diff --git a/404.html b/404.html index 5ec91744f..91fb619cc 100644 --- a/404.html +++ b/404.html @@ -6,22 +6,30 @@ 404 | ran - + - + + + + + + + + + - - + +
Skip to content

404

PAGE NOT FOUND

But if you don't change your direction, and if you keep looking, you may end up where you are heading.

Released under the MIT License.

- + \ No newline at end of file diff --git a/assets/app.4cfeba13.js b/assets/app.0729b6dc.js similarity index 75% rename from assets/app.4cfeba13.js rename to assets/app.0729b6dc.js index 301fcace5..27b6972d8 100644 --- a/assets/app.4cfeba13.js +++ b/assets/app.0729b6dc.js @@ -1,15 +1,15 @@ -import{a1 as v,I as S,a2 as Y,a3 as J,a4 as K,a5 as $,a6 as U,a7 as X,a8 as q,a9 as G,aa as Z,ab as W,d as V,u as ee,h as re,l as ie,ac as te,ad as ne,ae,af as oe}from"./chunks/framework.6fe2e870.js";import{t as pe}from"./chunks/theme.eee41b28.js";var se=Object.defineProperty,ce=(r,i,e)=>i in r?se(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,le=(r,i,e)=>(ce(r,typeof i!="symbol"?i+"":i,e),e);const E=[!1,"false",null,void 0],z=r=>{const i=r.hasAttribute("disabled"),e=r.getAttribute("disabled");return!!(i&&!E.includes(e))},L=(r,i)=>{const e=r.classList;e.contains(i)||e.add(i)},de=(r,i)=>{const e=r.querySelectorAll(`.${i}`);e.length>0&&e.forEach(t=>t.classList.remove(i))},kr=r=>new Promise((i,e)=>{const t=document.createElement("script");t.src=r,t.onload=function(){i({success:!0})},t.onerror=function(n){e({success:!1,error:n})},document.body.append(t)}),ve=(r,i={})=>{const{onProgress:e=()=>{},headers:t={},responseType:n="blob",method:a="GET",withCredentials:o=!1}=i;return new Promise((c,s)=>{const p=new XMLHttpRequest;p.open(a,r,!0),p.responseType=n,p.onload=()=>{const d=p.response,l=new File([d],d.name,{type:d.type});c(l)},p.onprogress=d=>{e&&e(d)},p.onerror=d=>{s(d)},p.withCredentials=o,t&&Object.keys(t).forEach(function(d){p.setRequestHeader(d,t[d])}),p.send()})},_=r=>{const i=r.backingStorePixelRatio||r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||1;return(window.devicePixelRatio||1)/i};function j(r){return class{constructor(e=r){le(this,"message"),this.message=e}}}var we=Object.defineProperty,xe=(r,i,e)=>i in r?we(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,k=(r,i,e)=>(xe(r,typeof i!="symbol"?i+"":i,e),e);const me=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}:host{position:relative;display:inline-block;font-weight:400;white-space:nowrap;text-align:center;background-image:none;border:1px solid transparent;box-shadow:0 2px #00000004;cursor:pointer;transition:all .3s cubic-bezier(.645,.045,.355,1);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;touch-action:manipulation;line-height:22px;font-size:14px;border-radius:2px;color:#000000d9;border-color:#d9d9d9;background:#fff;overflow:hidden;pointer-events:auto}:host,:host(:active),:host(:focus){outline:0}:host(:not([disabled]):hover){border-color:#1890ff;color:#1890ff}:host([type="primary"]){border-color:#1890ff;background-color:#1890ff;color:#fff}:host([type="primary"]:not([disabled])):after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="primary"]:not([disabled]):hover){background-color:#40a9ff;color:#fff}:host([type="warning"]){border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="warning"]:not([disabled])):after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="warning"]:not([disabled]):hover){border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="text"]){border:none}:host([disabled]){cursor:not-allowed;pointer-events:all;opacity:.6}:host(:not([disabled]):active):after{transform:translate(-50%,-50%) scale(0);opacity:.3;transition:0s}:host(:active) .btn:before{opacity:.2}:host(:not([disabled],[effect])):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}.btn{display:flex;justify-content:space-between;align-items:center;padding:4px 15px}.btn .icon{margin-right:2px} -`;function he(){if(typeof document<"u"&&!customElements.get("r-button")){class r extends HTMLElement{constructor(){super(),k(this,"_btn"),k(this,"_iconElement"),k(this,"_slot"),k(this,"_shadowDom"),k(this,"setIcon",()=>{if(this.icon){const{width:n,height:a}=this._slot.getBoundingClientRect(),o=Math.min(n,a);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",`${o-5}`)}}),k(this,"mousedown",n=>{if(!this.disabled||this.disabled==="false"){const{left:a,top:o}=this.getBoundingClientRect();this.style.setProperty("--ran-x",n.clientX-a+"px"),this.style.setProperty("--ran-y",n.clientY-o+"px")}}),k(this,"mouseLeave",()=>{setTimeout(()=>{this.style.removeProperty("--ran-x"),this.style.removeProperty("--ran-y")},300)}),this._slot=document.createElement("slot"),this._btn=document.createElement("div"),this._btn.setAttribute("class","btn"),this._btn.appendChild(this._slot),this._slot.setAttribute("class","slot");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=me,e.appendChild(t),this._shadowDom=e,e.appendChild(this._btn)}static get observedAttributes(){return["disabled","icon","effect","iconSize","sheet"]}get sheet(){return this.getAttribute("sheet")}set sheet(e){this.setAttribute("sheet",e||"")}get disabled(){return z(this)}set disabled(e){!e||e==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled","")}get iconSize(){return this.getAttribute("iconSize")}set iconSize(e){!e||e==="false"?this.removeAttribute("iconSize"):(this.setAttribute("iconSize",e),this.setIcon())}get icon(){return this.getAttribute("icon")}set icon(e){!e||e==="false"?this.removeAttribute("icon"):(this.setAttribute("icon",e),this.setIcon())}get effect(){return this.getAttribute("effect")}set effect(e){E.includes(e)||!e?this.removeAttribute("effect"):this.setAttribute("effect",e)}handlerExternalCss(){if(this.sheet)try{const e=new CSSStyleSheet;e.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[e]}catch{console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){this._btn.addEventListener("mousedown",this.mousedown),this._btn.addEventListener("mouseleave",this.mouseLeave),this.handlerExternalCss(),this.setIcon()}disconnectCallback(){this._btn.removeEventListener("mousedown",this.mousedown),this._btn.removeEventListener("mouseleave",this.mouseLeave)}attributeChangedCallback(e,t,n){e==="disabled"&&this._btn&&(!n||n==="false"?this._btn.setAttribute("disabled",""):this._btn.removeAttribute("disabled")),e==="icon"&&this._btn&&t!==n&&this.setIcon(),e==="iconSize"&&this._btn&&t!==n&&this._btn.setAttribute("iconSize",n),e==="sheet"&&this._shadowDom&&t!==n&&this.handlerExternalCss()}}return customElements.define("r-button",r),r}else return j("document is undefined or r-button is exist")}he();var fe=Object.defineProperty,be=(r,i,e)=>i in r?fe(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,g=(r,i,e)=>(be(r,typeof i!="symbol"?i+"":i,e),e);const ge=(r,i)=>{const e=r[i];return e?typeof e=="function"?e():Promise.resolve(e):new Promise((t,n)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(n.bind(null,new Error("Unknown variable dynamic import: "+i)))})},ue=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}:host{display:inline-flex}:host .icon{display:block}:host([spin]){animation-name:rotate;animation-duration:1.4s;animation-timing-function:linear;animation-iteration-count:infinite}@keyframes rotate{to{transform:rotate(360deg)}} -`,ke={};let C=ke;typeof process<"u"&&typeof C.Stats=="function"?C._identification=!0:C={_identification:!1,message:"require is not defined"};const ye=(r,i="text/xml")=>{if(window.DOMParser)return new window.DOMParser().parseFromString(r,i).documentElement;if(typeof window.ActiveXObject<"u"&&new window.ActiveXObject("Microsoft.XMLDOM")){const e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(r),e}};function ze(r,i,e,t,n){const a=i===void 0?void 0:i.key;return{sel:r,data:i,children:e,text:t,elm:n,key:a}}ze("",{},[],void 0,void 0);function Ae(){if(typeof window<"u"&&!customElements.get("r-icon")){class r extends HTMLElement{constructor(){super(),g(this,"_icon"),g(this,"_div"),g(this,"loadLocal",()=>new Promise((n,a)=>{ge(Object.assign({"../../assets/icons/add-user.svg":()=>v(()=>import("./chunks/add-user-d07564bd.11a32661.js"),[]),"../../assets/icons/book.svg":()=>v(()=>import("./chunks/book-2a5a596c.4c512d99.js"),[]),"../../assets/icons/check-circle-fill.svg":()=>v(()=>import("./chunks/check-circle-fill-62eaa796.e34c77e8.js"),[]),"../../assets/icons/check-circle.svg":()=>v(()=>import("./chunks/check-circle-2c986969.d1975c59.js"),[]),"../../assets/icons/close-circle-fill.svg":()=>v(()=>import("./chunks/close-circle-fill-b6906239.c047d020.js"),[]),"../../assets/icons/close-circle.svg":()=>v(()=>import("./chunks/close-circle-2afb6e94.ce6ebb78.js"),[]),"../../assets/icons/close.svg":()=>v(()=>import("./chunks/close-ee3ba1d1.a26e1d60.js"),[]),"../../assets/icons/eye-close.svg":()=>v(()=>import("./chunks/eye-close-bde3c1fc.84465181.js"),[]),"../../assets/icons/eye.svg":()=>v(()=>import("./chunks/eye-bd60afe1.bef263d6.js"),[]),"../../assets/icons/home.svg":()=>v(()=>import("./chunks/home-f824d8f4.125853a9.js"),[]),"../../assets/icons/info-circle-fill.svg":()=>v(()=>import("./chunks/info-circle-fill-3ab7660d.6e84f496.js"),[]),"../../assets/icons/info-circle.svg":()=>v(()=>import("./chunks/info-circle-59333e1c.0fcf2960.js"),[]),"../../assets/icons/loading.svg":()=>v(()=>import("./chunks/loading-407d8249.21ebf82e.js"),[]),"../../assets/icons/lock.svg":()=>v(()=>import("./chunks/lock-6d20715b.23e61a8a.js"),[]),"../../assets/icons/message.svg":()=>v(()=>import("./chunks/message-ee4fe153.d715e35c.js"),[]),"../../assets/icons/power-off.svg":()=>v(()=>import("./chunks/power-off-bbec6b5f.f3cdee00.js"),[]),"../../assets/icons/preview.svg":()=>v(()=>import("./chunks/preview-164a4944.3ea4f277.js"),[]),"../../assets/icons/setting.svg":()=>v(()=>import("./chunks/setting-735a1963.f740d380.js"),[]),"../../assets/icons/team.svg":()=>v(()=>import("./chunks/team-42573142.b6349320.js"),[]),"../../assets/icons/unlock.svg":()=>v(()=>import("./chunks/unlock-ae33c6f7.7ebd89aa.js"),[]),"../../assets/icons/user.svg":()=>v(()=>import("./chunks/user-b7098183.7f0f88ab.js"),[]),"../../assets/icons/warning-circle-fill.svg":()=>v(()=>import("./chunks/warning-circle-fill-e4be98bc.6feded44.js"),[]),"../../assets/icons/warning-circle.svg":()=>v(()=>import("./chunks/warning-circle-536d4749.a9e42ce5.js"),[])}),`../../assets/icons/${this.name}.svg`).then(o=>{if(o&&o.default&&o.default._identification){const{data:c}=o.default;this._icon&&this._div.removeChild(this._icon),this._icon=ye(c,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),n())}else this.loadNs(),a(` - couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)}).catch(o=>{this.loadNs()})})),g(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 n="http://www.w3.org/1999/xlink",a=document.createElementNS(n,"use");a.setAttributeNS(n,"xlink:href",`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(a),this._div.appendChild(this._icon)}),g(this,"setIcon",async()=>{this.name&&this.loadLocal()}),g(this,"setSize",()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))}),g(this,"setColor",()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))}),g(this,"setSpin",()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)}),this._div=document.createElement("div"),this._div.setAttribute("class","icon");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=ue,e.appendChild(t),e.appendChild(this._div)}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(e){e&&this.setAttribute("name",e)}get size(){return this.getAttribute("size")}set size(e){e&&this.setAttribute("size",e)}get color(){return this.getAttribute("color")}set color(e){e&&this.setAttribute("color",e)}get spin(){return this.getAttribute("spin")}set spin(e){e!=null&&this.setAttribute("spin",e)}connectedCallback(){this.setIcon()}attributeChangedCallback(e,t,n){n!==t&&(e==="name"&&this.setIcon(),e==="size"&&this.setSize(),e==="color"&&this.setColor(),e==="spin"&&this.setSpin())}}customElements.define("r-icon",r)}}Ae();var _e=Object.defineProperty,Ee=(r,i,e)=>i in r?_e(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,R=(r,i,e)=>(Ee(r,typeof i!="symbol"?i+"":i,e),e);const Ce=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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} -`,Pe=` +import{a1 as v,I as S,a2 as J,a3 as K,a4 as $,a5 as U,a6 as X,a7 as q,a8 as G,a9 as Z,aa as W,ab as V,d as ee,u as re,h as ie,l as te,ac as ne,ad as ae,ae as oe,af as pe}from"./chunks/framework.6fe2e870.js";import{t as se}from"./chunks/theme.eee41b28.js";var ce=Object.defineProperty,le=(r,i,e)=>i in r?ce(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,de=(r,i,e)=>(le(r,typeof i!="symbol"?i+"":i,e),e);const E=[!1,"false",null,void 0],z=r=>{const i=r.hasAttribute("disabled"),e=r.getAttribute("disabled");return!!(i&&!E.includes(e))},L=(r,i)=>{const e=r.classList;e.contains(i)||e.add(i)},ve=(r,i)=>{const e=r.querySelectorAll(`.${i}`);e.length>0&&e.forEach(t=>t.classList.remove(i))},yr=r=>new Promise((i,e)=>{const t=document.createElement("script");t.src=r,t.onload=function(){i({success:!0})},t.onerror=function(n){e({success:!1,error:n})},document.body.append(t)}),we=(r,i={})=>{const{onProgress:e=()=>{},headers:t={},responseType:n="blob",method:a="GET",withCredentials:o=!1}=i;return new Promise((c,s)=>{const p=new XMLHttpRequest;p.open(a,r,!0),p.responseType=n,p.onload=()=>{const d=p.response,l=new File([d],d.name,{type:d.type});c(l)},p.onprogress=d=>{e&&e(d)},p.onerror=d=>{s(d)},p.withCredentials=o,t&&Object.keys(t).forEach(function(d){p.setRequestHeader(d,t[d])}),p.send()})},_=r=>{const i=r.backingStorePixelRatio||r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||1;return(window.devicePixelRatio||1)/i};function j(r){return class{constructor(e=r){de(this,"message"),this.message=e}}}const R=function(){if(typeof window<"u"){const r=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(r)?"ipad":/android/.test(r)?"android":/iphone/.test(r)?"iphone":"pc"}return"pc"}();var xe=Object.defineProperty,me=(r,i,e)=>i in r?xe(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,k=(r,i,e)=>(me(r,typeof i!="symbol"?i+"":i,e),e);const he=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}:host{position:relative;display:inline-block;font-weight:400;white-space:nowrap;text-align:center;background-image:none;border:1px solid transparent;box-shadow:0 2px #00000004;cursor:pointer;transition:all .3s cubic-bezier(.645,.045,.355,1);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;touch-action:manipulation;line-height:22px;font-size:14px;border-radius:2px;color:#000000d9;border-color:#d9d9d9;background:#fff;overflow:hidden;pointer-events:auto}:host,:host(:active),:host(:focus){outline:0}:host(:not([disabled]):hover){border-color:#1890ff;color:#1890ff}:host([type="primary"]){border-color:#1890ff;background-color:#1890ff;color:#fff}:host([type="primary"]:not([disabled])):after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="primary"]:not([disabled]):hover){background-color:#40a9ff;color:#fff}:host([type="warning"]){border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="warning"]:not([disabled])):after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="warning"]:not([disabled]):hover){border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="text"]){border:none}:host([disabled]){cursor:not-allowed;pointer-events:all;opacity:.6}:host(:not([disabled]):active):after{transform:translate(-50%,-50%) scale(0);opacity:.3;transition:0s}:host(:active) .btn:before{opacity:.2}:host(:not([disabled],[effect])):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}.btn{display:flex;justify-content:space-between;align-items:center;padding:4px 15px}.btn .icon{margin-right:2px} +`;function fe(){if(typeof document<"u"&&!customElements.get("r-button")){class r extends HTMLElement{constructor(){super(),k(this,"_btn"),k(this,"_iconElement"),k(this,"_slot"),k(this,"_shadowDom"),k(this,"setIcon",()=>{if(this.icon){const{width:n,height:a}=this._slot.getBoundingClientRect(),o=Math.min(n,a);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",`${o-5}`)}}),k(this,"mousedown",n=>{if(R==="pc"&&(!this.disabled||this.disabled==="false")){const{left:a,top:o}=this.getBoundingClientRect();this.style.setProperty("--ran-x",n.clientX-a+"px"),this.style.setProperty("--ran-y",n.clientY-o+"px")}}),k(this,"mouseLeave",()=>{R==="pc"&&setTimeout(()=>{this.style.removeProperty("--ran-x"),this.style.removeProperty("--ran-y")},300)}),this._slot=document.createElement("slot"),this._btn=document.createElement("div"),this._btn.setAttribute("class","btn"),this._btn.appendChild(this._slot),this._slot.setAttribute("class","slot");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=he,e.appendChild(t),this._shadowDom=e,e.appendChild(this._btn)}static get observedAttributes(){return["disabled","icon","effect","iconSize","sheet"]}get sheet(){return this.getAttribute("sheet")}set sheet(e){this.setAttribute("sheet",e||"")}get disabled(){return z(this)}set disabled(e){!e||e==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled","")}get iconSize(){return this.getAttribute("iconSize")}set iconSize(e){!e||e==="false"?this.removeAttribute("iconSize"):(this.setAttribute("iconSize",e),this.setIcon())}get icon(){return this.getAttribute("icon")}set icon(e){!e||e==="false"?this.removeAttribute("icon"):(this.setAttribute("icon",e),this.setIcon())}get effect(){return this.getAttribute("effect")}set effect(e){E.includes(e)||!e?this.removeAttribute("effect"):this.setAttribute("effect",e)}handlerExternalCss(){if(this.sheet)try{const e=new CSSStyleSheet;e.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[e]}catch{console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){this._btn.addEventListener("mousedown",this.mousedown),this._btn.addEventListener("mouseleave",this.mouseLeave),this.handlerExternalCss(),this.setIcon()}disconnectCallback(){this._btn.removeEventListener("mousedown",this.mousedown),this._btn.removeEventListener("mouseleave",this.mouseLeave)}attributeChangedCallback(e,t,n){e==="disabled"&&this._btn&&(!n||n==="false"?this._btn.setAttribute("disabled",""):this._btn.removeAttribute("disabled")),e==="icon"&&this._btn&&t!==n&&this.setIcon(),e==="iconSize"&&this._btn&&t!==n&&this._btn.setAttribute("iconSize",n),e==="sheet"&&this._shadowDom&&t!==n&&this.handlerExternalCss()}}return customElements.define("r-button",r),r}else return j("document is undefined or r-button is exist")}fe();var be=Object.defineProperty,ge=(r,i,e)=>i in r?be(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,g=(r,i,e)=>(ge(r,typeof i!="symbol"?i+"":i,e),e);const ue=(r,i)=>{const e=r[i];return e?typeof e=="function"?e():Promise.resolve(e):new Promise((t,n)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(n.bind(null,new Error("Unknown variable dynamic import: "+i)))})},ke=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}:host{display:inline-flex}:host .icon{display:block}:host([spin]){animation-name:rotate;animation-duration:1.4s;animation-timing-function:linear;animation-iteration-count:infinite}@keyframes rotate{to{transform:rotate(360deg)}} +`,ye={};let C=ye;typeof process<"u"&&typeof C.Stats=="function"?C._identification=!0:C={_identification:!1,message:"require is not defined"};const ze=(r,i="text/xml")=>{if(window.DOMParser)return new window.DOMParser().parseFromString(r,i).documentElement;if(typeof window.ActiveXObject<"u"&&new window.ActiveXObject("Microsoft.XMLDOM")){const e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(r),e}};function Ae(r,i,e,t,n){const a=i===void 0?void 0:i.key;return{sel:r,data:i,children:e,text:t,elm:n,key:a}}Ae("",{},[],void 0,void 0);function _e(){if(typeof window<"u"&&!customElements.get("r-icon")){class r extends HTMLElement{constructor(){super(),g(this,"_icon"),g(this,"_div"),g(this,"loadLocal",()=>new Promise((n,a)=>{ue(Object.assign({"../../assets/icons/add-user.svg":()=>v(()=>import("./chunks/add-user-d07564bd.11a32661.js"),[]),"../../assets/icons/book.svg":()=>v(()=>import("./chunks/book-2a5a596c.4c512d99.js"),[]),"../../assets/icons/check-circle-fill.svg":()=>v(()=>import("./chunks/check-circle-fill-62eaa796.e34c77e8.js"),[]),"../../assets/icons/check-circle.svg":()=>v(()=>import("./chunks/check-circle-2c986969.d1975c59.js"),[]),"../../assets/icons/close-circle-fill.svg":()=>v(()=>import("./chunks/close-circle-fill-b6906239.c047d020.js"),[]),"../../assets/icons/close-circle.svg":()=>v(()=>import("./chunks/close-circle-2afb6e94.ce6ebb78.js"),[]),"../../assets/icons/close.svg":()=>v(()=>import("./chunks/close-ee3ba1d1.a26e1d60.js"),[]),"../../assets/icons/eye-close.svg":()=>v(()=>import("./chunks/eye-close-bde3c1fc.84465181.js"),[]),"../../assets/icons/eye.svg":()=>v(()=>import("./chunks/eye-bd60afe1.bef263d6.js"),[]),"../../assets/icons/home.svg":()=>v(()=>import("./chunks/home-f824d8f4.125853a9.js"),[]),"../../assets/icons/info-circle-fill.svg":()=>v(()=>import("./chunks/info-circle-fill-3ab7660d.6e84f496.js"),[]),"../../assets/icons/info-circle.svg":()=>v(()=>import("./chunks/info-circle-59333e1c.0fcf2960.js"),[]),"../../assets/icons/loading.svg":()=>v(()=>import("./chunks/loading-407d8249.21ebf82e.js"),[]),"../../assets/icons/lock.svg":()=>v(()=>import("./chunks/lock-6d20715b.23e61a8a.js"),[]),"../../assets/icons/message.svg":()=>v(()=>import("./chunks/message-ee4fe153.d715e35c.js"),[]),"../../assets/icons/power-off.svg":()=>v(()=>import("./chunks/power-off-bbec6b5f.f3cdee00.js"),[]),"../../assets/icons/preview.svg":()=>v(()=>import("./chunks/preview-164a4944.3ea4f277.js"),[]),"../../assets/icons/setting.svg":()=>v(()=>import("./chunks/setting-735a1963.f740d380.js"),[]),"../../assets/icons/team.svg":()=>v(()=>import("./chunks/team-42573142.b6349320.js"),[]),"../../assets/icons/unlock.svg":()=>v(()=>import("./chunks/unlock-ae33c6f7.7ebd89aa.js"),[]),"../../assets/icons/user.svg":()=>v(()=>import("./chunks/user-b7098183.7f0f88ab.js"),[]),"../../assets/icons/warning-circle-fill.svg":()=>v(()=>import("./chunks/warning-circle-fill-e4be98bc.6feded44.js"),[]),"../../assets/icons/warning-circle.svg":()=>v(()=>import("./chunks/warning-circle-536d4749.a9e42ce5.js"),[])}),`../../assets/icons/${this.name}.svg`).then(o=>{if(o&&o.default&&o.default._identification){const{data:c}=o.default;this._icon&&this._div.removeChild(this._icon),this._icon=ze(c,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),n())}else this.loadNs(),a(` + couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)}).catch(o=>{this.loadNs()})})),g(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 n="http://www.w3.org/1999/xlink",a=document.createElementNS(n,"use");a.setAttributeNS(n,"xlink:href",`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(a),this._div.appendChild(this._icon)}),g(this,"setIcon",async()=>{this.name&&this.loadLocal()}),g(this,"setSize",()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))}),g(this,"setColor",()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))}),g(this,"setSpin",()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)}),this._div=document.createElement("div"),this._div.setAttribute("class","icon");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=ke,e.appendChild(t),e.appendChild(this._div)}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(e){e&&this.setAttribute("name",e)}get size(){return this.getAttribute("size")}set size(e){e&&this.setAttribute("size",e)}get color(){return this.getAttribute("color")}set color(e){e&&this.setAttribute("color",e)}get spin(){return this.getAttribute("spin")}set spin(e){e!=null&&this.setAttribute("spin",e)}connectedCallback(){this.setIcon()}attributeChangedCallback(e,t,n){n!==t&&(e==="name"&&this.setIcon(),e==="size"&&this.setSize(),e==="color"&&this.setColor(),e==="spin"&&this.setSpin())}}customElements.define("r-icon",r)}}_e();var Ee=Object.defineProperty,Ce=(r,i,e)=>i in r?Ee(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,M=(r,i,e)=>(Ce(r,typeof i!="symbol"?i+"":i,e),e);const Pe=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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} +`,Se=` data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8u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NRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg== -`;function Se(){if(typeof window<"u"&&!customElements.get("r-img")){class r extends HTMLElement{constructor(){super(),R(this,"_image"),R(this,"_container"),this._container=document.createElement("div"),this._container.setAttribute("class","r-image");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=Ce,e.appendChild(t),e.appendChild(this._container)}static get observedAttributes(){return["fallback"]}get fallback(){return this.getAttribute("fallback")||Pe}set fallback(e){e?this.setAttribute("fallback",e):this.removeAttribute("fallback")}listenFallback(e,t){e==="fallback"&&this._image&&(t?this._image.setAttribute("fallback",t):this._image.removeAttribute("fallback"))}connectedCallback(){const e=this.getAttribute("src")||"";this._image=new Image,this._image.src=e,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(e,t,n){this.listenFallback(e,n)}}customElements.define("r-img",r)}}Se();var je=Object.defineProperty,Le=(r,i,e)=>i in r?je(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,y=(r,i,e)=>(Le(r,typeof i!="symbol"?i+"":i,e),e);const Re=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}.input{position:relative;display:flex;width:100%;min-width:0;padding:2px 8px;color:#000000d9;font-size:12px;line-height:1.5715;background-color:#fff;background-image:none;border-width:1px;border-style:solid;border-color:#d9d9d9;border-radius:2px;transition:all .3s}.input:active{border-color:#40a9ff;box-shadow:0 0 0 2px #1890ff33;border-right-width:1px;outline:0}.input:hover{border-color:#40a9ff;border-right-width:1px}.input>.input-main:hover~.input-label{color:#40a9ff}.input[value]>.input-label{transform:translateY(calc(-50% - .43em)) scale(.8);color:#00000040}.input[status=error]{border-color:#ff4d4f}.input[status=error]>.input-main~.input-label{color:#ff4d4f}.input[status=warning]{border-color:#ff7875}.input[status=warning]>.input-main~.input-label{color:#ff7875}.input[disabled]{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.input[disabled]>.input-main{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.input[disabled]>.input-main~.input-label{color:#00000040;background-color:#f5f5f5}.input[disabled]>.input-label{color:#999;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed}.input-main{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.5715;background-color:#fff;background-image:none;transition:all .3s}.input-main:focus,.input-main:hover{border:none;outline:0}.input-main::placeholder{color:#999}.input-main:placeholder-shown~.input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.input-main:focus~.input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.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} -`;function Me(){if(typeof window<"u"&&!customElements.get("r-input")){class r extends HTMLElement{constructor(){super(),y(this,"_container"),y(this,"_label"),y(this,"_input"),y(this,"_icon"),y(this,"customInput",n=>{n.stopPropagation();const a=n.target;this.value=a?a.value:"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("Input",{detail:{value:this.value}}))}),y(this,"customChange",()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("Change",{detail:{value:this.value}}))}),y(this,"dealIcon",()=>{if(!this._icon){this._icon=document.createElement("r-icon");const{width:n,height:a}=this._input.getBoundingClientRect(),o=Math.min(n,a);this._icon.setAttribute("size",`${o}`),this._input.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)});const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=Re,e.appendChild(t),this._container=document.createElement("div"),this._container.setAttribute("class","input"),this._input=document.createElement("input"),this._input.setAttribute("class","input-main"),this._container.appendChild(this._input),e.appendChild(this._container)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","status"]}get value(){return this.getAttribute("value")}set value(e){!z(this)&&e?(this.setAttribute("value",e),this._container.setAttribute("value",e)):(this.removeAttribute("value"),this._container.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")}set placeholder(e){e?this.setAttribute("placeholder",e):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")}set required(e){!e||e==="false"?this.removeAttribute("required"):this.setAttribute("required","")}get disabled(){return z(this)}set disabled(e){E.includes(e)?(this.removeAttribute("disabled"),this._container.removeAttribute("disabled"),this._input.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._container.setAttribute("disabled",""),this._input.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get status(){return this.getAttribute("status")||""}set status(e){e?(this.setAttribute("status",e),this._container.setAttribute("status",e)):(this.removeAttribute("status"),this._container.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(e){this.setAttribute("name",e)}get min(){return this.getAttribute("min")||""}set min(e){this.type==="number"&&this.setAttribute("min",e)}get max(){return this.getAttribute("max")||""}set max(e){this.type==="number"&&this.setAttribute("max",e)}get step(){return this.getAttribute("step")||""}set step(e){this.type==="number"&&this.setAttribute("step",e)}get icon(){return this.getAttribute("icon")}set icon(e){e?this.setAttribute("icon",e):this.removeAttribute("icon")}get type(){return this.getAttribute("type")}set type(e){e?this.setAttribute("type",e):this.removeAttribute("type")}listenPlaceholder(e,t){e==="placeholder"&&this._input&&(t!=null?this._input.setAttribute("placeholder",t):this._input.removeAttribute("placeholder"))}listenLabel(e,t){e==="label"&&this._input&&(t!=null?this._label?this._label.innerHTML=t:(this._label=document.createElement("label"),this._label.innerHTML=t,this._label.setAttribute("class","input-label"),this._container.appendChild(this._label)):(this._container.removeAttribute("label"),this._label&&(this._container.removeChild(this._label),this._label=void 0)))}listenType(e,t){e==="type"&&this._input&&(t?this._input.setAttribute("type",t):(this._input.removeAttribute("type"),this._input.removeAttribute("min"),this._input.removeAttribute("max"),this._input.removeAttribute("step")))}listenStatus(e,t){e==="status"&&this._container&&(t?this._container.setAttribute("status",t):this._container.removeAttribute("status"))}listenDisabled(e,t){e==="disabled"&&this._container&&(E.includes(t)?this._container.removeAttribute("disabled"):(this._container.setAttribute("disabled",""),this._input.setAttribute("disabled","")))}listenIcon(e,t,n){e==="icon"&&t&&t!==n&&(this.removeAttribute("label"),this.setAttribute("icon",t),this.dealIcon())}listenEvent(e,t,n){this.listenPlaceholder(e,n),this.listenLabel(e,n),this.listenStatus(e,n),this.listenDisabled(e,n),this.listenIcon(e,n,t)}connectedCallback(){this.value&&(this._input.value=this.value,this._container.setAttribute("value",this.value)),this.status&&this._container.setAttribute("status",this.status),z(this)&&(this._container.setAttribute("disabled",""),this._input.setAttribute("disabled","")),this.type&&this._input.setAttribute("type",this.type),this._input.addEventListener("input",this.customInput),document.readyState==="complete"&&this.dealIcon()}disconnectCallback(){this._input.removeEventListener("input",this.customInput)}attributeChangedCallback(e,t,n){this.listenEvent(e,t,n)}}return customElements.define("r-input",r),r}else return j("document is undefined or r-input is exist")}Me();var Ie=Object.defineProperty,Be=(r,i,e)=>i in r?Ie(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,u=(r,i,e)=>(Be(r,typeof i!="symbol"?i+"":i,e),e);const Qe=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}:host([type="toast"]){--ranui-message-background: rgba(0, 0, 0, .7);--ranui-message-color: #fff;--ranui-message-border-radius: 7px}.message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}.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}.message-notice-content-info{align-items:center;display:flex}.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} -`,M=300,I=3e3,Te=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),De=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#1890ff"],["toast","rgba(0, 0, 0, 0.7)"]]);function He(){if(typeof window<"u"&&!customElements.get("r-message")){class r extends HTMLElement{constructor(){super(),u(this,"_info"),u(this,"_notice"),u(this,"_content"),u(this,"_icon"),u(this,"_span"),u(this,"timeId"),u(this,"close"),u(this,"setIcon",c=>{var s,p,d,l;const w=Te.get(c),x=De.get(c);w&&((s=this._icon)==null||s.setAttribute("name",w),(p=this._icon)==null||p.style.setProperty("margin-right","8px"),(d=this._icon)==null||d.setAttribute("size","18"),x&&((l=this._icon)==null||l.setAttribute("color",x)))}),this._notice=document.createElement("div"),this._notice.setAttribute("class","message-notice"),this._content=document.createElement("div"),this._content.setAttribute("class","message-notice-content"),this._info=document.createElement("div"),this._info.setAttribute("class","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 a=this.attachShadow({mode:"closed"}),o=document.createElement("style");o.textContent=Qe,a.appendChild(o),a.appendChild(this._notice)}static get observedAttributes(){return["type","content"]}get type(){return this.getAttribute("type")}set type(a){a&&this.setAttribute("type",a)}get content(){return this.getAttribute("content")}set content(a){a&&this.setAttribute("content",a)}attributeChangedCallback(a,o,c){a==="content"&&o!==c&&(this._span.textContent=c),a==="type"&&o!==c&&this.setIcon(c)}}customElements.define("r-message",r);const i=document.createElement("div"),e=document.createElement("div");e.setAttribute("class","ranui-message"),document.body.appendChild(i),i.appendChild(e);const t=n=>a=>{const o=new r;o.setAttribute("class","message"),o.timeId&&clearTimeout(o.timeId),o.setAttribute("type",n);let c=I,s;typeof a=="string"?o.setAttribute("content",a):(o.setAttribute("content",a.content),s=a.close,c=a.duration||I);const p=setTimeout(()=>{o.classList.remove("message-in"),o.classList.add("message-leave"),clearTimeout(p)},c-M);o.timeId=setTimeout(()=>{o.classList.remove("message-leave"),e.removeChild(o),s&&s()},c),e.appendChild(o),o.classList.add("message-in"),setTimeout(()=>{o.classList.remove("message-in")},M)};return{info:t("info"),success:t("success"),error:t("error"),warning:t("warning"),toast:t("toast")}}}const B=He();typeof window<"u"&&B&&(window.message=B);var Oe=Object.defineProperty,Ne=(r,i,e)=>i in r?Oe(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,h=(r,i,e)=>(Ne(r,typeof i!="symbol"?i+"":i,e),e);const Fe=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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-slot{display:block}:host{cursor:pointer} -`,Ye="application/vnd.openxmlformats-officedocument.presentationml.presentation",Je="application/pdf",Ke="application/vnd.openxmlformats-officedocument.wordprocessingml.document",Q="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",T="application/vnd.ms-excel";async function $e(){if(typeof window<"u"&&!customElements.get("r-preview")){const{renderPptx:r}=await v(()=>import("./chunks/index-1ffff466.53d85534.js"),["assets/chunks/index-1ffff466.53d85534.js","assets/chunks/commonjs-dynamic-modules-2ceabb0b.23156833.js","assets/chunks/jszip.min-97cf7c6a.4dec9da4.js","assets/chunks/colz-746223ab.12984b03.js"]),{renderDocx:i}=await v(()=>import("./chunks/docx-5262a8f1.7b8bae14.js"),["assets/chunks/docx-5262a8f1.7b8bae14.js","assets/chunks/jszip.min-97cf7c6a.4dec9da4.js","assets/chunks/commonjs-dynamic-modules-2ceabb0b.23156833.js"]),{renderPdf:e}=await v(()=>import("./chunks/pdf-1f534069.cfd1b720.js"),["assets/chunks/pdf-1f534069.cfd1b720.js","assets/chunks/framework.6fe2e870.js","assets/chunks/theme.eee41b28.js"]),{renderExcel:t}=await v(()=>import("./chunks/index-714a1eb8.0992a4b8.js"),["assets/chunks/index-714a1eb8.0992a4b8.js","assets/chunks/commonjs-dynamic-modules-2ceabb0b.23156833.js","assets/chunks/colz-746223ab.12984b03.js"]),n=(s,p)=>new Promise((d,l)=>{const w=new FileReader;w.readAsArrayBuffer(s),w.onload=()=>{var x;if(w.result&&p){const f={pptx:w.result,resultElement:p};(x=r(f))==null||x.then(()=>{d()})}},w.onerror=x=>{l(x)},w.onabort=x=>{l(x)}}),a=(s,p)=>Promise.resolve().then(()=>i({buffer:s,bodyContainer:p})),o=new Map([[Je,e],[Ye,n],[Ke,a],[Q,t],[T,t]]);class c extends HTMLElement{constructor(){super(),h(this,"_loadingText"),h(this,"preview"),h(this,"previewContext"),h(this,"_slot"),h(this,"_div"),h(this,"_loadingElement"),h(this,"createLoading",()=>{this._loadingElement=document.createElement("div"),this._loadingElement.setAttribute("class","r-preview-loading");const l=document.createElement("r-icon");return l.setAttribute("name","loading"),l.setAttribute("size","100"),l.setAttribute("color","#1E90FF"),l.setAttribute("spin",""),this._loadingText=document.createElement("div"),this._loadingElement.appendChild(l),this._loadingText.setAttribute("class","r-preview-loading-text"),this._loadingElement.appendChild(this._loadingText),this._loadingElement}),h(this,"onProgress",l=>{const w=l.loaded/l.total*100,x=Math.min(99,w).toFixed(2)+"%";this._loadingText&&this._loadingElement&&(this._loadingText.innerText=`Loading ${x}`,w>=100&&setTimeout(()=>{var f;(f=this.preview)==null||f.removeChild(this._loadingElement)},300))}),h(this,"handleFile",async l=>{try{typeof l=="string"&&(l=await ve(l,{onProgress:this.onProgress}));const{type:w}=l,x=o.get(w);x&&this.previewContext&&(w===Q||w===T?this.previewContext.style.setProperty("width","100%"):this.previewContext.style.setProperty("width","100%"),x(l,this.previewContext))}catch(w){console.log("handleFile",w)}}),h(this,"closePreview",()=>{this.preview&&(document.body.removeChild(this.preview),this.preview=void 0)}),h(this,"showPreview",()=>{var l;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");const w=document.createElement("div");if(w.setAttribute("class","r-preview-options"),this.closeable!=="false"){const f=document.createElement("r-icon");f.setAttribute("class","r-preview-options-close"),f.setAttribute("name","close-circle-fill"),f.setAttribute("size","40"),f.addEventListener("click",this.closePreview),w.appendChild(f)}const x=document.createElement("div");x.setAttribute("class","r-preview-contain"),this.previewContext=document.createElement("div"),this.previewContext.setAttribute("class","r-preview-context"),x.appendChild(this.previewContext),this.preview.appendChild(w),(l=this.preview)==null||l.appendChild(x),this._loadingElement=this.createLoading(),this.preview.appendChild(this._loadingElement),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 p=this.attachShadow({mode:"closed"}),d=document.createElement("style");d.textContent=Fe,p.appendChild(d),p.appendChild(this._div)}static get observedAttributes(){return["src","closeable"]}get label(){return this.getAttribute("label")}set label(p){p&&this.setAttribute("label",p)}get src(){return this.getAttribute("src")}set src(p){p&&this.setAttribute("src",p)}get closeable(){return this.getAttribute("closeable")}set closeable(p){p&&this.setAttribute("closeable",p)}connectedCallback(){this.preview=document.getElementById("r-preview-mask"),this.addEventListener("click",this.showPreview)}disconnectedCallback(){this.removeEventListener("click",this.showPreview)}attributeChangedCallback(p,d,l){l!==d&&p==="src"&&l&&(this.setAttribute("src",l),this.showPreview())}}customElements.define("r-preview",c)}}$e();var Ue=Object.defineProperty,Xe=(r,i,e)=>i in r?Ue(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,qe=(r,i,e)=>(Xe(r,typeof i!="symbol"?i+"":i,e),e);const Ge=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background:rgba(0,0,0,.06);border-radius:4px}.skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:linear-gradient(90deg,rgba(0,0,0,.06) 25%,rgba(0,0,0,.15) 37%,rgba(0,0,0,.06) 63%);animation-name:skeleton;animation-duration:1.4s;animation-timing-function:ease;animation-iteration-count:infinite;content:""} -`;function Ze(){if(typeof window<"u"&&!customElements.get("r-skeleton")){class r extends HTMLElement{constructor(){super(),qe(this,"_div"),this._div=document.createElement("div"),this._div.setAttribute("class","skeleton");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=Ge,e.appendChild(t),e.appendChild(this._div)}static get observedAttributes(){return["disabled"]}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(e,t,n){}}window.customElements.define("r-skeleton",r)}}Ze();var We=Object.defineProperty,Ve=(r,i,e)=>i in r?We(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,P=(r,i,e)=>(Ve(r,typeof i!="symbol"?i+"":i,e),e);const er=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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} -`;function rr(){if(typeof window<"u"&&!customElements.get("r-tab")){class r extends HTMLElement{constructor(){super(),P(this,"_div"),P(this,"parent"),P(this,"initAttribute",()=>{var n,a,o;this.parent=this.parentNode,this.key&&((n=this.parent)==null||n.updateAttribute(this.key,"icon",this.icon)),this.key&&((a=this.parent)==null||a.updateAttribute(this.key,"iconSize",this.iconSize)),this.key&&((o=this.parent)==null||o.updateAttribute(this.key,"effect",this.effect))}),this._div=document.createElement("slot");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=er,e.appendChild(t),e.appendChild(this._div)}static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize"]}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get icon(){return this.getAttribute("icon")}set icon(e){!e||e==="false"?this.removeAttribute("icon"):this.setAttribute("icon",e)}get iconSize(){return this.getAttribute("iconSize")}set iconSize(e){!e||e==="false"?this.removeAttribute("iconSize"):this.setAttribute("iconSize",e)}get key(){return this.getAttribute("r-key")}set key(e){e?this.setAttribute("r-key",e):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(e){!e||e==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled",e)}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}onClick(e){console.log("e",e)}connectedCallback(){this._div.addEventListener("click",this.onClick),document.addEventListener("DOMContentLoaded",this.initAttribute)}disconnectCallback(){document.removeEventListener("DOMContentLoaded",this.initAttribute)}attributeChangedCallback(e,t,n){var a,o,c,s,p;t!==n&&this.key&&((a=this.parent)!=null&&a.updateAttribute)&&(e==="icon"&&((o=this.parent)==null||o.updateAttribute(this.key,"icon",n)),e==="iconSize"&&((c=this.parent)==null||c.updateAttribute(this.key,"iconSize",n)),e==="effect"&&((s=this.parent)==null||s.updateAttribute(this.key,"effect",n)),e==="disabled"&&((p=this.parent)==null||p.updateAttribute(this.key,"disabled",n)))}}return customElements.define("r-tab",r),r}}rr();var ir=Object.defineProperty,tr=(r,i,e)=>i in r?ir(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,m=(r,i,e)=>(tr(r,typeof i!="symbol"?i+"":i,e),e);const nr=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}.tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.tab-header_nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.tab-header_nav::-webkit-scrollbar{display:none}.tab-header_nav__item{flex-shrink:0}.tab-header_nav .active{color:var(--active-color, #1890ff)}.tab-header_line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--line-color, #1890ff);transition:.2s}.tab-content{overflow:hidden}.tab-content_wrap{display:flex;width:100%;height:100%;transition:.2s}:host([type="line"]) .tab-header_nav__item{border:solid 1px transparent}:host([type="line"]) .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"]) .tab-header_line{transition:none;visibility:hidden}:host([type="line"]) .tab-header_line:after,:host([type="line"]) .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"]) .tab-header_line:after{left:100%}:host([type="line"]) .tab-header_line:before{right:100%}:host([align="center"]) .tab-header_nav{justify-content:center}:host([align="center"]) .tab-header_line{left:50%}:host([align="end"]) .tab-header_nav{justify-content:flex-end} -`;function ar(){if(typeof window<"u"&&!customElements.get("r-tabs")){class r extends HTMLElement{constructor(){super(),m(this,"_container"),m(this,"_header"),m(this,"_nav"),m(this,"_line"),m(this,"_content"),m(this,"_wrap"),m(this,"_slot"),m(this,"tabHeaderKeyMapIndex"),m(this,"initTabHeaderKeyMapIndex",(n,a)=>{if(this.tabHeaderKeyMapIndex[n])throw new Error("tab 组件的 key 值存在重复, 或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[n]=a}),m(this,"initTabLineAlignCenter",()=>{const{length:n}=this._nav.children;let a=0;for(let o=0;o{const{length:n}=this._nav.children;let a=0;for(let o=0;o{if(n){const a=this.tabHeaderKeyMapIndex[n],o=this._nav.children[a],{width:c=0}=o.getBoundingClientRect();this._line.style.setProperty("width",`${c}px`);let s=0;for(let p=0;p{if(n){const a=this.tabHeaderKeyMapIndex[n];this._wrap.style.setProperty("transform",`translateX(${a*-100}%)`)}}),m(this,"clickTabHead",n=>{const a=n.target,o=a.getAttribute("r-key");!z(a)&&o&&(this.setAttribute("active",o),this.setTabLine(o),this.setTabContent(o),de(this._nav,"active"),L(a,"active"))}),m(this,"updateAttribute",(n,a,o="")=>{var c,s;const p=this.tabHeaderKeyMapIndex[n];n&&o&&this._nav.children[p]?(c=this._nav.children[p])==null||c.setAttribute(a,o):(s=this._nav.children[p])==null||s.removeAttribute(a)}),m(this,"initActive",()=>{const n=[...this._nav.children],a=n.filter(p=>!z(p));let o;if(this.active!=null&&(o=a.find(p=>p.getAttribute("r-key")===this.active),o==null||o.setAttribute("r-key",this.active)),o||(o=a.shift()),!o)return;const c=n.findIndex(p=>p===o),s=(o==null?void 0:o.getAttribute("r-key"))||`${c}`;s!=null&&(this.setAttribute("active",`${s}`),L(o,"active"),this.setTabContent(s),setTimeout(()=>{this.setTabLine(s)},200))}),m(this,"listenSlotChange",()=>{this._slot.assignedElements().forEach((a,o)=>{const c=this.createTabHeader(a,o);this._nav.appendChild(c),c.addEventListener("click",this.clickTabHead)}),this.initActive(),this.align&&(this.align==="center"&&this.initTabLineAlignCenter(),this.align==="end"&&this.initTabLineAlignEnd())}),m(this,"initTab",()=>{this._slot.addEventListener("slotchange",this.listenSlotChange)}),m(this,"unloadTab",()=>{this._slot.removeEventListener("slotchange",this.listenSlotChange)}),this._container=document.createElement("div"),this._container.setAttribute("class","tab"),this._header=document.createElement("div"),this._header.setAttribute("class","tab-header"),this._nav=document.createElement("div"),this._nav.setAttribute("class","tab-header_nav"),this._line=document.createElement("div"),this._line.setAttribute("class","tab-header_line"),this._content=document.createElement("div"),this._content.setAttribute("class","tab-content"),this._wrap=document.createElement("div"),this._wrap.setAttribute("class","tab-content_wrap"),this._slot=document.createElement("slot"),this._wrap.appendChild(this._slot),this._content.appendChild(this._wrap),this._header.appendChild(this._nav),this._header.appendChild(this._line),this._container.appendChild(this._header),this._container.appendChild(this._content),this.tabHeaderKeyMapIndex={};const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=nr,e.appendChild(t),e.appendChild(this._container)}static get observedAttributes(){return["active","forceRender","type","align","effect"]}get align(){return this.getAttribute("align")||"start"}set align(e){this.setAttribute("align",e)}set type(e){this.setAttribute("type",e)}get type(){return this.getAttribute("type")||"flat"}get active(){return this.getAttribute("active")}set active(e){e?(this.setAttribute("active",e),this.setTabLine(e),this.setTabContent(e)):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}createTabHeader(e,t){const n=e.getAttribute("label")||"",a=e.getAttribute("icon")||"",o=e.getAttribute("iconSize")||"",c=e.getAttribute("r-key")||`${t}`,s=e.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(c,t);const p=document.createElement("r-button");return p.setAttribute("class","tab-header_nav__item"),p.setAttribute("type",s),a&&p.setAttribute("icon",a),o&&p.setAttribute("iconSize",o),z(e)&&p.setAttribute("disabled",""),p.setAttribute("r-key",c),this.effect&&(e.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),e.setAttribute("r-key",c),p.innerHTML=n,p}connectedCallback(){this.initTab()}disconnectCallback(){this.unloadTab()}attributeChangedCallback(e,t,n){t!==n&&(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),e==="align"&&(n==="center"&&this.initTabLineAlignCenter(),n==="end"&&this.initTabLineAlignEnd()),e==="effect"&&[...this._nav.children].forEach(o=>{!this.effect||this.effect==="false"?o.removeAttribute("effect"):o.setAttribute("effect",n)}),e==="active"&&this.setAttribute(e,n))}}return customElements.define("r-tabs",r),r}}ar();var or=Object.defineProperty,pr=(r,i,e)=>i in r?or(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,b=(r,i,e)=>(pr(r,typeof i!="symbol"?i+"":i,e),e);const sr=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}.radar{position:relative;width:100%;height:100%;display:block} -`,cr="rgba(0,0,0,0)",lr="rgba(0,0,0,1)",D="#e6e6e6",H="#e6e6e6",dr="黑体",O="rgba(255,121,35,0.60)",N="rgba(255,121,35,0.60)";function vr(){if(typeof document<"u"&&!customElements.get("r-radar")){class r extends HTMLElement{constructor(){super(),b(this,"mData"),b(this,"mCount"),b(this,"mW"),b(this,"mCenter"),b(this,"mRadius"),b(this,"mAngle"),b(this,"abilityRadarChartContainer"),b(this,"abilityRadarChart"),b(this,"_iconElement"),b(this,"_shadowDom"),this.abilityRadarChartContainer=document.createElement("div"),this.abilityRadarChartContainer.setAttribute("class","radar"),this.abilityRadarChart=document.createElement("canvas"),this.abilityRadarChart.style.setProperty("width","100%"),this.abilityRadarChart.style.setProperty("height","100%"),this.abilityRadarChartContainer.appendChild(this.abilityRadarChart);const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=sr,e.appendChild(t),this._shadowDom=e,e.appendChild(this.abilityRadarChartContainer)}static get observedAttributes(){return["abilitys","colorPolygon","colorLine","fillColor","strokeColor"]}get abilitys(){const e=this.getAttribute("abilitys");return typeof e=="string"?JSON.parse(e):e}set abilitys(e){typeof e=="string"?this.setAttribute("abilitys",e||""):this.setAttribute("abilitys",JSON.stringify(e)||"")}get colorPolygon(){return this.getAttribute("colorPolygon")||D}set colorPolygon(e){this.setAttribute("colorPolygon",e||D)}get colorLine(){return this.getAttribute("colorLine")||H}set colorLine(e){this.setAttribute("colorLine",e||H)}get fillColor(){return this.getAttribute("fillColor")||O}set fillColor(e){this.setAttribute("fillColor",e||O)}get strokeColor(){return this.getAttribute("strokeColor")||N}set strokeColor(e){this.setAttribute("strokeColor",e||N)}refreshData(){var e;const t=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!t)return;const n=_(t),a=this.abilityRadarChartContainer.clientWidth*n,o=this.abilityRadarChartContainer.clientHeight*n;this.abilityRadarChart.width=a,this.abilityRadarChart.height=o,this.mW=a,this.mData=this.abilitys,this.mCount=((e=this.mData)==null?void 0:e.length)||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*n,this.mAngle=Math.PI*2/this.mCount,this.drawPolygon(t),this.drawSide(t),this.drawLines(t),this.drawText(t),this.drawRegion(t),this.drawCircle(t)}drawSide(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;e.save(),e.strokeStyle=this.colorLine;const t=this.mRadius;for(let n=0;n=0&&this.mAngle*a=Math.PI/2&&this.mAngle*a=Math.PI&&this.mAngle*adiv{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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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} -`;if(typeof document<"u"){const r=document.createElement("style");r.textContent=wr,document.body.appendChild(r)}const xr={...pe,enhanceApp({app:r}){}};function F(r){if(r.extends){const i=F(r.extends);return{...i,...r,async enhanceApp(e){i.enhanceApp&&await i.enhanceApp(e),r.enhanceApp&&await r.enhanceApp(e)}}}return r}const A=F(xr),mr=V({name:"VitePressApp",setup(){const{site:r}=ee();return re(()=>{ie(()=>{document.documentElement.lang=r.value.lang,document.documentElement.dir=r.value.dir})}),te(),ne(),ae(),A.setup&&A.setup(),()=>oe(A.Layout)}});async function hr(){const r=br(),i=fr();i.provide(J,r);const e=K(r.route);return i.provide($,e),i.component("Content",U),i.component("ClientOnly",X),Object.defineProperties(i.config.globalProperties,{$frontmatter:{get(){return e.frontmatter.value}},$params:{get(){return e.page.value.params}}}),A.enhanceApp&&await A.enhanceApp({app:i,router:r,siteData:q}),{app:i,router:r,data:e}}function fr(){return G(mr)}function br(){let r=S,i;return Z(e=>{let t=W(e);return r&&(i=t),(r||i===t)&&(t=t.replace(/\.js$/,".lean.js")),S&&(r=!1),v(()=>import(t),[])},A.NotFound)}S&&hr().then(({app:r,router:i,data:e})=>{i.go().then(()=>{Y(i.route,e.site),r.mount("#app")})});export{hr as createApp,kr as l}; +`;function je(){if(typeof window<"u"&&!customElements.get("r-img")){class r extends HTMLElement{constructor(){super(),M(this,"_image"),M(this,"_container"),this._container=document.createElement("div"),this._container.setAttribute("class","r-image");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=Pe,e.appendChild(t),e.appendChild(this._container)}static get observedAttributes(){return["fallback"]}get fallback(){return this.getAttribute("fallback")||Se}set fallback(e){e?this.setAttribute("fallback",e):this.removeAttribute("fallback")}listenFallback(e,t){e==="fallback"&&this._image&&(t?this._image.setAttribute("fallback",t):this._image.removeAttribute("fallback"))}connectedCallback(){const e=this.getAttribute("src")||"";this._image=new Image,this._image.src=e,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(e,t,n){this.listenFallback(e,n)}}customElements.define("r-img",r)}}je();var Le=Object.defineProperty,Re=(r,i,e)=>i in r?Le(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,y=(r,i,e)=>(Re(r,typeof i!="symbol"?i+"":i,e),e);const Me=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}.input{position:relative;display:flex;width:100%;min-width:0;padding:2px 8px;color:#000000d9;font-size:12px;line-height:1.5715;background-color:#fff;background-image:none;border-width:1px;border-style:solid;border-color:#d9d9d9;border-radius:2px;transition:all .3s}.input:active{border-color:#40a9ff;box-shadow:0 0 0 2px #1890ff33;border-right-width:1px;outline:0}.input:hover{border-color:#40a9ff;border-right-width:1px}.input>.input-main:hover~.input-label{color:#40a9ff}.input[value]>.input-label{transform:translateY(calc(-50% - .43em)) scale(.8);color:#00000040}.input[status=error]{border-color:#ff4d4f}.input[status=error]>.input-main~.input-label{color:#ff4d4f}.input[status=warning]{border-color:#ff7875}.input[status=warning]>.input-main~.input-label{color:#ff7875}.input[disabled]{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.input[disabled]>.input-main{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.input[disabled]>.input-main~.input-label{color:#00000040;background-color:#f5f5f5}.input[disabled]>.input-label{color:#999;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed}.input-main{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.5715;background-color:#fff;background-image:none;transition:all .3s}.input-main:focus,.input-main:hover{border:none;outline:0}.input-main::placeholder{color:#999}.input-main:placeholder-shown~.input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.input-main:focus~.input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.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} +`;function Ie(){if(typeof window<"u"&&!customElements.get("r-input")){class r extends HTMLElement{constructor(){super(),y(this,"_container"),y(this,"_label"),y(this,"_input"),y(this,"_icon"),y(this,"customInput",n=>{n.stopPropagation();const a=n.target;this.value=a?a.value:"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("Input",{detail:{value:this.value}}))}),y(this,"customChange",()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("Change",{detail:{value:this.value}}))}),y(this,"dealIcon",()=>{if(!this._icon){this._icon=document.createElement("r-icon");const{width:n,height:a}=this._input.getBoundingClientRect(),o=Math.min(n,a);this._icon.setAttribute("size",`${o}`),this._input.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)});const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=Me,e.appendChild(t),this._container=document.createElement("div"),this._container.setAttribute("class","input"),this._input=document.createElement("input"),this._input.setAttribute("class","input-main"),this._container.appendChild(this._input),e.appendChild(this._container)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","status"]}get value(){return this.getAttribute("value")}set value(e){!z(this)&&e?(this.setAttribute("value",e),this._container.setAttribute("value",e)):(this.removeAttribute("value"),this._container.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")}set placeholder(e){e?this.setAttribute("placeholder",e):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")}set required(e){!e||e==="false"?this.removeAttribute("required"):this.setAttribute("required","")}get disabled(){return z(this)}set disabled(e){E.includes(e)?(this.removeAttribute("disabled"),this._container.removeAttribute("disabled"),this._input.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._container.setAttribute("disabled",""),this._input.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get status(){return this.getAttribute("status")||""}set status(e){e?(this.setAttribute("status",e),this._container.setAttribute("status",e)):(this.removeAttribute("status"),this._container.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(e){this.setAttribute("name",e)}get min(){return this.getAttribute("min")||""}set min(e){this.type==="number"&&this.setAttribute("min",e)}get max(){return this.getAttribute("max")||""}set max(e){this.type==="number"&&this.setAttribute("max",e)}get step(){return this.getAttribute("step")||""}set step(e){this.type==="number"&&this.setAttribute("step",e)}get icon(){return this.getAttribute("icon")}set icon(e){e?this.setAttribute("icon",e):this.removeAttribute("icon")}get type(){return this.getAttribute("type")}set type(e){e?this.setAttribute("type",e):this.removeAttribute("type")}listenPlaceholder(e,t){e==="placeholder"&&this._input&&(t!=null?this._input.setAttribute("placeholder",t):this._input.removeAttribute("placeholder"))}listenLabel(e,t){e==="label"&&this._input&&(t!=null?this._label?this._label.innerHTML=t:(this._label=document.createElement("label"),this._label.innerHTML=t,this._label.setAttribute("class","input-label"),this._container.appendChild(this._label)):(this._container.removeAttribute("label"),this._label&&(this._container.removeChild(this._label),this._label=void 0)))}listenType(e,t){e==="type"&&this._input&&(t?this._input.setAttribute("type",t):(this._input.removeAttribute("type"),this._input.removeAttribute("min"),this._input.removeAttribute("max"),this._input.removeAttribute("step")))}listenStatus(e,t){e==="status"&&this._container&&(t?this._container.setAttribute("status",t):this._container.removeAttribute("status"))}listenDisabled(e,t){e==="disabled"&&this._container&&(E.includes(t)?this._container.removeAttribute("disabled"):(this._container.setAttribute("disabled",""),this._input.setAttribute("disabled","")))}listenIcon(e,t,n){e==="icon"&&t&&t!==n&&(this.removeAttribute("label"),this.setAttribute("icon",t),this.dealIcon())}listenEvent(e,t,n){this.listenPlaceholder(e,n),this.listenLabel(e,n),this.listenStatus(e,n),this.listenDisabled(e,n),this.listenIcon(e,n,t)}connectedCallback(){this.value&&(this._input.value=this.value,this._container.setAttribute("value",this.value)),this.status&&this._container.setAttribute("status",this.status),z(this)&&(this._container.setAttribute("disabled",""),this._input.setAttribute("disabled","")),this.type&&this._input.setAttribute("type",this.type),this._input.addEventListener("input",this.customInput),document.readyState==="complete"&&this.dealIcon()}disconnectCallback(){this._input.removeEventListener("input",this.customInput)}attributeChangedCallback(e,t,n){this.listenEvent(e,t,n)}}return customElements.define("r-input",r),r}else return j("document is undefined or r-input is exist")}Ie();var Be=Object.defineProperty,Qe=(r,i,e)=>i in r?Be(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,u=(r,i,e)=>(Qe(r,typeof i!="symbol"?i+"":i,e),e);const Te=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}:host([type="toast"]){--ranui-message-background: rgba(0, 0, 0, .7);--ranui-message-color: #fff;--ranui-message-border-radius: 7px}.message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}.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}.message-notice-content-info{align-items:center;display:flex}.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} +`,I=300,B=3e3,De=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),He=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#1890ff"],["toast","rgba(0, 0, 0, 0.7)"]]);function Oe(){if(typeof window<"u"&&!customElements.get("r-message")){class r extends HTMLElement{constructor(){super(),u(this,"_info"),u(this,"_notice"),u(this,"_content"),u(this,"_icon"),u(this,"_span"),u(this,"timeId"),u(this,"close"),u(this,"setIcon",c=>{var s,p,d,l;const w=De.get(c),x=He.get(c);w&&((s=this._icon)==null||s.setAttribute("name",w),(p=this._icon)==null||p.style.setProperty("margin-right","8px"),(d=this._icon)==null||d.setAttribute("size","18"),x&&((l=this._icon)==null||l.setAttribute("color",x)))}),this._notice=document.createElement("div"),this._notice.setAttribute("class","message-notice"),this._content=document.createElement("div"),this._content.setAttribute("class","message-notice-content"),this._info=document.createElement("div"),this._info.setAttribute("class","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 a=this.attachShadow({mode:"closed"}),o=document.createElement("style");o.textContent=Te,a.appendChild(o),a.appendChild(this._notice)}static get observedAttributes(){return["type","content"]}get type(){return this.getAttribute("type")}set type(a){a&&this.setAttribute("type",a)}get content(){return this.getAttribute("content")}set content(a){a&&this.setAttribute("content",a)}attributeChangedCallback(a,o,c){a==="content"&&o!==c&&(this._span.textContent=c),a==="type"&&o!==c&&this.setIcon(c)}}customElements.define("r-message",r);const i=document.createElement("div"),e=document.createElement("div");e.setAttribute("class","ranui-message"),document.body.appendChild(i),i.appendChild(e);const t=n=>a=>{const o=new r;o.setAttribute("class","message"),o.timeId&&clearTimeout(o.timeId),o.setAttribute("type",n);let c=B,s;typeof a=="string"?o.setAttribute("content",a):(o.setAttribute("content",a.content),s=a.close,c=a.duration||B);const p=setTimeout(()=>{o.classList.remove("message-in"),o.classList.add("message-leave"),clearTimeout(p)},c-I);o.timeId=setTimeout(()=>{o.classList.remove("message-leave"),e.removeChild(o),s&&s()},c),e.appendChild(o),o.classList.add("message-in"),setTimeout(()=>{o.classList.remove("message-in")},I)};return{info:t("info"),success:t("success"),error:t("error"),warning:t("warning"),toast:t("toast")}}}const Q=Oe();typeof window<"u"&&Q&&(window.message=Q);var Ne=Object.defineProperty,Fe=(r,i,e)=>i in r?Ne(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,h=(r,i,e)=>(Fe(r,typeof i!="symbol"?i+"":i,e),e);const Ye=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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-slot{display:block}:host{cursor:pointer} +`,Je="application/vnd.openxmlformats-officedocument.presentationml.presentation",Ke="application/pdf",$e="application/vnd.openxmlformats-officedocument.wordprocessingml.document",T="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",D="application/vnd.ms-excel";async function Ue(){if(typeof window<"u"&&!customElements.get("r-preview")){const{renderPptx:r}=await v(()=>import("./chunks/index-1ffff466.53d85534.js"),["assets/chunks/index-1ffff466.53d85534.js","assets/chunks/commonjs-dynamic-modules-2ceabb0b.23156833.js","assets/chunks/jszip.min-97cf7c6a.4dec9da4.js","assets/chunks/colz-746223ab.12984b03.js"]),{renderDocx:i}=await v(()=>import("./chunks/docx-5262a8f1.7b8bae14.js"),["assets/chunks/docx-5262a8f1.7b8bae14.js","assets/chunks/jszip.min-97cf7c6a.4dec9da4.js","assets/chunks/commonjs-dynamic-modules-2ceabb0b.23156833.js"]),{renderPdf:e}=await v(()=>import("./chunks/pdf-6e38f826.8a63f27e.js"),["assets/chunks/pdf-6e38f826.8a63f27e.js","assets/chunks/framework.6fe2e870.js","assets/chunks/theme.eee41b28.js"]),{renderExcel:t}=await v(()=>import("./chunks/index-05a561dd.337961cd.js"),["assets/chunks/index-05a561dd.337961cd.js","assets/chunks/commonjs-dynamic-modules-2ceabb0b.23156833.js","assets/chunks/colz-746223ab.12984b03.js","assets/chunks/framework.6fe2e870.js","assets/chunks/theme.eee41b28.js"]),n=(s,p)=>new Promise((d,l)=>{const w=new FileReader;w.readAsArrayBuffer(s),w.onload=()=>{var x;if(w.result&&p){const f={pptx:w.result,resultElement:p};(x=r(f))==null||x.then(()=>{d()})}},w.onerror=x=>{l(x)},w.onabort=x=>{l(x)}}),a=(s,p)=>Promise.resolve().then(()=>i({buffer:s,bodyContainer:p})),o=new Map([[Ke,e],[Je,n],[$e,a],[T,t],[D,t]]);class c extends HTMLElement{constructor(){super(),h(this,"_loadingText"),h(this,"preview"),h(this,"previewContext"),h(this,"_slot"),h(this,"_div"),h(this,"_loadingElement"),h(this,"createLoading",()=>{this._loadingElement=document.createElement("div"),this._loadingElement.setAttribute("class","r-preview-loading");const l=document.createElement("r-icon");return l.setAttribute("name","loading"),l.setAttribute("size","100"),l.setAttribute("color","#1E90FF"),l.setAttribute("spin",""),this._loadingText=document.createElement("div"),this._loadingElement.appendChild(l),this._loadingText.setAttribute("class","r-preview-loading-text"),this._loadingElement.appendChild(this._loadingText),this._loadingElement}),h(this,"onProgress",l=>{const w=l.loaded/l.total*100,x=Math.min(99,w).toFixed(2)+"%";this._loadingText&&this._loadingElement&&(this._loadingText.innerText=`Loading ${x}`,w>=100&&setTimeout(()=>{var f;(f=this.preview)==null||f.removeChild(this._loadingElement)},300))}),h(this,"handleFile",async l=>{try{typeof l=="string"&&(l=await we(l,{onProgress:this.onProgress}));const{type:w}=l,x=o.get(w);x&&this.previewContext&&(w===T||w===D?this.previewContext.style.setProperty("width","100%"):this.previewContext.style.setProperty("width","100%"),x(l,this.previewContext))}catch(w){console.log("handleFile",w)}}),h(this,"closePreview",()=>{this.preview&&(document.body.removeChild(this.preview),this.preview=void 0)}),h(this,"showPreview",()=>{var l;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");const w=document.createElement("div");if(w.setAttribute("class","r-preview-options"),this.closeable!=="false"){const f=document.createElement("r-icon");f.setAttribute("class","r-preview-options-close"),f.setAttribute("name","close-circle-fill"),f.setAttribute("size","40"),f.addEventListener("click",this.closePreview),w.appendChild(f)}const x=document.createElement("div");x.setAttribute("class","r-preview-contain"),this.previewContext=document.createElement("div"),this.previewContext.setAttribute("class","r-preview-context"),x.appendChild(this.previewContext),this.preview.appendChild(w),(l=this.preview)==null||l.appendChild(x),this._loadingElement=this.createLoading(),this.preview.appendChild(this._loadingElement),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 p=this.attachShadow({mode:"closed"}),d=document.createElement("style");d.textContent=Ye,p.appendChild(d),p.appendChild(this._div)}static get observedAttributes(){return["src","closeable"]}get label(){return this.getAttribute("label")}set label(p){p&&this.setAttribute("label",p)}get src(){return this.getAttribute("src")}set src(p){p&&this.setAttribute("src",p)}get closeable(){return this.getAttribute("closeable")}set closeable(p){p&&this.setAttribute("closeable",p)}connectedCallback(){this.preview=document.getElementById("r-preview-mask"),this.addEventListener("click",this.showPreview)}disconnectedCallback(){this.removeEventListener("click",this.showPreview)}attributeChangedCallback(p,d,l){l!==d&&p==="src"&&l&&(this.setAttribute("src",l),this.showPreview())}}customElements.define("r-preview",c)}}Ue();var Xe=Object.defineProperty,qe=(r,i,e)=>i in r?Xe(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,Ge=(r,i,e)=>(qe(r,typeof i!="symbol"?i+"":i,e),e);const Ze=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background:rgba(0,0,0,.06);border-radius:4px}.skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:linear-gradient(90deg,rgba(0,0,0,.06) 25%,rgba(0,0,0,.15) 37%,rgba(0,0,0,.06) 63%);animation-name:skeleton;animation-duration:1.4s;animation-timing-function:ease;animation-iteration-count:infinite;content:""} +`;function We(){if(typeof window<"u"&&!customElements.get("r-skeleton")){class r extends HTMLElement{constructor(){super(),Ge(this,"_div"),this._div=document.createElement("div"),this._div.setAttribute("class","skeleton");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=Ze,e.appendChild(t),e.appendChild(this._div)}static get observedAttributes(){return["disabled"]}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(e,t,n){}}window.customElements.define("r-skeleton",r)}}We();var Ve=Object.defineProperty,er=(r,i,e)=>i in r?Ve(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,P=(r,i,e)=>(er(r,typeof i!="symbol"?i+"":i,e),e);const rr=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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} +`;function ir(){if(typeof window<"u"&&!customElements.get("r-tab")){class r extends HTMLElement{constructor(){super(),P(this,"_div"),P(this,"parent"),P(this,"initAttribute",()=>{var n,a,o;this.parent=this.parentNode,this.key&&((n=this.parent)==null||n.updateAttribute(this.key,"icon",this.icon)),this.key&&((a=this.parent)==null||a.updateAttribute(this.key,"iconSize",this.iconSize)),this.key&&((o=this.parent)==null||o.updateAttribute(this.key,"effect",this.effect))}),this._div=document.createElement("slot");const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=rr,e.appendChild(t),e.appendChild(this._div)}static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize"]}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get icon(){return this.getAttribute("icon")}set icon(e){!e||e==="false"?this.removeAttribute("icon"):this.setAttribute("icon",e)}get iconSize(){return this.getAttribute("iconSize")}set iconSize(e){!e||e==="false"?this.removeAttribute("iconSize"):this.setAttribute("iconSize",e)}get key(){return this.getAttribute("r-key")}set key(e){e?this.setAttribute("r-key",e):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(e){!e||e==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled",e)}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}onClick(e){console.log("e",e)}connectedCallback(){this._div.addEventListener("click",this.onClick),document.addEventListener("DOMContentLoaded",this.initAttribute)}disconnectCallback(){document.removeEventListener("DOMContentLoaded",this.initAttribute)}attributeChangedCallback(e,t,n){var a,o,c,s,p;t!==n&&this.key&&((a=this.parent)!=null&&a.updateAttribute)&&(e==="icon"&&((o=this.parent)==null||o.updateAttribute(this.key,"icon",n)),e==="iconSize"&&((c=this.parent)==null||c.updateAttribute(this.key,"iconSize",n)),e==="effect"&&((s=this.parent)==null||s.updateAttribute(this.key,"effect",n)),e==="disabled"&&((p=this.parent)==null||p.updateAttribute(this.key,"disabled",n)))}}return customElements.define("r-tab",r),r}}ir();var tr=Object.defineProperty,nr=(r,i,e)=>i in r?tr(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,m=(r,i,e)=>(nr(r,typeof i!="symbol"?i+"":i,e),e);const ar=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}.tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.tab-header_nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.tab-header_nav::-webkit-scrollbar{display:none}.tab-header_nav__item{flex-shrink:0}.tab-header_nav .active{color:var(--active-color, #1890ff)}.tab-header_line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--line-color, #1890ff);transition:.2s}.tab-content{overflow:hidden}.tab-content_wrap{display:flex;width:100%;height:100%;transition:.2s}:host([type="line"]) .tab-header_nav__item{border:solid 1px transparent}:host([type="line"]) .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"]) .tab-header_line{transition:none;visibility:hidden}:host([type="line"]) .tab-header_line:after,:host([type="line"]) .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"]) .tab-header_line:after{left:100%}:host([type="line"]) .tab-header_line:before{right:100%}:host([align="center"]) .tab-header_nav{justify-content:center}:host([align="center"]) .tab-header_line{left:50%}:host([align="end"]) .tab-header_nav{justify-content:flex-end} +`;function or(){if(typeof window<"u"&&!customElements.get("r-tabs")){class r extends HTMLElement{constructor(){super(),m(this,"_container"),m(this,"_header"),m(this,"_nav"),m(this,"_line"),m(this,"_content"),m(this,"_wrap"),m(this,"_slot"),m(this,"tabHeaderKeyMapIndex"),m(this,"initTabHeaderKeyMapIndex",(n,a)=>{if(this.tabHeaderKeyMapIndex[n])throw new Error("tab 组件的 key 值存在重复, 或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[n]=a}),m(this,"initTabLineAlignCenter",()=>{const{length:n}=this._nav.children;let a=0;for(let o=0;o{const{length:n}=this._nav.children;let a=0;for(let o=0;o{if(n){const a=this.tabHeaderKeyMapIndex[n],o=this._nav.children[a],{width:c=0}=o.getBoundingClientRect();this._line.style.setProperty("width",`${c}px`);let s=0;for(let p=0;p{if(n){const a=this.tabHeaderKeyMapIndex[n];this._wrap.style.setProperty("transform",`translateX(${a*-100}%)`)}}),m(this,"clickTabHead",n=>{const a=n.target,o=a.getAttribute("r-key");!z(a)&&o&&(this.setAttribute("active",o),this.setTabLine(o),this.setTabContent(o),ve(this._nav,"active"),L(a,"active"))}),m(this,"updateAttribute",(n,a,o="")=>{var c,s;const p=this.tabHeaderKeyMapIndex[n];n&&o&&this._nav.children[p]?(c=this._nav.children[p])==null||c.setAttribute(a,o):(s=this._nav.children[p])==null||s.removeAttribute(a)}),m(this,"initActive",()=>{const n=[...this._nav.children],a=n.filter(p=>!z(p));let o;if(this.active!=null&&(o=a.find(p=>p.getAttribute("r-key")===this.active),o==null||o.setAttribute("r-key",this.active)),o||(o=a.shift()),!o)return;const c=n.findIndex(p=>p===o),s=(o==null?void 0:o.getAttribute("r-key"))||`${c}`;s!=null&&(this.setAttribute("active",`${s}`),L(o,"active"),this.setTabContent(s),setTimeout(()=>{this.setTabLine(s)},200))}),m(this,"listenSlotChange",()=>{this._slot.assignedElements().forEach((a,o)=>{const c=this.createTabHeader(a,o);this._nav.appendChild(c),c.addEventListener("click",this.clickTabHead)}),this.initActive(),this.align&&(this.align==="center"&&this.initTabLineAlignCenter(),this.align==="end"&&this.initTabLineAlignEnd())}),m(this,"initTab",()=>{this._slot.addEventListener("slotchange",this.listenSlotChange)}),m(this,"unloadTab",()=>{this._slot.removeEventListener("slotchange",this.listenSlotChange)}),this._container=document.createElement("div"),this._container.setAttribute("class","tab"),this._header=document.createElement("div"),this._header.setAttribute("class","tab-header"),this._nav=document.createElement("div"),this._nav.setAttribute("class","tab-header_nav"),this._line=document.createElement("div"),this._line.setAttribute("class","tab-header_line"),this._content=document.createElement("div"),this._content.setAttribute("class","tab-content"),this._wrap=document.createElement("div"),this._wrap.setAttribute("class","tab-content_wrap"),this._slot=document.createElement("slot"),this._wrap.appendChild(this._slot),this._content.appendChild(this._wrap),this._header.appendChild(this._nav),this._header.appendChild(this._line),this._container.appendChild(this._header),this._container.appendChild(this._content),this.tabHeaderKeyMapIndex={};const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=ar,e.appendChild(t),e.appendChild(this._container)}static get observedAttributes(){return["active","forceRender","type","align","effect"]}get align(){return this.getAttribute("align")||"start"}set align(e){this.setAttribute("align",e)}set type(e){this.setAttribute("type",e)}get type(){return this.getAttribute("type")||"flat"}get active(){return this.getAttribute("active")}set active(e){e?(this.setAttribute("active",e),this.setTabLine(e),this.setTabContent(e)):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}createTabHeader(e,t){const n=e.getAttribute("label")||"",a=e.getAttribute("icon")||"",o=e.getAttribute("iconSize")||"",c=e.getAttribute("r-key")||`${t}`,s=e.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(c,t);const p=document.createElement("r-button");return p.setAttribute("class","tab-header_nav__item"),p.setAttribute("type",s),a&&p.setAttribute("icon",a),o&&p.setAttribute("iconSize",o),z(e)&&p.setAttribute("disabled",""),p.setAttribute("r-key",c),this.effect&&(e.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),e.setAttribute("r-key",c),p.innerHTML=n,p}connectedCallback(){this.initTab()}disconnectCallback(){this.unloadTab()}attributeChangedCallback(e,t,n){t!==n&&(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),e==="align"&&(n==="center"&&this.initTabLineAlignCenter(),n==="end"&&this.initTabLineAlignEnd()),e==="effect"&&[...this._nav.children].forEach(o=>{!this.effect||this.effect==="false"?o.removeAttribute("effect"):o.setAttribute("effect",n)}),e==="active"&&this.setAttribute(e,n))}}return customElements.define("r-tabs",r),r}}or();var pr=Object.defineProperty,sr=(r,i,e)=>i in r?pr(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,b=(r,i,e)=>(sr(r,typeof i!="symbol"?i+"":i,e),e);const cr=`@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-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;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}.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-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items: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:#000000;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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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}.radar{position:relative;width:100%;height:100%;display:block} +`,lr="rgba(0,0,0,0)",dr="rgba(0,0,0,1)",H="#e6e6e6",O="#e6e6e6",vr="黑体",N="rgba(255,121,35,0.60)",F="rgba(255,121,35,0.60)";function wr(){if(typeof document<"u"&&!customElements.get("r-radar")){class r extends HTMLElement{constructor(){super(),b(this,"mData"),b(this,"mCount"),b(this,"mW"),b(this,"mCenter"),b(this,"mRadius"),b(this,"mAngle"),b(this,"abilityRadarChartContainer"),b(this,"abilityRadarChart"),b(this,"_iconElement"),b(this,"_shadowDom"),this.abilityRadarChartContainer=document.createElement("div"),this.abilityRadarChartContainer.setAttribute("class","radar"),this.abilityRadarChart=document.createElement("canvas"),this.abilityRadarChart.style.setProperty("width","100%"),this.abilityRadarChart.style.setProperty("height","100%"),this.abilityRadarChartContainer.appendChild(this.abilityRadarChart);const e=this.attachShadow({mode:"closed"}),t=document.createElement("style");t.textContent=cr,e.appendChild(t),this._shadowDom=e,e.appendChild(this.abilityRadarChartContainer)}static get observedAttributes(){return["abilitys","colorPolygon","colorLine","fillColor","strokeColor"]}get abilitys(){const e=this.getAttribute("abilitys");return typeof e=="string"?JSON.parse(e):e}set abilitys(e){typeof e=="string"?this.setAttribute("abilitys",e||""):this.setAttribute("abilitys",JSON.stringify(e)||"")}get colorPolygon(){return this.getAttribute("colorPolygon")||H}set colorPolygon(e){this.setAttribute("colorPolygon",e||H)}get colorLine(){return this.getAttribute("colorLine")||O}set colorLine(e){this.setAttribute("colorLine",e||O)}get fillColor(){return this.getAttribute("fillColor")||N}set fillColor(e){this.setAttribute("fillColor",e||N)}get strokeColor(){return this.getAttribute("strokeColor")||F}set strokeColor(e){this.setAttribute("strokeColor",e||F)}refreshData(){var e;const t=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!t)return;const n=_(t),a=this.abilityRadarChartContainer.clientWidth*n,o=this.abilityRadarChartContainer.clientHeight*n;this.abilityRadarChart.width=a,this.abilityRadarChart.height=o,this.mW=a,this.mData=this.abilitys,this.mCount=((e=this.mData)==null?void 0:e.length)||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*n,this.mAngle=Math.PI*2/this.mCount,this.drawPolygon(t),this.drawSide(t),this.drawLines(t),this.drawText(t),this.drawRegion(t),this.drawCircle(t)}drawSide(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;e.save(),e.strokeStyle=this.colorLine;const t=this.mRadius;for(let n=0;n=0&&this.mAngle*a=Math.PI/2&&this.mAngle*a=Math.PI&&this.mAngle*adiv{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:rgba(75,137,255,.1);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:rgba(0,0,0,.05)}.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:rgba(0,0,0,.08);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:#ffffff;-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:rgba(0,0,0,.08)}.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:rgba(0,0,0,.08);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} +`;if(typeof document<"u"){const r=document.createElement("style");r.textContent=xr,document.body.appendChild(r)}const mr={...se,enhanceApp({app:r}){}};function Y(r){if(r.extends){const i=Y(r.extends);return{...i,...r,async enhanceApp(e){i.enhanceApp&&await i.enhanceApp(e),r.enhanceApp&&await r.enhanceApp(e)}}}return r}const A=Y(mr),hr=ee({name:"VitePressApp",setup(){const{site:r}=re();return ie(()=>{te(()=>{document.documentElement.lang=r.value.lang,document.documentElement.dir=r.value.dir})}),ne(),ae(),oe(),A.setup&&A.setup(),()=>pe(A.Layout)}});async function fr(){const r=gr(),i=br();i.provide(K,r);const e=$(r.route);return i.provide(U,e),i.component("Content",X),i.component("ClientOnly",q),Object.defineProperties(i.config.globalProperties,{$frontmatter:{get(){return e.frontmatter.value}},$params:{get(){return e.page.value.params}}}),A.enhanceApp&&await A.enhanceApp({app:i,router:r,siteData:G}),{app:i,router:r,data:e}}function br(){return Z(hr)}function gr(){let r=S,i;return W(e=>{let t=V(e);return r&&(i=t),(r||i===t)&&(t=t.replace(/\.js$/,".lean.js")),S&&(r=!1),v(()=>import(t),[])},A.NotFound)}S&&fr().then(({app:r,router:i,data:e})=>{i.go().then(()=>{J(i.route,e.site),r.mount("#app")})});export{fr as createApp,yr as l}; diff --git a/assets/chunks/index-714a1eb8.0992a4b8.js b/assets/chunks/index-05a561dd.337961cd.js similarity index 75% rename from assets/chunks/index-714a1eb8.0992a4b8.js rename to assets/chunks/index-05a561dd.337961cd.js index 5f30ce15d..2a187c84a 100644 --- a/assets/chunks/index-714a1eb8.0992a4b8.js +++ b/assets/chunks/index-05a561dd.337961cd.js @@ -1,4 +1,4 @@ -import{c as Wt,a as No,g as q0}from"./commonjs-dynamic-modules-2ceabb0b.23156833.js";import{g as em,a as tm}from"./colz-746223ab.12984b03.js";var rm=Object.defineProperty,nm=(H,x,e)=>x in H?rm(H,x,{enumerable:!0,configurable:!0,writable:!0,value:e}):H[x]=e,Nn=(H,x,e)=>(nm(H,typeof x!="symbol"?x+"":x,e),e);class Xi{constructor(x,e=""){typeof x=="string"?(this.el=document.createElement(x),this.el.className=e):this.el=x,this.data={}}data(x,e){return e!==void 0?(this.data[x]=e,this):this.data[x]}on(x,e){const[S,..._]=x.split(".");let u=S;return u==="mousewheel"&&/Firefox/i.test(window.navigator.userAgent)&&(u="DOMMouseScroll"),this.el.addEventListener(u,y=>{e(y);for(let g=0;g<_.length;g+=1){const b=_[g];if(b==="left"&&y.button!==0||b==="right"&&y.button!==2)return;b==="stop"&&y.stopPropagation()}}),this}offset(x){if(x!==void 0)return Object.keys(x).forEach(y=>{this.css(y,`${x[y]}px`)}),this;const{offsetTop:e,offsetLeft:S,offsetHeight:_,offsetWidth:u}=this.el;return{top:e,left:S,height:_,width:u}}scroll(x){const{el:e}=this;return x!==void 0&&(x.left!==void 0&&(e.scrollLeft=x.left),x.top!==void 0&&(e.scrollTop=x.top)),{left:e.scrollLeft,top:e.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new Xi(this.el.parentNode)}children(...x){return arguments.length===0?this.el.childNodes:(x.forEach(e=>this.child(e)),this)}removeChild(x){this.el.removeChild(x)}child(x){let e=x;return typeof x=="string"?e=document.createTextNode(x):x instanceof Xi&&(e=x.el),this.el.appendChild(e),this}contains(x){return this.el.contains(x)}className(x){return x!==void 0?(this.el.className=x,this):this.el.className}addClass(x){return this.el.classList.add(x),this}hasClass(x){return this.el.classList.contains(x)}removeClass(x){return this.el.classList.remove(x),this}toggle(x="active"){return this.toggleClass(x)}toggleClass(x){return this.el.classList.toggle(x)}active(x=!0,e="active"){return x?this.addClass(e):this.removeClass(e),this}checked(x=!0){return this.active(x,"checked"),this}disabled(x=!0){return x?this.addClass("disabled"):this.removeClass("disabled"),this}attr(x,e){if(e!==void 0)this.el.setAttribute(x,e);else{if(typeof x=="string")return this.el.getAttribute(x);Object.keys(x).forEach(S=>{this.el.setAttribute(S,x[S])})}return this}removeAttr(x){return this.el.removeAttribute(x),this}html(x){return x!==void 0?(this.el.innerHTML=x,this):this.el.innerHTML}val(x){return x!==void 0?(this.el.value=x,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...x){return x.forEach(e=>this.el.style.removeProperty(e)),this}css(x,e){return e===void 0&&typeof x!="string"?(Object.keys(x).forEach(S=>{this.el.style[S]=x[S]}),this):e!==void 0?(this.el.style[x]=e,this):this.el.style[x]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const $e=(H,x="")=>new Xi(H,x),Ti=["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 ac(H){let x="",e=H;for(;e>=Ti.length;)e/=Ti.length,e-=1,x+=Ti[parseInt(e,10)%Ti.length];const S=H%Ti.length;return x+=Ti[S],x}function im(H){let x=0;for(let e=0;e="0"&&H.charAt(S)<="9"?e+=H.charAt(S):x+=H.charAt(S);return[im(x),parseInt(e,10)-1]}function di(H,x){return`${ac(H)}${x+1}`}function Ha(H,x,e,S=()=>!0){if(x===0&&e===0)return H;const[_,u]=Ri(H);return S(_,u)?di(_+x,u+e):H}class xr{constructor(x,e,S,_,u=0,y=0){this.sri=x,this.sci=e,this.eri=S,this.eci=_,this.w=u,this.h=y}set(x,e,S,_){this.sri=x,this.sci=e,this.eri=S,this.eci=_}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...x){let[e,S]=[0,0];x.length===1?[S,e]=Ri(x[0]):x.length===2&&([e,S]=x);const{sri:_,sci:u,eri:y,eci:g}=this;return _<=e&&e<=y&&u<=S&&S<=g}each(x,e=()=>!0){const{sri:S,sci:_,eri:u,eci:y}=this;for(let g=S;g<=u;g+=1)if(e(g))for(let b=_;b<=y;b+=1)x(g,b)}contains(x){return this.sri<=x.sri&&this.sci<=x.sci&&this.eri>=x.eri&&this.eci>=x.eci}within(x){return this.sri>=x.sri&&this.sci>=x.sci&&this.eri<=x.eri&&this.eci<=x.eci}disjoint(x){return this.sri>x.eri||this.sci>x.eci||x.sri>this.eri||x.sci>this.eci}intersects(x){return this.sri<=x.eri&&this.sci<=x.eci&&x.sri<=this.eri&&x.sci<=this.eci}union(x){const{sri:e,sci:S,eri:_,eci:u}=this;return new xr(x.sri_?x.eri:_,x.eci>u?x.eci:u)}difference(x){const e=[],S=(h,l,d,s)=>{e.push(new xr(h,l,d,s))},{sri:_,sci:u,eri:y,eci:g}=this,b=x.sri-_,w=x.sci-u,f=y-x.eri,v=g-x.eci;return b>0?(S(_,u,x.sri-1,g),f>0?(S(x.eri+1,u,y,g),w>0&&S(x.sri,u,x.eri,x.sci-1),v>0&&S(x.sri,x.eci+1,x.eri,g)):(w>0&&S(x.sri,u,y,x.sci-1),v>0&&S(x.sri,x.eci+1,y,g))):f>0&&(S(x.eri+1,u,y,g),w>0&&S(_,u,x.eri,x.sci-1),v>0&&S(_,x.eci+1,x.eri,g)),w>0?(S(_,u,y,x.sci-1),v>0?(S(_,x.eri+1,y,g),b>0&&S(_,x.sci,x.sri-1,x.eci),f>0&&S(x.sri+1,x.sci,y,x.eci)):(b>0&&S(_,x.sci,x.sri-1,g),f>0&&S(x.sri+1,x.sci,y,g))):v>0&&(S(y,x.eci+1,y,g),b>0&&S(_,u,x.sri-1,x.eci),f>0&&S(x.eri+1,u,y,x.eci)),e}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:x,sci:e,eri:S,eci:_}=this;let u=di(e,x);return this.multiple()&&(u=`${u}:${di(_,S)}`),u}clone(){const{sri:x,sci:e,eri:S,eci:_,w:u,h:y}=this;return new xr(x,e,S,_,u,y)}equals(x){return this.eri===x.eri&&this.eci===x.eci&&this.sri===x.sri&&this.sci===x.sci}static valueOf(x){const e=x.split(":"),[S,_]=Ri(e[0]);let[u,y]=[_,S];return e.length>1&&([y,u]=Ri(e[1])),new xr(_,S,u,y)}}let am=class{constructor(){this.range=new xr(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(x,e){this.ri=x,this.ci=e}size(){return this.range.size()}};class om{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class sm{constructor(){this.undoItems=[],this.redoItems=[]}add(x){this.undoItems.push(JSON.stringify(x)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(x,e){const{undoItems:S,redoItems:_}=this;this.canUndo()&&(_.push(JSON.stringify(x)),e(JSON.parse(S.pop())))}redo(x,e){const{undoItems:S,redoItems:_}=this;this.canRedo()&&(S.push(JSON.stringify(x)),e(JSON.parse(_.pop())))}}class fm{constructor(){this.range=null,this.state="clear"}copy(x){return this.range=x,this.state="copy",this}cut(x){return this.range=x,this.state="cut",this}isCopy(){return this.state==="copy"}isCut(){return this.state==="cut"}isClear(){return this.state==="clear"}clear(){this.range=null,this.state="clear"}}class Ol{constructor(x,e,S){this.ci=x,this.operator=e,this.value=S}set(x,e){this.operator=x,this.value=e}includes(x){const{operator:e,value:S}=this;return e==="all"?!0:e==="in"?S.includes(x):!1}vlength(){const{operator:x,value:e}=this;return x==="in"?e.length:0}getData(){const{ci:x,operator:e,value:S}=this;return{ci:x,operator:e,value:S}}}class El{constructor(x,e){this.ci=x,this.order=e}asc(){return this.order==="asc"}desc(){return this.order==="desc"}}class um{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:x,filters:e,sort:S}){x!=null&&(this.ref=x,this.filters=e.map(_=>new Ol(_.ci,_.operator,_.value)),S&&(this.sort=new El(S.ci,S.order)))}getData(){if(this.active()){const{ref:x,filters:e,sort:S}=this;return{ref:x,filters:e.map(_=>_.getData()),sort:S}}return{}}addFilter(x,e,S){const _=this.getFilter(x);_==null?this.filters.push(new Ol(x,e,S)):_.set(e,S)}setSort(x,e){this.sort=e?new El(x,e):null}includes(x,e){return this.active()?this.hrange().includes(x,e):!1}getSort(x){const{sort:e}=this;return e&&e.ci===x?e:null}getFilter(x){const{filters:e}=this;for(let S=0;S!e.within(x))}getFirstIncludes(x,e){for(let S=0;Se.intersects(x)))}intersects(x){for(let e=0;e{S.intersects(e)&&(e=S.union(e))}),e}add(x){this.deleteWithin(x),this._.push(x)}shift(x,e,S,_){this._.forEach(u=>{const{sri:y,sci:g,eri:b,eci:w}=u,f=u;x==="row"?y>=e?(f.sri+=S,f.eri+=S):y=e?(f.sci+=S,f.eci+=S):g{const u=_;u.within(x)&&(u.eri+=e,u.sri+=e,u.sci+=S,u.eci+=S)})}setData(x){return this._=x.map(e=>xr.valueOf(e)),this}getData(){return this._.map(x=>x.toString())}}function lm(H){return JSON.parse(JSON.stringify(H))}const oc=(H={},...x)=>(x.forEach(e=>{Object.keys(e).forEach(S=>{const _=e[S];typeof _=="string"||typeof _=="number"||typeof _=="boolean"?H[S]=_:typeof _!="function"&&!Array.isArray(_)&&_ instanceof Object?(H[S]=H[S]||{},oc(H[S],_)):H[S]=_})}),H);function hf(H,x){const e=Object.keys(H);if(e.length!==Object.keys(x).length)return!1;for(let S=0;Se)=>{let e=0,S=0;return Object.keys(H).forEach(_=>{e+=x(H[_],_),S+=1}),[e,S]};function hm(H,x){const e=H[`${x}`];return delete H[`${x}`],e}function dm(H,x,e,S,_,u){let y=e,g=S,b=H;for(;b_);b+=1)g=u(b),y+=g;return[b,y-g,g]}function pm(H,x,e){let S=0;for(let _=H;_5?g.toFixed(2):g;return g.toFixed(Math.max(S,_))}const fn={cloneDeep:lm,merge:(...H)=>oc({},...H),equals:hf,arrayEquals:ym,sum:cm,rangeEach:vm,rangeSum:pm,rangeReduceIf:dm,deleteProperty:hm,numberCalc:Li};class mm{constructor({len:x,height:e}){this._={},this.len=x,this.height=e}getHeight(x){if(this.isHide(x))return 0;const e=this.get(x);return e&&e.height?e.height:this.height}setHeight(x,e){const S=this.getOrNew(x);S.height=e}unhide(x){let e=x;for(;e>0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}isHide(x){const e=this.get(x);return e&&e.hide}setHide(x,e){const S=this.getOrNew(x);e===!0?S.hide=!0:delete S.hide}setStyle(x,e){const S=this.getOrNew(x);S.style=e}sumHeight(x,e,S){return fn.rangeSum(x,e,_=>S&&S.has(_)?0:this.getHeight(_))}totalHeight(){return this.sumHeight(0,this.len)}get(x){return this._[x]}getOrNew(x){return this._[x]=this._[x]||{cells:{}},this._[x]}getCell(x,e){const S=this.get(x);return S!==void 0&&S.cells!==void 0&&S.cells[e]!==void 0?S.cells[e]:null}getCellMerge(x,e){const S=this.getCell(x,e);return S&&S.merge?S.merge:[0,0]}getCellOrNew(x,e){const S=this.getOrNew(x);return S.cells[e]=S.cells[e]||{},S.cells[e]}setCell(x,e,S,_="all"){const u=this.getOrNew(x);_==="all"?u.cells[e]=S:_==="text"?(u.cells[e]=u.cells[e]||{},u.cells[e].text=S.text):_==="format"&&(u.cells[e]=u.cells[e]||{},u.cells[e].style=S.style,S.merge&&(u.cells[e].merge=S.merge))}setCellText(x,e,S){const _=this.getCellOrNew(x,e);_.editable!==!1&&(_.text=S)}copyPaste(x,e,S,_=!1,u=()=>{}){const{sri:y,sci:g,eri:b,eci:w}=x,f=e.sri,v=e.sci,h=e.eri,l=e.eci,[d,s]=x.size(),[m,c]=e.size();let a=!0,r=0;(h0){const{text:B}=P;let z=o-v+(n-f)+2;if(a||(z-=r+1),B[0]==="=")P.text=B.replace(/[a-zA-Z]{1,3}\d+/g,D=>{let[M,I]=[0,0];return y===f?M=z-1:I=z-1,/^\d+$/.test(D)?D:Ha(D,M,I)});else if(d<=1&&s>1&&(f>b||h1&&(v>w||l{this.eachCells(_,u=>{let y=parseInt(_,10),g=parseInt(u,10);x.includes(_,u)&&(y=e.sri+(y-x.sri),g=e.sci+(g-x.sci)),S[y]=S[y]||{cells:{}},S[y].cells[g]=this._[_].cells[u]})}),this._=S}paste(x,e){if(x.length<=0)return;const{sri:S,sci:_}=e;x.forEach((u,y)=>{const g=S+y;u.forEach((b,w)=>{const f=_+w;this.setCellText(g,f,b)})})}insert(x,e=1){const S={};this.each((_,u)=>{let y=parseInt(_,10);y>=x&&(y+=e,this.eachCells(_,(g,b)=>{b.text&&b.text[0]==="="&&(b.text=b.text.replace(/[a-zA-Z]{1,3}\d+/g,w=>Ha(w,0,e,(f,v)=>v>=x)))})),S[y]=u}),this._=S,this.len+=e}delete(x,e){const S=e-x+1,_={};this.each((u,y)=>{const g=parseInt(u,10);ge&&(_[g-S]=y,this.eachCells(u,(b,w)=>{w.text&&w.text[0]==="="&&(w.text=w.text.replace(/[a-zA-Z]{1,3}\d+/g,f=>Ha(f,0,-S,(v,h)=>h>e)))}))}),this._=_,this.len-=S}insertColumn(x,e=1){this.each((S,_)=>{const u={};this.eachCells(S,(y,g)=>{let b=parseInt(y,10);b>=x&&(b+=e,g.text&&g.text[0]==="="&&(g.text=g.text.replace(/[a-zA-Z]{1,3}\d+/g,w=>Ha(w,e,0,f=>f>=x)))),u[b]=g}),_.cells=u})}deleteColumn(x,e){const S=e-x+1;this.each((_,u)=>{const y={};this.eachCells(_,(g,b)=>{const w=parseInt(g,10);we&&(y[w-S]=b,b.text&&b.text[0]==="="&&(b.text=b.text.replace(/[a-zA-Z]{1,3}\d+/g,f=>Ha(f,-S,0,v=>v>e))))}),u.cells=y})}deleteCells(x,e="all"){x.each((S,_)=>{this.deleteCell(S,_,e)})}deleteCell(x,e,S="all"){const _=this.get(x);if(_!==null){const u=this.getCell(x,e);u!==null&&u.editable!==!1&&(S==="all"?delete _.cells[e]:S==="text"?(u.text&&delete u.text,u.value&&delete u.value):S==="format"?(u.style!==void 0&&delete u.style,u.merge&&delete u.merge):S==="merge"&&u.merge&&delete u.merge)}}maxCell(){const x=Object.keys(this._),e=x[x.length-1],S=this._[e];if(S){const{cells:_}=S,u=Object.keys(_),y=u[u.length-1];return[parseInt(e,10),parseInt(y,10)]}return[0,0]}each(x){Object.entries(this._).forEach(([e,S])=>{x(e,S)})}eachCells(x,e){this._[x]&&this._[x].cells&&Object.entries(this._[x].cells).forEach(([S,_])=>{e(S,_)})}setData(x){x.len&&(this.len=x.len,delete x.len),this._=x}getData(){const{len:x}=this;return Object.assign({len:x},this._)}}class bm{constructor({len:x,width:e,indexWidth:S,minWidth:_}){this._={},this.len=x,this.width=e,this.indexWidth=S,this.minWidth=_}setData(x){x.len&&(this.len=x.len,delete x.len),this._=x}getData(){const{len:x}=this;return Object.assign({len:x},this._)}getWidth(x){if(this.isHide(x))return 0;const e=this._[x];return e&&e.width?e.width:this.width}getOrNew(x){return this._[x]=this._[x]||{},this._[x]}setWidth(x,e){const S=this.getOrNew(x);S.width=e}unhide(x){let e=x;for(;e>0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}isHide(x){const e=this._[x];return e&&e.hide}setHide(x,e){const S=this.getOrNew(x);e===!0?S.hide=!0:delete S.hide}setStyle(x,e){const S=this.getOrNew(x);S.style=e}sumWidth(x,e){return fn.rangeSum(x,e,S=>this.getWidth(S))}totalWidth(){return this.sumWidth(0,this.len)}}const gm={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"}}};let df=["en"];const sc={en:gm};function Tl(H,x){if(x)for(const e of df){if(!x[e])break;let S=x[e];const _=H.match(/(?:\\.|[^.])+/g);for(let u=0;u<_.length;u+=1){const y=_[u],g=S[y];if(!g)break;if(u===_.length-1)return g;S=g}}}function Cr(H){let x=Tl(H,sc);return!x&&window&&window.x_spreadsheet&&window.x_spreadsheet.$messages&&(x=Tl(H,window.x_spreadsheet.$messages)),x||""}function Jt(H){return()=>Cr(H)}function fc(H,x,e=!1){e?df=[H]:df.unshift(H),x&&(sc[H]=x)}const Rl={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function $n(H,x,...e){let S="";return H||(S=Cr(`validation.${x}`,...e)),[H,S]}class uc{constructor(x,e,S,_){this.required=e,this.value=S,this.type=x,this.operator=_,this.message=""}parseValue(x){const{type:e}=this;return e==="date"?new Date(x):e==="number"?Number(x):x}equals(x){let e=this.type===x.type&&this.required===x.required&&this.operator===x.operator;return e&&(Array.isArray(this.value)?e=fn.arrayEquals(this.value,x.value):e=this.value===x.value),e}values(){return this.value.split(",")}validate(x){const{required:e,operator:S,value:_,type:u}=this;if(e&&/^\s*$/.test(x))return $n(!1,"required");if(/^\s*$/.test(x))return[!0];if(Rl[u]&&!Rl[u].test(x))return $n(!1,"notMatch");if(u==="list")return $n(this.values().includes(x),"notIn");if(S){const y=this.parseValue(x);if(S==="be"){const[g,b]=_;return $n(y>=this.parseValue(g)&&y<=this.parseValue(b),"between",g,b)}if(S==="nbe"){const[g,b]=_;return $n(ythis.parseValue(b),"notBetween",g,b)}if(S==="eq")return $n(y===this.parseValue(_),"equal",_);if(S==="neq")return $n(y!==this.parseValue(_),"notEqual",_);if(S==="lt")return $n(ythis.parseValue(_),"greaterThan",_);if(S==="gte")return $n(y>=this.parseValue(_),"greaterThanEqual",_)}return[!0]}}class Ko{constructor(x,e,S){this.refs=e,this.mode=x,this.validator=S}includes(x,e){const{refs:S}=this;for(let _=0;_{const _=xr.valueOf(S);_.intersects(x)?_.difference(x).forEach(y=>e.push(y.toString())):e.push(S)}),this.refs=e}getData(){const{refs:x,mode:e,validator:S}=this,{type:_,required:u,operator:y,value:g}=S;return{refs:x,mode:e,type:_,required:u,operator:y,value:g}}static valueOf({refs:x,mode:e,type:S,required:_,operator:u,value:y}){return new Ko(e,x,new uc(S,_,y,u))}}class _m{constructor(){this._=[],this.errors=new Map}getError(x,e){return this.errors.get(`${x}_${e}`)}validate(x,e,S){const _=this.get(x,e),u=`${x}_${e}`,{errors:y}=this;if(_!==null){const[g,b]=_.validator.validate(S);g?y.delete(u):y.set(u,b)}else y.delete(u);return!0}add(x,e,{type:S,required:_,value:u,operator:y}){const g=new uc(S,_,u,y),b=this.getByValidator(g);b!==null?b.addRef(e):this._.push(new Ko(x,[e],g))}getByValidator(x){for(let e=0;e{e.remove(x)})}each(x){this._.forEach(e=>x(e))}getData(){return this._.filter(x=>x.refs.length>0).map(x=>x.getData())}setData(x){this._=x.map(e=>Ko.valueOf(e))}}const wm={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"}},Sm=41,km=41,Cl=(H,x)=>Object.prototype.hasOwnProperty.call(H,x);function Pl(H,x,e=()=>{}){const{merges:S}=this,_=x.clone(),[u,y]=H.size(),[g,b]=x.size();return u>g&&(_.eri=x.sri+u-1),y>b&&(_.eci=x.sci+y-1),S.intersects(_)?(e(Cr("error.pasteForMergedCell")),!1):!0}function Al(H,x,e,S=!1){const{rows:_,merges:u}=this;(e==="all"||e==="format")&&(_.deleteCells(x,e),u.deleteWithin(x)),_.copyPaste(H,x,e,S,(y,g,b)=>{if(b&&b.merge){const[w,f]=b.merge;if(w<=0&&f<=0)return;u.add(new xr(y,g,y+w,g+f))}})}function xm(H,x){const{clipboard:e,rows:S,merges:_}=this;S.cutPaste(H,x),_.move(H,x.sri-H.sri,x.sci-H.sci),e.clear()}function va(H,x,e){const{styles:S,rows:_}=this,u=_.getCellOrNew(H,x);let y={};u.style!==void 0&&(y=fn.cloneDeep(S[u.style])),y=fn.merge(y,{border:e}),u.style=this.addStyle(y)}function Om({mode:H,style:x,color:e}){const{styles:S,selector:_,rows:u}=this,{sri:y,sci:g,eri:b,eci:w}=_.range,f=!this.isSignleSelected();if(!(!f&&(H==="inside"||H==="horizontal"||H==="vertical"))){if(H==="outside"&&!f)va.call(this,y,g,{top:[x,e],bottom:[x,e],left:[x,e],right:[x,e]});else if(H==="none")_.range.each((v,h)=>{const l=u.getCell(v,h);if(l&&l.style!==void 0){const d=fn.cloneDeep(S[l.style]);delete d.border,l.style=this.addStyle(d)}});else if(H==="all"||H==="inside"||H==="outside"||H==="horizontal"||H==="vertical"){const v=[];for(let h=y;h<=b;h+=1)for(let l=g;l<=w;l+=1){const d=[];for(let i=0;iv.splice(i,1)),l>w)break;const s=u.getCell(h,l);let[m,c]=[0,0];s&&s.merge&&([m,c]=s.merge,v.push([h,l,m,c]));const a=m>0&&h+m===b,r=c>0&&l+c===w;let t={};H==="all"?t={bottom:[x,e],top:[x,e],left:[x,e],right:[x,e]}:H==="inside"?(!r&&l0&&va.call(this,h,l,t),l+=c}}else if(H==="top"||H==="bottom")for(let v=g;v<=w;v+=1)H==="top"&&(va.call(this,y,v,{top:[x,e]}),v+=u.getCellMerge(y,v)[1]),H==="bottom"&&(va.call(this,b,v,{bottom:[x,e]}),v+=u.getCellMerge(b,v)[1]);else if(H==="left"||H==="right")for(let v=y;v<=b;v+=1)H==="left"&&(va.call(this,v,g,{left:[x,e]}),v+=u.getCellMerge(v,g)[0]),H==="right"&&(va.call(this,v,w,{right:[x,e]}),v+=u.getCellMerge(v,w)[0])}}function Em(H,x){const{rows:e}=this,S=this.freezeTotalHeight();let _=e.height;S+e.heightH);y+=1)u.has(y)||(b=e.getHeight(y),g+=b);return g-=b,g<=0?{ri:-1,top:0,height:b}:{ri:y-1,top:g,height:b}}function Tm(H,x){const{cols:e}=this,S=this.freezeTotalWidth();let _=e.indexWidth;S+e.indexWidthe.getWidth(b));return y<=0?{ci:-1,left:0,width:e.indexWidth}:{ci:u-1,left:y,width:g}}class Rm{constructor(x,e){this.settings=fn.merge(wm,e||{}),this.name=x||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new wf,this.rows=new mm(this.settings.row),this.cols=new bm(this.settings.col),this.validations=new _m,this.hyperlinks={},this.comments={},this.selector=new am,this.scroll=new om,this.history=new sm,this.clipboard=new fm,this.autoFilter=new um,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(x,e,S){this.changeData(()=>{this.validations.add(x,e,S)})}removeValidation(){const{range:x}=this.selector;this.changeData(()=>{this.validations.remove(x)})}getSelectedValidator(){const{ri:x,ci:e}=this.selector,S=this.validations.get(x,e);return S?S.validator:null}getSelectedValidation(){const{ri:x,ci:e,range:S}=this.selector,_=this.validations.get(x,e),u={ref:S.toString()};return _!==null&&(u.mode=_.mode,u.validator=_.validator),u}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),x=>{this.setData(x)})}redo(){this.history.redo(this.getData(),x=>{this.setData(x)})}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(){if(navigator.clipboard===void 0)return;let x="";const e=this.rows.getData();for(let S=this.selector.range.sri;S<=this.selector.range.eri;S+=1){if(Cl(e,S)){for(let _=this.selector.range.sci;_<=this.selector.range.eci;_+=1)if(_>this.selector.range.sci&&(x+=" "),Cl(e[S].cells,_)){const u=String(e[S].cells[_].text);u.indexOf(` +import{c as Wt,a as No,g as q0}from"./commonjs-dynamic-modules-2ceabb0b.23156833.js";import{g as em,a as tm}from"./colz-746223ab.12984b03.js";import"../app.0729b6dc.js";import"./framework.6fe2e870.js";import"./theme.eee41b28.js";var rm=Object.defineProperty,nm=(H,x,e)=>x in H?rm(H,x,{enumerable:!0,configurable:!0,writable:!0,value:e}):H[x]=e,Nn=(H,x,e)=>(nm(H,typeof x!="symbol"?x+"":x,e),e);class Xi{constructor(x,e=""){typeof x=="string"?(this.el=document.createElement(x),this.el.className=e):this.el=x,this.data={}}data(x,e){return e!==void 0?(this.data[x]=e,this):this.data[x]}on(x,e){const[S,..._]=x.split(".");let u=S;return u==="mousewheel"&&/Firefox/i.test(window.navigator.userAgent)&&(u="DOMMouseScroll"),this.el.addEventListener(u,y=>{e(y);for(let g=0;g<_.length;g+=1){const b=_[g];if(b==="left"&&y.button!==0||b==="right"&&y.button!==2)return;b==="stop"&&y.stopPropagation()}}),this}offset(x){if(x!==void 0)return Object.keys(x).forEach(y=>{this.css(y,`${x[y]}px`)}),this;const{offsetTop:e,offsetLeft:S,offsetHeight:_,offsetWidth:u}=this.el;return{top:e,left:S,height:_,width:u}}scroll(x){const{el:e}=this;return x!==void 0&&(x.left!==void 0&&(e.scrollLeft=x.left),x.top!==void 0&&(e.scrollTop=x.top)),{left:e.scrollLeft,top:e.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new Xi(this.el.parentNode)}children(...x){return arguments.length===0?this.el.childNodes:(x.forEach(e=>this.child(e)),this)}removeChild(x){this.el.removeChild(x)}child(x){let e=x;return typeof x=="string"?e=document.createTextNode(x):x instanceof Xi&&(e=x.el),this.el.appendChild(e),this}contains(x){return this.el.contains(x)}className(x){return x!==void 0?(this.el.className=x,this):this.el.className}addClass(x){return this.el.classList.add(x),this}hasClass(x){return this.el.classList.contains(x)}removeClass(x){return this.el.classList.remove(x),this}toggle(x="active"){return this.toggleClass(x)}toggleClass(x){return this.el.classList.toggle(x)}active(x=!0,e="active"){return x?this.addClass(e):this.removeClass(e),this}checked(x=!0){return this.active(x,"checked"),this}disabled(x=!0){return x?this.addClass("disabled"):this.removeClass("disabled"),this}attr(x,e){if(e!==void 0)this.el.setAttribute(x,e);else{if(typeof x=="string")return this.el.getAttribute(x);Object.keys(x).forEach(S=>{this.el.setAttribute(S,x[S])})}return this}removeAttr(x){return this.el.removeAttribute(x),this}html(x){return x!==void 0?(this.el.innerHTML=x,this):this.el.innerHTML}val(x){return x!==void 0?(this.el.value=x,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...x){return x.forEach(e=>this.el.style.removeProperty(e)),this}css(x,e){return e===void 0&&typeof x!="string"?(Object.keys(x).forEach(S=>{this.el.style[S]=x[S]}),this):e!==void 0?(this.el.style[x]=e,this):this.el.style[x]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const $e=(H,x="")=>new Xi(H,x),Ti=["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 ac(H){let x="",e=H;for(;e>=Ti.length;)e/=Ti.length,e-=1,x+=Ti[parseInt(e,10)%Ti.length];const S=H%Ti.length;return x+=Ti[S],x}function im(H){let x=0;for(let e=0;e="0"&&H.charAt(S)<="9"?e+=H.charAt(S):x+=H.charAt(S);return[im(x),parseInt(e,10)-1]}function di(H,x){return`${ac(H)}${x+1}`}function Ha(H,x,e,S=()=>!0){if(x===0&&e===0)return H;const[_,u]=Ri(H);return S(_,u)?di(_+x,u+e):H}class xr{constructor(x,e,S,_,u=0,y=0){this.sri=x,this.sci=e,this.eri=S,this.eci=_,this.w=u,this.h=y}set(x,e,S,_){this.sri=x,this.sci=e,this.eri=S,this.eci=_}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...x){let[e,S]=[0,0];x.length===1?[S,e]=Ri(x[0]):x.length===2&&([e,S]=x);const{sri:_,sci:u,eri:y,eci:g}=this;return _<=e&&e<=y&&u<=S&&S<=g}each(x,e=()=>!0){const{sri:S,sci:_,eri:u,eci:y}=this;for(let g=S;g<=u;g+=1)if(e(g))for(let b=_;b<=y;b+=1)x(g,b)}contains(x){return this.sri<=x.sri&&this.sci<=x.sci&&this.eri>=x.eri&&this.eci>=x.eci}within(x){return this.sri>=x.sri&&this.sci>=x.sci&&this.eri<=x.eri&&this.eci<=x.eci}disjoint(x){return this.sri>x.eri||this.sci>x.eci||x.sri>this.eri||x.sci>this.eci}intersects(x){return this.sri<=x.eri&&this.sci<=x.eci&&x.sri<=this.eri&&x.sci<=this.eci}union(x){const{sri:e,sci:S,eri:_,eci:u}=this;return new xr(x.sri_?x.eri:_,x.eci>u?x.eci:u)}difference(x){const e=[],S=(h,l,d,s)=>{e.push(new xr(h,l,d,s))},{sri:_,sci:u,eri:y,eci:g}=this,b=x.sri-_,w=x.sci-u,f=y-x.eri,v=g-x.eci;return b>0?(S(_,u,x.sri-1,g),f>0?(S(x.eri+1,u,y,g),w>0&&S(x.sri,u,x.eri,x.sci-1),v>0&&S(x.sri,x.eci+1,x.eri,g)):(w>0&&S(x.sri,u,y,x.sci-1),v>0&&S(x.sri,x.eci+1,y,g))):f>0&&(S(x.eri+1,u,y,g),w>0&&S(_,u,x.eri,x.sci-1),v>0&&S(_,x.eci+1,x.eri,g)),w>0?(S(_,u,y,x.sci-1),v>0?(S(_,x.eri+1,y,g),b>0&&S(_,x.sci,x.sri-1,x.eci),f>0&&S(x.sri+1,x.sci,y,x.eci)):(b>0&&S(_,x.sci,x.sri-1,g),f>0&&S(x.sri+1,x.sci,y,g))):v>0&&(S(y,x.eci+1,y,g),b>0&&S(_,u,x.sri-1,x.eci),f>0&&S(x.eri+1,u,y,x.eci)),e}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:x,sci:e,eri:S,eci:_}=this;let u=di(e,x);return this.multiple()&&(u=`${u}:${di(_,S)}`),u}clone(){const{sri:x,sci:e,eri:S,eci:_,w:u,h:y}=this;return new xr(x,e,S,_,u,y)}equals(x){return this.eri===x.eri&&this.eci===x.eci&&this.sri===x.sri&&this.sci===x.sci}static valueOf(x){const e=x.split(":"),[S,_]=Ri(e[0]);let[u,y]=[_,S];return e.length>1&&([y,u]=Ri(e[1])),new xr(_,S,u,y)}}let am=class{constructor(){this.range=new xr(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(x,e){this.ri=x,this.ci=e}size(){return this.range.size()}};class om{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class sm{constructor(){this.undoItems=[],this.redoItems=[]}add(x){this.undoItems.push(JSON.stringify(x)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(x,e){const{undoItems:S,redoItems:_}=this;this.canUndo()&&(_.push(JSON.stringify(x)),e(JSON.parse(S.pop())))}redo(x,e){const{undoItems:S,redoItems:_}=this;this.canRedo()&&(S.push(JSON.stringify(x)),e(JSON.parse(_.pop())))}}class fm{constructor(){this.range=null,this.state="clear"}copy(x){return this.range=x,this.state="copy",this}cut(x){return this.range=x,this.state="cut",this}isCopy(){return this.state==="copy"}isCut(){return this.state==="cut"}isClear(){return this.state==="clear"}clear(){this.range=null,this.state="clear"}}class Ol{constructor(x,e,S){this.ci=x,this.operator=e,this.value=S}set(x,e){this.operator=x,this.value=e}includes(x){const{operator:e,value:S}=this;return e==="all"?!0:e==="in"?S.includes(x):!1}vlength(){const{operator:x,value:e}=this;return x==="in"?e.length:0}getData(){const{ci:x,operator:e,value:S}=this;return{ci:x,operator:e,value:S}}}class El{constructor(x,e){this.ci=x,this.order=e}asc(){return this.order==="asc"}desc(){return this.order==="desc"}}class um{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:x,filters:e,sort:S}){x!=null&&(this.ref=x,this.filters=e.map(_=>new Ol(_.ci,_.operator,_.value)),S&&(this.sort=new El(S.ci,S.order)))}getData(){if(this.active()){const{ref:x,filters:e,sort:S}=this;return{ref:x,filters:e.map(_=>_.getData()),sort:S}}return{}}addFilter(x,e,S){const _=this.getFilter(x);_==null?this.filters.push(new Ol(x,e,S)):_.set(e,S)}setSort(x,e){this.sort=e?new El(x,e):null}includes(x,e){return this.active()?this.hrange().includes(x,e):!1}getSort(x){const{sort:e}=this;return e&&e.ci===x?e:null}getFilter(x){const{filters:e}=this;for(let S=0;S!e.within(x))}getFirstIncludes(x,e){for(let S=0;Se.intersects(x)))}intersects(x){for(let e=0;e{S.intersects(e)&&(e=S.union(e))}),e}add(x){this.deleteWithin(x),this._.push(x)}shift(x,e,S,_){this._.forEach(u=>{const{sri:y,sci:g,eri:b,eci:w}=u,f=u;x==="row"?y>=e?(f.sri+=S,f.eri+=S):y=e?(f.sci+=S,f.eci+=S):g{const u=_;u.within(x)&&(u.eri+=e,u.sri+=e,u.sci+=S,u.eci+=S)})}setData(x){return this._=x.map(e=>xr.valueOf(e)),this}getData(){return this._.map(x=>x.toString())}}function lm(H){return JSON.parse(JSON.stringify(H))}const oc=(H={},...x)=>(x.forEach(e=>{Object.keys(e).forEach(S=>{const _=e[S];typeof _=="string"||typeof _=="number"||typeof _=="boolean"?H[S]=_:typeof _!="function"&&!Array.isArray(_)&&_ instanceof Object?(H[S]=H[S]||{},oc(H[S],_)):H[S]=_})}),H);function hf(H,x){const e=Object.keys(H);if(e.length!==Object.keys(x).length)return!1;for(let S=0;Se)=>{let e=0,S=0;return Object.keys(H).forEach(_=>{e+=x(H[_],_),S+=1}),[e,S]};function hm(H,x){const e=H[`${x}`];return delete H[`${x}`],e}function dm(H,x,e,S,_,u){let y=e,g=S,b=H;for(;b_);b+=1)g=u(b),y+=g;return[b,y-g,g]}function pm(H,x,e){let S=0;for(let _=H;_5?g.toFixed(2):g;return g.toFixed(Math.max(S,_))}const fn={cloneDeep:lm,merge:(...H)=>oc({},...H),equals:hf,arrayEquals:ym,sum:cm,rangeEach:vm,rangeSum:pm,rangeReduceIf:dm,deleteProperty:hm,numberCalc:Li};class mm{constructor({len:x,height:e}){this._={},this.len=x,this.height=e}getHeight(x){if(this.isHide(x))return 0;const e=this.get(x);return e&&e.height?e.height:this.height}setHeight(x,e){const S=this.getOrNew(x);S.height=e}unhide(x){let e=x;for(;e>0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}isHide(x){const e=this.get(x);return e&&e.hide}setHide(x,e){const S=this.getOrNew(x);e===!0?S.hide=!0:delete S.hide}setStyle(x,e){const S=this.getOrNew(x);S.style=e}sumHeight(x,e,S){return fn.rangeSum(x,e,_=>S&&S.has(_)?0:this.getHeight(_))}totalHeight(){return this.sumHeight(0,this.len)}get(x){return this._[x]}getOrNew(x){return this._[x]=this._[x]||{cells:{}},this._[x]}getCell(x,e){const S=this.get(x);return S!==void 0&&S.cells!==void 0&&S.cells[e]!==void 0?S.cells[e]:null}getCellMerge(x,e){const S=this.getCell(x,e);return S&&S.merge?S.merge:[0,0]}getCellOrNew(x,e){const S=this.getOrNew(x);return S.cells[e]=S.cells[e]||{},S.cells[e]}setCell(x,e,S,_="all"){const u=this.getOrNew(x);_==="all"?u.cells[e]=S:_==="text"?(u.cells[e]=u.cells[e]||{},u.cells[e].text=S.text):_==="format"&&(u.cells[e]=u.cells[e]||{},u.cells[e].style=S.style,S.merge&&(u.cells[e].merge=S.merge))}setCellText(x,e,S){const _=this.getCellOrNew(x,e);_.editable!==!1&&(_.text=S)}copyPaste(x,e,S,_=!1,u=()=>{}){const{sri:y,sci:g,eri:b,eci:w}=x,f=e.sri,v=e.sci,h=e.eri,l=e.eci,[d,s]=x.size(),[m,c]=e.size();let a=!0,r=0;(h0){const{text:D}=P;let z=o-v+(n-f)+2;if(a||(z-=r+1),D[0]==="=")P.text=D.replace(/[a-zA-Z]{1,3}\d+/g,B=>{let[M,I]=[0,0];return y===f?M=z-1:I=z-1,/^\d+$/.test(B)?B:Ha(B,M,I)});else if(d<=1&&s>1&&(f>b||h1&&(v>w||l{this.eachCells(_,u=>{let y=parseInt(_,10),g=parseInt(u,10);x.includes(_,u)&&(y=e.sri+(y-x.sri),g=e.sci+(g-x.sci)),S[y]=S[y]||{cells:{}},S[y].cells[g]=this._[_].cells[u]})}),this._=S}paste(x,e){if(x.length<=0)return;const{sri:S,sci:_}=e;x.forEach((u,y)=>{const g=S+y;u.forEach((b,w)=>{const f=_+w;this.setCellText(g,f,b)})})}insert(x,e=1){const S={};this.each((_,u)=>{let y=parseInt(_,10);y>=x&&(y+=e,this.eachCells(_,(g,b)=>{b.text&&b.text[0]==="="&&(b.text=b.text.replace(/[a-zA-Z]{1,3}\d+/g,w=>Ha(w,0,e,(f,v)=>v>=x)))})),S[y]=u}),this._=S,this.len+=e}delete(x,e){const S=e-x+1,_={};this.each((u,y)=>{const g=parseInt(u,10);ge&&(_[g-S]=y,this.eachCells(u,(b,w)=>{w.text&&w.text[0]==="="&&(w.text=w.text.replace(/[a-zA-Z]{1,3}\d+/g,f=>Ha(f,0,-S,(v,h)=>h>e)))}))}),this._=_,this.len-=S}insertColumn(x,e=1){this.each((S,_)=>{const u={};this.eachCells(S,(y,g)=>{let b=parseInt(y,10);b>=x&&(b+=e,g.text&&g.text[0]==="="&&(g.text=g.text.replace(/[a-zA-Z]{1,3}\d+/g,w=>Ha(w,e,0,f=>f>=x)))),u[b]=g}),_.cells=u})}deleteColumn(x,e){const S=e-x+1;this.each((_,u)=>{const y={};this.eachCells(_,(g,b)=>{const w=parseInt(g,10);we&&(y[w-S]=b,b.text&&b.text[0]==="="&&(b.text=b.text.replace(/[a-zA-Z]{1,3}\d+/g,f=>Ha(f,-S,0,v=>v>e))))}),u.cells=y})}deleteCells(x,e="all"){x.each((S,_)=>{this.deleteCell(S,_,e)})}deleteCell(x,e,S="all"){const _=this.get(x);if(_!==null){const u=this.getCell(x,e);u!==null&&u.editable!==!1&&(S==="all"?delete _.cells[e]:S==="text"?(u.text&&delete u.text,u.value&&delete u.value):S==="format"?(u.style!==void 0&&delete u.style,u.merge&&delete u.merge):S==="merge"&&u.merge&&delete u.merge)}}maxCell(){const x=Object.keys(this._),e=x[x.length-1],S=this._[e];if(S){const{cells:_}=S,u=Object.keys(_),y=u[u.length-1];return[parseInt(e,10),parseInt(y,10)]}return[0,0]}each(x){Object.entries(this._).forEach(([e,S])=>{x(e,S)})}eachCells(x,e){this._[x]&&this._[x].cells&&Object.entries(this._[x].cells).forEach(([S,_])=>{e(S,_)})}setData(x){x.len&&(this.len=x.len,delete x.len),this._=x}getData(){const{len:x}=this;return Object.assign({len:x},this._)}}class bm{constructor({len:x,width:e,indexWidth:S,minWidth:_}){this._={},this.len=x,this.width=e,this.indexWidth=S,this.minWidth=_}setData(x){x.len&&(this.len=x.len,delete x.len),this._=x}getData(){const{len:x}=this;return Object.assign({len:x},this._)}getWidth(x){if(this.isHide(x))return 0;const e=this._[x];return e&&e.width?e.width:this.width}getOrNew(x){return this._[x]=this._[x]||{},this._[x]}setWidth(x,e){const S=this.getOrNew(x);S.width=e}unhide(x){let e=x;for(;e>0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}isHide(x){const e=this._[x];return e&&e.hide}setHide(x,e){const S=this.getOrNew(x);e===!0?S.hide=!0:delete S.hide}setStyle(x,e){const S=this.getOrNew(x);S.style=e}sumWidth(x,e){return fn.rangeSum(x,e,S=>this.getWidth(S))}totalWidth(){return this.sumWidth(0,this.len)}}const gm={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"}}};let df=["en"];const sc={en:gm};function Tl(H,x){if(x)for(const e of df){if(!x[e])break;let S=x[e];const _=H.match(/(?:\\.|[^.])+/g);for(let u=0;u<_.length;u+=1){const y=_[u],g=S[y];if(!g)break;if(u===_.length-1)return g;S=g}}}function Cr(H){let x=Tl(H,sc);return!x&&window&&window.x_spreadsheet&&window.x_spreadsheet.$messages&&(x=Tl(H,window.x_spreadsheet.$messages)),x||""}function Jt(H){return()=>Cr(H)}function fc(H,x,e=!1){e?df=[H]:df.unshift(H),x&&(sc[H]=x)}const Rl={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function $n(H,x,...e){let S="";return H||(S=Cr(`validation.${x}`,...e)),[H,S]}class uc{constructor(x,e,S,_){this.required=e,this.value=S,this.type=x,this.operator=_,this.message=""}parseValue(x){const{type:e}=this;return e==="date"?new Date(x):e==="number"?Number(x):x}equals(x){let e=this.type===x.type&&this.required===x.required&&this.operator===x.operator;return e&&(Array.isArray(this.value)?e=fn.arrayEquals(this.value,x.value):e=this.value===x.value),e}values(){return this.value.split(",")}validate(x){const{required:e,operator:S,value:_,type:u}=this;if(e&&/^\s*$/.test(x))return $n(!1,"required");if(/^\s*$/.test(x))return[!0];if(Rl[u]&&!Rl[u].test(x))return $n(!1,"notMatch");if(u==="list")return $n(this.values().includes(x),"notIn");if(S){const y=this.parseValue(x);if(S==="be"){const[g,b]=_;return $n(y>=this.parseValue(g)&&y<=this.parseValue(b),"between",g,b)}if(S==="nbe"){const[g,b]=_;return $n(ythis.parseValue(b),"notBetween",g,b)}if(S==="eq")return $n(y===this.parseValue(_),"equal",_);if(S==="neq")return $n(y!==this.parseValue(_),"notEqual",_);if(S==="lt")return $n(ythis.parseValue(_),"greaterThan",_);if(S==="gte")return $n(y>=this.parseValue(_),"greaterThanEqual",_)}return[!0]}}class Ko{constructor(x,e,S){this.refs=e,this.mode=x,this.validator=S}includes(x,e){const{refs:S}=this;for(let _=0;_{const _=xr.valueOf(S);_.intersects(x)?_.difference(x).forEach(y=>e.push(y.toString())):e.push(S)}),this.refs=e}getData(){const{refs:x,mode:e,validator:S}=this,{type:_,required:u,operator:y,value:g}=S;return{refs:x,mode:e,type:_,required:u,operator:y,value:g}}static valueOf({refs:x,mode:e,type:S,required:_,operator:u,value:y}){return new Ko(e,x,new uc(S,_,y,u))}}class _m{constructor(){this._=[],this.errors=new Map}getError(x,e){return this.errors.get(`${x}_${e}`)}validate(x,e,S){const _=this.get(x,e),u=`${x}_${e}`,{errors:y}=this;if(_!==null){const[g,b]=_.validator.validate(S);g?y.delete(u):y.set(u,b)}else y.delete(u);return!0}add(x,e,{type:S,required:_,value:u,operator:y}){const g=new uc(S,_,u,y),b=this.getByValidator(g);b!==null?b.addRef(e):this._.push(new Ko(x,[e],g))}getByValidator(x){for(let e=0;e{e.remove(x)})}each(x){this._.forEach(e=>x(e))}getData(){return this._.filter(x=>x.refs.length>0).map(x=>x.getData())}setData(x){this._=x.map(e=>Ko.valueOf(e))}}const wm={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"}},Sm=41,km=41,Cl=(H,x)=>Object.prototype.hasOwnProperty.call(H,x);function Pl(H,x,e=()=>{}){const{merges:S}=this,_=x.clone(),[u,y]=H.size(),[g,b]=x.size();return u>g&&(_.eri=x.sri+u-1),y>b&&(_.eci=x.sci+y-1),S.intersects(_)?(e(Cr("error.pasteForMergedCell")),!1):!0}function Al(H,x,e,S=!1){const{rows:_,merges:u}=this;(e==="all"||e==="format")&&(_.deleteCells(x,e),u.deleteWithin(x)),_.copyPaste(H,x,e,S,(y,g,b)=>{if(b&&b.merge){const[w,f]=b.merge;if(w<=0&&f<=0)return;u.add(new xr(y,g,y+w,g+f))}})}function xm(H,x){const{clipboard:e,rows:S,merges:_}=this;S.cutPaste(H,x),_.move(H,x.sri-H.sri,x.sci-H.sci),e.clear()}function va(H,x,e){const{styles:S,rows:_}=this,u=_.getCellOrNew(H,x);let y={};u.style!==void 0&&(y=fn.cloneDeep(S[u.style])),y=fn.merge(y,{border:e}),u.style=this.addStyle(y)}function Om({mode:H,style:x,color:e}){const{styles:S,selector:_,rows:u}=this,{sri:y,sci:g,eri:b,eci:w}=_.range,f=!this.isSignleSelected();if(!(!f&&(H==="inside"||H==="horizontal"||H==="vertical"))){if(H==="outside"&&!f)va.call(this,y,g,{top:[x,e],bottom:[x,e],left:[x,e],right:[x,e]});else if(H==="none")_.range.each((v,h)=>{const l=u.getCell(v,h);if(l&&l.style!==void 0){const d=fn.cloneDeep(S[l.style]);delete d.border,l.style=this.addStyle(d)}});else if(H==="all"||H==="inside"||H==="outside"||H==="horizontal"||H==="vertical"){const v=[];for(let h=y;h<=b;h+=1)for(let l=g;l<=w;l+=1){const d=[];for(let i=0;iv.splice(i,1)),l>w)break;const s=u.getCell(h,l);let[m,c]=[0,0];s&&s.merge&&([m,c]=s.merge,v.push([h,l,m,c]));const a=m>0&&h+m===b,r=c>0&&l+c===w;let t={};H==="all"?t={bottom:[x,e],top:[x,e],left:[x,e],right:[x,e]}:H==="inside"?(!r&&l0&&va.call(this,h,l,t),l+=c}}else if(H==="top"||H==="bottom")for(let v=g;v<=w;v+=1)H==="top"&&(va.call(this,y,v,{top:[x,e]}),v+=u.getCellMerge(y,v)[1]),H==="bottom"&&(va.call(this,b,v,{bottom:[x,e]}),v+=u.getCellMerge(b,v)[1]);else if(H==="left"||H==="right")for(let v=y;v<=b;v+=1)H==="left"&&(va.call(this,v,g,{left:[x,e]}),v+=u.getCellMerge(v,g)[0]),H==="right"&&(va.call(this,v,w,{right:[x,e]}),v+=u.getCellMerge(v,w)[0])}}function Em(H,x){const{rows:e}=this,S=this.freezeTotalHeight();let _=e.height;S+e.heightH);y+=1)u.has(y)||(b=e.getHeight(y),g+=b);return g-=b,g<=0?{ri:-1,top:0,height:b}:{ri:y-1,top:g,height:b}}function Tm(H,x){const{cols:e}=this,S=this.freezeTotalWidth();let _=e.indexWidth;S+e.indexWidthe.getWidth(b));return y<=0?{ci:-1,left:0,width:e.indexWidth}:{ci:u-1,left:y,width:g}}class Rm{constructor(x,e){this.settings=fn.merge(wm,e||{}),this.name=x||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new wf,this.rows=new mm(this.settings.row),this.cols=new bm(this.settings.col),this.validations=new _m,this.hyperlinks={},this.comments={},this.selector=new am,this.scroll=new om,this.history=new sm,this.clipboard=new fm,this.autoFilter=new um,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(x,e,S){this.changeData(()=>{this.validations.add(x,e,S)})}removeValidation(){const{range:x}=this.selector;this.changeData(()=>{this.validations.remove(x)})}getSelectedValidator(){const{ri:x,ci:e}=this.selector,S=this.validations.get(x,e);return S?S.validator:null}getSelectedValidation(){const{ri:x,ci:e,range:S}=this.selector,_=this.validations.get(x,e),u={ref:S.toString()};return _!==null&&(u.mode=_.mode,u.validator=_.validator),u}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),x=>{this.setData(x)})}redo(){this.history.redo(this.getData(),x=>{this.setData(x)})}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(){if(navigator.clipboard===void 0)return;let x="";const e=this.rows.getData();for(let S=this.selector.range.sri;S<=this.selector.range.eri;S+=1){if(Cl(e,S)){for(let _=this.selector.range.sci;_<=this.selector.range.eci;_+=1)if(_>this.selector.range.sci&&(x+=" "),Cl(e[S].cells,_)){const u=String(e[S].cells[_].text);u.indexOf(` `)===-1&&u.indexOf(" ")===-1&&u.indexOf('"')===-1?x+=u:x+=`"${u}"`}}else for(let _=this.selector.range.sci;_<=this.selector.range.eci;_+=1)x+=" ";x+=` `}navigator.clipboard.writeText(x).then(()=>{},S=>{console.log("text copy to the system clipboard error ",x,S)})}cut(){this.clipboard.cut(this.selector.range)}paste(x="all",e=()=>{}){const{clipboard:S,selector:_}=this;return S.isClear()||!Pl.call(this,S.range,_.range,e)?!1:(this.changeData(()=>{S.isCopy()?Al.call(this,S.range,_.range,x):S.isCut()&&xm.call(this,S.range,_.range)}),!0)}pasteFromText(x){const e=x.split(`\r `).map(u=>u.replace(/"/g,"").split(" "));e.length>0&&(e.length-=1);const{rows:S,selector:_}=this;this.changeData(()=>{S.paste(e,_.range)})}autofill(x,e,S=()=>{}){const _=this.selector.range;return Pl.call(this,_,x,S)?(this.changeData(()=>{Al.call(this,_,x,e,!0)}),!0):!1}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(x,e){const{selector:S,rows:_,cols:u,merges:y}=this;let{sri:g,sci:b,eri:w,eci:f}=S.range;const v=S.ri,h=S.ci;let[l,d]=[x,e];return x<0&&(l=_.len-1),e<0&&(d=u.len-1),l>v?[g,w]=[v,l]:[g,w]=[l,v],d>h?[b,f]=[h,d]:[b,f]=[d,h],S.range=y.union(new xr(g,b,w,f)),S.range=y.union(S.range),S.range}calSelectedRangeByStart(x,e){const{selector:S,rows:_,cols:u,merges:y}=this;let g=y.getFirstIncludes(x,e);return g===null&&(g=new xr(x,e,x,e),x===-1&&(g.sri=0,g.eri=_.len-1),e===-1&&(g.sci=0,g.eci=u.len-1)),S.range=g,g}setSelectedCellAttr(x,e){this.changeData(()=>{const{selector:S,styles:_,rows:u}=this;if(x==="merge")e?this.merge():this.unmerge();else if(x==="border")Om.call(this,e);else if(x==="formula"){const{ri:y,ci:g,range:b}=S;if(S.multiple()){const[w,f]=S.size(),{sri:v,sci:h,eri:l,eci:d}=b;if(w>1)for(let s=h;s<=d;s+=1){const m=u.getCellOrNew(l+1,s);m.text=`=${e}(${di(s,v)}:${di(s,l)})`}else if(f>1){const s=u.getCellOrNew(y,d+1);s.text=`=${e}(${di(h,y)}:${di(d,y)})`}}else{const w=u.getCellOrNew(y,g);w.text=`=${e}()`}}else S.range.each((y,g)=>{const b=u.getCellOrNew(y,g);let w={};if(b.style!==void 0&&(w=fn.cloneDeep(_[b.style])),x==="format")w.format=e,b.style=this.addStyle(w);else if(x==="font-bold"||x==="font-italic"||x==="font-name"||x==="font-size"){const f={};f[x.split("-")[1]]=e,w.font=Object.assign(w.font||{},f),b.style=this.addStyle(w)}else x==="strike"||x==="textwrap"||x==="underline"||x==="align"||x==="valign"||x==="color"||x==="bgcolor"?(w[x]=e,b.style=this.addStyle(w)):b[x]=e})})}setSelectedCellText(x,e="input"){const{autoFilter:S,selector:_,rows:u}=this,{ri:y,ci:g}=_;let b=y;this.unsortedRowMap.has(y)&&(b=this.unsortedRowMap.get(y));const w=u.getCell(b,g),f=w?w.text:"";if(this.setCellText(b,g,x,e),S.active()){const v=S.getFilter(g);if(v){const h=v.value.findIndex(l=>l===f);h>=0&&v.value.splice(h,1,x)}}}getSelectedCell(){const{ri:x,ci:e}=this.selector;let S=x;return this.unsortedRowMap.has(x)&&(S=this.unsortedRowMap.get(x)),this.rows.getCell(S,e)}xyInSelectedRect(x,e){const{left:S,top:_,width:u,height:y}=this.getSelectedRect(),g=x-this.cols.indexWidth,b=e-this.rows.height;return g>S&&g_&&b<_+y}getSelectedRect(){return this.getRect(this.selector.range)}getClipboardRect(){const{clipboard:x}=this;return x.isClear()?{left:-100,top:-100}:this.getRect(x.range)}getRect(x){const{scroll:e,rows:S,cols:_,exceptRowSet:u}=this,{sri:y,sci:g,eri:b,eci:w}=x;if(y<0&&g<0)return{left:0,l:0,top:0,t:0,scroll:e};const f=_.sumWidth(0,g),v=S.sumHeight(0,y,u),h=S.sumHeight(y,b+1,u),l=_.sumWidth(g,w+1);let d=f-e.x,s=v-e.y;const m=this.freezeTotalHeight(),c=this.freezeTotalWidth();return c>0&&c>f&&(d=f),m>0&&m>v&&(s=v),{l:f,t:v,left:d,top:s,height:h,width:l,scroll:e}}getCellRectByXY(x,e){const{scroll:S,merges:_,rows:u,cols:y}=this;let{ri:g,top:b,height:w}=Em.call(this,e,S.y),{ci:f,left:v,width:h}=Tm.call(this,x,S.x);if(f===-1&&(h=y.totalWidth()),g===-1&&(w=u.totalHeight()),g>=0||f>=0){const l=_.getFirstIncludes(g,f);l&&(g=l.sri,f=l.sci,{left:v,top:b,width:h,height:w}=this.cellRect(g,f))}return{ri:g,ci:f,left:v,top:b,width:h,height:w}}isSignleSelected(){const{sri:x,sci:e,eri:S,eci:_}=this.selector.range,u=this.getCell(x,e);if(u&&u.merge){const[y,g]=u.merge;if(x+y===S&&e+g===_)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:x,sci:e,eri:S,eci:_}=this.selector.range,u=this.getCell(x,e);if(u&&u.merge){const[y,g]=u.merge;if(x+y===S&&e+g===_)return!0}return!1}merge(){const{selector:x,rows:e}=this;if(this.isSignleSelected())return;const[S,_]=x.size();if(S>1||_>1){const{sri:u,sci:y}=x.range;this.changeData(()=>{const g=e.getCellOrNew(u,y);g.merge=[S-1,_-1],this.merges.add(x.range),this.rows.deleteCells(x.range),this.rows.setCell(u,y,g)})}}unmerge(){const{selector:x}=this;if(!this.isSignleSelected())return;const{sri:e,sci:S}=x.range;this.changeData(()=>{this.rows.deleteCell(e,S,"merge"),this.merges.deleteWithin(x.range)})}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:x,selector:e}=this;this.changeData(()=>{x.active()?(x.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):x.ref=e.range.toString()})}setAutoFilter(x,e,S,_){const{autoFilter:u}=this;u.addFilter(x,S,_),u.setSort(x,e),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:x,rows:e}=this;if(!x.active())return;const{sort:S}=x,{rset:_,fset:u}=x.filteredRows((b,w)=>e.getCell(b,w)),y=Array.from(u),g=Array.from(u);S&&y.sort((b,w)=>S.order==="asc"?b-w:S.order==="desc"?w-b:0),this.exceptRowSet=_,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,y.forEach((b,w)=>{this.sortedRowMap.set(g[w],b),this.unsortedRowMap.set(b,g[w])})}deleteCell(x="all"){const{selector:e}=this;this.changeData(()=>{this.rows.deleteCells(e.range,x),(x==="all"||x==="format")&&this.merges.deleteWithin(e.range)})}insert(x,e=1){this.changeData(()=>{const{sri:S,sci:_}=this.selector.range,{rows:u,merges:y,cols:g}=this;let b=S;x==="row"?u.insert(S,e):x==="column"&&(u.insertColumn(_,e),b=_,g.len+=1),y.shift(x,b,e,(w,f,v,h)=>{const l=u.getCell(w,f);l.merge[0]+=v,l.merge[1]+=h})})}delete(x){this.changeData(()=>{const{rows:e,merges:S,selector:_,cols:u}=this,{range:y}=_,{sri:g,sci:b,eri:w,eci:f}=_.range,[v,h]=_.range.size();let l=g,d=v;x==="row"?e.delete(g,w):x==="column"&&(e.deleteColumn(b,f),l=y.sci,d=h,u.len-=1),S.shift(x,l,-d,(s,m,c,a)=>{const r=e.getCell(s,m);r.merge[0]+=c,r.merge[1]+=a,r.merge[0]===0&&r.merge[1]===0&&delete r.merge})})}scrollx(x,e){const{scroll:S,freeze:_,cols:u}=this,[,y]=_,[g,b,w]=fn.rangeReduceIf(y,u.len,0,0,x,v=>u.getWidth(v));let f=b;x>0&&(f+=w),S.x!==f&&(S.ci=x>0?g:0,S.x=f,e())}scrolly(x,e){const{scroll:S,freeze:_,rows:u}=this,[y]=_,[g,b,w]=fn.rangeReduceIf(y,u.len,0,0,x,v=>u.getHeight(v));let f=b;x>0&&(f+=w),S.y!==f&&(S.ri=x>0?g:0,S.y=f,e())}cellRect(x,e){const{rows:S,cols:_}=this,u=_.sumWidth(0,e),y=S.sumHeight(0,x),g=S.getCell(x,e);let b=_.getWidth(e),w=S.getHeight(x);if(g!==null&&g.merge){const[f,v]=g.merge;if(f>0)for(let h=1;h<=f;h+=1)w+=S.getHeight(x+h);if(v>0)for(let h=1;h<=v;h+=1)b+=_.getWidth(e+h)}return{left:u,top:y,width:b,height:w,cell:g}}getCell(x,e){return this.rows.getCell(x,e)}getCellTextOrDefault(x,e){const S=this.getCell(x,e);return S&&S.text?S.text:""}getCellStyle(x,e){const S=this.getCell(x,e);return S&&S.style!==void 0?this.styles[S.style]:null}getCellStyleOrDefault(x,e){const{styles:S,rows:_}=this,u=_.getCell(x,e),y=u&&u.style!==void 0?S[u.style]:{};return fn.merge(this.defaultStyle(),y)}getSelectedCellStyle(){const{ri:x,ci:e}=this.selector;return this.getCellStyleOrDefault(x,e)}setCellText(x,e,S,_){const{rows:u,history:y,validations:g}=this;_==="finished"?(u.setCellText(x,e,""),y.add(this.getData()),u.setCellText(x,e,S)):(u.setCellText(x,e,S),this.change(this.getData())),g.validate(x,e,S)}freezeIsActive(){const[x,e]=this.freeze;return x>0||e>0}setFreeze(x,e){this.changeData(()=>{this.freeze=[x,e]})}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(x,e){this.changeData(()=>{this.rows.setHeight(x,e)})}setColWidth(x,e){this.changeData(()=>{this.cols.setWidth(x,e)})}viewHeight(){const{view:x,showToolbar:e,showBottomBar:S}=this.settings;let _=x.height();return S&&(_-=km),e&&(_-=Sm),_}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[x,e]=this.freeze;return new xr(0,0,x-1,e-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:x,cols:e}=this,[S,_]=x.maxCell(),u=x.sumHeight(0,S+1),y=e.sumWidth(0,_+1);return new xr(0,0,S,_,y,u)}exceptRowTotalHeight(x,e){const{exceptRowSet:S,rows:_}=this,u=Array.from(S);let y=0;return u.forEach(g=>{if(ge){const b=_.getHeight(g);y+=b}}),y}viewRange(){const{scroll:x,rows:e,cols:S,freeze:_,exceptRowSet:u}=this;let{ri:y,ci:g}=x;y<=0&&([y]=_),g<=0&&([,g]=_);let[b,w]=[0,0],[f,v]=[e.len,S.len];for(let h=y;hthis.viewHeight()));h+=1);for(let h=g;hthis.viewWidth()));h+=1);return new xr(y,g,f,v,b,w)}eachMergesInView(x,e){this.merges.filterIntersects(x).forEach(S=>e(S))}hideRowsOrCols(){const{rows:x,cols:e,selector:S}=this,[_,u]=S.size(),{sri:y,sci:g,eri:b,eci:w}=S.range;if(_===x.len)for(let f=g;f<=w;f+=1)e.setHide(f,!0);else if(u===e.len)for(let f=y;f<=b;f+=1)x.setHide(f,!0)}unhideRowsOrCols(x,e){this[`${x}s`].unhide(e)}rowEach(x,e,S){let _=0;const{rows:u}=this,y=this.exceptRowSet,g=[...y];let b=0;for(let w=0;w0&&(S(w,_,f),_+=f,_>this.viewHeight()))break}}colEach(x,e,S){let _=0;const{cols:u}=this;for(let y=x;y<=e;y+=1){const g=u.getWidth(y);if(g>0&&(S(y,_,g),_+=g,_>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(x){const{styles:e}=this;for(let S=0;S{if(e==="merges"||e==="rows"||e==="cols"||e==="validations")this[e].setData(x[e]);else if(e==="freeze"){const[S,_]=Ri(x[e]);this.freeze=[_,S]}else e==="autofilter"?this.autoFilter.setData(x[e]):x[e]!==void 0&&(this[e]=x[e])}),this}getData(){const{name:x,freeze:e,styles:S,merges:_,rows:u,cols:y,validations:g,autoFilter:b}=this;return{name:x,freeze:di(e[1],e[0]),styles:S,merges:_.getData(),rows:u.getData(),cols:y.getData(),validations:g.getData(),autofilter:b.getData()}}}function ln(H,x,e){H.addEventListener(x,e)}function Go(H,x,e){H.removeEventListener(x,e)}function _a(H){H.xclickoutside&&(Go(window.document.body,"click",H.xclickoutside),delete H.xclickoutside)}function Va(H,x){H.xclickoutside=e=>{e.detail===2||H.contains(e.target)||(x?x(H):(H.hide(),_a(H)))},ln(window.document.body,"click",H.xclickoutside)}function lc(H,x,e){ln(H,"mousemove",x);const S=H;S.xEvtUp=_=>{Go(H,"mousemove",x),Go(H,"mouseup",H.xEvtUp),e(_)},ln(H,"mouseup",H.xEvtUp)}function Ml(H,x,e,S){let _="";Math.abs(H)>Math.abs(x)?(_=H>0?"right":"left",S(_,H,e)):(_=x>0?"down":"up",S(_,x,e))}function Cm(H,{move:x,end:e}){let S=0,_=0;ln(H,"touchstart",u=>{const{pageX:y,pageY:g}=u.touches[0];S=y,_=g}),ln(H,"touchmove",u=>{if(!x)return;const{pageX:y,pageY:g}=u.changedTouches[0],b=y-S,w=g-_;(Math.abs(b)>10||Math.abs(w)>10)&&(Ml(b,w,u,x),S=y,_=g),u.preventDefault()}),ln(H,"touchend",u=>{if(!e)return;const{pageX:y,pageY:g}=u.changedTouches[0],b=y-S,w=g-_;Ml(b,w,u,e)})}function Pm(){const H=new Map;function x(y,g){const b=()=>{const f=H.get(y);return Array.isArray(f)&&f.push(g)||!1},w=()=>H.set(y,[].concat(g));return H.has(y)&&b()||w()}function e(y,g){const b=()=>{const w=H.get(y);for(const f of w)f.call(null,...g)};return H.has(y)&&b()}function S(y,g){const b=()=>{const w=H.get(y),f=w.indexOf(g);return f>=0&&w.splice(f,1)&&H.get(y).length===0&&H.delete(y)};return H.has(y)&&b()}function _(y,g){const b=(...w)=>{g.call(null,...w),S(y,b)};return x(y,b)}function u(){H.clear()}return{get current(){return H},on:x,once:_,fire:e,removeListener:S,removeAllListeners:u}}const lt="x-spreadsheet";class Il{constructor(x=!1,e){this.moving=!1,this.vertical=x,this.el=$e("div",`${lt}-resizer ${x?"vertical":"horizontal"}`).children(this.unhideHoverEl=$e("div",`${lt}-resizer-hover`).on("dblclick.stop",S=>this.mousedblclickHandler(S)).css("position","absolute").hide(),this.hoverEl=$e("div",`${lt}-resizer-hover`).on("mousedown.stop",S=>this.mousedownHandler(S)),this.lineEl=$e("div",`${lt}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=e,this.unhideFn=()=>{}}showUnhide(x){this.unhideIndex=x,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(x,e){const{moving:S,vertical:_,hoverEl:u,lineEl:y,el:g,unhideHoverEl:b}=this;if(S)return;this.cRect=x;const{left:w,top:f,width:v,height:h}=x;g.offset({left:_?w+v-5:w,top:_?f:f+h-5}).show(),u.offset({width:_?5:v,height:_?h:5}),y.offset({width:_?0:e.width,height:_?e.height:0}),b.offset({left:_?5-v:w,top:_?f:5-h,width:_?5:v,height:_?h:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(x){let e=x;const{el:S,lineEl:_,cRect:u,vertical:y,minDistance:g}=this;let b=y?u.width:u.height;_.show(),lc(window,w=>{this.moving=!0,e!==null&&w.buttons===1&&(y?(b+=w.movementX,b>g&&S.css("left",`${u.left+b}px`)):(b+=w.movementY,b>g&&S.css("top",`${u.top+b}px`)),e=w)},()=>{e=null,_.hide(),this.moving=!1,this.hide(),this.finishedFn&&(b{}).on("scroll.stop",e=>{const{scrollTop:S,scrollLeft:_}=e.target;this.moveFn&&this.moveFn(this.vertical?S:_,e)})}move(x){return this.el.scroll(x),this}scroll(){return this.el.scroll()}set(x,e){const S=x-1;if(e>S){const _=this.vertical?"height":"width";this.el.css(_,`${S-15}px`).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(_,`${e}px`)}else this.el.hide();return this}}const Do=2*2-1;let pf=10;class Bo{constructor(x=!1){this.useHideInput=x,this.inputChange=()=>{},this.cornerEl=$e("div",`${lt}-selector-corner`),this.areaEl=$e("div",`${lt}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=$e("div",`${lt}-selector-clipboard`).hide(),this.autofillEl=$e("div",`${lt}-selector-autofill`).hide(),this.el=$e("div",`${lt}-selector`).css("z-index",`${pf}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),x&&(this.hideInput=$e("input","").on("compositionend",e=>{this.inputChange(e.target.value)}),this.el.child(this.hideInputDiv=$e("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=$e("div","hide-input").child(this.hideInput))),pf+=1}setOffset(x){return this.el.offset(x).show(),this}hide(){return this.el.hide(),this}setAreaOffset(x){const{left:e,top:S,width:_,height:u}=x,y={width:_-Do+.8,height:u-Do+.8,left:e-.8,top:S-.8};this.areaEl.offset(y).show(),this.useHideInput&&(this.hideInputDiv.offset(y),this.hideInput.val("").focus())}setClipboardOffset(x){const{left:e,top:S,width:_,height:u}=x;this.clipboardEl.offset({left:e,top:S,width:_-5,height:u-5})}showAutofill(x){const{left:e,top:S,width:_,height:u}=x;this.autofillEl.offset({width:_-Do,height:u-Do,left:e,top:S}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function Sf(H){const{data:x}=this,{left:e,top:S,width:_,height:u,scroll:y,l:g,t:b}=H,w=x.freezeTotalWidth(),f=x.freezeTotalHeight();let v=e-w;w>g&&(v-=y.x);let h=S-f;return f>b&&(h-=y.y),{left:v,top:h,width:_,height:u}}function kf(H){const{data:x}=this,{left:e,width:S,height:_,l:u,t:y,scroll:g}=H,b=x.freezeTotalWidth();let w=e-b;return b>u&&(w-=g.x),{left:w,top:y,width:S,height:_}}function xf(H){const{data:x}=this,{top:e,width:S,height:_,l:u,t:y,scroll:g}=H,b=x.freezeTotalHeight();let w=e-b;return b>y&&(w-=g.y),{left:u,top:w,width:S,height:_}}function vf(H){const{br:x}=this;x.setAreaOffset(Sf.call(this,H))}function Am(H){const{tl:x}=this;x.setAreaOffset(H)}function cc(H){const{t:x}=this;x.setAreaOffset(kf.call(this,H))}function hc(H){const{l:x}=this;x.setAreaOffset(xf.call(this,H))}function dc(H){const{l:x}=this;x.setClipboardOffset(xf.call(this,H))}function yf(H){const{br:x}=this;x.setClipboardOffset(Sf.call(this,H))}function Mm(H){const{tl:x}=this;x.setClipboardOffset(H)}function pc(H){const{t:x}=this;x.setClipboardOffset(kf.call(this,H))}function Dl(H){vf.call(this,H),Am.call(this,H),cc.call(this,H),hc.call(this,H)}function Bl(H){yf.call(this,H),Mm.call(this,H),pc.call(this,H),dc.call(this,H)}class Im{constructor(x){this.inputChange=()=>{},this.data=x,this.br=new Bo(!0),this.t=new Bo,this.l=new Bo,this.tl=new Bo,this.br.inputChange=e=>{this.inputChange(e)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=$e("div",`${lt}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,pf+=1}resetData(x){this.data=x,this.range=x.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:x,tl:e,t:S,l:_,br:u}=this,y=x.freezeTotalHeight(),g=x.freezeTotalWidth();y>0||g>0?(e.setOffset({width:g,height:y}),S.setOffset({left:g,height:y}),_.setOffset({top:y,width:g}),u.setOffset({left:g,top:y})):(e.hide(),S.hide(),_.hide(),u.setOffset({left:0,top:0}))}resetAreaOffset(){const x=this.data.getSelectedRect(),e=this.data.getClipboardRect();Dl.call(this,x),Bl.call(this,e),this.resetOffset()}resetBRTAreaOffset(){const x=this.data.getSelectedRect(),e=this.data.getClipboardRect();vf.call(this,x),cc.call(this,x),yf.call(this,e),pc.call(this,e),this.resetOffset()}resetBRLAreaOffset(){const x=this.data.getSelectedRect(),e=this.data.getClipboardRect();vf.call(this,x),hc.call(this,x),yf.call(this,e),dc.call(this,e),this.resetOffset()}set(x,e,S=!0){const{data:_}=this,u=_.calSelectedRangeByStart(x,e),{sri:y,sci:g}=u;if(S){let[b,w]=[x,e];x<0&&(b=0),e<0&&(w=0),_.selector.setIndexes(b,w),this.indexes=[b,w]}this.moveIndexes=[y,g],this.range=u,this.resetAreaOffset(),this.el.show()}setEnd(x,e,S=!0){const{data:_,lastri:u,lastci:y}=this;if(S){if(x===u&&e===y)return;this.lastri=x,this.lastci=e}this.range=_.calSelectedRangeByEnd(x,e),Dl.call(this,this.data.getSelectedRect())}reset(){const{eri:x,eci:e}=this.data.selector.range;this.setEnd(x,e)}showAutofill(x,e){if(x===-1&&e===-1)return;const{sri:S,sci:_,eri:u,eci:y}=this.range,[g,b]=[x,e],w=S-x,f=_-e,v=u-x,h=y-e;if(f>0)this.arange=new xr(S,b,u,_-1);else if(w>0)this.arange=new xr(g,_,S-1,y);else if(h<0)this.arange=new xr(S,y+1,u,b);else if(v<0)this.arange=new xr(u+1,_,g,y);else{this.arange=null;return}if(this.arange!==null){const l=this.data.getRect(this.arange);l.width+=2,l.height+=2;const{br:d,l:s,t:m,tl:c}=this;d.showAutofill(Sf.call(this,l)),s.showAutofill(xf.call(this,l)),m.showAutofill(kf.call(this,l)),c.showAutofill(l)}}hideAutofill(){["br","l","t","tl"].forEach(x=>{this[x].hideAutofill()})}showClipboard(){const x=this.data.getClipboardRect();Bl.call(this,x),["br","l","t","tl"].forEach(e=>{this[e].showClipboard()})}hideClipboard(){["br","l","t","tl"].forEach(x=>{this[x].hideClipboard()})}}function Nm(H){H.preventDefault(),H.stopPropagation();const{filterItems:x}=this;x.length<=0||(this.itemIndex>=0&&x[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=x.length-1),x[this.itemIndex].toggle())}function Dm(H){H.stopPropagation();const{filterItems:x}=this;x.length<=0||(this.itemIndex>=0&&x[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>x.length-1&&(this.itemIndex=0),x[this.itemIndex].toggle())}function Fl(H){H.preventDefault();const{filterItems:x}=this;x.length<=0||(H.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),x[this.itemIndex].el.click(),this.hide())}function Bm(H){const{keyCode:x}=H;switch(H.ctrlKey&&H.stopPropagation(),x){case 37:H.stopPropagation();break;case 38:Nm.call(this,H);break;case 39:H.stopPropagation();break;case 40:Dm.call(this,H);break;case 13:Fl.call(this,H);break;case 9:Fl.call(this,H);break;default:H.stopPropagation();break}}class vc{constructor(x,e,S="200px"){this.filterItems=[],this.items=x,this.el=$e("div",`${lt}-suggest`).css("width",S).hide(),this.itemClick=e,this.itemIndex=-1}setOffset(x){this.el.cssRemoveKeys("top","bottom").offset(x)}hide(){const{el:x}=this;this.filterItems=[],this.itemIndex=-1,x.hide(),_a(this.el.parent())}setItems(x){this.items=x}search(x){let{items:e}=this;if(/^\s*$/.test(x)||(e=e.filter(_=>(_.key||_).startsWith(x.toUpperCase()))),e=e.map(_=>{let{title:u}=_;u?typeof u=="function"&&(u=u()):u=_;const y=$e("div",`${lt}-item`).child(u).on("click.stop",()=>{this.itemClick(_),this.hide()});return _.label&&y.child($e("div","label").html(_.label)),y}),this.filterItems=e,e.length<=0)return;const{el:S}=this;S.html("").children(...e).show(),Va(S.parent(),()=>{this.hide()})}bindInputEvents(x){x.on("keydown",e=>Bm.call(this,e))}}class Kr extends Xi{constructor(x){super("div",`${lt}-icon`),this.iconNameEl=$e("div",`${lt}-icon-img ${x}`),this.child(this.iconNameEl)}setName(x){this.iconNameEl.className(`${lt}-icon-img ${x}`)}}function jl(H,x){H.setMonth(H.getMonth()+x)}function Fm(H,x){const e=new Date(H);return e.setDate(x-H.getDay()+1),e}function jm(H,x,e){const S=new Date(H,x,1,23,59,59),_=[[],[],[],[],[],[]];for(let u=0;u<6;u+=1)for(let y=0;y<7;y+=1){const g=u*7+y,b=Fm(S,g),w=b.getMonth()!==x,f=b.getMonth()===e.getMonth()&&b.getDate()===e.getDate();_[u][y]={d:b,disabled:w,active:f}}return _}class Lm{constructor(x){this.value=x,this.cvalue=new Date(x),this.headerLeftEl=$e("div","calendar-header-left"),this.bodyEl=$e("tbody",""),this.buildAll(),this.el=$e("div","x-spreadsheet-calendar").children($e("div","calendar-header").children(this.headerLeftEl,$e("div","calendar-header-right").children($e("a","calendar-prev").on("click.stop",()=>this.prev()).child(new Kr("chevron-left")),$e("a","calendar-next").on("click.stop",()=>this.next()).child(new Kr("chevron-right")))),$e("table","calendar-body").children($e("thead","").child($e("tr","").children(...Cr("calendar.weeks").map(e=>$e("th","cell").child(e)))),this.bodyEl)),this.selectChange=()=>{}}setValue(x){this.value=x,this.cvalue=new Date(x),this.buildAll()}prev(){const{value:x}=this;jl(x,-1),this.buildAll()}next(){const{value:x}=this;jl(x,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:x}=this;this.headerLeftEl.html(`${Cr("calendar.months")[x.getMonth()]} ${x.getFullYear()}`)}buildBody(){const{value:x,cvalue:e,bodyEl:S}=this,u=jm(x.getFullYear(),x.getMonth(),e).map(y=>{const g=y.map(b=>{let w="cell";return b.disabled&&(w+=" disabled"),b.active&&(w+=" active"),$e("td","").child($e("div",w).on("click.stop",()=>{this.selectChange(b.d)}).child(b.d.getDate().toString()))});return $e("tr","").children(...g)});S.html("").children(...u)}}class zm{constructor(){this.calendar=new Lm(new Date),this.el=$e("div",`${lt}-datepicker`).child(this.calendar.el).hide()}setValue(x){const{calendar:e}=this;return typeof x=="string"?/^\d{4}-\d{1,2}-\d{1,2}$/.test(x)&&e.setValue(new Date(x.replace(new RegExp("-","g"),"/"))):x instanceof Date&&e.setValue(x),this}change(x){this.calendar.selectChange=e=>{x(e),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function Yo(){const{inputText:H}=this;if(!/^\s*$/.test(H)){const{textlineEl:x,textEl:e,areaOffset:S}=this,_=H.split(` @@ -18,9 +18,9 @@ import{c as Wt,a as No,g as q0}from"./commonjs-dynamic-modules-2ceabb0b.23156833 * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */qo.exports;(function(H,x){(function(){var e,S="4.17.21",_=200,u="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",y="Expected a function",g="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",w=500,f="__lodash_placeholder__",v=1,h=2,l=4,d=1,s=2,m=1,c=2,a=4,r=8,t=16,i=32,n=64,o=128,p=256,O=512,P=30,B="...",z=800,D=16,M=1,I=2,T=3,C=1/0,E=9007199254740991,A=17976931348623157e292,L=0/0,$=4294967295,W=$-1,U=$>>>1,N=[["ary",o],["bind",m],["bindKey",c],["curry",r],["curryRight",t],["flip",O],["partial",i],["partialRight",n],["rearg",p]],j="[object Arguments]",F="[object Array]",V="[object AsyncFunction]",re="[object Boolean]",ee="[object Date]",ce="[object DOMException]",ye="[object Error]",ge="[object Function]",oe="[object GeneratorFunction]",J="[object Map]",Q="[object Number]",he="[object Null]",xe="[object Object]",ne="[object Promise]",se="[object Proxy]",Ce="[object RegExp]",q="[object Set]",G="[object String]",Y="[object Symbol]",fe="[object Undefined]",we="[object WeakMap]",_e="[object WeakSet]",je="[object ArrayBuffer]",Ye="[object DataView]",nt="[object Float32Array]",ut="[object Float64Array]",ot="[object Int8Array]",Ue="[object Int16Array]",Ve="[object Int32Array]",Qe="[object Uint8Array]",tt="[object Uint8ClampedArray]",ae="[object Uint16Array]",Re="[object Uint32Array]",be=/\b__p \+= '';/g,Ee=/\b(__p \+=) '' \+/g,pe=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Pe=/&(?:amp|lt|gt|quot|#39);/g,te=/[&<>"']/g,He=RegExp(Pe.source),it=RegExp(te.source),K=/<%-([\s\S]+?)%>/g,Me=/<%([\s\S]+?)%>/g,Le=/<%=([\s\S]+?)%>/g,ue=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ke=/^\w*$/,Ie=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,st=/[\\^$.*+?()[\]{}|]/g,Ge=RegExp(st.source),rt=/^\s+/,_t=/\s/,wt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ot=/\{\n\/\* \[wrapped with (.+)\] \*/,pt=/,? & /,ct=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,At=/[()=,{}\[\]\/\s]/,Pt=/\\(\\)?/g,bt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Kt=/\w*$/,Ct=/^[-+]0x[0-9a-f]+$/i,St=/^0b[01]+$/i,Bt=/^\[object .+?Constructor\]$/,Lt=/^0o[0-7]+$/i,Et=/^(?:0|[1-9]\d*)$/,Nr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Or=/($^)/,Gr=/['\n\r\u2028\u2029\\]/g,Dr="\\ud800-\\udfff",Yr="\\u0300-\\u036f",Qt="\\ufe20-\\ufe2f",Xr="\\u20d0-\\u20ff",Br=Yr+Qt+Xr,Lr="\\u2700-\\u27bf",Ur="a-z\\xdf-\\xf6\\xf8-\\xff",yt="\\xac\\xb1\\xd7\\xf7",Ke="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",me="\\u2000-\\u206f",Be=" \\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",Fe="A-Z\\xc0-\\xd6\\xd8-\\xde",dt="\\ufe0e\\ufe0f",kt=yt+Ke+me+Be,Ht="['’]",lr="["+Dr+"]",gr="["+kt+"]",rn="["+Br+"]",zr="\\d+",vi="["+Lr+"]",$r="["+Ur+"]",Dn="[^"+Dr+kt+zr+Lr+Ur+Fe+"]",cn="\\ud83c[\\udffb-\\udfff]",yi="(?:"+rn+"|"+cn+")",hn="[^"+Dr+"]",dn="(?:\\ud83c[\\udde6-\\uddff]){2}",Bn="[\\ud800-\\udbff][\\udc00-\\udfff]",Fn="["+Fe+"]",Ui="\\u200d",$i="(?:"+$r+"|"+Dn+")",Wi="(?:"+Fn+"|"+Dn+")",ti="(?:"+Ht+"(?:d|ll|m|re|s|t|ve))?",jn="(?:"+Ht+"(?:D|LL|M|RE|S|T|VE))?",Vi=yi+"?",Ki="["+dt+"]?",Sn="(?:"+Ui+"(?:"+[hn,dn,Bn].join("|")+")"+Ki+Vi+")*",wa="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Gi="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Yi=Ki+Vi+Sn,Sa="(?:"+[vi,dn,Bn].join("|")+")"+Yi,ka="(?:"+[hn+rn+"?",rn,dn,Bn,lr].join("|")+")",kn=RegExp(Ht,"g"),Zi=RegExp(rn,"g"),Ci=RegExp(cn+"(?="+cn+")|"+ka+Yi,"g"),Ln=RegExp([Fn+"?"+$r+"+"+ti+"(?="+[gr,Fn,"$"].join("|")+")",Wi+"+"+jn+"(?="+[gr,Fn+$i,"$"].join("|")+")",Fn+"?"+$i+"+"+ti,Fn+"+"+jn,Gi,wa,zr,Sa].join("|"),"g"),xa=RegExp("["+Ui+Dr+Br+dt+"]"),xn=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,On=["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"],Ji=-1,rr={};rr[nt]=rr[ut]=rr[ot]=rr[Ue]=rr[Ve]=rr[Qe]=rr[tt]=rr[ae]=rr[Re]=!0,rr[j]=rr[F]=rr[je]=rr[re]=rr[Ye]=rr[ee]=rr[ye]=rr[ge]=rr[J]=rr[Q]=rr[xe]=rr[Ce]=rr[q]=rr[G]=rr[we]=!1;var er={};er[j]=er[F]=er[je]=er[Ye]=er[re]=er[ee]=er[nt]=er[ut]=er[ot]=er[Ue]=er[Ve]=er[J]=er[Q]=er[xe]=er[Ce]=er[q]=er[G]=er[Y]=er[Qe]=er[tt]=er[ae]=er[Re]=!0,er[ye]=er[ge]=er[we]=!1;var ri={À:"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",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,Je=typeof self=="object"&&self&&self.Object===Object&&self,ht=Ne||Je||Function("return this")(),Yt=x&&!x.nodeType&&x,Mt=Yt&&!0&&H&&!H.nodeType&&H,fr=Mt&&Mt.exports===Yt,nr=fr&&Ne.process,tr=function(){try{var De=Mt&&Mt.require&&Mt.require("util").types;return De||nr&&nr.binding&&nr.binding("util")}catch{}}(),ur=tr&&tr.isArrayBuffer,Pr=tr&&tr.isDate,Fr=tr&&tr.isMap,dr=tr&&tr.isRegExp,Er=tr&&tr.isSet,Ar=tr&&tr.isTypedArray;function pr(De,Ze,We){switch(We.length){case 0:return De.call(Ze);case 1:return De.call(Ze,We[0]);case 2:return De.call(Ze,We[0],We[1]);case 3:return De.call(Ze,We[0],We[1],We[2])}return De.apply(Ze,We)}function pn(De,Ze,We,gt){for(var Ft=-1,ar=De==null?0:De.length;++Ft-1}function le(De,Ze,We){for(var gt=-1,Ft=De==null?0:De.length;++gt-1;);return We}function If(De,Ze){for(var We=De.length;We--&&wr(Ze,De[We],0)>-1;);return We}function Ac(De,Ze){for(var We=De.length,gt=0;We--;)De[We]===Ze&&++gt;return gt}var Mc=vn(ri),Ic=vn(Qi);function Nc(De){return"\\"+qi[De]}function Dc(De,Ze){return De==null?e:De[Ze]}function na(De){return xa.test(De)}function Bc(De){return xn.test(De)}function Fc(De){for(var Ze,We=[];!(Ze=De.next()).done;)We.push(Ze.value);return We}function as(De){var Ze=-1,We=Array(De.size);return De.forEach(function(gt,Ft){We[++Ze]=[Ft,gt]}),We}function Nf(De,Ze){return function(We){return De(Ze(We))}}function gi(De,Ze){for(var We=-1,gt=De.length,Ft=0,ar=[];++We-1}function xh(k,R){var X=this.__data__,Z=co(X,k);return Z<0?(++this.size,X.push([k,R])):X[Z][1]=R,this}ni.prototype.clear=_h,ni.prototype.delete=wh,ni.prototype.get=Sh,ni.prototype.has=kh,ni.prototype.set=xh;function ii(k){var R=-1,X=k==null?0:k.length;for(this.clear();++R=R?k:R)),k}function Pn(k,R,X,Z,ie,ve){var Te,Ae=R&v,ze=R&h,qe=R&l;if(X&&(Te=ie?X(k,Z,ie,ve):X(k)),Te!==e)return Te;if(!yr(k))return k;var et=jt(k);if(et){if(Te=Rd(k),!Ae)return nn(k,Te)}else{var at=Vr(k),vt=at==ge||at==oe;if(Oi(k))return yu(k,Ae);if(at==xe||at==j||vt&&!ie){if(Te=ze||vt?{}:Du(k),!Ae)return ze?md(k,zh(Te,k)):yd(k,Vf(Te,k))}else{if(!er[at])return ie?k:{};Te=Cd(k,at,Ae)}}ve||(ve=new Hn);var xt=ve.get(k);if(xt)return xt;ve.set(k,Te),ll(k)?k.forEach(function(Dt){Te.add(Pn(Dt,R,X,Dt,k,ve))}):fl(k)&&k.forEach(function(Dt,Gt){Te.set(Gt,Pn(Dt,R,X,Gt,k,ve))});var Nt=qe?ze?As:Ps:ze?on:jr,$t=et?e:Nt(k);return mr($t||k,function(Dt,Gt){$t&&(Gt=Dt,Dt=k[Gt]),Ma(Te,Gt,Pn(Dt,R,X,Gt,k,ve))}),Te}function Hh(k){var R=jr(k);return function(X){return Kf(X,k,R)}}function Kf(k,R,X){var Z=X.length;if(k==null)return!Z;for(k=cr(k);Z--;){var ie=X[Z],ve=R[ie],Te=k[ie];if(Te===e&&!(ie in k)||!ve(Te))return!1}return!0}function Gf(k,R,X){if(typeof k!="function")throw new Rn(y);return La(function(){k.apply(e,X)},R)}function Ia(k,R,X,Z){var ie=-1,ve=ra,Te=!0,Ae=k.length,ze=[],qe=R.length;if(!Ae)return ze;X&&(R=Oe(R,yn(X))),Z?(ve=le,Te=!1):R.length>=_&&(ve=Ea,Te=!1,R=new Mi(R));e:for(;++ieie?0:ie+X),Z=Z===e||Z>ie?ie:Ut(Z),Z<0&&(Z+=ie),Z=X>Z?0:hl(Z);X0&&X(Ae)?R>1?Hr(Ae,R-1,X,Z,ie):Xe(ie,Ae):Z||(ie[ie.length]=Ae)}return ie}var hs=Su(),Jf=Su(!0);function Gn(k,R){return k&&hs(k,R,jr)}function ds(k,R){return k&&Jf(k,R,jr)}function po(k,R){return Zr(R,function(X){return ui(k[X])})}function Ni(k,R){R=ki(R,k);for(var X=0,Z=R.length;k!=null&&XR}function $h(k,R){return k!=null&&sr.call(k,R)}function Wh(k,R){return k!=null&&R in cr(k)}function Vh(k,R,X){return k>=Wr(R,X)&&k=120&&et.length>=120)?new Mi(Te&&et):e}et=k[0];var at=-1,vt=Ae[0];e:for(;++at-1;)Ae!==k&&io.call(Ae,ze,1),io.call(k,ze,1);return k}function fu(k,R){for(var X=k?R.length:0,Z=X-1;X--;){var ie=R[X];if(X==Z||ie!==ve){var ve=ie;fi(ie)?io.call(k,ie,1):ks(k,ie)}}return k}function _s(k,R){return k+so(Xf()*(R-k+1))}function ad(k,R,X,Z){for(var ie=-1,ve=Ir(oo((R-k)/(X||1)),0),Te=We(ve);ve--;)Te[Z?ve:++ie]=k,k+=X;return Te}function ws(k,R){var X="";if(!k||R<1||R>E)return X;do R%2&&(X+=k),R=so(R/2),R&&(k+=k);while(R);return X}function Vt(k,R){return js(ju(k,R,sn),k+"")}function od(k){return Wf(pa(k))}function sd(k,R){var X=pa(k);return Oo(X,Ii(R,0,X.length))}function Ba(k,R,X,Z){if(!yr(k))return k;R=ki(R,k);for(var ie=-1,ve=R.length,Te=ve-1,Ae=k;Ae!=null&&++ieie?0:ie+R),X=X>ie?ie:X,X<0&&(X+=ie),ie=R>X?0:X-R>>>0,R>>>=0;for(var ve=We(ie);++Z>>1,Te=k[ve];Te!==null&&!bn(Te)&&(X?Te<=R:Te=_){var qe=R?null:wd(k);if(qe)return Za(qe);Te=!1,ie=Ea,ze=new Mi}else ze=R?[]:Ae;e:for(;++Z=Z?k:An(k,R,X)}var vu=Qc||function(k){return ht.clearTimeout(k)};function yu(k,R){if(R)return k.slice();var X=k.length,Z=Ff?Ff(X):new k.constructor(X);return k.copy(Z),Z}function Ts(k){var R=new k.constructor(k.byteLength);return new ro(R).set(new ro(k)),R}function hd(k,R){var X=R?Ts(k.buffer):k.buffer;return new k.constructor(X,k.byteOffset,k.byteLength)}function dd(k){var R=new k.constructor(k.source,Kt.exec(k));return R.lastIndex=k.lastIndex,R}function pd(k){return Aa?cr(Aa.call(k)):{}}function mu(k,R){var X=R?Ts(k.buffer):k.buffer;return new k.constructor(X,k.byteOffset,k.length)}function bu(k,R){if(k!==R){var X=k!==e,Z=k===null,ie=k===k,ve=bn(k),Te=R!==e,Ae=R===null,ze=R===R,qe=bn(R);if(!Ae&&!qe&&!ve&&k>R||ve&&Te&&ze&&!Ae&&!qe||Z&&Te&&ze||!X&&ze||!ie)return 1;if(!Z&&!ve&&!qe&&k=Ae)return ze;var qe=X[Z];return ze*(qe=="desc"?-1:1)}}return k.index-R.index}function gu(k,R,X,Z){for(var ie=-1,ve=k.length,Te=X.length,Ae=-1,ze=R.length,qe=Ir(ve-Te,0),et=We(ze+qe),at=!Z;++Ae1?X[ie-1]:e,Te=ie>2?X[2]:e;for(ve=k.length>3&&typeof ve=="function"?(ie--,ve):e,Te&&en(X[0],X[1],Te)&&(ve=ie<3?e:ve,ie=1),R=cr(R);++Z-1?ie[ve?R[Te]:Te]:e}}function Ou(k){return si(function(R){var X=R.length,Z=X,ie=Cn.prototype.thru;for(k&&R.reverse();Z--;){var ve=R[Z];if(typeof ve!="function")throw new Rn(y);if(ie&&!Te&&ko(ve)=="wrapper")var Te=new Cn([],!0)}for(Z=Te?Z:X;++Z1&&qt.reverse(),et&&zeAe))return!1;var qe=ve.get(k),et=ve.get(R);if(qe&&et)return qe==R&&et==k;var at=-1,vt=!0,xt=X&s?new Mi:e;for(ve.set(k,R),ve.set(R,k);++at1?"& ":"")+R[Z],R=R.join(X>2?", ":" "),k.replace(wt,`{ + */qo.exports;(function(H,x){(function(){var e,S="4.17.21",_=200,u="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",y="Expected a function",g="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",w=500,f="__lodash_placeholder__",v=1,h=2,l=4,d=1,s=2,m=1,c=2,a=4,r=8,t=16,i=32,n=64,o=128,p=256,E=512,P=30,D="...",z=800,B=16,M=1,I=2,T=3,C=1/0,O=9007199254740991,A=17976931348623157e292,L=0/0,U=4294967295,W=U-1,$=U>>>1,N=[["ary",o],["bind",m],["bindKey",c],["curry",r],["curryRight",t],["flip",E],["partial",i],["partialRight",n],["rearg",p]],F="[object Arguments]",j="[object Array]",V="[object AsyncFunction]",te="[object Boolean]",re="[object Date]",le="[object DOMException]",ye="[object Error]",ge="[object Function]",ne="[object GeneratorFunction]",J="[object Map]",Q="[object Number]",he="[object Null]",xe="[object Object]",ie="[object Promise]",se="[object Proxy]",Ce="[object RegExp]",q="[object Set]",G="[object String]",Y="[object Symbol]",fe="[object Undefined]",we="[object WeakMap]",_e="[object WeakSet]",je="[object ArrayBuffer]",Ye="[object DataView]",nt="[object Float32Array]",ut="[object Float64Array]",ot="[object Int8Array]",Ue="[object Int16Array]",Ve="[object Int32Array]",Qe="[object Uint8Array]",tt="[object Uint8ClampedArray]",oe="[object Uint16Array]",Re="[object Uint32Array]",be=/\b__p \+= '';/g,Ee=/\b(__p \+=) '' \+/g,pe=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Pe=/&(?:amp|lt|gt|quot|#39);/g,ee=/[&<>"']/g,He=RegExp(Pe.source),it=RegExp(ee.source),K=/<%-([\s\S]+?)%>/g,Me=/<%([\s\S]+?)%>/g,Le=/<%=([\s\S]+?)%>/g,ue=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ke=/^\w*$/,Ie=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,st=/[\\^$.*+?()[\]{}|]/g,Ge=RegExp(st.source),rt=/^\s+/,_t=/\s/,wt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ot=/\{\n\/\* \[wrapped with (.+)\] \*/,pt=/,? & /,ct=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,At=/[()=,{}\[\]\/\s]/,Pt=/\\(\\)?/g,bt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Kt=/\w*$/,Ct=/^[-+]0x[0-9a-f]+$/i,St=/^0b[01]+$/i,Bt=/^\[object .+?Constructor\]$/,Lt=/^0o[0-7]+$/i,Et=/^(?:0|[1-9]\d*)$/,Nr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Or=/($^)/,Gr=/['\n\r\u2028\u2029\\]/g,Dr="\\ud800-\\udfff",Yr="\\u0300-\\u036f",Qt="\\ufe20-\\ufe2f",Xr="\\u20d0-\\u20ff",Br=Yr+Qt+Xr,Lr="\\u2700-\\u27bf",Ur="a-z\\xdf-\\xf6\\xf8-\\xff",yt="\\xac\\xb1\\xd7\\xf7",Ke="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",me="\\u2000-\\u206f",Be=" \\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",Fe="A-Z\\xc0-\\xd6\\xd8-\\xde",dt="\\ufe0e\\ufe0f",kt=yt+Ke+me+Be,Ht="['’]",lr="["+Dr+"]",gr="["+kt+"]",rn="["+Br+"]",zr="\\d+",vi="["+Lr+"]",$r="["+Ur+"]",Dn="[^"+Dr+kt+zr+Lr+Ur+Fe+"]",cn="\\ud83c[\\udffb-\\udfff]",yi="(?:"+rn+"|"+cn+")",hn="[^"+Dr+"]",dn="(?:\\ud83c[\\udde6-\\uddff]){2}",Bn="[\\ud800-\\udbff][\\udc00-\\udfff]",Fn="["+Fe+"]",Ui="\\u200d",$i="(?:"+$r+"|"+Dn+")",Wi="(?:"+Fn+"|"+Dn+")",ti="(?:"+Ht+"(?:d|ll|m|re|s|t|ve))?",jn="(?:"+Ht+"(?:D|LL|M|RE|S|T|VE))?",Vi=yi+"?",Ki="["+dt+"]?",Sn="(?:"+Ui+"(?:"+[hn,dn,Bn].join("|")+")"+Ki+Vi+")*",wa="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Gi="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Yi=Ki+Vi+Sn,Sa="(?:"+[vi,dn,Bn].join("|")+")"+Yi,ka="(?:"+[hn+rn+"?",rn,dn,Bn,lr].join("|")+")",kn=RegExp(Ht,"g"),Zi=RegExp(rn,"g"),Ci=RegExp(cn+"(?="+cn+")|"+ka+Yi,"g"),Ln=RegExp([Fn+"?"+$r+"+"+ti+"(?="+[gr,Fn,"$"].join("|")+")",Wi+"+"+jn+"(?="+[gr,Fn+$i,"$"].join("|")+")",Fn+"?"+$i+"+"+ti,Fn+"+"+jn,Gi,wa,zr,Sa].join("|"),"g"),xa=RegExp("["+Ui+Dr+Br+dt+"]"),xn=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,On=["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"],Ji=-1,rr={};rr[nt]=rr[ut]=rr[ot]=rr[Ue]=rr[Ve]=rr[Qe]=rr[tt]=rr[oe]=rr[Re]=!0,rr[F]=rr[j]=rr[je]=rr[te]=rr[Ye]=rr[re]=rr[ye]=rr[ge]=rr[J]=rr[Q]=rr[xe]=rr[Ce]=rr[q]=rr[G]=rr[we]=!1;var er={};er[F]=er[j]=er[je]=er[Ye]=er[te]=er[re]=er[nt]=er[ut]=er[ot]=er[Ue]=er[Ve]=er[J]=er[Q]=er[xe]=er[Ce]=er[q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:"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"},Qi={"&":"&","<":"<",">":">",'"':""","'":"'"},Oa={"&":"&","<":"<",">":">",""":'"',"'":"'"},qi={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ea=parseFloat,Se=parseInt,Ne=typeof Wt=="object"&&Wt&&Wt.Object===Object&&Wt,Je=typeof self=="object"&&self&&self.Object===Object&&self,ht=Ne||Je||Function("return this")(),Yt=x&&!x.nodeType&&x,Mt=Yt&&!0&&H&&!H.nodeType&&H,fr=Mt&&Mt.exports===Yt,nr=fr&&Ne.process,tr=function(){try{var De=Mt&&Mt.require&&Mt.require("util").types;return De||nr&&nr.binding&&nr.binding("util")}catch{}}(),ur=tr&&tr.isArrayBuffer,Pr=tr&&tr.isDate,Fr=tr&&tr.isMap,dr=tr&&tr.isRegExp,Er=tr&&tr.isSet,Ar=tr&&tr.isTypedArray;function pr(De,Ze,We){switch(We.length){case 0:return De.call(Ze);case 1:return De.call(Ze,We[0]);case 2:return De.call(Ze,We[0],We[1]);case 3:return De.call(Ze,We[0],We[1],We[2])}return De.apply(Ze,We)}function pn(De,Ze,We,gt){for(var Ft=-1,ar=De==null?0:De.length;++Ft-1}function ce(De,Ze,We){for(var gt=-1,Ft=De==null?0:De.length;++gt-1;);return We}function If(De,Ze){for(var We=De.length;We--&&wr(Ze,De[We],0)>-1;);return We}function Ac(De,Ze){for(var We=De.length,gt=0;We--;)De[We]===Ze&&++gt;return gt}var Mc=vn(ri),Ic=vn(Qi);function Nc(De){return"\\"+qi[De]}function Dc(De,Ze){return De==null?e:De[Ze]}function na(De){return xa.test(De)}function Bc(De){return xn.test(De)}function Fc(De){for(var Ze,We=[];!(Ze=De.next()).done;)We.push(Ze.value);return We}function as(De){var Ze=-1,We=Array(De.size);return De.forEach(function(gt,Ft){We[++Ze]=[Ft,gt]}),We}function Nf(De,Ze){return function(We){return De(Ze(We))}}function gi(De,Ze){for(var We=-1,gt=De.length,Ft=0,ar=[];++We-1}function xh(k,R){var X=this.__data__,Z=co(X,k);return Z<0?(++this.size,X.push([k,R])):X[Z][1]=R,this}ni.prototype.clear=_h,ni.prototype.delete=wh,ni.prototype.get=Sh,ni.prototype.has=kh,ni.prototype.set=xh;function ii(k){var R=-1,X=k==null?0:k.length;for(this.clear();++R=R?k:R)),k}function Pn(k,R,X,Z,ae,ve){var Te,Ae=R&v,ze=R&h,qe=R&l;if(X&&(Te=ae?X(k,Z,ae,ve):X(k)),Te!==e)return Te;if(!yr(k))return k;var et=jt(k);if(et){if(Te=Rd(k),!Ae)return nn(k,Te)}else{var at=Vr(k),vt=at==ge||at==ne;if(Oi(k))return yu(k,Ae);if(at==xe||at==F||vt&&!ae){if(Te=ze||vt?{}:Du(k),!Ae)return ze?md(k,zh(Te,k)):yd(k,Vf(Te,k))}else{if(!er[at])return ae?k:{};Te=Cd(k,at,Ae)}}ve||(ve=new Hn);var xt=ve.get(k);if(xt)return xt;ve.set(k,Te),ll(k)?k.forEach(function(Dt){Te.add(Pn(Dt,R,X,Dt,k,ve))}):fl(k)&&k.forEach(function(Dt,Gt){Te.set(Gt,Pn(Dt,R,X,Gt,k,ve))});var Nt=qe?ze?As:Ps:ze?on:jr,$t=et?e:Nt(k);return mr($t||k,function(Dt,Gt){$t&&(Gt=Dt,Dt=k[Gt]),Ma(Te,Gt,Pn(Dt,R,X,Gt,k,ve))}),Te}function Hh(k){var R=jr(k);return function(X){return Kf(X,k,R)}}function Kf(k,R,X){var Z=X.length;if(k==null)return!Z;for(k=cr(k);Z--;){var ae=X[Z],ve=R[ae],Te=k[ae];if(Te===e&&!(ae in k)||!ve(Te))return!1}return!0}function Gf(k,R,X){if(typeof k!="function")throw new Rn(y);return La(function(){k.apply(e,X)},R)}function Ia(k,R,X,Z){var ae=-1,ve=ra,Te=!0,Ae=k.length,ze=[],qe=R.length;if(!Ae)return ze;X&&(R=Oe(R,yn(X))),Z?(ve=ce,Te=!1):R.length>=_&&(ve=Ea,Te=!1,R=new Mi(R));e:for(;++aeae?0:ae+X),Z=Z===e||Z>ae?ae:Ut(Z),Z<0&&(Z+=ae),Z=X>Z?0:hl(Z);X0&&X(Ae)?R>1?Hr(Ae,R-1,X,Z,ae):Xe(ae,Ae):Z||(ae[ae.length]=Ae)}return ae}var hs=Su(),Jf=Su(!0);function Gn(k,R){return k&&hs(k,R,jr)}function ds(k,R){return k&&Jf(k,R,jr)}function po(k,R){return Zr(R,function(X){return ui(k[X])})}function Ni(k,R){R=ki(R,k);for(var X=0,Z=R.length;k!=null&&XR}function $h(k,R){return k!=null&&sr.call(k,R)}function Wh(k,R){return k!=null&&R in cr(k)}function Vh(k,R,X){return k>=Wr(R,X)&&k=120&&et.length>=120)?new Mi(Te&&et):e}et=k[0];var at=-1,vt=Ae[0];e:for(;++at-1;)Ae!==k&&io.call(Ae,ze,1),io.call(k,ze,1);return k}function fu(k,R){for(var X=k?R.length:0,Z=X-1;X--;){var ae=R[X];if(X==Z||ae!==ve){var ve=ae;fi(ae)?io.call(k,ae,1):ks(k,ae)}}return k}function _s(k,R){return k+so(Xf()*(R-k+1))}function ad(k,R,X,Z){for(var ae=-1,ve=Ir(oo((R-k)/(X||1)),0),Te=We(ve);ve--;)Te[Z?ve:++ae]=k,k+=X;return Te}function ws(k,R){var X="";if(!k||R<1||R>O)return X;do R%2&&(X+=k),R=so(R/2),R&&(k+=k);while(R);return X}function Vt(k,R){return js(ju(k,R,sn),k+"")}function od(k){return Wf(pa(k))}function sd(k,R){var X=pa(k);return Oo(X,Ii(R,0,X.length))}function Ba(k,R,X,Z){if(!yr(k))return k;R=ki(R,k);for(var ae=-1,ve=R.length,Te=ve-1,Ae=k;Ae!=null&&++aeae?0:ae+R),X=X>ae?ae:X,X<0&&(X+=ae),ae=R>X?0:X-R>>>0,R>>>=0;for(var ve=We(ae);++Z>>1,Te=k[ve];Te!==null&&!bn(Te)&&(X?Te<=R:Te=_){var qe=R?null:wd(k);if(qe)return Za(qe);Te=!1,ae=Ea,ze=new Mi}else ze=R?[]:Ae;e:for(;++Z=Z?k:An(k,R,X)}var vu=Qc||function(k){return ht.clearTimeout(k)};function yu(k,R){if(R)return k.slice();var X=k.length,Z=Ff?Ff(X):new k.constructor(X);return k.copy(Z),Z}function Ts(k){var R=new k.constructor(k.byteLength);return new ro(R).set(new ro(k)),R}function hd(k,R){var X=R?Ts(k.buffer):k.buffer;return new k.constructor(X,k.byteOffset,k.byteLength)}function dd(k){var R=new k.constructor(k.source,Kt.exec(k));return R.lastIndex=k.lastIndex,R}function pd(k){return Aa?cr(Aa.call(k)):{}}function mu(k,R){var X=R?Ts(k.buffer):k.buffer;return new k.constructor(X,k.byteOffset,k.length)}function bu(k,R){if(k!==R){var X=k!==e,Z=k===null,ae=k===k,ve=bn(k),Te=R!==e,Ae=R===null,ze=R===R,qe=bn(R);if(!Ae&&!qe&&!ve&&k>R||ve&&Te&&ze&&!Ae&&!qe||Z&&Te&&ze||!X&&ze||!ae)return 1;if(!Z&&!ve&&!qe&&k=Ae)return ze;var qe=X[Z];return ze*(qe=="desc"?-1:1)}}return k.index-R.index}function gu(k,R,X,Z){for(var ae=-1,ve=k.length,Te=X.length,Ae=-1,ze=R.length,qe=Ir(ve-Te,0),et=We(ze+qe),at=!Z;++Ae1?X[ae-1]:e,Te=ae>2?X[2]:e;for(ve=k.length>3&&typeof ve=="function"?(ae--,ve):e,Te&&en(X[0],X[1],Te)&&(ve=ae<3?e:ve,ae=1),R=cr(R);++Z-1?ae[ve?R[Te]:Te]:e}}function Ou(k){return si(function(R){var X=R.length,Z=X,ae=Cn.prototype.thru;for(k&&R.reverse();Z--;){var ve=R[Z];if(typeof ve!="function")throw new Rn(y);if(ae&&!Te&&ko(ve)=="wrapper")var Te=new Cn([],!0)}for(Z=Te?Z:X;++Z1&&qt.reverse(),et&&zeAe))return!1;var qe=ve.get(k),et=ve.get(R);if(qe&&et)return qe==R&&et==k;var at=-1,vt=!0,xt=X&s?new Mi:e;for(ve.set(k,R),ve.set(R,k);++at1?"& ":"")+R[Z],R=R.join(X>2?", ":" "),k.replace(wt,`{ /* [wrapped with `+R+`] */ -`)}function Ad(k){return jt(k)||Fi(k)||!!(zf&&k&&k[zf])}function fi(k,R){var X=typeof k;return R=R??E,!!R&&(X=="number"||X!="symbol"&&Et.test(k))&&k>-1&&k%1==0&&k0){if(++R>=z)return arguments[0]}else R=0;return k.apply(e,arguments)}}function Oo(k,R){var X=-1,Z=k.length,ie=Z-1;for(R=R===e?Z:R;++X1?k[R-1]:e;return X=typeof X=="function"?(k.pop(),X):e,Zu(k,X)});function Ju(k){var R=de(k);return R.__chain__=!0,R}function Xp(k,R){return R(k),k}function Eo(k,R){return R(k)}var Up=si(function(k){var R=k.length,X=R?k[0]:0,Z=this.__wrapped__,ie=function(ve){return cs(ve,k)};return R>1||this.__actions__.length||!(Z instanceof Zt)||!fi(X)?this.thru(ie):(Z=Z.slice(X,+X+(R?1:0)),Z.__actions__.push({func:Eo,args:[ie],thisArg:e}),new Cn(Z,this.__chain__).thru(function(ve){return R&&!ve.length&&ve.push(e),ve}))});function $p(){return Ju(this)}function Wp(){return new Cn(this.value(),this.__chain__)}function Vp(){this.__values__===e&&(this.__values__=cl(this.value()));var k=this.__index__>=this.__values__.length,R=k?e:this.__values__[this.__index__++];return{done:k,value:R}}function Kp(){return this}function Gp(k){for(var R,X=this;X instanceof lo;){var Z=$u(X);Z.__index__=0,Z.__values__=e,R?ie.__wrapped__=Z:R=Z;var ie=Z;X=X.__wrapped__}return ie.__wrapped__=k,R}function Yp(){var k=this.__wrapped__;if(k instanceof Zt){var R=k;return this.__actions__.length&&(R=new Zt(this)),R=R.reverse(),R.__actions__.push({func:Eo,args:[Ls],thisArg:e}),new Cn(R,this.__chain__)}return this.thru(Ls)}function Zp(){return du(this.__wrapped__,this.__actions__)}var Jp=bo(function(k,R,X){sr.call(k,X)?++k[X]:ai(k,X,1)});function Qp(k,R,X){var Z=jt(k)?En:Xh;return X&&en(k,R,X)&&(R=e),Z(k,It(R,3))}function qp(k,R){var X=jt(k)?Zr:Zf;return X(k,It(R,3))}var ev=xu(Wu),tv=xu(Vu);function rv(k,R){return Hr(To(k,R),1)}function nv(k,R){return Hr(To(k,R),C)}function iv(k,R,X){return X=X===e?1:Ut(X),Hr(To(k,R),X)}function Qu(k,R){var X=jt(k)?mr:wi;return X(k,It(R,3))}function qu(k,R){var X=jt(k)?ta:Yf;return X(k,It(R,3))}var av=bo(function(k,R,X){sr.call(k,X)?k[X].push(R):ai(k,X,[R])});function ov(k,R,X,Z){k=an(k)?k:pa(k),X=X&&!Z?Ut(X):0;var ie=k.length;return X<0&&(X=Ir(ie+X,0)),Mo(k)?X<=ie&&k.indexOf(R,X)>-1:!!ie&&wr(k,R,X)>-1}var sv=Vt(function(k,R,X){var Z=-1,ie=typeof R=="function",ve=an(k)?We(k.length):[];return wi(k,function(Te){ve[++Z]=ie?pr(R,Te,X):Na(Te,R,X)}),ve}),fv=bo(function(k,R,X){ai(k,X,R)});function To(k,R){var X=jt(k)?Oe:ru;return X(k,It(R,3))}function uv(k,R,X,Z){return k==null?[]:(jt(R)||(R=R==null?[]:[R]),X=Z?e:X,jt(X)||(X=X==null?[]:[X]),ou(k,R,X))}var lv=bo(function(k,R,X){k[X?0:1].push(R)},function(){return[[],[]]});function cv(k,R,X){var Z=jt(k)?ft:Kn,ie=arguments.length<3;return Z(k,It(R,4),X,ie,wi)}function hv(k,R,X){var Z=jt(k)?Tt:Kn,ie=arguments.length<3;return Z(k,It(R,4),X,ie,Yf)}function dv(k,R){var X=jt(k)?Zr:Zf;return X(k,Po(It(R,3)))}function pv(k){var R=jt(k)?Wf:od;return R(k)}function vv(k,R,X){(X?en(k,R,X):R===e)?R=1:R=Ut(R);var Z=jt(k)?Fh:sd;return Z(k,R)}function yv(k){var R=jt(k)?jh:ud;return R(k)}function mv(k){if(k==null)return 0;if(an(k))return Mo(k)?ia(k):k.length;var R=Vr(k);return R==J||R==q?k.size:ms(k).length}function bv(k,R,X){var Z=jt(k)?mt:ld;return X&&en(k,R,X)&&(R=e),Z(k,It(R,3))}var gv=Vt(function(k,R){if(k==null)return[];var X=R.length;return X>1&&en(k,R[0],R[1])?R=[]:X>2&&en(R[0],R[1],R[2])&&(R=[R[0]]),ou(k,Hr(R,1),[])}),Ro=qc||function(){return ht.Date.now()};function _v(k,R){if(typeof R!="function")throw new Rn(y);return k=Ut(k),function(){if(--k<1)return R.apply(this,arguments)}}function el(k,R,X){return R=X?e:R,R=k&&R==null?k.length:R,oi(k,o,e,e,e,e,R)}function tl(k,R){var X;if(typeof R!="function")throw new Rn(y);return k=Ut(k),function(){return--k>0&&(X=R.apply(this,arguments)),k<=1&&(R=e),X}}var Hs=Vt(function(k,R,X){var Z=m;if(X.length){var ie=gi(X,ha(Hs));Z|=i}return oi(k,Z,R,X,ie)}),rl=Vt(function(k,R,X){var Z=m|c;if(X.length){var ie=gi(X,ha(rl));Z|=i}return oi(R,Z,k,X,ie)});function nl(k,R,X){R=X?e:R;var Z=oi(k,r,e,e,e,e,e,R);return Z.placeholder=nl.placeholder,Z}function il(k,R,X){R=X?e:R;var Z=oi(k,t,e,e,e,e,e,R);return Z.placeholder=il.placeholder,Z}function al(k,R,X){var Z,ie,ve,Te,Ae,ze,qe=0,et=!1,at=!1,vt=!0;if(typeof k!="function")throw new Rn(y);R=In(R)||0,yr(X)&&(et=!!X.leading,at="maxWait"in X,ve=at?Ir(In(X.maxWait)||0,R):ve,vt="trailing"in X?!!X.trailing:vt);function xt(kr){var Un=Z,ci=ie;return Z=ie=e,qe=kr,Te=k.apply(ci,Un),Te}function Nt(kr){return qe=kr,Ae=La(Gt,R),et?xt(kr):Te}function $t(kr){var Un=kr-ze,ci=kr-qe,xl=R-Un;return at?Wr(xl,ve-ci):xl}function Dt(kr){var Un=kr-ze,ci=kr-qe;return ze===e||Un>=R||Un<0||at&&ci>=ve}function Gt(){var kr=Ro();if(Dt(kr))return qt(kr);Ae=La(Gt,$t(kr))}function qt(kr){return Ae=e,vt&&Z?xt(kr):(Z=ie=e,Te)}function gn(){Ae!==e&&vu(Ae),qe=0,Z=ze=ie=Ae=e}function tn(){return Ae===e?Te:qt(Ro())}function _n(){var kr=Ro(),Un=Dt(kr);if(Z=arguments,ie=this,ze=kr,Un){if(Ae===e)return Nt(ze);if(at)return vu(Ae),Ae=La(Gt,R),xt(ze)}return Ae===e&&(Ae=La(Gt,R)),Te}return _n.cancel=gn,_n.flush=tn,_n}var wv=Vt(function(k,R){return Gf(k,1,R)}),Sv=Vt(function(k,R,X){return Gf(k,In(R)||0,X)});function kv(k){return oi(k,O)}function Co(k,R){if(typeof k!="function"||R!=null&&typeof R!="function")throw new Rn(y);var X=function(){var Z=arguments,ie=R?R.apply(this,Z):Z[0],ve=X.cache;if(ve.has(ie))return ve.get(ie);var Te=k.apply(this,Z);return X.cache=ve.set(ie,Te)||ve,Te};return X.cache=new(Co.Cache||ii),X}Co.Cache=ii;function Po(k){if(typeof k!="function")throw new Rn(y);return function(){var R=arguments;switch(R.length){case 0:return!k.call(this);case 1:return!k.call(this,R[0]);case 2:return!k.call(this,R[0],R[1]);case 3:return!k.call(this,R[0],R[1],R[2])}return!k.apply(this,R)}}function xv(k){return tl(2,k)}var Ov=cd(function(k,R){R=R.length==1&&jt(R[0])?Oe(R[0],yn(It())):Oe(Hr(R,1),yn(It()));var X=R.length;return Vt(function(Z){for(var ie=-1,ve=Wr(Z.length,X);++ie=R}),Fi=qf(function(){return arguments}())?qf:function(k){return br(k)&&sr.call(k,"callee")&&!Lf.call(k,"callee")},jt=We.isArray,zv=ur?yn(ur):Gh;function an(k){return k!=null&&Ao(k.length)&&!ui(k)}function Sr(k){return br(k)&&an(k)}function Hv(k){return k===!0||k===!1||br(k)&&qr(k)==re}var Oi=th||qs,Xv=Pr?yn(Pr):Yh;function Uv(k){return br(k)&&k.nodeType===1&&!za(k)}function $v(k){if(k==null)return!0;if(an(k)&&(jt(k)||typeof k=="string"||typeof k.splice=="function"||Oi(k)||da(k)||Fi(k)))return!k.length;var R=Vr(k);if(R==J||R==q)return!k.size;if(ja(k))return!ms(k).length;for(var X in k)if(sr.call(k,X))return!1;return!0}function Wv(k,R){return Da(k,R)}function Vv(k,R,X){X=typeof X=="function"?X:e;var Z=X?X(k,R):e;return Z===e?Da(k,R,e,X):!!Z}function Us(k){if(!br(k))return!1;var R=qr(k);return R==ye||R==ce||typeof k.message=="string"&&typeof k.name=="string"&&!za(k)}function Kv(k){return typeof k=="number"&&Hf(k)}function ui(k){if(!yr(k))return!1;var R=qr(k);return R==ge||R==oe||R==V||R==se}function sl(k){return typeof k=="number"&&k==Ut(k)}function Ao(k){return typeof k=="number"&&k>-1&&k%1==0&&k<=E}function yr(k){var R=typeof k;return k!=null&&(R=="object"||R=="function")}function br(k){return k!=null&&typeof k=="object"}var fl=Fr?yn(Fr):Jh;function Gv(k,R){return k===R||ys(k,R,Is(R))}function Yv(k,R,X){return X=typeof X=="function"?X:e,ys(k,R,Is(R),X)}function Zv(k){return ul(k)&&k!=+k}function Jv(k){if(Nd(k))throw new Ft(u);return eu(k)}function Qv(k){return k===null}function qv(k){return k==null}function ul(k){return typeof k=="number"||br(k)&&qr(k)==Q}function za(k){if(!br(k)||qr(k)!=xe)return!1;var R=no(k);if(R===null)return!0;var X=sr.call(R,"constructor")&&R.constructor;return typeof X=="function"&&X instanceof X&&qa.call(X)==Yc}var $s=dr?yn(dr):Qh;function ey(k){return sl(k)&&k>=-E&&k<=E}var ll=Er?yn(Er):qh;function Mo(k){return typeof k=="string"||!jt(k)&&br(k)&&qr(k)==G}function bn(k){return typeof k=="symbol"||br(k)&&qr(k)==Y}var da=Ar?yn(Ar):ed;function ty(k){return k===e}function ry(k){return br(k)&&Vr(k)==we}function ny(k){return br(k)&&qr(k)==_e}var iy=So(bs),ay=So(function(k,R){return k<=R});function cl(k){if(!k)return[];if(an(k))return Mo(k)?zn(k):nn(k);if(Ta&&k[Ta])return Fc(k[Ta]());var R=Vr(k),X=R==J?as:R==q?Za:pa;return X(k)}function li(k){if(!k)return k===0?k:0;if(k=In(k),k===C||k===-C){var R=k<0?-1:1;return R*A}return k===k?k:0}function Ut(k){var R=li(k),X=R%1;return R===R?X?R-X:R:0}function hl(k){return k?Ii(Ut(k),0,$):0}function In(k){if(typeof k=="number")return k;if(bn(k))return L;if(yr(k)){var R=typeof k.valueOf=="function"?k.valueOf():k;k=yr(R)?R+"":R}if(typeof k!="string")return k===0?k:+k;k=Af(k);var X=St.test(k);return X||Lt.test(k)?Se(k.slice(2),X?2:8):Ct.test(k)?L:+k}function dl(k){return Yn(k,on(k))}function oy(k){return k?Ii(Ut(k),-E,E):k===0?k:0}function or(k){return k==null?"":mn(k)}var sy=la(function(k,R){if(ja(R)||an(R)){Yn(R,jr(R),k);return}for(var X in R)sr.call(R,X)&&Ma(k,X,R[X])}),pl=la(function(k,R){Yn(R,on(R),k)}),Io=la(function(k,R,X,Z){Yn(R,on(R),k,Z)}),fy=la(function(k,R,X,Z){Yn(R,jr(R),k,Z)}),uy=si(cs);function ly(k,R){var X=ua(k);return R==null?X:Vf(X,R)}var cy=Vt(function(k,R){k=cr(k);var X=-1,Z=R.length,ie=Z>2?R[2]:e;for(ie&&en(R[0],R[1],ie)&&(Z=1);++X1),ve}),Yn(k,As(k),X),Z&&(X=Pn(X,v|h|l,Sd));for(var ie=R.length;ie--;)ks(X,R[ie]);return X});function Cy(k,R){return yl(k,Po(It(R)))}var Py=si(function(k,R){return k==null?{}:nd(k,R)});function yl(k,R){if(k==null)return{};var X=Oe(As(k),function(Z){return[Z]});return R=It(R),su(k,X,function(Z,ie){return R(Z,ie[0])})}function Ay(k,R,X){R=ki(R,k);var Z=-1,ie=R.length;for(ie||(ie=1,k=e);++ZR){var Z=k;k=R,R=Z}if(X||k%1||R%1){var ie=Xf();return Wr(k+ie*(R-k+ea("1e-"+((ie+"").length-1))),R)}return _s(k,R)}var Xy=ca(function(k,R,X){return R=R.toLowerCase(),k+(X?gl(R):R)});function gl(k){return Ks(or(k).toLowerCase())}function _l(k){return k=or(k),k&&k.replace(Nr,Mc).replace(Zi,"")}function Uy(k,R,X){k=or(k),R=mn(R);var Z=k.length;X=X===e?Z:Ii(Ut(X),0,Z);var ie=X;return X-=R.length,X>=0&&k.slice(X,ie)==R}function $y(k){return k=or(k),k&&it.test(k)?k.replace(te,Ic):k}function Wy(k){return k=or(k),k&&Ge.test(k)?k.replace(st,"\\$&"):k}var Vy=ca(function(k,R,X){return k+(X?"-":"")+R.toLowerCase()}),Ky=ca(function(k,R,X){return k+(X?" ":"")+R.toLowerCase()}),Gy=ku("toLowerCase");function Yy(k,R,X){k=or(k),R=Ut(R);var Z=R?ia(k):0;if(!R||Z>=R)return k;var ie=(R-Z)/2;return wo(so(ie),X)+k+wo(oo(ie),X)}function Zy(k,R,X){k=or(k),R=Ut(R);var Z=R?ia(k):0;return R&&Z>>0,X?(k=or(k),k&&(typeof R=="string"||R!=null&&!$s(R))&&(R=mn(R),!R&&na(k))?xi(zn(k),0,X):k.split(R,X)):[]}var n0=ca(function(k,R,X){return k+(X?" ":"")+Ks(R)});function i0(k,R,X){return k=or(k),X=X==null?0:Ii(Ut(X),0,k.length),R=mn(R),k.slice(X,X+R.length)==R}function a0(k,R,X){var Z=de.templateSettings;X&&en(k,R,X)&&(R=e),k=or(k),R=Io({},R,Z,Pu);var ie=Io({},R.imports,Z.imports,Pu),ve=jr(ie),Te=is(ie,ve),Ae,ze,qe=0,et=R.interpolate||Or,at="__p += '",vt=os((R.escape||Or).source+"|"+et.source+"|"+(et===Le?bt:Or).source+"|"+(R.evaluate||Or).source+"|$","g"),xt="//# sourceURL="+(sr.call(R,"sourceURL")?(R.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ji+"]")+` +`)}function Ad(k){return jt(k)||Fi(k)||!!(zf&&k&&k[zf])}function fi(k,R){var X=typeof k;return R=R??O,!!R&&(X=="number"||X!="symbol"&&Et.test(k))&&k>-1&&k%1==0&&k0){if(++R>=z)return arguments[0]}else R=0;return k.apply(e,arguments)}}function Oo(k,R){var X=-1,Z=k.length,ae=Z-1;for(R=R===e?Z:R;++X1?k[R-1]:e;return X=typeof X=="function"?(k.pop(),X):e,Zu(k,X)});function Ju(k){var R=de(k);return R.__chain__=!0,R}function Xp(k,R){return R(k),k}function Eo(k,R){return R(k)}var Up=si(function(k){var R=k.length,X=R?k[0]:0,Z=this.__wrapped__,ae=function(ve){return cs(ve,k)};return R>1||this.__actions__.length||!(Z instanceof Zt)||!fi(X)?this.thru(ae):(Z=Z.slice(X,+X+(R?1:0)),Z.__actions__.push({func:Eo,args:[ae],thisArg:e}),new Cn(Z,this.__chain__).thru(function(ve){return R&&!ve.length&&ve.push(e),ve}))});function $p(){return Ju(this)}function Wp(){return new Cn(this.value(),this.__chain__)}function Vp(){this.__values__===e&&(this.__values__=cl(this.value()));var k=this.__index__>=this.__values__.length,R=k?e:this.__values__[this.__index__++];return{done:k,value:R}}function Kp(){return this}function Gp(k){for(var R,X=this;X instanceof lo;){var Z=$u(X);Z.__index__=0,Z.__values__=e,R?ae.__wrapped__=Z:R=Z;var ae=Z;X=X.__wrapped__}return ae.__wrapped__=k,R}function Yp(){var k=this.__wrapped__;if(k instanceof Zt){var R=k;return this.__actions__.length&&(R=new Zt(this)),R=R.reverse(),R.__actions__.push({func:Eo,args:[Ls],thisArg:e}),new Cn(R,this.__chain__)}return this.thru(Ls)}function Zp(){return du(this.__wrapped__,this.__actions__)}var Jp=bo(function(k,R,X){sr.call(k,X)?++k[X]:ai(k,X,1)});function Qp(k,R,X){var Z=jt(k)?En:Xh;return X&&en(k,R,X)&&(R=e),Z(k,It(R,3))}function qp(k,R){var X=jt(k)?Zr:Zf;return X(k,It(R,3))}var ev=xu(Wu),tv=xu(Vu);function rv(k,R){return Hr(To(k,R),1)}function nv(k,R){return Hr(To(k,R),C)}function iv(k,R,X){return X=X===e?1:Ut(X),Hr(To(k,R),X)}function Qu(k,R){var X=jt(k)?mr:wi;return X(k,It(R,3))}function qu(k,R){var X=jt(k)?ta:Yf;return X(k,It(R,3))}var av=bo(function(k,R,X){sr.call(k,X)?k[X].push(R):ai(k,X,[R])});function ov(k,R,X,Z){k=an(k)?k:pa(k),X=X&&!Z?Ut(X):0;var ae=k.length;return X<0&&(X=Ir(ae+X,0)),Mo(k)?X<=ae&&k.indexOf(R,X)>-1:!!ae&&wr(k,R,X)>-1}var sv=Vt(function(k,R,X){var Z=-1,ae=typeof R=="function",ve=an(k)?We(k.length):[];return wi(k,function(Te){ve[++Z]=ae?pr(R,Te,X):Na(Te,R,X)}),ve}),fv=bo(function(k,R,X){ai(k,X,R)});function To(k,R){var X=jt(k)?Oe:ru;return X(k,It(R,3))}function uv(k,R,X,Z){return k==null?[]:(jt(R)||(R=R==null?[]:[R]),X=Z?e:X,jt(X)||(X=X==null?[]:[X]),ou(k,R,X))}var lv=bo(function(k,R,X){k[X?0:1].push(R)},function(){return[[],[]]});function cv(k,R,X){var Z=jt(k)?ft:Kn,ae=arguments.length<3;return Z(k,It(R,4),X,ae,wi)}function hv(k,R,X){var Z=jt(k)?Tt:Kn,ae=arguments.length<3;return Z(k,It(R,4),X,ae,Yf)}function dv(k,R){var X=jt(k)?Zr:Zf;return X(k,Po(It(R,3)))}function pv(k){var R=jt(k)?Wf:od;return R(k)}function vv(k,R,X){(X?en(k,R,X):R===e)?R=1:R=Ut(R);var Z=jt(k)?Fh:sd;return Z(k,R)}function yv(k){var R=jt(k)?jh:ud;return R(k)}function mv(k){if(k==null)return 0;if(an(k))return Mo(k)?ia(k):k.length;var R=Vr(k);return R==J||R==q?k.size:ms(k).length}function bv(k,R,X){var Z=jt(k)?mt:ld;return X&&en(k,R,X)&&(R=e),Z(k,It(R,3))}var gv=Vt(function(k,R){if(k==null)return[];var X=R.length;return X>1&&en(k,R[0],R[1])?R=[]:X>2&&en(R[0],R[1],R[2])&&(R=[R[0]]),ou(k,Hr(R,1),[])}),Ro=qc||function(){return ht.Date.now()};function _v(k,R){if(typeof R!="function")throw new Rn(y);return k=Ut(k),function(){if(--k<1)return R.apply(this,arguments)}}function el(k,R,X){return R=X?e:R,R=k&&R==null?k.length:R,oi(k,o,e,e,e,e,R)}function tl(k,R){var X;if(typeof R!="function")throw new Rn(y);return k=Ut(k),function(){return--k>0&&(X=R.apply(this,arguments)),k<=1&&(R=e),X}}var Hs=Vt(function(k,R,X){var Z=m;if(X.length){var ae=gi(X,ha(Hs));Z|=i}return oi(k,Z,R,X,ae)}),rl=Vt(function(k,R,X){var Z=m|c;if(X.length){var ae=gi(X,ha(rl));Z|=i}return oi(R,Z,k,X,ae)});function nl(k,R,X){R=X?e:R;var Z=oi(k,r,e,e,e,e,e,R);return Z.placeholder=nl.placeholder,Z}function il(k,R,X){R=X?e:R;var Z=oi(k,t,e,e,e,e,e,R);return Z.placeholder=il.placeholder,Z}function al(k,R,X){var Z,ae,ve,Te,Ae,ze,qe=0,et=!1,at=!1,vt=!0;if(typeof k!="function")throw new Rn(y);R=In(R)||0,yr(X)&&(et=!!X.leading,at="maxWait"in X,ve=at?Ir(In(X.maxWait)||0,R):ve,vt="trailing"in X?!!X.trailing:vt);function xt(kr){var Un=Z,ci=ae;return Z=ae=e,qe=kr,Te=k.apply(ci,Un),Te}function Nt(kr){return qe=kr,Ae=La(Gt,R),et?xt(kr):Te}function $t(kr){var Un=kr-ze,ci=kr-qe,xl=R-Un;return at?Wr(xl,ve-ci):xl}function Dt(kr){var Un=kr-ze,ci=kr-qe;return ze===e||Un>=R||Un<0||at&&ci>=ve}function Gt(){var kr=Ro();if(Dt(kr))return qt(kr);Ae=La(Gt,$t(kr))}function qt(kr){return Ae=e,vt&&Z?xt(kr):(Z=ae=e,Te)}function gn(){Ae!==e&&vu(Ae),qe=0,Z=ze=ae=Ae=e}function tn(){return Ae===e?Te:qt(Ro())}function _n(){var kr=Ro(),Un=Dt(kr);if(Z=arguments,ae=this,ze=kr,Un){if(Ae===e)return Nt(ze);if(at)return vu(Ae),Ae=La(Gt,R),xt(ze)}return Ae===e&&(Ae=La(Gt,R)),Te}return _n.cancel=gn,_n.flush=tn,_n}var wv=Vt(function(k,R){return Gf(k,1,R)}),Sv=Vt(function(k,R,X){return Gf(k,In(R)||0,X)});function kv(k){return oi(k,E)}function Co(k,R){if(typeof k!="function"||R!=null&&typeof R!="function")throw new Rn(y);var X=function(){var Z=arguments,ae=R?R.apply(this,Z):Z[0],ve=X.cache;if(ve.has(ae))return ve.get(ae);var Te=k.apply(this,Z);return X.cache=ve.set(ae,Te)||ve,Te};return X.cache=new(Co.Cache||ii),X}Co.Cache=ii;function Po(k){if(typeof k!="function")throw new Rn(y);return function(){var R=arguments;switch(R.length){case 0:return!k.call(this);case 1:return!k.call(this,R[0]);case 2:return!k.call(this,R[0],R[1]);case 3:return!k.call(this,R[0],R[1],R[2])}return!k.apply(this,R)}}function xv(k){return tl(2,k)}var Ov=cd(function(k,R){R=R.length==1&&jt(R[0])?Oe(R[0],yn(It())):Oe(Hr(R,1),yn(It()));var X=R.length;return Vt(function(Z){for(var ae=-1,ve=Wr(Z.length,X);++ae=R}),Fi=qf(function(){return arguments}())?qf:function(k){return br(k)&&sr.call(k,"callee")&&!Lf.call(k,"callee")},jt=We.isArray,zv=ur?yn(ur):Gh;function an(k){return k!=null&&Ao(k.length)&&!ui(k)}function Sr(k){return br(k)&&an(k)}function Hv(k){return k===!0||k===!1||br(k)&&qr(k)==te}var Oi=th||qs,Xv=Pr?yn(Pr):Yh;function Uv(k){return br(k)&&k.nodeType===1&&!za(k)}function $v(k){if(k==null)return!0;if(an(k)&&(jt(k)||typeof k=="string"||typeof k.splice=="function"||Oi(k)||da(k)||Fi(k)))return!k.length;var R=Vr(k);if(R==J||R==q)return!k.size;if(ja(k))return!ms(k).length;for(var X in k)if(sr.call(k,X))return!1;return!0}function Wv(k,R){return Da(k,R)}function Vv(k,R,X){X=typeof X=="function"?X:e;var Z=X?X(k,R):e;return Z===e?Da(k,R,e,X):!!Z}function Us(k){if(!br(k))return!1;var R=qr(k);return R==ye||R==le||typeof k.message=="string"&&typeof k.name=="string"&&!za(k)}function Kv(k){return typeof k=="number"&&Hf(k)}function ui(k){if(!yr(k))return!1;var R=qr(k);return R==ge||R==ne||R==V||R==se}function sl(k){return typeof k=="number"&&k==Ut(k)}function Ao(k){return typeof k=="number"&&k>-1&&k%1==0&&k<=O}function yr(k){var R=typeof k;return k!=null&&(R=="object"||R=="function")}function br(k){return k!=null&&typeof k=="object"}var fl=Fr?yn(Fr):Jh;function Gv(k,R){return k===R||ys(k,R,Is(R))}function Yv(k,R,X){return X=typeof X=="function"?X:e,ys(k,R,Is(R),X)}function Zv(k){return ul(k)&&k!=+k}function Jv(k){if(Nd(k))throw new Ft(u);return eu(k)}function Qv(k){return k===null}function qv(k){return k==null}function ul(k){return typeof k=="number"||br(k)&&qr(k)==Q}function za(k){if(!br(k)||qr(k)!=xe)return!1;var R=no(k);if(R===null)return!0;var X=sr.call(R,"constructor")&&R.constructor;return typeof X=="function"&&X instanceof X&&qa.call(X)==Yc}var $s=dr?yn(dr):Qh;function ey(k){return sl(k)&&k>=-O&&k<=O}var ll=Er?yn(Er):qh;function Mo(k){return typeof k=="string"||!jt(k)&&br(k)&&qr(k)==G}function bn(k){return typeof k=="symbol"||br(k)&&qr(k)==Y}var da=Ar?yn(Ar):ed;function ty(k){return k===e}function ry(k){return br(k)&&Vr(k)==we}function ny(k){return br(k)&&qr(k)==_e}var iy=So(bs),ay=So(function(k,R){return k<=R});function cl(k){if(!k)return[];if(an(k))return Mo(k)?zn(k):nn(k);if(Ta&&k[Ta])return Fc(k[Ta]());var R=Vr(k),X=R==J?as:R==q?Za:pa;return X(k)}function li(k){if(!k)return k===0?k:0;if(k=In(k),k===C||k===-C){var R=k<0?-1:1;return R*A}return k===k?k:0}function Ut(k){var R=li(k),X=R%1;return R===R?X?R-X:R:0}function hl(k){return k?Ii(Ut(k),0,U):0}function In(k){if(typeof k=="number")return k;if(bn(k))return L;if(yr(k)){var R=typeof k.valueOf=="function"?k.valueOf():k;k=yr(R)?R+"":R}if(typeof k!="string")return k===0?k:+k;k=Af(k);var X=St.test(k);return X||Lt.test(k)?Se(k.slice(2),X?2:8):Ct.test(k)?L:+k}function dl(k){return Yn(k,on(k))}function oy(k){return k?Ii(Ut(k),-O,O):k===0?k:0}function or(k){return k==null?"":mn(k)}var sy=la(function(k,R){if(ja(R)||an(R)){Yn(R,jr(R),k);return}for(var X in R)sr.call(R,X)&&Ma(k,X,R[X])}),pl=la(function(k,R){Yn(R,on(R),k)}),Io=la(function(k,R,X,Z){Yn(R,on(R),k,Z)}),fy=la(function(k,R,X,Z){Yn(R,jr(R),k,Z)}),uy=si(cs);function ly(k,R){var X=ua(k);return R==null?X:Vf(X,R)}var cy=Vt(function(k,R){k=cr(k);var X=-1,Z=R.length,ae=Z>2?R[2]:e;for(ae&&en(R[0],R[1],ae)&&(Z=1);++X1),ve}),Yn(k,As(k),X),Z&&(X=Pn(X,v|h|l,Sd));for(var ae=R.length;ae--;)ks(X,R[ae]);return X});function Cy(k,R){return yl(k,Po(It(R)))}var Py=si(function(k,R){return k==null?{}:nd(k,R)});function yl(k,R){if(k==null)return{};var X=Oe(As(k),function(Z){return[Z]});return R=It(R),su(k,X,function(Z,ae){return R(Z,ae[0])})}function Ay(k,R,X){R=ki(R,k);var Z=-1,ae=R.length;for(ae||(ae=1,k=e);++ZR){var Z=k;k=R,R=Z}if(X||k%1||R%1){var ae=Xf();return Wr(k+ae*(R-k+ea("1e-"+((ae+"").length-1))),R)}return _s(k,R)}var Xy=ca(function(k,R,X){return R=R.toLowerCase(),k+(X?gl(R):R)});function gl(k){return Ks(or(k).toLowerCase())}function _l(k){return k=or(k),k&&k.replace(Nr,Mc).replace(Zi,"")}function Uy(k,R,X){k=or(k),R=mn(R);var Z=k.length;X=X===e?Z:Ii(Ut(X),0,Z);var ae=X;return X-=R.length,X>=0&&k.slice(X,ae)==R}function $y(k){return k=or(k),k&&it.test(k)?k.replace(ee,Ic):k}function Wy(k){return k=or(k),k&&Ge.test(k)?k.replace(st,"\\$&"):k}var Vy=ca(function(k,R,X){return k+(X?"-":"")+R.toLowerCase()}),Ky=ca(function(k,R,X){return k+(X?" ":"")+R.toLowerCase()}),Gy=ku("toLowerCase");function Yy(k,R,X){k=or(k),R=Ut(R);var Z=R?ia(k):0;if(!R||Z>=R)return k;var ae=(R-Z)/2;return wo(so(ae),X)+k+wo(oo(ae),X)}function Zy(k,R,X){k=or(k),R=Ut(R);var Z=R?ia(k):0;return R&&Z>>0,X?(k=or(k),k&&(typeof R=="string"||R!=null&&!$s(R))&&(R=mn(R),!R&&na(k))?xi(zn(k),0,X):k.split(R,X)):[]}var n0=ca(function(k,R,X){return k+(X?" ":"")+Ks(R)});function i0(k,R,X){return k=or(k),X=X==null?0:Ii(Ut(X),0,k.length),R=mn(R),k.slice(X,X+R.length)==R}function a0(k,R,X){var Z=de.templateSettings;X&&en(k,R,X)&&(R=e),k=or(k),R=Io({},R,Z,Pu);var ae=Io({},R.imports,Z.imports,Pu),ve=jr(ae),Te=is(ae,ve),Ae,ze,qe=0,et=R.interpolate||Or,at="__p += '",vt=os((R.escape||Or).source+"|"+et.source+"|"+(et===Le?bt:Or).source+"|"+(R.evaluate||Or).source+"|$","g"),xt="//# sourceURL="+(sr.call(R,"sourceURL")?(R.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ji+"]")+` `;k.replace(vt,function(Dt,Gt,qt,gn,tn,_n){return qt||(qt=gn),at+=k.slice(qe,_n).replace(Gr,Nc),Gt&&(Ae=!0,at+=`' + __e(`+Gt+`) + '`),tn&&(ze=!0,at+=`'; @@ -37,45 +37,45 @@ __p += '`),qt&&(at+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+at+`return __p -}`;var $t=Sl(function(){return ar(ve,xt+"return "+at).apply(e,Te)});if($t.source=at,Us($t))throw $t;return $t}function o0(k){return or(k).toLowerCase()}function s0(k){return or(k).toUpperCase()}function f0(k,R,X){if(k=or(k),k&&(X||R===e))return Af(k);if(!k||!(R=mn(R)))return k;var Z=zn(k),ie=zn(R),ve=Mf(Z,ie),Te=If(Z,ie)+1;return xi(Z,ve,Te).join("")}function u0(k,R,X){if(k=or(k),k&&(X||R===e))return k.slice(0,Df(k)+1);if(!k||!(R=mn(R)))return k;var Z=zn(k),ie=If(Z,zn(R))+1;return xi(Z,0,ie).join("")}function l0(k,R,X){if(k=or(k),k&&(X||R===e))return k.replace(rt,"");if(!k||!(R=mn(R)))return k;var Z=zn(k),ie=Mf(Z,zn(R));return xi(Z,ie).join("")}function c0(k,R){var X=P,Z=B;if(yr(R)){var ie="separator"in R?R.separator:ie;X="length"in R?Ut(R.length):X,Z="omission"in R?mn(R.omission):Z}k=or(k);var ve=k.length;if(na(k)){var Te=zn(k);ve=Te.length}if(X>=ve)return k;var Ae=X-ia(Z);if(Ae<1)return Z;var ze=Te?xi(Te,0,Ae).join(""):k.slice(0,Ae);if(ie===e)return ze+Z;if(Te&&(Ae+=ze.length-Ae),$s(ie)){if(k.slice(Ae).search(ie)){var qe,et=ze;for(ie.global||(ie=os(ie.source,or(Kt.exec(ie))+"g")),ie.lastIndex=0;qe=ie.exec(et);)var at=qe.index;ze=ze.slice(0,at===e?Ae:at)}}else if(k.indexOf(mn(ie),Ae)!=Ae){var vt=ze.lastIndexOf(ie);vt>-1&&(ze=ze.slice(0,vt))}return ze+Z}function h0(k){return k=or(k),k&&He.test(k)?k.replace(Pe,Hc):k}var d0=ca(function(k,R,X){return k+(X?" ":"")+R.toUpperCase()}),Ks=ku("toUpperCase");function wl(k,R,X){return k=or(k),R=X?e:R,R===e?Bc(k)?$c(k):hr(k):k.match(R)||[]}var Sl=Vt(function(k,R){try{return pr(k,e,R)}catch(X){return Us(X)?X:new Ft(X)}}),p0=si(function(k,R){return mr(R,function(X){X=Zn(X),ai(k,X,Hs(k[X],k))}),k});function v0(k){var R=k==null?0:k.length,X=It();return k=R?Oe(k,function(Z){if(typeof Z[1]!="function")throw new Rn(y);return[X(Z[0]),Z[1]]}):[],Vt(function(Z){for(var ie=-1;++ieE)return[];var X=$,Z=Wr(k,$);R=It(R),k-=$;for(var ie=bi(Z,R);++X0||R<0)?new Zt(X):(k<0?X=X.takeRight(-k):k&&(X=X.drop(k)),R!==e&&(R=Ut(R),X=R<0?X.dropRight(-R):X.take(R-k)),X)},Zt.prototype.takeRightWhile=function(k){return this.reverse().takeWhile(k).reverse()},Zt.prototype.toArray=function(){return this.take($)},Gn(Zt.prototype,function(k,R){var X=/^(?:filter|find|map|reject)|While$/.test(R),Z=/^(?:head|last)$/.test(R),ie=de[Z?"take"+(R=="last"?"Right":""):R],ve=Z||/^find/.test(R);ie&&(de.prototype[R]=function(){var Te=this.__wrapped__,Ae=Z?[1]:arguments,ze=Te instanceof Zt,qe=Ae[0],et=ze||jt(Te),at=function(Gt){var qt=ie.apply(de,Xe([Gt],Ae));return Z&&vt?qt[0]:qt};et&&X&&typeof qe=="function"&&qe.length!=1&&(ze=et=!1);var vt=this.__chain__,xt=!!this.__actions__.length,Nt=ve&&!vt,$t=ze&&!xt;if(!ve&&et){Te=$t?Te:new Zt(this);var Dt=k.apply(Te,Ae);return Dt.__actions__.push({func:Eo,args:[at],thisArg:e}),new Cn(Dt,vt)}return Nt&&$t?k.apply(this,Ae):(Dt=this.thru(at),Nt?Z?Dt.value()[0]:Dt.value():Dt)})}),mr(["pop","push","shift","sort","splice","unshift"],function(k){var R=Ja[k],X=/^(?:push|sort|unshift)$/.test(k)?"tap":"thru",Z=/^(?:pop|shift)$/.test(k);de.prototype[k]=function(){var ie=arguments;if(Z&&!this.__chain__){var ve=this.value();return R.apply(jt(ve)?ve:[],ie)}return this[X](function(Te){return R.apply(jt(Te)?Te:[],ie)})}}),Gn(Zt.prototype,function(k,R){var X=de[R];if(X){var Z=X.name+"";sr.call(fa,Z)||(fa[Z]=[]),fa[Z].push({name:R,func:X})}}),fa[go(e,c).name]=[{name:"wrapper",func:e}],Zt.prototype.clone=hh,Zt.prototype.reverse=dh,Zt.prototype.value=ph,de.prototype.at=Up,de.prototype.chain=$p,de.prototype.commit=Wp,de.prototype.next=Vp,de.prototype.plant=Gp,de.prototype.reverse=Yp,de.prototype.toJSON=de.prototype.valueOf=de.prototype.value=Zp,de.prototype.first=de.prototype.head,Ta&&(de.prototype[Ta]=Kp),de},aa=Wc();Mt?((Mt.exports=aa)._=aa,Yt._=aa):ht._=aa}).call(Wt)})(qo,qo.exports);var rs=qo.exports,Ec={exports:{}};(function(H,x){(function(e){H.exports=e()})(function(){return function(){function e(S,_,u){function y(w,f){if(!_[w]){if(!S[w]){var v=typeof No=="function"&&No;if(!f&&v)return v(w,!0);if(g)return g(w,!0);var h=new Error("Cannot find module '"+w+"'");throw h.code="MODULE_NOT_FOUND",h}var l=_[w]={exports:{}};S[w][0].call(l.exports,function(d){var s=S[w][1][d];return y(s||d)},l,l.exports,e,S,_,u)}return _[w].exports}for(var g=typeof No=="function"&&No,b=0;b2&&arguments[2]!==void 0?arguments[2]:0;if(u(this,f),!h)this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0;else if(typeof h=="string"){var d=b.decodeAddress(h);this.nativeCol=d.col+l,this.nativeColOff=0,this.nativeRow=d.row+l,this.nativeRowOff=0}else h.nativeCol!==void 0?(this.nativeCol=h.nativeCol||0,this.nativeColOff=h.nativeColOff||0,this.nativeRow=h.nativeRow||0,this.nativeRowOff=h.nativeRowOff||0):h.col!==void 0?(this.col=h.col+l,this.row=h.row+l):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);this.worksheet=v}return g(f,[{key:"col",get:function(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth},set:function(h){this.nativeCol=Math.floor(h),this.nativeColOff=Math.floor((h-this.nativeCol)*this.colWidth)}},{key:"row",get:function(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight},set:function(h){this.nativeRow=Math.floor(h),this.nativeRowOff=Math.floor((h-this.nativeRow)*this.rowHeight)}},{key:"colWidth",get:function(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(this.worksheet.getColumn(this.nativeCol+1).width*1e4):64e4}},{key:"rowHeight",get:function(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(this.worksheet.getRow(this.nativeRow+1).height*1e4):18e4}},{key:"model",get:function(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}},set:function(h){this.nativeCol=h.nativeCol,this.nativeColOff=h.nativeColOff,this.nativeRow=h.nativeRow,this.nativeRowOff=h.nativeRowOff}}],[{key:"asInstance",value:function(h){return h instanceof f||h==null?h:new f(h)}}]),f}();S.exports=w},{"../utils/col-cache":19}],3:[function(e,S,_){function u(z,D){if(!(z instanceof D))throw new TypeError("Cannot call a class as a function")}function y(z,D){for(var M=0;M0||this.type===z.Types.Merge}},{key:"master",get:function(){return this.type===z.Types.Merge?this._value.master:this}},{key:"isHyperlink",get:function(){return this._value.type===z.Types.Hyperlink}},{key:"hyperlink",get:function(){return this._value.hyperlink}},{key:"value",get:function(){return this._value.value},set:function(M){if(this.type===z.Types.Merge){this._value.master.value=M;return}this._value.release(),this._value=B.create(B.getType(M),this,M)}},{key:"note",get:function(){return this._comment&&this._comment.note},set:function(M){this._comment=new l(M)}},{key:"text",get:function(){return this._value.toString()}},{key:"html",get:function(){return w.escapeHtml(this.text)}},{key:"formula",get:function(){return this._value.formula}},{key:"result",get:function(){return this._value.result}},{key:"formulaType",get:function(){return this._value.formulaType}},{key:"fullAddress",get:function(){var M=this._row.worksheet;return{sheetName:M.name,address:this.address,row:this.row,col:this.col}}},{key:"name",get:function(){return this.names[0]},set:function(M){this.names=[M]}},{key:"names",get:function(){return this.workbook.definedNames.getNamesEx(this.fullAddress)},set:function(M){var I=this,T=this.workbook.definedNames;T.removeAllNames(this.fullAddress),M.forEach(function(C){T.addEx(I.fullAddress,C)})}},{key:"_dataValidations",get:function(){return this.worksheet.dataValidations}},{key:"dataValidation",get:function(){return this._dataValidations.find(this.address)},set:function(M){this._dataValidations.add(this.address,M)}},{key:"model",get:function(){var M=this._value.model;return M.style=this.style,this._comment&&(M.comment=this._comment.model),M},set:function(M){if(this._value.release(),this._value=B.create(M.type,this),this._value.model=M,M.comment)switch(M.comment.type){case"note":this._comment=l.fromModel(M.comment);break}M.style?this.style=M.style:this.style={}}}]),z}();d.Types=f.ValueType;var s=function(){function z(D){u(this,z),this.model={address:D.address,type:d.Types.Null}}return g(z,[{key:"toCsvString",value:function(){return""}},{key:"release",value:function(){}},{key:"toString",value:function(){return""}},{key:"value",get:function(){return null},set:function(M){}},{key:"type",get:function(){return d.Types.Null}},{key:"effectiveType",get:function(){return d.Types.Null}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),m=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.Number,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Number}},{key:"effectiveType",get:function(){return d.Types.Number}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),c=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.String,value:M}}return g(z,[{key:"toCsvString",value:function(){return'"'.concat(this.model.value.replace(/"/g,'""'),'"')}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.String}},{key:"effectiveType",get:function(){return d.Types.String}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),a=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.String,value:M}}return g(z,[{key:"toString",value:function(){return this.model.value.richText.map(function(M){return M.text}).join("")}},{key:"toCsvString",value:function(){return'"'.concat(this.text.replace(/"/g,'""'),'"')}},{key:"release",value:function(){}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.RichText}},{key:"effectiveType",get:function(){return d.Types.RichText}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),r=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.Date,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value.toISOString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Date}},{key:"effectiveType",get:function(){return d.Types.Date}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),t=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.Hyperlink,text:M?M.text:void 0,hyperlink:M?M.hyperlink:void 0},M&&M.tooltip&&(this.model.tooltip=M.tooltip)}return g(z,[{key:"toCsvString",value:function(){return this.model.hyperlink}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.text}},{key:"value",get:function(){var M={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(M.tooltip=this.model.tooltip),M},set:function(M){this.model={text:M.text,hyperlink:M.hyperlink},M.tooltip&&(this.model.tooltip=M.tooltip)}},{key:"text",get:function(){return this.model.text},set:function(M){this.model.text=M}},{key:"hyperlink",get:function(){return this.model.hyperlink},set:function(M){this.model.hyperlink=M}},{key:"type",get:function(){return d.Types.Hyperlink}},{key:"effectiveType",get:function(){return d.Types.Hyperlink}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),i=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.Merge,master:M?M.address:void 0},this._master=M,M&&M.addMergeRef()}return g(z,[{key:"isMergedTo",value:function(M){return M===this._master}},{key:"toCsvString",value:function(){return""}},{key:"release",value:function(){this._master.releaseMergeRef()}},{key:"toString",value:function(){return this.value.toString()}},{key:"value",get:function(){return this._master.value},set:function(M){M instanceof d?(this._master&&this._master.releaseMergeRef(),M.addMergeRef(),this._master=M):this._master.value=M}},{key:"master",get:function(){return this._master}},{key:"type",get:function(){return d.Types.Merge}},{key:"effectiveType",get:function(){return this._master.effectiveType}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),n=function(){function z(D,M){u(this,z),this.cell=D,this.model={address:D.address,type:d.Types.Formula,shareType:M?M.shareType:void 0,ref:M?M.ref:void 0,formula:M?M.formula:void 0,sharedFormula:M?M.sharedFormula:void 0,result:M?M.result:void 0}}return g(z,[{key:"_copyModel",value:function(M){var I={},T=function(E){var A=M[E];A&&(I[E]=A)};return T("formula"),T("result"),T("ref"),T("shareType"),T("sharedFormula"),I}},{key:"validate",value:function(M){switch(B.getType(M)){case d.Types.Null:case d.Types.String:case d.Types.Number:case d.Types.Date:break;case d.Types.Hyperlink:case d.Types.Formula:default:throw new Error("Cannot process that type of result value")}}},{key:"_getTranslatedFormula",value:function(){if(!this._translatedFormula&&this.model.sharedFormula){var M=this.cell.worksheet,I=M.findCell(this.model.sharedFormula);this._translatedFormula=I&&h(I.formula,I.address,this.model.address)}return this._translatedFormula}},{key:"toCsvString",value:function(){return"".concat(this.model.result||"")}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.result?this.model.result.toString():""}},{key:"value",get:function(){return this._copyModel(this.model)},set:function(M){this.model=this._copyModel(M)}},{key:"dependencies",get:function(){var M=this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),I=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);return{ranges:M,cells:I}}},{key:"formula",get:function(){return this.model.formula||this._getTranslatedFormula()},set:function(M){this.model.formula=M}},{key:"formulaType",get:function(){return this.model.formula?f.FormulaType.Master:this.model.sharedFormula?f.FormulaType.Shared:f.FormulaType.None}},{key:"result",get:function(){return this.model.result},set:function(M){this.model.result=M}},{key:"type",get:function(){return d.Types.Formula}},{key:"effectiveType",get:function(){var M=this.model.result;return M==null?f.ValueType.Null:M instanceof String||typeof M=="string"?f.ValueType.String:typeof M=="number"?f.ValueType.Number:M instanceof Date?f.ValueType.Date:M.text&&M.hyperlink?f.ValueType.Hyperlink:M.formula?f.ValueType.Formula:f.ValueType.Null}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),o=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.SharedString,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.SharedString}},{key:"effectiveType",get:function(){return d.Types.SharedString}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),p=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.Boolean,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value?1:0}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Boolean}},{key:"effectiveType",get:function(){return d.Types.Boolean}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),O=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.Error,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.error.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Error}},{key:"effectiveType",get:function(){return d.Types.Error}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),P=function(){function z(D,M){u(this,z),this.model={address:D.address,type:d.Types.String,value:JSON.stringify(M),rawValue:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value}},{key:"value",get:function(){return this.model.rawValue},set:function(M){this.model.rawValue=M,this.model.value=JSON.stringify(M)}},{key:"type",get:function(){return d.Types.String}},{key:"effectiveType",get:function(){return d.Types.String}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),B={getType:function(D){return D==null?d.Types.Null:D instanceof String||typeof D=="string"?d.Types.String:typeof D=="number"?d.Types.Number:typeof D=="boolean"?d.Types.Boolean:D instanceof Date?d.Types.Date:D.text&&D.hyperlink?d.Types.Hyperlink:D.formula||D.sharedFormula?d.Types.Formula:D.richText?d.Types.RichText:D.sharedString?d.Types.SharedString:D.error?d.Types.Error:d.Types.JSON},types:[{t:d.Types.Null,f:s},{t:d.Types.Number,f:m},{t:d.Types.String,f:c},{t:d.Types.Date,f:r},{t:d.Types.Hyperlink,f:t},{t:d.Types.Formula,f:n},{t:d.Types.Merge,f:i},{t:d.Types.JSON,f:P},{t:d.Types.SharedString,f:o},{t:d.Types.RichText,f:a},{t:d.Types.Boolean,f:p},{t:d.Types.Error,f:O}].reduce(function(z,D){return z[D.t]=D.f,z},[]),create:function(D,M,I){var T=this.types[D];if(!T)throw new Error("Could not create Value of type ".concat(D));return new T(M,I)}};S.exports=d},{"../utils/col-cache":19,"../utils/shared-formula":22,"../utils/under-dash":25,"./enums":7,"./note":9}],4:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s=this._worksheet.properties.outlineLevelCol)}},{key:"isDefault",get:function(){if(this.isCustomWidth||this.hidden||this.outlineLevel)return!1;var s=this.style;return!(s&&(s.font||s.numFmt||s.alignment||s.border||s.fill||s.protection))}},{key:"headerCount",get:function(){return this.headers.length}},{key:"values",get:function(){var s=[];return this.eachCell(function(m,c){m&&m.type!==w.ValueType.Null&&(s[c]=m.value)}),s},set:function(s){var m=this;if(s){var c=this.number,a=0;s.hasOwnProperty("0")&&(a=1),s.forEach(function(r,t){m._worksheet.getCell(t+a,c).value=r})}}},{key:"numFmt",get:function(){return this.style.numFmt},set:function(s){this._applyStyle("numFmt",s)}},{key:"font",get:function(){return this.style.font},set:function(s){this._applyStyle("font",s)}},{key:"alignment",get:function(){return this.style.alignment},set:function(s){this._applyStyle("alignment",s)}},{key:"protection",get:function(){return this.style.protection},set:function(s){this._applyStyle("protection",s)}},{key:"border",get:function(){return this.style.border},set:function(s){this._applyStyle("border",s)}},{key:"fill",get:function(){return this.style.fill},set:function(s){this._applyStyle("fill",s)}}],[{key:"toModel",value:function(s){var m=[],c=null;return s&&s.forEach(function(a,r){a.isDefault?c&&(c=null):!c||!a.equivalentTo(c)?(c={min:r+1,max:r+1,width:a.width!==void 0?a.width:v,style:a.style,isCustomWidth:a.isCustomWidth,hidden:a.hidden,outlineLevel:a.outlineLevel,collapsed:a.collapsed},m.push(c)):c.max=r+1}),m.length?m:void 0}},{key:"fromModel",value:function(s,m){m=m||[];for(var c=[],a=1,r=0;rthis.bottom)&&(this.bottom=d),(!this.model.right||s>this.right)&&(this.right=s)}},{key:"expandRow",value:function(h){if(h){var l=h.dimensions,d=h.number;l&&this.expand(d,l.min,d,l.max)}}},{key:"expandToAddress",value:function(h){var l=b.decodeEx(h);this.expand(l.row,l.col,l.row,l.col)}},{key:"toString",value:function(){return this.range}},{key:"intersects",value:function(h){return!(h.sheetName&&this.sheetName&&h.sheetName!==this.sheetName||h.bottomthis.bottom||h.rightthis.right)}},{key:"contains",value:function(h){var l=b.decodeEx(h);return this.containsEx(l)}},{key:"containsEx",value:function(h){return h.sheetName&&this.sheetName&&h.sheetName!==this.sheetName?!1:h.row>=this.top&&h.row<=this.bottom&&h.col>=this.left&&h.col<=this.right}},{key:"forEachAddress",value:function(h){for(var l=this.left;l<=this.right;l++)for(var d=this.top;d<=this.bottom;d++)h(b.encodeAddress(d,l),d,l)}},{key:"top",get:function(){return this.model.top||1},set:function(h){this.model.top=h}},{key:"left",get:function(){return this.model.left||1},set:function(h){this.model.left=h}},{key:"bottom",get:function(){return this.model.bottom||1},set:function(h){this.model.bottom=h}},{key:"right",get:function(){return this.model.right||1},set:function(h){this.model.right=h}},{key:"sheetName",get:function(){return this.model.sheetName},set:function(h){this.model.sheetName=h}},{key:"_serialisedSheetName",get:function(){var h=this.model.sheetName;return h?/^[a-zA-Z0-9]*$/.test(h)?"".concat(h,"!"):"'".concat(h,"'!"):""}},{key:"tl",get:function(){return b.n2l(this.left)+this.top}},{key:"$t$l",get:function(){return"$".concat(b.n2l(this.left),"$").concat(this.top)}},{key:"br",get:function(){return b.n2l(this.right)+this.bottom}},{key:"$b$r",get:function(){return"$".concat(b.n2l(this.right),"$").concat(this.bottom)}},{key:"range",get:function(){return"".concat(this._serialisedSheetName+this.tl,":").concat(this.br)}},{key:"$range",get:function(){return"".concat(this._serialisedSheetName+this.$t$l,":").concat(this.$b$r)}},{key:"shortRange",get:function(){return this.count>1?this.range:this._serialisedSheetName+this.tl}},{key:"$shortRange",get:function(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}},{key:"count",get:function(){return(1+this.bottom-this.top)*(1+this.right-this.left)}}]),f}();S.exports=w},{"../utils/col-cache":19}],11:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s2?a-2:0),t=2;t0)for(o=n;o>=c;o--)p=this._cells[o-1],p?(O=this.getCell(o+i),O.value=p.value,O.style=p.style,O._comment=p._comment):this._cells[o+i-1]=void 0;for(o=0;oc.col)&&(s=c.col),m0?{min:s,max:m}:null}},{key:"numFmt",get:function(){return this.style.numFmt},set:function(s){this._applyStyle("numFmt",s)}},{key:"font",get:function(){return this.style.font},set:function(s){this._applyStyle("font",s)}},{key:"alignment",get:function(){return this.style.alignment},set:function(s){this._applyStyle("alignment",s)}},{key:"protection",get:function(){return this.style.protection},set:function(s){this._applyStyle("protection",s)}},{key:"border",get:function(){return this.style.border},set:function(s){this._applyStyle("border",s)}},{key:"fill",get:function(){return this.style.fill},set:function(s){this._applyStyle("fill",s)}},{key:"hidden",get:function(){return!!this._hidden},set:function(s){this._hidden=s}},{key:"outlineLevel",get:function(){return this._outlineLevel||0},set:function(s){this._outlineLevel=s}},{key:"collapsed",get:function(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}},{key:"model",get:function(){var s=[],m=0,c=0;return this._cells.forEach(function(a){if(a){var r=a.model;r&&((!m||m>a.col)&&(m=a.col),c0,"Table must be on valid row"),m(r>0,"Table must be on valid col");var t=this.width,i=this.filterHeight,n=this.tableHeight;d.autoFilterRef=b.encode(a,r,a+i-1,r+t-1),d.tableRef=b.encode(a,r,a+n-1,r+t-1),d.columns.forEach(function(o,p){m(o.name,"Column ".concat(p," must have a name")),p===0?s(o,"totalsRowLabel","Total"):(s(o,"totalsRowFunction","none"),o.totalsRowFormula=l.getFormula(o))})}},{key:"store",value:function(){var l=this,d=function(p,O){O&&Object.keys(O).forEach(function(P){p[P]=O[P]})},s=this.worksheet,m=this.table,c=m.tl,a=c.row,r=c.col,t=0;if(m.headerRow){var i=s.getRow(a+t++);m.columns.forEach(function(o,p){var O=o.style,P=o.name,B=i.getCell(r+p);B.value=P,d(B,O)})}if(m.rows.forEach(function(o){var p=s.getRow(a+t++);o.forEach(function(O,P){var B=p.getCell(r+P);B.value=O,d(B,m.columns[P].style)})}),m.totalsRow){var n=s.getRow(a+t++);m.columns.forEach(function(o,p){var O=n.getCell(r+p);if(p===0)O.value=o.totalsRowLabel;else{var P=l.getFormula(o);P?O.value={formula:o.totalsRowFormula,result:o.totalsRowResult}:O.value=null}d(O,o.style)})}}},{key:"load",value:function(l){var d=this,s=this.table,m=s.tl,c=m.row,a=m.col,r=0;if(s.headerRow){var t=l.getRow(c+r++);s.columns.forEach(function(n,o){var p=t.getCell(a+o);p.value=n.name})}if(s.rows.forEach(function(n){var o=l.getRow(c+r++);n.forEach(function(p,O){var P=o.getCell(a+O);P.value=p})}),s.totalsRow){var i=l.getRow(c+r++);s.columns.forEach(function(n,o){var p=i.getCell(a+o);if(o===0)p.value=n.totalsRowLabel;else{var O=d.getFormula(n);O&&(p.value={formula:n.totalsRowFormula,result:n.totalsRowResult})}})}}},{key:"cacheState",value:function(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}},{key:"commit",value:function(){if(this._cache){this.validate();var l=b.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(var d=0;d1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.rows.splice(l,d)}},{key:"getColumn",value:function(l){var d=this.table.columns[l];return new w(this,d,l)}},{key:"addColumn",value:function(l,d,s){this.cacheState(),s===void 0?(this.table.columns.push(l),this.table.rows.forEach(function(m,c){m.push(d[c])})):(this.table.columns.splice(s,0,l),this.table.rows.forEach(function(m,c){m.splice(s,0,d[c])}))}},{key:"removeColumns",value:function(l){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.columns.splice(l,d),this.table.rows.forEach(function(s){s.splice(l,d)})}},{key:"_assign",value:function(l,d,s){this.cacheState(),l[d]=s}},{key:"width",get:function(){return this.table.columns.length}},{key:"height",get:function(){return this.table.rows.length}},{key:"filterHeight",get:function(){return this.height+(this.table.headerRow?1:0)}},{key:"tableHeight",get:function(){return this.filterHeight+(this.table.totalsRow?1:0)}},{key:"model",get:function(){return this.table},set:function(l){this.table=l}},{key:"ref",get:function(){return this.table.ref},set:function(l){this._assign(this.table,"ref",l)}},{key:"name",get:function(){return this.table.name},set:function(l){this.table.name=l}},{key:"displayName",get:function(){return this.table.displyName||this.table.name}},{key:"displayNamename",set:function(l){this.table.displayName=l}},{key:"headerRow",get:function(){return this.table.headerRow},set:function(l){this._assign(this.table,"headerRow",l)}},{key:"totalsRow",get:function(){return this.table.totalsRow},set:function(l){this._assign(this.table,"totalsRow",l)}},{key:"theme",get:function(){return this.table.style.name},set:function(l){this.table.style.name=l}},{key:"showFirstColumn",get:function(){return this.table.style.showFirstColumn},set:function(l){this.table.style.showFirstColumn=l}},{key:"showLastColumn",get:function(){return this.table.style.showLastColumn},set:function(l){this.table.style.showLastColumn=l}},{key:"showRowStripes",get:function(){return this.table.style.showRowStripes},set:function(l){this.table.style.showRowStripes=l}},{key:"showColumnStripes",get:function(){return this.table.style.showColumnStripes},set:function(l){this.table.style.showColumnStripes=l}}]),v}();S.exports=f},{"../utils/col-cache":19}],13:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s31&&console.warn("Worksheet name ".concat(s," exceeds 31 chars. This will be truncated")),/[*?:/\\[\]]/.test(s))throw new Error("Worksheet name ".concat(s," cannot include any of the following characters: * ? : \\ / [ ]"));if(/(^')|('$)/.test(s))throw new Error("The first or last character of worksheet name cannot be a single quotation mark: ".concat(s));if(s=(s||"sheet".concat(c)).substring(0,31),this._worksheets.find(function(i){return i&&i.name.toLowerCase()===s.toLowerCase()}))throw new Error("Worksheet name already exists: ".concat(s));m&&(typeof m=="string"?(console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'),m={properties:{tabColor:{argb:m}}}):(m.argb||m.theme||m.indexed)&&(console.trace("tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }"),m={properties:{tabColor:m}}));var a=this._worksheets.reduce(function(i,n){return(n&&n.orderNo)>i?n.orderNo:i},0),r=Object.assign({},m,{id:c,name:s,orderNo:a+1,workbook:this}),t=new b(r);return this._worksheets[c]=t,t}},{key:"removeWorksheetEx",value:function(s){delete this._worksheets[s.id]}},{key:"removeWorksheet",value:function(s){var m=this.getWorksheet(s);m&&m.destroy()}},{key:"getWorksheet",value:function(s){if(s===void 0)return this._worksheets.find(Boolean);if(typeof s=="number")return this._worksheets[s];if(typeof s=="string")return this._worksheets.find(function(m){return m&&m.name===s})}},{key:"eachSheet",value:function(s){this.worksheets.forEach(function(m){s(m,m.id)})}},{key:"clearThemes",value:function(){this._themes=void 0}},{key:"addImage",value:function(s){var m=this.media.length;return this.media.push(Object.assign({},s,{type:"image"})),m}},{key:"getImage",value:function(s){return this.media[s]}},{key:"xlsx",get:function(){return this._xlsx||(this._xlsx=new f(this)),this._xlsx}},{key:"csv",get:function(){return this._csv||(this._csv=new v(this)),this._csv}},{key:"nextId",get:function(){for(var s=1;sz.length)&&(D=z.length);for(var M=0,I=new Array(D);Mthis._columns.length)for(var T=this._columns.length+1;T<=M;)this._columns.push(new i(this,T++));return this._columns[M-1]}},{key:"spliceColumns",value:function(M,I){for(var T=this,C=this._rows,E=C.length,A=arguments.length,L=new Array(A>2?A-2:0),$=2;$0)for(var W=function(ye){var ge=[M,I];L.forEach(function(J){ge.push(J[ye]||null)});var oe=T.getRow(ye+1);oe.splice.apply(oe,ge)},U=0;U0)for(var re=F;re>=j;re--)this.getColumn(re+N).defn=this.getColumn(re).defn;for(var ee=M;ee1&&arguments[1]!==void 0?arguments[1]:"n",T=this._nextRow,C=this.getRow(T);return C.values=M,this._setStyleOption(T,I[0]==="i"?I:"n"),C}},{key:"addRows",value:function(M){var I=this,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n",C=[];return M.forEach(function(E){C.push(I.addRow(E,T))}),C}},{key:"insertRow",value:function(M,I){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";return this.spliceRows(M,0,I),this._setStyleOption(M,T),this.getRow(M)}},{key:"insertRows",value:function(M,I){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";if(this.spliceRows.apply(this,[M,0].concat(b(I))),T!=="n")for(var C=0;C1&&arguments[1]!==void 0?arguments[1]:"n";I[0]==="o"&&this.findRow(M+1)!==void 0?this._copyStyle(M+1,M,I[1]==="+"):I[0]==="i"&&this.findRow(M-1)!==void 0&&this._copyStyle(M-1,M,I[1]==="+")}},{key:"_copyStyle",value:function(M,I){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,C=this.getRow(M),E=this.getRow(I);E.style=Object.freeze(y({},C.style)),C.eachCell({includeEmpty:T},function(A,L){E.getCell(L).style=Object.freeze(y({},A.style))}),E.height=C.height}},{key:"duplicateRow",value:function(M,I){var T=this,C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,E=this._rows[M-1],A=new Array(I).fill(E.values);this.spliceRows.apply(this,[M+1,C?0:I].concat(b(A)));for(var L=function(U){var N=T._rows[M+U];N.style=E.style,N.height=E.height,E.eachCell({includeEmpty:!0},function(j,F){N.getCell(F).style=j.style})},$=0;$2?E-2:0),L=2;L0)for(N=U;N>=C;N--)j=this._rows[N-1],j?function(){var V=T.getRow(N+W);V.values=j.values,V.style=j.style,V.height=j.height,j.eachCell({includeEmpty:!0},function(re,ee){if(V.getCell(ee).style=re.style,re._value.constructor.name==="MergeValue"){var ce=T.getRow(re._row._number+$).getCell(ee),ye=re._value._master,ge=T.getRow(ye._row._number+$).getCell(ye._column._number);ce.merge(ge)}})}():this._rows[N+W-1]=void 0;for(N=0;N<$;N++){var F=this.getRow(M+N);F.style={},F.values=A[N]}this.workbook.definedNames.spliceRows(this.name,M,I,$)}},{key:"eachRow",value:function(M,I){if(I||(I=M,M=void 0),M&&M.includeEmpty)for(var T=this._rows.length,C=1;C<=T;C++)I(this.getRow(C),C);else this._rows.forEach(function(E){E&&E.hasValues&&I(E,E.number)})}},{key:"getSheetValues",value:function(){var M=[];return this._rows.forEach(function(I){I&&(M[I.number]=I.values)}),M}},{key:"findCell",value:function(M,I){var T=a.getAddress(M,I),C=this._rows[T.row-1];return C?C.findCell(T.col):void 0}},{key:"getCell",value:function(M,I){var T=a.getAddress(M,I),C=this.getRow(T.row);return C.getCellEx(T)}},{key:"mergeCells",value:function(){for(var M=arguments.length,I=new Array(M),T=0;TM.top||E>M.left)&&this.getCell(C,E).merge(T,I);this._merges[T.address]=M}},{key:"_unMergeMaster",value:function(M){var I=this._merges[M.address];if(I){for(var T=I.top;T<=I.bottom;T++)for(var C=I.left;C<=I.right;C++)this.getCell(T,C).unmerge();delete this._merges[M.address]}}},{key:"unMergeCells",value:function(){for(var M=arguments.length,I=new Array(M),T=0;T3&&arguments[3]!==void 0?arguments[3]:"shared",E=a.decode(M),A=E.top,L=E.left,$=E.bottom,W=E.right,U=W-L+1,N=a.encodeAddress(A,L),j=C==="shared",F;typeof T=="function"?F=T:Array.isArray(T)?Array.isArray(T[0])?F=function(ye,ge){return T[ye-A][ge-L]}:F=function(ye,ge){return T[(ye-A)*U+(ge-L)]}:F=function(){};for(var V=!0,re=A;re<=$;re++)for(var ee=L;ee<=W;ee++)V?(this.getCell(re,ee).value={shareType:C,formula:I,ref:M,result:F(re,ee)},V=!1):this.getCell(re,ee).value=j?{sharedFormula:N,result:F(re,ee)}:F(re,ee)}},{key:"addImage",value:function(M,I){var T={type:"image",imageId:M,range:I};this._media.push(new o(this,T))}},{key:"getImages",value:function(){return this._media.filter(function(M){return M.type==="image"})}},{key:"addBackgroundImage",value:function(M){var I={type:"background",imageId:M};this._media.push(new o(this,I))}},{key:"getBackgroundImageId",value:function(){var M=this._media.find(function(I){return I.type==="background"});return M&&M.imageId}},{key:"protect",value:function(M,I){var T=this;return new Promise(function(C){T.sheetProtection={sheet:!0},I&&"spinCount"in I&&(I.spinCount=Number.isFinite(I.spinCount)?Math.round(Math.max(0,I.spinCount)):1e5),M&&(T.sheetProtection.algorithmName="SHA-512",T.sheetProtection.saltValue=P.randomBytes(16).toString("base64"),T.sheetProtection.spinCount=I&&"spinCount"in I?I.spinCount:1e5,T.sheetProtection.hashValue=P.convertPasswordToHash(M,"SHA512",T.sheetProtection.saltValue,T.sheetProtection.spinCount)),I&&(T.sheetProtection=Object.assign(T.sheetProtection,I),!M&&"spinCount"in I&&delete T.sheetProtection.spinCount),C()})}},{key:"unprotect",value:function(){this.sheetProtection=null}},{key:"addTable",value:function(M){var I=new p(this,M);return this.tables[M.name]=I,I}},{key:"getTable",value:function(M){return this.tables[M]}},{key:"removeTable",value:function(M){delete this.tables[M]}},{key:"getTables",value:function(){return Object.values(this.tables)}},{key:"addConditionalFormatting",value:function(M){this.conditionalFormattings.push(M)}},{key:"removeConditionalFormatting",value:function(M){typeof M=="number"?this.conditionalFormattings.splice(M,1):M instanceof Function?this.conditionalFormattings=this.conditionalFormattings.filter(M):this.conditionalFormattings=[]}},{key:"_parseRows",value:function(M){var I=this;this._rows=[],M.rows.forEach(function(T){var C=new t(I,T.number);I._rows[C.number-1]=C,C.model=T})}},{key:"_parseMergeCells",value:function(M){var I=this;c.each(M.mergeCells,function(T){I.mergeCellsWithoutStyle(T)})}},{key:"workbook",get:function(){return this._workbook}},{key:"dimensions",get:function(){var M=new r;return this._rows.forEach(function(I){if(I){var T=I.dimensions;T&&M.expand(I.number,T.min,I.number,T.max)}}),M}},{key:"columns",get:function(){return this._columns},set:function(M){var I=this;this._headerRowCount=M.reduce(function(E,A){var L=A.header&&1||A.headers&&A.headers.length||0;return Math.max(E,L)},0);var T=1,C=this._columns=[];M.forEach(function(E){var A=new i(I,T++,!1);C.push(A),A.defn=E})}},{key:"lastColumn",get:function(){return this.getColumn(this.columnCount)}},{key:"columnCount",get:function(){var M=0;return this.eachRow(function(I){M=Math.max(M,I.cellCount)}),M}},{key:"actualColumnCount",get:function(){var M=[],I=0;return this.eachRow(function(T){T.eachCell(function(C){var E=C.col;M[E]||(M[E]=!0,I++)})}),I}},{key:"_lastRowNumber",get:function(){for(var M=this._rows,I=M.length;I>0&&M[I-1]===void 0;)I--;return I}},{key:"_nextRow",get:function(){return this._lastRowNumber+1}},{key:"lastRow",get:function(){if(this._rows.length)return this._rows[this._rows.length-1]}},{key:"rowCount",get:function(){return this._lastRowNumber}},{key:"actualRowCount",get:function(){var M=0;return this.eachRow(function(){M++}),M}},{key:"hasMerges",get:function(){return c.some(this._merges,Boolean)}},{key:"tabColor",get:function(){return console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor},set:function(M){console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor=M}},{key:"model",get:function(){var M={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(function(C){return C.model}),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(function(C){return C.model}),conditionalFormattings:this.conditionalFormattings};M.cols=i.toModel(this.columns);var I=M.rows=[],T=M.dimensions=new r;return this._rows.forEach(function(C){var E=C&&C.model;E&&(T.expand(E.number,E.min,E.number,E.max),I.push(E))}),M.merges=[],c.each(this._merges,function(C){M.merges.push(C.range)}),M},set:function(M){var I=this;this.name=M.name,this._columns=i.fromModel(this,M.cols),this._parseRows(M),this._parseMergeCells(M),this.dataValidations=new O(M.dataValidations),this.properties=M.properties,this.pageSetup=M.pageSetup,this.headerFooter=M.headerFooter,this.views=M.views,this.autoFilter=M.autoFilter,this._media=M.media.map(function(T){return new o(I,T)}),this.sheetProtection=M.sheetProtection,this.tables=M.tables.reduce(function(T,C){var E=new p;return E.model=C,T[C.name]=E,T},{}),this.conditionalFormattings=M.conditionalFormattings}}]),z}();S.exports=B},{"../utils/col-cache":19,"../utils/encryptor":20,"../utils/under-dash":25,"./column":4,"./data-validations":5,"./enums":7,"./image":8,"./range":10,"./row":11,"./table":12}],15:[function(e,S,_){e("core-js/modules/es.promise"),e("core-js/modules/es.object.assign"),e("core-js/modules/es.object.keys"),e("core-js/modules/es.object.values"),e("core-js/modules/es.symbol"),e("core-js/modules/es.symbol.async-iterator"),e("core-js/modules/es.array.iterator"),e("core-js/modules/es.array.includes"),e("core-js/modules/es.array.find-index"),e("core-js/modules/es.array.find"),e("core-js/modules/es.string.from-code-point"),e("core-js/modules/es.string.includes"),e("core-js/modules/es.number.is-nan"),e("regenerator-runtime/runtime");var u={Workbook:e("./doc/workbook")},y=e("./doc/enums");Object.keys(y).forEach(function(g){u[g]=y[g]}),S.exports=u},{"./doc/enums":7,"./doc/workbook":13,"core-js/modules/es.array.find":316,"core-js/modules/es.array.find-index":315,"core-js/modules/es.array.includes":317,"core-js/modules/es.array.iterator":318,"core-js/modules/es.number.is-nan":319,"core-js/modules/es.object.assign":320,"core-js/modules/es.object.keys":321,"core-js/modules/es.object.values":322,"core-js/modules/es.promise":323,"core-js/modules/es.string.from-code-point":324,"core-js/modules/es.string.includes":325,"core-js/modules/es.symbol":327,"core-js/modules/es.symbol.async-iterator":326,"regenerator-runtime/runtime":492}],16:[function(e,S,_){var u=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function y(g){return typeof g=="string"?g:u?u.decode(g):g.toString()}_.bufferToString=y},{}],17:[function(e,S,_){var u=typeof TextEncoder>"u"?null:new TextEncoder("utf-8"),y=e("buffer"),g=y.Buffer;function b(w){return typeof w!="string"?w:u?g.from(u.encode(w).buffer):g.from(w)}_.stringToBuffer=b},{buffer:216}],18:[function(e,S,_){function u(v,h){if(!(v instanceof h))throw new TypeError("Cannot call a class as a function")}function y(v,h){for(var l=0;lm.length)&&(c=m.length);for(var a=0,r=new Array(c);a"u"||!(Symbol.iterator in Object(m)))){var a=[],r=!0,t=!1,i=void 0;try{for(var n=m[Symbol.iterator](),o;!(r=(o=n.next()).done)&&(a.push(o.value),!(c&&a.length===c));r=!0);}catch(p){t=!0,i=p}finally{try{!r&&n.return!=null&&n.return()}finally{if(t)throw i}}return a}}function f(m){if(Array.isArray(m))return m}function v(m,c){var a=Object.keys(m);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);c&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(m,t).enumerable})),a.push.apply(a,r)}return a}function h(m){for(var c=1;c=4)throw new Error("Out of bounds. Excel supports columns from 1 to 16384");if(this._l2nFill<1&&c>=1){for(;o<=26;)a=this._dictionary[o-1],this._n2l[o]=a,this._l2n[a]=o,o++;this._l2nFill=1}if(this._l2nFill<2&&c>=2){for(o=27;o<=26+26*26;)r=o-(26+1),t=r%26,i=Math.floor(r/26),a=this._dictionary[i]+this._dictionary[t],this._n2l[o]=a,this._l2n[a]=o,o++;this._l2nFill=2}if(this._l2nFill<3&&c>=3){for(o=26+26*26+1;o<=16384;)r=o-(26*26+26+1),t=r%26,i=Math.floor(r/26)%26,n=Math.floor(r/(26*26)),a=this._dictionary[n]+this._dictionary[i]+this._dictionary[t],this._n2l[o]=a,this._l2n[a]=o,o++;this._l2nFill=3}},l2n:function(c){if(this._l2n[c]||this._fill(c.length),!this._l2n[c])throw new Error("Out of bounds. Invalid column letter: ".concat(c));return this._l2n[c]},n2l:function(c){if(c<1||c>16384)throw new Error("".concat(c," is out of bounds. Excel supports columns from 1 to 16384"));return this._n2l[c]||this._fill(this._level(c)),this._n2l[c]},_hash:{},validateAddress:function(c){if(!d.test(c))throw new Error("Invalid Address: ".concat(c));return!0},decodeAddress:function(c){var a=c.length<5&&this._hash[c];if(a)return a;for(var r=!1,t="",i=0,n=!1,o="",p=0,O=0,P;O=65&&P<=90)r=!0,t+=c[O],i=i*26+P-64;else if(P>=48&&P<=57)n=!0,o+=c[O],p=p*10+P-48;else if(n&&r&&P!==36)break;if(!r)i=void 0;else if(i>16384)throw new Error("Out of bounds. Invalid column letter: ".concat(t));n||(p=void 0),c=t+o;var B={address:c,col:i,row:p,$col$row:"$".concat(t,"$").concat(o)};return i<=100&&p<=100&&(this._hash[c]=B,this._hash[B.$col$row]=B),B},getAddress:function(c,a){if(a){var r=this.n2l(a)+c;return this.decodeAddress(r)}return this.decodeAddress(c)},decode:function(c){var a=c.split(":");if(a.length===2){var r=this.decodeAddress(a[0]),t=this.decodeAddress(a[1]),i={top:Math.min(r.row,t.row),left:Math.min(r.col,t.col),bottom:Math.max(r.row,t.row),right:Math.max(r.col,t.col)};return i.tl=this.n2l(i.left)+i.top,i.br=this.n2l(i.right)+i.bottom,i.dimensions="".concat(i.tl,":").concat(i.br),i}return this.decodeAddress(c)},decodeEx:function(c){var a=c.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/),r=a[1]||a[2],t=a[3],i=t.split(":");if(i.length>1){var n=this.decodeAddress(i[0]),o=this.decodeAddress(i[1]),p=Math.min(n.row,o.row),O=Math.min(n.col,o.col),P=Math.max(n.row,o.row),B=Math.max(n.col,o.col);return n=this.n2l(O)+p,o=this.n2l(B)+P,{top:p,left:O,bottom:P,right:B,sheetName:r,tl:{address:n,col:O,row:p,$col$row:"$".concat(this.n2l(O),"$").concat(p),sheetName:r},br:{address:o,col:B,row:P,$col$row:"$".concat(this.n2l(B),"$").concat(P),sheetName:r},dimensions:"".concat(n,":").concat(o)}}if(t.startsWith("#"))return r?{sheetName:r,error:t}:{error:t};var z=this.decodeAddress(t);return r?h({sheetName:r},z):z},encodeAddress:function(c,a){return s.n2l(a)+c},encode:function(){switch(arguments.length){case 2:return s.encodeAddress(arguments[0],arguments[1]);case 4:return"".concat(s.encodeAddress(arguments[0],arguments[1]),":").concat(s.encodeAddress(arguments[2],arguments[3]));default:throw new Error("Can only encode with 2 or 4 arguments")}},inRange:function(c,a){var r=u(c,5),t=r[0],i=r[1],n=r[3],o=r[4],p=u(a,2),O=p[0],P=p[1];return O>=t&&O<=n&&P>=i&&P<=o}};S.exports=s},{}],20:[function(e,S,_){(function(u){var y=e("crypto"),g={hash:function(w){for(var f=y.createHash(w),v=arguments.length,h=new Array(v>1?v-1:0),l=1;l3||i.length===3&&i>"XFD")return d;var p=u.l2n(i),O=parseInt(o,10);t||(p+=l.col-h.col),n||(O+=l.row-h.row);var P=(s||"")+(t||"")+u.n2l(p)+(n||"")+O;return P}return d})}S.exports={slideFormula:b}},{"./col-cache":19}],23:[function(e,S,_){(function(u,y){function g(t,i,n,o,p,O,P){try{var B=t[O](P),z=B.value}catch(D){n(D);return}B.done?i(z):Promise.resolve(z).then(o,p)}function b(t){return function(){var i=this,n=arguments;return new Promise(function(o,p){var O=t.apply(i,n);function P(z){g(O,o,p,P,B,"next",z)}function B(z){g(O,o,p,P,B,"throw",z)}P(void 0)})}}function w(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function f(t,i){for(var n=0;n=this.length?(o=this.toBuffer(),this.iRead=this.iWrite,o):(o=y.alloc(n),this.buffer.copy(o,0,this.iRead,n),this.iRead+=n,o)}},{key:"write",value:function(n,o,p){var O=Math.min(p,this.size-this.iWrite);return n.copy(this.buffer,this.iWrite,o,o+O),this.iWrite+=O,O}},{key:"length",get:function(){return this.iWrite-this.iRead}},{key:"eod",get:function(){return this.iRead===this.iWrite}},{key:"full",get:function(){return this.iWrite===this.size}}]),t}(),r=function(i){i=i||{},this.bufSize=i.bufSize||1024*1024,this.buffers=[],this.batch=i.batch||!1,this.corked=!1,this.inPos=0,this.outPos=0,this.pipes=[],this.paused=!1,this.encoding=null};l.inherits(r,h.Duplex,{toBuffer:function(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:return y.concat(this.buffers.map(function(i){return i.toBuffer()}))}},_getWritableBuffer:function(){if(this.buffers.length){var i=this.buffers[this.buffers.length-1];if(!i.full)return i}var n=new a(this.bufSize);return this.buffers.push(n),n},_pipe:function(i){var n=this;return b(regeneratorRuntime.mark(function o(){var p;return regeneratorRuntime.wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return p=function(z){return new Promise(function(D){z.write(i.toBuffer(),function(){D()})})},P.next=3,Promise.all(n.pipes.map(p));case 3:case"end":return P.stop()}},o)}))()},_writeToBuffers:function(i){for(var n=0,o=i.length;n1;)p._pipe(p.buffers.shift());z.next=29;break;case 21:if(p.corked){z.next=27;break}return z.next=24,p._pipe(P);case 24:o(),z.next=29;break;case 27:p._writeToBuffers(P),u.nextTick(o);case 29:z.next=34;break;case 31:p.paused||p.emit("data",P.toBuffer()),p._writeToBuffers(P),p.emit("readable");case 34:return z.abrupt("return",!0);case 35:case"end":return z.stop()}},O)}))()},cork:function(){this.corked=!0},_flush:function(){if(this.pipes.length)for(;this.buffers.length;)this._pipe(this.buffers.shift())},uncork:function(){this.corked=!1,this._flush()},end:function(i,n,o){var p=this,O=function(B){B?o(B):(p._flush(),p.pipes.forEach(function(z){z.end()}),p.emit("finish"))};i?this.write(i,n,O):O()},read:function(i){var n;if(i){for(n=[];i&&this.buffers.length&&!this.buffers[0].eod;){var o=this.buffers[0],p=o.read(i);i-=p.length,n.push(p),o.eod&&o.full&&this.buffers.shift()}return y.concat(n)}return n=this.buffers.map(function(O){return O.toBuffer()}).filter(Boolean),this.buffers=[],y.concat(n)},setEncoding:function(i){this.encoding=i},pause:function(){this.paused=!0},resume:function(){this.paused=!1},isPaused:function(){return!!this.paused},pipe:function(i){this.pipes.push(i),!this.paused&&this.buffers.length&&this.end()},unpipe:function(i){this.pipes=this.pipes.filter(function(n){return n!==i})},unshift:function(){throw new Error("Not Implemented")},wrap:function(){throw new Error("Not Implemented")}}),S.exports=r}).call(this,e("_process"),e("buffer").Buffer)},{"./string-buf":24,"./utils":26,_process:467,buffer:216,"readable-stream":491}],24:[function(e,S,_){(function(u){function y(f,v){if(!(f instanceof v))throw new TypeError("Cannot call a class as a function")}function g(f,v){for(var h=0;h=this._buf.length-4;)this._grow(this._inPos+h.length),l=this._inPos+this._buf.write(h,this._inPos,this._encoding);this._inPos=l}},{key:"addStringBuf",value:function(h){h.length&&(this._buffer=void 0,this.length+h.length>this.capacity&&this._grow(this.length+h.length),h._buf.copy(this._buf,this._inPos,0,h.length),this._inPos+=h.length)}},{key:"length",get:function(){return this._inPos}},{key:"capacity",get:function(){return this._buf.length}},{key:"buffer",get:function(){return this._buf}}]),f}();S.exports=w}).call(this,e("buffer").Buffer)},{buffer:216}],25:[function(e,S,_){function u(w){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(v){return typeof v}:u=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},u(w)}var y=Object.prototype.toString,g=/["&<>]/,b={each:function(f,v){f&&(Array.isArray(f)?f.forEach(v):Object.keys(f).forEach(function(h){v(f[h],h)}))},some:function(f,v){return f?Array.isArray(f)?f.some(v):Object.keys(f).some(function(h){return v(f[h],h)}):!1},every:function(f,v){return f?Array.isArray(f)?f.every(v):Object.keys(f).every(function(h){return v(f[h],h)}):!0},map:function(f,v){return f?Array.isArray(f)?f.map(v):Object.keys(f).map(function(h){return v(f[h],h)}):[]},keyBy:function(f,v){return f.reduce(function(h,l){return h[l[v]]=l,h},{})},isEqual:function(f,v){var h=u(f),l=u(v),d=Array.isArray(f),s=Array.isArray(v);if(h!==l)return!1;switch(u(f)){case"object":return d||s?d&&s?f.length===v.length&&f.every(function(m,c){var a=v[c];return b.isEqual(m,a)}):!1:b.every(f,function(m,c){var a=v[c];return b.isEqual(m,a)});default:return f===v}},escapeHtml:function(f){var v=g.exec(f);if(!v)return f;for(var h="",l="",d=0,s=v.index;s":l=">";break;default:continue}d!==s&&(h+=f.substring(d,s)),d=s+1,h+=l}return d!==s?h+f.substring(d,s):h},strcmp:function(f,v){return fv?1:0},isUndefined:function(f){return y.call(f)==="[object Undefined]"},isObject:function(f){return y.call(f)==="[object Object]"},deepMerge:function(){var f=arguments[0]||{},v=arguments.length,h,l,d;function s(c,a){h=f[a],d=Array.isArray(c),b.isObject(c)||d?(d?(d=!1,l=h&&Array.isArray(h)?h:[]):l=h&&b.isObject(h)?h:{},f[a]=b.deepMerge(l,c)):b.isUndefined(c)||(f[a]=c)}for(var m=0;m&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/,f={nop:function(){},promiseImmediate:function(h){return new Promise(function(l){u.setImmediate?y(function(){l(h)}):setTimeout(function(){l(h)},1)})},inherits:b,dateToExcel:function(h,l){return 25569+h.getTime()/(24*3600*1e3)-(l?1462:0)},excelToDate:function(h,l){var d=Math.round((h-25569+(l?1462:0))*24*3600*1e3);return new Date(d)},parsePath:function(h){var l=h.lastIndexOf("/");return{path:h.substring(0,l),name:h.substring(l+1)}},getRelsPath:function(h){var l=f.parsePath(h);return"".concat(l.path,"/_rels/").concat(l.name,".rels")},xmlEncode:function(h){var l=w.exec(h);if(!l)return h;for(var d="",s="",m=0,c=l.index;c=11&&a!==13)){s="";break}continue}}m!==c&&(d+=h.substring(m,c)),m=c+1,s&&(d+=s)}return m!==c?d+h.substring(m,c):d},xmlDecode:function(h){return h.replace(/&([a-z]*);/g,function(l){switch(l){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case""":return'"';default:return l}})},validInt:function(h){var l=parseInt(h,10);return Number.isNaN(l)?0:l},isDateFmt:function(h){if(!h)return!1;h=h.replace(/\[[^\]]*]/g,""),h=h.replace(/"[^"]*"/g,"");var l=h.match(/[ymdhMsb]+/)!==null;return l},fs:{exists:function(h){return new Promise(function(l){g.access(h,g.constants.F_OK,function(d){l(!d)})})}},toIsoDateString:function(h){return h.toIsoString().subsstr(0,10)}};S.exports=f}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{},e("timers").setImmediate)},{fs:215,timers:521}],27:[function(e,S,_){function u(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function y(t,i){for(var n=0;n",h="",d='="',s='"',m=" ";function c(t,i,n){t.push(m),t.push(i),t.push(d),t.push(w.xmlEncode(n.toString())),t.push(s)}function a(t,i){i&&b.each(i,function(n,o){n!==void 0&&c(t,o,n)})}var r=function(){function t(){u(this,t),this._xml=[],this._stack=[],this._rollbacks=[]}return g(t,[{key:"openXml",value:function(n){var o=this._xml;o.push(" -`)}},{key:"openNode",value:function(n,o){var p=this.tos,O=this._xml;p&&this.open&&O.push(v),this._stack.push(n),O.push(f),O.push(n),a(O,o),this.leaf=!0,this.open=!0}},{key:"addAttribute",value:function(n,o){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");o!==void 0&&c(this._xml,n,o)}},{key:"addAttributes",value:function(n){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");a(this._xml,n)}},{key:"writeText",value:function(n){var o=this._xml;this.open&&(o.push(v),this.open=!1),this.leaf=!1,o.push(w.xmlEncode(n.toString()))}},{key:"writeXml",value:function(n){this.open&&(this._xml.push(v),this.open=!1),this.leaf=!1,this._xml.push(n)}},{key:"closeNode",value:function(){var n=this._stack.pop(),o=this._xml;this.leaf?o.push(l):(o.push(h),o.push(n),o.push(v)),this.open=!1,this.leaf=!1}},{key:"leafNode",value:function(n,o,p){this.openNode(n,o),p!==void 0&&this.writeText(p),this.closeNode()}},{key:"closeAll",value:function(){for(;this._stack.length;)this.closeNode()}},{key:"addRollback",value:function(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}},{key:"commit",value:function(){this._rollbacks.pop()}},{key:"rollback",value:function(){var n=this._rollbacks.pop();this._xml.length>n.xml&&this._xml.splice(n.xml,this._xml.length-n.xml),this._stack.length>n.stack&&this._stack.splice(n.stack,this._stack.length-n.stack),this.leaf=n.leaf,this.open=n.open}},{key:"tos",get:function(){return this._stack.length?this._stack[this._stack.length-1]:void 0}},{key:"cursor",get:function(){return this._xml.length}},{key:"xml",get:function(){return this.closeAll(),this._xml.join("")}}]),t}();r.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"},S.exports=r},{"./under-dash":25,"./utils":26}],28:[function(e,S,_){(function(u){function y(O){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(B){return typeof B}:y=function(B){return B&&typeof Symbol=="function"&&B.constructor===Symbol&&B!==Symbol.prototype?"symbol":typeof B},y(O)}function g(O,P,B,z,D,M,I){try{var T=O[M](I),C=T.value}catch(E){B(E);return}T.done?P(C):Promise.resolve(C).then(z,D)}function b(O){return function(){var P=this,B=arguments;return new Promise(function(z,D){var M=O.apply(P,B);function I(C){g(M,z,D,I,T,"next",C)}function T(C){g(M,z,D,I,T,"throw",C)}I(void 0)})}}function w(O,P){if(!(O instanceof P))throw new TypeError("Cannot call a class as a function")}function f(O,P){for(var B=0;B"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(O){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(B){return B.__proto__||Object.getPrototypeOf(B)},a(O)}var r=e("events"),t=e("jszip"),i=e("./stream-buf"),n=e("./browser-buffer-encode"),o=n.stringToBuffer,p=function(O){h(B,O);var P=d(B);function B(z){var D;return w(this,B),D=P.call(this),D.options=Object.assign({type:"nodebuffer",compression:"DEFLATE"},z),D.zip=new t,D.stream=new i,D}return v(B,[{key:"append",value:function(D,M){M.hasOwnProperty("base64")&&M.base64?this.zip.file(M.name,D,{base64:!0}):(u.browser&&typeof D=="string"&&(D=o(D)),this.zip.file(M.name,D))}},{key:"finalize",value:function(){var z=b(regeneratorRuntime.mark(function M(){var I;return regeneratorRuntime.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,this.zip.generateAsync(this.options);case 2:I=C.sent,this.stream.end(I),this.emit("finish");case 5:case"end":return C.stop()}},M,this)}));function D(){return z.apply(this,arguments)}return D}()},{key:"read",value:function(D){return this.stream.read(D)}},{key:"setEncoding",value:function(D){return this.stream.setEncoding(D)}},{key:"pause",value:function(){return this.stream.pause()}},{key:"resume",value:function(){return this.stream.resume()}},{key:"isPaused",value:function(){return this.stream.isPaused()}},{key:"pipe",value:function(D,M){return this.stream.pipe(D,M)}},{key:"unpipe",value:function(D){return this.stream.unpipe(D)}},{key:"unshift",value:function(D){return this.stream.unshift(D)}},{key:"wrap",value:function(D){return this.stream.wrap(D)}}]),B}(r.EventEmitter);S.exports={ZipWriter:p}}).call(this,e("_process"))},{"./browser-buffer-encode":17,"./stream-buf":23,_process:467,events:367,jszip:399}],29:[function(e,S,_){S.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"}}},{}],30:[function(e,S,_){S.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"}},{}],31:[function(e,S,_){function u(c,a){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=y(c))||a&&c&&typeof c.length=="number"){r&&(c=r);var t=0,i=function(){};return{s:i,n:function(){return t>=c.length?{done:!0}:{done:!1,value:c[t++]}},e:function(P){throw P},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var P=r.next();return n=P.done,P},e:function(P){o=!0,p=P},f:function(){try{!n&&r.return!=null&&r.return()}finally{if(o)throw p}}}}function y(c,a){if(c){if(typeof c=="string")return g(c,a);var r=Object.prototype.toString.call(c).slice(8,-1);if(r==="Object"&&c.constructor&&(r=c.constructor.name),r==="Map"||r==="Set")return Array.from(c);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(c,a)}}function g(c,a){(a==null||a>c.length)&&(a=c.length);for(var r=0,t=new Array(a);r2&&arguments[2]!==void 0?arguments[2]:!1;if(r===void 0){if(i)return t}else if(i||r!==t)return r.toString()}},{key:"toStringAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return c.toAttribute(r,t,i)}},{key:"toStringValue",value:function(r,t){return r===void 0?t:r}},{key:"toBoolAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(r===void 0){if(i)return t}else if(i||r!==t)return r?"1":"0"}},{key:"toBoolValue",value:function(r,t){return r===void 0?t:r==="1"}},{key:"toIntAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return c.toAttribute(r,t,i)}},{key:"toIntValue",value:function(r,t){return r===void 0?t:parseInt(r,10)}},{key:"toFloatAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return c.toAttribute(r,t,i)}},{key:"toFloatValue",value:function(r,t){return r===void 0?t:parseFloat(r)}}]),c}();S.exports=m},{"../../utils/parse-sax":21,"../../utils/xml-stream":27}],32:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../base-xform"),c=e("../../../utils/col-cache"),a=function(i){w(o,i);var n=v(o);function o(){return y(this,o),n.apply(this,arguments)}return b(o,[{key:"render",value:function(O,P){O.openNode("definedName",{name:P.name,localSheetId:P.localSheetId}),O.writeText(P.ranges.join(",")),O.closeNode()}},{key:"parseOpen",value:function(O){switch(O.name){case"definedName":return this._parsedName=O.attributes.name,this._parsedLocalSheetId=O.attributes.localSheetId,this._parsedText=[],!0;default:return!1}}},{key:"parseText",value:function(O){this._parsedText.push(O)}},{key:"parseClose",value:function(){return this.model={name:this._parsedName,ranges:t(this._parsedText.join(""))},this._parsedLocalSheetId!==void 0&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}}]),o}(m);function r(i){try{return c.decodeEx(i),!0}catch{return!1}}function t(i){var n=[],o=!1,p="";return i.split(",").forEach(function(O){if(O){var P=(O.match(/'/g)||[]).length;if(!P){o?p+="".concat(O,","):r(O)&&n.push(O);return}var B=P%2===0;!o&&B&&r(O)?n.push(O):o&&!B?(o=!1,r(p+O)&&n.push(p+O),p=""):(o=!0,p+="".concat(O,","))}}),n}S.exports=a},{"../../../utils/col-cache":19,"../base-xform":31}],33:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/utils"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){o.leafNode("sheet",{sheetId:p.id,name:p.name,state:p.state,"r:id":p.rId})}},{key:"parseOpen",value:function(o){return o.name==="sheet"?(this.model={name:m.xmlDecode(o.attributes.name),id:parseInt(o.attributes.sheetId,10),state:o.attributes.state,rId:o.attributes["r:id"]},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),i}(c);S.exports=a},{"../../../utils/utils":26,"../base-xform":31}],34:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("calcPr",{calcId:171027,fullCalcOnLoad:o.fullCalcOnLoad?1:void 0})}},{key:"parseOpen",value:function(n){return n.name==="calcPr"?(this.model={},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],35:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("workbookPr",{date1904:o.date1904?1:void 0,defaultThemeVersion:164011,filterPrivacy:1})}},{key:"parseOpen",value:function(n){return n.name==="workbookPr"?(this.model={date1904:n.attributes.date1904==="1"},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],36:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){var p={xWindow:o.x||0,yWindow:o.y||0,windowWidth:o.width||12e3,windowHeight:o.height||24e3,firstSheet:o.firstSheet,activeTab:o.activeTab};o.visibility&&o.visibility!=="visible"&&(p.visibility=o.visibility),n.leafNode("workbookView",p)}},{key:"parseOpen",value:function(n){if(n.name==="workbookView"){var o=this.model={},p=function(B,z,D){var M=z!==void 0?o[B]=z:D;M!==void 0&&(o[B]=M)},O=function(B,z,D){var M=z!==void 0?o[B]=parseInt(z,10):D;M!==void 0&&(o[B]=M)};return O("x",n.attributes.xWindow,0),O("y",n.attributes.yWindow,0),O("width",n.attributes.windowWidth,25e3),O("height",n.attributes.windowHeight,1e4),p("visibility",n.attributes.visibility,"visible"),O("activeTab",n.attributes.activeTab,void 0),O("firstSheet",n.attributes.firstSheet,void 0),!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],37:[function(e,S,_){function u(z){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(M){return typeof M}:u=function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},u(z)}function y(z,D){if(!(z instanceof D))throw new TypeError("Cannot call a class as a function")}function g(z,D){for(var M=0;M"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(z){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(M){return M.__proto__||Object.getPrototypeOf(M)},s(z)}var m=e("../../../utils/under-dash"),c=e("../../../utils/col-cache"),a=e("../../../utils/xml-stream"),r=e("../base-xform"),t=e("../static-xform"),i=e("../list-xform"),n=e("./defined-name-xform"),o=e("./sheet-xform"),p=e("./workbook-view-xform"),O=e("./workbook-properties-xform"),P=e("./workbook-calc-properties-xform"),B=function(z){w(M,z);var D=v(M);function M(){var I;return y(this,M),I=D.call(this),I.map={fileVersion:M.STATIC_XFORMS.fileVersion,workbookPr:new O,bookViews:new i({tag:"bookViews",count:!1,childXform:new p}),sheets:new i({tag:"sheets",count:!1,childXform:new o}),definedNames:new i({tag:"definedNames",count:!1,childXform:new n}),calcPr:new P},I}return b(M,[{key:"prepare",value:function(T){T.sheets=T.worksheets;var C=[],E=0;T.sheets.forEach(function(A){if(A.pageSetup&&A.pageSetup.printArea&&A.pageSetup.printArea.split("&&").forEach(function(N){var j=N.split(":"),F={name:"_xlnm.Print_Area",ranges:["'".concat(A.name,"'!$").concat(j[0],":$").concat(j[1])],localSheetId:E};C.push(F)}),A.pageSetup&&(A.pageSetup.printTitlesRow||A.pageSetup.printTitlesColumn)){var L=[];if(A.pageSetup.printTitlesColumn){var $=A.pageSetup.printTitlesColumn.split(":");L.push("'".concat(A.name,"'!$").concat($[0],":$").concat($[1]))}if(A.pageSetup.printTitlesRow){var W=A.pageSetup.printTitlesRow.split(":");L.push("'".concat(A.name,"'!$").concat(W[0],":$").concat(W[1]))}var U={name:"_xlnm.Print_Titles",ranges:L,localSheetId:E};C.push(U)}E++}),C.length&&(T.definedNames=T.definedNames.concat(C)),(T.media||[]).forEach(function(A,L){A.name=A.type+(L+1)})}},{key:"render",value:function(T,C){T.openXml(a.StdDocAttributes),T.openNode("workbook",M.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(T),this.map.workbookPr.render(T,C.properties),this.map.bookViews.render(T,C.views),this.map.sheets.render(T,C.sheets),this.map.definedNames.render(T,C.definedNames),this.map.calcPr.render(T,C.calcProperties),T.closeNode()}},{key:"parseOpen",value:function(T){if(this.parser)return this.parser.parseOpen(T),!0;switch(T.name){case"workbook":return!0;default:return this.parser=this.map[T.name],this.parser&&this.parser.parseOpen(T),!0}}},{key:"parseText",value:function(T){this.parser&&this.parser.parseText(T)}},{key:"parseClose",value:function(T){if(this.parser)return this.parser.parseClose(T)||(this.parser=void 0),!0;switch(T){case"workbook":return 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;default:return!0}}},{key:"reconcile",value:function(T){var C=(T.workbookRels||[]).reduce(function(W,U){return W[U.Id]=U,W},{}),E=[],A,L=0;(T.sheets||[]).forEach(function(W){var U=C[W.rId];U&&(A=T.worksheetHash["xl/".concat(U.Target.replace(/^(\s|\/xl\/)+/,""))],A&&(A.name=W.name,A.id=W.id,A.state=W.state,E[L++]=A))});var $=[];m.each(T.definedNames,function(W){if(W.name==="_xlnm.Print_Area"){if(A=E[W.localSheetId],A){A.pageSetup||(A.pageSetup={});var U=c.decodeEx(W.ranges[0]);A.pageSetup.printArea=A.pageSetup.printArea?"".concat(A.pageSetup.printArea,"&&").concat(U.dimensions):U.dimensions}}else if(W.name==="_xlnm.Print_Titles"){if(A=E[W.localSheetId],A){A.pageSetup||(A.pageSetup={});var N=W.ranges.join(","),j=/\$/g,F=/\$\d+:\$\d+/,V=N.match(F);if(V&&V.length){var re=V[0];A.pageSetup.printTitlesRow=re.replace(j,"")}var ee=/\$[A-Z]+:\$[A-Z]+/,ce=N.match(ee);if(ce&&ce.length){var ye=ce[0];A.pageSetup.printTitlesColumn=ye.replace(j,"")}}}else $.push(W)}),T.definedNames=$,T.media.forEach(function(W,U){W.index=U})}}]),M}(r);B.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"},B.STATIC_XFORMS={fileVersion:new t({tag:"fileVersion",$:{appName:"xl",lastEdited:5,lowestEdited:5,rupBuild:9303}})},S.exports=B},{"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"../static-xform":119,"./defined-name-xform":32,"./sheet-xform":33,"./workbook-calc-properties-xform":34,"./workbook-properties-xform":35,"./workbook-view-xform":36}],38:[function(e,S,_){function u(h,l){var d=Object.keys(h);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(h);l&&(s=s.filter(function(m){return Object.getOwnPropertyDescriptor(h,m).enumerable})),d.push.apply(d,s)}return d}function y(h){for(var l=1;l"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n._model=i,n}return b(t,[{key:"render",value:function(n,o,p){o===p[2]?n.leafNode(this.tag):this.tag==="x:SizeWithCells"&&o===p[1]&&n.leafNode(this.tag)}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={},this.model[this.tag]=!0,!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return this._model&&this._model.tag}}]),t}(m);S.exports=c},{"../../base-xform":31}],41:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n._model=i,n}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.text="",!0;default:return!1}}},{key:"parseText",value:function(n){this.text=n}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return this._model&&this._model.tag}}]),t}(m);S.exports=c},{"../../base-xform":31}],42:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"getAnchorRect",value:function(n){var o=Math.floor(n.left),p=Math.floor((n.left-o)*68),O=Math.floor(n.top),P=Math.floor((n.top-O)*18),B=Math.floor(n.right),z=Math.floor((n.right-B)*68),D=Math.floor(n.bottom),M=Math.floor((n.bottom-D)*18);return[o,p,O,P,B,z,D,M]}},{key:"getDefaultRect",value:function(n){var o=n.col,p=6,O=Math.max(n.row-2,0),P=14,B=o+2,z=2,D=O+4,M=16;return[o,p,O,P,B,z,D,M]}},{key:"render",value:function(n,o){var p=o.anchor?this.getAnchorRect(o.anchor):this.getDefaultRect(o.refAddress);n.leafNode("x:Anchor",null,p.join(", "))}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.text="",!0;default:return!1}}},{key:"parseText",value:function(n){this.text=n}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"x:Anchor"}}]),t}(m);S.exports=c},{"../base-xform":31}],43:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../base-xform"),c=e("./vml-anchor-xform"),a=e("./style/vml-protection-xform"),r=e("./style/vml-position-xform"),t=["twoCells","oneCells","absolute"],i=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={"x:Anchor":new c,"x:Locked":new a({tag:"x:Locked"}),"x:LockText":new a({tag:"x:LockText"}),"x:SizeWithCells":new r({tag:"x:SizeWithCells"}),"x:MoveWithCells":new r({tag:"x:MoveWithCells"})},O}return b(p,[{key:"render",value:function(P,B){var z=B.note,D=z.protection,M=z.editAs;P.openNode(this.tag,{ObjectType:"Note"}),this.map["x:MoveWithCells"].render(P,M,t),this.map["x:SizeWithCells"].render(P,M,t),this.map["x:Anchor"].render(P,B),this.map["x:Locked"].render(P,D.locked),P.leafNode("x:AutoFill",null,"False"),this.map["x:LockText"].render(P,D.lockText),P.leafNode("x:Row",null,B.refAddress.row-1),P.leafNode("x:Column",null,B.refAddress.col-1),P.closeNode()}},{key:"parseOpen",value:function(P){switch(P.name){case this.tag:this.reset(),this.model={anchor:[],protection:{},editAs:""};break;default:this.parser=this.map[P.name],this.parser&&this.parser.parseOpen(P);break}return!0}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){case this.tag:return this.normalizeModel(),!1;default:return!0}}},{key:"normalizeModel",value:function(){var P=Object.assign({},this.map["x:MoveWithCells"].model,this.map["x:SizeWithCells"].model),B=Object.keys(P).length;this.model.editAs=t[B],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}},{key:"tag",get:function(){return"x:ClientData"}}]),p}(m);S.exports=i},{"../base-xform":31,"./style/vml-position-xform":40,"./style/vml-protection-xform":41,"./vml-anchor-xform":42}],44:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("./vml-shape-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"v:shape":new a},o}return b(n,[{key:"render",value:function(p,O){var P=this;p.openXml(m.StdDocAttributes),p.openNode(this.tag,n.DRAWING_ATTRIBUTES),p.openNode("o:shapelayout",{"v:ext":"edit"}),p.leafNode("o:idmap",{"v:ext":"edit",data:1}),p.closeNode(),p.openNode("v:shapetype",{id:"_x0000_t202",coordsize:"21600,21600","o:spt":202,path:"m,l,21600r21600,l21600,xe"}),p.leafNode("v:stroke",{joinstyle:"miter"}),p.leafNode("v:path",{gradientshapeok:"t","o:connecttype":"rect"}),p.closeNode(),O.comments.forEach(function(B,z){P.map["v:shape"].render(p,B,z)}),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset(),this.model={comments:[]};break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.model.comments.push(this.parser.model),this.parser=void 0),!0;switch(p){case this.tag:return!1;default:return!0}}},{key:"reconcile",value:function(p,O){var P=this;p.anchors.forEach(function(B){B.br?P.map["xdr:twoCellAnchor"].reconcile(B,O):P.map["xdr:oneCellAnchor"].reconcile(B,O)})}},{key:"tag",get:function(){return"xml"}}]),n}(c);r.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"},S.exports=r},{"../../../utils/xml-stream":27,"../base-xform":31,"./vml-shape-xform":45}],45:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./vml-textbox-xform"),a=e("./vml-client-data-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"v:textbox":new c,"x:ClientData":new a},o}return b(n,[{key:"render",value:function(p,O,P){p.openNode("v:shape",n.V_SHAPE_ATTRIBUTES(O,P)),p.leafNode("v:fill",{color2:"infoBackground [80]"}),p.leafNode("v:shadow",{color:"none [81]",obscured:"t"}),p.leafNode("v:path",{"o:connecttype":"none"}),this.map["v:textbox"].render(p,O),this.map["x:ClientData"].render(p,O),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset(),this.model={margins:{insetmode:p.attributes["o:insetmode"]},anchor:"",editAs:"",protection:{}};break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.parser=void 0),!0;switch(p){case this.tag:return 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;default:return!0}}},{key:"tag",get:function(){return"v:shape"}}]),n}(m);r.V_SHAPE_ATTRIBUTES=function(t,i){return{id:"_x0000_s".concat(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":t.note.margins&&t.note.margins.insetmode}},S.exports=r},{"../base-xform":31,"./vml-client-data-xform":43,"./vml-textbox-xform":46}],46:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"conversionUnit",value:function(n,o,p){return"".concat(parseFloat(n)*o.toFixed(2)).concat(p)}},{key:"reverseConversionUnit",value:function(n){var o=this;return(n||"").split(",").map(function(p){return Number(parseFloat(o.conversionUnit(parseFloat(p),.1,"")).toFixed(2))})}},{key:"render",value:function(n,o){var p=this,O={style:"mso-direction-alt:auto"};if(o&&o.note){var P=o.note&&o.note.margins,B=P.inset;Array.isArray(B)&&(B=B.map(function(z){return p.conversionUnit(z,10,"mm")}).join(",")),B&&(O.inset=B)}n.openNode("v:textbox",O),n.leafNode("div",{style:"text-align:left"}),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={inset:this.reverseConversionUnit(n.attributes.inset)},!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"v:textbox"}}]),t}(m);S.exports=c},{"../base-xform":31}],47:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("./base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"createNewModel",value:function(n){return{}}},{key:"parseOpen",value:function(n){return this.parser=this.parser||this.map[n.name],this.parser?(this.parser.parseOpen(n),!0):n.name===this.tag?(this.model=this.createNewModel(n),!0):!1}},{key:"parseText",value:function(n){this.parser&&this.parser.parseText(n)}},{key:"onParserClose",value:function(n,o){this.model[n]=o.model}},{key:"parseClose",value:function(n){return this.parser?(this.parser.parseClose(n)||(this.onParserClose(n,this.parser),this.parser=void 0),!0):n!==this.tag}}]),t}(m);S.exports=c},{"./base-xform":31}],48:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.openNode("HeadingPairs"),n.openNode("vt:vector",{size:2,baseType:"variant"}),n.openNode("vt:variant"),n.leafNode("vt:lpstr",void 0,"Worksheets"),n.closeNode(),n.openNode("vt:variant"),n.leafNode("vt:i4",void 0,o.length),n.closeNode(),n.closeNode(),n.closeNode()}},{key:"parseOpen",value:function(n){return n.name==="HeadingPairs"}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){return n!=="HeadingPairs"}}]),t}(m);S.exports=c},{"../base-xform":31}],49:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.openNode("TitlesOfParts"),n.openNode("vt:vector",{size:o.length,baseType:"lpstr"}),o.forEach(function(p){n.leafNode("vt:lpstr",void 0,p.name)}),n.closeNode(),n.closeNode()}},{key:"parseOpen",value:function(n){return n.name==="TitlesOfParts"}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){return n!=="TitlesOfParts"}}]),t}(m);S.exports=c},{"../base-xform":31}],50:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("../simple/string-xform"),r=e("./app-heading-pairs-xform"),t=e("./app-titles-of-parts-xform"),i=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={Company:new a({tag:"Company"}),Manager:new a({tag:"Manager"}),HeadingPairs:new r,TitleOfParts:new t},O}return b(p,[{key:"render",value:function(P,B){P.openXml(m.StdDocAttributes),P.openNode("Properties",p.PROPERTY_ATTRIBUTES),P.leafNode("Application",void 0,"Microsoft Excel"),P.leafNode("DocSecurity",void 0,"0"),P.leafNode("ScaleCrop",void 0,"false"),this.map.HeadingPairs.render(P,B.worksheets),this.map.TitleOfParts.render(P,B.worksheets),this.map.Company.render(P,B.company||""),this.map.Manager.render(P,B.manager),P.leafNode("LinksUpToDate",void 0,"false"),P.leafNode("SharedDoc",void 0,"false"),P.leafNode("HyperlinksChanged",void 0,"false"),P.leafNode("AppVersion",void 0,"16.0300"),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"Properties":return!0;default:return this.parser=this.map[P.name],this.parser?(this.parser.parseOpen(P),!0):!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){case"Properties":return this.model={worksheets:this.map.TitleOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1;default:return!0}}}]),p}(c);i.DateFormat=function(n){return n.toISOString().replace(/[.]\d{3,6}/,"")},i.DateAttrs={"xsi:type":"dcterms:W3CDTF"},i.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties","xmlns:vt":"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"},S.exports=i},{"../../../utils/xml-stream":27,"../base-xform":31,"../simple/string-xform":118,"./app-heading-pairs-xform":48,"./app-titles-of-parts-xform":49}],51:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){o.openXml(m.StdDocAttributes),o.openNode("Types",i.PROPERTY_ATTRIBUTES);var O={};(p.media||[]).forEach(function(B){if(B.type==="image"){var z=B.extension;O[z]||(O[z]=!0,o.leafNode("Default",{Extension:z,ContentType:"image/".concat(z)}))}}),o.leafNode("Default",{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}),o.leafNode("Default",{Extension:"xml",ContentType:"application/xml"}),o.leafNode("Override",{PartName:"/xl/workbook.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"}),p.worksheets.forEach(function(B){var z="/xl/worksheets/sheet".concat(B.id,".xml");o.leafNode("Override",{PartName:z,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"})}),o.leafNode("Override",{PartName:"/xl/theme/theme1.xml",ContentType:"application/vnd.openxmlformats-officedocument.theme+xml"}),o.leafNode("Override",{PartName:"/xl/styles.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"});var P=p.sharedStrings&&p.sharedStrings.count;P&&o.leafNode("Override",{PartName:"/xl/sharedStrings.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"}),p.tables&&p.tables.forEach(function(B){o.leafNode("Override",{PartName:"/xl/tables/".concat(B.target),ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"})}),p.drawings&&p.drawings.forEach(function(B){o.leafNode("Override",{PartName:"/xl/drawings/".concat(B.name,".xml"),ContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})}),p.commentRefs&&(o.leafNode("Default",{Extension:"vml",ContentType:"application/vnd.openxmlformats-officedocument.vmlDrawing"}),p.commentRefs.forEach(function(B){var z=B.commentName;o.leafNode("Override",{PartName:"/xl/".concat(z,".xml"),ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"})})),o.leafNode("Override",{PartName:"/docProps/core.xml",ContentType:"application/vnd.openxmlformats-package.core-properties+xml"}),o.leafNode("Override",{PartName:"/docProps/app.xml",ContentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml"}),o.closeNode()}},{key:"parseOpen",value:function(){return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),i}(c);a.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"},S.exports=a},{"../../../utils/xml-stream":27,"../base-xform":31}],52:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("../simple/date-xform"),r=e("../simple/string-xform"),t=e("../simple/integer-xform"),i=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={"dc:creator":new r({tag:"dc:creator"}),"dc:title":new r({tag:"dc:title"}),"dc:subject":new r({tag:"dc:subject"}),"dc:description":new r({tag:"dc:description"}),"dc:identifier":new r({tag:"dc:identifier"}),"dc:language":new r({tag:"dc:language"}),"cp:keywords":new r({tag:"cp:keywords"}),"cp:category":new r({tag:"cp:category"}),"cp:lastModifiedBy":new r({tag:"cp:lastModifiedBy"}),"cp:lastPrinted":new a({tag:"cp:lastPrinted",format:p.DateFormat}),"cp:revision":new t({tag:"cp:revision"}),"cp:version":new r({tag:"cp:version"}),"cp:contentStatus":new r({tag:"cp:contentStatus"}),"cp:contentType":new r({tag:"cp:contentType"}),"dcterms:created":new a({tag:"dcterms:created",attrs:p.DateAttrs,format:p.DateFormat}),"dcterms:modified":new a({tag:"dcterms:modified",attrs:p.DateAttrs,format:p.DateFormat})},O}return b(p,[{key:"render",value:function(P,B){P.openXml(m.StdDocAttributes),P.openNode("cp:coreProperties",p.CORE_PROPERTY_ATTRIBUTES),this.map["dc:creator"].render(P,B.creator),this.map["dc:title"].render(P,B.title),this.map["dc:subject"].render(P,B.subject),this.map["dc:description"].render(P,B.description),this.map["dc:identifier"].render(P,B.identifier),this.map["dc:language"].render(P,B.language),this.map["cp:keywords"].render(P,B.keywords),this.map["cp:category"].render(P,B.category),this.map["cp:lastModifiedBy"].render(P,B.lastModifiedBy),this.map["cp:lastPrinted"].render(P,B.lastPrinted),this.map["cp:revision"].render(P,B.revision),this.map["cp:version"].render(P,B.version),this.map["cp:contentStatus"].render(P,B.contentStatus),this.map["cp:contentType"].render(P,B.contentType),this.map["dcterms:created"].render(P,B.created),this.map["dcterms:modified"].render(P,B.modified),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"cp:coreProperties":case"coreProperties":return!0;default:if(this.parser=this.map[P.name],this.parser)return this.parser.parseOpen(P),!0;throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(P)))}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){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: ".concat(P))}}}]),p}(c);i.DateFormat=function(n){return n.toISOString().replace(/[.]\d{3}/,"")},i.DateAttrs={"xsi:type":"dcterms:W3CDTF"},i.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"},S.exports=i},{"../../../utils/xml-stream":27,"../base-xform":31,"../simple/date-xform":116,"../simple/integer-xform":117,"../simple/string-xform":118}],53:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("Relationship",o)}},{key:"parseOpen",value:function(n){switch(n.name){case"Relationship":return this.model=n.attributes,!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],54:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("./relationship-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={Relationship:new a},o}return b(n,[{key:"render",value:function(p,O){var P=this;O=O||this._values,p.openXml(m.StdDocAttributes),p.openNode("Relationships",n.RELATIONSHIPS_ATTRIBUTES),O.forEach(function(B){P.map.Relationship.render(p,B)}),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"Relationships":return this.model=[],!0;default:if(this.parser=this.map[p.name],this.parser)return this.parser.parseOpen(p),!0;throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(p)))}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.model.push(this.parser.model),this.parser=void 0),!0;switch(p){case"Relationships":return!1;default:throw new Error("Unexpected xml node in parseClose: ".concat(p))}}}]),n}(c);r.RELATIONSHIPS_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},S.exports=r},{"../../../utils/xml-stream":27,"../base-xform":31,"./relationship-xform":53}],55:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"parseOpen",value:function(n){if(this.parser)return this.parser.parseOpen(n),!0;switch(n.name){case this.tag:this.reset(),this.model={range:{editAs:n.attributes.editAs||"oneCell"}};break;default:this.parser=this.map[n.name],this.parser&&this.parser.parseOpen(n);break}return!0}},{key:"parseText",value:function(n){this.parser&&this.parser.parseText(n)}},{key:"reconcilePicture",value:function(n,o){if(n&&n.rId){var p=o.rels[n.rId],O=p.Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(O){var P=O[1],B=o.mediaIndex[P];return o.media[B]}}}}]),t}(m);S.exports=c},{"../base-xform":31}],56:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("./blip-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={"a:blip":new c},n}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag),this.map["a:blip"].render(o,p),o.openNode("a:stretch"),o.leafNode("a:fillRect"),o.closeNode(),o.closeNode()}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;switch(o.name){case this.tag:this.reset();break;default:this.parser=this.map[o.name],this.parser&&this.parser.parseOpen(o);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(o){if(this.parser)return this.parser.parseClose(o)||(this.parser=void 0),!0;switch(o){case this.tag:return this.model=this.map["a:blip"].model,!1;default:return!0}}},{key:"tag",get:function(){return"xdr:blipFill"}}]),i}(m);S.exports=a},{"../base-xform":31,"./blip-xform":57}],57:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:embed":o.rId,cstate:"print"})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:embed"]},!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"a:blip"}}]),t}(m);S.exports=c},{"../base-xform":31}],58:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n){n.openNode(this.tag),n.leafNode("a:picLocks",{noChangeAspect:"1"}),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"xdr:cNvPicPr"}}]),t}(m);S.exports=c},{"../base-xform":31}],59:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./hlink-click-xform"),a=e("./ext-lst-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"a:hlinkClick":new c,"a:extLst":new a},o}return b(n,[{key:"render",value:function(p,O){p.openNode(this.tag,{id:O.index,name:"Picture ".concat(O.index)}),this.map["a:hlinkClick"].render(p,O),this.map["a:extLst"].render(p,O),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset();break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.parser=void 0),!0;switch(p){case this.tag:return this.model=this.map["a:hlinkClick"].model,!1;default:return!0}}},{key:"tag",get:function(){return"xdr:cNvPr"}}]),n}(m);S.exports=r},{"../base-xform":31,"./ext-lst-xform":62,"./hlink-click-xform":64}],60:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("../simple/integer-xform"),a=function(r){w(i,r);var t=v(i);function i(n){var o;return y(this,i),o=t.call(this),o.tag=n.tag,o.map={"xdr:col":new c({tag:"xdr:col",zero:!0}),"xdr:colOff":new c({tag:"xdr:colOff",zero:!0}),"xdr:row":new c({tag:"xdr:row",zero:!0}),"xdr:rowOff":new c({tag:"xdr:rowOff",zero:!0})},o}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag),this.map["xdr:col"].render(o,p.nativeCol),this.map["xdr:colOff"].render(o,p.nativeColOff),this.map["xdr:row"].render(o,p.nativeRow),this.map["xdr:rowOff"].render(o,p.nativeRowOff),o.closeNode()}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;switch(o.name){case this.tag:this.reset();break;default:this.parser=this.map[o.name],this.parser&&this.parser.parseOpen(o);break}return!0}},{key:"parseText",value:function(o){this.parser&&this.parser.parseText(o)}},{key:"parseClose",value:function(o){if(this.parser)return this.parser.parseClose(o)||(this.parser=void 0),!0;switch(o){case this.tag:return 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;default:return!0}}}]),i}(m);S.exports=a},{"../base-xform":31,"../simple/integer-xform":117}],61:[function(e,S,_){function u(o){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(O){return typeof O}:u=function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},u(o)}function y(o,p){if(!(o instanceof p))throw new TypeError("Cannot call a class as a function")}function g(o,p){for(var O=0;O"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(o){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(O){return O.__proto__||Object.getPrototypeOf(O)},s(o)}var m=e("../../../utils/col-cache"),c=e("../../../utils/xml-stream"),a=e("../base-xform"),r=e("./two-cell-anchor-xform"),t=e("./one-cell-anchor-xform");function i(o){var p=typeof o.range=="string"?m.decode(o.range):o.range;return p.br?"xdr:twoCellAnchor":"xdr:oneCellAnchor"}var n=function(o){w(O,o);var p=v(O);function O(){var P;return y(this,O),P=p.call(this),P.map={"xdr:twoCellAnchor":new r,"xdr:oneCellAnchor":new t},P}return b(O,[{key:"prepare",value:function(B){var z=this;B.anchors.forEach(function(D,M){D.anchorType=i(D);var I=z.map[D.anchorType];I.prepare(D,{index:M})})}},{key:"render",value:function(B,z){var D=this;B.openXml(c.StdDocAttributes),B.openNode(this.tag,O.DRAWING_ATTRIBUTES),z.anchors.forEach(function(M){var I=D.map[M.anchorType];I.render(B,M)}),B.closeNode()}},{key:"parseOpen",value:function(B){if(this.parser)return this.parser.parseOpen(B),!0;switch(B.name){case this.tag:this.reset(),this.model={anchors:[]};break;default:this.parser=this.map[B.name],this.parser&&this.parser.parseOpen(B);break}return!0}},{key:"parseText",value:function(B){this.parser&&this.parser.parseText(B)}},{key:"parseClose",value:function(B){if(this.parser)return this.parser.parseClose(B)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0;switch(B){case this.tag:return!1;default:return!0}}},{key:"reconcile",value:function(B,z){var D=this;B.anchors.forEach(function(M){M.br?D.map["xdr:twoCellAnchor"].reconcile(M,z):D.map["xdr:oneCellAnchor"].reconcile(M,z)})}},{key:"tag",get:function(){return"xdr:wsDr"}}]),O}(a);n.DRAWING_ATTRIBUTES={"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"},S.exports=n},{"../../../utils/col-cache":19,"../../../utils/xml-stream":27,"../base-xform":31,"./one-cell-anchor-xform":66,"./two-cell-anchor-xform":69}],62:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n){n.openNode(this.tag),n.openNode("a:ext",{uri:"{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"}),n.leafNode("a16:creationId",{"xmlns:a16":"http://schemas.microsoft.com/office/drawing/2014/main",id:"{00000000-0008-0000-0000-000002000000}"}),n.closeNode(),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"a:extLst"}}]),t}(m);S.exports=c},{"../base-xform":31}],63:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=9525,a=function(r){w(i,r);var t=v(i);function i(n){var o;return y(this,i),o=t.call(this),o.tag=n.tag,o.map={},o}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag);var O=Math.floor(p.width*c),P=Math.floor(p.height*c);o.addAttribute("cx",O),o.addAttribute("cy",P),o.closeNode()}},{key:"parseOpen",value:function(o){return o.name===this.tag?(this.model={width:parseInt(o.attributes.cx||"0",10)/c,height:parseInt(o.attributes.cy||"0",10)/c},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),i}(m);S.exports=a},{"../base-xform":31}],64:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o.hyperlinks&&o.hyperlinks.rId&&n.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:id":o.hyperlinks.rId,tooltip:o.hyperlinks.tooltip})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={hyperlinks:{rId:n.attributes["r:id"],tooltip:n.attributes.tooltip}},!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"a:hlinkClick"}}]),t}(m);S.exports=c},{"../base-xform":31}],65:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./c-nv-pr-xform"),a=e("./c-nv-pic-pr-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"xdr:cNvPr":new c,"xdr:cNvPicPr":new a},o}return b(n,[{key:"render",value:function(p,O){p.openNode(this.tag),this.map["xdr:cNvPr"].render(p,O),this.map["xdr:cNvPicPr"].render(p,O),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset();break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.parser=void 0),!0;switch(p){case this.tag:return this.model=this.map["xdr:cNvPr"].model,!1;default:return!0}}},{key:"tag",get:function(){return"xdr:nvPicPr"}}]),n}(m);S.exports=r},{"../base-xform":31,"./c-nv-pic-pr-xform":58,"./c-nv-pr-xform":59}],66:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("./base-cell-anchor-xform"),c=e("../static-xform"),a=e("./cell-position-xform"),r=e("./ext-xform"),t=e("./pic-xform"),i=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={"xdr:from":new a({tag:"xdr:from"}),"xdr:ext":new r({tag:"xdr:ext"}),"xdr:pic":new t,"xdr:clientData":new c({tag:"xdr:clientData"})},O}return b(p,[{key:"prepare",value:function(P,B){this.map["xdr:pic"].prepare(P.picture,B)}},{key:"render",value:function(P,B){P.openNode(this.tag,{editAs:B.range.editAs||"oneCell"}),this.map["xdr:from"].render(P,B.range.tl),this.map["xdr:ext"].render(P,B.range.ext),this.map["xdr:pic"].render(P,B.picture),this.map["xdr:clientData"].render(P,{}),P.closeNode()}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){case this.tag:return 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;default:return!0}}},{key:"reconcile",value:function(P,B){P.medium=this.reconcilePicture(P.picture,B)}},{key:"tag",get:function(){return"xdr:oneCellAnchor"}}]),p}(m);S.exports=i},{"../static-xform":119,"./base-cell-anchor-xform":55,"./cell-position-xform":60,"./ext-xform":63,"./pic-xform":67}],67:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../base-xform"),c=e("../static-xform"),a=e("./blip-fill-xform"),r=e("./nv-pic-pr-xform"),t=e("./sp-pr"),i=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={"xdr:nvPicPr":new r,"xdr:blipFill":new a,"xdr:spPr":new c(t)},O}return b(p,[{key:"prepare",value:function(P,B){P.index=B.index+1}},{key:"render",value:function(P,B){P.openNode(this.tag),this.map["xdr:nvPicPr"].render(P,B),this.map["xdr:blipFill"].render(P,B),this.map["xdr:spPr"].render(P,B),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case this.tag:this.reset();break;default:this.parser=this.map[P.name],this.parser&&this.parser.parseOpen(P);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.mergeModel(this.parser.model),this.parser=void 0),!0;switch(P){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"xdr:pic"}}]),p}(m);S.exports=i},{"../base-xform":31,"../static-xform":119,"./blip-fill-xform":56,"./nv-pic-pr-xform":65,"./sp-pr":68}],68:[function(e,S,_){S.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"}]}]}},{}],69:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("./base-cell-anchor-xform"),c=e("../static-xform"),a=e("./cell-position-xform"),r=e("./pic-xform"),t=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={"xdr:from":new a({tag:"xdr:from"}),"xdr:to":new a({tag:"xdr:to"}),"xdr:pic":new r,"xdr:clientData":new c({tag:"xdr:clientData"})},p}return b(o,[{key:"prepare",value:function(O,P){this.map["xdr:pic"].prepare(O.picture,P)}},{key:"render",value:function(O,P){O.openNode(this.tag,{editAs:P.range.editAs||"oneCell"}),this.map["xdr:from"].render(O,P.range.tl),this.map["xdr:to"].render(O,P.range.br),this.map["xdr:pic"].render(O,P.picture),this.map["xdr:clientData"].render(O,{}),O.closeNode()}},{key:"parseClose",value:function(O){if(this.parser)return this.parser.parseClose(O)||(this.parser=void 0),!0;switch(O){case this.tag:return 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;default:return!0}}},{key:"reconcile",value:function(O,P){O.medium=this.reconcilePicture(O.picture,P)}},{key:"tag",get:function(){return"xdr:twoCellAnchor"}}]),o}(m);S.exports=t},{"../static-xform":119,"./base-cell-anchor-xform":55,"./cell-position-xform":60,"./pic-xform":67}],70:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("./base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.always=!!i.always,n.count=i.count,n.empty=i.empty,n.$count=i.$count||"count",n.$=i.$,n.childXform=i.childXform,n.maxItems=i.maxItems,n}return b(t,[{key:"prepare",value:function(n,o){var p=this.childXform;n&&n.forEach(function(O,P){o.index=P,p.prepare(O,o)})}},{key:"render",value:function(n,o){if(this.always||o&&o.length){n.openNode(this.tag,this.$),this.count&&n.addAttribute(this.$count,o&&o.length||0);var p=this.childXform;(o||[]).forEach(function(O,P){p.render(n,O,P)}),n.closeNode()}else this.empty&&n.leafNode(this.tag)}},{key:"parseOpen",value:function(n){if(this.parser)return this.parser.parseOpen(n),!0;switch(n.name){case this.tag:return this.model=[],!0;default:return this.childXform.parseOpen(n)?(this.parser=this.childXform,!0):!1}}},{key:"parseText",value:function(n){this.parser&&this.parser.parseText(n)}},{key:"parseClose",value:function(n){if(this.parser){if(!this.parser.parseClose(n)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw new Error("Max ".concat(this.childXform.tag," count (").concat(this.maxItems,") exceeded"));return!0}return!1}},{key:"reconcile",value:function(n,o){if(n){var p=this.childXform;n.forEach(function(O){p.reconcile(O,o)})}}}]),t}(m);S.exports=c},{"./base-xform":31}],71:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/col-cache"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){if(p)if(typeof p=="string")o.leafNode("autoFilter",{ref:p});else{var O=function(D){return typeof D=="string"?D:m.getAddress(D.row,D.column).address},P=O(p.from),B=O(p.to);P&&B&&o.leafNode("autoFilter",{ref:"".concat(P,":").concat(B)})}}},{key:"parseOpen",value:function(o){o.name==="autoFilter"&&(this.model=o.attributes.ref)}},{key:"tag",get:function(){return"autoFilter"}}]),i}(c);S.exports=a},{"../../../utils/col-cache":19,"../base-xform":31}],72:[function(e,S,_){function u(B){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(D){return typeof D}:u=function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},u(B)}function y(B,z){var D=Object.keys(B);if(Object.getOwnPropertySymbols){var M=Object.getOwnPropertySymbols(B);z&&(M=M.filter(function(I){return Object.getOwnPropertyDescriptor(B,I).enumerable})),D.push.apply(D,M)}return D}function g(B){for(var z=1;z"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(B){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(D){return D.__proto__||Object.getPrototypeOf(D)},a(B)}var r=e("../../../utils/utils"),t=e("../base-xform"),i=e("../../../doc/range"),n=e("../../../doc/enums"),o=e("../strings/rich-text-xform");function p(B){if(B==null)return n.ValueType.Null;if(B instanceof String||typeof B=="string")return n.ValueType.String;if(typeof B=="number")return n.ValueType.Number;if(typeof B=="boolean")return n.ValueType.Boolean;if(B instanceof Date)return n.ValueType.Date;if(B.text&&B.hyperlink)return n.ValueType.Hyperlink;if(B.formula)return n.ValueType.Formula;if(B.error)return n.ValueType.Error;throw new Error("I could not understand type of value")}function O(B){switch(B.type){case n.ValueType.Formula:return p(B.result);default:return B.type}}var P=function(B){h(D,B);var z=d(D);function D(){var M;return w(this,D),M=z.call(this),M.richTextXForm=new o,M}return v(D,[{key:"prepare",value:function(I,T){var C=T.styles.addStyleModel(I.style||{},O(I));switch(C&&(I.styleId=C),I.comment&&T.comments.push(g(g({},I.comment),{},{ref:I.address})),I.type){case n.ValueType.String:case n.ValueType.RichText:T.sharedStrings&&(I.ssId=T.sharedStrings.add(I.value));break;case n.ValueType.Date:T.date1904&&(I.date1904=!0);break;case n.ValueType.Hyperlink:T.sharedStrings&&I.text!==void 0&&I.text!==null&&(I.ssId=T.sharedStrings.add(I.text)),T.hyperlinks.push({address:I.address,target:I.hyperlink,tooltip:I.tooltip});break;case n.ValueType.Merge:T.merges.add(I);break;case n.ValueType.Formula:if(T.date1904&&(I.date1904=!0),I.shareType==="shared"&&(I.si=T.siFormulae++),I.formula)T.formulae[I.address]=I;else if(I.sharedFormula){var E=T.formulae[I.sharedFormula];if(!E)throw new Error("Shared Formula master must exist above and or left of clone for cell ".concat(I.address));E.si===void 0?(E.shareType="shared",E.si=T.siFormulae++,E.range=new i(E.address,I.address)):E.range&&E.range.expandToAddress(I.address),I.si=E.si}break}}},{key:"renderFormula",value:function(I,T){var C=null;switch(T.shareType){case"shared":C={t:"shared",ref:T.ref||T.range.range,si:T.si};break;case"array":C={t:"array",ref:T.ref};break;default:T.si!==void 0&&(C={t:"shared",si:T.si});break}switch(p(T.result)){case n.ValueType.Null:I.leafNode("f",C,T.formula);break;case n.ValueType.String:I.addAttribute("t","str"),I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result);break;case n.ValueType.Number:I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result);break;case n.ValueType.Boolean:I.addAttribute("t","b"),I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result?1:0);break;case n.ValueType.Error:I.addAttribute("t","e"),I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result.error);break;case n.ValueType.Date:I.leafNode("f",C,T.formula),I.leafNode("v",null,r.dateToExcel(T.result,T.date1904));break;default:throw new Error("I could not understand type of value")}}},{key:"render",value:function(I,T){var C=this;if(!(T.type===n.ValueType.Null&&!T.styleId)){switch(I.openNode("c"),I.addAttribute("r",T.address),T.styleId&&I.addAttribute("s",T.styleId),T.type){case n.ValueType.Null:break;case n.ValueType.Number:I.leafNode("v",null,T.value);break;case n.ValueType.Boolean:I.addAttribute("t","b"),I.leafNode("v",null,T.value?"1":"0");break;case n.ValueType.Error:I.addAttribute("t","e"),I.leafNode("v",null,T.value.error);break;case n.ValueType.String:case n.ValueType.RichText:T.ssId!==void 0?(I.addAttribute("t","s"),I.leafNode("v",null,T.ssId)):T.value&&T.value.richText?(I.addAttribute("t","inlineStr"),I.openNode("is"),T.value.richText.forEach(function(E){C.richTextXForm.render(I,E)}),I.closeNode("is")):(I.addAttribute("t","str"),I.leafNode("v",null,T.value));break;case n.ValueType.Date:I.leafNode("v",null,r.dateToExcel(T.value,T.date1904));break;case n.ValueType.Hyperlink:T.ssId!==void 0?(I.addAttribute("t","s"),I.leafNode("v",null,T.ssId)):(I.addAttribute("t","str"),I.leafNode("v",null,T.text));break;case n.ValueType.Formula:this.renderFormula(I,T);break;case n.ValueType.Merge:break}I.closeNode()}}},{key:"parseOpen",value:function(I){if(this.parser)return this.parser.parseOpen(I),!0;switch(I.name){case"c":return this.model={address:I.attributes.r},this.t=I.attributes.t,I.attributes.s&&(this.model.styleId=parseInt(I.attributes.s,10)),!0;case"f":return this.currentNode="f",this.model.si=I.attributes.si,this.model.shareType=I.attributes.t,this.model.ref=I.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(I),!0;default:return!1}}},{key:"parseText",value:function(I){if(this.parser){this.parser.parseText(I);return}switch(this.currentNode){case"f":this.model.formula=this.model.formula?this.model.formula+I:I;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+I:I:this.model.value=this.model.value?this.model.value+I:I;break}}},{key:"parseClose",value:function(I){switch(I){case"c":{var T=this.model;if(T.formula||T.shareType)T.type=n.ValueType.Formula,T.value&&(this.t==="str"?T.result=r.xmlDecode(T.value):this.t==="b"?T.result=parseInt(T.value,10)!==0:this.t==="e"?T.result={error:T.value}:T.result=parseFloat(T.value),T.value=void 0);else if(T.value!==void 0)switch(this.t){case"s":T.type=n.ValueType.String,T.value=parseInt(T.value,10);break;case"str":T.type=n.ValueType.String,T.value=r.xmlDecode(T.value);break;case"inlineStr":T.type=n.ValueType.String;break;case"b":T.type=n.ValueType.Boolean,T.value=parseInt(T.value,10)!==0;break;case"e":T.type=n.ValueType.Error,T.value={error:T.value};break;default:T.type=n.ValueType.Number,T.value=parseFloat(T.value);break}else T.styleId?T.type=n.ValueType.Null:T.type=n.ValueType.Merge;return!1}case"f":case"v":case"is":return this.currentNode=void 0,!0;case"t":return this.parser?(this.parser.parseClose(I),!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(I),!0):!1}}},{key:"reconcile",value:function(I,T){var C=I.styleId&&T.styles&&T.styles.getStyleModel(I.styleId);switch(C&&(I.style=C),I.styleId!==void 0&&(I.styleId=void 0),I.type){case n.ValueType.String:typeof I.value=="number"&&T.sharedStrings&&(I.value=T.sharedStrings.getString(I.value)),I.value.richText&&(I.type=n.ValueType.RichText);break;case n.ValueType.Number:C&&r.isDateFmt(C.numFmt)&&(I.type=n.ValueType.Date,I.value=r.excelToDate(I.value,T.date1904));break;case n.ValueType.Formula:I.result!==void 0&&C&&r.isDateFmt(C.numFmt)&&(I.result=r.excelToDate(I.result,T.date1904)),I.shareType==="shared"&&(I.ref?T.formulae[I.si]=I.address:(I.sharedFormula=T.formulae[I.si],delete I.shareType),delete I.si);break}var E=T.hyperlinkMap[I.address];E&&(I.type===n.ValueType.Formula?(I.text=I.result,I.result=void 0):(I.text=I.value,I.value=void 0),I.type=n.ValueType.Hyperlink,I.hyperlink=E);var A=T.commentsMap&&T.commentsMap[I.address];A&&(I.comment=A)}},{key:"tag",get:function(){return"c"}}]),D}(t);S.exports=P},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/utils":26,"../base-xform":31,"../strings/rich-text-xform":121}],73:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,{iconSet:o.iconSet,iconId:o.iconId})}},{key:"parseOpen",value:function(n){var o=n.attributes;this.model={iconSet:o.iconSet,iconId:m.toIntValue(o.iconId)}}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"x14:cfIcon"}}]),t}(m);S.exports=c},{"../../base-xform":31}],74:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,O){if(!(p instanceof O))throw new TypeError("Cannot call a class as a function")}function g(p,O){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("uuid"),c=m.v4,a=e("../../base-xform"),r=e("../../composite-xform"),t=e("./databar-ext-xform"),i=e("./icon-set-ext-xform"),n={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},o=function(p){w(P,p);var O=v(P);function P(){var B;return y(this,P),B=O.call(this),B.map={"x14:dataBar":B.databarXform=new t,"x14:iconSet":B.iconSetXform=new i},B}return b(P,[{key:"prepare",value:function(z){P.isExt(z)&&(z.x14Id="{".concat(c(),"}").toUpperCase())}},{key:"render",value:function(z,D){if(P.isExt(D))switch(D.type){case"dataBar":this.renderDataBar(z,D);break;case"iconSet":this.renderIconSet(z,D);break}}},{key:"renderDataBar",value:function(z,D){z.openNode(this.tag,{type:"dataBar",id:D.x14Id}),this.databarXform.render(z,D),z.closeNode()}},{key:"renderIconSet",value:function(z,D){z.openNode(this.tag,{type:"iconSet",priority:D.priority,id:D.x14Id||"{".concat(c(),"}")}),this.iconSetXform.render(z,D),z.closeNode()}},{key:"createNewModel",value:function(z){var D=z.attributes;return{type:D.type,x14Id:D.id,priority:a.toIntValue(D.priority)}}},{key:"onParserClose",value:function(z,D){Object.assign(this.model,D.model)}},{key:"tag",get:function(){return"x14:cfRule"}}],[{key:"isExt",value:function(z){return z.type==="dataBar"?t.isExt(z):!!(z.type==="iconSet"&&(z.custom||n[z.iconSet]))}}]),P}(r);S.exports=o},{"../../base-xform":31,"../../composite-xform":47,"./databar-ext-xform":78,"./icon-set-ext-xform":80,uuid:526}],75:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../composite-xform"),c=e("./f-ext-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={"xm:f":n.fExtXform=new c},n}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag,{type:p.type}),p.value!==void 0&&this.fExtXform.render(o,p.value),o.closeNode()}},{key:"createNewModel",value:function(o){return{type:o.attributes.type}}},{key:"onParserClose",value:function(o,p){switch(o){case"xm:f":this.model.value=p.model?parseFloat(p.model):0;break}}},{key:"tag",get:function(){return"x14:cfvo"}}]),i}(m);S.exports=a},{"../../composite-xform":47,"./f-ext-xform":79}],76:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("./sqref-ext-xform"),a=e("./cf-rule-ext-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"xm:sqref":o.sqRef=new c,"x14:cfRule":o.cfRule=new a},o}return b(n,[{key:"prepare",value:function(p,O){var P=this;p.rules.forEach(function(B){P.cfRule.prepare(B,O)})}},{key:"render",value:function(p,O){var P=this;O.rules.some(a.isExt)&&(p.openNode(this.tag,{"xmlns:xm":"http://schemas.microsoft.com/office/excel/2006/main"}),O.rules.filter(a.isExt).forEach(function(B){return P.cfRule.render(p,B)}),this.sqRef.render(p,O.ref),p.closeNode())}},{key:"createNewModel",value:function(){return{rules:[]}}},{key:"onParserClose",value:function(p,O){switch(p){case"xm:sqref":this.model.ref=O.model;break;case"x14:cfRule":this.model.rules.push(O.model);break}}},{key:"tag",get:function(){return"x14:conditionalFormatting"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"./cf-rule-ext-xform":74,"./sqref-ext-xform":81}],77:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("./cf-rule-ext-xform"),a=e("./conditional-formatting-ext-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"x14:conditionalFormatting":o.cfXform=new a},o}return b(n,[{key:"hasContent",value:function(p){return p.hasExtContent===void 0&&(p.hasExtContent=p.some(function(O){return O.rules.some(c.isExt)})),p.hasExtContent}},{key:"prepare",value:function(p,O){var P=this;p.forEach(function(B){P.cfXform.prepare(B,O)})}},{key:"render",value:function(p,O){var P=this;this.hasContent(O)&&(p.openNode(this.tag),O.forEach(function(B){return P.cfXform.render(p,B)}),p.closeNode())}},{key:"createNewModel",value:function(){return[]}},{key:"onParserClose",value:function(p,O){this.model.push(O.model)}},{key:"tag",get:function(){return"x14:conditionalFormattings"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"./cf-rule-ext-xform":74,"./conditional-formatting-ext-xform":76}],78:[function(e,S,_){function u(B){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(D){return typeof D}:u=function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},u(B)}function y(B,z){return v(B)||f(B,z)||b(B,z)||g()}function g(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(B,z){if(B){if(typeof B=="string")return w(B,z);var D=Object.prototype.toString.call(B).slice(8,-1);if(D==="Object"&&B.constructor&&(D=B.constructor.name),D==="Map"||D==="Set")return Array.from(B);if(D==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D))return w(B,z)}}function w(B,z){(z==null||z>B.length)&&(z=B.length);for(var D=0,M=new Array(z);D"u"||!(Symbol.iterator in Object(B)))){var D=[],M=!0,I=!1,T=void 0;try{for(var C=B[Symbol.iterator](),E;!(M=(E=C.next()).done)&&(D.push(E.value),!(z&&D.length===z));M=!0);}catch(A){I=!0,T=A}finally{try{!M&&C.return!=null&&C.return()}finally{if(I)throw T}}return D}}function v(B){if(Array.isArray(B))return B}function h(B,z){if(!(B instanceof z))throw new TypeError("Cannot call a class as a function")}function l(B,z){for(var D=0;D"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function i(B){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(D){return D.__proto__||Object.getPrototypeOf(D)},i(B)}var n=e("../../base-xform"),o=e("../../composite-xform"),p=e("../../style/color-xform"),O=e("./cfvo-ext-xform"),P=function(B){s(D,B);var z=c(D);function D(){var M;return h(this,D),M=z.call(this),M.map={"x14:cfvo":M.cfvoXform=new O,"x14:borderColor":M.borderColorXform=new p("x14:borderColor"),"x14:negativeBorderColor":M.negativeBorderColorXform=new p("x14:negativeBorderColor"),"x14:negativeFillColor":M.negativeFillColorXform=new p("x14:negativeFillColor"),"x14:axisColor":M.axisColorXform=new p("x14:axisColor")},M}return d(D,[{key:"render",value:function(I,T){var C=this;I.openNode(this.tag,{minLength:n.toIntAttribute(T.minLength,0,!0),maxLength:n.toIntAttribute(T.maxLength,100,!0),border:n.toBoolAttribute(T.border,!1),gradient:n.toBoolAttribute(T.gradient,!0),negativeBarColorSameAsPositive:n.toBoolAttribute(T.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:n.toBoolAttribute(T.negativeBarBorderColorSameAsPositive,!0),axisPosition:n.toAttribute(T.axisPosition,"auto"),direction:n.toAttribute(T.direction,"leftToRight")}),T.cfvo.forEach(function(E){C.cfvoXform.render(I,E)}),this.borderColorXform.render(I,T.borderColor),this.negativeBorderColorXform.render(I,T.negativeBorderColor),this.negativeFillColorXform.render(I,T.negativeFillColor),this.axisColorXform.render(I,T.axisColor),I.closeNode()}},{key:"createNewModel",value:function(I){var T=I.attributes;return{cfvo:[],minLength:n.toIntValue(T.minLength,0),maxLength:n.toIntValue(T.maxLength,100),border:n.toBoolValue(T.border,!1),gradient:n.toBoolValue(T.gradient,!0),negativeBarColorSameAsPositive:n.toBoolValue(T.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:n.toBoolValue(T.negativeBarBorderColorSameAsPositive,!0),axisPosition:n.toStringValue(T.axisPosition,"auto"),direction:n.toStringValue(T.direction,"leftToRight")}}},{key:"onParserClose",value:function(I,T){var C=I.split(":"),E=y(C,2),A=E[1];switch(A){case"cfvo":this.model.cfvo.push(T.model);break;default:this.model[A]=T.model;break}}},{key:"tag",get:function(){return"x14:dataBar"}}],[{key:"isExt",value:function(I){return!I.gradient}}]),D}(o);S.exports=P},{"../../base-xform":31,"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-ext-xform":75}],79:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(n){this.model+=n}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"xm:f"}}]),t}(m);S.exports=c},{"../../base-xform":31}],80:[function(e,S,_){function u(B){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(D){return typeof D}:u=function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},u(B)}function y(B,z){return v(B)||f(B,z)||b(B,z)||g()}function g(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(B,z){if(B){if(typeof B=="string")return w(B,z);var D=Object.prototype.toString.call(B).slice(8,-1);if(D==="Object"&&B.constructor&&(D=B.constructor.name),D==="Map"||D==="Set")return Array.from(B);if(D==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D))return w(B,z)}}function w(B,z){(z==null||z>B.length)&&(z=B.length);for(var D=0,M=new Array(z);D"u"||!(Symbol.iterator in Object(B)))){var D=[],M=!0,I=!1,T=void 0;try{for(var C=B[Symbol.iterator](),E;!(M=(E=C.next()).done)&&(D.push(E.value),!(z&&D.length===z));M=!0);}catch(A){I=!0,T=A}finally{try{!M&&C.return!=null&&C.return()}finally{if(I)throw T}}return D}}function v(B){if(Array.isArray(B))return B}function h(B,z){if(!(B instanceof z))throw new TypeError("Cannot call a class as a function")}function l(B,z){for(var D=0;D"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function i(B){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(D){return D.__proto__||Object.getPrototypeOf(D)},i(B)}var n=e("../../base-xform"),o=e("../../composite-xform"),p=e("./cfvo-ext-xform"),O=e("./cf-icon-ext-xform"),P=function(B){s(D,B);var z=c(D);function D(){var M;return h(this,D),M=z.call(this),M.map={"x14:cfvo":M.cfvoXform=new p,"x14:cfIcon":M.cfIconXform=new O},M}return d(D,[{key:"render",value:function(I,T){var C=this;I.openNode(this.tag,{iconSet:n.toStringAttribute(T.iconSet),reverse:n.toBoolAttribute(T.reverse,!1),showValue:n.toBoolAttribute(T.showValue,!0),custom:n.toBoolAttribute(T.icons,!1)}),T.cfvo.forEach(function(E){C.cfvoXform.render(I,E)}),T.icons&&T.icons.forEach(function(E,A){E.iconId=A,C.cfIconXform.render(I,E)}),I.closeNode()}},{key:"createNewModel",value:function(I){var T=I.attributes;return{cfvo:[],iconSet:n.toStringValue(T.iconSet,"3TrafficLights"),reverse:n.toBoolValue(T.reverse,!1),showValue:n.toBoolValue(T.showValue,!0)}}},{key:"onParserClose",value:function(I,T){var C=I.split(":"),E=y(C,2),A=E[1];switch(A){case"cfvo":this.model.cfvo.push(T.model);break;case"cfIcon":this.model.icons||(this.model.icons=[]),this.model.icons.push(T.model);break;default:this.model[A]=T.model;break}}},{key:"tag",get:function(){return"x14:iconSet"}}]),D}(o);S.exports=P},{"../../base-xform":31,"../../composite-xform":47,"./cf-icon-ext-xform":73,"./cfvo-ext-xform":75}],81:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(n){this.model+=n}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"xm:sqref"}}]),t}(m);S.exports=c},{"../../base-xform":31}],82:[function(e,S,_){function u(T){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(E){return typeof E}:u=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},u(T)}function y(T,C){var E=Object.keys(T);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(T);C&&(A=A.filter(function(L){return Object.getOwnPropertyDescriptor(T,L).enumerable})),E.push.apply(E,A)}return E}function g(T){for(var C=1;C"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(T){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(E){return E.__proto__||Object.getPrototypeOf(E)},a(T)}var r=e("../../base-xform"),t=e("../../composite-xform"),i=e("../../../../doc/range"),n=e("./databar-xform"),o=e("./ext-lst-ref-xform"),p=e("./formula-xform"),O=e("./color-scale-xform"),P=e("./icon-set-xform"),B={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},z=function(C){if(C.formulae&&C.formulae[0])return C.formulae[0];var E=new i(C.ref),A=E.tl;switch(C.operator){case"containsText":return'NOT(ISERROR(SEARCH("'.concat(C.text,'",').concat(A,")))");case"containsBlanks":return"LEN(TRIM(".concat(A,"))=0");case"notContainsBlanks":return"LEN(TRIM(".concat(A,"))>0");case"containsErrors":return"ISERROR(".concat(A,")");case"notContainsErrors":return"NOT(ISERROR(".concat(A,"))");default:return}},D=function(C){if(C.formulae&&C.formulae[0])return C.formulae[0];var E=new i(C.ref),A=E.tl;switch(C.timePeriod){case"thisWeek":return"AND(TODAY()-ROUNDDOWN(".concat(A,",0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(").concat(A,",0)-TODAY()<=7-WEEKDAY(TODAY()))");case"lastWeek":return"AND(TODAY()-ROUNDDOWN(".concat(A,",0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(").concat(A,",0)<(WEEKDAY(TODAY())+7))");case"nextWeek":return"AND(ROUNDDOWN(".concat(A,",0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(").concat(A,",0)-TODAY()<(15-WEEKDAY(TODAY())))");case"yesterday":return"FLOOR(".concat(A,",1)=TODAY()-1");case"today":return"FLOOR(".concat(A,",1)=TODAY()");case"tomorrow":return"FLOOR(".concat(A,",1)=TODAY()+1");case"last7Days":return"AND(TODAY()-FLOOR(".concat(A,",1)<=6,FLOOR(").concat(A,",1)<=TODAY())");case"lastMonth":return"AND(MONTH(".concat(A,")=MONTH(EDATE(TODAY(),0-1)),YEAR(").concat(A,")=YEAR(EDATE(TODAY(),0-1)))");case"thisMonth":return"AND(MONTH(".concat(A,")=MONTH(TODAY()),YEAR(").concat(A,")=YEAR(TODAY()))");case"nextMonth":return"AND(MONTH(".concat(A,")=MONTH(EDATE(TODAY(),0+1)),YEAR(").concat(A,")=YEAR(EDATE(TODAY(),0+1)))");default:return}},M=function(C){var E=C.type,A=C.operator;switch(E){case"containsText":case"containsBlanks":case"notContainsBlanks":case"containsErrors":case"notContainsErrors":return{type:"containsText",operator:E};default:return{type:E,operator:A}}},I=function(T){h(E,T);var C=d(E);function E(){var A;return w(this,E),A=C.call(this),A.map={dataBar:A.databarXform=new n,extLst:A.extLstRefXform=new o,formula:A.formulaXform=new p,colorScale:A.colorScaleXform=new O,iconSet:A.iconSetXform=new P},A}return v(E,[{key:"render",value:function(L,$){switch($.type){case"expression":this.renderExpression(L,$);break;case"cellIs":this.renderCellIs(L,$);break;case"top10":this.renderTop10(L,$);break;case"aboveAverage":this.renderAboveAverage(L,$);break;case"dataBar":this.renderDataBar(L,$);break;case"colorScale":this.renderColorScale(L,$);break;case"iconSet":this.renderIconSet(L,$);break;case"containsText":this.renderText(L,$);break;case"timePeriod":this.renderTimePeriod(L,$);break}}},{key:"renderExpression",value:function(L,$){L.openNode(this.tag,{type:"expression",dxfId:$.dxfId,priority:$.priority}),this.formulaXform.render(L,$.formulae[0]),L.closeNode()}},{key:"renderCellIs",value:function(L,$){var W=this;L.openNode(this.tag,{type:"cellIs",dxfId:$.dxfId,priority:$.priority,operator:$.operator}),$.formulae.forEach(function(U){W.formulaXform.render(L,U)}),L.closeNode()}},{key:"renderTop10",value:function(L,$){L.leafNode(this.tag,{type:"top10",dxfId:$.dxfId,priority:$.priority,percent:r.toBoolAttribute($.percent,!1),bottom:r.toBoolAttribute($.bottom,!1),rank:r.toIntValue($.rank,10,!0)})}},{key:"renderAboveAverage",value:function(L,$){L.leafNode(this.tag,{type:"aboveAverage",dxfId:$.dxfId,priority:$.priority,aboveAverage:r.toBoolAttribute($.aboveAverage,!0)})}},{key:"renderDataBar",value:function(L,$){L.openNode(this.tag,{type:"dataBar",priority:$.priority}),this.databarXform.render(L,$),this.extLstRefXform.render(L,$),L.closeNode()}},{key:"renderColorScale",value:function(L,$){L.openNode(this.tag,{type:"colorScale",priority:$.priority}),this.colorScaleXform.render(L,$),L.closeNode()}},{key:"renderIconSet",value:function(L,$){E.isPrimitive($)&&(L.openNode(this.tag,{type:"iconSet",priority:$.priority}),this.iconSetXform.render(L,$),L.closeNode())}},{key:"renderText",value:function(L,$){L.openNode(this.tag,{type:$.operator,dxfId:$.dxfId,priority:$.priority,operator:r.toStringAttribute($.operator,"containsText")});var W=z($);W&&this.formulaXform.render(L,W),L.closeNode()}},{key:"renderTimePeriod",value:function(L,$){L.openNode(this.tag,{type:"timePeriod",dxfId:$.dxfId,priority:$.priority,timePeriod:$.timePeriod});var W=D($);W&&this.formulaXform.render(L,W),L.closeNode()}},{key:"createNewModel",value:function(L){var $=L.attributes;return g(g({},M($)),{},{dxfId:r.toIntValue($.dxfId),priority:r.toIntValue($.priority),timePeriod:$.timePeriod,percent:r.toBoolValue($.percent),bottom:r.toBoolValue($.bottom),rank:r.toIntValue($.rank),aboveAverage:r.toBoolValue($.aboveAverage)})}},{key:"onParserClose",value:function(L,$){switch(L){case"dataBar":case"extLst":case"colorScale":case"iconSet":Object.assign(this.model,$.model);break;case"formula":this.model.formulae=this.model.formulae||[],this.model.formulae.push($.model);break}}},{key:"tag",get:function(){return"cfRule"}}],[{key:"isPrimitive",value:function(L){return!(L.type==="iconSet"&&(L.custom||B[L.iconSet]))}}]),E}(t);S.exports=I},{"../../../../doc/range":10,"../../base-xform":31,"../../composite-xform":47,"./color-scale-xform":84,"./databar-xform":87,"./ext-lst-ref-xform":88,"./formula-xform":89,"./icon-set-xform":90}],83:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,{type:o.type,val:o.value})}},{key:"parseOpen",value:function(n){this.model={type:n.attributes.type,value:m.toFloatValue(n.attributes.val)}}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"cfvo"}}]),t}(m);S.exports=c},{"../../base-xform":31}],84:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("../../style/color-xform"),a=e("./cfvo-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={cfvo:o.cfvoXform=new a,color:o.colorXform=new c},o}return b(n,[{key:"render",value:function(p,O){var P=this;p.openNode(this.tag),O.cfvo.forEach(function(B){P.cfvoXform.render(p,B)}),O.color.forEach(function(B){P.colorXform.render(p,B)}),p.closeNode()}},{key:"createNewModel",value:function(p){return{cfvo:[],color:[]}}},{key:"onParserClose",value:function(p,O){this.model[p].push(O.model)}},{key:"tag",get:function(){return"colorScale"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-xform":83}],85:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../composite-xform"),c=e("./cf-rule-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={cfRule:new c},n}return b(i,[{key:"render",value:function(o,p){var O=this;p.rules.some(c.isPrimitive)&&(o.openNode(this.tag,{sqref:p.ref}),p.rules.forEach(function(P){c.isPrimitive(P)&&(P.ref=p.ref,O.map.cfRule.render(o,P))}),o.closeNode())}},{key:"createNewModel",value:function(o){var p=o.attributes;return{ref:p.sqref,rules:[]}}},{key:"onParserClose",value:function(o,p){this.model.rules.push(p.model)}},{key:"tag",get:function(){return"conditionalFormatting"}}]),i}(m);S.exports=a},{"../../composite-xform":47,"./cf-rule-xform":82}],86:[function(e,S,_){function u(O){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(B){return typeof B}:u=function(B){return B&&typeof Symbol=="function"&&B.constructor===Symbol&&B!==Symbol.prototype?"symbol":typeof B},u(O)}function y(O){return f(O)||w(O)||b(O)||g()}function g(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(O,P){if(O){if(typeof O=="string")return v(O,P);var B=Object.prototype.toString.call(O).slice(8,-1);if(B==="Object"&&O.constructor&&(B=O.constructor.name),B==="Map"||B==="Set")return Array.from(O);if(B==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(B))return v(O,P)}}function w(O){if(typeof Symbol<"u"&&Symbol.iterator in Object(O))return Array.from(O)}function f(O){if(Array.isArray(O))return v(O)}function v(O,P){(P==null||P>O.length)&&(P=O.length);for(var B=0,z=new Array(P);B"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function i(O){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(B){return B.__proto__||Object.getPrototypeOf(B)},i(O)}var n=e("../../base-xform"),o=e("./conditional-formatting-xform"),p=function(O){s(B,O);var P=c(B);function B(){var z;return h(this,B),z=P.call(this),z.cfXform=new o,z}return d(B,[{key:"reset",value:function(){this.model=[]}},{key:"prepare",value:function(D,M){var I=D.reduce(function(T,C){return Math.max.apply(Math,[T].concat(y(C.rules.map(function(E){return E.priority||0}))))},1);D.forEach(function(T){T.rules.forEach(function(C){C.priority||(C.priority=I++),C.style&&(C.dxfId=M.styles.addDxfStyle(C.style))})})}},{key:"render",value:function(D,M){var I=this;M.forEach(function(T){I.cfXform.render(D,T)})}},{key:"parseOpen",value:function(D){if(this.parser)return this.parser.parseOpen(D),!0;switch(D.name){case"conditionalFormatting":return this.parser=this.cfXform,this.parser.parseOpen(D),!0;default:return!1}}},{key:"parseText",value:function(D){this.parser&&this.parser.parseText(D)}},{key:"parseClose",value:function(D){return this.parser?this.parser.parseClose(D)?!0:(this.model.push(this.parser.model),this.parser=void 0,!1):!1}},{key:"reconcile",value:function(D,M){D.forEach(function(I){I.rules.forEach(function(T){T.dxfId!==void 0&&(T.style=M.styles.getDxfStyle(T.dxfId),delete T.dxfId)})})}},{key:"tag",get:function(){return"conditionalFormatting"}}]),B}(n);S.exports=p},{"../../base-xform":31,"./conditional-formatting-xform":85}],87:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("../../style/color-xform"),a=e("./cfvo-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={cfvo:o.cfvoXform=new a,color:o.colorXform=new c},o}return b(n,[{key:"render",value:function(p,O){var P=this;p.openNode(this.tag),O.cfvo.forEach(function(B){P.cfvoXform.render(p,B)}),this.colorXform.render(p,O.color),p.closeNode()}},{key:"createNewModel",value:function(){return{cfvo:[]}}},{key:"onParserClose",value:function(p,O){switch(p){case"cfvo":this.model.cfvo.push(O.model);break;case"color":this.model.color=O.model;break}}},{key:"tag",get:function(){return"dataBar"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-xform":83}],88:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../../base-xform"),c=e("../../composite-xform"),a=function(i){w(o,i);var n=v(o);function o(){return y(this,o),n.apply(this,arguments)}return b(o,[{key:"render",value:function(O,P){O.leafNode(this.tag,null,P)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(O){this.model+=O}},{key:"parseClose",value:function(O){return O!==this.tag}},{key:"tag",get:function(){return"x14:id"}}]),o}(m),r=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={"x14:id":p.idXform=new a},p}return b(o,[{key:"render",value:function(O,P){O.openNode(this.tag,{uri:"{B025F937-C7B1-47D3-B67F-A62EFF666E3E}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.idXform.render(O,P.x14Id),O.closeNode()}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(O,P){this.model.x14Id=P.model}},{key:"tag",get:function(){return"ext"}}]),o}(c),t=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={ext:new r},p}return b(o,[{key:"render",value:function(O,P){O.openNode(this.tag),this.map.ext.render(O,P),O.closeNode()}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(O,P){Object.assign(this.model,P.model)}},{key:"tag",get:function(){return"extLst"}}]),o}(c);S.exports=t},{"../../base-xform":31,"../../composite-xform":47}],89:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(n){this.model+=n}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"formula"}}]),t}(m);S.exports=c},{"../../base-xform":31}],90:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../base-xform"),c=e("../../composite-xform"),a=e("./cfvo-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={cfvo:o.cfvoXform=new a},o}return b(n,[{key:"render",value:function(p,O){var P=this;p.openNode(this.tag,{iconSet:m.toStringAttribute(O.iconSet,"3TrafficLights"),reverse:m.toBoolAttribute(O.reverse,!1),showValue:m.toBoolAttribute(O.showValue,!0)}),O.cfvo.forEach(function(B){P.cfvoXform.render(p,B)}),p.closeNode()}},{key:"createNewModel",value:function(p){var O=p.attributes;return{iconSet:m.toStringValue(O.iconSet,"3TrafficLights"),reverse:m.toBoolValue(O.reverse),showValue:m.toBoolValue(O.showValue),cfvo:[]}}},{key:"onParserClose",value:function(p,O){this.model[p].push(O.model)}},{key:"tag",get:function(){return"iconSet"}}]),n}(c);S.exports=r},{"../../base-xform":31,"../../composite-xform":47,"./cfvo-xform":83}],91:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"prepare",value:function(n,o){var p=o.styles.addStyleModel(n.style||{});p&&(n.styleId=p)}},{key:"render",value:function(n,o){n.openNode("col"),n.addAttribute("min",o.min),n.addAttribute("max",o.max),o.width&&n.addAttribute("width",o.width),o.styleId&&n.addAttribute("style",o.styleId),o.hidden&&n.addAttribute("hidden","1"),o.bestFit&&n.addAttribute("bestFit","1"),o.outlineLevel&&n.addAttribute("outlineLevel",o.outlineLevel),o.collapsed&&n.addAttribute("collapsed","1"),n.addAttribute("customWidth","1"),n.closeNode()}},{key:"parseOpen",value:function(n){if(n.name==="col"){var o=this.model={min:parseInt(n.attributes.min||"0",10),max:parseInt(n.attributes.max||"0",10),width:n.attributes.width===void 0?void 0:parseFloat(n.attributes.width||"0")};return n.attributes.style&&(o.styleId=parseInt(n.attributes.style,10)),(n.attributes.hidden===!0||n.attributes.hidden==="true"||n.attributes.hidden===1||n.attributes.hidden==="1")&&(o.hidden=!0),n.attributes.bestFit&&(o.bestFit=!0),n.attributes.outlineLevel&&(o.outlineLevel=parseInt(n.attributes.outlineLevel,10)),n.attributes.collapsed&&(o.collapsed=!0),!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"reconcile",value:function(n,o){n.styleId&&(n.style=o.styles.getStyleModel(n.styleId))}},{key:"tag",get:function(){return"col"}}]),t}(m);S.exports=c},{"../base-xform":31}],92:[function(e,S,_){function u(D){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(I){return typeof I}:u=function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},u(D)}function y(D,M){if(!(D instanceof M))throw new TypeError("Cannot call a class as a function")}function g(D,M){for(var I=0;I"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(D){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(I){return I.__proto__||Object.getPrototypeOf(I)},s(D)}function m(D,M){var I=Object.keys(D);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(D);M&&(T=T.filter(function(C){return Object.getOwnPropertyDescriptor(D,C).enumerable})),I.push.apply(I,T)}return I}function c(D){for(var M=1;M1||$>1){var N=E.row+(A-1),j=E.col+($-1);return c(c({},C.dataValidation),{},{sqref:"".concat(C.address,":").concat(i.encodeAddress(N,j))})}return c(c({},C.dataValidation),{},{sqref:C.address})}return null}).filter(Boolean)}var z=function(D){w(I,D);var M=v(I);function I(){return y(this,I),M.apply(this,arguments)}return b(I,[{key:"render",value:function(C,E){var A=B(E);A.length&&(C.openNode("dataValidations",{count:A.length}),A.forEach(function(L){C.openNode("dataValidation"),L.type!=="any"&&(C.addAttribute("type",L.type),L.operator&&L.type!=="list"&&L.operator!=="between"&&C.addAttribute("operator",L.operator),L.allowBlank&&C.addAttribute("allowBlank","1")),L.showInputMessage&&C.addAttribute("showInputMessage","1"),L.promptTitle&&C.addAttribute("promptTitle",L.promptTitle),L.prompt&&C.addAttribute("prompt",L.prompt),L.showErrorMessage&&C.addAttribute("showErrorMessage","1"),L.errorStyle&&C.addAttribute("errorStyle",L.errorStyle),L.errorTitle&&C.addAttribute("errorTitle",L.errorTitle),L.error&&C.addAttribute("error",L.error),C.addAttribute("sqref",L.sqref),(L.formulae||[]).forEach(function($,W){C.openNode("formula".concat(W+1)),L.type==="date"?C.writeText(t.dateToExcel(new Date($))):C.writeText($),C.closeNode()}),C.closeNode()}),C.closeNode())}},{key:"parseOpen",value:function(C){switch(C.name){case"dataValidations":return this.model={},!0;case"dataValidation":{this._address=C.attributes.sqref;var E={type:C.attributes.type||"any",formulae:[]};switch(C.attributes.type&&P(E,C.attributes,"allowBlank"),P(E,C.attributes,"showInputMessage"),P(E,C.attributes,"showErrorMessage"),E.type){case"any":case"list":case"custom":break;default:p(E,C.attributes,"operator","between");break}return p(E,C.attributes,"promptTitle"),p(E,C.attributes,"prompt"),p(E,C.attributes,"errorStyle"),p(E,C.attributes,"errorTitle"),p(E,C.attributes,"error"),this._dataValidation=E,!0}case"formula1":case"formula2":return this._formula=[],!0;default:return!1}}},{key:"parseText",value:function(C){this._formula&&this._formula.push(C)}},{key:"parseClose",value:function(C){var E=this;switch(C){case"dataValidations":return!1;case"dataValidation":{(!this._dataValidation.formulae||!this._dataValidation.formulae.length)&&(delete this._dataValidation.formulae,delete this._dataValidation.operator);var A=this._address.split(/\s+/g)||[];return A.forEach(function($){if($.includes(":")){var W=new o($);W.forEachAddress(function(U){E.model[U]=E._dataValidation})}else E.model[$]=E._dataValidation}),!0}case"formula1":case"formula2":{var L=this._formula.join("");switch(this._dataValidation.type){case"whole":case"textLength":L=parseInt(L,10);break;case"decimal":L=parseFloat(L);break;case"date":L=t.excelToDate(parseFloat(L));break}return this._dataValidation.formulae.push(L),this._formula=void 0,!0}default:return!0}}},{key:"tag",get:function(){return"dataValidations"}}]),I}(n);S.exports=z},{"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/utils":26,"../base-xform":31}],93:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode("dimension",{ref:o})}},{key:"parseOpen",value:function(n){return n.name==="dimension"?(this.model=n.attributes.ref,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"dimension"}}]),t}(m);S.exports=c},{"../base-xform":31}],94:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode(this.tag,{"r:id":o.rId})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:id"]},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"drawing"}}]),t}(m);S.exports=c},{"../base-xform":31}],95:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../composite-xform"),c=e("./cf-ext/conditional-formattings-ext-xform"),a=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"x14:conditionalFormattings":o.conditionalFormattings=new c},o}return b(n,[{key:"hasContent",value:function(p){return this.conditionalFormattings.hasContent(p.conditionalFormattings)}},{key:"prepare",value:function(p,O){this.conditionalFormattings.prepare(p.conditionalFormattings,O)}},{key:"render",value:function(p,O){p.openNode("ext",{uri:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.conditionalFormattings.render(p,O.conditionalFormattings),p.closeNode()}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(p,O){this.model[p]=O.model}},{key:"tag",get:function(){return"ext"}}]),n}(m),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={ext:o.ext=new a},o}return b(n,[{key:"prepare",value:function(p,O){this.ext.prepare(p,O)}},{key:"hasContent",value:function(p){return this.ext.hasContent(p)}},{key:"render",value:function(p,O){this.hasContent(O)&&(p.openNode("extLst"),this.ext.render(p,O),p.closeNode())}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(p,O){Object.assign(this.model,O.model)}},{key:"tag",get:function(){return"extLst"}}]),n}(m);S.exports=r},{"../composite-xform":47,"./cf-ext/conditional-formattings-ext-xform":77}],96:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){if(o){n.addRollback();var p=!1;n.openNode("headerFooter"),o.differentFirst&&(n.addAttribute("differentFirst","1"),p=!0),o.differentOddEven&&(n.addAttribute("differentOddEven","1"),p=!0),o.oddHeader&&typeof o.oddHeader=="string"&&(n.leafNode("oddHeader",null,o.oddHeader),p=!0),o.oddFooter&&typeof o.oddFooter=="string"&&(n.leafNode("oddFooter",null,o.oddFooter),p=!0),o.evenHeader&&typeof o.evenHeader=="string"&&(n.leafNode("evenHeader",null,o.evenHeader),p=!0),o.evenFooter&&typeof o.evenFooter=="string"&&(n.leafNode("evenFooter",null,o.evenFooter),p=!0),o.firstHeader&&typeof o.firstHeader=="string"&&(n.leafNode("firstHeader",null,o.firstHeader),p=!0),o.firstFooter&&typeof o.firstFooter=="string"&&(n.leafNode("firstFooter",null,o.firstFooter),p=!0),p?(n.closeNode(),n.commit()):n.rollback()}}},{key:"parseOpen",value:function(n){switch(n.name){case"headerFooter":return this.model={},n.attributes.differentFirst&&(this.model.differentFirst=parseInt(n.attributes.differentFirst,0)===1),n.attributes.differentOddEven&&(this.model.differentOddEven=parseInt(n.attributes.differentOddEven,0)===1),!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}}},{key:"parseText",value:function(n){switch(this.currentNode){case"oddHeader":this.model.oddHeader=n;break;case"oddFooter":this.model.oddFooter=n;break;case"evenHeader":this.model.evenHeader=n;break;case"evenFooter":this.model.evenFooter=n;break;case"firstHeader":this.model.firstHeader=n;break;case"firstFooter":this.model.firstFooter=n;break}}},{key:"parseClose",value:function(){switch(this.currentNode){case"oddHeader":case"oddFooter":case"evenHeader":case"evenFooter":case"firstHeader":case"firstFooter":return this.currentNode=void 0,!0;default:return!1}}},{key:"tag",get:function(){return"headerFooter"}}]),t}(m);S.exports=c},{"../base-xform":31}],97:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("hyperlink",{ref:o.address,"r:id":o.rId,tooltip:o.tooltip})}},{key:"parseOpen",value:function(n){return n.name==="hyperlink"?(this.model={address:n.attributes.ref,rId:n.attributes["r:id"],tooltip:n.attributes.tooltip},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"hyperlink"}}]),t}(m);S.exports=c},{"../base-xform":31}],98:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("mergeCell",{ref:o})}},{key:"parseOpen",value:function(n){return n.name==="mergeCell"?(this.model=n.attributes.ref,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"mergeCell"}}]),t}(m);S.exports=c},{"../base-xform":31}],99:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=function(t){return typeof t<"u"},a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){return p&&(c(p.summaryBelow)||c(p.summaryRight))?(o.leafNode(this.tag,{summaryBelow:c(p.summaryBelow)?Number(p.summaryBelow):void 0,summaryRight:c(p.summaryRight)?Number(p.summaryRight):void 0}),!0):!1}},{key:"parseOpen",value:function(o){return o.name===this.tag?(this.model={summaryBelow:c(o.attributes.summaryBelow)?!!Number(o.attributes.summaryBelow):void 0,summaryRight:c(o.attributes.summaryRight)?!!Number(o.attributes.summaryRight):void 0},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"outlinePr"}}]),i}(m);S.exports=a},{"../base-xform":31}],101:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("brk",o)}},{key:"parseOpen",value:function(n){return n.name==="brk"?(this.model=n.attributes.ref,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"brk"}}]),t}(m);S.exports=c},{"../base-xform":31}],102:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/under-dash"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){if(p){var O={left:p.left,right:p.right,top:p.top,bottom:p.bottom,header:p.header,footer:p.footer};m.some(O,function(P){return P!==void 0})&&o.leafNode(this.tag,O)}}},{key:"parseOpen",value:function(o){switch(o.name){case this.tag:return this.model={left:parseFloat(o.attributes.left||.7),right:parseFloat(o.attributes.right||.7),top:parseFloat(o.attributes.top||.75),bottom:parseFloat(o.attributes.bottom||.75),header:parseFloat(o.attributes.header||.3),footer:parseFloat(o.attributes.footer||.3)},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"pageMargins"}}]),i}(c);S.exports=a},{"../../../utils/under-dash":25,"../base-xform":31}],103:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){return o&&o.fitToPage?(n.leafNode(this.tag,{fitToPage:o.fitToPage?"1":void 0}),!0):!1}},{key:"parseOpen",value:function(n){return n.name===this.tag?(this.model={fitToPage:n.attributes.fitToPage==="1"},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"pageSetUpPr"}}]),t}(m);S.exports=c},{"../base-xform":31}],104:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,O){if(!(p instanceof O))throw new TypeError("Cannot call a class as a function")}function g(p,O){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("../../../utils/under-dash"),c=e("../base-xform");function a(p){return p?"1":void 0}function r(p){switch(p){case"overThenDown":return p;default:return}}function t(p){switch(p){case"atEnd":case"asDisplyed":return p;default:return}}function i(p){switch(p){case"dash":case"blank":case"NA":return p;default:return}}function n(p){return p!==void 0?parseInt(p,10):void 0}var o=function(p){w(P,p);var O=v(P);function P(){return y(this,P),O.apply(this,arguments)}return b(P,[{key:"render",value:function(z,D){if(D){var M={paperSize:D.paperSize,orientation:D.orientation,horizontalDpi:D.horizontalDpi,verticalDpi:D.verticalDpi,pageOrder:r(D.pageOrder),blackAndWhite:a(D.blackAndWhite),draft:a(D.draft),cellComments:t(D.cellComments),errors:i(D.errors),scale:D.scale,fitToWidth:D.fitToWidth,fitToHeight:D.fitToHeight,firstPageNumber:D.firstPageNumber,useFirstPageNumber:a(D.firstPageNumber),usePrinterDefaults:a(D.usePrinterDefaults),copies:D.copies};m.some(M,function(I){return I!==void 0})&&z.leafNode(this.tag,M)}}},{key:"parseOpen",value:function(z){switch(z.name){case this.tag:return this.model={paperSize:n(z.attributes.paperSize),orientation:z.attributes.orientation||"portrait",horizontalDpi:parseInt(z.attributes.horizontalDpi||"4294967295",10),verticalDpi:parseInt(z.attributes.verticalDpi||"4294967295",10),pageOrder:z.attributes.pageOrder||"downThenOver",blackAndWhite:z.attributes.blackAndWhite==="1",draft:z.attributes.draft==="1",cellComments:z.attributes.cellComments||"None",errors:z.attributes.errors||"displayed",scale:parseInt(z.attributes.scale||"100",10),fitToWidth:parseInt(z.attributes.fitToWidth||"1",10),fitToHeight:parseInt(z.attributes.fitToHeight||"1",10),firstPageNumber:parseInt(z.attributes.firstPageNumber||"1",10),useFirstPageNumber:z.attributes.useFirstPageNumber==="1",usePrinterDefaults:z.attributes.usePrinterDefaults==="1",copies:parseInt(z.attributes.copies||"1",10)},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"pageSetup"}}]),P}(c);S.exports=o},{"../../../utils/under-dash":25,"../base-xform":31}],105:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode(this.tag,{"r:id":o.rId})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:id"]},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"picture"}}]),t}(m);S.exports=c},{"../base-xform":31}],106:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/under-dash"),c=e("../base-xform");function a(t){return t?"1":void 0}var r=function(t){w(n,t);var i=v(n);function n(){return y(this,n),i.apply(this,arguments)}return b(n,[{key:"render",value:function(p,O){if(O){var P={headings:a(O.showRowColHeaders),gridLines:a(O.showGridLines),horizontalCentered:a(O.horizontalCentered),verticalCentered:a(O.verticalCentered)};m.some(P,function(B){return B!==void 0})&&p.leafNode(this.tag,P)}}},{key:"parseOpen",value:function(p){switch(p.name){case this.tag:return this.model={showRowColHeaders:p.attributes.headings==="1",showGridLines:p.attributes.gridLines==="1",horizontalCentered:p.attributes.horizontalCentered==="1",verticalCentered:p.attributes.verticalCentered==="1"},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"printOptions"}}]),n}(c);S.exports=r},{"../../../utils/under-dash":25,"../base-xform":31}],107:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("./page-breaks-xform"),c=e("../list-xform"),a=function(r){w(i,r);var t=v(i);function i(){y(this,i);var n={tag:"rowBreaks",count:!0,childXform:new m};return t.call(this,n)}return b(i,[{key:"render",value:function(o,p){if(p&&p.length){o.openNode(this.tag,this.$),this.count&&(o.addAttribute(this.$count,p.length),o.addAttribute("manualBreakCount",p.length));var O=this.childXform;p.forEach(function(P){O.render(o,P)}),o.closeNode()}else this.empty&&o.leafNode(this.tag)}}]),i}(c);S.exports=a},{"../list-xform":70,"./page-breaks-xform":101}],108:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("./cell-xform"),a=function(r){w(i,r);var t=v(i);function i(n){var o;return y(this,i),o=t.call(this),o.maxItems=n&&n.maxItems,o.map={c:new c},o}return b(i,[{key:"prepare",value:function(o,p){var O=p.styles.addStyleModel(o.style);O&&(o.styleId=O);var P=this.map.c;o.cells.forEach(function(B){P.prepare(B,p)})}},{key:"render",value:function(o,p,O){o.openNode("row"),o.addAttribute("r",p.number),p.height&&(o.addAttribute("ht",p.height),o.addAttribute("customHeight","1")),p.hidden&&o.addAttribute("hidden","1"),p.min>0&&p.max>0&&p.min<=p.max&&o.addAttribute("spans","".concat(p.min,":").concat(p.max)),p.styleId&&(o.addAttribute("s",p.styleId),o.addAttribute("customFormat","1")),o.addAttribute("x14ac:dyDescent","0.25"),p.outlineLevel&&o.addAttribute("outlineLevel",p.outlineLevel),p.collapsed&&o.addAttribute("collapsed","1");var P=this.map.c;p.cells.forEach(function(B){P.render(o,B,O)}),o.closeNode()}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;if(o.name==="row"){this.numRowsSeen+=1;var p=o.attributes.spans?o.attributes.spans.split(":").map(function(P){return parseInt(P,10)}):[void 0,void 0],O=this.model={number:parseInt(o.attributes.r,10),min:p[0],max:p[1],cells:[]};return o.attributes.s&&(O.styleId=parseInt(o.attributes.s,10)),(o.attributes.hidden===!0||o.attributes.hidden==="true"||o.attributes.hidden===1||o.attributes.hidden==="1")&&(O.hidden=!0),o.attributes.bestFit&&(O.bestFit=!0),o.attributes.ht&&(O.height=parseFloat(o.attributes.ht)),o.attributes.outlineLevel&&(O.outlineLevel=parseInt(o.attributes.outlineLevel,10)),o.attributes.collapsed&&(O.collapsed=!0),!0}return this.parser=this.map[o.name],this.parser?(this.parser.parseOpen(o),!0):!1}},{key:"parseText",value:function(o){this.parser&&this.parser.parseText(o)}},{key:"parseClose",value:function(o){if(this.parser){if(!this.parser.parseClose(o)){if(this.model.cells.push(this.parser.model),this.maxItems&&this.model.cells.length>this.maxItems)throw new Error("Max column count (".concat(this.maxItems,") exceeded"));this.parser=void 0}return!0}return!1}},{key:"reconcile",value:function(o,p){o.style=o.styleId?p.styles.getStyleModel(o.styleId):{},o.styleId!==void 0&&(o.styleId=void 0);var O=this.map.c;o.cells.forEach(function(P){O.reconcile(P,p)})}},{key:"tag",get:function(){return"row"}}]),i}(m);S.exports=a},{"../base-xform":31,"./cell-xform":72}],109:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/under-dash"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){if(p){var O={defaultRowHeight:p.defaultRowHeight,outlineLevelRow:p.outlineLevelRow,outlineLevelCol:p.outlineLevelCol,"x14ac:dyDescent":p.dyDescent};p.defaultColWidth&&(O.defaultColWidth=p.defaultColWidth),(!p.defaultRowHeight||p.defaultRowHeight!==15)&&(O.customHeight="1"),m.some(O,function(P){return P!==void 0})&&o.leafNode("sheetFormatPr",O)}}},{key:"parseOpen",value:function(o){return o.name==="sheetFormatPr"?(this.model={defaultRowHeight:parseFloat(o.attributes.defaultRowHeight||"0"),dyDescent:parseFloat(o.attributes["x14ac:dyDescent"]||"0"),outlineLevelRow:parseInt(o.attributes.outlineLevelRow||"0",10),outlineLevelCol:parseInt(o.attributes.outlineLevelCol||"0",10)},o.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(o.attributes.defaultColWidth)),!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"sheetFormatPr"}}]),i}(c);S.exports=a},{"../../../utils/under-dash":25,"../base-xform":31}],110:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../base-xform"),c=e("../style/color-xform"),a=e("./page-setup-properties-xform"),r=e("./outline-properties-xform"),t=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={tabColor:new c("tabColor"),pageSetUpPr:new a,outlinePr:new r},p}return b(o,[{key:"render",value:function(O,P){if(P){O.addRollback(),O.openNode("sheetPr");var B=!1;B=this.map.tabColor.render(O,P.tabColor)||B,B=this.map.pageSetUpPr.render(O,P.pageSetup)||B,B=this.map.outlinePr.render(O,P.outlineProperties)||B,B?(O.closeNode(),O.commit()):O.rollback()}}},{key:"parseOpen",value:function(O){return this.parser?(this.parser.parseOpen(O),!0):O.name===this.tag?(this.reset(),!0):this.map[O.name]?(this.parser=this.map[O.name],this.parser.parseOpen(O),!0):!1}},{key:"parseText",value:function(O){return this.parser?(this.parser.parseText(O),!0):!1}},{key:"parseClose",value:function(O){return this.parser?(this.parser.parseClose(O)||(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)}},{key:"tag",get:function(){return"sheetPr"}}]),o}(m);S.exports=t},{"../base-xform":31,"../style/color-xform":127,"./outline-properties-xform":100,"./page-setup-properties-xform":103}],111:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../../../utils/under-dash"),c=e("../base-xform");function a(i,n){return i?n:void 0}function r(i,n){return i===n?!0:void 0}var t=function(i){w(o,i);var n=v(o);function o(){return y(this,o),n.apply(this,arguments)}return b(o,[{key:"render",value:function(O,P){if(P){var B={sheet:a(P.sheet,"1"),selectLockedCells:P.selectLockedCells===!1?"1":void 0,selectUnlockedCells:P.selectUnlockedCells===!1?"1":void 0,formatCells:a(P.formatCells,"0"),formatColumns:a(P.formatColumns,"0"),formatRows:a(P.formatRows,"0"),insertColumns:a(P.insertColumns,"0"),insertRows:a(P.insertRows,"0"),insertHyperlinks:a(P.insertHyperlinks,"0"),deleteColumns:a(P.deleteColumns,"0"),deleteRows:a(P.deleteRows,"0"),sort:a(P.sort,"0"),autoFilter:a(P.autoFilter,"0"),pivotTables:a(P.pivotTables,"0")};P.sheet&&(B.algorithmName=P.algorithmName,B.hashValue=P.hashValue,B.saltValue=P.saltValue,B.spinCount=P.spinCount,B.objects=a(P.objects===!1,"1"),B.scenarios=a(P.scenarios===!1,"1")),m.some(B,function(z){return z!==void 0})&&O.leafNode(this.tag,B)}}},{key:"parseOpen",value:function(O){switch(O.name){case this.tag:return this.model={sheet:r(O.attributes.sheet,"1"),objects:O.attributes.objects==="1"?!1:void 0,scenarios:O.attributes.scenarios==="1"?!1:void 0,selectLockedCells:O.attributes.selectLockedCells==="1"?!1:void 0,selectUnlockedCells:O.attributes.selectUnlockedCells==="1"?!1:void 0,formatCells:r(O.attributes.formatCells,"0"),formatColumns:r(O.attributes.formatColumns,"0"),formatRows:r(O.attributes.formatRows,"0"),insertColumns:r(O.attributes.insertColumns,"0"),insertRows:r(O.attributes.insertRows,"0"),insertHyperlinks:r(O.attributes.insertHyperlinks,"0"),deleteColumns:r(O.attributes.deleteColumns,"0"),deleteRows:r(O.attributes.deleteRows,"0"),sort:r(O.attributes.sort,"0"),autoFilter:r(O.attributes.autoFilter,"0"),pivotTables:r(O.attributes.pivotTables,"0")},O.attributes.algorithmName&&(this.model.algorithmName=O.attributes.algorithmName,this.model.hashValue=O.attributes.hashValue,this.model.saltValue=O.attributes.saltValue,this.model.spinCount=parseInt(O.attributes.spinCount,10)),!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"sheetProtection"}}]),o}(c);S.exports=t},{"../../../utils/under-dash":25,"../base-xform":31}],112:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/col-cache"),c=e("../base-xform"),a={frozen:"frozen",frozenSplit:"frozen",split:"split"},r=function(t){w(n,t);var i=v(n);function n(){return y(this,n),i.apply(this,arguments)}return b(n,[{key:"prepare",value:function(p){switch(p.state){case"frozen":case"split":break;default:p.state="normal";break}}},{key:"render",value:function(p,O){p.openNode("sheetView",{workbookViewId:O.workbookViewId||0});var P=function(T,C,E){E&&p.addAttribute(T,C)};P("rightToLeft","1",O.rightToLeft===!0),P("tabSelected","1",O.tabSelected),P("showRuler","0",O.showRuler===!1),P("showRowColHeaders","0",O.showRowColHeaders===!1),P("showGridLines","0",O.showGridLines===!1),P("zoomScale",O.zoomScale,O.zoomScale),P("zoomScaleNormal",O.zoomScaleNormal,O.zoomScaleNormal),P("view",O.style,O.style);var B,z,D,M;switch(O.state){case"frozen":z=O.xSplit||0,D=O.ySplit||0,B=O.topLeftCell||m.getAddress(D+1,z+1).address,M=O.xSplit&&O.ySplit&&"bottomRight"||O.xSplit&&"topRight"||"bottomLeft",p.leafNode("pane",{xSplit:O.xSplit||void 0,ySplit:O.ySplit||void 0,topLeftCell:B,activePane:M,state:"frozen"}),p.leafNode("selection",{pane:M,activeCell:O.activeCell,sqref:O.activeCell});break;case"split":O.activePane==="topLeft"&&(O.activePane=void 0),p.leafNode("pane",{xSplit:O.xSplit||void 0,ySplit:O.ySplit||void 0,topLeftCell:O.topLeftCell,activePane:O.activePane}),p.leafNode("selection",{pane:O.activePane,activeCell:O.activeCell,sqref:O.activeCell});break;case"normal":O.activeCell&&p.leafNode("selection",{activeCell:O.activeCell,sqref:O.activeCell});break}p.closeNode()}},{key:"parseOpen",value:function(p){switch(p.name){case"sheetView":return this.sheetView={workbookViewId:parseInt(p.attributes.workbookViewId,10),rightToLeft:p.attributes.rightToLeft==="1",tabSelected:p.attributes.tabSelected==="1",showRuler:p.attributes.showRuler!=="0",showRowColHeaders:p.attributes.showRowColHeaders!=="0",showGridLines:p.attributes.showGridLines!=="0",zoomScale:parseInt(p.attributes.zoomScale||"100",10),zoomScaleNormal:parseInt(p.attributes.zoomScaleNormal||"100",10),style:p.attributes.view},this.pane=void 0,this.selections={},!0;case"pane":return this.pane={xSplit:parseInt(p.attributes.xSplit||"0",10),ySplit:parseInt(p.attributes.ySplit||"0",10),topLeftCell:p.attributes.topLeftCell,activePane:p.attributes.activePane||"topLeft",state:p.attributes.state},!0;case"selection":{var O=p.attributes.pane||"topLeft";return this.selections[O]={pane:O,activeCell:p.attributes.activeCell},!0}default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){var O,P;switch(p){case"sheetView":return this.sheetView&&this.pane?(O=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:a[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},this.model.state==="split"&&(O.activePane=this.pane.activePane),P=this.selections[this.pane.activePane],P&&P.activeCell&&(O.activeCell=P.activeCell),this.sheetView.style&&(O.style=this.sheetView.style)):(O=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},P=this.selections.topLeft,P&&P.activeCell&&(O.activeCell=P.activeCell),this.sheetView.style&&(O.style=this.sheetView.style)),!1;default:return!0}}},{key:"reconcile",value:function(){}},{key:"tag",get:function(){return"sheetView"}}]),n}(c);S.exports=r},{"../../../utils/col-cache":19,"../base-xform":31}],113:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode(this.tag,{"r:id":o.rId})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:id"]},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"tablePart"}}]),t}(m);S.exports=c},{"../base-xform":31}],114:[function(e,S,_){function u(ye){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(oe){return typeof oe}:u=function(oe){return oe&&typeof Symbol=="function"&&oe.constructor===Symbol&&oe!==Symbol.prototype?"symbol":typeof oe},u(ye)}function y(ye,ge){if(!(ye instanceof ge))throw new TypeError("Cannot call a class as a function")}function g(ye,ge){for(var oe=0;oe"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(ye){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(oe){return oe.__proto__||Object.getPrototypeOf(oe)},s(ye)}var m=e("../../../utils/under-dash"),c=e("../../../utils/col-cache"),a=e("../../../utils/xml-stream"),r=e("../../rel-type"),t=e("./merges"),i=e("../base-xform"),n=e("../list-xform"),o=e("./row-xform"),p=e("./col-xform"),O=e("./dimension-xform"),P=e("./hyperlink-xform"),B=e("./merge-cell-xform"),z=e("./data-validations-xform"),D=e("./sheet-properties-xform"),M=e("./sheet-format-properties-xform"),I=e("./sheet-view-xform"),T=e("./sheet-protection-xform"),C=e("./page-margins-xform"),E=e("./page-setup-xform"),A=e("./print-options-xform"),L=e("./auto-filter-xform"),$=e("./picture-xform"),W=e("./drawing-xform"),U=e("./table-part-xform"),N=e("./row-breaks-xform"),j=e("./header-footer-xform"),F=e("./cf/conditional-formattings-xform"),V=e("./ext-lst-xform"),re=function(ge,oe){Object.keys(oe).forEach(function(J){var Q=ge[J],he=oe[J];Q===void 0&&he!==void 0&&(ge[J]=he)})},ee=function(ge,oe){if(!oe||!oe.length)return ge;if(!ge||!ge.length)return oe;var J={},Q={};return ge.forEach(function(he){J[he.ref]=he,he.rules.forEach(function(xe){var ne=xe.x14Id;ne&&(Q[ne]=xe)})}),oe.forEach(function(he){he.rules.forEach(function(xe){var ne=Q[xe.x14Id];ne?re(ne,xe):J[he.ref]?J[he.ref].rules.push(xe):ge.push({ref:he.ref,rules:[xe]})})}),ge},ce=function(ye){w(oe,ye);var ge=v(oe);function oe(J){var Q;y(this,oe),Q=ge.call(this);var he=J||{},xe=he.maxRows,ne=he.maxCols;return Q.map={sheetPr:new D,dimension:new O,sheetViews:new n({tag:"sheetViews",count:!1,childXform:new I}),sheetFormatPr:new M,cols:new n({tag:"cols",count:!1,childXform:new p}),sheetData:new n({tag:"sheetData",count:!1,empty:!0,childXform:new o({maxItems:ne}),maxItems:xe}),autoFilter:new L,mergeCells:new n({tag:"mergeCells",count:!0,childXform:new B}),rowBreaks:new N,hyperlinks:new n({tag:"hyperlinks",count:!1,childXform:new P}),pageMargins:new C,dataValidations:new z,pageSetup:new E,headerFooter:new j,printOptions:new A,picture:new $,drawing:new W,sheetProtection:new T,tableParts:new n({tag:"tableParts",count:!0,childXform:new U}),conditionalFormatting:new F,extLst:new V},Q}return b(oe,[{key:"prepare",value:function(Q,he){var xe=this;he.merges=new t,Q.hyperlinks=he.hyperlinks=[],Q.comments=he.comments=[],he.formulae={},he.siFormulae=0,this.map.cols.prepare(Q.cols,he),this.map.sheetData.prepare(Q.rows,he),this.map.conditionalFormatting.prepare(Q.conditionalFormattings,he),Q.mergeCells=he.merges.mergeCells;var ne=Q.rels=[];function se(fe){return"rId".concat(fe.length+1)}if(Q.hyperlinks.forEach(function(fe){var we=se(ne);fe.rId=we,ne.push({Id:we,Type:r.Hyperlink,Target:fe.target,TargetMode:"External"})}),Q.comments.length>0){var Ce={Id:se(ne),Type:r.Comments,Target:"../comments".concat(Q.id,".xml")};ne.push(Ce);var q={Id:se(ne),Type:r.VmlDrawing,Target:"../drawings/vmlDrawing".concat(Q.id,".vml")};ne.push(q),Q.comments.forEach(function(fe){fe.refAddress=c.decodeAddress(fe.ref)}),he.commentRefs.push({commentName:"comments".concat(Q.id),vmlDrawing:"vmlDrawing".concat(Q.id)})}var G=[],Y;Q.media.forEach(function(fe){if(fe.type==="background"){var we=se(ne);Y=he.media[fe.imageId],ne.push({Id:we,Type:r.Image,Target:"../media/".concat(Y.name,".").concat(Y.extension)}),Q.background={rId:we},Q.image=he.media[fe.imageId]}else if(fe.type==="image"){var _e=Q.drawing;Y=he.media[fe.imageId],_e||(_e=Q.drawing={rId:se(ne),name:"drawing".concat(++he.drawingsCount),anchors:[],rels:[]},he.drawings.push(_e),ne.push({Id:_e.rId,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",Target:"../drawings/".concat(_e.name,".xml")}));var je=xe.preImageId===fe.imageId?G[fe.imageId]:G[_e.rels.length];je||(je=se(_e.rels),G[_e.rels.length]=je,_e.rels.push({Id:je,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",Target:"../media/".concat(Y.name,".").concat(Y.extension)}));var Ye={picture:{rId:je},range:fe.range};if(fe.hyperlinks&&fe.hyperlinks.hyperlink){var nt=se(_e.rels);G[_e.rels.length]=nt,Ye.picture.hyperlinks={tooltip:fe.hyperlinks.tooltip,rId:nt},_e.rels.push({Id:nt,Type:r.Hyperlink,Target:fe.hyperlinks.hyperlink,TargetMode:"External"})}xe.preImageId=fe.imageId,_e.anchors.push(Ye)}}),Q.tables.forEach(function(fe){var we=se(ne);fe.rId=we,ne.push({Id:we,Type:r.Table,Target:"../tables/".concat(fe.target)}),fe.columns.forEach(function(_e){var je=_e.style;je&&(_e.dxfId=he.styles.addDxfStyle(je))})}),this.map.extLst.prepare(Q,he)}},{key:"render",value:function(Q,he){Q.openXml(a.StdDocAttributes),Q.openNode("worksheet",oe.WORKSHEET_ATTRIBUTES);var xe=he.properties?{defaultRowHeight:he.properties.defaultRowHeight,dyDescent:he.properties.dyDescent,outlineLevelCol:he.properties.outlineLevelCol,outlineLevelRow:he.properties.outlineLevelRow}:void 0;he.properties&&he.properties.defaultColWidth&&(xe.defaultColWidth=he.properties.defaultColWidth);var ne={outlineProperties:he.properties&&he.properties.outlineProperties,tabColor:he.properties&&he.properties.tabColor,pageSetup:he.pageSetup&&he.pageSetup.fitToPage?{fitToPage:he.pageSetup.fitToPage}:void 0},se=he.pageSetup&&he.pageSetup.margins,Ce={showRowColHeaders:he.pageSetup&&he.pageSetup.showRowColHeaders,showGridLines:he.pageSetup&&he.pageSetup.showGridLines,horizontalCentered:he.pageSetup&&he.pageSetup.horizontalCentered,verticalCentered:he.pageSetup&&he.pageSetup.verticalCentered},q=he.sheetProtection;this.map.sheetPr.render(Q,ne),this.map.dimension.render(Q,he.dimensions),this.map.sheetViews.render(Q,he.views),this.map.sheetFormatPr.render(Q,xe),this.map.cols.render(Q,he.cols),this.map.sheetData.render(Q,he.rows),this.map.sheetProtection.render(Q,q),this.map.autoFilter.render(Q,he.autoFilter),this.map.mergeCells.render(Q,he.mergeCells),this.map.conditionalFormatting.render(Q,he.conditionalFormattings),this.map.dataValidations.render(Q,he.dataValidations),this.map.hyperlinks.render(Q,he.hyperlinks),this.map.printOptions.render(Q,Ce),this.map.pageMargins.render(Q,se),this.map.pageSetup.render(Q,he.pageSetup),this.map.headerFooter.render(Q,he.headerFooter),this.map.rowBreaks.render(Q,he.rowBreaks),this.map.drawing.render(Q,he.drawing),this.map.picture.render(Q,he.background),this.map.tableParts.render(Q,he.tables),this.map.extLst.render(Q,he),he.rels&&he.rels.forEach(function(G){G.Type===r.VmlDrawing&&Q.leafNode("legacyDrawing",{"r:id":G.Id})}),Q.closeNode()}},{key:"parseOpen",value:function(Q){return this.parser?(this.parser.parseOpen(Q),!0):Q.name==="worksheet"?(m.each(this.map,function(he){he.reset()}),!0):(this.parser=this.map[Q.name],this.parser&&this.parser.parseOpen(Q),!0)}},{key:"parseText",value:function(Q){this.parser&&this.parser.parseText(Q)}},{key:"parseClose",value:function(Q){if(this.parser)return this.parser.parseClose(Q)||(this.parser=void 0),!0;switch(Q){case"worksheet":{var he=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(he.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(he.outlineProperties=this.map.sheetPr.model.outlineProperties);var xe={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},ne=Object.assign(xe,this.map.pageSetup.model,this.map.printOptions.model),se=ee(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:he,views:this.map.sheetViews.model,pageSetup:ne,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:se},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}default:return!0}}},{key:"reconcile",value:function(Q,he){var xe=(Q.relationships||[]).reduce(function(we,_e){if(we[_e.Id]=_e,_e.Type===r.Comments&&(Q.comments=he.comments[_e.Target].comments),_e.Type===r.VmlDrawing&&Q.comments&&Q.comments.length){var je=he.vmlDrawings[_e.Target].comments;Q.comments.forEach(function(Ye,nt){Ye.note=Object.assign({},Ye.note,je[nt])})}return we},{});if(he.commentsMap=(Q.comments||[]).reduce(function(we,_e){return _e.ref&&(we[_e.ref]=_e),we},{}),he.hyperlinkMap=(Q.hyperlinks||[]).reduce(function(we,_e){return _e.rId&&(we[_e.address]=xe[_e.rId].Target),we},{}),he.formulae={},Q.rows=Q.rows&&Q.rows.filter(Boolean)||[],Q.rows.forEach(function(we){we.cells=we.cells&&we.cells.filter(Boolean)||[]}),this.map.cols.reconcile(Q.cols,he),this.map.sheetData.reconcile(Q.rows,he),this.map.conditionalFormatting.reconcile(Q.conditionalFormattings,he),Q.media=[],Q.drawing){var ne=xe[Q.drawing.rId],se=ne.Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(se){var Ce=se[1],q=he.drawings[Ce];q.anchors.forEach(function(we){if(we.medium){var _e={type:"image",imageId:we.medium.index,range:we.range,hyperlinks:we.picture.hyperlinks};Q.media.push(_e)}})}}var G=Q.background&&xe[Q.background.rId];if(G){var Y=G.Target.split("/media/")[1],fe=he.mediaIndex&&he.mediaIndex[Y];fe!==void 0&&Q.media.push({type:"background",imageId:fe})}Q.tables=(Q.tables||[]).map(function(we){var _e=xe[we.rId];return he.tables[_e.Target]}),delete Q.relationships,delete Q.hyperlinks,delete Q.comments}}]),oe}(i);ce.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"},S.exports=ce},{"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/xml-stream":27,"../../rel-type":30,"../base-xform":31,"../list-xform":70,"./auto-filter-xform":71,"./cf/conditional-formattings-xform":86,"./col-xform":91,"./data-validations-xform":92,"./dimension-xform":93,"./drawing-xform":94,"./ext-lst-xform":95,"./header-footer-xform":96,"./hyperlink-xform":97,"./merge-cell-xform":98,"./merges":99,"./page-margins-xform":102,"./page-setup-xform":104,"./picture-xform":105,"./print-options-xform":106,"./row-breaks-xform":107,"./row-xform":108,"./sheet-format-properties-xform":109,"./sheet-properties-xform":110,"./sheet-protection-xform":111,"./sheet-view-xform":112,"./table-part-xform":113}],115:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n}return b(t,[{key:"render",value:function(n,o){o&&(n.openNode(this.tag),n.closeNode())}},{key:"parseOpen",value:function(n){n.name===this.tag&&(this.model=!0)}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],116:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n.attrs=i.attrs,n._format=i.format||function(o){try{return Number.isNaN(o.getTime())?"":o.toISOString()}catch{return""}},n._parse=i.parse||function(o){return new Date(o)},n}return b(t,[{key:"render",value:function(n,o){o&&(n.openNode(this.tag),this.attrs&&n.addAttributes(this.attrs),this.attr?n.addAttribute(this.attr,this._format(o)):n.writeText(this._format(o)),n.closeNode())}},{key:"parseOpen",value:function(n){n.name===this.tag&&(this.attr?this.model=this._parse(n.attributes[this.attr]):this.text=[])}},{key:"parseText",value:function(n){this.attr||this.text.push(n)}},{key:"parseClose",value:function(){return this.attr||(this.model=this._parse(this.text.join(""))),!1}}]),t}(m);S.exports=c},{"../base-xform":31}],117:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n.attrs=i.attrs,n.zero=i.zero,n}return b(t,[{key:"render",value:function(n,o){(o||this.zero)&&(n.openNode(this.tag),this.attrs&&n.addAttributes(this.attrs),this.attr?n.addAttribute(this.attr,o):n.writeText(o),n.closeNode())}},{key:"parseOpen",value:function(n){return n.name===this.tag?(this.attr?this.model=parseInt(n.attributes[this.attr],10):this.text=[],!0):!1}},{key:"parseText",value:function(n){this.attr||this.text.push(n)}},{key:"parseClose",value:function(){return this.attr||(this.model=parseInt(this.text.join("")||0,10)),!1}}]),t}(m);S.exports=c},{"../base-xform":31}],118:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n.attrs=i.attrs,n}return b(t,[{key:"render",value:function(n,o){o!==void 0&&(n.openNode(this.tag),this.attrs&&n.addAttributes(this.attrs),this.attr?n.addAttribute(this.attr,o):n.writeText(o),n.closeNode())}},{key:"parseOpen",value:function(n){n.name===this.tag&&(this.attr?this.model=n.attributes[this.attr]:this.text=[])}},{key:"parseText",value:function(n){this.attr||this.text.push(n)}},{key:"parseClose",value:function(){return this.attr||(this.model=this.text.join("")),!1}}]),t}(m);S.exports=c},{"../base-xform":31}],119:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("./base-xform"),c=e("../../utils/xml-stream");function a(t,i){t.openNode(i.tag,i.$),i.c&&i.c.forEach(function(n){a(t,n)}),i.t&&t.writeText(i.t),t.closeNode()}var r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p._model=o,p}return b(n,[{key:"render",value:function(p){if(!this._xml){var O=new c;a(O,this._model),this._xml=O.xml}p.writeXml(this._xml)}},{key:"parseOpen",value:function(){return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){switch(p){case this._model.tag:return!1;default:return!0}}}]),n}(m);S.exports=r},{"../../utils/xml-stream":27,"./base-xform":31}],120:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("./text-xform"),c=e("./rich-text-xform"),a=e("../base-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={r:new c,t:new m},o}return b(n,[{key:"render",value:function(p,O){if(p.openNode(this.tag,{sb:O.sb||0,eb:O.eb||0}),O&&O.hasOwnProperty("richText")&&O.richText){var P=this.map.r;O.richText.forEach(function(B){P.render(p,B)})}else O&&this.map.t.render(p,O.text);p.closeNode()}},{key:"parseOpen",value:function(p){var O=p.name;return this.parser?(this.parser.parseOpen(p),!0):O===this.tag?(this.model={sb:parseInt(p.attributes.sb,10),eb:parseInt(p.attributes.eb,10)},!0):(this.parser=this.map[O],this.parser?(this.parser.parseOpen(p),!0):!1)}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser){if(!this.parser.parseClose(p)){switch(p){case"r":{var O=this.model.richText;O||(O=this.model.richText=[]),O.push(this.parser.model);break}case"t":this.model.text=this.parser.model;break}this.parser=void 0}return!0}switch(p){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"rPh"}}]),n}(a);S.exports=r},{"../base-xform":31,"./rich-text-xform":121,"./text-xform":124}],121:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("./text-xform"),c=e("../style/font-xform"),a=e("../base-xform"),r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p.model=o,p}return b(n,[{key:"render",value:function(p,O){O=O||this.model,p.openNode("r"),O.font&&this.fontXform.render(p,O.font),this.textXform.render(p,O.text),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"r":return this.model={},!0;case"t":return this.parser=this.textXform,this.parser.parseOpen(p),!0;case"rPr":return this.parser=this.fontXform,this.parser.parseOpen(p),!0;default:return!1}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){switch(p){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(p),!0}}},{key:"tag",get:function(){return"r"}},{key:"textXform",get:function(){return this._textXform||(this._textXform=new m)}},{key:"fontXform",get:function(){return this._fontXform||(this._fontXform=new c(n.FONT_OPTIONS))}}]),n}(a);r.FONT_OPTIONS={tagName:"rPr",fontNameTag:"rFont"},S.exports=r},{"../base-xform":31,"../style/font-xform":130,"./text-xform":124}],122:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("./text-xform"),c=e("./rich-text-xform"),a=e("./phonetic-text-xform"),r=e("../base-xform"),t=function(i){w(o,i);var n=v(o);function o(p){var O;return y(this,o),O=n.call(this),O.model=p,O.map={r:new c,t:new m,rPh:new a},O}return b(o,[{key:"render",value:function(O,P){var B=this;O.openNode(this.tag),P&&P.hasOwnProperty("richText")&&P.richText?P.richText.length?P.richText.forEach(function(z){B.map.r.render(O,z)}):this.map.t.render(O,""):P!=null&&this.map.t.render(O,P),O.closeNode()}},{key:"parseOpen",value:function(O){var P=O.name;return this.parser?(this.parser.parseOpen(O),!0):P===this.tag?(this.model={},!0):(this.parser=this.map[P],this.parser?(this.parser.parseOpen(O),!0):!1)}},{key:"parseText",value:function(O){this.parser&&this.parser.parseText(O)}},{key:"parseClose",value:function(O){if(this.parser){if(!this.parser.parseClose(O)){switch(O){case"r":{var P=this.model.richText;P||(P=this.model.richText=[]),P.push(this.parser.model);break}case"t":this.model=this.parser.model;break}this.parser=void 0}return!0}switch(O){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"si"}}]),o}(r);S.exports=t},{"../base-xform":31,"./phonetic-text-xform":120,"./rich-text-xform":121,"./text-xform":124}],123:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("./shared-string-xform"),r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p.model=o||{values:[],count:0},p.hash=Object.create(null),p.rich=Object.create(null),p}return b(n,[{key:"getString",value:function(p){return this.model.values[p]}},{key:"add",value:function(p){return p.richText?this.addRichText(p):this.addText(p)}},{key:"addText",value:function(p){var O=this.hash[p];return O===void 0&&(O=this.hash[p]=this.model.values.length,this.model.values.push(p)),this.model.count++,O}},{key:"addRichText",value:function(p){var O=this.sharedStringXform.toXml(p),P=this.rich[O];return P===void 0&&(P=this.rich[O]=this.model.values.length,this.model.values.push(p)),this.model.count++,P}},{key:"render",value:function(p,O){O=O||this._values,p.openXml(m.StdDocAttributes),p.openNode("sst",{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",count:O.count,uniqueCount:O.values.length});var P=this.sharedStringXform;O.values.forEach(function(B){P.render(p,B)}),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"sst":return!0;case"si":return this.parser=this.sharedStringXform,this.parser.parseOpen(p),!0;default:throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(p)))}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;switch(p){case"sst":return!1;default:throw new Error("Unexpected xml node in parseClose: ".concat(p))}}},{key:"sharedStringXform",get:function(){return this._sharedStringXform||(this._sharedStringXform=new a)}},{key:"values",get:function(){return this.model.values}},{key:"uniqueCount",get:function(){return this.model.values.length}},{key:"count",get:function(){return this.model.count}}]),n}(c);S.exports=r},{"../../../utils/xml-stream":27,"../base-xform":31,"./shared-string-xform":122}],124:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.openNode("t"),/^\s|\n|\s$/.test(o)&&n.addAttribute("xml:space","preserve"),n.writeText(o),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case"t":return this._text=[],!0;default:return!1}}},{key:"parseText",value:function(n){this._text.push(n)}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"t"}},{key:"model",get:function(){return this._text.join("").replace(/_x([0-9A-F]{4})_/g,function(n,o){return String.fromCharCode(parseInt(o,16))})}}]),t}(m);S.exports=c},{"../base-xform":31}],125:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../doc/enums"),c=e("../../../utils/utils"),a=e("../base-xform"),r={horizontalValues:["left","center","right","fill","centerContinuous","distributed","justify"].reduce(function(n,o){return n[o]=!0,n},{}),horizontal:function(o){return this.horizontalValues[o]?o:void 0},verticalValues:["top","middle","bottom","distributed","justify"].reduce(function(n,o){return n[o]=!0,n},{}),vertical:function(o){return o==="middle"?"center":this.verticalValues[o]?o:void 0},wrapText:function(o){return o?!0:void 0},shrinkToFit:function(o){return o?!0:void 0},textRotation:function(o){switch(o){case"vertical":return o;default:return o=c.validInt(o),o>=-90&&o<=90?o:void 0}},indent:function(o){return o=c.validInt(o),Math.max(0,o)},readingOrder:function(o){switch(o){case"ltr":return m.ReadingOrder.LeftToRight;case"rtl":return m.ReadingOrder.RightToLeft;default:return}}},t={toXml:function(o){if(o=r.textRotation(o),o){if(o==="vertical")return 255;var p=Math.round(o);if(p>=0&&p<=90)return p;if(p<0&&p>=-90)return 90-p}},toModel:function(o){var p=c.validInt(o);if(p!==void 0){if(p===255)return"vertical";if(p>=0&&p<=90)return p;if(p>90&&p<=180)return 90-p}}},i=function(n){w(p,n);var o=v(p);function p(){return y(this,p),o.apply(this,arguments)}return b(p,[{key:"render",value:function(P,B){P.addRollback(),P.openNode("alignment");var z=!1;function D(M,I){I&&(P.addAttribute(M,I),z=!0)}D("horizontal",r.horizontal(B.horizontal)),D("vertical",r.vertical(B.vertical)),D("wrapText",r.wrapText(B.wrapText)?"1":!1),D("shrinkToFit",r.shrinkToFit(B.shrinkToFit)?"1":!1),D("indent",r.indent(B.indent)),D("textRotation",t.toXml(B.textRotation)),D("readingOrder",r.readingOrder(B.readingOrder)),P.closeNode(),z?P.commit():P.rollback()}},{key:"parseOpen",value:function(P){var B={},z=!1;function D(M,I,T){M&&(B[I]=T,z=!0)}D(P.attributes.horizontal,"horizontal",P.attributes.horizontal),D(P.attributes.vertical,"vertical",P.attributes.vertical==="center"?"middle":P.attributes.vertical),D(P.attributes.wrapText,"wrapText",!!P.attributes.wrapText),D(P.attributes.shrinkToFit,"shrinkToFit",!!P.attributes.shrinkToFit),D(P.attributes.indent,"indent",parseInt(P.attributes.indent,10)),D(P.attributes.textRotation,"textRotation",t.toModel(P.attributes.textRotation)),D(P.attributes.readingOrder,"readingOrder",P.attributes.readingOrder==="2"?"rtl":"ltr"),this.model=z?B:null}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"alignment"}}]),p}(a);S.exports=i},{"../../../doc/enums":7,"../../../utils/utils":26,"../base-xform":31}],126:[function(e,S,_){function u(o,p){var O=Object.keys(o);if(Object.getOwnPropertySymbols){var P=Object.getOwnPropertySymbols(o);p&&(P=P.filter(function(B){return Object.getOwnPropertyDescriptor(o,B).enumerable})),O.push.apply(O,P)}return O}function y(o){for(var p=1;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(o){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(O){return O.__proto__||Object.getPrototypeOf(O)},a(o)}var r=e("../base-xform"),t=e("./color-xform"),i=function(o){h(O,o);var p=d(O);function O(P){var B;return w(this,O),B=p.call(this),B.name=P,B.map={color:new t},B}return v(O,[{key:"render",value:function(B,z,D){var M=z&&z.color||D||this.defaultColor;B.openNode(this.name),z&&z.style&&(B.addAttribute("style",z.style),M&&this.map.color.render(B,M)),B.closeNode()}},{key:"parseOpen",value:function(B){if(this.parser)return this.parser.parseOpen(B),!0;switch(B.name){case this.name:{var z=B.attributes.style;return z?this.model={style:z}:this.model=void 0,!0}case"color":return this.parser=this.map.color,this.parser.parseOpen(B),!0;default:return!1}}},{key:"parseText",value:function(B){this.parser&&this.parser.parseText(B)}},{key:"parseClose",value:function(B){return this.parser?(this.parser.parseClose(B)||(this.parser=void 0),!0):(B===this.name&&this.map.color.model&&(this.model||(this.model={}),this.model.color=this.map.color.model),!1)}},{key:"validStyle",value:function(B){return O.validStyleValues[B]}},{key:"tag",get:function(){return this.name}}]),O}(r);i.validStyleValues=["thin","dotted","dashDot","hair","dashDotDot","slantDashDot","mediumDashed","mediumDashDotDot","mediumDashDot","medium","double","thick"].reduce(function(o,p){return o[p]=!0,o},{});var n=function(o){h(O,o);var p=d(O);function O(){var P;return w(this,O),P=p.call(this),P.map={top:new i("top"),left:new i("left"),bottom:new i("bottom"),right:new i("right"),diagonal:new i("diagonal")},P}return v(O,[{key:"render",value:function(B,z){var D=z.color;B.openNode("border"),z.diagonal&&z.diagonal.style&&(z.diagonal.up&&B.addAttribute("diagonalUp","1"),z.diagonal.down&&B.addAttribute("diagonalDown","1"));function M(I,T){I&&!I.color&&z.color&&(I=y(y({},I),{},{color:z.color})),T.render(B,I,D)}M(z.left,this.map.left),M(z.right,this.map.right),M(z.top,this.map.top),M(z.bottom,this.map.bottom),M(z.diagonal,this.map.diagonal),B.closeNode()}},{key:"parseOpen",value:function(B){if(this.parser)return this.parser.parseOpen(B),!0;switch(B.name){case"border":return this.reset(),this.diagonalUp=!!B.attributes.diagonalUp,this.diagonalDown=!!B.attributes.diagonalDown,!0;default:return this.parser=this.map[B.name],this.parser?(this.parser.parseOpen(B),!0):!1}}},{key:"parseText",value:function(B){this.parser&&this.parser.parseText(B)}},{key:"parseClose",value:function(B){if(this.parser)return this.parser.parseClose(B)||(this.parser=void 0),!0;if(B==="border"){var z=this.model={},D=function(I,T,C){T&&(C&&Object.assign(T,C),z[I]=T)};D("left",this.map.left.model),D("right",this.map.right.model),D("top",this.map.top.model),D("bottom",this.map.bottom.model),D("diagonal",this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}}]),O}(r);S.exports=n},{"../base-xform":31,"./color-xform":127}],127:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.name=i||"color",n}return b(t,[{key:"render",value:function(n,o){return o?(n.openNode(this.name),o.argb?n.addAttribute("rgb",o.argb):o.theme!==void 0?(n.addAttribute("theme",o.theme),o.tint!==void 0&&n.addAttribute("tint",o.tint)):o.indexed!==void 0?n.addAttribute("indexed",o.indexed):n.addAttribute("auto","1"),n.closeNode(),!0):!1}},{key:"parseOpen",value:function(n){return n.name===this.name?(n.attributes.rgb?this.model={argb:n.attributes.rgb}:n.attributes.theme?(this.model={theme:parseInt(n.attributes.theme,10)},n.attributes.tint&&(this.model.tint=parseFloat(n.attributes.tint))):n.attributes.indexed?this.model={indexed:parseInt(n.attributes.indexed,10)}:this.model=void 0,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return this.name}}]),t}(m);S.exports=c},{"../base-xform":31}],128:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,O){if(!(p instanceof O))throw new TypeError("Cannot call a class as a function")}function g(p,O){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("../base-xform"),c=e("./alignment-xform"),a=e("./border-xform"),r=e("./fill-xform"),t=e("./font-xform"),i=e("./numfmt-xform"),n=e("./protection-xform"),o=function(p){w(P,p);var O=v(P);function P(){var B;return y(this,P),B=O.call(this),B.map={alignment:new c,border:new a,fill:new r,font:new t,numFmt:new i,protection:new n},B}return b(P,[{key:"render",value:function(z,D){z.openNode(this.tag),D.font&&this.map.font.render(z,D.font),D.numFmt&&this.map.numFmt.render(z,D.numFmt),D.fill&&this.map.fill.render(z,D.fill),D.alignment&&this.map.alignment.render(z,D.alignment),D.border&&this.map.border.render(z,D.border),D.protection&&this.map.protection.render(z,D.protection),z.closeNode()}},{key:"parseOpen",value:function(z){if(this.parser)return this.parser.parseOpen(z),!0;switch(z.name){case this.tag:return this.reset(),!0;default:return this.parser=this.map[z.name],this.parser&&this.parser.parseOpen(z),!0}}},{key:"parseText",value:function(z){this.parser&&this.parser.parseText(z)}},{key:"parseClose",value:function(z){return this.parser?(this.parser.parseClose(z)||(this.parser=void 0),!0):z===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):!0}},{key:"tag",get:function(){return"dxf"}}]),P}(m);S.exports=o},{"../base-xform":31,"./alignment-xform":125,"./border-xform":126,"./fill-xform":129,"./font-xform":130,"./numfmt-xform":131,"./protection-xform":132}],129:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../base-xform"),c=e("./color-xform"),a=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={color:new c},O}return b(p,[{key:"render",value:function(P,B){P.openNode("stop"),P.addAttribute("position",B.position),this.map.color.render(P,B.color),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"stop":return this.model={position:parseFloat(P.attributes.position)},!0;case"color":return this.parser=this.map.color,this.parser.parseOpen(P),!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.model.color=this.parser.model,this.parser=void 0),!0):!1}},{key:"tag",get:function(){return"stop"}}]),p}(m),r=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={fgColor:new c("fgColor"),bgColor:new c("bgColor")},O}return b(p,[{key:"render",value:function(P,B){P.openNode("patternFill"),P.addAttribute("patternType",B.pattern),B.fgColor&&this.map.fgColor.render(P,B.fgColor),B.bgColor&&this.map.bgColor.render(P,B.bgColor),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"patternFill":return this.model={type:"pattern",pattern:P.attributes.patternType},!0;default:return this.parser=this.map[P.name],this.parser?(this.parser.parseOpen(P),!0):!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.parser.model&&(this.model[P]=this.parser.model),this.parser=void 0),!0):!1}},{key:"name",get:function(){return"pattern"}},{key:"tag",get:function(){return"patternFill"}}]),p}(m),t=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={stop:new a},O}return b(p,[{key:"render",value:function(P,B){switch(P.openNode("gradientFill"),B.gradient){case"angle":P.addAttribute("degree",B.degree);break;case"path":P.addAttribute("type","path"),B.center.left&&(P.addAttribute("left",B.center.left),B.center.right===void 0&&P.addAttribute("right",B.center.left)),B.center.right&&P.addAttribute("right",B.center.right),B.center.top&&(P.addAttribute("top",B.center.top),B.center.bottom===void 0&&P.addAttribute("bottom",B.center.top)),B.center.bottom&&P.addAttribute("bottom",B.center.bottom);break}var z=this.map.stop;B.stops.forEach(function(D){z.render(P,D)}),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"gradientFill":{var B=this.model={stops:[]};return P.attributes.degree?(B.gradient="angle",B.degree=parseInt(P.attributes.degree,10)):P.attributes.type==="path"&&(B.gradient="path",B.center={left:P.attributes.left?parseFloat(P.attributes.left):0,top:P.attributes.top?parseFloat(P.attributes.top):0},P.attributes.right!==P.attributes.left&&(B.center.right=P.attributes.right?parseFloat(P.attributes.right):0),P.attributes.bottom!==P.attributes.top&&(B.center.bottom=P.attributes.bottom?parseFloat(P.attributes.bottom):0)),!0}case"stop":return this.parser=this.map.stop,this.parser.parseOpen(P),!0;default:return!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0):!1}},{key:"name",get:function(){return"gradient"}},{key:"tag",get:function(){return"gradientFill"}}]),p}(m),i=function(n){w(p,n);var o=v(p);function p(){var O;return y(this,p),O=o.call(this),O.map={patternFill:new r,gradientFill:new t},O}return b(p,[{key:"render",value:function(P,B){switch(P.addRollback(),P.openNode("fill"),B.type){case"pattern":this.map.patternFill.render(P,B);break;case"gradient":this.map.gradientFill.render(P,B);break;default:P.rollback();return}P.closeNode(),P.commit()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"fill":return this.model={},!0;default:return this.parser=this.map[P.name],this.parser?(this.parser.parseOpen(P),!0):!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0):!1}},{key:"validStyle",value:function(P){return p.validPatternValues[P]}},{key:"tag",get:function(){return"fill"}}]),p}(m);i.validPatternValues=["none","solid","darkVertical","darkGray","mediumGray","lightGray","gray125","gray0625","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","lightGrid"].reduce(function(n,o){return n[o]=!0,n},{}),i.StopXform=a,i.PatternFillXform=r,i.GradientFillXform=t,S.exports=i},{"../base-xform":31,"./color-xform":127}],130:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,O){if(!(p instanceof O))throw new TypeError("Cannot call a class as a function")}function g(p,O){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("./color-xform"),c=e("../simple/boolean-xform"),a=e("../simple/integer-xform"),r=e("../simple/string-xform"),t=e("./underline-xform"),i=e("../../../utils/under-dash"),n=e("../base-xform"),o=function(p){w(P,p);var O=v(P);function P(B){var z;return y(this,P),z=O.call(this),z.options=B||P.OPTIONS,z.map={b:{prop:"bold",xform:new c({tag:"b",attr:"val"})},i:{prop:"italic",xform:new c({tag:"i",attr:"val"})},u:{prop:"underline",xform:new t},charset:{prop:"charset",xform:new a({tag:"charset",attr:"val"})},color:{prop:"color",xform:new m},condense:{prop:"condense",xform:new c({tag:"condense",attr:"val"})},extend:{prop:"extend",xform:new c({tag:"extend",attr:"val"})},family:{prop:"family",xform:new a({tag:"family",attr:"val"})},outline:{prop:"outline",xform:new c({tag:"outline",attr:"val"})},vertAlign:{prop:"vertAlign",xform:new r({tag:"vertAlign",attr:"val"})},scheme:{prop:"scheme",xform:new r({tag:"scheme",attr:"val"})},shadow:{prop:"shadow",xform:new c({tag:"shadow",attr:"val"})},strike:{prop:"strike",xform:new c({tag:"strike",attr:"val"})},sz:{prop:"size",xform:new a({tag:"sz",attr:"val"})}},z.map[z.options.fontNameTag]={prop:"name",xform:new r({tag:z.options.fontNameTag,attr:"val"})},z}return b(P,[{key:"render",value:function(z,D){var M=this.map;z.openNode(this.options.tagName),i.each(this.map,function(I,T){M[T].xform.render(z,D[I.prop])}),z.closeNode()}},{key:"parseOpen",value:function(z){if(this.parser)return this.parser.parseOpen(z),!0;if(this.map[z.name])return this.parser=this.map[z.name].xform,this.parser.parseOpen(z);switch(z.name){case this.options.tagName:return this.model={},!0;default:return!1}}},{key:"parseText",value:function(z){this.parser&&this.parser.parseText(z)}},{key:"parseClose",value:function(z){if(this.parser&&!this.parser.parseClose(z)){var D=this.map[z];return this.parser.model&&(this.model[D.prop]=this.parser.model),this.parser=void 0,!0}switch(z){case this.options.tagName:return!1;default:return!0}}},{key:"tag",get:function(){return this.options.tagName}}]),P}(n);o.OPTIONS={tagName:"font",fontNameTag:"name"},S.exports=o},{"../../../utils/under-dash":25,"../base-xform":31,"../simple/boolean-xform":115,"../simple/integer-xform":117,"../simple/string-xform":118,"./color-xform":127,"./underline-xform":135}],131:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../utils/under-dash"),c=e("../../defaultnumformats"),a=e("../base-xform");function r(){var n={};return m.each(c,function(o,p){o.f&&(n[o.f]=parseInt(p,10))}),n}var t=r(),i=function(n){w(p,n);var o=v(p);function p(O,P){var B;return y(this,p),B=o.call(this),B.id=O,B.formatCode=P,B}return b(p,[{key:"render",value:function(P,B){P.leafNode("numFmt",{numFmtId:B.id,formatCode:B.formatCode})}},{key:"parseOpen",value:function(P){switch(P.name){case"numFmt":return this.model={id:parseInt(P.attributes.numFmtId,10),formatCode:P.attributes.formatCode.replace(/[\\](.)/g,"$1")},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"numFmt"}}]),p}(a);i.getDefaultFmtId=function(o){return t[o]},i.getDefaultFmtCode=function(o){return c[o]&&c[o].f},S.exports=i},{"../../../utils/under-dash":25,"../../defaultnumformats":29,"../base-xform":31}],132:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c={boolean:function(t,i){return t===void 0?i:t}},a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){o.addRollback(),o.openNode("protection");var O=!1;function P(B,z){z!==void 0&&(o.addAttribute(B,z),O=!0)}P("locked",c.boolean(p.locked,!0)?void 0:"0"),P("hidden",c.boolean(p.hidden,!1)?"1":void 0),o.closeNode(),O?o.commit():o.rollback()}},{key:"parseOpen",value:function(o){var p={locked:o.attributes.locked!=="0",hidden:o.attributes.hidden==="1"},O=!p.locked||p.hidden;this.model=O?p:null}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"protection"}}]),i}(m);S.exports=a},{"../base-xform":31}],133:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./alignment-xform"),a=e("./protection-xform"),r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p.xfId=!!(o&&o.xfId),p.map={alignment:new c,protection:new a},p}return b(n,[{key:"render",value:function(p,O){p.openNode("xf",{numFmtId:O.numFmtId||0,fontId:O.fontId||0,fillId:O.fillId||0,borderId:O.borderId||0}),this.xfId&&p.addAttribute("xfId",O.xfId||0),O.numFmtId&&p.addAttribute("applyNumberFormat","1"),O.fontId&&p.addAttribute("applyFont","1"),O.fillId&&p.addAttribute("applyFill","1"),O.borderId&&p.addAttribute("applyBorder","1"),O.alignment&&p.addAttribute("applyAlignment","1"),O.protection&&p.addAttribute("applyProtection","1"),O.alignment&&this.map.alignment.render(p,O.alignment),O.protection&&this.map.protection.render(p,O.protection),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"xf":return this.model={numFmtId:parseInt(p.attributes.numFmtId,10),fontId:parseInt(p.attributes.fontId,10),fillId:parseInt(p.attributes.fillId,10),borderId:parseInt(p.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(p.attributes.xfId,10)),!0;case"alignment":return this.parser=this.map.alignment,this.parser.parseOpen(p),!0;case"protection":return this.parser=this.map.protection,this.parser.parseOpen(p),!0;default:return!1}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){return this.parser?(this.parser.parseClose(p)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):p!=="xf"}},{key:"tag",get:function(){return"xf"}}]),n}(m);S.exports=r},{"../base-xform":31,"./alignment-xform":125,"./protection-xform":132}],134:[function(e,S,_){function u(M){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(T){return typeof T}:u=function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},u(M)}function y(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")}function g(M,I){for(var T=0;T"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(M){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(T){return T.__proto__||Object.getPrototypeOf(T)},s(M)}var m=e("../../../doc/enums"),c=e("../../../utils/xml-stream"),a=e("../base-xform"),r=e("../static-xform"),t=e("../list-xform"),i=e("./font-xform"),n=e("./fill-xform"),o=e("./border-xform"),p=e("./numfmt-xform"),O=e("./style-xform"),P=e("./dxf-xform"),B=164,z=function(M){w(T,M);var I=v(T);function T(C){var E;return y(this,T),E=I.call(this),E.map={numFmts:new t({tag:"numFmts",count:!0,childXform:new p}),fonts:new t({tag:"fonts",count:!0,childXform:new i,$:{"x14ac:knownFonts":1}}),fills:new t({tag:"fills",count:!0,childXform:new n}),borders:new t({tag:"borders",count:!0,childXform:new o}),cellStyleXfs:new t({tag:"cellStyleXfs",count:!0,childXform:new O}),cellXfs:new t({tag:"cellXfs",count:!0,childXform:new O({xfId:!0})}),dxfs:new t({tag:"dxfs",always:!0,count:!0,childXform:new P}),numFmt:new p,font:new i,fill:new n,border:new o,style:new O({xfId:!0}),cellStyles:T.STATIC_XFORMS.cellStyles,tableStyles:T.STATIC_XFORMS.tableStyles,extLst:T.STATIC_XFORMS.extLst},C&&E.init(),E}return b(T,[{key:"initIndex",value:function(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}},{key:"init",value:function(){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}},{key:"render",value:function(E,A){A=A||this.model,E.openXml(c.StdDocAttributes),E.openNode("styleSheet",T.STYLESHEET_ATTRIBUTES),this.index?(A.numFmts&&A.numFmts.length&&(E.openNode("numFmts",{count:A.numFmts.length}),A.numFmts.forEach(function(L){E.writeXml(L)}),E.closeNode()),A.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),E.openNode("fonts",{count:A.fonts.length,"x14ac:knownFonts":1}),A.fonts.forEach(function(L){E.writeXml(L)}),E.closeNode(),E.openNode("fills",{count:A.fills.length}),A.fills.forEach(function(L){E.writeXml(L)}),E.closeNode(),E.openNode("borders",{count:A.borders.length}),A.borders.forEach(function(L){E.writeXml(L)}),E.closeNode(),this.map.cellStyleXfs.render(E,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),E.openNode("cellXfs",{count:A.styles.length}),A.styles.forEach(function(L){E.writeXml(L)}),E.closeNode()):(this.map.numFmts.render(E,A.numFmts),this.map.fonts.render(E,A.fonts),this.map.fills.render(E,A.fills),this.map.borders.render(E,A.borders),this.map.cellStyleXfs.render(E,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(E,A.styles)),T.STATIC_XFORMS.cellStyles.render(E),this.map.dxfs.render(E,A.dxfs),T.STATIC_XFORMS.tableStyles.render(E),T.STATIC_XFORMS.extLst.render(E),E.closeNode()}},{key:"parseOpen",value:function(E){if(this.parser)return this.parser.parseOpen(E),!0;switch(E.name){case"styleSheet":return this.initIndex(),!0;default:return this.parser=this.map[E.name],this.parser&&this.parser.parseOpen(E),!0}}},{key:"parseText",value:function(E){this.parser&&this.parser.parseText(E)}},{key:"parseClose",value:function(E){var A=this;if(this.parser)return this.parser.parseClose(E)||(this.parser=void 0),!0;switch(E){case"styleSheet":{this.model={};var L=function(U,N){N.model&&N.model.length&&(A.model[U]=N.model)};if(L("numFmts",this.map.numFmts),L("fonts",this.map.fonts),L("fills",this.map.fills),L("borders",this.map.borders),L("styles",this.map.cellXfs),L("dxfs",this.map.dxfs),this.index={model:[],numFmt:[]},this.model.numFmts){var $=this.index.numFmt;this.model.numFmts.forEach(function(W){$[W.id]=W.formatCode})}return!1}default:return!0}}},{key:"addStyleModel",value:function(E,A){if(!E)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(E))return this.weakMap.get(E);var L={};if(A=A||m.ValueType.Number,E.numFmt)L.numFmtId=this._addNumFmtStr(E.numFmt);else switch(A){case m.ValueType.Number:L.numFmtId=this._addNumFmtStr("General");break;case m.ValueType.Date:L.numFmtId=this._addNumFmtStr("mm-dd-yy");break}E.font&&(L.fontId=this._addFont(E.font)),E.border&&(L.borderId=this._addBorder(E.border)),E.fill&&(L.fillId=this._addFill(E.fill)),E.alignment&&(L.alignment=E.alignment),E.protection&&(L.protection=E.protection);var $=this._addStyle(L);return this.weakMap&&this.weakMap.set(E,$),$}},{key:"getStyleModel",value:function(E){var A=this.model.styles[E];if(!A)return null;var L=this.index.model[E];if(L)return L;if(L=this.index.model[E]={},A.numFmtId){var $=this.index.numFmt[A.numFmtId]||p.getDefaultFmtCode(A.numFmtId);$&&(L.numFmt=$)}function W(U,N,j){if(j||j===0){var F=N[j];F&&(L[U]=F)}}return W("font",this.model.fonts,A.fontId),W("border",this.model.borders,A.borderId),W("fill",this.model.fills,A.fillId),A.alignment&&(L.alignment=A.alignment),A.protection&&(L.protection=A.protection),L}},{key:"addDxfStyle",value:function(E){return this.model.dxfs.push(E),this.model.dxfs.length-1}},{key:"getDxfStyle",value:function(E){return this.model.dxfs[E]}},{key:"_addStyle",value:function(E){var A=this.map.style.toXml(E),L=this.index.style[A];return L===void 0&&(L=this.index.style[A]=this.model.styles.length,this.model.styles.push(A)),L}},{key:"_addNumFmtStr",value:function(E){var A=p.getDefaultFmtId(E);if(A!==void 0||(A=this.index.numFmt[E],A!==void 0))return A;A=this.index.numFmt[E]=B+this.model.numFmts.length;var L=this.map.numFmt.toXml({id:A,formatCode:E});return this.model.numFmts.push(L),A}},{key:"_addFont",value:function(E){var A=this.map.font.toXml(E),L=this.index.font[A];return L===void 0&&(L=this.index.font[A]=this.model.fonts.length,this.model.fonts.push(A)),L}},{key:"_addBorder",value:function(E){var A=this.map.border.toXml(E),L=this.index.border[A];return L===void 0&&(L=this.index.border[A]=this.model.borders.length,this.model.borders.push(A)),L}},{key:"_addFill",value:function(E){var A=this.map.fill.toXml(E),L=this.index.fill[A];return L===void 0&&(L=this.index.fill[A]=this.model.fills.length,this.model.fills.push(A)),L}}]),T}(a);z.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"},z.STATIC_XFORMS={cellStyles:new r({tag:"cellStyles",$:{count:1},c:[{tag:"cellStyle",$:{name:"Normal",xfId:0,builtinId:0}}]}),dxfs:new r({tag:"dxfs",$:{count:0}}),tableStyles:new r({tag:"tableStyles",$:{count:0,defaultTableStyle:"TableStyleMedium2",defaultPivotStyle:"PivotStyleLight16"}}),extLst:new r({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"}}]}]})};var D=function(M){w(T,M);var I=v(T);function T(){var C;return y(this,T),C=I.call(this),C.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"}]},C}return b(T,[{key:"parseStream",value:function(E){return E.autodrain(),Promise.resolve()}},{key:"addStyleModel",value:function(E,A){switch(A){case m.ValueType.Date:return this.dateStyleId;default:return 0}}},{key:"getStyleModel",value:function(){return{}}},{key:"dateStyleId",get:function(){if(!this._dateStyleId){var E={numFmtId:p.getDefaultFmtId("mm-dd-yy")};this._dateStyleId=this.model.styles.length,this.model.styles.push(E)}return this._dateStyleId}}]),T}(z);z.Mock=D,S.exports=z},{"../../../doc/enums":7,"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"../static-xform":119,"./border-xform":126,"./dxf-xform":128,"./fill-xform":129,"./font-xform":130,"./numfmt-xform":131,"./style-xform":133}],135:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.model=i,n}return b(t,[{key:"render",value:function(n,o){if(o=o||this.model,o===!0)n.leafNode("u");else{var p=t.Attributes[o];p&&n.leafNode("u",p)}}},{key:"parseOpen",value:function(n){n.name==="u"&&(this.model=n.attributes.val||!0)}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"u"}}]),t}(m);c.Attributes={single:{},double:{val:"double"},singleAccounting:{val:"singleAccounting"},doubleAccounting:{val:"doubleAccounting"}},S.exports=c},{"../base-xform":31}],136:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("./filter-column-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={filterColumn:new c},n}return b(i,[{key:"prepare",value:function(o){var p=this;o.columns.forEach(function(O,P){p.map.filterColumn.prepare(O,{index:P})})}},{key:"render",value:function(o,p){var O=this;return o.openNode(this.tag,{ref:p.autoFilterRef}),p.columns.forEach(function(P){O.map.filterColumn.render(o,P)}),o.closeNode(),!0}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;switch(o.name){case this.tag:return this.model={autoFilterRef:o.attributes.ref,columns:[]},!0;default:if(this.parser=this.map[o.name],this.parser)return this.parseOpen(o),!0;throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(o)))}}},{key:"parseText",value:function(o){this.parser&&this.parser.parseText(o)}},{key:"parseClose",value:function(o){if(this.parser)return this.parser.parseClose(o)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;switch(o){case this.tag:return!1;default:throw new Error("Unexpected xml node in parseClose: ".concat(o))}}},{key:"tag",get:function(){return"autoFilter"}}]),i}(m);S.exports=a},{"../base-xform":31,"./filter-column-xform":137}],137:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"prepare",value:function(n,o){n.colId=o.index.toString()}},{key:"render",value:function(n,o){return n.leafNode(this.tag,{colId:o.colId,hiddenButton:o.filterButton?"0":"1"}),!0}},{key:"parseOpen",value:function(n){if(n.name===this.tag){var o=n.attributes;return this.model={filterButton:o.hiddenButton==="0"},!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"filterColumn"}}]),t}(m);S.exports=c},{"../base-xform":31}],138:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"prepare",value:function(n,o){n.id=o.index+1}},{key:"render",value:function(n,o){return n.leafNode(this.tag,{id:o.id.toString(),name:o.name,totalsRowLabel:o.totalsRowLabel,totalsRowFunction:o.totalsRowFunction,dxfId:o.dxfId}),!0}},{key:"parseOpen",value:function(n){if(n.name===this.tag){var o=n.attributes;return this.model={name:o.name,totalsRowLabel:o.totalsRowLabel,totalsRowFunction:o.totalsRowFunction,dxfId:o.dxfId},!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"tableColumn"}}]),t}(m);S.exports=c},{"../base-xform":31}],139:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){return n.leafNode(this.tag,{name:o.theme?o.theme:void 0,showFirstColumn:o.showFirstColumn?"1":"0",showLastColumn:o.showLastColumn?"1":"0",showRowStripes:o.showRowStripes?"1":"0",showColumnStripes:o.showColumnStripes?"1":"0"}),!0}},{key:"parseOpen",value:function(n){if(n.name===this.tag){var o=n.attributes;return this.model={theme:o.name?o.name:null,showFirstColumn:o.showFirstColumn==="1",showLastColumn:o.showLastColumn==="1",showRowStripes:o.showRowStripes==="1",showColumnStripes:o.showColumnStripes==="1"},!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"tableStyleInfo"}}]),t}(m);S.exports=c},{"../base-xform":31}],140:[function(e,S,_){function u(P){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(z){return typeof z}:u=function(z){return z&&typeof Symbol=="function"&&z.constructor===Symbol&&z!==Symbol.prototype?"symbol":typeof z},u(P)}function y(P,B){var z=Object.keys(P);if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(P);B&&(D=D.filter(function(M){return Object.getOwnPropertyDescriptor(P,M).enumerable})),z.push.apply(z,D)}return z}function g(P){for(var B=1;B"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(P){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(z){return z.__proto__||Object.getPrototypeOf(z)},a(P)}var r=e("../../../utils/xml-stream"),t=e("../base-xform"),i=e("../list-xform"),n=e("./auto-filter-xform"),o=e("./table-column-xform"),p=e("./table-style-info-xform"),O=function(P){h(z,P);var B=d(z);function z(){var D;return w(this,z),D=B.call(this),D.map={autoFilter:new n,tableColumns:new i({tag:"tableColumns",count:!0,empty:!0,childXform:new o}),tableStyleInfo:new p},D}return v(z,[{key:"prepare",value:function(M,I){this.map.autoFilter.prepare(M),this.map.tableColumns.prepare(M.columns,I)}},{key:"render",value:function(M,I){M.openXml(r.StdDocAttributes),M.openNode(this.tag,g(g({},z.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(M,I),this.map.tableColumns.render(M,I.columns),this.map.tableStyleInfo.render(M,I.style),M.closeNode()}},{key:"parseOpen",value:function(M){if(this.parser)return this.parser.parseOpen(M),!0;var I=M.name,T=M.attributes;switch(I){case this.tag:this.reset(),this.model={name:T.name,displayName:T.displayName||T.name,tableRef:T.ref,totalsRow:T.totalsRowCount==="1",headerRow:T.headerRowCount==="1"};break;default:this.parser=this.map[M.name],this.parser&&this.parser.parseOpen(M);break}return!0}},{key:"parseText",value:function(M){this.parser&&this.parser.parseText(M)}},{key:"parseClose",value:function(M){var I=this;if(this.parser)return this.parser.parseClose(M)||(this.parser=void 0),!0;switch(M){case this.tag:return 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(function(T,C){I.model.columns[C].filterButton=T.filterButton})),this.model.style=this.map.tableStyleInfo.model,!1;default:return!0}}},{key:"reconcile",value:function(M,I){M.columns.forEach(function(T){T.dxfId!==void 0&&(T.style=I.styles.getDxfStyle(T.dxfId))})}},{key:"tag",get:function(){return"table"}}]),z}(t);O.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"},S.exports=O},{"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"./auto-filter-xform":136,"./table-column-xform":138,"./table-style-info-xform":139}],141:[function(e,S,_){(function(u,y){function g(W,U,N,j,F,V,re){try{var ee=W[V](re),ce=ee.value}catch(ye){N(ye);return}ee.done?U(ce):Promise.resolve(ce).then(j,F)}function b(W){return function(){var U=this,N=arguments;return new Promise(function(j,F){var V=W.apply(U,N);function re(ce){g(V,j,F,re,ee,"next",ce)}function ee(ce){g(V,j,F,re,ee,"throw",ce)}re(void 0)})}}function w(W,U){if(!(W instanceof U))throw new TypeError("Cannot call a class as a function")}function f(W,U){for(var N=0;N=1)){oe.next=6;break}return ce=re.substr(ee+1),ye=re.substr(0,ee),oe.next=6,new Promise(function(J,Q){var he=new a;he.on("finish",function(){V.mediaIndex[re]=V.media.length,V.mediaIndex[ye]=V.media.length;var xe={type:"image",name:ye,extension:ce,buffer:he.toBuffer()};V.media.push(xe),J()}),F.on("error",function(xe){Q(xe)}),F.pipe(he)});case 6:case"end":return oe.stop()}},j)}));function N(j,F,V){return U.apply(this,arguments)}return N}()},{key:"_processDrawingEntry",value:function(){var U=b(regeneratorRuntime.mark(function j(F,V,re){var ee,ce;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return ee=new I,ge.next=3,ee.parseStream(F);case 3:ce=ge.sent,V.drawings[re]=ce;case 5:case"end":return ge.stop()}},j)}));function N(j,F,V){return U.apply(this,arguments)}return N}()},{key:"_processDrawingRelsEntry",value:function(){var U=b(regeneratorRuntime.mark(function j(F,V,re){var ee,ce;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return ee=new P,ge.next=3,ee.parseStream(F);case 3:ce=ge.sent,V.drawingRels[re]=ce;case 5:case"end":return ge.stop()}},j)}));function N(j,F,V){return U.apply(this,arguments)}return N}()},{key:"_processVmlDrawingEntry",value:function(){var U=b(regeneratorRuntime.mark(function j(F,V,re){var ee,ce;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return ee=new E,ge.next=3,ee.parseStream(F);case 3:ce=ge.sent,V.vmlDrawings["../drawings/".concat(re,".vml")]=ce;case 5:case"end":return ge.stop()}},j)}));function N(j,F,V){return U.apply(this,arguments)}return N}()},{key:"_processThemeEntry",value:function(){var U=b(regeneratorRuntime.mark(function j(F,V,re){return regeneratorRuntime.wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:return ce.next=2,new Promise(function(ye,ge){var oe=new a;F.on("error",ge),oe.on("error",ge),oe.on("finish",function(){V.themes[re]=oe.read().toString(),ye()}),F.pipe(oe)});case 2:case"end":return ce.stop()}},j)}));function N(j,F,V){return U.apply(this,arguments)}return N}()},{key:"createInputStream",value:function(){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")}},{key:"read",value:function(){var U=b(regeneratorRuntime.mark(function j(F,V){var re,ee,ce,ye,ge,oe,J,Q;return regeneratorRuntime.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:!F[Symbol.asyncIterator]&&F.pipe&&(F=F.pipe(new m)),re=[],ee=!0,ce=!1,xe.prev=4,ge=h(F);case 6:return xe.next=8,ge.next();case 8:return oe=xe.sent,ee=oe.done,xe.next=12,oe.value;case 12:if(J=xe.sent,ee){xe.next=19;break}Q=J,re.push(Q);case 16:ee=!0,xe.next=6;break;case 19:xe.next=25;break;case 21:xe.prev=21,xe.t0=xe.catch(4),ce=!0,ye=xe.t0;case 25:if(xe.prev=25,xe.prev=26,!(!ee&&ge.return!=null)){xe.next=30;break}return xe.next=30,ge.return();case 30:if(xe.prev=30,!ce){xe.next=33;break}throw ye;case 33:return xe.finish(30);case 34:return xe.finish(25);case 35:return xe.abrupt("return",this.load(y.concat(re),V));case 36:case"end":return xe.stop()}},j,this,[[4,21,25,35],[26,,30,34]])}));function N(j,F){return U.apply(this,arguments)}return N}()},{key:"load",value:function(){var U=b(regeneratorRuntime.mark(function j(F,V){var re,ee,ce,ye,ge,oe,J,Q,he,xe,ne,se,Ce,q,G,Y,fe;return regeneratorRuntime.wrap(function(_e){for(;;)switch(_e.prev=_e.next){case 0:return V&&V.base64?re=y.from(F.toString(),"base64"):re=F,ee={worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},comments:{},tables:{},vmlDrawings:{}},_e.next=4,d.loadAsync(re);case 4:ce=_e.sent,ye=0,ge=Object.values(ce.files);case 6:if(!(ye0&&(Q=new t,ce.render(Q,J),F.append(Q.xml,{name:"xl/comments".concat(J.id,".xml")}),Q=new t,ye.render(Q,J),F.append(Q.xml,{name:"xl/drawings/vmlDrawing".concat(J.id,".vml")}))});case 5:case"end":return oe.stop()}},j)}));function N(j,F){return U.apply(this,arguments)}return N}()},{key:"_finalize",value:function(N){var j=this;return new Promise(function(F,V){N.on("finish",function(){F(j)}),N.on("error",V),N.finalize()})}},{key:"prepareModel",value:function(N,j){N.creator=N.creator||"ExcelJS",N.lastModifiedBy=N.lastModifiedBy||"ExcelJS",N.created=N.created||new Date,N.modified=N.modified||new Date,N.useSharedStrings=j.useSharedStrings!==void 0?j.useSharedStrings:!0,N.useStyles=j.useStyles!==void 0?j.useStyles:!0,N.sharedStrings=new O,N.styles=N.useStyles?new o(!0):new o.Mock;var F=new D,V=new M;F.prepare(N);var re={sharedStrings:N.sharedStrings,styles:N.styles,date1904:N.properties.date1904,drawingsCount:0,media:N.media};re.drawings=N.drawings=[],re.commentRefs=N.commentRefs=[];var ee=0;N.tables=[],N.worksheets.forEach(function(ce){ce.tables.forEach(function(ye){ee++,ye.target="table".concat(ee,".xml"),ye.id=ee,N.tables.push(ye)}),V.prepare(ce,re)})}},{key:"write",value:function(){var U=b(regeneratorRuntime.mark(function j(F,V){var re,ee;return regeneratorRuntime.wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:return V=V||{},re=this.workbook.model,ee=new c.ZipWriter(V.zip),ee.pipe(F),this.prepareModel(re,V),ye.next=7,this.addContentTypes(ee,re);case 7:return ye.next=9,this.addOfficeRels(ee,re);case 9:return ye.next=11,this.addWorkbookRels(ee,re);case 11:return ye.next=13,this.addWorksheets(ee,re);case 13:return ye.next=15,this.addSharedStrings(ee,re);case 15:return ye.next=17,this.addDrawings(ee,re);case 17:return ye.next=19,this.addTables(ee,re);case 19:return ye.next=21,Promise.all([this.addThemes(ee,re),this.addStyles(ee,re)]);case 21:return ye.next=23,this.addMedia(ee,re);case 23:return ye.next=25,Promise.all([this.addApp(ee,re),this.addCore(ee,re)]);case 25:return ye.next=27,this.addWorkbook(ee,re);case 27:return ye.abrupt("return",this._finalize(ee));case 28:case"end":return ye.stop()}},j,this)}));function N(j,F){return U.apply(this,arguments)}return N}()},{key:"writeFile",value:function(N,j){var F=this,V=l.createWriteStream(N);return new Promise(function(re,ee){V.on("finish",function(){re()}),V.on("error",function(ce){ee(ce)}),F.write(V,j).then(function(){V.end()})})}},{key:"writeBuffer",value:function(){var U=b(regeneratorRuntime.mark(function j(F){var V;return regeneratorRuntime.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return V=new a,ee.next=3,this.write(V,F);case 3:return ee.abrupt("return",V.read());case 4:case"end":return ee.stop()}},j,this)}));function N(j){return U.apply(this,arguments)}return N}()}]),W}();$.RelType=e("./rel-type"),S.exports=$}).call(this,e("_process"),e("buffer").Buffer)},{"../utils/browser-buffer-decode":16,"../utils/stream-buf":23,"../utils/utils":26,"../utils/xml-stream":27,"../utils/zip-stream":28,"./rel-type":30,"./xform/book/workbook-xform":37,"./xform/comment/comments-xform":39,"./xform/comment/vml-notes-xform":44,"./xform/core/app-xform":50,"./xform/core/content-types-xform":51,"./xform/core/core-xform":52,"./xform/core/relationships-xform":54,"./xform/drawing/drawing-xform":61,"./xform/sheet/worksheet-xform":114,"./xform/strings/shared-strings-xform":123,"./xform/style/styles-xform":134,"./xform/table/table-xform":140,"./xml/theme1.js":142,_process:467,buffer:216,fs:215,jszip:399,"readable-stream":491}],142:[function(e,S,_){S.exports=` - `},{}],143:[function(e,S,_){(function(u){function y(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(n){return typeof n}:y=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},y(t)}function g(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function b(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},m(t)}Object.defineProperty(_,"__esModule",{value:!0}),_.CsvFormatterStream=void 0;var c=e("stream"),a=e("./formatter"),r=function(t){f(n,t);var i=h(n);function n(o){var p;return g(this,n),p=i.call(this,{writableObjectMode:o.objectMode}),p.hasWrittenBOM=!1,p.formatterOptions=o,p.rowFormatter=new a.RowFormatter(o),p.hasWrittenBOM=!o.writeBOM,p}return w(n,[{key:"transform",value:function(p){return this.rowFormatter.rowTransform=p,this}},{key:"_transform",value:function(p,O,P){var B=this,z=!1;try{this.hasWrittenBOM||(this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0),this.rowFormatter.format(p,function(D,M){return D?(z=!0,P(D)):(M&&M.forEach(function(I){B.push(u.from(I,"utf8"))}),z=!0,P())})}catch(D){if(z)throw D;P(D)}}},{key:"_flush",value:function(p){var O=this;this.rowFormatter.finish(function(P,B){return P?p(P):(B&&B.forEach(function(z){O.push(u.from(z,"utf8"))}),p())})}}]),n}(c.Transform);_.CsvFormatterStream=r}).call(this,e("buffer").Buffer)},{"./formatter":147,buffer:216,stream:506}],144:[function(e,S,_){function u(g,b){if(!(g instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(_,"__esModule",{value:!0}),_.FormatterOptions=void 0;var y=function g(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};u(this,g);var w;this.objectMode=!0,this.delimiter=",",this.rowDelimiter=` +}`;var $t=Sl(function(){return ar(ve,xt+"return "+at).apply(e,Te)});if($t.source=at,Us($t))throw $t;return $t}function o0(k){return or(k).toLowerCase()}function s0(k){return or(k).toUpperCase()}function f0(k,R,X){if(k=or(k),k&&(X||R===e))return Af(k);if(!k||!(R=mn(R)))return k;var Z=zn(k),ae=zn(R),ve=Mf(Z,ae),Te=If(Z,ae)+1;return xi(Z,ve,Te).join("")}function u0(k,R,X){if(k=or(k),k&&(X||R===e))return k.slice(0,Df(k)+1);if(!k||!(R=mn(R)))return k;var Z=zn(k),ae=If(Z,zn(R))+1;return xi(Z,0,ae).join("")}function l0(k,R,X){if(k=or(k),k&&(X||R===e))return k.replace(rt,"");if(!k||!(R=mn(R)))return k;var Z=zn(k),ae=Mf(Z,zn(R));return xi(Z,ae).join("")}function c0(k,R){var X=P,Z=D;if(yr(R)){var ae="separator"in R?R.separator:ae;X="length"in R?Ut(R.length):X,Z="omission"in R?mn(R.omission):Z}k=or(k);var ve=k.length;if(na(k)){var Te=zn(k);ve=Te.length}if(X>=ve)return k;var Ae=X-ia(Z);if(Ae<1)return Z;var ze=Te?xi(Te,0,Ae).join(""):k.slice(0,Ae);if(ae===e)return ze+Z;if(Te&&(Ae+=ze.length-Ae),$s(ae)){if(k.slice(Ae).search(ae)){var qe,et=ze;for(ae.global||(ae=os(ae.source,or(Kt.exec(ae))+"g")),ae.lastIndex=0;qe=ae.exec(et);)var at=qe.index;ze=ze.slice(0,at===e?Ae:at)}}else if(k.indexOf(mn(ae),Ae)!=Ae){var vt=ze.lastIndexOf(ae);vt>-1&&(ze=ze.slice(0,vt))}return ze+Z}function h0(k){return k=or(k),k&&He.test(k)?k.replace(Pe,Hc):k}var d0=ca(function(k,R,X){return k+(X?" ":"")+R.toUpperCase()}),Ks=ku("toUpperCase");function wl(k,R,X){return k=or(k),R=X?e:R,R===e?Bc(k)?$c(k):hr(k):k.match(R)||[]}var Sl=Vt(function(k,R){try{return pr(k,e,R)}catch(X){return Us(X)?X:new Ft(X)}}),p0=si(function(k,R){return mr(R,function(X){X=Zn(X),ai(k,X,Hs(k[X],k))}),k});function v0(k){var R=k==null?0:k.length,X=It();return k=R?Oe(k,function(Z){if(typeof Z[1]!="function")throw new Rn(y);return[X(Z[0]),Z[1]]}):[],Vt(function(Z){for(var ae=-1;++aeO)return[];var X=U,Z=Wr(k,U);R=It(R),k-=U;for(var ae=bi(Z,R);++X0||R<0)?new Zt(X):(k<0?X=X.takeRight(-k):k&&(X=X.drop(k)),R!==e&&(R=Ut(R),X=R<0?X.dropRight(-R):X.take(R-k)),X)},Zt.prototype.takeRightWhile=function(k){return this.reverse().takeWhile(k).reverse()},Zt.prototype.toArray=function(){return this.take(U)},Gn(Zt.prototype,function(k,R){var X=/^(?:filter|find|map|reject)|While$/.test(R),Z=/^(?:head|last)$/.test(R),ae=de[Z?"take"+(R=="last"?"Right":""):R],ve=Z||/^find/.test(R);ae&&(de.prototype[R]=function(){var Te=this.__wrapped__,Ae=Z?[1]:arguments,ze=Te instanceof Zt,qe=Ae[0],et=ze||jt(Te),at=function(Gt){var qt=ae.apply(de,Xe([Gt],Ae));return Z&&vt?qt[0]:qt};et&&X&&typeof qe=="function"&&qe.length!=1&&(ze=et=!1);var vt=this.__chain__,xt=!!this.__actions__.length,Nt=ve&&!vt,$t=ze&&!xt;if(!ve&&et){Te=$t?Te:new Zt(this);var Dt=k.apply(Te,Ae);return Dt.__actions__.push({func:Eo,args:[at],thisArg:e}),new Cn(Dt,vt)}return Nt&&$t?k.apply(this,Ae):(Dt=this.thru(at),Nt?Z?Dt.value()[0]:Dt.value():Dt)})}),mr(["pop","push","shift","sort","splice","unshift"],function(k){var R=Ja[k],X=/^(?:push|sort|unshift)$/.test(k)?"tap":"thru",Z=/^(?:pop|shift)$/.test(k);de.prototype[k]=function(){var ae=arguments;if(Z&&!this.__chain__){var ve=this.value();return R.apply(jt(ve)?ve:[],ae)}return this[X](function(Te){return R.apply(jt(Te)?Te:[],ae)})}}),Gn(Zt.prototype,function(k,R){var X=de[R];if(X){var Z=X.name+"";sr.call(fa,Z)||(fa[Z]=[]),fa[Z].push({name:R,func:X})}}),fa[go(e,c).name]=[{name:"wrapper",func:e}],Zt.prototype.clone=hh,Zt.prototype.reverse=dh,Zt.prototype.value=ph,de.prototype.at=Up,de.prototype.chain=$p,de.prototype.commit=Wp,de.prototype.next=Vp,de.prototype.plant=Gp,de.prototype.reverse=Yp,de.prototype.toJSON=de.prototype.valueOf=de.prototype.value=Zp,de.prototype.first=de.prototype.head,Ta&&(de.prototype[Ta]=Kp),de},aa=Wc();Mt?((Mt.exports=aa)._=aa,Yt._=aa):ht._=aa}).call(Wt)})(qo,qo.exports);var rs=qo.exports,Ec={exports:{}};(function(H,x){(function(e){H.exports=e()})(function(){return function(){function e(S,_,u){function y(w,f){if(!_[w]){if(!S[w]){var v=typeof No=="function"&&No;if(!f&&v)return v(w,!0);if(g)return g(w,!0);var h=new Error("Cannot find module '"+w+"'");throw h.code="MODULE_NOT_FOUND",h}var l=_[w]={exports:{}};S[w][0].call(l.exports,function(d){var s=S[w][1][d];return y(s||d)},l,l.exports,e,S,_,u)}return _[w].exports}for(var g=typeof No=="function"&&No,b=0;b2&&arguments[2]!==void 0?arguments[2]:0;if(u(this,f),!h)this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0;else if(typeof h=="string"){var d=b.decodeAddress(h);this.nativeCol=d.col+l,this.nativeColOff=0,this.nativeRow=d.row+l,this.nativeRowOff=0}else h.nativeCol!==void 0?(this.nativeCol=h.nativeCol||0,this.nativeColOff=h.nativeColOff||0,this.nativeRow=h.nativeRow||0,this.nativeRowOff=h.nativeRowOff||0):h.col!==void 0?(this.col=h.col+l,this.row=h.row+l):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);this.worksheet=v}return g(f,[{key:"col",get:function(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth},set:function(h){this.nativeCol=Math.floor(h),this.nativeColOff=Math.floor((h-this.nativeCol)*this.colWidth)}},{key:"row",get:function(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight},set:function(h){this.nativeRow=Math.floor(h),this.nativeRowOff=Math.floor((h-this.nativeRow)*this.rowHeight)}},{key:"colWidth",get:function(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(this.worksheet.getColumn(this.nativeCol+1).width*1e4):64e4}},{key:"rowHeight",get:function(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(this.worksheet.getRow(this.nativeRow+1).height*1e4):18e4}},{key:"model",get:function(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}},set:function(h){this.nativeCol=h.nativeCol,this.nativeColOff=h.nativeColOff,this.nativeRow=h.nativeRow,this.nativeRowOff=h.nativeRowOff}}],[{key:"asInstance",value:function(h){return h instanceof f||h==null?h:new f(h)}}]),f}();S.exports=w},{"../utils/col-cache":19}],3:[function(e,S,_){function u(z,B){if(!(z instanceof B))throw new TypeError("Cannot call a class as a function")}function y(z,B){for(var M=0;M0||this.type===z.Types.Merge}},{key:"master",get:function(){return this.type===z.Types.Merge?this._value.master:this}},{key:"isHyperlink",get:function(){return this._value.type===z.Types.Hyperlink}},{key:"hyperlink",get:function(){return this._value.hyperlink}},{key:"value",get:function(){return this._value.value},set:function(M){if(this.type===z.Types.Merge){this._value.master.value=M;return}this._value.release(),this._value=D.create(D.getType(M),this,M)}},{key:"note",get:function(){return this._comment&&this._comment.note},set:function(M){this._comment=new l(M)}},{key:"text",get:function(){return this._value.toString()}},{key:"html",get:function(){return w.escapeHtml(this.text)}},{key:"formula",get:function(){return this._value.formula}},{key:"result",get:function(){return this._value.result}},{key:"formulaType",get:function(){return this._value.formulaType}},{key:"fullAddress",get:function(){var M=this._row.worksheet;return{sheetName:M.name,address:this.address,row:this.row,col:this.col}}},{key:"name",get:function(){return this.names[0]},set:function(M){this.names=[M]}},{key:"names",get:function(){return this.workbook.definedNames.getNamesEx(this.fullAddress)},set:function(M){var I=this,T=this.workbook.definedNames;T.removeAllNames(this.fullAddress),M.forEach(function(C){T.addEx(I.fullAddress,C)})}},{key:"_dataValidations",get:function(){return this.worksheet.dataValidations}},{key:"dataValidation",get:function(){return this._dataValidations.find(this.address)},set:function(M){this._dataValidations.add(this.address,M)}},{key:"model",get:function(){var M=this._value.model;return M.style=this.style,this._comment&&(M.comment=this._comment.model),M},set:function(M){if(this._value.release(),this._value=D.create(M.type,this),this._value.model=M,M.comment)switch(M.comment.type){case"note":this._comment=l.fromModel(M.comment);break}M.style?this.style=M.style:this.style={}}}]),z}();d.Types=f.ValueType;var s=function(){function z(B){u(this,z),this.model={address:B.address,type:d.Types.Null}}return g(z,[{key:"toCsvString",value:function(){return""}},{key:"release",value:function(){}},{key:"toString",value:function(){return""}},{key:"value",get:function(){return null},set:function(M){}},{key:"type",get:function(){return d.Types.Null}},{key:"effectiveType",get:function(){return d.Types.Null}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),m=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.Number,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Number}},{key:"effectiveType",get:function(){return d.Types.Number}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),c=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.String,value:M}}return g(z,[{key:"toCsvString",value:function(){return'"'.concat(this.model.value.replace(/"/g,'""'),'"')}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.String}},{key:"effectiveType",get:function(){return d.Types.String}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),a=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.String,value:M}}return g(z,[{key:"toString",value:function(){return this.model.value.richText.map(function(M){return M.text}).join("")}},{key:"toCsvString",value:function(){return'"'.concat(this.text.replace(/"/g,'""'),'"')}},{key:"release",value:function(){}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.RichText}},{key:"effectiveType",get:function(){return d.Types.RichText}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),r=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.Date,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value.toISOString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Date}},{key:"effectiveType",get:function(){return d.Types.Date}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),t=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.Hyperlink,text:M?M.text:void 0,hyperlink:M?M.hyperlink:void 0},M&&M.tooltip&&(this.model.tooltip=M.tooltip)}return g(z,[{key:"toCsvString",value:function(){return this.model.hyperlink}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.text}},{key:"value",get:function(){var M={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(M.tooltip=this.model.tooltip),M},set:function(M){this.model={text:M.text,hyperlink:M.hyperlink},M.tooltip&&(this.model.tooltip=M.tooltip)}},{key:"text",get:function(){return this.model.text},set:function(M){this.model.text=M}},{key:"hyperlink",get:function(){return this.model.hyperlink},set:function(M){this.model.hyperlink=M}},{key:"type",get:function(){return d.Types.Hyperlink}},{key:"effectiveType",get:function(){return d.Types.Hyperlink}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),i=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.Merge,master:M?M.address:void 0},this._master=M,M&&M.addMergeRef()}return g(z,[{key:"isMergedTo",value:function(M){return M===this._master}},{key:"toCsvString",value:function(){return""}},{key:"release",value:function(){this._master.releaseMergeRef()}},{key:"toString",value:function(){return this.value.toString()}},{key:"value",get:function(){return this._master.value},set:function(M){M instanceof d?(this._master&&this._master.releaseMergeRef(),M.addMergeRef(),this._master=M):this._master.value=M}},{key:"master",get:function(){return this._master}},{key:"type",get:function(){return d.Types.Merge}},{key:"effectiveType",get:function(){return this._master.effectiveType}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),n=function(){function z(B,M){u(this,z),this.cell=B,this.model={address:B.address,type:d.Types.Formula,shareType:M?M.shareType:void 0,ref:M?M.ref:void 0,formula:M?M.formula:void 0,sharedFormula:M?M.sharedFormula:void 0,result:M?M.result:void 0}}return g(z,[{key:"_copyModel",value:function(M){var I={},T=function(O){var A=M[O];A&&(I[O]=A)};return T("formula"),T("result"),T("ref"),T("shareType"),T("sharedFormula"),I}},{key:"validate",value:function(M){switch(D.getType(M)){case d.Types.Null:case d.Types.String:case d.Types.Number:case d.Types.Date:break;case d.Types.Hyperlink:case d.Types.Formula:default:throw new Error("Cannot process that type of result value")}}},{key:"_getTranslatedFormula",value:function(){if(!this._translatedFormula&&this.model.sharedFormula){var M=this.cell.worksheet,I=M.findCell(this.model.sharedFormula);this._translatedFormula=I&&h(I.formula,I.address,this.model.address)}return this._translatedFormula}},{key:"toCsvString",value:function(){return"".concat(this.model.result||"")}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.result?this.model.result.toString():""}},{key:"value",get:function(){return this._copyModel(this.model)},set:function(M){this.model=this._copyModel(M)}},{key:"dependencies",get:function(){var M=this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),I=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);return{ranges:M,cells:I}}},{key:"formula",get:function(){return this.model.formula||this._getTranslatedFormula()},set:function(M){this.model.formula=M}},{key:"formulaType",get:function(){return this.model.formula?f.FormulaType.Master:this.model.sharedFormula?f.FormulaType.Shared:f.FormulaType.None}},{key:"result",get:function(){return this.model.result},set:function(M){this.model.result=M}},{key:"type",get:function(){return d.Types.Formula}},{key:"effectiveType",get:function(){var M=this.model.result;return M==null?f.ValueType.Null:M instanceof String||typeof M=="string"?f.ValueType.String:typeof M=="number"?f.ValueType.Number:M instanceof Date?f.ValueType.Date:M.text&&M.hyperlink?f.ValueType.Hyperlink:M.formula?f.ValueType.Formula:f.ValueType.Null}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),o=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.SharedString,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.SharedString}},{key:"effectiveType",get:function(){return d.Types.SharedString}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),p=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.Boolean,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value?1:0}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Boolean}},{key:"effectiveType",get:function(){return d.Types.Boolean}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),E=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.Error,value:M}}return g(z,[{key:"toCsvString",value:function(){return this.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.error.toString()}},{key:"value",get:function(){return this.model.value},set:function(M){this.model.value=M}},{key:"type",get:function(){return d.Types.Error}},{key:"effectiveType",get:function(){return d.Types.Error}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),P=function(){function z(B,M){u(this,z),this.model={address:B.address,type:d.Types.String,value:JSON.stringify(M),rawValue:M}}return g(z,[{key:"toCsvString",value:function(){return this.model.value}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value}},{key:"value",get:function(){return this.model.rawValue},set:function(M){this.model.rawValue=M,this.model.value=JSON.stringify(M)}},{key:"type",get:function(){return d.Types.String}},{key:"effectiveType",get:function(){return d.Types.String}},{key:"address",get:function(){return this.model.address},set:function(M){this.model.address=M}}]),z}(),D={getType:function(B){return B==null?d.Types.Null:B instanceof String||typeof B=="string"?d.Types.String:typeof B=="number"?d.Types.Number:typeof B=="boolean"?d.Types.Boolean:B instanceof Date?d.Types.Date:B.text&&B.hyperlink?d.Types.Hyperlink:B.formula||B.sharedFormula?d.Types.Formula:B.richText?d.Types.RichText:B.sharedString?d.Types.SharedString:B.error?d.Types.Error:d.Types.JSON},types:[{t:d.Types.Null,f:s},{t:d.Types.Number,f:m},{t:d.Types.String,f:c},{t:d.Types.Date,f:r},{t:d.Types.Hyperlink,f:t},{t:d.Types.Formula,f:n},{t:d.Types.Merge,f:i},{t:d.Types.JSON,f:P},{t:d.Types.SharedString,f:o},{t:d.Types.RichText,f:a},{t:d.Types.Boolean,f:p},{t:d.Types.Error,f:E}].reduce(function(z,B){return z[B.t]=B.f,z},[]),create:function(B,M,I){var T=this.types[B];if(!T)throw new Error("Could not create Value of type ".concat(B));return new T(M,I)}};S.exports=d},{"../utils/col-cache":19,"../utils/shared-formula":22,"../utils/under-dash":25,"./enums":7,"./note":9}],4:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s=this._worksheet.properties.outlineLevelCol)}},{key:"isDefault",get:function(){if(this.isCustomWidth||this.hidden||this.outlineLevel)return!1;var s=this.style;return!(s&&(s.font||s.numFmt||s.alignment||s.border||s.fill||s.protection))}},{key:"headerCount",get:function(){return this.headers.length}},{key:"values",get:function(){var s=[];return this.eachCell(function(m,c){m&&m.type!==w.ValueType.Null&&(s[c]=m.value)}),s},set:function(s){var m=this;if(s){var c=this.number,a=0;s.hasOwnProperty("0")&&(a=1),s.forEach(function(r,t){m._worksheet.getCell(t+a,c).value=r})}}},{key:"numFmt",get:function(){return this.style.numFmt},set:function(s){this._applyStyle("numFmt",s)}},{key:"font",get:function(){return this.style.font},set:function(s){this._applyStyle("font",s)}},{key:"alignment",get:function(){return this.style.alignment},set:function(s){this._applyStyle("alignment",s)}},{key:"protection",get:function(){return this.style.protection},set:function(s){this._applyStyle("protection",s)}},{key:"border",get:function(){return this.style.border},set:function(s){this._applyStyle("border",s)}},{key:"fill",get:function(){return this.style.fill},set:function(s){this._applyStyle("fill",s)}}],[{key:"toModel",value:function(s){var m=[],c=null;return s&&s.forEach(function(a,r){a.isDefault?c&&(c=null):!c||!a.equivalentTo(c)?(c={min:r+1,max:r+1,width:a.width!==void 0?a.width:v,style:a.style,isCustomWidth:a.isCustomWidth,hidden:a.hidden,outlineLevel:a.outlineLevel,collapsed:a.collapsed},m.push(c)):c.max=r+1}),m.length?m:void 0}},{key:"fromModel",value:function(s,m){m=m||[];for(var c=[],a=1,r=0;rthis.bottom)&&(this.bottom=d),(!this.model.right||s>this.right)&&(this.right=s)}},{key:"expandRow",value:function(h){if(h){var l=h.dimensions,d=h.number;l&&this.expand(d,l.min,d,l.max)}}},{key:"expandToAddress",value:function(h){var l=b.decodeEx(h);this.expand(l.row,l.col,l.row,l.col)}},{key:"toString",value:function(){return this.range}},{key:"intersects",value:function(h){return!(h.sheetName&&this.sheetName&&h.sheetName!==this.sheetName||h.bottomthis.bottom||h.rightthis.right)}},{key:"contains",value:function(h){var l=b.decodeEx(h);return this.containsEx(l)}},{key:"containsEx",value:function(h){return h.sheetName&&this.sheetName&&h.sheetName!==this.sheetName?!1:h.row>=this.top&&h.row<=this.bottom&&h.col>=this.left&&h.col<=this.right}},{key:"forEachAddress",value:function(h){for(var l=this.left;l<=this.right;l++)for(var d=this.top;d<=this.bottom;d++)h(b.encodeAddress(d,l),d,l)}},{key:"top",get:function(){return this.model.top||1},set:function(h){this.model.top=h}},{key:"left",get:function(){return this.model.left||1},set:function(h){this.model.left=h}},{key:"bottom",get:function(){return this.model.bottom||1},set:function(h){this.model.bottom=h}},{key:"right",get:function(){return this.model.right||1},set:function(h){this.model.right=h}},{key:"sheetName",get:function(){return this.model.sheetName},set:function(h){this.model.sheetName=h}},{key:"_serialisedSheetName",get:function(){var h=this.model.sheetName;return h?/^[a-zA-Z0-9]*$/.test(h)?"".concat(h,"!"):"'".concat(h,"'!"):""}},{key:"tl",get:function(){return b.n2l(this.left)+this.top}},{key:"$t$l",get:function(){return"$".concat(b.n2l(this.left),"$").concat(this.top)}},{key:"br",get:function(){return b.n2l(this.right)+this.bottom}},{key:"$b$r",get:function(){return"$".concat(b.n2l(this.right),"$").concat(this.bottom)}},{key:"range",get:function(){return"".concat(this._serialisedSheetName+this.tl,":").concat(this.br)}},{key:"$range",get:function(){return"".concat(this._serialisedSheetName+this.$t$l,":").concat(this.$b$r)}},{key:"shortRange",get:function(){return this.count>1?this.range:this._serialisedSheetName+this.tl}},{key:"$shortRange",get:function(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}},{key:"count",get:function(){return(1+this.bottom-this.top)*(1+this.right-this.left)}}]),f}();S.exports=w},{"../utils/col-cache":19}],11:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s2?a-2:0),t=2;t0)for(o=n;o>=c;o--)p=this._cells[o-1],p?(E=this.getCell(o+i),E.value=p.value,E.style=p.style,E._comment=p._comment):this._cells[o+i-1]=void 0;for(o=0;oc.col)&&(s=c.col),m0?{min:s,max:m}:null}},{key:"numFmt",get:function(){return this.style.numFmt},set:function(s){this._applyStyle("numFmt",s)}},{key:"font",get:function(){return this.style.font},set:function(s){this._applyStyle("font",s)}},{key:"alignment",get:function(){return this.style.alignment},set:function(s){this._applyStyle("alignment",s)}},{key:"protection",get:function(){return this.style.protection},set:function(s){this._applyStyle("protection",s)}},{key:"border",get:function(){return this.style.border},set:function(s){this._applyStyle("border",s)}},{key:"fill",get:function(){return this.style.fill},set:function(s){this._applyStyle("fill",s)}},{key:"hidden",get:function(){return!!this._hidden},set:function(s){this._hidden=s}},{key:"outlineLevel",get:function(){return this._outlineLevel||0},set:function(s){this._outlineLevel=s}},{key:"collapsed",get:function(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}},{key:"model",get:function(){var s=[],m=0,c=0;return this._cells.forEach(function(a){if(a){var r=a.model;r&&((!m||m>a.col)&&(m=a.col),c0,"Table must be on valid row"),m(r>0,"Table must be on valid col");var t=this.width,i=this.filterHeight,n=this.tableHeight;d.autoFilterRef=b.encode(a,r,a+i-1,r+t-1),d.tableRef=b.encode(a,r,a+n-1,r+t-1),d.columns.forEach(function(o,p){m(o.name,"Column ".concat(p," must have a name")),p===0?s(o,"totalsRowLabel","Total"):(s(o,"totalsRowFunction","none"),o.totalsRowFormula=l.getFormula(o))})}},{key:"store",value:function(){var l=this,d=function(p,E){E&&Object.keys(E).forEach(function(P){p[P]=E[P]})},s=this.worksheet,m=this.table,c=m.tl,a=c.row,r=c.col,t=0;if(m.headerRow){var i=s.getRow(a+t++);m.columns.forEach(function(o,p){var E=o.style,P=o.name,D=i.getCell(r+p);D.value=P,d(D,E)})}if(m.rows.forEach(function(o){var p=s.getRow(a+t++);o.forEach(function(E,P){var D=p.getCell(r+P);D.value=E,d(D,m.columns[P].style)})}),m.totalsRow){var n=s.getRow(a+t++);m.columns.forEach(function(o,p){var E=n.getCell(r+p);if(p===0)E.value=o.totalsRowLabel;else{var P=l.getFormula(o);P?E.value={formula:o.totalsRowFormula,result:o.totalsRowResult}:E.value=null}d(E,o.style)})}}},{key:"load",value:function(l){var d=this,s=this.table,m=s.tl,c=m.row,a=m.col,r=0;if(s.headerRow){var t=l.getRow(c+r++);s.columns.forEach(function(n,o){var p=t.getCell(a+o);p.value=n.name})}if(s.rows.forEach(function(n){var o=l.getRow(c+r++);n.forEach(function(p,E){var P=o.getCell(a+E);P.value=p})}),s.totalsRow){var i=l.getRow(c+r++);s.columns.forEach(function(n,o){var p=i.getCell(a+o);if(o===0)p.value=n.totalsRowLabel;else{var E=d.getFormula(n);E&&(p.value={formula:n.totalsRowFormula,result:n.totalsRowResult})}})}}},{key:"cacheState",value:function(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}},{key:"commit",value:function(){if(this._cache){this.validate();var l=b.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(var d=0;d1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.rows.splice(l,d)}},{key:"getColumn",value:function(l){var d=this.table.columns[l];return new w(this,d,l)}},{key:"addColumn",value:function(l,d,s){this.cacheState(),s===void 0?(this.table.columns.push(l),this.table.rows.forEach(function(m,c){m.push(d[c])})):(this.table.columns.splice(s,0,l),this.table.rows.forEach(function(m,c){m.splice(s,0,d[c])}))}},{key:"removeColumns",value:function(l){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;this.cacheState(),this.table.columns.splice(l,d),this.table.rows.forEach(function(s){s.splice(l,d)})}},{key:"_assign",value:function(l,d,s){this.cacheState(),l[d]=s}},{key:"width",get:function(){return this.table.columns.length}},{key:"height",get:function(){return this.table.rows.length}},{key:"filterHeight",get:function(){return this.height+(this.table.headerRow?1:0)}},{key:"tableHeight",get:function(){return this.filterHeight+(this.table.totalsRow?1:0)}},{key:"model",get:function(){return this.table},set:function(l){this.table=l}},{key:"ref",get:function(){return this.table.ref},set:function(l){this._assign(this.table,"ref",l)}},{key:"name",get:function(){return this.table.name},set:function(l){this.table.name=l}},{key:"displayName",get:function(){return this.table.displyName||this.table.name}},{key:"displayNamename",set:function(l){this.table.displayName=l}},{key:"headerRow",get:function(){return this.table.headerRow},set:function(l){this._assign(this.table,"headerRow",l)}},{key:"totalsRow",get:function(){return this.table.totalsRow},set:function(l){this._assign(this.table,"totalsRow",l)}},{key:"theme",get:function(){return this.table.style.name},set:function(l){this.table.style.name=l}},{key:"showFirstColumn",get:function(){return this.table.style.showFirstColumn},set:function(l){this.table.style.showFirstColumn=l}},{key:"showLastColumn",get:function(){return this.table.style.showLastColumn},set:function(l){this.table.style.showLastColumn=l}},{key:"showRowStripes",get:function(){return this.table.style.showRowStripes},set:function(l){this.table.style.showRowStripes=l}},{key:"showColumnStripes",get:function(){return this.table.style.showColumnStripes},set:function(l){this.table.style.showColumnStripes=l}}]),v}();S.exports=f},{"../utils/col-cache":19}],13:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s31&&console.warn("Worksheet name ".concat(s," exceeds 31 chars. This will be truncated")),/[*?:/\\[\]]/.test(s))throw new Error("Worksheet name ".concat(s," cannot include any of the following characters: * ? : \\ / [ ]"));if(/(^')|('$)/.test(s))throw new Error("The first or last character of worksheet name cannot be a single quotation mark: ".concat(s));if(s=(s||"sheet".concat(c)).substring(0,31),this._worksheets.find(function(i){return i&&i.name.toLowerCase()===s.toLowerCase()}))throw new Error("Worksheet name already exists: ".concat(s));m&&(typeof m=="string"?(console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'),m={properties:{tabColor:{argb:m}}}):(m.argb||m.theme||m.indexed)&&(console.trace("tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }"),m={properties:{tabColor:m}}));var a=this._worksheets.reduce(function(i,n){return(n&&n.orderNo)>i?n.orderNo:i},0),r=Object.assign({},m,{id:c,name:s,orderNo:a+1,workbook:this}),t=new b(r);return this._worksheets[c]=t,t}},{key:"removeWorksheetEx",value:function(s){delete this._worksheets[s.id]}},{key:"removeWorksheet",value:function(s){var m=this.getWorksheet(s);m&&m.destroy()}},{key:"getWorksheet",value:function(s){if(s===void 0)return this._worksheets.find(Boolean);if(typeof s=="number")return this._worksheets[s];if(typeof s=="string")return this._worksheets.find(function(m){return m&&m.name===s})}},{key:"eachSheet",value:function(s){this.worksheets.forEach(function(m){s(m,m.id)})}},{key:"clearThemes",value:function(){this._themes=void 0}},{key:"addImage",value:function(s){var m=this.media.length;return this.media.push(Object.assign({},s,{type:"image"})),m}},{key:"getImage",value:function(s){return this.media[s]}},{key:"xlsx",get:function(){return this._xlsx||(this._xlsx=new f(this)),this._xlsx}},{key:"csv",get:function(){return this._csv||(this._csv=new v(this)),this._csv}},{key:"nextId",get:function(){for(var s=1;sz.length)&&(B=z.length);for(var M=0,I=new Array(B);Mthis._columns.length)for(var T=this._columns.length+1;T<=M;)this._columns.push(new i(this,T++));return this._columns[M-1]}},{key:"spliceColumns",value:function(M,I){for(var T=this,C=this._rows,O=C.length,A=arguments.length,L=new Array(A>2?A-2:0),U=2;U0)for(var W=function(ye){var ge=[M,I];L.forEach(function(J){ge.push(J[ye]||null)});var ne=T.getRow(ye+1);ne.splice.apply(ne,ge)},$=0;$0)for(var te=j;te>=F;te--)this.getColumn(te+N).defn=this.getColumn(te).defn;for(var re=M;re1&&arguments[1]!==void 0?arguments[1]:"n",T=this._nextRow,C=this.getRow(T);return C.values=M,this._setStyleOption(T,I[0]==="i"?I:"n"),C}},{key:"addRows",value:function(M){var I=this,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"n",C=[];return M.forEach(function(O){C.push(I.addRow(O,T))}),C}},{key:"insertRow",value:function(M,I){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";return this.spliceRows(M,0,I),this._setStyleOption(M,T),this.getRow(M)}},{key:"insertRows",value:function(M,I){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"n";if(this.spliceRows.apply(this,[M,0].concat(b(I))),T!=="n")for(var C=0;C1&&arguments[1]!==void 0?arguments[1]:"n";I[0]==="o"&&this.findRow(M+1)!==void 0?this._copyStyle(M+1,M,I[1]==="+"):I[0]==="i"&&this.findRow(M-1)!==void 0&&this._copyStyle(M-1,M,I[1]==="+")}},{key:"_copyStyle",value:function(M,I){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,C=this.getRow(M),O=this.getRow(I);O.style=Object.freeze(y({},C.style)),C.eachCell({includeEmpty:T},function(A,L){O.getCell(L).style=Object.freeze(y({},A.style))}),O.height=C.height}},{key:"duplicateRow",value:function(M,I){var T=this,C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,O=this._rows[M-1],A=new Array(I).fill(O.values);this.spliceRows.apply(this,[M+1,C?0:I].concat(b(A)));for(var L=function($){var N=T._rows[M+$];N.style=O.style,N.height=O.height,O.eachCell({includeEmpty:!0},function(F,j){N.getCell(j).style=F.style})},U=0;U2?O-2:0),L=2;L0)for(N=$;N>=C;N--)F=this._rows[N-1],F?function(){var V=T.getRow(N+W);V.values=F.values,V.style=F.style,V.height=F.height,F.eachCell({includeEmpty:!0},function(te,re){if(V.getCell(re).style=te.style,te._value.constructor.name==="MergeValue"){var le=T.getRow(te._row._number+U).getCell(re),ye=te._value._master,ge=T.getRow(ye._row._number+U).getCell(ye._column._number);le.merge(ge)}})}():this._rows[N+W-1]=void 0;for(N=0;NM.top||O>M.left)&&this.getCell(C,O).merge(T,I);this._merges[T.address]=M}},{key:"_unMergeMaster",value:function(M){var I=this._merges[M.address];if(I){for(var T=I.top;T<=I.bottom;T++)for(var C=I.left;C<=I.right;C++)this.getCell(T,C).unmerge();delete this._merges[M.address]}}},{key:"unMergeCells",value:function(){for(var M=arguments.length,I=new Array(M),T=0;T3&&arguments[3]!==void 0?arguments[3]:"shared",O=a.decode(M),A=O.top,L=O.left,U=O.bottom,W=O.right,$=W-L+1,N=a.encodeAddress(A,L),F=C==="shared",j;typeof T=="function"?j=T:Array.isArray(T)?Array.isArray(T[0])?j=function(ye,ge){return T[ye-A][ge-L]}:j=function(ye,ge){return T[(ye-A)*$+(ge-L)]}:j=function(){};for(var V=!0,te=A;te<=U;te++)for(var re=L;re<=W;re++)V?(this.getCell(te,re).value={shareType:C,formula:I,ref:M,result:j(te,re)},V=!1):this.getCell(te,re).value=F?{sharedFormula:N,result:j(te,re)}:j(te,re)}},{key:"addImage",value:function(M,I){var T={type:"image",imageId:M,range:I};this._media.push(new o(this,T))}},{key:"getImages",value:function(){return this._media.filter(function(M){return M.type==="image"})}},{key:"addBackgroundImage",value:function(M){var I={type:"background",imageId:M};this._media.push(new o(this,I))}},{key:"getBackgroundImageId",value:function(){var M=this._media.find(function(I){return I.type==="background"});return M&&M.imageId}},{key:"protect",value:function(M,I){var T=this;return new Promise(function(C){T.sheetProtection={sheet:!0},I&&"spinCount"in I&&(I.spinCount=Number.isFinite(I.spinCount)?Math.round(Math.max(0,I.spinCount)):1e5),M&&(T.sheetProtection.algorithmName="SHA-512",T.sheetProtection.saltValue=P.randomBytes(16).toString("base64"),T.sheetProtection.spinCount=I&&"spinCount"in I?I.spinCount:1e5,T.sheetProtection.hashValue=P.convertPasswordToHash(M,"SHA512",T.sheetProtection.saltValue,T.sheetProtection.spinCount)),I&&(T.sheetProtection=Object.assign(T.sheetProtection,I),!M&&"spinCount"in I&&delete T.sheetProtection.spinCount),C()})}},{key:"unprotect",value:function(){this.sheetProtection=null}},{key:"addTable",value:function(M){var I=new p(this,M);return this.tables[M.name]=I,I}},{key:"getTable",value:function(M){return this.tables[M]}},{key:"removeTable",value:function(M){delete this.tables[M]}},{key:"getTables",value:function(){return Object.values(this.tables)}},{key:"addConditionalFormatting",value:function(M){this.conditionalFormattings.push(M)}},{key:"removeConditionalFormatting",value:function(M){typeof M=="number"?this.conditionalFormattings.splice(M,1):M instanceof Function?this.conditionalFormattings=this.conditionalFormattings.filter(M):this.conditionalFormattings=[]}},{key:"_parseRows",value:function(M){var I=this;this._rows=[],M.rows.forEach(function(T){var C=new t(I,T.number);I._rows[C.number-1]=C,C.model=T})}},{key:"_parseMergeCells",value:function(M){var I=this;c.each(M.mergeCells,function(T){I.mergeCellsWithoutStyle(T)})}},{key:"workbook",get:function(){return this._workbook}},{key:"dimensions",get:function(){var M=new r;return this._rows.forEach(function(I){if(I){var T=I.dimensions;T&&M.expand(I.number,T.min,I.number,T.max)}}),M}},{key:"columns",get:function(){return this._columns},set:function(M){var I=this;this._headerRowCount=M.reduce(function(O,A){var L=A.header&&1||A.headers&&A.headers.length||0;return Math.max(O,L)},0);var T=1,C=this._columns=[];M.forEach(function(O){var A=new i(I,T++,!1);C.push(A),A.defn=O})}},{key:"lastColumn",get:function(){return this.getColumn(this.columnCount)}},{key:"columnCount",get:function(){var M=0;return this.eachRow(function(I){M=Math.max(M,I.cellCount)}),M}},{key:"actualColumnCount",get:function(){var M=[],I=0;return this.eachRow(function(T){T.eachCell(function(C){var O=C.col;M[O]||(M[O]=!0,I++)})}),I}},{key:"_lastRowNumber",get:function(){for(var M=this._rows,I=M.length;I>0&&M[I-1]===void 0;)I--;return I}},{key:"_nextRow",get:function(){return this._lastRowNumber+1}},{key:"lastRow",get:function(){if(this._rows.length)return this._rows[this._rows.length-1]}},{key:"rowCount",get:function(){return this._lastRowNumber}},{key:"actualRowCount",get:function(){var M=0;return this.eachRow(function(){M++}),M}},{key:"hasMerges",get:function(){return c.some(this._merges,Boolean)}},{key:"tabColor",get:function(){return console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor},set:function(M){console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor=M}},{key:"model",get:function(){var M={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(function(C){return C.model}),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(function(C){return C.model}),conditionalFormattings:this.conditionalFormattings};M.cols=i.toModel(this.columns);var I=M.rows=[],T=M.dimensions=new r;return this._rows.forEach(function(C){var O=C&&C.model;O&&(T.expand(O.number,O.min,O.number,O.max),I.push(O))}),M.merges=[],c.each(this._merges,function(C){M.merges.push(C.range)}),M},set:function(M){var I=this;this.name=M.name,this._columns=i.fromModel(this,M.cols),this._parseRows(M),this._parseMergeCells(M),this.dataValidations=new E(M.dataValidations),this.properties=M.properties,this.pageSetup=M.pageSetup,this.headerFooter=M.headerFooter,this.views=M.views,this.autoFilter=M.autoFilter,this._media=M.media.map(function(T){return new o(I,T)}),this.sheetProtection=M.sheetProtection,this.tables=M.tables.reduce(function(T,C){var O=new p;return O.model=C,T[C.name]=O,T},{}),this.conditionalFormattings=M.conditionalFormattings}}]),z}();S.exports=D},{"../utils/col-cache":19,"../utils/encryptor":20,"../utils/under-dash":25,"./column":4,"./data-validations":5,"./enums":7,"./image":8,"./range":10,"./row":11,"./table":12}],15:[function(e,S,_){e("core-js/modules/es.promise"),e("core-js/modules/es.object.assign"),e("core-js/modules/es.object.keys"),e("core-js/modules/es.object.values"),e("core-js/modules/es.symbol"),e("core-js/modules/es.symbol.async-iterator"),e("core-js/modules/es.array.iterator"),e("core-js/modules/es.array.includes"),e("core-js/modules/es.array.find-index"),e("core-js/modules/es.array.find"),e("core-js/modules/es.string.from-code-point"),e("core-js/modules/es.string.includes"),e("core-js/modules/es.number.is-nan"),e("regenerator-runtime/runtime");var u={Workbook:e("./doc/workbook")},y=e("./doc/enums");Object.keys(y).forEach(function(g){u[g]=y[g]}),S.exports=u},{"./doc/enums":7,"./doc/workbook":13,"core-js/modules/es.array.find":316,"core-js/modules/es.array.find-index":315,"core-js/modules/es.array.includes":317,"core-js/modules/es.array.iterator":318,"core-js/modules/es.number.is-nan":319,"core-js/modules/es.object.assign":320,"core-js/modules/es.object.keys":321,"core-js/modules/es.object.values":322,"core-js/modules/es.promise":323,"core-js/modules/es.string.from-code-point":324,"core-js/modules/es.string.includes":325,"core-js/modules/es.symbol":327,"core-js/modules/es.symbol.async-iterator":326,"regenerator-runtime/runtime":492}],16:[function(e,S,_){var u=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function y(g){return typeof g=="string"?g:u?u.decode(g):g.toString()}_.bufferToString=y},{}],17:[function(e,S,_){var u=typeof TextEncoder>"u"?null:new TextEncoder("utf-8"),y=e("buffer"),g=y.Buffer;function b(w){return typeof w!="string"?w:u?g.from(u.encode(w).buffer):g.from(w)}_.stringToBuffer=b},{buffer:216}],18:[function(e,S,_){function u(v,h){if(!(v instanceof h))throw new TypeError("Cannot call a class as a function")}function y(v,h){for(var l=0;lm.length)&&(c=m.length);for(var a=0,r=new Array(c);a"u"||!(Symbol.iterator in Object(m)))){var a=[],r=!0,t=!1,i=void 0;try{for(var n=m[Symbol.iterator](),o;!(r=(o=n.next()).done)&&(a.push(o.value),!(c&&a.length===c));r=!0);}catch(p){t=!0,i=p}finally{try{!r&&n.return!=null&&n.return()}finally{if(t)throw i}}return a}}function f(m){if(Array.isArray(m))return m}function v(m,c){var a=Object.keys(m);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);c&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(m,t).enumerable})),a.push.apply(a,r)}return a}function h(m){for(var c=1;c=4)throw new Error("Out of bounds. Excel supports columns from 1 to 16384");if(this._l2nFill<1&&c>=1){for(;o<=26;)a=this._dictionary[o-1],this._n2l[o]=a,this._l2n[a]=o,o++;this._l2nFill=1}if(this._l2nFill<2&&c>=2){for(o=27;o<=26+26*26;)r=o-(26+1),t=r%26,i=Math.floor(r/26),a=this._dictionary[i]+this._dictionary[t],this._n2l[o]=a,this._l2n[a]=o,o++;this._l2nFill=2}if(this._l2nFill<3&&c>=3){for(o=26+26*26+1;o<=16384;)r=o-(26*26+26+1),t=r%26,i=Math.floor(r/26)%26,n=Math.floor(r/(26*26)),a=this._dictionary[n]+this._dictionary[i]+this._dictionary[t],this._n2l[o]=a,this._l2n[a]=o,o++;this._l2nFill=3}},l2n:function(c){if(this._l2n[c]||this._fill(c.length),!this._l2n[c])throw new Error("Out of bounds. Invalid column letter: ".concat(c));return this._l2n[c]},n2l:function(c){if(c<1||c>16384)throw new Error("".concat(c," is out of bounds. Excel supports columns from 1 to 16384"));return this._n2l[c]||this._fill(this._level(c)),this._n2l[c]},_hash:{},validateAddress:function(c){if(!d.test(c))throw new Error("Invalid Address: ".concat(c));return!0},decodeAddress:function(c){var a=c.length<5&&this._hash[c];if(a)return a;for(var r=!1,t="",i=0,n=!1,o="",p=0,E=0,P;E=65&&P<=90)r=!0,t+=c[E],i=i*26+P-64;else if(P>=48&&P<=57)n=!0,o+=c[E],p=p*10+P-48;else if(n&&r&&P!==36)break;if(!r)i=void 0;else if(i>16384)throw new Error("Out of bounds. Invalid column letter: ".concat(t));n||(p=void 0),c=t+o;var D={address:c,col:i,row:p,$col$row:"$".concat(t,"$").concat(o)};return i<=100&&p<=100&&(this._hash[c]=D,this._hash[D.$col$row]=D),D},getAddress:function(c,a){if(a){var r=this.n2l(a)+c;return this.decodeAddress(r)}return this.decodeAddress(c)},decode:function(c){var a=c.split(":");if(a.length===2){var r=this.decodeAddress(a[0]),t=this.decodeAddress(a[1]),i={top:Math.min(r.row,t.row),left:Math.min(r.col,t.col),bottom:Math.max(r.row,t.row),right:Math.max(r.col,t.col)};return i.tl=this.n2l(i.left)+i.top,i.br=this.n2l(i.right)+i.bottom,i.dimensions="".concat(i.tl,":").concat(i.br),i}return this.decodeAddress(c)},decodeEx:function(c){var a=c.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/),r=a[1]||a[2],t=a[3],i=t.split(":");if(i.length>1){var n=this.decodeAddress(i[0]),o=this.decodeAddress(i[1]),p=Math.min(n.row,o.row),E=Math.min(n.col,o.col),P=Math.max(n.row,o.row),D=Math.max(n.col,o.col);return n=this.n2l(E)+p,o=this.n2l(D)+P,{top:p,left:E,bottom:P,right:D,sheetName:r,tl:{address:n,col:E,row:p,$col$row:"$".concat(this.n2l(E),"$").concat(p),sheetName:r},br:{address:o,col:D,row:P,$col$row:"$".concat(this.n2l(D),"$").concat(P),sheetName:r},dimensions:"".concat(n,":").concat(o)}}if(t.startsWith("#"))return r?{sheetName:r,error:t}:{error:t};var z=this.decodeAddress(t);return r?h({sheetName:r},z):z},encodeAddress:function(c,a){return s.n2l(a)+c},encode:function(){switch(arguments.length){case 2:return s.encodeAddress(arguments[0],arguments[1]);case 4:return"".concat(s.encodeAddress(arguments[0],arguments[1]),":").concat(s.encodeAddress(arguments[2],arguments[3]));default:throw new Error("Can only encode with 2 or 4 arguments")}},inRange:function(c,a){var r=u(c,5),t=r[0],i=r[1],n=r[3],o=r[4],p=u(a,2),E=p[0],P=p[1];return E>=t&&E<=n&&P>=i&&P<=o}};S.exports=s},{}],20:[function(e,S,_){(function(u){var y=e("crypto"),g={hash:function(w){for(var f=y.createHash(w),v=arguments.length,h=new Array(v>1?v-1:0),l=1;l3||i.length===3&&i>"XFD")return d;var p=u.l2n(i),E=parseInt(o,10);t||(p+=l.col-h.col),n||(E+=l.row-h.row);var P=(s||"")+(t||"")+u.n2l(p)+(n||"")+E;return P}return d})}S.exports={slideFormula:b}},{"./col-cache":19}],23:[function(e,S,_){(function(u,y){function g(t,i,n,o,p,E,P){try{var D=t[E](P),z=D.value}catch(B){n(B);return}D.done?i(z):Promise.resolve(z).then(o,p)}function b(t){return function(){var i=this,n=arguments;return new Promise(function(o,p){var E=t.apply(i,n);function P(z){g(E,o,p,P,D,"next",z)}function D(z){g(E,o,p,P,D,"throw",z)}P(void 0)})}}function w(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function f(t,i){for(var n=0;n=this.length?(o=this.toBuffer(),this.iRead=this.iWrite,o):(o=y.alloc(n),this.buffer.copy(o,0,this.iRead,n),this.iRead+=n,o)}},{key:"write",value:function(n,o,p){var E=Math.min(p,this.size-this.iWrite);return n.copy(this.buffer,this.iWrite,o,o+E),this.iWrite+=E,E}},{key:"length",get:function(){return this.iWrite-this.iRead}},{key:"eod",get:function(){return this.iRead===this.iWrite}},{key:"full",get:function(){return this.iWrite===this.size}}]),t}(),r=function(i){i=i||{},this.bufSize=i.bufSize||1024*1024,this.buffers=[],this.batch=i.batch||!1,this.corked=!1,this.inPos=0,this.outPos=0,this.pipes=[],this.paused=!1,this.encoding=null};l.inherits(r,h.Duplex,{toBuffer:function(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:return y.concat(this.buffers.map(function(i){return i.toBuffer()}))}},_getWritableBuffer:function(){if(this.buffers.length){var i=this.buffers[this.buffers.length-1];if(!i.full)return i}var n=new a(this.bufSize);return this.buffers.push(n),n},_pipe:function(i){var n=this;return b(regeneratorRuntime.mark(function o(){var p;return regeneratorRuntime.wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return p=function(z){return new Promise(function(B){z.write(i.toBuffer(),function(){B()})})},P.next=3,Promise.all(n.pipes.map(p));case 3:case"end":return P.stop()}},o)}))()},_writeToBuffers:function(i){for(var n=0,o=i.length;n1;)p._pipe(p.buffers.shift());z.next=29;break;case 21:if(p.corked){z.next=27;break}return z.next=24,p._pipe(P);case 24:o(),z.next=29;break;case 27:p._writeToBuffers(P),u.nextTick(o);case 29:z.next=34;break;case 31:p.paused||p.emit("data",P.toBuffer()),p._writeToBuffers(P),p.emit("readable");case 34:return z.abrupt("return",!0);case 35:case"end":return z.stop()}},E)}))()},cork:function(){this.corked=!0},_flush:function(){if(this.pipes.length)for(;this.buffers.length;)this._pipe(this.buffers.shift())},uncork:function(){this.corked=!1,this._flush()},end:function(i,n,o){var p=this,E=function(D){D?o(D):(p._flush(),p.pipes.forEach(function(z){z.end()}),p.emit("finish"))};i?this.write(i,n,E):E()},read:function(i){var n;if(i){for(n=[];i&&this.buffers.length&&!this.buffers[0].eod;){var o=this.buffers[0],p=o.read(i);i-=p.length,n.push(p),o.eod&&o.full&&this.buffers.shift()}return y.concat(n)}return n=this.buffers.map(function(E){return E.toBuffer()}).filter(Boolean),this.buffers=[],y.concat(n)},setEncoding:function(i){this.encoding=i},pause:function(){this.paused=!0},resume:function(){this.paused=!1},isPaused:function(){return!!this.paused},pipe:function(i){this.pipes.push(i),!this.paused&&this.buffers.length&&this.end()},unpipe:function(i){this.pipes=this.pipes.filter(function(n){return n!==i})},unshift:function(){throw new Error("Not Implemented")},wrap:function(){throw new Error("Not Implemented")}}),S.exports=r}).call(this,e("_process"),e("buffer").Buffer)},{"./string-buf":24,"./utils":26,_process:467,buffer:216,"readable-stream":491}],24:[function(e,S,_){(function(u){function y(f,v){if(!(f instanceof v))throw new TypeError("Cannot call a class as a function")}function g(f,v){for(var h=0;h=this._buf.length-4;)this._grow(this._inPos+h.length),l=this._inPos+this._buf.write(h,this._inPos,this._encoding);this._inPos=l}},{key:"addStringBuf",value:function(h){h.length&&(this._buffer=void 0,this.length+h.length>this.capacity&&this._grow(this.length+h.length),h._buf.copy(this._buf,this._inPos,0,h.length),this._inPos+=h.length)}},{key:"length",get:function(){return this._inPos}},{key:"capacity",get:function(){return this._buf.length}},{key:"buffer",get:function(){return this._buf}}]),f}();S.exports=w}).call(this,e("buffer").Buffer)},{buffer:216}],25:[function(e,S,_){function u(w){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(v){return typeof v}:u=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},u(w)}var y=Object.prototype.toString,g=/["&<>]/,b={each:function(f,v){f&&(Array.isArray(f)?f.forEach(v):Object.keys(f).forEach(function(h){v(f[h],h)}))},some:function(f,v){return f?Array.isArray(f)?f.some(v):Object.keys(f).some(function(h){return v(f[h],h)}):!1},every:function(f,v){return f?Array.isArray(f)?f.every(v):Object.keys(f).every(function(h){return v(f[h],h)}):!0},map:function(f,v){return f?Array.isArray(f)?f.map(v):Object.keys(f).map(function(h){return v(f[h],h)}):[]},keyBy:function(f,v){return f.reduce(function(h,l){return h[l[v]]=l,h},{})},isEqual:function(f,v){var h=u(f),l=u(v),d=Array.isArray(f),s=Array.isArray(v);if(h!==l)return!1;switch(u(f)){case"object":return d||s?d&&s?f.length===v.length&&f.every(function(m,c){var a=v[c];return b.isEqual(m,a)}):!1:b.every(f,function(m,c){var a=v[c];return b.isEqual(m,a)});default:return f===v}},escapeHtml:function(f){var v=g.exec(f);if(!v)return f;for(var h="",l="",d=0,s=v.index;s":l=">";break;default:continue}d!==s&&(h+=f.substring(d,s)),d=s+1,h+=l}return d!==s?h+f.substring(d,s):h},strcmp:function(f,v){return fv?1:0},isUndefined:function(f){return y.call(f)==="[object Undefined]"},isObject:function(f){return y.call(f)==="[object Object]"},deepMerge:function(){var f=arguments[0]||{},v=arguments.length,h,l,d;function s(c,a){h=f[a],d=Array.isArray(c),b.isObject(c)||d?(d?(d=!1,l=h&&Array.isArray(h)?h:[]):l=h&&b.isObject(h)?h:{},f[a]=b.deepMerge(l,c)):b.isUndefined(c)||(f[a]=c)}for(var m=0;m&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/,f={nop:function(){},promiseImmediate:function(h){return new Promise(function(l){u.setImmediate?y(function(){l(h)}):setTimeout(function(){l(h)},1)})},inherits:b,dateToExcel:function(h,l){return 25569+h.getTime()/(24*3600*1e3)-(l?1462:0)},excelToDate:function(h,l){var d=Math.round((h-25569+(l?1462:0))*24*3600*1e3);return new Date(d)},parsePath:function(h){var l=h.lastIndexOf("/");return{path:h.substring(0,l),name:h.substring(l+1)}},getRelsPath:function(h){var l=f.parsePath(h);return"".concat(l.path,"/_rels/").concat(l.name,".rels")},xmlEncode:function(h){var l=w.exec(h);if(!l)return h;for(var d="",s="",m=0,c=l.index;c=11&&a!==13)){s="";break}continue}}m!==c&&(d+=h.substring(m,c)),m=c+1,s&&(d+=s)}return m!==c?d+h.substring(m,c):d},xmlDecode:function(h){return h.replace(/&([a-z]*);/g,function(l){switch(l){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case""":return'"';default:return l}})},validInt:function(h){var l=parseInt(h,10);return Number.isNaN(l)?0:l},isDateFmt:function(h){if(!h)return!1;h=h.replace(/\[[^\]]*]/g,""),h=h.replace(/"[^"]*"/g,"");var l=h.match(/[ymdhMsb]+/)!==null;return l},fs:{exists:function(h){return new Promise(function(l){g.access(h,g.constants.F_OK,function(d){l(!d)})})}},toIsoDateString:function(h){return h.toIsoString().subsstr(0,10)}};S.exports=f}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{},e("timers").setImmediate)},{fs:215,timers:521}],27:[function(e,S,_){function u(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function y(t,i){for(var n=0;n",h="",d='="',s='"',m=" ";function c(t,i,n){t.push(m),t.push(i),t.push(d),t.push(w.xmlEncode(n.toString())),t.push(s)}function a(t,i){i&&b.each(i,function(n,o){n!==void 0&&c(t,o,n)})}var r=function(){function t(){u(this,t),this._xml=[],this._stack=[],this._rollbacks=[]}return g(t,[{key:"openXml",value:function(n){var o=this._xml;o.push(" +`)}},{key:"openNode",value:function(n,o){var p=this.tos,E=this._xml;p&&this.open&&E.push(v),this._stack.push(n),E.push(f),E.push(n),a(E,o),this.leaf=!0,this.open=!0}},{key:"addAttribute",value:function(n,o){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");o!==void 0&&c(this._xml,n,o)}},{key:"addAttributes",value:function(n){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");a(this._xml,n)}},{key:"writeText",value:function(n){var o=this._xml;this.open&&(o.push(v),this.open=!1),this.leaf=!1,o.push(w.xmlEncode(n.toString()))}},{key:"writeXml",value:function(n){this.open&&(this._xml.push(v),this.open=!1),this.leaf=!1,this._xml.push(n)}},{key:"closeNode",value:function(){var n=this._stack.pop(),o=this._xml;this.leaf?o.push(l):(o.push(h),o.push(n),o.push(v)),this.open=!1,this.leaf=!1}},{key:"leafNode",value:function(n,o,p){this.openNode(n,o),p!==void 0&&this.writeText(p),this.closeNode()}},{key:"closeAll",value:function(){for(;this._stack.length;)this.closeNode()}},{key:"addRollback",value:function(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}},{key:"commit",value:function(){this._rollbacks.pop()}},{key:"rollback",value:function(){var n=this._rollbacks.pop();this._xml.length>n.xml&&this._xml.splice(n.xml,this._xml.length-n.xml),this._stack.length>n.stack&&this._stack.splice(n.stack,this._stack.length-n.stack),this.leaf=n.leaf,this.open=n.open}},{key:"tos",get:function(){return this._stack.length?this._stack[this._stack.length-1]:void 0}},{key:"cursor",get:function(){return this._xml.length}},{key:"xml",get:function(){return this.closeAll(),this._xml.join("")}}]),t}();r.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"},S.exports=r},{"./under-dash":25,"./utils":26}],28:[function(e,S,_){(function(u){function y(E){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(D){return typeof D}:y=function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},y(E)}function g(E,P,D,z,B,M,I){try{var T=E[M](I),C=T.value}catch(O){D(O);return}T.done?P(C):Promise.resolve(C).then(z,B)}function b(E){return function(){var P=this,D=arguments;return new Promise(function(z,B){var M=E.apply(P,D);function I(C){g(M,z,B,I,T,"next",C)}function T(C){g(M,z,B,I,T,"throw",C)}I(void 0)})}}function w(E,P){if(!(E instanceof P))throw new TypeError("Cannot call a class as a function")}function f(E,P){for(var D=0;D"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(E){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(D){return D.__proto__||Object.getPrototypeOf(D)},a(E)}var r=e("events"),t=e("jszip"),i=e("./stream-buf"),n=e("./browser-buffer-encode"),o=n.stringToBuffer,p=function(E){h(D,E);var P=d(D);function D(z){var B;return w(this,D),B=P.call(this),B.options=Object.assign({type:"nodebuffer",compression:"DEFLATE"},z),B.zip=new t,B.stream=new i,B}return v(D,[{key:"append",value:function(B,M){M.hasOwnProperty("base64")&&M.base64?this.zip.file(M.name,B,{base64:!0}):(u.browser&&typeof B=="string"&&(B=o(B)),this.zip.file(M.name,B))}},{key:"finalize",value:function(){var z=b(regeneratorRuntime.mark(function M(){var I;return regeneratorRuntime.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,this.zip.generateAsync(this.options);case 2:I=C.sent,this.stream.end(I),this.emit("finish");case 5:case"end":return C.stop()}},M,this)}));function B(){return z.apply(this,arguments)}return B}()},{key:"read",value:function(B){return this.stream.read(B)}},{key:"setEncoding",value:function(B){return this.stream.setEncoding(B)}},{key:"pause",value:function(){return this.stream.pause()}},{key:"resume",value:function(){return this.stream.resume()}},{key:"isPaused",value:function(){return this.stream.isPaused()}},{key:"pipe",value:function(B,M){return this.stream.pipe(B,M)}},{key:"unpipe",value:function(B){return this.stream.unpipe(B)}},{key:"unshift",value:function(B){return this.stream.unshift(B)}},{key:"wrap",value:function(B){return this.stream.wrap(B)}}]),D}(r.EventEmitter);S.exports={ZipWriter:p}}).call(this,e("_process"))},{"./browser-buffer-encode":17,"./stream-buf":23,_process:467,events:367,jszip:399}],29:[function(e,S,_){S.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"}}},{}],30:[function(e,S,_){S.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"}},{}],31:[function(e,S,_){function u(c,a){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=y(c))||a&&c&&typeof c.length=="number"){r&&(c=r);var t=0,i=function(){};return{s:i,n:function(){return t>=c.length?{done:!0}:{done:!1,value:c[t++]}},e:function(P){throw P},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var P=r.next();return n=P.done,P},e:function(P){o=!0,p=P},f:function(){try{!n&&r.return!=null&&r.return()}finally{if(o)throw p}}}}function y(c,a){if(c){if(typeof c=="string")return g(c,a);var r=Object.prototype.toString.call(c).slice(8,-1);if(r==="Object"&&c.constructor&&(r=c.constructor.name),r==="Map"||r==="Set")return Array.from(c);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(c,a)}}function g(c,a){(a==null||a>c.length)&&(a=c.length);for(var r=0,t=new Array(a);r2&&arguments[2]!==void 0?arguments[2]:!1;if(r===void 0){if(i)return t}else if(i||r!==t)return r.toString()}},{key:"toStringAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return c.toAttribute(r,t,i)}},{key:"toStringValue",value:function(r,t){return r===void 0?t:r}},{key:"toBoolAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(r===void 0){if(i)return t}else if(i||r!==t)return r?"1":"0"}},{key:"toBoolValue",value:function(r,t){return r===void 0?t:r==="1"}},{key:"toIntAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return c.toAttribute(r,t,i)}},{key:"toIntValue",value:function(r,t){return r===void 0?t:parseInt(r,10)}},{key:"toFloatAttribute",value:function(r,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return c.toAttribute(r,t,i)}},{key:"toFloatValue",value:function(r,t){return r===void 0?t:parseFloat(r)}}]),c}();S.exports=m},{"../../utils/parse-sax":21,"../../utils/xml-stream":27}],32:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../base-xform"),c=e("../../../utils/col-cache"),a=function(i){w(o,i);var n=v(o);function o(){return y(this,o),n.apply(this,arguments)}return b(o,[{key:"render",value:function(E,P){E.openNode("definedName",{name:P.name,localSheetId:P.localSheetId}),E.writeText(P.ranges.join(",")),E.closeNode()}},{key:"parseOpen",value:function(E){switch(E.name){case"definedName":return this._parsedName=E.attributes.name,this._parsedLocalSheetId=E.attributes.localSheetId,this._parsedText=[],!0;default:return!1}}},{key:"parseText",value:function(E){this._parsedText.push(E)}},{key:"parseClose",value:function(){return this.model={name:this._parsedName,ranges:t(this._parsedText.join(""))},this._parsedLocalSheetId!==void 0&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}}]),o}(m);function r(i){try{return c.decodeEx(i),!0}catch{return!1}}function t(i){var n=[],o=!1,p="";return i.split(",").forEach(function(E){if(E){var P=(E.match(/'/g)||[]).length;if(!P){o?p+="".concat(E,","):r(E)&&n.push(E);return}var D=P%2===0;!o&&D&&r(E)?n.push(E):o&&!D?(o=!1,r(p+E)&&n.push(p+E),p=""):(o=!0,p+="".concat(E,","))}}),n}S.exports=a},{"../../../utils/col-cache":19,"../base-xform":31}],33:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/utils"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){o.leafNode("sheet",{sheetId:p.id,name:p.name,state:p.state,"r:id":p.rId})}},{key:"parseOpen",value:function(o){return o.name==="sheet"?(this.model={name:m.xmlDecode(o.attributes.name),id:parseInt(o.attributes.sheetId,10),state:o.attributes.state,rId:o.attributes["r:id"]},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),i}(c);S.exports=a},{"../../../utils/utils":26,"../base-xform":31}],34:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("calcPr",{calcId:171027,fullCalcOnLoad:o.fullCalcOnLoad?1:void 0})}},{key:"parseOpen",value:function(n){return n.name==="calcPr"?(this.model={},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],35:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("workbookPr",{date1904:o.date1904?1:void 0,defaultThemeVersion:164011,filterPrivacy:1})}},{key:"parseOpen",value:function(n){return n.name==="workbookPr"?(this.model={date1904:n.attributes.date1904==="1"},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],36:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){var p={xWindow:o.x||0,yWindow:o.y||0,windowWidth:o.width||12e3,windowHeight:o.height||24e3,firstSheet:o.firstSheet,activeTab:o.activeTab};o.visibility&&o.visibility!=="visible"&&(p.visibility=o.visibility),n.leafNode("workbookView",p)}},{key:"parseOpen",value:function(n){if(n.name==="workbookView"){var o=this.model={},p=function(D,z,B){var M=z!==void 0?o[D]=z:B;M!==void 0&&(o[D]=M)},E=function(D,z,B){var M=z!==void 0?o[D]=parseInt(z,10):B;M!==void 0&&(o[D]=M)};return E("x",n.attributes.xWindow,0),E("y",n.attributes.yWindow,0),E("width",n.attributes.windowWidth,25e3),E("height",n.attributes.windowHeight,1e4),p("visibility",n.attributes.visibility,"visible"),E("activeTab",n.attributes.activeTab,void 0),E("firstSheet",n.attributes.firstSheet,void 0),!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],37:[function(e,S,_){function u(z){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(M){return typeof M}:u=function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},u(z)}function y(z,B){if(!(z instanceof B))throw new TypeError("Cannot call a class as a function")}function g(z,B){for(var M=0;M"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(z){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(M){return M.__proto__||Object.getPrototypeOf(M)},s(z)}var m=e("../../../utils/under-dash"),c=e("../../../utils/col-cache"),a=e("../../../utils/xml-stream"),r=e("../base-xform"),t=e("../static-xform"),i=e("../list-xform"),n=e("./defined-name-xform"),o=e("./sheet-xform"),p=e("./workbook-view-xform"),E=e("./workbook-properties-xform"),P=e("./workbook-calc-properties-xform"),D=function(z){w(M,z);var B=v(M);function M(){var I;return y(this,M),I=B.call(this),I.map={fileVersion:M.STATIC_XFORMS.fileVersion,workbookPr:new E,bookViews:new i({tag:"bookViews",count:!1,childXform:new p}),sheets:new i({tag:"sheets",count:!1,childXform:new o}),definedNames:new i({tag:"definedNames",count:!1,childXform:new n}),calcPr:new P},I}return b(M,[{key:"prepare",value:function(T){T.sheets=T.worksheets;var C=[],O=0;T.sheets.forEach(function(A){if(A.pageSetup&&A.pageSetup.printArea&&A.pageSetup.printArea.split("&&").forEach(function(N){var F=N.split(":"),j={name:"_xlnm.Print_Area",ranges:["'".concat(A.name,"'!$").concat(F[0],":$").concat(F[1])],localSheetId:O};C.push(j)}),A.pageSetup&&(A.pageSetup.printTitlesRow||A.pageSetup.printTitlesColumn)){var L=[];if(A.pageSetup.printTitlesColumn){var U=A.pageSetup.printTitlesColumn.split(":");L.push("'".concat(A.name,"'!$").concat(U[0],":$").concat(U[1]))}if(A.pageSetup.printTitlesRow){var W=A.pageSetup.printTitlesRow.split(":");L.push("'".concat(A.name,"'!$").concat(W[0],":$").concat(W[1]))}var $={name:"_xlnm.Print_Titles",ranges:L,localSheetId:O};C.push($)}O++}),C.length&&(T.definedNames=T.definedNames.concat(C)),(T.media||[]).forEach(function(A,L){A.name=A.type+(L+1)})}},{key:"render",value:function(T,C){T.openXml(a.StdDocAttributes),T.openNode("workbook",M.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(T),this.map.workbookPr.render(T,C.properties),this.map.bookViews.render(T,C.views),this.map.sheets.render(T,C.sheets),this.map.definedNames.render(T,C.definedNames),this.map.calcPr.render(T,C.calcProperties),T.closeNode()}},{key:"parseOpen",value:function(T){if(this.parser)return this.parser.parseOpen(T),!0;switch(T.name){case"workbook":return!0;default:return this.parser=this.map[T.name],this.parser&&this.parser.parseOpen(T),!0}}},{key:"parseText",value:function(T){this.parser&&this.parser.parseText(T)}},{key:"parseClose",value:function(T){if(this.parser)return this.parser.parseClose(T)||(this.parser=void 0),!0;switch(T){case"workbook":return 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;default:return!0}}},{key:"reconcile",value:function(T){var C=(T.workbookRels||[]).reduce(function(W,$){return W[$.Id]=$,W},{}),O=[],A,L=0;(T.sheets||[]).forEach(function(W){var $=C[W.rId];$&&(A=T.worksheetHash["xl/".concat($.Target.replace(/^(\s|\/xl\/)+/,""))],A&&(A.name=W.name,A.id=W.id,A.state=W.state,O[L++]=A))});var U=[];m.each(T.definedNames,function(W){if(W.name==="_xlnm.Print_Area"){if(A=O[W.localSheetId],A){A.pageSetup||(A.pageSetup={});var $=c.decodeEx(W.ranges[0]);A.pageSetup.printArea=A.pageSetup.printArea?"".concat(A.pageSetup.printArea,"&&").concat($.dimensions):$.dimensions}}else if(W.name==="_xlnm.Print_Titles"){if(A=O[W.localSheetId],A){A.pageSetup||(A.pageSetup={});var N=W.ranges.join(","),F=/\$/g,j=/\$\d+:\$\d+/,V=N.match(j);if(V&&V.length){var te=V[0];A.pageSetup.printTitlesRow=te.replace(F,"")}var re=/\$[A-Z]+:\$[A-Z]+/,le=N.match(re);if(le&&le.length){var ye=le[0];A.pageSetup.printTitlesColumn=ye.replace(F,"")}}}else U.push(W)}),T.definedNames=U,T.media.forEach(function(W,$){W.index=$})}}]),M}(r);D.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"},D.STATIC_XFORMS={fileVersion:new t({tag:"fileVersion",$:{appName:"xl",lastEdited:5,lowestEdited:5,rupBuild:9303}})},S.exports=D},{"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"../static-xform":119,"./defined-name-xform":32,"./sheet-xform":33,"./workbook-calc-properties-xform":34,"./workbook-properties-xform":35,"./workbook-view-xform":36}],38:[function(e,S,_){function u(h,l){var d=Object.keys(h);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(h);l&&(s=s.filter(function(m){return Object.getOwnPropertyDescriptor(h,m).enumerable})),d.push.apply(d,s)}return d}function y(h){for(var l=1;l"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n._model=i,n}return b(t,[{key:"render",value:function(n,o,p){o===p[2]?n.leafNode(this.tag):this.tag==="x:SizeWithCells"&&o===p[1]&&n.leafNode(this.tag)}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={},this.model[this.tag]=!0,!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return this._model&&this._model.tag}}]),t}(m);S.exports=c},{"../../base-xform":31}],41:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n._model=i,n}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.text="",!0;default:return!1}}},{key:"parseText",value:function(n){this.text=n}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return this._model&&this._model.tag}}]),t}(m);S.exports=c},{"../../base-xform":31}],42:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"getAnchorRect",value:function(n){var o=Math.floor(n.left),p=Math.floor((n.left-o)*68),E=Math.floor(n.top),P=Math.floor((n.top-E)*18),D=Math.floor(n.right),z=Math.floor((n.right-D)*68),B=Math.floor(n.bottom),M=Math.floor((n.bottom-B)*18);return[o,p,E,P,D,z,B,M]}},{key:"getDefaultRect",value:function(n){var o=n.col,p=6,E=Math.max(n.row-2,0),P=14,D=o+2,z=2,B=E+4,M=16;return[o,p,E,P,D,z,B,M]}},{key:"render",value:function(n,o){var p=o.anchor?this.getAnchorRect(o.anchor):this.getDefaultRect(o.refAddress);n.leafNode("x:Anchor",null,p.join(", "))}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.text="",!0;default:return!1}}},{key:"parseText",value:function(n){this.text=n}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"x:Anchor"}}]),t}(m);S.exports=c},{"../base-xform":31}],43:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../base-xform"),c=e("./vml-anchor-xform"),a=e("./style/vml-protection-xform"),r=e("./style/vml-position-xform"),t=["twoCells","oneCells","absolute"],i=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={"x:Anchor":new c,"x:Locked":new a({tag:"x:Locked"}),"x:LockText":new a({tag:"x:LockText"}),"x:SizeWithCells":new r({tag:"x:SizeWithCells"}),"x:MoveWithCells":new r({tag:"x:MoveWithCells"})},E}return b(p,[{key:"render",value:function(P,D){var z=D.note,B=z.protection,M=z.editAs;P.openNode(this.tag,{ObjectType:"Note"}),this.map["x:MoveWithCells"].render(P,M,t),this.map["x:SizeWithCells"].render(P,M,t),this.map["x:Anchor"].render(P,D),this.map["x:Locked"].render(P,B.locked),P.leafNode("x:AutoFill",null,"False"),this.map["x:LockText"].render(P,B.lockText),P.leafNode("x:Row",null,D.refAddress.row-1),P.leafNode("x:Column",null,D.refAddress.col-1),P.closeNode()}},{key:"parseOpen",value:function(P){switch(P.name){case this.tag:this.reset(),this.model={anchor:[],protection:{},editAs:""};break;default:this.parser=this.map[P.name],this.parser&&this.parser.parseOpen(P);break}return!0}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){case this.tag:return this.normalizeModel(),!1;default:return!0}}},{key:"normalizeModel",value:function(){var P=Object.assign({},this.map["x:MoveWithCells"].model,this.map["x:SizeWithCells"].model),D=Object.keys(P).length;this.model.editAs=t[D],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}},{key:"tag",get:function(){return"x:ClientData"}}]),p}(m);S.exports=i},{"../base-xform":31,"./style/vml-position-xform":40,"./style/vml-protection-xform":41,"./vml-anchor-xform":42}],44:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("./vml-shape-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"v:shape":new a},o}return b(n,[{key:"render",value:function(p,E){var P=this;p.openXml(m.StdDocAttributes),p.openNode(this.tag,n.DRAWING_ATTRIBUTES),p.openNode("o:shapelayout",{"v:ext":"edit"}),p.leafNode("o:idmap",{"v:ext":"edit",data:1}),p.closeNode(),p.openNode("v:shapetype",{id:"_x0000_t202",coordsize:"21600,21600","o:spt":202,path:"m,l,21600r21600,l21600,xe"}),p.leafNode("v:stroke",{joinstyle:"miter"}),p.leafNode("v:path",{gradientshapeok:"t","o:connecttype":"rect"}),p.closeNode(),E.comments.forEach(function(D,z){P.map["v:shape"].render(p,D,z)}),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset(),this.model={comments:[]};break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.model.comments.push(this.parser.model),this.parser=void 0),!0;switch(p){case this.tag:return!1;default:return!0}}},{key:"reconcile",value:function(p,E){var P=this;p.anchors.forEach(function(D){D.br?P.map["xdr:twoCellAnchor"].reconcile(D,E):P.map["xdr:oneCellAnchor"].reconcile(D,E)})}},{key:"tag",get:function(){return"xml"}}]),n}(c);r.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"},S.exports=r},{"../../../utils/xml-stream":27,"../base-xform":31,"./vml-shape-xform":45}],45:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./vml-textbox-xform"),a=e("./vml-client-data-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"v:textbox":new c,"x:ClientData":new a},o}return b(n,[{key:"render",value:function(p,E,P){p.openNode("v:shape",n.V_SHAPE_ATTRIBUTES(E,P)),p.leafNode("v:fill",{color2:"infoBackground [80]"}),p.leafNode("v:shadow",{color:"none [81]",obscured:"t"}),p.leafNode("v:path",{"o:connecttype":"none"}),this.map["v:textbox"].render(p,E),this.map["x:ClientData"].render(p,E),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset(),this.model={margins:{insetmode:p.attributes["o:insetmode"]},anchor:"",editAs:"",protection:{}};break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.parser=void 0),!0;switch(p){case this.tag:return 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;default:return!0}}},{key:"tag",get:function(){return"v:shape"}}]),n}(m);r.V_SHAPE_ATTRIBUTES=function(t,i){return{id:"_x0000_s".concat(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":t.note.margins&&t.note.margins.insetmode}},S.exports=r},{"../base-xform":31,"./vml-client-data-xform":43,"./vml-textbox-xform":46}],46:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"conversionUnit",value:function(n,o,p){return"".concat(parseFloat(n)*o.toFixed(2)).concat(p)}},{key:"reverseConversionUnit",value:function(n){var o=this;return(n||"").split(",").map(function(p){return Number(parseFloat(o.conversionUnit(parseFloat(p),.1,"")).toFixed(2))})}},{key:"render",value:function(n,o){var p=this,E={style:"mso-direction-alt:auto"};if(o&&o.note){var P=o.note&&o.note.margins,D=P.inset;Array.isArray(D)&&(D=D.map(function(z){return p.conversionUnit(z,10,"mm")}).join(",")),D&&(E.inset=D)}n.openNode("v:textbox",E),n.leafNode("div",{style:"text-align:left"}),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={inset:this.reverseConversionUnit(n.attributes.inset)},!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"v:textbox"}}]),t}(m);S.exports=c},{"../base-xform":31}],47:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("./base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"createNewModel",value:function(n){return{}}},{key:"parseOpen",value:function(n){return this.parser=this.parser||this.map[n.name],this.parser?(this.parser.parseOpen(n),!0):n.name===this.tag?(this.model=this.createNewModel(n),!0):!1}},{key:"parseText",value:function(n){this.parser&&this.parser.parseText(n)}},{key:"onParserClose",value:function(n,o){this.model[n]=o.model}},{key:"parseClose",value:function(n){return this.parser?(this.parser.parseClose(n)||(this.onParserClose(n,this.parser),this.parser=void 0),!0):n!==this.tag}}]),t}(m);S.exports=c},{"./base-xform":31}],48:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.openNode("HeadingPairs"),n.openNode("vt:vector",{size:2,baseType:"variant"}),n.openNode("vt:variant"),n.leafNode("vt:lpstr",void 0,"Worksheets"),n.closeNode(),n.openNode("vt:variant"),n.leafNode("vt:i4",void 0,o.length),n.closeNode(),n.closeNode(),n.closeNode()}},{key:"parseOpen",value:function(n){return n.name==="HeadingPairs"}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){return n!=="HeadingPairs"}}]),t}(m);S.exports=c},{"../base-xform":31}],49:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.openNode("TitlesOfParts"),n.openNode("vt:vector",{size:o.length,baseType:"lpstr"}),o.forEach(function(p){n.leafNode("vt:lpstr",void 0,p.name)}),n.closeNode(),n.closeNode()}},{key:"parseOpen",value:function(n){return n.name==="TitlesOfParts"}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){return n!=="TitlesOfParts"}}]),t}(m);S.exports=c},{"../base-xform":31}],50:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("../simple/string-xform"),r=e("./app-heading-pairs-xform"),t=e("./app-titles-of-parts-xform"),i=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={Company:new a({tag:"Company"}),Manager:new a({tag:"Manager"}),HeadingPairs:new r,TitleOfParts:new t},E}return b(p,[{key:"render",value:function(P,D){P.openXml(m.StdDocAttributes),P.openNode("Properties",p.PROPERTY_ATTRIBUTES),P.leafNode("Application",void 0,"Microsoft Excel"),P.leafNode("DocSecurity",void 0,"0"),P.leafNode("ScaleCrop",void 0,"false"),this.map.HeadingPairs.render(P,D.worksheets),this.map.TitleOfParts.render(P,D.worksheets),this.map.Company.render(P,D.company||""),this.map.Manager.render(P,D.manager),P.leafNode("LinksUpToDate",void 0,"false"),P.leafNode("SharedDoc",void 0,"false"),P.leafNode("HyperlinksChanged",void 0,"false"),P.leafNode("AppVersion",void 0,"16.0300"),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"Properties":return!0;default:return this.parser=this.map[P.name],this.parser?(this.parser.parseOpen(P),!0):!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){case"Properties":return this.model={worksheets:this.map.TitleOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1;default:return!0}}}]),p}(c);i.DateFormat=function(n){return n.toISOString().replace(/[.]\d{3,6}/,"")},i.DateAttrs={"xsi:type":"dcterms:W3CDTF"},i.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties","xmlns:vt":"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"},S.exports=i},{"../../../utils/xml-stream":27,"../base-xform":31,"../simple/string-xform":118,"./app-heading-pairs-xform":48,"./app-titles-of-parts-xform":49}],51:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){o.openXml(m.StdDocAttributes),o.openNode("Types",i.PROPERTY_ATTRIBUTES);var E={};(p.media||[]).forEach(function(D){if(D.type==="image"){var z=D.extension;E[z]||(E[z]=!0,o.leafNode("Default",{Extension:z,ContentType:"image/".concat(z)}))}}),o.leafNode("Default",{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}),o.leafNode("Default",{Extension:"xml",ContentType:"application/xml"}),o.leafNode("Override",{PartName:"/xl/workbook.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"}),p.worksheets.forEach(function(D){var z="/xl/worksheets/sheet".concat(D.id,".xml");o.leafNode("Override",{PartName:z,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"})}),o.leafNode("Override",{PartName:"/xl/theme/theme1.xml",ContentType:"application/vnd.openxmlformats-officedocument.theme+xml"}),o.leafNode("Override",{PartName:"/xl/styles.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"});var P=p.sharedStrings&&p.sharedStrings.count;P&&o.leafNode("Override",{PartName:"/xl/sharedStrings.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"}),p.tables&&p.tables.forEach(function(D){o.leafNode("Override",{PartName:"/xl/tables/".concat(D.target),ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"})}),p.drawings&&p.drawings.forEach(function(D){o.leafNode("Override",{PartName:"/xl/drawings/".concat(D.name,".xml"),ContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})}),p.commentRefs&&(o.leafNode("Default",{Extension:"vml",ContentType:"application/vnd.openxmlformats-officedocument.vmlDrawing"}),p.commentRefs.forEach(function(D){var z=D.commentName;o.leafNode("Override",{PartName:"/xl/".concat(z,".xml"),ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"})})),o.leafNode("Override",{PartName:"/docProps/core.xml",ContentType:"application/vnd.openxmlformats-package.core-properties+xml"}),o.leafNode("Override",{PartName:"/docProps/app.xml",ContentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml"}),o.closeNode()}},{key:"parseOpen",value:function(){return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),i}(c);a.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"},S.exports=a},{"../../../utils/xml-stream":27,"../base-xform":31}],52:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("../simple/date-xform"),r=e("../simple/string-xform"),t=e("../simple/integer-xform"),i=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={"dc:creator":new r({tag:"dc:creator"}),"dc:title":new r({tag:"dc:title"}),"dc:subject":new r({tag:"dc:subject"}),"dc:description":new r({tag:"dc:description"}),"dc:identifier":new r({tag:"dc:identifier"}),"dc:language":new r({tag:"dc:language"}),"cp:keywords":new r({tag:"cp:keywords"}),"cp:category":new r({tag:"cp:category"}),"cp:lastModifiedBy":new r({tag:"cp:lastModifiedBy"}),"cp:lastPrinted":new a({tag:"cp:lastPrinted",format:p.DateFormat}),"cp:revision":new t({tag:"cp:revision"}),"cp:version":new r({tag:"cp:version"}),"cp:contentStatus":new r({tag:"cp:contentStatus"}),"cp:contentType":new r({tag:"cp:contentType"}),"dcterms:created":new a({tag:"dcterms:created",attrs:p.DateAttrs,format:p.DateFormat}),"dcterms:modified":new a({tag:"dcterms:modified",attrs:p.DateAttrs,format:p.DateFormat})},E}return b(p,[{key:"render",value:function(P,D){P.openXml(m.StdDocAttributes),P.openNode("cp:coreProperties",p.CORE_PROPERTY_ATTRIBUTES),this.map["dc:creator"].render(P,D.creator),this.map["dc:title"].render(P,D.title),this.map["dc:subject"].render(P,D.subject),this.map["dc:description"].render(P,D.description),this.map["dc:identifier"].render(P,D.identifier),this.map["dc:language"].render(P,D.language),this.map["cp:keywords"].render(P,D.keywords),this.map["cp:category"].render(P,D.category),this.map["cp:lastModifiedBy"].render(P,D.lastModifiedBy),this.map["cp:lastPrinted"].render(P,D.lastPrinted),this.map["cp:revision"].render(P,D.revision),this.map["cp:version"].render(P,D.version),this.map["cp:contentStatus"].render(P,D.contentStatus),this.map["cp:contentType"].render(P,D.contentType),this.map["dcterms:created"].render(P,D.created),this.map["dcterms:modified"].render(P,D.modified),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"cp:coreProperties":case"coreProperties":return!0;default:if(this.parser=this.map[P.name],this.parser)return this.parser.parseOpen(P),!0;throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(P)))}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){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: ".concat(P))}}}]),p}(c);i.DateFormat=function(n){return n.toISOString().replace(/[.]\d{3}/,"")},i.DateAttrs={"xsi:type":"dcterms:W3CDTF"},i.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"},S.exports=i},{"../../../utils/xml-stream":27,"../base-xform":31,"../simple/date-xform":116,"../simple/integer-xform":117,"../simple/string-xform":118}],53:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("Relationship",o)}},{key:"parseOpen",value:function(n){switch(n.name){case"Relationship":return this.model=n.attributes,!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],54:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("./relationship-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={Relationship:new a},o}return b(n,[{key:"render",value:function(p,E){var P=this;E=E||this._values,p.openXml(m.StdDocAttributes),p.openNode("Relationships",n.RELATIONSHIPS_ATTRIBUTES),E.forEach(function(D){P.map.Relationship.render(p,D)}),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"Relationships":return this.model=[],!0;default:if(this.parser=this.map[p.name],this.parser)return this.parser.parseOpen(p),!0;throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(p)))}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.model.push(this.parser.model),this.parser=void 0),!0;switch(p){case"Relationships":return!1;default:throw new Error("Unexpected xml node in parseClose: ".concat(p))}}}]),n}(c);r.RELATIONSHIPS_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},S.exports=r},{"../../../utils/xml-stream":27,"../base-xform":31,"./relationship-xform":53}],55:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"parseOpen",value:function(n){if(this.parser)return this.parser.parseOpen(n),!0;switch(n.name){case this.tag:this.reset(),this.model={range:{editAs:n.attributes.editAs||"oneCell"}};break;default:this.parser=this.map[n.name],this.parser&&this.parser.parseOpen(n);break}return!0}},{key:"parseText",value:function(n){this.parser&&this.parser.parseText(n)}},{key:"reconcilePicture",value:function(n,o){if(n&&n.rId){var p=o.rels[n.rId],E=p.Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(E){var P=E[1],D=o.mediaIndex[P];return o.media[D]}}}}]),t}(m);S.exports=c},{"../base-xform":31}],56:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("./blip-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={"a:blip":new c},n}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag),this.map["a:blip"].render(o,p),o.openNode("a:stretch"),o.leafNode("a:fillRect"),o.closeNode(),o.closeNode()}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;switch(o.name){case this.tag:this.reset();break;default:this.parser=this.map[o.name],this.parser&&this.parser.parseOpen(o);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(o){if(this.parser)return this.parser.parseClose(o)||(this.parser=void 0),!0;switch(o){case this.tag:return this.model=this.map["a:blip"].model,!1;default:return!0}}},{key:"tag",get:function(){return"xdr:blipFill"}}]),i}(m);S.exports=a},{"../base-xform":31,"./blip-xform":57}],57:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:embed":o.rId,cstate:"print"})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:embed"]},!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"a:blip"}}]),t}(m);S.exports=c},{"../base-xform":31}],58:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n){n.openNode(this.tag),n.leafNode("a:picLocks",{noChangeAspect:"1"}),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"xdr:cNvPicPr"}}]),t}(m);S.exports=c},{"../base-xform":31}],59:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./hlink-click-xform"),a=e("./ext-lst-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"a:hlinkClick":new c,"a:extLst":new a},o}return b(n,[{key:"render",value:function(p,E){p.openNode(this.tag,{id:E.index,name:"Picture ".concat(E.index)}),this.map["a:hlinkClick"].render(p,E),this.map["a:extLst"].render(p,E),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset();break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.parser=void 0),!0;switch(p){case this.tag:return this.model=this.map["a:hlinkClick"].model,!1;default:return!0}}},{key:"tag",get:function(){return"xdr:cNvPr"}}]),n}(m);S.exports=r},{"../base-xform":31,"./ext-lst-xform":62,"./hlink-click-xform":64}],60:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("../simple/integer-xform"),a=function(r){w(i,r);var t=v(i);function i(n){var o;return y(this,i),o=t.call(this),o.tag=n.tag,o.map={"xdr:col":new c({tag:"xdr:col",zero:!0}),"xdr:colOff":new c({tag:"xdr:colOff",zero:!0}),"xdr:row":new c({tag:"xdr:row",zero:!0}),"xdr:rowOff":new c({tag:"xdr:rowOff",zero:!0})},o}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag),this.map["xdr:col"].render(o,p.nativeCol),this.map["xdr:colOff"].render(o,p.nativeColOff),this.map["xdr:row"].render(o,p.nativeRow),this.map["xdr:rowOff"].render(o,p.nativeRowOff),o.closeNode()}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;switch(o.name){case this.tag:this.reset();break;default:this.parser=this.map[o.name],this.parser&&this.parser.parseOpen(o);break}return!0}},{key:"parseText",value:function(o){this.parser&&this.parser.parseText(o)}},{key:"parseClose",value:function(o){if(this.parser)return this.parser.parseClose(o)||(this.parser=void 0),!0;switch(o){case this.tag:return 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;default:return!0}}}]),i}(m);S.exports=a},{"../base-xform":31,"../simple/integer-xform":117}],61:[function(e,S,_){function u(o){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(E){return typeof E}:u=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},u(o)}function y(o,p){if(!(o instanceof p))throw new TypeError("Cannot call a class as a function")}function g(o,p){for(var E=0;E"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(o){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(E){return E.__proto__||Object.getPrototypeOf(E)},s(o)}var m=e("../../../utils/col-cache"),c=e("../../../utils/xml-stream"),a=e("../base-xform"),r=e("./two-cell-anchor-xform"),t=e("./one-cell-anchor-xform");function i(o){var p=typeof o.range=="string"?m.decode(o.range):o.range;return p.br?"xdr:twoCellAnchor":"xdr:oneCellAnchor"}var n=function(o){w(E,o);var p=v(E);function E(){var P;return y(this,E),P=p.call(this),P.map={"xdr:twoCellAnchor":new r,"xdr:oneCellAnchor":new t},P}return b(E,[{key:"prepare",value:function(D){var z=this;D.anchors.forEach(function(B,M){B.anchorType=i(B);var I=z.map[B.anchorType];I.prepare(B,{index:M})})}},{key:"render",value:function(D,z){var B=this;D.openXml(c.StdDocAttributes),D.openNode(this.tag,E.DRAWING_ATTRIBUTES),z.anchors.forEach(function(M){var I=B.map[M.anchorType];I.render(D,M)}),D.closeNode()}},{key:"parseOpen",value:function(D){if(this.parser)return this.parser.parseOpen(D),!0;switch(D.name){case this.tag:this.reset(),this.model={anchors:[]};break;default:this.parser=this.map[D.name],this.parser&&this.parser.parseOpen(D);break}return!0}},{key:"parseText",value:function(D){this.parser&&this.parser.parseText(D)}},{key:"parseClose",value:function(D){if(this.parser)return this.parser.parseClose(D)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0;switch(D){case this.tag:return!1;default:return!0}}},{key:"reconcile",value:function(D,z){var B=this;D.anchors.forEach(function(M){M.br?B.map["xdr:twoCellAnchor"].reconcile(M,z):B.map["xdr:oneCellAnchor"].reconcile(M,z)})}},{key:"tag",get:function(){return"xdr:wsDr"}}]),E}(a);n.DRAWING_ATTRIBUTES={"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"},S.exports=n},{"../../../utils/col-cache":19,"../../../utils/xml-stream":27,"../base-xform":31,"./one-cell-anchor-xform":66,"./two-cell-anchor-xform":69}],62:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n){n.openNode(this.tag),n.openNode("a:ext",{uri:"{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"}),n.leafNode("a16:creationId",{"xmlns:a16":"http://schemas.microsoft.com/office/drawing/2014/main",id:"{00000000-0008-0000-0000-000002000000}"}),n.closeNode(),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(n){switch(n){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"a:extLst"}}]),t}(m);S.exports=c},{"../base-xform":31}],63:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=9525,a=function(r){w(i,r);var t=v(i);function i(n){var o;return y(this,i),o=t.call(this),o.tag=n.tag,o.map={},o}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag);var E=Math.floor(p.width*c),P=Math.floor(p.height*c);o.addAttribute("cx",E),o.addAttribute("cy",P),o.closeNode()}},{key:"parseOpen",value:function(o){return o.name===this.tag?(this.model={width:parseInt(o.attributes.cx||"0",10)/c,height:parseInt(o.attributes.cy||"0",10)/c},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),i}(m);S.exports=a},{"../base-xform":31}],64:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o.hyperlinks&&o.hyperlinks.rId&&n.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:id":o.hyperlinks.rId,tooltip:o.hyperlinks.tooltip})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={hyperlinks:{rId:n.attributes["r:id"],tooltip:n.attributes.tooltip}},!0;default:return!0}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"a:hlinkClick"}}]),t}(m);S.exports=c},{"../base-xform":31}],65:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./c-nv-pr-xform"),a=e("./c-nv-pic-pr-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"xdr:cNvPr":new c,"xdr:cNvPicPr":new a},o}return b(n,[{key:"render",value:function(p,E){p.openNode(this.tag),this.map["xdr:cNvPr"].render(p,E),this.map["xdr:cNvPicPr"].render(p,E),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case this.tag:this.reset();break;default:this.parser=this.map[p.name],this.parser&&this.parser.parseOpen(p);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.parser=void 0),!0;switch(p){case this.tag:return this.model=this.map["xdr:cNvPr"].model,!1;default:return!0}}},{key:"tag",get:function(){return"xdr:nvPicPr"}}]),n}(m);S.exports=r},{"../base-xform":31,"./c-nv-pic-pr-xform":58,"./c-nv-pr-xform":59}],66:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("./base-cell-anchor-xform"),c=e("../static-xform"),a=e("./cell-position-xform"),r=e("./ext-xform"),t=e("./pic-xform"),i=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={"xdr:from":new a({tag:"xdr:from"}),"xdr:ext":new r({tag:"xdr:ext"}),"xdr:pic":new t,"xdr:clientData":new c({tag:"xdr:clientData"})},E}return b(p,[{key:"prepare",value:function(P,D){this.map["xdr:pic"].prepare(P.picture,D)}},{key:"render",value:function(P,D){P.openNode(this.tag,{editAs:D.range.editAs||"oneCell"}),this.map["xdr:from"].render(P,D.range.tl),this.map["xdr:ext"].render(P,D.range.ext),this.map["xdr:pic"].render(P,D.picture),this.map["xdr:clientData"].render(P,{}),P.closeNode()}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.parser=void 0),!0;switch(P){case this.tag:return 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;default:return!0}}},{key:"reconcile",value:function(P,D){P.medium=this.reconcilePicture(P.picture,D)}},{key:"tag",get:function(){return"xdr:oneCellAnchor"}}]),p}(m);S.exports=i},{"../static-xform":119,"./base-cell-anchor-xform":55,"./cell-position-xform":60,"./ext-xform":63,"./pic-xform":67}],67:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../base-xform"),c=e("../static-xform"),a=e("./blip-fill-xform"),r=e("./nv-pic-pr-xform"),t=e("./sp-pr"),i=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={"xdr:nvPicPr":new r,"xdr:blipFill":new a,"xdr:spPr":new c(t)},E}return b(p,[{key:"prepare",value:function(P,D){P.index=D.index+1}},{key:"render",value:function(P,D){P.openNode(this.tag),this.map["xdr:nvPicPr"].render(P,D),this.map["xdr:blipFill"].render(P,D),this.map["xdr:spPr"].render(P,D),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case this.tag:this.reset();break;default:this.parser=this.map[P.name],this.parser&&this.parser.parseOpen(P);break}return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(P){if(this.parser)return this.parser.parseClose(P)||(this.mergeModel(this.parser.model),this.parser=void 0),!0;switch(P){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"xdr:pic"}}]),p}(m);S.exports=i},{"../base-xform":31,"../static-xform":119,"./blip-fill-xform":56,"./nv-pic-pr-xform":65,"./sp-pr":68}],68:[function(e,S,_){S.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"}]}]}},{}],69:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("./base-cell-anchor-xform"),c=e("../static-xform"),a=e("./cell-position-xform"),r=e("./pic-xform"),t=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={"xdr:from":new a({tag:"xdr:from"}),"xdr:to":new a({tag:"xdr:to"}),"xdr:pic":new r,"xdr:clientData":new c({tag:"xdr:clientData"})},p}return b(o,[{key:"prepare",value:function(E,P){this.map["xdr:pic"].prepare(E.picture,P)}},{key:"render",value:function(E,P){E.openNode(this.tag,{editAs:P.range.editAs||"oneCell"}),this.map["xdr:from"].render(E,P.range.tl),this.map["xdr:to"].render(E,P.range.br),this.map["xdr:pic"].render(E,P.picture),this.map["xdr:clientData"].render(E,{}),E.closeNode()}},{key:"parseClose",value:function(E){if(this.parser)return this.parser.parseClose(E)||(this.parser=void 0),!0;switch(E){case this.tag:return 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;default:return!0}}},{key:"reconcile",value:function(E,P){E.medium=this.reconcilePicture(E.picture,P)}},{key:"tag",get:function(){return"xdr:twoCellAnchor"}}]),o}(m);S.exports=t},{"../static-xform":119,"./base-cell-anchor-xform":55,"./cell-position-xform":60,"./pic-xform":67}],70:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("./base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.always=!!i.always,n.count=i.count,n.empty=i.empty,n.$count=i.$count||"count",n.$=i.$,n.childXform=i.childXform,n.maxItems=i.maxItems,n}return b(t,[{key:"prepare",value:function(n,o){var p=this.childXform;n&&n.forEach(function(E,P){o.index=P,p.prepare(E,o)})}},{key:"render",value:function(n,o){if(this.always||o&&o.length){n.openNode(this.tag,this.$),this.count&&n.addAttribute(this.$count,o&&o.length||0);var p=this.childXform;(o||[]).forEach(function(E,P){p.render(n,E,P)}),n.closeNode()}else this.empty&&n.leafNode(this.tag)}},{key:"parseOpen",value:function(n){if(this.parser)return this.parser.parseOpen(n),!0;switch(n.name){case this.tag:return this.model=[],!0;default:return this.childXform.parseOpen(n)?(this.parser=this.childXform,!0):!1}}},{key:"parseText",value:function(n){this.parser&&this.parser.parseText(n)}},{key:"parseClose",value:function(n){if(this.parser){if(!this.parser.parseClose(n)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw new Error("Max ".concat(this.childXform.tag," count (").concat(this.maxItems,") exceeded"));return!0}return!1}},{key:"reconcile",value:function(n,o){if(n){var p=this.childXform;n.forEach(function(E){p.reconcile(E,o)})}}}]),t}(m);S.exports=c},{"./base-xform":31}],71:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/col-cache"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){if(p)if(typeof p=="string")o.leafNode("autoFilter",{ref:p});else{var E=function(B){return typeof B=="string"?B:m.getAddress(B.row,B.column).address},P=E(p.from),D=E(p.to);P&&D&&o.leafNode("autoFilter",{ref:"".concat(P,":").concat(D)})}}},{key:"parseOpen",value:function(o){o.name==="autoFilter"&&(this.model=o.attributes.ref)}},{key:"tag",get:function(){return"autoFilter"}}]),i}(c);S.exports=a},{"../../../utils/col-cache":19,"../base-xform":31}],72:[function(e,S,_){function u(D){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(B){return typeof B}:u=function(B){return B&&typeof Symbol=="function"&&B.constructor===Symbol&&B!==Symbol.prototype?"symbol":typeof B},u(D)}function y(D,z){var B=Object.keys(D);if(Object.getOwnPropertySymbols){var M=Object.getOwnPropertySymbols(D);z&&(M=M.filter(function(I){return Object.getOwnPropertyDescriptor(D,I).enumerable})),B.push.apply(B,M)}return B}function g(D){for(var z=1;z"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(D){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(B){return B.__proto__||Object.getPrototypeOf(B)},a(D)}var r=e("../../../utils/utils"),t=e("../base-xform"),i=e("../../../doc/range"),n=e("../../../doc/enums"),o=e("../strings/rich-text-xform");function p(D){if(D==null)return n.ValueType.Null;if(D instanceof String||typeof D=="string")return n.ValueType.String;if(typeof D=="number")return n.ValueType.Number;if(typeof D=="boolean")return n.ValueType.Boolean;if(D instanceof Date)return n.ValueType.Date;if(D.text&&D.hyperlink)return n.ValueType.Hyperlink;if(D.formula)return n.ValueType.Formula;if(D.error)return n.ValueType.Error;throw new Error("I could not understand type of value")}function E(D){switch(D.type){case n.ValueType.Formula:return p(D.result);default:return D.type}}var P=function(D){h(B,D);var z=d(B);function B(){var M;return w(this,B),M=z.call(this),M.richTextXForm=new o,M}return v(B,[{key:"prepare",value:function(I,T){var C=T.styles.addStyleModel(I.style||{},E(I));switch(C&&(I.styleId=C),I.comment&&T.comments.push(g(g({},I.comment),{},{ref:I.address})),I.type){case n.ValueType.String:case n.ValueType.RichText:T.sharedStrings&&(I.ssId=T.sharedStrings.add(I.value));break;case n.ValueType.Date:T.date1904&&(I.date1904=!0);break;case n.ValueType.Hyperlink:T.sharedStrings&&I.text!==void 0&&I.text!==null&&(I.ssId=T.sharedStrings.add(I.text)),T.hyperlinks.push({address:I.address,target:I.hyperlink,tooltip:I.tooltip});break;case n.ValueType.Merge:T.merges.add(I);break;case n.ValueType.Formula:if(T.date1904&&(I.date1904=!0),I.shareType==="shared"&&(I.si=T.siFormulae++),I.formula)T.formulae[I.address]=I;else if(I.sharedFormula){var O=T.formulae[I.sharedFormula];if(!O)throw new Error("Shared Formula master must exist above and or left of clone for cell ".concat(I.address));O.si===void 0?(O.shareType="shared",O.si=T.siFormulae++,O.range=new i(O.address,I.address)):O.range&&O.range.expandToAddress(I.address),I.si=O.si}break}}},{key:"renderFormula",value:function(I,T){var C=null;switch(T.shareType){case"shared":C={t:"shared",ref:T.ref||T.range.range,si:T.si};break;case"array":C={t:"array",ref:T.ref};break;default:T.si!==void 0&&(C={t:"shared",si:T.si});break}switch(p(T.result)){case n.ValueType.Null:I.leafNode("f",C,T.formula);break;case n.ValueType.String:I.addAttribute("t","str"),I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result);break;case n.ValueType.Number:I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result);break;case n.ValueType.Boolean:I.addAttribute("t","b"),I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result?1:0);break;case n.ValueType.Error:I.addAttribute("t","e"),I.leafNode("f",C,T.formula),I.leafNode("v",null,T.result.error);break;case n.ValueType.Date:I.leafNode("f",C,T.formula),I.leafNode("v",null,r.dateToExcel(T.result,T.date1904));break;default:throw new Error("I could not understand type of value")}}},{key:"render",value:function(I,T){var C=this;if(!(T.type===n.ValueType.Null&&!T.styleId)){switch(I.openNode("c"),I.addAttribute("r",T.address),T.styleId&&I.addAttribute("s",T.styleId),T.type){case n.ValueType.Null:break;case n.ValueType.Number:I.leafNode("v",null,T.value);break;case n.ValueType.Boolean:I.addAttribute("t","b"),I.leafNode("v",null,T.value?"1":"0");break;case n.ValueType.Error:I.addAttribute("t","e"),I.leafNode("v",null,T.value.error);break;case n.ValueType.String:case n.ValueType.RichText:T.ssId!==void 0?(I.addAttribute("t","s"),I.leafNode("v",null,T.ssId)):T.value&&T.value.richText?(I.addAttribute("t","inlineStr"),I.openNode("is"),T.value.richText.forEach(function(O){C.richTextXForm.render(I,O)}),I.closeNode("is")):(I.addAttribute("t","str"),I.leafNode("v",null,T.value));break;case n.ValueType.Date:I.leafNode("v",null,r.dateToExcel(T.value,T.date1904));break;case n.ValueType.Hyperlink:T.ssId!==void 0?(I.addAttribute("t","s"),I.leafNode("v",null,T.ssId)):(I.addAttribute("t","str"),I.leafNode("v",null,T.text));break;case n.ValueType.Formula:this.renderFormula(I,T);break;case n.ValueType.Merge:break}I.closeNode()}}},{key:"parseOpen",value:function(I){if(this.parser)return this.parser.parseOpen(I),!0;switch(I.name){case"c":return this.model={address:I.attributes.r},this.t=I.attributes.t,I.attributes.s&&(this.model.styleId=parseInt(I.attributes.s,10)),!0;case"f":return this.currentNode="f",this.model.si=I.attributes.si,this.model.shareType=I.attributes.t,this.model.ref=I.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(I),!0;default:return!1}}},{key:"parseText",value:function(I){if(this.parser){this.parser.parseText(I);return}switch(this.currentNode){case"f":this.model.formula=this.model.formula?this.model.formula+I:I;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+I:I:this.model.value=this.model.value?this.model.value+I:I;break}}},{key:"parseClose",value:function(I){switch(I){case"c":{var T=this.model;if(T.formula||T.shareType)T.type=n.ValueType.Formula,T.value&&(this.t==="str"?T.result=r.xmlDecode(T.value):this.t==="b"?T.result=parseInt(T.value,10)!==0:this.t==="e"?T.result={error:T.value}:T.result=parseFloat(T.value),T.value=void 0);else if(T.value!==void 0)switch(this.t){case"s":T.type=n.ValueType.String,T.value=parseInt(T.value,10);break;case"str":T.type=n.ValueType.String,T.value=r.xmlDecode(T.value);break;case"inlineStr":T.type=n.ValueType.String;break;case"b":T.type=n.ValueType.Boolean,T.value=parseInt(T.value,10)!==0;break;case"e":T.type=n.ValueType.Error,T.value={error:T.value};break;default:T.type=n.ValueType.Number,T.value=parseFloat(T.value);break}else T.styleId?T.type=n.ValueType.Null:T.type=n.ValueType.Merge;return!1}case"f":case"v":case"is":return this.currentNode=void 0,!0;case"t":return this.parser?(this.parser.parseClose(I),!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(I),!0):!1}}},{key:"reconcile",value:function(I,T){var C=I.styleId&&T.styles&&T.styles.getStyleModel(I.styleId);switch(C&&(I.style=C),I.styleId!==void 0&&(I.styleId=void 0),I.type){case n.ValueType.String:typeof I.value=="number"&&T.sharedStrings&&(I.value=T.sharedStrings.getString(I.value)),I.value.richText&&(I.type=n.ValueType.RichText);break;case n.ValueType.Number:C&&r.isDateFmt(C.numFmt)&&(I.type=n.ValueType.Date,I.value=r.excelToDate(I.value,T.date1904));break;case n.ValueType.Formula:I.result!==void 0&&C&&r.isDateFmt(C.numFmt)&&(I.result=r.excelToDate(I.result,T.date1904)),I.shareType==="shared"&&(I.ref?T.formulae[I.si]=I.address:(I.sharedFormula=T.formulae[I.si],delete I.shareType),delete I.si);break}var O=T.hyperlinkMap[I.address];O&&(I.type===n.ValueType.Formula?(I.text=I.result,I.result=void 0):(I.text=I.value,I.value=void 0),I.type=n.ValueType.Hyperlink,I.hyperlink=O);var A=T.commentsMap&&T.commentsMap[I.address];A&&(I.comment=A)}},{key:"tag",get:function(){return"c"}}]),B}(t);S.exports=P},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/utils":26,"../base-xform":31,"../strings/rich-text-xform":121}],73:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,{iconSet:o.iconSet,iconId:o.iconId})}},{key:"parseOpen",value:function(n){var o=n.attributes;this.model={iconSet:o.iconSet,iconId:m.toIntValue(o.iconId)}}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"x14:cfIcon"}}]),t}(m);S.exports=c},{"../../base-xform":31}],74:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,E){if(!(p instanceof E))throw new TypeError("Cannot call a class as a function")}function g(p,E){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("uuid"),c=m.v4,a=e("../../base-xform"),r=e("../../composite-xform"),t=e("./databar-ext-xform"),i=e("./icon-set-ext-xform"),n={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},o=function(p){w(P,p);var E=v(P);function P(){var D;return y(this,P),D=E.call(this),D.map={"x14:dataBar":D.databarXform=new t,"x14:iconSet":D.iconSetXform=new i},D}return b(P,[{key:"prepare",value:function(z){P.isExt(z)&&(z.x14Id="{".concat(c(),"}").toUpperCase())}},{key:"render",value:function(z,B){if(P.isExt(B))switch(B.type){case"dataBar":this.renderDataBar(z,B);break;case"iconSet":this.renderIconSet(z,B);break}}},{key:"renderDataBar",value:function(z,B){z.openNode(this.tag,{type:"dataBar",id:B.x14Id}),this.databarXform.render(z,B),z.closeNode()}},{key:"renderIconSet",value:function(z,B){z.openNode(this.tag,{type:"iconSet",priority:B.priority,id:B.x14Id||"{".concat(c(),"}")}),this.iconSetXform.render(z,B),z.closeNode()}},{key:"createNewModel",value:function(z){var B=z.attributes;return{type:B.type,x14Id:B.id,priority:a.toIntValue(B.priority)}}},{key:"onParserClose",value:function(z,B){Object.assign(this.model,B.model)}},{key:"tag",get:function(){return"x14:cfRule"}}],[{key:"isExt",value:function(z){return z.type==="dataBar"?t.isExt(z):!!(z.type==="iconSet"&&(z.custom||n[z.iconSet]))}}]),P}(r);S.exports=o},{"../../base-xform":31,"../../composite-xform":47,"./databar-ext-xform":78,"./icon-set-ext-xform":80,uuid:526}],75:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../composite-xform"),c=e("./f-ext-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={"xm:f":n.fExtXform=new c},n}return b(i,[{key:"render",value:function(o,p){o.openNode(this.tag,{type:p.type}),p.value!==void 0&&this.fExtXform.render(o,p.value),o.closeNode()}},{key:"createNewModel",value:function(o){return{type:o.attributes.type}}},{key:"onParserClose",value:function(o,p){switch(o){case"xm:f":this.model.value=p.model?parseFloat(p.model):0;break}}},{key:"tag",get:function(){return"x14:cfvo"}}]),i}(m);S.exports=a},{"../../composite-xform":47,"./f-ext-xform":79}],76:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("./sqref-ext-xform"),a=e("./cf-rule-ext-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"xm:sqref":o.sqRef=new c,"x14:cfRule":o.cfRule=new a},o}return b(n,[{key:"prepare",value:function(p,E){var P=this;p.rules.forEach(function(D){P.cfRule.prepare(D,E)})}},{key:"render",value:function(p,E){var P=this;E.rules.some(a.isExt)&&(p.openNode(this.tag,{"xmlns:xm":"http://schemas.microsoft.com/office/excel/2006/main"}),E.rules.filter(a.isExt).forEach(function(D){return P.cfRule.render(p,D)}),this.sqRef.render(p,E.ref),p.closeNode())}},{key:"createNewModel",value:function(){return{rules:[]}}},{key:"onParserClose",value:function(p,E){switch(p){case"xm:sqref":this.model.ref=E.model;break;case"x14:cfRule":this.model.rules.push(E.model);break}}},{key:"tag",get:function(){return"x14:conditionalFormatting"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"./cf-rule-ext-xform":74,"./sqref-ext-xform":81}],77:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("./cf-rule-ext-xform"),a=e("./conditional-formatting-ext-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"x14:conditionalFormatting":o.cfXform=new a},o}return b(n,[{key:"hasContent",value:function(p){return p.hasExtContent===void 0&&(p.hasExtContent=p.some(function(E){return E.rules.some(c.isExt)})),p.hasExtContent}},{key:"prepare",value:function(p,E){var P=this;p.forEach(function(D){P.cfXform.prepare(D,E)})}},{key:"render",value:function(p,E){var P=this;this.hasContent(E)&&(p.openNode(this.tag),E.forEach(function(D){return P.cfXform.render(p,D)}),p.closeNode())}},{key:"createNewModel",value:function(){return[]}},{key:"onParserClose",value:function(p,E){this.model.push(E.model)}},{key:"tag",get:function(){return"x14:conditionalFormattings"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"./cf-rule-ext-xform":74,"./conditional-formatting-ext-xform":76}],78:[function(e,S,_){function u(D){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(B){return typeof B}:u=function(B){return B&&typeof Symbol=="function"&&B.constructor===Symbol&&B!==Symbol.prototype?"symbol":typeof B},u(D)}function y(D,z){return v(D)||f(D,z)||b(D,z)||g()}function g(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(D,z){if(D){if(typeof D=="string")return w(D,z);var B=Object.prototype.toString.call(D).slice(8,-1);if(B==="Object"&&D.constructor&&(B=D.constructor.name),B==="Map"||B==="Set")return Array.from(D);if(B==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(B))return w(D,z)}}function w(D,z){(z==null||z>D.length)&&(z=D.length);for(var B=0,M=new Array(z);B"u"||!(Symbol.iterator in Object(D)))){var B=[],M=!0,I=!1,T=void 0;try{for(var C=D[Symbol.iterator](),O;!(M=(O=C.next()).done)&&(B.push(O.value),!(z&&B.length===z));M=!0);}catch(A){I=!0,T=A}finally{try{!M&&C.return!=null&&C.return()}finally{if(I)throw T}}return B}}function v(D){if(Array.isArray(D))return D}function h(D,z){if(!(D instanceof z))throw new TypeError("Cannot call a class as a function")}function l(D,z){for(var B=0;B"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function i(D){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(B){return B.__proto__||Object.getPrototypeOf(B)},i(D)}var n=e("../../base-xform"),o=e("../../composite-xform"),p=e("../../style/color-xform"),E=e("./cfvo-ext-xform"),P=function(D){s(B,D);var z=c(B);function B(){var M;return h(this,B),M=z.call(this),M.map={"x14:cfvo":M.cfvoXform=new E,"x14:borderColor":M.borderColorXform=new p("x14:borderColor"),"x14:negativeBorderColor":M.negativeBorderColorXform=new p("x14:negativeBorderColor"),"x14:negativeFillColor":M.negativeFillColorXform=new p("x14:negativeFillColor"),"x14:axisColor":M.axisColorXform=new p("x14:axisColor")},M}return d(B,[{key:"render",value:function(I,T){var C=this;I.openNode(this.tag,{minLength:n.toIntAttribute(T.minLength,0,!0),maxLength:n.toIntAttribute(T.maxLength,100,!0),border:n.toBoolAttribute(T.border,!1),gradient:n.toBoolAttribute(T.gradient,!0),negativeBarColorSameAsPositive:n.toBoolAttribute(T.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:n.toBoolAttribute(T.negativeBarBorderColorSameAsPositive,!0),axisPosition:n.toAttribute(T.axisPosition,"auto"),direction:n.toAttribute(T.direction,"leftToRight")}),T.cfvo.forEach(function(O){C.cfvoXform.render(I,O)}),this.borderColorXform.render(I,T.borderColor),this.negativeBorderColorXform.render(I,T.negativeBorderColor),this.negativeFillColorXform.render(I,T.negativeFillColor),this.axisColorXform.render(I,T.axisColor),I.closeNode()}},{key:"createNewModel",value:function(I){var T=I.attributes;return{cfvo:[],minLength:n.toIntValue(T.minLength,0),maxLength:n.toIntValue(T.maxLength,100),border:n.toBoolValue(T.border,!1),gradient:n.toBoolValue(T.gradient,!0),negativeBarColorSameAsPositive:n.toBoolValue(T.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:n.toBoolValue(T.negativeBarBorderColorSameAsPositive,!0),axisPosition:n.toStringValue(T.axisPosition,"auto"),direction:n.toStringValue(T.direction,"leftToRight")}}},{key:"onParserClose",value:function(I,T){var C=I.split(":"),O=y(C,2),A=O[1];switch(A){case"cfvo":this.model.cfvo.push(T.model);break;default:this.model[A]=T.model;break}}},{key:"tag",get:function(){return"x14:dataBar"}}],[{key:"isExt",value:function(I){return!I.gradient}}]),B}(o);S.exports=P},{"../../base-xform":31,"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-ext-xform":75}],79:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(n){this.model+=n}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"xm:f"}}]),t}(m);S.exports=c},{"../../base-xform":31}],80:[function(e,S,_){function u(D){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(B){return typeof B}:u=function(B){return B&&typeof Symbol=="function"&&B.constructor===Symbol&&B!==Symbol.prototype?"symbol":typeof B},u(D)}function y(D,z){return v(D)||f(D,z)||b(D,z)||g()}function g(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(D,z){if(D){if(typeof D=="string")return w(D,z);var B=Object.prototype.toString.call(D).slice(8,-1);if(B==="Object"&&D.constructor&&(B=D.constructor.name),B==="Map"||B==="Set")return Array.from(D);if(B==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(B))return w(D,z)}}function w(D,z){(z==null||z>D.length)&&(z=D.length);for(var B=0,M=new Array(z);B"u"||!(Symbol.iterator in Object(D)))){var B=[],M=!0,I=!1,T=void 0;try{for(var C=D[Symbol.iterator](),O;!(M=(O=C.next()).done)&&(B.push(O.value),!(z&&B.length===z));M=!0);}catch(A){I=!0,T=A}finally{try{!M&&C.return!=null&&C.return()}finally{if(I)throw T}}return B}}function v(D){if(Array.isArray(D))return D}function h(D,z){if(!(D instanceof z))throw new TypeError("Cannot call a class as a function")}function l(D,z){for(var B=0;B"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function i(D){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(B){return B.__proto__||Object.getPrototypeOf(B)},i(D)}var n=e("../../base-xform"),o=e("../../composite-xform"),p=e("./cfvo-ext-xform"),E=e("./cf-icon-ext-xform"),P=function(D){s(B,D);var z=c(B);function B(){var M;return h(this,B),M=z.call(this),M.map={"x14:cfvo":M.cfvoXform=new p,"x14:cfIcon":M.cfIconXform=new E},M}return d(B,[{key:"render",value:function(I,T){var C=this;I.openNode(this.tag,{iconSet:n.toStringAttribute(T.iconSet),reverse:n.toBoolAttribute(T.reverse,!1),showValue:n.toBoolAttribute(T.showValue,!0),custom:n.toBoolAttribute(T.icons,!1)}),T.cfvo.forEach(function(O){C.cfvoXform.render(I,O)}),T.icons&&T.icons.forEach(function(O,A){O.iconId=A,C.cfIconXform.render(I,O)}),I.closeNode()}},{key:"createNewModel",value:function(I){var T=I.attributes;return{cfvo:[],iconSet:n.toStringValue(T.iconSet,"3TrafficLights"),reverse:n.toBoolValue(T.reverse,!1),showValue:n.toBoolValue(T.showValue,!0)}}},{key:"onParserClose",value:function(I,T){var C=I.split(":"),O=y(C,2),A=O[1];switch(A){case"cfvo":this.model.cfvo.push(T.model);break;case"cfIcon":this.model.icons||(this.model.icons=[]),this.model.icons.push(T.model);break;default:this.model[A]=T.model;break}}},{key:"tag",get:function(){return"x14:iconSet"}}]),B}(o);S.exports=P},{"../../base-xform":31,"../../composite-xform":47,"./cf-icon-ext-xform":73,"./cfvo-ext-xform":75}],81:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(n){this.model+=n}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"xm:sqref"}}]),t}(m);S.exports=c},{"../../base-xform":31}],82:[function(e,S,_){function u(T){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(O){return typeof O}:u=function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},u(T)}function y(T,C){var O=Object.keys(T);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(T);C&&(A=A.filter(function(L){return Object.getOwnPropertyDescriptor(T,L).enumerable})),O.push.apply(O,A)}return O}function g(T){for(var C=1;C"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(T){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(O){return O.__proto__||Object.getPrototypeOf(O)},a(T)}var r=e("../../base-xform"),t=e("../../composite-xform"),i=e("../../../../doc/range"),n=e("./databar-xform"),o=e("./ext-lst-ref-xform"),p=e("./formula-xform"),E=e("./color-scale-xform"),P=e("./icon-set-xform"),D={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},z=function(C){if(C.formulae&&C.formulae[0])return C.formulae[0];var O=new i(C.ref),A=O.tl;switch(C.operator){case"containsText":return'NOT(ISERROR(SEARCH("'.concat(C.text,'",').concat(A,")))");case"containsBlanks":return"LEN(TRIM(".concat(A,"))=0");case"notContainsBlanks":return"LEN(TRIM(".concat(A,"))>0");case"containsErrors":return"ISERROR(".concat(A,")");case"notContainsErrors":return"NOT(ISERROR(".concat(A,"))");default:return}},B=function(C){if(C.formulae&&C.formulae[0])return C.formulae[0];var O=new i(C.ref),A=O.tl;switch(C.timePeriod){case"thisWeek":return"AND(TODAY()-ROUNDDOWN(".concat(A,",0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(").concat(A,",0)-TODAY()<=7-WEEKDAY(TODAY()))");case"lastWeek":return"AND(TODAY()-ROUNDDOWN(".concat(A,",0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(").concat(A,",0)<(WEEKDAY(TODAY())+7))");case"nextWeek":return"AND(ROUNDDOWN(".concat(A,",0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(").concat(A,",0)-TODAY()<(15-WEEKDAY(TODAY())))");case"yesterday":return"FLOOR(".concat(A,",1)=TODAY()-1");case"today":return"FLOOR(".concat(A,",1)=TODAY()");case"tomorrow":return"FLOOR(".concat(A,",1)=TODAY()+1");case"last7Days":return"AND(TODAY()-FLOOR(".concat(A,",1)<=6,FLOOR(").concat(A,",1)<=TODAY())");case"lastMonth":return"AND(MONTH(".concat(A,")=MONTH(EDATE(TODAY(),0-1)),YEAR(").concat(A,")=YEAR(EDATE(TODAY(),0-1)))");case"thisMonth":return"AND(MONTH(".concat(A,")=MONTH(TODAY()),YEAR(").concat(A,")=YEAR(TODAY()))");case"nextMonth":return"AND(MONTH(".concat(A,")=MONTH(EDATE(TODAY(),0+1)),YEAR(").concat(A,")=YEAR(EDATE(TODAY(),0+1)))");default:return}},M=function(C){var O=C.type,A=C.operator;switch(O){case"containsText":case"containsBlanks":case"notContainsBlanks":case"containsErrors":case"notContainsErrors":return{type:"containsText",operator:O};default:return{type:O,operator:A}}},I=function(T){h(O,T);var C=d(O);function O(){var A;return w(this,O),A=C.call(this),A.map={dataBar:A.databarXform=new n,extLst:A.extLstRefXform=new o,formula:A.formulaXform=new p,colorScale:A.colorScaleXform=new E,iconSet:A.iconSetXform=new P},A}return v(O,[{key:"render",value:function(L,U){switch(U.type){case"expression":this.renderExpression(L,U);break;case"cellIs":this.renderCellIs(L,U);break;case"top10":this.renderTop10(L,U);break;case"aboveAverage":this.renderAboveAverage(L,U);break;case"dataBar":this.renderDataBar(L,U);break;case"colorScale":this.renderColorScale(L,U);break;case"iconSet":this.renderIconSet(L,U);break;case"containsText":this.renderText(L,U);break;case"timePeriod":this.renderTimePeriod(L,U);break}}},{key:"renderExpression",value:function(L,U){L.openNode(this.tag,{type:"expression",dxfId:U.dxfId,priority:U.priority}),this.formulaXform.render(L,U.formulae[0]),L.closeNode()}},{key:"renderCellIs",value:function(L,U){var W=this;L.openNode(this.tag,{type:"cellIs",dxfId:U.dxfId,priority:U.priority,operator:U.operator}),U.formulae.forEach(function($){W.formulaXform.render(L,$)}),L.closeNode()}},{key:"renderTop10",value:function(L,U){L.leafNode(this.tag,{type:"top10",dxfId:U.dxfId,priority:U.priority,percent:r.toBoolAttribute(U.percent,!1),bottom:r.toBoolAttribute(U.bottom,!1),rank:r.toIntValue(U.rank,10,!0)})}},{key:"renderAboveAverage",value:function(L,U){L.leafNode(this.tag,{type:"aboveAverage",dxfId:U.dxfId,priority:U.priority,aboveAverage:r.toBoolAttribute(U.aboveAverage,!0)})}},{key:"renderDataBar",value:function(L,U){L.openNode(this.tag,{type:"dataBar",priority:U.priority}),this.databarXform.render(L,U),this.extLstRefXform.render(L,U),L.closeNode()}},{key:"renderColorScale",value:function(L,U){L.openNode(this.tag,{type:"colorScale",priority:U.priority}),this.colorScaleXform.render(L,U),L.closeNode()}},{key:"renderIconSet",value:function(L,U){O.isPrimitive(U)&&(L.openNode(this.tag,{type:"iconSet",priority:U.priority}),this.iconSetXform.render(L,U),L.closeNode())}},{key:"renderText",value:function(L,U){L.openNode(this.tag,{type:U.operator,dxfId:U.dxfId,priority:U.priority,operator:r.toStringAttribute(U.operator,"containsText")});var W=z(U);W&&this.formulaXform.render(L,W),L.closeNode()}},{key:"renderTimePeriod",value:function(L,U){L.openNode(this.tag,{type:"timePeriod",dxfId:U.dxfId,priority:U.priority,timePeriod:U.timePeriod});var W=B(U);W&&this.formulaXform.render(L,W),L.closeNode()}},{key:"createNewModel",value:function(L){var U=L.attributes;return g(g({},M(U)),{},{dxfId:r.toIntValue(U.dxfId),priority:r.toIntValue(U.priority),timePeriod:U.timePeriod,percent:r.toBoolValue(U.percent),bottom:r.toBoolValue(U.bottom),rank:r.toIntValue(U.rank),aboveAverage:r.toBoolValue(U.aboveAverage)})}},{key:"onParserClose",value:function(L,U){switch(L){case"dataBar":case"extLst":case"colorScale":case"iconSet":Object.assign(this.model,U.model);break;case"formula":this.model.formulae=this.model.formulae||[],this.model.formulae.push(U.model);break}}},{key:"tag",get:function(){return"cfRule"}}],[{key:"isPrimitive",value:function(L){return!(L.type==="iconSet"&&(L.custom||D[L.iconSet]))}}]),O}(t);S.exports=I},{"../../../../doc/range":10,"../../base-xform":31,"../../composite-xform":47,"./color-scale-xform":84,"./databar-xform":87,"./ext-lst-ref-xform":88,"./formula-xform":89,"./icon-set-xform":90}],83:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,{type:o.type,val:o.value})}},{key:"parseOpen",value:function(n){this.model={type:n.attributes.type,value:m.toFloatValue(n.attributes.val)}}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"cfvo"}}]),t}(m);S.exports=c},{"../../base-xform":31}],84:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("../../style/color-xform"),a=e("./cfvo-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={cfvo:o.cfvoXform=new a,color:o.colorXform=new c},o}return b(n,[{key:"render",value:function(p,E){var P=this;p.openNode(this.tag),E.cfvo.forEach(function(D){P.cfvoXform.render(p,D)}),E.color.forEach(function(D){P.colorXform.render(p,D)}),p.closeNode()}},{key:"createNewModel",value:function(p){return{cfvo:[],color:[]}}},{key:"onParserClose",value:function(p,E){this.model[p].push(E.model)}},{key:"tag",get:function(){return"colorScale"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-xform":83}],85:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../composite-xform"),c=e("./cf-rule-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={cfRule:new c},n}return b(i,[{key:"render",value:function(o,p){var E=this;p.rules.some(c.isPrimitive)&&(o.openNode(this.tag,{sqref:p.ref}),p.rules.forEach(function(P){c.isPrimitive(P)&&(P.ref=p.ref,E.map.cfRule.render(o,P))}),o.closeNode())}},{key:"createNewModel",value:function(o){var p=o.attributes;return{ref:p.sqref,rules:[]}}},{key:"onParserClose",value:function(o,p){this.model.rules.push(p.model)}},{key:"tag",get:function(){return"conditionalFormatting"}}]),i}(m);S.exports=a},{"../../composite-xform":47,"./cf-rule-xform":82}],86:[function(e,S,_){function u(E){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(D){return typeof D}:u=function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},u(E)}function y(E){return f(E)||w(E)||b(E)||g()}function g(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(E,P){if(E){if(typeof E=="string")return v(E,P);var D=Object.prototype.toString.call(E).slice(8,-1);if(D==="Object"&&E.constructor&&(D=E.constructor.name),D==="Map"||D==="Set")return Array.from(E);if(D==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D))return v(E,P)}}function w(E){if(typeof Symbol<"u"&&Symbol.iterator in Object(E))return Array.from(E)}function f(E){if(Array.isArray(E))return v(E)}function v(E,P){(P==null||P>E.length)&&(P=E.length);for(var D=0,z=new Array(P);D"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function i(E){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(D){return D.__proto__||Object.getPrototypeOf(D)},i(E)}var n=e("../../base-xform"),o=e("./conditional-formatting-xform"),p=function(E){s(D,E);var P=c(D);function D(){var z;return h(this,D),z=P.call(this),z.cfXform=new o,z}return d(D,[{key:"reset",value:function(){this.model=[]}},{key:"prepare",value:function(B,M){var I=B.reduce(function(T,C){return Math.max.apply(Math,[T].concat(y(C.rules.map(function(O){return O.priority||0}))))},1);B.forEach(function(T){T.rules.forEach(function(C){C.priority||(C.priority=I++),C.style&&(C.dxfId=M.styles.addDxfStyle(C.style))})})}},{key:"render",value:function(B,M){var I=this;M.forEach(function(T){I.cfXform.render(B,T)})}},{key:"parseOpen",value:function(B){if(this.parser)return this.parser.parseOpen(B),!0;switch(B.name){case"conditionalFormatting":return this.parser=this.cfXform,this.parser.parseOpen(B),!0;default:return!1}}},{key:"parseText",value:function(B){this.parser&&this.parser.parseText(B)}},{key:"parseClose",value:function(B){return this.parser?this.parser.parseClose(B)?!0:(this.model.push(this.parser.model),this.parser=void 0,!1):!1}},{key:"reconcile",value:function(B,M){B.forEach(function(I){I.rules.forEach(function(T){T.dxfId!==void 0&&(T.style=M.styles.getDxfStyle(T.dxfId),delete T.dxfId)})})}},{key:"tag",get:function(){return"conditionalFormatting"}}]),D}(n);S.exports=p},{"../../base-xform":31,"./conditional-formatting-xform":85}],87:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../composite-xform"),c=e("../../style/color-xform"),a=e("./cfvo-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={cfvo:o.cfvoXform=new a,color:o.colorXform=new c},o}return b(n,[{key:"render",value:function(p,E){var P=this;p.openNode(this.tag),E.cfvo.forEach(function(D){P.cfvoXform.render(p,D)}),this.colorXform.render(p,E.color),p.closeNode()}},{key:"createNewModel",value:function(){return{cfvo:[]}}},{key:"onParserClose",value:function(p,E){switch(p){case"cfvo":this.model.cfvo.push(E.model);break;case"color":this.model.color=E.model;break}}},{key:"tag",get:function(){return"dataBar"}}]),n}(m);S.exports=r},{"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-xform":83}],88:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../../base-xform"),c=e("../../composite-xform"),a=function(i){w(o,i);var n=v(o);function o(){return y(this,o),n.apply(this,arguments)}return b(o,[{key:"render",value:function(E,P){E.leafNode(this.tag,null,P)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(E){this.model+=E}},{key:"parseClose",value:function(E){return E!==this.tag}},{key:"tag",get:function(){return"x14:id"}}]),o}(m),r=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={"x14:id":p.idXform=new a},p}return b(o,[{key:"render",value:function(E,P){E.openNode(this.tag,{uri:"{B025F937-C7B1-47D3-B67F-A62EFF666E3E}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.idXform.render(E,P.x14Id),E.closeNode()}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(E,P){this.model.x14Id=P.model}},{key:"tag",get:function(){return"ext"}}]),o}(c),t=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={ext:new r},p}return b(o,[{key:"render",value:function(E,P){E.openNode(this.tag),this.map.ext.render(E,P),E.closeNode()}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(E,P){Object.assign(this.model,P.model)}},{key:"tag",get:function(){return"extLst"}}]),o}(c);S.exports=t},{"../../base-xform":31,"../../composite-xform":47}],89:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode(this.tag,null,o)}},{key:"parseOpen",value:function(){this.model=""}},{key:"parseText",value:function(n){this.model+=n}},{key:"parseClose",value:function(n){return n!==this.tag}},{key:"tag",get:function(){return"formula"}}]),t}(m);S.exports=c},{"../../base-xform":31}],90:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../base-xform"),c=e("../../composite-xform"),a=e("./cfvo-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={cfvo:o.cfvoXform=new a},o}return b(n,[{key:"render",value:function(p,E){var P=this;p.openNode(this.tag,{iconSet:m.toStringAttribute(E.iconSet,"3TrafficLights"),reverse:m.toBoolAttribute(E.reverse,!1),showValue:m.toBoolAttribute(E.showValue,!0)}),E.cfvo.forEach(function(D){P.cfvoXform.render(p,D)}),p.closeNode()}},{key:"createNewModel",value:function(p){var E=p.attributes;return{iconSet:m.toStringValue(E.iconSet,"3TrafficLights"),reverse:m.toBoolValue(E.reverse),showValue:m.toBoolValue(E.showValue),cfvo:[]}}},{key:"onParserClose",value:function(p,E){this.model[p].push(E.model)}},{key:"tag",get:function(){return"iconSet"}}]),n}(c);S.exports=r},{"../../base-xform":31,"../../composite-xform":47,"./cfvo-xform":83}],91:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"prepare",value:function(n,o){var p=o.styles.addStyleModel(n.style||{});p&&(n.styleId=p)}},{key:"render",value:function(n,o){n.openNode("col"),n.addAttribute("min",o.min),n.addAttribute("max",o.max),o.width&&n.addAttribute("width",o.width),o.styleId&&n.addAttribute("style",o.styleId),o.hidden&&n.addAttribute("hidden","1"),o.bestFit&&n.addAttribute("bestFit","1"),o.outlineLevel&&n.addAttribute("outlineLevel",o.outlineLevel),o.collapsed&&n.addAttribute("collapsed","1"),n.addAttribute("customWidth","1"),n.closeNode()}},{key:"parseOpen",value:function(n){if(n.name==="col"){var o=this.model={min:parseInt(n.attributes.min||"0",10),max:parseInt(n.attributes.max||"0",10),width:n.attributes.width===void 0?void 0:parseFloat(n.attributes.width||"0")};return n.attributes.style&&(o.styleId=parseInt(n.attributes.style,10)),(n.attributes.hidden===!0||n.attributes.hidden==="true"||n.attributes.hidden===1||n.attributes.hidden==="1")&&(o.hidden=!0),n.attributes.bestFit&&(o.bestFit=!0),n.attributes.outlineLevel&&(o.outlineLevel=parseInt(n.attributes.outlineLevel,10)),n.attributes.collapsed&&(o.collapsed=!0),!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"reconcile",value:function(n,o){n.styleId&&(n.style=o.styles.getStyleModel(n.styleId))}},{key:"tag",get:function(){return"col"}}]),t}(m);S.exports=c},{"../base-xform":31}],92:[function(e,S,_){function u(B){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(I){return typeof I}:u=function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},u(B)}function y(B,M){if(!(B instanceof M))throw new TypeError("Cannot call a class as a function")}function g(B,M){for(var I=0;I"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(B){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(I){return I.__proto__||Object.getPrototypeOf(I)},s(B)}function m(B,M){var I=Object.keys(B);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(B);M&&(T=T.filter(function(C){return Object.getOwnPropertyDescriptor(B,C).enumerable})),I.push.apply(I,T)}return I}function c(B){for(var M=1;M1||U>1){var N=O.row+(A-1),F=O.col+(U-1);return c(c({},C.dataValidation),{},{sqref:"".concat(C.address,":").concat(i.encodeAddress(N,F))})}return c(c({},C.dataValidation),{},{sqref:C.address})}return null}).filter(Boolean)}var z=function(B){w(I,B);var M=v(I);function I(){return y(this,I),M.apply(this,arguments)}return b(I,[{key:"render",value:function(C,O){var A=D(O);A.length&&(C.openNode("dataValidations",{count:A.length}),A.forEach(function(L){C.openNode("dataValidation"),L.type!=="any"&&(C.addAttribute("type",L.type),L.operator&&L.type!=="list"&&L.operator!=="between"&&C.addAttribute("operator",L.operator),L.allowBlank&&C.addAttribute("allowBlank","1")),L.showInputMessage&&C.addAttribute("showInputMessage","1"),L.promptTitle&&C.addAttribute("promptTitle",L.promptTitle),L.prompt&&C.addAttribute("prompt",L.prompt),L.showErrorMessage&&C.addAttribute("showErrorMessage","1"),L.errorStyle&&C.addAttribute("errorStyle",L.errorStyle),L.errorTitle&&C.addAttribute("errorTitle",L.errorTitle),L.error&&C.addAttribute("error",L.error),C.addAttribute("sqref",L.sqref),(L.formulae||[]).forEach(function(U,W){C.openNode("formula".concat(W+1)),L.type==="date"?C.writeText(t.dateToExcel(new Date(U))):C.writeText(U),C.closeNode()}),C.closeNode()}),C.closeNode())}},{key:"parseOpen",value:function(C){switch(C.name){case"dataValidations":return this.model={},!0;case"dataValidation":{this._address=C.attributes.sqref;var O={type:C.attributes.type||"any",formulae:[]};switch(C.attributes.type&&P(O,C.attributes,"allowBlank"),P(O,C.attributes,"showInputMessage"),P(O,C.attributes,"showErrorMessage"),O.type){case"any":case"list":case"custom":break;default:p(O,C.attributes,"operator","between");break}return p(O,C.attributes,"promptTitle"),p(O,C.attributes,"prompt"),p(O,C.attributes,"errorStyle"),p(O,C.attributes,"errorTitle"),p(O,C.attributes,"error"),this._dataValidation=O,!0}case"formula1":case"formula2":return this._formula=[],!0;default:return!1}}},{key:"parseText",value:function(C){this._formula&&this._formula.push(C)}},{key:"parseClose",value:function(C){var O=this;switch(C){case"dataValidations":return!1;case"dataValidation":{(!this._dataValidation.formulae||!this._dataValidation.formulae.length)&&(delete this._dataValidation.formulae,delete this._dataValidation.operator);var A=this._address.split(/\s+/g)||[];return A.forEach(function(U){if(U.includes(":")){var W=new o(U);W.forEachAddress(function($){O.model[$]=O._dataValidation})}else O.model[U]=O._dataValidation}),!0}case"formula1":case"formula2":{var L=this._formula.join("");switch(this._dataValidation.type){case"whole":case"textLength":L=parseInt(L,10);break;case"decimal":L=parseFloat(L);break;case"date":L=t.excelToDate(parseFloat(L));break}return this._dataValidation.formulae.push(L),this._formula=void 0,!0}default:return!0}}},{key:"tag",get:function(){return"dataValidations"}}]),I}(n);S.exports=z},{"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/utils":26,"../base-xform":31}],93:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode("dimension",{ref:o})}},{key:"parseOpen",value:function(n){return n.name==="dimension"?(this.model=n.attributes.ref,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"dimension"}}]),t}(m);S.exports=c},{"../base-xform":31}],94:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode(this.tag,{"r:id":o.rId})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:id"]},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"drawing"}}]),t}(m);S.exports=c},{"../base-xform":31}],95:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../composite-xform"),c=e("./cf-ext/conditional-formattings-ext-xform"),a=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={"x14:conditionalFormattings":o.conditionalFormattings=new c},o}return b(n,[{key:"hasContent",value:function(p){return this.conditionalFormattings.hasContent(p.conditionalFormattings)}},{key:"prepare",value:function(p,E){this.conditionalFormattings.prepare(p.conditionalFormattings,E)}},{key:"render",value:function(p,E){p.openNode("ext",{uri:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.conditionalFormattings.render(p,E.conditionalFormattings),p.closeNode()}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(p,E){this.model[p]=E.model}},{key:"tag",get:function(){return"ext"}}]),n}(m),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={ext:o.ext=new a},o}return b(n,[{key:"prepare",value:function(p,E){this.ext.prepare(p,E)}},{key:"hasContent",value:function(p){return this.ext.hasContent(p)}},{key:"render",value:function(p,E){this.hasContent(E)&&(p.openNode("extLst"),this.ext.render(p,E),p.closeNode())}},{key:"createNewModel",value:function(){return{}}},{key:"onParserClose",value:function(p,E){Object.assign(this.model,E.model)}},{key:"tag",get:function(){return"extLst"}}]),n}(m);S.exports=r},{"../composite-xform":47,"./cf-ext/conditional-formattings-ext-xform":77}],96:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){if(o){n.addRollback();var p=!1;n.openNode("headerFooter"),o.differentFirst&&(n.addAttribute("differentFirst","1"),p=!0),o.differentOddEven&&(n.addAttribute("differentOddEven","1"),p=!0),o.oddHeader&&typeof o.oddHeader=="string"&&(n.leafNode("oddHeader",null,o.oddHeader),p=!0),o.oddFooter&&typeof o.oddFooter=="string"&&(n.leafNode("oddFooter",null,o.oddFooter),p=!0),o.evenHeader&&typeof o.evenHeader=="string"&&(n.leafNode("evenHeader",null,o.evenHeader),p=!0),o.evenFooter&&typeof o.evenFooter=="string"&&(n.leafNode("evenFooter",null,o.evenFooter),p=!0),o.firstHeader&&typeof o.firstHeader=="string"&&(n.leafNode("firstHeader",null,o.firstHeader),p=!0),o.firstFooter&&typeof o.firstFooter=="string"&&(n.leafNode("firstFooter",null,o.firstFooter),p=!0),p?(n.closeNode(),n.commit()):n.rollback()}}},{key:"parseOpen",value:function(n){switch(n.name){case"headerFooter":return this.model={},n.attributes.differentFirst&&(this.model.differentFirst=parseInt(n.attributes.differentFirst,0)===1),n.attributes.differentOddEven&&(this.model.differentOddEven=parseInt(n.attributes.differentOddEven,0)===1),!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}}},{key:"parseText",value:function(n){switch(this.currentNode){case"oddHeader":this.model.oddHeader=n;break;case"oddFooter":this.model.oddFooter=n;break;case"evenHeader":this.model.evenHeader=n;break;case"evenFooter":this.model.evenFooter=n;break;case"firstHeader":this.model.firstHeader=n;break;case"firstFooter":this.model.firstFooter=n;break}}},{key:"parseClose",value:function(){switch(this.currentNode){case"oddHeader":case"oddFooter":case"evenHeader":case"evenFooter":case"firstHeader":case"firstFooter":return this.currentNode=void 0,!0;default:return!1}}},{key:"tag",get:function(){return"headerFooter"}}]),t}(m);S.exports=c},{"../base-xform":31}],97:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("hyperlink",{ref:o.address,"r:id":o.rId,tooltip:o.tooltip})}},{key:"parseOpen",value:function(n){return n.name==="hyperlink"?(this.model={address:n.attributes.ref,rId:n.attributes["r:id"],tooltip:n.attributes.tooltip},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"hyperlink"}}]),t}(m);S.exports=c},{"../base-xform":31}],98:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("mergeCell",{ref:o})}},{key:"parseOpen",value:function(n){return n.name==="mergeCell"?(this.model=n.attributes.ref,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"mergeCell"}}]),t}(m);S.exports=c},{"../base-xform":31}],99:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=function(t){return typeof t<"u"},a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){return p&&(c(p.summaryBelow)||c(p.summaryRight))?(o.leafNode(this.tag,{summaryBelow:c(p.summaryBelow)?Number(p.summaryBelow):void 0,summaryRight:c(p.summaryRight)?Number(p.summaryRight):void 0}),!0):!1}},{key:"parseOpen",value:function(o){return o.name===this.tag?(this.model={summaryBelow:c(o.attributes.summaryBelow)?!!Number(o.attributes.summaryBelow):void 0,summaryRight:c(o.attributes.summaryRight)?!!Number(o.attributes.summaryRight):void 0},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"outlinePr"}}]),i}(m);S.exports=a},{"../base-xform":31}],101:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.leafNode("brk",o)}},{key:"parseOpen",value:function(n){return n.name==="brk"?(this.model=n.attributes.ref,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"brk"}}]),t}(m);S.exports=c},{"../base-xform":31}],102:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/under-dash"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){if(p){var E={left:p.left,right:p.right,top:p.top,bottom:p.bottom,header:p.header,footer:p.footer};m.some(E,function(P){return P!==void 0})&&o.leafNode(this.tag,E)}}},{key:"parseOpen",value:function(o){switch(o.name){case this.tag:return this.model={left:parseFloat(o.attributes.left||.7),right:parseFloat(o.attributes.right||.7),top:parseFloat(o.attributes.top||.75),bottom:parseFloat(o.attributes.bottom||.75),header:parseFloat(o.attributes.header||.3),footer:parseFloat(o.attributes.footer||.3)},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"pageMargins"}}]),i}(c);S.exports=a},{"../../../utils/under-dash":25,"../base-xform":31}],103:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){return o&&o.fitToPage?(n.leafNode(this.tag,{fitToPage:o.fitToPage?"1":void 0}),!0):!1}},{key:"parseOpen",value:function(n){return n.name===this.tag?(this.model={fitToPage:n.attributes.fitToPage==="1"},!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"pageSetUpPr"}}]),t}(m);S.exports=c},{"../base-xform":31}],104:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,E){if(!(p instanceof E))throw new TypeError("Cannot call a class as a function")}function g(p,E){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("../../../utils/under-dash"),c=e("../base-xform");function a(p){return p?"1":void 0}function r(p){switch(p){case"overThenDown":return p;default:return}}function t(p){switch(p){case"atEnd":case"asDisplyed":return p;default:return}}function i(p){switch(p){case"dash":case"blank":case"NA":return p;default:return}}function n(p){return p!==void 0?parseInt(p,10):void 0}var o=function(p){w(P,p);var E=v(P);function P(){return y(this,P),E.apply(this,arguments)}return b(P,[{key:"render",value:function(z,B){if(B){var M={paperSize:B.paperSize,orientation:B.orientation,horizontalDpi:B.horizontalDpi,verticalDpi:B.verticalDpi,pageOrder:r(B.pageOrder),blackAndWhite:a(B.blackAndWhite),draft:a(B.draft),cellComments:t(B.cellComments),errors:i(B.errors),scale:B.scale,fitToWidth:B.fitToWidth,fitToHeight:B.fitToHeight,firstPageNumber:B.firstPageNumber,useFirstPageNumber:a(B.firstPageNumber),usePrinterDefaults:a(B.usePrinterDefaults),copies:B.copies};m.some(M,function(I){return I!==void 0})&&z.leafNode(this.tag,M)}}},{key:"parseOpen",value:function(z){switch(z.name){case this.tag:return this.model={paperSize:n(z.attributes.paperSize),orientation:z.attributes.orientation||"portrait",horizontalDpi:parseInt(z.attributes.horizontalDpi||"4294967295",10),verticalDpi:parseInt(z.attributes.verticalDpi||"4294967295",10),pageOrder:z.attributes.pageOrder||"downThenOver",blackAndWhite:z.attributes.blackAndWhite==="1",draft:z.attributes.draft==="1",cellComments:z.attributes.cellComments||"None",errors:z.attributes.errors||"displayed",scale:parseInt(z.attributes.scale||"100",10),fitToWidth:parseInt(z.attributes.fitToWidth||"1",10),fitToHeight:parseInt(z.attributes.fitToHeight||"1",10),firstPageNumber:parseInt(z.attributes.firstPageNumber||"1",10),useFirstPageNumber:z.attributes.useFirstPageNumber==="1",usePrinterDefaults:z.attributes.usePrinterDefaults==="1",copies:parseInt(z.attributes.copies||"1",10)},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"pageSetup"}}]),P}(c);S.exports=o},{"../../../utils/under-dash":25,"../base-xform":31}],105:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode(this.tag,{"r:id":o.rId})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:id"]},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"picture"}}]),t}(m);S.exports=c},{"../base-xform":31}],106:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/under-dash"),c=e("../base-xform");function a(t){return t?"1":void 0}var r=function(t){w(n,t);var i=v(n);function n(){return y(this,n),i.apply(this,arguments)}return b(n,[{key:"render",value:function(p,E){if(E){var P={headings:a(E.showRowColHeaders),gridLines:a(E.showGridLines),horizontalCentered:a(E.horizontalCentered),verticalCentered:a(E.verticalCentered)};m.some(P,function(D){return D!==void 0})&&p.leafNode(this.tag,P)}}},{key:"parseOpen",value:function(p){switch(p.name){case this.tag:return this.model={showRowColHeaders:p.attributes.headings==="1",showGridLines:p.attributes.gridLines==="1",horizontalCentered:p.attributes.horizontalCentered==="1",verticalCentered:p.attributes.verticalCentered==="1"},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"printOptions"}}]),n}(c);S.exports=r},{"../../../utils/under-dash":25,"../base-xform":31}],107:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("./page-breaks-xform"),c=e("../list-xform"),a=function(r){w(i,r);var t=v(i);function i(){y(this,i);var n={tag:"rowBreaks",count:!0,childXform:new m};return t.call(this,n)}return b(i,[{key:"render",value:function(o,p){if(p&&p.length){o.openNode(this.tag,this.$),this.count&&(o.addAttribute(this.$count,p.length),o.addAttribute("manualBreakCount",p.length));var E=this.childXform;p.forEach(function(P){E.render(o,P)}),o.closeNode()}else this.empty&&o.leafNode(this.tag)}}]),i}(c);S.exports=a},{"../list-xform":70,"./page-breaks-xform":101}],108:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("./cell-xform"),a=function(r){w(i,r);var t=v(i);function i(n){var o;return y(this,i),o=t.call(this),o.maxItems=n&&n.maxItems,o.map={c:new c},o}return b(i,[{key:"prepare",value:function(o,p){var E=p.styles.addStyleModel(o.style);E&&(o.styleId=E);var P=this.map.c;o.cells.forEach(function(D){P.prepare(D,p)})}},{key:"render",value:function(o,p,E){o.openNode("row"),o.addAttribute("r",p.number),p.height&&(o.addAttribute("ht",p.height),o.addAttribute("customHeight","1")),p.hidden&&o.addAttribute("hidden","1"),p.min>0&&p.max>0&&p.min<=p.max&&o.addAttribute("spans","".concat(p.min,":").concat(p.max)),p.styleId&&(o.addAttribute("s",p.styleId),o.addAttribute("customFormat","1")),o.addAttribute("x14ac:dyDescent","0.25"),p.outlineLevel&&o.addAttribute("outlineLevel",p.outlineLevel),p.collapsed&&o.addAttribute("collapsed","1");var P=this.map.c;p.cells.forEach(function(D){P.render(o,D,E)}),o.closeNode()}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;if(o.name==="row"){this.numRowsSeen+=1;var p=o.attributes.spans?o.attributes.spans.split(":").map(function(P){return parseInt(P,10)}):[void 0,void 0],E=this.model={number:parseInt(o.attributes.r,10),min:p[0],max:p[1],cells:[]};return o.attributes.s&&(E.styleId=parseInt(o.attributes.s,10)),(o.attributes.hidden===!0||o.attributes.hidden==="true"||o.attributes.hidden===1||o.attributes.hidden==="1")&&(E.hidden=!0),o.attributes.bestFit&&(E.bestFit=!0),o.attributes.ht&&(E.height=parseFloat(o.attributes.ht)),o.attributes.outlineLevel&&(E.outlineLevel=parseInt(o.attributes.outlineLevel,10)),o.attributes.collapsed&&(E.collapsed=!0),!0}return this.parser=this.map[o.name],this.parser?(this.parser.parseOpen(o),!0):!1}},{key:"parseText",value:function(o){this.parser&&this.parser.parseText(o)}},{key:"parseClose",value:function(o){if(this.parser){if(!this.parser.parseClose(o)){if(this.model.cells.push(this.parser.model),this.maxItems&&this.model.cells.length>this.maxItems)throw new Error("Max column count (".concat(this.maxItems,") exceeded"));this.parser=void 0}return!0}return!1}},{key:"reconcile",value:function(o,p){o.style=o.styleId?p.styles.getStyleModel(o.styleId):{},o.styleId!==void 0&&(o.styleId=void 0);var E=this.map.c;o.cells.forEach(function(P){E.reconcile(P,p)})}},{key:"tag",get:function(){return"row"}}]),i}(m);S.exports=a},{"../base-xform":31,"./cell-xform":72}],109:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../../../utils/under-dash"),c=e("../base-xform"),a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){if(p){var E={defaultRowHeight:p.defaultRowHeight,outlineLevelRow:p.outlineLevelRow,outlineLevelCol:p.outlineLevelCol,"x14ac:dyDescent":p.dyDescent};p.defaultColWidth&&(E.defaultColWidth=p.defaultColWidth),(!p.defaultRowHeight||p.defaultRowHeight!==15)&&(E.customHeight="1"),m.some(E,function(P){return P!==void 0})&&o.leafNode("sheetFormatPr",E)}}},{key:"parseOpen",value:function(o){return o.name==="sheetFormatPr"?(this.model={defaultRowHeight:parseFloat(o.attributes.defaultRowHeight||"0"),dyDescent:parseFloat(o.attributes["x14ac:dyDescent"]||"0"),outlineLevelRow:parseInt(o.attributes.outlineLevelRow||"0",10),outlineLevelCol:parseInt(o.attributes.outlineLevelCol||"0",10)},o.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(o.attributes.defaultColWidth)),!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"sheetFormatPr"}}]),i}(c);S.exports=a},{"../../../utils/under-dash":25,"../base-xform":31}],110:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../base-xform"),c=e("../style/color-xform"),a=e("./page-setup-properties-xform"),r=e("./outline-properties-xform"),t=function(i){w(o,i);var n=v(o);function o(){var p;return y(this,o),p=n.call(this),p.map={tabColor:new c("tabColor"),pageSetUpPr:new a,outlinePr:new r},p}return b(o,[{key:"render",value:function(E,P){if(P){E.addRollback(),E.openNode("sheetPr");var D=!1;D=this.map.tabColor.render(E,P.tabColor)||D,D=this.map.pageSetUpPr.render(E,P.pageSetup)||D,D=this.map.outlinePr.render(E,P.outlineProperties)||D,D?(E.closeNode(),E.commit()):E.rollback()}}},{key:"parseOpen",value:function(E){return this.parser?(this.parser.parseOpen(E),!0):E.name===this.tag?(this.reset(),!0):this.map[E.name]?(this.parser=this.map[E.name],this.parser.parseOpen(E),!0):!1}},{key:"parseText",value:function(E){return this.parser?(this.parser.parseText(E),!0):!1}},{key:"parseClose",value:function(E){return this.parser?(this.parser.parseClose(E)||(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)}},{key:"tag",get:function(){return"sheetPr"}}]),o}(m);S.exports=t},{"../base-xform":31,"../style/color-xform":127,"./outline-properties-xform":100,"./page-setup-properties-xform":103}],111:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("../../../utils/under-dash"),c=e("../base-xform");function a(i,n){return i?n:void 0}function r(i,n){return i===n?!0:void 0}var t=function(i){w(o,i);var n=v(o);function o(){return y(this,o),n.apply(this,arguments)}return b(o,[{key:"render",value:function(E,P){if(P){var D={sheet:a(P.sheet,"1"),selectLockedCells:P.selectLockedCells===!1?"1":void 0,selectUnlockedCells:P.selectUnlockedCells===!1?"1":void 0,formatCells:a(P.formatCells,"0"),formatColumns:a(P.formatColumns,"0"),formatRows:a(P.formatRows,"0"),insertColumns:a(P.insertColumns,"0"),insertRows:a(P.insertRows,"0"),insertHyperlinks:a(P.insertHyperlinks,"0"),deleteColumns:a(P.deleteColumns,"0"),deleteRows:a(P.deleteRows,"0"),sort:a(P.sort,"0"),autoFilter:a(P.autoFilter,"0"),pivotTables:a(P.pivotTables,"0")};P.sheet&&(D.algorithmName=P.algorithmName,D.hashValue=P.hashValue,D.saltValue=P.saltValue,D.spinCount=P.spinCount,D.objects=a(P.objects===!1,"1"),D.scenarios=a(P.scenarios===!1,"1")),m.some(D,function(z){return z!==void 0})&&E.leafNode(this.tag,D)}}},{key:"parseOpen",value:function(E){switch(E.name){case this.tag:return this.model={sheet:r(E.attributes.sheet,"1"),objects:E.attributes.objects==="1"?!1:void 0,scenarios:E.attributes.scenarios==="1"?!1:void 0,selectLockedCells:E.attributes.selectLockedCells==="1"?!1:void 0,selectUnlockedCells:E.attributes.selectUnlockedCells==="1"?!1:void 0,formatCells:r(E.attributes.formatCells,"0"),formatColumns:r(E.attributes.formatColumns,"0"),formatRows:r(E.attributes.formatRows,"0"),insertColumns:r(E.attributes.insertColumns,"0"),insertRows:r(E.attributes.insertRows,"0"),insertHyperlinks:r(E.attributes.insertHyperlinks,"0"),deleteColumns:r(E.attributes.deleteColumns,"0"),deleteRows:r(E.attributes.deleteRows,"0"),sort:r(E.attributes.sort,"0"),autoFilter:r(E.attributes.autoFilter,"0"),pivotTables:r(E.attributes.pivotTables,"0")},E.attributes.algorithmName&&(this.model.algorithmName=E.attributes.algorithmName,this.model.hashValue=E.attributes.hashValue,this.model.saltValue=E.attributes.saltValue,this.model.spinCount=parseInt(E.attributes.spinCount,10)),!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"sheetProtection"}}]),o}(c);S.exports=t},{"../../../utils/under-dash":25,"../base-xform":31}],112:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/col-cache"),c=e("../base-xform"),a={frozen:"frozen",frozenSplit:"frozen",split:"split"},r=function(t){w(n,t);var i=v(n);function n(){return y(this,n),i.apply(this,arguments)}return b(n,[{key:"prepare",value:function(p){switch(p.state){case"frozen":case"split":break;default:p.state="normal";break}}},{key:"render",value:function(p,E){p.openNode("sheetView",{workbookViewId:E.workbookViewId||0});var P=function(T,C,O){O&&p.addAttribute(T,C)};P("rightToLeft","1",E.rightToLeft===!0),P("tabSelected","1",E.tabSelected),P("showRuler","0",E.showRuler===!1),P("showRowColHeaders","0",E.showRowColHeaders===!1),P("showGridLines","0",E.showGridLines===!1),P("zoomScale",E.zoomScale,E.zoomScale),P("zoomScaleNormal",E.zoomScaleNormal,E.zoomScaleNormal),P("view",E.style,E.style);var D,z,B,M;switch(E.state){case"frozen":z=E.xSplit||0,B=E.ySplit||0,D=E.topLeftCell||m.getAddress(B+1,z+1).address,M=E.xSplit&&E.ySplit&&"bottomRight"||E.xSplit&&"topRight"||"bottomLeft",p.leafNode("pane",{xSplit:E.xSplit||void 0,ySplit:E.ySplit||void 0,topLeftCell:D,activePane:M,state:"frozen"}),p.leafNode("selection",{pane:M,activeCell:E.activeCell,sqref:E.activeCell});break;case"split":E.activePane==="topLeft"&&(E.activePane=void 0),p.leafNode("pane",{xSplit:E.xSplit||void 0,ySplit:E.ySplit||void 0,topLeftCell:E.topLeftCell,activePane:E.activePane}),p.leafNode("selection",{pane:E.activePane,activeCell:E.activeCell,sqref:E.activeCell});break;case"normal":E.activeCell&&p.leafNode("selection",{activeCell:E.activeCell,sqref:E.activeCell});break}p.closeNode()}},{key:"parseOpen",value:function(p){switch(p.name){case"sheetView":return this.sheetView={workbookViewId:parseInt(p.attributes.workbookViewId,10),rightToLeft:p.attributes.rightToLeft==="1",tabSelected:p.attributes.tabSelected==="1",showRuler:p.attributes.showRuler!=="0",showRowColHeaders:p.attributes.showRowColHeaders!=="0",showGridLines:p.attributes.showGridLines!=="0",zoomScale:parseInt(p.attributes.zoomScale||"100",10),zoomScaleNormal:parseInt(p.attributes.zoomScaleNormal||"100",10),style:p.attributes.view},this.pane=void 0,this.selections={},!0;case"pane":return this.pane={xSplit:parseInt(p.attributes.xSplit||"0",10),ySplit:parseInt(p.attributes.ySplit||"0",10),topLeftCell:p.attributes.topLeftCell,activePane:p.attributes.activePane||"topLeft",state:p.attributes.state},!0;case"selection":{var E=p.attributes.pane||"topLeft";return this.selections[E]={pane:E,activeCell:p.attributes.activeCell},!0}default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){var E,P;switch(p){case"sheetView":return this.sheetView&&this.pane?(E=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:a[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},this.model.state==="split"&&(E.activePane=this.pane.activePane),P=this.selections[this.pane.activePane],P&&P.activeCell&&(E.activeCell=P.activeCell),this.sheetView.style&&(E.style=this.sheetView.style)):(E=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},P=this.selections.topLeft,P&&P.activeCell&&(E.activeCell=P.activeCell),this.sheetView.style&&(E.style=this.sheetView.style)),!1;default:return!0}}},{key:"reconcile",value:function(){}},{key:"tag",get:function(){return"sheetView"}}]),n}(c);S.exports=r},{"../../../utils/col-cache":19,"../base-xform":31}],113:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){o&&n.leafNode(this.tag,{"r:id":o.rId})}},{key:"parseOpen",value:function(n){switch(n.name){case this.tag:return this.model={rId:n.attributes["r:id"]},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"tablePart"}}]),t}(m);S.exports=c},{"../base-xform":31}],114:[function(e,S,_){function u(ye){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(ne){return typeof ne}:u=function(ne){return ne&&typeof Symbol=="function"&&ne.constructor===Symbol&&ne!==Symbol.prototype?"symbol":typeof ne},u(ye)}function y(ye,ge){if(!(ye instanceof ge))throw new TypeError("Cannot call a class as a function")}function g(ye,ge){for(var ne=0;ne"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(ye){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(ne){return ne.__proto__||Object.getPrototypeOf(ne)},s(ye)}var m=e("../../../utils/under-dash"),c=e("../../../utils/col-cache"),a=e("../../../utils/xml-stream"),r=e("../../rel-type"),t=e("./merges"),i=e("../base-xform"),n=e("../list-xform"),o=e("./row-xform"),p=e("./col-xform"),E=e("./dimension-xform"),P=e("./hyperlink-xform"),D=e("./merge-cell-xform"),z=e("./data-validations-xform"),B=e("./sheet-properties-xform"),M=e("./sheet-format-properties-xform"),I=e("./sheet-view-xform"),T=e("./sheet-protection-xform"),C=e("./page-margins-xform"),O=e("./page-setup-xform"),A=e("./print-options-xform"),L=e("./auto-filter-xform"),U=e("./picture-xform"),W=e("./drawing-xform"),$=e("./table-part-xform"),N=e("./row-breaks-xform"),F=e("./header-footer-xform"),j=e("./cf/conditional-formattings-xform"),V=e("./ext-lst-xform"),te=function(ge,ne){Object.keys(ne).forEach(function(J){var Q=ge[J],he=ne[J];Q===void 0&&he!==void 0&&(ge[J]=he)})},re=function(ge,ne){if(!ne||!ne.length)return ge;if(!ge||!ge.length)return ne;var J={},Q={};return ge.forEach(function(he){J[he.ref]=he,he.rules.forEach(function(xe){var ie=xe.x14Id;ie&&(Q[ie]=xe)})}),ne.forEach(function(he){he.rules.forEach(function(xe){var ie=Q[xe.x14Id];ie?te(ie,xe):J[he.ref]?J[he.ref].rules.push(xe):ge.push({ref:he.ref,rules:[xe]})})}),ge},le=function(ye){w(ne,ye);var ge=v(ne);function ne(J){var Q;y(this,ne),Q=ge.call(this);var he=J||{},xe=he.maxRows,ie=he.maxCols;return Q.map={sheetPr:new B,dimension:new E,sheetViews:new n({tag:"sheetViews",count:!1,childXform:new I}),sheetFormatPr:new M,cols:new n({tag:"cols",count:!1,childXform:new p}),sheetData:new n({tag:"sheetData",count:!1,empty:!0,childXform:new o({maxItems:ie}),maxItems:xe}),autoFilter:new L,mergeCells:new n({tag:"mergeCells",count:!0,childXform:new D}),rowBreaks:new N,hyperlinks:new n({tag:"hyperlinks",count:!1,childXform:new P}),pageMargins:new C,dataValidations:new z,pageSetup:new O,headerFooter:new F,printOptions:new A,picture:new U,drawing:new W,sheetProtection:new T,tableParts:new n({tag:"tableParts",count:!0,childXform:new $}),conditionalFormatting:new j,extLst:new V},Q}return b(ne,[{key:"prepare",value:function(Q,he){var xe=this;he.merges=new t,Q.hyperlinks=he.hyperlinks=[],Q.comments=he.comments=[],he.formulae={},he.siFormulae=0,this.map.cols.prepare(Q.cols,he),this.map.sheetData.prepare(Q.rows,he),this.map.conditionalFormatting.prepare(Q.conditionalFormattings,he),Q.mergeCells=he.merges.mergeCells;var ie=Q.rels=[];function se(fe){return"rId".concat(fe.length+1)}if(Q.hyperlinks.forEach(function(fe){var we=se(ie);fe.rId=we,ie.push({Id:we,Type:r.Hyperlink,Target:fe.target,TargetMode:"External"})}),Q.comments.length>0){var Ce={Id:se(ie),Type:r.Comments,Target:"../comments".concat(Q.id,".xml")};ie.push(Ce);var q={Id:se(ie),Type:r.VmlDrawing,Target:"../drawings/vmlDrawing".concat(Q.id,".vml")};ie.push(q),Q.comments.forEach(function(fe){fe.refAddress=c.decodeAddress(fe.ref)}),he.commentRefs.push({commentName:"comments".concat(Q.id),vmlDrawing:"vmlDrawing".concat(Q.id)})}var G=[],Y;Q.media.forEach(function(fe){if(fe.type==="background"){var we=se(ie);Y=he.media[fe.imageId],ie.push({Id:we,Type:r.Image,Target:"../media/".concat(Y.name,".").concat(Y.extension)}),Q.background={rId:we},Q.image=he.media[fe.imageId]}else if(fe.type==="image"){var _e=Q.drawing;Y=he.media[fe.imageId],_e||(_e=Q.drawing={rId:se(ie),name:"drawing".concat(++he.drawingsCount),anchors:[],rels:[]},he.drawings.push(_e),ie.push({Id:_e.rId,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",Target:"../drawings/".concat(_e.name,".xml")}));var je=xe.preImageId===fe.imageId?G[fe.imageId]:G[_e.rels.length];je||(je=se(_e.rels),G[_e.rels.length]=je,_e.rels.push({Id:je,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",Target:"../media/".concat(Y.name,".").concat(Y.extension)}));var Ye={picture:{rId:je},range:fe.range};if(fe.hyperlinks&&fe.hyperlinks.hyperlink){var nt=se(_e.rels);G[_e.rels.length]=nt,Ye.picture.hyperlinks={tooltip:fe.hyperlinks.tooltip,rId:nt},_e.rels.push({Id:nt,Type:r.Hyperlink,Target:fe.hyperlinks.hyperlink,TargetMode:"External"})}xe.preImageId=fe.imageId,_e.anchors.push(Ye)}}),Q.tables.forEach(function(fe){var we=se(ie);fe.rId=we,ie.push({Id:we,Type:r.Table,Target:"../tables/".concat(fe.target)}),fe.columns.forEach(function(_e){var je=_e.style;je&&(_e.dxfId=he.styles.addDxfStyle(je))})}),this.map.extLst.prepare(Q,he)}},{key:"render",value:function(Q,he){Q.openXml(a.StdDocAttributes),Q.openNode("worksheet",ne.WORKSHEET_ATTRIBUTES);var xe=he.properties?{defaultRowHeight:he.properties.defaultRowHeight,dyDescent:he.properties.dyDescent,outlineLevelCol:he.properties.outlineLevelCol,outlineLevelRow:he.properties.outlineLevelRow}:void 0;he.properties&&he.properties.defaultColWidth&&(xe.defaultColWidth=he.properties.defaultColWidth);var ie={outlineProperties:he.properties&&he.properties.outlineProperties,tabColor:he.properties&&he.properties.tabColor,pageSetup:he.pageSetup&&he.pageSetup.fitToPage?{fitToPage:he.pageSetup.fitToPage}:void 0},se=he.pageSetup&&he.pageSetup.margins,Ce={showRowColHeaders:he.pageSetup&&he.pageSetup.showRowColHeaders,showGridLines:he.pageSetup&&he.pageSetup.showGridLines,horizontalCentered:he.pageSetup&&he.pageSetup.horizontalCentered,verticalCentered:he.pageSetup&&he.pageSetup.verticalCentered},q=he.sheetProtection;this.map.sheetPr.render(Q,ie),this.map.dimension.render(Q,he.dimensions),this.map.sheetViews.render(Q,he.views),this.map.sheetFormatPr.render(Q,xe),this.map.cols.render(Q,he.cols),this.map.sheetData.render(Q,he.rows),this.map.sheetProtection.render(Q,q),this.map.autoFilter.render(Q,he.autoFilter),this.map.mergeCells.render(Q,he.mergeCells),this.map.conditionalFormatting.render(Q,he.conditionalFormattings),this.map.dataValidations.render(Q,he.dataValidations),this.map.hyperlinks.render(Q,he.hyperlinks),this.map.printOptions.render(Q,Ce),this.map.pageMargins.render(Q,se),this.map.pageSetup.render(Q,he.pageSetup),this.map.headerFooter.render(Q,he.headerFooter),this.map.rowBreaks.render(Q,he.rowBreaks),this.map.drawing.render(Q,he.drawing),this.map.picture.render(Q,he.background),this.map.tableParts.render(Q,he.tables),this.map.extLst.render(Q,he),he.rels&&he.rels.forEach(function(G){G.Type===r.VmlDrawing&&Q.leafNode("legacyDrawing",{"r:id":G.Id})}),Q.closeNode()}},{key:"parseOpen",value:function(Q){return this.parser?(this.parser.parseOpen(Q),!0):Q.name==="worksheet"?(m.each(this.map,function(he){he.reset()}),!0):(this.parser=this.map[Q.name],this.parser&&this.parser.parseOpen(Q),!0)}},{key:"parseText",value:function(Q){this.parser&&this.parser.parseText(Q)}},{key:"parseClose",value:function(Q){if(this.parser)return this.parser.parseClose(Q)||(this.parser=void 0),!0;switch(Q){case"worksheet":{var he=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(he.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(he.outlineProperties=this.map.sheetPr.model.outlineProperties);var xe={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},ie=Object.assign(xe,this.map.pageSetup.model,this.map.printOptions.model),se=re(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:he,views:this.map.sheetViews.model,pageSetup:ie,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:se},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}default:return!0}}},{key:"reconcile",value:function(Q,he){var xe=(Q.relationships||[]).reduce(function(we,_e){if(we[_e.Id]=_e,_e.Type===r.Comments&&(Q.comments=he.comments[_e.Target].comments),_e.Type===r.VmlDrawing&&Q.comments&&Q.comments.length){var je=he.vmlDrawings[_e.Target].comments;Q.comments.forEach(function(Ye,nt){Ye.note=Object.assign({},Ye.note,je[nt])})}return we},{});if(he.commentsMap=(Q.comments||[]).reduce(function(we,_e){return _e.ref&&(we[_e.ref]=_e),we},{}),he.hyperlinkMap=(Q.hyperlinks||[]).reduce(function(we,_e){return _e.rId&&(we[_e.address]=xe[_e.rId].Target),we},{}),he.formulae={},Q.rows=Q.rows&&Q.rows.filter(Boolean)||[],Q.rows.forEach(function(we){we.cells=we.cells&&we.cells.filter(Boolean)||[]}),this.map.cols.reconcile(Q.cols,he),this.map.sheetData.reconcile(Q.rows,he),this.map.conditionalFormatting.reconcile(Q.conditionalFormattings,he),Q.media=[],Q.drawing){var ie=xe[Q.drawing.rId],se=ie.Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(se){var Ce=se[1],q=he.drawings[Ce];q.anchors.forEach(function(we){if(we.medium){var _e={type:"image",imageId:we.medium.index,range:we.range,hyperlinks:we.picture.hyperlinks};Q.media.push(_e)}})}}var G=Q.background&&xe[Q.background.rId];if(G){var Y=G.Target.split("/media/")[1],fe=he.mediaIndex&&he.mediaIndex[Y];fe!==void 0&&Q.media.push({type:"background",imageId:fe})}Q.tables=(Q.tables||[]).map(function(we){var _e=xe[we.rId];return he.tables[_e.Target]}),delete Q.relationships,delete Q.hyperlinks,delete Q.comments}}]),ne}(i);le.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"},S.exports=le},{"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/xml-stream":27,"../../rel-type":30,"../base-xform":31,"../list-xform":70,"./auto-filter-xform":71,"./cf/conditional-formattings-xform":86,"./col-xform":91,"./data-validations-xform":92,"./dimension-xform":93,"./drawing-xform":94,"./ext-lst-xform":95,"./header-footer-xform":96,"./hyperlink-xform":97,"./merge-cell-xform":98,"./merges":99,"./page-margins-xform":102,"./page-setup-xform":104,"./picture-xform":105,"./print-options-xform":106,"./row-breaks-xform":107,"./row-xform":108,"./sheet-format-properties-xform":109,"./sheet-properties-xform":110,"./sheet-protection-xform":111,"./sheet-view-xform":112,"./table-part-xform":113}],115:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n}return b(t,[{key:"render",value:function(n,o){o&&(n.openNode(this.tag),n.closeNode())}},{key:"parseOpen",value:function(n){n.name===this.tag&&(this.model=!0)}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}}]),t}(m);S.exports=c},{"../base-xform":31}],116:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n.attrs=i.attrs,n._format=i.format||function(o){try{return Number.isNaN(o.getTime())?"":o.toISOString()}catch{return""}},n._parse=i.parse||function(o){return new Date(o)},n}return b(t,[{key:"render",value:function(n,o){o&&(n.openNode(this.tag),this.attrs&&n.addAttributes(this.attrs),this.attr?n.addAttribute(this.attr,this._format(o)):n.writeText(this._format(o)),n.closeNode())}},{key:"parseOpen",value:function(n){n.name===this.tag&&(this.attr?this.model=this._parse(n.attributes[this.attr]):this.text=[])}},{key:"parseText",value:function(n){this.attr||this.text.push(n)}},{key:"parseClose",value:function(){return this.attr||(this.model=this._parse(this.text.join(""))),!1}}]),t}(m);S.exports=c},{"../base-xform":31}],117:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n.attrs=i.attrs,n.zero=i.zero,n}return b(t,[{key:"render",value:function(n,o){(o||this.zero)&&(n.openNode(this.tag),this.attrs&&n.addAttributes(this.attrs),this.attr?n.addAttribute(this.attr,o):n.writeText(o),n.closeNode())}},{key:"parseOpen",value:function(n){return n.name===this.tag?(this.attr?this.model=parseInt(n.attributes[this.attr],10):this.text=[],!0):!1}},{key:"parseText",value:function(n){this.attr||this.text.push(n)}},{key:"parseClose",value:function(){return this.attr||(this.model=parseInt(this.text.join("")||0,10)),!1}}]),t}(m);S.exports=c},{"../base-xform":31}],118:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.tag=i.tag,n.attr=i.attr,n.attrs=i.attrs,n}return b(t,[{key:"render",value:function(n,o){o!==void 0&&(n.openNode(this.tag),this.attrs&&n.addAttributes(this.attrs),this.attr?n.addAttribute(this.attr,o):n.writeText(o),n.closeNode())}},{key:"parseOpen",value:function(n){n.name===this.tag&&(this.attr?this.model=n.attributes[this.attr]:this.text=[])}},{key:"parseText",value:function(n){this.attr||this.text.push(n)}},{key:"parseClose",value:function(){return this.attr||(this.model=this.text.join("")),!1}}]),t}(m);S.exports=c},{"../base-xform":31}],119:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("./base-xform"),c=e("../../utils/xml-stream");function a(t,i){t.openNode(i.tag,i.$),i.c&&i.c.forEach(function(n){a(t,n)}),i.t&&t.writeText(i.t),t.closeNode()}var r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p._model=o,p}return b(n,[{key:"render",value:function(p){if(!this._xml){var E=new c;a(E,this._model),this._xml=E.xml}p.writeXml(this._xml)}},{key:"parseOpen",value:function(){return!0}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(p){switch(p){case this._model.tag:return!1;default:return!0}}}]),n}(m);S.exports=r},{"../../utils/xml-stream":27,"./base-xform":31}],120:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("./text-xform"),c=e("./rich-text-xform"),a=e("../base-xform"),r=function(t){w(n,t);var i=v(n);function n(){var o;return y(this,n),o=i.call(this),o.map={r:new c,t:new m},o}return b(n,[{key:"render",value:function(p,E){if(p.openNode(this.tag,{sb:E.sb||0,eb:E.eb||0}),E&&E.hasOwnProperty("richText")&&E.richText){var P=this.map.r;E.richText.forEach(function(D){P.render(p,D)})}else E&&this.map.t.render(p,E.text);p.closeNode()}},{key:"parseOpen",value:function(p){var E=p.name;return this.parser?(this.parser.parseOpen(p),!0):E===this.tag?(this.model={sb:parseInt(p.attributes.sb,10),eb:parseInt(p.attributes.eb,10)},!0):(this.parser=this.map[E],this.parser?(this.parser.parseOpen(p),!0):!1)}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser){if(!this.parser.parseClose(p)){switch(p){case"r":{var E=this.model.richText;E||(E=this.model.richText=[]),E.push(this.parser.model);break}case"t":this.model.text=this.parser.model;break}this.parser=void 0}return!0}switch(p){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"rPh"}}]),n}(a);S.exports=r},{"../base-xform":31,"./rich-text-xform":121,"./text-xform":124}],121:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("./text-xform"),c=e("../style/font-xform"),a=e("../base-xform"),r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p.model=o,p}return b(n,[{key:"render",value:function(p,E){E=E||this.model,p.openNode("r"),E.font&&this.fontXform.render(p,E.font),this.textXform.render(p,E.text),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"r":return this.model={},!0;case"t":return this.parser=this.textXform,this.parser.parseOpen(p),!0;case"rPr":return this.parser=this.fontXform,this.parser.parseOpen(p),!0;default:return!1}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){switch(p){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(p),!0}}},{key:"tag",get:function(){return"r"}},{key:"textXform",get:function(){return this._textXform||(this._textXform=new m)}},{key:"fontXform",get:function(){return this._fontXform||(this._fontXform=new c(n.FONT_OPTIONS))}}]),n}(a);r.FONT_OPTIONS={tagName:"rPr",fontNameTag:"rFont"},S.exports=r},{"../base-xform":31,"../style/font-xform":130,"./text-xform":124}],122:[function(e,S,_){function u(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(o){return typeof o}:u=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},u(i)}function y(i,n){if(!(i instanceof n))throw new TypeError("Cannot call a class as a function")}function g(i,n){for(var o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(i){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},s(i)}var m=e("./text-xform"),c=e("./rich-text-xform"),a=e("./phonetic-text-xform"),r=e("../base-xform"),t=function(i){w(o,i);var n=v(o);function o(p){var E;return y(this,o),E=n.call(this),E.model=p,E.map={r:new c,t:new m,rPh:new a},E}return b(o,[{key:"render",value:function(E,P){var D=this;E.openNode(this.tag),P&&P.hasOwnProperty("richText")&&P.richText?P.richText.length?P.richText.forEach(function(z){D.map.r.render(E,z)}):this.map.t.render(E,""):P!=null&&this.map.t.render(E,P),E.closeNode()}},{key:"parseOpen",value:function(E){var P=E.name;return this.parser?(this.parser.parseOpen(E),!0):P===this.tag?(this.model={},!0):(this.parser=this.map[P],this.parser?(this.parser.parseOpen(E),!0):!1)}},{key:"parseText",value:function(E){this.parser&&this.parser.parseText(E)}},{key:"parseClose",value:function(E){if(this.parser){if(!this.parser.parseClose(E)){switch(E){case"r":{var P=this.model.richText;P||(P=this.model.richText=[]),P.push(this.parser.model);break}case"t":this.model=this.parser.model;break}this.parser=void 0}return!0}switch(E){case this.tag:return!1;default:return!0}}},{key:"tag",get:function(){return"si"}}]),o}(r);S.exports=t},{"../base-xform":31,"./phonetic-text-xform":120,"./rich-text-xform":121,"./text-xform":124}],123:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../../../utils/xml-stream"),c=e("../base-xform"),a=e("./shared-string-xform"),r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p.model=o||{values:[],count:0},p.hash=Object.create(null),p.rich=Object.create(null),p}return b(n,[{key:"getString",value:function(p){return this.model.values[p]}},{key:"add",value:function(p){return p.richText?this.addRichText(p):this.addText(p)}},{key:"addText",value:function(p){var E=this.hash[p];return E===void 0&&(E=this.hash[p]=this.model.values.length,this.model.values.push(p)),this.model.count++,E}},{key:"addRichText",value:function(p){var E=this.sharedStringXform.toXml(p),P=this.rich[E];return P===void 0&&(P=this.rich[E]=this.model.values.length,this.model.values.push(p)),this.model.count++,P}},{key:"render",value:function(p,E){E=E||this._values,p.openXml(m.StdDocAttributes),p.openNode("sst",{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",count:E.count,uniqueCount:E.values.length});var P=this.sharedStringXform;E.values.forEach(function(D){P.render(p,D)}),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"sst":return!0;case"si":return this.parser=this.sharedStringXform,this.parser.parseOpen(p),!0;default:throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(p)))}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){if(this.parser)return this.parser.parseClose(p)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;switch(p){case"sst":return!1;default:throw new Error("Unexpected xml node in parseClose: ".concat(p))}}},{key:"sharedStringXform",get:function(){return this._sharedStringXform||(this._sharedStringXform=new a)}},{key:"values",get:function(){return this.model.values}},{key:"uniqueCount",get:function(){return this.model.values.length}},{key:"count",get:function(){return this.model.count}}]),n}(c);S.exports=r},{"../../../utils/xml-stream":27,"../base-xform":31,"./shared-string-xform":122}],124:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){n.openNode("t"),/^\s|\n|\s$/.test(o)&&n.addAttribute("xml:space","preserve"),n.writeText(o),n.closeNode()}},{key:"parseOpen",value:function(n){switch(n.name){case"t":return this._text=[],!0;default:return!1}}},{key:"parseText",value:function(n){this._text.push(n)}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"t"}},{key:"model",get:function(){return this._text.join("").replace(/_x([0-9A-F]{4})_/g,function(n,o){return String.fromCharCode(parseInt(o,16))})}}]),t}(m);S.exports=c},{"../base-xform":31}],125:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../doc/enums"),c=e("../../../utils/utils"),a=e("../base-xform"),r={horizontalValues:["left","center","right","fill","centerContinuous","distributed","justify"].reduce(function(n,o){return n[o]=!0,n},{}),horizontal:function(o){return this.horizontalValues[o]?o:void 0},verticalValues:["top","middle","bottom","distributed","justify"].reduce(function(n,o){return n[o]=!0,n},{}),vertical:function(o){return o==="middle"?"center":this.verticalValues[o]?o:void 0},wrapText:function(o){return o?!0:void 0},shrinkToFit:function(o){return o?!0:void 0},textRotation:function(o){switch(o){case"vertical":return o;default:return o=c.validInt(o),o>=-90&&o<=90?o:void 0}},indent:function(o){return o=c.validInt(o),Math.max(0,o)},readingOrder:function(o){switch(o){case"ltr":return m.ReadingOrder.LeftToRight;case"rtl":return m.ReadingOrder.RightToLeft;default:return}}},t={toXml:function(o){if(o=r.textRotation(o),o){if(o==="vertical")return 255;var p=Math.round(o);if(p>=0&&p<=90)return p;if(p<0&&p>=-90)return 90-p}},toModel:function(o){var p=c.validInt(o);if(p!==void 0){if(p===255)return"vertical";if(p>=0&&p<=90)return p;if(p>90&&p<=180)return 90-p}}},i=function(n){w(p,n);var o=v(p);function p(){return y(this,p),o.apply(this,arguments)}return b(p,[{key:"render",value:function(P,D){P.addRollback(),P.openNode("alignment");var z=!1;function B(M,I){I&&(P.addAttribute(M,I),z=!0)}B("horizontal",r.horizontal(D.horizontal)),B("vertical",r.vertical(D.vertical)),B("wrapText",r.wrapText(D.wrapText)?"1":!1),B("shrinkToFit",r.shrinkToFit(D.shrinkToFit)?"1":!1),B("indent",r.indent(D.indent)),B("textRotation",t.toXml(D.textRotation)),B("readingOrder",r.readingOrder(D.readingOrder)),P.closeNode(),z?P.commit():P.rollback()}},{key:"parseOpen",value:function(P){var D={},z=!1;function B(M,I,T){M&&(D[I]=T,z=!0)}B(P.attributes.horizontal,"horizontal",P.attributes.horizontal),B(P.attributes.vertical,"vertical",P.attributes.vertical==="center"?"middle":P.attributes.vertical),B(P.attributes.wrapText,"wrapText",!!P.attributes.wrapText),B(P.attributes.shrinkToFit,"shrinkToFit",!!P.attributes.shrinkToFit),B(P.attributes.indent,"indent",parseInt(P.attributes.indent,10)),B(P.attributes.textRotation,"textRotation",t.toModel(P.attributes.textRotation)),B(P.attributes.readingOrder,"readingOrder",P.attributes.readingOrder==="2"?"rtl":"ltr"),this.model=z?D:null}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"alignment"}}]),p}(a);S.exports=i},{"../../../doc/enums":7,"../../../utils/utils":26,"../base-xform":31}],126:[function(e,S,_){function u(o,p){var E=Object.keys(o);if(Object.getOwnPropertySymbols){var P=Object.getOwnPropertySymbols(o);p&&(P=P.filter(function(D){return Object.getOwnPropertyDescriptor(o,D).enumerable})),E.push.apply(E,P)}return E}function y(o){for(var p=1;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(o){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(E){return E.__proto__||Object.getPrototypeOf(E)},a(o)}var r=e("../base-xform"),t=e("./color-xform"),i=function(o){h(E,o);var p=d(E);function E(P){var D;return w(this,E),D=p.call(this),D.name=P,D.map={color:new t},D}return v(E,[{key:"render",value:function(D,z,B){var M=z&&z.color||B||this.defaultColor;D.openNode(this.name),z&&z.style&&(D.addAttribute("style",z.style),M&&this.map.color.render(D,M)),D.closeNode()}},{key:"parseOpen",value:function(D){if(this.parser)return this.parser.parseOpen(D),!0;switch(D.name){case this.name:{var z=D.attributes.style;return z?this.model={style:z}:this.model=void 0,!0}case"color":return this.parser=this.map.color,this.parser.parseOpen(D),!0;default:return!1}}},{key:"parseText",value:function(D){this.parser&&this.parser.parseText(D)}},{key:"parseClose",value:function(D){return this.parser?(this.parser.parseClose(D)||(this.parser=void 0),!0):(D===this.name&&this.map.color.model&&(this.model||(this.model={}),this.model.color=this.map.color.model),!1)}},{key:"validStyle",value:function(D){return E.validStyleValues[D]}},{key:"tag",get:function(){return this.name}}]),E}(r);i.validStyleValues=["thin","dotted","dashDot","hair","dashDotDot","slantDashDot","mediumDashed","mediumDashDotDot","mediumDashDot","medium","double","thick"].reduce(function(o,p){return o[p]=!0,o},{});var n=function(o){h(E,o);var p=d(E);function E(){var P;return w(this,E),P=p.call(this),P.map={top:new i("top"),left:new i("left"),bottom:new i("bottom"),right:new i("right"),diagonal:new i("diagonal")},P}return v(E,[{key:"render",value:function(D,z){var B=z.color;D.openNode("border"),z.diagonal&&z.diagonal.style&&(z.diagonal.up&&D.addAttribute("diagonalUp","1"),z.diagonal.down&&D.addAttribute("diagonalDown","1"));function M(I,T){I&&!I.color&&z.color&&(I=y(y({},I),{},{color:z.color})),T.render(D,I,B)}M(z.left,this.map.left),M(z.right,this.map.right),M(z.top,this.map.top),M(z.bottom,this.map.bottom),M(z.diagonal,this.map.diagonal),D.closeNode()}},{key:"parseOpen",value:function(D){if(this.parser)return this.parser.parseOpen(D),!0;switch(D.name){case"border":return this.reset(),this.diagonalUp=!!D.attributes.diagonalUp,this.diagonalDown=!!D.attributes.diagonalDown,!0;default:return this.parser=this.map[D.name],this.parser?(this.parser.parseOpen(D),!0):!1}}},{key:"parseText",value:function(D){this.parser&&this.parser.parseText(D)}},{key:"parseClose",value:function(D){if(this.parser)return this.parser.parseClose(D)||(this.parser=void 0),!0;if(D==="border"){var z=this.model={},B=function(I,T,C){T&&(C&&Object.assign(T,C),z[I]=T)};B("left",this.map.left.model),B("right",this.map.right.model),B("top",this.map.top.model),B("bottom",this.map.bottom.model),B("diagonal",this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}}]),E}(r);S.exports=n},{"../base-xform":31,"./color-xform":127}],127:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.name=i||"color",n}return b(t,[{key:"render",value:function(n,o){return o?(n.openNode(this.name),o.argb?n.addAttribute("rgb",o.argb):o.theme!==void 0?(n.addAttribute("theme",o.theme),o.tint!==void 0&&n.addAttribute("tint",o.tint)):o.indexed!==void 0?n.addAttribute("indexed",o.indexed):n.addAttribute("auto","1"),n.closeNode(),!0):!1}},{key:"parseOpen",value:function(n){return n.name===this.name?(n.attributes.rgb?this.model={argb:n.attributes.rgb}:n.attributes.theme?(this.model={theme:parseInt(n.attributes.theme,10)},n.attributes.tint&&(this.model.tint=parseFloat(n.attributes.tint))):n.attributes.indexed?this.model={indexed:parseInt(n.attributes.indexed,10)}:this.model=void 0,!0):!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return this.name}}]),t}(m);S.exports=c},{"../base-xform":31}],128:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,E){if(!(p instanceof E))throw new TypeError("Cannot call a class as a function")}function g(p,E){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("../base-xform"),c=e("./alignment-xform"),a=e("./border-xform"),r=e("./fill-xform"),t=e("./font-xform"),i=e("./numfmt-xform"),n=e("./protection-xform"),o=function(p){w(P,p);var E=v(P);function P(){var D;return y(this,P),D=E.call(this),D.map={alignment:new c,border:new a,fill:new r,font:new t,numFmt:new i,protection:new n},D}return b(P,[{key:"render",value:function(z,B){z.openNode(this.tag),B.font&&this.map.font.render(z,B.font),B.numFmt&&this.map.numFmt.render(z,B.numFmt),B.fill&&this.map.fill.render(z,B.fill),B.alignment&&this.map.alignment.render(z,B.alignment),B.border&&this.map.border.render(z,B.border),B.protection&&this.map.protection.render(z,B.protection),z.closeNode()}},{key:"parseOpen",value:function(z){if(this.parser)return this.parser.parseOpen(z),!0;switch(z.name){case this.tag:return this.reset(),!0;default:return this.parser=this.map[z.name],this.parser&&this.parser.parseOpen(z),!0}}},{key:"parseText",value:function(z){this.parser&&this.parser.parseText(z)}},{key:"parseClose",value:function(z){return this.parser?(this.parser.parseClose(z)||(this.parser=void 0),!0):z===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):!0}},{key:"tag",get:function(){return"dxf"}}]),P}(m);S.exports=o},{"../base-xform":31,"./alignment-xform":125,"./border-xform":126,"./fill-xform":129,"./font-xform":130,"./numfmt-xform":131,"./protection-xform":132}],129:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../base-xform"),c=e("./color-xform"),a=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={color:new c},E}return b(p,[{key:"render",value:function(P,D){P.openNode("stop"),P.addAttribute("position",D.position),this.map.color.render(P,D.color),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"stop":return this.model={position:parseFloat(P.attributes.position)},!0;case"color":return this.parser=this.map.color,this.parser.parseOpen(P),!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.model.color=this.parser.model,this.parser=void 0),!0):!1}},{key:"tag",get:function(){return"stop"}}]),p}(m),r=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={fgColor:new c("fgColor"),bgColor:new c("bgColor")},E}return b(p,[{key:"render",value:function(P,D){P.openNode("patternFill"),P.addAttribute("patternType",D.pattern),D.fgColor&&this.map.fgColor.render(P,D.fgColor),D.bgColor&&this.map.bgColor.render(P,D.bgColor),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"patternFill":return this.model={type:"pattern",pattern:P.attributes.patternType},!0;default:return this.parser=this.map[P.name],this.parser?(this.parser.parseOpen(P),!0):!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.parser.model&&(this.model[P]=this.parser.model),this.parser=void 0),!0):!1}},{key:"name",get:function(){return"pattern"}},{key:"tag",get:function(){return"patternFill"}}]),p}(m),t=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={stop:new a},E}return b(p,[{key:"render",value:function(P,D){switch(P.openNode("gradientFill"),D.gradient){case"angle":P.addAttribute("degree",D.degree);break;case"path":P.addAttribute("type","path"),D.center.left&&(P.addAttribute("left",D.center.left),D.center.right===void 0&&P.addAttribute("right",D.center.left)),D.center.right&&P.addAttribute("right",D.center.right),D.center.top&&(P.addAttribute("top",D.center.top),D.center.bottom===void 0&&P.addAttribute("bottom",D.center.top)),D.center.bottom&&P.addAttribute("bottom",D.center.bottom);break}var z=this.map.stop;D.stops.forEach(function(B){z.render(P,B)}),P.closeNode()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"gradientFill":{var D=this.model={stops:[]};return P.attributes.degree?(D.gradient="angle",D.degree=parseInt(P.attributes.degree,10)):P.attributes.type==="path"&&(D.gradient="path",D.center={left:P.attributes.left?parseFloat(P.attributes.left):0,top:P.attributes.top?parseFloat(P.attributes.top):0},P.attributes.right!==P.attributes.left&&(D.center.right=P.attributes.right?parseFloat(P.attributes.right):0),P.attributes.bottom!==P.attributes.top&&(D.center.bottom=P.attributes.bottom?parseFloat(P.attributes.bottom):0)),!0}case"stop":return this.parser=this.map.stop,this.parser.parseOpen(P),!0;default:return!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0):!1}},{key:"name",get:function(){return"gradient"}},{key:"tag",get:function(){return"gradientFill"}}]),p}(m),i=function(n){w(p,n);var o=v(p);function p(){var E;return y(this,p),E=o.call(this),E.map={patternFill:new r,gradientFill:new t},E}return b(p,[{key:"render",value:function(P,D){switch(P.addRollback(),P.openNode("fill"),D.type){case"pattern":this.map.patternFill.render(P,D);break;case"gradient":this.map.gradientFill.render(P,D);break;default:P.rollback();return}P.closeNode(),P.commit()}},{key:"parseOpen",value:function(P){if(this.parser)return this.parser.parseOpen(P),!0;switch(P.name){case"fill":return this.model={},!0;default:return this.parser=this.map[P.name],this.parser?(this.parser.parseOpen(P),!0):!1}}},{key:"parseText",value:function(P){this.parser&&this.parser.parseText(P)}},{key:"parseClose",value:function(P){return this.parser?(this.parser.parseClose(P)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0):!1}},{key:"validStyle",value:function(P){return p.validPatternValues[P]}},{key:"tag",get:function(){return"fill"}}]),p}(m);i.validPatternValues=["none","solid","darkVertical","darkGray","mediumGray","lightGray","gray125","gray0625","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","lightGrid"].reduce(function(n,o){return n[o]=!0,n},{}),i.StopXform=a,i.PatternFillXform=r,i.GradientFillXform=t,S.exports=i},{"../base-xform":31,"./color-xform":127}],130:[function(e,S,_){function u(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(P){return typeof P}:u=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},u(p)}function y(p,E){if(!(p instanceof E))throw new TypeError("Cannot call a class as a function")}function g(p,E){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(p){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},s(p)}var m=e("./color-xform"),c=e("../simple/boolean-xform"),a=e("../simple/integer-xform"),r=e("../simple/string-xform"),t=e("./underline-xform"),i=e("../../../utils/under-dash"),n=e("../base-xform"),o=function(p){w(P,p);var E=v(P);function P(D){var z;return y(this,P),z=E.call(this),z.options=D||P.OPTIONS,z.map={b:{prop:"bold",xform:new c({tag:"b",attr:"val"})},i:{prop:"italic",xform:new c({tag:"i",attr:"val"})},u:{prop:"underline",xform:new t},charset:{prop:"charset",xform:new a({tag:"charset",attr:"val"})},color:{prop:"color",xform:new m},condense:{prop:"condense",xform:new c({tag:"condense",attr:"val"})},extend:{prop:"extend",xform:new c({tag:"extend",attr:"val"})},family:{prop:"family",xform:new a({tag:"family",attr:"val"})},outline:{prop:"outline",xform:new c({tag:"outline",attr:"val"})},vertAlign:{prop:"vertAlign",xform:new r({tag:"vertAlign",attr:"val"})},scheme:{prop:"scheme",xform:new r({tag:"scheme",attr:"val"})},shadow:{prop:"shadow",xform:new c({tag:"shadow",attr:"val"})},strike:{prop:"strike",xform:new c({tag:"strike",attr:"val"})},sz:{prop:"size",xform:new a({tag:"sz",attr:"val"})}},z.map[z.options.fontNameTag]={prop:"name",xform:new r({tag:z.options.fontNameTag,attr:"val"})},z}return b(P,[{key:"render",value:function(z,B){var M=this.map;z.openNode(this.options.tagName),i.each(this.map,function(I,T){M[T].xform.render(z,B[I.prop])}),z.closeNode()}},{key:"parseOpen",value:function(z){if(this.parser)return this.parser.parseOpen(z),!0;if(this.map[z.name])return this.parser=this.map[z.name].xform,this.parser.parseOpen(z);switch(z.name){case this.options.tagName:return this.model={},!0;default:return!1}}},{key:"parseText",value:function(z){this.parser&&this.parser.parseText(z)}},{key:"parseClose",value:function(z){if(this.parser&&!this.parser.parseClose(z)){var B=this.map[z];return this.parser.model&&(this.model[B.prop]=this.parser.model),this.parser=void 0,!0}switch(z){case this.options.tagName:return!1;default:return!0}}},{key:"tag",get:function(){return this.options.tagName}}]),P}(n);o.OPTIONS={tagName:"font",fontNameTag:"name"},S.exports=o},{"../../../utils/under-dash":25,"../base-xform":31,"../simple/boolean-xform":115,"../simple/integer-xform":117,"../simple/string-xform":118,"./color-xform":127,"./underline-xform":135}],131:[function(e,S,_){function u(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(p){return typeof p}:u=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},u(n)}function y(n,o){if(!(n instanceof o))throw new TypeError("Cannot call a class as a function")}function g(n,o){for(var p=0;p"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(n){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},s(n)}var m=e("../../../utils/under-dash"),c=e("../../defaultnumformats"),a=e("../base-xform");function r(){var n={};return m.each(c,function(o,p){o.f&&(n[o.f]=parseInt(p,10))}),n}var t=r(),i=function(n){w(p,n);var o=v(p);function p(E,P){var D;return y(this,p),D=o.call(this),D.id=E,D.formatCode=P,D}return b(p,[{key:"render",value:function(P,D){P.leafNode("numFmt",{numFmtId:D.id,formatCode:D.formatCode})}},{key:"parseOpen",value:function(P){switch(P.name){case"numFmt":return this.model={id:parseInt(P.attributes.numFmtId,10),formatCode:P.attributes.formatCode.replace(/[\\](.)/g,"$1")},!0;default:return!1}}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"numFmt"}}]),p}(a);i.getDefaultFmtId=function(o){return t[o]},i.getDefaultFmtCode=function(o){return c[o]&&c[o].f},S.exports=i},{"../../../utils/under-dash":25,"../../defaultnumformats":29,"../base-xform":31}],132:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c={boolean:function(t,i){return t===void 0?i:t}},a=function(r){w(i,r);var t=v(i);function i(){return y(this,i),t.apply(this,arguments)}return b(i,[{key:"render",value:function(o,p){o.addRollback(),o.openNode("protection");var E=!1;function P(D,z){z!==void 0&&(o.addAttribute(D,z),E=!0)}P("locked",c.boolean(p.locked,!0)?void 0:"0"),P("hidden",c.boolean(p.hidden,!1)?"1":void 0),o.closeNode(),E?o.commit():o.rollback()}},{key:"parseOpen",value:function(o){var p={locked:o.attributes.locked!=="0",hidden:o.attributes.hidden==="1"},E=!p.locked||p.hidden;this.model=E?p:null}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"protection"}}]),i}(m);S.exports=a},{"../base-xform":31}],133:[function(e,S,_){function u(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(n){return typeof n}:u=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},u(t)}function y(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function g(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},s(t)}var m=e("../base-xform"),c=e("./alignment-xform"),a=e("./protection-xform"),r=function(t){w(n,t);var i=v(n);function n(o){var p;return y(this,n),p=i.call(this),p.xfId=!!(o&&o.xfId),p.map={alignment:new c,protection:new a},p}return b(n,[{key:"render",value:function(p,E){p.openNode("xf",{numFmtId:E.numFmtId||0,fontId:E.fontId||0,fillId:E.fillId||0,borderId:E.borderId||0}),this.xfId&&p.addAttribute("xfId",E.xfId||0),E.numFmtId&&p.addAttribute("applyNumberFormat","1"),E.fontId&&p.addAttribute("applyFont","1"),E.fillId&&p.addAttribute("applyFill","1"),E.borderId&&p.addAttribute("applyBorder","1"),E.alignment&&p.addAttribute("applyAlignment","1"),E.protection&&p.addAttribute("applyProtection","1"),E.alignment&&this.map.alignment.render(p,E.alignment),E.protection&&this.map.protection.render(p,E.protection),p.closeNode()}},{key:"parseOpen",value:function(p){if(this.parser)return this.parser.parseOpen(p),!0;switch(p.name){case"xf":return this.model={numFmtId:parseInt(p.attributes.numFmtId,10),fontId:parseInt(p.attributes.fontId,10),fillId:parseInt(p.attributes.fillId,10),borderId:parseInt(p.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(p.attributes.xfId,10)),!0;case"alignment":return this.parser=this.map.alignment,this.parser.parseOpen(p),!0;case"protection":return this.parser=this.map.protection,this.parser.parseOpen(p),!0;default:return!1}}},{key:"parseText",value:function(p){this.parser&&this.parser.parseText(p)}},{key:"parseClose",value:function(p){return this.parser?(this.parser.parseClose(p)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):p!=="xf"}},{key:"tag",get:function(){return"xf"}}]),n}(m);S.exports=r},{"../base-xform":31,"./alignment-xform":125,"./protection-xform":132}],134:[function(e,S,_){function u(M){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(T){return typeof T}:u=function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},u(M)}function y(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")}function g(M,I){for(var T=0;T"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(M){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(T){return T.__proto__||Object.getPrototypeOf(T)},s(M)}var m=e("../../../doc/enums"),c=e("../../../utils/xml-stream"),a=e("../base-xform"),r=e("../static-xform"),t=e("../list-xform"),i=e("./font-xform"),n=e("./fill-xform"),o=e("./border-xform"),p=e("./numfmt-xform"),E=e("./style-xform"),P=e("./dxf-xform"),D=164,z=function(M){w(T,M);var I=v(T);function T(C){var O;return y(this,T),O=I.call(this),O.map={numFmts:new t({tag:"numFmts",count:!0,childXform:new p}),fonts:new t({tag:"fonts",count:!0,childXform:new i,$:{"x14ac:knownFonts":1}}),fills:new t({tag:"fills",count:!0,childXform:new n}),borders:new t({tag:"borders",count:!0,childXform:new o}),cellStyleXfs:new t({tag:"cellStyleXfs",count:!0,childXform:new E}),cellXfs:new t({tag:"cellXfs",count:!0,childXform:new E({xfId:!0})}),dxfs:new t({tag:"dxfs",always:!0,count:!0,childXform:new P}),numFmt:new p,font:new i,fill:new n,border:new o,style:new E({xfId:!0}),cellStyles:T.STATIC_XFORMS.cellStyles,tableStyles:T.STATIC_XFORMS.tableStyles,extLst:T.STATIC_XFORMS.extLst},C&&O.init(),O}return b(T,[{key:"initIndex",value:function(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}},{key:"init",value:function(){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}},{key:"render",value:function(O,A){A=A||this.model,O.openXml(c.StdDocAttributes),O.openNode("styleSheet",T.STYLESHEET_ATTRIBUTES),this.index?(A.numFmts&&A.numFmts.length&&(O.openNode("numFmts",{count:A.numFmts.length}),A.numFmts.forEach(function(L){O.writeXml(L)}),O.closeNode()),A.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),O.openNode("fonts",{count:A.fonts.length,"x14ac:knownFonts":1}),A.fonts.forEach(function(L){O.writeXml(L)}),O.closeNode(),O.openNode("fills",{count:A.fills.length}),A.fills.forEach(function(L){O.writeXml(L)}),O.closeNode(),O.openNode("borders",{count:A.borders.length}),A.borders.forEach(function(L){O.writeXml(L)}),O.closeNode(),this.map.cellStyleXfs.render(O,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),O.openNode("cellXfs",{count:A.styles.length}),A.styles.forEach(function(L){O.writeXml(L)}),O.closeNode()):(this.map.numFmts.render(O,A.numFmts),this.map.fonts.render(O,A.fonts),this.map.fills.render(O,A.fills),this.map.borders.render(O,A.borders),this.map.cellStyleXfs.render(O,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(O,A.styles)),T.STATIC_XFORMS.cellStyles.render(O),this.map.dxfs.render(O,A.dxfs),T.STATIC_XFORMS.tableStyles.render(O),T.STATIC_XFORMS.extLst.render(O),O.closeNode()}},{key:"parseOpen",value:function(O){if(this.parser)return this.parser.parseOpen(O),!0;switch(O.name){case"styleSheet":return this.initIndex(),!0;default:return this.parser=this.map[O.name],this.parser&&this.parser.parseOpen(O),!0}}},{key:"parseText",value:function(O){this.parser&&this.parser.parseText(O)}},{key:"parseClose",value:function(O){var A=this;if(this.parser)return this.parser.parseClose(O)||(this.parser=void 0),!0;switch(O){case"styleSheet":{this.model={};var L=function($,N){N.model&&N.model.length&&(A.model[$]=N.model)};if(L("numFmts",this.map.numFmts),L("fonts",this.map.fonts),L("fills",this.map.fills),L("borders",this.map.borders),L("styles",this.map.cellXfs),L("dxfs",this.map.dxfs),this.index={model:[],numFmt:[]},this.model.numFmts){var U=this.index.numFmt;this.model.numFmts.forEach(function(W){U[W.id]=W.formatCode})}return!1}default:return!0}}},{key:"addStyleModel",value:function(O,A){if(!O)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(O))return this.weakMap.get(O);var L={};if(A=A||m.ValueType.Number,O.numFmt)L.numFmtId=this._addNumFmtStr(O.numFmt);else switch(A){case m.ValueType.Number:L.numFmtId=this._addNumFmtStr("General");break;case m.ValueType.Date:L.numFmtId=this._addNumFmtStr("mm-dd-yy");break}O.font&&(L.fontId=this._addFont(O.font)),O.border&&(L.borderId=this._addBorder(O.border)),O.fill&&(L.fillId=this._addFill(O.fill)),O.alignment&&(L.alignment=O.alignment),O.protection&&(L.protection=O.protection);var U=this._addStyle(L);return this.weakMap&&this.weakMap.set(O,U),U}},{key:"getStyleModel",value:function(O){var A=this.model.styles[O];if(!A)return null;var L=this.index.model[O];if(L)return L;if(L=this.index.model[O]={},A.numFmtId){var U=this.index.numFmt[A.numFmtId]||p.getDefaultFmtCode(A.numFmtId);U&&(L.numFmt=U)}function W($,N,F){if(F||F===0){var j=N[F];j&&(L[$]=j)}}return W("font",this.model.fonts,A.fontId),W("border",this.model.borders,A.borderId),W("fill",this.model.fills,A.fillId),A.alignment&&(L.alignment=A.alignment),A.protection&&(L.protection=A.protection),L}},{key:"addDxfStyle",value:function(O){return this.model.dxfs.push(O),this.model.dxfs.length-1}},{key:"getDxfStyle",value:function(O){return this.model.dxfs[O]}},{key:"_addStyle",value:function(O){var A=this.map.style.toXml(O),L=this.index.style[A];return L===void 0&&(L=this.index.style[A]=this.model.styles.length,this.model.styles.push(A)),L}},{key:"_addNumFmtStr",value:function(O){var A=p.getDefaultFmtId(O);if(A!==void 0||(A=this.index.numFmt[O],A!==void 0))return A;A=this.index.numFmt[O]=D+this.model.numFmts.length;var L=this.map.numFmt.toXml({id:A,formatCode:O});return this.model.numFmts.push(L),A}},{key:"_addFont",value:function(O){var A=this.map.font.toXml(O),L=this.index.font[A];return L===void 0&&(L=this.index.font[A]=this.model.fonts.length,this.model.fonts.push(A)),L}},{key:"_addBorder",value:function(O){var A=this.map.border.toXml(O),L=this.index.border[A];return L===void 0&&(L=this.index.border[A]=this.model.borders.length,this.model.borders.push(A)),L}},{key:"_addFill",value:function(O){var A=this.map.fill.toXml(O),L=this.index.fill[A];return L===void 0&&(L=this.index.fill[A]=this.model.fills.length,this.model.fills.push(A)),L}}]),T}(a);z.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"},z.STATIC_XFORMS={cellStyles:new r({tag:"cellStyles",$:{count:1},c:[{tag:"cellStyle",$:{name:"Normal",xfId:0,builtinId:0}}]}),dxfs:new r({tag:"dxfs",$:{count:0}}),tableStyles:new r({tag:"tableStyles",$:{count:0,defaultTableStyle:"TableStyleMedium2",defaultPivotStyle:"PivotStyleLight16"}}),extLst:new r({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"}}]}]})};var B=function(M){w(T,M);var I=v(T);function T(){var C;return y(this,T),C=I.call(this),C.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"}]},C}return b(T,[{key:"parseStream",value:function(O){return O.autodrain(),Promise.resolve()}},{key:"addStyleModel",value:function(O,A){switch(A){case m.ValueType.Date:return this.dateStyleId;default:return 0}}},{key:"getStyleModel",value:function(){return{}}},{key:"dateStyleId",get:function(){if(!this._dateStyleId){var O={numFmtId:p.getDefaultFmtId("mm-dd-yy")};this._dateStyleId=this.model.styles.length,this.model.styles.push(O)}return this._dateStyleId}}]),T}(z);z.Mock=B,S.exports=z},{"../../../doc/enums":7,"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"../static-xform":119,"./border-xform":126,"./dxf-xform":128,"./fill-xform":129,"./font-xform":130,"./numfmt-xform":131,"./style-xform":133}],135:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(i){var n;return y(this,t),n=r.call(this),n.model=i,n}return b(t,[{key:"render",value:function(n,o){if(o=o||this.model,o===!0)n.leafNode("u");else{var p=t.Attributes[o];p&&n.leafNode("u",p)}}},{key:"parseOpen",value:function(n){n.name==="u"&&(this.model=n.attributes.val||!0)}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"u"}}]),t}(m);c.Attributes={single:{},double:{val:"double"},singleAccounting:{val:"singleAccounting"},doubleAccounting:{val:"doubleAccounting"}},S.exports=c},{"../base-xform":31}],136:[function(e,S,_){function u(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(i){return typeof i}:u=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},u(r)}function y(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function g(r,t){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(r){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},s(r)}var m=e("../base-xform"),c=e("./filter-column-xform"),a=function(r){w(i,r);var t=v(i);function i(){var n;return y(this,i),n=t.call(this),n.map={filterColumn:new c},n}return b(i,[{key:"prepare",value:function(o){var p=this;o.columns.forEach(function(E,P){p.map.filterColumn.prepare(E,{index:P})})}},{key:"render",value:function(o,p){var E=this;return o.openNode(this.tag,{ref:p.autoFilterRef}),p.columns.forEach(function(P){E.map.filterColumn.render(o,P)}),o.closeNode(),!0}},{key:"parseOpen",value:function(o){if(this.parser)return this.parser.parseOpen(o),!0;switch(o.name){case this.tag:return this.model={autoFilterRef:o.attributes.ref,columns:[]},!0;default:if(this.parser=this.map[o.name],this.parser)return this.parseOpen(o),!0;throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(o)))}}},{key:"parseText",value:function(o){this.parser&&this.parser.parseText(o)}},{key:"parseClose",value:function(o){if(this.parser)return this.parser.parseClose(o)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;switch(o){case this.tag:return!1;default:throw new Error("Unexpected xml node in parseClose: ".concat(o))}}},{key:"tag",get:function(){return"autoFilter"}}]),i}(m);S.exports=a},{"../base-xform":31,"./filter-column-xform":137}],137:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"prepare",value:function(n,o){n.colId=o.index.toString()}},{key:"render",value:function(n,o){return n.leafNode(this.tag,{colId:o.colId,hiddenButton:o.filterButton?"0":"1"}),!0}},{key:"parseOpen",value:function(n){if(n.name===this.tag){var o=n.attributes;return this.model={filterButton:o.hiddenButton==="0"},!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"filterColumn"}}]),t}(m);S.exports=c},{"../base-xform":31}],138:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"prepare",value:function(n,o){n.id=o.index+1}},{key:"render",value:function(n,o){return n.leafNode(this.tag,{id:o.id.toString(),name:o.name,totalsRowLabel:o.totalsRowLabel,totalsRowFunction:o.totalsRowFunction,dxfId:o.dxfId}),!0}},{key:"parseOpen",value:function(n){if(n.name===this.tag){var o=n.attributes;return this.model={name:o.name,totalsRowLabel:o.totalsRowLabel,totalsRowFunction:o.totalsRowFunction,dxfId:o.dxfId},!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"tableColumn"}}]),t}(m);S.exports=c},{"../base-xform":31}],139:[function(e,S,_){function u(a){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(t){return typeof t}:u=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(a)}function y(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function g(a,r){for(var t=0;t"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function s(a){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(a)}var m=e("../base-xform"),c=function(a){w(t,a);var r=v(t);function t(){return y(this,t),r.apply(this,arguments)}return b(t,[{key:"render",value:function(n,o){return n.leafNode(this.tag,{name:o.theme?o.theme:void 0,showFirstColumn:o.showFirstColumn?"1":"0",showLastColumn:o.showLastColumn?"1":"0",showRowStripes:o.showRowStripes?"1":"0",showColumnStripes:o.showColumnStripes?"1":"0"}),!0}},{key:"parseOpen",value:function(n){if(n.name===this.tag){var o=n.attributes;return this.model={theme:o.name?o.name:null,showFirstColumn:o.showFirstColumn==="1",showLastColumn:o.showLastColumn==="1",showRowStripes:o.showRowStripes==="1",showColumnStripes:o.showColumnStripes==="1"},!0}return!1}},{key:"parseText",value:function(){}},{key:"parseClose",value:function(){return!1}},{key:"tag",get:function(){return"tableStyleInfo"}}]),t}(m);S.exports=c},{"../base-xform":31}],140:[function(e,S,_){function u(P){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(z){return typeof z}:u=function(z){return z&&typeof Symbol=="function"&&z.constructor===Symbol&&z!==Symbol.prototype?"symbol":typeof z},u(P)}function y(P,D){var z=Object.keys(P);if(Object.getOwnPropertySymbols){var B=Object.getOwnPropertySymbols(P);D&&(B=B.filter(function(M){return Object.getOwnPropertyDescriptor(P,M).enumerable})),z.push.apply(z,B)}return z}function g(P){for(var D=1;D"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(P){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(z){return z.__proto__||Object.getPrototypeOf(z)},a(P)}var r=e("../../../utils/xml-stream"),t=e("../base-xform"),i=e("../list-xform"),n=e("./auto-filter-xform"),o=e("./table-column-xform"),p=e("./table-style-info-xform"),E=function(P){h(z,P);var D=d(z);function z(){var B;return w(this,z),B=D.call(this),B.map={autoFilter:new n,tableColumns:new i({tag:"tableColumns",count:!0,empty:!0,childXform:new o}),tableStyleInfo:new p},B}return v(z,[{key:"prepare",value:function(M,I){this.map.autoFilter.prepare(M),this.map.tableColumns.prepare(M.columns,I)}},{key:"render",value:function(M,I){M.openXml(r.StdDocAttributes),M.openNode(this.tag,g(g({},z.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(M,I),this.map.tableColumns.render(M,I.columns),this.map.tableStyleInfo.render(M,I.style),M.closeNode()}},{key:"parseOpen",value:function(M){if(this.parser)return this.parser.parseOpen(M),!0;var I=M.name,T=M.attributes;switch(I){case this.tag:this.reset(),this.model={name:T.name,displayName:T.displayName||T.name,tableRef:T.ref,totalsRow:T.totalsRowCount==="1",headerRow:T.headerRowCount==="1"};break;default:this.parser=this.map[M.name],this.parser&&this.parser.parseOpen(M);break}return!0}},{key:"parseText",value:function(M){this.parser&&this.parser.parseText(M)}},{key:"parseClose",value:function(M){var I=this;if(this.parser)return this.parser.parseClose(M)||(this.parser=void 0),!0;switch(M){case this.tag:return 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(function(T,C){I.model.columns[C].filterButton=T.filterButton})),this.model.style=this.map.tableStyleInfo.model,!1;default:return!0}}},{key:"reconcile",value:function(M,I){M.columns.forEach(function(T){T.dxfId!==void 0&&(T.style=I.styles.getDxfStyle(T.dxfId))})}},{key:"tag",get:function(){return"table"}}]),z}(t);E.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"},S.exports=E},{"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"./auto-filter-xform":136,"./table-column-xform":138,"./table-style-info-xform":139}],141:[function(e,S,_){(function(u,y){function g(W,$,N,F,j,V,te){try{var re=W[V](te),le=re.value}catch(ye){N(ye);return}re.done?$(le):Promise.resolve(le).then(F,j)}function b(W){return function(){var $=this,N=arguments;return new Promise(function(F,j){var V=W.apply($,N);function te(le){g(V,F,j,te,re,"next",le)}function re(le){g(V,F,j,te,re,"throw",le)}te(void 0)})}}function w(W,$){if(!(W instanceof $))throw new TypeError("Cannot call a class as a function")}function f(W,$){for(var N=0;N<$.length;N++){var F=$[N];F.enumerable=F.enumerable||!1,F.configurable=!0,"value"in F&&(F.writable=!0),Object.defineProperty(W,F.key,F)}}function v(W,$,N){return $&&f(W.prototype,$),N&&f(W,N),W}function h(W){var $;if(typeof Symbol<"u"&&(Symbol.asyncIterator&&($=W[Symbol.asyncIterator],$!=null)||Symbol.iterator&&($=W[Symbol.iterator],$!=null)))return $.call(W);throw new TypeError("Object is not async iterable")}var l=e("fs"),d=e("jszip"),s=e("readable-stream"),m=s.PassThrough,c=e("../utils/zip-stream"),a=e("../utils/stream-buf"),r=e("../utils/utils"),t=e("../utils/xml-stream"),i=e("../utils/browser-buffer-decode"),n=i.bufferToString,o=e("./xform/style/styles-xform"),p=e("./xform/core/core-xform"),E=e("./xform/strings/shared-strings-xform"),P=e("./xform/core/relationships-xform"),D=e("./xform/core/content-types-xform"),z=e("./xform/core/app-xform"),B=e("./xform/book/workbook-xform"),M=e("./xform/sheet/worksheet-xform"),I=e("./xform/drawing/drawing-xform"),T=e("./xform/table/table-xform"),C=e("./xform/comment/comments-xform"),O=e("./xform/comment/vml-notes-xform"),A=e("./xml/theme1.js");function L(W,$){return new Promise(function(N,F){l.readFile(W,$,function(j,V){j?F(j):N(V)})})}var U=function(){function W($){w(this,W),this.workbook=$}return v(W,[{key:"readFile",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V){var te,re;return regeneratorRuntime.wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:return ye.next=2,r.fs.exists(j);case 2:if(ye.sent){ye.next=4;break}throw new Error("File not found: ".concat(j));case 4:return te=l.createReadStream(j),ye.prev=5,ye.next=8,this.read(te,V);case 8:return re=ye.sent,te.close(),ye.abrupt("return",re);case 13:throw ye.prev=13,ye.t0=ye.catch(5),te.close(),ye.t0;case 17:case"end":return ye.stop()}},F,this,[[5,13]])}));function N(F,j){return $.apply(this,arguments)}return N}()},{key:"parseRels",value:function(N){var F=new P;return F.parseStream(N)}},{key:"parseWorkbook",value:function(N){var F=new B;return F.parseStream(N)}},{key:"parseSharedStrings",value:function(N){var F=new E;return F.parseStream(N)}},{key:"reconcile",value:function(N,F){var j=new B,V=new M(F),te=new I,re=new T;j.reconcile(N);var le={media:N.media,mediaIndex:N.mediaIndex};Object.keys(N.drawings).forEach(function(ne){var J=N.drawings[ne],Q=N.drawingRels[ne];Q&&(le.rels=Q.reduce(function(he,xe){return he[xe.Id]=xe,he},{}),(J.anchors||[]).forEach(function(he){var xe=he.picture&&he.picture.hyperlinks;xe&&le.rels[xe.rId]&&(xe.hyperlink=le.rels[xe.rId].Target,delete xe.rId)}),te.reconcile(J,le))});var ye={styles:N.styles};Object.values(N.tables).forEach(function(ne){re.reconcile(ne,ye)});var ge={styles:N.styles,sharedStrings:N.sharedStrings,media:N.media,mediaIndex:N.mediaIndex,date1904:N.properties&&N.properties.date1904,drawings:N.drawings,comments:N.comments,tables:N.tables,vmlDrawings:N.vmlDrawings};N.worksheets.forEach(function(ne){ne.relationships=N.worksheetRels[ne.sheetNo],V.reconcile(ne,ge)}),delete N.worksheetHash,delete N.worksheetRels,delete N.globalRels,delete N.sharedStrings,delete N.workbookRels,delete N.sheetDefs,delete N.styles,delete N.mediaIndex,delete N.drawings,delete N.drawingRels,delete N.vmlDrawings}},{key:"_processWorksheetEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te,re,le){var ye,ge;return regeneratorRuntime.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return ye=new M(re),J.next=3,ye.parseStream(j);case 3:ge=J.sent,ge.sheetNo=te,V.worksheetHash[le]=ge,V.worksheets.push(ge);case 7:case"end":return J.stop()}},F)}));function N(F,j,V,te,re){return $.apply(this,arguments)}return N}()},{key:"_processCommentEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){var re,le;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return re=new C,ge.next=3,re.parseStream(j);case 3:le=ge.sent,V.comments["../".concat(te,".xml")]=le;case 5:case"end":return ge.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"_processTableEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){var re,le;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return re=new T,ge.next=3,re.parseStream(j);case 3:le=ge.sent,V.tables["../tables/".concat(te,".xml")]=le;case 5:case"end":return ge.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"_processWorksheetRelsEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){var re,le;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return re=new P,ge.next=3,re.parseStream(j);case 3:le=ge.sent,V.worksheetRels[te]=le;case 5:case"end":return ge.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"_processMediaEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){var re,le,ye;return regeneratorRuntime.wrap(function(ne){for(;;)switch(ne.prev=ne.next){case 0:if(re=te.lastIndexOf("."),!(re>=1)){ne.next=6;break}return le=te.substr(re+1),ye=te.substr(0,re),ne.next=6,new Promise(function(J,Q){var he=new a;he.on("finish",function(){V.mediaIndex[te]=V.media.length,V.mediaIndex[ye]=V.media.length;var xe={type:"image",name:ye,extension:le,buffer:he.toBuffer()};V.media.push(xe),J()}),j.on("error",function(xe){Q(xe)}),j.pipe(he)});case 6:case"end":return ne.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"_processDrawingEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){var re,le;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return re=new I,ge.next=3,re.parseStream(j);case 3:le=ge.sent,V.drawings[te]=le;case 5:case"end":return ge.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"_processDrawingRelsEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){var re,le;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return re=new P,ge.next=3,re.parseStream(j);case 3:le=ge.sent,V.drawingRels[te]=le;case 5:case"end":return ge.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"_processVmlDrawingEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){var re,le;return regeneratorRuntime.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return re=new O,ge.next=3,re.parseStream(j);case 3:le=ge.sent,V.vmlDrawings["../drawings/".concat(te,".vml")]=le;case 5:case"end":return ge.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"_processThemeEntry",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V,te){return regeneratorRuntime.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return le.next=2,new Promise(function(ye,ge){var ne=new a;j.on("error",ge),ne.on("error",ge),ne.on("finish",function(){V.themes[te]=ne.read().toString(),ye()}),j.pipe(ne)});case 2:case"end":return le.stop()}},F)}));function N(F,j,V){return $.apply(this,arguments)}return N}()},{key:"createInputStream",value:function(){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")}},{key:"read",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V){var te,re,le,ye,ge,ne,J,Q;return regeneratorRuntime.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:!j[Symbol.asyncIterator]&&j.pipe&&(j=j.pipe(new m)),te=[],re=!0,le=!1,xe.prev=4,ge=h(j);case 6:return xe.next=8,ge.next();case 8:return ne=xe.sent,re=ne.done,xe.next=12,ne.value;case 12:if(J=xe.sent,re){xe.next=19;break}Q=J,te.push(Q);case 16:re=!0,xe.next=6;break;case 19:xe.next=25;break;case 21:xe.prev=21,xe.t0=xe.catch(4),le=!0,ye=xe.t0;case 25:if(xe.prev=25,xe.prev=26,!(!re&&ge.return!=null)){xe.next=30;break}return xe.next=30,ge.return();case 30:if(xe.prev=30,!le){xe.next=33;break}throw ye;case 33:return xe.finish(30);case 34:return xe.finish(25);case 35:return xe.abrupt("return",this.load(y.concat(te),V));case 36:case"end":return xe.stop()}},F,this,[[4,21,25,35],[26,,30,34]])}));function N(F,j){return $.apply(this,arguments)}return N}()},{key:"load",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V){var te,re,le,ye,ge,ne,J,Q,he,xe,ie,se,Ce,q,G,Y,fe;return regeneratorRuntime.wrap(function(_e){for(;;)switch(_e.prev=_e.next){case 0:return V&&V.base64?te=y.from(j.toString(),"base64"):te=j,re={worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},comments:{},tables:{},vmlDrawings:{}},_e.next=4,d.loadAsync(te);case 4:le=_e.sent,ye=0,ge=Object.values(le.files);case 6:if(!(ye0&&(Q=new t,le.render(Q,J),j.append(Q.xml,{name:"xl/comments".concat(J.id,".xml")}),Q=new t,ye.render(Q,J),j.append(Q.xml,{name:"xl/drawings/vmlDrawing".concat(J.id,".vml")}))});case 5:case"end":return ne.stop()}},F)}));function N(F,j){return $.apply(this,arguments)}return N}()},{key:"_finalize",value:function(N){var F=this;return new Promise(function(j,V){N.on("finish",function(){j(F)}),N.on("error",V),N.finalize()})}},{key:"prepareModel",value:function(N,F){N.creator=N.creator||"ExcelJS",N.lastModifiedBy=N.lastModifiedBy||"ExcelJS",N.created=N.created||new Date,N.modified=N.modified||new Date,N.useSharedStrings=F.useSharedStrings!==void 0?F.useSharedStrings:!0,N.useStyles=F.useStyles!==void 0?F.useStyles:!0,N.sharedStrings=new E,N.styles=N.useStyles?new o(!0):new o.Mock;var j=new B,V=new M;j.prepare(N);var te={sharedStrings:N.sharedStrings,styles:N.styles,date1904:N.properties.date1904,drawingsCount:0,media:N.media};te.drawings=N.drawings=[],te.commentRefs=N.commentRefs=[];var re=0;N.tables=[],N.worksheets.forEach(function(le){le.tables.forEach(function(ye){re++,ye.target="table".concat(re,".xml"),ye.id=re,N.tables.push(ye)}),V.prepare(le,te)})}},{key:"write",value:function(){var $=b(regeneratorRuntime.mark(function F(j,V){var te,re;return regeneratorRuntime.wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:return V=V||{},te=this.workbook.model,re=new c.ZipWriter(V.zip),re.pipe(j),this.prepareModel(te,V),ye.next=7,this.addContentTypes(re,te);case 7:return ye.next=9,this.addOfficeRels(re,te);case 9:return ye.next=11,this.addWorkbookRels(re,te);case 11:return ye.next=13,this.addWorksheets(re,te);case 13:return ye.next=15,this.addSharedStrings(re,te);case 15:return ye.next=17,this.addDrawings(re,te);case 17:return ye.next=19,this.addTables(re,te);case 19:return ye.next=21,Promise.all([this.addThemes(re,te),this.addStyles(re,te)]);case 21:return ye.next=23,this.addMedia(re,te);case 23:return ye.next=25,Promise.all([this.addApp(re,te),this.addCore(re,te)]);case 25:return ye.next=27,this.addWorkbook(re,te);case 27:return ye.abrupt("return",this._finalize(re));case 28:case"end":return ye.stop()}},F,this)}));function N(F,j){return $.apply(this,arguments)}return N}()},{key:"writeFile",value:function(N,F){var j=this,V=l.createWriteStream(N);return new Promise(function(te,re){V.on("finish",function(){te()}),V.on("error",function(le){re(le)}),j.write(V,F).then(function(){V.end()})})}},{key:"writeBuffer",value:function(){var $=b(regeneratorRuntime.mark(function F(j){var V;return regeneratorRuntime.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:return V=new a,re.next=3,this.write(V,j);case 3:return re.abrupt("return",V.read());case 4:case"end":return re.stop()}},F,this)}));function N(F){return $.apply(this,arguments)}return N}()}]),W}();U.RelType=e("./rel-type"),S.exports=U}).call(this,e("_process"),e("buffer").Buffer)},{"../utils/browser-buffer-decode":16,"../utils/stream-buf":23,"../utils/utils":26,"../utils/xml-stream":27,"../utils/zip-stream":28,"./rel-type":30,"./xform/book/workbook-xform":37,"./xform/comment/comments-xform":39,"./xform/comment/vml-notes-xform":44,"./xform/core/app-xform":50,"./xform/core/content-types-xform":51,"./xform/core/core-xform":52,"./xform/core/relationships-xform":54,"./xform/drawing/drawing-xform":61,"./xform/sheet/worksheet-xform":114,"./xform/strings/shared-strings-xform":123,"./xform/style/styles-xform":134,"./xform/table/table-xform":140,"./xml/theme1.js":142,_process:467,buffer:216,fs:215,jszip:399,"readable-stream":491}],142:[function(e,S,_){S.exports=` + `},{}],143:[function(e,S,_){(function(u){function y(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(n){return typeof n}:y=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},y(t)}function g(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function b(t,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},m(t)}Object.defineProperty(_,"__esModule",{value:!0}),_.CsvFormatterStream=void 0;var c=e("stream"),a=e("./formatter"),r=function(t){f(n,t);var i=h(n);function n(o){var p;return g(this,n),p=i.call(this,{writableObjectMode:o.objectMode}),p.hasWrittenBOM=!1,p.formatterOptions=o,p.rowFormatter=new a.RowFormatter(o),p.hasWrittenBOM=!o.writeBOM,p}return w(n,[{key:"transform",value:function(p){return this.rowFormatter.rowTransform=p,this}},{key:"_transform",value:function(p,E,P){var D=this,z=!1;try{this.hasWrittenBOM||(this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0),this.rowFormatter.format(p,function(B,M){return B?(z=!0,P(B)):(M&&M.forEach(function(I){D.push(u.from(I,"utf8"))}),z=!0,P())})}catch(B){if(z)throw B;P(B)}}},{key:"_flush",value:function(p){var E=this;this.rowFormatter.finish(function(P,D){return P?p(P):(D&&D.forEach(function(z){E.push(u.from(z,"utf8"))}),p())})}}]),n}(c.Transform);_.CsvFormatterStream=r}).call(this,e("buffer").Buffer)},{"./formatter":147,buffer:216,stream:506}],144:[function(e,S,_){function u(g,b){if(!(g instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(_,"__esModule",{value:!0}),_.FormatterOptions=void 0;var y=function g(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};u(this,g);var w;this.objectMode=!0,this.delimiter=",",this.rowDelimiter=` `,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,b||{}),typeof(b==null?void 0:b.quoteHeaders)>"u"&&(this.quoteHeaders=this.quoteColumns),(b==null?void 0:b.quote)===!0?this.quote='"':(b==null?void 0:b.quote)===!1&&(this.quote=""),typeof(b==null?void 0:b.escape)!="string"&&(this.escape=this.quote),this.shouldWriteHeaders=!!this.headers&&((w=b.writeHeaders)!==null&&w!==void 0?w:!0),this.headers=Array.isArray(this.headers)?this.headers:null,this.escapedQuote="".concat(this.escape).concat(this.quote)};_.FormatterOptions=y},{}],145:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;s1&&arguments[1]!==void 0?arguments[1]:{},r=[],t=new v.Writable({write:function(n,o,p){r.push(n),p()}});return new Promise(function(i,n){t.on("error",n).on("finish",function(){return i(u.concat(r))}),_.write(c,a).pipe(t)})},_.writeToString=function(c,a){return _.writeToBuffer(c,a).then(function(r){return r.toString()})},_.writeToPath=function(c,a,r){var t=h.createWriteStream(c,{encoding:"utf8"});return _.write(a,r).pipe(t)}}).call(this,e("buffer").Buffer)},{"./CsvFormatterStream":143,"./FormatterOptions":144,"./types":149,buffer:216,fs:215,stream:506,util:525}],149:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.isSyncTransform=void 0,_.isSyncTransform=function(u){return u.length===1}},{}],150:[function(e,S,_){(function(u){function y(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(P){return typeof P}:y=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},y(p)}function g(p,O){if(!(p instanceof O))throw new TypeError("Cannot call a class as a function")}function b(p,O){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(p){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},a(p)}Object.defineProperty(_,"__esModule",{value:!0}),_.CsvParserStream=void 0;var r=e("string_decoder"),t=e("stream"),i=e("./transforms"),n=e("./parser"),o=function(p){h(P,p);var O=d(P);function P(B){var z;return g(this,P),z=O.call(this,{objectMode:B.objectMode}),z.lines="",z.rowCount=0,z.parsedRowCount=0,z.parsedLineCount=0,z.endEmitted=!1,z.headersEmitted=!1,z.parserOptions=B,z.parser=new n.Parser(B),z.headerTransformer=new i.HeaderTransformer(B),z.decoder=new r.StringDecoder(B.encoding),z.rowTransformerValidator=new i.RowTransformerValidator,z}return w(P,[{key:"transform",value:function(z){return this.rowTransformerValidator.rowTransform=z,this}},{key:"validate",value:function(z){return this.rowTransformerValidator.rowValidator=z,this}},{key:"emit",value:function(z){var D;if(z==="end")return this.endEmitted||(this.endEmitted=!0,f(a(P.prototype),"emit",this).call(this,"end",this.rowCount)),!1;for(var M=arguments.length,I=new Array(M>1?M-1:0),T=1;T=I||M.hasHitRowLimit)return D();if(M.parsedLineCount+=1,M.shouldSkipLine)return A();var L=z[E];M.rowCount+=1,M.parsedRowCount+=1;var $=M.rowCount;return M.transformRow(L,function(W,U){if(W)return M.rowCount-=1,A(W);if(!U)return A(new Error("expected transform result"));if(!U.isValid)M.emit("data-invalid",U.row,$,U.reason);else if(U.row)return M.pushRow(U.row,A);return A()})};T(0)}},{key:"transformRow",value:function(z,D){var M=this;try{this.headerTransformer.transform(z,function(I,T){return I?D(I):T?T.isValid?T.row?M.shouldEmitRows?M.rowTransformerValidator.transformAndValidate(T.row,D):M.skipRow(D):(M.rowCount-=1,M.parsedRowCount-=1,D(null,{row:null,isValid:!0})):M.shouldEmitRows?D(null,{isValid:!1,row:z}):M.skipRow(D):D(new Error("Expected result from header transform"))})}catch(I){D(I)}}},{key:"checkAndEmitHeaders",value:function(){!this.headersEmitted&&this.headerTransformer.headers&&(this.headersEmitted=!0,this.emit("headers",this.headerTransformer.headers))}},{key:"skipRow",value:function(z){return this.rowCount-=1,z(null,{row:null,isValid:!0})}},{key:"pushRow",value:function(z,D){try{this.parserOptions.objectMode?this.push(z):this.push(JSON.stringify(z)),D()}catch(M){D(M)}}},{key:"hasHitRowLimit",get:function(){return this.parserOptions.limitRows&&this.rowCount>=this.parserOptions.maxRows}},{key:"shouldEmitRows",get:function(){return this.parsedRowCount>this.parserOptions.skipRows}},{key:"shouldSkipLine",get:function(){return this.parsedLineCount<=this.parserOptions.skipLines}}]),P}(t.Transform);_.CsvParserStream=o}).call(this,e("timers").setImmediate)},{"./parser":162,"./transforms":165,stream:506,string_decoder:520,timers:521}],151:[function(e,S,_){function u(f,v){if(!(f instanceof v))throw new TypeError("Cannot call a class as a function")}var y=function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(_,"__esModule",{value:!0}),_.ParserOptions=void 0;var g=y(e("lodash.escaperegexp")),b=y(e("lodash.isnil")),w=function f(v){u(this,f);var h;if(this.objectMode=!0,this.delimiter=",",this.ignoreEmpty=!1,this.quote='"',this.escape=null,this.escapeChar=this.quote,this.comment=null,this.supportsComments=!1,this.ltrim=!1,this.rtrim=!1,this.trim=!1,this.headers=null,this.renameHeaders=!1,this.strictColumnHandling=!1,this.discardUnmappedColumns=!1,this.carriageReturn="\r",this.encoding="utf8",this.limitRows=!1,this.maxRows=0,this.skipLines=0,this.skipRows=0,Object.assign(this,v||{}),this.delimiter.length>1)throw new Error("delimiter option must be one character long");this.escapedDelimiter=g.default(this.delimiter),this.escapeChar=(h=this.escape)!==null&&h!==void 0?h:this.quote,this.supportsComments=!b.default(this.comment),this.NEXT_TOKEN_REGEXP=new RegExp("([^\\s]|\\r\\n|\\n|\\r|".concat(this.escapedDelimiter,")")),this.maxRows>0&&(this.limitRows=!0)};_.ParserOptions=w},{"lodash.escaperegexp":426,"lodash.isnil":431}],152:[function(e,S,_){var u=Object.create?function(s,m,c,a){a===void 0&&(a=c),Object.defineProperty(s,a,{enumerable:!0,get:function(){return m[c]}})}:function(s,m,c,a){a===void 0&&(a=c),s[a]=m[c]},y=Object.create?function(s,m){Object.defineProperty(s,"default",{enumerable:!0,value:m})}:function(s,m){s.default=m},g=function(s){if(s&&s.__esModule)return s;var m={};if(s!=null)for(var c in s)c!=="default"&&Object.hasOwnProperty.call(s,c)&&u(m,s,c);return y(m,s),m},b=function(s,m){for(var c in s)c!=="default"&&!m.hasOwnProperty(c)&&u(m,s,c)};Object.defineProperty(_,"__esModule",{value:!0}),_.parseString=_.parseFile=_.parseStream=_.parse=void 0;var w=g(e("fs")),f=e("stream"),v=e("./ParserOptions"),h=e("./CsvParserStream");b(e("./types"),_);var l=e("./CsvParserStream");Object.defineProperty(_,"CsvParserStream",{enumerable:!0,get:function(){return l.CsvParserStream}});var d=e("./ParserOptions");Object.defineProperty(_,"ParserOptions",{enumerable:!0,get:function(){return d.ParserOptions}}),_.parse=function(s){return new h.CsvParserStream(new v.ParserOptions(s))},_.parseStream=function(s,m){return s.pipe(new h.CsvParserStream(new v.ParserOptions(m)))},_.parseFile=function(s){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return w.createReadStream(s).pipe(new h.CsvParserStream(new v.ParserOptions(m)))},_.parseString=function(s,m){var c=new f.Readable;return c.push(s),c.push(null),c.pipe(new h.CsvParserStream(new v.ParserOptions(m)))}},{"./CsvParserStream":150,"./ParserOptions":151,"./types":166,fs:215,stream:506}],153:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;sthis.cursor}},{key:"nextNonSpaceToken",get:function(){var l=this.lineFromCursor,d=this.parserOptions.NEXT_TOKEN_REGEXP;if(l.search(d)===-1)return null;var s=d.exec(l);if(s==null)return null;var m=s[1],c=this.cursor+(s.index||0);return new b.Token({token:m,startCursor:c,endCursor:c+m.length-1})}},{key:"nextCharacterToken",get:function(){var l=this.cursor,d=this.lineLength;return d<=l?null:new b.Token({token:this.line[l],startCursor:l,endCursor:l})}},{key:"lineFromCursor",get:function(){return this.line.substr(this.cursor)}}]),v}();_.Scanner=f},{"./Token":156}],156:[function(e,S,_){function u(w,f){if(!(w instanceof f))throw new TypeError("Cannot call a class as a function")}function y(w,f){for(var v=0;v1&&arguments[1]!==void 0?arguments[1]:{},r=[],t=new v.Writable({write:function(n,o,p){r.push(n),p()}});return new Promise(function(i,n){t.on("error",n).on("finish",function(){return i(u.concat(r))}),_.write(c,a).pipe(t)})},_.writeToString=function(c,a){return _.writeToBuffer(c,a).then(function(r){return r.toString()})},_.writeToPath=function(c,a,r){var t=h.createWriteStream(c,{encoding:"utf8"});return _.write(a,r).pipe(t)}}).call(this,e("buffer").Buffer)},{"./CsvFormatterStream":143,"./FormatterOptions":144,"./types":149,buffer:216,fs:215,stream:506,util:525}],149:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.isSyncTransform=void 0,_.isSyncTransform=function(u){return u.length===1}},{}],150:[function(e,S,_){(function(u){function y(p){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(P){return typeof P}:y=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},y(p)}function g(p,E){if(!(p instanceof E))throw new TypeError("Cannot call a class as a function")}function b(p,E){for(var P=0;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function a(p){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},a(p)}Object.defineProperty(_,"__esModule",{value:!0}),_.CsvParserStream=void 0;var r=e("string_decoder"),t=e("stream"),i=e("./transforms"),n=e("./parser"),o=function(p){h(P,p);var E=d(P);function P(D){var z;return g(this,P),z=E.call(this,{objectMode:D.objectMode}),z.lines="",z.rowCount=0,z.parsedRowCount=0,z.parsedLineCount=0,z.endEmitted=!1,z.headersEmitted=!1,z.parserOptions=D,z.parser=new n.Parser(D),z.headerTransformer=new i.HeaderTransformer(D),z.decoder=new r.StringDecoder(D.encoding),z.rowTransformerValidator=new i.RowTransformerValidator,z}return w(P,[{key:"transform",value:function(z){return this.rowTransformerValidator.rowTransform=z,this}},{key:"validate",value:function(z){return this.rowTransformerValidator.rowValidator=z,this}},{key:"emit",value:function(z){var B;if(z==="end")return this.endEmitted||(this.endEmitted=!0,f(a(P.prototype),"emit",this).call(this,"end",this.rowCount)),!1;for(var M=arguments.length,I=new Array(M>1?M-1:0),T=1;T=I||M.hasHitRowLimit)return B();if(M.parsedLineCount+=1,M.shouldSkipLine)return A();var L=z[O];M.rowCount+=1,M.parsedRowCount+=1;var U=M.rowCount;return M.transformRow(L,function(W,$){if(W)return M.rowCount-=1,A(W);if(!$)return A(new Error("expected transform result"));if(!$.isValid)M.emit("data-invalid",$.row,U,$.reason);else if($.row)return M.pushRow($.row,A);return A()})};T(0)}},{key:"transformRow",value:function(z,B){var M=this;try{this.headerTransformer.transform(z,function(I,T){return I?B(I):T?T.isValid?T.row?M.shouldEmitRows?M.rowTransformerValidator.transformAndValidate(T.row,B):M.skipRow(B):(M.rowCount-=1,M.parsedRowCount-=1,B(null,{row:null,isValid:!0})):M.shouldEmitRows?B(null,{isValid:!1,row:z}):M.skipRow(B):B(new Error("Expected result from header transform"))})}catch(I){B(I)}}},{key:"checkAndEmitHeaders",value:function(){!this.headersEmitted&&this.headerTransformer.headers&&(this.headersEmitted=!0,this.emit("headers",this.headerTransformer.headers))}},{key:"skipRow",value:function(z){return this.rowCount-=1,z(null,{row:null,isValid:!0})}},{key:"pushRow",value:function(z,B){try{this.parserOptions.objectMode?this.push(z):this.push(JSON.stringify(z)),B()}catch(M){B(M)}}},{key:"hasHitRowLimit",get:function(){return this.parserOptions.limitRows&&this.rowCount>=this.parserOptions.maxRows}},{key:"shouldEmitRows",get:function(){return this.parsedRowCount>this.parserOptions.skipRows}},{key:"shouldSkipLine",get:function(){return this.parsedLineCount<=this.parserOptions.skipLines}}]),P}(t.Transform);_.CsvParserStream=o}).call(this,e("timers").setImmediate)},{"./parser":162,"./transforms":165,stream:506,string_decoder:520,timers:521}],151:[function(e,S,_){function u(f,v){if(!(f instanceof v))throw new TypeError("Cannot call a class as a function")}var y=function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(_,"__esModule",{value:!0}),_.ParserOptions=void 0;var g=y(e("lodash.escaperegexp")),b=y(e("lodash.isnil")),w=function f(v){u(this,f);var h;if(this.objectMode=!0,this.delimiter=",",this.ignoreEmpty=!1,this.quote='"',this.escape=null,this.escapeChar=this.quote,this.comment=null,this.supportsComments=!1,this.ltrim=!1,this.rtrim=!1,this.trim=!1,this.headers=null,this.renameHeaders=!1,this.strictColumnHandling=!1,this.discardUnmappedColumns=!1,this.carriageReturn="\r",this.encoding="utf8",this.limitRows=!1,this.maxRows=0,this.skipLines=0,this.skipRows=0,Object.assign(this,v||{}),this.delimiter.length>1)throw new Error("delimiter option must be one character long");this.escapedDelimiter=g.default(this.delimiter),this.escapeChar=(h=this.escape)!==null&&h!==void 0?h:this.quote,this.supportsComments=!b.default(this.comment),this.NEXT_TOKEN_REGEXP=new RegExp("([^\\s]|\\r\\n|\\n|\\r|".concat(this.escapedDelimiter,")")),this.maxRows>0&&(this.limitRows=!0)};_.ParserOptions=w},{"lodash.escaperegexp":426,"lodash.isnil":431}],152:[function(e,S,_){var u=Object.create?function(s,m,c,a){a===void 0&&(a=c),Object.defineProperty(s,a,{enumerable:!0,get:function(){return m[c]}})}:function(s,m,c,a){a===void 0&&(a=c),s[a]=m[c]},y=Object.create?function(s,m){Object.defineProperty(s,"default",{enumerable:!0,value:m})}:function(s,m){s.default=m},g=function(s){if(s&&s.__esModule)return s;var m={};if(s!=null)for(var c in s)c!=="default"&&Object.hasOwnProperty.call(s,c)&&u(m,s,c);return y(m,s),m},b=function(s,m){for(var c in s)c!=="default"&&!m.hasOwnProperty(c)&&u(m,s,c)};Object.defineProperty(_,"__esModule",{value:!0}),_.parseString=_.parseFile=_.parseStream=_.parse=void 0;var w=g(e("fs")),f=e("stream"),v=e("./ParserOptions"),h=e("./CsvParserStream");b(e("./types"),_);var l=e("./CsvParserStream");Object.defineProperty(_,"CsvParserStream",{enumerable:!0,get:function(){return l.CsvParserStream}});var d=e("./ParserOptions");Object.defineProperty(_,"ParserOptions",{enumerable:!0,get:function(){return d.ParserOptions}}),_.parse=function(s){return new h.CsvParserStream(new v.ParserOptions(s))},_.parseStream=function(s,m){return s.pipe(new h.CsvParserStream(new v.ParserOptions(m)))},_.parseFile=function(s){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return w.createReadStream(s).pipe(new h.CsvParserStream(new v.ParserOptions(m)))},_.parseString=function(s,m){var c=new f.Readable;return c.push(s),c.push(null),c.pipe(new h.CsvParserStream(new v.ParserOptions(m)))}},{"./CsvParserStream":150,"./ParserOptions":151,"./types":166,fs:215,stream:506}],153:[function(e,S,_){function u(l,d){if(!(l instanceof d))throw new TypeError("Cannot call a class as a function")}function y(l,d){for(var s=0;sthis.cursor}},{key:"nextNonSpaceToken",get:function(){var l=this.lineFromCursor,d=this.parserOptions.NEXT_TOKEN_REGEXP;if(l.search(d)===-1)return null;var s=d.exec(l);if(s==null)return null;var m=s[1],c=this.cursor+(s.index||0);return new b.Token({token:m,startCursor:c,endCursor:c+m.length-1})}},{key:"nextCharacterToken",get:function(){var l=this.cursor,d=this.lineLength;return d<=l?null:new b.Token({token:this.line[l],startCursor:l,endCursor:l})}},{key:"lineFromCursor",get:function(){return this.line.substr(this.cursor)}}]),v}();_.Scanner=f},{"./Token":156}],156:[function(e,S,_){function u(w,f){if(!(w instanceof f))throw new TypeError("Cannot call a class as a function")}function y(w,f){for(var v=0;vthis.headersLength){if(!c.strictColumnHandling)throw new Error("Unexpected Error: column header mismatch expected: ".concat(this.headersLength," columns got: ").concat(m.length));return{row:m,isValid:!1,reason:"Column header mismatch expected: ".concat(this.headersLength," columns got: ").concat(m.length)}}return c.strictColumnHandling&&m.length1});throw new Error("Duplicate headers found ".concat(JSON.stringify(t)))}this.headers=m,this.receivedHeaders=!0,this.headersLength=((c=this.headers)===null||c===void 0?void 0:c.length)||0}}]),d}();_.HeaderTransformer=l},{"lodash.groupby":427,"lodash.isfunction":430,"lodash.isundefined":432,"lodash.uniq":433}],164:[function(e,S,_){function u(h,l){if(!(h instanceof l))throw new TypeError("Cannot call a class as a function")}function y(h,l){for(var d=0;d>6],a=(m&32)===0;if((m&31)===31){var r=m;for(m=0;(r&128)===128;){if(r=d.readUInt8(s),d.isError(r))return r;m<<=7,m|=r&127}}else m&=31;var t=w.tag[m];return{cls:c,primitive:a,tag:m,tagStr:t}}function l(d,s,m){var c=d.readUInt8(m);if(d.isError(c))return c;if(!s&&c===128)return null;if(!(c&128))return c;var a=c&127;if(a>4)return d.error("length octect is too long");c=0;for(var r=0;r=256;i>>=8)t++;var n=y.alloc(1+1+t);n[0]=a,n[1]=128|t;for(var o=1+t,p=c.length;p>0;o--,p>>=8)n[o]=p&255;return this._createEncoderBuffer([n,c])},f.prototype._encodeStr=function(d,s){if(s==="bitstr")return this._createEncoderBuffer([d.unused|0,d.data]);if(s==="bmpstr"){for(var m=y.alloc(d.length*2),c=0;c=40)return this.reporter.error("Second objid identifier OOB");d.splice(0,2,d[0]*40+d[1])}for(var r=0,t=0;t=128;i>>=7)r++}for(var n=y.alloc(r),o=n.length-1,p=d.length-1;p>=0;p--){var O=d[p];for(n[o--]=O&127;(O>>=7)>0;)n[o--]=128|O&127}return this._createEncoderBuffer(n)};function v(l){return l<10?"0"+l:l}f.prototype._encodeTime=function(d,s){var m,c=new Date(d);return s==="gentime"?m=[v(c.getUTCFullYear()),v(c.getUTCMonth()+1),v(c.getUTCDate()),v(c.getUTCHours()),v(c.getUTCMinutes()),v(c.getUTCSeconds()),"Z"].join(""):s==="utctime"?m=[v(c.getUTCFullYear()%100),v(c.getUTCMonth()+1),v(c.getUTCDate()),v(c.getUTCHours()),v(c.getUTCMinutes()),v(c.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+s+" time is not supported yet"),this._encodeStr(m,"octstr")},f.prototype._encodeNull=function(){return this._createEncoderBuffer("")},f.prototype._encodeInt=function(d,s){if(typeof d=="string"){if(!s)return this.reporter.error("String int or enum given, but no values map");if(!s.hasOwnProperty(d))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(d));d=s[d]}if(typeof d!="number"&&!y.isBuffer(d)){var m=d.toArray();!d.sign&&m[0]&128&&m.unshift(0),d=y.from(m)}if(y.isBuffer(d)){var c=d.length;d.length===0&&c++;var a=y.alloc(c);return d.copy(a),d.length===0&&(a[0]=0),this._createEncoderBuffer(a)}if(d<128)return this._createEncoderBuffer(d);if(d<256)return this._createEncoderBuffer([0,d]);for(var r=1,t=d;t>=256;t>>=8)r++;for(var i=new Array(r),n=i.length-1;n>=0;n--)i[n]=d&255,d>>=8;return i[0]&128&&i.unshift(0),this._createEncoderBuffer(y.from(i))},f.prototype._encodeBool=function(d){return this._createEncoderBuffer(d?255:0)},f.prototype._use=function(d,s){return typeof d=="function"&&(d=d(s)),d._getEncoder("der").tree},f.prototype._skipDefault=function(d,s,m){var c=this._baseState,a;if(c.default===null)return!1;var r=d.join();if(c.defaultBuffer===void 0&&(c.defaultBuffer=this._encodeValue(c.default,s,m).join()),r.length!==c.defaultBuffer.length)return!1;for(a=0;a=31?m.error("Multi-octet tag encoding unsupported"):(d||(c|=32),c|=b.tagClassByName[s||"universal"]<<6,c)}},{"../base/node":171,"../constants/der":173,inherits:387,"safer-buffer":495}],179:[function(e,S,_){var u=_;u.der=e("./der"),u.pem=e("./pem")},{"./der":178,"./pem":180}],180:[function(e,S,_){var u=e("inherits"),y=e("./der");function g(b){y.call(this,b),this.enc="pem"}u(g,y),S.exports=g,g.prototype.encode=function(w,f){for(var v=y.prototype.encode.call(this,w),h=v.toString("base64"),l=["-----BEGIN "+f.label+"-----"],d=0;d0?T:C},f.min=function(T,C){return T.cmp(C)<0?T:C},f.prototype._init=function(T,C,E){if(typeof T=="number")return this._initNumber(T,C,E);if(u(T)==="object")return this._initArray(T,C,E);C==="hex"&&(C=16),b(C===(C|0)&&C>=2&&C<=36),T=T.toString().replace(/\s+/g,"");var A=0;T[0]==="-"&&A++,C===16?this._parseHex(T,A):this._parseBase(T,C,A),T[0]==="-"&&(this.negative=1),this.strip(),E==="le"&&this._initArray(this.toArray(),C,E)},f.prototype._initNumber=function(T,C,E){T<0&&(this.negative=1,T=-T),T<67108864?(this.words=[T&67108863],this.length=1):T<4503599627370496?(this.words=[T&67108863,T/67108864&67108863],this.length=2):(b(T<9007199254740992),this.words=[T&67108863,T/67108864&67108863,1],this.length=3),E==="le"&&this._initArray(this.toArray(),C,E)},f.prototype._initArray=function(T,C,E){if(b(typeof T.length=="number"),T.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(T.length/3),this.words=new Array(this.length);for(var A=0;A=0;A-=3)$=T[A]|T[A-1]<<8|T[A-2]<<16,this.words[L]|=$<>>26-W&67108863,W+=24,W>=26&&(W-=26,L++);else if(E==="le")for(A=0,L=0;A>>26-W&67108863,W+=24,W>=26&&(W-=26,L++);return this.strip()};function h(I,T,C){for(var E=0,A=Math.min(I.length,C),L=T;L=49&&$<=54?E|=$-49+10:$>=17&&$<=22?E|=$-17+10:E|=$&15}return E}f.prototype._parseHex=function(T,C){this.length=Math.ceil((T.length-C)/6),this.words=new Array(this.length);for(var E=0;E=C;E-=6)L=h(T,E,E+6),this.words[A]|=L<<$&67108863,this.words[A+1]|=L>>>26-$&4194303,$+=24,$>=26&&($-=26,A++);E+6!==C&&(L=h(T,C,E+6),this.words[A]|=L<<$&67108863,this.words[A+1]|=L>>>26-$&4194303),this.strip()};function l(I,T,C,E){for(var A=0,L=Math.min(I.length,C),$=T;$=49?A+=W-49+10:W>=17?A+=W-17+10:A+=W}return A}f.prototype._parseBase=function(T,C,E){this.words=[0],this.length=1;for(var A=0,L=1;L<=67108863;L*=C)A++;A--,L=L/C|0;for(var $=T.length-E,W=$%A,U=Math.min($,$-W)+E,N=0,j=E;j1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.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"],s=[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],m=[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];f.prototype.toString=function(T,C){T=T||10,C=C|0||1;var E;if(T===16||T==="hex"){E="";for(var A=0,L=0,$=0;$>>24-A&16777215,L!==0||$!==this.length-1?E=d[6-U.length]+U+E:E=U+E,A+=2,A>=26&&(A-=26,$--)}for(L!==0&&(E=L.toString(16)+E);E.length%C!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}if(T===(T|0)&&T>=2&&T<=36){var N=s[T],j=m[T];E="";var F=this.clone();for(F.negative=0;!F.isZero();){var V=F.modn(j).toString(T);F=F.idivn(j),F.isZero()?E=V+E:E=d[N-V.length]+V+E}for(this.isZero()&&(E="0"+E);E.length%C!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}b(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var T=this.words[0];return this.length===2?T+=this.words[1]*67108864:this.length===3&&this.words[2]===1?T+=4503599627370496+this.words[1]*67108864:this.length>2&&b(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-T:T},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(T,C){return b(typeof v<"u"),this.toArrayLike(v,T,C)},f.prototype.toArray=function(T,C){return this.toArrayLike(Array,T,C)},f.prototype.toArrayLike=function(T,C,E){var A=this.byteLength(),L=E||Math.max(1,A);b(A<=L,"byte array longer than desired length"),b(L>0,"Requested array length <= 0"),this.strip();var $=C==="le",W=new T(L),U,N,j=this.clone();if($){for(N=0;!j.isZero();N++)U=j.andln(255),j.iushrn(8),W[N]=U;for(;N=4096&&(E+=13,C>>>=13),C>=64&&(E+=7,C>>>=7),C>=8&&(E+=4,C>>>=4),C>=2&&(E+=2,C>>>=2),E+C},f.prototype._zeroBits=function(T){if(T===0)return 26;var C=T,E=0;return C&8191||(E+=13,C>>>=13),C&127||(E+=7,C>>>=7),C&15||(E+=4,C>>>=4),C&3||(E+=2,C>>>=2),C&1||E++,E},f.prototype.bitLength=function(){var T=this.words[this.length-1],C=this._countBits(T);return(this.length-1)*26+C};function c(I){for(var T=new Array(I.bitLength()),C=0;C>>A}return T}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var T=0,C=0;CT.length?this.clone().ior(T):T.clone().ior(this)},f.prototype.uor=function(T){return this.length>T.length?this.clone().iuor(T):T.clone().iuor(this)},f.prototype.iuand=function(T){var C;this.length>T.length?C=T:C=this;for(var E=0;ET.length?this.clone().iand(T):T.clone().iand(this)},f.prototype.uand=function(T){return this.length>T.length?this.clone().iuand(T):T.clone().iuand(this)},f.prototype.iuxor=function(T){var C,E;this.length>T.length?(C=this,E=T):(C=T,E=this);for(var A=0;AT.length?this.clone().ixor(T):T.clone().ixor(this)},f.prototype.uxor=function(T){return this.length>T.length?this.clone().iuxor(T):T.clone().iuxor(this)},f.prototype.inotn=function(T){b(typeof T=="number"&&T>=0);var C=Math.ceil(T/26)|0,E=T%26;this._expand(C),E>0&&C--;for(var A=0;A0&&(this.words[A]=~this.words[A]&67108863>>26-E),this.strip()},f.prototype.notn=function(T){return this.clone().inotn(T)},f.prototype.setn=function(T,C){b(typeof T=="number"&&T>=0);var E=T/26|0,A=T%26;return this._expand(E+1),C?this.words[E]=this.words[E]|1<T.length?(E=this,A=T):(E=T,A=this);for(var L=0,$=0;$>>26;for(;L!==0&&$>>26;if(this.length=E.length,L!==0)this.words[this.length]=L,this.length++;else if(E!==this)for(;$T.length?this.clone().iadd(T):T.clone().iadd(this)},f.prototype.isub=function(T){if(T.negative!==0){T.negative=0;var C=this.iadd(T);return T.negative=1,C._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(T),this.negative=1,this._normSign();var E=this.cmp(T);if(E===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,L;E>0?(A=this,L=T):(A=T,L=this);for(var $=0,W=0;W>26,this.words[W]=C&67108863;for(;$!==0&&W>26,this.words[W]=C&67108863;if($===0&&W>>26,F=U&67108863,V=Math.min(N,T.length-1),re=Math.max(0,N-I.length+1);re<=V;re++){var ee=N-re|0;A=I.words[ee]|0,L=T.words[re]|0,$=A*L+F,j+=$/67108864|0,F=$&67108863}C.words[N]=F|0,U=j|0}return U!==0?C.words[N]=U|0:C.length--,C.strip()}var r=function(T,C,E){var A=T.words,L=C.words,$=E.words,W=0,U,N,j,F=A[0]|0,V=F&8191,re=F>>>13,ee=A[1]|0,ce=ee&8191,ye=ee>>>13,ge=A[2]|0,oe=ge&8191,J=ge>>>13,Q=A[3]|0,he=Q&8191,xe=Q>>>13,ne=A[4]|0,se=ne&8191,Ce=ne>>>13,q=A[5]|0,G=q&8191,Y=q>>>13,fe=A[6]|0,we=fe&8191,_e=fe>>>13,je=A[7]|0,Ye=je&8191,nt=je>>>13,ut=A[8]|0,ot=ut&8191,Ue=ut>>>13,Ve=A[9]|0,Qe=Ve&8191,tt=Ve>>>13,ae=L[0]|0,Re=ae&8191,be=ae>>>13,Ee=L[1]|0,pe=Ee&8191,Pe=Ee>>>13,te=L[2]|0,He=te&8191,it=te>>>13,K=L[3]|0,Me=K&8191,Le=K>>>13,ue=L[4]|0,ke=ue&8191,Ie=ue>>>13,st=L[5]|0,Ge=st&8191,rt=st>>>13,_t=L[6]|0,wt=_t&8191,Ot=_t>>>13,pt=L[7]|0,ct=pt&8191,At=pt>>>13,Pt=L[8]|0,bt=Pt&8191,Kt=Pt>>>13,Ct=L[9]|0,St=Ct&8191,Bt=Ct>>>13;E.negative=T.negative^C.negative,E.length=19,U=Math.imul(V,Re),N=Math.imul(V,be),N=N+Math.imul(re,Re)|0,j=Math.imul(re,be);var Lt=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,U=Math.imul(ce,Re),N=Math.imul(ce,be),N=N+Math.imul(ye,Re)|0,j=Math.imul(ye,be),U=U+Math.imul(V,pe)|0,N=N+Math.imul(V,Pe)|0,N=N+Math.imul(re,pe)|0,j=j+Math.imul(re,Pe)|0;var Et=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Et>>>26)|0,Et&=67108863,U=Math.imul(oe,Re),N=Math.imul(oe,be),N=N+Math.imul(J,Re)|0,j=Math.imul(J,be),U=U+Math.imul(ce,pe)|0,N=N+Math.imul(ce,Pe)|0,N=N+Math.imul(ye,pe)|0,j=j+Math.imul(ye,Pe)|0,U=U+Math.imul(V,He)|0,N=N+Math.imul(V,it)|0,N=N+Math.imul(re,He)|0,j=j+Math.imul(re,it)|0;var Nr=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,U=Math.imul(he,Re),N=Math.imul(he,be),N=N+Math.imul(xe,Re)|0,j=Math.imul(xe,be),U=U+Math.imul(oe,pe)|0,N=N+Math.imul(oe,Pe)|0,N=N+Math.imul(J,pe)|0,j=j+Math.imul(J,Pe)|0,U=U+Math.imul(ce,He)|0,N=N+Math.imul(ce,it)|0,N=N+Math.imul(ye,He)|0,j=j+Math.imul(ye,it)|0,U=U+Math.imul(V,Me)|0,N=N+Math.imul(V,Le)|0,N=N+Math.imul(re,Me)|0,j=j+Math.imul(re,Le)|0;var Or=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Or>>>26)|0,Or&=67108863,U=Math.imul(se,Re),N=Math.imul(se,be),N=N+Math.imul(Ce,Re)|0,j=Math.imul(Ce,be),U=U+Math.imul(he,pe)|0,N=N+Math.imul(he,Pe)|0,N=N+Math.imul(xe,pe)|0,j=j+Math.imul(xe,Pe)|0,U=U+Math.imul(oe,He)|0,N=N+Math.imul(oe,it)|0,N=N+Math.imul(J,He)|0,j=j+Math.imul(J,it)|0,U=U+Math.imul(ce,Me)|0,N=N+Math.imul(ce,Le)|0,N=N+Math.imul(ye,Me)|0,j=j+Math.imul(ye,Le)|0,U=U+Math.imul(V,ke)|0,N=N+Math.imul(V,Ie)|0,N=N+Math.imul(re,ke)|0,j=j+Math.imul(re,Ie)|0;var Gr=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,U=Math.imul(G,Re),N=Math.imul(G,be),N=N+Math.imul(Y,Re)|0,j=Math.imul(Y,be),U=U+Math.imul(se,pe)|0,N=N+Math.imul(se,Pe)|0,N=N+Math.imul(Ce,pe)|0,j=j+Math.imul(Ce,Pe)|0,U=U+Math.imul(he,He)|0,N=N+Math.imul(he,it)|0,N=N+Math.imul(xe,He)|0,j=j+Math.imul(xe,it)|0,U=U+Math.imul(oe,Me)|0,N=N+Math.imul(oe,Le)|0,N=N+Math.imul(J,Me)|0,j=j+Math.imul(J,Le)|0,U=U+Math.imul(ce,ke)|0,N=N+Math.imul(ce,Ie)|0,N=N+Math.imul(ye,ke)|0,j=j+Math.imul(ye,Ie)|0,U=U+Math.imul(V,Ge)|0,N=N+Math.imul(V,rt)|0,N=N+Math.imul(re,Ge)|0,j=j+Math.imul(re,rt)|0;var Dr=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,U=Math.imul(we,Re),N=Math.imul(we,be),N=N+Math.imul(_e,Re)|0,j=Math.imul(_e,be),U=U+Math.imul(G,pe)|0,N=N+Math.imul(G,Pe)|0,N=N+Math.imul(Y,pe)|0,j=j+Math.imul(Y,Pe)|0,U=U+Math.imul(se,He)|0,N=N+Math.imul(se,it)|0,N=N+Math.imul(Ce,He)|0,j=j+Math.imul(Ce,it)|0,U=U+Math.imul(he,Me)|0,N=N+Math.imul(he,Le)|0,N=N+Math.imul(xe,Me)|0,j=j+Math.imul(xe,Le)|0,U=U+Math.imul(oe,ke)|0,N=N+Math.imul(oe,Ie)|0,N=N+Math.imul(J,ke)|0,j=j+Math.imul(J,Ie)|0,U=U+Math.imul(ce,Ge)|0,N=N+Math.imul(ce,rt)|0,N=N+Math.imul(ye,Ge)|0,j=j+Math.imul(ye,rt)|0,U=U+Math.imul(V,wt)|0,N=N+Math.imul(V,Ot)|0,N=N+Math.imul(re,wt)|0,j=j+Math.imul(re,Ot)|0;var Yr=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,U=Math.imul(Ye,Re),N=Math.imul(Ye,be),N=N+Math.imul(nt,Re)|0,j=Math.imul(nt,be),U=U+Math.imul(we,pe)|0,N=N+Math.imul(we,Pe)|0,N=N+Math.imul(_e,pe)|0,j=j+Math.imul(_e,Pe)|0,U=U+Math.imul(G,He)|0,N=N+Math.imul(G,it)|0,N=N+Math.imul(Y,He)|0,j=j+Math.imul(Y,it)|0,U=U+Math.imul(se,Me)|0,N=N+Math.imul(se,Le)|0,N=N+Math.imul(Ce,Me)|0,j=j+Math.imul(Ce,Le)|0,U=U+Math.imul(he,ke)|0,N=N+Math.imul(he,Ie)|0,N=N+Math.imul(xe,ke)|0,j=j+Math.imul(xe,Ie)|0,U=U+Math.imul(oe,Ge)|0,N=N+Math.imul(oe,rt)|0,N=N+Math.imul(J,Ge)|0,j=j+Math.imul(J,rt)|0,U=U+Math.imul(ce,wt)|0,N=N+Math.imul(ce,Ot)|0,N=N+Math.imul(ye,wt)|0,j=j+Math.imul(ye,Ot)|0,U=U+Math.imul(V,ct)|0,N=N+Math.imul(V,At)|0,N=N+Math.imul(re,ct)|0,j=j+Math.imul(re,At)|0;var Qt=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,U=Math.imul(ot,Re),N=Math.imul(ot,be),N=N+Math.imul(Ue,Re)|0,j=Math.imul(Ue,be),U=U+Math.imul(Ye,pe)|0,N=N+Math.imul(Ye,Pe)|0,N=N+Math.imul(nt,pe)|0,j=j+Math.imul(nt,Pe)|0,U=U+Math.imul(we,He)|0,N=N+Math.imul(we,it)|0,N=N+Math.imul(_e,He)|0,j=j+Math.imul(_e,it)|0,U=U+Math.imul(G,Me)|0,N=N+Math.imul(G,Le)|0,N=N+Math.imul(Y,Me)|0,j=j+Math.imul(Y,Le)|0,U=U+Math.imul(se,ke)|0,N=N+Math.imul(se,Ie)|0,N=N+Math.imul(Ce,ke)|0,j=j+Math.imul(Ce,Ie)|0,U=U+Math.imul(he,Ge)|0,N=N+Math.imul(he,rt)|0,N=N+Math.imul(xe,Ge)|0,j=j+Math.imul(xe,rt)|0,U=U+Math.imul(oe,wt)|0,N=N+Math.imul(oe,Ot)|0,N=N+Math.imul(J,wt)|0,j=j+Math.imul(J,Ot)|0,U=U+Math.imul(ce,ct)|0,N=N+Math.imul(ce,At)|0,N=N+Math.imul(ye,ct)|0,j=j+Math.imul(ye,At)|0,U=U+Math.imul(V,bt)|0,N=N+Math.imul(V,Kt)|0,N=N+Math.imul(re,bt)|0,j=j+Math.imul(re,Kt)|0;var Xr=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,U=Math.imul(Qe,Re),N=Math.imul(Qe,be),N=N+Math.imul(tt,Re)|0,j=Math.imul(tt,be),U=U+Math.imul(ot,pe)|0,N=N+Math.imul(ot,Pe)|0,N=N+Math.imul(Ue,pe)|0,j=j+Math.imul(Ue,Pe)|0,U=U+Math.imul(Ye,He)|0,N=N+Math.imul(Ye,it)|0,N=N+Math.imul(nt,He)|0,j=j+Math.imul(nt,it)|0,U=U+Math.imul(we,Me)|0,N=N+Math.imul(we,Le)|0,N=N+Math.imul(_e,Me)|0,j=j+Math.imul(_e,Le)|0,U=U+Math.imul(G,ke)|0,N=N+Math.imul(G,Ie)|0,N=N+Math.imul(Y,ke)|0,j=j+Math.imul(Y,Ie)|0,U=U+Math.imul(se,Ge)|0,N=N+Math.imul(se,rt)|0,N=N+Math.imul(Ce,Ge)|0,j=j+Math.imul(Ce,rt)|0,U=U+Math.imul(he,wt)|0,N=N+Math.imul(he,Ot)|0,N=N+Math.imul(xe,wt)|0,j=j+Math.imul(xe,Ot)|0,U=U+Math.imul(oe,ct)|0,N=N+Math.imul(oe,At)|0,N=N+Math.imul(J,ct)|0,j=j+Math.imul(J,At)|0,U=U+Math.imul(ce,bt)|0,N=N+Math.imul(ce,Kt)|0,N=N+Math.imul(ye,bt)|0,j=j+Math.imul(ye,Kt)|0,U=U+Math.imul(V,St)|0,N=N+Math.imul(V,Bt)|0,N=N+Math.imul(re,St)|0,j=j+Math.imul(re,Bt)|0;var Br=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Br>>>26)|0,Br&=67108863,U=Math.imul(Qe,pe),N=Math.imul(Qe,Pe),N=N+Math.imul(tt,pe)|0,j=Math.imul(tt,Pe),U=U+Math.imul(ot,He)|0,N=N+Math.imul(ot,it)|0,N=N+Math.imul(Ue,He)|0,j=j+Math.imul(Ue,it)|0,U=U+Math.imul(Ye,Me)|0,N=N+Math.imul(Ye,Le)|0,N=N+Math.imul(nt,Me)|0,j=j+Math.imul(nt,Le)|0,U=U+Math.imul(we,ke)|0,N=N+Math.imul(we,Ie)|0,N=N+Math.imul(_e,ke)|0,j=j+Math.imul(_e,Ie)|0,U=U+Math.imul(G,Ge)|0,N=N+Math.imul(G,rt)|0,N=N+Math.imul(Y,Ge)|0,j=j+Math.imul(Y,rt)|0,U=U+Math.imul(se,wt)|0,N=N+Math.imul(se,Ot)|0,N=N+Math.imul(Ce,wt)|0,j=j+Math.imul(Ce,Ot)|0,U=U+Math.imul(he,ct)|0,N=N+Math.imul(he,At)|0,N=N+Math.imul(xe,ct)|0,j=j+Math.imul(xe,At)|0,U=U+Math.imul(oe,bt)|0,N=N+Math.imul(oe,Kt)|0,N=N+Math.imul(J,bt)|0,j=j+Math.imul(J,Kt)|0,U=U+Math.imul(ce,St)|0,N=N+Math.imul(ce,Bt)|0,N=N+Math.imul(ye,St)|0,j=j+Math.imul(ye,Bt)|0;var Lr=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Lr>>>26)|0,Lr&=67108863,U=Math.imul(Qe,He),N=Math.imul(Qe,it),N=N+Math.imul(tt,He)|0,j=Math.imul(tt,it),U=U+Math.imul(ot,Me)|0,N=N+Math.imul(ot,Le)|0,N=N+Math.imul(Ue,Me)|0,j=j+Math.imul(Ue,Le)|0,U=U+Math.imul(Ye,ke)|0,N=N+Math.imul(Ye,Ie)|0,N=N+Math.imul(nt,ke)|0,j=j+Math.imul(nt,Ie)|0,U=U+Math.imul(we,Ge)|0,N=N+Math.imul(we,rt)|0,N=N+Math.imul(_e,Ge)|0,j=j+Math.imul(_e,rt)|0,U=U+Math.imul(G,wt)|0,N=N+Math.imul(G,Ot)|0,N=N+Math.imul(Y,wt)|0,j=j+Math.imul(Y,Ot)|0,U=U+Math.imul(se,ct)|0,N=N+Math.imul(se,At)|0,N=N+Math.imul(Ce,ct)|0,j=j+Math.imul(Ce,At)|0,U=U+Math.imul(he,bt)|0,N=N+Math.imul(he,Kt)|0,N=N+Math.imul(xe,bt)|0,j=j+Math.imul(xe,Kt)|0,U=U+Math.imul(oe,St)|0,N=N+Math.imul(oe,Bt)|0,N=N+Math.imul(J,St)|0,j=j+Math.imul(J,Bt)|0;var Ur=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,U=Math.imul(Qe,Me),N=Math.imul(Qe,Le),N=N+Math.imul(tt,Me)|0,j=Math.imul(tt,Le),U=U+Math.imul(ot,ke)|0,N=N+Math.imul(ot,Ie)|0,N=N+Math.imul(Ue,ke)|0,j=j+Math.imul(Ue,Ie)|0,U=U+Math.imul(Ye,Ge)|0,N=N+Math.imul(Ye,rt)|0,N=N+Math.imul(nt,Ge)|0,j=j+Math.imul(nt,rt)|0,U=U+Math.imul(we,wt)|0,N=N+Math.imul(we,Ot)|0,N=N+Math.imul(_e,wt)|0,j=j+Math.imul(_e,Ot)|0,U=U+Math.imul(G,ct)|0,N=N+Math.imul(G,At)|0,N=N+Math.imul(Y,ct)|0,j=j+Math.imul(Y,At)|0,U=U+Math.imul(se,bt)|0,N=N+Math.imul(se,Kt)|0,N=N+Math.imul(Ce,bt)|0,j=j+Math.imul(Ce,Kt)|0,U=U+Math.imul(he,St)|0,N=N+Math.imul(he,Bt)|0,N=N+Math.imul(xe,St)|0,j=j+Math.imul(xe,Bt)|0;var yt=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(yt>>>26)|0,yt&=67108863,U=Math.imul(Qe,ke),N=Math.imul(Qe,Ie),N=N+Math.imul(tt,ke)|0,j=Math.imul(tt,Ie),U=U+Math.imul(ot,Ge)|0,N=N+Math.imul(ot,rt)|0,N=N+Math.imul(Ue,Ge)|0,j=j+Math.imul(Ue,rt)|0,U=U+Math.imul(Ye,wt)|0,N=N+Math.imul(Ye,Ot)|0,N=N+Math.imul(nt,wt)|0,j=j+Math.imul(nt,Ot)|0,U=U+Math.imul(we,ct)|0,N=N+Math.imul(we,At)|0,N=N+Math.imul(_e,ct)|0,j=j+Math.imul(_e,At)|0,U=U+Math.imul(G,bt)|0,N=N+Math.imul(G,Kt)|0,N=N+Math.imul(Y,bt)|0,j=j+Math.imul(Y,Kt)|0,U=U+Math.imul(se,St)|0,N=N+Math.imul(se,Bt)|0,N=N+Math.imul(Ce,St)|0,j=j+Math.imul(Ce,Bt)|0;var Ke=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,U=Math.imul(Qe,Ge),N=Math.imul(Qe,rt),N=N+Math.imul(tt,Ge)|0,j=Math.imul(tt,rt),U=U+Math.imul(ot,wt)|0,N=N+Math.imul(ot,Ot)|0,N=N+Math.imul(Ue,wt)|0,j=j+Math.imul(Ue,Ot)|0,U=U+Math.imul(Ye,ct)|0,N=N+Math.imul(Ye,At)|0,N=N+Math.imul(nt,ct)|0,j=j+Math.imul(nt,At)|0,U=U+Math.imul(we,bt)|0,N=N+Math.imul(we,Kt)|0,N=N+Math.imul(_e,bt)|0,j=j+Math.imul(_e,Kt)|0,U=U+Math.imul(G,St)|0,N=N+Math.imul(G,Bt)|0,N=N+Math.imul(Y,St)|0,j=j+Math.imul(Y,Bt)|0;var me=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(me>>>26)|0,me&=67108863,U=Math.imul(Qe,wt),N=Math.imul(Qe,Ot),N=N+Math.imul(tt,wt)|0,j=Math.imul(tt,Ot),U=U+Math.imul(ot,ct)|0,N=N+Math.imul(ot,At)|0,N=N+Math.imul(Ue,ct)|0,j=j+Math.imul(Ue,At)|0,U=U+Math.imul(Ye,bt)|0,N=N+Math.imul(Ye,Kt)|0,N=N+Math.imul(nt,bt)|0,j=j+Math.imul(nt,Kt)|0,U=U+Math.imul(we,St)|0,N=N+Math.imul(we,Bt)|0,N=N+Math.imul(_e,St)|0,j=j+Math.imul(_e,Bt)|0;var Be=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Be>>>26)|0,Be&=67108863,U=Math.imul(Qe,ct),N=Math.imul(Qe,At),N=N+Math.imul(tt,ct)|0,j=Math.imul(tt,At),U=U+Math.imul(ot,bt)|0,N=N+Math.imul(ot,Kt)|0,N=N+Math.imul(Ue,bt)|0,j=j+Math.imul(Ue,Kt)|0,U=U+Math.imul(Ye,St)|0,N=N+Math.imul(Ye,Bt)|0,N=N+Math.imul(nt,St)|0,j=j+Math.imul(nt,Bt)|0;var Fe=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,U=Math.imul(Qe,bt),N=Math.imul(Qe,Kt),N=N+Math.imul(tt,bt)|0,j=Math.imul(tt,Kt),U=U+Math.imul(ot,St)|0,N=N+Math.imul(ot,Bt)|0,N=N+Math.imul(Ue,St)|0,j=j+Math.imul(Ue,Bt)|0;var dt=(W+U|0)+((N&8191)<<13)|0;W=(j+(N>>>13)|0)+(dt>>>26)|0,dt&=67108863,U=Math.imul(Qe,St),N=Math.imul(Qe,Bt),N=N+Math.imul(tt,St)|0,j=Math.imul(tt,Bt);var kt=(W+U|0)+((N&8191)<<13)|0;return W=(j+(N>>>13)|0)+(kt>>>26)|0,kt&=67108863,$[0]=Lt,$[1]=Et,$[2]=Nr,$[3]=Or,$[4]=Gr,$[5]=Dr,$[6]=Yr,$[7]=Qt,$[8]=Xr,$[9]=Br,$[10]=Lr,$[11]=Ur,$[12]=yt,$[13]=Ke,$[14]=me,$[15]=Be,$[16]=Fe,$[17]=dt,$[18]=kt,W!==0&&($[19]=W,E.length++),E};Math.imul||(r=a);function t(I,T,C){C.negative=T.negative^I.negative,C.length=I.length+T.length;for(var E=0,A=0,L=0;L>>26)|0,A+=$>>>26,$&=67108863}C.words[L]=W,E=$,$=A}return E!==0?C.words[L]=E:C.length--,C.strip()}function i(I,T,C){var E=new n;return E.mulp(I,T,C)}f.prototype.mulTo=function(T,C){var E,A=this.length+T.length;return this.length===10&&T.length===10?E=r(this,T,C):A<63?E=a(this,T,C):A<1024?E=t(this,T,C):E=i(this,T,C),E};function n(I,T){this.x=I,this.y=T}n.prototype.makeRBT=function(T){for(var C=new Array(T),E=f.prototype._countBits(T)-1,A=0;A>=1;return A},n.prototype.permute=function(T,C,E,A,L,$){for(var W=0;W<$;W++)A[W]=C[T[W]],L[W]=E[T[W]]},n.prototype.transform=function(T,C,E,A,L,$){this.permute($,T,C,E,A,L);for(var W=1;W>>1)L++;return 1<>>13,E[2*$+1]=L&8191,L=L>>>13;for($=2*C;$>=26,C+=A/67108864|0,C+=L>>>26,this.words[E]=L&67108863}return C!==0&&(this.words[E]=C,this.length++),this},f.prototype.muln=function(T){return this.clone().imuln(T)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(T){var C=c(T);if(C.length===0)return new f(1);for(var E=this,A=0;A=0);var C=T%26,E=(T-C)/26,A=67108863>>>26-C<<26-C,L;if(C!==0){var $=0;for(L=0;L>>26-C}$&&(this.words[L]=$,this.length++)}if(E!==0){for(L=this.length-1;L>=0;L--)this.words[L+E]=this.words[L];for(L=0;L=0);var A;C?A=(C-C%26)/26:A=0;var L=T%26,$=Math.min((T-L)/26,this.length),W=67108863^67108863>>>L<$)for(this.length-=$,N=0;N=0&&(j!==0||N>=A);N--){var F=this.words[N]|0;this.words[N]=j<<26-L|F>>>L,j=F&W}return U&&j!==0&&(U.words[U.length++]=j),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(T,C,E){return b(this.negative===0),this.iushrn(T,C,E)},f.prototype.shln=function(T){return this.clone().ishln(T)},f.prototype.ushln=function(T){return this.clone().iushln(T)},f.prototype.shrn=function(T){return this.clone().ishrn(T)},f.prototype.ushrn=function(T){return this.clone().iushrn(T)},f.prototype.testn=function(T){b(typeof T=="number"&&T>=0);var C=T%26,E=(T-C)/26,A=1<=0);var C=T%26,E=(T-C)/26;if(b(this.negative===0,"imaskn works only with positive numbers"),this.length<=E)return this;if(C!==0&&E++,this.length=Math.min(E,this.length),C!==0){var A=67108863^67108863>>>C<=67108864;C++)this.words[C]-=67108864,C===this.length-1?this.words[C+1]=1:this.words[C+1]++;return this.length=Math.max(this.length,C+1),this},f.prototype.isubn=function(T){if(b(typeof T=="number"),b(T<67108864),T<0)return this.iaddn(-T);if(this.negative!==0)return this.negative=0,this.iaddn(T),this.negative=1,this;if(this.words[0]-=T,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var C=0;C>26)-(U/67108864|0),this.words[L+E]=$&67108863}for(;L>26,this.words[L+E]=$&67108863;if(W===0)return this.strip();for(b(W===-1),W=0,L=0;L>26,this.words[L]=$&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(T,C){var E=this.length-T.length,A=this.clone(),L=T,$=L.words[L.length-1]|0,W=this._countBits($);E=26-W,E!==0&&(L=L.ushln(E),A.iushln(E),$=L.words[L.length-1]|0);var U=A.length-L.length,N;if(C!=="mod"){N=new f(null),N.length=U+1,N.words=new Array(N.length);for(var j=0;j=0;V--){var re=(A.words[L.length+V]|0)*67108864+(A.words[L.length+V-1]|0);for(re=Math.min(re/$|0,67108863),A._ishlnsubmul(L,re,V);A.negative!==0;)re--,A.negative=0,A._ishlnsubmul(L,1,V),A.isZero()||(A.negative^=1);N&&(N.words[V]=re)}return N&&N.strip(),A.strip(),C!=="div"&&E!==0&&A.iushrn(E),{div:N||null,mod:A}},f.prototype.divmod=function(T,C,E){if(b(!T.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var A,L,$;return this.negative!==0&&T.negative===0?($=this.neg().divmod(T,C),C!=="mod"&&(A=$.div.neg()),C!=="div"&&(L=$.mod.neg(),E&&L.negative!==0&&L.iadd(T)),{div:A,mod:L}):this.negative===0&&T.negative!==0?($=this.divmod(T.neg(),C),C!=="mod"&&(A=$.div.neg()),{div:A,mod:$.mod}):this.negative&T.negative?($=this.neg().divmod(T.neg(),C),C!=="div"&&(L=$.mod.neg(),E&&L.negative!==0&&L.isub(T)),{div:$.div,mod:L}):T.length>this.length||this.cmp(T)<0?{div:new f(0),mod:this}:T.length===1?C==="div"?{div:this.divn(T.words[0]),mod:null}:C==="mod"?{div:null,mod:new f(this.modn(T.words[0]))}:{div:this.divn(T.words[0]),mod:new f(this.modn(T.words[0]))}:this._wordDiv(T,C)},f.prototype.div=function(T){return this.divmod(T,"div",!1).div},f.prototype.mod=function(T){return this.divmod(T,"mod",!1).mod},f.prototype.umod=function(T){return this.divmod(T,"mod",!0).mod},f.prototype.divRound=function(T){var C=this.divmod(T);if(C.mod.isZero())return C.div;var E=C.div.negative!==0?C.mod.isub(T):C.mod,A=T.ushrn(1),L=T.andln(1),$=E.cmp(A);return $<0||L===1&&$===0?C.div:C.div.negative!==0?C.div.isubn(1):C.div.iaddn(1)},f.prototype.modn=function(T){b(T<=67108863);for(var C=(1<<26)%T,E=0,A=this.length-1;A>=0;A--)E=(C*E+(this.words[A]|0))%T;return E},f.prototype.idivn=function(T){b(T<=67108863);for(var C=0,E=this.length-1;E>=0;E--){var A=(this.words[E]|0)+C*67108864;this.words[E]=A/T|0,C=A%T}return this.strip()},f.prototype.divn=function(T){return this.clone().idivn(T)},f.prototype.egcd=function(T){b(T.negative===0),b(!T.isZero());var C=this,E=T.clone();C.negative!==0?C=C.umod(T):C=C.clone();for(var A=new f(1),L=new f(0),$=new f(0),W=new f(1),U=0;C.isEven()&&E.isEven();)C.iushrn(1),E.iushrn(1),++U;for(var N=E.clone(),j=C.clone();!C.isZero();){for(var F=0,V=1;!(C.words[0]&V)&&F<26;++F,V<<=1);if(F>0)for(C.iushrn(F);F-- >0;)(A.isOdd()||L.isOdd())&&(A.iadd(N),L.isub(j)),A.iushrn(1),L.iushrn(1);for(var re=0,ee=1;!(E.words[0]&ee)&&re<26;++re,ee<<=1);if(re>0)for(E.iushrn(re);re-- >0;)($.isOdd()||W.isOdd())&&($.iadd(N),W.isub(j)),$.iushrn(1),W.iushrn(1);C.cmp(E)>=0?(C.isub(E),A.isub($),L.isub(W)):(E.isub(C),$.isub(A),W.isub(L))}return{a:$,b:W,gcd:E.iushln(U)}},f.prototype._invmp=function(T){b(T.negative===0),b(!T.isZero());var C=this,E=T.clone();C.negative!==0?C=C.umod(T):C=C.clone();for(var A=new f(1),L=new f(0),$=E.clone();C.cmpn(1)>0&&E.cmpn(1)>0;){for(var W=0,U=1;!(C.words[0]&U)&&W<26;++W,U<<=1);if(W>0)for(C.iushrn(W);W-- >0;)A.isOdd()&&A.iadd($),A.iushrn(1);for(var N=0,j=1;!(E.words[0]&j)&&N<26;++N,j<<=1);if(N>0)for(E.iushrn(N);N-- >0;)L.isOdd()&&L.iadd($),L.iushrn(1);C.cmp(E)>=0?(C.isub(E),A.isub(L)):(E.isub(C),L.isub(A))}var F;return C.cmpn(1)===0?F=A:F=L,F.cmpn(0)<0&&F.iadd(T),F},f.prototype.gcd=function(T){if(this.isZero())return T.abs();if(T.isZero())return this.abs();var C=this.clone(),E=T.clone();C.negative=0,E.negative=0;for(var A=0;C.isEven()&&E.isEven();A++)C.iushrn(1),E.iushrn(1);do{for(;C.isEven();)C.iushrn(1);for(;E.isEven();)E.iushrn(1);var L=C.cmp(E);if(L<0){var $=C;C=E,E=$}else if(L===0||E.cmpn(1)===0)break;C.isub(E)}while(!0);return E.iushln(A)},f.prototype.invm=function(T){return this.egcd(T).a.umod(T)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(T){return this.words[0]&T},f.prototype.bincn=function(T){b(typeof T=="number");var C=T%26,E=(T-C)/26,A=1<>>26,W&=67108863,this.words[$]=W}return L!==0&&(this.words[$]=L,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(T){var C=T<0;if(this.negative!==0&&!C)return-1;if(this.negative===0&&C)return 1;this.strip();var E;if(this.length>1)E=1;else{C&&(T=-T),b(T<=67108863,"Number is too big");var A=this.words[0]|0;E=A===T?0:AT.length)return 1;if(this.length=0;E--){var A=this.words[E]|0,L=T.words[E]|0;if(A!==L){AL&&(C=1);break}}return C},f.prototype.gtn=function(T){return this.cmpn(T)===1},f.prototype.gt=function(T){return this.cmp(T)===1},f.prototype.gten=function(T){return this.cmpn(T)>=0},f.prototype.gte=function(T){return this.cmp(T)>=0},f.prototype.ltn=function(T){return this.cmpn(T)===-1},f.prototype.lt=function(T){return this.cmp(T)===-1},f.prototype.lten=function(T){return this.cmpn(T)<=0},f.prototype.lte=function(T){return this.cmp(T)<=0},f.prototype.eqn=function(T){return this.cmpn(T)===0},f.prototype.eq=function(T){return this.cmp(T)===0},f.red=function(T){return new D(T)},f.prototype.toRed=function(T){return b(!this.red,"Already a number in reduction context"),b(this.negative===0,"red works only with positives"),T.convertTo(this)._forceRed(T)},f.prototype.fromRed=function(){return b(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(T){return this.red=T,this},f.prototype.forceRed=function(T){return b(!this.red,"Already a number in reduction context"),this._forceRed(T)},f.prototype.redAdd=function(T){return b(this.red,"redAdd works only with red numbers"),this.red.add(this,T)},f.prototype.redIAdd=function(T){return b(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,T)},f.prototype.redSub=function(T){return b(this.red,"redSub works only with red numbers"),this.red.sub(this,T)},f.prototype.redISub=function(T){return b(this.red,"redISub works only with red numbers"),this.red.isub(this,T)},f.prototype.redShl=function(T){return b(this.red,"redShl works only with red numbers"),this.red.shl(this,T)},f.prototype.redMul=function(T){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.mul(this,T)},f.prototype.redIMul=function(T){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.imul(this,T)},f.prototype.redSqr=function(){return b(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return b(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return b(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return b(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return b(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(T){return b(this.red&&!T.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,T)};var o={k256:null,p224:null,p192:null,p25519:null};function p(I,T){this.name=I,this.p=new f(T,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}p.prototype._tmp=function(){var T=new f(null);return T.words=new Array(Math.ceil(this.n/13)),T},p.prototype.ireduce=function(T){var C=T,E;do this.split(C,this.tmp),C=this.imulK(C),C=C.iadd(this.tmp),E=C.bitLength();while(E>this.n);var A=E0?C.isub(this.p):C.strip!==void 0?C.strip():C._strip(),C},p.prototype.split=function(T,C){T.iushrn(this.n,0,C)},p.prototype.imulK=function(T){return T.imul(this.k)};function O(){p.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}w(O,p),O.prototype.split=function(T,C){for(var E=4194303,A=Math.min(T.length,9),L=0;L>>22,$=W}$>>>=22,T.words[L-10]=$,$===0&&T.length>10?T.length-=10:T.length-=9},O.prototype.imulK=function(T){T.words[T.length]=0,T.words[T.length+1]=0,T.length+=2;for(var C=0,E=0;E>>=26,T.words[E]=L,C=A}return C!==0&&(T.words[T.length++]=C),T},f._prime=function(T){if(o[T])return o[T];var C;if(T==="k256")C=new O;else if(T==="p224")C=new P;else if(T==="p192")C=new B;else if(T==="p25519")C=new z;else throw new Error("Unknown prime "+T);return o[T]=C,C};function D(I){if(typeof I=="string"){var T=f._prime(I);this.m=T.p,this.prime=T}else b(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}D.prototype._verify1=function(T){b(T.negative===0,"red works only with positives"),b(T.red,"red works only with red numbers")},D.prototype._verify2=function(T,C){b((T.negative|C.negative)===0,"red works only with positives"),b(T.red&&T.red===C.red,"red works only with red numbers")},D.prototype.imod=function(T){return this.prime?this.prime.ireduce(T)._forceRed(this):T.umod(this.m)._forceRed(this)},D.prototype.neg=function(T){return T.isZero()?T.clone():this.m.sub(T)._forceRed(this)},D.prototype.add=function(T,C){this._verify2(T,C);var E=T.add(C);return E.cmp(this.m)>=0&&E.isub(this.m),E._forceRed(this)},D.prototype.iadd=function(T,C){this._verify2(T,C);var E=T.iadd(C);return E.cmp(this.m)>=0&&E.isub(this.m),E},D.prototype.sub=function(T,C){this._verify2(T,C);var E=T.sub(C);return E.cmpn(0)<0&&E.iadd(this.m),E._forceRed(this)},D.prototype.isub=function(T,C){this._verify2(T,C);var E=T.isub(C);return E.cmpn(0)<0&&E.iadd(this.m),E},D.prototype.shl=function(T,C){return this._verify1(T),this.imod(T.ushln(C))},D.prototype.imul=function(T,C){return this._verify2(T,C),this.imod(T.imul(C))},D.prototype.mul=function(T,C){return this._verify2(T,C),this.imod(T.mul(C))},D.prototype.isqr=function(T){return this.imul(T,T.clone())},D.prototype.sqr=function(T){return this.mul(T,T)},D.prototype.sqrt=function(T){if(T.isZero())return T.clone();var C=this.m.andln(3);if(b(C%2===1),C===3){var E=this.m.add(new f(1)).iushrn(2);return this.pow(T,E)}for(var A=this.m.subn(1),L=0;!A.isZero()&&A.andln(1)===0;)L++,A.iushrn(1);b(!A.isZero());var $=new f(1).toRed(this),W=$.redNeg(),U=this.m.subn(1).iushrn(1),N=this.m.bitLength();for(N=new f(2*N*N).toRed(this);this.pow(N,U).cmp(W)!==0;)N.redIAdd(W);for(var j=this.pow(N,A),F=this.pow(T,A.addn(1).iushrn(1)),V=this.pow(T,A),re=L;V.cmp($)!==0;){for(var ee=V,ce=0;ee.cmp($)!==0;ce++)ee=ee.redSqr();b(ce=0;L--){for(var j=C.words[L],F=N-1;F>=0;F--){var V=j>>F&1;if($!==A[0]&&($=this.sqr($)),V===0&&W===0){U=0;continue}W<<=1,W|=V,U++,!(U!==E&&(L!==0||F!==0))&&($=this.mul($,A[W]),U=0,W=0)}N=26}return $},D.prototype.convertTo=function(T){var C=T.umod(this.m);return C===T?C.clone():C},D.prototype.convertFrom=function(T){var C=T.clone();return C.red=null,C},f.mont=function(T){return new M(T)};function M(I){D.call(this,I),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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(M,D),M.prototype.convertTo=function(T){return this.imod(T.ushln(this.shift))},M.prototype.convertFrom=function(T){var C=this.imod(T.mul(this.rinv));return C.red=null,C},M.prototype.imul=function(T,C){if(T.isZero()||C.isZero())return T.words[0]=0,T.length=1,T;var E=T.imul(C),A=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),L=E.isub(A).iushrn(this.shift),$=L;return L.cmp(this.m)>=0?$=L.isub(this.m):L.cmpn(0)<0&&($=L.iadd(this.m)),$._forceRed(this)},M.prototype.mul=function(T,C){if(T.isZero()||C.isZero())return new f(0)._forceRed(this);var E=T.mul(C),A=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),L=E.isub(A).iushrn(this.shift),$=L;return L.cmp(this.m)>=0?$=L.isub(this.m):L.cmpn(0)<0&&($=L.iadd(this.m)),$._forceRed(this)},M.prototype.invm=function(T){var C=this.imod(T._invmp(this.m).mul(this.r2));return C._forceRed(this)}})(typeof S>"u"||S,void 0)},{buffer:185}],182:[function(e,S,_){_.byteLength=h,_.toByteArray=d,_.fromByteArray=c;for(var u=[],y=[],g=typeof Uint8Array<"u"?Uint8Array:Array,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0,f=b.length;w0)throw new Error("Invalid string. Length must be a multiple of 4");var t=a.indexOf("=");t===-1&&(t=r);var i=t===r?0:4-t%4;return[t,i]}function h(a){var r=v(a),t=r[0],i=r[1];return(t+i)*3/4-i}function l(a,r,t){return(r+t)*3/4-t}function d(a){var r,t=v(a),i=t[0],n=t[1],o=new g(l(a,i,n)),p=0,O=n>0?i-4:i,P;for(P=0;P>16&255,o[p++]=r>>8&255,o[p++]=r&255;return n===2&&(r=y[a.charCodeAt(P)]<<2|y[a.charCodeAt(P+1)]>>4,o[p++]=r&255),n===1&&(r=y[a.charCodeAt(P)]<<10|y[a.charCodeAt(P+1)]<<4|y[a.charCodeAt(P+2)]>>2,o[p++]=r>>8&255,o[p++]=r&255),o}function s(a){return u[a>>18&63]+u[a>>12&63]+u[a>>6&63]+u[a&63]}function m(a,r,t){for(var i,n=[],o=r;oO?O:p+o));return i===1?(r=a[t-1],n.push(u[r>>2]+u[r<<4&63]+"==")):i===2&&(r=(a[t-2]<<8)+a[t-1],n.push(u[r>>10]+u[r>>4&63]+u[r<<2&63]+"=")),n.join("")}},{}],183:[function(e,S,_){function u(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(b){return typeof b}:u=function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},u(y)}(function(y,g){function b(C,E){if(!C)throw new Error(E||"Assertion failed")}function w(C,E){C.super_=E;var A=function(){};A.prototype=E.prototype,C.prototype=new A,C.prototype.constructor=C}function f(C,E,A){if(f.isBN(C))return C;this.negative=0,this.words=null,this.length=0,this.red=null,C!==null&&((E==="le"||E==="be")&&(A=E,E=10),this._init(C||0,E||10,A||"be"))}u(y)==="object"?y.exports=f:g.BN=f,f.BN=f,f.wordSize=26;var v;try{v=e("buffer").Buffer}catch{}f.isBN=function(E){return E instanceof f?!0:E!==null&&u(E)==="object"&&E.constructor.wordSize===f.wordSize&&Array.isArray(E.words)},f.max=function(E,A){return E.cmp(A)>0?E:A},f.min=function(E,A){return E.cmp(A)<0?E:A},f.prototype._init=function(E,A,L){if(typeof E=="number")return this._initNumber(E,A,L);if(u(E)==="object")return this._initArray(E,A,L);A==="hex"&&(A=16),b(A===(A|0)&&A>=2&&A<=36),E=E.toString().replace(/\s+/g,"");var $=0;E[0]==="-"&&$++,A===16?this._parseHex(E,$):this._parseBase(E,A,$),E[0]==="-"&&(this.negative=1),this._strip(),L==="le"&&this._initArray(this.toArray(),A,L)},f.prototype._initNumber=function(E,A,L){E<0&&(this.negative=1,E=-E),E<67108864?(this.words=[E&67108863],this.length=1):E<4503599627370496?(this.words=[E&67108863,E/67108864&67108863],this.length=2):(b(E<9007199254740992),this.words=[E&67108863,E/67108864&67108863,1],this.length=3),L==="le"&&this._initArray(this.toArray(),A,L)},f.prototype._initArray=function(E,A,L){if(b(typeof E.length=="number"),E.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(E.length/3),this.words=new Array(this.length);for(var $=0;$=0;$-=3)U=E[$]|E[$-1]<<8|E[$-2]<<16,this.words[W]|=U<>>26-N&67108863,N+=24,N>=26&&(N-=26,W++);else if(L==="le")for($=0,W=0;$>>26-N&67108863,N+=24,N>=26&&(N-=26,W++);return this._strip()};function h(C,E,A){for(var L=0,$=Math.min(C.length,A),W=0,U=E;U<$;U++){var N=C.charCodeAt(U)-48;L<<=4;var j;N>=49&&N<=54?j=N-49+10:N>=17&&N<=22?j=N-17+10:j=N,L|=j,W|=j}return b(!(W&240),"Invalid character in "+C),L}f.prototype._parseHex=function(E,A){this.length=Math.ceil((E.length-A)/6),this.words=new Array(this.length);for(var L=0;L=A;L-=6)W=h(E,L,L+6),this.words[$]|=W<>>26-U&4194303,U+=24,U>=26&&(U-=26,$++);L+6!==A&&(W=h(E,A,L+6),this.words[$]|=W<>>26-U&4194303),this._strip()};function l(C,E,A,L){for(var $=0,W=0,U=Math.min(C.length,A),N=E;N=49?W=j-49+10:j>=17?W=j-17+10:W=j,b(j>=0&&W1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{f.prototype[Symbol.for("nodejs.util.inspect.custom")]=s}catch{f.prototype.inspect=s}else f.prototype.inspect=s;function s(){return(this.red?""}var m=["","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"],c=[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],a=[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];f.prototype.toString=function(E,A){E=E||10,A=A|0||1;var L;if(E===16||E==="hex"){L="";for(var $=0,W=0,U=0;U>>24-$&16777215,W!==0||U!==this.length-1?L=m[6-j.length]+j+L:L=j+L,$+=2,$>=26&&($-=26,U--)}for(W!==0&&(L=W.toString(16)+L);L.length%A!==0;)L="0"+L;return this.negative!==0&&(L="-"+L),L}if(E===(E|0)&&E>=2&&E<=36){var F=c[E],V=a[E];L="";var re=this.clone();for(re.negative=0;!re.isZero();){var ee=re.modrn(V).toString(E);re=re.idivn(V),re.isZero()?L=ee+L:L=m[F-ee.length]+ee+L}for(this.isZero()&&(L="0"+L);L.length%A!==0;)L="0"+L;return this.negative!==0&&(L="-"+L),L}b(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var E=this.words[0];return this.length===2?E+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E+=4503599627370496+this.words[1]*67108864:this.length>2&&b(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E:E},f.prototype.toJSON=function(){return this.toString(16,2)},v&&(f.prototype.toBuffer=function(E,A){return this.toArrayLike(v,E,A)}),f.prototype.toArray=function(E,A){return this.toArrayLike(Array,E,A)};var r=function(E,A){return E.allocUnsafe?E.allocUnsafe(A):new E(A)};f.prototype.toArrayLike=function(E,A,L){this._strip();var $=this.byteLength(),W=L||Math.max(1,$);b($<=W,"byte array longer than desired length"),b(W>0,"Requested array length <= 0");var U=r(E,W),N=A==="le"?"LE":"BE";return this["_toArrayLike"+N](U,$),U},f.prototype._toArrayLikeLE=function(E,A){for(var L=0,$=0,W=0,U=0;W>8&255),L>16&255),U===6?(L>24&255),$=0,U=0):($=N>>>24,U+=2)}if(L=0&&(E[L--]=N>>8&255),L>=0&&(E[L--]=N>>16&255),U===6?(L>=0&&(E[L--]=N>>24&255),$=0,U=0):($=N>>>24,U+=2)}if(L>=0)for(E[L--]=$;L>=0;)E[L--]=0},Math.clz32?f.prototype._countBits=function(E){return 32-Math.clz32(E)}:f.prototype._countBits=function(E){var A=E,L=0;return A>=4096&&(L+=13,A>>>=13),A>=64&&(L+=7,A>>>=7),A>=8&&(L+=4,A>>>=4),A>=2&&(L+=2,A>>>=2),L+A},f.prototype._zeroBits=function(E){if(E===0)return 26;var A=E,L=0;return A&8191||(L+=13,A>>>=13),A&127||(L+=7,A>>>=7),A&15||(L+=4,A>>>=4),A&3||(L+=2,A>>>=2),A&1||L++,L},f.prototype.bitLength=function(){var E=this.words[this.length-1],A=this._countBits(E);return(this.length-1)*26+A};function t(C){for(var E=new Array(C.bitLength()),A=0;A>>$&1}return E}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E=0,A=0;AE.length?this.clone().ior(E):E.clone().ior(this)},f.prototype.uor=function(E){return this.length>E.length?this.clone().iuor(E):E.clone().iuor(this)},f.prototype.iuand=function(E){var A;this.length>E.length?A=E:A=this;for(var L=0;LE.length?this.clone().iand(E):E.clone().iand(this)},f.prototype.uand=function(E){return this.length>E.length?this.clone().iuand(E):E.clone().iuand(this)},f.prototype.iuxor=function(E){var A,L;this.length>E.length?(A=this,L=E):(A=E,L=this);for(var $=0;$E.length?this.clone().ixor(E):E.clone().ixor(this)},f.prototype.uxor=function(E){return this.length>E.length?this.clone().iuxor(E):E.clone().iuxor(this)},f.prototype.inotn=function(E){b(typeof E=="number"&&E>=0);var A=Math.ceil(E/26)|0,L=E%26;this._expand(A),L>0&&A--;for(var $=0;$0&&(this.words[$]=~this.words[$]&67108863>>26-L),this._strip()},f.prototype.notn=function(E){return this.clone().inotn(E)},f.prototype.setn=function(E,A){b(typeof E=="number"&&E>=0);var L=E/26|0,$=E%26;return this._expand(L+1),A?this.words[L]=this.words[L]|1<<$:this.words[L]=this.words[L]&~(1<<$),this._strip()},f.prototype.iadd=function(E){var A;if(this.negative!==0&&E.negative===0)return this.negative=0,A=this.isub(E),this.negative^=1,this._normSign();if(this.negative===0&&E.negative!==0)return E.negative=0,A=this.isub(E),E.negative=1,A._normSign();var L,$;this.length>E.length?(L=this,$=E):(L=E,$=this);for(var W=0,U=0;U<$.length;U++)A=(L.words[U]|0)+($.words[U]|0)+W,this.words[U]=A&67108863,W=A>>>26;for(;W!==0&&U>>26;if(this.length=L.length,W!==0)this.words[this.length]=W,this.length++;else if(L!==this)for(;UE.length?this.clone().iadd(E):E.clone().iadd(this)},f.prototype.isub=function(E){if(E.negative!==0){E.negative=0;var A=this.iadd(E);return E.negative=1,A._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E),this.negative=1,this._normSign();var L=this.cmp(E);if(L===0)return this.negative=0,this.length=1,this.words[0]=0,this;var $,W;L>0?($=this,W=E):($=E,W=this);for(var U=0,N=0;N>26,this.words[N]=A&67108863;for(;U!==0&&N<$.length;N++)A=($.words[N]|0)+U,U=A>>26,this.words[N]=A&67108863;if(U===0&&N<$.length&&$!==this)for(;N<$.length;N++)this.words[N]=$.words[N];return this.length=Math.max(this.length,N),$!==this&&(this.negative=1),this._strip()},f.prototype.sub=function(E){return this.clone().isub(E)};function i(C,E,A){A.negative=E.negative^C.negative;var L=C.length+E.length|0;A.length=L,L=L-1|0;var $=C.words[0]|0,W=E.words[0]|0,U=$*W,N=U&67108863,j=U/67108864|0;A.words[0]=N;for(var F=1;F>>26,re=j&67108863,ee=Math.min(F,E.length-1),ce=Math.max(0,F-C.length+1);ce<=ee;ce++){var ye=F-ce|0;$=C.words[ye]|0,W=E.words[ce]|0,U=$*W+re,V+=U/67108864|0,re=U&67108863}A.words[F]=re|0,j=V|0}return j!==0?A.words[F]=j|0:A.length--,A._strip()}var n=function(E,A,L){var $=E.words,W=A.words,U=L.words,N=0,j,F,V,re=$[0]|0,ee=re&8191,ce=re>>>13,ye=$[1]|0,ge=ye&8191,oe=ye>>>13,J=$[2]|0,Q=J&8191,he=J>>>13,xe=$[3]|0,ne=xe&8191,se=xe>>>13,Ce=$[4]|0,q=Ce&8191,G=Ce>>>13,Y=$[5]|0,fe=Y&8191,we=Y>>>13,_e=$[6]|0,je=_e&8191,Ye=_e>>>13,nt=$[7]|0,ut=nt&8191,ot=nt>>>13,Ue=$[8]|0,Ve=Ue&8191,Qe=Ue>>>13,tt=$[9]|0,ae=tt&8191,Re=tt>>>13,be=W[0]|0,Ee=be&8191,pe=be>>>13,Pe=W[1]|0,te=Pe&8191,He=Pe>>>13,it=W[2]|0,K=it&8191,Me=it>>>13,Le=W[3]|0,ue=Le&8191,ke=Le>>>13,Ie=W[4]|0,st=Ie&8191,Ge=Ie>>>13,rt=W[5]|0,_t=rt&8191,wt=rt>>>13,Ot=W[6]|0,pt=Ot&8191,ct=Ot>>>13,At=W[7]|0,Pt=At&8191,bt=At>>>13,Kt=W[8]|0,Ct=Kt&8191,St=Kt>>>13,Bt=W[9]|0,Lt=Bt&8191,Et=Bt>>>13;L.negative=E.negative^A.negative,L.length=19,j=Math.imul(ee,Ee),F=Math.imul(ee,pe),F=F+Math.imul(ce,Ee)|0,V=Math.imul(ce,pe);var Nr=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,j=Math.imul(ge,Ee),F=Math.imul(ge,pe),F=F+Math.imul(oe,Ee)|0,V=Math.imul(oe,pe),j=j+Math.imul(ee,te)|0,F=F+Math.imul(ee,He)|0,F=F+Math.imul(ce,te)|0,V=V+Math.imul(ce,He)|0;var Or=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Or>>>26)|0,Or&=67108863,j=Math.imul(Q,Ee),F=Math.imul(Q,pe),F=F+Math.imul(he,Ee)|0,V=Math.imul(he,pe),j=j+Math.imul(ge,te)|0,F=F+Math.imul(ge,He)|0,F=F+Math.imul(oe,te)|0,V=V+Math.imul(oe,He)|0,j=j+Math.imul(ee,K)|0,F=F+Math.imul(ee,Me)|0,F=F+Math.imul(ce,K)|0,V=V+Math.imul(ce,Me)|0;var Gr=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,j=Math.imul(ne,Ee),F=Math.imul(ne,pe),F=F+Math.imul(se,Ee)|0,V=Math.imul(se,pe),j=j+Math.imul(Q,te)|0,F=F+Math.imul(Q,He)|0,F=F+Math.imul(he,te)|0,V=V+Math.imul(he,He)|0,j=j+Math.imul(ge,K)|0,F=F+Math.imul(ge,Me)|0,F=F+Math.imul(oe,K)|0,V=V+Math.imul(oe,Me)|0,j=j+Math.imul(ee,ue)|0,F=F+Math.imul(ee,ke)|0,F=F+Math.imul(ce,ue)|0,V=V+Math.imul(ce,ke)|0;var Dr=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,j=Math.imul(q,Ee),F=Math.imul(q,pe),F=F+Math.imul(G,Ee)|0,V=Math.imul(G,pe),j=j+Math.imul(ne,te)|0,F=F+Math.imul(ne,He)|0,F=F+Math.imul(se,te)|0,V=V+Math.imul(se,He)|0,j=j+Math.imul(Q,K)|0,F=F+Math.imul(Q,Me)|0,F=F+Math.imul(he,K)|0,V=V+Math.imul(he,Me)|0,j=j+Math.imul(ge,ue)|0,F=F+Math.imul(ge,ke)|0,F=F+Math.imul(oe,ue)|0,V=V+Math.imul(oe,ke)|0,j=j+Math.imul(ee,st)|0,F=F+Math.imul(ee,Ge)|0,F=F+Math.imul(ce,st)|0,V=V+Math.imul(ce,Ge)|0;var Yr=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,j=Math.imul(fe,Ee),F=Math.imul(fe,pe),F=F+Math.imul(we,Ee)|0,V=Math.imul(we,pe),j=j+Math.imul(q,te)|0,F=F+Math.imul(q,He)|0,F=F+Math.imul(G,te)|0,V=V+Math.imul(G,He)|0,j=j+Math.imul(ne,K)|0,F=F+Math.imul(ne,Me)|0,F=F+Math.imul(se,K)|0,V=V+Math.imul(se,Me)|0,j=j+Math.imul(Q,ue)|0,F=F+Math.imul(Q,ke)|0,F=F+Math.imul(he,ue)|0,V=V+Math.imul(he,ke)|0,j=j+Math.imul(ge,st)|0,F=F+Math.imul(ge,Ge)|0,F=F+Math.imul(oe,st)|0,V=V+Math.imul(oe,Ge)|0,j=j+Math.imul(ee,_t)|0,F=F+Math.imul(ee,wt)|0,F=F+Math.imul(ce,_t)|0,V=V+Math.imul(ce,wt)|0;var Qt=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,j=Math.imul(je,Ee),F=Math.imul(je,pe),F=F+Math.imul(Ye,Ee)|0,V=Math.imul(Ye,pe),j=j+Math.imul(fe,te)|0,F=F+Math.imul(fe,He)|0,F=F+Math.imul(we,te)|0,V=V+Math.imul(we,He)|0,j=j+Math.imul(q,K)|0,F=F+Math.imul(q,Me)|0,F=F+Math.imul(G,K)|0,V=V+Math.imul(G,Me)|0,j=j+Math.imul(ne,ue)|0,F=F+Math.imul(ne,ke)|0,F=F+Math.imul(se,ue)|0,V=V+Math.imul(se,ke)|0,j=j+Math.imul(Q,st)|0,F=F+Math.imul(Q,Ge)|0,F=F+Math.imul(he,st)|0,V=V+Math.imul(he,Ge)|0,j=j+Math.imul(ge,_t)|0,F=F+Math.imul(ge,wt)|0,F=F+Math.imul(oe,_t)|0,V=V+Math.imul(oe,wt)|0,j=j+Math.imul(ee,pt)|0,F=F+Math.imul(ee,ct)|0,F=F+Math.imul(ce,pt)|0,V=V+Math.imul(ce,ct)|0;var Xr=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,j=Math.imul(ut,Ee),F=Math.imul(ut,pe),F=F+Math.imul(ot,Ee)|0,V=Math.imul(ot,pe),j=j+Math.imul(je,te)|0,F=F+Math.imul(je,He)|0,F=F+Math.imul(Ye,te)|0,V=V+Math.imul(Ye,He)|0,j=j+Math.imul(fe,K)|0,F=F+Math.imul(fe,Me)|0,F=F+Math.imul(we,K)|0,V=V+Math.imul(we,Me)|0,j=j+Math.imul(q,ue)|0,F=F+Math.imul(q,ke)|0,F=F+Math.imul(G,ue)|0,V=V+Math.imul(G,ke)|0,j=j+Math.imul(ne,st)|0,F=F+Math.imul(ne,Ge)|0,F=F+Math.imul(se,st)|0,V=V+Math.imul(se,Ge)|0,j=j+Math.imul(Q,_t)|0,F=F+Math.imul(Q,wt)|0,F=F+Math.imul(he,_t)|0,V=V+Math.imul(he,wt)|0,j=j+Math.imul(ge,pt)|0,F=F+Math.imul(ge,ct)|0,F=F+Math.imul(oe,pt)|0,V=V+Math.imul(oe,ct)|0,j=j+Math.imul(ee,Pt)|0,F=F+Math.imul(ee,bt)|0,F=F+Math.imul(ce,Pt)|0,V=V+Math.imul(ce,bt)|0;var Br=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Br>>>26)|0,Br&=67108863,j=Math.imul(Ve,Ee),F=Math.imul(Ve,pe),F=F+Math.imul(Qe,Ee)|0,V=Math.imul(Qe,pe),j=j+Math.imul(ut,te)|0,F=F+Math.imul(ut,He)|0,F=F+Math.imul(ot,te)|0,V=V+Math.imul(ot,He)|0,j=j+Math.imul(je,K)|0,F=F+Math.imul(je,Me)|0,F=F+Math.imul(Ye,K)|0,V=V+Math.imul(Ye,Me)|0,j=j+Math.imul(fe,ue)|0,F=F+Math.imul(fe,ke)|0,F=F+Math.imul(we,ue)|0,V=V+Math.imul(we,ke)|0,j=j+Math.imul(q,st)|0,F=F+Math.imul(q,Ge)|0,F=F+Math.imul(G,st)|0,V=V+Math.imul(G,Ge)|0,j=j+Math.imul(ne,_t)|0,F=F+Math.imul(ne,wt)|0,F=F+Math.imul(se,_t)|0,V=V+Math.imul(se,wt)|0,j=j+Math.imul(Q,pt)|0,F=F+Math.imul(Q,ct)|0,F=F+Math.imul(he,pt)|0,V=V+Math.imul(he,ct)|0,j=j+Math.imul(ge,Pt)|0,F=F+Math.imul(ge,bt)|0,F=F+Math.imul(oe,Pt)|0,V=V+Math.imul(oe,bt)|0,j=j+Math.imul(ee,Ct)|0,F=F+Math.imul(ee,St)|0,F=F+Math.imul(ce,Ct)|0,V=V+Math.imul(ce,St)|0;var Lr=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Lr>>>26)|0,Lr&=67108863,j=Math.imul(ae,Ee),F=Math.imul(ae,pe),F=F+Math.imul(Re,Ee)|0,V=Math.imul(Re,pe),j=j+Math.imul(Ve,te)|0,F=F+Math.imul(Ve,He)|0,F=F+Math.imul(Qe,te)|0,V=V+Math.imul(Qe,He)|0,j=j+Math.imul(ut,K)|0,F=F+Math.imul(ut,Me)|0,F=F+Math.imul(ot,K)|0,V=V+Math.imul(ot,Me)|0,j=j+Math.imul(je,ue)|0,F=F+Math.imul(je,ke)|0,F=F+Math.imul(Ye,ue)|0,V=V+Math.imul(Ye,ke)|0,j=j+Math.imul(fe,st)|0,F=F+Math.imul(fe,Ge)|0,F=F+Math.imul(we,st)|0,V=V+Math.imul(we,Ge)|0,j=j+Math.imul(q,_t)|0,F=F+Math.imul(q,wt)|0,F=F+Math.imul(G,_t)|0,V=V+Math.imul(G,wt)|0,j=j+Math.imul(ne,pt)|0,F=F+Math.imul(ne,ct)|0,F=F+Math.imul(se,pt)|0,V=V+Math.imul(se,ct)|0,j=j+Math.imul(Q,Pt)|0,F=F+Math.imul(Q,bt)|0,F=F+Math.imul(he,Pt)|0,V=V+Math.imul(he,bt)|0,j=j+Math.imul(ge,Ct)|0,F=F+Math.imul(ge,St)|0,F=F+Math.imul(oe,Ct)|0,V=V+Math.imul(oe,St)|0,j=j+Math.imul(ee,Lt)|0,F=F+Math.imul(ee,Et)|0,F=F+Math.imul(ce,Lt)|0,V=V+Math.imul(ce,Et)|0;var Ur=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,j=Math.imul(ae,te),F=Math.imul(ae,He),F=F+Math.imul(Re,te)|0,V=Math.imul(Re,He),j=j+Math.imul(Ve,K)|0,F=F+Math.imul(Ve,Me)|0,F=F+Math.imul(Qe,K)|0,V=V+Math.imul(Qe,Me)|0,j=j+Math.imul(ut,ue)|0,F=F+Math.imul(ut,ke)|0,F=F+Math.imul(ot,ue)|0,V=V+Math.imul(ot,ke)|0,j=j+Math.imul(je,st)|0,F=F+Math.imul(je,Ge)|0,F=F+Math.imul(Ye,st)|0,V=V+Math.imul(Ye,Ge)|0,j=j+Math.imul(fe,_t)|0,F=F+Math.imul(fe,wt)|0,F=F+Math.imul(we,_t)|0,V=V+Math.imul(we,wt)|0,j=j+Math.imul(q,pt)|0,F=F+Math.imul(q,ct)|0,F=F+Math.imul(G,pt)|0,V=V+Math.imul(G,ct)|0,j=j+Math.imul(ne,Pt)|0,F=F+Math.imul(ne,bt)|0,F=F+Math.imul(se,Pt)|0,V=V+Math.imul(se,bt)|0,j=j+Math.imul(Q,Ct)|0,F=F+Math.imul(Q,St)|0,F=F+Math.imul(he,Ct)|0,V=V+Math.imul(he,St)|0,j=j+Math.imul(ge,Lt)|0,F=F+Math.imul(ge,Et)|0,F=F+Math.imul(oe,Lt)|0,V=V+Math.imul(oe,Et)|0;var yt=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(yt>>>26)|0,yt&=67108863,j=Math.imul(ae,K),F=Math.imul(ae,Me),F=F+Math.imul(Re,K)|0,V=Math.imul(Re,Me),j=j+Math.imul(Ve,ue)|0,F=F+Math.imul(Ve,ke)|0,F=F+Math.imul(Qe,ue)|0,V=V+Math.imul(Qe,ke)|0,j=j+Math.imul(ut,st)|0,F=F+Math.imul(ut,Ge)|0,F=F+Math.imul(ot,st)|0,V=V+Math.imul(ot,Ge)|0,j=j+Math.imul(je,_t)|0,F=F+Math.imul(je,wt)|0,F=F+Math.imul(Ye,_t)|0,V=V+Math.imul(Ye,wt)|0,j=j+Math.imul(fe,pt)|0,F=F+Math.imul(fe,ct)|0,F=F+Math.imul(we,pt)|0,V=V+Math.imul(we,ct)|0,j=j+Math.imul(q,Pt)|0,F=F+Math.imul(q,bt)|0,F=F+Math.imul(G,Pt)|0,V=V+Math.imul(G,bt)|0,j=j+Math.imul(ne,Ct)|0,F=F+Math.imul(ne,St)|0,F=F+Math.imul(se,Ct)|0,V=V+Math.imul(se,St)|0,j=j+Math.imul(Q,Lt)|0,F=F+Math.imul(Q,Et)|0,F=F+Math.imul(he,Lt)|0,V=V+Math.imul(he,Et)|0;var Ke=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,j=Math.imul(ae,ue),F=Math.imul(ae,ke),F=F+Math.imul(Re,ue)|0,V=Math.imul(Re,ke),j=j+Math.imul(Ve,st)|0,F=F+Math.imul(Ve,Ge)|0,F=F+Math.imul(Qe,st)|0,V=V+Math.imul(Qe,Ge)|0,j=j+Math.imul(ut,_t)|0,F=F+Math.imul(ut,wt)|0,F=F+Math.imul(ot,_t)|0,V=V+Math.imul(ot,wt)|0,j=j+Math.imul(je,pt)|0,F=F+Math.imul(je,ct)|0,F=F+Math.imul(Ye,pt)|0,V=V+Math.imul(Ye,ct)|0,j=j+Math.imul(fe,Pt)|0,F=F+Math.imul(fe,bt)|0,F=F+Math.imul(we,Pt)|0,V=V+Math.imul(we,bt)|0,j=j+Math.imul(q,Ct)|0,F=F+Math.imul(q,St)|0,F=F+Math.imul(G,Ct)|0,V=V+Math.imul(G,St)|0,j=j+Math.imul(ne,Lt)|0,F=F+Math.imul(ne,Et)|0,F=F+Math.imul(se,Lt)|0,V=V+Math.imul(se,Et)|0;var me=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(me>>>26)|0,me&=67108863,j=Math.imul(ae,st),F=Math.imul(ae,Ge),F=F+Math.imul(Re,st)|0,V=Math.imul(Re,Ge),j=j+Math.imul(Ve,_t)|0,F=F+Math.imul(Ve,wt)|0,F=F+Math.imul(Qe,_t)|0,V=V+Math.imul(Qe,wt)|0,j=j+Math.imul(ut,pt)|0,F=F+Math.imul(ut,ct)|0,F=F+Math.imul(ot,pt)|0,V=V+Math.imul(ot,ct)|0,j=j+Math.imul(je,Pt)|0,F=F+Math.imul(je,bt)|0,F=F+Math.imul(Ye,Pt)|0,V=V+Math.imul(Ye,bt)|0,j=j+Math.imul(fe,Ct)|0,F=F+Math.imul(fe,St)|0,F=F+Math.imul(we,Ct)|0,V=V+Math.imul(we,St)|0,j=j+Math.imul(q,Lt)|0,F=F+Math.imul(q,Et)|0,F=F+Math.imul(G,Lt)|0,V=V+Math.imul(G,Et)|0;var Be=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Be>>>26)|0,Be&=67108863,j=Math.imul(ae,_t),F=Math.imul(ae,wt),F=F+Math.imul(Re,_t)|0,V=Math.imul(Re,wt),j=j+Math.imul(Ve,pt)|0,F=F+Math.imul(Ve,ct)|0,F=F+Math.imul(Qe,pt)|0,V=V+Math.imul(Qe,ct)|0,j=j+Math.imul(ut,Pt)|0,F=F+Math.imul(ut,bt)|0,F=F+Math.imul(ot,Pt)|0,V=V+Math.imul(ot,bt)|0,j=j+Math.imul(je,Ct)|0,F=F+Math.imul(je,St)|0,F=F+Math.imul(Ye,Ct)|0,V=V+Math.imul(Ye,St)|0,j=j+Math.imul(fe,Lt)|0,F=F+Math.imul(fe,Et)|0,F=F+Math.imul(we,Lt)|0,V=V+Math.imul(we,Et)|0;var Fe=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,j=Math.imul(ae,pt),F=Math.imul(ae,ct),F=F+Math.imul(Re,pt)|0,V=Math.imul(Re,ct),j=j+Math.imul(Ve,Pt)|0,F=F+Math.imul(Ve,bt)|0,F=F+Math.imul(Qe,Pt)|0,V=V+Math.imul(Qe,bt)|0,j=j+Math.imul(ut,Ct)|0,F=F+Math.imul(ut,St)|0,F=F+Math.imul(ot,Ct)|0,V=V+Math.imul(ot,St)|0,j=j+Math.imul(je,Lt)|0,F=F+Math.imul(je,Et)|0,F=F+Math.imul(Ye,Lt)|0,V=V+Math.imul(Ye,Et)|0;var dt=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(dt>>>26)|0,dt&=67108863,j=Math.imul(ae,Pt),F=Math.imul(ae,bt),F=F+Math.imul(Re,Pt)|0,V=Math.imul(Re,bt),j=j+Math.imul(Ve,Ct)|0,F=F+Math.imul(Ve,St)|0,F=F+Math.imul(Qe,Ct)|0,V=V+Math.imul(Qe,St)|0,j=j+Math.imul(ut,Lt)|0,F=F+Math.imul(ut,Et)|0,F=F+Math.imul(ot,Lt)|0,V=V+Math.imul(ot,Et)|0;var kt=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(kt>>>26)|0,kt&=67108863,j=Math.imul(ae,Ct),F=Math.imul(ae,St),F=F+Math.imul(Re,Ct)|0,V=Math.imul(Re,St),j=j+Math.imul(Ve,Lt)|0,F=F+Math.imul(Ve,Et)|0,F=F+Math.imul(Qe,Lt)|0,V=V+Math.imul(Qe,Et)|0;var Ht=(N+j|0)+((F&8191)<<13)|0;N=(V+(F>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,j=Math.imul(ae,Lt),F=Math.imul(ae,Et),F=F+Math.imul(Re,Lt)|0,V=Math.imul(Re,Et);var lr=(N+j|0)+((F&8191)<<13)|0;return N=(V+(F>>>13)|0)+(lr>>>26)|0,lr&=67108863,U[0]=Nr,U[1]=Or,U[2]=Gr,U[3]=Dr,U[4]=Yr,U[5]=Qt,U[6]=Xr,U[7]=Br,U[8]=Lr,U[9]=Ur,U[10]=yt,U[11]=Ke,U[12]=me,U[13]=Be,U[14]=Fe,U[15]=dt,U[16]=kt,U[17]=Ht,U[18]=lr,N!==0&&(U[19]=N,L.length++),L};Math.imul||(n=i);function o(C,E,A){A.negative=E.negative^C.negative,A.length=C.length+E.length;for(var L=0,$=0,W=0;W>>26)|0,$+=U>>>26,U&=67108863}A.words[W]=N,L=U,U=$}return L!==0?A.words[W]=L:A.length--,A._strip()}function p(C,E,A){return o(C,E,A)}f.prototype.mulTo=function(E,A){var L,$=this.length+E.length;return this.length===10&&E.length===10?L=n(this,E,A):$<63?L=i(this,E,A):$<1024?L=o(this,E,A):L=p(this,E,A),L},f.prototype.mul=function(E){var A=new f(null);return A.words=new Array(this.length+E.length),this.mulTo(E,A)},f.prototype.mulf=function(E){var A=new f(null);return A.words=new Array(this.length+E.length),p(this,E,A)},f.prototype.imul=function(E){return this.clone().mulTo(E,this)},f.prototype.imuln=function(E){var A=E<0;A&&(E=-E),b(typeof E=="number"),b(E<67108864);for(var L=0,$=0;$>=26,L+=W/67108864|0,L+=U>>>26,this.words[$]=U&67108863}return L!==0&&(this.words[$]=L,this.length++),A?this.ineg():this},f.prototype.muln=function(E){return this.clone().imuln(E)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(E){var A=t(E);if(A.length===0)return new f(1);for(var L=this,$=0;$=0);var A=E%26,L=(E-A)/26,$=67108863>>>26-A<<26-A,W;if(A!==0){var U=0;for(W=0;W>>26-A}U&&(this.words[W]=U,this.length++)}if(L!==0){for(W=this.length-1;W>=0;W--)this.words[W+L]=this.words[W];for(W=0;W=0);var $;A?$=(A-A%26)/26:$=0;var W=E%26,U=Math.min((E-W)/26,this.length),N=67108863^67108863>>>W<U)for(this.length-=U,F=0;F=0&&(V!==0||F>=$);F--){var re=this.words[F]|0;this.words[F]=V<<26-W|re>>>W,V=re&N}return j&&V!==0&&(j.words[j.length++]=V),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},f.prototype.ishrn=function(E,A,L){return b(this.negative===0),this.iushrn(E,A,L)},f.prototype.shln=function(E){return this.clone().ishln(E)},f.prototype.ushln=function(E){return this.clone().iushln(E)},f.prototype.shrn=function(E){return this.clone().ishrn(E)},f.prototype.ushrn=function(E){return this.clone().iushrn(E)},f.prototype.testn=function(E){b(typeof E=="number"&&E>=0);var A=E%26,L=(E-A)/26,$=1<=0);var A=E%26,L=(E-A)/26;if(b(this.negative===0,"imaskn works only with positive numbers"),this.length<=L)return this;if(A!==0&&L++,this.length=Math.min(L,this.length),A!==0){var $=67108863^67108863>>>A<=67108864;A++)this.words[A]-=67108864,A===this.length-1?this.words[A+1]=1:this.words[A+1]++;return this.length=Math.max(this.length,A+1),this},f.prototype.isubn=function(E){if(b(typeof E=="number"),b(E<67108864),E<0)return this.iaddn(-E);if(this.negative!==0)return this.negative=0,this.iaddn(E),this.negative=1,this;if(this.words[0]-=E,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var A=0;A>26)-(j/67108864|0),this.words[W+L]=U&67108863}for(;W>26,this.words[W+L]=U&67108863;if(N===0)return this._strip();for(b(N===-1),N=0,W=0;W>26,this.words[W]=U&67108863;return this.negative=1,this._strip()},f.prototype._wordDiv=function(E,A){var L=this.length-E.length,$=this.clone(),W=E,U=W.words[W.length-1]|0,N=this._countBits(U);L=26-N,L!==0&&(W=W.ushln(L),$.iushln(L),U=W.words[W.length-1]|0);var j=$.length-W.length,F;if(A!=="mod"){F=new f(null),F.length=j+1,F.words=new Array(F.length);for(var V=0;V=0;ee--){var ce=($.words[W.length+ee]|0)*67108864+($.words[W.length+ee-1]|0);for(ce=Math.min(ce/U|0,67108863),$._ishlnsubmul(W,ce,ee);$.negative!==0;)ce--,$.negative=0,$._ishlnsubmul(W,1,ee),$.isZero()||($.negative^=1);F&&(F.words[ee]=ce)}return F&&F._strip(),$._strip(),A!=="div"&&L!==0&&$.iushrn(L),{div:F||null,mod:$}},f.prototype.divmod=function(E,A,L){if(b(!E.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var $,W,U;return this.negative!==0&&E.negative===0?(U=this.neg().divmod(E,A),A!=="mod"&&($=U.div.neg()),A!=="div"&&(W=U.mod.neg(),L&&W.negative!==0&&W.iadd(E)),{div:$,mod:W}):this.negative===0&&E.negative!==0?(U=this.divmod(E.neg(),A),A!=="mod"&&($=U.div.neg()),{div:$,mod:U.mod}):this.negative&E.negative?(U=this.neg().divmod(E.neg(),A),A!=="div"&&(W=U.mod.neg(),L&&W.negative!==0&&W.isub(E)),{div:U.div,mod:W}):E.length>this.length||this.cmp(E)<0?{div:new f(0),mod:this}:E.length===1?A==="div"?{div:this.divn(E.words[0]),mod:null}:A==="mod"?{div:null,mod:new f(this.modrn(E.words[0]))}:{div:this.divn(E.words[0]),mod:new f(this.modrn(E.words[0]))}:this._wordDiv(E,A)},f.prototype.div=function(E){return this.divmod(E,"div",!1).div},f.prototype.mod=function(E){return this.divmod(E,"mod",!1).mod},f.prototype.umod=function(E){return this.divmod(E,"mod",!0).mod},f.prototype.divRound=function(E){var A=this.divmod(E);if(A.mod.isZero())return A.div;var L=A.div.negative!==0?A.mod.isub(E):A.mod,$=E.ushrn(1),W=E.andln(1),U=L.cmp($);return U<0||W===1&&U===0?A.div:A.div.negative!==0?A.div.isubn(1):A.div.iaddn(1)},f.prototype.modrn=function(E){var A=E<0;A&&(E=-E),b(E<=67108863);for(var L=(1<<26)%E,$=0,W=this.length-1;W>=0;W--)$=(L*$+(this.words[W]|0))%E;return A?-$:$},f.prototype.modn=function(E){return this.modrn(E)},f.prototype.idivn=function(E){var A=E<0;A&&(E=-E),b(E<=67108863);for(var L=0,$=this.length-1;$>=0;$--){var W=(this.words[$]|0)+L*67108864;this.words[$]=W/E|0,L=W%E}return this._strip(),A?this.ineg():this},f.prototype.divn=function(E){return this.clone().idivn(E)},f.prototype.egcd=function(E){b(E.negative===0),b(!E.isZero());var A=this,L=E.clone();A.negative!==0?A=A.umod(E):A=A.clone();for(var $=new f(1),W=new f(0),U=new f(0),N=new f(1),j=0;A.isEven()&&L.isEven();)A.iushrn(1),L.iushrn(1),++j;for(var F=L.clone(),V=A.clone();!A.isZero();){for(var re=0,ee=1;!(A.words[0]&ee)&&re<26;++re,ee<<=1);if(re>0)for(A.iushrn(re);re-- >0;)($.isOdd()||W.isOdd())&&($.iadd(F),W.isub(V)),$.iushrn(1),W.iushrn(1);for(var ce=0,ye=1;!(L.words[0]&ye)&&ce<26;++ce,ye<<=1);if(ce>0)for(L.iushrn(ce);ce-- >0;)(U.isOdd()||N.isOdd())&&(U.iadd(F),N.isub(V)),U.iushrn(1),N.iushrn(1);A.cmp(L)>=0?(A.isub(L),$.isub(U),W.isub(N)):(L.isub(A),U.isub($),N.isub(W))}return{a:U,b:N,gcd:L.iushln(j)}},f.prototype._invmp=function(E){b(E.negative===0),b(!E.isZero());var A=this,L=E.clone();A.negative!==0?A=A.umod(E):A=A.clone();for(var $=new f(1),W=new f(0),U=L.clone();A.cmpn(1)>0&&L.cmpn(1)>0;){for(var N=0,j=1;!(A.words[0]&j)&&N<26;++N,j<<=1);if(N>0)for(A.iushrn(N);N-- >0;)$.isOdd()&&$.iadd(U),$.iushrn(1);for(var F=0,V=1;!(L.words[0]&V)&&F<26;++F,V<<=1);if(F>0)for(L.iushrn(F);F-- >0;)W.isOdd()&&W.iadd(U),W.iushrn(1);A.cmp(L)>=0?(A.isub(L),$.isub(W)):(L.isub(A),W.isub($))}var re;return A.cmpn(1)===0?re=$:re=W,re.cmpn(0)<0&&re.iadd(E),re},f.prototype.gcd=function(E){if(this.isZero())return E.abs();if(E.isZero())return this.abs();var A=this.clone(),L=E.clone();A.negative=0,L.negative=0;for(var $=0;A.isEven()&&L.isEven();$++)A.iushrn(1),L.iushrn(1);do{for(;A.isEven();)A.iushrn(1);for(;L.isEven();)L.iushrn(1);var W=A.cmp(L);if(W<0){var U=A;A=L,L=U}else if(W===0||L.cmpn(1)===0)break;A.isub(L)}while(!0);return L.iushln($)},f.prototype.invm=function(E){return this.egcd(E).a.umod(E)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(E){return this.words[0]&E},f.prototype.bincn=function(E){b(typeof E=="number");var A=E%26,L=(E-A)/26,$=1<>>26,N&=67108863,this.words[U]=N}return W!==0&&(this.words[U]=W,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(E){var A=E<0;if(this.negative!==0&&!A)return-1;if(this.negative===0&&A)return 1;this._strip();var L;if(this.length>1)L=1;else{A&&(E=-E),b(E<=67108863,"Number is too big");var $=this.words[0]|0;L=$===E?0:$E.length)return 1;if(this.length=0;L--){var $=this.words[L]|0,W=E.words[L]|0;if($!==W){$W&&(A=1);break}}return A},f.prototype.gtn=function(E){return this.cmpn(E)===1},f.prototype.gt=function(E){return this.cmp(E)===1},f.prototype.gten=function(E){return this.cmpn(E)>=0},f.prototype.gte=function(E){return this.cmp(E)>=0},f.prototype.ltn=function(E){return this.cmpn(E)===-1},f.prototype.lt=function(E){return this.cmp(E)===-1},f.prototype.lten=function(E){return this.cmpn(E)<=0},f.prototype.lte=function(E){return this.cmp(E)<=0},f.prototype.eqn=function(E){return this.cmpn(E)===0},f.prototype.eq=function(E){return this.cmp(E)===0},f.red=function(E){return new I(E)},f.prototype.toRed=function(E){return b(!this.red,"Already a number in reduction context"),b(this.negative===0,"red works only with positives"),E.convertTo(this)._forceRed(E)},f.prototype.fromRed=function(){return b(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(E){return this.red=E,this},f.prototype.forceRed=function(E){return b(!this.red,"Already a number in reduction context"),this._forceRed(E)},f.prototype.redAdd=function(E){return b(this.red,"redAdd works only with red numbers"),this.red.add(this,E)},f.prototype.redIAdd=function(E){return b(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E)},f.prototype.redSub=function(E){return b(this.red,"redSub works only with red numbers"),this.red.sub(this,E)},f.prototype.redISub=function(E){return b(this.red,"redISub works only with red numbers"),this.red.isub(this,E)},f.prototype.redShl=function(E){return b(this.red,"redShl works only with red numbers"),this.red.shl(this,E)},f.prototype.redMul=function(E){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,E),this.red.mul(this,E)},f.prototype.redIMul=function(E){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,E),this.red.imul(this,E)},f.prototype.redSqr=function(){return b(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return b(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return b(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return b(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return b(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(E){return b(this.red&&!E.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E)};var O={k256:null,p224:null,p192:null,p25519:null};function P(C,E){this.name=C,this.p=new f(E,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}P.prototype._tmp=function(){var E=new f(null);return E.words=new Array(Math.ceil(this.n/13)),E},P.prototype.ireduce=function(E){var A=E,L;do this.split(A,this.tmp),A=this.imulK(A),A=A.iadd(this.tmp),L=A.bitLength();while(L>this.n);var $=L0?A.isub(this.p):A.strip!==void 0?A.strip():A._strip(),A},P.prototype.split=function(E,A){E.iushrn(this.n,0,A)},P.prototype.imulK=function(E){return E.imul(this.k)};function B(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}w(B,P),B.prototype.split=function(E,A){for(var L=4194303,$=Math.min(E.length,9),W=0;W<$;W++)A.words[W]=E.words[W];if(A.length=$,E.length<=9){E.words[0]=0,E.length=1;return}var U=E.words[9];for(A.words[A.length++]=U&L,W=10;W>>22,U=N}U>>>=22,E.words[W-10]=U,U===0&&E.length>10?E.length-=10:E.length-=9},B.prototype.imulK=function(E){E.words[E.length]=0,E.words[E.length+1]=0,E.length+=2;for(var A=0,L=0;L>>=26,E.words[L]=W,A=$}return A!==0&&(E.words[E.length++]=A),E},f._prime=function(E){if(O[E])return O[E];var A;if(E==="k256")A=new B;else if(E==="p224")A=new z;else if(E==="p192")A=new D;else if(E==="p25519")A=new M;else throw new Error("Unknown prime "+E);return O[E]=A,A};function I(C){if(typeof C=="string"){var E=f._prime(C);this.m=E.p,this.prime=E}else b(C.gtn(1),"modulus must be greater than 1"),this.m=C,this.prime=null}I.prototype._verify1=function(E){b(E.negative===0,"red works only with positives"),b(E.red,"red works only with red numbers")},I.prototype._verify2=function(E,A){b((E.negative|A.negative)===0,"red works only with positives"),b(E.red&&E.red===A.red,"red works only with red numbers")},I.prototype.imod=function(E){return this.prime?this.prime.ireduce(E)._forceRed(this):(d(E,E.umod(this.m)._forceRed(this)),E)},I.prototype.neg=function(E){return E.isZero()?E.clone():this.m.sub(E)._forceRed(this)},I.prototype.add=function(E,A){this._verify2(E,A);var L=E.add(A);return L.cmp(this.m)>=0&&L.isub(this.m),L._forceRed(this)},I.prototype.iadd=function(E,A){this._verify2(E,A);var L=E.iadd(A);return L.cmp(this.m)>=0&&L.isub(this.m),L},I.prototype.sub=function(E,A){this._verify2(E,A);var L=E.sub(A);return L.cmpn(0)<0&&L.iadd(this.m),L._forceRed(this)},I.prototype.isub=function(E,A){this._verify2(E,A);var L=E.isub(A);return L.cmpn(0)<0&&L.iadd(this.m),L},I.prototype.shl=function(E,A){return this._verify1(E),this.imod(E.ushln(A))},I.prototype.imul=function(E,A){return this._verify2(E,A),this.imod(E.imul(A))},I.prototype.mul=function(E,A){return this._verify2(E,A),this.imod(E.mul(A))},I.prototype.isqr=function(E){return this.imul(E,E.clone())},I.prototype.sqr=function(E){return this.mul(E,E)},I.prototype.sqrt=function(E){if(E.isZero())return E.clone();var A=this.m.andln(3);if(b(A%2===1),A===3){var L=this.m.add(new f(1)).iushrn(2);return this.pow(E,L)}for(var $=this.m.subn(1),W=0;!$.isZero()&&$.andln(1)===0;)W++,$.iushrn(1);b(!$.isZero());var U=new f(1).toRed(this),N=U.redNeg(),j=this.m.subn(1).iushrn(1),F=this.m.bitLength();for(F=new f(2*F*F).toRed(this);this.pow(F,j).cmp(N)!==0;)F.redIAdd(N);for(var V=this.pow(F,$),re=this.pow(E,$.addn(1).iushrn(1)),ee=this.pow(E,$),ce=W;ee.cmp(U)!==0;){for(var ye=ee,ge=0;ye.cmp(U)!==0;ge++)ye=ye.redSqr();b(ge=0;W--){for(var V=A.words[W],re=F-1;re>=0;re--){var ee=V>>re&1;if(U!==$[0]&&(U=this.sqr(U)),ee===0&&N===0){j=0;continue}N<<=1,N|=ee,j++,!(j!==L&&(W!==0||re!==0))&&(U=this.mul(U,$[N]),j=0,N=0)}F=26}return U},I.prototype.convertTo=function(E){var A=E.umod(this.m);return A===E?A.clone():A},I.prototype.convertFrom=function(E){var A=E.clone();return A.red=null,A},f.mont=function(E){return new T(E)};function T(C){I.call(this,C),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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(T,I),T.prototype.convertTo=function(E){return this.imod(E.ushln(this.shift))},T.prototype.convertFrom=function(E){var A=this.imod(E.mul(this.rinv));return A.red=null,A},T.prototype.imul=function(E,A){if(E.isZero()||A.isZero())return E.words[0]=0,E.length=1,E;var L=E.imul(A),$=L.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),W=L.isub($).iushrn(this.shift),U=W;return W.cmp(this.m)>=0?U=W.isub(this.m):W.cmpn(0)<0&&(U=W.iadd(this.m)),U._forceRed(this)},T.prototype.mul=function(E,A){if(E.isZero()||A.isZero())return new f(0)._forceRed(this);var L=E.mul(A),$=L.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),W=L.isub($).iushrn(this.shift),U=W;return W.cmp(this.m)>=0?U=W.isub(this.m):W.cmpn(0)<0&&(U=W.iadd(this.m)),U._forceRed(this)},T.prototype.invm=function(E){var A=this.imod(E._invmp(this.m).mul(this.r2));return A._forceRed(this)}})(typeof S>"u"||S,void 0)},{buffer:185}],184:[function(e,S,_){function u(w){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(v){return typeof v}:u=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},u(w)}var y;S.exports=function(f){return y||(y=new g(null)),y.generate(f)};function g(w){this.rand=w}if(S.exports.Rand=g,g.prototype.generate=function(f){return this._rand(f)},g.prototype._rand=function(f){if(this.rand.getBytes)return this.rand.getBytes(f);for(var v=new Uint8Array(f),h=0;h"u"?"undefined":u(self))==="object")self.crypto&&self.crypto.getRandomValues?g.prototype._rand=function(f){var v=new Uint8Array(f);return self.crypto.getRandomValues(v),v}:self.msCrypto&&self.msCrypto.getRandomValues?g.prototype._rand=function(f){var v=new Uint8Array(f);return self.msCrypto.getRandomValues(v),v}:(typeof window>"u"?"undefined":u(window))==="object"&&(g.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var b=e("crypto");if(typeof b.randomBytes!="function")throw new Error("Not supported");g.prototype._rand=function(f){return b.randomBytes(f)}}catch{}},{crypto:185}],185:[function(e,S,_){},{}],186:[function(e,S,_){var u=e("safe-buffer").Buffer;function y(h){u.isBuffer(h)||(h=u.from(h));for(var l=h.length/4|0,d=new Array(l),s=0;s>>24]^a[n>>>16&255]^r[o>>>8&255]^t[p&255]^l[D++],P=c[n>>>24]^a[o>>>16&255]^r[p>>>8&255]^t[i&255]^l[D++],B=c[o>>>24]^a[p>>>16&255]^r[i>>>8&255]^t[n&255]^l[D++],z=c[p>>>24]^a[i>>>16&255]^r[n>>>8&255]^t[o&255]^l[D++],i=O,n=P,o=B,p=z;return O=(s[i>>>24]<<24|s[n>>>16&255]<<16|s[o>>>8&255]<<8|s[p&255])^l[D++],P=(s[n>>>24]<<24|s[o>>>16&255]<<16|s[p>>>8&255]<<8|s[i&255])^l[D++],B=(s[o>>>24]<<24|s[p>>>16&255]<<16|s[i>>>8&255]<<8|s[n&255])^l[D++],z=(s[p>>>24]<<24|s[i>>>16&255]<<16|s[n>>>8&255]<<8|s[o&255])^l[D++],O=O>>>0,P=P>>>0,B=B>>>0,z=z>>>0,[O,P,B,z]}var w=[0,1,2,4,8,16,32,64,128,27,54],f=function(){for(var h=new Array(256),l=0;l<256;l++)l<128?h[l]=l<<1:h[l]=l<<1^283;for(var d=[],s=[],m=[[],[],[],[]],c=[[],[],[],[]],a=0,r=0,t=0;t<256;++t){var i=r^r<<1^r<<2^r<<3^r<<4;i=i>>>8^i&255^99,d[a]=i,s[i]=a;var n=h[a],o=h[n],p=h[o],O=h[i]*257^i*16843008;m[0][a]=O<<24|O>>>8,m[1][a]=O<<16|O>>>16,m[2][a]=O<<8|O>>>24,m[3][a]=O,O=p*16843009^o*65537^n*257^a*16843008,c[0][i]=O<<24|O>>>8,c[1][i]=O<<16|O>>>16,c[2][i]=O<<8|O>>>24,c[3][i]=O,a===0?a=r=1:(a=n^h[h[h[p^n]]],r^=h[h[r]])}return{SBOX:d,INV_SBOX:s,SUB_MIX:m,INV_SUB_MIX:c}}();function v(h){this._key=y(h),this._reset()}v.blockSize=4*4,v.keySize=256/8,v.prototype.blockSize=v.blockSize,v.prototype.keySize=v.keySize,v.prototype._reset=function(){for(var h=this._key,l=h.length,d=l+6,s=(d+1)*4,m=[],c=0;c>>24,a=f.SBOX[a>>>24]<<24|f.SBOX[a>>>16&255]<<16|f.SBOX[a>>>8&255]<<8|f.SBOX[a&255],a^=w[c/l|0]<<24):l>6&&c%l===4&&(a=f.SBOX[a>>>24]<<24|f.SBOX[a>>>16&255]<<16|f.SBOX[a>>>8&255]<<8|f.SBOX[a&255]),m[c]=m[c-l]^a}for(var r=[],t=0;t>>24]]^f.INV_SUB_MIX[1][f.SBOX[n>>>16&255]]^f.INV_SUB_MIX[2][f.SBOX[n>>>8&255]]^f.INV_SUB_MIX[3][f.SBOX[n&255]]}this._nRounds=d,this._keySchedule=m,this._invKeySchedule=r},v.prototype.encryptBlockRaw=function(h){return h=y(h),b(h,this._keySchedule,f.SUB_MIX,f.SBOX,this._nRounds)},v.prototype.encryptBlock=function(h){var l=this.encryptBlockRaw(h),d=u.allocUnsafe(16);return d.writeUInt32BE(l[0],0),d.writeUInt32BE(l[1],4),d.writeUInt32BE(l[2],8),d.writeUInt32BE(l[3],12),d},v.prototype.decryptBlock=function(h){h=y(h);var l=h[1];h[1]=h[3],h[3]=l;var d=b(h,this._invKeySchedule,f.INV_SUB_MIX,f.INV_SBOX,this._nRounds),s=u.allocUnsafe(16);return s.writeUInt32BE(d[0],0),s.writeUInt32BE(d[3],4),s.writeUInt32BE(d[2],8),s.writeUInt32BE(d[1],12),s},v.prototype.scrub=function(){g(this._keySchedule),g(this._invKeySchedule),g(this._key)},S.exports.AES=v},{"safe-buffer":494}],187:[function(e,S,_){var u=e("./aes"),y=e("safe-buffer").Buffer,g=e("cipher-base"),b=e("inherits"),w=e("./ghash"),f=e("buffer-xor"),v=e("./incr32");function h(s,m){var c=0;s.length!==m.length&&c++;for(var a=Math.min(s.length,m.length),r=0;r16)return r=this.cache.slice(0,16),this.cache=this.cache.slice(16),r}else if(this.cache.length>=16)return r=this.cache.slice(0,16),this.cache=this.cache.slice(16),r;return null},d.prototype.flush=function(){if(this.cache.length)return this.cache};function s(a){var r=a[15];if(r<1||r>16)throw new Error("unable to decrypt data");for(var t=-1;++t15){var a=this.cache.slice(0,16);return this.cache=this.cache.slice(16),a}return null},s.prototype.flush=function(){for(var a=16-this.cache.length,r=g.allocUnsafe(a),t=-1;++t>>0,0),v.writeUInt32BE(f[1]>>>0,4),v.writeUInt32BE(f[2]>>>0,8),v.writeUInt32BE(f[3]>>>0,12),v}function w(f){this.h=f,this.state=u.alloc(16,0),this.cache=u.allocUnsafe(0)}w.prototype.ghash=function(f){for(var v=-1;++v0;h--)f[h]=f[h]>>>1|(f[h-1]&1)<<31;f[0]=f[0]>>>1,d&&(f[0]=f[0]^225<<24)}this.state=b(v)},w.prototype.update=function(f){this.cache=u.concat([this.cache,f]);for(var v;this.cache.length>=16;)v=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(v)},w.prototype.final=function(f,v){return this.cache.length&&this.ghash(u.concat([this.cache,y],16)),this.ghash(b([0,f,0,v])),this.state},S.exports=w},{"safe-buffer":494}],192:[function(e,S,_){function u(y){for(var g=y.length,b;g--;)if(b=y.readUInt8(g),b===255)y.writeUInt8(0,g);else{b++,y.writeUInt8(b,g);break}}S.exports=u},{}],193:[function(e,S,_){var u=e("buffer-xor");_.encrypt=function(y,g){var b=u(g,y._prev);return y._prev=y._cipher.encryptBlock(b),y._prev},_.decrypt=function(y,g){var b=y._prev;y._prev=g;var w=y._cipher.decryptBlock(g);return u(w,b)}},{"buffer-xor":217}],194:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("buffer-xor");function g(b,w,f){var v=w.length,h=y(w,b._cache);return b._cache=b._cache.slice(v),b._prev=u.concat([b._prev,f?w:h]),h}_.encrypt=function(b,w,f){for(var v=u.allocUnsafe(0),h;w.length;)if(b._cache.length===0&&(b._cache=b._cipher.encryptBlock(b._prev),b._prev=u.allocUnsafe(0)),b._cache.length<=w.length)h=b._cache.length,v=u.concat([v,g(b,w.slice(0,h),f)]),w=w.slice(h);else{v=u.concat([v,g(b,w,f)]);break}return v}},{"buffer-xor":217,"safe-buffer":494}],195:[function(e,S,_){var u=e("safe-buffer").Buffer;function y(b,w,f){for(var v,h=-1,l=8,d=0,s,m;++h>h%8,b._prev=g(b._prev,f?s:m);return d}function g(b,w){var f=b.length,v=-1,h=u.allocUnsafe(b.length);for(b=u.concat([b,u.from([w])]);++v>7;return h}_.encrypt=function(b,w,f){for(var v=w.length,h=u.allocUnsafe(v),l=-1;++l=0||!l.umod(v.prime1)||!l.umod(v.prime2);)l=new y(g(h));return l}}).call(this,e("buffer").Buffer)},{"bn.js":207,buffer:216,randombytes:475}],207:[function(e,S,_){arguments[4][181][0].apply(_,arguments)},{buffer:185,dup:181}],208:[function(e,S,_){S.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":209}],209:[function(e,S,_){S.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"}}},{}],210:[function(e,S,_){S.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"}},{}],211:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("create-hash"),g=e("readable-stream"),b=e("inherits"),w=e("./sign"),f=e("./verify"),v=e("./algorithms.json");Object.keys(v).forEach(function(m){v[m].id=u.from(v[m].id,"hex"),v[m.toLowerCase()]=v[m]});function h(m){g.Writable.call(this);var c=v[m];if(!c)throw new Error("Unknown message digest");this._hashType=c.hash,this._hash=y(c.hash),this._tag=c.id,this._signType=c.sign}b(h,g.Writable),h.prototype._write=function(c,a,r){this._hash.update(c),r()},h.prototype.update=function(c,a){return typeof c=="string"&&(c=u.from(c,a)),this._hash.update(c),this},h.prototype.sign=function(c,a){this.end();var r=this._hash.digest(),t=w(r,c,this._hashType,this._signType,this._tag);return a?t.toString(a):t};function l(m){g.Writable.call(this);var c=v[m];if(!c)throw new Error("Unknown message digest");this._hash=y(c.hash),this._tag=c.id,this._signType=c.sign}b(l,g.Writable),l.prototype._write=function(c,a,r){this._hash.update(c),r()},l.prototype.update=function(c,a){return typeof c=="string"&&(c=u.from(c,a)),this._hash.update(c),this},l.prototype.verify=function(c,a,r){typeof a=="string"&&(a=u.from(a,r)),this.end();var t=this._hash.digest();return f(a,t,c,this._signType,this._tag)};function d(m){return new h(m)}function s(m){return new l(m)}S.exports={Sign:d,Verify:s,createSign:d,createVerify:s}},{"./algorithms.json":209,"./sign":212,"./verify":213,"create-hash":331,inherits:387,"readable-stream":491,"safe-buffer":214}],212:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("create-hmac"),g=e("browserify-rsa"),b=e("elliptic").ec,w=e("bn.js"),f=e("parse-asn1"),v=e("./curves.json");function h(i,n,o,p,O){var P=f(n);if(P.curve){if(p!=="ecdsa"&&p!=="ecdsa/rsa")throw new Error("wrong private key type");return l(i,P)}else if(P.type==="dsa"){if(p!=="dsa")throw new Error("wrong private key type");return d(i,P,o)}else if(p!=="rsa"&&p!=="ecdsa/rsa")throw new Error("wrong private key type");i=u.concat([O,i]);for(var B=P.modulus.byteLength(),z=[0,1];i.length+z.length+10&&o.ishrn(p),o}function a(i,n){i=c(i,n),i=i.mod(n);var o=u.from(i.toArray());if(o.length=s)throw new Error("invalid sig")}S.exports=f},{"./curves.json":210,"bn.js":183,elliptic:350,"parse-asn1":459,"safe-buffer":214}],214:[function(e,S,_){/*! safe-buffer. MIT License. Feross Aboukhadijeh */var u=e("buffer"),y=u.Buffer;function g(w,f){for(var v in w)f[v]=w[v]}y.from&&y.alloc&&y.allocUnsafe&&y.allocUnsafeSlow?S.exports=u:(g(u,_),_.Buffer=b);function b(w,f,v){return y(w,f,v)}b.prototype=Object.create(y.prototype),g(y,b),b.from=function(w,f,v){if(typeof w=="number")throw new TypeError("Argument must not be a number");return y(w,f,v)},b.alloc=function(w,f,v){if(typeof w!="number")throw new TypeError("Argument must be a number");var h=y(w);return f!==void 0?typeof v=="string"?h.fill(f,v):h.fill(f):h.fill(0),h},b.allocUnsafe=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return y(w)},b.allocUnsafeSlow=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(w)}},{buffer:216}],215:[function(e,S,_){arguments[4][185][0].apply(_,arguments)},{dup:185}],216:[function(e,S,_){(function(h){function y(q){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(Y){return typeof Y}:y=function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y},y(q)}var g=e("base64-js"),b=e("ieee754");_.Buffer=h,_.SlowBuffer=n,_.INSPECT_MAX_BYTES=50;var w=2147483647;_.kMaxLength=w,h.TYPED_ARRAY_SUPPORT=f(),!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&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.");function f(){try{var q=new Uint8Array(1);return q.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},q.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function v(q){if(q>w)throw new RangeError('The value "'+q+'" is invalid for option "size"');var G=new Uint8Array(q);return G.__proto__=h.prototype,G}function h(q,G,Y){if(typeof q=="number"){if(typeof G=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(q)}return l(q,G,Y)}typeof Symbol<"u"&&Symbol.species!=null&&h[Symbol.species]===h&&Object.defineProperty(h,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),h.poolSize=8192;function l(q,G,Y){if(typeof q=="string")return c(q,G);if(ArrayBuffer.isView(q))return a(q);if(q==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+y(q));if(se(q,ArrayBuffer)||q&&se(q.buffer,ArrayBuffer))return r(q,G,Y);if(typeof q=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var fe=q.valueOf&&q.valueOf();if(fe!=null&&fe!==q)return h.from(fe,G,Y);var we=t(q);if(we)return we;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof q[Symbol.toPrimitive]=="function")return h.from(q[Symbol.toPrimitive]("string"),G,Y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+y(q))}h.from=function(q,G,Y){return l(q,G,Y)},h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array;function d(q){if(typeof q!="number")throw new TypeError('"size" argument must be of type number');if(q<0)throw new RangeError('The value "'+q+'" is invalid for option "size"')}function s(q,G,Y){return d(q),q<=0?v(q):G!==void 0?typeof Y=="string"?v(q).fill(G,Y):v(q).fill(G):v(q)}h.alloc=function(q,G,Y){return s(q,G,Y)};function m(q){return d(q),v(q<0?0:i(q)|0)}h.allocUnsafe=function(q){return m(q)},h.allocUnsafeSlow=function(q){return m(q)};function c(q,G){if((typeof G!="string"||G==="")&&(G="utf8"),!h.isEncoding(G))throw new TypeError("Unknown encoding: "+G);var Y=o(q,G)|0,fe=v(Y),we=fe.write(q,G);return we!==Y&&(fe=fe.slice(0,we)),fe}function a(q){for(var G=q.length<0?0:i(q.length)|0,Y=v(G),fe=0;fe=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return q|0}function n(q){return+q!=q&&(q=0),h.alloc(+q)}h.isBuffer=function(G){return G!=null&&G._isBuffer===!0&&G!==h.prototype},h.compare=function(G,Y){if(se(G,Uint8Array)&&(G=h.from(G,G.offset,G.byteLength)),se(Y,Uint8Array)&&(Y=h.from(Y,Y.offset,Y.byteLength)),!h.isBuffer(G)||!h.isBuffer(Y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(G===Y)return 0;for(var fe=G.length,we=Y.length,_e=0,je=Math.min(fe,we);_e2&&arguments[2]===!0;if(!fe&&Y===0)return 0;for(var we=!1;;)switch(G){case"ascii":case"latin1":case"binary":return Y;case"utf8":case"utf-8":return J(q).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y*2;case"hex":return Y>>>1;case"base64":return xe(q).length;default:if(we)return fe?-1:J(q).length;G=(""+G).toLowerCase(),we=!0}}h.byteLength=o;function p(q,G,Y){var fe=!1;if((G===void 0||G<0)&&(G=0),G>this.length||((Y===void 0||Y>this.length)&&(Y=this.length),Y<=0)||(Y>>>=0,G>>>=0,Y<=G))return"";for(q||(q="utf8");;)switch(q){case"hex":return N(this,G,Y);case"utf8":case"utf-8":return A(this,G,Y);case"ascii":return W(this,G,Y);case"latin1":case"binary":return U(this,G,Y);case"base64":return E(this,G,Y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,G,Y);default:if(fe)throw new TypeError("Unknown encoding: "+q);q=(q+"").toLowerCase(),fe=!0}}h.prototype._isBuffer=!0;function O(q,G,Y){var fe=q[G];q[G]=q[Y],q[Y]=fe}h.prototype.swap16=function(){var G=this.length;if(G%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var Y=0;YY&&(G+=" ... "),""},h.prototype.compare=function(G,Y,fe,we,_e){if(se(G,Uint8Array)&&(G=h.from(G,G.offset,G.byteLength)),!h.isBuffer(G))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+y(G));if(Y===void 0&&(Y=0),fe===void 0&&(fe=G?G.length:0),we===void 0&&(we=0),_e===void 0&&(_e=this.length),Y<0||fe>G.length||we<0||_e>this.length)throw new RangeError("out of range index");if(we>=_e&&Y>=fe)return 0;if(we>=_e)return-1;if(Y>=fe)return 1;if(Y>>>=0,fe>>>=0,we>>>=0,_e>>>=0,this===G)return 0;for(var je=_e-we,Ye=fe-Y,nt=Math.min(je,Ye),ut=this.slice(we,_e),ot=G.slice(Y,fe),Ue=0;Ue2147483647?Y=2147483647:Y<-2147483648&&(Y=-2147483648),Y=+Y,Ce(Y)&&(Y=we?0:q.length-1),Y<0&&(Y=q.length+Y),Y>=q.length){if(we)return-1;Y=q.length-1}else if(Y<0)if(we)Y=0;else return-1;if(typeof G=="string"&&(G=h.from(G,fe)),h.isBuffer(G))return G.length===0?-1:B(q,G,Y,fe,we);if(typeof G=="number")return G=G&255,typeof Uint8Array.prototype.indexOf=="function"?we?Uint8Array.prototype.indexOf.call(q,G,Y):Uint8Array.prototype.lastIndexOf.call(q,G,Y):B(q,[G],Y,fe,we);throw new TypeError("val must be string, number or Buffer")}function B(q,G,Y,fe,we){var _e=1,je=q.length,Ye=G.length;if(fe!==void 0&&(fe=String(fe).toLowerCase(),fe==="ucs2"||fe==="ucs-2"||fe==="utf16le"||fe==="utf-16le")){if(q.length<2||G.length<2)return-1;_e=2,je/=2,Ye/=2,Y/=2}function nt(Qe,tt){return _e===1?Qe[tt]:Qe.readUInt16BE(tt*_e)}var ut;if(we){var ot=-1;for(ut=Y;utje&&(Y=je-Ye),ut=Y;ut>=0;ut--){for(var Ue=!0,Ve=0;Vewe&&(fe=we)):fe=we;var _e=G.length;fe>_e/2&&(fe=_e/2);for(var je=0;je>>0,isFinite(fe)?(fe=fe>>>0,we===void 0&&(we="utf8")):(we=fe,fe=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var _e=this.length-Y;if((fe===void 0||fe>_e)&&(fe=_e),G.length>0&&(fe<0||Y<0)||Y>this.length)throw new RangeError("Attempt to write outside buffer bounds");we||(we="utf8");for(var je=!1;;)switch(we){case"hex":return z(this,G,Y,fe);case"utf8":case"utf-8":return D(this,G,Y,fe);case"ascii":return M(this,G,Y,fe);case"latin1":case"binary":return I(this,G,Y,fe);case"base64":return T(this,G,Y,fe);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,G,Y,fe);default:if(je)throw new TypeError("Unknown encoding: "+we);we=(""+we).toLowerCase(),je=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(q,G,Y){return G===0&&Y===q.length?g.fromByteArray(q):g.fromByteArray(q.slice(G,Y))}function A(q,G,Y){Y=Math.min(q.length,Y);for(var fe=[],we=G;we239?4:_e>223?3:_e>191?2:1;if(we+Ye<=Y){var nt,ut,ot,Ue;switch(Ye){case 1:_e<128&&(je=_e);break;case 2:nt=q[we+1],(nt&192)===128&&(Ue=(_e&31)<<6|nt&63,Ue>127&&(je=Ue));break;case 3:nt=q[we+1],ut=q[we+2],(nt&192)===128&&(ut&192)===128&&(Ue=(_e&15)<<12|(nt&63)<<6|ut&63,Ue>2047&&(Ue<55296||Ue>57343)&&(je=Ue));break;case 4:nt=q[we+1],ut=q[we+2],ot=q[we+3],(nt&192)===128&&(ut&192)===128&&(ot&192)===128&&(Ue=(_e&15)<<18|(nt&63)<<12|(ut&63)<<6|ot&63,Ue>65535&&Ue<1114112&&(je=Ue))}}je===null?(je=65533,Ye=1):je>65535&&(je-=65536,fe.push(je>>>10&1023|55296),je=56320|je&1023),fe.push(je),we+=Ye}return $(fe)}var L=4096;function $(q){var G=q.length;if(G<=L)return String.fromCharCode.apply(String,q);for(var Y="",fe=0;fefe)&&(Y=fe);for(var we="",_e=G;_efe&&(G=fe),Y<0?(Y+=fe,Y<0&&(Y=0)):Y>fe&&(Y=fe),YY)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUIntLE=function(G,Y,fe){G=G>>>0,Y=Y>>>0,fe||F(G,Y,this.length);for(var we=this[G],_e=1,je=0;++je>>0,Y=Y>>>0,fe||F(G,Y,this.length);for(var we=this[G+--Y],_e=1;Y>0&&(_e*=256);)we+=this[G+--Y]*_e;return we},h.prototype.readUInt8=function(G,Y){return G=G>>>0,Y||F(G,1,this.length),this[G]},h.prototype.readUInt16LE=function(G,Y){return G=G>>>0,Y||F(G,2,this.length),this[G]|this[G+1]<<8},h.prototype.readUInt16BE=function(G,Y){return G=G>>>0,Y||F(G,2,this.length),this[G]<<8|this[G+1]},h.prototype.readUInt32LE=function(G,Y){return G=G>>>0,Y||F(G,4,this.length),(this[G]|this[G+1]<<8|this[G+2]<<16)+this[G+3]*16777216},h.prototype.readUInt32BE=function(G,Y){return G=G>>>0,Y||F(G,4,this.length),this[G]*16777216+(this[G+1]<<16|this[G+2]<<8|this[G+3])},h.prototype.readIntLE=function(G,Y,fe){G=G>>>0,Y=Y>>>0,fe||F(G,Y,this.length);for(var we=this[G],_e=1,je=0;++je=_e&&(we-=Math.pow(2,8*Y)),we},h.prototype.readIntBE=function(G,Y,fe){G=G>>>0,Y=Y>>>0,fe||F(G,Y,this.length);for(var we=Y,_e=1,je=this[G+--we];we>0&&(_e*=256);)je+=this[G+--we]*_e;return _e*=128,je>=_e&&(je-=Math.pow(2,8*Y)),je},h.prototype.readInt8=function(G,Y){return G=G>>>0,Y||F(G,1,this.length),this[G]&128?(255-this[G]+1)*-1:this[G]},h.prototype.readInt16LE=function(G,Y){G=G>>>0,Y||F(G,2,this.length);var fe=this[G]|this[G+1]<<8;return fe&32768?fe|4294901760:fe},h.prototype.readInt16BE=function(G,Y){G=G>>>0,Y||F(G,2,this.length);var fe=this[G+1]|this[G]<<8;return fe&32768?fe|4294901760:fe},h.prototype.readInt32LE=function(G,Y){return G=G>>>0,Y||F(G,4,this.length),this[G]|this[G+1]<<8|this[G+2]<<16|this[G+3]<<24},h.prototype.readInt32BE=function(G,Y){return G=G>>>0,Y||F(G,4,this.length),this[G]<<24|this[G+1]<<16|this[G+2]<<8|this[G+3]},h.prototype.readFloatLE=function(G,Y){return G=G>>>0,Y||F(G,4,this.length),b.read(this,G,!0,23,4)},h.prototype.readFloatBE=function(G,Y){return G=G>>>0,Y||F(G,4,this.length),b.read(this,G,!1,23,4)},h.prototype.readDoubleLE=function(G,Y){return G=G>>>0,Y||F(G,8,this.length),b.read(this,G,!0,52,8)},h.prototype.readDoubleBE=function(G,Y){return G=G>>>0,Y||F(G,8,this.length),b.read(this,G,!1,52,8)};function V(q,G,Y,fe,we,_e){if(!h.isBuffer(q))throw new TypeError('"buffer" argument must be a Buffer instance');if(G>we||G<_e)throw new RangeError('"value" argument is out of bounds');if(Y+fe>q.length)throw new RangeError("Index out of range")}h.prototype.writeUIntLE=function(G,Y,fe,we){if(G=+G,Y=Y>>>0,fe=fe>>>0,!we){var _e=Math.pow(2,8*fe)-1;V(this,G,Y,fe,_e,0)}var je=1,Ye=0;for(this[Y]=G&255;++Ye>>0,fe=fe>>>0,!we){var _e=Math.pow(2,8*fe)-1;V(this,G,Y,fe,_e,0)}var je=fe-1,Ye=1;for(this[Y+je]=G&255;--je>=0&&(Ye*=256);)this[Y+je]=G/Ye&255;return Y+fe},h.prototype.writeUInt8=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,1,255,0),this[Y]=G&255,Y+1},h.prototype.writeUInt16LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,65535,0),this[Y]=G&255,this[Y+1]=G>>>8,Y+2},h.prototype.writeUInt16BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,65535,0),this[Y]=G>>>8,this[Y+1]=G&255,Y+2},h.prototype.writeUInt32LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,4294967295,0),this[Y+3]=G>>>24,this[Y+2]=G>>>16,this[Y+1]=G>>>8,this[Y]=G&255,Y+4},h.prototype.writeUInt32BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,4294967295,0),this[Y]=G>>>24,this[Y+1]=G>>>16,this[Y+2]=G>>>8,this[Y+3]=G&255,Y+4},h.prototype.writeIntLE=function(G,Y,fe,we){if(G=+G,Y=Y>>>0,!we){var _e=Math.pow(2,8*fe-1);V(this,G,Y,fe,_e-1,-_e)}var je=0,Ye=1,nt=0;for(this[Y]=G&255;++je>0)-nt&255;return Y+fe},h.prototype.writeIntBE=function(G,Y,fe,we){if(G=+G,Y=Y>>>0,!we){var _e=Math.pow(2,8*fe-1);V(this,G,Y,fe,_e-1,-_e)}var je=fe-1,Ye=1,nt=0;for(this[Y+je]=G&255;--je>=0&&(Ye*=256);)G<0&&nt===0&&this[Y+je+1]!==0&&(nt=1),this[Y+je]=(G/Ye>>0)-nt&255;return Y+fe},h.prototype.writeInt8=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,1,127,-128),G<0&&(G=255+G+1),this[Y]=G&255,Y+1},h.prototype.writeInt16LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,32767,-32768),this[Y]=G&255,this[Y+1]=G>>>8,Y+2},h.prototype.writeInt16BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,32767,-32768),this[Y]=G>>>8,this[Y+1]=G&255,Y+2},h.prototype.writeInt32LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,2147483647,-2147483648),this[Y]=G&255,this[Y+1]=G>>>8,this[Y+2]=G>>>16,this[Y+3]=G>>>24,Y+4},h.prototype.writeInt32BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,2147483647,-2147483648),G<0&&(G=4294967295+G+1),this[Y]=G>>>24,this[Y+1]=G>>>16,this[Y+2]=G>>>8,this[Y+3]=G&255,Y+4};function re(q,G,Y,fe,we,_e){if(Y+fe>q.length)throw new RangeError("Index out of range");if(Y<0)throw new RangeError("Index out of range")}function ee(q,G,Y,fe,we){return G=+G,Y=Y>>>0,we||re(q,G,Y,4),b.write(q,G,Y,fe,23,4),Y+4}h.prototype.writeFloatLE=function(G,Y,fe){return ee(this,G,Y,!0,fe)},h.prototype.writeFloatBE=function(G,Y,fe){return ee(this,G,Y,!1,fe)};function ce(q,G,Y,fe,we){return G=+G,Y=Y>>>0,we||re(q,G,Y,8),b.write(q,G,Y,fe,52,8),Y+8}h.prototype.writeDoubleLE=function(G,Y,fe){return ce(this,G,Y,!0,fe)},h.prototype.writeDoubleBE=function(G,Y,fe){return ce(this,G,Y,!1,fe)},h.prototype.copy=function(G,Y,fe,we){if(!h.isBuffer(G))throw new TypeError("argument should be a Buffer");if(fe||(fe=0),!we&&we!==0&&(we=this.length),Y>=G.length&&(Y=G.length),Y||(Y=0),we>0&&we=this.length)throw new RangeError("Index out of range");if(we<0)throw new RangeError("sourceEnd out of bounds");we>this.length&&(we=this.length),G.length-Y=0;--je)G[je+Y]=this[je+fe];else Uint8Array.prototype.set.call(G,this.subarray(fe,we),Y);return _e},h.prototype.fill=function(G,Y,fe,we){if(typeof G=="string"){if(typeof Y=="string"?(we=Y,Y=0,fe=this.length):typeof fe=="string"&&(we=fe,fe=this.length),we!==void 0&&typeof we!="string")throw new TypeError("encoding must be a string");if(typeof we=="string"&&!h.isEncoding(we))throw new TypeError("Unknown encoding: "+we);if(G.length===1){var _e=G.charCodeAt(0);(we==="utf8"&&_e<128||we==="latin1")&&(G=_e)}}else typeof G=="number"&&(G=G&255);if(Y<0||this.length>>0,fe=fe===void 0?this.length:fe>>>0,G||(G=0);var je;if(typeof G=="number")for(je=Y;je55295&&Y<57344){if(!we){if(Y>56319){(G-=3)>-1&&_e.push(239,191,189);continue}else if(je+1===fe){(G-=3)>-1&&_e.push(239,191,189);continue}we=Y;continue}if(Y<56320){(G-=3)>-1&&_e.push(239,191,189),we=Y;continue}Y=(we-55296<<10|Y-56320)+65536}else we&&(G-=3)>-1&&_e.push(239,191,189);if(we=null,Y<128){if((G-=1)<0)break;_e.push(Y)}else if(Y<2048){if((G-=2)<0)break;_e.push(Y>>6|192,Y&63|128)}else if(Y<65536){if((G-=3)<0)break;_e.push(Y>>12|224,Y>>6&63|128,Y&63|128)}else if(Y<1114112){if((G-=4)<0)break;_e.push(Y>>18|240,Y>>12&63|128,Y>>6&63|128,Y&63|128)}else throw new Error("Invalid code point")}return _e}function Q(q){for(var G=[],Y=0;Y>8,we=Y%256,_e.push(we),_e.push(fe);return _e}function xe(q){return g.toByteArray(ge(q))}function ne(q,G,Y,fe){for(var we=0;we=G.length||we>=q.length);++we)G[we+Y]=q[we];return we}function se(q,G){return q instanceof G||q!=null&&q.constructor!=null&&q.constructor.name!=null&&q.constructor.name===G.name}function Ce(q){return q!==q}}).call(this,e("buffer").Buffer)},{"base64-js":182,buffer:216,ieee754:385}],217:[function(e,S,_){(function(u){S.exports=function(g,b){for(var w=Math.min(g.length,b.length),f=new u(w),v=0;vs;)if(m=l[s++],m!=m)return!0}else for(;d>s;s++)if((w||s in l)&&l[s]===v)return w||s||0;return!w&&-1}};S.exports={includes:b(!0),indexOf:b(!1)}},{"../internals/to-absolute-index":304,"../internals/to-indexed-object":305,"../internals/to-length":307}],225:[function(e,S,_){var u=e("../internals/function-bind-context"),y=e("../internals/indexed-object"),g=e("../internals/to-object"),b=e("../internals/to-length"),w=e("../internals/array-species-create"),f=[].push,v=function(h){var l=h==1,d=h==2,s=h==3,m=h==4,c=h==6,a=h==5||c;return function(r,t,i,n){for(var o=g(r),p=y(o),O=u(t,i,3),P=b(p.length),B=0,z=n||w,D=l?z(r,P):d?z(r,0):void 0,M,I;P>B;B++)if((a||B in p)&&(M=p[B],I=O(M,B,o),h)){if(l)D[B]=I;else if(I)switch(h){case 3:return!0;case 5:return M;case 6:return B;case 2:f.call(D,M)}else if(m)return!1}return c?-1:s||m?m:D}};S.exports={forEach:v(0),map:v(1),filter:v(2),some:v(3),every:v(4),find:v(5),findIndex:v(6)}},{"../internals/array-species-create":227,"../internals/function-bind-context":248,"../internals/indexed-object":257,"../internals/to-length":307,"../internals/to-object":308}],226:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/fails"),g=e("../internals/has"),b=Object.defineProperty,w={},f=function(v){throw v};S.exports=function(v,h){if(g(w,v))return w[v];h||(h={});var l=[][v],d=g(h,"ACCESSORS")?h.ACCESSORS:!1,s=g(h,0)?h[0]:f,m=g(h,1)?h[1]:void 0;return w[v]=!!l&&!y(function(){if(d&&!u)return!0;var c={length:-1};d?b(c,1,{enumerable:!0,get:f}):c[1]=1,l.call(c,s,m)})}},{"../internals/descriptors":240,"../internals/fails":247,"../internals/has":252}],227:[function(e,S,_){var u=e("../internals/is-object"),y=e("../internals/is-array"),g=e("../internals/well-known-symbol"),b=g("species");S.exports=function(w,f){var v;return y(w)&&(v=w.constructor,typeof v=="function"&&(v===Array||y(v.prototype))?v=void 0:u(v)&&(v=v[b],v===null&&(v=void 0))),new(v===void 0?Array:v)(f===0?0:f)}},{"../internals/is-array":261,"../internals/is-object":263,"../internals/well-known-symbol":314}],228:[function(e,S,_){var u=e("../internals/an-object");S.exports=function(y,g,b,w){try{return w?g(u(b)[0],b[1]):g(b)}catch(v){var f=y.return;throw f!==void 0&&u(f.call(y)),v}}},{"../internals/an-object":223}],229:[function(e,S,_){var u=e("../internals/well-known-symbol"),y=u("iterator"),g=!1;try{var b=0,w={next:function(){return{done:!!b++}},return:function(){g=!0}};w[y]=function(){return this},Array.from(w,function(){throw 2})}catch{}S.exports=function(f,v){if(!v&&!g)return!1;var h=!1;try{var l={};l[y]=function(){return{next:function(){return{done:h=!0}}}},f(l)}catch{}return h}},{"../internals/well-known-symbol":314}],230:[function(e,S,_){var u={}.toString;S.exports=function(y){return u.call(y).slice(8,-1)}},{}],231:[function(e,S,_){var u=e("../internals/to-string-tag-support"),y=e("../internals/classof-raw"),g=e("../internals/well-known-symbol"),b=g("toStringTag"),w=y(function(){return arguments}())=="Arguments",f=function(v,h){try{return v[h]}catch{}};S.exports=u?y:function(v){var h,l,d;return v===void 0?"Undefined":v===null?"Null":typeof(l=f(h=Object(v),b))=="string"?l:w?y(h):(d=y(h))=="Object"&&typeof h.callee=="function"?"Arguments":d}},{"../internals/classof-raw":230,"../internals/to-string-tag-support":310,"../internals/well-known-symbol":314}],232:[function(e,S,_){var u=e("../internals/has"),y=e("../internals/own-keys"),g=e("../internals/object-get-own-property-descriptor"),b=e("../internals/object-define-property");S.exports=function(w,f){for(var v=y(f),h=b.f,l=g.f,d=0;d=74)&&(f=y.match(/Chrome\/(\d+)/),f&&(v=f[1]))),S.exports=v&&+v},{"../internals/engine-user-agent":243,"../internals/global":251}],245:[function(e,S,_){S.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},{}],246:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/object-get-own-property-descriptor").f,g=e("../internals/create-non-enumerable-property"),b=e("../internals/redefine"),w=e("../internals/set-global"),f=e("../internals/copy-constructor-properties"),v=e("../internals/is-forced");S.exports=function(h,l){var d=h.target,s=h.global,m=h.stat,c,a,r,t,i,n;if(s?a=u:m?a=u[d]||w(d,{}):a=(u[d]||{}).prototype,a)for(r in l){if(i=l[r],h.noTargetGet?(n=y(a,r),t=n&&n.value):t=a[r],c=v(s?r:d+(m?".":"#")+r,h.forced),!c&&t!==void 0){if(typeof i==typeof t)continue;f(i,t)}(h.sham||t&&t.sham)&&g(i,"sham",!0),b(a,r,i,h)}}},{"../internals/copy-constructor-properties":232,"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/is-forced":262,"../internals/object-get-own-property-descriptor":279,"../internals/redefine":294,"../internals/set-global":296}],247:[function(e,S,_){S.exports=function(u){try{return!!u()}catch{return!0}}},{}],248:[function(e,S,_){var u=e("../internals/a-function");S.exports=function(y,g,b){if(u(y),g===void 0)return y;switch(b){case 0:return function(){return y.call(g)};case 1:return function(w){return y.call(g,w)};case 2:return function(w,f){return y.call(g,w,f)};case 3:return function(w,f,v){return y.call(g,w,f,v)}}return function(){return y.apply(g,arguments)}}},{"../internals/a-function":219}],249:[function(e,S,_){var u=e("../internals/path"),y=e("../internals/global"),g=function(b){return typeof b=="function"?b:void 0};S.exports=function(b,w){return arguments.length<2?g(u[b])||g(y[b]):u[b]&&u[b][w]||y[b]&&y[b][w]}},{"../internals/global":251,"../internals/path":290}],250:[function(e,S,_){var u=e("../internals/classof"),y=e("../internals/iterators"),g=e("../internals/well-known-symbol"),b=g("iterator");S.exports=function(w){if(w!=null)return w[b]||w["@@iterator"]||y[u(w)]}},{"../internals/classof":231,"../internals/iterators":268,"../internals/well-known-symbol":314}],251:[function(e,S,_){(function(u){var y=function(g){return g&&g.Math==Math&&g};S.exports=y(typeof globalThis=="object"&&globalThis)||y(typeof window=="object"&&window)||y(typeof self=="object"&&self)||y(typeof u=="object"&&u)||Function("return this")()}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],252:[function(e,S,_){var u={}.hasOwnProperty;S.exports=function(y,g){return u.call(y,g)}},{}],253:[function(e,S,_){S.exports={}},{}],254:[function(e,S,_){var u=e("../internals/global");S.exports=function(y,g){var b=u.console;b&&b.error&&(arguments.length===1?b.error(y):b.error(y,g))}},{"../internals/global":251}],255:[function(e,S,_){var u=e("../internals/get-built-in");S.exports=u("document","documentElement")},{"../internals/get-built-in":249}],256:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/fails"),g=e("../internals/document-create-element");S.exports=!u&&!y(function(){return Object.defineProperty(g("div"),"a",{get:function(){return 7}}).a!=7})},{"../internals/descriptors":240,"../internals/document-create-element":241,"../internals/fails":247}],257:[function(e,S,_){var u=e("../internals/fails"),y=e("../internals/classof-raw"),g="".split;S.exports=u(function(){return!Object("z").propertyIsEnumerable(0)})?function(b){return y(b)=="String"?g.call(b,""):Object(b)}:Object},{"../internals/classof-raw":230,"../internals/fails":247}],258:[function(e,S,_){var u=e("../internals/shared-store"),y=Function.toString;typeof u.inspectSource!="function"&&(u.inspectSource=function(g){return y.call(g)}),S.exports=u.inspectSource},{"../internals/shared-store":300}],259:[function(e,S,_){var u=e("../internals/native-weak-map"),y=e("../internals/global"),g=e("../internals/is-object"),b=e("../internals/create-non-enumerable-property"),w=e("../internals/has"),f=e("../internals/shared-key"),v=e("../internals/hidden-keys"),h=y.WeakMap,l,d,s,m=function(o){return s(o)?d(o):l(o,{})},c=function(o){return function(p){var O;if(!g(p)||(O=d(p)).type!==o)throw TypeError("Incompatible receiver, "+o+" required");return O}};if(u){var a=new h,r=a.get,t=a.has,i=a.set;l=function(o,p){return i.call(a,o,p),p},d=function(o){return r.call(a,o)||{}},s=function(o){return t.call(a,o)}}else{var n=f("state");v[n]=!0,l=function(o,p){return b(o,n,p),p},d=function(o){return w(o,n)?o[n]:{}},s=function(o){return w(o,n)}}S.exports={set:l,get:d,has:s,enforce:m,getterFor:c}},{"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/has":252,"../internals/hidden-keys":253,"../internals/is-object":263,"../internals/native-weak-map":272,"../internals/shared-key":299}],260:[function(e,S,_){var u=e("../internals/well-known-symbol"),y=e("../internals/iterators"),g=u("iterator"),b=Array.prototype;S.exports=function(w){return w!==void 0&&(y.Array===w||b[g]===w)}},{"../internals/iterators":268,"../internals/well-known-symbol":314}],261:[function(e,S,_){var u=e("../internals/classof-raw");S.exports=Array.isArray||function(g){return u(g)=="Array"}},{"../internals/classof-raw":230}],262:[function(e,S,_){var u=e("../internals/fails"),y=/#|\.prototype\./,g=function(h,l){var d=w[b(h)];return d==v?!0:d==f?!1:typeof l=="function"?u(l):!!l},b=g.normalize=function(h){return String(h).replace(y,".").toLowerCase()},w=g.data={},f=g.NATIVE="N",v=g.POLYFILL="P";S.exports=g},{"../internals/fails":247}],263:[function(e,S,_){S.exports=function(u){return typeof u=="object"?u!==null:typeof u=="function"}},{}],264:[function(e,S,_){S.exports=!1},{}],265:[function(e,S,_){var u=e("../internals/is-object"),y=e("../internals/classof-raw"),g=e("../internals/well-known-symbol"),b=g("match");S.exports=function(w){var f;return u(w)&&((f=w[b])!==void 0?!!f:y(w)=="RegExp")}},{"../internals/classof-raw":230,"../internals/is-object":263,"../internals/well-known-symbol":314}],266:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/is-array-iterator-method"),g=e("../internals/to-length"),b=e("../internals/function-bind-context"),w=e("../internals/get-iterator-method"),f=e("../internals/call-with-safe-iteration-closing"),v=function(l,d){this.stopped=l,this.result=d},h=S.exports=function(l,d,s,m,c){var a=b(d,s,m?2:1),r,t,i,n,o,p,O;if(c)r=l;else{if(t=w(l),typeof t!="function")throw TypeError("Target is not iterable");if(y(t)){for(i=0,n=g(l.length);n>i;i++)if(o=m?a(u(O=l[i])[0],O[1]):a(l[i]),o&&o instanceof v)return o;return new v(!1)}r=t.call(l)}for(p=r.next;!(O=p.call(r)).done;)if(o=f(r,a,O.value,m),typeof o=="object"&&o&&o instanceof v)return o;return new v(!1)};h.stop=function(l){return new v(!0,l)}},{"../internals/an-object":223,"../internals/call-with-safe-iteration-closing":228,"../internals/function-bind-context":248,"../internals/get-iterator-method":250,"../internals/is-array-iterator-method":260,"../internals/to-length":307}],267:[function(e,S,_){var u=e("../internals/object-get-prototype-of"),y=e("../internals/create-non-enumerable-property"),g=e("../internals/has"),b=e("../internals/well-known-symbol"),w=e("../internals/is-pure"),f=b("iterator"),v=!1,h=function(){return this},l,d,s;[].keys&&(s=[].keys(),"next"in s?(d=u(u(s)),d!==Object.prototype&&(l=d)):v=!0),l==null&&(l={}),!w&&!g(l,f)&&y(l,f,h),S.exports={IteratorPrototype:l,BUGGY_SAFARI_ITERATORS:v}},{"../internals/create-non-enumerable-property":236,"../internals/has":252,"../internals/is-pure":264,"../internals/object-get-prototype-of":283,"../internals/well-known-symbol":314}],268:[function(e,S,_){arguments[4][253][0].apply(_,arguments)},{dup:253}],269:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/object-get-own-property-descriptor").f,g=e("../internals/classof-raw"),b=e("../internals/task").set,w=e("../internals/engine-is-ios"),f=u.MutationObserver||u.WebKitMutationObserver,v=u.process,h=u.Promise,l=g(v)=="process",d=y(u,"queueMicrotask"),s=d&&d.value,m,c,a,r,t,i,n,o;s||(m=function(){var p,O;for(l&&(p=v.domain)&&p.exit();c;){O=c.fn,c=c.next;try{O()}catch(P){throw c?r():a=void 0,P}}a=void 0,p&&p.enter()},l?r=function(){v.nextTick(m)}:f&&!w?(t=!0,i=document.createTextNode(""),new f(m).observe(i,{characterData:!0}),r=function(){i.data=t=!t}):h&&h.resolve?(n=h.resolve(void 0),o=n.then,r=function(){o.call(n,m)}):r=function(){b.call(u,m)}),S.exports=s||function(p){var O={fn:p,next:void 0};a&&(a.next=O),c||(c=O,r()),a=O}},{"../internals/classof-raw":230,"../internals/engine-is-ios":242,"../internals/global":251,"../internals/object-get-own-property-descriptor":279,"../internals/task":303}],270:[function(e,S,_){var u=e("../internals/global");S.exports=u.Promise},{"../internals/global":251}],271:[function(e,S,_){var u=e("../internals/fails");S.exports=!!Object.getOwnPropertySymbols&&!u(function(){return!String(Symbol())})},{"../internals/fails":247}],272:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/inspect-source"),g=u.WeakMap;S.exports=typeof g=="function"&&/native code/.test(y(g))},{"../internals/global":251,"../internals/inspect-source":258}],273:[function(e,S,_){var u=e("../internals/a-function"),y=function(g){var b,w;this.promise=new g(function(f,v){if(b!==void 0||w!==void 0)throw TypeError("Bad Promise constructor");b=f,w=v}),this.resolve=u(b),this.reject=u(w)};S.exports.f=function(g){return new y(g)}},{"../internals/a-function":219}],274:[function(e,S,_){var u=e("../internals/is-regexp");S.exports=function(y){if(u(y))throw TypeError("The method doesn't accept regular expressions");return y}},{"../internals/is-regexp":265}],275:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/fails"),g=e("../internals/object-keys"),b=e("../internals/object-get-own-property-symbols"),w=e("../internals/object-property-is-enumerable"),f=e("../internals/to-object"),v=e("../internals/indexed-object"),h=Object.assign,l=Object.defineProperty;S.exports=!h||y(function(){if(u&&h({b:1},h(l({},"a",{enumerable:!0,get:function(){l(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var d={},s={},m=Symbol(),c="abcdefghijklmnopqrst";return d[m]=7,c.split("").forEach(function(a){s[a]=a}),h({},d)[m]!=7||g(h({},s)).join("")!=c})?function(s,m){for(var c=f(s),a=arguments.length,r=1,t=b.f,i=w.f;a>r;)for(var n=v(arguments[r++]),o=t?g(n).concat(t(n)):g(n),p=o.length,O=0,P;p>O;)P=o[O++],(!u||i.call(n,P))&&(c[P]=n[P]);return c}:h},{"../internals/descriptors":240,"../internals/fails":247,"../internals/indexed-object":257,"../internals/object-get-own-property-symbols":282,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/to-object":308}],276:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/object-define-properties"),g=e("../internals/enum-bug-keys"),b=e("../internals/hidden-keys"),w=e("../internals/html"),f=e("../internals/document-create-element"),v=e("../internals/shared-key"),h=">",l="<",d="prototype",s="script",m=v("IE_PROTO"),c=function(){},a=function(o){return l+s+h+o+l+"/"+s+h},r=function(o){o.write(a("")),o.close();var p=o.parentWindow.Object;return o=null,p},t=function(){var o=f("iframe"),p="java"+s+":",O;return o.style.display="none",w.appendChild(o),o.src=String(p),O=o.contentWindow.document,O.open(),O.write(a("document.F=Object")),O.close(),O.F},i,n=function(){try{i=document.domain&&new ActiveXObject("htmlfile")}catch{}n=i?r(i):t();for(var o=g.length;o--;)delete n[d][g[o]];return n()};b[m]=!0,S.exports=Object.create||function(p,O){var P;return p!==null?(c[d]=u(p),P=new c,c[d]=null,P[m]=p):P=n(),O===void 0?P:y(P,O)}},{"../internals/an-object":223,"../internals/document-create-element":241,"../internals/enum-bug-keys":245,"../internals/hidden-keys":253,"../internals/html":255,"../internals/object-define-properties":277,"../internals/shared-key":299}],277:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/object-define-property"),g=e("../internals/an-object"),b=e("../internals/object-keys");S.exports=u?Object.defineProperties:function(f,v){g(f);for(var h=b(v),l=h.length,d=0,s;l>d;)y.f(f,s=h[d++],v[s]);return f}},{"../internals/an-object":223,"../internals/descriptors":240,"../internals/object-define-property":278,"../internals/object-keys":285}],278:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/ie8-dom-define"),g=e("../internals/an-object"),b=e("../internals/to-primitive"),w=Object.defineProperty;_.f=u?w:function(v,h,l){if(g(v),h=b(h,!0),g(l),y)try{return w(v,h,l)}catch{}if("get"in l||"set"in l)throw TypeError("Accessors not supported");return"value"in l&&(v[h]=l.value),v}},{"../internals/an-object":223,"../internals/descriptors":240,"../internals/ie8-dom-define":256,"../internals/to-primitive":309}],279:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/object-property-is-enumerable"),g=e("../internals/create-property-descriptor"),b=e("../internals/to-indexed-object"),w=e("../internals/to-primitive"),f=e("../internals/has"),v=e("../internals/ie8-dom-define"),h=Object.getOwnPropertyDescriptor;_.f=u?h:function(d,s){if(d=b(d),s=w(s,!0),v)try{return h(d,s)}catch{}if(f(d,s))return g(!y.f.call(d,s),d[s])}},{"../internals/create-property-descriptor":237,"../internals/descriptors":240,"../internals/has":252,"../internals/ie8-dom-define":256,"../internals/object-property-is-enumerable":286,"../internals/to-indexed-object":305,"../internals/to-primitive":309}],280:[function(e,S,_){var u=e("../internals/to-indexed-object"),y=e("../internals/object-get-own-property-names").f,g={}.toString,b=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],w=function(f){try{return y(f)}catch{return b.slice()}};S.exports.f=function(v){return b&&g.call(v)=="[object Window]"?w(v):y(u(v))}},{"../internals/object-get-own-property-names":281,"../internals/to-indexed-object":305}],281:[function(e,S,_){var u=e("../internals/object-keys-internal"),y=e("../internals/enum-bug-keys"),g=y.concat("length","prototype");_.f=Object.getOwnPropertyNames||function(w){return u(w,g)}},{"../internals/enum-bug-keys":245,"../internals/object-keys-internal":284}],282:[function(e,S,_){_.f=Object.getOwnPropertySymbols},{}],283:[function(e,S,_){var u=e("../internals/has"),y=e("../internals/to-object"),g=e("../internals/shared-key"),b=e("../internals/correct-prototype-getter"),w=g("IE_PROTO"),f=Object.prototype;S.exports=b?Object.getPrototypeOf:function(v){return v=y(v),u(v,w)?v[w]:typeof v.constructor=="function"&&v instanceof v.constructor?v.constructor.prototype:v instanceof Object?f:null}},{"../internals/correct-prototype-getter":234,"../internals/has":252,"../internals/shared-key":299,"../internals/to-object":308}],284:[function(e,S,_){var u=e("../internals/has"),y=e("../internals/to-indexed-object"),g=e("../internals/array-includes").indexOf,b=e("../internals/hidden-keys");S.exports=function(w,f){var v=y(w),h=0,l=[],d;for(d in v)!u(b,d)&&u(v,d)&&l.push(d);for(;f.length>h;)u(v,d=f[h++])&&(~g(l,d)||l.push(d));return l}},{"../internals/array-includes":224,"../internals/has":252,"../internals/hidden-keys":253,"../internals/to-indexed-object":305}],285:[function(e,S,_){var u=e("../internals/object-keys-internal"),y=e("../internals/enum-bug-keys");S.exports=Object.keys||function(b){return u(b,y)}},{"../internals/enum-bug-keys":245,"../internals/object-keys-internal":284}],286:[function(e,S,_){var u={}.propertyIsEnumerable,y=Object.getOwnPropertyDescriptor,g=y&&!u.call({1:2},1);_.f=g?function(w){var f=y(this,w);return!!f&&f.enumerable}:u},{}],287:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/a-possible-prototype");S.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var g=!1,b={},w;try{w=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set,w.call(b,[]),g=b instanceof Array}catch{}return function(v,h){return u(v),y(h),g?w.call(v,h):v.__proto__=h,v}}():void 0)},{"../internals/a-possible-prototype":220,"../internals/an-object":223}],288:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/object-keys"),g=e("../internals/to-indexed-object"),b=e("../internals/object-property-is-enumerable").f,w=function(f){return function(v){for(var h=g(v),l=y(h),d=l.length,s=0,m=[],c;d>s;)c=l[s++],(!u||b.call(h,c))&&m.push(f?[c,h[c]]:h[c]);return m}};S.exports={entries:w(!0),values:w(!1)}},{"../internals/descriptors":240,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/to-indexed-object":305}],289:[function(e,S,_){var u=e("../internals/get-built-in"),y=e("../internals/object-get-own-property-names"),g=e("../internals/object-get-own-property-symbols"),b=e("../internals/an-object");S.exports=u("Reflect","ownKeys")||function(f){var v=y.f(b(f)),h=g.f;return h?v.concat(h(f)):v}},{"../internals/an-object":223,"../internals/get-built-in":249,"../internals/object-get-own-property-names":281,"../internals/object-get-own-property-symbols":282}],290:[function(e,S,_){var u=e("../internals/global");S.exports=u},{"../internals/global":251}],291:[function(e,S,_){S.exports=function(u){try{return{error:!1,value:u()}}catch(y){return{error:!0,value:y}}}},{}],292:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/is-object"),g=e("../internals/new-promise-capability");S.exports=function(b,w){if(u(b),y(w)&&w.constructor===b)return w;var f=g.f(b),v=f.resolve;return v(w),f.promise}},{"../internals/an-object":223,"../internals/is-object":263,"../internals/new-promise-capability":273}],293:[function(e,S,_){var u=e("../internals/redefine");S.exports=function(y,g,b){for(var w in g)u(y,w,g[w],b);return y}},{"../internals/redefine":294}],294:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/create-non-enumerable-property"),g=e("../internals/has"),b=e("../internals/set-global"),w=e("../internals/inspect-source"),f=e("../internals/internal-state"),v=f.get,h=f.enforce,l=String(String).split("String");(S.exports=function(d,s,m,c){var a=c?!!c.unsafe:!1,r=c?!!c.enumerable:!1,t=c?!!c.noTargetGet:!1;if(typeof m=="function"&&(typeof s=="string"&&!g(m,"name")&&y(m,"name",s),h(m).source=l.join(typeof s=="string"?s:"")),d===u){r?d[s]=m:b(s,m);return}else a?!t&&d[s]&&(r=!0):delete d[s];r?d[s]=m:y(d,s,m)})(Function.prototype,"toString",function(){return typeof this=="function"&&v(this).source||w(this)})},{"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/has":252,"../internals/inspect-source":258,"../internals/internal-state":259,"../internals/set-global":296}],295:[function(e,S,_){S.exports=function(u){if(u==null)throw TypeError("Can't call method on "+u);return u}},{}],296:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/create-non-enumerable-property");S.exports=function(g,b){try{y(u,g,b)}catch{u[g]=b}return b}},{"../internals/create-non-enumerable-property":236,"../internals/global":251}],297:[function(e,S,_){var u=e("../internals/get-built-in"),y=e("../internals/object-define-property"),g=e("../internals/well-known-symbol"),b=e("../internals/descriptors"),w=g("species");S.exports=function(f){var v=u(f),h=y.f;b&&v&&!v[w]&&h(v,w,{configurable:!0,get:function(){return this}})}},{"../internals/descriptors":240,"../internals/get-built-in":249,"../internals/object-define-property":278,"../internals/well-known-symbol":314}],298:[function(e,S,_){var u=e("../internals/object-define-property").f,y=e("../internals/has"),g=e("../internals/well-known-symbol"),b=g("toStringTag");S.exports=function(w,f,v){w&&!y(w=v?w:w.prototype,b)&&u(w,b,{configurable:!0,value:f})}},{"../internals/has":252,"../internals/object-define-property":278,"../internals/well-known-symbol":314}],299:[function(e,S,_){var u=e("../internals/shared"),y=e("../internals/uid"),g=u("keys");S.exports=function(b){return g[b]||(g[b]=y(b))}},{"../internals/shared":301,"../internals/uid":311}],300:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/set-global"),g="__core-js_shared__",b=u[g]||y(g,{});S.exports=b},{"../internals/global":251,"../internals/set-global":296}],301:[function(e,S,_){var u=e("../internals/is-pure"),y=e("../internals/shared-store");(S.exports=function(g,b){return y[g]||(y[g]=b!==void 0?b:{})})("versions",[]).push({version:"3.6.5",mode:u?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})},{"../internals/is-pure":264,"../internals/shared-store":300}],302:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/a-function"),g=e("../internals/well-known-symbol"),b=g("species");S.exports=function(w,f){var v=u(w).constructor,h;return v===void 0||(h=u(v)[b])==null?f:y(h)}},{"../internals/a-function":219,"../internals/an-object":223,"../internals/well-known-symbol":314}],303:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/fails"),g=e("../internals/classof-raw"),b=e("../internals/function-bind-context"),w=e("../internals/html"),f=e("../internals/document-create-element"),v=e("../internals/engine-is-ios"),h=u.location,l=u.setImmediate,d=u.clearImmediate,s=u.process,m=u.MessageChannel,c=u.Dispatch,a=0,r={},t="onreadystatechange",i,n,o,p=function(z){if(r.hasOwnProperty(z)){var D=r[z];delete r[z],D()}},O=function(z){return function(){p(z)}},P=function(z){p(z.data)},B=function(z){u.postMessage(z+"",h.protocol+"//"+h.host)};(!l||!d)&&(l=function(D){for(var M=[],I=1;arguments.length>I;)M.push(arguments[I++]);return r[++a]=function(){(typeof D=="function"?D:Function(D)).apply(void 0,M)},i(a),a},d=function(D){delete r[D]},g(s)=="process"?i=function(z){s.nextTick(O(z))}:c&&c.now?i=function(z){c.now(O(z))}:m&&!v?(n=new m,o=n.port2,n.port1.onmessage=P,i=b(o.postMessage,o,1)):u.addEventListener&&typeof postMessage=="function"&&!u.importScripts&&!y(B)&&h.protocol!=="file:"?(i=B,u.addEventListener("message",P,!1)):t in f("script")?i=function(z){w.appendChild(f("script"))[t]=function(){w.removeChild(this),p(z)}}:i=function(z){setTimeout(O(z),0)}),S.exports={set:l,clear:d}},{"../internals/classof-raw":230,"../internals/document-create-element":241,"../internals/engine-is-ios":242,"../internals/fails":247,"../internals/function-bind-context":248,"../internals/global":251,"../internals/html":255}],304:[function(e,S,_){var u=e("../internals/to-integer"),y=Math.max,g=Math.min;S.exports=function(b,w){var f=u(b);return f<0?y(f+w,0):g(f,w)}},{"../internals/to-integer":306}],305:[function(e,S,_){var u=e("../internals/indexed-object"),y=e("../internals/require-object-coercible");S.exports=function(g){return u(y(g))}},{"../internals/indexed-object":257,"../internals/require-object-coercible":295}],306:[function(e,S,_){var u=Math.ceil,y=Math.floor;S.exports=function(g){return isNaN(g=+g)?0:(g>0?y:u)(g)}},{}],307:[function(e,S,_){var u=e("../internals/to-integer"),y=Math.min;S.exports=function(g){return g>0?y(u(g),9007199254740991):0}},{"../internals/to-integer":306}],308:[function(e,S,_){var u=e("../internals/require-object-coercible");S.exports=function(y){return Object(u(y))}},{"../internals/require-object-coercible":295}],309:[function(e,S,_){var u=e("../internals/is-object");S.exports=function(y,g){if(!u(y))return y;var b,w;if(g&&typeof(b=y.toString)=="function"&&!u(w=b.call(y))||typeof(b=y.valueOf)=="function"&&!u(w=b.call(y))||!g&&typeof(b=y.toString)=="function"&&!u(w=b.call(y)))return w;throw TypeError("Can't convert object to primitive value")}},{"../internals/is-object":263}],310:[function(e,S,_){var u=e("../internals/well-known-symbol"),y=u("toStringTag"),g={};g[y]="z",S.exports=String(g)==="[object z]"},{"../internals/well-known-symbol":314}],311:[function(e,S,_){var u=0,y=Math.random();S.exports=function(g){return"Symbol("+String(g===void 0?"":g)+")_"+(++u+y).toString(36)}},{}],312:[function(e,S,_){var u=e("../internals/native-symbol");S.exports=u&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},{"../internals/native-symbol":271}],313:[function(e,S,_){var u=e("../internals/well-known-symbol");_.f=u},{"../internals/well-known-symbol":314}],314:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/shared"),g=e("../internals/has"),b=e("../internals/uid"),w=e("../internals/native-symbol"),f=e("../internals/use-symbol-as-uid"),v=y("wks"),h=u.Symbol,l=f?h:h&&h.withoutSetter||b;S.exports=function(d){return g(v,d)||(w&&g(h,d)?v[d]=h[d]:v[d]=l("Symbol."+d)),v[d]}},{"../internals/global":251,"../internals/has":252,"../internals/native-symbol":271,"../internals/shared":301,"../internals/uid":311,"../internals/use-symbol-as-uid":312}],315:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/array-iteration").findIndex,g=e("../internals/add-to-unscopables"),b=e("../internals/array-method-uses-to-length"),w="findIndex",f=!0,v=b(w);w in[]&&Array(1)[w](function(){f=!1}),u({target:"Array",proto:!0,forced:f||!v},{findIndex:function(l){return y(this,l,arguments.length>1?arguments[1]:void 0)}}),g(w)},{"../internals/add-to-unscopables":221,"../internals/array-iteration":225,"../internals/array-method-uses-to-length":226,"../internals/export":246}],316:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/array-iteration").find,g=e("../internals/add-to-unscopables"),b=e("../internals/array-method-uses-to-length"),w="find",f=!0,v=b(w);w in[]&&Array(1)[w](function(){f=!1}),u({target:"Array",proto:!0,forced:f||!v},{find:function(l){return y(this,l,arguments.length>1?arguments[1]:void 0)}}),g(w)},{"../internals/add-to-unscopables":221,"../internals/array-iteration":225,"../internals/array-method-uses-to-length":226,"../internals/export":246}],317:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/array-includes").includes,g=e("../internals/add-to-unscopables"),b=e("../internals/array-method-uses-to-length"),w=b("indexOf",{ACCESSORS:!0,1:0});u({target:"Array",proto:!0,forced:!w},{includes:function(v){return y(this,v,arguments.length>1?arguments[1]:void 0)}}),g("includes")},{"../internals/add-to-unscopables":221,"../internals/array-includes":224,"../internals/array-method-uses-to-length":226,"../internals/export":246}],318:[function(e,S,_){var u=e("../internals/to-indexed-object"),y=e("../internals/add-to-unscopables"),g=e("../internals/iterators"),b=e("../internals/internal-state"),w=e("../internals/define-iterator"),f="Array Iterator",v=b.set,h=b.getterFor(f);S.exports=w(Array,"Array",function(l,d){v(this,{type:f,target:u(l),index:0,kind:d})},function(){var l=h(this),d=l.target,s=l.kind,m=l.index++;return!d||m>=d.length?(l.target=void 0,{value:void 0,done:!0}):s=="keys"?{value:m,done:!1}:s=="values"?{value:d[m],done:!1}:{value:[m,d[m]],done:!1}},"values"),g.Arguments=g.Array,y("keys"),y("values"),y("entries")},{"../internals/add-to-unscopables":221,"../internals/define-iterator":238,"../internals/internal-state":259,"../internals/iterators":268,"../internals/to-indexed-object":305}],319:[function(e,S,_){var u=e("../internals/export");u({target:"Number",stat:!0},{isNaN:function(g){return g!=g}})},{"../internals/export":246}],320:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/object-assign");u({target:"Object",stat:!0,forced:Object.assign!==y},{assign:y})},{"../internals/export":246,"../internals/object-assign":275}],321:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/to-object"),g=e("../internals/object-keys"),b=e("../internals/fails"),w=b(function(){g(1)});u({target:"Object",stat:!0,forced:w},{keys:function(v){return g(y(v))}})},{"../internals/export":246,"../internals/fails":247,"../internals/object-keys":285,"../internals/to-object":308}],322:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/object-to-array").values;u({target:"Object",stat:!0},{values:function(b){return y(b)}})},{"../internals/export":246,"../internals/object-to-array":288}],323:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/is-pure"),g=e("../internals/global"),b=e("../internals/get-built-in"),w=e("../internals/native-promise-constructor"),f=e("../internals/redefine"),v=e("../internals/redefine-all"),h=e("../internals/set-to-string-tag"),l=e("../internals/set-species"),d=e("../internals/is-object"),s=e("../internals/a-function"),m=e("../internals/an-instance"),c=e("../internals/classof-raw"),a=e("../internals/inspect-source"),r=e("../internals/iterate"),t=e("../internals/check-correctness-of-iteration"),i=e("../internals/species-constructor"),n=e("../internals/task").set,o=e("../internals/microtask"),p=e("../internals/promise-resolve"),O=e("../internals/host-report-errors"),P=e("../internals/new-promise-capability"),B=e("../internals/perform"),z=e("../internals/internal-state"),D=e("../internals/is-forced"),M=e("../internals/well-known-symbol"),I=e("../internals/engine-v8-version"),T=M("species"),C="Promise",E=z.get,A=z.set,L=z.getterFor(C),$=w,W=g.TypeError,U=g.document,N=g.process,j=b("fetch"),F=P.f,V=F,re=c(N)=="process",ee=!!(U&&U.createEvent&&g.dispatchEvent),ce="unhandledrejection",ye="rejectionhandled",ge=0,oe=1,J=2,Q=1,he=2,xe,ne,se,Ce,q=D(C,function(){var Ue=a($)!==String($);if(!Ue&&(I===66||!re&&typeof PromiseRejectionEvent!="function")||y&&!$.prototype.finally)return!0;if(I>=51&&/native code/.test($))return!1;var Ve=$.resolve(1),Qe=function(ae){ae(function(){},function(){})},tt=Ve.constructor={};return tt[T]=Qe,!(Ve.then(function(){})instanceof Qe)}),G=q||!t(function(Ue){$.all(Ue).catch(function(){})}),Y=function(Ue){var Ve;return d(Ue)&&typeof(Ve=Ue.then)=="function"?Ve:!1},fe=function(Ue,Ve,Qe){if(!Ve.notified){Ve.notified=!0;var tt=Ve.reactions;o(function(){for(var ae=Ve.value,Re=Ve.state==oe,be=0;tt.length>be;){var Ee=tt[be++],pe=Re?Ee.ok:Ee.fail,Pe=Ee.resolve,te=Ee.reject,He=Ee.domain,it,K,Me;try{pe?(Re||(Ve.rejection===he&&Ye(Ue,Ve),Ve.rejection=Q),pe===!0?it=ae:(He&&He.enter(),it=pe(ae),He&&(He.exit(),Me=!0)),it===Ee.promise?te(W("Promise-chain cycle")):(K=Y(it))?K.call(it,Pe,te):Pe(it)):te(ae)}catch(Le){He&&!Me&&He.exit(),te(Le)}}Ve.reactions=[],Ve.notified=!1,Qe&&!Ve.rejection&&_e(Ue,Ve)})}},we=function(Ue,Ve,Qe){var tt,ae;ee?(tt=U.createEvent("Event"),tt.promise=Ve,tt.reason=Qe,tt.initEvent(Ue,!1,!0),g.dispatchEvent(tt)):tt={promise:Ve,reason:Qe},(ae=g["on"+Ue])?ae(tt):Ue===ce&&O("Unhandled promise rejection",Qe)},_e=function(Ue,Ve){n.call(g,function(){var Qe=Ve.value,tt=je(Ve),ae;if(tt&&(ae=B(function(){re?N.emit("unhandledRejection",Qe,Ue):we(ce,Ue,Qe)}),Ve.rejection=re||je(Ve)?he:Q,ae.error))throw ae.value})},je=function(Ue){return Ue.rejection!==Q&&!Ue.parent},Ye=function(Ue,Ve){n.call(g,function(){re?N.emit("rejectionHandled",Ue):we(ye,Ue,Ve.value)})},nt=function(Ue,Ve,Qe,tt){return function(ae){Ue(Ve,Qe,ae,tt)}},ut=function(Ue,Ve,Qe,tt){Ve.done||(Ve.done=!0,tt&&(Ve=tt),Ve.value=Qe,Ve.state=J,fe(Ue,Ve,!0))},ot=function(Ue,Ve,Qe,tt){if(!Ve.done){Ve.done=!0,tt&&(Ve=tt);try{if(Ue===Qe)throw W("Promise can't be resolved itself");var ae=Y(Qe);ae?o(function(){var Re={done:!1};try{ae.call(Qe,nt(ot,Ue,Re,Ve),nt(ut,Ue,Re,Ve))}catch(be){ut(Ue,Re,be,Ve)}}):(Ve.value=Qe,Ve.state=oe,fe(Ue,Ve,!1))}catch(Re){ut(Ue,{done:!1},Re,Ve)}}};q&&($=function(Ve){m(this,$,C),s(Ve),xe.call(this);var Qe=E(this);try{Ve(nt(ot,this,Qe),nt(ut,this,Qe))}catch(tt){ut(this,Qe,tt)}},xe=function(Ve){A(this,{type:C,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:ge,value:void 0})},xe.prototype=v($.prototype,{then:function(Ve,Qe){var tt=L(this),ae=F(i(this,$));return ae.ok=typeof Ve=="function"?Ve:!0,ae.fail=typeof Qe=="function"&&Qe,ae.domain=re?N.domain:void 0,tt.parent=!0,tt.reactions.push(ae),tt.state!=ge&&fe(this,tt,!1),ae.promise},catch:function(Ue){return this.then(void 0,Ue)}}),ne=function(){var Ue=new xe,Ve=E(Ue);this.promise=Ue,this.resolve=nt(ot,Ue,Ve),this.reject=nt(ut,Ue,Ve)},P.f=F=function(Ue){return Ue===$||Ue===se?new ne(Ue):V(Ue)},!y&&typeof w=="function"&&(Ce=w.prototype.then,f(w.prototype,"then",function(Ve,Qe){var tt=this;return new $(function(ae,Re){Ce.call(tt,ae,Re)}).then(Ve,Qe)},{unsafe:!0}),typeof j=="function"&&u({global:!0,enumerable:!0,forced:!0},{fetch:function(Ve){return p($,j.apply(g,arguments))}}))),u({global:!0,wrap:!0,forced:q},{Promise:$}),h($,C,!1,!0),l(C),se=b(C),u({target:C,stat:!0,forced:q},{reject:function(Ve){var Qe=F(this);return Qe.reject.call(void 0,Ve),Qe.promise}}),u({target:C,stat:!0,forced:y||q},{resolve:function(Ve){return p(y&&this===se?$:this,Ve)}}),u({target:C,stat:!0,forced:G},{all:function(Ve){var Qe=this,tt=F(Qe),ae=tt.resolve,Re=tt.reject,be=B(function(){var Ee=s(Qe.resolve),pe=[],Pe=0,te=1;r(Ve,function(He){var it=Pe++,K=!1;pe.push(void 0),te++,Ee.call(Qe,He).then(function(Me){K||(K=!0,pe[it]=Me,--te||ae(pe))},Re)}),--te||ae(pe)});return be.error&&Re(be.value),tt.promise},race:function(Ve){var Qe=this,tt=F(Qe),ae=tt.reject,Re=B(function(){var be=s(Qe.resolve);r(Ve,function(Ee){be.call(Qe,Ee).then(tt.resolve,ae)})});return Re.error&&ae(Re.value),tt.promise}})},{"../internals/a-function":219,"../internals/an-instance":222,"../internals/check-correctness-of-iteration":229,"../internals/classof-raw":230,"../internals/engine-v8-version":244,"../internals/export":246,"../internals/get-built-in":249,"../internals/global":251,"../internals/host-report-errors":254,"../internals/inspect-source":258,"../internals/internal-state":259,"../internals/is-forced":262,"../internals/is-object":263,"../internals/is-pure":264,"../internals/iterate":266,"../internals/microtask":269,"../internals/native-promise-constructor":270,"../internals/new-promise-capability":273,"../internals/perform":291,"../internals/promise-resolve":292,"../internals/redefine":294,"../internals/redefine-all":293,"../internals/set-species":297,"../internals/set-to-string-tag":298,"../internals/species-constructor":302,"../internals/task":303,"../internals/well-known-symbol":314}],324:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/to-absolute-index"),g=String.fromCharCode,b=String.fromCodePoint,w=!!b&&b.length!=1;u({target:"String",stat:!0,forced:w},{fromCodePoint:function(v){for(var h=[],l=arguments.length,d=0,s;l>d;){if(s=+arguments[d++],y(s,1114111)!==s)throw RangeError(s+" is not a valid code point");h.push(s<65536?g(s):g(((s-=65536)>>10)+55296,s%1024+56320))}return h.join("")}})},{"../internals/export":246,"../internals/to-absolute-index":304}],325:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/not-a-regexp"),g=e("../internals/require-object-coercible"),b=e("../internals/correct-is-regexp-logic");u({target:"String",proto:!0,forced:!b("includes")},{includes:function(f){return!!~String(g(this)).indexOf(y(f),arguments.length>1?arguments[1]:void 0)}})},{"../internals/correct-is-regexp-logic":233,"../internals/export":246,"../internals/not-a-regexp":274,"../internals/require-object-coercible":295}],326:[function(e,S,_){var u=e("../internals/define-well-known-symbol");u("asyncIterator")},{"../internals/define-well-known-symbol":239}],327:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/global"),g=e("../internals/get-built-in"),b=e("../internals/is-pure"),w=e("../internals/descriptors"),f=e("../internals/native-symbol"),v=e("../internals/use-symbol-as-uid"),h=e("../internals/fails"),l=e("../internals/has"),d=e("../internals/is-array"),s=e("../internals/is-object"),m=e("../internals/an-object"),c=e("../internals/to-object"),a=e("../internals/to-indexed-object"),r=e("../internals/to-primitive"),t=e("../internals/create-property-descriptor"),i=e("../internals/object-create"),n=e("../internals/object-keys"),o=e("../internals/object-get-own-property-names"),p=e("../internals/object-get-own-property-names-external"),O=e("../internals/object-get-own-property-symbols"),P=e("../internals/object-get-own-property-descriptor"),B=e("../internals/object-define-property"),z=e("../internals/object-property-is-enumerable"),D=e("../internals/create-non-enumerable-property"),M=e("../internals/redefine"),I=e("../internals/shared"),T=e("../internals/shared-key"),C=e("../internals/hidden-keys"),E=e("../internals/uid"),A=e("../internals/well-known-symbol"),L=e("../internals/well-known-symbol-wrapped"),$=e("../internals/define-well-known-symbol"),W=e("../internals/set-to-string-tag"),U=e("../internals/internal-state"),N=e("../internals/array-iteration").forEach,j=T("hidden"),F="Symbol",V="prototype",re=A("toPrimitive"),ee=U.set,ce=U.getterFor(F),ye=Object[V],ge=y.Symbol,oe=g("JSON","stringify"),J=P.f,Q=B.f,he=p.f,xe=z.f,ne=I("symbols"),se=I("op-symbols"),Ce=I("string-to-symbol-registry"),q=I("symbol-to-string-registry"),G=I("wks"),Y=y.QObject,fe=!Y||!Y[V]||!Y[V].findChild,we=w&&h(function(){return i(Q({},"a",{get:function(){return Q(this,"a",{value:7}).a}})).a!=7})?function(ae,Re,be){var Ee=J(ye,Re);Ee&&delete ye[Re],Q(ae,Re,be),Ee&&ae!==ye&&Q(ye,Re,Ee)}:Q,_e=function(ae,Re){var be=ne[ae]=i(ge[V]);return ee(be,{type:F,tag:ae,description:Re}),w||(be.description=Re),be},je=v?function(ae){return typeof ae=="symbol"}:function(ae){return Object(ae)instanceof ge},Ye=function(Re,be,Ee){Re===ye&&Ye(se,be,Ee),m(Re);var pe=r(be,!0);return m(Ee),l(ne,pe)?(Ee.enumerable?(l(Re,j)&&Re[j][pe]&&(Re[j][pe]=!1),Ee=i(Ee,{enumerable:t(0,!1)})):(l(Re,j)||Q(Re,j,t(1,{})),Re[j][pe]=!0),we(Re,pe,Ee)):Q(Re,pe,Ee)},nt=function(Re,be){m(Re);var Ee=a(be),pe=n(Ee).concat(Qe(Ee));return N(pe,function(Pe){(!w||ot.call(Ee,Pe))&&Ye(Re,Pe,Ee[Pe])}),Re},ut=function(Re,be){return be===void 0?i(Re):nt(i(Re),be)},ot=function(Re){var be=r(Re,!0),Ee=xe.call(this,be);return this===ye&&l(ne,be)&&!l(se,be)?!1:Ee||!l(this,be)||!l(ne,be)||l(this,j)&&this[j][be]?Ee:!0},Ue=function(Re,be){var Ee=a(Re),pe=r(be,!0);if(!(Ee===ye&&l(ne,pe)&&!l(se,pe))){var Pe=J(Ee,pe);return Pe&&l(ne,pe)&&!(l(Ee,j)&&Ee[j][pe])&&(Pe.enumerable=!0),Pe}},Ve=function(Re){var be=he(a(Re)),Ee=[];return N(be,function(pe){!l(ne,pe)&&!l(C,pe)&&Ee.push(pe)}),Ee},Qe=function(Re){var be=Re===ye,Ee=he(be?se:a(Re)),pe=[];return N(Ee,function(Pe){l(ne,Pe)&&(!be||l(ye,Pe))&&pe.push(ne[Pe])}),pe};if(f||(ge=function(){if(this instanceof ge)throw TypeError("Symbol is not a constructor");var Re=!arguments.length||arguments[0]===void 0?void 0:String(arguments[0]),be=E(Re),Ee=function(pe){this===ye&&Ee.call(se,pe),l(this,j)&&l(this[j],be)&&(this[j][be]=!1),we(this,be,t(1,pe))};return w&&fe&&we(ye,be,{configurable:!0,set:Ee}),_e(be,Re)},M(ge[V],"toString",function(){return ce(this).tag}),M(ge,"withoutSetter",function(ae){return _e(E(ae),ae)}),z.f=ot,B.f=Ye,P.f=Ue,o.f=p.f=Ve,O.f=Qe,L.f=function(ae){return _e(A(ae),ae)},w&&(Q(ge[V],"description",{configurable:!0,get:function(){return ce(this).description}}),b||M(ye,"propertyIsEnumerable",ot,{unsafe:!0}))),u({global:!0,wrap:!0,forced:!f,sham:!f},{Symbol:ge}),N(n(G),function(ae){$(ae)}),u({target:F,stat:!0,forced:!f},{for:function(ae){var Re=String(ae);if(l(Ce,Re))return Ce[Re];var be=ge(Re);return Ce[Re]=be,q[be]=Re,be},keyFor:function(Re){if(!je(Re))throw TypeError(Re+" is not a symbol");if(l(q,Re))return q[Re]},useSetter:function(){fe=!0},useSimple:function(){fe=!1}}),u({target:"Object",stat:!0,forced:!f,sham:!w},{create:ut,defineProperty:Ye,defineProperties:nt,getOwnPropertyDescriptor:Ue}),u({target:"Object",stat:!0,forced:!f},{getOwnPropertyNames:Ve,getOwnPropertySymbols:Qe}),u({target:"Object",stat:!0,forced:h(function(){O.f(1)})},{getOwnPropertySymbols:function(Re){return O.f(c(Re))}}),oe){var tt=!f||h(function(){var ae=ge();return oe([ae])!="[null]"||oe({a:ae})!="{}"||oe(Object(ae))!="{}"});u({target:"JSON",stat:!0,forced:tt},{stringify:function(Re,be,Ee){for(var pe=[Re],Pe=1,te;arguments.length>Pe;)pe.push(arguments[Pe++]);if(te=be,!(!s(be)&&Re===void 0||je(Re)))return d(be)||(be=function(He,it){if(typeof te=="function"&&(it=te.call(this,He,it)),!je(it))return it}),pe[1]=be,oe.apply(null,pe)}})}ge[V][re]||D(ge[V],re,ge[V].valueOf),W(ge,F),C[j]=!0},{"../internals/an-object":223,"../internals/array-iteration":225,"../internals/create-non-enumerable-property":236,"../internals/create-property-descriptor":237,"../internals/define-well-known-symbol":239,"../internals/descriptors":240,"../internals/export":246,"../internals/fails":247,"../internals/get-built-in":249,"../internals/global":251,"../internals/has":252,"../internals/hidden-keys":253,"../internals/internal-state":259,"../internals/is-array":261,"../internals/is-object":263,"../internals/is-pure":264,"../internals/native-symbol":271,"../internals/object-create":276,"../internals/object-define-property":278,"../internals/object-get-own-property-descriptor":279,"../internals/object-get-own-property-names":281,"../internals/object-get-own-property-names-external":280,"../internals/object-get-own-property-symbols":282,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/redefine":294,"../internals/set-to-string-tag":298,"../internals/shared":301,"../internals/shared-key":299,"../internals/to-indexed-object":305,"../internals/to-object":308,"../internals/to-primitive":309,"../internals/uid":311,"../internals/use-symbol-as-uid":312,"../internals/well-known-symbol":314,"../internals/well-known-symbol-wrapped":313}],328:[function(e,S,_){(function(u){function y(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(p){return typeof p}:y=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},y(n)}function g(n){return Array.isArray?Array.isArray(n):i(n)==="[object Array]"}_.isArray=g;function b(n){return typeof n=="boolean"}_.isBoolean=b;function w(n){return n===null}_.isNull=w;function f(n){return n==null}_.isNullOrUndefined=f;function v(n){return typeof n=="number"}_.isNumber=v;function h(n){return typeof n=="string"}_.isString=h;function l(n){return y(n)==="symbol"}_.isSymbol=l;function d(n){return n===void 0}_.isUndefined=d;function s(n){return i(n)==="[object RegExp]"}_.isRegExp=s;function m(n){return y(n)==="object"&&n!==null}_.isObject=m;function c(n){return i(n)==="[object Date]"}_.isDate=c;function a(n){return i(n)==="[object Error]"||n instanceof Error}_.isError=a;function r(n){return typeof n=="function"}_.isFunction=r;function t(n){return n===null||typeof n=="boolean"||typeof n=="number"||typeof n=="string"||y(n)==="symbol"||typeof n>"u"}_.isPrimitive=t,_.isBuffer=u.isBuffer;function i(n){return Object.prototype.toString.call(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":388}],329:[function(e,S,_){(function(u){var y=e("elliptic"),g=e("bn.js");S.exports=function(h){return new w(h)};var b={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}};b.p224=b.secp224r1,b.p256=b.secp256r1=b.prime256v1,b.p192=b.secp192r1=b.prime192v1,b.p384=b.secp384r1,b.p521=b.secp521r1;function w(v){this.curveType=b[v],this.curveType||(this.curveType={name:v}),this.curve=new y.ec(this.curveType.name),this.keys=void 0}w.prototype.generateKeys=function(v,h){return this.keys=this.curve.genKeyPair(),this.getPublicKey(v,h)},w.prototype.computeSecret=function(v,h,l){h=h||"utf8",u.isBuffer(v)||(v=new u(v,h));var d=this.curve.keyFromPublic(v).getPublic(),s=d.mul(this.keys.getPrivate()).getX();return f(s,l,this.curveType.byteLength)},w.prototype.getPublicKey=function(v,h){var l=this.keys.getPublic(h==="compressed",!0);return h==="hybrid"&&(l[l.length-1]%2?l[0]=7:l[0]=6),f(l,v)},w.prototype.getPrivateKey=function(v){return f(this.keys.getPrivate(),v)},w.prototype.setPublicKey=function(v,h){return h=h||"utf8",u.isBuffer(v)||(v=new u(v,h)),this.keys._importPublic(v),this},w.prototype.setPrivateKey=function(v,h){h=h||"utf8",u.isBuffer(v)||(v=new u(v,h));var l=new g(v);return l=l.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(l),this};function f(v,h,l){Array.isArray(v)||(v=v.toArray());var d=new u(v);if(l&&d.lengthm){var c=d==="rmd160"?new f:v(d);s=c.update(s).digest()}else s.lengthw?h=v(h):h.length"u"?"undefined":u(_))=="object"&&typeof S<"u"?S.exports=g():y.dayjs=g()})(void 0,function(){var y="millisecond",g="second",b="minute",w="hour",f="day",v="week",h="month",l="quarter",d="year",s="date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d+)?$/,c=/\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,a=function(M,I,T){var C=String(M);return!C||C.length>=I?M:""+Array(I+1-C.length).join(T)+M},r={s:a,z:function(M){var I=-M.utcOffset(),T=Math.abs(I),C=Math.floor(T/60),E=T%60;return(I<=0?"+":"-")+a(C,2,"0")+":"+a(E,2,"0")},m:function D(M,I){if(M.date()"u"?"undefined":u(_))=="object"&&typeof S<"u"?S.exports=g():y.dayjs_plugin_customParseFormat=g()})(void 0,function(){var y,g=/(\[[^[]*\])|([-:/.()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,b=/\d\d/,w=/\d\d?/,f=/\d*[^\s\d-:/()]+/,v=function(c){return function(a){this[c]=+a}},h=[/[+-]\d\d:?\d\d/,function(m){var c,a;(this.zone||(this.zone={})).offset=(c=m.match(/([+-]|\d\d)/g),(a=60*c[1]+ +c[2])===0?0:c[0]==="+"?-a:a)}],l=function(c){var a=y[c];return a&&(a.indexOf?a:a.s.concat(a.f))},d={A:[/[AP]M/,function(m){this.afternoon=m==="PM"}],a:[/[ap]m/,function(m){this.afternoon=m==="pm"}],S:[/\d/,function(m){this.milliseconds=100*+m}],SS:[b,function(m){this.milliseconds=10*+m}],SSS:[/\d{3}/,function(m){this.milliseconds=+m}],s:[w,v("seconds")],ss:[w,v("seconds")],m:[w,v("minutes")],mm:[w,v("minutes")],H:[w,v("hours")],h:[w,v("hours")],HH:[w,v("hours")],hh:[w,v("hours")],D:[w,v("day")],DD:[b,v("day")],Do:[f,function(m){var c=y.ordinal,a=m.match(/\d+/);if(this.day=a[0],c)for(var r=1;r<=31;r+=1)c(r).replace(/\[|\]/g,"")===m&&(this.day=r)}],M:[w,v("month")],MM:[b,v("month")],MMM:[f,function(m){var c=l("months"),a=(l("monthsShort")||c.map(function(r){return r.substr(0,3)})).indexOf(m)+1;if(a<1)throw new Error;this.month=a%12||a}],MMMM:[f,function(m){var c=l("months").indexOf(m)+1;if(c<1)throw new Error;this.month=c%12||c}],Y:[/[+-]?\d+/,v("year")],YY:[b,function(m){m=+m,this.year=m+(m>68?1900:2e3)}],YYYY:[/\d{4}/,v("year")],Z:h,ZZ:h},s=function(c,a,r){try{var t=function($){for(var W=$.match(g),U=W.length,N=0;N0?n-1:D.getMonth());var C=p||0,E=O||0,A=P||0,L=B||0;return z?new Date(Date.UTC(I,T,M,C,E,A,L+60*z.offset*1e3)):r?new Date(Date.UTC(I,T,M,C,E,A,L)):new Date(I,T,M,C,E,A,L)}catch{return new Date("")}};return function(m,c,a){var r=c.prototype,t=r.parse;r.parse=function(i){var n=i.date,o=i.utc,p=i.args;this.$u=o;var O=p[1];if(typeof O=="string"){var P=p[2]===!0,B=p[3]===!0,z=P||B,D=p[2];B&&(D=p[2]),P||(y=D?a.Ls[D]:this.$locale()),this.$d=s(n,O,o),this.init(),D&&D!==!0&&(this.$L=this.locale(D).$L),z&&n!==this.format(O)&&(this.$d=new Date(""))}else if(O instanceof Array)for(var M=O.length,I=1;I<=M;I+=1){p[1]=O[I-1];var T=a.apply(this,p);if(T.isValid()){this.$d=T.$d,this.$L=T.$L,this.init();break}I===M&&(this.$d=new Date(""))}else t.call(this,i)}}})},{}],338:[function(e,S,_){function u(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(b){return typeof b}:u=function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},u(y)}(function(y,g){(typeof _>"u"?"undefined":u(_))=="object"&&typeof S<"u"?S.exports=g():y.dayjs_plugin_utc=g()})(void 0,function(){return function(y,g,b){var w=new Date().getTimezoneOffset(),f=g.prototype;b.utc=function(c){return new g({date:c,utc:!0,args:arguments})},f.utc=function(){return b(this.toDate(),{locale:this.$L,utc:!0})},f.local=function(){return b(this.toDate(),{locale:this.$L,utc:!1})};var v=f.parse;f.parse=function(c){c.utc&&(this.$u=!0),this.$utils().u(c.$offset)||(this.$offset=c.$offset),v.call(this,c)};var h=f.init;f.init=function(){if(this.$u){var c=this.$d;this.$y=c.getUTCFullYear(),this.$M=c.getUTCMonth(),this.$D=c.getUTCDate(),this.$W=c.getUTCDay(),this.$H=c.getUTCHours(),this.$m=c.getUTCMinutes(),this.$s=c.getUTCSeconds(),this.$ms=c.getUTCMilliseconds()}else h.call(this)};var l=f.utcOffset;f.utcOffset=function(c,a){var r=this.$utils().u;if(r(c))return this.$u?0:r(this.$offset)?l.call(this):this.$offset;var t=Math.abs(c)<=16?60*c:c,i=this;return a?(i.$offset=t,i.$u=c===0,i):(c!==0?(i=this.local().add(t+w,"minute")).$offset=t:i=this.utc(),i)};var d=f.format;f.format=function(c){var a=c||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,a)},f.valueOf=function(){var c=this.$utils().u(this.$offset)?0:this.$offset+w;return this.$d.valueOf()-6e4*c},f.isUTC=function(){return!!this.$u},f.toISOString=function(){return this.toDate().toISOString()},f.toString=function(){return this.toDate().toUTCString()};var s=f.toDate;f.toDate=function(c){return c==="s"&&this.$offset?b(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():s.call(this)};var m=f.diff;f.diff=function(c,a,r){var t=this.local(),i=b(c).local();return m.call(t,i,a,r)}}})},{}],339:[function(e,S,_){_.utils=e("./des/utils"),_.Cipher=e("./des/cipher"),_.DES=e("./des/des"),_.CBC=e("./des/cbc"),_.EDE=e("./des/ede")},{"./des/cbc":340,"./des/cipher":341,"./des/des":342,"./des/ede":343,"./des/utils":344}],340:[function(e,S,_){var u=e("minimalistic-assert"),y=e("inherits"),g={};function b(f){u.equal(f.length,8,"Invalid IV length"),this.iv=new Array(8);for(var v=0;v0;v--)w+=this._buffer(b,w),f+=this._flushBuffer(h,f);return w+=this._buffer(b,w),h},y.prototype.final=function(b){var w;b&&(w=this.update(b));var f;return this.type==="encrypt"?f=this._finalEncrypt():f=this._finalDecrypt(),w?w.concat(f):f},y.prototype._pad=function(b,w){if(w===0)return!1;for(;w>>1];s=g.r28shl(s,a),m=g.r28shl(m,a),g.pc2(s,m,l.keys,c)}},f.prototype._update=function(l,d,s,m){var c=this._desState,a=g.readUInt32BE(l,d),r=g.readUInt32BE(l,d+4);g.ip(a,r,c.tmp,0),a=c.tmp[0],r=c.tmp[1],this.type==="encrypt"?this._encrypt(c,a,r,c.tmp,0):this._decrypt(c,a,r,c.tmp,0),a=c.tmp[0],r=c.tmp[1],g.writeUInt32BE(s,a,m),g.writeUInt32BE(s,r,m+4)},f.prototype._pad=function(l,d){for(var s=l.length-d,m=d;m>>0,a=O}g.rip(r,a,m,c)},f.prototype._decrypt=function(l,d,s,m,c){for(var a=s,r=d,t=l.keys.length-2;t>=0;t-=2){var i=l.keys[t],n=l.keys[t+1];g.expand(a,l.tmp,0),i^=l.tmp[0],n^=l.tmp[1];var o=g.substitute(i,n),p=g.permute(o),O=a;a=(r^p)>>>0,r=O}g.rip(a,r,m,c)}},{"./cipher":341,"./utils":344,inherits:387,"minimalistic-assert":437}],343:[function(e,S,_){var u=e("minimalistic-assert"),y=e("inherits"),g=e("./cipher"),b=e("./des");function w(v,h){u.equal(h.length,24,"Invalid key length");var l=h.slice(0,8),d=h.slice(8,16),s=h.slice(16,24);v==="encrypt"?this.ciphers=[b.create({type:"encrypt",key:l}),b.create({type:"decrypt",key:d}),b.create({type:"encrypt",key:s})]:this.ciphers=[b.create({type:"decrypt",key:s}),b.create({type:"encrypt",key:d}),b.create({type:"decrypt",key:l})]}function f(v){g.call(this,v);var h=new w(this.type,this.options.key);this._edeState=h}y(f,g),S.exports=f,f.create=function(h){return new f(h)},f.prototype._update=function(h,l,d,s){var m=this._edeState;m.ciphers[0]._update(h,l,d,s),m.ciphers[1]._update(d,s,d,s),m.ciphers[2]._update(d,s,d,s)},f.prototype._pad=b.prototype._pad,f.prototype._unpad=b.prototype._unpad},{"./cipher":341,"./des":342,inherits:387,"minimalistic-assert":437}],344:[function(e,S,_){_.readUInt32BE=function(w,f){var v=w[0+f]<<24|w[1+f]<<16|w[2+f]<<8|w[3+f];return v>>>0},_.writeUInt32BE=function(w,f,v){w[0+v]=f>>>24,w[1+v]=f>>>16&255,w[2+v]=f>>>8&255,w[3+v]=f&255},_.ip=function(w,f,v,h){for(var l=0,d=0,s=6;s>=0;s-=2){for(var m=0;m<=24;m+=8)l<<=1,l|=f>>>m+s&1;for(var m=0;m<=24;m+=8)l<<=1,l|=w>>>m+s&1}for(var s=6;s>=0;s-=2){for(var m=1;m<=25;m+=8)d<<=1,d|=f>>>m+s&1;for(var m=1;m<=25;m+=8)d<<=1,d|=w>>>m+s&1}v[h+0]=l>>>0,v[h+1]=d>>>0},_.rip=function(w,f,v,h){for(var l=0,d=0,s=0;s<4;s++)for(var m=24;m>=0;m-=8)l<<=1,l|=f>>>m+s&1,l<<=1,l|=w>>>m+s&1;for(var s=4;s<8;s++)for(var m=24;m>=0;m-=8)d<<=1,d|=f>>>m+s&1,d<<=1,d|=w>>>m+s&1;v[h+0]=l>>>0,v[h+1]=d>>>0},_.pc1=function(w,f,v,h){for(var l=0,d=0,s=7;s>=5;s--){for(var m=0;m<=24;m+=8)l<<=1,l|=f>>m+s&1;for(var m=0;m<=24;m+=8)l<<=1,l|=w>>m+s&1}for(var m=0;m<=24;m+=8)l<<=1,l|=f>>m+s&1;for(var s=1;s<=3;s++){for(var m=0;m<=24;m+=8)d<<=1,d|=f>>m+s&1;for(var m=0;m<=24;m+=8)d<<=1,d|=w>>m+s&1}for(var m=0;m<=24;m+=8)d<<=1,d|=w>>m+s&1;v[h+0]=l>>>0,v[h+1]=d>>>0},_.r28shl=function(w,f){return w<>>28-f};var u=[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];_.pc2=function(w,f,v,h){for(var l=0,d=0,s=u.length>>>1,m=0;m>>u[m]&1;for(var m=s;m>>u[m]&1;v[h+0]=l>>>0,v[h+1]=d>>>0},_.expand=function(w,f,v){var h=0,l=0;h=(w&1)<<5|w>>>27;for(var d=23;d>=15;d-=4)h<<=6,h|=w>>>d&63;for(var d=11;d>=3;d-=4)l|=w>>>d&63,l<<=6;l|=(w&31)<<1|w>>>31,f[v+0]=h>>>0,f[v+1]=l>>>0};var y=[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];_.substitute=function(w,f){for(var v=0,h=0;h<4;h++){var l=w>>>18-h*6&63,d=y[h*64+l];v<<=4,v|=d}for(var h=0;h<4;h++){var l=f>>>18-h*6&63,d=y[4*64+h*64+l];v<<=4,v|=d}return v>>>0};var g=[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];_.permute=function(w){for(var f=0,v=0;v>>g[v]&1;return f>>>0},_.padSplit=function(w,f,v){for(var h=w.toString(2);h.lengthn;)p.ishrn(1);if(p.isEven()&&p.iadd(f),p.testn(1)||p.iadd(v),o.cmp(v)){if(!o.cmp(h))for(;p.mod(l).cmp(d);)p.iadd(m)}else for(;p.mod(g).cmp(s);)p.iadd(m);if(O=p.shrn(1),r(O)&&r(p)&&t(O)&&t(p)&&w.test(O)&&w.test(p))return p}}},{"bn.js":349,"miller-rabin":435,randombytes:475}],348:[function(e,S,_){S.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"}}},{}],349:[function(e,S,_){arguments[4][181][0].apply(_,arguments)},{buffer:185,dup:181}],350:[function(e,S,_){var u=_;u.version=e("../package.json").version,u.utils=e("./elliptic/utils"),u.rand=e("brorand"),u.curve=e("./elliptic/curve"),u.curves=e("./elliptic/curves"),u.ec=e("./elliptic/ec"),u.eddsa=e("./elliptic/eddsa")},{"../package.json":366,"./elliptic/curve":353,"./elliptic/curves":356,"./elliptic/ec":357,"./elliptic/eddsa":360,"./elliptic/utils":364,brorand:184}],351:[function(e,S,_){var u=e("bn.js"),y=e("../utils"),g=y.getNAF,b=y.getJSF,w=y.assert;function f(h,l){this.type=h,this.p=new u(l.p,16),this.red=l.prime?u.red(l.prime):u.mont(this.p),this.zero=new u(0).toRed(this.red),this.one=new u(1).toRed(this.red),this.two=new u(2).toRed(this.red),this.n=l.n&&new u(l.n,16),this.g=l.g&&this.pointFromJSON(l.g,l.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 d=this.n&&this.p.div(this.n);!d||d.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}S.exports=f,f.prototype.point=function(){throw new Error("Not implemented")},f.prototype.validate=function(){throw new Error("Not implemented")},f.prototype._fixedNafMul=function(l,d){w(l.precomputed);var s=l._getDoubles(),m=g(d,1,this._bitLength),c=(1<=r;d--)t=(t<<1)+m[d];a.push(t)}for(var i=this.jpoint(null,null,null),n=this.jpoint(null,null,null),o=c;o>0;o--){for(var r=0;r=0;t--){for(var d=0;t>=0&&a[t]===0;t--)d++;if(t>=0&&d++,r=r.dblp(d),t<0)break;var i=a[t];w(i!==0),l.type==="affine"?i>0?r=r.mixedAdd(c[i-1>>1]):r=r.mixedAdd(c[-i-1>>1].neg()):i>0?r=r.add(c[i-1>>1]):r=r.add(c[-i-1>>1].neg())}return l.type==="affine"?r.toP():r},f.prototype._wnafMulAdd=function(l,d,s,m,c){for(var a=this._wnafT1,r=this._wnafT2,t=this._wnafT3,i=0,n=0;n=1;n-=2){var O=n-1,P=n;if(a[O]!==1||a[P]!==1){t[O]=g(s[O],a[O],this._bitLength),t[P]=g(s[P],a[P],this._bitLength),i=Math.max(t[O].length,i),i=Math.max(t[P].length,i);continue}var B=[d[O],null,null,d[P]];d[O].y.cmp(d[P].y)===0?(B[1]=d[O].add(d[P]),B[2]=d[O].toJ().mixedAdd(d[P].neg())):d[O].y.cmp(d[P].y.redNeg())===0?(B[1]=d[O].toJ().mixedAdd(d[P]),B[2]=d[O].add(d[P].neg())):(B[1]=d[O].toJ().mixedAdd(d[P]),B[2]=d[O].toJ().mixedAdd(d[P].neg()));var z=[-3,-1,-5,-7,0,7,5,1,3],D=b(s[O],s[P]);i=Math.max(D[0].length,i),t[O]=new Array(i),t[P]=new Array(i);for(var M=0;M=0;n--){for(var A=0;n>=0;){for(var L=!0,M=0;M=0&&A++,C=C.dblp(A),n<0)break;for(var M=0;M0?o=r[M][$-1>>1]:$<0&&(o=r[M][-$-1>>1].neg()),o.type==="affine"?C=C.mixedAdd(o):C=C.add(o))}}for(var n=0;n=Math.ceil((l.bitLength()+1)/d.step):!1},v.prototype._getDoubles=function(l,d){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var s=[this],m=this,c=0;c":""},v.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},v.prototype._extDbl=function(){var l=this.x.redSqr(),d=this.y.redSqr(),s=this.z.redSqr();s=s.redIAdd(s);var m=this.curve._mulA(l),c=this.x.redAdd(this.y).redSqr().redISub(l).redISub(d),a=m.redAdd(d),r=a.redSub(s),t=m.redSub(d),i=c.redMul(r),n=a.redMul(t),o=c.redMul(t),p=r.redMul(a);return this.curve.point(i,n,p,o)},v.prototype._projDbl=function(){var l=this.x.redAdd(this.y).redSqr(),d=this.x.redSqr(),s=this.y.redSqr(),m,c,a;if(this.curve.twisted){var r=this.curve._mulA(d),t=r.redAdd(s);if(this.zOne)m=l.redSub(d).redSub(s).redMul(t.redSub(this.curve.two)),c=t.redMul(r.redSub(s)),a=t.redSqr().redSub(t).redSub(t);else{var i=this.z.redSqr(),n=t.redSub(i).redISub(i);m=l.redSub(d).redISub(s).redMul(n),c=t.redMul(r.redSub(s)),a=t.redMul(n)}}else{var r=d.redAdd(s),i=this.curve._mulC(this.z).redSqr(),n=r.redSub(i).redSub(i);m=this.curve._mulC(l.redISub(r)).redMul(n),c=this.curve._mulC(r).redMul(d.redISub(s)),a=r.redMul(n)}return this.curve.point(m,c,a)},v.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},v.prototype._extAdd=function(l){var d=this.y.redSub(this.x).redMul(l.y.redSub(l.x)),s=this.y.redAdd(this.x).redMul(l.y.redAdd(l.x)),m=this.t.redMul(this.curve.dd).redMul(l.t),c=this.z.redMul(l.z.redAdd(l.z)),a=s.redSub(d),r=c.redSub(m),t=c.redAdd(m),i=s.redAdd(d),n=a.redMul(r),o=t.redMul(i),p=a.redMul(i),O=r.redMul(t);return this.curve.point(n,o,O,p)},v.prototype._projAdd=function(l){var d=this.z.redMul(l.z),s=d.redSqr(),m=this.x.redMul(l.x),c=this.y.redMul(l.y),a=this.curve.d.redMul(m).redMul(c),r=s.redSub(a),t=s.redAdd(a),i=this.x.redAdd(this.y).redMul(l.x.redAdd(l.y)).redISub(m).redISub(c),n=d.redMul(r).redMul(i),o,p;return this.curve.twisted?(o=d.redMul(t).redMul(c.redSub(this.curve._mulA(m))),p=r.redMul(t)):(o=d.redMul(t).redMul(c.redSub(m)),p=this.curve._mulC(r).redMul(t)),this.curve.point(n,o,p)},v.prototype.add=function(l){return this.isInfinity()?l:l.isInfinity()?this:this.curve.extended?this._extAdd(l):this._projAdd(l)},v.prototype.mul=function(l){return this._hasDoubles(l)?this.curve._fixedNafMul(this,l):this.curve._wnafMul(this,l)},v.prototype.mulAdd=function(l,d,s){return this.curve._wnafMulAdd(1,[this,d],[l,s],2,!1)},v.prototype.jmulAdd=function(l,d,s){return this.curve._wnafMulAdd(1,[this,d],[l,s],2,!0)},v.prototype.normalize=function(){if(this.zOne)return this;var l=this.z.redInvm();return this.x=this.x.redMul(l),this.y=this.y.redMul(l),this.t&&(this.t=this.t.redMul(l)),this.z=this.curve.one,this.zOne=!0,this},v.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},v.prototype.getX=function(){return this.normalize(),this.x.fromRed()},v.prototype.getY=function(){return this.normalize(),this.y.fromRed()},v.prototype.eq=function(l){return this===l||this.getX().cmp(l.getX())===0&&this.getY().cmp(l.getY())===0},v.prototype.eqXToP=function(l){var d=l.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(d)===0)return!0;for(var s=l.clone(),m=this.curve.redN.redMul(this.z);;){if(s.iadd(this.curve.n),s.cmp(this.curve.p)>=0)return!1;if(d.redIAdd(m),this.x.cmp(d)===0)return!0}},v.prototype.toP=v.prototype.normalize,v.prototype.mixedAdd=v.prototype.add},{"../utils":364,"./base":351,"bn.js":365,inherits:387}],353:[function(e,S,_){var u=_;u.base=e("./base"),u.short=e("./short"),u.mont=e("./mont"),u.edwards=e("./edwards")},{"./base":351,"./edwards":352,"./mont":354,"./short":355}],354:[function(e,S,_){var u=e("bn.js"),y=e("inherits"),g=e("./base"),b=e("../utils");function w(v){g.call(this,"mont",v),this.a=new u(v.a,16).toRed(this.red),this.b=new u(v.b,16).toRed(this.red),this.i4=new u(4).toRed(this.red).redInvm(),this.two=new u(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}y(w,g),S.exports=w,w.prototype.validate=function(h){var l=h.normalize().x,d=l.redSqr(),s=d.redMul(l).redAdd(d.redMul(this.a)).redAdd(l),m=s.redSqrt();return m.redSqr().cmp(s)===0};function f(v,h,l){g.BasePoint.call(this,v,"projective"),h===null&&l===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new u(h,16),this.z=new u(l,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}y(f,g.BasePoint),w.prototype.decodePoint=function(h,l){return this.point(b.toArray(h,l),1)},w.prototype.point=function(h,l){return new f(this,h,l)},w.prototype.pointFromJSON=function(h){return f.fromJSON(this,h)},f.prototype.precompute=function(){},f.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},f.fromJSON=function(h,l){return new f(h,l[0],l[1]||h.one)},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return this.z.cmpn(0)===0},f.prototype.dbl=function(){var h=this.x.redAdd(this.z),l=h.redSqr(),d=this.x.redSub(this.z),s=d.redSqr(),m=l.redSub(s),c=l.redMul(s),a=m.redMul(s.redAdd(this.curve.a24.redMul(m)));return this.curve.point(c,a)},f.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.diffAdd=function(h,l){var d=this.x.redAdd(this.z),s=this.x.redSub(this.z),m=h.x.redAdd(h.z),c=h.x.redSub(h.z),a=c.redMul(d),r=m.redMul(s),t=l.z.redMul(a.redAdd(r).redSqr()),i=l.x.redMul(a.redISub(r).redSqr());return this.curve.point(t,i)},f.prototype.mul=function(h){for(var l=h.clone(),d=this,s=this.curve.point(null,null),m=this,c=[];l.cmpn(0)!==0;l.iushrn(1))c.push(l.andln(1));for(var a=c.length-1;a>=0;a--)c[a]===0?(d=d.diffAdd(s,m),s=s.dbl()):(s=d.diffAdd(s,m),d=d.dbl());return s},f.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.eq=function(h){return this.getX().cmp(h.getX())===0},f.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":364,"./base":351,"bn.js":365,inherits:387}],355:[function(e,S,_){var u=e("../utils"),y=e("bn.js"),g=e("inherits"),b=e("./base"),w=u.assert;function f(l){b.call(this,"short",l),this.a=new y(l.a,16).toRed(this.red),this.b=new y(l.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(l),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}g(f,b),S.exports=f,f.prototype._getEndomorphism=function(d){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var s,m;if(d.beta)s=new y(d.beta,16).toRed(this.red);else{var c=this._getEndoRoots(this.p);s=c[0].cmp(c[1])<0?c[0]:c[1],s=s.toRed(this.red)}if(d.lambda)m=new y(d.lambda,16);else{var a=this._getEndoRoots(this.n);this.g.mul(a[0]).x.cmp(this.g.x.redMul(s))===0?m=a[0]:(m=a[1],w(this.g.mul(m).x.cmp(this.g.x.redMul(s))===0))}var r;return d.basis?r=d.basis.map(function(t){return{a:new y(t.a,16),b:new y(t.b,16)}}):r=this._getEndoBasis(m),{beta:s,lambda:m,basis:r}}},f.prototype._getEndoRoots=function(d){var s=d===this.p?this.red:y.mont(d),m=new y(2).toRed(s).redInvm(),c=m.redNeg(),a=new y(3).toRed(s).redNeg().redSqrt().redMul(m),r=c.redAdd(a).fromRed(),t=c.redSub(a).fromRed();return[r,t]},f.prototype._getEndoBasis=function(d){for(var s=this.n.ushrn(Math.floor(this.n.bitLength()/2)),m=d,c=this.n.clone(),a=new y(1),r=new y(0),t=new y(0),i=new y(1),n,o,p,O,P,B,z,D=0,M,I;m.cmpn(0)!==0;){var T=c.div(m);M=c.sub(T.mul(m)),I=t.sub(T.mul(a));var C=i.sub(T.mul(r));if(!p&&M.cmp(s)<0)n=z.neg(),o=a,p=M.neg(),O=I;else if(p&&++D===2)break;z=M,c=m,m=M,t=a,a=I,i=r,r=C}P=M.neg(),B=I;var E=p.sqr().add(O.sqr()),A=P.sqr().add(B.sqr());return A.cmp(E)>=0&&(P=n,B=o),p.negative&&(p=p.neg(),O=O.neg()),P.negative&&(P=P.neg(),B=B.neg()),[{a:p,b:O},{a:P,b:B}]},f.prototype._endoSplit=function(d){var s=this.endo.basis,m=s[0],c=s[1],a=c.b.mul(d).divRound(this.n),r=m.b.neg().mul(d).divRound(this.n),t=a.mul(m.a),i=r.mul(c.a),n=a.mul(m.b),o=r.mul(c.b),p=d.sub(t).sub(i),O=n.add(o).neg();return{k1:p,k2:O}},f.prototype.pointFromX=function(d,s){d=new y(d,16),d.red||(d=d.toRed(this.red));var m=d.redSqr().redMul(d).redIAdd(d.redMul(this.a)).redIAdd(this.b),c=m.redSqrt();if(c.redSqr().redSub(m).cmp(this.zero)!==0)throw new Error("invalid point");var a=c.fromRed().isOdd();return(s&&!a||!s&&a)&&(c=c.redNeg()),this.point(d,c)},f.prototype.validate=function(d){if(d.inf)return!0;var s=d.x,m=d.y,c=this.a.redMul(s),a=s.redSqr().redMul(s).redIAdd(c).redIAdd(this.b);return m.redSqr().redISub(a).cmpn(0)===0},f.prototype._endoWnafMulAdd=function(d,s,m){for(var c=this._endoWnafT1,a=this._endoWnafT2,r=0;r":""},v.prototype.isInfinity=function(){return this.inf},v.prototype.add=function(d){if(this.inf)return d;if(d.inf)return this;if(this.eq(d))return this.dbl();if(this.neg().eq(d))return this.curve.point(null,null);if(this.x.cmp(d.x)===0)return this.curve.point(null,null);var s=this.y.redSub(d.y);s.cmpn(0)!==0&&(s=s.redMul(this.x.redSub(d.x).redInvm()));var m=s.redSqr().redISub(this.x).redISub(d.x),c=s.redMul(this.x.redSub(m)).redISub(this.y);return this.curve.point(m,c)},v.prototype.dbl=function(){if(this.inf)return this;var d=this.y.redAdd(this.y);if(d.cmpn(0)===0)return this.curve.point(null,null);var s=this.curve.a,m=this.x.redSqr(),c=d.redInvm(),a=m.redAdd(m).redIAdd(m).redIAdd(s).redMul(c),r=a.redSqr().redISub(this.x.redAdd(this.x)),t=a.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,t)},v.prototype.getX=function(){return this.x.fromRed()},v.prototype.getY=function(){return this.y.fromRed()},v.prototype.mul=function(d){return d=new y(d,16),this.isInfinity()?this:this._hasDoubles(d)?this.curve._fixedNafMul(this,d):this.curve.endo?this.curve._endoWnafMulAdd([this],[d]):this.curve._wnafMul(this,d)},v.prototype.mulAdd=function(d,s,m){var c=[this,s],a=[d,m];return this.curve.endo?this.curve._endoWnafMulAdd(c,a):this.curve._wnafMulAdd(1,c,a,2)},v.prototype.jmulAdd=function(d,s,m){var c=[this,s],a=[d,m];return this.curve.endo?this.curve._endoWnafMulAdd(c,a,!0):this.curve._wnafMulAdd(1,c,a,2,!0)},v.prototype.eq=function(d){return this===d||this.inf===d.inf&&(this.inf||this.x.cmp(d.x)===0&&this.y.cmp(d.y)===0)},v.prototype.neg=function(d){if(this.inf)return this;var s=this.curve.point(this.x,this.y.redNeg());if(d&&this.precomputed){var m=this.precomputed,c=function(r){return r.neg()};s.precomputed={naf:m.naf&&{wnd:m.naf.wnd,points:m.naf.points.map(c)},doubles:m.doubles&&{step:m.doubles.step,points:m.doubles.points.map(c)}}}return s},v.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var d=this.curve.jpoint(this.x,this.y,this.curve.one);return d};function h(l,d,s,m){b.BasePoint.call(this,l,"jacobian"),d===null&&s===null&&m===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new y(0)):(this.x=new y(d,16),this.y=new y(s,16),this.z=new y(m,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}g(h,b.BasePoint),f.prototype.jpoint=function(d,s,m){return new h(this,d,s,m)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var d=this.z.redInvm(),s=d.redSqr(),m=this.x.redMul(s),c=this.y.redMul(s).redMul(d);return this.curve.point(m,c)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(d){if(this.isInfinity())return d;if(d.isInfinity())return this;var s=d.z.redSqr(),m=this.z.redSqr(),c=this.x.redMul(s),a=d.x.redMul(m),r=this.y.redMul(s.redMul(d.z)),t=d.y.redMul(m.redMul(this.z)),i=c.redSub(a),n=r.redSub(t);if(i.cmpn(0)===0)return n.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var o=i.redSqr(),p=o.redMul(i),O=c.redMul(o),P=n.redSqr().redIAdd(p).redISub(O).redISub(O),B=n.redMul(O.redISub(P)).redISub(r.redMul(p)),z=this.z.redMul(d.z).redMul(i);return this.curve.jpoint(P,B,z)},h.prototype.mixedAdd=function(d){if(this.isInfinity())return d.toJ();if(d.isInfinity())return this;var s=this.z.redSqr(),m=this.x,c=d.x.redMul(s),a=this.y,r=d.y.redMul(s).redMul(this.z),t=m.redSub(c),i=a.redSub(r);if(t.cmpn(0)===0)return i.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var n=t.redSqr(),o=n.redMul(t),p=m.redMul(n),O=i.redSqr().redIAdd(o).redISub(p).redISub(p),P=i.redMul(p.redISub(O)).redISub(a.redMul(o)),B=this.z.redMul(t);return this.curve.jpoint(O,P,B)},h.prototype.dblp=function(d){if(d===0)return this;if(this.isInfinity())return this;if(!d)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var s=this,m=0;m=0)return!1;if(m.redIAdd(a),this.x.cmp(m)===0)return!0}},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return this.z.cmpn(0)===0}},{"../utils":364,"./base":351,"bn.js":365,inherits:387}],356:[function(e,S,_){var u=_,y=e("hash.js"),g=e("./curve"),b=e("./utils"),w=b.assert;function f(l){l.type==="short"?this.curve=new g.short(l):l.type==="edwards"?this.curve=new g.edwards(l):this.curve=new g.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,w(this.g.validate(),"Invalid curve"),w(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}u.PresetCurve=f;function v(l,d){Object.defineProperty(u,l,{configurable:!0,enumerable:!0,get:function(){var m=new f(d);return Object.defineProperty(u,l,{configurable:!0,enumerable:!0,value:m}),m}})}v("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:y.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),v("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:y.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),v("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:y.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),v("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:y.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"]}),v("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:y.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"]}),v("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:y.sha256,gRed:!1,g:["9"]}),v("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:y.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var h;try{h=e("./precomputed/secp256k1")}catch{h=void 0}v("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:y.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",h]})},{"./curve":353,"./precomputed/secp256k1":363,"./utils":364,"hash.js":372}],357:[function(e,S,_){function u(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(c){return typeof c}:u=function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},u(s)}var y=e("bn.js"),g=e("hmac-drbg"),b=e("../utils"),w=e("../curves"),f=e("brorand"),v=b.assert,h=e("./key"),l=e("./signature");function d(s){if(!(this instanceof d))return new d(s);typeof s=="string"&&(v(w.hasOwnProperty(s),"Unknown curve "+s),s=w[s]),s instanceof w.PresetCurve&&(s={curve:s}),this.curve=s.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=s.curve.g,this.g.precompute(s.curve.n.bitLength()+1),this.hash=s.hash||s.curve.hash}S.exports=d,d.prototype.keyPair=function(m){return new h(this,m)},d.prototype.keyFromPrivate=function(m,c){return h.fromPrivate(this,m,c)},d.prototype.keyFromPublic=function(m,c){return h.fromPublic(this,m,c)},d.prototype.genKeyPair=function(m){m||(m={});var c=new g({hash:this.hash,pers:m.pers,persEnc:m.persEnc||"utf8",entropy:m.entropy||f(this.hash.hmacStrength),entropyEnc:m.entropy&&m.entropyEnc||"utf8",nonce:this.n.toArray()}),a=this.n.byteLength(),r=this.n.sub(new y(2));do{var t=new y(c.generate(a));if(!(t.cmp(r)>0))return t.iaddn(1),this.keyFromPrivate(t)}while(!0)},d.prototype._truncateToN=function(m,c){var a=m.byteLength()*8-this.n.bitLength();return a>0&&(m=m.ushrn(a)),!c&&m.cmp(this.n)>=0?m.sub(this.n):m},d.prototype.sign=function(m,c,a,r){u(a)==="object"&&(r=a,a=null),r||(r={}),c=this.keyFromPrivate(c,a),m=this._truncateToN(new y(m,16));for(var t=this.n.byteLength(),i=c.getPrivate().toArray("be",t),n=m.toArray("be",t),o=new g({hash:this.hash,entropy:i,nonce:n,pers:r.pers,persEnc:r.persEnc||"utf8"}),p=this.n.sub(new y(1)),O=0;;O++){var P=r.k?r.k(O):new y(o.generate(this.n.byteLength()));if(P=this._truncateToN(P,!0),!(P.cmpn(1)<=0||P.cmp(p)>=0)){var B=this.g.mul(P);if(!B.isInfinity()){var z=B.getX(),D=z.umod(this.n);if(D.cmpn(0)!==0){var M=P.invm(this.n).mul(D.mul(c.getPrivate()).iadd(m));if(M=M.umod(this.n),M.cmpn(0)!==0){var I=(B.getY().isOdd()?1:0)|(z.cmp(D)!==0?2:0);return r.canonical&&M.cmp(this.nh)>0&&(M=this.n.sub(M),I^=1),new l({r:D,s:M,recoveryParam:I})}}}}}},d.prototype.verify=function(m,c,a,r){m=this._truncateToN(new y(m,16)),a=this.keyFromPublic(a,r),c=new l(c,"hex");var t=c.r,i=c.s;if(t.cmpn(1)<0||t.cmp(this.n)>=0||i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;var n=i.invm(this.n),o=n.mul(m).umod(this.n),p=n.mul(t).umod(this.n);if(!this.curve._maxwellTrick){var O=this.g.mulAdd(o,a.getPublic(),p);return O.isInfinity()?!1:O.getX().umod(this.n).cmp(t)===0}var O=this.g.jmulAdd(o,a.getPublic(),p);return O.isInfinity()?!1:O.eqXToP(t)},d.prototype.recoverPubKey=function(s,m,c,a){v((3&c)===c,"The recovery param is more than two bits"),m=new l(m,a);var r=this.n,t=new y(s),i=m.r,n=m.s,o=c&1,p=c>>1;if(i.cmp(this.curve.p.umod(this.curve.n))>=0&&p)throw new Error("Unable to find sencond key candinate");p?i=this.curve.pointFromX(i.add(this.curve.n),o):i=this.curve.pointFromX(i,o);var O=m.r.invm(r),P=r.sub(t).mul(O).umod(r),B=n.mul(O).umod(r);return this.g.mulAdd(P,i,B)},d.prototype.getKeyRecoveryParam=function(s,m,c,a){if(m=new l(m,a),m.recoveryParam!==null)return m.recoveryParam;for(var r=0;r<4;r++){var t;try{t=this.recoverPubKey(s,m,r)}catch{continue}if(t.eq(c))return r}throw new Error("Unable to find valid recovery factor")}},{"../curves":356,"../utils":364,"./key":358,"./signature":359,"bn.js":365,brorand:184,"hmac-drbg":384}],358:[function(e,S,_){var u=e("bn.js"),y=e("../utils"),g=y.assert;function b(w,f){this.ec=w,this.priv=null,this.pub=null,f.priv&&this._importPrivate(f.priv,f.privEnc),f.pub&&this._importPublic(f.pub,f.pubEnc)}S.exports=b,b.fromPublic=function(f,v,h){return v instanceof b?v:new b(f,{pub:v,pubEnc:h})},b.fromPrivate=function(f,v,h){return v instanceof b?v:new b(f,{priv:v,privEnc:h})},b.prototype.validate=function(){var f=this.getPublic();return f.isInfinity()?{result:!1,reason:"Invalid public key"}:f.validate()?f.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"}},b.prototype.getPublic=function(f,v){return typeof f=="string"&&(v=f,f=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),v?this.pub.encode(v,f):this.pub},b.prototype.getPrivate=function(f){return f==="hex"?this.priv.toString(16,2):this.priv},b.prototype._importPrivate=function(f,v){this.priv=new u(f,v||16),this.priv=this.priv.umod(this.ec.curve.n)},b.prototype._importPublic=function(f,v){if(f.x||f.y){this.ec.curve.type==="mont"?g(f.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&g(f.x&&f.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(f.x,f.y);return}this.pub=this.ec.curve.decodePoint(f,v)},b.prototype.derive=function(f){return f.mul(this.priv).getX()},b.prototype.sign=function(f,v,h){return this.ec.sign(f,this,v,h)},b.prototype.verify=function(f,v){return this.ec.verify(f,v,this)},b.prototype.inspect=function(){return""}},{"../utils":364,"bn.js":365}],359:[function(e,S,_){var u=e("bn.js"),y=e("../utils"),g=y.assert;function b(l,d){if(l instanceof b)return l;this._importDER(l,d)||(g(l.r&&l.s,"Signature without r or s"),this.r=new u(l.r,16),this.s=new u(l.s,16),l.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=l.recoveryParam)}S.exports=b;function w(){this.place=0}function f(l,d){var s=l[d.place++];if(!(s&128))return s;var m=s&15;if(m===0||m>4)return!1;for(var c=0,a=0,r=d.place;a>>=0;return c<=127?!1:(d.place=r,c)}function v(l){for(var d=0,s=l.length-1;!l[d]&&!(l[d+1]&128)&&d>>3);for(l.push(s|128);--s;)l.push(d>>>(s<<3)&255);l.push(d)}b.prototype.toDER=function(d){var s=this.r.toArray(),m=this.s.toArray();for(s[0]&128&&(s=[0].concat(s)),m[0]&128&&(m=[0].concat(m)),s=v(s),m=v(m);!m[0]&&!(m[1]&128);)m=m.slice(1);var c=[2];h(c,s.length),c=c.concat(s),c.push(2),h(c,m.length);var a=c.concat(m),r=[48];return h(r,a.length),r=r.concat(a),y.encode(r,d)}},{"../utils":364,"bn.js":365}],360:[function(e,S,_){var u=e("hash.js"),y=e("../curves"),g=e("../utils"),b=g.assert,w=g.parseBytes,f=e("./key"),v=e("./signature");function h(d){if(b(d==="ed25519","only tested with ed25519 so far"),!(this instanceof h))return new h(d);var d=y[d].curve;this.curve=d,this.g=d.g,this.g.precompute(d.n.bitLength()+1),this.pointClass=d.point().constructor,this.encodingLength=Math.ceil(d.n.bitLength()/8),this.hash=u.sha512}S.exports=h,h.prototype.sign=function(d,s){d=w(d);var m=this.keyFromSecret(s),c=this.hashInt(m.messagePrefix(),d),a=this.g.mul(c),r=this.encodePoint(a),t=this.hashInt(r,m.pubBytes(),d).mul(m.priv()),i=c.add(t).umod(this.curve.n);return this.makeSignature({R:a,S:i,Rencoded:r})},h.prototype.verify=function(d,s,m){d=w(d),s=this.makeSignature(s);var c=this.keyFromPublic(m),a=this.hashInt(s.Rencoded(),c.pubBytes(),d),r=this.g.mul(s.S()),t=s.R().add(c.pub().mul(a));return t.eq(r)},h.prototype.hashInt=function(){for(var d=this.hash(),s=0;s(a>>1)-1?i=(a>>1)-n:i=n,r.isubn(i)):i=0,c[t]=i,r.iushrn(1)}return c}u.getNAF=w;function f(d,s){var m=[[],[]];d=d.clone(),s=s.clone();for(var c=0,a=0;d.cmpn(-c)>0||s.cmpn(-a)>0;){var r=d.andln(3)+c&3,t=s.andln(3)+a&3;r===3&&(r=-1),t===3&&(t=-1);var i;if(!(r&1))i=0;else{var n=d.andln(7)+c&7;(n===3||n===5)&&t===2?i=-r:i=r}m[0].push(i);var o;if(!(t&1))o=0;else{var n=s.andln(7)+a&7;(n===3||n===5)&&r===2?o=-t:o=t}m[1].push(o),2*c===i+1&&(c=1-c),2*a===o+1&&(a=1-a),d.iushrn(1),s.iushrn(1)}return m}u.getJSF=f;function v(d,s,m){var c="_"+s;d.prototype[s]=function(){return this[c]!==void 0?this[c]:this[c]=m.call(this)}}u.cachedProperty=v;function h(d){return typeof d=="string"?u.toArray(d,"hex"):d}u.parseBytes=h;function l(d){return new y(d,"hex","le")}u.intFromLE=l},{"bn.js":365,"minimalistic-assert":437,"minimalistic-crypto-utils":438}],365:[function(e,S,_){arguments[4][181][0].apply(_,arguments)},{buffer:185,dup:181}],366:[function(e,S,_){S.exports={_from:"elliptic@^6.5.3",_id:"elliptic@6.5.3",_inBundle:!1,_integrity:"sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.5.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.5.3",saveSpec:null,fetchSpec:"^6.5.3"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",_shasum:"cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6",_spec:"elliptic@^6.5.3",_where:"/mnt/d/dev/git/exceljs/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^3.0.8",grunt:"^1.0.4","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.2",jscs:"^3.0.7",jshint:"^2.10.3",mocha:"^6.2.2"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.3"}},{}],367:[function(e,S,_){function u(M){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(T){return typeof T}:u=function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},u(M)}var y=Object.create||B,g=Object.keys||z,b=Function.prototype.bind||D;function w(){(!this._events||!Object.prototype.hasOwnProperty.call(this,"_events"))&&(this._events=y(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}S.exports=w,w.EventEmitter=w,w.prototype._events=void 0,w.prototype._maxListeners=void 0;var f=10,v;try{var h={};Object.defineProperty&&Object.defineProperty(h,"x",{value:0}),v=h.x===0}catch{v=!1}v?Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return f},set:function(I){if(typeof I!="number"||I<0||I!==I)throw new TypeError('"defaultMaxListeners" must be a positive number');f=I}}):w.defaultMaxListeners=f,w.prototype.setMaxListeners=function(I){if(typeof I!="number"||I<0||isNaN(I))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=I,this};function l(M){return M._maxListeners===void 0?w.defaultMaxListeners:M._maxListeners}w.prototype.getMaxListeners=function(){return l(this)};function d(M,I,T){if(I)M.call(T);else for(var C=M.length,E=O(M,C),A=0;A1&&(T=arguments[1]),T instanceof Error)throw T;var U=new Error('Unhandled "error" event. ('+T+")");throw U.context=T,U}if(C=$[I],!C)return!1;var N=typeof C=="function";switch(E=arguments.length,E){case 1:d(C,N,this);break;case 2:s(C,N,this,arguments[1]);break;case 3:m(C,N,this,arguments[1],arguments[2]);break;case 4:c(C,N,this,arguments[1],arguments[2],arguments[3]);break;default:for(A=new Array(E-1),L=1;L0&&L.length>E)){L.warned=!0;var $=new Error("Possible EventEmitter memory leak detected. "+L.length+' "'+String(I)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');$.name="MaxListenersExceededWarning",$.emitter=M,$.type=I,$.count=L.length,(typeof console>"u"?"undefined":u(console))==="object"&&console.warn&&console.warn("%s: %s",$.name,$.message)}return M}w.prototype.addListener=function(I,T){return r(this,I,T,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(I,T){return r(this,I,T,!0)};function t(){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 M=new Array(arguments.length),I=0;I=0;L--)if(C[L]===T||C[L].listener===T){$=C[L].listener,A=L;break}if(A<0)return this;A===0?C.shift():p(C,A),C.length===1&&(E[I]=C[0]),E.removeListener&&this.emit("removeListener",I,$||T)}return this},w.prototype.removeAllListeners=function(I){var T,C,E;if(C=this._events,!C)return this;if(!C.removeListener)return arguments.length===0?(this._events=y(null),this._eventsCount=0):C[I]&&(--this._eventsCount===0?this._events=y(null):delete C[I]),this;if(arguments.length===0){var A=g(C),L;for(E=0;E=0;E--)this.removeListener(I,T[E]);return this};function n(M,I,T){var C=M._events;if(!C)return[];var E=C[I];return E?typeof E=="function"?T?[E.listener||E]:[E]:T?P(E):O(E,E.length):[]}w.prototype.listeners=function(I){return n(this,I,!0)},w.prototype.rawListeners=function(I){return n(this,I,!1)},w.listenerCount=function(M,I){return typeof M.listenerCount=="function"?M.listenerCount(I):o.call(M,I)},w.prototype.listenerCount=o;function o(M){var I=this._events;if(I){var T=I[M];if(typeof T=="function")return 1;if(T)return T.length}return 0}w.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function p(M,I){for(var T=I,C=T+1,E=M.length;C0||v>0;){var m=new y;m.update(s),m.update(b),w&&m.update(w),s=m.digest();var c=0;if(h>0){var a=l.length-h;c=Math.min(h,s.length),s.copy(l,a,0,c),h-=c}if(c0){var r=d.length-v,t=Math.min(v,s.length-c);s.copy(d,r,c,c+t),v-=t}}return s.fill(0),{key:l,iv:d}}S.exports=g},{"md5.js":434,"safe-buffer":494}],369:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0});var u=e("@fast-csv/format");Object.defineProperty(_,"format",{enumerable:!0,get:function(){return u.format}}),Object.defineProperty(_,"write",{enumerable:!0,get:function(){return u.write}}),Object.defineProperty(_,"writeToStream",{enumerable:!0,get:function(){return u.writeToStream}}),Object.defineProperty(_,"writeToBuffer",{enumerable:!0,get:function(){return u.writeToBuffer}}),Object.defineProperty(_,"writeToString",{enumerable:!0,get:function(){return u.writeToString}}),Object.defineProperty(_,"writeToPath",{enumerable:!0,get:function(){return u.writeToPath}}),Object.defineProperty(_,"CsvFormatterStream",{enumerable:!0,get:function(){return u.CsvFormatterStream}}),Object.defineProperty(_,"FormatterOptions",{enumerable:!0,get:function(){return u.FormatterOptions}});var y=e("@fast-csv/parse");Object.defineProperty(_,"parse",{enumerable:!0,get:function(){return y.parse}}),Object.defineProperty(_,"parseString",{enumerable:!0,get:function(){return y.parseString}}),Object.defineProperty(_,"parseStream",{enumerable:!0,get:function(){return y.parseStream}}),Object.defineProperty(_,"parseFile",{enumerable:!0,get:function(){return y.parseFile}}),Object.defineProperty(_,"ParserOptions",{enumerable:!0,get:function(){return y.ParserOptions}}),Object.defineProperty(_,"CsvParserStream",{enumerable:!0,get:function(){return y.CsvParserStream}})},{"@fast-csv/format":148,"@fast-csv/parse":152}],370:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("readable-stream").Transform,g=e("inherits");function b(f,v){if(!u.isBuffer(f)&&typeof f!="string")throw new TypeError(v+" must be a string or a buffer")}function w(f){y.call(this),this._block=u.allocUnsafe(f),this._blockSize=f,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}g(w,y),w.prototype._transform=function(f,v,h){var l=null;try{this.update(f,v)}catch(d){l=d}h(l)},w.prototype._flush=function(f){var v=null;try{this.push(this.digest())}catch(h){v=h}f(v)},w.prototype.update=function(f,v){if(b(f,"Data"),this._finalized)throw new Error("Digest already called");u.isBuffer(f)||(f=u.from(f,v));for(var h=this._block,l=0;this._blockOffset+f.length-l>=this._blockSize;){for(var d=this._blockOffset;d0;++s)this._length[s]+=m,m=this._length[s]/4294967296|0,m>0&&(this._length[s]-=4294967296*m);return this},w.prototype._update=function(){throw new Error("_update is not implemented")},w.prototype.digest=function(f){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var v=this._digest();f!==void 0&&(v=v.toString(f)),this._block.fill(0),this._blockOffset=0;for(var h=0;h<4;++h)this._length[h]=0;return v},w.prototype._digest=function(){throw new Error("_digest is not implemented")},S.exports=w},{inherits:387,"readable-stream":491,"safe-buffer":371}],371:[function(e,S,_){arguments[4][214][0].apply(_,arguments)},{buffer:216,dup:214}],372:[function(e,S,_){var u=_;u.utils=e("./hash/utils"),u.common=e("./hash/common"),u.sha=e("./hash/sha"),u.ripemd=e("./hash/ripemd"),u.hmac=e("./hash/hmac"),u.sha1=u.sha.sha1,u.sha256=u.sha.sha256,u.sha224=u.sha.sha224,u.sha384=u.sha.sha384,u.sha512=u.sha.sha512,u.ripemd160=u.ripemd.ripemd160},{"./hash/common":373,"./hash/hmac":374,"./hash/ripemd":375,"./hash/sha":376,"./hash/utils":383}],373:[function(e,S,_){var u=e("./utils"),y=e("minimalistic-assert");function g(){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}_.BlockHash=g,g.prototype.update=function(w,f){if(w=u.toArray(w,f),this.pending?this.pending=this.pending.concat(w):this.pending=w,this.pendingTotal+=w.length,this.pending.length>=this._delta8){w=this.pending;var v=w.length%this._delta8;this.pending=w.slice(w.length-v,w.length),this.pending.length===0&&(this.pending=null),w=u.join32(w,0,w.length-v,this.endian);for(var h=0;h>>24&255,h[l++]=w>>>16&255,h[l++]=w>>>8&255,h[l++]=w&255}else for(h[l++]=w&255,h[l++]=w>>>8&255,h[l++]=w>>>16&255,h[l++]=w>>>24&255,h[l++]=0,h[l++]=0,h[l++]=0,h[l++]=0,d=8;dthis.blockSize&&(w=new this.Hash().update(w).digest()),y(w.length<=this.blockSize);for(var f=w.length;f>>3}_.g0_256=l;function d(s){return y(s,17)^y(s,19)^s>>>10}_.g1_256=d},{"../utils":383}],383:[function(e,S,_){var u=e("minimalistic-assert"),y=e("inherits");_.inherits=y;function g(C,E){return(C.charCodeAt(E)&64512)!==55296||E<0||E+1>=C.length?!1:(C.charCodeAt(E+1)&64512)===56320}function b(C,E){if(Array.isArray(C))return C.slice();if(!C)return[];var A=[];if(typeof C=="string")if(E){if(E==="hex")for(C=C.replace(/[^a-z0-9]+/ig,""),C.length%2!==0&&(C="0"+C),$=0;$>6|192,A[L++]=W&63|128):g(C,$)?(W=65536+((W&1023)<<10)+(C.charCodeAt(++$)&1023),A[L++]=W>>18|240,A[L++]=W>>12&63|128,A[L++]=W>>6&63|128,A[L++]=W&63|128):(A[L++]=W>>12|224,A[L++]=W>>6&63|128,A[L++]=W&63|128)}else for($=0;$>>24|C>>>8&65280|C<<8&16711680|(C&255)<<24;return E>>>0}_.htonl=f;function v(C,E){for(var A="",L=0;L>>0}return W}_.join32=d;function s(C,E){for(var A=new Array(C.length*4),L=0,$=0;L>>24,A[$+1]=W>>>16&255,A[$+2]=W>>>8&255,A[$+3]=W&255):(A[$+3]=W>>>24,A[$+2]=W>>>16&255,A[$+1]=W>>>8&255,A[$]=W&255)}return A}_.split32=s;function m(C,E){return C>>>E|C<<32-E}_.rotr32=m;function c(C,E){return C<>>32-E}_.rotl32=c;function a(C,E){return C+E>>>0}_.sum32=a;function r(C,E,A){return C+E+A>>>0}_.sum32_3=r;function t(C,E,A,L){return C+E+A+L>>>0}_.sum32_4=t;function i(C,E,A,L,$){return C+E+A+L+$>>>0}_.sum32_5=i;function n(C,E,A,L){var $=C[E],W=C[E+1],U=L+W>>>0,N=(U>>0,C[E+1]=U}_.sum64=n;function o(C,E,A,L){var $=E+L>>>0,W=($>>0}_.sum64_hi=o;function p(C,E,A,L){var $=E+L;return $>>>0}_.sum64_lo=p;function O(C,E,A,L,$,W,U,N){var j=0,F=E;F=F+L>>>0,j+=F>>0,j+=F>>0,j+=F>>0}_.sum64_4_hi=O;function P(C,E,A,L,$,W,U,N){var j=E+L+W+N;return j>>>0}_.sum64_4_lo=P;function B(C,E,A,L,$,W,U,N,j,F){var V=0,re=E;re=re+L>>>0,V+=re>>0,V+=re>>0,V+=re>>0,V+=re>>0}_.sum64_5_hi=B;function z(C,E,A,L,$,W,U,N,j,F){var V=E+L+W+N+F;return V>>>0}_.sum64_5_lo=z;function D(C,E,A){var L=E<<32-A|C>>>A;return L>>>0}_.rotr64_hi=D;function M(C,E,A){var L=C<<32-A|E>>>A;return L>>>0}_.rotr64_lo=M;function I(C,E,A){return C>>>A}_.shr64_hi=I;function T(C,E,A){var L=C<<32-A|E>>>A;return L>>>0}_.shr64_lo=T},{inherits:387,"minimalistic-assert":437}],384:[function(e,S,_){var u=e("hash.js"),y=e("minimalistic-crypto-utils"),g=e("minimalistic-assert");function b(w){if(!(this instanceof b))return new b(w);this.hash=w.hash,this.predResist=!!w.predResist,this.outLen=this.hash.outSize,this.minEntropy=w.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var f=y.toArray(w.entropy,w.entropyEnc||"hex"),v=y.toArray(w.nonce,w.nonceEnc||"hex"),h=y.toArray(w.pers,w.persEnc||"hex");g(f.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(f,v,h)}S.exports=b,b.prototype._init=function(f,v,h){var l=f.concat(v).concat(h);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var d=0;d=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(f.concat(h||[])),this._reseed=1},b.prototype.generate=function(f,v,h,l){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof v!="string"&&(l=h,h=v,v=null),h&&(h=y.toArray(h,l||"hex"),this._update(h));for(var d=[];d.length>1,s=-7,m=g?w-1:0,c=g?-1:1,a=u[y+m];for(m+=c,f=a&(1<<-s)-1,a>>=-s,s+=h;s>0;f=f*256+u[y+m],m+=c,s-=8);for(v=f&(1<<-s)-1,f>>=-s,s+=b;s>0;v=v*256+u[y+m],m+=c,s-=8);if(f===0)f=1-d;else{if(f===l)return v?NaN:(a?-1:1)*(1/0);v=v+Math.pow(2,b),f=f-d}return(a?-1:1)*v*Math.pow(2,f-b)},_.write=function(u,y,g,b,w,f){var v,h,l,d=f*8-w-1,s=(1<>1,c=w===23?Math.pow(2,-24)-Math.pow(2,-77):0,a=b?0:f-1,r=b?1:-1,t=y<0||y===0&&1/y<0?1:0;for(y=Math.abs(y),isNaN(y)||y===1/0?(h=isNaN(y)?1:0,v=s):(v=Math.floor(Math.log(y)/Math.LN2),y*(l=Math.pow(2,-v))<1&&(v--,l*=2),v+m>=1?y+=c/l:y+=c*Math.pow(2,1-m),y*l>=2&&(v++,l/=2),v+m>=s?(h=0,v=s):v+m>=1?(h=(y*l-1)*Math.pow(2,w),v=v+m):(h=y*Math.pow(2,m-1)*Math.pow(2,w),v=0));w>=8;u[g+a]=h&255,a+=r,h/=256,w-=8);for(v=v<0;u[g+a]=v&255,a+=r,v/=256,d-=8);u[g+a-r]|=t*128}},{}],386:[function(e,S,_){(function(u){var y=u.MutationObserver||u.WebKitMutationObserver,g;if(y){var b=0,w=new y(d),f=u.document.createTextNode("");w.observe(f,{characterData:!0}),g=function(){f.data=b=++b%2}}else if(!u.setImmediate&&typeof u.MessageChannel<"u"){var v=new u.MessageChannel;v.port1.onmessage=d,g=function(){v.port2.postMessage(0)}}else"document"in u&&"onreadystatechange"in u.document.createElement("script")?g=function(){var c=u.document.createElement("script");c.onreadystatechange=function(){d(),c.onreadystatechange=null,c.parentNode.removeChild(c),c=null},u.document.documentElement.appendChild(c)}:g=function(){setTimeout(d,0)};var h,l=[];function d(){h=!0;for(var m,c,a=l.length;a;){for(c=l,l=[],m=-1;++mthis.headersLength){if(!c.strictColumnHandling)throw new Error("Unexpected Error: column header mismatch expected: ".concat(this.headersLength," columns got: ").concat(m.length));return{row:m,isValid:!1,reason:"Column header mismatch expected: ".concat(this.headersLength," columns got: ").concat(m.length)}}return c.strictColumnHandling&&m.length1});throw new Error("Duplicate headers found ".concat(JSON.stringify(t)))}this.headers=m,this.receivedHeaders=!0,this.headersLength=((c=this.headers)===null||c===void 0?void 0:c.length)||0}}]),d}();_.HeaderTransformer=l},{"lodash.groupby":427,"lodash.isfunction":430,"lodash.isundefined":432,"lodash.uniq":433}],164:[function(e,S,_){function u(h,l){if(!(h instanceof l))throw new TypeError("Cannot call a class as a function")}function y(h,l){for(var d=0;d>6],a=(m&32)===0;if((m&31)===31){var r=m;for(m=0;(r&128)===128;){if(r=d.readUInt8(s),d.isError(r))return r;m<<=7,m|=r&127}}else m&=31;var t=w.tag[m];return{cls:c,primitive:a,tag:m,tagStr:t}}function l(d,s,m){var c=d.readUInt8(m);if(d.isError(c))return c;if(!s&&c===128)return null;if(!(c&128))return c;var a=c&127;if(a>4)return d.error("length octect is too long");c=0;for(var r=0;r=256;i>>=8)t++;var n=y.alloc(1+1+t);n[0]=a,n[1]=128|t;for(var o=1+t,p=c.length;p>0;o--,p>>=8)n[o]=p&255;return this._createEncoderBuffer([n,c])},f.prototype._encodeStr=function(d,s){if(s==="bitstr")return this._createEncoderBuffer([d.unused|0,d.data]);if(s==="bmpstr"){for(var m=y.alloc(d.length*2),c=0;c=40)return this.reporter.error("Second objid identifier OOB");d.splice(0,2,d[0]*40+d[1])}for(var r=0,t=0;t=128;i>>=7)r++}for(var n=y.alloc(r),o=n.length-1,p=d.length-1;p>=0;p--){var E=d[p];for(n[o--]=E&127;(E>>=7)>0;)n[o--]=128|E&127}return this._createEncoderBuffer(n)};function v(l){return l<10?"0"+l:l}f.prototype._encodeTime=function(d,s){var m,c=new Date(d);return s==="gentime"?m=[v(c.getUTCFullYear()),v(c.getUTCMonth()+1),v(c.getUTCDate()),v(c.getUTCHours()),v(c.getUTCMinutes()),v(c.getUTCSeconds()),"Z"].join(""):s==="utctime"?m=[v(c.getUTCFullYear()%100),v(c.getUTCMonth()+1),v(c.getUTCDate()),v(c.getUTCHours()),v(c.getUTCMinutes()),v(c.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+s+" time is not supported yet"),this._encodeStr(m,"octstr")},f.prototype._encodeNull=function(){return this._createEncoderBuffer("")},f.prototype._encodeInt=function(d,s){if(typeof d=="string"){if(!s)return this.reporter.error("String int or enum given, but no values map");if(!s.hasOwnProperty(d))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(d));d=s[d]}if(typeof d!="number"&&!y.isBuffer(d)){var m=d.toArray();!d.sign&&m[0]&128&&m.unshift(0),d=y.from(m)}if(y.isBuffer(d)){var c=d.length;d.length===0&&c++;var a=y.alloc(c);return d.copy(a),d.length===0&&(a[0]=0),this._createEncoderBuffer(a)}if(d<128)return this._createEncoderBuffer(d);if(d<256)return this._createEncoderBuffer([0,d]);for(var r=1,t=d;t>=256;t>>=8)r++;for(var i=new Array(r),n=i.length-1;n>=0;n--)i[n]=d&255,d>>=8;return i[0]&128&&i.unshift(0),this._createEncoderBuffer(y.from(i))},f.prototype._encodeBool=function(d){return this._createEncoderBuffer(d?255:0)},f.prototype._use=function(d,s){return typeof d=="function"&&(d=d(s)),d._getEncoder("der").tree},f.prototype._skipDefault=function(d,s,m){var c=this._baseState,a;if(c.default===null)return!1;var r=d.join();if(c.defaultBuffer===void 0&&(c.defaultBuffer=this._encodeValue(c.default,s,m).join()),r.length!==c.defaultBuffer.length)return!1;for(a=0;a=31?m.error("Multi-octet tag encoding unsupported"):(d||(c|=32),c|=b.tagClassByName[s||"universal"]<<6,c)}},{"../base/node":171,"../constants/der":173,inherits:387,"safer-buffer":495}],179:[function(e,S,_){var u=_;u.der=e("./der"),u.pem=e("./pem")},{"./der":178,"./pem":180}],180:[function(e,S,_){var u=e("inherits"),y=e("./der");function g(b){y.call(this,b),this.enc="pem"}u(g,y),S.exports=g,g.prototype.encode=function(w,f){for(var v=y.prototype.encode.call(this,w),h=v.toString("base64"),l=["-----BEGIN "+f.label+"-----"],d=0;d0?T:C},f.min=function(T,C){return T.cmp(C)<0?T:C},f.prototype._init=function(T,C,O){if(typeof T=="number")return this._initNumber(T,C,O);if(u(T)==="object")return this._initArray(T,C,O);C==="hex"&&(C=16),b(C===(C|0)&&C>=2&&C<=36),T=T.toString().replace(/\s+/g,"");var A=0;T[0]==="-"&&A++,C===16?this._parseHex(T,A):this._parseBase(T,C,A),T[0]==="-"&&(this.negative=1),this.strip(),O==="le"&&this._initArray(this.toArray(),C,O)},f.prototype._initNumber=function(T,C,O){T<0&&(this.negative=1,T=-T),T<67108864?(this.words=[T&67108863],this.length=1):T<4503599627370496?(this.words=[T&67108863,T/67108864&67108863],this.length=2):(b(T<9007199254740992),this.words=[T&67108863,T/67108864&67108863,1],this.length=3),O==="le"&&this._initArray(this.toArray(),C,O)},f.prototype._initArray=function(T,C,O){if(b(typeof T.length=="number"),T.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(T.length/3),this.words=new Array(this.length);for(var A=0;A=0;A-=3)U=T[A]|T[A-1]<<8|T[A-2]<<16,this.words[L]|=U<>>26-W&67108863,W+=24,W>=26&&(W-=26,L++);else if(O==="le")for(A=0,L=0;A>>26-W&67108863,W+=24,W>=26&&(W-=26,L++);return this.strip()};function h(I,T,C){for(var O=0,A=Math.min(I.length,C),L=T;L=49&&U<=54?O|=U-49+10:U>=17&&U<=22?O|=U-17+10:O|=U&15}return O}f.prototype._parseHex=function(T,C){this.length=Math.ceil((T.length-C)/6),this.words=new Array(this.length);for(var O=0;O=C;O-=6)L=h(T,O,O+6),this.words[A]|=L<>>26-U&4194303,U+=24,U>=26&&(U-=26,A++);O+6!==C&&(L=h(T,C,O+6),this.words[A]|=L<>>26-U&4194303),this.strip()};function l(I,T,C,O){for(var A=0,L=Math.min(I.length,C),U=T;U=49?A+=W-49+10:W>=17?A+=W-17+10:A+=W}return A}f.prototype._parseBase=function(T,C,O){this.words=[0],this.length=1;for(var A=0,L=1;L<=67108863;L*=C)A++;A--,L=L/C|0;for(var U=T.length-O,W=U%A,$=Math.min(U,U-W)+O,N=0,F=O;F<$;F+=A)N=l(T,F,F+A,C),this.imuln(L),this.words[0]+N<67108864?this.words[0]+=N:this._iaddn(N);if(W!==0){var j=1;for(N=l(T,F,T.length,C),F=0;F1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.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"],s=[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],m=[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];f.prototype.toString=function(T,C){T=T||10,C=C|0||1;var O;if(T===16||T==="hex"){O="";for(var A=0,L=0,U=0;U>>24-A&16777215,L!==0||U!==this.length-1?O=d[6-$.length]+$+O:O=$+O,A+=2,A>=26&&(A-=26,U--)}for(L!==0&&(O=L.toString(16)+O);O.length%C!==0;)O="0"+O;return this.negative!==0&&(O="-"+O),O}if(T===(T|0)&&T>=2&&T<=36){var N=s[T],F=m[T];O="";var j=this.clone();for(j.negative=0;!j.isZero();){var V=j.modn(F).toString(T);j=j.idivn(F),j.isZero()?O=V+O:O=d[N-V.length]+V+O}for(this.isZero()&&(O="0"+O);O.length%C!==0;)O="0"+O;return this.negative!==0&&(O="-"+O),O}b(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var T=this.words[0];return this.length===2?T+=this.words[1]*67108864:this.length===3&&this.words[2]===1?T+=4503599627370496+this.words[1]*67108864:this.length>2&&b(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-T:T},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(T,C){return b(typeof v<"u"),this.toArrayLike(v,T,C)},f.prototype.toArray=function(T,C){return this.toArrayLike(Array,T,C)},f.prototype.toArrayLike=function(T,C,O){var A=this.byteLength(),L=O||Math.max(1,A);b(A<=L,"byte array longer than desired length"),b(L>0,"Requested array length <= 0"),this.strip();var U=C==="le",W=new T(L),$,N,F=this.clone();if(U){for(N=0;!F.isZero();N++)$=F.andln(255),F.iushrn(8),W[N]=$;for(;N=4096&&(O+=13,C>>>=13),C>=64&&(O+=7,C>>>=7),C>=8&&(O+=4,C>>>=4),C>=2&&(O+=2,C>>>=2),O+C},f.prototype._zeroBits=function(T){if(T===0)return 26;var C=T,O=0;return C&8191||(O+=13,C>>>=13),C&127||(O+=7,C>>>=7),C&15||(O+=4,C>>>=4),C&3||(O+=2,C>>>=2),C&1||O++,O},f.prototype.bitLength=function(){var T=this.words[this.length-1],C=this._countBits(T);return(this.length-1)*26+C};function c(I){for(var T=new Array(I.bitLength()),C=0;C>>A}return T}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var T=0,C=0;CT.length?this.clone().ior(T):T.clone().ior(this)},f.prototype.uor=function(T){return this.length>T.length?this.clone().iuor(T):T.clone().iuor(this)},f.prototype.iuand=function(T){var C;this.length>T.length?C=T:C=this;for(var O=0;OT.length?this.clone().iand(T):T.clone().iand(this)},f.prototype.uand=function(T){return this.length>T.length?this.clone().iuand(T):T.clone().iuand(this)},f.prototype.iuxor=function(T){var C,O;this.length>T.length?(C=this,O=T):(C=T,O=this);for(var A=0;AT.length?this.clone().ixor(T):T.clone().ixor(this)},f.prototype.uxor=function(T){return this.length>T.length?this.clone().iuxor(T):T.clone().iuxor(this)},f.prototype.inotn=function(T){b(typeof T=="number"&&T>=0);var C=Math.ceil(T/26)|0,O=T%26;this._expand(C),O>0&&C--;for(var A=0;A0&&(this.words[A]=~this.words[A]&67108863>>26-O),this.strip()},f.prototype.notn=function(T){return this.clone().inotn(T)},f.prototype.setn=function(T,C){b(typeof T=="number"&&T>=0);var O=T/26|0,A=T%26;return this._expand(O+1),C?this.words[O]=this.words[O]|1<T.length?(O=this,A=T):(O=T,A=this);for(var L=0,U=0;U>>26;for(;L!==0&&U>>26;if(this.length=O.length,L!==0)this.words[this.length]=L,this.length++;else if(O!==this)for(;UT.length?this.clone().iadd(T):T.clone().iadd(this)},f.prototype.isub=function(T){if(T.negative!==0){T.negative=0;var C=this.iadd(T);return T.negative=1,C._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(T),this.negative=1,this._normSign();var O=this.cmp(T);if(O===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,L;O>0?(A=this,L=T):(A=T,L=this);for(var U=0,W=0;W>26,this.words[W]=C&67108863;for(;U!==0&&W>26,this.words[W]=C&67108863;if(U===0&&W>>26,j=$&67108863,V=Math.min(N,T.length-1),te=Math.max(0,N-I.length+1);te<=V;te++){var re=N-te|0;A=I.words[re]|0,L=T.words[te]|0,U=A*L+j,F+=U/67108864|0,j=U&67108863}C.words[N]=j|0,$=F|0}return $!==0?C.words[N]=$|0:C.length--,C.strip()}var r=function(T,C,O){var A=T.words,L=C.words,U=O.words,W=0,$,N,F,j=A[0]|0,V=j&8191,te=j>>>13,re=A[1]|0,le=re&8191,ye=re>>>13,ge=A[2]|0,ne=ge&8191,J=ge>>>13,Q=A[3]|0,he=Q&8191,xe=Q>>>13,ie=A[4]|0,se=ie&8191,Ce=ie>>>13,q=A[5]|0,G=q&8191,Y=q>>>13,fe=A[6]|0,we=fe&8191,_e=fe>>>13,je=A[7]|0,Ye=je&8191,nt=je>>>13,ut=A[8]|0,ot=ut&8191,Ue=ut>>>13,Ve=A[9]|0,Qe=Ve&8191,tt=Ve>>>13,oe=L[0]|0,Re=oe&8191,be=oe>>>13,Ee=L[1]|0,pe=Ee&8191,Pe=Ee>>>13,ee=L[2]|0,He=ee&8191,it=ee>>>13,K=L[3]|0,Me=K&8191,Le=K>>>13,ue=L[4]|0,ke=ue&8191,Ie=ue>>>13,st=L[5]|0,Ge=st&8191,rt=st>>>13,_t=L[6]|0,wt=_t&8191,Ot=_t>>>13,pt=L[7]|0,ct=pt&8191,At=pt>>>13,Pt=L[8]|0,bt=Pt&8191,Kt=Pt>>>13,Ct=L[9]|0,St=Ct&8191,Bt=Ct>>>13;O.negative=T.negative^C.negative,O.length=19,$=Math.imul(V,Re),N=Math.imul(V,be),N=N+Math.imul(te,Re)|0,F=Math.imul(te,be);var Lt=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,$=Math.imul(le,Re),N=Math.imul(le,be),N=N+Math.imul(ye,Re)|0,F=Math.imul(ye,be),$=$+Math.imul(V,pe)|0,N=N+Math.imul(V,Pe)|0,N=N+Math.imul(te,pe)|0,F=F+Math.imul(te,Pe)|0;var Et=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Et>>>26)|0,Et&=67108863,$=Math.imul(ne,Re),N=Math.imul(ne,be),N=N+Math.imul(J,Re)|0,F=Math.imul(J,be),$=$+Math.imul(le,pe)|0,N=N+Math.imul(le,Pe)|0,N=N+Math.imul(ye,pe)|0,F=F+Math.imul(ye,Pe)|0,$=$+Math.imul(V,He)|0,N=N+Math.imul(V,it)|0,N=N+Math.imul(te,He)|0,F=F+Math.imul(te,it)|0;var Nr=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,$=Math.imul(he,Re),N=Math.imul(he,be),N=N+Math.imul(xe,Re)|0,F=Math.imul(xe,be),$=$+Math.imul(ne,pe)|0,N=N+Math.imul(ne,Pe)|0,N=N+Math.imul(J,pe)|0,F=F+Math.imul(J,Pe)|0,$=$+Math.imul(le,He)|0,N=N+Math.imul(le,it)|0,N=N+Math.imul(ye,He)|0,F=F+Math.imul(ye,it)|0,$=$+Math.imul(V,Me)|0,N=N+Math.imul(V,Le)|0,N=N+Math.imul(te,Me)|0,F=F+Math.imul(te,Le)|0;var Or=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Or>>>26)|0,Or&=67108863,$=Math.imul(se,Re),N=Math.imul(se,be),N=N+Math.imul(Ce,Re)|0,F=Math.imul(Ce,be),$=$+Math.imul(he,pe)|0,N=N+Math.imul(he,Pe)|0,N=N+Math.imul(xe,pe)|0,F=F+Math.imul(xe,Pe)|0,$=$+Math.imul(ne,He)|0,N=N+Math.imul(ne,it)|0,N=N+Math.imul(J,He)|0,F=F+Math.imul(J,it)|0,$=$+Math.imul(le,Me)|0,N=N+Math.imul(le,Le)|0,N=N+Math.imul(ye,Me)|0,F=F+Math.imul(ye,Le)|0,$=$+Math.imul(V,ke)|0,N=N+Math.imul(V,Ie)|0,N=N+Math.imul(te,ke)|0,F=F+Math.imul(te,Ie)|0;var Gr=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,$=Math.imul(G,Re),N=Math.imul(G,be),N=N+Math.imul(Y,Re)|0,F=Math.imul(Y,be),$=$+Math.imul(se,pe)|0,N=N+Math.imul(se,Pe)|0,N=N+Math.imul(Ce,pe)|0,F=F+Math.imul(Ce,Pe)|0,$=$+Math.imul(he,He)|0,N=N+Math.imul(he,it)|0,N=N+Math.imul(xe,He)|0,F=F+Math.imul(xe,it)|0,$=$+Math.imul(ne,Me)|0,N=N+Math.imul(ne,Le)|0,N=N+Math.imul(J,Me)|0,F=F+Math.imul(J,Le)|0,$=$+Math.imul(le,ke)|0,N=N+Math.imul(le,Ie)|0,N=N+Math.imul(ye,ke)|0,F=F+Math.imul(ye,Ie)|0,$=$+Math.imul(V,Ge)|0,N=N+Math.imul(V,rt)|0,N=N+Math.imul(te,Ge)|0,F=F+Math.imul(te,rt)|0;var Dr=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,$=Math.imul(we,Re),N=Math.imul(we,be),N=N+Math.imul(_e,Re)|0,F=Math.imul(_e,be),$=$+Math.imul(G,pe)|0,N=N+Math.imul(G,Pe)|0,N=N+Math.imul(Y,pe)|0,F=F+Math.imul(Y,Pe)|0,$=$+Math.imul(se,He)|0,N=N+Math.imul(se,it)|0,N=N+Math.imul(Ce,He)|0,F=F+Math.imul(Ce,it)|0,$=$+Math.imul(he,Me)|0,N=N+Math.imul(he,Le)|0,N=N+Math.imul(xe,Me)|0,F=F+Math.imul(xe,Le)|0,$=$+Math.imul(ne,ke)|0,N=N+Math.imul(ne,Ie)|0,N=N+Math.imul(J,ke)|0,F=F+Math.imul(J,Ie)|0,$=$+Math.imul(le,Ge)|0,N=N+Math.imul(le,rt)|0,N=N+Math.imul(ye,Ge)|0,F=F+Math.imul(ye,rt)|0,$=$+Math.imul(V,wt)|0,N=N+Math.imul(V,Ot)|0,N=N+Math.imul(te,wt)|0,F=F+Math.imul(te,Ot)|0;var Yr=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,$=Math.imul(Ye,Re),N=Math.imul(Ye,be),N=N+Math.imul(nt,Re)|0,F=Math.imul(nt,be),$=$+Math.imul(we,pe)|0,N=N+Math.imul(we,Pe)|0,N=N+Math.imul(_e,pe)|0,F=F+Math.imul(_e,Pe)|0,$=$+Math.imul(G,He)|0,N=N+Math.imul(G,it)|0,N=N+Math.imul(Y,He)|0,F=F+Math.imul(Y,it)|0,$=$+Math.imul(se,Me)|0,N=N+Math.imul(se,Le)|0,N=N+Math.imul(Ce,Me)|0,F=F+Math.imul(Ce,Le)|0,$=$+Math.imul(he,ke)|0,N=N+Math.imul(he,Ie)|0,N=N+Math.imul(xe,ke)|0,F=F+Math.imul(xe,Ie)|0,$=$+Math.imul(ne,Ge)|0,N=N+Math.imul(ne,rt)|0,N=N+Math.imul(J,Ge)|0,F=F+Math.imul(J,rt)|0,$=$+Math.imul(le,wt)|0,N=N+Math.imul(le,Ot)|0,N=N+Math.imul(ye,wt)|0,F=F+Math.imul(ye,Ot)|0,$=$+Math.imul(V,ct)|0,N=N+Math.imul(V,At)|0,N=N+Math.imul(te,ct)|0,F=F+Math.imul(te,At)|0;var Qt=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,$=Math.imul(ot,Re),N=Math.imul(ot,be),N=N+Math.imul(Ue,Re)|0,F=Math.imul(Ue,be),$=$+Math.imul(Ye,pe)|0,N=N+Math.imul(Ye,Pe)|0,N=N+Math.imul(nt,pe)|0,F=F+Math.imul(nt,Pe)|0,$=$+Math.imul(we,He)|0,N=N+Math.imul(we,it)|0,N=N+Math.imul(_e,He)|0,F=F+Math.imul(_e,it)|0,$=$+Math.imul(G,Me)|0,N=N+Math.imul(G,Le)|0,N=N+Math.imul(Y,Me)|0,F=F+Math.imul(Y,Le)|0,$=$+Math.imul(se,ke)|0,N=N+Math.imul(se,Ie)|0,N=N+Math.imul(Ce,ke)|0,F=F+Math.imul(Ce,Ie)|0,$=$+Math.imul(he,Ge)|0,N=N+Math.imul(he,rt)|0,N=N+Math.imul(xe,Ge)|0,F=F+Math.imul(xe,rt)|0,$=$+Math.imul(ne,wt)|0,N=N+Math.imul(ne,Ot)|0,N=N+Math.imul(J,wt)|0,F=F+Math.imul(J,Ot)|0,$=$+Math.imul(le,ct)|0,N=N+Math.imul(le,At)|0,N=N+Math.imul(ye,ct)|0,F=F+Math.imul(ye,At)|0,$=$+Math.imul(V,bt)|0,N=N+Math.imul(V,Kt)|0,N=N+Math.imul(te,bt)|0,F=F+Math.imul(te,Kt)|0;var Xr=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,$=Math.imul(Qe,Re),N=Math.imul(Qe,be),N=N+Math.imul(tt,Re)|0,F=Math.imul(tt,be),$=$+Math.imul(ot,pe)|0,N=N+Math.imul(ot,Pe)|0,N=N+Math.imul(Ue,pe)|0,F=F+Math.imul(Ue,Pe)|0,$=$+Math.imul(Ye,He)|0,N=N+Math.imul(Ye,it)|0,N=N+Math.imul(nt,He)|0,F=F+Math.imul(nt,it)|0,$=$+Math.imul(we,Me)|0,N=N+Math.imul(we,Le)|0,N=N+Math.imul(_e,Me)|0,F=F+Math.imul(_e,Le)|0,$=$+Math.imul(G,ke)|0,N=N+Math.imul(G,Ie)|0,N=N+Math.imul(Y,ke)|0,F=F+Math.imul(Y,Ie)|0,$=$+Math.imul(se,Ge)|0,N=N+Math.imul(se,rt)|0,N=N+Math.imul(Ce,Ge)|0,F=F+Math.imul(Ce,rt)|0,$=$+Math.imul(he,wt)|0,N=N+Math.imul(he,Ot)|0,N=N+Math.imul(xe,wt)|0,F=F+Math.imul(xe,Ot)|0,$=$+Math.imul(ne,ct)|0,N=N+Math.imul(ne,At)|0,N=N+Math.imul(J,ct)|0,F=F+Math.imul(J,At)|0,$=$+Math.imul(le,bt)|0,N=N+Math.imul(le,Kt)|0,N=N+Math.imul(ye,bt)|0,F=F+Math.imul(ye,Kt)|0,$=$+Math.imul(V,St)|0,N=N+Math.imul(V,Bt)|0,N=N+Math.imul(te,St)|0,F=F+Math.imul(te,Bt)|0;var Br=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Br>>>26)|0,Br&=67108863,$=Math.imul(Qe,pe),N=Math.imul(Qe,Pe),N=N+Math.imul(tt,pe)|0,F=Math.imul(tt,Pe),$=$+Math.imul(ot,He)|0,N=N+Math.imul(ot,it)|0,N=N+Math.imul(Ue,He)|0,F=F+Math.imul(Ue,it)|0,$=$+Math.imul(Ye,Me)|0,N=N+Math.imul(Ye,Le)|0,N=N+Math.imul(nt,Me)|0,F=F+Math.imul(nt,Le)|0,$=$+Math.imul(we,ke)|0,N=N+Math.imul(we,Ie)|0,N=N+Math.imul(_e,ke)|0,F=F+Math.imul(_e,Ie)|0,$=$+Math.imul(G,Ge)|0,N=N+Math.imul(G,rt)|0,N=N+Math.imul(Y,Ge)|0,F=F+Math.imul(Y,rt)|0,$=$+Math.imul(se,wt)|0,N=N+Math.imul(se,Ot)|0,N=N+Math.imul(Ce,wt)|0,F=F+Math.imul(Ce,Ot)|0,$=$+Math.imul(he,ct)|0,N=N+Math.imul(he,At)|0,N=N+Math.imul(xe,ct)|0,F=F+Math.imul(xe,At)|0,$=$+Math.imul(ne,bt)|0,N=N+Math.imul(ne,Kt)|0,N=N+Math.imul(J,bt)|0,F=F+Math.imul(J,Kt)|0,$=$+Math.imul(le,St)|0,N=N+Math.imul(le,Bt)|0,N=N+Math.imul(ye,St)|0,F=F+Math.imul(ye,Bt)|0;var Lr=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Lr>>>26)|0,Lr&=67108863,$=Math.imul(Qe,He),N=Math.imul(Qe,it),N=N+Math.imul(tt,He)|0,F=Math.imul(tt,it),$=$+Math.imul(ot,Me)|0,N=N+Math.imul(ot,Le)|0,N=N+Math.imul(Ue,Me)|0,F=F+Math.imul(Ue,Le)|0,$=$+Math.imul(Ye,ke)|0,N=N+Math.imul(Ye,Ie)|0,N=N+Math.imul(nt,ke)|0,F=F+Math.imul(nt,Ie)|0,$=$+Math.imul(we,Ge)|0,N=N+Math.imul(we,rt)|0,N=N+Math.imul(_e,Ge)|0,F=F+Math.imul(_e,rt)|0,$=$+Math.imul(G,wt)|0,N=N+Math.imul(G,Ot)|0,N=N+Math.imul(Y,wt)|0,F=F+Math.imul(Y,Ot)|0,$=$+Math.imul(se,ct)|0,N=N+Math.imul(se,At)|0,N=N+Math.imul(Ce,ct)|0,F=F+Math.imul(Ce,At)|0,$=$+Math.imul(he,bt)|0,N=N+Math.imul(he,Kt)|0,N=N+Math.imul(xe,bt)|0,F=F+Math.imul(xe,Kt)|0,$=$+Math.imul(ne,St)|0,N=N+Math.imul(ne,Bt)|0,N=N+Math.imul(J,St)|0,F=F+Math.imul(J,Bt)|0;var Ur=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,$=Math.imul(Qe,Me),N=Math.imul(Qe,Le),N=N+Math.imul(tt,Me)|0,F=Math.imul(tt,Le),$=$+Math.imul(ot,ke)|0,N=N+Math.imul(ot,Ie)|0,N=N+Math.imul(Ue,ke)|0,F=F+Math.imul(Ue,Ie)|0,$=$+Math.imul(Ye,Ge)|0,N=N+Math.imul(Ye,rt)|0,N=N+Math.imul(nt,Ge)|0,F=F+Math.imul(nt,rt)|0,$=$+Math.imul(we,wt)|0,N=N+Math.imul(we,Ot)|0,N=N+Math.imul(_e,wt)|0,F=F+Math.imul(_e,Ot)|0,$=$+Math.imul(G,ct)|0,N=N+Math.imul(G,At)|0,N=N+Math.imul(Y,ct)|0,F=F+Math.imul(Y,At)|0,$=$+Math.imul(se,bt)|0,N=N+Math.imul(se,Kt)|0,N=N+Math.imul(Ce,bt)|0,F=F+Math.imul(Ce,Kt)|0,$=$+Math.imul(he,St)|0,N=N+Math.imul(he,Bt)|0,N=N+Math.imul(xe,St)|0,F=F+Math.imul(xe,Bt)|0;var yt=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(yt>>>26)|0,yt&=67108863,$=Math.imul(Qe,ke),N=Math.imul(Qe,Ie),N=N+Math.imul(tt,ke)|0,F=Math.imul(tt,Ie),$=$+Math.imul(ot,Ge)|0,N=N+Math.imul(ot,rt)|0,N=N+Math.imul(Ue,Ge)|0,F=F+Math.imul(Ue,rt)|0,$=$+Math.imul(Ye,wt)|0,N=N+Math.imul(Ye,Ot)|0,N=N+Math.imul(nt,wt)|0,F=F+Math.imul(nt,Ot)|0,$=$+Math.imul(we,ct)|0,N=N+Math.imul(we,At)|0,N=N+Math.imul(_e,ct)|0,F=F+Math.imul(_e,At)|0,$=$+Math.imul(G,bt)|0,N=N+Math.imul(G,Kt)|0,N=N+Math.imul(Y,bt)|0,F=F+Math.imul(Y,Kt)|0,$=$+Math.imul(se,St)|0,N=N+Math.imul(se,Bt)|0,N=N+Math.imul(Ce,St)|0,F=F+Math.imul(Ce,Bt)|0;var Ke=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,$=Math.imul(Qe,Ge),N=Math.imul(Qe,rt),N=N+Math.imul(tt,Ge)|0,F=Math.imul(tt,rt),$=$+Math.imul(ot,wt)|0,N=N+Math.imul(ot,Ot)|0,N=N+Math.imul(Ue,wt)|0,F=F+Math.imul(Ue,Ot)|0,$=$+Math.imul(Ye,ct)|0,N=N+Math.imul(Ye,At)|0,N=N+Math.imul(nt,ct)|0,F=F+Math.imul(nt,At)|0,$=$+Math.imul(we,bt)|0,N=N+Math.imul(we,Kt)|0,N=N+Math.imul(_e,bt)|0,F=F+Math.imul(_e,Kt)|0,$=$+Math.imul(G,St)|0,N=N+Math.imul(G,Bt)|0,N=N+Math.imul(Y,St)|0,F=F+Math.imul(Y,Bt)|0;var me=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(me>>>26)|0,me&=67108863,$=Math.imul(Qe,wt),N=Math.imul(Qe,Ot),N=N+Math.imul(tt,wt)|0,F=Math.imul(tt,Ot),$=$+Math.imul(ot,ct)|0,N=N+Math.imul(ot,At)|0,N=N+Math.imul(Ue,ct)|0,F=F+Math.imul(Ue,At)|0,$=$+Math.imul(Ye,bt)|0,N=N+Math.imul(Ye,Kt)|0,N=N+Math.imul(nt,bt)|0,F=F+Math.imul(nt,Kt)|0,$=$+Math.imul(we,St)|0,N=N+Math.imul(we,Bt)|0,N=N+Math.imul(_e,St)|0,F=F+Math.imul(_e,Bt)|0;var Be=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Be>>>26)|0,Be&=67108863,$=Math.imul(Qe,ct),N=Math.imul(Qe,At),N=N+Math.imul(tt,ct)|0,F=Math.imul(tt,At),$=$+Math.imul(ot,bt)|0,N=N+Math.imul(ot,Kt)|0,N=N+Math.imul(Ue,bt)|0,F=F+Math.imul(Ue,Kt)|0,$=$+Math.imul(Ye,St)|0,N=N+Math.imul(Ye,Bt)|0,N=N+Math.imul(nt,St)|0,F=F+Math.imul(nt,Bt)|0;var Fe=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,$=Math.imul(Qe,bt),N=Math.imul(Qe,Kt),N=N+Math.imul(tt,bt)|0,F=Math.imul(tt,Kt),$=$+Math.imul(ot,St)|0,N=N+Math.imul(ot,Bt)|0,N=N+Math.imul(Ue,St)|0,F=F+Math.imul(Ue,Bt)|0;var dt=(W+$|0)+((N&8191)<<13)|0;W=(F+(N>>>13)|0)+(dt>>>26)|0,dt&=67108863,$=Math.imul(Qe,St),N=Math.imul(Qe,Bt),N=N+Math.imul(tt,St)|0,F=Math.imul(tt,Bt);var kt=(W+$|0)+((N&8191)<<13)|0;return W=(F+(N>>>13)|0)+(kt>>>26)|0,kt&=67108863,U[0]=Lt,U[1]=Et,U[2]=Nr,U[3]=Or,U[4]=Gr,U[5]=Dr,U[6]=Yr,U[7]=Qt,U[8]=Xr,U[9]=Br,U[10]=Lr,U[11]=Ur,U[12]=yt,U[13]=Ke,U[14]=me,U[15]=Be,U[16]=Fe,U[17]=dt,U[18]=kt,W!==0&&(U[19]=W,O.length++),O};Math.imul||(r=a);function t(I,T,C){C.negative=T.negative^I.negative,C.length=I.length+T.length;for(var O=0,A=0,L=0;L>>26)|0,A+=U>>>26,U&=67108863}C.words[L]=W,O=U,U=A}return O!==0?C.words[L]=O:C.length--,C.strip()}function i(I,T,C){var O=new n;return O.mulp(I,T,C)}f.prototype.mulTo=function(T,C){var O,A=this.length+T.length;return this.length===10&&T.length===10?O=r(this,T,C):A<63?O=a(this,T,C):A<1024?O=t(this,T,C):O=i(this,T,C),O};function n(I,T){this.x=I,this.y=T}n.prototype.makeRBT=function(T){for(var C=new Array(T),O=f.prototype._countBits(T)-1,A=0;A>=1;return A},n.prototype.permute=function(T,C,O,A,L,U){for(var W=0;W>>1)L++;return 1<>>13,O[2*U+1]=L&8191,L=L>>>13;for(U=2*C;U>=26,C+=A/67108864|0,C+=L>>>26,this.words[O]=L&67108863}return C!==0&&(this.words[O]=C,this.length++),this},f.prototype.muln=function(T){return this.clone().imuln(T)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(T){var C=c(T);if(C.length===0)return new f(1);for(var O=this,A=0;A=0);var C=T%26,O=(T-C)/26,A=67108863>>>26-C<<26-C,L;if(C!==0){var U=0;for(L=0;L>>26-C}U&&(this.words[L]=U,this.length++)}if(O!==0){for(L=this.length-1;L>=0;L--)this.words[L+O]=this.words[L];for(L=0;L=0);var A;C?A=(C-C%26)/26:A=0;var L=T%26,U=Math.min((T-L)/26,this.length),W=67108863^67108863>>>L<U)for(this.length-=U,N=0;N=0&&(F!==0||N>=A);N--){var j=this.words[N]|0;this.words[N]=F<<26-L|j>>>L,F=j&W}return $&&F!==0&&($.words[$.length++]=F),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(T,C,O){return b(this.negative===0),this.iushrn(T,C,O)},f.prototype.shln=function(T){return this.clone().ishln(T)},f.prototype.ushln=function(T){return this.clone().iushln(T)},f.prototype.shrn=function(T){return this.clone().ishrn(T)},f.prototype.ushrn=function(T){return this.clone().iushrn(T)},f.prototype.testn=function(T){b(typeof T=="number"&&T>=0);var C=T%26,O=(T-C)/26,A=1<=0);var C=T%26,O=(T-C)/26;if(b(this.negative===0,"imaskn works only with positive numbers"),this.length<=O)return this;if(C!==0&&O++,this.length=Math.min(O,this.length),C!==0){var A=67108863^67108863>>>C<=67108864;C++)this.words[C]-=67108864,C===this.length-1?this.words[C+1]=1:this.words[C+1]++;return this.length=Math.max(this.length,C+1),this},f.prototype.isubn=function(T){if(b(typeof T=="number"),b(T<67108864),T<0)return this.iaddn(-T);if(this.negative!==0)return this.negative=0,this.iaddn(T),this.negative=1,this;if(this.words[0]-=T,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var C=0;C>26)-($/67108864|0),this.words[L+O]=U&67108863}for(;L>26,this.words[L+O]=U&67108863;if(W===0)return this.strip();for(b(W===-1),W=0,L=0;L>26,this.words[L]=U&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(T,C){var O=this.length-T.length,A=this.clone(),L=T,U=L.words[L.length-1]|0,W=this._countBits(U);O=26-W,O!==0&&(L=L.ushln(O),A.iushln(O),U=L.words[L.length-1]|0);var $=A.length-L.length,N;if(C!=="mod"){N=new f(null),N.length=$+1,N.words=new Array(N.length);for(var F=0;F=0;V--){var te=(A.words[L.length+V]|0)*67108864+(A.words[L.length+V-1]|0);for(te=Math.min(te/U|0,67108863),A._ishlnsubmul(L,te,V);A.negative!==0;)te--,A.negative=0,A._ishlnsubmul(L,1,V),A.isZero()||(A.negative^=1);N&&(N.words[V]=te)}return N&&N.strip(),A.strip(),C!=="div"&&O!==0&&A.iushrn(O),{div:N||null,mod:A}},f.prototype.divmod=function(T,C,O){if(b(!T.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var A,L,U;return this.negative!==0&&T.negative===0?(U=this.neg().divmod(T,C),C!=="mod"&&(A=U.div.neg()),C!=="div"&&(L=U.mod.neg(),O&&L.negative!==0&&L.iadd(T)),{div:A,mod:L}):this.negative===0&&T.negative!==0?(U=this.divmod(T.neg(),C),C!=="mod"&&(A=U.div.neg()),{div:A,mod:U.mod}):this.negative&T.negative?(U=this.neg().divmod(T.neg(),C),C!=="div"&&(L=U.mod.neg(),O&&L.negative!==0&&L.isub(T)),{div:U.div,mod:L}):T.length>this.length||this.cmp(T)<0?{div:new f(0),mod:this}:T.length===1?C==="div"?{div:this.divn(T.words[0]),mod:null}:C==="mod"?{div:null,mod:new f(this.modn(T.words[0]))}:{div:this.divn(T.words[0]),mod:new f(this.modn(T.words[0]))}:this._wordDiv(T,C)},f.prototype.div=function(T){return this.divmod(T,"div",!1).div},f.prototype.mod=function(T){return this.divmod(T,"mod",!1).mod},f.prototype.umod=function(T){return this.divmod(T,"mod",!0).mod},f.prototype.divRound=function(T){var C=this.divmod(T);if(C.mod.isZero())return C.div;var O=C.div.negative!==0?C.mod.isub(T):C.mod,A=T.ushrn(1),L=T.andln(1),U=O.cmp(A);return U<0||L===1&&U===0?C.div:C.div.negative!==0?C.div.isubn(1):C.div.iaddn(1)},f.prototype.modn=function(T){b(T<=67108863);for(var C=(1<<26)%T,O=0,A=this.length-1;A>=0;A--)O=(C*O+(this.words[A]|0))%T;return O},f.prototype.idivn=function(T){b(T<=67108863);for(var C=0,O=this.length-1;O>=0;O--){var A=(this.words[O]|0)+C*67108864;this.words[O]=A/T|0,C=A%T}return this.strip()},f.prototype.divn=function(T){return this.clone().idivn(T)},f.prototype.egcd=function(T){b(T.negative===0),b(!T.isZero());var C=this,O=T.clone();C.negative!==0?C=C.umod(T):C=C.clone();for(var A=new f(1),L=new f(0),U=new f(0),W=new f(1),$=0;C.isEven()&&O.isEven();)C.iushrn(1),O.iushrn(1),++$;for(var N=O.clone(),F=C.clone();!C.isZero();){for(var j=0,V=1;!(C.words[0]&V)&&j<26;++j,V<<=1);if(j>0)for(C.iushrn(j);j-- >0;)(A.isOdd()||L.isOdd())&&(A.iadd(N),L.isub(F)),A.iushrn(1),L.iushrn(1);for(var te=0,re=1;!(O.words[0]&re)&&te<26;++te,re<<=1);if(te>0)for(O.iushrn(te);te-- >0;)(U.isOdd()||W.isOdd())&&(U.iadd(N),W.isub(F)),U.iushrn(1),W.iushrn(1);C.cmp(O)>=0?(C.isub(O),A.isub(U),L.isub(W)):(O.isub(C),U.isub(A),W.isub(L))}return{a:U,b:W,gcd:O.iushln($)}},f.prototype._invmp=function(T){b(T.negative===0),b(!T.isZero());var C=this,O=T.clone();C.negative!==0?C=C.umod(T):C=C.clone();for(var A=new f(1),L=new f(0),U=O.clone();C.cmpn(1)>0&&O.cmpn(1)>0;){for(var W=0,$=1;!(C.words[0]&$)&&W<26;++W,$<<=1);if(W>0)for(C.iushrn(W);W-- >0;)A.isOdd()&&A.iadd(U),A.iushrn(1);for(var N=0,F=1;!(O.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(O.iushrn(N);N-- >0;)L.isOdd()&&L.iadd(U),L.iushrn(1);C.cmp(O)>=0?(C.isub(O),A.isub(L)):(O.isub(C),L.isub(A))}var j;return C.cmpn(1)===0?j=A:j=L,j.cmpn(0)<0&&j.iadd(T),j},f.prototype.gcd=function(T){if(this.isZero())return T.abs();if(T.isZero())return this.abs();var C=this.clone(),O=T.clone();C.negative=0,O.negative=0;for(var A=0;C.isEven()&&O.isEven();A++)C.iushrn(1),O.iushrn(1);do{for(;C.isEven();)C.iushrn(1);for(;O.isEven();)O.iushrn(1);var L=C.cmp(O);if(L<0){var U=C;C=O,O=U}else if(L===0||O.cmpn(1)===0)break;C.isub(O)}while(!0);return O.iushln(A)},f.prototype.invm=function(T){return this.egcd(T).a.umod(T)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(T){return this.words[0]&T},f.prototype.bincn=function(T){b(typeof T=="number");var C=T%26,O=(T-C)/26,A=1<>>26,W&=67108863,this.words[U]=W}return L!==0&&(this.words[U]=L,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(T){var C=T<0;if(this.negative!==0&&!C)return-1;if(this.negative===0&&C)return 1;this.strip();var O;if(this.length>1)O=1;else{C&&(T=-T),b(T<=67108863,"Number is too big");var A=this.words[0]|0;O=A===T?0:AT.length)return 1;if(this.length=0;O--){var A=this.words[O]|0,L=T.words[O]|0;if(A!==L){AL&&(C=1);break}}return C},f.prototype.gtn=function(T){return this.cmpn(T)===1},f.prototype.gt=function(T){return this.cmp(T)===1},f.prototype.gten=function(T){return this.cmpn(T)>=0},f.prototype.gte=function(T){return this.cmp(T)>=0},f.prototype.ltn=function(T){return this.cmpn(T)===-1},f.prototype.lt=function(T){return this.cmp(T)===-1},f.prototype.lten=function(T){return this.cmpn(T)<=0},f.prototype.lte=function(T){return this.cmp(T)<=0},f.prototype.eqn=function(T){return this.cmpn(T)===0},f.prototype.eq=function(T){return this.cmp(T)===0},f.red=function(T){return new B(T)},f.prototype.toRed=function(T){return b(!this.red,"Already a number in reduction context"),b(this.negative===0,"red works only with positives"),T.convertTo(this)._forceRed(T)},f.prototype.fromRed=function(){return b(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(T){return this.red=T,this},f.prototype.forceRed=function(T){return b(!this.red,"Already a number in reduction context"),this._forceRed(T)},f.prototype.redAdd=function(T){return b(this.red,"redAdd works only with red numbers"),this.red.add(this,T)},f.prototype.redIAdd=function(T){return b(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,T)},f.prototype.redSub=function(T){return b(this.red,"redSub works only with red numbers"),this.red.sub(this,T)},f.prototype.redISub=function(T){return b(this.red,"redISub works only with red numbers"),this.red.isub(this,T)},f.prototype.redShl=function(T){return b(this.red,"redShl works only with red numbers"),this.red.shl(this,T)},f.prototype.redMul=function(T){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.mul(this,T)},f.prototype.redIMul=function(T){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.imul(this,T)},f.prototype.redSqr=function(){return b(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return b(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return b(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return b(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return b(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(T){return b(this.red&&!T.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,T)};var o={k256:null,p224:null,p192:null,p25519:null};function p(I,T){this.name=I,this.p=new f(T,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}p.prototype._tmp=function(){var T=new f(null);return T.words=new Array(Math.ceil(this.n/13)),T},p.prototype.ireduce=function(T){var C=T,O;do this.split(C,this.tmp),C=this.imulK(C),C=C.iadd(this.tmp),O=C.bitLength();while(O>this.n);var A=O0?C.isub(this.p):C.strip!==void 0?C.strip():C._strip(),C},p.prototype.split=function(T,C){T.iushrn(this.n,0,C)},p.prototype.imulK=function(T){return T.imul(this.k)};function E(){p.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}w(E,p),E.prototype.split=function(T,C){for(var O=4194303,A=Math.min(T.length,9),L=0;L>>22,U=W}U>>>=22,T.words[L-10]=U,U===0&&T.length>10?T.length-=10:T.length-=9},E.prototype.imulK=function(T){T.words[T.length]=0,T.words[T.length+1]=0,T.length+=2;for(var C=0,O=0;O>>=26,T.words[O]=L,C=A}return C!==0&&(T.words[T.length++]=C),T},f._prime=function(T){if(o[T])return o[T];var C;if(T==="k256")C=new E;else if(T==="p224")C=new P;else if(T==="p192")C=new D;else if(T==="p25519")C=new z;else throw new Error("Unknown prime "+T);return o[T]=C,C};function B(I){if(typeof I=="string"){var T=f._prime(I);this.m=T.p,this.prime=T}else b(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}B.prototype._verify1=function(T){b(T.negative===0,"red works only with positives"),b(T.red,"red works only with red numbers")},B.prototype._verify2=function(T,C){b((T.negative|C.negative)===0,"red works only with positives"),b(T.red&&T.red===C.red,"red works only with red numbers")},B.prototype.imod=function(T){return this.prime?this.prime.ireduce(T)._forceRed(this):T.umod(this.m)._forceRed(this)},B.prototype.neg=function(T){return T.isZero()?T.clone():this.m.sub(T)._forceRed(this)},B.prototype.add=function(T,C){this._verify2(T,C);var O=T.add(C);return O.cmp(this.m)>=0&&O.isub(this.m),O._forceRed(this)},B.prototype.iadd=function(T,C){this._verify2(T,C);var O=T.iadd(C);return O.cmp(this.m)>=0&&O.isub(this.m),O},B.prototype.sub=function(T,C){this._verify2(T,C);var O=T.sub(C);return O.cmpn(0)<0&&O.iadd(this.m),O._forceRed(this)},B.prototype.isub=function(T,C){this._verify2(T,C);var O=T.isub(C);return O.cmpn(0)<0&&O.iadd(this.m),O},B.prototype.shl=function(T,C){return this._verify1(T),this.imod(T.ushln(C))},B.prototype.imul=function(T,C){return this._verify2(T,C),this.imod(T.imul(C))},B.prototype.mul=function(T,C){return this._verify2(T,C),this.imod(T.mul(C))},B.prototype.isqr=function(T){return this.imul(T,T.clone())},B.prototype.sqr=function(T){return this.mul(T,T)},B.prototype.sqrt=function(T){if(T.isZero())return T.clone();var C=this.m.andln(3);if(b(C%2===1),C===3){var O=this.m.add(new f(1)).iushrn(2);return this.pow(T,O)}for(var A=this.m.subn(1),L=0;!A.isZero()&&A.andln(1)===0;)L++,A.iushrn(1);b(!A.isZero());var U=new f(1).toRed(this),W=U.redNeg(),$=this.m.subn(1).iushrn(1),N=this.m.bitLength();for(N=new f(2*N*N).toRed(this);this.pow(N,$).cmp(W)!==0;)N.redIAdd(W);for(var F=this.pow(N,A),j=this.pow(T,A.addn(1).iushrn(1)),V=this.pow(T,A),te=L;V.cmp(U)!==0;){for(var re=V,le=0;re.cmp(U)!==0;le++)re=re.redSqr();b(le=0;L--){for(var F=C.words[L],j=N-1;j>=0;j--){var V=F>>j&1;if(U!==A[0]&&(U=this.sqr(U)),V===0&&W===0){$=0;continue}W<<=1,W|=V,$++,!($!==O&&(L!==0||j!==0))&&(U=this.mul(U,A[W]),$=0,W=0)}N=26}return U},B.prototype.convertTo=function(T){var C=T.umod(this.m);return C===T?C.clone():C},B.prototype.convertFrom=function(T){var C=T.clone();return C.red=null,C},f.mont=function(T){return new M(T)};function M(I){B.call(this,I),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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(M,B),M.prototype.convertTo=function(T){return this.imod(T.ushln(this.shift))},M.prototype.convertFrom=function(T){var C=this.imod(T.mul(this.rinv));return C.red=null,C},M.prototype.imul=function(T,C){if(T.isZero()||C.isZero())return T.words[0]=0,T.length=1,T;var O=T.imul(C),A=O.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),L=O.isub(A).iushrn(this.shift),U=L;return L.cmp(this.m)>=0?U=L.isub(this.m):L.cmpn(0)<0&&(U=L.iadd(this.m)),U._forceRed(this)},M.prototype.mul=function(T,C){if(T.isZero()||C.isZero())return new f(0)._forceRed(this);var O=T.mul(C),A=O.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),L=O.isub(A).iushrn(this.shift),U=L;return L.cmp(this.m)>=0?U=L.isub(this.m):L.cmpn(0)<0&&(U=L.iadd(this.m)),U._forceRed(this)},M.prototype.invm=function(T){var C=this.imod(T._invmp(this.m).mul(this.r2));return C._forceRed(this)}})(typeof S>"u"||S,void 0)},{buffer:185}],182:[function(e,S,_){_.byteLength=h,_.toByteArray=d,_.fromByteArray=c;for(var u=[],y=[],g=typeof Uint8Array<"u"?Uint8Array:Array,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0,f=b.length;w0)throw new Error("Invalid string. Length must be a multiple of 4");var t=a.indexOf("=");t===-1&&(t=r);var i=t===r?0:4-t%4;return[t,i]}function h(a){var r=v(a),t=r[0],i=r[1];return(t+i)*3/4-i}function l(a,r,t){return(r+t)*3/4-t}function d(a){var r,t=v(a),i=t[0],n=t[1],o=new g(l(a,i,n)),p=0,E=n>0?i-4:i,P;for(P=0;P>16&255,o[p++]=r>>8&255,o[p++]=r&255;return n===2&&(r=y[a.charCodeAt(P)]<<2|y[a.charCodeAt(P+1)]>>4,o[p++]=r&255),n===1&&(r=y[a.charCodeAt(P)]<<10|y[a.charCodeAt(P+1)]<<4|y[a.charCodeAt(P+2)]>>2,o[p++]=r>>8&255,o[p++]=r&255),o}function s(a){return u[a>>18&63]+u[a>>12&63]+u[a>>6&63]+u[a&63]}function m(a,r,t){for(var i,n=[],o=r;oE?E:p+o));return i===1?(r=a[t-1],n.push(u[r>>2]+u[r<<4&63]+"==")):i===2&&(r=(a[t-2]<<8)+a[t-1],n.push(u[r>>10]+u[r>>4&63]+u[r<<2&63]+"=")),n.join("")}},{}],183:[function(e,S,_){function u(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(b){return typeof b}:u=function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},u(y)}(function(y,g){function b(C,O){if(!C)throw new Error(O||"Assertion failed")}function w(C,O){C.super_=O;var A=function(){};A.prototype=O.prototype,C.prototype=new A,C.prototype.constructor=C}function f(C,O,A){if(f.isBN(C))return C;this.negative=0,this.words=null,this.length=0,this.red=null,C!==null&&((O==="le"||O==="be")&&(A=O,O=10),this._init(C||0,O||10,A||"be"))}u(y)==="object"?y.exports=f:g.BN=f,f.BN=f,f.wordSize=26;var v;try{v=e("buffer").Buffer}catch{}f.isBN=function(O){return O instanceof f?!0:O!==null&&u(O)==="object"&&O.constructor.wordSize===f.wordSize&&Array.isArray(O.words)},f.max=function(O,A){return O.cmp(A)>0?O:A},f.min=function(O,A){return O.cmp(A)<0?O:A},f.prototype._init=function(O,A,L){if(typeof O=="number")return this._initNumber(O,A,L);if(u(O)==="object")return this._initArray(O,A,L);A==="hex"&&(A=16),b(A===(A|0)&&A>=2&&A<=36),O=O.toString().replace(/\s+/g,"");var U=0;O[0]==="-"&&U++,A===16?this._parseHex(O,U):this._parseBase(O,A,U),O[0]==="-"&&(this.negative=1),this._strip(),L==="le"&&this._initArray(this.toArray(),A,L)},f.prototype._initNumber=function(O,A,L){O<0&&(this.negative=1,O=-O),O<67108864?(this.words=[O&67108863],this.length=1):O<4503599627370496?(this.words=[O&67108863,O/67108864&67108863],this.length=2):(b(O<9007199254740992),this.words=[O&67108863,O/67108864&67108863,1],this.length=3),L==="le"&&this._initArray(this.toArray(),A,L)},f.prototype._initArray=function(O,A,L){if(b(typeof O.length=="number"),O.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(O.length/3),this.words=new Array(this.length);for(var U=0;U=0;U-=3)$=O[U]|O[U-1]<<8|O[U-2]<<16,this.words[W]|=$<>>26-N&67108863,N+=24,N>=26&&(N-=26,W++);else if(L==="le")for(U=0,W=0;U>>26-N&67108863,N+=24,N>=26&&(N-=26,W++);return this._strip()};function h(C,O,A){for(var L=0,U=Math.min(C.length,A),W=0,$=O;$=49&&N<=54?F=N-49+10:N>=17&&N<=22?F=N-17+10:F=N,L|=F,W|=F}return b(!(W&240),"Invalid character in "+C),L}f.prototype._parseHex=function(O,A){this.length=Math.ceil((O.length-A)/6),this.words=new Array(this.length);for(var L=0;L=A;L-=6)W=h(O,L,L+6),this.words[U]|=W<<$&67108863,this.words[U+1]|=W>>>26-$&4194303,$+=24,$>=26&&($-=26,U++);L+6!==A&&(W=h(O,A,L+6),this.words[U]|=W<<$&67108863,this.words[U+1]|=W>>>26-$&4194303),this._strip()};function l(C,O,A,L){for(var U=0,W=0,$=Math.min(C.length,A),N=O;N<$;N++){var F=C.charCodeAt(N)-48;U*=L,F>=49?W=F-49+10:F>=17?W=F-17+10:W=F,b(F>=0&&W1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{f.prototype[Symbol.for("nodejs.util.inspect.custom")]=s}catch{f.prototype.inspect=s}else f.prototype.inspect=s;function s(){return(this.red?""}var m=["","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"],c=[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],a=[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];f.prototype.toString=function(O,A){O=O||10,A=A|0||1;var L;if(O===16||O==="hex"){L="";for(var U=0,W=0,$=0;$>>24-U&16777215,W!==0||$!==this.length-1?L=m[6-F.length]+F+L:L=F+L,U+=2,U>=26&&(U-=26,$--)}for(W!==0&&(L=W.toString(16)+L);L.length%A!==0;)L="0"+L;return this.negative!==0&&(L="-"+L),L}if(O===(O|0)&&O>=2&&O<=36){var j=c[O],V=a[O];L="";var te=this.clone();for(te.negative=0;!te.isZero();){var re=te.modrn(V).toString(O);te=te.idivn(V),te.isZero()?L=re+L:L=m[j-re.length]+re+L}for(this.isZero()&&(L="0"+L);L.length%A!==0;)L="0"+L;return this.negative!==0&&(L="-"+L),L}b(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var O=this.words[0];return this.length===2?O+=this.words[1]*67108864:this.length===3&&this.words[2]===1?O+=4503599627370496+this.words[1]*67108864:this.length>2&&b(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-O:O},f.prototype.toJSON=function(){return this.toString(16,2)},v&&(f.prototype.toBuffer=function(O,A){return this.toArrayLike(v,O,A)}),f.prototype.toArray=function(O,A){return this.toArrayLike(Array,O,A)};var r=function(O,A){return O.allocUnsafe?O.allocUnsafe(A):new O(A)};f.prototype.toArrayLike=function(O,A,L){this._strip();var U=this.byteLength(),W=L||Math.max(1,U);b(U<=W,"byte array longer than desired length"),b(W>0,"Requested array length <= 0");var $=r(O,W),N=A==="le"?"LE":"BE";return this["_toArrayLike"+N]($,U),$},f.prototype._toArrayLikeLE=function(O,A){for(var L=0,U=0,W=0,$=0;W>8&255),L>16&255),$===6?(L>24&255),U=0,$=0):(U=N>>>24,$+=2)}if(L=0&&(O[L--]=N>>8&255),L>=0&&(O[L--]=N>>16&255),$===6?(L>=0&&(O[L--]=N>>24&255),U=0,$=0):(U=N>>>24,$+=2)}if(L>=0)for(O[L--]=U;L>=0;)O[L--]=0},Math.clz32?f.prototype._countBits=function(O){return 32-Math.clz32(O)}:f.prototype._countBits=function(O){var A=O,L=0;return A>=4096&&(L+=13,A>>>=13),A>=64&&(L+=7,A>>>=7),A>=8&&(L+=4,A>>>=4),A>=2&&(L+=2,A>>>=2),L+A},f.prototype._zeroBits=function(O){if(O===0)return 26;var A=O,L=0;return A&8191||(L+=13,A>>>=13),A&127||(L+=7,A>>>=7),A&15||(L+=4,A>>>=4),A&3||(L+=2,A>>>=2),A&1||L++,L},f.prototype.bitLength=function(){var O=this.words[this.length-1],A=this._countBits(O);return(this.length-1)*26+A};function t(C){for(var O=new Array(C.bitLength()),A=0;A>>U&1}return O}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var O=0,A=0;AO.length?this.clone().ior(O):O.clone().ior(this)},f.prototype.uor=function(O){return this.length>O.length?this.clone().iuor(O):O.clone().iuor(this)},f.prototype.iuand=function(O){var A;this.length>O.length?A=O:A=this;for(var L=0;LO.length?this.clone().iand(O):O.clone().iand(this)},f.prototype.uand=function(O){return this.length>O.length?this.clone().iuand(O):O.clone().iuand(this)},f.prototype.iuxor=function(O){var A,L;this.length>O.length?(A=this,L=O):(A=O,L=this);for(var U=0;UO.length?this.clone().ixor(O):O.clone().ixor(this)},f.prototype.uxor=function(O){return this.length>O.length?this.clone().iuxor(O):O.clone().iuxor(this)},f.prototype.inotn=function(O){b(typeof O=="number"&&O>=0);var A=Math.ceil(O/26)|0,L=O%26;this._expand(A),L>0&&A--;for(var U=0;U0&&(this.words[U]=~this.words[U]&67108863>>26-L),this._strip()},f.prototype.notn=function(O){return this.clone().inotn(O)},f.prototype.setn=function(O,A){b(typeof O=="number"&&O>=0);var L=O/26|0,U=O%26;return this._expand(L+1),A?this.words[L]=this.words[L]|1<O.length?(L=this,U=O):(L=O,U=this);for(var W=0,$=0;$>>26;for(;W!==0&&$>>26;if(this.length=L.length,W!==0)this.words[this.length]=W,this.length++;else if(L!==this)for(;$O.length?this.clone().iadd(O):O.clone().iadd(this)},f.prototype.isub=function(O){if(O.negative!==0){O.negative=0;var A=this.iadd(O);return O.negative=1,A._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(O),this.negative=1,this._normSign();var L=this.cmp(O);if(L===0)return this.negative=0,this.length=1,this.words[0]=0,this;var U,W;L>0?(U=this,W=O):(U=O,W=this);for(var $=0,N=0;N>26,this.words[N]=A&67108863;for(;$!==0&&N>26,this.words[N]=A&67108863;if($===0&&N>>26,te=F&67108863,re=Math.min(j,O.length-1),le=Math.max(0,j-C.length+1);le<=re;le++){var ye=j-le|0;U=C.words[ye]|0,W=O.words[le]|0,$=U*W+te,V+=$/67108864|0,te=$&67108863}A.words[j]=te|0,F=V|0}return F!==0?A.words[j]=F|0:A.length--,A._strip()}var n=function(O,A,L){var U=O.words,W=A.words,$=L.words,N=0,F,j,V,te=U[0]|0,re=te&8191,le=te>>>13,ye=U[1]|0,ge=ye&8191,ne=ye>>>13,J=U[2]|0,Q=J&8191,he=J>>>13,xe=U[3]|0,ie=xe&8191,se=xe>>>13,Ce=U[4]|0,q=Ce&8191,G=Ce>>>13,Y=U[5]|0,fe=Y&8191,we=Y>>>13,_e=U[6]|0,je=_e&8191,Ye=_e>>>13,nt=U[7]|0,ut=nt&8191,ot=nt>>>13,Ue=U[8]|0,Ve=Ue&8191,Qe=Ue>>>13,tt=U[9]|0,oe=tt&8191,Re=tt>>>13,be=W[0]|0,Ee=be&8191,pe=be>>>13,Pe=W[1]|0,ee=Pe&8191,He=Pe>>>13,it=W[2]|0,K=it&8191,Me=it>>>13,Le=W[3]|0,ue=Le&8191,ke=Le>>>13,Ie=W[4]|0,st=Ie&8191,Ge=Ie>>>13,rt=W[5]|0,_t=rt&8191,wt=rt>>>13,Ot=W[6]|0,pt=Ot&8191,ct=Ot>>>13,At=W[7]|0,Pt=At&8191,bt=At>>>13,Kt=W[8]|0,Ct=Kt&8191,St=Kt>>>13,Bt=W[9]|0,Lt=Bt&8191,Et=Bt>>>13;L.negative=O.negative^A.negative,L.length=19,F=Math.imul(re,Ee),j=Math.imul(re,pe),j=j+Math.imul(le,Ee)|0,V=Math.imul(le,pe);var Nr=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,F=Math.imul(ge,Ee),j=Math.imul(ge,pe),j=j+Math.imul(ne,Ee)|0,V=Math.imul(ne,pe),F=F+Math.imul(re,ee)|0,j=j+Math.imul(re,He)|0,j=j+Math.imul(le,ee)|0,V=V+Math.imul(le,He)|0;var Or=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Or>>>26)|0,Or&=67108863,F=Math.imul(Q,Ee),j=Math.imul(Q,pe),j=j+Math.imul(he,Ee)|0,V=Math.imul(he,pe),F=F+Math.imul(ge,ee)|0,j=j+Math.imul(ge,He)|0,j=j+Math.imul(ne,ee)|0,V=V+Math.imul(ne,He)|0,F=F+Math.imul(re,K)|0,j=j+Math.imul(re,Me)|0,j=j+Math.imul(le,K)|0,V=V+Math.imul(le,Me)|0;var Gr=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,F=Math.imul(ie,Ee),j=Math.imul(ie,pe),j=j+Math.imul(se,Ee)|0,V=Math.imul(se,pe),F=F+Math.imul(Q,ee)|0,j=j+Math.imul(Q,He)|0,j=j+Math.imul(he,ee)|0,V=V+Math.imul(he,He)|0,F=F+Math.imul(ge,K)|0,j=j+Math.imul(ge,Me)|0,j=j+Math.imul(ne,K)|0,V=V+Math.imul(ne,Me)|0,F=F+Math.imul(re,ue)|0,j=j+Math.imul(re,ke)|0,j=j+Math.imul(le,ue)|0,V=V+Math.imul(le,ke)|0;var Dr=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,F=Math.imul(q,Ee),j=Math.imul(q,pe),j=j+Math.imul(G,Ee)|0,V=Math.imul(G,pe),F=F+Math.imul(ie,ee)|0,j=j+Math.imul(ie,He)|0,j=j+Math.imul(se,ee)|0,V=V+Math.imul(se,He)|0,F=F+Math.imul(Q,K)|0,j=j+Math.imul(Q,Me)|0,j=j+Math.imul(he,K)|0,V=V+Math.imul(he,Me)|0,F=F+Math.imul(ge,ue)|0,j=j+Math.imul(ge,ke)|0,j=j+Math.imul(ne,ue)|0,V=V+Math.imul(ne,ke)|0,F=F+Math.imul(re,st)|0,j=j+Math.imul(re,Ge)|0,j=j+Math.imul(le,st)|0,V=V+Math.imul(le,Ge)|0;var Yr=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,F=Math.imul(fe,Ee),j=Math.imul(fe,pe),j=j+Math.imul(we,Ee)|0,V=Math.imul(we,pe),F=F+Math.imul(q,ee)|0,j=j+Math.imul(q,He)|0,j=j+Math.imul(G,ee)|0,V=V+Math.imul(G,He)|0,F=F+Math.imul(ie,K)|0,j=j+Math.imul(ie,Me)|0,j=j+Math.imul(se,K)|0,V=V+Math.imul(se,Me)|0,F=F+Math.imul(Q,ue)|0,j=j+Math.imul(Q,ke)|0,j=j+Math.imul(he,ue)|0,V=V+Math.imul(he,ke)|0,F=F+Math.imul(ge,st)|0,j=j+Math.imul(ge,Ge)|0,j=j+Math.imul(ne,st)|0,V=V+Math.imul(ne,Ge)|0,F=F+Math.imul(re,_t)|0,j=j+Math.imul(re,wt)|0,j=j+Math.imul(le,_t)|0,V=V+Math.imul(le,wt)|0;var Qt=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,F=Math.imul(je,Ee),j=Math.imul(je,pe),j=j+Math.imul(Ye,Ee)|0,V=Math.imul(Ye,pe),F=F+Math.imul(fe,ee)|0,j=j+Math.imul(fe,He)|0,j=j+Math.imul(we,ee)|0,V=V+Math.imul(we,He)|0,F=F+Math.imul(q,K)|0,j=j+Math.imul(q,Me)|0,j=j+Math.imul(G,K)|0,V=V+Math.imul(G,Me)|0,F=F+Math.imul(ie,ue)|0,j=j+Math.imul(ie,ke)|0,j=j+Math.imul(se,ue)|0,V=V+Math.imul(se,ke)|0,F=F+Math.imul(Q,st)|0,j=j+Math.imul(Q,Ge)|0,j=j+Math.imul(he,st)|0,V=V+Math.imul(he,Ge)|0,F=F+Math.imul(ge,_t)|0,j=j+Math.imul(ge,wt)|0,j=j+Math.imul(ne,_t)|0,V=V+Math.imul(ne,wt)|0,F=F+Math.imul(re,pt)|0,j=j+Math.imul(re,ct)|0,j=j+Math.imul(le,pt)|0,V=V+Math.imul(le,ct)|0;var Xr=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,F=Math.imul(ut,Ee),j=Math.imul(ut,pe),j=j+Math.imul(ot,Ee)|0,V=Math.imul(ot,pe),F=F+Math.imul(je,ee)|0,j=j+Math.imul(je,He)|0,j=j+Math.imul(Ye,ee)|0,V=V+Math.imul(Ye,He)|0,F=F+Math.imul(fe,K)|0,j=j+Math.imul(fe,Me)|0,j=j+Math.imul(we,K)|0,V=V+Math.imul(we,Me)|0,F=F+Math.imul(q,ue)|0,j=j+Math.imul(q,ke)|0,j=j+Math.imul(G,ue)|0,V=V+Math.imul(G,ke)|0,F=F+Math.imul(ie,st)|0,j=j+Math.imul(ie,Ge)|0,j=j+Math.imul(se,st)|0,V=V+Math.imul(se,Ge)|0,F=F+Math.imul(Q,_t)|0,j=j+Math.imul(Q,wt)|0,j=j+Math.imul(he,_t)|0,V=V+Math.imul(he,wt)|0,F=F+Math.imul(ge,pt)|0,j=j+Math.imul(ge,ct)|0,j=j+Math.imul(ne,pt)|0,V=V+Math.imul(ne,ct)|0,F=F+Math.imul(re,Pt)|0,j=j+Math.imul(re,bt)|0,j=j+Math.imul(le,Pt)|0,V=V+Math.imul(le,bt)|0;var Br=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Br>>>26)|0,Br&=67108863,F=Math.imul(Ve,Ee),j=Math.imul(Ve,pe),j=j+Math.imul(Qe,Ee)|0,V=Math.imul(Qe,pe),F=F+Math.imul(ut,ee)|0,j=j+Math.imul(ut,He)|0,j=j+Math.imul(ot,ee)|0,V=V+Math.imul(ot,He)|0,F=F+Math.imul(je,K)|0,j=j+Math.imul(je,Me)|0,j=j+Math.imul(Ye,K)|0,V=V+Math.imul(Ye,Me)|0,F=F+Math.imul(fe,ue)|0,j=j+Math.imul(fe,ke)|0,j=j+Math.imul(we,ue)|0,V=V+Math.imul(we,ke)|0,F=F+Math.imul(q,st)|0,j=j+Math.imul(q,Ge)|0,j=j+Math.imul(G,st)|0,V=V+Math.imul(G,Ge)|0,F=F+Math.imul(ie,_t)|0,j=j+Math.imul(ie,wt)|0,j=j+Math.imul(se,_t)|0,V=V+Math.imul(se,wt)|0,F=F+Math.imul(Q,pt)|0,j=j+Math.imul(Q,ct)|0,j=j+Math.imul(he,pt)|0,V=V+Math.imul(he,ct)|0,F=F+Math.imul(ge,Pt)|0,j=j+Math.imul(ge,bt)|0,j=j+Math.imul(ne,Pt)|0,V=V+Math.imul(ne,bt)|0,F=F+Math.imul(re,Ct)|0,j=j+Math.imul(re,St)|0,j=j+Math.imul(le,Ct)|0,V=V+Math.imul(le,St)|0;var Lr=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Lr>>>26)|0,Lr&=67108863,F=Math.imul(oe,Ee),j=Math.imul(oe,pe),j=j+Math.imul(Re,Ee)|0,V=Math.imul(Re,pe),F=F+Math.imul(Ve,ee)|0,j=j+Math.imul(Ve,He)|0,j=j+Math.imul(Qe,ee)|0,V=V+Math.imul(Qe,He)|0,F=F+Math.imul(ut,K)|0,j=j+Math.imul(ut,Me)|0,j=j+Math.imul(ot,K)|0,V=V+Math.imul(ot,Me)|0,F=F+Math.imul(je,ue)|0,j=j+Math.imul(je,ke)|0,j=j+Math.imul(Ye,ue)|0,V=V+Math.imul(Ye,ke)|0,F=F+Math.imul(fe,st)|0,j=j+Math.imul(fe,Ge)|0,j=j+Math.imul(we,st)|0,V=V+Math.imul(we,Ge)|0,F=F+Math.imul(q,_t)|0,j=j+Math.imul(q,wt)|0,j=j+Math.imul(G,_t)|0,V=V+Math.imul(G,wt)|0,F=F+Math.imul(ie,pt)|0,j=j+Math.imul(ie,ct)|0,j=j+Math.imul(se,pt)|0,V=V+Math.imul(se,ct)|0,F=F+Math.imul(Q,Pt)|0,j=j+Math.imul(Q,bt)|0,j=j+Math.imul(he,Pt)|0,V=V+Math.imul(he,bt)|0,F=F+Math.imul(ge,Ct)|0,j=j+Math.imul(ge,St)|0,j=j+Math.imul(ne,Ct)|0,V=V+Math.imul(ne,St)|0,F=F+Math.imul(re,Lt)|0,j=j+Math.imul(re,Et)|0,j=j+Math.imul(le,Lt)|0,V=V+Math.imul(le,Et)|0;var Ur=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,F=Math.imul(oe,ee),j=Math.imul(oe,He),j=j+Math.imul(Re,ee)|0,V=Math.imul(Re,He),F=F+Math.imul(Ve,K)|0,j=j+Math.imul(Ve,Me)|0,j=j+Math.imul(Qe,K)|0,V=V+Math.imul(Qe,Me)|0,F=F+Math.imul(ut,ue)|0,j=j+Math.imul(ut,ke)|0,j=j+Math.imul(ot,ue)|0,V=V+Math.imul(ot,ke)|0,F=F+Math.imul(je,st)|0,j=j+Math.imul(je,Ge)|0,j=j+Math.imul(Ye,st)|0,V=V+Math.imul(Ye,Ge)|0,F=F+Math.imul(fe,_t)|0,j=j+Math.imul(fe,wt)|0,j=j+Math.imul(we,_t)|0,V=V+Math.imul(we,wt)|0,F=F+Math.imul(q,pt)|0,j=j+Math.imul(q,ct)|0,j=j+Math.imul(G,pt)|0,V=V+Math.imul(G,ct)|0,F=F+Math.imul(ie,Pt)|0,j=j+Math.imul(ie,bt)|0,j=j+Math.imul(se,Pt)|0,V=V+Math.imul(se,bt)|0,F=F+Math.imul(Q,Ct)|0,j=j+Math.imul(Q,St)|0,j=j+Math.imul(he,Ct)|0,V=V+Math.imul(he,St)|0,F=F+Math.imul(ge,Lt)|0,j=j+Math.imul(ge,Et)|0,j=j+Math.imul(ne,Lt)|0,V=V+Math.imul(ne,Et)|0;var yt=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(yt>>>26)|0,yt&=67108863,F=Math.imul(oe,K),j=Math.imul(oe,Me),j=j+Math.imul(Re,K)|0,V=Math.imul(Re,Me),F=F+Math.imul(Ve,ue)|0,j=j+Math.imul(Ve,ke)|0,j=j+Math.imul(Qe,ue)|0,V=V+Math.imul(Qe,ke)|0,F=F+Math.imul(ut,st)|0,j=j+Math.imul(ut,Ge)|0,j=j+Math.imul(ot,st)|0,V=V+Math.imul(ot,Ge)|0,F=F+Math.imul(je,_t)|0,j=j+Math.imul(je,wt)|0,j=j+Math.imul(Ye,_t)|0,V=V+Math.imul(Ye,wt)|0,F=F+Math.imul(fe,pt)|0,j=j+Math.imul(fe,ct)|0,j=j+Math.imul(we,pt)|0,V=V+Math.imul(we,ct)|0,F=F+Math.imul(q,Pt)|0,j=j+Math.imul(q,bt)|0,j=j+Math.imul(G,Pt)|0,V=V+Math.imul(G,bt)|0,F=F+Math.imul(ie,Ct)|0,j=j+Math.imul(ie,St)|0,j=j+Math.imul(se,Ct)|0,V=V+Math.imul(se,St)|0,F=F+Math.imul(Q,Lt)|0,j=j+Math.imul(Q,Et)|0,j=j+Math.imul(he,Lt)|0,V=V+Math.imul(he,Et)|0;var Ke=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,F=Math.imul(oe,ue),j=Math.imul(oe,ke),j=j+Math.imul(Re,ue)|0,V=Math.imul(Re,ke),F=F+Math.imul(Ve,st)|0,j=j+Math.imul(Ve,Ge)|0,j=j+Math.imul(Qe,st)|0,V=V+Math.imul(Qe,Ge)|0,F=F+Math.imul(ut,_t)|0,j=j+Math.imul(ut,wt)|0,j=j+Math.imul(ot,_t)|0,V=V+Math.imul(ot,wt)|0,F=F+Math.imul(je,pt)|0,j=j+Math.imul(je,ct)|0,j=j+Math.imul(Ye,pt)|0,V=V+Math.imul(Ye,ct)|0,F=F+Math.imul(fe,Pt)|0,j=j+Math.imul(fe,bt)|0,j=j+Math.imul(we,Pt)|0,V=V+Math.imul(we,bt)|0,F=F+Math.imul(q,Ct)|0,j=j+Math.imul(q,St)|0,j=j+Math.imul(G,Ct)|0,V=V+Math.imul(G,St)|0,F=F+Math.imul(ie,Lt)|0,j=j+Math.imul(ie,Et)|0,j=j+Math.imul(se,Lt)|0,V=V+Math.imul(se,Et)|0;var me=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(me>>>26)|0,me&=67108863,F=Math.imul(oe,st),j=Math.imul(oe,Ge),j=j+Math.imul(Re,st)|0,V=Math.imul(Re,Ge),F=F+Math.imul(Ve,_t)|0,j=j+Math.imul(Ve,wt)|0,j=j+Math.imul(Qe,_t)|0,V=V+Math.imul(Qe,wt)|0,F=F+Math.imul(ut,pt)|0,j=j+Math.imul(ut,ct)|0,j=j+Math.imul(ot,pt)|0,V=V+Math.imul(ot,ct)|0,F=F+Math.imul(je,Pt)|0,j=j+Math.imul(je,bt)|0,j=j+Math.imul(Ye,Pt)|0,V=V+Math.imul(Ye,bt)|0,F=F+Math.imul(fe,Ct)|0,j=j+Math.imul(fe,St)|0,j=j+Math.imul(we,Ct)|0,V=V+Math.imul(we,St)|0,F=F+Math.imul(q,Lt)|0,j=j+Math.imul(q,Et)|0,j=j+Math.imul(G,Lt)|0,V=V+Math.imul(G,Et)|0;var Be=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Be>>>26)|0,Be&=67108863,F=Math.imul(oe,_t),j=Math.imul(oe,wt),j=j+Math.imul(Re,_t)|0,V=Math.imul(Re,wt),F=F+Math.imul(Ve,pt)|0,j=j+Math.imul(Ve,ct)|0,j=j+Math.imul(Qe,pt)|0,V=V+Math.imul(Qe,ct)|0,F=F+Math.imul(ut,Pt)|0,j=j+Math.imul(ut,bt)|0,j=j+Math.imul(ot,Pt)|0,V=V+Math.imul(ot,bt)|0,F=F+Math.imul(je,Ct)|0,j=j+Math.imul(je,St)|0,j=j+Math.imul(Ye,Ct)|0,V=V+Math.imul(Ye,St)|0,F=F+Math.imul(fe,Lt)|0,j=j+Math.imul(fe,Et)|0,j=j+Math.imul(we,Lt)|0,V=V+Math.imul(we,Et)|0;var Fe=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,F=Math.imul(oe,pt),j=Math.imul(oe,ct),j=j+Math.imul(Re,pt)|0,V=Math.imul(Re,ct),F=F+Math.imul(Ve,Pt)|0,j=j+Math.imul(Ve,bt)|0,j=j+Math.imul(Qe,Pt)|0,V=V+Math.imul(Qe,bt)|0,F=F+Math.imul(ut,Ct)|0,j=j+Math.imul(ut,St)|0,j=j+Math.imul(ot,Ct)|0,V=V+Math.imul(ot,St)|0,F=F+Math.imul(je,Lt)|0,j=j+Math.imul(je,Et)|0,j=j+Math.imul(Ye,Lt)|0,V=V+Math.imul(Ye,Et)|0;var dt=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(dt>>>26)|0,dt&=67108863,F=Math.imul(oe,Pt),j=Math.imul(oe,bt),j=j+Math.imul(Re,Pt)|0,V=Math.imul(Re,bt),F=F+Math.imul(Ve,Ct)|0,j=j+Math.imul(Ve,St)|0,j=j+Math.imul(Qe,Ct)|0,V=V+Math.imul(Qe,St)|0,F=F+Math.imul(ut,Lt)|0,j=j+Math.imul(ut,Et)|0,j=j+Math.imul(ot,Lt)|0,V=V+Math.imul(ot,Et)|0;var kt=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(kt>>>26)|0,kt&=67108863,F=Math.imul(oe,Ct),j=Math.imul(oe,St),j=j+Math.imul(Re,Ct)|0,V=Math.imul(Re,St),F=F+Math.imul(Ve,Lt)|0,j=j+Math.imul(Ve,Et)|0,j=j+Math.imul(Qe,Lt)|0,V=V+Math.imul(Qe,Et)|0;var Ht=(N+F|0)+((j&8191)<<13)|0;N=(V+(j>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,F=Math.imul(oe,Lt),j=Math.imul(oe,Et),j=j+Math.imul(Re,Lt)|0,V=Math.imul(Re,Et);var lr=(N+F|0)+((j&8191)<<13)|0;return N=(V+(j>>>13)|0)+(lr>>>26)|0,lr&=67108863,$[0]=Nr,$[1]=Or,$[2]=Gr,$[3]=Dr,$[4]=Yr,$[5]=Qt,$[6]=Xr,$[7]=Br,$[8]=Lr,$[9]=Ur,$[10]=yt,$[11]=Ke,$[12]=me,$[13]=Be,$[14]=Fe,$[15]=dt,$[16]=kt,$[17]=Ht,$[18]=lr,N!==0&&($[19]=N,L.length++),L};Math.imul||(n=i);function o(C,O,A){A.negative=O.negative^C.negative,A.length=C.length+O.length;for(var L=0,U=0,W=0;W>>26)|0,U+=$>>>26,$&=67108863}A.words[W]=N,L=$,$=U}return L!==0?A.words[W]=L:A.length--,A._strip()}function p(C,O,A){return o(C,O,A)}f.prototype.mulTo=function(O,A){var L,U=this.length+O.length;return this.length===10&&O.length===10?L=n(this,O,A):U<63?L=i(this,O,A):U<1024?L=o(this,O,A):L=p(this,O,A),L},f.prototype.mul=function(O){var A=new f(null);return A.words=new Array(this.length+O.length),this.mulTo(O,A)},f.prototype.mulf=function(O){var A=new f(null);return A.words=new Array(this.length+O.length),p(this,O,A)},f.prototype.imul=function(O){return this.clone().mulTo(O,this)},f.prototype.imuln=function(O){var A=O<0;A&&(O=-O),b(typeof O=="number"),b(O<67108864);for(var L=0,U=0;U>=26,L+=W/67108864|0,L+=$>>>26,this.words[U]=$&67108863}return L!==0&&(this.words[U]=L,this.length++),A?this.ineg():this},f.prototype.muln=function(O){return this.clone().imuln(O)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(O){var A=t(O);if(A.length===0)return new f(1);for(var L=this,U=0;U=0);var A=O%26,L=(O-A)/26,U=67108863>>>26-A<<26-A,W;if(A!==0){var $=0;for(W=0;W>>26-A}$&&(this.words[W]=$,this.length++)}if(L!==0){for(W=this.length-1;W>=0;W--)this.words[W+L]=this.words[W];for(W=0;W=0);var U;A?U=(A-A%26)/26:U=0;var W=O%26,$=Math.min((O-W)/26,this.length),N=67108863^67108863>>>W<$)for(this.length-=$,j=0;j=0&&(V!==0||j>=U);j--){var te=this.words[j]|0;this.words[j]=V<<26-W|te>>>W,V=te&N}return F&&V!==0&&(F.words[F.length++]=V),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},f.prototype.ishrn=function(O,A,L){return b(this.negative===0),this.iushrn(O,A,L)},f.prototype.shln=function(O){return this.clone().ishln(O)},f.prototype.ushln=function(O){return this.clone().iushln(O)},f.prototype.shrn=function(O){return this.clone().ishrn(O)},f.prototype.ushrn=function(O){return this.clone().iushrn(O)},f.prototype.testn=function(O){b(typeof O=="number"&&O>=0);var A=O%26,L=(O-A)/26,U=1<=0);var A=O%26,L=(O-A)/26;if(b(this.negative===0,"imaskn works only with positive numbers"),this.length<=L)return this;if(A!==0&&L++,this.length=Math.min(L,this.length),A!==0){var U=67108863^67108863>>>A<=67108864;A++)this.words[A]-=67108864,A===this.length-1?this.words[A+1]=1:this.words[A+1]++;return this.length=Math.max(this.length,A+1),this},f.prototype.isubn=function(O){if(b(typeof O=="number"),b(O<67108864),O<0)return this.iaddn(-O);if(this.negative!==0)return this.negative=0,this.iaddn(O),this.negative=1,this;if(this.words[0]-=O,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var A=0;A>26)-(F/67108864|0),this.words[W+L]=$&67108863}for(;W>26,this.words[W+L]=$&67108863;if(N===0)return this._strip();for(b(N===-1),N=0,W=0;W>26,this.words[W]=$&67108863;return this.negative=1,this._strip()},f.prototype._wordDiv=function(O,A){var L=this.length-O.length,U=this.clone(),W=O,$=W.words[W.length-1]|0,N=this._countBits($);L=26-N,L!==0&&(W=W.ushln(L),U.iushln(L),$=W.words[W.length-1]|0);var F=U.length-W.length,j;if(A!=="mod"){j=new f(null),j.length=F+1,j.words=new Array(j.length);for(var V=0;V=0;re--){var le=(U.words[W.length+re]|0)*67108864+(U.words[W.length+re-1]|0);for(le=Math.min(le/$|0,67108863),U._ishlnsubmul(W,le,re);U.negative!==0;)le--,U.negative=0,U._ishlnsubmul(W,1,re),U.isZero()||(U.negative^=1);j&&(j.words[re]=le)}return j&&j._strip(),U._strip(),A!=="div"&&L!==0&&U.iushrn(L),{div:j||null,mod:U}},f.prototype.divmod=function(O,A,L){if(b(!O.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var U,W,$;return this.negative!==0&&O.negative===0?($=this.neg().divmod(O,A),A!=="mod"&&(U=$.div.neg()),A!=="div"&&(W=$.mod.neg(),L&&W.negative!==0&&W.iadd(O)),{div:U,mod:W}):this.negative===0&&O.negative!==0?($=this.divmod(O.neg(),A),A!=="mod"&&(U=$.div.neg()),{div:U,mod:$.mod}):this.negative&O.negative?($=this.neg().divmod(O.neg(),A),A!=="div"&&(W=$.mod.neg(),L&&W.negative!==0&&W.isub(O)),{div:$.div,mod:W}):O.length>this.length||this.cmp(O)<0?{div:new f(0),mod:this}:O.length===1?A==="div"?{div:this.divn(O.words[0]),mod:null}:A==="mod"?{div:null,mod:new f(this.modrn(O.words[0]))}:{div:this.divn(O.words[0]),mod:new f(this.modrn(O.words[0]))}:this._wordDiv(O,A)},f.prototype.div=function(O){return this.divmod(O,"div",!1).div},f.prototype.mod=function(O){return this.divmod(O,"mod",!1).mod},f.prototype.umod=function(O){return this.divmod(O,"mod",!0).mod},f.prototype.divRound=function(O){var A=this.divmod(O);if(A.mod.isZero())return A.div;var L=A.div.negative!==0?A.mod.isub(O):A.mod,U=O.ushrn(1),W=O.andln(1),$=L.cmp(U);return $<0||W===1&&$===0?A.div:A.div.negative!==0?A.div.isubn(1):A.div.iaddn(1)},f.prototype.modrn=function(O){var A=O<0;A&&(O=-O),b(O<=67108863);for(var L=(1<<26)%O,U=0,W=this.length-1;W>=0;W--)U=(L*U+(this.words[W]|0))%O;return A?-U:U},f.prototype.modn=function(O){return this.modrn(O)},f.prototype.idivn=function(O){var A=O<0;A&&(O=-O),b(O<=67108863);for(var L=0,U=this.length-1;U>=0;U--){var W=(this.words[U]|0)+L*67108864;this.words[U]=W/O|0,L=W%O}return this._strip(),A?this.ineg():this},f.prototype.divn=function(O){return this.clone().idivn(O)},f.prototype.egcd=function(O){b(O.negative===0),b(!O.isZero());var A=this,L=O.clone();A.negative!==0?A=A.umod(O):A=A.clone();for(var U=new f(1),W=new f(0),$=new f(0),N=new f(1),F=0;A.isEven()&&L.isEven();)A.iushrn(1),L.iushrn(1),++F;for(var j=L.clone(),V=A.clone();!A.isZero();){for(var te=0,re=1;!(A.words[0]&re)&&te<26;++te,re<<=1);if(te>0)for(A.iushrn(te);te-- >0;)(U.isOdd()||W.isOdd())&&(U.iadd(j),W.isub(V)),U.iushrn(1),W.iushrn(1);for(var le=0,ye=1;!(L.words[0]&ye)&&le<26;++le,ye<<=1);if(le>0)for(L.iushrn(le);le-- >0;)($.isOdd()||N.isOdd())&&($.iadd(j),N.isub(V)),$.iushrn(1),N.iushrn(1);A.cmp(L)>=0?(A.isub(L),U.isub($),W.isub(N)):(L.isub(A),$.isub(U),N.isub(W))}return{a:$,b:N,gcd:L.iushln(F)}},f.prototype._invmp=function(O){b(O.negative===0),b(!O.isZero());var A=this,L=O.clone();A.negative!==0?A=A.umod(O):A=A.clone();for(var U=new f(1),W=new f(0),$=L.clone();A.cmpn(1)>0&&L.cmpn(1)>0;){for(var N=0,F=1;!(A.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(A.iushrn(N);N-- >0;)U.isOdd()&&U.iadd($),U.iushrn(1);for(var j=0,V=1;!(L.words[0]&V)&&j<26;++j,V<<=1);if(j>0)for(L.iushrn(j);j-- >0;)W.isOdd()&&W.iadd($),W.iushrn(1);A.cmp(L)>=0?(A.isub(L),U.isub(W)):(L.isub(A),W.isub(U))}var te;return A.cmpn(1)===0?te=U:te=W,te.cmpn(0)<0&&te.iadd(O),te},f.prototype.gcd=function(O){if(this.isZero())return O.abs();if(O.isZero())return this.abs();var A=this.clone(),L=O.clone();A.negative=0,L.negative=0;for(var U=0;A.isEven()&&L.isEven();U++)A.iushrn(1),L.iushrn(1);do{for(;A.isEven();)A.iushrn(1);for(;L.isEven();)L.iushrn(1);var W=A.cmp(L);if(W<0){var $=A;A=L,L=$}else if(W===0||L.cmpn(1)===0)break;A.isub(L)}while(!0);return L.iushln(U)},f.prototype.invm=function(O){return this.egcd(O).a.umod(O)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(O){return this.words[0]&O},f.prototype.bincn=function(O){b(typeof O=="number");var A=O%26,L=(O-A)/26,U=1<>>26,N&=67108863,this.words[$]=N}return W!==0&&(this.words[$]=W,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(O){var A=O<0;if(this.negative!==0&&!A)return-1;if(this.negative===0&&A)return 1;this._strip();var L;if(this.length>1)L=1;else{A&&(O=-O),b(O<=67108863,"Number is too big");var U=this.words[0]|0;L=U===O?0:UO.length)return 1;if(this.length=0;L--){var U=this.words[L]|0,W=O.words[L]|0;if(U!==W){UW&&(A=1);break}}return A},f.prototype.gtn=function(O){return this.cmpn(O)===1},f.prototype.gt=function(O){return this.cmp(O)===1},f.prototype.gten=function(O){return this.cmpn(O)>=0},f.prototype.gte=function(O){return this.cmp(O)>=0},f.prototype.ltn=function(O){return this.cmpn(O)===-1},f.prototype.lt=function(O){return this.cmp(O)===-1},f.prototype.lten=function(O){return this.cmpn(O)<=0},f.prototype.lte=function(O){return this.cmp(O)<=0},f.prototype.eqn=function(O){return this.cmpn(O)===0},f.prototype.eq=function(O){return this.cmp(O)===0},f.red=function(O){return new I(O)},f.prototype.toRed=function(O){return b(!this.red,"Already a number in reduction context"),b(this.negative===0,"red works only with positives"),O.convertTo(this)._forceRed(O)},f.prototype.fromRed=function(){return b(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(O){return this.red=O,this},f.prototype.forceRed=function(O){return b(!this.red,"Already a number in reduction context"),this._forceRed(O)},f.prototype.redAdd=function(O){return b(this.red,"redAdd works only with red numbers"),this.red.add(this,O)},f.prototype.redIAdd=function(O){return b(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,O)},f.prototype.redSub=function(O){return b(this.red,"redSub works only with red numbers"),this.red.sub(this,O)},f.prototype.redISub=function(O){return b(this.red,"redISub works only with red numbers"),this.red.isub(this,O)},f.prototype.redShl=function(O){return b(this.red,"redShl works only with red numbers"),this.red.shl(this,O)},f.prototype.redMul=function(O){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,O),this.red.mul(this,O)},f.prototype.redIMul=function(O){return b(this.red,"redMul works only with red numbers"),this.red._verify2(this,O),this.red.imul(this,O)},f.prototype.redSqr=function(){return b(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return b(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return b(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return b(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return b(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(O){return b(this.red&&!O.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,O)};var E={k256:null,p224:null,p192:null,p25519:null};function P(C,O){this.name=C,this.p=new f(O,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}P.prototype._tmp=function(){var O=new f(null);return O.words=new Array(Math.ceil(this.n/13)),O},P.prototype.ireduce=function(O){var A=O,L;do this.split(A,this.tmp),A=this.imulK(A),A=A.iadd(this.tmp),L=A.bitLength();while(L>this.n);var U=L0?A.isub(this.p):A.strip!==void 0?A.strip():A._strip(),A},P.prototype.split=function(O,A){O.iushrn(this.n,0,A)},P.prototype.imulK=function(O){return O.imul(this.k)};function D(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}w(D,P),D.prototype.split=function(O,A){for(var L=4194303,U=Math.min(O.length,9),W=0;W>>22,$=N}$>>>=22,O.words[W-10]=$,$===0&&O.length>10?O.length-=10:O.length-=9},D.prototype.imulK=function(O){O.words[O.length]=0,O.words[O.length+1]=0,O.length+=2;for(var A=0,L=0;L>>=26,O.words[L]=W,A=U}return A!==0&&(O.words[O.length++]=A),O},f._prime=function(O){if(E[O])return E[O];var A;if(O==="k256")A=new D;else if(O==="p224")A=new z;else if(O==="p192")A=new B;else if(O==="p25519")A=new M;else throw new Error("Unknown prime "+O);return E[O]=A,A};function I(C){if(typeof C=="string"){var O=f._prime(C);this.m=O.p,this.prime=O}else b(C.gtn(1),"modulus must be greater than 1"),this.m=C,this.prime=null}I.prototype._verify1=function(O){b(O.negative===0,"red works only with positives"),b(O.red,"red works only with red numbers")},I.prototype._verify2=function(O,A){b((O.negative|A.negative)===0,"red works only with positives"),b(O.red&&O.red===A.red,"red works only with red numbers")},I.prototype.imod=function(O){return this.prime?this.prime.ireduce(O)._forceRed(this):(d(O,O.umod(this.m)._forceRed(this)),O)},I.prototype.neg=function(O){return O.isZero()?O.clone():this.m.sub(O)._forceRed(this)},I.prototype.add=function(O,A){this._verify2(O,A);var L=O.add(A);return L.cmp(this.m)>=0&&L.isub(this.m),L._forceRed(this)},I.prototype.iadd=function(O,A){this._verify2(O,A);var L=O.iadd(A);return L.cmp(this.m)>=0&&L.isub(this.m),L},I.prototype.sub=function(O,A){this._verify2(O,A);var L=O.sub(A);return L.cmpn(0)<0&&L.iadd(this.m),L._forceRed(this)},I.prototype.isub=function(O,A){this._verify2(O,A);var L=O.isub(A);return L.cmpn(0)<0&&L.iadd(this.m),L},I.prototype.shl=function(O,A){return this._verify1(O),this.imod(O.ushln(A))},I.prototype.imul=function(O,A){return this._verify2(O,A),this.imod(O.imul(A))},I.prototype.mul=function(O,A){return this._verify2(O,A),this.imod(O.mul(A))},I.prototype.isqr=function(O){return this.imul(O,O.clone())},I.prototype.sqr=function(O){return this.mul(O,O)},I.prototype.sqrt=function(O){if(O.isZero())return O.clone();var A=this.m.andln(3);if(b(A%2===1),A===3){var L=this.m.add(new f(1)).iushrn(2);return this.pow(O,L)}for(var U=this.m.subn(1),W=0;!U.isZero()&&U.andln(1)===0;)W++,U.iushrn(1);b(!U.isZero());var $=new f(1).toRed(this),N=$.redNeg(),F=this.m.subn(1).iushrn(1),j=this.m.bitLength();for(j=new f(2*j*j).toRed(this);this.pow(j,F).cmp(N)!==0;)j.redIAdd(N);for(var V=this.pow(j,U),te=this.pow(O,U.addn(1).iushrn(1)),re=this.pow(O,U),le=W;re.cmp($)!==0;){for(var ye=re,ge=0;ye.cmp($)!==0;ge++)ye=ye.redSqr();b(ge=0;W--){for(var V=A.words[W],te=j-1;te>=0;te--){var re=V>>te&1;if($!==U[0]&&($=this.sqr($)),re===0&&N===0){F=0;continue}N<<=1,N|=re,F++,!(F!==L&&(W!==0||te!==0))&&($=this.mul($,U[N]),F=0,N=0)}j=26}return $},I.prototype.convertTo=function(O){var A=O.umod(this.m);return A===O?A.clone():A},I.prototype.convertFrom=function(O){var A=O.clone();return A.red=null,A},f.mont=function(O){return new T(O)};function T(C){I.call(this,C),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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(T,I),T.prototype.convertTo=function(O){return this.imod(O.ushln(this.shift))},T.prototype.convertFrom=function(O){var A=this.imod(O.mul(this.rinv));return A.red=null,A},T.prototype.imul=function(O,A){if(O.isZero()||A.isZero())return O.words[0]=0,O.length=1,O;var L=O.imul(A),U=L.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),W=L.isub(U).iushrn(this.shift),$=W;return W.cmp(this.m)>=0?$=W.isub(this.m):W.cmpn(0)<0&&($=W.iadd(this.m)),$._forceRed(this)},T.prototype.mul=function(O,A){if(O.isZero()||A.isZero())return new f(0)._forceRed(this);var L=O.mul(A),U=L.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),W=L.isub(U).iushrn(this.shift),$=W;return W.cmp(this.m)>=0?$=W.isub(this.m):W.cmpn(0)<0&&($=W.iadd(this.m)),$._forceRed(this)},T.prototype.invm=function(O){var A=this.imod(O._invmp(this.m).mul(this.r2));return A._forceRed(this)}})(typeof S>"u"||S,void 0)},{buffer:185}],184:[function(e,S,_){function u(w){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(v){return typeof v}:u=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},u(w)}var y;S.exports=function(f){return y||(y=new g(null)),y.generate(f)};function g(w){this.rand=w}if(S.exports.Rand=g,g.prototype.generate=function(f){return this._rand(f)},g.prototype._rand=function(f){if(this.rand.getBytes)return this.rand.getBytes(f);for(var v=new Uint8Array(f),h=0;h"u"?"undefined":u(self))==="object")self.crypto&&self.crypto.getRandomValues?g.prototype._rand=function(f){var v=new Uint8Array(f);return self.crypto.getRandomValues(v),v}:self.msCrypto&&self.msCrypto.getRandomValues?g.prototype._rand=function(f){var v=new Uint8Array(f);return self.msCrypto.getRandomValues(v),v}:(typeof window>"u"?"undefined":u(window))==="object"&&(g.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var b=e("crypto");if(typeof b.randomBytes!="function")throw new Error("Not supported");g.prototype._rand=function(f){return b.randomBytes(f)}}catch{}},{crypto:185}],185:[function(e,S,_){},{}],186:[function(e,S,_){var u=e("safe-buffer").Buffer;function y(h){u.isBuffer(h)||(h=u.from(h));for(var l=h.length/4|0,d=new Array(l),s=0;s>>24]^a[n>>>16&255]^r[o>>>8&255]^t[p&255]^l[B++],P=c[n>>>24]^a[o>>>16&255]^r[p>>>8&255]^t[i&255]^l[B++],D=c[o>>>24]^a[p>>>16&255]^r[i>>>8&255]^t[n&255]^l[B++],z=c[p>>>24]^a[i>>>16&255]^r[n>>>8&255]^t[o&255]^l[B++],i=E,n=P,o=D,p=z;return E=(s[i>>>24]<<24|s[n>>>16&255]<<16|s[o>>>8&255]<<8|s[p&255])^l[B++],P=(s[n>>>24]<<24|s[o>>>16&255]<<16|s[p>>>8&255]<<8|s[i&255])^l[B++],D=(s[o>>>24]<<24|s[p>>>16&255]<<16|s[i>>>8&255]<<8|s[n&255])^l[B++],z=(s[p>>>24]<<24|s[i>>>16&255]<<16|s[n>>>8&255]<<8|s[o&255])^l[B++],E=E>>>0,P=P>>>0,D=D>>>0,z=z>>>0,[E,P,D,z]}var w=[0,1,2,4,8,16,32,64,128,27,54],f=function(){for(var h=new Array(256),l=0;l<256;l++)l<128?h[l]=l<<1:h[l]=l<<1^283;for(var d=[],s=[],m=[[],[],[],[]],c=[[],[],[],[]],a=0,r=0,t=0;t<256;++t){var i=r^r<<1^r<<2^r<<3^r<<4;i=i>>>8^i&255^99,d[a]=i,s[i]=a;var n=h[a],o=h[n],p=h[o],E=h[i]*257^i*16843008;m[0][a]=E<<24|E>>>8,m[1][a]=E<<16|E>>>16,m[2][a]=E<<8|E>>>24,m[3][a]=E,E=p*16843009^o*65537^n*257^a*16843008,c[0][i]=E<<24|E>>>8,c[1][i]=E<<16|E>>>16,c[2][i]=E<<8|E>>>24,c[3][i]=E,a===0?a=r=1:(a=n^h[h[h[p^n]]],r^=h[h[r]])}return{SBOX:d,INV_SBOX:s,SUB_MIX:m,INV_SUB_MIX:c}}();function v(h){this._key=y(h),this._reset()}v.blockSize=4*4,v.keySize=256/8,v.prototype.blockSize=v.blockSize,v.prototype.keySize=v.keySize,v.prototype._reset=function(){for(var h=this._key,l=h.length,d=l+6,s=(d+1)*4,m=[],c=0;c>>24,a=f.SBOX[a>>>24]<<24|f.SBOX[a>>>16&255]<<16|f.SBOX[a>>>8&255]<<8|f.SBOX[a&255],a^=w[c/l|0]<<24):l>6&&c%l===4&&(a=f.SBOX[a>>>24]<<24|f.SBOX[a>>>16&255]<<16|f.SBOX[a>>>8&255]<<8|f.SBOX[a&255]),m[c]=m[c-l]^a}for(var r=[],t=0;t>>24]]^f.INV_SUB_MIX[1][f.SBOX[n>>>16&255]]^f.INV_SUB_MIX[2][f.SBOX[n>>>8&255]]^f.INV_SUB_MIX[3][f.SBOX[n&255]]}this._nRounds=d,this._keySchedule=m,this._invKeySchedule=r},v.prototype.encryptBlockRaw=function(h){return h=y(h),b(h,this._keySchedule,f.SUB_MIX,f.SBOX,this._nRounds)},v.prototype.encryptBlock=function(h){var l=this.encryptBlockRaw(h),d=u.allocUnsafe(16);return d.writeUInt32BE(l[0],0),d.writeUInt32BE(l[1],4),d.writeUInt32BE(l[2],8),d.writeUInt32BE(l[3],12),d},v.prototype.decryptBlock=function(h){h=y(h);var l=h[1];h[1]=h[3],h[3]=l;var d=b(h,this._invKeySchedule,f.INV_SUB_MIX,f.INV_SBOX,this._nRounds),s=u.allocUnsafe(16);return s.writeUInt32BE(d[0],0),s.writeUInt32BE(d[3],4),s.writeUInt32BE(d[2],8),s.writeUInt32BE(d[1],12),s},v.prototype.scrub=function(){g(this._keySchedule),g(this._invKeySchedule),g(this._key)},S.exports.AES=v},{"safe-buffer":494}],187:[function(e,S,_){var u=e("./aes"),y=e("safe-buffer").Buffer,g=e("cipher-base"),b=e("inherits"),w=e("./ghash"),f=e("buffer-xor"),v=e("./incr32");function h(s,m){var c=0;s.length!==m.length&&c++;for(var a=Math.min(s.length,m.length),r=0;r16)return r=this.cache.slice(0,16),this.cache=this.cache.slice(16),r}else if(this.cache.length>=16)return r=this.cache.slice(0,16),this.cache=this.cache.slice(16),r;return null},d.prototype.flush=function(){if(this.cache.length)return this.cache};function s(a){var r=a[15];if(r<1||r>16)throw new Error("unable to decrypt data");for(var t=-1;++t15){var a=this.cache.slice(0,16);return this.cache=this.cache.slice(16),a}return null},s.prototype.flush=function(){for(var a=16-this.cache.length,r=g.allocUnsafe(a),t=-1;++t>>0,0),v.writeUInt32BE(f[1]>>>0,4),v.writeUInt32BE(f[2]>>>0,8),v.writeUInt32BE(f[3]>>>0,12),v}function w(f){this.h=f,this.state=u.alloc(16,0),this.cache=u.allocUnsafe(0)}w.prototype.ghash=function(f){for(var v=-1;++v0;h--)f[h]=f[h]>>>1|(f[h-1]&1)<<31;f[0]=f[0]>>>1,d&&(f[0]=f[0]^225<<24)}this.state=b(v)},w.prototype.update=function(f){this.cache=u.concat([this.cache,f]);for(var v;this.cache.length>=16;)v=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(v)},w.prototype.final=function(f,v){return this.cache.length&&this.ghash(u.concat([this.cache,y],16)),this.ghash(b([0,f,0,v])),this.state},S.exports=w},{"safe-buffer":494}],192:[function(e,S,_){function u(y){for(var g=y.length,b;g--;)if(b=y.readUInt8(g),b===255)y.writeUInt8(0,g);else{b++,y.writeUInt8(b,g);break}}S.exports=u},{}],193:[function(e,S,_){var u=e("buffer-xor");_.encrypt=function(y,g){var b=u(g,y._prev);return y._prev=y._cipher.encryptBlock(b),y._prev},_.decrypt=function(y,g){var b=y._prev;y._prev=g;var w=y._cipher.decryptBlock(g);return u(w,b)}},{"buffer-xor":217}],194:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("buffer-xor");function g(b,w,f){var v=w.length,h=y(w,b._cache);return b._cache=b._cache.slice(v),b._prev=u.concat([b._prev,f?w:h]),h}_.encrypt=function(b,w,f){for(var v=u.allocUnsafe(0),h;w.length;)if(b._cache.length===0&&(b._cache=b._cipher.encryptBlock(b._prev),b._prev=u.allocUnsafe(0)),b._cache.length<=w.length)h=b._cache.length,v=u.concat([v,g(b,w.slice(0,h),f)]),w=w.slice(h);else{v=u.concat([v,g(b,w,f)]);break}return v}},{"buffer-xor":217,"safe-buffer":494}],195:[function(e,S,_){var u=e("safe-buffer").Buffer;function y(b,w,f){for(var v,h=-1,l=8,d=0,s,m;++h>h%8,b._prev=g(b._prev,f?s:m);return d}function g(b,w){var f=b.length,v=-1,h=u.allocUnsafe(b.length);for(b=u.concat([b,u.from([w])]);++v>7;return h}_.encrypt=function(b,w,f){for(var v=w.length,h=u.allocUnsafe(v),l=-1;++l=0||!l.umod(v.prime1)||!l.umod(v.prime2);)l=new y(g(h));return l}}).call(this,e("buffer").Buffer)},{"bn.js":207,buffer:216,randombytes:475}],207:[function(e,S,_){arguments[4][181][0].apply(_,arguments)},{buffer:185,dup:181}],208:[function(e,S,_){S.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":209}],209:[function(e,S,_){S.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"}}},{}],210:[function(e,S,_){S.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"}},{}],211:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("create-hash"),g=e("readable-stream"),b=e("inherits"),w=e("./sign"),f=e("./verify"),v=e("./algorithms.json");Object.keys(v).forEach(function(m){v[m].id=u.from(v[m].id,"hex"),v[m.toLowerCase()]=v[m]});function h(m){g.Writable.call(this);var c=v[m];if(!c)throw new Error("Unknown message digest");this._hashType=c.hash,this._hash=y(c.hash),this._tag=c.id,this._signType=c.sign}b(h,g.Writable),h.prototype._write=function(c,a,r){this._hash.update(c),r()},h.prototype.update=function(c,a){return typeof c=="string"&&(c=u.from(c,a)),this._hash.update(c),this},h.prototype.sign=function(c,a){this.end();var r=this._hash.digest(),t=w(r,c,this._hashType,this._signType,this._tag);return a?t.toString(a):t};function l(m){g.Writable.call(this);var c=v[m];if(!c)throw new Error("Unknown message digest");this._hash=y(c.hash),this._tag=c.id,this._signType=c.sign}b(l,g.Writable),l.prototype._write=function(c,a,r){this._hash.update(c),r()},l.prototype.update=function(c,a){return typeof c=="string"&&(c=u.from(c,a)),this._hash.update(c),this},l.prototype.verify=function(c,a,r){typeof a=="string"&&(a=u.from(a,r)),this.end();var t=this._hash.digest();return f(a,t,c,this._signType,this._tag)};function d(m){return new h(m)}function s(m){return new l(m)}S.exports={Sign:d,Verify:s,createSign:d,createVerify:s}},{"./algorithms.json":209,"./sign":212,"./verify":213,"create-hash":331,inherits:387,"readable-stream":491,"safe-buffer":214}],212:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("create-hmac"),g=e("browserify-rsa"),b=e("elliptic").ec,w=e("bn.js"),f=e("parse-asn1"),v=e("./curves.json");function h(i,n,o,p,E){var P=f(n);if(P.curve){if(p!=="ecdsa"&&p!=="ecdsa/rsa")throw new Error("wrong private key type");return l(i,P)}else if(P.type==="dsa"){if(p!=="dsa")throw new Error("wrong private key type");return d(i,P,o)}else if(p!=="rsa"&&p!=="ecdsa/rsa")throw new Error("wrong private key type");i=u.concat([E,i]);for(var D=P.modulus.byteLength(),z=[0,1];i.length+z.length+10&&o.ishrn(p),o}function a(i,n){i=c(i,n),i=i.mod(n);var o=u.from(i.toArray());if(o.length=s)throw new Error("invalid sig")}S.exports=f},{"./curves.json":210,"bn.js":183,elliptic:350,"parse-asn1":459,"safe-buffer":214}],214:[function(e,S,_){/*! safe-buffer. MIT License. Feross Aboukhadijeh */var u=e("buffer"),y=u.Buffer;function g(w,f){for(var v in w)f[v]=w[v]}y.from&&y.alloc&&y.allocUnsafe&&y.allocUnsafeSlow?S.exports=u:(g(u,_),_.Buffer=b);function b(w,f,v){return y(w,f,v)}b.prototype=Object.create(y.prototype),g(y,b),b.from=function(w,f,v){if(typeof w=="number")throw new TypeError("Argument must not be a number");return y(w,f,v)},b.alloc=function(w,f,v){if(typeof w!="number")throw new TypeError("Argument must be a number");var h=y(w);return f!==void 0?typeof v=="string"?h.fill(f,v):h.fill(f):h.fill(0),h},b.allocUnsafe=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return y(w)},b.allocUnsafeSlow=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(w)}},{buffer:216}],215:[function(e,S,_){arguments[4][185][0].apply(_,arguments)},{dup:185}],216:[function(e,S,_){(function(h){function y(q){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(Y){return typeof Y}:y=function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y},y(q)}var g=e("base64-js"),b=e("ieee754");_.Buffer=h,_.SlowBuffer=n,_.INSPECT_MAX_BYTES=50;var w=2147483647;_.kMaxLength=w,h.TYPED_ARRAY_SUPPORT=f(),!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&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.");function f(){try{var q=new Uint8Array(1);return q.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},q.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function v(q){if(q>w)throw new RangeError('The value "'+q+'" is invalid for option "size"');var G=new Uint8Array(q);return G.__proto__=h.prototype,G}function h(q,G,Y){if(typeof q=="number"){if(typeof G=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(q)}return l(q,G,Y)}typeof Symbol<"u"&&Symbol.species!=null&&h[Symbol.species]===h&&Object.defineProperty(h,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),h.poolSize=8192;function l(q,G,Y){if(typeof q=="string")return c(q,G);if(ArrayBuffer.isView(q))return a(q);if(q==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+y(q));if(se(q,ArrayBuffer)||q&&se(q.buffer,ArrayBuffer))return r(q,G,Y);if(typeof q=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var fe=q.valueOf&&q.valueOf();if(fe!=null&&fe!==q)return h.from(fe,G,Y);var we=t(q);if(we)return we;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof q[Symbol.toPrimitive]=="function")return h.from(q[Symbol.toPrimitive]("string"),G,Y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+y(q))}h.from=function(q,G,Y){return l(q,G,Y)},h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array;function d(q){if(typeof q!="number")throw new TypeError('"size" argument must be of type number');if(q<0)throw new RangeError('The value "'+q+'" is invalid for option "size"')}function s(q,G,Y){return d(q),q<=0?v(q):G!==void 0?typeof Y=="string"?v(q).fill(G,Y):v(q).fill(G):v(q)}h.alloc=function(q,G,Y){return s(q,G,Y)};function m(q){return d(q),v(q<0?0:i(q)|0)}h.allocUnsafe=function(q){return m(q)},h.allocUnsafeSlow=function(q){return m(q)};function c(q,G){if((typeof G!="string"||G==="")&&(G="utf8"),!h.isEncoding(G))throw new TypeError("Unknown encoding: "+G);var Y=o(q,G)|0,fe=v(Y),we=fe.write(q,G);return we!==Y&&(fe=fe.slice(0,we)),fe}function a(q){for(var G=q.length<0?0:i(q.length)|0,Y=v(G),fe=0;fe=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return q|0}function n(q){return+q!=q&&(q=0),h.alloc(+q)}h.isBuffer=function(G){return G!=null&&G._isBuffer===!0&&G!==h.prototype},h.compare=function(G,Y){if(se(G,Uint8Array)&&(G=h.from(G,G.offset,G.byteLength)),se(Y,Uint8Array)&&(Y=h.from(Y,Y.offset,Y.byteLength)),!h.isBuffer(G)||!h.isBuffer(Y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(G===Y)return 0;for(var fe=G.length,we=Y.length,_e=0,je=Math.min(fe,we);_e2&&arguments[2]===!0;if(!fe&&Y===0)return 0;for(var we=!1;;)switch(G){case"ascii":case"latin1":case"binary":return Y;case"utf8":case"utf-8":return J(q).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y*2;case"hex":return Y>>>1;case"base64":return xe(q).length;default:if(we)return fe?-1:J(q).length;G=(""+G).toLowerCase(),we=!0}}h.byteLength=o;function p(q,G,Y){var fe=!1;if((G===void 0||G<0)&&(G=0),G>this.length||((Y===void 0||Y>this.length)&&(Y=this.length),Y<=0)||(Y>>>=0,G>>>=0,Y<=G))return"";for(q||(q="utf8");;)switch(q){case"hex":return N(this,G,Y);case"utf8":case"utf-8":return A(this,G,Y);case"ascii":return W(this,G,Y);case"latin1":case"binary":return $(this,G,Y);case"base64":return O(this,G,Y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,G,Y);default:if(fe)throw new TypeError("Unknown encoding: "+q);q=(q+"").toLowerCase(),fe=!0}}h.prototype._isBuffer=!0;function E(q,G,Y){var fe=q[G];q[G]=q[Y],q[Y]=fe}h.prototype.swap16=function(){var G=this.length;if(G%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var Y=0;YY&&(G+=" ... "),""},h.prototype.compare=function(G,Y,fe,we,_e){if(se(G,Uint8Array)&&(G=h.from(G,G.offset,G.byteLength)),!h.isBuffer(G))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+y(G));if(Y===void 0&&(Y=0),fe===void 0&&(fe=G?G.length:0),we===void 0&&(we=0),_e===void 0&&(_e=this.length),Y<0||fe>G.length||we<0||_e>this.length)throw new RangeError("out of range index");if(we>=_e&&Y>=fe)return 0;if(we>=_e)return-1;if(Y>=fe)return 1;if(Y>>>=0,fe>>>=0,we>>>=0,_e>>>=0,this===G)return 0;for(var je=_e-we,Ye=fe-Y,nt=Math.min(je,Ye),ut=this.slice(we,_e),ot=G.slice(Y,fe),Ue=0;Ue2147483647?Y=2147483647:Y<-2147483648&&(Y=-2147483648),Y=+Y,Ce(Y)&&(Y=we?0:q.length-1),Y<0&&(Y=q.length+Y),Y>=q.length){if(we)return-1;Y=q.length-1}else if(Y<0)if(we)Y=0;else return-1;if(typeof G=="string"&&(G=h.from(G,fe)),h.isBuffer(G))return G.length===0?-1:D(q,G,Y,fe,we);if(typeof G=="number")return G=G&255,typeof Uint8Array.prototype.indexOf=="function"?we?Uint8Array.prototype.indexOf.call(q,G,Y):Uint8Array.prototype.lastIndexOf.call(q,G,Y):D(q,[G],Y,fe,we);throw new TypeError("val must be string, number or Buffer")}function D(q,G,Y,fe,we){var _e=1,je=q.length,Ye=G.length;if(fe!==void 0&&(fe=String(fe).toLowerCase(),fe==="ucs2"||fe==="ucs-2"||fe==="utf16le"||fe==="utf-16le")){if(q.length<2||G.length<2)return-1;_e=2,je/=2,Ye/=2,Y/=2}function nt(Qe,tt){return _e===1?Qe[tt]:Qe.readUInt16BE(tt*_e)}var ut;if(we){var ot=-1;for(ut=Y;utje&&(Y=je-Ye),ut=Y;ut>=0;ut--){for(var Ue=!0,Ve=0;Vewe&&(fe=we)):fe=we;var _e=G.length;fe>_e/2&&(fe=_e/2);for(var je=0;je>>0,isFinite(fe)?(fe=fe>>>0,we===void 0&&(we="utf8")):(we=fe,fe=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var _e=this.length-Y;if((fe===void 0||fe>_e)&&(fe=_e),G.length>0&&(fe<0||Y<0)||Y>this.length)throw new RangeError("Attempt to write outside buffer bounds");we||(we="utf8");for(var je=!1;;)switch(we){case"hex":return z(this,G,Y,fe);case"utf8":case"utf-8":return B(this,G,Y,fe);case"ascii":return M(this,G,Y,fe);case"latin1":case"binary":return I(this,G,Y,fe);case"base64":return T(this,G,Y,fe);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,G,Y,fe);default:if(je)throw new TypeError("Unknown encoding: "+we);we=(""+we).toLowerCase(),je=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(q,G,Y){return G===0&&Y===q.length?g.fromByteArray(q):g.fromByteArray(q.slice(G,Y))}function A(q,G,Y){Y=Math.min(q.length,Y);for(var fe=[],we=G;we239?4:_e>223?3:_e>191?2:1;if(we+Ye<=Y){var nt,ut,ot,Ue;switch(Ye){case 1:_e<128&&(je=_e);break;case 2:nt=q[we+1],(nt&192)===128&&(Ue=(_e&31)<<6|nt&63,Ue>127&&(je=Ue));break;case 3:nt=q[we+1],ut=q[we+2],(nt&192)===128&&(ut&192)===128&&(Ue=(_e&15)<<12|(nt&63)<<6|ut&63,Ue>2047&&(Ue<55296||Ue>57343)&&(je=Ue));break;case 4:nt=q[we+1],ut=q[we+2],ot=q[we+3],(nt&192)===128&&(ut&192)===128&&(ot&192)===128&&(Ue=(_e&15)<<18|(nt&63)<<12|(ut&63)<<6|ot&63,Ue>65535&&Ue<1114112&&(je=Ue))}}je===null?(je=65533,Ye=1):je>65535&&(je-=65536,fe.push(je>>>10&1023|55296),je=56320|je&1023),fe.push(je),we+=Ye}return U(fe)}var L=4096;function U(q){var G=q.length;if(G<=L)return String.fromCharCode.apply(String,q);for(var Y="",fe=0;fefe)&&(Y=fe);for(var we="",_e=G;_efe&&(G=fe),Y<0?(Y+=fe,Y<0&&(Y=0)):Y>fe&&(Y=fe),YY)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUIntLE=function(G,Y,fe){G=G>>>0,Y=Y>>>0,fe||j(G,Y,this.length);for(var we=this[G],_e=1,je=0;++je>>0,Y=Y>>>0,fe||j(G,Y,this.length);for(var we=this[G+--Y],_e=1;Y>0&&(_e*=256);)we+=this[G+--Y]*_e;return we},h.prototype.readUInt8=function(G,Y){return G=G>>>0,Y||j(G,1,this.length),this[G]},h.prototype.readUInt16LE=function(G,Y){return G=G>>>0,Y||j(G,2,this.length),this[G]|this[G+1]<<8},h.prototype.readUInt16BE=function(G,Y){return G=G>>>0,Y||j(G,2,this.length),this[G]<<8|this[G+1]},h.prototype.readUInt32LE=function(G,Y){return G=G>>>0,Y||j(G,4,this.length),(this[G]|this[G+1]<<8|this[G+2]<<16)+this[G+3]*16777216},h.prototype.readUInt32BE=function(G,Y){return G=G>>>0,Y||j(G,4,this.length),this[G]*16777216+(this[G+1]<<16|this[G+2]<<8|this[G+3])},h.prototype.readIntLE=function(G,Y,fe){G=G>>>0,Y=Y>>>0,fe||j(G,Y,this.length);for(var we=this[G],_e=1,je=0;++je=_e&&(we-=Math.pow(2,8*Y)),we},h.prototype.readIntBE=function(G,Y,fe){G=G>>>0,Y=Y>>>0,fe||j(G,Y,this.length);for(var we=Y,_e=1,je=this[G+--we];we>0&&(_e*=256);)je+=this[G+--we]*_e;return _e*=128,je>=_e&&(je-=Math.pow(2,8*Y)),je},h.prototype.readInt8=function(G,Y){return G=G>>>0,Y||j(G,1,this.length),this[G]&128?(255-this[G]+1)*-1:this[G]},h.prototype.readInt16LE=function(G,Y){G=G>>>0,Y||j(G,2,this.length);var fe=this[G]|this[G+1]<<8;return fe&32768?fe|4294901760:fe},h.prototype.readInt16BE=function(G,Y){G=G>>>0,Y||j(G,2,this.length);var fe=this[G+1]|this[G]<<8;return fe&32768?fe|4294901760:fe},h.prototype.readInt32LE=function(G,Y){return G=G>>>0,Y||j(G,4,this.length),this[G]|this[G+1]<<8|this[G+2]<<16|this[G+3]<<24},h.prototype.readInt32BE=function(G,Y){return G=G>>>0,Y||j(G,4,this.length),this[G]<<24|this[G+1]<<16|this[G+2]<<8|this[G+3]},h.prototype.readFloatLE=function(G,Y){return G=G>>>0,Y||j(G,4,this.length),b.read(this,G,!0,23,4)},h.prototype.readFloatBE=function(G,Y){return G=G>>>0,Y||j(G,4,this.length),b.read(this,G,!1,23,4)},h.prototype.readDoubleLE=function(G,Y){return G=G>>>0,Y||j(G,8,this.length),b.read(this,G,!0,52,8)},h.prototype.readDoubleBE=function(G,Y){return G=G>>>0,Y||j(G,8,this.length),b.read(this,G,!1,52,8)};function V(q,G,Y,fe,we,_e){if(!h.isBuffer(q))throw new TypeError('"buffer" argument must be a Buffer instance');if(G>we||G<_e)throw new RangeError('"value" argument is out of bounds');if(Y+fe>q.length)throw new RangeError("Index out of range")}h.prototype.writeUIntLE=function(G,Y,fe,we){if(G=+G,Y=Y>>>0,fe=fe>>>0,!we){var _e=Math.pow(2,8*fe)-1;V(this,G,Y,fe,_e,0)}var je=1,Ye=0;for(this[Y]=G&255;++Ye>>0,fe=fe>>>0,!we){var _e=Math.pow(2,8*fe)-1;V(this,G,Y,fe,_e,0)}var je=fe-1,Ye=1;for(this[Y+je]=G&255;--je>=0&&(Ye*=256);)this[Y+je]=G/Ye&255;return Y+fe},h.prototype.writeUInt8=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,1,255,0),this[Y]=G&255,Y+1},h.prototype.writeUInt16LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,65535,0),this[Y]=G&255,this[Y+1]=G>>>8,Y+2},h.prototype.writeUInt16BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,65535,0),this[Y]=G>>>8,this[Y+1]=G&255,Y+2},h.prototype.writeUInt32LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,4294967295,0),this[Y+3]=G>>>24,this[Y+2]=G>>>16,this[Y+1]=G>>>8,this[Y]=G&255,Y+4},h.prototype.writeUInt32BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,4294967295,0),this[Y]=G>>>24,this[Y+1]=G>>>16,this[Y+2]=G>>>8,this[Y+3]=G&255,Y+4},h.prototype.writeIntLE=function(G,Y,fe,we){if(G=+G,Y=Y>>>0,!we){var _e=Math.pow(2,8*fe-1);V(this,G,Y,fe,_e-1,-_e)}var je=0,Ye=1,nt=0;for(this[Y]=G&255;++je>0)-nt&255;return Y+fe},h.prototype.writeIntBE=function(G,Y,fe,we){if(G=+G,Y=Y>>>0,!we){var _e=Math.pow(2,8*fe-1);V(this,G,Y,fe,_e-1,-_e)}var je=fe-1,Ye=1,nt=0;for(this[Y+je]=G&255;--je>=0&&(Ye*=256);)G<0&&nt===0&&this[Y+je+1]!==0&&(nt=1),this[Y+je]=(G/Ye>>0)-nt&255;return Y+fe},h.prototype.writeInt8=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,1,127,-128),G<0&&(G=255+G+1),this[Y]=G&255,Y+1},h.prototype.writeInt16LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,32767,-32768),this[Y]=G&255,this[Y+1]=G>>>8,Y+2},h.prototype.writeInt16BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,2,32767,-32768),this[Y]=G>>>8,this[Y+1]=G&255,Y+2},h.prototype.writeInt32LE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,2147483647,-2147483648),this[Y]=G&255,this[Y+1]=G>>>8,this[Y+2]=G>>>16,this[Y+3]=G>>>24,Y+4},h.prototype.writeInt32BE=function(G,Y,fe){return G=+G,Y=Y>>>0,fe||V(this,G,Y,4,2147483647,-2147483648),G<0&&(G=4294967295+G+1),this[Y]=G>>>24,this[Y+1]=G>>>16,this[Y+2]=G>>>8,this[Y+3]=G&255,Y+4};function te(q,G,Y,fe,we,_e){if(Y+fe>q.length)throw new RangeError("Index out of range");if(Y<0)throw new RangeError("Index out of range")}function re(q,G,Y,fe,we){return G=+G,Y=Y>>>0,we||te(q,G,Y,4),b.write(q,G,Y,fe,23,4),Y+4}h.prototype.writeFloatLE=function(G,Y,fe){return re(this,G,Y,!0,fe)},h.prototype.writeFloatBE=function(G,Y,fe){return re(this,G,Y,!1,fe)};function le(q,G,Y,fe,we){return G=+G,Y=Y>>>0,we||te(q,G,Y,8),b.write(q,G,Y,fe,52,8),Y+8}h.prototype.writeDoubleLE=function(G,Y,fe){return le(this,G,Y,!0,fe)},h.prototype.writeDoubleBE=function(G,Y,fe){return le(this,G,Y,!1,fe)},h.prototype.copy=function(G,Y,fe,we){if(!h.isBuffer(G))throw new TypeError("argument should be a Buffer");if(fe||(fe=0),!we&&we!==0&&(we=this.length),Y>=G.length&&(Y=G.length),Y||(Y=0),we>0&&we=this.length)throw new RangeError("Index out of range");if(we<0)throw new RangeError("sourceEnd out of bounds");we>this.length&&(we=this.length),G.length-Y=0;--je)G[je+Y]=this[je+fe];else Uint8Array.prototype.set.call(G,this.subarray(fe,we),Y);return _e},h.prototype.fill=function(G,Y,fe,we){if(typeof G=="string"){if(typeof Y=="string"?(we=Y,Y=0,fe=this.length):typeof fe=="string"&&(we=fe,fe=this.length),we!==void 0&&typeof we!="string")throw new TypeError("encoding must be a string");if(typeof we=="string"&&!h.isEncoding(we))throw new TypeError("Unknown encoding: "+we);if(G.length===1){var _e=G.charCodeAt(0);(we==="utf8"&&_e<128||we==="latin1")&&(G=_e)}}else typeof G=="number"&&(G=G&255);if(Y<0||this.length>>0,fe=fe===void 0?this.length:fe>>>0,G||(G=0);var je;if(typeof G=="number")for(je=Y;je55295&&Y<57344){if(!we){if(Y>56319){(G-=3)>-1&&_e.push(239,191,189);continue}else if(je+1===fe){(G-=3)>-1&&_e.push(239,191,189);continue}we=Y;continue}if(Y<56320){(G-=3)>-1&&_e.push(239,191,189),we=Y;continue}Y=(we-55296<<10|Y-56320)+65536}else we&&(G-=3)>-1&&_e.push(239,191,189);if(we=null,Y<128){if((G-=1)<0)break;_e.push(Y)}else if(Y<2048){if((G-=2)<0)break;_e.push(Y>>6|192,Y&63|128)}else if(Y<65536){if((G-=3)<0)break;_e.push(Y>>12|224,Y>>6&63|128,Y&63|128)}else if(Y<1114112){if((G-=4)<0)break;_e.push(Y>>18|240,Y>>12&63|128,Y>>6&63|128,Y&63|128)}else throw new Error("Invalid code point")}return _e}function Q(q){for(var G=[],Y=0;Y>8,we=Y%256,_e.push(we),_e.push(fe);return _e}function xe(q){return g.toByteArray(ge(q))}function ie(q,G,Y,fe){for(var we=0;we=G.length||we>=q.length);++we)G[we+Y]=q[we];return we}function se(q,G){return q instanceof G||q!=null&&q.constructor!=null&&q.constructor.name!=null&&q.constructor.name===G.name}function Ce(q){return q!==q}}).call(this,e("buffer").Buffer)},{"base64-js":182,buffer:216,ieee754:385}],217:[function(e,S,_){(function(u){S.exports=function(g,b){for(var w=Math.min(g.length,b.length),f=new u(w),v=0;vs;)if(m=l[s++],m!=m)return!0}else for(;d>s;s++)if((w||s in l)&&l[s]===v)return w||s||0;return!w&&-1}};S.exports={includes:b(!0),indexOf:b(!1)}},{"../internals/to-absolute-index":304,"../internals/to-indexed-object":305,"../internals/to-length":307}],225:[function(e,S,_){var u=e("../internals/function-bind-context"),y=e("../internals/indexed-object"),g=e("../internals/to-object"),b=e("../internals/to-length"),w=e("../internals/array-species-create"),f=[].push,v=function(h){var l=h==1,d=h==2,s=h==3,m=h==4,c=h==6,a=h==5||c;return function(r,t,i,n){for(var o=g(r),p=y(o),E=u(t,i,3),P=b(p.length),D=0,z=n||w,B=l?z(r,P):d?z(r,0):void 0,M,I;P>D;D++)if((a||D in p)&&(M=p[D],I=E(M,D,o),h)){if(l)B[D]=I;else if(I)switch(h){case 3:return!0;case 5:return M;case 6:return D;case 2:f.call(B,M)}else if(m)return!1}return c?-1:s||m?m:B}};S.exports={forEach:v(0),map:v(1),filter:v(2),some:v(3),every:v(4),find:v(5),findIndex:v(6)}},{"../internals/array-species-create":227,"../internals/function-bind-context":248,"../internals/indexed-object":257,"../internals/to-length":307,"../internals/to-object":308}],226:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/fails"),g=e("../internals/has"),b=Object.defineProperty,w={},f=function(v){throw v};S.exports=function(v,h){if(g(w,v))return w[v];h||(h={});var l=[][v],d=g(h,"ACCESSORS")?h.ACCESSORS:!1,s=g(h,0)?h[0]:f,m=g(h,1)?h[1]:void 0;return w[v]=!!l&&!y(function(){if(d&&!u)return!0;var c={length:-1};d?b(c,1,{enumerable:!0,get:f}):c[1]=1,l.call(c,s,m)})}},{"../internals/descriptors":240,"../internals/fails":247,"../internals/has":252}],227:[function(e,S,_){var u=e("../internals/is-object"),y=e("../internals/is-array"),g=e("../internals/well-known-symbol"),b=g("species");S.exports=function(w,f){var v;return y(w)&&(v=w.constructor,typeof v=="function"&&(v===Array||y(v.prototype))?v=void 0:u(v)&&(v=v[b],v===null&&(v=void 0))),new(v===void 0?Array:v)(f===0?0:f)}},{"../internals/is-array":261,"../internals/is-object":263,"../internals/well-known-symbol":314}],228:[function(e,S,_){var u=e("../internals/an-object");S.exports=function(y,g,b,w){try{return w?g(u(b)[0],b[1]):g(b)}catch(v){var f=y.return;throw f!==void 0&&u(f.call(y)),v}}},{"../internals/an-object":223}],229:[function(e,S,_){var u=e("../internals/well-known-symbol"),y=u("iterator"),g=!1;try{var b=0,w={next:function(){return{done:!!b++}},return:function(){g=!0}};w[y]=function(){return this},Array.from(w,function(){throw 2})}catch{}S.exports=function(f,v){if(!v&&!g)return!1;var h=!1;try{var l={};l[y]=function(){return{next:function(){return{done:h=!0}}}},f(l)}catch{}return h}},{"../internals/well-known-symbol":314}],230:[function(e,S,_){var u={}.toString;S.exports=function(y){return u.call(y).slice(8,-1)}},{}],231:[function(e,S,_){var u=e("../internals/to-string-tag-support"),y=e("../internals/classof-raw"),g=e("../internals/well-known-symbol"),b=g("toStringTag"),w=y(function(){return arguments}())=="Arguments",f=function(v,h){try{return v[h]}catch{}};S.exports=u?y:function(v){var h,l,d;return v===void 0?"Undefined":v===null?"Null":typeof(l=f(h=Object(v),b))=="string"?l:w?y(h):(d=y(h))=="Object"&&typeof h.callee=="function"?"Arguments":d}},{"../internals/classof-raw":230,"../internals/to-string-tag-support":310,"../internals/well-known-symbol":314}],232:[function(e,S,_){var u=e("../internals/has"),y=e("../internals/own-keys"),g=e("../internals/object-get-own-property-descriptor"),b=e("../internals/object-define-property");S.exports=function(w,f){for(var v=y(f),h=b.f,l=g.f,d=0;d=74)&&(f=y.match(/Chrome\/(\d+)/),f&&(v=f[1]))),S.exports=v&&+v},{"../internals/engine-user-agent":243,"../internals/global":251}],245:[function(e,S,_){S.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},{}],246:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/object-get-own-property-descriptor").f,g=e("../internals/create-non-enumerable-property"),b=e("../internals/redefine"),w=e("../internals/set-global"),f=e("../internals/copy-constructor-properties"),v=e("../internals/is-forced");S.exports=function(h,l){var d=h.target,s=h.global,m=h.stat,c,a,r,t,i,n;if(s?a=u:m?a=u[d]||w(d,{}):a=(u[d]||{}).prototype,a)for(r in l){if(i=l[r],h.noTargetGet?(n=y(a,r),t=n&&n.value):t=a[r],c=v(s?r:d+(m?".":"#")+r,h.forced),!c&&t!==void 0){if(typeof i==typeof t)continue;f(i,t)}(h.sham||t&&t.sham)&&g(i,"sham",!0),b(a,r,i,h)}}},{"../internals/copy-constructor-properties":232,"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/is-forced":262,"../internals/object-get-own-property-descriptor":279,"../internals/redefine":294,"../internals/set-global":296}],247:[function(e,S,_){S.exports=function(u){try{return!!u()}catch{return!0}}},{}],248:[function(e,S,_){var u=e("../internals/a-function");S.exports=function(y,g,b){if(u(y),g===void 0)return y;switch(b){case 0:return function(){return y.call(g)};case 1:return function(w){return y.call(g,w)};case 2:return function(w,f){return y.call(g,w,f)};case 3:return function(w,f,v){return y.call(g,w,f,v)}}return function(){return y.apply(g,arguments)}}},{"../internals/a-function":219}],249:[function(e,S,_){var u=e("../internals/path"),y=e("../internals/global"),g=function(b){return typeof b=="function"?b:void 0};S.exports=function(b,w){return arguments.length<2?g(u[b])||g(y[b]):u[b]&&u[b][w]||y[b]&&y[b][w]}},{"../internals/global":251,"../internals/path":290}],250:[function(e,S,_){var u=e("../internals/classof"),y=e("../internals/iterators"),g=e("../internals/well-known-symbol"),b=g("iterator");S.exports=function(w){if(w!=null)return w[b]||w["@@iterator"]||y[u(w)]}},{"../internals/classof":231,"../internals/iterators":268,"../internals/well-known-symbol":314}],251:[function(e,S,_){(function(u){var y=function(g){return g&&g.Math==Math&&g};S.exports=y(typeof globalThis=="object"&&globalThis)||y(typeof window=="object"&&window)||y(typeof self=="object"&&self)||y(typeof u=="object"&&u)||Function("return this")()}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],252:[function(e,S,_){var u={}.hasOwnProperty;S.exports=function(y,g){return u.call(y,g)}},{}],253:[function(e,S,_){S.exports={}},{}],254:[function(e,S,_){var u=e("../internals/global");S.exports=function(y,g){var b=u.console;b&&b.error&&(arguments.length===1?b.error(y):b.error(y,g))}},{"../internals/global":251}],255:[function(e,S,_){var u=e("../internals/get-built-in");S.exports=u("document","documentElement")},{"../internals/get-built-in":249}],256:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/fails"),g=e("../internals/document-create-element");S.exports=!u&&!y(function(){return Object.defineProperty(g("div"),"a",{get:function(){return 7}}).a!=7})},{"../internals/descriptors":240,"../internals/document-create-element":241,"../internals/fails":247}],257:[function(e,S,_){var u=e("../internals/fails"),y=e("../internals/classof-raw"),g="".split;S.exports=u(function(){return!Object("z").propertyIsEnumerable(0)})?function(b){return y(b)=="String"?g.call(b,""):Object(b)}:Object},{"../internals/classof-raw":230,"../internals/fails":247}],258:[function(e,S,_){var u=e("../internals/shared-store"),y=Function.toString;typeof u.inspectSource!="function"&&(u.inspectSource=function(g){return y.call(g)}),S.exports=u.inspectSource},{"../internals/shared-store":300}],259:[function(e,S,_){var u=e("../internals/native-weak-map"),y=e("../internals/global"),g=e("../internals/is-object"),b=e("../internals/create-non-enumerable-property"),w=e("../internals/has"),f=e("../internals/shared-key"),v=e("../internals/hidden-keys"),h=y.WeakMap,l,d,s,m=function(o){return s(o)?d(o):l(o,{})},c=function(o){return function(p){var E;if(!g(p)||(E=d(p)).type!==o)throw TypeError("Incompatible receiver, "+o+" required");return E}};if(u){var a=new h,r=a.get,t=a.has,i=a.set;l=function(o,p){return i.call(a,o,p),p},d=function(o){return r.call(a,o)||{}},s=function(o){return t.call(a,o)}}else{var n=f("state");v[n]=!0,l=function(o,p){return b(o,n,p),p},d=function(o){return w(o,n)?o[n]:{}},s=function(o){return w(o,n)}}S.exports={set:l,get:d,has:s,enforce:m,getterFor:c}},{"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/has":252,"../internals/hidden-keys":253,"../internals/is-object":263,"../internals/native-weak-map":272,"../internals/shared-key":299}],260:[function(e,S,_){var u=e("../internals/well-known-symbol"),y=e("../internals/iterators"),g=u("iterator"),b=Array.prototype;S.exports=function(w){return w!==void 0&&(y.Array===w||b[g]===w)}},{"../internals/iterators":268,"../internals/well-known-symbol":314}],261:[function(e,S,_){var u=e("../internals/classof-raw");S.exports=Array.isArray||function(g){return u(g)=="Array"}},{"../internals/classof-raw":230}],262:[function(e,S,_){var u=e("../internals/fails"),y=/#|\.prototype\./,g=function(h,l){var d=w[b(h)];return d==v?!0:d==f?!1:typeof l=="function"?u(l):!!l},b=g.normalize=function(h){return String(h).replace(y,".").toLowerCase()},w=g.data={},f=g.NATIVE="N",v=g.POLYFILL="P";S.exports=g},{"../internals/fails":247}],263:[function(e,S,_){S.exports=function(u){return typeof u=="object"?u!==null:typeof u=="function"}},{}],264:[function(e,S,_){S.exports=!1},{}],265:[function(e,S,_){var u=e("../internals/is-object"),y=e("../internals/classof-raw"),g=e("../internals/well-known-symbol"),b=g("match");S.exports=function(w){var f;return u(w)&&((f=w[b])!==void 0?!!f:y(w)=="RegExp")}},{"../internals/classof-raw":230,"../internals/is-object":263,"../internals/well-known-symbol":314}],266:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/is-array-iterator-method"),g=e("../internals/to-length"),b=e("../internals/function-bind-context"),w=e("../internals/get-iterator-method"),f=e("../internals/call-with-safe-iteration-closing"),v=function(l,d){this.stopped=l,this.result=d},h=S.exports=function(l,d,s,m,c){var a=b(d,s,m?2:1),r,t,i,n,o,p,E;if(c)r=l;else{if(t=w(l),typeof t!="function")throw TypeError("Target is not iterable");if(y(t)){for(i=0,n=g(l.length);n>i;i++)if(o=m?a(u(E=l[i])[0],E[1]):a(l[i]),o&&o instanceof v)return o;return new v(!1)}r=t.call(l)}for(p=r.next;!(E=p.call(r)).done;)if(o=f(r,a,E.value,m),typeof o=="object"&&o&&o instanceof v)return o;return new v(!1)};h.stop=function(l){return new v(!0,l)}},{"../internals/an-object":223,"../internals/call-with-safe-iteration-closing":228,"../internals/function-bind-context":248,"../internals/get-iterator-method":250,"../internals/is-array-iterator-method":260,"../internals/to-length":307}],267:[function(e,S,_){var u=e("../internals/object-get-prototype-of"),y=e("../internals/create-non-enumerable-property"),g=e("../internals/has"),b=e("../internals/well-known-symbol"),w=e("../internals/is-pure"),f=b("iterator"),v=!1,h=function(){return this},l,d,s;[].keys&&(s=[].keys(),"next"in s?(d=u(u(s)),d!==Object.prototype&&(l=d)):v=!0),l==null&&(l={}),!w&&!g(l,f)&&y(l,f,h),S.exports={IteratorPrototype:l,BUGGY_SAFARI_ITERATORS:v}},{"../internals/create-non-enumerable-property":236,"../internals/has":252,"../internals/is-pure":264,"../internals/object-get-prototype-of":283,"../internals/well-known-symbol":314}],268:[function(e,S,_){arguments[4][253][0].apply(_,arguments)},{dup:253}],269:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/object-get-own-property-descriptor").f,g=e("../internals/classof-raw"),b=e("../internals/task").set,w=e("../internals/engine-is-ios"),f=u.MutationObserver||u.WebKitMutationObserver,v=u.process,h=u.Promise,l=g(v)=="process",d=y(u,"queueMicrotask"),s=d&&d.value,m,c,a,r,t,i,n,o;s||(m=function(){var p,E;for(l&&(p=v.domain)&&p.exit();c;){E=c.fn,c=c.next;try{E()}catch(P){throw c?r():a=void 0,P}}a=void 0,p&&p.enter()},l?r=function(){v.nextTick(m)}:f&&!w?(t=!0,i=document.createTextNode(""),new f(m).observe(i,{characterData:!0}),r=function(){i.data=t=!t}):h&&h.resolve?(n=h.resolve(void 0),o=n.then,r=function(){o.call(n,m)}):r=function(){b.call(u,m)}),S.exports=s||function(p){var E={fn:p,next:void 0};a&&(a.next=E),c||(c=E,r()),a=E}},{"../internals/classof-raw":230,"../internals/engine-is-ios":242,"../internals/global":251,"../internals/object-get-own-property-descriptor":279,"../internals/task":303}],270:[function(e,S,_){var u=e("../internals/global");S.exports=u.Promise},{"../internals/global":251}],271:[function(e,S,_){var u=e("../internals/fails");S.exports=!!Object.getOwnPropertySymbols&&!u(function(){return!String(Symbol())})},{"../internals/fails":247}],272:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/inspect-source"),g=u.WeakMap;S.exports=typeof g=="function"&&/native code/.test(y(g))},{"../internals/global":251,"../internals/inspect-source":258}],273:[function(e,S,_){var u=e("../internals/a-function"),y=function(g){var b,w;this.promise=new g(function(f,v){if(b!==void 0||w!==void 0)throw TypeError("Bad Promise constructor");b=f,w=v}),this.resolve=u(b),this.reject=u(w)};S.exports.f=function(g){return new y(g)}},{"../internals/a-function":219}],274:[function(e,S,_){var u=e("../internals/is-regexp");S.exports=function(y){if(u(y))throw TypeError("The method doesn't accept regular expressions");return y}},{"../internals/is-regexp":265}],275:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/fails"),g=e("../internals/object-keys"),b=e("../internals/object-get-own-property-symbols"),w=e("../internals/object-property-is-enumerable"),f=e("../internals/to-object"),v=e("../internals/indexed-object"),h=Object.assign,l=Object.defineProperty;S.exports=!h||y(function(){if(u&&h({b:1},h(l({},"a",{enumerable:!0,get:function(){l(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var d={},s={},m=Symbol(),c="abcdefghijklmnopqrst";return d[m]=7,c.split("").forEach(function(a){s[a]=a}),h({},d)[m]!=7||g(h({},s)).join("")!=c})?function(s,m){for(var c=f(s),a=arguments.length,r=1,t=b.f,i=w.f;a>r;)for(var n=v(arguments[r++]),o=t?g(n).concat(t(n)):g(n),p=o.length,E=0,P;p>E;)P=o[E++],(!u||i.call(n,P))&&(c[P]=n[P]);return c}:h},{"../internals/descriptors":240,"../internals/fails":247,"../internals/indexed-object":257,"../internals/object-get-own-property-symbols":282,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/to-object":308}],276:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/object-define-properties"),g=e("../internals/enum-bug-keys"),b=e("../internals/hidden-keys"),w=e("../internals/html"),f=e("../internals/document-create-element"),v=e("../internals/shared-key"),h=">",l="<",d="prototype",s="script",m=v("IE_PROTO"),c=function(){},a=function(o){return l+s+h+o+l+"/"+s+h},r=function(o){o.write(a("")),o.close();var p=o.parentWindow.Object;return o=null,p},t=function(){var o=f("iframe"),p="java"+s+":",E;return o.style.display="none",w.appendChild(o),o.src=String(p),E=o.contentWindow.document,E.open(),E.write(a("document.F=Object")),E.close(),E.F},i,n=function(){try{i=document.domain&&new ActiveXObject("htmlfile")}catch{}n=i?r(i):t();for(var o=g.length;o--;)delete n[d][g[o]];return n()};b[m]=!0,S.exports=Object.create||function(p,E){var P;return p!==null?(c[d]=u(p),P=new c,c[d]=null,P[m]=p):P=n(),E===void 0?P:y(P,E)}},{"../internals/an-object":223,"../internals/document-create-element":241,"../internals/enum-bug-keys":245,"../internals/hidden-keys":253,"../internals/html":255,"../internals/object-define-properties":277,"../internals/shared-key":299}],277:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/object-define-property"),g=e("../internals/an-object"),b=e("../internals/object-keys");S.exports=u?Object.defineProperties:function(f,v){g(f);for(var h=b(v),l=h.length,d=0,s;l>d;)y.f(f,s=h[d++],v[s]);return f}},{"../internals/an-object":223,"../internals/descriptors":240,"../internals/object-define-property":278,"../internals/object-keys":285}],278:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/ie8-dom-define"),g=e("../internals/an-object"),b=e("../internals/to-primitive"),w=Object.defineProperty;_.f=u?w:function(v,h,l){if(g(v),h=b(h,!0),g(l),y)try{return w(v,h,l)}catch{}if("get"in l||"set"in l)throw TypeError("Accessors not supported");return"value"in l&&(v[h]=l.value),v}},{"../internals/an-object":223,"../internals/descriptors":240,"../internals/ie8-dom-define":256,"../internals/to-primitive":309}],279:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/object-property-is-enumerable"),g=e("../internals/create-property-descriptor"),b=e("../internals/to-indexed-object"),w=e("../internals/to-primitive"),f=e("../internals/has"),v=e("../internals/ie8-dom-define"),h=Object.getOwnPropertyDescriptor;_.f=u?h:function(d,s){if(d=b(d),s=w(s,!0),v)try{return h(d,s)}catch{}if(f(d,s))return g(!y.f.call(d,s),d[s])}},{"../internals/create-property-descriptor":237,"../internals/descriptors":240,"../internals/has":252,"../internals/ie8-dom-define":256,"../internals/object-property-is-enumerable":286,"../internals/to-indexed-object":305,"../internals/to-primitive":309}],280:[function(e,S,_){var u=e("../internals/to-indexed-object"),y=e("../internals/object-get-own-property-names").f,g={}.toString,b=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],w=function(f){try{return y(f)}catch{return b.slice()}};S.exports.f=function(v){return b&&g.call(v)=="[object Window]"?w(v):y(u(v))}},{"../internals/object-get-own-property-names":281,"../internals/to-indexed-object":305}],281:[function(e,S,_){var u=e("../internals/object-keys-internal"),y=e("../internals/enum-bug-keys"),g=y.concat("length","prototype");_.f=Object.getOwnPropertyNames||function(w){return u(w,g)}},{"../internals/enum-bug-keys":245,"../internals/object-keys-internal":284}],282:[function(e,S,_){_.f=Object.getOwnPropertySymbols},{}],283:[function(e,S,_){var u=e("../internals/has"),y=e("../internals/to-object"),g=e("../internals/shared-key"),b=e("../internals/correct-prototype-getter"),w=g("IE_PROTO"),f=Object.prototype;S.exports=b?Object.getPrototypeOf:function(v){return v=y(v),u(v,w)?v[w]:typeof v.constructor=="function"&&v instanceof v.constructor?v.constructor.prototype:v instanceof Object?f:null}},{"../internals/correct-prototype-getter":234,"../internals/has":252,"../internals/shared-key":299,"../internals/to-object":308}],284:[function(e,S,_){var u=e("../internals/has"),y=e("../internals/to-indexed-object"),g=e("../internals/array-includes").indexOf,b=e("../internals/hidden-keys");S.exports=function(w,f){var v=y(w),h=0,l=[],d;for(d in v)!u(b,d)&&u(v,d)&&l.push(d);for(;f.length>h;)u(v,d=f[h++])&&(~g(l,d)||l.push(d));return l}},{"../internals/array-includes":224,"../internals/has":252,"../internals/hidden-keys":253,"../internals/to-indexed-object":305}],285:[function(e,S,_){var u=e("../internals/object-keys-internal"),y=e("../internals/enum-bug-keys");S.exports=Object.keys||function(b){return u(b,y)}},{"../internals/enum-bug-keys":245,"../internals/object-keys-internal":284}],286:[function(e,S,_){var u={}.propertyIsEnumerable,y=Object.getOwnPropertyDescriptor,g=y&&!u.call({1:2},1);_.f=g?function(w){var f=y(this,w);return!!f&&f.enumerable}:u},{}],287:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/a-possible-prototype");S.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var g=!1,b={},w;try{w=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set,w.call(b,[]),g=b instanceof Array}catch{}return function(v,h){return u(v),y(h),g?w.call(v,h):v.__proto__=h,v}}():void 0)},{"../internals/a-possible-prototype":220,"../internals/an-object":223}],288:[function(e,S,_){var u=e("../internals/descriptors"),y=e("../internals/object-keys"),g=e("../internals/to-indexed-object"),b=e("../internals/object-property-is-enumerable").f,w=function(f){return function(v){for(var h=g(v),l=y(h),d=l.length,s=0,m=[],c;d>s;)c=l[s++],(!u||b.call(h,c))&&m.push(f?[c,h[c]]:h[c]);return m}};S.exports={entries:w(!0),values:w(!1)}},{"../internals/descriptors":240,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/to-indexed-object":305}],289:[function(e,S,_){var u=e("../internals/get-built-in"),y=e("../internals/object-get-own-property-names"),g=e("../internals/object-get-own-property-symbols"),b=e("../internals/an-object");S.exports=u("Reflect","ownKeys")||function(f){var v=y.f(b(f)),h=g.f;return h?v.concat(h(f)):v}},{"../internals/an-object":223,"../internals/get-built-in":249,"../internals/object-get-own-property-names":281,"../internals/object-get-own-property-symbols":282}],290:[function(e,S,_){var u=e("../internals/global");S.exports=u},{"../internals/global":251}],291:[function(e,S,_){S.exports=function(u){try{return{error:!1,value:u()}}catch(y){return{error:!0,value:y}}}},{}],292:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/is-object"),g=e("../internals/new-promise-capability");S.exports=function(b,w){if(u(b),y(w)&&w.constructor===b)return w;var f=g.f(b),v=f.resolve;return v(w),f.promise}},{"../internals/an-object":223,"../internals/is-object":263,"../internals/new-promise-capability":273}],293:[function(e,S,_){var u=e("../internals/redefine");S.exports=function(y,g,b){for(var w in g)u(y,w,g[w],b);return y}},{"../internals/redefine":294}],294:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/create-non-enumerable-property"),g=e("../internals/has"),b=e("../internals/set-global"),w=e("../internals/inspect-source"),f=e("../internals/internal-state"),v=f.get,h=f.enforce,l=String(String).split("String");(S.exports=function(d,s,m,c){var a=c?!!c.unsafe:!1,r=c?!!c.enumerable:!1,t=c?!!c.noTargetGet:!1;if(typeof m=="function"&&(typeof s=="string"&&!g(m,"name")&&y(m,"name",s),h(m).source=l.join(typeof s=="string"?s:"")),d===u){r?d[s]=m:b(s,m);return}else a?!t&&d[s]&&(r=!0):delete d[s];r?d[s]=m:y(d,s,m)})(Function.prototype,"toString",function(){return typeof this=="function"&&v(this).source||w(this)})},{"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/has":252,"../internals/inspect-source":258,"../internals/internal-state":259,"../internals/set-global":296}],295:[function(e,S,_){S.exports=function(u){if(u==null)throw TypeError("Can't call method on "+u);return u}},{}],296:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/create-non-enumerable-property");S.exports=function(g,b){try{y(u,g,b)}catch{u[g]=b}return b}},{"../internals/create-non-enumerable-property":236,"../internals/global":251}],297:[function(e,S,_){var u=e("../internals/get-built-in"),y=e("../internals/object-define-property"),g=e("../internals/well-known-symbol"),b=e("../internals/descriptors"),w=g("species");S.exports=function(f){var v=u(f),h=y.f;b&&v&&!v[w]&&h(v,w,{configurable:!0,get:function(){return this}})}},{"../internals/descriptors":240,"../internals/get-built-in":249,"../internals/object-define-property":278,"../internals/well-known-symbol":314}],298:[function(e,S,_){var u=e("../internals/object-define-property").f,y=e("../internals/has"),g=e("../internals/well-known-symbol"),b=g("toStringTag");S.exports=function(w,f,v){w&&!y(w=v?w:w.prototype,b)&&u(w,b,{configurable:!0,value:f})}},{"../internals/has":252,"../internals/object-define-property":278,"../internals/well-known-symbol":314}],299:[function(e,S,_){var u=e("../internals/shared"),y=e("../internals/uid"),g=u("keys");S.exports=function(b){return g[b]||(g[b]=y(b))}},{"../internals/shared":301,"../internals/uid":311}],300:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/set-global"),g="__core-js_shared__",b=u[g]||y(g,{});S.exports=b},{"../internals/global":251,"../internals/set-global":296}],301:[function(e,S,_){var u=e("../internals/is-pure"),y=e("../internals/shared-store");(S.exports=function(g,b){return y[g]||(y[g]=b!==void 0?b:{})})("versions",[]).push({version:"3.6.5",mode:u?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})},{"../internals/is-pure":264,"../internals/shared-store":300}],302:[function(e,S,_){var u=e("../internals/an-object"),y=e("../internals/a-function"),g=e("../internals/well-known-symbol"),b=g("species");S.exports=function(w,f){var v=u(w).constructor,h;return v===void 0||(h=u(v)[b])==null?f:y(h)}},{"../internals/a-function":219,"../internals/an-object":223,"../internals/well-known-symbol":314}],303:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/fails"),g=e("../internals/classof-raw"),b=e("../internals/function-bind-context"),w=e("../internals/html"),f=e("../internals/document-create-element"),v=e("../internals/engine-is-ios"),h=u.location,l=u.setImmediate,d=u.clearImmediate,s=u.process,m=u.MessageChannel,c=u.Dispatch,a=0,r={},t="onreadystatechange",i,n,o,p=function(z){if(r.hasOwnProperty(z)){var B=r[z];delete r[z],B()}},E=function(z){return function(){p(z)}},P=function(z){p(z.data)},D=function(z){u.postMessage(z+"",h.protocol+"//"+h.host)};(!l||!d)&&(l=function(B){for(var M=[],I=1;arguments.length>I;)M.push(arguments[I++]);return r[++a]=function(){(typeof B=="function"?B:Function(B)).apply(void 0,M)},i(a),a},d=function(B){delete r[B]},g(s)=="process"?i=function(z){s.nextTick(E(z))}:c&&c.now?i=function(z){c.now(E(z))}:m&&!v?(n=new m,o=n.port2,n.port1.onmessage=P,i=b(o.postMessage,o,1)):u.addEventListener&&typeof postMessage=="function"&&!u.importScripts&&!y(D)&&h.protocol!=="file:"?(i=D,u.addEventListener("message",P,!1)):t in f("script")?i=function(z){w.appendChild(f("script"))[t]=function(){w.removeChild(this),p(z)}}:i=function(z){setTimeout(E(z),0)}),S.exports={set:l,clear:d}},{"../internals/classof-raw":230,"../internals/document-create-element":241,"../internals/engine-is-ios":242,"../internals/fails":247,"../internals/function-bind-context":248,"../internals/global":251,"../internals/html":255}],304:[function(e,S,_){var u=e("../internals/to-integer"),y=Math.max,g=Math.min;S.exports=function(b,w){var f=u(b);return f<0?y(f+w,0):g(f,w)}},{"../internals/to-integer":306}],305:[function(e,S,_){var u=e("../internals/indexed-object"),y=e("../internals/require-object-coercible");S.exports=function(g){return u(y(g))}},{"../internals/indexed-object":257,"../internals/require-object-coercible":295}],306:[function(e,S,_){var u=Math.ceil,y=Math.floor;S.exports=function(g){return isNaN(g=+g)?0:(g>0?y:u)(g)}},{}],307:[function(e,S,_){var u=e("../internals/to-integer"),y=Math.min;S.exports=function(g){return g>0?y(u(g),9007199254740991):0}},{"../internals/to-integer":306}],308:[function(e,S,_){var u=e("../internals/require-object-coercible");S.exports=function(y){return Object(u(y))}},{"../internals/require-object-coercible":295}],309:[function(e,S,_){var u=e("../internals/is-object");S.exports=function(y,g){if(!u(y))return y;var b,w;if(g&&typeof(b=y.toString)=="function"&&!u(w=b.call(y))||typeof(b=y.valueOf)=="function"&&!u(w=b.call(y))||!g&&typeof(b=y.toString)=="function"&&!u(w=b.call(y)))return w;throw TypeError("Can't convert object to primitive value")}},{"../internals/is-object":263}],310:[function(e,S,_){var u=e("../internals/well-known-symbol"),y=u("toStringTag"),g={};g[y]="z",S.exports=String(g)==="[object z]"},{"../internals/well-known-symbol":314}],311:[function(e,S,_){var u=0,y=Math.random();S.exports=function(g){return"Symbol("+String(g===void 0?"":g)+")_"+(++u+y).toString(36)}},{}],312:[function(e,S,_){var u=e("../internals/native-symbol");S.exports=u&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},{"../internals/native-symbol":271}],313:[function(e,S,_){var u=e("../internals/well-known-symbol");_.f=u},{"../internals/well-known-symbol":314}],314:[function(e,S,_){var u=e("../internals/global"),y=e("../internals/shared"),g=e("../internals/has"),b=e("../internals/uid"),w=e("../internals/native-symbol"),f=e("../internals/use-symbol-as-uid"),v=y("wks"),h=u.Symbol,l=f?h:h&&h.withoutSetter||b;S.exports=function(d){return g(v,d)||(w&&g(h,d)?v[d]=h[d]:v[d]=l("Symbol."+d)),v[d]}},{"../internals/global":251,"../internals/has":252,"../internals/native-symbol":271,"../internals/shared":301,"../internals/uid":311,"../internals/use-symbol-as-uid":312}],315:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/array-iteration").findIndex,g=e("../internals/add-to-unscopables"),b=e("../internals/array-method-uses-to-length"),w="findIndex",f=!0,v=b(w);w in[]&&Array(1)[w](function(){f=!1}),u({target:"Array",proto:!0,forced:f||!v},{findIndex:function(l){return y(this,l,arguments.length>1?arguments[1]:void 0)}}),g(w)},{"../internals/add-to-unscopables":221,"../internals/array-iteration":225,"../internals/array-method-uses-to-length":226,"../internals/export":246}],316:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/array-iteration").find,g=e("../internals/add-to-unscopables"),b=e("../internals/array-method-uses-to-length"),w="find",f=!0,v=b(w);w in[]&&Array(1)[w](function(){f=!1}),u({target:"Array",proto:!0,forced:f||!v},{find:function(l){return y(this,l,arguments.length>1?arguments[1]:void 0)}}),g(w)},{"../internals/add-to-unscopables":221,"../internals/array-iteration":225,"../internals/array-method-uses-to-length":226,"../internals/export":246}],317:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/array-includes").includes,g=e("../internals/add-to-unscopables"),b=e("../internals/array-method-uses-to-length"),w=b("indexOf",{ACCESSORS:!0,1:0});u({target:"Array",proto:!0,forced:!w},{includes:function(v){return y(this,v,arguments.length>1?arguments[1]:void 0)}}),g("includes")},{"../internals/add-to-unscopables":221,"../internals/array-includes":224,"../internals/array-method-uses-to-length":226,"../internals/export":246}],318:[function(e,S,_){var u=e("../internals/to-indexed-object"),y=e("../internals/add-to-unscopables"),g=e("../internals/iterators"),b=e("../internals/internal-state"),w=e("../internals/define-iterator"),f="Array Iterator",v=b.set,h=b.getterFor(f);S.exports=w(Array,"Array",function(l,d){v(this,{type:f,target:u(l),index:0,kind:d})},function(){var l=h(this),d=l.target,s=l.kind,m=l.index++;return!d||m>=d.length?(l.target=void 0,{value:void 0,done:!0}):s=="keys"?{value:m,done:!1}:s=="values"?{value:d[m],done:!1}:{value:[m,d[m]],done:!1}},"values"),g.Arguments=g.Array,y("keys"),y("values"),y("entries")},{"../internals/add-to-unscopables":221,"../internals/define-iterator":238,"../internals/internal-state":259,"../internals/iterators":268,"../internals/to-indexed-object":305}],319:[function(e,S,_){var u=e("../internals/export");u({target:"Number",stat:!0},{isNaN:function(g){return g!=g}})},{"../internals/export":246}],320:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/object-assign");u({target:"Object",stat:!0,forced:Object.assign!==y},{assign:y})},{"../internals/export":246,"../internals/object-assign":275}],321:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/to-object"),g=e("../internals/object-keys"),b=e("../internals/fails"),w=b(function(){g(1)});u({target:"Object",stat:!0,forced:w},{keys:function(v){return g(y(v))}})},{"../internals/export":246,"../internals/fails":247,"../internals/object-keys":285,"../internals/to-object":308}],322:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/object-to-array").values;u({target:"Object",stat:!0},{values:function(b){return y(b)}})},{"../internals/export":246,"../internals/object-to-array":288}],323:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/is-pure"),g=e("../internals/global"),b=e("../internals/get-built-in"),w=e("../internals/native-promise-constructor"),f=e("../internals/redefine"),v=e("../internals/redefine-all"),h=e("../internals/set-to-string-tag"),l=e("../internals/set-species"),d=e("../internals/is-object"),s=e("../internals/a-function"),m=e("../internals/an-instance"),c=e("../internals/classof-raw"),a=e("../internals/inspect-source"),r=e("../internals/iterate"),t=e("../internals/check-correctness-of-iteration"),i=e("../internals/species-constructor"),n=e("../internals/task").set,o=e("../internals/microtask"),p=e("../internals/promise-resolve"),E=e("../internals/host-report-errors"),P=e("../internals/new-promise-capability"),D=e("../internals/perform"),z=e("../internals/internal-state"),B=e("../internals/is-forced"),M=e("../internals/well-known-symbol"),I=e("../internals/engine-v8-version"),T=M("species"),C="Promise",O=z.get,A=z.set,L=z.getterFor(C),U=w,W=g.TypeError,$=g.document,N=g.process,F=b("fetch"),j=P.f,V=j,te=c(N)=="process",re=!!($&&$.createEvent&&g.dispatchEvent),le="unhandledrejection",ye="rejectionhandled",ge=0,ne=1,J=2,Q=1,he=2,xe,ie,se,Ce,q=B(C,function(){var Ue=a(U)!==String(U);if(!Ue&&(I===66||!te&&typeof PromiseRejectionEvent!="function")||y&&!U.prototype.finally)return!0;if(I>=51&&/native code/.test(U))return!1;var Ve=U.resolve(1),Qe=function(oe){oe(function(){},function(){})},tt=Ve.constructor={};return tt[T]=Qe,!(Ve.then(function(){})instanceof Qe)}),G=q||!t(function(Ue){U.all(Ue).catch(function(){})}),Y=function(Ue){var Ve;return d(Ue)&&typeof(Ve=Ue.then)=="function"?Ve:!1},fe=function(Ue,Ve,Qe){if(!Ve.notified){Ve.notified=!0;var tt=Ve.reactions;o(function(){for(var oe=Ve.value,Re=Ve.state==ne,be=0;tt.length>be;){var Ee=tt[be++],pe=Re?Ee.ok:Ee.fail,Pe=Ee.resolve,ee=Ee.reject,He=Ee.domain,it,K,Me;try{pe?(Re||(Ve.rejection===he&&Ye(Ue,Ve),Ve.rejection=Q),pe===!0?it=oe:(He&&He.enter(),it=pe(oe),He&&(He.exit(),Me=!0)),it===Ee.promise?ee(W("Promise-chain cycle")):(K=Y(it))?K.call(it,Pe,ee):Pe(it)):ee(oe)}catch(Le){He&&!Me&&He.exit(),ee(Le)}}Ve.reactions=[],Ve.notified=!1,Qe&&!Ve.rejection&&_e(Ue,Ve)})}},we=function(Ue,Ve,Qe){var tt,oe;re?(tt=$.createEvent("Event"),tt.promise=Ve,tt.reason=Qe,tt.initEvent(Ue,!1,!0),g.dispatchEvent(tt)):tt={promise:Ve,reason:Qe},(oe=g["on"+Ue])?oe(tt):Ue===le&&E("Unhandled promise rejection",Qe)},_e=function(Ue,Ve){n.call(g,function(){var Qe=Ve.value,tt=je(Ve),oe;if(tt&&(oe=D(function(){te?N.emit("unhandledRejection",Qe,Ue):we(le,Ue,Qe)}),Ve.rejection=te||je(Ve)?he:Q,oe.error))throw oe.value})},je=function(Ue){return Ue.rejection!==Q&&!Ue.parent},Ye=function(Ue,Ve){n.call(g,function(){te?N.emit("rejectionHandled",Ue):we(ye,Ue,Ve.value)})},nt=function(Ue,Ve,Qe,tt){return function(oe){Ue(Ve,Qe,oe,tt)}},ut=function(Ue,Ve,Qe,tt){Ve.done||(Ve.done=!0,tt&&(Ve=tt),Ve.value=Qe,Ve.state=J,fe(Ue,Ve,!0))},ot=function(Ue,Ve,Qe,tt){if(!Ve.done){Ve.done=!0,tt&&(Ve=tt);try{if(Ue===Qe)throw W("Promise can't be resolved itself");var oe=Y(Qe);oe?o(function(){var Re={done:!1};try{oe.call(Qe,nt(ot,Ue,Re,Ve),nt(ut,Ue,Re,Ve))}catch(be){ut(Ue,Re,be,Ve)}}):(Ve.value=Qe,Ve.state=ne,fe(Ue,Ve,!1))}catch(Re){ut(Ue,{done:!1},Re,Ve)}}};q&&(U=function(Ve){m(this,U,C),s(Ve),xe.call(this);var Qe=O(this);try{Ve(nt(ot,this,Qe),nt(ut,this,Qe))}catch(tt){ut(this,Qe,tt)}},xe=function(Ve){A(this,{type:C,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:ge,value:void 0})},xe.prototype=v(U.prototype,{then:function(Ve,Qe){var tt=L(this),oe=j(i(this,U));return oe.ok=typeof Ve=="function"?Ve:!0,oe.fail=typeof Qe=="function"&&Qe,oe.domain=te?N.domain:void 0,tt.parent=!0,tt.reactions.push(oe),tt.state!=ge&&fe(this,tt,!1),oe.promise},catch:function(Ue){return this.then(void 0,Ue)}}),ie=function(){var Ue=new xe,Ve=O(Ue);this.promise=Ue,this.resolve=nt(ot,Ue,Ve),this.reject=nt(ut,Ue,Ve)},P.f=j=function(Ue){return Ue===U||Ue===se?new ie(Ue):V(Ue)},!y&&typeof w=="function"&&(Ce=w.prototype.then,f(w.prototype,"then",function(Ve,Qe){var tt=this;return new U(function(oe,Re){Ce.call(tt,oe,Re)}).then(Ve,Qe)},{unsafe:!0}),typeof F=="function"&&u({global:!0,enumerable:!0,forced:!0},{fetch:function(Ve){return p(U,F.apply(g,arguments))}}))),u({global:!0,wrap:!0,forced:q},{Promise:U}),h(U,C,!1,!0),l(C),se=b(C),u({target:C,stat:!0,forced:q},{reject:function(Ve){var Qe=j(this);return Qe.reject.call(void 0,Ve),Qe.promise}}),u({target:C,stat:!0,forced:y||q},{resolve:function(Ve){return p(y&&this===se?U:this,Ve)}}),u({target:C,stat:!0,forced:G},{all:function(Ve){var Qe=this,tt=j(Qe),oe=tt.resolve,Re=tt.reject,be=D(function(){var Ee=s(Qe.resolve),pe=[],Pe=0,ee=1;r(Ve,function(He){var it=Pe++,K=!1;pe.push(void 0),ee++,Ee.call(Qe,He).then(function(Me){K||(K=!0,pe[it]=Me,--ee||oe(pe))},Re)}),--ee||oe(pe)});return be.error&&Re(be.value),tt.promise},race:function(Ve){var Qe=this,tt=j(Qe),oe=tt.reject,Re=D(function(){var be=s(Qe.resolve);r(Ve,function(Ee){be.call(Qe,Ee).then(tt.resolve,oe)})});return Re.error&&oe(Re.value),tt.promise}})},{"../internals/a-function":219,"../internals/an-instance":222,"../internals/check-correctness-of-iteration":229,"../internals/classof-raw":230,"../internals/engine-v8-version":244,"../internals/export":246,"../internals/get-built-in":249,"../internals/global":251,"../internals/host-report-errors":254,"../internals/inspect-source":258,"../internals/internal-state":259,"../internals/is-forced":262,"../internals/is-object":263,"../internals/is-pure":264,"../internals/iterate":266,"../internals/microtask":269,"../internals/native-promise-constructor":270,"../internals/new-promise-capability":273,"../internals/perform":291,"../internals/promise-resolve":292,"../internals/redefine":294,"../internals/redefine-all":293,"../internals/set-species":297,"../internals/set-to-string-tag":298,"../internals/species-constructor":302,"../internals/task":303,"../internals/well-known-symbol":314}],324:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/to-absolute-index"),g=String.fromCharCode,b=String.fromCodePoint,w=!!b&&b.length!=1;u({target:"String",stat:!0,forced:w},{fromCodePoint:function(v){for(var h=[],l=arguments.length,d=0,s;l>d;){if(s=+arguments[d++],y(s,1114111)!==s)throw RangeError(s+" is not a valid code point");h.push(s<65536?g(s):g(((s-=65536)>>10)+55296,s%1024+56320))}return h.join("")}})},{"../internals/export":246,"../internals/to-absolute-index":304}],325:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/not-a-regexp"),g=e("../internals/require-object-coercible"),b=e("../internals/correct-is-regexp-logic");u({target:"String",proto:!0,forced:!b("includes")},{includes:function(f){return!!~String(g(this)).indexOf(y(f),arguments.length>1?arguments[1]:void 0)}})},{"../internals/correct-is-regexp-logic":233,"../internals/export":246,"../internals/not-a-regexp":274,"../internals/require-object-coercible":295}],326:[function(e,S,_){var u=e("../internals/define-well-known-symbol");u("asyncIterator")},{"../internals/define-well-known-symbol":239}],327:[function(e,S,_){var u=e("../internals/export"),y=e("../internals/global"),g=e("../internals/get-built-in"),b=e("../internals/is-pure"),w=e("../internals/descriptors"),f=e("../internals/native-symbol"),v=e("../internals/use-symbol-as-uid"),h=e("../internals/fails"),l=e("../internals/has"),d=e("../internals/is-array"),s=e("../internals/is-object"),m=e("../internals/an-object"),c=e("../internals/to-object"),a=e("../internals/to-indexed-object"),r=e("../internals/to-primitive"),t=e("../internals/create-property-descriptor"),i=e("../internals/object-create"),n=e("../internals/object-keys"),o=e("../internals/object-get-own-property-names"),p=e("../internals/object-get-own-property-names-external"),E=e("../internals/object-get-own-property-symbols"),P=e("../internals/object-get-own-property-descriptor"),D=e("../internals/object-define-property"),z=e("../internals/object-property-is-enumerable"),B=e("../internals/create-non-enumerable-property"),M=e("../internals/redefine"),I=e("../internals/shared"),T=e("../internals/shared-key"),C=e("../internals/hidden-keys"),O=e("../internals/uid"),A=e("../internals/well-known-symbol"),L=e("../internals/well-known-symbol-wrapped"),U=e("../internals/define-well-known-symbol"),W=e("../internals/set-to-string-tag"),$=e("../internals/internal-state"),N=e("../internals/array-iteration").forEach,F=T("hidden"),j="Symbol",V="prototype",te=A("toPrimitive"),re=$.set,le=$.getterFor(j),ye=Object[V],ge=y.Symbol,ne=g("JSON","stringify"),J=P.f,Q=D.f,he=p.f,xe=z.f,ie=I("symbols"),se=I("op-symbols"),Ce=I("string-to-symbol-registry"),q=I("symbol-to-string-registry"),G=I("wks"),Y=y.QObject,fe=!Y||!Y[V]||!Y[V].findChild,we=w&&h(function(){return i(Q({},"a",{get:function(){return Q(this,"a",{value:7}).a}})).a!=7})?function(oe,Re,be){var Ee=J(ye,Re);Ee&&delete ye[Re],Q(oe,Re,be),Ee&&oe!==ye&&Q(ye,Re,Ee)}:Q,_e=function(oe,Re){var be=ie[oe]=i(ge[V]);return re(be,{type:j,tag:oe,description:Re}),w||(be.description=Re),be},je=v?function(oe){return typeof oe=="symbol"}:function(oe){return Object(oe)instanceof ge},Ye=function(Re,be,Ee){Re===ye&&Ye(se,be,Ee),m(Re);var pe=r(be,!0);return m(Ee),l(ie,pe)?(Ee.enumerable?(l(Re,F)&&Re[F][pe]&&(Re[F][pe]=!1),Ee=i(Ee,{enumerable:t(0,!1)})):(l(Re,F)||Q(Re,F,t(1,{})),Re[F][pe]=!0),we(Re,pe,Ee)):Q(Re,pe,Ee)},nt=function(Re,be){m(Re);var Ee=a(be),pe=n(Ee).concat(Qe(Ee));return N(pe,function(Pe){(!w||ot.call(Ee,Pe))&&Ye(Re,Pe,Ee[Pe])}),Re},ut=function(Re,be){return be===void 0?i(Re):nt(i(Re),be)},ot=function(Re){var be=r(Re,!0),Ee=xe.call(this,be);return this===ye&&l(ie,be)&&!l(se,be)?!1:Ee||!l(this,be)||!l(ie,be)||l(this,F)&&this[F][be]?Ee:!0},Ue=function(Re,be){var Ee=a(Re),pe=r(be,!0);if(!(Ee===ye&&l(ie,pe)&&!l(se,pe))){var Pe=J(Ee,pe);return Pe&&l(ie,pe)&&!(l(Ee,F)&&Ee[F][pe])&&(Pe.enumerable=!0),Pe}},Ve=function(Re){var be=he(a(Re)),Ee=[];return N(be,function(pe){!l(ie,pe)&&!l(C,pe)&&Ee.push(pe)}),Ee},Qe=function(Re){var be=Re===ye,Ee=he(be?se:a(Re)),pe=[];return N(Ee,function(Pe){l(ie,Pe)&&(!be||l(ye,Pe))&&pe.push(ie[Pe])}),pe};if(f||(ge=function(){if(this instanceof ge)throw TypeError("Symbol is not a constructor");var Re=!arguments.length||arguments[0]===void 0?void 0:String(arguments[0]),be=O(Re),Ee=function(pe){this===ye&&Ee.call(se,pe),l(this,F)&&l(this[F],be)&&(this[F][be]=!1),we(this,be,t(1,pe))};return w&&fe&&we(ye,be,{configurable:!0,set:Ee}),_e(be,Re)},M(ge[V],"toString",function(){return le(this).tag}),M(ge,"withoutSetter",function(oe){return _e(O(oe),oe)}),z.f=ot,D.f=Ye,P.f=Ue,o.f=p.f=Ve,E.f=Qe,L.f=function(oe){return _e(A(oe),oe)},w&&(Q(ge[V],"description",{configurable:!0,get:function(){return le(this).description}}),b||M(ye,"propertyIsEnumerable",ot,{unsafe:!0}))),u({global:!0,wrap:!0,forced:!f,sham:!f},{Symbol:ge}),N(n(G),function(oe){U(oe)}),u({target:j,stat:!0,forced:!f},{for:function(oe){var Re=String(oe);if(l(Ce,Re))return Ce[Re];var be=ge(Re);return Ce[Re]=be,q[be]=Re,be},keyFor:function(Re){if(!je(Re))throw TypeError(Re+" is not a symbol");if(l(q,Re))return q[Re]},useSetter:function(){fe=!0},useSimple:function(){fe=!1}}),u({target:"Object",stat:!0,forced:!f,sham:!w},{create:ut,defineProperty:Ye,defineProperties:nt,getOwnPropertyDescriptor:Ue}),u({target:"Object",stat:!0,forced:!f},{getOwnPropertyNames:Ve,getOwnPropertySymbols:Qe}),u({target:"Object",stat:!0,forced:h(function(){E.f(1)})},{getOwnPropertySymbols:function(Re){return E.f(c(Re))}}),ne){var tt=!f||h(function(){var oe=ge();return ne([oe])!="[null]"||ne({a:oe})!="{}"||ne(Object(oe))!="{}"});u({target:"JSON",stat:!0,forced:tt},{stringify:function(Re,be,Ee){for(var pe=[Re],Pe=1,ee;arguments.length>Pe;)pe.push(arguments[Pe++]);if(ee=be,!(!s(be)&&Re===void 0||je(Re)))return d(be)||(be=function(He,it){if(typeof ee=="function"&&(it=ee.call(this,He,it)),!je(it))return it}),pe[1]=be,ne.apply(null,pe)}})}ge[V][te]||B(ge[V],te,ge[V].valueOf),W(ge,j),C[F]=!0},{"../internals/an-object":223,"../internals/array-iteration":225,"../internals/create-non-enumerable-property":236,"../internals/create-property-descriptor":237,"../internals/define-well-known-symbol":239,"../internals/descriptors":240,"../internals/export":246,"../internals/fails":247,"../internals/get-built-in":249,"../internals/global":251,"../internals/has":252,"../internals/hidden-keys":253,"../internals/internal-state":259,"../internals/is-array":261,"../internals/is-object":263,"../internals/is-pure":264,"../internals/native-symbol":271,"../internals/object-create":276,"../internals/object-define-property":278,"../internals/object-get-own-property-descriptor":279,"../internals/object-get-own-property-names":281,"../internals/object-get-own-property-names-external":280,"../internals/object-get-own-property-symbols":282,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/redefine":294,"../internals/set-to-string-tag":298,"../internals/shared":301,"../internals/shared-key":299,"../internals/to-indexed-object":305,"../internals/to-object":308,"../internals/to-primitive":309,"../internals/uid":311,"../internals/use-symbol-as-uid":312,"../internals/well-known-symbol":314,"../internals/well-known-symbol-wrapped":313}],328:[function(e,S,_){(function(u){function y(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(p){return typeof p}:y=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},y(n)}function g(n){return Array.isArray?Array.isArray(n):i(n)==="[object Array]"}_.isArray=g;function b(n){return typeof n=="boolean"}_.isBoolean=b;function w(n){return n===null}_.isNull=w;function f(n){return n==null}_.isNullOrUndefined=f;function v(n){return typeof n=="number"}_.isNumber=v;function h(n){return typeof n=="string"}_.isString=h;function l(n){return y(n)==="symbol"}_.isSymbol=l;function d(n){return n===void 0}_.isUndefined=d;function s(n){return i(n)==="[object RegExp]"}_.isRegExp=s;function m(n){return y(n)==="object"&&n!==null}_.isObject=m;function c(n){return i(n)==="[object Date]"}_.isDate=c;function a(n){return i(n)==="[object Error]"||n instanceof Error}_.isError=a;function r(n){return typeof n=="function"}_.isFunction=r;function t(n){return n===null||typeof n=="boolean"||typeof n=="number"||typeof n=="string"||y(n)==="symbol"||typeof n>"u"}_.isPrimitive=t,_.isBuffer=u.isBuffer;function i(n){return Object.prototype.toString.call(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":388}],329:[function(e,S,_){(function(u){var y=e("elliptic"),g=e("bn.js");S.exports=function(h){return new w(h)};var b={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}};b.p224=b.secp224r1,b.p256=b.secp256r1=b.prime256v1,b.p192=b.secp192r1=b.prime192v1,b.p384=b.secp384r1,b.p521=b.secp521r1;function w(v){this.curveType=b[v],this.curveType||(this.curveType={name:v}),this.curve=new y.ec(this.curveType.name),this.keys=void 0}w.prototype.generateKeys=function(v,h){return this.keys=this.curve.genKeyPair(),this.getPublicKey(v,h)},w.prototype.computeSecret=function(v,h,l){h=h||"utf8",u.isBuffer(v)||(v=new u(v,h));var d=this.curve.keyFromPublic(v).getPublic(),s=d.mul(this.keys.getPrivate()).getX();return f(s,l,this.curveType.byteLength)},w.prototype.getPublicKey=function(v,h){var l=this.keys.getPublic(h==="compressed",!0);return h==="hybrid"&&(l[l.length-1]%2?l[0]=7:l[0]=6),f(l,v)},w.prototype.getPrivateKey=function(v){return f(this.keys.getPrivate(),v)},w.prototype.setPublicKey=function(v,h){return h=h||"utf8",u.isBuffer(v)||(v=new u(v,h)),this.keys._importPublic(v),this},w.prototype.setPrivateKey=function(v,h){h=h||"utf8",u.isBuffer(v)||(v=new u(v,h));var l=new g(v);return l=l.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(l),this};function f(v,h,l){Array.isArray(v)||(v=v.toArray());var d=new u(v);if(l&&d.lengthm){var c=d==="rmd160"?new f:v(d);s=c.update(s).digest()}else s.lengthw?h=v(h):h.length"u"?"undefined":u(_))=="object"&&typeof S<"u"?S.exports=g():y.dayjs=g()})(void 0,function(){var y="millisecond",g="second",b="minute",w="hour",f="day",v="week",h="month",l="quarter",d="year",s="date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d+)?$/,c=/\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,a=function(M,I,T){var C=String(M);return!C||C.length>=I?M:""+Array(I+1-C.length).join(T)+M},r={s:a,z:function(M){var I=-M.utcOffset(),T=Math.abs(I),C=Math.floor(T/60),O=T%60;return(I<=0?"+":"-")+a(C,2,"0")+":"+a(O,2,"0")},m:function B(M,I){if(M.date()"u"?"undefined":u(_))=="object"&&typeof S<"u"?S.exports=g():y.dayjs_plugin_customParseFormat=g()})(void 0,function(){var y,g=/(\[[^[]*\])|([-:/.()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,b=/\d\d/,w=/\d\d?/,f=/\d*[^\s\d-:/()]+/,v=function(c){return function(a){this[c]=+a}},h=[/[+-]\d\d:?\d\d/,function(m){var c,a;(this.zone||(this.zone={})).offset=(c=m.match(/([+-]|\d\d)/g),(a=60*c[1]+ +c[2])===0?0:c[0]==="+"?-a:a)}],l=function(c){var a=y[c];return a&&(a.indexOf?a:a.s.concat(a.f))},d={A:[/[AP]M/,function(m){this.afternoon=m==="PM"}],a:[/[ap]m/,function(m){this.afternoon=m==="pm"}],S:[/\d/,function(m){this.milliseconds=100*+m}],SS:[b,function(m){this.milliseconds=10*+m}],SSS:[/\d{3}/,function(m){this.milliseconds=+m}],s:[w,v("seconds")],ss:[w,v("seconds")],m:[w,v("minutes")],mm:[w,v("minutes")],H:[w,v("hours")],h:[w,v("hours")],HH:[w,v("hours")],hh:[w,v("hours")],D:[w,v("day")],DD:[b,v("day")],Do:[f,function(m){var c=y.ordinal,a=m.match(/\d+/);if(this.day=a[0],c)for(var r=1;r<=31;r+=1)c(r).replace(/\[|\]/g,"")===m&&(this.day=r)}],M:[w,v("month")],MM:[b,v("month")],MMM:[f,function(m){var c=l("months"),a=(l("monthsShort")||c.map(function(r){return r.substr(0,3)})).indexOf(m)+1;if(a<1)throw new Error;this.month=a%12||a}],MMMM:[f,function(m){var c=l("months").indexOf(m)+1;if(c<1)throw new Error;this.month=c%12||c}],Y:[/[+-]?\d+/,v("year")],YY:[b,function(m){m=+m,this.year=m+(m>68?1900:2e3)}],YYYY:[/\d{4}/,v("year")],Z:h,ZZ:h},s=function(c,a,r){try{var t=function(U){for(var W=U.match(g),$=W.length,N=0;N<$;N+=1){var F=W[N],j=d[F],V=j&&j[0],te=j&&j[1];W[N]=te?{regex:V,parser:te}:F.replace(/^\[|\]$/g,"")}return function(re){for(var le={},ye=0,ge=0;ye<$;ye+=1){var ne=W[ye];if(typeof ne=="string")ge+=ne.length;else{var J=ne.regex,Q=ne.parser,he=re.substr(ge),xe=J.exec(he)[0];Q.call(le,xe),re=re.replace(xe,"")}}return function(ie){var se=ie.afternoon;if(se!==void 0){var Ce=ie.hours;se?Ce<12&&(ie.hours+=12):Ce===12&&(ie.hours=0),delete ie.afternoon}}(le),le}}(a)(c),i=t.year,n=t.month,o=t.day,p=t.hours,E=t.minutes,P=t.seconds,D=t.milliseconds,z=t.zone,B=new Date,M=o||(i||n?1:B.getDate()),I=i||B.getFullYear(),T=0;i&&!n||(T=n>0?n-1:B.getMonth());var C=p||0,O=E||0,A=P||0,L=D||0;return z?new Date(Date.UTC(I,T,M,C,O,A,L+60*z.offset*1e3)):r?new Date(Date.UTC(I,T,M,C,O,A,L)):new Date(I,T,M,C,O,A,L)}catch{return new Date("")}};return function(m,c,a){var r=c.prototype,t=r.parse;r.parse=function(i){var n=i.date,o=i.utc,p=i.args;this.$u=o;var E=p[1];if(typeof E=="string"){var P=p[2]===!0,D=p[3]===!0,z=P||D,B=p[2];D&&(B=p[2]),P||(y=B?a.Ls[B]:this.$locale()),this.$d=s(n,E,o),this.init(),B&&B!==!0&&(this.$L=this.locale(B).$L),z&&n!==this.format(E)&&(this.$d=new Date(""))}else if(E instanceof Array)for(var M=E.length,I=1;I<=M;I+=1){p[1]=E[I-1];var T=a.apply(this,p);if(T.isValid()){this.$d=T.$d,this.$L=T.$L,this.init();break}I===M&&(this.$d=new Date(""))}else t.call(this,i)}}})},{}],338:[function(e,S,_){function u(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(b){return typeof b}:u=function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},u(y)}(function(y,g){(typeof _>"u"?"undefined":u(_))=="object"&&typeof S<"u"?S.exports=g():y.dayjs_plugin_utc=g()})(void 0,function(){return function(y,g,b){var w=new Date().getTimezoneOffset(),f=g.prototype;b.utc=function(c){return new g({date:c,utc:!0,args:arguments})},f.utc=function(){return b(this.toDate(),{locale:this.$L,utc:!0})},f.local=function(){return b(this.toDate(),{locale:this.$L,utc:!1})};var v=f.parse;f.parse=function(c){c.utc&&(this.$u=!0),this.$utils().u(c.$offset)||(this.$offset=c.$offset),v.call(this,c)};var h=f.init;f.init=function(){if(this.$u){var c=this.$d;this.$y=c.getUTCFullYear(),this.$M=c.getUTCMonth(),this.$D=c.getUTCDate(),this.$W=c.getUTCDay(),this.$H=c.getUTCHours(),this.$m=c.getUTCMinutes(),this.$s=c.getUTCSeconds(),this.$ms=c.getUTCMilliseconds()}else h.call(this)};var l=f.utcOffset;f.utcOffset=function(c,a){var r=this.$utils().u;if(r(c))return this.$u?0:r(this.$offset)?l.call(this):this.$offset;var t=Math.abs(c)<=16?60*c:c,i=this;return a?(i.$offset=t,i.$u=c===0,i):(c!==0?(i=this.local().add(t+w,"minute")).$offset=t:i=this.utc(),i)};var d=f.format;f.format=function(c){var a=c||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,a)},f.valueOf=function(){var c=this.$utils().u(this.$offset)?0:this.$offset+w;return this.$d.valueOf()-6e4*c},f.isUTC=function(){return!!this.$u},f.toISOString=function(){return this.toDate().toISOString()},f.toString=function(){return this.toDate().toUTCString()};var s=f.toDate;f.toDate=function(c){return c==="s"&&this.$offset?b(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():s.call(this)};var m=f.diff;f.diff=function(c,a,r){var t=this.local(),i=b(c).local();return m.call(t,i,a,r)}}})},{}],339:[function(e,S,_){_.utils=e("./des/utils"),_.Cipher=e("./des/cipher"),_.DES=e("./des/des"),_.CBC=e("./des/cbc"),_.EDE=e("./des/ede")},{"./des/cbc":340,"./des/cipher":341,"./des/des":342,"./des/ede":343,"./des/utils":344}],340:[function(e,S,_){var u=e("minimalistic-assert"),y=e("inherits"),g={};function b(f){u.equal(f.length,8,"Invalid IV length"),this.iv=new Array(8);for(var v=0;v0;v--)w+=this._buffer(b,w),f+=this._flushBuffer(h,f);return w+=this._buffer(b,w),h},y.prototype.final=function(b){var w;b&&(w=this.update(b));var f;return this.type==="encrypt"?f=this._finalEncrypt():f=this._finalDecrypt(),w?w.concat(f):f},y.prototype._pad=function(b,w){if(w===0)return!1;for(;w>>1];s=g.r28shl(s,a),m=g.r28shl(m,a),g.pc2(s,m,l.keys,c)}},f.prototype._update=function(l,d,s,m){var c=this._desState,a=g.readUInt32BE(l,d),r=g.readUInt32BE(l,d+4);g.ip(a,r,c.tmp,0),a=c.tmp[0],r=c.tmp[1],this.type==="encrypt"?this._encrypt(c,a,r,c.tmp,0):this._decrypt(c,a,r,c.tmp,0),a=c.tmp[0],r=c.tmp[1],g.writeUInt32BE(s,a,m),g.writeUInt32BE(s,r,m+4)},f.prototype._pad=function(l,d){for(var s=l.length-d,m=d;m>>0,a=E}g.rip(r,a,m,c)},f.prototype._decrypt=function(l,d,s,m,c){for(var a=s,r=d,t=l.keys.length-2;t>=0;t-=2){var i=l.keys[t],n=l.keys[t+1];g.expand(a,l.tmp,0),i^=l.tmp[0],n^=l.tmp[1];var o=g.substitute(i,n),p=g.permute(o),E=a;a=(r^p)>>>0,r=E}g.rip(a,r,m,c)}},{"./cipher":341,"./utils":344,inherits:387,"minimalistic-assert":437}],343:[function(e,S,_){var u=e("minimalistic-assert"),y=e("inherits"),g=e("./cipher"),b=e("./des");function w(v,h){u.equal(h.length,24,"Invalid key length");var l=h.slice(0,8),d=h.slice(8,16),s=h.slice(16,24);v==="encrypt"?this.ciphers=[b.create({type:"encrypt",key:l}),b.create({type:"decrypt",key:d}),b.create({type:"encrypt",key:s})]:this.ciphers=[b.create({type:"decrypt",key:s}),b.create({type:"encrypt",key:d}),b.create({type:"decrypt",key:l})]}function f(v){g.call(this,v);var h=new w(this.type,this.options.key);this._edeState=h}y(f,g),S.exports=f,f.create=function(h){return new f(h)},f.prototype._update=function(h,l,d,s){var m=this._edeState;m.ciphers[0]._update(h,l,d,s),m.ciphers[1]._update(d,s,d,s),m.ciphers[2]._update(d,s,d,s)},f.prototype._pad=b.prototype._pad,f.prototype._unpad=b.prototype._unpad},{"./cipher":341,"./des":342,inherits:387,"minimalistic-assert":437}],344:[function(e,S,_){_.readUInt32BE=function(w,f){var v=w[0+f]<<24|w[1+f]<<16|w[2+f]<<8|w[3+f];return v>>>0},_.writeUInt32BE=function(w,f,v){w[0+v]=f>>>24,w[1+v]=f>>>16&255,w[2+v]=f>>>8&255,w[3+v]=f&255},_.ip=function(w,f,v,h){for(var l=0,d=0,s=6;s>=0;s-=2){for(var m=0;m<=24;m+=8)l<<=1,l|=f>>>m+s&1;for(var m=0;m<=24;m+=8)l<<=1,l|=w>>>m+s&1}for(var s=6;s>=0;s-=2){for(var m=1;m<=25;m+=8)d<<=1,d|=f>>>m+s&1;for(var m=1;m<=25;m+=8)d<<=1,d|=w>>>m+s&1}v[h+0]=l>>>0,v[h+1]=d>>>0},_.rip=function(w,f,v,h){for(var l=0,d=0,s=0;s<4;s++)for(var m=24;m>=0;m-=8)l<<=1,l|=f>>>m+s&1,l<<=1,l|=w>>>m+s&1;for(var s=4;s<8;s++)for(var m=24;m>=0;m-=8)d<<=1,d|=f>>>m+s&1,d<<=1,d|=w>>>m+s&1;v[h+0]=l>>>0,v[h+1]=d>>>0},_.pc1=function(w,f,v,h){for(var l=0,d=0,s=7;s>=5;s--){for(var m=0;m<=24;m+=8)l<<=1,l|=f>>m+s&1;for(var m=0;m<=24;m+=8)l<<=1,l|=w>>m+s&1}for(var m=0;m<=24;m+=8)l<<=1,l|=f>>m+s&1;for(var s=1;s<=3;s++){for(var m=0;m<=24;m+=8)d<<=1,d|=f>>m+s&1;for(var m=0;m<=24;m+=8)d<<=1,d|=w>>m+s&1}for(var m=0;m<=24;m+=8)d<<=1,d|=w>>m+s&1;v[h+0]=l>>>0,v[h+1]=d>>>0},_.r28shl=function(w,f){return w<>>28-f};var u=[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];_.pc2=function(w,f,v,h){for(var l=0,d=0,s=u.length>>>1,m=0;m>>u[m]&1;for(var m=s;m>>u[m]&1;v[h+0]=l>>>0,v[h+1]=d>>>0},_.expand=function(w,f,v){var h=0,l=0;h=(w&1)<<5|w>>>27;for(var d=23;d>=15;d-=4)h<<=6,h|=w>>>d&63;for(var d=11;d>=3;d-=4)l|=w>>>d&63,l<<=6;l|=(w&31)<<1|w>>>31,f[v+0]=h>>>0,f[v+1]=l>>>0};var y=[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];_.substitute=function(w,f){for(var v=0,h=0;h<4;h++){var l=w>>>18-h*6&63,d=y[h*64+l];v<<=4,v|=d}for(var h=0;h<4;h++){var l=f>>>18-h*6&63,d=y[4*64+h*64+l];v<<=4,v|=d}return v>>>0};var g=[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];_.permute=function(w){for(var f=0,v=0;v>>g[v]&1;return f>>>0},_.padSplit=function(w,f,v){for(var h=w.toString(2);h.lengthn;)p.ishrn(1);if(p.isEven()&&p.iadd(f),p.testn(1)||p.iadd(v),o.cmp(v)){if(!o.cmp(h))for(;p.mod(l).cmp(d);)p.iadd(m)}else for(;p.mod(g).cmp(s);)p.iadd(m);if(E=p.shrn(1),r(E)&&r(p)&&t(E)&&t(p)&&w.test(E)&&w.test(p))return p}}},{"bn.js":349,"miller-rabin":435,randombytes:475}],348:[function(e,S,_){S.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"}}},{}],349:[function(e,S,_){arguments[4][181][0].apply(_,arguments)},{buffer:185,dup:181}],350:[function(e,S,_){var u=_;u.version=e("../package.json").version,u.utils=e("./elliptic/utils"),u.rand=e("brorand"),u.curve=e("./elliptic/curve"),u.curves=e("./elliptic/curves"),u.ec=e("./elliptic/ec"),u.eddsa=e("./elliptic/eddsa")},{"../package.json":366,"./elliptic/curve":353,"./elliptic/curves":356,"./elliptic/ec":357,"./elliptic/eddsa":360,"./elliptic/utils":364,brorand:184}],351:[function(e,S,_){var u=e("bn.js"),y=e("../utils"),g=y.getNAF,b=y.getJSF,w=y.assert;function f(h,l){this.type=h,this.p=new u(l.p,16),this.red=l.prime?u.red(l.prime):u.mont(this.p),this.zero=new u(0).toRed(this.red),this.one=new u(1).toRed(this.red),this.two=new u(2).toRed(this.red),this.n=l.n&&new u(l.n,16),this.g=l.g&&this.pointFromJSON(l.g,l.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 d=this.n&&this.p.div(this.n);!d||d.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}S.exports=f,f.prototype.point=function(){throw new Error("Not implemented")},f.prototype.validate=function(){throw new Error("Not implemented")},f.prototype._fixedNafMul=function(l,d){w(l.precomputed);var s=l._getDoubles(),m=g(d,1,this._bitLength),c=(1<=r;d--)t=(t<<1)+m[d];a.push(t)}for(var i=this.jpoint(null,null,null),n=this.jpoint(null,null,null),o=c;o>0;o--){for(var r=0;r=0;t--){for(var d=0;t>=0&&a[t]===0;t--)d++;if(t>=0&&d++,r=r.dblp(d),t<0)break;var i=a[t];w(i!==0),l.type==="affine"?i>0?r=r.mixedAdd(c[i-1>>1]):r=r.mixedAdd(c[-i-1>>1].neg()):i>0?r=r.add(c[i-1>>1]):r=r.add(c[-i-1>>1].neg())}return l.type==="affine"?r.toP():r},f.prototype._wnafMulAdd=function(l,d,s,m,c){for(var a=this._wnafT1,r=this._wnafT2,t=this._wnafT3,i=0,n=0;n=1;n-=2){var E=n-1,P=n;if(a[E]!==1||a[P]!==1){t[E]=g(s[E],a[E],this._bitLength),t[P]=g(s[P],a[P],this._bitLength),i=Math.max(t[E].length,i),i=Math.max(t[P].length,i);continue}var D=[d[E],null,null,d[P]];d[E].y.cmp(d[P].y)===0?(D[1]=d[E].add(d[P]),D[2]=d[E].toJ().mixedAdd(d[P].neg())):d[E].y.cmp(d[P].y.redNeg())===0?(D[1]=d[E].toJ().mixedAdd(d[P]),D[2]=d[E].add(d[P].neg())):(D[1]=d[E].toJ().mixedAdd(d[P]),D[2]=d[E].toJ().mixedAdd(d[P].neg()));var z=[-3,-1,-5,-7,0,7,5,1,3],B=b(s[E],s[P]);i=Math.max(B[0].length,i),t[E]=new Array(i),t[P]=new Array(i);for(var M=0;M=0;n--){for(var A=0;n>=0;){for(var L=!0,M=0;M=0&&A++,C=C.dblp(A),n<0)break;for(var M=0;M0?o=r[M][U-1>>1]:U<0&&(o=r[M][-U-1>>1].neg()),o.type==="affine"?C=C.mixedAdd(o):C=C.add(o))}}for(var n=0;n=Math.ceil((l.bitLength()+1)/d.step):!1},v.prototype._getDoubles=function(l,d){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var s=[this],m=this,c=0;c":""},v.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},v.prototype._extDbl=function(){var l=this.x.redSqr(),d=this.y.redSqr(),s=this.z.redSqr();s=s.redIAdd(s);var m=this.curve._mulA(l),c=this.x.redAdd(this.y).redSqr().redISub(l).redISub(d),a=m.redAdd(d),r=a.redSub(s),t=m.redSub(d),i=c.redMul(r),n=a.redMul(t),o=c.redMul(t),p=r.redMul(a);return this.curve.point(i,n,p,o)},v.prototype._projDbl=function(){var l=this.x.redAdd(this.y).redSqr(),d=this.x.redSqr(),s=this.y.redSqr(),m,c,a;if(this.curve.twisted){var r=this.curve._mulA(d),t=r.redAdd(s);if(this.zOne)m=l.redSub(d).redSub(s).redMul(t.redSub(this.curve.two)),c=t.redMul(r.redSub(s)),a=t.redSqr().redSub(t).redSub(t);else{var i=this.z.redSqr(),n=t.redSub(i).redISub(i);m=l.redSub(d).redISub(s).redMul(n),c=t.redMul(r.redSub(s)),a=t.redMul(n)}}else{var r=d.redAdd(s),i=this.curve._mulC(this.z).redSqr(),n=r.redSub(i).redSub(i);m=this.curve._mulC(l.redISub(r)).redMul(n),c=this.curve._mulC(r).redMul(d.redISub(s)),a=r.redMul(n)}return this.curve.point(m,c,a)},v.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},v.prototype._extAdd=function(l){var d=this.y.redSub(this.x).redMul(l.y.redSub(l.x)),s=this.y.redAdd(this.x).redMul(l.y.redAdd(l.x)),m=this.t.redMul(this.curve.dd).redMul(l.t),c=this.z.redMul(l.z.redAdd(l.z)),a=s.redSub(d),r=c.redSub(m),t=c.redAdd(m),i=s.redAdd(d),n=a.redMul(r),o=t.redMul(i),p=a.redMul(i),E=r.redMul(t);return this.curve.point(n,o,E,p)},v.prototype._projAdd=function(l){var d=this.z.redMul(l.z),s=d.redSqr(),m=this.x.redMul(l.x),c=this.y.redMul(l.y),a=this.curve.d.redMul(m).redMul(c),r=s.redSub(a),t=s.redAdd(a),i=this.x.redAdd(this.y).redMul(l.x.redAdd(l.y)).redISub(m).redISub(c),n=d.redMul(r).redMul(i),o,p;return this.curve.twisted?(o=d.redMul(t).redMul(c.redSub(this.curve._mulA(m))),p=r.redMul(t)):(o=d.redMul(t).redMul(c.redSub(m)),p=this.curve._mulC(r).redMul(t)),this.curve.point(n,o,p)},v.prototype.add=function(l){return this.isInfinity()?l:l.isInfinity()?this:this.curve.extended?this._extAdd(l):this._projAdd(l)},v.prototype.mul=function(l){return this._hasDoubles(l)?this.curve._fixedNafMul(this,l):this.curve._wnafMul(this,l)},v.prototype.mulAdd=function(l,d,s){return this.curve._wnafMulAdd(1,[this,d],[l,s],2,!1)},v.prototype.jmulAdd=function(l,d,s){return this.curve._wnafMulAdd(1,[this,d],[l,s],2,!0)},v.prototype.normalize=function(){if(this.zOne)return this;var l=this.z.redInvm();return this.x=this.x.redMul(l),this.y=this.y.redMul(l),this.t&&(this.t=this.t.redMul(l)),this.z=this.curve.one,this.zOne=!0,this},v.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},v.prototype.getX=function(){return this.normalize(),this.x.fromRed()},v.prototype.getY=function(){return this.normalize(),this.y.fromRed()},v.prototype.eq=function(l){return this===l||this.getX().cmp(l.getX())===0&&this.getY().cmp(l.getY())===0},v.prototype.eqXToP=function(l){var d=l.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(d)===0)return!0;for(var s=l.clone(),m=this.curve.redN.redMul(this.z);;){if(s.iadd(this.curve.n),s.cmp(this.curve.p)>=0)return!1;if(d.redIAdd(m),this.x.cmp(d)===0)return!0}},v.prototype.toP=v.prototype.normalize,v.prototype.mixedAdd=v.prototype.add},{"../utils":364,"./base":351,"bn.js":365,inherits:387}],353:[function(e,S,_){var u=_;u.base=e("./base"),u.short=e("./short"),u.mont=e("./mont"),u.edwards=e("./edwards")},{"./base":351,"./edwards":352,"./mont":354,"./short":355}],354:[function(e,S,_){var u=e("bn.js"),y=e("inherits"),g=e("./base"),b=e("../utils");function w(v){g.call(this,"mont",v),this.a=new u(v.a,16).toRed(this.red),this.b=new u(v.b,16).toRed(this.red),this.i4=new u(4).toRed(this.red).redInvm(),this.two=new u(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}y(w,g),S.exports=w,w.prototype.validate=function(h){var l=h.normalize().x,d=l.redSqr(),s=d.redMul(l).redAdd(d.redMul(this.a)).redAdd(l),m=s.redSqrt();return m.redSqr().cmp(s)===0};function f(v,h,l){g.BasePoint.call(this,v,"projective"),h===null&&l===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new u(h,16),this.z=new u(l,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}y(f,g.BasePoint),w.prototype.decodePoint=function(h,l){return this.point(b.toArray(h,l),1)},w.prototype.point=function(h,l){return new f(this,h,l)},w.prototype.pointFromJSON=function(h){return f.fromJSON(this,h)},f.prototype.precompute=function(){},f.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},f.fromJSON=function(h,l){return new f(h,l[0],l[1]||h.one)},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return this.z.cmpn(0)===0},f.prototype.dbl=function(){var h=this.x.redAdd(this.z),l=h.redSqr(),d=this.x.redSub(this.z),s=d.redSqr(),m=l.redSub(s),c=l.redMul(s),a=m.redMul(s.redAdd(this.curve.a24.redMul(m)));return this.curve.point(c,a)},f.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.diffAdd=function(h,l){var d=this.x.redAdd(this.z),s=this.x.redSub(this.z),m=h.x.redAdd(h.z),c=h.x.redSub(h.z),a=c.redMul(d),r=m.redMul(s),t=l.z.redMul(a.redAdd(r).redSqr()),i=l.x.redMul(a.redISub(r).redSqr());return this.curve.point(t,i)},f.prototype.mul=function(h){for(var l=h.clone(),d=this,s=this.curve.point(null,null),m=this,c=[];l.cmpn(0)!==0;l.iushrn(1))c.push(l.andln(1));for(var a=c.length-1;a>=0;a--)c[a]===0?(d=d.diffAdd(s,m),s=s.dbl()):(s=d.diffAdd(s,m),d=d.dbl());return s},f.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.eq=function(h){return this.getX().cmp(h.getX())===0},f.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":364,"./base":351,"bn.js":365,inherits:387}],355:[function(e,S,_){var u=e("../utils"),y=e("bn.js"),g=e("inherits"),b=e("./base"),w=u.assert;function f(l){b.call(this,"short",l),this.a=new y(l.a,16).toRed(this.red),this.b=new y(l.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(l),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}g(f,b),S.exports=f,f.prototype._getEndomorphism=function(d){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var s,m;if(d.beta)s=new y(d.beta,16).toRed(this.red);else{var c=this._getEndoRoots(this.p);s=c[0].cmp(c[1])<0?c[0]:c[1],s=s.toRed(this.red)}if(d.lambda)m=new y(d.lambda,16);else{var a=this._getEndoRoots(this.n);this.g.mul(a[0]).x.cmp(this.g.x.redMul(s))===0?m=a[0]:(m=a[1],w(this.g.mul(m).x.cmp(this.g.x.redMul(s))===0))}var r;return d.basis?r=d.basis.map(function(t){return{a:new y(t.a,16),b:new y(t.b,16)}}):r=this._getEndoBasis(m),{beta:s,lambda:m,basis:r}}},f.prototype._getEndoRoots=function(d){var s=d===this.p?this.red:y.mont(d),m=new y(2).toRed(s).redInvm(),c=m.redNeg(),a=new y(3).toRed(s).redNeg().redSqrt().redMul(m),r=c.redAdd(a).fromRed(),t=c.redSub(a).fromRed();return[r,t]},f.prototype._getEndoBasis=function(d){for(var s=this.n.ushrn(Math.floor(this.n.bitLength()/2)),m=d,c=this.n.clone(),a=new y(1),r=new y(0),t=new y(0),i=new y(1),n,o,p,E,P,D,z,B=0,M,I;m.cmpn(0)!==0;){var T=c.div(m);M=c.sub(T.mul(m)),I=t.sub(T.mul(a));var C=i.sub(T.mul(r));if(!p&&M.cmp(s)<0)n=z.neg(),o=a,p=M.neg(),E=I;else if(p&&++B===2)break;z=M,c=m,m=M,t=a,a=I,i=r,r=C}P=M.neg(),D=I;var O=p.sqr().add(E.sqr()),A=P.sqr().add(D.sqr());return A.cmp(O)>=0&&(P=n,D=o),p.negative&&(p=p.neg(),E=E.neg()),P.negative&&(P=P.neg(),D=D.neg()),[{a:p,b:E},{a:P,b:D}]},f.prototype._endoSplit=function(d){var s=this.endo.basis,m=s[0],c=s[1],a=c.b.mul(d).divRound(this.n),r=m.b.neg().mul(d).divRound(this.n),t=a.mul(m.a),i=r.mul(c.a),n=a.mul(m.b),o=r.mul(c.b),p=d.sub(t).sub(i),E=n.add(o).neg();return{k1:p,k2:E}},f.prototype.pointFromX=function(d,s){d=new y(d,16),d.red||(d=d.toRed(this.red));var m=d.redSqr().redMul(d).redIAdd(d.redMul(this.a)).redIAdd(this.b),c=m.redSqrt();if(c.redSqr().redSub(m).cmp(this.zero)!==0)throw new Error("invalid point");var a=c.fromRed().isOdd();return(s&&!a||!s&&a)&&(c=c.redNeg()),this.point(d,c)},f.prototype.validate=function(d){if(d.inf)return!0;var s=d.x,m=d.y,c=this.a.redMul(s),a=s.redSqr().redMul(s).redIAdd(c).redIAdd(this.b);return m.redSqr().redISub(a).cmpn(0)===0},f.prototype._endoWnafMulAdd=function(d,s,m){for(var c=this._endoWnafT1,a=this._endoWnafT2,r=0;r":""},v.prototype.isInfinity=function(){return this.inf},v.prototype.add=function(d){if(this.inf)return d;if(d.inf)return this;if(this.eq(d))return this.dbl();if(this.neg().eq(d))return this.curve.point(null,null);if(this.x.cmp(d.x)===0)return this.curve.point(null,null);var s=this.y.redSub(d.y);s.cmpn(0)!==0&&(s=s.redMul(this.x.redSub(d.x).redInvm()));var m=s.redSqr().redISub(this.x).redISub(d.x),c=s.redMul(this.x.redSub(m)).redISub(this.y);return this.curve.point(m,c)},v.prototype.dbl=function(){if(this.inf)return this;var d=this.y.redAdd(this.y);if(d.cmpn(0)===0)return this.curve.point(null,null);var s=this.curve.a,m=this.x.redSqr(),c=d.redInvm(),a=m.redAdd(m).redIAdd(m).redIAdd(s).redMul(c),r=a.redSqr().redISub(this.x.redAdd(this.x)),t=a.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,t)},v.prototype.getX=function(){return this.x.fromRed()},v.prototype.getY=function(){return this.y.fromRed()},v.prototype.mul=function(d){return d=new y(d,16),this.isInfinity()?this:this._hasDoubles(d)?this.curve._fixedNafMul(this,d):this.curve.endo?this.curve._endoWnafMulAdd([this],[d]):this.curve._wnafMul(this,d)},v.prototype.mulAdd=function(d,s,m){var c=[this,s],a=[d,m];return this.curve.endo?this.curve._endoWnafMulAdd(c,a):this.curve._wnafMulAdd(1,c,a,2)},v.prototype.jmulAdd=function(d,s,m){var c=[this,s],a=[d,m];return this.curve.endo?this.curve._endoWnafMulAdd(c,a,!0):this.curve._wnafMulAdd(1,c,a,2,!0)},v.prototype.eq=function(d){return this===d||this.inf===d.inf&&(this.inf||this.x.cmp(d.x)===0&&this.y.cmp(d.y)===0)},v.prototype.neg=function(d){if(this.inf)return this;var s=this.curve.point(this.x,this.y.redNeg());if(d&&this.precomputed){var m=this.precomputed,c=function(r){return r.neg()};s.precomputed={naf:m.naf&&{wnd:m.naf.wnd,points:m.naf.points.map(c)},doubles:m.doubles&&{step:m.doubles.step,points:m.doubles.points.map(c)}}}return s},v.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var d=this.curve.jpoint(this.x,this.y,this.curve.one);return d};function h(l,d,s,m){b.BasePoint.call(this,l,"jacobian"),d===null&&s===null&&m===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new y(0)):(this.x=new y(d,16),this.y=new y(s,16),this.z=new y(m,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}g(h,b.BasePoint),f.prototype.jpoint=function(d,s,m){return new h(this,d,s,m)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var d=this.z.redInvm(),s=d.redSqr(),m=this.x.redMul(s),c=this.y.redMul(s).redMul(d);return this.curve.point(m,c)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(d){if(this.isInfinity())return d;if(d.isInfinity())return this;var s=d.z.redSqr(),m=this.z.redSqr(),c=this.x.redMul(s),a=d.x.redMul(m),r=this.y.redMul(s.redMul(d.z)),t=d.y.redMul(m.redMul(this.z)),i=c.redSub(a),n=r.redSub(t);if(i.cmpn(0)===0)return n.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var o=i.redSqr(),p=o.redMul(i),E=c.redMul(o),P=n.redSqr().redIAdd(p).redISub(E).redISub(E),D=n.redMul(E.redISub(P)).redISub(r.redMul(p)),z=this.z.redMul(d.z).redMul(i);return this.curve.jpoint(P,D,z)},h.prototype.mixedAdd=function(d){if(this.isInfinity())return d.toJ();if(d.isInfinity())return this;var s=this.z.redSqr(),m=this.x,c=d.x.redMul(s),a=this.y,r=d.y.redMul(s).redMul(this.z),t=m.redSub(c),i=a.redSub(r);if(t.cmpn(0)===0)return i.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var n=t.redSqr(),o=n.redMul(t),p=m.redMul(n),E=i.redSqr().redIAdd(o).redISub(p).redISub(p),P=i.redMul(p.redISub(E)).redISub(a.redMul(o)),D=this.z.redMul(t);return this.curve.jpoint(E,P,D)},h.prototype.dblp=function(d){if(d===0)return this;if(this.isInfinity())return this;if(!d)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var s=this,m=0;m=0)return!1;if(m.redIAdd(a),this.x.cmp(m)===0)return!0}},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return this.z.cmpn(0)===0}},{"../utils":364,"./base":351,"bn.js":365,inherits:387}],356:[function(e,S,_){var u=_,y=e("hash.js"),g=e("./curve"),b=e("./utils"),w=b.assert;function f(l){l.type==="short"?this.curve=new g.short(l):l.type==="edwards"?this.curve=new g.edwards(l):this.curve=new g.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,w(this.g.validate(),"Invalid curve"),w(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}u.PresetCurve=f;function v(l,d){Object.defineProperty(u,l,{configurable:!0,enumerable:!0,get:function(){var m=new f(d);return Object.defineProperty(u,l,{configurable:!0,enumerable:!0,value:m}),m}})}v("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:y.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),v("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:y.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),v("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:y.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),v("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:y.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"]}),v("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:y.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"]}),v("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:y.sha256,gRed:!1,g:["9"]}),v("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:y.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var h;try{h=e("./precomputed/secp256k1")}catch{h=void 0}v("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:y.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",h]})},{"./curve":353,"./precomputed/secp256k1":363,"./utils":364,"hash.js":372}],357:[function(e,S,_){function u(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(c){return typeof c}:u=function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},u(s)}var y=e("bn.js"),g=e("hmac-drbg"),b=e("../utils"),w=e("../curves"),f=e("brorand"),v=b.assert,h=e("./key"),l=e("./signature");function d(s){if(!(this instanceof d))return new d(s);typeof s=="string"&&(v(w.hasOwnProperty(s),"Unknown curve "+s),s=w[s]),s instanceof w.PresetCurve&&(s={curve:s}),this.curve=s.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=s.curve.g,this.g.precompute(s.curve.n.bitLength()+1),this.hash=s.hash||s.curve.hash}S.exports=d,d.prototype.keyPair=function(m){return new h(this,m)},d.prototype.keyFromPrivate=function(m,c){return h.fromPrivate(this,m,c)},d.prototype.keyFromPublic=function(m,c){return h.fromPublic(this,m,c)},d.prototype.genKeyPair=function(m){m||(m={});var c=new g({hash:this.hash,pers:m.pers,persEnc:m.persEnc||"utf8",entropy:m.entropy||f(this.hash.hmacStrength),entropyEnc:m.entropy&&m.entropyEnc||"utf8",nonce:this.n.toArray()}),a=this.n.byteLength(),r=this.n.sub(new y(2));do{var t=new y(c.generate(a));if(!(t.cmp(r)>0))return t.iaddn(1),this.keyFromPrivate(t)}while(!0)},d.prototype._truncateToN=function(m,c){var a=m.byteLength()*8-this.n.bitLength();return a>0&&(m=m.ushrn(a)),!c&&m.cmp(this.n)>=0?m.sub(this.n):m},d.prototype.sign=function(m,c,a,r){u(a)==="object"&&(r=a,a=null),r||(r={}),c=this.keyFromPrivate(c,a),m=this._truncateToN(new y(m,16));for(var t=this.n.byteLength(),i=c.getPrivate().toArray("be",t),n=m.toArray("be",t),o=new g({hash:this.hash,entropy:i,nonce:n,pers:r.pers,persEnc:r.persEnc||"utf8"}),p=this.n.sub(new y(1)),E=0;;E++){var P=r.k?r.k(E):new y(o.generate(this.n.byteLength()));if(P=this._truncateToN(P,!0),!(P.cmpn(1)<=0||P.cmp(p)>=0)){var D=this.g.mul(P);if(!D.isInfinity()){var z=D.getX(),B=z.umod(this.n);if(B.cmpn(0)!==0){var M=P.invm(this.n).mul(B.mul(c.getPrivate()).iadd(m));if(M=M.umod(this.n),M.cmpn(0)!==0){var I=(D.getY().isOdd()?1:0)|(z.cmp(B)!==0?2:0);return r.canonical&&M.cmp(this.nh)>0&&(M=this.n.sub(M),I^=1),new l({r:B,s:M,recoveryParam:I})}}}}}},d.prototype.verify=function(m,c,a,r){m=this._truncateToN(new y(m,16)),a=this.keyFromPublic(a,r),c=new l(c,"hex");var t=c.r,i=c.s;if(t.cmpn(1)<0||t.cmp(this.n)>=0||i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;var n=i.invm(this.n),o=n.mul(m).umod(this.n),p=n.mul(t).umod(this.n);if(!this.curve._maxwellTrick){var E=this.g.mulAdd(o,a.getPublic(),p);return E.isInfinity()?!1:E.getX().umod(this.n).cmp(t)===0}var E=this.g.jmulAdd(o,a.getPublic(),p);return E.isInfinity()?!1:E.eqXToP(t)},d.prototype.recoverPubKey=function(s,m,c,a){v((3&c)===c,"The recovery param is more than two bits"),m=new l(m,a);var r=this.n,t=new y(s),i=m.r,n=m.s,o=c&1,p=c>>1;if(i.cmp(this.curve.p.umod(this.curve.n))>=0&&p)throw new Error("Unable to find sencond key candinate");p?i=this.curve.pointFromX(i.add(this.curve.n),o):i=this.curve.pointFromX(i,o);var E=m.r.invm(r),P=r.sub(t).mul(E).umod(r),D=n.mul(E).umod(r);return this.g.mulAdd(P,i,D)},d.prototype.getKeyRecoveryParam=function(s,m,c,a){if(m=new l(m,a),m.recoveryParam!==null)return m.recoveryParam;for(var r=0;r<4;r++){var t;try{t=this.recoverPubKey(s,m,r)}catch{continue}if(t.eq(c))return r}throw new Error("Unable to find valid recovery factor")}},{"../curves":356,"../utils":364,"./key":358,"./signature":359,"bn.js":365,brorand:184,"hmac-drbg":384}],358:[function(e,S,_){var u=e("bn.js"),y=e("../utils"),g=y.assert;function b(w,f){this.ec=w,this.priv=null,this.pub=null,f.priv&&this._importPrivate(f.priv,f.privEnc),f.pub&&this._importPublic(f.pub,f.pubEnc)}S.exports=b,b.fromPublic=function(f,v,h){return v instanceof b?v:new b(f,{pub:v,pubEnc:h})},b.fromPrivate=function(f,v,h){return v instanceof b?v:new b(f,{priv:v,privEnc:h})},b.prototype.validate=function(){var f=this.getPublic();return f.isInfinity()?{result:!1,reason:"Invalid public key"}:f.validate()?f.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"}},b.prototype.getPublic=function(f,v){return typeof f=="string"&&(v=f,f=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),v?this.pub.encode(v,f):this.pub},b.prototype.getPrivate=function(f){return f==="hex"?this.priv.toString(16,2):this.priv},b.prototype._importPrivate=function(f,v){this.priv=new u(f,v||16),this.priv=this.priv.umod(this.ec.curve.n)},b.prototype._importPublic=function(f,v){if(f.x||f.y){this.ec.curve.type==="mont"?g(f.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&g(f.x&&f.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(f.x,f.y);return}this.pub=this.ec.curve.decodePoint(f,v)},b.prototype.derive=function(f){return f.mul(this.priv).getX()},b.prototype.sign=function(f,v,h){return this.ec.sign(f,this,v,h)},b.prototype.verify=function(f,v){return this.ec.verify(f,v,this)},b.prototype.inspect=function(){return""}},{"../utils":364,"bn.js":365}],359:[function(e,S,_){var u=e("bn.js"),y=e("../utils"),g=y.assert;function b(l,d){if(l instanceof b)return l;this._importDER(l,d)||(g(l.r&&l.s,"Signature without r or s"),this.r=new u(l.r,16),this.s=new u(l.s,16),l.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=l.recoveryParam)}S.exports=b;function w(){this.place=0}function f(l,d){var s=l[d.place++];if(!(s&128))return s;var m=s&15;if(m===0||m>4)return!1;for(var c=0,a=0,r=d.place;a>>=0;return c<=127?!1:(d.place=r,c)}function v(l){for(var d=0,s=l.length-1;!l[d]&&!(l[d+1]&128)&&d>>3);for(l.push(s|128);--s;)l.push(d>>>(s<<3)&255);l.push(d)}b.prototype.toDER=function(d){var s=this.r.toArray(),m=this.s.toArray();for(s[0]&128&&(s=[0].concat(s)),m[0]&128&&(m=[0].concat(m)),s=v(s),m=v(m);!m[0]&&!(m[1]&128);)m=m.slice(1);var c=[2];h(c,s.length),c=c.concat(s),c.push(2),h(c,m.length);var a=c.concat(m),r=[48];return h(r,a.length),r=r.concat(a),y.encode(r,d)}},{"../utils":364,"bn.js":365}],360:[function(e,S,_){var u=e("hash.js"),y=e("../curves"),g=e("../utils"),b=g.assert,w=g.parseBytes,f=e("./key"),v=e("./signature");function h(d){if(b(d==="ed25519","only tested with ed25519 so far"),!(this instanceof h))return new h(d);var d=y[d].curve;this.curve=d,this.g=d.g,this.g.precompute(d.n.bitLength()+1),this.pointClass=d.point().constructor,this.encodingLength=Math.ceil(d.n.bitLength()/8),this.hash=u.sha512}S.exports=h,h.prototype.sign=function(d,s){d=w(d);var m=this.keyFromSecret(s),c=this.hashInt(m.messagePrefix(),d),a=this.g.mul(c),r=this.encodePoint(a),t=this.hashInt(r,m.pubBytes(),d).mul(m.priv()),i=c.add(t).umod(this.curve.n);return this.makeSignature({R:a,S:i,Rencoded:r})},h.prototype.verify=function(d,s,m){d=w(d),s=this.makeSignature(s);var c=this.keyFromPublic(m),a=this.hashInt(s.Rencoded(),c.pubBytes(),d),r=this.g.mul(s.S()),t=s.R().add(c.pub().mul(a));return t.eq(r)},h.prototype.hashInt=function(){for(var d=this.hash(),s=0;s(a>>1)-1?i=(a>>1)-n:i=n,r.isubn(i)):i=0,c[t]=i,r.iushrn(1)}return c}u.getNAF=w;function f(d,s){var m=[[],[]];d=d.clone(),s=s.clone();for(var c=0,a=0;d.cmpn(-c)>0||s.cmpn(-a)>0;){var r=d.andln(3)+c&3,t=s.andln(3)+a&3;r===3&&(r=-1),t===3&&(t=-1);var i;if(!(r&1))i=0;else{var n=d.andln(7)+c&7;(n===3||n===5)&&t===2?i=-r:i=r}m[0].push(i);var o;if(!(t&1))o=0;else{var n=s.andln(7)+a&7;(n===3||n===5)&&r===2?o=-t:o=t}m[1].push(o),2*c===i+1&&(c=1-c),2*a===o+1&&(a=1-a),d.iushrn(1),s.iushrn(1)}return m}u.getJSF=f;function v(d,s,m){var c="_"+s;d.prototype[s]=function(){return this[c]!==void 0?this[c]:this[c]=m.call(this)}}u.cachedProperty=v;function h(d){return typeof d=="string"?u.toArray(d,"hex"):d}u.parseBytes=h;function l(d){return new y(d,"hex","le")}u.intFromLE=l},{"bn.js":365,"minimalistic-assert":437,"minimalistic-crypto-utils":438}],365:[function(e,S,_){arguments[4][181][0].apply(_,arguments)},{buffer:185,dup:181}],366:[function(e,S,_){S.exports={_from:"elliptic@^6.5.3",_id:"elliptic@6.5.3",_inBundle:!1,_integrity:"sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.5.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.5.3",saveSpec:null,fetchSpec:"^6.5.3"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",_shasum:"cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6",_spec:"elliptic@^6.5.3",_where:"/mnt/d/dev/git/exceljs/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^3.0.8",grunt:"^1.0.4","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.2",jscs:"^3.0.7",jshint:"^2.10.3",mocha:"^6.2.2"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.3"}},{}],367:[function(e,S,_){function u(M){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(T){return typeof T}:u=function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},u(M)}var y=Object.create||D,g=Object.keys||z,b=Function.prototype.bind||B;function w(){(!this._events||!Object.prototype.hasOwnProperty.call(this,"_events"))&&(this._events=y(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}S.exports=w,w.EventEmitter=w,w.prototype._events=void 0,w.prototype._maxListeners=void 0;var f=10,v;try{var h={};Object.defineProperty&&Object.defineProperty(h,"x",{value:0}),v=h.x===0}catch{v=!1}v?Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return f},set:function(I){if(typeof I!="number"||I<0||I!==I)throw new TypeError('"defaultMaxListeners" must be a positive number');f=I}}):w.defaultMaxListeners=f,w.prototype.setMaxListeners=function(I){if(typeof I!="number"||I<0||isNaN(I))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=I,this};function l(M){return M._maxListeners===void 0?w.defaultMaxListeners:M._maxListeners}w.prototype.getMaxListeners=function(){return l(this)};function d(M,I,T){if(I)M.call(T);else for(var C=M.length,O=E(M,C),A=0;A1&&(T=arguments[1]),T instanceof Error)throw T;var $=new Error('Unhandled "error" event. ('+T+")");throw $.context=T,$}if(C=U[I],!C)return!1;var N=typeof C=="function";switch(O=arguments.length,O){case 1:d(C,N,this);break;case 2:s(C,N,this,arguments[1]);break;case 3:m(C,N,this,arguments[1],arguments[2]);break;case 4:c(C,N,this,arguments[1],arguments[2],arguments[3]);break;default:for(A=new Array(O-1),L=1;L0&&L.length>O)){L.warned=!0;var U=new Error("Possible EventEmitter memory leak detected. "+L.length+' "'+String(I)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');U.name="MaxListenersExceededWarning",U.emitter=M,U.type=I,U.count=L.length,(typeof console>"u"?"undefined":u(console))==="object"&&console.warn&&console.warn("%s: %s",U.name,U.message)}return M}w.prototype.addListener=function(I,T){return r(this,I,T,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(I,T){return r(this,I,T,!0)};function t(){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 M=new Array(arguments.length),I=0;I=0;L--)if(C[L]===T||C[L].listener===T){U=C[L].listener,A=L;break}if(A<0)return this;A===0?C.shift():p(C,A),C.length===1&&(O[I]=C[0]),O.removeListener&&this.emit("removeListener",I,U||T)}return this},w.prototype.removeAllListeners=function(I){var T,C,O;if(C=this._events,!C)return this;if(!C.removeListener)return arguments.length===0?(this._events=y(null),this._eventsCount=0):C[I]&&(--this._eventsCount===0?this._events=y(null):delete C[I]),this;if(arguments.length===0){var A=g(C),L;for(O=0;O=0;O--)this.removeListener(I,T[O]);return this};function n(M,I,T){var C=M._events;if(!C)return[];var O=C[I];return O?typeof O=="function"?T?[O.listener||O]:[O]:T?P(O):E(O,O.length):[]}w.prototype.listeners=function(I){return n(this,I,!0)},w.prototype.rawListeners=function(I){return n(this,I,!1)},w.listenerCount=function(M,I){return typeof M.listenerCount=="function"?M.listenerCount(I):o.call(M,I)},w.prototype.listenerCount=o;function o(M){var I=this._events;if(I){var T=I[M];if(typeof T=="function")return 1;if(T)return T.length}return 0}w.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function p(M,I){for(var T=I,C=T+1,O=M.length;C0||v>0;){var m=new y;m.update(s),m.update(b),w&&m.update(w),s=m.digest();var c=0;if(h>0){var a=l.length-h;c=Math.min(h,s.length),s.copy(l,a,0,c),h-=c}if(c0){var r=d.length-v,t=Math.min(v,s.length-c);s.copy(d,r,c,c+t),v-=t}}return s.fill(0),{key:l,iv:d}}S.exports=g},{"md5.js":434,"safe-buffer":494}],369:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0});var u=e("@fast-csv/format");Object.defineProperty(_,"format",{enumerable:!0,get:function(){return u.format}}),Object.defineProperty(_,"write",{enumerable:!0,get:function(){return u.write}}),Object.defineProperty(_,"writeToStream",{enumerable:!0,get:function(){return u.writeToStream}}),Object.defineProperty(_,"writeToBuffer",{enumerable:!0,get:function(){return u.writeToBuffer}}),Object.defineProperty(_,"writeToString",{enumerable:!0,get:function(){return u.writeToString}}),Object.defineProperty(_,"writeToPath",{enumerable:!0,get:function(){return u.writeToPath}}),Object.defineProperty(_,"CsvFormatterStream",{enumerable:!0,get:function(){return u.CsvFormatterStream}}),Object.defineProperty(_,"FormatterOptions",{enumerable:!0,get:function(){return u.FormatterOptions}});var y=e("@fast-csv/parse");Object.defineProperty(_,"parse",{enumerable:!0,get:function(){return y.parse}}),Object.defineProperty(_,"parseString",{enumerable:!0,get:function(){return y.parseString}}),Object.defineProperty(_,"parseStream",{enumerable:!0,get:function(){return y.parseStream}}),Object.defineProperty(_,"parseFile",{enumerable:!0,get:function(){return y.parseFile}}),Object.defineProperty(_,"ParserOptions",{enumerable:!0,get:function(){return y.ParserOptions}}),Object.defineProperty(_,"CsvParserStream",{enumerable:!0,get:function(){return y.CsvParserStream}})},{"@fast-csv/format":148,"@fast-csv/parse":152}],370:[function(e,S,_){var u=e("safe-buffer").Buffer,y=e("readable-stream").Transform,g=e("inherits");function b(f,v){if(!u.isBuffer(f)&&typeof f!="string")throw new TypeError(v+" must be a string or a buffer")}function w(f){y.call(this),this._block=u.allocUnsafe(f),this._blockSize=f,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}g(w,y),w.prototype._transform=function(f,v,h){var l=null;try{this.update(f,v)}catch(d){l=d}h(l)},w.prototype._flush=function(f){var v=null;try{this.push(this.digest())}catch(h){v=h}f(v)},w.prototype.update=function(f,v){if(b(f,"Data"),this._finalized)throw new Error("Digest already called");u.isBuffer(f)||(f=u.from(f,v));for(var h=this._block,l=0;this._blockOffset+f.length-l>=this._blockSize;){for(var d=this._blockOffset;d0;++s)this._length[s]+=m,m=this._length[s]/4294967296|0,m>0&&(this._length[s]-=4294967296*m);return this},w.prototype._update=function(){throw new Error("_update is not implemented")},w.prototype.digest=function(f){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var v=this._digest();f!==void 0&&(v=v.toString(f)),this._block.fill(0),this._blockOffset=0;for(var h=0;h<4;++h)this._length[h]=0;return v},w.prototype._digest=function(){throw new Error("_digest is not implemented")},S.exports=w},{inherits:387,"readable-stream":491,"safe-buffer":371}],371:[function(e,S,_){arguments[4][214][0].apply(_,arguments)},{buffer:216,dup:214}],372:[function(e,S,_){var u=_;u.utils=e("./hash/utils"),u.common=e("./hash/common"),u.sha=e("./hash/sha"),u.ripemd=e("./hash/ripemd"),u.hmac=e("./hash/hmac"),u.sha1=u.sha.sha1,u.sha256=u.sha.sha256,u.sha224=u.sha.sha224,u.sha384=u.sha.sha384,u.sha512=u.sha.sha512,u.ripemd160=u.ripemd.ripemd160},{"./hash/common":373,"./hash/hmac":374,"./hash/ripemd":375,"./hash/sha":376,"./hash/utils":383}],373:[function(e,S,_){var u=e("./utils"),y=e("minimalistic-assert");function g(){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}_.BlockHash=g,g.prototype.update=function(w,f){if(w=u.toArray(w,f),this.pending?this.pending=this.pending.concat(w):this.pending=w,this.pendingTotal+=w.length,this.pending.length>=this._delta8){w=this.pending;var v=w.length%this._delta8;this.pending=w.slice(w.length-v,w.length),this.pending.length===0&&(this.pending=null),w=u.join32(w,0,w.length-v,this.endian);for(var h=0;h>>24&255,h[l++]=w>>>16&255,h[l++]=w>>>8&255,h[l++]=w&255}else for(h[l++]=w&255,h[l++]=w>>>8&255,h[l++]=w>>>16&255,h[l++]=w>>>24&255,h[l++]=0,h[l++]=0,h[l++]=0,h[l++]=0,d=8;dthis.blockSize&&(w=new this.Hash().update(w).digest()),y(w.length<=this.blockSize);for(var f=w.length;f>>3}_.g0_256=l;function d(s){return y(s,17)^y(s,19)^s>>>10}_.g1_256=d},{"../utils":383}],383:[function(e,S,_){var u=e("minimalistic-assert"),y=e("inherits");_.inherits=y;function g(C,O){return(C.charCodeAt(O)&64512)!==55296||O<0||O+1>=C.length?!1:(C.charCodeAt(O+1)&64512)===56320}function b(C,O){if(Array.isArray(C))return C.slice();if(!C)return[];var A=[];if(typeof C=="string")if(O){if(O==="hex")for(C=C.replace(/[^a-z0-9]+/ig,""),C.length%2!==0&&(C="0"+C),U=0;U>6|192,A[L++]=W&63|128):g(C,U)?(W=65536+((W&1023)<<10)+(C.charCodeAt(++U)&1023),A[L++]=W>>18|240,A[L++]=W>>12&63|128,A[L++]=W>>6&63|128,A[L++]=W&63|128):(A[L++]=W>>12|224,A[L++]=W>>6&63|128,A[L++]=W&63|128)}else for(U=0;U>>24|C>>>8&65280|C<<8&16711680|(C&255)<<24;return O>>>0}_.htonl=f;function v(C,O){for(var A="",L=0;L>>0}return W}_.join32=d;function s(C,O){for(var A=new Array(C.length*4),L=0,U=0;L>>24,A[U+1]=W>>>16&255,A[U+2]=W>>>8&255,A[U+3]=W&255):(A[U+3]=W>>>24,A[U+2]=W>>>16&255,A[U+1]=W>>>8&255,A[U]=W&255)}return A}_.split32=s;function m(C,O){return C>>>O|C<<32-O}_.rotr32=m;function c(C,O){return C<>>32-O}_.rotl32=c;function a(C,O){return C+O>>>0}_.sum32=a;function r(C,O,A){return C+O+A>>>0}_.sum32_3=r;function t(C,O,A,L){return C+O+A+L>>>0}_.sum32_4=t;function i(C,O,A,L,U){return C+O+A+L+U>>>0}_.sum32_5=i;function n(C,O,A,L){var U=C[O],W=C[O+1],$=L+W>>>0,N=($>>0,C[O+1]=$}_.sum64=n;function o(C,O,A,L){var U=O+L>>>0,W=(U>>0}_.sum64_hi=o;function p(C,O,A,L){var U=O+L;return U>>>0}_.sum64_lo=p;function E(C,O,A,L,U,W,$,N){var F=0,j=O;j=j+L>>>0,F+=j>>0,F+=j>>0,F+=j>>0}_.sum64_4_hi=E;function P(C,O,A,L,U,W,$,N){var F=O+L+W+N;return F>>>0}_.sum64_4_lo=P;function D(C,O,A,L,U,W,$,N,F,j){var V=0,te=O;te=te+L>>>0,V+=te>>0,V+=te>>0,V+=te>>0,V+=te>>0}_.sum64_5_hi=D;function z(C,O,A,L,U,W,$,N,F,j){var V=O+L+W+N+j;return V>>>0}_.sum64_5_lo=z;function B(C,O,A){var L=O<<32-A|C>>>A;return L>>>0}_.rotr64_hi=B;function M(C,O,A){var L=C<<32-A|O>>>A;return L>>>0}_.rotr64_lo=M;function I(C,O,A){return C>>>A}_.shr64_hi=I;function T(C,O,A){var L=C<<32-A|O>>>A;return L>>>0}_.shr64_lo=T},{inherits:387,"minimalistic-assert":437}],384:[function(e,S,_){var u=e("hash.js"),y=e("minimalistic-crypto-utils"),g=e("minimalistic-assert");function b(w){if(!(this instanceof b))return new b(w);this.hash=w.hash,this.predResist=!!w.predResist,this.outLen=this.hash.outSize,this.minEntropy=w.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var f=y.toArray(w.entropy,w.entropyEnc||"hex"),v=y.toArray(w.nonce,w.nonceEnc||"hex"),h=y.toArray(w.pers,w.persEnc||"hex");g(f.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(f,v,h)}S.exports=b,b.prototype._init=function(f,v,h){var l=f.concat(v).concat(h);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var d=0;d=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(f.concat(h||[])),this._reseed=1},b.prototype.generate=function(f,v,h,l){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof v!="string"&&(l=h,h=v,v=null),h&&(h=y.toArray(h,l||"hex"),this._update(h));for(var d=[];d.length>1,s=-7,m=g?w-1:0,c=g?-1:1,a=u[y+m];for(m+=c,f=a&(1<<-s)-1,a>>=-s,s+=h;s>0;f=f*256+u[y+m],m+=c,s-=8);for(v=f&(1<<-s)-1,f>>=-s,s+=b;s>0;v=v*256+u[y+m],m+=c,s-=8);if(f===0)f=1-d;else{if(f===l)return v?NaN:(a?-1:1)*(1/0);v=v+Math.pow(2,b),f=f-d}return(a?-1:1)*v*Math.pow(2,f-b)},_.write=function(u,y,g,b,w,f){var v,h,l,d=f*8-w-1,s=(1<>1,c=w===23?Math.pow(2,-24)-Math.pow(2,-77):0,a=b?0:f-1,r=b?1:-1,t=y<0||y===0&&1/y<0?1:0;for(y=Math.abs(y),isNaN(y)||y===1/0?(h=isNaN(y)?1:0,v=s):(v=Math.floor(Math.log(y)/Math.LN2),y*(l=Math.pow(2,-v))<1&&(v--,l*=2),v+m>=1?y+=c/l:y+=c*Math.pow(2,1-m),y*l>=2&&(v++,l/=2),v+m>=s?(h=0,v=s):v+m>=1?(h=(y*l-1)*Math.pow(2,w),v=v+m):(h=y*Math.pow(2,m-1)*Math.pow(2,w),v=0));w>=8;u[g+a]=h&255,a+=r,h/=256,w-=8);for(v=v<0;u[g+a]=v&255,a+=r,v/=256,d-=8);u[g+a-r]|=t*128}},{}],386:[function(e,S,_){(function(u){var y=u.MutationObserver||u.WebKitMutationObserver,g;if(y){var b=0,w=new y(d),f=u.document.createTextNode("");w.observe(f,{characterData:!0}),g=function(){f.data=b=++b%2}}else if(!u.setImmediate&&typeof u.MessageChannel<"u"){var v=new u.MessageChannel;v.port1.onmessage=d,g=function(){v.port2.postMessage(0)}}else"document"in u&&"onreadystatechange"in u.document.createElement("script")?g=function(){var c=u.document.createElement("script");c.onreadystatechange=function(){d(),c.onreadystatechange=null,c.parentNode.removeChild(c),c=null},u.document.documentElement.appendChild(c)}:g=function(){setTimeout(d,0)};var h,l=[];function d(){h=!0;for(var m,c,a=l.length;a;){for(c=l,l=[],m=-1;++m * @license MIT - */S.exports=function(g){return g!=null&&(u(g)||y(g)||!!g._isBuffer)};function u(g){return!!g.constructor&&typeof g.constructor.isBuffer=="function"&&g.constructor.isBuffer(g)}function y(g){return typeof g.readFloatLE=="function"&&typeof g.slice=="function"&&u(g.slice(0,0))}},{}],389:[function(e,S,_){var u={}.toString;S.exports=Array.isArray||function(y){return u.call(y)=="[object Array]"}},{}],390:[function(e,S,_){var u=e("./utils"),y=e("./support"),g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";_.encode=function(b){for(var w=[],f,v,h,l,d,s,m,c=0,a=b.length,r=a,t=u.getTypeOf(b)!=="string";c>2,d=(f&3)<<4|v>>4,s=r>1?(v&15)<<2|h>>6:64,m=r>2?h&63:64,w.push(g.charAt(l)+g.charAt(d)+g.charAt(s)+g.charAt(m));return w.join("")},_.decode=function(b){var w,f,v,h,l,d,s,m=0,c=0,a="data:";if(b.substr(0,a.length)===a)throw new Error("Invalid base64 input, it looks like a data url.");b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");var r=b.length*3/4;if(b.charAt(b.length-1)===g.charAt(64)&&r--,b.charAt(b.length-2)===g.charAt(64)&&r--,r%1!==0)throw new Error("Invalid base64 input, bad content length.");var t;for(y.uint8array?t=new Uint8Array(r|0):t=new Array(r|0);m>4,f=(l&15)<<4|d>>2,v=(d&3)<<6|s,t[c++]=w,d!==64&&(t[c++]=f),s!==64&&(t[c++]=v);return t}},{"./support":419,"./utils":421}],391:[function(e,S,_){var u=e("./external"),y=e("./stream/DataWorker"),b=e("./stream/DataLengthProbe"),g=e("./stream/Crc32Probe"),b=e("./stream/DataLengthProbe");function w(f,v,h,l,d){this.compressedSize=f,this.uncompressedSize=v,this.crc32=h,this.compression=l,this.compressedContent=d}w.prototype={getContentWorker:function(){var v=new y(u.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new b("data_length")),h=this;return v.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),v},getCompressedWorker:function(){return new y(u.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},w.createWorkerFrom=function(f,v,h){return f.pipe(new g).pipe(new b("uncompressedSize")).pipe(v.compressWorker(h)).pipe(new b("compressedSize")).withStreamInfo("compression",v)},S.exports=w},{"./external":395,"./stream/Crc32Probe":414,"./stream/DataLengthProbe":415,"./stream/DataWorker":416}],392:[function(e,S,_){var u=e("./stream/GenericWorker");_.STORE={magic:"\0\0",compressWorker:function(g){return new u("STORE compression")},uncompressWorker:function(){return new u("STORE decompression")}},_.DEFLATE=e("./flate")},{"./flate":396,"./stream/GenericWorker":417}],393:[function(e,S,_){var u=e("./utils");function y(){for(var f,v=[],h=0;h<256;h++){f=h;for(var l=0;l<8;l++)f=f&1?3988292384^f>>>1:f>>>1;v[h]=f}return v}var g=y();function b(f,v,h,l){var d=g,s=l+h;f=f^-1;for(var m=l;m>>8^d[(f^v[m])&255];return f^-1}function w(f,v,h,l){var d=g,s=l+h;f=f^-1;for(var m=l;m>>8^d[(f^v.charCodeAt(m))&255];return f^-1}S.exports=function(v,h){if(typeof v>"u"||!v.length)return 0;var l=u.getTypeOf(v)!=="string";return l?b(h|0,v,v.length,0):w(h|0,v,v.length,0)}},{"./utils":421}],394:[function(e,S,_){_.base64=!1,_.binary=!1,_.dir=!1,_.createFolders=!0,_.date=null,_.compression=null,_.compressionOptions=null,_.comment=null,_.unixPermissions=null,_.dosPermissions=null},{}],395:[function(e,S,_){var u=null;typeof Promise<"u"?u=Promise:u=e("lie"),S.exports={Promise:u}},{lie:425}],396:[function(e,S,_){var u=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",y=e("pako"),g=e("./utils"),b=e("./stream/GenericWorker"),w=u?"uint8array":"array";_.magic="\b\0";function f(v,h){b.call(this,"FlateWorker/"+v),this._pako=null,this._pakoAction=v,this._pakoOptions=h,this.meta={}}g.inherits(f,b),f.prototype.processChunk=function(v){this.meta=v.meta,this._pako===null&&this._createPako(),this._pako.push(g.transformTo(w,v.data),!1)},f.prototype.flush=function(){b.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){b.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new y[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var v=this;this._pako.onData=function(h){v.push({data:h,meta:v.meta})}},_.compressWorker=function(v){return new f("Deflate",v)},_.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":417,"./utils":421,pako:439}],397:[function(e,S,_){var u=e("../utils"),y=e("../stream/GenericWorker"),g=e("../utf8"),b=e("../crc32"),w=e("../signature"),f=function(a,r){var t="",i;for(i=0;i>>8;return t},v=function(a,r){var t=a;return a||(t=r?16893:33204),(t&65535)<<16},h=function(a,r){return(a||0)&63},l=function(a,r,t,i,n,o){var p=a.file,O=a.compression,P=o!==g.utf8encode,B=u.transformTo("string",o(p.name)),z=u.transformTo("string",g.utf8encode(p.name)),D=p.comment,M=u.transformTo("string",o(D)),I=u.transformTo("string",g.utf8encode(D)),T=z.length!==p.name.length,C=I.length!==D.length,E,A,L="",$="",W="",U=p.dir,N=p.date,j={crc32:0,compressedSize:0,uncompressedSize:0};(!r||t)&&(j.crc32=a.crc32,j.compressedSize=a.compressedSize,j.uncompressedSize=a.uncompressedSize);var F=0;r&&(F|=8),!P&&(T||C)&&(F|=2048);var V=0,re=0;U&&(V|=16),n==="UNIX"?(re=798,V|=v(p.unixPermissions,U)):(re=20,V|=h(p.dosPermissions)),E=N.getUTCHours(),E=E<<6,E=E|N.getUTCMinutes(),E=E<<5,E=E|N.getUTCSeconds()/2,A=N.getUTCFullYear()-1980,A=A<<4,A=A|N.getUTCMonth()+1,A=A<<5,A=A|N.getUTCDate(),T&&($=f(1,1)+f(b(B),4)+z,L+="up"+f($.length,2)+$),C&&(W=f(1,1)+f(b(M),4)+I,L+="uc"+f(W.length,2)+W);var ee="";ee+=` -\0`,ee+=f(F,2),ee+=O.magic,ee+=f(E,2),ee+=f(A,2),ee+=f(j.crc32,4),ee+=f(j.compressedSize,4),ee+=f(j.uncompressedSize,4),ee+=f(B.length,2),ee+=f(L.length,2);var ce=w.LOCAL_FILE_HEADER+ee+B+L,ye=w.CENTRAL_FILE_HEADER+f(re,2)+ee+f(M.length,2)+"\0\0\0\0"+f(V,4)+f(i,4)+B+L+M;return{fileRecord:ce,dirRecord:ye}},d=function(a,r,t,i,n){var o="",p=u.transformTo("string",n(i));return o=w.CENTRAL_DIRECTORY_END+"\0\0\0\0"+f(a,2)+f(a,2)+f(r,4)+f(t,4)+f(p.length,2)+p,o},s=function(a){var r="";return r=w.DATA_DESCRIPTOR+f(a.crc32,4)+f(a.compressedSize,4)+f(a.uncompressedSize,4),r};function m(c,a,r,t){y.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=a,this.zipPlatform=r,this.encodeFileName=t,this.streamFiles=c,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}u.inherits(m,y),m.prototype.push=function(c){var a=c.meta.percent||0,r=this.entriesCount,t=this._sources.length;this.accumulate?this.contentBuffer.push(c):(this.bytesWritten+=c.data.length,y.prototype.push.call(this,{data:c.data,meta:{currentFile:this.currentFile,percent:r?(a+100*(r-t-1))/r:100}}))},m.prototype.openedSource=function(c){this.currentSourceOffset=this.bytesWritten,this.currentFile=c.file.name;var a=this.streamFiles&&!c.file.dir;if(a){var r=l(c,a,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(c){this.accumulate=!1;var a=this.streamFiles&&!c.file.dir,r=l(c,a,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),a)this.push({data:s(c),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var c=this.bytesWritten,a=0;a"u")&&(B.binary=!z);var D=o instanceof f&&o.uncompressedSize===0;(D||B.dir||!o||o.length===0)&&(B.base64=!1,B.binary=!0,o="",B.compression="STORE",O="string");var M=null;o instanceof f||o instanceof g?M=o:l.isNode&&l.isStream(o)?M=new d(n,o):M=y.prepareContent(n,o,B.binary,B.optimizedBinaryString,B.base64);var I=new v(n,M,B);this.files[n]=I},m=function(n){n.slice(-1)==="/"&&(n=n.substring(0,n.length-1));var o=n.lastIndexOf("/");return o>0?n.substring(0,o):""},c=function(n){return n.slice(-1)!=="/"&&(n+="/"),n},a=function(n,o){return o=typeof o<"u"?o:w.createFolders,n=c(n),this.files[n]||s.call(this,n,null,{dir:!0,createFolders:o}),this.files[n]};function r(i){return Object.prototype.toString.call(i)==="[object RegExp]"}var t={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(n){var o,p,O;for(o in this.files)this.files.hasOwnProperty(o)&&(O=this.files[o],p=o.slice(this.root.length,o.length),p&&o.slice(0,this.root.length)===this.root&&n(p,O))},filter:function(n){var o=[];return this.forEach(function(p,O){n(p,O)&&o.push(O)}),o},file:function(n,o,p){if(arguments.length===1)if(r(n)){var O=n;return this.filter(function(B,z){return!z.dir&&O.test(B)})}else{var P=this.files[this.root+n];return P&&!P.dir?P:null}else n=this.root+n,s.call(this,n,o,p);return this},folder:function(n){if(!n)return this;if(r(n))return this.filter(function(P,B){return B.dir&&n.test(P)});var o=this.root+n,p=a.call(this,o),O=this.clone();return O.root=p.name,O},remove:function(n){n=this.root+n;var o=this.files[n];if(o||(n.slice(-1)!=="/"&&(n+="/"),o=this.files[n]),o&&!o.dir)delete this.files[n];else for(var p=this.filter(function(P,B){return B.name.slice(0,n.length)===n}),O=0;O=0;--l)if(this.data[l]===w&&this.data[l+1]===f&&this.data[l+2]===v&&this.data[l+3]===h)return l-this.zero;return-1},g.prototype.readAndCheckSignature=function(b){var w=b.charCodeAt(0),f=b.charCodeAt(1),v=b.charCodeAt(2),h=b.charCodeAt(3),l=this.readData(4);return w===l[0]&&f===l[1]&&v===l[2]&&h===l[3]},g.prototype.readData=function(b){if(this.checkOffset(b),b===0)return[];var w=this.data.slice(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./DataReader":407}],407:[function(e,S,_){var u=e("../utils");function y(g){this.data=g,this.length=g.length,this.index=0,this.zero=0}y.prototype={checkOffset:function(b){this.checkIndex(this.index+b)},checkIndex:function(b){if(this.length=this.index;f--)w=(w<<8)+this.byteAt(f);return this.index+=b,w},readString:function(b){return u.transformTo("string",this.readData(b))},readData:function(b){},lastIndexOfSignature:function(b){},readAndCheckSignature:function(b){},readDate:function(){var b=this.readInt(4);return new Date(Date.UTC((b>>25&127)+1980,(b>>21&15)-1,b>>16&31,b>>11&31,b>>5&63,(b&31)<<1))}},S.exports=y},{"../utils":421}],408:[function(e,S,_){var u=e("./Uint8ArrayReader"),y=e("../utils");function g(b){u.call(this,b)}y.inherits(g,u),g.prototype.readData=function(b){this.checkOffset(b);var w=this.data.slice(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./Uint8ArrayReader":410}],409:[function(e,S,_){var u=e("./DataReader"),y=e("../utils");function g(b){u.call(this,b)}y.inherits(g,u),g.prototype.byteAt=function(b){return this.data.charCodeAt(this.zero+b)},g.prototype.lastIndexOfSignature=function(b){return this.data.lastIndexOf(b)-this.zero},g.prototype.readAndCheckSignature=function(b){var w=this.readData(4);return b===w},g.prototype.readData=function(b){this.checkOffset(b);var w=this.data.slice(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./DataReader":407}],410:[function(e,S,_){var u=e("./ArrayReader"),y=e("../utils");function g(b){u.call(this,b)}y.inherits(g,u),g.prototype.readData=function(b){if(this.checkOffset(b),b===0)return new Uint8Array(0);var w=this.data.subarray(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./ArrayReader":406}],411:[function(e,S,_){var u=e("../utils"),y=e("../support"),g=e("./ArrayReader"),b=e("./StringReader"),w=e("./NodeBufferReader"),f=e("./Uint8ArrayReader");S.exports=function(v){var h=u.getTypeOf(v);return u.checkSupport(h),h==="string"&&!y.uint8array?new b(v):h==="nodebuffer"?new w(v):y.uint8array?new f(u.transformTo("uint8array",v)):new g(u.transformTo("array",v))}},{"../support":419,"../utils":421,"./ArrayReader":406,"./NodeBufferReader":408,"./StringReader":409,"./Uint8ArrayReader":410}],412:[function(e,S,_){_.LOCAL_FILE_HEADER="PK",_.CENTRAL_FILE_HEADER="PK",_.CENTRAL_DIRECTORY_END="PK",_.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",_.ZIP64_CENTRAL_DIRECTORY_END="PK",_.DATA_DESCRIPTOR="PK\x07\b"},{}],413:[function(e,S,_){var u=e("./GenericWorker"),y=e("../utils");function g(b){u.call(this,"ConvertWorker to "+b),this.destType=b}y.inherits(g,u),g.prototype.processChunk=function(b){this.push({data:y.transformTo(this.destType,b.data),meta:b.meta})},S.exports=g},{"../utils":421,"./GenericWorker":417}],414:[function(e,S,_){var u=e("./GenericWorker"),y=e("../crc32"),g=e("../utils");function b(){u.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}g.inherits(b,u),b.prototype.processChunk=function(w){this.streamInfo.crc32=y(w.data,this.streamInfo.crc32||0),this.push(w)},S.exports=b},{"../crc32":393,"../utils":421,"./GenericWorker":417}],415:[function(e,S,_){var u=e("../utils"),y=e("./GenericWorker");function g(b){y.call(this,"DataLengthProbe for "+b),this.propName=b,this.withStreamInfo(b,0)}u.inherits(g,y),g.prototype.processChunk=function(b){if(b){var w=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=w+b.data.length}y.prototype.processChunk.call(this,b)},S.exports=g},{"../utils":421,"./GenericWorker":417}],416:[function(e,S,_){var u=e("../utils"),y=e("./GenericWorker"),g=16*1024;function b(w){y.call(this,"DataWorker");var f=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,w.then(function(v){f.dataIsReady=!0,f.data=v,f.max=v&&v.length||0,f.type=u.getTypeOf(v),f.isPaused||f._tickAndRepeat()},function(v){f.error(v)})}u.inherits(b,y),b.prototype.cleanUp=function(){y.prototype.cleanUp.call(this),this.data=null},b.prototype.resume=function(){return y.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,u.delay(this._tickAndRepeat,[],this)),!0):!1},b.prototype._tickAndRepeat=function(){this._tickScheduled=!1,!(this.isPaused||this.isFinished)&&(this._tick(),this.isFinished||(u.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},b.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var w=g,f=null,v=Math.min(this.max,this.index+w);if(this.index>=this.max)return this.end();switch(this.type){case"string":f=this.data.substring(this.index,v);break;case"uint8array":f=this.data.subarray(this.index,v);break;case"array":case"nodebuffer":f=this.data.slice(this.index,v);break}return this.index=v,this.push({data:f,meta:{percent:this.max?this.index/this.max*100:0}})},S.exports=b},{"../utils":421,"./GenericWorker":417}],417:[function(e,S,_){function u(y){this.name=y||"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}u.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?!1:(this.isPaused?this.generatedError=g:(this.isFinished=!0,this.emit("error",g),this.previous&&this.previous.error(g),this.cleanUp()),!0)},on:function(g,b){return this._listeners[g].push(b),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(g,b){if(this._listeners[g])for(var w=0;w "+g:g}},S.exports=u},{}],418:[function(e,S,_){(function(u){var y=e("../utils"),g=e("./ConvertWorker"),b=e("./GenericWorker"),w=e("../base64"),f=e("../support"),v=e("../external"),h=null;if(f.nodestream)try{h=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function l(c,a,r){switch(c){case"blob":return y.newBlob(y.transformTo("arraybuffer",a),r);case"base64":return w.encode(a);default:return y.transformTo(c,a)}}function d(c,a){var r,t=0,i=null,n=0;for(r=0;r"u")_.blob=!1;else{var y=new ArrayBuffer(0);try{_.blob=new Blob([y],{type:"application/zip"}).size===0}catch{try{var g=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,b=new g;b.append(y),_.blob=b.getBlob("application/zip").size===0}catch{_.blob=!1}}}try{_.nodestream=!!e("readable-stream").Readable}catch{_.nodestream=!1}}).call(this,e("buffer").Buffer)},{buffer:216,"readable-stream":405}],420:[function(e,S,_){for(var u=e("./utils"),y=e("./support"),g=e("./nodejsUtils"),b=e("./stream/GenericWorker"),w=new Array(256),f=0;f<256;f++)w[f]=f>=252?6:f>=248?5:f>=240?4:f>=224?3:f>=192?2:1;w[254]=w[254]=1;var v=function(c){var a,r,t,i,n,o=c.length,p=0;for(i=0;i>>6,a[n++]=128|r&63):r<65536?(a[n++]=224|r>>>12,a[n++]=128|r>>>6&63,a[n++]=128|r&63):(a[n++]=240|r>>>18,a[n++]=128|r>>>12&63,a[n++]=128|r>>>6&63,a[n++]=128|r&63);return a},h=function(c,a){var r;for(a=a||c.length,a>c.length&&(a=c.length),r=a-1;r>=0&&(c[r]&192)===128;)r--;return r<0||r===0?a:r+w[c[r]]>a?r:a},l=function(c){var a,r,t,i,n=c.length,o=new Array(n*2);for(r=0,a=0;a4){o[r++]=65533,a+=i-1;continue}for(t&=i===2?31:i===3?15:7;i>1&&a1){o[r++]=65533;continue}t<65536?o[r++]=t:(t-=65536,o[r++]=55296|t>>10&1023,o[r++]=56320|t&1023)}return o.length!==r&&(o.subarray?o=o.subarray(0,r):o.length=r),u.applyFromCharCode(o)};_.utf8encode=function(c){return y.nodebuffer?g.newBufferFrom(c,"utf-8"):v(c)},_.utf8decode=function(c){return y.nodebuffer?u.transformTo("nodebuffer",c).toString("utf-8"):(c=u.transformTo(y.uint8array?"uint8array":"array",c),l(c))};function d(){b.call(this,"utf-8 decode"),this.leftOver=null}u.inherits(d,b),d.prototype.processChunk=function(m){var c=u.transformTo(y.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(y.uint8array){var a=c;c=new Uint8Array(a.length+this.leftOver.length),c.set(this.leftOver,0),c.set(a,this.leftOver.length)}else c=this.leftOver.concat(c);this.leftOver=null}var r=h(c),t=c;r!==c.length&&(y.uint8array?(t=c.subarray(0,r),this.leftOver=c.subarray(r,c.length)):(t=c.slice(0,r),this.leftOver=c.slice(r,c.length))),this.push({data:_.utf8decode(t),meta:m.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:_.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},_.Utf8DecodeWorker=d;function s(){b.call(this,"utf-8 encode")}u.inherits(s,b),s.prototype.processChunk=function(m){this.push({data:_.utf8encode(m.data),meta:m.meta})},_.Utf8EncodeWorker=s},{"./nodejsUtils":403,"./stream/GenericWorker":417,"./support":419,"./utils":421}],421:[function(e,S,_){var u=e("./support"),y=e("./base64"),g=e("./nodejsUtils"),b=e("set-immediate-shim"),w=e("./external");function f(c){var a=null;return u.uint8array?a=new Uint8Array(c.length):a=new Array(c.length),h(c,a)}_.newBlob=function(c,a){_.checkSupport("blob");try{return new Blob([c],{type:a})}catch{try{var r=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,t=new r;return t.append(c),t.getBlob(a)}catch{throw new Error("Bug : can't construct the Blob.")}}};function v(c){return c}function h(c,a){for(var r=0;r1;)try{return l.stringifyByChunk(c,r,a)}catch{a=Math.floor(a/2)}return l.stringifyByChar(c)}_.applyFromCharCode=d;function s(c,a){for(var r=0;r"u"&&(c[r]=arguments[a][r]);return c},_.prepareContent=function(c,a,r,t,i){var n=w.Promise.resolve(a).then(function(o){var p=u.blob&&(o instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(o))!==-1);return p&&typeof FileReader<"u"?new w.Promise(function(O,P){var B=new FileReader;B.onload=function(z){O(z.target.result)},B.onerror=function(z){P(z.target.error)},B.readAsArrayBuffer(o)}):o});return n.then(function(o){var p=_.getTypeOf(o);return p?(p==="arraybuffer"?o=_.transformTo("uint8array",o):p==="string"&&(i?o=y.decode(o):r&&t!==!0&&(o=f(o))),o):w.Promise.reject(new Error("Can't read the data of '"+c+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":390,"./external":395,"./nodejsUtils":403,"./support":419,"set-immediate-shim":497}],422:[function(e,S,_){var u=e("./reader/readerFor"),y=e("./utils"),g=e("./signature"),b=e("./zipEntry");e("./utf8");var w=e("./support");function f(v){this.files=[],this.loadOptions=v}f.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var l=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+y.pretty(l)+", expected "+y.pretty(h)+")")}},isSignature:function(h,l){var d=this.reader.index;this.reader.setIndex(h);var s=this.reader.readString(4),m=s===l;return this.reader.setIndex(d),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),l=w.uint8array?"uint8array":"array",d=y.transformTo(l,h);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h=this.zip64EndOfCentralSize-44,l=0,d,s,m;l1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,l;for(h=0;h0)this.isSignature(d,g.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(h){this.reader=u(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},S.exports=f},{"./reader/readerFor":411,"./signature":412,"./support":419,"./utf8":420,"./utils":421,"./zipEntry":423}],423:[function(e,S,_){var u=e("./reader/readerFor"),y=e("./utils"),g=e("./compressedObject"),b=e("./crc32"),w=e("./utf8"),f=e("./compressions"),v=e("./support"),h=0,l=3,d=function(c){for(var a in f)if(f.hasOwnProperty(a)&&f[a].magic===c)return f[a];return null};function s(m,c){this.options=m,this.loadOptions=c}s.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(c){var a,r;if(c.skip(22),this.fileNameLength=c.readInt(2),r=c.readInt(2),this.fileName=c.readData(this.fileNameLength),c.skip(r),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(a=d(this.compressionMethod),a===null)throw new Error("Corrupted zip : compression "+y.pretty(this.compressionMethod)+" unknown (inner file : "+y.transformTo("string",this.fileName)+")");this.decompressed=new g(this.compressedSize,this.uncompressedSize,this.crc32,a,c.readData(this.compressedSize))},readCentralPart:function(c){this.versionMadeBy=c.readInt(2),c.skip(2),this.bitFlag=c.readInt(2),this.compressionMethod=c.readString(2),this.date=c.readDate(),this.crc32=c.readInt(4),this.compressedSize=c.readInt(4),this.uncompressedSize=c.readInt(4);var a=c.readInt(2);if(this.extraFieldsLength=c.readInt(2),this.fileCommentLength=c.readInt(2),this.diskNumberStart=c.readInt(2),this.internalFileAttributes=c.readInt(2),this.externalFileAttributes=c.readInt(4),this.localHeaderOffset=c.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");c.skip(a),this.readExtraFields(c),this.parseZIP64ExtraField(c),this.fileComment=c.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var c=this.versionMadeBy>>8;this.dir=!!(this.externalFileAttributes&16),c===h&&(this.dosPermissions=this.externalFileAttributes&63),c===l&&(this.unixPermissions=this.externalFileAttributes>>16&65535),!this.dir&&this.fileNameStr.slice(-1)==="/"&&(this.dir=!0)},parseZIP64ExtraField:function(c){if(this.extraFields[1]){var a=u(this.extraFields[1].value);this.uncompressedSize===y.MAX_VALUE_32BITS&&(this.uncompressedSize=a.readInt(8)),this.compressedSize===y.MAX_VALUE_32BITS&&(this.compressedSize=a.readInt(8)),this.localHeaderOffset===y.MAX_VALUE_32BITS&&(this.localHeaderOffset=a.readInt(8)),this.diskNumberStart===y.MAX_VALUE_32BITS&&(this.diskNumberStart=a.readInt(4))}},readExtraFields:function(c){var a=c.index+this.extraFieldsLength,r,t,i;for(this.extraFields||(this.extraFields={});c.index+4"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,h=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,l=v||h||Function("return this")(),d=Object.prototype,s=d.toString,m=l.Symbol,c=m?m.prototype:void 0,a=c?c.toString:void 0;function r(p){if(typeof p=="string")return p;if(i(p))return a?a.call(p):"";var O=p+"";return O=="0"&&1/p==-g?"-0":O}function t(p){return!!p&&y(p)=="object"}function i(p){return y(p)=="symbol"||t(p)&&s.call(p)==b}function n(p){return p==null?"":r(p)}function o(p){return p=n(p),p&&f.test(p)?p.replace(w,"\\$&"):p}S.exports=o}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],427:[function(e,S,_){(function(u){function y(le){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(Xe){return typeof Xe}:y=function(Xe){return Xe&&typeof Symbol=="function"&&Xe.constructor===Symbol&&Xe!==Symbol.prototype?"symbol":typeof Xe},y(le)}var g=200,b="Expected a function",w="__lodash_hash_undefined__",f=1,v=2,h=1/0,l=9007199254740991,d="[object Arguments]",s="[object Array]",m="[object Boolean]",c="[object Date]",a="[object Error]",r="[object Function]",t="[object GeneratorFunction]",i="[object Map]",n="[object Number]",o="[object Object]",p="[object Promise]",O="[object RegExp]",P="[object Set]",B="[object String]",z="[object Symbol]",D="[object WeakMap]",M="[object ArrayBuffer]",I="[object DataView]",T="[object Float32Array]",C="[object Float64Array]",E="[object Int8Array]",A="[object Int16Array]",L="[object Int32Array]",$="[object Uint8Array]",W="[object Uint8ClampedArray]",U="[object Uint16Array]",N="[object Uint32Array]",j=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,F=/^\w*$/,V=/^\./,re=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ee=/[\\^$.*+?()[\]{}|]/g,ce=/\\(\\)?/g,ye=/^\[object .+?Constructor\]$/,ge=/^(?:0|[1-9]\d*)$/,oe={};oe[T]=oe[C]=oe[E]=oe[A]=oe[L]=oe[$]=oe[W]=oe[U]=oe[N]=!0,oe[d]=oe[s]=oe[M]=oe[m]=oe[I]=oe[c]=oe[a]=oe[r]=oe[i]=oe[n]=oe[o]=oe[O]=oe[P]=oe[B]=oe[D]=!1;var J=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,Q=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,he=J||Q||Function("return this")(),xe=(typeof _>"u"?"undefined":y(_))=="object"&&_&&!_.nodeType&&_,ne=xe&&(typeof S>"u"?"undefined":y(S))=="object"&&S&&!S.nodeType&&S,se=ne&&ne.exports===xe,Ce=se&&J.process,q=function(){try{return Ce&&Ce.binding("util")}catch{}}(),G=q&&q.isTypedArray;function Y(le,Oe,Xe,ft){for(var Tt=-1,mt=le?le.length:0;++Tt-1}function Yr(le,Oe){var Xe=this.__data__,ft=zr(Xe,le);return ft<0?Xe.push([le,Oe]):Xe[ft][1]=Oe,this}Et.prototype.clear=Nr,Et.prototype.delete=Or,Et.prototype.get=Gr,Et.prototype.has=Dr,Et.prototype.set=Yr;function Qt(le){var Oe=-1,Xe=le?le.length:0;for(this.clear();++Oeir))return!1;var _r=mt.get(le);if(_r&&mt.get(Oe))return _r==Oe;var Tr=-1,wr=!0,Rr=Tt&f?new Ke:void 0;for(mt.set(le,Oe),mt.set(Oe,le);++Tr-1&&le%1==0&&le-1&&le%1==0&&le<=l}function dr(le){var Oe=y(le);return!!le&&(Oe=="object"||Oe=="function")}function Er(le){return!!le&&y(le)=="object"}function Ar(le){return y(le)=="symbol"||Er(le)&&pe.call(le)==z}var pr=G?je(G):Wi;function pn(le){return le==null?"":wa(le)}function mr(le,Oe,Xe){var ft=le==null?void 0:yi(le,Oe);return ft===void 0?Xe:ft}function ta(le,Oe){return le!=null&&Ji(le,Oe,dn)}function En(le){return tr(le)?rn(le):jn(le)}function Zr(le){return le}function ra(le){return er(le)?we(Ne(le)):Sn(le)}S.exports=ht}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],428:[function(e,S,_){function u(v){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(l){return typeof l}:u=function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},u(v)}var y="[object Boolean]",g=Object.prototype,b=g.toString;function w(v){return v===!0||v===!1||f(v)&&b.call(v)==y}function f(v){return!!v&&u(v)=="object"}S.exports=w},{}],429:[function(e,S,_){(function(u){function y(Se){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(Je){return typeof Je}:y=function(Je){return Je&&typeof Symbol=="function"&&Je.constructor===Symbol&&Je!==Symbol.prototype?"symbol":typeof Je},y(Se)}var g=200,b="__lodash_hash_undefined__",w=1,f=2,v=9007199254740991,h="[object Arguments]",l="[object Array]",d="[object AsyncFunction]",s="[object Boolean]",m="[object Date]",c="[object Error]",a="[object Function]",r="[object GeneratorFunction]",t="[object Map]",i="[object Number]",n="[object Null]",o="[object Object]",p="[object Promise]",O="[object Proxy]",P="[object RegExp]",B="[object Set]",z="[object String]",D="[object Symbol]",M="[object Undefined]",I="[object WeakMap]",T="[object ArrayBuffer]",C="[object DataView]",E="[object Float32Array]",A="[object Float64Array]",L="[object Int8Array]",$="[object Int16Array]",W="[object Int32Array]",U="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",F="[object Uint32Array]",V=/[\\^$.*+?()[\]{}|]/g,re=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,ce={};ce[E]=ce[A]=ce[L]=ce[$]=ce[W]=ce[U]=ce[N]=ce[j]=ce[F]=!0,ce[h]=ce[l]=ce[T]=ce[s]=ce[C]=ce[m]=ce[c]=ce[a]=ce[t]=ce[i]=ce[o]=ce[P]=ce[B]=ce[z]=ce[I]=!1;var ye=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,ge=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,oe=ye||ge||Function("return this")(),J=(typeof _>"u"?"undefined":y(_))=="object"&&_&&!_.nodeType&&_,Q=J&&(typeof S>"u"?"undefined":y(S))=="object"&&S&&!S.nodeType&&S,he=Q&&Q.exports===J,xe=he&&ye.process,ne=function(){try{return xe&&xe.binding&&xe.binding("util")}catch{}}(),se=ne&&ne.isTypedArray;function Ce(Se,Ne){for(var Je=-1,ht=Se==null?0:Se.length,Yt=0,Mt=[];++Je-1}function Yr(Se,Ne){var Je=this.__data__,ht=zr(Je,Se);return ht<0?(++this.size,Je.push([Se,Ne])):Je[ht][1]=Ne,this}Et.prototype.clear=Nr,Et.prototype.delete=Or,Et.prototype.get=Gr,Et.prototype.has=Dr,Et.prototype.set=Yr;function Qt(Se){var Ne=-1,Je=Se==null?0:Se.length;for(this.clear();++Nenr))return!1;var ur=Mt.get(Se);if(ur&&Mt.get(Ne))return ur==Ne;var Pr=-1,Fr=!0,dr=Je&f?new Ke:void 0;for(Mt.set(Se,Ne),Mt.set(Ne,Se);++Pr-1&&Se%1==0&&Se-1&&Se%1==0&&Se<=v}function er(Se){var Ne=y(Se);return Se!=null&&(Ne=="object"||Ne=="function")}function ri(Se){return Se!=null&&y(Se)=="object"}var Qi=se?fe(se):dn;function Oa(Se){return xa(Se)?rn(Se):Bn(Se)}function qi(){return[]}function ea(){return!1}S.exports=On}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],430:[function(e,S,_){(function(u){function y(P){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(z){return typeof z}:y=function(z){return z&&typeof Symbol=="function"&&z.constructor===Symbol&&z!==Symbol.prototype?"symbol":typeof z},y(P)}var g="[object AsyncFunction]",b="[object Function]",w="[object GeneratorFunction]",f="[object Null]",v="[object Proxy]",h="[object Undefined]",l=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,d=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,s=l||d||Function("return this")(),m=Object.prototype,c=m.hasOwnProperty,a=m.toString,r=s.Symbol,t=r?r.toStringTag:void 0;function i(P){return P==null?P===void 0?h:f:t&&t in Object(P)?n(P):o(P)}function n(P){var B=c.call(P,t),z=P[t];try{P[t]=void 0;var D=!0}catch{}var M=a.call(P);return D&&(B?P[t]=z:delete P[t]),M}function o(P){return a.call(P)}function p(P){if(!O(P))return!1;var B=i(P);return B==b||B==w||B==g||B==v}function O(P){var B=y(P);return P!=null&&(B=="object"||B=="function")}S.exports=p}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],431:[function(e,S,_){function u(y){return y==null}S.exports=u},{}],432:[function(e,S,_){function u(y){return y===void 0}S.exports=u},{}],433:[function(e,S,_){(function(u){function y(be){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(pe){return typeof pe}:y=function(pe){return pe&&typeof Symbol=="function"&&pe.constructor===Symbol&&pe!==Symbol.prototype?"symbol":typeof pe},y(be)}var g=200,b="__lodash_hash_undefined__",w=1/0,f="[object Function]",v="[object GeneratorFunction]",h=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,d=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,s=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,m=d||s||Function("return this")();function c(be,Ee){var pe=be?be.length:0;return!!pe&&t(be,Ee,0)>-1}function a(be,Ee,pe){for(var Pe=-1,te=be?be.length:0;++Pe-1}function J(be,Ee){var pe=this.__data__,Pe=fe(pe,be);return Pe<0?pe.push([be,Ee]):pe[Pe][1]=Ee,this}ee.prototype.clear=ce,ee.prototype.delete=ye,ee.prototype.get=ge,ee.prototype.has=oe,ee.prototype.set=J;function Q(be){var Ee=-1,pe=be?be.length:0;for(this.clear();++Ee=g){var Le=Ee?null:je(be);if(Le)return O(Le);it=!1,te=n,Me=new q}else Me=Ee?[]:K;e:for(;++Pe56&&(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 s=g.allocUnsafe(16);return s.writeInt32LE(this._a,0),s.writeInt32LE(this._b,4),s.writeInt32LE(this._c,8),s.writeInt32LE(this._d,12),s};function f(s,m){return s<>>32-m}function v(s,m,c,a,r,t,i){return f(s+(m&c|~m&a)+r+t|0,i)+m|0}function h(s,m,c,a,r,t,i){return f(s+(m&a|c&~a)+r+t|0,i)+m|0}function l(s,m,c,a,r,t,i){return f(s+(m^c^a)+r+t|0,i)+m|0}function d(s,m,c,a,r,t,i){return f(s+(c^(m|~a))+r+t|0,i)+m|0}S.exports=w},{"hash-base":370,inherits:387,"safe-buffer":494}],435:[function(e,S,_){var u=e("bn.js"),y=e("brorand");function g(b){this.rand=b||new y.Rand}S.exports=g,g.create=function(w){return new g(w)},g.prototype._randbelow=function(w){var f=w.bitLength(),v=Math.ceil(f/8);do var h=new u(this.rand.generate(v));while(h.cmp(w)>=0);return h},g.prototype._randrange=function(w,f){var v=f.sub(w);return w.add(this._randbelow(v))},g.prototype.test=function(w,f,v){var h=w.bitLength(),l=u.mont(w),d=new u(1).toRed(l);f||(f=Math.max(1,h/48|0));for(var s=w.subn(1),m=0;!s.testn(m);m++);for(var c=w.shrn(m),a=s.toRed(l),r=!0;f>0;f--){var t=this._randrange(new u(2),s);v&&v(t);var i=t.toRed(l).redPow(c);if(!(i.cmp(d)===0||i.cmp(a)===0)){for(var n=1;n0;f--){var a=this._randrange(new u(2),d),r=w.gcd(a);if(r.cmpn(1)!==0)return r;var t=a.toRed(h).redPow(m);if(!(t.cmp(l)===0||t.cmp(c)===0)){for(var i=1;i>8,s=l&255;d?v.push(d,s):v.push(s)}return v}u.toArray=y;function g(w){return w.length===1?"0"+w:w}u.zero2=g;function b(w){for(var f="",v=0;v0?p.windowBits=-p.windowBits:p.gzip&&p.windowBits>0&&p.windowBits<16&&(p.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new w,this.strm.avail_out=0;var O=u.deflateInit2(this.strm,p.level,p.method,p.windowBits,p.memLevel,p.strategy);if(O!==l)throw new Error(b[O]);if(p.header&&u.deflateSetHeader(this.strm,p.header),p.dictionary){var P;if(typeof p.dictionary=="string"?P=g.string2buf(p.dictionary):f.call(p.dictionary)==="[object ArrayBuffer]"?P=new Uint8Array(p.dictionary):P=p.dictionary,O=u.deflateSetDictionary(this.strm,P),O!==l)throw new Error(b[O]);this._dict_set=!0}}r.prototype.push=function(o,p){var O=this.strm,P=this.options.chunkSize,B,z;if(this.ended)return!1;z=p===~~p?p:p===!0?h:v,typeof o=="string"?O.input=g.string2buf(o):f.call(o)==="[object ArrayBuffer]"?O.input=new Uint8Array(o):O.input=o,O.next_in=0,O.avail_in=O.input.length;do{if(O.avail_out===0&&(O.output=new y.Buf8(P),O.next_out=0,O.avail_out=P),B=u.deflate(O,z),B!==d&&B!==l)return this.onEnd(B),this.ended=!0,!1;(O.avail_out===0||O.avail_in===0&&(z===h||z===s))&&(this.options.to==="string"?this.onData(g.buf2binstring(y.shrinkBuf(O.output,O.next_out))):this.onData(y.shrinkBuf(O.output,O.next_out)))}while((O.avail_in>0||O.avail_out===0)&&B!==d);return z===h?(B=u.deflateEnd(this.strm),this.onEnd(B),this.ended=!0,B===l):(z===s&&(this.onEnd(l),O.avail_out=0),!0)},r.prototype.onData=function(o){this.chunks.push(o)},r.prototype.onEnd=function(o){o===l&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=y.flattenChunks(this.chunks)),this.chunks=[],this.err=o,this.msg=this.strm.msg};function t(o,p){var O=new r(p);if(O.push(o,!0),O.err)throw O.msg||b[O.err];return O.result}function i(o,p){return p=p||{},p.raw=!0,t(o,p)}function n(o,p){return p=p||{},p.gzip=!0,t(o,p)}_.Deflate=r,_.deflate=t,_.deflateRaw=i,_.gzip=n},{"./utils/common":442,"./utils/strings":443,"./zlib/deflate":447,"./zlib/messages":452,"./zlib/zstream":454}],441:[function(e,S,_){var u=e("./zlib/inflate"),y=e("./utils/common"),g=e("./utils/strings"),b=e("./zlib/constants"),w=e("./zlib/messages"),f=e("./zlib/zstream"),v=e("./zlib/gzheader"),h=Object.prototype.toString;function l(m){if(!(this instanceof l))return new l(m);this.options=y.assign({chunkSize:16384,windowBits:0,to:""},m||{});var c=this.options;c.raw&&c.windowBits>=0&&c.windowBits<16&&(c.windowBits=-c.windowBits,c.windowBits===0&&(c.windowBits=-15)),c.windowBits>=0&&c.windowBits<16&&!(m&&m.windowBits)&&(c.windowBits+=32),c.windowBits>15&&c.windowBits<48&&(c.windowBits&15||(c.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;var a=u.inflateInit2(this.strm,c.windowBits);if(a!==b.Z_OK)throw new Error(w[a]);if(this.header=new v,u.inflateGetHeader(this.strm,this.header),c.dictionary&&(typeof c.dictionary=="string"?c.dictionary=g.string2buf(c.dictionary):h.call(c.dictionary)==="[object ArrayBuffer]"&&(c.dictionary=new Uint8Array(c.dictionary)),c.raw&&(a=u.inflateSetDictionary(this.strm,c.dictionary),a!==b.Z_OK)))throw new Error(w[a])}l.prototype.push=function(m,c){var a=this.strm,r=this.options.chunkSize,t=this.options.dictionary,i,n,o,p,O,P=!1;if(this.ended)return!1;n=c===~~c?c:c===!0?b.Z_FINISH:b.Z_NO_FLUSH,typeof m=="string"?a.input=g.binstring2buf(m):h.call(m)==="[object ArrayBuffer]"?a.input=new Uint8Array(m):a.input=m,a.next_in=0,a.avail_in=a.input.length;do{if(a.avail_out===0&&(a.output=new y.Buf8(r),a.next_out=0,a.avail_out=r),i=u.inflate(a,b.Z_NO_FLUSH),i===b.Z_NEED_DICT&&t&&(i=u.inflateSetDictionary(this.strm,t)),i===b.Z_BUF_ERROR&&P===!0&&(i=b.Z_OK,P=!1),i!==b.Z_STREAM_END&&i!==b.Z_OK)return this.onEnd(i),this.ended=!0,!1;a.next_out&&(a.avail_out===0||i===b.Z_STREAM_END||a.avail_in===0&&(n===b.Z_FINISH||n===b.Z_SYNC_FLUSH))&&(this.options.to==="string"?(o=g.utf8border(a.output,a.next_out),p=a.next_out-o,O=g.buf2string(a.output,o),a.next_out=p,a.avail_out=r-p,p&&y.arraySet(a.output,a.output,o,p,0),this.onData(O)):this.onData(y.shrinkBuf(a.output,a.next_out))),a.avail_in===0&&a.avail_out===0&&(P=!0)}while((a.avail_in>0||a.avail_out===0)&&i!==b.Z_STREAM_END);return i===b.Z_STREAM_END&&(n=b.Z_FINISH),n===b.Z_FINISH?(i=u.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===b.Z_OK):(n===b.Z_SYNC_FLUSH&&(this.onEnd(b.Z_OK),a.avail_out=0),!0)},l.prototype.onData=function(m){this.chunks.push(m)},l.prototype.onEnd=function(m){m===b.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=y.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg};function d(m,c){var a=new l(c);if(a.push(m,!0),a.err)throw a.msg||w[a.err];return a.result}function s(m,c){return c=c||{},c.raw=!0,d(m,c)}_.Inflate=l,_.inflate=d,_.inflateRaw=s,_.ungzip=d},{"./utils/common":442,"./utils/strings":443,"./zlib/constants":445,"./zlib/gzheader":448,"./zlib/inflate":450,"./zlib/messages":452,"./zlib/zstream":454}],442:[function(e,S,_){function u(f){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(h){return typeof h}:u=function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},u(f)}var y=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function g(f,v){return Object.prototype.hasOwnProperty.call(f,v)}_.assign=function(f){for(var v=Array.prototype.slice.call(arguments,1);v.length;){var h=v.shift();if(h){if(u(h)!=="object")throw new TypeError(h+"must be non-object");for(var l in h)g(h,l)&&(f[l]=h[l])}}return f},_.shrinkBuf=function(f,v){return f.length===v?f:f.subarray?f.subarray(0,v):(f.length=v,f)};var b={arraySet:function(v,h,l,d,s){if(h.subarray&&v.subarray){v.set(h.subarray(l,l+d),s);return}for(var m=0;m=252?6:w>=248?5:w>=240?4:w>=224?3:w>=192?2:1;b[254]=b[254]=1,_.string2buf=function(v){var h,l,d,s,m,c=v.length,a=0;for(s=0;s>>6,h[m++]=128|l&63):l<65536?(h[m++]=224|l>>>12,h[m++]=128|l>>>6&63,h[m++]=128|l&63):(h[m++]=240|l>>>18,h[m++]=128|l>>>12&63,h[m++]=128|l>>>6&63,h[m++]=128|l&63);return h};function f(v,h){if(h<65534&&(v.subarray&&g||!v.subarray&&y))return String.fromCharCode.apply(null,u.shrinkBuf(v,h));for(var l="",d=0;d4){a[d++]=65533,l+=m-1;continue}for(s&=m===2?31:m===3?15:7;m>1&&l1){a[d++]=65533;continue}s<65536?a[d++]=s:(s-=65536,a[d++]=55296|s>>10&1023,a[d++]=56320|s&1023)}return f(a,d)},_.utf8border=function(v,h){var l;for(h=h||v.length,h>v.length&&(h=v.length),l=h-1;l>=0&&(v[l]&192)===128;)l--;return l<0||l===0?h:l+b[v[l]]>h?l:h}},{"./common":442}],444:[function(e,S,_){function u(y,g,b,w){for(var f=y&65535|0,v=y>>>16&65535|0,h=0;b!==0;){h=b>2e3?2e3:b,b-=h;do f=f+g[w++]|0,v=v+f|0;while(--h);f%=65521,v%=65521}return f|v<<16|0}S.exports=u},{}],445:[function(e,S,_){S.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],446:[function(e,S,_){function u(){for(var b,w=[],f=0;f<256;f++){b=f;for(var v=0;v<8;v++)b=b&1?3988292384^b>>>1:b>>>1;w[f]=b}return w}var y=u();function g(b,w,f,v){var h=y,l=v+f;b^=-1;for(var d=v;d>>8^h[(b^w[d])&255];return b^-1}S.exports=g},{}],447:[function(e,S,_){var u=e("../utils/common"),y=e("./trees"),g=e("./adler32"),b=e("./crc32"),w=e("./messages"),f=0,v=1,h=3,l=4,d=5,s=0,m=1,c=-2,a=-3,r=-5,t=-1,i=1,n=2,o=3,p=4,O=0,P=2,B=8,z=9,D=15,M=8,I=29,T=256,C=T+1+I,E=30,A=19,L=2*C+1,$=15,W=3,U=258,N=U+W+1,j=32,F=42,V=69,re=73,ee=91,ce=103,ye=113,ge=666,oe=1,J=2,Q=3,he=4,xe=3;function ne(K,Me){return K.msg=w[Me],Me}function se(K){return(K<<1)-(K>4?9:0)}function Ce(K){for(var Me=K.length;--Me>=0;)K[Me]=0}function q(K){var Me=K.state,Le=Me.pending;Le>K.avail_out&&(Le=K.avail_out),Le!==0&&(u.arraySet(K.output,Me.pending_buf,Me.pending_out,Le,K.next_out),K.next_out+=Le,Me.pending_out+=Le,K.total_out+=Le,K.avail_out-=Le,Me.pending-=Le,Me.pending===0&&(Me.pending_out=0))}function G(K,Me){y._tr_flush_block(K,K.block_start>=0?K.block_start:-1,K.strstart-K.block_start,Me),K.block_start=K.strstart,q(K.strm)}function Y(K,Me){K.pending_buf[K.pending++]=Me}function fe(K,Me){K.pending_buf[K.pending++]=Me>>>8&255,K.pending_buf[K.pending++]=Me&255}function we(K,Me,Le,ue){var ke=K.avail_in;return ke>ue&&(ke=ue),ke===0?0:(K.avail_in-=ke,u.arraySet(Me,K.input,K.next_in,ke,Le),K.state.wrap===1?K.adler=g(K.adler,Me,ke,Le):K.state.wrap===2&&(K.adler=b(K.adler,Me,ke,Le)),K.next_in+=ke,K.total_in+=ke,ke)}function _e(K,Me){var Le=K.max_chain_length,ue=K.strstart,ke,Ie,st=K.prev_length,Ge=K.nice_match,rt=K.strstart>K.w_size-N?K.strstart-(K.w_size-N):0,_t=K.window,wt=K.w_mask,Ot=K.prev,pt=K.strstart+U,ct=_t[ue+st-1],At=_t[ue+st];K.prev_length>=K.good_match&&(Le>>=2),Ge>K.lookahead&&(Ge=K.lookahead);do if(ke=Me,!(_t[ke+st]!==At||_t[ke+st-1]!==ct||_t[ke]!==_t[ue]||_t[++ke]!==_t[ue+1])){ue+=2,ke++;do;while(_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&uest){if(K.match_start=Me,st=Ie,Ie>=Ge)break;ct=_t[ue+st-1],At=_t[ue+st]}}while((Me=Ot[Me&wt])>rt&&--Le!==0);return st<=K.lookahead?st:K.lookahead}function je(K){var Me=K.w_size,Le,ue,ke,Ie,st;do{if(Ie=K.window_size-K.lookahead-K.strstart,K.strstart>=Me+(Me-N)){u.arraySet(K.window,K.window,Me,Me,0),K.match_start-=Me,K.strstart-=Me,K.block_start-=Me,ue=K.hash_size,Le=ue;do ke=K.head[--Le],K.head[Le]=ke>=Me?ke-Me:0;while(--ue);ue=Me,Le=ue;do ke=K.prev[--Le],K.prev[Le]=ke>=Me?ke-Me:0;while(--ue);Ie+=Me}if(K.strm.avail_in===0)break;if(ue=we(K.strm,K.window,K.strstart+K.lookahead,Ie),K.lookahead+=ue,K.lookahead+K.insert>=W)for(st=K.strstart-K.insert,K.ins_h=K.window[st],K.ins_h=(K.ins_h<K.pending_buf_size-5&&(Le=K.pending_buf_size-5);;){if(K.lookahead<=1){if(je(K),K.lookahead===0&&Me===f)return oe;if(K.lookahead===0)break}K.strstart+=K.lookahead,K.lookahead=0;var ue=K.block_start+Le;if((K.strstart===0||K.strstart>=ue)&&(K.lookahead=K.strstart-ue,K.strstart=ue,G(K,!1),K.strm.avail_out===0)||K.strstart-K.block_start>=K.w_size-N&&(G(K,!1),K.strm.avail_out===0))return oe}return K.insert=0,Me===l?(G(K,!0),K.strm.avail_out===0?Q:he):(K.strstart>K.block_start&&(G(K,!1),K.strm.avail_out===0),oe)}function nt(K,Me){for(var Le,ue;;){if(K.lookahead=W&&(K.ins_h=(K.ins_h<=W)if(ue=y._tr_tally(K,K.strstart-K.match_start,K.match_length-W),K.lookahead-=K.match_length,K.match_length<=K.max_lazy_match&&K.lookahead>=W){K.match_length--;do K.strstart++,K.ins_h=(K.ins_h<=W&&(K.ins_h=(K.ins_h<4096)&&(K.match_length=W-1)),K.prev_length>=W&&K.match_length<=K.prev_length){ke=K.strstart+K.lookahead-W,ue=y._tr_tally(K,K.strstart-1-K.prev_match,K.prev_length-W),K.lookahead-=K.prev_length-1,K.prev_length-=2;do++K.strstart<=ke&&(K.ins_h=(K.ins_h<=W&&K.strstart>0&&(ke=K.strstart-1,ue=st[ke],ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke])){Ie=K.strstart+U;do;while(ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&keK.lookahead&&(K.match_length=K.lookahead)}if(K.match_length>=W?(Le=y._tr_tally(K,1,K.match_length-W),K.lookahead-=K.match_length,K.strstart+=K.match_length,K.match_length=0):(Le=y._tr_tally(K,0,K.window[K.strstart]),K.lookahead--,K.strstart++),Le&&(G(K,!1),K.strm.avail_out===0))return oe}return K.insert=0,Me===l?(G(K,!0),K.strm.avail_out===0?Q:he):K.last_lit&&(G(K,!1),K.strm.avail_out===0)?oe:J}function Ue(K,Me){for(var Le;;){if(K.lookahead===0&&(je(K),K.lookahead===0)){if(Me===f)return oe;break}if(K.match_length=0,Le=y._tr_tally(K,0,K.window[K.strstart]),K.lookahead--,K.strstart++,Le&&(G(K,!1),K.strm.avail_out===0))return oe}return K.insert=0,Me===l?(G(K,!0),K.strm.avail_out===0?Q:he):K.last_lit&&(G(K,!1),K.strm.avail_out===0)?oe:J}function Ve(K,Me,Le,ue,ke){this.good_length=K,this.max_lazy=Me,this.nice_length=Le,this.max_chain=ue,this.func=ke}var Qe;Qe=[new Ve(0,0,0,0,Ye),new Ve(4,4,8,4,nt),new Ve(4,5,16,8,nt),new Ve(4,6,32,32,nt),new Ve(4,4,16,16,ut),new Ve(8,16,32,32,ut),new Ve(8,16,128,128,ut),new Ve(8,32,128,256,ut),new Ve(32,128,258,1024,ut),new Ve(32,258,258,4096,ut)];function tt(K){K.window_size=2*K.w_size,Ce(K.head),K.max_lazy_match=Qe[K.level].max_lazy,K.good_match=Qe[K.level].good_length,K.nice_match=Qe[K.level].nice_length,K.max_chain_length=Qe[K.level].max_chain,K.strstart=0,K.block_start=0,K.lookahead=0,K.insert=0,K.match_length=K.prev_length=W-1,K.match_available=0,K.ins_h=0}function ae(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=B,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new u.Buf16(L*2),this.dyn_dtree=new u.Buf16((2*E+1)*2),this.bl_tree=new u.Buf16((2*A+1)*2),Ce(this.dyn_ltree),Ce(this.dyn_dtree),Ce(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new u.Buf16($+1),this.heap=new u.Buf16(2*C+1),Ce(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new u.Buf16(2*C+1),Ce(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Re(K){var Me;return!K||!K.state?ne(K,c):(K.total_in=K.total_out=0,K.data_type=P,Me=K.state,Me.pending=0,Me.pending_out=0,Me.wrap<0&&(Me.wrap=-Me.wrap),Me.status=Me.wrap?F:ye,K.adler=Me.wrap===2?0:1,Me.last_flush=f,y._tr_init(Me),s)}function be(K){var Me=Re(K);return Me===s&&tt(K.state),Me}function Ee(K,Me){return!K||!K.state||K.state.wrap!==2?c:(K.state.gzhead=Me,s)}function pe(K,Me,Le,ue,ke,Ie){if(!K)return c;var st=1;if(Me===t&&(Me=6),ue<0?(st=0,ue=-ue):ue>15&&(st=2,ue-=16),ke<1||ke>z||Le!==B||ue<8||ue>15||Me<0||Me>9||Ie<0||Ie>p)return ne(K,c);ue===8&&(ue=9);var Ge=new ae;return K.state=Ge,Ge.strm=K,Ge.wrap=st,Ge.gzhead=null,Ge.w_bits=ue,Ge.w_size=1<d||Me<0)return K?ne(K,c):c;if(ue=K.state,!K.output||!K.input&&K.avail_in!==0||ue.status===ge&&Me!==l)return ne(K,K.avail_out===0?r:c);if(ue.strm=K,Le=ue.last_flush,ue.last_flush=Me,ue.status===F)if(ue.wrap===2)K.adler=0,Y(ue,31),Y(ue,139),Y(ue,8),ue.gzhead?(Y(ue,(ue.gzhead.text?1:0)+(ue.gzhead.hcrc?2:0)+(ue.gzhead.extra?4:0)+(ue.gzhead.name?8:0)+(ue.gzhead.comment?16:0)),Y(ue,ue.gzhead.time&255),Y(ue,ue.gzhead.time>>8&255),Y(ue,ue.gzhead.time>>16&255),Y(ue,ue.gzhead.time>>24&255),Y(ue,ue.level===9?2:ue.strategy>=n||ue.level<2?4:0),Y(ue,ue.gzhead.os&255),ue.gzhead.extra&&ue.gzhead.extra.length&&(Y(ue,ue.gzhead.extra.length&255),Y(ue,ue.gzhead.extra.length>>8&255)),ue.gzhead.hcrc&&(K.adler=b(K.adler,ue.pending_buf,ue.pending,0)),ue.gzindex=0,ue.status=V):(Y(ue,0),Y(ue,0),Y(ue,0),Y(ue,0),Y(ue,0),Y(ue,ue.level===9?2:ue.strategy>=n||ue.level<2?4:0),Y(ue,xe),ue.status=ye);else{var st=B+(ue.w_bits-8<<4)<<8,Ge=-1;ue.strategy>=n||ue.level<2?Ge=0:ue.level<6?Ge=1:ue.level===6?Ge=2:Ge=3,st|=Ge<<6,ue.strstart!==0&&(st|=j),st+=31-st%31,ue.status=ye,fe(ue,st),ue.strstart!==0&&(fe(ue,K.adler>>>16),fe(ue,K.adler&65535)),K.adler=1}if(ue.status===V)if(ue.gzhead.extra){for(ke=ue.pending;ue.gzindex<(ue.gzhead.extra.length&65535)&&!(ue.pending===ue.pending_buf_size&&(ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),q(K),ke=ue.pending,ue.pending===ue.pending_buf_size));)Y(ue,ue.gzhead.extra[ue.gzindex]&255),ue.gzindex++;ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),ue.gzindex===ue.gzhead.extra.length&&(ue.gzindex=0,ue.status=re)}else ue.status=re;if(ue.status===re)if(ue.gzhead.name){ke=ue.pending;do{if(ue.pending===ue.pending_buf_size&&(ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),q(K),ke=ue.pending,ue.pending===ue.pending_buf_size)){Ie=1;break}ue.gzindexke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),Ie===0&&(ue.gzindex=0,ue.status=ee)}else ue.status=ee;if(ue.status===ee)if(ue.gzhead.comment){ke=ue.pending;do{if(ue.pending===ue.pending_buf_size&&(ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),q(K),ke=ue.pending,ue.pending===ue.pending_buf_size)){Ie=1;break}ue.gzindexke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),Ie===0&&(ue.status=ce)}else ue.status=ce;if(ue.status===ce&&(ue.gzhead.hcrc?(ue.pending+2>ue.pending_buf_size&&q(K),ue.pending+2<=ue.pending_buf_size&&(Y(ue,K.adler&255),Y(ue,K.adler>>8&255),K.adler=0,ue.status=ye)):ue.status=ye),ue.pending!==0){if(q(K),K.avail_out===0)return ue.last_flush=-1,s}else if(K.avail_in===0&&se(Me)<=se(Le)&&Me!==l)return ne(K,r);if(ue.status===ge&&K.avail_in!==0)return ne(K,r);if(K.avail_in!==0||ue.lookahead!==0||Me!==f&&ue.status!==ge){var rt=ue.strategy===n?Ue(ue,Me):ue.strategy===o?ot(ue,Me):Qe[ue.level].func(ue,Me);if((rt===Q||rt===he)&&(ue.status=ge),rt===oe||rt===Q)return K.avail_out===0&&(ue.last_flush=-1),s;if(rt===J&&(Me===v?y._tr_align(ue):Me!==d&&(y._tr_stored_block(ue,0,0,!1),Me===h&&(Ce(ue.head),ue.lookahead===0&&(ue.strstart=0,ue.block_start=0,ue.insert=0))),q(K),K.avail_out===0))return ue.last_flush=-1,s}return Me!==l?s:ue.wrap<=0?m:(ue.wrap===2?(Y(ue,K.adler&255),Y(ue,K.adler>>8&255),Y(ue,K.adler>>16&255),Y(ue,K.adler>>24&255),Y(ue,K.total_in&255),Y(ue,K.total_in>>8&255),Y(ue,K.total_in>>16&255),Y(ue,K.total_in>>24&255)):(fe(ue,K.adler>>>16),fe(ue,K.adler&65535)),q(K),ue.wrap>0&&(ue.wrap=-ue.wrap),ue.pending!==0?s:m)}function He(K){var Me;return!K||!K.state?c:(Me=K.state.status,Me!==F&&Me!==V&&Me!==re&&Me!==ee&&Me!==ce&&Me!==ye&&Me!==ge?ne(K,c):(K.state=null,Me===ye?ne(K,a):s))}function it(K,Me){var Le=Me.length,ue,ke,Ie,st,Ge,rt,_t,wt;if(!K||!K.state||(ue=K.state,st=ue.wrap,st===2||st===1&&ue.status!==F||ue.lookahead))return c;for(st===1&&(K.adler=g(K.adler,Me,Le,0)),ue.wrap=0,Le>=ue.w_size&&(st===0&&(Ce(ue.head),ue.strstart=0,ue.block_start=0,ue.insert=0),wt=new u.Buf8(ue.w_size),u.arraySet(wt,Me,Le-ue.w_size,ue.w_size,0),Me=wt,Le=ue.w_size),Ge=K.avail_in,rt=K.next_in,_t=K.input,K.avail_in=Le,K.next_in=0,K.input=Me,je(ue);ue.lookahead>=W;){ke=ue.strstart,Ie=ue.lookahead-(W-1);do ue.ins_h=(ue.ins_h<>>24,i>>>=z,n-=z,z=B>>>16&255,z===0)E[l++]=B&65535;else if(z&16){D=B&65535,z&=15,z&&(n>>=z,n-=z),n<15&&(i+=C[v++]<>>24,i>>>=z,n-=z,z=B>>>16&255,z&16){if(M=B&65535,z&=15,nm){b.msg="invalid distance too far back",f.mode=u;break e}if(i>>>=z,n-=z,z=l-d,M>z){if(z=M-z,z>a&&f.sane){b.msg="invalid distance too far back",f.mode=u;break e}if(I=0,T=t,r===0){if(I+=c-z,z2;)E[l++]=T[I++],E[l++]=T[I++],E[l++]=T[I++],D-=3;D&&(E[l++]=T[I++],D>1&&(E[l++]=T[I++]))}else{I=l-M;do E[l++]=E[I++],E[l++]=E[I++],E[l++]=E[I++],D-=3;while(D>2);D&&(E[l++]=E[I++],D>1&&(E[l++]=E[I++]))}}else if(z&64){b.msg="invalid distance code",f.mode=u;break e}else{B=p[(B&65535)+(i&(1<>3,v-=D,n-=D<<3,i&=(1<>>24&255)+(pe>>>8&65280)+((pe&65280)<<8)+((pe&255)<<24)}function we(){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 u.Buf16(320),this.work=new u.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _e(pe){var Pe;return!pe||!pe.state?r:(Pe=pe.state,pe.total_in=pe.total_out=Pe.total=0,pe.msg="",Pe.wrap&&(pe.adler=Pe.wrap&1),Pe.mode=p,Pe.last=0,Pe.havedict=0,Pe.dmax=32768,Pe.head=null,Pe.hold=0,Pe.bits=0,Pe.lencode=Pe.lendyn=new u.Buf32(Ce),Pe.distcode=Pe.distdyn=new u.Buf32(q),Pe.sane=1,Pe.back=-1,m)}function je(pe){var Pe;return!pe||!pe.state?r:(Pe=pe.state,Pe.wsize=0,Pe.whave=0,Pe.wnext=0,_e(pe))}function Ye(pe,Pe){var te,He;return!pe||!pe.state||(He=pe.state,Pe<0?(te=0,Pe=-Pe):(te=(Pe>>4)+1,Pe<48&&(Pe&=15)),Pe&&(Pe<8||Pe>15))?r:(He.window!==null&&He.wbits!==Pe&&(He.window=null),He.wrap=te,He.wbits=Pe,je(pe))}function nt(pe,Pe){var te,He;return pe?(He=new we,pe.state=He,He.window=null,te=Ye(pe,Pe),te!==m&&(pe.state=null),te):r}function ut(pe){return nt(pe,Y)}var ot=!0,Ue,Ve;function Qe(pe){if(ot){var Pe;for(Ue=new u.Buf32(512),Ve=new u.Buf32(32),Pe=0;Pe<144;)pe.lens[Pe++]=8;for(;Pe<256;)pe.lens[Pe++]=9;for(;Pe<280;)pe.lens[Pe++]=7;for(;Pe<288;)pe.lens[Pe++]=8;for(w(v,pe.lens,0,288,Ue,0,pe.work,{bits:9}),Pe=0;Pe<32;)pe.lens[Pe++]=5;w(h,pe.lens,0,32,Ve,0,pe.work,{bits:5}),ot=!1}pe.lencode=Ue,pe.lenbits=9,pe.distcode=Ve,pe.distbits=5}function tt(pe,Pe,te,He){var it,K=pe.state;return K.window===null&&(K.wsize=1<=K.wsize?(u.arraySet(K.window,Pe,te-K.wsize,K.wsize,0),K.wnext=0,K.whave=K.wsize):(it=K.wsize-K.wnext,it>He&&(it=He),u.arraySet(K.window,Pe,te-He,it,K.wnext),He-=it,He?(u.arraySet(K.window,Pe,te-He,He,0),K.wnext=He,K.whave=K.wsize):(K.wnext+=it,K.wnext===K.wsize&&(K.wnext=0),K.whave>>8&255,te.check=g(te.check,Bt,2,0),ke=0,Ie=0,te.mode=O;break}if(te.flags=0,te.head&&(te.head.done=!1),!(te.wrap&1)||(((ke&255)<<8)+(ke>>8))%31){pe.msg="incorrect header check",te.mode=xe;break}if((ke&15)!==o){pe.msg="unknown compression method",te.mode=xe;break}if(ke>>>=4,Ie-=4,Ct=(ke&15)+8,te.wbits===0)te.wbits=Ct;else if(Ct>te.wbits){pe.msg="invalid window size",te.mode=xe;break}te.dmax=1<>8&1),te.flags&512&&(Bt[0]=ke&255,Bt[1]=ke>>>8&255,te.check=g(te.check,Bt,2,0)),ke=0,Ie=0,te.mode=P;case P:for(;Ie<32;){if(Le===0)break e;Le--,ke+=He[K++]<>>8&255,Bt[2]=ke>>>16&255,Bt[3]=ke>>>24&255,te.check=g(te.check,Bt,4,0)),ke=0,Ie=0,te.mode=B;case B:for(;Ie<16;){if(Le===0)break e;Le--,ke+=He[K++]<>8),te.flags&512&&(Bt[0]=ke&255,Bt[1]=ke>>>8&255,te.check=g(te.check,Bt,2,0)),ke=0,Ie=0,te.mode=z;case z:if(te.flags&1024){for(;Ie<16;){if(Le===0)break e;Le--,ke+=He[K++]<>>8&255,te.check=g(te.check,Bt,2,0)),ke=0,Ie=0}else te.head&&(te.head.extra=null);te.mode=D;case D:if(te.flags&1024&&(rt=te.length,rt>Le&&(rt=Le),rt&&(te.head&&(Ct=te.head.extra_len-te.length,te.head.extra||(te.head.extra=new Array(te.head.extra_len)),u.arraySet(te.head.extra,He,K,rt,Ct)),te.flags&512&&(te.check=g(te.check,He,rt,K)),Le-=rt,K+=rt,te.length-=rt),te.length))break e;te.length=0,te.mode=M;case M:if(te.flags&2048){if(Le===0)break e;rt=0;do Ct=He[K+rt++],te.head&&Ct&&te.length<65536&&(te.head.name+=String.fromCharCode(Ct));while(Ct&&rt>9&1,te.head.done=!0),pe.adler=te.check=0,te.mode=A;break;case C:for(;Ie<32;){if(Le===0)break e;Le--,ke+=He[K++]<>>=Ie&7,Ie-=Ie&7,te.mode=J;break}for(;Ie<3;){if(Le===0)break e;Le--,ke+=He[K++]<>>=1,Ie-=1,ke&3){case 0:te.mode=$;break;case 1:if(Qe(te),te.mode=V,Pe===s){ke>>>=2,Ie-=2;break e}break;case 2:te.mode=N;break;case 3:pe.msg="invalid block type",te.mode=xe}ke>>>=2,Ie-=2;break;case $:for(ke>>>=Ie&7,Ie-=Ie&7;Ie<32;){if(Le===0)break e;Le--,ke+=He[K++]<>>16^65535)){pe.msg="invalid stored block lengths",te.mode=xe;break}if(te.length=ke&65535,ke=0,Ie=0,te.mode=W,Pe===s)break e;case W:te.mode=U;case U:if(rt=te.length,rt){if(rt>Le&&(rt=Le),rt>ue&&(rt=ue),rt===0)break e;u.arraySet(it,He,K,rt,Me),Le-=rt,K+=rt,ue-=rt,Me+=rt,te.length-=rt;break}te.mode=A;break;case N:for(;Ie<14;){if(Le===0)break e;Le--,ke+=He[K++]<>>=5,Ie-=5,te.ndist=(ke&31)+1,ke>>>=5,Ie-=5,te.ncode=(ke&15)+4,ke>>>=4,Ie-=4,te.nlen>286||te.ndist>30){pe.msg="too many length or distance symbols",te.mode=xe;break}te.have=0,te.mode=j;case j:for(;te.have>>=3,Ie-=3}for(;te.have<19;)te.lens[Nr[te.have++]]=0;if(te.lencode=te.lendyn,te.lenbits=7,Lt={bits:te.lenbits},St=w(f,te.lens,0,19,te.lencode,0,te.work,Lt),te.lenbits=Lt.bits,St){pe.msg="invalid code lengths set",te.mode=xe;break}te.have=0,te.mode=F;case F:for(;te.have>>24,ct=Ot>>>16&255,At=Ot&65535,!(pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>>=pt,Ie-=pt,te.lens[te.have++]=At;else{if(At===16){for(Et=pt+2;Ie>>=pt,Ie-=pt,te.have===0){pe.msg="invalid bit length repeat",te.mode=xe;break}Ct=te.lens[te.have-1],rt=3+(ke&3),ke>>>=2,Ie-=2}else if(At===17){for(Et=pt+3;Ie>>=pt,Ie-=pt,Ct=0,rt=3+(ke&7),ke>>>=3,Ie-=3}else{for(Et=pt+7;Ie>>=pt,Ie-=pt,Ct=0,rt=11+(ke&127),ke>>>=7,Ie-=7}if(te.have+rt>te.nlen+te.ndist){pe.msg="invalid bit length repeat",te.mode=xe;break}for(;rt--;)te.lens[te.have++]=Ct}}if(te.mode===xe)break;if(te.lens[256]===0){pe.msg="invalid code -- missing end-of-block",te.mode=xe;break}if(te.lenbits=9,Lt={bits:te.lenbits},St=w(v,te.lens,0,te.nlen,te.lencode,0,te.work,Lt),te.lenbits=Lt.bits,St){pe.msg="invalid literal/lengths set",te.mode=xe;break}if(te.distbits=6,te.distcode=te.distdyn,Lt={bits:te.distbits},St=w(h,te.lens,te.nlen,te.ndist,te.distcode,0,te.work,Lt),te.distbits=Lt.bits,St){pe.msg="invalid distances set",te.mode=xe;break}if(te.mode=V,Pe===s)break e;case V:te.mode=re;case re:if(Le>=6&&ue>=258){pe.next_out=Me,pe.avail_out=ue,pe.next_in=K,pe.avail_in=Le,te.hold=ke,te.bits=Ie,b(pe,Ge),Me=pe.next_out,it=pe.output,ue=pe.avail_out,K=pe.next_in,He=pe.input,Le=pe.avail_in,ke=te.hold,Ie=te.bits,te.mode===A&&(te.back=-1);break}for(te.back=0;Ot=te.lencode[ke&(1<>>24,ct=Ot>>>16&255,At=Ot&65535,!(pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>Pt)],pt=Ot>>>24,ct=Ot>>>16&255,At=Ot&65535,!(Pt+pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>>=Pt,Ie-=Pt,te.back+=Pt}if(ke>>>=pt,Ie-=pt,te.back+=pt,te.length=At,ct===0){te.mode=oe;break}if(ct&32){te.back=-1,te.mode=A;break}if(ct&64){pe.msg="invalid literal/length code",te.mode=xe;break}te.extra=ct&15,te.mode=ee;case ee:if(te.extra){for(Et=te.extra;Ie>>=te.extra,Ie-=te.extra,te.back+=te.extra}te.was=te.length,te.mode=ce;case ce:for(;Ot=te.distcode[ke&(1<>>24,ct=Ot>>>16&255,At=Ot&65535,!(pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>Pt)],pt=Ot>>>24,ct=Ot>>>16&255,At=Ot&65535,!(Pt+pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>>=Pt,Ie-=Pt,te.back+=Pt}if(ke>>>=pt,Ie-=pt,te.back+=pt,ct&64){pe.msg="invalid distance code",te.mode=xe;break}te.offset=At,te.extra=ct&15,te.mode=ye;case ye:if(te.extra){for(Et=te.extra;Ie>>=te.extra,Ie-=te.extra,te.back+=te.extra}if(te.offset>te.dmax){pe.msg="invalid distance too far back",te.mode=xe;break}te.mode=ge;case ge:if(ue===0)break e;if(rt=Ge-ue,te.offset>rt){if(rt=te.offset-rt,rt>te.whave&&te.sane){pe.msg="invalid distance too far back",te.mode=xe;break}rt>te.wnext?(rt-=te.wnext,_t=te.wsize-rt):_t=te.wnext-rt,rt>te.length&&(rt=te.length),wt=te.window}else wt=it,_t=Me-te.offset,rt=te.length;rt>ue&&(rt=ue),ue-=rt,te.length-=rt;do it[Me++]=wt[_t++];while(--rt);te.length===0&&(te.mode=re);break;case oe:if(ue===0)break e;it[Me++]=te.length,ue--,te.mode=re;break;case J:if(te.wrap){for(;Ie<32;){if(Le===0)break e;Le--,ke|=He[K++]<=1&&re[D]===0;D--);if(M>D&&(M=D),D===0)return i[n++]=1<<24|64<<16|0,i[n++]=1<<24|64<<16|0,p.bits=1,0;for(z=1;z0&&(c===w||D!==1))return-1;for(ee[1]=0,P=1;Pg||c===v&&E>b)return 1;for(;;){ge=P-T,o[B]V?(oe=ce[ye+o[B]],J=j[F+o[B]]):(oe=32+64,J=0),L=1<>T)+$]=ge<<24|oe<<16|J|0;while($!==0);for(L=1<>=1;if(L!==0?(A&=L-1,A+=L):A=0,B++,--re[P]===0){if(P===D)break;P=a[r+o[B]]}if(P>M&&(A&U)!==W){for(T===0&&(T=M),N+=z,I=P-T,C=1<g||c===v&&E>b)return 1;W=A&U,i[W]=M<<24|I<<16|N-n|0}}return A!==0&&(i[N+A]=P-T<<24|64<<16|0),p.bits=M,0}},{"../utils/common":442}],452:[function(e,S,_){S.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],453:[function(e,S,_){var u=e("../utils/common"),y=4,g=0,b=1,w=2;function f(ae){for(var Re=ae.length;--Re>=0;)ae[Re]=0}var v=0,h=1,l=2,d=3,s=258,m=29,c=256,a=c+1+m,r=30,t=19,i=2*a+1,n=15,o=16,p=7,O=256,P=16,B=17,z=18,D=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],C=512,E=new Array((a+2)*2);f(E);var A=new Array(r*2);f(A);var L=new Array(C);f(L);var $=new Array(s-d+1);f($);var W=new Array(m);f(W);var U=new Array(r);f(U);function N(ae,Re,be,Ee,pe){this.static_tree=ae,this.extra_bits=Re,this.extra_base=be,this.elems=Ee,this.max_length=pe,this.has_stree=ae&&ae.length}var j,F,V;function re(ae,Re){this.dyn_tree=ae,this.max_code=0,this.stat_desc=Re}function ee(ae){return ae<256?L[ae]:L[256+(ae>>>7)]}function ce(ae,Re){ae.pending_buf[ae.pending++]=Re&255,ae.pending_buf[ae.pending++]=Re>>>8&255}function ye(ae,Re,be){ae.bi_valid>o-be?(ae.bi_buf|=Re<>o-ae.bi_valid,ae.bi_valid+=be-o):(ae.bi_buf|=Re<>>=1,be<<=1;while(--Re>0);return be>>>1}function J(ae){ae.bi_valid===16?(ce(ae,ae.bi_buf),ae.bi_buf=0,ae.bi_valid=0):ae.bi_valid>=8&&(ae.pending_buf[ae.pending++]=ae.bi_buf&255,ae.bi_buf>>=8,ae.bi_valid-=8)}function Q(ae,Re){var be=Re.dyn_tree,Ee=Re.max_code,pe=Re.stat_desc.static_tree,Pe=Re.stat_desc.has_stree,te=Re.stat_desc.extra_bits,He=Re.stat_desc.extra_base,it=Re.stat_desc.max_length,K,Me,Le,ue,ke,Ie,st=0;for(ue=0;ue<=n;ue++)ae.bl_count[ue]=0;for(be[ae.heap[ae.heap_max]*2+1]=0,K=ae.heap_max+1;Kit&&(ue=it,st++),be[Me*2+1]=ue,!(Me>Ee)&&(ae.bl_count[ue]++,ke=0,Me>=He&&(ke=te[Me-He]),Ie=be[Me*2],ae.opt_len+=Ie*(ue+ke),Pe&&(ae.static_len+=Ie*(pe[Me*2+1]+ke)));if(st!==0){do{for(ue=it-1;ae.bl_count[ue]===0;)ue--;ae.bl_count[ue]--,ae.bl_count[ue+1]+=2,ae.bl_count[it]--,st-=2}while(st>0);for(ue=it;ue!==0;ue--)for(Me=ae.bl_count[ue];Me!==0;)Le=ae.heap[--K],!(Le>Ee)&&(be[Le*2+1]!==ue&&(ae.opt_len+=(ue-be[Le*2+1])*be[Le*2],be[Le*2+1]=ue),Me--)}}function he(ae,Re,be){var Ee=new Array(n+1),pe=0,Pe,te;for(Pe=1;Pe<=n;Pe++)Ee[Pe]=pe=pe+be[Pe-1]<<1;for(te=0;te<=Re;te++){var He=ae[te*2+1];He!==0&&(ae[te*2]=oe(Ee[He]++,He))}}function xe(){var ae,Re,be,Ee,pe,Pe=new Array(n+1);for(be=0,Ee=0;Ee>=7;Ee8?ce(ae,ae.bi_buf):ae.bi_valid>0&&(ae.pending_buf[ae.pending++]=ae.bi_buf),ae.bi_buf=0,ae.bi_valid=0}function Ce(ae,Re,be,Ee){se(ae),Ee&&(ce(ae,be),ce(ae,~be)),u.arraySet(ae.pending_buf,ae.window,Re,be,ae.pending),ae.pending+=be}function q(ae,Re,be,Ee){var pe=Re*2,Pe=be*2;return ae[pe]>1;te>=1;te--)G(ae,be,te);K=Pe;do te=ae.heap[1],ae.heap[1]=ae.heap[ae.heap_len--],G(ae,be,1),He=ae.heap[1],ae.heap[--ae.heap_max]=te,ae.heap[--ae.heap_max]=He,be[K*2]=be[te*2]+be[He*2],ae.depth[K]=(ae.depth[te]>=ae.depth[He]?ae.depth[te]:ae.depth[He])+1,be[te*2+1]=be[He*2+1]=K,ae.heap[1]=K++,G(ae,be,1);while(ae.heap_len>=2);ae.heap[--ae.heap_max]=ae.heap[1],Q(ae,Re),he(be,it,ae.bl_count)}function we(ae,Re,be){var Ee,pe=-1,Pe,te=Re[0*2+1],He=0,it=7,K=4;for(te===0&&(it=138,K=3),Re[(be+1)*2+1]=65535,Ee=0;Ee<=be;Ee++)Pe=te,te=Re[(Ee+1)*2+1],!(++He=3&&ae.bl_tree[T[Re]*2+1]===0;Re--);return ae.opt_len+=3*(Re+1)+5+5+4,Re}function Ye(ae,Re,be,Ee){var pe;for(ye(ae,Re-257,5),ye(ae,be-1,5),ye(ae,Ee-4,4),pe=0;pe>>=1)if(Re&1&&ae.dyn_ltree[be*2]!==0)return g;if(ae.dyn_ltree[9*2]!==0||ae.dyn_ltree[10*2]!==0||ae.dyn_ltree[13*2]!==0)return b;for(be=32;be0?(ae.strm.data_type===w&&(ae.strm.data_type=nt(ae)),fe(ae,ae.l_desc),fe(ae,ae.d_desc),te=je(ae),pe=ae.opt_len+3+7>>>3,Pe=ae.static_len+3+7>>>3,Pe<=pe&&(pe=Pe)):pe=Pe=be+5,be+4<=pe&&Re!==-1?Ue(ae,Re,be,Ee):ae.strategy===y||Pe===pe?(ye(ae,(h<<1)+(Ee?1:0),3),Y(ae,E,A)):(ye(ae,(l<<1)+(Ee?1:0),3),Ye(ae,ae.l_desc.max_code+1,ae.d_desc.max_code+1,te+1),Y(ae,ae.dyn_ltree,ae.dyn_dtree)),ne(ae),Ee&&se(ae)}function tt(ae,Re,be){return ae.pending_buf[ae.d_buf+ae.last_lit*2]=Re>>>8&255,ae.pending_buf[ae.d_buf+ae.last_lit*2+1]=Re&255,ae.pending_buf[ae.l_buf+ae.last_lit]=be&255,ae.last_lit++,Re===0?ae.dyn_ltree[be*2]++:(ae.matches++,Re--,ae.dyn_ltree[($[be]+c+1)*2]++,ae.dyn_dtree[ee(Re)*2]++),ae.last_lit===ae.lit_bufsize-1}_._tr_init=ot,_._tr_stored_block=Ue,_._tr_flush_block=Qe,_._tr_tally=tt,_._tr_align=Ve},{"../utils/common":442}],454:[function(e,S,_){function u(){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}S.exports=u},{}],455:[function(e,S,_){S.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],456:[function(e,S,_){var u=e("asn1.js");_.certificate=e("./certificate");var y=u.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});_.RSAPrivateKey=y;var g=u.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});_.RSAPublicKey=g;var b=u.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(w),this.key("subjectPublicKey").bitstr())});_.PublicKey=b;var w=u.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),f=u.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(w),this.key("subjectPrivateKey").octstr())});_.PrivateKey=f;var v=u.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});_.EncryptedPrivateKey=v;var h=u.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});_.DSAPrivateKey=h,_.DSAparam=u.define("DSAparam",function(){this.int()});var l=u.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(d),this.key("publicKey").optional().explicit(1).bitstr())});_.ECPrivateKey=l;var d=u.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});_.signature=u.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":457,"asn1.js":167}],457:[function(e,S,_){var u=e("asn1.js"),y=u.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),g=u.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),b=u.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),w=u.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(b),this.key("subjectPublicKey").bitstr())}),f=u.define("RelativeDistinguishedName",function(){this.setof(g)}),v=u.define("RDNSequence",function(){this.seqof(f)}),h=u.define("Name",function(){this.choice({rdnSequence:this.use(v)})}),l=u.define("Validity",function(){this.seq().obj(this.key("notBefore").use(y),this.key("notAfter").use(y))}),d=u.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),s=u.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(b),this.key("issuer").use(h),this.key("validity").use(l),this.key("subject").use(h),this.key("subjectPublicKeyInfo").use(w),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(d).optional())}),m=u.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(s),this.key("signatureAlgorithm").use(b),this.key("signatureValue").bitstr())});S.exports=m},{"asn1.js":167}],458:[function(e,S,_){var u=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,y=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,g=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,b=e("evp_bytestokey"),w=e("browserify-aes"),f=e("safe-buffer").Buffer;S.exports=function(v,h){var l=v.toString(),d=l.match(u),s;if(d){var c="aes"+d[1],a=f.from(d[2],"hex"),r=f.from(d[3].replace(/[\r\n]/g,""),"base64"),t=b(h,a.slice(0,8),parseInt(d[1],10)).key,i=[],n=w.createDecipheriv(c,t,a);i.push(n.update(r)),i.push(n.final()),s=f.concat(i)}else{var m=l.match(g);s=f.from(m[2].replace(/[\r\n]/g,""),"base64")}var o=l.match(y)[1];return{tag:o,data:s}}},{"browserify-aes":188,evp_bytestokey:368,"safe-buffer":494}],459:[function(e,S,_){function u(d){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(m){return typeof m}:u=function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},u(d)}var y=e("./asn1"),g=e("./aesid.json"),b=e("./fixProc"),w=e("browserify-aes"),f=e("pbkdf2"),v=e("safe-buffer").Buffer;S.exports=h;function h(d){var s;u(d)==="object"&&!v.isBuffer(d)&&(s=d.passphrase,d=d.key),typeof d=="string"&&(d=v.from(d));var m=b(d,s),c=m.tag,a=m.data,r,t;switch(c){case"CERTIFICATE":t=y.certificate.decode(a,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(t||(t=y.PublicKey.decode(a,"der")),r=t.algorithm.algorithm.join("."),r){case"1.2.840.113549.1.1.1":return y.RSAPublicKey.decode(t.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return t.subjectPrivateKey=t.subjectPublicKey,{type:"ec",data:t};case"1.2.840.10040.4.1":return t.algorithm.params.pub_key=y.DSAparam.decode(t.subjectPublicKey.data,"der"),{type:"dsa",data:t.algorithm.params};default:throw new Error("unknown key id "+r)}case"ENCRYPTED PRIVATE KEY":a=y.EncryptedPrivateKey.decode(a,"der"),a=l(a,s);case"PRIVATE KEY":switch(t=y.PrivateKey.decode(a,"der"),r=t.algorithm.algorithm.join("."),r){case"1.2.840.113549.1.1.1":return y.RSAPrivateKey.decode(t.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:t.algorithm.curve,privateKey:y.ECPrivateKey.decode(t.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return t.algorithm.params.priv_key=y.DSAparam.decode(t.subjectPrivateKey,"der"),{type:"dsa",params:t.algorithm.params};default:throw new Error("unknown key id "+r)}case"RSA PUBLIC KEY":return y.RSAPublicKey.decode(a,"der");case"RSA PRIVATE KEY":return y.RSAPrivateKey.decode(a,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:y.DSAPrivateKey.decode(a,"der")};case"EC PRIVATE KEY":return a=y.ECPrivateKey.decode(a,"der"),{curve:a.parameters.value,privateKey:a.privateKey};default:throw new Error("unknown key type "+c)}}h.signature=y.signature;function l(d,s){var m=d.algorithm.decrypt.kde.kdeparams.salt,c=parseInt(d.algorithm.decrypt.kde.kdeparams.iters.toString(),10),a=g[d.algorithm.decrypt.cipher.algo.join(".")],r=d.algorithm.decrypt.cipher.iv,t=d.subjectPrivateKey,i=parseInt(a.split("-")[1],10)/8,n=f.pbkdf2Sync(s,m,c,i,"sha1"),o=w.createDecipheriv(a,n,r),p=[];return p.push(o.update(t)),p.push(o.final()),v.concat(p)}},{"./aesid.json":455,"./asn1":456,"./fixProc":458,"browserify-aes":188,pbkdf2:460,"safe-buffer":494}],460:[function(e,S,_){_.pbkdf2=e("./lib/async"),_.pbkdf2Sync=e("./lib/sync")},{"./lib/async":461,"./lib/sync":464}],461:[function(e,S,_){(function(u,y){var g=e("safe-buffer").Buffer,b=e("./precondition"),w=e("./default-encoding"),f=e("./sync"),v=e("./to-buffer"),h,l=y.crypto&&y.crypto.subtle,d={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},s=[];function m(r){if(y.process&&!y.process.browser||!l||!l.importKey||!l.deriveBits)return Promise.resolve(!1);if(s[r]!==void 0)return s[r];h=h||g.alloc(8);var t=c(h,h,10,128,r).then(function(){return!0}).catch(function(){return!1});return s[r]=t,t}function c(r,t,i,n,o){return l.importKey("raw",r,{name:"PBKDF2"},!1,["deriveBits"]).then(function(p){return l.deriveBits({name:"PBKDF2",salt:t,iterations:i,hash:{name:o}},p,n<<3)}).then(function(p){return g.from(p)})}function a(r,t){r.then(function(i){u.nextTick(function(){t(null,i)})},function(i){u.nextTick(function(){t(i)})})}S.exports=function(r,t,i,n,o,p){typeof o=="function"&&(p=o,o=void 0),o=o||"sha1";var O=d[o.toLowerCase()];if(!O||typeof y.Promise!="function")return u.nextTick(function(){var P;try{P=f(r,t,i,n,o)}catch(B){return p(B)}p(null,P)});if(b(i,n),r=v(r,w,"Password"),t=v(t,w,"Salt"),typeof p!="function")throw new Error("No callback provided to pbkdf2");a(m(O).then(function(P){return P?c(r,t,i,n,O):f(r,t,i,n,o)}),p)}}).call(this,e("_process"),typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{"./default-encoding":462,"./precondition":463,"./sync":464,"./to-buffer":465,_process:467,"safe-buffer":494}],462:[function(e,S,_){(function(u){var y;if(u.browser)y="utf-8";else if(u.version){var g=parseInt(u.version.split(".")[0].slice(1),10);y=g>=6?"utf-8":"binary"}else y="utf-8";S.exports=y}).call(this,e("_process"))},{_process:467}],463:[function(e,S,_){var u=Math.pow(2,30)-1;S.exports=function(y,g){if(typeof y!="number")throw new TypeError("Iterations not a number");if(y<0)throw new TypeError("Bad iterations");if(typeof g!="number")throw new TypeError("Key length not a number");if(g<0||g>u||g!==g)throw new TypeError("Bad key length")}},{}],464:[function(e,S,_){var u=e("create-hash/md5"),y=e("ripemd160"),g=e("sha.js"),b=e("safe-buffer").Buffer,w=e("./precondition"),f=e("./default-encoding"),v=e("./to-buffer"),h=b.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function d(c,a,r){var t=s(c),i=c==="sha512"||c==="sha384"?128:64;a.length>i?a=t(a):a.length"u"||!u.version||u.version.indexOf("v0.")===0||u.version.indexOf("v1.")===0&&u.version.indexOf("v1.8.")!==0?S.exports={nextTick:y}:S.exports=u;function y(g,b,w,f){if(typeof g!="function")throw new TypeError('"callback" argument must be a function');var v=arguments.length,h,l;switch(v){case 0:case 1:return u.nextTick(g);case 2:return u.nextTick(function(){g.call(null,b)});case 3:return u.nextTick(function(){g.call(null,b,w)});case 4:return u.nextTick(function(){g.call(null,b,w,f)});default:for(h=new Array(v-1),l=0;l1)for(var n=1;nn||new b(a).cmp(i.modulus)>=0)throw new Error("decryption error");var o;r?o=v(new b(a),i):o=w(a,i);var p=h.alloc(n-o.length);if(o=h.concat([p,o],n),t===4)return l(i,o);if(t===1)return d(i,o,r);if(t===3)return o;throw new Error("unknown padding")};function l(m,c){var a=m.modulus.byteLength(),r=f("sha1").update(h.alloc(0)).digest(),t=r.length;if(c[0]!==0)throw new Error("decryption error");var i=c.slice(1,t+1),n=c.slice(t+1),o=g(i,y(n,t)),p=g(n,y(o,a-t-1));if(s(r,p.slice(0,t)))throw new Error("decryption error");for(var O=t;p[O]===0;)O++;if(p[O++]!==1)throw new Error("decryption error");return p.slice(O)}function d(m,c,a){for(var r=c.slice(0,2),t=2,i=0;c[t++]!==0;)if(t>=c.length){i++;break}var n=c.slice(2,t-1);if((r.toString("hex")!=="0002"&&!a||r.toString("hex")!=="0001"&&a)&&i++,n.length<8&&i++,i)throw new Error("decryption error");return c.slice(t)}function s(m,c){m=h.from(m),c=h.from(c);var a=0,r=m.length;m.length!==c.length&&(a++,r=Math.min(m.length,c.length));for(var t=-1;++t=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return t?h(o,n):v(o,n)};function d(c,a){var r=c.modulus.byteLength(),t=a.length,i=g("sha1").update(l.alloc(0)).digest(),n=i.length,o=2*n;if(t>r-o-2)throw new Error("message too long");var p=l.alloc(r-t-o-2),O=r-n-1,P=y(n),B=w(l.concat([i,p,l.alloc(1,1),a],O),b(P,O)),z=w(P,b(B,n));return new f(l.concat([l.alloc(1),z,B],r))}function s(c,a,r){var t=a.length,i=c.modulus.byteLength();if(t>i-11)throw new Error("message too long");var n;return r?n=l.alloc(i-t-3,255):n=m(i-t-3),new f(l.concat([l.from([0,r?1:2]),n,l.alloc(1),a],i))}function m(c){for(var a=l.allocUnsafe(c),r=0,t=y(c*2),i=0,n;r>2,d=(f&3)<<4|v>>4,s=r>1?(v&15)<<2|h>>6:64,m=r>2?h&63:64,w.push(g.charAt(l)+g.charAt(d)+g.charAt(s)+g.charAt(m));return w.join("")},_.decode=function(b){var w,f,v,h,l,d,s,m=0,c=0,a="data:";if(b.substr(0,a.length)===a)throw new Error("Invalid base64 input, it looks like a data url.");b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");var r=b.length*3/4;if(b.charAt(b.length-1)===g.charAt(64)&&r--,b.charAt(b.length-2)===g.charAt(64)&&r--,r%1!==0)throw new Error("Invalid base64 input, bad content length.");var t;for(y.uint8array?t=new Uint8Array(r|0):t=new Array(r|0);m>4,f=(l&15)<<4|d>>2,v=(d&3)<<6|s,t[c++]=w,d!==64&&(t[c++]=f),s!==64&&(t[c++]=v);return t}},{"./support":419,"./utils":421}],391:[function(e,S,_){var u=e("./external"),y=e("./stream/DataWorker"),b=e("./stream/DataLengthProbe"),g=e("./stream/Crc32Probe"),b=e("./stream/DataLengthProbe");function w(f,v,h,l,d){this.compressedSize=f,this.uncompressedSize=v,this.crc32=h,this.compression=l,this.compressedContent=d}w.prototype={getContentWorker:function(){var v=new y(u.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new b("data_length")),h=this;return v.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),v},getCompressedWorker:function(){return new y(u.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},w.createWorkerFrom=function(f,v,h){return f.pipe(new g).pipe(new b("uncompressedSize")).pipe(v.compressWorker(h)).pipe(new b("compressedSize")).withStreamInfo("compression",v)},S.exports=w},{"./external":395,"./stream/Crc32Probe":414,"./stream/DataLengthProbe":415,"./stream/DataWorker":416}],392:[function(e,S,_){var u=e("./stream/GenericWorker");_.STORE={magic:"\0\0",compressWorker:function(g){return new u("STORE compression")},uncompressWorker:function(){return new u("STORE decompression")}},_.DEFLATE=e("./flate")},{"./flate":396,"./stream/GenericWorker":417}],393:[function(e,S,_){var u=e("./utils");function y(){for(var f,v=[],h=0;h<256;h++){f=h;for(var l=0;l<8;l++)f=f&1?3988292384^f>>>1:f>>>1;v[h]=f}return v}var g=y();function b(f,v,h,l){var d=g,s=l+h;f=f^-1;for(var m=l;m>>8^d[(f^v[m])&255];return f^-1}function w(f,v,h,l){var d=g,s=l+h;f=f^-1;for(var m=l;m>>8^d[(f^v.charCodeAt(m))&255];return f^-1}S.exports=function(v,h){if(typeof v>"u"||!v.length)return 0;var l=u.getTypeOf(v)!=="string";return l?b(h|0,v,v.length,0):w(h|0,v,v.length,0)}},{"./utils":421}],394:[function(e,S,_){_.base64=!1,_.binary=!1,_.dir=!1,_.createFolders=!0,_.date=null,_.compression=null,_.compressionOptions=null,_.comment=null,_.unixPermissions=null,_.dosPermissions=null},{}],395:[function(e,S,_){var u=null;typeof Promise<"u"?u=Promise:u=e("lie"),S.exports={Promise:u}},{lie:425}],396:[function(e,S,_){var u=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",y=e("pako"),g=e("./utils"),b=e("./stream/GenericWorker"),w=u?"uint8array":"array";_.magic="\b\0";function f(v,h){b.call(this,"FlateWorker/"+v),this._pako=null,this._pakoAction=v,this._pakoOptions=h,this.meta={}}g.inherits(f,b),f.prototype.processChunk=function(v){this.meta=v.meta,this._pako===null&&this._createPako(),this._pako.push(g.transformTo(w,v.data),!1)},f.prototype.flush=function(){b.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){b.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new y[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var v=this;this._pako.onData=function(h){v.push({data:h,meta:v.meta})}},_.compressWorker=function(v){return new f("Deflate",v)},_.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":417,"./utils":421,pako:439}],397:[function(e,S,_){var u=e("../utils"),y=e("../stream/GenericWorker"),g=e("../utf8"),b=e("../crc32"),w=e("../signature"),f=function(a,r){var t="",i;for(i=0;i>>8;return t},v=function(a,r){var t=a;return a||(t=r?16893:33204),(t&65535)<<16},h=function(a,r){return(a||0)&63},l=function(a,r,t,i,n,o){var p=a.file,E=a.compression,P=o!==g.utf8encode,D=u.transformTo("string",o(p.name)),z=u.transformTo("string",g.utf8encode(p.name)),B=p.comment,M=u.transformTo("string",o(B)),I=u.transformTo("string",g.utf8encode(B)),T=z.length!==p.name.length,C=I.length!==B.length,O,A,L="",U="",W="",$=p.dir,N=p.date,F={crc32:0,compressedSize:0,uncompressedSize:0};(!r||t)&&(F.crc32=a.crc32,F.compressedSize=a.compressedSize,F.uncompressedSize=a.uncompressedSize);var j=0;r&&(j|=8),!P&&(T||C)&&(j|=2048);var V=0,te=0;$&&(V|=16),n==="UNIX"?(te=798,V|=v(p.unixPermissions,$)):(te=20,V|=h(p.dosPermissions)),O=N.getUTCHours(),O=O<<6,O=O|N.getUTCMinutes(),O=O<<5,O=O|N.getUTCSeconds()/2,A=N.getUTCFullYear()-1980,A=A<<4,A=A|N.getUTCMonth()+1,A=A<<5,A=A|N.getUTCDate(),T&&(U=f(1,1)+f(b(D),4)+z,L+="up"+f(U.length,2)+U),C&&(W=f(1,1)+f(b(M),4)+I,L+="uc"+f(W.length,2)+W);var re="";re+=` +\0`,re+=f(j,2),re+=E.magic,re+=f(O,2),re+=f(A,2),re+=f(F.crc32,4),re+=f(F.compressedSize,4),re+=f(F.uncompressedSize,4),re+=f(D.length,2),re+=f(L.length,2);var le=w.LOCAL_FILE_HEADER+re+D+L,ye=w.CENTRAL_FILE_HEADER+f(te,2)+re+f(M.length,2)+"\0\0\0\0"+f(V,4)+f(i,4)+D+L+M;return{fileRecord:le,dirRecord:ye}},d=function(a,r,t,i,n){var o="",p=u.transformTo("string",n(i));return o=w.CENTRAL_DIRECTORY_END+"\0\0\0\0"+f(a,2)+f(a,2)+f(r,4)+f(t,4)+f(p.length,2)+p,o},s=function(a){var r="";return r=w.DATA_DESCRIPTOR+f(a.crc32,4)+f(a.compressedSize,4)+f(a.uncompressedSize,4),r};function m(c,a,r,t){y.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=a,this.zipPlatform=r,this.encodeFileName=t,this.streamFiles=c,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}u.inherits(m,y),m.prototype.push=function(c){var a=c.meta.percent||0,r=this.entriesCount,t=this._sources.length;this.accumulate?this.contentBuffer.push(c):(this.bytesWritten+=c.data.length,y.prototype.push.call(this,{data:c.data,meta:{currentFile:this.currentFile,percent:r?(a+100*(r-t-1))/r:100}}))},m.prototype.openedSource=function(c){this.currentSourceOffset=this.bytesWritten,this.currentFile=c.file.name;var a=this.streamFiles&&!c.file.dir;if(a){var r=l(c,a,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(c){this.accumulate=!1;var a=this.streamFiles&&!c.file.dir,r=l(c,a,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),a)this.push({data:s(c),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var c=this.bytesWritten,a=0;a"u")&&(D.binary=!z);var B=o instanceof f&&o.uncompressedSize===0;(B||D.dir||!o||o.length===0)&&(D.base64=!1,D.binary=!0,o="",D.compression="STORE",E="string");var M=null;o instanceof f||o instanceof g?M=o:l.isNode&&l.isStream(o)?M=new d(n,o):M=y.prepareContent(n,o,D.binary,D.optimizedBinaryString,D.base64);var I=new v(n,M,D);this.files[n]=I},m=function(n){n.slice(-1)==="/"&&(n=n.substring(0,n.length-1));var o=n.lastIndexOf("/");return o>0?n.substring(0,o):""},c=function(n){return n.slice(-1)!=="/"&&(n+="/"),n},a=function(n,o){return o=typeof o<"u"?o:w.createFolders,n=c(n),this.files[n]||s.call(this,n,null,{dir:!0,createFolders:o}),this.files[n]};function r(i){return Object.prototype.toString.call(i)==="[object RegExp]"}var t={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(n){var o,p,E;for(o in this.files)this.files.hasOwnProperty(o)&&(E=this.files[o],p=o.slice(this.root.length,o.length),p&&o.slice(0,this.root.length)===this.root&&n(p,E))},filter:function(n){var o=[];return this.forEach(function(p,E){n(p,E)&&o.push(E)}),o},file:function(n,o,p){if(arguments.length===1)if(r(n)){var E=n;return this.filter(function(D,z){return!z.dir&&E.test(D)})}else{var P=this.files[this.root+n];return P&&!P.dir?P:null}else n=this.root+n,s.call(this,n,o,p);return this},folder:function(n){if(!n)return this;if(r(n))return this.filter(function(P,D){return D.dir&&n.test(P)});var o=this.root+n,p=a.call(this,o),E=this.clone();return E.root=p.name,E},remove:function(n){n=this.root+n;var o=this.files[n];if(o||(n.slice(-1)!=="/"&&(n+="/"),o=this.files[n]),o&&!o.dir)delete this.files[n];else for(var p=this.filter(function(P,D){return D.name.slice(0,n.length)===n}),E=0;E=0;--l)if(this.data[l]===w&&this.data[l+1]===f&&this.data[l+2]===v&&this.data[l+3]===h)return l-this.zero;return-1},g.prototype.readAndCheckSignature=function(b){var w=b.charCodeAt(0),f=b.charCodeAt(1),v=b.charCodeAt(2),h=b.charCodeAt(3),l=this.readData(4);return w===l[0]&&f===l[1]&&v===l[2]&&h===l[3]},g.prototype.readData=function(b){if(this.checkOffset(b),b===0)return[];var w=this.data.slice(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./DataReader":407}],407:[function(e,S,_){var u=e("../utils");function y(g){this.data=g,this.length=g.length,this.index=0,this.zero=0}y.prototype={checkOffset:function(b){this.checkIndex(this.index+b)},checkIndex:function(b){if(this.length=this.index;f--)w=(w<<8)+this.byteAt(f);return this.index+=b,w},readString:function(b){return u.transformTo("string",this.readData(b))},readData:function(b){},lastIndexOfSignature:function(b){},readAndCheckSignature:function(b){},readDate:function(){var b=this.readInt(4);return new Date(Date.UTC((b>>25&127)+1980,(b>>21&15)-1,b>>16&31,b>>11&31,b>>5&63,(b&31)<<1))}},S.exports=y},{"../utils":421}],408:[function(e,S,_){var u=e("./Uint8ArrayReader"),y=e("../utils");function g(b){u.call(this,b)}y.inherits(g,u),g.prototype.readData=function(b){this.checkOffset(b);var w=this.data.slice(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./Uint8ArrayReader":410}],409:[function(e,S,_){var u=e("./DataReader"),y=e("../utils");function g(b){u.call(this,b)}y.inherits(g,u),g.prototype.byteAt=function(b){return this.data.charCodeAt(this.zero+b)},g.prototype.lastIndexOfSignature=function(b){return this.data.lastIndexOf(b)-this.zero},g.prototype.readAndCheckSignature=function(b){var w=this.readData(4);return b===w},g.prototype.readData=function(b){this.checkOffset(b);var w=this.data.slice(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./DataReader":407}],410:[function(e,S,_){var u=e("./ArrayReader"),y=e("../utils");function g(b){u.call(this,b)}y.inherits(g,u),g.prototype.readData=function(b){if(this.checkOffset(b),b===0)return new Uint8Array(0);var w=this.data.subarray(this.zero+this.index,this.zero+this.index+b);return this.index+=b,w},S.exports=g},{"../utils":421,"./ArrayReader":406}],411:[function(e,S,_){var u=e("../utils"),y=e("../support"),g=e("./ArrayReader"),b=e("./StringReader"),w=e("./NodeBufferReader"),f=e("./Uint8ArrayReader");S.exports=function(v){var h=u.getTypeOf(v);return u.checkSupport(h),h==="string"&&!y.uint8array?new b(v):h==="nodebuffer"?new w(v):y.uint8array?new f(u.transformTo("uint8array",v)):new g(u.transformTo("array",v))}},{"../support":419,"../utils":421,"./ArrayReader":406,"./NodeBufferReader":408,"./StringReader":409,"./Uint8ArrayReader":410}],412:[function(e,S,_){_.LOCAL_FILE_HEADER="PK",_.CENTRAL_FILE_HEADER="PK",_.CENTRAL_DIRECTORY_END="PK",_.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",_.ZIP64_CENTRAL_DIRECTORY_END="PK",_.DATA_DESCRIPTOR="PK\x07\b"},{}],413:[function(e,S,_){var u=e("./GenericWorker"),y=e("../utils");function g(b){u.call(this,"ConvertWorker to "+b),this.destType=b}y.inherits(g,u),g.prototype.processChunk=function(b){this.push({data:y.transformTo(this.destType,b.data),meta:b.meta})},S.exports=g},{"../utils":421,"./GenericWorker":417}],414:[function(e,S,_){var u=e("./GenericWorker"),y=e("../crc32"),g=e("../utils");function b(){u.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}g.inherits(b,u),b.prototype.processChunk=function(w){this.streamInfo.crc32=y(w.data,this.streamInfo.crc32||0),this.push(w)},S.exports=b},{"../crc32":393,"../utils":421,"./GenericWorker":417}],415:[function(e,S,_){var u=e("../utils"),y=e("./GenericWorker");function g(b){y.call(this,"DataLengthProbe for "+b),this.propName=b,this.withStreamInfo(b,0)}u.inherits(g,y),g.prototype.processChunk=function(b){if(b){var w=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=w+b.data.length}y.prototype.processChunk.call(this,b)},S.exports=g},{"../utils":421,"./GenericWorker":417}],416:[function(e,S,_){var u=e("../utils"),y=e("./GenericWorker"),g=16*1024;function b(w){y.call(this,"DataWorker");var f=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,w.then(function(v){f.dataIsReady=!0,f.data=v,f.max=v&&v.length||0,f.type=u.getTypeOf(v),f.isPaused||f._tickAndRepeat()},function(v){f.error(v)})}u.inherits(b,y),b.prototype.cleanUp=function(){y.prototype.cleanUp.call(this),this.data=null},b.prototype.resume=function(){return y.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,u.delay(this._tickAndRepeat,[],this)),!0):!1},b.prototype._tickAndRepeat=function(){this._tickScheduled=!1,!(this.isPaused||this.isFinished)&&(this._tick(),this.isFinished||(u.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},b.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var w=g,f=null,v=Math.min(this.max,this.index+w);if(this.index>=this.max)return this.end();switch(this.type){case"string":f=this.data.substring(this.index,v);break;case"uint8array":f=this.data.subarray(this.index,v);break;case"array":case"nodebuffer":f=this.data.slice(this.index,v);break}return this.index=v,this.push({data:f,meta:{percent:this.max?this.index/this.max*100:0}})},S.exports=b},{"../utils":421,"./GenericWorker":417}],417:[function(e,S,_){function u(y){this.name=y||"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}u.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?!1:(this.isPaused?this.generatedError=g:(this.isFinished=!0,this.emit("error",g),this.previous&&this.previous.error(g),this.cleanUp()),!0)},on:function(g,b){return this._listeners[g].push(b),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(g,b){if(this._listeners[g])for(var w=0;w "+g:g}},S.exports=u},{}],418:[function(e,S,_){(function(u){var y=e("../utils"),g=e("./ConvertWorker"),b=e("./GenericWorker"),w=e("../base64"),f=e("../support"),v=e("../external"),h=null;if(f.nodestream)try{h=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function l(c,a,r){switch(c){case"blob":return y.newBlob(y.transformTo("arraybuffer",a),r);case"base64":return w.encode(a);default:return y.transformTo(c,a)}}function d(c,a){var r,t=0,i=null,n=0;for(r=0;r"u")_.blob=!1;else{var y=new ArrayBuffer(0);try{_.blob=new Blob([y],{type:"application/zip"}).size===0}catch{try{var g=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,b=new g;b.append(y),_.blob=b.getBlob("application/zip").size===0}catch{_.blob=!1}}}try{_.nodestream=!!e("readable-stream").Readable}catch{_.nodestream=!1}}).call(this,e("buffer").Buffer)},{buffer:216,"readable-stream":405}],420:[function(e,S,_){for(var u=e("./utils"),y=e("./support"),g=e("./nodejsUtils"),b=e("./stream/GenericWorker"),w=new Array(256),f=0;f<256;f++)w[f]=f>=252?6:f>=248?5:f>=240?4:f>=224?3:f>=192?2:1;w[254]=w[254]=1;var v=function(c){var a,r,t,i,n,o=c.length,p=0;for(i=0;i>>6,a[n++]=128|r&63):r<65536?(a[n++]=224|r>>>12,a[n++]=128|r>>>6&63,a[n++]=128|r&63):(a[n++]=240|r>>>18,a[n++]=128|r>>>12&63,a[n++]=128|r>>>6&63,a[n++]=128|r&63);return a},h=function(c,a){var r;for(a=a||c.length,a>c.length&&(a=c.length),r=a-1;r>=0&&(c[r]&192)===128;)r--;return r<0||r===0?a:r+w[c[r]]>a?r:a},l=function(c){var a,r,t,i,n=c.length,o=new Array(n*2);for(r=0,a=0;a4){o[r++]=65533,a+=i-1;continue}for(t&=i===2?31:i===3?15:7;i>1&&a1){o[r++]=65533;continue}t<65536?o[r++]=t:(t-=65536,o[r++]=55296|t>>10&1023,o[r++]=56320|t&1023)}return o.length!==r&&(o.subarray?o=o.subarray(0,r):o.length=r),u.applyFromCharCode(o)};_.utf8encode=function(c){return y.nodebuffer?g.newBufferFrom(c,"utf-8"):v(c)},_.utf8decode=function(c){return y.nodebuffer?u.transformTo("nodebuffer",c).toString("utf-8"):(c=u.transformTo(y.uint8array?"uint8array":"array",c),l(c))};function d(){b.call(this,"utf-8 decode"),this.leftOver=null}u.inherits(d,b),d.prototype.processChunk=function(m){var c=u.transformTo(y.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(y.uint8array){var a=c;c=new Uint8Array(a.length+this.leftOver.length),c.set(this.leftOver,0),c.set(a,this.leftOver.length)}else c=this.leftOver.concat(c);this.leftOver=null}var r=h(c),t=c;r!==c.length&&(y.uint8array?(t=c.subarray(0,r),this.leftOver=c.subarray(r,c.length)):(t=c.slice(0,r),this.leftOver=c.slice(r,c.length))),this.push({data:_.utf8decode(t),meta:m.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:_.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},_.Utf8DecodeWorker=d;function s(){b.call(this,"utf-8 encode")}u.inherits(s,b),s.prototype.processChunk=function(m){this.push({data:_.utf8encode(m.data),meta:m.meta})},_.Utf8EncodeWorker=s},{"./nodejsUtils":403,"./stream/GenericWorker":417,"./support":419,"./utils":421}],421:[function(e,S,_){var u=e("./support"),y=e("./base64"),g=e("./nodejsUtils"),b=e("set-immediate-shim"),w=e("./external");function f(c){var a=null;return u.uint8array?a=new Uint8Array(c.length):a=new Array(c.length),h(c,a)}_.newBlob=function(c,a){_.checkSupport("blob");try{return new Blob([c],{type:a})}catch{try{var r=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,t=new r;return t.append(c),t.getBlob(a)}catch{throw new Error("Bug : can't construct the Blob.")}}};function v(c){return c}function h(c,a){for(var r=0;r1;)try{return l.stringifyByChunk(c,r,a)}catch{a=Math.floor(a/2)}return l.stringifyByChar(c)}_.applyFromCharCode=d;function s(c,a){for(var r=0;r"u"&&(c[r]=arguments[a][r]);return c},_.prepareContent=function(c,a,r,t,i){var n=w.Promise.resolve(a).then(function(o){var p=u.blob&&(o instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(o))!==-1);return p&&typeof FileReader<"u"?new w.Promise(function(E,P){var D=new FileReader;D.onload=function(z){E(z.target.result)},D.onerror=function(z){P(z.target.error)},D.readAsArrayBuffer(o)}):o});return n.then(function(o){var p=_.getTypeOf(o);return p?(p==="arraybuffer"?o=_.transformTo("uint8array",o):p==="string"&&(i?o=y.decode(o):r&&t!==!0&&(o=f(o))),o):w.Promise.reject(new Error("Can't read the data of '"+c+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":390,"./external":395,"./nodejsUtils":403,"./support":419,"set-immediate-shim":497}],422:[function(e,S,_){var u=e("./reader/readerFor"),y=e("./utils"),g=e("./signature"),b=e("./zipEntry");e("./utf8");var w=e("./support");function f(v){this.files=[],this.loadOptions=v}f.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var l=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+y.pretty(l)+", expected "+y.pretty(h)+")")}},isSignature:function(h,l){var d=this.reader.index;this.reader.setIndex(h);var s=this.reader.readString(4),m=s===l;return this.reader.setIndex(d),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),l=w.uint8array?"uint8array":"array",d=y.transformTo(l,h);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h=this.zip64EndOfCentralSize-44,l=0,d,s,m;l1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,l;for(h=0;h0)this.isSignature(d,g.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(h){this.reader=u(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},S.exports=f},{"./reader/readerFor":411,"./signature":412,"./support":419,"./utf8":420,"./utils":421,"./zipEntry":423}],423:[function(e,S,_){var u=e("./reader/readerFor"),y=e("./utils"),g=e("./compressedObject"),b=e("./crc32"),w=e("./utf8"),f=e("./compressions"),v=e("./support"),h=0,l=3,d=function(c){for(var a in f)if(f.hasOwnProperty(a)&&f[a].magic===c)return f[a];return null};function s(m,c){this.options=m,this.loadOptions=c}s.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(c){var a,r;if(c.skip(22),this.fileNameLength=c.readInt(2),r=c.readInt(2),this.fileName=c.readData(this.fileNameLength),c.skip(r),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(a=d(this.compressionMethod),a===null)throw new Error("Corrupted zip : compression "+y.pretty(this.compressionMethod)+" unknown (inner file : "+y.transformTo("string",this.fileName)+")");this.decompressed=new g(this.compressedSize,this.uncompressedSize,this.crc32,a,c.readData(this.compressedSize))},readCentralPart:function(c){this.versionMadeBy=c.readInt(2),c.skip(2),this.bitFlag=c.readInt(2),this.compressionMethod=c.readString(2),this.date=c.readDate(),this.crc32=c.readInt(4),this.compressedSize=c.readInt(4),this.uncompressedSize=c.readInt(4);var a=c.readInt(2);if(this.extraFieldsLength=c.readInt(2),this.fileCommentLength=c.readInt(2),this.diskNumberStart=c.readInt(2),this.internalFileAttributes=c.readInt(2),this.externalFileAttributes=c.readInt(4),this.localHeaderOffset=c.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");c.skip(a),this.readExtraFields(c),this.parseZIP64ExtraField(c),this.fileComment=c.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var c=this.versionMadeBy>>8;this.dir=!!(this.externalFileAttributes&16),c===h&&(this.dosPermissions=this.externalFileAttributes&63),c===l&&(this.unixPermissions=this.externalFileAttributes>>16&65535),!this.dir&&this.fileNameStr.slice(-1)==="/"&&(this.dir=!0)},parseZIP64ExtraField:function(c){if(this.extraFields[1]){var a=u(this.extraFields[1].value);this.uncompressedSize===y.MAX_VALUE_32BITS&&(this.uncompressedSize=a.readInt(8)),this.compressedSize===y.MAX_VALUE_32BITS&&(this.compressedSize=a.readInt(8)),this.localHeaderOffset===y.MAX_VALUE_32BITS&&(this.localHeaderOffset=a.readInt(8)),this.diskNumberStart===y.MAX_VALUE_32BITS&&(this.diskNumberStart=a.readInt(4))}},readExtraFields:function(c){var a=c.index+this.extraFieldsLength,r,t,i;for(this.extraFields||(this.extraFields={});c.index+4"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,h=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,l=v||h||Function("return this")(),d=Object.prototype,s=d.toString,m=l.Symbol,c=m?m.prototype:void 0,a=c?c.toString:void 0;function r(p){if(typeof p=="string")return p;if(i(p))return a?a.call(p):"";var E=p+"";return E=="0"&&1/p==-g?"-0":E}function t(p){return!!p&&y(p)=="object"}function i(p){return y(p)=="symbol"||t(p)&&s.call(p)==b}function n(p){return p==null?"":r(p)}function o(p){return p=n(p),p&&f.test(p)?p.replace(w,"\\$&"):p}S.exports=o}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],427:[function(e,S,_){(function(u){function y(ce){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(Xe){return typeof Xe}:y=function(Xe){return Xe&&typeof Symbol=="function"&&Xe.constructor===Symbol&&Xe!==Symbol.prototype?"symbol":typeof Xe},y(ce)}var g=200,b="Expected a function",w="__lodash_hash_undefined__",f=1,v=2,h=1/0,l=9007199254740991,d="[object Arguments]",s="[object Array]",m="[object Boolean]",c="[object Date]",a="[object Error]",r="[object Function]",t="[object GeneratorFunction]",i="[object Map]",n="[object Number]",o="[object Object]",p="[object Promise]",E="[object RegExp]",P="[object Set]",D="[object String]",z="[object Symbol]",B="[object WeakMap]",M="[object ArrayBuffer]",I="[object DataView]",T="[object Float32Array]",C="[object Float64Array]",O="[object Int8Array]",A="[object Int16Array]",L="[object Int32Array]",U="[object Uint8Array]",W="[object Uint8ClampedArray]",$="[object Uint16Array]",N="[object Uint32Array]",F=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,j=/^\w*$/,V=/^\./,te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,re=/[\\^$.*+?()[\]{}|]/g,le=/\\(\\)?/g,ye=/^\[object .+?Constructor\]$/,ge=/^(?:0|[1-9]\d*)$/,ne={};ne[T]=ne[C]=ne[O]=ne[A]=ne[L]=ne[U]=ne[W]=ne[$]=ne[N]=!0,ne[d]=ne[s]=ne[M]=ne[m]=ne[I]=ne[c]=ne[a]=ne[r]=ne[i]=ne[n]=ne[o]=ne[E]=ne[P]=ne[D]=ne[B]=!1;var J=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,Q=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,he=J||Q||Function("return this")(),xe=(typeof _>"u"?"undefined":y(_))=="object"&&_&&!_.nodeType&&_,ie=xe&&(typeof S>"u"?"undefined":y(S))=="object"&&S&&!S.nodeType&&S,se=ie&&ie.exports===xe,Ce=se&&J.process,q=function(){try{return Ce&&Ce.binding("util")}catch{}}(),G=q&&q.isTypedArray;function Y(ce,Oe,Xe,ft){for(var Tt=-1,mt=ce?ce.length:0;++Tt-1}function Yr(ce,Oe){var Xe=this.__data__,ft=zr(Xe,ce);return ft<0?Xe.push([ce,Oe]):Xe[ft][1]=Oe,this}Et.prototype.clear=Nr,Et.prototype.delete=Or,Et.prototype.get=Gr,Et.prototype.has=Dr,Et.prototype.set=Yr;function Qt(ce){var Oe=-1,Xe=ce?ce.length:0;for(this.clear();++Oeir))return!1;var _r=mt.get(ce);if(_r&&mt.get(Oe))return _r==Oe;var Tr=-1,wr=!0,Rr=Tt&f?new Ke:void 0;for(mt.set(ce,Oe),mt.set(Oe,ce);++Tr-1&&ce%1==0&&ce-1&&ce%1==0&&ce<=l}function dr(ce){var Oe=y(ce);return!!ce&&(Oe=="object"||Oe=="function")}function Er(ce){return!!ce&&y(ce)=="object"}function Ar(ce){return y(ce)=="symbol"||Er(ce)&&pe.call(ce)==z}var pr=G?je(G):Wi;function pn(ce){return ce==null?"":wa(ce)}function mr(ce,Oe,Xe){var ft=ce==null?void 0:yi(ce,Oe);return ft===void 0?Xe:ft}function ta(ce,Oe){return ce!=null&&Ji(ce,Oe,dn)}function En(ce){return tr(ce)?rn(ce):jn(ce)}function Zr(ce){return ce}function ra(ce){return er(ce)?we(Ne(ce)):Sn(ce)}S.exports=ht}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],428:[function(e,S,_){function u(v){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(l){return typeof l}:u=function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},u(v)}var y="[object Boolean]",g=Object.prototype,b=g.toString;function w(v){return v===!0||v===!1||f(v)&&b.call(v)==y}function f(v){return!!v&&u(v)=="object"}S.exports=w},{}],429:[function(e,S,_){(function(u){function y(Se){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(Je){return typeof Je}:y=function(Je){return Je&&typeof Symbol=="function"&&Je.constructor===Symbol&&Je!==Symbol.prototype?"symbol":typeof Je},y(Se)}var g=200,b="__lodash_hash_undefined__",w=1,f=2,v=9007199254740991,h="[object Arguments]",l="[object Array]",d="[object AsyncFunction]",s="[object Boolean]",m="[object Date]",c="[object Error]",a="[object Function]",r="[object GeneratorFunction]",t="[object Map]",i="[object Number]",n="[object Null]",o="[object Object]",p="[object Promise]",E="[object Proxy]",P="[object RegExp]",D="[object Set]",z="[object String]",B="[object Symbol]",M="[object Undefined]",I="[object WeakMap]",T="[object ArrayBuffer]",C="[object DataView]",O="[object Float32Array]",A="[object Float64Array]",L="[object Int8Array]",U="[object Int16Array]",W="[object Int32Array]",$="[object Uint8Array]",N="[object Uint8ClampedArray]",F="[object Uint16Array]",j="[object Uint32Array]",V=/[\\^$.*+?()[\]{}|]/g,te=/^\[object .+?Constructor\]$/,re=/^(?:0|[1-9]\d*)$/,le={};le[O]=le[A]=le[L]=le[U]=le[W]=le[$]=le[N]=le[F]=le[j]=!0,le[h]=le[l]=le[T]=le[s]=le[C]=le[m]=le[c]=le[a]=le[t]=le[i]=le[o]=le[P]=le[D]=le[z]=le[I]=!1;var ye=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,ge=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,ne=ye||ge||Function("return this")(),J=(typeof _>"u"?"undefined":y(_))=="object"&&_&&!_.nodeType&&_,Q=J&&(typeof S>"u"?"undefined":y(S))=="object"&&S&&!S.nodeType&&S,he=Q&&Q.exports===J,xe=he&&ye.process,ie=function(){try{return xe&&xe.binding&&xe.binding("util")}catch{}}(),se=ie&&ie.isTypedArray;function Ce(Se,Ne){for(var Je=-1,ht=Se==null?0:Se.length,Yt=0,Mt=[];++Je-1}function Yr(Se,Ne){var Je=this.__data__,ht=zr(Je,Se);return ht<0?(++this.size,Je.push([Se,Ne])):Je[ht][1]=Ne,this}Et.prototype.clear=Nr,Et.prototype.delete=Or,Et.prototype.get=Gr,Et.prototype.has=Dr,Et.prototype.set=Yr;function Qt(Se){var Ne=-1,Je=Se==null?0:Se.length;for(this.clear();++Nenr))return!1;var ur=Mt.get(Se);if(ur&&Mt.get(Ne))return ur==Ne;var Pr=-1,Fr=!0,dr=Je&f?new Ke:void 0;for(Mt.set(Se,Ne),Mt.set(Ne,Se);++Pr-1&&Se%1==0&&Se-1&&Se%1==0&&Se<=v}function er(Se){var Ne=y(Se);return Se!=null&&(Ne=="object"||Ne=="function")}function ri(Se){return Se!=null&&y(Se)=="object"}var Qi=se?fe(se):dn;function Oa(Se){return xa(Se)?rn(Se):Bn(Se)}function qi(){return[]}function ea(){return!1}S.exports=On}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],430:[function(e,S,_){(function(u){function y(P){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(z){return typeof z}:y=function(z){return z&&typeof Symbol=="function"&&z.constructor===Symbol&&z!==Symbol.prototype?"symbol":typeof z},y(P)}var g="[object AsyncFunction]",b="[object Function]",w="[object GeneratorFunction]",f="[object Null]",v="[object Proxy]",h="[object Undefined]",l=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,d=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,s=l||d||Function("return this")(),m=Object.prototype,c=m.hasOwnProperty,a=m.toString,r=s.Symbol,t=r?r.toStringTag:void 0;function i(P){return P==null?P===void 0?h:f:t&&t in Object(P)?n(P):o(P)}function n(P){var D=c.call(P,t),z=P[t];try{P[t]=void 0;var B=!0}catch{}var M=a.call(P);return B&&(D?P[t]=z:delete P[t]),M}function o(P){return a.call(P)}function p(P){if(!E(P))return!1;var D=i(P);return D==b||D==w||D==g||D==v}function E(P){var D=y(P);return P!=null&&(D=="object"||D=="function")}S.exports=p}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],431:[function(e,S,_){function u(y){return y==null}S.exports=u},{}],432:[function(e,S,_){function u(y){return y===void 0}S.exports=u},{}],433:[function(e,S,_){(function(u){function y(be){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(pe){return typeof pe}:y=function(pe){return pe&&typeof Symbol=="function"&&pe.constructor===Symbol&&pe!==Symbol.prototype?"symbol":typeof pe},y(be)}var g=200,b="__lodash_hash_undefined__",w=1/0,f="[object Function]",v="[object GeneratorFunction]",h=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,d=(typeof u>"u"?"undefined":y(u))=="object"&&u&&u.Object===Object&&u,s=(typeof self>"u"?"undefined":y(self))=="object"&&self&&self.Object===Object&&self,m=d||s||Function("return this")();function c(be,Ee){var pe=be?be.length:0;return!!pe&&t(be,Ee,0)>-1}function a(be,Ee,pe){for(var Pe=-1,ee=be?be.length:0;++Pe-1}function J(be,Ee){var pe=this.__data__,Pe=fe(pe,be);return Pe<0?pe.push([be,Ee]):pe[Pe][1]=Ee,this}re.prototype.clear=le,re.prototype.delete=ye,re.prototype.get=ge,re.prototype.has=ne,re.prototype.set=J;function Q(be){var Ee=-1,pe=be?be.length:0;for(this.clear();++Ee=g){var Le=Ee?null:je(be);if(Le)return E(Le);it=!1,ee=n,Me=new q}else Me=Ee?[]:K;e:for(;++Pe56&&(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 s=g.allocUnsafe(16);return s.writeInt32LE(this._a,0),s.writeInt32LE(this._b,4),s.writeInt32LE(this._c,8),s.writeInt32LE(this._d,12),s};function f(s,m){return s<>>32-m}function v(s,m,c,a,r,t,i){return f(s+(m&c|~m&a)+r+t|0,i)+m|0}function h(s,m,c,a,r,t,i){return f(s+(m&a|c&~a)+r+t|0,i)+m|0}function l(s,m,c,a,r,t,i){return f(s+(m^c^a)+r+t|0,i)+m|0}function d(s,m,c,a,r,t,i){return f(s+(c^(m|~a))+r+t|0,i)+m|0}S.exports=w},{"hash-base":370,inherits:387,"safe-buffer":494}],435:[function(e,S,_){var u=e("bn.js"),y=e("brorand");function g(b){this.rand=b||new y.Rand}S.exports=g,g.create=function(w){return new g(w)},g.prototype._randbelow=function(w){var f=w.bitLength(),v=Math.ceil(f/8);do var h=new u(this.rand.generate(v));while(h.cmp(w)>=0);return h},g.prototype._randrange=function(w,f){var v=f.sub(w);return w.add(this._randbelow(v))},g.prototype.test=function(w,f,v){var h=w.bitLength(),l=u.mont(w),d=new u(1).toRed(l);f||(f=Math.max(1,h/48|0));for(var s=w.subn(1),m=0;!s.testn(m);m++);for(var c=w.shrn(m),a=s.toRed(l),r=!0;f>0;f--){var t=this._randrange(new u(2),s);v&&v(t);var i=t.toRed(l).redPow(c);if(!(i.cmp(d)===0||i.cmp(a)===0)){for(var n=1;n0;f--){var a=this._randrange(new u(2),d),r=w.gcd(a);if(r.cmpn(1)!==0)return r;var t=a.toRed(h).redPow(m);if(!(t.cmp(l)===0||t.cmp(c)===0)){for(var i=1;i>8,s=l&255;d?v.push(d,s):v.push(s)}return v}u.toArray=y;function g(w){return w.length===1?"0"+w:w}u.zero2=g;function b(w){for(var f="",v=0;v0?p.windowBits=-p.windowBits:p.gzip&&p.windowBits>0&&p.windowBits<16&&(p.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new w,this.strm.avail_out=0;var E=u.deflateInit2(this.strm,p.level,p.method,p.windowBits,p.memLevel,p.strategy);if(E!==l)throw new Error(b[E]);if(p.header&&u.deflateSetHeader(this.strm,p.header),p.dictionary){var P;if(typeof p.dictionary=="string"?P=g.string2buf(p.dictionary):f.call(p.dictionary)==="[object ArrayBuffer]"?P=new Uint8Array(p.dictionary):P=p.dictionary,E=u.deflateSetDictionary(this.strm,P),E!==l)throw new Error(b[E]);this._dict_set=!0}}r.prototype.push=function(o,p){var E=this.strm,P=this.options.chunkSize,D,z;if(this.ended)return!1;z=p===~~p?p:p===!0?h:v,typeof o=="string"?E.input=g.string2buf(o):f.call(o)==="[object ArrayBuffer]"?E.input=new Uint8Array(o):E.input=o,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new y.Buf8(P),E.next_out=0,E.avail_out=P),D=u.deflate(E,z),D!==d&&D!==l)return this.onEnd(D),this.ended=!0,!1;(E.avail_out===0||E.avail_in===0&&(z===h||z===s))&&(this.options.to==="string"?this.onData(g.buf2binstring(y.shrinkBuf(E.output,E.next_out))):this.onData(y.shrinkBuf(E.output,E.next_out)))}while((E.avail_in>0||E.avail_out===0)&&D!==d);return z===h?(D=u.deflateEnd(this.strm),this.onEnd(D),this.ended=!0,D===l):(z===s&&(this.onEnd(l),E.avail_out=0),!0)},r.prototype.onData=function(o){this.chunks.push(o)},r.prototype.onEnd=function(o){o===l&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=y.flattenChunks(this.chunks)),this.chunks=[],this.err=o,this.msg=this.strm.msg};function t(o,p){var E=new r(p);if(E.push(o,!0),E.err)throw E.msg||b[E.err];return E.result}function i(o,p){return p=p||{},p.raw=!0,t(o,p)}function n(o,p){return p=p||{},p.gzip=!0,t(o,p)}_.Deflate=r,_.deflate=t,_.deflateRaw=i,_.gzip=n},{"./utils/common":442,"./utils/strings":443,"./zlib/deflate":447,"./zlib/messages":452,"./zlib/zstream":454}],441:[function(e,S,_){var u=e("./zlib/inflate"),y=e("./utils/common"),g=e("./utils/strings"),b=e("./zlib/constants"),w=e("./zlib/messages"),f=e("./zlib/zstream"),v=e("./zlib/gzheader"),h=Object.prototype.toString;function l(m){if(!(this instanceof l))return new l(m);this.options=y.assign({chunkSize:16384,windowBits:0,to:""},m||{});var c=this.options;c.raw&&c.windowBits>=0&&c.windowBits<16&&(c.windowBits=-c.windowBits,c.windowBits===0&&(c.windowBits=-15)),c.windowBits>=0&&c.windowBits<16&&!(m&&m.windowBits)&&(c.windowBits+=32),c.windowBits>15&&c.windowBits<48&&(c.windowBits&15||(c.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;var a=u.inflateInit2(this.strm,c.windowBits);if(a!==b.Z_OK)throw new Error(w[a]);if(this.header=new v,u.inflateGetHeader(this.strm,this.header),c.dictionary&&(typeof c.dictionary=="string"?c.dictionary=g.string2buf(c.dictionary):h.call(c.dictionary)==="[object ArrayBuffer]"&&(c.dictionary=new Uint8Array(c.dictionary)),c.raw&&(a=u.inflateSetDictionary(this.strm,c.dictionary),a!==b.Z_OK)))throw new Error(w[a])}l.prototype.push=function(m,c){var a=this.strm,r=this.options.chunkSize,t=this.options.dictionary,i,n,o,p,E,P=!1;if(this.ended)return!1;n=c===~~c?c:c===!0?b.Z_FINISH:b.Z_NO_FLUSH,typeof m=="string"?a.input=g.binstring2buf(m):h.call(m)==="[object ArrayBuffer]"?a.input=new Uint8Array(m):a.input=m,a.next_in=0,a.avail_in=a.input.length;do{if(a.avail_out===0&&(a.output=new y.Buf8(r),a.next_out=0,a.avail_out=r),i=u.inflate(a,b.Z_NO_FLUSH),i===b.Z_NEED_DICT&&t&&(i=u.inflateSetDictionary(this.strm,t)),i===b.Z_BUF_ERROR&&P===!0&&(i=b.Z_OK,P=!1),i!==b.Z_STREAM_END&&i!==b.Z_OK)return this.onEnd(i),this.ended=!0,!1;a.next_out&&(a.avail_out===0||i===b.Z_STREAM_END||a.avail_in===0&&(n===b.Z_FINISH||n===b.Z_SYNC_FLUSH))&&(this.options.to==="string"?(o=g.utf8border(a.output,a.next_out),p=a.next_out-o,E=g.buf2string(a.output,o),a.next_out=p,a.avail_out=r-p,p&&y.arraySet(a.output,a.output,o,p,0),this.onData(E)):this.onData(y.shrinkBuf(a.output,a.next_out))),a.avail_in===0&&a.avail_out===0&&(P=!0)}while((a.avail_in>0||a.avail_out===0)&&i!==b.Z_STREAM_END);return i===b.Z_STREAM_END&&(n=b.Z_FINISH),n===b.Z_FINISH?(i=u.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===b.Z_OK):(n===b.Z_SYNC_FLUSH&&(this.onEnd(b.Z_OK),a.avail_out=0),!0)},l.prototype.onData=function(m){this.chunks.push(m)},l.prototype.onEnd=function(m){m===b.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=y.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg};function d(m,c){var a=new l(c);if(a.push(m,!0),a.err)throw a.msg||w[a.err];return a.result}function s(m,c){return c=c||{},c.raw=!0,d(m,c)}_.Inflate=l,_.inflate=d,_.inflateRaw=s,_.ungzip=d},{"./utils/common":442,"./utils/strings":443,"./zlib/constants":445,"./zlib/gzheader":448,"./zlib/inflate":450,"./zlib/messages":452,"./zlib/zstream":454}],442:[function(e,S,_){function u(f){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(h){return typeof h}:u=function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},u(f)}var y=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function g(f,v){return Object.prototype.hasOwnProperty.call(f,v)}_.assign=function(f){for(var v=Array.prototype.slice.call(arguments,1);v.length;){var h=v.shift();if(h){if(u(h)!=="object")throw new TypeError(h+"must be non-object");for(var l in h)g(h,l)&&(f[l]=h[l])}}return f},_.shrinkBuf=function(f,v){return f.length===v?f:f.subarray?f.subarray(0,v):(f.length=v,f)};var b={arraySet:function(v,h,l,d,s){if(h.subarray&&v.subarray){v.set(h.subarray(l,l+d),s);return}for(var m=0;m=252?6:w>=248?5:w>=240?4:w>=224?3:w>=192?2:1;b[254]=b[254]=1,_.string2buf=function(v){var h,l,d,s,m,c=v.length,a=0;for(s=0;s>>6,h[m++]=128|l&63):l<65536?(h[m++]=224|l>>>12,h[m++]=128|l>>>6&63,h[m++]=128|l&63):(h[m++]=240|l>>>18,h[m++]=128|l>>>12&63,h[m++]=128|l>>>6&63,h[m++]=128|l&63);return h};function f(v,h){if(h<65534&&(v.subarray&&g||!v.subarray&&y))return String.fromCharCode.apply(null,u.shrinkBuf(v,h));for(var l="",d=0;d4){a[d++]=65533,l+=m-1;continue}for(s&=m===2?31:m===3?15:7;m>1&&l1){a[d++]=65533;continue}s<65536?a[d++]=s:(s-=65536,a[d++]=55296|s>>10&1023,a[d++]=56320|s&1023)}return f(a,d)},_.utf8border=function(v,h){var l;for(h=h||v.length,h>v.length&&(h=v.length),l=h-1;l>=0&&(v[l]&192)===128;)l--;return l<0||l===0?h:l+b[v[l]]>h?l:h}},{"./common":442}],444:[function(e,S,_){function u(y,g,b,w){for(var f=y&65535|0,v=y>>>16&65535|0,h=0;b!==0;){h=b>2e3?2e3:b,b-=h;do f=f+g[w++]|0,v=v+f|0;while(--h);f%=65521,v%=65521}return f|v<<16|0}S.exports=u},{}],445:[function(e,S,_){S.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],446:[function(e,S,_){function u(){for(var b,w=[],f=0;f<256;f++){b=f;for(var v=0;v<8;v++)b=b&1?3988292384^b>>>1:b>>>1;w[f]=b}return w}var y=u();function g(b,w,f,v){var h=y,l=v+f;b^=-1;for(var d=v;d>>8^h[(b^w[d])&255];return b^-1}S.exports=g},{}],447:[function(e,S,_){var u=e("../utils/common"),y=e("./trees"),g=e("./adler32"),b=e("./crc32"),w=e("./messages"),f=0,v=1,h=3,l=4,d=5,s=0,m=1,c=-2,a=-3,r=-5,t=-1,i=1,n=2,o=3,p=4,E=0,P=2,D=8,z=9,B=15,M=8,I=29,T=256,C=T+1+I,O=30,A=19,L=2*C+1,U=15,W=3,$=258,N=$+W+1,F=32,j=42,V=69,te=73,re=91,le=103,ye=113,ge=666,ne=1,J=2,Q=3,he=4,xe=3;function ie(K,Me){return K.msg=w[Me],Me}function se(K){return(K<<1)-(K>4?9:0)}function Ce(K){for(var Me=K.length;--Me>=0;)K[Me]=0}function q(K){var Me=K.state,Le=Me.pending;Le>K.avail_out&&(Le=K.avail_out),Le!==0&&(u.arraySet(K.output,Me.pending_buf,Me.pending_out,Le,K.next_out),K.next_out+=Le,Me.pending_out+=Le,K.total_out+=Le,K.avail_out-=Le,Me.pending-=Le,Me.pending===0&&(Me.pending_out=0))}function G(K,Me){y._tr_flush_block(K,K.block_start>=0?K.block_start:-1,K.strstart-K.block_start,Me),K.block_start=K.strstart,q(K.strm)}function Y(K,Me){K.pending_buf[K.pending++]=Me}function fe(K,Me){K.pending_buf[K.pending++]=Me>>>8&255,K.pending_buf[K.pending++]=Me&255}function we(K,Me,Le,ue){var ke=K.avail_in;return ke>ue&&(ke=ue),ke===0?0:(K.avail_in-=ke,u.arraySet(Me,K.input,K.next_in,ke,Le),K.state.wrap===1?K.adler=g(K.adler,Me,ke,Le):K.state.wrap===2&&(K.adler=b(K.adler,Me,ke,Le)),K.next_in+=ke,K.total_in+=ke,ke)}function _e(K,Me){var Le=K.max_chain_length,ue=K.strstart,ke,Ie,st=K.prev_length,Ge=K.nice_match,rt=K.strstart>K.w_size-N?K.strstart-(K.w_size-N):0,_t=K.window,wt=K.w_mask,Ot=K.prev,pt=K.strstart+$,ct=_t[ue+st-1],At=_t[ue+st];K.prev_length>=K.good_match&&(Le>>=2),Ge>K.lookahead&&(Ge=K.lookahead);do if(ke=Me,!(_t[ke+st]!==At||_t[ke+st-1]!==ct||_t[ke]!==_t[ue]||_t[++ke]!==_t[ue+1])){ue+=2,ke++;do;while(_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&_t[++ue]===_t[++ke]&&uest){if(K.match_start=Me,st=Ie,Ie>=Ge)break;ct=_t[ue+st-1],At=_t[ue+st]}}while((Me=Ot[Me&wt])>rt&&--Le!==0);return st<=K.lookahead?st:K.lookahead}function je(K){var Me=K.w_size,Le,ue,ke,Ie,st;do{if(Ie=K.window_size-K.lookahead-K.strstart,K.strstart>=Me+(Me-N)){u.arraySet(K.window,K.window,Me,Me,0),K.match_start-=Me,K.strstart-=Me,K.block_start-=Me,ue=K.hash_size,Le=ue;do ke=K.head[--Le],K.head[Le]=ke>=Me?ke-Me:0;while(--ue);ue=Me,Le=ue;do ke=K.prev[--Le],K.prev[Le]=ke>=Me?ke-Me:0;while(--ue);Ie+=Me}if(K.strm.avail_in===0)break;if(ue=we(K.strm,K.window,K.strstart+K.lookahead,Ie),K.lookahead+=ue,K.lookahead+K.insert>=W)for(st=K.strstart-K.insert,K.ins_h=K.window[st],K.ins_h=(K.ins_h<K.pending_buf_size-5&&(Le=K.pending_buf_size-5);;){if(K.lookahead<=1){if(je(K),K.lookahead===0&&Me===f)return ne;if(K.lookahead===0)break}K.strstart+=K.lookahead,K.lookahead=0;var ue=K.block_start+Le;if((K.strstart===0||K.strstart>=ue)&&(K.lookahead=K.strstart-ue,K.strstart=ue,G(K,!1),K.strm.avail_out===0)||K.strstart-K.block_start>=K.w_size-N&&(G(K,!1),K.strm.avail_out===0))return ne}return K.insert=0,Me===l?(G(K,!0),K.strm.avail_out===0?Q:he):(K.strstart>K.block_start&&(G(K,!1),K.strm.avail_out===0),ne)}function nt(K,Me){for(var Le,ue;;){if(K.lookahead=W&&(K.ins_h=(K.ins_h<=W)if(ue=y._tr_tally(K,K.strstart-K.match_start,K.match_length-W),K.lookahead-=K.match_length,K.match_length<=K.max_lazy_match&&K.lookahead>=W){K.match_length--;do K.strstart++,K.ins_h=(K.ins_h<=W&&(K.ins_h=(K.ins_h<4096)&&(K.match_length=W-1)),K.prev_length>=W&&K.match_length<=K.prev_length){ke=K.strstart+K.lookahead-W,ue=y._tr_tally(K,K.strstart-1-K.prev_match,K.prev_length-W),K.lookahead-=K.prev_length-1,K.prev_length-=2;do++K.strstart<=ke&&(K.ins_h=(K.ins_h<=W&&K.strstart>0&&(ke=K.strstart-1,ue=st[ke],ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke])){Ie=K.strstart+$;do;while(ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&ue===st[++ke]&&keK.lookahead&&(K.match_length=K.lookahead)}if(K.match_length>=W?(Le=y._tr_tally(K,1,K.match_length-W),K.lookahead-=K.match_length,K.strstart+=K.match_length,K.match_length=0):(Le=y._tr_tally(K,0,K.window[K.strstart]),K.lookahead--,K.strstart++),Le&&(G(K,!1),K.strm.avail_out===0))return ne}return K.insert=0,Me===l?(G(K,!0),K.strm.avail_out===0?Q:he):K.last_lit&&(G(K,!1),K.strm.avail_out===0)?ne:J}function Ue(K,Me){for(var Le;;){if(K.lookahead===0&&(je(K),K.lookahead===0)){if(Me===f)return ne;break}if(K.match_length=0,Le=y._tr_tally(K,0,K.window[K.strstart]),K.lookahead--,K.strstart++,Le&&(G(K,!1),K.strm.avail_out===0))return ne}return K.insert=0,Me===l?(G(K,!0),K.strm.avail_out===0?Q:he):K.last_lit&&(G(K,!1),K.strm.avail_out===0)?ne:J}function Ve(K,Me,Le,ue,ke){this.good_length=K,this.max_lazy=Me,this.nice_length=Le,this.max_chain=ue,this.func=ke}var Qe;Qe=[new Ve(0,0,0,0,Ye),new Ve(4,4,8,4,nt),new Ve(4,5,16,8,nt),new Ve(4,6,32,32,nt),new Ve(4,4,16,16,ut),new Ve(8,16,32,32,ut),new Ve(8,16,128,128,ut),new Ve(8,32,128,256,ut),new Ve(32,128,258,1024,ut),new Ve(32,258,258,4096,ut)];function tt(K){K.window_size=2*K.w_size,Ce(K.head),K.max_lazy_match=Qe[K.level].max_lazy,K.good_match=Qe[K.level].good_length,K.nice_match=Qe[K.level].nice_length,K.max_chain_length=Qe[K.level].max_chain,K.strstart=0,K.block_start=0,K.lookahead=0,K.insert=0,K.match_length=K.prev_length=W-1,K.match_available=0,K.ins_h=0}function oe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=D,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new u.Buf16(L*2),this.dyn_dtree=new u.Buf16((2*O+1)*2),this.bl_tree=new u.Buf16((2*A+1)*2),Ce(this.dyn_ltree),Ce(this.dyn_dtree),Ce(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new u.Buf16(U+1),this.heap=new u.Buf16(2*C+1),Ce(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new u.Buf16(2*C+1),Ce(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Re(K){var Me;return!K||!K.state?ie(K,c):(K.total_in=K.total_out=0,K.data_type=P,Me=K.state,Me.pending=0,Me.pending_out=0,Me.wrap<0&&(Me.wrap=-Me.wrap),Me.status=Me.wrap?j:ye,K.adler=Me.wrap===2?0:1,Me.last_flush=f,y._tr_init(Me),s)}function be(K){var Me=Re(K);return Me===s&&tt(K.state),Me}function Ee(K,Me){return!K||!K.state||K.state.wrap!==2?c:(K.state.gzhead=Me,s)}function pe(K,Me,Le,ue,ke,Ie){if(!K)return c;var st=1;if(Me===t&&(Me=6),ue<0?(st=0,ue=-ue):ue>15&&(st=2,ue-=16),ke<1||ke>z||Le!==D||ue<8||ue>15||Me<0||Me>9||Ie<0||Ie>p)return ie(K,c);ue===8&&(ue=9);var Ge=new oe;return K.state=Ge,Ge.strm=K,Ge.wrap=st,Ge.gzhead=null,Ge.w_bits=ue,Ge.w_size=1<d||Me<0)return K?ie(K,c):c;if(ue=K.state,!K.output||!K.input&&K.avail_in!==0||ue.status===ge&&Me!==l)return ie(K,K.avail_out===0?r:c);if(ue.strm=K,Le=ue.last_flush,ue.last_flush=Me,ue.status===j)if(ue.wrap===2)K.adler=0,Y(ue,31),Y(ue,139),Y(ue,8),ue.gzhead?(Y(ue,(ue.gzhead.text?1:0)+(ue.gzhead.hcrc?2:0)+(ue.gzhead.extra?4:0)+(ue.gzhead.name?8:0)+(ue.gzhead.comment?16:0)),Y(ue,ue.gzhead.time&255),Y(ue,ue.gzhead.time>>8&255),Y(ue,ue.gzhead.time>>16&255),Y(ue,ue.gzhead.time>>24&255),Y(ue,ue.level===9?2:ue.strategy>=n||ue.level<2?4:0),Y(ue,ue.gzhead.os&255),ue.gzhead.extra&&ue.gzhead.extra.length&&(Y(ue,ue.gzhead.extra.length&255),Y(ue,ue.gzhead.extra.length>>8&255)),ue.gzhead.hcrc&&(K.adler=b(K.adler,ue.pending_buf,ue.pending,0)),ue.gzindex=0,ue.status=V):(Y(ue,0),Y(ue,0),Y(ue,0),Y(ue,0),Y(ue,0),Y(ue,ue.level===9?2:ue.strategy>=n||ue.level<2?4:0),Y(ue,xe),ue.status=ye);else{var st=D+(ue.w_bits-8<<4)<<8,Ge=-1;ue.strategy>=n||ue.level<2?Ge=0:ue.level<6?Ge=1:ue.level===6?Ge=2:Ge=3,st|=Ge<<6,ue.strstart!==0&&(st|=F),st+=31-st%31,ue.status=ye,fe(ue,st),ue.strstart!==0&&(fe(ue,K.adler>>>16),fe(ue,K.adler&65535)),K.adler=1}if(ue.status===V)if(ue.gzhead.extra){for(ke=ue.pending;ue.gzindex<(ue.gzhead.extra.length&65535)&&!(ue.pending===ue.pending_buf_size&&(ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),q(K),ke=ue.pending,ue.pending===ue.pending_buf_size));)Y(ue,ue.gzhead.extra[ue.gzindex]&255),ue.gzindex++;ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),ue.gzindex===ue.gzhead.extra.length&&(ue.gzindex=0,ue.status=te)}else ue.status=te;if(ue.status===te)if(ue.gzhead.name){ke=ue.pending;do{if(ue.pending===ue.pending_buf_size&&(ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),q(K),ke=ue.pending,ue.pending===ue.pending_buf_size)){Ie=1;break}ue.gzindexke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),Ie===0&&(ue.gzindex=0,ue.status=re)}else ue.status=re;if(ue.status===re)if(ue.gzhead.comment){ke=ue.pending;do{if(ue.pending===ue.pending_buf_size&&(ue.gzhead.hcrc&&ue.pending>ke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),q(K),ke=ue.pending,ue.pending===ue.pending_buf_size)){Ie=1;break}ue.gzindexke&&(K.adler=b(K.adler,ue.pending_buf,ue.pending-ke,ke)),Ie===0&&(ue.status=le)}else ue.status=le;if(ue.status===le&&(ue.gzhead.hcrc?(ue.pending+2>ue.pending_buf_size&&q(K),ue.pending+2<=ue.pending_buf_size&&(Y(ue,K.adler&255),Y(ue,K.adler>>8&255),K.adler=0,ue.status=ye)):ue.status=ye),ue.pending!==0){if(q(K),K.avail_out===0)return ue.last_flush=-1,s}else if(K.avail_in===0&&se(Me)<=se(Le)&&Me!==l)return ie(K,r);if(ue.status===ge&&K.avail_in!==0)return ie(K,r);if(K.avail_in!==0||ue.lookahead!==0||Me!==f&&ue.status!==ge){var rt=ue.strategy===n?Ue(ue,Me):ue.strategy===o?ot(ue,Me):Qe[ue.level].func(ue,Me);if((rt===Q||rt===he)&&(ue.status=ge),rt===ne||rt===Q)return K.avail_out===0&&(ue.last_flush=-1),s;if(rt===J&&(Me===v?y._tr_align(ue):Me!==d&&(y._tr_stored_block(ue,0,0,!1),Me===h&&(Ce(ue.head),ue.lookahead===0&&(ue.strstart=0,ue.block_start=0,ue.insert=0))),q(K),K.avail_out===0))return ue.last_flush=-1,s}return Me!==l?s:ue.wrap<=0?m:(ue.wrap===2?(Y(ue,K.adler&255),Y(ue,K.adler>>8&255),Y(ue,K.adler>>16&255),Y(ue,K.adler>>24&255),Y(ue,K.total_in&255),Y(ue,K.total_in>>8&255),Y(ue,K.total_in>>16&255),Y(ue,K.total_in>>24&255)):(fe(ue,K.adler>>>16),fe(ue,K.adler&65535)),q(K),ue.wrap>0&&(ue.wrap=-ue.wrap),ue.pending!==0?s:m)}function He(K){var Me;return!K||!K.state?c:(Me=K.state.status,Me!==j&&Me!==V&&Me!==te&&Me!==re&&Me!==le&&Me!==ye&&Me!==ge?ie(K,c):(K.state=null,Me===ye?ie(K,a):s))}function it(K,Me){var Le=Me.length,ue,ke,Ie,st,Ge,rt,_t,wt;if(!K||!K.state||(ue=K.state,st=ue.wrap,st===2||st===1&&ue.status!==j||ue.lookahead))return c;for(st===1&&(K.adler=g(K.adler,Me,Le,0)),ue.wrap=0,Le>=ue.w_size&&(st===0&&(Ce(ue.head),ue.strstart=0,ue.block_start=0,ue.insert=0),wt=new u.Buf8(ue.w_size),u.arraySet(wt,Me,Le-ue.w_size,ue.w_size,0),Me=wt,Le=ue.w_size),Ge=K.avail_in,rt=K.next_in,_t=K.input,K.avail_in=Le,K.next_in=0,K.input=Me,je(ue);ue.lookahead>=W;){ke=ue.strstart,Ie=ue.lookahead-(W-1);do ue.ins_h=(ue.ins_h<>>24,i>>>=z,n-=z,z=D>>>16&255,z===0)O[l++]=D&65535;else if(z&16){B=D&65535,z&=15,z&&(n>>=z,n-=z),n<15&&(i+=C[v++]<>>24,i>>>=z,n-=z,z=D>>>16&255,z&16){if(M=D&65535,z&=15,nm){b.msg="invalid distance too far back",f.mode=u;break e}if(i>>>=z,n-=z,z=l-d,M>z){if(z=M-z,z>a&&f.sane){b.msg="invalid distance too far back",f.mode=u;break e}if(I=0,T=t,r===0){if(I+=c-z,z2;)O[l++]=T[I++],O[l++]=T[I++],O[l++]=T[I++],B-=3;B&&(O[l++]=T[I++],B>1&&(O[l++]=T[I++]))}else{I=l-M;do O[l++]=O[I++],O[l++]=O[I++],O[l++]=O[I++],B-=3;while(B>2);B&&(O[l++]=O[I++],B>1&&(O[l++]=O[I++]))}}else if(z&64){b.msg="invalid distance code",f.mode=u;break e}else{D=p[(D&65535)+(i&(1<>3,v-=B,n-=B<<3,i&=(1<>>24&255)+(pe>>>8&65280)+((pe&65280)<<8)+((pe&255)<<24)}function we(){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 u.Buf16(320),this.work=new u.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _e(pe){var Pe;return!pe||!pe.state?r:(Pe=pe.state,pe.total_in=pe.total_out=Pe.total=0,pe.msg="",Pe.wrap&&(pe.adler=Pe.wrap&1),Pe.mode=p,Pe.last=0,Pe.havedict=0,Pe.dmax=32768,Pe.head=null,Pe.hold=0,Pe.bits=0,Pe.lencode=Pe.lendyn=new u.Buf32(Ce),Pe.distcode=Pe.distdyn=new u.Buf32(q),Pe.sane=1,Pe.back=-1,m)}function je(pe){var Pe;return!pe||!pe.state?r:(Pe=pe.state,Pe.wsize=0,Pe.whave=0,Pe.wnext=0,_e(pe))}function Ye(pe,Pe){var ee,He;return!pe||!pe.state||(He=pe.state,Pe<0?(ee=0,Pe=-Pe):(ee=(Pe>>4)+1,Pe<48&&(Pe&=15)),Pe&&(Pe<8||Pe>15))?r:(He.window!==null&&He.wbits!==Pe&&(He.window=null),He.wrap=ee,He.wbits=Pe,je(pe))}function nt(pe,Pe){var ee,He;return pe?(He=new we,pe.state=He,He.window=null,ee=Ye(pe,Pe),ee!==m&&(pe.state=null),ee):r}function ut(pe){return nt(pe,Y)}var ot=!0,Ue,Ve;function Qe(pe){if(ot){var Pe;for(Ue=new u.Buf32(512),Ve=new u.Buf32(32),Pe=0;Pe<144;)pe.lens[Pe++]=8;for(;Pe<256;)pe.lens[Pe++]=9;for(;Pe<280;)pe.lens[Pe++]=7;for(;Pe<288;)pe.lens[Pe++]=8;for(w(v,pe.lens,0,288,Ue,0,pe.work,{bits:9}),Pe=0;Pe<32;)pe.lens[Pe++]=5;w(h,pe.lens,0,32,Ve,0,pe.work,{bits:5}),ot=!1}pe.lencode=Ue,pe.lenbits=9,pe.distcode=Ve,pe.distbits=5}function tt(pe,Pe,ee,He){var it,K=pe.state;return K.window===null&&(K.wsize=1<=K.wsize?(u.arraySet(K.window,Pe,ee-K.wsize,K.wsize,0),K.wnext=0,K.whave=K.wsize):(it=K.wsize-K.wnext,it>He&&(it=He),u.arraySet(K.window,Pe,ee-He,it,K.wnext),He-=it,He?(u.arraySet(K.window,Pe,ee-He,He,0),K.wnext=He,K.whave=K.wsize):(K.wnext+=it,K.wnext===K.wsize&&(K.wnext=0),K.whave>>8&255,ee.check=g(ee.check,Bt,2,0),ke=0,Ie=0,ee.mode=E;break}if(ee.flags=0,ee.head&&(ee.head.done=!1),!(ee.wrap&1)||(((ke&255)<<8)+(ke>>8))%31){pe.msg="incorrect header check",ee.mode=xe;break}if((ke&15)!==o){pe.msg="unknown compression method",ee.mode=xe;break}if(ke>>>=4,Ie-=4,Ct=(ke&15)+8,ee.wbits===0)ee.wbits=Ct;else if(Ct>ee.wbits){pe.msg="invalid window size",ee.mode=xe;break}ee.dmax=1<>8&1),ee.flags&512&&(Bt[0]=ke&255,Bt[1]=ke>>>8&255,ee.check=g(ee.check,Bt,2,0)),ke=0,Ie=0,ee.mode=P;case P:for(;Ie<32;){if(Le===0)break e;Le--,ke+=He[K++]<>>8&255,Bt[2]=ke>>>16&255,Bt[3]=ke>>>24&255,ee.check=g(ee.check,Bt,4,0)),ke=0,Ie=0,ee.mode=D;case D:for(;Ie<16;){if(Le===0)break e;Le--,ke+=He[K++]<>8),ee.flags&512&&(Bt[0]=ke&255,Bt[1]=ke>>>8&255,ee.check=g(ee.check,Bt,2,0)),ke=0,Ie=0,ee.mode=z;case z:if(ee.flags&1024){for(;Ie<16;){if(Le===0)break e;Le--,ke+=He[K++]<>>8&255,ee.check=g(ee.check,Bt,2,0)),ke=0,Ie=0}else ee.head&&(ee.head.extra=null);ee.mode=B;case B:if(ee.flags&1024&&(rt=ee.length,rt>Le&&(rt=Le),rt&&(ee.head&&(Ct=ee.head.extra_len-ee.length,ee.head.extra||(ee.head.extra=new Array(ee.head.extra_len)),u.arraySet(ee.head.extra,He,K,rt,Ct)),ee.flags&512&&(ee.check=g(ee.check,He,rt,K)),Le-=rt,K+=rt,ee.length-=rt),ee.length))break e;ee.length=0,ee.mode=M;case M:if(ee.flags&2048){if(Le===0)break e;rt=0;do Ct=He[K+rt++],ee.head&&Ct&&ee.length<65536&&(ee.head.name+=String.fromCharCode(Ct));while(Ct&&rt>9&1,ee.head.done=!0),pe.adler=ee.check=0,ee.mode=A;break;case C:for(;Ie<32;){if(Le===0)break e;Le--,ke+=He[K++]<>>=Ie&7,Ie-=Ie&7,ee.mode=J;break}for(;Ie<3;){if(Le===0)break e;Le--,ke+=He[K++]<>>=1,Ie-=1,ke&3){case 0:ee.mode=U;break;case 1:if(Qe(ee),ee.mode=V,Pe===s){ke>>>=2,Ie-=2;break e}break;case 2:ee.mode=N;break;case 3:pe.msg="invalid block type",ee.mode=xe}ke>>>=2,Ie-=2;break;case U:for(ke>>>=Ie&7,Ie-=Ie&7;Ie<32;){if(Le===0)break e;Le--,ke+=He[K++]<>>16^65535)){pe.msg="invalid stored block lengths",ee.mode=xe;break}if(ee.length=ke&65535,ke=0,Ie=0,ee.mode=W,Pe===s)break e;case W:ee.mode=$;case $:if(rt=ee.length,rt){if(rt>Le&&(rt=Le),rt>ue&&(rt=ue),rt===0)break e;u.arraySet(it,He,K,rt,Me),Le-=rt,K+=rt,ue-=rt,Me+=rt,ee.length-=rt;break}ee.mode=A;break;case N:for(;Ie<14;){if(Le===0)break e;Le--,ke+=He[K++]<>>=5,Ie-=5,ee.ndist=(ke&31)+1,ke>>>=5,Ie-=5,ee.ncode=(ke&15)+4,ke>>>=4,Ie-=4,ee.nlen>286||ee.ndist>30){pe.msg="too many length or distance symbols",ee.mode=xe;break}ee.have=0,ee.mode=F;case F:for(;ee.have>>=3,Ie-=3}for(;ee.have<19;)ee.lens[Nr[ee.have++]]=0;if(ee.lencode=ee.lendyn,ee.lenbits=7,Lt={bits:ee.lenbits},St=w(f,ee.lens,0,19,ee.lencode,0,ee.work,Lt),ee.lenbits=Lt.bits,St){pe.msg="invalid code lengths set",ee.mode=xe;break}ee.have=0,ee.mode=j;case j:for(;ee.have>>24,ct=Ot>>>16&255,At=Ot&65535,!(pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>>=pt,Ie-=pt,ee.lens[ee.have++]=At;else{if(At===16){for(Et=pt+2;Ie>>=pt,Ie-=pt,ee.have===0){pe.msg="invalid bit length repeat",ee.mode=xe;break}Ct=ee.lens[ee.have-1],rt=3+(ke&3),ke>>>=2,Ie-=2}else if(At===17){for(Et=pt+3;Ie>>=pt,Ie-=pt,Ct=0,rt=3+(ke&7),ke>>>=3,Ie-=3}else{for(Et=pt+7;Ie>>=pt,Ie-=pt,Ct=0,rt=11+(ke&127),ke>>>=7,Ie-=7}if(ee.have+rt>ee.nlen+ee.ndist){pe.msg="invalid bit length repeat",ee.mode=xe;break}for(;rt--;)ee.lens[ee.have++]=Ct}}if(ee.mode===xe)break;if(ee.lens[256]===0){pe.msg="invalid code -- missing end-of-block",ee.mode=xe;break}if(ee.lenbits=9,Lt={bits:ee.lenbits},St=w(v,ee.lens,0,ee.nlen,ee.lencode,0,ee.work,Lt),ee.lenbits=Lt.bits,St){pe.msg="invalid literal/lengths set",ee.mode=xe;break}if(ee.distbits=6,ee.distcode=ee.distdyn,Lt={bits:ee.distbits},St=w(h,ee.lens,ee.nlen,ee.ndist,ee.distcode,0,ee.work,Lt),ee.distbits=Lt.bits,St){pe.msg="invalid distances set",ee.mode=xe;break}if(ee.mode=V,Pe===s)break e;case V:ee.mode=te;case te:if(Le>=6&&ue>=258){pe.next_out=Me,pe.avail_out=ue,pe.next_in=K,pe.avail_in=Le,ee.hold=ke,ee.bits=Ie,b(pe,Ge),Me=pe.next_out,it=pe.output,ue=pe.avail_out,K=pe.next_in,He=pe.input,Le=pe.avail_in,ke=ee.hold,Ie=ee.bits,ee.mode===A&&(ee.back=-1);break}for(ee.back=0;Ot=ee.lencode[ke&(1<>>24,ct=Ot>>>16&255,At=Ot&65535,!(pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>Pt)],pt=Ot>>>24,ct=Ot>>>16&255,At=Ot&65535,!(Pt+pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>>=Pt,Ie-=Pt,ee.back+=Pt}if(ke>>>=pt,Ie-=pt,ee.back+=pt,ee.length=At,ct===0){ee.mode=ne;break}if(ct&32){ee.back=-1,ee.mode=A;break}if(ct&64){pe.msg="invalid literal/length code",ee.mode=xe;break}ee.extra=ct&15,ee.mode=re;case re:if(ee.extra){for(Et=ee.extra;Ie>>=ee.extra,Ie-=ee.extra,ee.back+=ee.extra}ee.was=ee.length,ee.mode=le;case le:for(;Ot=ee.distcode[ke&(1<>>24,ct=Ot>>>16&255,At=Ot&65535,!(pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>Pt)],pt=Ot>>>24,ct=Ot>>>16&255,At=Ot&65535,!(Pt+pt<=Ie);){if(Le===0)break e;Le--,ke+=He[K++]<>>=Pt,Ie-=Pt,ee.back+=Pt}if(ke>>>=pt,Ie-=pt,ee.back+=pt,ct&64){pe.msg="invalid distance code",ee.mode=xe;break}ee.offset=At,ee.extra=ct&15,ee.mode=ye;case ye:if(ee.extra){for(Et=ee.extra;Ie>>=ee.extra,Ie-=ee.extra,ee.back+=ee.extra}if(ee.offset>ee.dmax){pe.msg="invalid distance too far back",ee.mode=xe;break}ee.mode=ge;case ge:if(ue===0)break e;if(rt=Ge-ue,ee.offset>rt){if(rt=ee.offset-rt,rt>ee.whave&&ee.sane){pe.msg="invalid distance too far back",ee.mode=xe;break}rt>ee.wnext?(rt-=ee.wnext,_t=ee.wsize-rt):_t=ee.wnext-rt,rt>ee.length&&(rt=ee.length),wt=ee.window}else wt=it,_t=Me-ee.offset,rt=ee.length;rt>ue&&(rt=ue),ue-=rt,ee.length-=rt;do it[Me++]=wt[_t++];while(--rt);ee.length===0&&(ee.mode=te);break;case ne:if(ue===0)break e;it[Me++]=ee.length,ue--,ee.mode=te;break;case J:if(ee.wrap){for(;Ie<32;){if(Le===0)break e;Le--,ke|=He[K++]<=1&&te[B]===0;B--);if(M>B&&(M=B),B===0)return i[n++]=1<<24|64<<16|0,i[n++]=1<<24|64<<16|0,p.bits=1,0;for(z=1;z0&&(c===w||B!==1))return-1;for(re[1]=0,P=1;Pg||c===v&&O>b)return 1;for(;;){ge=P-T,o[D]V?(ne=le[ye+o[D]],J=F[j+o[D]]):(ne=32+64,J=0),L=1<>T)+U]=ge<<24|ne<<16|J|0;while(U!==0);for(L=1<>=1;if(L!==0?(A&=L-1,A+=L):A=0,D++,--te[P]===0){if(P===B)break;P=a[r+o[D]]}if(P>M&&(A&$)!==W){for(T===0&&(T=M),N+=z,I=P-T,C=1<g||c===v&&O>b)return 1;W=A&$,i[W]=M<<24|I<<16|N-n|0}}return A!==0&&(i[N+A]=P-T<<24|64<<16|0),p.bits=M,0}},{"../utils/common":442}],452:[function(e,S,_){S.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],453:[function(e,S,_){var u=e("../utils/common"),y=4,g=0,b=1,w=2;function f(oe){for(var Re=oe.length;--Re>=0;)oe[Re]=0}var v=0,h=1,l=2,d=3,s=258,m=29,c=256,a=c+1+m,r=30,t=19,i=2*a+1,n=15,o=16,p=7,E=256,P=16,D=17,z=18,B=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],C=512,O=new Array((a+2)*2);f(O);var A=new Array(r*2);f(A);var L=new Array(C);f(L);var U=new Array(s-d+1);f(U);var W=new Array(m);f(W);var $=new Array(r);f($);function N(oe,Re,be,Ee,pe){this.static_tree=oe,this.extra_bits=Re,this.extra_base=be,this.elems=Ee,this.max_length=pe,this.has_stree=oe&&oe.length}var F,j,V;function te(oe,Re){this.dyn_tree=oe,this.max_code=0,this.stat_desc=Re}function re(oe){return oe<256?L[oe]:L[256+(oe>>>7)]}function le(oe,Re){oe.pending_buf[oe.pending++]=Re&255,oe.pending_buf[oe.pending++]=Re>>>8&255}function ye(oe,Re,be){oe.bi_valid>o-be?(oe.bi_buf|=Re<>o-oe.bi_valid,oe.bi_valid+=be-o):(oe.bi_buf|=Re<>>=1,be<<=1;while(--Re>0);return be>>>1}function J(oe){oe.bi_valid===16?(le(oe,oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0):oe.bi_valid>=8&&(oe.pending_buf[oe.pending++]=oe.bi_buf&255,oe.bi_buf>>=8,oe.bi_valid-=8)}function Q(oe,Re){var be=Re.dyn_tree,Ee=Re.max_code,pe=Re.stat_desc.static_tree,Pe=Re.stat_desc.has_stree,ee=Re.stat_desc.extra_bits,He=Re.stat_desc.extra_base,it=Re.stat_desc.max_length,K,Me,Le,ue,ke,Ie,st=0;for(ue=0;ue<=n;ue++)oe.bl_count[ue]=0;for(be[oe.heap[oe.heap_max]*2+1]=0,K=oe.heap_max+1;Kit&&(ue=it,st++),be[Me*2+1]=ue,!(Me>Ee)&&(oe.bl_count[ue]++,ke=0,Me>=He&&(ke=ee[Me-He]),Ie=be[Me*2],oe.opt_len+=Ie*(ue+ke),Pe&&(oe.static_len+=Ie*(pe[Me*2+1]+ke)));if(st!==0){do{for(ue=it-1;oe.bl_count[ue]===0;)ue--;oe.bl_count[ue]--,oe.bl_count[ue+1]+=2,oe.bl_count[it]--,st-=2}while(st>0);for(ue=it;ue!==0;ue--)for(Me=oe.bl_count[ue];Me!==0;)Le=oe.heap[--K],!(Le>Ee)&&(be[Le*2+1]!==ue&&(oe.opt_len+=(ue-be[Le*2+1])*be[Le*2],be[Le*2+1]=ue),Me--)}}function he(oe,Re,be){var Ee=new Array(n+1),pe=0,Pe,ee;for(Pe=1;Pe<=n;Pe++)Ee[Pe]=pe=pe+be[Pe-1]<<1;for(ee=0;ee<=Re;ee++){var He=oe[ee*2+1];He!==0&&(oe[ee*2]=ne(Ee[He]++,He))}}function xe(){var oe,Re,be,Ee,pe,Pe=new Array(n+1);for(be=0,Ee=0;Ee>=7;Ee8?le(oe,oe.bi_buf):oe.bi_valid>0&&(oe.pending_buf[oe.pending++]=oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0}function Ce(oe,Re,be,Ee){se(oe),Ee&&(le(oe,be),le(oe,~be)),u.arraySet(oe.pending_buf,oe.window,Re,be,oe.pending),oe.pending+=be}function q(oe,Re,be,Ee){var pe=Re*2,Pe=be*2;return oe[pe]>1;ee>=1;ee--)G(oe,be,ee);K=Pe;do ee=oe.heap[1],oe.heap[1]=oe.heap[oe.heap_len--],G(oe,be,1),He=oe.heap[1],oe.heap[--oe.heap_max]=ee,oe.heap[--oe.heap_max]=He,be[K*2]=be[ee*2]+be[He*2],oe.depth[K]=(oe.depth[ee]>=oe.depth[He]?oe.depth[ee]:oe.depth[He])+1,be[ee*2+1]=be[He*2+1]=K,oe.heap[1]=K++,G(oe,be,1);while(oe.heap_len>=2);oe.heap[--oe.heap_max]=oe.heap[1],Q(oe,Re),he(be,it,oe.bl_count)}function we(oe,Re,be){var Ee,pe=-1,Pe,ee=Re[0*2+1],He=0,it=7,K=4;for(ee===0&&(it=138,K=3),Re[(be+1)*2+1]=65535,Ee=0;Ee<=be;Ee++)Pe=ee,ee=Re[(Ee+1)*2+1],!(++He=3&&oe.bl_tree[T[Re]*2+1]===0;Re--);return oe.opt_len+=3*(Re+1)+5+5+4,Re}function Ye(oe,Re,be,Ee){var pe;for(ye(oe,Re-257,5),ye(oe,be-1,5),ye(oe,Ee-4,4),pe=0;pe>>=1)if(Re&1&&oe.dyn_ltree[be*2]!==0)return g;if(oe.dyn_ltree[9*2]!==0||oe.dyn_ltree[10*2]!==0||oe.dyn_ltree[13*2]!==0)return b;for(be=32;be0?(oe.strm.data_type===w&&(oe.strm.data_type=nt(oe)),fe(oe,oe.l_desc),fe(oe,oe.d_desc),ee=je(oe),pe=oe.opt_len+3+7>>>3,Pe=oe.static_len+3+7>>>3,Pe<=pe&&(pe=Pe)):pe=Pe=be+5,be+4<=pe&&Re!==-1?Ue(oe,Re,be,Ee):oe.strategy===y||Pe===pe?(ye(oe,(h<<1)+(Ee?1:0),3),Y(oe,O,A)):(ye(oe,(l<<1)+(Ee?1:0),3),Ye(oe,oe.l_desc.max_code+1,oe.d_desc.max_code+1,ee+1),Y(oe,oe.dyn_ltree,oe.dyn_dtree)),ie(oe),Ee&&se(oe)}function tt(oe,Re,be){return oe.pending_buf[oe.d_buf+oe.last_lit*2]=Re>>>8&255,oe.pending_buf[oe.d_buf+oe.last_lit*2+1]=Re&255,oe.pending_buf[oe.l_buf+oe.last_lit]=be&255,oe.last_lit++,Re===0?oe.dyn_ltree[be*2]++:(oe.matches++,Re--,oe.dyn_ltree[(U[be]+c+1)*2]++,oe.dyn_dtree[re(Re)*2]++),oe.last_lit===oe.lit_bufsize-1}_._tr_init=ot,_._tr_stored_block=Ue,_._tr_flush_block=Qe,_._tr_tally=tt,_._tr_align=Ve},{"../utils/common":442}],454:[function(e,S,_){function u(){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}S.exports=u},{}],455:[function(e,S,_){S.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],456:[function(e,S,_){var u=e("asn1.js");_.certificate=e("./certificate");var y=u.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});_.RSAPrivateKey=y;var g=u.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});_.RSAPublicKey=g;var b=u.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(w),this.key("subjectPublicKey").bitstr())});_.PublicKey=b;var w=u.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),f=u.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(w),this.key("subjectPrivateKey").octstr())});_.PrivateKey=f;var v=u.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});_.EncryptedPrivateKey=v;var h=u.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});_.DSAPrivateKey=h,_.DSAparam=u.define("DSAparam",function(){this.int()});var l=u.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(d),this.key("publicKey").optional().explicit(1).bitstr())});_.ECPrivateKey=l;var d=u.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});_.signature=u.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":457,"asn1.js":167}],457:[function(e,S,_){var u=e("asn1.js"),y=u.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),g=u.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),b=u.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),w=u.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(b),this.key("subjectPublicKey").bitstr())}),f=u.define("RelativeDistinguishedName",function(){this.setof(g)}),v=u.define("RDNSequence",function(){this.seqof(f)}),h=u.define("Name",function(){this.choice({rdnSequence:this.use(v)})}),l=u.define("Validity",function(){this.seq().obj(this.key("notBefore").use(y),this.key("notAfter").use(y))}),d=u.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),s=u.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(b),this.key("issuer").use(h),this.key("validity").use(l),this.key("subject").use(h),this.key("subjectPublicKeyInfo").use(w),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(d).optional())}),m=u.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(s),this.key("signatureAlgorithm").use(b),this.key("signatureValue").bitstr())});S.exports=m},{"asn1.js":167}],458:[function(e,S,_){var u=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,y=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,g=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,b=e("evp_bytestokey"),w=e("browserify-aes"),f=e("safe-buffer").Buffer;S.exports=function(v,h){var l=v.toString(),d=l.match(u),s;if(d){var c="aes"+d[1],a=f.from(d[2],"hex"),r=f.from(d[3].replace(/[\r\n]/g,""),"base64"),t=b(h,a.slice(0,8),parseInt(d[1],10)).key,i=[],n=w.createDecipheriv(c,t,a);i.push(n.update(r)),i.push(n.final()),s=f.concat(i)}else{var m=l.match(g);s=f.from(m[2].replace(/[\r\n]/g,""),"base64")}var o=l.match(y)[1];return{tag:o,data:s}}},{"browserify-aes":188,evp_bytestokey:368,"safe-buffer":494}],459:[function(e,S,_){function u(d){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(m){return typeof m}:u=function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},u(d)}var y=e("./asn1"),g=e("./aesid.json"),b=e("./fixProc"),w=e("browserify-aes"),f=e("pbkdf2"),v=e("safe-buffer").Buffer;S.exports=h;function h(d){var s;u(d)==="object"&&!v.isBuffer(d)&&(s=d.passphrase,d=d.key),typeof d=="string"&&(d=v.from(d));var m=b(d,s),c=m.tag,a=m.data,r,t;switch(c){case"CERTIFICATE":t=y.certificate.decode(a,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(t||(t=y.PublicKey.decode(a,"der")),r=t.algorithm.algorithm.join("."),r){case"1.2.840.113549.1.1.1":return y.RSAPublicKey.decode(t.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return t.subjectPrivateKey=t.subjectPublicKey,{type:"ec",data:t};case"1.2.840.10040.4.1":return t.algorithm.params.pub_key=y.DSAparam.decode(t.subjectPublicKey.data,"der"),{type:"dsa",data:t.algorithm.params};default:throw new Error("unknown key id "+r)}case"ENCRYPTED PRIVATE KEY":a=y.EncryptedPrivateKey.decode(a,"der"),a=l(a,s);case"PRIVATE KEY":switch(t=y.PrivateKey.decode(a,"der"),r=t.algorithm.algorithm.join("."),r){case"1.2.840.113549.1.1.1":return y.RSAPrivateKey.decode(t.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:t.algorithm.curve,privateKey:y.ECPrivateKey.decode(t.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return t.algorithm.params.priv_key=y.DSAparam.decode(t.subjectPrivateKey,"der"),{type:"dsa",params:t.algorithm.params};default:throw new Error("unknown key id "+r)}case"RSA PUBLIC KEY":return y.RSAPublicKey.decode(a,"der");case"RSA PRIVATE KEY":return y.RSAPrivateKey.decode(a,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:y.DSAPrivateKey.decode(a,"der")};case"EC PRIVATE KEY":return a=y.ECPrivateKey.decode(a,"der"),{curve:a.parameters.value,privateKey:a.privateKey};default:throw new Error("unknown key type "+c)}}h.signature=y.signature;function l(d,s){var m=d.algorithm.decrypt.kde.kdeparams.salt,c=parseInt(d.algorithm.decrypt.kde.kdeparams.iters.toString(),10),a=g[d.algorithm.decrypt.cipher.algo.join(".")],r=d.algorithm.decrypt.cipher.iv,t=d.subjectPrivateKey,i=parseInt(a.split("-")[1],10)/8,n=f.pbkdf2Sync(s,m,c,i,"sha1"),o=w.createDecipheriv(a,n,r),p=[];return p.push(o.update(t)),p.push(o.final()),v.concat(p)}},{"./aesid.json":455,"./asn1":456,"./fixProc":458,"browserify-aes":188,pbkdf2:460,"safe-buffer":494}],460:[function(e,S,_){_.pbkdf2=e("./lib/async"),_.pbkdf2Sync=e("./lib/sync")},{"./lib/async":461,"./lib/sync":464}],461:[function(e,S,_){(function(u,y){var g=e("safe-buffer").Buffer,b=e("./precondition"),w=e("./default-encoding"),f=e("./sync"),v=e("./to-buffer"),h,l=y.crypto&&y.crypto.subtle,d={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},s=[];function m(r){if(y.process&&!y.process.browser||!l||!l.importKey||!l.deriveBits)return Promise.resolve(!1);if(s[r]!==void 0)return s[r];h=h||g.alloc(8);var t=c(h,h,10,128,r).then(function(){return!0}).catch(function(){return!1});return s[r]=t,t}function c(r,t,i,n,o){return l.importKey("raw",r,{name:"PBKDF2"},!1,["deriveBits"]).then(function(p){return l.deriveBits({name:"PBKDF2",salt:t,iterations:i,hash:{name:o}},p,n<<3)}).then(function(p){return g.from(p)})}function a(r,t){r.then(function(i){u.nextTick(function(){t(null,i)})},function(i){u.nextTick(function(){t(i)})})}S.exports=function(r,t,i,n,o,p){typeof o=="function"&&(p=o,o=void 0),o=o||"sha1";var E=d[o.toLowerCase()];if(!E||typeof y.Promise!="function")return u.nextTick(function(){var P;try{P=f(r,t,i,n,o)}catch(D){return p(D)}p(null,P)});if(b(i,n),r=v(r,w,"Password"),t=v(t,w,"Salt"),typeof p!="function")throw new Error("No callback provided to pbkdf2");a(m(E).then(function(P){return P?c(r,t,i,n,E):f(r,t,i,n,o)}),p)}}).call(this,e("_process"),typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{"./default-encoding":462,"./precondition":463,"./sync":464,"./to-buffer":465,_process:467,"safe-buffer":494}],462:[function(e,S,_){(function(u){var y;if(u.browser)y="utf-8";else if(u.version){var g=parseInt(u.version.split(".")[0].slice(1),10);y=g>=6?"utf-8":"binary"}else y="utf-8";S.exports=y}).call(this,e("_process"))},{_process:467}],463:[function(e,S,_){var u=Math.pow(2,30)-1;S.exports=function(y,g){if(typeof y!="number")throw new TypeError("Iterations not a number");if(y<0)throw new TypeError("Bad iterations");if(typeof g!="number")throw new TypeError("Key length not a number");if(g<0||g>u||g!==g)throw new TypeError("Bad key length")}},{}],464:[function(e,S,_){var u=e("create-hash/md5"),y=e("ripemd160"),g=e("sha.js"),b=e("safe-buffer").Buffer,w=e("./precondition"),f=e("./default-encoding"),v=e("./to-buffer"),h=b.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function d(c,a,r){var t=s(c),i=c==="sha512"||c==="sha384"?128:64;a.length>i?a=t(a):a.length"u"||!u.version||u.version.indexOf("v0.")===0||u.version.indexOf("v1.")===0&&u.version.indexOf("v1.8.")!==0?S.exports={nextTick:y}:S.exports=u;function y(g,b,w,f){if(typeof g!="function")throw new TypeError('"callback" argument must be a function');var v=arguments.length,h,l;switch(v){case 0:case 1:return u.nextTick(g);case 2:return u.nextTick(function(){g.call(null,b)});case 3:return u.nextTick(function(){g.call(null,b,w)});case 4:return u.nextTick(function(){g.call(null,b,w,f)});default:for(h=new Array(v-1),l=0;l1)for(var n=1;nn||new b(a).cmp(i.modulus)>=0)throw new Error("decryption error");var o;r?o=v(new b(a),i):o=w(a,i);var p=h.alloc(n-o.length);if(o=h.concat([p,o],n),t===4)return l(i,o);if(t===1)return d(i,o,r);if(t===3)return o;throw new Error("unknown padding")};function l(m,c){var a=m.modulus.byteLength(),r=f("sha1").update(h.alloc(0)).digest(),t=r.length;if(c[0]!==0)throw new Error("decryption error");var i=c.slice(1,t+1),n=c.slice(t+1),o=g(i,y(n,t)),p=g(n,y(o,a-t-1));if(s(r,p.slice(0,t)))throw new Error("decryption error");for(var E=t;p[E]===0;)E++;if(p[E++]!==1)throw new Error("decryption error");return p.slice(E)}function d(m,c,a){for(var r=c.slice(0,2),t=2,i=0;c[t++]!==0;)if(t>=c.length){i++;break}var n=c.slice(2,t-1);if((r.toString("hex")!=="0002"&&!a||r.toString("hex")!=="0001"&&a)&&i++,n.length<8&&i++,i)throw new Error("decryption error");return c.slice(t)}function s(m,c){m=h.from(m),c=h.from(c);var a=0,r=m.length;m.length!==c.length&&(a++,r=Math.min(m.length,c.length));for(var t=-1;++t=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return t?h(o,n):v(o,n)};function d(c,a){var r=c.modulus.byteLength(),t=a.length,i=g("sha1").update(l.alloc(0)).digest(),n=i.length,o=2*n;if(t>r-o-2)throw new Error("message too long");var p=l.alloc(r-t-o-2),E=r-n-1,P=y(n),D=w(l.concat([i,p,l.alloc(1,1),a],E),b(P,E)),z=w(P,b(D,n));return new f(l.concat([l.alloc(1),z,D],r))}function s(c,a,r){var t=a.length,i=c.modulus.byteLength();if(t>i-11)throw new Error("message too long");var n;return r?n=l.alloc(i-t-3,255):n=m(i-t-3),new f(l.concat([l.from([0,r?1:2]),n,l.alloc(1),a],i))}function m(c){for(var a=l.allocUnsafe(c),r=0,t=y(c*2),i=0,n;rb)throw new RangeError("requested too many random bytes");var s=f.allocUnsafe(l);if(l>0)if(l>g)for(var m=0;ml||r<0)throw new TypeError("offset must be a uint32");if(r>v||r>t)throw new RangeError("offset out of range")}function s(r,t,i){if(typeof r!="number"||r!==r)throw new TypeError("size must be a number");if(r>l||r<0)throw new TypeError("size must be a uint32");if(r+t>i||r>v)throw new RangeError("buffer too small")}h&&h.getRandomValues||!u.browser?(_.randomFill=m,_.randomFillSync=a):(_.randomFill=g,_.randomFillSync=g);function m(r,t,i,n){if(!f.isBuffer(r)&&!(r instanceof y.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof t=="function")n=t,t=0,i=r.length;else if(typeof i=="function")n=i,i=r.length-t;else if(typeof n!="function")throw new TypeError('"cb" argument must be a function');return d(t,r.length),s(i,t,r.length),c(r,t,i,n)}function c(r,t,i,n){if(u.browser){var o=r.buffer,p=new Uint8Array(o,t,i);if(h.getRandomValues(p),n){u.nextTick(function(){n(null,r)});return}return r}if(n){w(i,function(P,B){if(P)return n(P);B.copy(r,t),n(null,r)});return}var O=w(i);return O.copy(r,t),r}function a(r,t,i){if(typeof t>"u"&&(t=0),!f.isBuffer(r)&&!(r instanceof y.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return d(t,r.length),i===void 0&&(i=r.length-t),s(i,t,r.length),c(r,t,i)}}).call(this,e("_process"),typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{_process:467,randombytes:475,"safe-buffer":494}],477:[function(e,S,_){function u(l){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(s){return typeof s}:u=function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},u(l)}function y(l,d){l.prototype=Object.create(d.prototype),l.prototype.constructor=l,l.__proto__=d}var g={};function b(l,d,s){s||(s=Error);function m(a,r,t){return typeof d=="string"?d:d(a,r,t)}var c=function(a){y(r,a);function r(t,i,n){return a.call(this,m(t,i,n))||this}return r}(s);c.prototype.name=s.name,c.prototype.code=l,g[l]=c}function w(l,d){if(Array.isArray(l)){var s=l.length;return l=l.map(function(m){return String(m)}),s>2?"one of ".concat(d," ").concat(l.slice(0,s-1).join(", "),", or ")+l[s-1]:s===2?"one of ".concat(d," ").concat(l[0]," or ").concat(l[1]):"of ".concat(d," ").concat(l[0])}else return"of ".concat(d," ").concat(String(l))}function f(l,d,s){return l.substr(!s||s<0?0:+s,d.length)===d}function v(l,d,s){return(s===void 0||s>l.length)&&(s=l.length),l.substring(s-d.length,s)===d}function h(l,d,s){return typeof s!="number"&&(s=0),s+d.length>l.length?!1:l.indexOf(d,s)!==-1}b("ERR_INVALID_OPT_VALUE",function(l,d){return'The value "'+d+'" is invalid for option "'+l+'"'},TypeError),b("ERR_INVALID_ARG_TYPE",function(l,d,s){var m;typeof d=="string"&&f(d,"not ")?(m="must not be",d=d.replace(/^not /,"")):m="must be";var c;if(v(l," argument"))c="The ".concat(l," ").concat(m," ").concat(w(d,"type"));else{var a=h(l,".")?"property":"argument";c='The "'.concat(l,'" ').concat(a," ").concat(m," ").concat(w(d,"type"))}return c+=". Received type ".concat(u(s)),c},TypeError),b("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),b("ERR_METHOD_NOT_IMPLEMENTED",function(l){return"The "+l+" method is not implemented"}),b("ERR_STREAM_PREMATURE_CLOSE","Premature close"),b("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" after a stream was destroyed"}),b("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),b("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),b("ERR_STREAM_WRITE_AFTER_END","write after end"),b("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),b("ERR_UNKNOWN_ENCODING",function(l){return"Unknown encoding: "+l},TypeError),b("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),S.exports.codes=g},{}],478:[function(e,S,_){(function(u){var y=Object.keys||function(s){var m=[];for(var c in s)m.push(c);return m};S.exports=h;var g=e("./_stream_readable"),b=e("./_stream_writable");e("inherits")(h,g);for(var w=y(b.prototype),f=0;f0)if(typeof se!="string"&&!Y.objectMode&&Object.getPrototypeOf(se)!==f.prototype&&(se=h(se)),q)Y.endEmitted?z(ne,new p):E(ne,Y,se,!0);else if(Y.ended)z(ne,new n);else{if(Y.destroyed)return!1;Y.reading=!1,Y.decoder&&!Ce?(se=Y.decoder.write(se),Y.objectMode||se.length!==0?E(ne,Y,se,!1):F(ne,Y)):E(ne,Y,se,!1)}else q||(Y.reading=!1,F(ne,Y))}return!Y.ended&&(Y.length=L?ne=L:(ne--,ne|=ne>>>1,ne|=ne>>>2,ne|=ne>>>4,ne|=ne>>>8,ne|=ne>>>16,ne++),ne}function W(ne,se){return ne<=0||se.length===0&&se.ended?0:se.objectMode?1:ne!==ne?se.flowing&&se.length?se.buffer.head.data.length:se.length:(ne>se.highWaterMark&&(se.highWaterMark=$(ne)),ne<=se.length?ne:se.ended?se.length:(se.needReadable=!0,0))}T.prototype.read=function(ne){s("read",ne),ne=parseInt(ne,10);var se=this._readableState,Ce=ne;if(ne!==0&&(se.emittedReadable=!1),ne===0&&se.needReadable&&((se.highWaterMark!==0?se.length>=se.highWaterMark:se.length>0)||se.ended))return s("read: emitReadable",se.length,se.ended),se.length===0&&se.ended?Q(this):N(this),null;if(ne=W(ne,se),ne===0&&se.ended)return se.length===0&&Q(this),null;var q=se.needReadable;s("need readable",q),(se.length===0||se.length-ne0?G=J(ne,se):G=null,G===null?(se.needReadable=se.length<=se.highWaterMark,ne=0):(se.length-=ne,se.awaitDrain=0),se.length===0&&(se.ended||(se.needReadable=!0),Ce!==ne&&se.ended&&Q(this)),G!==null&&this.emit("data",G),G};function U(ne,se){if(s("onEofChunk"),!se.ended){if(se.decoder){var Ce=se.decoder.end();Ce&&Ce.length&&(se.buffer.push(Ce),se.length+=se.objectMode?1:Ce.length)}se.ended=!0,se.sync?N(ne):(se.needReadable=!1,se.emittedReadable||(se.emittedReadable=!0,j(ne)))}}function N(ne){var se=ne._readableState;s("emitReadable",se.needReadable,se.emittedReadable),se.needReadable=!1,se.emittedReadable||(s("emitReadable",se.flowing),se.emittedReadable=!0,u.nextTick(j,ne))}function j(ne){var se=ne._readableState;s("emitReadable_",se.destroyed,se.length,se.ended),!se.destroyed&&(se.length||se.ended)&&(ne.emit("readable"),se.emittedReadable=!1),se.needReadable=!se.flowing&&!se.ended&&se.length<=se.highWaterMark,oe(ne)}function F(ne,se){se.readingMore||(se.readingMore=!0,u.nextTick(V,ne,se))}function V(ne,se){for(;!se.reading&&!se.ended&&(se.length1&&xe(q.pipes,ne)!==-1)&&!je&&(s("false write response, pause",q.awaitDrain),q.awaitDrain++),Ce.pause())}function ut(Qe){s("onerror",Qe),Ve(),ne.removeListener("error",ut),b(ne,"error")===0&&z(ne,Qe)}M(ne,"error",ut);function ot(){ne.removeListener("finish",Ue),Ve()}ne.once("close",ot);function Ue(){s("onfinish"),ne.removeListener("close",ot),Ve()}ne.once("finish",Ue);function Ve(){s("unpipe"),Ce.unpipe(ne)}return ne.emit("pipe",Ce),q.flowing||(s("pipe resume"),Ce.resume()),ne};function re(ne){return function(){var Ce=ne._readableState;s("pipeOnDrain",Ce.awaitDrain),Ce.awaitDrain&&Ce.awaitDrain--,Ce.awaitDrain===0&&b(ne,"data")&&(Ce.flowing=!0,oe(ne))}}T.prototype.unpipe=function(ne){var se=this._readableState,Ce={hasUnpiped:!1};if(se.pipesCount===0)return this;if(se.pipesCount===1)return ne&&ne!==se.pipes?this:(ne||(ne=se.pipes),se.pipes=null,se.pipesCount=0,se.flowing=!1,ne&&ne.emit("unpipe",this,Ce),this);if(!ne){var q=se.pipes,G=se.pipesCount;se.pipes=null,se.pipesCount=0,se.flowing=!1;for(var Y=0;Y0,q.flowing!==!1&&this.resume()):ne==="readable"&&!q.endEmitted&&!q.readableListening&&(q.readableListening=q.needReadable=!0,q.flowing=!1,q.emittedReadable=!1,s("on readable",q.length,q.reading),q.length?N(this):q.reading||u.nextTick(ce,this)),Ce},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(ne,se){var Ce=w.prototype.removeListener.call(this,ne,se);return ne==="readable"&&u.nextTick(ee,this),Ce},T.prototype.removeAllListeners=function(ne){var se=w.prototype.removeAllListeners.apply(this,arguments);return(ne==="readable"||ne===void 0)&&u.nextTick(ee,this),se};function ee(ne){var se=ne._readableState;se.readableListening=ne.listenerCount("readable")>0,se.resumeScheduled&&!se.paused?se.flowing=!0:ne.listenerCount("data")>0&&ne.resume()}function ce(ne){s("readable nexttick read 0"),ne.read(0)}T.prototype.resume=function(){var ne=this._readableState;return ne.flowing||(s("resume"),ne.flowing=!ne.readableListening,ye(this,ne)),ne.paused=!1,this};function ye(ne,se){se.resumeScheduled||(se.resumeScheduled=!0,u.nextTick(ge,ne,se))}function ge(ne,se){s("resume",se.reading),se.reading||ne.read(0),se.resumeScheduled=!1,ne.emit("resume"),oe(ne),se.flowing&&!se.reading&&ne.read(0)}T.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function oe(ne){var se=ne._readableState;for(s("flow",se.flowing);se.flowing&&ne.read()!==null;);}T.prototype.wrap=function(ne){var se=this,Ce=this._readableState,q=!1;ne.on("end",function(){if(s("wrapped end"),Ce.decoder&&!Ce.ended){var fe=Ce.decoder.end();fe&&fe.length&&se.push(fe)}se.push(null)}),ne.on("data",function(fe){if(s("wrapped data"),Ce.decoder&&(fe=Ce.decoder.write(fe)),!(Ce.objectMode&&fe==null)&&!(!Ce.objectMode&&(!fe||!fe.length))){var we=se.push(fe);we||(q=!0,ne.pause())}});for(var G in ne)this[G]===void 0&&typeof ne[G]=="function"&&(this[G]=function(we){return function(){return ne[we].apply(ne,arguments)}}(G));for(var Y=0;Y=se.length?(se.decoder?Ce=se.buffer.join(""):se.buffer.length===1?Ce=se.buffer.first():Ce=se.buffer.concat(se.length),se.buffer.clear()):Ce=se.buffer.consume(ne,se.decoder),Ce}function Q(ne){var se=ne._readableState;s("endReadable",se.endEmitted),se.endEmitted||(se.ended=!0,u.nextTick(he,se,ne))}function he(ne,se){if(s("endReadableNT",ne.endEmitted,ne.length),!ne.endEmitted&&ne.length===0&&(ne.endEmitted=!0,se.readable=!1,se.emit("end"),ne.autoDestroy)){var Ce=se._writableState;(!Ce||Ce.autoDestroy&&Ce.finished)&&se.destroy()}}typeof Symbol=="function"&&(T.from=function(ne,se){return B===void 0&&(B=e("./internal/streams/from")),B(T,ne,se)});function xe(ne,se){for(var Ce=0,q=ne.length;Ce-1))throw new P(J);return this._writableState.defaultEncoding=J,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function E(oe,J,Q){return!oe.objectMode&&oe.decodeStrings!==!1&&typeof J=="string"&&(J=v.from(J,Q)),J}Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function A(oe,J,Q,he,xe,ne){if(!Q){var se=E(J,he,xe);he!==se&&(Q=!0,xe="buffer",he=se)}var Ce=J.objectMode?1:he.length;J.length+=Ce;var q=J.length0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(r){var t={data:r,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var t=this.head,i=""+t.data;t=t.next;)i+=r+t.data;return i}},{key:"concat",value:function(r){if(this.length===0)return h.alloc(0);for(var t=h.allocUnsafe(r>>>0),i=this.head,n=0;i;)m(i.data,t,n),n+=i.data.length,i=i.next;return t}},{key:"consume",value:function(r,t){var i;return ro.length?o.length:r;if(p===o.length?n+=o:n+=o.slice(0,r),r-=p,r===0){p===o.length?(++i,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(p));break}++i}return this.length-=i,n}},{key:"_getBuffer",value:function(r){var t=h.allocUnsafe(r),i=this.head,n=1;for(i.data.copy(t),r-=i.data.length;i=i.next;){var o=i.data,p=r>o.length?o.length:r;if(o.copy(t,t.length-r,0,p),r-=p,r===0){p===o.length?(++n,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=o.slice(p));break}++n}return this.length-=n,t}},{key:s,value:function(r,t){return d(this,y({},t,{depth:0,customInspect:!1}))}}]),c}()},{buffer:216,util:185}],485:[function(e,S,_){(function(u){function y(h,l){var d=this,s=this._readableState&&this._readableState.destroyed,m=this._writableState&&this._writableState.destroyed;return s||m?(l?l(h):h&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,u.nextTick(f,this,h)):u.nextTick(f,this,h)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(h||null,function(c){!l&&c?d._writableState?d._writableState.errorEmitted?u.nextTick(b,d):(d._writableState.errorEmitted=!0,u.nextTick(g,d,c)):u.nextTick(g,d,c):l?(u.nextTick(b,d),l(c)):u.nextTick(b,d)}),this)}function g(h,l){f(h,l),b(h)}function b(h){h._writableState&&!h._writableState.emitClose||h._readableState&&!h._readableState.emitClose||h.emit("close")}function w(){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 f(h,l){h.emit("error",l)}function v(h,l){var d=h._readableState,s=h._writableState;d&&d.autoDestroy||s&&s.autoDestroy?h.destroy(l):h.emit("error",l)}S.exports={destroy:y,undestroy:w,errorOrDestroy:v}}).call(this,e("_process"))},{_process:467}],486:[function(e,S,_){var u=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function y(f){var v=!1;return function(){if(!v){v=!0;for(var h=arguments.length,l=new Array(h),d=0;d0;return h(o,O,P,function(B){i||(i=B),B&&n.forEach(l),!O&&(n.forEach(l),t(i))})});return a.reduce(d)}S.exports=m},{"../../../errors":477,"./end-of-stream":486}],489:[function(e,S,_){var u=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function y(b,w,f){return b.highWaterMark!=null?b.highWaterMark:w?b[f]:null}function g(b,w,f,v){var h=y(w,v,f);if(h!=null){if(!(isFinite(h)&&Math.floor(h)===h)||h<0){var l=v?f:"highWaterMark";throw new u(l,h)}return Math.floor(h)}return b.objectMode?16:16*1024}S.exports={getHighWaterMark:g}},{"../../../errors":477}],490:[function(e,S,_){S.exports=e("events").EventEmitter},{events:367}],491:[function(e,S,_){_=S.exports=e("./lib/_stream_readable.js"),_.Stream=_,_.Readable=_,_.Writable=e("./lib/_stream_writable.js"),_.Duplex=e("./lib/_stream_duplex.js"),_.Transform=e("./lib/_stream_transform.js"),_.PassThrough=e("./lib/_stream_passthrough.js"),_.finished=e("./lib/internal/streams/end-of-stream.js"),_.pipeline=e("./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(e,S,_){function u(g){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(w){return typeof w}:u=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},u(g)}var y=function(g){var b=Object.prototype,w=b.hasOwnProperty,f,v=typeof Symbol=="function"?Symbol:{},h=v.iterator||"@@iterator",l=v.asyncIterator||"@@asyncIterator",d=v.toStringTag||"@@toStringTag";function s(U,N,j){return Object.defineProperty(U,N,{value:j,enumerable:!0,configurable:!0,writable:!0}),U[N]}try{s({},"")}catch{s=function(j,F,V){return j[F]=V}}function m(U,N,j,F){var V=N&&N.prototype instanceof o?N:o,re=Object.create(V.prototype),ee=new L(F||[]);return re._invoke=T(U,j,ee),re}g.wrap=m;function c(U,N,j){try{return{type:"normal",arg:U.call(N,j)}}catch(F){return{type:"throw",arg:F}}}var a="suspendedStart",r="suspendedYield",t="executing",i="completed",n={};function o(){}function p(){}function O(){}var P={};P[h]=function(){return this};var B=Object.getPrototypeOf,z=B&&B(B($([])));z&&z!==b&&w.call(z,h)&&(P=z);var D=O.prototype=o.prototype=Object.create(P);p.prototype=D.constructor=O,O.constructor=p,p.displayName=s(O,d,"GeneratorFunction");function M(U){["next","throw","return"].forEach(function(N){s(U,N,function(j){return this._invoke(N,j)})})}g.isGeneratorFunction=function(U){var N=typeof U=="function"&&U.constructor;return N?N===p||(N.displayName||N.name)==="GeneratorFunction":!1},g.mark=function(U){return Object.setPrototypeOf?Object.setPrototypeOf(U,O):(U.__proto__=O,s(U,d,"GeneratorFunction")),U.prototype=Object.create(D),U},g.awrap=function(U){return{__await:U}};function I(U,N){function j(re,ee,ce,ye){var ge=c(U[re],U,ee);if(ge.type==="throw")ye(ge.arg);else{var oe=ge.arg,J=oe.value;return J&&u(J)==="object"&&w.call(J,"__await")?N.resolve(J.__await).then(function(Q){j("next",Q,ce,ye)},function(Q){j("throw",Q,ce,ye)}):N.resolve(J).then(function(Q){oe.value=Q,ce(oe)},function(Q){return j("throw",Q,ce,ye)})}}var F;function V(re,ee){function ce(){return new N(function(ye,ge){j(re,ee,ye,ge)})}return F=F?F.then(ce,ce):ce()}this._invoke=V}M(I.prototype),I.prototype[l]=function(){return this},g.AsyncIterator=I,g.async=function(U,N,j,F,V){V===void 0&&(V=Promise);var re=new I(m(U,N,j,F),V);return g.isGeneratorFunction(N)?re:re.next().then(function(ee){return ee.done?ee.value:re.next()})};function T(U,N,j){var F=a;return function(re,ee){if(F===t)throw new Error("Generator is already running");if(F===i){if(re==="throw")throw ee;return W()}for(j.method=re,j.arg=ee;;){var ce=j.delegate;if(ce){var ye=C(ce,j);if(ye){if(ye===n)continue;return ye}}if(j.method==="next")j.sent=j._sent=j.arg;else if(j.method==="throw"){if(F===a)throw F=i,j.arg;j.dispatchException(j.arg)}else j.method==="return"&&j.abrupt("return",j.arg);F=t;var ge=c(U,N,j);if(ge.type==="normal"){if(F=j.done?i:r,ge.arg===n)continue;return{value:ge.arg,done:j.done}}else ge.type==="throw"&&(F=i,j.method="throw",j.arg=ge.arg)}}}function C(U,N){var j=U.iterator[N.method];if(j===f){if(N.delegate=null,N.method==="throw"){if(U.iterator.return&&(N.method="return",N.arg=f,C(U,N),N.method==="throw"))return n;N.method="throw",N.arg=new TypeError("The iterator does not provide a 'throw' method")}return n}var F=c(j,U.iterator,N.arg);if(F.type==="throw")return N.method="throw",N.arg=F.arg,N.delegate=null,n;var V=F.arg;if(!V)return N.method="throw",N.arg=new TypeError("iterator result is not an object"),N.delegate=null,n;if(V.done)N[U.resultName]=V.value,N.next=U.nextLoc,N.method!=="return"&&(N.method="next",N.arg=f);else return V;return N.delegate=null,n}M(D),s(D,d,"Generator"),D[h]=function(){return this},D.toString=function(){return"[object Generator]"};function E(U){var N={tryLoc:U[0]};1 in U&&(N.catchLoc=U[1]),2 in U&&(N.finallyLoc=U[2],N.afterLoc=U[3]),this.tryEntries.push(N)}function A(U){var N=U.completion||{};N.type="normal",delete N.arg,U.completion=N}function L(U){this.tryEntries=[{tryLoc:"root"}],U.forEach(E,this),this.reset(!0)}g.keys=function(U){var N=[];for(var j in U)N.push(j);return N.reverse(),function F(){for(;N.length;){var V=N.pop();if(V in U)return F.value=V,F.done=!1,F}return F.done=!0,F}};function $(U){if(U){var N=U[h];if(N)return N.call(U);if(typeof U.next=="function")return U;if(!isNaN(U.length)){var j=-1,F=function V(){for(;++j=0;--V){var re=this.tryEntries[V],ee=re.completion;if(re.tryLoc==="root")return F("end");if(re.tryLoc<=this.prev){var ce=w.call(re,"catchLoc"),ye=w.call(re,"finallyLoc");if(ce&&ye){if(this.prev=0;--F){var V=this.tryEntries[F];if(V.tryLoc<=this.prev&&w.call(V,"finallyLoc")&&this.prev=0;--j){var F=this.tryEntries[j];if(F.finallyLoc===N)return this.complete(F.completion,F.afterLoc),A(F),n}},catch:function(N){for(var j=this.tryEntries.length-1;j>=0;--j){var F=this.tryEntries[j];if(F.tryLoc===N){var V=F.completion;if(V.type==="throw"){var re=V.arg;A(F)}return re}}throw new Error("illegal catch attempt")},delegateYield:function(N,j,F){return this.delegate={iterator:$(N),resultName:j,nextLoc:F},this.method==="next"&&(this.arg=f),n}},g}((typeof S>"u"?"undefined":u(S))==="object"?S.exports:{});try{regeneratorRuntime=y}catch{Function("r","regeneratorRuntime = r")(y)}},{}],493:[function(e,S,_){var u=e("buffer").Buffer,y=e("inherits"),g=e("hash-base"),b=new Array(16),w=[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],f=[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],v=[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],h=[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],l=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0];function s(){g.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}y(s,g),s.prototype._update=function(){for(var n=b,o=0;o<16;++o)n[o]=this._block.readInt32LE(o*4);for(var p=this._a|0,O=this._b|0,P=this._c|0,B=this._d|0,z=this._e|0,D=this._a|0,M=this._b|0,I=this._c|0,T=this._d|0,C=this._e|0,E=0;E<80;E+=1){var A,L;E<16?(A=c(p,O,P,B,z,n[w[E]],l[0],v[E]),L=i(D,M,I,T,C,n[f[E]],d[0],h[E])):E<32?(A=a(p,O,P,B,z,n[w[E]],l[1],v[E]),L=t(D,M,I,T,C,n[f[E]],d[1],h[E])):E<48?(A=r(p,O,P,B,z,n[w[E]],l[2],v[E]),L=r(D,M,I,T,C,n[f[E]],d[2],h[E])):E<64?(A=t(p,O,P,B,z,n[w[E]],l[3],v[E]),L=a(D,M,I,T,C,n[f[E]],d[3],h[E])):(A=i(p,O,P,B,z,n[w[E]],l[4],v[E]),L=c(D,M,I,T,C,n[f[E]],d[4],h[E])),p=z,z=B,B=m(P,10),P=O,O=A,D=C,C=T,T=m(I,10),I=M,M=L}var $=this._b+P+T|0;this._b=this._c+B+C|0,this._c=this._d+z+D|0,this._d=this._e+p+M|0,this._e=this._a+O+I|0,this._a=$},s.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 n=u.alloc?u.alloc(20):new u(20);return n.writeInt32LE(this._a,0),n.writeInt32LE(this._b,4),n.writeInt32LE(this._c,8),n.writeInt32LE(this._d,12),n.writeInt32LE(this._e,16),n};function m(n,o){return n<>>32-o}function c(n,o,p,O,P,B,z,D){return m(n+(o^p^O)+B+z|0,D)+P|0}function a(n,o,p,O,P,B,z,D){return m(n+(o&p|~o&O)+B+z|0,D)+P|0}function r(n,o,p,O,P,B,z,D){return m(n+((o|~p)^O)+B+z|0,D)+P|0}function t(n,o,p,O,P,B,z,D){return m(n+(o&O|p&~O)+B+z|0,D)+P|0}function i(n,o,p,O,P,B,z,D){return m(n+(o^(p|~O))+B+z|0,D)+P|0}S.exports=s},{buffer:216,"hash-base":370,inherits:387}],494:[function(e,S,_){var u=e("buffer"),y=u.Buffer;function g(w,f){for(var v in w)f[v]=w[v]}y.from&&y.alloc&&y.allocUnsafe&&y.allocUnsafeSlow?S.exports=u:(g(u,_),_.Buffer=b);function b(w,f,v){return y(w,f,v)}g(y,b),b.from=function(w,f,v){if(typeof w=="number")throw new TypeError("Argument must not be a number");return y(w,f,v)},b.alloc=function(w,f,v){if(typeof w!="number")throw new TypeError("Argument must be a number");var h=y(w);return f!==void 0?typeof v=="string"?h.fill(f,v):h.fill(f):h.fill(0),h},b.allocUnsafe=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return y(w)},b.allocUnsafeSlow=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(w)}},{buffer:216}],495:[function(e,S,_){(function(u){function y(h){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(d){return typeof d}:y=function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},y(h)}var g=e("buffer"),b=g.Buffer,w={},f;for(f in g)g.hasOwnProperty(f)&&(f==="SlowBuffer"||f==="Buffer"||(w[f]=g[f]));var v=w.Buffer={};for(f in b)b.hasOwnProperty(f)&&(f==="allocUnsafe"||f==="allocUnsafeSlow"||(v[f]=b[f]));if(w.Buffer.prototype=b.prototype,(!v.from||v.from===Uint8Array.from)&&(v.from=function(h,l,d){if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+y(h));if(h&&typeof h.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+y(h));return b(h,l,d)}),v.alloc||(v.alloc=function(h,l,d){if(typeof h!="number")throw new TypeError('The "size" argument must be of type number. Received type '+y(h));if(h<0||h>=2*(1<<30))throw new RangeError('The value "'+h+'" is invalid for option "size"');var s=b(h);return!l||l.length===0?s.fill(0):typeof d=="string"?s.fill(l,d):s.fill(l),s}),!w.kStringMaxLength)try{w.kStringMaxLength=u.binding("buffer").kStringMaxLength}catch{}w.constants||(w.constants={MAX_LENGTH:w.kMaxLength},w.kStringMaxLength&&(w.constants.MAX_STRING_LENGTH=w.kStringMaxLength)),S.exports=w}).call(this,e("_process"))},{_process:467,buffer:216}],496:[function(e,S,_){function u(yt,Ke){var me;if(typeof Symbol>"u"||yt[Symbol.iterator]==null){if(Array.isArray(yt)||(me=h(yt))||Ke&&yt&&typeof yt.length=="number"){me&&(yt=me);var Be=0,Fe=function(){};return{s:Fe,n:function(){return Be>=yt.length?{done:!0}:{done:!1,value:yt[Be++]}},e:function(gr){throw gr},f:Fe}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +use chrome, FireFox or Internet Explorer 11`)}var b=e("safe-buffer"),w=e("randombytes"),f=b.Buffer,v=b.kMaxLength,h=y.crypto||y.msCrypto,l=Math.pow(2,32)-1;function d(r,t){if(typeof r!="number"||r!==r)throw new TypeError("offset must be a number");if(r>l||r<0)throw new TypeError("offset must be a uint32");if(r>v||r>t)throw new RangeError("offset out of range")}function s(r,t,i){if(typeof r!="number"||r!==r)throw new TypeError("size must be a number");if(r>l||r<0)throw new TypeError("size must be a uint32");if(r+t>i||r>v)throw new RangeError("buffer too small")}h&&h.getRandomValues||!u.browser?(_.randomFill=m,_.randomFillSync=a):(_.randomFill=g,_.randomFillSync=g);function m(r,t,i,n){if(!f.isBuffer(r)&&!(r instanceof y.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof t=="function")n=t,t=0,i=r.length;else if(typeof i=="function")n=i,i=r.length-t;else if(typeof n!="function")throw new TypeError('"cb" argument must be a function');return d(t,r.length),s(i,t,r.length),c(r,t,i,n)}function c(r,t,i,n){if(u.browser){var o=r.buffer,p=new Uint8Array(o,t,i);if(h.getRandomValues(p),n){u.nextTick(function(){n(null,r)});return}return r}if(n){w(i,function(P,D){if(P)return n(P);D.copy(r,t),n(null,r)});return}var E=w(i);return E.copy(r,t),r}function a(r,t,i){if(typeof t>"u"&&(t=0),!f.isBuffer(r)&&!(r instanceof y.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return d(t,r.length),i===void 0&&(i=r.length-t),s(i,t,r.length),c(r,t,i)}}).call(this,e("_process"),typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{_process:467,randombytes:475,"safe-buffer":494}],477:[function(e,S,_){function u(l){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(s){return typeof s}:u=function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},u(l)}function y(l,d){l.prototype=Object.create(d.prototype),l.prototype.constructor=l,l.__proto__=d}var g={};function b(l,d,s){s||(s=Error);function m(a,r,t){return typeof d=="string"?d:d(a,r,t)}var c=function(a){y(r,a);function r(t,i,n){return a.call(this,m(t,i,n))||this}return r}(s);c.prototype.name=s.name,c.prototype.code=l,g[l]=c}function w(l,d){if(Array.isArray(l)){var s=l.length;return l=l.map(function(m){return String(m)}),s>2?"one of ".concat(d," ").concat(l.slice(0,s-1).join(", "),", or ")+l[s-1]:s===2?"one of ".concat(d," ").concat(l[0]," or ").concat(l[1]):"of ".concat(d," ").concat(l[0])}else return"of ".concat(d," ").concat(String(l))}function f(l,d,s){return l.substr(!s||s<0?0:+s,d.length)===d}function v(l,d,s){return(s===void 0||s>l.length)&&(s=l.length),l.substring(s-d.length,s)===d}function h(l,d,s){return typeof s!="number"&&(s=0),s+d.length>l.length?!1:l.indexOf(d,s)!==-1}b("ERR_INVALID_OPT_VALUE",function(l,d){return'The value "'+d+'" is invalid for option "'+l+'"'},TypeError),b("ERR_INVALID_ARG_TYPE",function(l,d,s){var m;typeof d=="string"&&f(d,"not ")?(m="must not be",d=d.replace(/^not /,"")):m="must be";var c;if(v(l," argument"))c="The ".concat(l," ").concat(m," ").concat(w(d,"type"));else{var a=h(l,".")?"property":"argument";c='The "'.concat(l,'" ').concat(a," ").concat(m," ").concat(w(d,"type"))}return c+=". Received type ".concat(u(s)),c},TypeError),b("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),b("ERR_METHOD_NOT_IMPLEMENTED",function(l){return"The "+l+" method is not implemented"}),b("ERR_STREAM_PREMATURE_CLOSE","Premature close"),b("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" after a stream was destroyed"}),b("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),b("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),b("ERR_STREAM_WRITE_AFTER_END","write after end"),b("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),b("ERR_UNKNOWN_ENCODING",function(l){return"Unknown encoding: "+l},TypeError),b("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),S.exports.codes=g},{}],478:[function(e,S,_){(function(u){var y=Object.keys||function(s){var m=[];for(var c in s)m.push(c);return m};S.exports=h;var g=e("./_stream_readable"),b=e("./_stream_writable");e("inherits")(h,g);for(var w=y(b.prototype),f=0;f0)if(typeof se!="string"&&!Y.objectMode&&Object.getPrototypeOf(se)!==f.prototype&&(se=h(se)),q)Y.endEmitted?z(ie,new p):O(ie,Y,se,!0);else if(Y.ended)z(ie,new n);else{if(Y.destroyed)return!1;Y.reading=!1,Y.decoder&&!Ce?(se=Y.decoder.write(se),Y.objectMode||se.length!==0?O(ie,Y,se,!1):j(ie,Y)):O(ie,Y,se,!1)}else q||(Y.reading=!1,j(ie,Y))}return!Y.ended&&(Y.length=L?ie=L:(ie--,ie|=ie>>>1,ie|=ie>>>2,ie|=ie>>>4,ie|=ie>>>8,ie|=ie>>>16,ie++),ie}function W(ie,se){return ie<=0||se.length===0&&se.ended?0:se.objectMode?1:ie!==ie?se.flowing&&se.length?se.buffer.head.data.length:se.length:(ie>se.highWaterMark&&(se.highWaterMark=U(ie)),ie<=se.length?ie:se.ended?se.length:(se.needReadable=!0,0))}T.prototype.read=function(ie){s("read",ie),ie=parseInt(ie,10);var se=this._readableState,Ce=ie;if(ie!==0&&(se.emittedReadable=!1),ie===0&&se.needReadable&&((se.highWaterMark!==0?se.length>=se.highWaterMark:se.length>0)||se.ended))return s("read: emitReadable",se.length,se.ended),se.length===0&&se.ended?Q(this):N(this),null;if(ie=W(ie,se),ie===0&&se.ended)return se.length===0&&Q(this),null;var q=se.needReadable;s("need readable",q),(se.length===0||se.length-ie0?G=J(ie,se):G=null,G===null?(se.needReadable=se.length<=se.highWaterMark,ie=0):(se.length-=ie,se.awaitDrain=0),se.length===0&&(se.ended||(se.needReadable=!0),Ce!==ie&&se.ended&&Q(this)),G!==null&&this.emit("data",G),G};function $(ie,se){if(s("onEofChunk"),!se.ended){if(se.decoder){var Ce=se.decoder.end();Ce&&Ce.length&&(se.buffer.push(Ce),se.length+=se.objectMode?1:Ce.length)}se.ended=!0,se.sync?N(ie):(se.needReadable=!1,se.emittedReadable||(se.emittedReadable=!0,F(ie)))}}function N(ie){var se=ie._readableState;s("emitReadable",se.needReadable,se.emittedReadable),se.needReadable=!1,se.emittedReadable||(s("emitReadable",se.flowing),se.emittedReadable=!0,u.nextTick(F,ie))}function F(ie){var se=ie._readableState;s("emitReadable_",se.destroyed,se.length,se.ended),!se.destroyed&&(se.length||se.ended)&&(ie.emit("readable"),se.emittedReadable=!1),se.needReadable=!se.flowing&&!se.ended&&se.length<=se.highWaterMark,ne(ie)}function j(ie,se){se.readingMore||(se.readingMore=!0,u.nextTick(V,ie,se))}function V(ie,se){for(;!se.reading&&!se.ended&&(se.length1&&xe(q.pipes,ie)!==-1)&&!je&&(s("false write response, pause",q.awaitDrain),q.awaitDrain++),Ce.pause())}function ut(Qe){s("onerror",Qe),Ve(),ie.removeListener("error",ut),b(ie,"error")===0&&z(ie,Qe)}M(ie,"error",ut);function ot(){ie.removeListener("finish",Ue),Ve()}ie.once("close",ot);function Ue(){s("onfinish"),ie.removeListener("close",ot),Ve()}ie.once("finish",Ue);function Ve(){s("unpipe"),Ce.unpipe(ie)}return ie.emit("pipe",Ce),q.flowing||(s("pipe resume"),Ce.resume()),ie};function te(ie){return function(){var Ce=ie._readableState;s("pipeOnDrain",Ce.awaitDrain),Ce.awaitDrain&&Ce.awaitDrain--,Ce.awaitDrain===0&&b(ie,"data")&&(Ce.flowing=!0,ne(ie))}}T.prototype.unpipe=function(ie){var se=this._readableState,Ce={hasUnpiped:!1};if(se.pipesCount===0)return this;if(se.pipesCount===1)return ie&&ie!==se.pipes?this:(ie||(ie=se.pipes),se.pipes=null,se.pipesCount=0,se.flowing=!1,ie&&ie.emit("unpipe",this,Ce),this);if(!ie){var q=se.pipes,G=se.pipesCount;se.pipes=null,se.pipesCount=0,se.flowing=!1;for(var Y=0;Y0,q.flowing!==!1&&this.resume()):ie==="readable"&&!q.endEmitted&&!q.readableListening&&(q.readableListening=q.needReadable=!0,q.flowing=!1,q.emittedReadable=!1,s("on readable",q.length,q.reading),q.length?N(this):q.reading||u.nextTick(le,this)),Ce},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(ie,se){var Ce=w.prototype.removeListener.call(this,ie,se);return ie==="readable"&&u.nextTick(re,this),Ce},T.prototype.removeAllListeners=function(ie){var se=w.prototype.removeAllListeners.apply(this,arguments);return(ie==="readable"||ie===void 0)&&u.nextTick(re,this),se};function re(ie){var se=ie._readableState;se.readableListening=ie.listenerCount("readable")>0,se.resumeScheduled&&!se.paused?se.flowing=!0:ie.listenerCount("data")>0&&ie.resume()}function le(ie){s("readable nexttick read 0"),ie.read(0)}T.prototype.resume=function(){var ie=this._readableState;return ie.flowing||(s("resume"),ie.flowing=!ie.readableListening,ye(this,ie)),ie.paused=!1,this};function ye(ie,se){se.resumeScheduled||(se.resumeScheduled=!0,u.nextTick(ge,ie,se))}function ge(ie,se){s("resume",se.reading),se.reading||ie.read(0),se.resumeScheduled=!1,ie.emit("resume"),ne(ie),se.flowing&&!se.reading&&ie.read(0)}T.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function ne(ie){var se=ie._readableState;for(s("flow",se.flowing);se.flowing&&ie.read()!==null;);}T.prototype.wrap=function(ie){var se=this,Ce=this._readableState,q=!1;ie.on("end",function(){if(s("wrapped end"),Ce.decoder&&!Ce.ended){var fe=Ce.decoder.end();fe&&fe.length&&se.push(fe)}se.push(null)}),ie.on("data",function(fe){if(s("wrapped data"),Ce.decoder&&(fe=Ce.decoder.write(fe)),!(Ce.objectMode&&fe==null)&&!(!Ce.objectMode&&(!fe||!fe.length))){var we=se.push(fe);we||(q=!0,ie.pause())}});for(var G in ie)this[G]===void 0&&typeof ie[G]=="function"&&(this[G]=function(we){return function(){return ie[we].apply(ie,arguments)}}(G));for(var Y=0;Y=se.length?(se.decoder?Ce=se.buffer.join(""):se.buffer.length===1?Ce=se.buffer.first():Ce=se.buffer.concat(se.length),se.buffer.clear()):Ce=se.buffer.consume(ie,se.decoder),Ce}function Q(ie){var se=ie._readableState;s("endReadable",se.endEmitted),se.endEmitted||(se.ended=!0,u.nextTick(he,se,ie))}function he(ie,se){if(s("endReadableNT",ie.endEmitted,ie.length),!ie.endEmitted&&ie.length===0&&(ie.endEmitted=!0,se.readable=!1,se.emit("end"),ie.autoDestroy)){var Ce=se._writableState;(!Ce||Ce.autoDestroy&&Ce.finished)&&se.destroy()}}typeof Symbol=="function"&&(T.from=function(ie,se){return D===void 0&&(D=e("./internal/streams/from")),D(T,ie,se)});function xe(ie,se){for(var Ce=0,q=ie.length;Ce-1))throw new P(J);return this._writableState.defaultEncoding=J,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function O(ne,J,Q){return!ne.objectMode&&ne.decodeStrings!==!1&&typeof J=="string"&&(J=v.from(J,Q)),J}Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function A(ne,J,Q,he,xe,ie){if(!Q){var se=O(J,he,xe);he!==se&&(Q=!0,xe="buffer",he=se)}var Ce=J.objectMode?1:he.length;J.length+=Ce;var q=J.length0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(r){var t={data:r,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var t=this.head,i=""+t.data;t=t.next;)i+=r+t.data;return i}},{key:"concat",value:function(r){if(this.length===0)return h.alloc(0);for(var t=h.allocUnsafe(r>>>0),i=this.head,n=0;i;)m(i.data,t,n),n+=i.data.length,i=i.next;return t}},{key:"consume",value:function(r,t){var i;return ro.length?o.length:r;if(p===o.length?n+=o:n+=o.slice(0,r),r-=p,r===0){p===o.length?(++i,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(p));break}++i}return this.length-=i,n}},{key:"_getBuffer",value:function(r){var t=h.allocUnsafe(r),i=this.head,n=1;for(i.data.copy(t),r-=i.data.length;i=i.next;){var o=i.data,p=r>o.length?o.length:r;if(o.copy(t,t.length-r,0,p),r-=p,r===0){p===o.length?(++n,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=o.slice(p));break}++n}return this.length-=n,t}},{key:s,value:function(r,t){return d(this,y({},t,{depth:0,customInspect:!1}))}}]),c}()},{buffer:216,util:185}],485:[function(e,S,_){(function(u){function y(h,l){var d=this,s=this._readableState&&this._readableState.destroyed,m=this._writableState&&this._writableState.destroyed;return s||m?(l?l(h):h&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,u.nextTick(f,this,h)):u.nextTick(f,this,h)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(h||null,function(c){!l&&c?d._writableState?d._writableState.errorEmitted?u.nextTick(b,d):(d._writableState.errorEmitted=!0,u.nextTick(g,d,c)):u.nextTick(g,d,c):l?(u.nextTick(b,d),l(c)):u.nextTick(b,d)}),this)}function g(h,l){f(h,l),b(h)}function b(h){h._writableState&&!h._writableState.emitClose||h._readableState&&!h._readableState.emitClose||h.emit("close")}function w(){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 f(h,l){h.emit("error",l)}function v(h,l){var d=h._readableState,s=h._writableState;d&&d.autoDestroy||s&&s.autoDestroy?h.destroy(l):h.emit("error",l)}S.exports={destroy:y,undestroy:w,errorOrDestroy:v}}).call(this,e("_process"))},{_process:467}],486:[function(e,S,_){var u=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function y(f){var v=!1;return function(){if(!v){v=!0;for(var h=arguments.length,l=new Array(h),d=0;d0;return h(o,E,P,function(D){i||(i=D),D&&n.forEach(l),!E&&(n.forEach(l),t(i))})});return a.reduce(d)}S.exports=m},{"../../../errors":477,"./end-of-stream":486}],489:[function(e,S,_){var u=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function y(b,w,f){return b.highWaterMark!=null?b.highWaterMark:w?b[f]:null}function g(b,w,f,v){var h=y(w,v,f);if(h!=null){if(!(isFinite(h)&&Math.floor(h)===h)||h<0){var l=v?f:"highWaterMark";throw new u(l,h)}return Math.floor(h)}return b.objectMode?16:16*1024}S.exports={getHighWaterMark:g}},{"../../../errors":477}],490:[function(e,S,_){S.exports=e("events").EventEmitter},{events:367}],491:[function(e,S,_){_=S.exports=e("./lib/_stream_readable.js"),_.Stream=_,_.Readable=_,_.Writable=e("./lib/_stream_writable.js"),_.Duplex=e("./lib/_stream_duplex.js"),_.Transform=e("./lib/_stream_transform.js"),_.PassThrough=e("./lib/_stream_passthrough.js"),_.finished=e("./lib/internal/streams/end-of-stream.js"),_.pipeline=e("./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(e,S,_){function u(g){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(w){return typeof w}:u=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},u(g)}var y=function(g){var b=Object.prototype,w=b.hasOwnProperty,f,v=typeof Symbol=="function"?Symbol:{},h=v.iterator||"@@iterator",l=v.asyncIterator||"@@asyncIterator",d=v.toStringTag||"@@toStringTag";function s($,N,F){return Object.defineProperty($,N,{value:F,enumerable:!0,configurable:!0,writable:!0}),$[N]}try{s({},"")}catch{s=function(F,j,V){return F[j]=V}}function m($,N,F,j){var V=N&&N.prototype instanceof o?N:o,te=Object.create(V.prototype),re=new L(j||[]);return te._invoke=T($,F,re),te}g.wrap=m;function c($,N,F){try{return{type:"normal",arg:$.call(N,F)}}catch(j){return{type:"throw",arg:j}}}var a="suspendedStart",r="suspendedYield",t="executing",i="completed",n={};function o(){}function p(){}function E(){}var P={};P[h]=function(){return this};var D=Object.getPrototypeOf,z=D&&D(D(U([])));z&&z!==b&&w.call(z,h)&&(P=z);var B=E.prototype=o.prototype=Object.create(P);p.prototype=B.constructor=E,E.constructor=p,p.displayName=s(E,d,"GeneratorFunction");function M($){["next","throw","return"].forEach(function(N){s($,N,function(F){return this._invoke(N,F)})})}g.isGeneratorFunction=function($){var N=typeof $=="function"&&$.constructor;return N?N===p||(N.displayName||N.name)==="GeneratorFunction":!1},g.mark=function($){return Object.setPrototypeOf?Object.setPrototypeOf($,E):($.__proto__=E,s($,d,"GeneratorFunction")),$.prototype=Object.create(B),$},g.awrap=function($){return{__await:$}};function I($,N){function F(te,re,le,ye){var ge=c($[te],$,re);if(ge.type==="throw")ye(ge.arg);else{var ne=ge.arg,J=ne.value;return J&&u(J)==="object"&&w.call(J,"__await")?N.resolve(J.__await).then(function(Q){F("next",Q,le,ye)},function(Q){F("throw",Q,le,ye)}):N.resolve(J).then(function(Q){ne.value=Q,le(ne)},function(Q){return F("throw",Q,le,ye)})}}var j;function V(te,re){function le(){return new N(function(ye,ge){F(te,re,ye,ge)})}return j=j?j.then(le,le):le()}this._invoke=V}M(I.prototype),I.prototype[l]=function(){return this},g.AsyncIterator=I,g.async=function($,N,F,j,V){V===void 0&&(V=Promise);var te=new I(m($,N,F,j),V);return g.isGeneratorFunction(N)?te:te.next().then(function(re){return re.done?re.value:te.next()})};function T($,N,F){var j=a;return function(te,re){if(j===t)throw new Error("Generator is already running");if(j===i){if(te==="throw")throw re;return W()}for(F.method=te,F.arg=re;;){var le=F.delegate;if(le){var ye=C(le,F);if(ye){if(ye===n)continue;return ye}}if(F.method==="next")F.sent=F._sent=F.arg;else if(F.method==="throw"){if(j===a)throw j=i,F.arg;F.dispatchException(F.arg)}else F.method==="return"&&F.abrupt("return",F.arg);j=t;var ge=c($,N,F);if(ge.type==="normal"){if(j=F.done?i:r,ge.arg===n)continue;return{value:ge.arg,done:F.done}}else ge.type==="throw"&&(j=i,F.method="throw",F.arg=ge.arg)}}}function C($,N){var F=$.iterator[N.method];if(F===f){if(N.delegate=null,N.method==="throw"){if($.iterator.return&&(N.method="return",N.arg=f,C($,N),N.method==="throw"))return n;N.method="throw",N.arg=new TypeError("The iterator does not provide a 'throw' method")}return n}var j=c(F,$.iterator,N.arg);if(j.type==="throw")return N.method="throw",N.arg=j.arg,N.delegate=null,n;var V=j.arg;if(!V)return N.method="throw",N.arg=new TypeError("iterator result is not an object"),N.delegate=null,n;if(V.done)N[$.resultName]=V.value,N.next=$.nextLoc,N.method!=="return"&&(N.method="next",N.arg=f);else return V;return N.delegate=null,n}M(B),s(B,d,"Generator"),B[h]=function(){return this},B.toString=function(){return"[object Generator]"};function O($){var N={tryLoc:$[0]};1 in $&&(N.catchLoc=$[1]),2 in $&&(N.finallyLoc=$[2],N.afterLoc=$[3]),this.tryEntries.push(N)}function A($){var N=$.completion||{};N.type="normal",delete N.arg,$.completion=N}function L($){this.tryEntries=[{tryLoc:"root"}],$.forEach(O,this),this.reset(!0)}g.keys=function($){var N=[];for(var F in $)N.push(F);return N.reverse(),function j(){for(;N.length;){var V=N.pop();if(V in $)return j.value=V,j.done=!1,j}return j.done=!0,j}};function U($){if($){var N=$[h];if(N)return N.call($);if(typeof $.next=="function")return $;if(!isNaN($.length)){var F=-1,j=function V(){for(;++F<$.length;)if(w.call($,F))return V.value=$[F],V.done=!1,V;return V.value=f,V.done=!0,V};return j.next=j}}return{next:W}}g.values=U;function W(){return{value:f,done:!0}}return L.prototype={constructor:L,reset:function(N){if(this.prev=0,this.next=0,this.sent=this._sent=f,this.done=!1,this.delegate=null,this.method="next",this.arg=f,this.tryEntries.forEach(A),!N)for(var F in this)F.charAt(0)==="t"&&w.call(this,F)&&!isNaN(+F.slice(1))&&(this[F]=f)},stop:function(){this.done=!0;var N=this.tryEntries[0],F=N.completion;if(F.type==="throw")throw F.arg;return this.rval},dispatchException:function(N){if(this.done)throw N;var F=this;function j(ge,ne){return re.type="throw",re.arg=N,F.next=ge,ne&&(F.method="next",F.arg=f),!!ne}for(var V=this.tryEntries.length-1;V>=0;--V){var te=this.tryEntries[V],re=te.completion;if(te.tryLoc==="root")return j("end");if(te.tryLoc<=this.prev){var le=w.call(te,"catchLoc"),ye=w.call(te,"finallyLoc");if(le&&ye){if(this.prev=0;--j){var V=this.tryEntries[j];if(V.tryLoc<=this.prev&&w.call(V,"finallyLoc")&&this.prev=0;--F){var j=this.tryEntries[F];if(j.finallyLoc===N)return this.complete(j.completion,j.afterLoc),A(j),n}},catch:function(N){for(var F=this.tryEntries.length-1;F>=0;--F){var j=this.tryEntries[F];if(j.tryLoc===N){var V=j.completion;if(V.type==="throw"){var te=V.arg;A(j)}return te}}throw new Error("illegal catch attempt")},delegateYield:function(N,F,j){return this.delegate={iterator:U(N),resultName:F,nextLoc:j},this.method==="next"&&(this.arg=f),n}},g}((typeof S>"u"?"undefined":u(S))==="object"?S.exports:{});try{regeneratorRuntime=y}catch{Function("r","regeneratorRuntime = r")(y)}},{}],493:[function(e,S,_){var u=e("buffer").Buffer,y=e("inherits"),g=e("hash-base"),b=new Array(16),w=[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],f=[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],v=[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],h=[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],l=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0];function s(){g.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}y(s,g),s.prototype._update=function(){for(var n=b,o=0;o<16;++o)n[o]=this._block.readInt32LE(o*4);for(var p=this._a|0,E=this._b|0,P=this._c|0,D=this._d|0,z=this._e|0,B=this._a|0,M=this._b|0,I=this._c|0,T=this._d|0,C=this._e|0,O=0;O<80;O+=1){var A,L;O<16?(A=c(p,E,P,D,z,n[w[O]],l[0],v[O]),L=i(B,M,I,T,C,n[f[O]],d[0],h[O])):O<32?(A=a(p,E,P,D,z,n[w[O]],l[1],v[O]),L=t(B,M,I,T,C,n[f[O]],d[1],h[O])):O<48?(A=r(p,E,P,D,z,n[w[O]],l[2],v[O]),L=r(B,M,I,T,C,n[f[O]],d[2],h[O])):O<64?(A=t(p,E,P,D,z,n[w[O]],l[3],v[O]),L=a(B,M,I,T,C,n[f[O]],d[3],h[O])):(A=i(p,E,P,D,z,n[w[O]],l[4],v[O]),L=c(B,M,I,T,C,n[f[O]],d[4],h[O])),p=z,z=D,D=m(P,10),P=E,E=A,B=C,C=T,T=m(I,10),I=M,M=L}var U=this._b+P+T|0;this._b=this._c+D+C|0,this._c=this._d+z+B|0,this._d=this._e+p+M|0,this._e=this._a+E+I|0,this._a=U},s.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 n=u.alloc?u.alloc(20):new u(20);return n.writeInt32LE(this._a,0),n.writeInt32LE(this._b,4),n.writeInt32LE(this._c,8),n.writeInt32LE(this._d,12),n.writeInt32LE(this._e,16),n};function m(n,o){return n<>>32-o}function c(n,o,p,E,P,D,z,B){return m(n+(o^p^E)+D+z|0,B)+P|0}function a(n,o,p,E,P,D,z,B){return m(n+(o&p|~o&E)+D+z|0,B)+P|0}function r(n,o,p,E,P,D,z,B){return m(n+((o|~p)^E)+D+z|0,B)+P|0}function t(n,o,p,E,P,D,z,B){return m(n+(o&E|p&~E)+D+z|0,B)+P|0}function i(n,o,p,E,P,D,z,B){return m(n+(o^(p|~E))+D+z|0,B)+P|0}S.exports=s},{buffer:216,"hash-base":370,inherits:387}],494:[function(e,S,_){var u=e("buffer"),y=u.Buffer;function g(w,f){for(var v in w)f[v]=w[v]}y.from&&y.alloc&&y.allocUnsafe&&y.allocUnsafeSlow?S.exports=u:(g(u,_),_.Buffer=b);function b(w,f,v){return y(w,f,v)}g(y,b),b.from=function(w,f,v){if(typeof w=="number")throw new TypeError("Argument must not be a number");return y(w,f,v)},b.alloc=function(w,f,v){if(typeof w!="number")throw new TypeError("Argument must be a number");var h=y(w);return f!==void 0?typeof v=="string"?h.fill(f,v):h.fill(f):h.fill(0),h},b.allocUnsafe=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return y(w)},b.allocUnsafeSlow=function(w){if(typeof w!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(w)}},{buffer:216}],495:[function(e,S,_){(function(u){function y(h){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(d){return typeof d}:y=function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},y(h)}var g=e("buffer"),b=g.Buffer,w={},f;for(f in g)g.hasOwnProperty(f)&&(f==="SlowBuffer"||f==="Buffer"||(w[f]=g[f]));var v=w.Buffer={};for(f in b)b.hasOwnProperty(f)&&(f==="allocUnsafe"||f==="allocUnsafeSlow"||(v[f]=b[f]));if(w.Buffer.prototype=b.prototype,(!v.from||v.from===Uint8Array.from)&&(v.from=function(h,l,d){if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+y(h));if(h&&typeof h.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+y(h));return b(h,l,d)}),v.alloc||(v.alloc=function(h,l,d){if(typeof h!="number")throw new TypeError('The "size" argument must be of type number. Received type '+y(h));if(h<0||h>=2*(1<<30))throw new RangeError('The value "'+h+'" is invalid for option "size"');var s=b(h);return!l||l.length===0?s.fill(0):typeof d=="string"?s.fill(l,d):s.fill(l),s}),!w.kStringMaxLength)try{w.kStringMaxLength=u.binding("buffer").kStringMaxLength}catch{}w.constants||(w.constants={MAX_LENGTH:w.kMaxLength},w.kStringMaxLength&&(w.constants.MAX_STRING_LENGTH=w.kStringMaxLength)),S.exports=w}).call(this,e("_process"))},{_process:467,buffer:216}],496:[function(e,S,_){function u(yt,Ke){var me;if(typeof Symbol>"u"||yt[Symbol.iterator]==null){if(Array.isArray(yt)||(me=h(yt))||Ke&&yt&&typeof yt.length=="number"){me&&(yt=me);var Be=0,Fe=function(){};return{s:Fe,n:function(){return Be>=yt.length?{done:!0}:{done:!1,value:yt[Be++]}},e:function(gr){throw gr},f:Fe}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var dt=!0,kt=!1,Ht;return{s:function(){me=yt[Symbol.iterator]()},n:function(){var gr=me.next();return dt=gr.done,gr},e:function(gr){kt=!0,Ht=gr},f:function(){try{!dt&&me.return!=null&&me.return()}finally{if(kt)throw Ht}}}}function y(yt){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?y=function(me){return typeof me}:y=function(me){return me&&typeof Symbol=="function"&&me.constructor===Symbol&&me!==Symbol.prototype?"symbol":typeof me},y(yt)}function g(yt,Ke){if(!(yt instanceof Ke))throw new TypeError("Cannot call a class as a function")}function b(yt,Ke){for(var me=0;meyt.length)&&(Ke=yt.length);for(var me=0,Be=new Array(Ke);me",lt:"<",quot:'"',apos:"'"},C=-1,E=-2,A=0,L=1,$=2,W=3,U=4,N=5,j=6,F=7,V=8,re=9,ee=10,ce=11,ye=12,ge=13,oe=14,J=15,Q=16,he=17,xe=18,ne=19,se=20,Ce=21,q=22,G=23,Y=24,fe=25,we=26,_e=27,je=28,Ye=29,nt=30,ut=31,ot=32,Ue=33,Ve=34,Qe=35,tt=36,ae=37,Re=38,be=39,Ee=40,pe=41,Pe=42,te=43,He=44,it=9,K=10,Me=13,Le=32,ue=33,ke=34,Ie=38,st=39,Ge=45,rt=47,_t=59,wt=60,Ot=61,pt=62,ct=63,At=91,Pt=93,bt=133,Kt=8232,Ct=function(Ke){return Ke===ke||Ke===st},St=[ke,st],Bt=[].concat(St,[At,pt]),Lt=[].concat(St,[wt,Pt]),Et=[Ot,ct].concat(f(o)),Nr=[].concat(f(o),[pt,Ie,wt]);function Or(yt,Ke,me){switch(Ke){case"xml":me!==D&&yt.fail("xml prefix must be bound to ".concat(D,"."));break;case"xmlns":me!==M&&yt.fail("xmlns prefix must be bound to ".concat(M,"."));break}switch(me){case M:yt.fail(Ke===""?"the default namespace may not be set to ".concat(me,"."):'may not assign a prefix (even "xmlns") to the URI '.concat(M,"."));break;case D:switch(Ke){case"xml":break;case"":yt.fail("the default namespace may not be set to ".concat(me,"."));break;default:yt.fail("may not assign the xml namespace to another prefix.")}break}}function Gr(yt,Ke){for(var me=0,Be=Object.keys(Ke);me0&&(Fe+=":"),Fe+="".concat(this.line,":").concat(this.column)),Fe.length>0&&(Fe+=": "),new Error(Fe+me)}},{key:"fail",value:function(me){var Be=this.makeError(me),Fe=this.errorHandler;if(Fe===void 0)throw Be;return Fe(Be),this}},{key:"write",value:function(me){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");var Be=!1;me===null?(Be=!0,me=""):y(me)==="object"&&(me=me.toString()),this.carriedFromPrevious!==void 0&&(me="".concat(this.carriedFromPrevious).concat(me),this.carriedFromPrevious=void 0);var Fe=me.length,dt=me.charCodeAt(Fe-1);!Be&&(dt===Me||dt>=55296&&dt<=56319)&&(this.carriedFromPrevious=me[Fe-1],Fe--,me=me.slice(0,Fe));var kt=this.stateTable;for(this.chunk=me,this.i=0;this.i=me.length)return C;var Fe=me.charCodeAt(Be);if(this.column++,Fe<55296){if(Fe>=Le||Fe===it)return Fe;switch(Fe){case K:return this.line++,this.column=0,this.positionAtNewLine=this.position,K;case Me:return me.charCodeAt(Be+1)===K&&(this.i=Be+2),this.line++,this.column=0,this.positionAtNewLine=this.position,E;default:return this.fail("disallowed character."),Fe}}if(Fe>56319)return Fe>=57344&&Fe<=65533||this.fail("disallowed character."),Fe;var dt=65536+(Fe-55296)*1024+(me.charCodeAt(Be+1)-56320);return this.i=Be+2,dt>1114111&&this.fail("disallowed character."),dt}},{key:"getCode11",value:function(){var me=this.chunk,Be=this.i;if(this.prevI=Be,this.i=Be+1,Be>=me.length)return C;var Fe=me.charCodeAt(Be);if(this.column++,Fe<55296){if(Fe>31&&Fe<127||Fe>159&&Fe!==Kt||Fe===it)return Fe;switch(Fe){case K:return this.line++,this.column=0,this.positionAtNewLine=this.position,K;case Me:{var dt=me.charCodeAt(Be+1);(dt===K||dt===bt)&&(this.i=Be+2)}case bt:case Kt:return this.line++,this.column=0,this.positionAtNewLine=this.position,E;default:return this.fail("disallowed character."),Fe}}if(Fe>56319)return Fe>=57344&&Fe<=65533||this.fail("disallowed character."),Fe;var kt=65536+(Fe-55296)*1024+(me.charCodeAt(Be+1)-56320);return this.i=Be+2,kt>1114111&&this.fail("disallowed character."),kt}},{key:"getCodeNorm",value:function(){var me=this.getCode();return me===E?K:me}},{key:"unget",value:function(){this.i=this.prevI,this.column--}},{key:"captureTo",value:function(me){for(var Be=this.i,Fe=this.chunk;;){var dt=this.getCode(),kt=dt===E,Ht=kt?K:dt;if(Ht===C||me.includes(Ht))return this.text+=Fe.slice(Be,this.prevI),Ht;kt&&(this.text+="".concat(Fe.slice(Be,this.prevI),` -`),Be=this.i)}}},{key:"captureToChar",value:function(me){for(var Be=this.i,Fe=this.chunk;;){var dt=this.getCode();switch(dt){case E:this.text+="".concat(Fe.slice(Be,this.prevI),` -`),Be=this.i,dt=K;break;case C:return this.text+=Fe.slice(Be),!1}if(dt===me)return this.text+=Fe.slice(Be,this.prevI),!0}}},{key:"captureNameChars",value:function(){for(var me=this.chunk,Be=this.i;;){var Fe=this.getCode();if(Fe===C)return this.name+=me.slice(Be),C;if(!n(Fe))return this.name+=me.slice(Be,this.prevI),Fe===E?K:Fe}}},{key:"skipSpaces",value:function(){for(;;){var me=this.getCodeNorm();if(me===C||!r(me))return me}}},{key:"setXMLVersion",value:function(me){this.currentXMLVersion=me,me==="1.0"?(this.isChar=t,this.getCode=this.getCode10):(this.isChar=O,this.getCode=this.getCode11)}},{key:"sBegin",value:function(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=L}},{key:"sBeginWhitespace",value:function(){var me=this.i,Be=this.skipSpaces();switch(this.prevI!==me&&(this.xmlDeclPossible=!1),Be){case wt:if(this.state=J,this.text.length!==0)throw new Error("no-empty text at start");break;case C:break;default:this.unget(),this.state=ge,this.xmlDeclPossible=!1}}},{key:"sDoctype",value:function(){var me,Be=this.captureTo(Bt);switch(Be){case pt:{(me=this.doctypeHandler)===null||me===void 0||me.call(this,this.text),this.text="",this.state=ge,this.doctype=!0;break}case C:break;default:this.text+=String.fromCodePoint(Be),Be===At?this.state=U:Ct(Be)&&(this.state=W,this.q=Be)}}},{key:"sDoctypeQuote",value:function(){var me=this.q;this.captureToChar(me)&&(this.text+=String.fromCodePoint(me),this.q=null,this.state=$)}},{key:"sDTD",value:function(){var me=this.captureTo(Lt);me!==C&&(this.text+=String.fromCodePoint(me),me===Pt?this.state=$:me===wt?this.state=j:Ct(me)&&(this.state=N,this.q=me))}},{key:"sDTDQuoted",value:function(){var me=this.q;this.captureToChar(me)&&(this.text+=String.fromCodePoint(me),this.state=U,this.q=null)}},{key:"sDTDOpenWaka",value:function(){var me=this.getCodeNorm();switch(this.text+=String.fromCodePoint(me),me){case ue:this.state=F,this.openWakaBang="";break;case ct:this.state=ce;break;default:this.state=U}}},{key:"sDTDOpenWakaBang",value:function(){var me=String.fromCodePoint(this.getCodeNorm()),Be=this.openWakaBang+=me;this.text+=me,Be!=="-"&&(this.state=Be==="--"?V:U,this.openWakaBang="")}},{key:"sDTDComment",value:function(){this.captureToChar(Ge)&&(this.text+="-",this.state=re)}},{key:"sDTDCommentEnding",value:function(){var me=this.getCodeNorm();this.text+=String.fromCodePoint(me),this.state=me===Ge?ee:V}},{key:"sDTDCommentEnded",value:function(){var me=this.getCodeNorm();this.text+=String.fromCodePoint(me),me===pt?this.state=U:(this.fail("malformed comment."),this.state=V)}},{key:"sDTDPI",value:function(){this.captureToChar(ct)&&(this.text+="?",this.state=ye)}},{key:"sDTDPIEnding",value:function(){var me=this.getCodeNorm();this.text+=String.fromCodePoint(me),me===pt&&(this.state=U)}},{key:"sText",value:function(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}},{key:"sEntity",value:function(){var me=this.i,Be=this.chunk;e:for(;;)switch(this.getCode()){case E:this.entity+="".concat(Be.slice(me,this.prevI),` -`),me=this.i;break;case _t:{var Fe=this.entityReturnState,dt=this.entity+Be.slice(me,this.prevI);this.state=Fe;var kt=void 0;dt===""?(this.fail("empty entity name."),kt="&;"):(kt=this.parseEntity(dt),this.entity=""),(Fe!==ge||this.textHandler!==void 0)&&(this.text+=kt);break e}case C:this.entity+=Be.slice(me);break e}}},{key:"sOpenWaka",value:function(){var me=this.getCode();if(i(me))this.state=Ve,this.unget(),this.xmlDeclPossible=!1;else switch(me){case rt:this.state=te,this.xmlDeclPossible=!1;break;case ue:this.state=Q,this.openWakaBang="",this.xmlDeclPossible=!1;break;case ct:this.state=G;break;default:this.fail("disallowed character in tag name"),this.state=ge,this.xmlDeclPossible=!1}}},{key:"sOpenWakaBang",value:function(){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=se,this.openWakaBang="";break;case"--":this.state=he,this.openWakaBang="";break;case"DOCTYPE":this.state=$,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}},{key:"sComment",value:function(){this.captureToChar(Ge)&&(this.state=xe)}},{key:"sCommentEnding",value:function(){var me,Be=this.getCodeNorm();Be===Ge?(this.state=ne,(me=this.commentHandler)===null||me===void 0||me.call(this,this.text),this.text=""):(this.text+="-".concat(String.fromCodePoint(Be)),this.state=he)}},{key:"sCommentEnded",value:function(){var me=this.getCodeNorm();me!==pt?(this.fail("malformed comment."),this.text+="--".concat(String.fromCodePoint(me)),this.state=he):this.state=ge}},{key:"sCData",value:function(){this.captureToChar(Pt)&&(this.state=Ce)}},{key:"sCDataEnding",value:function(){var me=this.getCodeNorm();me===Pt?this.state=q:(this.text+="]".concat(String.fromCodePoint(me)),this.state=se)}},{key:"sCDataEnding2",value:function(){var me,Be=this.getCodeNorm();switch(Be){case pt:{(me=this.cdataHandler)===null||me===void 0||me.call(this,this.text),this.text="",this.state=ge;break}case Pt:this.text+="]";break;default:this.text+="]]".concat(String.fromCodePoint(Be)),this.state=se}}},{key:"sPIFirstChar",value:function(){var me=this.getCodeNorm();this.nameStartCheck(me)?(this.piTarget+=String.fromCodePoint(me),this.state=Y):me===ct||r(me)?(this.fail("processing instruction without a target."),this.state=me===ct?we:fe):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(me),this.state=Y)}},{key:"sPIRest",value:function(){for(var me=this.chunk,Be=this.i;;){var Fe=this.getCodeNorm();if(Fe===C){this.piTarget+=me.slice(Be);return}if(!this.nameCheck(Fe)){this.piTarget+=me.slice(Be,this.prevI);var dt=Fe===ct;dt||r(Fe)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=dt?Ue:_e):this.state=dt?we:fe:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(Fe));break}}}},{key:"sPIBody",value:function(){if(this.text.length===0){var me=this.getCodeNorm();me===ct?this.state=we:r(me)||(this.text=String.fromCodePoint(me))}else this.captureToChar(ct)&&(this.state=we)}},{key:"sPIEnding",value:function(){var me,Be=this.getCodeNorm();if(Be===pt){var Fe=this.piTarget;Fe.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),(me=this.piHandler)===null||me===void 0||me.call(this,{target:Fe,body:this.text}),this.piTarget=this.text="",this.state=ge}else Be===ct?this.text+="?":(this.text+="?".concat(String.fromCodePoint(Be)),this.state=fe);this.xmlDeclPossible=!1}},{key:"sXMLDeclNameStart",value:function(){var me=this.skipSpaces();if(me===ct){this.state=Ue;return}me!==C&&(this.state=je,this.name=String.fromCodePoint(me))}},{key:"sXMLDeclName",value:function(){var me=this.captureTo(Et);if(me===ct){this.state=Ue,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(r(me)||me===Ot){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 ".concat(this.xmlDeclExpects[0],"."));break;default:this.fail("expected one of ".concat(this.xmlDeclExpects.join(", ")))}this.state=me===Ot?nt:Ye}}},{key:"sXMLDeclEq",value:function(){var me=this.getCodeNorm();if(me===ct){this.state=Ue,this.fail("XML declaration is incomplete.");return}r(me)||(me!==Ot&&this.fail("value required."),this.state=nt)}},{key:"sXMLDeclValueStart",value:function(){var me=this.getCodeNorm();if(me===ct){this.state=Ue,this.fail("XML declaration is incomplete.");return}r(me)||(Ct(me)?this.q=me:(this.fail("value must be quoted."),this.q=Le),this.state=ut)}},{key:"sXMLDeclValue",value:function(){var me=this.captureTo([this.q,ct]);if(me===ct){this.state=Ue,this.text="",this.fail("XML declaration is incomplete.");return}if(me!==C){var Be=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];var Fe=Be;this.xmlDecl.version=Fe,/^1\.[0-9]+$/.test(Fe)?this.opt.forceXMLVersion||this.setXMLVersion(Fe):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(Be)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=Be;break;case"standalone":Be!=="yes"&&Be!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=Be;break}this.name="",this.state=ot}}},{key:"sXMLDeclSeparator",value:function(){var me=this.getCodeNorm();if(me===ct){this.state=Ue;return}r(me)||(this.fail("whitespace required."),this.unget()),this.state=_e}},{key:"sXMLDeclEnding",value:function(){var me,Be=this.getCodeNorm();Be===pt?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),(me=this.xmldeclHandler)===null||me===void 0||me.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=ge):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}},{key:"sOpenTag",value:function(){var me,Be=this.captureNameChars();if(Be!==C){var Fe=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=Fe.ns=Object.create(null)),(me=this.openTagStartHandler)===null||me===void 0||me.call(this,Fe),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),Be){case pt:this.openTag();break;case rt:this.state=Qe;break;default:r(Be)||this.fail("disallowed character in tag name."),this.state=tt}}}},{key:"sOpenTagSlash",value:function(){this.getCode()===pt?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=tt)}},{key:"sAttrib",value:function(){var me=this.skipSpaces();me!==C&&(i(me)?(this.unget(),this.state=ae):me===pt?this.openTag():me===rt?this.state=Qe:this.fail("disallowed character in attribute name."))}},{key:"sAttribName",value:function(){var me=this.captureNameChars();me===Ot?this.state=be:r(me)?this.state=Re:me===pt?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):me!==C&&this.fail("disallowed character in attribute name.")}},{key:"sAttribNameSawWhite",value:function(){var me=this.skipSpaces();switch(me){case C:return;case Ot:this.state=be;break;default:this.fail("attribute without value."),this.text="",this.name="",me===pt?this.openTag():i(me)?(this.unget(),this.state=ae):(this.fail("disallowed character in attribute name."),this.state=tt)}}},{key:"sAttribValue",value:function(){var me=this.getCodeNorm();Ct(me)?(this.q=me,this.state=Ee):r(me)||(this.fail("unquoted attribute value."),this.state=Pe,this.unget())}},{key:"sAttribValueQuoted",value:function(){for(var me=this.q,Be=this.chunk,Fe=this.i;;)switch(this.getCode()){case me:this.pushAttrib(this.name,this.text+Be.slice(Fe,this.prevI)),this.name=this.text="",this.q=null,this.state=pe;return;case Ie:this.text+=Be.slice(Fe,this.prevI),this.state=oe,this.entityReturnState=Ee;return;case K:case E:case it:this.text+="".concat(Be.slice(Fe,this.prevI)," "),Fe=this.i;break;case wt:this.text+=Be.slice(Fe,this.prevI),this.fail("disallowed character.");return;case C:this.text+=Be.slice(Fe);return}}},{key:"sAttribValueClosed",value:function(){var me=this.getCodeNorm();r(me)?this.state=tt:me===pt?this.openTag():me===rt?this.state=Qe:i(me)?(this.fail("no whitespace between attributes."),this.unget(),this.state=ae):this.fail("disallowed character in attribute name.")}},{key:"sAttribValueUnquoted",value:function(){var me=this.captureTo(Nr);switch(me){case Ie:this.state=oe,this.entityReturnState=Pe;break;case wt:this.fail("disallowed character.");break;case C:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",me===pt?this.openTag():this.state=tt}}},{key:"sCloseTag",value:function(){var me=this.captureNameChars();me===pt?this.closeTag():r(me)?this.state=He:me!==C&&this.fail("disallowed character in closing tag.")}},{key:"sCloseTagSawWhite",value:function(){switch(this.skipSpaces()){case pt:this.closeTag();break;case C:break;default:this.fail("disallowed character in closing tag.")}}},{key:"handleTextInRoot",value:function(){var me=this.i,Be=this.forbiddenState,Fe=this.chunk,dt=this.textHandler;e:for(;;)switch(this.getCode()){case wt:{if(this.state=J,dt!==void 0){var kt=this.text,Ht=Fe.slice(me,this.prevI);kt.length!==0?(dt(kt+Ht),this.text=""):Ht.length!==0&&dt(Ht)}Be=Qt;break e}case Ie:this.state=oe,this.entityReturnState=ge,dt!==void 0&&(this.text+=Fe.slice(me,this.prevI)),Be=Qt;break e;case Pt:switch(Be){case Qt:Be=Xr;break;case Xr:Be=Br;break;case Br:break;default:throw new Error("impossible state")}break;case pt:Be===Br&&this.fail('the string "]]>" is disallowed in char data.'),Be=Qt;break;case E:dt!==void 0&&(this.text+="".concat(Fe.slice(me,this.prevI),` -`)),me=this.i,Be=Qt;break;case C:dt!==void 0&&(this.text+=Fe.slice(me));break e;default:Be=Qt}this.forbiddenState=Be}},{key:"handleTextOutsideRoot",value:function(){var me=this.i,Be=this.chunk,Fe=this.textHandler,dt=!1;e:for(;;){var kt=this.getCode();switch(kt){case wt:{if(this.state=J,Fe!==void 0){var Ht=this.text,lr=Be.slice(me,this.prevI);Ht.length!==0?(Fe(Ht+lr),this.text=""):lr.length!==0&&Fe(lr)}break e}case Ie:this.state=oe,this.entityReturnState=ge,Fe!==void 0&&(this.text+=Be.slice(me,this.prevI)),dt=!0;break e;case E:Fe!==void 0&&(this.text+="".concat(Be.slice(me,this.prevI),` -`)),me=this.i;break;case C:Fe!==void 0&&(this.text+=Be.slice(me));break e;default:r(kt)||(dt=!0)}}dt&&(!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))}},{key:"pushAttribNS",value:function(me,Be){var Fe,dt=this.qname(me),kt=dt.prefix,Ht=dt.local,lr={name:me,prefix:kt,local:Ht,value:Be};if(this.attribList.push(lr),(Fe=this.attributeHandler)===null||Fe===void 0||Fe.call(this,lr),kt==="xmlns"){var gr=Be.trim();this.currentXMLVersion==="1.0"&&gr===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[Ht]=gr,Or(this,Ht,gr)}else if(me==="xmlns"){var rn=Be.trim();this.topNS[""]=rn,Or(this,"",rn)}}},{key:"pushAttribPlain",value:function(me,Be){var Fe,dt={name:me,value:Be};this.attribList.push(dt),(Fe=this.attributeHandler)===null||Fe===void 0||Fe.call(this,dt)}},{key:"end",value:function(){var me,Be;this.sawRoot||this.fail("document must contain a root element.");for(var Fe=this.tags;Fe.length>0;){var dt=Fe.pop();this.fail("unclosed tag: ".concat(dt.name))}this.state!==A&&this.state!==ge&&this.fail("unexpected end.");var kt=this.text;return kt.length!==0&&((me=this.textHandler)===null||me===void 0||me.call(this,kt),this.text=""),this._closed=!0,(Be=this.endHandler)===null||Be===void 0||Be.call(this),this._init(),this}},{key:"resolve",value:function(me){var Be,Fe,dt=this.topNS[me];if(dt!==void 0)return dt;for(var kt=this.tags,Ht=kt.length-1;Ht>=0;Ht--)if(dt=kt[Ht].ns[me],dt!==void 0)return dt;return dt=this.ns[me],dt!==void 0?dt:(Fe=(Be=this.opt).resolvePrefix)===null||Fe===void 0?void 0:Fe.call(Be,me)}},{key:"qname",value:function(me){var Be=me.indexOf(":");if(Be===-1)return{prefix:"",local:me};var Fe=me.slice(Be+1),dt=me.slice(0,Be);return(dt===""||Fe===""||Fe.includes(":"))&&this.fail("malformed name: ".concat(me,".")),{prefix:dt,local:Fe}}},{key:"processAttribsNS",value:function(){var me,Be=this.attribList,Fe=this.tag;{var dt=this.qname(Fe.name),kt=dt.prefix,Ht=dt.local;Fe.prefix=kt,Fe.local=Ht;var lr=Fe.uri=(me=this.resolve(kt))!==null&&me!==void 0?me:"";kt!==""&&(kt==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),lr===""&&(this.fail("unbound namespace prefix: ".concat(JSON.stringify(kt),".")),Fe.uri=kt))}if(Be.length!==0){var gr=Fe.attributes,rn=new Set,zr=u(Be),vi;try{for(zr.s();!(vi=zr.n()).done;){var $r=vi.value,Dn=$r.name,cn=$r.prefix,yi=$r.local,hn=void 0,dn=void 0;cn===""?(hn=Dn==="xmlns"?M:"",dn=Dn):(hn=this.resolve(cn),hn===void 0&&(this.fail("unbound namespace prefix: ".concat(JSON.stringify(cn),".")),hn=cn),dn="{".concat(hn,"}").concat(yi)),rn.has(dn)&&this.fail("duplicate attribute: ".concat(dn,".")),rn.add(dn),$r.uri=hn,gr[Dn]=$r}}catch(Bn){zr.e(Bn)}finally{zr.f()}this.attribList=[]}}},{key:"processAttribsPlain",value:function(){var me=this.attribList,Be=this.tag.attributes,Fe=u(me),dt;try{for(Fe.s();!(dt=Fe.n()).done;){var kt=dt.value,Ht=kt.name,lr=kt.value;Be[Ht]!==void 0&&this.fail("duplicate attribute: ".concat(Ht,".")),Be[Ht]=lr}}catch(gr){Fe.e(gr)}finally{Fe.f()}this.attribList=[]}},{key:"openTag",value:function(){var me;this.processAttribs();var Be=this.tags,Fe=this.tag;Fe.isSelfClosing=!1,(me=this.openTagHandler)===null||me===void 0||me.call(this,Fe),Be.push(Fe),this.state=ge,this.name=""}},{key:"openSelfClosingTag",value:function(){var me,Be,Fe;this.processAttribs();var dt=this.tags,kt=this.tag;kt.isSelfClosing=!0,(me=this.openTagHandler)===null||me===void 0||me.call(this,kt),(Be=this.closeTagHandler)===null||Be===void 0||Be.call(this,kt);var Ht=this.tag=(Fe=dt[dt.length-1])!==null&&Fe!==void 0?Fe:null;Ht===null&&(this.closedRoot=!0),this.state=ge,this.name=""}},{key:"closeTag",value:function(){var me=this.tags,Be=this.name;if(this.state=ge,this.name="",Be===""){this.fail("weird empty close tag."),this.text+="";return}for(var Fe=this.closeTagHandler,dt=me.length;dt-- >0;){var kt=this.tag=me.pop();if(this.topNS=kt.ns,Fe==null||Fe(kt),kt.name===Be)break;this.fail("unexpected close tag.")}dt===0?this.closedRoot=!0:dt<0&&(this.fail("unmatched closing tag: ".concat(Be,".")),this.text+=""))}},{key:"parseEntity",value:function(me){if(me[0]!=="#"){var Be=this.ENTITIES[me];return Be!==void 0?Be:(this.fail(this.isName(me)?"undefined entity.":"disallowed character in entity name."),"&".concat(me,";"))}var Fe=NaN;return me[1]==="x"&&/^#x[0-9a-f]+$/i.test(me)?Fe=parseInt(me.slice(2),16):/^#[0-9]+$/.test(me)&&(Fe=parseInt(me.slice(1),10)),this.isChar(Fe)?String.fromCodePoint(Fe):(this.fail("malformed character entity."),"&".concat(me,";"))}},{key:"closed",get:function(){return this._closed}},{key:"position",get:function(){return this.chunkPosition+this.i}},{key:"columnIndex",get:function(){return this.position-this.positionAtNewLine}}]),yt}();_.SaxesParser=Ur},{"xmlchars/xml/1.0/ed5":541,"xmlchars/xml/1.1/ed2":542,"xmlchars/xmlns/1.0/ed3":543}],497:[function(e,S,_){(function(u){S.exports=typeof u=="function"?u:function(){var g=[].slice.apply(arguments);g.splice(1,0,0),setTimeout.apply(null,g)}}).call(this,e("timers").setImmediate)},{timers:521}],498:[function(e,S,_){var u=e("safe-buffer").Buffer;function y(g,b){this._block=u.alloc(g),this._finalSize=b,this._blockSize=g,this._len=0}y.prototype.update=function(g,b){typeof g=="string"&&(b=b||"utf8",g=u.from(g,b));for(var w=this._block,f=this._blockSize,v=g.length,h=this._len,l=0;l=this._finalSize&&(this._update(this._block),this._block.fill(0));var w=this._len*8;if(w<=4294967295)this._block.writeUInt32BE(w,this._blockSize-4);else{var f=(w&4294967295)>>>0,v=(w-f)/4294967296;this._block.writeUInt32BE(v,this._blockSize-8),this._block.writeUInt32BE(f,this._blockSize-4)}this._update(this._block);var h=this._hash();return g?h.toString(g):h},y.prototype._update=function(){throw new Error("_update must be implemented by subclass")},S.exports=y},{"safe-buffer":494}],499:[function(e,S,_){var u=S.exports=function(g){g=g.toLowerCase();var b=u[g];if(!b)throw new Error(g+" is not supported (we accept pull requests)");return new b};u.sha=e("./sha"),u.sha1=e("./sha1"),u.sha224=e("./sha224"),u.sha256=e("./sha256"),u.sha384=e("./sha384"),u.sha512=e("./sha512")},{"./sha":500,"./sha1":501,"./sha224":502,"./sha256":503,"./sha384":504,"./sha512":505}],500:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[1518500249,1859775393,-1894007588,-899497514],w=new Array(80);function f(){this.init(),this._w=w,y.call(this,64,56)}u(f,y),f.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function v(d){return d<<5|d>>>27}function h(d){return d<<30|d>>>2}function l(d,s,m,c){return d===0?s&m|~s&c:d===2?s&m|s&c|m&c:s^m^c}f.prototype._update=function(d){for(var s=this._w,m=this._a|0,c=this._b|0,a=this._c|0,r=this._d|0,t=this._e|0,i=0;i<16;++i)s[i]=d.readInt32BE(i*4);for(;i<80;++i)s[i]=s[i-3]^s[i-8]^s[i-14]^s[i-16];for(var n=0;n<80;++n){var o=~~(n/20),p=v(m)+l(o,c,a,r)+t+s[n]+b[o]|0;t=r,r=a,a=h(c),c=m,m=p}this._a=m+this._a|0,this._b=c+this._b|0,this._c=a+this._c|0,this._d=r+this._d|0,this._e=t+this._e|0},f.prototype._hash=function(){var d=g.allocUnsafe(20);return d.writeInt32BE(this._a|0,0),d.writeInt32BE(this._b|0,4),d.writeInt32BE(this._c|0,8),d.writeInt32BE(this._d|0,12),d.writeInt32BE(this._e|0,16),d},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],501:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[1518500249,1859775393,-1894007588,-899497514],w=new Array(80);function f(){this.init(),this._w=w,y.call(this,64,56)}u(f,y),f.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function v(s){return s<<1|s>>>31}function h(s){return s<<5|s>>>27}function l(s){return s<<30|s>>>2}function d(s,m,c,a){return s===0?m&c|~m&a:s===2?m&c|m&a|c&a:m^c^a}f.prototype._update=function(s){for(var m=this._w,c=this._a|0,a=this._b|0,r=this._c|0,t=this._d|0,i=this._e|0,n=0;n<16;++n)m[n]=s.readInt32BE(n*4);for(;n<80;++n)m[n]=v(m[n-3]^m[n-8]^m[n-14]^m[n-16]);for(var o=0;o<80;++o){var p=~~(o/20),O=h(c)+d(p,a,r,t)+i+m[o]+b[p]|0;i=t,t=r,r=l(a),a=c,c=O}this._a=c+this._a|0,this._b=a+this._b|0,this._c=r+this._c|0,this._d=t+this._d|0,this._e=i+this._e|0},f.prototype._hash=function(){var s=g.allocUnsafe(20);return s.writeInt32BE(this._a|0,0),s.writeInt32BE(this._b|0,4),s.writeInt32BE(this._c|0,8),s.writeInt32BE(this._d|0,12),s.writeInt32BE(this._e|0,16),s},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],502:[function(e,S,_){var u=e("inherits"),y=e("./sha256"),g=e("./hash"),b=e("safe-buffer").Buffer,w=new Array(64);function f(){this.init(),this._w=w,g.call(this,64,56)}u(f,y),f.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},f.prototype._hash=function(){var v=b.allocUnsafe(28);return v.writeInt32BE(this._a,0),v.writeInt32BE(this._b,4),v.writeInt32BE(this._c,8),v.writeInt32BE(this._d,12),v.writeInt32BE(this._e,16),v.writeInt32BE(this._f,20),v.writeInt32BE(this._g,24),v},S.exports=f},{"./hash":498,"./sha256":503,inherits:387,"safe-buffer":494}],503:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[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],w=new Array(64);function f(){this.init(),this._w=w,y.call(this,64,56)}u(f,y),f.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};function v(c,a,r){return r^c&(a^r)}function h(c,a,r){return c&a|r&(c|a)}function l(c){return(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10)}function d(c){return(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7)}function s(c){return(c>>>7|c<<25)^(c>>>18|c<<14)^c>>>3}function m(c){return(c>>>17|c<<15)^(c>>>19|c<<13)^c>>>10}f.prototype._update=function(c){for(var a=this._w,r=this._a|0,t=this._b|0,i=this._c|0,n=this._d|0,o=this._e|0,p=this._f|0,O=this._g|0,P=this._h|0,B=0;B<16;++B)a[B]=c.readInt32BE(B*4);for(;B<64;++B)a[B]=m(a[B-2])+a[B-7]+s(a[B-15])+a[B-16]|0;for(var z=0;z<64;++z){var D=P+d(o)+v(o,p,O)+b[z]+a[z]|0,M=l(r)+h(r,t,i)|0;P=O,O=p,p=o,o=n+D|0,n=i,i=t,t=r,r=D+M|0}this._a=r+this._a|0,this._b=t+this._b|0,this._c=i+this._c|0,this._d=n+this._d|0,this._e=o+this._e|0,this._f=p+this._f|0,this._g=O+this._g|0,this._h=P+this._h|0},f.prototype._hash=function(){var c=g.allocUnsafe(32);return c.writeInt32BE(this._a,0),c.writeInt32BE(this._b,4),c.writeInt32BE(this._c,8),c.writeInt32BE(this._d,12),c.writeInt32BE(this._e,16),c.writeInt32BE(this._f,20),c.writeInt32BE(this._g,24),c.writeInt32BE(this._h,28),c},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],504:[function(e,S,_){var u=e("inherits"),y=e("./sha512"),g=e("./hash"),b=e("safe-buffer").Buffer,w=new Array(160);function f(){this.init(),this._w=w,g.call(this,128,112)}u(f,y),f.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},f.prototype._hash=function(){var v=b.allocUnsafe(48);function h(l,d,s){v.writeInt32BE(l,s),v.writeInt32BE(d,s+4)}return h(this._ah,this._al,0),h(this._bh,this._bl,8),h(this._ch,this._cl,16),h(this._dh,this._dl,24),h(this._eh,this._el,32),h(this._fh,this._fl,40),v},S.exports=f},{"./hash":498,"./sha512":505,inherits:387,"safe-buffer":494}],505:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[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],w=new Array(160);function f(){this.init(),this._w=w,y.call(this,128,112)}u(f,y),f.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};function v(t,i,n){return n^t&(i^n)}function h(t,i,n){return t&i|n&(t|i)}function l(t,i){return(t>>>28|i<<4)^(i>>>2|t<<30)^(i>>>7|t<<25)}function d(t,i){return(t>>>14|i<<18)^(t>>>18|i<<14)^(i>>>9|t<<23)}function s(t,i){return(t>>>1|i<<31)^(t>>>8|i<<24)^t>>>7}function m(t,i){return(t>>>1|i<<31)^(t>>>8|i<<24)^(t>>>7|i<<25)}function c(t,i){return(t>>>19|i<<13)^(i>>>29|t<<3)^t>>>6}function a(t,i){return(t>>>19|i<<13)^(i>>>29|t<<3)^(t>>>6|i<<26)}function r(t,i){return t>>>0>>0?1:0}f.prototype._update=function(t){for(var i=this._w,n=this._ah|0,o=this._bh|0,p=this._ch|0,O=this._dh|0,P=this._eh|0,B=this._fh|0,z=this._gh|0,D=this._hh|0,M=this._al|0,I=this._bl|0,T=this._cl|0,C=this._dl|0,E=this._el|0,A=this._fl|0,L=this._gl|0,$=this._hl|0,W=0;W<32;W+=2)i[W]=t.readInt32BE(W*4),i[W+1]=t.readInt32BE(W*4+4);for(;W<160;W+=2){var U=i[W-30],N=i[W-15*2+1],j=s(U,N),F=m(N,U);U=i[W-2*2],N=i[W-2*2+1];var V=c(U,N),re=a(N,U),ee=i[W-7*2],ce=i[W-7*2+1],ye=i[W-16*2],ge=i[W-16*2+1],oe=F+ce|0,J=j+ee+r(oe,F)|0;oe=oe+re|0,J=J+V+r(oe,re)|0,oe=oe+ge|0,J=J+ye+r(oe,ge)|0,i[W]=J,i[W+1]=oe}for(var Q=0;Q<160;Q+=2){J=i[Q],oe=i[Q+1];var he=h(n,o,p),xe=h(M,I,T),ne=l(n,M),se=l(M,n),Ce=d(P,E),q=d(E,P),G=b[Q],Y=b[Q+1],fe=v(P,B,z),we=v(E,A,L),_e=$+q|0,je=D+Ce+r(_e,$)|0;_e=_e+we|0,je=je+fe+r(_e,we)|0,_e=_e+Y|0,je=je+G+r(_e,Y)|0,_e=_e+oe|0,je=je+J+r(_e,oe)|0;var Ye=se+xe|0,nt=ne+he+r(Ye,se)|0;D=z,$=L,z=B,L=A,B=P,A=E,E=C+_e|0,P=O+je+r(E,C)|0,O=p,C=T,p=o,T=I,o=n,I=M,M=_e+Ye|0,n=je+nt+r(M,_e)|0}this._al=this._al+M|0,this._bl=this._bl+I|0,this._cl=this._cl+T|0,this._dl=this._dl+C|0,this._el=this._el+E|0,this._fl=this._fl+A|0,this._gl=this._gl+L|0,this._hl=this._hl+$|0,this._ah=this._ah+n+r(this._al,M)|0,this._bh=this._bh+o+r(this._bl,I)|0,this._ch=this._ch+p+r(this._cl,T)|0,this._dh=this._dh+O+r(this._dl,C)|0,this._eh=this._eh+P+r(this._el,E)|0,this._fh=this._fh+B+r(this._fl,A)|0,this._gh=this._gh+z+r(this._gl,L)|0,this._hh=this._hh+D+r(this._hl,$)|0},f.prototype._hash=function(){var t=g.allocUnsafe(64);function i(n,o,p){t.writeInt32BE(n,p),t.writeInt32BE(o,p+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),t},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],506:[function(e,S,_){S.exports=g;var u=e("events").EventEmitter,y=e("inherits");y(g,u),g.Readable=e("readable-stream/readable.js"),g.Writable=e("readable-stream/writable.js"),g.Duplex=e("readable-stream/duplex.js"),g.Transform=e("readable-stream/transform.js"),g.PassThrough=e("readable-stream/passthrough.js"),g.Stream=g;function g(){u.call(this)}g.prototype.pipe=function(b,w){var f=this;function v(a){b.writable&&b.write(a)===!1&&f.pause&&f.pause()}f.on("data",v);function h(){f.readable&&f.resume&&f.resume()}b.on("drain",h),!b._isStdio&&(!w||w.end!==!1)&&(f.on("end",d),f.on("close",s));var l=!1;function d(){l||(l=!0,b.end())}function s(){l||(l=!0,typeof b.destroy=="function"&&b.destroy())}function m(a){if(c(),u.listenerCount(this,"error")===0)throw a}f.on("error",m),b.on("error",m);function c(){f.removeListener("data",v),b.removeListener("drain",h),f.removeListener("end",d),f.removeListener("close",s),f.removeListener("error",m),b.removeListener("error",m),f.removeListener("end",c),f.removeListener("close",c),b.removeListener("close",c)}return f.on("end",c),f.on("close",c),b.on("close",c),b.emit("pipe",f),b}},{events:367,inherits:387,"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}],507:[function(e,S,_){S.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":508}],508:[function(e,S,_){var u=e("process-nextick-args"),y=Object.keys||function(m){var c=[];for(var a in m)c.push(a);return c};S.exports=l;var g=Object.create(e("core-util-is"));g.inherits=e("inherits");var b=e("./_stream_readable"),w=e("./_stream_writable");g.inherits(l,b);for(var f=y(w.prototype),v=0;v0?(typeof Q!="string"&&!se.objectMode&&Object.getPrototypeOf(Q)!==h.prototype&&(Q=d(Q)),xe?se.endEmitted?J.emit("error",new Error("stream.unshift() after end event")):B(J,se,Q,!0):se.ended?J.emit("error",new Error("stream.push() after EOF")):(se.reading=!1,se.decoder&&!he?(Q=se.decoder.write(Q),se.objectMode||Q.length!==0?B(J,se,Q,!1):L(J,se)):B(J,se,Q,!1))):xe||(se.reading=!1)}return D(se)}function B(J,Q,he,xe){Q.flowing&&Q.length===0&&!Q.sync?(J.emit("data",he),J.read(0)):(Q.length+=Q.objectMode?1:he.length,xe?Q.buffer.unshift(he):Q.buffer.push(he),Q.needReadable&&E(J)),L(J,Q)}function z(J,Q){var he;return!s(Q)&&typeof Q!="string"&&Q!==void 0&&!J.objectMode&&(he=new TypeError("Invalid non-string/buffer chunk")),he}function D(J){return!J.ended&&(J.needReadable||J.length=M?J=M:(J--,J|=J>>>1,J|=J>>>2,J|=J>>>4,J|=J>>>8,J|=J>>>16,J++),J}function T(J,Q){return J<=0||Q.length===0&&Q.ended?0:Q.objectMode?1:J!==J?Q.flowing&&Q.length?Q.buffer.head.data.length:Q.length:(J>Q.highWaterMark&&(Q.highWaterMark=I(J)),J<=Q.length?J:Q.ended?Q.length:(Q.needReadable=!0,0))}O.prototype.read=function(J){a("read",J),J=parseInt(J,10);var Q=this._readableState,he=J;if(J!==0&&(Q.emittedReadable=!1),J===0&&Q.needReadable&&(Q.length>=Q.highWaterMark||Q.ended))return a("read: emitReadable",Q.length,Q.ended),Q.length===0&&Q.ended?ye(this):E(this),null;if(J=T(J,Q),J===0&&Q.ended)return Q.length===0&&ye(this),null;var xe=Q.needReadable;a("need readable",xe),(Q.length===0||Q.length-J0?ne=V(J,Q):ne=null,ne===null?(Q.needReadable=!0,J=0):Q.length-=J,Q.length===0&&(Q.ended||(Q.needReadable=!0),he!==J&&Q.ended&&ye(this)),ne!==null&&this.emit("data",ne),ne};function C(J,Q){if(!Q.ended){if(Q.decoder){var he=Q.decoder.end();he&&he.length&&(Q.buffer.push(he),Q.length+=Q.objectMode?1:he.length)}Q.ended=!0,E(J)}}function E(J){var Q=J._readableState;Q.needReadable=!1,Q.emittedReadable||(a("emitReadable",Q.flowing),Q.emittedReadable=!0,Q.sync?g.nextTick(A,J):A(J))}function A(J){a("emit readable"),J.emit("readable"),F(J)}function L(J,Q){Q.readingMore||(Q.readingMore=!0,g.nextTick($,J,Q))}function $(J,Q){for(var he=Q.length;!Q.reading&&!Q.flowing&&!Q.ended&&Q.length1&&oe(xe.pipes,J)!==-1)&&!Y&&(a("false write response, pause",he._readableState.awaitDrain),he._readableState.awaitDrain++,we=!0),he.pause())}function je(ot){a("onerror",ot),ut(),J.removeListener("error",je),f(J,"error")===0&&J.emit("error",ot)}o(J,"error",je);function Ye(){J.removeListener("finish",nt),ut()}J.once("close",Ye);function nt(){a("onfinish"),J.removeListener("close",Ye),ut()}J.once("finish",nt);function ut(){a("unpipe"),he.unpipe(J)}return J.emit("pipe",he),xe.flowing||(a("pipe resume"),he.resume()),J};function W(J){return function(){var Q=J._readableState;a("pipeOnDrain",Q.awaitDrain),Q.awaitDrain&&Q.awaitDrain--,Q.awaitDrain===0&&f(J,"data")&&(Q.flowing=!0,F(J))}}O.prototype.unpipe=function(J){var Q=this._readableState,he={hasUnpiped:!1};if(Q.pipesCount===0)return this;if(Q.pipesCount===1)return J&&J!==Q.pipes?this:(J||(J=Q.pipes),Q.pipes=null,Q.pipesCount=0,Q.flowing=!1,J&&J.emit("unpipe",this,he),this);if(!J){var xe=Q.pipes,ne=Q.pipesCount;Q.pipes=null,Q.pipesCount=0,Q.flowing=!1;for(var se=0;se=Q.length?(Q.decoder?he=Q.buffer.join(""):Q.buffer.length===1?he=Q.buffer.head.data:he=Q.buffer.concat(Q.length),Q.buffer.clear()):he=re(J,Q.buffer,Q.decoder),he}function re(J,Q,he){var xe;return Jse.length?se.length:J;if(Ce===se.length?ne+=se:ne+=se.slice(0,J),J-=Ce,J===0){Ce===se.length?(++xe,he.next?Q.head=he.next:Q.head=Q.tail=null):(Q.head=he,he.data=se.slice(Ce));break}++xe}return Q.length-=xe,ne}function ce(J,Q){var he=h.allocUnsafe(J),xe=Q.head,ne=1;for(xe.data.copy(he),J-=xe.data.length;xe=xe.next;){var se=xe.data,Ce=J>se.length?se.length:J;if(se.copy(he,he.length-J,0,Ce),J-=Ce,J===0){Ce===se.length?(++ne,xe.next?Q.head=xe.next:Q.head=Q.tail=null):(Q.head=xe,xe.data=se.slice(Ce));break}++ne}return Q.length-=ne,he}function ye(J){var Q=J._readableState;if(Q.length>0)throw new Error('"endReadable()" called on non-empty stream');Q.endEmitted||(Q.ended=!0,g.nextTick(ge,Q,J))}function ge(J,Q){!J.endEmitted&&J.length===0&&(J.endEmitted=!0,Q.readable=!1,Q.emit("end"))}function oe(J,Q){for(var he=0,xe=J.length;he-1?g:b.nextTick,v;o.WritableState=i;var h=Object.create(e("core-util-is"));h.inherits=e("inherits");var l={deprecate:e("util-deprecate")},d=e("./internal/streams/stream"),s=e("safe-buffer").Buffer,m=y.Uint8Array||function(){};function c(j){return s.from(j)}function a(j){return s.isBuffer(j)||j instanceof m}var r=e("./internal/streams/destroy");h.inherits(o,d);function t(){}function i(j,F){v=v||e("./_stream_duplex"),j=j||{};var V=F instanceof v;this.objectMode=!!j.objectMode,V&&(this.objectMode=this.objectMode||!!j.writableObjectMode);var re=j.highWaterMark,ee=j.writableHighWaterMark,ce=this.objectMode?16:16*1024;re||re===0?this.highWaterMark=re:V&&(ee||ee===0)?this.highWaterMark=ee:this.highWaterMark=ce,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 ye=j.decodeStrings===!1;this.decodeStrings=!ye,this.defaultEncoding=j.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ge){I(F,ge)},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 w(this)}i.prototype.getBuffer=function(){for(var F=this.bufferedRequest,V=[];F;)V.push(F),F=F.next;return V},function(){try{Object.defineProperty(i.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var n;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(o,Symbol.hasInstance,{value:function(F){return n.call(this,F)?!0:this!==o?!1:F&&F._writableState instanceof i}})):n=function(F){return F instanceof this};function o(j){if(v=v||e("./_stream_duplex"),!n.call(o,this)&&!(this instanceof v))return new o(j);this._writableState=new i(j,this),this.writable=!0,j&&(typeof j.write=="function"&&(this._write=j.write),typeof j.writev=="function"&&(this._writev=j.writev),typeof j.destroy=="function"&&(this._destroy=j.destroy),typeof j.final=="function"&&(this._final=j.final)),d.call(this)}o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function p(j,F){var V=new Error("write after end");j.emit("error",V),b.nextTick(F,V)}function O(j,F,V,re){var ee=!0,ce=!1;return V===null?ce=new TypeError("May not write null values to stream"):typeof V!="string"&&V!==void 0&&!F.objectMode&&(ce=new TypeError("Invalid non-string/buffer chunk")),ce&&(j.emit("error",ce),b.nextTick(re,ce),ee=!1),ee}o.prototype.write=function(j,F,V){var re=this._writableState,ee=!1,ce=!re.objectMode&&a(j);return ce&&!s.isBuffer(j)&&(j=c(j)),typeof F=="function"&&(V=F,F=null),ce?F="buffer":F||(F=re.defaultEncoding),typeof V!="function"&&(V=t),re.ended?p(this,V):(ce||O(this,re,j,V))&&(re.pendingcb++,ee=B(this,re,ce,j,F,V)),ee},o.prototype.cork=function(){var j=this._writableState;j.corked++},o.prototype.uncork=function(){var j=this._writableState;j.corked&&(j.corked--,!j.writing&&!j.corked&&!j.finished&&!j.bufferProcessing&&j.bufferedRequest&&E(this,j))},o.prototype.setDefaultEncoding=function(F){if(typeof F=="string"&&(F=F.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((F+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+F);return this._writableState.defaultEncoding=F,this};function P(j,F,V){return!j.objectMode&&j.decodeStrings!==!1&&typeof F=="string"&&(F=s.from(F,V)),F}Object.defineProperty(o.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function B(j,F,V,re,ee,ce){if(!V){var ye=P(F,re,ee);re!==ye&&(V=!0,ee="buffer",re=ye)}var ge=F.objectMode?1:re.length;F.length+=ge;var oe=F.length0?this.tail.next=h:this.head=h,this.tail=h,++this.length},w.prototype.unshift=function(v){var h={data:v,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length},w.prototype.shift=function(){if(this.length!==0){var v=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,v}},w.prototype.clear=function(){this.head=this.tail=null,this.length=0},w.prototype.join=function(v){if(this.length===0)return"";for(var h=this.head,l=""+h.data;h=h.next;)l+=v+h.data;return l},w.prototype.concat=function(v){if(this.length===0)return y.alloc(0);if(this.length===1)return this.head.data;for(var h=y.allocUnsafe(v>>>0),l=this.head,d=0;l;)b(l.data,h,d),d+=l.data.length,l=l.next;return h},w}(),g&&g.inspect&&g.inspect.custom&&(S.exports.prototype[g.inspect.custom]=function(){var w=g.inspect({length:this.length});return this.constructor.name+" "+w})},{"safe-buffer":494,util:185}],514:[function(e,S,_){var u=e("process-nextick-args");function y(w,f){var v=this,h=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return h||l?(f?f(w):w&&(!this._writableState||!this._writableState.errorEmitted)&&u.nextTick(b,this,w),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(w||null,function(d){!f&&d?(u.nextTick(b,v,d),v._writableState&&(v._writableState.errorEmitted=!0)):f&&f(d)}),this)}function g(){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.finished=!1,this._writableState.errorEmitted=!1)}function b(w,f){w.emit("error",f)}S.exports={destroy:y,undestroy:g}},{"process-nextick-args":466}],515:[function(e,S,_){arguments[4][490][0].apply(_,arguments)},{dup:490,events:367}],516:[function(e,S,_){S.exports=e("./readable").PassThrough},{"./readable":517}],517:[function(e,S,_){_=S.exports=e("./lib/_stream_readable.js"),_.Stream=_,_.Readable=_,_.Writable=e("./lib/_stream_writable.js"),_.Duplex=e("./lib/_stream_duplex.js"),_.Transform=e("./lib/_stream_transform.js"),_.PassThrough=e("./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(e,S,_){S.exports=e("./readable").Transform},{"./readable":517}],519:[function(e,S,_){S.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":512}],520:[function(e,S,_){var u=e("safe-buffer").Buffer,y=u.isEncoding||function(n){switch(n=""+n,n&&n.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 g(n){if(!n)return"utf8";for(var o;;)switch(n){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 n;default:if(o)return;n=(""+n).toLowerCase(),o=!0}}function b(n){var o=g(n);if(typeof o!="string"&&(u.isEncoding===y||!y(n)))throw new Error("Unknown encoding: "+n);return o||n}_.StringDecoder=w;function w(n){this.encoding=b(n);var o;switch(this.encoding){case"utf16le":this.text=m,this.end=c,o=4;break;case"utf8":this.fillLast=l,o=4;break;case"base64":this.text=a,this.end=r,o=3;break;default:this.write=t,this.end=i;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=u.allocUnsafe(o)}w.prototype.write=function(n){if(n.length===0)return"";var o,p;if(this.lastNeed){if(o=this.fillLast(n),o===void 0)return"";p=this.lastNeed,this.lastNeed=0}else p=0;return p>5===6?2:n>>4===14?3:n>>3===30?4:n>>6===2?-1:-2}function v(n,o,p){var O=o.length-1;if(O=0?(P>0&&(n.lastNeed=P-1),P):--O=0?(P>0&&(n.lastNeed=P-2),P):--O=0?(P>0&&(P===2?P=0:n.lastNeed=P-3),P):0))}function h(n,o,p){if((o[0]&192)!==128)return n.lastNeed=0,"�";if(n.lastNeed>1&&o.length>1){if((o[1]&192)!==128)return n.lastNeed=1,"�";if(n.lastNeed>2&&o.length>2&&(o[2]&192)!==128)return n.lastNeed=2,"�"}}function l(n){var o=this.lastTotal-this.lastNeed,p=h(this,n);if(p!==void 0)return p;if(this.lastNeed<=n.length)return n.copy(this.lastChar,o,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);n.copy(this.lastChar,o,0,n.length),this.lastNeed-=n.length}function d(n,o){var p=v(this,n,o);if(!this.lastNeed)return n.toString("utf8",o);this.lastTotal=p;var O=n.length-(p-this.lastNeed);return n.copy(this.lastChar,0,O),n.toString("utf8",o,O)}function s(n){var o=n&&n.length?this.write(n):"";return this.lastNeed?o+"�":o}function m(n,o){if((n.length-o)%2===0){var p=n.toString("utf16le",o);if(p){var O=p.charCodeAt(p.length-1);if(O>=55296&&O<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=n[n.length-2],this.lastChar[1]=n[n.length-1],p.slice(0,-1)}return p}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=n[n.length-1],n.toString("utf16le",o,n.length-1)}function c(n){var o=n&&n.length?this.write(n):"";if(this.lastNeed){var p=this.lastTotal-this.lastNeed;return o+this.lastChar.toString("utf16le",0,p)}return o}function a(n,o){var p=(n.length-o)%3;return p===0?n.toString("base64",o):(this.lastNeed=3-p,this.lastTotal=3,p===1?this.lastChar[0]=n[n.length-1]:(this.lastChar[0]=n[n.length-2],this.lastChar[1]=n[n.length-1]),n.toString("base64",o,n.length-p))}function r(n){var o=n&&n.length?this.write(n):"";return this.lastNeed?o+this.lastChar.toString("base64",0,3-this.lastNeed):o}function t(n){return n.toString(this.encoding)}function i(n){return n&&n.length?this.write(n):""}},{"safe-buffer":494}],521:[function(e,S,_){(function(u,y){var g=e("process/browser.js").nextTick,b=Function.prototype.apply,w=Array.prototype.slice,f={},v=0;_.setTimeout=function(){return new h(b.call(setTimeout,window,arguments),clearTimeout)},_.setInterval=function(){return new h(b.call(setInterval,window,arguments),clearInterval)},_.clearTimeout=_.clearInterval=function(l){l.close()};function h(l,d){this._id=l,this._clearFn=d}h.prototype.unref=h.prototype.ref=function(){},h.prototype.close=function(){this._clearFn.call(window,this._id)},_.enroll=function(l,d){clearTimeout(l._idleTimeoutId),l._idleTimeout=d},_.unenroll=function(l){clearTimeout(l._idleTimeoutId),l._idleTimeout=-1},_._unrefActive=_.active=function(l){clearTimeout(l._idleTimeoutId);var d=l._idleTimeout;d>=0&&(l._idleTimeoutId=setTimeout(function(){l._onTimeout&&l._onTimeout()},d))},_.setImmediate=typeof u=="function"?u:function(l){var d=v++,s=arguments.length<2?!1:w.call(arguments,1);return f[d]=!0,g(function(){f[d]&&(s?l.apply(null,s):l.call(null),_.clearImmediate(d))}),d},_.clearImmediate=typeof y=="function"?y:function(l){delete f[l]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":467,timers:521}],522:[function(e,S,_){(function(u){S.exports=y;function y(b,w){if(g("noDeprecation"))return b;var f=!1;function v(){if(!f){if(g("throwDeprecation"))throw new Error(w);g("traceDeprecation")?console.trace(w):console.warn(w),f=!0}return b.apply(this,arguments)}return v}function g(b){try{if(!u.localStorage)return!1}catch{return!1}var w=u.localStorage[b];return w==null?!1:String(w).toLowerCase()==="true"}}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],523:[function(e,S,_){typeof Object.create=="function"?S.exports=function(y,g){y.super_=g,y.prototype=Object.create(g.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}})}:S.exports=function(y,g){y.super_=g;var b=function(){};b.prototype=g.prototype,y.prototype=new b,y.prototype.constructor=y}},{}],524:[function(e,S,_){function u(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(b){return typeof b}:u=function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},u(y)}S.exports=function(g){return g&&u(g)==="object"&&typeof g.copy=="function"&&typeof g.fill=="function"&&typeof g.readUInt8=="function"}},{}],525:[function(e,S,_){(function(u,y){function g(N){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?g=function(F){return typeof F}:g=function(F){return F&&typeof Symbol=="function"&&F.constructor===Symbol&&F!==Symbol.prototype?"symbol":typeof F},g(N)}var b=/%[sdj%]/g;_.format=function(N){if(!P(N)){for(var j=[],F=0;F=re)return ye;switch(ye){case"%s":return String(V[F++]);case"%d":return Number(V[F++]);case"%j":try{return JSON.stringify(V[F++])}catch{return"[Circular]"}default:return ye}}),ce=V[F];F=3&&(F.depth=arguments[2]),arguments.length>=4&&(F.colors=arguments[3]),n(j)?F.showHidden=j:j&&_._extend(F,j),z(F.showHidden)&&(F.showHidden=!1),z(F.depth)&&(F.depth=2),z(F.colors)&&(F.colors=!1),z(F.customInspect)&&(F.customInspect=!0),F.colors&&(F.stylize=h),s(F,N,F.depth)}_.inspect=v,v.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]},v.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function h(N,j){var F=v.styles[j];return F?"\x1B["+v.colors[F][0]+"m"+N+"\x1B["+v.colors[F][1]+"m":N}function l(N,j){return N}function d(N){var j={};return N.forEach(function(F,V){j[F]=!0}),j}function s(N,j,F){if(N.customInspect&&j&&C(j.inspect)&&j.inspect!==_.inspect&&!(j.constructor&&j.constructor.prototype===j)){var V=j.inspect(F,N);return P(V)||(V=s(N,V,F)),V}var re=m(N,j);if(re)return re;var ee=Object.keys(j),ce=d(ee);if(N.showHidden&&(ee=Object.getOwnPropertyNames(j)),T(j)&&(ee.indexOf("message")>=0||ee.indexOf("description")>=0))return c(j);if(ee.length===0){if(C(j)){var ye=j.name?": "+j.name:"";return N.stylize("[Function"+ye+"]","special")}if(D(j))return N.stylize(RegExp.prototype.toString.call(j),"regexp");if(I(j))return N.stylize(Date.prototype.toString.call(j),"date");if(T(j))return c(j)}var ge="",oe=!1,J=["{","}"];if(i(j)&&(oe=!0,J=["[","]"]),C(j)){var Q=j.name?": "+j.name:"";ge=" [Function"+Q+"]"}if(D(j)&&(ge=" "+RegExp.prototype.toString.call(j)),I(j)&&(ge=" "+Date.prototype.toUTCString.call(j)),T(j)&&(ge=" "+c(j)),ee.length===0&&(!oe||j.length==0))return J[0]+ge+J[1];if(F<0)return D(j)?N.stylize(RegExp.prototype.toString.call(j),"regexp"):N.stylize("[Object]","special");N.seen.push(j);var he;return oe?he=a(N,j,F,ce,ee):he=ee.map(function(xe){return r(N,j,F,ce,xe,oe)}),N.seen.pop(),t(he,ge,J)}function m(N,j){if(z(j))return N.stylize("undefined","undefined");if(P(j)){var F="'"+JSON.stringify(j).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return N.stylize(F,"string")}if(O(j))return N.stylize(""+j,"number");if(n(j))return N.stylize(""+j,"boolean");if(o(j))return N.stylize("null","null")}function c(N){return"["+Error.prototype.toString.call(N)+"]"}function a(N,j,F,V,re){for(var ee=[],ce=0,ye=j.length;ce-1&&(ee?ye=ye.split(` -`).map(function(oe){return" "+oe}).join(` +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function h(yt,Ke){if(yt){if(typeof yt=="string")return s(yt,Ke);var me=Object.prototype.toString.call(yt).slice(8,-1);if(me==="Object"&&yt.constructor&&(me=yt.constructor.name),me==="Map"||me==="Set")return Array.from(yt);if(me==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(me))return s(yt,Ke)}}function l(yt){if(typeof Symbol<"u"&&Symbol.iterator in Object(yt))return Array.from(yt)}function d(yt){if(Array.isArray(yt))return s(yt)}function s(yt,Ke){(Ke==null||Ke>yt.length)&&(Ke=yt.length);for(var me=0,Be=new Array(Ke);me",lt:"<",quot:'"',apos:"'"},C=-1,O=-2,A=0,L=1,U=2,W=3,$=4,N=5,F=6,j=7,V=8,te=9,re=10,le=11,ye=12,ge=13,ne=14,J=15,Q=16,he=17,xe=18,ie=19,se=20,Ce=21,q=22,G=23,Y=24,fe=25,we=26,_e=27,je=28,Ye=29,nt=30,ut=31,ot=32,Ue=33,Ve=34,Qe=35,tt=36,oe=37,Re=38,be=39,Ee=40,pe=41,Pe=42,ee=43,He=44,it=9,K=10,Me=13,Le=32,ue=33,ke=34,Ie=38,st=39,Ge=45,rt=47,_t=59,wt=60,Ot=61,pt=62,ct=63,At=91,Pt=93,bt=133,Kt=8232,Ct=function(Ke){return Ke===ke||Ke===st},St=[ke,st],Bt=[].concat(St,[At,pt]),Lt=[].concat(St,[wt,Pt]),Et=[Ot,ct].concat(f(o)),Nr=[].concat(f(o),[pt,Ie,wt]);function Or(yt,Ke,me){switch(Ke){case"xml":me!==B&&yt.fail("xml prefix must be bound to ".concat(B,"."));break;case"xmlns":me!==M&&yt.fail("xmlns prefix must be bound to ".concat(M,"."));break}switch(me){case M:yt.fail(Ke===""?"the default namespace may not be set to ".concat(me,"."):'may not assign a prefix (even "xmlns") to the URI '.concat(M,"."));break;case B:switch(Ke){case"xml":break;case"":yt.fail("the default namespace may not be set to ".concat(me,"."));break;default:yt.fail("may not assign the xml namespace to another prefix.")}break}}function Gr(yt,Ke){for(var me=0,Be=Object.keys(Ke);me0&&(Fe+=":"),Fe+="".concat(this.line,":").concat(this.column)),Fe.length>0&&(Fe+=": "),new Error(Fe+me)}},{key:"fail",value:function(me){var Be=this.makeError(me),Fe=this.errorHandler;if(Fe===void 0)throw Be;return Fe(Be),this}},{key:"write",value:function(me){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");var Be=!1;me===null?(Be=!0,me=""):y(me)==="object"&&(me=me.toString()),this.carriedFromPrevious!==void 0&&(me="".concat(this.carriedFromPrevious).concat(me),this.carriedFromPrevious=void 0);var Fe=me.length,dt=me.charCodeAt(Fe-1);!Be&&(dt===Me||dt>=55296&&dt<=56319)&&(this.carriedFromPrevious=me[Fe-1],Fe--,me=me.slice(0,Fe));var kt=this.stateTable;for(this.chunk=me,this.i=0;this.i=me.length)return C;var Fe=me.charCodeAt(Be);if(this.column++,Fe<55296){if(Fe>=Le||Fe===it)return Fe;switch(Fe){case K:return this.line++,this.column=0,this.positionAtNewLine=this.position,K;case Me:return me.charCodeAt(Be+1)===K&&(this.i=Be+2),this.line++,this.column=0,this.positionAtNewLine=this.position,O;default:return this.fail("disallowed character."),Fe}}if(Fe>56319)return Fe>=57344&&Fe<=65533||this.fail("disallowed character."),Fe;var dt=65536+(Fe-55296)*1024+(me.charCodeAt(Be+1)-56320);return this.i=Be+2,dt>1114111&&this.fail("disallowed character."),dt}},{key:"getCode11",value:function(){var me=this.chunk,Be=this.i;if(this.prevI=Be,this.i=Be+1,Be>=me.length)return C;var Fe=me.charCodeAt(Be);if(this.column++,Fe<55296){if(Fe>31&&Fe<127||Fe>159&&Fe!==Kt||Fe===it)return Fe;switch(Fe){case K:return this.line++,this.column=0,this.positionAtNewLine=this.position,K;case Me:{var dt=me.charCodeAt(Be+1);(dt===K||dt===bt)&&(this.i=Be+2)}case bt:case Kt:return this.line++,this.column=0,this.positionAtNewLine=this.position,O;default:return this.fail("disallowed character."),Fe}}if(Fe>56319)return Fe>=57344&&Fe<=65533||this.fail("disallowed character."),Fe;var kt=65536+(Fe-55296)*1024+(me.charCodeAt(Be+1)-56320);return this.i=Be+2,kt>1114111&&this.fail("disallowed character."),kt}},{key:"getCodeNorm",value:function(){var me=this.getCode();return me===O?K:me}},{key:"unget",value:function(){this.i=this.prevI,this.column--}},{key:"captureTo",value:function(me){for(var Be=this.i,Fe=this.chunk;;){var dt=this.getCode(),kt=dt===O,Ht=kt?K:dt;if(Ht===C||me.includes(Ht))return this.text+=Fe.slice(Be,this.prevI),Ht;kt&&(this.text+="".concat(Fe.slice(Be,this.prevI),` +`),Be=this.i)}}},{key:"captureToChar",value:function(me){for(var Be=this.i,Fe=this.chunk;;){var dt=this.getCode();switch(dt){case O:this.text+="".concat(Fe.slice(Be,this.prevI),` +`),Be=this.i,dt=K;break;case C:return this.text+=Fe.slice(Be),!1}if(dt===me)return this.text+=Fe.slice(Be,this.prevI),!0}}},{key:"captureNameChars",value:function(){for(var me=this.chunk,Be=this.i;;){var Fe=this.getCode();if(Fe===C)return this.name+=me.slice(Be),C;if(!n(Fe))return this.name+=me.slice(Be,this.prevI),Fe===O?K:Fe}}},{key:"skipSpaces",value:function(){for(;;){var me=this.getCodeNorm();if(me===C||!r(me))return me}}},{key:"setXMLVersion",value:function(me){this.currentXMLVersion=me,me==="1.0"?(this.isChar=t,this.getCode=this.getCode10):(this.isChar=E,this.getCode=this.getCode11)}},{key:"sBegin",value:function(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=L}},{key:"sBeginWhitespace",value:function(){var me=this.i,Be=this.skipSpaces();switch(this.prevI!==me&&(this.xmlDeclPossible=!1),Be){case wt:if(this.state=J,this.text.length!==0)throw new Error("no-empty text at start");break;case C:break;default:this.unget(),this.state=ge,this.xmlDeclPossible=!1}}},{key:"sDoctype",value:function(){var me,Be=this.captureTo(Bt);switch(Be){case pt:{(me=this.doctypeHandler)===null||me===void 0||me.call(this,this.text),this.text="",this.state=ge,this.doctype=!0;break}case C:break;default:this.text+=String.fromCodePoint(Be),Be===At?this.state=$:Ct(Be)&&(this.state=W,this.q=Be)}}},{key:"sDoctypeQuote",value:function(){var me=this.q;this.captureToChar(me)&&(this.text+=String.fromCodePoint(me),this.q=null,this.state=U)}},{key:"sDTD",value:function(){var me=this.captureTo(Lt);me!==C&&(this.text+=String.fromCodePoint(me),me===Pt?this.state=U:me===wt?this.state=F:Ct(me)&&(this.state=N,this.q=me))}},{key:"sDTDQuoted",value:function(){var me=this.q;this.captureToChar(me)&&(this.text+=String.fromCodePoint(me),this.state=$,this.q=null)}},{key:"sDTDOpenWaka",value:function(){var me=this.getCodeNorm();switch(this.text+=String.fromCodePoint(me),me){case ue:this.state=j,this.openWakaBang="";break;case ct:this.state=le;break;default:this.state=$}}},{key:"sDTDOpenWakaBang",value:function(){var me=String.fromCodePoint(this.getCodeNorm()),Be=this.openWakaBang+=me;this.text+=me,Be!=="-"&&(this.state=Be==="--"?V:$,this.openWakaBang="")}},{key:"sDTDComment",value:function(){this.captureToChar(Ge)&&(this.text+="-",this.state=te)}},{key:"sDTDCommentEnding",value:function(){var me=this.getCodeNorm();this.text+=String.fromCodePoint(me),this.state=me===Ge?re:V}},{key:"sDTDCommentEnded",value:function(){var me=this.getCodeNorm();this.text+=String.fromCodePoint(me),me===pt?this.state=$:(this.fail("malformed comment."),this.state=V)}},{key:"sDTDPI",value:function(){this.captureToChar(ct)&&(this.text+="?",this.state=ye)}},{key:"sDTDPIEnding",value:function(){var me=this.getCodeNorm();this.text+=String.fromCodePoint(me),me===pt&&(this.state=$)}},{key:"sText",value:function(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}},{key:"sEntity",value:function(){var me=this.i,Be=this.chunk;e:for(;;)switch(this.getCode()){case O:this.entity+="".concat(Be.slice(me,this.prevI),` +`),me=this.i;break;case _t:{var Fe=this.entityReturnState,dt=this.entity+Be.slice(me,this.prevI);this.state=Fe;var kt=void 0;dt===""?(this.fail("empty entity name."),kt="&;"):(kt=this.parseEntity(dt),this.entity=""),(Fe!==ge||this.textHandler!==void 0)&&(this.text+=kt);break e}case C:this.entity+=Be.slice(me);break e}}},{key:"sOpenWaka",value:function(){var me=this.getCode();if(i(me))this.state=Ve,this.unget(),this.xmlDeclPossible=!1;else switch(me){case rt:this.state=ee,this.xmlDeclPossible=!1;break;case ue:this.state=Q,this.openWakaBang="",this.xmlDeclPossible=!1;break;case ct:this.state=G;break;default:this.fail("disallowed character in tag name"),this.state=ge,this.xmlDeclPossible=!1}}},{key:"sOpenWakaBang",value:function(){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=se,this.openWakaBang="";break;case"--":this.state=he,this.openWakaBang="";break;case"DOCTYPE":this.state=U,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}},{key:"sComment",value:function(){this.captureToChar(Ge)&&(this.state=xe)}},{key:"sCommentEnding",value:function(){var me,Be=this.getCodeNorm();Be===Ge?(this.state=ie,(me=this.commentHandler)===null||me===void 0||me.call(this,this.text),this.text=""):(this.text+="-".concat(String.fromCodePoint(Be)),this.state=he)}},{key:"sCommentEnded",value:function(){var me=this.getCodeNorm();me!==pt?(this.fail("malformed comment."),this.text+="--".concat(String.fromCodePoint(me)),this.state=he):this.state=ge}},{key:"sCData",value:function(){this.captureToChar(Pt)&&(this.state=Ce)}},{key:"sCDataEnding",value:function(){var me=this.getCodeNorm();me===Pt?this.state=q:(this.text+="]".concat(String.fromCodePoint(me)),this.state=se)}},{key:"sCDataEnding2",value:function(){var me,Be=this.getCodeNorm();switch(Be){case pt:{(me=this.cdataHandler)===null||me===void 0||me.call(this,this.text),this.text="",this.state=ge;break}case Pt:this.text+="]";break;default:this.text+="]]".concat(String.fromCodePoint(Be)),this.state=se}}},{key:"sPIFirstChar",value:function(){var me=this.getCodeNorm();this.nameStartCheck(me)?(this.piTarget+=String.fromCodePoint(me),this.state=Y):me===ct||r(me)?(this.fail("processing instruction without a target."),this.state=me===ct?we:fe):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(me),this.state=Y)}},{key:"sPIRest",value:function(){for(var me=this.chunk,Be=this.i;;){var Fe=this.getCodeNorm();if(Fe===C){this.piTarget+=me.slice(Be);return}if(!this.nameCheck(Fe)){this.piTarget+=me.slice(Be,this.prevI);var dt=Fe===ct;dt||r(Fe)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=dt?Ue:_e):this.state=dt?we:fe:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(Fe));break}}}},{key:"sPIBody",value:function(){if(this.text.length===0){var me=this.getCodeNorm();me===ct?this.state=we:r(me)||(this.text=String.fromCodePoint(me))}else this.captureToChar(ct)&&(this.state=we)}},{key:"sPIEnding",value:function(){var me,Be=this.getCodeNorm();if(Be===pt){var Fe=this.piTarget;Fe.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),(me=this.piHandler)===null||me===void 0||me.call(this,{target:Fe,body:this.text}),this.piTarget=this.text="",this.state=ge}else Be===ct?this.text+="?":(this.text+="?".concat(String.fromCodePoint(Be)),this.state=fe);this.xmlDeclPossible=!1}},{key:"sXMLDeclNameStart",value:function(){var me=this.skipSpaces();if(me===ct){this.state=Ue;return}me!==C&&(this.state=je,this.name=String.fromCodePoint(me))}},{key:"sXMLDeclName",value:function(){var me=this.captureTo(Et);if(me===ct){this.state=Ue,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(r(me)||me===Ot){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 ".concat(this.xmlDeclExpects[0],"."));break;default:this.fail("expected one of ".concat(this.xmlDeclExpects.join(", ")))}this.state=me===Ot?nt:Ye}}},{key:"sXMLDeclEq",value:function(){var me=this.getCodeNorm();if(me===ct){this.state=Ue,this.fail("XML declaration is incomplete.");return}r(me)||(me!==Ot&&this.fail("value required."),this.state=nt)}},{key:"sXMLDeclValueStart",value:function(){var me=this.getCodeNorm();if(me===ct){this.state=Ue,this.fail("XML declaration is incomplete.");return}r(me)||(Ct(me)?this.q=me:(this.fail("value must be quoted."),this.q=Le),this.state=ut)}},{key:"sXMLDeclValue",value:function(){var me=this.captureTo([this.q,ct]);if(me===ct){this.state=Ue,this.text="",this.fail("XML declaration is incomplete.");return}if(me!==C){var Be=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];var Fe=Be;this.xmlDecl.version=Fe,/^1\.[0-9]+$/.test(Fe)?this.opt.forceXMLVersion||this.setXMLVersion(Fe):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(Be)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=Be;break;case"standalone":Be!=="yes"&&Be!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=Be;break}this.name="",this.state=ot}}},{key:"sXMLDeclSeparator",value:function(){var me=this.getCodeNorm();if(me===ct){this.state=Ue;return}r(me)||(this.fail("whitespace required."),this.unget()),this.state=_e}},{key:"sXMLDeclEnding",value:function(){var me,Be=this.getCodeNorm();Be===pt?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),(me=this.xmldeclHandler)===null||me===void 0||me.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=ge):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}},{key:"sOpenTag",value:function(){var me,Be=this.captureNameChars();if(Be!==C){var Fe=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=Fe.ns=Object.create(null)),(me=this.openTagStartHandler)===null||me===void 0||me.call(this,Fe),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),Be){case pt:this.openTag();break;case rt:this.state=Qe;break;default:r(Be)||this.fail("disallowed character in tag name."),this.state=tt}}}},{key:"sOpenTagSlash",value:function(){this.getCode()===pt?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=tt)}},{key:"sAttrib",value:function(){var me=this.skipSpaces();me!==C&&(i(me)?(this.unget(),this.state=oe):me===pt?this.openTag():me===rt?this.state=Qe:this.fail("disallowed character in attribute name."))}},{key:"sAttribName",value:function(){var me=this.captureNameChars();me===Ot?this.state=be:r(me)?this.state=Re:me===pt?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):me!==C&&this.fail("disallowed character in attribute name.")}},{key:"sAttribNameSawWhite",value:function(){var me=this.skipSpaces();switch(me){case C:return;case Ot:this.state=be;break;default:this.fail("attribute without value."),this.text="",this.name="",me===pt?this.openTag():i(me)?(this.unget(),this.state=oe):(this.fail("disallowed character in attribute name."),this.state=tt)}}},{key:"sAttribValue",value:function(){var me=this.getCodeNorm();Ct(me)?(this.q=me,this.state=Ee):r(me)||(this.fail("unquoted attribute value."),this.state=Pe,this.unget())}},{key:"sAttribValueQuoted",value:function(){for(var me=this.q,Be=this.chunk,Fe=this.i;;)switch(this.getCode()){case me:this.pushAttrib(this.name,this.text+Be.slice(Fe,this.prevI)),this.name=this.text="",this.q=null,this.state=pe;return;case Ie:this.text+=Be.slice(Fe,this.prevI),this.state=ne,this.entityReturnState=Ee;return;case K:case O:case it:this.text+="".concat(Be.slice(Fe,this.prevI)," "),Fe=this.i;break;case wt:this.text+=Be.slice(Fe,this.prevI),this.fail("disallowed character.");return;case C:this.text+=Be.slice(Fe);return}}},{key:"sAttribValueClosed",value:function(){var me=this.getCodeNorm();r(me)?this.state=tt:me===pt?this.openTag():me===rt?this.state=Qe:i(me)?(this.fail("no whitespace between attributes."),this.unget(),this.state=oe):this.fail("disallowed character in attribute name.")}},{key:"sAttribValueUnquoted",value:function(){var me=this.captureTo(Nr);switch(me){case Ie:this.state=ne,this.entityReturnState=Pe;break;case wt:this.fail("disallowed character.");break;case C:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",me===pt?this.openTag():this.state=tt}}},{key:"sCloseTag",value:function(){var me=this.captureNameChars();me===pt?this.closeTag():r(me)?this.state=He:me!==C&&this.fail("disallowed character in closing tag.")}},{key:"sCloseTagSawWhite",value:function(){switch(this.skipSpaces()){case pt:this.closeTag();break;case C:break;default:this.fail("disallowed character in closing tag.")}}},{key:"handleTextInRoot",value:function(){var me=this.i,Be=this.forbiddenState,Fe=this.chunk,dt=this.textHandler;e:for(;;)switch(this.getCode()){case wt:{if(this.state=J,dt!==void 0){var kt=this.text,Ht=Fe.slice(me,this.prevI);kt.length!==0?(dt(kt+Ht),this.text=""):Ht.length!==0&&dt(Ht)}Be=Qt;break e}case Ie:this.state=ne,this.entityReturnState=ge,dt!==void 0&&(this.text+=Fe.slice(me,this.prevI)),Be=Qt;break e;case Pt:switch(Be){case Qt:Be=Xr;break;case Xr:Be=Br;break;case Br:break;default:throw new Error("impossible state")}break;case pt:Be===Br&&this.fail('the string "]]>" is disallowed in char data.'),Be=Qt;break;case O:dt!==void 0&&(this.text+="".concat(Fe.slice(me,this.prevI),` +`)),me=this.i,Be=Qt;break;case C:dt!==void 0&&(this.text+=Fe.slice(me));break e;default:Be=Qt}this.forbiddenState=Be}},{key:"handleTextOutsideRoot",value:function(){var me=this.i,Be=this.chunk,Fe=this.textHandler,dt=!1;e:for(;;){var kt=this.getCode();switch(kt){case wt:{if(this.state=J,Fe!==void 0){var Ht=this.text,lr=Be.slice(me,this.prevI);Ht.length!==0?(Fe(Ht+lr),this.text=""):lr.length!==0&&Fe(lr)}break e}case Ie:this.state=ne,this.entityReturnState=ge,Fe!==void 0&&(this.text+=Be.slice(me,this.prevI)),dt=!0;break e;case O:Fe!==void 0&&(this.text+="".concat(Be.slice(me,this.prevI),` +`)),me=this.i;break;case C:Fe!==void 0&&(this.text+=Be.slice(me));break e;default:r(kt)||(dt=!0)}}dt&&(!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))}},{key:"pushAttribNS",value:function(me,Be){var Fe,dt=this.qname(me),kt=dt.prefix,Ht=dt.local,lr={name:me,prefix:kt,local:Ht,value:Be};if(this.attribList.push(lr),(Fe=this.attributeHandler)===null||Fe===void 0||Fe.call(this,lr),kt==="xmlns"){var gr=Be.trim();this.currentXMLVersion==="1.0"&&gr===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[Ht]=gr,Or(this,Ht,gr)}else if(me==="xmlns"){var rn=Be.trim();this.topNS[""]=rn,Or(this,"",rn)}}},{key:"pushAttribPlain",value:function(me,Be){var Fe,dt={name:me,value:Be};this.attribList.push(dt),(Fe=this.attributeHandler)===null||Fe===void 0||Fe.call(this,dt)}},{key:"end",value:function(){var me,Be;this.sawRoot||this.fail("document must contain a root element.");for(var Fe=this.tags;Fe.length>0;){var dt=Fe.pop();this.fail("unclosed tag: ".concat(dt.name))}this.state!==A&&this.state!==ge&&this.fail("unexpected end.");var kt=this.text;return kt.length!==0&&((me=this.textHandler)===null||me===void 0||me.call(this,kt),this.text=""),this._closed=!0,(Be=this.endHandler)===null||Be===void 0||Be.call(this),this._init(),this}},{key:"resolve",value:function(me){var Be,Fe,dt=this.topNS[me];if(dt!==void 0)return dt;for(var kt=this.tags,Ht=kt.length-1;Ht>=0;Ht--)if(dt=kt[Ht].ns[me],dt!==void 0)return dt;return dt=this.ns[me],dt!==void 0?dt:(Fe=(Be=this.opt).resolvePrefix)===null||Fe===void 0?void 0:Fe.call(Be,me)}},{key:"qname",value:function(me){var Be=me.indexOf(":");if(Be===-1)return{prefix:"",local:me};var Fe=me.slice(Be+1),dt=me.slice(0,Be);return(dt===""||Fe===""||Fe.includes(":"))&&this.fail("malformed name: ".concat(me,".")),{prefix:dt,local:Fe}}},{key:"processAttribsNS",value:function(){var me,Be=this.attribList,Fe=this.tag;{var dt=this.qname(Fe.name),kt=dt.prefix,Ht=dt.local;Fe.prefix=kt,Fe.local=Ht;var lr=Fe.uri=(me=this.resolve(kt))!==null&&me!==void 0?me:"";kt!==""&&(kt==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),lr===""&&(this.fail("unbound namespace prefix: ".concat(JSON.stringify(kt),".")),Fe.uri=kt))}if(Be.length!==0){var gr=Fe.attributes,rn=new Set,zr=u(Be),vi;try{for(zr.s();!(vi=zr.n()).done;){var $r=vi.value,Dn=$r.name,cn=$r.prefix,yi=$r.local,hn=void 0,dn=void 0;cn===""?(hn=Dn==="xmlns"?M:"",dn=Dn):(hn=this.resolve(cn),hn===void 0&&(this.fail("unbound namespace prefix: ".concat(JSON.stringify(cn),".")),hn=cn),dn="{".concat(hn,"}").concat(yi)),rn.has(dn)&&this.fail("duplicate attribute: ".concat(dn,".")),rn.add(dn),$r.uri=hn,gr[Dn]=$r}}catch(Bn){zr.e(Bn)}finally{zr.f()}this.attribList=[]}}},{key:"processAttribsPlain",value:function(){var me=this.attribList,Be=this.tag.attributes,Fe=u(me),dt;try{for(Fe.s();!(dt=Fe.n()).done;){var kt=dt.value,Ht=kt.name,lr=kt.value;Be[Ht]!==void 0&&this.fail("duplicate attribute: ".concat(Ht,".")),Be[Ht]=lr}}catch(gr){Fe.e(gr)}finally{Fe.f()}this.attribList=[]}},{key:"openTag",value:function(){var me;this.processAttribs();var Be=this.tags,Fe=this.tag;Fe.isSelfClosing=!1,(me=this.openTagHandler)===null||me===void 0||me.call(this,Fe),Be.push(Fe),this.state=ge,this.name=""}},{key:"openSelfClosingTag",value:function(){var me,Be,Fe;this.processAttribs();var dt=this.tags,kt=this.tag;kt.isSelfClosing=!0,(me=this.openTagHandler)===null||me===void 0||me.call(this,kt),(Be=this.closeTagHandler)===null||Be===void 0||Be.call(this,kt);var Ht=this.tag=(Fe=dt[dt.length-1])!==null&&Fe!==void 0?Fe:null;Ht===null&&(this.closedRoot=!0),this.state=ge,this.name=""}},{key:"closeTag",value:function(){var me=this.tags,Be=this.name;if(this.state=ge,this.name="",Be===""){this.fail("weird empty close tag."),this.text+="";return}for(var Fe=this.closeTagHandler,dt=me.length;dt-- >0;){var kt=this.tag=me.pop();if(this.topNS=kt.ns,Fe==null||Fe(kt),kt.name===Be)break;this.fail("unexpected close tag.")}dt===0?this.closedRoot=!0:dt<0&&(this.fail("unmatched closing tag: ".concat(Be,".")),this.text+=""))}},{key:"parseEntity",value:function(me){if(me[0]!=="#"){var Be=this.ENTITIES[me];return Be!==void 0?Be:(this.fail(this.isName(me)?"undefined entity.":"disallowed character in entity name."),"&".concat(me,";"))}var Fe=NaN;return me[1]==="x"&&/^#x[0-9a-f]+$/i.test(me)?Fe=parseInt(me.slice(2),16):/^#[0-9]+$/.test(me)&&(Fe=parseInt(me.slice(1),10)),this.isChar(Fe)?String.fromCodePoint(Fe):(this.fail("malformed character entity."),"&".concat(me,";"))}},{key:"closed",get:function(){return this._closed}},{key:"position",get:function(){return this.chunkPosition+this.i}},{key:"columnIndex",get:function(){return this.position-this.positionAtNewLine}}]),yt}();_.SaxesParser=Ur},{"xmlchars/xml/1.0/ed5":541,"xmlchars/xml/1.1/ed2":542,"xmlchars/xmlns/1.0/ed3":543}],497:[function(e,S,_){(function(u){S.exports=typeof u=="function"?u:function(){var g=[].slice.apply(arguments);g.splice(1,0,0),setTimeout.apply(null,g)}}).call(this,e("timers").setImmediate)},{timers:521}],498:[function(e,S,_){var u=e("safe-buffer").Buffer;function y(g,b){this._block=u.alloc(g),this._finalSize=b,this._blockSize=g,this._len=0}y.prototype.update=function(g,b){typeof g=="string"&&(b=b||"utf8",g=u.from(g,b));for(var w=this._block,f=this._blockSize,v=g.length,h=this._len,l=0;l=this._finalSize&&(this._update(this._block),this._block.fill(0));var w=this._len*8;if(w<=4294967295)this._block.writeUInt32BE(w,this._blockSize-4);else{var f=(w&4294967295)>>>0,v=(w-f)/4294967296;this._block.writeUInt32BE(v,this._blockSize-8),this._block.writeUInt32BE(f,this._blockSize-4)}this._update(this._block);var h=this._hash();return g?h.toString(g):h},y.prototype._update=function(){throw new Error("_update must be implemented by subclass")},S.exports=y},{"safe-buffer":494}],499:[function(e,S,_){var u=S.exports=function(g){g=g.toLowerCase();var b=u[g];if(!b)throw new Error(g+" is not supported (we accept pull requests)");return new b};u.sha=e("./sha"),u.sha1=e("./sha1"),u.sha224=e("./sha224"),u.sha256=e("./sha256"),u.sha384=e("./sha384"),u.sha512=e("./sha512")},{"./sha":500,"./sha1":501,"./sha224":502,"./sha256":503,"./sha384":504,"./sha512":505}],500:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[1518500249,1859775393,-1894007588,-899497514],w=new Array(80);function f(){this.init(),this._w=w,y.call(this,64,56)}u(f,y),f.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function v(d){return d<<5|d>>>27}function h(d){return d<<30|d>>>2}function l(d,s,m,c){return d===0?s&m|~s&c:d===2?s&m|s&c|m&c:s^m^c}f.prototype._update=function(d){for(var s=this._w,m=this._a|0,c=this._b|0,a=this._c|0,r=this._d|0,t=this._e|0,i=0;i<16;++i)s[i]=d.readInt32BE(i*4);for(;i<80;++i)s[i]=s[i-3]^s[i-8]^s[i-14]^s[i-16];for(var n=0;n<80;++n){var o=~~(n/20),p=v(m)+l(o,c,a,r)+t+s[n]+b[o]|0;t=r,r=a,a=h(c),c=m,m=p}this._a=m+this._a|0,this._b=c+this._b|0,this._c=a+this._c|0,this._d=r+this._d|0,this._e=t+this._e|0},f.prototype._hash=function(){var d=g.allocUnsafe(20);return d.writeInt32BE(this._a|0,0),d.writeInt32BE(this._b|0,4),d.writeInt32BE(this._c|0,8),d.writeInt32BE(this._d|0,12),d.writeInt32BE(this._e|0,16),d},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],501:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[1518500249,1859775393,-1894007588,-899497514],w=new Array(80);function f(){this.init(),this._w=w,y.call(this,64,56)}u(f,y),f.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function v(s){return s<<1|s>>>31}function h(s){return s<<5|s>>>27}function l(s){return s<<30|s>>>2}function d(s,m,c,a){return s===0?m&c|~m&a:s===2?m&c|m&a|c&a:m^c^a}f.prototype._update=function(s){for(var m=this._w,c=this._a|0,a=this._b|0,r=this._c|0,t=this._d|0,i=this._e|0,n=0;n<16;++n)m[n]=s.readInt32BE(n*4);for(;n<80;++n)m[n]=v(m[n-3]^m[n-8]^m[n-14]^m[n-16]);for(var o=0;o<80;++o){var p=~~(o/20),E=h(c)+d(p,a,r,t)+i+m[o]+b[p]|0;i=t,t=r,r=l(a),a=c,c=E}this._a=c+this._a|0,this._b=a+this._b|0,this._c=r+this._c|0,this._d=t+this._d|0,this._e=i+this._e|0},f.prototype._hash=function(){var s=g.allocUnsafe(20);return s.writeInt32BE(this._a|0,0),s.writeInt32BE(this._b|0,4),s.writeInt32BE(this._c|0,8),s.writeInt32BE(this._d|0,12),s.writeInt32BE(this._e|0,16),s},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],502:[function(e,S,_){var u=e("inherits"),y=e("./sha256"),g=e("./hash"),b=e("safe-buffer").Buffer,w=new Array(64);function f(){this.init(),this._w=w,g.call(this,64,56)}u(f,y),f.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},f.prototype._hash=function(){var v=b.allocUnsafe(28);return v.writeInt32BE(this._a,0),v.writeInt32BE(this._b,4),v.writeInt32BE(this._c,8),v.writeInt32BE(this._d,12),v.writeInt32BE(this._e,16),v.writeInt32BE(this._f,20),v.writeInt32BE(this._g,24),v},S.exports=f},{"./hash":498,"./sha256":503,inherits:387,"safe-buffer":494}],503:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[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],w=new Array(64);function f(){this.init(),this._w=w,y.call(this,64,56)}u(f,y),f.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};function v(c,a,r){return r^c&(a^r)}function h(c,a,r){return c&a|r&(c|a)}function l(c){return(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10)}function d(c){return(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7)}function s(c){return(c>>>7|c<<25)^(c>>>18|c<<14)^c>>>3}function m(c){return(c>>>17|c<<15)^(c>>>19|c<<13)^c>>>10}f.prototype._update=function(c){for(var a=this._w,r=this._a|0,t=this._b|0,i=this._c|0,n=this._d|0,o=this._e|0,p=this._f|0,E=this._g|0,P=this._h|0,D=0;D<16;++D)a[D]=c.readInt32BE(D*4);for(;D<64;++D)a[D]=m(a[D-2])+a[D-7]+s(a[D-15])+a[D-16]|0;for(var z=0;z<64;++z){var B=P+d(o)+v(o,p,E)+b[z]+a[z]|0,M=l(r)+h(r,t,i)|0;P=E,E=p,p=o,o=n+B|0,n=i,i=t,t=r,r=B+M|0}this._a=r+this._a|0,this._b=t+this._b|0,this._c=i+this._c|0,this._d=n+this._d|0,this._e=o+this._e|0,this._f=p+this._f|0,this._g=E+this._g|0,this._h=P+this._h|0},f.prototype._hash=function(){var c=g.allocUnsafe(32);return c.writeInt32BE(this._a,0),c.writeInt32BE(this._b,4),c.writeInt32BE(this._c,8),c.writeInt32BE(this._d,12),c.writeInt32BE(this._e,16),c.writeInt32BE(this._f,20),c.writeInt32BE(this._g,24),c.writeInt32BE(this._h,28),c},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],504:[function(e,S,_){var u=e("inherits"),y=e("./sha512"),g=e("./hash"),b=e("safe-buffer").Buffer,w=new Array(160);function f(){this.init(),this._w=w,g.call(this,128,112)}u(f,y),f.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},f.prototype._hash=function(){var v=b.allocUnsafe(48);function h(l,d,s){v.writeInt32BE(l,s),v.writeInt32BE(d,s+4)}return h(this._ah,this._al,0),h(this._bh,this._bl,8),h(this._ch,this._cl,16),h(this._dh,this._dl,24),h(this._eh,this._el,32),h(this._fh,this._fl,40),v},S.exports=f},{"./hash":498,"./sha512":505,inherits:387,"safe-buffer":494}],505:[function(e,S,_){var u=e("inherits"),y=e("./hash"),g=e("safe-buffer").Buffer,b=[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],w=new Array(160);function f(){this.init(),this._w=w,y.call(this,128,112)}u(f,y),f.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};function v(t,i,n){return n^t&(i^n)}function h(t,i,n){return t&i|n&(t|i)}function l(t,i){return(t>>>28|i<<4)^(i>>>2|t<<30)^(i>>>7|t<<25)}function d(t,i){return(t>>>14|i<<18)^(t>>>18|i<<14)^(i>>>9|t<<23)}function s(t,i){return(t>>>1|i<<31)^(t>>>8|i<<24)^t>>>7}function m(t,i){return(t>>>1|i<<31)^(t>>>8|i<<24)^(t>>>7|i<<25)}function c(t,i){return(t>>>19|i<<13)^(i>>>29|t<<3)^t>>>6}function a(t,i){return(t>>>19|i<<13)^(i>>>29|t<<3)^(t>>>6|i<<26)}function r(t,i){return t>>>0>>0?1:0}f.prototype._update=function(t){for(var i=this._w,n=this._ah|0,o=this._bh|0,p=this._ch|0,E=this._dh|0,P=this._eh|0,D=this._fh|0,z=this._gh|0,B=this._hh|0,M=this._al|0,I=this._bl|0,T=this._cl|0,C=this._dl|0,O=this._el|0,A=this._fl|0,L=this._gl|0,U=this._hl|0,W=0;W<32;W+=2)i[W]=t.readInt32BE(W*4),i[W+1]=t.readInt32BE(W*4+4);for(;W<160;W+=2){var $=i[W-30],N=i[W-15*2+1],F=s($,N),j=m(N,$);$=i[W-2*2],N=i[W-2*2+1];var V=c($,N),te=a(N,$),re=i[W-7*2],le=i[W-7*2+1],ye=i[W-16*2],ge=i[W-16*2+1],ne=j+le|0,J=F+re+r(ne,j)|0;ne=ne+te|0,J=J+V+r(ne,te)|0,ne=ne+ge|0,J=J+ye+r(ne,ge)|0,i[W]=J,i[W+1]=ne}for(var Q=0;Q<160;Q+=2){J=i[Q],ne=i[Q+1];var he=h(n,o,p),xe=h(M,I,T),ie=l(n,M),se=l(M,n),Ce=d(P,O),q=d(O,P),G=b[Q],Y=b[Q+1],fe=v(P,D,z),we=v(O,A,L),_e=U+q|0,je=B+Ce+r(_e,U)|0;_e=_e+we|0,je=je+fe+r(_e,we)|0,_e=_e+Y|0,je=je+G+r(_e,Y)|0,_e=_e+ne|0,je=je+J+r(_e,ne)|0;var Ye=se+xe|0,nt=ie+he+r(Ye,se)|0;B=z,U=L,z=D,L=A,D=P,A=O,O=C+_e|0,P=E+je+r(O,C)|0,E=p,C=T,p=o,T=I,o=n,I=M,M=_e+Ye|0,n=je+nt+r(M,_e)|0}this._al=this._al+M|0,this._bl=this._bl+I|0,this._cl=this._cl+T|0,this._dl=this._dl+C|0,this._el=this._el+O|0,this._fl=this._fl+A|0,this._gl=this._gl+L|0,this._hl=this._hl+U|0,this._ah=this._ah+n+r(this._al,M)|0,this._bh=this._bh+o+r(this._bl,I)|0,this._ch=this._ch+p+r(this._cl,T)|0,this._dh=this._dh+E+r(this._dl,C)|0,this._eh=this._eh+P+r(this._el,O)|0,this._fh=this._fh+D+r(this._fl,A)|0,this._gh=this._gh+z+r(this._gl,L)|0,this._hh=this._hh+B+r(this._hl,U)|0},f.prototype._hash=function(){var t=g.allocUnsafe(64);function i(n,o,p){t.writeInt32BE(n,p),t.writeInt32BE(o,p+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),t},S.exports=f},{"./hash":498,inherits:387,"safe-buffer":494}],506:[function(e,S,_){S.exports=g;var u=e("events").EventEmitter,y=e("inherits");y(g,u),g.Readable=e("readable-stream/readable.js"),g.Writable=e("readable-stream/writable.js"),g.Duplex=e("readable-stream/duplex.js"),g.Transform=e("readable-stream/transform.js"),g.PassThrough=e("readable-stream/passthrough.js"),g.Stream=g;function g(){u.call(this)}g.prototype.pipe=function(b,w){var f=this;function v(a){b.writable&&b.write(a)===!1&&f.pause&&f.pause()}f.on("data",v);function h(){f.readable&&f.resume&&f.resume()}b.on("drain",h),!b._isStdio&&(!w||w.end!==!1)&&(f.on("end",d),f.on("close",s));var l=!1;function d(){l||(l=!0,b.end())}function s(){l||(l=!0,typeof b.destroy=="function"&&b.destroy())}function m(a){if(c(),u.listenerCount(this,"error")===0)throw a}f.on("error",m),b.on("error",m);function c(){f.removeListener("data",v),b.removeListener("drain",h),f.removeListener("end",d),f.removeListener("close",s),f.removeListener("error",m),b.removeListener("error",m),f.removeListener("end",c),f.removeListener("close",c),b.removeListener("close",c)}return f.on("end",c),f.on("close",c),b.on("close",c),b.emit("pipe",f),b}},{events:367,inherits:387,"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}],507:[function(e,S,_){S.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":508}],508:[function(e,S,_){var u=e("process-nextick-args"),y=Object.keys||function(m){var c=[];for(var a in m)c.push(a);return c};S.exports=l;var g=Object.create(e("core-util-is"));g.inherits=e("inherits");var b=e("./_stream_readable"),w=e("./_stream_writable");g.inherits(l,b);for(var f=y(w.prototype),v=0;v0?(typeof Q!="string"&&!se.objectMode&&Object.getPrototypeOf(Q)!==h.prototype&&(Q=d(Q)),xe?se.endEmitted?J.emit("error",new Error("stream.unshift() after end event")):D(J,se,Q,!0):se.ended?J.emit("error",new Error("stream.push() after EOF")):(se.reading=!1,se.decoder&&!he?(Q=se.decoder.write(Q),se.objectMode||Q.length!==0?D(J,se,Q,!1):L(J,se)):D(J,se,Q,!1))):xe||(se.reading=!1)}return B(se)}function D(J,Q,he,xe){Q.flowing&&Q.length===0&&!Q.sync?(J.emit("data",he),J.read(0)):(Q.length+=Q.objectMode?1:he.length,xe?Q.buffer.unshift(he):Q.buffer.push(he),Q.needReadable&&O(J)),L(J,Q)}function z(J,Q){var he;return!s(Q)&&typeof Q!="string"&&Q!==void 0&&!J.objectMode&&(he=new TypeError("Invalid non-string/buffer chunk")),he}function B(J){return!J.ended&&(J.needReadable||J.length=M?J=M:(J--,J|=J>>>1,J|=J>>>2,J|=J>>>4,J|=J>>>8,J|=J>>>16,J++),J}function T(J,Q){return J<=0||Q.length===0&&Q.ended?0:Q.objectMode?1:J!==J?Q.flowing&&Q.length?Q.buffer.head.data.length:Q.length:(J>Q.highWaterMark&&(Q.highWaterMark=I(J)),J<=Q.length?J:Q.ended?Q.length:(Q.needReadable=!0,0))}E.prototype.read=function(J){a("read",J),J=parseInt(J,10);var Q=this._readableState,he=J;if(J!==0&&(Q.emittedReadable=!1),J===0&&Q.needReadable&&(Q.length>=Q.highWaterMark||Q.ended))return a("read: emitReadable",Q.length,Q.ended),Q.length===0&&Q.ended?ye(this):O(this),null;if(J=T(J,Q),J===0&&Q.ended)return Q.length===0&&ye(this),null;var xe=Q.needReadable;a("need readable",xe),(Q.length===0||Q.length-J0?ie=V(J,Q):ie=null,ie===null?(Q.needReadable=!0,J=0):Q.length-=J,Q.length===0&&(Q.ended||(Q.needReadable=!0),he!==J&&Q.ended&&ye(this)),ie!==null&&this.emit("data",ie),ie};function C(J,Q){if(!Q.ended){if(Q.decoder){var he=Q.decoder.end();he&&he.length&&(Q.buffer.push(he),Q.length+=Q.objectMode?1:he.length)}Q.ended=!0,O(J)}}function O(J){var Q=J._readableState;Q.needReadable=!1,Q.emittedReadable||(a("emitReadable",Q.flowing),Q.emittedReadable=!0,Q.sync?g.nextTick(A,J):A(J))}function A(J){a("emit readable"),J.emit("readable"),j(J)}function L(J,Q){Q.readingMore||(Q.readingMore=!0,g.nextTick(U,J,Q))}function U(J,Q){for(var he=Q.length;!Q.reading&&!Q.flowing&&!Q.ended&&Q.length1&&ne(xe.pipes,J)!==-1)&&!Y&&(a("false write response, pause",he._readableState.awaitDrain),he._readableState.awaitDrain++,we=!0),he.pause())}function je(ot){a("onerror",ot),ut(),J.removeListener("error",je),f(J,"error")===0&&J.emit("error",ot)}o(J,"error",je);function Ye(){J.removeListener("finish",nt),ut()}J.once("close",Ye);function nt(){a("onfinish"),J.removeListener("close",Ye),ut()}J.once("finish",nt);function ut(){a("unpipe"),he.unpipe(J)}return J.emit("pipe",he),xe.flowing||(a("pipe resume"),he.resume()),J};function W(J){return function(){var Q=J._readableState;a("pipeOnDrain",Q.awaitDrain),Q.awaitDrain&&Q.awaitDrain--,Q.awaitDrain===0&&f(J,"data")&&(Q.flowing=!0,j(J))}}E.prototype.unpipe=function(J){var Q=this._readableState,he={hasUnpiped:!1};if(Q.pipesCount===0)return this;if(Q.pipesCount===1)return J&&J!==Q.pipes?this:(J||(J=Q.pipes),Q.pipes=null,Q.pipesCount=0,Q.flowing=!1,J&&J.emit("unpipe",this,he),this);if(!J){var xe=Q.pipes,ie=Q.pipesCount;Q.pipes=null,Q.pipesCount=0,Q.flowing=!1;for(var se=0;se=Q.length?(Q.decoder?he=Q.buffer.join(""):Q.buffer.length===1?he=Q.buffer.head.data:he=Q.buffer.concat(Q.length),Q.buffer.clear()):he=te(J,Q.buffer,Q.decoder),he}function te(J,Q,he){var xe;return Jse.length?se.length:J;if(Ce===se.length?ie+=se:ie+=se.slice(0,J),J-=Ce,J===0){Ce===se.length?(++xe,he.next?Q.head=he.next:Q.head=Q.tail=null):(Q.head=he,he.data=se.slice(Ce));break}++xe}return Q.length-=xe,ie}function le(J,Q){var he=h.allocUnsafe(J),xe=Q.head,ie=1;for(xe.data.copy(he),J-=xe.data.length;xe=xe.next;){var se=xe.data,Ce=J>se.length?se.length:J;if(se.copy(he,he.length-J,0,Ce),J-=Ce,J===0){Ce===se.length?(++ie,xe.next?Q.head=xe.next:Q.head=Q.tail=null):(Q.head=xe,xe.data=se.slice(Ce));break}++ie}return Q.length-=ie,he}function ye(J){var Q=J._readableState;if(Q.length>0)throw new Error('"endReadable()" called on non-empty stream');Q.endEmitted||(Q.ended=!0,g.nextTick(ge,Q,J))}function ge(J,Q){!J.endEmitted&&J.length===0&&(J.endEmitted=!0,Q.readable=!1,Q.emit("end"))}function ne(J,Q){for(var he=0,xe=J.length;he-1?g:b.nextTick,v;o.WritableState=i;var h=Object.create(e("core-util-is"));h.inherits=e("inherits");var l={deprecate:e("util-deprecate")},d=e("./internal/streams/stream"),s=e("safe-buffer").Buffer,m=y.Uint8Array||function(){};function c(F){return s.from(F)}function a(F){return s.isBuffer(F)||F instanceof m}var r=e("./internal/streams/destroy");h.inherits(o,d);function t(){}function i(F,j){v=v||e("./_stream_duplex"),F=F||{};var V=j instanceof v;this.objectMode=!!F.objectMode,V&&(this.objectMode=this.objectMode||!!F.writableObjectMode);var te=F.highWaterMark,re=F.writableHighWaterMark,le=this.objectMode?16:16*1024;te||te===0?this.highWaterMark=te:V&&(re||re===0)?this.highWaterMark=re:this.highWaterMark=le,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 ye=F.decodeStrings===!1;this.decodeStrings=!ye,this.defaultEncoding=F.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ge){I(j,ge)},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 w(this)}i.prototype.getBuffer=function(){for(var j=this.bufferedRequest,V=[];j;)V.push(j),j=j.next;return V},function(){try{Object.defineProperty(i.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var n;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(o,Symbol.hasInstance,{value:function(j){return n.call(this,j)?!0:this!==o?!1:j&&j._writableState instanceof i}})):n=function(j){return j instanceof this};function o(F){if(v=v||e("./_stream_duplex"),!n.call(o,this)&&!(this instanceof v))return new o(F);this._writableState=new i(F,this),this.writable=!0,F&&(typeof F.write=="function"&&(this._write=F.write),typeof F.writev=="function"&&(this._writev=F.writev),typeof F.destroy=="function"&&(this._destroy=F.destroy),typeof F.final=="function"&&(this._final=F.final)),d.call(this)}o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function p(F,j){var V=new Error("write after end");F.emit("error",V),b.nextTick(j,V)}function E(F,j,V,te){var re=!0,le=!1;return V===null?le=new TypeError("May not write null values to stream"):typeof V!="string"&&V!==void 0&&!j.objectMode&&(le=new TypeError("Invalid non-string/buffer chunk")),le&&(F.emit("error",le),b.nextTick(te,le),re=!1),re}o.prototype.write=function(F,j,V){var te=this._writableState,re=!1,le=!te.objectMode&&a(F);return le&&!s.isBuffer(F)&&(F=c(F)),typeof j=="function"&&(V=j,j=null),le?j="buffer":j||(j=te.defaultEncoding),typeof V!="function"&&(V=t),te.ended?p(this,V):(le||E(this,te,F,V))&&(te.pendingcb++,re=D(this,te,le,F,j,V)),re},o.prototype.cork=function(){var F=this._writableState;F.corked++},o.prototype.uncork=function(){var F=this._writableState;F.corked&&(F.corked--,!F.writing&&!F.corked&&!F.finished&&!F.bufferProcessing&&F.bufferedRequest&&O(this,F))},o.prototype.setDefaultEncoding=function(j){if(typeof j=="string"&&(j=j.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((j+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+j);return this._writableState.defaultEncoding=j,this};function P(F,j,V){return!F.objectMode&&F.decodeStrings!==!1&&typeof j=="string"&&(j=s.from(j,V)),j}Object.defineProperty(o.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function D(F,j,V,te,re,le){if(!V){var ye=P(j,te,re);te!==ye&&(V=!0,re="buffer",te=ye)}var ge=j.objectMode?1:te.length;j.length+=ge;var ne=j.length0?this.tail.next=h:this.head=h,this.tail=h,++this.length},w.prototype.unshift=function(v){var h={data:v,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length},w.prototype.shift=function(){if(this.length!==0){var v=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,v}},w.prototype.clear=function(){this.head=this.tail=null,this.length=0},w.prototype.join=function(v){if(this.length===0)return"";for(var h=this.head,l=""+h.data;h=h.next;)l+=v+h.data;return l},w.prototype.concat=function(v){if(this.length===0)return y.alloc(0);if(this.length===1)return this.head.data;for(var h=y.allocUnsafe(v>>>0),l=this.head,d=0;l;)b(l.data,h,d),d+=l.data.length,l=l.next;return h},w}(),g&&g.inspect&&g.inspect.custom&&(S.exports.prototype[g.inspect.custom]=function(){var w=g.inspect({length:this.length});return this.constructor.name+" "+w})},{"safe-buffer":494,util:185}],514:[function(e,S,_){var u=e("process-nextick-args");function y(w,f){var v=this,h=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return h||l?(f?f(w):w&&(!this._writableState||!this._writableState.errorEmitted)&&u.nextTick(b,this,w),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(w||null,function(d){!f&&d?(u.nextTick(b,v,d),v._writableState&&(v._writableState.errorEmitted=!0)):f&&f(d)}),this)}function g(){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.finished=!1,this._writableState.errorEmitted=!1)}function b(w,f){w.emit("error",f)}S.exports={destroy:y,undestroy:g}},{"process-nextick-args":466}],515:[function(e,S,_){arguments[4][490][0].apply(_,arguments)},{dup:490,events:367}],516:[function(e,S,_){S.exports=e("./readable").PassThrough},{"./readable":517}],517:[function(e,S,_){_=S.exports=e("./lib/_stream_readable.js"),_.Stream=_,_.Readable=_,_.Writable=e("./lib/_stream_writable.js"),_.Duplex=e("./lib/_stream_duplex.js"),_.Transform=e("./lib/_stream_transform.js"),_.PassThrough=e("./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(e,S,_){S.exports=e("./readable").Transform},{"./readable":517}],519:[function(e,S,_){S.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":512}],520:[function(e,S,_){var u=e("safe-buffer").Buffer,y=u.isEncoding||function(n){switch(n=""+n,n&&n.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 g(n){if(!n)return"utf8";for(var o;;)switch(n){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 n;default:if(o)return;n=(""+n).toLowerCase(),o=!0}}function b(n){var o=g(n);if(typeof o!="string"&&(u.isEncoding===y||!y(n)))throw new Error("Unknown encoding: "+n);return o||n}_.StringDecoder=w;function w(n){this.encoding=b(n);var o;switch(this.encoding){case"utf16le":this.text=m,this.end=c,o=4;break;case"utf8":this.fillLast=l,o=4;break;case"base64":this.text=a,this.end=r,o=3;break;default:this.write=t,this.end=i;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=u.allocUnsafe(o)}w.prototype.write=function(n){if(n.length===0)return"";var o,p;if(this.lastNeed){if(o=this.fillLast(n),o===void 0)return"";p=this.lastNeed,this.lastNeed=0}else p=0;return p>5===6?2:n>>4===14?3:n>>3===30?4:n>>6===2?-1:-2}function v(n,o,p){var E=o.length-1;if(E=0?(P>0&&(n.lastNeed=P-1),P):--E=0?(P>0&&(n.lastNeed=P-2),P):--E=0?(P>0&&(P===2?P=0:n.lastNeed=P-3),P):0))}function h(n,o,p){if((o[0]&192)!==128)return n.lastNeed=0,"�";if(n.lastNeed>1&&o.length>1){if((o[1]&192)!==128)return n.lastNeed=1,"�";if(n.lastNeed>2&&o.length>2&&(o[2]&192)!==128)return n.lastNeed=2,"�"}}function l(n){var o=this.lastTotal-this.lastNeed,p=h(this,n);if(p!==void 0)return p;if(this.lastNeed<=n.length)return n.copy(this.lastChar,o,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);n.copy(this.lastChar,o,0,n.length),this.lastNeed-=n.length}function d(n,o){var p=v(this,n,o);if(!this.lastNeed)return n.toString("utf8",o);this.lastTotal=p;var E=n.length-(p-this.lastNeed);return n.copy(this.lastChar,0,E),n.toString("utf8",o,E)}function s(n){var o=n&&n.length?this.write(n):"";return this.lastNeed?o+"�":o}function m(n,o){if((n.length-o)%2===0){var p=n.toString("utf16le",o);if(p){var E=p.charCodeAt(p.length-1);if(E>=55296&&E<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=n[n.length-2],this.lastChar[1]=n[n.length-1],p.slice(0,-1)}return p}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=n[n.length-1],n.toString("utf16le",o,n.length-1)}function c(n){var o=n&&n.length?this.write(n):"";if(this.lastNeed){var p=this.lastTotal-this.lastNeed;return o+this.lastChar.toString("utf16le",0,p)}return o}function a(n,o){var p=(n.length-o)%3;return p===0?n.toString("base64",o):(this.lastNeed=3-p,this.lastTotal=3,p===1?this.lastChar[0]=n[n.length-1]:(this.lastChar[0]=n[n.length-2],this.lastChar[1]=n[n.length-1]),n.toString("base64",o,n.length-p))}function r(n){var o=n&&n.length?this.write(n):"";return this.lastNeed?o+this.lastChar.toString("base64",0,3-this.lastNeed):o}function t(n){return n.toString(this.encoding)}function i(n){return n&&n.length?this.write(n):""}},{"safe-buffer":494}],521:[function(e,S,_){(function(u,y){var g=e("process/browser.js").nextTick,b=Function.prototype.apply,w=Array.prototype.slice,f={},v=0;_.setTimeout=function(){return new h(b.call(setTimeout,window,arguments),clearTimeout)},_.setInterval=function(){return new h(b.call(setInterval,window,arguments),clearInterval)},_.clearTimeout=_.clearInterval=function(l){l.close()};function h(l,d){this._id=l,this._clearFn=d}h.prototype.unref=h.prototype.ref=function(){},h.prototype.close=function(){this._clearFn.call(window,this._id)},_.enroll=function(l,d){clearTimeout(l._idleTimeoutId),l._idleTimeout=d},_.unenroll=function(l){clearTimeout(l._idleTimeoutId),l._idleTimeout=-1},_._unrefActive=_.active=function(l){clearTimeout(l._idleTimeoutId);var d=l._idleTimeout;d>=0&&(l._idleTimeoutId=setTimeout(function(){l._onTimeout&&l._onTimeout()},d))},_.setImmediate=typeof u=="function"?u:function(l){var d=v++,s=arguments.length<2?!1:w.call(arguments,1);return f[d]=!0,g(function(){f[d]&&(s?l.apply(null,s):l.call(null),_.clearImmediate(d))}),d},_.clearImmediate=typeof y=="function"?y:function(l){delete f[l]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":467,timers:521}],522:[function(e,S,_){(function(u){S.exports=y;function y(b,w){if(g("noDeprecation"))return b;var f=!1;function v(){if(!f){if(g("throwDeprecation"))throw new Error(w);g("traceDeprecation")?console.trace(w):console.warn(w),f=!0}return b.apply(this,arguments)}return v}function g(b){try{if(!u.localStorage)return!1}catch{return!1}var w=u.localStorage[b];return w==null?!1:String(w).toLowerCase()==="true"}}).call(this,typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],523:[function(e,S,_){typeof Object.create=="function"?S.exports=function(y,g){y.super_=g,y.prototype=Object.create(g.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}})}:S.exports=function(y,g){y.super_=g;var b=function(){};b.prototype=g.prototype,y.prototype=new b,y.prototype.constructor=y}},{}],524:[function(e,S,_){function u(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(b){return typeof b}:u=function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},u(y)}S.exports=function(g){return g&&u(g)==="object"&&typeof g.copy=="function"&&typeof g.fill=="function"&&typeof g.readUInt8=="function"}},{}],525:[function(e,S,_){(function(u,y){function g(N){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?g=function(j){return typeof j}:g=function(j){return j&&typeof Symbol=="function"&&j.constructor===Symbol&&j!==Symbol.prototype?"symbol":typeof j},g(N)}var b=/%[sdj%]/g;_.format=function(N){if(!P(N)){for(var F=[],j=0;j=te)return ye;switch(ye){case"%s":return String(V[j++]);case"%d":return Number(V[j++]);case"%j":try{return JSON.stringify(V[j++])}catch{return"[Circular]"}default:return ye}}),le=V[j];j=3&&(j.depth=arguments[2]),arguments.length>=4&&(j.colors=arguments[3]),n(F)?j.showHidden=F:F&&_._extend(j,F),z(j.showHidden)&&(j.showHidden=!1),z(j.depth)&&(j.depth=2),z(j.colors)&&(j.colors=!1),z(j.customInspect)&&(j.customInspect=!0),j.colors&&(j.stylize=h),s(j,N,j.depth)}_.inspect=v,v.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]},v.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function h(N,F){var j=v.styles[F];return j?"\x1B["+v.colors[j][0]+"m"+N+"\x1B["+v.colors[j][1]+"m":N}function l(N,F){return N}function d(N){var F={};return N.forEach(function(j,V){F[j]=!0}),F}function s(N,F,j){if(N.customInspect&&F&&C(F.inspect)&&F.inspect!==_.inspect&&!(F.constructor&&F.constructor.prototype===F)){var V=F.inspect(j,N);return P(V)||(V=s(N,V,j)),V}var te=m(N,F);if(te)return te;var re=Object.keys(F),le=d(re);if(N.showHidden&&(re=Object.getOwnPropertyNames(F)),T(F)&&(re.indexOf("message")>=0||re.indexOf("description")>=0))return c(F);if(re.length===0){if(C(F)){var ye=F.name?": "+F.name:"";return N.stylize("[Function"+ye+"]","special")}if(B(F))return N.stylize(RegExp.prototype.toString.call(F),"regexp");if(I(F))return N.stylize(Date.prototype.toString.call(F),"date");if(T(F))return c(F)}var ge="",ne=!1,J=["{","}"];if(i(F)&&(ne=!0,J=["[","]"]),C(F)){var Q=F.name?": "+F.name:"";ge=" [Function"+Q+"]"}if(B(F)&&(ge=" "+RegExp.prototype.toString.call(F)),I(F)&&(ge=" "+Date.prototype.toUTCString.call(F)),T(F)&&(ge=" "+c(F)),re.length===0&&(!ne||F.length==0))return J[0]+ge+J[1];if(j<0)return B(F)?N.stylize(RegExp.prototype.toString.call(F),"regexp"):N.stylize("[Object]","special");N.seen.push(F);var he;return ne?he=a(N,F,j,le,re):he=re.map(function(xe){return r(N,F,j,le,xe,ne)}),N.seen.pop(),t(he,ge,J)}function m(N,F){if(z(F))return N.stylize("undefined","undefined");if(P(F)){var j="'"+JSON.stringify(F).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return N.stylize(j,"string")}if(E(F))return N.stylize(""+F,"number");if(n(F))return N.stylize(""+F,"boolean");if(o(F))return N.stylize("null","null")}function c(N){return"["+Error.prototype.toString.call(N)+"]"}function a(N,F,j,V,te){for(var re=[],le=0,ye=F.length;le-1&&(re?ye=ye.split(` +`).map(function(ne){return" "+ne}).join(` `).substr(2):ye=` `+ye.split(` -`).map(function(oe){return" "+oe}).join(` -`))):ye=N.stylize("[Circular]","special")),z(ce)){if(ee&&re.match(/^\d+$/))return ye;ce=JSON.stringify(""+re),ce.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(ce=ce.substr(1,ce.length-2),ce=N.stylize(ce,"name")):(ce=ce.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),ce=N.stylize(ce,"string"))}return ce+": "+ye}function t(N,j,F){var V=N.reduce(function(re,ee){return ee.indexOf(` -`)>=0,re+ee.replace(/\u001b\[\d\d?m/g,"").length+1},0);return V>60?F[0]+(j===""?"":j+` +`).map(function(ne){return" "+ne}).join(` +`))):ye=N.stylize("[Circular]","special")),z(le)){if(re&&te.match(/^\d+$/))return ye;le=JSON.stringify(""+te),le.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(le=le.substr(1,le.length-2),le=N.stylize(le,"name")):(le=le.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),le=N.stylize(le,"string"))}return le+": "+ye}function t(N,F,j){var V=N.reduce(function(te,re){return re.indexOf(` +`)>=0,te+re.replace(/\u001b\[\d\d?m/g,"").length+1},0);return V>60?j[0]+(F===""?"":F+` `)+" "+N.join(`, - `)+" "+F[1]:F[0]+j+" "+N.join(", ")+" "+F[1]}function i(N){return Array.isArray(N)}_.isArray=i;function n(N){return typeof N=="boolean"}_.isBoolean=n;function o(N){return N===null}_.isNull=o;function p(N){return N==null}_.isNullOrUndefined=p;function O(N){return typeof N=="number"}_.isNumber=O;function P(N){return typeof N=="string"}_.isString=P;function B(N){return g(N)==="symbol"}_.isSymbol=B;function z(N){return N===void 0}_.isUndefined=z;function D(N){return M(N)&&A(N)==="[object RegExp]"}_.isRegExp=D;function M(N){return g(N)==="object"&&N!==null}_.isObject=M;function I(N){return M(N)&&A(N)==="[object Date]"}_.isDate=I;function T(N){return M(N)&&(A(N)==="[object Error]"||N instanceof Error)}_.isError=T;function C(N){return typeof N=="function"}_.isFunction=C;function E(N){return N===null||typeof N=="boolean"||typeof N=="number"||typeof N=="string"||g(N)==="symbol"||typeof N>"u"}_.isPrimitive=E,_.isBuffer=e("./support/isBuffer");function A(N){return Object.prototype.toString.call(N)}function L(N){return N<10?"0"+N.toString(10):N.toString(10)}var $=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function W(){var N=new Date,j=[L(N.getHours()),L(N.getMinutes()),L(N.getSeconds())].join(":");return[N.getDate(),$[N.getMonth()],j].join(" ")}_.log=function(){console.log("%s - %s",W(),_.format.apply(_,arguments))},_.inherits=e("inherits"),_._extend=function(N,j){if(!j||!M(j))return N;for(var F=Object.keys(j),V=F.length;V--;)N[F[V]]=j[F[V]];return N};function U(N,j){return Object.prototype.hasOwnProperty.call(N,j)}}).call(this,e("_process"),typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{"./support/isBuffer":524,_process:467,inherits:523}],526:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),Object.defineProperty(_,"v1",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(_,"v3",{enumerable:!0,get:function(){return y.default}}),Object.defineProperty(_,"v4",{enumerable:!0,get:function(){return g.default}}),Object.defineProperty(_,"v5",{enumerable:!0,get:function(){return b.default}}),Object.defineProperty(_,"NIL",{enumerable:!0,get:function(){return w.default}}),Object.defineProperty(_,"version",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(_,"validate",{enumerable:!0,get:function(){return v.default}}),Object.defineProperty(_,"stringify",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(_,"parse",{enumerable:!0,get:function(){return l.default}});var u=d(e("./v1.js")),y=d(e("./v3.js")),g=d(e("./v4.js")),b=d(e("./v5.js")),w=d(e("./nil.js")),f=d(e("./version.js")),v=d(e("./validate.js")),h=d(e("./stringify.js")),l=d(e("./parse.js"));function d(s){return s&&s.__esModule?s:{default:s}}},{"./nil.js":528,"./parse.js":529,"./stringify.js":533,"./v1.js":534,"./v3.js":535,"./v4.js":537,"./v5.js":538,"./validate.js":539,"./version.js":540}],527:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;function u(a){if(typeof a=="string"){var r=unescape(encodeURIComponent(a));a=new Uint8Array(r.length);for(var t=0;t>5]>>>n%32&255,p=parseInt(i.charAt(o>>>4&15)+i.charAt(o&15),16);r.push(p)}return r}function g(a){return(a+64>>>9<<4)+14+1}function b(a,r){a[r>>5]|=128<>5]|=(a[i/8]&255)<>16)+(r>>16)+(t>>16);return i<<16|t&65535}function v(a,r){return a<>>32-r}function h(a,r,t,i,n,o){return f(v(f(f(r,a),f(i,o)),n),t)}function l(a,r,t,i,n,o,p){return h(r&t|~r&i,a,r,n,o,p)}function d(a,r,t,i,n,o,p){return h(r&i|t&~i,a,r,n,o,p)}function s(a,r,t,i,n,o,p){return h(r^t^i,a,r,n,o,p)}function m(a,r,t,i,n,o,p){return h(t^(r|~i),a,r,n,o,p)}var c=u;_.default=c},{}],528:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u="00000000-0000-0000-0000-000000000000";_.default=u},{}],529:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=y(e("./validate.js"));function y(w){return w&&w.__esModule?w:{default:w}}function g(w){if(!(0,u.default)(w))throw TypeError("Invalid UUID");var f,v=new Uint8Array(16);return v[0]=(f=parseInt(w.slice(0,8),16))>>>24,v[1]=f>>>16&255,v[2]=f>>>8&255,v[3]=f&255,v[4]=(f=parseInt(w.slice(9,13),16))>>>8,v[5]=f&255,v[6]=(f=parseInt(w.slice(14,18),16))>>>8,v[7]=f&255,v[8]=(f=parseInt(w.slice(19,23),16))>>>8,v[9]=f&255,v[10]=(f=parseInt(w.slice(24,36),16))/1099511627776&255,v[11]=f/4294967296&255,v[12]=f>>>24&255,v[13]=f>>>16&255,v[14]=f>>>8&255,v[15]=f&255,v}var b=g;_.default=b},{"./validate.js":539}],530:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=/^(?:[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;_.default=u},{}],531:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=g;var u=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),y=new Uint8Array(16);function g(){if(!u)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return u(y)}},{}],532:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;function u(w,f,v,h){switch(w){case 0:return f&v^~f&h;case 1:return f^v^h;case 2:return f&v^f&h^v&h;case 3:return f^v^h}}function y(w,f){return w<>>32-f}function g(w){var f=[1518500249,1859775393,2400959708,3395469782],v=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof w=="string"){var h=unescape(encodeURIComponent(w));w=[];for(var l=0;l>>0;z=B,B=P,P=y(O,30)>>>0,O=p,p=I}v[0]=v[0]+p>>>0,v[1]=v[1]+O>>>0,v[2]=v[2]+P>>>0,v[3]=v[3]+B>>>0,v[4]=v[4]+z>>>0}return[v[0]>>24&255,v[0]>>16&255,v[0]>>8&255,v[0]&255,v[1]>>24&255,v[1]>>16&255,v[1]>>8&255,v[1]&255,v[2]>>24&255,v[2]>>16&255,v[2]>>8&255,v[2]&255,v[3]>>24&255,v[3]>>16&255,v[3]>>8&255,v[3]&255,v[4]>>24&255,v[4]>>16&255,v[4]>>8&255,v[4]&255]}var b=g;_.default=b},{}],533:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=y(e("./validate.js"));function y(v){return v&&v.__esModule?v:{default:v}}for(var g=[],b=0;b<256;++b)g.push((b+256).toString(16).substr(1));function w(v){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,l=(g[v[h+0]]+g[v[h+1]]+g[v[h+2]]+g[v[h+3]]+"-"+g[v[h+4]]+g[v[h+5]]+"-"+g[v[h+6]]+g[v[h+7]]+"-"+g[v[h+8]]+g[v[h+9]]+"-"+g[v[h+10]]+g[v[h+11]]+g[v[h+12]]+g[v[h+13]]+g[v[h+14]]+g[v[h+15]]).toLowerCase();if(!(0,u.default)(l))throw TypeError("Stringified UUID is invalid");return l}var f=w;_.default=f},{"./validate.js":539}],534:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=g(e("./rng.js")),y=g(e("./stringify.js"));function g(d){return d&&d.__esModule?d:{default:d}}var b,w,f=0,v=0;function h(d,s,m){var c=s&&m||0,a=s||new Array(16);d=d||{};var r=d.node||b,t=d.clockseq!==void 0?d.clockseq:w;if(r==null||t==null){var i=d.random||(d.rng||u.default)();r==null&&(r=b=[i[0]|1,i[1],i[2],i[3],i[4],i[5]]),t==null&&(t=w=(i[6]<<8|i[7])&16383)}var n=d.msecs!==void 0?d.msecs:Date.now(),o=d.nsecs!==void 0?d.nsecs:v+1,p=n-f+(o-v)/1e4;if(p<0&&d.clockseq===void 0&&(t=t+1&16383),(p<0||n>f)&&d.nsecs===void 0&&(o=0),o>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f=n,v=o,w=t,n+=122192928e5;var O=((n&268435455)*1e4+o)%4294967296;a[c++]=O>>>24&255,a[c++]=O>>>16&255,a[c++]=O>>>8&255,a[c++]=O&255;var P=n/4294967296*1e4&268435455;a[c++]=P>>>8&255,a[c++]=P&255,a[c++]=P>>>24&15|16,a[c++]=P>>>16&255,a[c++]=t>>>8|128,a[c++]=t&255;for(var B=0;B<6;++B)a[c+B]=r[B];return s||(0,y.default)(a)}var l=h;_.default=l},{"./rng.js":531,"./stringify.js":533}],535:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=g(e("./v35.js")),y=g(e("./md5.js"));function g(f){return f&&f.__esModule?f:{default:f}}var b=(0,u.default)("v3",48,y.default),w=b;_.default=w},{"./md5.js":527,"./v35.js":536}],536:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=v,_.URL=_.DNS=void 0;var u=g(e("./stringify.js")),y=g(e("./parse.js"));function g(h){return h&&h.__esModule?h:{default:h}}function b(h){h=unescape(encodeURIComponent(h));for(var l=[],d=0;d"u"}_.isPrimitive=O,_.isBuffer=e("./support/isBuffer");function A(N){return Object.prototype.toString.call(N)}function L(N){return N<10?"0"+N.toString(10):N.toString(10)}var U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function W(){var N=new Date,F=[L(N.getHours()),L(N.getMinutes()),L(N.getSeconds())].join(":");return[N.getDate(),U[N.getMonth()],F].join(" ")}_.log=function(){console.log("%s - %s",W(),_.format.apply(_,arguments))},_.inherits=e("inherits"),_._extend=function(N,F){if(!F||!M(F))return N;for(var j=Object.keys(F),V=j.length;V--;)N[j[V]]=F[j[V]];return N};function $(N,F){return Object.prototype.hasOwnProperty.call(N,F)}}).call(this,e("_process"),typeof Wt<"u"?Wt:typeof self<"u"?self:typeof window<"u"?window:{})},{"./support/isBuffer":524,_process:467,inherits:523}],526:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),Object.defineProperty(_,"v1",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(_,"v3",{enumerable:!0,get:function(){return y.default}}),Object.defineProperty(_,"v4",{enumerable:!0,get:function(){return g.default}}),Object.defineProperty(_,"v5",{enumerable:!0,get:function(){return b.default}}),Object.defineProperty(_,"NIL",{enumerable:!0,get:function(){return w.default}}),Object.defineProperty(_,"version",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(_,"validate",{enumerable:!0,get:function(){return v.default}}),Object.defineProperty(_,"stringify",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(_,"parse",{enumerable:!0,get:function(){return l.default}});var u=d(e("./v1.js")),y=d(e("./v3.js")),g=d(e("./v4.js")),b=d(e("./v5.js")),w=d(e("./nil.js")),f=d(e("./version.js")),v=d(e("./validate.js")),h=d(e("./stringify.js")),l=d(e("./parse.js"));function d(s){return s&&s.__esModule?s:{default:s}}},{"./nil.js":528,"./parse.js":529,"./stringify.js":533,"./v1.js":534,"./v3.js":535,"./v4.js":537,"./v5.js":538,"./validate.js":539,"./version.js":540}],527:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;function u(a){if(typeof a=="string"){var r=unescape(encodeURIComponent(a));a=new Uint8Array(r.length);for(var t=0;t>5]>>>n%32&255,p=parseInt(i.charAt(o>>>4&15)+i.charAt(o&15),16);r.push(p)}return r}function g(a){return(a+64>>>9<<4)+14+1}function b(a,r){a[r>>5]|=128<>5]|=(a[i/8]&255)<>16)+(r>>16)+(t>>16);return i<<16|t&65535}function v(a,r){return a<>>32-r}function h(a,r,t,i,n,o){return f(v(f(f(r,a),f(i,o)),n),t)}function l(a,r,t,i,n,o,p){return h(r&t|~r&i,a,r,n,o,p)}function d(a,r,t,i,n,o,p){return h(r&i|t&~i,a,r,n,o,p)}function s(a,r,t,i,n,o,p){return h(r^t^i,a,r,n,o,p)}function m(a,r,t,i,n,o,p){return h(t^(r|~i),a,r,n,o,p)}var c=u;_.default=c},{}],528:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u="00000000-0000-0000-0000-000000000000";_.default=u},{}],529:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=y(e("./validate.js"));function y(w){return w&&w.__esModule?w:{default:w}}function g(w){if(!(0,u.default)(w))throw TypeError("Invalid UUID");var f,v=new Uint8Array(16);return v[0]=(f=parseInt(w.slice(0,8),16))>>>24,v[1]=f>>>16&255,v[2]=f>>>8&255,v[3]=f&255,v[4]=(f=parseInt(w.slice(9,13),16))>>>8,v[5]=f&255,v[6]=(f=parseInt(w.slice(14,18),16))>>>8,v[7]=f&255,v[8]=(f=parseInt(w.slice(19,23),16))>>>8,v[9]=f&255,v[10]=(f=parseInt(w.slice(24,36),16))/1099511627776&255,v[11]=f/4294967296&255,v[12]=f>>>24&255,v[13]=f>>>16&255,v[14]=f>>>8&255,v[15]=f&255,v}var b=g;_.default=b},{"./validate.js":539}],530:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=/^(?:[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;_.default=u},{}],531:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=g;var u=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),y=new Uint8Array(16);function g(){if(!u)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return u(y)}},{}],532:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;function u(w,f,v,h){switch(w){case 0:return f&v^~f&h;case 1:return f^v^h;case 2:return f&v^f&h^v&h;case 3:return f^v^h}}function y(w,f){return w<>>32-f}function g(w){var f=[1518500249,1859775393,2400959708,3395469782],v=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof w=="string"){var h=unescape(encodeURIComponent(w));w=[];for(var l=0;l>>0;z=D,D=P,P=y(E,30)>>>0,E=p,p=I}v[0]=v[0]+p>>>0,v[1]=v[1]+E>>>0,v[2]=v[2]+P>>>0,v[3]=v[3]+D>>>0,v[4]=v[4]+z>>>0}return[v[0]>>24&255,v[0]>>16&255,v[0]>>8&255,v[0]&255,v[1]>>24&255,v[1]>>16&255,v[1]>>8&255,v[1]&255,v[2]>>24&255,v[2]>>16&255,v[2]>>8&255,v[2]&255,v[3]>>24&255,v[3]>>16&255,v[3]>>8&255,v[3]&255,v[4]>>24&255,v[4]>>16&255,v[4]>>8&255,v[4]&255]}var b=g;_.default=b},{}],533:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=y(e("./validate.js"));function y(v){return v&&v.__esModule?v:{default:v}}for(var g=[],b=0;b<256;++b)g.push((b+256).toString(16).substr(1));function w(v){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,l=(g[v[h+0]]+g[v[h+1]]+g[v[h+2]]+g[v[h+3]]+"-"+g[v[h+4]]+g[v[h+5]]+"-"+g[v[h+6]]+g[v[h+7]]+"-"+g[v[h+8]]+g[v[h+9]]+"-"+g[v[h+10]]+g[v[h+11]]+g[v[h+12]]+g[v[h+13]]+g[v[h+14]]+g[v[h+15]]).toLowerCase();if(!(0,u.default)(l))throw TypeError("Stringified UUID is invalid");return l}var f=w;_.default=f},{"./validate.js":539}],534:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=g(e("./rng.js")),y=g(e("./stringify.js"));function g(d){return d&&d.__esModule?d:{default:d}}var b,w,f=0,v=0;function h(d,s,m){var c=s&&m||0,a=s||new Array(16);d=d||{};var r=d.node||b,t=d.clockseq!==void 0?d.clockseq:w;if(r==null||t==null){var i=d.random||(d.rng||u.default)();r==null&&(r=b=[i[0]|1,i[1],i[2],i[3],i[4],i[5]]),t==null&&(t=w=(i[6]<<8|i[7])&16383)}var n=d.msecs!==void 0?d.msecs:Date.now(),o=d.nsecs!==void 0?d.nsecs:v+1,p=n-f+(o-v)/1e4;if(p<0&&d.clockseq===void 0&&(t=t+1&16383),(p<0||n>f)&&d.nsecs===void 0&&(o=0),o>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f=n,v=o,w=t,n+=122192928e5;var E=((n&268435455)*1e4+o)%4294967296;a[c++]=E>>>24&255,a[c++]=E>>>16&255,a[c++]=E>>>8&255,a[c++]=E&255;var P=n/4294967296*1e4&268435455;a[c++]=P>>>8&255,a[c++]=P&255,a[c++]=P>>>24&15|16,a[c++]=P>>>16&255,a[c++]=t>>>8|128,a[c++]=t&255;for(var D=0;D<6;++D)a[c+D]=r[D];return s||(0,y.default)(a)}var l=h;_.default=l},{"./rng.js":531,"./stringify.js":533}],535:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var u=g(e("./v35.js")),y=g(e("./md5.js"));function g(f){return f&&f.__esModule?f:{default:f}}var b=(0,u.default)("v3",48,y.default),w=b;_.default=w},{"./md5.js":527,"./v35.js":536}],536:[function(e,S,_){Object.defineProperty(_,"__esModule",{value:!0}),_.default=v,_.URL=_.DNS=void 0;var u=g(e("./stringify.js")),y=g(e("./parse.js"));function g(h){return h&&h.__esModule?h:{default:h}}function b(h){h=unescape(encodeURIComponent(h));for(var l=[],d=0;d=65&&g<=90||g===95||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}_.isNCNameStartChar=u;function y(g){return u(g)||g===45||g===46||g>=48&&g<=57||g===183||g>=768&&g<=879||g>=8255&&g<=8256}_.isNCNameChar=y},{}]},{},[15])(15)})})(Ec);var Ag=Ec.exports;function es(H){"@babel/helpers - typeof";return es=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(x){return typeof x}:function(x){return x&&typeof Symbol=="function"&&x.constructor===Symbol&&x!==Symbol.prototype?"symbol":typeof x},es(H)}var Mg=/^\s+/,Ig=/\s+$/;function Rt(H,x){if(H=H||"",x=x||{},H instanceof Rt)return H;if(!(this instanceof Rt))return new Rt(H,x);var e=Ng(H);this._originalInput=H,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=x.format||e.format,this._gradientType=x.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=e.ok}Rt.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 x=this.toRgb();return(x.r*299+x.g*587+x.b*114)/1e3},getLuminance:function(){var x=this.toRgb(),e,S,_,u,y,g;return e=x.r/255,S=x.g/255,_=x.b/255,e<=.03928?u=e/12.92:u=Math.pow((e+.055)/1.055,2.4),S<=.03928?y=S/12.92:y=Math.pow((S+.055)/1.055,2.4),_<=.03928?g=_/12.92:g=Math.pow((_+.055)/1.055,2.4),.2126*u+.7152*y+.0722*g},setAlpha:function(x){return this._a=Tc(x),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var x=ql(this._r,this._g,this._b);return{h:x.h*360,s:x.s,v:x.v,a:this._a}},toHsvString:function(){var x=ql(this._r,this._g,this._b),e=Math.round(x.h*360),S=Math.round(x.s*100),_=Math.round(x.v*100);return this._a==1?"hsv("+e+", "+S+"%, "+_+"%)":"hsva("+e+", "+S+"%, "+_+"%, "+this._roundA+")"},toHsl:function(){var x=Ql(this._r,this._g,this._b);return{h:x.h*360,s:x.s,l:x.l,a:this._a}},toHslString:function(){var x=Ql(this._r,this._g,this._b),e=Math.round(x.h*360),S=Math.round(x.s*100),_=Math.round(x.l*100);return this._a==1?"hsl("+e+", "+S+"%, "+_+"%)":"hsla("+e+", "+S+"%, "+_+"%, "+this._roundA+")"},toHex:function(x){return ec(this._r,this._g,this._b,x)},toHexString:function(x){return"#"+this.toHex(x)},toHex8:function(x){return jg(this._r,this._g,this._b,this._a,x)},toHex8String:function(x){return"#"+this.toHex8(x)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"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(vr(this._r,255)*100)+"%",g:Math.round(vr(this._g,255)*100)+"%",b:Math.round(vr(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(vr(this._r,255)*100)+"%, "+Math.round(vr(this._g,255)*100)+"%, "+Math.round(vr(this._b,255)*100)+"%)":"rgba("+Math.round(vr(this._r,255)*100)+"%, "+Math.round(vr(this._g,255)*100)+"%, "+Math.round(vr(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:Zg[ec(this._r,this._g,this._b,!0)]||!1},toFilter:function(x){var e="#"+tc(this._r,this._g,this._b,this._a),S=e,_=this._gradientType?"GradientType = 1, ":"";if(x){var u=Rt(x);S="#"+tc(u._r,u._g,u._b,u._a)}return"progid:DXImageTransform.Microsoft.gradient("+_+"startColorstr="+e+",endColorstr="+S+")"},toString:function(x){var e=!!x;x=x||this._format;var S=!1,_=this._a<1&&this._a>=0,u=!e&&_&&(x==="hex"||x==="hex6"||x==="hex3"||x==="hex4"||x==="hex8"||x==="name");return u?x==="name"&&this._a===0?this.toName():this.toRgbString():(x==="rgb"&&(S=this.toRgbString()),x==="prgb"&&(S=this.toPercentageRgbString()),(x==="hex"||x==="hex6")&&(S=this.toHexString()),x==="hex3"&&(S=this.toHexString(!0)),x==="hex4"&&(S=this.toHex8String(!0)),x==="hex8"&&(S=this.toHex8String()),x==="name"&&(S=this.toName()),x==="hsl"&&(S=this.toHslString()),x==="hsv"&&(S=this.toHsvString()),S||this.toHexString())},clone:function(){return Rt(this.toString())},_applyModification:function(x,e){var S=x.apply(null,[this].concat([].slice.call(e)));return this._r=S._r,this._g=S._g,this._b=S._b,this.setAlpha(S._a),this},lighten:function(){return this._applyModification(Xg,arguments)},brighten:function(){return this._applyModification(Ug,arguments)},darken:function(){return this._applyModification($g,arguments)},desaturate:function(){return this._applyModification(Lg,arguments)},saturate:function(){return this._applyModification(zg,arguments)},greyscale:function(){return this._applyModification(Hg,arguments)},spin:function(){return this._applyModification(Wg,arguments)},_applyCombination:function(x,e){return x.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(Gg,arguments)},complement:function(){return this._applyCombination(Vg,arguments)},monochromatic:function(){return this._applyCombination(Yg,arguments)},splitcomplement:function(){return this._applyCombination(Kg,arguments)},triad:function(){return this._applyCombination(rc,[3])},tetrad:function(){return this._applyCombination(rc,[4])}};Rt.fromRatio=function(H,x){if(es(H)=="object"){var e={};for(var S in H)H.hasOwnProperty(S)&&(S==="a"?e[S]=H[S]:e[S]=Wa(H[S]));H=e}return Rt(H,x)};function Ng(H){var x={r:0,g:0,b:0},e=1,S=null,_=null,u=null,y=!1,g=!1;return typeof H=="string"&&(H=e1(H)),es(H)=="object"&&(hi(H.r)&&hi(H.g)&&hi(H.b)?(x=Dg(H.r,H.g,H.b),y=!0,g=String(H.r).substr(-1)==="%"?"prgb":"rgb"):hi(H.h)&&hi(H.s)&&hi(H.v)?(S=Wa(H.s),_=Wa(H.v),x=Fg(H.h,S,_),y=!0,g="hsv"):hi(H.h)&&hi(H.s)&&hi(H.l)&&(S=Wa(H.s),u=Wa(H.l),x=Bg(H.h,S,u),y=!0,g="hsl"),H.hasOwnProperty("a")&&(e=H.a)),e=Tc(e),{ok:y,format:H.format||g,r:Math.min(255,Math.max(x.r,0)),g:Math.min(255,Math.max(x.g,0)),b:Math.min(255,Math.max(x.b,0)),a:e}}function Dg(H,x,e){return{r:vr(H,255)*255,g:vr(x,255)*255,b:vr(e,255)*255}}function Ql(H,x,e){H=vr(H,255),x=vr(x,255),e=vr(e,255);var S=Math.max(H,x,e),_=Math.min(H,x,e),u,y,g=(S+_)/2;if(S==_)u=y=0;else{var b=S-_;switch(y=g>.5?b/(2-S-_):b/(S+_),S){case H:u=(x-e)/b+(x1&&(v-=1),v<1/6?w+(f-w)*6*v:v<1/2?f:v<2/3?w+(f-w)*(2/3-v)*6:w}if(x===0)S=_=u=e;else{var g=e<.5?e*(1+x):e+x-e*x,b=2*e-g;S=y(b,g,H+1/3),_=y(b,g,H),u=y(b,g,H-1/3)}return{r:S*255,g:_*255,b:u*255}}function ql(H,x,e){H=vr(H,255),x=vr(x,255),e=vr(e,255);var S=Math.max(H,x,e),_=Math.min(H,x,e),u,y,g=S,b=S-_;if(y=S===0?0:b/S,S==_)u=0;else{switch(S){case H:u=(x-e)/b+(x>1)+720)%360;--x;)S.h=(S.h+_)%360,u.push(Rt(S));return u}function Yg(H,x){x=x||6;for(var e=Rt(H).toHsv(),S=e.h,_=e.s,u=e.v,y=[],g=1/x;x--;)y.push(Rt({h:S,s:_,v:u})),u=(u+g)%1;return y}Rt.mix=function(H,x,e){e=e===0?0:e||50;var S=Rt(H).toRgb(),_=Rt(x).toRgb(),u=e/100,y={r:(_.r-S.r)*u+S.r,g:(_.g-S.g)*u+S.g,b:(_.b-S.b)*u+S.b,a:(_.a-S.a)*u+S.a};return Rt(y)};Rt.readability=function(H,x){var e=Rt(H),S=Rt(x);return(Math.max(e.getLuminance(),S.getLuminance())+.05)/(Math.min(e.getLuminance(),S.getLuminance())+.05)};Rt.isReadable=function(H,x,e){var S=Rt.readability(H,x),_,u;switch(u=!1,_=t1(e),_.level+_.size){case"AAsmall":case"AAAlarge":u=S>=4.5;break;case"AAlarge":u=S>=3;break;case"AAAsmall":u=S>=7;break}return u};Rt.mostReadable=function(H,x,e){var S=null,_=0,u,y,g,b;e=e||{},y=e.includeFallbackColors,g=e.level,b=e.size;for(var w=0;w_&&(_=u,S=Rt(x[w]));return Rt.isReadable(H,S,{level:g,size:b})||!y?S:(e.includeFallbackColors=!1,Rt.mostReadable(H,["#fff","#000"],e))};var _f=Rt.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"},Zg=Rt.hexNames=Jg(_f);function Jg(H){var x={};for(var e in H)H.hasOwnProperty(e)&&(x[H[e]]=e);return x}function Tc(H){return H=parseFloat(H),(isNaN(H)||H<0||H>1)&&(H=1),H}function vr(H,x){Qg(H)&&(H="100%");var e=qg(H);return H=Math.min(x,Math.max(0,parseFloat(H))),e&&(H=parseInt(H*x,10)/100),Math.abs(H-x)<1e-6?1:H%x/parseFloat(x)}function ns(H){return Math.min(1,Math.max(0,H))}function wn(H){return parseInt(H,16)}function Qg(H){return typeof H=="string"&&H.indexOf(".")!=-1&&parseFloat(H)===1}function qg(H){return typeof H=="string"&&H.indexOf("%")!=-1}function Vn(H){return H.length==1?"0"+H:""+H}function Wa(H){return H<=1&&(H=H*100+"%"),H}function Rc(H){return Math.round(parseFloat(H)*255).toString(16)}function nc(H){return wn(H)/255}var Wn=function(){var H="[-\\+]?\\d+%?",x="[-\\+]?\\d*\\.\\d+%?",e="(?:"+x+")|(?:"+H+")",S="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",_="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+S),rgba:new RegExp("rgba"+_),hsl:new RegExp("hsl"+S),hsla:new RegExp("hsla"+_),hsv:new RegExp("hsv"+S),hsva:new RegExp("hsva"+_),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 hi(H){return!!Wn.CSS_UNIT.exec(H)}function e1(H){H=H.replace(Mg,"").replace(Ig,"").toLowerCase();var x=!1;if(_f[H])H=_f[H],x=!0;else if(H=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=Wn.rgb.exec(H))?{r:e[1],g:e[2],b:e[3]}:(e=Wn.rgba.exec(H))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=Wn.hsl.exec(H))?{h:e[1],s:e[2],l:e[3]}:(e=Wn.hsla.exec(H))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=Wn.hsv.exec(H))?{h:e[1],s:e[2],v:e[3]}:(e=Wn.hsva.exec(H))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=Wn.hex8.exec(H))?{r:wn(e[1]),g:wn(e[2]),b:wn(e[3]),a:nc(e[4]),format:x?"name":"hex8"}:(e=Wn.hex6.exec(H))?{r:wn(e[1]),g:wn(e[2]),b:wn(e[3]),format:x?"name":"hex"}:(e=Wn.hex4.exec(H))?{r:wn(e[1]+""+e[1]),g:wn(e[2]+""+e[2]),b:wn(e[3]+""+e[3]),a:nc(e[4]+""+e[4]),format:x?"name":"hex8"}:(e=Wn.hex3.exec(H))?{r:wn(e[1]+""+e[1]),g:wn(e[2]+""+e[2]),b:wn(e[3]+""+e[3]),format:x?"name":"hex"}:!1}function t1(H){var x,e;return H=H||{level:"AA",size:"small"},x=(H.level||"AA").toUpperCase(),e=(H.size||"small").toLowerCase(),x!=="AA"&&x!=="AAA"&&(x="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:x,size:e}}var Cc={exports:{}};(function(H,x){(function(e,S){H.exports=S()})(Wt,function(){var e=1e3,S=6e4,_=36e5,u="millisecond",y="second",g="minute",b="hour",w="day",f="week",v="month",h="quarter",l="year",d="date",s="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,a={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var M=["th","st","nd","rd"],I=D%100;return"["+D+(M[(I-20)%10]||M[I]||M[0])+"]"}},r=function(D,M,I){var T=String(D);return!T||T.length>=M?D:""+Array(M+1-T.length).join(I)+D},t={s:r,z:function(D){var M=-D.utcOffset(),I=Math.abs(M),T=Math.floor(I/60),C=I%60;return(M<=0?"+":"-")+r(T,2,"0")+":"+r(C,2,"0")},m:function D(M,I){if(M.date()1)return D(A[0])}else{var L=M.name;n[L]=M,C=L}return!T&&C&&(i=C),C||!T&&i},O=function(D,M){if(o(D))return D.clone();var I=typeof M=="object"?M:{};return I.date=D,I.args=arguments,new B(I)},P=t;P.l=p,P.i=o,P.w=function(D,M){return O(D,{locale:M.$L,utc:M.$u,x:M.$x,$offset:M.$offset})};var B=function(){function D(I){this.$L=p(I.locale,null,!0),this.parse(I)}var M=D.prototype;return M.parse=function(I){this.$d=function(T){var C=T.date,E=T.utc;if(C===null)return new Date(NaN);if(P.u(C))return new Date;if(C instanceof Date)return new Date(C);if(typeof C=="string"&&!/Z$/i.test(C)){var A=C.match(m);if(A){var L=A[2]-1||0,$=(A[7]||"0").substring(0,3);return E?new Date(Date.UTC(A[1],L,A[3]||1,A[4]||0,A[5]||0,A[6]||0,$)):new Date(A[1],L,A[3]||1,A[4]||0,A[5]||0,A[6]||0,$)}}return new Date(C)}(I),this.$x=I.x||{},this.init()},M.init=function(){var I=this.$d;this.$y=I.getFullYear(),this.$M=I.getMonth(),this.$D=I.getDate(),this.$W=I.getDay(),this.$H=I.getHours(),this.$m=I.getMinutes(),this.$s=I.getSeconds(),this.$ms=I.getMilliseconds()},M.$utils=function(){return P},M.isValid=function(){return this.$d.toString()!==s},M.isSame=function(I,T){var C=O(I);return this.startOf(T)<=C&&C<=this.endOf(T)},M.isAfter=function(I,T){return O(I)9?"#C7C9CC":typeof x>"u"?of[H]:x>0?em(of[H],x):tm(of[H],Math.abs(x))}function f1(H){H.style=rs.cloneDeep(H.style);let x=null;H.style.fill&&H.style.fill.fgColor&&(H.style.fill.fgColor.argb?x=ff(H.style.fill.fgColor.argb):Object.prototype.hasOwnProperty.call(H.style.fill.fgColor,"theme")?x=uf(H.style.fill.fgColor.theme,H.style.fill.fgColor.tint):H.style.fill.fgColor.indexed?x=sf[H.style.fill.fgColor.indexed]||"#C7C9CC":x="#C7C9CC"),x&&(H.style.bgcolor=x);let e=null;if(H.style.font&&H.style.font.color&&(H.style.font.color.argb?e=ff(H.style.font.color.argb):Object.prototype.hasOwnProperty.call(H.style.font.color,"theme")?e=uf(H.style.font.color.theme,H.style.font.color.tint):H.style.font.color.indexed?e=sf[H.style.font.color.indexed]||"#000000":e="#000000"),e&&(H.style.color=e),H.style.alignment&&(H.style.alignment.horizontal&&(H.style.align=H.style.alignment.horizontal),H.style.alignment.vertical&&(H.style.valign=H.style.alignment.vertical)),H.style.alignment&&H.style.alignment.wrapText&&(H.style.textwrap=!0),H.style.border){const S={};Object.keys(H.style.border).forEach(_=>{const u=H.style.border[_];let y="#000000";typeof u.color=="string"?y=u.color:u.color&&(u.color.argb?y=ff(u.color.argb)||"":Object.prototype.hasOwnProperty.call(u.color,"theme")?y=uf(u.color.theme,u.color.tint):u.color.indexed&&(y=sf[u.color.indexed])),S[_]=[u.style||"thin",y]}),H.style.border2={...H.style.border},H.style.border=S}return H.style}function u1(H,x){const e=[];return H.eachSheet(S=>{const _={name:S.name,styles:[],rows:{},cols:{},merges:[],media:[]},u=[];for(const y in S._merges){_.merges.push(S._merges[y].shortRange);const g={};g.startAddress=S._merges[y].tl,g.endAddress=S._merges[y].br,g.YRange=S._merges[y].model.bottom-S._merges[y].model.top,g.XRange=S._merges[y].model.right-S._merges[y].model.left,u.push(g)}o1(S,_,x),(S._rows||[]).forEach((y,g)=>{_.rows[g]={cells:{}},y.height?_.rows[g].height=y.height+(x.heightOffset||0):_.rows[g].height=i1+(x.heightOffset||0),(y._cells||[]).forEach((b,w)=>{_.rows[g].cells[w]={};const f=rs.find(u,function(v){return v.startAddress===b._address});f&&b.master.address!==f.startAddress||(f&&(_.rows[g].cells[w].merge=[f.YRange,f.XRange]),_.rows[g].cells[w].text=s1(b),_.styles.push(f1(b)),_.rows[g].cells[w].style=_.styles.length-1)})}),_._media&&(_.media=_._media),_.rows.len=Math.max(Object.keys(_.rows).length,100),e.push(_)}),{workbookData:e,workbookSource:H,medias:H.media||[]}}let $o=[];function Ho(H,x,e,S){e&&e._media.length&&e._media.forEach(_=>{const{imageId:u,range:y,type:g}=_;if(g==="image"){const b=l1(e,y,S);c1(H,u,x[u],b)}})}const Wo=60,Vo=25,lf=80,cf=24,Qn=window.devicePixelRatio;function l1(H,x,e){var S,_,u,y,g,b,w,f,v,h,l,d,s,m;const{tl:c={},br:a={}}=x,{nativeCol:r,nativeColOff:t,nativeRow:i,nativeRowOff:n}=c;let o=Wo,p=Vo;for(let C=0;C{let u=0,y=0,g=_.width,b=_.height,w=S.x,f=S.y,v=S.width,h=S.height;const l=v/g,d=h/b;if(w{})}function h1(H,x){return new Promise((e,S)=>{if($o[H])return e($o[H]);const{buffer:_,extension:u}=x.buffer,y=new Blob([_],{type:"image/"+u}),g=URL.createObjectURL(y),b=new Image;b.src=g,b.onload=function(){e(b),$o[H]=b},b.onerror=function(w){S(w)}})}function d1(H){if(H){const x=H.querySelectorAll("input");for(const e of x)e&&!e.readOnly&&(e.readOnly=!0)}}const p1={minColLength:20};class v1{constructor(x,e={}){Nn(this,"container"),Nn(this,"options",{}),Nn(this,"wrapper"),Nn(this,"wrapperMain"),Nn(this,"xs"),Nn(this,"sheetIndex"),Nn(this,"mediasSource"),Nn(this,"workbookDataSource"),Nn(this,"ctx"),Nn(this,"fileData"),Nn(this,"observer"),Nn(this,"offset"),this.container=x,this.options={...p1,...e},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)}initSpreadsheet(){var x;if(!this.wrapper||(this.xs=new Oc(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 S=this.xs.bottombar.swapFunc;this.xs.bottombar.swapFunc=_=>{var u;S.call((u=this.xs)==null?void 0:u.bottombar,_),this.sheetIndex=_+1,setTimeout(()=>{var y,g;(y=this.xs)!=null&&y.reRender&&((g=this.xs)==null||g.reRender()),this.mediasSource&&this.ctx&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)})}}if((x=this.xs.sheet)!=null&&x.editor){const S=this.xs.sheet.editor.clear;this.xs.sheet.editor.clear=(...u)=>{var y,g;S.apply((g=(y=this.xs)==null?void 0:y.sheet)==null?void 0:g.editor,u),setTimeout(()=>{this.ctx&&this.mediasSource&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)})};const _=this.xs.sheet.editor.setOffset;this.xs.sheet.editor.setOffset=(...u)=>{var y,g;_.apply((g=(y=this.xs)==null?void 0:y.sheet)==null?void 0:g.editor,u),u.length>1&&(this.offset=u.shift()),this.ctx&&this.mediasSource&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}}const e=this.wrapper.querySelector("canvas");e&&(this.ctx=e.getContext("2d"))}renderExcel(x){return this.fileData=x,a1(x).then(e=>{var S;if(!e._worksheets||e._worksheets.length===0)throw new Error("未获取到数据,可能文件格式不正确或文件已损坏");const{workbookData:_,medias:u,workbookSource:y}=u1(e,this.options);this.mediasSource=u,this.workbookDataSource=y,this.offset=void 0,this.sheetIndex=1,ic(),(S=this.xs)==null||S.loadData(_),this.ctx&&this.mediasSource&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}).catch(e=>{var S;return this.mediasSource=[],this.workbookDataSource={_worksheets:[]},ic(),(S=this.xs)==null||S.loadData({}),Promise.reject(e)})}hack(){if(!this.wrapper)return;const x=rs.debounce(d1,200).bind(this,this.wrapper);this.observer=new MutationObserver(x);const e={attributes:!0,childList:!0,subtree:!0};this.observer.observe(this.wrapper,e),x()}}const x1=(H,x)=>{if(!x)return Promise.reject();const e=new v1(x);return(()=>new Promise((_,u)=>{const y=new FileReader;y.readAsArrayBuffer(H),y.onload=()=>{y.result?_(y==null?void 0:y.result):u()}}))().then(_=>{e.renderExcel(_)})};export{x1 as renderExcel}; + */Object.defineProperty(_,"__esModule",{value:!0}),_.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",_.NC_NAME_CHAR="-"+_.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",_.NC_NAME_START_CHAR_RE=new RegExp("^["+_.NC_NAME_START_CHAR+"]$","u"),_.NC_NAME_CHAR_RE=new RegExp("^["+_.NC_NAME_CHAR+"]$","u"),_.NC_NAME_RE=new RegExp("^["+_.NC_NAME_START_CHAR+"]["+_.NC_NAME_CHAR+"]*$","u");function u(g){return g>=65&&g<=90||g===95||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}_.isNCNameStartChar=u;function y(g){return u(g)||g===45||g===46||g>=48&&g<=57||g===183||g>=768&&g<=879||g>=8255&&g<=8256}_.isNCNameChar=y},{}]},{},[15])(15)})})(Ec);var Ag=Ec.exports;function es(H){"@babel/helpers - typeof";return es=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(x){return typeof x}:function(x){return x&&typeof Symbol=="function"&&x.constructor===Symbol&&x!==Symbol.prototype?"symbol":typeof x},es(H)}var Mg=/^\s+/,Ig=/\s+$/;function Rt(H,x){if(H=H||"",x=x||{},H instanceof Rt)return H;if(!(this instanceof Rt))return new Rt(H,x);var e=Ng(H);this._originalInput=H,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=x.format||e.format,this._gradientType=x.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=e.ok}Rt.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 x=this.toRgb();return(x.r*299+x.g*587+x.b*114)/1e3},getLuminance:function(){var x=this.toRgb(),e,S,_,u,y,g;return e=x.r/255,S=x.g/255,_=x.b/255,e<=.03928?u=e/12.92:u=Math.pow((e+.055)/1.055,2.4),S<=.03928?y=S/12.92:y=Math.pow((S+.055)/1.055,2.4),_<=.03928?g=_/12.92:g=Math.pow((_+.055)/1.055,2.4),.2126*u+.7152*y+.0722*g},setAlpha:function(x){return this._a=Tc(x),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var x=ql(this._r,this._g,this._b);return{h:x.h*360,s:x.s,v:x.v,a:this._a}},toHsvString:function(){var x=ql(this._r,this._g,this._b),e=Math.round(x.h*360),S=Math.round(x.s*100),_=Math.round(x.v*100);return this._a==1?"hsv("+e+", "+S+"%, "+_+"%)":"hsva("+e+", "+S+"%, "+_+"%, "+this._roundA+")"},toHsl:function(){var x=Ql(this._r,this._g,this._b);return{h:x.h*360,s:x.s,l:x.l,a:this._a}},toHslString:function(){var x=Ql(this._r,this._g,this._b),e=Math.round(x.h*360),S=Math.round(x.s*100),_=Math.round(x.l*100);return this._a==1?"hsl("+e+", "+S+"%, "+_+"%)":"hsla("+e+", "+S+"%, "+_+"%, "+this._roundA+")"},toHex:function(x){return ec(this._r,this._g,this._b,x)},toHexString:function(x){return"#"+this.toHex(x)},toHex8:function(x){return jg(this._r,this._g,this._b,this._a,x)},toHex8String:function(x){return"#"+this.toHex8(x)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"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(vr(this._r,255)*100)+"%",g:Math.round(vr(this._g,255)*100)+"%",b:Math.round(vr(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(vr(this._r,255)*100)+"%, "+Math.round(vr(this._g,255)*100)+"%, "+Math.round(vr(this._b,255)*100)+"%)":"rgba("+Math.round(vr(this._r,255)*100)+"%, "+Math.round(vr(this._g,255)*100)+"%, "+Math.round(vr(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:Zg[ec(this._r,this._g,this._b,!0)]||!1},toFilter:function(x){var e="#"+tc(this._r,this._g,this._b,this._a),S=e,_=this._gradientType?"GradientType = 1, ":"";if(x){var u=Rt(x);S="#"+tc(u._r,u._g,u._b,u._a)}return"progid:DXImageTransform.Microsoft.gradient("+_+"startColorstr="+e+",endColorstr="+S+")"},toString:function(x){var e=!!x;x=x||this._format;var S=!1,_=this._a<1&&this._a>=0,u=!e&&_&&(x==="hex"||x==="hex6"||x==="hex3"||x==="hex4"||x==="hex8"||x==="name");return u?x==="name"&&this._a===0?this.toName():this.toRgbString():(x==="rgb"&&(S=this.toRgbString()),x==="prgb"&&(S=this.toPercentageRgbString()),(x==="hex"||x==="hex6")&&(S=this.toHexString()),x==="hex3"&&(S=this.toHexString(!0)),x==="hex4"&&(S=this.toHex8String(!0)),x==="hex8"&&(S=this.toHex8String()),x==="name"&&(S=this.toName()),x==="hsl"&&(S=this.toHslString()),x==="hsv"&&(S=this.toHsvString()),S||this.toHexString())},clone:function(){return Rt(this.toString())},_applyModification:function(x,e){var S=x.apply(null,[this].concat([].slice.call(e)));return this._r=S._r,this._g=S._g,this._b=S._b,this.setAlpha(S._a),this},lighten:function(){return this._applyModification(Xg,arguments)},brighten:function(){return this._applyModification(Ug,arguments)},darken:function(){return this._applyModification($g,arguments)},desaturate:function(){return this._applyModification(Lg,arguments)},saturate:function(){return this._applyModification(zg,arguments)},greyscale:function(){return this._applyModification(Hg,arguments)},spin:function(){return this._applyModification(Wg,arguments)},_applyCombination:function(x,e){return x.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(Gg,arguments)},complement:function(){return this._applyCombination(Vg,arguments)},monochromatic:function(){return this._applyCombination(Yg,arguments)},splitcomplement:function(){return this._applyCombination(Kg,arguments)},triad:function(){return this._applyCombination(rc,[3])},tetrad:function(){return this._applyCombination(rc,[4])}};Rt.fromRatio=function(H,x){if(es(H)=="object"){var e={};for(var S in H)H.hasOwnProperty(S)&&(S==="a"?e[S]=H[S]:e[S]=Wa(H[S]));H=e}return Rt(H,x)};function Ng(H){var x={r:0,g:0,b:0},e=1,S=null,_=null,u=null,y=!1,g=!1;return typeof H=="string"&&(H=e1(H)),es(H)=="object"&&(hi(H.r)&&hi(H.g)&&hi(H.b)?(x=Dg(H.r,H.g,H.b),y=!0,g=String(H.r).substr(-1)==="%"?"prgb":"rgb"):hi(H.h)&&hi(H.s)&&hi(H.v)?(S=Wa(H.s),_=Wa(H.v),x=Fg(H.h,S,_),y=!0,g="hsv"):hi(H.h)&&hi(H.s)&&hi(H.l)&&(S=Wa(H.s),u=Wa(H.l),x=Bg(H.h,S,u),y=!0,g="hsl"),H.hasOwnProperty("a")&&(e=H.a)),e=Tc(e),{ok:y,format:H.format||g,r:Math.min(255,Math.max(x.r,0)),g:Math.min(255,Math.max(x.g,0)),b:Math.min(255,Math.max(x.b,0)),a:e}}function Dg(H,x,e){return{r:vr(H,255)*255,g:vr(x,255)*255,b:vr(e,255)*255}}function Ql(H,x,e){H=vr(H,255),x=vr(x,255),e=vr(e,255);var S=Math.max(H,x,e),_=Math.min(H,x,e),u,y,g=(S+_)/2;if(S==_)u=y=0;else{var b=S-_;switch(y=g>.5?b/(2-S-_):b/(S+_),S){case H:u=(x-e)/b+(x1&&(v-=1),v<1/6?w+(f-w)*6*v:v<1/2?f:v<2/3?w+(f-w)*(2/3-v)*6:w}if(x===0)S=_=u=e;else{var g=e<.5?e*(1+x):e+x-e*x,b=2*e-g;S=y(b,g,H+1/3),_=y(b,g,H),u=y(b,g,H-1/3)}return{r:S*255,g:_*255,b:u*255}}function ql(H,x,e){H=vr(H,255),x=vr(x,255),e=vr(e,255);var S=Math.max(H,x,e),_=Math.min(H,x,e),u,y,g=S,b=S-_;if(y=S===0?0:b/S,S==_)u=0;else{switch(S){case H:u=(x-e)/b+(x>1)+720)%360;--x;)S.h=(S.h+_)%360,u.push(Rt(S));return u}function Yg(H,x){x=x||6;for(var e=Rt(H).toHsv(),S=e.h,_=e.s,u=e.v,y=[],g=1/x;x--;)y.push(Rt({h:S,s:_,v:u})),u=(u+g)%1;return y}Rt.mix=function(H,x,e){e=e===0?0:e||50;var S=Rt(H).toRgb(),_=Rt(x).toRgb(),u=e/100,y={r:(_.r-S.r)*u+S.r,g:(_.g-S.g)*u+S.g,b:(_.b-S.b)*u+S.b,a:(_.a-S.a)*u+S.a};return Rt(y)};Rt.readability=function(H,x){var e=Rt(H),S=Rt(x);return(Math.max(e.getLuminance(),S.getLuminance())+.05)/(Math.min(e.getLuminance(),S.getLuminance())+.05)};Rt.isReadable=function(H,x,e){var S=Rt.readability(H,x),_,u;switch(u=!1,_=t1(e),_.level+_.size){case"AAsmall":case"AAAlarge":u=S>=4.5;break;case"AAlarge":u=S>=3;break;case"AAAsmall":u=S>=7;break}return u};Rt.mostReadable=function(H,x,e){var S=null,_=0,u,y,g,b;e=e||{},y=e.includeFallbackColors,g=e.level,b=e.size;for(var w=0;w_&&(_=u,S=Rt(x[w]));return Rt.isReadable(H,S,{level:g,size:b})||!y?S:(e.includeFallbackColors=!1,Rt.mostReadable(H,["#fff","#000"],e))};var _f=Rt.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"},Zg=Rt.hexNames=Jg(_f);function Jg(H){var x={};for(var e in H)H.hasOwnProperty(e)&&(x[H[e]]=e);return x}function Tc(H){return H=parseFloat(H),(isNaN(H)||H<0||H>1)&&(H=1),H}function vr(H,x){Qg(H)&&(H="100%");var e=qg(H);return H=Math.min(x,Math.max(0,parseFloat(H))),e&&(H=parseInt(H*x,10)/100),Math.abs(H-x)<1e-6?1:H%x/parseFloat(x)}function ns(H){return Math.min(1,Math.max(0,H))}function wn(H){return parseInt(H,16)}function Qg(H){return typeof H=="string"&&H.indexOf(".")!=-1&&parseFloat(H)===1}function qg(H){return typeof H=="string"&&H.indexOf("%")!=-1}function Vn(H){return H.length==1?"0"+H:""+H}function Wa(H){return H<=1&&(H=H*100+"%"),H}function Rc(H){return Math.round(parseFloat(H)*255).toString(16)}function nc(H){return wn(H)/255}var Wn=function(){var H="[-\\+]?\\d+%?",x="[-\\+]?\\d*\\.\\d+%?",e="(?:"+x+")|(?:"+H+")",S="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",_="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+S),rgba:new RegExp("rgba"+_),hsl:new RegExp("hsl"+S),hsla:new RegExp("hsla"+_),hsv:new RegExp("hsv"+S),hsva:new RegExp("hsva"+_),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 hi(H){return!!Wn.CSS_UNIT.exec(H)}function e1(H){H=H.replace(Mg,"").replace(Ig,"").toLowerCase();var x=!1;if(_f[H])H=_f[H],x=!0;else if(H=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=Wn.rgb.exec(H))?{r:e[1],g:e[2],b:e[3]}:(e=Wn.rgba.exec(H))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=Wn.hsl.exec(H))?{h:e[1],s:e[2],l:e[3]}:(e=Wn.hsla.exec(H))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=Wn.hsv.exec(H))?{h:e[1],s:e[2],v:e[3]}:(e=Wn.hsva.exec(H))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=Wn.hex8.exec(H))?{r:wn(e[1]),g:wn(e[2]),b:wn(e[3]),a:nc(e[4]),format:x?"name":"hex8"}:(e=Wn.hex6.exec(H))?{r:wn(e[1]),g:wn(e[2]),b:wn(e[3]),format:x?"name":"hex"}:(e=Wn.hex4.exec(H))?{r:wn(e[1]+""+e[1]),g:wn(e[2]+""+e[2]),b:wn(e[3]+""+e[3]),a:nc(e[4]+""+e[4]),format:x?"name":"hex8"}:(e=Wn.hex3.exec(H))?{r:wn(e[1]+""+e[1]),g:wn(e[2]+""+e[2]),b:wn(e[3]+""+e[3]),format:x?"name":"hex"}:!1}function t1(H){var x,e;return H=H||{level:"AA",size:"small"},x=(H.level||"AA").toUpperCase(),e=(H.size||"small").toLowerCase(),x!=="AA"&&x!=="AAA"&&(x="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:x,size:e}}var Cc={exports:{}};(function(H,x){(function(e,S){H.exports=S()})(Wt,function(){var e=1e3,S=6e4,_=36e5,u="millisecond",y="second",g="minute",b="hour",w="day",f="week",v="month",h="quarter",l="year",d="date",s="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,a={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(M){var I=["th","st","nd","rd"],T=M%100;return"["+M+(I[(T-20)%10]||I[T]||I[0])+"]"}},r=function(M,I,T){var C=String(M);return!C||C.length>=I?M:""+Array(I+1-C.length).join(T)+M},t={s:r,z:function(M){var I=-M.utcOffset(),T=Math.abs(I),C=Math.floor(T/60),O=T%60;return(I<=0?"+":"-")+r(C,2,"0")+":"+r(O,2,"0")},m:function M(I,T){if(I.date()1)return M(L[0])}else{var U=I.name;n[U]=I,O=U}return!C&&O&&(i=O),O||!C&&i},P=function(M,I){if(p(M))return M.clone();var T=typeof I=="object"?I:{};return T.date=M,T.args=arguments,new z(T)},D=t;D.l=E,D.i=p,D.w=function(M,I){return P(M,{locale:I.$L,utc:I.$u,x:I.$x,$offset:I.$offset})};var z=function(){function M(T){this.$L=E(T.locale,null,!0),this.parse(T),this.$x=this.$x||T.x||{},this[o]=!0}var I=M.prototype;return I.parse=function(T){this.$d=function(C){var O=C.date,A=C.utc;if(O===null)return new Date(NaN);if(D.u(O))return new Date;if(O instanceof Date)return new Date(O);if(typeof O=="string"&&!/Z$/i.test(O)){var L=O.match(m);if(L){var U=L[2]-1||0,W=(L[7]||"0").substring(0,3);return A?new Date(Date.UTC(L[1],U,L[3]||1,L[4]||0,L[5]||0,L[6]||0,W)):new Date(L[1],U,L[3]||1,L[4]||0,L[5]||0,L[6]||0,W)}}return new Date(O)}(T),this.init()},I.init=function(){var T=this.$d;this.$y=T.getFullYear(),this.$M=T.getMonth(),this.$D=T.getDate(),this.$W=T.getDay(),this.$H=T.getHours(),this.$m=T.getMinutes(),this.$s=T.getSeconds(),this.$ms=T.getMilliseconds()},I.$utils=function(){return D},I.isValid=function(){return this.$d.toString()!==s},I.isSame=function(T,C){var O=P(T);return this.startOf(C)<=O&&O<=this.endOf(C)},I.isAfter=function(T,C){return P(T)9?"#C7C9CC":typeof x>"u"?of[H]:x>0?em(of[H],x):tm(of[H],Math.abs(x))}function f1(H){H.style=rs.cloneDeep(H.style);let x=null;H.style.fill&&H.style.fill.fgColor&&(H.style.fill.fgColor.argb?x=ff(H.style.fill.fgColor.argb):Object.prototype.hasOwnProperty.call(H.style.fill.fgColor,"theme")?x=uf(H.style.fill.fgColor.theme,H.style.fill.fgColor.tint):H.style.fill.fgColor.indexed?x=sf[H.style.fill.fgColor.indexed]||"#C7C9CC":x="#C7C9CC"),x&&(H.style.bgcolor=x);let e=null;if(H.style.font&&H.style.font.color&&(H.style.font.color.argb?e=ff(H.style.font.color.argb):Object.prototype.hasOwnProperty.call(H.style.font.color,"theme")?e=uf(H.style.font.color.theme,H.style.font.color.tint):H.style.font.color.indexed?e=sf[H.style.font.color.indexed]||"#000000":e="#000000"),e&&(H.style.color=e),H.style.alignment&&(H.style.alignment.horizontal&&(H.style.align=H.style.alignment.horizontal),H.style.alignment.vertical&&(H.style.valign=H.style.alignment.vertical)),H.style.alignment&&H.style.alignment.wrapText&&(H.style.textwrap=!0),H.style.border){const S={};Object.keys(H.style.border).forEach(_=>{const u=H.style.border[_];let y="#000000";typeof u.color=="string"?y=u.color:u.color&&(u.color.argb?y=ff(u.color.argb)||"":Object.prototype.hasOwnProperty.call(u.color,"theme")?y=uf(u.color.theme,u.color.tint):u.color.indexed&&(y=sf[u.color.indexed])),S[_]=[u.style||"thin",y]}),H.style.border2={...H.style.border},H.style.border=S}return H.style}function u1(H,x){const e=[];return H.eachSheet(S=>{const _={name:S.name,styles:[],rows:{},cols:{},merges:[],media:[]},u=[];for(const y in S._merges){_.merges.push(S._merges[y].shortRange);const g={};g.startAddress=S._merges[y].tl,g.endAddress=S._merges[y].br,g.YRange=S._merges[y].model.bottom-S._merges[y].model.top,g.XRange=S._merges[y].model.right-S._merges[y].model.left,u.push(g)}o1(S,_,x),(S._rows||[]).forEach((y,g)=>{_.rows[g]={cells:{}},y.height?_.rows[g].height=y.height+(x.heightOffset||0):_.rows[g].height=i1+(x.heightOffset||0),(y._cells||[]).forEach((b,w)=>{_.rows[g].cells[w]={};const f=rs.find(u,function(v){return v.startAddress===b._address});f&&b.master.address!==f.startAddress||(f&&(_.rows[g].cells[w].merge=[f.YRange,f.XRange]),_.rows[g].cells[w].text=s1(b),_.styles.push(f1(b)),_.rows[g].cells[w].style=_.styles.length-1)})}),_._media&&(_.media=_._media),_.rows.len=Math.max(Object.keys(_.rows).length,100),e.push(_)}),{workbookData:e,workbookSource:H,medias:H.media||[]}}let $o=[];function Ho(H,x,e,S){e&&e._media.length&&e._media.forEach(_=>{const{imageId:u,range:y,type:g}=_;if(g==="image"){const b=l1(e,y,S);c1(H,u,x[u],b)}})}const Wo=60,Vo=25,lf=80,cf=24,Qn=window.devicePixelRatio;function l1(H,x,e){var S,_,u,y,g,b,w,f,v,h,l,d,s,m;const{tl:c={},br:a={}}=x,{nativeCol:r,nativeColOff:t,nativeRow:i,nativeRowOff:n}=c;let o=Wo,p=Vo;for(let C=0;C{let u=0,y=0,g=_.width,b=_.height,w=S.x,f=S.y,v=S.width,h=S.height;const l=v/g,d=h/b;if(w{})}function h1(H,x){return new Promise((e,S)=>{if($o[H])return e($o[H]);const{buffer:_,extension:u}=x.buffer,y=new Blob([_],{type:"image/"+u}),g=URL.createObjectURL(y),b=new Image;b.src=g,b.onload=function(){e(b),$o[H]=b},b.onerror=function(w){S(w)}})}function d1(H){if(H){const x=H.querySelectorAll("input");for(const e of x)e&&!e.readOnly&&(e.readOnly=!0)}}const p1={minColLength:20};class v1{constructor(x,e={}){Nn(this,"container"),Nn(this,"options",{}),Nn(this,"wrapper"),Nn(this,"wrapperMain"),Nn(this,"xs"),Nn(this,"sheetIndex"),Nn(this,"mediasSource"),Nn(this,"workbookDataSource"),Nn(this,"ctx"),Nn(this,"fileData"),Nn(this,"observer"),Nn(this,"offset"),this.container=x,this.options={...p1,...e},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)}initSpreadsheet(){var x;if(!this.wrapper||(this.xs=new Oc(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 S=this.xs.bottombar.swapFunc;this.xs.bottombar.swapFunc=_=>{var u;S.call((u=this.xs)==null?void 0:u.bottombar,_),this.sheetIndex=_+1,setTimeout(()=>{var y,g;(y=this.xs)!=null&&y.reRender&&((g=this.xs)==null||g.reRender()),this.mediasSource&&this.ctx&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)})}}if((x=this.xs.sheet)!=null&&x.editor){const S=this.xs.sheet.editor.clear;this.xs.sheet.editor.clear=(...u)=>{var y,g;S.apply((g=(y=this.xs)==null?void 0:y.sheet)==null?void 0:g.editor,u),setTimeout(()=>{this.ctx&&this.mediasSource&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)})};const _=this.xs.sheet.editor.setOffset;this.xs.sheet.editor.setOffset=(...u)=>{var y,g;_.apply((g=(y=this.xs)==null?void 0:y.sheet)==null?void 0:g.editor,u),u.length>1&&(this.offset=u.shift()),this.ctx&&this.mediasSource&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}}const e=this.wrapper.querySelector("canvas");e&&(this.ctx=e.getContext("2d"))}renderExcel(x){return this.fileData=x,a1(x).then(e=>{var S;if(!e._worksheets||e._worksheets.length===0)throw new Error("未获取到数据,可能文件格式不正确或文件已损坏");const{workbookData:_,medias:u,workbookSource:y}=u1(e,this.options);this.mediasSource=u,this.workbookDataSource=y,this.offset=void 0,this.sheetIndex=1,ic(),(S=this.xs)==null||S.loadData(_),this.ctx&&this.mediasSource&&this.offset&&Ho(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}).catch(e=>{var S;return this.mediasSource=[],this.workbookDataSource={_worksheets:[]},ic(),(S=this.xs)==null||S.loadData({}),Promise.reject(e)})}hack(){if(!this.wrapper)return;const x=rs.debounce(d1,200).bind(this,this.wrapper);this.observer=new MutationObserver(x);const e={attributes:!0,childList:!0,subtree:!0};this.observer.observe(this.wrapper,e),x()}}const T1=(H,x)=>{if(!x)return Promise.reject();const e=new v1(x);return(()=>new Promise((_,u)=>{const y=new FileReader;y.readAsArrayBuffer(H),y.onload=()=>{y.result?_(y==null?void 0:y.result):u()}}))().then(_=>{e.renderExcel(_)})};export{T1 as renderExcel}; diff --git a/assets/chunks/pdf-1f534069.cfd1b720.js b/assets/chunks/pdf-6e38f826.8a63f27e.js similarity index 99% rename from assets/chunks/pdf-1f534069.cfd1b720.js rename to assets/chunks/pdf-6e38f826.8a63f27e.js index 7fc9aad7f..0c5f48780 100644 --- a/assets/chunks/pdf-1f534069.cfd1b720.js +++ b/assets/chunks/pdf-6e38f826.8a63f27e.js @@ -1 +1 @@ -import{l as Y}from"../app.4cfeba13.js";import"./framework.6fe2e870.js";import"./theme.eee41b28.js";var w=Object.defineProperty,R=(A,g,I)=>g in A?w(A,g,{enumerable:!0,configurable:!0,writable:!0,value:I}):A[g]=I,G=(A,g,I)=>(R(A,typeof g!="symbol"?g+"":g,I),I);const N="LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKICoKICogICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saW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AgICAgICBleHBvcnRzLnN0cmluZ1RvVVRGOFN0cmluZyA9IHN0cmluZ1RvVVRGOFN0cmluZzsKICAgICAgICAgICAgICAgIGV4cG9ydHMudW5yZWFjaGFibGUgPSB1bnJlYWNoYWJsZTsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXRmOFN0cmluZ1RvU3RyaW5nID0gdXRmOFN0cmluZ1RvU3RyaW5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy53YXJuID0gd2FybjsKICAgICAgICAgICAgICAgIGlmICghZ2xvYmFsVGhpcy5fcGRmanNDb21wYXRpYmlsaXR5Q2hlY2tlZCkgewogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuX3BkZmpzQ29tcGF0aWJpbGl0eUNoZWNrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oMik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBJREVOVElUWV9NQVRSSVggPSBbMSwgMCwgMCwgMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLklERU5USVRZX01BVFJJWCA9IElERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgIGNvbnN0IEZPTlRfSURFTlRJVFlfTUFUUklYID0gWzAuMDAxLCAwLCAwLCAwLjAwMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLkZPTlRfSURFTlRJVFlfTUFUUklYID0gRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfSU1BR0VfU0laRV9UT19DQUNIRSA9IDEwZTY7CiAgICAgICAgICAgICAgICBleHBvcnRzLk1BWF9JTUFHRV9TSVpFX1RPX0NBQ0hFID0gTUFYX0lNQUdFX1NJWkVfVE9fQ0FDSEU7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0ZBQ1RPUiA9IDEuMzU7CiAgICAgICAgICAgICAgICBleHBvcnRzLkxJTkVfRkFDVE9SID0gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0RFU0NFTlRfRkFDVE9SID0gMC4zNTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTElORV9ERVNDRU5UX0ZBQ1RPUiA9IExJTkVfREVTQ0VOVF9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBCQVNFTElORV9GQUNUT1IgPSBMSU5FX0RFU0NFTlRfRkFDVE9SIC8gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJBU0VMSU5FX0ZBQ1RPUiA9IEJBU0VMSU5FX0ZBQ1RPUjsKICAgICAgICAgICAgICAgIGNvbnN0IFJlbmRlcmluZ0ludGVudEZsYWcgPSB7CiAgICAgICAgICAgICAgICAgICAgQU5ZOiAweDAxLAogICAgICAgICAgICAgICAgICAgIERJU1BMQVk6IDB4MDIsCiAgICAgICAgICAgICAgICAgICAgUFJJTlQ6IDB4MDQsCiAgICAgICAgICAgICAgICAgICAgU0FWRTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19GT1JNUzogMHgxMCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19TVE9SQUdFOiAweDIwLAogICAgICAgICAgICAgICAgICAgIEFOTk9UQVRJT05TX0RJU0FCTEU6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgT1BMSVNUOiAweDEwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nSW50ZW50RmxhZyA9IFJlbmRlcmluZ0ludGVudEZsYWc7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTW9kZSA9IHsKICAgICAgICAgICAgICAgICAgICBESVNBQkxFOiAwLAogICAgICAgICAgICAgICAgICAgIEVOQUJMRTogMSwKICAgICAgICAgICAgICAgICAgICBFTkFCTEVfRk9STVM6IDIsCiAgICAgICAgICAgICAgICAgICAgRU5BQkxFX1NUT1JBR0U6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Nb2RlID0gQW5ub3RhdGlvbk1vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gInBkZmpzX2ludGVybmFsX2VkaXRvcl8iOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gQW5ub3RhdGlvbkVkaXRvclByZWZpeDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JUeXBlID0gewogICAgICAgICAgICAgICAgICAgIERJU0FCTEU6IC0xLAogICAgICAgICAgICAgICAgICAgIE5PTkU6IDAsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFQ6IDMsCiAgICAgICAgICAgICAgICAgICAgSU5LOiAxNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclR5cGUgPSBBbm5vdGF0aW9uRWRpdG9yVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlID0gewogICAgICAgICAgICAgICAgICAgIEZSRUVURVhUX1NJWkU6IDEsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfQ09MT1I6IDIsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfT1BBQ0lUWTogMywKICAgICAgICAgICAgICAgICAgICBJTktfQ09MT1I6IDExLAogICAgICAgICAgICAgICAgICAgIElOS19USElDS05FU1M6IDEyLAogICAgICAgICAgICAgICAgICAgIElOS19PUEFDSVRZOiAxMwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUgPSBBbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFBlcm1pc3Npb25GbGFnID0gewogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9DT05URU5UUzogMHgwOCwKICAgICAgICAgICAgICAgICAgICBDT1BZOiAweDEwLAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9BTk5PVEFUSU9OUzogMHgyMCwKICAgICAgICAgICAgICAgICAgICBGSUxMX0lOVEVSQUNUSVZFX0ZPUk1TOiAweDEwMCwKICAgICAgICAgICAgICAgICAgICBDT1BZX0ZPUl9BQ0NFU1NJQklMSVRZOiAweDIwMCwKICAgICAgICAgICAgICAgICAgICBBU1NFTUJMRTogMHg0MDAsCiAgICAgICAgICAgICAgICAgICAgUFJJTlRfSElHSF9RVUFMSVRZOiAweDgwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUGVybWlzc2lvbkZsYWcgPSBQZXJtaXNzaW9uRmxhZzsKICAgICAgICAgICAgICAgIGNvbnN0IFRleHRSZW5kZXJpbmdNb2RlID0gewogICAgICAgICAgICAgICAgICAgIEZJTEw6IDAsCiAgICAgICAgICAgICAgICAgICAgU1RST0tFOiAxLAogICAgICAgICAgICAgICAgICAgIEZJTExfU1RST0tFOiAyLAogICAgICAgICAgICAgICAgICAgIElOVklTSUJMRTogMywKICAgICAgICAgICAgICAgICAgICBGSUxMX0FERF9UT19QQVRIOiA0LAogICAgICAgICAgICAgICAgICAgIFNUUk9LRV9BRERfVE9fUEFUSDogNSwKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9BRERfVE9fUEFUSDogNiwKICAgICAgICAgICAgICAgICAgICBBRERfVE9fUEFUSDogNywKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9NQVNLOiAzLAogICAgICAgICAgICAgICAgICAgIEFERF9UT19QQVRIX0ZMQUc6IDQKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRSZW5kZXJpbmdNb2RlID0gVGV4dFJlbmRlcmluZ01vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBJbWFnZUtpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JBWVNDQUxFXzFCUFA6IDEsCiAgICAgICAgICAgICAgICAgICAgUkdCXzI0QlBQOiAyLAogICAgICAgICAgICAgICAgICAgIFJHQkFfMzJCUFA6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkltYWdlS2luZCA9IEltYWdlS2luZDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25UeXBlID0gewogICAgICAgICAgICAgICAgICAgIFRFWFQ6IDEsCiAgICAgICAgICAgICAgICAgICAgTElOSzogMiwKICAgICAgICAgICAgICAgICAgICBGUkVFVEVYVDogMywKICAgICAgICAgICAgICAgICAgICBMSU5FOiA0LAogICAgICAgICAgICAgICAgICAgIFNRVUFSRTogNSwKICAgICAgICAgICAgICAgICAgICBDSVJDTEU6IDYsCiAgICAgICAgICAgICAgICAgICAgUE9MWUdPTjogNywKICAgICAgICAgICAgICAgICAgICBQT0xZTElORTogOCwKICAgICAgICAgICAgICAgICAgICBISUdITElHSFQ6IDksCiAgICAgICAgICAgICAgICAgICAgVU5ERVJMSU5FOiAxMCwKICAgICAgICAgICAgICAgICAgICBTUVVJR0dMWTogMTEsCiAgICAgICAgICAgICAgICAgICAgU1RSSUtFT1VUOiAxMiwKICAgICAgICAgICAgICAgICAgICBTVEFNUDogMTMsCiAgICAgICAgICAgICAgICAgICAgQ0FSRVQ6IDE0LAogICAgICAgICAgICAgICAgICAgIElOSzogMTUsCiAgICAgICAgICAgICAgICAgICAgUE9QVVA6IDE2LAogICAgICAgICAgICAgICAgICAgIEZJTEVBVFRBQ0hNRU5UOiAxNywKICAgICAgICAgICAgICAgICAgICBTT1VORDogMTgsCiAgICAgICAgICAgICAgICAgICAgTU9WSUU6IDE5LAogICAgICAgICAgICAgICAgICAgIFdJREdFVDogMjAsCiAgICAgICAgICAgICAgICAgICAgU0NSRUVOOiAyMSwKICAgICAgICAgICAgICAgICAgICBQUklOVEVSTUFSSzogMjIsCiAgICAgICAgICAgICAgICAgICAgVFJBUE5FVDogMjMsCiAgICAgICAgICAgICAgICAgICAgV0FURVJNQVJLOiAyNCwKICAgICAgICAgICAgICAgICAgICBUSFJFRUQ6IDI1LAogICAgICAgICAgICAgICAgICAgIFJFREFDVDogMjYKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25UeXBlID0gQW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBSRVZJRVc6ICJSZXZpZXciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTWFya2VkU3RhdGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBVTk1BUktFRDogIlVubWFya2VkIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbk1hcmtlZFN0YXRlID0gQW5ub3RhdGlvbk1hcmtlZFN0YXRlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvblJldmlld1N0YXRlID0gewogICAgICAgICAgICAgICAgICAgIEFDQ0VQVEVEOiAiQWNjZXB0ZWQiLAogICAgICAgICAgICAgICAgICAgIFJFSkVDVEVEOiAiUmVqZWN0ZWQiLAogICAgICAgICAgICAgICAgICAgIENBTkNFTExFRDogIkNhbmNlbGxlZCIsCiAgICAgICAgICAgICAgICAgICAgQ09NUExFVEVEOiAiQ29tcGxldGVkIiwKICAgICAgICAgICAgICAgICAgICBOT05FOiAiTm9uZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25SZXZpZXdTdGF0ZSA9IEFubm90YXRpb25SZXZpZXdTdGF0ZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25SZXBseVR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JPVVA6ICJHcm91cCIsCiAgICAgICAgICAgICAgICAgICAgUkVQTFk6ICJSIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblJlcGx5VHlwZSA9IEFubm90YXRpb25SZXBseVR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBJTlZJU0lCTEU6IDB4MDEsCiAgICAgICAgICAgICAgICAgICAgSElEREVOOiAweDAyLAogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE5PWk9PTTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBOT1JPVEFURTogMHgxMCwKICAgICAgICAgICAgICAgICAgICBOT1ZJRVc6IDB4MjAsCiAgICAgICAgICAgICAgICAgICAgUkVBRE9OTFk6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEOiAweDgwLAogICAgICAgICAgICAgICAgICAgIFRPR0dMRU5PVklFVzogMHgxMDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEQ09OVEVOVFM6IDB4MjAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRmxhZyA9IEFubm90YXRpb25GbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkZpZWxkRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBSRUFET05MWTogMHgwMDAwMDAxLAogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEOiAweDAwMDAwMDIsCiAgICAgICAgICAgICAgICAgICAgTk9FWFBPUlQ6IDB4MDAwMDAwNCwKICAgICAgICAgICAgICAgICAgICBNVUxUSUxJTkU6IDB4MDAwMTAwMCwKICAgICAgICAgICAgICAgICAgICBQQVNTV09SRDogMHgwMDAyMDAwLAogICAgICAgICAgICAgICAgICAgIE5PVE9HR0xFVE9PRkY6IDB4MDAwNDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJTzogMHgwMDA4MDAwLAogICAgICAgICAgICAgICAgICAgIFBVU0hCVVRUT046IDB4MDAxMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01CTzogMHgwMDIwMDAwLAogICAgICAgICAgICAgICAgICAgIEVESVQ6IDB4MDA0MDAwMCwKICAgICAgICAgICAgICAgICAgICBTT1JUOiAweDAwODAwMDAsCiAgICAgICAgICAgICAgICAgICAgRklMRVNFTEVDVDogMHgwMTAwMDAwLAogICAgICAgICAgICAgICAgICAgIE1VTFRJU0VMRUNUOiAweDAyMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTUEVMTENIRUNLOiAweDA0MDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTQ1JPTEw6IDB4MDgwMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01COiAweDEwMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgUklDSFRFWFQ6IDB4MjAwMDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJT1NJTlVOSVNPTjogMHgyMDAwMDAwLAogICAgICAgICAgICAgICAgICAgIENPTU1JVE9OU0VMQ0hBTkdFOiAweDQwMDAwMDAKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25GaWVsZEZsYWcgPSBBbm5vdGF0aW9uRmllbGRGbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkJvcmRlclN0eWxlVHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBTT0xJRDogMSwKICAgICAgICAgICAgICAgICAgICBEQVNIRUQ6IDIsCiAgICAgICAgICAgICAgICAgICAgQkVWRUxFRDogMywKICAgICAgICAgICAgICAgICAgICBJTlNFVDogNCwKICAgICAgICAgICAgICAgICAgICBVTkRFUkxJTkU6IDUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUgPSBBbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBFOiAiTW91c2UgRW50ZXIiLAogICAgICAgICAgICAgICAgICAgIFg6ICJNb3VzZSBFeGl0IiwKICAgICAgICAgICAgICAgICAgICBEOiAiTW91c2UgRG93biIsCiAgICAgICAgICAgICAgICAgICAgVTogIk1vdXNlIFVwIiwKICAgICAgICAgICAgICAgICAgICBGbzogIkZvY3VzIiwKICAgICAgICAgICAgICAgICAgICBCbDogIkJsdXIiLAogICAgICAgICAgICAgICAgICAgIFBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIFBDOiAiUGFnZUNsb3NlIiwKICAgICAgICAgICAgICAgICAgICBQVjogIlBhZ2VWaXNpYmxlIiwKICAgICAgICAgICAgICAgICAgICBQSTogIlBhZ2VJbnZpc2libGUiLAogICAgICAgICAgICAgICAgICAgIEs6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgIEY6ICJGb3JtYXQiLAogICAgICAgICAgICAgICAgICAgIFY6ICJWYWxpZGF0ZSIsCiAgICAgICAgICAgICAgICAgICAgQzogIkNhbGN1bGF0ZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25BY3Rpb25FdmVudFR5cGUgPSBBbm5vdGF0aW9uQWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgRG9jdW1lbnRBY3Rpb25FdmVudFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgV0M6ICJXaWxsQ2xvc2UiLAogICAgICAgICAgICAgICAgICAgIFdTOiAiV2lsbFNhdmUiLAogICAgICAgICAgICAgICAgICAgIERTOiAiRGlkU2F2ZSIsCiAgICAgICAgICAgICAgICAgICAgV1A6ICJXaWxsUHJpbnQiLAogICAgICAgICAgICAgICAgICAgIERQOiAiRGlkUHJpbnQiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Eb2N1bWVudEFjdGlvbkV2ZW50VHlwZSA9IERvY3VtZW50QWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgUGFnZUFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIEM6ICJQYWdlQ2xvc2UiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlQWN0aW9uRXZlbnRUeXBlID0gUGFnZUFjdGlvbkV2ZW50VHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFZlcmJvc2l0eUxldmVsID0gewogICAgICAgICAgICAgICAgICAgIEVSUk9SUzogMCwKICAgICAgICAgICAgICAgICAgICBXQVJOSU5HUzogMSwKICAgICAgICAgICAgICAgICAgICBJTkZPUzogNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVmVyYm9zaXR5TGV2ZWwgPSBWZXJib3NpdHlMZXZlbDsKICAgICAgICAgICAgICAgIGNvbnN0IENNYXBDb21wcmVzc2lvblR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTk9ORTogMCwKICAgICAgICAgICAgICAgICAgICBCSU5BUlk6IDEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkNNYXBDb21wcmVzc2lvblR5cGUgPSBDTWFwQ29tcHJlc3Npb25UeXBlOwogICAgICAgICAgICAgICAgY29uc3QgT1BTID0gewogICAgICAgICAgICAgICAgICAgIGRlcGVuZGVuY3k6IDEsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZVdpZHRoOiAyLAogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXA6IDMsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW46IDQsCiAgICAgICAgICAgICAgICAgICAgc2V0TWl0ZXJMaW1pdDogNSwKICAgICAgICAgICAgICAgICAgICBzZXREYXNoOiA2LAogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudDogNywKICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzczogOCwKICAgICAgICAgICAgICAgICAgICBzZXRHU3RhdGU6IDksCiAgICAgICAgICAgICAgICAgICAgc2F2ZTogMTAsCiAgICAgICAgICAgICAgICAgICAgcmVzdG9yZTogMTEsCiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiAxMiwKICAgICAgICAgICAgICAgICAgICBtb3ZlVG86IDEzLAogICAgICAgICAgICAgICAgICAgIGxpbmVUbzogMTQsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzogMTUsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzI6IDE2LAogICAgICAgICAgICAgICAgICAgIGN1cnZlVG8zOiAxNywKICAgICAgICAgICAgICAgICAgICBjbG9zZVBhdGg6IDE4LAogICAgICAgICAgICAgICAgICAgIHJlY3RhbmdsZTogMTksCiAgICAgICAgICAgICAgICAgICAgc3Ryb2tlOiAyMCwKICAgICAgICAgICAgICAgICAgICBjbG9zZVN0cm9rZTogMjEsCiAgICAgICAgICAgICAgICAgICAgZmlsbDogMjIsCiAgICAgICAgICAgICAgICAgICAgZW9GaWxsOiAyMywKICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlOiAyNCwKICAgICAgICAgICAgICAgICAgICBlb0ZpbGxTdHJva2U6IDI1LAogICAgICAgICAgICAgICAgICAgIGNsb3NlRmlsbFN0cm9rZTogMjYsCiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2U6IDI3LAogICAgICAgICAgICAgICAgICAgIGVuZFBhdGg6IDI4LAogICAgICAgICAgICAgICAgICAgIGNsaXA6IDI5LAogICAgICAgICAgICAgICAgICAgIGVvQ2xpcDogMzAsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0OiAzMSwKICAgICAgICAgICAgICAgICAgICBlbmRUZXh0OiAzMiwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyU3BhY2luZzogMzMsCiAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmc6IDM0LAogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZTogMzUsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZzogMzYsCiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udDogMzcsCiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGU6IDM4LAogICAgICAgICAgICAgICAgICAgIHNldFRleHRSaXNlOiAzOSwKICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dDogNDAsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0OiA0MSwKICAgICAgICAgICAgICAgICAgICBzZXRUZXh0TWF0cml4OiA0MiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZTogNDMsCiAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQ6IDQ0LAogICAgICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0OiA0NSwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNob3dUZXh0OiA0NiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDogNDcsCiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoOiA0OCwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyV2lkdGhBbmRCb3VuZHM6IDQ5LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yU3BhY2U6IDUwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvclNwYWNlOiA1MSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDb2xvcjogNTIsCiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOOiA1MywKICAgICAgICAgICAgICAgICAgICBzZXRGaWxsQ29sb3I6IDU0LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck46IDU1LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUdyYXk6IDU2LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxHcmF5OiA1NywKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VSR0JDb2xvcjogNTgsCiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yOiA1OSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDTVlLQ29sb3I6IDYwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDTVlLQ29sb3I6IDYxLAogICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsOiA2MiwKICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlOiA2MywKICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YTogNjQsCiAgICAgICAgICAgICAgICAgICAgZW5kSW5saW5lSW1hZ2U6IDY1LAogICAgICAgICAgICAgICAgICAgIHBhaW50WE9iamVjdDogNjYsCiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50OiA2NywKICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wczogNjgsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50OiA2OSwKICAgICAgICAgICAgICAgICAgICBiZWdpbk1hcmtlZENvbnRlbnRQcm9wczogNzAsCiAgICAgICAgICAgICAgICAgICAgZW5kTWFya2VkQ29udGVudDogNzEsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Db21wYXQ6IDcyLAogICAgICAgICAgICAgICAgICAgIGVuZENvbXBhdDogNzMsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luOiA3NCwKICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kOiA3NSwKICAgICAgICAgICAgICAgICAgICBiZWdpbkdyb3VwOiA3NiwKICAgICAgICAgICAgICAgICAgICBlbmRHcm91cDogNzcsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Bbm5vdGF0aW9uOiA4MCwKICAgICAgICAgICAgICAgICAgICBlbmRBbm5vdGF0aW9uOiA4MSwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3Q6IDgzLAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwOiA4NCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdDogODUsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRJbmxpbmVJbWFnZVhPYmplY3Q6IDg2LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXA6IDg3LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0OiA4OCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3RSZXBlYXQ6IDg5LAogICAgICAgICAgICAgICAgICAgIHBhaW50U29saWRDb2xvckltYWdlTWFzazogOTAsCiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aDogOTEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLk9QUyA9IE9QUzsKICAgICAgICAgICAgICAgIGNvbnN0IFBhc3N3b3JkUmVzcG9uc2VzID0gewogICAgICAgICAgICAgICAgICAgIE5FRURfUEFTU1dPUkQ6IDEsCiAgICAgICAgICAgICAgICAgICAgSU5DT1JSRUNUX1BBU1NXT1JEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXNzd29yZFJlc3BvbnNlcyA9IFBhc3N3b3JkUmVzcG9uc2VzOwogICAgICAgICAgICAgICAgbGV0IHZlcmJvc2l0eSA9IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2V0VmVyYm9zaXR5TGV2ZWwobGV2ZWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihsZXZlbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5ID0gbGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0VmVyYm9zaXR5TGV2ZWwoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGluZm8obXNnKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZlcmJvc2l0eSA+PSBWZXJib3NpdHlMZXZlbC5JTkZPUykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhgSW5mbzogJHttc2d9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fybihtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmVyYm9zaXR5ID49IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGBXYXJuaW5nOiAke21zZ31gKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1bnJlYWNoYWJsZShtc2cpIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFzc2VydChjb25kLCBtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUobXNnKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNWYWxpZFByb3RvY29sKHVybCkgewogICAgICAgICAgICAgICAgICAgIGlmICghdXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh1cmwucHJvdG9jb2wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiaHR0cDoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJodHRwczoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJmdHA6IjoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibWFpbHRvOiI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRlbDoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYmFzZVVybCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBsZXQgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgdHlwZW9mIHVybCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLmFkZERlZmF1bHRQcm90b2NvbCAmJiB1cmwuc3RhcnRzV2l0aCgid3d3LiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZG90cyA9IHVybC5tYXRjaCgvXC4vZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvdHMgJiYgZG90cy5sZW5ndGggPj0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBgaHR0cDovLyR7dXJsfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMudHJ5Q29udmVydEVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gc3RyaW5nVG9VVEY4U3RyaW5nKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWJzb2x1dGVVcmwgPSBiYXNlVXJsID8gbmV3IFVSTCh1cmwsIGJhc2VVcmwpIDogbmV3IFVSTCh1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzVmFsaWRQcm90b2NvbChhYnNvbHV0ZVVybCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2hhZG93KG9iaiwgcHJvcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbm9uU2VyaWFsaXphYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBwcm9wLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhbm9uU2VyaWFsaXphYmxlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IEJhc2VFeGNlcHRpb24gPSBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uQ2xvc3VyZSgpIHsKICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uKG1lc3NhZ2UsIG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVucmVhY2hhYmxlKCJDYW5ub3QgaW5pdGlhbGl6ZSBCYXNlRXhjZXB0aW9uLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZSA9IG1lc3NhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEJhc2VFeGNlcHRpb24ucHJvdG90eXBlID0gbmV3IEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgQmFzZUV4Y2VwdGlvbi5jb25zdHJ1Y3RvciA9IEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VFeGNlcHRpb24gPSBCYXNlRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgUGFzc3dvcmRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGNvZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiUGFzc3dvcmRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlID0gY29kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBhc3N3b3JkRXhjZXB0aW9uID0gUGFzc3dvcmRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBVbmtub3duRXJyb3JFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiVW5rbm93bkVycm9yRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWlscyA9IGRldGFpbHM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Vbmtub3duRXJyb3JFeGNlcHRpb24gPSBVbmtub3duRXJyb3JFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBJbnZhbGlkUERGRXhjZXB0aW9uIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkludmFsaWRQREZFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkludmFsaWRQREZFeGNlcHRpb24gPSBJbnZhbGlkUERGRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgTWlzc2luZ1BERkV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihtc2csICJNaXNzaW5nUERGRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NaXNzaW5nUERGRXhjZXB0aW9uID0gTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZywgc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXR1cyA9IHN0YXR1czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiA9IFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIEZvcm1hdEVycm9yIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkZvcm1hdEVycm9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Gb3JtYXRFcnJvciA9IEZvcm1hdEVycm9yOwogICAgICAgICAgICAgICAgY2xhc3MgQWJvcnRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2cpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiQWJvcnRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkFib3J0RXhjZXB0aW9uID0gQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBieXRlc1RvU3RyaW5nKGJ5dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBieXRlcyAhPT0gIm9iamVjdCIgfHwgYnl0ZXMgPT09IG51bGwgfHwgYnl0ZXMubGVuZ3RoID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUoIkludmFsaWQgYXJndW1lbnQgZm9yIGJ5dGVzVG9TdHJpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9BUkdVTUVOVF9DT1VOVCA9IDgxOTI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZS5hcHBseShudWxsLCBieXRlcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0VuZCA9IE1hdGgubWluKGkgKyBNQVhfQVJHVU1FTlRfQ09VTlQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gYnl0ZXMuc3ViYXJyYXkoaSwgY2h1bmtFbmQpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb0J5dGVzKHN0cikgewogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RyICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICB1bnJlYWNoYWJsZSgiSW52YWxpZCBhcmd1bWVudCBmb3Igc3RyaW5nVG9CeXRlcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBzdHIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkobGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2ldID0gc3RyLmNoYXJDb2RlQXQoaSkgJiAweGZmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmczMih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHZhbHVlID4+IDI0ICYgMHhmZiwgdmFsdWUgPj4gMTYgJiAweGZmLCB2YWx1ZSA+PiA4ICYgMHhmZiwgdmFsdWUgJiAweGZmKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9iamVjdFNpemUob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKG9iaikubGVuZ3RoOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gb2JqZWN0RnJvbU1hcChtYXApIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNMaXR0bGVFbmRpYW4oKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyOCA9IG5ldyBVaW50OEFycmF5KDQpOwogICAgICAgICAgICAgICAgICAgIGJ1ZmZlcjhbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXczMiA9IG5ldyBVaW50MzJBcnJheShidWZmZXI4LmJ1ZmZlciwgMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXczMlswXSA9PT0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzRXZhbFN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBuZXcgRnVuY3Rpb24oIiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGZWF0dXJlVGVzdCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0xpdHRsZUVuZGlhbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNMaXR0bGVFbmRpYW4iLCBpc0xpdHRsZUVuZGlhbigpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0V2YWxTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzaGFkb3codGhpcywgImlzRXZhbFN1cHBvcnRlZCIsIGlzRXZhbFN1cHBvcnRlZCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQiLCB0eXBlb2YgT2Zmc2NyZWVuQ2FudmFzICE9PSAidW5kZWZpbmVkIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgcGxhdGZvcm0oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgbmF2aWdhdG9yID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW46IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1dpbjogbmF2aWdhdG9yLnBsYXRmb3JtLmluY2x1ZGVzKCJXaW4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBuYXZpZ2F0b3IucGxhdGZvcm0uaW5jbHVkZXMoIk1hYyIpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRmVhdHVyZVRlc3QgPSBGZWF0dXJlVGVzdDsKICAgICAgICAgICAgICAgIGNvbnN0IGhleE51bWJlcnMgPSBbLi4uQXJyYXkoMjU2KS5rZXlzKCldLm1hcChuID0+IG4udG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIikpOwogICAgICAgICAgICAgICAgY2xhc3MgVXRpbCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG1ha2VIZXhDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7aGV4TnVtYmVyc1tyXX0ke2hleE51bWJlcnNbZ119JHtoZXhOdW1iZXJzW2JdfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wID0gbWluTWF4WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzNdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IG1pbk1heFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzFdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm1bMl0gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzFdID0gdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gKj0gdHJhbnNmb3JtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsyXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0cmFuc2Zvcm0obTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbbTFbMF0gKiBtMlswXSArIG0xWzJdICogbTJbMV0sIG0xWzFdICogbTJbMF0gKyBtMVszXSAqIG0yWzFdLCBtMVswXSAqIG0yWzJdICsgbTFbMl0gKiBtMlszXSwgbTFbMV0gKiBtMlsyXSArIG0xWzNdICogbTJbM10sIG0xWzBdICogbTJbNF0gKyBtMVsyXSAqIG0yWzVdICsgbTFbNF0sIG0xWzFdICogbTJbNF0gKyBtMVszXSAqIG0yWzVdICsgbTFbNV1dOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYXBwbHlUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4dCA9IHBbMF0gKiBtWzBdICsgcFsxXSAqIG1bMl0gKyBtWzRdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5dCA9IHBbMF0gKiBtWzFdICsgcFsxXSAqIG1bM10gKyBtWzVdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3h0LCB5dF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhcHBseUludmVyc2VUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkID0gbVswXSAqIG1bM10gLSBtWzFdICogbVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHQgPSAocFswXSAqIG1bM10gLSBwWzFdICogbVsyXSArIG1bMl0gKiBtWzVdIC0gbVs0XSAqIG1bM10pIC8gZDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXQgPSAoLXBbMF0gKiBtWzFdICsgcFsxXSAqIG1bMF0gKyBtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeHQsIHl0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldEF4aWFsQWxpZ25lZEJvdW5kaW5nQm94KHIsIG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEgPSBVdGlsLmFwcGx5VHJhbnNmb3JtKHIsIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMiA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oci5zbGljZSgyLCA0KSwgbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzID0gVXRpbC5hcHBseVRyYW5zZm9ybShbclswXSwgclszXV0sIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNCA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JbMl0sIHJbMV1dLCBtKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbihwMVswXSwgcDJbMF0sIHAzWzBdLCBwNFswXSksIE1hdGgubWluKHAxWzFdLCBwMlsxXSwgcDNbMV0sIHA0WzFdKSwgTWF0aC5tYXgocDFbMF0sIHAyWzBdLCBwM1swXSwgcDRbMF0pLCBNYXRoLm1heChwMVsxXSwgcDJbMV0sIHAzWzFdLCBwNFsxXSldOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW52ZXJzZVRyYW5zZm9ybShtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzBdICogbVszXSAtIG1bMV0gKiBtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW21bM10gLyBkLCAtbVsxXSAvIGQsIC1tWzJdIC8gZCwgbVswXSAvIGQsIChtWzJdICogbVs1XSAtIG1bNF0gKiBtWzNdKSAvIGQsIChtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc3Bvc2UgPSBbbVswXSwgbVsyXSwgbVsxXSwgbVszXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBtWzBdICogdHJhbnNwb3NlWzBdICsgbVsxXSAqIHRyYW5zcG9zZVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IG1bMF0gKiB0cmFuc3Bvc2VbMV0gKyBtWzFdICogdHJhbnNwb3NlWzNdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gbVsyXSAqIHRyYW5zcG9zZVswXSArIG1bM10gKiB0cmFuc3Bvc2VbMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzJdICogdHJhbnNwb3NlWzFdICsgbVszXSAqIHRyYW5zcG9zZVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlyc3QgPSAoYSArIGQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2Vjb25kID0gTWF0aC5zcXJ0KChhICsgZCkgKiogMiAtIDQgKiAoYSAqIGQgLSBjICogYikpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ggPSBmaXJzdCArIHNlY29uZCB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzeSA9IGZpcnN0IC0gc2Vjb25kIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbTWF0aC5zcXJ0KHN4KSwgTWF0aC5zcXJ0KHN5KV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemVSZWN0KHJlY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgciA9IHJlY3Quc2xpY2UoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0WzBdID4gcmVjdFsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgclswXSA9IHJlY3RbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByWzJdID0gcmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVjdFsxXSA+IHJlY3RbM10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJbMV0gPSByZWN0WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgclszXSA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBpbnRlcnNlY3QocmVjdDEsIHJlY3QyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhMb3cgPSBNYXRoLm1heChNYXRoLm1pbihyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1pbihyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeEhpZ2ggPSBNYXRoLm1pbihNYXRoLm1heChyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1heChyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhMb3cgPiB4SGlnaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeUxvdyA9IE1hdGgubWF4KE1hdGgubWluKHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWluKHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5SGlnaCA9IE1hdGgubWluKE1hdGgubWF4KHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWF4KHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeUxvdyA+IHlIaWdoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hMb3csIHlMb3csIHhIaWdoLCB5SGlnaF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBiZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHZhbHVlcyA9IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzID0gW1tdLCBbXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhLCBiLCBjLCB0LCB0MSwgdDIsIGIyYWMsIHNxcnRiMmFjOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHgwIC0gMTIgKiB4MSArIDYgKiB4MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB4MCArIDkgKiB4MSAtIDkgKiB4MiArIDMgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHgxIC0gMyAqIHgwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHkwIC0gMTIgKiB5MSArIDYgKiB5MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB5MCArIDkgKiB5MSAtIDkgKiB5MiArIDMgKiB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHkxIC0gMyAqIHkwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKGEpIDwgMWUtMTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoYikgPCAxZS0xMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHZhbHVlcy5wdXNoKHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGIyYWMgPSBiICogYiAtIDQgKiBjICogYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNxcnRiMmFjID0gTWF0aC5zcXJ0KGIyYWMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MSA9ICgtYiArIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MiA9ICgtYiAtIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGogPSB0dmFsdWVzLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqbGVuID0gajsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGotLSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IHR2YWx1ZXNbal07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2pdID0gbXQgKiBtdCAqIG10ICogeDAgKyAzICogbXQgKiBtdCAqIHQgKiB4MSArIDMgKiBtdCAqIHQgKiB0ICogeDIgKyB0ICogdCAqIHQgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqXSA9IG10ICogbXQgKiBtdCAqIHkwICsgMyAqIG10ICogbXQgKiB0ICogeTEgKyAzICogbXQgKiB0ICogdCAqIHkyICsgdCAqIHQgKiB0ICogeTM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuXSA9IHkwOwogICAgICAgICAgICAgICAgICAgICAgICBib3VuZHNbMF1bamxlbiArIDFdID0geDM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdLmxlbmd0aCA9IGJvdW5kc1sxXS5sZW5ndGggPSBqbGVuICsgMjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbiguLi5ib3VuZHNbMF0pLCBNYXRoLm1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4LCAweDE3ZCwgMHgxMzEsIDB4MTQyLCAweDE1MywgMHgxNjEsIDB4MTdlLCAwLCAweDIwYWNdOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc3RyaW5nVG9QREZTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0clswXSA+PSAiXHhFRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVuY29kaW5nOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyWzBdID09PSAiXHhGRSIgJiYgc3RyWzFdID09PSAiXHhGRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuY29kaW5nID0gInV0Zi0xNmJlIjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdHJbMF0gPT09ICJceEZGIiAmJiBzdHJbMV0gPT09ICJceEZFIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5jb2RpbmcgPSAidXRmLTE2bGUiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0clswXSA9PT0gIlx4RUYiICYmIHN0clsxXSA9PT0gIlx4QkIiICYmIHN0clsyXSA9PT0gIlx4QkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNvZGluZyA9ICJ1dGYtOCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBzdHJpbmdUb0J5dGVzKHN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZXIuZGVjb2RlKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm4oYHN0cmluZ1RvUERGU3RyaW5nOiAiJHtleH0iLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHN0ci5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBQREZTdHJpbmdUcmFuc2xhdGVUYWJsZVtzdHIuY2hhckNvZGVBdChpKV07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKGNvZGUgPyBTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpIDogc3RyLmNoYXJBdChpKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb1VURjhTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudChlc2NhcGUoc3RyKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1dGY4U3RyaW5nVG9TdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZXNjYXBlKGVuY29kZVVSSUNvbXBvbmVudChzdHIpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlCdWZmZXIodikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgdiA9PT0gIm9iamVjdCIgJiYgdiAhPT0gbnVsbCAmJiB2LmJ5dGVMZW5ndGggIT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlFcXVhbChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFycjEubGVuZ3RoICE9PSBhcnIyLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGFycjEubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJyMVtpXSAhPT0gYXJyMltpXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0TW9kaWZpY2F0aW9uRGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IERhdGUoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbZGF0ZS5nZXRVVENGdWxsWWVhcigpLnRvU3RyaW5nKCksIChkYXRlLmdldFVUQ01vbnRoKCkgKyAxKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIiksIGRhdGUuZ2V0VVRDRGF0ZSgpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENIb3VycygpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENNaW51dGVzKCkudG9TdHJpbmcoKS5wYWRTdGFydCgyLCAiMCIpLCBkYXRlLmdldFVUQ1NlY29uZHMoKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIildOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBidWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSgpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaXNTZXR0bGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGNhcGFiaWxpdHksICJzZXR0bGVkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBnZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTZXR0bGVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlID0gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUgPSBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0ID0gZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja0RPTU1hdHJpeCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsVGhpcy5ET01NYXRyaXggfHwgIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2xvYmFsVGhpcy5ET01NYXRyaXggPSByZXF1aXJlKCJjYW52YXMiKS5ET01NYXRyaXg7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrUGF0aDJEKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlBhdGgyRCB8fCAhX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIENhbnZhc1JlbmRlcmluZ0NvbnRleHQyRAogICAgICAgICAgICAgICAgICAgIH0gPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJECiAgICAgICAgICAgICAgICAgICAgfSA9IHJlcXVpcmUoInBhdGgyZC1wb2x5ZmlsbCIpOwogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEID0gQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEOwogICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJEKGdsb2JhbFRoaXMpOwogICAgICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja1JlYWRhYmxlU3RyZWFtKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlJlYWRhYmxlU3RyZWFtIHx8ICFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuUmVhZGFibGVTdHJlYW0gPSByZXF1aXJlKCJ3ZWItc3RyZWFtcy1wb2x5ZmlsbC9kaXN0L3BvbnlmaWxsLmpzIikuUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrQXJyYXlBdCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg0KTsKICAgICAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgICAgICAoZnVuY3Rpb24gY2hlY2tUeXBlZEFycmF5QXQoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKFVpbnQ4QXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OCk7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrU3RydWN0dXJlZENsb25lKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLnN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTApOwogICAgICAgICAgICAgICAgfSkoKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgaXNOb2RlSlMgPSB0eXBlb2YgcHJvY2VzcyA9PT0gIm9iamVjdCIgJiYgcHJvY2VzcyArICIiID09PSAiW29iamVjdCBwcm9jZXNzXSIgJiYgIXByb2Nlc3MudmVyc2lvbnMubncgJiYgIShwcm9jZXNzLnZlcnNpb25zLmVsZWN0cm9uICYmIHByb2Nlc3MudHlwZSAmJiBwcm9jZXNzLnR5cGUgIT09ICJicm93c2VyIik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gaXNOb2RlSlM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oNSk7CiAgICAgICAgICAgICAgICB2YXIgZW50cnlVbmJpbmQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDc3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZW50cnlVbmJpbmQoJ0FycmF5JywgJ2F0Jyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciAkID0gX193X3BkZmpzX3JlcXVpcmVfXyg2KTsKICAgICAgICAgICAgICAgIHZhciB0b09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFkZFRvVW5zY29wYWJsZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcyKTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIHRhcmdldDogJ0FycmF5JywKICAgICAgICAgICAgICAgICAgICBwcm90bzogdHJ1ZQogICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgIGF0OiBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbGVuID0gbGVuZ3RoT2ZBcnJheUxpa2UoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBrID0gcmVsYXRpdmVJbmRleCA+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+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgRnVuY3Rpb25OYW1lID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZUl0ZXJhdG9yQ29uc3RydWN0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk0KTsKICAgICAgICAgICAgICAgIHZhciBnZXRQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODUpOwogICAgICAgICAgICAgICAgdmFyIHNldFByb3RvdHlwZU9mID0g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AgICAgIHZhciBFTlRSSUVTID0gJ2VudHJpZXMnOwogICAgICAgICAgICAgICAgdmFyIHJldHVyblRoaXMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoSXRlcmFibGUsIE5BTUUsIEl0ZXJhdG9yQ29uc3RydWN0b3IsIG5leHQsIERFRkFVTFQsIElTX1NFVCwgRk9SQ0VEKSB7CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlSXRlcmF0b3JDb25zdHJ1Y3RvcihJdGVyYXRvckNvbnN0cnVjdG9yLCBOQU1FLCBuZXh0KTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0SXRlcmF0aW9uTWV0aG9kID0gZnVuY3Rpb24gKEtJTkQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEtJTkQgPT09IERFRkFVTFQgJiYgZGVmYXVsdEl0ZXJhdG9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFCVUdHWV9TQUZBUklfSVRFUkFUT1JTICYmIEtJTkQgaW4gSXRlcmFibGVQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSXRlcmFibGVQcm90b3R5cGVbS0lORF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoS0lORCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBLRVlTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBrZXlzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVkFMVUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSXRlcmF0b3JDb25zdHJ1Y3Rvcih0aGlzLCBLSU5EKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBFTlRSSUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBlbnRyaWVzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBJdGVyYXRvckNvbnN0cnVjdG9yKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSBOQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJdGVyYWJsZVByb3RvdHlwZSA9IEl0ZXJhYmxlLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB2YXIgbmF0aXZlSXRlcmF0b3IgPSBJdGVyYWJsZVByb3RvdHlwZVtJVEVSQVRPUl0gfHwgSXRlcmFibGVQcm90b3R5cGVbJ0BAaXRlcmF0b3InXSB8fCBERUZBVUxUICYmIEl0ZXJhYmxlUHJvdG90eXBlW0RFRkFVTFRdOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0SXRlcmF0b3IgPSAhQlVHR1lfU0FGQVJJX0lURVJBVE9SUyAmJiBuYXRpdmVJdGVyYXRvciB8fCBnZXRJdGVyYXRpb25NZXRob2QoREVGQVVMVCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGFueU5hdGl2ZUl0ZXJhdG9yID0gTkFNRSA9PSAnQXJyYXknID8gSXRlcmFibGVQcm90b3R5cGUuZW50cmllcyB8fCBuYXRpdmVJdGVyYXRvciA6IG5hdGl2ZUl0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBDdXJyZW50SXRlcmF0b3JQcm90b3R5cGUsIG1ldGhvZHMsIEtFWTsKICAgICAgICAgICAgICAgICAgICBpZiAoYW55TmF0aXZlSXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlID0gZ2V0UHJvdG90eXBlT2YoYW55TmF0aXZlSXRlcmF0b3IuY2FsbChuZXcgSXRlcmFibGUoKSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlICE9PSBPYmplY3QucHJvdG90eXBlICYmIEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZS5uZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUlTX1BVUkUgJiYgZ2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlKSAhPT0gSXRlcmF0b3JQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlLCBJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghaXNDYWxsYWJsZShDdXJyZW50SXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgSVRFUkFUT1IsIHJldHVyblRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRvU3RyaW5nVGFnKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgVE9fU1RSSU5HX1RBRywgdHJ1ZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbVE9fU1RSSU5HX1RBR10gPSByZXR1cm5UaGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfRlVOQ1RJT05fTkFNRSAmJiBERUZBVUxUID09IFZBTFVFUyAmJiBuYXRpdmVJdGVyYXRvciAmJiBuYXRpdmVJdGVyYXRvci5uYW1lICE9PSBWQUxVRVMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19QVVJFICYmIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoSXRlcmFibGVQcm90b3R5cGUsICduYW1lJywgVkFMVUVTKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0SXRlcmF0b3IgPSBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGwobmF0aXZlSXRlcmF0b3IsIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoREVGQVVMVCkgewogICAgICAgICAgICAgICAgICAgICAgICBtZXRob2RzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzOiBnZXRJdGVyYXRpb25NZXRob2QoVkFMVUVTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleXM6IElTX1NFVCA/IGRlZmF1bHRJdGVyYXRvciA6IGdldEl0ZXJhdGlvbk1ldGhvZChLRVlTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJpZXM6IGdldEl0ZXJhdGlvbk1ldGhvZChFTlRSSUVTKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoRk9SQ0VEKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChLRVkgaW4gbWV0aG9kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9TQUZBUklfSVRFUkFUT1JTIHx8IElOQ09SUkVDVF9WQUxVRVNfTkFNRSB8fCAhKEtFWSBpbiBJdGVyYWJsZVByb3RvdHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgS0VZLCBtZXRob2RzW0tFWV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBOQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmNlZDogQlVHR1lfU0FGQVJJX0lURVJBVE9SUyB8fCBJTkNPUlJFQ1RfVkFMVUVTX05BTUUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIG1ldGhvZHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoKCFJU19QVVJFIHx8IEZPUkNFRCkgJiYgSXRlcmFibGVQcm90b3R5cGVbSVRFUkFUT1JdICE9PSBkZWZhdWx0SXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgSVRFUkFUT1IsIGRlZmF1bHRJdGVyYXRvciwgeyBuYW1lOiBERUZBVUxUIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbTkFNRV0gPSBkZWZhdWx0SXRlcmF0b3I7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGhvZHM7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvclByb3RvdHlwZSA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDk1KS5JdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciByZXR1cm5UaGlzID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKEl0ZXJhdG9yQ29uc3RydWN0b3IsIE5BTUUsIG5leHQsIEVOVU1FUkFCTEVfTkVYVCkgewogICAgICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gTkFNRSArICcgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yQ29uc3RydWN0b3IucHJvdG90eXBlID0gY3JlYXRlKEl0ZXJhdG9yUHJvdG90eXBlLCB7IG5leHQ6IGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigrIUVOVU1FUkFCTEVfTkVYVCwgbmV4dCkgfSk7CiAgICAgICAgICAgICAgICAgICAgc2V0VG9TdHJpbmdUYWcoSXRlcmF0b3JDb25zdHJ1Y3RvciwgVE9fU1RSSU5HX1RBRywgZmFsc2UsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yc1tUT19TVFJJTkdfVEFHXSA9IHJldHVyblRoaXM7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzMpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBCVUdHWV9TQUZBUklfSVRFUkFUT1JTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUsIFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZSwgYXJyYXlJdGVyYXRvcjsKICAgICAgICAgICAgICAgIGlmIChbXS5rZXlzKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXlJdGVyYXRvciA9IFtdLmtleXMoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnbmV4dCcgaW4gYXJyYXlJdGVyYXRvcikpCiAgICAgICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgPSBnZXRQcm90b3R5cGVPZihnZXRQcm90b3R5cGVPZihhcnJheUl0ZXJhdG9yKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgIT09IE9iamVjdC5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgTkVXX0lURVJBVE9SX1BST1RPVFlQRSA9ICFpc09iamVjdChJdGVyYXRvclByb3RvdHlwZSkgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciB0ZXN0ID0ge307CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yUHJvdG90eXBlW0lURVJBVE9SXS5jYWxsKHRlc3QpICE9PSB0ZXN0OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBpZiAoTkVXX0lURVJBVE9SX1BST1RPVFlQRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IHt9OwogICAgICAgICAgICAgICAgZWxzZSBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IGNyZWF0ZShJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoSXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oSXRlcmF0b3JQcm90b3R5cGUsIElURVJBVE9SLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0b3JQcm90b3R5cGU6IEl0ZXJhdG9yUHJvdG90eXBlLAogICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlM6IEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHRhcmdldCwgVEFHLCBTVEFUSUMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICYmICFTVEFUSUMpCiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IHRhcmdldC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAmJiAhaGFzT3duKHRhcmdldCwgVE9fU1RSSU5HX1RBRykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodGFyZ2V0LCBUT19TVFJJTkdfVEFHLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogVEFHCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodmFsdWUsIGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGRvbmUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUdfU1VQUE9SVCA9IF9fd19wZGZqc19yZXF1aXJlX18oODMpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUxKTsKICAgICAgICAgICAgICAgIHZhciB0b1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oOTkpOwogICAgICAgICAgICAgICAgaWYgKCFUT19TVFJJTkdfVEFHX1NVUFBPUlQpIHsKICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKE9iamVjdC5wcm90b3R5cGUsICd0b1N0cmluZycsIHRvU3RyaW5nLCB7IHVuc2FmZTogdHJ1ZSB9KTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyB7fS50b1N0cmluZyA6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnW29iamVjdCAnICsgY2xhc3NvZih0aGlzKSArICddJzsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMik7CiAgICAgICAgICAgICAgICB2YXIgY29sbGVjdGlvblN0cm9uZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIwKTsKICAgICAgICAgICAgICAgIGNvbGxlY3Rpb24oJ01hcCcsIGZ1bmN0aW9uIChpbml0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIE1hcCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGluaXQodGhpcywgYXJndW1lbnRzLmxlbmd0aCA/IGFyZ3VtZW50c1swXSA6IHVuZGVmaW5lZCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sIGNvbGxlY3Rpb25TdHJvbmcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzRm9yY2VkID0gX193X3BkZmpzX3JlcXVpcmVfXyg3MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsTWV0YWRhdGFNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMyk7CiAgICAgICAgICAgICAgICB2YXIgaXRlcmF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEwKTsKICAgICAgICAgICAgICAgIHZhciBhbkluc3RhbmNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc051bGxPclVuZGVmaW5lZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjaGVja0NvcnJlY3RuZXNzT2ZJdGVyYXRpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExOCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBpbmhlcml0SWZSZXF1aXJlZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTE5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKENPTlNUUlVDVE9SX05BTUUsIHdyYXBwZXIsIGNvbW1vbikgewogICAgICAgICAgICAgICAgICAgIHZhciBJU19NQVAgPSBDT05TVFJVQ1RPUl9OQU1FLmluZGV4T2YoJ01hcCcpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfV0VBSyA9IENPTlNUUlVDVE9SX05BTUUuaW5kZXhPZignV2VhaycpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgQURERVIgPSBJU19NQVAgPyAnc2V0JyA6ICdhZGQnOwogICAgICAgICAgICAgICAgICAgIHZhciBOYXRpdmVDb25zdHJ1Y3RvciA9IGdsb2JhbFtDT05TVFJVQ1RPUl9OQU1FXTsKICAgICAgICAgICAgICAgICAgICB2YXIgTmF0aXZlUHJvdG90eXBlID0gTmF0aXZlQ29uc3RydWN0b3IgJiYgTmF0aXZlQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IE5hdGl2ZUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBleHBvcnRlZCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBmaXhNZXRob2QgPSBmdW5jdGlvbiAoS0VZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1bmN1cnJpZWROYXRpdmVNZXRob2QgPSB1bmN1cnJ5VGhpcyhOYXRpdmVQcm90b3R5cGVbS0VZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oTmF0aXZlUHJvdG90eXBlLCBLRVksIEtFWSA9PSAnYWRkJyA/IGZ1bmN0aW9uIGFkZCh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIHZhbHVlID09PSAwID8gMCA6IHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdkZWxldGUnID8gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IEtFWSA9PSAnZ2V0JyA/IGZ1bmN0aW9uIGdldChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJU19XRUFLICYmICFpc09iamVjdChrZXkpID8gdW5kZWZpbmVkIDogdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdoYXMnID8gZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIHNldChrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmN1cnJpZWROYXRpdmVNZXRob2QodGhpcywga2V5ID09PSAwID8gMCA6IGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFJFUExBQ0UgPSBpc0ZvcmNlZChDT05TVFJVQ1RPUl9OQU1FLCAhaXNDYWxsYWJsZShOYXRpdmVDb25zdHJ1Y3RvcikgfHwgIShJU19XRUFLIHx8IE5hdGl2ZVByb3RvdHlwZS5mb3JFYWNoICYmICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcigpLmVudHJpZXMoKS5uZXh0KCk7CiAgICAgICAgICAgICAgICAgICAgfSkpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoUkVQTEFDRSkgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IGNvbW1vbi5nZXRDb25zdHJ1Y3Rvcih3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxNZXRhZGF0YU1vZHVsZS5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzRm9yY2VkKENPTlNUUlVDVE9SX05BTUUsIHRydWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnN0YW5jZSA9IG5ldyBDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgSEFTTlRfQ0hBSU5JTkcgPSBpbnN0YW5jZVtBRERFUl0oSVNfV0VBSyA/IHt9IDogLTAsIDEpICE9IGluc3RhbmNlOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgVEhST1dTX09OX1BSSU1JVElWRVMgPSBmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZS5oYXMoMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQUNDRVBUX0lURVJBQkxFUyA9IGNoZWNrQ29ycmVjdG5lc3NPZkl0ZXJhdGlvbihmdW5jdGlvbiAoaXRlcmFibGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcihpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQlVHR1lfWkVSTyA9ICFJU19XRUFLICYmIGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkaW5zdGFuY2UgPSBuZXcgTmF0aXZlQ29uc3RydWN0b3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IDU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW5zdGFuY2VbQURERVJdKGluZGV4LCBpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gISRpbnN0YW5jZS5oYXMoLTApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBQ0NFUFRfSVRFUkFCTEVTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKGR1bW15LCBpdGVyYWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuSW5zdGFuY2UoZHVtbXksIE5hdGl2ZVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBpbmhlcml0SWZSZXF1aXJlZChuZXcgTmF0aXZlQ29uc3RydWN0b3IoKSwgZHVtbXksIENvbnN0cnVjdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShpdGVyYWJsZSwgdGhhdFtBRERFUl0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQ6IHRoYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnN0cnVjdG9yLnByb3RvdHlwZSA9IE5hdGl2ZVByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5hdGl2ZVByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IENvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUSFJPV1NfT05fUFJJTUlUSVZFUyB8fCBCVUdHWV9aRVJPKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaXhNZXRob2QoJ2RlbGV0ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKCdoYXMnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElTX01BUCAmJiBmaXhNZXRob2QoJ2dldCcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9aRVJPIHx8IEhBU05UX0NIQUlOSU5HKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKElTX1dFQUsgJiYgTmF0aXZlUHJvdG90eXBlLmNsZWFyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE5hdGl2ZVByb3RvdHlwZS5jbGVhcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0ZWRbQ09OU1RSVUNUT1JfTkFNRV0gPSBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICAkKHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2xvYmFsOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBDb25zdHJ1Y3RvciAhPSBOYXRpdmVDb25zdHJ1Y3RvcgogICAgICAgICAgICAgICAgICAgIH0sIGV4cG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBzZXRUb1N0cmluZ1RhZyhDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19XRUFLKQogICAgICAgICAgICAgICAgICAgICAgICBjb21tb24uc2V0U3Ryb25nKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGlkZGVuS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNTgpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5TmFtZXNFeHRlcm5hbE1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA0KTsKICAgICAgICAgICAgICAgIHZhciBpc0V4dGVuc2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNyk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgRlJFRVpJTkcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwOSk7CiAgICAgICAgICAgICAgICB2YXIgUkVRVUlSRUQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIHZhciBNRVRBREFUQSA9IHVpZCgnbWV0YScpOwogICAgICAgICAgICAgICAgdmFyIGlkID0gMDsKICAgICAgICAgICAgICAgIHZhciBzZXRNZXRhZGF0YSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGl0LCBNRVRBREFUQSwgewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0SUQ6ICdPJyArIGlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWFrRGF0YToge30KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBmYXN0S2V5ID0gZnVuY3Rpb24gKGl0LCBjcmVhdGUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnc3ltYm9sJyA/IGl0IDogKHR5cGVvZiBpdCA9PSAnc3RyaW5nJyA/ICdTJyA6ICdQJykgKyBpdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bihpdCwgTUVUQURBVEEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFeHRlbnNpYmxlKGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnRic7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3JlYXRlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdFJzsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0TWV0YWRhdGEoaXQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRbTUVUQURBVEFdLm9iamVjdElEOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXRXZWFrRGF0YSA9IGZ1bmN0aW9uIChpdCwgY3JlYXRlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oaXQsIE1FVEFEQVRBKSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzRXh0ZW5zaWJsZShpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjcmVhdGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W01FVEFEQVRBXS53ZWFrRGF0YTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgb25GcmVlemUgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoRlJFRVpJTkcgJiYgUkVRVUlSRUQgJiYgaXNFeHRlbnNpYmxlKGl0KSAmJiAhaGFzT3duKGl0LCBNRVRBREFUQSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBtZXRhLmVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lcyA9IGdldE93blByb3BlcnR5TmFtZXNNb2R1bGUuZjsKICAgICAgICAgICAgICAgICAgICB2YXIgc3BsaWNlID0gdW5jdXJyeVRoaXMoW10uc3BsaWNlKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHRlc3RbTUVUQURBVEFdID0gMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0T3duUHJvcGVydHlOYW1lcyh0ZXN0KS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2V0T3duUHJvcGVydHlOYW1lcyhpdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuZ3RoID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdFtpXSA9PT0gTUVUQURBVEEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaWNlKHJlc3VsdCwgaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiAnT2JqZWN0JywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXQ6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZWQ6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSwgeyBnZXRPd25Qcm9wZXJ0eU5hbWVzOiBnZXRPd25Qcm9wZXJ0eU5hbWVzRXh0ZXJuYWxNb2R1bGUuZiB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIG1ldGEgPSBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBlbmFibGU6IGVuYWJsZSwKICAgICAgICAgICAgICAgICAgICBmYXN0S2V5OiBmYXN0S2V5LAogICAgICAgICAgICAgICAgICAgIGdldFdlYWtEYXRhOiBnZXRXZWFrRGF0YSwKICAgICAgICAgICAgICAgICAgICBvbkZyZWV6ZTogb25GcmVlemUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW01FVEFEQVRBXSA9IHRydWU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciAkZ2V0T3duUHJvcGVydHlOYW1lcyA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYxKS5mKTsKICAgICAgICAgICAgICAgIHZhciBhcnJheVNsaWNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDUpOwogICAgICAgICAgICAgICAgdmFyIHdpbmRvd05hbWVzID0gdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB3aW5kb3cgJiYgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMgPyBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh3aW5kb3cpIDogW107CiAgICAgICAgICAgICAgICB2YXIgZ2V0V2luZG93TmFtZXMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGdldE93blByb3BlcnR5TmFtZXMoaXQpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnJheVNsaWNlKHdpbmRvd05hbWVzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuZiA9IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93TmFtZXMgJiYgY2xhc3NvZihpdCkgPT0gJ1dpbmRvdycgPyBnZXRXaW5kb3dOYW1lcyhpdCkgOiAkZ2V0T3duUHJvcGVydHlOYW1lcyh0b0luZGV4ZWRPYmplY3QoaXQpKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvQWJzb2x1dGVJbmRleCA9IF9fd19wZGZqc19yZXF1aXJlX18oNjQpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgJEFycmF5ID0gQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgbWF4ID0gTWF0aC5tYXg7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChPLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciBrID0gdG9BYnNvbHV0ZUluZGV4KHN0YXJ0LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIHZhciBmaW4gPSB0b0Fic29sdXRlSW5kZXgoZW5kID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiBlbmQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9ICRBcnJheShtYXgoZmluIC0gaywgMCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIG4gPSAwOyBrIDwgZmluOyBrKyssIG4rKykKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkocmVzdWx0LCBuLCBPW2tdKTsKICAgICAgICAgICAgICAgICAgICByZXN1bHQubGVuZ3RoID0gbjsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIHRvUHJvcGVydHlLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIxKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5S2V5ID0gdG9Qcm9wZXJ0eUtleShrZXkpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9wZXJ0eUtleSBpbiBvYmplY3QpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBwcm9wZXJ0eUtleSwgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKDAsIHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3RbcHJvcGVydHlLZXldID0gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMTgpOwogICAgICAgICAgICAgICAgdmFyIEFSUkFZX0JVRkZFUl9OT05fRVhURU5TSUJMRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA4KTsKICAgICAgICAgICAgICAgIHZhciAkaXNFeHRlbnNpYmxlID0gT2JqZWN0LmlzRXh0ZW5zaWJsZTsKICAgICAgICAgICAgICAgIHZhciBGQUlMU19PTl9QUklNSVRJVkVTID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICRpc0V4dGVuc2libGUoMSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gRkFJTFNfT05fUFJJTUlUSVZFUyB8fCBBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgPyBmdW5jdGlvbiBpc0V4dGVuc2libGUoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmIChBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgJiYgY2xhc3NvZihpdCkgPT0gJ0FycmF5QnVmZmVyJykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkaXNFeHRlbnNpYmxlID8gJGlzRXh0ZW5zaWJsZShpdCkgOiB0cnVlOwogICAgICAgICAgICAgICAgfSA6ICRpc0V4dGVuc2libGU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEFycmF5QnVmZmVyID09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IG5ldyBBcnJheUJ1ZmZlcig4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5pc0V4dGVuc2libGUoYnVmZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShidWZmZXIsICdhJywgeyB2YWx1ZTogOCB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmlzRXh0ZW5zaWJsZShPYmplY3QucHJldmVudEV4dGVuc2lvbnMoe30pKTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgaXNBcnJheUl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTQpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdG9yQ2xvc2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNik7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBSZXN1bHQgPSBmdW5jdGlvbiAoc3RvcHBlZCwgcmVzdWx0KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdG9wcGVkID0gc3RvcHBlZDsKICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgUmVzdWx0UHJvdG90eXBlID0gUmVzdWx0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhYmxlLCB1bmJvdW5kRnVuY3Rpb24sIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IG9wdGlvbnMgJiYgb3B0aW9ucy50aGF0OwogICAgICAgICAgICAgICAgICAgIHZhciBBU19FTlRSSUVTID0gISEob3B0aW9ucyAmJiBvcHRpb25zLkFTX0VOVFJJRVMpOwogICAgICAgICAgICAgICAgICAgIHZhciBJU19SRUNPUkQgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfUkVDT1JEKTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfSVRFUkFUT1IgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgICAgIHZhciBJTlRFUlJVUFRFRCA9ICEhKG9wdGlvbnMgJiYgb3B0aW9ucy5JTlRFUlJVUFRFRCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZuID0gYmluZCh1bmJvdW5kRnVuY3Rpb24sIHRoYXQpOwogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvciwgaXRlckZuLCBpbmRleCwgbGVuZ3RoLCByZXN1bHQsIG5leHQsIHN0ZXA7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3AgPSBmdW5jdGlvbiAoY29uZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVyYXRvcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXJhdG9yQ2xvc2UoaXRlcmF0b3IsICdub3JtYWwnLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlc3VsdCh0cnVlLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIGNhbGxGbiA9IGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQVNfRU5UUklFUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWVbMF0sIHZhbHVlWzFdLCBzdG9wKSA6IGZuKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWUsIHN0b3ApIDogZm4odmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaWYgKElTX1JFQ09SRCkgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGl0ZXJhYmxlLml0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoSVNfSVRFUkFUT1IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0b3IgPSBpdGVyYWJsZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyRm4gPSBnZXRJdGVyYXRvck1ldGhvZChpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXRlckZuKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhpdGVyYWJsZSkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBcnJheUl0ZXJhdG9yTWV0aG9kKGl0ZXJGbikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW5kZXggPSAwLCBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZShpdGVyYWJsZSk7IGxlbmd0aCA+IGluZGV4OyBpbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gY2FsbEZuKGl0ZXJhYmxlW2luZGV4XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAmJiBpc1Byb3RvdHlwZU9mKFJlc3VsdFByb3RvdHlwZSwgcmVzdWx0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUmVzdWx0KGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGdldEl0ZXJhdG9yKGl0ZXJhYmxlLCBpdGVyRm4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0ID0gSVNfUkVDT1JEID8gaXRlcmFibGUubmV4dCA6IGl0ZXJhdG9yLm5leHQ7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCEoc3RlcCA9IGNhbGwobmV4dCwgaXRlcmF0b3IpKS5kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBjYWxsRm4oc3RlcC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvckNsb3NlKGl0ZXJhdG9yLCAndGhyb3cnLCBlcnJvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXN1bHQgPT0gJ29iamVjdCcgJiYgcmVzdWx0ICYmIGlzUHJvdG90eXBlT2YoUmVzdWx0UHJvdG90eXBlLCByZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZXN1bHQoZmFsc2UpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMik7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gdW5jdXJyeVRoaXModW5jdXJyeVRoaXMuYmluZCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChmbiwgdGhhdCkgewogICAgICAgICAgICAgICAgICAgIGFDYWxsYWJsZShmbik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQgPT09IHVuZGVmaW5lZCA/IGZuIDogTkFUSVZFX0JJTkQgPyBiaW5kKGZuLCB0aGF0KSA6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZuLmFwcGx5KHRoYXQsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZm4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY2xhc3NvZlJhdyhmbikgPT09ICdGdW5jdGlvbicpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhmbik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBBcnJheVByb3RvdHlwZSA9IEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ICE9PSB1bmRlZmluZWQgJiYgKEl0ZXJhdG9ycy5BcnJheSA9PT0gaXQgfHwgQXJyYXlQcm90b3R5cGVbSVRFUkFUT1JdID09PSBpdCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMzUpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCwgdXNpbmdJdGVyYXRvcikgewogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvck1ldGhvZCA9IGFyZ3VtZW50cy5sZW5ndGggPCAyID8gZ2V0SXRlcmF0b3JNZXRob2QoYXJndW1lbnQpIDogdXNpbmdJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoYUNhbGxhYmxlKGl0ZXJhdG9yTWV0aG9kKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFuT2JqZWN0KGNhbGwoaXRlcmF0b3JNZXRob2QsIGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TWV0aG9kKGl0LCBJVEVSQVRPUikgfHwgZ2V0TWV0aG9kKGl0LCAnQEBpdGVyYXRvcicpIHx8IEl0ZXJhdG9yc1tjbGFzc29mKGl0KV07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRNZXRob2QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMzKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhdG9yLCBraW5kLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclJlc3VsdCwgaW5uZXJFcnJvcjsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBnZXRNZXRob2QoaXRlcmF0b3IsICdyZXR1cm4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbm5lclJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09ICd0aHJvdycpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBjYWxsKGlubmVyUmVzdWx0LCBpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJFcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyUmVzdWx0ID0gZXJyb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSAndGhyb3cnKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJFcnJvcikKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgaW5uZXJSZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoaW5uZXJSZXN1bHQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzUHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI4KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQsIFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1Byb3RvdHlwZU9mKFByb3RvdHlwZSwgaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElURVJBVE9SID0gd2VsbEtub3duU3ltYm9sKCdpdGVyYXRvcicpOwogICAgICAgICAgICAgICAgdmFyIFNBRkVfQ0xPU0lORyA9IGZhbHNlOwogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICB2YXIgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICB2YXIgaXRlcmF0b3JXaXRoUmV0dXJuID0gewogICAgICAgICAgICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiAhIWNhbGxlZCsrIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICdyZXR1cm4nOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTQUZFX0NMT1NJTkcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBpdGVyYXRvcldpdGhSZXR1cm5bSVRFUkFUT1JdID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIEFycmF5LmZyb20oaXRlcmF0b3JXaXRoUmV0dXJuLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IDI7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZXhlYywgU0tJUF9DTE9TSU5HKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFTS0lQX0NMT1NJTkcgJiYgIVNBRkVfQ0xPU0lORykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJVEVSQVRJT05fU1VQUE9SVCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmplY3QgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0W0lURVJBVE9SXSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiBJVEVSQVRJT05fU1VQUE9SVCA9IHRydWUgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBleGVjKG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElURVJBVElPTl9TVVBQT1JUOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCR0aGlzLCBkdW1teSwgV3JhcHBlcikgewogICAgICAgICAgICAgICAgICAgIHZhciBOZXdUYXJnZXQsIE5ld1RhcmdldFByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YgJiYgaXNDYWxsYWJsZShOZXdUYXJnZXQgPSBkdW1teS5jb25zdHJ1Y3RvcikgJiYgTmV3VGFyZ2V0ICE9PSBXcmFwcGVyICYmIGlzT2JqZWN0KE5ld1RhcmdldFByb3RvdHlwZSA9IE5ld1RhcmdldC5wcm90b3R5cGUpICYmIE5ld1RhcmdldFByb3RvdHlwZSAhPT0gV3JhcHBlci5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKCR0aGlzLCBOZXdUYXJnZXRQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyMCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjcmVhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDczKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdElucyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIxKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGFuSW5zdGFuY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciBpdGVyYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTApOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIHNldFNwZWNpZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhc3RLZXkgPSAoX193X3BkZmpzX3JlcXVpcmVfXygxMDMpLmZhc3RLZXkpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBzZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5zZXQ7CiAgICAgICAgICAgICAgICB2YXIgaW50ZXJuYWxTdGF0ZUdldHRlckZvciA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0dGVyRm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29uc3RydWN0b3I6IGZ1bmN0aW9uICh3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKHRoYXQsIGl0ZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbkluc3RhbmNlKHRoYXQsIFByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoYXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDT05TVFJVQ1RPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBjcmVhdGUobnVsbCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3Q6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0OiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZTogMAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRlKGl0ZXJhYmxlLCB0aGF0W0FEREVSXSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0OiB0aGF0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBQcm90b3R5cGUgPSBDb25zdHJ1Y3Rvci5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gaW50ZXJuYWxTdGF0ZUdldHRlckZvcihDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmluZSA9IGZ1bmN0aW9uICh0aGF0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gZ2V0RW50cnkodGhhdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2aW91cywgaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS52YWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gZW50cnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCA9IGZhc3RLZXkoa2V5LCB0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldmlvdXM6IHByZXZpb3VzID0gc3RhdGUubGFzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVkOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5maXJzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuZmlyc3QgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZpb3VzLm5leHQgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLnNpemUrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCAhPT0gJ0YnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5pbmRleFtpbmRleF0gPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGF0OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0RW50cnkgPSBmdW5jdGlvbiAodGhhdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gZmFzdEtleShrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ICE9PSAnRicpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlLmluZGV4W2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoZW50cnkgPSBzdGF0ZS5maXJzdDsgZW50cnk7IGVudHJ5ID0gZW50cnkubmV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeS5rZXkgPT0ga2V5KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW5zKFByb3RvdHlwZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXI6IGZ1bmN0aW9uIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkYXRhID0gc3RhdGUuaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gc3RhdGUuZmlyc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGVudHJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkucHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS5wcmV2aW91cyA9IGVudHJ5LnByZXZpb3VzLm5leHQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBkYXRhW2VudHJ5LmluZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkgPSBlbnRyeS5uZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5maXJzdCA9IHN0YXRlLmxhc3QgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zaXplID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGF0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZW50cnkgPSBnZXRFbnRyeSh0aGF0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dCA9IGVudHJ5Lm5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdGF0ZS5pbmRleFtlbnRyeS5pbmRleF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXYubmV4dCA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dC5wcmV2aW91cyA9IHByZXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5maXJzdCA9PSBlbnRyeSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmZpcnN0ID0gbmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QgPT0gZW50cnkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gcHJldjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuc2l6ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0LnNpemUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yRWFjaDogZnVuY3Rpb24gZm9yRWFjaChjYWxsYmFja2ZuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYm91bmRGdW5jdGlvbiA9IGJpbmQoY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5maXJzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3VuZEZ1bmN0aW9uKGVudHJ5LnZhbHVlLCBlbnRyeS5rZXksIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhczogZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIWdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdElucyhQcm90b3R5cGUsIElTX01BUCA/IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IGdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVudHJ5ICYmIGVudHJ5LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24gc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmaW5lKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZDogZnVuY3Rpb24gYWRkKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZSh0aGlzLCB2YWx1ZSA9IHZhbHVlID09PSAwID8gMCA6IHZhbHVlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoUHJvdG90eXBlLCAnc2l6ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9uZzogZnVuY3Rpb24gKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIElURVJBVE9SX05BTUUgPSBDT05TVFJVQ1RPUl9OQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbENvbGxlY3Rpb25TdGF0ZSA9IGludGVybmFsU3RhdGVHZXR0ZXJGb3IoQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbEl0ZXJhdG9yU3RhdGUgPSBpbnRlcm5hbFN0YXRlR2V0dGVyRm9yKElURVJBVE9SX05BTUUpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVJdGVyYXRvcihDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSwgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBJVEVSQVRPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaXRlcmF0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IGdldEludGVybmFsQ29sbGVjdGlvblN0YXRlKGl0ZXJhdGVkKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3Q6IHVuZGVmaW5lZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsSXRlcmF0b3JTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IHN0YXRlLmxhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LnByZXZpb3VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS50YXJnZXQgfHwgIShzdGF0ZS5sYXN0ID0gZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5zdGF0ZS5maXJzdCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS50YXJnZXQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUl0ZXJSZXN1bHRPYmplY3QodW5kZWZpbmVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICdrZXlzJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChlbnRyeS5rZXksIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICd2YWx1ZXMnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGVudHJ5LnZhbHVlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkua2V5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIElTX01BUCA/ICdlbnRyaWVzJyA6ICd2YWx1ZXMnLCAhSVNfTUFQLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3BlY2llcyhDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNyYywgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBzcmMpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNyY1trZXldLCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTIyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgU1BFQ0lFUyA9IHdlbGxLbm93blN5bWJvbCgnc3BlY2llcycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoQ09OU1RSVUNUT1JfTkFNRSkgewogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IGdldEJ1aWx0SW4oQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTICYmIENvbnN0cnVjdG9yICYmICFDb25zdHJ1Y3RvcltTUEVDSUVTXSkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoQ29uc3RydWN0b3IsIFNQRUNJRVMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjQpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjb2xsZWN0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDIpOwogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb25TdHJvbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMCk7CiAgICAgICAgICAgICAgICBjb2xsZWN0aW9uKCdTZXQnLCBmdW5jdGlvbiAoaW5pdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBTZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbml0KHRoaXMsIGFyZ3VtZW50cy5sZW5ndGggPyBhcmd1bWVudHNbMF0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LCBjb2xsZWN0aW9uU3Ryb25nKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTI1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRCdWlsdGluID0gX193X3BkZmpzX3JlcXVpcmVfXygyNyk7CiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE3KTsKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIHVpZCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDQpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMjYpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Nyk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0ZUFyZ3VtZW50c0xlbmd0aCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRSZWdFeHBGbGFncyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI4KTsKICAgICAgICAgICAgICAgIHZhciBNYXBIZWxwZXJzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzApOwogICAgICAgICAgICAgICAgdmFyIFNldEhlbHBlcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMSk7CiAgICAgICAgICAgICAgICB2YXIgRVJST1JfU1RBQ0tfSU5TVEFMTEFCTEUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMik7CiAgICAgICAgICAgICAgICB2YXIgUFJPUEVSX1RSQU5TRkVSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzMpOwogICAgICAgICAgICAgICAgdmFyIE9iamVjdCA9IGdsb2JhbC5PYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXkgPSBnbG9iYWwuQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgRGF0ZSA9IGdsb2JhbC5EYXRlOwogICAgICAgICAgICAgICAgdmFyIEVycm9yID0gZ2xvYmFsLkVycm9yOwogICAgICAgICAgICAgICAgdmFyIEV2YWxFcnJvciA9IGdsb2JhbC5FdmFsRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUmFuZ2VFcnJvciA9IGdsb2JhbC5SYW5nZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJlZmVyZW5jZUVycm9yID0gZ2xvYmFsLlJlZmVyZW5jZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFN5bnRheEVycm9yID0gZ2xvYmFsLlN5bnRheEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVVJJRXJyb3IgPSBnbG9iYWwuVVJJRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUGVyZm9ybWFuY2VNYXJrID0gZ2xvYmFsLlBlcmZvcm1hbmNlTWFyazsKICAgICAgICAgICAgICAgIHZhciBXZWJBc3NlbWJseSA9IGdsb2JhbC5XZWJBc3NlbWJseTsKICAgICAgICAgICAgICAgIHZhciBDb21waWxlRXJyb3IgPSBXZWJBc3NlbWJseSAmJiBXZWJBc3NlbWJseS5Db21waWxlRXJyb3IgfHwgRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgTGlua0Vycm9yID0gV2ViQXNzZW1ibHkgJiYgV2ViQXNzZW1ibHkuTGlua0Vycm9yIHx8IEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJ1bnRpbWVFcnJvciA9IFdlYkFzc2VtYmx5ICYmIFdlYkFzc2VtYmx5LlJ1bnRpbWVFcnJvciB8fCBFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBET01FeGNlcHRpb24gPSBnZXRCdWlsdGluKCdET01FeGNlcHRpb24nKTsKICAgICAgICAgICAgICAgIHZhciBNYXAgPSBNYXBIZWxwZXJzLk1hcDsKICAgICAgICAgICAgICAgIHZhciBtYXBIYXMgPSBNYXBIZWxwZXJzLmhhczsKICAgICAgICAgICAgICAgIHZhciBtYXBHZXQgPSBNYXBIZWxwZXJzLmdldDsKICAgICAgICAgICAgICAgIHZhciBtYXBTZXQgPSBNYXBIZWxwZXJzLnNldDsKICAgICAgICAgICAgICAgIHZhciBTZXQgPSBTZXRIZWxwZXJzLlNldDsKICAgICAgICAgICAgICAgIHZhciBzZXRBZGQgPSBTZXRIZWxwZXJzLmFkZDsKICAgICAgICAgICAgICAgIHZhciBvYmplY3RLZXlzID0gZ2V0QnVpbHRpbignT2JqZWN0JywgJ2tleXMnKTsKICAgICAgICAgICAgICAgIHZhciBwdXNoID0gdW5jdXJyeVRoaXMoW10ucHVzaCk7CiAgICAgICAgICAgICAgICB2YXIgdGhpc0Jvb2xlYW5WYWx1ZSA9IHVuY3VycnlUaGlzKHRydWUudmFsdWVPZik7CiAgICAgICAgICAgICAgICB2YXIgdGhpc051bWJlclZhbHVlID0gdW5jdXJyeVRoaXMoMS4wLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNTdHJpbmdWYWx1ZSA9IHVuY3VycnlUaGlzKCcnLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNUaW1lVmFsdWUgPSB1bmN1cnJ5VGhpcyhEYXRlLnByb3RvdHlwZS5nZXRUaW1lKTsKICAgICAgICAgICAgICAgIHZhciBQRVJGT1JNQU5DRV9NQVJLID0gdWlkKCdzdHJ1Y3R1cmVkQ2xvbmUnKTsKICAgICAgICAgICAgICAgIHZhciBEQVRBX0NMT05FX0VSUk9SID0gJ0RhdGFDbG9uZUVycm9yJzsKICAgICAgICAgICAgICAgIHZhciBUUkFOU0ZFUlJJTkcgPSAnVHJhbnNmZXJyaW5nJzsKICAgICAgICAgICAgICAgIHZhciBjaGVja0Jhc2ljU2VtYW50aWMgPSBmdW5jdGlvbiAoc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNldDEgPSBuZXcgZ2xvYmFsLlNldChbN10pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgc2V0MiA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHNldDEpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbnVtYmVyID0gc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24oT2JqZWN0KDcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNldDIgPT0gc2V0MSB8fCAhc2V0Mi5oYXMoNykgfHwgdHlwZW9mIG51bWJlciAhPSAnb2JqZWN0JyB8fCBudW1iZXIgIT0gNzsKICAgICAgICAgICAgICAgICAgICB9KSAmJiBzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbjsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY2hlY2tFcnJvcnNDbG9uaW5nID0gZnVuY3Rpb24gKHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uLCAkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gbmV3ICRFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGE6IGVycm9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYjogZXJyb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKHRlc3QgJiYgdGVzdC5hID09PSB0ZXN0LmIgJiYgdGVzdC5hIGluc3RhbmNlb2YgJEVycm9yICYmIHRlc3QuYS5zdGFjayA9PT0gZXJyb3Iuc3RhY2spOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBjaGVja05ld0Vycm9yc0Nsb25pbmdTZW1hbnRpYyA9IGZ1bmN0aW9uIChzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKG5ldyBnbG9iYWwuQWdncmVnYXRlRXJyb3IoWzFdLCBQRVJGT1JNQU5DRV9NQVJLLCB7I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U1hcms7CiAgICAgICAgICAgICAgICB2YXIgdGhyb3dVbmNsb25lYWJsZSA9IGZ1bmN0aW9uICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IERPTUV4Y2VwdGlvbignVW5jbG9uZWFibGUgdHlwZTogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0aHJvd1VucG9seWZpbGxhYmxlID0gZnVuY3Rpb24gKHR5cGUsIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oKGFjdGlvbiB8fCAnQ2xvbmluZycpICsgJyBvZiAnICsgdHlwZSArICcgY2Fubm90IGJlIHByb3Blcmx5IHBvbHlmaWxsZWQgaW4gdGhpcyBlbmdpbmUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRGF0YVRyYW5zZmVyID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBkYXRhVHJhbnNmZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5EYXRhVHJhbnNmZXIoKTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5DbGlwYm9hcmRFdmVudCgnJykuY2xpcGJvYXJkRGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGFUcmFuc2ZlciAmJiBkYXRhVHJhbnNmZXIuaXRlbXMgJiYgZGF0YVRyYW5zZmVyLmZpbGVzID8gZGF0YVRyYW5zZmVyIDogbnVsbDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgc3RydWN0dXJlZENsb25lSW50ZXJuYWwgPSBmdW5jdGlvbiAodmFsdWUsIG1hcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1N5bWJvbCh2YWx1ZSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5jbG9uZWFibGUoJ1N5bWJvbCcpOwogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hcEdldChtYXAsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgIHZhciB0eXBlID0gY2xhc3NvZih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgQywgbmFtZSwgY2xvbmVkLCBkYXRhVHJhbnNmZXIsIGksIGxlbmd0aCwga2V5cywga2V5LCBzb3VyY2UsIHRhcmdldCwgb3B0aW9uczsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQXJyYXkobGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdTZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnUmVnRXhwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBSZWdFeHAodmFsdWUuc291cmNlLCBnZXRSZWdFeHBGbGFncyh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQWdncmVnYXRlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBnZXRCdWlsdGluKCdBZ2dyZWdhdGVFcnJvcicpKFtdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRXZhbEVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gRXZhbEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JhbmdlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBSYW5nZUVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JlZmVyZW5jZUVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gUmVmZXJlbmNlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU3ludGF4RXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBTeW50YXhFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdUeXBlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBUeXBlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVVJJRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBVUklFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDb21waWxlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDb21waWxlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnTGlua0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gTGlua0Vycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1J1bnRpbWVFcnJvcic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IFJ1bnRpbWVFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NRXhjZXB0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01FeGNlcHRpb24odmFsdWUubWVzc2FnZSwgdmFsdWUubmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdEYXRhVmlldyc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDhBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1VpbnQ4QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50OENsYW1wZWRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDE2QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MTZBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDMyQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0JpZ0ludDY0QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdCaWdVaW50NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEMoc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuYnVmZmVyLCBtYXApLCB2YWx1ZS5ieXRlT2Zmc2V0LCB0eXBlID09PSAnRGF0YVZpZXcnID8gdmFsdWUuYnl0ZUxlbmd0aCA6IHZhbHVlLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUXVhZCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01RdWFkKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnAxLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZS5wMiwgbWFwKSwgc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUucDMsIG1hcCksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnA0LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZUxpc3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gY3JlYXRlRGF0YVRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVRyYW5zZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuZ3RoID0gbGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyLml0ZW1zLmFkZChzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZVtpXSwgbWFwKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IGRhdGFUcmFuc2Zlci5maWxlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdJbWFnZURhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgSW1hZ2VEYXRhKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmRhdGEsIG1hcCksIHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQsIHsgY29sb3JTcGFjZTogdmFsdWUuY29sb3JTcGFjZSB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXRpdmVSZXN0cmljdGVkU3RydWN0dXJlZENsb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmlnSW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IE9iamVjdCh2YWx1ZS52YWx1ZU9mKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Jvb2xlYW4nOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNCb29sZWFuVmFsdWUodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdOdW1iZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNOdW1iZXJWYWx1ZSh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1N0cmluZyc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBPYmplY3QodGhpc1N0cmluZ1ZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRGF0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgRGF0ZSh0aGlzVGltZVZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5EYXRhVmlldzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQyAmJiB0eXBlb2YgdmFsdWUuc2xpY2UgIT0gJ2Z1bmN0aW9uJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnNsaWNlID09ICdmdW5jdGlvbicgJiYgIXZhbHVlLnJlc2l6YWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB2YWx1ZS5zbGljZSgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zID0gJ21heEJ5dGVMZW5ndGgnIGluIHZhbHVlID8geyBtYXhCeXRlTGVuZ3RoOiB2YWx1ZS5tYXhCeXRlTGVuZ3RoIH0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBBcnJheUJ1ZmZlcihsZW5ndGgsIG9wdGlvbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2UgPSBuZXcgQyh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IG5ldyBDKGNsb25lZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnNldFVpbnQ4KGksIHNvdXJjZS5nZXRVaW50OChpKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0FycmF5QnVmZmVyIGlzIGRldGFjaGVkJywgREFUQV9DTE9ORV9FUlJPUik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU2hhcmVkQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmxvYic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IHZhbHVlLnNsaWNlKDAsIHZhbHVlLnNpemUsIHZhbHVlLnR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVBvaW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUG9pbnRSZWFkT25seSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDLmZyb21Qb2ludCA/IEMuZnJvbVBvaW50KHZhbHVlKSA6IG5ldyBDKHZhbHVlLngsIHZhbHVlLnksIHZhbHVlLnosIHZhbHVlLncpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVJlY3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdET01SZWN0UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tUmVjdCA/IEMuZnJvbVJlY3QodmFsdWUpIDogbmV3IEModmFsdWUueCwgdmFsdWUueSwgdmFsdWUud2lkdGgsIHZhbHVlLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tTWF0cml4ID8gQy5mcm9tTWF0cml4KHZhbHVlKSA6IG5ldyBDKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdWaWRlb0ZyYW1lJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZSh2YWx1ZS5jbG9uZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEZpbGUoW3ZhbHVlXSwgdmFsdWUubmFtZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Nyb3BUYXJnZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDcnlwdG9LZXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtRGlyZWN0b3J5SGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZVN5c3RlbUZpbGVIYW5kbGUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25JbmZvJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25NZXNzYWdlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW1hZ2VCaXRtYXAnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSVENDZXJ0aWZpY2F0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1dlYkFzc2VtYmx5Lk1vZHVsZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG1hcFNldChtYXAsIHZhbHVlLCBjbG9uZWQpOwogICAgICAgICAgICAgICAgICAgIGlmIChkZWVwKQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0FycmF5JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5cyA9IG9iamVjdEtleXModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDAsIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKGtleXMpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkoY2xvbmVkLCBrZXksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlW2tleV0sIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodiwgaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXBTZXQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbChrLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1NldCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRBZGQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoY2xvbmVkLCAnbWVzc2FnZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLm1lc3NhZ2UsIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24odmFsdWUsICdjYXVzZScpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdjYXVzZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmNhdXNlLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgPT0gJ0FnZ3JlZ2F0ZUVycm9yJykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQuZXJyb3JzID0gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuZXJyb3JzLCBtYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTUV4Y2VwdGlvbic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEVSUk9SX1NUQUNLX0lOU1RBTExBQkxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdzdGFjaycsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnN0YWNrLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmVkOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1RyYW5zZmVyID0gZnVuY3Rpb24gKHJhd1RyYW5zZmVyLCBtYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHJhd1RyYW5zZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKCdUcmFuc2ZlciBvcHRpb24gY2Fubm90IGJlIGNvbnZlcnRlZCB0byBhIHNlcXVlbmNlJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShyYXdUcmFuc2ZlciwgZnVuY3Rpb24gKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHB1c2godHJhbnNmZXIsIGFuT2JqZWN0KHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZSh0cmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlLCB0eXBlLCBDLCB0cmFuc2ZlcnJlZEFycmF5LCB0cmFuc2ZlcnJlZCwgY2FudmFzLCBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfVFJBTlNGRVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJyZWRBcnJheSA9IG5hdGl2ZVN0cnVjdHVyZWRDbG9uZSh0cmFuc2ZlciwgeyB0cmFuc2ZlcjogdHJhbnNmZXIgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdHJhbnNmZXJbaV0sIHRyYW5zZmVycmVkQXJyYXlbaSsrXSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRyYW5zZmVyW2krK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0R1cGxpY2F0ZSB0cmFuc2ZlcmFibGUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBjbGFzc29mKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ltYWdlQml0bWFwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5PZmZzY3JlZW5DYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDb25zdHJ1Y3RvcihDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcyA9IG5ldyBDKHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dCA9IGNhbnZhcy5nZXRDb250ZXh0KCdiaXRtYXByZW5kZXJlcicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC50cmFuc2ZlckZyb21JbWFnZUJpdG1hcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IGNhbnZhcy50cmFuc2ZlclRvSW1hZ2VCaXRtYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1ZpZGVvRnJhbWUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUuY2xvbmUpIHx8ICFpc0NhbGxhYmxlKHZhbHVlLmNsb3NlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVycmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUudHJhbnNmZXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlLCBUUkFOU0ZFUlJJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IHZhbHVlLnRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01lZGlhU291cmNlSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdNZXNzYWdlUG9ydCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnT2Zmc2NyZWVuQ2FudmFzJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSZWFkYWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVHJhbnNmb3JtU3RyZWFtJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdXcml0YWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2ZlcnJlZCA9PT0gdW5kZWZpbmVkKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ1RoaXMgb2JqZWN0IGNhbm5vdCBiZSB0cmFuc2ZlcnJlZDogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdmFsdWUsIHRyYW5zZmVycmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIGdsb2JhbDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIHNoYW06ICFQUk9QRVJfVFJBTlNGRVIsCiAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBGT1JDRURfUkVQTEFDRU1FTlQKICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICBzdHJ1Y3R1cmVkQ2xvbmU6IGZ1bmN0aW9uIHN0cnVjdHVyZWRDbG9uZSh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IHZhbGlkYXRlQXJndW1lbnRzTGVuZ3RoKGFyZ3VtZW50cy5sZW5ndGgsIDEpID4gMSAmJiAhaXNOdWxsT3JVbmRlZmluZWQoYXJndW1lbnRzWzFdKSA/IGFuT2JqZWN0KGFyZ3VtZW50c1sxXSkgOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2ZlciA9IG9wdGlvbnMgPyBvcHRpb25zLnRyYW5zZmVyIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWFwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmZXIgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5VG9UcmFuc2Zlcih0cmFuc2ZlciwgbWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpbnNwZWN0U291cmNlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NCk7CiAgICAgICAgICAgICAgICB2YXIgbm9vcCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZW1wdHkgPSBbXTsKICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3QgPSBnZXRCdWlsdEluKCdSZWZsZWN0JywgJ2NvbnN0cnVjdCcpOwogICAgICAgICAgICAgICAgdmFyIGNvbnN0cnVjdG9yUmVnRXhwID0gL15ccyooPzpjbGFzc3xmdW5jdGlvbilcYi87CiAgICAgICAgICAgICAgICB2YXIgZXhlYyA9IHVuY3VycnlUaGlzKGNvbnN0cnVjdG9yUmVnRXhwLmV4ZWMpOwogICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9UT19TVFJJTkcgPSAhY29uc3RydWN0b3JSZWdFeHAuZXhlYyhub29wKTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yTW9kZXJuID0gZnVuY3Rpb24gaXNDb25zdHJ1Y3Rvcihhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZShhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Qobm9vcCwgZW1wdHksIGFyZ3VtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgaXNDb25zdHJ1Y3RvckxlZ2FjeSA9IGZ1bmN0aW9uIGlzQ29uc3RydWN0b3IoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChjbGFzc29mKGFyZ3VtZW50KSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0Z1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR2VuZXJhdG9yRnVuY3Rpb24nOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0dlbmVyYXRvckZ1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOQ09SUkVDVF9UT19TVFJJTkcgfHwgISFleGVjKGNvbnN0cnVjdG9yUmVnRXhwLCBpbnNwZWN0U291cmNlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGlzQ29uc3RydWN0b3JMZWdhY3kuc2hhbSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFjb25zdHJ1Y3QgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBjYWxsZWQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ29uc3RydWN0b3JNb2Rlcm4oaXNDb25zdHJ1Y3Rvck1vZGVybi5jYWxsKSB8fCAhaXNDb25zdHJ1Y3Rvck1vZGVybihPYmplY3QpIHx8ICFpc0NvbnN0cnVjdG9yTW9kZXJuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9KSB8fCBjYWxsZWQ7CiAgICAgICAgICAgICAgICB9KSA/IGlzQ29uc3RydWN0b3JMZWdhY3kgOiBpc0NvbnN0cnVjdG9yTW9kZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHBhc3NlZCwgcmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAocGFzc2VkIDwgcmVxdWlyZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICRUeXBlRXJyb3IoJ05vdCBlbm91Z2ggYXJndW1lbnRzJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhc3NlZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBpc1Byb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXygyOCk7CiAgICAgICAgICAgICAgICB2YXIgcmVnRXhwRmxhZ3MgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyOSk7CiAgICAgICAgICAgICAgICB2YXIgUmVnRXhwUHJvdG90eXBlID0gUmVnRXhwLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKFIpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZmxhZ3MgPSBSLmZsYWdzOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmbGFncyA9PT0gdW5kZWZpbmVkICYmICEoJ2ZsYWdzJyBpbiBSZWdFeHBQcm90b3R5cGUpICYmICFoYXNPd24oUiwgJ2ZsYWdzJykgJiYgaXNQcm90b3R5cGVPZihSZWdFeHBQcm90b3R5cGUsIFIpID8gY2FsbChyZWdFeHBGbGFncywgUikgOiBmbGFnczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBhbk9iamVjdCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaGFzSW5kaWNlcykKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdkJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5nbG9iYWwpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnZyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaWdub3JlQ2FzZSkKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdpJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5tdWx0aWxpbmUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnbSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuZG90QWxsKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3MnOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGF0LnVuaWNvZGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQudW5pY29kZVNldHMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndic7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuc3RpY2t5KQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3knOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIE1hcFByb3RvdHlwZSA9IE1hcC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBNYXA6IE1hcCwKICAgICAgICAgICAgICAgICAgICBzZXQ6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZS5zZXQpLAogICAgICAgICAgICAgICAgICAgIGdldDogdW5jdXJyeVRoaXMoTWFwUHJvdG90eXBlLmdldCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhNYXBQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBNYXBQcm90b3R5cGUKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgU2V0UHJvdG90eXBlID0gU2V0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gewogICAgICAgICAgICAgICAgICAgIFNldDogU2V0LAogICAgICAgICAgICAgICAgICAgIGFkZDogdW5jdXJyeVRoaXMoU2V0UHJvdG90eXBlLmFkZCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhTZXRQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKFNldFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBTZXRQcm90b3R5cGUsCiAgICAgICAgICAgICAgICAgICAgJGhhczogU2V0UHJvdG90eXBlLmhhcywKICAgICAgICAgICAgICAgICAgICAka2V5czogU2V0UHJvdG90eXBlLmtleXMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gRXJyb3IoJ2EnKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnc3RhY2snIGluIGVycm9yKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGVycm9yLCAnc3RhY2snLCBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IoMSwgNykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvci5zdGFjayAhPT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgVjggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMxKTsKICAgICAgICAgICAgICAgIHZhciBJU19CUk9XU0VSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzQpOwogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIHZhciBzdHJ1Y3R1cmVkQ2xvbmUgPSBnbG9iYWwuc3RydWN0dXJlZENsb25lOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhIXN0cnVjdHVyZWRDbG9uZSAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChJU19ERU5PICYmIFY4ID4gOTIgfHwgSVNfTk9ERSAmJiBWOCA+IDk0IHx8IElTX0JST1dTRVIgJiYgVjggPiA5NykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIoOCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGNsb25lID0gc3RydWN0dXJlZENsb25lKGJ1ZmZlciwgeyB0cmFuc2ZlcjogW2J1ZmZlcl0gfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlci5ieXRlTGVuZ3RoICE9IDAgfHwgY2xvbmUuYnl0ZUxlbmd0aCAhPSA4OwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIUlTX0RFTk8gJiYgIUlTX05PREUgJiYgdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB0eXBlb2YgZG9jdW1lbnQgPT0gJ29iamVjdCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdHlwZW9mIERlbm8gPT0gJ29iamVjdCcgJiYgRGVubyAmJiB0eXBlb2YgRGVuby52ZXJzaW9uID09ICdvYmplY3QnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBwcm9jZXNzICE9ICd1bmRlZmluZWQnICYmIGNsYXNzb2YocHJvY2VzcykgPT0gJ3Byb2Nlc3MnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZ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leHBvcnRzLnZlcnNpb24gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9hbm5vdGF0aW9uX3N0b3JhZ2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2ZvbnRfbG9hZGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDUpOwogICAgICAgICAgICAgICAgdmFyIF9jYW52YXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Nik7CiAgICAgICAgICAgICAgICB2YXIgX3dvcmtlcl9vcHRpb25zID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDkpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIHZhciBfbWVzc2FnZV9oYW5kbGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTApOwogICAgICAgICAgICAgICAgdmFyIF9tZXRhZGF0YSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTUxKTsKICAgICAgICAgICAgICAgIHZhciBfb3B0aW9uYWxfY29udGVudF9jb25maWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Mik7CiAgICAgICAgICAgICAgICB2YXIgX3RyYW5zcG9ydF9zdHJlYW0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Myk7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRl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ICBleHBvcnRzLkRlZmF1bHRTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSA9IERlZmF1bHRTdGFuZGFyZEZvbnREYXRhRmFjdG9yeTsKICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVDTWFwUmVhZGVyRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVTdGFuZGFyZEZvbnREYXRhRmFjdG9yeQogICAgICAgICAgICAgICAgICAgIH0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1NSk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q2FudmFzRmFjdG9yeSA9IERlZmF1bHRDYW52YXNGYWN0b3J5ID0gTm9kZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBEZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0RmlsdGVyRmFjdG9yeSA9IERlZmF1bHRGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBEZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3Rvcnk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgY3JlYXRlUERGTmV0d29ya1N0cmVhbTsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGTm9kZVN0cmVhbQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVQREZOZXR3b3JrU3RyZWFtID0gcGFyYW1zID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGTm9kZVN0cmVhbShwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBERk5ldHdvcmtTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU5KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGRmV0Y2hTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUERGTmV0d29ya1N0cmVhbSA9IHBhcmFtcyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF9kaXNwbGF5X3V0aWxzLmlzVmFsaWRGZXRjaFVybCkocGFyYW1zLnVybCkgPyBuZXcgUERGRmV0Y2hTdHJlYW0ocGFyYW1zKSA6IG5ldyBQREZOZXR3b3JrU3RyZWFtKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RG9jdW1lbnQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzcmMgPT09ICJzdHJpbmciIHx8IHNyYyBpbnN0YW5jZW9mIFVSTCkgewogICAgICAgICAgICAgICAgICAgICAgICBzcmMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHNyYwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKHNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3JjID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogc3JjCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3JjICE9PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIGluIGdldERvY3VtZW50LCBuZWVkIHBhcmFtZXRlciBvYmplY3QuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghc3JjLnVybCAmJiAhc3JjLmRhdGEgJiYgIXNyYy5yYW5nZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIG9iamVjdDogbmVlZCBlaXRoZXIgLmRhdGEsIC5yYW5nZSBvciAudXJsIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgUERGRG9jdW1lbnRMb2FkaW5nVGFzaygpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQKICAgICAgICAgICAgICAgICAgICB9ID0gdGFzazsKICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzcmMudXJsID8gZ2V0VXJsUHJvcChzcmMudXJsKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHNyYy5kYXRhID8gZ2V0RGF0YVByb3Aoc3JjLmRhdGEpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBodHRwSGVhZGVycyA9IHNyYy5odHRwSGVhZGVycyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpdGhDcmVkZW50aWFscyA9IHNyYy53aXRoQ3JlZGVudGlhbHMgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFzc3dvcmQgPSBzcmMucGFzc3dvcmQgPz8gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZVRyYW5zcG9ydCA9IHNyYy5yYW5nZSBpbnN0YW5jZW9mIFBERkRhdGFSYW5nZVRyYW5zcG9ydCA/IHNyYy5yYW5nZSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VDaHVua1NpemUgPSBOdW1iZXIuaXNJbnRlZ2VyKHNyYy5yYW5nZUNodW5rU2l6ZSkgJiYgc3JjLnJhbmdlQ2h1bmtTaXplID4gMCA/IHNyYy5yYW5nZUNodW5rU2l6ZSA6IERFRkFVTFRfUkFOR0VfQ0hVTktfU0laRTsKICAgICAgICAgICAgICAgICAgICBsZXQgd29ya2VyID0gc3JjLndvcmtlciBpbnN0YW5jZW9mIFBERldvcmtlciA/IHNyYy53b3JrZXIgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcmJvc2l0eSA9IHNyYy52ZXJib3NpdHk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZG9jQmFzZVVybCA9IHR5cGVvZiBzcmMuZG9jQmFzZVVybCA9PT0gInN0cmluZyIgJiYgISgwLCBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlb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GZpbHRlckZhY3RvcnkgPSBzcmMuZmlsdGVyRmFjdG9yeSB8fCBuZXcgRGVmYXVsdEZpbHRlckZhY3RvcnkoewogICAgICAgICAgICAgICAgICAgICAgICBkb2NJZCwKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnNldFZlcmJvc2l0eUxldmVsKSh2ZXJib3NpdHkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydEZhY3RvcnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnkKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmICghdXNlV29ya2VyRmV0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNwb3J0RmFjdG9yeS5jTWFwUmVhZGVyRmFjdG9yeSA9IG5ldyBDTWFwUmVhZGVyRmFjdG9yeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlVXJsOiBjTWFwVXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkOiBjTWFwUGFja2VkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRGYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gbmV3IFN0YW5kYXJkRm9udERhdGFGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmw6IHN0YW5kYXJkRm9udERhdGFVcmwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghd29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlclBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclBvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyID0gd29ya2VyUGFyYW1zLnBvcnQgPyBQREZXb3JrZXIuZnJvbVBvcnQod29ya2VyUGFyYW1zKSA6IG5ldyBQREZXb3JrZXIod29ya2VyUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fd29ya2VyID0gd29ya2VyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBmZXRjaERvY1BhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGFwaVZlcnNpb246ICczLjUuMTIyJywKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvY0Jhc2VVcmwsCiAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYSwKICAgICAgICAgICAgICAgICAgICAgICAgZXZhbHVhdG9yT3B0aW9uczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4SW1hZ2VTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNNYXhBcmVhSW5CeXRlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRFeHRyYVByb3BlcnRpZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VTeXN0ZW1Gb250cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBVcmw6IHVzZVdvcmtlckZldGNoID8gY01hcFVybCA6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZEZvbnREYXRhVXJsOiB1c2VXb3JrZXJGZXRjaCA/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/IGFyZ3VtZW50c1swXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYW5jZWwobnVsbCwgZXh0cmFEZWxheSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBzZXBhcmF0ZUFubm90cygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2VwYXJhdGVBbm5vdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLiNpbnRlcm5hbFJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzZXBhcmF0ZUFubm90cy5mb3JtIHx8IHNlcGFyYXRlQW5ub3RzLmNhbnZhcyAmJiAoYW5ub3RhdGlvbkNhbnZhc01hcCA9PT0gbnVsbCB8fCBhbm5vdGF0aW9uQ2FudmFzTWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhbm5vdGF0aW9uQ2FudmFzTWFwLnNpemUpID4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlJlbmRlclRhc2sgPSBSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgY2xhc3MgSW50ZXJuYWxSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgI2NhbnZhc0luVXNlID0gbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmMTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBkZkJ1ZyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUNvbG9ycyA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYxMzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWxsYmFjayA9IGNhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzID0gY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwID0gYW5ub3RhdGlvbkNhbnZhc01hcDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IG9wZXJhdG9yTGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUluZGV4ID0gcGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkgPSBmaWx0ZXJGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZUNvbG9ycyA9IHBhZ2VDb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucnVubmluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPT09IHRydWUgJiYgdHlwZW9mIHdpbmRvdyAhPT0gInVuZGVmaW5lZCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsbGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50YXNrID0gbmV3IFJlbmRlclRhc2sodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbmNlbEJvdW5kID0gdGhpcy5jYW5jZWwuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWVCb3VuZCA9IHRoaXMuX2NvbnRpbnVlLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kID0gdGhpcy5fc2NoZWR1bGVOZXh0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCA9IHRoaXMuX25leHQuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FudmFzID0gcGFyYW1zLmNhbnZhc0NvbnRleHQuY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY29tcGxldGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jYXBhYmlsaXR5LnByb21pc2UuY2F0Y2goZnVuY3Rpb24gKCkge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpbml0aWFsaXplR3JhcGhpY3MoX3JlZjE0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRTdGVwcGVyTWEsIF90aGlzJGdyYXBoaWNzUmVhZHlDYTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbmNlbGxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYW52YXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl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ICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNDb250ZXh0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZnggPSBuZXcgX2NhbnZhcy5DYW52YXNHcmFwaGljcyhjYW52YXNDb250ZXh0LCB0aGlzLmNvbW1vbk9ianMsIHRoaXMub2JqcywgdGhpcy5jYW52YXNGYWN0b3J5LCB0aGlzLmZpbHRlckZhY3RvcnksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZwogICAgICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLmFubm90YXRpb25DYW52YXNNYXApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5iZWdpbkRyYXdpbmcoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdElkeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRncmFwaGljc1JlYWR5Q2EgPSB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgPT09IG51bGwgfHwgX3RoaXMkZ3JhcGhpY3NSZWFkeUNhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRncmFwaGljc1JlYWR5Q2EuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2Z4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZXJyb3IgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBleHRyYURlbGF5ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW5jZWxsZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZ2Z4ID0gdGhpcy5nZngpID09PSBudWxsIHx8IF90aGlzJGdmeCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZ2Z4LmVuZERyYXdpbmcodGhpcy5wYWdlQ29sb3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxSZW5kZXJUYXNrLiNjYW52YXNJblVzZS5kZWxldGUodGhpcy5fY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKGVycm9yIHx8IG5ldyBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24oYFJlbmRlcmluZyBjYW5jZWxsZWQsIHBhZ2UgJHt0aGlzLl9wYWdlSW5kZXggKyAxfWAsICJjYW52YXMiLCBleHRyYURlbGF5KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRzdGVwcGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhcGhpY3NSZWFkeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeUNhbGxiYWNrID0gdGhpcy5fY29udGludWVCb3VuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkc3RlcHBlciA9IHRoaXMuc3RlcHBlcikgPT09IG51bGwgfHwgX3RoaXMkc3RlcHBlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3RlcHBlci51cGRhdGVPcGVyYXRvckxpc3QodGhpcy5vcGVyYXRvckxpc3QpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5ydW5uaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NvbnRpbnVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5jZWxsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50YXNrLm9uQ29udGludWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFzay5vbkNvbnRpbnVlKHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zY2hlZHVsZU5leHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCgpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbih0aGlzLl9uZXh0Qm91bmQpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBfbmV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSB0aGlzLmdmeC5leGVjdXRlT3BlcmF0b3JMaXN0KHRoaXMub3BlcmF0b3JMaXN0LCB0aGlzLm9wZXJhdG9yTGlzdElkeCwgdGhpcy5fY29udGludWVCb3VuZCwgdGhpcy5zdGVwcGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMub3BlcmF0b3JMaXN0SWR4ID09PSB0aGlzLm9wZXJhdG9yTGlzdC5hcmdzQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm9wZXJhdG9yTGlzdC5sYXN0Q2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5lbmREcmF3aW5nKHRoaXMucGFnZUNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmRlbGV0ZSh0aGlzLl9jYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCB2ZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICAgICAgZXhwb3J0cy52ZXJzaW9uID0gdmVyc2lvbjsKICAgICAgICAgICAgICAgIGNvbnN0IGJ1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgICAgICAgICBleHBvcnRzLmJ1aWxkID0gYnVpbGQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBleHBvcnRzLkFubm90YXRpb25TdG9yYWdlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRlU2V0LmFkZChvYmopOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyhvYmosIHByaXZhdGVNYXAsIHZhbHVlKSB7IF9jaGVja1ByaXZhdGVSZWRlY2xhcmF0aW9uKG9iaiwgcHJpdmF0ZU1hcCk7IHByaXZhdGVNY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fXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0TW9kaWZpZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25TdG9yYWdlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RpZmllZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9zdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25TZXRNb2RpZmllZCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25SZXNldE1vZGlmaWVkID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWYWx1ZShrZXksIGRlZmF1bHRWYWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmYXVsdFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGRlZmF1bHRWYWx1ZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXdWYWx1ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKS5kZWxldGUoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB2YWx1ZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWYWx1ZShrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtb2RpZmllZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JqICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2VudHJ5LCB2YWxdIG9mIE9iamVjdC5lbnRyaWVzKHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvYmpbZW50cnldICE9PSB2YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmpbZW50cnldID0gdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RpZmllZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0TW9kaWZpZWQsIF9zZXRNb2RpZmllZDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yICYmIHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IodmFsdWUuY29uc3RydWN0b3IuX3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuaGFzKGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA+IDAgPyAoMCwgX3V0aWwub2JqZWN0RnJvbU1hcCkoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKSkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBbGwob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBPYmplY3QuZW50cmllcyhvYmopKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFZhbHVlKGtleSwgdmFsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzZXRNb2RpZmllZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGlmaWVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SZXNldE1vZGlmaWVkID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJpbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJpbnRBbm5vdGF0aW9uU3RvcmFnZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmUgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXJpYWxpemVkID0gdmFsIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yID8gdmFsLnNlcmlhbGl6ZSgpIDogdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlcmlhbGl6ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZS5zZXQoa2V5LCBzZXJpYWxpemVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXRIYXNoKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc2ggPSBuZXcgX211cm11cmhhc2guTXVybXVySGFzaDNfNjQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWxdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzaC51cGRhdGUoYCR7a2V5fToke0pTT04uc3RyaW5naWZ5KHZhbCl9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2guaGV4ZGlnZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RvcmFnZSA9IEFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1vZGlmaWVkMigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbW9kaWZpZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25TZXRNb2RpZmllZCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQcmludEFubm90YXRpb25TdG9yYWdlIGV4dGVuZHMgQW5ub3RhdGlvblN0b3JhZ2UgewogICAgICAgICAgICAgICAgICAgICNzZXJpYWxpemFibGUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNzZXJpYWxpemFibGUgPSBzdHJ1Y3R1cmVkQ2xvbmUocGFyZW50LnNlcmlhbGl6YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcmludCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIFByaW50QW5ub3RhdGlvblN0b3JhZ2UucHJpbnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3NlcmlhbGl6YWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBQcmludEFubm90YXRpb25TdG9yYWdlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yIHsKICAgICAgICAgICAgICAgICAgICAjYm91bmRGb2N1c2luID0gdGhpcy5mb2N1c2luLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2JvdW5kRm9jdXNvdXQgPSB0aGlzLmZvY3Vzb3V0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2hhc0JlZW5TZWxlY3RlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNpc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAjaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX3VpTWFuYWdlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgI3pJbmRleCA9IEFubm90YXRpb25FZGl0b3IuX3pJbmRleCsrOwogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JNYW5hZ2VyID0gbmV3IF90b29scy5Db2xvck1hbmFnZXIoKTsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgX3pJbmRleCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQW5ub3RhdGlvbkVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQW5ub3RhdGlvbkVkaXRvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmFtZXRlcnMucGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlkID0gcGFyYW1ldGVycy5pZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aWR0aCA9IHRoaXMuaGVpZ2h0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJhbWV0ZXJzLnBhcmVudC5wYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IHBhcmFtZXRlcnMubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIgPSBwYXJhbWV0ZXJzLnVpTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEaW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMucGFyZW50LnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZURpbWVuc2lvbnMgPSBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlVHJhbnNsYXRpb24gPSBbcGFnZVgsIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3dpZHRoLCBoZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSBwYXJhbWV0ZXJzLnggLyB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55ID0gcGFyYW1ldGVycy55IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzQXR0YWNoZWRUb0RPTSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZ2V0IF9kZWZhdWx0TGluZUNvbG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9kZWZhdWx0TGluZUNvbG9yIiwgdGhpcy5fY29sb3JNYW5hZ2VyLmdldEhleENvZGUoIkNhbnZhc1RleHQiKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZENvbW1hbmRzKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkQ29tbWFuZHMocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRMYXllcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3VpTWFuYWdlci5jdXJyZW50TGF5ZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEluQmFja2dyb3VuZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUuekluZGV4ID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0SW5Gb3JlZ3JvdW5kKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS56SW5kZXggPSB0aGlzLiN6SW5kZXg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFBhcmVudChwYXJlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudCAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJlbnQucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlRGltZW5zaW9ucyA9IHBhcmVudC5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuI2hhc0JlZW5TZWxlY3RlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNoYXNCZWVuU2VsZWN0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb2N1c291dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkcGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gZXZlbnQucmVsYXRlZFRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAhPT0gbnVsbCAmJiB0YXJnZXQgIT09IHZvaWQgMCAmJiB0YXJnZXQuY2xvc2VzdChgIyR7dGhpcy5pZH1gKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKChfdGhpcyRwYXJlbnQgPSB0aGlzLnBhcmVudCkgIT09IG51bGwgJiYgX3RoaXMkcGFyZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkcGFyZW50LmlzTXVsdGlwbGVTZWxlY3Rpb24pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0T3JSZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRyYWdzdGFydChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5wYXJlbnQuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0WCA9IGV2ZW50LmNsaWVudFggLSByZWN0Lng7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRZID0gZXZlbnQuY2xpZW50WSAtIHJlY3QueTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLnNldERhdGEoInRleHQvcGxhaW4iLCB0aGlzLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmVmZmVjdEFsbG93ZWQgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEF0KHgsIHksIHR4LCB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt0eCwgdHldID0gdGhpcy5zY3JlZW5Ub1BhZ2VUcmFuc2xhdGlvbih0eCwgdHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAoeCArIHR4KSAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAoeSArIHR5KSAvIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUubGVmdCA9IGAkezEwMCAqIHRoaXMueH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUudG9wID0gYCR7MTAwICogdGhpcy55fSVgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGUoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IHRoaXMuc2NyZWVuVG9QYWdlVHJhbnNsYXRpb24oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCArPSB4IC8gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSArPSB5IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5sZWZ0ID0gYCR7MTAwICogdGhpcy54fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS50b3AgPSBgJHsxMDAgKiB0aGlzLnl9JWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNjcmVlblRvUGFnZVRyYW5zbGF0aW9uKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnBhcmVudFJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeSwgLXhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteCwgLXldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyNzA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteSwgeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCwgeV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFNjYWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJlYWxTY2FsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFJvdGF0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcGFyZW50RGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl91aU1hbmFnZXIudmlld1BhcmFtZXRlcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlV2lkdGgsIHBhZ2VIZWlnaHRdID0gdGhpcy5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtwYWdlV2lkdGggKiByZWFsU2NhbGUsIHBhZ2VIZWlnaHQgKiByZWFsU2NhbGVdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREaW1zKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS53aWR0aCA9IGAkezEwMCAqIHdpZHRoIC8gcGFyZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnN0eWxlLmhlaWdodCA9IGAkezEwMCAqIGhlaWdodCAvIHBhcmVudEhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZml4RGltcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUGVyY2VudCA9IHdpZHRoLmVuZHNXaXRoKCIlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFBlcmNlbnQgPSBoZWlnaHQuZW5kc1dpdGgoIiUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUGVyY2VudCAmJiBoZWlnaHRQZXJjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpZHRoUGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBgJHsxMDAgKiBwYXJzZUZsb2F0KHdpZHRoKSAvIHBhcmVudFdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaGVpZ2h0UGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogcGFyc2VGbG9hdChoZWlnaHQpIC8gcGFyZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImRhdGEtZWRpdG9yLXJvdGF0aW9uIiwgKDM2MCAtIHRoaXMucm90YXRpb24pICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuY2xhc3NOYW1lID0gdGhpcy5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImlkIiwgdGhpcy5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgidGFiSW5kZXgiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFkZEV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt0eCwgdHldID0gdGhpcy5nZXRJbml0aWFsVHJhbnNsYXRpb24oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUodHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF90b29scy5iaW5kRXZlbnRzKSh0aGlzLCB0aGlzLmRpdiwgWyJkcmFnc3RhcnQiLCAicG9pbnRlcmRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNNYWMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF91dGlsLkZlYXR1cmVUZXN0LnBsYXRmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwIHx8IGV2ZW50LmN0cmxLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmN0cmxLZXkgJiYgIWlzTWFjIHx8IGV2ZW50LnNoaWZ0S2V5IHx8IGV2ZW50Lm1ldGFLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnRvZ2dsZVNlbGVjdGVkKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaGFzQmVlblNlbGVjdGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVjdCh0eCwgdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IHRoaXMucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlWCwgcGFnZVldID0gdGhpcy5wYWdlVHJhbnNsYXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WCA9IHR4IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WSA9IHR5IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSB0aGlzLnggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSB0aGlzLnkgKiBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRYICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRZIC0gaGVpZ2h0ICsgcGFnZVksIHggKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VYLCBwYWdlSGVpZ2h0IC0geSAtIHNoaWZ0WSArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRYICsgcGFnZVksIHggKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCAtIHNoaWZ0WCAtIHdpZHRoICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRZICsgcGFnZVksIHggLSBzaGlmdFggKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3ggLSBzaGlmdFkgLSBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgLSBzaGlmdFggLSB3aWR0aCArIHBhZ2VZLCB4IC0gc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRYICsgcGFnZVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZWN0SW5DdXJyZW50Q29vcmRzKHJlY3QsIHBhZ2VIZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0geDIgLSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0geTIgLSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkyLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkxLCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeDIsIHBhZ2VIZWlnaHQgLSB5MSwgd2lkdGgsIGhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3gyLCBwYWdlSGVpZ2h0IC0geTIsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbmNlQWRkZWQoKSB7fQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzSW5FZGl0TW9kZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzSW5FZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzSW5FZGl0TW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2hvdWxkR2V0S2V5Ym9hcmRFdmVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbmVlZHNUb0JlUmVidWlsdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2ICYmICF0aGlzLmlzQXR0YWNoZWRUb0RPTTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGRpdi5hZGRFdmVudExpc3RlbmVyKCJmb2N1c2luIiwgdGhpcy4jYm91bmRGb2N1c2luKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VyaWFsaXplKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBbiBlZGl0b3IgbXVzdCBiZSBzZXJpYWxpemFibGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGRlc2VyaWFsaXplKGRhdGEsIHBhcmVudCwgdWlNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IG5ldyB0aGlzLnByb3RvdHlwZS5jb25zdHJ1Y3Rvcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogcGFyZW50LmdldE5leHRJZCgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlNYW5hZ2VyCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iucm90YXRpb24gPSBkYXRhLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IGVkaXRvci5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gsIHksIHdpZHRoLCBoZWlnaHRdID0gZWRpdG9yLmdldFJlY3RJbkN1cnJlbnRDb29yZHMoZGF0YS5yZWN0LCBwYWdlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnggPSB4IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IueSA9IHkgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iud2lkdGggPSB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmhlaWdodCA9IGhlaWdodCAvIHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQucmVtb3ZlKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZGl2MiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkaXYyLmNsYXNzTGlzdC5hZGQoInNlbGVjdGVkRWRpdG9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGl2MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdjMgPSB0aGlzLmRpdikgPT09IG51bGwgfHwgX3RoaXMkZGl2MyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2My5jbGFzc0xpc3QucmVtb3ZlKCJzZWxlY3RlZEVkaXRvciIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVQYXJhbXModHlwZSwgdmFsdWUpIHt9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGVuYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7fTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnREaXYoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzRWRpdGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0IGlzRWRpdGluZyh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNpc0VkaXRpbmcgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRTZWxlY3RlZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvciA9IEFubm90YXRpb25FZGl0b3I7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE0MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLktleWJvYXJkTWFuYWdlciA9IGV4cG9ydHMuQ29tbWFuZE1hbmFnZXIgPSBleHBvcnRzLkN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IHsKICAgICAgICAgICAgICAgICAgICAjaWQgPSAwOwogICAgICAgICAgICAgICAgICAgIGdldElkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYCR7X3V0aWwuQW5ub3RhdGlvbkVkaXRvclByZWZpeH0ke3RoaXMuI2lkKyt9YDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb21tYW5kTWFuYWdlciB7CiAgICAgICAgICAgICAgICAgICAgI2NvbW1hbmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgI2xvY2tlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICNwb3NpdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF4U2l6ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtYXhTaXplID0gbWF4U2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBOYU4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbyA9IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobXVzdEV4ZWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNsb2NrZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY21kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI3Bvc2l0aW9uID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI2NvbW1hbmRzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jcG9zaXRpb24gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHMucHVzaChzYXZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3ZlcndyaXRlSWZTYW1lVHlwZSAmJiB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0udHlwZSA9PT0gdHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtlZXBVbmRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZS51bmRvID0gdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG87CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0gPSBzYXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5leHQgPSB0aGlzLiNwb3NpdGlvbiArIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0ID09PSB0aGlzLiNtYXhTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5zcGxpY2UoMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNwb3NpdGlvbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dCA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzLnNwbGljZShuZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5wdXNoKHNhdmUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jcG9zaXRpb24gPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uIC09IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsb2NrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLmNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jcG9zaXRpb24gIT09IC0xOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbW1hbmRNYW5hZ2VyID0gQ29tbWFuZE1hbmFnZXI7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgS2V5Ym9hcmRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlciA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcyA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleXMsIGNhbGxiYWNrXSBvZiBjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IG9mIGtleXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc01hY0tleSA9IGtleS5zdGFydHNXaXRoKCJtYWMrIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTWFjICYmIGlzTWFjS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tzLnNldChrZXkuc2xpY2UoNCksIGNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzLmFkZChrZXkuc3BsaXQoIisiKS5hdCgtMSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzTWFjICYmICFpc01hY0tleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcy5zZXQoa2V5LCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxsS2V5cy5hZGQoa2V5LnNwbGl0KCIrIikuYXQoLTEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlYyhzZWxmLCBldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuYWxsS2V5cy5oYXMoZXZlbnQua2V5KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbGxiYWNrID0gdGhpcy5jYWxsYmFja3MuZ2V0KF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZSwgX3NlcmlhbGl6ZTIpLmNhbGwodGhpcywgZXZlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLmJpbmQoc2VsZikoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5LZXlib2FyZE1hbmFnZXIgPSBLZXlib2FyZE1hbmFnZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5hbHRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgiYWx0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5jdHJsS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVyLnB1c2goImN0cmwiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50Lm1ldGFLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgibWV0YSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuc2hpZnRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgic2hpZnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaChldmVudC5rZXkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ciA9IHRoaXMuYnVmZmVyLmpvaW4oIisiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvck1hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JzTWFwcGluZyA9IG5ldyBNYXAoW1siQ2FudmFzVGV4dCIsIFswLCAwLCAwXV0sIFsiQ2FudmFzIiwgWzI1NSwgMjU1LCAyNTVdXV0pOwogICAgICAgICAgICAgICAgICAgIGdldCBfY29sb3JzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvcnMgPSBuZXcgTWFwKFtbIkNhbnZhc1RleHQiLCBudWxsXSwgWyJDYW52YXMiLCBudWxsXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q29sb3JWYWx1ZXMpKGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX2NvbG9ycyIsIGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnZlcnQoY29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldFJHQikoY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpbmRvdy5tYXRjaE1lZGlhKCIoZm9yY2VkLWNvbG9yczogYWN0aXZlKSIpLm1hdGNoZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZ2I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbbmFtZSwgUkdCXSBvZiB0aGlzLl9jb2xvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSR0IuZXZlcnkoKHgsIGkpID0+IHggPT09IHJnYltpXSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQ29sb3JNYW5hZ2VyLl9jb2xvcnNNYXBwaW5nLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmdiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRIZXhDb2RlKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gdGhpcy5fY29sb3JzLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZ2IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5yZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQ29sb3JNYW5hZ2VyID0gQ29sb3JNYW5hZ2VyOwogICAgICAgICAgICAgICAgdmFyIF9hY3RpdmVFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYWxsRWRpdG9ycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hbGxMYXllcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYW5ub3RhdGlvblN0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29tbWFuZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY3VycmVudFBhZ2VJbmRleCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JUeXBlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzVG9SZXNjYWxlID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2ZW50QnVzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0VuYWJsZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfbW9kZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RlZEVkaXRvcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDb3B5ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ3V0ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kUGFzdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRLZXlkb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25FZGl0aW5nQWN0aW9uID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25QYWdlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblNjYWxlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcHJldmlvdXNTdGF0ZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGFpbmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEtleWJvYXJkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfYWRkQ29weVBhc3RlTGlzdGVuZXJzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVVJID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuYWJsZUFsbCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlQWxsID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEVkaXRvclRvTGF5ZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfaXNFbXB0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RFZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb250YWluZXIsIGV2ZW50QnVzLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3NlbGVjdEVkaXRvcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzRW1wdHkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEVkaXRvclRvTGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Rpc2FibGVBbGwpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2VuYWJsZUFsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYWRkQ29weVBhc3RlTGlzdGVuZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEtleWJvYXJkTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY3RpdmVFZGl0b3IsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxMYXllcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Fubm90YXRpb25TdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY29tbWFuZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBDb21tYW5kTWFuYWdlcigpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY3VycmVudFBhZ2VJbmRleCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvclR5cGVzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZWRpdG9yc1RvUmVzY2FsZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IFNldCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZXZlbnRCdXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBJZE1hbmFnZXIoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzRW5hYmxlZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgU2V0KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENvcHksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY29weS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDdXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY3V0LmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBhc3RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLnBhc3RlLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEtleWRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMua2V5ZG93bi5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRPbkVkaXRpbmdBY3Rpb24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMub25FZGl0aW5nQWN0aW9uLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uUGFnZUNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUGFnZUNoYW5naW5nLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uU2NhbGVDaGFuZ2luZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5vblNjYWxlQ2hhbmdpbmcuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kT25Sb3RhdGlvbkNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUm90YXRpb25DaGFuZ2luZy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcHJldmlvdXNTdGF0ZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbnRhaW5lciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250YWluZXIsIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZXZlbnRCdXMsIGV2ZW50QnVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29uKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInBhZ2VjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblBhZ2VDaGFuZ2luZykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInNjYWxlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25TY2FsZUNoYW5naW5nKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLl9vbigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSwgYW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdQYXJhbWV0ZXJzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlOiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogMAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJwYWdlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25QYWdlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigic2NhbGVjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblNjYWxlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnNUb1Jlc2NhbGUpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25QYWdlQ2hhbmdpbmcoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VOdW1iZXIKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgsIHBhZ2VOdW1iZXIgLSAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNNYWluQ29udGFpbmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRhaW5lcikuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5hZGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yZWFsU2NhbGUgPSBzY2FsZSAqIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2guUERGX1RPX0NTU19VTklUUzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uU2NhbGVDaGFuZ2luZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uUm90YXRpb25DaGFuZ2luZyhfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXNSb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yb3RhdGlvbiA9IHBhZ2VzUm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yLmlzRW1wdHkoKSAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Fubm90YXRpb25TdG9yYWdlKSAmJiAhX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSkuaGFzKGVkaXRvci5pZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpLnNldFZhbHVlKGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb3B5KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKS5jb21taXRPclJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5oYXNTZWxlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvci5zZXJpYWxpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcnMubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuY2xpcGJvYXJkRGF0YS5zZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIsIEpTT04uc3RyaW5naWZ5KGVkaXRvcnMpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3V0KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29weShldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhc3RlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gZXZlbnQuY2xpcGJvYXJkRGF0YS5nZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IEpTT04ucGFyc2UoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGRhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdEFsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsTGF5ZXJzKS5nZXQoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jdXJyZW50UGFnZUluZGV4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdFZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVzZXJpYWxpemVkRWRpdG9yID0gbGF5ZXIuZGVzZXJpYWxpemUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRlc2VyaWFsaXplZEVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0VkaXRvcnMucHVzaChkZXNlcmlhbGl6ZWRFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWRkRWRpdG9yVG9MYXllciwgX2FkZEVkaXRvclRvTGF5ZXIyKS5jYWxsKHRoaXMsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlbGVjdEVkaXRvcnMsIF9zZWxlY3RFZGl0b3JzMikuY2FsbCh0aGlzLCBuZXdFZGl0b3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAga2V5ZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2V0QWN0aXZlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgoX3RoaXMkZ2V0QWN0aXZlID0gdGhpcy5nZXRBY3RpdmUoKSkgIT09IG51bGwgJiYgX3RoaXMkZ2V0QWN0aXZlICE9PSB2b2lkIDAgJiYgX3RoaXMkZ2V0QWN0aXZlLnNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25FZGl0aW5nQWN0aW9uKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFsidW5kbyIsICJyZWRvIiwgImRlbGV0ZSIsICJzZWxlY3RBbGwiXS5pbmNsdWRlcyhkZXRhaWxzLm5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2RldGFpbHMubmFtZV0oKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRFZGl0aW5nU3RhdGUoaXNFZGl0aW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FkZEtleWJvYXJkTWFuYWdlciwgX2FkZEtleWJvYXJkTWFuYWdlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRWRpdGluZzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSAhPT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1VuZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmhhc1NvbWV0aGluZ1RvUmVkbygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZWdpc3RlckVkaXRvclR5cGVzKHR5cGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvclR5cGVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZWRpdG9yVHlwZXMsIHR5cGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3JUeXBlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yVHlwZS5kZWZhdWx0UHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaWRNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY3VycmVudExheWVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLmdldChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRQYWdlSW5kZXgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuc2V0KGxheWVyLnBhZ2VJbmRleCwgbGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRpc2FibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmVMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZGVsZXRlKGxheWVyLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZU1vZGUobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGUsIG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzYWJsZUFsbCwgX2Rpc2FibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9lbmFibGVBbGwsIF9lbmFibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci51cGRhdGVNb2RlKG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVRvb2xiYXIobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJzd2l0Y2hhbm5vdGF0aW9uZWRpdG9ybW9kZSIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhcmFtcyh0eXBlLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvclR5cGUgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JUeXBlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvclR5cGUudXBkYXRlRGVmYXVsdFBhcmFtcyh0eXBlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RWRpdG9ycyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9ycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbEVkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLnBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVkaXRvcnM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEVkaXRvcihpZCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5nZXQoaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykuc2V0KGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5kZWxldGUoZWRpdG9yLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQyLnJlbW92ZShlZGl0b3IuaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBY3RpdmVFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikgPT09IGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yLnByb3BlcnRpZXNUb1VwZGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9nZ2xlU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuaGFzKGVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlVUksIF9kaXNwYXRjaFVwZGF0ZVVJMikuY2FsbCh0aGlzLCBlZGl0b3IucHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFNlbGVjdGVkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkICE9PSBlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZC51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZWxlY3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSwgX2Rpc3BhdGNoVXBkYXRlVUkyKS5jYWxsKHRoaXMsIGVkaXRvci5wcm9wZXJ0aWVzVG9VcGRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5oYXMoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdW5zZWxlY3QoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuZGVsZXRlKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhhc1NlbGVjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5zaXplICE9PSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS51bmRvKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NvbWV0aGluZ1RvVW5kbzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb21tYW5kTWFuYWdlcikuaGFzU29tZXRoaW5nVG9VbmRvKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLnJlZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9SZWRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1JlZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzRW1wdHksIF9pc0VtcHR5MikuY2FsbCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWFuZHMocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmFkZChwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1VuZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eTogX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfaXNFbXB0eSwgX2lzRW1wdHkyKS5jYWxsKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZWxldGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmhhc1NlbGVjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvcnMgPSBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIGVkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRFZGl0b3JUb0xheWVyLCBfYWRkRWRpdG9yVG9MYXllcjIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdE9yUmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZWxlY3RFZGl0b3JzLCBfc2VsZWN0RWRpdG9yczIpLmNhbGwodGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS52YWx1ZXMoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLnNpemUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpID09PSBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFjdGl2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyID0gQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlcjsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5yZW1vdmVFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKCkgewogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNvcHkiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ29weSkpOwogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGl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gIH0pOwogICAgICAgICAgICAgICAgICAgIGlmIChoYXNDaGFuZ2VkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJhbm5vdGF0aW9uZWRpdG9yc3RhdGVzY2hhbmdlZCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHM6IE9iamVjdC5hc3NpZ24oX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wcmV2aW91c1N0YXRlcyksIGRldGFpbHMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kaXNwYXRjaFVwZGF0ZVVJMihkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuZGlzcGF0Y2goImFubm90YXRpb25lZGl0b3JwYXJhbXNjaGFuZ2VkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHMKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmFibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmVuYWJsZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Rpc2FibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIHRoaXMudW5zZWxlY3RBbGwoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGF5ZXIgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5kaXNhYmxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfYWRkRWRpdG9yVG9MYXllcjIoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZ2V0KGVkaXRvci5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBsYXllci5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9pc0VtcHR5MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3IuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZWxlY3RFZGl0b3JzMihlZGl0b3JzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF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Zm9ybSA9IGdldEN1cnJlbnRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlID0gZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2U7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldEZpbGVuYW1lRnJvbVVybCA9IGdldEZpbGVuYW1lRnJvbVVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0UGRmRmlsZW5hbWVGcm9tVXJsID0gZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOwogICAgICAgICAgICAgICAgZXhwb3J0cy5nZXRSR0IgPSBnZXRSR0I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFhmYVBhZ2VWaWV3cG9ydCA9IGdldFhmYVBhZ2VWaWV3cG9ydDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuaXNEYXRhU2NoZW1lID0gaXNEYXRhU2NoZW1lOwogICAgICAgICAgICAgICAgZXhwb3J0cy5pc1BkZkZpbGUgPSBpc1BkZkZpbGU7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzVmFsaWRGZXRjaFVybCA9IGlzVmFsaWRGZXRjaFVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMubG9hZFNjcmlwdCA9IGxvYWRTY3JpcHQ7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldExheWVyRGltZW5zaW9ucyA9IHNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2Y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RlZCB0byBzZXQgcmVhZCBvbmx5IHByaXZhdGUgZmllbGQiKTsgfSBkZXNjcmlwdG9yLnZhbHVlID0gdmFsdWU7IH0gfQogICAgICAgICAgICAgICAgY29uc3QgU1ZHX05TID0gImh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIjsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25QcmVmaXggPSAicGRmanNfaW50ZXJuYWxfaWRfIjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblByZWZpeCA9IEFubm90YXRpb25QcmVmaXg7CiAgICAgICAgICAgICAgICBjbGFzcyBQaXhlbHNQZXJJbmNoIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgQ1NTID0gOTYuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGID0gNzIuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGX1RPX0NTU19VTklUUyA9IHRoaXMuQ1NTIC8gdGhpcy5QREY7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBpeGVsc1BlckluY2ggPSBQaXhlbHNQZXJJbmNoOwogICAgICAgICAgICAgICAgdmFyIF9jYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY0lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hjbUZpbHRlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oY21LZXkgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfaGNtVXJsID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hcHBlbmRGZUZ1bmMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIERPTUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudCA9IGdsb2JhbFRoaXMuZG9jdW1lbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYXBwZW5kRmVGdW5jKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2RlZnMyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfZGVmcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGUyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfY2FjaGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQ6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kZWZzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kb2NJZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZG9jdW1lbnQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hjbUZpbHRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGNtS2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9oY21VcmwsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RvY0lkLCBkb2NJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZG9jdW1lbnQsIG93bmVyRG9jdW1lbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRGaWx0ZXIobWFwcykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkaWQsIF90aGlzJGlkMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQobWFwcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWJsZVIsIHRhYmxlRywgdGFibGVCLCBrZXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXBzLmxlbmd0aCA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwUiA9IG1hcHNbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJbaV0gPSBtYXBSW2ldIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0gdGFibGVSID0gdGFibGVHID0gdGFibGVCID0gYnVmZmVyLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFttYXBSLCBtYXBHLCBtYXBCXSA9IG1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJSID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJHID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJCID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyUltpXSA9IG1hcFJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyR1tpXSA9IG1hcEdbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyQltpXSA9IG1hcEJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWJsZVIgPSBidWZmZXJSLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhYmxlRyA9IGJ1ZmZlckcuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFibGVCID0gYnVmZmVyQi5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXkgPSBgJHt0YWJsZVJ9JHt0YWJsZUd9JHt0YWJsZUJ9YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBnXyR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2NJZCl9X3RyYW5zZmVyX21hcF8keyhfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lkLCAoX3RoaXMkaWQgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2lkKSwgX3RoaXMkaWQyID0gX3RoaXMkaWQrKywgX3RoaXMkaWQpKSwgX3RoaXMkaWQyKX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKCMke2lkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5zZXQoa2V5LCB1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWx0ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLnNldEF0dHJpYnV0ZSgiaWQiLCBpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycyIsICJzUkdCIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZlQ29tcG9uZW50VHJhbnNmZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb21wb25lbnRUcmFuc2ZlciIpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuYXBwZW5kKGZlQ29tcG9uZW50VHJhbnNmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgdGFibGVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYXBwZW5kRmVGdW5jLCBfYXBwZW5kRmVGdW5jMikuY2FsbCh0aGlzLCBmZUNvbXBvbmVudFRyYW5zZmVyLCAiZmVGdW5jRyIsIHRhYmxlRyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZUIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkSENNRmlsdGVyKGZnQ29sb3IsIGJnQ29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGAke2ZnQ29sb3J9LSR7YmdDb2xvcn1gOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21LZXkpID09PSBrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hjbVVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21LZXksIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtVXJsLCAibm9uZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtRmlsdGVyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0Mi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmZ0NvbG9yIHx8ICFiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpLnN0eWxlLmNvbG9yID0gZmdDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgZmdDb2xvciA9IGdldENvbXB1dGVkU3R5bGUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikpLmdldFByb3BlcnR5VmFsdWUoImNvbG9yIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZnUkdCID0gZ2V0UkdCKGZnQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZmdSR0IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5zdHlsZS5jb2xvciA9IGJnQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGJnQ29sb3IgPSBnZXRDb21wdXRlZFN0eWxlKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpKS5nZXRQcm9wZXJ0eVZhbHVlKCJjb2xvciIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiZ1JHQiA9IGdldFJHQihiZ0NvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmJnUkdCKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikuc3R5bGUuY29sb3IgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZnQ29sb3IgPT09ICIjMDAwMDAwIiAmJiBiZ0NvbG9yID09PSAiI2ZmZmZmZiIgfHwgZmdDb2xvciA9PT0gYmdDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPD0gMjU1OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBpIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwW2ldID0geCA8PSAwLjAzOTI4ID8geCAvIDEyLjkyIDogKCh4ICsgMC4wNTUpIC8gMS4wNTUpICoqIDIuNDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IG1hcC5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gYGdfJHtfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY0lkKX1faGNtX2ZpbHRlcmA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlciA9IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtRmlsdGVyLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuc2V0QXR0cmlidXRlKCJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnMiLCAic1JHQiIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb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AgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFN0ZXBzID0gKGMsIG4pID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXJ0ID0gZmdSR0JbY10gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBiZ1JHQltjXSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyciA9IG5ldyBBcnJheShuICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbaV0gPSBzdGFydCArIGkgLyBuICogKGVuZCAtIHN0YXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgZ2V0U3RlcHMoMCwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNHIiwgZ2V0U3RlcHMoMSwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNCIiwgZ2V0U3RlcHMoMiwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21VcmwsIGB1cmwoIyR7aWR9KWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQga2VlcEhDTSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZWVwSENNICYmIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpLnBhcmVudE5vZGUucGFyZW50Tm9kZS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVmcywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jYWNoZSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pZCwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01GaWx0ZXJGYWN0b3J5ID0gRE9NRmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9nZXRfY2FjaGUoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpIHx8IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2FjaGUsIG5ldyBNYXAoKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0X2RlZnMoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbnRhaW4gPSAic3RyaWN0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBzdHlsZS5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLnRvcCA9IHN0eWxlLmxlZnQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS56SW5kZXggPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgInN2ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kZWZzLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZGVmcyIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmcykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5ib2R5LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hcHBlbmRGZUZ1bmMyKGZlQ29tcG9uZW50VHJhbnNmZXIsIGZ1bmMsIHRhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmVGdW5jID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgZnVuYyk7CiAgICAgICAgICAgICAgICAgICAgZmVGdW5jLnNldEF0dHJpYnV0ZSgidHlwZSIsICJkaXNjcmV0ZSIpOwogICAgICAgICAgICAgICAgICAgIGZlRnVuYy5zZXRBdHRyaWJ1dGUoInRhYmxlVmFsdWVzIiwgdGFibGUpOwogICAgICAgICAgICAgICAgICAgIGZlQ29tcG9uZW50VHJhbnNmZXIuYXBwZW5kKGZlRnVuYyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DYW52YXNGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50ID0gZ2xvYmFsVGhpcy5kb2N1bWVudAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+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+IDAgJiYgbG9hZGluZ1JlcXVlc3RzWzBdLmRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdGhlclJlcXVlc3QgPSBsb2FkaW5nUmVxdWVzdHMuc2hpZnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KG90aGVyUmVxdWVzdC5jYWxsYmFjaywgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZTogY29tcGxldGVSZXF1ZXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICA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ICAgICAgICAgY29uc3QgY2h1bmsyID0gcy5zdWJzdHJpbmcob2Zmc2V0ICsgcmVtb3ZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjaHVuazEgKyBpbnNlcnQgKyBjaHVuazI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLndpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNGb250UmVhZHkobmFtZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgrK2NhbGxlZCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJMb2FkIHRlc3QgZm9udCBuZXZlciBsb2FkZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9ICIzMHB4ICIgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCIuIiwgMCwgMjApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1hZ2VEYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEuZGF0YVszXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoaXNGb250UmVhZHkuYmluZChudWxsLCBuYW1lLCBjYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvYWRUZXN0Rm9udElkID0gYGx0JHtEYXRlLm5vdygpfSR7dGhpcy5sb2FkVGVzdEZvbnRJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gdGhpcy5fbG9hZFRlc3RGb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDT01NRU5UX09GRlNFVCA9IDk3NjsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHNwbGljZVN0cmluZyhkYXRhLCBDT01NRU5UX09GRlNFVCwgbG9hZFRlc3RGb250SWQubGVuZ3RoLCBsb2FkVGVzdEZvbnRJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENGRl9DSEVDS1NVTV9PRkZTRVQgPSAxNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgWFhYWF9WQUxVRSA9IDB4NTg1ODU4NTg7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGVja3N1bSA9IGludDMyKGRhdGEsIENGRl9DSEVDS1NVTV9PRkZTRVQpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IGxvYWRUZXN0Rm9udElkLmxlbmd0aCAtIDM7IGkgPCBpaTsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja3N1bSA9IGNoZWNrc3VtIC0gWFhYWF9WQUxVRSArIGludDMyKGxvYWRUZXN0Rm9udElkLCBpKSB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCBsb2FkVGVzdEZvbnRJZC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrc3VtID0gY2hlY2tzdW0gLSBYWFhYX1ZBTFVFICsgaW50MzIobG9hZFRlc3RGb250SWQgKyAiWFhYIiwgaSkgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBzcGxpY2VTdHJpbmcoZGF0YSwgQ0ZGX0NIRUNLU1VNX09GRlNFVCwgNCwgKDAsIF91dGlsLnN0cmluZzMyKShjaGVja3N1bSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKGRhdGE6Zm9udC9vcGVudHlwZTtiYXNlNjQsJHtidG9hKGRhdGEpfSk7YDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGBAZm9udC1mYWNlIHtmb250LWZhbWlseToiJHtsb2FkVGVzdEZvbnRJZH0iO3NyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbnNlcnRSdWxlKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXYgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLndpZHRoID0gZGl2LnN0eWxlLmhlaWdodCA9ICIxMHB4IjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnBvc2l0aW9uID0gImFic29sdXRlIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnRvcCA9IGRpdi5zdHlsZS5sZWZ0ID0gIjBweCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBbZm9udC5sb2FkZWROYW1lLCBsb2FkVGVzdEZvbnRJZF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYW4gPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnRleHRDb250ZW50ID0gIkhpIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW4uc3R5bGUuZm9udEZhbWlseSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYuYXBwZW5kKHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmJvZHkuYXBwZW5kKGRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlzRm9udFJlYWR5KGxvYWRUZXN0Rm9udElkLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmNvbXBsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IEZvbnRMb2FkZXI7CiAgICAgICAgICAgICAgICBjbGFzcyBGb250RmFjZU9iamVjdCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IodHJhbnNsYXRlZERhdGEsIF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQgPSB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnMgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluc3BlY3RGb250ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGkgaW4gdHJhbnNsYXRlZERhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbaV0gPSB0cmFuc2xhdGVkRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRXZhbFN1cHBvcnRlZCA9IGlzRXZhbFN1cHBvcnRlZCAhPT0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUZvbnRGYWNlID0gZGlzYWJsZUZvbnRGYWNlID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlnbm9yZUVycm9ycyA9IGlnbm9yZUVycm9ycyA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5zcGVjdEZvbnQgPSBpbnNwZWN0Rm9udDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlTmF0aXZlRm9udEZhY2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfaW5zcGVjdEZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhIHx8IHRoaXMuZGlzYWJsZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0aXZlRm9udEZhY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jc3NGb250SW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0aXZlRm9udEZhY2UgPSBuZXcgRm9udEZhY2UodGhpcy5sb2FkZWROYW1lLCB0aGlzLmRhdGEsIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNzcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWlnaHQ6IHRoaXMuY3NzRm9udEluZm8uZm9udFdlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzLnN0eWxlID0gYG9ibGlxdWUgJHt0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlfWRlZ2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVGb250RmFjZSA9IG5ldyBGb250RmFjZSh0aGlzLmNzc0ZvbnRJbmZvLmZvbnRGYW1pbHksIHRoaXMuZGF0YSwgY3NzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250ID0gdGhpcy5faW5zcGVjdEZvbnQpID09PSBudWxsIHx8IF90aGlzJF9pbnNwZWN0Rm9udCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2luc3BlY3RGb250LmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYXRpdmVGb250RmFjZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlRm9udEZhY2VSdWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2luc3BlY3RGb250MjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEgfHwgdGhpcy5kaXNhYmxlRm9udEZhY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSAoMCwgX3V0aWwuYnl0ZXNUb1N0cmluZykodGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gYHVybChkYXRhOiR7dGhpcy5taW1ldHlwZX07YmFzZTY0LCR7YnRvYShkYXRhKX0pO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzRm9udEluZm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBgQGZvbnQtZmFjZSB7Zm9udC1mYW1pbHk6IiR7dGhpcy5sb2FkZWROYW1lfSI7c3JjOiR7dXJsfX1gOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNzcyA9IGBmb250LXdlaWdodDogJHt0aGlzLmNzc0ZvbnRJbmZvLmZvbnRXZWlnaHR9O2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jc3NGb250SW5mby5pdGFsaWNBbmdsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzcyArPSBgZm9udC1zdHlsZTogb2JsaXF1ZSAke3RoaXMuY3NzRm9udEluZm8uaXRhbGljQW5nbGV9ZGVnO2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYEBmb250LWZhY2Uge2ZvbnQtZmFtaWx5OiIke3RoaXMuY3NzRm9udEluZm8uZm9udEZhbWlseX0iOyR7Y3NzfXNyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250MiA9IHRoaXMuX2luc3BlY3RGb250KSA9PT0gbnVsbCB8fCBfdGhpcyRfaW5zcGVjdEZvbnQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfaW5zcGVjdEZvbnQyLmNhbGwodGhpcywgdGhpcywgdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdGhHZW5lcmF0b3Iob2JqcywgY2hhcmFjdGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbXBpbGVkR2x5cGhzW2NoYXJhY3Rlcl0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY21kczsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZHMgPSBvYmpzLmdldCh0aGlzLmxvYWRlZE5hbWUgKyAiX3BhdGhfIiArIGNoYXJhY3Rlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFBhdGhHZW5lcmF0b3IgLSBpZ25vcmluZyBjaGFyYWN0ZXI6ICIke2V4fSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gZnVuY3Rpb24gKGMsIHNpemUpIHt9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRXZhbFN1cHBvcnRlZCAmJiBfdXRpbC5GZWF0dXJlVGVzdC5pc0V2YWxTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGpzQnVmID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBjdXJyZW50LmFyZ3MgIT09IHVuZGVmaW5lZCA/IGN1cnJlbnQuYXJncy5qb2luKCIsIikgOiAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc0J1Zi5wdXNoKCJjLiIsIGN1cnJlbnQuY21kLCAiKCIsIGFyZ3MsICIpO1xuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gbmV3IEZ1bmN0aW9uKCJjIiwgInNpemUiLCBqc0J1Zi5qb2luKCIiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXSA9IGZ1bmN0aW9uIChjLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmNtZCA9PT0gInNjYWxlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmFyZ3MgPSBbc2l6ZSwgLXNpemVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjW2N1cnJlbnQuY21kXS5hcHBseShjLCBjdXJyZW50LmFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSBGb250RmFjZU9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ2ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQ2FudmFzR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAg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fU0laRSA9IDQwOTY7CiAgICAgICAgICAgICAgICBjb25zdCBFWEVDVVRJT05fVElNRSA9IDE1OwogICAgICAgICAgICAgICAgY29uc3QgRVhFQ1VUSU9OX1NURVBTID0gMTA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfU0laRV9UT19DT01QSUxFID0gMTAwMDsKICAgICAgICAgICAgICAgIGNvbnN0IEZVTExfQ0hVTktfSEVJR0hUID0gMTY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIGRlc3RDdHgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY3R4Ll9yZW1vdmVNaXJyb3JpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDb250ZXh0IGlzIGFscmVhZHkgZm9yd2FyZGluZyBvcGVyYXRpb25zLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFNhdmUgPSBjdHguc2F2ZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc3RvcmUgPSBjdHgucmVzdG9yZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJvdGF0ZSA9IGN0eC5yb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxTY2FsZSA9IGN0eC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZSA9IGN0eC50cmFuc2xhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxUcmFuc2Zvcm0gPSBjdHgudHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsU2V0VHJhbnNmb3JtID0gY3R4LnNldFRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtID0gY3R4LnJlc2V0VHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQ2xpcCA9IGN0eC5jbGlwOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsTW92ZVRvID0gY3R4Lm1vdmVUbzsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbExpbmVUbyA9IGN0eC5saW5lVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvID0gY3R4LmJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxSZWN0ID0gY3R4LnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGggPSBjdHguY2xvc2VQYXRoOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQmVnaW5QYXRoID0gY3R4LmJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICBjdHguX3JlbW92ZU1pcnJvcmluZyA9ICgpID0+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/IGN1cnJlbnRUcmFuc2Zvcm0gOiBbY3VycmVudFRyYW5zZm9ybS5zbGljZSgwLCA0KSwgZmlsbENvbG9yXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZSA9IHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuZ2V0KG1haW5LZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWNoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuc2V0KG1haW5LZXksIGNhY2hlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhY2hlZEltYWdlID0gY2FjaGUuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRJbWFnZSAmJiAhaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLnJvdW5kKE1hdGgubWluKGN1cnJlbnRUcmFuc2Zvcm1bMF0sIGN1cnJlbnRUcmFuc2Zvcm1bMl0pICsgY3VycmVudFRyYW5zZm9ybVs0XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgucm91bmQoTWF0aC5taW4oY3VycmVudFRyYW5zZm9ybVsxXSwgY3VycmVudFRyYW5zZm9ybVszXSkgKyBjdXJyZW50VHJhbnNmb3JtWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXM6IGNhY2hlZEltYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IGNhY2hlZEltYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoIm1hc2tDYW52YXMiLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlTWFzayhtYXNrQ2FudmFzLmNvbnRleHQsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGN1cnJlbnRUcmFuc2Zvcm0sIFsxIC8gd2lkdGgsIDAsIDAsIC0xIC8gaGVpZ2h0LCAwLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hc2tUb0NhbnZhcywgWzEsIDAsIDAsIDEsIDAsIC1oZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDEgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgaGVpZ2h0XSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbY29yZDFbMF0sIGNvcmQxWzFdLCBjb3JkMlswXSwgY29yZDJbMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IE1hdGgucm91bmQocmVjdFsyXSAtIHJlY3RbMF0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRyYXduSGVpZ2h0ID0gTWF0aC5yb3VuZChyZWN0WzNdIC0gcmVjdFsxXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJmaWxsQ2FudmFzIiwgZHJhd25XaWR0aCwgZHJhd25IZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ3R4ID0gZmlsbENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvZmZzZXRYID0gTWF0aC5taW4oY29yZDFbMF0sIGNvcmQyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgubWluKGNvcmQxWzFdLCBjb3JkMlsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNmb3JtKC4uLm1hc2tUb0NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWQgPSB0aGlzLl9zY2FsZUltYWdlKG1hc2tDYW52YXMuY2FudmFzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IHNjYWxlZC5pbWc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLnNldChjYWNoZUtleSwgc2NhbGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoZmlsbEN0eCksIGltZy5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhmaWxsQ3R4LCBzY2FsZWQsIDAsIDAsIHNjYWxlZC53aWR0aCwgc2NhbGVkLmhlaWdodCwgMCwgMCwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1pbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludmVyc2UgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybSgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpLCBbMSwgMCwgMCwgMSwgLW9mZnNldFgsIC1vZmZzZXRZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZmlsbFN0eWxlID0gaXNQYXR0ZXJuRmlsbCA/IGZpbGxDb2xvci5nZXRQYXR0ZXJuKGN0eCwgdGhpcywgaW52ZXJzZSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpIDogZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgIWlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkQ2FudmFzZXMuZGVsZXRlKCJmaWxsQ2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZS5zZXQoY2FjaGVLZXksIGZpbGxDYW52YXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBmaWxsQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IE1hdGgucm91bmQob2Zmc2V0WCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBNYXRoLnJvdW5kKG9mZnNldFkpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggIT09IHRoaXMuY3VycmVudC5saW5lV2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZVdpZHRoID0gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXAoc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVKb2luKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmxpbmVKb2luID0gTElORV9KT0lOX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubWl0ZXJMaW1pdCA9IGxpbWl0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREYXNoKGRhc2hBcnJheSwgZGFzaFBoYXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3R4LnNldExpbmVEYXNoICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChkYXNoQXJyYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaFBoYXNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudChpbnRlbnQpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0RmxhdG5lc3MoZmxhdG5lc3MpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBzdGF0ZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lQ2FwKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVKb2luKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldE1pdGVyTGltaXQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRSZW5kZXJpbmdJbnRlbnQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmxhdG5lc3ModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkNBIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUFscGhhID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5nbG9iYWxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJCTSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJTTWFzayI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayA9IHZhbHVlID8gdGhpcy50ZW1wU01hc2sgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRlbXBTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tTTWFza1N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlRSIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gdGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9IHRoaXMuZmlsdGVyRmFjdG9yeS5hZGRGaWx0ZXIodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaW5TTWFza01vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIXRoaXMuc3VzcGVuZGVkQ3R4OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjaGVja1NNYXNrU3RhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluU01hc2tNb2RlID0gdGhpcy5pblNNYXNrTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayAmJiAhaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmVnaW5TTWFza01vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5jdXJyZW50LmFjdGl2ZVNNYXNrICYmIGluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFNNYXNrTW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pblNNYXNrTW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJiZWdpblNNYXNrTW9kZSBjYWxsZWQgd2hpbGUgYWxyZWFkeSBpbiBzbWFzayBtb2RlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25IZWlnaHQgPSB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZUlkID0gInNtYXNrR3JvdXBBdCIgKyB0aGlzLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldFRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5zdXNwZW5kZWRDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuc3VzcGVuZGVkQ3R4LCBjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIHRoaXMuc3VzcGVuZGVkQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZW5kU01hc2tNb2RlIGNhbGxlZCB3aGlsZSBub3QgaW4gc21hc2sgbW9kZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Ll9yZW1vdmVNaXJyb3JpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuY3R4LCB0aGlzLnN1c3BlbmRlZEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tcG9zZShkaXJ0eUJveCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3VycmVudC5hY3RpdmVTTWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZGlydHlCb3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94ID0gWzAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJ0eUJveFswXSA9IE1hdGguZmxvb3IoZGlydHlCb3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlydHlCb3hbMV0gPSBNYXRoLmZsb29yKGRpcnR5Qm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzJdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzNdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzbWFzayA9IHRoaXMuY3VycmVudC5hY3RpdmVTTWFzazsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3VzcGVuZGVkQ3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFzayhzdXNwZW5kZWRDdHgsIHNtYXNrLCB0aGlzLmN0eCwgZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xlYXJSZWN0KDAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2F2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLmN0eCwgdGhpcy5zdXNwZW5kZWRDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9sZCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGF0ZVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gb2xkLmNsb25lKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoID09PSAwICYmIHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhdGVTdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLnN1c3BlbmRlZEN0eCwgdGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoZWNrU01hc2tTdGF0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RQYXRoKG9wcywgYXJncywgbWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBjdXJyZW50Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdGFydFgsIHN0YXJ0WTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NjYWxpbmdNYXRyaXggPSBjdXJyZW50VHJhbnNmb3JtWzBdID09PSAwICYmIGN1cnJlbnRUcmFuc2Zvcm1bM10gPT09IDAgfHwgY3VycmVudFRyYW5zZm9ybVsxXSA9PT0gMCAmJiBjdXJyZW50VHJhbnNmb3JtWzJdID09PSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtaW5NYXhGb3JCZXppZXIgPSBpc1NjYWxpbmdNYXRyaXggPyBtaW5NYXguc2xpY2UoMCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gb3BzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BzW2ldIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHcgPSB4ICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHloID0geSArIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID09PSAwIHx8IGhlaWdodCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeWgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHh3LCB5aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHgsIHloKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU2NhbGluZ01hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVSZWN0TWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIFt4LCB5LCB4dywgeWhdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1NjYWxpbmdNYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5saW5lVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCBhcmdzW2ogKyAyXSwgYXJnc1tqICsgM10sIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZUN1cnZlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCBzdGFydFgsIHN0YXJ0WSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSwgeCwgeSwgbWluTWF4Rm9yQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8oeCwgeSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlQ3VydmVQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIHN0YXJ0WCwgc3RhcnRZLCB4LCB5LCBhcmdzW2pdLCBhcmdzW2ogKyAxXSwgYXJnc1tqICsgMl0sIGFyZ3NbaiArIDNdLCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2ogKyAzXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgM107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVDdXJ2ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgc3RhcnRYLCBzdGFydFksIGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5LCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVNjYWxpbmdQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIG1pbk1heEZvckJlemllcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5zZXRDdXJyZW50UG9pbnQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnN1bWVQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+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/IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKSh0aGlzLiNtZXRhZGF0YU1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNtZXRhZGF0YU1hcC5oYXMobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IE1ldGFkYXRhOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTIgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5PcHRpb25hbENvbnRlbnRDb25maWcgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVf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5zZXQpIHsgZGVzY3JpcHRvci5zZXQuY2FsbChyZWNlaXZlciwgdmFsdWUpOyB9IGVsc2UgeyBpZiAoIWRlc2NyaXB0b3Iud3JpdGFibGUpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIHNldCByZWFkIG9ubHkgcHJpdmF0ZSBmaWVsZCIpOyB9IGRlc2NyaXB0b3IudmFsdWUgPSB2YWx1ZTsgfSB9CiAgICAgICAgICAgICAgICBjb25zdCBJTlRFUk5BTCA9IFN5bWJvbCgiSU5URVJOQUwiKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudEdyb3VwIHsKICAgICAgICAgICAgICAgICAgICAjdmlzaWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobmFtZSwgaW50ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaW50ZW50ID0gaW50ZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgdmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3Zpc2libGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRWaXNpYmxlKGludGVybmFsLCB2aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcm5hbCAhPT0gSU5URVJOQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkludGVybmFsIG1ldGhvZCBgX3NldFZpc2libGVgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiN2aXNpYmxlID0gdmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlZEdldEhhc2ggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfZ3JvdXBzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2luaXRpYWxIYXNoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX29yZGVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudENvbmZpZyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGVkR2V0SGFzaCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2dyb3VwcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaW5pdGlhbEhhc2gsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9vcmRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5uYW1lID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jcmVhdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBkYXRhLm5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3JlYXRvciA9IGRhdGEuY3JlYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9vcmRlciwgZGF0YS5vcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZ3JvdXAgb2YgZGF0YS5ncm91cHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zZXQoZ3JvdXAuaWQsIG5ldyBPcHRpb25hbENvbnRlbnRHcm91cChncm91cC5uYW1lLCBncm91cC5pbnRlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5iYXNlU3RhdGUgPT09ICJPRkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdyb3VwIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwLl9zZXRWaXNpYmxlKElOVEVSTkFMLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvbiBvZiBkYXRhLm9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KG9uKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvZmYgb2YgZGF0YS5vZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQob2ZmKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaW5pdGlhbEhhc2gsIHRoaXMuZ2V0SGFzaCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlKGdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3Vwcykuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBkZWZpbmVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ0ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoZ3JvdXAuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtncm91cC5pZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGdyb3VwLmlkKS52aXNpYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ01EIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmV4cHJlc3Npb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZXZhbHVhdGVWaXNpYmlsaXR5RXhwcmVzc2lvbiwgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKS5jYWxsKHRoaXMsIGdyb3VwLmV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5wb2xpY3kgfHwgZ3JvdXAucG9saWN5ID09PSAiQW55T24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpZCBvZiBncm91cC5pZHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtpZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGlkKS52aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnBvbGljeSA9PT0gIkFsbE9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQW55T2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQWxsT2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmdldChpZCkudmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG9wdGlvbmFsIGNvbnRlbnQgcG9saWN5ICR7Z3JvdXAucG9saWN5fS5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBncm91cCB0eXBlICR7Z3JvdXAudHlwZX0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWaXNpYmlsaXR5KGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2aXNpYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9wdGlvbmFsIGNvbnRlbnQgZ3JvdXAgbm90IGZvdW5kOiAke2lkfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLl9zZXRWaXNpYmxlKElOVEVSTkFMLCAhIXZpc2libGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGFzSW5pdGlhbFZpc2liaWxpdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldEhhc2goKSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pbml0aWFsSGFzaCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9yZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vcmRlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29yZGVyKS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmtleXMoKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEdyb3VwcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplID4gMCA/ICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKShfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0R3JvdXAoaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEhhc2goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlZEdldEhhc2gpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jYWNoZWRHZXRIYXNoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNoID0gbmV3IF9tdXJtdXJoYXNoLk11cm11ckhhc2gzXzY0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2lkLCBncm91cF0gb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNoLnVwZGF0ZShgJHtpZH06JHtncm91cC52aXNpYmxlfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIGhhc2guaGV4ZGlnZXN0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuT3B0aW9uYWxDb250ZW50Q29uZmlnID0gT3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKGFycmF5KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvciA9IGFycmF5WzBdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24sIF9ldmFsdWF0ZVZpc2liaWxpdHlFeHByZXNzaW9uMikuY2FsbCh0aGlzLCBlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoZWxlbWVudCkudmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7ZWxlbWVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkFuZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiT3IiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJOb3QiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBvcGVyYXRvciA9PT0gIkFuZCI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZiwgcGRmRGF0YVJhbmdlVHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzaXZlRG9uZSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHBkZkRhdGFSYW5nZVRyYW5zcG9ydCwgJ1BERkRhdGFUcmFuc3BvcnRTdHJlYW0gLSBtaXNzaW5nIHJlcXVpcmVkICJwZGZEYXRhUmFuZ2VUcmFuc3BvcnQiIGFyZ3VtZW50LicpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lID0gcHJvZ3Jlc3NpdmVEb25lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGluaXRpYWxEYXRhID09PSBudWxsIHx8IGluaXRpYWxEYXRhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBpbml0aWFsRGF0YS5sZW5ndGgpID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyID0gaW5pdGlhbERhdGEgaW5zdGFuY2VvZiBVaW50OEFycmF5ICYmIGluaXRpYWxEYXRhLmJ5dGVMZW5ndGggPT09IGluaXRpYWxEYXRhLmJ1ZmZlci5ieXRlTGVuZ3RoID8gaW5pdGlhbERhdGEuYnVmZmVyIDogbmV3IFVpbnQ4QXJyYXkoaW5pdGlhbERhdGEpLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcy5wdXNoKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0ID0gcGRmRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFkaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gIWRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFJhbmdlTGlzdGVuZXIoKGJlZ2luLCBjaHVuaykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzTGlzdGVuZXIoKGxvYWRlZCwgdG90YWwpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3MoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIoY2h1bmsgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzaXZlRG9uZUxpc3RlbmVyKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQudHJhbnNwb3J0UmVhZHkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUmVjZWl2ZURhdGEoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBjaHVuayBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgY2h1bmsuYnl0ZUxlbmd0aCA9PT0gY2h1bmsuYnVmZmVyLmJ5dGVMZW5ndGggPyBjaHVuay5idWZmZXIgOiBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmVnaW4gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIuX2VucXVldWUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvdW5kID0gdGhpcy5fcmFuZ2VSZWFkZXJzLnNvbWUoZnVuY3Rpb24gKHJhbmdlUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJhbmdlUmVhZGVyLl9iZWdpbiAhPT0gYmVnaW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZVJlYWRlci5fZW5xdWV1ZShidWZmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShmb3VuZCwgIl9vblJlY2VpdmVEYXRhIC0gbm8gYFBERkRhdGFUcmFuc3BvcnRTdHJlYW1SYW5nZVJlYWRlcmAgaW5zdGFuY2UgZm91bmQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2dC50b3RhbCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JhbmdlUmVhZGVycyQsIF90aGlzJF9yYW5nZVJlYWRlcnMkJDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmFuZ2VSZWFkZXJzJCA9IHRoaXMuX3JhbmdlUmVhZGVyc1swXSkgPT09IG51bGwgfHwgX3RoaXMkX3JhbmdlUmVhZGVycyQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPSBfdGhpcyRfcmFuZ2VSZWFkZXJzJC5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yYW5nZVJlYWRlcnMkJC5jYWxsKF90aGlzJF9yYW5nZVJlYWRlcnMkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPSBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMuY2FsbChfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vblByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWE0ID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQucHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW1vdmVSYW5nZVJlYWRlcihyZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IHRoaXMuX3JhbmdlUmVhZGVycy5pbmRleE9mKHJlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGRGF0YVRyYW5zcG9ydFN0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxdWV1ZWRDaHVua3MgPSB0aGlzLl9xdWV1ZWRDaHVua3M7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlcih0aGlzLCBxdWV1ZWRDaHVua3MsIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSwgdGhpcy5fY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmQgPD0gdGhpcy5fcHJvZ3Jlc3NpdmVEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhNSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1LmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSBQREZEYXRhVHJhbnNwb3J0U3RyZWFtOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtLCBxdWV1ZWRDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzaXZlRG9uZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gcHJvZ3Jlc3NpdmVEb25lIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfZGlzcGxheV91dGlscy5pc1BkZkZpbGUpKGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lKSA/IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzID0gcXVldWVkQ2h1bmtzIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNodW5rIG9mIHRoaXMuX3F1ZXVlZENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlYWR5ID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbS5fZnVsbFJlcXVlc3RSZWFkZXIgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSBjaHVuay5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGVhZGVyc1JlYWR5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faGVhZGVyc1JlYWR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUmFuZ2VTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHJlYW0uX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N0cmVhbS5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc3RyZWFtLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc2l2ZURvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0sIGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iZWdpbiA9IGJlZ2luOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbmQgPSBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0c0NhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdHNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbS5fcmVtb3ZlUmFuZ2VSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0uX3JlbW92ZVJhbmdlUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU0ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhVGV4dCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNsYXNzIFhmYVRleHQgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0ZXh0Q29udGVudCh4ZmEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3V0cHV0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fsayhub2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX25vZGUkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IG5vZGUubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYW1lID09PSAiI3RleHQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyID0gbm9kZS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVhmYVRleHQuc2hvdWxkQnVpbGRUZXh0KG5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlICE9PSBudWxsICYmIG5vZGUgIT09IHZvaWQgMCAmJiAoX25vZGUkYXR0cmlidXRlcyA9IG5vZGUuYXR0cmlidXRlcykgIT09IG51bGwgJiYgX25vZGUkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9ub2RlJGF0dHJpYnV0ZXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLmF0dHJpYnV0ZXMudGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGUudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0ciAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2Ygbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoY2hpbGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoeGZhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG91dHB1dDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNob3VsZEJ1aWxkVGV4dChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKG5hbWUgPT09ICJ0ZXh0YXJlYSIgfHwgbmFtZSA9PT0gImlucHV0IiB8fCBuYW1lID09PSAib3B0aW9uIiB8fCBuYW1lID09PSAic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5YZmFUZXh0ID0gWGZhVGV4dDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5Ob2RlRmlsdGVyRmFjdG9yeSA9IGV4cG9ydHMuTm9kZUNhbnZhc0ZhY3RvcnkgPSBleHBvcnRzLk5vZGVDTWFwUmVhZGVyRmFjdG9yeSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgZmV0Y2hEYXRhID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZnMucmVhZEZpbGUodXJsLCAoZXJyb3IsIGRhdGEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciB8fCAhZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRXJyb3IoZXJyb3IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5ldyBVaW50OEFycmF5KGRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHt9CiAgICAgICAgICAgICAgICBleHBvcnRzLk5vZGVGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlQ2FudmFzRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNhbnZhc0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDYW52YXMgPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIENhbnZhcy5jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ2FudmFzRmFjdG9yeSA9IE5vZGVDYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUNNYXBSZWFkZXJGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsLCBjb21wcmVzc2lvblR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpLnRoZW4oZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBEYXRhOiBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXByZXNzaW9uVHlwZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGh0dHAgPSByZXF1aXJlKCJodHRwIik7CiAgICAgICAgICAgICAgICBjb25zdCBodHRwcyA9IHJlcXVpcmUoImh0dHBzIik7CiAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSByZXF1aXJlKCJ1cmwiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVVcmlSZWdleCA9IC9eZmlsZTpcL1wvXC9bYS16QS1aXTpcLy87CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBwYXJzZVVybChzb3VyY2VVcmwpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJzZWRVcmwgPSB1cmwucGFyc2Uoc291cmNlVXJsKTsKICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VkVXJsLnByb3RvY29sID09PSAiZmlsZToiIHx8IHBhcnNlZFVybC5ob3N0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZWRVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgvXlthLXpdOlsvXFxdL2kudGVzdChzb3VyY2VVcmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwucGFyc2UoYGZpbGU6Ly8vJHtzb3VyY2VVcmx9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghcGFyc2VkVXJsLmhvc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VkVXJsLnByb3RvY29sID0gImZpbGU6IjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlZFVybDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNvdXJjZSA9IHNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChzb3VyY2UudXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0h0dHAgPSB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHA6IiB8fCB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNGc1VybCA9IHRoaXMudXJsLnByb3RvY29sID09PSAiZmlsZToiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmh0dHBIZWFkZXJzID0gdGhpcy5pc0h0dHAgJiYgc291cmNlLmh0dHBIZWFkZXJzIHx8IHt9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRGdWxsUmVhZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIsICJQREZOb2RlU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gdGhpcy5pc0ZzVXJsID8gbmV3IFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIodGhpcykgOiBuZXcgUERGTm9kZVN0cmVhbUZ1bGxSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmFuZ2VSZWFkZXIoc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5kIDw9IHRoaXMuX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLmlzRnNVcmwgPyBuZXcgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIodGhpcywgc3RhcnQsIGVuZCkgOiBuZXcgUERGTm9kZVN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmFuZ2VSZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmFuZ2VSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbEFsbFJlcXVlc3RzKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMi5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZWFkZXIgb2YgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zbGljZSgwKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gUERGTm9kZVN0cmVhbTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzb3VyY2UubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGFibGVTdHJlYW0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5fcmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zdG9yZWRFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdGhpcy5fc3RvcmVkRXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsgPSB0aGlzLl9yZWFkYWJsZVN0cmVhbS5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaHVuayA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MgPT09IHZvaWQgMCA/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+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvckxheWVyID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0MSk7CiAgICAgICAgICAgICAgICB2YXIgX2ZyZWV0ZXh0ID0gX193X3BkZmp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ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU5ld0VkaXRvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQW5ub3RhdGlvbkVkaXRvckxheWVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihvcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY2xlYW51cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlQW5kQWRkTmV3RWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jcmVhdGVOZXdFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NoYW5nZVBhcmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYWxsb3dDbGljaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5wb2ludGVydXAuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kUG9pbnRlcmRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMucG9pbnRlcmRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hhZFBvaW50ZXJEb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzQ2xlYW5pbmdVcCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF91aU1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9mcmVldGV4dC5GcmVlVGV4dEVkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfaW5rLklua0VkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy51aU1hbmFnZXIucmVnaXN0ZXJFZGl0b3JUeXBlcyhbX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLCBfaW5rLklua0VkaXRvcl0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3VpTWFuYWdlciwgb3B0aW9ucy51aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2VJbmRleCA9IG9wdGlvbnMucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IG9wdGlvbnMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyLCBvcHRpb25zLmFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZExheWVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuc2l6ZSA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlVG9vbGJhcihtb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS51cGRhdGVUb29sYmFyKG1vZGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbW9kZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2xlYW51cCwgX2NsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0QWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RlICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJmcmVlVGV4dEVkaXRpbmciLCBtb2RlID09PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJpbmtFZGl0aW5nIiwgbW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZElua0VkaXRvcklmTmVlZGVkKGlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZyAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuZ2V0TW9kZSgpICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTkspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRJbkJhY2tncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRDb21tYW5kcyhwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZENvbW1hbmRzKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVuYWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUucG9pbnRlckV2ZW50cyA9ICJhdXRvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmVuYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5wb2ludGVyRXZlbnRzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGlzYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jbGVhbnVwLCBfY2xlYW51cDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0QWN0aXZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50QWN0aXZlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEFjdGl2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEFjdGl2ZSA9PT0gZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEFjdGl2ZUVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVDbGljaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcmRvd24iLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kUG9pbnRlcmRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcnVwIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ2xpY2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXR0YWNoKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnNldChlZGl0b3IuaWQsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldGFjaChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuZGVsZXRlKGVkaXRvci5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIChfY2xhc3NQcml2YXRlRmllbGRHZXQyID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIucmVtb3ZlUG9pbnRlckluVGV4dExheWVyKGVkaXRvci5jb250ZW50RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikucmVtb3ZlRWRpdG9yKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYuc3R5bGUuZGlzcGxheSA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGl2LnN0eWxlLmRpc3BsYXkgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaXNBdHRhY2hlZFRvRE9NID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jdW1lbnQuYWN0aXZlRWxlbWVudCA9PT0gZG9jdW1lbnQuYm9keSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5mb2N1c01haW5Db250YWluZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NsZWFuaW5nVXApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IGVkaXRvci5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmlzQXR0YWNoZWRUb0RPTSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uY2VBZGRlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZShlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlRWRpdG9ySW5ET00oZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQzOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MyA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWNjZXNzaWJpbGl0eU1hbmFnZXIpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQzLm1vdmVFbGVtZW50SW5ET00odGhpcy5kaXYsIGVkaXRvci5kaXYsIGVkaXRvci5jb250ZW50RGl2LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkT3JSZWJ1aWxkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLm5lZWRzVG9CZVJlYnVpbHQoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQU5ld0VkaXRvcihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFVuZG9hYmxlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbWQgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZE9yUmVidWlsZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE5leHRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXNlcmlhbGl6ZShkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5hbm5vdGF0aW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLmRlc2VyaWFsaXplKGRhdGEsIHRoaXMsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLklOSzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2luay5JbmtFZGl0b3IuZGVzZXJpYWxpemUoZGF0YSwgdGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5zZXRTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0b2dnbGVTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnRvZ2dsZVNlbGVjdGVkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuaXNTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bnNlbGVjdChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0KGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hhZFBvaW50ZXJEb3duKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFkUG9pbnRlckRvd24sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbG93Q2xpY2spKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FsbG93Q2xpY2ssIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvciwgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludGVyZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oYWRQb2ludGVyRG93biwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbGxvd0NsaWNrLCAhZWRpdG9yIHx8IGVkaXRvci5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcm9wKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZXZlbnQuZGF0YVRyYW5zZmVyLmdldERhdGEoInRleHQvcGxhaW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcihpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmRyb3BFZmZlY3QgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRYID0gZXZlbnQuY2xpZW50WCAtIHJlY3QueDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5kWSA9IGV2ZW50LmNsaWVudFkgLSByZWN0Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50cmFuc2xhdGUoZW5kWCAtIGVkaXRvci5zdGFydFgsIGVuZFkgLSBlZGl0b3Iuc3RhcnRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcmFnb3ZlcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCgoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NC5wYXJlbnQpID09PSB0aGlzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuc2V0QWN0aXZlRWRpdG9yKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQ1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDUgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NS5yZW1vdmVQb2ludGVySW5UZXh0TGF5ZXIoZWRpdG9yLmNvbnRlbnREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFBhcmVudChudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pc0F0dGFjaGVkVG9ET00gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5yZW1vdmVMYXllcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0ID0gdmlld3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKHRoaXMuZGl2LCB2aWV3cG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdG9vbHMuYmluZEV2ZW50cykodGhpcywgdGhpcy5kaXYsIFsiZHJhZ292ZXIiLCAiZHJvcCJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcnModGhpcy5wYWdlSW5kZXgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlTW9kZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGUoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSB2aWV3cG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9ucykodGhpcy5kaXYsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cGRhdGVNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlRGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy52aWV3cG9ydC5yYXdEaW1zOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yTGF5ZXIgPSBBbm5vdGF0aW9uRWRpdG9yTGF5ZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hhbmdlUGFyZW50MihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciRwYXJlbnQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvci5wYXJlbnQgPT09IHRoaXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIChfZWRpdG9yJHBhcmVudCA9IGVkaXRvci5wYXJlbnQpID09PSBudWxsIHx8IF9lZGl0b3IkcGFyZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZWRpdG9yJHBhcmVudC5kZXRhY2goZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UGFyZW50KHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuZGl2ICYmIGVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKGVkaXRvci5kaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jcmVhdGVOZXdFZGl0b3IyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZnJlZXRleHQuRnJlZVRleHRFZGl0b3IocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTks6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF9pbmsuSW5rRWRpdG9yKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IHRoaXMuZ2V0TmV4dElkKCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlTmV3RWRpdG9yLCBfY3JlYXRlTmV3RWRpdG9yMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudDogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHg6IGV2ZW50Lm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgIHk6IGV2ZW50Lm9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgIHVpTWFuYWdlcjogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNDbGVhbmluZ1VwLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NsZWFuaW5nVXAsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yTGF5ZXIsICJfaW5pdGlhbGl6ZWQiLCBmYWxzZSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICA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2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVGb250U2l6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVDb2xvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9leHRyYWN0VGV4dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRFZGl0b3JEaW1lbnNpb25zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEVkaXRvciBleHRlbmRzIF9lZGl0b3IuQW5ub3RhdGlvbkVkaXRvciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLnBhcmFtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJmcmVlVGV4dEVkaXRvciIKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3VwZGF0ZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVGb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEVkaXRvckRpdkJsdXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZWRpdG9yRGl2Qmx1ci5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZGb2N1cywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZGb2N1cy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZJbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZJbnB1dC5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZLZXlkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmVkaXRvckRpdktleWRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbG9yLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9jb250ZW50LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAiIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvckRpdklkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBgJHt0aGlzLmlkfS1lZGl0b3JgCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZm9udFNpemUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgcGFyYW1zLmNvbG9yIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9mb250U2l6ZSwgcGFyYW1zLmZvbnRTaXplIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Rm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImZyZWVfdGV4dDJfZGVmYXVsdF9jb250ZW50IiwgImVkaXRvcl9mcmVlX3RleHQyX2FyaWFfbGFiZWwiXS5tYXAoc3RyID0+IFtzdHIsIGwxMG4uZ2V0KHN0cildKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gZ2V0Q29tcHV0ZWRTdHlsZShkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlcm5hbFBhZGRpbmcgPSBwYXJzZUZsb2F0KHN0eWxlLmdldFByb3BlcnR5VmFsdWUoIi0tZnJlZXRleHQtcGFkZGluZyIpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX1NJWkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fZGVmYXVsdENvbG9yID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZUZvbnRTaXplLCBfdXBkYXRlRm9udFNpemUyKS5jYWxsKHRoaXMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZV0sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUiwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3JdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSldLCBbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1IsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29sb3IpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWy1GcmVlVGV4dEVkaXRvci5faW50ZXJuYWxQYWRkaW5nICogc2NhbGUsIC0oRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyArIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHNjYWxlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVidWlsZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kaXYgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5hZGQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQudXBkYXRlVG9vbGJhcihfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdi5jbGFzc0xpc3QucmVtb3ZlKCJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNvbnRlbnRFZGl0YWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5yZW1vdmVBdHRyaWJ1dGUoImFyaWEtYWN0aXZlZGVzY2VuZGFudCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlb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vckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5mb2N1c2luKGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LnRhcmdldCAhPT0gdGhpcy5lZGl0b3JEaXYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmZvY3VzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICF0aGlzLmVkaXRvckRpdiB8fCB0aGlzLmVkaXRvckRpdi5pbm5lclRleHQudHJpbSgpID09PSAiIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuYWRkVW5kb2FibGVFZGl0b3IodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250ZW50LCBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0VGV4dCwgX2V4dHJhY3RUZXh0MikuY2FsbCh0aGlzKS50cmltRW5kKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRFZGl0b3JEaW1lbnNpb25zLCBfc2V0RWRpdG9yRGltZW5zaW9uczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5pc0luRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGJsY2xpY2soZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBrZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgPT09IHRoaXMuZGl2ICYmIGV2ZW50LmtleSA9PT0gIkVudGVyIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZLZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEZyZWVUZXh0RWRpdG9yLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVkaXRvckRpdkZvY3VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWRpdG9yRGl2Qmx1cihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZJbnB1dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5kaXYuY2xhc3NMaXN0LnRvZ2dsZSgiZnJlZVRleHRFZGl0aW5nIiwgdGhpcy5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc2V0QXR0cmlidXRlKCJyb2xlIiwgImNvbW1lbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlQXR0cmlidXRlKCJhcmlhLW11bHRpbGluZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAidGV4dGJveCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoImFyaWEtbXVsdGlsaW5lIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNsYXNzTmFtZSA9ICJpbnRlcm5hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiaWQiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvckRpdklkKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdGluZygpOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfZnJlZV90ZXh0Ml9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGVkaXRvckRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZWRpdG9yRGl2ID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJmcmVlX3RleHQyX2RlZmF1bHRfY29udGVudCIpLnRoZW4obXNnID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRlZGl0b3JEaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChfdGhpcyRlZGl0b3JEaXYyID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGVkaXRvckRpdjIuc2V0QXR0cmlidXRlKCJkZWZhdWx0LWNvbnRlbnQiLCBtc2cpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZWRpdG9yRGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSl9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLmVkaXRvckRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXlEaXYuY2xhc3NMaXN0LmFkZCgib3ZlcmxheSIsICJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLm92ZXJsYXlEaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3Rvb2xzLmJpbmRFdmVudHMpKHRoaXMsIHRoaXMuZGl2LCBbImRibGNsaWNrIiwgImtleWRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLndpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0KGJhc2VYICogcGFyZW50V2lkdGgsIGJhc2VZICogcGFyZW50SGVpZ2h0LCB0aGlzLndpZHRoICogcGFyZW50V2lkdGgsIHRoaXMuaGVpZ2h0ICogcGFyZW50SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRlbnQpLnNwbGl0KCJcbiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChsaW5lID8gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUobGluZSkgOiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJiciIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hcHBlbmQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5jb250ZW50RWRpdGFibGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50RGl2KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBzdXBlci5kZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9mb250U2l6ZSwgZGF0YS5mb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9jb2xvciwgX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZGF0YS5jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfY29udGVudCwgZGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlcmlhbGl6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkaW5nID0gRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyAqIHRoaXMucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLmdldFJlY3QocGFkZGluZywgcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmlzQXR0YWNoZWRUb0RPTSA/IGdldENvbXB1dGVkU3R5bGUodGhpcy5lZGl0b3JEaXYpLmNvbG9yIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvblR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhULAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb250ZW50KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHRoaXMucm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gRnJlZVRleHRFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlRm9udFNpemUyKGZvbnRTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2V0Rm9udHNpemUgPSBzaXplID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc3R5bGUuZm9udFNpemUgPSBgY2FsYygke3NpemV9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRlKDAsIC0oc2l6ZSAtIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHRoaXMucGFyZW50U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2ZvbnRTaXplLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucywgX3NldEVkaXRvckRpbWVuc2lvbnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGb250c2l6ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnRzaXplKGZvbnRTaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Rm9udHNpemUoc2F2ZWRGb250c2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbG9yKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgY21kOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NvbG9yLCB0aGlzLmVkaXRvckRpdi5zdHlsZS5jb2xvciA9IGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgdGhpcy5lZGl0b3JEaXYuc3R5bGUuY29sb3IgPSBzYXZlZENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX0NPTE9SLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V4dHJhY3RUZXh0MigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZzID0gdGhpcy5lZGl0b3JEaXYuZ2V0RWxlbWVudHNCeVRhZ05hbWUoImRpdiIpOwogICAgICAgICAgICAgICAgICAgIGlmIChkaXZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXYuaW5uZXJUZXh0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiBkaXZzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGRpdi5pbm5lclRleHQucmVwbGFjZSgvXHJcbj98XG4vLCAiIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVmZmVyLmpvaW4oIlxuIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0RWRpdG9yRGltZW5zaW9uczIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIGxldCByZWN0OwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQXR0YWNoZWRUb0RPTSkgewogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gdGhpcy5kaXYuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZERpc3BsYXkgPSBkaXYuc3R5bGUuZGlzcGxheTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLmRpc3BsYXkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLmRpdi5hcHBlbmQodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdi5zdHlsZS5kaXNwbGF5ID0gc2F2ZWREaXNwbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLndpZHRoID0gcmVjdC53aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gcmVjdC5oZWlnaHQgLyBwYXJlbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZnJlZVRleHREZWZhdWx0Q29udGVudCIsICIiKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShGcmVlVGV4dEVkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfaW50ZXJuYWxQYWRkaW5nIiwgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdENvbG9yIiwgbnVsbCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdEZvbnRTaXplIiwgMTApOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KEZyZWVUZXh0RWRpdG9yLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBfdG9vbHMuS2V5Ym9hcmRNYW5hZ2VyKFtbWyJjdHJsK0VudGVyIiwgIm1hYyttZXRhK0VudGVyIiwgIkVzY2FwZSIsICJtYWMrRXNjYXBlIl0sIEZyZWVUZXh0RWRpdG9yLnByb3RvdHlwZS5jb21taXRPclJlbW92ZV1dKSk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfdHlwZSIsICJmcmVldGV4dCIpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgImZpdEN1cnZlIiwgKHsKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3BkZmpzRml0Q3VydmUuZml0Q3VydmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9wZGZqc0ZpdEN1cnZlID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjUpOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RlZmluZVByb3BlcnR5KG9iaiwga2V5LCB2YWx1ZSkgeyBrZXkgPSBfdG9Qcm9wZXJ0eUtleShrZXkpOyBpZiAoa2V5IGluIG9iaikgeyBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBrZXksIHsgdmFsdWU6IHZhbHVlLCBlbnVtZXJhYmxlOiB0cnVlLCBjb25maWd1cmFibGU6IHRydWUsIHdyaXRhYmxlOiB0cnVlIH0pOyB9IGVsc2Ugey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dmF0ZU1ldGhvZEdldChyZWNlaXZlciwgcHJpdmF0ZVNldCwgZm4pIHsgaWYgKCFwcml2YXRlU2V0LmhhcyhyZWNlaXZlcikpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIGdldCBwcml2YXRlIGZpZWxkIG9uIG5vbi1pbnN0YW5jZSIpOyB9IHJldHVybiBmbjsgfQogICAgICAgICAgICAgICAgY29uc3QgUkVTSVpFUl9TSVpFID0gMTY7CiAgICAgICAgICAgICAgICB2YXIgX2FzcGVjdFJhdGlvID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Jhc2VIZWlnaHQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYmFzZVdpZHRoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVybGVhdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVydXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlRWRpdGluZyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0NhbnZhc0luaXRpYWxpemVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2xhc3RQb2ludCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9vYnNlcnZlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZWFsV2lkdGggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVhbEhlaWdodCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZXF1ZXN0RnJhbWVDYWxsYmFjayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVUaGlja25lc3MgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlQ29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlT3BhY2l0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRJbml0aWFsQkJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRTdHJva2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RhcnREcmF3aW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2RyYXcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RvcERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVkcmF3ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuZERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY3JlYXRlQ2FudmFzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU9ic2VydmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NldENhbnZhc0RpbXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0U2NhbGVGYWN0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlVHJhbnNmb3JtID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZVBhdGhzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2V4dHJhY3RQb2ludHNPbkJlemllciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0FsbW9zdEZsYXQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfZ2V0QmJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRQYWRkaW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2ZpdFRvQ29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRNaW5EaW1zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBJbmtFZGl0b3IgZXh0ZW5kcyBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi5wYXJhbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiaW5rRWRpdG9yIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNaW5EaW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9maXRUb0NvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldFBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEJib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzQWxtb3N0RmxhdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFBvaW50c09uQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemVQYXRocyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0Q2FudmFzRGltcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NyZWF0ZUNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5kRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfcmVkcmF3KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zdG9wRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZHJhdyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc3RhcnREcmF3aW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTdHJva2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEluaXRpYWxCQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVPcGFjaXR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVGhpY2tuZXNzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2FzcGVjdFJhdGlvLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYmFzZUhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Jhc2VXaWR0aCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcm1vdmUuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJsZWF2ZS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcnVwLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJkb3duLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kaXNhYmxlRWRpdGluZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2xhc3RQb2ludCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ic2VydmVyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbFdpZHRoLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbEhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yID0gcGFyYW1zLmNvbG9yIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gcGFyYW1zLnRoaWNrbmVzcyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBwYXJhbXMub3BhY2l0eSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJEID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZUZhY3RvciA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25YID0gdGhpcy50cmFuc2xhdGlvblkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiLCAiZWRpdG9yX2luazJfYXJpYV9sYWJlbCJdLm1hcChzdHIgPT4gW3N0ciwgbDEwbi5nZXQoc3RyKV0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1M6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRPcGFjaXR5ID0gdmFsdWUgLyAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZVRoaWNrbmVzcywgX3VwZGF0ZVRoaWNrbmVzczIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVPcGFjaXR5LCBfdXBkYXRlT3BhY2l0eTIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX1RISUNLTkVTUywgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKElua0VkaXRvci5fZGVmYXVsdE9wYWNpdHkgKiAxMDApXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1MsIHRoaXMudGhpY2tuZXNzIHx8IElua0VkaXRvci5fZGVmYXVsdFRoaWNrbmVzc10sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1IsIHRoaXMuY29sb3IgfHwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKDEwMCAqICh0aGlzLm9wYWNpdHkgPz8gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eSkpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlYnVpbGQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZU9ic2VydmVyLCBfY3JlYXRlT2JzZXJ2ZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldENhbnZhc0RpbXMsIF9zZXRDYW52YXNEaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9maXRUb0NvbnRlbnQsIF9maXRUb0NvbnRlbnQyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbnZhcyA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMud2lkdGggPSB0aGlzLmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29ic2VydmVyKS5kaXNjb25uZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0UGFyZW50KHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGFyZW50ICYmIHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLnJlbW92ZVNob3VsZFJlc2NhbGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5wYXJlbnQgJiYgcGFyZW50ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkU2hvdWxkUmVzY2FsZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5zZXRQYXJlbnQocGFyZW50KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1lbnNpb25zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpIHx8IHRoaXMuY2FudmFzID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNJbkVkaXRNb2RlKCkgfHwgdGhpcy5jYW52YXMgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gIXRoaXMuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QucmVtb3ZlKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSAhdGhpcy5pc0VtcHR5KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMCB8fCB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMSAmJiB0aGlzLnBhdGhzWzBdLmxlbmd0aCA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZElua0VkaXRvcklmTmVlZGVkKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5tb3ZlRWRpdG9ySW5ET00odGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvY3VzaW4oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZm9jdXNpbihldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmJ1dHRvbiAhPT0gMCB8fCAhdGhpcy5pc0luRWRpdE1vZGUoKSB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5Gb3JlZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50eXBlICE9PSAibW91c2UiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5hZGRFdmVudExpc3RlbmVyKCJwb2ludGVybGVhdmUiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJtb3ZlIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJtb3ZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0YXJ0RHJhd2luZywgX3N0YXJ0RHJhd2luZzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJtb3ZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kcmF3LCBfZHJhdzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJbkVkaXRNb2RlKCkgJiYgdGhpcy5jdXJyZW50UGF0aC5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5kRHJhd2luZywgX2VuZERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmxlYXZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2VuZERyYXdpbmcsIF9lbmREcmF3aW5nMikuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIElua0VkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfaW5rMl9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZGl2ID0gdGhpcy5kaXYpID09PSBudWxsIHx8IF90aGlzJGRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeSwgdywgaF0gPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRJbml0aWFsQkJveCwgX2dldEluaXRpYWxCQm94MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdCh4LCB5LCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVDYW52YXMsIF9jcmVhdGVDYW52YXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdChiYXNlWCAqIHBhcmVudFdpZHRoLCBiYXNlWSAqIHBhcmVudEhlaWdodCwgdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoLCB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lzQ2FudmFzSW5pdGlhbGl6ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHRoaXMud2lkdGggKiBwYXJlbnRXaWR0aCwgdGhpcy5oZWlnaHQgKiBwYXJlbnRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldE1pbkRpbXMsIF9zZXRNaW5EaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QuYWRkKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIsIF9jcmVhdGVPYnNlcnZlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RGltZW5zaW9ucyh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvdW5kZWRXaWR0aCA9IE1hdGgucm91bmQod2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZGVkSGVpZ2h0ID0gTWF0aC5yb3VuZChoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsV2lkdGgpID09PSByb3VuZGVkV2lkdGggJiYgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsSGVpZ2h0KSA9PT0gcm91bmRlZEhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVhbFdpZHRoLCByb3VuZGVkV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIHJvdW5kZWRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAmJiBNYXRoLmFicyhfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAtIHdpZHRoIC8gaGVpZ2h0KSA+IDFlLTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9IE1hdGguY2VpbCh3aWR0aCAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGltcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhlaWdodCA9IGhlaWdodCAvIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbCh0aGlzLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRDYW52YXNEaW1zLCBfc2V0Q2FudmFzRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnN0eWxlLnZpc2liaWxpdHkgPSAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZml4RGltcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gc3VwZXIuZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudGhpY2tuZXNzID0gZGF0YS50aGlja25lc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmRhdGEuY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iub3BhY2l0eSA9IGRhdGEub3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF0gPSBlZGl0b3IucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gZWRpdG9yLndpZHRoICogcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBlZGl0b3IuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3IgPSBlZGl0b3IucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBkYXRhLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9hc3BlY3RSYXRpbywgd2lkdGggLyBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfZGlzYWJsZUVkaXRpbmcsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfcmVhbFdpZHRoLCBNYXRoLnJvdW5kKHdpZHRoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9yZWFsSGVpZ2h0LCBNYXRoLnJvdW5kKGhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcgogICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGRhdGEucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wYXRocy5wdXNoKHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyWzBdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcDEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbMV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2ldIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDExID0gc2NhbGVGYWN0b3IgKiAoaGVpZ2h0IC0gYmV6aWVyW2kgKyAxXSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHNjYWxlRmFjdG9yICogKGJlemllcltpICsgMl0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMjEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbaSArIDNdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2kgKyA0XSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzMSA9IHNjYWxlRmFjdG9yICogKGhlaWdodCAtIGJlemllcltpICsgNV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goW1twMCwgcDFdLCBbcDEwLCBwMTFdLCBbcDIwLCBwMjFdLCBbcDMwLCBwMzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDAgPSBwMzA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDEgPSBwMzE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoMkQgPSBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKHRoaXMsIHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmJlemllclBhdGgyRC5wdXNoKHBhdGgyRCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQoZWRpdG9yLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KGVkaXRvciwgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldChlZGl0b3IsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbChlZGl0b3IsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXJpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZ2V0UmVjdCgwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5yb3RhdGlvbiAlIDE4MCA9PT0gMCA/IHJlY3RbM10gLSByZWN0WzFdIDogcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmN0eC5zdHJva2VTdHlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uVHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlja25lc3M6IHRoaXMudGhpY2tuZXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BhY2l0eTogdGhpcy5vcGFjaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aHM6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZVBhdGhzLCBfc2VyaWFsaXplUGF0aHMyKS5jYWxsKHRoaXMsIHRoaXMuc2NhbGVGYWN0b3IgLyB0aGlzLnBhcmVudFNjYWxlLCB0aGlzLnRyYW5zbGF0aW9uWCwgdGhpcy50cmFuc2xhdGlvblksIGhlaWdodCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB0aGlzLnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSBJbmtFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlVGhpY2tuZXNzMih0aGlja25lc3MpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZFRoaWNrbmVzcyA9IHRoaXMudGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gdGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZml0VG9Db250ZW50LCBfZml0VG9Db250ZW50MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50aGlja25lc3MgPSBzYXZlZFRoaWNrbmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG86ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBzYXZlZENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwKICAgICAgICAgICAgICAgICAgICAgICAgb3ZlcndyaXRlSWZTYW1lVHlwZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAga2VlcFVuZG86IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF91cGRhdGVPcGFjaXR5MihvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgb3BhY2l0eSAvPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRPcGFjaXR5ID0gdGhpcy5vcGFjaXR5OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA9IG9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICB1bmRvOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBzYXZlZE9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX09QQUNJVFksCiAgICAgICAgICAgICAgICAgICAgICAgIG92ZXJ3cml0ZUlmU2FtZVR5cGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGtlZXBVbmRvOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0SW5pdGlhbEJCb3gyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Um90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudERpbWVuc2lvbnM6IFt3aWR0aCwgaGVpZ2h0XQogICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAocGFyZW50Um90YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMCwgaGVpZ2h0LCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3dpZHRoLCBoZWlnaHQsIHdpZHRoLCBoZWlnaHRdOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbd2lkdGgsIDAsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0U3Ryb2tlMigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgIG9wYWNpdHksCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzcywKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50U2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlRmFjdG9yCiAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHRoaWNrbmVzcyAqIHBhcmVudFNjYWxlIC8gc2NhbGVGYWN0b3I7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAicm91bmQiOwogICAgICAgICAgICAgICAgICAgIGN0eC5saW5lSm9pbiA9ICJyb3VuZCI7CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1pdGVyTGltaXQgPSAxMDsKICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBgJHtjb2xvcn0keygwLCBfdG9vbHMub3BhY2l0eVRvSGV4KShvcGFjaXR5KX1gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0YXJ0RHJhd2luZzIoeCwgeSkgewogICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaXNDYW52YXNJbml0aWFsaXplZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRoaWNrbmVzcyB8fD0gSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yIHx8PSBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA/Pz0gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50UGF0aC5wdXNoKFt4LCB5XSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9sYXN0UG9pbnQsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldFN0cm9rZSwgX3NldFN0cm9rZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVxdWVzdEZyYW1lQ2FsbGJhY2ssICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2xhc3RQb2ludCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGVhclJlY3QoMCwgMCwgdGhpcy5jYW52YXMud2lkdGgsIHRoaXMuY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5saW5lVG8oLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9sYXN0UG9pbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RyYXcyKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbbGFzdFgsIGxhc3RZXSA9IHRoaXMuY3VycmVudFBhdGguYXQoLTEpOwogICAgICAgICAgICAgICAgICAgIGlmICh4ID09PSBsYXN0WCAmJiB5ID09PSBsYXN0WSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBbeCwgeV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0b3BEcmF3aW5nMih4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGgubWluKE1hdGgubWF4KHgsIDApLCB0aGlzLmNhbnZhcy53aWR0aCk7CiAgICAgICAgICAgICAgICAgICAgeSA9IE1hdGgubWluKE1hdGgubWF4KHksIDApLCB0aGlzLmNhbnZhcy5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtsYXN0WCwgbGFzdFldID0gdGhpcy5jdXJyZW50UGF0aC5hdCgtMSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHggIT09IGxhc3RYIHx8IHkgIT09IGxhc3RZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgYmV6aWVyOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCAhPT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICBiZXppZXIgPSAoMCwgX3BkZmpzRml0Q3VydmUuZml0Q3VydmUpKHRoaXMuY3VycmVudFBhdGgsIDMwLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4eSA9IFt4LCB5XTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6aWVyID0gW1t4eSwgeHkuc2xpY2UoKSwgeHkuc2xpY2UoKSwgeHldXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGF0aDJEID0gX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChJbmtFZGl0b3IsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKElua0VkaXRvciwgYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzLnB1c2goYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iZXppZXJQYXRoMkQucHVzaChwYXRoMkQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuZG8gPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGF0aHMucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJELnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wYXRocy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVPYnNlcnZlciwgX2NyZWF0ZU9ic2VydmVyMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfcmVkcmF3MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTdHJva2UsIF9zZXRTdHJva2UyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGVhclJlY3QoMCwgMCwgY2FudmFzLndpZHRoLCBjYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVUcmFuc2Zvcm0sIF91cGRhdGVUcmFuc2Zvcm0yKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLmJlemllclBhdGgyRCkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKHBhdGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmREcmF3aW5nMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0b3BEcmF3aW5nLCBfc3RvcERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50Lm9mZnNldFgsIGV2ZW50Lm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJsZWF2ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybGVhdmUpKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmVFdmVudExpc3RlbmVyKCJwb2ludGVybW92ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybW92ZSkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUNhbnZhczIoKSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IHRoaXMuY2FudmFzLmhlaWdodCA9IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMuY2xhc3NOYW1lID0gImlua0VkaXRvckNhbnZhcyI7CiAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9sMTBuUHJvbWlzZS5nZXQoImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiKS50aGVuKG1zZyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkY2FudmFzID0gdGhpcy5jYW52YXMpID09PSBudWxsIHx8IF90aGlzJGNhbnZhcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY2FudmFzLnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKHRoaXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY3JlYXRlT2JzZXJ2ZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG5ldyBSZXNpemVPYnNlcnZlcihlbnRyaWVzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IGVudHJpZXNbMF0uY29udGVudFJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0LndpZHRoICYmIHJlY3QuaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldERpbWVuc2lvbnMocmVjdC53aWR0aCwgcmVjdC5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2JzZXJ2ZXIpLm9ic2VydmUodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldENhbnZhc0RpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnRXaWR0aCwgcGFyZW50SGVpZ2h0XSA9IHRoaXMucGFyZW50RGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IE1hdGguY2VpbCh0aGlzLndpZHRoICogcGFyZW50V2lkdGgpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmhlaWdodCA9IE1hdGguY2VpbCh0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZXRTY2FsZUZhY3RvcjIod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRQYWRkaW5nLCBfZ2V0UGFkZGluZzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JXID0gKHdpZHRoIC0gcGFkZGluZykgLyBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Jhc2VXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JIID0gKGhlaWdodCAtIHBhZGRpbmcpIC8gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9iYXNlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnNjYWxlRmFjdG9yID0gTWF0aC5taW4oc2NhbGVGYWN0b3JXLCBzY2FsZUZhY3RvckgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZVRyYW5zZm9ybTIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFkZGluZyA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2dldFBhZGRpbmcsIF9nZXRQYWRkaW5nMikuY2FsbCh0aGlzKSAvIDI7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKHRoaXMuc2NhbGVGYWN0b3IsIDAsIDAsIHRoaXMuc2NhbGVGYWN0b3IsIHRoaXMudHJhbnNsYXRpb25YICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcsIHRoaXMudHJhbnNsYXRpb25ZICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2J1aWxkUGF0aDJEKGJlemllcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGgyRCA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbZmlyc3QsIGNvbnRyb2wxLCBjb250cm9sMiwgc2Vjb25kXSA9IGJlemllcltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5tb3ZlVG8oLi4uZmlyc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5iZXppZXJDdXJ2ZVRvKGNvbnRyb2wxWzBdLCBjb250cm9sMVsxXSwgY29udHJvbDJbMF0sIGNvbnRyb2wyWzFdLCBzZWNvbmRbMF0sIHNlY29uZFsxXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXRoMkQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplUGF0aHMyKHMsIHR4LCB0eSwgaCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE5VTUJFUl9PRl9QT0lOVFNfT05fQkVaSUVSX0NVUlZFID0gNDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IFtdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSB0aGlzLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGJ1ZmZlciwgcG9pbnRzOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmV6aWVyIG9mIHRoaXMucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gPSBiZXppZXJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMTAgPSBzICogKGZpcnN0WzBdICsgdHgpICsgcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAxMSA9IGggLSBzICogKGZpcnN0WzFdICsgdHkpIC0gcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHMgKiAoY29udHJvbDFbMF0gKyB0eCkgKyBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIxID0gaCAtIHMgKiAoY29udHJvbDFbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gcyAqIChjb250cm9sMlswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMzEgPSBoIC0gcyAqIChjb250cm9sMlsxXSArIHR5KSAtIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDAgPSBzICogKHNlY29uZFswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDEgPSBoIC0gcyAqIChzZWNvbmRbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIucHVzaChwMTAsIHAxMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocDEwLCBwMTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2gocDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0UG9pbnRzT25CZXppZXIsIF9leHRyYWN0UG9pbnRzT25CZXppZXIyKS5jYWxsKHRoaXMsIHAxMCwgcDExLCBwMjAsIHAyMSwgcDMwLCBwMzEsIHA0MCwgcDQxLCBOVU1CRVJfT0ZfUE9JTlRTX09OX0JFWklFUl9DVVJWRSwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcjogYnVmZmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0aHM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZXh0cmFjdFBvaW50c09uQmV6aWVyMihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSwgbiwgcG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzQWxtb3N0RmxhdCwgX2lzQWxtb3N0RmxhdDIpLmNhbGwodGhpcywgcDEwLCBwMTEsIHAyMCwgcDIxLCBwMzAsIHAzMSwgcDQwLCBwNDEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHA0MCwgcDQxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IGkgLyBuOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTEwID0gdCAqIHAxMCArIG10ICogcDIwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTExID0gdCAqIHAxMSArIG10ICogcDIxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIwID0gdCAqIHAyMCArIG10ICogcDMwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIxID0gdCAqIHAyMSArIG10ICogcDMxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxMzAgPSB0ICogcDMwICsgbXQgKiBwNDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHEzMSA9IHQgKiBwMzEgKyBtdCAqIHA0MTsKICAgICAgICAgICAgICAgICAgICAgICAgcTEwID0gdCAqIHExMCArIG10ICogcTIwOwogICAgICAgICAgICAgICAgICAgICAgICBxMTEgPSB0ICogcTExICsgbXQgKiBxMjE7CiAgICAgICAgICAgICAgICAgICAgICAgIHEyMCA9IHQgKiBxMjAgKyBtdCAqIHEzMDsKICAgICAgICAgICAgICAgICAgICAgICAgcTIxID0gdCAqIHEyMSArIG10ICogcTMxOwogICAgICAgICAgICAgICAgICAgICAgICBxMTAgPSB0ICogcTEwICsgbXQgKiBxMjA7CiAgICAgICAgICAgICAgICAgICAgICAgIHExMSA9IHQgKiBxMTEgKyBtdCAqIHEyMTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocTEwLCBxMTEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNBbG1vc3RGbGF0MihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvbCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF4ID0gKDMgKiBwMjAgLSAyICogcDEwIC0gcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF5ID0gKDMgKiBwMjEgLSAyICogcDExIC0gcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ4ID0gKDMgKiBwMzAgLSBwMTAgLSAyICogcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5ID0gKDMgKiBwMzEgLSBwMTEgLSAyICogcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLm1heChheCwgYngpICsgTWF0aC5tYXgoYXksIGJ5KSA8PSB0b2w7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0QmJveDIoKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHhNaW4gPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeE1heCA9IC1JbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeU1pbiA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGxldCB5TWF4ID0gLUluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLnBhdGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gb2YgcGF0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF91dGlsLlV0aWwuYmV6aWVyQm91bmRpbmdCb3goLi4uZmlyc3QsIC4uLmNvbnRyb2wxLCAuLi5jb250cm9sMiwgLi4uc2Vjb25kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNaW4gPSBNYXRoLm1pbih4TWluLCBiYm94WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNaW4gPSBNYXRoLm1pbih5TWluLCBiYm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNYXggPSBNYXRoLm1heCh4TWF4LCBiYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNYXggPSBNYXRoLm1heCh5TWF4LCBiYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hNaW4sIHlNaW4sIHhNYXgsIHlNYXhdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2dldFBhZGRpbmcyKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSA/IE1hdGguY2VpbCh0aGlzLnRoaWNrbmVzcyAqIHRoaXMucGFyZW50U2NhbGUpIDogMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9maXRUb0NvbnRlbnQyKCkgewogICAgICAgICAgICAgICAgICAgIGxldCBmaXJzdFRpbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94ID0gX2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aGlzLCBfYXNwZWN0UmF0aW8sIHdpZHRoIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRNaW5EaW1zLCBfc2V0TWluRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldlRyYW5zbGF0aW9uWCA9IHRoaXMudHJhbnNsYXRpb25YOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZUcmFuc2xhdGlvblkgPSB0aGlzLnRyYW5zbGF0aW9uWTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zbGF0aW9uWCA9IC1iYm94WzBdOwogICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25ZID0gLWJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZWFsV2lkdGgsIHdpZHRoKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2NhbGVkUGFkZGluZyA9IGZpcnN0VGltZSA/IHBhZGRpbmcgLyB0aGlzLnNjYWxlRmFjdG9yIC8gMiA6IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUocHJldlRyYW5zbGF0aW9uWCAtIHRoaXMudHJhbnNsYXRpb25YIC0gdW5zY2FsZWRQYWRkaW5nLCBwcmV2VHJhbnNsYXRpb25ZIC0gdGhpcy50cmFuc2xhdGlvblkgLSB1bnNjYWxlZFBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1pbkRpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pID49IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluSGVpZ2h0ID0gYCR7UkVTSVpFUl9TSVpFfXB4YDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtNYXRoLnJvdW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pICogUkVTSVpFUl9TSVpFKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtSRVNJWkVSX1NJWkV9cHhgOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5taW5IZWlnaHQgPSBgJHtNYXRoLnJvdW5kKFJFU0laRVJfU0laRSAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9kZWZhdWx0Q29sb3IiLCBudWxsKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdE9wYWNpdHkiLCAxKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdFRoaWNrbmVzcyIsIDEpOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoSW5rRWRpdG9yLCAiX3R5cGUiLCAiaW5rIik7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgZml0Q3VydmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gZml0Q3VydmU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3VydmUocG9pbnRzLCBtYXhFcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkZpcnN0IGFyZ3VtZW50IHNob3VsZCBiZSBhbiBhcnJheSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaChwb2ludCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludCkgfHwgcG9pbnQuc29tZShpdGVtID0+IHR5cGVvZiBpdGVtICE9PSAnbnVtYmVyJykgfHwgcG9pbnQubGVuZ3RoICE9PSBwb2ludHNbMF0ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcigiRWFjaCBwb2ludCBzaG91bGQgYmUgYW4gYXJyYXkgb2YgbnVtYmVycy4gRWFjaCBwb2ludCBzaG91bGQgaGF2ZSB0aGUgc2FtZSBhbW91bnQgb2YgbnVtYmVycy4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IHBvaW50cy5maWx0ZXIoKHBvaW50LCBpKSA9PiBpID09PSAwIHx8ICFwb2ludC5ldmVyeSgodmFsLCBqKSA9PiB2YWwgPT09IHBvaW50c1tpIC0gMV1bal0pKTsKICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW4gPSBwb2ludHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlZnRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbMV0sIHBvaW50c1swXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmlnaHRUYW5nZW50ID0gY3JlYX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ICAgICAgfQogICAgICAgICAgICAgICAgICAgIHUgPSBjaG9yZExlbmd0aFBhcmFtZXRlcml6ZShwb2ludHMpOwogICAgICAgICAgICAgICAgICAgIFtiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCB1LCB1LCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBpZiAobWF4RXJyb3IgPT09IDAgfHwgbWF4RXJyb3IgPCBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG1heEVycm9yIDwgZXJyb3IgKiBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB1UHJpbWUgPSB1OwogICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZTcGxpdCA9IHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBNYXhJdGVyYXRpb25zOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVQcmltZSA9IHJlcGFyYW1ldGVyaXplKGJlekN1cnZlLCBwb2ludHMsIHVQcmltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbYmV6Q3VydmUsIG1heEVycm9yLCBzcGxpdFBvaW50XSA9IGdlbmVyYXRlQW5kUmVwb3J0KHBvaW50cywgdSwgdVByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhFcnJvciA8IGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNwbGl0UG9pbnQgPT09IHByZXZTcGxpdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcnJDaGFuZ2UgPSBtYXhFcnJvciAvIHByZXZFcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyckNoYW5nZSA+IC45OTk5ICYmIGVyckNoYW5nZSA8IDEuMDAwMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2U3BsaXQgPSBzcGxpdFBvaW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlemllcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBjZW50ZXJWZWN0b3IgPSBtYXRocy5zdWJ0cmFjdChwb2ludHNbc3BsaXRQb2ludCAtIDFdLCBwb2ludHNbc3BsaXRQb2ludCArIDFdKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY2VudGVyVmVjdG9yLmV2ZXJ5KHZhbCA9PiB2YWwgPT09IDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlclZlY3RvciA9IG1hdGhzLnN1YnRyYWN0KHBvaW50c1tzcGxpdFBvaW50IC0gMV0sIHBvaW50c1tzcGxpdFBvaW50XSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFtjZW50ZXJWZWN0b3JbMF0sIGNlbnRlclZlY3RvclsxXV0gPSBbLWNlbnRlclZlY3RvclsxXSwgY2VudGVyVmVjdG9yWzBdXTsKICAgICAgICAgICA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UG9pbnRdID0gY29tcHV0ZU1heEVycm9yKHBvaW50cywgYmV6Q3VydmUsIHBhcmFtc09yaWcpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0NhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzQ2FsbGJhY2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmV6OiBiZXpDdXJ2ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50czogcG9pbnRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiBwYXJhbXNPcmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4RXJyOiBtYXhFcnJvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heFBvaW50OiBzcGxpdFBvaW50CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlLCBtYXhFcnJvciwgc3BsaXRQb2ludF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtZXRlcnMsIGxlZnRUYW5nZW50LCByaWdodFRhbmdlbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsCiAgICAgICAgICAgICAgICAgICAgICAgIEEsCiAgICAgICAgICAgICAgICAgICAgICAgIGEsCiAgICAgICAgICAgICAgICAgICAgICAgIEMsCiAgICAgICAgICAgICAgICAgICAgICAgIFgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSwKICAgICAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1gsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9YX0MxLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9sLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9yLAogICAgICAgICAgICAgICAgICAgICAgICBlcHNpbG9uLAogICAgICAgICAgICAgICAgICAgICAgICBzZWdMZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGksCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbiwKICAgICAgICAgICAgICAgICAgICAgICAgdG1wLAogICAgICAgICAgICAgICAgICAgICAgICB1LAogICAgICAgICAgICAgICAgICAgICAgICB1eCwKICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RQb2ludCA9IHBvaW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFBvaW50ID0gcG9pbnRzW3BvaW50cy5sZW5ndGggLSAxXTsKICAgICAgICAgICAgICAgICAgICBiZXpDdXJ2ZSA9IFtmaXJzdFBvaW50LCBudWxsLCBudWxsLCBsYXN0UG9pbnRdOwogICAgICAgICAgICAgICAgICAgIEEgPSBtYXRocy56ZXJvc19YeDJ4MihwYXJhbWV0ZXJzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcGFyYW1ldGVycy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB1ID0gcGFyYW1ldGVyc1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgdXggPSAxIC0gdTsKICAgICAgICAgICAgICAgICAgICAgICAgYSA9IEFbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGFbMF0gPSBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgMyAqIHUgKiAodXggKiB1eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBhWzFdID0gbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCAzICogdXggKiAodSAqIHUpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQyA9IFtbMCwgMF0sIFswLCAwXV07CiAgICAgICAgICAgICAgICAgICAgWCA9IFswLCAwXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBwb2ludHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdSA9IHBhcmFtZXRlcnNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGEgPSBBW2ldOwogICAgICAgICAgICAgICAgICAgICAgICBDWzBdWzBdICs9IG1hdGhzLmRvdChhWzBdLCBhWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ1swXVsxXSArPSBtYXRocy5kb3QoYVswXSwgYVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENbMV1bMF0gKz0gbWF0aHMuZG90KGFbMF0sIGFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICBDWzFdWzFdICs9IG1hdGhzLmRvdChhWzFdLCBhWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gbWF0aHMuc3VidHJhY3QocG9pbnRzW2ldLCBiZXppZXIucShbZmlyc3RQb2ludCwgZmlyc3RQb2ludCwgbGFzdFBvaW50LCBsYXN0UG9pbnRdLCB1KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMF0gKz0gbWF0aHMuZG90KGFbMF0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMV0gKz0gbWF0aHMuZG90KGFbMV0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSA9IENbMF1bMF0gKiBDWzFdWzFdIC0gQ1sxXVswXSAqIENbMF1bMV07CiAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1ggPSBDWzBdWzBdICogWFsxXSAtIENbMV1bMF0gKiBYWzBdOwogICAgICAgICAgICAgICAgICAgIGRldF9YX0MxID0gWFswXSAqIENbMV1bMV0gLSBYWzFdICogQ1swXVsxXTsKICAgICAgICAgICAgICAgICAgICBhbHBoYV9sID0gZGV0X0MwX0MxID09PSAwID8gMCA6IGRldF9YX0MxIC8gZGV0X0MwX0MxOwogICAgICAgICAgICAgICAgICAgIGFscGhhX3IgPSBkZXRfQzBfQzEgPT09IDAgPyAwIDogZGV0X0MwX1ggLyBkZXRfQzBfQzE7CiAgICAgICAgICAgICAgICAgICAgc2VnTGVuZ3RoID0gbWF0aHMudmVjdG9yTGVuKG1hdGhzLnN1YnRyYWN0KGZpcnN0UG9pbnQsIGxhc3RQb2ludCkpOwogICAgICAgICAgICAgICAgICAgIGVwc2lsb24gPSAxLjBlLTYgKiBzZWdMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFscGhhX2wgPCBlcHNpbG9uIHx8IGFscGhhX3IgPCBlcHNpbG9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBzZWdMZW5ndGggLyAzLjApKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmVbMl0gPSBtYXRocy5hZGRBcnJheXMobGFzdFBvaW50LCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIHNlZ0xlbmd0aCAvIDMuMCkpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBhbHBoYV9sKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzJdID0gbWF0aHMuYWRkQXJyYXlzKGxhc3RQb2ludCwgbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCBhbHBoYV9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXpDdXJ2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlcGFyYW1ldGVyaXplKGJlemllciwgcG9pbnRzLCBwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcmFtZXRlcnMubWFwKChwLCBpKSA9PiBuZXd0b25SYXBoc29uUm9vdEZpbmQoYmV6aWVyLCBwb2ludHNbaV0sIHApKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG5ld3RvblJhcGhzb25Sb290RmluZChiZXosIHBvaW50LCB1KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGQgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHUpLCBwb2ludCksCiAgICAgICAgICAgICAgICAgICAgICAgIHFwcmltZSA9IGJlemllci5xcHJpbWUoYmV6LCB1KSwKICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJhdG9yID0gbWF0aHMubXVsTWF0cml4KGQsIHFwcmltZSksCiAgICAgICAgICAgICAgICAgICAgICAgIGRlbm9taW5hdG9yID0gbWF0aHMuc3VtKG1hdGhzLnNxdWFyZUl0ZW1zKHFwcmltZSkpICsgMiAqIG1hdGhzLm11bE1hdHJpeChkLCBiZXppZXIucXByaW1lcHJpbWUoYmV6LCB1KSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlbm9taW5hdG9yID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1IC0gbnVtZXJhdG9yIC8gZGVub21pbmF0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY2hvcmRMZW5ndGhQYXJhbWV0ZXJpemUocG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHUgPSBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgY3VyclUsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZVLAogICAgICAgICAgICAgICAgICAgICAgICBwcmV2UDsKICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaCgocCwgaSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjdXJyVSA9IGkgPyBwcmV2VSArIG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChwLCBwcmV2UCkpIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgdS5wdXNoKGN1cnJVKTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlUgPSBjdXJyVTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlAgPSBwOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHUgPSB1Lm1hcCh4ID0+IHggLyBwcmV2VSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICA7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wdXRlTWF4RXJyb3IocG9pbnRzLCBiZXosIHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZGlzdCwgbWF4RGlzdCwgc3BsaXRQb2ludCwgdiwgaSwgY291bnQsIHBvaW50LCB0OwogICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSAwOwogICAgICAgICAgICAgICAgICAgIHNwbGl0UG9pbnQgPSBNYXRoLmZsb29yKHBvaW50cy5sZW5ndGggLyAyKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0X2Rpc3RNYXAgPSBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyhiZXosIDEwKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBjb3VudCA9IHBvaW50cy5sZW5ndGg7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ID0gcG9pbnRzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICB0ID0gZmluZF90KGJleiwgcGFyYW1ldGVyc1tpXSwgdF9kaXN0TWFwLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHQpLCBwb2ludCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSB2WzBdICogdlswXSArIHZbMV0gKiB2WzFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IG1heERpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaXRQb2ludCA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFttYXhEaXN0LCBzcGxpdFBvaW50XTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIHZhciBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyA9IGZ1bmN0aW9uIChiZXosIEJfcGFydHMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQl90X2N1cnI7CiAgICAgICAgICAgICAgICAgICAgdmFyIEJfdF9kaXN0ID0gWzBdOwogICAgICAgICAgICAgICAgICAgIHZhciBCX3RfcHJldiA9IGJlelswXTsKICAgICAgICAgICAgICAgICAgICB2YXIgc3VtTGVuID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8PSBCX3BhcnRzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2N1cnIgPSBiZXppZXIucShiZXosIGkgLyBCX3BhcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtTGVuICs9IG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChCX3RfY3VyciwgQl90X3ByZXYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2Rpc3QucHVzaChzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgICAgICBCX3RfcHJldiA9IEJfdF9jdXJyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBCX3RfZGlzdCA9IEJfdF9kaXN0Lm1hcCh4ID0+IHggLyBzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBCX3RfZGlzdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaW5kX3QoYmV6LCBwYXJhbSwgdF9kaXN0TWFwLCBCX3BhcnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbk1heCwgbGVuTWluLCB0TWF4LCB0TWluLCB0OwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAxOyBpIDw9IEJfcGFydHM7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW0gPD0gdF9kaXN0TWFwW2ldKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWluID0gKGkgLSAxKSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWF4ID0gaSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5NaW4gPSB0X2Rpc3RNYXBbaSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuTWF4ID0gdF9kaXN0TWFwW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IChwYXJhbSAtIGxlbk1pbikgLyAobGVuTWF4IC0gbGVuTWluKSAqICh0TWF4IC0gdE1pbikgKyB0TWluOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVUYW5nZW50KHBvaW50QSwgcG9pbnRCKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLm5vcm1hbGl6ZShtYXRocy5zdWJ0cmFjdChwb2ludEEsIHBvaW50QikpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgbWF0aHMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB6ZXJvc19YeDJ4Mih4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB6cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoeC0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB6cy5wdXNoKFswLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHpzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgbXVsSXRlbXMoaXRlbXMsIG11bHRpcGxpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggKiBtdWx0aXBsaWVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG11bE1hdHJpeChtMSwgbTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG0xLnJlZHVjZSgoc3VtLCB4MSwgaSkgPT4gc3VtICsgeDEgKiBtMltpXSwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzdWJ0cmFjdChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLm1hcCgoeDEsIGkpID0+IHgxIC0gYXJyMltpXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhZGRBcnJheXMoYXJyMSwgYXJyMikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5tYXAoKHgxLCBpKSA9PiB4MSArIGFycjJbaV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYWRkSXRlbXMoaXRlbXMsIGFkZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICsgYWRkaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc3VtKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5yZWR1Y2UoKHN1bSwgeCkgPT4gc3VtICsgeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkb3QobTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtYXRocy5tdWxNYXRyaXgobTEsIG0yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHZlY3Rvckxlbih2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmh5cG90KC4uLnYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGl2SXRlbXMoaXRlbXMsIGRpdmlzb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggLyBkaXZpc29yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNxdWFyZUl0ZW1zKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICogeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemUodikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXZJdGVtcyh2LCB0aGlzLnZlY3Rvckxlbih2KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgYmV6aWVyIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcShjdHJsUG9seSwgdCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHggPSAxLjAgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgcEEgPSBtYXRocy5tdWxJdGVtcyhjdHJsUG9seVswXSwgdHggKiB0eCAqIHR4KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBCID0gbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMV0sIDMgKiB0eCAqIHR4ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQyA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzJdLCAzICogdHggKiB0ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwRCA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzNdLCB0ICogdCAqIHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWF0aHMuYWRkQXJyYXlzKG1hdGhzLmFkZEFycmF5cyhwQSwgcEIpLCBtYXRocy5hZGRBcnJheXMocEMsIHBEKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBxcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHR4ID0gMS4wIC0gdDsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBBID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMV0sIGN0cmxQb2x5WzBdKSwgMyAqIHR4ICogdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcEIgPSBtYXRocy5tdWxJdGVtcyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVsyXSwgY3RybFBvbHlbMV0pLCA2ICogdHggKiB0KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbM10sIGN0cmxQb2x5WzJdKSwgMyAqIHQgKiB0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5hZGRBcnJheXMocEEsIHBCKSwgcEMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcXByaW1lcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5tdWxJdGVtcyhtYXRocy5hZGRBcnJheXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMl0sIG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzFdLCAyKSksIGN0cmxQb2x5WzBdKSwgNiAqICgxLjAgLSB0KSksIG1hdGhzLm11bEl0ZW1zKG1hdGhzLmFkZEFycmF5cyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVszXSwgbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMl0sIDIpKSwgY3RybFBvbHlbMV0pLCA2ICogdCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZml0Q3VydmU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cy5maXRDdWJpYyA9IGZpdEN1YmljOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuY3JlYXRlVGFuZ2VudCA9IGNyZWF0ZVRhbmdlbnQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25MYXllciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fc3RvcmFnZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM5KTsKICAgICAgICAgICAgICAgIHZhciBfc2NyaXB0aW5nX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjgpOwogICAgICAgICAgICAgICAgdmFyIF94ZmFfbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2OSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHJlY2VpdmVyLCBjbGFzc0NvbnN0cnVjdG9yLCBtZXRob2QpIHsgX2NsYXNzQ2hlY2tQcml2YXRlU3RhdGlj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BERUZBVUxUX1RBQl9JTkRFWCA9IDEwMDA7CiAgICAgICAgICAgICAgICBjb25zdCBERUZBVUxUX0ZPTlRfU0laRSA9IDk7CiAgICAgICAgICAgICAgICBjb25zdCBHZXRFbGVtZW50c0J5TmFtZVNldCA9IG5ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRSZWN0RGltcyhyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGg6IHJlY3RbMl0gLSByZWN0WzBdLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQ6IHJlY3RbM10gLSByZWN0WzFdCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25FbGVtZW50RmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGNyZWF0ZShwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YnR5cGUgPSBwYXJhbWV0ZXJzLmRhdGEuYW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoc3VidHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5MSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTGlua0Fubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5URVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5XSURHRVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRUeXBlID0gcGFyYW1ldGVycy5kYXRhLmZpZWxkVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGZpZWxkVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJUeCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFRleHRXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQnRuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbWV0ZXJzLmRhdGEucmFkaW9CdXR0b24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlvQnV0dG9uV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhcmFtZXRlcnMuZGF0YS5jaGVja0JveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2hlY2tib3hXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHVzaEJ1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJDaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT1BVUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRnJlZVRleHRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IExpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVQVJFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgU3F1YXJlQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNJUkNMRToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENpcmNsZUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT0xZTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNBUkVUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2FyZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSW5rQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT046CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQb2x5Z29uQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkhJR0hMSUdIVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEhpZ2hsaWdodEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5VTkRFUkxJTkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVbmRlcmxpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5TVFJJS0VPVVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdHJpa2VPdXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RBTVA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGFtcEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5GSUxFQVRUQUNITUVOVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEZpbGVBdHRhY2htZW50QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXIgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNSZW5kZXJhYmxlID0gaXNSZW5kZXJhYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEgPSBwYXJhbWV0ZXJzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGF5ZXIgPSBwYXJhbWV0ZXJzLmxheWVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2UgPSBwYXJhbWV0ZXJzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSBwYXJhbWV0ZXJzLnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmtTZXJ2aWNlID0gcGFyYW1ldGVycy5saW5rU2VydmljZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZE1hbmFnZXIgPSBwYXJhbWV0ZXJzLmRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbWFnZVJlc291cmNlc1BhdGggPSBwYXJhbWV0ZXJzLmltYWdlUmVzb3VyY2VzUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJGb3JtcyA9IHBhcmFtZXRlcnMucmVuZGVyRm9ybXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRmFjdG9yeSA9IHBhcmFtZXRlcnMuc3ZnRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZSA9IHBhcmFtZXRlcnMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlU2NyaXB0aW5nID0gcGFyYW1ldGVycy5lbmFibGVTY3JpcHRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGFzSlNBY3Rpb25zID0gcGFyYW1ldGVycy5oYXNKU0FjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZWxkT2JqZWN0cyA9IHBhcmFtZXRlcnMuZmllbGRPYmplY3RzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lciA9IHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjcmVhdGVRdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5xdWFkcmlsYXRlcmFscyA9IHRoaXMuX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKGlnbm9yZUJvcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUNvbnRhaW5lcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlnbm9yZUJvcmRlciA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNlY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnNldEF0dHJpYnV0ZSgiZGF0YS1hbm5vdGF0aW9uLWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLm5vUm90YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgibm9yb3RhdGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW2RhdGEucmVjdFswXSwgcGFnZS52aWV3WzNdIC0gZGF0YS5yZWN0WzFdICsgcGFnZS52aWV3WzFdLCBkYXRhLnJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIGRhdGEucmVjdFszXSArIHBhZ2Uudmlld1sxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlnbm9yZUJvcmRlciAmJiBkYXRhLmJvcmRlclN0eWxlLndpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlcldpZHRoID0gYCR7ZGF0YS5ib3JkZXJTdHlsZS53aWR0aH1weGA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBob3Jpem9udGFsUmFkaXVzID0gZGF0YS5ib3JkZXJTdHlsZS5ob3Jpem9udGFsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGljYWxSYWRpdXMgPSBkYXRhLmJvcmRlclN0eWxlLnZlcnRpY2FsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhvcml6b250YWxSYWRpdXMgPiAwIHx8IHZlcnRpY2FsUmFkaXVzID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhZGl1cyA9IGBjYWxjKCR7aG9yaXpvbnRhbFJhZGl1c31weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke3ZlcnRpY2FsUmFkaXVzfXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJSYWRpdXMgPSByYWRpdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMgaW5zdGFuY2VvZiBSYWRpb0J1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFkaXVzID0gYGNhbGMoJHt3aWR0aH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke2hlaWdodH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyUmFkaXVzID0gcmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChkYXRhLmJvcmRlclN0eWxlLnN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLlNPTElEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuREFTSEVEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAiZGFzaGVkIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLkJFVkVMRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBib3JkZXIgc3R5bGU6IGJldmVsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLklOU0VUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuaW1wbGVtZW50ZWQgYm9yZGVyIHN0eWxlOiBpbnNldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuVU5ERVJMSU5FOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyQm90dG9tU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlckNvbG9yID0gZGF0YS5ib3JkZXJDb2xvciB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJvcmRlckNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlckNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoYm9yZGVyQ29sb3JbMF0gfCAwLCBib3JkZXJDb2xvclsxXSB8IDAsIGJvcmRlckNvbG9yWzJdIHwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJXaWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocmVjdFswXSAtIHBhZ2VYKSAvIHBhZ2VXaWR0aH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLnRvcCA9IGAkezEwMCAqIChyZWN0WzFdIC0gcGFnZVkpIC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmhhc093bkNhbnZhcyB8fCByb3RhdGlvbiA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLndpZHRoID0gYCR7MTAwICogd2lkdGggLyBwYWdlV2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogaGVpZ2h0IC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24ocm90YXRpb24sIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Um90YXRpb24oYW5nbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRhaW5lciA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMudmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKHRoaXMuZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRXaWR0aCwgZWxlbWVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuZ2xlICUgMTgwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50V2lkdGggPSAxMDAgKiB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRIZWlnaHQgPSAxMDAgKiBoZWlnaHQgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFdpZHRoID0gMTAwICogaGVpZ2h0IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudEhlaWdodCA9IDEwMCAqIHdpZHRoIC8gcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUud2lkdGggPSBgJHtlbGVtZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5oZWlnaHQgPSBgJHtlbGVtZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc2V0QXR0cmlidXRlKCJkYXRhLW1haW4tcm90YXRpb24iLCAoMzYwIC0gYW5nbGUpICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9jb21tb25BY3Rpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXRDb2xvciA9IChqc05hbWUsIHN0eWxlTmFtZSwgZXZlbnQpID0+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/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1bnBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaGlkZUVsZW1lbnQuaGlkZGVuICYmICF0aGlzLnBpbm5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4ID0gcGFyc2VJbnQodGhpcy5jb250YWluZXIu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ICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0Q29udGVudCA9IHBhcmFtZXRlcnMuZGF0YS50ZXh0Q29udGVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQuY2xhc3NMaXN0LmFkZCgiYW5ub3RhdGlvblRleHRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LnNldEF0dHJpYnV0ZSgicm9sZSIsICJjb21tZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpbmUgb2YgdGhpcy50ZXh0Q29udGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVTcGFuID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVTcGFuLnRleHRDb250ZW50ID0gbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LmFwcGVuZChsaW5lU3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoY29udGVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIExpbmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250MyA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDMuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2gzID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMy5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmxpbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoIngxIiwgZGF0YS5yZWN0WzJdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgieTEiLCBkYXRhLnJlY3RbM10gLSBkYXRhLmxpbmVDb29yZGluYXRlc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmUuc2V0QXR0cmlidXRlKCJ4MiIsIGRhdGEucmVjdFsyXSAtIGRhdGEubGluZUNvb3JkaW5hdGVzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInkyIiwgZGF0YS5yZWN0WzNdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbM10pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInN0cm9rZSIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKGxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobGluZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVhcmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LCBfcGFyYW1ldGVycyRkYXRhJGNvbnQ0LCBfcGFyYW1ldGVycyRkYXRhJHJpY2g0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250NCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250NCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDQuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2g0ID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g0ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNC5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgic3F1YXJlQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZSh3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9yZGVyV2lkdGggPSBkYXRhLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcXVhcmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgieCIsIGJvcmRlcldpZHRoIC8gMik7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInkiLCBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIHdpZHRoIC0gYm9yZGVyV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCBoZWlnaHQgLSBib3JkZXJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInN0cm9rZS13aWR0aCIsIGJvcmRlcldpZHRoIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKHNxdWFyZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChzcXVhcmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQ2lyY2xlQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNSwgX3BhcmFtZXRlcnMkZGF0YSRjb250NSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw1ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw1ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ1LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDUuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNpcmNsZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gZGF0YS5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzplbGxpcHNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImN4Iiwgd2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgiY3kiLCBoZWlnaHQgLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgicngiLCB3aWR0aCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJyeSIsIGhlaWdodCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJzdHJva2Utd2lkdGgiLCBib3JkZXJXaWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChjaXJjbGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAoY2lyY2xlLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF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QogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCh0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBnZXRSZWN0RGltcyhkYXRhLnJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29vcmRpbmF0ZSBvZiBkYXRhLnZlcnRpY2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4ID0gY29vcmRpbmF0ZS54IC0gZGF0YS5yZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHggKyAiLCIgKyB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb2x5bGluZSA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KHRoaXMuc3ZnRWxlbWVudE5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoInBvaW50cyIsIHBvaW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJmaWxsIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAocG9seWxpbmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9seWdvbkFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgUG9seWxpbmVBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAicG9seWdvbkFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5Z29uIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYXJldEFubm90YXRpb25FbGVtZW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ICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJjYXJldEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIElua0Fubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDgsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDgsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsOCA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDguc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQ4ID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ4ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250OC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g4LnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAiaW5rQW5ub3RhdGlvbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRWxlbWVudE5hbWUgPSAic3ZnOnBvbHlsaW5lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKHRoaXMuY29udGFpbmVyQ2xhc3NOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5rTGlzdCBvZiBkYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNvb3JkaW5hdGUgb2YgaW5rTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBjb29yZGluYXRlLnggLSBkYXRhLnJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChgJHt4fSwke3l9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9seWxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCh0aGlzLnN2Z0VsZW1lbnROYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgicG9pbnRzIiwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKHBvbHlsaW5lLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSGlnaGxpZ2h0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOSwgX3BhcmFtZXRlcnMkZGF0YSRjb250OSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw5ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw5ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ5LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDkuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygiaGlnaGxpZ2h0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImhpZ2hsaWdodEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFVuZGVybGluZUFubm90YXRpb25FbGVtZW50I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VF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInVuZGVybGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJ1bmRlcmxpbmVBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MTEgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgU3RyaWtlT3V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMiA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygic3RyaWtlb3V0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0cmlrZW91dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYX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0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0YW1wQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZGF0YS5oYXNQb3B1cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobnVsbCwgdGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgRmlsZUF0dGFjaG1lbnRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmUxMDsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5maWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGVuYW1lID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEZpbGVuYW1lRnJvbVVybCkoZmlsZW5hbWUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnQgPSBjb250ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUxMCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAuZGlzcGF0Y2goImZpbGVhdHRhY2htZW50YW5ub3RhdGlvbiIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSR0aXRsZU9iaiwgX3RoaXMkZGF0YSRjb250ZW50c09iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmaWxlQXR0YWNobWVudEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyaWdnZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuaGFzQXBwZWFyYW5jZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImltZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5zcmMgPSBgJHt0aGlzLmltYWdlUmVzb3VyY2VzUGF0aH1hbm5vdGF0aW9uLSR7L3BhcGVyY2xpcC9pLnRlc3QodGhpcy5kYXRhLm5hbWUpID8gInBhcGVyY2xpcCIgOiAicHVzaHBpbiJ9LnN2Z2A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5jbGFzc0xpc3QuYWRkKCJwb3B1cFRyaWdnZXJBcmVhIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuYWRkRXZlbnRMaXN0ZW5lcigiZGJsY2xpY2siLCB0aGlzLl9kb3dubG9hZC5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXAgJiYgKChfdGhpcyRkYXRhJHRpdGxlT2JqID0gdGhpcy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSR0aXRsZU9iai5zdHIgfHwgKF90aGlzJGRhdGEkY29udGVudHNPYiA9IHRoaXMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iLnN0ciB8fCB0aGlzLmRhdGEucmljaFRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cCh0cmlnZ2VyLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZG93bmxvYWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkb3dubG9hZE1hbmFnZXIyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZG93bmxvYWRNYW5hZ2VyMiA9IHRoaXMuZG93bmxvYWRNYW5hZ2VyKSA9PT0gbnVsbCB8fCBfdGhpcyRkb3dubG9hZE1hbmFnZXIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIyLm9wZW5PckRvd25sb2FkRGF0YSh0aGlzLmNvbnRhaW5lciwgdGhpcy5jb250ZW50LCB0aGlzLmZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlcgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShkaXYsIHZpZXdwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcjogZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlOiBwYXJhbXMubGlua1NlcnZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZE1hbmFnZXI6IHBhcmFtcy5kb3dubG9hZE1hbmFnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWFnZVJlc291cmNlc1BhdGg6IHBhcmFtcy5pbWFnZVJlc291cmNlc1BhdGggfHwgIiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJGb3JtczogcGFyYW1zLnJlbmRlckZvcm1zICE9PSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Z0ZhY3Rvcnk6IG5ldyBfZGlzcGxheV91dGlscy5ET01TVkdGYWN0b3J5KCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogcGFyYW1zLmFubm90YXRpb25TdG9yYWdlIHx8IG5ldyBfYW5ub3RhdGlvbl9zdG9yYWdlLkFubm90YXRpb25TdG9yYWdlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVTY3JpcHRpbmc6IHBhcmFtcy5lbmFibGVTY3JpcHRpbmcgPT09IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnM6IHBhcmFtcy5oYXNKU0FjdGlvbnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZE9iamVjdHM6IHBhcmFtcy5maWVsZE9iamVjdHMKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHpJbmRleCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZGF0YSBvZiBhbm5vdGF0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubm9IVE1MKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5hbm5vdGF0aW9uVHlwZSAhPT0gX3V0aWwuQW5ub3RhdGlvblR5cGUuUE9QVVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggPD0gMCB8fCBoZWlnaHQgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50UGFyYW1zLmRhdGEgPSBkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IEFubm90YXRpb25FbGVtZW50RmFjdG9yeS5jcmVhdGUoZWxlbWVudFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQuaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZW5kZXJlZCA9IGVsZW1lbnQucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5oaWRkZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZW5kZXJlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlbmRlcmVkRWxlbWVudCBvZiByZW5kZXJlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZEVsZW1lbnQuc3R5bGUuekluZGV4ID0gekluZGV4Kys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQoQW5ub3RhdGlvbkxheWVyLCBBbm5vdGF0aW9uTGF5ZXIsIF9hcHBlbmRFbGVtZW50KS5jYWxsKEFubm90YXRpb25MYXllciwgcmVuZGVyZWRFbGVtZW50LCBkYXRhLmlkLCBkaXYsIGFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmVkLnN0eWxlLnpJbmRleCA9IHpJbmRleCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50IGluc3RhbmNlb2YgUG9wdXBBbm5vdGF0aW9uRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucHJlcGVuZChyZW5kZXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChBbm5vdGF0aW9uTGF5ZXIsIEFubm90YXRpb25MYXllciwgX2FwcGVuZEVsZW1lbnQpLmNhbGwoQW5ub3RhdGlvbkxheWVyLCByZW5kZXJlZCwgZGF0YS5pZCwgZGl2LCBhY2Nlc3NpYmlsaXR5TWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQodGhpcywgQW5ub3RhdGlvbkxheWVyLCBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcCkuY2FsbCh0aGlzLCBkaXYsIHBhcmFtcy5hbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGRpdiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHZpZXdwb3J0LnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIEFubm90YXRpb25MYXllciwgX3NldEFubm90YXRpb25DYW52YXNNYXApLmNhbGwodGhpcywgZGl2LCBhbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkxheWVyID0gQW5ub3RhdGlvbkxheWVyOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2FwcGVuZEVsZW1lbnQoZWxlbWVudCwgaWQsIGRpdiwgYWNjZXNzaWJpbGl0eU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50RWxlbWVudCA9IGVsZW1lbnQuZmlyc3RDaGlsZCB8fCBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnRFbGVtZW50LmlkID0gYCR7X2Rpc3BsYXlfdXRpbHMuQW5ub3RhdGlvblByZWZpeH0ke2lkfWA7CiAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gbnVsbCB8fCBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogYWNjZXNzaWJpbGl0eU1hbmFnZXIubW92ZUVsZW1lbnRJbkRPTShkaXYsIGVsZW1lbnQsIGNvbnRlbnRFbGVtZW50LCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcChkaXYsIGFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtpZCwgY2FudmFzXSBvZiBhbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBkaXYucXVlcnlTZWxlY3RvcihgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0Q2hpbGQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlyc3RDaGlsZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hcHBlbmQoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaXJzdENoaWxkLm5vZGVOYW1lID09PSAiQ0FOVkFTIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5yZXBsYWNlV2l0aChjYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5iZWZvcmUoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLmNsZWFyKCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG1ha2VDb2xvckNvbXAobikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmZsb29yKE1hdGgubWF4KDAsIE1hdGgubWluKDEsIG4pKSAqIDI1NSkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvckNvbnZlcnRlcnMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0coX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2MsIHksIG0sIGtdID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiRyIsIDEgLSBNYXRoLm1pbigxLCAwLjMgKiBjICsgMC41OSAqIG0gKyAwLjExICogeSArIGspXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIEdfQ01ZSyhfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCAwLCAwLCAwLCAxIC0gZ107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBHX1JHQihfcmVmMykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIlJHQiIsIGcsIGcsIGddOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgR19IVE1MKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbZ10gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRyA9IG1ha2VDb2xvckNvbXAoZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7R30ke0d9JHtHfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfRyhfcmVmNSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjU7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkciLCAwLjMgKiByICsgMC41OSAqIGcgKyAwLjExICogYl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfSFRNTChfcmVmNikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFIgPSBtYWtlQ29sb3JDb21wKHIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBHID0gbWFrZUNvbG9yQ29tcChnKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQiA9IG1ha2VDb2xvckNvbXAoYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7Un0ke0d9JHtCfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBUX0hUTUwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiIzAwMDAwMDAwIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIENNWUtfUkdCKF9yZWY3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbYywgeSwgbSwga10gPSBfcmVmNzsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiUkdCIiwgMSAtIE1hdGgubWluKDEsIGMgKyBrKSwgMSAtIE1hdGgubWluKDEsIG0gKyBrKSwgMSAtIE1hdGgubWluKDEsIHkgKyBrKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0hUTUwoY29tcG9uZW50cykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZ2IgPSB0aGlzLkNNWUtfUkdCKGNvbXBvbmVudHMpLnNsaWNlKDEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5SR0JfSFRNTChyZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUkdCX0NNWUsoX3JlZjgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtyLCBnLCBiXSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gMSAtIHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAxIC0gZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IDEgLSBiOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrID0gTWF0aC5taW4oYywgbSwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCBjLCBtLCB5LCBrXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IENvbG9yQ29udmVydGVyczsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTY5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+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/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhc2hBcnJheSA9IGN1cnJlbnQuZGFzaEFycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpbmVXaWR0aFNjYWxlICE9PSAxICYmIGRhc2hBcnJheS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGFzaEFycmF5ID0gZGFzaEFycmF5Lm1hcChmdW5jdGlvbiAodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpbmVXaWR0aFNjYWxlICogdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UiLCBjdXJyZW50LnN0cm9rZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInN0cm9rZS1vcGFjaXR5IiwgY3VycmVudC5zdHJva2VBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtbWl0ZXJsaW1pdCIsIHBmKGN1cnJlbnQubWl0ZXJMaW1pdCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVjYXAiLCBjdXJyZW50LmxpbmVDYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVqb2luIiwgY3VycmVudC5saW5lSm9pbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2Utd2lkdGgiLCBwZihsaW5lV2lkdGhTY2FsZSAqIGN1cnJlbnQubGluZVdpZHRoKSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWRhc2hhcnJheSIsIGRhc2hBcnJheS5tYXAocGYpLmpvaW4oIiAiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtZGFzaG9mZnNldCIsIHBmKGxpbmVXaWR0aFNjYWxlICogY3VycmVudC5kYXNoUGhhc2UpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW9GaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGN1cnJlbnQkZWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRjdXJyZW50JGVsZW1lbnQgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRjdXJyZW50JGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVvRmlsbFN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjdXJyZW50JGVsZW1lbnQyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGN1cnJlbnQkZWxlbWVudDIgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY3VycmVudCRlbGVtZW50Mi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbC1ydWxlIiwgImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlRU9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW9GaWxsU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRTb2xpZENvbG9ySW1hZ2VNYXNrKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsICIwIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQocmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZVhPYmplY3Qob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYERlcGVuZGVudCBpbWFnZSB3aXRoIG9iamVjdCBJRCAke29iaklkfSBpcyBub3QgcmVhZHkgeWV0YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhLCBtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ1NyYyA9IGNvbnZlcnRJbWdEYXRhVG9QbmcoaW1nRGF0YSwgdGhpcy5mb3JjZURhdGFTY2hlbWEsICEhbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJoZWlnaHQiLCBwZihoZWlnaHQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5lbGVtZW50ID0gY2xpcHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0VsID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzppbWFnZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMoWExJTktfTlMsICJ4bGluazpocmVmIiwgaW1nU3JjKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdFbC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIGBzY2FsZSgke3BmKDEgLyB3aWR0aCl9ICR7cGYoLTEgLyBoZWlnaHQpfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5hcHBlbmQoaW1nRWwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChpbWdFbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZU1hc2tYT2JqZWN0KGltZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nRGF0YSA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJwYWludEltYWdlTWFza1hPYmplY3Q6IEltYWdlQml0bWFwIHN1cHBvcnQgaXMgbm90IGltcGxlbWVudGVkLCAiICsgImVuc3VyZSB0aGF0IHRoZSBgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWRgIEFQSSBwYXJhbWV0ZXIgaXMgZGlzYWJsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lm1hc2tJZCA9IGBtYXNrJHttYXNrQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bWFzayIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjdXJyZW50Lm1hc2tJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCBwZih3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgZmlsbENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIm1hc2siLCBgdXJsKCMke2N1cnJlbnQubWFza0lkfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQobWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChyZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSwgbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luKG1hdHJpeCwgYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0obWF0cml4WzBdLCBtYXRyaXhbMV0sIG1hdHJpeFsyXSwgbWF0cml4WzNdLCBtYXRyaXhbNF0sIG1hdHJpeFs1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gYmJveFsyXSAtIGJib3hbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsIGJib3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgYmJveFsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmVsZW1lbnQgPSBjbGlwcmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kKCkge30KICAgICAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUodmlld3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodmlld3BvcnQud2lkdGgsIHZpZXdwb3J0LmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZpbml0aW9ucyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZGVmcyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChkZWZpbml0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMgPSBkZWZpbml0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RHcm91cCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh2aWV3cG9ydC50cmFuc2Zvcm0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocm9vdEdyb3VwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gcm9vdEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfZW5zdXJlQ2xpcEdyb3VwKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmN1cnJlbnQuY2xpcEdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcEdyb3VwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXBhdGgiLCB0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcuYXBwZW5kKGNsaXBHcm91cCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmNsaXBHcm91cCA9IGNsaXBHcm91cDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmN1cnJlbnQuY2xpcEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy50Z3JwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh0aGlzLnRyYW5zZm9ybU1hdHJpeCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVDbGlwR3JvdXAoKS5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Zy5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50Z3JwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KQogICAgICAgICAgICAvKioqKioqLyAJXSk7CiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIG1vZHVsZSBjYWNoZQogICAgICAgIC8qKioqKiovIAl2YXIgX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fID0ge307CiAgICAgICAgLyoqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIHJlcXVpcmUgZnVuY3Rpb24KICAgICAgICAvKioqKioqLyAJZnVuY3Rpb24gX193X3BkZmpzX3JlcXVpcmVfXyhtb2R1bGVJZCkgewogICAgICAgICAgICAvKioqKioqLyAJCS8vIENoZWNrIGlmIG1vZHVsZSBpcyBpbiBjYWNoZQogICAgICAgICAgICAvKioqKioqLyAJCXZhciBjYWNoZWRNb2R1bGUgPSBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX19bbW9kdWxlSWRdOwogICAgICAgICAgICAvKioqKioqLyAJCWlmIChjYWNoZWRNb2R1bGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgLyoqKioqKi8gCQkJcmV0dXJuIGNhY2hlZE1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9CiAgICAgICAgICAgIC8qKioqKiovIAkJLy8gQ3JlYXRlIGEgbmV3IG1vZHVsZSAoYW5kIHB1dCBpdCBpbnRvIHRoZSBjYWNoZSkKICAgICAgICAgICAgLyoqKioqKi8gCQl2YXIgbW9kdWxlID0gX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fW21vZHVsZUlkXSA9IHsKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5pZCBuZWVkZWQKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5sb2FkZWQgbmVlZGVkCiAgICAgICAgICAgICAgICAvKioqKioqLyAJCQlleHBvcnRzOiB7fQogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9OwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIEV4ZWN1dGUgdGhlIG1vZHVsZSBmdW5jdGlvbgogICAgICAgICAgICAvKioqKioqLyAJCV9fd2VicGFja19tb2R1bGVzX19bbW9kdWxlSWRdKG1vZHVsZSwgbW9kdWxlLmV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pOwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIFJldHVybiB0aGUgZXhwb3J0cyBvZiB0aGUgbW9kdWxlCiAgICAgICAgICAgIC8qKioqKiovIAkJcmV0dXJuIG1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAvKioqKioqLyAJfQogICAgICAgIC8qKioqKiovCiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICB2YXIgX193ZWJwYWNrX2V4cG9ydHNfXyA9IHt9OwovLyBUaGlzIGVudHJ5IG5lZWQgdG8gYmUgd3JhcHBlZCBpbiBhbiBJSUZFIGJlY2F1c2UgaXQgbmVlZCB0byBiZSBpbiBzdHJpY3QgbW9kZS4KICAgICAgICAoKCkgPT4gewogICAgICAgICAgICAidXNlIHN0cmljdCI7CiAgICAgICAgICAgIHZhciBleHBvcnRzID0gX193ZWJwYWNrX2V4cG9ydHNfXzsKCgogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFib3J0RXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9lZGl0b3JfbGF5ZXIuQW5ub3RhdGlvbkVkaXRvckxheWVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFubm90YXRpb25FZGl0b3JUeXBlIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3Rvb2xzLkFubm90YXRpb25FZGl0b3JVSU1hbmFnZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9sYXllci5Bbm5vdGF0aW9uTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTW9kZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkFubm90YXRpb25Nb2RlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQ01hcENvbXByZXNzaW9uVHlwZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJGZWF0dXJlVGVzdCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkZlYXR1cmVUZXN0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiR2xvYmFsV29ya2VyT3B0aW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiSW52YWxpZFBERkV4Y2VwdGlvbiIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkludmFsaWRQREZFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJNaXNzaW5nUERGRXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIk9QUyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLk9QUzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBERkRhdGFSYW5nZVRyYW5zcG9ydCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuUERGRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUERGRGF0ZVN0cmluZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQREZXb3JrZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLlBERldvcmtlcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBhc3N3b3JkUmVzcG9uc2VzIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuUGFzc3dvcmRSZXNwb25zZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQZXJtaXNzaW9uRmxhZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlBlcm1pc3Npb25GbGFnOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUGl4ZWxzUGVySW5jaCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2g7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJTVkdHcmFwaGljcyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9zdmcuU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVdGlsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlZlcmJvc2l0eUxldmVsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJYZmFMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfbGF5ZXIuWGZhTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJidWlsZCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuYnVpbGQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXREb2N1bWVudCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuZ2V0RG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRQZGZGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRQZGZGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRYZmFQYWdlVmlld3BvcnQiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRYZmFQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc0RhdGFTY2hlbWUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc1BkZkZpbGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc1BkZkZpbGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJsb2FkU2NyaXB0IiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2Rpc3BsYXlfdXRpbHMubG9hZFNjcmlwdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInJlbmRlclRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNldExheWVyRGltZW5zaW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNoYWRvdyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLnNoYWRvdzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInVwZGF0ZVRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnVwZGF0ZVRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInZlcnNpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLnZlcnNpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgdmFyIF9hcGkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOCk7CiAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgdmFyIF90ZXh0X2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fZWRpdG9yX2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjIpOwogICAgICAgICAgICB2YXIgX3Rvb2xzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nyk7CiAgICAgICAgICAgIHZhciBfd29ya2VyX29wdGlvbnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OSk7CiAgICAgICAgICAgIHZhciBfc3ZnID0gX193X3BkZmpzX3JlcXVpcmVfXygxNzApOwogICAgICAgICAgICB2YXIgX3hmYV9sYXllciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTY5KTsKICAgICAgICAgICAgY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICBjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgfSkoKTsKCiAgICAgICAgLyoqKioqKi8gCXJldHVybiB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ByZWFkQ2h1bmsgPSBmdW5jdGlvbiAoX3JlZjIpIHsKICAgICAgICAgIGxldCB7CiAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICBkb25lCiAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgaWYgKCFuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICBmbHVzaENodW5rcygpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYW5jZWxYSFJzID0gbnVsbDsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgIGlmICghZnVsbFJlcXVlc3QuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICBoYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICAgICAgICAgICAgbG9hZGVkLAogICAgICAgICAgICAgICAgdG90YWw6IE1hdGgubWF4KGxvYWRlZCwgZnVsbFJlcXVlc3QuY29udGVudExlbmd0aCB8fCAwKQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgbmV3UGRmTWFuYWdlci5zZW5kUHJvZ3Jlc3NpdmVEYXRhKHZhbHVlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjYWNoZWRDaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVsbFJlcXVlc3QucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgICB9CiAgIC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mluYWxseShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbihmdW5jdGlvbiAoX3JlZjgpIHsKICAgICAgICBsZXQgW3N0cmVhbSwgYWNyb0Zvcm0sIGFjcm9Gb3JtUmVmLCB4cmVmLCBzdGFydFhSZWYsIC4uLnJlZnNdID0gX3JlZjg7CiAgICAgICAgbGV0IG5ld1JlZnMgPSBbXTsKICAgICAgICBsZXQgeGZhRGF0YSA9IG51bGw7CiAgICAgICAgaWYgKGlzUHVyZVhmYSkgewogICAgICAgICAgeGZhRGF0YSA9IHJlZnNbMF07CiAgICAgICAgICBpZiAoIXhmYURhdGEpIHsKICAgICAgICAgICAgcmV0dXJuIHN0cmVhbS5ieXRlczsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgbmV3UmVmcyA9IHJlZnMuZmxhdCgyKTsKICAgICAgICAgIGlmIChuZXdSZWZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gc3RyZWFtLmJ5dGVzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb25zdCBuZWVkQXBwZWFyYW5jZXMgPSBhY3JvRm9ybVJlZiAmJiBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgbmV3UmVmcy5zb21lKHJlZiA9PiByZWYubmVlZEFwcGVhcmFuY2VzKTsKICAgICAgICBjb25zdCB4ZmEgPSBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgYWNyb0Zvcm0uZ2V0KCJYRkEiKSB8fCBudWxsOwogICAgICAgIGxldCB4ZmFEYXRhc2V0c1JlZiA9IG51bGw7CiAgICAgICAgbGV0IGhhc1hmYURhdGFzZXRzRW50cnkgPSBmYWxzZTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh4ZmEpKSB7CiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB4ZmEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBpZiAoeGZhW2ldID09PSAiZGF0YXNldHMiKSB7CiAgICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4ZmFbaSArIDFdOwogICAgICAgICAgICAgIGhhc1hmYURhdGFzZXRzRW50cnkgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoeGZhRGF0YXNldHNSZWYgPT09IG51bGwpIHsKICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoeGZhKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIFhGQSB0eXBlLiIpOwogICAgICAgIH0KICAgICAgICBsZXQgbmV3WHJlZkluZm8gPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgIGlmICh4cmVmLnRyYWlsZXIpIHsKICAgICAgICAgIGNvbnN0IGluZm9PYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgY29uc3QgeHJlZkluZm8gPSB4cmVmLnRyYWlsZXIuZ2V0KCJJbmZvIikgfHwgbnVsbDsKICAgICAgICAgIGlmICh4cmVmSW5mbyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgeHJlZkluZm8uZm9yRWFjaCgoa2V5LCB2YWx1ZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBpbmZvT2JqW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgbGFzdFhSZWZTdHJlYW1Qb3MgPSB4cmVmLmxhc3RYUmVmU3RyZWFtUG9zOwogICAgICAgICAgbmV3WHJlZkluZm8gPSB7CiAgICAgICAgICAgIHJvb3RSZWY6IHhyZWYudHJhaWxlci5nZXRSYXcoIlJvb3QiKSB8fCBudWxsLAogICAgICAgICAgICBlbmNyeXB0UmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJFbmNyeXB0IikgfHwgbnVsbCwKICAgICAgICAgICAgbmV3UmVmOiB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpLAogICAgICAgICAgICBpbmZvUmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJJbmZvIikgfHwgbnVsbCwKICAgICAgICAgICAgaW5mbzogaW5mb09iaiwKICAgICAgICAgICAgZmlsZUlkczogeHJlZi50cmFpbGVyLmdldCgiSUQiKSB8fCBudWxsLAogICAgICAgICAgICBzdGFydFhSZWY6IGxhc3RYUmVmU3RyZWFtUG9zID09PSBudWxsID8gc3RhcnRYUmVmIDogbGFzdFhSZWZTdHJlYW1Qb3MsCiAgICAgICAgICAgIGZpbGVuYW1lCiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgcmV0dXJuICgwLCBfd3JpdGVyLmluY3JlbWVudGFsVXBkYXRlKSh7CiAgICAgICAgICAgIG9yaWdpbmFsRGF0YTogc3RyZWFtLmJ5dGVzLAogICAgICAgICAgICB4cmVmSW5mbzogbmV3WHJlZkluZm8sCiAgICAgICAgICAgIG5ld1JlZnMsCiAgICAgICAgICAgIHhyZWYsCiAgICAgICAgICAgIGhhc1hmYTogISF4ZmEsCiAgICAgICAgICAgIHhmYURhdGFzZXRzUmVmLAogICAgICAgICAgICBoYXNYZmFEYXRhc2V0c0VudHJ5LAogICAgICAgICAgICBuZWVkQXBwZWFyYW5jZXMsCiAgICAgICAgICAgIGFjcm9Gb3JtUmVmLAogICAgICAgICAgICBhY3JvRm9ybSwKICAgICAgICAgICAgeGZhRGF0YQogICAgICAgICAgfSk7CiAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgIHhyZWYucmVzZXROZXdUZW1wb3JhcnlSZWYoKTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRPcGVyYXRvckxpc3QiLCBmdW5jdGlvbiAoZGF0YSwgc2luaykgewogICAgICBjb25zdCBwYWdlSW5kZXggPSBkYXRhLnBhZ2VJbmRleDsKICAgICAgcGRmTWFuYWdlci5nZXRQYWdlKHBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgR2V0T3BlcmF0b3JMaXN0OiBwYWdlICR7cGFnZUluZGV4fWApOwogICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICBjb25zdCBzdGFydCA9IHZlcmJvc2l0eSA+PSBfdXRpbC5WZXJib3NpdHlMZXZlbC5JTkZPUyA/IERhdGUubm93KCkgOiAwOwogICAgICAgIHBhZ2UuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIGhhbmRsZXIsCiAgICAgICAgICBzaW5rLAogICAgICAgICAgdGFzaywKICAgICAgICAgIGludGVudDogZGF0YS5pbnRlbnQsCiAgICAgICAgICBjYWNoZUtleTogZGF0YS5jYWNoZUtleSwKICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBkYXRhLmFubm90YXRpb25TdG9yYWdlCiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAob3BlcmF0b3JMaXN0SW5mbykgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldE9wZXJhdG9yTGlzdDogdGltZT1gICsgYCR7RGF0ZS5ub3coKSAtIHN0YXJ0fW1zLCBsZW49JHtvcGVyYXRvckxpc3RJbmZvLmxlbmd0aH1gKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRUZXh0Q29udGVudCIsIGZ1bmN0aW9uIChkYXRhLCBzaW5rKSB7CiAgICAgIGNvbnN0IHBhZ2VJbmRleCA9IGRhdGEucGFnZUluZGV4OwogICAgICBwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgY29uc3QgdGFzayA9IG5ldyBXb3JrZXJUYXNrKCJHZXRUZXh0Q29udGVudDogcGFnZSAiICsgcGFnZUluZGV4KTsKICAgICAgICBzdGFydFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgY29uc3Qgc3RhcnQgPSB2ZXJib3NpdHkgPj0gX3V0aWwuVmVyYm9zaXR5TGV2ZWwuSU5GT1MgPyBEYXRlLm5vdygpIDogMDsKICAgICAgICBwYWdlLmV4dHJhY3RUZXh0Q29udGVudCh7CiAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgdGFzaywKICAgICAgICAgIHNpbmssCiAgICAgICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogZGF0YS5pbmNsdWRlTWFya2VkQ29udGVudCwKICAgICAgICAgIGNvbWJpbmVUZXh0SXRlbXM6IGRhdGEuY29tYmluZVRleHRJdGVtcwogICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldFRleHRDb250ZW50OiB0aW1lPWAgKyBgJHtEYXRlLm5vdygpIC0gc3RhcnR9bXNgKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRTdHJ1Y3RUcmVlIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuZ2V0UGFnZShkYXRhLnBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIHJldHVybiBwZGZNYW5hZ2VyLmVuc3VyZShwYWdlLCAiZ2V0U3RydWN0VHJlZSIpOwogICAgICB9KTsKICAgIH0pOwogICAgaGFuZGxlci5vbigiRm9udEZhbGxiYWNrIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuZm9udEZhbGxiYWNrKGRhdGEuaWQsIGhhbmRsZXIpOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJDbGVhbnVwIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuY2xlYW51cCh0cnVlKTsKICAgIH0pOwogICAgaGFuZGxlci5vbigiVGVybWlu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SAtMyAqIHgwICsgOSAqIHgxIC0gOSAqIHgyICsgMyAqIHgzOwogICAgICAgIGMgPSAzICogeDEgLSAzICogeDA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYiA9IDYgKiB5MCAtIDEyICogeTEgKyA2ICogeTI7CiAgICAgICAgYSA9IC0zICogeTAgKyA5ICogeTEgLSA5ICogeTIgKyAzICogeTM7CiAgICAgICAgYyA9IDMgKiB5MSAtIDMgKiB5MDsKICAgICAgfQogICAgICBpZiAoTWF0aC5hYnMoYSkgPCAxZS0xMikgewogICAgICAgIGlmIChNYXRoLmFicyhiKSA8IDFlLTEyKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgIHR2YWx1ZXMucHVzaCh0KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgYjJhYyA9IGIgKiBiIC0gNCAqIGMgKiBhOwogICAgICBzcXJ0YjJhYyA9IE1hdGguc3FydChiMmFjKTsKICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdDEgPSAoLWIgKyBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgIH0KICAgICAgdDIgPSAoLWIgLSBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgIH0KICAgIH0KICAgIGxldCBqID0gdHZhbHVlcy5sZW5ndGgsCiAgICAgIG10OwogICAgY29uc3QgamxlbiA9IGo7CiAgICB3aGlsZSAoai0tKSB7CiAgICAgIHQgPSB0dmFsdWVzW2pdOwogICAgICBtdCA9IDEgLSB0Ow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sKICAgICAgICAgIHByb3BlcnR5ID0gW107CiAgICAgICAgICBwcm9wZXJ0aWVzLnNldChrZXksIHByb3BlcnR5KTsKICAgICAgICB9IGVsc2UgaWYgKCFtZXJnZVN1YkRpY3RzIHx8ICEodmFsdWUgaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHByb3BlcnR5LnB1c2godmFsdWUpOwogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IFtuYW1lLCB2YWx1ZXNdIG9mIHByb3BlcnRpZXMpIHsKICAgICAgaWYgKHZhbHVlcy5sZW5ndGggPT09IDEgfHwgISh2YWx1ZXNbMF0gaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHZhbHVlc1swXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBzdWJEaWN0ID0gbmV3IERpY3QoeHJlZik7CiAgICAgIGZvciAoY29uc3QgZGljdCBvZiB2YWx1ZXMpIHsKICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBPYmplY3QuZW50cmllcyhkaWN0Ll9tYXApKSB7CiAgICAgICAgICBpZiAoc3ViRGljdC5fbWFwW2tleV0gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBzdWJEaWN0Ll9tYXBba2V5XSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoc3ViRGljdC5zaXplID4gMCkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHN1YkRpY3Q7CiAgICAgIH0KICAgIH0KICAgIHByb3BlcnRpZXMuY2xlYXIoKTsKICAgIHJldHVybiBtZXJnZWREaWN0LnNpemUgPiAwID8gbWVyZ2VkRGljdCA6IERpY3QuZW1wdHk7CiAgfQp9CmV4cG9ydHMuRGljdCA9IERpY3Q7CmNvbnN0IFJlZiA9IGZ1bmN0a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m9yIChjb25zdCByYW5nZSBvZiByYW5nZXMpIHsKICAgICAgY29uc3QgYmVnaW5DaHVuayA9IHRoaXMuZ2V0QmVnaW5DaHVuayhyYW5nZS5iZWdpbik7CiAgICAgIGNvbnN0IGVuZENodW5rID0gdGhpcy5nZXRFbmRDaHVuayhyYW5nZS5lbmQpOwogICAgICBmb3IgKGxldCBjaHVuayA9IGJlZ2luQ2h1bms7IGNodW5rIDwgZW5kQ2h1bms7ICsrY2h1bmspIHsKICAgICAgICBpZiAoIWNodW5rc1RvUmVxdWVzdC5pbmNsdWRlcyhjaHVuaykpIHsKICAgICAgICAgIGNodW5rc1RvUmVxdWVzdC5wdXNoKGNodW5rKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNodW5rc1RvUmVxdWVzdC5zb3J0KGZ1bmN0aW9uIChhLCBiKSB7CiAgICAgIHJldHVybiBhIC0gYjsKICAgIH0pOwogICAgcmV0dXJuIHRoaXMuX3JlcXVlc3RDaHVua3MoY2h1bmtzVG9SZXF1ZXN0KTsKICB9CiAgZ3JvdXBDaHVua3MoY2h1bmtzKSB7CiAgICBjb25zdCBncm91cGVkQ2h1bmtzID0gW107CiAgICBsZXQgYmVnaW5DaHVuayA9IC0xOwogICAgbGV0IHByZXZDaHVuayA9IC0xOwogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2h1bmtzLmxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgY2h1bmsgPSBjaHVua3NbaV07CiAgICAgIGlmIChiZWdpbkNodW5rIDwgMCkgewogICAgICAgIGJlZ2luQ2h1bmsgPSBjaHVuazsKICAgICAgfQogICAgICBpZiAocHJldkNodW5rID49IDAgJiYgcHJldkNodW5rICsgMSAhPT0gY2h1bmspIHsKICAgICAgICBncm91cGVkQ2h1bmtzLnB1c2goewogICAgICAgICAgYmVnaW5DaHVuaywKICAgICAgICAgIGVuZENodW5rOiBwcmV2Q2h1bmsgKyAxCiAgICAgICAgfSk7CiAgICA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dGF0aW9ucykgewogICAgICAgIGlmICghYW5ub3RhdGlvbi5tdXN0QmVQcmludGVkKGFubm90YXRpb25TdG9yYWdlKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5ld1JlZnNQcm9taXNlcy5wdXNoKGFubm90YXRpb24uc2F2ZShwYXJ0aWFsRXZhbHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9uU3RvcmFnZSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJzYXZlIC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChuZXdSZWZzUHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG5ld1JlZnMpIHsKICAgICAgICByZXR1cm4gbmV3UmVmcy5maWx0ZXIobmV3UmVmID0+ICEhbmV3UmVmKTsKICAgICAgfSk7CiAgICB9KTsKICB9CiAgbG9hZFJlc291cmNlcyhrZXlzKSB7CiAgICBpZiAoIXRoaXMucmVzb3VyY2VzUHJvbWlzZSkgewogICAgICB0aGlzLnJlc291cmNlc1Byb21pc2UgPSB0aGlzLnBkZk1hbmFnZXIuZW5zdXJlKHRoaXMsICJyZXNvdXJjZXMiKTsKICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlc1Byb21pc2UudGhlbigoKSA9PiB7CiAgICAgIGNvbnN0IG9iamVjdExvYWRlciA9IG5ldyBfb2JqZWN0X2xvYWRlci5PYmplY3RMb2FkZXIodGhpcy5yZXNvdXJjZXMsIGtleXMsIHRoaXMueHJlZik7CiAgICAgIHJldHVybiBvYmplY3RMb2FkZXIubG9hZCgpOwogICAgfSk7CiAgfQogIGdldE9wZXJhdG9yTGlzdChfcmV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VhbTogY29udGVudFN0cmVhbSwKICAgICAgICB0YXNrLAogICAgICAgIHJlc291cmNlczogdGhpcy5yZXNvdXJjZXMsCiAgICAgICAgb3BlcmF0b3JMaXN0OiBvcExpc3QKICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgcmV0dXJuIG9wTGlzdDsKICAgICAgfSk7CiAgICB9KTsKICAgIHJldHVybiBQcm9taXNlLmFsbChbcGFnZUxpc3RQcm9taXNlLCB0aGlzLl9wYXJzZWRBbm5vdGF0aW9ucywgbmV3QW5ub3RhdGlvbnNQcm9taXNlXSkudGhlbihmdW5jdGlvbiAoX3JlZjQpIHsKICAgICAgbGV0IFtwYWdlT3BMaXN0LCBhbm5vdGF0aW9ucywgbmV3QW5ub3RhdGlvbnNdID0gX3JlZjQ7CiAgICAgIGlmIChuZXdBbm5vdGF0aW9ucykgewogICAgICAgIGFubm90YXRpb25zID0gYW5ub3RhdGlvbnMuY29uY2F0KG5ld0Fubm90YXRpb25zKTsKICAgICAgfQogICAgICBpZiAoYW5ub3RhdGlvbnMubGVuZ3RoID09PSAwIHx8IGludGVudCAmIF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRElTQUJMRSkgewogICAgICAgIHBhZ2VPcExpc3QuZmx1c2godHJ1ZSk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGxlbmd0aDogcGFnZU9wTGlzdC50b3RhbExlbmd0aAogICAgICAgIH07CiAgICAgIH0KICAgICAgY29uc3QgcmVuZGVyRm9ybXMgPSAhIShpbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOTk9UQVRJT05TX0ZPUk1TKSwKICAgICAgICBpbnRlbnRBbnkgPSAhIShpbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOWSksCiAgICAgICAgaW50ZW50RGlzcGxheSA9ICEhKGludGVudCAmIF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuRElTUExBWSksCiAgICAgICAgaW50ZW50UHJpbnQgPSAhIShpbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UKTsKICAgICAgY29uc3Qgb3BMaXN0UHJvbWlzZXMgPSBbXTsKICAgICAgZm9yIChjb25zdCBhbm5vdGF0aW9uIG9mIGFubm90YXRpb25zKSB7CiAgICAgICAgaWYgKGludGVudEFueSB8fCBpbnRlbnREaXNwbGF5ICYmIGFubm90YXRpb24ubXVzdEJlVmlld2VkKGFubm90YXRpb25TdG9yYWdlKSB8fCBpbnRlbnRQcmludCAmJiBhbm5vdGF0aW9uLm11c3RCZVByaW50ZWQoYW5ub3RhdGlvblN0b3JhZ2UpKSB7CiAgICAgICAgICBvcExpc3RQcm9taXNlcy5wdXNoKGFubm90YXRpb24uZ2V0T3BlcmF0b3JMaXN0KHBhcnRpYWxFdmFsdWF0b3IsIHRhc2ssIGludGVudCwgcmVuZGVyRm9ybXMsIGFubm90YXRpb25TdG9yYWdlKS5jYXRjaChmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgIG9wTGlzdDogbnVsbCwKICAgICAgICAgICAgICBzZXBhcmF0ZUZvcm06IGZhbHNlLAogICAgICAgICAgICAgIHNlcGFyYXRlQ2FudmFzOiBmYWxzZQogICAgICAgICAgICB9OwogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwob3BMaXN0UHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG9wTGlzdHMpIHsKICAgICAgICBsZXQgZm9ybSA9IGZhbHNlLAogICAgICAgICAgY2FudmFzID0gZmFsc2U7CiAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICBvcExpc3QsCiAgICAgICAgICBzZXBhcmF0ZUZvcm0sCiAgICAgICAgICBzZXBhcmF0ZUNhbnZhcwogICAgICAgIH0gb2Ygb3BMaXN0cykgewogICAgICAgICAgcGFnZU9wTGlzdC5hZGRPcExpc3Qob3BMaXN0KTsKICAgICAgICAgIGlmIChzZXBhcmF0ZUZvcm0pIHsKICAgICAgICAgICAgZm9ybSA9IHNlcGFyYXRlRm9ybTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzZXBhcmF0ZUNhbnZhcykgewogICAgICAgICAgICBjYW52YXMgPSBzZXBhcmF0ZUNhbnZhczsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcGFnZU9wTGlzdC5mbHVzaCh0cnVlLCB7CiAgICAgICAgICBmb3JtLAogICAgICAgICAgY2FudmFzCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGxlbmd0aDogcGFnZU9wTGlzdC50b3RhbExlbmd0aAogICAgICAgIH07CiAgICAgIH0pOwogICAgfSk7CiAgfQogIGV4dHJhY3RUZXh0Q29udGVudChfcmVmNSkgewogICAgbGV0IHsKICAgICAgaGFuZGxlciwKICAgICAgdGFzaywKICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQsCiAgICAgIHNpbmssCiAgICAgIGNvbWJpbmVUZXh0SXRlbXMKICAgIH0gPSBfcmVmNTsKICAgIGNvbnN0IGNvbnRlbnRTdHJlYW1Qcm9taXNlID0gdGhpcy5nZXRDb250ZW50U3RyZWFtKCk7CiAgICBjb25zdCByZXNvdXJjZXNQcm9taXNlID0gdGhpcy5sb2FkUmVzb3VyY2VzKFsiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUHJvcGVydGllcyIsICJYT2JqZWN0Il0pOwogICAgY29uc3QgZGF0YVByb21pc2VzID0gUHJvbWlzZS5hbGwoW2NvbnRlbnRTdHJlYW1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LmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgX3BhcnNlZEFubm90YXRpb25zOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0pKTsKICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwoYW5ub3RhdGlvblByb21pc2VzKS50aGVuKGZ1bmN0aW9uIChhbm5vdGF0aW9ucykgewogICAgICAgIGlmIChhbm5vdGF0aW9ucy5sZW5ndGggPT09IDApIHsKICAgICAgICAgIHJldHVybiBhbm5vdGF0aW9uczsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc29ydGVkQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICBsZXQgcG9wdXBBbm5vdGF0aW9uczsKICAgICAgICBmb3IgKGNvbnN0IGFubm90YXRpb24gb2YgYW5ub3RhdGlvbnMpIHsKICAgICAgICAgIGlmICghYW5ub3RhdGlvbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhbm5vdGF0aW9uIGluc3RhbmNlb2YgX2Fubm90YXRpb24uUG9wdXBBbm5vdGF0aW9uKSB7CiAgICAgICAgICAgIGlmICghcG9wdXBBbm5vdGF0aW9ucykgewogICAgICAgICAgICAgIHBvcHVwQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3B1cEFubm90YXRpb25zLnB1c2goYW5ub3RhdGlvbik7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgc29ydGVkQW5ub3RhdGlvbnMucHVzaChhbm5vdGF0aW9uKTsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcHVwQW5ub3RhdGlvbnMpIHsKICAgICAgICAgIHNvcnRlZEFubm90YXRpb25zLnB1c2goLi4ucG9wdXBBbm5vdGF0aW9ucyk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzb3J0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J0WFJlZiA9IHN0cmVhbS5wb3MgKyA2IC0gc3RyZWFtLnN0YXJ0OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBzdGVwID0gMTAyNDsKICAgICAgY29uc3Qgc3RhcnRYUmVmTGVuZ3RoID0gU1RBUlRYUkVGX1NJR05BVFVSRS5sZW5ndGg7CiAgICAgIGxldCBmb3VuZCA9IGZhbHNlLAogICAgICAgIHBvcyA9IHN0cmVhbS5lbmQ7CiAgICAgIHdoaWxlICghZm91bmQgJiYgcG9zID4gMCkgewogICAgICAgIHBvcyAtPSBzdGVwIC0gc3RhcnRYUmVmTGVuZ3RoOwogICAgICAgIGlmIChwb3MgPCAwKSB7CiAgICAgICAgICBwb3MgPSAwOwogICAgICAgIH0KICAgICAgICBzdHJlYW0ucG9zID0gcG9zOwogICAgICAgIGZvdW5kID0gZmluZChzdHJlYW0sIFNUQVJUWFJFRl9TSUdOQVRVUkUsIHN0ZXAsIHRydWUpOwogICAgICB9CiAgICAgIGlmIChmb3VuZCkgewogICAgICAgIHN0cmVhbS5za2lwKDkpOwogICAgICAgIGxldCBjaDsKICAgICAgICBkbyB7CiAgICAgICAgICBjaCA9IHN0cmVhbS5nZXRCeXRlKCk7CiAgICAgICAgfSB3aGlsZSAoKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpKTsKICAgICAgICBsZXQgc3RyID0gIiI7CiAgICAgICAgd2hpbGUgKGNoID49IDB4MjAgJiYgY2ggPD0gMHgzOSkgewogICAgICAgICAgc3RyICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgICAgICAgY2ggPSBzdHJlYW0uZ2V0Qnl0ZSgpOwogICAgICAgIH0KICAgICAgICBzdGFydFhSZWYgPSBwYXJzZUludChzdHIsIDEwKTsKICAgICAgICBpZiAoaXNOYU4oc3RhcnRYUmVmKSkgewogICAgICAgICAgc3RhcnRYUmVmID0gMDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAg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CB4ZmEubGVuZ3RoID09PSAwKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0geGZhLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgbGV0IG5hbWU7CiAgICAgIGlmIChpID09PSAwKSB7CiAgICAgICAgbmFtZSA9ICJ4ZHA6eGRwIjsKICAgICAgfSBlbHNlIGlmIChpID09PSBpaSAtIDIpIHsKICAgICAgICBuYW1lID0gIi94ZHA6eGRwIjsKICAgICAgfSBlbHNlIHsKICAgICAgICBuYW1lID0geGZhW2ldOwogICAgICB9CiAgICAgIGlmICghZW50cmllcy5oYXNPd25Qcm9wZXJ0eShuYW1lKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZih4ZmFbaSArIDFdKTsKICAgICAgaWYgKCEoZGF0YSBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB8fCBkYXRhLmlzRW1wdHkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBlbnRyaWVzW25hbWVdID0gZGF0YTsKICAgIH0KICAgIHJldHVybiBlbnRyaWVzOwogIH0KICBnZXQgeGZhRGF0YXNldHMoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbnVsbCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImRhdGFzZXRzIiwgInhkcDp4ZHAiXSkgewogICAgICBjb25zdCBzdHJlYW0gPSBzdHJlYW1zW2tleV07CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBzdHIgPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICAgIGNvbnN0IGRhdGEgPSB7CiAgICAgICAgICBba2V5XTogc3RyCiAgICAgICAgfTsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbmV3IF9kYXRhc2V0X3JlYWRlci5EYXRhc2V0UmVhZGVyKGRhdGEpKTsKICAgICAgfSBjYXRjaCAoXykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCB1dGYtOCBzdHJpbmcuIik7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAieGZhRGF0YXNldHMiLCBudWxsKTsKICB9CiAgZ2V0IHhmYURhdGEoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IGRhdGEgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgZm9yIChjb25zdCBba2V5LCBzdHJlYW1dIG9mIE9iamVjdC5lbnRyaWVzKHN0cmVhbXMpKSB7CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBkYXRhW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICB9IGNhdGNoIChfKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBJbnZhbGlkIHV0Zi04IHN0cmluZy4iKTsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgfQogICAgcmV0dXJuIGRhdGE7CiAgfQogIGdldCB4ZmFGYWN0b3J5KC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tRm9udHMgPSBmYWxzZTsKICAgIGNvbnN0IHBhcnRpYWxFdmFsdWF0b3IgPSBuZXcgX2V2YWx1YXRvci5QYXJ0aWFsRXZhbHVhdG9yKHsKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICBoYW5kbGVyLAogICAgICBwYWdlSW5kZXg6IC0xLAogICAgICBpZEZhY3Rvcnk6IHRoaXMuX2dsb2JhbElkRmFjdG9yeSwKICAgICAgZm9udENhY2hlOiB0aGlzLmNhdGFsb2cuZm9udENhY2hlLAogICAgICBidWlsdEluQ01hcENhY2hlOiB0aGlzLmNhdGFsb2cuYnVpbHRJbkNNYXBDYWNoZSwKICAgICAgc3RhbmRhcmRGb250RGF0YUNhY2hlOiB0aGlzLmNhdGFsb2cuc3RhbmRhcmRGb250RGF0YUNhY2hlLAogICAgICBvcHRpb25zCiAgICB9KTsKICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgIGNvbnN0IHBkZkZvbnRzID0gW107CiAgICBjb25zdCBpbml0aWFsU3RhdGUgPSB7CiAgICAgIGdldCBmb250KCkgewogICAgICAgIHJldHVybiBwZGZGb250cy5hdCgtMSk7CiAgICAgIH0sCiAgICAgIHNldCBmb250KGZvbnQpIHsKICAgICAgICBwZGZGb250cy5wdXNoKGZvbnQpOwogICAgICB9LAogICAgICBjbG9uZSgpIHsKICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfQogICAgfTsKICAgIGNvbnN0IGZvbnRzID0gbmV3IE1hcCgpOwogICAgZm9udFJlcy5mb3JFYWNoKChmb250TmFtZSwgZm9udCkgPT4gewogICAgICBmb250cy5zZXQoZm9udE5hbWUsIGZvbnQpOwogICAgfSk7CiAgICBjb25zdCBwcm9taXNlcyA9IFtdOwogICAgZm9yIChjb25zdCBbZm9udE5hbWUsIGZvbnRdIG9mIGZvbnRzKSB7CiAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSBmb250LmdldCgiRm9udERlc2NyaXB0b3IiKTsKICAgICAgaWYgKCEoZGVzY3JpcHRvciBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbGV0IGZvbnRGYW1pbHkgPSBkZXNjcmlwdG9yLmdldCgiRm9udEZhbWlseSIpOwogICAgICBmb250RmFtaWx5ID0gZm9udEZhbWlseS5yZXBsYWNlQWxsKC9bIF0rKFxkKS9nLCAiJDEiKTsKICAgICAgY29uc3QgZm9udFdlaWdodCA9IGRlc2NyaXB0b3IuZ2V0KCJGb250V2VpZ2h0Iik7CiAgICAgIGNvbnN0IGl0YWxpY0FuZ2xlID0gLWRlc2NyaXB0b3IuZ2V0KCJJdGFsaWNBbmdsZSIpOwogICAgICBjb25zdCBjc3NGb250SW5mbyA9IHsKICAgICAgICBmb250RmFtaWx5LAogICAgICAgIGZvbnRXZWlnaHQsCiAgICAgICAgaXRhbGljQW5nbGUKICAgICAgfTsKICAgICAgaWYgKCEoMCwgX2NvcmVfdXRpbHMudmFsaWRhdGVDU1NGb250KShjc3NGb250SW5mbykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBwcm9taXNlcy5wdXNoKHBhcnRpYWxFdmFsdWF0b3IuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIFtfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSksIDFdLCBudWxsLCBvcGVyYXRvckxpc3QsIHRhc2ssIGluaXRpYWxTdGF0ZSwgbnVsbCwgY3NzRm9udEluZm8pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGxvYWRYZmFGb250czogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0pKTsKICAgIH0KICAgIGF3YWl0IFByb21pc2UuYWxsKHByb21pc2VzKTsKICAgIGNvbnN0IG1pc3NpbmdGb250cyA9IHRoaXMueGZhRmFjdG9yeS5zZXRGb250cyhwZGZGb250cyk7CiAgICBpZiAoIW1pc3NpbmdGb250cykgewogICAgICByZXR1cm47CiAgICB9CiAgICBvcHRpb25zLmlnbm9yZUVycm9ycyA9IHRydWU7CiAgICBwcm9taXNlcy5sZW5ndGggPSAwOwogICAgcGRmRm9udHMubGVuZ3RoID0gMDsKICAgIGNvbnN0IHJlYWxseU1pc3NpbmdGb250cyA9IG5ldyBTZXQoKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiBtaXNzaW5nRm9udHMpIHsKICAgICAgaWYgKCEoMCwgX3hmYV9mb250cy5nZXRYZmFGb250TmFtZSkoYCR7bWlzc2luZ30tUmVndWxhcmApKSB7CiAgICAgICAgcmVhbGx5TWlzc2luZ0ZvbnRzLmFkZChtaXNzaW5nKTsKICAgICAgfQogICAgfQogICAgaWYgKHJlYWxseU1pc3NpbmdGb250cy5zaXplKSB7CiAgICAgIG1pc3NpbmdGb250cy5wdXNoKCJQZGZKUy1GYWxsYmFjayIpOwogICAgfQogICAgZm9yIChjb25zdCBtaXNzaW5nIG9mIG1pc3NpbmdGb250cykgewogICAgICBpZiAocmVhbGx5TWlzc2luZ0ZvbnRzLmhhcyhtaXNzaW5nKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAoY29uc3QgZm9udEluZm8gb2YgW3sKICAgICAgICBuYW1lOiAiUmVndWxhciIsCiAgICAgICAgZm9udFdlaWdodDogNDAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZCIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiSXRhbGljIiwKICAgICAgICBmb250V2VpZ2h0OiA0MDAsCiAgICAgICAgaXRhbGljQW5nbGU6IDEyCiAgICAgIH0sIHsKICAgICAgIC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ICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJUcmFwcGVkIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgZG9jSW5mb1trZXldID0gdmFsdWU7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGxldCBjdXN0b21WYWx1ZTsKICAgICAgICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7CiAgICAgICAgICAgIGNhc2UgInN0cmluZyI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAibnVtYmVyIjoKICAgICAgICAgICAgY2FzZSAiYm9vbGVhbiI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBjdXN0b21WYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjdXN0b21WYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQmFkIHZhbHVlLCBmb3IgY3VzdG9tIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCFkb2NJbmZvLkN1c3RvbSkgewogICAgICAgICAgICBkb2NJbmZvLkN1c3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wogICAgICAgICAgICBiYXNlRm9udFJlZiA9IHhyZWYuZ2V0TmV3VGVtcG9yYXJ5UmVmKCk7CiAgICAgICAgICAgICgwLCBfd3JpdGVyLndyaXRlT2JqZWN0KShiYXNlRm9udFJlZiwgYmFzZUZvbnQsIGJ1ZmZlciwgbnVsbCk7CiAgICAgICAgICAgIGRlcGVuZGVuY2llcy5wdXNoKHsKICAgICAgICAgICAgICByZWY6IGJhc2VGb250UmVmLAogICAgICAgICAgICAgIGRhdGE6IGJ1ZmZlci5qb2luKCIiKQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHByb21pc2VzLnB1c2goRnJlZVRleHRBbm5vdGF0aW9uLmNyZWF0ZU5ld0Fubm90YXRpb24oeHJlZiwgYW5ub3RhdGlvbiwgZGVwZW5kZW5jaWVzLCB7CiAgICAgICAgICAgIGV2YWx1YXRvciwKICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgYmFzZUZvbnRSZWYKICAgICAgICAgIH0pKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LOgogICAgICAgICAgcHJvbWlzZXMucHVzaChJbmtBbm5vdGF0aW9uLmNyZWF0ZU5ld0Fubm90YXRpb24oeHJlZiwgYW5ub3RhdGlvbiwgZGVwZW5kZW5jaWVzKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB7CiAgICAgIGFubm90YXRpb25zOiBhd2FpdCBQcm9taXNlLmFsbChwcm9taXNlcyksCiAgICAgIGRlcGVuZGVuY2llcwogICAgfTsKICB9CiAgc3RhdGljIGFzeW5jIHByaW50TmV3QW5ub3RhdGlvbnMoZXZhbHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9ucykgewogICAgaWYgKCFhbm5vdGF0aW9ucykgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IHhyZWYgPSBldmFsdWF0b3IueHJlZjsKICAgIGNvbn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md0aCA9PT0gMCB8fCBxdWFkUG9pbnRzLmxlbmd0aCAlIDggPiAwKSB7CiAgICByZXR1cm4gbnVsbDsKICB9CiAgY29uc3QgcXVhZFBvaW50c0xpc3RzID0gW107CiAgZm9yIChsZXQgaSA9IDAsIGlpID0gcXVhZFBvaW50cy5sZW5ndGggLyA4OyBpIDwgaWk7IGkrKykgewogICAgbGV0IG1pblggPSBJbmZpbml0eSwKICAgICAgbWF4WCA9IC1JbmZpbml0eSwKICAgICAgbWluWSA9IEluZmluaXR5LAogICAgICBtYXhZID0gLUluZmluaXR5OwogICAgZm9yIChsZXQgaiA9IGkgKiA4LCBqaiA9IGkgKiA4ICsgODsgaiA8IGpqOyBqICs9IDIpIHsKICAgICAgY29uc3QgeCA9IHF1YWRQb2ludHNbal07CiAgICAgIGNvbnN0IHkgPSBxdWFkUG9pbnRzW2ogKyAxXTsKICAgICAgbWluWCA9IE1hdGgubWluKHgsIG1pblgpOwogICAgICBtYXhYID0gTWF0aC5tYXgoeCwgbWF4WCk7CiAgICAgIG1pblkgPSBNYXRoLm1pbih5LCBtaW5ZKTsKICAgICAgbWF4WSA9IE1hdGgubWF4KHksIG1heFkpOwogICAgfQogICAgaWYgKHJlY3QgIT09IG51bGwgJiYgKG1pblggPCByZWN0WzBdIHx8IG1heFggPiByZWN0WzJdIHx8IG1pblkgPCByZWN0WzFdIHx8IG1heFkgPiByZWN0WzNdKSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIHF1YWRQb2ludHNMaXN0cy5wdXNoKFt7CiAgICAgIHg6IG1pblgsCiAgICAgIHk6IG1heFkKICAgIH0sIHsKICAgICAgeDogbWF4WCwKICAgICAgeTogbWF4WQogICAgfSwgewogICAgICB4OiBtaW5YLAogICAgICB5OiBtaW5ZCiAgICB9LCB7CiAgICAgIHg6IG1heFgsCiAgICAgIHk6IG1pblkKICAgIH1dKTsKICB9CiAgcmV0dXJuIHF1YWRQb2ludHNMaXN0czsKfQpmdW5jdGlvbiBn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W5lZCkgewogICAgICByZXR1cm4gc3RvcmFnZUVudHJ5LnByaW50OwogICAgfQogICAgcmV0dXJuIHRoaXMucHJpbnRhYmxlOwogIH0KICBnZXQgdmlld2FibGUoKSB7CiAgICBpZiAodGhpcy5kYXRhLnF1YWRQb2ludHMgPT09IG51bGwpIHsKICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQogICAgaWYgKHRoaXMuZmxhZ3MgPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICByZXR1cm4gdGhpcy5faXNWaWV3YWJsZSh0aGlzLmZsYWdzKTsKICB9CiAgZ2V0IHByaW50YWJsZSgpIHsKICAgIGlmICh0aGlzLmRhdGEucXVhZFBvaW50cyA9PT0gbnVsbCkgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAodGhpcy5mbGFncyA9PT0gMCkgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICByZXR1cm4gdGhpcy5faXNQcmludGFibGUodGhpcy5mbGFncyk7CiAgfQogIF9wYXJzZVN0cmluZ0hlbHBlcihkYXRhKSB7CiAgICBjb25zdCBzdHIgPSB0eXBlb2YgZGF0YSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRhdGEpIDogIiI7CiAgICBjb25zdCBkaXIgPSBzdHIgJiYgKDAsIF9iaWRpLmJpZGkpKHN0cikuZGlyID09PSAicnRsIiA/ICJydGwiIDogImx0ciI7CiAgICByZXR1cm4gewogICAgICBzdHIsCiAgICAgIGRpcgogICAgfTsKICB9CiAgc2V0RGVmYXVsdEFwcGVhcmFuY2UocGFyYW1zKSB7CiAgICBjb25zdCBkZWZhdWx0QXBwZWFyYW5jZSA9ICgwLCBfY29yZV91dGlscy5nZXRJbmhlcml0YWJsZVByb3BlcnR5KSh7CiAgICAgIGRpY3Q6IHBhcmFtcy5kaWN0LAogICAgICBrZXk6ICJEQSIKICAgIH0pIHx8IHBhcmFtcy5h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1hbGl6ZVJlY3QocmVjdGFuZ2xlKTsKICAgIH0gZWxzZSB7CiAgICAgIHRoaXMucmVjdGFuZ2xlID0gWzAsIDAsIDAsIDBdOwogICAgfQogIH0KICBzZXRDb2xvcihjb2xvcikgewogICAgdGhpcy5jb2xvciA9IGdldFJnYkNvbG9yKGNvbG9yKTsKICB9CiAgc2V0TGluZUVuZGluZ3MobGluZUVuZGluZ3MpIHsKICAgIHRoaXMubGluZUVuZGluZ3MgPSBbIk5vbmUiLCAiTm9uZSJdOwogICAgaWYgKEFycmF5LmlzQXJyYXkobGluZUVuZGluZ3MpICYmIGxpbmVFbmRpbmdzLmxlbmd0aCA9PT0gMikgewogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7IGkrKykgewogICAgICAgIGNvbnN0IG9iaiA9IGxpbmVFbmRpbmdzW2ldOwogICAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBzd2l0Y2ggKG9iai5uYW1lKSB7CiAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBjYXNlICJTcXVhcmUiOgogICAgICAgICAgICBjYXNlICJDaXJjbGUiOgogICAgICAgICAgICBjYXNlICJEaWFtb25kIjoKICAgICAgICAgICAgY2FzZSAiT3BlbkFycm93IjoKICAgICAgICAgICAgY2FzZSAiQ2xvc2VkQXJyb3ciOgogICAgICAgICAgICBjYXNlICJCdXR0IjoKICAgICAgICAgICAgY2FzZSAiUk9wZW5BcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlJDbG9zZWRBcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlNsYXNoIjoKICAgICAgICAgICAgICB0aGlzLmxpbmVFbmRpbmdzW2ldID0gb2JqLm5hbWU7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3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BoYXNUZXh0Q29udGVudCgpIHsKICAgIHJldHVybiBmYWxzZTsKICB9CiAgYXN5bmMgZXh0cmFjdFRleHRDb250ZW50KGV2YWx1YXRvciwgdGFzaywgdmlld0JveCkgewogICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgcmVzb3VyY2VzID0gYXdhaXQgdGhpcy5sb2FkUmVzb3VyY2VzKFsiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUHJvcGVydGllcyIsICJYT2JqZWN0Il0sIHRoaXMuYXBwZWFyYW5jZSk7CiAgICBjb25zdCB0ZXh0ID0gW107CiAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgIGNvbnN0IHNpbmsgPSB7CiAgICAgIGRlc2lyZWRTaXplOiBNYXRoLkluZmluaXR5LAogICAgICByZWFkeTogdHJ1ZSwKICAgICAgZW5xdWV1ZShjaHVuaywgc2l6ZSkgewogICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBjaHVuay5pdGVtcykgewogICAgICAgICAgYnVmZmVyLnB1c2goaXRlbS5zdHIpOwogICAgICAgICAgaWYgKGl0ZW0uaGFzRU9MKSB7CiAgICAgICAgICAgIHRleHQucHVzaChidWZmZXIuam9pbigiIikpOwogICAgICAgICAgICBidWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgICBhd2FpdCBldmFsdWF0b3IuZ2V0VGV4dENvbnRlbnQoewogICAgICBzdHJlYW06IHRoaXMuYXBwZWFyYW5jZSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogdHJ1ZSwKICAgICAgY29tYmluZVRleHRJdGVtczogdHJ1ZSwKICAgICAgc2luaywKICAgICAgdmlld0JveAogICAgfSk7CiAgICB0aGlzLnJlc2V0KCk7CiAgICBpZiAoYnVmZmVyLmxlbmd0aCkgewogICAgICB0ZXh0LnB1c2goYnVmZmVyLmpvaW4oIiIpKTsKICAgIH0KICAgIGlmICh0ZXh0Lmxlbmd0aCA+IDApIHsKICAgICAgdGhpcy5kYXRhLnRleHRDb250ZW50ID0gdGV4dDsKICAgIH0KICB9CiAgZ2V0RmllbGRPYmplY3QoKSB7CiAgICBpZiAodGhpcy5kYXRhLmtpZElkcykgewogICAgICByZXR1cm4gewogICAgICAgIGlkOiB0aGlzLmRhdGEuaWQsCiAgICAgICAgYWN0aW9uczogdGhpcy5kYXRhLmFjdGlvbnMsCiAgICAgICAgbmFtZTogdGhpcy5kYXRhLmZpZWxkTmFtZSwKICAgICAgICBzdHJva2VDb2xvcjogdGhpcy5kYXRhLmJvcmRlckNvbG9yLAogICAgICAgIGZpbGxDb2xvcjogdGhpcy5kYXRhLmJhY2tncm91bmRDb2xvciwKICAgICAgICB0eXBlOiAiIiwKICAgICAgICBraWRJZHM6IHRoaXMuZGF0YS5raWRJZHMsCiAgICAgICAgcGFnZTogdGhpcy5kYXRhLnBhZ2VJbmRleCwKICAgICAgICByb3RhdGlvbjogdGhpcy5yb3RhdGlvbgogICAgICB9OwogICAgfQogICAgcmV0dXJuIG51bGw7CiAgfQogIHJlc2V0KCkgewogICAgZm9yIChjb25zdCBzdHJlYW0gb2YgdGhpcy5fc3RyZWFtcykgewogICAgICBzdHJlYW0ucmVzZXQoKTsKICAgIH0KICB9CiAgX2NvbnN0cnVjdEZpZWxkTmFtZShkaWN0KSB7CiAgICBpZiAoIWRpY3QuaGFzKCJUIikgJiYgIWRpY3QuaGFzKCJQYXJlbnQiKSkgewogICAgICAoMCwgX3V0aWwud2FybikoIlVua25vd24gZmllbGQgbmFtZSwgZmFsbGluZyBiYWNrIHRvIGVtcHR5IGZpZWxkIG5hbWUuIik7CiAgICAgIHJldHVybiAiIjsKICAgIH0KICAgIGlmICghZGljdC5oYXMoIlBhcmVudCIpKSB7CiAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmc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WmVyb3MgPSB0cnVlOwogICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgZGFzaEFycmF5KSB7CiAgICAgICAgY29uc3QgdmFsaWROdW1iZXIgPSArZWxlbWVudCA+PSAwOwogICAgICAgIGlmICghdmFsaWROdW1iZXIpIHsKICAgICAgICAgIGlzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0gZWxzZSBpZiAoZWxlbWVudCA+IDApIHsKICAgICAgICAgIGFsbFplcm9zID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChpc1ZhbGlkICYmICFhbGxaZXJvcykgewogICAgICAgIHRoaXMuZGFzaEFycmF5ID0gZGFzaEFycmF5OwogICAgICAgIGlmIChmb3JjZVN0eWxlKSB7CiAgICAgICAgICB0aGlzLnNldFN0eWxlKF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEIikpOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB0aGlzLndpZHRoID0gMDsKICAgICAgfQogICAgfSBlbHNlIGlmIChkYXNoQXJyYXkpIHsKICAgICAgdGhpcy53aWR0aCA9IDA7CiAgICB9CiAgfQogIHNldEhvcml6b250YWxDb3JuZXJSYWRpdXMocmFkaXVzKSB7CiAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihyYWRpdXMpKSB7CiAgICAgIHRoaXMuaG9yaXpvbnRhbENvcm5lclJhZGl1cyA9IHJhZGl1czsKICAgIH0KICB9CiAgc2V0VmVydGljYWxDb3JuZXJSYWRpdXMocmFkaXVzKSB7CiAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihyYWRpdXMpKSB7CiAgICAgIHRoaXMudmVydGljYWxDb3JuZXJSYWRpdXMgPSByYWRpdXM7CiAgICB9CiAgfQp9CmV4cG9ydHMuQW5ub3RhdGlvbkJvcmRlclN0eWxlID0gQW5ub3RhdGlvbkJvcmRlclN0eWxlOwpjbGFzcyBNYXJrdXBBbm5vdGF0aW9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nZXRDaGFyUG9zaXRpb25zKGVuY29kZWQpOwogICAgICAgICAgY2FjaGVkTGluZXMucHVzaCh7CiAgICAgICAgICAgIGxpbmU6IGVuY29kZWQsCiAgICAgICAgICAgIGdseXBocywKICAgICAgICAgICAgcG9zaXRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgaXNUb29CaWcgPSBmc2l6ZSA9PiB7CiAgICAgICAgICBsZXQgdG90YWxIZWlnaHQgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiBjYWNoZWRMaW5lcykgewogICAgICAgICAgICBjb25zdCBjaHVua3MgPSB0aGlzLl9zcGxpdExpbmUobnVsbCwgZm9udCwgZnNpemUsIHdpZHRoLCBjYWNoZSk7CiAgICAgICAgICAgIHRvdGFsSGVpZ2h0ICs9IGNodW5rcy5sZW5ndGggKiBmc2l6ZTsKICAgICAgICAgICAgaWYgKHRvdGFsSGVpZ2h0ID4gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9OwogICAgICAgIG51bWJlck9mTGluZXMgPSBNYXRoLm1heChudW1iZXJPZkxpbmVzLCBsaW5lQ291bnQpOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBsaW5lSGVpZ2h0ID0gaGVpZ2h0IC8gbnVtYmVyT2ZMaW5lczsKICAgICAgICAgIGZvbnRTaXplID0gcm91bmRXaXRoVHdvRGlnaXRzKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUik7CiAgICAgICAgICBpZiAoaXNUb29CaWcoZm9udFNpemUpKSB7CiAgICAgICAgICAgIG51bWJlck9mTGluZXMrKzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgewogICAg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bmdFbmQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IGxhc3RTcGFjZVBvc0luU3RyaW5nRW5kOwogICAgICAgICAgICBpID0gbGFzdFNwYWNlUG9zICsgMTsKICAgICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgc3RhcnQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IHN0YXJ0OwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSBnbHlwaFdpZHRoOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50V2lkdGggKz0gZ2x5cGhXaWR0aDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChzdGFydENodW5rIDwgbGluZS5sZW5ndGgpIHsKICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGluZS5sZW5ndGgpKTsKICAgIH0KICAgIHJldHVybiBjaHVua3M7CiAgfQogIGdldEZpZWxkT2JqZWN0KCkgewogICAgcmV0dXJuIHsKICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlLAogICAgICBkZWZhdWx0VmFsdWU6IHRoaXMuZGF0YS5kZWZhdWx0RmllbGRWYWx1ZSB8fCAiIiwKICAgICAgbXVsdGlsaW5lOiB0aGlzLmRhdGEubXVsdGlMaW5lLAogICAgICBwYXNzd29yZDogdGhpcy5oYXNGaWVsZEZsYWcoX3V0aWwuQW5ub3RhdGlvbkZpZWxkRmxhZy5QQVNTV09SRCksCiAgICAgIGNoYXJMaW1pdDogdGhpcy5kYXRhLm1heExlbiwKICAgICAgY29tYjogdGhpcy5kYXRhLmNvbW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CJDQSIpOwogICAgICBjb25zdCBpbnRlcmlvckNvbG9yID0gZ2V0UmdiQ29sb3IoZGljdC5nZXRBcnJheSgiSUMiKSwgbnVsbCk7CiAgICAgIGNvbnN0IGZpbGxDb2xvciA9IGludGVyaW9yQ29sb3IgPyBnZXRQZGZDb2xvckFycmF5KGludGVyaW9yQ29sb3IpIDogbnVsbDsKICAgICAgY29uc3QgZmlsbEFscGhhID0gZmlsbENvbG9yID8gc3Ryb2tlQWxwaGEgOiBudWxsOwogICAgICBjb25zdCBib3JkZXJXaWR0aCA9IHRoaXMuYm9yZGVyU3R5bGUud2lkdGggfHwgMSwKICAgICAgICBib3JkZXJBZGp1c3QgPSAyICogYm9yZGVyV2lkdGg7CiAgICAgIGNvbnN0IGJib3ggPSBbdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1swXSAtIGJvcmRlckFkanVzdCwgdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1sxXSAtIGJvcmRlckFkanVzdCwgdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1syXSArIGJvcmRlckFkanVzdCwgdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1szXSArIGJvcmRlckFkanVzdF07CiAgICAgIGlmICghX3V0aWwuVXRpbC5pbnRlcnNlY3QodGhpcy5yZWN0YW5nbGUsIGJib3gpKSB7CiAgICAgICAgdGhpcy5yZWN0YW5nbGUgPSBiYm94OwogICAgICB9CiAgICAgIHRoaXMuX3NldERlZmF1bHRBcHBlYXJhbmNlKHsKICAgICAgICB4cmVmLAogICAgICAgIGV4dHJhOiBgJHtib3JkZXJXaWR0aH0gd2AsCiAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgZmlsbENvbG9yLAogICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgIGZpbGxBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBidWZmZXIucHVzaChgJHtsaW5lQ29v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GZpbGxBbHBoYSA9IGZpbGxDb2xvciA/IHN0cm9rZUFscGhhIDogbnVsbDsKICAgICAgaWYgKHRoaXMuYm9yZGVyU3R5bGUud2lkdGggPT09IDAgJiYgIWZpbGxDb2xvcikgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aGlzLl9zZXREZWZhdWx0QXBwZWFyYW5jZSh7CiAgICAgICAgeHJlZiwKICAgICAgICBleHRyYTogYCR7dGhpcy5ib3JkZXJTdHlsZS53aWR0aH0gd2AsCiAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgZmlsbENvbG9yLAogICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgIGZpbGxBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB4ID0gcG9pbnRzWzJdLnggKyB0aGlzLmJvcmRlclN0eWxlLndpZHRoIC8gMjsKICAgICAgICAgIGNvbnN0IHkgPSBwb2ludHNbMl0ueSArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3Qgd2lkdGggPSBwb2ludHNbM10ueCAtIHBvaW50c1syXS54IC0gdGhpcy5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHBvaW50c1sxXS55IC0gcG9pbnRzWzNdLnkgLSB0aGlzLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5fSAke3dpZHRofSAke2hlaWdodH0gcmVgKTsKICAgICAgICAgIGlmIChmaWxsQ29sb3IpIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIkIiKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJ1ZmZlci5wdXNoKCJTIik7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gW3BvaW50c1swXS54LCBwb2ludHNbMV0ueCwgcG9pbnRzWzNdLn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eDB9ICR7eU1pZH0gY2AsIGAke3gwfSAke3lNaWQgKyB5T2Zmc2V0fSAke3hNaWQgLSB4T2Zmc2V0fSAke3kxfSAke3hNaWR9ICR7eTF9IGNgLCAiaCIpOwogICAgICAgICAgaWYgKGZpbGxDb2xvcikgewogICAgICAgICAgICBidWZmZXIucHVzaCgiQiIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIlMiKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBbcG9pbnRzWzBdLngsIHBvaW50c1sxXS54LCBwb2ludHNbM10ueSwgcG9pbnRzWzFdLnldOwogICAgICAgIH0KICAgICAgfSk7CiAgICB9CiAgfQp9CmNsYXNzIFBvbHlsaW5lQW5ub3RhdGlvbiBleHRlbmRzIE1hcmt1cEFubm90YXRpb24gewogIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgc3VwZXIocGFyYW1zKTsKICAgIGNvbnN0IHsKICAgICAgZGljdCwKICAgICAgeHJlZgogICAgfSA9IHBhcmFtczsKICAgIHRoaXMuZGF0YS5hbm5vdGF0aW9uVHlwZSA9IF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlMSU5FOwogICAgdGhpcy5kYXRhLmhhc093bkNhbnZhcyA9IHRoaXMuZGF0YS5ub1JvdGF0ZTsKICAgIHRoaXMuZGF0YS52ZXJ0aWNlcyA9IFtdOwogICAgaWYgKCEodGhpcyBpbnN0YW5jZW9mIFBvbHlnb25Bbm5vdGF0aW9uKSkgewogICAgICB0aGlzLnNldExpbmVFbmRpbmdzKGRpY3QuZ2V0QXJyYXkoIkxFIikpOwogICAgICB0aGlzLmRhdGEubGluZUVuZGluZ3MgPSB0aGlzLmxpbmVFbmRpbmdzOwogICAgfQogICAgY29uc3QgcmF3VmVydGljZXMgPSBkaWN0LmdldEFycmF5KCJWZXJ0aWNlcyIpOwogICAgaWYgKCFBcnJheS5pc0FycmF5KHJhd1ZlcnRpY2VzKSkgewogICAgICByZXR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mJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB2ZXJ0aWNlcyA9IHRoaXMuZGF0YS52ZXJ0aWNlczsKICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHZlcnRpY2VzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7dmVydGljZXNbaV0ueH0gJHt2ZXJ0aWNlc1tpXS55fSAke2kgPT09IDAgPyAibSIgOiAibCJ9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLngsIHBvaW50c1szXS55LCBwb2ludHNbMV0ueV07CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICB9Cn0KY2xhc3MgUG9seWdvbkFubm90YXRpb24gZXh0ZW5kcyBQb2x5bGluZUFubm90YXRpb24gewogIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgc3VwZXIocGFyYW1zKTsKICAgIHRoaXMuZGF0YS5hbm5vdGF0aW9uVHlwZSA9IF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT047CiAgfQp9CmNsYXNzIENhcmV0QW5ub3RhdGlvbiBleHRlbmRzIE1hcmt1cEFubm90YXRpb24gewogIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgc3VwZXIocGFyYW1zKTsKICAgIHRoaXMuZGF0YS5hbm5vdGF0aW9uVHlwZSA9IF91dGlsL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OiBbMCwgMCwgMF07CiAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gdGhpcy5ib3JkZXJTdHlsZS53aWR0aCB8fCAxLAogICAgICAgIGJvcmRlckFkanVzdCA9IDIgKiBib3JkZXJXaWR0aDsKICAgICAgY29uc3QgYmJveCA9IFtJbmZpbml0eSwgSW5maW5pdHksIC1JbmZpbml0eSwgLUluZmluaXR5XTsKICAgICAgZm9yIChjb25zdCBpbmtMaXN0cyBvZiB0aGlzLmRhdGEuaW5rTGlzdHMpIHsKICAgICAgICBmb3IgKGNvbnN0IHZlcnRleCBvZiBpbmtMaXN0cykgewogICAgICAgICAgYmJveFswXSA9IE1hdGgubWluKGJib3hbMF0sIHZlcnRleC54IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICAgIGJib3hbMV0gPSBNYXRoLm1pbihiYm94WzFdLCB2ZXJ0ZXgueSAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgICAgYmJveFszXSA9IE1hdGgubWF4KGJib3hbM10sIHZlcnRleC55ICsgYm9yZGVyQWRqdXN0KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBmb3IgKGNvbnN0IGlua0xpc3Qgb2YgdGhpcy5kYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGlua0xpc3QubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke2lua0xpc3RbaV0ueH0gJHtpbmtMaXN0W2ldLnl9ICR7aSA9PT0gMCA/ICJtIiA6ICJsIn1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLngsIHBvaW50c1szXS55LCBwb2ludHNbMV0ueV07CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICB9CiAgc3RhdGljIGNyZWF0ZU5ld0RpY3QoYW5ub3RhdGlvbiwgeHJlZiwgX3JlZjUpIHsKICAgIGxldCB7CiAgICAgIGFwUmVmLAogICAgICBhcAogICAgfSA9IF9yZWY1OwogICAgY29uc3QgewogICAgICBwYXRocywKICAgICAgcmVjdCwKICAgICAgcm90YXRpb24KICAgIH0gPSBhbm5vdGF0aW9uOwogICAgY29uc3QgaW5rID0gbmV3IF9wcmltaXRpdmVzLkRpY3QoeHJlZik7CiAgICBpbmsuc2V0KCJUeXBlIiwgX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkFubm90IikpOwogICAgaW5rLnNldCgiU3VidHlwZSIsIF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJJbmsiKSk7CiAgICBpbmsuc2V0KCJDcmVhdGlvbkRhdGUiLCBgRDokeygwLCBfdXRpbC5nZXRNb2RpZmljYXRpb25EYXRlKSgpfWApOwogICAgaW5rLnNldCgiUmVjdCIsIHJlY3QpOwogICAgaW5rLnNldCgiSW5rTGlzdCIsIHBhdGhzLm1hcChwID0+IHAucG9pbnRzKSk7CiAgICBpbmsuc2V0KCJGIiwgNCk7CiAgICBpbmsuc2V0KCJCb3JkZXIiLCBbMCwgMCwgMF0pOwogICAgaW5rLnNldCgiUm90YXRlIiwgcm90YXRpb24pOwogICAgY29uc3QgbiA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KHhyZWYpOwogICAgaW5rLnNldCgiQVAiLCBuKTsKICAgIGlmIChhcFJlZikgewogICAgICBuLnNldCgiTiIsIGFwUmVmKTsKICAgIH0gZWxzZSB7CiAgICAgIG4uc2V0KCJOIiwgYXApOwogICAgfQogICAgcmV0dXJuIGluazsKICB9CiAgc3RhdGljIGFzeW5jIGNyZWF0ZU5ld0FwcGVhcmFuY2VTdHJlYW0oYW5ub3RhdGlvbiwgeHJlZiwgcGFyYW1zKSB7CiAgICBjb25zdCB7CiAgICAgIGNvbG9yLAogICAgICByZWN0LAogICAgICByb3RhdGlvbiwKICAgICAgcGF0aHMsCiAgICAgIHRoaWNrbmVzcywKICAgICAgb3BhY2l0eQogICAgfSA9IGFubm90YXRpb247CiAgICBjb25zdCBbeDEsIHkxLCB4MiwgeTJdID0gcmVjdDsKICAgIGxldCB3ID0geDIgLSB4MTsKICAgIGxldCBoID0geTIgLSB5MTsKICAgIGlmIChyb3RhdGlvbiAlIDE4MCAhPT0gMCkgewogICAgICBbdywgaF0gPSBbaCwgd107CiAgICB9CiAgICBjb25zdCBhcHBlYXJhbmNlQnVmZmVyID0gW2Ake3RoaWNrbmVzc30gdyAxIEogMSBqYCwgYCR7KDAsIF9kZWZhdWx0X2FwcGVhcmFuY2UuZ2V0UGRmQ29sb3IpKGNvbG9yLCBmYWxzZSl9YF07CiAgICBpZiAob3BhY2l0eSAhPT0gMSkgewogICAgICBhcHBlYXJhbmNlQnVmZmVyLnB1c2goIi9SMCBncyIpOwogICAgfQogICAgY29uc3QgYnVmZmVyID0gW107CiAgICBmb3IgKGNvbnN0IHsKICAgICAgYmV6aWVyCiAgICB9IG9mIHBhdGhzKSB7CiAgICAgIGJ1ZmZlci5sZW5ndGggPSAwOwogICAgICBidWZmZXIuc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mVyLnB1c2goYCR7cG9pbnRzWzJdLnh9ICR7cG9pbnRzWzJdLnl9IG1gLCBgJHtwb2ludHNbM10ueH0gJHtwb2ludHNbM10ueX0gbGAsICJTIik7CiAgICAgICAgICAgIHJldHVybiBbcG9pbnRzWzBdLngsIHBvaW50c1sxXS54LCBwb2ludHNbM10ueSwgcG9pbnRzWzFdLnldOwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmRhdGEuaGFzUG9wdXAgPSBmYWxzZTsKICAgIH0KICB9Cn0KY2xhc3MgU3F1aWdnbHlBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk7CiAgICBjb25zdCBxdWFkUG9pbnRzID0gdGhpcy5kYXRhLnF1YWRQb2ludHMgPSBnZXRRdWFkUG9pbnRzKGRpY3QsIG51bGwpOwogICAgaWYgKHF1YWRQb2ludHMpIHsKICAgICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgICBjb25zdCBzdHJva2VDb2xvciA9IHRoaXMuY29sb3IgPyBnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgICAgeHJlZiwKICAgICAgICAgIGV4dHJhOiAiW10gMCBkIDEgdyIsCiAgICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgICBjb25zdCBkeSA9IChwb2ludHNbMF0ueSAtIHBvaW50c1syXS55KSAvIDY7CiAgICAgICAgICAgIGxldCBzaGlmdCA9IGR5OwogICAgICAgICAgICBsZXQgeCA9IHBvaW50c1syXS54OwogICAgICAgICAgICBjb25zdCB5ID0gcG9pbnRzWzJdLnk7CiAgICAgICAgICAgIGNvbnN0IHhFbmQgPSBwb2ludHNbM10ueDsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5ICsgc2hpZnR9IG1gKTsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIHggKz0gMjsKICAgICAgICAgICAgICBzaGlmdCA9IHNoaWZ0ID09PSAwID8gZHkgOiAwOwogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke3h9ICR7eSArIHNoaWZ0fSBsYCk7CiAgICAgICAgICAgIH0gd2hpbGUgKHggPCB4RW5kKTsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIlMiKTsKICAgICAgICAgICAgcmV0dXJuIFtwb2ludHNbMl0ueCwgeEVuZCwgeSAtIDIgKiBkeSwgeSArIDIgKiBkeV07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIHRoaXMuZGF0YS5oYXNQb3B1cCA9IGZhbHNlOwogICAgfQogIH0KfQpjbGFzcyBTdHJpa2VPdXRBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RSSUtFT1VUOwogICAgY29uc3QgcXVhZFBvaW50cyA9IHR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GggPSAwOwogICAgICAgIGlmICghdGhpcy5yZWFkKG9wZXJhdGlvbikpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5zYXZlZFN0YXRlc0RlcHRoICE9PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgewogICAgICAgICAgZm4sCiAgICAgICAgICBhcmdzCiAgICAgICAgfSA9IG9wZXJhdGlvbjsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgY29uc3QgW2ZvbnROYW1lLCBmb250U2l6ZV0gPSBhcmdzOwogICAgICAgICAgICBpZiAoZm9udE5hbWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgcmVzdWx0LmZvbnROYW1lID0gZm9udE5hbWUubmFtZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHlwZW9mIGZvbnRTaXplID09PSAibnVtYmVyIiAmJiBmb250U2l6ZSA+IDApIHsKICAgICAgICAgICAgICByZXN1bHQuZm9udFNpemUgPSBmb250U2l6ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYi5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxHcmF5OgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuZ3JheS5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAg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GRlc2NlbmRhbnRGb250LnNldCgiRmlyc3RDaGFyIiwgdGhpcy5maXJzdENoYXIpOwogICAgZGVzY2VuZGFudEZvbnQuc2V0KCJMYXN0Q2hhciIsIHRoaXMubGFzdENoYXIpOwogICAgZGVzY2VuZGFudEZvbnQuc2V0KCJGb250RGVzY3JpcHRvciIsIHRoaXMuZm9udERlc2NyaXB0b3JSZWYpOwogICAgZGVzY2VuZGFudEZvbnQuc2V0KCJEVyIsIDEwMDApOwogICAgY29uc3Qgd2lkdGhzID0gW107CiAgICBjb25zdCBjaGFycyA9IFsuLi50aGlzLndpZHRocy5lbnRyaWVzKCldLnNvcnQoKTsKICAgIGxldCBjdXJyZW50Q2hhciA9IG51bGw7CiAgICBsZXQgY3VycmVudFdpZHRocyA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtjaGFyLCB3aWR0aF0gb2YgY2hhcnMpIHsKICAgICAgaWYgKCFjdXJyZW50Q2hhcikgewogICAgICAgIGN1cnJlbnRDaGFyID0gY2hhcjsKICAgICAgICBjdXJyZW50V2lkdGhzID0gW3dpZHRoXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2hhciA9PT0gY3VycmVudENoYXIgKyBjdXJyZW50V2lkdGhzLmxlbmd0aCkgewogICAgICAgIGN1cnJlbnRXaWR0aHMucHVzaCh3aWR0aCk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgd2lkdGhzLnB1c2goY3VycmVudENoYXIsIGN1cnJlbnRXaWR0aHMpOwogICAgICAgIGN1cnJlbnRDaGFyID0gY2hhcjsKICAgICAgICBjdXJyZW50V2lkdGhzID0gW3dpZHRoXTsKICAgICAgfQogICAgfQogICAgaWYgKGN1cnJlbnRDaGFyKSB7CiAgICAgIHdpZHRocy5wdXNoKGN1cnJlbnRDaGFyLCBjdXJyZW50V2lkdGhzKTsKICAgIH0KICAgIGRlc2NlbmRhbnRGb250LnNldCgiVyIsIHdpZHRocyk7CiAgICBjb25zdCBjaWRTeXN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KICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlczsKICB9CiAgY3JlYXRlQXBwZWFyYW5jZSh0ZXh0LCByZWN0LCByb3RhdGlvbiwgZm9udFNpemUsIGJnQ29sb3IsIHN0cm9rZUFscGhhKSB7CiAgICBjb25zdCBjdHggPSB0aGlzLl9jcmVhdGVDb250ZXh0KCk7CiAgICBjb25zdCBsaW5lcyA9IFtdOwogICAgbGV0IG1heFdpZHRoID0gLUluZmluaXR5OwogICAgZm9yIChjb25zdCBsaW5lIG9mIHRleHQuc3BsaXQoL1xyXG4/fFxuLykpIHsKICAgICAgbGluZXMucHVzaChsaW5lKTsKICAgICAgY29uc3QgbGluZVdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGxpbmUpLndpZHRoOwogICAgICBtYXhXaWR0aCA9IE1hdGgubWF4KG1heFdpZHRoLCBsaW5lV2lkdGgpOwogICAgICBmb3IgKGNvbnN0IGNoYXIgb2YgbGluZS5zcGxpdCgiIikpIHsKICAgICAgICBjb25zdCBjb2RlID0gY2hhci5jaGFyQ29kZUF0KDApOwogICAgICAgIGxldCB3aWR0aCA9IHRoaXMud2lkdGhzLmdldChjb2RlKTsKICAgICAgICBpZiAod2lkdGggPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgY29uc3QgbWV0cmljcyA9IGN0eC5tZWFzdXJlVGV4dChjaGFyKTsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKG1ldHJpY3Mud2lkdGgpOwogICAgICAgICAgdGhpcy53aWR0aHMuc2V0KGNvZGUsIHdpZHRoKTsKICAgICAgICAgIHRoaXMuZmlyc3RDaGFyID0gTWF0aC5taW4oY29kZSwgdGhpcy5maXJzdENoYXIpOwogICAgICAgICAgdGhpcy5sYXN0Q2hhciA9IE1hdGgubWF4KGNvZGUsIHRoaXMubGFzdENoYXIpOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgbWF4V2lkdGggKj0gZm9udFNpemUgLyAxMDAwOwogICAgY29uc3Qg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sb3JzW2ldID0gaTsKICAgICAgfQogICAgICBjb25zdCBjb2xvck1hcCA9IG5ldyBVaW50OENsYW1wZWRBcnJheShudW1Db21wb25lbnRDb2xvcnMgKiAzKTsKICAgICAgdGhpcy5nZXRSZ2JCdWZmZXIoYWxsQ29sb3JzLCAwLCBudW1Db21wb25lbnRDb2xvcnMsIGNvbG9yTWFwLCAwLCBicGMsIDApOwogICAgICBpZiAoIW5lZWRzUmVzaXppbmcpIHsKICAgICAgICBsZXQgZGVzdFBvcyA9IDA7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgKytpKSB7CiAgICAgICAgICBjb25zdCBrZXkgPSBjb21wc1tpXSAqIDM7CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gY29sb3JNYXBba2V5ICsgMV07CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXkgKyAyXTsKICAgICAgICAgIGRlc3RQb3MgKz0gYWxwaGEwMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmdiQnVmID0gbmV3IFVpbnQ4QXJyYXkoY291bnQgKiAzKTsKICAgICAgICBsZXQgcmdiUG9zID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvdW50OyArK2kpIHsKICAgICAgICAgIGNvbnN0IGtleSA9IGNvbXBzW2ldICogMzsKICAgICAgICAgIHJnYkJ1ZltyZ2JQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDFdOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDJdOwogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgaWYgKCFuZWVkc1Jlc2l6aW5nKSB7CiAgICAgICAgdGhpcy5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3MubmFtZSkgewogICAgICAgIGNhc2UgIkciOgogICAgICAgIGNhc2UgIkRldmljZUdyYXkiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5ncmF5OwogICAgICAgIGNhc2UgIlJHQiI6CiAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgIGNhc2UgIkNNWUsiOgogICAgICAgIGNhc2UgIkRldmljZUNNWUsiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5jbXlrOwogICAgICAgIGNhc2UgIlBhdHRlcm4iOgogICAgICAgICAgcmV0dXJuIG5ldyBQYXR0ZXJuQ1MobnVsbCk7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChyZXNvdXJjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yU3BhY2VzID0gcmVzb3VyY2VzLmdldCgiQ29sb3JTcGFjZSIpOwogICAgICAgICAgICBpZiAoY29sb3JTcGFjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgICAgY29uc3QgcmVzb3VyY2VzQ1MgPSBjb2xvclNwYWNlcy5nZXQoY3MubmFtZSk7CiAgICAgICAgICAgICAgaWYgKHJlc291cmNlc0NTKSB7CiAgICAgICAgICAgICAgICBpZiAocmVzb3VyY2VzQ1MgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXJzZShyZXNvdXJjZXNDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY3MgPSByZXNvdXJjZXNDUzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnJlY29nbml6ZWQgQ29sb3JTcGFjZTogJHtjcy5uYW1lfWApOwogICAgICB9CiAgICB9CiAgICBpZiAoQXJyYXkuaXNBcnJheShjcykpIHsKICAgICAgY29uc3QgbW9kZSA9IHhyZWYuZmV0Y2hJZlJlZihjc1swXSkubmFtZTsKICAgICAgbGV0IHBhcmFtcywgbnVtQ29tcHMsIGJhc2VDUywgd2hpdGVQb2ludCwgYmxhY2tQb2ludCwgZ2FtbWE7CiAgICAgIHN3aXRjaCAobW9kZSkgewogICAgICAgIGNhc2UgIkciOgogICAgICAgIGNhc2UgIkRldmljZUdyYXkiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5ncmF5OwogICAgICAgIGNhc2UgIlJHQiI6CiAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgIGNhc2UgIkNNWUsiOgogICAgICAgIGNhc2UgIkRldmljZUNNWUsiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5jbXlrOwogICAgICAgIGNhc2UgIkNhbEdyYXkiOgogICAgICAgICAgcGFyYW1zID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIHdoaXRlUG9pbnQgPSBwYXJhbXMuZ2V0QXJyYXkoIldoaXRlUG9pbnQiKTsKICAgICAgICAgIGJsYWNrUG9pbnQgPSBwYXJhbXMuZ2V0QXJyYXkoIkJsYWNrUG9pbnQiKTsKICAgICAgICAgIGdhbW1hID0gcGFyYW1zLmdldCgiR2FtbWEiKTsKICAgICAgICAgIHJldHVybiBuZXcgQ2FsR3JheUNTKHdoaXRlUG9pbnQsIGJsYWNrUG9pbnQsIGdhbW1hKTsKICAgICAgICBjYXNlICJDYWxSR0IiOgogICAgICAgICAgcGFyYW1zID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIHdoaXRlUG9pbnQgPSBwYXJhbXMuZ2V0QXJyYXkoIldoaXRlUG9pbnQiKTsKICAgICAgICAgIGJsYWNrUG9pbnQgPSBwYXJhbXMuZ2V0QXJyYXkoIkJsYWNrUG9pbnQiKTsKICAgICAgICAgIGdhbW1hID0gcGFyYW1zLmdldEFycmF5KCJHYW1tYSIpOwogICAgICAgICAgY29uc3QgbWF0cml4ID0gcGFyYW1zLmdldEFycmF5KCJNYXRyaXgiKTsKICAgICAgICAgIHJldHVybiBuZXcgQ2FsUkdCQ1Mod2hpdGVQb2ludCwgYmxhY2tQb2ludCwgZ2FtbWEsIG1hdHJpeCk7CiAgICAgICAgY2FzZSAiSUNDQmFzZWQiOgogICAgICAgICAgY29uc3Qgc3RyZWFtID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIGNvbnN0IGRpY3QgPSBzdHJlYW0uZGljdDsKICAgICAgICAgIG51bUNvbXBzID0gZGljdC5nZXQoIk4iKTsKICAgICAgICAgIGNvbnN0IGFsdCA9IGRpY3QuZ2V0KCJBbHRlcm5hdGUiKTsKICAgICAgICAgIGlmIChhbHQpIHsKICAgICAgICAgICAgY29uc3QgYWx0Q1MgPSB0aGlzLl9wYXJzZShhbHQsIHhyZWYsIHJlc291cmNlcywgcGRmRnVuY3Rpb25GYWN0b3J5KTsKICAgICAgICAgICAgaWYgKGFsdENTLm51bUNvbXBzID09PSBudW1Db21wcykgewogICAgICAgICAgICAgIHJldHVybiBhbHRDUzsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIklDQ0Jhc2VkIGNvbG9yIHNwYWNlOiBJZ25vcmluZyBpbmNvcnJlY3QgL0FsdGVybmF0ZSBlbnRyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChudW1Db21wcyA9PT0gMSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUNvbXBzID09PSAzKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgICAgfSBlbHNlIGlmIChudW1Db21wcyA9PT0gNCkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmNteWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgIGJhc2VDUyA9IGNzWzFdIHx8IG51bGw7CiAgICAgICAgICBpZiAoYmFzZUNTKSB7CiAgICAgICAgICAgIGJhc2VDUyA9IHRoaXMuX3BhcnNlKGJhc2VDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBQYXR0ZXJuQ1MoYmFzZUNTKTsKICAgICAgICBjYXNlICJJIjoKICAgICAgICBjYXNlICJJbmRleGVkIjoKICAgICAgICAgIGJhc2VDUyA9IHRoaXMuX3BhcnNlKGNzWzFdLCB4cmVmLCByZXNvdXJjZXMsIHBkZkZ1bmN0aW9uRmFjdG9yeSk7CiAgICAgICAgICBjb25zdCBoaVZhbCA9IHhyZWYuZmV0Y2hJZlJlZihjc1syXSkgKyAxOwogICAgICAgICAgY29uc3QgbG9va3VwID0geHJlZi5mZXRjaElmUmVmKGNzWzNdKTsKICAgICAgICAgIHJldHVybiBuZXcgSW5kZXhlZENTKGJhc2VDUywgaGlWYWwsIGxvb2t1cCk7CiAgICAgICAgY2FzZSAiU2VwYXJhdGlvbiI6CiAgICAgICAgY2FzZSAiRGV2aWNlTiI6CiAgICAgICAgICBjb25zdCBuYW1lID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIG51bUNvbXBzID0gQXJyYXkuaXNBcnJheShuYW1lKSA/IG5hbWUubGVuZ3RoIDogM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pKCJUaGUgZGVjb2RlIG1hcCBpcyBub3QgdGhlIGNvcnJlY3QgbGVuZ3RoIik7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGVjb2RlLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgaWYgKGRlY29kZVtpXSAhPT0gMCB8fCBkZWNvZGVbaSArIDFdICE9PSAxKSB7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgc3RhdGljIGdldCBzaW5nbGV0b25zKCkgewogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJzaW5nbGV0b25zIiwgewogICAgICBnZXQgZ3JheSgpIHsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImdyYXkiLCBuZXcgRGV2aWNlR3JheUNTKCkpOwogICAgICB9LAogICAgICBnZXQgcmdiKCkgewogICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAicmdiIiwgbmV3IERldmljZVJnYkNTKCkpOwogICAgICB9LAogICAgICBnZXQgY215aygpIHsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImNteWsiLCBuZXcgRGV2aWNlQ215a0NTKCkpOwogICAgICB9CiAgICB9KTsKICB9Cn0KZXhwb3J0cy5Db2xvclNwYWNlID0gQ29sb3JTcGFjZTsKY2xhc3MgQWx0ZXJuYXRlQ1MgZXh0ZW5kcyBDb2xvclNwYWNlIHsKICBjb25zdHJ1Y3RvcihudW1Db21wcywgYmFzZSwgdGludEZuKSB7CiAgICBzdXBlcigiQWx0ZXJuYXRlIiwgbnVtQ29tcHMpOwogICAgdGhpcy5iYXNlID0gYmFzZTsKICAgIHRoaXMudGludEZuID0gdGludEZuOwogICAgdGhpcy50bXBCdWYgPSBuZXcgRmxvYXQzMkFycmF5KGJhc2U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KTsKICAgIHJldHVybiAic291cmNlLW92ZXIiOwogIH0KICBpZiAoISh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpKSB7CiAgICBpZiAocGFyc2luZ0FycmF5KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgcmV0dXJuICJzb3VyY2Utb3ZlciI7CiAgfQogIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgY2FzZSAiTm9ybWFsIjoKICAgIGNhc2UgIkNvbXBhdGlibGUiOgogICAgICByZXR1cm4gInNvdXJjZS1vdmVyIjsKICAgIGNhc2UgIk11bHRpcGx5IjoKICAgICAgcmV0dXJuICJtdWx0aXBseSI7CiAgICBjYXNlICJTY3JlZW4iOgogICAgICByZXR1cm4gInNjcmVlbiI7CiAgICBjYXNlICJPdmVybGF5IjoKICAgICAgcmV0dXJuICJvdmVybGF5IjsKICAgIGNhc2UgIkRhcmtlbiI6CiAgICAgIHJldHVybiAiZGFya2VuIjsKICAgIGNhc2UgIkxpZ2h0ZW4iOgogICAgICByZXR1cm4gImxpZ2h0ZW4iOwogICAgY2FzZSAiQ29sb3JEb2RnZSI6CiAgICAgIHJldHVybiAiY29sb3ItZG9kZ2UiOwogICAgY2FzZSAiQ29sb3JCdXJuIjoKICAgICAgcmV0dXJuICJjb2xvci1idXJuIjsKICAgIGNhc2UgIkhhcmRMaWdodCI6CiAgICAgIHJldHVybiAiaGFyZC1saWdodCI7CiAgICBjYXNlICJTb2Z0TGlnaHQiOgogICAgICByZXR1cm4gInNvZnQtbGlnaHQiOwogICAgY2FzZSAiRGlmZmVyZW5jZSI6CiAgICAgIHJldHVybiAiZGlmZmVyZW5jZSI7CiAgICBjYXNlICJFeGNsdXNpb24iOgogICAgICByZXR1cm4gImV4Y2x1c2lvbiI7CiAgICBjYXNlICJIdWUiOgogICAgICByZXR1cm4gImh1ZSI7CiAgICBjYXNlICJTYXR1cmF0aW9uIjoKICAgICAgcmV0dXJuICJzYXR1cmF0aW9uI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ICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCEoZ3JhcGhpY1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZ3JhcGhpY1N0YXRlLm9iaklkKSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoZ3JhcGhpY1N0YXRlLm9iaklkKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGJtID0gZ3JhcGhpY1N0YXRlLmdldCgiQk0iKTsKICAgICAgICAgIGlmIChibSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgaWYgKGJtLm5hbWUgIT09ICJOb3JtYWwiKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYm0gIT09IHVuZGVmaW5lZCAmJiBBcnJheS5pc0FycmF5KGJtKSkgewogICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgYm0pIHsKICAgICAgICAgICAgICBpZiAoZWxlbWVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUgJiYgZWxlbWVudC5uYW1lICE9PSAiTm9ybWFsIikgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHhPYmplY3RzID0gbm9kZS5nZXQoIlhPYmplY3QiKTsKICAgICAgaWYgKCEoeE9iamVjdHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IHhPYmplY3Qgb2YgeE9iamVjdHMuZ2V0UmF3VmFsdWVzKCkpIHsKICAgICAgICBpZiAoeE9iamVjdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaWYgKHByb2Nlc3NlZC5oYXMoeE9iamVjdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cnkgewogICAgICAgICAgICB4T2JqZWN0ID0geHJlZi5mZXRjaCh4T2JqZWN0KTsKICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeE9iamVjdCk7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoISh4T2JqZWN0IGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhPYmplY3QuZGljdC5vYmpJZCkgewogICAgICAgICAgcHJvY2Vzc2VkLnB1dCh4T2JqZWN0LmRpY3Qub2JqSWQpOwogICAgICAgIH0KICAgICAgICBjb25zdCB4UmVzb3VyY2VzID0geE9iamVjdC5kaWN0LmdldCgiUmVzb3VyY2VzIik7CiAgICAgICAgaWYgKCEoeFJlc291cmNlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQgJiYgcHJvY2Vzc2VkLmhhcyh4UmVzb3VyY2VzLm9iaklkKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5vZGVzLnB1c2goeFJlc291cmNlcyk7CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub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nZXRSYXcoIkNTIik7CiAgICAgICAgICBjb25zdCBjYWNoZWRDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5nZXRDYWNoZWQoY3MsIHRoaXMueHJlZiwgbG9jYWxDb2xvclNwYWNlQ2FjaGUpOwogICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgY29sb3JTcGFjZSA9IGNhY2hlZENvbG9yU3BhY2U7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb2xvclNwYWNlID0gYXdhaXQgdGhpcy5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgIGNzLAogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKHNtYXNrICYmIHNtYXNrLmJhY2tkcm9wKSB7CiAgICAgICAgY29sb3JTcGFjZSA9IGNvbG9yU3BhY2UgfHwgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYjsKICAgICAgICBzbWFzay5iYWNrZHJvcCA9IGNvbG9yU3BhY2UuZ2V0UmdiKHNtYXNrLmJhY2tkcm9wLCAwKTsKICAgICAgfQogICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLmJlZ2luR3JvdXAsIFtncm91cE9wdGlvbnNdKTsKICAgIH0KICAgIGNvbnN0IGFyZ3MgPSBncm91cCA/IFttYXRyaXgsIG51bGxdIDogW21hdHJpeCwgYmJveF07CiAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnBhaW50Rm9ybVhPYmplY3RCZWdpbiwgYXJncyk7CiAgICByZXR1cm4gdGhpcy5nZXRPcGVyYXRvckxpc3QoewogICAgICBzdHJlYW06IHhvYmosCiAgICAgIHRhc2ssCiAgICAgIHJlc291cmNlcz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gICAgICBmbjogX3V0aWwuT1BTLnBhaW50U29saWRDb2xvckltYWdlTWFzaywKICAgICAgICAgICAgYXJnczogW10sCiAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBvYmpJZCA9IGBtYXNrXyR7dGhpcy5pZEZhY3RvcnkuY3JlYXRlT2JqSWQoKX1gOwogICAgICBvcGVyYXRvckxpc3QuYWRkRGVwZW5kZW5jeShvYmpJZCk7CiAgICAgIHRoaXMuX3NlbmRJbWdEYXRhKG9iaklkLCBpbWdEYXRhKTsKICAgICAgYXJncyA9IFt7CiAgICAgICAgZGF0YTogb2JqSWQsCiAgICAgICAgd2lkdGg6IGltZ0RhdGEud2lkdGgsCiAgICAgICAgaGVpZ2h0OiBpbWdEYXRhLmhlaWdodCwKICAgICAgICBpbnRlcnBvbGF0ZTogaW1nRGF0YS5pbnRlcnBvbGF0ZSwKICAgICAgICBjb3VudDogMQogICAgICB9XTsKICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKF91dGlsLk9QUy5wYWludEltYWdlTWFza1hPYmplY3QsIGFyZ3MsIG9wdGlvbmFsQ29udGVudCk7CiAgICAgIGlmIChjYWNoZUtleSkgewogICAgICAgIGxvY2FsSW1hZ2VDYWNoZS5zZXQoY2FjaGVLZXksIGltYWdlUmVmLCB7CiAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50SW1hZ2VNYXNrWE9iamVjdCwKICAgICAgICAgIGFyZ3MsCiAgICAgICAgICBvcHRpb25hbENvbnRlbnQKICAgICAgICB9KTsKICAgICAgfQogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBzb2Z0TWFzayA9IGRpY3QuZ2V0KCJTTSIsICJTTWFzayIpIHx8IGZhbHNlOwogICAgY29uc3QgbWFzayA9IGRpY3QuZ2V0KCJNYXNrIikgfHwgZmFsc2U7CiAgICBjb25zdCBTTUF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dXNoKFtrZXksIHZhbHVlXSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgIGlzU2ltcGxlR1N0YXRlID0gZmFsc2U7CiAgICAgICAgICBwcm9taXNlID0gcHJvbWlzZS50aGVuKCgpID0+IHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIG51bGwsIHZhbHVlWzBdLCBvcGVyYXRvckxpc3QsIHRhc2ssIHN0YXRlTWFuYWdlci5zdGF0ZSkudGhlbihmdW5jdGlvbiAobG9hZGVkTmFtZSkgewogICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGxvYWRlZE5hbWUpOwogICAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIFtsb2FkZWROYW1lLCB2YWx1ZVsxXV1dKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJNIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIG5vcm1hbGl6ZUJsZW5kTW9kZSh2YWx1ZSldKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlNNYXNrIjoKICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh2YWx1ZSwgIk5vbmUiKSkgewogICAgICAgICAgICBnU3RhdGVPYmoucHVzaChba2V5LCBmYWxzZV0pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgaXNTaW1wbGVHU3RhdGUgPSBmYWxzZTsKICAgICAgICAgICAgcHJvbWlzZSA9IHByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU01hc2sodmFsdWUsIHJlc291cmNlcywgb3BlcmF0b3JMaXN0LCB0YXNrLCBzdGF0ZU1hbmFnZXIsIGxvY2FsQ29sb3JTcGFjZUNhY2hlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRydWVdKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5zdXBwb3J0ZWQgU01hc2sgdHlwZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiVFIiOgogICAgICAgICAgY29uc3QgdHJhbnNmZXJNYXBzID0gdGhpcy5oYW5kbGVUcmFuc2ZlckZ1bmN0aW9uKHZhbHVlKTsKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRyYW5zZmVyTWFwc10pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT1AiOgogICAgICAgIGNhc2UgIm9wIjoKICAgICAgICBjYXNlICJPUE0iOgogICAgICAgIGNhc2UgIkJHIjoKICAgICAgICBjYXNlICJCRzIiOgogICAgICAgIGNhc2UgIlVDUiI6CiAgICAgICAgY2FzZSAiVUNSMiI6CiAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgY2FzZSAiU00iOgogICAgICAgIGNhc2UgIlNBIjoKICAgICAgICBjYXNlICJBSVMiOgogICAgICAgIGNhc2UgIlRLIjoKICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICsga2V5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoIlVua25vd24gZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICsga2V5KTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcHJvbWlzZS50aGVuKGZ1b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PSBmb250OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmb250UmVzID0gcmVzb3VyY2VzLmdldCgiRm9udCIpOwogICAgICBpZiAoZm9udFJlcykgewogICAgICAgIGZvbnRSZWYgPSBmb250UmVzLmdldFJhdyhmb250TmFtZSk7CiAgICAgIH0KICAgIH0KICAgIGlmICghZm9udFJlZikgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gYEZvbnQgIiR7Zm9udE5hbWUgfHwgZm9udCAmJiBmb250LnRvU3RyaW5nKCl9IiBpcyBub3QgYXZhaWxhYmxlYDsKICAgICAgaWYgKCF0aGlzLm9wdGlvbnMuaWdub3JlRXJyb3JzICYmICF0aGlzLnBhcnNpbmdUeXBlM0ZvbnQpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7cGFydGlhbE1zZ30uYCk7CiAgICAgICAgcmV0dXJuIGVycm9yRm9udCgpOwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKShgJHtwYXJ0aWFsTXNnfSAtLSBhdHRlbXB0aW5nIHRvIGZhbGxiYWNrIHRvIGEgZGVmYXVsdCBmb250LmApOwogICAgICBpZiAoZmFsbGJhY2tGb250RGljdCkgewogICAgICAgIGZvbnRSZWYgPSBmYWxsYmFja0ZvbnREaWN0OwogICAgICB9IGVsc2UgewogICAgICAgIGZvbnRSZWYgPSBQYXJ0aWFsRXZhbHVhdG9yLmZhbGxiYWNrRm9udERpY3Q7CiAgICAgIH0KICAgIH0KICAgIGlmICh0aGlzLnBhcnNpbmdUeXBlM0ZvbnQgJiYgdGhpcy50eXBlM0ZvbnRSZWZzLmhhcyhmb250UmVmKSkgewogICAgICByZXR1cm4gZXJyb3JGb250KCk7CiAgICB9CiAgICBpZiAodGhpcy5mb250Q2FjaGUuaGFzKGZvbnRSZWYpKSB7CiAgICAgIHJldHVybiB0aGlzLmZvbnRDYWNoZS5nZXQoZm9udFJlZik7CiAgICB9CiAgICBmb250ID0geHJlZi5mZXRjaElmUmV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udEFsaWFzZXMpIHsKICAgICAgICBkZXNjcmlwdG9yLmZvbnRBbGlhc2VzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgfQogICAgICBjb25zdCBmb250QWxpYXNlcyA9IGRlc2NyaXB0b3IuZm9udEFsaWFzZXM7CiAgICAgIGlmIChmb250QWxpYXNlc1toYXNoXSkgewogICAgICAgIGNvbnN0IGFsaWFzRm9udFJlZiA9IGZvbnRBbGlhc2VzW2hhc2hdLmFsaWFzUmVmOwogICAgICAgIGlmIChmb250UmVmSXNSZWYgJiYgYWxpYXNGb250UmVmICYmIHRoaXMuZm9udENhY2hlLmhhcyhhbGlhc0ZvbnRSZWYpKSB7CiAgICAgICAgICB0aGlzLmZvbnRDYWNoZS5wdXRBbGlhcyhmb250UmVmLCBhbGlhc0ZvbnRSZWYpOwogICAgICAgICAgcmV0dXJuIHRoaXMuZm9udENhY2hlLmdldChmb250UmVmKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9udEFsaWFzZXNbaGFzaF0gPSB7CiAgICAgICAgICBmb250SUQ6IHRoaXMuaWRGYWN0b3J5LmNyZWF0ZUZvbnRJZCgpCiAgICAgICAgfTsKICAgICAgfQogICAgICBpZiAoZm9udFJlZklzUmVmKSB7CiAgICAgICAgZm9udEFsaWFzZXNbaGFzaF0uYWxpYXNSZWYgPSBmb250UmVmOwogICAgICB9CiAgICAgIGZvbnRJRCA9IGZvbnRBbGlhc2VzW2hhc2hdLmZvbnRJRDsKICAgIH0KICAgIGlmIChmb250UmVmSXNSZWYpIHsKICAgICAgdGhpcy5mb250Q2FjaGUucHV0KGZvbnRSZWYsIGZvbnRDYXBhYmlsaXR5LnByb21pc2UpOwogICAgfSBlbHNlIHsKICAgICAgaWYgKCFmb250SUQpIHsKICAgICAgICBmb250SUQgPSB0aGlzLmlkRmFjdG9yeS5jcmVhdGVGb250SWQoKTsKICAgICAgfQogICAgICBmb250LmNhY2hlS2V5ID0gYGNhY2hlS2V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ICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4ID0gW2FyZ3NbMF0sIGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMV1dOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIG1pbk1heCA9IFtJbmZpbml0eSwgLUluZmluaXR5LCBJbmZpbml0eSwgLUluZmluaXR5XTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuY29uc3RydWN0UGF0aCwgW1tmbl0sIGFyZ3MsIG1pbk1heF0pOwogICAgICBpZiAocGFyc2luZ1RleHQpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnJlc3RvcmUsIG51bGwpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBvcEFyZ3MgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5W2xhc3RJbmRleF07CiAgICAgIG9wQXJnc1swXS5wdXNoKGZuKTsKICAgICAgb3BBcmdzWzFdLnB1c2goLi4uYXJncyk7CiAgICAgIGNvbnN0IG1pbk1heCA9IG9wQXJnc1syXTsKICAgICAgc3dpdGNoIChmbikgewogICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgIGNvbnN0IHggPSBhcmdzWzBdICsgYXJnc1syXTsKICAgICAgICAgIGNvbnN0IHkgPSBhcmdzWzFdICsgYXJnc1szXTsKICAgICAgICAgIG1pbk1heFswXSA9IE1hdGgubWluKG1pbk1heFswXSwgYXJnc1swXSwgeCk7CiAgICAgICAgICBtaW5NYXhbMV0gPSBNYXRoLm1heChtaW5NYXhbMV0sIGFyZ3NbMF0sIHgpOwogICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBhcmdzWzFdLCB5KTsKICAgICAgICAgIG1pbk1heFszXSA9IE1hdGgubWF4KG1pbk1heFszXSwgYXJnc1sxXSwgeSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4WzBdID0gTWF0aC5taW4obWluTWF4WzBdLCBhcmdzWzBdKTsKICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYXJnc1swXSk7CiAgICAgICAgICBtaW5NYXhbMl0gPSBNYXRoLm1pbihtaW5NYXhbMl0sIGFyZ3NbMV0pOwogICAgICAgICAgbWluTWF4WzNdID0gTWF0aC5tYXgobWluTWF4WzNdLCBhcmdzWzFdKTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlQ29sb3JTcGFjZShfcmVmNCkgewogICAgbGV0IHsKICAgICAgY3MsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgIH0gPSBfcmVmNDsKICAgIHJldHVybiBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlQXN5bmMoewogICAgICBjcywKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICByZXNvdXJjZXMsCiAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeTogdGhpcy5fcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlQ29sb3JTcGFjZSAtIGlnbm9yaW5nIENvbG9yU3BhY2U6ICIke3JlYXNvbn0i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ENvbnRlbnQgPSBjb250ZW50UHJvcGVydGllczsKICAgIH0gZWxzZSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiT3B0aW9uYWwgY29udGVudCBwcm9wZXJ0aWVzIG1hbGZvcm1lZC4iKTsKICAgIH0KICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudFR5cGUgPSBvcHRpb25hbENvbnRlbnQuZ2V0KCJUeXBlIikubmFtZTsKICAgIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NHIikgewogICAgICByZXR1cm4gewogICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgaWQ6IG9wdGlvbmFsQ29udGVudC5vYmpJZAogICAgICB9OwogICAgfSBlbHNlIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NNRCIpIHsKICAgICAgY29uc3QgZXhwcmVzc2lvbiA9IG9wdGlvbmFsQ29udGVudC5nZXQoIlZFIik7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KGV4cHJlc3Npb24pKSB7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gW107CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihleHByZXNzaW9uLCAwLCByZXN1bHQpOwogICAgICAgIGlmIChyZXN1bHQubGVuZ3RoID4gMCkgewogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgdHlwZTogIk9DTUQiLAogICAgICAgICAgICBleHByZXNzaW9uOiByZXN1bHQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudEdyb3VwcyA9IG9wdGlvbmFsQ29udGVudC5nZXQoIk9DR3MiKTsKICAgICAgaWYgKEFycmF5LmlzQXJyYXkob3B0aW9uYWxDb250ZW50R3JvdXBzKSB8fCBvcHRpb25hbENvbnRlbnRHcm91cHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgY29uc3QgZ3JvdXBJZHMgPSBbXTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvcHRpb25hbENvbnRlbnRHcm91cHMpKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IG9jZyBvZiBvcHRpb25hbENvbnRlbnRHcm91cHMpIHsKICAgICAgICAgICAgZ3JvdXBJZHMucHVzaChvY2cudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGdyb3VwSWRzLnB1c2gob3B0aW9uYWxDb250ZW50R3JvdXBzLm9iaklkKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZHM6IGdyb3VwSWRzLAogICAgICAgICAgcG9saWN5OiBvcHRpb25hbENvbnRlbnQuZ2V0KCJQIikgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gb3B0aW9uYWxDb250ZW50LmdldCgiUCIpLm5hbWUgOiBudWxsLAogICAgICAgICAgZXhwcmVzc2lvbjogbnVsbAogICAgICAgIH07CiAgICAgIH0gZWxzZSBpZiAob3B0aW9uYWxDb250ZW50R3JvdXBzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZDogb3B0aW9uYWxDb250ZW50R3JvdXBzLnRvU3RyaW5nKCkKICAgICAgICB9OwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbnVsbDsKICB9CiAgZ2V0T3BlcmF0b3JMaXN0KF9yZWY2KSB7CiAgICBsZXQgewogICAgICBzdHJlYW0sCiAgICAgIHRhc2ssCiAgICAgIHJlc291cmNlcywKICAgICAgb3BlcmF0b3JMaXN0LAogICAgICBpbml0aWFsU3RhdGUgPSBudWxsLAogICAg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BjcywgbmFtZSwgaXNWYWxpZE5hbWU7CiAgICAgIHdoaWxlICghKHN0b3AgPSB0aW1lU2xvdE1hbmFnZXIuY2hlY2soKSkpIHsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IG51bGw7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgbGV0IGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBsZXQgZm4gPSBvcGVyYXRpb24uZm47CiAgICAgICAgc3dpdGNoIChmbiB8IDApIHsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50WE9iamVjdDoKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeU5hbWUobmFtZSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZVhPYmplY3QsIHJlamVjdFhPYmplY3QpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlhPYmplY3QgbXVzdCBiZSByZWZlcnJlZCB0byBieSBuYW1lLiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZXQgeG9iaiA9IHhvYmpzLmdldFJhdyhuYW1lKTsKICAgICAgICAgICAgICBpZiAoeG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeVJlZih4b2JqKTsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgICAgaW5jcmVtZW50Q2FjaGVkSW1hZ2VNYXNrQ291bnQobG9jYWxJbWFnZSk7CiAgICAgICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGdsb2JhbEltYWdlID0gc2VsZi5nbG9iYWxJbWFnZUNhY2hlLmdldERhdGEoeG9iaiwgc2VsZi5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgaWYgKGdsb2JhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGdsb2JhbEltYWdlLm9iaklkKTsKICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKGdsb2JhbEltYWdlLmZuLCBnbG9iYWxJbWFnZS5hcmdzLCBnbG9iYWxJbWFnZS5vcHRpb25hbENvbnRlbnQpOwogICAgICAgICAgICAgICAgICByZXNvbHZlWE9iamVjdCgpOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB4b2JqID0geHJlZi5mZXRjaCh4b2JqKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKCEoeG9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBiZSBhIHN0cmVhbSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCB0eXBlID0geG9iai5kaWN0LmdldCgiU3VidHlwZSIpOwogICAgICAgICAgICAgIGlmICghKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBoYXZlIGEgTmFtZSBzdWJ0eXBlIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICh0eXBlLm5hbWUgPT09ICJGb3JtIikgewogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICAgICAgICAgIHNlbGYuYnVpbGRGb3JtWE9iamVjdChyZXNvdXJjZXMsIHhvYmosIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCksIGxvY2FsQ29sb3JTcGFjZUNhY2hlKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIH0sIHJlamVjdFhPYmplY3QpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZS5uYW1lID09PSAiSW1hZ2UiKSB7CiAgICAgICAgICAgICAgICBzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICAgIGltYWdlOiB4b2JqLAogICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUsCiAgICAgICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgICAgICB9KS50aGVuKHJlc29sdmVYT2JqZWN0LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGUubmFtZSA9PT0gIlBTIikgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJJZ25vcmVkIFhPYmplY3Qgc3VidHlwZSBQUyIpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVuaGFuZGxlZCBYT2JqZWN0IHN1YnR5cGUgJHt0eXBlLm5hbWV9YCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgWE9iamVjdDogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICB2YXIgZm9udFNpemUgPSBhcmdzWzFdOwogICAgICAgICAgICBuZXh0KHNlbGYuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIGFyZ3MsIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLCBmYWxsYmFja0ZvbnREaWN0KS50aGVuKGZ1bmN0aW9uIChsb2FkZWROYW1lKSB7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZERlcGVuZGVuY3kobG9hZGVkTmFtZSk7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRGb250LCBbbG9hZGVkTmFtZSwgZm9udFNpemVdKTsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHBhcnNpbmdUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lbmRUZXh0OgogICAgICAgICAgICBwYXJzaW5nVGV4dCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZElubGluZUltYWdlOgogICAgICAgICAgICB2YXIgY2FjaGVLZXkgPSBhcmdzWzBdLmNhY2hlS2V5OwogICAgICAgICAgICBpZiAoY2FjaGVLZXkpIHsKICAgICAgICAgICAgICBjb25zdCBsb2NhbEltYWdlID0gbG9jYWxJbWFnZUNhY2hlLmdldEJ5TmFtZShjYWNoZUtleSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBpbWFnZTogYXJnc1swXSwKICAgICAgICAgICAgICBpc0lubGluZTogdHJ1ZSwKICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgY2FjaGVLZXksCiAgICAgICAgICAgICAgbG9jYWxJbWFnZUNhY2hlLAogICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGFyZ3NbMF0gPSBzZWxmLmhhbmRsZVRleHQoYXJnc1swXSwgc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNvbWJpbmVkR2x5cGhzID0gW107CiAgICAgICAgICAgIHZhciBzdGF0ZSA9IHN0YXRlTWFuYWdlci5zdGF0ZTsKICAgICAgICAgICAgZm9yIChjb25zdCBhcnJJdGVtIG9mIGFyZ3NbMF0pIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKC4uLnNlbGYuaGFuZGxlVGV4dChhcnJJdGVtLCBzdGF0ZSkpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKGFyckl0ZW0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzWzBdID0gY29tYmluZWRHbHlwaHM7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdX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IHsKICAgICAgICAgICAgICBjb25zdCBjYWNoZWRDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5nZXRDYWNoZWQoYXJnc1swXSwgeHJlZiwgbG9jYWxDb2xvclNwYWNlQ2FjaGUpOwogICAgICAgICAgICAgIGlmIChjYWNoZWRDb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuZmlsbENvbG9yU3BhY2UgPSBjYWNoZWRDb2xvclNwYWNlOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIG5leHQoc2VsZi5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgICAgY3M6IGFyZ3NbMF0sCiAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIGlmIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JTcGFjZToKICAgICAgICAgICAgewogICAgICAgICAgICAgIGNvbnN0IGNhY2hlZENvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLmdldENhY2hlZChhcmdzWzBdLCB4cmVmLCBsb2NhbENvbG9yU3BhY2VDYWNoZSk7CiAgICAgICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlID0gY2FjaGVkQ29sb3JTcGFjZTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VDb2xvclNwYWNlKHsKICAgICAgICAgICAgICAgIGNzOiBhcmdzWzBdLAogICAgICAgICAgICAgICAgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBpZiAoY29sb3JTcGFjZSkgewogICAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuc3Ryb2tlQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZTsKICAgICAgICAgICAgYXJncyA9IGNzLmdldFJnYihhcmdzLCAwKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2V0RmlsbFJHQkNvbG9yOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlOwogICAgICAgICAgICBhcmdzID0gY3MuZ2V0UmdiKGFyZ3MsIDApOwogICAgICAgICAgICBmbiA9IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvcjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsR3JheToKICAgICAgICAgICAgc3R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AgICAgICAgICBpZiAoIXNoYWRpbmdSZXMpIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk5vIHNoYWRpbmcgcmVzb3VyY2UgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgc2hhZGluZyA9IHNoYWRpbmdSZXMuZ2V0KGFyZ3NbMF0ubmFtZSk7CiAgICAgICAgICAgIGlmICghc2hhZGluZykgewogICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTm8gc2hhZGluZyBvYmplY3QgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBwYXR0ZXJuSWQgPSBzZWxmLnBhcnNlU2hhZGluZyh7CiAgICAgICAgICAgICAgc2hhZGluZywKICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgICAgICAgICAgbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBhcmdzID0gW3BhdHRlcm5JZF07CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNoYWRpbmdGaWxsOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxHU3RhdGVPYmogPSBsb2NhbEdTdGF0ZUNhY2hlLmdldEJ5TmFtZShuYW1lKTsKICAgICAgICAgICAgICBpZiAobG9jYWxHU3RhdGVPYmopIHsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuc2V0R1N0YXRlLCBbbG9jYWxHU3RhdGVPYmpdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGFyZ3MgPSBudWxsOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQobmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIG11c3QgYmUgcmVmZXJyZWQgdG8gYnkgbmFtZS4iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZXh0R1N0YXRlID0gcmVzb3VyY2VzLmdldCgiRXh0R1N0YXRlIik7CiAgICAgICAgICAgICAgaWYgKCEoZXh0R1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiRXh0R1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGdTdGF0ZSA9IGV4dEdTdGF0ZS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgaWYgKCEoZ1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNlbGYuc2V0R1N0YXRlKHsKICAgICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICAgIGdTdGF0ZSwKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlciwKICAgICAgICAgICAgICAgIGxvY2FsR1N0YXRlQ2FjaGUsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4ocmVzb2x2ZUdTdGF0ZSwgcmVqZWN0R1N0YXRlKTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubW92ZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8yOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzM6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZVBhdGg6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5yZWN0YW5nbGU6CiAgICAgICAgICAgIHNlbGYuYnVpbGRQYXRoKG9wZXJhdG9yTGlzdCwgZm4sIGFyZ3MsIHBhcnNpbmdUZXh0KTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnQ6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnRQcm9wczoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luQ29tcGF0OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kQ29tcGF0OgogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudFByb3BzOgogICAgICAgICAgICBpZiAoIShhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEV4cGVjdGVkIG5hbWUgZm9yIGJlZ2luTWFya2VkQ29udGVudFByb3BzIGFyZzA9JHthcmdzWzBdfWApOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcmdzWzBdLm5hbWUgPT09ICJPQyIpIHsKICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VNYXJrZWRDb250ZW50UHJvcHMoYXJnc1sxXSwgcmVzb3VyY2VzKS50aGVuKGRhdGEgPT4gewogICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywgWyJPQyIsIGRhdGFdKTsKICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzZWxmLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzID0gW2FyZ3NbMF0ubmFtZSwgYXJnc1sxXSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgPyBhcmdzWzFdLmdldCgiTUNJRCIpIDogbnVsbF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGlmIChhcmdzICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgZm9yIChpID0gMCwgaWkgPSBhcmdzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChhcmdzW2ldIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKGkgPCBpaSkgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBvcGVyYXRvcjogIiArIGZuKTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoZm4sIGFyZ3MpOwogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNsb3NlUGVuZGluZ1Jlc3RvcmVPUFMoKTsKICAgICAgcmVzb2x2ZSgpOwogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGlmICh0aGlzLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBlcnJvcnMgZHVyaW5nICIke3Rhc2submFtZX0iIGAgKyBgdGFzazogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgY2xvc2VQZW5kaW5nUmVzdG9yZU9QUygpOwogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aHJvdyByZWFzb247CiAgICB9KTsKICB9CiAgZ2V0VGV4dENvbnRlbnQoX3JlZjcpIHsKICAgIGxldCB7CiAgICAgIHN0cmVhbSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBzdGF0ZU1hbmFnZXIgPSBudWxsLAogICAgICBjb21iaW5lVGV4dEl0ZW1zID0gZmFsc2UsCiAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50ID0gZmFsc2UsCiAgICAgIHNpbmssCiAgICAgIHNlZW5TdHlsZXMgPSBuZXcgU2V0KCksCiAgICAgIHZpZXdCb3gsCiAgICAgIG1hcmtlZENvbnRlbnREYXRhID0gbnVsbAogICAgfSA9IF9yZWY3OwogICAgcmVzb3VyY2VzID0gcmVzb3VyY2VzIHx8IF9wcmltaXRp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AgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnQsCiAgICAgICAgbG9hZGVkTmFtZQogICAgICB9ID0gdGV4dFN0YXRlOwogICAgICBpZiAoIXNlZW5TdHlsZXMuaGFzKGxvYWRlZE5hbWUpKSB7CiAgICAgICAgc2VlblN0eWxlcy5hZGQobG9hZGVkTmFtZSk7CiAgICAgICAgdGV4dENvbnRlbnQuc3R5bGVzW2xvYWRlZE5hbWVdID0gewogICAgICAgICAgZm9udEZhbWlseTogZm9udC5mYWxsYmFja05hbWUsCiAgICAgICAgICBhc2NlbnQ6IGZvbnQuYXNjZW50LAogICAgICAgICAgZGVzY2VudDogZm9udC5kZXNjZW50LAogICAgICAgICAgdmVydGljYWw6IGZvbnQudmVydGljYWwKICAgICAgICB9OwogICAgICB9CiAgICAgIHRleHRDb250ZW50SXRlbS5mb250TmFtZSA9IGxvYWRlZE5hbWU7CiAgICAgIGNvbnN0IHRybSA9IHRleHRDb250ZW50SXRlbS50cmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICBpZiAoIWZvbnQudmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggPSB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCA9IDA7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9IE1hdGguaHlwb3QodHJtWzJdLCB0cm1bM10pOwogICAgICAgIHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCA9IGZhbHNlOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50SXRlbS53aWR0aCA9IHRleHRDb250ZW50SXRlbS50b3RhbFdpZHRoID0gTWF0aC5oeXBvdCh0cm1bMF0sIHRybVsxXSk7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9ID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l0ZW0oKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVgpID4gdGV4dENvbnRlbnRJdGVtLndpZHRoKSB7CiAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoYWR2YW5jZVkgPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLm5vdEFTcGFjZSkgewogICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICB9CiAgICAgICAgaWYgKGFkdmFuY2VZIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS50cmFja2luZ1NwYWNlTWluKSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICs9IGFkdmFuY2VZOwogICAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVksIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgICBpZiAodGV4dENvbnRlbnRJdGVtLnN0ci5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgICAgc3RyOiAiICIsCiAgICAgICAgICAgICAgZGlyOiAibHRyIiwKICAgICAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgICAgICBoZWlnaHQ6IE1hdGguYWJzKGFkdmFuY2VZKSwKICAgICAgICAgICAgICB0cmFuc2Zvcm06IHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLAogICAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRDb250ZW50SXRlbS5oZWlnaHQgKz0gYWR2YW5jZVk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWCkgPiB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiBWRVJUSUNBTF9TSElGVF9SQVRJTykgewogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH0KICAgICAgY29uc3QgYWR2YW5jZVggPSAocG9zWCAtIGxhc3RQb3NYKSAvIHRleHRDb250ZW50SXRlbS50ZXh0QWR2YW5jZVNjYWxlOwogICAgICBjb25zdCBhZHZhbmNlWSA9IHBvc1kgLSBsYXN0UG9zWTsKICAgICAgY29uc3QgdGV4dE9yaWVudGF0aW9uID0gTWF0aC5zaWduKHRleHRDb250ZW50SXRlbS53aWR0aCk7CiAgICAgIGlmIChhZHZhbmNlWCA8IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5uZWdhdGl2ZVNwYWNlTWF4KSB7CiAgICAgICAgaWYgKE1hdGguYWJzKGFkdmFuY2VZKSA+IDAuNSAqIHRleHRDb250ZW50SXRlbS5oZWlnaHQpIHsKICAgICAgICAgIGFwcGVuZEVPTCgpOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfQogICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVkpID4gdGV4dENvbnRlbnRJdGVtLmhlaWdodCkgewogICAgICAgIGFwcGVuZEVPTCgpOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChhZHZhbmNlWCA8PSB0ZXh0T3JpZW50YXRpb24gKiB0ZXh0Q29udGVudEl0ZW0ubm90QVNwYWNlKSB7CiAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgfQogICAgICBpZiAoYWR2YW5jZVggPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnRyYWNraW5nU3BhY2VNaW4pIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVgsIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5zdHIubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgIHN0cjogIiAiLAogICAgICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgICAgICB3aWR0aDogTWF0aC5hYnMoYWR2YW5jZVgpLAogICAgICAgICAgICBoZWlnaHQ6IDAsCiAgICAgICAgICAgIHRyYW5zZm9ybTogdGV4dENvbnRlbnRJdGVtLnByZXZUcmFuc2Zvcm0sCiAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgIGhhc0VPTDogZmFsc2UKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWSkgPiB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICogVkVSVElDQUxfU0hJRlRfUkFUSU8pIHsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZnVuY3Rpb24gYnVpbGRUZXh0Q29udGVudEl0ZW0oX3JlZjgpIHsKICAgICAgbGV0IHsKICAgICAgICBjaGFycywKICAgICAgICBleHRyYVNwYWNpbmcKICAgICAgfSA9IF9yZWY4OwogICAgICBjb25zdCBmb250ID0gdGV4dFN0YXRlLmZvbnQ7CiAgICAgIGlmICghY2hhcnMpIHsKICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IHRleHRTdGF0ZS5jaGFyU3BhY2luZyArIGV4dHJhU3BhY2luZzsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBnbHlwaHMgPSBmb250LmNoYXJzVG9HbHlwaHMoY2hhcnMpOwogICAgICBjb25zdCBzY2FsZSA9IHRleHRTdGF0ZS5mb250TWF0cml4WzBdICogdGV4dFN0YXRlLmZvbnRTaXplOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBnbHlwaHMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgIGNvbnN0IHsKICAgICAgICAgIGNhdGVnb3J5CiAgICAgICAgfSA9IGdseXBoOwogICAgICAgIGlmIChjYXRlZ29yeS5pc0ludmlzaWJsZUZvcm1hdE1hcmspIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsZXQgY2hhclNwYWNpbmcgPSB0ZXh0U3RhdGUuY2hhclNwYWNpbmcgKyAoaSArIDEgPT09IGlpID8gZXh0cmFTcGFjaW5nIDogMCk7CiAgICAgICAgbGV0IGdseXBoV2lkdGggPSBnbHlwaC53aWR0aDsKICAgICAgICBpZiAoZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgZ2x5cGhXaWR0aCA9IGdseXBoLnZtZXRyaWMgPyBnbHlwaC52bWV0cmljWzBdIDogLWdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGxldCBzY2FsZWREaW0gPSBnbHlwaFdpZHRoICogc2NhbGU7CiAgICAgICAgaWYgKGNhdGVnb3J5LmlzV2hpdGVzcGFjZSkgewogICAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICAgIGNoYXJTcGFjaW5nICs9IHNjYWxlZERpbSArIHRleHRTdGF0ZS53b3JkU3BhY2luZzsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoY2hhclNwYWNpbmcgKiB0ZXh0U3RhdGUudGV4dEhTY2FsZSwgMCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjaGFyU3BhY2luZyArPSAtc2NhbGVkRGltICsgdGV4dFN0YXRlLndvcmRTcGFjaW5nOwogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeCgwLCAtY2hhclNwYWNpbmcpOwogICAgICAgICAgfQogICAgICAgICAgc2F2ZUxhc3RDaGFyKCIgIik7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKCFjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYyAmJiAhY29tcGFyZVdpdGhMYXN0UG9zaXRpb24oKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHRleHRDaHVuayA9IGVuc3VyZVRleHRDb250ZW50SXRlbSgpOwogICAgICAgIGlmIChjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYykgewogICAgICAgICAgc2NhbGVkRGltID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICBzY2FsZWREaW0gKj0gdGV4dFN0YXRlLnRleHRIU2NhbGU7CiAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChzY2FsZWREaW0sIDApOwogICAgICAgICAgdGV4dENodW5rLndpZHRoICs9IHNjYWxlZERpbTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoMCwgc2NhbGVkRGltKTsKICAgICAgICAgIHNjYWxlZERpbSA9IE1hdGguYWJzKHNjYWxlZERpbSk7CiAgICAgICAgICB0ZXh0Q2h1bmsuaGVpZ2h0ICs9IHNjYWxlZERpbTsKICAgICAgICB9CiAgICAgICAgaWYgKHNjYWxlZERpbSkgewogICAgICAgICAgdGV4dENodW5rLnByZXZUcmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICAgIH0KICAgICAgICBjb25zdCBnbHlwaFVuaWNvZGUgPSBnbHlwaC5ub3JtYWxpemVkVW5pY29kZTsKICAgICAgICBpZiAoc2F2ZUxhc3RDaGFyKGdseXBoVW5pY29kZSkpIHsKICAgICAgICAgIHRleHRDaHVuay5zdHIucHVzaCgiICIpOwogICAgICAgIH0KICAgICAgICB0ZXh0Q2h1bmsuc3RyLnB1c2goZ2x5cGhVbmljb2RlKTsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhcHBlbmRFT0woKSB7CiAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGFzRU9MID0gdHJ1ZTsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgc3RyOiAiIiwKICAgICAgICAgIGRpcjogImx0ciIsCiAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgIGhlaWdodDogMCwKICAgICAgICAgIHRyYW5zZm9ybTogZ2V0Q3VycmVudFRleHRUcmFuc2Zvcm0oKSwKICAgICAgICAgIGZvbnROYW1lOiB0ZXh0U3RhdGUubG9hZGVkTmFtZSwKICAgICAgICAgIGhhc0VPTDogdHJ1ZQogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhZGRGYWtlU3BhY2VzKHdpZHRoLCB0cmFuc2YsIHRleHRPcmllbnRhdGlvbikgewogICAgICBpZiAodGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnNwYWNlSW5GbG93TWluIDw9IHdpZHRoICYmIHdpZHRoIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5zcGFjZUluRmxvd01heCkgewogICAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uc3RyLnB1c2goIiAiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnROYW1lID0gdGV4dENvbnRlbnRJdGVtLmZvbnROYW1lOwogICAgICBsZXQgaGVpZ2h0ID0gMDsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCkgewogICAgICAgIGhlaWdodCA9IHdpZHRoOwogICAgICAgIHdpZHRoID0gMDsKICAgICAgfQogICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICByZXNldExhc3RDaGFycygpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICBzdHI6ICIgIiwKICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgIHdpZHRoOiBNYXRoLmFicyh3aWR0aCksCiAgICAgICAgaGVpZ2h0OiBNYXRoLmFicyhoZWlnaHQpLAogICAgICAgIHRyYW5zZm9ybTogdHJhbnNmIHx8IGdldEN1cnJlbnRUZXh0VHJhbnNmb3JtKCksCiAgICAgICAgZm9udE5hbWUsCiAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICB9KTsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBmdW5jdGlvbiBmbHVzaFRleHRDb250ZW50SXRlbSgpIHsKICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQgfHwgIXRleHRDb250ZW50SXRlbS5zdHIpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0udmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCArPSB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiB0ZXh0Q29udGVudEl0ZW0udGV4dEFkdmFuY2VTY2FsZTsKICAgICAgfSBlbHNlIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0udG90YWxIZWlnaHQgKz0gdGV4dENvbnRlbnRJdGVtLmhlaWdodCAqIHRleHRDb250ZW50SXRl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gpIHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCk7CiAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICByZWplY3QoZXgpOwogICAgICAgICAgfQogICAgICAgIH0sIHJlamVjdCk7CiAgICAgIH07CiAgICAgIHRhc2suZW5zdXJlTm90VGVybWluYXRlZCgpOwogICAgICB0aW1lU2xvdE1hbmFnZXIucmVzZXQoKTsKICAgICAgY29uc3Qgb3BlcmF0aW9uID0ge307CiAgICAgIGxldCBzdG9wLAogICAgICAgIGFyZ3MgPSBbXTsKICAgICAgd2hpbGUgKCEoc3RvcCA9IHRpbWVTbG90TWFuYWdlci5jaGVjaygpKSkgewogICAgICAgIGFyZ3MubGVuZ3RoID0gMDsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IGFyZ3M7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGV4dFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlOwogICAgICAgIGNvbnN0IGZuID0gb3BlcmF0aW9uLmZuOwogICAgICAgIGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgdmFyIGZvbnROYW1lQXJnID0gYXJnc1swXS5uYW1lLAogICAgICAgICAgICAgIGZvbnRTaXplQXJnID0gYXJnc1sxXTsKICAgICAgICAgICAgaWYgKHRleHRTdGF0ZS5mb250ICYmIGZvbnROYW1lQXJnID09PSB0ZXh0U3RhdGUuZm9udE5hbWUgJiYgZm9udFNpemVBcmcgPT09IHRleHRTdGF0ZS5mb250U2l6ZSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS5mb250TmFtZSA9IGZvbnROYW1lQXJnOwogICAgICAgICAgICB0ZXh0U3RhdGUuZm9udFNpemUgPSBmb250U2l6ZUFyZzsKICAgICAgICAgICAgbmV4dChoYW5kbGVTZXRGb250KGZvbnROYW1lQXJnLCBudWxsKSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSaXNlOgogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dFJpc2UgPSBhcmdzWzBdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgdGV4dFN0YXRlLnRleHRIU2NhbGUgPSBhcmdzWzBdIC8gMTAwOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmc6CiAgICAgICAgICAgIHRleHRTdGF0ZS5sZWFkaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmdNb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLmxlYWRpbmcgPSAtYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lOgogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRUZXh0TWF0cml4OgogICAgICAgICAgICB0ZXh0U3RhdGUuc2V0VGV4dE1hdHJpeChhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdLCBhcmdzWzNdLCBhcmdzWzRdLCBhcmdzWzVdKTsKICAgICAgICAgICAgdGV4dFN0YXRlLnNldFRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMl0sIGFyZ3NbM10sIGFyZ3NbNF0sIGFyZ3NbNV0pOwogICAgICAgICAgICB1cGRhdGVBZHZhbmNlU2NhbGUoKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZzoKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRXb3JkU3BhY2luZzoKICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYLnNsaWNlKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBzcGFjZUZhY3RvciA9ICh0ZXh0U3RhdGUuZm9udC52ZXJ0aWNhbCA/IDEgOiAtMSkgKiB0ZXh0U3RhdGUuZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICBjb25zdCBlbGVtZW50cyA9IGFyZ3NbMF07CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGVsZW1lbnRzLmxlbmd0aDsgaSA8IGlpIC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGVsZW1lbnRzW2ldOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0QnVmZmVyLnB1c2goaXRlbSk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gIm51bWJlciIgJiYgaXRlbSAhPT0gMCkgewogICAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IGl0ZW0gKiBzcGFjZUZhY3RvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBlbGVtZW50cy5hdCgtMSk7CiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5wdXNoKGl0ZW0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgc2hvd1NwYWNlZFRleHRCdWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgICAgICBidWlsZFRleHRDb250ZW50SXRlbSh7CiAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgZXh0cmFTcGFjaW5nOiAwCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNhcnJpYWdlUmV0dXJuKCk7CiAgICAgICAgICAgIGJ1aWxkVGV4dENvbnRlbnRJdGVtKHsKICAgICAgICAgICAgICBjaGFyczogYXJnc1syXSwKICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IDAKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRYT2JqZWN0OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoIXhvYmpzKSB7CiAgICAgICAgICAgICAgeG9ianMgPSByZXNvdXJjZXMuZ2V0KCJYT2JqZWN0IikgfHwgX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgdmFyIG5hbWUgPSBhcmdzWzBdLm5hbWU7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkTmFtZSAmJiBlbXB0eVhPYmplY3RDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlWE9iamVjdCwgcmVqZWN0WE9iamVjdCkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxldCB4b2JqID0geG9ianMuZ2V0UmF3KG5hbWUpOwogICAgICAgICAgICAgIGlmICh4b2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHlYT2JqZWN0Q2FjaGUuZ2V0QnlSZWYoeG9iaikpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgZ2xvYmFsSW1hZ2UgPSBzZWxmLmdsb2JhbEltYWdlQ2FjaGUuZ2V0RGF0YSh4b2JqLCBzZWxmLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsSW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgeG9iaiA9IHhyZWYuZmV0Y2goeG9iaik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICghKHhvYmogaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgYmUgYSBzdHJlYW0iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHhvYmouZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICAgICAgICBpZiAoISh0eXBlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgaGF2ZSBhIE5hbWUgc3VidHlwZSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZS5uYW1lICE9PSAiRm9ybSIpIHsKICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgY3VycmVudFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCk7CiAgICAgICAgICAgICAgY29uc3QgeE9ialN0YXRlTWFuYWdlciA9IG5ldyBTdGF0ZU1hbmFnZXIoY3VycmVudFN0YXRlKTsKICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSB4b2JqLmRpY3QuZ2V0QXJyYXkoIk1hdHJpeCIpOwogICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KG1hdHJpeCkgJiYgbWF0cml4Lmxlbmd0aCA9PT0gNikgewogICAgICAgICAgICAgICAgeE9ialN0YXRlTWFuYWdlci50cmFuc2Zvcm0obWF0cml4KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgICAgICAgY29uc3Qgc2lua1dyYXBwZXIgPSB7CiAgICAgICAgICAgICAgICBlbnF1ZXVlSW52b2tlZDogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgIHRoaXMuZW5xdWV1ZUludm9rZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUoY2h1bmssIHNpemUpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGdldCBkZXNpcmVkU2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHNpbmsuZGVzaXJlZFNpemU7CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZ2V0IHJlYWR5KCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gc2luay5yZWFkeTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIHNlbGYuZ2V0VGV4dENvbnRlbnQoewogICAgICAgICAgICAgICAgc3RyZWFtOiB4b2JqLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHJlc291cmNlczogeG9iai5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyOiB4T2JqU3RhdGVNYW5hZ2VyLAogICAgICAgICAgICAgICAgY29tYmluZVRleHRJdGVtcywKICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50LAogICAgICAgICAgICAgICAgc2luazogc2lua1dyYXBwZXIsCiAgICAgICAgICAgICAgICBzZWVuU3R5bGVzLAogICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhCiAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBpZiAoIXNpbmtXcmFwcGVyLmVucXVldWVJbnZva2VkKSB7CiAgICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICB9LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRUZXh0Q29udGVudCAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0R1N0YXRlOgogICAgICAgICAgICBpc1ZhbGlkTmFtZSA9IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lOwogICAgICAgICAgICBuYW1lID0gYXJnc1swXS5uYW1lOwogICAgICAgICAgICBpZiAoaXNWYWxpZE5hbWUgJiYgZW1wdHlHU3RhdGVDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlR1N0YXRlLCByZWplY3RHU3RhdGUpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGV4dEdTdGF0ZSA9IHJlc291cmNlcy5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICAgICAgICAgIGlmICghKGV4dEdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkV4dEdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGUgPSBleHRHU3RhdGUuZ2V0KG5hbWUpOwogICAgICAgICAgICAgIGlmICghKGdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGVGb250ID0gZ1N0YXRlLmdldCgiRm9udCIpOwogICAgICAgICAgICAgIGlmICghZ1N0YXRlRm9udCkgewogICAgICAgICAgICAgICAgZW1wdHlHU3RhdGVDYWNoZS5zZXQobmFtZSwgZ1N0YXRlLm9iaklkLCB0cnVlKTsKICAgICAgICAgICAgICAgIHJlc29sdmVHU3RhdGUoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgICB0ZXh0U3RhdGUuZm9udE5hbWUgPSBudWxsOwogICAgICAgICAgICAgIHRleHRTdGF0ZS5mb250U2l6ZSA9IGdTdGF0ZUZvbnRbMV07CiAgICAgICAgICAgICAgaGFuZGxlU2V0Rm9udChudWxsLCBnU3RhdGVGb250WzBdKS50aGVuKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0VGV4dENvbnRlbnQgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoaW5jbHVkZU1hcmtlZENvbnRlbnQpIHsKICAgICAgICAgICAgICBtYXJrZWRDb250ZW50RGF0YS5sZXZlbCsrOwogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudCIsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIGlmIChpbmNsdWRlTWFya2VkQ29udGVudCkgewogICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhLmxldmVsKys7CiAgICAgICAgICAgICAgbGV0IG1jaWQgPSBudWxsOwogICAgICAgICAgICAgIGlmIChhcmdzWzFdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgbWNpZCA9IGFyZ3NbMV0uZ2V0KCJNQ0lEIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudFByb3BzIiwKICAgICAgICAgICAgICAgIGlkOiBOdW1iZXIuaXNJbnRlZ2VyKG1jaWQpID8gYCR7c2VsZi5pZEZhY3RvcnkuZ2V0UGFnZU9iaklkKCl9X21jaWQke21jaWR9YCA6IG51bGwsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgaWYgKGluY2x1ZGVNYXJrZWRDb250ZW50KSB7CiAgICAgICAgICAgICAgaWYgKG1hcmtlZENvbnRlbnREYXRhLmxldmVsID09PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgbWFya2VkQ29udGVudERhdGEubGV2ZWwtLTsKICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICAgICAgICAgIHR5cGU6ICJlbmRNYXJrZWRDb250ZW50IgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoID49IHNpbmsuZGVzaXJlZFNpemUpIHsKICAgICAgICAgIHN0b3AgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgIGVucXVldWVDaHVuaygpOwogICAgICByZXNvbHZlKCk7CiAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFRleHRDb250ZW50IC0gaWdub3JpbmcgZXJyb3JzIGR1cmluZyAiJHt0YXNrLm5hbWV9IiBgICsgYHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICAgIH0pOwogIH0KICBleHRyYWN0RGF0YVN0cnVjdHVyZXMoZGljdCwgYmFzZURpY3QsIHByb3BlcnRpZXMpI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HJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgZGlmZmVyZW5jZXNbaW5kZXgrK10gPSBkYXRhLm5hbWU7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkIGVudHJ5IGluICdEaWZmZXJlbmNlcycgYXJyYXk6ICR7ZGF0YX1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChlbmNvZGluZyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICBiYXNlRW5jb2RpbmdOYW1lID0gZW5jb2RpbmcubmFtZTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBtc2cgPSAiRW5jb2RpbmcgaXMgbm90IGEgTmFtZSBub3IgYSBEaWN0IjsKICAgICAgICBpZiAoIXRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihtc2cpOwogICAgICAgIH0KICAgICAgICAoMCwgX3V0aWwud2FybikobXNnKTsKICAgICAgfQogICAgICBpZiAoYmFzZUVuY29kaW5nTmFtZSAhPT0gIk1hY1JvbWFuRW5jb2RpbmciICYmIGJhc2VFbmNvZGluZ05hbWUgIT09ICJNYWNFeHBlcnRFbmNvZGluZyIgJiYgYmFzZUVuY29kaW5nTmFtZSAhPT0gIldpbkFuc2lFbmNvZGluZyIpIHsKICAgICAgICBiYXNlRW5jb2RpbmdOYW1lID0gbnVsbDsKICAgICAgfQogICAgfQogICAgaWYgKGJhc2VFbmNvZGluZ05hbWUpIHsKICAgICAgcHJvcGVydGllcy5kZWZhdWx0RW5jb2RpbmcgPSAoMCwgX2VuY29kaW5ncy5nZXRFbmNvZGluZykoYmFzZUVuY29kaW5nTmFtZSk7CiAgICB9IGVsc2UgewogICAgICBjb25zdCBpc1N5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hazsKICAgICAgICBjYXNlICJnIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSA1KSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJDIjoKICAgICAgICBjYXNlICJjIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID49IDMgJiYgZ2x5cGhOYW1lLmxlbmd0aCA8PSA0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGVTdHIgPSBnbHlwaE5hbWUuc3Vic3RyaW5nKDEpOwogICAgICAgICAgICBpZiAoZm9yY2VHbHlwaHMpIHsKICAgICAgICAgICAgICBjb2RlID0gcGFyc2VJbnQoY29kZVN0ciwgMTYpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvZGUgPSArY29kZVN0cjsKICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihjb2RlKSAmJiBOdW1iZXIuaXNJbnRlZ2VyKHBhcnNlSW50KGNvZGVTdHIsIDE2KSkpIHsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc2ltcGxlRm9udFRvVW5pY29kZShwcm9wZXJ0aWVzLCB0cnVlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidSI6CiAgICAgICAgICB1bmljb2RlID0gKDAsIF91bmljb2RlLmdldFVuaWNvZGVGb3JHbHlwaCkoZ2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGlmICh1bmljb2RlICE9PSAtMSkgewogICAgICAgICAgICBjb2RlID0gdW5pY29kZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzd2l0Y2ggKGdseXBoTmFtZSkgewogICAgICAgICAgICBjYXNlICJmX2giOgogICAgICAgICAgICBjYXNlICJmX3QiOgogICAgICAgICAgICBjYXNlICJUX2giOgogICAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBnbHlwaE5hbWUucmVwbGFjZUFsbCgiXyIsICIiKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChjb2RlID4gMCAmJiBjb2RlIDw9IDB4MTBmZmZmICYmIE51bWJlci5pc0ludGVnZXIoY29kZSkpIHsKICAgICAgICBpZiAoYmFzZUVuY29kaW5nTmFtZSAmJiBjb2RlID09PSArY2hhcmNvZGUpIHsKICAgICAgICAgIGNvbnN0IGJhc2VFbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShiYXNlRW5jb2RpbmdOYW1lKTsKICAgICAgICAgIGlmIChiYXNlRW5jb2RpbmcgJiYgKGdseXBoTmFtZSA9IGJhc2VFbmNvZGluZ1tjaGFyY29kZV0pKSB7CiAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGdseXBoc1VuaWNvZGVNYXBbZ2x5cGhOYW1lXSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0b1VuaWNvZGVbY2hhcmNvZGVdID0gU3RyaW5nLmZyb21Db2RlUG9pbnQoY29kZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0b1VuaWNvZGU7CiAgfQogIGFzeW5jIGJ1aWxkVG9Vbmljb2RlKHByb3BlcnRpZXMpIHsKICAgIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgPSAhIXByb3BlcnRpZXMudG9Vbmljb2RlICYmIHByb3BlcnRpZXMudG9Vbmljb2RlLmxlbmd0aCA+IDA7CiAgICBpZiAocHJvcGVydGllcy5o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BpZiAoY21hcCBpbnN0YW5jZW9mIF9jbWFwLklkZW50aXR5Q01hcCkgewogICAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuSWRlbnRpdHlUb1VuaWNvZGVNYXAoMCwgMHhmZmZmKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgbWFwID0gbmV3IEFycmF5KGNtYXAubGVuZ3RoKTsKICAgICAgICBjbWFwLmZvckVhY2goZnVuY3Rpb24gKGNoYXJDb2RlLCB0b2tlbikgewogICAgICAgICAgaWYgKHR5cGVvZiB0b2tlbiA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KHRva2VuKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RyID0gW107CiAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IHRva2VuLmxlbmd0aDsgayArPSAyKSB7CiAgICAgICAgICAgIGNvbnN0IHcxID0gdG9rZW4uY2hhckNvZGVBdChrKSA8PCA4IHwgdG9rZW4uY2hhckNvZGVBdChrICsgMSk7CiAgICAgICAgICAgIGlmICgodzEgJiAweGY4MDApICE9PSAweGQ4MDApIHsKICAgICAgICAgICAgICBzdHIucHVzaCh3MSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgayArPSAyOwogICAgICAgICAgICBjb25zdCB3MiA9IHRva2VuLmNoYXJDb2RlQXQoaykgPDwgOCB8IHRva2VuLmNoYXJDb2RlQXQoayArIDEpOwogICAgICAgICAgICBzdHIucHVzaCgoKHcxICYgMHgzZmYpIDw8IDEwKSArICh3MiAmIDB4M2ZmKSArIDB4MTAwMDApOwogICAgICAgICAgfQogICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KC4uLnN0cik7CiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuVG9Vbmljb2RlTWFwKG1hcCk7CiAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgcmVhZFRvVW5pY29kZSAtIGlnbm9yaW5nIFRvVW5pY29kZSBkYXRhOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgICB0aHJvdyByZWFzb247CiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShudWxsKTsKICB9CiAgcmVhZENpZFRvR2lkTWFwKGdseXBoc0RhdGEsIHRvVW5pY29kZSkgewogICAgY29uc3QgcmVzdWx0ID0gW107CiAgICBmb3IgKGxldCBqID0gMCwgamogPSBnbHlwaHNEYXRhLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgZ2x5cGhJRCA9IGdseXBoc0RhdGFbaisrXSA8PCA4IHwgZ2x5cGhzRGF0YVtqXTsKICAgICAgY29uc3QgY29kZSA9IGogPj4gMTsKICAgICAgaWYgKGdseXBoSUQgPT09IDAgJiYgIXRvVW5pY29kZS5oYXMoY29kZSkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByZXN1bHRbY29kZV0gPSBnbHlwaElEOwogICAgfQogICAgcmV0dXJuIHJlc3VsdDsKICB9CiAgZXh0cmFjdFdpZHRocyhkaWN0LCBkZXNjcmlwdG9yLCBwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGdseXBoc1dpZHRocyA9IFtdOwogICAgbGV0IGRlZmF1bHRXaWR0aCA9IDA7CiAgICBjb25zdCBnbHlwaHNWTWV0cmljcyA9IFtdOwogICAgbGV0IGRlZmF1bHRWTWV0cmljczsKICAgIGxldCBpLCBpaSwgaiwgamosIHN0YXJ0LCBjb2RlLCB3aWR0aHM7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgZGVmYXVsdFdpZHRoID0gZGljdC5oYXMoIkRXIikgPyBkaWN0LmdldCgiRFciKSA6IDEwMDA7CiAgICAgIHdpZHRocyA9IGRpY3QuZ2V0KCJXIik7CiAgICAgIGlmICh3aWR0aHMpIHsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBzdGFydCA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaSsrXSk7CiAgICAgICAgICBjb2RlID0geHJlZi5mZXRjaElmUmVmKHdpZHRoc1tpXSk7CiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGUubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgICAgIGdseXBoc1dpZHRoc1tzdGFydCsrXSA9IHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3Qgd2lkdGggPSB4cmVmLmZldGNoSWZSZWYod2lkdGhzWysraV0pOwogICAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBjb2RlOyBqKyspIHsKICAgICAgICAgICAgICBnbHlwaHNXaWR0aHNbal0gPSB3aWR0aDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocHJvcGVydGllcy52ZXJ0aWNhbCkgewogICAgICAgIGxldCB2bWV0cmljcyA9IGRpY3QuZ2V0QXJyYXkoIkRXMiIpIHx8IFs4ODAsIC0xMDAwXTsKICAgICAgICBkZWZhdWx0Vk1ldHJpY3MgPSBbdm1ldHJpY3NbMV0sIGRlZmF1bHRXaWR0aCAqIDAuNSwgdm1ldHJpY3NbMF1dOwogICAgICAgIHZtZXRyaWNzID0gZGljdC5nZXQoIlcyIik7CiAgICAgICAgaWYgKHZtZXRyaWNzKSB7CiAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHZtZXRyaWNzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgc3RhcnQgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaSsrXSk7CiAgICAgICAgICAgIGNvZGUgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaV0pOwogICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICAgIGZvciAoaiA9IDAsIGpqID0gY29kZS5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tzdGFydCsrXSA9IFt4cmVmLmZldGNoSWZSZWYoY29kZVtqKytdKSwgeHJlZi5mZXRjaElmUmVmKGNvZGVbaisrXSksIHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBbeHJlZi5mZXRjaElmUmVmKHZtZXRyaWNzWysraV0pLCB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbKytpXSksIHhyZWYuZmV0Y2hJZlJlZih2bWV0cmljc1srK2ldKV07CiAgICAgICAgICAgICAgZm9yIChqID0gc3RhcnQ7IGogPD0gY29kZTsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tqXSA9IHZtZXRyaWM7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB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WYpIHsKICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goZW50cnkudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGhhc2gudXBkYXRlKHdpZHRoc0J1Zi5qb2luKCkpOwogICAgICB9CiAgICAgIGlmIChjb21wb3NpdGUpIHsKICAgICAgICBoYXNoLnVwZGF0ZSgiY29tcG9zaXRlRm9udCIpOwogICAgICAgIGNvbnN0IGNvbXBvc2l0ZVdpZHRocyA9IGRpY3QuZ2V0KCJXIikgfHwgYmFzZURpY3QuZ2V0KCJXIik7CiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoY29tcG9zaXRlV2lkdGhzKSkgewogICAgICAgICAgY29uc3Qgd2lkdGhzQnVmID0gW107CiAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGNvbXBvc2l0ZVdpZHRocykgewogICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAibnVtYmVyIiB8fCBlbnRyeSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHdpZHRoc0J1Zi5wdXNoKGVudHJ5LnRvU3RyaW5nKCkpOwogICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoZW50cnkpKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3ViV2lkdGhzQnVmID0gW107CiAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIGVudHJ5KSB7CiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVsZW1lbnQgPT09ICJudW1iZXIiIHx8IGVsZW1lbnQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICAgICAgc3ViV2lkdGhzQnVmLnB1c2goZWxlbWVudC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goYFske3N1YldpZHRoc0J1Zi5qb2luKCl9XWApOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoLnVwZGF0ZSh3aWR0aHNCdWYuam9pbigpKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgY2lkVG9HaWRNYXAgPSBkaWN0LmdldFJhdygiQ0lEVG9HSURNYXAiKSB8fCBiYXNlRGljdC5nZXRSYXcoIkNJRFRvR0lETWFwIik7CiAgICAgICAgaWYgKGNpZFRvR2lkTWFwIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAubmFtZSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAudG9TdHJpbmcoKSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICBoYXNoLnVwZGF0ZShjaWRUb0dpZE1hcC5wZWVrQnl0ZXMoKSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBkZXNjcmlwdG9yLAogICAgICBkaWN0LAogICAgICBiYXNlRGljdCwKICAgICAgY29tcG9zaXRlLAogICAgICB0eXBlOiB0eXBlLm5hbWUsCiAgICAgIGZpcnN0Q2hhciwKICAgICAgbGFzdENoYXIsCiAgICAgIHRvVW5pY29kZSwKICAgICAgaGFzaDogaGFzaCA/IGhhc2guaGV4ZGlnZXN0KCkgOiAiIgogICAgfTsKICB9CiAgYXN5bmMgdHJhbnNsYXRlRm9udChfcmVmOSkgewogICAgbGV0IHsKICAgICAgZGVzY3JpcHRvciwKICAgICAgZGljdCwKICAgICAgYmFzZURpY3QsCiAgICAgIGNvbXBvc2l0ZSwKICAgICAgdHlwZSwK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dXRpbHMuRm9udEZsYWdzLlNlcmlmIDogMCkgfCAobWV0cmljcy5tb25vc3BhY2UgPyBfZm9udHNfdXRpbHMuRm9udEZsYWdzLkZpeGVkUGl0Y2ggOiAwKSB8ICgoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN5bWJvbHNGb250cykoKVtmb250TmFtZVdvU3R5bGVdID8gX2ZvbnRzX3V0aWxzLkZvbnRGbGFncy5TeW1ib2xpYyA6IF9mb250c191dGlscy5Gb250RmxhZ3MuTm9uc3ltYm9saWMpOwogICAgICAgIHByb3BlcnRpZXMgPSB7CiAgICAgICAgICB0eXBlLAogICAgICAgICAgbmFtZTogYmFzZUZvbnROYW1lLAogICAgICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgICAgIHdpZHRoczogbWV0cmljcy53aWR0aHMsCiAgICAgICAgICBkZWZhdWx0V2lkdGg6IG1ldHJpY3MuZGVmYXVsdFdpZHRoLAogICAgICAgICAgaXNTaW11bGF0ZWRGbGFnczogdHJ1ZSwKICAgICAgICAgIGZsYWdzLAogICAgICAgICAgZmlyc3RDaGFyLAogICAgICAgICAgbGFzdENoYXIsCiAgICAgICAgICB0b1VuaWNvZGUsCiAgICAgICAgICB4SGVpZ2h0OiAwLAogICAgICAgICAgY2FwSGVpZ2h0OiAwLAogICAgICAgICAgaXRhbGljQW5nbGU6IDAsCiAgICAgICAgICBpc1R5cGUzRm9udAogICAgICAgIH07CiAgICAgICAgY29uc3Qgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGJhc2VGb250TmFtZSk7CiAgICAgICAgbGV0IGZpbGUgPSBudWxsOwogICAgICAgIGlmIChzdGFuZGFyZEZvbnROYW1lKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLmlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICAgIGZpbGUgPSBhd2FpdCB0aGlzLmZldGNoU3RhbmRhcmRGb250RGF0YShzdGFuZGFyZEZvbnROYW1lKTsKICAgICAgICAgIHByb3BlcnRpZXMuaXNJbnRlcm5hbEZvbnQgPSAhIWZpbGU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLmV4dHJhY3REYXRhU3RydWN0dXJlcyhkaWN0LCBkaWN0LCBwcm9wZXJ0aWVzKS50aGVuKG5ld1Byb3BlcnRpZXMgPT4gewogICAgICAgICAgaWYgKHdpZHRocykgewogICAgICAgICAgICBjb25zdCBnbHlwaFdpZHRocyA9IFtdOwogICAgICAgICAgICBsZXQgaiA9IGZpcnN0Q2hhcjsKICAgICAgICAgICAgZm9yIChjb25zdCB3aWR0aCBvZiB3aWR0aHMpIHsKICAgICAgICAgICAgICBnbHlwaFdpZHRoc1tqKytdID0gdGhpcy54cmVmLmZldGNoSWZSZWYod2lkdGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5ld1Byb3BlcnRpZXMud2lkdGhzID0gZ2x5cGhXaWR0aHM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBuZXdQcm9wZXJ0aWVzLndpZHRocyA9IHRoaXMuYnVpbGRDaGFyQ29kZVRvV2lkdGgobWV0cmljcy53aWR0aHMsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBfZm9udHMuRm9udChiYXNlRm9udE5hbWUsIGZpbGUsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBsZXQgZm9udE5hbWUgPSBkZXNjcmlwdG9yLmdldCgiRm9udE5hbWUiKTsKICAgIGxldCBiYXNlRm9udCA9IGRpY3QuZ2V0KCJCYXNlRm9udCIpOwogICAgaWYgKHR5cGVvZiBmb250TmFtZSA9PT0gInN0cmluZyIpIHsKICAgICAgZm9udE5hbWUgPSBfc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ICJGb250RmlsZTIiLCAiRm9udEZpbGUzIik7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoIXRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYHRyYW5zbGF0ZUZvbnQgLSBmZXRjaGluZyAiJHtmb250TmFtZS5uYW1lfSIgZm9udCBmaWxlOiAiJHtleH0iLmApOwogICAgICBmb250RmlsZSA9IG5ldyBfc3RyZWFtLk51bGxTdHJlYW0oKTsKICAgIH0KICAgIGxldCBpc1N0YW5kYXJkRm9udCA9IGZhbHNlOwogICAgbGV0IGlzSW50ZXJuYWxGb250ID0gZmFsc2U7CiAgICBsZXQgZ2x5cGhTY2FsZUZhY3RvcnMgPSBudWxsOwogICAgaWYgKGZvbnRGaWxlKSB7CiAgICAgIGlmIChmb250RmlsZS5kaWN0KSB7CiAgICAgICAgY29uc3Qgc3VidHlwZUVudHJ5ID0gZm9udEZpbGUuZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICBpZiAoc3VidHlwZUVudHJ5IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgc3VidHlwZSA9IHN1YnR5cGVFbnRyeS5uYW1lOwogICAgICAgIH0KICAgICAgICBsZW5ndGgxID0gZm9udEZpbGUuZGljdC5nZXQoIkxlbmd0aDEiKTsKICAgICAgICBsZW5ndGgyID0gZm9udEZpbGUuZGljdC5nZXQoIkxlbmd0aDIiKTsKICAgICAgICBsZW5ndGgzID0gZm9udEZpbGUuZGljdC5nZXQoIkxlbmd0aDMiKTsKICAgICAgfQogICAgfSBlbHNlIGlmIChjc3NGb250SW5mbykgewogICAgICBjb25zdCBzdGFuZGFyZEZvbnROYW1lID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udE5hbWUpKGZvbnROYW1lLm5hbWUpOwogICAgICBpZiAoc3RhbmRhcmRGb250TmFtZSkgew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wogICAgY29uc3QgY2hhclByb2NzID0gdGhpcy5kaWN0LmdldCgiQ2hhclByb2NzIik7CiAgICBjb25zdCBmb250UmVzb3VyY2VzID0gdGhpcy5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzOwogICAgY29uc3QgY2hhclByb2NPcGVyYXRvckxpc3QgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgY29uc3QgZm9udEJCb3ggPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QodHJhbnNsYXRlZEZvbnQuYmJveCB8fCBbMCwgMCwgMCwgMF0pLAogICAgICB3aWR0aCA9IGZvbnRCQm94WzJdIC0gZm9udEJCb3hbMF0sCiAgICAgIGhlaWdodCA9IGZvbnRCQm94WzNdIC0gZm9udEJCb3hbMV07CiAgICBjb25zdCBmb250QkJveFNpemUgPSBNYXRoLmh5cG90KHdpZHRoLCBoZWlnaHQpOwogICAgZm9yIChjb25zdCBrZXkgb2YgY2hhclByb2NzLmdldEtleXMoKSkgewogICAgICBsb2FkQ2hhclByb2NzUHJvbWlzZSA9IGxvYWRDaGFyUHJvY3NQcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgIGNvbnN0IGdseXBoU3RyZWFtID0gY2hhclByb2NzLmdldChrZXkpOwogICAgICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgICAgICByZXR1cm4gdHlwZTNFdmFsdWF0b3IuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIHN0cmVhbTogZ2x5cGhTdHJlYW0sCiAgICAgICAgICB0YXNrLAogICAgICAgICAgcmVzb3VyY2VzOiBmb250UmVzb3VyY2VzLAogICAgICAgICAgb3BlcmF0b3JMaXN0CiAgICAgICAgfSkudGhlbigoKSA9PiB7CiAgICAgICAgICBpZiAob3BlcmF0b3JMaXN0LmZuQXJyYXlbMF0gPT09IF91dGlsLk9QUy5zZXRD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AgIG9wZXJhdG9yTGlzdC5mbkFycmF5LnNwbGljZShpLCAxKTsKICAgICAgICAgIG9wZXJhdG9yTGlzdC5hcmdzQXJyYXkuc3BsaWNlKGksIDEpOwogICAgICAgICAgaWktLTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgIGNvbnN0IFtnU3RhdGVPYmpdID0gb3BlcmF0b3JMaXN0LmFyZ3NBcnJheVtpXTsKICAgICAgICAgIGxldCBqID0gMCwKICAgICAgICAgICAgamogPSBnU3RhdGVPYmoubGVuZ3RoOwogICAgICAgICAgd2hpbGUgKGogPCBqaikgewogICAgICAgICAgICBjb25zdCBbZ1N0YXRlS2V5XSA9IGdTdGF0ZU9ialtqXTsKICAgICAgICAgICAgc3dpdGNoIChnU3RhdGVLZXkpIHsKICAgICAgICAgICAgICBjYXNlICJUUiI6CiAgICAgICAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgICAgICAgY2FzZSAiQkciOgogICAgICAgICAgICAgIGNhc2UgIkJHMiI6CiAgICAgICAgICAgICAgY2FzZSAiVUNSIjoKICAgICAgICAgICAgICBjYXNlICJVQ1IyIjoKICAgICAgICAgICAgICAgIGdTdGF0ZU9iai5zcGxpY2UoaiwgMSk7CiAgICAgICAgICAgICAgICBqai0tOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaisrOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaSsrOwogICAgfQogIH0KfQpjbGFzcyBTdGF0ZU1hbmFnZXIgewogIGNvbnN0cnVjdG9yKCkgewogICAgbGV0IGluaXRpYWxTdGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IEV2YWxTd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QXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuaiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldExpbmVKb2luLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0Lk0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRNaXRlckxpbWl0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXREYXNoLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJpID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0UmVuZGVyaW5nSW50ZW50LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGbGF0bmVzcywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5ncyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEdTdGF0ZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5xID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2F2ZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5RID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVzdG9yZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5jbSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnRyYW5zZm9ybSwKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5tID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRvLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmwgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5saW5lVG8sCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuYyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8sCiAgICAgICAgbnVtQXJnczogNiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQudiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jdXJ2ZVRvMywKICAgICAgICBudW1BcmdzOiA0LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5oID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xvc2VQYXRoLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJlID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVjdGFuZ2xlLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQucyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmNsb3NlU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJmKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJCKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUZpbGxTdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHRbImIqIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5uID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW5kUGF0aCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5XID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdFsiVyoiXSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVvQ2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luVGV4dCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVuZFRleHQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UdyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFdvcmRTcGFjaW5nLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlR6ID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0SFNjYWxlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRMID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0TGVhZGluZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UZiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZvbnQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVHIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0UmVuZGVyaW5nTW9kZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UcyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFRleHRSaXNlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRkID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVEQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVG0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0TWF0cml4LAogICAgICAgIG51bUFyZ3M6IDYsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJUKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubmV4dExpbmUsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGogPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5USiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyInIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyciJ10gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aCwKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aEFuZEJvdW5kcywKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5DUyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yU3BhY2UsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuY3MgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ29sb3JTcGFjZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5TQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuU0NOID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JOLAogICAgICAgIG51bUFyZ3M6IDMzLAogICAgICAgIHZhcmlhYmxlQXJnczogdHJ1ZQogICAgICB9OwogICAgICB0LnNjID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuc2NuID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yTiwKICAgICAgICBudW1BcmdzOiAzMywKICAgICAgICB2YXJpYWJsZUFyZ3M6IHRydWUKICAgICAgfTsKICAgICAgdC5HID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlR3JheSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5nID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbEdyYXksCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuUkcgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5yZyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5LID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmsgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnNoID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2hhZGluZ0ZpbGwsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQkkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbklubGluZUltYWdlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LklEID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5JbWFnZURhdGEsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRUkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRJbmxpbmVJbWFnZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EbyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnBhaW50WE9iamVjdCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5NUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludFByb3BzLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJNQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CREMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FTUMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRNYXJrZWRDb250ZW50LAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJYID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5Db21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRVggPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRDb21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQk0gPSBudWxsOwogICAgICB0LkJEID0gbnVsbDsKICAgICAgdC50cnVlID0gbnVsbDsKICAgICAgdC5mYSA9IG51bGw7CiAgICAgIHQuZmFsID0gbnV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AodHJ1ZSkgewogICAgICBjb25zdCBvYmogPSB0aGlzLnBhcnNlci5nZXRPYmooKTsKICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkNtZCkgewogICAgICAgIGNvbnN0IGNtZCA9IG9iai5jbWQ7CiAgICAgICAgY29uc3Qgb3BTcGVjID0gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLm9wTWFwW2NtZF07CiAgICAgICAgaWYgKCFvcFNwZWMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBjb21tYW5kICIke2NtZH0iLmApOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGZuID0gb3BTcGVjLmlkOwogICAgICAgIGNvbnN0IG51bUFyZ3MgPSBvcFNwZWMubnVtQXJnczsKICAgICAgICBsZXQgYXJnc0xlbmd0aCA9IGFyZ3MgIT09IG51bGwgPyBhcmdzLmxlbmd0aCA6IDA7CiAgICAgICAgaWYgKCF0aGlzLl9pc1BhdGhPcCkgewogICAgICAgICAgdGhpcy5fbnVtSW52YWxpZFBhdGhPUFMgPSAwOwogICAgICAgIH0KICAgICAgICB0aGlzLl9pc1BhdGhPcCA9IGZuID49IF91dGlsLk9QUy5tb3ZlVG8gJiYgZm4gPD0gX3V0aWwuT1BTLmVuZFBhdGg7CiAgICAgICAgaWYgKCFvcFNwZWMudmFyaWFibGVBcmdzKSB7CiAgICAgICAgICBpZiAoYXJnc0xlbmd0aCAhPT0gbnVtQXJncykgewogICAgICAgICAgICBjb25zdCBub25Qcm9jZXNzZWRBcmdzID0gdGhpcy5ub25Qcm9jZXNzZWRBcmdzOwogICAgICAgICAgICB3aGlsZSAoYXJnc0xlbmd0aCA+IG51bUFyZ3MpIHsKICAgICAgICAgICAgICBub25Qcm9jZXNzZWRBcmdzLnB1c2goYXJncy5zaGlmdCgpKTsKICAgICAgICAgICAgICBhcmdzTGVuZ3RoLS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKGFyZ3NMZW5ndGggPCBudW1BcmdzICYmIG5vblByb2Nlc3NlZEFyZ3MubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYXJncy51bnNoaWZ0KG5vblByb2Nlc3NlZEFyZ3MucG9wKCkpOwogICAgICAgICAgICAgIGFyZ3NMZW5ndGgrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGFyZ3NMZW5ndGggPCBudW1BcmdzKSB7CiAgICAgICAgICAgIGNvbnN0IHBhcnRpYWxNc2cgPSBgY29tbWFuZCAke2NtZH06IGV4cGVjdGVkICR7bnVtQXJnc30gYXJncywgYCArIGBidXQgcmVjZWl2ZWQgJHthcmdzTGVuZ3RofSBhcmdzLmA7CiAgICAgICAgICAgIGlmICh0aGlzLl9pc1BhdGhPcCAmJiArK3RoaXMuX251bUludmFsaWRQYXRoT1BTID4gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLk1BWF9JTlZBTElEX1BBVEhfT1BTKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFNraXBwaW5nICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgaWYgKGFyZ3MgIT09IG51bGwpIHsKICAgICAgICAgICAgICBhcmdzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChhcmdzTGVuZ3RoID4gbnVtQXJncykgewogICAgICAgICAgKDAsIF91dGlsLmluZm8pKGBDb21tYW5kICR7Y21kfTogZXhwZWN0ZWQgWzAsICR7bnVtQXJnc31dIGFyZ3MsIGAgKyBgYnV0IHJlY2VpdmVkICR7YXJnc0xlbmd0aH0gYXJncy5gKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5wcmVwcm9jZXNzQ29tbWFuZChmbiwgYXJncyk7CiAgICAgICAgb3BlcmF0aW9uLmZuID0gZm47CiAgICAgICAgb3BlcmF0aW9uLmFyZ3MgPSBhcmdzOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAob2JqICE9PSBudWxsKSB7CiAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICB9CiAgICAgICAgYXJncy5wdXNoKG9iaik7CiAgICAgICAgaWYgKGFyZ3MubGVuZ3RoID4gMzMpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVG9vIG1hbnkgYXJndW1lbnRzIik7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfQogIHByZXByb2Nlc3NDb21tYW5kKGZuLCBhcmdzKSB7CiAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICBjYXNlIF91dGlsLk9QUy5zYXZlOgogICAgICAgIHRoaXMuc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBfdXRpbC5PUFMucmVzdG9yZToKICAgICAgICB0aGlzLnN0YXRlTWFuYWdlci5yZXN0b3JlKCk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgX3V0aWwuT1BTLnRyYW5zZm9ybToKICAgICAgICB0aGlzLnN0YXRlTWFuYWdlci50cmFuc2Zvcm0oYXJncyk7CiAgICAgICAgYnJlYWs7CiAgICB9CiAgfQp9CmV4cG9ydHMuRXZhbHVhdG9yUHJlcHJvY2Vzc29yID0gRXZhbHVhdG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RhdGEubGVuZ3RoOwogICAgICB0aGlzLnRtcEJ1ZiA9IG5ldyBVaW50OEFycmF5KE1BWF9FTkNPREVEX05VTV9TSVpFKTsKICAgIH0KICAgIHJlYWRCeXRlKCkgewogICAgICBpZiAodGhpcy5wb3MgPj0gdGhpcy5lbmQpIHsKICAgICAgICByZXR1cm4gLTE7CiAgICAgIH0KICAgICAgcmV0dXJuIHRoaXMuYnVmZmVyW3RoaXMucG9zKytdOwogICAgfQogICAgcmVhZE51bWJlcigpIHsKICAgICAgbGV0IG4gPSAwOwogICAgICBsZXQgbGFzdDsKICAgICAgZG8gewogICAgICAgIGNvbnN0IGIgPSB0aGlzLnJlYWRCeXRlKCk7CiAgICAgICAgaWYgKGIgPCAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoInVuZXhwZWN0ZWQgRU9GIGluIGJjbWFwIik7CiAgICAgICAgfQogICAgICAgIGxhc3QgPSAhKGIgJiAweDgwKTsKICAgICAgICBuID0gbiA8PCA3IHwgYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZWFkU2lnbmVkKCkgewogICAgICBjb25zdCBuID0gdGhpcy5yZWFkTnVtYmVyKCk7CiAgICAgIHJldHVybiBuICYgMSA/IH4obiA+Pj4gMSkgOiBuID4+PiAxOwogICAgfQogICAgcmVhZEhleChudW0sIHNpemUpIHsKICAgICAgbnVtLnNldCh0aGlzLmJ1ZmZlci5zdWJhcnJheSh0aGlzLnBvcywgdGhpcy5wb3MgKyBzaXplICsgMSkpOwogICAgICB0aGlzLnBvcyArPSBzaXplICsgMTsKICAgIH0KICAgIHJlYWRIZXhOdW1iZXIobnVtLCBzaXplKSB7CiAgICAgIGxldCBsYXN0OwogICAgICBjb25zdCBzdGFjayA9IHRoaXMudG1wQnVmOwogICAgICBsZXQgc3AgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgYiA9IHRoaXMucmVhZEJ5dGUoKTsKICAgICAgICBpZiAoYiA8IDApIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigidW5leHBlY3RlZCBFT0YgaW4gYmNtYXAiKTsKICAgICAgICB9CiAgICAgICAgbGFzdCA9ICEoYiAmIDB4ODApOwogICAgICAgIHN0YWNrW3NwKytdID0gYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgbGV0IGkgPSBzaXplLAogICAgICAgIGJ1ZmZlciA9IDAsCiAgICAgICAgYnVmZmVyU2l6ZSA9IDA7CiAgICAgIHdoaWxlIChpID49IDApIHsKICAgICAgICB3aGlsZSAoYnVmZmVyU2l6ZSA8IDggJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgYnVmZmVyIHw9IHN0YWNrWy0tc3BdIDw8IGJ1ZmZlclNpemU7CiAgICAgICAgICBidWZmZXJTaXplICs9IDc7CiAgICAgICAgfQogICAgICAgIG51bVtpXSA9IGJ1ZmZlciAmIDI1NTsKICAgICAgICBpLS07CiAgICAgICAgYnVmZmVyID4+PSA4OwogICAgICAgIGJ1ZmZlclNpemUgLT0gODsKICAgICAgfQogICAgfQogICAgcmVhZEhleFNpZ25lZChudW0sIHNpemUpIHsKICAgICAgdGhpcy5yZWFkSGV4TnVtYmVyKG51bSwgc2l6ZSk7CiAgICAgIGNvbnN0IHNpZ24gPSBudW1bc2l6ZV0gJiAxID8gMjU1IDogMDsKICAgICAgbGV0IGMgPSAwOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBzaXplOyBpKyspIHsKICAgICAgICBjID0gKGMgJiAxKSA8PCA4IHwgbnVtW2ldOwogICAgICAgIG51bVtpXSA9IGMgPj4gMSBeIHNpZ247CiAgICAgIH0KICAgIH0KICAgIHJlYWRTdHJpbmcoKSB7CiAgICAgIGNvbnN0IGxlbiA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICBsZXQgcyA9ICIiOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHRoaXMucmVhZE51bWJlcigpKTsKICAgICAgfQogICAgICByZXR1cm4gczsKICAgIH0KICB9CiAgY2xhc3MgQmluYXJ5Q01hcFJlYWRlciB7CiAgICBhc3luYyBwcm9jZXNzKGRhdGEsIGNNYXAsIGV4dGVuZCkgewogICAgICBjb25zdCBzdHJlYW0gPSBuZXcgQmluYXJ5Q01hcFN0cmVhbShkYXRhKTsKICAgICAgY29uc3QgaGVhZGVyID0gc3RyZWFtLnJlYWRCeXRlKCk7CiAgICAgIGNNYXAudmVydGljYWwgPSAhIShoZWFkZXIgJiAxKTsKICAgICAgbGV0IHVzZUNNYXAgPSBudWxsOwogICAgICBjb25zdCBzdGFydCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGVuZCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGNoYXIgPSBuZXcgVWludDhBcnJheShNQVhfTlVNX1NJWkUpOwogICAgICBjb25zdCBjaGFyQ29kZSA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IHRtcCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGxldCBjb2RlOwogICAgICBsZXQgYjsKICAgICAgd2hpbGUgKChiID0gc3RyZWFtLnJlYWRCeXRlKCkpID49IDApIHsKICAgICAgICBjb25zdCB0eXBlID0gYiA+PiA1OwogICAgICAgIGlmICh0eXBlID09PSA3KSB7CiAgICAgICAgICBzd2l0Y2ggKGIgJiAweDFmKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBzdHJlYW0ucmVhZFN0cmluZygpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgdXNlQ01hcCA9IHN0cmVhbS5yZWFkU3RyaW5nKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc2VxdWVuY2UgPSAhIShiICYgMHgxMCk7CiAgICAgICAgY29uc3QgZGF0YVNpemUgPSBiICYgMTU7CiAgICAgICAgaWYgKGRhdGFTaXplICsgMSA+IE1BWF9OVU1fU0laRSkgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJCaW5hcnlDTWFwUmVhZGVyLnByb2Nlc3M6IEludmFsaWQgZGF0YVNpemUuIik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHVjczJEYXRhU2l6ZSA9IDE7CiAgICAgICAgY29uc3Qgc3ViaXRlbXNDb3VudCA9IHN0cmVhbS5yZWFkTnVtYmVyKCk7CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4KHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGlmICghc2VxdWVuY2UpIHsKICAgICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgICAgYWRkSGV4KGNoYXIsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWRTaWduZWQoKSArIChjb2RlICsgMSk7CiAgICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICBjTWFwLm1hcENpZFJhbmdlKGhleFRvSW50KHN0YXJ0LCBkYXRhU2l6ZSksIGhleFRvSW50KGVuZCwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHN0YXJ0LnNldChlbmQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICAgIGNNYXAubWFwQ2lkUmFuZ2UoaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSksIGNvZGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLm1hcE9uZShoZXhUb0ludChjaGFyLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBpZiAoIXNlcXVlbmNlKSB7CiAgICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcih0bXAsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoY2hhciwgdG1wLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpbmNIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleFNpZ25lZCh0bXAsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoY2hhckNvZGUsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwT25lKGhleFRvSW50KGNoYXIsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA1OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgY01hcC5tYXBCZlJhbmdlKGhleFRvSW50KHN0YXJ0LCB1Y3MyRGF0YVNpemUpLCBoZXhUb0ludChlbmQsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgc3RhcnQuc2V0KGVuZCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwQmZSYW5nZShoZXhUb0ludChzdGFydCwgdWNzMkRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgQmluYXJ5Q01hcFJlYWRlci5wcm9jZXNzIC0gdW5rbm93biB0eXBlOiAke3R5cGV9YCk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICh1c2VDTWFwKSB7CiAgICAgICAgcmV0dXJuIGV4dGVuZCh1c2VDTWFwKTsKICAgICAgfQogICAgICByZXR1cm4gY01hcDsKICAgIH0KICB9CiAgcmV0dXJuIEJpbmFyeUNNYXBSZWFkZXI7Cn0oKTsKY29uc3QgQ01hcEZhY3RvcnkgPSBmdW5jdGlvbiBDTWFwRmFjdG9yeUNsb3N1cmUoKSB7CiAgZnVuY3Rpb24gc3RyVG9JbnQoc3RyKSB7CiAgICBsZXQgYSA9IDA7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkrKykgewogICAgICBhID0gYSA8PCA4IHwgc3RyLmNoYXJDb2RlQXQoaSk7CiAgICB9CiAgICByZXR1cm4gYSA+Pj4gMDsKICB9CiAgZnVuY3Rpb24gZXhwZWN0U3RyaW5nKG9iaikgewogICAgaWYgKHR5cGVvZiBvYmogIT09ICJzdHJpbmciKSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTWFsZm9ybWVkIENNYXA6IGV4cGVjdGVkIHN0cmluZy4iKTsKICAgIH0KICB9CiAgZnVuY3Rpb24gZXhwZWN0SW50KG9iaikgewogICAgaWYgKCFOdW1iZXIuaXNJbnRlZ2VyKG9iaikpIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJNYWxmb3JtZWQgQ01hcDogZXhwZWN0ZWQgaW50LiIpOwogICAgfQogIH0KICBmdW5jdGlvbiBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRiZmNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VCZlJhbmdlKGNNYXAsIGxleGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgIm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leGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgImVuZGNpZGNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdEludChvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRSYW5nZShjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRjaWRyYW5nZSIpKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBsb3cgPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0U3RyaW5nKG9iaik7CiAgICAgIGNvbnN0IGhpZ2ggPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0SW50KG9iaik7CiAgICAgIGNvbnN0IGRzdExvdyA9IG9iajsKICAgICAgY01hcC5tYXBDaWRSYW5nZShsb3csIGhpZ2gsIGRzdExvdyk7CiA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zLk5hbWUpIHsKICAgICAgY01hcC5uYW1lID0gb2JqLm5hbWU7CiAgICB9CiAgfQogIGFzeW5jIGZ1bmN0aW9uIHBhcnNlQ01hcChjTWFwLCBsZXhlciwgZmV0Y2hCdWlsdEluQ01hcCwgdXNlQ01hcCkgewogICAgbGV0IHByZXZpb3VzLCBlbWJlZGRlZFVzZUNNYXA7CiAgICBvYmpMb29wOiB3aGlsZSAodHJ1ZSkgewogICAgICB0cnkgewogICAgICAgIGNvbnN0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBpZiAob2JqLm5hbWUgPT09ICJXTW9kZSIpIHsKICAgICAgICAgICAgcGFyc2VXTW9kZShjTWFwLCBsZXhlcik7CiAgICAgICAgICB9IGVsc2UgaWYgKG9iai5uYW1lID09PSAiQ01hcE5hbWUiKSB7CiAgICAgICAgICAgIHBhcnNlQ01hcE5hbWUoY01hcCwgbGV4ZXIpOwogICAgICAgICAgfQogICAgICAgICAgcHJldmlvdXMgPSBvYmo7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5DbWQpIHsKICAgICAgICAgIHN3aXRjaCAob2JqLmNtZCkgewogICAgICAgICAgICBjYXNlICJlbmRjbWFwIjoKICAgICAgICAgICAgICBicmVhayBvYmpMb29wOwogICAgICAgICAgICBjYXNlICJ1c2VjbWFwIjoKICAgICAgICAgICAgICBpZiAocHJldmlvdXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBlbWJlZGRlZFVzZUNNYXAgPSBwcmV2aW91cy5uYW1lOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5jb2Rlc3BhY2VyYW5nZSI6CiAgICAgICAgICAgICAgcGFyc2VDb2Rlc3BhY2VSYW5nZShjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luYmZjaGFyIjoKICAgICAgICAgICAgICBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luY2lkY2hhciI6CiAgICAgICAgICAgICAgcGFyc2VDaWRDaGFyKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5iZnJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUJmUmFuZ2UoY01hcCwgbGV4ZXIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJiZWdpbmNpZHJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUNpZFJhbmdlKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGV4OwogICAgICAgIH0KICAgICAgICAoMCwgX3V0aWwud2FybikoIkludmFsaWQgY01hcCBkYXRhOiAiICsgZXgpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICBpZiAoIXVzZUNNYXAgJiYgZW1iZWRkZWRVc2VDTWFwKSB7CiAgICAgIHVzZUNNYXAgPSBlbWJlZGRlZFVzZUNNYXA7CiAgICB9CiAgICBpZiAodXNlQ01hcCkgewogICAgICByZXR1cm4gZXh0ZW5kQ01hcChjTWFwLCBmZXRjaEJ1aWx0SW5DTWFwLCB1c2VDTWFwKTsKICAgI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qKGNpcGhlclRyYW5zZm9ybSkpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgIGlmICh0aGlzLnJlY292ZXJ5TW9kZSkgewogICAgICAgICAgICAgIHJldHVybiBhcnJheTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZXcgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKCJFbmQgb2YgZmlsZSBpbnNpZGUgYXJyYXkuIik7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICByZXR1cm4gYXJyYXk7CiAgICAgICAgY2FzZSAiPDwiOgogICAgICAgICAgY29uc3QgZGljdCA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KHRoaXMueHJlZik7CiAgICAgICAgICB3aGlsZSAoISgwLCBfcHJpbWl0aXZlcy5pc0NtZCkodGhpcy5idWYxLCAiPj4iKSAmJiB0aGlzLmJ1ZjEgIT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAoISh0aGlzLmJ1ZjEgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiTWFsZm9ybWVkIGRpY3Rpb25hcnk6IGtleSBtdXN0IGJlIGEgbmFtZSBvYmplY3QiKTsKICAgICAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3Qga2V5ID0gdGhpcy5idWYxLm5hbWU7CiAgICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZGljdC5zZXQoa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iAoY2ggPT09IE5VTCAmJiBmb2xsb3dpbmdCeXRlc1tpICsgMV0gIT09IE5VTCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjaCAhPT0gTEYgJiYgY2ggIT09IENSICYmIChjaCA8IFNQQUNFIHx8IGNoID4gMHg3ZikpIHsKICAgICAgICAgICAgICBzdGF0ZSA9IDA7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZSAhPT0gMikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChsZXhlci5rbm93bkNvbW1hbmRzKSB7CiAgICAgICAgICAgIGNvbnN0IG5leHRPYmogPSBsZXhlci5wZWVrT2JqKCk7CiAgICAgICAgICAgIGlmIChuZXh0T2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuQ21kICYmICFsZXhlci5rbm93bkNvbW1hbmRzW25leHRPYmouY21kXSkgewogICAgICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZCAtIGBsZXhlci5rbm93bkNvbW1hbmRzYCBpcyB1bmRlZmluZWQuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdGUgPT09IDIpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChjaCA9PT0gLTEpIHsKICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZDogIiArICJSZWFjaGVkIHRoZSBlbmQgb2YgdGhlIHN0cmVhbSB3aXRob3V0IGZpbmR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s7CiAgICAgICAgY2FzZSAweGMwOgogICAgICAgIGNhc2UgMHhjMToKICAgICAgICBjYXNlIDB4YzI6CiAgICAgICAgY2FzZSAweGMzOgogICAgICAgIGNhc2UgMHhjNToKICAgICAgICBjYXNlIDB4YzY6CiAgICAgICAgY2FzZSAweGM3OgogICAgICAgIGNhc2UgMHhjOToKICAgICAgICBjYXNlIDB4Y2E6CiAgICAgICAgY2FzZSAweGNiOgogICAgICAgIGNhc2UgMHhjZDoKICAgICAgICBjYXNlIDB4Y2U6CiAgICAgICAgY2FzZSAweGNmOgogICAgICAgIGNhc2UgMHhjNDoKICAgICAgICBjYXNlIDB4Y2M6CiAgICAgICAgY2FzZSAweGRhOgogICAgICAgIGNhc2UgMHhkYjoKICAgICAgICBjYXNlIDB4ZGM6CiAgICAgICAgY2FzZSAweGRkOgogICAgICAgIGNhc2UgMHhkZToKICAgICAgICBjYXNlIDB4ZGY6CiAgICAgICAgY2FzZSAweGUwOgogICAgICAgIGNhc2UgMHhlMToKICAgICAgICBjYXNlIDB4ZTI6CiAgICAgICAgY2FzZSAweGUzOgogICAgICAgIGNhc2UgMHhlNDoKICAgICAgICBjYXNlIDB4ZTU6CiAgICAgICAgY2FzZSAweGU2OgogICAgICAgIGNhc2UgMHhlNzoKICAgICAgICBjYXNlIDB4ZTg6CiAgICAgICAgY2FzZSAweGU5OgogICAgICAgIGNhc2UgMHhlYToKICAgICAgICBjYXNlIDB4ZWI6CiAgICAgICAgY2FzZSAweGVjOgogICAgICAgIGNhc2UgMHhlZDoKICAgICAgICBjYXNlIDB4ZWU6CiAgICAgICAgY2FzZSAweGVmOgogICAgICAgIGNhc2UgMHhmZToKICAgICAgICAgIG1hcmtlckxlbmd0aCA9IHN0cmVhbS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmIChtYXJrZXJMZW5ndGggPiAyKSB7CiAgICAgICAgICAgIHN0cmVhbS5za2lwKG1hcmtlckxlbmd0aCAtIDIpOwogICAgICAgICAgfSBlbHNlIHsK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ICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDApIHsKICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzOSkgewogICAgICAgIGNvbnN0IGN1cnJlbnREaWdpdCA9IGNoIC0gMHgzMDsKICAgICAgICBpZiAoZU5vdGF0aW9uKSB7CiAgICAgICAgICBwb3dlclZhbHVlID0gcG93ZXJWYWx1ZSAqIDEwICsgY3VycmVudERpZ2l0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgICAgICAgZGl2aWRlQnkgKj0gMTA7CiAgICAgICAgICB9CiAgICAgICAgICBiYXNlVmFsdWUgPSBiYXNlVmFsdWUgKiAxMCArIGN1cnJlbnREaWdpdDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MmUpIHsKICAgICAgICBpZiAoZGl2aWRlQnkgPT09IDApIHsKICAgICAgICAgIGRpdmlkZUJ5ID0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDJkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJCYWRseSBmb3JtYXR0ZWQgbnVtYmVyOiBtaW51cyBzaWduIGluIHRoZSBtaWRkbGUiKTsKICAgICAgfSBlbHNlIGlmIChjaCA9PT0gMHg0NSB8fCBjaCA9PT0gMHg2NSkgewogICAgICAgIGNoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICAgIGlmIChjaCA9PT0gMHgyYiB8fCBjaCA9PT0gMHgyZCkgewogICAgICAgICAgcG93ZXJWYWx1ZVNpZ24gPSBjaCA9PT0gMHgyZCA/IC0xIDogMTsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB9IGVsc2UgaWYgKGNoIDwgMHgzMCB8fCBjaCA+IDB4MzkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBlTm90YXRpb24gPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgYmFzZVZhbHVlIC89IGRpdmlkZUJ5OwogICAgfQogICAgaWYgKGVOb3RhdGlvbikgewogICAgICBiYXNlVmFsdWUgKj0gMTAgKiogKHBvd2VyVmFsdWVTaWduICogcG93ZXJWYWx1ZSk7CiAgICB9CiAgICByZXR1cm4gc2lnbiAqIGJhc2VWYWx1ZTsKICB9CiAgZ2V0U3RyaW5nKCkgewogICAgbGV0IG51bVBhcmVuID0gMTsKICAgIGxldCBkb25lID0gZmFsc2U7CiAgICBjb25zdCBzdHJCdWYgPSB0aGlzLnN0ckJ1ZjsKICAgIHN0ckJ1Zi5sZW5ndGggPSAwOwogICAgbGV0IGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IGNoYXJCdWZmZXJlZCA9IGZhbHNlOwogICAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICAgIGNhc2UgLTE6CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBzdHJpbmciKTsKICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI4OgogICAgICAgICAgKytudW1QYXJlbjsKICAgICAgICAgIHN0ckJ1Zi5wdXNoKCIoIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4Mjk6CiAgICAgICAgICBpZiAoLS1udW1QYXJlbiA9PT0gMCkgewogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyQnVmLnB1c2goIikiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHg1YzoKICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgc3dpdGNoIChjaCkgewogICAgICAgICAgICBjYXNlIC0xOgogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW50ZXJtaW5hdGVkIHN0cmluZyIpOwogICAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NmU6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxuIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg3MjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXHIiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDc0OgogICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKCJcdCIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NjI6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxiIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg2NjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXGYiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDVjOgogICAgICAgICAgICBjYXNlIDB4Mjg6CiAgICAgICAgICAgIGNhc2UgMHgyOToKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgzMDoKICAgICAgICAgICAgY2FzZSAweDMxOgogICAgICAgICAgICBjYXNlIDB4MzI6CiAgICAgICAgICAgIGNhc2UgMHgzMzoKICAgICAgICAgICAgY2FzZSAweDM0OgogICAgICAgICAgICBjYXNlIDB4MzU6CiAgICAgICAgICAgIGNhc2UgMHgzNjoKICAgICAgICAgICAgY2FzZSAweDM3OgogICAgICAgICAgICAgIGxldCB4ID0gY2ggJiAweDBmOwogICAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICAgIGNoYXJCdWZmZXJlZCA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzNykgewogICAgICAgICAgICAgICAgeCA9ICh4IDw8IDMpICsgKGNoICYgMHgwZik7CiAgICAgICAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICAgIGlmIChjaCA+PSAweDMwICYmIGNoIDw9IDB4MzcpIHsKICAgICAgICAgICAgICAgICAgY2hhckJ1ZmZlcmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHggPSAoeCA8PCAzKSArIChjaCAmIDB4MGYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKHgpKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDBkOgogICAgICAgICAgICAgIGlmICh0aGlzLnBlZWtDaGFyKCkgPT09IDB4MGEpIHsKICAgICAgICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgwYToKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgc3RyQnVmLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShjaCkpOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGRvbmUpIHsKICAgICAgICBicmVhazsK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dHJpbmdOdW1XYXJuID4gTUFYX0hFWF9TVFJJTkdfTlVNX1dBUk4pIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgKDAsIF91dGlsLndhcm4pKGBnZXRIZXhTdHJpbmcgLSBpZ25vcmluZyBpbnZhbGlkIGNoYXJhY3RlcjogJHtjaH1gKTsKICB9CiAgZ2V0SGV4U3RyaW5nKCkgewogICAgY29uc3Qgc3RyQnVmID0gdGhpcy5zdHJCdWY7CiAgICBzdHJCdWYubGVuZ3RoID0gMDsKICAgIGxldCBjaCA9IHRoaXMuY3VycmVudENoYXI7CiAgICBsZXQgaXNGaXJzdEhleCA9IHRydWU7CiAgICBsZXQgZmlyc3REaWdpdCwgc2Vjb25kRGlnaXQ7CiAgICB0aGlzLl9oZXhTdHJpbmdOdW1XYXJuID0gMDsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBoZXggc3RyaW5nIik7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSA9PT0gMSkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGlmIChpc0ZpcnN0SGV4KSB7CiAgICAgICAgICBmaXJzdERpZ2l0ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoZmlyc3REaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgc2Vjb25kRGlnaXQgPSB0b0hleERpZ2l0KGNoKTsKICAgICAgICAgIGlmIChzZWNvbmREaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoZmlyc3REaWdpdCA8PCA0IHwgc2Vjb25kRGlnaXQpKTsKICAgICAgICB9CiAgICAgICAgaXNGaXJzdEhleCA9ICFpc0ZpcnN0SGV4OwogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXRPYmooKSB7CiAgICBsZXQgY29tbWVudCA9IGZhbHNlOwogICAgbGV0IGNoID0gdGhpcy5jdXJyZW50Q2hhcjsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuRU9GOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSAhPT0gMSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgc3dpdGNoIChjaCB8IDApIHsKICAgICAgY2FzZSAweDMwOgogICAgICBjYXNlIDB4MzE6CiAgICAgIGNhc2UgMHgzMjoKICAgICAgY2FzZSAweDMzOgogICAgICBjYXNlIDB4MzQ6CiAgICAgIGNhc2UgMHgzNToKICAgICAgY2FzZSAweDM2OgogICAgICBjYXNlIDB4Mzc6CiAgICAgIGNhc2UgMHgzODoKICAgICAgY2FzZSAweDM5OgogICAgICBjYXNlIDB4MmI6CiAgICAgIGNhc2UgMHgyZDoKICAgICAgY2FzZSAweDJlOgogICAgICAgIHJldHVybiB0aGlzLmdldE51bWJlcigpOwogICAgICBjYXNlIDB4Mjg6CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgyZjoKICAgICAgICByZXR1cm4gdGhpcy5nZXROYW1lKCk7CiAgICAgIGNhc2UgMHg1YjoKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoIlsiKTsKICAgICAgY2FzZSAweDVkOgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiXSIpOwogICAgICBjYXNlIDB4M2M6CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKGNoID09PSAweDNjKSB7CiAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiPDwiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0SGV4U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgzZToKICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5DbWQuZ2V0KCI+PiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiPiIpOwogICAgICBjYXNlIDB4N2I6CiAgICAgICAgdGhpcy5uZXh0Q2hhcigpOwogICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5DbWQuZ2V0KCJ7Iik7CiAgICAgIGNhc2UgMHg3ZDoKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoIn0iKTsKICAgICAgY2FzZSAweDI5OgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYElsbGVnYWwgY2hhcmFjdGVyOiAke2NofWApOwogICAgfQogICAgbGV0IHN0ciA9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgaWYgKGNoIDwgMHgyMCB8fCBjaCA+IDB4N2YpIHsKICAgICAgY29uc3QgbmV4dENoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICBpZiAobmV4dENoID49IDB4MjAgJiYgbmV4dENoIDw9IDB4N2YpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICAgICAgfQogICAgfQogICAgY29uc3Qga25vd25Db21tYW5kcyA9IHRoaXMua25vd25Db21tYW5kczsKICAgIGxldCBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB3aGlsZSAoKGNoID0gdGhpcy5uZXh0Q2hhcigpKSA+PSAwICYmICFzcGVjaWFsQ2hhcnNbY2hdKSB7CiAgICAgIGNvbnN0IHBvc3NpYmxlQ29tbWFuZCA9IHN0ciArIFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgICBpZiAoa25vd25Db21tYW5kRm91bmQgJiYga25vd25Db21tYW5kc1twb3NzaWJsZUNvbW1hbmRdID09PSB1bmRlZmluZWQpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoc3RyLmxlbmd0aCA9PT0gMTI4KSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBDb21tYW5kIHRva2VuIHRvbyBsb25nOiAke3N0ci5sZW5ndGh9YCk7CiAgICAgIH0KICAgICAgc3RyID0gcG9zc2libGVDb21tYW5kOwogICAgICBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB9CiAgICBpZiAoc3RyID09PSAidHJ1ZSIpIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBpZiAoc3RyID09PSAiZmFsc2UiKSB7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGlmIChzdHIgPT09ICJudWxsIikgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGlmIChzdHIgPT09ICJCSSIpIHsKICAgICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5zdHJlYW0ucG9zOwogICAgfQogICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICB9CiAgcGVla09iaigpIHsKICAgIGNvbnN0IHN0cmVhbVBvcyA9IHRoaXMuc3RyZWFtLnBvcywKICAgICAgY3VycmVudENoYXIgPSB0aGlzLmN1cnJlbnRDaGFyLAogICAgICBiZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5iZWdpbklubGluZUltYWdlUG9zOwogICAgbGV0IG5leHRPYmo7CiAgICB0cnkgewogICAgICBuZXh0T2JqID0gdGhpcy5nZXRPYmooKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKGBwZWVrT2Jq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AgICAgIHRocm93IG5ldyBFcnJvcihgVGhlICIke25hbWV9IiBwYXJhbWV0ZXIgaW4gdGhlIGxpbmVhcml6YXRpb24gYCArICJkaWN0aW9uYXJ5IGlzIGludmFsaWQuIik7CiAgICB9CiAgICBmdW5jdGlvbiBnZXRIaW50cyhsaW5EaWN0KSB7CiAgICAgIGNvbnN0IGhpbnRzID0gbGluRGljdC5nZXQoIkgiKTsKICAgICAgbGV0IGhpbnRzTGVuZ3RoOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShoaW50cykgJiYgKChoaW50c0xlbmd0aCA9IGhpbnRzLmxlbmd0aCkgPT09IDIgfHwgaGludHNMZW5ndGggPT09IDQpKSB7CiAgICAgICAgZm9yIChsZXQgaW5kZXggPSAwOyBpbmRleCA8IGhpbnRzTGVuZ3RoOyBpbmRleCsrKSB7CiAgICAgICAgICBjb25zdCBoaW50ID0gaGludHNbaW5kZXhdOwogICAgICAgICAgaWYgKCEoTnVtYmVyLmlzSW50ZWdlcihoaW50KSAmJiBoaW50ID4gMCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBIaW50ICgke2luZGV4fSkgaW4gdGhlIGxpbmVhcml6YXRpb24gZGljdGlvbmFyeSBpcyBpbnZhbGlkLmApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gaGludHM7CiAgICAgIH0KICAgICAgdGhyb3cgbmV3IEVycm9yKCJIaW50IGFycmF5IGluIHRoZSBsaW5lYXJpemF0aW9uIGRpY3Rpb25hcnkgaXMgaW52YWxpZC4iKTsKICAgIH0KICAgIGNvbnN0IHBhcnNlciA9IG5ldyBQYXJzZXIoewogICAgICBsZXhlcjogbmV3IExleGVyKHN0cmVhbSksCiAgICAgIHhyZWY6IG51bGwKICAgIH0pOwogICAgY29uc3Qgb2JqMSA9IHBhcnNlci5nZXRPYmooKTsKICAgIGNvbnN0IG9iajIgPSBwYXJzZXIuZ2V0T2JqKCk7CiAgICBjb25zdCBvYmozID0g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AgIGlmICh0aGlzLm91dHB1dEJpdHMgPT09IDApIHsKICAgICAgaWYgKHRoaXMucm93c0RvbmUpIHsKICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9mKSB7CiAgICAgICAgcmV0dXJuIC0xOwogICAgICB9CiAgICAgIHRoaXMuZXJyID0gZmFsc2U7CiAgICAgIGxldCBjb2RlMSwgY29kZTIsIGNvZGUzOwogICAgICBpZiAodGhpcy5uZXh0TGluZTJEKSB7CiAgICAgICAgZm9yIChpID0gMDsgY29kaW5nTGluZVtpXSA8IGNvbHVtbnM7ICsraSkgewogICAgICAgICAgcmVmTGluZVtpXSA9IGNvZGluZ0xpbmVbaV07CiAgICAgICAgfQogICAgICAgIHJlZkxpbmVbaSsrXSA9IGNvbHVtbnM7CiAgICAgICAgcmVmTGluZVtpXSA9IGNvbHVtbnM7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIHJlZlBvcyA9IDA7CiAgICAgICAgYmxhY2tQaXhlbHMgPSAwOwogICAgICAgIHdoaWxlIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fZ2V0VHdvRGltQ29kZSgpOwogICAgICAgICAgc3dpdGNoIChjb2RlMSkgewogICAgICAgICAgICBjYXNlIHR3b0RpbVBhc3M6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zICsgMV0sIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBpZiAocmVmTGluZVtyZWZQb3MgKyAxXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1Ib3JpejoKICAgICAgICAgICAgICBjb2RlMSA9IGNvZGUyID0gMDsKICAgICAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTEgKz0gY29kZTMgPSB0aGlzLl9nZXRCbGFja0NvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTIgKz0gY29kZTMgPSB0aGlzLl9nZXRXaGl0ZUNvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMiArPSBjb2RlMyA9IHRoaXMuX2dldEJsYWNrQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVscyhjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSArIGNvZGUyLCBibGFja1BpeGVscyBeIDEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjM6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDMsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjE6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDEsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0MDoKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMocmVmTGluZVtyZWZQb3NdLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgdHdvRGltVmVydEwzOgogICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVsc05lZyhyZWZMaW5lW3JlZlBvc10gLSAzLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICBpZiAocmVmUG9zID4gMCkgewogICAgICAgICAgICAgICAgICAtLXJlZlBvczsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0TDI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzTmVnKHJlZkxpbmVbcmVmUG9zXSAtIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIGlmIChyZWZQb3MgPiAwKSB7CiAgICAgICAgICAgICAgICAgIC0tcmVmUG9zOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgKytyZWZQb3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICAgcmVmUG9zICs9IDI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIHR3b0RpbVZlcnRMMToKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHNOZWcocmVmTGluZVtyZWZQb3NdIC0gMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGJsYWNrUGl4ZWxzIF49IDE7CiAgICAgICAgICAgICAgaWYgKGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgaWYgKHJlZlBvcyA+IDApIHsKICAgICAgICAgICAgICAgICAgLS1yZWZQb3M7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgY2NpdHRFT0Y6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCAyZCBjb2RlIik7CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIGJsYWNrUGl4ZWxzID0gMDsKICAgICAgICB3aGlsZSAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICBjb2RlMSA9IDA7CiAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGNvZGUxICs9IGNvZGUzID0gdGhpcy5fZ2V0QmxhY2tDb2RlKCk7CiAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICB9IHdoaWxlIChjb2RlMyA+PSA2NCk7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGdvdEVPTCA9IGZhbHNlOwogICAgICBpZiAodGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICB0aGlzLmlucHV0Qml0cyAmPSB+NzsKICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9ibG9jayAmJiB0aGlzLnJvdyA9PT0gdGhpcy5yb3dzIC0gMSkgewogICAgICAgIHRoaXMucm93c0RvbmUgPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgIGlmICh0aGlzLmVvbGluZSkgewogICAgICAgICAgd2hpbGUgKGNvZGUxICE9PSBjY2l0dEVPRiAmJiBjb2RlMSAhPT0gMSkgewogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2hpbGUgKGNvZGUxID09PSAwKSB7CiAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgZ290RU9MID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9mICYmIHRoaXMuZW5jb2RpbmcgPiAwICYmICF0aGlzLnJvd3NEb25lKSB7CiAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIXRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9ibG9jayAmJiBnb3RFT0wgJiYgdGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgIHRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPj0gMCkgewogICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgICAgICAgY29kZTEgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgICAgICAgICAgaWYgKGNvZGUxICE9PSAxKSB7CiAgICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBydGMgY29kZTogIiArIGNvZGUxKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLl9sb29rQml0cygxKTsKICAgICAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHRoaXMuZXJyICYmIHRoaXMuZW9saW5lKSB7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTMpOwogICAgICAgICAgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjb2RlMSA+PiAxID09PSAxKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIShjb2RlMSAmIDEpOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29kaW5nTGluZVswXSA+IDApIHsKICAgICAgICB0aGlzLm91dHB1dEJpdHMgPSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zID0gMF07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyA9IDFdOwogICAgICB9CiAgICAgIHRoaXMucm93Kys7CiAgICB9CiAgICBsZXQgYzsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPj0gOCkgewogICAgICBjID0gdGhpcy5jb2RpbmdQb3MgJiAxID8gMCA6IDB4ZmY7CiAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSA4OwogICAgICBpZiAodGhpcy5vdXRwdXRCaXRzID09PSAwICYmIGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gLSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zIC0gMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGJpdHMgPSA4OwogICAgICBjID0gMDsKICAgICAgZG8gewogICAgICAgIGlmICh0eXBlb2YgdGhpcy5vdXRwdXRCaXRzICE9PSAibnVtYmVyIikgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdJbnZhbGlkIC9DQ0lUVEZheERlY29kZSBkYXRhLCAib3V0cHV0Qml0cyIgbXVzdCBiZSBhIG51bWJlci4nKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3V0cHV0Qml0cyA+IGJpdHMpIHsKICAgICAgICAgIGMgPDw9IGJpdHM7CiAgICAgICAgICBpZiAoISh0aGlzLmNvZGluZ1BvcyAmIDEpKSB7CiAgICAgICAgICAgIGMgfD0gMHhmZiA+PiA4IC0gYml0czsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSBiaXRzOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGMgPDw9IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIGlmICghKHRoaXMuY29kaW5nUG9zICYgMSkpIHsKICAgICAgICAgICAgYyB8PSAweGZmID4+IDggLSB0aGlzLm91dHB1dEJpdHM7CiAgICAgICAgICB9CiAgICAgICAgICBiaXRzIC09IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IDA7CiAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIC0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyAtIDFdOwogICAgICAgICAgfSBlbHNlIGlmIChiaXRzID4gMCkgewogICAgICAgICAgICBjIDw8PSBiaXRzOwogICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gd2hpbGUgKGJpdHMpOwogICAgfQogICAgaWYgKHRoaXMuYmxhY2spIHsKICAgICAgYyBePSAweGZmOwogICAgfQogICAgcmV0dXJuIGM7CiAgfQogIF9hZGRQaXhlbHMoYTEsIGJsYWNrUGl4ZWxzKSB7CiAgICBjb25zdCBjb2RpbmdMaW5lID0gdGhpcy5jb2RpbmdMaW5lOwogICAgbGV0IGNvZGluZ1BvcyA9IHRoaXMuY29kaW5nUG9zOwogICAgaWYgKGExID4gY29kaW5nTGluZVtjb2RpbmdQb3NdKSB7CiAgICAgIGlmIChhMSA+IHRoaXMuY29sdW1ucykgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgicm93IGlzIHdyb25nIGxlbmd0aCIpOwogICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgIC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ZpbmRUYWJsZUNvZGUoMSwgNywgdHdvRGltVGFibGUpOwogICAgICBpZiAocmVzdWx0WzBdICYmIHJlc3VsdFsyXSkgewogICAgICAgIHJldHVybiByZXN1bHRbMV07CiAgICAgIH0KICAgIH0KICAgICgwLCBfdXRpbC5pbmZvKSgiQmFkIHR3byBkaW0gY29kZSIpOwogICAgcmV0dXJuIGNjaXR0RU9GOwogIH0KICBfZ2V0V2hpdGVDb2RlKCkgewogICAgbGV0IGNvZGUgPSAwOwogICAgbGV0IHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDUgPT09IDApIHsKICAgICAgICBwID0gd2hpdGVUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcCA9IHdoaXRlVGFibGUyW2NvZGUgPj4gM107CiAgICAgIH0KICAgICAgaWYgKHBbMF0gPiAwKSB7CiAgICAgICAgdGhpcy5fZWF0Qml0cyhwWzBdKTsKICAgICAgICByZXR1cm4gcFsxXTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgOSwgd2hpdGVUYWJsZTIpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgICByZXN1bHQgPSB0aGlzLl9maW5kVGFibGVDb2RlKDExLCAxMiwgd2hpdGVUYWJsZTEpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgfQogICAgKDAsIF91dGlsLmluZm8pKCJiYWQgd2hpdGUgY29kZSIpOwogICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIHJldHVybiAxOwogIH0KICBfZ2V0QmxhY2tDb2RlKCkgewogICAgbGV0IGNvZGUsIHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMyk7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDcgPT09IDApIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSBpZiAoY29kZSA+PiA5ID09PSAwICYmIGNvZGUgPj4gNyAhPT0gMCkgewogICAgICAgIHAgPSBibGFja1RhYmxlMlsoY29kZSA+PiAxKSAtIDY0XTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTNbY29kZSA+PiA3XTsKICAgICAgfQogICAgICBpZiAocFswXSA+IDApIHsKICAgICAgICB0aGlzLl9lYXRCaXRzKHBbMF0pOwogICAgICAgIHJldHVybiBwWzFdOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBsZXQgcmVzdWx0ID0gdGhpcy5fZmluZFRhYmxlQ29kZSgyLCA2LCBibGFja1RhYmxlMyk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoNywgMTIsIGJsYWNrVGFibGUyLCA2NCk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMTAsIDEzLCBibGFja1RhYmxlMSk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICB9CiAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBibGFjay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CBjb2RlcyA9IG5ldyBJbnQzMkFycmF5KHNpemUpOwogICAgZm9yIChsZXQgbGVuID0gMSwgY29kZSA9IDAsIHNraXAgPSAyOyBsZW4gPD0gbWF4TGVuOyArK2xlbiwgY29kZSA8PD0gMSwgc2tpcCA8PD0gMSkgewogICAgICBmb3IgKGxldCB2YWwgPSAwOyB2YWwgPCBuOyArK3ZhbCkgewogICAgICAgIGlmIChsZW5ndGhzW3ZhbF0gPT09IGxlbikgewogICAgICAgICAgbGV0IGNvZGUyID0gMDsKICAgICAgICAgIGxldCB0ID0gY29kZTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgICBjb2RlMiA9IGNvZGUyIDw8IDEgfCB0ICYgMTsKICAgICAgICAgICAgdCA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGNvZGUyOyBpIDwgc2l6ZTsgaSArPSBza2lwKSB7CiAgICAgICAgICAgIGNvZGVzW2ldID0gbGVuIDw8IDE2IHwgdmFsOwogICAgICAgICAgfQogICAgICAgICAgKytjb2RlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIFtjb2RlcywgbWF4TGVuXTsKICB9CiAgcmVhZEJsb2NrKCkgewogICAgbGV0IGJ1ZmZlciwgbGVuOwogICAgY29uc3Qgc3RyID0gdGhpcy5zdHI7CiAgICBsZXQgaGRyID0gdGhpcy5nZXRCaXRzKDMpOwogICAgaWYgKGhkciAmIDEpIHsKICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgfQogICAgaGRyID4+PSAxOwogICAgaWYgKGhkciA9PT0gMCkgewogICAgICBsZXQgYjsKICAgICAgaWYgKChiID0gc3RyLmdldEJ5dGUoKSkgPT09IC0xKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJCYWQgYmxvY2sgaGVhZGVyIGluIGZsYXRlIHN0cmVhbSIpOwogICAgICB9CiAgICAgIGxldCB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zdCBjb2RlTGVuQ29kZVRhYiA9IHRoaXMuZ2VuZXJhdGVIdWZmbWFuVGFibGUoY29kZUxlbkNvZGVMZW5ndGhzKTsKICAgICAgbGVuID0gMDsKICAgICAgaSA9IDA7CiAgICAgIGNvbnN0IGNvZGVzID0gbnVtTGl0Q29kZXMgKyBudW1EaXN0Q29kZXM7CiAgICAgIGNvbnN0IGNvZGVMZW5ndGhzID0gbmV3IFVpbnQ4QXJyYXkoY29kZXMpOwogICAgICBsZXQgYml0c0xlbmd0aCwgYml0c09mZnNldCwgd2hhdDsKICAgICAgd2hpbGUgKGkgPCBjb2RlcykgewogICAgICAgIGNvbnN0IGNvZGUgPSB0aGlzLmdldENvZGUoY29kZUxlbkNvZGVUYWIpOwogICAgICAgIGlmIChjb2RlID09PSAxNikgewogICAgICAgICAgYml0c0xlbmd0aCA9IDI7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW47CiAgICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAxNykgewogICAgICAgICAgYml0c0xlbmd0aCA9IDM7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW4gPSAwOwogICAgICAgIH0gZWxzZSBpZiAoY29kZSA9PT0gMTgpIHsKICAgICAgICAgIGJpdHNMZW5ndGggPSA3OwogICAgICAgICAgYml0c09mZnNldCA9IDExOwogICAgICAgICAgd2hhdCA9IGxlbiA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSBsZW4gPSBjb2RlOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGxldCByZXBlYXRMZW5ndGggPSB0aGlzLmdldEJpdHMoYml0c0xlbmd0aCkgKyBiaXRzT2Zmc2V0OwogICAgICAgIHdoaWxlIChyZXBlYXRMZW5ndGgtLSA+IDApIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSB3a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MQp9LCB7CiAgeDogMCwKICB5OiAtMQp9LCB7CiAgeDogMSwKICB5OiAtMQp9LCB7CiAgeDogMiwKICB5OiAtMQp9LCB7CiAgeDogLTMsCiAgeTogMAp9LCB7CiAgeDogLTIsCiAgeTogMAp9LCB7CiAgeDogLTEsCiAgeTogMAp9XSwgW3sKICB4OiAtMSwKICB5OiAtMgp9LCB7CiAgeDogMCwKICB5OiAtMgp9LCB7CiAgeDogMSwKICB5OiAtMgp9LCB7CiAgeDogLTIsCiAgeTogLTEKfSwgewogIHg6IC0xLAogIHk6IC0xCn0sIHsKICB4OiAwLAogIHk6IC0xCn0sIHsKICB4OiAxLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAwCn0sIHsKICB4OiAtMSwKICB5OiAwCn1dLCBbewogIHg6IC0zLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAtMQp9LCB7CiAgeDogLTEsCiAgeTogLTEKfSwgewogIHg6IDAsCiAgeTogLTEKfSwgewogIHg6IDEsCiAgeTogLTEKfSwgewogIHg6IC00LAogIHk6IDAKfSwgewogIHg6IC0zLAogIHk6IDAKfSwgewogIHg6IC0yLAogIHk6IDAKfSwgewogIHg6IC0xLAogIHk6IDAKfV1dOwpjb25zdCBSZWZpbmVtZW50VGVtcGxhdGVzID0gW3sKICBjb2Rpbmc6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9XSwKICByZWZlcmVuY2U6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAwLAogICAgeTogMAogIH0sIHsKICAgIHg6IDEsCiAgICB5OiAwCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAxCiAgfSwgewogICAgeDogMCwKICAgIHk6IDEKICB9LCB7Ci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iAgY29uc3QgcHNldWRvUGl4ZWxDb250ZXh0ID0gUmV1c2VkQ29udGV4dHNbdGVtcGxhdGVJbmRleF07CiAgbGV0IHJvdyA9IG5ldyBVaW50OEFycmF5KHdpZHRoKTsKICBjb25zdCBiaXRtYXAgPSBbXTsKICBjb25zdCBkZWNvZGVyID0gZGVjb2RpbmdDb250ZXh0LmRlY29kZXI7CiAgY29uc3QgY29udGV4dHMgPSBkZWNvZGluZ0NvbnRleHQuY29udGV4dENhY2hlLmdldENvbnRleHRzKCJHQiIpOwogIGxldCBsdHAgPSAwLAogICAgaiwKICAgIGkwLAogICAgajAsCiAgICBjb250ZXh0TGFiZWwgPSAwLAogICAgYml0LAogICAgc2hpZnQ7CiAgZm9yIChsZXQgaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgaWYgKHByZWRpY3Rpb24pIHsKICAgICAgY29uc3Qgc2x0cCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgcHNldWRvUGl4ZWxDb250ZXh0KTsKICAgICAgbHRwIF49IHNsdHA7CiAgICAgIGlmIChsdHApIHsKICAgICAgICBiaXRtYXAucHVzaChyb3cpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICByb3cgPSBuZXcgVWludDhBcnJheShyb3cpOwogICAgYml0bWFwLnB1c2gocm93KTsKICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGlmICh1c2Vza2lwICYmIHNraXBbaV1bal0pIHsKICAgICAgICByb3dbal0gPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChqID49IHNiYl9sZWZ0ICYmIGogPCBzYmJfcmlnaHQgJiYgaSA+PSBzYmJfdG9wKSB7CiAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgJiByZXVzZU1hc2s7CiAgICAgICAgZm9yIChrID0gMDsgayA8IGNoYW5naW5nRW50cmllc0xlbmd0aDsgaysrKSB7CiAgICAgICAgICBpMCA9IGkgKyBjaGFuZ2luZ1RlbXBsYXRlWVtrXTsKICAgICAgICAgIGowID0gaiArIGNoYW5naW5nVGVtcGxhdGVYW2tdOwogICAgICAgICAgYml0ID0gYml0bWFwW2kwXVtqMF07CiAgICAgICAgICBpZiAoYml0KSB7CiAgICAgICAgICAgIGJpdCA9IGNoYW5naW5nVGVtcGxhdGVCaXRba107CiAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDA7CiAgICAgICAgc2hpZnQgPSB0ZW1wbGF0ZUxlbmd0aCAtIDE7CiAgICAgICAgZm9yIChrID0gMDsgayA8IHRlbXBsYXRlTGVuZ3RoOyBrKyssIHNoaWZ0LS0pIHsKICAgICAgICAgIGowID0gaiArIHRlbXBsYXRlWFtrXTsKICAgICAgICAgIGlmIChqMCA+PSAwICYmIGowIDwgd2lkdGgpIHsKICAgICAgICAgICAgaTAgPSBpICsgdGVtcGxhdGVZW2tdOwogICAgICAgICAgICBpZiAoaTAgPj0gMCkgewogICAgICAgICAgICAgIGJpdCA9IGJpdG1hcFtpMF1bajBdOwogICAgICAgICAgICAgIGlmIChiaXQpIHsKICAgICAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQgPDwgc2hpZnQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHBpeGVsID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICByb3dbal0gPSBwaXhlbDsKICAgIH0KICB9CiAgcmV0dXJuIGJpdG1hcDsKfQpmdW5jdGlvbiBkZWNvZGVSZWZpbmVtZW50KHdpZHRoLCBoZWlnaHQsIHRlbXBsYXRlSW5kZXgsIHJlZmVyZW5jZUJpdG1hcCwgb2Zm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CByb3cgPSBuZXcgVWludDhBcnJheSh3aWR0aCk7CiAgICBiaXRtYXAucHVzaChyb3cpOwogICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGxldCBpMCwgajA7CiAgICAgIGxldCBjb250ZXh0TGFiZWwgPSAwOwogICAgICBmb3IgKGsgPSAwOyBrIDwgY29kaW5nVGVtcGxhdGVMZW5ndGg7IGsrKykgewogICAgICAgIGkwID0gaSArIGNvZGluZ1RlbXBsYXRlWVtrXTsKICAgICAgICBqMCA9IGogKyBjb2RpbmdUZW1wbGF0ZVhba107CiAgICAgICAgaWYgKGkwIDwgMCB8fCBqMCA8IDAgfHwgajAgPj0gd2lkdGgpIHsKICAgICAgICAgIGNvbnRleHRMYWJlbCA8PD0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgfCBiaXRtYXBbaTBdW2owXTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChrID0gMDsgayA8IHJlZmVyZW5jZVRlbXBsYXRlTGVuZ3RoOyBrKyspIHsKICAgICAgICBpMCA9IGkgKyByZWZlcmVuY2VUZW1wbGF0ZVlba10gLSBvZmZzZXRZOwogICAgICAgIGowID0gaiArIHJlZmVyZW5jZVRlbXBsYXRlWFtrXSAtIG9mZnNldFg7CiAgICAgICAgaWYgKGkwIDwgMCB8fCBpMCA+PSByZWZlcmVuY2VIZWlnaHQgfHwgajAgPCAwIHx8IGowID49IHJlZmVyZW5jZVdpZHRoKSB7CiAgICAgICAgICBjb250ZXh0TGFiZWwgPDw9IDE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnRleHRMYWJlbCA9IGNvbnRleHRMYWJlbCA8PCAxIHwgcmVmZXJlbmNlQml0bWFwW2kwXVtqMF07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHBpeGVsID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzL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SBudW1iZXJPZlN5bWJvbHNEZWNvZGVkIC0gMSkgewogICAgICAgIG5ld1N5bWJvbHMucHVzaChjb2xsZWN0aXZlQml0bWFwKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBsZXQgaSwKICAgICAgICAgIHksCiAgICAgICAgICB4TWluID0gMCwKICAgICAgICAgIHhNYXgsCiAgICAgICAgICBiaXRtYXBXaWR0aCwKICAgICAgICAgIHN5bWJvbEJpdG1hcDsKICAgICAgICBmb3IgKGkgPSBmaXJzdFN5bWJvbDsgaSA8IG51bWJlck9mU3ltYm9sc0RlY29kZWQ7IGkrKykgewogICAgICAgICAgYml0bWFwV2lkdGggPSBzeW1ib2xXaWR0aHNbaV07CiAgICAgICAgICB4TWF4ID0geE1pbiArIGJpdG1hcFdpZHRoOwogICAgICAgICAgc3ltYm9sQml0bWFwID0gW107CiAgICAgICAgICBmb3IgKHkgPSAwOyB5IDwgY3VycmVudEhlaWdodDsgeSsrKSB7CiAgICAgICAgICAgIHN5bWJvbEJpdG1hcC5wdXNoKGNvbGxlY3RpdmVCaXRtYXBbeV0uc3ViYXJyYXkoeE1pbiwgeE1heCkpOwogICAgICAgICAgfQogICAgICAgICAgbmV3U3ltYm9scy5wdXNoKHN5bWJvbEJpdG1hcCk7CiAgICAgICAgICB4TWluID0geE1heDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgY29uc3QgZXhwb3J0ZWRTeW1ib2xzID0gW10sCiAgICBmbGFncyA9IFtdOwogIGxldCBjdXJyZW50RmxhZyA9IGZhbHNlLAogICAgaSwKICAgIGlpOwogIGNvbnN0IHRvdGFsU3ltYm9sc0xlbmd0aCA9IHN5bWJvbHMubGVuZ3RoICsgbnVtYmVyT2ZOZXdTeW1ib2xzOwogIHdoaWxlIChmbGFncy5sZW5ndGggPCB0b3RhbFN5bWJvbHNMZW5ndGgpIHsKICAgIGxldCBydW5MZW5ndGggPSBodWZmbWFuID8gdGFibGVCMS5kZWNvZGUoaHVmZm1hbklucHV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KHdpZHRoIC0gb2Zmc2V0VCwgc3ltYm9sV2lkdGgpOwogICAgICAgICAgc3dpdGNoIChjb21iaW5hdGlvbk9wZXJhdG9yKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gfD0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gXj0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpiaWcyRXJyb3IoYG9wZXJhdG9yICR7Y29tYmluYXRpb25PcGVyYXRvcn0gaXMgbm90IHN1cHBvcnRlZGApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjdXJyZW50UyArPSBzeW1ib2xIZWlnaHQgLSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAodDIgPSAwOyB0MiA8IHN5bWJvbEhlaWdodDsgdDIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFQgKyB0Ml07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFt0Ml07CiAgICAgICAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSB8PSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSBePSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgSmJpZzJFcnJvcihgb3BlcmF0b3IgJHtjb21iaW5hdGlvbk9wZXJhdG9yfSBpcyBub3Qgc3VwcG9ydGVkYCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGN1cnJlbnRTICs9IHN5bWJvbFdpZHRoIC0gMTsKICAgICAgfQogICAgICBpKys7CiAgICAgIGNvbnN0IGRlbHRhUyA9IGh1ZmZtYW4gPyBodWZmbWFuVGFibGVzLnRhYmxlRGVsdGFTLmRlY29kZShodWZmbWFuSW5wdXQpIDogZGVjb2RlSW50ZWdlcihjb250ZXh0Q2FjaGUsICJJQURTIiwgZGVjb2Rlcik7CiAgICAgIGlmIChkZWx0YVMgPT09IG51bGwpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBjdXJyZW50UyArPSBkZWx0YVMgKyBkc09mZnNldDsKICAgIH0gd2hpbGUgKHRydWUpOwogIH0KICByZXR1cm4gYml0bWFwOwp9CmZ1bmN0aW9uIGRlY29kZVBhdHRlcm5EaWN0aW9uYXJ5KG1tciwgcGF0dGVybldpZHRoLCBwYXR0ZXJuSGVpZ2h0LCBtYXhQYXR0ZXJuSW5kZXgsIHRlbXBsYXRlLCBkZWNvZGluZ0NvbnRleHQpIHsKICBjb25zdCBhdCA9IFtdOwogIGlmICghbW1yKSB7CiAgICBhdC5wdXNoKHsKICA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gICAgICAgIGlmIChiaXRtYXBbaV1bal0pIHsKICAgICAgICAgICAgICBidWZmZXJbb2Zmc2V0XSB8PSBtYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgIGlmICghbWFzaykgewogICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgb2Zmc2V0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldDAgKz0gcm93U2l6ZTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgIG1hc2sgPSBtYXNrMDsKICAgICAgICAgIG9mZnNldCA9IG9mZnNldDA7CiAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICBpZiAoYml0bWFwW2ldW2pdKSB7CiAgICAgICAgICAgICAgYnVmZmVyW29mZnNldF0gXj0gbWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgICBpZiAoIW1hc2spIHsKICAgICAgICAgICAgICBtYXNrID0gMTI4OwogICAgICAgICAgICAgIG9mZnNldCsrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBvZmZzZXQwICs9IHJvd1NpemU7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBKYmlnMkVycm9yKGBvcGVyYXRvciAke2NvbWJpbmF0aW9uT3BlcmF0b3J9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgIH0KICB9CiAgb25JbW1lZGlhdGVHZW5lcmljUmVnaW9uKHJlZ2lvbiwgZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgcmVnaW9uSW5mbyA9IHJlZ2lvbi5pbmZvOwogICAgY29uc3Qg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sc2UgewogICAgICBicCsrOwogICAgICB0aGlzLmNsb3cgKz0gYnAgPCB0aGlzLmRhdGFFbmQgPyBkYXRhW2JwXSA8PCA4IDogMHhmZjAwOwogICAgICB0aGlzLmN0ID0gODsKICAgICAgdGhpcy5icCA9IGJwOwogICAgfQogICAgaWYgKHRoaXMuY2xvdyA+IDB4ZmZmZikgewogICAgICB0aGlzLmNoaWdoICs9IHRoaXMuY2xvdyA+PiAxNjsKICAgICAgdGhpcy5jbG93ICY9IDB4ZmZmZjsKICAgIH0KICB9CiAgcmVhZEJpdChjb250ZXh0cywgcG9zKSB7CiAgICBsZXQgY3hfaW5kZXggPSBjb250ZXh0c1twb3NdID4+IDEsCiAgICAgIGN4X21wcyA9IGNvbnRleHRzW3Bvc10gJiAxOwogICAgY29uc3QgcWVUYWJsZUljeCA9IFFlVGFibGVbY3hfaW5kZXhdOwogICAgY29uc3QgcWVJY3ggPSBxZVRhYmxlSWN4LnFlOwogICAgbGV0IGQ7CiAgICBsZXQgYSA9IHRoaXMuYSAtIHFlSWN4OwogICAgaWYgKHRoaXMuY2hpZ2ggPCBxZUljeCkgewogICAgICBpZiAoYSA8IHFlSWN4KSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSBjeF9tcHM7CiAgICAgICAgY3hfaW5kZXggPSBxZVRhYmxlSWN4Lm5tcHM7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSAxIF4gY3hfbXBzOwogICAgICAgIGlmIChxZVRhYmxlSWN4LnN3aXRjaEZsYWcgPT09IDEpIHsKICAgICAgICAgIGN4X21wcyA9IGQ7CiAgICAgICAgfQogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubHBzOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmNoaWdoIC09IHFlSWN4OwogICAgICBpZiAoKGEgJiAweDgwMDApICE9PSAwKSB7CiAgICAgICAgdGhpcy5hID0gYTsKICAgICA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IGNvbnN0IG4gPSByZWNlaXZlKGxlbmd0aCk7CiAgICBpZiAobiA+PSAxIDw8IGxlbmd0aCAtIDEpIHsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZXR1cm4gbiArICgtMSA8PCBsZW5ndGgpICsgMTsKICB9CiAgZnVuY3Rpb24gZGVjb2RlQmFzZWxpbmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29uc3QgdCA9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZURDKTsKICAgIGNvbnN0IGRpZmYgPSB0ID09PSAwID8gMCA6IHJlY2VpdmVBbmRFeHRlbmQodCk7CiAgICBjb21wb25lbnQuYmxvY2tEYXRhW2Jsb2NrT2Zmc2V0XSA9IGNvbXBvbmVudC5wcmVkICs9IGRpZmY7CiAgICBsZXQgayA9IDE7CiAgICB3aGlsZSAoayA8IDY0KSB7CiAgICAgIGNvbnN0IHJzID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlQUMpOwogICAgICBjb25zdCBzID0gcnMgJiAxNSwKICAgICAgICByID0gcnMgPj4gNDsKICAgICAgaWYgKHMgPT09IDApIHsKICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgKyB6XSA9IHJlY2VpdmVBbmRFeHRlbmQocyk7CiAgICAgIGsrKzsKICAgIH0KICB9CiAgZnVuY3Rpb24gZGVjb2RlRENGaXJzdChjb21wb25lbnQsIGJsb2NrT2Zmc2V0KSB7CiAgICBjb25zdCB0ID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlREMpOwogICAgY29uc3QgZGlmZiA9IHQgPT09IDAgPyAwIDogcmVjZWl2ZUFuZEV4dGVuZCh0KSA8PCBzdWNjZXNzaXZlOwogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gPSBjb21wb25lbnQucHJlZCArPSBkaWZmOwogIH0KICBmdW5jdGlvbiBkZWNvZGVEQ1N1Y2Nlc3NpdmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gfD0gcmVhZEJpdCgpIDw8IHN1Y2Nlc3NpdmU7CiAgfQogIGxldCBlb2JydW4gPSAwOwogIGZ1bmN0aW9uIGRlY29kZUFDRmlyc3QoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgaWYgKGVvYnJ1biA+IDApIHsKICAgICAgZW9icnVuLS07CiAgICAgIHJldHVybjsKICAgIH0KICAgIGxldCBrID0gc3BlY3RyYWxTdGFydDsKICAgIGNvbnN0IGUgPSBzcGVjdHJhbEVuZDsKICAgIHdoaWxlIChrIDw9IGUpIHsKICAgICAgY29uc3QgcnMgPSBkZWNvZGVIdWZmbWFuKGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyk7CiAgICAgIGNvbnN0IHMgPSBycyAmIDE1LAogICAgICAgIHIgPSBycyA+PiA0OwogICAgICBpZiAocyA9PT0gMCkgewogICAgICAgIGlmIChyIDwgMTUpIHsKICAgICAgICAgIGVvYnJ1biA9IHJlY2VpdmUocikgKyAoMSA8PCByKSAtIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgKyB6XSA9IHJlY2VpdmVBbmRFeHRlbmQocykgKiAoMSA8PCBzdWNjZXNzaXZlKTsKICAgICAgaysrOwogICAgfQogIH0KICBsZXQgc3VjY2Vzc2l2ZUFDU3RhdGUgPSAwLAogICAgc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlOwogIGZ1bmN0aW9uIGRlY29kZUFDU3VjY2Vzc2l2ZShjb21wb25lbnQsIGJsb2NrT2Zmc2V0KSB7CiAgICBsZXQgayA9IHNwZWN0cmFsU3RhcnQ7CiAgICBjb25zdCBlID0gc3BlY3RyYWxFbmQ7CiAgICBsZXQgciA9IDA7CiAgICBsZXQgczsKICAgIGxldCByczsKICAgIHdoaWxlIChrIDw9IGUpIHsKICAgICAgY29uc3Qgb2Zmc2V0WiA9IGJsb2NrT2Zmc2V0ICsgZGN0WmlnWmFnW2tdOwogICAgICBjb25zdCBzaWduID0gY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSA8IDAgPyAtMSA6IDE7CiAgICAgIHN3aXRjaCAoc3VjY2Vzc2l2ZUFDU3RhdGUpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBycyA9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZUFDKTsKICAgICAgICAgIHMgPSBycyAmIDE1OwogICAgICAgICAgciA9IHJzID4+IDQ7CiAgICAgICAgICBpZiAocyA9PT0gMCkgewogICAgICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICAgICAgZW9icnVuID0gcmVjZWl2ZShyKSArICgxIDw8IHIpOwogICAgICAgICAgICAgIHN1Y2Nlc3NpdmVBQ1N0YXRlID0gNDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICByID0gMTY7CiAgICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZiAocyAhPT0gMSkgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoImludmFsaWQgQUNuIGVuY29kaW5nIik7CiAgICAgICAgICAgIH0KICAgIC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cG9uZW50c0xlbmd0aDsgaSsrKSB7CiAgICAgICAgY29tcG9uZW50c1tpXS5wcmVkID0gMDsKICAgICAgfQogICAgICBlb2JydW4gPSAwOwogICAgICBpZiAoY29tcG9uZW50c0xlbmd0aCA9PT0gMSkgewogICAgICAgIGNvbXBvbmVudCA9IGNvbXBvbmVudHNbMF07CiAgICAgICAgZm9yIChuID0gMDsgbiA8IG1jdVRvUmVhZDsgbisrKSB7CiAgICAgICAgICBkZWNvZGVCbG9jayhjb21wb25lbnQsIGRlY29kZUZuLCBtY3UpOwogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobiA9IDA7IG4gPCBtY3VUb1JlYWQ7IG4rKykgewogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGNvbXBvbmVudHNMZW5ndGg7IGkrKykgewogICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRzW2ldOwogICAgICAgICAgICBoID0gY29tcG9uZW50Lmg7CiAgICAgICAgICAgIHYgPSBjb21wb25lbnQudjsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IHY7IGorKykgewogICAgICAgICAgICAgIGZvciAoayA9IDA7IGsgPCBoOyBrKyspIHsKICAgICAgICAgICAgICAgIGRlY29kZU1jdShjb21wb25lbnQsIGRlY29kZUZuLCBtY3UsIGosIGspOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBiaXRzQ291bnQgPSAwOwogICAgZmlsZU1hcmtlciA9IGZpbmROZXh0RmlsZU1hcmtlcihkYXRhLCBvZmZzZXQpOwogICAgaWYgKCFmaWxlTWFya2VyKSB7CiAgICAgIGJyZWFrOwogICAgfQogICAgaWYgKGZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gbWN1VG9SZWFkID4gMCA/ICJ1bmV4cGVj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djYgPSB0OwogICAgcDAgPSB2MCArIHY3OwogICAgcDcgPSB2MCAtIHY3OwogICAgcDEgPSB2MSArIHY2OwogICAgcDYgPSB2MSAtIHY2OwogICAgcDIgPSB2MiArIHY1OwogICAgcDUgPSB2MiAtIHY1OwogICAgcDMgPSB2MyArIHY0OwogICAgcDQgPSB2MyAtIHY0OwogICAgaWYgKHAwIDwgMTYpIHsKICAgICAgcDAgPSAwOwogICAgfSBlbHNlIGlmIChwMCA+PSA0MDgwKSB7CiAgICAgIHAwID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDAgPj49IDQ7CiAgICB9CiAgICBpZiAocDEgPCAxNikgewogICAgICBwMSA9IDA7CiAgICB9IGVsc2UgaWYgKHAxID49IDQwODApIHsKICAgICAgcDEgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwMSA+Pj0gNDsKICAgIH0KICAgIGlmIChwMiA8IDE2KSB7CiAgICAgIHAyID0gMDsKICAgIH0gZWxzZSBpZiAocDIgPj0gNDA4MCkgewogICAgICBwMiA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHAyID4+PSA0OwogICAgfQogICAgaWYgKHAzIDwgMTYpIHsKICAgICAgcDMgPSAwOwogICAgfSBlbHNlIGlmIChwMyA+PSA0MDgwKSB7CiAgICAgIHAzID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDMgPj49IDQ7CiAgICB9CiAgICBpZiAocDQgPCAxNikgewogICAgICBwNCA9IDA7CiAgICB9IGVsc2UgaWYgKHA0ID49IDQwODApIHsKICAgICAgcDQgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNCA+Pj0gNDsKICAgIH0KICAgIGlmIChwNSA8IDE2KSB7CiAgICAgIHA1ID0gMDsKICAgIH0gZWxzZSBpZiAocDUgPj0gNDA4MCkgewogICAgICBwNSA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHA1ID4+PSA0OwogICAgfQogICAgaWYgKHA2IDwgMTYpIHsKICAgICAgc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1hcmtlciAhPT0gMHhmZmQ4KSB7CiAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIlNPSSBub3QgZm91bmQiKTsKICAgIH0KICAgIGZpbGVNYXJrZXIgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgIG9mZnNldCArPSAyOwogICAgbWFya2VyTG9vcDogd2hpbGUgKGZpbGVNYXJrZXIgIT09IDB4ZmZkOSkgewogICAgICBsZXQgaSwgaiwgbDsKICAgICAgc3dpdGNoIChmaWxlTWFya2VyKSB7CiAgICAgICAgY2FzZSAweGZmZTA6CiAgICAgICAgY2FzZSAweGZmZTE6CiAgICAgICAgY2FzZSAweGZmZTI6CiAgICAgICAgY2FzZSAweGZmZTM6CiAgICAgICAgY2FzZSAweGZmZTQ6CiAgICAgICAgY2FzZSAweGZmZTU6CiAgICAgICAgY2FzZSAweGZmZTY6CiAgICAgICAgY2FzZSAweGZmZTc6CiAgICAgICAgY2FzZSAweGZmZTg6CiAgICAgICAgY2FzZSAweGZmZTk6CiAgICAgICAgY2FzZSAweGZmZWE6CiAgICAgICAgY2FzZSAweGZmZWI6CiAgICAgICAgY2FzZSAweGZmZWM6CiAgICAgICAgY2FzZSAweGZmZWQ6CiAgICAgICAgY2FzZSAweGZmZWU6CiAgICAgICAgY2FzZSAweGZmZWY6CiAgICAgICAgY2FzZSAweGZmZmU6CiAgICAgICAgICBjb25zdCBhcHBEYXRhID0gcmVhZERhdGFCbG9jaygpOwogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlMCkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0YSAmJiBhcHBEYXRhWzFdID09PSAweDQ2ICYmIGFwcERhdGFbMl0gPT09IDB4NDkgJiYgYXBwRGF0YVszXSA9PT0gMHg0NiAmJiBhcHBEYXRhWzRdID09PSAwKSB7CiAgICAgICAgICAgICAgamZpZiA9IHsKICAgICAgICAgICAgICAgIHZlcnNpb246IHsKICAgICAgICAgICAgICAgICAgbWFqb3I6IGFwcERhdGFbNV0sCiAgICAgICAgICAgICAgICAgIG1pbm9yOiBhcHBEYXRhWzZdCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZGVuc2l0eVVuaXRzOiBhcHBEYXRhWzddLAogICAgICAgICAgICAgICAgeERlbnNpdHk6IGFwcERhdGFbOF0gPDwgOCB8IGFwcERhdGFbOV0sCiAgICAgICAgICAgICAgICB5RGVuc2l0eTogYXBwRGF0YVsxMF0gPDwgOCB8IGFwcERhdGFbMTFdLAogICAgICAgICAgICAgICAgdGh1bWJXaWR0aDogYXBwRGF0YVsxMl0sCiAgICAgICAgICAgICAgICB0aHVtYkhlaWdodDogYXBwRGF0YVsxM10sCiAgICAgICAgICAgICAgICB0aHVtYkRhdGE6IGFwcERhdGEuc3ViYXJyYXkoMTQsIDE0ICsgMyAqIGFwcERhdGFbMTJdICogYXBwRGF0YVsxM10pCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlZSkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0MSAmJiBhcHBEYXRhWzFdID09PSAweDY0ICYmIGFwcERhdGFbMl0gPT09IDB4NmYgJiYgYXBwRGF0YVszXSA9PT0gMHg2MiAmJiBhcHBEYXRhWzRdID09PSAweDY1KSB7CiAgICAgICAgICAgICAgYWRvYmUgPSB7CiAgICAgICAgICAgICAgICB2ZXJzaW9uOiBhcHBEYXRhWzVdIDw8IDggfCBhcHBEYXRhWzZdLAogICAgICAgICAgICAgICAgZmxhZ3MwOiBhcHBEYXRhWzddIDw8IDggfCBhcHBEYXRhWzhdLAogICAgICAgICAgICAgICAgZmxhZ3MxOiBhcHBEYXRhWzldIDw8IDggfCBhcHBEYXRhWzEwXSwKICAgICAgICAgICAgICAgIHRyYW5zZm9ybUNvZGU6IGFwcERhdGFbMTFdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGI6CiAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZXNMZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgY29uc3QgcXVhbnRpemF0aW9uVGFibGVzRW5kID0gcXVhbnRpemF0aW9uVGFibGVzTGVuZ3RoICsgb2Zmc2V0IC0gMjsKICAgICAgICAgIGxldCB6OwogICAgICAgICAgd2hpbGUgKG9mZnNldCA8IHF1YW50aXphdGlvblRhYmxlc0VuZCkgewogICAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZVNwZWMgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgY29uc3QgdGFibGVEYXRhID0gbmV3IFVpbnQxNkFycmF5KDY0KTsKICAgICAgICAgICAgaWYgKHF1YW50aXphdGlvblRhYmxlU3BlYyA+PiA0ID09PSAwKSB7CiAgICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyBqKyspIHsKICAgICAgICAgICAgICAgIHogPSBkY3RaaWdaYWdbal07CiAgICAgICAgICAgICAgICB0YWJsZURhdGFbel0gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSBpZiAocXVhbnRpemF0aW9uVGFibGVTcGVjID4+IDQgPT09IDEpIHsKICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7IGorKykgewogICAgICAgICAgICAgICAgeiA9IGRjdFppZ1phZ1tqXTsKICAgICAgICAgICAgICAgIHRhYmxlRGF0YVt6XSA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIkRRVCAtIGludmFsaWQgdGFibGUgc3BlYyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlc1txdWFudGl6YXRpb25UYWJsZVNwZWMgJiAxNV0gPSB0YWJsZURhdGE7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZjMDoKICAgICAgICBjYXNlIDB4ZmZjMToKICAgICAgICBjYXNlIDB4ZmZjMjoKICAgICAgICAgIGlmIChmcmFtZSkgewogICAgICAgICAgICB0aHJvdyBuZXcgSnBlZ0Vycm9yKCJPbmx5IHNpbmdsZSBmcmFtZSBKUEVHcyBzdXBwb3J0ZWQiKTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUgPSB7fTsKICAgICAgICAgIGZyYW1lLmV4dGVuZGVkID0gZmlsZU1hcmtlciA9PT0gMHhmZmMxOwogICAgICAgICAgZnJhbWUucHJvZ3Jlc3NpdmUgPSBmaWxlTWFya2VyID09PSAweGZmYzI7CiAgICAgICAgICBmcmFtZS5wcmVjaXNpb24gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGNvbnN0IHNvZlNjYW5MaW5lcyA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmcmFtZS5zY2FuTGluZXMgPSBkbmxTY2FuTGluZXMgfHwgc29mU2NhbkxpbmVzOwogICAgICAgICAgZnJhbWUuc2FtcGxlc1BlckxpbmUgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50cyA9IFtdOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50SWRzID0ge307CiAgICAgICAgICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGxldCBtYXhIID0gMCwKICAgICAgICAgICAgbWF4ViA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3QgY29tcG9uZW50SWQgPSBkYXRhW29mZnNldF07CiAgICAgICAgICAgIGNvbnN0IGggPSBkYXRhW29mZnNldCArIDFdID4+IDQ7CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhW29mZnNldCArIDFdICYgMTU7CiAgICAgICAgICAgIGlmIChtYXhIIDwgaCkgewogICAgICAgICAgICAgIG1heEggPSBoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChtYXhWIDwgdikgewogICAgICAgICAgICAgIG1heFYgPSB2OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHFJZCA9IGRhdGFbb2Zmc2V0ICsgMl07CiAgICAgICAgICAgIGwgPSBmcmFtZS5jb21wb25lbnRzLnB1c2goewogICAgICAgICAgICAgIGgsCiAgICAgICAgICAgICAgdiwKICAgICAgICAgICAgICBxdWFudGl6YXRpb25JZDogcUlkLAogICAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlOiBudWxsCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBmcmFtZS5jb21wb25lbnRJZHNbY29tcG9uZW50SWRdID0gbCAtIDE7CiAgICAgICAgICAgIG9mZnNldCArPSAzOwogICAgICAgICAgfQogICAgICAgICAgZnJhbWUubWF4SCA9IG1heEg7CiAgICAgICAgICBmcmFtZS5tYXhWID0gbWF4VjsKICAgICAgICAgIHByZXBhcmVDb21wb25lbnRzKGZyYW1lKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmM0OgogICAgICAgICAgY29uc3QgaHVmZm1hbkxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmb3IgKGkgPSAyOyBpIDwgaHVmZm1hbkxlbmd0aDspIHsKICAgICAgICAgICAgY29uc3QgaHVmZm1hblRhYmxlU3BlYyA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb2RlTGVuZ3RocyA9IG5ldyBVaW50OEFycmF5KDE2KTsKICAgICAgICAgICAgbGV0IGNvZGVMZW5ndGhTdW0gPSAwOwogICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgMTY7IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBjb2RlTGVuZ3RoU3VtICs9IGNvZGVMZW5ndGhzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGh1ZmZtYW5WYWx1ZXMgPSBuZXcgVWludDhBcnJheShjb2RlTGVuZ3RoU3VtKTsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IGNvZGVMZW5ndGhTdW07IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBodWZmbWFuVmFsdWVzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGkgKz0gMTcgKyBjb2RlTGVuZ3RoU3VtOwogICAgICAgICAgICAoaHVmZm1hblRhYmxlU3BlYyA+PiA0ID09PSAwID8gaHVmZm1hblRhYmxlc0RDIDogaHVmZm1hblRhYmxlc0FDKVtodWZmbWFuVGFibGVTcGVjICYgMTVdID0gYnVpbGRIdWZmbWFuVGFibGUoY29kZUxlbmd0aHMsIGh1ZmZtYW5WYWx1ZXMpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGQ6CiAgICAgICAgICBvZmZzZXQgKz0gMjsKICAgICAgICAgIHJlc2V0SW50ZXJ2YWwgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGE6CiAgICAgICAgICBjb25zdCBwYXJzZUROTE1hcmtlciA9ICsrbnVtU09TTWFya2VycyA9PT0gMSAmJiAhZG5sU2NhbkxpbmVzOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBjb25zdCBzZWxlY3RvcnNDb3VudCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBjb21wb25lbnRzID0gW107CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgc2VsZWN0b3JzQ291bnQ7IGkrKykgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb21wb25lbnRJbmRleCA9IGZyYW1lLmNvbXBvbmVudElkc1tpbmRleF07CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudCA9IGZyYW1lLmNvbXBvbmVudHNbY29tcG9uZW50SW5kZXhdOwogICAgICAgICAgICBjb21wb25lbnQuaW5kZXggPSBpbmRleDsKICAgICAgICAgICAgY29uc3QgdGFibGVTcGVjID0gZGF0YVtvZmZzZXQrK107CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVEQyA9IGh1ZmZtYW5UYWJsZXNEQ1t0YWJsZVNwZWMgPj4gNF07CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyA9IGh1ZmZtYW5UYWJsZXNBQ1t0YWJsZVNwZWMgJiAxNV07CiAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3BlY3RyYWxTdGFydCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzcGVjdHJhbEVuZCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzdWNjZXNzaXZlQXBwcm94aW1hdGlvbiA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkID0gZGVjb2RlU2NhbihkYXRhLCBvZmZzZXQsIGZyYW1lLCBjb21wb25lbnRzLCByZXNldEludGVydmFsLCBzcGVjdHJhbFN0YXJ0LCBzcGVjdHJhbEVuZCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gPj4gNCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gJiAxNSwgcGFyc2VETkxNYXJrZXIpOwogICAgICAgICAgICBvZmZzZXQgKz0gcHJvY2Vzc2VkOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgRE5MTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gYXR0ZW1wdGluZyB0byByZS1wYXJzZSB0aGUgSlBFRyBpbWFnZS5gKTsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5wYXJzZShkYXRhLCB7CiAgICAgICAgICAgICAgICBkbmxTY2FuTGluZXM6IGV4LnNjYW5MaW5lcwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgRU9JTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gaWdub3JpbmcgdGhlIHJlc3Qgb2YgdGhlIGltYWdlIGRhdGEuYCk7CiAgICAgICAgICAgICAgYnJlYWsgbWFya2VyTG9vcDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmRjOgogICAgICAgICAgb2Zmc2V0ICs9IDQ7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZmZjoKICAgICAgICAgIGlmIChkYXRhW29mZnNldF0gIT09IDB4ZmYpIHsKICAgICAgICAgICAgb2Zmc2V0LS07CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgY29uc3QgbmV4dEZpbGVNYXJrZXIgPSBmaW5kTmV4dEZpbGVNYXJrZXIoZGF0YSwgb2Zmc2V0IC0gMiwgb2Zmc2V0IC0gMyk7CiAgICAgICAgICBpZiAobmV4dEZpbGVNYXJrZXIgJiYgbmV4dEZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHVuZXhwZWN0ZWQgZGF0YSwgY3VycmVudCBtYXJrZXIgaXM6ICIgKyBuZXh0RmlsZU1hcmtlci5pbnZhbGlkKTsKICAgICAgICAgICAgb2Zmc2V0ID0gbmV4dEZpbGVNYXJrZXIub2Zmc2V0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghbmV4dEZpbGVNYXJrZXIgfHwgb2Zmc2V0ID49IGRhdGEubGVuZ3RoIC0gMSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHJlYWNoZWQgdGhlIGVuZCBvZiB0aGUgaW1hZ2UgZGF0YSAiICsgIndpdGhvdXQgZmluZGluZyBhbiBFT0kgbWFya2VyICgweEZGRDkpLiIpOwogICAgICAgICAgICBicmVhayBtYXJrZXJMb29wOwogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IEpwZWdFcnJvcigiSnBlZ0ltYWdlLnBhcnNlIC0gdW5rbm93biBtYXJrZXI6ICIgKyBmaWxlTWFya2VyLnRvU3RyaW5nKDE2KSk7CiAgICAgIH0KICAgICAgZmlsZU1hcmtlciA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICBvZmZzZXQgKz0gMjsKICAgIH0KICAgIHRoaXMud2lkdGggPSBmcmFtZS5zYW1wbGVzUGVyTGluZTsKICAgIHRoaXMuaGVpZ2h0ID0gZnJhbWUuc2NhbkxpbmVzOwogICAgdGhpcy5qZmlmID0gamZpZjsKICAgIHRoaXMuYWRvYmUgPSBhZG9iZTsKICAgIHRoaXMuY29tcG9uZW50cyA9IFtdOwogICAgZm9yIChjb25zdCBjb21wb25lbnQgb2YgZnJhbWUuY29tcG9uZW50cykgewogICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZSA9IHF1YW50aXphdGlvblRhYmxlc1tjb21wb25lbnQucXVhbnRpemF0aW9uSWRdOwogICAgICBpZiAocXVhbnRpemF0aW9uVGFibGUpIHsKICAgICAgICBjb21wb25lbnQucXVhbnRpemF0aW9uVGFibGUgPSBxdWFudGl6YXRpb25UYWJsZTsKICAgICAgfQogICAgICB0aGlzLmNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgaW5kZXg6IGNvbXBvbmVudC5pbmRleCwKICAgICAgICBvdXRwdXQ6IGJ1aWxkQ29tcG9uZW50RGF0YShmcmFtZSwgY29tcG9uZW50KSwKICAgICAgICBzY2FsZVg6IGNvbXBvbmVudC5oIC8gZnJhbWUubWF4SCwKICAgICAgICBzY2FsZVk6IGNvbXBvbmVudC52IC8gZnJhbWUubWF4ViwKICAgICAgICBibG9ja3NQZXJMaW5lOiBjb21wb25lbnQuYmxvY2tzUGVyTGluZSwKICAgICAgICBibG9ja3NQZXJDb2x1bW46IGNvbXBvbmVudC5ibG9ja3NQZXJDb2x1bW4KICAgICAgfSk7CiAgICB9CiAgICB0aGlzLm51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogICAgcmV0dXJuIHVuZGVmaW5lZDsKICB9CiAgX2dldExpbmVhcml6ZWRCbG9ja0RhdGEod2lkdGgsIGhlaW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dGFMZW5ndGg7KSB7CiAgICAgICAgZm9yIChqID0gMCwgayA9IDA7IGogPCBudW1Db21wb25lbnRzOyBqKyssIGkrKywgayArPSAyKSB7CiAgICAgICAgICBkYXRhW2ldID0gKGRhdGFbaV0gKiB0cmFuc2Zvcm1ba10gPj4gOCkgKyB0cmFuc2Zvcm1bayArIDFdOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGRhdGE7CiAgfQogIGdldCBfaXNDb2xvckNvbnZlcnNpb25OZWVkZWQoKSB7CiAgICBpZiAodGhpcy5hZG9iZSkgewogICAgICByZXR1cm4gISF0aGlzLmFkb2JlLnRyYW5zZm9ybUNvZGU7CiAgICB9CiAgICBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSAzKSB7CiAgICAgIGlmICh0aGlzLl9jb2xvclRyYW5zZm9ybSA9PT0gMCkgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfSBlbHNlIGlmICh0aGlzLmNvbXBvbmVudHNbMF0uaW5kZXggPT09IDB4NTIgJiYgdGhpcy5jb21wb25lbnRzWzFdLmluZGV4ID09PSAweDQ3ICYmIHRoaXMuY29tcG9uZW50c1syXS5pbmRleCA9PT0gMHg0MikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGlmICh0aGlzLl9jb2xvclRyYW5zZm9ybSA9PT0gMSkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKICB9CiAgX2NvbnZlcnRZY2NUb1JnYihkYXRhKSB7CiAgICBsZXQgWSwgQ2IsIENyOwogICAgZm9yIChsZXQgaSA9IDAsIGxlbmd0aCA9IGRhdGEubGVuZ3RoOyBpIDwgbGVuZ3RoOyBpICs9IDMpIHsKICAgICAgWSA9IGRhdGFbaV07CiAgICAgIENiID0gZGF0YVtpICsgMV07CiAgICAgIENyID0gZGF0YVtpICsgMl07CiAgICAgIGRhdGFb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dGlvbiArPSA4OwogICAgICAgIGhlYWRlclNpemUgKz0gODsKICAgICAgfQogICAgICBpZiAobGJveCA9PT0gMCkgewogICAgICAgIGxib3ggPSBsZW5ndGggLSBwb3NpdGlvbiArIGhlYWRlclNpemU7CiAgICAgIH0KICAgICAgaWYgKGxib3ggPCBoZWFkZXJTaXplKSB7CiAgICAgICAgdGhyb3cgbmV3IEpweEVycm9yKCJJbnZhbGlkIGJveCBmaWVsZCBzaXplIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUxlbmd0aCA9IGxib3ggLSBoZWFkZXJTaXplOwogICAgICBsZXQganVtcERhdGFMZW5ndGggPSB0cnVlOwogICAgICBzd2l0Y2ggKHRib3gpIHsKICAgICAgICBjYXNlIDB4NmE3MDMyNjg6CiAgICAgICAgICBqdW1wRGF0YUxlbmd0aCA9IGZhbHNlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDYzNmY2YzcyOgogICAgICAgICAgY29uc3QgbWV0aG9kID0gZGF0YVtwb3NpdGlvbl07CiAgICAgICAgICBpZiAobWV0aG9kID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yc3BhY2UgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzKTsKICAgICAgICAgICAgc3dpdGNoIChjb2xvcnNwYWNlKSB7CiAgICAgICAgICAgICAgY2FzZSAxNjoKICAgICAgICAgICAgICBjYXNlIDE3OgogICAgICAgICAgICAgIGNhc2UgMTg6CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmtub3duIGNvbG9yc3BhY2UgIiArIGNvbG9yc3BhY2UpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAobWV0aG9kID09PSAyKSB7CiAgICAgICAgICAgICgwLCBf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KICAgICAgbGV0IHBvc2l0aW9uID0gc3RhcnQ7CiAgICAgIHdoaWxlIChwb3NpdGlvbiArIDEgPCBlbmQpIHsKICAgICAgICBjb25zdCBjb2RlID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIGxldCBsZW5ndGggPSAwLAogICAgICAgICAgaiwKICAgICAgICAgIHNxY2QsCiAgICAgICAgICBzcHFjZHMsCiAgICAgICAgICBzcHFjZFNpemUsCiAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQsCiAgICAgICAgICB0aWxlOwogICAgICAgIHN3aXRjaCAoY29kZSkgewogICAgICAgICAgY2FzZSAweGZmNGY6CiAgICAgICAgICAgIGNvbnRleHQubWFpbkhlYWRlciA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmZDk6CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTE6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHNpeiA9IHt9OwogICAgICAgICAgICBzaXouWHNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICBzaXouWXNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDgpOwogICAgICAgICAgICBzaXouWE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAxMik7CiAgICAgICAgICAgIHNpei5ZT3NpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDE2KTsKICAgICAgICAgICAgc2l6LlhUc2l6ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uICsgMjApOwogICAgICAgICAgICBzaXouWVRzaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyNCk7CiAgICAgICAgICAgIHNpei5YVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyOCk7CiAgICAgICAgICAgIHNpei5ZVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzMik7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDM2KTsKICAgICAgICAgICAgc2l6LkNzaXogPSBjb21wb25lbnRzQ291bnQ7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHMgPSBbXTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMzg7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB7CiAgICAgICAgICAgICAgICBwcmVjaXNpb246IChkYXRhW2pdICYgMHg3ZikgKyAxLAogICAgICAgICAgICAgICAgaXNTaWduZWQ6ICEhKGRhdGFbal0gJiAweDgwKSwKICAgICAgICAgICAgICAgIFhSc2l6OiBkYXRhW2ogKyAxXSwKICAgICAgICAgICAgICAgIFlSc2l6OiBkYXRhW2ogKyAyXQogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgaiArPSAzOwogICAgICAgICAgICAgIGNhbGN1bGF0ZUNvbXBvbmVudERpbWVuc2lvbnMoY29tcG9uZW50LCBzaXopOwogICAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnRleHQuU0laID0gc2l6OwogICAgICAgICAgICBjb250ZXh0LmNvbXBvbmVudHMgPSBjb21wb25lbnRzOwogICAgICAgICAgICBjYWxjdWxhdGVUaWxlR3JpZHMoY29udGV4dCwgY29tcG9uZW50cyk7CiAgICAgICAgICAgIGNvbnRleHQuUUNDID0gW107CiAgICAgICAgICAgIGNvbnRleHQuQ09DID0gW107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNWM6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHFjZCA9IHt9OwogICAgICAgICAgICBqID0gcG9zaXRpb24gKyAyOwogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Qubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjZC5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjZC5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2QuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0QgPSBxY2Q7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0QgPSBxY2Q7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0MgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMHhmZjVkOgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBjb25zdCBxY2MgPSB7fTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMjsKICAgICAgICAgICAgbGV0IGNxY2M7CiAgICAgICAgICAgIGlmIChjb250ZXh0LlNJWi5Dc2l6IDwgMjU3KSB7CiAgICAgICAgICAgICAgY3FjYyA9IGRhdGFbaisrXTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjcWNjID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIGopOwogICAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgfQogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Mubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjYy5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjYy5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2MuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDB4ZmY1MjoKICAgICAgICAgICAgbGVuZ3RoID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICAgICAgY29uc3QgY29kID0ge307CiAgICAgICAgICAgIGogPSBwb3NpdGlvbiArIDI7CiAgICAgICAgICAgIGNvbnN0IHNjb2QgPSBkYXRhW2orK107CiAgICAgICAgICAgIGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzID0gISEoc2NvZCAmIDEpOwogICAgICAgICAgICBjb2Quc29wTWFya2VyVXNlZCA9ICEhKHNjb2QgJiAyKTsKICAgICAgICAgICAgY29kLmVwaE1hcmtlclVzZWQgPSAhIShzY29kICYgNCk7CiAgICAgICAgICAgIGNvZC5wcm9ncmVzc2lvbk9yZGVyID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QubGF5ZXJzQ291bnQgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgaik7CiAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgY29kLm11bHRpcGxlQ29tcG9uZW50VHJhbnNmb3JtID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QueGNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb2QueWNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb25zdCBibG9ja1N0eWxlID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2Quc2VsZWN0aXZlQXJpdGhtZXRpY0NvZGluZ0J5cGFzcyA9ICEhKGJsb2NrU3R5bGUgJiAxKTsKICAgICAgICAgICAgY29kLnJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMgPSAhIShibG9ja1N0eWxlICYgMik7CiAgICAgICAgICAgIGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MgPSAhIShibG9ja1N0eWxlICYgNCk7CiAgICAgICAgICAgIGNvZC52ZXJ0aWNhbGx5U3RyaXBlID0gISEoYmxvY2tTdHlsZSAmIDgpOwogICAgICAgICAgICBjb2QucHJlZGljdGFibGVUZXJtaW5hdGlvbiA9ICEhKGJsb2NrU3R5bGUgJiAxNik7CiAgICAgICAgICAgIGNvZC5zZWdtZW50YXRpb25TeW1ib2xVc2VkID0gISEoYmxvY2tTdHlsZSAmIDMyKTsKICAgICAgICAgICAgY29kLnJldmVyc2libGVUcmFuc2Zvcm1hdGlvbiA9IGRhdGFbaisrXTsKICAgICAgICAgICAgaWYgKGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzKSB7CiAgICAgICAgICAgICAgY29uc3QgcHJlY2luY3RzU2l6ZXMgPSBbXTsKICAgICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwcmVjaW5jdHNTaXplID0gZGF0YVtqKytdOwogICAgICAgICAgICAgICAgcHJlY2luY3RzU2l6ZXMucHVzaCh7CiAgICAgICAgICAgICAgICAgIFBQeDogcHJlY2luY3RzU2l6ZSAmIDB4ZiwKICAgICAgICAgICAgICAgICAgUFB5OiBwcmVjaW5jdHNTaXplID4+IDQKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2QucHJlY2luY3RzU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCB1bnN1cHBvcnRlZCA9IFtdOwogICAgICAgICAgICBpZiAoY29kLnNlbGVjdGl2ZUFyaXRobWV0aWNDb2RpbmdCeXBhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJzZWxlY3RpdmVBcml0aG1ldGljQ29kaW5nQnlwYXNzIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ0ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY29kLnZlcnRpY2FsbHlTdHJpcGUpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ2ZXJ0aWNhbGx5U3RyaXBlIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC5wcmVkaWN0YWJsZVRlcm1pbmF0aW9uKSB7CiAgICAgICAgICAgICAgdW5zdXBwb3J0ZWQucHVzaCgicHJlZGljdGFibGVUZXJtaW5hdGlvbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh1bnN1cHBvcnRlZC5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgZG9Ob3RSZWNvdmVyID0gdHJ1ZTsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEpQWDogVW5zdXBwb3J0ZWQgQ09EIG9wdGlvbnMgKCR7dW5zdXBwb3J0ZWQuam9pbigiLCAiKX0pLmApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb250ZXh0Lm1haW5IZWFkZXIpIHsKICAgICAgICAgICAgICBjb250ZXh0LkNPRCA9IGNvZDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPRCA9IGNvZDsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPQyA9IFtdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTA6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIHRpbGUgPSB7fTsKICAgICAgICAgICAgdGlsZS5pbmRleCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDIpOwogICAgICAgICAgICB0aWxlLmxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICB0aWxlLmRhdGFFbmQgPSB0aWxlLmxlbmd0aCArIHBvc2l0aW9uIC0gMjsKICAgICAgICAgICAgdGlsZS5wYXJ0SW5kZXggPSBkYXRhW3Bvc2l0aW9uICsgOF07CiAgICAgICAgICAgIHRpbGUucGFydHNDb3VudCA9IGRhdGFbcG9zaXRpb24gKyA5XTsKICAgICAgICAgICAgY29udGV4dC5tYWluSGVhZGVyID0gZmFsc2U7CiAgICAgICAgICAgIGlmICh0aWxlLnBhcnRJbmRleCA9PT0gMCkgewogICAgICAgICAgICAgIHRpbGUuQ09EID0gY29udGV4dC5DT0Q7CiAgICAgICAgICAgICAgdGlsZS5DT0MgPSBjb250ZXh0LkNPQy5zbGljZSgwKTsKICAgICAgICAgICAgICB0aWxlLlFDRCA9IGNvbnRleHQuUUNEOwogICAgICAgICAgICAgIHRpbGUuUUNDID0gY29udGV4dC5RQ0Muc2xpY2UoMCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZSA9IHRpbGU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTM6CiAgICAgICAgICAgIHRpbGUgPSBjb250ZXh0LmN1cnJlbnRUaWxlOwogICAgICAgICAgICBpZiAodGlsZS5wYXJ0SW5kZXggPT09IDApIHsKICAgICAgICAgICAgICBpbml0aWFsaXplVGlsZShjb250ZXh0LCB0aWxlLmluZGV4KTsKICAgICAgICAgICAgICBidWlsZFBhY2tldHMoY29udGV4dCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGVuZ3RoID0gdGlsZS5kYXRhRW5kIC0gcG9zaXRpb247CiAgICAgICAgICAgIHBhcnNlVGlsZVBhY2tldHMoY29udGV4dCwgZGF0YSwgcG9zaXRpb24sIGxlbmd0aCk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTM6CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSlBYOiBD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l6KTsKICAgICAgdGlsZS50eDEgPSBNYXRoLm1pbihzaXouWFRPc2l6ICsgKHAgKyAxKSAqIHNpei5YVHNpeiwgc2l6LlhzaXopOwogICAgICB0aWxlLnR5MSA9IE1hdGgubWluKHNpei5ZVE9zaXogKyAocSArIDEpICogc2l6LllUc2l6LCBzaXouWXNpeik7CiAgICAgIHRpbGUud2lkdGggPSB0aWxlLnR4MSAtIHRpbGUudHgwOwogICAgICB0aWxlLmhlaWdodCA9IHRpbGUudHkxIC0gdGlsZS50eTA7CiAgICAgIHRpbGUuY29tcG9uZW50cyA9IFtdOwogICAgICB0aWxlcy5wdXNoKHRpbGUpOwogICAgfQogIH0KICBjb250ZXh0LnRpbGVzID0gdGlsZXM7CiAgY29uc3QgY29tcG9uZW50c0NvdW50ID0gc2l6LkNzaXo7CiAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29tcG9uZW50c0NvdW50OyBpIDwgaWk7IGkrKykgewogICAgY29uc3QgY29tcG9uZW50ID0gY29tcG9uZW50c1tpXTsKICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHRpbGVzLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgdGlsZUNvbXBvbmVudCA9IHt9OwogICAgICB0aWxlID0gdGlsZXNbal07CiAgICAgIHRpbGVDb21wb25lbnQudGN4MCA9IE1hdGguY2VpbCh0aWxlLnR4MCAvIGNvbXBvbmVudC5YUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQudGN5MCA9IE1hdGguY2VpbCh0aWxlLnR5MCAvIGNvbXBvbmVudC5ZUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQudGN4MSA9IE1hdGguY2VpbCh0aWxlLnR4MSAvIGNvbXBvbmVudC5YUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQudGN5MSA9IE1hdGguY2VpbCh0aWxlLnR5MSAvIGNvbXBvbmVudC5ZUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQud2lkdGggPSB0aWxl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yA9IE1hdGgubWF4KHN1YmJhbmQudGJ4MCwgY29kZWJsb2NrLnRieDApOwogICAgICBjb2RlYmxvY2sudGJ5MF8gPSBNYXRoLm1heChzdWJiYW5kLnRieTAsIGNvZGVibG9jay50YnkwKTsKICAgICAgY29kZWJsb2NrLnRieDFfID0gTWF0aC5taW4oc3ViYmFuZC50YngxLCBjb2RlYmxvY2sudGJ4MSk7CiAgICAgIGNvZGVibG9jay50YnkxXyA9IE1hdGgubWluKHN1YmJhbmQudGJ5MSwgY29kZWJsb2NrLnRieTEpOwogICAgICBjb25zdCBwaSA9IE1hdGguZmxvb3IoKGNvZGVibG9jay50YngwXyAtIHN1YmJhbmQudGJ4MCkgLyBwcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RXaWR0aEluU3ViYmFuZCk7CiAgICAgIGNvbnN0IHBqID0gTWF0aC5mbG9vcigoY29kZWJsb2NrLnRieTBfIC0gc3ViYmFuZC50YnkwKSAvIHByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdEhlaWdodEluU3ViYmFuZCk7CiAgICAgIHByZWNpbmN0TnVtYmVyID0gcGkgKyBwaiAqIHByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHN3aWRlOwogICAgICBjb2RlYmxvY2sucHJlY2luY3ROdW1iZXIgPSBwcmVjaW5jdE51bWJlcjsKICAgICAgY29kZWJsb2NrLnN1YmJhbmRUeXBlID0gc3ViYmFuZC50eXBlOwogICAgICBjb2RlYmxvY2suTGJsb2NrID0gMzsKICAgICAgaWYgKGNvZGVibG9jay50YngxXyA8PSBjb2RlYmxvY2sudGJ4MF8gfHwgY29kZWJsb2NrLnRieTFfIDw9IGNvZGVibG9jay50YnkwXykgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvZGVibG9ja3MucHVzaChjb2RlYmxvY2spOwogICAgICBsZXQgcHJlY2luY3QgPSBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdOwogICAgICBpZiAocHJlY2luY3QgIT09IHVuZGVmaW5lZCkgewogICAgICAgIGlmIChpIDwgcHJlY2luY3QuY2J4TWluKSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnhNaW4gPSBpOwogICAgICAgIH0gZWxzZSBpZiAoaSA+IHByZWNpbmN0LmNieE1heCkgewogICAgICAgICAgcHJlY2luY3QuY2J4TWF4ID0gaTsKICAgICAgICB9CiAgICAgICAgaWYgKGogPCBwcmVjaW5jdC5jYnlNaW4pIHsKICAgICAgICAgIHByZWNpbmN0LmNieE1pbiA9IGo7CiAgICAgICAgfSBlbHNlIGlmIChqID4gcHJlY2luY3QuY2J5TWF4KSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnlNYXggPSBqOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdID0gcHJlY2luY3QgPSB7CiAgICAgICAgICBjYnhNaW46IGksCiAgICAgICAgICBjYnlNaW46IGosCiAgICAgICAgICBjYnhNYXg6IGksCiAgICAgICAgICBjYnlNYXg6IGoKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvZGVibG9jay5wcmVjaW5jdCA9IHByZWNpbmN0OwogICAgfQogIH0KICBzdWJiYW5kLmNvZGVibG9ja1BhcmFtZXRlcnMgPSB7CiAgICBjb2RlYmxvY2tXaWR0aDogeGNiXywKICAgIGNvZGVibG9ja0hlaWdodDogeWNiXywKICAgIG51bWNvZGVibG9ja3dpZGU6IGNieDEgLSBjYngwICsgMSwKICAgIG51bWNvZGVibG9ja2hpZ2g6IGNieTEgLSBjYnkwICsgMQogIH07CiAgc3ViYmFuZC5jb2RlYmxvY2tzID0gY29kZWJsb2NrczsKICBzdWJiYW5kLnByZWNpbmN0cyA9IHByZWNpbmN0czsKfQpmdW5jdGlvbiBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgcHJlY2luY3ROdW1iZXIsIGxheWVyTnVtYmVyKSB7CiAgY29uc3QgcHJlY2luY3RDb2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HNDb3VudDsgcSsrKSB7CiAgICBtYXhEZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBNYXRoLm1heChtYXhEZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQsIHRpbGUuY29tcG9uZW50c1txXS5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KTsKICB9CiAgbGV0IGwgPSAwLAogICAgciA9IDAsCiAgICBpID0gMCwKICAgIGsgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OyBsKyspIHsKICAgICAgZm9yICg7IHIgPD0gbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50OyByKyspIHsKICAgICAgICBmb3IgKDsgaSA8IGNvbXBvbmVudHNDb3VudDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOw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CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICBsID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25Qb3NpdGlvbkNvbXBvbmVudExheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBsZXQgbCwgciwgYywgcDsKIC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9IG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgIGZvciAoOyBwIDwgbWF4TnVtUHJlY2luY3RzSW5MZXZlbFtyXTsgcCsrKSB7CiAgICAgICAgZm9yICg7IGMgPCBjb21wb25lbnRzQ291bnQ7IGMrKykgewogICAgICAgICAgY29uc3QgY29tcG9uZW50ID0gdGlsZS5jb21wb25lbnRzW2NdOwogICAgICAgICAgaWYgKHIgPiBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICBjb25zdCBudW1wcmVjaW5jdHMgPSByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHM7CiAgICAgICAgICBpZiAocCA+PSBudW1wcmVjaW5jdHMpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgcCwgbCk7CiAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGwgPSAwOwogICAgICAgIH0KICAgICAgICBjID0gMDsKICAgICAgfQogICAgICBwID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFBvc2l0aW9uQ29tcG9uZW50UmVzb2x1dGlvbkxheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBjb25zdCBwcmVjaW5jdHNTaXplcyA9IGdldFByZWNpbmN0U2l6ZXNJbkltYWdlU2NhbGUodGlsZSk7CiAgY29uc3QgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICBsZXQgbCA9IDAsCiAgICByID0gMCwKICAgIGMgPSAwLAogICAgcHggPSAwLAogICAgcHkgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgcHkgPCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5tYXhOdW1IaWdoOyBweSsrKSB7CiAgICAgIGZvciAoOyBweCA8IHByZWNpbmN0c0l0ZXJhdGlvblNpemVzLm1heE51bVdpZGU7IHB4KyspIHsKICAgICAgICBmb3IgKDsgYyA8IGNvbXBvbmVudHNDb3VudDsgYysrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbY107CiAgICAgICAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdLnJlc29sdXRpb25zW3JdOwogICAgICAgICAgICBjb25zdCBrID0gZ2V0UHJlY2luY3RJbmRleElmRXhpc3QocHgsIHB5LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcywgcmVzb2x1dGlvbik7CiAgICAgICAgICAgIGlmIChrID09PSBudWxsKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yICg7IGwgPCBsYXllcnNDb3VudDspIHsKICAgICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgICAgbCsrOwogICAgICAgICAgICAgIHJldHVybiBwYWNrZXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgYyA9IDA7CiAgICAgIH0KICAgICAgcHggPSAwOwogICAgfQogICAgdGhyb3cgbmV3IEpweEVycm9yKCJPdXQgb2YgcGFja2V0cyIpOwogIH07Cn0KZnVuY3Rpb24gQ29tcG9uZW50UG9zaXRpb25SZXNvbHV0aW9uTGF5ZXJJdGVyYXRvcihjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGxheWVyc0NvdW50ID0gdGlsZS5jb2RpbmdTdHlsZURlZmF1bHRQYXJhbWV0ZXJzLmxheWVyc0NvdW50OwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGNvbnN0IHByZWNpbmN0c1NpemVzID0gZ2V0UHJlY2luY3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AgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoOyBsIDwgbGF5ZXJzQ291bnQ7KSB7CiAgICAgICAgICAgICAgY29uc3QgcGFja2V0ID0gY3JlYXRlUGFja2V0KHJlc29sdXRpb24sIGssIGwpOwogICAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgICByZXR1cm4gcGFja2V0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGwgPSAwOwogICAgICAgICAgfQogICAgICAgICAgciA9IDA7CiAgICAgICAgfQogICAgICAgIHB4ID0gMDsKICAgICAgfQogICAgICBweSA9IDA7CiAgICB9CiAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIk91dCBvZiBwYWNrZXRzIik7CiAgfTsKfQpmdW5jdGlvbiBnZXRQcmVjaW5jdEluZGV4SWZFeGlzdChweEluZGV4LCBweUluZGV4LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdEl0ZXJhdGlvblNpemVzLCByZXNvbHV0aW9uKSB7CiAgY29uc3QgcG9zWCA9IHB4SW5kZXggKiBwcmVjaW5jdEl0ZXJhdGlvblNpemVzLm1pbldpZHRoOwogIGNvbnN0IHBvc1kgPSBweUluZGV4ICogcHJlY2luY3RJdGVyYXRpb25TaXplcy5taW5IZWlnaHQ7CiAgaWYgKHBvc1ggJSBzaXplSW5JbWFnZVNjYWxlLndpZHRoICE9PSAwIHx8IHBvc1kgJSBzaXplSW5JbWFnZVNjYWxlLmhlaWdodCAhPT0gMCkgewogICAgcmV0dXJuIG51bGw7CiAgfQogIGNvbnN0IHN0YXJ0UHJlY2luY3RSb3dJbmRleCA9IHBvc1kgLyBzaXplSW5JbWFnZVNjYWxlLndpZHRoICogcmVzb2x1dGlvbi5wcmVjaW5jdFBhcmFtZXRlcnMubnVtcHJlY2luY3Rzd2lkZTsKICByZXR1cm4gcG9zWCAvIHNpemVJbkltYWdlU2NhbGUuaGVpZ2h0ICsgc3RhcnRQcmVjaW5jdF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QgPSBNYXRoLm1pbihtaW5IZWlnaHQsIG1pbkhlaWdodEN1cnJlbnRDb21wb25lbnQpOwogICAgbWF4TnVtV2lkZSA9IE1hdGgubWF4KG1heE51bVdpZGUsIG1heE51bVdpZGVDdXJyZW50Q29tcG9uZW50KTsKICAgIG1heE51bUhpZ2ggPSBNYXRoLm1heChtYXhOdW1IaWdoLCBtYXhOdW1IaWdoQ3VycmVudENvbXBvbmVudCk7CiAgICBzaXplUGVyQ29tcG9uZW50W2NdID0gewogICAgICByZXNvbHV0aW9uczogc2l6ZVBlclJlc29sdXRpb24sCiAgICAgIG1pbldpZHRoOiBtaW5XaWR0aEN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1pbkhlaWdodDogbWluSGVpZ2h0Q3VycmVudENvbXBvbmVudCwKICAgICAgbWF4TnVtV2lkZTogbWF4TnVtV2lkZUN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1heE51bUhpZ2g6IG1heE51bUhpZ2hDdXJyZW50Q29tcG9uZW50CiAgICB9OwogIH0KICByZXR1cm4gewogICAgY29tcG9uZW50czogc2l6ZVBlckNvbXBvbmVudCwKICAgIG1pbldpZHRoLAogICAgbWluSGVpZ2h0LAogICAgbWF4TnVtV2lkZSwKICAgIG1heE51bUhpZ2gKICB9Owp9CmZ1bmN0aW9uIGJ1aWxkUGFja2V0cyhjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgIGNvbnN0IGRlY29tcG9zaXRpb25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AgICAgICAgIGZvciAobGV0IGwgPSAwOyBsIDwgbGF5ZXJOdW1iZXI7IGwrKykgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkgIT09IDApIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIkludmFsaWQgdGFnIHRyZWUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoaW5jbHVzaW9uVHJlZS5yZXNldChjb2RlYmxvY2tDb2x1bW4sIGNvZGVibG9ja1JvdywgbGF5ZXJOdW1iZXIpKSB7CiAgICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkpIHsKICAgICAgICAgICAgICB2YWx1ZVJlYWR5ID0gIWluY2x1c2lvblRyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgICAgaWYgKHZhbHVlUmVhZHkpIHsKICAgICAgICAgICAgICAgIGNvZGVibG9jay5pbmNsdWRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBjb2RlYmxvY2tJbmNsdWRlZCA9IGZpcnN0VGltZUluY2x1c2lvbiA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaW5jbHVzaW9uVHJlZS5pbmNyZW1lbnRWYWx1ZShsYXllck51bWJlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFjb2RlYmxvY2tJbmNsdWRlZCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChmaXJzdFRpbWVJbmNsdXNpb24pIHsKICAgICAgICB6ZXJvQml0UGxhbmVzVHJlZSA9IHByZWNpbmN0Lnplcm9CaXRQbGFuZXNUcmVlOwogICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLnJlc2V0KGNvZGVibG9ja0NvbHVtbiwgY29kZWJsb2NrUm93KTsKICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgaWYgKHJlYWRCaXRzKDEpKSB7CiAgICAgICAgICAgIHZhbHVlUmVhZHkgPSAhemVyb0JpdFBsYW5lc1RyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgIGlmICh2YWx1ZVJlYWR5KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLmluY3JlbWVudFZhbHVlKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvZGVibG9jay56ZXJvQml0UGxhbmVzID0gemVyb0JpdFBsYW5lc1RyZWUudmFsdWU7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzID0gcmVhZENvZGluZ3Bhc3NlcygpOwogICAgICB3aGlsZSAocmVhZEJpdHMoMSkpIHsKICAgICAgICBjb2RlYmxvY2suTGJsb2NrKys7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzTG9nMiA9ICgwLCBfY29yZV91dGlscy5sb2cyKShjb2RpbmdwYXNzZXMpOwogICAgICBjb25zdCBiaXRzID0gKGNvZGluZ3Bhc3NlcyA8IDEgPDwgY29kaW5ncGFzc2VzTG9nMiA/IGNvZGluZ3Bhc3Nlc0xvZzIgLSAxIDogY29kaW5ncGFzc2VzTG9nMikgKyBjb2RlYmxvY2suTGJsb2NrOwogICAgICBjb25zdCBjb2RlZERhdGFMZW5ndGggPSByZWFkQml0cyhiaXRzKTsKICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgY29kZWJsb2NrLAogICAgICAgIGNvZGluZ3Bhc3NlcywKICAgICAgICBkYXRhTGVuZ3RoOiBjb2RlZERhdGFMZW5ndGgKICAgICAgfSk7CiAgICB9CiAgICBhbGlnblRvQnl0ZSgpOwogICAgaWYgKGVwaE1hcmt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pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMpIHsKICAgICAgICBiaXRNb2RlbC5yZXNldCgpOwogICAgICB9CiAgICAgIGN1cnJlbnRDb2RpbmdwYXNzVHlwZSA9IChjdXJyZW50Q29kaW5ncGFzc1R5cGUgKyAxKSAlIDM7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gY29kZWJsb2NrLnRieDBfIC0geDAgKyAoY29kZWJsb2NrLnRieTBfIC0geTApICogd2lkdGg7CiAgICBjb25zdCBzaWduID0gYml0TW9kZWwuY29lZmZpY2VudHNTaWduOwogICAgY29uc3QgbWFnbml0dWRlID0gYml0TW9kZWwuY29lZmZpY2VudHNNYWduaXR1ZGU7CiAgICBjb25zdCBiaXRzRGVjb2RlZCA9IGJpdE1vZGVsLmJpdHNEZWNvZGVkOwogICAgY29uc3QgbWFnbml0dWRlQ29ycmVjdGlvbiA9IHJldmVyc2libGUgPyAwIDogMC41OwogICAgbGV0IGssIG4sIG5iOwogICAgcG9zaXRpb24gPSAwOwogICAgY29uc3QgaW50ZXJsZWF2ZSA9IHN1YmJhbmQudHlwZSAhPT0gIkxMIjsKICAgIGZvciAoaiA9IDA7IGogPCBibG9ja0hlaWdodDsgaisrKSB7CiAgICAgIGNvbnN0IHJvdyA9IG9mZnNldCAvIHdpZHRoIHwgMDsKICAgICAgY29uc3QgbGV2ZWxPZmZzZXQgPSAyICogcm93ICogKGxldmVsV2lkdGggLSB3aWR0aCkgKyByaWdodCArIGJvdHRvbTsKICAgICAgZm9yIChrID0gMDsgayA8IGJsb2NrV2lkdGg7IGsrKykgewogICAgICAgIG4gPSBtYWduaXR1ZGVbcG9zaXRpb25dOwogICAgICAgIGlmIChuICE9PSAwKSB7CiAgICAgICAgICBuID0gKG4gKyBtYWduaXR1ZGVDb3JyZWN0aW9uKSAqIGRlbHRhOwogICAgICAgICAgaWYgKHNpZ25bcG9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IG91dFtwb3MrK10gPSB5MCAtIDAuMzQ0MTMgKiB5MSAtIDAuNzE0MTQgKiB5MiA+PiBzaGlmdDsKICAgICAgICAgIG91dFtwb3MrK10gPSB5MCArIDEuNzcyICogeTEgPj4gc2hpZnQ7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAoaiA9IDA7IGogPCBqajsgaisrLCBwb3MgKz0gYWxwaGEwMSkgewogICAgICAgICAgeTAgPSB5MGl0ZW1zW2pdICsgb2Zmc2V0OwogICAgICAgICAgeTEgPSB5MWl0ZW1zW2pdOwogICAgICAgICAgeTIgPSB5Mml0ZW1zW2pdOwogICAgICAgICAgY29uc3QgZyA9IHkwIC0gKHkyICsgeTEgPj4gMik7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkyID4+IHNoaWZ0OwogICAgICAgICAgb3V0W3BvcysrXSA9IGcgPj4gc2hpZnQ7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkxID4+IHNoaWZ0OwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZm91ckNvbXBvbmVudHMpIHsKICAgICAgICBmb3IgKGogPSAwLCBwb3MgPSAzOyBqIDwgamo7IGorKywgcG9zICs9IDQpIHsKICAgICAgICAgIG91dFtwb3NdID0geTNpdGVtc1tqXSArIG9mZnNldCA+PiBzaGlmdDsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgICAgICBjb25zdCBpdGVtcyA9IHRyYW5zZm9ybWVkVGlsZXNbY10uaXRlbXM7CiAgICAgICAgc2hpZnQgPSBjb21wb25lbnRzW2NdLnByZWNpc2lvbiAtIDg7CiAgICAgICAgb2Zmc2V0ID0gKDEyOCA8PCBzaGlmdCkgKyAwLjU7CiAgICAgICAgZm9yIChwb3MgPSBjLCBqID0gMCwgamogPSBpdGVtcy5sZW5ndGg7IGogPCBqajsgaisr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ZW50Q291bnQpOwogICAgICB9IGVsc2UgaWYgKG1iID4gNikgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQxNkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQ4QXJyYXkoY29lZmZpY2llbnRDb3VudCk7CiAgICAgIH0KICAgICAgdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZSA9IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICB0aGlzLnByb2Nlc3NpbmdGbGFncyA9IG5ldyBVaW50OEFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICBjb25zdCBiaXRzRGVjb2RlZCA9IG5ldyBVaW50OEFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICBpZiAoemVyb0JpdFBsYW5lcyAhPT0gMCkgewogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29lZmZpY2llbnRDb3VudDsgaSsrKSB7CiAgICAgICAgICBiaXRzRGVjb2RlZFtpXSA9IHplcm9CaXRQbGFuZXM7CiAgICAgICAgfQogICAgICB9CiAgICAgIHRoaXMuYml0c0RlY29kZWQgPSBiaXRzRGVjb2RlZDsKICAgICAgdGhpcy5yZXNldCgpOwogICAgfQogICAgc2V0RGVjb2RlcihkZWNvZGVyKSB7CiAgICAgIHRoaXMuZGVjb2RlciA9IGRlY29kZXI7CiAgICB9CiAgICByZXNldCgpIHsKICAgICAgdGhpcy5jb250ZXh0cyA9IG5ldyBJbnQ4QXJyYXkoMTkpOwogICAgICB0aGlzLmNvbnRleHRzWzBdID0gNCA8PCAxIHwgMDsKICAgICAgdGhpcy5jb250ZXh0c1tVTklGT1JNX0NPTlRFWFRdID0gNDYgPDwgMSB8IDA7CiAgICAgIHRoaXMuY29udGV4dHNbUlVOTEVOR1RIX0NPTlRFWFRdID0gMyA8PCAxIHwgMDsKICAgIH0KICAgIHNldE5laWdoYm9yc1NpZ25pZmljYW5jZShyb3csIGNvbHVtbiwgaW5kZXgpIHsKICAgICAgY29uc3QgbmVpZ2hib3JzU2lnbmlmaWNhbmNlID0gdGhpcy5uZWlnaGJvcnNTaWduaWZpY2FuY2U7CiAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCwKICAgICAgICBoZWlnaHQgPSB0aGlzLmhlaWdodDsKICAgICAgY29uc3QgbGVmdCA9IGNvbHVtbiA+IDA7CiAgICAgIGNvbnN0IHJpZ2h0ID0gY29sdW1uICsgMSA8IHdpZHRoOwogICAgICBsZXQgaTsKICAgICAgaWYgKHJvdyA+IDApIHsKICAgICAgICBpID0gaW5kZXggLSB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKHJvdyArIDEgPCBoZWlnaHQpIHsKICAgICAgICBpID0gaW5kZXggKyB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKGxlZnQpIHsKICAgICAgICBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXggLSAxXSArPSAweDAxOwogICAgICB9C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PSBpMCAqIHdpZHRoICsgajsKICAgICAgICAgIGZvciAobGV0IGkxID0gMDsgaTEgPCA0OyBpMSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBjb25zdCBpID0gaTAgKyBpMTsKICAgICAgICAgICAgaWYgKGkgPj0gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmPSBwcm9jZXNzZWRJbnZlcnNlTWFzazsKICAgICAgICAgICAgaWYgKGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSB8fCAhbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGNvbnRleHRMYWJlbCA9IGxhYmVsc1tuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdXTsKICAgICAgICAgICAgY29uc3QgZGVjaXNpb24gPSBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIGNvbnRleHRMYWJlbCk7CiAgICAgICAgICAgIGlmIChkZWNpc2lvbikgewogICAgICAgICAgICAgIGNvbnN0IHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzU2lnbltpbmRleF0gPSBzaWduOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSA9IDE7CiAgICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gZmlyc3RNYWduaXR1ZGVCaXRNYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4XSsrOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IHByb2Nlc3NlZE1hc2s7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBkZWNvZGVTaWduQml0KHJvdywgY29sdW1uLCBpbmRleCkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IGNvZWZmaWNlbnRzTWFnbml0dWRlID0gdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZTsKICAgICAgY29uc3QgY29lZmZpY2VudHNTaWduID0gdGhpcy5jb2VmZmljZW50c1NpZ247CiAgICAgIGxldCBjb250cmlidXRpb24sIHNpZ24wLCBzaWduMSwgc2lnbmlmaWNhbmNlMTsKICAgICAgbGV0IGNvbnRleHRMYWJlbCwgZGVjb2RlZDsKICAgICAgc2lnbmlmaWNhbmNlMSA9IGNvbHVtbiA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSAxXSAhPT0gMDsKICAgICAgaWYgKGNvbHVtbiArIDEgPCB3aWR0aCAmJiBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleCArIDFdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyAxXTsKICAgICAgICBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgICAgc2lnbjAgPSBjb2VmZmljZW50c1NpZ25baW5kZXggLSAxXTsKICAgICAgICAgIGNvbnRyaWJ1dGlvbiA9IDEgLSBzaWduMSAtIHNpZ24wOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gMV07CiAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24wIC0gc2lnbjA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gMDsKICAgICAgfQogICAgICBjb25zdCBob3Jpem9udGFsQ29udHJpYnV0aW9uID0gMyAqIGNvbnRyaWJ1dGlvbjsKICAgICAgc2lnbmlmaWNhbmNlMSA9IHJvdyA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSB3aWR0aF0gIT09IDA7CiAgICAgIGlmIChyb3cgKyAxIDwgaGVpZ2h0ICYmIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4ICsgd2lkdGhdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyB3aWR0aF07CiAgICAgICAgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gd2lkdGhdOwogICAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24xIC0gc2lnbjAgKyBob3Jpem9udGFsQ29udHJpYnV0aW9uOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMSArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICBzaWduMCA9IGNvZWZmaWNlbnRzU2lnbltpbmRleCAtIHdpZHRoXTsKICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjAgLSBzaWduMCArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gaG9yaXpvbnRhbENvbnRyaWJ1dGlvbjsKICAgICAgfQogICAgICBpZiAoY29udHJpYnV0aW9uID49IDApIHsKICAgICAgICBjb250ZXh0TGFiZWwgPSA5ICsgY29udHJpYnV0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TmV4dCkgewogICAgICAgIGluZGV4TmV4dCA9IE1hdGgubWluKGxlbmd0aCwgaW5kZXgwICsgd2lkdGg0KTsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHdpZHRoOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGluZGV4ID0gaW5kZXgwICsgajsgaW5kZXggPCBpbmRleE5leHQ7IGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgIGlmICghY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgY29udGV4dExhYmVsID0gMTY7CiAgICAgICAgICAgIGlmICgocHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmIGZpcnN0TWFnbml0dWRlQml0TWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIF49IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgICBjb25zdCBzaWduaWZpY2FuY2UgPSBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdICYgMTI3OwogICAgICAgICAgICAgIGNvbnRleHRMYWJlbCA9IHNpZ25pZmljYW5jZSA9PT0gMCA/IDE1IDogMTQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgYml0ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPDwgMSB8IGJpdDsKICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gcHJvY2Vzc2V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XgwXSsrOwogICAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4MCArIG9uZVJvd0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdHdvUm93c0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0rKzsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpMSA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAxIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpOwogICAgICAgICAgICBpZiAoaTEgIT09IDApIHsKICAgICAgICAgICAgICBpID0gaTAgKyBpMTsKICAgICAgICAgICAgICBpbmRleCArPSBpMSAqIHdpZHRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdID0gMTsKICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgaW5kZXggPSBpbmRleDA7CiAgICAgICAgICAgIGZvciAobGV0IGkyID0gaTA7IGkyIDw9IGk7IGkyKyssIGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaTErKzsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGkwICsgaTE7IGkgPCBpTmV4dDsgaSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBpZiAoY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBjb250ZXh0TGFiZWwgPSBsYWJlbHNbbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XV07CiAgICAgICAgICAgIGNvbnN0IGRlY2lzaW9uID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBpZiAoZGVjaXNpb24gPT09IDEpIHsKICAgICAgICAgICAgICBzaWduID0gdGhpcy5kZWNvZGVTaWduQml0KGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSAxOwogICAgICAgICAgICAgIHRoaXMuc2V0TmVpZ2hib3JzU2lnbmlmaWNhbmNlKGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBiaXRzRGVjb2RlZFtpbmRleF0rKzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNoZWNrU2VnbWVudGF0aW9uU3ltYm9sKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCBjb250ZXh0cyA9IHRoaXMuY29udGV4dHM7CiAgICAgIGNvbnN0IHN5bWJvbCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAzIHwgZGVjb2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ICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAodSA9IDA7IHUgPCB3aWR0aDsgdSsrKSB7CiAgICAgICAgaWYgKGN1cnJlbnRCdWZmZXIgPT09IDApIHsKICAgICAgICAgIG51bUJ1ZmZlcnMgPSBNYXRoLm1pbih3aWR0aCAtIHUsIG51bUJ1ZmZlcnMpOwogICAgICAgICAgZm9yIChrID0gdSwgbCA9IGJ1ZmZlclBhZGRpbmc7IGwgPCBsbDsgayArPSB3aWR0aCwgbCsrKSB7CiAgICAgICAgICAgIGZvciAoYiA9IDA7IGIgPCBudW1CdWZmZXJzOyBiKyspIHsKICAgICAgICAgICAgICBjb2xCdWZmZXJzW2JdW2xdID0gaXRlbXNbayArIGJdOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBjdXJyZW50QnVmZmVyID0gbnVtQnVmZmVyczsKICAgICAgICB9CiAgICAgICAgY3VycmVudEJ1ZmZlci0tOwogICAgICAgIGNvbnN0IGJ1ZmZlciA9IGNvbEJ1ZmZlcnNbY3VycmVudEJ1ZmZlcl07CiAgICAgICAgdGhpcy5leHRlbmQoYnVmZmVyLCBidWZmZXJQYWRkaW5nLCBoZWlnaHQpOwogICAgICAgIHRoaXMuZmlsdGVyKGJ1ZmZlciwgYnVmZmVyUGFkZGluZywgaGVpZ2h0KTsKICAgICAgICBpZiAoY3VycmVudEJ1ZmZlciA9PT0gMCkgewogICAgICAgICAgayA9IHUgLSBudW1CdWZmZXJzICsgMTsKICAgICAgICAgIGZvciAobCA9IGJ1ZmZlclBhZGRpbmc7IGwgPCBsbDsgayArPSB3aWR0aCwgbCsrKSB7CiAgICAgICAgICAgIGZvciAoYiA9IDA7IGIgPCBudW1CdWZmZXJzOyBiKyspIHsKICAgICAgICAgICAgICBpdGVtc1trICsgYl0gPSBjb2xCdWZmZXJzW2JdW2xdOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZ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gY3VycmVudCA9IGdhbW1hICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAyOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSAtPSBjdXJyZW50ICsgbmV4dDsKICAgICAgaWYgKG4tLSkgewogICAgICAgIGogKz0gMjsKICAgICAgICBjdXJyZW50ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBqID0gb2Zmc2V0OwogICAgY3VycmVudCA9IGJldGEgKiB4W2ogLSAxXTsKICAgIGZvciAobiA9IGxlbiArIDE7IG4tLTsgaiArPSAyKSB7CiAgICAgIG5leHQgPSBiZXRhICogeFtqICsgMV07CiAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGJldGEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAobGVuICE9PSAwKSB7CiAgICAgIGogPSBvZmZzZXQgKyAxOwogICAgICBjdXJyZW50ID0gYWxwaGEgKiB4W2ogLSAxXTsKICAgICAgZm9yIChuID0gbGVuOyBuLS07IGogKz0gMikgewogICAgICAgIG5leHQgPSBhbHBoYSAqIHhbaiArIDFdOwogICAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgICAgaWYgKG4tLSkgewogICAgICAgICAgaiArPSAyOwogICAgICAgICAgY3VycmVudCA9IGFscGhhICogeFtqICsgMV07CiAgICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBicmVhazs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OwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAyNTYpIHsKICAgICAgICBjb2RlTGVuZ3RoID0gOTsKICAgICAgICBuZXh0Q29kZSA9IDI1ODsKICAgICAgICBjdXJyZW50U2VxdWVuY2VMZW5ndGggPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5sendTdGF0ZTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoaGFzUHJldikgewogICAgICAgIGRpY3Rpb25hcnlQcmV2Q29kZXNbbmV4dENvZGVdID0gcHJldkNvZGU7CiAgICAgICAgZGljdGlvbmFyeUxlbmd0aHNbbmV4dENvZGVdID0gZGljdGlvbmFyeUxlbmd0aHNbcHJldkNvZGVdICsgMTsKICAgICAgICBkaWN0aW9uYXJ5VmFsdWVzW25leHRDb2RlXSA9IGN1cnJlbnRTZXF1ZW5jZVswXTsKICAgICAgICBuZXh0Q29kZSsrOwogICAgICAgIGNvZGVMZW5ndGggPSBuZXh0Q29kZSArIGVhcmx5Q2hhbmdlICYgbmV4dENvZGUgKyBlYXJseUNoYW5nZSAtIDEgPyBjb2RlTGVuZ3RoIDogTWF0aC5taW4oTWF0aC5sb2cobmV4dENvZGUgKyBlYXJseUNoYW5nZSkgLyAwLjY5MzE0NzE4MDU1OTk0NTMgKyAxLCAxMikgfCAwOwogICAgICB9CiAgICAgIHByZXZDb2RlID0gY29kZTsKICAgICAgZGVjb2RlZExlbmd0aCArPSBjdXJyZW50U2VxdWVuY2VMZW5ndGg7CiAgICAgIGlmIChlc3RpbWF0ZWREZWNvZGVkU2l6ZSA8IGRlY29kZWRMZW5ndGgpIHsKICAgICAgICBkbyB7CiAgICAgICAgICBlc3RpbWF0ZWREZWNvZGVkU2l6ZSArPSBkZWNvZGVkU2l6ZURlbHRhOwogICAgICAgIH0gd2hpbGUgKGVzdGltYXRlZERlY29kZ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OwogICAgICBjb25zdCBjb2x1bW5zID0gdGhpcy5jb2x1bW5zOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29sdW1uczsgKytpKSB7CiAgICAgICAgZm9yIChsZXQga2sgPSAwOyBrayA8IGNvbG9yczsgKytraykgewogICAgICAgICAgaWYgKGluYml0cyA8IGJpdHMpIHsKICAgICAgICAgICAgaW5idWYgPSBpbmJ1ZiA8PCA4IHwgcmF3Qnl0ZXNbaisrXSAmIDB4ZmY7CiAgICAgICAgICAgIGluYml0cyArPSA4OwogICAgICAgICAgfQogICAgICAgICAgY29tcEFycmF5W2trXSA9IGNvbXBBcnJheVtra10gKyAoaW5idWYgPj4gaW5iaXRzIC0gYml0cykgJiBiaXRNYXNrOwogICAgICAgICAgaW5iaXRzIC09IGJpdHM7CiAgICAgICAgICBvdXRidWYgPSBvdXRidWYgPDwgYml0cyB8IGNvbXBBcnJheVtra107CiAgICAgICAgICBvdXRiaXRzICs9IGJpdHM7CiAgICAgICAgICBpZiAob3V0Yml0cyA+PSA4KSB7CiAgICAgICAgICAgIGJ1ZmZlcltrKytdID0gb3V0YnVmID4+IG91dGJpdHMgLSA4ICYgMHhmZjsKICAgICAgICAgICAgb3V0Yml0cyAtPSA4OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAob3V0Yml0cyA+IDApIHsKICAgICAgICBidWZmZXJbaysrXSA9IChvdXRidWYgPDwgOCAtIG91dGJpdHMpICsgKGluYnVmICYgKDEgPDwgOCAtIG91dGJpdHMpIC0gMSk7CiAgICAgIH0KICAgIH0KICAgIHRoaXMuYnVmZmVyTGVuZ3RoICs9IHJvd0J5dGVzOwogIH0KICByZWFkQmxvY2tQbmcoKSB7CiAgICBjb25zdCByb3dCeXRlcyA9IHRoaXMucm93Qnl0ZXM7CiAgICBjb25zdCBwaXhCeXRlcyA9IHRoaXMucGl4Qnl0ZXM7CiAgICBjb25zdCBwcmVkaWN0b3IgPSB0aGlzLnN0ci5nZXRCeXRlKC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6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcHJldlJvd1tpXSArIHJhd0J5dGVzW2ldICYgMHhmZjsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMzoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcGl4Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2orK10gPSAocHJldlJvd1tpXSA+PiAxKSArIHJhd0J5dGVzW2ldOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqXSA9IChwcmV2Um93W2ldICsgYnVmZmVyW2ogLSBwaXhCeXRlc10gPj4gMSkgKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDQ6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGMgPSByYXdCeXRlc1tpXTsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gdXAgKyBjOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGNvbnN0IHVwTGVmdCA9IHByZXZSb3dbaSAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IGxlZnQgPSBidWZmZXJbaiAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IHAgPSBsZWZ0ICsgdXAgLSB1cExlZnQ7CiAgICAgICAgICBsZXQgcGEgPSBwIC0gbGVmdDsKICAgICAgICAgIGlmIChwYSA8IDApIHsKICAgICAgICAgICAgcGEgPSAtcGE7CiAgICAgICAgICB9CiAgICAgICAgICBsZXQgcGIgPSBwIC0gdXA7CiAgICAgICAgICBpZiAocGIgPCAwKSB7CiAgICAgICAgICAgIHBiID0gLXBiOwogICAgICAgICAgfQogICAgICAgICAgbGV0IHBjID0gcCAtIHVwTGVmdDsKICAgICAgICAgIGlmIChwYyA8IDApIHsKICAgICAgICAgICAgcGMgPSAtcGM7CiAgICAgICAgICB9CiAgICAgICAgICBjID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgICBpZiAocGEgPD0gcGIgJiYgcGEgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSBsZWZ0ICsgYzsKICAgICAgICAgIH0gZWxzZSBpZiAocGIgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSB1cCArIGM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBidWZmZXJbaisrXSA9IHVwTGVmdCArIGM7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5zdXBwb3J0ZWQgcHJlZGljdG9yOiAke3ByZWRpY3Rvcn1gKTsKICAgIH0KICAgIHRoaXMuYnVmZmVyTGVuZ3RoICs9IHJvd0J5dGVzOwogIH0KfQpleHBvcnRzLlByZWRpY3RvclN0cmVhbSA9IFByZWRpY3RvclN0cmVhbTsKCi8qKiovIH0pLAovKiAxNjggKi8KLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKInVzZSBzdHJpY3QiOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgdmFsdWU6IHRydWUKfSkpOwpleHBvcnRzLlJ1bkxlbmd0aFN0cmVhbSA9IHZvaWQgMDsKdmFyIF9kZWNvZGVfc3RyZWFtID0gX193X3BkZmpzX3Jlc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wogICAgc3RhcnRDb3VudCArPSBzdHJpbmcxNihzdGFydCk7CiAgICBlbmRDb3VudCArPSBzdHJpbmcxNihlbmQpOwogICAgY29kZXMgPSByYW5nZVsyXTsKICAgIGxldCBjb250aWd1b3VzID0gdHJ1ZTsKICAgIGZvciAoaiA9IDEsIGpqID0gY29kZXMubGVuZ3RoOyBqIDwgamo7ICsraikgewogICAgICBpZiAoY29kZXNbal0gIT09IGNvZGVzW2ogLSAxXSArIDEpIHsKICAgICAgICBjb250aWd1b3VzID0gZmFsc2U7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGlmICghY29udGlndW91cykgewogICAgICBjb25zdCBvZmZzZXQgPSAoc2VnQ291bnQgLSBpKSAqIDIgKyBiaWFzICogMjsKICAgICAgYmlhcyArPSBlbmQgLSBzdGFydCArIDE7CiAgICAgIGlkRGVsdGFzICs9IHN0cmluZzE2KDApOwogICAgICBpZFJhbmdlT2Zmc2V0cyArPSBzdHJpbmcxNihvZmZzZXQpOwogICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBnbHlwaHNJZHMgKz0gc3RyaW5nMTYoY29kZXNbal0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBzdGFydENvZGUgPSBjb2Rlc1swXTsKICAgICAgaWREZWx0YXMgKz0gc3RyaW5nMTYoc3RhcnRDb2RlIC0gc3RhcnQgJiAweGZmZmYpOwogICAgICBpZFJhbmdlT2Zmc2V0cyArPSBzdHJpbmcxNigwKTsKICAgIH0KICB9CiAgaWYgKHRyYWlsaW5nUmFuZ2VzQ291bnQgPiAwKSB7CiAgICBlbmRDb3VudCArPSAiXHhGRlx4RkYiOwogICAgc3RhcnRDb3VudCArPSAiXHhGRlx4RkYiOwogICAgaWREZWx0YXMgKz0gIlx4MDBceDAxIjsKICAgIGlkUmFuZ2VPZmZzZXRzICs9ICJceDAwXHgwMCI7CiAgfQogIG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TFDIiB8fCBzdWJ0eXBlID09PSAiQ0lERm9udFR5cGUwQyIgPyBuZXcgX2NmZl9mb250LkNGRkZvbnQoZmlsZSwgcHJvcGVydGllcykgOiBuZXcgX3R5cGUxX2ZvbnQuVHlwZTFGb250KG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgYWRqdXN0V2lkdGhzKHByb3BlcnRpZXMpOwogICAgICAgICAgZGF0YSA9IHRoaXMuY29udmVydChuYW1lLCBjZmYsIHByb3BlcnRpZXMpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT3BlblR5cGUiOgogICAgICAgIGNhc2UgIlRydWVUeXBlIjoKICAgICAgICBjYXNlICJDSURGb250VHlwZTIiOgogICAgICAgICAgdGhpcy5taW1ldHlwZSA9ICJmb250L29wZW50eXBlIjsKICAgICAgICAgIGRhdGEgPSB0aGlzLmNoZWNrQW5kUmVwYWlyKG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgaWYgKHRoaXMuaXNPcGVuVHlwZSkgewogICAgICAgICAgICBhZGp1c3RXaWR0aHMocHJvcGVydGllcyk7CiAgICAgICAgICAgIHR5cGUgPSAiT3BlblR5cGUiOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgRm9udCAke3R5cGV9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgICAgfQogICAgfSBjYXRjaCAoZSkgewogICAgICAoMCwgX3V0aWwud2FybikoZSk7CiAgICAgIHRoaXMuZmFsbGJhY2tUb1N5c3RlbUZvbnQocHJvcGVydGllcyk7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGFtZW5kRmFsbGJhY2tUb1VuaWNvZGUocHJvcGVydGllcyk7CiAgICB0aGlzLmRhdGEgPSBkYXRhOwogICAgdGhpcy50eXBlID0gdHlwZTsKICAgIHRoaXMuc3VidH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AgdGFibGVzWyJPUy8yIl0gPSBudWxsOwogICAgICB0YWJsZXMuY21hcCA9IG51bGw7CiAgICAgIHRhYmxlcy5oZWFkID0gbnVsbDsKICAgICAgdGFibGVzLmhoZWEgPSBudWxsOwogICAgICB0YWJsZXMuaG10eCA9IG51bGw7CiAgICAgIHRhYmxlcy5tYXhwID0gbnVsbDsKICAgICAgdGFibGVzLm5hbWUgPSBudWxsOwogICAgICB0YWJsZXMucG9zdCA9IG51bGw7CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtVGFibGVzOyBpKyspIHsKICAgICAgICBjb25zdCB0YWJsZSA9IHJlYWRUYWJsZUVudHJ5KGZpbGUpOwogICAgICAgIGlmICghVkFMSURfVEFCTEVTLmluY2x1ZGVzKHRhYmxlLnRhZykpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGFibGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdGFibGVzW3RhYmxlLnRhZ10gPSB0YWJsZTsKICAgICAgfQogICAgICByZXR1cm4gdGFibGVzOwogICAgfQogICAgZnVuY3Rpb24gcmVhZFRhYmxlRW50cnkoZmlsZSkgewogICAgICBjb25zdCB0YWcgPSBmaWxlLmdldFN0cmluZyg0KTsKICAgICAgY29uc3QgY2hlY2tzdW0gPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgY29uc3QgbGVuZ3RoID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICBjb25zdCBwcmV2aW91c1Bvc2l0aW9uID0gZmlsZS5wb3M7CiAgICAgIGZpbGUucG9zID0gZmlsZS5zdGFydCB8fCAwOwogICAgICBmaWxlLnNraXAob2Zmc2V0KTsKICAgICAgY29uc3QgZGF0YSA9IGZpbGUuZ2V0Qnl0ZXMobGVuZ3R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YmxlID0gW107CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtRm9udHM7IGkrKykgewogICAgICAgIG9mZnNldFRhYmxlLnB1c2godHRjLmdldEludDMyKCkgPj4+IDApOwogICAgICB9CiAgICAgIGNvbnN0IGhlYWRlciA9IHsKICAgICAgICB0dGNUYWcsCiAgICAgICAgbWFqb3JWZXJzaW9uLAogICAgICAgIG1pbm9yVmVyc2lvbiwKICAgICAgICBudW1Gb250cywKICAgICAgICBvZmZzZXRUYWJsZQogICAgICB9OwogICAgICBzd2l0Y2ggKG1ham9yVmVyc2lvbikgewogICAgICAgIGNhc2UgMToKICAgICAgICAgIHJldHVybiBoZWFkZXI7CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaGVhZGVyLmRzaWdUYWcgPSB0dGMuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGhlYWRlci5kc2lnTGVuZ3RoID0gdHRjLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgICBoZWFkZXIuZHNpZ09mZnNldCA9IHR0Yy5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgcmV0dXJuIGhlYWRlcjsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEludmFsaWQgVHJ1ZVR5cGUgQ29sbGVjdGlvbiBtYWpvclZlcnNpb246ICR7bWFqb3JWZXJzaW9ufS5gKTsKICAgIH0KICAgIGZ1bmN0aW9uIHJlYWRUcnVlVHlwZUNvbGxlY3Rpb25EYXRhKHR0YywgZm9udE5hbWUpIHsKICAgICAgY29uc3QgewogICAgICAgIG51bUZvbnRzLAogICAgICAgIG9mZnNldFRhYmxlCiAgICAgIH0gPSByZWFkVHJ1ZVR5cGVDb2xsZWN0aW9uSGVhZGVyKHR0Yyk7CiAgICAgIGNvbnN0IGZvbnROYW1lUGFydHMgPSBmb250TmFtZS5zcGxpdCgiKyIpOwogICAgICBsZXQgZmFsbGJhY2tEYXRhOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG51bUZvbnRzOyBpKyspIHsKICAgICAgICB0dGMucG9zID0gKHR0Yy5zdGFydCB8fCAwKSArIG9mZnNldFRhYmxlW2ldOwogICAgICAgIGNvbnN0IHBvdGVudGlhbEhlYWRlciA9IHJlYWRPcGVuVHlwZUhlYWRlcih0dGMpOwogICAgICAgIGNvbnN0IHBvdGVudGlhbFRhYmxlcyA9IHJlYWRUYWJsZXModHRjLCBwb3RlbnRpYWxIZWFkZXIubnVtVGFibGVzKTsKICAgICAgICBpZiAoIXBvdGVudGlhbFRhYmxlcy5uYW1lKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoJ1RydWVUeXBlIENvbGxlY3Rpb24gZm9udCBtdXN0IGNvbnRhaW4gYSAibmFtZSIgdGFibGUuJyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IFtuYW1lVGFibGVdID0gcmVhZE5hbWVUYWJsZShwb3RlbnRpYWxUYWJsZXMubmFtZSk7CiAgICAgICAgZm9yIChsZXQgaiA9IDAsIGpqID0gbmFtZVRhYmxlLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGsgPSAwLCBrayA9IG5hbWVUYWJsZVtqXS5sZW5ndGg7IGsgPCBrazsgaysrKSB7CiAgICAgICAgICAgIGNvbnN0IG5hbWVFbnRyeSA9IG5hbWVUYWJsZVtqXVtrXSAmJiBuYW1lVGFibGVbal1ba10ucmVwbGFjZUFsbCgvXHMvZywgIiIpOwogICAgICAgICAgICBpZiAoIW5hbWVFbnRyeSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IGZvbnROYW1lKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIGhlYWRlcjogcG90ZW50aWFsSGVhZGVyLAogICAgICAgICAgICAgICAgdGFibGVzOiBwb3RlbnRpYWxUYWJsZXMKICAgICAgICAgICAgICB9OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmb250TmFtZVBhcnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3IgKGNvbnN0IHBhcnQgb2YgZm9udE5hbWVQYXJ0cykgewogICAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IHBhcnQpIHsKICAgICAgICAgICAgICAgIGZhbGxiYWNrRGF0YSA9IHsKICAgICAgICAgICAgICAgICAgbmFtZTogcGFydCwKICAgICAgICAgICAgICAgICAgaGVhZGVyOiBwb3RlbnRpYWxIZWFkZXIsCiAgICAgICAgICAgICAgICAgIHRhYmxlczogcG90ZW50aWFsVGFibGVzCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZmFsbGJhY2tEYXRhKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUcnVlVHlwZSBDb2xsZWN0aW9uIGRvZXMgbm90IGNvbnRhaW4gIiR7Zm9udE5hbWV9IiBmb250LCBgICsgYGZhbGxpbmcgYmFjayB0byAiJHtmYWxsYmFja0RhdGEubmFtZX0iIGZvbnQgaW5zdGVhZC5gKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgaGVhZGVyOiBmYWxsYmFja0RhdGEuaGVhZGVyLAogICAgICAgICAgdGFibGVzOiBmYWxsYmFja0RhdGEudGFibGVzCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFRydWVUeXBlIENvbGxlY3Rpb24gZG9lcyBub3QgY29udGFpbiAiJHtmb250TmFtZX0iIGZvbnQuYCk7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkQ21hcFRhYmxlKGNtYXAsIGZpbGUsIGlzU3ltYm9saWNGb250LCBoYXNFbmNvZGluZykgewogICAgICBpZiAoIWNtYXApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vIGNtYXAgdGFibGUgYXZhaWxhYmxlLiIpOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBwbGF0Zm9ybUlkOiAtMSwKICAgICAgICAgIGVuY29kaW5nSWQ6IC0xLAogICAgICAgICAgbWFwcGluZ3M6IFtdLAogICAgICAgICAgaGFzU2hvcnRDbWFwOiBmYWxzZQogICAgICAgIH07CiAgICAgIH0KICAgICAgbGV0IHNlZ21lbnQ7CiAgICAgIGxldCBzdGFydCA9IChmaWxlLnN0YXJ0IHx8IDApICsgY21hcC5vZmZzZXQ7CiAgICAgIGZpbGUucG9zID0gc3RhcnQ7CiAgICAgIGZpbGUuc2tpcCgyKTsKICAgICAgY29uc3QgbnVtVGFibGVzID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgbGV0IHBvdGVudGlhbFRhYmxlOwogICAgICBsZXQgY2FuQnJlYWsgPSBmYWxzZTsKICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBudW1UYWJsZXM7IGkrKykgewogICAgICAgIGNvbnN0IHBsYXRmb3JtSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVuY29kaW5nSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICBsZXQgdXNlVGFibGUgPSBmYWxzZTsKICAgICAgICBpZiAocG90ZW50aWFsVGFibGUgJiYgcG90ZW50aWFsVGFibGUucGxhdGZvcm1JZCA9PT0gcGxhdGZvcm1JZCAmJiBwb3RlbnRpYWxUYWJsZS5lbmNvZGluZ0lkID09PSBlbmNvZGluZ0lkKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHBsYXRmb3JtSWQgPT09IDAgJiYgKGVuY29kaW5nSWQgPT09IDAgfHwgZW5jb2RpbmdJZCA9PT0gMSB8fCBlbmNvZGluZ0lkID09PSAzKSkgewogICAgICAgICAgdXNlVGFibGUgPSB0cnVlOwogICAgICAgIH0gZWxzZSBpZiAocGxhdGZvcm1JZCA9PT0gMSAmJiBlbmNvZGluZ0lkID09PSAwKSB7CiAgICAgICAgICB1c2VUYWJsZSA9IHRydWU7CiAgICAgICAgfSBlbHNlIGlmIChwbGF0Zm9ybUlkID09PSAzICYmIGVuY29kaW5nSWQgPT09IDEgJiYgKGhhc0VuY29kaW5nIHx8ICFwb3RlbnRpYWxUYWJsZSkpIHsKICAgICAgICAgIHVzZVRhYmxlID0gdHJ1ZTsKICAgICAgICAgIGlmICghaXNTeW1ib2xpY0ZvbnQpIHsKICAgICAgICAgICAgY2FuQnJlYWsgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoaXNTeW1ib2xpY0ZvbnQgJiYgcGxhdGZvcm1JZCA9PT0gMyAmJiBlbmNvZGluZ0lkID09PSAwKSB7CiAgICAgICAgICB1c2VUYWJsZSA9IHRydWU7CiAgICAgICAgICBsZXQgY29ycmVjdGx5U29ydGVkID0gdHJ1ZTsKICAgICAgICAgIGlmIChpIDwgbnVtVGFibGVzIC0gMSkgewogICAgICAgICAgICBjb25zdCBuZXh0Qnl0ZXMgPSBmaWxlLnBlZWtCeXRlcygyKSwKICAgICAgICAgICAgICBuZXh0UGxhdGZvcm1JZCA9IGludDE2KG5leHRCeXRlc1swXSwgbmV4dEJ5dGVzWzFdKTsKICAgICAgICAgICAgaWYgKG5leHRQbGF0Zm9ybUlkIDwgcGxhdGZvcm1JZCkgewogICAgICAgICAgICAgIGNvcnJlY3RseVNvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29ycmVjdGx5U29ydGVkKSB7CiAgICAgICAgICAgIGNhbkJyZWFrID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVzZVRhYmxlKSB7CiAgICAgICAgICBwb3RlbnRpYWxUYWJsZSA9IHsKICAgICAgICAgICAgcGxhdGZvcm1JZCwKICAgICAgICAgICAgZW5jb2RpbmdJZCwKICAgICAgICAgICAgb2Zmc2V0CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICBpZiAoY2FuQnJlYWspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocG90ZW50aWFsVGFibGUpIHsKICAgICAgICBmaWxlLnBvcyA9IHN0YXJ0ICsgcG90ZW50aWFsVGFibGUub2Zmc2V0OwogICAgICB9CiAgICAgIGlmICghcG90ZW50aWFsVGFibGUgfHwgZmlsZS5wZWVrQnl0ZSgpID09PSAtMSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiQ291bGQgbm90IGZpbmQgYSBwcmVmZXJyZWQgY21hcCB0YWJsZS4iKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGxldCBoYXNTaG9ydENtYXAgPSBmYWxzZTsKICAgICAgY29uc3QgbWFwcGluZ3MgPSBbXTsKICAgICAgbGV0IGosIGdseXBoSWQ7CiAgICAgIGlmIChmb3JtYXQgPT09IDApIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAyNTY7IGorKykgewogICAgICAgICAgY29uc3QgaW5kZXggPSBmaWxlLmdldEJ5dGUoKTsKICAgICAgICAgIGlmICghaW5kZXgpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgIGdseXBoSWQ6IGluZGV4CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaGFzU2hvcnRDbWFwID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmIChmb3JtYXQgPT09IDIpIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGNvbnN0IHN1YkhlYWRlcktleXMgPSBbXTsKICAgICAgICBsZXQgbWF4U3ViSGVhZGVyS2V5ID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICBjb25zdCBzdWJIZWFkZXJLZXkgPSBmaWxlLmdldFVpbnQxNigpID4+IDM7CiAgICAgICAgICBzdWJIZWFkZXJLZXlzLnB1c2goc3ViSGVhZGVyS2V5KTsKICAgICAgICAgIG1heFN1YkhlYWRlcktleSA9IE1hdGgubWF4KHN1YkhlYWRlcktleSwgbWF4U3ViSGVhZGVyS2V5KTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc3ViSGVhZGVycyA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IG1heFN1YkhlYWRlcktleTsgaSsrKSB7CiAgICAgICAgICBzdWJIZWFkZXJzLnB1c2goewogICAgICAgICAgICBmaXJzdENvZGU6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGVudHJ5Q291bnQ6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGlkRGVsdGE6IHNpZ25lZEludDE2KGZpbGUuZ2V0Qnl0ZSgpLCBmaWxlLmdldEJ5dGUoKSksCiAgICAgICAgICAgIGlkUmFuZ2VQb3M6IGZpbGUucG9zICsgZmlsZS5nZXRVaW50MTYoKQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgIGlmIChzdWJIZWFkZXJLZXlzW2ldID09PSAwKSB7CiAgICAgICAgICAgIGZpbGUucG9zID0gc3ViSGVhZGVyc1swXS5pZFJhbmdlUG9zICsgMiAqIGk7CiAgICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBjaGFyQ29kZTogaSwKICAgICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgcyA9IHN1YkhlYWRlcnNbc3ViSGVhZGVyS2V5c1tpXV07CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBzLmVudHJ5Q291bnQ7IGorKykgewogICAgICAgICAgICAgIGNvbnN0IGNoYXJDb2RlID0gKGkgPDwgOCkgKyBqICsgcy5maXJzdENvZGU7CiAgICAgICAgICAgICAgZmlsZS5wb3MgPSBzLmlkUmFuZ2VQb3MgKyAyICogajsKICAgICAgICAgICAgICBnbHlwaElkID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgICAgICBpZiAoZ2x5cGhJZCAhPT0gMCkgewogICAgICAgICAgICAgICAgZ2x5cGhJZCA9IChnbHlwaElkICsgcy5pZERlbHRhKSAlIDY1NTM2OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gNCkgewogICAgICAgIGZpbGUuc2tpcCgyICsgMik7CiAgICAgICAgY29uc3Qgc2VnQ291bnQgPSBmaWxlLmdldFVpbnQxNigpID4+IDE7CiAgICAgICAgZmlsZS5za2lwKDYpOwogICAgICAgIGNvbnN0IHNlZ21lbnRzID0gW107CiAgICAgICAgbGV0IHNlZ0luZGV4OwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50cy5wdXNoKHsKICAgICAgICAgICAgZW5kOiBmaWxlLmdldFVpbnQxNigpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgZmlsZS5za2lwKDIpOwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50c1tzZWdJbmRleF0uc3RhcnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIH0KICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudHNbc2VnSW5kZXhdLmRlbHRhID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICB9CiAgICAgICAgbGV0IG9mZnNldHNDb3VudCA9IDAsCiAgICAgICAgICBvZmZzZXRJbmRleDsKICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudCA9IHNlZ21lbnRzW3NlZ0luZGV4XTsKICAgICAgICAgIGNvbnN0IHJhbmdlT2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmICghcmFuZ2VPZmZzZXQpIHsKICAgICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IC0xOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldEluZGV4ID0gKHJhbmdlT2Zmc2V0ID4+IDEpIC0gKHNlZ0NvdW50IC0gc2VnSW5kZXgpOwogICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IG9mZnNldEluZGV4OwogICAgICAgICAgb2Zmc2V0c0NvdW50ID0gTWF0aC5tYXgob2Zmc2V0c0NvdW50LCBvZmZzZXRJbmRleCArIHNlZ21lbnQuZW5kIC0gc2VnbWVudC5zdGFydCArIDEpOwogICAgICAgIH0KICAgICAgICBjb25zdCBvZmZzZXRzID0gW107CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG9mZnNldHNDb3VudDsgaisrKSB7CiAgICAgICAgICBvZmZzZXRzLnB1c2goZmlsZS5nZXRVaW50MTYoKSk7CiAgICAgICAgfQogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50ID0gc2VnbWVudHNbc2VnSW5kZXhdOwogICAgICAgICAgc3RhcnQgPSBzZWdtZW50LnN0YXJ0OwogICAgICAgICAgY29uc3QgZW5kID0gc2VnbWVudC5lbmQ7CiAgICAgICAgICBjb25zdCBkZWx0YSA9IHNlZ21lbnQuZGVsdGE7CiAgICAgICAgICBvZmZzZXRJbmRleCA9IHNlZ21lbnQub2Zmc2V0SW5kZXg7CiAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBlbmQ7IGorKykgewogICAgICAgICAgICBpZiAoaiA9PT0gMHhmZmZmKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhJZCA9IG9mZnNldEluZGV4IDwgMCA/IGogOiBvZmZzZXRzW29mZnNldEluZGV4ICsgaiAtIHN0YXJ0XTsKICAgICAgICAgICAgZ2x5cGhJZCA9IGdseXBoSWQgKyBkZWx0YSAmIDB4ZmZmZjsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSA2KSB7CiAgICAgICAgZmlsZS5za2lwKDIgKyAyKTsKICAgICAgICBjb25zdCBmaXJzdENvZGUgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVudHJ5Q291bnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCBlbnRyeUNvdW50OyBqKyspIHsKICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgY29uc3QgY2hhckNvZGUgPSBmaXJzdENvZGUgKyBqOwogICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgICAgIGZpbGUuc2tpcCgyICsgNCArIDQpOwogICAgICAgIGNvbnN0IG5Hcm91cHMgPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG5Hcm91cHM7IGorKykgewogICAgICAgICAgY29uc3Qgc3RhcnRDaGFyQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGNvbnN0IGVuZENoYXJDb2RlID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgbGV0IGdseXBoQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGZvciAobGV0IGNoYXJDb2RlID0gc3RhcnRDaGFyQ29kZTsgY2hhckNvZGUgPD0gZW5kQ2hhckNvZGU7IGNoYXJDb2RlKyspIHsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGUsCiAgICAgICAgICAgICAgZ2x5cGhJZDogZ2x5cGhDb2RlKysKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgIC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cm47CiAgICAgIH0KICAgICAgZmlsZS5wb3MgPSAoZmlsZS5zdGFydCB8fCAwKSArIGhlYWRlci5vZmZzZXQ7CiAgICAgIGZpbGUucG9zICs9IDQ7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGNvbnN0IGNhcmV0T2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgZmlsZS5wb3MgKz0gODsKICAgICAgZmlsZS5wb3MgKz0gMjsKICAgICAgbGV0IG51bU9mTWV0cmljcyA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGlmIChjYXJldE9mZnNldCAhPT0gMCkgewogICAgICAgIGNvbnN0IG1hY1N0eWxlID0gaW50MTYoaGVhZFRhYmxlLmRhdGFbNDRdLCBoZWFkVGFibGUuZGF0YVs0NV0pOwogICAgICAgIGlmICghKG1hY1N0eWxlICYgMikpIHsKICAgICAgICAgIGhlYWRlci5kYXRhWzIyXSA9IDA7CiAgICAgICAgICBoZWFkZXIuZGF0YVsyM10gPSAwOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAobnVtT2ZNZXRyaWNzID4gbnVtR2x5cGhzKSB7CiAgICAgICAgKDAsIF91dGlsLmluZm8pKGBUaGUgbnVtT2ZNZXRyaWNzICgke251bU9mTWV0cmljc30pIHNob3VsZCBub3QgYmUgYCArIGBncmVhdGVyIHRoYW4gdGhlIG51bUdseXBocyAoJHtudW1HbHlwaHN9KS5gKTsKICAgICAgICBudW1PZk1ldHJpY3MgPSBudW1HbHlwaHM7CiAgICAgICAgaGVhZGVyLmRhdGFbMzRdID0gKG51bU9mTWV0cmljcyAmIDB4ZmYwMCkgPj4gODsKICAgICAgICBoZWFkZXIuZGF0YVszNV0gPSBudW1PZk1ldHJpY3MgJiAweDAwZmY7CiAgICAgIH0KICAgICAgY29uc3QgbnVtT2ZTaWRlYmVhcmluZ3MgPSBudW1HbHlwaHMgLSBudW1PZk1ldHJpY3M7CiAgICAgIGNvbnN0IG51bU1pc3NpbmcgPSBudW1PZlNpZGViZWFyaW5ncyAtIChtZXRyaWNzLmxlbmd0aCAtIG51bU9mTWV0cmljcyAqIDQgPj4gMSk7CiAgICAgIGlmIChudW1NaXNzaW5nID4gMCkgewogICAgICAgIGNvbnN0IGVudHJpZXMgPSBuZXcgVWludDhBcnJheShtZXRyaWNzLmxlbmd0aCArIG51bU1pc3NpbmcgKiAyKTsKICAgICAgICBlbnRyaWVzLnNldChtZXRyaWNzLmRhdGEpOwogICAgICAgIGlmIChkdXBGaXJzdEVudHJ5KSB7CiAgICAgICAgICBlbnRyaWVzW21ldHJpY3MubGVuZ3RoXSA9IG1ldHJpY3MuZGF0YVsyXTsKICAgICAgICAgIGVudHJpZXNbbWV0cmljcy5sZW5ndGggKyAxXSA9IG1ldHJpY3MuZGF0YVszXTsKICAgICAgICB9CiAgICAgICAgbWV0cmljcy5kYXRhID0gZW50cmllczsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVHbHlwaChzb3VyY2UsIHNvdXJjZVN0YXJ0LCBzb3VyY2VFbmQsIGRlc3QsIGRlc3RTdGFydCwgaGludHNWYWxpZCkgewogICAgICBjb25zdCBnbHlwaFByb2ZpbGUgPSB7CiAgICAgICAgbGVuZ3RoOiAwLAogICAgICAgIHNpemVPZkluc3RydWN0aW9uczogMAogICAgICB9OwogICAgICBpZiAoc291cmNlRW5kIC0gc291cmNlU3RhcnQgPD0gMTIpIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGNvbnN0IGdseWYgPSBzb3VyY2Uuc3ViYXJyYXkoc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ltqKytdOwogICAgICAgIGlmIChmbGFnICYgMHhjMCkgewogICAgICAgICAgZ2x5ZltqIC0gMV0gPSBmbGFnICYgMHgzZjsKICAgICAgICB9CiAgICAgICAgbGV0IHhMZW5ndGggPSAyOwogICAgICAgIGlmIChmbGFnICYgMikgewogICAgICAgICAgeExlbmd0aCA9IDE7CiAgICAgICAgfSBlbHNlIGlmIChmbGFnICYgMTYpIHsKICAgICAgICAgIHhMZW5ndGggPSAwOwogICAgICAgIH0KICAgICAgICBsZXQgeUxlbmd0aCA9IDI7CiAgICAgICAgaWYgKGZsYWcgJiA0KSB7CiAgICAgICAgICB5TGVuZ3RoID0gMTsKICAgICAgICB9IGVsc2UgaWYgKGZsYWcgJiAzMikgewogICAgICAgICAgeUxlbmd0aCA9IDA7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHh5TGVuZ3RoID0geExlbmd0aCArIHlMZW5ndGg7CiAgICAgICAgY29vcmRpbmF0ZXNMZW5ndGggKz0geHlMZW5ndGg7CiAgICAgICAgaWYgKGZsYWcgJiA4KSB7CiAgICAgICAgICBjb25zdCByZXBlYXQgPSBnbHlmW2orK107CiAgICAgICAgICBpICs9IHJlcGVhdDsKICAgICAgICAgIGNvb3JkaW5hdGVzTGVuZ3RoICs9IHJlcGVhdCAqIHh5TGVuZ3RoOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29vcmRpbmF0ZXNMZW5ndGggPT09IDApIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGxldCBnbHlwaERhdGFMZW5ndGggPSBqICsgY29vcmRpbmF0ZXNMZW5ndGg7CiAgICAgIGlmIChnbHlwaERhdGFMZW5ndGggPiBnbHlmLmxlbmd0aCkgewogICAgICAgIHJldHVybiBnbHlwaFByb2ZpbGU7CiAgICAgIH0KICAgICAgaWYgKCFoaW50c1ZhbGlkICYmIGluc3RydWN0aW9uc0xlbmd0aCA+IDApIHsKICAgICAgICBkZXN0LnNldChnbHlm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IGkrKywgaiArPSBpdGVtU2l6ZSkgewogICAgICAgIGxldCBvZmZzZXQgPSBpdGVtRGVjb2RlKGxvY2FEYXRhLCBqKTsKICAgICAgICBpZiAob2Zmc2V0ID4gb2xkR2x5ZkRhdGFMZW5ndGgpIHsKICAgICAgICAgIG9mZnNldCA9IG9sZEdseWZEYXRhTGVuZ3RoOwogICAgICAgIH0KICAgICAgICBsb2NhRW50cmllcy5wdXNoKHsKICAgICAgICAgIGluZGV4OiBpLAogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0OiAwCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgbG9jYUVudHJpZXMuc29ydCgoYSwgYikgPT4gewogICAgICAgIHJldHVybiBhLm9mZnNldCAtIGIub2Zmc2V0OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgbG9jYUVudHJpZXNbaV0uZW5kT2Zmc2V0ID0gbG9jYUVudHJpZXNbaSArIDFdLm9mZnNldDsKICAgICAgfQogICAgICBsb2NhRW50cmllcy5zb3J0KChhLCBiKSA9PiB7CiAgICAgICAgcmV0dXJuIGEuaW5kZXggLSBiLmluZGV4OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0CiAgICAgICAgfSA9IGxvY2FFbnRyaWVzW2ldOwogICAgICAgIGlmIChvZmZzZXQgIT09IDAgfHwgZW5kT2Zmc2V0ICE9PSAwKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY29uc3QgbmV4dE9mZnNldCA9IGxvY2FFbnRyaWVzW2kgKyAxXS5vZmZzZXQ7CiAgICAgICAgaWYgKG5leHRPZmZzZXQgPT09IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsb2N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bHNlIHsKICAgICAgICBnbHlmLmRhdGEgPSBuZXdHbHlmRGF0YS5zdWJhcnJheSgwLCB3cml0ZU9mZnNldCk7CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICBtaXNzaW5nR2x5cGhzLAogICAgICAgIG1heFNpemVPZkluc3RydWN0aW9ucwogICAgICB9OwogICAgfQogICAgZnVuY3Rpb24gcmVhZFBvc3RTY3JpcHRUYWJsZShwb3N0LCBwcm9wZXJ0aWVzT2JqLCBtYXhwTnVtR2x5cGhzKSB7CiAgICAgIGNvbnN0IHN0YXJ0ID0gKGZvbnQuc3RhcnQgfHwgMCkgKyBwb3N0Lm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbGVuZ3RoID0gcG9zdC5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IHZlcnNpb24gPSBmb250LmdldEludDMyKCk7CiAgICAgIGZvbnQuc2tpcCgyOCk7CiAgICAgIGxldCBnbHlwaE5hbWVzOwogICAgICBsZXQgdmFsaWQgPSB0cnVlOwogICAgICBsZXQgaTsKICAgICAgc3dpdGNoICh2ZXJzaW9uKSB7CiAgICAgICAgY2FzZSAweDAwMDEwMDAwOgogICAgICAgICAgZ2x5cGhOYW1lcyA9IF9mb250c191dGlscy5NYWNTdGFuZGFyZEdseXBoT3JkZXJpbmc7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDAwMjAwMDA6CiAgICAgICAgICBjb25zdCBudW1HbHlwaHMgPSBmb250LmdldFVpbnQxNigpOwogICAgICAgICAgaWYgKG51bUdseXBocyAhPT0gbWF4cE51bUdseXBocykgewogICAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGdseXBoTmFtZUluZGV4ZXMgPSBbXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1HbHlwaHM7ICsraSkgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgICAgICAgIGlmIChpbmRleCA+PSAzMjc2OCkgewogICAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhOYW1lSW5kZXhlcy5wdXNoKGluZGV4KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjdXN0b21OYW1lcyA9IFtdLAogICAgICAgICAgICBzdHJCdWYgPSBbXTsKICAgICAgICAgIHdoaWxlIChmb250LnBvcyA8IGVuZCkgewogICAgICAgICAgICBjb25zdCBzdHJpbmdMZW5ndGggPSBmb250LmdldEJ5dGUoKTsKICAgICAgICAgICAgc3RyQnVmLmxlbmd0aCA9IHN0cmluZ0xlbmd0aDsKICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHN0cmluZ0xlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgc3RyQnVmW2ldID0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldEJ5dGUoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3VzdG9tTmFtZXMucHVzaChzdHJCdWYuam9pbigiIikpOwogICAgICAgICAgfQogICAgICAgICAgZ2x5cGhOYW1lcyA9IFtdOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgKytpKSB7CiAgICAgICAgICAgIGNvbnN0IGogPSBnbHlwaE5hbWVJbmRleGVzW2ldOwogICAgICAgICAgICBpZiAoaiA8IDI1OCkgewogICAgICAgICAgICAgIGdseXBoTmFtZXMucHVzaChfZm9udHNfdXRpbHMuTWFjU3RhbmRhcmRHbHlwaE9yZGVyaW5nW2pdKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBnbHlwaE5hbWVzLnB1c2goY3VzdG9tTmFtZXNbaiAtIDI1OF0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDAwMDMwMDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5rbm93bi91bnN1cHBvcnRlZCBwb3N0IHRhYmxlIHZlcnNpb24gIiArIHZlcnNpb24pOwogICAgICAgICAgdmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGlmIChwcm9wZXJ0aWVzT2JqLmRlZmF1bHRFbmNvZGluZykgewogICAgICAgICAgICBnbHlwaE5hbWVzID0gcHJvcGVydGllc09iai5kZWZhdWx0RW5jb2Rpbmc7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwcm9wZXJ0aWVzT2JqLmdseXBoTmFtZXMgPSBnbHlwaE5hbWVzOwogICAgICByZXR1cm4gdmFsaWQ7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkTmFtZVRhYmxlKG5hbWVUYWJsZSkgewogICAgICBjb25zdCBzdGFydCA9IChmb250LnN0YXJ0IHx8IDApICsgbmFtZVRhYmxlLm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbmFtZXMgPSBbW10sIFtdXSwKICAgICAgICByZWNvcmRzID0gW107CiAgICAgIGNvbnN0IGxlbmd0aCA9IG5hbWVUYWJsZS5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IEZPUk1BVF8wX0hFQURFUl9MRU5HVEggPSA2OwogICAgICBpZiAoZm9ybWF0ICE9PSAwIHx8IGxlbmd0aCA8IEZPUk1BVF8wX0hFQURFUl9MRU5HVEgpIHsKICAgICAgICByZXR1cm4gW25hbWVzLCByZWNvcmRzXTsKICAgICAgfQogICAgICBjb25zdCBudW1SZWNvcmRzID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3Qgc3RyaW5nc1N0YXJ0ID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3QgTkFNRV9SRUNPUkRfTEVOR1RIID0gMTI7CiAgICAgIGxldCBpLCBpaTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bVJlY29yZHMgJiYgZm9udC5wb3MgKyBOQU1FX1JFQ09SRF9MRU5HVEggPD0gZW5kOyBpKyspIHsKICAgICAgICBjb25zdCByID0gewogICAgICAgICAgcGxhdGZvcm06IGZvbnQuZ2V0VWludDE2KCksCiAgICAgICAgICBlbmNvZGluZzogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxhbmd1YWdlOiBmb250LmdldFVpbnQxNigpLAogICAgICAgICAgbmFtZTogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxlbmd0aDogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIG9mZnNldDogZm9udC5nZXRVaW50MTYoKQogICAgICAgIH07CiAgICAgICAgaWYgKGlzTWFjTmFtZVJlY29yZChyKSB8fCBpc1dpbk5hbWVSZWNvcmQocikpIHsKICAgICAgICAgIHJlY29yZHMucHVzaChyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChpID0gMCwgaWkgPSByZWNvcmRzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCByZWNvcmQgPSByZWNvcmRzW2ldOwogICAgICAgIGlmIChyZWNvcmQubGVuZ3RoIDw9IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBwb3MgPSBzdGFydCArIHN0cmluZ3NTdGFydCArIHJlY29yZC5vZmZzZXQ7CiAgICAgICAgaWYgKHBvcyArIHJlY29yZC5sZW5ndGggPiBlbmQpIHsKICAgICAgICAgIGNvbnR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ogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBzdGFjay5wdXNoKGRhdGFbaSsrXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDQxKSB7CiAgICAgICAgICBuID0gZGF0YVtpKytdOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjApIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjAgKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IG47IGorKykgewogICAgICAgICAgICAgIHN0YWNrLnB1c2goZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjgpIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjggKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmIgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKCFpbkZERUYgJiYgIWluRUxTRSkgewogICAgICAgICAgICBmdW5jSWQgPSBzdGFjay5hdCgtMSk7CiAgICAgICAgICAgIGlmIChpc05hTihmdW5jSWQpKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUVDogQ0FMTCBlbXB0eSBzdGFjayAob3IgaW52YWxpZCBlbnRyeSkuIik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1VzZWRbZnVuY0lkXSA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGZ1bmNJZCBpbiB0dENvbnRleHQuZnVuY3Rpb25zU3RhY2tEZWx0YXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG5ld1N0YWNrTGVuZ3RoID0gc3RhY2subGVuZ3RoICsgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF07CiAgICAgICAgICAgICAgICBpZiAobmV3U3RhY2tMZW5ndGggPCAwKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IENBTEwgaW52YWxpZCBmdW5jdGlvbnMgc3RhY2sgZGVsdGEuIik7CiAgICAgICAgICAgICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YWNrLmxlbmd0aCA9IG5ld1N0YWNrTGVuZ3RoOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoZnVuY0lkIGluIHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkICYmICFmdW5jdGlvbnNDYWxsZWQuaW5jbHVkZXMoZnVuY0lkKSkgewogICAgICAgICAgICAgICAgY2FsbHN0YWNrLnB1c2goewogICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICBpLAogICAgICAgICAgICAgICAgICBzdGFja1RvcDogc3RhY2subGVuZ3RoIC0gMQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbnNDYWxsZWQucHVzaChmdW5jSWQpOwogICAgICAgICAgICAgICAgcGMgPSB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdOwogICAgICAgICAgICAgICAgaWYgKCFwYykgewogICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBDQUxMIG5vbi1leGlzdGVudCBmdW5jdGlvbiIpOwogICAgICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBkYXRhID0gcGMuZGF0YTsKICAgICAgICAgICAgICAgIGkgPSBwYy5pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmMgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogbmVzdGVkIEZERUZzIG5vdCBhbGxvd2VkIik7CiAgICAgICAgICAgIHRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucyA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBpbkZERUYgPSB0cnVlOwogICAgICAgICAgbGFzdERlZmYgPSBpOwogICAgICAgICAgZnVuY0lkID0gc3RhY2sucG9wKCk7CiAgICAgICAgICB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdID0gewogICAgICAgICAgICBkYXRhLAogICAgICAgICAgICBpCiAgICAgICAgICB9OwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmQpIHsKICAgICAgICAgIGlmIChpbkZERUYpIHsKICAgICAgICAgICAgaW5GREVGID0gZmFsc2U7CiAgICAgICAgICAgIGxhc3RFbmRmID0gaTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBjID0gY2FsbHN0YWNrLnBvcCgpOwogICAgICAgICAgICBpZiAoIXBjKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogRU5ERiBiYWQgc3RhY2siKTsKICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jSWQgPSBmdW5jdGlvbnNDYWxsZWQucG9wKCk7CiAgICAgICAgICAgIGRhdGEgPSBwYy5kYXRhOwogICAgICAgICAgICBpID0gcGMuaTsKICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF0gPSBzdGFjay5sZW5ndGggLSBwYy5zdGFja1RvcDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDg5KSB7CiAgICAgICAgICBpZiAoaW5GREVGIHx8IGluRUxTRSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBuZXN0ZWQgSURFRnMgbm90IGFsbG93ZWQiKTsKICAgICAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGluRkRFRiA9IHRydWU7CiAgICAgICAgICBsYXN0RGVmZiA9IGk7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OCkgewogICAgICAgICAgKytpZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWIpIHsKICAgICAgICAgIGluRUxTRSA9IGlmTGV2ZWw7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OSkgewogICAgICAgICAgaWYgKGluRUxTRSA9PT0gaWZMZXZlbCkgewogICAgICAgICAgICBpbkVMU0UgPSAwOwogICAgICAgICAgfQogICAgICAgICAgLS1pZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWMpIHsKICAgICAgICAgIGlmICghaW5GREVGICYmICFpbkVMU0UpIHsKICAgICAgICAgICAgY29uc3Qgb2Zmc2V0ID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICBpZiAob2Zmc2V0ID4gMCkgewogICAgICAgICAgICAgIGkgKz0gb2Zmc2V0IC0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIWluRkRFRiAmJiAhaW5FTFNFKSB7CiAgICAgICAgICBsZXQgc3RhY2tEZWx0YSA9IDA7CiAgICAgICAgICBpZiAob3AgPD0gMHg4ZSkgewogICAgICAgICAgICBzdGFja0RlbHRhID0gVFRPcHNTdGFja0RlbHRhc1tvcF07CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4YzAgJiYgb3AgPD0gMHhkZikgewogICAgICAgICAgICBzdGFja0RlbHRhID0gLTE7CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4ZTApIHsKICAgICAgICAgICAgc3RhY2tEZWx0YSA9IC0yOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG9wID49IDB4NzEgJiYgb3AgPD0gMHg3NSkgewogICAgICAgICAgICBuID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghaXNOYU4obikpIHsKICAgICAgICAgICAgICBzdGFja0RlbHRhID0gLW4gKiAyOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2tEZWx0YSA8IDAgJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgICAgc3RhY2tEZWx0YSsrOwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN0YWNrRGVsdGEgPiAwKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goTmFOKTsKICAgICAgICAgICAgc3RhY2tEZWx0YS0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBjb25zdCBjb250ZW50ID0gW2RhdGFdOwogICAgICBpZiAoaSA+IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgY29udGVudC5wdXNoKG5ldyBVaW50OEFycmF5KGkgLSBkYXRhLmxlbmd0aCkpOwogICAgICB9CiAgICAgIGlmIChsYXN0RGVmZiA+IGxhc3RFbmRmKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogY29tcGxlbWVudGluZyBhIG1pc3NpbmcgZnVuY3Rpb24gdGFpbCIpOwogICAgICAgIGNvbnRlbnQucHVzaChuZXcgVWludDhBcnJheShbMHgyMiwgMHgyZF0pKTsKICAgICAgfQogICAgICBmb2xkVFRUYWJsZSh0YWJsZSwgY29udGVudCk7CiAgICB9CiAgICBmdW5jdGlvbiBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpIHsKICAgICAgaWYgKHR0Q29udGV4dC50b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkLmxlbmd0aCA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IG1vcmUgZnVuY3Rpb25zIGRlZmluZWQgdGhhbiBleHBlY3RlZCIpOwogICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICBpZiAoaiA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogaW52YWxpZCBmdW5jdGlvbiBpZDogIiArIGopOwogICAgICAgICAgdHRDb250ZXh0LmhpbnRzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkW2pdICYmICF0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtqXSkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogdW5kZWZpbmVkIGZ1bmN0aW9uOiAiICsgaik7CiAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gZm9sZFRUVGFibGUodGFibGUsIGNvbnRlbnQpIHsKICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID4gMSkgewogICAgICAgIGxldCBuZXdMZW5ndGggPSAwOwogICAgICAgIGxldCBqLCBqajsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgbmV3TGVuZ3RoICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBuZXdMZW5ndGggPSBuZXdMZW5ndGggKyAzICYgfjM7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkobmV3TGVuZ3RoKTsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgcmVzdWx0LnNldChjb250ZW50W2pdLCBwb3MpOwogICAgICAgICAgcG9zICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICB0YWJsZS5kYXRhID0gcmVzdWx0OwogICAgICAgIHRhYmxlLmxlbmd0aCA9IG5ld0xlbmd0aDsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVUVFByb2dyYW1zKGZwZ20sIHByZXAsIGN2dCwgbWF4RnVuY3Rpb25EZWZzKSB7CiAgICAgIGNvbnN0IHR0Q29udGV4dCA9IHsKICAgICAgICBmdW5jdGlvbnNEZWZpbmVkOiBbXSwKICAgICAgICBmdW5jdGlvbnNVc2VkOiBbXSwKICAgICAgICBmdW5jdGlvbnNTdGFja0RlbHRhczogW10sCiAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOiBmYWxzZSwKICAgICAgICBoaW50c1ZhbGlkOiB0cnVlCiAgICAgIH07CiAgICAgIGlmIChmcGdtKSB7CiAgICAgICAgc2FuaXRpemVUVFByb2dyYW0oZnBnbSwgdHRDb250ZXh0KTsKICAgICAgfQogICAgICBpZiAocHJlcCkgewogICAgICAgIHNhbml0aXplVFRQcm9ncmFtKHByZXAsIHR0Q29udGV4dCk7CiAgICAgIH0KICAgICAgaWYgKGZwZ20pIHsKICAgICAgICBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpOwogICAgICB9CiAgICAgIGlmIChjdnQgJiYgY3Z0Lmxlbmd0aCAmIDEpIHsKICAgICAgICBjb25zdCBjdnREYXRhID0gbmV3IFVpbnQ4QXJyYXkoY3Z0Lmxlbmd0aCArIDEpOwogICAgICAgIGN2dERhdGEuc2V0KGN2dC5kYXRhKTsKICAgICAgICBjdnQuZGF0YSA9IGN2dERhdGE7CiAgICAgIH0KICAgICAgcmV0dXJuIHR0Q29udGV4dC5oaW50c1ZhbGlkO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jZmZGaWxlLCBwcm9wZXJ0aWVzKTsKICAgICAgICBhZGp1c3RXaWR0aHMocHJvcGVydGllcyk7CiAgICAgICAgcmV0dXJuIHRoaXMuY29udmVydChuYW1lLCBjZmYsIHByb3BlcnRpZXMpOwogICAgICB9CiAgICAgIGRlbGV0ZSB0YWJsZXMuZ2x5ZjsKICAgICAgZGVsZXRlIHRhYmxlcy5sb2NhOwogICAgICBkZWxldGUgdGFibGVzLmZwZ207CiAgICAgIGRlbGV0ZSB0YWJsZXMucHJlcDsKICAgICAgZGVsZXRlIHRhYmxlc1siY3Z0ICJdOwogICAgICB0aGlzLmlzT3BlblR5cGUgPSB0cnVlOwogICAgfSBlbHNlIHsKICAgICAgaWYgKCF0YWJsZXMubG9jYSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcignUmVxdWlyZWQgImxvY2EiIHRhYmxlIGlzIG5vdCBmb3VuZCcpOwogICAgICB9CiAgICAgIGlmICghdGFibGVzLmdseWYpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoJ1JlcXVpcmVkICJnbHlmIiB0YWJsZSBpcyBub3QgZm91bmQgLS0gdHJ5aW5nIHRvIHJlY292ZXIuJyk7CiAgICAgICAgdGFibGVzLmdseWYgPSB7CiAgICAgICAgICB0YWc6ICJnbHlmIiwKICAgICAgICAgIGRhdGE6IG5ldyBVaW50OEFycmF5KDApCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aGlzLmlzT3BlblR5cGUgPSBmYWxzZTsKICAgIH0KICAgIGlmICghdGFibGVzLm1heHApIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdSZXF1aXJlZCAibWF4cCIgdGFibGUgaXMgbm90IGZvdW5kJyk7CiAgICB9CiAgICBmb250LnBvcyA9IChmb250LnN0YXJ0IHx8IDApICsgdGFibGVzLm1heHAub2Zmc2V0OwogICAgY29uc3QgdmVyc2lvbiA9IGZvbnQuZ2V0SW50MzIoKTsKICAgI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TsKICAgICAgICAgIGlmIChjbWFwUGxhdGZvcm1JZCA9PT0gMyAmJiBjbWFwRW5jb2RpbmdJZCA9PT0gMSkgewogICAgICAgICAgICB1bmljb2RlT3JDaGFyQ29kZSA9IGdseXBoc1VuaWNvZGVNYXBbc3RhbmRhcmRHbHlwaE5hbWVdOwogICAgICAgICAgfSBlbHNlIGlmIChjbWFwUGxhdGZvcm1JZCA9PT0gMSAmJiBjbWFwRW5jb2RpbmdJZCA9PT0gMCkgewogICAgICAgICAgICB1bmljb2RlT3JDaGFyQ29kZSA9IF9lbmNvZGluZ3MuTWFjUm9tYW5FbmNvZGluZy5pbmRleE9mKHN0YW5kYXJkR2x5cGhOYW1lKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh1bmljb2RlT3JDaGFyQ29kZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgIGlmICghcHJvcGVydGllcy5nbHlwaE5hbWVzICYmIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgJiYgISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICAgICAgICBjb25zdCB1bmljb2RlID0gdGhpcy50b1VuaWNvZGUuZ2V0KGNoYXJDb2RlKTsKICAgICAgICAgICAgICBpZiAodW5pY29kZSkgewogICAgICAgICAgICAgICAgdW5pY29kZU9yQ2hhckNvZGUgPSB1bmljb2RlLmNvZGVQb2ludEF0KDApOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodW5pY29kZU9yQ2hhckNvZGUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGNvbnN0IG1hcHBpbmcgb2YgY21hcE1hcHBpbmdzKSB7CiAgICAgICAgICAgIGlmIChtYXBwaW5nLmNoYX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lwaElkW2ldICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBnbHlwaE5hbWUgPSB0aGlzLmRpZmZlcmVuY2VzW2ldIHx8IGJhc2VFbmNvZGluZ1tpXTsKICAgICAgICAgIGlmICghZ2x5cGhOYW1lKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgZ2x5cGhJZCA9IHByb3BlcnRpZXMuZ2x5cGhOYW1lcy5pbmRleE9mKGdseXBoTmFtZSk7CiAgICAgICAgICBpZiAoZ2x5cGhJZCA+IDAgJiYgaGFzR2x5cGgoZ2x5cGhJZCkpIHsKICAgICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbaV0gPSBnbHlwaElkOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgaWYgKGNoYXJDb2RlVG9HbHlwaElkLmxlbmd0aCA9PT0gMCkgewogICAgICBjaGFyQ29kZVRvR2x5cGhJZFswXSA9IDA7CiAgICB9CiAgICBsZXQgZ2x5cGhaZXJvSWQgPSBudW1HbHlwaHNPdXQgLSAxOwogICAgaWYgKCFkdXBGaXJzdEVudHJ5KSB7CiAgICAgIGdseXBoWmVyb0lkID0gMDsKICAgIH0KICAgIGlmICghcHJvcGVydGllcy5jc3NGb250SW5mbykgewogICAgICBjb25zdCBuZXdNYXBwaW5nID0gYWRqdXN0TWFwcGluZyhjaGFyQ29kZVRvR2x5cGhJZCwgaGFzR2x5cGgsIGdseXBoWmVyb0lkLCB0aGlzLnRvVW5pY29kZSk7CiAgICAgIHRoaXMudG9Gb250Q2hhciA9IG5ld01hcHBpbmcudG9Gb250Q2hhcjsKICAgICAgdGFibGVzLmNtYXAgPSB7CiAgICAgICAgdGFnOiAiY21hcCIsCiAgICAgICAgZGF0YTogY3JlYXRlQ21hcFRhYmxlKG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWQsIG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gICAgICBkYXRhOiBjcmVhdGVOYW1lVGFibGUodGhpcy5uYW1lKQogICAgICB9OwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgW25hbWVQcm90b3R5cGUsIG5hbWVSZWNvcmRzXSA9IHJlYWROYW1lVGFibGUodGFibGVzLm5hbWUpOwogICAgICB0YWJsZXMubmFtZS5kYXRhID0gY3JlYXRlTmFtZVRhYmxlKG5hbWUsIG5hbWVQcm90b3R5cGUpOwogICAgICB0aGlzLnBzTmFtZSA9IG5hbWVQcm90b3R5cGVbMF1bNl0gfHwgbnVsbDsKICAgICAgaWYgKCFwcm9wZXJ0aWVzLmNvbXBvc2l0ZSkgewogICAgICAgIGFkanVzdFRydWVUeXBlVG9Vbmljb2RlKHByb3BlcnRpZXMsIHRoaXMuaXNTeW1ib2xpY0ZvbnQsIG5hbWVSZWNvcmRzKTsKICAgICAgfQogICAgfQogICAgY29uc3QgYnVpbGRlciA9IG5ldyBfb3BlbnR5cGVfZmlsZV9idWlsZGVyLk9wZW5UeXBlRmlsZUJ1aWxkZXIoaGVhZGVyLnZlcnNpb24pOwogICAgZm9yIChjb25zdCB0YWJsZVRhZyBpbiB0YWJsZXMpIHsKICAgICAgYnVpbGRlci5hZGRUYWJsZSh0YWJsZVRhZywgdGFibGVzW3RhYmxlVGFnXS5kYXRhKTsKICAgIH0KICAgIHJldHVybiBidWlsZGVyLnRvQXJyYXkoKTsKICB9CiAgY29udmVydChmb250TmFtZSwgZm9udCwgcHJvcGVydGllcykgewogICAgcHJvcGVydGllcy5maXhlZFBpdGNoID0gZmFsc2U7CiAgICBpZiAocHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpIHsKICAgICAgYWRqdXN0VHlwZTFUb1VuaWNvZGUocHJvcGVydGllcywgcHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpOwogICAgfQogICAgbGV0IGdseXBoWmVyb0lkID0gMTsKICAgIGlmIChmb250IGluc3RhbmNlb2YgX2NmZl9mb250LkNGRkZvbnQpIHsKICAgICAgZ2x5cGhaZXJvSWQgPSBmb250Lm51bUdseXBocyAtIDE7CiAgICB9CiAgICBjb25zdCBtYXBwaW5nID0gZm9udC5nZXRHbHlwaE1hcHBpbmcocHJvcGVydGllcyk7CiAgICBsZXQgbmV3TWFwcGluZyA9IG51bGw7CiAgICBsZXQgbmV3Q2hhckNvZGVUb0dseXBoSWQgPSBtYXBwaW5nOwogICAgbGV0IHRvVW5pY29kZUV4dHJhTWFwID0gbnVsbDsKICAgIGlmICghcHJvcGVydGllcy5jc3NGb250SW5mbykgewogICAgICBuZXdNYXBwaW5nID0gYWRqdXN0TWFwcGluZyhtYXBwaW5nLCBmb250Lmhhc0dseXBoSWQuYmluZChmb250KSwgZ2x5cGhaZXJvSWQsIHRoaXMudG9Vbmljb2RlKTsKICAgICAgdGhpcy50b0ZvbnRDaGFyID0gbmV3TWFwcGluZy50b0ZvbnRDaGFyOwogICAgICBuZXdDaGFyQ29kZVRvR2x5cGhJZCA9IG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWQ7CiAgICAgIHRvVW5pY29kZUV4dHJhTWFwID0gbmV3TWFwcGluZy50b1VuaWNvZGVFeHRyYU1hcDsKICAgIH0KICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQubnVtR2x5cGhzOwogICAgZnVuY3Rpb24gZ2V0Q2hhckNvZGVzKGNoYXJDb2RlVG9HbHlwaElkLCBnbHlwaElkKSB7CiAgICAgIGxldCBjaGFyQ29kZXMgPSBudWxsOwogICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIGluIGNoYXJDb2RlVG9HbHlwaElkKSB7CiAgICAgICAgaWYgKGdseXBoSWQgPT09IGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSkgewogICAgICAgICAgaWYgKCFjaGFyQ29kZXMpIHsKICAgICAgICAgICAgY2hhckNvZGVzID0gW107CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZXMucHVzaChjaGFyQ29kZSB8IDApOwogICAgIC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ikgewogICAgICAgIGZvbnRDaGFyID0gU3RyaW5nLmZyb21Db2RlUG9pbnQoZm9udENoYXJDb2RlKTsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGNoYXJUb0dseXBoIC0gaW52YWxpZCBmb250Q2hhckNvZGU6ICR7Zm9udENoYXJDb2RlfWApOwogICAgICB9CiAgICB9CiAgICBnbHlwaCA9IG5ldyBHbHlwaChjaGFyY29kZSwgZm9udENoYXIsIHVuaWNvZGUsIGFjY2VudCwgd2lkdGgsIHZtZXRyaWMsIG9wZXJhdG9yTGlzdElkLCBpc1NwYWNlLCBpc0luRm9udCk7CiAgICByZXR1cm4gdGhpcy5fZ2x5cGhDYWNoZVtjaGFyY29kZV0gPSBnbHlwaDsKICB9CiAgY2hhcnNUb0dseXBocyhjaGFycykgewogICAgbGV0IGdseXBocyA9IHRoaXMuX2NoYXJzQ2FjaGVbY2hhcnNdOwogICAgaWYgKGdseXBocykgewogICAgICByZXR1cm4gZ2x5cGhzOwogICAgfQogICAgZ2x5cGhzID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpLAogICAgICAgIGlpID0gY2hhcnMubGVuZ3RoOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgaWkpIHsKICAgICAgICB0aGlzLmNNYXAucmVhZENoYXJDb2RlKGNoYXJzLCBpLCBjKTsKICAgICAgICBjb25zdCB7CiAgICAgICAgICBjaGFyY29kZSwKICAgICAgICAgIGxlbmd0aAogICAgICAgIH0gPSBjOwogICAgICAgIGkgKz0gbGVuZ3RoOwogICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5fY2hhclRvR2x5cGgoY2hhcmNvZGUsIGxlbmd0aCA9PT0gMSAmJiBjaGFycy5jaGFyQ29kZUF0KGkgLSAxKSA9PT0gMHgyMCk7CiAgICAgICAgZ2x5cGhzLnB1c2goZ2x5cGgpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjaGFycy5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgY29uc3QgY2hhcmNvZGUgPSBjaGFycy5jaGFyQ29kZUF0KGkpOwogICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5fY2hhclRvR2x5cGgoY2hhcmNvZGUsIGNoYXJjb2RlID09PSAweDIwKTsKICAgICAgICBnbHlwaHMucHVzaChnbHlwaCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLl9jaGFyc0NhY2hlW2NoYXJzXSA9IGdseXBoczsKICB9CiAgZ2V0Q2hhclBvc2l0aW9ucyhjaGFycykgewogICAgY29uc3QgcG9zaXRpb25zID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgY2hhcnMubGVuZ3RoKSB7CiAgICAgICAgdGhpcy5jTWFwLnJlYWRDaGFyQ29kZShjaGFycywgaSwgYyk7CiAgICAgICAgY29uc3QgbGVuZ3RoID0gYy5sZW5ndGg7CiAgICAgICAgcG9zaXRpb25zLnB1c2goW2ksIGkgKyBsZW5ndGhdKTsKICAgICAgICBpICs9IGxlbmd0aDsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2hhcnMubGVuZ3RoOyBpIDwgaWk7ICsraSkgewogICAgICAgIHBvc2l0aW9ucy5wdXNoKFtpLCBpICsgMV0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zaXRpb25zOwogIH0KICBnZXQgZ2x5cGhDYWNoZVZhbHVlcygpIHsKICAgIHJldHVybiBPYmplY3QudmFsdWVzKHRoaXMuX2dseXBoQ2FjaGUpOwogIH0KICBlbmNvZGVTdHJpbmcoc3RyKSB7CiAgICBjb25zdCBidWZmZXJzID0gW107CiAgICBjb25zdCBjdXJyZW50QnVmID0gW107CiAgICBjb25zdCBoYXNDdXJyZW50QnVmRXJyb3JzID0gKCkgPT4gYnVmZmVycy5sZW5ndGggJSAyID09PSAxOwogICAgY29uc3QgZ2V0Q2hhckNvZGUgPSB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCA/IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZih1bmljb2RlKSA6IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZihTdHJpbmcuZnJvbUNvZGVQb2ludCh1bmljb2RlKSk7CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBzdHIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICBjb25zdCB1bmljb2RlID0gc3RyLmNvZGVQb2ludEF0KGkpOwogICAgICBpZiAodW5pY29kZSA+IDB4ZDdmZiAmJiAodW5pY29kZSA8IDB4ZTAwMCB8fCB1bmljb2RlID4gMHhmZmZkKSkgewogICAgICAgIGkrKzsKICAgICAgfQogICAgICBpZiAodGhpcy50b1VuaWNvZGUpIHsKICAgICAgICBjb25zdCBjaGFyQ29kZSA9IGdldENoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGlmIChjaGFyQ29kZSAhPT0gLTEpIHsKICAgICAgICAgIGlmIChoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICAgICAgYnVmZmVycy5wdXNoKGN1cnJlbnRCdWYuam9pbigiIikpOwogICAgICAgICAgICBjdXJyZW50QnVmLmxlbmd0aCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjaGFyQ29kZUxlbmd0aCA9IHRoaXMuY01hcCA/IHRoaXMuY01hcC5nZXRDaGFyQ29kZUxlbmd0aChjaGFyQ29kZSkgOiAxOwogICAgICAgICAgZm9yIChsZXQgaiA9IGNoYX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AgY29uc3QgYjEgPSBiID4+IDQ7CiAgICAgICAgY29uc3QgYjIgPSBiICYgMTU7CiAgICAgICAgaWYgKGIxID09PSBlb2YpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHIgKz0gbG9va3VwW2IxXTsKICAgICAgICBpZiAoYjIgPT09IGVvZikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHN0ciArPSBsb29rdXBbYjJdOwogICAgICB9CiAgICAgIHJldHVybiBwYXJzZUZsb2F0KHN0cik7CiAgICB9CiAgICBsZXQgb3BlcmFuZHMgPSBbXTsKICAgIGNvbnN0IGVudHJpZXMgPSBbXTsKICAgIHBvcyA9IDA7CiAgICBjb25zdCBlbmQgPSBkaWN0Lmxlbmd0aDsKICAgIHdoaWxlIChwb3MgPCBlbmQpIHsKICAgICAgbGV0IGIgPSBkaWN0W3Bvc107CiAgICAgIGlmIChiIDw9IDIxKSB7CiAgICAgICAgaWYgKGIgPT09IDEyKSB7CiAgICAgICAgICBiID0gYiA8PCA4IHwgZGljdFsrK3Bvc107CiAgICAgICAgfQogICAgICAgIGVudHJpZXMucHVzaChbYiwgb3BlcmFuZHNdKTsKICAgICAgICBvcGVyYW5kcyA9IFtdOwogICAgICAgICsrcG9zOwogICAgICB9IGVsc2UgewogICAgICAgIG9wZXJhbmRzLnB1c2gocGFyc2VPcGVyYW5kKCkpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW50cmllczsKICB9CiAgcGFyc2VJbmRleChwb3MpIHsKICAgIGNvbnN0IGNmZkluZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBjb25zdCBieXRlcyA9IHRoaXMuYnl0ZXM7CiAgICBjb25zdCBjb3VudCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgY29uc3Qgb2Zmc2V0cyA9IFtdOwogICAgbGV0IGVuZCA9IHBvczsKICAgIGxldCBpLCBpaTsKICAgIGlmIChjb3VudCAhPT0gMCkgewogICAgICBjb25zdCBvZmZzZXRTaXplID0gYnl0ZXNbcG9zKytdOwogICAgICBjb25zdCBzdGFydFBvcyA9IHBvcyArIChjb3VudCArIDEpICogb2Zmc2V0U2l6ZSAtIDE7CiAgICAgIGZvciAoaSA9IDAsIGlpID0gY291bnQgKyAxOyBpIDwgaWk7ICsraSkgewogICAgICAgIGxldCBvZmZzZXQgPSAwOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgb2Zmc2V0U2l6ZTsgKytqKSB7CiAgICAgICAgICBvZmZzZXQgPDw9IDg7CiAgICAgICAgICBvZmZzZXQgKz0gYnl0ZXNbcG9zKytdOwogICAgICAgIH0KICAgICAgICBvZmZzZXRzLnB1c2goc3RhcnRQb3MgKyBvZmZzZXQpOwogICAgICB9CiAgICAgIGVuZCA9IG9mZnNldHNbY291bnRdOwogICAgfQogICAgZm9yIChpID0gMCwgaWkgPSBvZmZzZXRzLmxlbmd0aCAtIDE7IGkgPCBpaTsgKytpKSB7CiAgICAgIGNvbnN0IG9mZnNldFN0YXJ0ID0gb2Zmc2V0c1tpXTsKICAgICAgY29uc3Qgb2Zmc2V0RW5kID0gb2Zmc2V0c1tpICsgMV07CiAgICAgIGNmZkluZGV4LmFkZChieXRlcy5zdWJhcnJheShvZmZzZXRTdGFydCwgb2Zmc2V0RW5kKSk7CiAgICB9CiAgICByZXR1cm4gewogICAgICBvYmo6IGNmZkluZGV4LAogICAgICBlbmRQb3M6IGVuZAogICAgfTsKICB9CiAgcGFyc2VOYW1lSW5kZXgoaW5kZXgpIHsKICAgIGNvbnN0IG5hbWVzID0gW107CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBpbmRleC5jb3VudDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgbmFtZSA9IGluZGV4LmdldChpKTsKICAgICAgbmFtZXMucHVzaCgoMCwgX3V0aWwuYnl0ZXNUb1N0cmluZykobmFtZSkpOwogICAgfQogICAgcmV0dXJuIG5hbWV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SArIGRhdGFbal0gKyAxMDggOiAtKHZhbHVlIC0gMjUxIDw8IDgpIC0gZGF0YVtqXSAtIDEwODsKICAgICAgICBqKys7CiAgICAgICAgc3RhY2tTaXplKys7CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPT09IDI1NSkgewogICAgICAgIHN0YWNrW3N0YWNrU2l6ZV0gPSAoZGF0YVtqXSA8PCAyNCB8IGRhdGFbaiArIDFdIDw8IDE2IHwgZGF0YVtqICsgMl0gPDwgOCB8IGRhdGFbaiArIDNdKSAvIDY1NTM2OwogICAgICAgIGogKz0gNDsKICAgICAgICBzdGFja1NpemUrKzsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMTkgfHwgdmFsdWUgPT09IDIwKSB7CiAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgaiArPSBzdGF0ZS5oaW50cyArIDcgPj4gMzsKICAgICAgICBzdGFja1NpemUgJT0gMjsKICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPT09IDEwIHx8IHZhbHVlID09PSAyOSkgewogICAgICAgIGxldCBzdWJyc0luZGV4OwogICAgICAgIGlmICh2YWx1ZSA9PT0gMTApIHsKICAgICAgICAgIHN1YnJzSW5kZXggPSBsb2NhbFN1YnJJbmRleDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3VicnNJbmRleCA9IGdsb2JhbFN1YnJJbmRleDsKICAgICAgICB9CiAgICAgICAgaWYgKCFzdWJyc0luZGV4KSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk1pc3Npbmcgc3VicnNJbmRleCBmb3IgIiArIHZhbGlkYXRpb25Db21tYW5kLmlkKTsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgbGV0IGJpYXMgPSAzMjc2ODsKICAgICAgICBpZiAoc3VicnNJbmRleC5jb3VudCA8IDEyNDApIHsKICAgICAgICAgIGJpYXMgPSAxMDc7CiAgICAgICAgfSBlbHNlIGlmIChzdWJyc0luZGV4LmNvdW50IDwgMzM5MDApIHsKICAgICAgICAgIGJpYXMgPSAxMTMxOwogICAgICAgIH0KICAgICAgICBjb25zdCBzdWJyTnVtYmVyID0gc3RhY2tbLS1zdGFja1NpemVdICsgYmlhczsKICAgICAgICBpZiAoc3Vick51bWJlciA8IDAgfHwgc3Vick51bWJlciA+PSBzdWJyc0luZGV4LmNvdW50IHx8IGlzTmFOKHN1YnJOdW1iZXIpKSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk91dCBvZiBib3VuZHMgc3VickluZGV4IGZvciAiICsgdmFsaWRhdGlvbkNvbW1hbmQuaWQpOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5zdGFja1NpemUgPSBzdGFja1NpemU7CiAgICAgICAgc3RhdGUuY2FsbERlcHRoKys7CiAgICAgICAgY29uc3QgdmFsaWQgPSB0aGlzLnBhcnNlQ2hhclN0cmluZyhzdGF0ZSwgc3VicnNJbmRleC5nZXQoc3Vick51bWJlciksIGxvY2FsU3VickluZGV4LCBnbG9iYWxTdWJySW5kZXgpOwogICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgc3RhdGUuY2FsbERlcHRoLS07CiAgICAgICAgc3RhY2tTaXplID0gc3RhdGUuc3RhY2tTaXplOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSAxMS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1hbmQpIHsKICAgICAgICAgIGlmICghc3RhdGUudW5kZWZTdGFjayAmJiBzdGFja1NpemUgPCB2YWxpZGF0aW9uQ29tbWFuZC5taW4pIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJOb3QgZW5vdWdoIHBhcmFtZXRlcnMgZm9yICIgKyB2YWxpZGF0aW9uQ29tbWFuZC5pZCArICI7IGFjdHVhbDogIiArIHN0YWNrU2l6ZSArICIsIGV4cGVjdGVkOiAiICsgdmFsaWRhdGlvbkNvbW1hbmQubWluKTsKICAgICAgICAgICAgaWYgKHN0YWNrU2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUuZmlyc3RTdGFja0NsZWFyaW5nICYmIHZhbGlkYXRpb25Db21tYW5kLnN0YWNrQ2xlYXJpbmcpIHsKICAgICAgICAgIHN0YXRlLmZpcnN0U3RhY2tDbGVhcmluZyA9IGZhbHNlOwogICAgICAgICAgc3RhY2tTaXplIC09IHZhbGlkYXRpb25Db21tYW5kLm1pbjsKICAgICAgICAgIGlmIChzdGFja1NpemUgPj0gMiAmJiB2YWxpZGF0aW9uQ29tbWFuZC5zdGVtKSB7CiAgICAgICAgICAgIHN0YWNrU2l6ZSAlPSAyOwogICAgICAgICAgfSBlbHNlIGlmIChzdGFja1NpemUgPiAxKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRm91bmQgdG9vIG1hbnkgcGFyYW1ldGVycyBmb3Igc3RhY2stY2xlYXJpbmcgY29tbWFuZCIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0YWNrU2l6ZSA+IDApIHsKICAgICAgICAgICAgc3RhdGUud2lkdGggPSBzdGFja1tzdGFja1NpemUgLSAxXTsKICA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jdCwKICAgICAgZmRBcnJheSwKICAgICAgcHJpdmF0ZURpY3QKICAgIH0gPSBfcmVmOwogICAgY29uc3Qgc2VhY3MgPSBbXTsKICAgIGNvbnN0IHdpZHRocyA9IFtdOwogICAgY29uc3QgY291bnQgPSBjaGFyU3RyaW5ncy5jb3VudDsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY291bnQ7IGkrKykgewogICAgICBjb25zdCBjaGFyc3RyaW5nID0gY2hhclN0cmluZ3MuZ2V0KGkpOwogICAgICBjb25zdCBzdGF0ZSA9IHsKICAgICAgICBjYWxsRGVwdGg6IDAsCiAgICAgICAgc3RhY2tTaXplOiAwLAogICAgICAgIHN0YWNrOiBbXSwKICAgICAgICB1bmRlZlN0YWNrOiB0cnVlLAogICAgICAgIGhpbnRzOiAwLAogICAgICAgIGZpcnN0U3RhY2tDbGVhcmluZzogdHJ1ZSwKICAgICAgICBzZWFjOiBudWxsLAogICAgICAgIHdpZHRoOiBudWxsLAogICAgICAgIGhhc1ZTdGVtczogZmFsc2UKICAgICAgfTsKICAgICAgbGV0IHZhbGlkID0gdHJ1ZTsKICAgICAgbGV0IGxvY2FsU3ViclRvVXNlID0gbnVsbDsKICAgICAgbGV0IHByaXZhdGVEaWN0VG9Vc2UgPSBwcml2YXRlRGljdDsKICAgICAgaWYgKGZkU2VsZWN0ICYmIGZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgY29uc3QgZmRJbmRleCA9IGZkU2VsZWN0LmdldEZESW5kZXgoaSk7CiAgICAgICAgaWYgKGZkSW5kZXggPT09IC0xKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkdseXBoIGluZGV4IGlzIG5vdCBpbiBmZCBzZWxlY3QuIik7CiAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgIH0KICAgICAgICBpZiAoZmRJbmRleCA+PSBmZEFycmF5Lmxlbmd0aCkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZ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Ynl0ZXNbcG9zKytdIDw8IDggfCBieXRlc1twb3MrK107CiAgICAgICAgICBjb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPD0gY291bnQ7IGkrKykgewogICAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQrKyA6IHN0cmluZ3MuZ2V0KGlkKyspKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICB3aGlsZSAoY2hhcnNldC5sZW5ndGggPD0gbGVuZ3RoKSB7CiAgICAgICAgICBpZCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgICAgICAgY291bnQgPSBieXRlc1twb3MrK10gPDwgOCB8IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPD0gY291bnQ7IGkrKykgewogICAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQrKyA6IHN0cmluZ3MuZ2V0KGlkKyspKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIGNoYXJzZXQgZm9ybWF0Iik7CiAgICB9CiAgICBjb25zdCBlbmQgPSBwb3M7CiAgICBjb25zdCByYXcgPSBieXRlcy5zdWJhcnJheShzdGFydCwgZW5kKTsKICAgIHJldHVybiBuZXcgQ0ZGQ2hhcnNldChmYWxzZSwgZm9ybWF0LCBjaGFyc2V0LCByYXcpOwogIH0KICBwYXJzZUVuY29kaW5nKHBvcywgcHJvcGVydGllcywgc3RyaW5ncywgY2hhcnNldCkgewogICAgY29uc3QgZW5jb2RpbmcgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgY29uc3QgYnl0ZXMgPSB0aGlzLmJ5dGVzOwogICAgbGV0IHByZWRlZmluZWQgPSBmYWxzZTsKICAgIGxldCBmb3JtYXQsIGksIGlpOwogICAgbGV0IHJhdyA9IG51bGw7CiAgICBmdW5jdGlvbiByZWFkU3VwcGxlbWVudCgpIHsKICAgICAgY29uc3Qgc3VwcGxlbWVudHNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgZm9yIChpID0gMDsgaSA8IHN1cHBsZW1lbnRzQ291bnQ7IGkrKykgewogICAgICAgIGNvbnN0IGNvZGUgPSBieXRlc1twb3MrK107CiAgICAgICAgY29uc3Qgc2lkID0gKGJ5dGVzW3BvcysrXSA8PCA4KSArIChieXRlc1twb3MrK10gJiAweGZmKTsKICAgICAgICBlbmNvZGluZ1tjb2RlXSA9IGNoYXJzZXQuaW5kZXhPZihzdHJpbmdzLmdldChzaWQpKTsKICAgICAgfQogICAgfQogICAgaWYgKHBvcyA9PT0gMCB8fCBwb3MgPT09IDEpIHsKICAgICAgcHJlZGVmaW5lZCA9IHRydWU7CiAgICAgIGZvcm1hdCA9IHBvczsKICAgICAgY29uc3QgYmFzZUVuY29kaW5nID0gcG9zID8gX2VuY29kaW5ncy5FeHBlcnRFbmNvZGluZyA6IF9lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZzsKICAgICAgZm9yIChpID0gMCwgaWkgPSBjaGFyc2V0Lmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCBpbmRleCA9IGJhc2VFbmNvZGluZy5pbmRleE9mKGNoYXJzZXRbaV0pOwogICAgICAgIGlmIChpbmRleCAhPT0gLTEpIHsKICAgICAgICAgIGVuY29kaW5nW2luZGV4XSA9IGk7CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhU3RhcnQgPSBwb3M7CiAgICAgIGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgICAgc3dpdGNoIChmb3JtYXQgJiAweDdmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgY29uc3QgZ2x5cGhzQ291bnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICBmb3IgKGkgPSAxOyBpIDw9IGdseXBoc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgZW5jb2RpbmdbYnl0ZXNbcG9zKytdXSA9IGk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDE6CiAgICAgICAgICBjb25zdCByYW5nZXNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGxldCBnaWQgPSAxOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJhbmdlc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc3RhcnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGNvbnN0IGxlZnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGZvciAobGV0IGogPSBzdGFydDsgaiA8PSBzdGFydCArIGxlZnQ7IGorKykgewogICAgICAgICAgICAgIGVuY29kaW5nW2pdID0gZ2lkKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVua25vd24gZW5jb2RpbmcgZm9ybWF0OiAke2Zvcm1hdH0gaW4gQ0ZGYCk7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUVuZCA9IHBvczsKICAgICAgaWYgKGZvcm1hdCAmIDB4ODApIHsKICAgICAgICBieXRlc1tkYXRhU3RhcnRdICY9IDB4N2Y7CiAgICAgICAgcmVhZFN1cHBsZW1lbnQoKTsKICAgICAgfQogICAgICByYXcgPSBieXRlcy5zdWJhcnJheShkYXRhU3RhcnQsIGRhdGFFbmQpOwogICAgfQogICAgZm9ybWF0ICY9IDB4N2Y7CiAgICByZXR1cm4gbmV3IENGRkVuY29kaW5nKHByZWRlZmluZWQsIGZvcm1hdCwgZW5jb2RpbmcsIHJhdyk7CiAgfQogIHBhcnNlRkR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cyA9IHsKICAgICAga2V5VG9OYW1lTWFwOiB7fSwKICAgICAgbmFtZVRvS2V5TWFwOiB7fSwKICAgICAgZGVmYXVsdHM6IHt9LAogICAgICB0eXBlczoge30sCiAgICAgIG9wY29kZXM6IHt9LAogICAgICBvcmRlcjogW10KICAgIH07CiAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGxheW91dCkgewogICAgICBjb25zdCBrZXkgPSBBcnJheS5pc0FycmF5KGVudHJ5WzBdKSA/IChlbnRyeVswXVswXSA8PCA4KSArIGVudHJ5WzBdWzFdIDogZW50cnlbMF07CiAgICAgIHRhYmxlcy5rZXlUb05hbWVNYXBba2V5XSA9IGVudHJ5WzFdOwogICAgICB0YWJsZXMubmFtZVRvS2V5TWFwW2VudHJ5WzFdXSA9IGtleTsKICAgICAgdGFibGVzLnR5cGVzW2tleV0gPSBlbnRyeVsyXTsKICAgICAgdGFibGVzLmRlZmF1bHRzW2tleV0gPSBlbnRyeVszXTsKICAgICAgdGFibGVzLm9wY29kZXNba2V5XSA9IEFycmF5LmlzQXJyYXkoZW50cnlbMF0pID8gZW50cnlbMF0gOiBbZW50cnlbMF1dOwogICAgICB0YWJsZXMub3JkZXIucHVzaChrZXkpOwogICAgfQogICAgcmV0dXJuIHRhYmxlczsKICB9Cn0KY29uc3QgQ0ZGVG9wRGljdExheW91dCA9IFtbWzEyLCAzMF0sICJST1MiLCBbInNpZCIsICJzaWQiLCAibnVtIl0sIG51bGxdLCBbWzEyLCAyMF0sICJTeW50aGV0aWNCYXNlIiwgIm51bSIsIG51bGxdLCBbMCwgInZlcnNpb24iLCAic2lkIiwgbnVsbF0sIFsxLCAiTm90aWNlIiwgInNpZCIsIG51bGxdLCBbWzEyLCAwXSwgIkNvcHlyaWdodCIsICJzaWQiLCBudWxsXSwgWzIsICJGdWxsTmFtZSIsICJzaWQiLCBudWxsXSwgWzMsICJGYW1pbHlOYW1lIiwgInNpZCIsIG51bGxdLCBbNCwgIldlaWdodCIsICJzaWQiLCBud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gY29tcGlsZVRvcERpY3RzKGRpY3RzLCBsZW5ndGgsIHJlbW92ZUNpZEtleXMpIHsKICAgIGNvbnN0IGZvbnREaWN0VHJhY2tlcnMgPSBbXTsKICAgIGxldCBmZEFycmF5SW5kZXggPSBuZXcgQ0ZGSW5kZXgoKTsKICAgIGZvciAoY29uc3QgZm9udERpY3Qgb2YgZGljdHMpIHsKICAgICAgaWYgKHJlbW92ZUNpZEtleXMpIHsKICAgICAgICBmb250RGljdC5yZW1vdmVCeU5hbWUoIkNJREZvbnRWZXJzaW9uIik7CiAgICAgICAgZm9udERpY3QucmVtb3ZlQnlOYW1lKCJDSURGb250UmV2aXNpb24iKTsKICAgICAgICBmb250RGljdC5yZW1vdmVCeU5hbWUoIkNJREZvbnRUeXBlIik7CiAgICAgICAgZm9udERpY3QucmVtb3ZlQnlOYW1lKCJDSURDb3VudCIpOwogICAgICAgIGZvbnREaWN0LnJlbW92ZUJ5TmFtZSgiVUlEQmFzZSIpOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnREaWN0VHJhY2tlciA9IG5ldyBDRkZPZmZzZXRUcmFja2VyKCk7CiAgICAgIGNvbnN0IGZvbnREaWN0RGF0YSA9IHRoaXMuY29tcGlsZURpY3QoZm9udERpY3QsIGZvbnREaWN0VHJhY2tlcik7CiAgICAgIGZvbnREaWN0VHJhY2tlcnMucHVzaChmb250RGljdFRyYWNrZXIpOwogICAgICBmZEFycmF5SW5kZXguYWRkKGZvbnREaWN0RGF0YSk7CiAgICAgIGZvbnREaWN0VHJhY2tlci5vZmZzZXQobGVuZ3RoKTsKICAgIH0KICAgIGZkQXJyYXlJbmRleCA9IHRoaXMuY29tcGlsZUluZGV4KGZkQXJyYXlJbmRleCwgZm9udERpY3RUcmFja2Vycyk7CiAgICByZXR1cm4gewogICAgICB0cmFja2VyczogZm9udERpY3RUcmFja2VycywKICAgICAgb3V0cHV0OiBmZEFycmF5SW5kZXgKICAgIH07CiAgfQogIGNvbXBpbGVQcml2YXRlRGljd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cGlsZUluZGV4KHByaXZhdGVEaWN0LnN1YnJzSW5kZXgpOwogICAgICAgIHByaXZhdGVEaWN0VHJhY2tlci5zZXRFbnRyeUxvY2F0aW9uKCJTdWJycyIsIFtwcml2YXRlRGljdERhdGEubGVuZ3RoXSwgb3V0cHV0KTsKICAgICAgICBvdXRwdXQuYWRkKHN1YnJzKTsKICAgICAgfQogICAgfQogIH0KICBjb21waWxlRGljdChkaWN0LCBvZmZzZXRUcmFja2VyKSB7CiAgICBjb25zdCBvdXQgPSBbXTsKICAgIGZvciAoY29uc3Qga2V5IG9mIGRpY3Qub3JkZXIpIHsKICAgICAgaWYgKCEoa2V5IGluIGRpY3QudmFsdWVzKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCB2YWx1ZXMgPSBkaWN0LnZhbHVlc1trZXldOwogICAgICBsZXQgdHlwZXMgPSBkaWN0LnR5cGVzW2tleV07CiAgICAgIGlmICghQXJyYXkuaXNBcnJheSh0eXBlcykpIHsKICAgICAgICB0eXBlcyA9IFt0eXBlc107CiAgICAgIH0KICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHZhbHVlcykpIHsKICAgICAgICB2YWx1ZXMgPSBbdmFsdWVzXTsKICAgICAgfQogICAgICBpZiAodmFsdWVzLmxlbmd0aCA9PT0gMCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR5cGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBjb25zdCB0eXBlID0gdHlwZXNbal07CiAgICAgICAgY29uc3QgdmFsdWUgPSB2YWx1ZXNbal07CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlICJudW0iOgogICAgICAgICAgY2FzZSAic2lkIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJvZmZzZXQiOgogICAgICAgICAgICBjb25zdCBuYW1lID0gZGljdC5rZXlUb05hbWVNYXBba2V5XTsKICAgICAgICAgICAgaWYgKCFvZmZzZXRUcmFja2VyLmlzVHJhY2tpbmcobmFtZSkpIHsKICAgICAgICAgICAgICBvZmZzZXRUcmFja2VyLnRyYWNrKG5hbWUsIG91dC5sZW5ndGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG91dC5wdXNoKDB4MWQsIDAsIDAsIDAsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgImFycmF5IjoKICAgICAgICAgIGNhc2UgImRlbHRhIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDEsIGtrID0gdmFsdWVzLmxlbmd0aDsgayA8IGtrOyArK2spIHsKICAgICAgICAgICAgICBvdXQucHVzaCguLi50aGlzLmVuY29kZU51bWJlcih2YWx1ZXNba10pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5rbm93biBkYXRhIHR5cGUgb2YgJHt0eXBlfWApOwogICAgICAgIH0KICAgICAgfQogICAgICBvdXQucHVzaCguLi5kaWN0Lm9wY29kZXNba2V5XSk7CiAgICB9CiAgICByZXR1cm4gb3V0OwogIH0KICBjb21waWxlU3RyaW5nSW5kZXgoc3RyaW5ncykgewogICAgY29uc3Qgc3RyaW5nSW5kZXggPSBuZXcgQ0ZGSW5kZXgoKTsKICAgIGZvciAoY29uc3Qgc3RyaW5nIG9mIHN0cmluZ3MpIHsKICAgICAgc3RyaW5nSW5kZXguYWRkKCgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShzdHJpbmcpKTsKICAgIH0KICAgIHJldHVybiB0aGlzLmNvbXBpbGVJbmRleChzdHJpbmdJbmRleCk7CiAgfQogIGNvbXBpbGVHbG9iYWxTdWJySW5kZXgoKSB7CiAgICBjb25zdCBnbG9iYWxTdWJySW5kZXggPSB0aGlzLmNmZi5nbG9iYWxTdWJySW5kZXg7CiAgICB0aGlzLm91dC53cml0ZUJ5dGVBcnJheSh0aGlzLmNvbXBpbGVJbmRleChnbG9iYWxTdWJySW5kZXgpKTsKICB9CiAgY29tcGlsZUNoYXJTdHJpbmdzKGNoYXJTdHJpbmdzKSB7CiAgICBjb25zdCBjaGFyU3RyaW5nc0luZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNoYXJTdHJpbmdzLmNvdW50OyBpKyspIHsKICAgICAgY29uc3QgZ2x5cGggPSBjaGFyU3RyaW5ncy5nZXQoaSk7CiAgICAgIGlmIChnbHlwaC5sZW5ndGggPT09IDApIHsKICAgICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChuZXcgVWludDhBcnJheShbMHg4YiwgMHgwZV0pKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChnbHlwaCk7CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlSW5kZXgoY2hhclN0cmluZ3NJbmRleCk7CiAgfQogIGNvbXBpbGVDaGFyc2V0KGNoYXJzZXQsIG51bUdseXBocywgc3RyaW5ncywgaXNDSURGb250KSB7CiAgICBsZXQgb3V0OwogICAgY29uc3QgbnVtR2x5cGhzTGVzc05vdERlZiA9IG51bUdseXBocyAtIDE7CiAgICBpZiAoaXNDSURGb250KSB7CiAgICAgIG91dCA9IG5ldyBVaW50OEFycmF5KFsyLCAwLCAwLCBudW1HbHlwaHNMZXNzTm90RGVmID4+IDggJiAweGZmLCBudW1HbHlwaHNMZXNzTm90RGVmICYgMHhmZl0pOwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgbGVuZ3RoID0gMSArIG51bUdseXBoc0xlc3NOb3REZWYgKiAyOwogICAgICBvdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgICBvdXRbMF0gPSAwOwogICAgICBsZXQgY2hhcnNldEluZGV4ID0gMDsKICAgICAgY29uc3QgbnVtQ2hhcnNldHMgPSBjaGFyc2V0LmNoYXJzZXQubGVuZ3RoOwogICAgICBsZXQgd2FybmVkID0gZmFsc2U7CiAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgb3V0Lmxlbmd0aDsgaSArPSAyKSB7CiAgICAgICAgbGV0IHNpZCA9IDA7CiAgICAgICAgaWYgKGNoYXJzZXRJbmRleCA8IG51bUNoYXJzZXRzKSB7CiAgICAgICAgICBjb25zdCBuYW1lID0gY2hhcnNldC5jaGFyc2V0W2NoYXJzZXRJbmRleCsrXTsKICAgICAgICAgIHNpZCA9IHN0cmluZ3MuZ2V0U0lEKG5hbWUpOwogICAgICAgICAgaWYgKHNpZCA9PT0gLTEpIHsKICAgICAgICAgICAgc2lkID0gMDsKICAgICAgICAgICAgaWYgKCF3YXJuZWQpIHsKICAgICAgICAgICAgICB3YXJuZWQgPSB0cnVlOwogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQ291bGRuJ3QgZmluZCAke25hbWV9IGluIENGRiBzdHJpbmdzYCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0W2ldID0gc2lkID4+IDggJiAweGZmOwogICAgICAgIG91dFtpICsgMV0gPSBzaWQgJiAweGZmOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlVHlwZWRBcnJheShvdXQpOwogIH0KICBjb21waWxlRW5jb2RpbmcoZW5jb2RpbmcpIHsKICAgIHJldHVybiB0aGlzLmNvbXBpbGVUeXBlZEFycmF5KGVuY29kaW5nLnJhdyk7CiAgfQogIGNvbXBpbGVGRFNlbGVjdChmZFNlbGVjdCkgewogICAgY29uc3QgZm9ybWF0ID0gZmRTZWxlY3QuZm9ybWF0OwogIC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IsCiAgMHgwMDVkLAogICJicmFja2V0cmlnaHRidCIsCiAgMHhmOGZiLAogICJicmFja2V0cmlnaHRleCIsCiAgMHhmOGZhLAogICJicmFja2V0cmlnaHRtb25vc3BhY2UiLAogIDB4ZmYzZCwKICAiYnJhY2tldHJpZ2h0dHAiLAogIDB4ZjhmOSwKICAiYnJldmUiLAogIDB4MDJkOCwKICAiYnJldmViZWxvd2NtYiIsCiAgMHgwMzJlLAogICJicmV2ZWNtYiIsCiAgMHgwMzA2LAogICJicmV2ZWludmVydGVkYmVsb3djbWIiLAogIDB4MDMyZiwKICAiYnJldmVpbnZlcnRlZGNtYiIsCiAgMHgwMzExLAogICJicmV2ZWludmVydGVkZG91YmxlY21iIiwKICAweDAzNjEsCiAgImJyaWRnZWJlbG93Y21iIiwKICAweDAzMmEsCiAgImJyaWRnZWludmVydGVkYmVsb3djbWIiLAogIDB4MDMzYSwKICAiYnJva2VuYmFyIiwKICAweDAwYTYsCiAgImJzdHJva2UiLAogIDB4MDE4MCwKICAiYnN1cGVyaW9yIiwKICAweGY2ZWEsCiAgImJ0b3BiYXIiLAogIDB4MDE4MywKICAiYnVoaXJhZ2FuYSIsCiAgMHgzMDc2LAogICJidWthdGFrYW5hIiwKICAweDMwZDYsCiAgImJ1bGxldCIsCiAgMHgyMDIyLAogICJidWxsZXRpbnZlcnNlIiwKICAweDI1ZDgsCiAgImJ1bGxldG9wZXJhdG9yIiwKICAweDIyMTksCiAgImJ1bGxzZXllIiwKICAweDI1Y2UsCiAgImMiLAogIDB4MDA2MywKICAiY2Fhcm1lbmlhbiIsCiAgMHgwNTZlLAogICJjYWJlbmdhbGkiLAogIDB4MDk5YSwKICAiY2FjdXRlIiwKICAweDAxMDcsCiAgImNhZGV2YSIsCiAgMHgwOTFhLAogICJjYWd1amFyYXRpIiwKICAweDBhOWEsCiAgImNhZ3VybXVraGkiLAogIDB4MGExYSwKICAiY2Fsc3F1YXJlIiwKICAweDMzODgsCiAgImNhbmRyYWJpbmR1Ym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wMmQxLAogICJjb2xvbnRyaWFuZ3VsYXJtb2QiLAogIDB4MDJkMCwKICAiY29tbWEiLAogIDB4MDAyYywKICAiY29tbWFhYm92ZWNtYiIsCiAgMHgwMzEzLAogICJjb21tYWFib3ZlcmlnaHRjbWIiLAogIDB4MDMxNSwKICAiY29tbWFhY2NlbnQiLAogIDB4ZjZjMywKICAiY29tbWFhcmFiaWMiLAogIDB4MDYwYywKICAiY29tbWFhcm1lbmlhbiIsCiAgMHgwNTVkLAogICJjb21tYWluZmVyaW9yIiwKICAweGY2ZTEsCiAgImNvbW1hbW9ub3NwYWNlIiwKICAweGZmMGMsCiAgImNvbW1hcmV2ZXJzZWRhYm92ZWNtYiIsCiAgMHgwMzE0LAogICJjb21tYXJldmVyc2VkbW9kIiwKICAweDAyYmQsCiAgImNvbW1hc21hbGwiLAogIDB4ZmU1MCwKICAiY29tbWFzdXBlcmlvciIsCiAgMHhmNmUyLAogICJjb21tYXR1cm5lZGFib3ZlY21iIiwKICAweDAzMTIsCiAgImNvbW1hdHVybmVkbW9kIiwKICAweDAyYmIsCiAgImNvbXBhc3MiLAogIDB4MjYzYywKICAiY29uZ3J1ZW50IiwKICAweDIyNDUsCiAgImNvbnRvdXJpbnRlZ3JhbCIsCiAgMHgyMjJlLAogICJjb250cm9sIiwKICAweDIzMDMsCiAgImNvbnRyb2xBQ0siLAogIDB4MDAwNiwKICAiY29udHJvbEJFTCIsCiAgMHgwMDA3LAogICJjb250cm9sQlMiLAogIDB4MDAwOCwKICAiY29udHJvbENBTiIsCiAgMHgwMDE4LAogICJjb250cm9sQ1IiLAogIDB4MDAwZCwKICAiY29udHJvbERDMSIsCiAgMHgwMDExLAogICJjb250cm9sREMyIiwKICAweDAwMTIsCiAgImNvbnRyb2xEQzMiLAogIDB4MDAxMywKICAiY29udHJvbERDNCIsCiAgMHgwMDE0LAogICJjb250cm9sREVMIiwKICAweDAwN2YsCiAgImNvbnRyb2xETEUiLAogIDB4MDAxMCwKICAiY29udHJvbEVNIiwKICAweDAwMTksCiAgImNvbnRyb2xFTlEiLAogIDB4MDAwNSwKICAiY29udHJvbEVPVCIsCiAgMHgwMDA0LAogICJjb250cm9sRVNDIiwKICAweDAwMWIsCiAgImNvbnRyb2xFVEIiLAogIDB4MDAxNywKICAiY29udHJvbEVUWCIsCiAgMHgwMDAzLAogICJjb250cm9sRkYiLAogIDB4MDAwYywKICAiY29udHJvbEZTIiwKICAweDAwMWMsCiAgImNvbnRyb2xHUyIsCiAgMHgwMDFkLAogICJjb250cm9sSFQiLAogIDB4MDAwOSwKICAiY29udHJvbExGIiwKICAweDAwMGEsCiAgImNvbnRyb2xOQUsiLAogIDB4MDAxNSwKICAiY29udHJvbE5VTEwiLAogIDB4MDAwMCwKICAiY29udHJvbFJTIiwKICAweDAwMWUsCiAgImNvbnRyb2xTSSIsCiAgMHgwMDBmLAogICJjb250cm9sU08iLAogIDB4MDAwZSwKICAiY29udHJvbFNPVCIsCiAgMHgwMDAyLAogICJjb250cm9sU1RYIiwKICAweDAwMDEsCiAgImNvbnRyb2xTVUIiLAogIDB4MDAxYSwKICAiY29udHJvbFNZTiIsCiAgMHgwMDE2LAogICJjb250cm9sVVMiLAogIDB4MDAxZiwKICAiY29udHJvbFZUIiwKICAweDAwMGIsCiAgImNvcHlyaWdodCIsCiAgMHgwMGE5LAogICJjb3B5cmlnaHRzYW5zIiwKICAweGY4ZTksCiAgImNvcHlyaWdodHNlcmlmIiwKICAweGY2ZDksCiAgImNvcm5lcmJyYWNrZXRsZWZ0IiwKICAweDMwMGMsCiAgImNvcm5lcmJyYWNrZXRsZWZ0aGFsZndpZHRoIiwKICAweGZmNjIsCiAgImNvcm5lcmJyYWNrZXRsZWZ0dmVydGljYWwiLAogIDB4ZmU0MSwKICAiY29ybmVyYnJhY2tldHJpZ2h0IiwKICAweDMwMGQsCiAgImNvcm5lcmJyYWNrZXRyaWdodGhhbGZ3aWR0aCIsCiAgMHhmZjYzLAogICJjb3JuZXJicmFja2V0cmlnaHR2Z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iwKICAiaG9rYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjhlLAogICJob2xhbSIsCiAgMHgwNWI5LAogICJob2xhbTE5IiwKICAweDA1YjksCiAgImhvbGFtMjYiLAogIDB4MDViOSwKICAiaG9sYW0zMiIsCiAgMHgwNWI5LAogICJob2xhbWhlYnJldyIsCiAgMHgwNWI5LAogICJob2xhbW5hcnJvd2hlYnJldyIsCiAgMHgwNWI5LAogICJob2xhbXF1YXJ0ZXJoZWJyZXciLAogIDB4MDViOSwKICAiaG9sYW13aWRlaGVicmV3IiwKICAweDA1YjksCiAgImhvbm9raHVrdGhhaSIsCiAgMHgwZTJlLAogICJob29rYWJvdmVjb21iIiwKICAweDAzMDksCiAgImhvb2tjbWIiLAogIDB4MDMwOSwKICAiaG9va3BhbGF0YWxpemVkYmVsb3djbWIiLAogIDB4MDMyMSwKICAiaG9va3JldHJvZmxleGJlbG93Y21iIiwKICAweDAzMjIsCiAgImhvb25zcXVhcmUiLAogIDB4MzM0MiwKICAiaG9yaWNvcHRpYyIsCiAgMHgwM2U5LAogICJob3Jpem9udGFsYmFyIiwKICAweDIwMTUsCiAgImhvcm5jbWIiLAogIDB4MDMxYiwKICAiaG90c3ByaW5ncyIsCiAgMHgyNjY4LAogICJob3VzZSIsCiAgMHgyMzAyLAogICJocGFyZW4iLAogIDB4MjRhMywKICAiaHN1cGVyaW9yIiwKICAweDAyYjAsCiAgImh0dXJuZWQiLAogIDB4MDI2NSwKICAiaHVoaXJhZ2FuYSIsCiAgMHgzMDc1LAogICJodWlpdG9zcXVhcmUiLAogIDB4MzMzMywKICAiaHVrYXRha2FuYSIsCiAgMHgzMGQ1LAogICJodWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOGMsCiAgImh1bmdhcnVtbGF1dCIsCiAgMHgwMmRkLAogICJodW5nYXJ1bWxhdXRjbWIiLAogIDB4MDMwYiwKICAiaHYiLAogIDB4MDE5NSwKICAiaHlwaGVuIiwKICAweDAwMmQsCiAgImh5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ICJpbWFjcm9uIiwKICAweDAxMmIsCiAgImltYWNyb25jeXJpbGxpYyIsCiAgMHgwNGUzLAogICJpbWFnZW9yYXBwcm94aW1hdGVseWVxdWFsIiwKICAweDIyNTMsCiAgImltYXRyYWd1cm11a2hpIiwKICAweDBhM2YsCiAgImltb25vc3BhY2UiLAogIDB4ZmY0OSwKICAiaW5jcmVtZW50IiwKICAweDIyMDYsCiAgImluZmluaXR5IiwKICAweDIyMWUsCiAgImluaWFybWVuaWFuIiwKICAweDA1NmIsCiAgImludGVncmFsIiwKICAweDIyMmIsCiAgImludGVncmFsYm90dG9tIiwKICAweDIzMjEsCiAgImludGVncmFsYnQiLAogIDB4MjMyMSwKICAiaW50ZWdyYWxleCIsCiAgMHhmOGY1LAogICJpbnRlZ3JhbHRvcCIsCiAgMHgyMzIwLAogICJpbnRlZ3JhbHRwIiwKICAweDIzMjAsCiAgImludGVyc2VjdGlvbiIsCiAgMHgyMjI5LAogICJpbnRpc3F1YXJlIiwKICAweDMzMDUsCiAgImludmJ1bGxldCIsCiAgMHgyNWQ4LAogICJpbnZjaXJjbGUiLAogIDB4MjVkOSwKICAiaW52c21pbGVmYWNlIiwKICAweDI2M2IsCiAgImlvY3lyaWxsaWMiLAogIDB4MDQ1MSwKICAiaW9nb25layIsCiAgMHgwMTJmLAogICJpb3RhIiwKICAweDAzYjksCiAgImlvdGFkaWVyZXNpcyIsCiAgMHgwM2NhLAogICJpb3RhZGllcmVzaXN0b25vcyIsCiAgMHgwMzkwLAogICJpb3RhbGF0aW4iLAogIDB4MDI2OSwKICAiaW90YXRvbm9zIiwKICAweDAzYWYsCiAgImlwYXJlbiIsCiAgMHgyNGE0LAogICJpcmlndXJtdWtoaSIsCiAgMHgwYTcyLAogICJpc21hbGxoaXJhZ2FuYSIsCiAgMHgzMDQzLAogICJpc21hbGxrYXRha2FuYSIsCiAgMHgzMGEzLAogICJpc21hbGxrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjY4LAogICJpc3No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WMiLAogIDB4ZmVhMCwKICAiamVoYXJhYmljIiwKICAweDA2OTgsCiAgImplaGZpbmFsYXJhYmljIiwKICAweGZiOGIsCiAgImpoYWJlbmdhbGkiLAogIDB4MDk5ZCwKICAiamhhZGV2YSIsCiAgMHgwOTFkLAogICJqaGFndWphcmF0aSIsCiAgMHgwYTlkLAogICJqaGFndXJtdWtoaSIsCiAgMHgwYTFkLAogICJqaGVoYXJtZW5pYW4iLAogIDB4MDU3YiwKICAiamlzIiwKICAweDMwMDQsCiAgImptb25vc3BhY2UiLAogIDB4ZmY0YSwKICAianBhcmVuIiwKICAweDI0YTUsCiAgImpzdXBlcmlvciIsCiAgMHgwMmIyLAogICJrIiwKICAweDAwNmIsCiAgImthYmFzaGtpcmN5cmlsbGljIiwKICAweDA0YTEsCiAgImthYmVuZ2FsaSIsCiAgMHgwOTk1LAogICJrYWN1dGUiLAogIDB4MWUzMSwKICAia2FjeXJpbGxpYyIsCiAgMHgwNDNhLAogICJrYWRlc2NlbmRlcmN5cmlsbGljIiwKICAweDA0OWIsCiAgImthZGV2YSIsCiAgMHgwOTE1LAogICJrYWYiLAogIDB4MDVkYiwKICAia2FmYXJhYmljIiwKICAweDA2NDMsCiAgImthZmRhZ2VzaCIsCiAgMHhmYjNiLAogICJrYWZkYWdlc2hoZWJyZXciLAogIDB4ZmIzYiwKICAia2FmZmluYWxhcmFiaWMiLAogIDB4ZmVkYSwKICAia2FmaGVicmV3IiwKICAweDA1ZGIsCiAgImthZmluaXRpYWxhcmFiaWMiLAogIDB4ZmVkYiwKICAia2FmbWVkaWFsYXJhYmljIiwKICAweGZlZGMsCiAgImthZnJhZmVoZWJyZXciLAogIDB4ZmI0ZCwKICAia2FndWphcmF0aSIsCiAgMHgwYTk1LAogICJrYWd1cm11a2hpIiwKICAweDBhMTUsCiAgImthaGlyYWdhbmEiLAogIDB4MzA0YiwKICAia2Fob29rY3lyaWxsaWMiLAogIDB4MDRjNCwKICAia2FrYXRha2FuYSIsCiAgMHgz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XRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjc5LAogICJrZW5hcm1lbmlhbiIsCiAgMHgwNTZmLAogICJrZXNtYWxsa2F0YWthbmEiLAogIDB4MzBmNiwKICAia2dyZWVubGFuZGljIiwKICAweDAxMzgsCiAgImtoYWJlbmdhbGkiLAogIDB4MDk5NiwKICAia2hhY3lyaWxsaWMiLAogIDB4MDQ0NSwKICAia2hhZGV2YSIsCiAgMHgwOTE2LAogICJraGFndWphcmF0aSIsCiAgMHgwYTk2LAogICJraGFndXJtdWtoaSIsCiAgMHgwYTE2LAogICJraGFoYXJhYmljIiwKICAweDA2MmUsCiAgImtoYWhmaW5hbGFyYWJpYyIsCiAgMHhmZWE2LAogICJraGFoaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWE3LAogICJraGFobWVkaWFsYXJhYmljIiwKICAweGZlYTgsCiAgImtoZWljb3B0aWMiLAogIDB4MDNlNywKICAia2hoYWRldmEiLAogIDB4MDk1OSwKICAia2hoYWd1cm11a2hpIiwKICAweDBhNTksCiAgImtoaWV1a2hhY2lyY2xla29yZWFuIiwKICAweDMyNzgsCiAgImtoaWV1a2hhcGFyZW5rb3JlYW4iLAogIDB4MzIxOCwKICAia2hpZXVraGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZhLAogICJraGlldWtoa29yZWFuIiwKICAweDMxNGIsCiAgImtoaWV1a2hwYXJlbmtvcmVhbiIsCiAgMHgzMjBhLAogICJraG9raGFpdGhhaSIsCiAgMHgwZTAyLAogICJraG9raG9udGhhaSIsCiAgMHgwZTA1LAogICJraG9raHVhdHRoYWkiLAogIDB4MGUwMywKICAia2hva2h3YWl0aGFpIiwKICAweDBlMDQsCiAgImtob211dHRoYWkiLAogIDB4MGU1YiwKICAia2hvb2siLAogIDB4MDE5OSwKICAia2hvcmFraGFuZ3RoYWkiLAogIDB4MGUwNiwKICAia2h6c3F1YXJlIiwKICAweDMzOTEsCiAgImtpaGlyYWdhbmEiLAogIDB4MzA0ZCwKICAia2lrYXRha2FuYSIsCiAgMHgzMGFkLAogICJraWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzcsCiAgImtpcm9ndXJhbXVzcXVhcmUiLAogIDB4MzMxNSwKICAia2lyb21lZXRvcnVzcXVhcmUiLAogIDB4MzMxNiwKICAia2lyb3NxdWFyZSIsCiAgMHgzMzE0LAogICJraXllb2thY2lyY2xla29yZWFuIiwKICAweDMyNmUsCiAgImtpeWVva2FwYXJlbmtvcmVhbiIsCiAgMHgzMjBlLAogICJraXllb2tjaXJjbGVrb3JlYW4iLAogIDB4MzI2MCwKICAia2l5ZW9ra29yZWFuIiwKICAweDMxMzEsCiAgImtpeWVva3BhcmVua29yZWFuIiwKICAweDMyMDAsCiAgImtpeWVva3Npb3Nrb3JlYW4iLAogIDB4MzEzMywKICAia2plY3lyaWxsaWMiLAogIDB4MDQ1YywKICAia2xpbmViZWxvdyIsCiAgMHgxZTM1LAogICJrbHNxdWFyZSIsCiAgMHgzMzk4LAogICJrbWN1YmVkc3F1YXJlIiwKICAweDMzYTYsCiAgImttb25vc3BhY2UiLAogIDB4ZmY0YiwKICAia21zcXVhcmVkc3F1YXJlIiwKICAweDMzYTIsCiAgImtvaGlyYWdhbmEiLAogIDB4MzA1MywKICAia29obXNxdWFyZSIsCiAgMHgzM2MwLAogICJrb2thaXRoYWkiLAogIDB4MGUwMSwKICAia29rYXRha2FuYSIsCiAgMHgzMGIzLAogICJrb2thdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2EsCiAgImtvb3Bvc3F1YXJlIiwKICAweDMzMWUsCiAgImtvcHBhY3lyaWxsaWMiLAogIDB4MDQ4MSwKICAia29yZWFuc3RhbmRhcmRzeW1ib2wiLAogIDB4MzI3ZiwKICAia29yb25pc2NtYiIsCiAgMHgwMzQzLAogICJrcGFyZW4iLAogIDB4MjRhNiwKICAia3Bhc3F1YXJlIiwKICAweDMzYWEsCiAgImtzaWN5cmlsbGljIiwKICAweDA0NmYsCiAgImt0c3F1YXJlIi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ogIDB4MDU3NiwKICAibnBhcmVuIiwKICAweDI0YTksCiAgIm5zc3F1YXJlIiwKICAweDMzYjEsCiAgIm5zdXBlcmlvciIsCiAgMHgyMDdmLAogICJudGlsZGUiLAogIDB4MDBmMSwKICAibnUiLAogIDB4MDNiZCwKICAibnVoaXJhZ2FuYSIsCiAgMHgzMDZjLAogICJudWthdGFrYW5hIiwKICAweDMwY2MsCiAgIm51a2F0YWthbmFoYWxmd2lkdGgiLAogIDB4ZmY4NywKICAibnVrdGFiZW5nYWxpIiwKICAweDA5YmMsCiAgIm51a3RhZGV2YSIsCiAgMHgwOTNjLAogICJudWt0YWd1amFyYXRpIiwKICAweDBhYmMsCiAgIm51a3RhZ3VybXVraGkiLAogIDB4MGEzYywKICAibnVtYmVyc2lnbiIsCiAgMHgwMDIzLAogICJudW1iZXJzaWdubW9ub3NwYWNlIiwKICAweGZmMDMsCiAgIm51bWJlcnNpZ25zbWFsbCIsCiAgMHhmZTVmLAogICJudW1lcmFsc2lnbmdyZWVrIiwKICAweDAzNzQsCiAgIm51bWVyYWxzaWdubG93ZXJncmVlayIsCiAgMHgwMzc1LAogICJudW1lcm8iLAogIDB4MjExNiwKICAibnVuIiwKICAweDA1ZTAsCiAgIm51bmRhZ2VzaCIsCiAgMHhmYjQwLAogICJudW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0MCwKICAibnVuaGVicmV3IiwKICAweDA1ZTAsCiAgIm52c3F1YXJlIiwKICAweDMzYjUsCiAgIm53c3F1YXJlIiwKICAweDMzYmIsCiAgIm55YWJlbmdhbGkiLAogIDB4MDk5ZSwKICAibnlhZGV2YSIsCiAgMHgwOTFlLAogICJueWFndWphcmF0aSIsCiAgMHgwYTllLAogICJueWFndXJtdWtoaSIsCiAgMHgwYTFlLAogICJvIiwKICAweDAwNmYsCiAgIm9hY3V0ZSIsCiAgMHgwMGYzLAogICJvYW5ndGhhaSIsCiAgMHgwZTJkLAogICJvYmFycmVkIiwKICAweDAyNzUsCiAgIm9iYX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MiLAogIDB4ZmQzZiwKICAicGFyZW5yaWdodGJ0IiwKICAweGY4ZjgsCiAgInBhcmVucmlnaHRleCIsCiAgMHhmOGY3LAogICJwYXJlbnJpZ2h0aW5mZXJpb3IiLAogIDB4MjA4ZSwKICAicGFyZW5yaWdodG1vbm9zcGFjZSIsCiAgMHhmZjA5LAogICJwYXJlbnJpZ2h0c21hbGwiLAogIDB4ZmU1YSwKICAicGFyZW5yaWdodHN1cGVyaW9yIiwKICAweDIwN2UsCiAgInBhcmVucmlnaHR0cCIsCiAgMHhmOGY2LAogICJwYXJlbnJpZ2h0dmVydGljYWwiLAogIDB4ZmUzNiwKICAicGFydGlhbGRpZmYiLAogIDB4MjIwMiwKICAicGFzZXFoZWJyZXciLAogIDB4MDVjMCwKICAicGFzaHRhaGVicmV3IiwKICAweDA1OTksCiAgInBhc3F1YXJlIiwKICAweDMzYTksCiAgInBhdGFoIiwKICAweDA1YjcsCiAgInBhdGFoMTEiLAogIDB4MDViNywKICAicGF0YWgxZCIsCiAgMHgwNWI3LAogICJwYXRhaDJhIiwKICAweDA1YjcsCiAgInBhdGFoaGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFobmFycm93aGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFocXVhcnRlcmhlYnJldyIsCiAgMHgwNWI3LAogICJwYXRhaHdpZGVoZWJyZXciLAogIDB4MDViNywKICAicGF6ZXJoZWJyZXciLAogIDB4MDVhMSwKICAicGJvcG9tb2ZvIiwKICAweDMxMDYsCiAgInBjaXJjbGUiLAogIDB4MjRkZiwKICAicGRvdGFjY2VudCIsCiAgMHgxZTU3LAogICJwZSIsCiAgMHgwNWU0LAogICJwZWN5cmlsbGljIiwKICAweDA0M2YsCiAgInBlZGFnZXNoIiwKICAweGZiNDQsCiAgInBlZGFnZXNoaGVicmV3IiwKICAweGZiNDQsCiAgInBlZXppc3F1YXJlIiwKICAweDMzM2IsCiAgInBlZmluYWxkYWdlc2hoZWJyZXciLAogIDB4ZmI0MywK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AweDBhYWIsCiAgInBoYWd1cm11a2hpIiwKICAweDBhMmIsCiAgInBoaSIsCiAgMHgwM2M2LAogICJwaGkxIiwKICAweDAzZDUsCiAgInBoaWV1cGhhY2lyY2xla29yZWFuIiwKICAweDMyN2EsCiAgInBoaWV1cGhhcGFyZW5rb3JlYW4iLAogIDB4MzIxYSwKICAicGhpZXVwaGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZjLAogICJwaGlldXBoa29yZWFuIiwKICAweDMxNGQsCiAgInBoaWV1cGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBjLAogICJwaGlsYXRpbiIsCiAgMHgwMjc4LAogICJwaGludGh1dGhhaSIsCiAgMHgwZTNhLAogICJwaGlzeW1ib2xncmVlayIsCiAgMHgwM2Q1LAogICJwaG9vayIsCiAgMHgwMWE1LAogICJwaG9waGFudGhhaSIsCiAgMHgwZTFlLAogICJwaG9waHVuZ3RoYWkiLAogIDB4MGUxYywKICAicGhvc2FtcGhhb3RoYWkiLAogIDB4MGUyMCwKICAicGkiLAogIDB4MDNjMCwKICAicGlldXBhY2lyY2xla29yZWFuIiwKICAweDMyNzMsCiAgInBpZXVwYXBhcmVua29yZWFuIiwKICAweDMyMTMsCiAgInBpZXVwY2lldWNrb3JlYW4iLAogIDB4MzE3NiwKICAicGlldXBjaXJjbGVrb3JlYW4iLAogIDB4MzI2NSwKICAicGlldXBraXllb2trb3JlYW4iLAogIDB4MzE3MiwKICAicGlldXBrb3JlYW4iLAogIDB4MzE0MiwKICAicGlldXBwYXJlbmtvcmVhbiIsCiAgMHgzMjA1LAogICJwaWV1cHNpb3NraXllb2trb3JlYW4iLAogIDB4MzE3NCwKICAicGlldXBzaW9za29yZWFuIiwKICAweDMxNDQsCiAgInBpZXVwc2lvc3Rpa2V1dGtvcmVhbiIsCiAgMHgzMTc1LAogICJwaWV1cHRoaWV1dGhrb3JlYW4iLAogIDB4MzE3NywKICAicGlldXB0aWtldXRrb3JlYW4iLAogIDB4MzE3MywKICAicGloa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mYywKICAicHJvcGVsbG9yIiwKICAweDIzMTgsCiAgInByb3BlcnN1YnNldCIsCiAgMHgyMjgyLAogICJwcm9wZXJzdXBlcnNldCIsCiAgMHgyMjgzLAogICJwcm9wb3J0aW9uIiwKICAweDIyMzcsCiAgInByb3BvcnRpb25hbCIsCiAgMHgyMjFkLAogICJwc2kiLAogIDB4MDNjOCwKICAicHNpY3lyaWxsaWMiLAogIDB4MDQ3MSwKICAicHNpbGlwbmV1bWF0YWN5cmlsbGljY21iIiwKICAweDA0ODYsCiAgInBzc3F1YXJlIiwKICAweDMzYjAsCiAgInB1aGlyYWdhbmEiLAogIDB4MzA3NywKICAicHVrYXRha2FuYSIsCiAgMHgzMGQ3LAogICJwdnNxdWFyZSIsCiAgMHgzM2I0LAogICJwd3NxdWFyZSIsCiAgMHgzM2JhLAogICJxIiwKICAweDAwNzEsCiAgInFhZGV2YSIsCiAgMHgwOTU4LAogICJxYWRtYWhlYnJldyIsCiAgMHgwNWE4LAogICJxYWZhcmFiaWMiLAogIDB4MDY0MiwKICAicWFmZmluYWxhcmFiaWMiLAogIDB4ZmVkNiwKICAicWFmaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWQ3LAogICJxYWZtZWRpYWxhcmFiaWMiLAogIDB4ZmVkOCwKICAicWFtYXRzIiwKICAweDA1YjgsCiAgInFhbWF0czEwIiwKICAweDA1YjgsCiAgInFhbWF0czFhIiwKICAweDA1YjgsCiAgInFhbWF0czFjIiwKICAweDA1YjgsCiAgInFhbWF0czI3IiwKICAweDA1YjgsCiAgInFhbWF0czI5IiwKICAweDA1YjgsCiAgInFhbWF0czMzIiwKICAweDA1YjgsCiAgInFhbWF0c2RlIiwKICAweDA1YjgsCiAgInFhbWF0c2hlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNuYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5oZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5uYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5xdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3FhdGFud2lkZWhlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNxdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3dpZGVoZWJyZXciLAogIDB4MDViOCwKICAicWFybmV5cGFyYWhlYnJldyIsCiAgMHgwNTlmLAogICJxYm9wb21vZm8iLAogIDB4MzExMSwKICAicWNpcmNsZSIsCiAgMHgyNGUwLAogICJxaG9vayIsCiAgMHgwMmEwLAogICJxbW9ub3NwYWNlIiwKICAweGZmNTEsCiAgInFvZiIsCiAgMHgwNWU3LAogICJxb2ZkYWdlc2giLAogIDB4ZmI0NywKICAicW9mZGFnZXNoaGVicmV3IiwKICAweGZiNDcsCiAgInFvZmhlYnJldyIsCiAgMHgwNWU3LAogICJxcGFyZW4iLAogIDB4MjRhYywKICAicXVhcnRlcm5vdGUiLAogIDB4MjY2OSwKICAicXVidXRzIiwKICAweDA1YmIsCiAgInF1YnV0czE4IiwKICAweDA1YmIsCiAgInF1YnV0czI1IiwKICAweDA1YmIsCiAgInF1YnV0czMxIiwKICAweDA1YmIsCiAgInF1YnV0c2hlYnJldyIsCiAgMHgwNWJiLAogICJxdWJ1dHNuYXJyb3doZWJyZXciLAogIDB4MDViYiwKICAicXVidXRzcXVhcnRlcmhlYnJldyIsCiAgMHgwNWJiLAogICJxdWJ1dHN3aWRlaGVicmV3IiwKICAweDA1YmIsCiAgInF1ZXN0aW9uIiwKICAweDAwM2YsCiAgInF1ZXN0aW9uYXJhYmljIiwKICAweDA2MWYsCiAgInF1ZXN0aW9uYXJtZW5pYW4iLAogIDB4MDU1ZSwKICAicXVlc3Rpb25kb3duIiwKICAweDAwYmYsCiAgInF1ZXN0aW9uZG93bnNtYWxsIiwKICAweGY3YmYsCiAgInF1ZXN0aW9uZ3JlZWsiLAogIDB4MDM3ZSwKICAicXVlc3Rpb25tb25vc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FsYXJhYmljIiwKICAweGZlYjMsCiAgInNlZW5tZWRpYWxhcmFiaWMiLAogIDB4ZmViNCwKICAic2Vnb2wiLAogIDB4MDViNiwKICAic2Vnb2wxMyIsCiAgMHgwNWI2LAogICJzZWdvbDFmIiwKICAweDA1YjYsCiAgInNlZ29sMmMiLAogIDB4MDViNiwKICAic2Vnb2xoZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xuYXJyb3doZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xxdWFydGVyaGVicmV3IiwKICAweDA1YjYsCiAgInNlZ29sdGFoZWJyZXciLAogIDB4MDU5MiwKICAic2Vnb2x3aWRlaGVicmV3IiwKICAweDA1YjYsCiAgInNlaGFybWVuaWFuIiwKICAweDA1N2QsCiAgInNlaGlyYWdhbmEiLAogIDB4MzA1YiwKICAic2VrYXRha2FuYSIsCiAgMHgzMGJiLAogICJzZWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2UsCiAgInNlbWljb2xvbiIsCiAgMHgwMDNiLAogICJzZW1pY29sb25hcmFiaWMiLAogIDB4MDYxYiwKICAic2VtaWNvbG9ubW9ub3NwYWNlIiwKICAweGZmMWIsCiAgInNlbWljb2xvbnNtYWxsIiwKICAweGZlNTQsCiAgInNlbWl2b2ljZWRtYXJra2FuYSIsCiAgMHgzMDljLAogICJzZW1pdm9pY2VkbWFya2thbmFoYWxmd2lkdGgiLAogIDB4ZmY5ZiwKICAic2VudGlzcXVhcmUiLAogIDB4MzMyMiwKICAic2VudG9zcXVhcmUiLAogIDB4MzMyMywKICAic2V2ZW4iLAogIDB4MDAzNywKICAic2V2ZW5hcmFiaWMiLAogIDB4MDY2NywKICAic2V2ZW5iZW5nYWxpIiwKICAweDA5ZWQsCiAgInNldmVuY2lyY2xlIiwKICAweDI0NjYsCiAgInNldmVuY2lyY2xlaW52ZXJzZXNhbnNzZXJpZiIsCiAgMHgyNzkwLAogICJzZXZlbmRldmEiLAogIDB4MDk2ZCwKICAic2V2ZW5laWdod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hZGUiLAogIDB4MjU5MiwKICAic2hhZGVkYXJrIiwKICAweDI1OTMsCiAgInNoYWRlbGlnaHQiLAogIDB4MjU5MSwKICAic2hhZGVtZWRpdW0iLAogIDB4MjU5MiwKICAic2hhZGV2YSIsCiAgMHgwOTM2LAogICJzaGFndWphcmF0aSIsCiAgMHgwYWI2LAogICJzaGFndXJtdWtoaSIsCiAgMHgwYTM2LAogICJzaGFsc2hlbGV0aGVicmV3IiwKICAweDA1OTMsCiAgInNoYm9wb21vZm8iLAogIDB4MzExNSwKICAic2hjaGFjeXJpbGxpYyIsCiAgMHgwNDQ5LAogICJzaGVlbmFyYWJpYyIsCiAgMHgwNjM0LAogICJzaGVlbmZpbmFsYXJhYmljIiwKICAweGZlYjYsCiAgInNoZWVuaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWI3LAogICJzaGVlbm1lZGlhbGFyYWJpYyIsCiAgMHhmZWI4LAogICJzaGVpY29wdGljIiwKICAweDAzZTMsCiAgInNoZXFlbCIsCiAgMHgyMGFhLAogICJzaGVxZWxoZWJyZXciLAogIDB4MjBhYSwKICAic2hldmEiLAogIDB4MDViMCwKICAic2hldmExMTUiLAogIDB4MDViMCwKICAic2hldmExNSIsCiAgMHgwNWIwLAogICJzaGV2YTIyIiwKICAweDA1YjAsCiAgInNoZXZhMmUiLAogIDB4MDViMCwKICAic2hldmFoZWJyZXciLAogIDB4MDViMCwKICAic2hldmFuYXJyb3doZWJyZXciLAogIDB4MDViMCwKICAic2hldmFxdWFydGVyaGVicmV3IiwKICAweDA1YjAsCiAgInNoZXZhd2lkZWhlYnJldyIsCiAgMHgwNWIwLAogICJzaGhhY3lyaWxsaWMiLAogIDB4MDRiYiwKICAic2hpbWFjb3B0aWMiLAogIDB4MDNlZCwKICAic2hpbiIsCiAgMHgwNWU5LAogICJzaGluZGFnZXNoIiwKICAweGZiNDksCiAgInNoaW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0OSwKICAic2hpbmRhZ2VzaHNoaW5kb3QiLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNoaW5kb3RoZWJyZXciLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNpbmRvdCIsCiAgMHhmYjJkLAogICJzaGluZGFnZXNoc2luZG90aGVicmV3IiwKICAweGZiMmQsCiAgInNoaW5kb3RoZWJyZXciLAogIDB4MDVjMSwKICAic2hpbmhlYnJldyIsCiAgMHgwNWU5LAogICJzaGluc2hpbmRvdCIsCiAgMHhmYjJhLAogICJzaGluc2hpbmRvdGhlYnJldyIsCiAgMHhmYjJhLAogICJzaGluc2luZG90IiwKICAweGZiMmIsCiAgInNoaW5zaW5kb3RoZWJyZXciLAogIDB4ZmIyYiwKICAic2hvb2siLAogIDB4MDI4MiwKICAic2lnbWEiLAogIDB4MDNjMywKICAic2lnbWExIiwKICAweDAzYzIsCiAgInNpZ21hZmluYWwiLAogIDB4MDNjMiwKICAic2lnbWFsdW5hdGVzeW1ib2xncmVlayIsCiAgMHgwM2YyLAogICJzaWhpcmFnYW5hIiwKICAweDMwNTcsCiAgInNpa2F0YWthbmEiLAogIDB4MzBiNywKICAic2lrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjdjLAogICJzaWx1cWhlYnJldyIsCiAgMHgwNWJkLAogICJzaWx1cWxlZnRoZWJyZXciLAogIDB4MDViZCwKICAic2ltaWxhciIsCiAgMHgyMjNjLAogICJzaW5kb3RoZWJyZXciLAogIDB4MDVjMiwKICAic2lvc2FjaXJjbGVrb3JlYW4iLAogIDB4MzI3NCwKICAic2lvc2FwYXJlbmtvcmVhbiIsCiAgMHgzMjE0LAogICJzaW9zY2lldWNrb3JlYW4iLAogIDB4MzE3ZSwKICAic2lvc2NpcmNsZWtvcmVhbiIsCiAgMHgzMjY2LAogICJzaW9za2l5ZW9ra29yZWFuIiwKICAweDMxN2EsCiAgInNpb3Nrb3JlYW4iLAogIDB4MzE0NSwKICAic2lvc25pZXVua29yZWFuIiwKICAweDMxN2IsCiAgInNpb3NwYX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CwKICAieXVzbGl0dGxlY3lyaWxsaWMiLAogIDB4MDQ2NywKICAieXVzbGl0dGxlaW90aWZpZWRjeXJpbGxpYyIsCiAgMHgwNDY5LAogICJ5dXNtYWxsaGlyYWdhbmEiLAogIDB4MzA4NSwKICAieXVzbWFsbGthdGFrYW5hIiwKICAweDMwZTUsCiAgInl1c21hbGxrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjZkLAogICJ5dXlla29yZWFuIiwKICAweDMxOGIsCiAgInl1eWVva29yZWFuIiwKICAweDMxOGEsCiAgInl5YWJlbmdhbGkiLAogIDB4MDlkZiwKICAieXlhZGV2YSIsCiAgMHgwOTVmLAogICJ6IiwKICAweDAwN2EsCiAgInphYXJtZW5pYW4iLAogIDB4MDU2NiwKICAiemFjdXRlIiwKICAweDAxN2EsCiAgInphZGV2YSIsCiAgMHgwOTViLAogICJ6YWd1cm11a2hpIiwKICAweDBhNWIsCiAgInphaGFyYWJpYyIsCiAgMHgwNjM4LAogICJ6YWhmaW5hbGFyYWJpYyIsCiAgMHhmZWM2LAogICJ6YWhpbml0aWFsYXJhYmljIiwKICAweGZlYzcsCiAgInphaGlyYWdhbmEiLAogIDB4MzA1NiwKICAiemFobWVkaWFsYXJhYmljIiwKICAweGZlYzgsCiAgInphaW5hcmFiaWMiLAogIDB4MDYzMiwKICAiemFpbmZpbmFsYXJhYmljIiwKICAweGZlYjAsCiAgInpha2F0YWthbmEiLAogIDB4MzBiNiwKICAiemFxZWZnYWRvbGhlYnJldyIsCiAgMHgwNTk1LAogICJ6YXFlZnFhdGFuaGVicmV3IiwKICAweDA1OTQsCiAgInphcnFhaGVicmV3IiwKICAweDA1OTgsCiAgInpheWluIiwKICAweDA1ZDYsCiAgInpheWluZGFnZXNoIiwKICAweGZiMzYsCiAgInpheWluZGFnZXNoaGVicmV3IiwKICAweGZiMzYsCiAgInpheWluaGVicmV3IiwKICAweDA1ZDYsCiAgInpib3BvbW9mbyIsCiAgMHgzMTE3LAogICJ6Y2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0LAogICJhNCIsCiAgMHgyNjBlLAogICJhNSIsCiAgMHgyNzA2LAogICJhMTE5IiwKICAweDI3MDcsCiAgImExMTgiLAogIDB4MjcwOCwKICAiYTExNyIsCiAgMHgyNzA5LAogICJhMTEiLAogIDB4MjYxYiwKICAiYTEyIiwKICAweDI2MWUsCiAgImExMyIsCiAgMHgyNzBjLAogICJhMTQiLAogIDB4MjcwZCwKICAiYTE1IiwKICAweDI3MGUsCiAgImExNiIsCiAgMHgyNzBmLAogICJhMTA1IiwKICAweDI3MTAsCiAgImExNyIsCiAgMHgyNzExLAogICJhMTgiLAogIDB4MjcxMiwKICAiYTE5IiwKICAweDI3MTMsCiAgImEyMCIsCiAgMHgyNzE0LAogICJhMjEiLAogIDB4MjcxNSwKICAiYTIyIiwKICAweDI3MTYsCiAgImEyMyIsCiAgMHgyNzE3LAogICJhMjQiLAogIDB4MjcxOCwKICAiYTI1IiwKICAweDI3MTksCiAgImEyNiIsCiAgMHgyNzFhLAogICJhMjciLAogIDB4MjcxYiwKICAiYTI4IiwKICAweDI3MWMsCiAgImE2IiwKICAweDI3MWQsCiAgImE3IiwKICAweDI3MWUsCiAgImE4IiwKICAweDI3MWYsCiAgImE5IiwKICAweDI3MjAsCiAgImExMCIsCiAgMHgyNzIxLAogICJhMjkiLAogIDB4MjcyMiwKICAiYTMwIiwKICAweDI3MjMsCiAgImEzMSIsCiAgMHgyNzI0LAogICJhMzIiLAogIDB4MjcyNSwKICAiYTMzIiwKICAweDI3MjYsCiAgImEzNCIsCiAgMHgyNzI3LAogICJhMzUiLAogIDB4MjYwNSwKICAiYTM2IiwKICAweDI3MjksCiAgImEzNyIsCiAgMHgyNzJhLAogICJhMzgiLAogIDB4MjcyYiwKICAiYTM5IiwKICAweDI3MmMsCiAgImE0MCIsCiAgMHgyNzJkLAogICJhNDEiLAogIDB4MjcyZSwKICAiYTQyIiwKICAweDI3MmYsCiAgImE0MyIsCiAgMHgyNzMwLAogICJhNDQiLAogIDB4MjczMSwKICA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AiLAogIDB4Mjc1ZSwKICAiYTEwMSIsCiAgMHgyNzYxLAogICJhMTAyIiwKICAweDI3NjIsCiAgImExMDMiLAogIDB4Mjc2MywKICAiYTEwNCIsCiAgMHgyNzY0LAogICJhMTA2IiwKICAweDI3NjUsCiAgImExMDciLAogIDB4Mjc2NiwKICAiYTEwOCIsCiAgMHgyNzY3LAogICJhMTEyIiwKICAweDI2NjMsCiAgImExMTEiLAogIDB4MjY2NiwKICAiYTExMCIsCiAgMHgyNjY1LAogICJhMTA5IiwKICAweDI2NjAsCiAgImExMjAiLAogIDB4MjQ2MCwKICAiYTEyMSIsCiAgMHgyNDYxLAogICJhMTIyIiwKICAweDI0NjIsCiAgImExMjMiLAogIDB4MjQ2MywKICAiYTEyNCIsCiAgMHgyNDY0LAogICJhMTI1IiwKICAweDI0NjUsCiAgImExMjYiLAogIDB4MjQ2NiwKICAiYTEyNyIsCiAgMHgyNDY3LAogICJhMTI4IiwKICAweDI0NjgsCiAgImExMjkiLAogIDB4MjQ2OSwKICAiYTEzMCIsCiAgMHgyNzc2LAogICJhMTMxIiwKICAweDI3NzcsCiAgImExMzIiLAogIDB4Mjc3OCwKICAiYTEzMyIsCiAgMHgyNzc5LAogICJhMTM0IiwKICAweDI3N2EsCiAgImExMzUiLAogIDB4Mjc3YiwKICAiYTEzNiIsCiAgMHgyNzdjLAogICJhMTM3IiwKICAweDI3N2QsCiAgImExMzgiLAogIDB4Mjc3ZSwKICAiYTEzOSIsCiAgMHgyNzdmLAogICJhMTQwIiwKICAweDI3ODAsCiAgImExNDEiLAogIDB4Mjc4MSwKICAiYTE0MiIsCiAgMHgyNzgyLAogICJhMTQzIiwKICAweDI3ODMsCiAgImExNDQiLAogIDB4Mjc4NCwKICAiYTE0NSIsCiAgMHgyNzg1LAogICJhMTQ2IiwKICAweDI3ODYsCiAgImExNDciLAogIDB4Mjc4NywKICAiYTE0OCIsCiAgMHgyNzg4LAogICJhMTQ5IiwKICAweDI3ODksCiAgImExNTAiLAogIDB4Mjc4YSwKICAiYTE1MSIsCiAgMHgyNzhiLAogICJhMTUyIiwKICAweDI3OGMsCiAgImExNTMiLAogIDB4Mjc4ZCwKICAiYTE1NCIsCiAgMHgyNzhlLAogICJhMTU1IiwKICAweDI3OGYsCiAgImExNTYiLAogIDB4Mjc5MCwKICAiYTE1NyIsCiAgMHgyNzkxLAogICJhMTU4IiwKICAweDI3OTIsCiAgImExNTkiLAogIDB4Mjc5MywKICAiYTE2MCIsCiAgMHgyNzk0LAogICJhMTYxIiwKICAweDIxOTIsCiAgImExNjMiLAogIDB4MjE5NCwKICAiYTE2NCIsCiAgMHgyMTk1LAogICJhMTk2IiwKICAweDI3OTgsCiAgImExNjUiLAogIDB4Mjc5OSwKICAiYTE5MiIsCiAgMHgyNzlhLAogICJhMTY2IiwKICAweDI3OWIsCiAgImExNjciLAogIDB4Mjc5YywKICAiYTE2OCIsCiAgMHgyNzlkLAogICJhMTY5IiwKICAweDI3OWUsCiAgImExNzAiLAogIDB4Mjc5ZiwKICAiYTE3MSIsCiAgMHgyN2EwLAogICJhMTcyIiwKICAweDI3YTEsCiAgImExNzMiLAogIDB4MjdhMiwKICAiYTE2MiIsCiAgMHgyN2EzLAogICJhMTc0IiwKICAweDI3YTQsCiAgImExNzUiLAogIDB4MjdhNSwKICAiYTE3NiIsCiAgMHgyN2E2LAogICJhMTc3IiwKICAweDI3YTcsCiAgImExNzgiLAogIDB4MjdhOCwKICAiYTE3OSIsCiAgMHgyN2E5LAogICJhMTkzIiwKICAweDI3YWEsCiAgImExODAiLAogIDB4MjdhYiwKICAiYTE5OSIsCiAgMHgyN2FjLAogICJhMTgxIiwKICAweDI3YWQsCiAgImEyMDAiLAogIDB4MjdhZSwKICAiYTE4MiIsCiAgMHgyN2FmLAogICJhMjAxIiwKICAweDI3YjEsCiAgImExODMiLAogIDB4MjdiMiwKICAiYTE4NCIsCiAgMHgyN2IzLAogICJhMTk3IiwKICAweDI3YjQsCiAgImExODUiLAogIDB4MjdiNSwKIC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KShmdW5jdGlvbiAoKSB7CiByZXR1cm4gWwogICJcdTAwQTgiLAogICJcdTAwMjBcdTAzMDgiLAogICJcdTAwQUYiLAogICJcdTAwMjBcdTAzMDQiLAogICJcdTAwQjQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAwQjUiLAogICJcdTAzQkMiLAogICJcdTAwQjgiLAogICJcdTAwMjBcdTAzMjciLAogICJcdTAxMzIiLAogICJcdTAwNDlcdTAwNEEiLAogICJcdTAxMzMiLAogICJcdTAwNjlcdTAwNkEiLAogICJcdTAxM0YiLAogICJcdTAwNENcdTAwQjciLAogICJcdTAxNDAiLAogICJcdTAwNkNcdTAwQjciLAogICJcdTAxNDkiLAogICJcdTAyQkNcdTAwNkUiLAogICJcdTAxN0YiLAogICJcdTAwNzMiLAogICJcdTAxQzQiLAogICJcdTAwNDRcdTAxN0QiLAogICJcdTAxQzUiLAogICJcdTAwNDRcdTAxN0UiLAogICJcdTAxQzYiLAogICJcdTAwNjRcdTAxN0UiLAogICJcdTAxQzciLAogICJcdTAwNENcdTAwNEEiLAogICJcdTAxQzgiLAogICJcdTAwNENcdTAwNkEiLAogICJcdTAxQzkiLAogICJcdTAwNkNcdTAwNkEiLAogICJcdTAxQ0EiLAogICJcdTAwNEVcdTAwNEEiLAogICJcdTAxQ0IiLAogICJcdTAwNEVcdTAwNkEiLAogICJcdTAxQ0MiLAogICJcdTAwNkVcdTAwNkEiLAogICJcdTAxRjEiLAogICJcdTAwNDRcdTAwNUEiLAogICJcdTAxRjIiLAogICJcdTAwNDRcdTAwN0EiLAogICJcdTAxRjMiLAogICJcdTAwNjRcdTAwN0EiLAogICJcdTAyRDgiLAogICJcdTAwMjBcdTAzMDYiLAogICJcdTAyRDkiLAogICJcdTAwMjBcdTAzMDciLAogICJcdTAyREEiLAogICJcdTAwMjBcdTAzMEEiLAogICJcdTAyREIiLAogICJcdTAwMjBcdTAzMjgiLAogICJcdTAyREMiLAogICJcdTAwMjBcdTAzMDMiLAogICJcdTAyREQiLAogICJcdTAwMjBcdTAzMEIiLAogICJcdTAzN0EiLAogICJcdTAwMjBcdTAzNDUiLAogICJcdTAzODQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAzRDAiLAogICJcdTAzQjIiLAogICJcdTAzRDEiLAogICJcdTAzQjgiLAogICJcdTAzRDIiLAogICJcdTAzQTUiLAogICJcdTAzRDUiLAogICJcdTAzQzYiLAogICJcdTAzRDYiLAogICJcdTAzQzAiLAogICJcdTAzRjAiLAogICJcdTAzQkEiLAogICJcdTAzRjEiLAogICJcdTAzQzEiLAogICJcdTAzRjIiLAogICJcdTAzQzIiLAogICJcdTAzRjQiLAogICJcdTAzOTgiLAogICJcdTAzRjUiLAogICJcdTAzQjUiLAogICJcdTAzRjkiLAogICJcdTAzQTMiLAogICJcdTA1ODciLAogICJcdTA1NjVcdTA1ODIiLAogICJcdTA2NzUiLAogICJcdTA2MjdcdTA2NzQiLAogICJcdTA2NzYiLAogICJcdTA2NDhcdTA2NzQiLAogICJcdTA2NzciLAogICJcdTA2QzdcdTA2NzQiLAogICJcdTA2NzgiLAogICJcdTA2NEFcdTA2NzQiLAogICJcdTBFMzMiLAogICJcdTBFNERcdTBFMzIiLAogICJcdTBFQjMiLAogICJcdTBFQ0RcdTBFQjIiLAogICJcdTBFREMiLAogICJcdTBFQUJcdTBFOTkiLAogICJcdTBFREQiLAogICJcdTBFQUJcdTBFQTEiLAogICJcdTBGNzciLAogICJcdTBGQjJcdTBGODEiLAogICJcdTBGNzkiLAogICJcdTBGQjNcdTBGODEiLAogICJcdTFFOUEiLAogICJcdTAwNjFcdTAyQkUiLAogICJcdTFGQkQiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQkYiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQzAiLAogICJcdTAwMjBcdTAzNDIiLAogICJcdTFGRkUiLAogICJcdTAwMjBcdTAzMTQiLAogICJcdTIwMDIiLAogICJcdTAwMjAiLAogICJcdTIwMDMiLAogICJcdTAwMjAiLAogICJcdTIwMDQiLAogICJcdTAwMjAiLAogICJcdTIwMDUiLAogICJcdTAwMjAiLAogICJcdTIwMDYiLAogICJcdTAwMjAiLAogICJcdTIwMDgiLAogICJcdTAwMjAiLAogICJcdTIwMDkiLAogICJcdTAwMjAiLAogICJcdTIwMEEiLAogICJcdTAwMjAiLAogICJcdTIwMTciLAogICJcdTAwMjBcdTAzMzMiLAogICJcdTIwMjQiLAogICJcdTAwMkUiLAogICJcdTIwMjUiLAogICJcdTAwMkVcdTAwMkUiLAogICJcdTIwMjYiLAogICJcdTAwMkVcdTAwMkVcdTAwMkUiLAogICJcdTIwMzMiLAogICJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzQiLAogICJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzYiLAogICJcdTIwMzVcdTIwMzUiLAogICJcdTIwMzciLAogICJcdTIwMzVcdTIwMzVcdTIwMzUiLAogICJcdTIwM0MiLAogICJcdTAwMjFcdTAwMjEiLAogICJcdTIwM0UiLAogICJcdTAwMjBcdTAzMDUiLAogICJcdTIwNDciLAogICJcdTAwM0ZcdTAwM0YiLAogICJcdTIwNDgiLAogICJcdTAwM0ZcdTAwMjEiLAogICJcdTIwNDkiLAogICJcdTAwMjFcdTAwM0YiLAogICJcdTIwNTciLAogICJcdTIwMzJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwNUYiLAogICJcdTAwMjAiLAogICJcdTIwQTgiLAogICJcdTAwNTJcdTAwNzMiLAogICJcdTIxMDAiLAogICJcdTAwNjFcdTAwMkZcdTAwNjMiLAogICJcdTIxMDEiLAogICJcdTAwNjFcdTAwMkZcdTAwNzMiLAogICJcdTIxMDMiLAogICJcdTAwQjBcdTAwNDMiLAogICJcdTIxMDUiLAogICJcdTAwNjNcdTAwMkZcdTAwNkYiLAogICJcdTIxMDYiLAogICJcdTAwNjNcdTAwMkZcdTAwNzUiLAogICJcdTIxMDciLAogICJcdTAxOTAiLAogICJcdTIxMDkiLAogICJcdTAwQjBcdTAwNDYiLAogICJcdTIxMTYiLAogICJcdTAwNEVcdTAwNkYiLAogICJcdTIxMjEiLAogICJcdTAwNTRcdTAwNDVcdTAwNEMiLAogICJcdTIxMzUiLAogICJcdTA1RDAiLAogICJcdTIxMzYiLAogICJcdTA1RDEiLAogICJcdTIxMzciLAogICJcdTA1RDIiLAogICJcdTIxMzgiLAogICJcdTA1RDMiLAogICJcdTIxM0IiLAogICJcdTAwNDZcdTAwNDFcdTAwNTgiLAogICJcdTIxNjAiLAogICJcdTAwNDkiLAogICJcdTIxNjEiLAogICJcdTAwNDlcdTAwNDkiLAogICJcdTIxNjIiLAogICJcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjMiLAogICJcdTAwNDlcdTAwNTYiLAogICJcdTIxNjQiLAogICJcdTAwNTYiLAogICJcdTIxNjUiLAogICJcdTAwNTZcdTAwNDkiLAogICJcdTIxNjYiLAogICJcdTAwNTZcdTAwNDlcdTAwNDkiLAogICJcdTIxNjciLAogICJcdTAwNTZcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjgiLAogICJcdTAwNDlcdTAwNTgiLAogICJcdTIxNjkiLAogICJcdTAwNTgiLAogICJcdTIxNkEiLAogICJcdTAwNThcdTAwNDkiLAogICJcdTIxNkIiLAogICJcdTAwNThcdTAwNDlcdTAwNDkiLAogICJcdTIxNkMiLAogICJcdTAwNEMiLAogICJcdTIxNkQiLAogICJcdTAwNDMiLAogICJcdTIxNkUiLAogICJcdTAwNDQiLAogICJcdTIxNkYiLAogICJcdTAwNEQiLAogICJcdTIxNzAiLAogICJcdTAwNjkiLAogICJcdTIxNzEiLAogICJcdTAwNjlcdTAwNjkiLAogICJcdTIxNzIiLAogICJcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzMiLAogICJcdTAwNjlcdTAwNzYiLAogICJcdTIxNzQiLAogICJcdTAwNzYiLAogICJcdTIxNzUiLAogICJcdTAwNzZcdTAwNjkiLAogICJcdTIxNzYiLAogICJcdTAwNzZcdTAwNjlcdTAwNjkiLAogICJcdTIxNzciLAogICJcdTAwNzZcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzgiLAogICJcdTAwNjlcdTAwNzgiLAogICJcdTIxNzkiLAogICJcdTAwNzgiLAogICJcdTIxN0EiLAogICJcdTAwNzhcdTAwNjkiLAogICJcdTIxN0IiLAogICJcdTAwNzhcdTAwNjlcdTAwNjkiLAogICJcdTIxN0MiLAogICJcdTAwNkMiLAogICJcdTIxN0QiLAogICJcdTAwNjMiLAogICJcdTIxN0UiLAogICJcdTAwNjQiLAogICJcdTIxN0YiLAogICJcdTAwNkQiLAogICJcdTIyMkMiLAogICJcdTIyMkJcdTIyMkIiLAogICJcdTIyMkQiLAogICJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTIyMkYiLAogICJcdTIyMkVcdTIyMkUiLAogICJcdTIyMzAiLAogICJcdTIyMkVcdTIyMkVcdTIyMkUiLAogICJcdTI0NzQiLAogICJcdTAwMjhcdTAwMzFcdTAwMjkiLAogICJcdTI0NzUiLAogICJcdTAwMjhcdTAwMzJcdTAwMjkiLAogICJcdTI0NzYiLAogICJcdTAwMjhcdTAwMzNcdTAwMjkiLAogICJcdTI0NzciLAogICJcdTAwMjhcdTAwMzRcdTAwMjkiLAogICJcdTI0NzgiLAogICJcdTAwMjhcdTAwMzVcdTAwMjkiLAogICJcdTI0NzkiLAogICJcdTAwMjhcdTAwMzZcdTAwMjkiLAogICJcdTI0N0EiLAogICJcdTAwMjhcdTAwMzdcdTAwMjkiLAogICJcdTI0N0IiLAogICJcdTAwMjhcdTAwMzhcdTAwMjkiLAogICJcdTI0N0MiLAogICJcdTAwMjhcdTAwMzlcdTAwMjkiLAogICJcdTI0N0QiLAogICJcdTAwMjhcdTAwMzFcdTAwMzBcdTAwMjkiLAogICJcdTI0N0UiLAogICJcdTAwMjhcdTAwMzFcdTAwMzFcdTAwMjkiLAogICJcdTI0N0YiLA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iLAogICJcdTI0QUUiLAogICJcdTAwMjhcdTAwNzNcdTAwMjkiLAogICJcdTI0QUYiLAogICJcdTAwMjhcdTAwNzRcdTAwMjkiLAogICJcdTI0QjAiLAogICJcdTAwMjhcdTAwNzVcdTAwMjkiLAogICJcdTI0QjEiLAogICJcdTAwMjhcdTAwNzZcdTAwMjkiLAogICJcdTI0QjIiLAogICJcdTAwMjhcdTAwNzdcdTAwMjkiLAogICJcdTI0QjMiLAogICJcdTAwMjhcdTAwNzhcdTAwMjkiLAogICJcdTI0QjQiLAogICJcdTAwMjhcdTAwNzlcdTAwMjkiLAogICJcdTI0QjUiLAogICJcdTAwMjhcdTAwN0FcdTAwMjkiLAogICJcdTJBMEMiLAogICJcdTIyMkJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTJBNzQiLAogICJcdTAwM0FcdTAwM0FcdTAwM0QiLAogICJcdTJBNzUiLAogICJcdTAwM0RcdTAwM0QiLAogICJcdTJBNzYiLAogICJcdTAwM0RcdTAwM0RcdTAwM0QiLAogICJcdTJFOUYiLAogICJcdTZCQ0QiLAogICJcdTJFRjMiLAogICJcdTlGOUYiLAogICJcdTJGMDAiLAogICJcdTRFMDAiLAogICJcdTJGMDEiLAogICJcdTRFMjgiLAogICJcdTJGMDIiLAogICJcdTRFMzYiLAogICJcdTJGMDMiLAogICJcdTRFM0YiLAogICJcdTJGMDQiLAogICJcdTRFNTkiLAogICJcdTJGMDUiLAogICJcdTRFODUiLAogICJcdTJGMDYiLAogICJcdTRFOEMiLAogICJcdTJGMDciLAogICJcdTRFQTAiLAogICJcdTJGMDgiLAogICJcdTRFQkEiLAogICJcdTJGMDkiLAogICJcdTUxM0YiLAogICJcdTJGMEEiLAogICJcdTUxNjUiLAogICJcdTJGMEIiLAogICJcdTUxNkIiLAogICJcdTJGMEMiLAogICJcdTUxODIiLAogICJcdTJGMEQiLAogICJcdTUxOTYiLAogICJcdTJGMEUiLAogICJcdTUxQUIiLAogICJcdTJGMEYiLAogICJcdTUxRTAiLAogICJcdTJGMTAiLAogICJcdTUxRjUiLAogICJcdTJGMTEiLAogICJcdTUyMDAiLAogICJcdTJGMTIiLAogICJcdTUyOUIiLAogICJcdTJGMTMiLAogICJcdTUyRjkiLAogICJcdTJGMTQiLAogICJcdTUzMTUiLAogICJcdTJGMTUiLAogICJcdTUzMUEiLAogICJcdTJGMTYiLAogICJcdTUzMzgiLAogICJcdTJGMTciLAogICJcdTUzNDEiLAogICJcdTJGMTgiLAogICJcdTUzNUMiLAogICJcdTJGMTkiLAogICJcdTUzNjkiLAogICJcdTJGMUEiLAogICJcdTUzODIiLAogICJcdTJGMUIiLAogICJcdTUzQjYiLAogICJcdTJGMUMiLAogICJcdTUzQzgiLAogICJcdTJGMUQiLAogICJcdTUzRTMiLAogICJcdTJGMUUiLAogICJcdTU2RDciLAogICJcdTJGMUYiLAogICJcdTU3MUYiLAogICJcdTJGMjAiLAogICJcdTU4RUIiLAogICJcdTJGMjEiLAogICJcdTU5MDIiLAogICJcdTJGMjIiLAogICJcdTU5MEEiLAogICJcdTJGMjMiLAogICJcdTU5MTUiLAogICJcdTJGMjQiLAogICJcdTU5MjciLAogICJcdTJGMjUiLAogICJcdTU5NzMiLAogICJcdTJGMjYiLAogICJcdTVCNTAiLAogICJcdTJGMjciLAogICJcdTVCODAiLAogICJcdTJGMjgiLAogICJcdTVCRjgiLAogICJcdTJGMjkiLAogICJcdTVDMEYiLAogICJcdTJGMkEiLAogICJcdTVDMjIiLAogICJcdTJGMkIiLAogICJcdTVDMzgiLAogICJcdTJGMkMiLAogICJcdTVDNkUiLAogICJcdTJGMkQiLAogICJcdTVDNzEiLAogICJcdTJGMkUiLAogICJcdTVEREIiLAogICJcdTJGMkYiLAogICJcdTVERTUiLAogICJcdTJGMzAiLAogICJcdTVERjEiLAogICJcdTJGMzEiLAogICJcdTVERkUiLAogICJcdTJGMzIiLAogICJcdTVFNzIiLAogICJcdTJGMzMiLAogICJcdTVFN0EiLAogICJcdTJGMzQiLAogICJcdTVFN0YiLAogICJcdTJGMzUiLAogICJcdTVFRjQiLAogICJcdTJGMzYiLAogICJcdTVFRkUiLAogICJcdTJGMzciLAogICJcdTVGMEIiLAogICJcdTJGMzgiLAogICJcdTVGMTMiLAogICJcdTJGMzkiLAogICJcdTVGNTAiLAogICJcdTJGM0EiLAogICJcdTVGNjEiLAogICJcdTJGM0IiLAogICJcdTVGNzMiLAogICJcdTJGM0MiLAogICJcdTVGQzMiLAogICJcdTJGM0QiLAogICJcdTYyMDgiLAogICJcdTJGM0UiLAogICJcdTYyMzYiLAogICJcdTJGM0YiLAogICJcdTYyNEIiLAogICJcdTJGNDAiLAogICJcdTY1MkYiLAogICJcdTJGNDEiLAogICJcdTY1MzQiLAogICJcdTJGNDIiLAogICJcdTY1ODciLAogICJcdTJGNDMiLAogICJcdTY1OTciLAogICJcdTJGNDQiLAogICJcdTY1QTQiLAogICJcdTJGNDUiLAogICJcdTY1QjkiLAogICJcdTJGNDYiLAogICJcdTY1RTAiLAogICJcdTJGNDciLAogICJcdTY1RTUiLAogICJcdTJGNDgiLAogICJcdTY2RjAiLAogICJcdTJGNDkiLAogICJcdTY3MDgiLAogICJcdTJGNEEiLAogICJcdTY3MjgiLAogICJcdTJGNEIiLAogICJcdTZCMjAiLAogICJcdTJGNEMiLAogICJcdTZCNjIiLAogICJcdTJGNEQiLAogICJcdTZCNzkiLAogICJcdTJGNEUiLAogICJcdTZCQjMiLAogICJcdTJGNEYiLAogICJcdTZCQ0IiLAogICJcdTJGNTAiLAogICJcdTZCRDQiLAogICJcdTJGNTEiLAogICJcdTZCREIiLAogICJcdTJGNTIiLAogICJcdTZDMEYiLAogICJcdTJGNTMiLAogICJcdTZDMTQiLAogICJcdTJGNTQiLAogICJcdTZDMzQiLAogICJcdTJGNTUiLAogICJcdTcwNkIiLAogICJcdTJGNTYiLAogICJcdTcyMkEiLAogICJcdTJGNTciLAogICJcdTcyMzYiLAogICJcdTJGNTgiLAogICJcdTcyM0IiLAogICJcdTJGNTkiLAogICJcdTcyM0YiLAogICJcdTJGNUEiLAogICJcdTcyNDciLAogICJcdTJGNUIiLAogICJcdTcyNTkiLAogICJcdTJGNUMiLAogICJcdTcyNUIiLAogICJcdTJGNUQiLAogICJcdTcyQUMiLAogICJcdTJGNUUiLAogICJcdTczODQiLAogICJcdTJGNUYiLAogICJcdTczODkiLAogICJcdTJGNjAiLAogICJcdTc0REMiLAogICJcdTJGNjEiLAogICJcdTc0RTYiLAogICJcdTJGNjIiLAogICJcdTc1MTgiLAogICJcdTJGNjMiLAogICJcdTc1MUYiLAogICJcdTJGNjQiLAogICJcdTc1MjgiLAogICJcdTJGNjUiLAogICJcdTc1MzAiLAogICJcdTJGNjYiLAogICJcdTc1OEIiLAogICJcdTJGNjciLAogICJcdTc1OTIiLAogICJcdTJGNjgiLAogICJcdTc2NzYiLAogICJcdTJGNjkiLAogICJcdTc2N0QiLAogICJcdTJGNkEiLAogICJcdTc2QUUiLAogICJcdTJGNkIiLAogICJcdTc2QkYiLAogICJcdTJGNkMiLAogICJcdTc2RUUiLAogICJcdTJGNkQiLAogICJcdTc3REIiLAogICJcdTJGNkUiLAogICJcdTc3RTIiLAogICJcdTJGNkYiLAogICJcdTc3RjMiLAogICJcdTJGNzAiLAogICJcdTc5M0EiLAogICJcdTJGNzEiLAogICJcdTc5QjgiLAogICJcdTJGNzIiLAogICJcdTc5QkUiLAogICJcdTJGNzMiLAogICJcdTdBNzQiLAogICJcdTJGNzQiLAogICJcdTdBQ0IiLAogICJcdTJGNzUiLAogICJcdTdBRjkiLAogICJcdTJGNzYiLAogICJcdTdDNzMiLAogICJcdTJGNzciLAogICJcdTdDRjgiLAogICJcdTJGNzgiLAogICJcdTdGMzYiLAogICJcdTJGNzkiLAogICJcdTdGNTEiLAogICJcdTJGN0EiLAogICJcdTdGOEEiLAogICJcdTJGN0IiLAogICJcdTdGQkQiLAogICJcdTJGN0MiLAogICJcdTgwMDEiLAogICJcdTJGN0QiLAogICJcdTgwMEMiLAogICJcdTJGN0UiLAogICJcdTgwMTIiLAogICJcdTJGN0YiLAogICJcdTgwMzMiLAogICJcdTJGODAiLAogICJcdTgwN0YiLAogICJcdTJGODEiLAogICJcdTgwODkiLAogICJcdTJGODIiLAogICJcdTgxRTMiLAogICJcdTJGODMiLAogICJcdTgxRUEiLAogICJcdTJGODQiLAogICJcdTgxRjMiLAogICJcdTJGODUiLAogICJcdTgxRkMiLAogICJcdTJGODYiLAogICJcdTgyMEMiLAogICJcdTJGODciLAogICJcdTgyMUIiLAogICJcdTJGODgiLAogICJcdTgyMUYiLAogICJcdTJGODkiLAogICJcdTgyNkUiLAogICJcdTJGOEEiLAogICJcdTgyNzIiLAogICJcdTJGOEIiLAogICJcdTgyNzgiLAogICJcdTJGOEMiLAogICJcdTg2NEQiLAogICJcdTJGOEQiLAogICJcdTg2NkIiLAogICJcdTJGOEUiLAogICJcdTg4NDAiLAogICJcdTJGOEYiLAogICJcdTg4NEMiLAogICJcdTJGOTAiLAogICJcdTg4NjMiLAogICJcdTJGOTEiLAogICJcdTg5N0UiLAogICJcdTJGOTIiLAogICJcdTg5OEIiLAogICJcdTJGOTMiLAogICJcdTg5RDIiLAogICJcdTJGOTQiLAogICJcdThBMDAiLAogICJcdTJGOTUiLAogICJcdThDMzciLAogICJcdTJGOTYiLAogICJcdThDNDYiLAogICJcdTJGOTciLAogICJcdThDNTUiLAogICJcdTJGOTgiLAogICJcdThDNzgiLAogICJcdTJGOTkiLAogICJcdThDOUQiLAogICJcdTJGOUEiLAogICJcdThENjQiLAogICJcdTJGOUIiLAogICJcdThENzAiLAogICJcdTJGOUMiLAogICJcdThEQjMiLAogICJcdTJGOUQiLAogICJcdThFQUIiLAogICJcdTJGOUUiLAogICJcdThFQ0EiLAogICJcdTJGOUYiLAogICJcdThGOUIiLAogICJcdTJGQTAiLAogICJcdThGQjAiLAogICJcdTJGQTEiLAogICJcdThGQjUiLAogICJcdTJGQTIiLAogICJcdTkwOTEiLAogICJcdTJGQTMiLAogICJcdTkxNDkiLAogICJcdTJGQTQiLAogICJcdTkxQzYiLAogICJcdTJGQTUiLAogICJcdTkxQ0MiLAogICJcdTJGQTYiLAogICJcdTkxRDEiLAogICJcdTJGQTciLAogICJcdTk1NzciLAogICJcdTJGQTgiLAogICJcdTk1ODAiLAogICJcdTJGQTkiLAogICJcdTk2MUMiLAogICJcdTJGQUEiLAogICJcdTk2QjYiLAogICJcdTJGQUIiLAogICJcdTk2QjkiLAogICJcdTJGQUMiLAogICJcdTk2RTgiLAogICJcdTJGQUQiLAogICJcdTk3NTEiLAogICJcdTJGQUUiLAogICJcdTk3NUUiLAogICJcdTJGQUYiLAogICJcdTk3NjIiLAogICJcdTJGQjAiLAogICJcdTk3NjkiLAogICJcdTJGQjEiLAogICJcdTk3Q0IiLAogICJcdTJGQjIiLAogICJcdTk3RUQiLAogICJcdTJGQjMiLAogICJcdTk3RjMiLAogICJcdTJGQjQiLAogICJcdTk4MDEiLAogICJcdTJGQjUiLAogICJcdTk4QTgiLAogICJcdTJGQjYiLAogICJcdTk4REIiLAogICJcdTJGQjciLAogICJcdTk4REYiLAogICJcdTJGQjgiLAogICJcdTk5OTYiLAogICJcdTJGQjkiLAogICJcdTk5OTkiLAogICJcdTJGQkEiLAogICJcdTk5QUMiLAogICJcdTJGQkIiLAogICJcdTlBQTgiLAogICJcdTJGQkMiLAogICJcdTlBRDgiLAogICJcdTJGQkQiLAogICJcdTlBREYiLAogICJcdTJGQkUiLAogICJcdTlCMjUiLAogICJcdTJGQkYiLAogICJcdTlCMkYiLAogICJcdTJGQzAiLAogICJcdTlCMzIiLAogICJcdTJGQzEiLAogICJcdTlCM0MiLAogICJcdTJGQzIiLAogICJcdTlCNUEiLAogICJcdTJGQzMiLAogICJcdTlDRTUiLAogICJcdTJGQzQiLAogICJcdTlFNzUiLAogICJcdTJGQzUiLAogICJcdTlFN0YiLAogICJcdTJGQzYiLAogICJcdTlFQTUiLAogICJcdTJGQzciLAogICJcdTlFQkIiLAogICJcdTJGQzgiLAogICJcdTlFQzMiLAogICJcdTJGQzkiLAogICJcdTlFQ0QiLAogICJcdTJGQ0EiLAogICJcdTlFRDEiLAogICJcdTJGQ0IiLAogICJcdTlFRjkiLAogICJcdTJGQ0MiLAogICJcdTlFRkQiLAogICJcdTJGQ0QiLAogICJcdTlGMEUiLAogICJcdTJGQ0UiLAogICJcdTlGMTMiLAogICJcdTJGQ0YiLAogICJcdTlGMjAiLAogICJcdTJGRDAiLAogICJcdTlGM0IiLAogICJcdTJGRDEiLAogICJcdTlGNEEiLAogICJcdTJGRDIiLAogICJcdTlGNTIiLAogICJcdTJGRDMiLAogICJcdTlGOEQiLAogICJcdTJGRDQiLAogICJcdTlGOUMiLAogICJcdTJGRDUiLAogICJcdTlGQTAiLAogICJcdTMwMzYiLAogICJcdTMwMTIiLAogICJcdTMwMzgiLAogICJcdTUzNDEiLAogICJcdTMwMzkiLAogICJcdTUzNDQiLAogICJcdTMwM0EiLAogICJcdTUzNDUiLAogICJcdTMwOUIiLAogICJcdTAwMjBcdTMwOTkiLAogICJcdTMwOUMiLAogICJcdTAwMjBcdTMwOUEiLAogICJcdTMxMzEiLAogICJcdTExMDAiLAogICJcdTMxMzIiLAogICJcdTExMDEiLAogICJcdTMxMzMiLAogICJcdTExQUEiLAogICJcdTMxMzQiLAogICJcdTExMDIiLAogICJcdTMxMzUiLAogICJcdTExQUMiLAogICJcdTMxMzYiLAogICJcdTExQUQiLAogICJcdTMxMzciLAogICJcdTExMDMiLAogICJcdTMxMzgiLAogICJcdTExMDQiLAogICJcdTMxMzkiLAogICJcdTExMDUiLAogICJcdTMxM0EiLAogICJcdTExQjAiLAogICJcdTMxM0IiLAogICJcdTExQjEiLAogICJcdTMxM0MiLAogICJcdTExQjIiLAogICJcdTMxM0QiLAogICJcdTExQjMiLAogICJcdTMxM0UiLAogICJcdTExQjQiLAogICJcdTMxM0YiLAogICJcdTExQjUiLAogICJcdTMxNDAiLAogICJcdTExMUEiLAogICJcdTMxNDEiLAogICJcdTExMDYiLAogICJcdTMxNDIiLAogICJcdTExMDciLAogICJcdTMxNDMiLAogICJcdTExMDgiLAogICJcdTMxNDQiLAogICJcdTExMjEiLAogICJcdTMxNDUiLAogICJcdTExMDkiLAogICJcdTMxNDYiLAogICJcdTExMEEiLAogICJcdTMxNDciLAogICJcdTExMEIiLAogICJcdTMxNDgiLAogICJcdTExMEMiLAogICJcdTMxNDkiLAogICJcdTExMEQiLAogICJcdTMxNEEiLAogICJcdTExMEUiLAogICJcdTMxNEIiLAogICJcdTExMEYiLAogICJcdTMxNEMiLAogICJcdTExMTAiLAogICJcdTMxNEQiLAogICJcdTExMTEiLAogICJcdTMxNEUiLAogICJcdTExMTIiLAogICJcdTMxNEYiLAogICJcdTExNjEiLAogICJcdTMxNTAiLAogICJcdTExNjIiLAogICJcdTMxNTEiLAogICJcdTExNjMiLAogICJcdTMxNTIiLAogICJcdTExNjQiLAogICJcdTMxNTMiLAogICJcdTExNjUiLAogICJcdTMxNTQiLAogICJcdTExNjYiLAogICJcdTMxNTUiLAogICJcdTExNjciLAogICJcdTMxNTYiLAogICJcdTExNjgiLAogICJcdTMxNTciLAogICJcdTExNjkiLAogICJcdTMxNTgiLAogICJcdTExNkEiLAogICJcdTMxNTkiLAogICJcdTExNkIiLAogICJcdTMxNUEiLAogICJcdTExNkMiLAogICJcdTMxNUIiLAogICJcdTExNkQiLAogICJcdTMxNUMiLAogICJcdTExNkUiLAogICJcdTMxNUQiLAogICJcdTExNkYiLAogICJcdTMxNUUiLAogICJcdTExNzAiLAogICJcdTMxNUYiLAogICJcdTExNzEiLAogICJcdTMxNjAiLAogICJcdTExNzIiLAogICJcdTMxNjEiLAogICJcdTExNzMiLAogICJcdTMxNjIiLAogICJcdTExNzQiLAogICJcdTMxNjMiLAogICJcdTExNzUiLAogICJcdTMxNjQiLAogICJcdTExNjAiLAogICJcdTMxNjUiLAogICJcdTExMTQiLAogICJcdTMxNjYiLAogICJcdTExMTUiLAogICJcdTMxNjciLAogICJcdTExQzciLAogICJcdTMxNjgiLAogICJcdTExQzgiLAogICJcdTMxNjkiLAogICJcdTExQ0MiLAogICJcdTMxNkEiLAogICJcdTExQ0UiLAogICJcdTMxNkIiLAogICJcdTExRDMiLAogICJcdTMxNkMiLAogICJcdTExRDciLAogICJcdTMxNkQiLAogICJcdTExRDkiLAogICJcdTMxNkUiLAogICJcdTExMUMiLAogICJcdTMxNkYiLAogICJcdTExREQiLAogICJcdTMxNzAiLAogICJcdTExREYiLAogICJcdTMxNzEiLAogICJcdTExMUQiLAogICJcdTMxNzIiLAogICJcdTExMUUiLAogICJcdTMxNzMiLAogICJcdTExMjAiLAogICJcdTMxNzQiLAogICJcdTExMjIiLAogICJcdTMxNzUiLAogICJcdTExMjMiLAogICJcdTMxNzYiLAogICJcdTExMjciLAogICJcdTMxNzciLAogICJcdTExMjkiLAogICJcdTMxNzgiLAogICJcdTExMkIiLAogICJcdTMxNzkiLAogICJcdTExMkMiLAogICJcdTMxN0EiLAogICJcdTExMkQiLAogICJcdTMxN0IiLAogICJcdTExMkUiLAogICJcdTMxN0MiLAogICJcdTExMkYiLAogICJcdTMxN0QiLAogICJcdTExMzIiLAogICJcdTMxN0UiLAogICJcdTExMzYiLAogICJcdTMxN0YiLAogICJcdTExNDAiLAogICJcdTMxODAiLAogICJcdTExNDciLAogICJcdTMxODEiLAogICJcdTExNEMiLAogICJcdTMxODIiLAogICJcdTExRjEiLAogICJcdTMxODMiLAogICJcdTExRjIiLAogICJcdTMxODQiLAogICJcdTExNTciLAogICJcdTMxODUiLAogICJcdTExNTgiLAogICJcdTMxODYiLAogICJcdTExNTkiLAogICJcdTMxODciLAogICJcdTExODQiLAogICJcdTMxODgiLAogICJcdTExODUiLAogICJcdTMxODkiLAogICJcdTExODgiLAogICJcdTMxOEEiLAogICJcdTExOTEiLAogICJcdTMxOEIiLAogICJcdTExOTIiLAogICJcdTMxOEMiLAogICJcdTExOTQiLAogICJcdTMxOEQiLAogICJcdTExOUUiLAogICJcdTMxOEUiLAogICJcdTExQTEiLAogICJcdTMyMDAiLAogICJcdTAwMjhcdTExMDBcdTAwMjkiLAogICJcdTMyMDEiLAogICJcdTAwMjhcdTExMDJcdTAwMjkiLAogICJcdTMyMDIiLAogICJcdTAwMjhcdTExMDNcdTAwMjkiLAogICJcdTMyMDMiLAogICJcdTAwMjhcdTExMDVcdTAwMjkiLAogICJcdTMyMDQiLAogICJcdTAwMjhcdTExMDZcdTAwMjkiLAogICJcdTMyMDUiLAogICJcdTAwMjhcdTExMDdcdTAwMjkiLAogICJcdTMyMDYiLAogICJcdTAwMjhcdTExMDlcdTAwMjkiLAogICJcdTMyMDciLAogICJcdTAwMjhcdTExMEJcdTAwMjkiLAogICJcdTMyMDgiLAogICJcdTAwMjhcdTExMENcdTAwMjkiLAogICJcdTMyMDkiLAogICJcdTAwMjhcdTExMEVcdTAwMjkiLAogICJcdTMyMEEiLAogICJcdTAwMjhcdTExMEZcdTAwMjkiLAogICJcdTMyMEIiLAogICJcdTAwMjhcdTExMTBcdTAwMjkiLAogICJcdTMyMEMiLAogICJcdTAwMjhcdTExMTFcdTAwMjkiLAogICJcdTMyMEQiLAogICJcdTAwMjhcdTExMTJcdTAwMjkiLAogICJcdTMyMEUiLAogICJcdTAwMjhcdTExMDBcdTExNjFcdTAwMjkiLAogICJcdTMyMEYiLAogICJcdTAwMjhcdTExMDJcdTExNjFcdTAwMjkiLAogICJcdTMyMTAiLAogICJcdTAwMjhcdTExMDNcdTExNjFcdTAwMjkiLAogICJcdTMyMTEiLAogICJcdTAwMjhcdTExMDVcdTExNjFcdTAwMjkiLAogICJcdTMyMTIiLAogICJcdTAwMjhcdTExMDZcdTExNjFcdTAwMjkiLAogICJcdTMyMTMiLAogICJcdTAwMjhcdTExMDdcdTExNjFcdTAwMjkiLAogICJcdTMyMTQiLAogICJcdTAwMjhcdTExMDlcdTExNjFcdTAwMjkiLAogICJcdTMyMTUiLAogICJcdTAwMjhcdTExMEJcdTExNjFcdTAwMjkiLAogICJcdTMyMTYiLAogICJcdTAwMjhcdTExMENcdTExNjFcdTAwMjkiLAogICJcdTMyMTciLAogICJcdTAwMjhcdTExMEVcdTExNjFcdTAwMjkiLAogICJcdTMyMTgiLAogICJcdTAwMjhcdTExMEZcdTExNjFcdTAwMjkiLAogICJcdTMyMTkiLAogICJcdTAwMjhcdTExMTBcdTExNjFcdTAwMjkiLAogICJcdTMyMUEiLAogICJcdTAwMjhcdTExMTFcdTExNjFcdTAwMjkiLAogICJcdTMyMUIiLAogICJcdTAwMjhcdTExMTJcdTExNjFcdTAwMjkiLAogICJcdTMyMUMiLAogICJcdTAwMjhcdTExMENcdTExNkVcdTAwMjkiLAogICJcdTMyMUQiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMENcdTExNjVcdTExQUJcdTAwMjkiLAogICJcdTMyMUUiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMTJcdTExNkVcdTAwMjkiLAogICJcdTMyMjAiLAogICJcdTAwMjhcdTRFMDBcdTAwMjkiLAogICJcdTMyMjEiLAogICJcdTAwMjhcdTRFOENcdTAwMjkiLAogICJcdTMyMjIiLAogICJcdTAwMjhcdTRFMDlcdTAwMjkiLAogICJcdTMyMjMiLAogICJcdTAwMjhcdTU2REJcdTAwMjkiLAogICJcdTMyMjQiLAogICJcdTAwMjhcdTRFOTRcdTAwMjkiLAogICJcdTMyMjUiLAogICJcdTAwMjhcdTUxNkRcdTAwMjkiLAogICJcdTMyMjYiLAogICJcdTAwMjhcdTRFMDNcdTAwMjkiLAogICJcdTMyMjciLAogICJcdTAwMjhcdTUxNkJcdTAwMjkiLAogICJcdTMyMjgiLAogICJcdTAwMjhcdTRFNURcdTAwMjkiLAogICJcdTMyMjkiLAogICJcdTAwMjhcdTUzNDFcdTAwMjkiLAogICJcdTMyMkEiLAogICJcdTAwMjhcdTY3MDhcdTAwMjkiLAogICJcdTMyMkIiLAogICJcdTAwMjhcdTcwNkJcdTAwMjkiLAogICJcdTMyMkMiLAogICJcdTAwMjhcdTZDMzRcdT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zAiLAogICJcdTAwMzFcdTY3MDgiLAogICJcdTMyQzEiLAogICJcdTAwMzJcdTY3MDgiLAogICJcdTMyQzIiLAogICJcdTAwMzNcdTY3MDgiLAogICJcdTMyQzMiLAogICJcdTAwMzRcdTY3MDgiLAogICJcdTMyQzQiLAogICJcdTAwMzVcdTY3MDgiLAogICJcdTMyQzUiLAogICJcdTAwMzZcdTY3MDgiLAogICJcdTMyQzYiLAogICJcdTAwMzdcdTY3MDgiLAogICJcdTMyQzciLAogICJcdTAwMzhcdTY3MDgiLAogICJcdTMyQzgiLAogICJcdTAwMzlcdTY3MDgiLAogICJcdTMyQzkiLAogICJcdTAwMzFcdTAwMzBcdTY3MDgiLAogICJcdTMyQ0EiLAogICJcdTAwMzFcdTAwMzFcdTY3MDgiLAogICJcdTMyQ0IiLAogICJcdTAwMzFcdTAwMzJcdTY3MDgiLAogICJcdTMzNTgiLAogICJcdTAwMzBcdTcwQjkiLAogICJcdTMzNTkiLAogICJcdTAwMzFcdTcwQjkiLAogICJcdTMzNUEiLAogICJcdTAwMzJcdTcwQjkiLAogICJcdTMzNUIiLAogICJcdTAwMzNcdTcwQjkiLAogICJcdTMzNUMiLAogICJcdTAwMzRcdTcwQjkiLAogICJcdTMzNUQiLAogICJcdTAwMzVcdTcwQjkiLAogICJcdTMzNUUiLAogICJcdTAwMzZcdTcwQjkiLAogICJcdTMzNUYiLAogICJcdTAwMzdcdTcwQjkiLAogICJcdTMzNjAiLAogICJcdTAwMzhcdTcwQjkiLAogICJcdTMzNjEiLAogICJcdTAwMzlcdTcwQjkiLAogICJcdTMzNjIiLAogICJcdTAwMzFcdTAwMzBcdTcwQjkiLAogICJcdTMzNjMiLAogICJcdTAwMzFcdTAwMzFcdTcwQjkiLAogICJcdTMzNjQiLAogICJcdTAwMzFcdTAwMzJcdTcwQjkiLAogICJcdTMzNjUiLAogICJcdTAwMzFcdTAwMzNcdTcwQjkiLAogICJcdTMzNjYiLAogICJcdTAwMzFcdTAwMzRcdTcwQj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QiLAogICJcdTA1NzRcdTA1NjUiLAogICJcdUZCMTUiLAogICJcdTA1NzRcdTA1NkIiLAogICJcdUZCMTYiLAogICJcdTA1N0VcdTA1NzYiLAogICJcdUZCMTciLAogICJcdTA1NzRcdTA1NkQiLAogICJcdUZCNEYiLAogICJcdTA1RDBcdTA1REMiLAogICJcdUZCNTAiLAogICJcdTA2NzEiLAogICJcdUZCNTEiLAogICJcdTA2NzEiLAogICJcdUZCNTIiLAogICJcdTA2N0IiLAogICJcdUZCNTMiLAogICJcdTA2N0IiLAogICJcdUZCNTQiLAogICJcdTA2N0IiLAogICJcdUZCNTUiLAogICJcdTA2N0IiLAogICJcdUZCNTYiLAogICJcdTA2N0UiLAogICJcdUZCNTciLAogICJcdTA2N0UiLAogICJcdUZCNTgiLAogICJcdTA2N0UiLAogICJcdUZCNTkiLAogICJcdTA2N0UiLAogICJcdUZCNUEiLAogICJcdTA2ODAiLAogICJcdUZCNUIiLAogICJcdTA2ODAiLAogICJcdUZCNUMiLAogICJcdTA2ODAiLAogICJcdUZCNUQiLAogICJcdTA2ODAiLAogICJcdUZCNUUiLAogICJcdTA2N0EiLAogICJcdUZCNUYiLAogICJcdTA2N0EiLAogICJcdUZCNjAiLAogICJcdTA2N0EiLAogICJcdUZCNjEiLAogICJcdTA2N0EiLAogICJcdUZCNjIiLAogICJcdTA2N0YiLAogICJcdUZCNjMiLAogICJcdTA2N0YiLAogICJcdUZCNjQiLAogICJcdTA2N0YiLAogICJcdUZCNjUiLAogICJcdTA2N0YiLAogICJcdUZCNjYiLAogICJcdTA2NzkiLAogICJcdUZCNjciLAogICJcdTA2NzkiLAogICJcdUZCNjgiLAogICJcdTA2NzkiLAogICJcdUZCNjkiLAogICJcdTA2NzkiLAogICJcdUZCNkEiLAogICJcdTA2QTQiLAogICJcdUZCNkIiLAogICJcdTA2QTQiLAogICJcdUZCNkMiLAogICJcdTA2QTQiLAogICJcdUZCNkQiLAogICJcdTA2QTQiLAogICJcdUZCNkUiLAogICJcdTA2QTYiLAogICJcdUZCNkYiLAogICJcdTA2QTYiLAogICJcdUZCNzAiLAogICJcdTA2QTYiLAogICJcdUZCNzEiLAogICJcdTA2QTYiLAogICJcdUZCNzIiLAogICJcdTA2ODQiLAogICJcdUZCNzMiLAogICJcdTA2ODQiLAogICJcdUZCNzQiLAogICJcdTA2ODQiLAogICJcdUZCNzUiLAogICJcdTA2ODQiLAogICJcdUZCNzYiLAogICJcdTA2ODMiLAogICJcdUZCNzciLAogICJcdTA2ODMiLAogICJcdUZCNzgiLAogICJcdTA2ODMiLAogICJcdUZCNzkiLAogICJcdTA2ODMiLAogICJcdUZCN0EiLAogICJcdTA2ODYiLAogICJcdUZCN0IiLAogICJcdTA2ODYiLAogICJcdUZCN0MiLAogICJcdTA2ODYiLAogICJcdUZCN0QiLAogICJcdTA2ODYiLAogICJcdUZCN0UiLAogICJcdTA2ODciLAogICJcdUZCN0YiLAogICJcdTA2ODciLAogICJcdUZCODAiLAogICJcdTA2ODciLAogICJcdUZCODEiLAogICJcdTA2ODciLAogICJcdUZCODIiLAogICJcdTA2OEQiLAogICJcdUZCODMiLAogICJcdTA2OEQiLAogICJcdUZCODQiLAogICJcdTA2OEMiLAogICJcdUZCODUiLAogICJcdTA2OEMiLAogICJcdUZCODYiLAogICJcdTA2OEUiLAogICJcdUZCODciLAogICJcdTA2OEUiLAogICJcdUZCODgiLAogICJcdTA2ODgiLAogICJcdUZCODkiLAogICJcdTA2ODgiLAogICJcdUZCOEEiLAogICJcdTA2OTgiLAogICJcdUZCOEIiLAogICJcdTA2OTgiLAogICJcdUZCOEMiLAogICJcdTA2OTEiLAogICJcdUZCOEQiLAogICJcdTA2OTEiLAogICJcdUZCOEUiLAogICJcdTA2QTkiLAogICJcdUZCOEYiLAogICJcdTA2QTkiLAogICJcdUZCOTAiLAogICJcdTA2QTkiLAogICJcdUZCOTEiLAogICJcdTA2QTkiLAogICJcdUZCOTIiLAogICJcdTA2QUYiLAogICJcdUZCOTMiLAogICJcdTA2QUYiLAogICJcdUZCOTQiLAogICJcdTA2QUYiLAogICJcdUZCOTUiLAogICJcdTA2QUYiLAogICJcdUZCOTYiLAogICJcdTA2QjMiLAogICJcdUZCOTciLAogICJcdTA2QjMiLAogICJcdUZCOTgiLAogICJcdTA2QjMiLAogICJcdUZCOTkiLAogICJcdTA2QjMiLAogICJcdUZCOUEiLAogICJcdTA2QjEiLAogICJcdUZCOUIiLAogICJcdTA2QjEiLAogICJcdUZCOUMiLAogICJcdTA2QjEiLAogICJcdUZCOUQiLAogICJcdTA2QjEiLAogICJcdUZCOUUiLAogICJcdTA2QkEiLAogICJcdUZCOUYiLAogICJcdTA2QkEiLAogICJcdUZCQTAiLAogICJcdTA2QkIiLAogICJcdUZCQTEiLAogICJcdTA2QkIiLAogICJcdUZCQTIiLAogICJcdTA2QkIiLAogICJcdUZCQTMiLAogICJcdTA2QkIiLAogICJcdUZCQTQiLAogICJcdTA2QzAiLAogICJcdUZCQTUiLAogICJcdTA2QzAiLAogICJcdUZCQTYiLAogICJcdTA2QzEiLAogICJcdUZCQTciLAogICJcdTA2QzEiLAogICJcdUZCQTgiLAogICJcdTA2QzEiLAogICJcdUZCQTkiLAogICJcdTA2QzEiLAogICJcdUZCQUEiLAogICJcdTA2QkUiLAogICJcdUZCQUIiLAogICJcdTA2QkUiLAogICJcdUZCQUMiLAogICJcdTA2QkUiLAogICJcdUZCQUQiLAogICJcdTA2QkUiLAogICJcdUZCQUUiLAogICJcdTA2RDIiLAogICJcdUZCQUYiLAogICJcdTA2RDIiLAogICJcdUZCQjAiLAogICJcdTA2RDMiLAogICJcdUZCQjEiLAogICJcdTA2RDMiLAogICJcdUZCRDMiLAogICJcdTA2QUQiLAogICJcdUZCRDQiLAogICJcdTA2QUQiLAogICJcdUZCRDUiLAogICJcdTA2QUQiLAogICJcdUZCRDYiLAogICJcdTA2QUQiLAogICJcdUZCRDciLAogICJcdTA2QzciLAogICJcdUZCRDgiLAogICJcdTA2QzciLAogICJcdUZCRDkiLAogICJcdTA2QzYiLAogICJcdUZCREEiLAogICJcdTA2QzYiLAogICJcdUZCREIiLAogICJcdTA2QzgiLAogICJcdUZCREMiLAogICJcdTA2QzgiLAogICJcdUZCREQiLAogICJcdTA2NzciLAogICJcdUZCREUiLAogICJcdTA2Q0IiLAogICJcdUZCREYiLAogICJcdTA2Q0IiLAogICJcdUZCRTAiLAogICJcdTA2QzUiLAogICJcdUZCRTEiLAogICJcdTA2QzUiLAogICJcdUZCRTIiLAogICJcdTA2QzkiLAogICJcdUZCRTMiLAogICJcdTA2QzkiLAogICJcdUZCRTQiLAogICJcdTA2RDAiLAogICJcdUZCRTUiLAogICJcdTA2RDAiLAogICJcdUZCRTYiLAogICJcdTA2RDAiLAogICJcdUZCRTciLAogICJcdTA2RDAiLAogICJcdUZCRTgiLAogICJcdTA2NDkiLAogICJcdUZCRTkiLAogICJcdTA2NDkiLAogICJcdUZCRUEiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUIiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUMiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUQiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUUiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRUYiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRjAiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjEiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjIiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjMiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjQiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjUiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjYiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjciLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjgiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjkiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkEiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkIiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkMiLAogICJcdTA2Q0MiLAogICJcdUZCRkQiLAogICJcdTA2Q0MiLAogICJcdUZCRkUiLAogICJcdTA2Q0MiLAogICJcdUZCRkYiLAogICJcdTA2Q0MiLAogICJcdUZDMDAiLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDMDEiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDMDIiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDMDMiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDMDQiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDMDUiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDMDYiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDMDciLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDMDgiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDMDkiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDMEEiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDMEIiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDMEMiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDMEQiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDMEUiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDMEYiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDMTAiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDMTEiLAogICJcdTA2MkJcdTA2MkMiLAogICJcdUZDMTIiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDMTMiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDMTQiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDMTUiLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDMTYiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDMTciLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDMTgiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDMTkiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDMUEiLAogICJcdTA2MkVcdTA2MkQiLAogICJcdUZDMUIiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDMUMiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDMUQiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDMUUiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDMUYiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDMjAiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDMjEiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDMjIiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDMjMiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDMjQiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDMjUiLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDMjYiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDMjciLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZDMjgiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDMjkiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDMkEiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDMkIiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDMkMiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDMkQiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDMkUiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDMkYiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDMzAiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDMzEiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDMzIiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDMzMiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDMzQiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDMzUiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDMzYiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDMzciLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDMzgiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDMzkiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDM0EiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDM0IiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDM0MiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDM0QiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDM0UiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDM0YiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDNDAiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDNDEiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDNDIiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDNDMiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDNDQiLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDNDUiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDNDYiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDNDciLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDNDgiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDNDkiLAogICJcdTA2NDVcdTA2NDkiLAogICJcdUZDNEEiLAogICJcdTA2NDVcdTA2NEEiLAogICJcdUZDNEIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDNEMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDNEQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDNEUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDNEYiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDNTAiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDNTEiLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDNTIiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDNTMiLAogICJcdTA2NDdcdTA2NDkiLAogICJcdUZDNTQiLAogICJcdTA2NDdcdTA2NEEiLAogICJcdUZDNTUiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDNTYiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDNTciLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDNTgiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDNTkiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDNUEiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDNUIiLAogICJcdTA2MzBcdTA2NzAiLAogICJcdUZDNUMiLAogICJcdTA2MzFcdTA2NzAiLAogICJcdUZDNUQiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDNUUiLAogICJcdTAwMjBcdTA2NENcdTA2NTEiLAogICJcdUZDNUYiLAogICJcdTAwMjBcdTA2NERcdTA2NTEiLAogICJcdUZDNjAiLAogICJcdTAwMjBcdTA2NEVcdTA2NTEiLAogICJcdUZDNjEiLAogICJcdTAwMjBcdTA2NEZcdTA2NTEiLAogICJcdUZDNjIiLAogICJcdTAwMjBcdTA2NTBcdTA2NTEiLAogICJcdUZDNjMiLAogICJcdTAwMjBcdTA2NTFcdTA2NzAiLAogICJcdUZDNjQiLAogICJcdTA2MjZcdTA2MzEiLAogICJcdUZDNjUiLAogICJcdTA2MjZcdTA2MzIiLAogICJcdUZDNjYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDNjciLAogICJcdTA2MjZcdTA2NDYiLAogICJcdUZDNjgiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDNjkiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDNkEiLAogICJcdTA2MjhcdTA2MzEiLAogICJcdUZDNkIiLAogICJcdTA2MjhcdTA2MzIiLAogICJcdUZDNkMiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDNkQiLAogICJcdTA2MjhcdTA2NDYiLAogICJcdUZDNkUiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDNkYiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDNzAiLAogICJcdTA2MkFcdTA2MzEiLAogICJcdUZDNzEiLAogICJcdTA2MkFcdTA2MzIiLAogICJcdUZDNzIiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDNzMiLAogICJcdTA2MkFcdTA2NDYiLAogICJcdUZDNzQiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDNzUiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDNzYiLAogICJcdTA2MkJcdTA2MzEiLAogICJcdUZDNzciLAogICJcdTA2MkJcdTA2MzIiLAogICJcdUZDNzgiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDNzkiLAogICJcdTA2MkJcdTA2NDYiLAogICJcdUZDN0EiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDN0IiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDN0MiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDN0QiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDN0UiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDN0YiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDODAiLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDODEiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDODIiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDODMiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDODQiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDODUiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDODYiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDODciLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDODgiLAogICJcdTA2NDVcdTA2MjciLAogICJcdUZDODkiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDOEEiLAogICJcdTA2NDZcdTA2MzEiLAogICJcdUZDOEIiLAogICJcdTA2NDZcdTA2MzIiLAogICJcdUZDOEMiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDOEQiLAogICJcdTA2NDZcdTA2NDYiLAogICJcdUZDOEUiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDOEYiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDOTAiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDOTEiLAogICJcdTA2NEFcdTA2MzEiLAogICJcdUZDOTIiLAogICJcdTA2NEFcdTA2MzIiLAogICJcdUZDOTMiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDOTQiLAogICJcdTA2NEFcdTA2NDYiLAogICJcdUZDOTUiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDOTYiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDOTciLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDOTgiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDOTkiLAogICJcdTA2MjZcdTA2MkUiLAogICJcdUZDOUEiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDOUIiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDOUMiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDOUQiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDOUUiLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDOUYiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDQTAiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDQTEiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDQTIiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDQTMiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDQTQiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDQTUiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDQTYiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDQTciLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDQTgiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDQTkiLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDQUEiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDQUIiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDQUMiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDQUQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDQUUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDQUYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDQjAiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDQjEiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDQjIiLAogICJcdTA2MzVcdTA2MkUiLAogICJcdUZDQjMiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDQjQiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDQjUiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDQjYiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDQjciLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDQjgiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDQjkiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDQkEiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDQkIiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDQkMiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDQkQiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDQkUiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDQkYiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDQzAiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDQzEiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDQzIiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDQzMiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDQzQiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDQzUiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDQzYiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDQzciLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDQzgiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDQzkiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDQ0EiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDQ0IiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDQ0MiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDQ0QiLAogICJcdTA2NDRcdTA2NDciLAogICJcdUZDQ0UiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDQ0YiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDRDAiLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDRDEiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDRDIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDRDMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDRDQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDRDUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRDYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRDciLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDRDgiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDRDkiLAogICJcdTA2NDdcdTA2NzAiLAogICJcdUZDREEiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDREIiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDREMiLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDREQiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDREUiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDREYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDRTAiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDRTEiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDRTIiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDRTMiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDRTQiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDRTUiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDRTYiLAogICJcdTA2MkJcdTA2NDciLAogICJcdUZDRTciLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDRTgiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZDRTkiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZDRUEiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZDRUIiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDRUMiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDRUQiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDRUUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRUYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRjAiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDRjEiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDRjIiLAogICJcdTA2NDBcdTA2NEVcdTA2NTEiLAogICJcdUZDRjMiLAogICJcdTA2NDBcdTA2NEZcdTA2NTEiLAogICJcdUZDRjQiLAogICJcdTA2NDBcdTA2NTBcdTA2NTEiLAogICJcdUZDRjUiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZDRjYiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZDRjciLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZDRjgiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZDRjkiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZDRkEiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZDRkIiLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZDRkMiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZDRkQiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZDRkUiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZDRkYiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMDAiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMDEiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMDIiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMDMiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMDQiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMDUiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMDYiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMDciLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMDgiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMDkiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMEEiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMEIiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMEMiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMEQiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMEUiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMEYiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMTAiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMTEiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZEMTIiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZEMTMiLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZEMTQiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZEMTUiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZEMTYiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZEMTciLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZEMTgiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZEMTkiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZEMUEiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZEMUIiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMUMiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMUQiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMUUiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMUYiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMjAiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMjEiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMjIiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMjMiLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMjQiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMjUiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMjYiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMjciLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMjgiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMjkiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMkEiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMkIiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMkMiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMkQiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMkUiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMkYiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMzAiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMzEiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZEMzIiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZEMzMiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEMzQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZEMzUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZEMzYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZEMzciLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMzgiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMzkiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEM0EiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEM0IiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZEM0MiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZEM0QiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZENTAiLAogICJcdTA2MkFcdTA2MkNcdTA2NDUiLAogICJcdUZENTEiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTIiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTMiLAogICJcdTA2MkFcdTA2MkRcdTA2NDUiLAogICJcdUZENTQiLAogICJcdTA2MkFcdTA2MkVcdTA2NDUiLAogICJcdUZENTUiLAogICJcdTA2MkFcdTA2NDVcdTA2MkMiLAogICJcdUZENTYiLAogICJcdTA2MkFcdTA2NDVcdTA2MkQiLAogICJcdUZENTciLAogICJcdTA2MkFcdTA2NDVcdTA2MkUiLAogICJcdUZENTgiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENTkiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENUEiLAogICJcdTA2MkRcdTA2NDVcdTA2NEEiLAogICJcdUZENUIiLAogICJcdTA2MkRcdTA2NDVcdTA2NDkiLAogICJcdUZENUMiLAogICJcdTA2MzNcdTA2MkRcdTA2MkMiLAogICJcdUZENUQiLAogICJcdTA2MzNcdTA2MkNcdTA2MkQiLAogICJcdUZENUUiLAogICJcdTA2MzNcdTA2MkNcdTA2NDkiLAogICJcdUZENUYiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjAiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjEiLAogICJcdTA2MzNcdTA2NDVcdTA2MkMiLAogICJcdUZENjIiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjMiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjQiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjUiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjYiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZENjciLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjgiLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjkiLAogICJcdTA2MzRcdTA2MkNcdTA2NEEiLAogICJcdUZENkEiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkIiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkMiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkQiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkUiLAogICJcdTA2MzZcdTA2MkRcdTA2NDkiLAogICJcdUZENkYiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzAiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzEiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzIiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzMiLAogICJcdTA2MzdcdTA2NDVcdTA2NDUiLAogICJcdUZENzQiLAogICJcdTA2MzdcdTA2NDVcdTA2NEEiLAogICJcdUZENzUiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZENzYiLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzciLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzgiLAogICJcdTA2MzlcdTA2NDVcdTA2NDkiLAogICJcdUZENzkiLAogICJcdTA2M0FcdTA2NDVcdTA2NDUiLAogICJcdUZEN0EiLAogICJcdTA2M0FcdTA2NDVcdTA2NEEiLAogICJcdUZEN0IiLAogICJcdTA2M0FcdTA2NDVcdTA2NDkiLAogICJcdUZEN0MiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0QiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0UiLAogICJcdTA2NDJcdTA2NDVcdTA2MkQiLAogICJcdUZEN0YiLAogICJcdTA2NDJcdTA2NDVcdTA2NDUiLAogICJcdUZEODAiLAogICJcdTA2NDRcdTA2MkRcdTA2NDUiLAogICJcdUZEODEiLAogICJcdTA2NDRcdTA2MkRcdTA2NEEiLAogICJcdUZEODIiLAogICJcdTA2NDRcdTA2MkRcdTA2NDkiLAogICJcdUZEODMiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODQiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODUiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODYiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODciLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODgiLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODkiLAogICJcdTA2NDVcdTA2MkRcdTA2MkMiLAogICJcdUZEOEEiLAogICJcdTA2NDVcdTA2MkRcdTA2NDUiLAogICJcdUZEOEIiLAogICJcdTA2NDVcdTA2MkRcdTA2NEEiLAogICJcdUZEOEMiLAogICJcdTA2NDVcdTA2MkNcdTA2MkQiLAogICJcdUZEOEQiLAogICJcdTA2NDVcdTA2MkNcdTA2NDUiLAogICJcd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RcdTA2NEEiLAogICJcdUZEQkYiLAogICJcdTA2MkRcdTA2MkNcdTA2NEEiLAogICJcdUZEQzAiLAogICJcdTA2NDVcdTA2MkNcdTA2NEEiLAogICJcdUZEQzEiLAogICJcdTA2NDFcdTA2NDVcdTA2NEEiLAogICJcdUZEQzIiLAogICJcdTA2MjhcdTA2MkRcdTA2NEEiLAogICJcdUZEQzMiLAogICJcdTA2NDNcdTA2NDVcdTA2NDUiLAogICJcdUZEQzQiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZEQzUiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZEQzYiLAogICJcdTA2MzNcdTA2MkVcdTA2NEEiLAogICJcdUZEQzciLAogICJcdTA2NDZcdTA2MkNcdTA2NEEiLAogICJcdUZFNDkiLAogICJcdTIwM0UiLAogICJcdUZFNEEiLAogICJcdTIwM0UiLAogICJcdUZFNEIiLAogICJcdTIwM0UiLAogICJcdUZFNEMiLAogICJcdTIwM0UiLAogICJcdUZFNEQiLAogICJcdTAwNUYiLAogICJcdUZFNEUiLAogICJcdTAwNUYiLAogICJcdUZFNEYiLAogICJcdTAwNUYiLAogICJcdUZFODAiLAogICJcdTA2MjEiLAogICJcdUZFODEiLAogICJcdTA2MjIiLAogICJcdUZFODIiLAogICJcdTA2MjIiLAogICJcdUZFODMiLAogICJcdTA2MjMiLAogICJcdUZFODQiLAogICJcdTA2MjMiLAogICJcdUZFODUiLAogICJcdTA2MjQiLAogICJcdUZFODYiLAogICJcdTA2MjQiLAogICJcdUZFODciLAogICJcdTA2MjUiLAogICJcdUZFODgiLAogICJcdTA2MjUiLAogICJcdUZFODkiLAogICJcdTA2MjYiLAogICJcdUZFOEEiLAogICJcdTA2MjYiLAogICJcdUZFOEIiLAogICJcdTA2MjYiLAogICJcdUZFOEMiLAogICJcdTA2MjYiLAogICJcdUZFOEQiLAogICJcdTA2MjciLAogICJcdUZFOEUiLAogICJcdTA2MjciLAogICJcdUZFOEYiLAogICJcdTA2MjgiLAogICJcdUZFOTAiLAogICJcdTA2MjgiLAogICJcdUZFOTEiLAogICJcdTA2MjgiLAogICJcdUZFOTIiLAogICJcdTA2MjgiLAogICJcdUZFOTMiLAogICJcdTA2MjkiLAogICJcdUZFOTQiLAogICJcdTA2MjkiLAogICJcdUZFOTUiLAogICJcdTA2MkEiLAogICJcdUZFOTYiLAogICJcdTA2MkEiLAogICJcdUZFOTciLAogICJcdTA2MkEiLAogICJcdUZFOTgiLAogICJcdTA2MkEiLAogICJcdUZFOTkiLAogICJcdTA2MkIiLAogICJcdUZFOUEiLAogICJcdTA2MkIiLAogICJcdUZFOUIiLAogICJcdTA2MkIiLAogICJcdUZFOUMiLAogICJcdTA2MkIiLAogICJcdUZFOUQiLAogICJcdTA2MkMiLAogICJcdUZFOUUiLAogICJcdTA2MkMiLAogICJcdUZFOUYiLAogICJcdTA2MkMiLAogICJcdUZFQTAiLAogICJcdTA2MkMiLAogICJcdUZFQTEiLAogICJcdTA2MkQiLAogICJcdUZFQTIiLAogICJcdTA2MkQiLAogICJcdUZFQTMiLAogICJcdTA2MkQiLAogICJcdUZFQTQiLAogICJcdTA2MkQiLAogICJcdUZFQTUiLAogICJcdTA2MkUiLAogICJcdUZFQTYiLAogICJcdTA2MkUiLAogICJcdUZFQTciLAogICJcdTA2MkUiLAogICJcdUZFQTgiLAogICJcdTA2MkUiLAogICJcdUZFQTkiLAogICJcdTA2MkYiLAogICJcdUZFQUEiLAogICJcdTA2MkYiLAogICJcdUZFQUIiLAogICJcdTA2MzAiLAogICJcdUZFQUMiLAogICJcdTA2MzAiLAogICJcdUZFQUQiLAogICJcdTA2MzEiLAogICJcdUZFQUUiLAogICJcdTA2MzEiLAogICJcdUZFQUYiLAogICJcdTA2MzIiLAogICJcdUZFQjAiLAogICJcdTA2MzIiLAogICJcdUZFQjEiLAogICJcdTA2MzMiLAogICJcdUZFQjIiLAogICJcdTA2MzMiLAogICJcdUZFQjMiLAogICJcdTA2MzMiLAogICJcdUZFQjQiLAogICJcdTA2MzMiLAogICJcdUZFQjUiLAogICJcdTA2MzQiLAogICJcdUZFQjYiLAogICJcdTA2MzQiLAogICJcdUZFQjciLAogICJcdTA2MzQiLAogICJcdUZFQjgiLAogICJcdTA2MzQiLAogICJcdUZFQjkiLAogICJcdTA2MzUiLAogICJcdUZFQkEiLAogICJcdTA2MzUiLAogICJcdUZFQkIiLAogICJcdTA2MzUiLAogICJcdUZFQkMiLAogICJcdTA2MzUiLAogICJcdUZFQkQiLAogICJcdTA2MzYiLAogICJcdUZFQkUiLAogICJcdTA2MzYiLAogICJcdUZFQkYiLAogICJcdTA2MzYiLAogICJcdUZFQzAiLAogICJcdTA2MzYiLAogICJcdUZFQzEiLAogICJcdTA2MzciLAogICJcdUZFQzIiLAogICJcdTA2MzciLAogICJcdUZFQzMiLAogICJcdTA2MzciLAogICJcdUZFQzQiLAogICJcdTA2MzciLAogICJcdUZFQzUiLAogICJcdTA2MzgiLAogICJcdUZFQzYiLAogICJcdTA2MzgiLAogICJcdUZFQzciLAogICJcdTA2MzgiLAogICJcdUZFQzgiLAogICJcdTA2MzgiLAogICJcdUZFQzkiLAogICJcdTA2MzkiLAogICJcdUZFQ0EiLAogICJcdTA2MzkiLAogICJcdUZFQ0IiLAogICJcdTA2MzkiLAogICJcdUZFQ0MiLAogICJcdTA2MzkiLAogICJcdUZFQ0QiLAogICJcdTA2M0EiLAogICJcdUZFQ0UiLAogICJcdTA2M0EiLAogICJcdUZFQ0YiLAogICJcdTA2M0EiLAogICJcdUZFRDAiLAogICJcdTA2M0EiLAogICJcdUZFRDEiLAogICJcdTA2NDEiLAogICJcdUZFRDIiLAogICJcdTA2NDEiLAogICJcdUZFRDMiLAogICJcdTA2NDEiLAogICJcdUZFRDQiLAogICJcdTA2NDEiLAogICJcdUZFRDUiLAogICJcdTA2NDIiLAogICJcdUZFRDYiLAogICJcdTA2NDIiLAogICJcdUZFRDciLAogICJcdTA2NDIiLAogICJcdUZFRDgiLAogICJcdTA2NDIiLAogICJcdUZFRDkiLAogICJcdTA2NDMiLAogICJcdUZFREEiLAogICJcdTA2NDMiLAogICJcdUZFREIiLAogICJcdTA2NDMiLAogICJcdUZFREMiLAogICJcdTA2NDMiLAogICJcdUZFREQiLAogICJcdTA2NDQiLAogICJcdUZFREUiLAogICJcdTA2NDQiLAogICJcdUZFREYiLAogICJcdTA2NDQiLAogICJcdUZFRTAiLAogICJcdTA2NDQiLAogICJcdUZFRTEiLAogICJcdTA2NDUiLAogICJcdUZFRTIiLAogICJcdTA2NDUiLAogICJcdUZFRTMiLAogICJcdTA2NDUiLAogICJcdUZFRTQiLAogICJcdTA2NDUiLAogICJcdUZFRTUiLAogICJcdTA2NDYiLAogICJcdUZFRTYiLAogICJcdTA2NDYiLAogICJcdUZFRTciLAogICJcdTA2NDYiLAogICJcdUZFRTgiLAogICJcdTA2NDYiLAogICJcdUZFRTkiLAogICJcdTA2NDciLAogICJcdUZFRUEiLAogICJcdTA2NDciLAogICJcdUZFRUIiLAogICJcdTA2NDciLAogICJcdUZFRUMiLAogICJcdTA2NDciLAogICJcdUZFRUQiLAogICJcdTA2NDgiLAogICJcdUZFRUUiLAogICJcdTA2NDgiLAogICJcdUZFRUYiLAogICJcdTA2NDkiLAogICJcdUZFRjAiLAogICJcdTA2NDkiLAogICJcdUZFRjEiLAogICJcdTA2NEEiLAogICJcdUZFRjIiLAogICJcdTA2NEEiLAogICJcdUZFRjMiLAogICJcdTA2NEEiLAogICJcdUZFRjQiLAogICJcdTA2NEEiLAogICJcdUZFRjUiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjYiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjciLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjgiLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjkiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkEiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkIiLAogICJcdTA2NDRcdTA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KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgY2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgY2hhckNvZGU7CiAgICAgIGlmIChjZmYuaXNDSURGb250KSB7CiAgICAgICAgZm9yIChnbHlwaElkID0gMDsgZ2x5cGhJZCA8IGNoYXJzZXRzLmxlbmd0aDsgZ2x5cGhJZCsrKSB7CiAgICAgICAgICBjb25zdCBjaWQgPSBjaGFyc2V0c1tnbHlwaElkXTsKICAgICAgICAgIGNoYXJDb2RlID0gY01hcC5jaGFyQ29kZU9mKGNpZCk7CiAgICAgICAgICBpZiAoaW52Q2lkVG9HaWRNYXAgJiYgaW52Q2lkVG9HaWRNYXBbY2hhckNvZGVdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgY2hhckNvZGUgPSBpbnZDaWRUb0dpZE1hcFtjaGFyQ29kZV07CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBmb3IgKGdseXBoSWQgPSAwOyBnbHlwaElkIDwgY2ZmLmNoYXJTdHJpbmdzLmNvdW50OyBnbHlwaElkKyspIHsKICAgICAgICAgIGNoYXJDb2RlID0gY01hcC5jaGFyQ29kZU9mKGdseXBoSWQpOwogICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIGNoYXJDb2RlVG9HbHlwaElkOwogICAgfQogICAgbGV0IGVuY29kaW5nID0gY2ZmLmVuY29kaW5nID8gY2ZmLmVuY29kaW5nLmVuY29kaW5nIDogbnVsbDsKICAgIGlmIChwcm9wZXJ0aWVzLmlzSW50ZXJuYWxGb250KSB7CiAgICAgIGVuY29kaW5nID0gcHJvcGVydGllcy5kZWZhdWx0RW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gICAgcmFuZ2VzW2ldLnN0YXJ0ID0gZ2V0VWludDE2KGRhdGEsIHApOwogICAgfQogICAgZm9yIChpID0gMDsgaSA8IHNlZ0NvdW50OyBpKyssIHAgKz0gMikgewogICAgICByYW5nZXNbaV0uaWREZWx0YSA9IGdldFVpbnQxNihkYXRhLCBwKTsKICAgIH0KICAgIGZvciAoaSA9IDA7IGkgPCBzZWdDb3VudDsgaSsrLCBwICs9IDIpIHsKICAgICAgbGV0IGlkT2Zmc2V0ID0gZ2V0VWludDE2KGRhdGEsIHApOwogICAgICBpZiAoaWRPZmZzZXQgPT09IDApIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByYW5nZXNbaV0uaWRzID0gW107CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHJhbmdlc1tpXS5lbmQgLSByYW5nZXNbaV0uc3RhcnQgKyAxOyBqIDwgamo7IGorKykgewogICAgICAgIHJhbmdlc1tpXS5pZHNbal0gPSBnZXRVaW50MTYoZGF0YSwgcCArIGlkT2Zmc2V0KTsKICAgICAgICBpZE9mZnNldCArPSAyOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcmFuZ2VzOwogIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgY29uc3QgZ3JvdXBzID0gZ2V0VWludDMyKGRhdGEsIHN0YXJ0ICsgb2Zmc2V0ICsgMTIpOwogICAgcCA9IHN0YXJ0ICsgb2Zmc2V0ICsgMTY7CiAgICByYW5nZXMgPSBbXTsKICAgIGZvciAoaSA9IDA7IGkgPCBncm91cHM7IGkrKykgewogICAgICBzdGFydCA9IGdldFVpbnQzMihkYXRhLCBwKTsKICAgICAgcmFuZ2VzLnB1c2goewogICAgICAgIHN0YXJ0LAogICAgICAgIGVuZDogZ2V0VWludDMyKGRhdGEsIHAgKyA0KSwKICAgICAgICBpZERlbHRhOiBnZXRVaW50MzIoZGF0YSwgcCArIDgpIC0gc3RhcnQKICAgICAgfSk7CiAgICAgIHAgKz0gMT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hcmcxID0gZ2V0VWludDE2KGNvZGUsIGkpOwogICAgICAgICAgYXJnMiA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgICAgfQogICAgICAgIGkgKz0gNDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50OChjb2RlLCBpKyspOwogICAgICAgICAgYXJnMiA9IGdldEludDgoY29kZSwgaSsrKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYXJnMSA9IGNvZGVbaSsrXTsKICAgICAgICAgIGFyZzIgPSBjb2RlW2krK107CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChmbGFncyAmIDB4MDIpIHsKICAgICAgICB4ID0gYXJnMTsKICAgICAgICB5ID0gYXJnMjsKICAgICAgfSBlbHNlIHsKICAgICAgICB4ID0gMDsKICAgICAgICB5ID0gMDsKICAgICAgfQogICAgICBsZXQgc2NhbGVYID0gMSwKICAgICAgICBzY2FsZVkgPSAxLAogICAgICAgIHNjYWxlMDEgPSAwLAogICAgICAgIHNjYWxlMTAgPSAwOwogICAgICBpZiAoZmxhZ3MgJiAweDA4KSB7CiAgICAgICAgc2NhbGVYID0gc2NhbGVZID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgaSArPSAyOwogICAgICB9IGVsc2UgaWYgKGZsYWdzICYgMHg0MCkgewogICAgICAgIHNjYWxlWCA9IGdldEZsb2F0MjE0KGNvZGUsIGkpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0gZWxzZSBpZiAoZmxhZ3MgJiAweDgwKSB7CiAgICAgICAgc2NhbGVYID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgc2NhbGUwMSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBzY2FsZTEwID0gZ2V0RmxvYXQyMTQoY29kZSwgaSArIDQpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyA2KTsKICAgICAgICBpICs9IDg7CiAgICAgIH0KICAgICAgY29uc3Qgc3ViZ2x5cGggPSBmb250LmdseXBoc1tnbHlwaEluZGV4XTsKICAgICAgaWYgKHN1YmdseXBoKSB7CiAgICAgICAgY21kcy5wdXNoKHsKICAgICAgICAgIGNtZDogInNhdmUiCiAgICAgICAgfSwgewogICAgICAgICAgY21kOiAidHJhbnNmb3JtIiwKICAgICAgICAgIGFyZ3M6IFtzY2FsZVgsIHNjYWxlMDEsIHNjYWxlMTAsIHNjYWxlWSwgeCwgeV0KICAgICAgICB9KTsKICAgICAgICBpZiAoIShmbGFncyAmIDB4MDIpKSB7fQogICAgICAgIGNvbXBpbGVHbHlmKHN1YmdseXBoLCBjbWRzLCBmb250KTsKICAgICAgICBjbWRzLnB1c2goewogICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICB9KTsKICAgICAgfQogICAgfSB3aGlsZSAoZmxhZ3MgJiAweDIwKTsKICB9IGVsc2UgewogICAgY29uc3QgZW5kUHRzT2ZDb250b3VycyA9IFtdOwogICAgbGV0IGosIGpqOwogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mQ29udG91cnM7IGorKykgewogICAgICBlbmRQdHNPZkNvbnRvdXJzLnB1c2goZ2V0VWludDE2KGNvZGUsIGkpKTsKICAgICAgaSArPSAyOwogICAgfQogICAgY29uc3QgaW5zdHJ1Y3Rpb25MZW5ndGggPSBnZXRVaW50MTYoY29kZSwgaSk7CiAgICBpICs9IDIgKyBpbnN0cnVjdGlvbkxlbmd0aDsKICAgIGNvbnN0IG51bWJlck9mUG9pbnRzID0gZW5kUHRzT2ZDb250b3Vycy5hdCgtMSkgKyAxOwogICAgY29uc3QgcG9pbnRzID0gW107CiAgICB3aGlsZSAocG9pbnRzLmxlbmd0aCA8IG51bWJlck9mUG9pbnRzKSB7CiAgICAgIGZsYWdzID0gY29kZVtpKytdOwogICAgICBsZXQgcmVwZWF0ID0gMTsKICAgICAgaWYgKGZsYWdzICYgMHgwOCkgewogICAgICAgIHJlcGVhdCArPSBjb2RlW2krK107CiAgICAgIH0KICAgICAgd2hpbGUgKHJlcGVhdC0tID4gMCkgewogICAgICAgIHBvaW50cy5wdXNoKHsKICAgICAgICAgIGZsYWdzCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIGZvciAoaiA9IDA7IGogPCBudW1iZXJPZlBvaW50czsgaisrKSB7CiAgICAgIHN3aXRjaCAocG9pbnRzW2pdLmZsYWdzICYgMHgxMikgewogICAgICAgIGNhc2UgMHgwMDoKICAgICAgICAgIHggKz0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBpICs9IDI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDI6CiAgICAgICAgICB4IC09IGNvZGVbaSsrXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgxMjoKICAgICAgICAgIHggKz0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgcG9pbnRzW2pdLnggPSB4OwogICAgfQogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mUG9pbnRzOyBqKyspIHsKICAgICAgc3dpdGNoIChwb2ludHNbal0uZmxhZ3MgJiAweDI0KSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgeSArPSBnZXRJbnQxNihjb2RlLCBpKTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgwNDoKICAgICAgICAgIHkgLT0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI0OgogICAgICAgICAgeSArPSBjb2RlW2krK107CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwb2ludHNbal0ueSA9IHk7CiAgICB9CiAgICBsZXQgc3RhcnRQb2ludCA9IDA7CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtYmVyT2ZDb250b3VyczsgaSsrKSB7CiAgICAgIGNvbnN0IGVuZFBvaW50ID0gZW5kUHRzT2ZDb250b3Vyc1tpXTsKICAgICAgY29uc3QgY29udG91ciA9IHBvaW50cy5zbGljZShzdGFydFBvaW50LCBlbmRQb2ludCArIDEpOwogICAgICBpZiAoY29udG91clswXS5mbGFncyAmIDEpIHsKICAgICAgICBjb250b3VyLnB1c2goY29udG91clswXSk7CiAgICAgIH0gZWxzZSBpZiAoY29udG91ci5hdCgtMSkuZmxhZ3MgJiAxKSB7CiAgICAgICAgY29udG91ci51bnNoaWZ0KGNvbnRvdXIuYXQoLTEpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBwID0gewogICAgICAgICAgZmxhZ3M6IDEsCiAgICAgICAgICB4OiAoY29udG91clswXS54ICsgY29udG91ci5hdCgtMSkueCkgLyAyLAogICAgICAgICAgeTogKGNvbnRvdXJbMF0ueSArIGNvbnRvdXIuYXQoLTEpLnkpIC8gMgogICAgICAgIH07CiAgICAgICAgY29udG91ci51bnNoaWZ0KHApOwogICAgICAgIGNvbnRvdXIucHVzaChwKTsKICAgICAgfQogICAgICBtb3ZlVG8oY29udG91clswXS54LCBjb250b3VyWzBdLnkpOwogICAgICBmb3IgKGogPSAxLCBqaiA9IGNvbnRvdXIubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgIGlmIChjb250b3VyW2pdLmZsYWdzICYgMSkgewogICAgICAgICAgbGluZVRvKGNvbnRvdXJbal0ueCwgY29udG91cltqXS55KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbnRvdXJbaiArIDFdLmZsYWdzICYgMSkgewogICAgICAgICAgcXVhZHJhdGljQ3VydmVUbyhjb250b3VyW2pdLngsIGNvbnRvdXJbal0ueSwgY29udG91cltqICsgMV0ueCwgY29udG91cltqICsgMV0ueSk7CiAgICAgICAgICBqKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHF1YWRyYXRpY0N1cnZlVG8oY29udG91cltqXS54LCBjb250b3VyW2pdLnksIChjb250b3VyW2pdLnggKyBjb250b3VyW2ogKyAxXS54KSAvIDIsIChjb250b3VyW2pdLnkgKyBjb250b3VyW2ogKyAxXS55KSAvIDIpOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGFydFBvaW50ID0gZW5kUG9pbnQgKyAxOwogICAgfQogIH0KfQpmdW5jdGlvbiBjb21waWxlQ2hhclN0cmluZyhjaGFyU3RyaW5nQ29kZSwgY21kcywgZm9udCwgZ2x5cGhJZCkgewogIGZ1bmN0aW9uIG1vdmVUbyh4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJtb3ZlVG8iLAogICAgICBhcmdzOiBbeCwgeV0KICAgIH0pOwogIH0KICBmdW5jdGlvbiBsaW5lVG8oeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAibGluZVRvIiwKICAgICAgYXJnczogW3gsIHldCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gYmV6aWVyQ3VydmVUbyh4MSwgeTEsIHgyLCB5MiwgeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAiYmV6aWVyQ3VydmVUbyIsCiAgICAgIGFyZ3M6IFt4MSwgeTEsIHgyLCB5MiwgeCwgeV0KICAgIH0pOwogIH0KICBjb25zdCBzdGFjayA9IFtdOwogIGxldCB4ID0gMCwKICAgIHkgPSAwOwogIGxldCBzdGVtcyA9IDA7CiAgZnVuY3Rpb24gcGFyc2UoY29kZSkgewogICAgbGV0IGkgPSAwOwogICAgd2hpbGUgKGkgPCBjb2RlLmxlbmd0aCkgewogICAgICBsZXQgc3RhY2tDbGVhbiA9IGZhbHNlOwogICAgICBsZXQgdiA9IGNvZGVbaSsrXTsKICAgICAgbGV0IHhhLCB4YiwgeWEsIHliLCB5MSwgeTIsIHkzLCBuLCBzdWJyQ29kZTsKICAgICAgc3dpdGNoICh2KSB7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgc3RlbXMgKz0gc3RhY2subGVuZ3RoID4+IDE7CiAgICAgICAgICBzdGFja0NsZWFuID0gdHJ1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDQ6CiAgICAgICAgICB5ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA2OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNzoKICAgICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDg6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxMDoKICAgICAgICAgIG4gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN1YnJDb2RlID0gbnVsbDsKICAgICAgICAgIGlmIChmb250LmlzQ0ZGQ0lERm9udCkgewogICAgICAgICAgICBjb25zdCBmZEluZGV4ID0gZm9udC5mZFNlbGVjdC5nZXRGREluZGV4KGdseXBoSWQpOwogICAgICAgICAgICBpZiAoZmRJbmRleCA+PSAwICYmIGZkSW5kZXggPCBmb250LmZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgY29uc3QgZm9udERpY3QgPSBmb250LmZkQXJyYXlbZmRJbmRleF07CiAgICAgICAgICAgICAgbGV0IHN1YnJzOwogICAgICAgICAgICAgIGlmIChmb250RGljdC5wcml2YXRlRGljdCAmJiBmb250RGljdC5wcml2YXRlRGljdC5zdWJyc0luZGV4KSB7CiAgICAgICAgICAgICAgICBzdWJycyA9IGZvbnREaWN0LnByaXZhdGVEaWN0LnN1YnJzSW5kZXgub2JqZWN0czsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHN1YnJzKSB7CiAgICAgICAgICAgICAgICBuICs9IGdldFN1YnJvdXRpbmVCaWFzKHN1YnJzKTsKICAgICAgICAgICAgICAgIHN1YnJDb2RlID0gc3VicnNbbl07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSW52YWxpZCBmZCBpbmRleCBmb3IgZ2x5cGggaW5kZXguIik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN1YnJDb2RlID0gZm9udC5zdWJyc1tuICsgZm9udC5zdWJyc0JpYXNdOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTE6CiAgICAgICAgICByZXR1cm47CiAgICAgICAgY2FzZSAxMjoKICAgICAgICAgIHYgPSBjb2RlW2krK107CiAgICAgICAgICBzd2l0Y2ggKHYpIHsKICAgICAgICAgICAgY2FzZSAzNDoKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkxID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5LCB4YiwgeTEsIHgsIHkxKTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5LCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNToKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMzY6CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5MSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkyID0geTEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5MiwgeCwgeTIpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeTMgPSB5MiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5MiwgeGIsIHkzLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNzoKICAgICAgICAgICAgICBjb25zdCB4MCA9IHgsCiAgICAgICAgICAgICAgICB5MCA9IHk7CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICAgIHkgPSB5YjsKICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoeCAtIHgwKSA+IE1hdGguYWJzKHkgLSB5MCkpIHsKICAgICAgICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgeSArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYHVua25vd24gb3BlcmF0b3I6IDEyICR7dn1gKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTQ6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID49IDQpIHsKICAgICAgICAgICAgY29uc3QgYWNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgYmNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgeSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICB4ID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAic2F2ZSIKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgIGNtZDogInRyYW5zbGF0ZSIsCiAgICAgICAgICAgICAgYXJnczogW3gsIHldCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBsZXQgY21hcCA9IGxvb2t1cENtYXAoZm9udC5jbWFwLCBTdHJpbmcuZnJvbUNoYXJDb2RlKGZvbnQuZ2x5cGhOYW1lTWFwW19lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZ1thY2hhcl1dKSk7CiAgICAgICAgICAgIGNvbXBpbGVDaGFyU3RyaW5nKGZvbnQuZ2x5cGhzW2NtYXAuZ2x5cGhJZF0sIGNtZHMsIGZvbnQsIGNtYXAuZ2x5cGhJZCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGNtYXAgPSBsb29rdXBDbWFwKGZvbnQuY21hcCwgU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdseXBoTmFtZU1hcFtfZW5jb2RpbmdzLlN0YW5kYXJkRW5jb2RpbmdbYmNoYXJdXSkpOwogICAgICAgICAgICBjb21waWxlQ2hhclN0cmluZyhmb250LmdseXBoc1tjbWFwLmdseXBoSWRdLCBjbWRzLCBmb250LCBjbWFwLmdseXBoSWQpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIGNhc2UgMTg6CiAgICAgICAgICBzdGVtcyArPSBzdGFjay5sZW5ndGggPj4gMTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOToKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMDoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMToKICAgICAgICAgIHkgKz0gc3RhY2sucG9wKCk7CiAgICAgICAgICB4ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDIyOgogICAgICAgICAgeCArPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG1vdmVUbyh4LCB5KTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI0OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDIpIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gNikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjY6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjc6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjg6CiAgICAgICAgICBzdGFjay5wdXNoKChjb2RlW2ldIDw8IDI0IHwgY29kZVtpICsgMV0gPDwgMTYpID4+IDE2KTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjk6CiAgICAgICAgICBuID0gc3RhY2sucG9wKCkgKyBmb250LmdzdWJyc0JpYXM7CiAgICAgICAgICBzdWJyQ29kZSA9IGZvbnQuZ3N1YnJzW25dOwogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzA6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDMxOgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5OwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeGEgPSB4OwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmICh2IDwgMzIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGB1bmtub3duIG9wZXJhdG9yOiAke3Z9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodiA8IDI0NykgewogICAgICAgICAgICBzdGFjay5wdXNoKHYgLSAxMzkpOwogICAgICAgICAgfSBlbHNlIGlmICh2IDwgMjUxKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goKHYgLSAyNDcpICogMjU2ICsgY29kZVtpKytdICsgMTA4KTsKICAgICAgICAgIH0gZWxzZSBpZiAodiA8IDI1NSkgewogICAgICAgICAgICBzdGFjay5wdXNoKC0odiAtIDI1MSkgKiAyNTYgLSBjb2RlW2krK10gLSAxMDgpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaCgoY29kZVtpXSA8PCAyNCB8IGNvZGVbaSArIDFdIDw8IDE2IHwgY29kZVtpICsgMl0gPDwgOCB8IGNvZGVbaSArIDNdKSAvIDY1NTM2KTsKICAgICAgICAgICAgaSArPSA0OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHN0YWNrQ2xlYW4pIHsKICAgICAgICBzdGFjay5sZW5ndGggPSAwOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlKGNoYXJTdHJpbmdDb2RlKTsKfQpjb25zdCBOT09QID0gW107CmNsYXNzIENvbXBpbGVkRm9udCB7CiAgY29uc3RydWN0b3IoZm9udE1hdHJpeCkgewogICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IENvbXBpbGVkRm9udCkgewogICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJDYW5ub3QgaW5pdGlhbGl6ZSBDb21waWxlZEZvbnQuIik7CiAgICB9CiAgICB0aGlzLmZvbnRNYXRyaXggPSBmb250TWF0cml4OwogICAgdGhpcy5jb21waWxlZEdseXBocyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIH0KICBnZXRQYXRoSnModW5pY29kZSkgewogICAgY29uc3QgewogICAgICBjaGFyQ29kZSwKICAgICAgZ2x5cGhJZAogICAgfSA9IGxvb2t1cENtYXAodGhpcy5jbWFwLCB1bmljb2RlKTsKICAgIGxldCBmbiA9IHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF07CiAgICBpZiAoIWZuKSB7CiAgICAgIHRyeSB7CiAgICAgICAgZm4gPSB0aGlzLmNvbXBpbGVHbHlwaCh0aGlzLmdseXBoc1tnbHlwaElkXSwgZ2x5cGhJZCk7CiAgICAgICAgdGhpcy5jb21waWxlZEdseXBoc1tnbHlwaElkXSA9IGZuOwogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF0gPSBOT09QOwogICAgICAgIGlmICh0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPT09IHVuZGVmaW5lZCkgewogICAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgIH0KICAgIHJldHVybiBmbjsKICB9CiAgY29tcGlsZUdseXBoKGNvZGUsIGdseXBoSWQpIHsKICAgIGlmICghY29kZSB8fCBjb2RlLmxlbmd0aCA9PT0gMCB8fCBjb2RlWzBdID09PSAxNCkgewogICAgICByZXR1cm4gTk9PUDsKICAgIH0KICAgIGxldCBmb250TWF0cml4ID0gdGhpcy5mb250TWF0cml4OwogICAgaWYgKHRoaXMuaXNDRkZDSURGb250KSB7CiAgICAgIGNvbnN0IGZkSW5kZXggPSB0aGlzLmZkU2VsZWN0LmdldEZESW5kZXgoZ2x5cGhJZCk7CiAgICAgIGlmIChmZEluZGV4ID49IDAgJiYgZmRJbmRleCA8IHRoaXMuZmRBcnJheS5sZW5ndGgpIHsKICAgICAgICBjb25zdCBmb250RGljdCA9IHRoaXMuZmRBcnJheVtmZEluZGV4XTsKICAgICAgICBmb250TWF0cml4ID0gZm9udERpY3QuZ2V0QnlOYW1lKCJGb250TWF0cml4IikgfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZGV4IGZvciBnbHlwaCBpbmRleC4iKTsKICAgICAgfQogICAgfQogICAgY29uc3QgY21kcyA9IFt7CiAgICAgIGNtZDogInNhdmUiCiAgICB9LCB7CiAgICAgIGNtZDogInRyYW5zZm9ybSIsCiAgICAgIGFyZ3M6IGZvbnRNYXRyaXguc2xpY2UoKQogICAgfSwgewogICAgICBjbWQ6ICJzY2FsZSIsCiAgICAgIGFyZ3M6IFsic2l6ZSIsICItc2l6ZSJdCiAgICB9XTsKICAgIHRoaXMuY29tcGlsZUdseXBoSW1wbChjb2RlLCBjbWRzLCBnbHlwaElkKTsKICAgIGNtZHMucHVzaCh7CiAgICAgIGNtZDogInJlc3RvcmUiCiAgICB9KTsKICAgIHJldHVybiBjbWRzOwogIH0KICBjb21wa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sbGFyID0gNTU2OwogICAgdC5wZXJjZW50ID0gODg5OwogICAgdC5hbXBlcnNhbmQgPSA2Njc7CiAgICB0LnF1b3RlcmlnaHQgPSAyMjI7CiAgICB0LnBhcmVubGVmdCA9IDMzMzsKICAgIHQucGFyZW5yaWdodCA9IDMzMzsKICAgIHQuYXN0ZXJpc2sgPSAzODk7CiAgICB0LnBsdXMgPSA1ODQ7CiAgICB0LmNvbW1hID0gMjc4OwogICAgdC5oeXBoZW4gPSAzMzM7CiAgICB0LnBlcmlvZCA9IDI3ODsKICAgIHQuc2xhc2ggPSAyNzg7CiAgICB0Lnplcm8gPSA1NTY7CiAgICB0Lm9uZSA9IDU1NjsKICAgIHQudHdvID0gNTU2OwogICAgdC50aHJlZSA9IDU1NjsKICAgIHQuZm91ciA9IDU1NjsKICAgIHQuZml2ZSA9IDU1NjsKICAgIHQuc2l4ID0gNTU2OwogICAgdC5zZXZlbiA9IDU1NjsKICAgIHQuZWlnaHQgPSA1NTY7CiAgICB0Lm5pbmUgPSA1NTY7CiAgICB0LmNvbG9uID0gMjc4OwogICAgdC5zZW1pY29sb24gPSAyNzg7CiAgICB0Lmxlc3MgPSA1ODQ7CiAgICB0LmVxdWFsID0gNTg0OwogICAgdC5ncmVhdGVyID0gNTg0OwogICAgdC5xdWVzdGlvbiA9IDU1NjsKICAgIHQuYXQgPSAxMDE1OwogICAgdC5BID0gNjY3OwogICAgdC5CID0gNjY3OwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTAwOwogICAgdC5LID0gNjY3OwogICAgdC5MID0gNTU2OwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3O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W1wZXJzYW5kID0gNzIyOwogICAgdC5xdW90ZXJpZ2h0ID0gMjc4OwogICAgdC5wYXJlbmxlZnQgPSAzMzM7CiAgICB0LnBhcmVucmlnaHQgPSAzMzM7CiAgICB0LmFzdGVyaXNrID0gMzg5OwogICAgdC5wbHVzID0gNTg0OwogICAgdC5jb21tYSA9IDI3ODsKICAgIHQuaHlwaGVuID0gMzMzOwogICAgdC5wZXJpb2QgPSAyNzg7CiAgICB0LnNsYXNoID0gMjc4OwogICAgdC56ZXJvID0gNTU2OwogICAgdC5vbmUgPSA1NTY7CiAgICB0LnR3byA9IDU1NjsKICAgIHQudGhyZWUgPSA1NTY7CiAgICB0LmZvdXIgPSA1NTY7CiAgICB0LmZpdmUgPSA1NTY7CiAgICB0LnNpeCA9IDU1NjsKICAgIHQuc2V2ZW4gPSA1NTY7CiAgICB0LmVpZ2h0ID0gNTU2OwogICAgdC5uaW5lID0gNTU2OwogICAgdC5jb2xvbiA9IDMzMzsKICAgIHQuc2VtaWNvbG9uID0gMzMzOwogICAgdC5sZXNzID0gNTg0OwogICAgdC5lcXVhbCA9IDU4NDsKICAgIHQuZ3JlYXRlciA9IDU4NDsKICAgIHQucXVlc3Rpb24gPSA2MTE7CiAgICB0LmF0ID0gOTc1OwogICAgdC5BID0gNzIyOwogICAgdC5CID0gNzIyOwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTU2OwogICAgdC5LID0gNzIyOwogICAgdC5MID0gNjExOwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgd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sKICAgIHQuWSA9IDY2NzsKICAgIHQuWiA9IDYxMTsKICAgIHQuYnJhY2tldGxlZnQgPSAzMzM7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzMzOwogICAgdC5hc2NpaWNpcmN1bSA9IDU4NDsKICAgIHQudW5kZXJzY29yZSA9IDU1NjsKICAgIHQucXVvdGVsZWZ0ID0gMjc4OwogICAgdC5hID0gNTU2OwogICAgdC5iID0gNjExOwogICAgdC5jID0gNTU2OwogICAgdC5kID0gNjExOwogICAgdC5lID0gNTU2OwogICAgdC5mID0gMzMzOwogICAgdC5nID0gNjExOwogICAgdC5oID0gNjExOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNTU2OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gODg5OwogICAgdC5uID0gNjExOwogICAgdC5vID0gNjExOwogICAgdC5wID0gNjExOwogICAgdC5xID0gNjExOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gNTU2OwogICAgdC50ID0gMzMzOwogICAgdC51ID0gNjExOwogICAgdC52ID0gNTU2OwogICAgdC53ID0gNzc4OwogICAgdC54ID0gNTU2OwogICAgdC55ID0gNTU2OwogICAgdC56ID0gNTAwOwogICAgdC5icmFjZWxlZnQgPSAzODk7CiAgICB0LmJhciA9IDI4MDsKICAgIHQuYnJhY2VyaWdodCA9IDM4OTsKICAgIHQuYXNjaWl0aWxkZSA9IDU4NDsKICAgIHQuZXhjbGFtZG93biA9IDMzMzsKICAgIHQuY2VudCA9IDU1NjsKICAgIHQuc3RlcmxpbmcgPSA1NTY7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1NTY7CiAgICB0LmZsb3JpbiA9IDU1NjsKICAgIHQuc2VjdGlvbiA9IDU1NjsKICAgIHQuY3VycmVuY3kgPSA1NTY7CiAgICB0LnF1b3Rlc2luZ2xlID0gMjM4OwogICAgdC5xdW90ZWRibGxlZ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NjsKICAgIHQuYnJhY2tldGxlZnQgPSAzODk7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzg5OwogICAgdC5hc2NpaWNpcmN1bSA9IDQyMjsKICAgIHQudW5kZXJzY29yZSA9IDUwMDsKICAgIHQucXVvdGVsZWZ0ID0gMzMzOwogICAgdC5hID0gNTAwOwogICAgdC5iID0gNTAwOwogICAgdC5jID0gNDQ0OwogICAgdC5kID0gNTAwOwogICAgdC5lID0gNDQ0OwogICAgdC5mID0gMjc4OwogICAgdC5nID0gNTAwOwogICAgdC5oID0gNTAwOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNDQ0OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gNzIyOwogICAgdC5uID0gNTAwOwogICAgdC5vID0gNTAwOwogICAgdC5wID0gNTAwOwogICAgdC5xID0gNTAwOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gMzg5OwogICAgdC50ID0gMjc4OwogICAgdC51ID0gNTAwOwogICAgdC52ID0gNDQ0OwogICAgdC53ID0gNjY3OwogICAgdC54ID0gNDQ0OwogICAgdC55ID0gNDQ0OwogICAgdC56ID0gMzg5OwogICAgdC5icmFjZWxlZnQgPSA0MDA7CiAgICB0LmJhciA9IDI3NTsKICAgIHQuYnJhY2VyaWdodCA9IDQwMDsKICAgIHQuYXNjaWl0aWxkZSA9IDU0MTsKICAgIHQuZXhjbGFtZG93biA9IDM4OTsKICAgIHQuY2VudCA9IDUwMDsKICAgIHQuc3RlcmxpbmcgPSA1MDA7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1MDA7CiAgICB0LmZsb3JpbiA9IDUwMDsKICAgIHQuc2VjdGlvbiA9IDUwMDsKICAgIHQuY3VycmVuY3kgPSA1MDA7CiAgICB0LnF1b3Rlc2luZ2xlID0gMjE0OwogICAgdC5xdW90ZWRibGxlZnQgPSA1NTY7CiAgICB0L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TA2ID0gNjY3OwogICAgdC5hMTA3ID0gNzYwOwogICAgdC5hMTA4ID0gNzYwOwogICAgdC5hMTEyID0gNzc2OwogICAgdC5hMTExID0gNTk1OwogICAgdC5hMTEwID0gNjk0OwogICAgdC5hMTA5ID0gNjI2OwogICAgdC5hMTIwID0gNzg4OwogICAgdC5hMTIxID0gNzg4OwogICAgdC5hMTIyID0gNzg4OwogICAgdC5hMTIzID0gNzg4OwogICAgdC5hMTI0ID0gNzg4OwogICAgdC5hMTI1ID0gNzg4OwogICAgdC5hMTI2ID0gNzg4OwogICAgdC5hMTI3ID0gNzg4OwogICAgdC5hMTI4ID0gNzg4OwogICAgdC5hMTI5ID0gNzg4OwogICAgdC5hMTMwID0gNzg4OwogICAgdC5hMTMxID0gNzg4OwogICAgdC5hMTMyID0gNzg4OwogICAgdC5hMTMzID0gNzg4OwogICAgdC5hMTM0ID0gNzg4OwogICAgdC5hMTM1ID0gNzg4OwogICAgdC5hMTM2ID0gNzg4OwogICAgdC5hMTM3ID0gNzg4OwogICAgdC5hMTM4ID0gNzg4OwogICAgdC5hMTM5ID0gNzg4OwogICAgdC5hMTQwID0gNzg4OwogICAgdC5hMTQxID0gNzg4OwogICAgdC5hMTQyID0gNzg4OwogICAgdC5hMTQzID0gNzg4OwogICAgdC5hMTQ0ID0gNzg4OwogICAgdC5hMTQ1ID0gNzg4OwogICAgdC5hMTQ2ID0gNzg4OwogICAgdC5hMTQ3ID0gNzg4OwogICAgdC5hMTQ4ID0gNzg4OwogICAgdC5hMTQ5ID0gNzg4OwogICAgdC5hMTUwID0gNzg4OwogICAgdC5hMTUxID0gNzg4OwogICAgdC5hMTUyID0gNzg4OwogICAgdC5hMTUzID0gNzg4OwogICAgdC5hMTU0ID0gNzg4OwogICAgdC5hMTU1ID0gNzg4OwogICAgdC5hMTU2ID0gNzg4OwogICAgdC5hMTU3ID0gNzg4OwogICAgdC5hMTU4ID0gNzg4OwogICAgdC5hMTU5ID0gNzg4OwogICAgdC5hMTYwID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gICAgICB5Q29vcmRpbmF0ZXMKICAgICAgICB9KSk7CiAgICAgICAgeUNvb3JkaW5hdGVzID0gW107CiAgICAgICAgcG9pbnRGbGFncyA9IFtdOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbmV3IFNpbXBsZUdseXBoKHsKICAgICAgY29udG91cnMsCiAgICAgIGluc3RydWN0aW9ucwogICAgfSk7CiAgfQogIGdldFNpemUoKSB7CiAgICBsZXQgc2l6ZSA9IHRoaXMuY29udG91cnMubGVuZ3RoICogMiArIDIgKyB0aGlzLmluc3RydWN0aW9ucy5sZW5ndGg7CiAgICBsZXQgbGFzdFggPSAwOwogICAgbGV0IGxhc3RZID0gMDsKICAgIGZvciAoY29uc3QgY29udG91ciBvZiB0aGlzLmNvbnRvdXJzKSB7CiAgICAgIHNpemUgKz0gY29udG91ci5mbGFncy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGNvbnRvdXIueENvb3JkaW5hdGVzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCB4ID0gY29udG91ci54Q29vcmRpbmF0ZXNbaV07CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGxldCBhYnMgPSBNYXRoLmFicyh4IC0gbGFzdFgpOwogICAgICAgIGlmIChhYnMgPiAyNTUpIHsKICAgICAgICAgIHNpemUgKz0gMjsKICAgICAgICB9IGVsc2UgaWYgKGFicyA+IDApIHsKICAgICAgICAgIHNpemUgKz0gMTsKICAgICAgICB9CiAgICAgICAgbGFzdFggPSB4OwogICAgICAgIGFicyA9IE1hdGguYWJzKHkgLSBsYXN0WSk7CiAgICAgICAgaWYgKGFicyA+IDI1NSkgewogICAgICAgICAgc2l6ZSArPSAyOwogICAgICAgIH0gZWxzZSBpZiAoYWJzID4gMCkgewogICAgICAgICAgc2l6ZSArPSAxOwogICAgICAgIH0KICAgICAgICBsYXN0WSA9IHk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBzaXplOwogIH0KICB3cml0ZShwb3MsIGJ1ZikgewogICAgY29uc3Qgc3BvcyA9IHBvczsKICAgIGNvbnN0IHhDb29yZGluYXRlcyA9IFtdOwogICAgY29uc3QgeUNvb3JkaW5hdGVzID0gW107CiAgICBjb25zdCBmbGFncyA9IFtdOwogICAgbGV0IGxhc3RYID0gMDsKICAgIGxldCBsYXN0WSA9IDA7CiAgICBmb3IgKGNvbnN0IGNvbnRvdXIgb2YgdGhpcy5jb250b3VycykgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjb250b3VyLnhDb29yZGluYXRlcy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgbGV0IGZsYWcgPSBjb250b3VyLmZsYWdzW2ldOwogICAgICAgIGNvbnN0IHggPSBjb250b3VyLnhDb29yZGluYXRlc1tpXTsKICAgICAgICBsZXQgZGVsdGEgPSB4IC0gbGFzdFg7CiAgICAgICAgaWYgKGRlbHRhID09PSAwKSB7CiAgICAgICAgICBmbGFnIHw9IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgIHhDb29yZGluYXRlcy5wdXNoKDApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBhYnMgPSBNYXRoLmFicyhkZWx0YSk7CiAgICAgICAgICBpZiAoYWJzIDw9IDI1NSkgewogICAgICAgICAgICBmbGFnIHw9IGRlbHRhID49IDAgPyBYX1NIT1JUX1ZFQ1RPUiB8IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUiA6IFhfU0hPUlRfVkVDVE9SOwogICAgICAgICAgICB4Q29vcmRpbmF0ZXMucHVzaChhYnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgeENvb3JkaW5hdGVzLnB1c2goZGVsdGEpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsYXN0WCA9IHg7CiA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sZW5ndGg7CiAgICBsZXQgZXJyb3IgPSBmYWxzZTsKICAgIGxldCB3eCwgc2J4LCBzdWJyTnVtYmVyOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgIGxldCB2YWx1ZSA9IGVuY29kZWRbaV07CiAgICAgIGlmICh2YWx1ZSA8IDMyKSB7CiAgICAgICAgaWYgKHZhbHVlID09PSAxMikgewogICAgICAgICAgdmFsdWUgPSAodmFsdWUgPDwgOCkgKyBlbmNvZGVkWysraV07CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAodmFsdWUpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLmhzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC52c3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMSkgewogICAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGR5ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCwgZHkpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bW92ZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5ybGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDY6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC5obGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDc6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDg6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg2LCBDT01NQU5EX01BUC5ycmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgOToKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMTA6CiAgICAgICAgICAgIGlmICh0aGlzLnN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3Vick51bWJlciA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghc3VicnNbc3Vick51bWJlcl0pIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmNvbnZlcnQoc3VicnNbc3Vick51bWJlcl0sIHN1YnJzLCBzZWFjQW5hbHlzaXNFbmFibGVkKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDExOgogICAgICAgICAgICByZXR1cm4gZXJyb3I7CiAgICAgICAgICBjYXNlIDEzOgogICAgICAgICAgICBpZiAodGhpcy5zdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHd4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgc2J4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgdGhpcy5sc2IgPSBzYng7CiAgICAgICAgICAgIHRoaXMud2lkdGggPSB3eDsKICAgICAgICAgICAgdGhpcy5zdGFjay5wdXNoKHd4LCBzYngpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMiwgQ09NTUFORF9NQVAuaG1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxNDoKICAgICAgICAgICAgdGhpcy5vdXRwdXQucHVzaChDT01NQU5EX01BUC5lbmRjaGFyWzBdKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDIxOgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnJtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjI6CiAgICAgICAgICAgIGlmICh0aGlzLmZsZXhpbmcpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEsIENPTU1BTkRfTUFQLmhtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzA6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC52aGN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzE6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5odmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMDoKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnZzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDI6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5oc3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyA2OgogICAgICAgICAgICBpZiAoc2VhY0FuYWx5c2lzRW5hYmxlZCkgewogICAgICAgICAgICAgIGNvbnN0IGFzYiA9IHRoaXMuc3RhY2suYXQoLTUpOwogICAgICAgICAgICAgIHRoaXMuc2VhYyA9IHRoaXMuc3RhY2suc3BsaWNlKC00LCA0KTsKICAgICAgICAgICAgICB0aGlzLnNlYWNbMF0gKz0gdGhpcy5sc2IgLSBhc2I7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDAsIENPTU1BTkRfTUFQLmVuZGNoYXIpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5lbmRjaGFyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgNzoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgNCkgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnN0YWNrLnBvcCgpOwogICAgICAgICAgICB3eCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNvbnN0IHNieSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHNieCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMubHNiID0gc2J4OwogICAgICAgICAgICB0aGlzLndpZHRoID0gd3g7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaCh3eCwgc2J4LCBzYnkpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMywgQ09NTUFORF9NQVAucm1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxMjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBudW0yID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtMSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChudW0xIC8gbnVtMik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxNjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdWJyTnVtYmVyID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtQXJncyA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmIChzdWJyTnVtYmVyID09PSAwICYmIG51bUFyZ3MgPT09IDMpIHsKICAgICAgICAgICAgICBjb25zdCBmbGV4QXJncyA9IHRoaXMuc3RhY2suc3BsaWNlKC0xNywgMTcpOwogICAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChmbGV4QXJnc1syXSArIGZsZXhBcmdzWzBdLCBmbGV4QXJnc1szXSArIGZsZXhBcmdzWzFdLCBmbGV4QXJnc1s0XSwgZmxleEFyZ3NbNV0sIGZsZXhBcmdzWzZdLCBmbGV4QXJnc1s3XSwgZmxleEFyZ3NbOF0sIGZsZXhBcmdzWzldLCBmbGV4QXJnc1sxMF0sIGZsZXhBcmdzWzExXSwgZmxleEFyZ3NbMTJdLCBmbGV4QXJnc1sxM10sIGZsZXhBcmdzWzE0XSk7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEzLCBDT01NQU5EX01BUC5mbGV4LCB0cnVlKTsKICAgICAgICAgICAgICB0aGlzLmZsZXhpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goZmxleEFyZ3NbMTVdLCBmbGV4QXJnc1sxNl0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKHN1YnJOdW1iZXIgPT09IDEgJiYgbnVtQXJncyA9PT0gMCkgewogICAgICAgICAgICAgIHRoaXMuZmxleGluZyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDE3OgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMzM6CiAgICAgICAgICAgIHRoaXMuc3RhY2sgPSBbXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoJ1Vua25vd24gdHlwZSAxIGNoYXJzdHJpbmcgY29tbWFuZCBvZiAiJyArIHZhbHVlICsgJyInKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChlcnJvcikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlIDw9IDI0NikgewogICAgICAgIHZhbHVlIC09IDEzOTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA8PSAyNTApIHsKICAgICAgICB2YWx1ZSA9ICh2YWx1ZSAtIDI0NykgKiAyNTYgKyBlbmNvZGVkWysraV0gKyAxMDg7CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPD0gMjU0KSB7CiAgICAgICAgdmFsdWUgPSAtKCh2YWx1ZSAtIDI1MSkgKiAyNTYpIC0gZW5jb2RlZFsrK2ldIC0gMTA4OwogICAgICB9IGVsc2UgewogICAgICAgIHZhbHVlID0gKGVuY29kZWRbKytpXSAmIDB4ZmYpIDw8IDI0IHwgKGVuY29kZ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uIHx8IDApKTsKICAgIH0KICAgIHJldHVybiBhcnJheTsKICB9CiAgcmVhZE51bWJlcigpIHsKICAgIGNvbnN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHBhcnNlRmxvYXQodG9rZW4gfHwgMCk7CiAgfQogIHJlYWRJbnQoKSB7CiAgICBjb25zdCB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgIHJldHVybiBwYXJzZUludCh0b2tlbiB8fCAwLCAxMCkgfCAwOwogIH0KICByZWFkQm9vbGVhbigpIHsKICAgIGNvbnN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHRva2VuID09PSAidHJ1ZSIgPyAxIDogMDsKICB9CiAgbmV4dENoYXIoKSB7CiAgICByZXR1cm4gdGhpcy5jdXJyZW50Q2hhciA9IHRoaXMuc3RyZWFtLmdldEJ5dGUoKTsKICB9CiAgcHJldkNoYXIoKSB7CiAgICB0aGlzLnN0cmVhbS5za2lwKC0yKTsKICAgIHJldHVybiB0aGlzLmN1cnJlbnRDaGFyID0gdGhpcy5zdHJlYW0uZ2V0Qnl0ZSgpOwogIH0KICBnZXRUb2tlbigpIHsKICAgIGxldCBjb21tZW50ID0gZmFsc2U7CiAgICBsZXQgY2ggPSB0aGlzLmN1cnJlbnRDaGFyOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgaWYgKGNoID09PSAtMSkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoISgwLCBfY29yZV91dGlscy5pc1doaXRlU3BhY2UpKGNoKSkgewogICAgICAgIGJyZW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cy5nZXRUb2tlbigpKSAhPT0gbnVsbCkgewogICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICBzd2l0Y2ggKHRva2VuKSB7CiAgICAgICAgY2FzZSAiQ2hhclN0cmluZ3MiOgogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gbnVsbCB8fCB0b2tlbiA9PT0gImVuZCIpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodG9rZW4gPT09ICIvIikgewogICAgICAgICAgICAgIHRoaXMucHJldkNoYXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjaGFyc3RyaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBnbHlwaCwKICAgICAgICAgICAgICBlbmNvZGVkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU3VicnMiOgogICAgICAgICAgdGhpcy5yZWFkSW50KCk7CiAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICB3aGlsZSAodGhpcy5nZXRUb2tlbigpID09PSAiZHVwIikgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IHRoaXMucmVhZEludCgpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VicnNbaW5kZXhdID0gZW5jb2RlZDsKICAgICA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cigpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRXhwYW5zaW9uRmFjdG9yIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWROdW1iZXIoKSB8fCAwLjA2OwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9yY2VCb2xkIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWRCb29sZWFuKCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIGVuY29kZWQsCiAgICAgIGdseXBoCiAgICB9IG9mIGNoYXJzdHJpbmdzKSB7CiAgICAgIGNvbnN0IGNoYXJTdHJpbmcgPSBuZXcgVHlwZTFDaGFyU3RyaW5nKCk7CiAgICAgIGNvbnN0IGVycm9yID0gY2hhclN0cmluZy5jb252ZXJ0KGVuY29kZWQsIHN1YnJzLCB0aGlzLnNlYWNBbmFseXNpc0VuYWJsZWQpOwogICAgICBsZXQgb3V0cHV0ID0gY2hhclN0cmluZy5vdXRwdXQ7CiAgICAgIGlmIChlcnJvcikgewogICAgICAgIG91dHB1dCA9IFsxNF07CiAgICAgIH0KICAgICAgY29uc3QgY2hhclN0cmluZ09iamVjdCA9IHsKICAgICAgICBnbHlwaE5hbWU6IGdseXBoLAogICAgICAgIGNoYXJzdHJpbmc6IG91dHB1dCwKICAgICAgICB3aWR0aDogY2hhclN0cmluZy53aWR0aCwKICAgICAgICBsc2I6IGNoYXJTdHJpbmcubHNiLAogICAgICAgIHNlYWM6IGNoYXJTdHJpbmcuc2VhYwogICAgICB9OwogICAgICBpZiAoZ2x5cGggPT09ICIubm90ZGVmIikgewogICAgICAgIHByb2dyYW0uY2hhcnN0cmluZ3MudW5zaGlmdChjaGFyU3RyaW5nT2JqZWN0KTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwcm9ncmFtLmNoYXJzdHJpbmdzLnB1c2goY2hhclN0cmluZ09iamVjdCk7CiAgICAgIH0KICAgICAgaWYgKHByb3BlcnRpZXMuYnVpbHRJbkVuY29kaW5nKSB7CiAgICAgICAgY29uc3QgaW5kZXggPSBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZy5pbmRleE9mKGdseXBoKTsKICAgICAgICBpZiAoaW5kZXggPiAtMSAmJiBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPT09IHVuZGVmaW5lZCAmJiBpbmRleCA+PSBwcm9wZXJ0aWVzLmZpcnN0Q2hhciAmJiBpbmRleCA8PSBwcm9wZXJ0aWVzLmxhc3RDaGFyKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPSBjaGFyU3RyaW5nLndpZHRoOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIHByb2dyYW07CiAgfQogIGV4dHJhY3RGb250SGVhZGVyKHByb3BlcnRpZXMpIHsKICAgIGxldCB0b2tlbjsKICAgIHdoaWxlICgodG9rZW4gPSB0aGlzLmdldFRva2VuKCkpICE9PSBudWxsKSB7CiAgICAgIGlmICh0b2tlbiAhPT0gIi8iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgIHN3aXRjaCAodG9rZW4pIHsKICAgICAgICBjYXNlICJGb250TWF0cml4IjoKICAgICAgICAgIGNvbnN0IG1hdHJpeCA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBwcm9wZXJ0aWVzLmZvbnRNYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJFbmNvZGluZyI6CiAgICAgICAgICBjb25zdCBlbmNvZGluZ0FyZyA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgIGxldCBlbmNvZGluZzsKICAgICAgICAgIGlmICghL15cZCskLy50ZXN0KGVuY29kaW5nQXJnKSkgewogICAgICAgICAgICBlbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShlbmNvZGluZ0FyZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBlbmNvZGluZyA9IFtdOwogICAgICAgICAgICBjb25zdCBzaXplID0gcGFyc2VJbnQoZW5jb2RpbmdBcmcsIDEwKSB8IDA7CiAgICAgICAgICAgIHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBzaXplOyBqKyspIHsKICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgICB3aGlsZSAodG9rZW4gIT09ICJkdXAiICYmIHRva2VuICE9PSAiZGVmIikgewogICAgICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICBpZiAodG9rZW4gPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodG9rZW4gPT09ICJkZWYiKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgY29uc3QgZ2x5cGggPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgZW5jb2RpbmdbaW5kZXhdID0gZ2x5cGg7CiAgICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZyA9IGVuY29kaW5nOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9udE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oOyBpIDwgaWk7IGkrKykgewogICAgICAgIHRoaXMuX2J1aWxkRmlndXJlRnJvbVBhdGNoKGkpOwogICAgICB9CiAgICB9CiAgICB0aGlzLl91cGRhdGVCb3VuZHMoKTsKICAgIHRoaXMuX3BhY2tEYXRhKCk7CiAgfQogIF9kZWNvZGVUeXBlNFNoYWRpbmcocmVhZGVyKSB7CiAgICBjb25zdCBjb29yZHMgPSB0aGlzLmNvb3JkczsKICAgIGNvbnN0IGNvbG9ycyA9IHRoaXMuY29sb3JzOwogICAgY29uc3Qgb3BlcmF0b3JzID0gW107CiAgICBjb25zdCBwcyA9IFtdOwogICAgbGV0IHZlcnRpY2VzTGVmdCA9IDA7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBjb25zdCBjb29yZCA9IHJlYWRlci5yZWFkQ29vcmRpbmF0ZSgpOwogICAgICBjb25zdCBjb2xvciA9IHJlYWRlci5yZWFkQ29tcG9uZW50cygpOwogICAgICBpZiAodmVydGljZXNMZWZ0ID09PSAwKSB7CiAgICAgICAgaWYgKCEoMCA8PSBmICYmIGYgPD0gMikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNCBmbGFnIik7CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAoZikgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICB2ZXJ0aWNlc0xlZnQgPSAzOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgcHMucHVzaChwcy5hdCgtMiksIHBzLmF0KC0xKSk7CiAgICAgICAgICAgIHZlcnRpY2VzTGVmdCA9IDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBwcy5wdXNoKHBzLmF0KC0zKSwgcHMuYXQoLTEpKTsKICAgICAgICAgICAgdmVydGlj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KHJlYWRlcikgewogICAgY29uc3QgY29vcmRzID0gdGhpcy5jb29yZHM7CiAgICBjb25zdCBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBzID0gbmV3IEludDMyQXJyYXkoMTYpOwogICAgY29uc3QgY3MgPSBuZXcgSW50MzJBcnJheSg0KTsKICAgIHdoaWxlIChyZWFkZXIuaGFzRGF0YSkgewogICAgICBjb25zdCBmID0gcmVhZGVyLnJlYWRGbGFnKCk7CiAgICAgIGlmICghKDAgPD0gZiAmJiBmIDw9IDMpKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIHR5cGU2IGZsYWciKTsKICAgICAgfQogICAgICBjb25zdCBwaSA9IGNvb3Jkcy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGYgIT09IDAgPyA4IDogMTI7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29vcmRzLnB1c2gocmVhZGVyLnJlYWRDb29yZGluYXRlKCkpOwogICAgICB9CiAgICAgIGNvbnN0IGNpID0gY29sb3JzLmxlbmd0aDsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZiAhPT0gMCA/IDIgOiA0OyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbG9ycy5wdXNoKHJlYWRlci5yZWFkQ29tcG9uZW50cygpKTsKICAgICAgfQogICAgICBsZXQgdG1wMSwgdG1wMiwgdG1wMywgdG1wNDsKICAgICAgc3dpdGNoIChmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgcHNbMTJdID0gcGkgKyAzOwogICAgICAgICAgcHNbMTNdID0gcGkgKyA0OwogICAgICAgICAgcHNbMTRdID0gcGkgKyA1OwogICAgICAgICAgcHNbMTVdID0gcGkgKyA2OwogICAgICAgICAgcHNbOF0gPSBwaSArIDI7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbN10gPSBwaSArIDQ7CiAgICAgICAgICBwc1swXSA9IHRtcDE7CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICB0bXAxID0gY3NbMl07CiAgICAgICAgICB0bXAyID0gY3NbM107CiAgICAgICAgICBjc1syXSA9IHRtcDI7CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICB0bXAxID0gcHNbMTVdOwogICAgICAgICAgdG1wMiA9IHBzWzExXTsKICAgICAgICAgIHBzWzEyXSA9IHBzWzNdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1s3XTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gdG1wMjsKICAgICAgICAgIHBzWzddID0gcGkgKyA0OwogICAgICAgICAgcHNbMF0gPSB0bXAxOwogICAgICAgICAgcHNbMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1syXSA9IHBpICsgNjsKICAgICAgICAgIHBzWzNdID0gcGkgKyA1OwogICAgICAgICAgdG1wMSA9IGNzWzNdOwogICAgICAgICAgY3NbMl0gPSBjc1sxXTsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHBzWzEyXSA9IHBzWzBdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1sxXTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gcHNbMl07CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTs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l1dWzFdICsgY29vcmRzW3BzWzhdXVsxXSkpIC8gOV0pOwogICAgICB0aGlzLmZpZ3VyZXMucHVzaCh7CiAgICAgICAgdHlwZTogInBhdGNoIiwKICAgICAgICBjb29yZHM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgICBjb2xvcnM6IG5ldyBJbnQzMkFycmF5KGNzKQogICAgICB9KTsKICAgIH0KICB9CiAgX2RlY29kZVR5cGU3U2hhZGluZyhyZWFkZXIpIHsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzOwogICAgY29uc3QgY29sb3JzID0gdGhpcy5jb2xvcnM7CiAgICBjb25zdCBwcyA9IG5ldyBJbnQzMkFycmF5KDE2KTsKICAgIGNvbnN0IGNzID0gbmV3IEludDMyQXJyYXkoNCk7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBpZiAoISgwIDw9IGYgJiYgZiA8PSAzKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNyBmbGFnIik7CiAgICAgIH0KICAgICAgY29uc3QgcGkgPSBjb29yZHMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMTIgOiAxNjsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb29yZHMucHVzaChyZWFkZXIucmVhZENvb3JkaW5hdGUoKSk7CiAgICAgIH0KICAgICAgY29uc3QgY2kgPSBjb2xvcnMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMiA6IDQ7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29sb3JzLnB1c2gocmVhZGVyLnJlYWRDb21wb25lbnRzKCkpOwogICAgICB9CiAgICAgIGxldCB0bXAxLCB0bXAyLCB0bXAzLCB0bXA0OwogICAgICBzd2l0Y2ggKGYpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBwc1sxMl0gPSBwaSArIDM7CiAgICAgICAgICBwc1sxM10gPSBwaSArIDQ7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDU7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDY7CiAgICAgICAgICBwc1s4XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzldID0gcGkgKyAxMzsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTQ7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzVdID0gcGkgKyAxMjsKICAgICAgICAgIHBzWzZdID0gcGkgKyAxNTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1syXTsKICAgICAgICAgIHRtcDIgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gdG1wMjsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIHRtcDEgPSBwc1sxNV07CiAgICAgICAgICB0bXAyID0gcHNbMTFdOwogICAgICAgICAgcHNbMTJdID0gcHNbM107CiAgICAgICAgICBwc1sxM10gPSBwaSArIDA7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDE7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDI7CiAgICAgICAgICBwc1s4XSA9IHBzWzddOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gY3NbMV07CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDM6CiAgICAgICAgICBwc1sxMl0gPSBwc1swXTsKICAgICAgICAgIHBzWzEzXSA9IHBpICsgMDsKICAgICAgICAgIHBzWzE0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzE1XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzhdID0gcHNbMV07CiAgICAgICAgICBwc1s5XSA9IHBpICsgOTsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTA7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDM7CiAgICAgICAgICBwc1s0XSA9IHBzWzJdOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMuZmlndXJlcy5wdXNoKHsKICAgICAgICB0eXBlOiAicGF0Y2giLAogICAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICAgIGNvbG9yczogbmV3IEludDMyQXJyYXkoY3MpCiAgICAgIH0pOwogICAgfQogIH0KICBfYnVpbGRGaWd1cmVGcm9tUGF0Y2goaW5kZXgpIHsKICAgIGNvbnN0IGZpZ3VyZSA9IHRoaXMuZmlnd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ewogICAgICBjbFswXSA9IChjMFswXSAqIChzcGxpdFlCeSAtIHJvdykgKyBjMlswXSAqIHJvdykgLyBzcGxpdFlCeSB8IDA7CiAgICAgIGNsWzFdID0gKGMwWzFdICogKHNwbGl0WUJ5IC0gcm93KSArIGMyWzFdICogcm93KSAvIHNwbGl0WUJ5IHwgMDsKICAgICAgY2xbMl0gPSAoYzBbMl0gKiAoc3BsaXRZQnkgLSByb3cpICsgYzJbMl0gKiByb3cpIC8gc3BsaXRZQnkgfCAwOwogICAgICBjclswXSA9IChjMVswXSAqIChzcGxpdFlCeSAtIHJvdykgKyBjM1swXSAqIHJvdykgLyBzcGxpdFlCeSB8IDA7CiAgICAgIGNyWzFdID0gKGMxWzFdICogKHNwbGl0WUJ5IC0gcm93KSArIGMzWzFdICogcm93KSAvIHNwbGl0WUJ5IHwgMDsKICAgICAgY3JbMl0gPSAoYzFbMl0gKiAoc3BsaXRZQnkgLSByb3cpICsgYzNbMl0gKiByb3cpIC8gc3BsaXRZQnkgfCAwOwogICAgICBmb3IgKGxldCBjb2wgPSAwOyBjb2wgPD0gc3BsaXRYQnk7IGNvbCsrLCBrKyspIHsKICAgICAgICBpZiAoKHJvdyA9PT0gMCB8fCByb3cgPT09IHNwbGl0WUJ5KSAmJiAoY29sID09PSAwIHx8IGNvbCA9PT0gc3BsaXRYQnkpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgbGV0IHggPSAwLAogICAgICAgICAgeSA9IDA7CiAgICAgICAgbGV0IHEgPSAwOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IDM7IGkrKykgewogICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPD0gMzsgaisrLCBxKyspIHsKICAgICAgICAgICAgY29uc3QgbSA9IGJSb3dbcm93XVtpXSAqIGJDb2xbY29sXVtqXTsKICAgICAgICAgICAgeCArPSBjb29yZHNbcGlbcV1dWzBdICogbTsKICAgICAgICAgICAgeSArPSBjb29yZHNbcGl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jaVszXTsKICAgIHRoaXMuZmlndXJlc1tpbmRleF0gPSB7CiAgICAgIHR5cGU6ICJsYXR0aWNlIiwKICAgICAgY29vcmRzOiBmaWd1cmVDb29yZHMsCiAgICAgIGNvbG9yczogZmlndXJlQ29sb3JzLAogICAgICB2ZXJ0aWNlc1BlclJvdwogICAgfTsKICB9CiAgX3VwZGF0ZUJvdW5kcygpIHsKICAgIGxldCBtaW5YID0gdGhpcy5jb29yZHNbMF1bMF0sCiAgICAgIG1pblkgPSB0aGlzLmNvb3Jkc1swXVsxXSwKICAgICAgbWF4WCA9IG1pblgsCiAgICAgIG1heFkgPSBtaW5ZOwogICAgZm9yIChsZXQgaSA9IDEsIGlpID0gdGhpcy5jb29yZHMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICBjb25zdCB4ID0gdGhpcy5jb29yZHNbaV1bMF0sCiAgICAgICAgeSA9IHRoaXMuY29vcmRzW2ldWzFdOwogICAgICBtaW5YID0gbWluWCA+IHggPyB4IDogbWluWDsKICAgICAgbWluWSA9IG1pblkgPiB5ID8geSA6IG1pblk7CiAgICAgIG1heFggPSBtYXhYIDwgeCA/IHggOiBtYXhYOwogICAgICBtYXhZID0gbWF4WSA8IHkgPyB5IDogbWF4WTsKICAgIH0KICAgIHRoaXMuYm91bmRzID0gW21pblgsIG1pblksIG1heFgsIG1heFldOwogIH0KICBfcGFja0RhdGEoKSB7CiAgICBsZXQgaSwgaWksIGosIGpqOwogICAgY29uc3QgY29vcmRzID0gdGhpcy5jb29yZHM7CiAgICBjb25zdCBjb29yZHNQYWNrZWQgPSBuZXcgRmxvYXQzMkFycmF5KGNvb3Jkcy5sZW5ndGggKiAyKTsKICAgIGZvciAoaSA9IDAsIGogPSAwLCBpaSA9IGNvb3Jkcy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgIGNvbnN0IHh5ID0gY29vcmRzW2ldOwogICAgICBjb29yZHNQYWNrZWRbaisrXSA9IHh5WzBdOwogICAgICBjb29yZ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ykgLyA4KTsKICAgIGxldCBzdHJJZHggPSAwOwogICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHdoaWxlIChjb2RlU2l6ZSA8IGJwcykgewogICAgICAgIGNvZGVCdWYgPDw9IDg7CiAgICAgICAgY29kZUJ1ZiB8PSBzdHJCeXRlc1tzdHJJZHgrK107CiAgICAgICAgY29kZVNpemUgKz0gODsKICAgICAgfQogICAgICBjb2RlU2l6ZSAtPSBicHM7CiAgICAgIGFycmF5W2ldID0gKGNvZGVCdWYgPj4gY29kZVNpemUpICogc2FtcGxlTXVsOwogICAgICBjb2RlQnVmICY9ICgxIDw8IGNvZGVTaXplKSAtIDE7CiAgICB9CiAgICByZXR1cm4gYXJyYXk7CiAgfQogIHN0YXRpYyBwYXJzZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICBmbgogICAgfSA9IF9yZWYyOwogICAgY29uc3QgZGljdCA9IGZuLmRpY3QgfHwgZm47CiAgICBjb25zdCB0eXBlTnVtID0gZGljdC5nZXQoIkZ1bmN0aW9uVHlwZSIpOwogICAgc3dpdGNoICh0eXBlTnVtKSB7CiAgICAgIGNhc2UgMDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTYW1wbGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgICAgY2FzZSAxOgogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgcmV0dXJuIHRoaXMuY29uc3RydWN0SW50ZXJwb2xhdGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgMzoKICAgICAgICByZXR1cm4gdGhpcy5jb25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CArIGs7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IGN1YmVWZXJ0aWNlczsgaisrKSB7CiAgICAgICAgICBpZiAoaiAmIHBvcykgewogICAgICAgICAgICBjdWJlTltqXSAqPSBuMTsKICAgICAgICAgICAgY3ViZVZlcnRleFtqXSArPSBvZmZzZXQxOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY3ViZU5bal0gKj0gbjA7CiAgICAgICAgICAgIGN1YmVWZXJ0ZXhbal0gKz0gb2Zmc2V0MDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgayAqPSBzaXplX2k7CiAgICAgICAgcG9zIDw8PSAxOwogICAgICB9CiAgICAgIGZvciAoaiA9IDA7IGogPCBvdXRwdXRTaXplOyArK2opIHsKICAgICAgICBsZXQgcmogPSAwOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBjdWJlVmVydGljZXM7IGkrKykgewogICAgICAgICAgcmogKz0gc2FtcGxlc1tjdWJlVmVydGV4W2ldICsgal0gKiBjdWJlTltpXTsKICAgICAgICB9CiAgICAgICAgcmogPSBpbnRlcnBvbGF0ZShyaiwgMCwgMSwgZGVjb2RlW2pdWzBdLCBkZWNvZGVbal1bMV0pOwogICAgICAgIGRlc3RbZGVzdE9mZnNldCArIGpdID0gTWF0aC5taW4oTWF0aC5tYXgocmosIHJhbmdlW2pdWzBdKSwgcmFuZ2Vbal1bMV0pOwogICAgICB9CiAgICB9OwogIH0KICBzdGF0aWMgY29uc3RydWN0SW50ZXJwb2xhdGVkKF9yZWY1KSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGRpY3QKICAgIH0gPSBfcmVmNTsKICAgIGNvbnN0IGMwID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJDMCIpKSB8fCBbMF07CiAgICBjb25zdCBjMSA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQzEiKSkgfHwgWzF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ciAoY29uc3QgZm4gb2YgZGljdC5nZXQoIkZ1bmN0aW9ucyIpKSB7CiAgICAgIGZucy5wdXNoKHRoaXMucGFyc2UoewogICAgICAgIHhyZWYsCiAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgIGZuOiB4cmVmLmZldGNoSWZSZWYoZm4pCiAgICAgIH0pKTsKICAgIH0KICAgIGNvbnN0IGJvdW5kcyA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQm91bmRzIikpOwogICAgY29uc3QgZW5jb2RlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJFbmNvZGUiKSk7CiAgICBjb25zdCB0bXBCdWYgPSBuZXcgRmxvYXQzMkFycmF5KDEpOwogICAgcmV0dXJuIGZ1bmN0aW9uIGNvbnN0cnVjdFN0aWNoZWRGbihzcmMsIHNyY09mZnNldCwgZGVzdCwgZGVzdE9mZnNldCkgewogICAgICBjb25zdCBjbGlwID0gZnVuY3Rpb24gY29uc3RydWN0U3RpY2hlZEZyb21JUkNsaXAodiwgbWluLCBtYXgpIHsKICAgICAgICBpZiAodiA+IG1heCkgewogICAgICAgICAgdiA9IG1heDsKICAgICAgICB9IGVsc2UgaWYgKHYgPCBtaW4pIHsKICAgICAgICAgIHYgPSBtaW47CiAgICAgICAgfQogICAgICAgIHJldHVybiB2OwogICAgICB9OwogICAgICBjb25zdCB2ID0gY2xpcChzcmNbc3JjT2Zmc2V0XSwgZG9tYWluWzBdLCBkb21haW5bMV0pOwogICAgICBjb25zdCBsZW5ndGggPSBib3VuZHMubGVuZ3RoOwogICAgICBsZXQgaTsKICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgaWYgKHYgPCBib3VuZHNbaV0pIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBsZXQgZG1pbiA9IGRvbWFpblswXTsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgZG1pbi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ICAgIHZhbHVlID0gc3JjW3NyY09mZnNldCArIGldOwogICAgICAgIGlucHV0W2ldID0gdmFsdWU7CiAgICAgICAga2V5ICs9IHZhbHVlICsgIl8iOwogICAgICB9CiAgICAgIGNvbnN0IGNhY2hlZFZhbHVlID0gY2FjaGVba2V5XTsKICAgICAgaWYgKGNhY2hlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICBkZXN0LnNldChjYWNoZWRWYWx1ZSwgZGVzdE9mZnNldCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IG91dHB1dCA9IG5ldyBGbG9hdDMyQXJyYXkobnVtT3V0cHV0cyk7CiAgICAgIGNvbnN0IHN0YWNrID0gZXZhbHVhdG9yLmV4ZWN1dGUoaW5wdXQpOwogICAgICBjb25zdCBzdGFja0luZGV4ID0gc3RhY2subGVuZ3RoIC0gbnVtT3V0cHV0czsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bU91dHB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3RhY2tbc3RhY2tJbmRleCArIGldOwogICAgICAgIGxldCBib3VuZCA9IHJhbmdlW2kgKiAyXTsKICAgICAgICBpZiAodmFsdWUgPCBib3VuZCkgewogICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYm91bmQgPSByYW5nZVtpICogMiArIDFdOwogICAgICAgICAgaWYgKHZhbHVlID4gYm91bmQpIHsKICAgICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgIH0KICAgICAgaWYgKGNhY2hlX2F2YWlsYWJsZSA+IDApIHsKICAgICAgICBjYWNoZV9hdmFpbGFibGUtLTsKICAgICAgICBjYWNoZVtrZXldID0gb3V0cHV0OwogICAgICB9CiAgICAgIGRlc3Quc2V0KG91dHB1dCwgZGVzdE9mZnNldCk7CiAgICB9OwogIH0K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md0aCArIG4gPj0gUG9zdFNjcmlwdFN0YWNrLk1BWF9TVEFDS19TSVpFKSB7CiAgICAgIHRocm93IG5ldyBFcnJvcigiUG9zdFNjcmlwdCBmdW5jdGlvbiBzdGFjayBvdmVyZmxvdy4iKTsKICAgIH0KICAgIGNvbnN0IHN0YWNrID0gdGhpcy5zdGFjazsKICAgIGZvciAobGV0IGkgPSBzdGFjay5sZW5ndGggLSBuLCBqID0gbiAtIDE7IGogPj0gMDsgai0tLCBpKyspIHsKICAgICAgc3RhY2sucHVzaChzdGFja1tpXSk7CiAgICB9CiAgfQogIGluZGV4KG4pIHsKICAgIHRoaXMucHVzaCh0aGlzLnN0YWNrW3RoaXMuc3RhY2subGVuZ3RoIC0gbiAtIDFdKTsKICB9CiAgcm9sbChuLCBwKSB7CiAgICBjb25zdCBzdGFjayA9IHRoaXMuc3RhY2s7CiAgICBjb25zdCBsID0gc3RhY2subGVuZ3RoIC0gbjsKICAgIGNvbnN0IHIgPSBzdGFjay5sZW5ndGggLSAxOwogICAgY29uc3QgYyA9IGwgKyAocCAtIE1hdGguZmxvb3IocCAvIG4pICogbik7CiAgICBmb3IgKGxldCBpID0gbCwgaiA9IHI7IGkgPCBqOyBpKyssIGotLSkgewogICAgICBjb25zdCB0ID0gc3RhY2tbaV07CiAgICAgIHN0YWNrW2ldID0gc3RhY2tbal07CiAgICAgIHN0YWNrW2pdID0gdDsKICAgIH0KICAgIGZvciAobGV0IGkgPSBsLCBqID0gYyAtIDE7IGkgPCBqOyBpKyssIGotLSkgewogICAgICBjb25zdCB0ID0gc3RhY2tbaV07CiAgICAgIHN0YWNrW2ldID0gc3RhY2tbal07CiAgICAgIHN0YWNrW2pdID0gdDsKICAgIH0KICAgIGZvciAobGV0IGkgPSBjLCBqID0gcjsgaSA8IGo7IGkrKywgai0tKSB7CiAgICAgIGNvbnN0IHQgPSBzdGFja1tpXTsKICAgICAgc3RhY2tbaV0gPSBzdGFja1tqXTsKICAgICAgc3RhY2tbal0gPSB0OwogICAgfQogIH0KfQpjbGFzcyBQb3N0U2NyaXB0RXZhbHVhdG9yIHsKICBjb25zdHJ1Y3RvcihvcGVyYXRvcnMpIHsKICAgIHRoaXMub3BlcmF0b3JzID0gb3BlcmF0b3JzOwogIH0KICBleGVjdXRlKGluaXRpYWxTdGFjaykgewogICAgY29uc3Qgc3RhY2sgPSBuZXcgUG9zdFNjcmlwdFN0YWNrKGluaXRpYWxTdGFjayk7CiAgICBsZXQgY291bnRlciA9IDA7CiAgICBjb25zdCBvcGVyYXRvcnMgPSB0aGlzLm9wZXJhdG9yczsKICAgIGNvbnN0IGxlbmd0aCA9IG9wZXJhdG9ycy5sZW5ndGg7CiAgICBsZXQgb3BlcmF0b3IsIGEsIGI7CiAgICB3aGlsZSAoY291bnRlciA8IGxlbmd0aCkgewogICAgICBvcGVyYXRvciA9IG9wZXJhdG9yc1tjb3VudGVyKytdOwogICAgICBpZiAodHlwZW9mIG9wZXJhdG9yID09PSAibnVtYmVyIikgewogICAgICAgIHN0YWNrLnB1c2gob3BlcmF0b3IpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICBjYXNlICJqeiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoIWEpIHsKICAgICAgICAgICAgY291bnRlciA9IGI7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJqIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGNvdW50ZXIgPSBhOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWJzIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5hYnMoYSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSArIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYW5kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGlmICh0eXBlb2YgYSA9PT0gImJvb2xlYW4iICYmIHR5cGVvZiBiID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYmIGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYgYik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJhdGFuIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBNYXRoLmF0YW4yKGEsIGIpIC8gTWF0aC5QSSAqIDE4MDsKICAgICAgICAgIGlmIChhIDwgMCkgewogICAgICAgICAgICBhICs9IDM2MDsKICAgICAgICAgIH0KICAgICAgICAgIHN0YWNrLnB1c2goYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJiaXRzaGlmdCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoYSA+IDApIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhIDw8IGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhID4+IGIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY2VpbGluZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguY2VpbChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3B5IjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLmNvcHkoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3MiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLmNvcyhhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZpIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKSB8IDA7CiAgICAgICAgICBzdGFjay5wdXNoKGEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZyIjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImRpdiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgLyBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImR1cCI6CiAgICAgICAgICBzdGFjay5jb3B5KDEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXEiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhID09PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4Y2giOgogICAgICAgICAgc3RhY2sucm9sbCgyLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4cCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgKiogYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmYWxzZSI6CiAgICAgICAgICBzdGFjay5wdXNoKGZhbHNlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZsb29yIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5mbG9vcihhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPj0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPiBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImlkaXYiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC8gYiB8IDApOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiaW5kZXgiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2suaW5kZXgoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPD0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsbiI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImxvZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpIC8gTWF0aC5MTjEwKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImx0IjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSA8IGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibW9kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAlIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibXVsIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAqIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibmUiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhICE9PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5lZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKC1hKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5vdCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKCFhKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2gofmEpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAib3IiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKHR5cGVvZiBhID09PSAiYm9vbGVhbiIgJiYgdHlwZW9mIGIgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfHwgYik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfCBiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInBvcCI6CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvbGwiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucm9sbChhLCBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvdW5kIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5yb3VuZChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzaW4iOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLnNpbihhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAic3FydCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguc3FydChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzdWIiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVlIjoKICAgICAgICAgIHN0YWNrLnB1c2godHJ1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVuY2F0ZSI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gY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Rpb24gYnVpbGRNdWxPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBuZXcgQXN0TGl0ZXJhbCgwKTsKICAgIH0gZWxzZSBpZiAobnVtMi5udW1iZXIgPT09IDEpIHsKICAgICAgcmV0dXJuIG51bTE7CiAgICB9IGVsc2UgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICAgIHJldHVybiBuZXcgQXN0TGl0ZXJhbChudW0xLm51bWJlciAqIG51bTIubnVtYmVyKTsKICAgIH0KICB9CiAgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICBpZiAobnVtMS5udW1iZXIgPT09IDApIHsKICAgICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKDApOwogICAgfSBlbHNlIGlmIChudW0xLm51bWJlciA9PT0gMSkgewogICAgICByZXR1cm4gbnVtMjsKICAgIH0KICB9CiAgY29uc3QgbWluID0gTWF0aC5taW4obnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgY29uc3QgbWF4ID0gTWF0aC5tYXgobnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgcmV0dXJuIG5ldyBBc3RCaW5hcnlPcGVyYXRpb24oIioiLCBudW0xLCBudW0yLCBtaW4sIG1heCk7Cn0KZnVuY3Rpb24gYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBudW0xOwogICAgfSBlbHNlIGlmIChudW0xLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgLSBudW0yLm51bWJlcik7CiAgICB9CiAgfQogIGlmIChudW0yLnR5cGUgPT09ICJiaW5hcnkiICYmIG51bTIub3AgPT09ICItIiAmJiBudW0xLnR5cGUgPT09ICJsaXRlcmFsIiAmJiBudW0xLm51bWJlciA9PT0gMSAmJiBudW0yLmFyZzEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIuYXJnMS5udW1iZXIgPT09IDEpIHsKICAgIHJldHVybiBudW0yLmFyZzI7CiAgfQogIHJldHVybiBuZXcgQXN0QmluYXJ5T3BlcmF0aW9uKCItIiwgbnVtMSwgbnVtMiwgbnVtMS5taW4gLSBudW0yLm1heCwgbnVtMS5tYXggLSBudW0yLm1pbik7Cn0KZnVuY3Rpb24gYnVpbGRNaW5PcGVyYXRpb24obnVtMSwgbWF4KSB7CiAgaWYgKG51bTEubWluID49IG1heCkgewogICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKG1heCk7CiAgfSBlbHNlIGlmIChudW0xLm1heCA8PSBtYXgpIHsKICAgIHJldHVybiBudW0xOwogIH0KICByZXR1cm4gbmV3IEFzdE1pbihudW0xLCBtYXgpOwp9CmNsYXNzIFBvc3RTY3JpcHRDb21waWxlciB7CiAgY29tcGlsZShjb2RlLCBkb21haW4sIHJhbmdlKSB7CiAgICBjb25zdCBzdGFjayA9IFtdOwogICAgY29uc3QgaW5zdHJ1Y3Rpb25zID0gW107CiAgICBjb25zdCBpbnB1dFNpemUgPSBkb21haW4ubGVuZ3RoID4+IDEsCiAgICAgIG91dHB1dFNpemUgPSByYW5nZS5sZW5ndGggPj4gMTsKICAgIGxldCBsYXN0UmVnaXN0ZXIgPSAwOwogICAgbGV0IG4sIGo7CiAgICBsZXQgbnVtMSwgbnVtMiwgYXN0MSwgYXN0MiwgdG1wVmFyLCBpdGVtOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpbnB1dFNpemU7IGkrKykgewogICAgICBzdGFjay5wdXNoKG5ldyBBc3RBcmd1bWVudChpLCBkb21haW5baSAqIDJdLCBkb21haW5baSAqIDIgKyAxXSkpOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29kZS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgIGl0ZW0gPSBjb2RlW2ldOwogICAgICBpZiAodHlwZW9mIGl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgc3RhY2sucHVzaChuZXcgQXN0TGl0ZXJhbChpdGVtKSk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChpdGVtKSB7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjdnIiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtdWwiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBudW0yID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBudW0xID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTXVsT3BlcmF0aW9uKG51bTEsIG51bTIpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInN1YiI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIG51bTIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG51bTEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXhjaCI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIGFzdDEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGFzdDIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYXN0MSwgYXN0Mik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJwb3AiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImluZGV4IjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKG4pIHx8IHN0YWNrLmxlbmd0aCA8IG4pIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gbiAtIDFdOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSBuIC0gMV0gPSB0bXBWYXI7CiAgICAgICAgICBzdGFjay5wdXNoKHRtcFZhcik7CiAgICAgICAgICBpbnN0cnVjdGlvbnMucHVzaChuZXcgQXN0VmFyaWFibGVEZWZpbml0aW9uKHRtcFZhciwgYXN0MSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZHVwIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBjb2RlW2kgKyAxXSA9PT0gIm51bWJlciIgJiYgY29kZVtpICsgMl0gPT09ICJndCIgJiYgY29kZVtpICsgM10gPT09IGkgKyA3ICYmIGNvZGVbaSArIDRdID09PSAianoiICYmIGNvZGVbaSArIDVdID09PSAicG9wIiAmJiBjb2RlW2kgKyA2XSA9PT0gY29kZVtpICsgMV0pIHsKICAgICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTWluT3BlcmF0aW9uKG51bTEsIGNvZGVbaSArIDFdKSk7CiAgICAgICAgICAgIGkgKz0gNjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSAxXSA9IHRtcFZhcjsKICAgICAgICAgIHN0YWNrLnB1c2godG1wVmFyKTsKICAgICAgICAgIGluc3RydWN0aW9ucy5wdXNoKG5ldyBBc3RWYXJpYWJsZURlZmluaXRpb24odG1wVmFyLCBhc3QxKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyb2xsIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTIudHlwZSAhPT0gImxpdGVyYWwiIHx8IG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IG51bTIubnVtYmVyOwogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPD0gMCB8fCAhTnVtYmVyLmlzSW50ZWdlcihuKSB8fCAhTnVtYmVyLmlzSW50ZWdlcihqKSB8fCBzdGFjay5sZW5ndGggPCBuKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IChqICUgbiArIG4pICUgbjsKICAgICAgICAgIGlmIChqID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgc3RhY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kVUIiwgIkFOIiwgIkFOIiwgIkFMIiwgIkFMIiwgIkFMIiwgIk5TTSIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQU4iLCAiT04iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQUwiLCAiQUwiLCAiTlNNIiwgIk5TTSIsICJPTiIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQUwiLCAiQUwiLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU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5cGVzW2kgLSAxXTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJFTiIpIHsKICAgICAgZm9yIChsZXQgaiA9IGkgLSAxOyBqID49IDA7IC0taikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gaSArIDE7IGogPCBzdHJMZW5ndGg7ICsraikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgfQogIH0KICBmb3IgKGkgPSAwOyBpIDwgc3RyTGVuZ3RoOyArK2kpIHsKICAgIHQgPSB0eXBlc1tpXTsKICAgIGlmICh0ID09PSAiV1MiIHx8IHQgPT09ICJFUyIgfHwgdCA9PT0gIkVUIiB8fCB0ID09PSAiQ1MiKSB7CiAgICAgIHR5cGVzW2ldID0gIk9OIjsKICAgIH0KICB9CiAgbGFzdFR5cGUgPSBzb3I7CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAodCA9PT0gIkVOIikgewogICAgICB0eXBlc1tpXSA9IGxhc3RUeXBlID09PSAiTCIgPyAiTCIgOiAiRU4iOwogICAgfSBlbHNlIGlmICh0ID09PSAiUiIgfHwgdCA9PT0gIkwiKSB7CiAgICAgIGxhc3RUeXBlID0gdDsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJPTiIpIHsKICAgICAgY29uc3QgZW5kID0gZmluZFVuZXF1YWwodHlwZXMsIGkgKyAxLCAiT04iKTsKICAgICAgbGV0IGJlZm9yZSA9IHNvcjsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgYmVmb3JlID0gdHlwZXNbaSAtIDFdOwogICAgICB9CiAgICAgIGxldCBhZnRlciA9IGVvcjsKICAgICAgaWYgKGVuZCArIDEgPCBzdHJMZW5ndGgpIHsKICAgICAgICBhZnRlciA9IHR5cGVzW2VuZCArIDFdOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgIT09ICJMIikgewogICAgICAgIGJlZm9yZSA9ICJSIjsKICAgICAgfQogICAgICBpZiAoYWZ0ZXIgIT09ICJMIikgewogICAgICAgIGFmdGVyID0gIlIiOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgPT09IGFmdGVyKSB7CiAgICAgICAgc2V0VmFsdWVzKHR5cGVzLCBpLCBlbmQsIGJlZm9yZSk7CiAgICAgIH0KICAgICAgaSA9IGVuZCAtIDE7CiAgICB9CiAgfQogIGZvciAoaSA9IDA7IGkgPCBzdHJMZW5ndGg7ICsraSkgewogICAgaWYgKHR5cGVzW2ldID09PSAiT04iKSB7CiAgICAgIHR5cGVzW2ldID0gZTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAoaXNFdmVuKGxldmVsc1tpXSkpIHsKICAgICAgaWYgKHQgPT09ICJSIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9IGVsc2UgaWYgKHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAyOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBpZiAodCA9PT0gIkwiIHx8IHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9CiAgICB9CiAgfQogIGxldCBoaWdoZXN0TGV2ZWwgPSAtMTsKICBsZXQgbG93ZXN0T2RkTGV2ZW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HJldHVybiBpbWdEYXRhOwogIH0KICBfZW5jb2RlQk1QKCkgewogICAgY29uc3QgewogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBraW5kCiAgICB9ID0gdGhpcy5faW1nRGF0YTsKICAgIGxldCBkYXRhID0gdGhpcy5faW1nRGF0YS5kYXRhOwogICAgbGV0IGJpdFBlclBpeGVsOwogICAgbGV0IGNvbG9yVGFibGUgPSBuZXcgVWludDhBcnJheSgwKTsKICAgIGxldCBtYXNrVGFibGUgPSBjb2xvclRhYmxlOwogICAgbGV0IGNvbXByZXNzaW9uID0gMDsKICAgIHN3aXRjaCAoa2luZCkgewogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICB7CiAgICAgICAgICBiaXRQZXJQaXhlbCA9IDE7CiAgICAgICAgICBjb2xvclRhYmxlID0gbmV3IFVpbnQ4QXJyYXkodGhpcy5faXNNYXNrID8gWzI1NSwgMjU1LCAyNTUsIDI1NSwgMCwgMCwgMCwgMF0gOiBbMCwgMCwgMCwgMCwgMjU1LCAyNTUsIDI1NSwgMjU1XSk7CiAgICAgICAgICBjb25zdCByb3dMZW4gPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgIGNvbnN0IHJvd1NpemUgPSByb3dMZW4gKyAzICYgLTQ7CiAgICAgICAgICBpZiAocm93TGVuICE9PSByb3dTaXplKSB7CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4sIGsgKz0gcm93U2l6ZSkgewogICAgICAgICAgICAgIG5ld0RhdGEuc2V0KGRhdGEuc3ViYXJyYXkoaSwgaSArIHJvd0xlbiksIGspOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgewogICAgICAgICAgYml0UGVyUGl4ZWwgPSAyNDsKICAgICAgICAgIGlmICh3aWR0aCAmIDMpIHsKICAgICAgICAgICAgY29uc3Qgcm93TGVuID0gMyAqIHdpZHRoOwogICAgICAgICAgICBjb25zdCByb3dTaXplID0gcm93TGVuICsgMyAmIC00OwogICAgICAgICAgICBjb25zdCBleHRyYUxlbiA9IHJvd1NpemUgLSByb3dMZW47CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4pIHsKICAgICAgICAgICAgICBjb25zdCByb3cgPSBkYXRhLnN1YmFycmF5KGksIGkgKyByb3dMZW4pOwogICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgcm93TGVuOyBqICs9IDMpIHsKICAgICAgICAgICAgICAgIG5ld0RhdGFbaysrXSA9IHJvd1tqICsgMl07CiAgICAgICAgICAgICAgICBuZXdEYXRhW2srK10gPSByb3dbaiArIDFdOwogICAgICAgICAgICAgICAgbmV3RGF0YVtrKytdID0gcm93W2pdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBrICs9IGV4dHJhTGVuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGF0YS5sZW5ndGg7IGkgPCBpaTsgaSArPSAzKSB7CiAgICAgICAgICAgICAgY29uc3QgdG1wID0gZGF0YVtpXTsK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21wb25lbnQpIHsKICAgICAgYml0c1BlckNvbXBvbmVudCA9IGRpY3QuZ2V0KCJCUEMiLCAiQml0c1BlckNvbXBvbmVudCIpOwogICAgICBpZiAoIWJpdHNQZXJDb21wb25lbnQpIHsKICAgICAgICBpZiAodGhpcy5pbWFnZU1hc2spIHsKICAgICAgICAgIGJpdHNQZXJDb21wb25lbnQgPSAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEJpdHMgcGVyIGNvbXBvbmVudCBtaXNzaW5nIGluIGltYWdlOiAke3RoaXMuaW1hZ2VNYXNrfWApOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgdGhpcy5icGMgPSBiaXRzUGVyQ29tcG9uZW50OwogICAgaWYgKCF0aGlzLmltYWdlTWFzaykgewogICAgICBsZXQgY29sb3JTcGFjZSA9IGRpY3QuZ2V0UmF3KCJDUyIpIHx8IGRpY3QuZ2V0UmF3KCJDb2xvclNwYWNlIik7CiAgICAgIGlmICghY29sb3JTcGFjZSkgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSlBYIGltYWdlcyAod2hpY2ggZG8gbm90IHJlcXVpcmUgY29sb3Igc3BhY2VzKSIpOwogICAgICAgIHN3aXRjaCAoaW1hZ2UubnVtQ29tcHMpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VHcmF5Iik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICBjb2xvclNwYWNlID0gX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkRldmljZVJHQiIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VDTVlLIik7CiAgICAgICAgIC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XcgUERGSW1hZ2UoewogICAgICAgICAgICB4cmVmLAogICAgICAgICAgICByZXMsCiAgICAgICAgICAgIGltYWdlOiBtYXNrLAogICAgICAgICAgICBpc0lubGluZSwKICAgICAgICAgICAgaXNNYXNrOiB0cnVlLAogICAgICAgICAgICBwZGZGdW5jdGlvbkZhY3RvcnksCiAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5tYXNrID0gbWFzazsKICAgICAgfQogICAgfQogIH0KICBzdGF0aWMgYXN5bmMgYnVpbGRJbWFnZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgcmVzLAogICAgICBpbWFnZSwKICAgICAgaXNJbmxpbmUgPSBmYWxzZSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSA9IF9yZWYyOwogICAgY29uc3QgaW1hZ2VEYXRhID0gaW1hZ2U7CiAgICBsZXQgc21hc2tEYXRhID0gbnVsbDsKICAgIGxldCBtYXNrRGF0YSA9IG51bGw7CiAgICBjb25zdCBzbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJTTWFzayIpOwogICAgY29uc3QgbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJNYXNrIik7CiAgICBpZiAoc21hc2spIHsKICAgICAgaWYgKHNtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBzbWFza0RhdGEgPSBzbWFzazsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIC9TTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAobWFzaykgewogICAgICBpZiAobWFzayBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtIHx8IEFycmF5LmlzQXJyYXkobWFzaykpIHsKICAgICAgICBtYXNrRGF0YSA9IG1hc2s7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbnN1cHBvcnRlZCAvTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBuZXcgUERGSW1hZ2UoewogICAgICB4cmVmLAogICAgICByZXMsCiAgICAgIGltYWdlOiBpbWFnZURhdGEsCiAgICAgIGlzSW5saW5lLAogICAgICBzbWFzazogc21hc2tEYXRhLAogICAgICBtYXNrOiBtYXNrRGF0YSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSk7CiAgfQogIHN0YXRpYyBjcmVhdGVSYXdNYXNrKF9yZWYzKSB7CiAgICBsZXQgewogICAgICBpbWdBcnJheSwKICAgICAgd2lkdGgsCiAgICAgIGhlaWdodCwKICAgICAgaW1hZ2VJc0Zyb21EZWNvZGVTdHJlYW0sCiAgICAgIGludmVyc2VEZWNvZGUsCiAgICAgIGludGVycG9sYXRlCiAgICB9ID0gX3JlZjM7CiAgICBjb25zdCBjb21wdXRlZExlbmd0aCA9ICh3aWR0aCArIDcgPj4gMykgKiBoZWlnaHQ7CiAgICBjb25zdCBhY3R1YWxMZW5ndGggPSBpbWdBcnJheS5ieXRlTGVuZ3RoOwogICAgY29uc3QgaGF2ZUZ1bGxEYXRhID0gY29tcHV0ZWRMZW5ndGggPT09IGFjdHVhbExlbmd0aDsKICAgIGxldCBkYXRhLCBpOwogICAgaWYgKGltYWdlSXNGcm9tRGVjb2RlU3RyZWFtICYmICghaW52ZXJzZURlY29kZSB8fCBoYXZlRnVsbERhdGEpKSB7CiAgICAgIGRhdGEgPSBpbWdBcnJheTsKICAgIH0gZWxzZSBpZiAoIWludmVyc2VEZWNvZGUpIHsKICAgICAgZGF0YSA9IG5ldyBVaW50OEFycmF5KGltZ0FycmF5KTsKICAgI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EltYWdlRGF0YShpbWdEYXRhLCAwLCAwKTsKICAgICAgY29uc3QgYml0bWFwID0gY2FudmFzLnRyYW5zZmVyVG9JbWFnZUJpdG1hcCgpOwogICAgICByZXR1cm4gewogICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIGludGVycG9sYXRlLAogICAgICAgIGJpdG1hcAogICAgICB9OwogICAgfQogICAgcmV0dXJuIHRoaXMuY3JlYXRlUmF3TWFzayh7CiAgICAgIGltZ0FycmF5LAogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBpbnZlcnNlRGVjb2RlLAogICAgICBpbWFnZUlzRnJvbURlY29kZVN0cmVhbSwKICAgICAgaW50ZXJwb2xhdGUKICAgIH0pOwogIH0KICBnZXQgZHJhd1dpZHRoKCkgewogICAgcmV0dXJuIE1hdGgubWF4KHRoaXMud2lkdGgsIHRoaXMuc21hc2sgJiYgdGhpcy5zbWFzay53aWR0aCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLndpZHRoIHx8IDApOwogIH0KICBnZXQgZHJhd0hlaWdodCgpIHsKICAgIHJldHVybiBNYXRoLm1heCh0aGlzLmhlaWdodCwgdGhpcy5zbWFzayAmJiB0aGlzLnNtYXNrLmhlaWdodCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLmhlaWdodCB8fCAwKTsKICB9CiAgZGVjb2RlQnVmZmVyKGJ1ZmZlcikgewogICAgY29uc3QgYnBjID0gdGhpcy5icGM7CiAgICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICBjb25zdCBkZWNvZGVBZGRlbmRzID0gdGhpcy5kZWNvZGVBZGRlbmRzOwogICAgY29uc3QgZGVjb2RlQ29lZmZpY2llbnRzID0gdGhpcy5kZWNvZGVDb2VmZmljaWVudHM7CiAgICBjb25zdCBtYXggPSAoMSA8PCBicGMpIC0gMTsKICAgIGxldCBpLCBpaTsKICAgIGlmIChicGMgPT09IDEpIHsKICAgICAgZm9yIChpID0gMCwgaWkgPSBidWZmZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGJ1ZmZlcltpXSA9ICshYnVmZmVyW2ldOwogICAgICB9CiAgICAgIHJldHVybjsKICAgIH0KICAgIGxldCBpbmRleCA9IDA7CiAgICBmb3IgKGkgPSAwLCBpaSA9IHRoaXMud2lkdGggKiB0aGlzLmhlaWdodDsgaSA8IGlpOyBpKyspIHsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBudW1Db21wczsgaisrKSB7CiAgICAgICAgYnVmZmVyW2luZGV4XSA9IGRlY29kZUFuZENsYW1wKGJ1ZmZlcltpbmRleF0sIGRlY29kZUFkZGVuZHNbal0sIGRlY29kZUNvZWZmaWNpZW50c1tqXSwgbWF4KTsKICAgICAgICBpbmRleCsrOwogICAgICB9CiAgICB9CiAgfQogIGdldENvbXBvbmVudHMoYnVmZmVyKSB7CiAgICBjb25zdCBicGMgPSB0aGlzLmJwYzsKICAgIGlmIChicGMgPT09IDgpIHsKICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgIH0KICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDsKICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0OwogICAgY29uc3QgbnVtQ29tcHMgPSB0aGlzLm51bUNvbXBzOwogICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiBudW1Db21wczsKICAgIGxldCBidWZmZXJQb3MgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGlmIChicGMgPD0gOCkgewogICAgICBvdXRwdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgfSBlbHNlIGlmIChicGMgPD0gMTYpIHsKICAgICAgb3V0cHV0ID0gbmV3IFVpbnQxNkFycmF5KGxlbmd0aCk7CiAgICB9IGVsc2UgewogICAgICBvdXRwdXQgPSBuZXcgVWludDMyQXJyYXkobGVuZ3RoKTsKICAgIH0KICAgIGNvbnN0IHJvd0NvbXBzID0gd2lkdGggKiBudW1Db21wczsKICAgIGNvbnN0IG1heCA9ICgxIDw8IGJwYykgLSAxOwogICAgbGV0IGkgPSAwLAogICAgICBpaSwKICAgICAgYnVmOwogICAgaWYgKGJwYyA9PT0gMSkgewogICAgICBsZXQgbWFzaywgbG9vcDFFbmQsIGxvb3AyRW5kOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGhlaWdodDsgaisrKSB7CiAgICAgICAgbG9vcDFFbmQgPSBpICsgKHJvd0NvbXBzICYgfjcpOwogICAgICAgIGxvb3AyRW5kID0gaSArIHJvd0NvbXBzOwogICAgICAgIHdoaWxlIChpIDwgbG9vcDFFbmQpIHsKICAgICAgICAgIGJ1ZiA9IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBvdXRwdXRbaV0gPSBidWYgPj4gNyAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDFdID0gYnVmID4+IDYgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyAyXSA9IGJ1ZiA+PiA1ICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgM10gPSBidWYgPj4gNCAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDRdID0gYnVmID4+IDMgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyA1XSA9IGJ1ZiA+PiAyICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgNl0gPSBidWYgPj4gMSAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDddID0gYnVmICYgMTsKICAgICAgICAgIGkgKz0gODsKICAgICAgICB9CiAgICAgICAgaWYgKGkgPCBsb29wMkVuZCkgewogICAgICAgICAgYnVmID0gYnVmZmVyW2J1ZmZlclBvcysrXTsKICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICB3aGlsZSAoaSA8IGxvb3AyRW5kKSB7CiAgICAgICAgICAgIG91dHB1dFtpKytdID0gKyEhKGJ1ZiAmIG1hc2spOwogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IGJpdHMgPSAwOwogICAgICBidWYgPSAwOwogICAgICBmb3IgKGkgPSAwLCBpaSA9IGxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgICBpZiAoaSAlIHJvd0NvbXBzID09PSAwKSB7CiAgICAgICAgICBidWYgPSAwOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChiaXRzIDwgYnBjKSB7CiAgICAgICAgICBidWYgPSBidWYgPDwgOCB8IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHJlbWFpbmluZ0JpdHMgPSBiaXRzIC0gYnBjOwogICAgICAgIGxldCB2YWx1ZSA9IGJ1ZiA+PiByZW1haW5pbmdCaXRzOwogICAgICAgIGlmICh2YWx1ZSA8IDApIHsKICAgICAgICAgIHZhbHVlID0gMDsKICAgICAgICB9IGVsc2UgaWYgKHZhbHVlID4gbWF4KSB7CiAgICAgICAgICB2YWx1ZSA9IG1heDsKICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgICAgYnVmICY9ICgxIDw8IHJlbWFpbmluZ0JpdHMpIC0gMTsKICAgICAgICBiaXRzID0gcmVtYWluaW5nQml0czsKICAgICAgfQogICAgfQogICAgcmV0dXJuIG91dHB1dDsKICB9CiAgZmlsbE9wYWNpdHkocmdiYUJ1Ziwgd2lkdGgsIGhlaWdodCwgYWN0dWFsSGVpZ2h0LCBpbWFnZSkgewogICAgY29uc3Qgc21hc2sgPSB0aGlzLnNtYXNrOwogICAgY29uc3QgbWFzayA9IHRoaXMubWFzazsKICAgIGxldCBhbHBoYUJ1Ziwgc3csIHNoLCBpLCBpaSwgajsKICAgIGlmIChzbWFzaykgewogICAgICBz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ICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICAgICAgZm9yIChpID0gMCwgaWkgPSB3aWR0aCAqIGhlaWdodDsgaSA8IGlpOyArK2kpIHsKICAgICAgICAgIGxldCBvcGFjaXR5ID0gMDsKICAgICAgICAgIGNvbnN0IGltYWdlT2Zmc2V0ID0gaSAqIG51bUNvbXBzOwogICAgICAgICAgZm9yIChqID0gMDsgaiA8IG51bUNvbXBzOyArK2opIHsKICAgICAgICAgICAgY29uc3QgY29sb3IgPSBpbWFnZVtpbWFnZU9mZnNldCArIGpdOwogICAgICAgICAgICBjb25zdCBtYXNrT2Zmc2V0ID0gaiAqIDI7CiAgICAgICAgICAgIGlmIChjb2xvciA8IG1hc2tbbWFza09mZnNldF0gfHwgY29sb3IgPiBtYXNrW21hc2tPZmZzZXQgKyAxXSkgewogICAgICAgICAgICAgIG9wYWNpdHkgPSAyNTU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGFscGhhQnVmW2ldID0gb3BhY2l0eTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIG1hc2sgZm9ybWF0LiIpOwogICAgICB9CiAgICB9CiAgICBpZiAoYWxwaGFCdWYpIHsKICAgICAgZm9yIChpID0gMCwgaiA9IDMsIGlpID0gd2lkdGggKiBhY3R1YWxIZWlnaHQ7IGkgPCBpaTsgKytpLCBqICs9IDQpIHsKICAgICAgICByZ2JhQnVmW2pdID0gYWxwaGFCdWZbaV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAoaSA9IDAsIGogPSAzLCBpaSA9IHdpZHRoICogYWN0dWFsSGVpZ2h0OyBpIDwgaWk7ICsraSwgaiArPSA0KSB7CiAgICAgICAgcmdiYUJ1ZltqXSA9IDI1NTsKICAgICAgfQogICAgfQogIH0KICB1bmRvUH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AgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJEZXZpY2VDTVlLIjoKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGlzSGFuZGxlZCkgewogICAgICAgICAgICBjb25zdCByZ2JhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKGltYWdlTGVuZ3RoLCB7CiAgICAgICAgICAgICAgZHJhd1dpZHRoLAogICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgZm9yY2VSR0JBOiB0cnVlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gdGhpcy5jcmVhdGVCaXRtYXAoX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFAsIGRyYXdXaWR0aCwgZHJhd0hlaWdodCwgcmdiYSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN3aXRjaCAodGhpcy5jb2xvclNwYWNlLm5hbWUpIHsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlR3JheSI6CiAgICAgICAgICAgICAgaW1hZ2VMZW5ndGggKj0gMzsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgICAgY2FzZSAiRGV2aWNlQ01ZSyI6CiAgICAgICAgICAgICAgaW1nRGF0YS5raW5kID0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDsKICAgICAgICAgICAgICBpbWdEYXRhLmRhdGEgPSB0aGlzLmdldEltYWdlQnl0ZXMoaW1hZ2VMZW5ndGgsIHsKICAgICAgICAgICAgICAgIGRyYXdXaWR0aCwKICAgICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgICBmb3JjZVJHQjogdHJ1ZQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIGlmIChtdXN0QmVSZXNpemVkKSB7CiAgICAgICAgICAgICAgICByZXR1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ICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgY2FzZSAiYW1wIjoKICAgICAgICAgIHJldHVybiAiJiI7CiAgICAgICAgY2FzZSAicXVvdCI6CiAgICAgICAgICByZXR1cm4gJyInOwogICAgICAgIGNhc2UgImFwb3MiOgogICAgICAgICAgcmV0dXJuICInIjsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5vblJlc29sdmVFbnRpdHkoZW50aXR5KTsKICAgIH0pOwogIH0KICBfcGFyc2VDb250ZW50KHMsIHN0YXJ0KSB7CiAgICBjb25zdCBhdHRyaWJ1dGVzID0gW107CiAgICBsZXQgcG9zID0gc3RhcnQ7CiAgICBmdW5jdGlvbiBza2lwV3MoKSB7CiAgICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiBpc1doaXRlc3BhY2UocywgcG9zKSkgewogICAgICAgICsrcG9zOwogICAgICB9CiAgICB9CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj4iICYmIHNbcG9zXSAhPT0gIi8iKSB7CiAgICAgICsrcG9zOwogICAgfQogICAgY29uc3QgbmFtZSA9IHMuc3Vic3RyaW5nKHN0YXJ0LCBwb3MpOwogICAgc2tpcFdzKCk7CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiLyIgJiYgc1twb3NdICE9PSAiPyIpIHsKICAgICAgc2tpcFdzKCk7CiAgICAgIGxldCBhdHRyTmFtZSA9ICIiLAogICAgICAgIGF0dHJWYWx1ZSA9ICIiOwogICAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj0iKSB7CiAgICAgICAgYXR0ck5hbWUgKz0gc1twb3NdOwogICAgICAgICsrcG9zOwogICAgICB9CiAgICAgIHNraXBXcygpOwogICAgICB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PiIgJiYgc1twb3NdICE9PSAiPyIgJiYgc1twb3NdICE9PSAiLyIpIHsKICAgICAgKytwb3M7CiAgICB9CiAgICBjb25zdCBuYW1lID0gcy5zdWJzdHJpbmcoc3RhcnQsIHBvcyk7CiAgICBza2lwV3MoKTsKICAgIGNvbnN0IGF0dHJTdGFydCA9IHBvczsKICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiAoc1twb3NdICE9PSAiPyIgfHwgc1twb3MgKyAxXSAhPT0gIj4iKSkgewogICAgICArK3BvczsKICAgIH0KICAgIGNvbnN0IHZhbHVlID0gcy5zdWJzdHJpbmcoYXR0clN0YXJ0LCBwb3MpOwogICAgcmV0dXJuIHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUsCiAgICAgIHBhcnNlZDogcG9zIC0gc3RhcnQKICAgIH07CiAgfQogIHBhcnNlWG1sKHMpIHsKICAgIGxldCBpID0gMDsKICAgIHdoaWxlIChpIDwgcy5sZW5ndGgpIHsKICAgICAgY29uc3QgY2ggPSBzW2ldOwogICAgICBsZXQgaiA9IGk7CiAgICAgIGlmIChjaCA9PT0gIjwiKSB7CiAgICAgICAgKytqOwogICAgICAgIGNvbnN0IGNoMiA9IHNbal07CiAgICAgICAgbGV0IHE7CiAgICAgICAgc3dpdGNoIChjaDIpIHsKICAgICAgICAgIGNhc2UgIi8iOgogICAgICAgICAgICArK2o7CiAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqKTsKICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkVuZEVsZW1lbnQocy5zdWJzdHJpbmcoaiwgcSkpOwogICAgICAgICAgICBqID0gcSArIDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiPyI6CiAgICAgICAgICAgICsrajsKICAgICAgICAgICAgY29uc3QgcGkgPSB0aGlzLl9wYXJzZVByb2Nlc3NpbmdJbnN0cnVjdGlvbihzLCBqKTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBwaS5wYXJzZWQsIGogKyBwaS5wYXJzZWQgKyAyKSAhPT0gIj8+IikgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuVW50ZXJtaW5hdGVkWG1sRGVjbGFyYXRpb24pOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLm9uUGkocGkubmFtZSwgcGkudmFsdWUpOwogICAgICAgICAgICBqICs9IHBpLnBhcnNlZCArIDI7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiISI6CiAgICAgICAgICAgIGlmIChzLnN1YnN0cmluZyhqICsgMSwgaiArIDMpID09PSAiLS0iKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiLS0+IiwgaiArIDMpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDb21tZW50KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNvbW1lbnQocy5zdWJzdHJpbmcoaiArIDMsIHEpKTsKICAgICAgICAgICAgICBqID0gcSArIDM7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIDEsIGogKyA4KSA9PT0gIltDREFUQVsiKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiXV0+IiwgaiArIDgpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDZGF0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNkYXRhKHMuc3Vic3RyaW5nKGogKyA4LCBxKSk7CiAgICAgICAgICAgICAgaiA9IHEgKyAzOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMuc3Vic3RyaW5nKGogKyAxLCBqICsgOCkgPT09ICJET0NUWVBFIikgewogICAgICAgICAgICAgIGNvbnN0IHEyID0gcy5pbmRleE9mKCJbIiwgaiArIDgpOwogICAgICAgICAgICAgIGxldCBjb21wbGV4RG9jdHlwZSA9IGZhbHNlOwogICAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqICsgOCk7CiAgICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChxMiA+IDAgJiYgcSA+IHEyKSB7CiAgICAgICAgICAgICAgICBxID0gcy5pbmRleE9mKCJdPiIsIGogKyA4KTsKICAgICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbXBsZXhEb2N0eXBlID0gdHJ1ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZG9jdHlwZUNvbnRlbnQgPSBzLnN1YnN0cmluZyhqICsgOCwgcSArIChjb21wbGV4RG9jdHlwZSA/IDEgOiAwKSk7CiAgICAgICAgICAgICAgdGhpcy5vbkRvY3R5cGUoZG9jdHlwZUNvbnRlbnQpOwogICAgICAgICAgICAgIGogPSBxICsgKGNvbXBsZXhEb2N0eXBlID8gMiA6IDEpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuTWFsZm9ybWVkRWxlbWVudCk7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgY29uc3QgY29udGVudCA9IHRoaXMuX3BhcnNlQ29udGVudChzLCBqKTsKICAgICAgICAgICAgaWYgKGNvbnRlbnQgPT09IG51bGwpIHsKICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLk1hbGZvcm1lZEVsZW1lbnQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaXNDbG9zZWQgPSBmYWxzZTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBjb250ZW50LnBhcnNlZCwgaiArIGNvbnRlbnQucGFyc2VkICsgMikgPT09ICIvPiIpIHsKICAgICAgICAgICAgICBpc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIGNvbnRlbnQucGFyc2VkLCBqICsgY29udGVudC5wYXJzZWQgKyAxKSAhPT0gIj4iKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkJlZ2luRWxlbWVudChjb250ZW50Lm5hbWUsIGNvbnRlbnQuYXR0cmlidXRlcywgaXNDbG9zZWQpOwogICAgICAgICAgICBqICs9IGNvb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0gbm9kZS5ub2RlTmFtZSkgewogICAgICAgIGlmIChjb21wb25lbnQucG9zID09PSAwKSB7CiAgICAgICAgICBjb25zdCByZXMgPSBub2RlLnNlYXJjaE5vZGUocGF0aHMsIHBvcyArIDEpOwogICAgICAgICAgaWYgKHJlcyAhPT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm4gcmVzOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgW3BhcmVudF0gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGxldCBzaWJsaW5nUG9zID0gMDsKICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgcGFyZW50LmNoaWxkTm9kZXMpIHsKICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5uYW1lID09PSBjaGlsZC5ub2RlTmFtZSkgewogICAgICAgICAgICAgIGlmIChzaWJsaW5nUG9zID09PSBjb21wb25lbnQucG9zKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gY2hpbGQuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNpYmxpbmdQb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5vZGUuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChub2RlLmNoaWxkTm9kZXMgJiYgbm9kZS5jaGlsZE5vZGVzLmxlbmd0aCAhPT0gMCkgewogICAgICAgIHN0YWNrLnB1c2goW25vZGUsIDBdKTsKICAgICAgICBub2RlID0gbm9kZS5jaGlsZE5vZGVzWzBdOwogICAgICB9IGVsc2UgaWYgKHN0YWNrLmxlbmd0aCA9PT0gMCkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9IGVsc2UgewogICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGN1cnJlbnRQb3NdID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBjb25zdCBuZXdQb3MgPSBjdXJyZW50UG9zICsgMTsKICAgICAgICAgIGlmIChuZXdQb3MgPCBwYXJlbnQuY2hpbGROb2Rlcy5sZW5ndGgpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChbcGFyZW50LCBuZXdQb3NdKTsKICAgICAgICAgICAgbm9kZSA9IHBhcmVudC5jaGlsZE5vZGVzW25ld1Bvc107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgZHVtcChidWZmZXIpIHsKICAgIGlmICh0aGlzLm5vZGVOYW1lID09PSAiI3RleHQiKSB7CiAgICAgIGJ1ZmZlci5wdXNoKCgwLCBfY29yZV91dGlscy5lbmNvZGVUb1htbFN0cmluZykodGhpcy5ub2RlVmFsdWUpKTsKICAgICAgcmV0dXJuOwogICAgfQogICAgYnVmZmVyLnB1c2goYDwke3RoaXMubm9kZU5hbWV9YCk7CiAgICBpZiAodGhpcy5hdHRyaWJ1dGVzKSB7CiAgICAgIGZvciAoY29uc3QgYXR0cmlidXRlIG9mIHRoaXMuYXR0cmlidXRlcykgewogICAgICAgIGJ1ZmZlci5wdXNoKGAgJHthdHRyaWJ1dGUubmFtZX09IiR7KDAsIF9jb3JlX3V0aWxzLmVuY29kZVRvWG1sU3RyaW5nKShhdHRyaWJ1dGUudmFsdWUpfSJgKTsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMuaGFzQ2hpbGROb2RlcygpKSB7CiAgICAgIGJ1ZmZlci5wdXNoKCI+Iik7CiAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgdGhpcy5j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ICAgYiA9IGgxLAogICAgICAgIGMgPSBoMiwKICAgICAgICBkID0gaDMsCiAgICAgICAgZiwKICAgICAgICBnOwogICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7ICsraikgewogICAgICAgIGlmIChqIDwgMTYpIHsKICAgICAgICAgIGYgPSBiICYgYyB8IH5iICYgZDsKICAgICAgICAgIGcgPSBqOwogICAgICAgIH0gZWxzZSBpZiAoaiA8IDMyKSB7CiAgICAgICAgICBmID0gZCAmIGIgfCB+ZCAmIGM7CiAgICAgICAgICBnID0gNSAqIGogKyAxICYgMTU7CiAgICAgICAgfSBlbHNlIGlmIChqIDwgNDgpIHsKICAgICAgICAgIGYgPSBiIF4gYyBeIGQ7CiAgICAgICAgICBnID0gMyAqIGogKyA1ICYgMTU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGYgPSBjIF4gKGIgfCB+ZCk7CiAgICAgICAgICBnID0gNyAqIGogJiAxNTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdG1wID0gZCwKICAgICAgICAgIHJvdGF0ZUFyZyA9IGEgKyBmICsga1tqXSArIHdbZ10gfCAwLAogICAgICAgICAgcm90YXRlID0gcltqXTsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYiArIChyb3RhdGVBcmcgPDwgcm90YXRlIHwgcm90YXRlQXJnID4+PiAzMiAtIHJvdGF0ZSkgfCAwOwogICAgICAgIGEgPSB0bXA7CiAgICAgIH0KICAgICAgaDAgPSBoMCArIGEgfCAwOwogICAgICBoMSA9IGgxICsgYiB8IDA7CiAgICAgIGgyID0gaDIgKyBjIHwgMDsKICAgICAgaDMgPSBoMyArIGQgfCAwOwogICAgfQogICAgcmV0dXJuIG5ldyBVaW50OEFycmF5KFtoMCAmIDB4RkYsIGgwID4+IDggJiAweEZGLCBoMCA+PiAxNiAmIDB4RkYsIGgwID4+PiAyNCAmIDB4RkYsIGgxICYgMHhGRiwgaDEgPj4gOCAmIDB4RkYsIGgxID4+I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hUHJpbWUodG1wMSwgZSwgdG1wMik7CiAgICAgICAgdDEuYWRkKHRtcDEpOwogICAgICAgIGNoKHRtcDEsIGUsIGYsIGcsIHRtcDIpOwogICAgICAgIHQxLmFkZCh0bXAxKTsKICAgICAgICB0MS5hZGQoa1tqXSk7CiAgICAgICAgdDEuYWRkKHdbal0pOwogICAgICAgIHNpZ21hKHQyLCBhLCB0bXAyKTsKICAgICAgICBtYWoodG1wMSwgYSwgYiwgYywgdG1wMik7CiAgICAgICAgdDIuYWRkKHRtcDEpOwogICAgICAgIHRtcDMgPSBoOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGQuYWRkKHQxKTsKICAgICAgICBlID0gZDsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYTsKICAgICAgICB0bXAzLmFzc2lnbih0MSk7CiAgICAgICAgdG1wMy5hZGQodDIpOwogICAgICAgIGEgPSB0bXAzOwogICAgICB9CiAgICAgIGgwLmFkZChhKTsKICAgICAgaDEuYWRkKGIpOwogICAgICBoMi5hZGQoYyk7CiAgICAgIGgzLmFkZChkKTsKICAgICAgaDQuYWRkKGUpOwogICAgICBoNS5hZGQoZik7CiAgICAgIGg2LmFkZChnKTsKICAgICAgaDcuYWRkKGgpOwogICAgfQogICAgbGV0IHJlc3VsdDsKICAgIGlmICghbW9kZTM4NCkgewogICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheSg2NCk7CiAgICAgIGgwLmNvcHlUbyhyZXN1bHQsIDApOwogICAgICBoMS5jb3B5VG8ocmVzdWx0LCA4KTsKICAgICAgaDIuY29weVRvKHJlc3VsdCwgMTYpOwogICAgICBoMy5jb3B5VG8ocmVzdWx0LCAyNCk7CiAgICAgIGg0LmNvcHlUbyhyZXN1bHQsIDMyKTsKICAgICAgaDUuY29weVRvKHJlc3VsdCwgNDApOwogICAgICBoNi5jb3B5VG8ocmVzdWx0LCA0OCk7CiAgICAgIGg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gICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7ICsraikgewogICAgICAgIHN0YXRlW2pdID0gc1tzdGF0ZVtqXV07CiAgICAgIH0KICAgICAgdiA9IHN0YXRlWzFdOwogICAgICBzdGF0ZVsxXSA9IHN0YXRlWzVdOwogICAgICBzdGF0ZVs1XSA9IHN0YXRlWzldOwogICAgICBzdGF0ZVs5XSA9IHN0YXRlWzEzXTsKICAgICAgc3RhdGVbMTNdID0gdjsKICAgICAgdiA9IHN0YXRlWzJdOwogICAgICB1ID0gc3RhdGVbNl07CiAgICAgIHN0YXRlWzJdID0gc3RhdGVbMTBdOwogICAgICBzdGF0ZVs2XSA9IHN0YXRlWzE0XTsKICAgICAgc3RhdGVbMTBdID0gdjsKICAgICAgc3RhdGVbMTRdID0gdTsKICAgICAgdiA9IHN0YXRlWzNdOwogICAgICB1ID0gc3RhdGVbN107CiAgICAgIHQgPSBzdGF0ZVsxMV07CiAgICAgIHN0YXRlWzNdID0gc3RhdGVbMTVdOwogICAgICBzdGF0ZVs3XSA9IHY7CiAgICAgIHN0YXRlWzExXSA9IHU7CiAgICAgIHN0YXRlWzE1XSA9IHQ7CiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7IGogKz0gNCkgewogICAgICAgIGNvbnN0IHMwID0gc3RhdGVbaiArIDBdOwogICAgICAgIGNvbnN0IHMxID0gc3RhdGVbaiArIDFdOwogICAgICAgIGNvbnN0IHMyID0gc3RhdGVbaiArIDJdOwogICAgICAgIGNvbnN0IHMzID0gc3RhdGVbaiArIDNdOwogICAgICAgIHQgPSBzMCBeIHMxIF4gczIgXiBzMzsKICAgICAgICBzdGF0ZVtqICsgMF0gXj0gdCBeIHRoaXMuX21peENvbFtzMCBeIHMxXTsKICAgICAgICBzdGF0ZVtqICsgMV0gXj0gdCBeIHRoaXMuX21peENvbFtzMSBeIHMyXTsKICAgICAgICBzdGF0ZVtqICsgMl0gXj0gdCBeIHRoaXMuX21peENvbFtzMiBeIHMzXTsKIC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GU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkXSk7CiAgICB0aGlzLl9rZXkgPSB0aGlzLl9leHBhbmRLZXkoa2V5KTsKICB9CiAgX2V4cGFuZEtleShjaXBoZXJLZXkpIHsKICAgIGNvbnN0IGIgPSAxNzY7CiAgICBjb25zdCBzID0gdGhpcy5fczsKICAgIGNvbnN0IHJjb24gPSB0aGlzLl9yY29uOwogICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkoYik7CiAgICByZXN1bHQuc2V0KGNpcGhlcktleSk7CiAgICBmb3IgKGxldCBqID0gMTYsIGkgPSAxOyBqIDwgYjsgKytpKSB7CiAgICAgIGxldCB0MSA9IHJlc3VsdFtqIC0gM107CiAgICAgIGxldCB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgIGxldCB0MyA9IHJlc3VsdFtqIC0gMV07CiAgICAgIGxldCB0NCA9IHJlc3VsdFtqIC0gNF07CiAgICAgIHQxID0gc1t0MV07CiAgICAgIHQyID0gc1t0Ml07CiAgICAgIHQzID0gc1t0M107CiAgICAgIHQ0ID0gc1t0NF07CiAgICAgIHQxIF49IHJjb25baV07CiAgICAgIGZvciAobGV0IG4gPSAwOyBuIDwgNDsgKytuKSB7CiAgICAgICAgcmVzdWx0W2pdID0gdDEgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQyIF49IHJlc3VsdFtqIC0gMTZdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0MyBePSByZXN1bHRbaiAtIDE2XTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDQgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzdWx0OwogIH0KfQpleHBvcnRzLkFFUzEyOENpcGhlciA9IEFFUzEyOENpcGhlcjsKY2xhc3MgQUVTMjU2Q2lwaGVyIGV4dGVuZHMgQUVTQmFzZUNpcGhlciB7CiAgY29uc3RydWN0b3Ioa2V5KSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5fY3ljbGVzT2ZSZXBldGl0aW9uID0gMTQ7CiAgICB0aGlzLl9rZXlTaXplID0gMjI0OwogICAgdGhpcy5fa2V5ID0gdGhpcy5fZXhwYW5kS2V5KGtleSk7CiAgfQogIF9leHBhbmRLZXkoY2lwaGVyS2V5KSB7CiAgICBjb25zdCBiID0gMjQwOwogICAgY29uc3QgcyA9IHRoaXMuX3M7CiAgICBjb25zdCByZXN1bHQgPSBuZXcgVWludDhBcnJheShiKTsKICAgIHJlc3VsdC5zZXQoY2lwaGVyS2V5KTsKICAgIGxldCByID0gMTsKICAgIGxldCB0MSwgdDIsIHQzLCB0NDsKICAgIGZvciAobGV0IGogPSAzMiwgaSA9IDE7IGogPCBiOyArK2kpIHsKICAgICAgaWYgKGogJSAzMiA9PT0gMTYpIHsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICB9IGVsc2UgaWYgKGogJSAzMiA9PT0gMCkgewogICAgICAgIHQxID0gcmVzdWx0W2ogLSAzXTsKICAgICAgICB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgICAgdDMgPSByZXN1bHRbaiAtIDFdOwogICAgICAgIHQ0ID0gcmVzdWx0W2ogLSA0XTsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICAgIHQxIF49IHI7CiAgICAgICAgaWYgKChyIDw8PSAxKSA+PSAyNTYpIHsKICAgICAgICAgIHIgPSAociBeIDB4MWIpICYgMHhmZjsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCA0OyArK24pIHsKICAgICAgICByZXN1bHRbal0gPSB0MSBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDIgXj0gcmVzdWx0W2ogLSAzMl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQzIF49IHJlc3VsdFtqIC0gMzJdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0NCBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByZXN1bHQ7CiAgfQp9CmV4cG9ydHMuQUVTMjU2Q2lwaGVyID0gQUVTMjU2Q2lwaGVyOwpjbGFzcyBQREYxNyB7CiAgY2hlY2tPd25lclBhc3N3b3JkKHBhc3N3b3JkLCBvd25lclZhbGlkYXRpb25TYWx0LCB1c2VyQnl0ZXMsIG93bmVyUGFzc3dvcmQpIHsKICAgIGNvbnN0IGhhc2hEYXRhID0gbmV3IFVpbnQ4QXJyYXkocGFzc3dvcm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yArK2opIHsKICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IG47ICsraykgewogICAgICAgICAgZGVyaXZlZEtleVtrXSA9IGVuY3J5cHRpb25LZXlba10gXiBqOwogICAgICAgIH0KICAgICAgICBjaXBoZXIgPSBuZXcgQVJDRm91ckNpcGhlcihkZXJpdmVkS2V5KTsKICAgICAgICBjaGVja0RhdGEgPSBjaXBoZXIuZW5jcnlwdEJsb2NrKGNoZWNrRGF0YSk7CiAgICAgIH0KICAgICAgZm9yIChqID0gMCwgbiA9IGNoZWNrRGF0YS5sZW5ndGg7IGogPCBuOyArK2opIHsKICAgICAgICBpZiAodXNlclBhc3N3b3JkW2pdICE9PSBjaGVja0RhdGFbal0pIHsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgY2lwaGVyID0gbmV3IEFSQ0ZvdXJDaXBoZXIoZW5jcnlwdGlvbktleSk7CiAgICAgIGNoZWNrRGF0YSA9IGNpcGhlci5lbmNyeXB0QmxvY2soZGVmYXVsdFBhc3N3b3JkQnl0ZXMpOwogICAgICBmb3IgKGogPSAwLCBuID0gY2hlY2tEYXRhLmxlbmd0aDsgaiA8IG47ICsraikgewogICAgICAgIGlmICh1c2VyUGFzc3dvcmRbal0gIT09IGNoZWNrRGF0YVtqXSkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW5jcnlwdGlvbktleTsKICB9CiAgZnVuY3Rpb24gZGVjb2RlVXNlclBhc3N3b3JkKHBhc3N3b3JkLCBvd25lclBhc3N3b3JkLCByZXZpc2lvbiwga2V5TGVuZ3RoKSB7CiAgICBjb25zdCBoYXNoRGF0YSA9IG5ldyBVaW50OEFycmF5KDMyKTsKICAgIGxldCBpID0gMDsKICAgIGNvbnN0IG4gPSBNYXRoLm1pbigzMiwgcGFzc3dvcmQubGVuZ3RoKTsKICAgIGZvciAoOyBpIDwgbj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ICAgIH0KICAgICAgdGhpcy5hbGdvcml0aG0gPSBhbGdvcml0aG07CiAgICAgIGxldCBrZXlMZW5ndGggPSBkaWN0LmdldCgiTGVuZ3RoIik7CiAgICAgIGlmICgha2V5TGVuZ3RoKSB7CiAgICAgICAgaWYgKGFsZ29yaXRobSA8PSAzKSB7CiAgICAgICAgICBrZXlMZW5ndGggPSA0MDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgY2ZEaWN0ID0gZGljdC5nZXQoIkNGIik7CiAgICAgICAgICBjb25zdCBzdHJlYW1DcnlwdG9OYW1lID0gZGljdC5nZXQoIlN0bUYiKTsKICAgICAgICAgIGlmIChjZkRpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0ICYmIHN0cmVhbUNyeXB0b05hbWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIGNmRGljdC5zdXBwcmVzc0VuY3J5cHRpb24gPSB0cnVlOwogICAgICAgICAgICBjb25zdCBoYW5kbGVyRGljdCA9IGNmRGljdC5nZXQoc3RyZWFtQ3J5cHRvTmFtZS5uYW1lKTsKICAgICAgICAgICAga2V5TGVuZ3RoID0gaGFuZGxlckRpY3QgJiYgaGFuZGxlckRpY3QuZ2V0KCJMZW5ndGgiKSB8fCAxMjg7CiAgICAgICAgICAgIGlmIChrZXlMZW5ndGggPCA0MCkgewogICAgICAgICAgICAgIGtleUxlbmd0aCA8PD0gMzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIU51bWJlci5pc0ludGVnZXIoa2V5TGVuZ3RoKSB8fCBrZXlMZW5ndGggPCA0MCB8fCBrZXlMZW5ndGggJSA4ICE9PSAwKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJpbnZhbGlkIGtleSBsZW5ndGgiKTsKICAgICAgfQogICAgICBjb25zdCBvd25lclBhc3N3b3JkID0g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B9CiAgICBjb25zdCByb290ID0gewogICAgICBpdGVtczogW10KICAgIH07CiAgICBjb25zdCBxdWV1ZSA9IFt7CiAgICAgIG9iaiwKICAgICAgcGFyZW50OiByb290CiAgICB9XTsKICAgIGNvbnN0IHByb2Nlc3NlZCA9IG5ldyBfcHJpbWl0aXZlcy5SZWZTZXQoKTsKICAgIHByb2Nlc3NlZC5wdXQob2JqKTsKICAgIGNvbnN0IHhyZWYgPSB0aGlzLnhyZWYsCiAgICAgIGJsYWNrQ29sb3IgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoMyk7CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBpID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29uc3Qgb3V0bGluZURpY3QgPSB4cmVmLmZldGNoSWZSZWYoaS5vYmopOwogICAgICBpZiAob3V0bGluZURpY3QgPT09IG51bGwpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIW91dGxpbmVEaWN0LmhhcygiVGl0bGUiKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBvdXRsaW5lIGl0ZW0gZW5jb3VudGVyZWQuIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YSA9IHsKICAgICAgICB1cmw6IG51bGwsCiAgICAgICAgZGVzdDogbnVsbCwKICAgICAgICBhY3Rpb246IG51bGwKICAgICAgfTsKICAgICAgQ2F0YWxvZy5wYXJzZURlc3REaWN0aW9uYXJ5KHsKICAgICAgICBkZXN0RGljdDogb3V0bGluZURpY3QsCiAgICAgICAgcmVzdWx0T2JqOiBkYXRhLAogICAgICAgIGRvY0Jhc2VVcmw6IHRoaXMucGRmTWFuYWdlci5kb2NCYXNlVXJsLAogICAgICAgIGRvY0F0dGFjaG1lbnRzOiB0aGlzLmF0dGFjaG1lbnRzCiAgICAgIH0pOwogICAgICBjb25zdCB0aXRsZSA9IG91dGxpbmVEaWN0LmdldCgiVGl0bGUiKTsKICAgICAgY29uc3QgZmxhZ3MgPSBvdXRsaW5lRGljdC5nZXQoIkYiKSB8fCAwOwogICAgICBjb25zdCBjb2xvciA9IG91dGxpbmVEaWN0LmdldEFycmF5KCJDIik7CiAgICAgIGNvbnN0IGNvdW50ID0gb3V0bGluZURpY3QuZ2V0KCJDb3VudCIpOwogICAgICBsZXQgcmdiQ29sb3IgPSBibGFja0NvbG9yOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2xvcikgJiYgY29sb3IubGVuZ3RoID09PSAzICYmIChjb2xvclswXSAhPT0gMCB8fCBjb2xvclsxXSAhPT0gMCB8fCBjb2xvclsyXSAhPT0gMCkpIHsKICAgICAgICByZ2JDb2xvciA9IF9jb2xvcnNwYWNlLkNvbG9yU3BhY2Uuc2luZ2xldG9ucy5yZ2IuZ2V0UmdiKGNvbG9yLCAwKTsKICAgICAgfQogICAgICBjb25zdCBvdXRsaW5lSXRlbSA9IHsKICAgICAgICBhY3Rpb246IGRhdGEuYWN0aW9uLAogICAgICAgIGF0dGFjaG1lbnQ6IGRhdGEuYXR0YWNobWVudCwKICAgICAgICBkZXN0OiBkYXRhLmRlc3QsCiAgICAgICAgdXJsOiBkYXRhLnVybCwKICAgICAgICB1bnNhZmVVcmw6IGRhdGEudW5zYWZlVXJsLAogICAgICAgIG5ld1dpbmRvdzogZGF0YS5uZXdXaW5kb3csCiAgICAgICAgc2V0T0NHU3RhdGU6IGRhdGEuc2V0T0NHU3RhdGUsCiAgICAgICAgdGl0bGU6ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykodGl0bGUpLAogICAgICAgIGNvbG9yOiByZ2JDb2xvciwKICAgICAgICBjb3VudDogTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgPyBjb3VudCA6IHVuZGVmaW5lZCwKICAgICAgICBib2xkOiAhIShmbGFncyAmIDIpLAogICAgICAgIGl0YWxpYzogISEoZmxhZ3MgJiAxKSwKICAgICAgICBpdGVtczogW10KICAgICAgfTsKICAgICAgaS5wYXJlbnQuaXRlbXMucHVzaChvdXRsaW5lSXRlbSk7CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiRmlyc3QiKTsKICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiAmJiAhcHJvY2Vzc2VkLmhhcyhvYmopKSB7CiAgICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgICBvYmosCiAgICAgICAgICBwYXJlbnQ6IG91dGxpbmVJdGVtCiAgICAgICAgfSk7CiAgICAgICAgcHJvY2Vzc2VkLnB1dChvYmopOwogICAgICB9CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiTmV4dCIpOwogICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmICYmICFwcm9jZXNzZWQuaGFzKG9iaikpIHsKICAgICAgICBxdWV1ZS5wdXNoKHsKICAgICAgICAgIG9iaiwKICAgICAgICAgIHBhcmVudDogaS5wYXJlbnQKICAgICAgICB9KTsKICAgICAgICBwcm9jZXNzZWQucHV0KG9iaik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByb290Lml0ZW1zLmxlbmd0aCA+IDAgPyByb290Lml0ZW1zIDogbnVsbDsKICB9CiAgZ2V0IHBlcm1pc3Npb25zKCkgewogICAgbGV0IHBlcm1pc3Npb25zID0gbnVsbDsKICAgIHRyeSB7CiAgICAgIHBlcm1pc3Npb25zID0gdGhpcy5fcmVhZFBlcm1pc3Npb25zKCk7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoZXggaW5zdGFuY2VvZiBfY29yZV91dGlscy5NaXNzaW5nRGF0YUV4Y2VwdGlvbikgewogICAgICAgIHRocm93IGV4OwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5hYmxlIHRvIHJlYWQgcGVybWlzc2lvbnMuIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInBlcm1pc3Npb25zIiwgcGVybWlzc2lvbnMpOwogIH0KICBfcmVhZFBlcm1pc3Npb25zKCkgewogICAgY29uc3QgZW5jcnlwdCA9IHRoaXMueHJlZi50cmFpbGVyLmdldCgiRW5jcnlwdCIpOwogICAgaWYgKCEoZW5jcnlwdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IGZsYWdzID0gZW5jcnlwdC5nZXQoIlAiKTsKICAgIGlmICh0eXBlb2YgZmxhZ3MgIT09ICJudW1iZXIiKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgZmxhZ3MgKz0gMiAqKiAzMjsKICAgIGNvbnN0IHBlcm1pc3Npb25zID0gW107CiAgICBmb3IgKGNvbnN0IGtleSBpbiBfdXRpbC5QZXJtaXNzaW9uRmxhZykgewogICAgICBjb25zdCB2YWx1ZSA9IF91dGlsLlBlcm1pc3Npb25GbGFnW2tleV07CiAgICAgIGlmIChmbGFncyAmIHZhbHVlKSB7CiAgICAgICAgcGVybWlzc2lvbnMucHVzaCh2YWx1ZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBwZXJtaXNzaW9uczsKICB9CiAgZ2V0IG9wdGlvbmFsQ29udGVudENvbmZpZygpIHsKICAgIGxldCBjb25maWcgPSBudWxsOwogICAgdHJ5IHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPQ1Byb3BlcnRpZXMiKTsKICAgICAgaWYgKCFwcm9wZXJ0aWVzKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBkZWZhdWx0Q29uZmlnID0gcHJvcGVydGllcy5nZXQoIkQiKTsKICAgICAgaWYgKCFkZWZhdWx0Q29uZmlnKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHNEYXRhID0gcHJvcGVydGllcy5nZXQoIk9DR3MiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGdyb3Vwc0RhdGEpKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHMgPSBbXTsKICAgICAgY29uc3QgZ3JvdXBSZWZzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgZ3JvdXBzRGF0YSkgewogICAgICAgIGlmICghKGdyb3VwUmVmIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGdyb3VwUmVmcy5wdXNoKGdyb3VwUmVmKTsKICAgICAgICBjb25zdCBncm91cCA9IHRoaXMueHJlZi5mZXRjaElmUmVmKGdyb3VwUmVmKTsKICAgICAgICBncm91cHMucHVzaCh7CiAgICAgICAgICBpZDogZ3JvdXBSZWYudG9TdHJpbmcoKSwKICAgICAgICAgIG5hbWU6IHR5cGVvZiBncm91cC5nZXQoIk5hbWUiKSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGdyb3VwLmdldCgiTmFtZSIpKSA6IG51bGwsCiAgICAgICAgICBpbnRlbnQ6IHR5cGVvZiBncm91cC5nZXQoIkludGVudCIpID09PSAic3RyaW5nIiA/ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykoZ3JvdXAuZ2V0KCJJbnRlbnQiKSkgOiBudWxsCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uZmlnID0gdGhpcy5fcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhkZWZhdWx0Q29uZmlnLCBncm91cFJlZnMpOwogICAgICBjb25maWcuZ3JvdXBzID0gZ3JvdXBzOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYFVuYWJsZSB0byByZWFkIG9wdGlvbmFsIGNvbnRlbnQgY29uZmlnOiAke2V4fWApOwogICAgfQogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBjb25maWcpOwogIH0KICBfcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhjb25maWcsIGNvbnRlbnRHcm91cFJlZnMpIHsKICAgIGZ1bmN0aW9uIHBhcnNlT25PZmYocmVmcykgewogICAgICBjb25zdCBvblBhcnNlZCA9IFtdOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShyZWZzKSkgewogICAgICAgIGZvciAoY29uc3QgdmFsdWUgb2YgcmVmcykgewogICAgICAgICAgaWYgKCEodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvbnRlbnRHcm91cFJlZnMuaW5jbHVkZXModmFsdWUpKSB7CiAgICAgICAgICAgIG9uUGFyc2VkLnB1c2godmFsdWUudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBvblBhcnNlZDsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlT3JkZXIocmVmcykgewogICAgICBsZXQgbmVzdGVkTGV2ZWxzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkocmVmcykpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBvcmRlciA9IFtdOwogICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIHJlZnMpIHsKICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYgJiYgY29udGVudEdyb3VwUmVmcy5pbmNsdWRlcyh2YWx1ZSkpIHsKICAgICAgICAgIHBhcnNlZE9yZGVyUmVmcy5wdXQodmFsdWUpOwogICAgICAgICAgb3JkZXIucHVzaCh2YWx1ZS50b1N0cmluZygpKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBuZXN0ZWRPcmRlciA9IHBhcnNlTmVzdGVkT3JkZXIodmFsdWUsIG5lc3RlZExldmVscyk7CiAgICAgICAgaWYgKG5lc3RlZE9yZGVyKSB7CiAgICAgICAgICBvcmRlci5wdXNoKG5lc3RlZE9yZGVyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKG5lc3RlZExldmVscyA+IDApIHsKICAgICAgICByZXR1cm4gb3JkZXI7CiAgICAgIH0KICAgICAgY29uc3QgaGlkZGVuR3JvdXBzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgY29udGVudEdyb3VwUmVmcykgewogICAgICAgIGlmIChwYXJzZWRPcmRlclJlZnMuaGFzKGdyb3VwUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGhpZGRlbkdyb3Vwcy5wdXNoKGdyb3VwUmVmLnRvU3RyaW5nKCkpOwogICAgICB9CiAgICAgIGlmIChoaWRkZW5Hcm91cHMubGVuZ3RoKSB7CiAgICAgICAgb3JkZXIucHVzaCh7CiAgICAgICAgICBuYW1lOiBudWxsLAogICAgICAgICAgb3JkZXI6IGhpZGRlbkdyb3VwcwogICAgICAgI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nZUxhYmVsIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICB9CiAgICAgICAgICBwcmVmaXggPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcmVmaXggPSAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGxhYmVsRGljdC5oYXMoIlN0IikpIHsKICAgICAgICAgIGNvbnN0IHN0ID0gbGFiZWxEaWN0LmdldCgiU3QiKTsKICAgICAgICAgIGlmICghKE51bWJlci5pc0ludGVnZXIoc3QpICYmIHN0ID49IDEpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdGFydCBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRJbmRleCA9IHN0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50SW5kZXggPSAxOwogICAgICAgIH0KICAgICAgfQogICAgICBzd2l0Y2ggKHN0eWxlKSB7CiAgICAgICAgY2FzZSAiRCI6CiAgICAgICAgICBjdXJyZW50TGFiZWwgPSBjdXJyZW50SW5kZXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJSIjoKICAgICAgICBjYXNlICJyIjoKICAgICAgICAgIGN1cnJlbnRMYWJlbCA9ICgwLCBfY29yZV91dGlscy50b1JvbWFuTnVtZXJhbHMpKGN1cnJlbnRJbmRleCwgc3R5bGUgPT09ICJyIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJBIjoKICAgICAgICBjYXNlICJhIjoKICAgICAgICAgIGNvbnN0IExJTUlUID0gMjY7CiAgICAgICAgICBjb25zdCBBX1VQUEVSX0NBU0UgPSAweDQxLAogICAgICAgICAgICBBX0xPV0VSX0NBU0UgPSAweDYxOwogICAgICAgICAgY29uc3QgYmFzZUNoYXJDb2RlID0gc3R5bGUgPT09ICJhI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2V5IG9mIG9iai5nZXRLZXlzKCkpIHsKICAgICAgY29uc3QgdmFsdWUgPSBvYmouZ2V0KGtleSk7CiAgICAgIGxldCBwcmVmVmFsdWU7CiAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgY2FzZSAiSGlkZVRvb2xiYXIiOgogICAgICAgIGNhc2UgIkhpZGVNZW51YmFyIjoKICAgICAgICBjYXNlICJIaWRlV2luZG93VUkiOgogICAgICAgIGNhc2UgIkZpdFdpbmRvdyI6CiAgICAgICAgY2FzZSAiQ2VudGVyV2luZG93IjoKICAgICAgICBjYXNlICJEaXNwbGF5RG9jVGl0bGUiOgogICAgICAgIGNhc2UgIlBpY2tUcmF5QnlQREZTaXplIjoKICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk5vbkZ1bGxTY3JlZW5QYWdlTW9kZSI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlVzZU5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU91dGxpbmVzIjoKICAgICAgICAgICAgICBjYXNlICJVc2VUaHVtYnMiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU9DIjoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlLm5hbWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gIlVzZU5vbmUiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJEaXJlY3Rpb24iOgogICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICBzd2l0Y2ggKHZhbHVlLm5hbWUpIHsKICAgICAgICAgICAgICBjYXNlICJMMlIiOgogICAgICAgICAgICAgIGNhc2UgIlIyTCI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJMMlIiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJWaWV3QXJlYSI6CiAgICAgICAgY2FzZSAiVmlld0NsaXAiOgogICAgICAgIGNhc2UgIlByaW50QXJlYSI6CiAgICAgICAgY2FzZSAiUHJpbnRDbGlwIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgc3dpdGNoICh2YWx1ZS5uYW1lKSB7CiAgICAgICAgICAgICAgY2FzZSAiTWVkaWFCb3giOgogICAgICAgICAgICAgIGNhc2UgIkNyb3BCb3giOgogICAgICAgICAgICAgIGNhc2UgIkJsZWVkQm94IjoKICAgICAgICAgICAgICBjYXNlICJUcmltQm94IjoKICAgICAgICAgICAgICBjYXNlICJBcnRCb3giOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQ3JvcEJveCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlByaW50U2NhbGluZyI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIkFwcERlZmF1bHQiOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQXBwRGVmYXVsdCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkR1cGxleCI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlNpbXBsZXgiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBTaG9ydEVkZ2UiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBMb25nRWRnZSI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJOb25lIjsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiUHJpbnRQYWdlUmFuZ2UiOgogICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIHZhbHVlLmxlbmd0aCAlIDIgPT09IDApIHsKICAgICAgICAgICAgY29uc3QgaXNWYWxpZCA9IHZhbHVlLmV2ZXJ5KChwYWdlLCBpLCBhcnIpID0+IHsKICAgICAgICAgICAgICByZXR1cm4gTnVtYmVyLmlzSW50ZWdlcihwYWdlKSAmJiBwYWdlID4gMCAmJiAoaSA9PT0gMCB8fCBwYWdlID49IGFycltpIC0gMV0pICYmIHBhZ2UgPD0gdGhpcy5udW1QYWdlczsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkKSB7CiAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk51bUNvcGllcyI6CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkgJiYgdmFsdWUgPiAwKSB7CiAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3Jpbmcgbm9uLXN0YW5kYXJkIGtleSBpbiBWaWV3ZXJQcmVmZXJlbmNlczogJHtrZXl9LmApOwogICAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByZWZWYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBCYWQgdmFsdWUsIGZvciBrZXkgIiR7a2V5fSIsIGluIFZpZXdlclByZWZlcmVuY2VzOiAke3ZhbHVlfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIXByZWZzKSB7CiAgICAgICAgcHJlZnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICB9CiAgICAgIHByZWZzW2tleV0gPSBwcmVmVmFsdWU7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInZpZXdlclByZWZlcmVuY2VzIiwgcHJlZnMpOwogIH0KICBnZXQgb3BlbkFjdGlvbigpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPcGVuQWN0aW9uIik7CiAgICBjb25zdCBvcGVuQWN0aW9uID0gT2J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d0aCkgewogICAgICBjb25zdCBjdXJyZW50Tm9kZSA9IG5vZGVzVG9WaXNpdC5wb3AoKTsKICAgICAgaWYgKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgY29uc3QgY291bnQgPSBwYWdlS2lkc0NvdW50Q2FjaGUuZ2V0KGN1cnJlbnROb2RlKTsKICAgICAgICBpZiAoY291bnQgPj0gMCAmJiBjdXJyZW50UGFnZUluZGV4ICsgY291bnQgPD0gcGFnZUluZGV4KSB7CiAgICAgICAgICBjdXJyZW50UGFnZUluZGV4ICs9IGNvdW50OwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh2aXNpdGVkTm9kZXMuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKTsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChjdXJyZW50Tm9kZSk7CiAgICAgICAgY29uc3Qgb2JqID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGN1cnJlbnROb2RlKTsKICAgICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgbGV0IHR5cGUgPSBvYmouZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCgwLCBfcHJpbWl0aXZlcy5pc05hbWUpKHR5cGUsICJQYWdlIikgfHwgIW9iai5oYXMoIktpZHMiKSkgewogICAgICAgICAgICBpZiAoIXBhZ2VLaWRzQ291bnRDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUtpZHNDb3VudENhY2hlLnB1dChjdXJyZW50Tm9kZSwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKCFwYWdlSW5kZXhDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUluZGV4Q2FjaGUucHV0KGN1cnJlbnROb2RlLCBjdXJyZW50UGFnZUluZGV4KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY3VycmVudFBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgcmV0dXJuIFtvYmosIGN1cnJlbnROb2RlXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjdXJyZW50UGFnZUluZGV4Kys7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChvYmopOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWQgcmVmZXJlbmNlIHBvaW50cyB0byB3cm9uZyB0eXBlIG9mIG9iamVjdC4iKTsKICAgICAgfQogICAgICBjb25zdCB7CiAgICAgICAgb2JqSWQKICAgICAgfSA9IGN1cnJlbnROb2RlOwogICAgICBsZXQgY291bnQgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIkNvdW50Iik7CiAgICAgIGlmIChjb3VudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGNvdW50ID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGNvdW50KTsKICAgICAgfQogICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgJiYgY291bnQgPj0gMCkgewogICAgICAgIGlmIChvYmpJZCAmJiAhcGFnZUtpZHNDb3VudENhY2hlLmhhcyhvYmpJZCkpIHsKICAgICAgICAgIHBhZ2VLaWRzQ291bnRDYWNoZS5wdXQob2JqSWQsIGNvdW50KTsKICAgICAgICB9CiAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggKyBjb3VudCA8PSBwYWdlSW5kZXgpIHsKICAgICAgICAgIGN1cnJlbnRQYWdlSW5kZXggKz0gY291bnQ7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGtpZHMgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIktpZHMiKTsKICAgICAgaWYgKGtpZHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGxldCB0eXBlID0gY3VycmVudE5vZGUuZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgaWYgKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgIHR5cGUgPSBhd2FpdCB4cmVmLmZldGNoQXN5bmModHlwZSk7CiAgICAgICAgfQogICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFjdXJyZW50Tm9kZS5oYXMoIktpZHMiKSkgewogICAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggPT09IHBhZ2VJbmRleCkgewogICAgICAgICAgICByZXR1cm4gW2N1cnJlbnROb2RlLCBudWxsXTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRQYWdlSW5kZXgrKzsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoI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gICAgIHRyeSB7CiAgICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGFkZFBhZ2VFcnJvcihuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWRzIG9iamVjdCBpcyBub3QgYW4gYXJyYXkuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChwb3NJbktpZHMgPj0ga2lkcy5sZW5ndGgpIHsKICAgICAgICBxdWV1ZS5wb3AoKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBraWRPYmogPSBraWRzW3Bvc0luS2lkc107CiAgICAgIGxldCBvYmo7CiAgICAgIGlmIChraWRPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodmlzaXRlZE5vZGVzLmhhcyhraWRPYmopKSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChraWRPYmopOwogICAgICAgIHRyeSB7CiAgICAgICAgICBvYmogPSBhd2FpdCB4cmVmLmZldGNoQXN5bmMoa2lkT2JqKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgYWRkUGFnZUVycm9yKGV4KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBvYmogPSBraWRPYmo7CiAgICAgIH0KICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlIGRpY3Rpb25hcnkga2lkIHJlZmVyZW5jZSBwb2ludHMgdG8gd3JvbmcgdHlwZSBvZiBvYmplY3QuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldCB0eXBlID0gb2JqLmdldFJhdygiVHlwZSIpOwogICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBhZGRQYWdlRGljdChvYmosIGtpZE9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiA/IGtpZE9iaiA6IG51bGwpOwogICAgICB9IGVsc2UgewogICAgICAgIHF1ZXVlLnB1c2goewogICAgICAgICAgY3VycmVudE5vZGU6IG9iaiwKICAgICAgICAgIHBvc0luS2lkczogMAogICAgICAgIH0pOwogICAgICB9CiAgICAgIHF1ZXVlSXRlbS5wb3NJbktpZHMrKzsKICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldFBhZ2VJbmRleChwYWdlUmVmKSB7CiAgICBjb25zdCBjYWNoZWRQYWdlSW5kZXggPSB0aGlzLnBhZ2VJbmRleENhY2hlLmdldChwYWdlUmVmKTsKICAgIGlmIChjYWNoZWRQYWdlSW5kZXggIT09IHVuZGVmaW5lZCkgewogICAgICByZXR1cm4gU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w7CiAgICAgICAgfQogICAgICAgIGlmICghKHBhcmVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhcmVudCBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhcmVudC5nZXRBc3luYygiS2lkcyIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChraWRzKSB7CiAgICAgICAgaWYgKCFraWRzKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3Qga2lkUHJvbWlzZXMgPSBbXTsKICAgICAgICBsZXQgZm91bmQgPSBmYWxzZTsKICAgICAgICBmb3IgKGNvbnN0IGtpZCBvZiBraWRzKSB7CiAgICAgICAgICBpZiAoIShraWQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiS2lkIG11c3QgYmUgYSByZWZlcmVuY2UuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzUmVmc0VxdWFsKShraWQsIGtpZFJlZikpIHsKICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGtpZFByb21pc2VzLnB1c2goeHJlZi5mZXRjaEFzeW5jKGtpZCkudGhlbihmdW5jdGlvbiAob2JqKSB7CiAgICAgICAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJLaWQgbm9kZSBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAob2JqLmhhcygiQ291bnQiKSkgewogICAgICAgICAgICAgIHRvdGFsICs9IG9iai5nZXQoIkNvdW50Iik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdG90YWwrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIktpZCByZWZlcmVuY2Ugbm90IGZvdW5kIGluIHBhcmVudCdzIGtpZHMuIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBQcm9taXNlLmFsbChraWRQcm9taXNlcykudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICByZXR1cm4gW3RvdGFsLCBwYXJlbnRSZWZdOwogICAgICAgIH0pOwogICAgICB9KTsKICAgIH0KICAgIGxldCB0b3RhbCA9IDA7CiAgICBjb25zdCBuZXh0ID0gcmVmID0+IHBhZ2VzQmVmb3JlUmVmKHJlZikudGhlbihhcmdzID0+IHsKICAgICAgaWYgKCFhcmdzKSB7CiAgICAgICAgdGhpcy5wYWdlSW5kZXhDYWNoZS5wdXQocGFnZVJlZiwgdG90YWwpOwogICAgICAgIHJldHVybiB0b3RhbDsKICAgICAgfQogICAgICBjb25zdCBbY291bnQsIHBhcmVudFJlZl0gPSBhcmdzOwogICAgICB0b3RhbCArPSBjb3VudDsKICAgICAgcmV0dXJuIG5leHQocGFyZW50UmVmKTsKICAgIH0pOwogICAgcmV0dXJuIG5leHQocGFnZVJlZik7CiAgfQogIGdldCBiYXNlVXJsKCkgewogICAgY29uc3QgdXJpID0gdGhpcy5fY2F0RGljdC5nZXQoIlVSSSIpOwogICAgaWYgKHVyaSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgY29uc3QgYmFzZSA9IHVyaS5nZXQoIkJhc2UiKTsKICAgICAgaWYgKHR5cGVvZiBiYXNlID09PSAic3RyaW5nIikgewogICAgICAgIGNvbnN0IG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QgaW5jbHVkZSA9ICgodHlwZW9mIGZsYWdzID09PSAibnVtYmVyIiA/IGZsYWdzIDogMCkgJiAxKSA9PT0gMDsKICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IFtdOwogICAgICAgICAgY29uc3QgcmVmcyA9IFtdOwogICAgICAgICAgZm9yIChjb25zdCBvYmogb2YgYWN0aW9uLmdldCgiRmllbGRzIikgfHwgW10pIHsKICAgICAgICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHJlZnMucHVzaChvYmoudG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG9iaiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBmaWVsZHMucHVzaCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKG9iaikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHRPYmoucmVzZXRGb3JtID0gewogICAgICAgICAgICBmaWVsZHMsCiAgICAgICAgICAgIHJlZnMsCiAgICAgICAgICAgIGluY2x1ZGUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJVUkkiOgogICAgICAgICAgdXJsID0gYWN0aW9uLmdldCgiVVJJIik7CiAgICAgICAgICBpZiAodXJsIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICB1cmwgPSAiLyIgKyB1cmwubmFtZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkdvVG8iOgogICAgICAgICAgZGVzdCA9IGFjdGlvbi5nZXQoIkQiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkxhdW5jaCI6CiAgICAgICAgY2FzZSAiR29Ub1IiOgogICAgICAgICAgY29uc3QgdXJsRGljdCA9IGFjdGlvbi5nZXQoIkYiKTsKICAgICAgICAgIGlmICh1cmxEaWN0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0LmdldCgiRiIpIHx8IG51bGw7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB1cmxEaWN0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0OwogICAgICAgICAgfQogICAgICAgICAgbGV0IHJlbW90ZURlc3QgPSBhY3Rpb24uZ2V0KCJEIik7CiAgICAgICAgICBpZiAocmVtb3RlRGVzdCkgewogICAgICAgICAgICBpZiAocmVtb3RlRGVzdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICByZW1vdGVEZXN0ID0gcmVtb3RlRGVzdC5uYW1lOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgdXJsID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgIGNvbnN0IGJhc2VVcmwgPSB1cmwuc3BsaXQoIiMiKVswXTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbW90ZURlc3QgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICB1cmwgPSBiYXNlVXJsICsgIiMiICsgcmVtb3RlRGVzdDsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkocmVtb3RlRGVzdCkpIHsKICAgICAgICAgICAgICAgIHVybCA9IGJhc2VVcmwgKyAiIyIgKyBKU09OLnN0cmluZ2lmeShyZW1vdGVEZXN0KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG5ld1dpbmRvdyA9IGFjdGlvbi5nZXQoIk5ld1dpbmRvdyIpOwogICAgICAgICAgaWYgKHR5cGVvZiBuZXdXaW5kb3cgPT09ICJib29sZWFuIikgewogICAgICAgICAgICByZXN1bHRPYmoubmV3V2luZG93ID0gbmV3V2luZG93OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiR29Ub0UiOgogICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYWN0aW9uLmdldCgiVCIpOwogICAgICAgICAgbGV0IGF0dGFjaG1lbnQ7CiAgICAgICAgICBpZiAoZG9jQXR0YWNobWVudHMgJiYgdGFyZ2V0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICBjb25zdCByZWxhdGlvbnNoaXAgPSB0YXJnZXQuZ2V0KCJSIik7CiAgICAgICAgICAgIGNvbnN0IG5hbWUgPSB0YXJnZXQuZ2V0KCJOIik7CiAgICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKShyZWxhdGlvbnNoaXAsICJDIikgJiYgdHlwZW9mIG5hbWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgYXR0YWNobWVudCA9IGRvY0F0dGFjaG1lbnRzWygwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykobmFtZSldOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYXR0YWNobWVudCkgewogICAgICAgICAgICByZXN1bHRPYmouYXR0YWNobWVudCA9IGF0dGFjaG1lbnQ7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVzdERpY3Rpb25hcnkgLSB1bmltcGxlbWVudGVkICJHb1RvRSIgYWN0aW9uLmApOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiTmFtZWQiOgogICAgICAgICAgY29uc3QgbmFtZWRBY3Rpb24gPSBhY3Rpb24uZ2V0KCJOIik7CiAgICAgICAgICBpZiAobmFtZWRBY3Rpb24gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHJlc3VsdE9iai5hY3Rpb24gPSBuYW1lZEFjdGlvbi5uYW1lOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU2V0T0NHU3RhdGUiOgogICAgICAgICAgY29uc3Qgc3RhdGUgPSBhY3Rpb24uZ2V0KCJTdGF0ZSIpOwogICAgICAgICAgY29uc3QgcHJlc2VydmVSQiA9IGFjdGlvbi5nZXQoIlByZXNlcnZlUkIiKTsKICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShzdGF0ZSkgfHwgc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RhdGVBcnIgPSBbXTsKICAgICAgICAgIGZvciAoY29uc3QgZWxlbSBvZiBzdGF0ZSkgewogICAgICAgICAgICBpZiAoZWxlbSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICBzd2l0Y2ggKGVsZW0ubmFtZSkgewogICAgICAgICAgICAgICAgY2FzZSAiT04iOgogICAgICAgICAgICAgICAgY2FzZSAiT0ZGIjoKICAgICAgICAgICAgICAgIGNhc2UgIlRvZ2dsZSI6CiAgICAgICAgICAgICAgICAgIHN0YXRlQXJyLnB1c2goZWxlbS5uYW1lKTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgaWYgKGVsZW0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICBzdGF0ZUFyci5wdXNoKGVsZW0udG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZUFyci5sZW5ndGggIT09IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHJlc3VsdE9iai5zZXRPQ0dTdGF0ZSA9IHsKICAgICAgICAgICAgc3RhdGU6IHN0YXRlQXJyLAogICAgICAgICAgICBwcmVzZXJ2ZVJCOiB0eXBlb2YgcHJlc2VydmVSQiA9PT0gImJvb2xlYW4iID8gcHJlc2VydmVSQiA6IHRydWUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJKYXZhU2NyaXB0IjoKICAgICAgICAgIGNvbnN0IGpzQWN0aW9uID0gYWN0aW9uLmdldCgiSlMiKTsKICAgICAgICAgIGxldCBqczsKICAgICAgICAgIGlmIChqc0FjdGlvbiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICAgIGpzID0ganNBY3Rpb24uZ2V0U3RyaW5nKCk7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBqc0FjdGlvbiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAganMgPSBqc0FjdGlvbjsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGpzVVJMID0ganMgJiYgKDAsIF9jb3JlX3V0aWxzLnJlY292ZXJKc1VSTCkoKDAsIF91dGlsLnN0cmluZ1RvUERGU3RyaW5nKShqcykpOwogICAgICAgICAgaWYgKGpzVVJMKSB7CiAgICAgICAgICAgIHVybCA9IGpzVVJMLnVybDsKICAgICAgICAgICAgcmVzdWx0T2JqLm5ld1dpbmRvdyA9IGpzVVJMLm5ld1dpbmRvdzsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChhY3Rpb25OYW1lID09PSAiSmF2YVNjcmlwdCIgfHwgYWN0aW9uTmFtZSA9PT0gIlN1Ym1pdEZvcm0iKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBwYXJzZURlc3REaWN0aW9uYXJ5IC0gdW5zdXBwb3J0ZWQgYWN0aW9uOiAiJHthY3Rpb25OYW1lfSIuYCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfSBlbHNlIGl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Bjb25zdCBraWRzID0gb2JqLmdldCgiS2lkcyIpOwogICAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZvciAoY29uc3Qga2lkIG9mIGtpZHMpIHsKICAgICAgICAgIGlmIChwcm9jZXNzZWQuaGFzKGtpZCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBEdXBsaWNhdGUgZW50cnkgaW4gIiR7dGhpcy5fdHlwZX0iIHRyZWUuYCk7CiAgICAgICAgICB9CiAgICAgICAgICBxdWV1ZS5wdXNoKGtpZCk7CiAgICAgICAgICBwcm9jZXNzZWQucHV0KGtpZCk7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGVudHJpZXMgPSBvYmouZ2V0KHRoaXMuX3R5cGUpOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZW50cmllcykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBlbnRyaWVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBtYXAuc2V0KHhyZWYuZmV0Y2hJZlJlZihlbnRyaWVzW2ldKSwgeHJlZi5mZXRjaElmUmVmKGVudHJpZXNbaSArIDFdKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldChrZXkpIHsKICAgIGlmICghdGhpcy5yb290KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29uc3QgeHJlZiA9IHRoaXMueHJlZjsKICAgIGxldCBraWRzT3JFbnRyaWVzID0geHJlZi5mZXRjaElmUmVmKHRoaXMucm9vdCk7CiAgICBsZXQgbG9vcENvdW50ID0gMDsKICAgIGNvbnN0IE1BWF9MRVZFTFMgPSAxMDsKICAgIHdoaWxlIChraWRzT3JFbnRyaWVzLmhhcygiS2lkcyIpKSB7CiAgICAgIGlmICgrK2xvb3BDb3VudCA+IE1BWF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFNlYXJjaCBkZXB0aCBsaW1pdCByZWFjaGVkIGZvciAiJHt0aGlzLl90eXBlfSIgdHJlZS5gKTsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBraWRzID0ga2lkc09yRW50cmllcy5nZXQoIktpZHMiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGtpZHMpKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgbGV0IGwgPSAwLAogICAgICAgIHIgPSBraWRzLmxlbmd0aCAtIDE7CiAgICAgIHdoaWxlIChsIDw9IHIpIHsKICAgICAgICBjb25zdCBtID0gbCArIHIgPj4gMTsKICAgICAgICBjb25zdCBraWQgPSB4cmVmLmZldGNoSWZSZWYoa2lkc1ttXSk7CiAgICAgICAgY29uc3QgbGltaXRzID0ga2lkLmdldCgiTGltaXRzIik7CiAgICAgICAgaWYgKGtleSA8IHhyZWYuZmV0Y2hJZlJlZihsaW1pdHNbMF0pKSB7CiAgICAgICAgICByID0gbSAtIDE7CiAgICAgICAgfSBlbHNlIGlmIChrZXkgPiB4cmVmLmZldGNoSWZSZWYobGltaXRzWzFdKSkgewogICAgICAgICAgbCA9IG0gKyAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBraWRzT3JFbnRyaWVzID0ga2lkOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChsID4gcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICB9CiAgICBjb25zdCBlbnRyaWVzID0ga2lkc09yRW50cmllcy5nZXQodGhpcy5fdHlwZSk7CiAgICBpZiAoQXJyYXkuaXNBcnJheShlbnRyaWVzKSkgewogICAgICBsZXQgbCA9IDAsCiAgICAgICAgciA9IGVudHJpZXMubGVuZ3RoIC0gMjsKIC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ChbMC0zXSkoWzAtN10pKFswLTddKS9nLCBmdW5jdGlvbiAoY29kZSwgZDEsIGQyLCBkMykgewogICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKGQxICogNjQgKyBkMiAqIDggKyBkMyAqIDEpOwogICAgICB9KS5yZXBsYWNlQWxsKC8mKGFtcHxhcG9zfGd0fGx0fHF1b3QpOy9nLCBmdW5jdGlvbiAoc3RyLCBuYW1lKSB7CiAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICBjYXNlICJhbXAiOgogICAgICAgICAgICByZXR1cm4gIiYiOwogICAgICAgICAgY2FzZSAiYXBvcyI6CiAgICAgICAgICAgIHJldHVybiAiJyI7CiAgICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICAgIHJldHVybiAiPCI7CiAgICAgICAgICBjYXNlICJxdW90IjoKICAgICAgICAgICAgcmV0dXJuICciJzsKICAgICAgICB9CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBfcmVwYWlyOiAke25hbWV9IGlzbid0IGRlZmluZWQuYCk7CiAgICAgIH0pOwogICAgICBjb25zdCBjaGFyQnVmID0gWyI+Il07CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBjb25zdCBjb2RlID0gYnl0ZXMuY2hhckNvZGVBdChpKSAqIDI1NiArIGJ5dGVzLmNoYXJDb2RlQXQoaSArIDEpOwogICAgICAgIGlmIChjb2RlID49IDMyICYmIGNvZGUgPCAxMjcgJiYgY29kZSAhPT0gNjAgJiYgY29kZSAhPT0gNjIgJiYgY29kZSAhPT0gMzgpIHsKICAgICAgICAgIGNoYXJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY2hhckJ1Zi5w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Agb2JqLmFsdCA9ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykoYWx0KTsKICAgICAgfQogICAgICBjb25zdCBsYW5nID0gbm9kZS5kaWN0LmdldCgiTGFuZyIpOwogICAgICBpZiAodHlwZW9mIGxhbmcgPT09ICJzdHJpbmciKSB7CiAgICAgICAgb2JqLmxhbmcgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGxhbmcpOwogICAgICB9CiAgICAgIGZvciAoY29uc3Qga2lkIG9mIG5vZGUua2lkcykgewogICAgICAgIGNvbnN0IGtpZEVsZW1lbnQgPSBraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuRUxFTUVOVCA/IGtpZC5wYXJlbnROb2RlIDogbnVsbDsKICAgICAgICBpZiAoa2lkRWxlbWVudCkgewogICAgICAgICAgbm9kZVRvU2VyaWFsaXphYmxlKGtpZEVsZW1lbnQsIG9iaiwgbGV2ZWwgKyAxKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLlBBR0VfQ09OVEVOVCB8fCBraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuU1RSRUFNX0NPTlRFTlQpIHsKICAgICAgICAgIG9iai5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgdHlwZTogImNvbnRlbnQiLAogICAgICAgICAgICBpZDogYHBhZ2Uke2tpZC5wYWdlT2JqSWR9X21jaWQke2tpZC5tY2lkfWAKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLk9CSkVDVCkgewogICAgICAgICAgb2JqLmNoaWxkcmVuLnB1c2goewogICAgICAgICAgICB0eXBlOiAib2JqZWN0IiwKICAgICAgICAgICAgaWQ6IGtpZC5yZWZPYmpJZAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAg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ZXRSYXcoa2V5KTsKICAgICAgaWYgKHJhd1ZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChyYXdWYWx1ZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLl93YWxrKG5vZGVzVG9WaXNpdCk7CiAgfQogIGFzeW5jIF93YWxrKG5vZGVzVG9WaXNpdCkgewogICAgY29uc3Qgbm9kZXNUb1JldmlzaXQgPSBbXTsKICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0cyA9IFtdOwogICAgd2hpbGUgKG5vZGVzVG9WaXNpdC5sZW5ndGgpIHsKICAgICAgbGV0IGN1cnJlbnROb2RlID0gbm9kZXNUb1Zpc2l0LnBvcCgpOwogICAgICBpZiAoY3VycmVudE5vZGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodGhpcy5yZWZTZXQuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHRyeSB7CiAgICAgICAgICB0aGlzLnJlZlNldC5wdXQoY3VycmVudE5vZGUpOwogICAgICAgICAgY3VycmVudE5vZGUgPSB0aGlzLnhyZWYuZmV0Y2goY3VycmVudE5vZGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBpZiAoIShleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9iamVjdExvYWRlci5fd2FsayAtIHJlcXVlc3RpbmcgYWxsIGRhdGE6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIHRoaXMucmVmU2V0ID0gbnVsbDsKICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgIG1hbmFnZXIKICAgICAgICAgICAgfSA9IHRoaXMueHJlZi5zdHJlYW07CiAgICAgICAgICAgIHJldHVybiBtYW5hZ2VyLnJlcXVlc3RBbGxDaHVua3MoKTsKICAgICAgICAgIH0KICAgICAgICAgIG5vZGVzVG9SZXZpc2l0LnB1c2goY3VycmVudE5vZGUpOwogICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICBiZWdpbjogZXguYmVnaW4sCiAgICAgICAgICAgIGVuZDogZXguZW5kCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBiYXNlU3RyZWFtcyA9IGN1cnJlbnROb2RlLmdldEJhc2VTdHJlYW1zKCk7CiAgICAgICAgaWYgKGJhc2VTdHJlYW1zKSB7CiAgICAgICAgICBsZXQgZm91bmRNaXNzaW5nRGF0YSA9IGZhbHNlOwogICAgICAgICAgZm9yIChjb25zdCBzdHJlYW0gb2YgYmFzZVN0cmVhbXMpIHsKICAgICAgICAgICAgaWYgKHN0cmVhbS5pc0RhdGFMb2FkZWQpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3VuZE1pc3NpbmdEYXRhID0gdHJ1ZTsKICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICAgIGJlZ2luOiBzdHJlYW0uc3RhcnQsCiAgICAgICAgICAgICAgZW5kOiBzdHJlYW0uZW5kCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGZvdW5kTWlzc2luZ0RhdGEpIHsKICAgICAgICAgICAgbm9kZXNUb1JldmlzaXQucHVzaChjdXJyZW50Tm9kZSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGFkZENoaWxkcmVuKGN1cnJlbnROb2RlLCBub2Rlc1RvVmlzaXQpOwogICAgfQogICAgaWYgKHBlbmRpbmdSZXF1ZXN0cy5sZ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AgfQogIFskdGV4dF0oKSB7CiAgICBpZiAodGhpc1tfY2hpbGRyZW5dLmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdGhpc1skY29udGVudF07CiAgICB9CiAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dLm1hcChjID0+IGNbJHRleHRdKCkpLmpvaW4oIiIpOwogIH0KICBnZXQgW19hdHRyaWJ1dGVOYW1lc10oKSB7CiAgICBjb25zdCBwcm90byA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0aGlzKTsKICAgIGlmICghcHJvdG8uX2F0dHJpYnV0ZXMpIHsKICAgICAgY29uc3QgYXR0cmlidXRlcyA9IHByb3RvLl9hdHRyaWJ1dGVzID0gbmV3IFNldCgpOwogICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgICBpZiAodGhpc1tuYW1lXSA9PT0gbnVsbCB8fCB0aGlzW25hbWVdIGluc3RhbmNlb2YgWEZBT2JqZWN0IHx8IHRoaXNbbmFtZV0gaW5zdGFuY2VvZiBYRkFPYmplY3RBcnJheSkgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGF0dHJpYnV0ZXMuYWRkKG5hbWUpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgX2F0dHJpYnV0ZU5hbWVzLCBwcm90by5fYXR0cmlidXRlcyk7CiAgfQogIFskaXNEZXNjZW5kZW50XShwYXJlbnQpIHsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlIChub2RlKSB7CiAgICAgIGlmIChub2RlID09PSBwYXJlbnQpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBub2RlID0gbm9kZVskZ2V0UGFyZW50XSgpOwogICAgfQogICAgcmV0dXJuIGZhbHNlOwogIH0KICBbJGdldFBhcmVudF0oKSB7CiAgICByZXR1cm4gdGhp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lcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gdmFsdWVbX2NoaWxkcmVuXS5sZW5ndGgsIGlpID0gcHJvdG9WYWx1ZVtfY2hpbGRyZW5dLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgIGNvbnN0IGNoaWxkID0gcHJvdG9bX2NoaWxkcmVuXVtpXVskY2xvbmVdKCk7CiAgICAgICAgICBpZiAodmFsdWUucHVzaChjaGlsZCkpIHsKICAgICAgICAgICAgY2hpbGRbX3BhcmVudF0gPSB0aGlzOwogICAgICAgICAgICB0aGlzW19jaGlsZHJlbl0ucHVzaChjaGlsZCk7CiAgICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWx1ZSAhPT0gbnVsbCkgewogICAgICAgIHZhbHVlWyRyZXNvbHZlUHJvdG90eXBlc10oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIGlmIChwcm90b1ZhbHVlKSB7CiAgICAgICAgICB2YWx1ZVtfYXBwbHlQcm90b3R5cGVdKHByb3RvVmFsdWUsIGlkcywgYW5jZXN0b3JzKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByb3RvVmFsdWUgIT09IG51bGwpIHsKICAgICAgICBjb25zdCBjaGlsZCA9IHByb3RvVmFsdWVbJGNsb25lXSgpOwogICAgICAgIGNoaWxkW19wYXJlbnRdID0gdGhpczsKICAgICAgICB0aGlzW25hbWVdID0gY2hpbGQ7CiAgICAgICAgdGhpc1tfY2hpbGRyZW5dLnB1c2goY2hpbGQpOwogICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbH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ICAgICBjb25zdCB2YWx1ZSA9IHRoaXNbbmFtZV07CiAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIFhGQU9iamVjdEFycmF5KSB7CiAgICAgICAgY2xvbmVbbmFtZV0gPSBuZXcgWEZBT2JqZWN0QXJyYXkodmFsdWVbX21heF0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdID0gbnVsbDsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCBjaGlsZCBvZiB0aGlzW19jaGlsZHJlbl0pIHsKICAgICAgY29uc3QgbmFtZSA9IGNoaWxkWyRub2RlTmFtZV07CiAgICAgIGNvbnN0IGNsb25lZENoaWxkID0gY2hpbGRbJGNsb25lXSgpOwogICAgICBjbG9uZVtfY2hpbGRyZW5dLnB1c2goY2xvbmVkQ2hpbGQpOwogICAgICBjbG9uZWRDaGlsZFtfcGFyZW50XSA9IGNsb25lOwogICAgICBpZiAoY2xvbmVbbmFtZV0gPT09IG51bGwpIHsKICAgICAgICBjbG9uZVtuYW1lXSA9IGNsb25lZENoaWxkOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdW19jaGlsZHJlbl0ucHVzaChjbG9uZWRDaGlsZCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBjbG9uZTsKICB9CiAgWyRnZXRDaGlsZHJlbl0oKSB7CiAgICBsZXQgbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgIGlmICghbmFtZSkgewogICAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dOwogICAgfQogICAgcmV0dXJuIHRoaXNbX2NoaWxkcmVuXS5maWx0ZXIoYyA9PiBjWyRub2RlTmFtZV0gPT09IG5hbWUpOwogIH0KICBbJGdldENoaWxkcmVuQnlDbGFzc10obmFtZSkgewogICAgcmV0dXJuIHRoaXNbbmFtZV07CiAgfQ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y2goaW5kZXhQYXR0ZXJuKTsKICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCBpbmRleCBpbiBTT00gZXhwcmVzc2lvbiIpOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIHBhcnNlZC5hdCgtMSkuaW5kZXggPSBwYXJzZUluZGV4KG1hdGNoWzBdKTsKICAgICAgcG9zICs9IG1hdGNoWzBdLmxlbmd0aCArIDE7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgbGV0IG9wZXJhdG9yOwogICAgc3dpdGNoIChleHByLmNoYXJBdChwb3MpKSB7CiAgICAgIGNhc2UgIi4iOgogICAgICAgIGlmICghZG90RG90QWxsb3dlZCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIHBvcysrOwogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdERvdDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiIyI6CiAgICAgICAgcG9zKys7CiAgICAgICAgb3BlcmF0b3IgPSBvcGVyYXRvcnMuZG90SGFzaDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiWyI6CiAgICAgICAgaWYgKG5vRXhwcikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBTT00gZXhwcmVzc2lvbiBjb250YWlucyBhIEZvcm1DYWxjIHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdEJyYWNrZXQ7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIigiOgogICAgICAgIGlmIChub0V4cHIpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gU09NIGV4cHJlc3Npb24gY29udGFpbnMgYSBKYXZh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Bjb25zdCBmbiA9IHNob3J0Y3V0cy5nZXQocGFyc2VkWzBdLm5hbWUpOwogIGxldCBpID0gMDsKICBsZXQgaXNRdWFsaWZpZWQ7CiAgaWYgKGZuKSB7CiAgICBpc1F1YWxpZmllZCA9IHRydWU7CiAgICByb290ID0gW2ZuKHJvb3QsIGNvbnRhaW5lcildOwogICAgaSA9IDE7CiAgfSBlbHNlIHsKICAgIGlzUXVhbGlmaWVkID0gY29udGFpbmVyID09PSBudWxsOwogICAgcm9vdCA9IFtjb250YWluZXIgfHwgcm9vdF07CiAgfQogIGZvciAobGV0IGlpID0gcGFyc2VkLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgIGNvbnN0IHsKICAgICAgbmFtZSwKICAgICAgY2FjaGVOYW1lLAogICAgICBvcGVyYXRvciwKICAgICAgaW5kZXgKICAgIH0gPSBwYXJzZWRbaV07CiAgICBjb25zdCBub2RlcyA9IFtdOwogICAgZm9yIChjb25zdCBub2RlIG9mIHJvb3QpIHsKICAgICAgaWYgKCEobm9kZSBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgY2hpbGRyZW4sIGNhY2hlZDsKICAgICAgaWYgKHVzZUNhY2hlKSB7CiAgICAgICAgY2FjaGVkID0gc29tQ2FjaGUuZ2V0KG5vZGUpOwogICAgICAgIGlmICghY2FjaGVkKSB7CiAgICAgICAgICBjYWNoZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICBzb21DYWNoZS5zZXQobm9kZSwgY2FjaGVkKTsKICAgICAgICB9CiAgICAgICAgY2hpbGRyZW4gPSBjYWNoZWQuZ2V0KGNhY2hlTmFtZSk7CiAgICAgIH0KICAgICAgaWYgKCFjaGlsZHJlbikgewogICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgZmFsc2UpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdERvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgdHJ1ZSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBvcGVyYXRvcnMuZG90SGFzaDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5Q2xhc3NdKG5hbWUpOwogICAgICAgICAgICBpZiAoY2hpbGRyZW4gaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSkgewogICAgICAgICAgICAgIGNoaWxkcmVuID0gY2hpbGRyZW4uY2hpbGRyZW47CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY2hpbGRyZW4gPSBbY2hpbGRyZW5dOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICh1c2VDYWNoZSkgewogICAgICAgICAgY2FjaGVkLnNldChjYWNoZU5hbWUsIGNoaWxkcmVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICBub2Rlcy5wdXNoKGNoaWxkcmVuKTsKICAgICAgfQogICAgfQogICAgaWYgKG5vZGVzLmxlbmd0aCA9PT0gMCAmJiAhaXNRdWFsaWZpZWQgJiYgaSA9PT0gMCkgewogICAgICBjb25zdCBwYXJlbnQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgICAgY29udGFpbmVyID0gcGFyZW50OwogIC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XJuOwogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIHJlZiwKICAgICAgdGFyZ2V0LAogICAgICBjb25uZWN0aW9uCiAgICB9IG9mIGZvcm1Ob2RlLnNldFByb3BlcnR5LmNoaWxkcmVuKSB7CiAgICAgIGlmIChjb25uZWN0aW9uKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKCFyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBub2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZGF0YU5vZGUsIHJlZiwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCFub2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCByZWZlcmVuY2U6ICR7cmVmfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbbm9kZV0gPSBub2RlczsKICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YSkpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgbm9kZTogbXVzdCBiZSBhIGRhdGEgbm9kZS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0YXJnZXROb2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZm9ybU5vZGUsIHRhcmdldCwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCF0YXJnZXROb2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCB0YXJnZXQ6ICR7dGFyZ2V0fS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbdGFyZ2V0Tm9kZV0gPSB0YXJnZXROb2RlczsKICAgICAgaWYgKCF0YXJnZXROb2RlW194ZmFfb2JqZWN0LiRpc0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AgICAgICAgICAgZ2xvYmFsID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJkYXRhUmVmIjoKICAgICAgICAgICAgaWYgKCFjaGlsZC5iaW5kLnJlZikgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gcmVmIGlzIGVtcHR5IGluIG5vZGUgJHtjaGlsZFtfeGZhX29iamVjdC4kbm9kZU5hbWVdfS5gKTsKICAgICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVmID0gY2hpbGQuYmluZC5yZWY7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChjaGlsZC5iaW5kLnBpY3R1cmUpIHsKICAgICAgICAgIHBpY3R1cmUgPSBjaGlsZC5iaW5kLnBpY3R1cmVbX3hmYV9vYmplY3QuJGNvbnRlbnRdOwogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBbbWluLCBtYXhdID0gdGhpcy5fZ2V0T2NjdXJJbmZvKGNoaWxkKTsKICAgICAgaWYgKHJlZikgewogICAgICAgIG1hdGNoID0gKDAsIF9zb20uc2VhcmNoTm9kZSkodGhpcy5yb290LCBkYXRhTm9kZSwgcmVmLCB0cnVlLCBmYWxzZSk7CiAgICAgICAgaWYgKG1hdGNoID09PSBudWxsKSB7CiAgICAgICAgICBtYXRjaCA9ICgwLCBfc29tLmNyZWF0ZURhdGFOb2RlKSh0aGlzLmRhdGEsIGRhdGFOb2RlLCByZWYpOwogICAgICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgICAgbWF0Y2hbX3hmYV9vYmplY3QuJGNvbnN1bWVkXSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKHRoaXMuX2lzQ29uc3VtZURhdGEoKSkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLmZpbHRlcihub2RlID0+ICFub2RlW194ZmFfb2JqZWN0LiRjb25zdW1lZF0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG1hdGNoLmxlbmd0aCA+IG1heCkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLnNsaWNlKDAsIG1heCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICBtYXRjaCA9IG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobWF0Y2ggJiYgdGhpcy5faXNDb25zdW1lRGF0YSgpKSB7CiAgICAgICAgICAgIG1hdGNoLmZvckVhY2gobm9kZSA9PiB7CiAgICAgICAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29uc3VtZWRdID0gdHJ1ZTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICghY2hpbGQubmFtZSkgewogICAgICAgICAgdGhpcy5fc2V0QW5kQmluZChjaGlsZCwgZGF0YU5vZGUpOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgIHdoaWxlIChtYXRjaGVzLmxlbmd0aCA8IG1heCkgewogICAgICAgICAgICBjb25zdCBmb3VuZCA9IHRoaXMuX2ZpbmREYXRhQnlOYW1lVG9Db25zdW1lKGNoaWxkLm5hbWUsIGNoaWxkW194ZmFfb2JqZWN0LiRoYXNTZXR0YWJsZVZhbHVlXSgpLCBkYXRhTm9kZSwgZ2xvYmFsKTsKICAgICAgICAgICAgaWYgKCFmb3VuZCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvdW5kW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICBtYXRjaGVzLnB1c2goZm91bmQpOwogICAgICAgICAgfQogICAgICAgICAgbWF0Y2ggPSBtYXRjaGVzLmxlbmd0aCA+IDAgPyBtYXRjaGVzIDogbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbWF0Y2ggPSBkYXRhTm9kZVtfeGZhX29iamVjdC4kZ2V0UmVhbENoaWxkcmVuQnlOYW1lSXRdKGNoaWxkLm5hbWUsIGZhbHNlLCB0aGlzLmVtcHR5TWVyZ2UpLm5leHQoKS52YWx1ZTsKICAgICAgICAgIGlmICghbWF0Y2gpIHsKICAgICAgICAgICAgaWYgKG1pbiA9PT0gMCkgewogICAgICAgICAgICAgIHVzZWxlc3NOb2Rlcy5wdXNoKGNoaWxkKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBuc0lkID0gZGF0YU5vZGVbX3hmYV9vYmplY3QuJG5hbWVzcGFjZUlkXSA9PT0gTlNfREFUQVNFVFMgPyAtMSA6IGRhdGFOb2RlW194ZmFfb2JqZWN0LiRuYW1lc3BhY2VJZF07CiAgICAgICAgICAgIG1hdGNoID0gY2hpbGRbX3hmYV9vYmplY3QuJGRhdGFdID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBjaGlsZC5uYW1lKTsKICAgICAgICAgICAgaWYgKHRoaXMuZW1wdHlNZXJnZSkgewogICAgICAgICAgICAgIG1hdGNoW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICB9CiAg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RlKSB7CiAgd2hpbGUgKG5vZGUpIHsKICAgIGlmICghbm9kZS50cmF2ZXJzYWwpIHsKICAgICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICAgIHJldHVybjsKICAgIH0KICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiR0YWJJbmRleF0pIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgbGV0IG5leHQgPSBudWxsOwogICAgZm9yIChjb25zdCBjaGlsZCBvZiBub2RlLnRyYXZlcnNhbFtfeGZhX29iamVjdC4kZ2V0Q2hpbGRyZW5dKCkpIHsKICAgICAgaWYgKGNoaWxkLm9wZXJhdGlvbiA9PT0gIm5leHQiKSB7CiAgICAgICAgbmV4dCA9IGNoaWxkOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoIW5leHQgfHwgIW5leHQucmVmKSB7CiAgICAgIG5vZGVbX3hmYV9vYmplY3QuJHRhYkluZGV4XSA9IG5vZGVbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKVtfeGZhX29iamVjdC4kdGFiSW5kZXhdOwogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCByb290ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0VGVtcGxhdGVSb290XSgpOwogICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gKytyb290W194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICBjb25zdCByZWYgPSByb290W194ZmFfb2JqZWN0LiRzZWFyY2hOb2RlXShuZXh0LnJlZiwgbm9kZSk7CiAgICBpZiAoIXJlZikgewogICAgICByZXR1cm47CiAgICB9CiAgICBub2RlID0gcmVmWzBdOwogIH0KfQpmdW5jdGlvbiBhcHBseUFzc2lzdChvYmosIGF0dHJpYnV0ZXMpIHsKICBjb25zdCBhc3Npc3QgPSBvYmouYXNz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YXJnZXQgPSBudWxsOwogICAgfQogICAgaWYgKG5vZGUuc3RhcnROZXcpIHsKICAgICAgbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLnRhcmdldCA9IHRhcmdldCB8fCBjdXJyZW50UGFnZUFyZWE7CiAgICAgIHJldHVybiB0cnVlOwogICAgfSBlbHNlIGlmICh0YXJnZXQgJiYgdGFyZ2V0ICE9PSBjdXJyZW50UGFnZUFyZWEpIHsKICAgICAgbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLnRhcmdldCA9IHRhcmdldDsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICByZXR1cm4gZmFsc2U7CiAgfQogIGlmICghKHRhcmdldCBpbnN0YW5jZW9mIENvbnRlbnRBcmVhKSkgewogICAgdGFyZ2V0ID0gbnVsbDsKICB9CiAgY29uc3QgcGFnZUFyZWEgPSB0YXJnZXQgJiYgdGFyZ2V0W194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgbGV0IGluZGV4OwogIGxldCBuZXh0UGFnZUFyZWEgPSBwYWdlQXJlYTsKICBpZiAobm9kZS5zdGFydE5ldykgewogICAgaWYgKHRhcmdldCkgewogICAgICBjb25zdCBjb250ZW50QXJlYXMgPSBwYWdlQXJlYS5jb250ZW50QXJlYS5jaGlsZHJlbjsKICAgICAgY29uc3QgaW5kZXhGb3JDdXJyZW50ID0gY29udGVudEFyZWFzLmluZGV4T2YoY3VycmVudENvbnRlbnRBcmVhKTsKICAgICAgY29uc3QgaW5kZXhGb3JUYXJnZXQgPSBjb250ZW50QXJlYXMuaW5kZXhPZih0YXJnZXQpOwogICAgICBpZiAoaW5kZXhGb3JDdXJyZW50ICE9PSAtMSAmJiBpbmRleEZvckN1cnJlbnQgPCBpbmRleEZvclRhcmdldCkgewogICAgICAgIG5leHRQYWdlQXJlYSA9IG51bGw7CiAgICAgIH0KICAgICAgaW5kZXggPSBpbmRleEZvclRhcmdldCAtIDE7CiAgICB9IGVsc2UgewogICAgICBp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ZSkpLCA1MCAqICgxICsgTWF0aC5jb3Moc3RhcnRBbmdsZSArIHN3ZWVwQW5nbGUpKSwgNTAgKiAoMSAtIE1hdGguc2luKHN0YXJ0QW5nbGUgKyBzd2VlcEFuZ2xlKSldOwogICAgICBhcmMgPSB7CiAgICAgICAgbmFtZTogInBhdGgiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIHhtbG5zOiBTVkdfTlMsCiAgICAgICAgICBkOiBgTSAke3gxfSAke3kxfSBBIDUwIDUwIDAgJHtsYXJnZUFyY30gMCAke3gyfSAke3kyfWAsCiAgICAgICAgICB2ZWN0b3JFZmZlY3Q6ICJub24tc2NhbGluZy1zdHJva2UiLAogICAgICAgICAgc3R5bGUKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5hc3NpZ24oYXR0cmlidXRlcywgewogICAgICAgIHZpZXdCb3g6ICIwIDAgMTAwIDEwMCIsCiAgICAgICAgcHJlc2VydmVBc3BlY3RSYXRpbzogIm5vbmUiCiAgICAgIH0pOwogICAgfQogICAgY29uc3Qgc3ZnID0gewogICAgICBuYW1lOiAic3ZnIiwKICAgICAgY2hpbGRyZW46IFthcmNdLAogICAgICBhdHRyaWJ1dGVzCiAgICB9OwogICAgY29uc3QgcGFyZW50ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICBpZiAoaGFzTWFyZ2luKHBhcmVudCkpIHsKICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LnN1Y2Nlc3MoewogICAgICAgIG5hbWU6ICJkaXYiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIHN0eWxlOiB7CiAgICAgICAgICAgIGRpc3BsYXk6ICJpbmxpbmUiLAogICAgICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgICAgICBoZWlnaHQ6ICIxMDAlIgogICAgICAgICAgfQogICAgICAgIH0sC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1dGVzLnVzZWhyZWYgfHwgIiI7CiAgICB0aGlzLmV4dHJhcyA9IG51bGw7CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgY29uc3QgcGFyZW50ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ3JhbmRwYSA9IHBhcmVudFtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgaHRtbEJ1dHRvbiA9IHsKICAgICAgbmFtZTogImJ1dHRvbiIsCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICBpZDogdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICBjbGFzczogWyJ4ZmFCdXR0b24iXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW46IFtdCiAgICB9OwogICAgZm9yIChjb25zdCBldmVudCBvZiBncmFuZHBhLmV2ZW50LmNoaWxkcmVuKSB7CiAgICAgIGlmIChldmVudC5hY3Rpdml0eSAhPT0gImNsaWNrIiB8fCAhZXZlbnQuc2NyaXB0KSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QganNVUkwgPSAoMCwgX2NvcmVfdXRpbHMucmVjb3ZlckpzVVJMKShldmVudC5zY3JpcHRbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgaWYgKCFqc1VSTCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGhyZWYgPSAoMCwgX2h0bWxfdXRpbHMuZml4VVJMKShqc1VSTC51cmwpOwogICAgICBpZiAoIWhyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBodG1sQnV0dG9uLmNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICJhIiwKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBpZDogImxpbmsiICsgdGhpc1tfeGZhX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ICAgd2lkdGggPSB0aGlzLnJlc2VydmUgPD0gMCA/IHdpZHRoIDogdGhpcy5yZXNlcnZlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICBjYXNlICJib3R0b20iOgogICAgICAgICAgaGVpZ2h0ID0gdGhpcy5yZXNlcnZlIDw9IDAgPyBoZWlnaHQgOiB0aGlzLnJlc2VydmU7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0gPSAoMCwgX2h0bWxfdXRpbHMubGF5b3V0Tm9kZSkodGhpcywgewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodAogICAgICB9KTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV07CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgaWYgKCF0aGlzLnZhbHVlKSB7CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5FTVBUWTsKICAgIH0KICAgIHRoaXNbX3hmYV9vYmplY3QuJHB1c2hQYXJhXSgpOwogICAgY29uc3QgdmFsdWUgPSB0aGlzLnZhbHVlW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKS5odG1sOwogICAgaWYgKCF2YWx1ZSkgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuRU1QVFk7CiAgICB9CiAgICBjb25zdCBzYXZlZFJlc2VydmUgPSB0aGlzLnJlc2VydmU7CiAgICBpZiAodGhpcy5yZXNlcnZlIDw9IDApIHsKICAgICAgY29uc3QgewogICAgICAgIHcsCiAgICAgICAgaAogICAgICB9ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0RXh0cmFdKGF2YWlsYWJsZVNwYWNlKTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgdGhpcy5yZXNlcnZlID0gdzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInRvcCI6CiAgICAgICAgY2FzZSAiYm90dG9tIjoKICAgICAgICAgIHRoaXMucmVzZXJ2ZSA9IGg7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgY29uc3QgY2hpbGRyZW4gPSBbXTsKICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgIGNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICIjdGV4dCIsCiAgICAgICAgdmFsdWUKICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBjaGlsZHJlbi5wdXNoKHZhbHVlKTsKICAgIH0KICAgIGNvbnN0IHN0eWxlID0gKDAsIF9odG1sX3V0aWxzLnRvU3R5bGUpKHRoaXMsICJmb250IiwgIm1hcmdpbiIsICJ2aXNpYmlsaXR5Iik7CiAgICBzd2l0Y2ggKHRoaXMucGxhY2VtZW50KSB7CiAgICAgIGNhc2UgImxlZnQiOgogICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgaWYgKHRoaXMucmVzZXJ2ZSA+IDApIHsKICAgICAgICAgIHN0eWxlLndpZHRoID0gKDAsIF9odG1sX3V0aWxzLm1lYXN1cmVUb1N0cmluZykodGhpcy5yZXNlcnZlKTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgInRvcCI6CiAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgaWYgKHRoaXMucmVzZXJ2ZSA+IDApIHsKICAgICAgICAgIHN0eWxlLmhlaWdodCA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMucmVzZXJ2ZSk7CiAgICAgICAgfQogICAgICAgIGJyZWF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gICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaERvdERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaGVkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gImRhc2hlZCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJkb3R0ZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAiZG90dGVkIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImVtYm9zc2VkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gInJpZGdlIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV0Y2hlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJncm9vdmUiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibG93ZXJlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJpbnNldCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyYWlzZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAib3V0c2V0IjsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3R5bGU7CiAgfQp9CmNsYXNzIEVuY29kaW5nIGV4dGVuZHMgX3hmYV9vYmplY3QuT3B0aW9uT2JqZWN0IHsKICBjb25zdHJ1Y3RvcihhdHRyaWJ1dGVzKSB7CiAgICBzdXBlcihURU1QTEFURV9OU19JRCwgImVuY29kaW5nIiwgWyJhZGJlLng1MDkucnNhX3NoYTEiLCAiYWRiZS5wa2NzNy5kZXRhY2hlZCIsICJhZGJlLnBrY3M3LnNoYTEiXSk7CiAgICB0aGlzLmlkID0gYXR0cmlidXRlcy5pZCB8fCAiIjsKICAgIHRoaXMudXNlID0gYXR0cmlidXRl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pcy5ldmVudCA9IG5ldyBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSgpOwogICAgdGhpcy5zZXRQcm9wZXJ0eSA9IG5ldyBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSgpOwogIH0KICBbX3hmYV9vYmplY3QuJGlzQmluZGFibGVdKCkgewogICAgcmV0dXJuIHRydWU7CiAgfQogIFtfeGZhX29iamVjdC4kc2V0VmFsdWVdKHZhbHVlKSB7CiAgICBfc2V0VmFsdWUodGhpcywgdmFsdWUpOwogIH0KICBbX3hmYV9vYmplY3QuJHRvSFRNTF0oYXZhaWxhYmxlU3BhY2UpIHsKICAgIHNldFRhYkluZGV4KHRoaXMpOwogICAgaWYgKCF0aGlzLnVpKSB7CiAgICAgIHRoaXMudWkgPSBuZXcgVWkoe30pOwogICAgICB0aGlzLnVpW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXSA9IHRoaXNbX3hmYV9vYmplY3QuJGdsb2JhbERhdGFdOwogICAgICB0aGlzW194ZmFfb2JqZWN0LiRhcHBlbmRDaGlsZF0odGhpcy51aSk7CiAgICAgIGxldCBub2RlOwogICAgICBzd2l0Y2ggKHRoaXMuaXRlbXMuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgbm9kZSA9IG5ldyBUZXh0RWRpdCh7fSk7CiAgICAgICAgICB0aGlzLnVpLnRleHRFZGl0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIG5vZGUgPSBuZXcgQ2hlY2tCdXR0b24oe30pOwogICAgICAgICAgdGhpcy51aS5jaGVja0J1dHRvbiA9IG5vZGU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICBub2RlID0gbmV3IENob2ljZUxpc3Qoe30pOwogICAgICAgICAgdGhpcy51aS5jaG9pY2VMaXN0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAg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RoaXMudWkuY2hlY2tCdXR0b24pIHsKICAgICAgICB1aVcgPSB1aUggPSB0aGlzLnVpLmNoZWNrQnV0dG9uLnNpemU7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgdywKICAgICAgICAgIGgKICAgICAgICB9ID0gKDAsIF9odG1sX3V0aWxzLmxheW91dE5vZGUpKHRoaXMsIGF2YWlsYWJsZVNwYWNlKTsKICAgICAgICBpZiAodyAhPT0gbnVsbCkgewogICAgICAgICAgdWlXID0gdzsKICAgICAgICAgIHVpSCA9IGg7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHVpSCA9ICgwLCBfZm9udHMuZ2V0TWV0cmljcykodGhpcy5mb250LCB0cnVlKS5saW5lTm9HYXA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGJvcmRlckRpbXMgPSBnZXRCb3JkZXJEaW1zKHRoaXMudWlbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpKTsKICAgICAgdWlXICs9IGJvcmRlckRpbXMudzsKICAgICAgdWlIICs9IGJvcmRlckRpbXMuaDsKICAgICAgaWYgKHRoaXMuY2FwdGlvbikgewogICAgICAgIGNvbnN0IHsKICAgICAgICAgIHcsCiAgICAgICAgICBoLAogICAgICAgICAgaXNCcm9rZW4KICAgICAgICB9ID0gdGhpcy5jYXB0aW9uW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oYXZhaWxhYmxlU3BhY2UpOwogICAgICAgIGlmIChpc0Jyb2tlbiAmJiB0aGlzW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpW194ZmFfb2JqZWN0LiRpc1RoZXJlTW9yZVdpZHRoXSgpKSB7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkZBSUxVUkU7CiAgICAgICAgfQogICAgICAgIHdpZHRoID0gdzsKICAgICAgICBoZWlnaHQgPSBoOwogICAgICAgIHN3aXRjaCAodGhpcy5jYXB0aW9uLnBsYWNlbWVudCkgewogICAgICAgICAgY2FzZSAibGVmdCI6CiAgICAgICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgICB3aWR0aCArPSB1aVc7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgICAgIGhlaWdodCArPSB1aUg7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB3aWR0aCA9IHVpVzsKICAgICAgICBoZWlnaHQgPSB1aUg7CiAgICAgIH0KICAgICAgaWYgKHdpZHRoICYmIHRoaXMudyA9PT0gIiIpIHsKICAgICAgICB3aWR0aCArPSBtYXJnaW5IOwogICAgICAgIHRoaXMudyA9IE1hdGgubWluKHRoaXMubWF4VyA8PSAwID8gSW5maW5pdHkgOiB0aGlzLm1heFcsIHRoaXMubWluVyArIDEgPCB3aWR0aCA/IHdpZHRoIDogdGhpcy5taW5XKTsKICAgICAgfQogICAgICBpZiAoaGVpZ2h0ICYmIHRoaXMuaCA9PT0gIiIpIHsKICAgICAgICBoZWlnaHQgKz0gbWFyZ2luVjsKICAgICAgICB0aGlzLmggPSBNYXRoLm1pbih0aGlzLm1heEggPD0gMCA/IEluZmluaXR5IDogdGhpcy5tYXhILCB0aGlzLm1pbkggKyAxIDwgaGVpZ2h0ID8gaGVpZ2h0IDogdGhpcy5taW5IKTsKICAgICAgfQogICAgfQogICAgdGhpc1tfeGZhX29iamVjdC4kcG9wUGFyYV0oKTsKICAgICgwLCBfaHRtbF91dGlscy5maXhEaW1lbnNpb25zKSh0aGlzKTsKICAgIHNldEZpcnN0VW5zcGxpdHRhYmxlKHRoaXMpOwogICAgaWYgKCEoMCwgX2xheW91dC5jaGVja0RpbWVuc2lvbnMpKHRoaXMsIGF2YWlsYW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uZHBhW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICBjb25zdCBzdHlsZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBsZXQgcHJvcE5hbWUgPSAiY29sb3IiOwogICAgbGV0IGFsdFByb3BOYW1lID0gcHJvcE5hbWU7CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgQm9yZGVyKSB7CiAgICAgIHByb3BOYW1lID0gImJhY2tncm91bmQtY29sb3IiOwogICAgICBhbHRQcm9wTmFtZSA9ICJiYWNrZ3JvdW5kIjsKICAgICAgaWYgKGdncmFuZHBhIGluc3RhbmNlb2YgVWkpIHsKICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSAid2hpdGUiOwogICAgICB9CiAgICB9CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgUmVjdGFuZ2xlIHx8IHBhcmVudCBpbnN0YW5jZW9mIEFyYykgewogICAgICBwcm9wTmFtZSA9IGFsdFByb3BOYW1lID0gImZpbGwiOwogICAgICBzdHlsZS5maWxsID0gIndoaXRlIjsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImV4dHJhcyIgfHwgbmFtZSA9PT0gImNvbG9yIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBjb2xvciA9IG9ialtfeGZhX29iamVjdC4kdG9TdHlsZV0odGhpcy5jb2xvcik7CiAgICAgIGlmIChjb2xvcikgewogICAgICAgIHN0eWxlW2NvbG9yLnN0YXJ0c1dpdGgoIiMiKSA/IHByb3BOYW1lIDogYWx0UHJvcE5h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9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMuYmFzZWxpbmVTaGlmdCk7CiAgICB9CiAgICBzdHlsZS5mb250S2VybmluZyA9IHRoaXMua2VybmluZ01vZGUgPT09ICJub25lIiA/ICJub25lIiA6ICJub3JtYWwiOwogICAgc3R5bGUubGV0dGVyU3BhY2luZyA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMubGV0dGVyU3BhY2luZyk7CiAgICBpZiAodGhpcy5saW5lVGhyb3VnaCAhPT0gMCkgewogICAgICBzdHlsZS50ZXh0RGVjb3JhdGlvbiA9ICJsaW5lLXRocm91Z2giOwogICAgICBpZiAodGhpcy5saW5lVGhyb3VnaCA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMub3ZlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAib3ZlcmxpbmUiOwogICAgICBpZiAodGhpcy5vdmVybGluZSA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgc3R5bGUuZm9udFN0eWxlID0gdGhpcy5wb3N0dXJlOwogICAgc3R5bGUuZm9udFNpemUgPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKSgwLjk5ICogdGhpcy5zaXplKTsKICAgICgwLCBfaHRtbF91dGlscy5zZXRGb250RmFtaWx5KSh0aGlzLCB0aGlzLCB0aGlzW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXS5mb250RmluZGVyLCBzdHlsZSk7CiAgICBpZiAodGhpcy51bmRlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAidW5kZXJsaW5lIjsKICAgICAgaWYgKHRoaXMudW5kZX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ICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCF0aGlzLmNvbnRlbnRUeXBlKSB7CiAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkVNUFRZOwogICAgICB9CiAgICB9CiAgICBjb25zdCBibG9iID0gbmV3IEJsb2IoW2J1ZmZlcl0sIHsKICAgICAgdHlwZTogdGhpcy5jb250ZW50VHlwZQogICAgfSk7CiAgICBsZXQgc3R5bGU7CiAgICBzd2l0Y2ggKHRoaXMuYXNwZWN0KSB7CiAgICAgIGNhc2UgImZpdCI6CiAgICAgIGNhc2UgImFjdHVhbCI6CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhlaWdodCI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICBoZWlnaHQ6ICIxMDAlIiwKICAgICAgICAgIG9iamVjdEZpdDogImZpbGwiCiAgICAgICAgfTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAibm9uZSI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgICAgaGVpZ2h0OiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIndpZHRoIjoKICAgICAgICBzdHlsZSA9IHsKICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICB9CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgIG5hbWU6ICJpbWciLAogICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgY2xhc3M6IFsieGZhSW1hZ2UiXSwKICAgICAgICBzdHlsZSwKICAgIC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IDApOwogICAgc3R5bGUuc3Ryb2tlID0gZWRnZVN0eWxlLmNvbG9yOwogICAgY29uc3QgY29ybmVyID0gdGhpcy5jb3JuZXIuY2hpbGRyZW4ubGVuZ3RoID8gdGhpcy5jb3JuZXIuY2hpbGRyZW5bMF0gOiBuZXcgQ29ybmVyKHt9KTsKICAgIGNvbnN0IGNvcm5lclN0eWxlID0gY29ybmVyW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpOwogICAgY29uc3QgcmVjdCA9IHsKICAgICAgbmFtZTogInJlY3QiLAogICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgeG1sbnM6IFNWR19OUywKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiLAogICAgICAgIHg6IDAsCiAgICAgICAgeTogMCwKICAgICAgICByeDogY29ybmVyU3R5bGUucmFkaXVzLAogICAgICAgIHJ5OiBjb3JuZXJTdHlsZS5yYWRpdXMsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbcmVjdF0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICBvdmVyZmxvdzogInZpc2libGUiCiAgICAgICAgfSwKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgIH0KICAgIH07CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKClbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgIGlmIChoYXNNYXJnaW4ocGFyZW50KSkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICA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hYmxlID0gbnVsbDsKICAgICAgdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSA9IGZhbHNlOwogICAgICBjb25zdCBmbHVzaCA9IGluZGV4ID0+IHsKICAgICAgICBjb25zdCBodG1sID0gcm9vdFtfeGZhX29iamVjdC4kZmx1c2hIVE1MXSgpOwogICAgICAgIGlmIChodG1sKSB7CiAgICAgICAgICBoYXNTb21ldGhpbmcgPSBoYXNTb21ldGhpbmcgfHwgaHRtbC5jaGlsZHJlbiAmJiBodG1sLmNoaWxkcmVuLmxlbmd0aCAhPT0gMDsKICAgICAgICAgIGh0bWxDb250ZW50QXJlYXNbaW5kZXhdLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleCwgaWkgPSBjb250ZW50QXJlYXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGNvbnRlbnRBcmVhID0gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmN1cnJlbnRDb250ZW50QXJlYSA9IGNvbnRlbnRBcmVhc1tpXTsKICAgICAgICBjb25zdCBzcGFjZSA9IHsKICAgICAgICAgIHdpZHRoOiBjb250ZW50QXJlYS53LAogICAgICAgICAgaGVpZ2h0OiBjb250ZW50QXJlYS5oCiAgICAgICAgfTsKICAgICAgICBzdGFydEluZGV4ID0gMDsKICAgICAgICBpZiAobGVhZGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2gobGVhZGVyW194ZmFfb2JqZWN0LiR0b0hUTUxdKHNwYWNlKS5odG1sKTsKICAgICAgICAgIGxlYWRlciA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICh0cmFpbGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2godHJhaWxlcltfeGZhX29iamVjdC4kdG9IVE1MXShzcGFjZSkuaHRtbCk7CiAgICAgICAgICB0cmFpbGVyID0gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3QgaHRtbCA9IHJvb3RbX3hmYV9vYmplY3QuJHRvSFRNTF0oc3BhY2UpOwogICAgICAgIGlmIChodG1sLnN1Y2Nlc3MpIHsKICAgICAgICAgIGlmIChodG1sLmh0bWwpIHsKICAgICAgICAgICAgaGFzU29tZXRoaW5nID0gaGFzU29tZXRoaW5nIHx8IGh0bWwuaHRtbC5jaGlsZHJlbiAmJiBodG1sLmh0bWwuY2hpbGRyZW4ubGVuZ3RoICE9PSAwOwogICAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2goaHRtbC5odG1sKTsKICAgICAgICAgIH0gZWxzZSBpZiAoIWhhc1NvbWV0aGluZyAmJiBtYWluSHRtbC5jaGlsZHJlbi5sZW5ndGggPiAxKSB7CiAgICAgICAgICAgIG1haW5IdG1sLmNoaWxkcmVuLnBvcCgpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG1haW5IdG1sOwogICAgICAgIH0KICAgICAgICBpZiAoaHRtbC5pc0JyZWFrKCkpIHsKICAgICAgICAgIGNvbnN0IG5vZGUgPSBodG1sLmJyZWFrTm9kZTsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gImF1dG8iKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUubGVhZGVyKSB7CiAgICAgICAgICAgIGxlYWRlciA9IHRoaXNbX3hmYV9vYmplY3QuJHNlYXJjaE5vZGVdKG5vZGUubGVhZGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICBsZWFkZXIgPSBsZWFkZXIgPyBsZWFkZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudHJhaWxlcikgewogICAgICAgICAgICB0cmFpbGVyID0gdGhpc1tfeGZhX29iamVjdC4kc2VhcmNoTm9kZV0obm9kZS50cmFpbGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICB0cmFpbGVyID0gdHJhaWxlciA/IHRyYWlsZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gInBhZ2VBcmVhIikgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQ7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0gZWxzZSBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQpIHsKICAgICAgICAgICAgaSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLnRhcmdldDsKICAgICAgICAgICAgc3RhcnRJbmRleCA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleCArIDE7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLm92ZXJmbG93Tm9kZSkgewogICAgICAgICAgY29uc3Qgbm9kZSA9IHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXS5vdmVyZmxvd05vZGU7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0ub3ZlcmZsb3dOb2RlID0gbnVsbDsKICAgICAgICAgIGNvbnN0IG92ZXJmbG93RXh0cmEgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oKTsKICAgICAgICAgIGNvbnN0IHRhcmdldCA9IG92ZXJmbG93RXh0cmEudGFyZ2V0OwogICAgICAgICAgb3ZlcmZsb3dFeHRyYS5hZGRMZWFkZXIgPSBvdmVyZmxvd0V4dHJhLmxlYWRlciAhPT0gbnVsbDsKICAgICAgICAgIG92ZXJmbG93RXh0cmEuYWRkVHJhaWxlciA9IG92ZXJmbG93RXh0cmEudHJhaWxlciAhPT0gbnVsbDsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgY29uc3QgY3VycmVudEluZGV4ID0gaTsKICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIGlmICh0YXJnZXQgaW5zdGFuY2VvZiBQYWdlQXJlYSkgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IHRhcmdldDsKICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0IGluc3RhbmNlb2YgQ29udGVudEFyZWEpIHsKICAgICAgICAgICAgY29uc3QgaW5kZXggPSBjb250ZW50QXJlYXMuaW5kZXhPZih0YXJnZXQpOwogICAgICAgICAgICBpZiAoaW5kZXggIT09IC0xKSB7CiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gY3VycmVudEluZGV4KSB7CiAgICAgICAgICAgICAgICBpID0gaW5kZXggLSAxOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaW5kZXg7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gdGFyZ2V0W194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICAgICAgICAgICAgc3RhcnRJbmRleCA9IHRhcmdldFBhZ2VBcmVhLmNvbnRlbnRBcmVhLmNoaWxkcmVuLmluZGV4T2YodGFyZ2V0KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZ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WN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOVx1MjAyOFxuXS8pLnJlZHVjZSgoYWNjLCBsaW5lKSA9PiB7CiAgICAgICAgaWYgKGxpbmUpIHsKICAgICAgICAgIGFjYy5wdXNoKGxpbmUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYWNjOwogICAgICB9LCBbXSkuam9pbigiXG4iKTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XVtfeGZhX29iamVjdC4kdGV4dF0oKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBpZiAodHlwZW9mIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID09PSAic3RyaW5nIikgewogICAgICBjb25zdCBodG1sID0gdmFsdWVUb0h0bWwodGhpc1tfeGZhX29iamVjdC4kY29udGVudF0pLmh0bWw7CiAgICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5pbmNsdWRlcygiXHUyMDI5IikpIHsKICAgICAgICBodG1sLm5hbWUgPSAiZGl2IjsKICAgICAgICBodG1sLmNoaWxkcmVuID0gW107CiAgICAgICAgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0uc3BsaXQoIlx1MjAyOSIpLm1hcChwYXJhID0+IHBhcmEuc3BsaXQoL1tcdTIwMjhcbl0vKS5yZWR1Y2UoKGFjYywgbGluZSkgPT4gewogICAgICAgICAgYWNjLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIGFjYzsKICAgICAgICB9LCBbXSkpLmZvckVhY2gobGluZXMgPT4gewogICAgICAgICAgaHRtbC5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgbmFtZTogInAiLAogICAg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0gZmllbGQgaW5zdGFuY2VvZiBEcmF3ID8gMSA6IDA7CiAgICB9CiAgICBpZiAodGhpcy5tdWx0aUxpbmUgPT09IDEpIHsKICAgICAgaHRtbCA9IHsKICAgICAgICBuYW1lOiAidGV4dGFyZWEiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIGRhdGFJZDogZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdICYmIGZpZWxkW194ZmFfb2JqZWN0LiRkYXRhXVtfeGZhX29iamVjdC4kdWlkXSB8fCBmaWVsZFtfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGZpZWxkSWQ6IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgY2xhc3M6IFsieGZhVGV4dGZpZWxkIl0sCiAgICAgICAgICBzdHlsZSwKICAgICAgICAgICJhcmlhLWxhYmVsIjogYXJpYUxhYmVsKGZpZWxkKSwKICAgICAgICAgICJhcmlhLXJlcXVpcmVkIjogZmFsc2UKICAgICAgICB9CiAgICAgIH07CiAgICB9IGVsc2UgewogICAgICBodG1sID0gewogICAgICAgIG5hbWU6ICJpbnB1dCIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgdHlwZTogInRleHQiLAogICAgICAgICAgZGF0YUlkOiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV0gJiYgZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdW194ZmFfb2JqZWN0LiR1aWRdIHx8IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgZmllbGRJZDogZmllbGRbX3hmYV9vYmplY3QuJHVpZF0sCiAgICAgICAgICBjbGFzczogWyJ4ZmFUZXh0ZmllbGQiXSwKICAgICAgICAgIHN0eWxlLAogICAgICAgICAgImFyaWEtbGFiZWwiOiBhcmlhTGFiZWwoZmllbGQpLAogICAgICAgICAgImFyaWEtcmVxdWlyZWQiOiBmYWxzZQogICAgICAgIH0KICAgICAgfTsKICAgIH0KICAgIGl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FPYmplY3QpIHsKICAgICAgICB0aGlzW25hbWVdID0gbnVsbDsKICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRyZW1vdmVDaGlsZF0ob2JqKTsKICAgICAgfQogICAgfQogICAgdGhpc1t2YWx1ZVtfeGZhX29iamVjdC4kbm9kZU5hbWVdXSA9IHZhbHVlOwogICAgdGhpc1tfeGZhX29iamVjdC4kYXBwZW5kQ2hpbGRdKHZhbHVlKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0ZXh0XSgpIHsKICAgIGlmICh0aGlzLmV4RGF0YSkgewogICAgICBpZiAodHlwZW9mIHRoaXMuZXhEYXRhW194ZmFfb2JqZWN0LiRjb250ZW50XSA9PT0gInN0cmluZyIpIHsKICAgICAgICByZXR1cm4gdGhpcy5leERhdGFbX3hmYV9vYmplY3QuJGNvbnRlbnRdLnRyaW0oKTsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5leERhdGFbX3hmYV9vYmplY3QuJGNvbnRlbnRdW194ZmFfb2JqZWN0LiR0ZXh0XSgpLnRyaW0oKTsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImltYWdlIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3QpIHsKICAgICAgICByZXR1cm4gKG9ialtfeGZhX29iamVjdC4kY29udGVudF0gfHwgIiIpLnRvU3RyaW5nKCkudHJpbSgpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbnVsbDsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModG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Rycyk7CiAgfQogIHN0YXRpYyBldmVudChhdHRycykgewogICAgcmV0dXJuIG5ldyBFdmVudChhdHRycyk7CiAgfQogIHN0YXRpYyBleERhdGEoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRXhEYXRhKGF0dHJzKTsKICB9CiAgc3RhdGljIGV4T2JqZWN0KGF0dHJzKSB7CiAgICByZXR1cm4gbmV3IEV4T2JqZWN0KGF0dHJzKTsKICB9CiAgc3RhdGljIGV4Y2xHcm91cChhdHRycykgewogICAgcmV0dXJuIG5ldyBFeGNsR3JvdXAoYXR0cnMpOwogIH0KICBzdGF0aWMgZXhlY3V0ZShhdHRycykgewogICAgcmV0dXJuIG5ldyBFeGVjdXRlKGF0dHJzKTsKICB9CiAgc3RhdGljIGV4dHJhcyhhdHRycykgewogICAgcmV0dXJuIG5ldyBFeHRyYXMoYXR0cnMpOwogIH0KICBzdGF0aWMgZmllbGQoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRmllbGQoYXR0cnMpOwogIH0KICBzdGF0aWMgZmlsbChhdHRycykgewogICAgcmV0dXJuIG5ldyBGaWxsKGF0dHJzKTsKICB9CiAgc3RhdGljIGZpbHRlcihhdHRycykgewogICAgcmV0dXJuIG5ldyBGaWx0ZXIoYXR0cnMpOwogIH0KICBzdGF0aWMgZmxvYXQoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRmxvYXQoYXR0cnMpOwogIH0KICBzdGF0aWMgZm9udChhdHRycykgewogICAgcmV0dXJuIG5ldyBGb250KGF0dHJzKTsKICB9CiAgc3RhdGljIGZvcm1hdChhdHRycykgewogICAgcmV0dXJuIG5ldyBGb3JtYXQoYXR0cnMpOwogIH0KICBzdGF0aWMgaGFuZGxlcihhdHRycykgewogICAgcmV0dXJuIG5ldyBIYW5kbGVyKGF0dHJzKTsKICB9CiAgc3RhdGljIGh5cGhlbmF0aW9uKGF0dHJzKSB7CiAgICByZXR1cm4gbmV3IEh5cGhlbmF0aW9uKGF0dHJzKTsKICB9Ci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gICBleHRyYS53aWR0aCA9IE1hdGgubWF4KGV4dHJhLndpZHRoLCB4ICsgdyk7CiAgICAgICAgZXh0cmEuaGVpZ2h0ID0gTWF0aC5tYXgoZXh0cmEuaGVpZ2h0LCB5ICsgaCk7CiAgICAgICAgZXh0cmEuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgY2FzZSAibHItdGIiOgogICAgY2FzZSAicmwtdGIiOgogICAgICBpZiAoIWV4dHJhLmxpbmUgfHwgZXh0cmEuYXR0ZW1wdCA9PT0gMSkgewogICAgICAgIGV4dHJhLmxpbmUgPSBjcmVhdGVMaW5lKG5vZGUsIFtdKTsKICAgICAgICBleHRyYS5jaGlsZHJlbi5wdXNoKGV4dHJhLmxpbmUpOwogICAgICAgIGV4dHJhLm51bWJlckluTGluZSA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEubnVtYmVySW5MaW5lICs9IDE7CiAgICAgIGV4dHJhLmxpbmUuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgaWYgKGV4dHJhLmF0dGVtcHQgPT09IDApIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGV4dHJhLnByZXZIZWlnaHQgKyBoKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggPSB3OwogICAgICAgIGV4dHJhLnByZXZIZWlnaHQgPSBleHRyYS5oZWlnaHQ7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuYXR0ZW1wdCA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEud2lkdGggPSBNYXRoLm1heChleHRyYS53aWR0aCwgZXh0cmEuY3VycmVudFdpZHRoKTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJybC1yb3ciOgogICAgY2FzZSAicm93IjoKICAgICAgewogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgZXh0cmEud2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGgpOwogICAgICAgIGNvbnN0IGhlaWdodCA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKGV4dHJhLmhlaWdodCk7CiAgICAgICAgZm9yIChjb25zdCBjaGlsZCBvZiBleHRyYS5jaGlsZHJlbikgewogICAgICAgICAgY2hpbGQuYXR0cmlidXRlcy5zdHlsZS5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICBjYXNlICJ0YWJsZSI6CiAgICAgIHsKICAgICAgICBleHRyYS53aWR0aCA9IE1hdGgubWluKGF2YWlsYWJsZVNwYWNlLndpZHRoLCBNYXRoLm1heChleHRyYS53aWR0aCwgdykpOwogICAgICAgIGV4dHJhLmhlaWdodCArPSBoOwogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIGNhc2UgInRiIjoKICAgICAgewogICAgICAgIGV4dHJhLndpZHRoID0gTWF0aC5taW4oYXZhaWxhYmxlU3BhY2Uud2lkdGgsIE1hdGgubWF4KGV4dHJhLndpZHRoLCB3KSk7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgICBicmVhazsKICAgICAgfQogIH0KfQpmdW5jdGlvbiBnZXRBdmFpbGFibGVTcGFjZShub2RlKSB7CiAgY29uc3QgYXZhaWxhYmxlU3BhY2UgPSBub2RlW194ZmFfb2JqZWN0LiRleHRyYV0uYXZhaWxhYmxlU3BhY2U7CiAgY29uc3QgbWFyZ2luViA9IG5vZGUubWFyZ2luID8gbm9kZS5tYXJnaW4udG9wSW5zZXQgKyBub2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wogICAgY2FzZSAidGFibGUiOgogICAgY2FzZSAidGIiOgogICAgICByZXR1cm4gewogICAgICAgIHdpZHRoOiBhdmFpbGFibGVTcGFjZS53aWR0aCAtIG1hcmdpbkgsCiAgICAgICAgaGVpZ2h0OiBhdmFpbGFibGVTcGFjZS5oZWlnaHQgLSBtYXJnaW5WIC0gbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLmhlaWdodAogICAgICB9OwogICAgY2FzZSAicG9zaXRpb24iOgogICAgZGVmYXVsdDoKICAgICAgcmV0dXJuIGF2YWlsYWJsZVNwYWNlOwogIH0KfQpmdW5jdGlvbiBnZXRUcmFuc2Zvcm1lZEJCb3gobm9kZSkgewogIGxldCB3ID0gbm9kZS53ID09PSAiIiA/IE5hTiA6IG5vZGUudzsKICBsZXQgaCA9IG5vZGUuaCA9PT0gIiIgPyBOYU4gOiBub2RlLmg7CiAgbGV0IFtjZW50ZXJYLCBjZW50ZXJZXSA9IFswLCAwXTsKICBzd2l0Y2ggKG5vZGUuYW5jaG9yVHlwZSB8fCAiIikgewogICAgY2FzZSAiYm90dG9tQ2VudGVyIjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3cgLyAyLCBoXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJib3R0b21MZWZ0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gWzAsIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgImJvdHRvbVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUNlbnRlciI6CiAgICAgIFtjZW50ZXJYLCBjZW50ZXJZXSA9IFt3IC8gMiwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUxlZnQiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbMCwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGggLyAyXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJ0b3BDZW50ZXIiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbdyAvIDIsIDBdOwogICAgICBicmVhazsKICAgIGNhc2UgInRvcFJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIDBdOwogICAgICBicmVhazsKICB9CiAgbGV0IHgsIHk7CiAgc3dpdGNoIChub2RlLnJvdGF0ZSB8fCAwKSB7CiAgICBjYXNlIDA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWCwgLWNlbnRlclldOwogICAgICBicmVhazsKICAgIGNhc2UgOTA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWSwgY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFtoLCAtd107CiAgICAgIGJyZWFrOwogICAgY2FzZSAxODA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJYLCBjZW50ZXJZXTsKICAgICAgW3csIGhdID0gWy13LCAtaF07CiAgICAgIGJyZWFrOwogICAgY2FzZSAyNzA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJZLCAtY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFstaCwgd107CiAgICAgIGJyZWFrOwogIH0KICByZXR1cm4gW25vZGUueCArIHggKyBNYXRoLm1pbigwLCB3KSwgbm9kZS55ICsgeSArIE1hdGgubWluKDAsIGgpLCBNYXRoLmFicyh3KSwgTWF0aC5hYnMoaCldOwp9CmZ1bmN0aW9uIGNoZWNrRGltZW5zaW9ucyhub2RlLCBzcGFjZSkgewogIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJvb3RdKClbX3hmYV9vYmplY3QuJGV4dHJhXS5maXJzdFVuc3BsaXR0YWJsZSA9PT0gbnVsbCkgewogICAgcmV0dXJuIHRydWU7CiAgfQogIGlmIChub2RlLncgPT09IDAgfHwgbm9kZS5oID09PSAwKSB7CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgY29uc3QgRVJST1IgPSAyOwogIGNvbnN0IHBhcmVudCA9IG5vZGVbX3hmYV9vYmplY3QuJGdldFN1YmZvcm1QYXJlbnRdKCk7CiAgY29uc3QgYXR0ZW1wdCA9IHBhcmVudFtfeGZhX29iamVjdC4kZXh0cmFdICYmIHBhcmVudFtfeGZhX29iamVjdC4kZXh0cmFdLmF0dGVtcHQgfHwgMDsKICBjb25zdCBbLCB5LCB3LCBoXSA9IGdldFRyYW5zZm9ybWVkQkJveChub2RlKTsKICBzd2l0Y2ggKHBhcmVudC5sYXlvdXQpIHsKICAgIGNhc2UgImxyLXRiIjoKICAgIGNhc2UgInJsLXRiIjoKICAgICAgaWYgKGF0dGVtcHQgPT09IDApIHsKICAgICAgICBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgICAgaWYgKG5vZGUuaCAhPT0gIiIgJiYgTWF0aC5yb3VuZChoIC0gc3BhY2UuaGVpZ2h0KSA+IEVSUk9SKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChub2RlLncgIT09ICIiKSB7CiAgICAgICAgICAgIGlmIChNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocGFyZW50W194ZmFfb2JqZWN0LiRleHRyYV0ubnVtYmVySW5MaW5lID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHNwYWNlLmhlaWdodCA+IEVSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzcGFjZS53aWR0aCA+IEVSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAobm9kZS53ICE9PSAiIikgewogICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQodyAtIHNwYWNlLndpZHRoKSA8PSBFUlJPUjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHNwYWNlLndpZHRoID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKG5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChub2RlLmggIT09ICIiICYmIE1hdGgucm91bmQoaCAtIHNwYWNlLmhlaWdodCkgPiBFUlJPUikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobm9kZS53ID09PSAiIiB8fCBNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKHBhcmVudFtfeGZhX29iamVjdC4kaXNUaGVyZU1vcmVXaWR0aF0oKSkgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICBjYXNlICJ0YWJsZSI6CiAgICBjYXNlICJ0YiI6CiAgICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJvb3RdKClbX3hmYV9vYmplY3QuJGV4dHJhXS5ub0xheW91dEZhaWx1cmUpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBpZiAobm9kZS5oICE9PSAiIiAmJiAhbm9kZVtfeGZhX29iamVjdC4kaXNTcGxpdHRhYmxlXSgpKSB7CiAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoaCAtIHNwYWNlLmhlaWdodCkgPD0gRVJ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OwogICAgc3R5bGUudG9wID0gbWVhc3VyZVRvU3RyaW5nKG5vZGUueSk7CiAgfSwKICByb3RhdGUobm9kZSwgc3R5bGUpIHsKICAgIGlmIChub2RlLnJvdGF0ZSkgewogICAgICBpZiAoISgidHJhbnNmb3JtIiBpbiBzdHlsZSkpIHsKICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSAiIjsKICAgICAgfQogICAgICBzdHlsZS50cmFuc2Zvcm0gKz0gYHJvdGF0ZSgtJHtub2RlLnJvdGF0ZX1kZWcpYDsKICAgICAgc3R5bGUudHJhbnNmb3JtT3JpZ2luID0gInRvcCBsZWZ0IjsKICAgIH0KICB9LAogIHByZXNlbmNlKG5vZGUsIHN0eWxlKSB7CiAgICBzd2l0Y2ggKG5vZGUucHJlc2VuY2UpIHsKICAgICAgY2FzZSAiaW52aXNpYmxlIjoKICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhpZGRlbiI6CiAgICAgIGNhc2UgImluYWN0aXZlIjoKICAgICAgICBzdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgICAgIGJyZWFrOwogICAgfQogIH0sCiAgaEFsaWduKG5vZGUsIHN0eWxlKSB7CiAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kbm9kZU5hbWVdID09PSAicGFyYSIpIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImp1c3RpZnlBbGwiOgogICAgICAgICAgc3R5bGUudGV4dEFsaWduID0gImp1c3RpZnktYWxsIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJhZGl4IjoKICAgICAgICAgIHN0eWxlLnRleHRBbGlnbiA9ICJsZWZ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBub2RlLmhBbGlnbjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgICAgc3R5bGUuYWxpZ25TZWxmID0gInN0YXJ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImNlbnRlciI6CiAgICAgICAgICBzdHlsZS5hbGlnblNlbGYgPSAiY2VudGVyIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICAgIHN0eWxlLmFsaWduU2VsZiA9ICJlbmQiOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICB9LAogIG1hcmdpbihub2RlLCBzdHlsZSkgewogICAgaWYgKG5vZGUubWFyZ2luKSB7CiAgICAgIHN0eWxlLm1hcmdpbiA9IG5vZGUubWFyZ2luW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpLm1hcmdpbjsKICAgIH0KICB9Cn07CmZ1bmN0aW9uIHNldE1pbk1heERpbWVuc2lvbnMobm9kZSwgc3R5bGUpIHsKICBjb25zdCBwYXJlbnQgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpOwogIGlmIChwYXJlbnQubGF5b3V0ID09PSAicG9zaXRpb24iKSB7CiAgICBpZiAobm9kZS5taW5XID4gMCkgewogICAgICBzdHlsZS5taW5XaWR0aCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLm1pblcpOwogICAgfQogICAgaWYgKG5vZGUubWF4VyA+IDApIHsKICAgICAgc3R5bGUubWF4V2lkdGggPSBtZWFzdXJlVG9TdHJpbmcobm9kZS5tYXhXKTsKICAgIH0KICAgIGlmIChub2RlLm1pbkggPiAwKSB7CiAgICAgIHN0eWxlLm1pbkhlaWdodCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLm1pbkgpOwogICAgfQogICAgaWYgKG5vZGUubWF4SCA+IDApIHsKICAgICAgc3R5bGUubWF4SGVpZ2h0ID0gbWVhc3VyZVRvU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WwsIGF2YWlsYWJsZVNwYWNlKSB7CiAgbGV0IGJib3g7CiAgaWYgKG5vZGUudyAhPT0gIiIgJiYgbm9kZS5oICE9PSAiIikgewogICAgYmJveCA9IFtub2RlLngsIG5vZGUueSwgbm9kZS53LCBub2RlLmhdOwogIH0gZWxzZSB7CiAgICBpZiAoIWF2YWlsYWJsZVNwYWNlKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IHdpZHRoID0gbm9kZS53OwogICAgaWYgKHdpZHRoID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhXID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQudyAhPT0gIiIpIHsKICAgICAgICAgIHdpZHRoID0gMDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2lkdGggPSBub2RlLm1pblc7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIHdpZHRoID0gTWF0aC5taW4obm9kZS5tYXhXLCBhdmFpbGFibGVTcGFjZS53aWR0aCk7CiAgICAgIH0KICAgICAgaHRtbC5hdHRyaWJ1dGVzLnN0eWxlLndpZHRoID0gbWVhc3VyZVRvU3RyaW5nKHdpZHRoKTsKICAgIH0KICAgIGxldCBoZWlnaHQgPSBub2RlLmg7CiAgICBpZiAoaGVpZ2h0ID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhIID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQuaCAhPT0gIiIpIHsKICAgICAgICAgIGhlaWdodCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgIC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CA/IGBjYWxjKDEwMCUgLSAke2luc2V0c0h9cHgpYCA6ICIxMDAlIjsKICAgICAgICBicmVhazsKICAgIH0KICAgIGNvbnN0IGNsYXNzTmFtZXMgPSBbInhmYUJvcmRlciJdOwogICAgaWYgKGlzUHJpbnRPbmx5KG5vZGUuYm9yZGVyKSkgewogICAgICBjbGFzc05hbWVzLnB1c2goInhmYVByaW50T25seSIpOwogICAgfQogICAgY29uc3QgYm9yZGVyID0gewogICAgICBuYW1lOiAiZGl2IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBjbGFzc05hbWVzLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICB0b3A6IGAke3RvcH1weGAsCiAgICAgICAgICBsZWZ0OiBgJHtsZWZ0fXB4YCwKICAgICAgICAgIHdpZHRoLAogICAgICAgICAgaGVpZ2h0CiAgICAgICAgfQogICAgICB9LAogICAgICBjaGlsZHJlbjogW10KICAgIH07CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImJvcmRlciIsICJib3JkZXJXaWR0aCIsICJib3JkZXJDb2xvciIsICJib3JkZXJSYWRpdXMiLCAiYm9yZGVyU3R5bGUiXSkgewogICAgICBpZiAoc3R5bGVba2V5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgYm9yZGVyLmF0dHJpYnV0ZXMuc3R5bGVba2V5XSA9IHN0eWxlW2tleV07CiAgICAgICAgZGVsZXRlIHN0eWxlW2tleV07CiAgICAgIH0KICAgIH0KICAgIHdyYXBwZXIuY2hpbGRyZW4ucHVzaChib3JkZXIsIGh0bWwpOwogIH0gZWxzZSB7CiAgICB3cmFwcGVyLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgfQogIGZvciAoY29uc3Qga2V5IG9mIFsiYmFja2dyb3VuZCIsICJiYWNrZ3JvdW5kQ2xpcCIsICJ0b3AiLCAibGVmdCIsICJ3aWR0aCIsICJoZWlnaHQiLCAibWluV2lkdGgiLCAibWluSGVpZ2h0IiwgIm1he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ewogICAgICBpZiAobm9kZS5oID09PSAiIikgewogICAgICAgIG5vZGVTdHlsZS5oZWlnaHQgPSAiYXV0byI7CiAgICAgIH0KICAgICAgaWYgKG5vZGUudyA9PT0gIiIpIHsKICAgICAgICBub2RlU3R5bGUud2lkdGggPSAiYXV0byI7CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IHBhcmEgPSBnZXRDdXJyZW50UGFyYShub2RlKTsKICAgIGlmIChwYXJhKSB7CiAgICAgIGNvbnN0IHZhbHVlU3R5bGUgPSB2YWx1ZS5hdHRyaWJ1dGVzLnN0eWxlOwogICAgICB2YWx1ZVN0eWxlLmRpc3BsYXkgPSAiZmxleCI7CiAgICAgIHZhbHVlU3R5bGUuZmxleERpcmVjdGlvbiA9ICJjb2x1bW4iOwogICAgICBzd2l0Y2ggKHBhcmEudkFsaWduKSB7CiAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICAgIHZhbHVlU3R5bGUuanVzdGlmeUNvbnRlbnQgPSAic3RhcnQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYm90dG9tIjoKICAgICAgICAgIHZhbHVlU3R5bGUuanVzdGlmeUNvbnRlbnQgPSAiZW5kIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm1pZGRsZSI6CiAgICAgICAgICB2YWx1ZVN0eWxlLmp1c3RpZnlDb250ZW50ID0gImNlbnRlciI7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBjb25zdCBwYXJhU3R5bGUgPSBwYXJhW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpOwogICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbF0gb2YgT2JqZWN0LmVudHJpZXMocGFyYVN0eWxlKSkgewogICAgICAgIGlmICghKGtleSBpbiB2YWx1ZVN0eWxlKSkgewogICAgICAgICAgdmFsdWVTdHlsZVtrZXldID0gdmFsOwogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KfQpmdW5jdGlvbiBzZXRGb250R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GlzLmFkZFBkZkZvbnQocGRmRm9udCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IHBkZkZvbnQgb2YgdGhpcy5mb250cy52YWx1ZXMoKSkgewogICAgICBpZiAoIXBkZkZvbnQucmVndWxhcikgewogICAgICAgIHBkZkZvbnQucmVndWxhciA9IHBkZkZvbnQuaXRhbGljIHx8IHBkZkZvbnQuYm9sZCB8fCBwZGZGb250LmJvbGRpdGFsaWM7CiAgICAgIH0KICAgIH0KICAgIGlmICghcmVhbGx5TWlzc2luZ0ZvbnRzIHx8IHJlYWxseU1pc3NpbmdGb250cy5zaXplID09PSAwKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGNvbnN0IG15cmlhZCA9IHRoaXMuZm9udHMuZ2V0KCJQZGZKUy1GYWxsYmFjay1QZGZKUy1YRkEiKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiByZWFsbHlNaXNzaW5nRm9udHMpIHsKICAgICAgdGhpcy5mb250cy5zZXQobWlzc2luZywgbXlyaWFkKTsKICAgIH0KICB9CiAgYWRkUGRmRm9udChwZGZGb250KSB7CiAgICBjb25zdCBjc3NGb250SW5mbyA9IHBkZkZvbnQuY3NzRm9udEluZm87CiAgICBjb25zdCBuYW1lID0gY3NzRm9udEluZm8uZm9udEZhbWlseTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoIWZvbnQpIHsKICAgICAgZm9udCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgIHRoaXMuZm9udHMuc2V0KG5hbWUsIGZvbnQpOwogICAgICBpZiAoIXRoaXMuZGVmYXVsdEZvbnQpIHsKICAgICAgICB0aGlzLmRlZmF1bHRGb250ID0gZm9udDsKICAgICAgfQogICAgfQogICAgbGV0IHByb3BlcnR5ID0gIiI7CiAgICBjb25zdCBmb250V2VpZ2h0ID0gcGFyc2VGbG9hdChjc3NGb250SW5mby5mb250V2VpZ2h0KTsKICAgIGlmIChwYXJzZUZ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2FjaGUuZ2V0KGZvbnROYW1lKTsKICAgIGlmIChmb250KSB7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgY29uc3QgcGF0dGVybiA9IC8sfC18X3wgfGJvbGRpdGFsaWN8Ym9sZHxpdGFsaWN8cmVndWxhcnxpdC9naTsKICAgIGxldCBuYW1lID0gZm9udE5hbWUucmVwbGFjZUFsbChwYXR0ZXJuLCAiIik7CiAgICBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoZm9udCkgewogICAgICB0aGlzLmNhY2hlLnNldChmb250TmFtZSwgZm9udCk7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgbmFtZSA9IG5hbWUudG9Mb3dlckNhc2UoKTsKICAgIGNvbnN0IG1heWJlID0gW107CiAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgIGlmIChmYW1pbHkucmVwbGFjZUFsbChwYXR0ZXJuLCAiIikudG9Mb3dlckNhc2UoKS5zdGFydHNXaXRoKG5hbWUpKSB7CiAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgfQogICAgfQogICAgaWYgKG1heWJlLmxlbmd0aCA9PT0gMCkgewogICAgICBmb3IgKGNvbnN0IFssIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPT09IDApIHsKICAgICAgbmFtZSA9IG5hbWUucmVwbGFjZUFsbCgvcHNtdHxtdC9naSwgIiIpOwogICAgICBmb3IgK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WF0aC5tYXgoMSwgbm9HYXApICogZm9udFNpemU7CiAgICAgIGNvbnN0IHNjYWxlID0gZm9udFNpemUgLyAxMDAwOwogICAgICBjb25zdCBmYWxsYmFja1dpZHRoID0gcGRmRm9udC5kZWZhdWx0V2lkdGggfHwgcGRmRm9udC5jaGFyc1RvR2x5cGhzKCIgIilbMF0ud2lkdGg7CiAgICAgIGZvciAoY29uc3QgbGluZSBvZiBzdHIuc3BsaXQoL1tcdTIwMjlcbl0vKSkgewogICAgICAgIGNvbnN0IGVuY29kZWRMaW5lID0gcGRmRm9udC5lbmNvZGVTdHJpbmcobGluZSkuam9pbigiIik7CiAgICAgICAgY29uc3QgZ2x5cGhzID0gcGRmRm9udC5jaGFyc1RvR2x5cGhzKGVuY29kZWRMaW5lKTsKICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgY29uc3Qgd2lkdGggPSBnbHlwaC53aWR0aCB8fCBmYWxsYmFja1dpZHRoOwogICAgICAgICAgdGhpcy5nbHlwaHMucHVzaChbd2lkdGggKiBzY2FsZSArIGxldHRlclNwYWNpbmcsIGxpbmVIZWlnaHQsIGZpcnN0TGluZUhlaWdodCwgZ2x5cGgudW5pY29kZSwgZmFsc2VdKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5nbHlwaHMucHVzaChbMCwgMCwgMCwgIlxuIiwgdHJ1ZV0pOwogICAgICB9CiAgICAgIHRoaXMuZ2x5cGhzLnBvcCgpOwogICAgICByZXR1cm47CiAgICB9CiAgICBmb3IgKGNvbnN0IGxpbmUgb2Ygc3RyLnNwbGl0KC9bXHUyMDI5XG5dLykpIHsKICAgICAgZm9yIChjb25zdCBjaGFyIG9mIGxpbmUuc3BsaXQoIiIpKSB7CiAgICAgICAgdGhpcy5nbHlwaHMucHVzaChbZm9udFNpemUsIDEuMiAqIGZvbnRTaXplLCBmb250U2l6ZSwgY2hhciwgZmFsc2VdKTsKICAgICAgfQogICAgICB0aGlzLmdseXBocy5w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NTcGFjZSkgewogICAgICAgIGlmIChjdXJyZW50TGluZVdpZHRoICsgZ2x5cGhXaWR0aCA+IG1heFdpZHRoKSB7CiAgICAgICAgICB3aWR0aCA9IE1hdGgubWF4KHdpZHRoLCBjdXJyZW50TGluZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgaGVpZ2h0ICs9IGN1cnJlbnRMaW5lSGVpZ2h0OwogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICAgIGxhc3RTcGFjZVBvcyA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSAwOwogICAgICAgICAgaXNCcm9rZW4gPSB0cnVlOwogICAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSBjdXJyZW50TGluZVdpZHRoOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gaTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnRMaW5lV2lkdGggKyBnbHlwaFdpZHRoID4gbWF4V2lkdGgpIHsKICAgICAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQ7CiAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICBpZiAobGFzdFNwYWNlUG9zICE9PSAtMSkgewogICAgICAgICAgaSA9IGxhc3RTcGFjZVBvczsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGxhc3RTcGFjZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggP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bmFtZSwKICAgICAgdmFsdWUKICAgIH0gb2YgYXR0cmlidXRlcykgewogICAgICBpZiAobmFtZSA9PT0gInhtbG5zIikgewogICAgICAgIGlmICghbmFtZXNwYWNlKSB7CiAgICAgICAgICBuYW1lc3BhY2UgPSB2YWx1ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBYRkEgLSBtdWx0aXBsZSBuYW1lc3BhY2UgZGVmaW5pdGlvbiBpbiA8JHt0YWdOYW1lfT5gKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAobmFtZS5zdGFydHNXaXRoKCJ4bWxuczoiKSkgewogICAgICAgIGNvbnN0IHByZWZpeCA9IG5hbWUuc3Vic3RyaW5nKCJ4bWxuczoiLmxlbmd0aCk7CiAgICAgICAgaWYgKCFwcmVmaXhlcykgewogICAgICAgICAgcHJlZml4ZXMgPSBbXTsKICAgICAgICB9CiAgICAgICAgcHJlZml4ZXMucHVzaCh7CiAgICAgICAgICBwcmVmaXgsCiAgICAgICAgICB2YWx1ZQogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGkgPSBuYW1lLmluZGV4T2YoIjoiKTsKICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgIGF0dHJpYnV0ZU9ialtuYW1lXSA9IHZhbHVlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBsZXQgbnNBdHRycyA9IGF0dHJpYnV0ZU9ialtfeGZhX29iamVjdC4kbnNBdHRyaWJ1dGVzXTsKICAgICAgICAgIGlmICghbnNBdHRycykgewogICAgICAgICAgICBuc0F0dHJzID0gYXR0cmlidXRlT2JqW194ZmFfb2JqZWN0LiRuc0F0dHJpYnV0ZXNdID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IFtucywgYXR0ck5hbWVdID0gW25hbWUuc2xpY2UoMCwgaSksIG5hbWUuc2xpY2UoaSArID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NBZ25vc3RpY10oKSkgewogICAgICBub2RlW194ZmFfb2JqZWN0LiRjbGVhbnVwXSA9IHsKICAgICAgICBoYXNOYW1lc3BhY2U6IGhhc05hbWVzcGFjZURlZiwKICAgICAgICBwcmVmaXhlcywKICAgICAgICBuc0Fnbm9zdGljOiBub2RlW194ZmFfb2JqZWN0LiRpc05zQWdub3N0aWNdKCkKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBub2RlOwogIH0KICBpc05zQWdub3N0aWMoKSB7CiAgICByZXR1cm4gdGhpcy5fbnNBZ25vc3RpY0xldmVsID4gMDsKICB9CiAgX3NlYXJjaE5hbWVzcGFjZShuc05hbWUpIHsKICAgIGxldCBucyA9IHRoaXMuX25hbWVzcGFjZXMuZ2V0KG5zTmFtZSk7CiAgICBpZiAobnMpIHsKICAgICAgcmV0dXJuIG5zOwogICAgfQogICAgZm9yIChjb25zdCBbbmFtZSwgewogICAgICBjaGVjawogICAgfV0gb2YgT2JqZWN0LmVudHJpZXMoX25hbWVzcGFjZXMuTmFtZXNwYWNlSWRzKSkgewogICAgICBpZiAoY2hlY2sobnNOYW1lKSkgewogICAgICAgIG5zID0gX3NldHVwLk5hbWVzcGFjZVNldFVwW25hbWVdOwogICAgICAgIGlmIChucykgewogICAgICAgICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICAgICAgICByZXR1cm4gbnM7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBucyA9IG5ldyBfdW5rbm93bi5Vbmtub3duTmFtZXNwYWNlKCsrdGhpcy5fbmV4dE5zSWQpOwogICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICByZXR1cm4gbnM7CiAgfQogIF9hZGROYW1lc3BhY2VQcmVmaXgocHJlZml4ZXMpIHsKICAgIGZvciAoY29uc3QgewogICAgICBwcmVmaXgsCiAgICAgIHZhbHVlCiAgICB9IG9mIHByZWZpeGVzKSB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lzW194ZmFfb2JqZWN0LiRjb250ZW50XSArPSBzdHI7CiAgICB9CiAgfQogIFtfeGZhX29iamVjdC4kcHVzaEdseXBoc10obWVhc3VyZSkgewogICAgbGV0IG11c3RQb3AgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHRydWU7CiAgICBjb25zdCB4ZmFGb250ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGNvbnN0IG1hcmdpbiA9IHsKICAgICAgdG9wOiBOYU4sCiAgICAgIGJvdHRvbTogTmFOLAogICAgICBsZWZ0OiBOYU4sCiAgICAgIHJpZ2h0OiBOYU4KICAgIH07CiAgICBsZXQgbGluZUhlaWdodCA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiB0aGlzLnN0eWxlLnNwbGl0KCI7IikubWFwKHMgPT4gcy5zcGxpdCgiOiIsIDIpKSkgewogICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgIGNhc2UgImZvbnQtZmFtaWx5IjoKICAgICAgICAgIHhmYUZvbnQudHlwZWZhY2UgPSAoMCwgX3V0aWxzLnN0cmlwUXVvdGVzKSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmb250LXNpemUiOgogICAgICAgICAgeGZhRm9udC5zaXplID0gKDAsIF91dGlscy5nZXRNZWFzdXJlbWVudCkodmFsdWUpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZm9udC13ZWlnaHQiOgogICAgICAgICAgeGZhRm9udC53ZWlnaHQgPSB2YWx1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZvbnQtc3R5bGUiOgogICAgICAgICAgeGZhRm9udC5wb3N0dXJlID0gdmFsdWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZXR0ZXItc3BhY2luZyI6CiAgICAgICAgICB4ZmFGb250LmxldHRlclNwYWNpbmcgPSAoMCwgX3V0aWxzLmdldE1lYXN1cmVtZW50KSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtYXJnaW4iOgogICAgICAgICAgY29uc3QgdmFsdWVzID0gdmFsdWUuc3BsaXQoLyBcdC8pLm1hcCh4ID0+ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHgpKTsKICAgICAgICAgIHN3aXRjaCAodmFsdWVzLmxlbmd0aCkgewogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IG1hcmdpbi5ib3R0b20gPSBtYXJnaW4ubGVmdCA9IG1hcmdpbi5yaWdodCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIG1hcmdpbi50b3AgPSBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzBdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4ubGVmdCA9IHZhbHVlc1sxXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5yaWdodCA9IHZhbHVlc1szXTsKICAgICAgICAgICAgICBicmVh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hc3N3b3JkKTsKICAgIH0KICAgIGxldCByb290OwogICAgdHJ5IHsKICAgICAgcm9vdCA9IHRyYWlsZXJEaWN0LmdldCgiUm9vdCIpOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYFhSZWYucGFyc2UgLSBJbnZhbGlkICJSb290IiByZWZlcmVuY2U6ICIke2V4fSIuYCk7CiAgICB9CiAgICBpZiAocm9vdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBwYWdlcyA9IHJvb3QuZ2V0KCJQYWdlcyIpOwogICAgICAgIGlmIChwYWdlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgIHRoaXMucm9vdCA9IHJvb3Q7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgICB0aHJvdyBleDsKICAgICAgICB9CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBYUmVmLnBhcnNlIC0gSW52YWxpZCAiUGFnZXMiIHJlZmVyZW5jZTogIiR7ZXh9Ii5gKTsKICAgICAgfQogICAgfQogICAgaWYgKCFyZWNvdmVyeU1vZGUpIHsKICAgICAgdGhyb3cgbmV3IF9jb3JlX3V0aWxzLlhSZWZQYXJzZUV4Y2VwdGlvbigpOwogICAgfQogICAgdGhyb3cgbmV3IF91dGlsLkludmFsaWRQREZFeGNlcHRpb24oIkludmFsaWQgUm9vdCByZWZlcmVuY2UuIik7CiAgfQogIHByb2Nlc3NYUmVmVGFibGUocGFyc2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mc2V0Qnl0ZTsKICAgICAgICB9CiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBnZW5lcmF0aW9uRmllbGRXaWR0aDsgKytqKSB7CiAgICAgICAgICBjb25zdCBnZW5lcmF0aW9uQnl0ZSA9IHN0cmVhbS5nZXRCeXRlKCk7CiAgICAgICAgICBpZiAoZ2VuZXJhdGlvbkJ5dGUgPT09IC0xKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBYUmVmIGJ5dGVXaWR0aHMgJ2dlbmVyYXRpb24nLiIpOwogICAgICAgICAgfQogICAgICAgICAgZ2VuZXJhdGlvbiA9IGdlbmVyYXRpb24gPDwgOCB8IGdlbmVyYXRpb25CeXRlOwogICAgICAgIH0KICAgICAgICBjb25zdCBlbnRyeSA9IHt9OwogICAgICAgIGVudHJ5Lm9mZnNldCA9IG9mZnNldDsKICAgICAgICBlbnRyeS5nZW4gPSBnZW5lcmF0aW9uOwogICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICBlbnRyeS5mcmVlID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgIGVudHJ5LnVuY29tcHJlc3NlZCA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgSW52YWxpZCBYUmVmIGVudHJ5IHR5cGU6ICR7dHlwZX1gKTsKICAgICAgICB9CiAgICAgICAgaWYgKCF0aGlzLmVudHJpZXNbZmlyc3QgKyBpXSkgewogICAgICAgICAgdGhpcy5lbnRyaWVzW2ZpcnN0ICsgaV0gPSBlbnRyeTsKICAgICAgICB9CiAgICAgIH0KICAgICAgc3RyZWFtU3RhdG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ogICAgd2hpbGUgKHBvc2l0aW9uIDwgbGVuZ3RoKSB7CiAgICAgIGxldCBjaCA9IGJ1ZmZlcltwb3NpdGlvbl07CiAgICAgIGlmIChjaCA9PT0gVEFCIHx8IGNoID09PSBMRiB8fCBjaCA9PT0gQ1IgfHwgY2ggPT09IFNQQUNFKSB7CiAgICAgICAgKytwb3NpdGlvbjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2ggPT09IFBFUkNFTlQpIHsKICAgICAgICBkbyB7CiAgICAgICAgICArK3Bvc2l0aW9uOwogICAgICAgICAgaWYgKHBvc2l0aW9uID49IGxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNoID0gYnVmZmVyW3Bvc2l0aW9uXTsKICAgICAgICB9IHdoaWxlIChjaCAhPT0gTEYgJiYgY2ggIT09IENSKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0b2tlbiA9IHJlYWRUb2tlbihidWZmZXIsIHBvc2l0aW9uKTsKICAgICAgbGV0IG07CiAgICAgIGlmICh0b2tlbi5zdGFydHNXaXRoKCJ4cmVmIikgJiYgKHRva2VuLmxlbmd0aCA9PT0gNCB8fCAvXHMvLnRlc3QodG9rZW5bNF0pKSkgewogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCB0cmFpbGVyQnl0ZXMpOwogICAgICAgIHRyYWlsZXJzLnB1c2gocG9zaXRpb24pOwogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCBzdGFydHhyZWZCeXRlcyk7CiAgICAgIH0gZWxzZSBpZiAobSA9IG9ialJlZ0V4cC5leGVjKHRva2VuKSkgewogICAgICAgIGNvbnN0IG51bSA9IG1bMV0gfCAwLAogICAgICAgICAgZ2VuID0gbVsyXSB8IDA7CiAgICAgICAgY29uc3Qgc3RhcnRQb3MgPSBwb3NpdGlvbiArIHRva2VuLmxlbmd0aDsKICAgICAgICBsZXQgY29udGVudExlbmd0aCwKICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSBmYWxzZTsKICAgICAgICBpZiAoIXRoaXMuZW50cmllc1tudW1dKSB7CiAgICAgICAgICB1cGRhdGVFbnRyaWVzID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKHRoaXMuZW50cmllc1tudW1dLmdlbiA9PT0gZ2VuKSB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBwYXJzZXIgPSBuZXcgX3BhcnNlci5QYXJzZXIoewogICAgICAgICAgICAgIGxleGVyOiBuZXcgX3BhcnNlci5MZXhlcihzdHJlYW0ubWFrZVN1YlN0cmVhbShzdGFydFBvcykpCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBwYXJzZXIuZ2V0T2JqKCk7CiAgICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSB0cnVlOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBpbmRleE9iamVjdHMgLS0gY2hlY2tpbmcgb2JqZWN0ICgke3Rva2VufSk6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdXBkYXRlRW50cmllcyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVwZGF0ZUVudHJpZXMpIHsKICAgICAgICAgIHRoaXMuZW50cmllc1tudW1dID0gewogICAgICAgICAgICBvZmZzZXQ6IHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0LAogICAgICAgICAgICBnZW4sCiAgICAgICAgICAgIHVuY29tcHJlc3NlZDogdHJ1ZQogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggPSBzdGFydFBvczsKICAgICAgICBjb25zdCBtYXRjaCA9IGdFbmRvYmpSZWdFeHAuZXhlYyhidWZmZXJTdHIpOwogICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgY29uc3QgZW5kUG9zID0gZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggKyAxOwogICAgICAgICAgY29udGVudExlbmd0aCA9IGVuZFBvcyAtIHBvc2l0aW9uOwogICAgICAgICAgaWYgKG1hdGNoWzFdICE9PSAiZW5kb2JqIikgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGluZGV4T2JqZWN0czogRm91bmQgIiR7bWF0Y2hbMV19IiBpbnNpZGUgb2YgYW5vdGhlciAib2JqIiwgYCArICdjYXVzZWQgYnkgbWlzc2luZyAiZW5kb2JqIiAtLSB0cnlpbmcgdG8gcmVjb3Zlci4nKTsKICAgICAgICAgICAgY29udGVudExlbmd0aCAtPSBtYXRjaFsxXS5sZW5ndGggKyAxOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250ZW50TGVuZ3RoID0gbGVuZ3RoIC0gcG9zaXRpb247CiAgICAgICAgfQogICAgICAgIGNvbnN0IGNvbnRlbnQgPSBidWZmZXIuc3ViYXJyYXkocG9zaXRpb24sIHBvc2l0aW9uICsgY29udGVudExlbmd0aCk7CiAgICAgICAgY29uc3QgeHJlZlRhZ09mZnNldCA9IHNraXBVbnRpbChjb250ZW50LCAwLCB4cmVmQnl0ZXMpOwogICAgICAgIGlmICh4cmVmVGFnT2Zmc2V0IDwgY29udGVudExlbmd0aCAmJiBjb250ZW50W3hyZWZUYWdPZmZzZXQgKyA1XSA8IDY0KSB7CiAgICAgICAgICB4cmVmU3Rtcy5wdXNoKHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0KTsKICAgICAgICAgIHRoaXMuX3hyZWZTdG1zLmFkZChwb3NpdGlvbiAtIHN0cmVhbS5z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bnN0IGRpY3Qgb2YgWy4uLnRyYWlsZXJEaWN0cywgImdlbkZhbGxiYWNrIiwgLi4udHJhaWxlckRpY3RzXSkgewogICAgICBpZiAoZGljdCA9PT0gImdlbkZhbGxiYWNrIikgewogICAgICAgIGlmICghdHJhaWxlckVycm9yKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZ2VuZXJhdGlvbkZhbGxiYWNrID0gdHJ1ZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdmFsaWRQYWdlc0RpY3QgPSBmYWxzZTsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCByb290RGljdCA9IGRpY3QuZ2V0KCJSb290Iik7CiAgICAgICAgaWYgKCEocm9vdERpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzRGljdCA9IHJvb3REaWN0LmdldCgiUGFnZXMiKTsKICAgICAgICBpZiAoIShwYWdlc0RpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzQ291bnQgPSBwYWdlc0RpY3QuZ2V0KCJDb3VudCIpOwogICAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKHBhZ2VzQ291bnQpKSB7CiAgICAgICAgICB2YWxpZFBhZ2VzRGljdCA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRyYWlsZXJFcnJvciA9IGV4OwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWxpZFBhZ2VzRGljdCAmJiAoIWlzRW5jcnlwdGVkIHx8IGRpY3QuaGFzKCJFbmNyeXB0IikpICYmIGRpY3QuaGFzKCJJRCIpKSB7CiAgICAgICAgcmV0dXJuIGRpY3Q7Ci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7CiAgICAgICAgICB9CiAgICAgICAgICBkaWN0ID0gdGhpcy5wcm9jZXNzWFJlZlN0cmVhbShvYmopOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghZGljdCkgewogICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkZhaWxlZCB0byByZWFkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBYUmVmIHN0cmVhbSBoZWFkZXIiKTsKICAgICAgICB9CiAgICAgICAgb2JqID0gZGljdC5nZXQoIlByZXYiKTsKICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihvYmopKSB7CiAgICAgICAgICB0aGlzLnN0YXJ0WFJlZlF1ZXVlLnB1c2gob2JqKTsKICAgICAgICB9IGVsc2UgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgdGhpcy5zdGFydFhSZWZRdWV1ZS5wdXNoKG9iai5udW0pOwogICAgICAgIH0KICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgIGlmIChlIGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGU7CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiKHdoaWxlIHJlYWRpbmcgWFJlZik6ICIgKyBlKTsKICAgICAgfQogICAgICB0aGlzLnN0YXJ0WFJlZlF1ZXVlLnNoaWZ0KCk7CiAgICB9CiAgICBpZiAodGhpcy50b3BEaWN0KSB7CiAgICAgIHJldHVybiB0aGlzLnRvcERpY3Q7CiAgICB9CiAgICBpZiAocmVjb3ZlcnlNb2RlKSB7C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AgICAgIGlmIChkYXRhLnRhcmdldE5hbWUgIT09IHRoaXMuc291cmNlTmFtZSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBpZiAoZGF0YS5zdHJlYW0pIHsKICAgICAgICB0aGlzLl9wcm9jZXNzU3RyZWFtTWVzc2FnZShkYXRhKTsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKGRhdGEuY2FsbGJhY2spIHsKICAgICAgICBjb25zdCBjYWxsYmFja0lkID0gZGF0YS5jYWxsYmFja0lkOwogICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzW2NhbGxiYWNrSWRdOwogICAgICAgIGlmICghY2FwYWJpbGl0eSkgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW5ub3QgcmVzb2x2ZSBjYWxsYmFjayAke2NhbGxiYWNrSWR9YCk7CiAgICAgICAgfQogICAgICAgIGRlbGV0ZSB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzW2NhbGxiYWNrSWRdOwogICAgICAgIGlmIChkYXRhLmNhbGxiYWNrID09PSBDYWxsYmFja0tpbmQuREFUQSkgewogICAgICAgICAgY2FwYWJpbGl0eS5yZXNvbHZlKGRhdGEuZGF0YSk7CiAgICAgICAgfSBlbHNlIGlmIChkYXRhLmNhbGxiYWNrID09PSBDYWxsYmFja0tpbmQuRVJST1IpIHsKICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJVbmV4cGVjdGVkIGNhbGxiYWNrIGNhc2UiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IGFjdGlvbiA9IHRoaXMuYWN0aW9uSGFuZGxlcltkYXRhLmFjdGlvbl07CiAgICAgIGlmICghYWN0aW9uKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmtub3duIGFjdGlvbiBmcm9tIHdvcmtlcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgfQogICAgICBpZiAoZGF0YS5jYWxsYmFja0lkKSB7CiAgICAgICAgY29uc3QgY2JTb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lOwogICAgICAgIGNvbnN0IGNiVGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShhY3Rpb24oZGF0YS5kYXRhKSk7CiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lOiBjYlNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgIGRhdGE6IHJlc3VsdAogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lOiBjYlRhcmdldE5hbWUsCiAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgIGNhbGxiYWNrSWQ6IGRhdGEuY2FsbGJhY2tJZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHJldHVybjsKICAgICAgfQogICA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FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGNvbnN0IGxhc3REZXNpcmVkU2l6ZSA9IHRoaXMuZGVzaXJlZFNpemU7CiAgICAgICAgdGhpcy5kZXNpcmVkU2l6ZSAtPSBzaXplOwogICAgICAgIGlmIChsYXN0RGVzaXJlZFNpemUgPiAwICYmIHRoaXMuZGVzaXJlZFNpemUgPD0gMCkgewogICAgICAgICAgdGhpcy5zaW5rQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgfQogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICBjaHVuawogICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgIH0sCiAgICAgIGNsb3NlKCkgewogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMuaXNDYW5jZWxsZWQgPSB0cnVlOwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DTE9TRSwKICAgICAgICAgIHN0cmVhbUlkCiAgICAgICAgfSk7CiAgICAgICAgZGVsZXRlIHNlbGYuc3RyZWFtU2lua3Nbc3RyZWFtSWRdOwogICAgICB9LAogICAgICBlcnJvcihyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24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ICAgICAgIGJyZWFrOwogICAgICBjYXNlIFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURToKICAgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnJlc29sdmUoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgIH0KICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLlBVTEw6CiAgICAgICAgaWYgKCFzdHJlYW1TaW5rKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgIHN1Y2Nlc3M6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgIH0KICAgICAgICBzdHJlYW1TaW5rLmRlc2lyZWRTaXplID0gZGF0YS5kZXNpcmVkU2l6ZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uUHVsbCAmJiBzdHJlYW1TaW5rLm9uUHVsbCgpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgU3RyZWFtS2luZC5FTlFVRVVFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlbnF1ZXVlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNvbnRyb2xsZXIuZW5xdWV1ZShkYXRhLmNodW5rKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLkNMT1NFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJjbG9zZSBzaG91bGQgaGF2ZSBzdHJlYW0gY29udHJvbGxlciIpOwogICAgICAgIGlmIChzdHJlYW1Db250cm9sbGVyLmlzQ2xvc2VkKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgc3RyZWFtQ29udH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ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uQ2FuY2VsICYmIHN0cmVhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJVbmV4cGVjdGVkIHN0cmVhbSBjYXNlIik7CiAgICB9CiAgfQogIGFzeW5jIF9kZWxldGVTdHJlYW1Db250cm9sbGVyKHN0cmVhbUNvbnRyb2xsZXIsIHN0c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B7CiJ1c2Ugc3RyaWN0IjsKdmFyIGV4cG9ydHMgPSBfX3dlYnBhY2tfZXhwb3J0c19fOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgdmFsdWU6IHRydWUKfSkpOwpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIldvcmtlck1lc3NhZ2VIYW5kbGVyIiwgKHsKICBlbnVtZXJhYmxlOiB0cnVlLAogIGdldDogZnVuY3Rpb24gKCkgewogICAgcmV0dXJuIF93b3JrZXIuV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgfQp9KSk7CnZhciBfd29ya2VyID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwpjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7Cn0pKCk7CgovKioqKioqLyAJcmV0dXJuIF9fd2VicGFja19leHBvcnRzX187Ci8qKioqKiovIH0pKCkKOwp9KTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cGRmLndvcmtlci5qcy5tYXA=",y=`data:text/javascript;base64,${N}`,o=`data:text/javascript;base64,${s}`;class h{constructor(g,I){G(this,"pdfDoc"),G(this,"pageNumber"),G(this,"total"),G(this,"dom"),G(this,"pdf"),G(this,"getPdfPage",C=>new Promise((Z,i)=>{this.pdfDoc?this.pdfDoc.getPage(C).then(b=>{const l=b.getViewport(),d=document.createElement("canvas");this.dom.appendChild(d);const V=d.getContext("2d"),m=document.body.clientWidth-20,[K,J,c,W]=l.viewBox,B=c>m?m/c:1;d.width=c,d.height=W,l.width=c,l.height=W,d.style.width=Math.floor(l.width)*B+"px",d.style.height=Math.floor(l.height)*B+"px";const X={canvasContext:V,viewport:l,transform:[1,0,0,-1,0,l.height]};b.render(X),Z({success:!0,data:b})}):i({success:!1,data:null,message:"pdfDoc is undefined"})})),G(this,"pdfPreview",()=>{Y(y).then(()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=o,window.pdfjsLib.getDocument(this.pdf).promise.then(async C=>{this.pdfDoc=C,this.total=C.numPages;for(let Z=1;Z<=this.total;Z++)await this.getPdfPage(Z)})})}),G(this,"prevPage",()=>{this.pageNumber>1?this.pageNumber-=1:this.pageNumber=1,this.getPdfPage(this.pageNumber)}),G(this,"nextPage",()=>{this.pageNumbernew Promise((g,I)=>{const C=new FileReader;C.readAsDataURL(A),C.onload=()=>{g(C.result)},C.onerror=Z=>{I(Z)},C.onabort=Z=>{I(Z)}}),p=async(A,g)=>{try{if(typeof window<"u"){const I=await H(A);I&&new h(I,g).pdfPreview()}}catch(I){console.log("renderPdf",I)}};export{p as renderPdf}; +import{l as Y}from"../app.0729b6dc.js";import"./framework.6fe2e870.js";import"./theme.eee41b28.js";var w=Object.defineProperty,R=(A,g,I)=>g in A?w(A,g,{enumerable:!0,configurable:!0,writable:!0,value:I}):A[g]=I,G=(A,g,I)=>(R(A,typeof g!="symbol"?g+"":g,I),I);const N="LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKICoKICogICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAogKgogKiBVbmxlc3MgcmVxdWly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5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSA9IGNyZWF0ZVByb21pc2VDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgZXhwb3J0cy5jcmVhdGVWYWxpZEFic29sdXRlVXJsID0gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0TW9kaWZpY2F0aW9uRGF0ZSA9IGdldE1vZGlmaWNhdGlvbkRhdGU7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFZlcmJvc2l0eUxldmVsID0gZ2V0VmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICBleHBvcnRzLmluZm8gPSBpbmZvOwogICAgICAgICAgICAgICAgZXhwb3J0cy5pc0FycmF5QnVmZmVyID0gaXNBcnJheUJ1ZmZlcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuaXNBcnJheUVxdWFsID0gaXNBcnJheUVxdWFsOwogICAgICAgICAgICAgICAgZXhwb3J0cy5vYmplY3RGcm9tTWFwID0gb2JqZWN0RnJvbU1hcDsKICAgICAgICAgICAgICAgIGV4cG9ydHMub2JqZWN0U2l6ZSA9IG9iamVjdFNpemU7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldFZlcmJvc2l0eUxldmVsID0gc2V0VmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNoYWRvdyA9IHNoYWRvdzsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nMzIgPSBzdHJpbmczMjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nVG9CeXRlcyA9IHN0cmluZ1RvQnl0ZXM7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvUERGU3RyaW5nID0gc3RyaW5nVG9QREZTdHJpbmc7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvVVRGOFN0cmluZyA9IHN0cmluZ1RvVVRGOFN0cmluZzsKICAgICAgICAgICAgICAgIGV4cG9ydHMudW5yZWFjaGFibGUgPSB1bnJlYWNoYWJsZTsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXRmOFN0cmluZ1RvU3RyaW5nID0gdXRmOFN0cmluZ1RvU3RyaW5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy53YXJuID0gd2FybjsKICAgICAgICAgICAgICAgIGlmICghZ2xvYmFsVGhpcy5fcGRmanNDb21wYXRpYmlsaXR5Q2hlY2tlZCkgewogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuX3BkZmpzQ29tcGF0aWJpbGl0eUNoZWNrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oMik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBJREVOVElUWV9NQVRSSVggPSBbMSwgMCwgMCwgMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLklERU5USVRZX01BVFJJWCA9IElERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgIGNvbnN0IEZPTlRfSURFTlRJVFlfTUFUUklYID0gWzAuMDAxLCAwLCAwLCAwLjAwMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLkZPTlRfSURFTlRJVFlfTUFUUklYID0gRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfSU1BR0VfU0laRV9UT19DQUNIRSA9IDEwZTY7CiAgICAgICAgICAgICAgICBleHBvcnRzLk1BWF9JTUFHRV9TSVpFX1RPX0NBQ0hFID0gTUFYX0lNQUdFX1NJWkVfVE9fQ0FDSEU7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0ZBQ1RPUiA9IDEuMzU7CiAgICAgICAgICAgICAgICBleHBvcnRzLkxJTkVfRkFDVE9SID0gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0RFU0NFTlRfRkFDVE9SID0gMC4zNTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTElORV9ERVNDRU5UX0ZBQ1RPUiA9IExJTkVfREVTQ0VOVF9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBCQVNFTElORV9GQUNUT1IgPSBMSU5FX0RFU0NFTlRfRkFDVE9SIC8gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJBU0VMSU5FX0ZBQ1RPUiA9IEJBU0VMSU5FX0ZBQ1RPUjsKICAgICAgICAgICAgICAgIGNvbnN0IFJlbmRlcmluZ0ludGVudEZsYWcgPSB7CiAgICAgICAgICAgICAgICAgICAgQU5ZOiAweDAxLAogICAgICAgICAgICAgICAgICAgIERJU1BMQVk6IDB4MDIsCiAgICAgICAgICAgICAgICAgICAgUFJJTlQ6IDB4MDQsCiAgICAgICAgICAgICAgICAgICAgU0FWRTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19GT1JNUzogMHgxMCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19TVE9SQUdFOiAweDIwLAogICAgICAgICAgICAgICAgICAgIEFOTk9UQVRJT05TX0RJU0FCTEU6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgT1BMSVNUOiAweDEwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nSW50ZW50RmxhZyA9IFJlbmRlcmluZ0ludGVudEZsYWc7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTW9kZSA9IHsKICAgICAgICAgICAgICAgICAgICBESVNBQkxFOiAwLAogICAgICAgICAgICAgICAgICAgIEVOQUJMRTogMSwKICAgICAgICAgICAgICAgICAgICBFTkFCTEVfRk9STVM6IDIsCiAgICAgICAgICAgICAgICAgICAgRU5BQkxFX1NUT1JBR0U6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Nb2RlID0gQW5ub3RhdGlvbk1vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gInBkZmpzX2ludGVybmFsX2VkaXRvcl8iOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gQW5ub3RhdGlvbkVkaXRvclByZWZpeDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JUeXBlID0gewogICAgICAgICAgICAgICAgICAgIERJU0FCTEU6IC0xLAogICAgICAgICAgICAgICAgICAgIE5PTkU6IDAsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFQ6IDMsCiAgICAgICAgICAgICAgICAgICAgSU5LOiAxNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclR5cGUgPSBBbm5vdGF0aW9uRWRpdG9yVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlID0gewogICAgICAgICAgICAgICAgICAgIEZSRUVURVhUX1NJWkU6IDEsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfQ09MT1I6IDIsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfT1BBQ0lUWTogMywKICAgICAgICAgICAgICAgICAgICBJTktfQ09MT1I6IDExLAogICAgICAgICAgICAgICAgICAgIElOS19USElDS05FU1M6IDEyLAogICAgICAgICAgICAgICAgICAgIElOS19PUEFDSVRZOiAxMwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUgPSBBbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFBlcm1pc3Npb25GbGFnID0gewogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9DT05URU5UUzogMHgwOCwKICAgICAgICAgICAgICAgICAgICBDT1BZOiAweDEwLAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9BTk5PVEFUSU9OUzogMHgyMCwKICAgICAgICAgICAgICAgICAgICBGSUxMX0lOVEVSQUNUSVZFX0ZPUk1TOiAweDEwMCwKICAgICAgICAgICAgICAgICAgICBDT1BZX0ZPUl9BQ0NFU1NJQklMSVRZOiAweDIwMCwKICAgICAgICAgICAgICAgICAgICBBU1NFTUJMRTogMHg0MDAsCiAgICAgICAgICAgICAgICAgICAgUFJJTlRfSElHSF9RVUFMSVRZOiAweDgwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUGVybWlzc2lvbkZsYWcgPSBQZXJtaXNzaW9uRmxhZzsKICAgICAgICAgICAgICAgIGNvbnN0IFRleHRSZW5kZXJpbmdNb2RlID0gewogICAgICAgICAgICAgICAgICAgIEZJTEw6IDAsCiAgICAgICAgICAgICAgICAgICAgU1RST0tFOiAxLAogICAgICAgICAgICAgICAgICAgIEZJTExfU1RST0tFOiAyLAogICAgICAgICAgICAgICAgICAgIElOVklTSUJMRTogMywKICAgICAgICAgICAgICAgICAgICBGSUxMX0FERF9UT19QQVRIOiA0LAogICAgICAgICAgICAgICAgICAgIFNUUk9LRV9BRERfVE9fUEFUSDogNSwKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9BRERfVE9fUEFUSDogNiwKICAgICAgICAgICAgICAgICAgICBBRERfVE9fUEFUSDogNywKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9NQVNLOiAzLAogICAgICAgICAgICAgICAgICAgIEFERF9UT19QQVRIX0ZMQUc6IDQKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRSZW5kZXJpbmdNb2RlID0gVGV4dFJlbmRlcmluZ01vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBJbWFnZUtpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JBWVNDQUxFXzFCUFA6IDEsCiAgICAgICAgICAgICAgICAgICAgUkdCXzI0QlBQOiAyLAogICAgICAgICAgICAgICAgICAgIFJHQkFfMzJCUFA6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkltYWdlS2luZCA9IEltYWdlS2luZDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25UeXBlID0gewogICAgICAgICAgICAgICAgICAgIFRFWFQ6IDEsCiAgICAgICAgICAgICAgICAgICAgTElOSzogMiwKICAgICAgICAgICAgICAgICAgICBGUkVFVEVYVDogMywKICAgICAgICAgICAgICAgICAgICBMSU5FOiA0LAogICAgICAgICAgICAgICAgICAgIFNRVUFSRTogNSwKICAgICAgICAgICAgICAgICAgICBDSVJDTEU6IDYsCiAgICAgICAgICAgICAgICAgICAgUE9MWUdPTjogNywKICAgICAgICAgICAgICAgICAgICBQT0xZTElORTogOCwKICAgICAgICAgICAgICAgICAgICBISUdITElHSFQ6IDksCiAgICAgICAgICAgICAgICAgICAgVU5ERVJMSU5FOiAxMCwKICAgICAgICAgICAgICAgICAgICBTUVVJR0dMWTogMTEsCiAgICAgICAgICAgICAgICAgICAgU1RSSUtFT1VUOiAxMiwKICAgICAgICAgICAgICAgICAgICBTVEFNUDogMTMsCiAgICAgICAgICAgICAgICAgICAgQ0FSRVQ6IDE0LAogICAgICAgICAgICAgICAgICAgIElOSzogMTUsCiAgICAgICAgICAgICAgICAgICAgUE9QVVA6IDE2LAogICAgICAgICAgICAgICAgICAgIEZJTEVBVFRBQ0hNRU5UOiAxNywKICAgICAgICAgICAgICAgICAgICBTT1VORDogMTgsCiAgICAgICAgICAgICAgICAgICAgTU9WSUU6IDE5LAogICAgICAgICAgICAgICAgICAgIFdJREdFVDogMjAsCiAgICAgICAgICAgICAgICAgICAgU0NSRUVOOiAyMSwKICAgICAgICAgICAgICAgICAgICBQUklOVEVSTUFSSzogMjIsCiAgICAgICAgICAgICAgICAgICAgVFJBUE5FVDogMjMsCiAgICAgICAgICAgICAgICAgICAgV0FURVJNQVJLOiAyNCwKICAgICAgICAgICAgICAgICAgICBUSFJFRUQ6IDI1LAogICAgICAgICAgICAgICAgICAgIFJFREFDVDogMjYKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25UeXBlID0gQW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBSRVZJRVc6ICJSZXZpZXciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTWFya2VkU3RhdGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBVTk1BUktFRDogIlVubWFya2VkIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbk1hcmtlZFN0YXRlID0gQW5ub3RhdGlvbk1hcmtlZFN0YXRlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvblJldmlld1N0YXRlID0gewogICAgICAgICAgICAgICAgICAgIEFDQ0VQVEVEOiAiQWNjZXB0ZWQiLAogICAgICAgICAgICAgICAgICAgIFJFSkVDVEVEOiAiUmVqZWN0ZWQiLAogICAgICAgICAgICAgICAgICAgIENBTkNFTExFRDogIkNhbmNlbGxlZCIsCiAgICAgICAgICAgICAgICAgICAgQ09NUExFVEVEOiAiQ29tcGxldGVkIiwKICAgICAgICAgICAgICAgICAgICBOT05FOiAiTm9uZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25SZXZpZXdTdGF0ZSA9IEFubm90YXRpb25SZXZpZXdTdGF0ZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25SZXBseVR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JPVVA6ICJHcm91cCIsCiAgICAgICAgICAgICAgICAgICAgUkVQTFk6ICJSIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblJlcGx5VHlwZSA9IEFubm90YXRpb25SZXBseVR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBJTlZJU0lCTEU6IDB4MDEsCiAgICAgICAgICAgICAgICAgICAgSElEREVOOiAweDAyLAogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE5PWk9PTTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBOT1JPVEFURTogMHgxMCwKICAgICAgICAgICAgICAgICAgICBOT1ZJRVc6IDB4MjAsCiAgICAgICAgICAgICAgICAgICAgUkVBRE9OTFk6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEOiAweDgwLAogICAgICAgICAgICAgICAgICAgIFRPR0dMRU5PVklFVzogMHgxMDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEQ09OVEVOVFM6IDB4MjAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRmxhZyA9IEFubm90YXRpb25GbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkZpZWxkRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBSRUFET05MWTogMHgwMDAwMDAxLAogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEOiAweDAwMDAwMDIsCiAgICAgICAgICAgICAgICAgICAgTk9FWFBPUlQ6IDB4MDAwMDAwNCwKICAgICAgICAgICAgICAgICAgICBNVUxUSUxJTkU6IDB4MDAwMTAwMCwKICAgICAgICAgICAgICAgICAgICBQQVNTV09SRDogMHgwMDAyMDAwLAogICAgICAgICAgICAgICAgICAgIE5PVE9HR0xFVE9PRkY6IDB4MDAwNDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJTzogMHgwMDA4MDAwLAogICAgICAgICAgICAgICAgICAgIFBVU0hCVVRUT046IDB4MDAxMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01CTzogMHgwMDIwMDAwLAogICAgICAgICAgICAgICAgICAgIEVESVQ6IDB4MDA0MDAwMCwKICAgICAgICAgICAgICAgICAgICBTT1JUOiAweDAwODAwMDAsCiAgICAgICAgICAgICAgICAgICAgRklMRVNFTEVDVDogMHgwMTAwMDAwLAogICAgICAgICAgICAgICAgICAgIE1VTFRJU0VMRUNUOiAweDAyMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTUEVMTENIRUNLOiAweDA0MDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTQ1JPTEw6IDB4MDgwMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01COiAweDEwMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgUklDSFRFWFQ6IDB4MjAwMDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJT1NJTlVOSVNPTjogMHgyMDAwMDAwLAogICAgICAgICAgICAgICAgICAgIENPTU1JVE9OU0VMQ0hBTkdFOiAweDQwMDAwMDAKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25GaWVsZEZsYWcgPSBBbm5vdGF0aW9uRmllbGRGbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkJvcmRlclN0eWxlVHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBTT0xJRDogMSwKICAgICAgICAgICAgICAgICAgICBEQVNIRUQ6IDIsCiAgICAgICAgICAgICAgICAgICAgQkVWRUxFRDogMywKICAgICAgICAgICAgICAgICAgICBJTlNFVDogNCwKICAgICAgICAgICAgICAgICAgICBVTkRFUkxJTkU6IDUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUgPSBBbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBFOiAiTW91c2UgRW50ZXIiLAogICAgICAgICAgICAgICAgICAgIFg6ICJNb3VzZSBFeGl0IiwKICAgICAgICAgICAgICAgICAgICBEOiAiTW91c2UgRG93biIsCiAgICAgICAgICAgICAgICAgICAgVTogIk1vdXNlIFVwIiwKICAgICAgICAgICAgICAgICAgICBGbzogIkZvY3VzIiwKICAgICAgICAgICAgICAgICAgICBCbDogIkJsdXIiLAogICAgICAgICAgICAgICAgICAgIFBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIFBDOiAiUGFnZUNsb3NlIiwKICAgICAgICAgICAgICAgICAgICBQVjogIlBhZ2VWaXNpYmxlIiwKICAgICAgICAgICAgICAgICAgICBQSTogIlBhZ2VJbnZpc2libGUiLAogICAgICAgICAgICAgICAgICAgIEs6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgIEY6ICJGb3JtYXQiLAogICAgICAgICAgICAgICAgICAgIFY6ICJWYWxpZGF0ZSIsCiAgICAgICAgICAgICAgICAgICAgQzogIkNhbGN1bGF0ZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25BY3Rpb25FdmVudFR5cGUgPSBBbm5vdGF0aW9uQWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgRG9jdW1lbnRBY3Rpb25FdmVudFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgV0M6ICJXaWxsQ2xvc2UiLAogICAgICAgICAgICAgICAgICAgIFdTOiAiV2lsbFNhdmUiLAogICAgICAgICAgICAgICAgICAgIERTOiAiRGlkU2F2ZSIsCiAgICAgICAgICAgICAgICAgICAgV1A6ICJXaWxsUHJpbnQiLAogICAgICAgICAgICAgICAgICAgIERQOiAiRGlkUHJpbnQiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Eb2N1bWVudEFjdGlvbkV2ZW50VHlwZSA9IERvY3VtZW50QWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgUGFnZUFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIEM6ICJQYWdlQ2xvc2UiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlQWN0aW9uRXZlbnRUeXBlID0gUGFnZUFjdGlvbkV2ZW50VHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFZlcmJvc2l0eUxldmVsID0gewogICAgICAgICAgICAgICAgICAgIEVSUk9SUzogMCwKICAgICAgICAgICAgICAgICAgICBXQVJOSU5HUzogMSwKICAgICAgICAgICAgICAgICAgICBJTkZPUzogNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVmVyYm9zaXR5TGV2ZWwgPSBWZXJib3NpdHlMZXZlbDsKICAgICAgICAgICAgICAgIGNvbnN0IENNYXBDb21wcmVzc2lvblR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTk9ORTogMCwKICAgICAgICAgICAgICAgICAgICBCSU5BUlk6IDEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkNNYXBDb21wcmVzc2lvblR5cGUgPSBDTWFwQ29tcHJlc3Npb25UeXBlOwogICAgICAgICAgICAgICAgY29uc3QgT1BTID0gewogICAgICAgICAgICAgICAgICAgIGRlcGVuZGVuY3k6IDEsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZVdpZHRoOiAyLAogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXA6IDMsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW46IDQsCiAgICAgICAgICAgICAgICAgICAgc2V0TWl0ZXJMaW1pdDogNSwKICAgICAgICAgICAgICAgICAgICBzZXREYXNoOiA2LAogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudDogNywKICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzczogOCwKICAgICAgICAgICAgICAgICAgICBzZXRHU3RhdGU6IDksCiAgICAgICAgICAgICAgICAgICAgc2F2ZTogMTAsCiAgICAgICAgICAgICAgICAgICAgcmVzdG9yZTogMTEsCiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiAxMiwKICAgICAgICAgICAgICAgICAgICBtb3ZlVG86IDEzLAogICAgICAgICAgICAgICAgICAgIGxpbmVUbzogMTQsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzogMTUsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzI6IDE2LAogICAgICAgICAgICAgICAgICAgIGN1cnZlVG8zOiAxNywKICAgICAgICAgICAgICAgICAgICBjbG9zZVBhdGg6IDE4LAogICAgICAgICAgICAgICAgICAgIHJlY3RhbmdsZTogMTksCiAgICAgICAgICAgICAgICAgICAgc3Ryb2tlOiAyMCwKICAgICAgICAgICAgICAgICAgICBjbG9zZVN0cm9rZTogMjEsCiAgICAgICAgICAgICAgICAgICAgZmlsbDogMjIsCiAgICAgICAgICAgICAgICAgICAgZW9GaWxsOiAyMywKICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlOiAyNCwKICAgICAgICAgICAgICAgICAgICBlb0ZpbGxTdHJva2U6IDI1LAogICAgICAgICAgICAgICAgICAgIGNsb3NlRmlsbFN0cm9rZTogMjYsCiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2U6IDI3LAogICAgICAgICAgICAgICAgICAgIGVuZFBhdGg6IDI4LAogICAgICAgICAgICAgICAgICAgIGNsaXA6IDI5LAogICAgICAgICAgICAgICAgICAgIGVvQ2xpcDogMzAsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0OiAzMSwKICAgICAgICAgICAgICAgICAgICBlbmRUZXh0OiAzMiwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyU3BhY2luZzogMzMsCiAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmc6IDM0LAogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZTogMzUsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZzogMzYsCiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udDogMzcsCiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGU6IDM4LAogICAgICAgICAgICAgICAgICAgIHNldFRleHRSaXNlOiAzOSwKICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dDogNDAsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0OiA0MSwKICAgICAgICAgICAgICAgICAgICBzZXRUZXh0TWF0cml4OiA0MiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZTogNDMsCiAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQ6IDQ0LAogICAgICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0OiA0NSwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNob3dUZXh0OiA0NiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDogNDcsCiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoOiA0OCwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyV2lkdGhBbmRCb3VuZHM6IDQ5LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yU3BhY2U6IDUwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvclNwYWNlOiA1MSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDb2xvcjogNTIsCiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOOiA1MywKICAgICAgICAgICAgICAgICAgICBzZXRGaWxsQ29sb3I6IDU0LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck46IDU1LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUdyYXk6IDU2LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxHcmF5OiA1NywKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VSR0JDb2xvcjogNTgsCiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yOiA1OSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDTVlLQ29sb3I6IDYwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDTVlLQ29sb3I6IDYxLAogICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsOiA2MiwKICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlOiA2MywKICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YTogNjQsCiAgICAgICAgICAgICAgICAgICAgZW5kSW5saW5lSW1hZ2U6IDY1LAogICAgICAgICAgICAgICAgICAgIHBhaW50WE9iamVjdDogNjYsCiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50OiA2NywKICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wczogNjgsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50OiA2OSwKICAgICAgICAgICAgICAgICAgICBiZWdpbk1hcmtlZENvbnRlbnRQcm9wczogNzAsCiAgICAgICAgICAgICAgICAgICAgZW5kTWFya2VkQ29udGVudDogNzEsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Db21wYXQ6IDcyLAogICAgICAgICAgICAgICAgICAgIGVuZENvbXBhdDogNzMsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luOiA3NCwKICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kOiA3NSwKICAgICAgICAgICAgICAgICAgICBiZWdpbkdyb3VwOiA3NiwKICAgICAgICAgICAgICAgICAgICBlbmRHcm91cDogNzcsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Bbm5vdGF0aW9uOiA4MCwKICAgICAgICAgICAgICAgICAgICBlbmRBbm5vdGF0aW9uOiA4MSwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3Q6IDgzLAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwOiA4NCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdDogODUsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRJbmxpbmVJbWFnZVhPYmplY3Q6IDg2LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXA6IDg3LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0OiA4OCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3RSZXBlYXQ6IDg5LAogICAgICAgICAgICAgICAgICAgIHBhaW50U29saWRDb2xvckltYWdlTWFzazogOTAsCiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aDogOTEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLk9QUyA9IE9QUzsKICAgICAgICAgICAgICAgIGNvbnN0IFBhc3N3b3JkUmVzcG9uc2VzID0gewogICAgICAgICAgICAgICAgICAgIE5FRURfUEFTU1dPUkQ6IDEsCiAgICAgICAgICAgICAgICAgICAgSU5DT1JSRUNUX1BBU1NXT1JEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXNzd29yZFJlc3BvbnNlcyA9IFBhc3N3b3JkUmVzcG9uc2VzOwogICAgICAgICAgICAgICAgbGV0IHZlcmJvc2l0eSA9IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2V0VmVyYm9zaXR5TGV2ZWwobGV2ZWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihsZXZlbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5ID0gbGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0VmVyYm9zaXR5TGV2ZWwoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGluZm8obXNnKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZlcmJvc2l0eSA+PSBWZXJib3NpdHlMZXZlbC5JTkZPUykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhgSW5mbzogJHttc2d9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fybihtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmVyYm9zaXR5ID49IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGBXYXJuaW5nOiAke21zZ31gKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1bnJlYWNoYWJsZShtc2cpIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFzc2VydChjb25kLCBtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUobXNnKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNWYWxpZFByb3RvY29sKHVybCkgewogICAgICAgICAgICAgICAgICAgIGlmICghdXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh1cmwucHJvdG9jb2wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiaHR0cDoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJodHRwczoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJmdHA6IjoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibWFpbHRvOiI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRlbDoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYmFzZVVybCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBsZXQgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgdHlwZW9mIHVybCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLmFkZERlZmF1bHRQcm90b2NvbCAmJiB1cmwuc3RhcnRzV2l0aCgid3d3LiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZG90cyA9IHVybC5tYXRjaCgvXC4vZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvdHMgJiYgZG90cy5sZW5ndGggPj0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBgaHR0cDovLyR7dXJsfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMudHJ5Q29udmVydEVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gc3RyaW5nVG9VVEY4U3RyaW5nKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWJzb2x1dGVVcmwgPSBiYXNlVXJsID8gbmV3IFVSTCh1cmwsIGJhc2VVcmwpIDogbmV3IFVSTCh1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzVmFsaWRQcm90b2NvbChhYnNvbHV0ZVVybCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2hhZG93KG9iaiwgcHJvcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbm9uU2VyaWFsaXphYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBwcm9wLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhbm9uU2VyaWFsaXphYmxlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IEJhc2VFeGNlcHRpb24gPSBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uQ2xvc3VyZSgpIHsKICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uKG1lc3NhZ2UsIG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVucmVhY2hhYmxlKCJDYW5ub3QgaW5pdGlhbGl6ZSBCYXNlRXhjZXB0aW9uLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZSA9IG1lc3NhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEJhc2VFeGNlcHRpb24ucHJvdG90eXBlID0gbmV3IEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgQmFzZUV4Y2VwdGlvbi5jb25zdHJ1Y3RvciA9IEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VFeGNlcHRpb24gPSBCYXNlRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgUGFzc3dvcmRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGNvZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiUGFzc3dvcmRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlID0gY29kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBhc3N3b3JkRXhjZXB0aW9uID0gUGFzc3dvcmRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBVbmtub3duRXJyb3JFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiVW5rbm93bkVycm9yRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWlscyA9IGRldGFpbHM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Vbmtub3duRXJyb3JFeGNlcHRpb24gPSBVbmtub3duRXJyb3JFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBJbnZhbGlkUERGRXhjZXB0aW9uIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkludmFsaWRQREZFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkludmFsaWRQREZFeGNlcHRpb24gPSBJbnZhbGlkUERGRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgTWlzc2luZ1BERkV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihtc2csICJNaXNzaW5nUERGRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NaXNzaW5nUERGRXhjZXB0aW9uID0gTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZywgc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXR1cyA9IHN0YXR1czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiA9IFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIEZvcm1hdEVycm9yIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkZvcm1hdEVycm9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Gb3JtYXRFcnJvciA9IEZvcm1hdEVycm9yOwogICAgICAgICAgICAgICAgY2xhc3MgQWJvcnRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2cpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiQWJvcnRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkFib3J0RXhjZXB0aW9uID0gQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBieXRlc1RvU3RyaW5nKGJ5dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBieXRlcyAhPT0gIm9iamVjdCIgfHwgYnl0ZXMgPT09IG51bGwgfHwgYnl0ZXMubGVuZ3RoID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUoIkludmFsaWQgYXJndW1lbnQgZm9yIGJ5dGVzVG9TdHJpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9BUkdVTUVOVF9DT1VOVCA9IDgxOTI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZS5hcHBseShudWxsLCBieXRlcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0VuZCA9IE1hdGgubWluKGkgKyBNQVhfQVJHVU1FTlRfQ09VTlQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gYnl0ZXMuc3ViYXJyYXkoaSwgY2h1bmtFbmQpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb0J5dGVzKHN0cikgewogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RyICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICB1bnJlYWNoYWJsZSgiSW52YWxpZCBhcmd1bWVudCBmb3Igc3RyaW5nVG9CeXRlcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBzdHIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkobGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2ldID0gc3RyLmNoYXJDb2RlQXQoaSkgJiAweGZmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmczMih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHZhbHVlID4+IDI0ICYgMHhmZiwgdmFsdWUgPj4gMTYgJiAweGZmLCB2YWx1ZSA+PiA4ICYgMHhmZiwgdmFsdWUgJiAweGZmKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9iamVjdFNpemUob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKG9iaikubGVuZ3RoOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gb2JqZWN0RnJvbU1hcChtYXApIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNMaXR0bGVFbmRpYW4oKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyOCA9IG5ldyBVaW50OEFycmF5KDQpOwogICAgICAgICAgICAgICAgICAgIGJ1ZmZlcjhbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXczMiA9IG5ldyBVaW50MzJBcnJheShidWZmZXI4LmJ1ZmZlciwgMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXczMlswXSA9PT0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzRXZhbFN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBuZXcgRnVuY3Rpb24oIiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGZWF0dXJlVGVzdCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0xpdHRsZUVuZGlhbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNMaXR0bGVFbmRpYW4iLCBpc0xpdHRsZUVuZGlhbigpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0V2YWxTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzaGFkb3codGhpcywgImlzRXZhbFN1cHBvcnRlZCIsIGlzRXZhbFN1cHBvcnRlZCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQiLCB0eXBlb2YgT2Zmc2NyZWVuQ2FudmFzICE9PSAidW5kZWZpbmVkIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgcGxhdGZvcm0oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgbmF2aWdhdG9yID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW46IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1dpbjogbmF2aWdhdG9yLnBsYXRmb3JtLmluY2x1ZGVzKCJXaW4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBuYXZpZ2F0b3IucGxhdGZvcm0uaW5jbHVkZXMoIk1hYyIpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRmVhdHVyZVRlc3QgPSBGZWF0dXJlVGVzdDsKICAgICAgICAgICAgICAgIGNvbnN0IGhleE51bWJlcnMgPSBbLi4uQXJyYXkoMjU2KS5rZXlzKCldLm1hcChuID0+IG4udG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIikpOwogICAgICAgICAgICAgICAgY2xhc3MgVXRpbCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG1ha2VIZXhDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7aGV4TnVtYmVyc1tyXX0ke2hleE51bWJlcnNbZ119JHtoZXhOdW1iZXJzW2JdfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wID0gbWluTWF4WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzNdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IG1pbk1heFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzFdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm1bMl0gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzFdID0gdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gKj0gdHJhbnNmb3JtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsyXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0cmFuc2Zvcm0obTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbbTFbMF0gKiBtMlswXSArIG0xWzJdICogbTJbMV0sIG0xWzFdICogbTJbMF0gKyBtMVszXSAqIG0yWzFdLCBtMVswXSAqIG0yWzJdICsgbTFbMl0gKiBtMlszXSwgbTFbMV0gKiBtMlsyXSArIG0xWzNdICogbTJbM10sIG0xWzBdICogbTJbNF0gKyBtMVsyXSAqIG0yWzVdICsgbTFbNF0sIG0xWzFdICogbTJbNF0gKyBtMVszXSAqIG0yWzVdICsgbTFbNV1dOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYXBwbHlUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4dCA9IHBbMF0gKiBtWzBdICsgcFsxXSAqIG1bMl0gKyBtWzRdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5dCA9IHBbMF0gKiBtWzFdICsgcFsxXSAqIG1bM10gKyBtWzVdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3h0LCB5dF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhcHBseUludmVyc2VUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkID0gbVswXSAqIG1bM10gLSBtWzFdICogbVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHQgPSAocFswXSAqIG1bM10gLSBwWzFdICogbVsyXSArIG1bMl0gKiBtWzVdIC0gbVs0XSAqIG1bM10pIC8gZDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXQgPSAoLXBbMF0gKiBtWzFdICsgcFsxXSAqIG1bMF0gKyBtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeHQsIHl0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldEF4aWFsQWxpZ25lZEJvdW5kaW5nQm94KHIsIG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEgPSBVdGlsLmFwcGx5VHJhbnNmb3JtKHIsIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMiA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oci5zbGljZSgyLCA0KSwgbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzID0gVXRpbC5hcHBseVRyYW5zZm9ybShbclswXSwgclszXV0sIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNCA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JbMl0sIHJbMV1dLCBtKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbihwMVswXSwgcDJbMF0sIHAzWzBdLCBwNFswXSksIE1hdGgubWluKHAxWzFdLCBwMlsxXSwgcDNbMV0sIHA0WzFdKSwgTWF0aC5tYXgocDFbMF0sIHAyWzBdLCBwM1swXSwgcDRbMF0pLCBNYXRoLm1heChwMVsxXSwgcDJbMV0sIHAzWzFdLCBwNFsxXSldOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW52ZXJzZVRyYW5zZm9ybShtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzBdICogbVszXSAtIG1bMV0gKiBtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW21bM10gLyBkLCAtbVsxXSAvIGQsIC1tWzJdIC8gZCwgbVswXSAvIGQsIChtWzJdICogbVs1XSAtIG1bNF0gKiBtWzNdKSAvIGQsIChtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc3Bvc2UgPSBbbVswXSwgbVsyXSwgbVsxXSwgbVszXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBtWzBdICogdHJhbnNwb3NlWzBdICsgbVsxXSAqIHRyYW5zcG9zZVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IG1bMF0gKiB0cmFuc3Bvc2VbMV0gKyBtWzFdICogdHJhbnNwb3NlWzNdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gbVsyXSAqIHRyYW5zcG9zZVswXSArIG1bM10gKiB0cmFuc3Bvc2VbMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzJdICogdHJhbnNwb3NlWzFdICsgbVszXSAqIHRyYW5zcG9zZVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlyc3QgPSAoYSArIGQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2Vjb25kID0gTWF0aC5zcXJ0KChhICsgZCkgKiogMiAtIDQgKiAoYSAqIGQgLSBjICogYikpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ggPSBmaXJzdCArIHNlY29uZCB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzeSA9IGZpcnN0IC0gc2Vjb25kIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbTWF0aC5zcXJ0KHN4KSwgTWF0aC5zcXJ0KHN5KV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemVSZWN0KHJlY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgciA9IHJlY3Quc2xpY2UoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0WzBdID4gcmVjdFsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgclswXSA9IHJlY3RbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByWzJdID0gcmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVjdFsxXSA+IHJlY3RbM10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJbMV0gPSByZWN0WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgclszXSA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBpbnRlcnNlY3QocmVjdDEsIHJlY3QyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhMb3cgPSBNYXRoLm1heChNYXRoLm1pbihyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1pbihyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeEhpZ2ggPSBNYXRoLm1pbihNYXRoLm1heChyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1heChyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhMb3cgPiB4SGlnaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeUxvdyA9IE1hdGgubWF4KE1hdGgubWluKHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWluKHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5SGlnaCA9IE1hdGgubWluKE1hdGgubWF4KHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWF4KHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeUxvdyA+IHlIaWdoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hMb3csIHlMb3csIHhIaWdoLCB5SGlnaF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBiZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHZhbHVlcyA9IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzID0gW1tdLCBbXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhLCBiLCBjLCB0LCB0MSwgdDIsIGIyYWMsIHNxcnRiMmFjOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHgwIC0gMTIgKiB4MSArIDYgKiB4MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB4MCArIDkgKiB4MSAtIDkgKiB4MiArIDMgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHgxIC0gMyAqIHgwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHkwIC0gMTIgKiB5MSArIDYgKiB5MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB5MCArIDkgKiB5MSAtIDkgKiB5MiArIDMgKiB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHkxIC0gMyAqIHkwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKGEpIDwgMWUtMTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoYikgPCAxZS0xMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHZhbHVlcy5wdXNoKHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGIyYWMgPSBiICogYiAtIDQgKiBjICogYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNxcnRiMmFjID0gTWF0aC5zcXJ0KGIyYWMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MSA9ICgtYiArIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MiA9ICgtYiAtIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGogPSB0dmFsdWVzLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqbGVuID0gajsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGotLSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IHR2YWx1ZXNbal07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2pdID0gbXQgKiBtdCAqIG10ICogeDAgKyAzICogbXQgKiBtdCAqIHQgKiB4MSArIDMgKiBtdCAqIHQgKiB0ICogeDIgKyB0ICogdCAqIHQgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqXSA9IG10ICogbXQgKiBtdCAqIHkwICsgMyAqIG10ICogbXQgKiB0ICogeTEgKyAzICogbXQgKiB0ICogdCAqIHkyICsgdCAqIHQgKiB0ICogeTM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuXSA9IHkwOwogICAgICAgICAgICAgICAgICAgICAgICBib3VuZHNbMF1bamxlbiArIDFdID0geDM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdLmxlbmd0aCA9IGJvdW5kc1sxXS5sZW5ndGggPSBqbGVuICsgMjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbiguLi5ib3VuZHNbMF0pLCBNYXRoLm1pbiguLi5ib3VuZHNbMV0pLCBNYXRoLm1heCguLi5ib3VuZHNbMF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DB4MTdlLCAwLCAweDIwYWNdOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc3RyaW5nVG9QREZTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0clswXSA+PSAiXHhFRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVuY29kaW5nOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyWzBdID09PSAiXHhGRSIgJiYgc3RyWzFdID09PSAiXHhGRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuY29kaW5nID0gInV0Zi0xNmJlIjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdHJbMF0gPT09ICJceEZGIiAmJiBzdHJbMV0gPT09ICJceEZFIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5jb2RpbmcgPSAidXRmLTE2bGUiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0clswXSA9PT0gIlx4RUYiICYmIHN0clsxXSA9PT0gIlx4QkIiICYmIHN0clsyXSA9PT0gIlx4QkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNvZGluZyA9ICJ1dGYtOCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBzdHJpbmdUb0J5dGVzKHN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZXIuZGVjb2RlKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm4oYHN0cmluZ1RvUERGU3RyaW5nOiAiJHtleH0iLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHN0ci5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBQREZTdHJpbmdUcmFuc2xhdGVUYWJsZVtzdHIuY2hhckNvZGVBdChpKV07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKGNvZGUgPyBTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpIDogc3RyLmNoYXJBdChpKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb1VURjhTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudChlc2NhcGUoc3RyKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1dGY4U3RyaW5nVG9TdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZXNjYXBlKGVuY29kZVVSSUNvbXBvbmVudChzdHIpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlCdWZmZXIodikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgdiA9PT0gIm9iamVjdCIgJiYgdiAhPT0gbnVsbCAmJiB2LmJ5dGVMZW5ndGggIT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlFcXVhbChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFycjEubGVuZ3RoICE9PSBhcnIyLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGFycjEubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJyMVtpXSAhPT0gYXJyMltpXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0TW9kaWZpY2F0aW9uRGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IERhdGUoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbZGF0ZS5nZXRVVENGdWxsWWVhcigpLnRvU3RyaW5nKCksIChkYXRlLmdldFVUQ01vbnRoKCkgKyAxKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIiksIGRhdGUuZ2V0VVRDRGF0ZSgpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENIb3VycygpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENNaW51dGVzKCkudG9TdHJpbmcoKS5wYWRTdGFydCgyLCAiMCIpLCBkYXRlLmdldFVUQ1NlY29uZHMoKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIildOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBidWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSgpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaXNTZXR0bGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGNhcGFiaWxpdHksICJzZXR0bGVkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBnZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTZXR0bGVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlID0gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUgPSBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0ID0gZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja0RPTU1hdHJpeCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsVGhpcy5ET01NYXRyaXggfHwgIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2xvYmFsVGhpcy5ET01NYXRyaXggPSByZXF1aXJlKCJjYW52YXMiKS5ET01NYXRyaXg7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrUGF0aDJEKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlBhdGgyRCB8fCAhX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIENhbnZhc1JlbmRlcmluZ0NvbnRleHQyRAogICAgICAgICAgICAgICAgICAgIH0gPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJECiAgICAgICAgICAgICAgICAgICAgfSA9IHJlcXVpcmUoInBhdGgyZC1wb2x5ZmlsbCIpOwogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEID0gQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEOwogICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJEKGdsb2JhbFRoaXMpOwogICAgICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja1JlYWRhYmxlU3RyZWFtKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlJlYWRhYmxlU3RyZWFtIHx8ICFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuUmVhZGFibGVTdHJlYW0gPSByZXF1aXJlKCJ3ZWItc3RyZWFtcy1wb2x5ZmlsbC9kaXN0L3BvbnlmaWxsLmpzIikuUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrQXJyYXlBdCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg0KTsKICAgICAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgICAgICAoZnVuY3Rpb24gY2hlY2tUeXBlZEFycmF5QXQoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKFVpbnQ4QXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OCk7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrU3RydWN0dXJlZENsb25lKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLnN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTApOwogICAgICAgICAgICAgICAgfSkoKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgaXNOb2RlSlMgPSB0eXBlb2YgcHJvY2VzcyA9PT0gIm9iamVjdCIgJiYgcHJvY2VzcyArICIiID09PSAiW29iamVjdCBwcm9jZXNzXSIgJiYgIXByb2Nlc3MudmVyc2lvbnMubncgJiYgIShwcm9jZXNzLnZlcnNpb25zLmVsZWN0cm9uICYmIHByb2Nlc3MudHlwZSAmJiBwcm9jZXNzLnR5cGUgIT09ICJicm93c2VyIik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gaXNOb2RlSlM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oNSk7CiAgICAgICAgICAgICAgICB2YXIgZW50cnlVbmJpbmQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDc3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZW50cnlVbmJpbmQoJ0FycmF5JywgJ2F0Jyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciAkID0gX193X3BkZmpzX3JlcXVpcmVfXyg2KTsKICAgICAgICAgICAgICAgIHZhciB0b09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFkZFRvVW5zY29wYWJsZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcyKTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIHRhcmdldDogJ0FycmF5JywKICAgICAgICAgICAgICAgICAgICBwcm90bzogdHJ1ZQogICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgIGF0OiBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbGVuID0gbGVuZ3RoT2ZBcnJheUxpa2UoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBrID0gcmVsYXRpdmVJbmRleCA+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+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgRnVuY3Rpb25OYW1lID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZUl0ZXJhdG9yQ29uc3RydWN0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk0KTsKICAgICAgICAgICAgICAgIHZhciBnZXRQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODUpOwogICAgICAgICAgICAgICAgdmFyIHNldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzQ29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oOTUpOwogICAgICAgICAgICAgICAgdmFyIFBST1BFUl9GVU5DVElPTl9OQU1FID0gRnVuY3Rpb25OYW1lLlBST1BFUjsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEVfRlVOQ1RJT05fTkFNRSA9IEZ1bmN0aW9uTmFtZS5DT05GSUdVUkFCTEU7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUgPSBJdGVyYXRvcnNDb3JlLkl0ZXJhdG9yUHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSBJdGVyYXRvcnNDb3JlLkJVR0dZX1NBRkFSSV9JVEVSQVRPUlM7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICB2YXIgS0VZUyA9ICdrZXlzJzsKICAgICAgICAgICAgICAgIHZhciBWQUxVRVMgPSAndmFsdWVzJzsKICAgICAgICAgICAgICAgIHZhciBFTlRSSUVTID0gJ2VudHJpZXMnOwogICAgICAgICAgICAgICAgdmFyIHJldHVyblRoaXMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoSXRlcmFibGUsIE5BTUUsIEl0ZXJhdG9yQ29uc3RydWN0b3IsIG5leHQsIERFRkFVTFQsIElTX1NFVCwgRk9SQ0VEKSB7CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlSXRlcmF0b3JDb25zdHJ1Y3RvcihJdGVyYXRvckNvbnN0cnVjdG9yLCBOQU1FLCBuZXh0KTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0SXRlcmF0aW9uTWV0aG9kID0gZnVuY3Rpb24gKEtJTkQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEtJTkQgPT09IERFRkFVTFQgJiYgZGVmYXVsdEl0ZXJhdG9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFCVUdHWV9TQUZBUklfSVRFUkFUT1JTICYmIEtJTkQgaW4gSXRlcmFibGVQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSXRlcmFibGVQcm90b3R5cGVbS0lORF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoS0lORCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBLRVlTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBrZXlzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVkFMVUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSXRlcmF0b3JDb25zdHJ1Y3Rvcih0aGlzLCBLSU5EKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBFTlRSSUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBlbnRyaWVzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBJdGVyYXRvckNvbnN0cnVjdG9yKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSBOQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJdGVyYWJsZVByb3RvdHlwZSA9IEl0ZXJhYmxlLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB2YXIgbmF0aXZlSXRlcmF0b3IgPSBJdGVyYWJsZVByb3RvdHlwZVtJVEVSQVRPUl0gfHwgSXRlcmFibGVQcm90b3R5cGVbJ0BAaXRlcmF0b3InXSB8fCBERUZBVUxUICYmIEl0ZXJhYmxlUHJvdG90eXBlW0RFRkFVTFRdOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0SXRlcmF0b3IgPSAhQlVHR1lfU0FGQVJJX0lURVJBVE9SUyAmJiBuYXRpdmVJdGVyYXRvciB8fCBnZXRJdGVyYXRpb25NZXRob2QoREVGQVVMVCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGFueU5hdGl2ZUl0ZXJhdG9yID0gTkFNRSA9PSAnQXJyYXknID8gSXRlcmFibGVQcm90b3R5cGUuZW50cmllcyB8fCBuYXRpdmVJdGVyYXRvciA6IG5hdGl2ZUl0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBDdXJyZW50SXRlcmF0b3JQcm90b3R5cGUsIG1ldGhvZHMsIEtFWTsKICAgICAgICAgICAgICAgICAgICBpZiAoYW55TmF0aXZlSXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlID0gZ2V0UHJvdG90eXBlT2YoYW55TmF0aXZlSXRlcmF0b3IuY2FsbChuZXcgSXRlcmFibGUoKSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlICE9PSBPYmplY3QucHJvdG90eXBlICYmIEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZS5uZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUlTX1BVUkUgJiYgZ2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlKSAhPT0gSXRlcmF0b3JQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlLCBJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghaXNDYWxsYWJsZShDdXJyZW50SXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgSVRFUkFUT1IsIHJldHVyblRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRvU3RyaW5nVGFnKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgVE9fU1RSSU5HX1RBRywgdHJ1ZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbVE9fU1RSSU5HX1RBR10gPSByZXR1cm5UaGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfRlVOQ1RJT05fTkFNRSAmJiBERUZBVUxUID09IFZBTFVFUyAmJiBuYXRpdmVJdGVyYXRvciAmJiBuYXRpdmVJdGVyYXRvci5uYW1lICE9PSBWQUxVRVMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19QVVJFICYmIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoSXRlcmFibGVQcm90b3R5cGUsICduYW1lJywgVkFMVUVTKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0SXRlcmF0b3IgPSBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGwobmF0aXZlSXRlcmF0b3IsIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoREVGQVVMVCkgewogICAgICAgICAgICAgICAgICAgICAgICBtZXRob2RzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzOiBnZXRJdGVyYXRpb25NZXRob2QoVkFMVUVTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleXM6IElTX1NFVCA/IGRlZmF1bHRJdGVyYXRvciA6IGdldEl0ZXJhdGlvbk1ldGhvZChLRVlTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJpZXM6IGdldEl0ZXJhdGlvbk1ldGhvZChFTlRSSUVTKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoRk9SQ0VEKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChLRVkgaW4gbWV0aG9kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9TQUZBUklfSVRFUkFUT1JTIHx8IElOQ09SUkVDVF9WQUxVRVNfTkFNRSB8fCAhKEtFWSBpbiBJdGVyYWJsZVByb3RvdHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgS0VZLCBtZXRob2RzW0tFWV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBOQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmNlZDogQlVHR1lfU0FGQVJJX0lURVJBVE9SUyB8fCBJTkNPUlJFQ1RfVkFMVUVTX05BTUUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIG1ldGhvZHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoKCFJU19QVVJFIHx8IEZPUkNFRCkgJiYgSXRlcmFibGVQcm90b3R5cGVbSVRFUkFUT1JdICE9PSBkZWZhdWx0SXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgSVRFUkFUT1IsIGRlZmF1bHRJdGVyYXRvciwgeyBuYW1lOiBERUZBVUxUIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbTkFNRV0gPSBkZWZhdWx0SXRlcmF0b3I7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGhvZHM7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvclByb3RvdHlwZSA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDk1KS5JdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciByZXR1cm5UaGlzID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKEl0ZXJhdG9yQ29uc3RydWN0b3IsIE5BTUUsIG5leHQsIEVOVU1FUkFCTEVfTkVYVCkgewogICAgICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gTkFNRSArICcgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yQ29uc3RydWN0b3IucHJvdG90eXBlID0gY3JlYXRlKEl0ZXJhdG9yUHJvdG90eXBlLCB7IG5leHQ6IGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigrIUVOVU1FUkFCTEVfTkVYVCwgbmV4dCkgfSk7CiAgICAgICAgICAgICAgICAgICAgc2V0VG9TdHJpbmdUYWcoSXRlcmF0b3JDb25zdHJ1Y3RvciwgVE9fU1RSSU5HX1RBRywgZmFsc2UsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yc1tUT19TVFJJTkdfVEFHXSA9IHJldHVyblRoaXM7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzMpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBCVUdHWV9TQUZBUklfSVRFUkFUT1JTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUsIFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZSwgYXJyYXlJdGVyYXRvcjsKICAgICAgICAgICAgICAgIGlmIChbXS5rZXlzKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXlJdGVyYXRvciA9IFtdLmtleXMoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnbmV4dCcgaW4gYXJyYXlJdGVyYXRvcikpCiAgICAgICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgPSBnZXRQcm90b3R5cGVPZihnZXRQcm90b3R5cGVPZihhcnJheUl0ZXJhdG9yKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgIT09IE9iamVjdC5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgTkVXX0lURVJBVE9SX1BST1RPVFlQRSA9ICFpc09iamVjdChJdGVyYXRvclByb3RvdHlwZSkgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciB0ZXN0ID0ge307CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yUHJvdG90eXBlW0lURVJBVE9SXS5jYWxsKHRlc3QpICE9PSB0ZXN0OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBpZiAoTkVXX0lURVJBVE9SX1BST1RPVFlQRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IHt9OwogICAgICAgICAgICAgICAgZWxzZSBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IGNyZWF0ZShJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoSXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oSXRlcmF0b3JQcm90b3R5cGUsIElURVJBVE9SLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0b3JQcm90b3R5cGU6IEl0ZXJhdG9yUHJvdG90eXBlLAogICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlM6IEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHRhcmdldCwgVEFHLCBTVEFUSUMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICYmICFTVEFUSUMpCiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IHRhcmdldC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAmJiAhaGFzT3duKHRhcmdldCwgVE9fU1RSSU5HX1RBRykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodGFyZ2V0LCBUT19TVFJJTkdfVEFHLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogVEFHCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodmFsdWUsIGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGRvbmUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUdfU1VQUE9SVCA9IF9fd19wZGZqc19yZXF1aXJlX18oODMpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUxKTsKICAgICAgICAgICAgICAgIHZhciB0b1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oOTkpOwogICAgICAgICAgICAgICAgaWYgKCFUT19TVFJJTkdfVEFHX1NVUFBPUlQpIHsKICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKE9iamVjdC5wcm90b3R5cGUsICd0b1N0cmluZycsIHRvU3RyaW5nLCB7IHVuc2FmZTogdHJ1ZSB9KTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyB7fS50b1N0cmluZyA6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnW29iamVjdCAnICsgY2xhc3NvZih0aGlzKSArICddJzsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMik7CiAgICAgICAgICAgICAgICB2YXIgY29sbGVjdGlvblN0cm9uZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIwKTsKICAgICAgICAgICAgICAgIGNvbGxlY3Rpb24oJ01hcCcsIGZ1bmN0aW9uIChpbml0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIE1hcCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGluaXQodGhpcywgYXJndW1lbnRzLmxlbmd0aCA/IGFyZ3VtZW50c1swXSA6IHVuZGVmaW5lZCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sIGNvbGxlY3Rpb25TdHJvbmcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzRm9yY2VkID0gX193X3BkZmpzX3JlcXVpcmVfXyg3MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsTWV0YWRhdGFNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMyk7CiAgICAgICAgICAgICAgICB2YXIgaXRlcmF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEwKTsKICAgICAgICAgICAgICAgIHZhciBhbkluc3RhbmNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc051bGxPclVuZGVmaW5lZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjaGVja0NvcnJlY3RuZXNzT2ZJdGVyYXRpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExOCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBpbmhlcml0SWZSZXF1aXJlZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTE5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKENPTlNUUlVDVE9SX05BTUUsIHdyYXBwZXIsIGNvbW1vbikgewogICAgICAgICAgICAgICAgICAgIHZhciBJU19NQVAgPSBDT05TVFJVQ1RPUl9OQU1FLmluZGV4T2YoJ01hcCcpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfV0VBSyA9IENPTlNUUlVDVE9SX05BTUUuaW5kZXhPZignV2VhaycpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgQURERVIgPSBJU19NQVAgPyAnc2V0JyA6ICdhZGQnOwogICAgICAgICAgICAgICAgICAgIHZhciBOYXRpdmVDb25zdHJ1Y3RvciA9IGdsb2JhbFtDT05TVFJVQ1RPUl9OQU1FXTsKICAgICAgICAgICAgICAgICAgICB2YXIgTmF0aXZlUHJvdG90eXBlID0gTmF0aXZlQ29uc3RydWN0b3IgJiYgTmF0aXZlQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IE5hdGl2ZUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBleHBvcnRlZCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBmaXhNZXRob2QgPSBmdW5jdGlvbiAoS0VZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1bmN1cnJpZWROYXRpdmVNZXRob2QgPSB1bmN1cnJ5VGhpcyhOYXRpdmVQcm90b3R5cGVbS0VZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oTmF0aXZlUHJvdG90eXBlLCBLRVksIEtFWSA9PSAnYWRkJyA/IGZ1bmN0aW9uIGFkZCh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIHZhbHVlID09PSAwID8gMCA6IHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdkZWxldGUnID8gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IEtFWSA9PSAnZ2V0JyA/IGZ1bmN0aW9uIGdldChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJU19XRUFLICYmICFpc09iamVjdChrZXkpID8gdW5kZWZpbmVkIDogdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdoYXMnID8gZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIHNldChrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmN1cnJpZWROYXRpdmVNZXRob2QodGhpcywga2V5ID09PSAwID8gMCA6IGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFJFUExBQ0UgPSBpc0ZvcmNlZChDT05TVFJVQ1RPUl9OQU1FLCAhaXNDYWxsYWJsZShOYXRpdmVDb25zdHJ1Y3RvcikgfHwgIShJU19XRUFLIHx8IE5hdGl2ZVByb3RvdHlwZS5mb3JFYWNoICYmICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcigpLmVudHJpZXMoKS5uZXh0KCk7CiAgICAgICAgICAgICAgICAgICAgfSkpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoUkVQTEFDRSkgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IGNvbW1vbi5nZXRDb25zdHJ1Y3Rvcih3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxNZXRhZGF0YU1vZHVsZS5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzRm9yY2VkKENPTlNUUlVDVE9SX05BTUUsIHRydWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnN0YW5jZSA9IG5ldyBDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgSEFTTlRfQ0hBSU5JTkcgPSBpbnN0YW5jZVtBRERFUl0oSVNfV0VBSyA/IHt9IDogLTAsIDEpICE9IGluc3RhbmNlOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgVEhST1dTX09OX1BSSU1JVElWRVMgPSBmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZS5oYXMoMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQUNDRVBUX0lURVJBQkxFUyA9IGNoZWNrQ29ycmVjdG5lc3NPZkl0ZXJhdGlvbihmdW5jdGlvbiAoaXRlcmFibGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcihpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQlVHR1lfWkVSTyA9ICFJU19XRUFLICYmIGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkaW5zdGFuY2UgPSBuZXcgTmF0aXZlQ29uc3RydWN0b3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IDU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW5zdGFuY2VbQURERVJdKGluZGV4LCBpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gISRpbnN0YW5jZS5oYXMoLTApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBQ0NFUFRfSVRFUkFCTEVTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKGR1bW15LCBpdGVyYWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuSW5zdGFuY2UoZHVtbXksIE5hdGl2ZVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBpbmhlcml0SWZSZXF1aXJlZChuZXcgTmF0aXZlQ29uc3RydWN0b3IoKSwgZHVtbXksIENvbnN0cnVjdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShpdGVyYWJsZSwgdGhhdFtBRERFUl0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQ6IHRoYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnN0cnVjdG9yLnByb3RvdHlwZSA9IE5hdGl2ZVByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5hdGl2ZVByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IENvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUSFJPV1NfT05fUFJJTUlUSVZFUyB8fCBCVUdHWV9aRVJPKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaXhNZXRob2QoJ2RlbGV0ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKCdoYXMnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElTX01BUCAmJiBmaXhNZXRob2QoJ2dldCcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9aRVJPIHx8IEhBU05UX0NIQUlOSU5HKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKElTX1dFQUsgJiYgTmF0aXZlUHJvdG90eXBlLmNsZWFyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE5hdGl2ZVByb3RvdHlwZS5jbGVhcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0ZWRbQ09OU1RSVUNUT1JfTkFNRV0gPSBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICAkKHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2xvYmFsOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBDb25zdHJ1Y3RvciAhPSBOYXRpdmVDb25zdHJ1Y3RvcgogICAgICAgICAgICAgICAgICAgIH0sIGV4cG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBzZXRUb1N0cmluZ1RhZyhDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19XRUFLKQogICAgICAgICAgICAgICAgICAgICAgICBjb21tb24uc2V0U3Ryb25nKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGlkZGVuS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNTgpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5TmFtZXNFeHRlcm5hbE1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA0KTsKICAgICAgICAgICAgICAgIHZhciBpc0V4dGVuc2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNyk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgRlJFRVpJTkcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwOSk7CiAgICAgICAgICAgICAgICB2YXIgUkVRVUlSRUQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIHZhciBNRVRBREFUQSA9IHVpZCgnbWV0YScpOwogICAgICAgICAgICAgICAgdmFyIGlkID0gMDsKICAgICAgICAgICAgICAgIHZhciBzZXRNZXRhZGF0YSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGl0LCBNRVRBREFUQSwgewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0SUQ6ICdPJyArIGlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWFrRGF0YToge30KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBmYXN0S2V5ID0gZnVuY3Rpb24gKGl0LCBjcmVhdGUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnc3ltYm9sJyA/IGl0IDogKHR5cGVvZiBpdCA9PSAnc3RyaW5nJyA/ICdTJyA6ICdQJykgKyBpdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bihpdCwgTUVUQURBVEEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFeHRlbnNpYmxlKGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnRic7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3JlYXRlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdFJzsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0TWV0YWRhdGEoaXQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRbTUVUQURBVEFdLm9iamVjdElEOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXRXZWFrRGF0YSA9IGZ1bmN0aW9uIChpdCwgY3JlYXRlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oaXQsIE1FVEFEQVRBKSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzRXh0ZW5zaWJsZShpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjcmVhdGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W01FVEFEQVRBXS53ZWFrRGF0YTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgb25GcmVlemUgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoRlJFRVpJTkcgJiYgUkVRVUlSRUQgJiYgaXNFeHRlbnNpYmxlKGl0KSAmJiAhaGFzT3duKGl0LCBNRVRBREFUQSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBtZXRhLmVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lcyA9IGdldE93blByb3BlcnR5TmFtZXNNb2R1bGUuZjsKICAgICAgICAgICAgICAgICAgICB2YXIgc3BsaWNlID0gdW5jdXJyeVRoaXMoW10uc3BsaWNlKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHRlc3RbTUVUQURBVEFdID0gMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0T3duUHJvcGVydHlOYW1lcyh0ZXN0KS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2V0T3duUHJvcGVydHlOYW1lcyhpdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuZ3RoID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdFtpXSA9PT0gTUVUQURBVEEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaWNlKHJlc3VsdCwgaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiAnT2JqZWN0JywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXQ6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZWQ6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSwgeyBnZXRPd25Qcm9wZXJ0eU5hbWVzOiBnZXRPd25Qcm9wZXJ0eU5hbWVzRXh0ZXJuYWxNb2R1bGUuZiB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIG1ldGEgPSBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBlbmFibGU6IGVuYWJsZSwKICAgICAgICAgICAgICAgICAgICBmYXN0S2V5OiBmYXN0S2V5LAogICAgICAgICAgICAgICAgICAgIGdldFdlYWtEYXRhOiBnZXRXZWFrRGF0YSwKICAgICAgICAgICAgICAgICAgICBvbkZyZWV6ZTogb25GcmVlemUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW01FVEFEQVRBXSA9IHRydWU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciAkZ2V0T3duUHJvcGVydHlOYW1lcyA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYxKS5mKTsKICAgICAgICAgICAgICAgIHZhciBhcnJheVNsaWNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDUpOwogICAgICAgICAgICAgICAgdmFyIHdpbmRvd05hbWVzID0gdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB3aW5kb3cgJiYgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMgPyBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh3aW5kb3cpIDogW107CiAgICAgICAgICAgICAgICB2YXIgZ2V0V2luZG93TmFtZXMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGdldE93blByb3BlcnR5TmFtZXMoaXQpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnJheVNsaWNlKHdpbmRvd05hbWVzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuZiA9IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93TmFtZXMgJiYgY2xhc3NvZihpdCkgPT0gJ1dpbmRvdycgPyBnZXRXaW5kb3dOYW1lcyhpdCkgOiAkZ2V0T3duUHJvcGVydHlOYW1lcyh0b0luZGV4ZWRPYmplY3QoaXQpKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvQWJzb2x1dGVJbmRleCA9IF9fd19wZGZqc19yZXF1aXJlX18oNjQpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgJEFycmF5ID0gQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgbWF4ID0gTWF0aC5tYXg7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChPLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciBrID0gdG9BYnNvbHV0ZUluZGV4KHN0YXJ0LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIHZhciBmaW4gPSB0b0Fic29sdXRlSW5kZXgoZW5kID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiBlbmQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9ICRBcnJheShtYXgoZmluIC0gaywgMCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIG4gPSAwOyBrIDwgZmluOyBrKyssIG4rKykKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkocmVzdWx0LCBuLCBPW2tdKTsKICAgICAgICAgICAgICAgICAgICByZXN1bHQubGVuZ3RoID0gbjsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIHRvUHJvcGVydHlLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIxKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5S2V5ID0gdG9Qcm9wZXJ0eUtleShrZXkpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9wZXJ0eUtleSBpbiBvYmplY3QpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBwcm9wZXJ0eUtleSwgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKDAsIHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3RbcHJvcGVydHlLZXldID0gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMTgpOwogICAgICAgICAgICAgICAgdmFyIEFSUkFZX0JVRkZFUl9OT05fRVhURU5TSUJMRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA4KTsKICAgICAgICAgICAgICAgIHZhciAkaXNFeHRlbnNpYmxlID0gT2JqZWN0LmlzRXh0ZW5zaWJsZTsKICAgICAgICAgICAgICAgIHZhciBGQUlMU19PTl9QUklNSVRJVkVTID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICRpc0V4dGVuc2libGUoMSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gRkFJTFNfT05fUFJJTUlUSVZFUyB8fCBBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgPyBmdW5jdGlvbiBpc0V4dGVuc2libGUoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmIChBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgJiYgY2xhc3NvZihpdCkgPT0gJ0FycmF5QnVmZmVyJykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkaXNFeHRlbnNpYmxlID8gJGlzRXh0ZW5zaWJsZShpdCkgOiB0cnVlOwogICAgICAgICAgICAgICAgfSA6ICRpc0V4dGVuc2libGU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEFycmF5QnVmZmVyID09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IG5ldyBBcnJheUJ1ZmZlcig4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5pc0V4dGVuc2libGUoYnVmZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShidWZmZXIsICdhJywgeyB2YWx1ZTogOCB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmlzRXh0ZW5zaWJsZShPYmplY3QucHJldmVudEV4dGVuc2lvbnMoe30pKTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgaXNBcnJheUl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTQpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdG9yQ2xvc2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNik7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBSZXN1bHQgPSBmdW5jdGlvbiAoc3RvcHBlZCwgcmVzdWx0KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdG9wcGVkID0gc3RvcHBlZDsKICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgUmVzdWx0UHJvdG90eXBlID0gUmVzdWx0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhYmxlLCB1bmJvdW5kRnVuY3Rpb24sIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IG9wdGlvbnMgJiYgb3B0aW9ucy50aGF0OwogICAgICAgICAgICAgICAgICAgIHZhciBBU19FTlRSSUVTID0gISEob3B0aW9ucyAmJiBvcHRpb25zLkFTX0VOVFJJRVMpOwogICAgICAgICAgICAgICAgICAgIHZhciBJU19SRUNPUkQgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfUkVDT1JEKTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfSVRFUkFUT1IgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgICAgIHZhciBJTlRFUlJVUFRFRCA9ICEhKG9wdGlvbnMgJiYgb3B0aW9ucy5JTlRFUlJVUFRFRCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZuID0gYmluZCh1bmJvdW5kRnVuY3Rpb24sIHRoYXQpOwogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvciwgaXRlckZuLCBpbmRleCwgbGVuZ3RoLCByZXN1bHQsIG5leHQsIHN0ZXA7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3AgPSBmdW5jdGlvbiAoY29uZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVyYXRvcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXJhdG9yQ2xvc2UoaXRlcmF0b3IsICdub3JtYWwnLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlc3VsdCh0cnVlLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIGNhbGxGbiA9IGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQVNfRU5UUklFUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWVbMF0sIHZhbHVlWzFdLCBzdG9wKSA6IGZuKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWUsIHN0b3ApIDogZm4odmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaWYgKElTX1JFQ09SRCkgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGl0ZXJhYmxlLml0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoSVNfSVRFUkFUT1IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0b3IgPSBpdGVyYWJsZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyRm4gPSBnZXRJdGVyYXRvck1ldGhvZChpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXRlckZuKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhpdGVyYWJsZSkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBcnJheUl0ZXJhdG9yTWV0aG9kKGl0ZXJGbikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW5kZXggPSAwLCBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZShpdGVyYWJsZSk7IGxlbmd0aCA+IGluZGV4OyBpbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gY2FsbEZuKGl0ZXJhYmxlW2luZGV4XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAmJiBpc1Byb3RvdHlwZU9mKFJlc3VsdFByb3RvdHlwZSwgcmVzdWx0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUmVzdWx0KGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGdldEl0ZXJhdG9yKGl0ZXJhYmxlLCBpdGVyRm4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0ID0gSVNfUkVDT1JEID8gaXRlcmFibGUubmV4dCA6IGl0ZXJhdG9yLm5leHQ7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCEoc3RlcCA9IGNhbGwobmV4dCwgaXRlcmF0b3IpKS5kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBjYWxsRm4oc3RlcC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvckNsb3NlKGl0ZXJhdG9yLCAndGhyb3cnLCBlcnJvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXN1bHQgPT0gJ29iamVjdCcgJiYgcmVzdWx0ICYmIGlzUHJvdG90eXBlT2YoUmVzdWx0UHJvdG90eXBlLCByZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZXN1bHQoZmFsc2UpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMik7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gdW5jdXJyeVRoaXModW5jdXJyeVRoaXMuYmluZCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChmbiwgdGhhdCkgewogICAgICAgICAgICAgICAgICAgIGFDYWxsYWJsZShmbik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQgPT09IHVuZGVmaW5lZCA/IGZuIDogTkFUSVZFX0JJTkQgPyBiaW5kKGZuLCB0aGF0KSA6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZuLmFwcGx5KHRoYXQsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZm4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY2xhc3NvZlJhdyhmbikgPT09ICdGdW5jdGlvbicpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhmbik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBBcnJheVByb3RvdHlwZSA9IEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ICE9PSB1bmRlZmluZWQgJiYgKEl0ZXJhdG9ycy5BcnJheSA9PT0gaXQgfHwgQXJyYXlQcm90b3R5cGVbSVRFUkFUT1JdID09PSBpdCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMzUpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCwgdXNpbmdJdGVyYXRvcikgewogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvck1ldGhvZCA9IGFyZ3VtZW50cy5sZW5ndGggPCAyID8gZ2V0SXRlcmF0b3JNZXRob2QoYXJndW1lbnQpIDogdXNpbmdJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoYUNhbGxhYmxlKGl0ZXJhdG9yTWV0aG9kKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFuT2JqZWN0KGNhbGwoaXRlcmF0b3JNZXRob2QsIGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TWV0aG9kKGl0LCBJVEVSQVRPUikgfHwgZ2V0TWV0aG9kKGl0LCAnQEBpdGVyYXRvcicpIHx8IEl0ZXJhdG9yc1tjbGFzc29mKGl0KV07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRNZXRob2QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMzKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhdG9yLCBraW5kLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclJlc3VsdCwgaW5uZXJFcnJvcjsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBnZXRNZXRob2QoaXRlcmF0b3IsICdyZXR1cm4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbm5lclJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09ICd0aHJvdycpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBjYWxsKGlubmVyUmVzdWx0LCBpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJFcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyUmVzdWx0ID0gZXJyb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSAndGhyb3cnKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJFcnJvcikKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgaW5uZXJSZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoaW5uZXJSZXN1bHQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzUHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI4KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQsIFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1Byb3RvdHlwZU9mKFByb3RvdHlwZSwgaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElURVJBVE9SID0gd2VsbEtub3duU3ltYm9sKCdpdGVyYXRvcicpOwogICAgICAgICAgICAgICAgdmFyIFNBRkVfQ0xPU0lORyA9IGZhbHNlOwogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICB2YXIgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICB2YXIgaXRlcmF0b3JXaXRoUmV0dXJuID0gewogICAgICAgICAgICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiAhIWNhbGxlZCsrIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICdyZXR1cm4nOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTQUZFX0NMT1NJTkcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBpdGVyYXRvcldpdGhSZXR1cm5bSVRFUkFUT1JdID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIEFycmF5LmZyb20oaXRlcmF0b3JXaXRoUmV0dXJuLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IDI7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZXhlYywgU0tJUF9DTE9TSU5HKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFTS0lQX0NMT1NJTkcgJiYgIVNBRkVfQ0xPU0lORykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJVEVSQVRJT05fU1VQUE9SVCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmplY3QgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0W0lURVJBVE9SXSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiBJVEVSQVRJT05fU1VQUE9SVCA9IHRydWUgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBleGVjKG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElURVJBVElPTl9TVVBQT1JUOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCR0aGlzLCBkdW1teSwgV3JhcHBlcikgewogICAgICAgICAgICAgICAgICAgIHZhciBOZXdUYXJnZXQsIE5ld1RhcmdldFByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YgJiYgaXNDYWxsYWJsZShOZXdUYXJnZXQgPSBkdW1teS5jb25zdHJ1Y3RvcikgJiYgTmV3VGFyZ2V0ICE9PSBXcmFwcGVyICYmIGlzT2JqZWN0KE5ld1RhcmdldFByb3RvdHlwZSA9IE5ld1RhcmdldC5wcm90b3R5cGUpICYmIE5ld1RhcmdldFByb3RvdHlwZSAhPT0gV3JhcHBlci5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKCR0aGlzLCBOZXdUYXJnZXRQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyMCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjcmVhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDczKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdElucyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIxKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGFuSW5zdGFuY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciBpdGVyYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTApOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIHNldFNwZWNpZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhc3RLZXkgPSAoX193X3BkZmpzX3JlcXVpcmVfXygxMDMpLmZhc3RLZXkpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBzZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5zZXQ7CiAgICAgICAgICAgICAgICB2YXIgaW50ZXJuYWxTdGF0ZUdldHRlckZvciA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0dGVyRm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29uc3RydWN0b3I6IGZ1bmN0aW9uICh3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKHRoYXQsIGl0ZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbkluc3RhbmNlKHRoYXQsIFByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoYXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDT05TVFJVQ1RPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBjcmVhdGUobnVsbCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3Q6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0OiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZTogMAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRlKGl0ZXJhYmxlLCB0aGF0W0FEREVSXSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0OiB0aGF0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBQcm90b3R5cGUgPSBDb25zdHJ1Y3Rvci5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gaW50ZXJuYWxTdGF0ZUdldHRlckZvcihDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmluZSA9IGZ1bmN0aW9uICh0aGF0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gZ2V0RW50cnkodGhhdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2aW91cywgaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS52YWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gZW50cnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCA9IGZhc3RLZXkoa2V5LCB0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldmlvdXM6IHByZXZpb3VzID0gc3RhdGUubGFzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVkOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5maXJzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuZmlyc3QgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZpb3VzLm5leHQgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLnNpemUrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCAhPT0gJ0YnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5pbmRleFtpbmRleF0gPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGF0OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0RW50cnkgPSBmdW5jdGlvbiAodGhhdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gZmFzdEtleShrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ICE9PSAnRicpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlLmluZGV4W2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoZW50cnkgPSBzdGF0ZS5maXJzdDsgZW50cnk7IGVudHJ5ID0gZW50cnkubmV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeS5rZXkgPT0ga2V5KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW5zKFByb3RvdHlwZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXI6IGZ1bmN0aW9uIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkYXRhID0gc3RhdGUuaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gc3RhdGUuZmlyc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGVudHJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkucHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS5wcmV2aW91cyA9IGVudHJ5LnByZXZpb3VzLm5leHQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBkYXRhW2VudHJ5LmluZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkgPSBlbnRyeS5uZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5maXJzdCA9IHN0YXRlLmxhc3QgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zaXplID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGF0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZW50cnkgPSBnZXRFbnRyeSh0aGF0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dCA9IGVudHJ5Lm5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdGF0ZS5pbmRleFtlbnRyeS5pbmRleF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXYubmV4dCA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dC5wcmV2aW91cyA9IHByZXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5maXJzdCA9PSBlbnRyeSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmZpcnN0ID0gbmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QgPT0gZW50cnkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gcHJldjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuc2l6ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0LnNpemUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yRWFjaDogZnVuY3Rpb24gZm9yRWFjaChjYWxsYmFja2ZuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYm91bmRGdW5jdGlvbiA9IGJpbmQoY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5maXJzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3VuZEZ1bmN0aW9uKGVudHJ5LnZhbHVlLCBlbnRyeS5rZXksIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhczogZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIWdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdElucyhQcm90b3R5cGUsIElTX01BUCA/IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IGdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVudHJ5ICYmIGVudHJ5LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24gc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmaW5lKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZDogZnVuY3Rpb24gYWRkKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZSh0aGlzLCB2YWx1ZSA9IHZhbHVlID09PSAwID8gMCA6IHZhbHVlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoUHJvdG90eXBlLCAnc2l6ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9uZzogZnVuY3Rpb24gKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIElURVJBVE9SX05BTUUgPSBDT05TVFJVQ1RPUl9OQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbENvbGxlY3Rpb25TdGF0ZSA9IGludGVybmFsU3RhdGVHZXR0ZXJGb3IoQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbEl0ZXJhdG9yU3RhdGUgPSBpbnRlcm5hbFN0YXRlR2V0dGVyRm9yKElURVJBVE9SX05BTUUpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVJdGVyYXRvcihDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSwgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBJVEVSQVRPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaXRlcmF0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IGdldEludGVybmFsQ29sbGVjdGlvblN0YXRlKGl0ZXJhdGVkKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3Q6IHVuZGVmaW5lZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsSXRlcmF0b3JTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IHN0YXRlLmxhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LnByZXZpb3VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS50YXJnZXQgfHwgIShzdGF0ZS5sYXN0ID0gZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5zdGF0ZS5maXJzdCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS50YXJnZXQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUl0ZXJSZXN1bHRPYmplY3QodW5kZWZpbmVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICdrZXlzJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChlbnRyeS5rZXksIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICd2YWx1ZXMnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGVudHJ5LnZhbHVlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkua2V5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIElTX01BUCA/ICdlbnRyaWVzJyA6ICd2YWx1ZXMnLCAhSVNfTUFQLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3BlY2llcyhDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNyYywgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBzcmMpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNyY1trZXldLCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTIyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgU1BFQ0lFUyA9IHdlbGxLbm93blN5bWJvbCgnc3BlY2llcycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoQ09OU1RSVUNUT1JfTkFNRSkgewogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IGdldEJ1aWx0SW4oQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTICYmIENvbnN0cnVjdG9yICYmICFDb25zdHJ1Y3RvcltTUEVDSUVTXSkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoQ29uc3RydWN0b3IsIFNQRUNJRVMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjQpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjb2xsZWN0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDIpOwogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb25TdHJvbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMCk7CiAgICAgICAgICAgICAgICBjb2xsZWN0aW9uKCdTZXQnLCBmdW5jdGlvbiAoaW5pdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBTZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbml0KHRoaXMsIGFyZ3VtZW50cy5sZW5ndGggPyBhcmd1bWVudHNbMF0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LCBjb2xsZWN0aW9uU3Ryb25nKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTI1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRCdWlsdGluID0gX193X3BkZmpzX3JlcXVpcmVfXygyNyk7CiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE3KTsKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIHVpZCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDQpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMjYpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Nyk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0ZUFyZ3VtZW50c0xlbmd0aCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRSZWdFeHBGbGFncyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI4KTsKICAgICAgICAgICAgICAgIHZhciBNYXBIZWxwZXJzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzApOwogICAgICAgICAgICAgICAgdmFyIFNldEhlbHBlcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMSk7CiAgICAgICAgICAgICAgICB2YXIgRVJST1JfU1RBQ0tfSU5TVEFMTEFCTEUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMik7CiAgICAgICAgICAgICAgICB2YXIgUFJPUEVSX1RSQU5TRkVSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzMpOwogICAgICAgICAgICAgICAgdmFyIE9iamVjdCA9IGdsb2JhbC5PYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXkgPSBnbG9iYWwuQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgRGF0ZSA9IGdsb2JhbC5EYXRlOwogICAgICAgICAgICAgICAgdmFyIEVycm9yID0gZ2xvYmFsLkVycm9yOwogICAgICAgICAgICAgICAgdmFyIEV2YWxFcnJvciA9IGdsb2JhbC5FdmFsRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUmFuZ2VFcnJvciA9IGdsb2JhbC5SYW5nZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJlZmVyZW5jZUVycm9yID0gZ2xvYmFsLlJlZmVyZW5jZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFN5bnRheEVycm9yID0gZ2xvYmFsLlN5bnRheEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVVJJRXJyb3IgPSBnbG9iYWwuVVJJRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUGVyZm9ybWFuY2VNYXJrID0gZ2xvYmFsLlBlcmZvcm1hbmNlTWFyazsKICAgICAgICAgICAgICAgIHZhciBXZWJBc3NlbWJseSA9IGdsb2JhbC5XZWJBc3NlbWJseTsKICAgICAgICAgICAgICAgIHZhciBDb21waWxlRXJyb3IgPSBXZWJBc3NlbWJseSAmJiBXZWJBc3NlbWJseS5Db21waWxlRXJyb3IgfHwgRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgTGlua0Vycm9yID0gV2ViQXNzZW1ibHkgJiYgV2ViQXNzZW1ibHkuTGlua0Vycm9yIHx8IEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJ1bnRpbWVFcnJvciA9IFdlYkFzc2VtYmx5ICYmIFdlYkFzc2VtYmx5LlJ1bnRpbWVFcnJvciB8fCBFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBET01FeGNlcHRpb24gPSBnZXRCdWlsdGluKCdET01FeGNlcHRpb24nKTsKICAgICAgICAgICAgICAgIHZhciBNYXAgPSBNYXBIZWxwZXJzLk1hcDsKICAgICAgICAgICAgICAgIHZhciBtYXBIYXMgPSBNYXBIZWxwZXJzLmhhczsKICAgICAgICAgICAgICAgIHZhciBtYXBHZXQgPSBNYXBIZWxwZXJzLmdldDsKICAgICAgICAgICAgICAgIHZhciBtYXBTZXQgPSBNYXBIZWxwZXJzLnNldDsKICAgICAgICAgICAgICAgIHZhciBTZXQgPSBTZXRIZWxwZXJzLlNldDsKICAgICAgICAgICAgICAgIHZhciBzZXRBZGQgPSBTZXRIZWxwZXJzLmFkZDsKICAgICAgICAgICAgICAgIHZhciBvYmplY3RLZXlzID0gZ2V0QnVpbHRpbignT2JqZWN0JywgJ2tleXMnKTsKICAgICAgICAgICAgICAgIHZhciBwdXNoID0gdW5jdXJyeVRoaXMoW10ucHVzaCk7CiAgICAgICAgICAgICAgICB2YXIgdGhpc0Jvb2xlYW5WYWx1ZSA9IHVuY3VycnlUaGlzKHRydWUudmFsdWVPZik7CiAgICAgICAgICAgICAgICB2YXIgdGhpc051bWJlclZhbHVlID0gdW5jdXJyeVRoaXMoMS4wLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNTdHJpbmdWYWx1ZSA9IHVuY3VycnlUaGlzKCcnLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNUaW1lVmFsdWUgPSB1bmN1cnJ5VGhpcyhEYXRlLnByb3RvdHlwZS5nZXRUaW1lKTsKICAgICAgICAgICAgICAgIHZhciBQRVJGT1JNQU5DRV9NQVJLID0gdWlkKCdzdHJ1Y3R1cmVkQ2xvbmUnKTsKICAgICAgICAgICAgICAgIHZhciBEQVRBX0NMT05FX0VSUk9SID0gJ0RhdGFDbG9uZUVycm9yJzsKICAgICAgICAgICAgICAgIHZhciBUUkFOU0ZFUlJJTkcgPSAnVHJhbnNmZXJyaW5nJzsKICAgICAgICAgICAgICAgIHZhciBjaGVja0Jhc2ljU2VtYW50aWMgPSBmdW5jdGlvbiAoc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNldDEgPSBuZXcgZ2xvYmFsLlNldChbN10pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgc2V0MiA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHNldDEpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbnVtYmVyID0gc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24oT2JqZWN0KDcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNldDIgPT0gc2V0MSB8fCAhc2V0Mi5oYXMoNykgfHwgdHlwZW9mIG51bWJlciAhPSAnb2JqZWN0JyB8fCBudW1iZXIgIT0gNzsKICAgICAgICAgICAgICAgICAgICB9KSAmJiBzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbjsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY2hlY2tFcnJvcnNDbG9uaW5nID0gZnVuY3Rpb24gKHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uLCAkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gbmV3ICRFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGE6IGVycm9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYjogZXJyb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKHRlc3QgJiYgdGVzdC5hID09PSB0ZXN0LmIgJiYgdGVzdC5hIGluc3RhbmNlb2YgJEVycm9yICYmIHRlc3QuYS5zdGFjayA9PT0gZXJyb3Iuc3RhY2spOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBjaGVja05ld0Vycm9yc0Nsb25pbmdTZW1hbnRpYyA9IGZ1bmN0aW9uIChzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKG5ldyBnbG9iYWwuQWdncmVnYXRlRXJyb3IoWzFdLCBQRVJGT1JNQU5DRV9NQVJLLCB7IGNhdXNlOiAzIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0d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ZSA9IGZ1bmN0aW9uICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IERPTUV4Y2VwdGlvbignVW5jbG9uZWFibGUgdHlwZTogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0aHJvd1VucG9seWZpbGxhYmxlID0gZnVuY3Rpb24gKHR5cGUsIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oKGFjdGlvbiB8fCAnQ2xvbmluZycpICsgJyBvZiAnICsgdHlwZSArICcgY2Fubm90IGJlIHByb3Blcmx5IHBvbHlmaWxsZWQgaW4gdGhpcyBlbmdpbmUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRGF0YVRyYW5zZmVyID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBkYXRhVHJhbnNmZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5EYXRhVHJhbnNmZXIoKTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5DbGlwYm9hcmRFdmVudCgnJykuY2xpcGJvYXJkRGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGFUcmFuc2ZlciAmJiBkYXRhVHJhbnNmZXIuaXRlbXMgJiYgZGF0YVRyYW5zZmVyLmZpbGVzID8gZGF0YVRyYW5zZmVyIDogbnVsbDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgc3RydWN0dXJlZENsb25lSW50ZXJuYWwgPSBmdW5jdGlvbiAodmFsdWUsIG1hcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1N5bWJvbCh2YWx1ZSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5jbG9uZWFibGUoJ1N5bWJvbCcpOwogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hcEdldChtYXAsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgIHZhciB0eXBlID0gY2xhc3NvZih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgQywgbmFtZSwgY2xvbmVkLCBkYXRhVHJhbnNmZXIsIGksIGxlbmd0aCwga2V5cywga2V5LCBzb3VyY2UsIHRhcmdldCwgb3B0aW9uczsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQXJyYXkobGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdTZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnUmVnRXhwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBSZWdFeHAodmFsdWUuc291cmNlLCBnZXRSZWdFeHBGbGFncyh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQWdncmVnYXRlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBnZXRCdWlsdGluKCdBZ2dyZWdhdGVFcnJvcicpKFtdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRXZhbEVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gRXZhbEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JhbmdlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBSYW5nZUVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JlZmVyZW5jZUVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gUmVmZXJlbmNlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU3ludGF4RXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBTeW50YXhFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdUeXBlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBUeXBlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVVJJRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBVUklFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDb21waWxlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDb21waWxlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnTGlua0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gTGlua0Vycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1J1bnRpbWVFcnJvcic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IFJ1bnRpbWVFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NRXhjZXB0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01FeGNlcHRpb24odmFsdWUubWVzc2FnZSwgdmFsdWUubmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdEYXRhVmlldyc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDhBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1VpbnQ4QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50OENsYW1wZWRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDE2QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MTZBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDMyQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0JpZ0ludDY0QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdCaWdVaW50NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEMoc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuYnVmZmVyLCBtYXApLCB2YWx1ZS5ieXRlT2Zmc2V0LCB0eXBlID09PSAnRGF0YVZpZXcnID8gdmFsdWUuYnl0ZUxlbmd0aCA6IHZhbHVlLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUXVhZCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01RdWFkKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnAxLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZS5wMiwgbWFwKSwgc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUucDMsIG1hcCksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnA0LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZUxpc3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gY3JlYXRlRGF0YVRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVRyYW5zZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuZ3RoID0gbGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyLml0ZW1zLmFkZChzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZVtpXSwgbWFwKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IGRhdGFUcmFuc2Zlci5maWxlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdJbWFnZURhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgSW1hZ2VEYXRhKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmRhdGEsIG1hcCksIHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQsIHsgY29sb3JTcGFjZTogdmFsdWUuY29sb3JTcGFjZSB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXRpdmVSZXN0cmljdGVkU3RydWN0dXJlZENsb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmlnSW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IE9iamVjdCh2YWx1ZS52YWx1ZU9mKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Jvb2xlYW4nOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNCb29sZWFuVmFsdWUodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdOdW1iZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNOdW1iZXJWYWx1ZSh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1N0cmluZyc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBPYmplY3QodGhpc1N0cmluZ1ZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRGF0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgRGF0ZSh0aGlzVGltZVZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5EYXRhVmlldzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQyAmJiB0eXBlb2YgdmFsdWUuc2xpY2UgIT0gJ2Z1bmN0aW9uJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnNsaWNlID09ICdmdW5jdGlvbicgJiYgIXZhbHVlLnJlc2l6YWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB2YWx1ZS5zbGljZSgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zID0gJ21heEJ5dGVMZW5ndGgnIGluIHZhbHVlID8geyBtYXhCeXRlTGVuZ3RoOiB2YWx1ZS5tYXhCeXRlTGVuZ3RoIH0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBBcnJheUJ1ZmZlcihsZW5ndGgsIG9wdGlvbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2UgPSBuZXcgQyh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IG5ldyBDKGNsb25lZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnNldFVpbnQ4KGksIHNvdXJjZS5nZXRVaW50OChpKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0FycmF5QnVmZmVyIGlzIGRldGFjaGVkJywgREFUQV9DTE9ORV9FUlJPUik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU2hhcmVkQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmxvYic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IHZhbHVlLnNsaWNlKDAsIHZhbHVlLnNpemUsIHZhbHVlLnR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVBvaW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUG9pbnRSZWFkT25seSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDLmZyb21Qb2ludCA/IEMuZnJvbVBvaW50KHZhbHVlKSA6IG5ldyBDKHZhbHVlLngsIHZhbHVlLnksIHZhbHVlLnosIHZhbHVlLncpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVJlY3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdET01SZWN0UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tUmVjdCA/IEMuZnJvbVJlY3QodmFsdWUpIDogbmV3IEModmFsdWUueCwgdmFsdWUueSwgdmFsdWUud2lkdGgsIHZhbHVlLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tTWF0cml4ID8gQy5mcm9tTWF0cml4KHZhbHVlKSA6IG5ldyBDKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdWaWRlb0ZyYW1lJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZSh2YWx1ZS5jbG9uZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEZpbGUoW3ZhbHVlXSwgdmFsdWUubmFtZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Nyb3BUYXJnZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDcnlwdG9LZXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtRGlyZWN0b3J5SGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZVN5c3RlbUZpbGVIYW5kbGUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25JbmZvJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25NZXNzYWdlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW1hZ2VCaXRtYXAnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSVENDZXJ0aWZpY2F0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1dlYkFzc2VtYmx5Lk1vZHVsZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG1hcFNldChtYXAsIHZhbHVlLCBjbG9uZWQpOwogICAgICAgICAgICAgICAgICAgIGlmIChkZWVwKQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0FycmF5JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5cyA9IG9iamVjdEtleXModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDAsIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKGtleXMpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkoY2xvbmVkLCBrZXksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlW2tleV0sIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodiwgaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXBTZXQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbChrLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1NldCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRBZGQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoY2xvbmVkLCAnbWVzc2FnZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLm1lc3NhZ2UsIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24odmFsdWUsICdjYXVzZScpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdjYXVzZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmNhdXNlLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgPT0gJ0FnZ3JlZ2F0ZUVycm9yJykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQuZXJyb3JzID0gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuZXJyb3JzLCBtYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTUV4Y2VwdGlvbic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEVSUk9SX1NUQUNLX0lOU1RBTExBQkxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdzdGFjaycsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnN0YWNrLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmVkOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1RyYW5zZmVyID0gZnVuY3Rpb24gKHJhd1RyYW5zZmVyLCBtYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHJhd1RyYW5zZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKCdUcmFuc2ZlciBvcHRpb24gY2Fubm90IGJlIGNvbnZlcnRlZCB0byBhIHNlcXVlbmNlJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShyYXdUcmFuc2ZlciwgZnVuY3Rpb24gKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHB1c2godHJhbnNmZXIsIGFuT2JqZWN0KHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZSh0cmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlLCB0eXBlLCBDLCB0cmFuc2ZlcnJlZEFycmF5LCB0cmFuc2ZlcnJlZCwgY2FudmFzLCBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfVFJBTlNGRVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJyZWRBcnJheSA9IG5hdGl2ZVN0cnVjdHVyZWRDbG9uZSh0cmFuc2ZlciwgeyB0cmFuc2ZlcjogdHJhbnNmZXIgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdHJhbnNmZXJbaV0sIHRyYW5zZmVycmVkQXJyYXlbaSsrXSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRyYW5zZmVyW2krK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0R1cGxpY2F0ZSB0cmFuc2ZlcmFibGUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBjbGFzc29mKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ltYWdlQml0bWFwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5PZmZzY3JlZW5DYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDb25zdHJ1Y3RvcihDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcyA9IG5ldyBDKHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dCA9IGNhbnZhcy5nZXRDb250ZXh0KCdiaXRtYXByZW5kZXJlcicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC50cmFuc2ZlckZyb21JbWFnZUJpdG1hcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IGNhbnZhcy50cmFuc2ZlclRvSW1hZ2VCaXRtYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1ZpZGVvRnJhbWUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUuY2xvbmUpIHx8ICFpc0NhbGxhYmxlKHZhbHVlLmNsb3NlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVycmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUudHJhbnNmZXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlLCBUUkFOU0ZFUlJJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IHZhbHVlLnRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01lZGlhU291cmNlSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdNZXNzYWdlUG9ydCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnT2Zmc2NyZWVuQ2FudmFzJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSZWFkYWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVHJhbnNmb3JtU3RyZWFtJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdXcml0YWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2ZlcnJlZCA9PT0gdW5kZWZpbmVkKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ1RoaXMgb2JqZWN0IGNhbm5vdCBiZSB0cmFuc2ZlcnJlZDogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdmFsdWUsIHRyYW5zZmVycmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIGdsb2JhbDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIHNoYW06ICFQUk9QRVJfVFJBTlNGRVIsCiAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBGT1JDRURfUkVQTEFDRU1FTlQKICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICBzdHJ1Y3R1cmVkQ2xvbmU6IGZ1bmN0aW9uIHN0cnVjdHVyZWRDbG9uZSh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IHZhbGlkYXRlQXJndW1lbnRzTGVuZ3RoKGFyZ3VtZW50cy5sZW5ndGgsIDEpID4gMSAmJiAhaXNOdWxsT3JVbmRlZmluZWQoYXJndW1lbnRzWzFdKSA/IGFuT2JqZWN0KGFyZ3VtZW50c1sxXSkgOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2ZlciA9IG9wdGlvbnMgPyBvcHRpb25zLnRyYW5zZmVyIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWFwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmZXIgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5VG9UcmFuc2Zlcih0cmFuc2ZlciwgbWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpbnNwZWN0U291cmNlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NCk7CiAgICAgICAgICAgICAgICB2YXIgbm9vcCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZW1wdHkgPSBbXTsKICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3QgPSBnZXRCdWlsdEluKCdSZWZsZWN0JywgJ2NvbnN0cnVjdCcpOwogICAgICAgICAgICAgICAgdmFyIGNvbnN0cnVjdG9yUmVnRXhwID0gL15ccyooPzpjbGFzc3xmdW5jdGlvbilcYi87CiAgICAgICAgICAgICAgICB2YXIgZXhlYyA9IHVuY3VycnlUaGlzKGNvbnN0cnVjdG9yUmVnRXhwLmV4ZWMpOwogICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9UT19TVFJJTkcgPSAhY29uc3RydWN0b3JSZWdFeHAuZXhlYyhub29wKTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yTW9kZXJuID0gZnVuY3Rpb24gaXNDb25zdHJ1Y3Rvcihhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZShhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Qobm9vcCwgZW1wdHksIGFyZ3VtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgaXNDb25zdHJ1Y3RvckxlZ2FjeSA9IGZ1bmN0aW9uIGlzQ29uc3RydWN0b3IoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChjbGFzc29mKGFyZ3VtZW50KSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0Z1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR2VuZXJhdG9yRnVuY3Rpb24nOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0dlbmVyYXRvckZ1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOQ09SUkVDVF9UT19TVFJJTkcgfHwgISFleGVjKGNvbnN0cnVjdG9yUmVnRXhwLCBpbnNwZWN0U291cmNlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGlzQ29uc3RydWN0b3JMZWdhY3kuc2hhbSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFjb25zdHJ1Y3QgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBjYWxsZWQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ29uc3RydWN0b3JNb2Rlcm4oaXNDb25zdHJ1Y3Rvck1vZGVybi5jYWxsKSB8fCAhaXNDb25zdHJ1Y3Rvck1vZGVybihPYmplY3QpIHx8ICFpc0NvbnN0cnVjdG9yTW9kZXJuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9KSB8fCBjYWxsZWQ7CiAgICAgICAgICAgICAgICB9KSA/IGlzQ29uc3RydWN0b3JMZWdhY3kgOiBpc0NvbnN0cnVjdG9yTW9kZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHBhc3NlZCwgcmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAocGFzc2VkIDwgcmVxdWlyZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICRUeXBlRXJyb3IoJ05vdCBlbm91Z2ggYXJndW1lbnRzJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhc3NlZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBpc1Byb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXygyOCk7CiAgICAgICAgICAgICAgICB2YXIgcmVnRXhwRmxhZ3MgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyOSk7CiAgICAgICAgICAgICAgICB2YXIgUmVnRXhwUHJvdG90eXBlID0gUmVnRXhwLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKFIpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZmxhZ3MgPSBSLmZsYWdzOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmbGFncyA9PT0gdW5kZWZpbmVkICYmICEoJ2ZsYWdzJyBpbiBSZWdFeHBQcm90b3R5cGUpICYmICFoYXNPd24oUiwgJ2ZsYWdzJykgJiYgaXNQcm90b3R5cGVPZihSZWdFeHBQcm90b3R5cGUsIFIpID8gY2FsbChyZWdFeHBGbGFncywgUikgOiBmbGFnczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBhbk9iamVjdCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaGFzSW5kaWNlcykKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdkJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5nbG9iYWwpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnZyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaWdub3JlQ2FzZSkKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdpJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5tdWx0aWxpbmUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnbSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuZG90QWxsKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3MnOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGF0LnVuaWNvZGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQudW5pY29kZVNldHMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndic7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuc3RpY2t5KQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3knOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIE1hcFByb3RvdHlwZSA9IE1hcC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBNYXA6IE1hcCwKICAgICAgICAgICAgICAgICAgICBzZXQ6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZS5zZXQpLAogICAgICAgICAgICAgICAgICAgIGdldDogdW5jdXJyeVRoaXMoTWFwUHJvdG90eXBlLmdldCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhNYXBQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBNYXBQcm90b3R5cGUKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgU2V0UHJvdG90eXBlID0gU2V0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gewogICAgICAgICAgICAgICAgICAgIFNldDogU2V0LAogICAgICAgICAgICAgICAgICAgIGFkZDogdW5jdXJyeVRoaXMoU2V0UHJvdG90eXBlLmFkZCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhTZXRQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKFNldFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBTZXRQcm90b3R5cGUsCiAgICAgICAgICAgICAgICAgICAgJGhhczogU2V0UHJvdG90eXBlLmhhcywKICAgICAgICAgICAgICAgICAgICAka2V5czogU2V0UHJvdG90eXBlLmtleXMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gRXJyb3IoJ2EnKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnc3RhY2snIGluIGVycm9yKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGVycm9yLCAnc3RhY2snLCBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IoMSwgNykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvci5zdGFjayAhPT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgVjggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMxKTsKICAgICAgICAgICAgICAgIHZhciBJU19CUk9XU0VSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzQpOwogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIHZhciBzdHJ1Y3R1cmVkQ2xvbmUgPSBnbG9iYWwuc3RydWN0dXJlZENsb25lOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhIXN0cnVjdHVyZWRDbG9uZSAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChJU19ERU5PICYmIFY4ID4gOTIgfHwgSVNfTk9ERSAmJiBWOCA+IDk0IHx8IElTX0JST1dTRVIgJiYgVjggPiA5NykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIoOCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGNsb25lID0gc3RydWN0dXJlZENsb25lKGJ1ZmZlciwgeyB0cmFuc2ZlcjogW2J1ZmZlcl0gfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlci5ieXRlTGVuZ3RoICE9IDAgfHwgY2xvbmUuYnl0ZUxlbmd0aCAhPSA4OwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIUlTX0RFTk8gJiYgIUlTX05PREUgJiYgdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB0eXBlb2YgZG9jdW1lbnQgPT0gJ29iamVjdCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdHlwZW9mIERlbm8gPT0gJ29iamVjdCcgJiYgRGVubyAmJiB0eXBlb2YgRGVuby52ZXJzaW9uID09ICdvYmplY3QnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBwcm9jZXNzICE9ICd1bmRlZmluZWQnICYmIGNsYXNzb2YocHJvY2VzcykgPT0gJ3Byb2Nlc3MnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnb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B2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9hbm5vdGF0aW9uX3N0b3JhZ2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2ZvbnRfbG9hZGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDUpOwogICAgICAgICAgICAgICAgdmFyIF9jYW52YXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Nik7CiAgICAgICAgICAgICAgICB2YXIgX3dvcmtlcl9vcHRpb25zID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDkpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIHZhciBfbWVzc2FnZV9oYW5kbGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTApOwogICAgICAgICAgICAgICAgdmFyIF9tZXRhZGF0YSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTUxKTsKICAgICAgICAgICAgICAgIHZhciBfb3B0aW9uYWxfY29udGVudF9jb25maWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Mik7CiAgICAgICAgICAgICAgICB2YXIgX3RyYW5zcG9ydF9zdHJlYW0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Myk7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRl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yeSA9IERlZmF1bHRTdGFuZGFyZEZvbnREYXRhRmFjdG9yeTsKICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVDTWFwUmVhZGVyRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVTdGFuZGFyZEZvbnREYXRhRmFjdG9yeQogICAgICAgICAgICAgICAgICAgIH0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1NSk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q2FudmFzRmFjdG9yeSA9IERlZmF1bHRDYW52YXNGYWN0b3J5ID0gTm9kZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBEZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0RmlsdGVyRmFjdG9yeSA9IERlZmF1bHRGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBEZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3Rvcnk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgY3JlYXRlUERGTmV0d29ya1N0cmVhbTsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGTm9kZVN0cmVhbQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVQREZOZXR3b3JrU3RyZWFtID0gcGFyYW1zID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGTm9kZVN0cmVhbShwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBERk5ldHdvcmtTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU5KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGRmV0Y2hTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUERGTmV0d29ya1N0cmVhbSA9IHBhcmFtcyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF9kaXNwbGF5X3V0aWxzLmlzVmFsaWRGZXRjaFVybCkocGFyYW1zLnVybCkgPyBuZXcgUERGRmV0Y2hTdHJlYW0ocGFyYW1zKSA6IG5ldyBQREZOZXR3b3JrU3RyZWFtKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RG9jdW1lbnQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzcmMgPT09ICJzdHJpbmciIHx8IHNyYyBpbnN0YW5jZW9mIFVSTCkgewogICAgICAgICAgICAgICAgICAgICAgICBzcmMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHNyYwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKHNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3JjID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogc3JjCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3JjICE9PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIGluIGdldERvY3VtZW50LCBuZWVkIHBhcmFtZXRlciBvYmplY3QuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghc3JjLnVybCAmJiAhc3JjLmRhdGEgJiYgIXNyYy5yYW5nZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIG9iamVjdDogbmVlZCBlaXRoZXIgLmRhdGEsIC5yYW5nZSBvciAudXJsIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgUERGRG9jdW1lbnRMb2FkaW5nVGFzaygpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQKICAgICAgICAgICAgICAgICAgICB9ID0gdGFzazsKICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzcmMudXJsID8gZ2V0VXJsUHJvcChzcmMudXJsKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHNyYy5kYXRhID8gZ2V0RGF0YVByb3Aoc3JjLmRhdGEpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBodHRwSGVhZGVycyA9IHNyYy5odHRwSGVhZGVycyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpdGhDcmVkZW50aWFscyA9IHNyYy53aXRoQ3JlZGVudGlhbHMgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFzc3dvcmQgPSBzcmMucGFzc3dvcmQgPz8gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZVRyYW5zcG9ydCA9IHNyYy5yYW5nZSBpbnN0YW5jZW9mIFBERkRhdGFSYW5nZVRyYW5zcG9ydCA/IHNyYy5yYW5nZSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VDaHVua1NpemUgPSBOdW1iZXIuaXNJbnRlZ2VyKHNyYy5yYW5nZUNodW5rU2l6ZSkgJiYgc3JjLnJhbmdlQ2h1bmtTaXplID4gMCA/IHNyYy5yYW5nZUNodW5rU2l6ZSA6IERFRkFVTFRfUkFOR0VfQ0hVTktfU0laRTsKICAgICAgICAgICAgICAgICAgICBsZXQgd29ya2VyID0gc3JjLndvcmtlciBpbnN0YW5jZW9mIFBERldvcmtlciA/IHNyYy53b3JrZXIgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcmJvc2l0eSA9IHNyYy52ZXJib3NpdHk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZG9jQmFzZVVybCA9IHR5cGVvZiBzcmMuZG9jQmFzZVVybCA9PT0gInN0cmluZyIgJiYgISgwLCBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWUpKHNyYy5kb2NCYXNlVXJsKSA/IHNyYy5kb2NCYXNlVXJsI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BuZXcgRGVmYXVsdEZpbHRlckZhY3RvcnkoewogICAgICAgICAgICAgICAgICAgICAgICBkb2NJZCwKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnNldFZlcmJvc2l0eUxldmVsKSh2ZXJib3NpdHkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydEZhY3RvcnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnkKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmICghdXNlV29ya2VyRmV0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNwb3J0RmFjdG9yeS5jTWFwUmVhZGVyRmFjdG9yeSA9IG5ldyBDTWFwUmVhZGVyRmFjdG9yeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlVXJsOiBjTWFwVXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkOiBjTWFwUGFja2VkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRGYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gbmV3IFN0YW5kYXJkRm9udERhdGFGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmw6IHN0YW5kYXJkRm9udERhdGFVcmwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghd29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlclBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclBvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyID0gd29ya2VyUGFyYW1zLnBvcnQgPyBQREZXb3JrZXIuZnJvbVBvcnQod29ya2VyUGFyYW1zKSA6IG5ldyBQREZXb3JrZXIod29ya2VyUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fd29ya2VyID0gd29ya2VyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBmZXRjaERvY1BhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGFwaVZlcnNpb246ICczLjUuMTIyJywKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvY0Jhc2VVcmwsCiAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYSwKICAgICAgICAgICAgICAgICAgICAgICAgZXZhbHVhdG9yT3B0aW9uczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4SW1hZ2VTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNNYXhBcmVhSW5CeXRlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRFeHRyYVByb3BlcnRpZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VTeXN0ZW1Gb250cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBVcmw6IHVzZVdvcmtlckZldGNoID8gY01hcFVybCA6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZEZvbnREYXRhVXJsOiB1c2VXb3JrZXJGZXRjaCA/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+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW5jZWxsZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZ2Z4ID0gdGhpcy5nZngpID09PSBudWxsIHx8IF90aGlzJGdmeCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZ2Z4LmVuZERyYXdpbmcodGhpcy5wYWdlQ29sb3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxSZW5kZXJUYXNrLiNjYW52YXNJblVzZS5kZWxldGUodGhpcy5fY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKGVycm9yIHx8IG5ldyBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24oYFJlbmRlcmluZyBjYW5jZWxsZWQsIHBhZ2UgJHt0aGlzLl9wYWdlSW5kZXggKyAxfWAsICJjYW52YXMiLCBleHRyYURlbGF5KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRzdGVwcGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhcGhpY3NSZWFkeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeUNhbGxiYWNrID0gdGhpcy5fY29udGludWVCb3VuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkc3RlcHBlciA9IHRoaXMuc3RlcHBlcikgPT09IG51bGwgfHwgX3RoaXMkc3RlcHBlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3RlcHBlci51cGRhdGVPcGVyYXRvckxpc3QodGhpcy5vcGVyYXRvckxpc3QpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5ydW5uaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NvbnRpbnVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5jZWxsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50YXNrLm9uQ29udGludWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFzay5vbkNvbnRpbnVlKHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zY2hlZHVsZU5leHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCgpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbih0aGlzLl9uZXh0Qm91bmQpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBfbmV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSB0aGlzLmdmeC5leGVjdXRlT3BlcmF0b3JMaXN0KHRoaXMub3BlcmF0b3JMaXN0LCB0aGlzLm9wZXJhdG9yTGlzdElkeCwgdGhpcy5fY29udGludWVCb3VuZCwgdGhpcy5zdGVwcGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMub3BlcmF0b3JMaXN0SWR4ID09PSB0aGlzLm9wZXJhdG9yTGlzdC5hcmdzQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm9wZXJhdG9yTGlzdC5sYXN0Q2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5lbmREcmF3aW5nKHRoaXMucGFnZUNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmRlbGV0ZSh0aGlzLl9jYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCB2ZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICAgICAgZXhwb3J0cy52ZXJzaW9uID0gdmVyc2lvbjsKICAgICAgICAgICAgICAgIGNvbnN0IGJ1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgICAgICAgICBleHBvcnRzLmJ1aWxkID0gYnVpbGQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBleHBvcnRzLkFubm90YXRpb25TdG9yYWdlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRlU2V0LmFkZChvYmopOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyhvYmosIHByaXZhdGVNYXAsIHZhbHVlKSB7IF9jaGVja1ByaXZhdGVSZWRlY2xhcmF0aW9uKG9iaiwgcHJpdmF0ZU1hcCk7IHByaXZhdGVNYXAuc2V0KG9iaiwgdmFsdWUpOyB9CiAgICAgICAgICAgICAgICBmdW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V0TW9kaWZpZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25TdG9yYWdlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RpZmllZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9zdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25TZXRNb2RpZmllZCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25SZXNldE1vZGlmaWVkID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWYWx1ZShrZXksIGRlZmF1bHRWYWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmYXVsdFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGRlZmF1bHRWYWx1ZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXdWYWx1ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKS5kZWxldGUoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB2YWx1ZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWYWx1ZShrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtb2RpZmllZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JqICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2VudHJ5LCB2YWxdIG9mIE9iamVjdC5lbnRyaWVzKHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvYmpbZW50cnldICE9PSB2YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmpbZW50cnldID0gdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RpZmllZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0TW9kaWZpZWQsIF9zZXRNb2RpZmllZDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yICYmIHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IodmFsdWUuY29uc3RydWN0b3IuX3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuaGFzKGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA+IDAgPyAoMCwgX3V0aWwub2JqZWN0RnJvbU1hcCkoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKSkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBbGwob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBPYmplY3QuZW50cmllcyhvYmopKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFZhbHVlKGtleSwgdmFsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzZXRNb2RpZmllZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGlmaWVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SZXNldE1vZGlmaWVkID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJpbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJpbnRBbm5vdGF0aW9uU3RvcmFnZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmUgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXJpYWxpemVkID0gdmFsIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yID8gdmFsLnNlcmlhbGl6ZSgpIDogdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlcmlhbGl6ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZS5zZXQoa2V5LCBzZXJpYWxpemVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXRIYXNoKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc2ggPSBuZXcgX211cm11cmhhc2guTXVybXVySGFzaDNfNjQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWxdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzaC51cGRhdGUoYCR7a2V5fToke0pTT04uc3RyaW5naWZ5KHZhbCl9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2guaGV4ZGlnZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RvcmFnZSA9IEFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1vZGlmaWVkMigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbW9kaWZpZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25TZXRNb2RpZmllZCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQcmludEFubm90YXRpb25TdG9yYWdlIGV4dGVuZHMgQW5ub3RhdGlvblN0b3JhZ2UgewogICAgICAgICAgICAgICAgICAgICNzZXJpYWxpemFibGUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNzZXJpYWxpemFibGUgPSBzdHJ1Y3R1cmVkQ2xvbmUocGFyZW50LnNlcmlhbGl6YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcmludCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIFByaW50QW5ub3RhdGlvblN0b3JhZ2UucHJpbnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3NlcmlhbGl6YWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBQcmludEFubm90YXRpb25TdG9yYWdlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yIHsKICAgICAgICAgICAgICAgICAgICAjYm91bmRGb2N1c2luID0gdGhpcy5mb2N1c2luLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2JvdW5kRm9jdXNvdXQgPSB0aGlzLmZvY3Vzb3V0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2hhc0JlZW5TZWxlY3RlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNpc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAjaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX3VpTWFuYWdlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgI3pJbmRleCA9IEFubm90YXRpb25FZGl0b3IuX3pJbmRleCsrOwogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JNYW5hZ2VyID0gbmV3IF90b29scy5Db2xvck1hbmFnZXIoKTsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgX3pJbmRleCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQW5ub3RhdGlvbkVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQW5ub3RhdGlvbkVkaXRvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmFtZXRlcnMucGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlkID0gcGFyYW1ldGVycy5pZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aWR0aCA9IHRoaXMuaGVpZ2h0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJhbWV0ZXJzLnBhcmVudC5wYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IHBhcmFtZXRlcnMubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIgPSBwYXJhbWV0ZXJzLnVpTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEaW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMucGFyZW50LnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZURpbWVuc2lvbnMgPSBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlVHJhbnNsYXRpb24gPSBbcGFnZVgsIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3dpZHRoLCBoZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSBwYXJhbWV0ZXJzLnggLyB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55ID0gcGFyYW1ldGVycy55IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzQXR0YWNoZWRUb0RPTSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZ2V0IF9kZWZhdWx0TGluZUNvbG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9kZWZhdWx0TGluZUNvbG9yIiwgdGhpcy5fY29sb3JNYW5hZ2VyLmdldEhleENvZGUoIkNhbnZhc1RleHQiKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZENvbW1hbmRzKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkQ29tbWFuZHMocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRMYXllcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3VpTWFuYWdlci5jdXJyZW50TGF5ZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEluQmFja2dyb3VuZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUuekluZGV4ID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0SW5Gb3JlZ3JvdW5kKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS56SW5kZXggPSB0aGlzLiN6SW5kZXg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFBhcmVudChwYXJlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudCAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJlbnQucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlRGltZW5zaW9ucyA9IHBhcmVudC5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuI2hhc0JlZW5TZWxlY3RlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNoYXNCZWVuU2VsZWN0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb2N1c291dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkcGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gZXZlbnQucmVsYXRlZFRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAhPT0gbnVsbCAmJiB0YXJnZXQgIT09IHZvaWQgMCAmJiB0YXJnZXQuY2xvc2VzdChgIyR7dGhpcy5pZH1gKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKChfdGhpcyRwYXJlbnQgPSB0aGlzLnBhcmVudCkgIT09IG51bGwgJiYgX3RoaXMkcGFyZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkcGFyZW50LmlzTXVsdGlwbGVTZWxlY3Rpb24pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0T3JSZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRyYWdzdGFydChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5wYXJlbnQuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0WCA9IGV2ZW50LmNsaWVudFggLSByZWN0Lng7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRZID0gZXZlbnQuY2xpZW50WSAtIHJlY3QueTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLnNldERhdGEoInRleHQvcGxhaW4iLCB0aGlzLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmVmZmVjdEFsbG93ZWQgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEF0KHgsIHksIHR4LCB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt0eCwgdHldID0gdGhpcy5zY3JlZW5Ub1BhZ2VUcmFuc2xhdGlvbih0eCwgdHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAoeCArIHR4KSAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAoeSArIHR5KSAvIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUubGVmdCA9IGAkezEwMCAqIHRoaXMueH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUudG9wID0gYCR7MTAwICogdGhpcy55fSVgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGUoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IHRoaXMuc2NyZWVuVG9QYWdlVHJhbnNsYXRpb24oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCArPSB4IC8gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSArPSB5IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5sZWZ0ID0gYCR7MTAwICogdGhpcy54fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS50b3AgPSBgJHsxMDAgKiB0aGlzLnl9JWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNjcmVlblRvUGFnZVRyYW5zbGF0aW9uKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnBhcmVudFJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeSwgLXhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteCwgLXldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyNzA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteSwgeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCwgeV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFNjYWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJlYWxTY2FsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFJvdGF0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcGFyZW50RGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl91aU1hbmFnZXIudmlld1BhcmFtZXRlcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlV2lkdGgsIHBhZ2VIZWlnaHRdID0gdGhpcy5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtwYWdlV2lkdGggKiByZWFsU2NhbGUsIHBhZ2VIZWlnaHQgKiByZWFsU2NhbGVdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREaW1zKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS53aWR0aCA9IGAkezEwMCAqIHdpZHRoIC8gcGFyZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnN0eWxlLmhlaWdodCA9IGAkezEwMCAqIGhlaWdodCAvIHBhcmVudEhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZml4RGltcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUGVyY2VudCA9IHdpZHRoLmVuZHNXaXRoKCIlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFBlcmNlbnQgPSBoZWlnaHQuZW5kc1dpdGgoIiUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUGVyY2VudCAmJiBoZWlnaHRQZXJjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpZHRoUGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBgJHsxMDAgKiBwYXJzZUZsb2F0KHdpZHRoKSAvIHBhcmVudFdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaGVpZ2h0UGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogcGFyc2VGbG9hdChoZWlnaHQpIC8gcGFyZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImRhdGEtZWRpdG9yLXJvdGF0aW9uIiwgKDM2MCAtIHRoaXMucm90YXRpb24pICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuY2xhc3NOYW1lID0gdGhpcy5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImlkIiwgdGhpcy5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgidGFiSW5kZXgiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFkZEV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt0eCwgdHldID0gdGhpcy5nZXRJbml0aWFsVHJhbnNsYXRpb24oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUodHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF90b29scy5iaW5kRXZlbnRzKSh0aGlzLCB0aGlzLmRpdiwgWyJkcmFnc3RhcnQiLCAicG9pbnRlcmRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNNYWMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF91dGlsLkZlYXR1cmVUZXN0LnBsYXRmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwIHx8IGV2ZW50LmN0cmxLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmN0cmxLZXkgJiYgIWlzTWFjIHx8IGV2ZW50LnNoaWZ0S2V5IHx8IGV2ZW50Lm1ldGFLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnRvZ2dsZVNlbGVjdGVkKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaGFzQmVlblNlbGVjdGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVjdCh0eCwgdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IHRoaXMucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlWCwgcGFnZVldID0gdGhpcy5wYWdlVHJhbnNsYXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WCA9IHR4IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WSA9IHR5IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSB0aGlzLnggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSB0aGlzLnkgKiBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRYICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRZIC0gaGVpZ2h0ICsgcGFnZVksIHggKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VYLCBwYWdlSGVpZ2h0IC0geSAtIHNoaWZ0WSArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRYICsgcGFnZVksIHggKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCAtIHNoaWZ0WCAtIHdpZHRoICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRZICsgcGFnZVksIHggLSBzaGlmdFggKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3ggLSBzaGlmdFkgLSBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgLSBzaGlmdFggLSB3aWR0aCArIHBhZ2VZLCB4IC0gc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRYICsgcGFnZVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZWN0SW5DdXJyZW50Q29vcmRzKHJlY3QsIHBhZ2VIZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0geDIgLSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0geTIgLSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkyLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkxLCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeDIsIHBhZ2VIZWlnaHQgLSB5MSwgd2lkdGgsIGhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3gyLCBwYWdlSGVpZ2h0IC0geTIsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbmNlQWRkZWQoKSB7fQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzSW5FZGl0TW9kZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzSW5FZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzSW5FZGl0TW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2hvdWxkR2V0S2V5Ym9hcmRFdmVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbmVlZHNUb0JlUmVidWlsdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2ICYmICF0aGlzLmlzQXR0YWNoZWRUb0RPTTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGRpdi5hZGRFdmVudExpc3RlbmVyKCJmb2N1c2luIiwgdGhpcy4jYm91bmRGb2N1c2luKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VyaWFsaXplKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBbiBlZGl0b3IgbXVzdCBiZSBzZXJpYWxpemFibGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGRlc2VyaWFsaXplKGRhdGEsIHBhcmVudCwgdWlNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IG5ldyB0aGlzLnByb3RvdHlwZS5jb25zdHJ1Y3Rvcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogcGFyZW50LmdldE5leHRJZCgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlNYW5hZ2VyCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iucm90YXRpb24gPSBkYXRhLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IGVkaXRvci5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gsIHksIHdpZHRoLCBoZWlnaHRdID0gZWRpdG9yLmdldFJlY3RJbkN1cnJlbnRDb29yZHMoZGF0YS5yZWN0LCBwYWdlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnggPSB4IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IueSA9IHkgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iud2lkdGggPSB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmhlaWdodCA9IGhlaWdodCAvIHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQucmVtb3ZlKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZGl2MiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkaXYyLmNsYXNzTGlzdC5hZGQoInNlbGVjdGVkRWRpdG9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGl2MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdjMgPSB0aGlzLmRpdikgPT09IG51bGwgfHwgX3RoaXMkZGl2MyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2My5jbGFzc0xpc3QucmVtb3ZlKCJzZWxlY3RlZEVkaXRvciIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVQYXJhbXModHlwZSwgdmFsdWUpIHt9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGVuYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7fTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnREaXYoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzRWRpdGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0IGlzRWRpdGluZyh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNpc0VkaXRpbmcgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRTZWxlY3RlZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvciA9IEFubm90YXRpb25FZGl0b3I7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE0MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLktleWJvYXJkTWFuYWdlciA9IGV4cG9ydHMuQ29tbWFuZE1hbmFnZXIgPSBleHBvcnRzLkNvbG9yTWFuYWdlciA9IGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRv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ICAgICAgIGdldElkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYCR7X3V0aWwuQW5ub3RhdGlvbkVkaXRvclByZWZpeH0ke3RoaXMuI2lkKyt9YDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb21tYW5kTWFuYWdlciB7CiAgICAgICAgICAgICAgICAgICAgI2NvbW1hbmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgI2xvY2tlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICNwb3NpdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF4U2l6ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtYXhTaXplID0gbWF4U2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBOYU4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbyA9IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobXVzdEV4ZWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNsb2NrZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY21kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI3Bvc2l0aW9uID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI2NvbW1hbmRzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jcG9zaXRpb24gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHMucHVzaChzYXZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3ZlcndyaXRlSWZTYW1lVHlwZSAmJiB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0udHlwZSA9PT0gdHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtlZXBVbmRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZS51bmRvID0gdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG87CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0gPSBzYXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5leHQgPSB0aGlzLiNwb3NpdGlvbiArIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0ID09PSB0aGlzLiNtYXhTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5zcGxpY2UoMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNwb3NpdGlvbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dCA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzLnNwbGljZShuZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5wdXNoKHNhdmUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jcG9zaXRpb24gPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uIC09IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsb2NrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLmNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jcG9zaXRpb24gIT09IC0xOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbW1hbmRNYW5hZ2VyID0gQ29tbWFuZE1hbmFnZXI7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgS2V5Ym9hcmRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlciA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcyA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleXMsIGNhbGxiYWNrXSBvZiBjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IG9mIGtleXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc01hY0tleSA9IGtleS5zdGFydHNXaXRoKCJtYWMrIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTWFjICYmIGlzTWFjS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tzLnNldChrZXkuc2xpY2UoNCksIGNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzLmFkZChrZXkuc3BsaXQoIisiKS5hdCgtMSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzTWFjICYmICFpc01hY0tleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcy5zZXQoa2V5LCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxsS2V5cy5hZGQoa2V5LnNwbGl0KCIrIikuYXQoLTEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlYyhzZWxmLCBldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuYWxsS2V5cy5oYXMoZXZlbnQua2V5KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbGxiYWNrID0gdGhpcy5jYWxsYmFja3MuZ2V0KF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZSwgX3NlcmlhbGl6ZTIpLmNhbGwodGhpcywgZXZlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLmJpbmQoc2VsZikoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5LZXlib2FyZE1hbmFnZXIgPSBLZXlib2FyZE1hbmFnZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5hbHRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgiYWx0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5jdHJsS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVyLnB1c2goImN0cmwiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50Lm1ldGFLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgibWV0YSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuc2hpZnRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgic2hpZnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaChldmVudC5rZXkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ciA9IHRoaXMuYnVmZmVyLmpvaW4oIisiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvck1hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JzTWFwcGluZyA9IG5ldyBNYXAoW1siQ2FudmFzVGV4dCIsIFswLCAwLCAwXV0sIFsiQ2FudmFzIiwgWzI1NSwgMjU1LCAyNTVdXV0pOwogICAgICAgICAgICAgICAgICAgIGdldCBfY29sb3JzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvcnMgPSBuZXcgTWFwKFtbIkNhbnZhc1RleHQiLCBudWxsXSwgWyJDYW52YXMiLCBudWxsXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q29sb3JWYWx1ZXMpKGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX2NvbG9ycyIsIGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnZlcnQoY29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldFJHQikoY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpbmRvdy5tYXRjaE1lZGlhKCIoZm9yY2VkLWNvbG9yczogYWN0aXZlKSIpLm1hdGNoZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZ2I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbbmFtZSwgUkdCXSBvZiB0aGlzLl9jb2xvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSR0IuZXZlcnkoKHgsIGkpID0+IHggPT09IHJnYltpXSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQ29sb3JNYW5hZ2VyLl9jb2xvcnNNYXBwaW5nLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmdiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRIZXhDb2RlKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gdGhpcy5fY29sb3JzLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZ2IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5yZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQ29sb3JNYW5hZ2VyID0gQ29sb3JNYW5hZ2VyOwogICAgICAgICAgICAgICAgdmFyIF9hY3RpdmVFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYWxsRWRpdG9ycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hbGxMYXllcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYW5ub3RhdGlvblN0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29tbWFuZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY3VycmVudFBhZ2VJbmRleCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JUeXBlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzVG9SZXNjYWxlID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2ZW50QnVzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0VuYWJsZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfbW9kZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RlZEVkaXRvcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDb3B5ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ3V0ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kUGFzdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRLZXlkb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25FZGl0aW5nQWN0aW9uID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25QYWdlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblNjYWxlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcHJldmlvdXNTdGF0ZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGFpbmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEtleWJvYXJkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfYWRkQ29weVBhc3RlTGlzdGVuZXJzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVVJID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuYWJsZUFsbCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlQWxsID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEVkaXRvclRvTGF5ZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfaXNFbXB0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RFZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb250YWluZXIsIGV2ZW50QnVzLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3NlbGVjdEVkaXRvcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzRW1wdHkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEVkaXRvclRvTGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Rpc2FibGVBbGwpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2VuYWJsZUFsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYWRkQ29weVBhc3RlTGlzdGVuZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEtleWJvYXJkTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY3RpdmVFZGl0b3IsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxMYXllcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Fubm90YXRpb25TdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY29tbWFuZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBDb21tYW5kTWFuYWdlcigpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY3VycmVudFBhZ2VJbmRleCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvclR5cGVzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZWRpdG9yc1RvUmVzY2FsZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IFNldCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZXZlbnRCdXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBJZE1hbmFnZXIoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzRW5hYmxlZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgU2V0KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENvcHksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY29weS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDdXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY3V0LmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBhc3RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLnBhc3RlLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEtleWRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMua2V5ZG93bi5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRPbkVkaXRpbmdBY3Rpb24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMub25FZGl0aW5nQWN0aW9uLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uUGFnZUNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUGFnZUNoYW5naW5nLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uU2NhbGVDaGFuZ2luZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5vblNjYWxlQ2hhbmdpbmcuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kT25Sb3RhdGlvbkNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUm90YXRpb25DaGFuZ2luZy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcHJldmlvdXNTdGF0ZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbnRhaW5lciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250YWluZXIsIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZXZlbnRCdXMsIGV2ZW50QnVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29uKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInBhZ2VjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblBhZ2VDaGFuZ2luZykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInNjYWxlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25TY2FsZUNoYW5naW5nKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLl9vbigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSwgYW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdQYXJhbWV0ZXJzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlOiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogMAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJwYWdlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25QYWdlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigic2NhbGVjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblNjYWxlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnNUb1Jlc2NhbGUpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25QYWdlQ2hhbmdpbmcoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VOdW1iZXIKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgsIHBhZ2VOdW1iZXIgLSAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNNYWluQ29udGFpbmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRhaW5lcikuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5hZGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yZWFsU2NhbGUgPSBzY2FsZSAqIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2guUERGX1RPX0NTU19VTklUUzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uU2NhbGVDaGFuZ2luZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uUm90YXRpb25DaGFuZ2luZyhfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXNSb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yb3RhdGlvbiA9IHBhZ2VzUm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yLmlzRW1wdHkoKSAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Fubm90YXRpb25TdG9yYWdlKSAmJiAhX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSkuaGFzKGVkaXRvci5pZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpLnNldFZhbHVlKGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb3B5KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKS5jb21taXRPclJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5oYXNTZWxlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvci5zZXJpYWxpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcnMubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuY2xpcGJvYXJkRGF0YS5zZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIsIEpTT04uc3RyaW5naWZ5KGVkaXRvcnMpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3V0KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29weShldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhc3RlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gZXZlbnQuY2xpcGJvYXJkRGF0YS5nZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IEpTT04ucGFyc2UoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGRhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdEFsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsTGF5ZXJzKS5nZXQoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jdXJyZW50UGFnZUluZGV4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdFZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVzZXJpYWxpemVkRWRpdG9yID0gbGF5ZXIuZGVzZXJpYWxpemUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRlc2VyaWFsaXplZEVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0VkaXRvcnMucHVzaChkZXNlcmlhbGl6ZWRFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWRkRWRpdG9yVG9MYXllciwgX2FkZEVkaXRvclRvTGF5ZXIyKS5jYWxsKHRoaXMsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlbGVjdEVkaXRvcnMsIF9zZWxlY3RFZGl0b3JzMikuY2FsbCh0aGlzLCBuZXdFZGl0b3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAga2V5ZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2V0QWN0aXZlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgoX3RoaXMkZ2V0QWN0aXZlID0gdGhpcy5nZXRBY3RpdmUoKSkgIT09IG51bGwgJiYgX3RoaXMkZ2V0QWN0aXZlICE9PSB2b2lkIDAgJiYgX3RoaXMkZ2V0QWN0aXZlLnNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25FZGl0aW5nQWN0aW9uKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFsidW5kbyIsICJyZWRvIiwgImRlbGV0ZSIsICJzZWxlY3RBbGwiXS5pbmNsdWRlcyhkZXRhaWxzLm5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2RldGFpbHMubmFtZV0oKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRFZGl0aW5nU3RhdGUoaXNFZGl0aW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FkZEtleWJvYXJkTWFuYWdlciwgX2FkZEtleWJvYXJkTWFuYWdlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRWRpdGluZzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSAhPT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1VuZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmhhc1NvbWV0aGluZ1RvUmVkbygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZWdpc3RlckVkaXRvclR5cGVzKHR5cGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvclR5cGVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZWRpdG9yVHlwZXMsIHR5cGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3JUeXBlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yVHlwZS5kZWZhdWx0UHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaWRNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY3VycmVudExheWVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLmdldChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRQYWdlSW5kZXgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuc2V0KGxheWVyLnBhZ2VJbmRleCwgbGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRpc2FibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmVMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZGVsZXRlKGxheWVyLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZU1vZGUobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGUsIG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzYWJsZUFsbCwgX2Rpc2FibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9lbmFibGVBbGwsIF9lbmFibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci51cGRhdGVNb2RlKG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVRvb2xiYXIobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJzd2l0Y2hhbm5vdGF0aW9uZWRpdG9ybW9kZSIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhcmFtcyh0eXBlLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvclR5cGUgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JUeXBlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvclR5cGUudXBkYXRlRGVmYXVsdFBhcmFtcyh0eXBlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RWRpdG9ycyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9ycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbEVkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLnBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVkaXRvcnM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEVkaXRvcihpZCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5nZXQoaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykuc2V0KGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5kZWxldGUoZWRpdG9yLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQyLnJlbW92ZShlZGl0b3IuaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBY3RpdmVFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikgPT09IGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yLnByb3BlcnRpZXNUb1VwZGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9nZ2xlU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuaGFzKGVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlVUksIF9kaXNwYXRjaFVwZGF0ZVVJMikuY2FsbCh0aGlzLCBlZGl0b3IucHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFNlbGVjdGVkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkICE9PSBlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZC51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZWxlY3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSwgX2Rpc3BhdGNoVXBkYXRlVUkyKS5jYWxsKHRoaXMsIGVkaXRvci5wcm9wZXJ0aWVzVG9VcGRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5oYXMoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdW5zZWxlY3QoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuZGVsZXRlKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhhc1NlbGVjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5zaXplICE9PSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS51bmRvKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NvbWV0aGluZ1RvVW5kbzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb21tYW5kTWFuYWdlcikuaGFzU29tZXRoaW5nVG9VbmRvKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLnJlZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9SZWRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1JlZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzRW1wdHksIF9pc0VtcHR5MikuY2FsbCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWFuZHMocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmFkZChwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1VuZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eTogX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfaXNFbXB0eSwgX2lzRW1wdHkyKS5jYWxsKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZWxldGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmhhc1NlbGVjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvcnMgPSBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIGVkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRFZGl0b3JUb0xheWVyLCBfYWRkRWRpdG9yVG9MYXllcjIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdE9yUmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZWxlY3RFZGl0b3JzLCBfc2VsZWN0RWRpdG9yczIpLmNhbGwodGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS52YWx1ZXMoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLnNpemUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpID09PSBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFjdGl2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyID0gQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlcjsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5yZW1vdmVFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKCkgewogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNvcHkiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ29weSkpOwogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoImN1dCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0a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B7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJhbm5vdGF0aW9uZWRpdG9yc3RhdGVzY2hhbmdlZCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHM6IE9iamVjdC5hc3NpZ24oX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wcmV2aW91c1N0YXRlcyksIGRldGFpbHMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kaXNwYXRjaFVwZGF0ZVVJMihkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuZGlzcGF0Y2goImFubm90YXRpb25lZGl0b3JwYXJhbXNjaGFuZ2VkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHMKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmFibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmVuYWJsZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Rpc2FibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIHRoaXMudW5zZWxlY3RBbGwoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGF5ZXIgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5kaXNhYmxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfYWRkRWRpdG9yVG9MYXllcjIoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZ2V0KGVkaXRvci5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBsYXllci5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9pc0VtcHR5MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3IuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZWxlY3RFZGl0b3JzMihlZGl0b3JzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICA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ICAgICBleHBvcnRzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlID0gZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2U7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldEZpbGVuYW1lRnJvbVVybCA9IGdldEZpbGVuYW1lRnJvbVVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0UGRmRmlsZW5hbWVGcm9tVXJsID0gZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOwogICAgICAgICAgICAgICAgZXhwb3J0cy5nZXRSR0IgPSBnZXRSR0I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFhmYVBhZ2VWaWV3cG9ydCA9IGdldFhmYVBhZ2VWaWV3cG9ydDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuaXNEYXRhU2NoZW1lID0gaXNEYXRhU2NoZW1lOwogICAgICAgICAgICAgICAgZXhwb3J0cy5pc1BkZkZpbGUgPSBpc1BkZkZpbGU7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzVmFsaWRGZXRjaFVybCA9IGlzVmFsaWRGZXRjaFVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMubG9hZFNjcmlwdCA9IGxvYWRTY3JpcHQ7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldExheWVyRGltZW5zaW9ucyA9IHNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgIC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SBkZXNjcmlwdG9yLnZhbHVlID0gdmFsdWU7IH0gfQogICAgICAgICAgICAgICAgY29uc3QgU1ZHX05TID0gImh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIjsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25QcmVmaXggPSAicGRmanNfaW50ZXJuYWxfaWRfIjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblByZWZpeCA9IEFubm90YXRpb25QcmVmaXg7CiAgICAgICAgICAgICAgICBjbGFzcyBQaXhlbHNQZXJJbmNoIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgQ1NTID0gOTYuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGID0gNzIuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGX1RPX0NTU19VTklUUyA9IHRoaXMuQ1NTIC8gdGhpcy5QREY7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBpeGVsc1BlckluY2ggPSBQaXhlbHNQZXJJbmNoOwogICAgICAgICAgICAgICAgdmFyIF9jYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY0lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hjbUZpbHRlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oY21LZXkgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfaGNtVXJsID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hcHBlbmRGZUZ1bmMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIERPTUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudCA9IGdsb2JhbFRoaXMuZG9jdW1lbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYXBwZW5kRmVGdW5jKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2RlZnMyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfZGVmcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGUyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfY2FjaGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQ6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kZWZzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kb2NJZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZG9jdW1lbnQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hjbUZpbHRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGNtS2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9oY21VcmwsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RvY0lkLCBkb2NJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZG9jdW1lbnQsIG93bmVyRG9jdW1lbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRGaWx0ZXIobWFwcykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkaWQsIF90aGlzJGlkMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQobWFwcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWJsZVIsIHRhYmxlRywgdGFibGVCLCBrZXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXBzLmxlbmd0aCA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwUiA9IG1hcHNbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJbaV0gPSBtYXBSW2ldIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0gdGFibGVSID0gdGFibGVHID0gdGFibGVCID0gYnVmZmVyLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFttYXBSLCBtYXBHLCBtYXBCXSA9IG1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJSID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJHID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJCID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyUltpXSA9IG1hcFJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyR1tpXSA9IG1hcEdbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyQltpXSA9IG1hcEJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWJsZVIgPSBidWZmZXJSLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhYmxlRyA9IGJ1ZmZlckcuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFibGVCID0gYnVmZmVyQi5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXkgPSBgJHt0YWJsZVJ9JHt0YWJsZUd9JHt0YWJsZUJ9YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBnXyR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2NJZCl9X3RyYW5zZmVyX21hcF8keyhfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lkLCAoX3RoaXMkaWQgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2lkKSwgX3RoaXMkaWQyID0gX3RoaXMkaWQrKywgX3RoaXMkaWQpKSwgX3RoaXMkaWQyKX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKCMke2lkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5zZXQoa2V5LCB1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWx0ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLnNldEF0dHJpYnV0ZSgiaWQiLCBpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycyIsICJzUkdCIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZlQ29tcG9uZW50VHJhbnNmZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb21wb25lbnRUcmFuc2ZlciIpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuYXBwZW5kKGZlQ29tcG9uZW50VHJhbnNmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgdGFibGVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYXBwZW5kRmVGdW5jLCBfYXBwZW5kRmVGdW5jMikuY2FsbCh0aGlzLCBmZUNvbXBvbmVudFRyYW5zZmVyLCAiZmVGdW5jRyIsIHRhYmxlRyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZUIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkSENNRmlsdGVyKGZnQ29sb3IsIGJnQ29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGAke2ZnQ29sb3J9LSR7YmdDb2xvcn1gOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21LZXkpID09PSBrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hjbVVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21LZXksIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtVXJsLCAibm9uZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtRmlsdGVyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0Mi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmZ0NvbG9yIHx8ICFiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpLnN0eWxlLmNvbG9yID0gZmdDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgZmdDb2xvciA9IGdldENvbXB1dGVkU3R5bGUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikpLmdldFByb3BlcnR5VmFsdWUoImNvbG9yIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZnUkdCID0gZ2V0UkdCKGZnQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZmdSR0IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5zdHlsZS5jb2xvciA9IGJnQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGJnQ29sb3IgPSBnZXRDb21wdXRlZFN0eWxlKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpKS5nZXRQcm9wZXJ0eVZhbHVlKCJjb2xvciIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiZ1JHQiA9IGdldFJHQihiZ0NvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmJnUkdCKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikuc3R5bGUuY29sb3IgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZnQ29sb3IgPT09ICIjMDAwMDAwIiAmJiBiZ0NvbG9yID09PSAiI2ZmZmZmZiIgfHwgZmdDb2xvciA9PT0gYmdDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPD0gMjU1OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBpIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwW2ldID0geCA8PSAwLjAzOTI4ID8geCAvIDEyLjkyIDogKCh4ICsgMC4wNTUpIC8gMS4wNTUpICoqIDIuNDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IG1hcC5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gYGdfJHtfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY0lkKX1faGNtX2ZpbHRlcmA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlciA9IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtRmlsdGVyLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuc2V0QXR0cmlidXRlKCJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnMiLCAic1JHQiIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY1IiLCB0YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0ciLCB0YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZlQ29sb3JNYXRyaXggPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb2xvck1hdHJpeCIpOwogICAgICAgICAgICAgICAgICAgICAgICBmZUNvbG9yTWF0cml4LnNldEF0dHJpYnV0ZSgidHlwZSIsICJtYXRyaXgiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmVDb2xvck1hdHJpeC5zZXRBdHRyaWJ1dGUoInZhbHVlcyIsICIwLjIxMjYgMC43MTUyIDAuMDcyMiAwIDAgMC4yMTI2IDAuNzE1MiAwLjA3MjIgMCAwIDAuMjEyNiAwLjcxNTIgMC4wNzIyIDAgMCAwIDAgMCAxIDAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLmFwcGVuZChmZUNvbG9yTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFN0ZXBzID0gKGMsIG4pID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXJ0ID0gZmdSR0JbY10gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBiZ1JHQltjXSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyciA9IG5ldyBBcnJheShuICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbaV0gPSBzdGFydCArIGkgLyBuICogKGVuZCAtIHN0YXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgZ2V0U3RlcHMoMCwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNHIiwgZ2V0U3RlcHMoMSwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNCIiwgZ2V0U3RlcHMoMiwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21VcmwsIGB1cmwoIyR7aWR9KWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQga2VlcEhDTSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZWVwSENNICYmIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpLnBhcmVudE5vZGUucGFyZW50Tm9kZS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVmcywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jYWNoZSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pZCwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01GaWx0ZXJGYWN0b3J5ID0gRE9NRmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9nZXRfY2FjaGUoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpIHx8IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2FjaGUsIG5ldyBNYXAoKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0X2RlZnMoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbnRhaW4gPSAic3RyaWN0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBzdHlsZS5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLnRvcCA9IHN0eWxlLmxlZnQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS56SW5kZXggPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgInN2ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kZWZzLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZGVmcyIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmcykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5ib2R5LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hcHBlbmRGZUZ1bmMyKGZlQ29tcG9uZW50VHJhbnNmZXIsIGZ1bmMsIHRhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmVGdW5jID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgZnVuYyk7CiAgICAgICAgICAgICAgICAgICAgZmVGdW5jLnNldEF0dHJpYnV0ZSgidHlwZSIsICJkaXNjcmV0ZSIpOwogICAgICAgICAgICAgICAgICAgIGZlRnVuYy5zZXRBdHRyaWJ1dGUoInRhYmxlVmFsdWVzIiwgdGFibGUpOwogICAgICAgICAgICAgICAgICAgIGZlQ29tcG9uZW50VHJhbnNmZXIuYXBwZW5kKGZlRnVuYyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DYW52YXNGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50ID0gZ2xvYmFsVGhpcy5kb2N1bWVudAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+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+IDAgJiYgbG9hZGluZ1JlcXVlc3RzWzBdLmRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdGhlclJlcXVlc3QgPSBsb2FkaW5nUmVxdWVzdHMuc2hpZnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KG90aGVyUmVxdWVzdC5jYWxsYmFjaywgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZTogY29tcGxldGVSZXF1ZXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgIC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FBQyIgKyAiQVFFQklWaFlXRmhZV0ZoWVdGaFlXRmhZV0ZoWVdGaFlXRmhZV0ZoWVdGaFlXRmhZQUFBQkFRQUFEd0FDQVFFRUUvdDMiICsgIkRvdjZmQUg2ZkFUK2ZQcDgrbndIRG9zTUN2bTFDdm0xREF6NmZCUUFBQUFBQUFBQkFBQUFBTW1KYnpFQUFBQUF6Z1RqIiArICJGUUFBQUFET0JPUXBBQUVBQUFBQUFBQUFEQUFVQUFRQUFBQUJBQUFBQWdBQkFBQUFBQUFBQUFBRDZBQUFBQUFBQUE9PSIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9sb2FkVGVzdEZvbnQiLCB0ZXN0Rm9udCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9wcmVwYXJlRm9udExvYWRFdmVudChmb250LCByZXF1ZXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGludDMyKGRhdGEsIG9mZnNldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuY2hhckNvZGVBdChvZmZzZXQpIDw8IDI0IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDEpIDw8IDE2IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDIpIDw8IDggfCBkYXRhLmNoYXJDb2RlQXQob2Zmc2V0ICsgMykgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHNwbGljZVN0cmluZyhzLCBvZmZzZXQsIHJlbW92ZSwgaW5zZXJ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuazEgPSBzLnN1YnN0cmluZygwLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsyID0gcy5zdWJzdHJpbmcob2Zmc2V0ICsgcmVtb3ZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjaHVuazEgKyBpbnNlcnQgKyBjaHVuazI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLndpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNGb250UmVhZHkobmFtZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgrK2NhbGxlZCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJMb2FkIHRlc3QgZm9udCBuZXZlciBsb2FkZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9ICIzMHB4ICIgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCIuIiwgMCwgMjApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1hZ2VEYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEuZGF0YVszXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoaXNGb250UmVhZHkuYmluZChudWxsLCBuYW1lLCBjYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvYWRUZXN0Rm9udElkID0gYGx0JHtEYXRlLm5vdygpfSR7dGhpcy5sb2FkVGVzdEZvbnRJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gdGhpcy5fbG9hZFRlc3RGb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDT01NRU5UX09GRlNFVCA9IDk3NjsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHNwbGljZVN0cmluZyhkYXRhLCBDT01NRU5UX09GRlNFVCwgbG9hZFRlc3RGb250SWQubGVuZ3RoLCBsb2FkVGVzdEZvbnRJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENGRl9DSEVDS1NVTV9PRkZTRVQgPSAxNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgWFhYWF9WQUxVRSA9IDB4NTg1ODU4NTg7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGVja3N1bSA9IGludDMyKGRhdGEsIENGRl9DSEVDS1NVTV9PRkZTRVQpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IGxvYWRUZXN0Rm9udElkLmxlbmd0aCAtIDM7IGkgPCBpaTsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja3N1bSA9IGNoZWNrc3VtIC0gWFhYWF9WQUxVRSArIGludDMyKGxvYWRUZXN0Rm9udElkLCBpKSB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCBsb2FkVGVzdEZvbnRJZC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrc3VtID0gY2hlY2tzdW0gLSBYWFhYX1ZBTFVFICsgaW50MzIobG9hZFRlc3RGb250SWQgKyAiWFhYIiwgaSkgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBzcGxpY2VTdHJpbmcoZGF0YSwgQ0ZGX0NIRUNLU1VNX09GRlNFVCwgNCwgKDAsIF91dGlsLnN0cmluZzMyKShjaGVja3N1bSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKGRhdGE6Zm9udC9vcGVudHlwZTtiYXNlNjQsJHtidG9hKGRhdGEpfSk7YDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGBAZm9udC1mYWNlIHtmb250LWZhbWlseToiJHtsb2FkVGVzdEZvbnRJZH0iO3NyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbnNlcnRSdWxlKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXYgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLndpZHRoID0gZGl2LnN0eWxlLmhlaWdodCA9ICIxMHB4IjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnBvc2l0aW9uID0gImFic29sdXRlIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnRvcCA9IGRpdi5zdHlsZS5sZWZ0ID0gIjBweCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBbZm9udC5sb2FkZWROYW1lLCBsb2FkVGVzdEZvbnRJZF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYW4gPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnRleHRDb250ZW50ID0gIkhpIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW4uc3R5bGUuZm9udEZhbWlseSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYuYXBwZW5kKHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmJvZHkuYXBwZW5kKGRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlzRm9udFJlYWR5KGxvYWRUZXN0Rm9udElkLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmNvbXBsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IEZvbnRMb2FkZXI7CiAgICAgICAgICAgICAgICBjbGFzcyBGb250RmFjZU9iamVjdCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IodHJhbnNsYXRlZERhdGEsIF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQgPSB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnMgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluc3BlY3RGb250ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGkgaW4gdHJhbnNsYXRlZERhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbaV0gPSB0cmFuc2xhdGVkRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRXZhbFN1cHBvcnRlZCA9IGlzRXZhbFN1cHBvcnRlZCAhPT0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUZvbnRGYWNlID0gZGlzYWJsZUZvbnRGYWNlID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlnbm9yZUVycm9ycyA9IGlnbm9yZUVycm9ycyA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5zcGVjdEZvbnQgPSBpbnNwZWN0Rm9udDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlTmF0aXZlRm9udEZhY2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfaW5zcGVjdEZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhIHx8IHRoaXMuZGlzYWJsZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0aXZlRm9udEZhY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jc3NGb250SW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0aXZlRm9udEZhY2UgPSBuZXcgRm9udEZhY2UodGhpcy5sb2FkZWROYW1lLCB0aGlzLmRhdGEsIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNzcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWlnaHQ6IHRoaXMuY3NzRm9udEluZm8uZm9udFdlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzLnN0eWxlID0gYG9ibGlxdWUgJHt0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlfWRlZ2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVGb250RmFjZSA9IG5ldyBGb250RmFjZSh0aGlzLmNzc0ZvbnRJbmZvLmZvbnRGYW1pbHksIHRoaXMuZGF0YSwgY3NzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250ID0gdGhpcy5faW5zcGVjdEZvbnQpID09PSBudWxsIHx8IF90aGlzJF9pbnNwZWN0Rm9udCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2luc3BlY3RGb250LmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYXRpdmVGb250RmFjZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlRm9udEZhY2VSdWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2luc3BlY3RGb250MjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEgfHwgdGhpcy5kaXNhYmxlRm9udEZhY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSAoMCwgX3V0aWwuYnl0ZXNUb1N0cmluZykodGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gYHVybChkYXRhOiR7dGhpcy5taW1ldHlwZX07YmFzZTY0LCR7YnRvYShkYXRhKX0pO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzRm9udEluZm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBgQGZvbnQtZmFjZSB7Zm9udC1mYW1pbHk6IiR7dGhpcy5sb2FkZWROYW1lfSI7c3JjOiR7dXJsfX1gOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNzcyA9IGBmb250LXdlaWdodDogJHt0aGlzLmNzc0ZvbnRJbmZvLmZvbnRXZWlnaHR9O2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jc3NGb250SW5mby5pdGFsaWNBbmdsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzcyArPSBgZm9udC1zdHlsZTogb2JsaXF1ZSAke3RoaXMuY3NzRm9udEluZm8uaXRhbGljQW5nbGV9ZGVnO2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYEBmb250LWZhY2Uge2ZvbnQtZmFtaWx5OiIke3RoaXMuY3NzRm9udEluZm8uZm9udEZhbWlseX0iOyR7Y3NzfXNyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250MiA9IHRoaXMuX2luc3BlY3RGb250KSA9PT0gbnVsbCB8fCBfdGhpcyRfaW5zcGVjdEZvbnQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfaW5zcGVjdEZvbnQyLmNhbGwodGhpcywgdGhpcywgdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdGhHZW5lcmF0b3Iob2JqcywgY2hhcmFjdGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbXBpbGVkR2x5cGhzW2NoYXJhY3Rlcl0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY21kczsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZHMgPSBvYmpzLmdldCh0aGlzLmxvYWRlZE5hbWUgKyAiX3BhdGhfIiArIGNoYXJhY3Rlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFBhdGhHZW5lcmF0b3IgLSBpZ25vcmluZyBjaGFyYWN0ZXI6ICIke2V4fSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gZnVuY3Rpb24gKGMsIHNpemUpIHt9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRXZhbFN1cHBvcnRlZCAmJiBfdXRpbC5GZWF0dXJlVGVzdC5pc0V2YWxTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGpzQnVmID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBjdXJyZW50LmFyZ3MgIT09IHVuZGVmaW5lZCA/IGN1cnJlbnQuYXJncy5qb2luKCIsIikgOiAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc0J1Zi5wdXNoKCJjLiIsIGN1cnJlbnQuY21kLCAiKCIsIGFyZ3MsICIpO1xuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gbmV3IEZ1bmN0aW9uKCJjIiwgInNpemUiLCBqc0J1Zi5qb2luKCIiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXSA9IGZ1bmN0aW9uIChjLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmNtZCA9PT0gInNjYWxlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmFyZ3MgPSBbc2l6ZSwgLXNpemVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjW2N1cnJlbnQuY21kXS5hcHBseShjLCBjdXJyZW50LmFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSBGb250RmFjZU9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ2ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQ2FudmFzR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgdmFyIF9wYXR0ZXJuX2hlbHBlciA9IF9fd19wZGZq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RJT05fVElNRSA9IDE1OwogICAgICAgICAgICAgICAgY29uc3QgRVhFQ1VUSU9OX1NURVBTID0gMTA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfU0laRV9UT19DT01QSUxFID0gMTAwMDsKICAgICAgICAgICAgICAgIGNvbnN0IEZVTExfQ0hVTktfSEVJR0hUID0gMTY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIGRlc3RDdHgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY3R4Ll9yZW1vdmVNaXJyb3JpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDb250ZXh0IGlzIGFscmVhZHkgZm9yd2FyZGluZyBvcGVyYXRpb25zLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFNhdmUgPSBjdHguc2F2ZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc3RvcmUgPSBjdHgucmVzdG9yZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJvdGF0ZSA9IGN0eC5yb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxTY2FsZSA9IGN0eC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZSA9IGN0eC50cmFuc2xhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxUcmFuc2Zvcm0gPSBjdHgudHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsU2V0VHJhbnNmb3JtID0gY3R4LnNldFRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtID0gY3R4LnJlc2V0VHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQ2xpcCA9IGN0eC5jbGlwOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsTW92ZVRvID0gY3R4Lm1vdmVUbzsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbExpbmVUbyA9IGN0eC5saW5lVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvID0gY3R4LmJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxSZWN0ID0gY3R4LnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGggPSBjdHguY2xvc2VQYXRoOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQmVnaW5QYXRoID0gY3R4LmJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICBjdHguX3JlbW92ZU1pcnJvcmluZyA9ICgpID0+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/IGN1cnJlbnRUcmFuc2Zvcm0gOiBbY3VycmVudFRyYW5zZm9ybS5zbGljZSgwLCA0KSwgZmlsbENvbG9yXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZSA9IHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuZ2V0KG1haW5LZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWNoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuc2V0KG1haW5LZXksIGNhY2hlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhY2hlZEltYWdlID0gY2FjaGUuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRJbWFnZSAmJiAhaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLnJvdW5kKE1hdGgubWluKGN1cnJlbnRUcmFuc2Zvcm1bMF0sIGN1cnJlbnRUcmFuc2Zvcm1bMl0pICsgY3VycmVudFRyYW5zZm9ybVs0XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgucm91bmQoTWF0aC5taW4oY3VycmVudFRyYW5zZm9ybVsxXSwgY3VycmVudFRyYW5zZm9ybVszXSkgKyBjdXJyZW50VHJhbnNmb3JtWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXM6IGNhY2hlZEltYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IGNhY2hlZEltYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoIm1hc2tDYW52YXMiLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlTWFzayhtYXNrQ2FudmFzLmNvbnRleHQsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGN1cnJlbnRUcmFuc2Zvcm0sIFsxIC8gd2lkdGgsIDAsIDAsIC0xIC8gaGVpZ2h0LCAwLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hc2tUb0NhbnZhcywgWzEsIDAsIDAsIDEsIDAsIC1oZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDEgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgaGVpZ2h0XSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbY29yZDFbMF0sIGNvcmQxWzFdLCBjb3JkMlswXSwgY29yZDJbMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IE1hdGgucm91bmQocmVjdFsyXSAtIHJlY3RbMF0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRyYXduSGVpZ2h0ID0gTWF0aC5yb3VuZChyZWN0WzNdIC0gcmVjdFsxXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJmaWxsQ2FudmFzIiwgZHJhd25XaWR0aCwgZHJhd25IZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ3R4ID0gZmlsbENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvZmZzZXRYID0gTWF0aC5taW4oY29yZDFbMF0sIGNvcmQyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgubWluKGNvcmQxWzFdLCBjb3JkMlsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNmb3JtKC4uLm1hc2tUb0NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWQgPSB0aGlzLl9zY2FsZUltYWdlKG1hc2tDYW52YXMuY2FudmFzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IHNjYWxlZC5pbWc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLnNldChjYWNoZUtleSwgc2NhbGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoZmlsbEN0eCksIGltZy5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhmaWxsQ3R4LCBzY2FsZWQsIDAsIDAsIHNjYWxlZC53aWR0aCwgc2NhbGVkLmhlaWdodCwgMCwgMCwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1pbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludmVyc2UgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybSgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpLCBbMSwgMCwgMCwgMSwgLW9mZnNldFgsIC1vZmZzZXRZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZmlsbFN0eWxlID0gaXNQYXR0ZXJuRmlsbCA/IGZpbGxDb2xvci5nZXRQYXR0ZXJuKGN0eCwgdGhpcywgaW52ZXJzZSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpIDogZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgIWlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkQ2FudmFzZXMuZGVsZXRlKCJmaWxsQ2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZS5zZXQoY2FjaGVLZXksIGZpbGxDYW52YXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBmaWxsQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IE1hdGgucm91bmQob2Zmc2V0WCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBNYXRoLnJvdW5kKG9mZnNldFkpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggIT09IHRoaXMuY3VycmVudC5saW5lV2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZVdpZHRoID0gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXAoc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVKb2luKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmxpbmVKb2luID0gTElORV9KT0lOX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubWl0ZXJMaW1pdCA9IGxpbWl0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREYXNoKGRhc2hBcnJheSwgZGFzaFBoYXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3R4LnNldExpbmVEYXNoICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChkYXNoQXJyYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaFBoYXNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudChpbnRlbnQpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0RmxhdG5lc3MoZmxhdG5lc3MpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBzdGF0ZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lQ2FwKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVKb2luKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldE1pdGVyTGltaXQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRSZW5kZXJpbmdJbnRlbnQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmxhdG5lc3ModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkNBIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUFscGhhID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5nbG9iYWxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJCTSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJTTWFzayI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayA9IHZhbHVlID8gdGhpcy50ZW1wU01hc2sgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRlbXBTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tTTWFza1N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlRSIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gdGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9IHRoaXMuZmlsdGVyRmFjdG9yeS5hZGRGaWx0ZXIodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaW5TTWFza01vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIXRoaXMuc3VzcGVuZGVkQ3R4OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjaGVja1NNYXNrU3RhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluU01hc2tNb2RlID0gdGhpcy5pblNNYXNrTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayAmJiAhaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmVnaW5TTWFza01vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5jdXJyZW50LmFjdGl2ZVNNYXNrICYmIGluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFNNYXNrTW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pblNNYXNrTW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJiZWdpblNNYXNrTW9kZSBjYWxsZWQgd2hpbGUgYWxyZWFkeSBpbiBzbWFzayBtb2RlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25IZWlnaHQgPSB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZUlkID0gInNtYXNrR3JvdXBBdCIgKyB0aGlzLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldFRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5zdXNwZW5kZWRDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuc3VzcGVuZGVkQ3R4LCBjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIHRoaXMuc3VzcGVuZGVkQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZW5kU01hc2tNb2RlIGNhbGxlZCB3aGlsZSBub3QgaW4gc21hc2sgbW9kZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Ll9yZW1vdmVNaXJyb3JpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuY3R4LCB0aGlzLnN1c3BlbmRlZEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tcG9zZShkaXJ0eUJveCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3VycmVudC5hY3RpdmVTTWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZGlydHlCb3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94ID0gWzAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJ0eUJveFswXSA9IE1hdGguZmxvb3IoZGlydHlCb3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlydHlCb3hbMV0gPSBNYXRoLmZsb29yKGRpcnR5Qm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzJdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzNdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzbWFzayA9IHRoaXMuY3VycmVudC5hY3RpdmVTTWFzazsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3VzcGVuZGVkQ3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFzayhzdXNwZW5kZWRDdHgsIHNtYXNrLCB0aGlzLmN0eCwgZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xlYXJSZWN0KDAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2F2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLmN0eCwgdGhpcy5zdXNwZW5kZWRDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9sZCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGF0ZVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gb2xkLmNsb25lKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoID09PSAwICYmIHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhdGVTdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLnN1c3BlbmRlZEN0eCwgdGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoZWNrU01hc2tTdGF0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RQYXRoKG9wcywgYXJncywgbWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBjdXJyZW50Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdGFydFgsIHN0YXJ0WTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NjYWxpbmdNYXRyaXggPSBjdXJyZW50VHJhbnNmb3JtWzBdID09PSAwICYmIGN1cnJlbnRUcmFuc2Zvcm1bM10gPT09IDAgfHwgY3VycmVudFRyYW5zZm9ybVsxXSA9PT0gMCAmJiBjdXJyZW50VHJhbnNmb3JtWzJdID09PSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtaW5NYXhGb3JCZXppZXIgPSBpc1NjYWxpbmdNYXRyaXggPyBtaW5NYXguc2xpY2UoMCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gb3BzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BzW2ldIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHcgPSB4ICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHloID0geSArIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID09PSAwIHx8IGhlaWdodCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeWgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHh3LCB5aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHgsIHloKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU2NhbGluZ01hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVSZWN0TWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIFt4LCB5LCB4dywgeWhdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1NjYWxpbmdNYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5saW5lVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCBhcmdzW2ogKyAyXSwgYXJnc1tqICsgM10sIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZUN1cnZlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCBzdGFydFgsIHN0YXJ0WSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSwgeCwgeSwgbWluTWF4Rm9yQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8oeCwgeSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlQ3VydmVQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIHN0YXJ0WCwgc3RhcnRZLCB4LCB5LCBhcmdzW2pdLCBhcmdzW2ogKyAxXSwgYXJnc1tqICsgMl0sIGFyZ3NbaiArIDNdLCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2ogKyAzXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgM107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVDdXJ2ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgc3RhcnRYLCBzdGFydFksIGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5LCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVNjYWxpbmdQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIG1pbk1heEZvckJlemllcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5zZXRDdXJyZW50UG9pbnQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnN1bWVQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+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/IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKSh0aGlzLiNtZXRhZGF0YU1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNtZXRhZGF0YU1hcC5oYXMobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IE1ldGFkYXRhOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTIgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5PcHRpb25hbENvbnRlbnRDb25maWcgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJ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mFsdWUpOyB9IGVsc2UgeyBpZiAoIWRlc2NyaXB0b3Iud3JpdGFibGUpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIHNldCByZWFkIG9ubHkgcHJpdmF0ZSBmaWVsZCIpOyB9IGRlc2NyaXB0b3IudmFsdWUgPSB2YWx1ZTsgfSB9CiAgICAgICAgICAgICAgICBjb25zdCBJTlRFUk5BTCA9IFN5bWJvbCgiSU5URVJOQUwiKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudEdyb3VwIHsKICAgICAgICAgICAgICAgICAgICAjdmlzaWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobmFtZSwgaW50ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaW50ZW50ID0gaW50ZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgdmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3Zpc2libGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRWaXNpYmxlKGludGVybmFsLCB2aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcm5hbCAhPT0gSU5URVJOQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkludGVybmFsIG1ldGhvZCBgX3NldFZpc2libGVgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiN2aXNpYmxlID0gdmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlZEdldEhhc2ggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfZ3JvdXBzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2luaXRpYWxIYXNoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX29yZGVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudENvbmZpZyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGVkR2V0SGFzaCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2dyb3VwcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaW5pdGlhbEhhc2gsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9vcmRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5uYW1lID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jcmVhdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBkYXRhLm5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3JlYXRvciA9IGRhdGEuY3JlYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9vcmRlciwgZGF0YS5vcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZ3JvdXAgb2YgZGF0YS5ncm91cHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zZXQoZ3JvdXAuaWQsIG5ldyBPcHRpb25hbENvbnRlbnRHcm91cChncm91cC5uYW1lLCBncm91cC5pbnRlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5iYXNlU3RhdGUgPT09ICJPRkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdyb3VwIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwLl9zZXRWaXNpYmxlKElOVEVSTkFMLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvbiBvZiBkYXRhLm9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KG9uKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvZmYgb2YgZGF0YS5vZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQob2ZmKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaW5pdGlhbEhhc2gsIHRoaXMuZ2V0SGFzaCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlKGdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3Vwcykuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBkZWZpbmVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ0ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoZ3JvdXAuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtncm91cC5pZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGdyb3VwLmlkKS52aXNpYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ01EIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmV4cHJlc3Npb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZXZhbHVhdGVWaXNpYmlsaXR5RXhwcmVzc2lvbiwgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKS5jYWxsKHRoaXMsIGdyb3VwLmV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5wb2xpY3kgfHwgZ3JvdXAucG9saWN5ID09PSAiQW55T24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpZCBvZiBncm91cC5pZHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtpZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGlkKS52aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnBvbGljeSA9PT0gIkFsbE9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQW55T2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQWxsT2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmdldChpZCkudmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG9wdGlvbmFsIGNvbnRlbnQgcG9saWN5ICR7Z3JvdXAucG9saWN5fS5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBncm91cCB0eXBlICR7Z3JvdXAudHlwZX0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWaXNpYmlsaXR5KGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2aXNpYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9wdGlvbmFsIGNvbnRlbnQgZ3JvdXAgbm90IGZvdW5kOiAke2lkfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLl9zZXRWaXNpYmxlKElOVEVSTkFMLCAhIXZpc2libGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGFzSW5pdGlhbFZpc2liaWxpdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldEhhc2goKSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pbml0aWFsSGFzaCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9yZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vcmRlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29yZGVyKS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmtleXMoKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEdyb3VwcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplID4gMCA/ICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKShfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0R3JvdXAoaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEhhc2goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlZEdldEhhc2gpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jYWNoZWRHZXRIYXNoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNoID0gbmV3IF9tdXJtdXJoYXNoLk11cm11ckhhc2gzXzY0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2lkLCBncm91cF0gb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNoLnVwZGF0ZShgJHtpZH06JHtncm91cC52aXNpYmxlfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIGhhc2guaGV4ZGlnZXN0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuT3B0aW9uYWxDb250ZW50Q29uZmlnID0gT3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKGFycmF5KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvciA9IGFycmF5WzBdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24sIF9ldmFsdWF0ZVZpc2liaWxpdHlFeHByZXNzaW9uMikuY2FsbCh0aGlzLCBlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoZWxlbWVudCkudmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7ZWxlbWVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkFuZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiT3IiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJOb3QiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBvcGVyYXRvciA9PT0gIkFuZCI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZiwgcGRmRGF0YVJhbmdlVHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzaXZlRG9uZSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHBkZkRhdGFSYW5nZVRyYW5zcG9ydCwgJ1BERkRhdGFUcmFuc3BvcnRTdHJlYW0gLSBtaXNzaW5nIHJlcXVpcmVkICJwZGZEYXRhUmFuZ2VUcmFuc3BvcnQiIGFyZ3VtZW50LicpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lID0gcHJvZ3Jlc3NpdmVEb25lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGluaXRpYWxEYXRhID09PSBudWxsIHx8IGluaXRpYWxEYXRhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBpbml0aWFsRGF0YS5sZW5ndGgpID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyID0gaW5pdGlhbERhdGEgaW5zdGFuY2VvZiBVaW50OEFycmF5ICYmIGluaXRpYWxEYXRhLmJ5dGVMZW5ndGggPT09IGluaXRpYWxEYXRhLmJ1ZmZlci5ieXRlTGVuZ3RoID8gaW5pdGlhbERhdGEuYnVmZmVyIDogbmV3IFVpbnQ4QXJyYXkoaW5pdGlhbERhdGEpLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcy5wdXNoKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0ID0gcGRmRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFkaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gIWRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFJhbmdlTGlzdGVuZXIoKGJlZ2luLCBjaHVuaykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzTGlzdGVuZXIoKGxvYWRlZCwgdG90YWwpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3MoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIoY2h1bmsgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzaXZlRG9uZUxpc3RlbmVyKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQudHJhbnNwb3J0UmVhZHkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUmVjZWl2ZURhdGEoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBjaHVuayBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgY2h1bmsuYnl0ZUxlbmd0aCA9PT0gY2h1bmsuYnVmZmVyLmJ5dGVMZW5ndGggPyBjaHVuay5idWZmZXIgOiBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmVnaW4gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIuX2VucXVldWUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvdW5kID0gdGhpcy5fcmFuZ2VSZWFkZXJzLnNvbWUoZnVuY3Rpb24gKHJhbmdlUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJhbmdlUmVhZGVyLl9iZWdpbiAhPT0gYmVnaW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZVJlYWRlci5fZW5xdWV1ZShidWZmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShmb3VuZCwgIl9vblJlY2VpdmVEYXRhIC0gbm8gYFBERkRhdGFUcmFuc3BvcnRTdHJlYW1SYW5nZVJlYWRlcmAgaW5zdGFuY2UgZm91bmQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2dC50b3RhbCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JhbmdlUmVhZGVycyQsIF90aGlzJF9yYW5nZVJlYWRlcnMkJDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmFuZ2VSZWFkZXJzJCA9IHRoaXMuX3JhbmdlUmVhZGVyc1swXSkgPT09IG51bGwgfHwgX3RoaXMkX3JhbmdlUmVhZGVycyQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPSBfdGhpcyRfcmFuZ2VSZWFkZXJzJC5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yYW5nZVJlYWRlcnMkJC5jYWxsKF90aGlzJF9yYW5nZVJlYWRlcnMkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPSBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMuY2FsbChfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vblByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWE0ID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQucHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW1vdmVSYW5nZVJlYWRlcihyZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IHRoaXMuX3JhbmdlUmVhZGVycy5pbmRleE9mKHJlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGRGF0YVRyYW5zcG9ydFN0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxdWV1ZWRDaHVua3MgPSB0aGlzLl9xdWV1ZWRDaHVua3M7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlcih0aGlzLCBxdWV1ZWRDaHVua3MsIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSwgdGhpcy5fY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmQgPD0gdGhpcy5fcHJvZ3Jlc3NpdmVEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhNSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1LmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSBQREZEYXRhVHJhbnNwb3J0U3RyZWFtOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtLCBxdWV1ZWRDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzaXZlRG9uZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gcHJvZ3Jlc3NpdmVEb25lIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfZGlzcGxheV91dGlscy5pc1BkZkZpbGUpKGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lKSA/IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzID0gcXVldWVkQ2h1bmtzIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNodW5rIG9mIHRoaXMuX3F1ZXVlZENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlYWR5ID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbS5fZnVsbFJlcXVlc3RSZWFkZXIgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSBjaHVuay5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGVhZGVyc1JlYWR5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faGVhZGVyc1JlYWR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUmFuZ2VTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHJlYW0uX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N0cmVhbS5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc3RyZWFtLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc2l2ZURvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0sIGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iZWdpbiA9IGJlZ2luOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbmQgPSBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0c0NhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdHNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbS5fcmVtb3ZlUmFuZ2VSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0uX3JlbW92ZVJhbmdlUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU0ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhVGV4dCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNsYXNzIFhmYVRleHQgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0ZXh0Q29udGVudCh4ZmEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3V0cHV0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fsayhub2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX25vZGUkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IG5vZGUubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYW1lID09PSAiI3RleHQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyID0gbm9kZS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVhmYVRleHQuc2hvdWxkQnVpbGRUZXh0KG5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlICE9PSBudWxsICYmIG5vZGUgIT09IHZvaWQgMCAmJiAoX25vZGUkYXR0cmlidXRlcyA9IG5vZGUuYXR0cmlidXRlcykgIT09IG51bGwgJiYgX25vZGUkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9ub2RlJGF0dHJpYnV0ZXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLmF0dHJpYnV0ZXMudGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGUudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0ciAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2Ygbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoY2hpbGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoeGZhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG91dHB1dDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNob3VsZEJ1aWxkVGV4dChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKG5hbWUgPT09ICJ0ZXh0YXJlYSIgfHwgbmFtZSA9PT0gImlucHV0IiB8fCBuYW1lID09PSAib3B0aW9uIiB8fCBuYW1lID09PSAic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5YZmFUZXh0ID0gWGZhVGV4dDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5Ob2RlRmlsdGVyRmFjdG9yeSA9IGV4cG9ydHMuTm9kZUNhbnZhc0ZhY3RvcnkgPSBleHBvcnRzLk5vZGVDTWFwUmVhZGVyRmFjdG9yeSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgZmV0Y2hEYXRhID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZnMucmVhZEZpbGUodXJsLCAoZXJyb3IsIGRhdGEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciB8fCAhZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRXJyb3IoZXJyb3IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5ldyBVaW50OEFycmF5KGRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHt9CiAgICAgICAgICAgICAgICBleHBvcnRzLk5vZGVGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlQ2FudmFzRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNhbnZhc0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDYW52YXMgPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIENhbnZhcy5jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ2FudmFzRmFjdG9yeSA9IE5vZGVDYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUNNYXBSZWFkZXJGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsLCBjb21wcmVzc2lvblR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpLnRoZW4oZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBEYXRhOiBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXByZXNzaW9uVHlwZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGh0dHAgPSByZXF1aXJlKCJodHRwIik7CiAgICAgICAgICAgICAgICBjb25zdCBodHRwcyA9IHJlcXVpcmUoImh0dHBzIik7CiAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSByZXF1aXJlKCJ1cmwiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVVcmlSZWdleCA9IC9eZmlsZTpcL1wvXC9bYS16QS1aXTpcLy87CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBwYXJzZVVybChzb3VyY2VVcmwpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJzZWRVcmwgPSB1cmwucGFyc2Uoc291cmNlVXJsKTsKICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VkVXJsLnByb3RvY29sID09PSAiZmlsZToiIHx8IHBhcnNlZFVybC5ob3N0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZWRVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgvXlthLXpdOlsvXFxdL2kudGVzdChzb3VyY2VVcmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwucGFyc2UoYGZpbGU6Ly8vJHtzb3VyY2VVcmx9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghcGFyc2VkVXJsLmhvc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VkVXJsLnByb3RvY29sID0gImZpbGU6IjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlZFVybDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNvdXJjZSA9IHNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChzb3VyY2UudXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0h0dHAgPSB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHA6IiB8fCB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNGc1VybCA9IHRoaXMudXJsLnByb3RvY29sID09PSAiZmlsZToiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmh0dHBIZWFkZXJzID0gdGhpcy5pc0h0dHAgJiYgc291cmNlLmh0dHBIZWFkZXJzIHx8IHt9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRGdWxsUmVhZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIsICJQREZOb2RlU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gdGhpcy5pc0ZzVXJsID8gbmV3IFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIodGhpcykgOiBuZXcgUERGTm9kZVN0cmVhbUZ1bGxSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmFuZ2VSZWFkZXIoc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5kIDw9IHRoaXMuX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLmlzRnNVcmwgPyBuZXcgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIodGhpcywgc3RhcnQsIGVuZCkgOiBuZXcgUERGTm9kZVN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmFuZ2VSZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmFuZ2VSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbEFsbFJlcXVlc3RzKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMi5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZWFkZXIgb2YgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zbGljZSgwKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gUERGTm9kZVN0cmVhbTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzb3VyY2UubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGFibGVTdHJlYW0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5fcmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zdG9yZWRFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdGhpcy5fc3RvcmVkRXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsgPSB0aGlzLl9yZWFkYWJsZVN0cmVhbS5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaHVuayA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MgPT09IHZvaWQgMCA/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+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvckxheWVyID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0MSk7CiAgICAgICAgICAgICAgICB2YXIgX2ZyZWV0ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjMpOwogICAgICAgICAgICAgICAgdmFyIF9pbm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ZU5ld0VkaXRvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQW5ub3RhdGlvbkVkaXRvckxheWVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihvcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY2xlYW51cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlQW5kQWRkTmV3RWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jcmVhdGVOZXdFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NoYW5nZVBhcmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYWxsb3dDbGljaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5wb2ludGVydXAuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kUG9pbnRlcmRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMucG9pbnRlcmRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hhZFBvaW50ZXJEb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzQ2xlYW5pbmdVcCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF91aU1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9mcmVldGV4dC5GcmVlVGV4dEVkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfaW5rLklua0VkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy51aU1hbmFnZXIucmVnaXN0ZXJFZGl0b3JUeXBlcyhbX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLCBfaW5rLklua0VkaXRvcl0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3VpTWFuYWdlciwgb3B0aW9ucy51aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2VJbmRleCA9IG9wdGlvbnMucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IG9wdGlvbnMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyLCBvcHRpb25zLmFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZExheWVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuc2l6ZSA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlVG9vbGJhcihtb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS51cGRhdGVUb29sYmFyKG1vZGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbW9kZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2xlYW51cCwgX2NsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0QWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RlICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJmcmVlVGV4dEVkaXRpbmciLCBtb2RlID09PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJpbmtFZGl0aW5nIiwgbW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZElua0VkaXRvcklmTmVlZGVkKGlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZyAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuZ2V0TW9kZSgpICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTkspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRJbkJhY2tncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRDb21tYW5kcyhwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZENvbW1hbmRzKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVuYWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUucG9pbnRlckV2ZW50cyA9ICJhdXRvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmVuYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5wb2ludGVyRXZlbnRzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGlzYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jbGVhbnVwLCBfY2xlYW51cDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0QWN0aXZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50QWN0aXZlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEFjdGl2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEFjdGl2ZSA9PT0gZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEFjdGl2ZUVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVDbGljaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcmRvd24iLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kUG9pbnRlcmRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcnVwIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ2xpY2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXR0YWNoKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnNldChlZGl0b3IuaWQsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldGFjaChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuZGVsZXRlKGVkaXRvci5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIChfY2xhc3NQcml2YXRlRmllbGRHZXQyID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIucmVtb3ZlUG9pbnRlckluVGV4dExheWVyKGVkaXRvci5jb250ZW50RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikucmVtb3ZlRWRpdG9yKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYuc3R5bGUuZGlzcGxheSA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGl2LnN0eWxlLmRpc3BsYXkgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaXNBdHRhY2hlZFRvRE9NID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jdW1lbnQuYWN0aXZlRWxlbWVudCA9PT0gZG9jdW1lbnQuYm9keSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5mb2N1c01haW5Db250YWluZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NsZWFuaW5nVXApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IGVkaXRvci5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmlzQXR0YWNoZWRUb0RPTSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uY2VBZGRlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZShlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlRWRpdG9ySW5ET00oZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQzOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MyA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWNjZXNzaWJpbGl0eU1hbmFnZXIpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQzLm1vdmVFbGVtZW50SW5ET00odGhpcy5kaXYsIGVkaXRvci5kaXYsIGVkaXRvci5jb250ZW50RGl2LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkT3JSZWJ1aWxkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLm5lZWRzVG9CZVJlYnVpbHQoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQU5ld0VkaXRvcihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFVuZG9hYmxlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbWQgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZE9yUmVidWlsZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE5leHRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXNlcmlhbGl6ZShkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5hbm5vdGF0aW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLmRlc2VyaWFsaXplKGRhdGEsIHRoaXMsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLklOSzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2luay5JbmtFZGl0b3IuZGVzZXJpYWxpemUoZGF0YSwgdGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5zZXRTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0b2dnbGVTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnRvZ2dsZVNlbGVjdGVkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuaXNTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bnNlbGVjdChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0KGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hhZFBvaW50ZXJEb3duKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFkUG9pbnRlckRvd24sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbG93Q2xpY2spKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FsbG93Q2xpY2ssIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvciwgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludGVyZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oYWRQb2ludGVyRG93biwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbGxvd0NsaWNrLCAhZWRpdG9yIHx8IGVkaXRvci5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcm9wKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZXZlbnQuZGF0YVRyYW5zZmVyLmdldERhdGEoInRleHQvcGxhaW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcihpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmRyb3BFZmZlY3QgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRYID0gZXZlbnQuY2xpZW50WCAtIHJlY3QueDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5kWSA9IGV2ZW50LmNsaWVudFkgLSByZWN0Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50cmFuc2xhdGUoZW5kWCAtIGVkaXRvci5zdGFydFgsIGVuZFkgLSBlZGl0b3Iuc3RhcnRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcmFnb3ZlcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCgoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NC5wYXJlbnQpID09PSB0aGlzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuc2V0QWN0aXZlRWRpdG9yKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQ1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDUgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NS5yZW1vdmVQb2ludGVySW5UZXh0TGF5ZXIoZWRpdG9yLmNvbnRlbnREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFBhcmVudChudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pc0F0dGFjaGVkVG9ET00gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5yZW1vdmVMYXllcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0ID0gdmlld3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKHRoaXMuZGl2LCB2aWV3cG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdG9vbHMuYmluZEV2ZW50cykodGhpcywgdGhpcy5kaXYsIFsiZHJhZ292ZXIiLCAiZHJvcCJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcnModGhpcy5wYWdlSW5kZXgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlTW9kZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGUoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSB2aWV3cG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9ucykodGhpcy5kaXYsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cGRhdGVNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlRGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy52aWV3cG9ydC5yYXdEaW1zOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yTGF5ZXIgPSBBbm5vdGF0aW9uRWRpdG9yTGF5ZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hhbmdlUGFyZW50MihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciRwYXJlbnQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvci5wYXJlbnQgPT09IHRoaXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIChfZWRpdG9yJHBhcmVudCA9IGVkaXRvci5wYXJlbnQpID09PSBudWxsIHx8IF9lZGl0b3IkcGFyZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZWRpdG9yJHBhcmVudC5kZXRhY2goZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UGFyZW50KHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuZGl2ICYmIGVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKGVkaXRvci5kaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jcmVhdGVOZXdFZGl0b3IyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZnJlZXRleHQuRnJlZVRleHRFZGl0b3IocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTks6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF9pbmsuSW5rRWRpdG9yKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IHRoaXMuZ2V0TmV4dElkKCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlTmV3RWRpdG9yLCBfY3JlYXRlTmV3RWRpdG9yMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudDogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHg6IGV2ZW50Lm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgIHk6IGV2ZW50Lm9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgIHVpTWFuYWdlcjogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNDbGVhbmluZ1VwLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NsZWFuaW5nVXAsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yTGF5ZXIsICJfaW5pdGlhbGl6ZWQiLCBmYWxzZSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxd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6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVDb2xvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9leHRyYWN0VGV4dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRFZGl0b3JEaW1lbnNpb25zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEVkaXRvciBleHRlbmRzIF9lZGl0b3IuQW5ub3RhdGlvbkVkaXRvciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLnBhcmFtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJmcmVlVGV4dEVkaXRvciIKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3VwZGF0ZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVGb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEVkaXRvckRpdkJsdXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZWRpdG9yRGl2Qmx1ci5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZGb2N1cywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZGb2N1cy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZJbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZJbnB1dC5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZLZXlkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmVkaXRvckRpdktleWRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbG9yLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9jb250ZW50LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAiIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvckRpdklkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBgJHt0aGlzLmlkfS1lZGl0b3JgCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZm9udFNpemUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgcGFyYW1zLmNvbG9yIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9mb250U2l6ZSwgcGFyYW1zLmZvbnRTaXplIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Rm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImZyZWVfdGV4dDJfZGVmYXVsdF9jb250ZW50IiwgImVkaXRvcl9mcmVlX3RleHQyX2FyaWFfbGFiZWwiXS5tYXAoc3RyID0+IFtzdHIsIGwxMG4uZ2V0KHN0cildKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gZ2V0Q29tcHV0ZWRTdHlsZShkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlcm5hbFBhZGRpbmcgPSBwYXJzZUZsb2F0KHN0eWxlLmdldFByb3BlcnR5VmFsdWUoIi0tZnJlZXRleHQtcGFkZGluZyIpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX1NJWkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fZGVmYXVsdENvbG9yID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZUZvbnRTaXplLCBfdXBkYXRlRm9udFNpemUyKS5jYWxsKHRoaXMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZV0sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUiwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3JdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSldLCBbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1IsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29sb3IpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWy1GcmVlVGV4dEVkaXRvci5faW50ZXJuYWxQYWRkaW5nICogc2NhbGUsIC0oRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyArIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHNjYWxlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVidWlsZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kaXYgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5hZGQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQudXBkYXRlVG9vbGJhcihfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdi5jbGFzc0xpc3QucmVtb3ZlKCJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNvbnRlbnRFZGl0YWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5yZW1vdmVBdHRyaWJ1dGUoImFyaWEtYWN0aXZlZGVzY2VuZGFudCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKHRydWUpOwogICAgICAgICAgICAgICAg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Gl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5mb2N1c2luKGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LnRhcmdldCAhPT0gdGhpcy5lZGl0b3JEaXYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmZvY3VzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICF0aGlzLmVkaXRvckRpdiB8fCB0aGlzLmVkaXRvckRpdi5pbm5lclRleHQudHJpbSgpID09PSAiIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuYWRkVW5kb2FibGVFZGl0b3IodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250ZW50LCBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0VGV4dCwgX2V4dHJhY3RUZXh0MikuY2FsbCh0aGlzKS50cmltRW5kKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRFZGl0b3JEaW1lbnNpb25zLCBfc2V0RWRpdG9yRGltZW5zaW9uczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5pc0luRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGJsY2xpY2soZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBrZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgPT09IHRoaXMuZGl2ICYmIGV2ZW50LmtleSA9PT0gIkVudGVyIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZLZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEZyZWVUZXh0RWRpdG9yLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVkaXRvckRpdkZvY3VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWRpdG9yRGl2Qmx1cihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZJbnB1dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5kaXYuY2xhc3NMaXN0LnRvZ2dsZSgiZnJlZVRleHRFZGl0aW5nIiwgdGhpcy5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc2V0QXR0cmlidXRlKCJyb2xlIiwgImNvbW1lbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlQXR0cmlidXRlKCJhcmlhLW11bHRpbGluZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAidGV4dGJveCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoImFyaWEtbXVsdGlsaW5lIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNsYXNzTmFtZSA9ICJpbnRlcm5hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiaWQiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvckRpdklkKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdGluZygpOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfZnJlZV90ZXh0Ml9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGVkaXRvckRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZWRpdG9yRGl2ID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJmcmVlX3RleHQyX2RlZmF1bHRfY29udGVudCIpLnRoZW4obXNnID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRlZGl0b3JEaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChfdGhpcyRlZGl0b3JEaXYyID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGVkaXRvckRpdjIuc2V0QXR0cmlidXRlKCJkZWZhdWx0LWNvbnRlbnQiLCBtc2cpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZWRpdG9yRGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSl9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLmVkaXRvckRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXlEaXYuY2xhc3NMaXN0LmFkZCgib3ZlcmxheSIsICJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLm92ZXJsYXlEaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3Rvb2xzLmJpbmRFdmVudHMpKHRoaXMsIHRoaXMuZGl2LCBbImRibGNsaWNrIiwgImtleWRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLndpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0KGJhc2VYICogcGFyZW50V2lkdGgsIGJhc2VZICogcGFyZW50SGVpZ2h0LCB0aGlzLndpZHRoICogcGFyZW50V2lkdGgsIHRoaXMuaGVpZ2h0ICogcGFyZW50SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRlbnQpLnNwbGl0KCJcbiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChsaW5lID8gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUobGluZSkgOiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJiciIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hcHBlbmQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5jb250ZW50RWRpdGFibGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50RGl2KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBzdXBlci5kZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9mb250U2l6ZSwgZGF0YS5mb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9jb2xvciwgX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZGF0YS5jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfY29udGVudCwgZGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlcmlhbGl6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkaW5nID0gRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyAqIHRoaXMucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLmdldFJlY3QocGFkZGluZywgcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmlzQXR0YWNoZWRUb0RPTSA/IGdldENvbXB1dGVkU3R5bGUodGhpcy5lZGl0b3JEaXYpLmNvbG9yIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvblR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhULAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb250ZW50KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHRoaXMucm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gRnJlZVRleHRFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlRm9udFNpemUyKGZvbnRTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2V0Rm9udHNpemUgPSBzaXplID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc3R5bGUuZm9udFNpemUgPSBgY2FsYygke3NpemV9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRlKDAsIC0oc2l6ZSAtIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHRoaXMucGFyZW50U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2ZvbnRTaXplLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucywgX3NldEVkaXRvckRpbWVuc2lvbnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGb250c2l6ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnRzaXplKGZvbnRTaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Rm9udHNpemUoc2F2ZWRGb250c2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbG9yKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgY21kOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NvbG9yLCB0aGlzLmVkaXRvckRpdi5zdHlsZS5jb2xvciA9IGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgdGhpcy5lZGl0b3JEaXYuc3R5bGUuY29sb3IgPSBzYXZlZENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX0NPTE9SLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V4dHJhY3RUZXh0MigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZzID0gdGhpcy5lZGl0b3JEaXYuZ2V0RWxlbWVudHNCeVRhZ05hbWUoImRpdiIpOwogICAgICAgICAgICAgICAgICAgIGlmIChkaXZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXYuaW5uZXJUZXh0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiBkaXZzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGRpdi5pbm5lclRleHQucmVwbGFjZSgvXHJcbj98XG4vLCAiIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVmZmVyLmpvaW4oIlxuIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0RWRpdG9yRGltZW5zaW9uczIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIGxldCByZWN0OwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQXR0YWNoZWRUb0RPTSkgewogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gdGhpcy5kaXYuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZERpc3BsYXkgPSBkaXYuc3R5bGUuZGlzcGxheTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLmRpc3BsYXkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLmRpdi5hcHBlbmQodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdi5zdHlsZS5kaXNwbGF5ID0gc2F2ZWREaXNwbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLndpZHRoID0gcmVjdC53aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gcmVjdC5oZWlnaHQgLyBwYXJlbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZnJlZVRleHREZWZhdWx0Q29udGVudCIsICIiKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShGcmVlVGV4dEVkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfaW50ZXJuYWxQYWRkaW5nIiwgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdENvbG9yIiwgbnVsbCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdEZvbnRTaXplIiwgMTApOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KEZyZWVUZXh0RWRpdG9yLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBfdG9vbHMuS2V5Ym9hcmRNYW5hZ2VyKFtbWyJjdHJsK0VudGVyIiwgIm1hYyttZXRhK0VudGVyIiwgIkVzY2FwZSIsICJtYWMrRXNjYXBlIl0sIEZyZWVUZXh0RWRpdG9yLnByb3RvdHlwZS5jb21taXRPclJlbW92ZV1dKSk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfdHlwZSIsICJmcmVldGV4dCIpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgImZpdEN1cnZlIiwgKHsKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3BkZmpzRml0Q3VydmUuZml0Q3VydmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9wZGZqc0ZpdEN1cnZlID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjUpOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RlZmluZVByb3BlcnR5KG9iaiwga2V5LCB2YWx1ZSkgeyBrZXkgPSBfdG9Qcm9wZXJ0eUtleShrZXkpOyBpZiAoa2V5IGluIG9iaikgeyBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBrZXksIHsgdmFsdWU6IHZhbHVlLCBlbnVtZXJhYmxlOiB0cnVlLCBjb25maWd1cmFibGU6IHRydWUsIHdyaXRhYmxlOiB0cnVlIH0pOyB9IGVsc2UgeyBvYmpba2V5XSA9IHZhbHVlOyB9IHJldHVybiBvYmo7IH0KICAgICA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4pIHsgaWYgKCFwcml2YXRlU2V0LmhhcyhyZWNlaXZlcikpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIGdldCBwcml2YXRlIGZpZWxkIG9uIG5vbi1pbnN0YW5jZSIpOyB9IHJldHVybiBmbjsgfQogICAgICAgICAgICAgICAgY29uc3QgUkVTSVpFUl9TSVpFID0gMTY7CiAgICAgICAgICAgICAgICB2YXIgX2FzcGVjdFJhdGlvID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Jhc2VIZWlnaHQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYmFzZVdpZHRoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVybGVhdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVydXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlRWRpdGluZyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0NhbnZhc0luaXRpYWxpemVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2xhc3RQb2ludCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9vYnNlcnZlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZWFsV2lkdGggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVhbEhlaWdodCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZXF1ZXN0RnJhbWVDYWxsYmFjayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVUaGlja25lc3MgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlQ29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlT3BhY2l0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRJbml0aWFsQkJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRTdHJva2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RhcnREcmF3aW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2RyYXcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RvcERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVkcmF3ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuZERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY3JlYXRlQ2FudmFzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU9ic2VydmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NldENhbnZhc0RpbXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0U2NhbGVGYWN0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlVHJhbnNmb3JtID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZVBhdGhzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2V4dHJhY3RQb2ludHNPbkJlemllciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0FsbW9zdEZsYXQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfZ2V0QmJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRQYWRkaW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2ZpdFRvQ29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRNaW5EaW1zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBJbmtFZGl0b3IgZXh0ZW5kcyBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi5wYXJhbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiaW5rRWRpdG9yIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNaW5EaW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9maXRUb0NvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldFBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEJib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzQWxtb3N0RmxhdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFBvaW50c09uQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemVQYXRocyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0Q2FudmFzRGltcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NyZWF0ZUNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5kRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfcmVkcmF3KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zdG9wRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZHJhdyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc3RhcnREcmF3aW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTdHJva2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEluaXRpYWxCQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVPcGFjaXR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVGhpY2tuZXNzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2FzcGVjdFJhdGlvLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYmFzZUhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Jhc2VXaWR0aCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcm1vdmUuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJsZWF2ZS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcnVwLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJkb3duLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kaXNhYmxlRWRpdGluZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2xhc3RQb2ludCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ic2VydmVyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbFdpZHRoLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbEhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yID0gcGFyYW1zLmNvbG9yIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gcGFyYW1zLnRoaWNrbmVzcyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBwYXJhbXMub3BhY2l0eSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJEID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZUZhY3RvciA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25YID0gdGhpcy50cmFuc2xhdGlvblkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiLCAiZWRpdG9yX2luazJfYXJpYV9sYWJlbCJdLm1hcChzdHIgPT4gW3N0ciwgbDEwbi5nZXQoc3RyKV0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1M6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRPcGFjaXR5ID0gdmFsdWUgLyAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZVRoaWNrbmVzcywgX3VwZGF0ZVRoaWNrbmVzczIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVPcGFjaXR5LCBfdXBkYXRlT3BhY2l0eTIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX1RISUNLTkVTUywgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKElua0VkaXRvci5fZGVmYXVsdE9wYWNpdHkgKiAxMDApXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1MsIHRoaXMudGhpY2tuZXNzIHx8IElua0VkaXRvci5fZGVmYXVsdFRoaWNrbmVzc10sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1IsIHRoaXMuY29sb3IgfHwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKDEwMCAqICh0aGlzLm9wYWNpdHkgPz8gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eSkpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlYnVpbGQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZU9ic2VydmVyLCBfY3JlYXRlT2JzZXJ2ZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldENhbnZhc0RpbXMsIF9zZXRDYW52YXNEaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9maXRUb0NvbnRlbnQsIF9maXRUb0NvbnRlbnQyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbnZhcyA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMud2lkdGggPSB0aGlzLmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29ic2VydmVyKS5kaXNjb25uZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0UGFyZW50KHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGFyZW50ICYmIHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLnJlbW92ZVNob3VsZFJlc2NhbGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5wYXJlbnQgJiYgcGFyZW50ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkU2hvdWxkUmVzY2FsZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5zZXRQYXJlbnQocGFyZW50KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1lbnNpb25zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpIHx8IHRoaXMuY2FudmFzID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNJbkVkaXRNb2RlKCkgfHwgdGhpcy5jYW52YXMgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gIXRoaXMuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QucmVtb3ZlKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSAhdGhpcy5pc0VtcHR5KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMCB8fCB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMSAmJiB0aGlzLnBhdGhzWzBdLmxlbmd0aCA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZElua0VkaXRvcklmTmVlZGVkKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5tb3ZlRWRpdG9ySW5ET00odGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvY3VzaW4oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZm9jdXNpbihldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmJ1dHRvbiAhPT0gMCB8fCAhdGhpcy5pc0luRWRpdE1vZGUoKSB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5Gb3JlZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50eXBlICE9PSAibW91c2UiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5hZGRFdmVudExpc3RlbmVyKCJwb2ludGVybGVhdmUiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJtb3ZlIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJtb3ZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0YXJ0RHJhd2luZywgX3N0YXJ0RHJhd2luZzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJtb3ZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kcmF3LCBfZHJhdzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJbkVkaXRNb2RlKCkgJiYgdGhpcy5jdXJyZW50UGF0aC5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5kRHJhd2luZywgX2VuZERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmxlYXZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2VuZERyYXdpbmcsIF9lbmREcmF3aW5nMikuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIElua0VkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfaW5rMl9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZGl2ID0gdGhpcy5kaXYpID09PSBudWxsIHx8IF90aGlzJGRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeSwgdywgaF0gPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRJbml0aWFsQkJveCwgX2dldEluaXRpYWxCQm94MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdCh4LCB5LCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVDYW52YXMsIF9jcmVhdGVDYW52YXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdChiYXNlWCAqIHBhcmVudFdpZHRoLCBiYXNlWSAqIHBhcmVudEhlaWdodCwgdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoLCB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lzQ2FudmFzSW5pdGlhbGl6ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHRoaXMud2lkdGggKiBwYXJlbnRXaWR0aCwgdGhpcy5oZWlnaHQgKiBwYXJlbnRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldE1pbkRpbXMsIF9zZXRNaW5EaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QuYWRkKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIsIF9jcmVhdGVPYnNlcnZlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RGltZW5zaW9ucyh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvdW5kZWRXaWR0aCA9IE1hdGgucm91bmQod2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZGVkSGVpZ2h0ID0gTWF0aC5yb3VuZChoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsV2lkdGgpID09PSByb3VuZGVkV2lkdGggJiYgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsSGVpZ2h0KSA9PT0gcm91bmRlZEhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVhbFdpZHRoLCByb3VuZGVkV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIHJvdW5kZWRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAmJiBNYXRoLmFicyhfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAtIHdpZHRoIC8gaGVpZ2h0KSA+IDFlLTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9IE1hdGguY2VpbCh3aWR0aCAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGltcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhlaWdodCA9IGhlaWdodCAvIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbCh0aGlzLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRDYW52YXNEaW1zLCBfc2V0Q2FudmFzRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnN0eWxlLnZpc2liaWxpdHkgPSAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZml4RGltcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gc3VwZXIuZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudGhpY2tuZXNzID0gZGF0YS50aGlja25lc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmRhdGEuY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iub3BhY2l0eSA9IGRhdGEub3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF0gPSBlZGl0b3IucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gZWRpdG9yLndpZHRoICogcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBlZGl0b3IuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3IgPSBlZGl0b3IucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBkYXRhLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9hc3BlY3RSYXRpbywgd2lkdGggLyBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfZGlzYWJsZUVkaXRpbmcsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfcmVhbFdpZHRoLCBNYXRoLnJvdW5kKHdpZHRoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9yZWFsSGVpZ2h0LCBNYXRoLnJvdW5kKGhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcgogICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGRhdGEucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wYXRocy5wdXNoKHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyWzBdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcDEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbMV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2ldIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDExID0gc2NhbGVGYWN0b3IgKiAoaGVpZ2h0IC0gYmV6aWVyW2kgKyAxXSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHNjYWxlRmFjdG9yICogKGJlemllcltpICsgMl0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMjEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbaSArIDNdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2kgKyA0XSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzMSA9IHNjYWxlRmFjdG9yICogKGhlaWdodCAtIGJlemllcltpICsgNV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goW1twMCwgcDFdLCBbcDEwLCBwMTFdLCBbcDIwLCBwMjFdLCBbcDMwLCBwMzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDAgPSBwMzA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDEgPSBwMzE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoMkQgPSBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKHRoaXMsIHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmJlemllclBhdGgyRC5wdXNoKHBhdGgyRCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQoZWRpdG9yLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KGVkaXRvciwgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldChlZGl0b3IsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbChlZGl0b3IsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXJpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZ2V0UmVjdCgwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5yb3RhdGlvbiAlIDE4MCA9PT0gMCA/IHJlY3RbM10gLSByZWN0WzFdIDogcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmN0eC5zdHJva2VTdHlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uVHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlja25lc3M6IHRoaXMudGhpY2tuZXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BhY2l0eTogdGhpcy5vcGFjaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aHM6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZVBhdGhzLCBfc2VyaWFsaXplUGF0aHMyKS5jYWxsKHRoaXMsIHRoaXMuc2NhbGVGYWN0b3IgLyB0aGlzLnBhcmVudFNjYWxlLCB0aGlzLnRyYW5zbGF0aW9uWCwgdGhpcy50cmFuc2xhdGlvblksIGhlaWdodCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB0aGlzLnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSBJbmtFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlVGhpY2tuZXNzMih0aGlja25lc3MpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZFRoaWNrbmVzcyA9IHRoaXMudGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gdGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZml0VG9Db250ZW50LCBfZml0VG9Db250ZW50MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50aGlja25lc3MgPSBzYXZlZFRoaWNrbmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG86ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBzYXZlZENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwKICAgICAgICAgICAgICAgICAgICAgICAgb3ZlcndyaXRlSWZTYW1lVHlwZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAga2VlcFVuZG86IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF91cGRhdGVPcGFjaXR5MihvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgb3BhY2l0eSAvPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRPcGFjaXR5ID0gdGhpcy5vcGFjaXR5OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA9IG9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICB1bmRvOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBzYXZlZE9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX09QQUNJVFksCiAgICAgICAgICAgICAgICAgICAgICAgIG92ZXJ3cml0ZUlmU2FtZVR5cGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGtlZXBVbmRvOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0SW5pdGlhbEJCb3gyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Um90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudERpbWVuc2lvbnM6IFt3aWR0aCwgaGVpZ2h0XQogICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAocGFyZW50Um90YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMCwgaGVpZ2h0LCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3dpZHRoLCBoZWlnaHQsIHdpZHRoLCBoZWlnaHRdOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbd2lkdGgsIDAsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0U3Ryb2tlMigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgIG9wYWNpdHksCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzcywKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50U2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlRmFjdG9yCiAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHRoaWNrbmVzcyAqIHBhcmVudFNjYWxlIC8gc2NhbGVGYWN0b3I7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAicm91bmQiOwogICAgICAgICAgICAgICAgICAgIGN0eC5saW5lSm9pbiA9ICJyb3VuZCI7CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1pdGVyTGltaXQgPSAxMDsKICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBgJHtjb2xvcn0keygwLCBfdG9vbHMub3BhY2l0eVRvSGV4KShvcGFjaXR5KX1gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0YXJ0RHJhd2luZzIoeCwgeSkgewogICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaXNDYW52YXNJbml0aWFsaXplZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRoaWNrbmVzcyB8fD0gSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yIHx8PSBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA/Pz0gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50UGF0aC5wdXNoKFt4LCB5XSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9sYXN0UG9pbnQsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldFN0cm9rZSwgX3NldFN0cm9rZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVxdWVzdEZyYW1lQ2FsbGJhY2ssICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2xhc3RQb2ludCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGVhclJlY3QoMCwgMCwgdGhpcy5jYW52YXMud2lkdGgsIHRoaXMuY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5saW5lVG8oLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9sYXN0UG9pbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RyYXcyKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbbGFzdFgsIGxhc3RZXSA9IHRoaXMuY3VycmVudFBhdGguYXQoLTEpOwogICAgICAgICAgICAgICAgICAgIGlmICh4ID09PSBsYXN0WCAmJiB5ID09PSBsYXN0WSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBbeCwgeV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0b3BEcmF3aW5nMih4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGgubWluKE1hdGgubWF4KHgsIDApLCB0aGlzLmNhbnZhcy53aWR0aCk7CiAgICAgICAgICAgICAgICAgICAgeSA9IE1hdGgubWluKE1hdGgubWF4KHksIDApLCB0aGlzLmNhbnZhcy5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtsYXN0WCwgbGFzdFldID0gdGhpcy5jdXJyZW50UGF0aC5hdCgtMSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHggIT09IGxhc3RYIHx8IHkgIT09IGxhc3RZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgYmV6aWVyOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCAhPT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICBiZXppZXIgPSAoMCwgX3BkZmpzRml0Q3VydmUuZml0Q3VydmUpKHRoaXMuY3VycmVudFBhdGgsIDMwLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4eSA9IFt4LCB5XTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6aWVyID0gW1t4eSwgeHkuc2xpY2UoKSwgeHkuc2xpY2UoKSwgeHldXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGF0aDJEID0gX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChJbmtFZGl0b3IsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKElua0VkaXRvciwgYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzLnB1c2goYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iZXppZXJQYXRoMkQucHVzaChwYXRoMkQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuZG8gPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGF0aHMucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJELnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wYXRocy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVPYnNlcnZlciwgX2NyZWF0ZU9ic2VydmVyMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfcmVkcmF3MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTdHJva2UsIF9zZXRTdHJva2UyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGVhclJlY3QoMCwgMCwgY2FudmFzLndpZHRoLCBjYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVUcmFuc2Zvcm0sIF91cGRhdGVUcmFuc2Zvcm0yKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLmJlemllclBhdGgyRCkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKHBhdGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmREcmF3aW5nMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0b3BEcmF3aW5nLCBfc3RvcERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50Lm9mZnNldFgsIGV2ZW50Lm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJsZWF2ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybGVhdmUpKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmVFdmVudExpc3RlbmVyKCJwb2ludGVybW92ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybW92ZSkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUNhbnZhczIoKSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IHRoaXMuY2FudmFzLmhlaWdodCA9IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMuY2xhc3NOYW1lID0gImlua0VkaXRvckNhbnZhcyI7CiAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9sMTBuUHJvbWlzZS5nZXQoImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiKS50aGVuKG1zZyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkY2FudmFzID0gdGhpcy5jYW52YXMpID09PSBudWxsIHx8IF90aGlzJGNhbnZhcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY2FudmFzLnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKHRoaXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY3JlYXRlT2JzZXJ2ZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG5ldyBSZXNpemVPYnNlcnZlcihlbnRyaWVzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IGVudHJpZXNbMF0uY29udGVudFJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0LndpZHRoICYmIHJlY3QuaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldERpbWVuc2lvbnMocmVjdC53aWR0aCwgcmVjdC5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2JzZXJ2ZXIpLm9ic2VydmUodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldENhbnZhc0RpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnRXaWR0aCwgcGFyZW50SGVpZ2h0XSA9IHRoaXMucGFyZW50RGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IE1hdGguY2VpbCh0aGlzLndpZHRoICogcGFyZW50V2lkdGgpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmhlaWdodCA9IE1hdGguY2VpbCh0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZXRTY2FsZUZhY3RvcjIod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRQYWRkaW5nLCBfZ2V0UGFkZGluZzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JXID0gKHdpZHRoIC0gcGFkZGluZykgLyBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Jhc2VXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JIID0gKGhlaWdodCAtIHBhZGRpbmcpIC8gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9iYXNlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnNjYWxlRmFjdG9yID0gTWF0aC5taW4oc2NhbGVGYWN0b3JXLCBzY2FsZUZhY3RvckgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZVRyYW5zZm9ybTIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFkZGluZyA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2dldFBhZGRpbmcsIF9nZXRQYWRkaW5nMikuY2FsbCh0aGlzKSAvIDI7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKHRoaXMuc2NhbGVGYWN0b3IsIDAsIDAsIHRoaXMuc2NhbGVGYWN0b3IsIHRoaXMudHJhbnNsYXRpb25YICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcsIHRoaXMudHJhbnNsYXRpb25ZICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2J1aWxkUGF0aDJEKGJlemllcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGgyRCA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbZmlyc3QsIGNvbnRyb2wxLCBjb250cm9sMiwgc2Vjb25kXSA9IGJlemllcltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5tb3ZlVG8oLi4uZmlyc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5iZXppZXJDdXJ2ZVRvKGNvbnRyb2wxWzBdLCBjb250cm9sMVsxXSwgY29udHJvbDJbMF0sIGNvbnRyb2wyWzFdLCBzZWNvbmRbMF0sIHNlY29uZFsxXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXRoMkQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplUGF0aHMyKHMsIHR4LCB0eSwgaCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE5VTUJFUl9PRl9QT0lOVFNfT05fQkVaSUVSX0NVUlZFID0gNDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IFtdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSB0aGlzLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGJ1ZmZlciwgcG9pbnRzOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmV6aWVyIG9mIHRoaXMucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gPSBiZXppZXJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMTAgPSBzICogKGZpcnN0WzBdICsgdHgpICsgcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAxMSA9IGggLSBzICogKGZpcnN0WzFdICsgdHkpIC0gcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHMgKiAoY29udHJvbDFbMF0gKyB0eCkgKyBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIxID0gaCAtIHMgKiAoY29udHJvbDFbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gcyAqIChjb250cm9sMlswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMzEgPSBoIC0gcyAqIChjb250cm9sMlsxXSArIHR5KSAtIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDAgPSBzICogKHNlY29uZFswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDEgPSBoIC0gcyAqIChzZWNvbmRbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIucHVzaChwMTAsIHAxMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocDEwLCBwMTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2gocDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0UG9pbnRzT25CZXppZXIsIF9leHRyYWN0UG9pbnRzT25CZXppZXIyKS5jYWxsKHRoaXMsIHAxMCwgcDExLCBwMjAsIHAyMSwgcDMwLCBwMzEsIHA0MCwgcDQxLCBOVU1CRVJfT0ZfUE9JTlRTX09OX0JFWklFUl9DVVJWRSwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcjogYnVmZmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0aHM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZXh0cmFjdFBvaW50c09uQmV6aWVyMihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSwgbiwgcG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzQWxtb3N0RmxhdCwgX2lzQWxtb3N0RmxhdDIpLmNhbGwodGhpcywgcDEwLCBwMTEsIHAyMCwgcDIxLCBwMzAsIHAzMSwgcDQwLCBwNDEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHA0MCwgcDQxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IGkgLyBuOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTEwID0gdCAqIHAxMCArIG10ICogcDIwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTExID0gdCAqIHAxMSArIG10ICogcDIxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIwID0gdCAqIHAyMCArIG10ICogcDMwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIxID0gdCAqIHAyMSArIG10ICogcDMxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxMzAgPSB0ICogcDMwICsgbXQgKiBwNDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHEzMSA9IHQgKiBwMzEgKyBtdCAqIHA0MTsKICAgICAgICAgICAgICAgICAgICAgICAgcTEwID0gdCAqIHExMCArIG10ICogcTIwOwogICAgICAgICAgICAgICAgICAgICAgICBxMTEgPSB0ICogcTExICsgbXQgKiBxMjE7CiAgICAgICAgICAgICAgICAgICAgICAgIHEyMCA9IHQgKiBxMjAgKyBtdCAqIHEzMDsKICAgICAgICAgICAgICAgICAgICAgICAgcTIxID0gdCAqIHEyMSArIG10ICogcTMxOwogICAgICAgICAgICAgICAgICAgICAgICBxMTAgPSB0ICogcTEwICsgbXQgKiBxMjA7CiAgICAgICAgICAgICAgICAgICAgICAgIHExMSA9IHQgKiBxMTEgKyBtdCAqIHEyMTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocTEwLCBxMTEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNBbG1vc3RGbGF0MihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvbCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF4ID0gKDMgKiBwMjAgLSAyICogcDEwIC0gcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF5ID0gKDMgKiBwMjEgLSAyICogcDExIC0gcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ4ID0gKDMgKiBwMzAgLSBwMTAgLSAyICogcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5ID0gKDMgKiBwMzEgLSBwMTEgLSAyICogcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLm1heChheCwgYngpICsgTWF0aC5tYXgoYXksIGJ5KSA8PSB0b2w7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0QmJveDIoKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHhNaW4gPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeE1heCA9IC1JbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeU1pbiA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGxldCB5TWF4ID0gLUluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLnBhdGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gb2YgcGF0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF91dGlsLlV0aWwuYmV6aWVyQm91bmRpbmdCb3goLi4uZmlyc3QsIC4uLmNvbnRyb2wxLCAuLi5jb250cm9sMiwgLi4uc2Vjb25kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNaW4gPSBNYXRoLm1pbih4TWluLCBiYm94WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNaW4gPSBNYXRoLm1pbih5TWluLCBiYm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNYXggPSBNYXRoLm1heCh4TWF4LCBiYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNYXggPSBNYXRoLm1heCh5TWF4LCBiYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hNaW4sIHlNaW4sIHhNYXgsIHlNYXhdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2dldFBhZGRpbmcyKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSA/IE1hdGguY2VpbCh0aGlzLnRoaWNrbmVzcyAqIHRoaXMucGFyZW50U2NhbGUpIDogMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9maXRUb0NvbnRlbnQyKCkgewogICAgICAgICAgICAgICAgICAgIGxldCBmaXJzdFRpbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94ID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZ2V0QmJveC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KICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRNaW5EaW1zLCBfc2V0TWluRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldlRyYW5zbGF0aW9uWCA9IHRoaXMudHJhbnNsYXRpb25YOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZUcmFuc2xhdGlvblkgPSB0aGlzLnRyYW5zbGF0aW9uWTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zbGF0aW9uWCA9IC1iYm94WzBdOwogICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25ZID0gLWJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZWFsV2lkdGgsIHdpZHRoKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2NhbGVkUGFkZGluZyA9IGZpcnN0VGltZSA/IHBhZGRpbmcgLyB0aGlzLnNjYWxlRmFjdG9yIC8gMiA6IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUocHJldlRyYW5zbGF0aW9uWCAtIHRoaXMudHJhbnNsYXRpb25YIC0gdW5zY2FsZWRQYWRkaW5nLCBwcmV2VHJhbnNsYXRpb25ZIC0gdGhpcy50cmFuc2xhdGlvblkgLSB1bnNjYWxlZFBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1pbkRpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pID49IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluSGVpZ2h0ID0gYCR7UkVTSVpFUl9TSVpFfXB4YDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtNYXRoLnJvdW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pICogUkVTSVpFUl9TSVpFKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtSRVNJWkVSX1NJWkV9cHhgOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5taW5IZWlnaHQgPSBgJHtNYXRoLnJvdW5kKFJFU0laRVJfU0laRSAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9kZWZhdWx0Q29sb3IiLCBudWxsKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdE9wYWNpdHkiLCAxKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdFRoaWNrbmVzcyIsIDEpOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoSW5rRWRpdG9yLCAiX3R5cGUiLCAiaW5rIik7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgZml0Q3VydmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gZml0Q3VydmU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3VydmUocG9pbnRzLCBtYXhFcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkZpcnN0IGFyZ3VtZW50IHNob3VsZCBiZSBhbiBhcnJheSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaChwb2ludCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludCkgfHwgcG9pbnQuc29tZShpdGVtID0+IHR5cGVvZiBpdGVtICE9PSAnbnVtYmVyJykgfHwgcG9pbnQubGVuZ3RoICE9PSBwb2ludHNbMF0ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcigiRWFjaCBwb2ludCBzaG91bGQgYmUgYW4gYXJyYXkgb2YgbnVtYmVycy4gRWFjaCBwb2ludCBzaG91bGQgaGF2ZSB0aGUgc2FtZSBhbW91bnQgb2YgbnVtYmVycy4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IHBvaW50cy5maWx0ZXIoKHBvaW50LCBpKSA9PiBpID09PSAwIHx8ICFwb2ludC5ldmVyeSgodmFsLCBqKSA9PiB2YWwgPT09IHBvaW50c1tpIC0gMV1bal0pKTsKICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW4gPSBwb2ludHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlZnRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbMV0sIHBvaW50c1swXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmlnaHRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbbGVuIC0gMl0sIHBvaW50c1tsZW4gLSAxXSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpdEN1YmljKHBvaW50cywgbGVmdFRhbmdlbnQsIHJpZ2h0VGFuZ2VudCwgbWF4RXJyb3IsIHByb2dyZXNzQ2FsbGJhY2spOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3ViaWMocG9pbnRzLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBlcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1heEl0ZXJhdGlvbnMgPSAyMDsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsIHUsIHVQcmltZSwgbWF4RXJyb3IsIHByZXZFcnIsIHNwbGl0UG9pbnQsIHByZXZTcGxpdCwgY2VudGVyVmVjdG9yLCB0b0NlbnRlclRhbmdlbnQsIGZyb21DZW50ZXJUYW5nZW50LCBiZXppZXJzLCBkaXN0LCBpOwogICAgICAgICAgICAgICAgICAgIGlmIChwb2ludHMubGVuZ3RoID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSBtYXRocy52ZWN0b3JMZW4obWF0aHMuc3VidHJhY3QocG9pbnRzWzBdLCBwb2ludHNbMV0pKSAvIDMuMDsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmUgPSBbcG9pbnRzWzBdLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzBdLCBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgZGlzdCkpLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzFdLCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIGRpc3QpKSwgcG9pbnRzWzFdXTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHUgPSBjaG9yZExlbmd0aFBhcmFtZXRlcml6ZShwb2ludHMpOwogICAgICAgICAgICAgICAgICAgIFtiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCB1LCB1LCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBpZiAobWF4RXJyb3IgPT09IDAgfHwgbWF4RXJyb3IgPCBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG1heEVycm9yIDwgZXJyb3IgKiBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB1UHJpbWUgPSB1OwogICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZTcGxpdCA9IHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBNYXhJdGVyYXRpb25zOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVQcmltZSA9IHJlcGFyYW1ldGVyaXplKGJlekN1cnZlLCBwb2ludHMsIHVQcmltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbYmV6Q3VydmUsIG1heEVycm9yLCBzcGxpdFBvaW50XSA9IGdlbmVyYXRlQW5kUmVwb3J0KHBvaW50cywgdSwgdVByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhFcnJvciA8IGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNwbGl0UG9pbnQgPT09IHByZXZTcGxpdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcnJDaGFuZ2UgPSBtYXhFcnJvciAvIHByZXZFcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyckNoYW5nZSA+IC45OTk5ICYmIGVyckNoYW5nZSA8IDEuMDAwMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2U3BsaXQgPSBzcGxpdFBvaW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlemllcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBjZW50ZXJWZWN0b3IgPSBtYXRocy5zdWJ0cmFjdChwb2ludHNbc3BsaXRQb2ludCAtIDFdLCBwb2ludHNbc3BsaXRQb2ludCArIDFdKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY2VudGVyVmVjdG9yLmV2ZXJ5KHZhbCA9PiB2YWwgPT09IDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlclZlY3RvciA9IG1hdGhzLnN1YnRyYWN0KHBvaW50c1tzcGxpdFBvaW50IC0gMV0sIHBvaW50c1tzcGxpdFBvaW50XSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFtjZW50ZXJWZWN0b3JbMF0sIGNlbnRlclZlY3RvclsxXV0gPSBbLWNlbnRlclZlY3RvclsxXSwgY2VudGVyVmVjdG9yWzBdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9DZW50ZXJUYW5n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mUsIHBhcmFtc09yaWcpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0NhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzQ2FsbGJhY2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmV6OiBiZXpDdXJ2ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50czogcG9pbnRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiBwYXJhbXNPcmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4RXJyOiBtYXhFcnJvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heFBvaW50OiBzcGxpdFBvaW50CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlLCBtYXhFcnJvciwgc3BsaXRQb2ludF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtZXRlcnMsIGxlZnRUYW5nZW50LCByaWdodFRhbmdlbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsCiAgICAgICAgICAgICAgICAgICAgICAgIEEsCiAgICAgICAgICAgICAgICAgICAgICAgIGEsCiAgICAgICAgICAgICAgICAgICAgICAgIEMsCiAgICAgICAgICAgICAgICAgICAgICAgIFgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSwKICAgICAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1gsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9YX0MxLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9sLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9yLAogICAgICAgICAgICAgICAgICAgICAgICBlcHNpbG9uLAogICAgICAgICAgICAgICAgICAgICAgICBzZWdMZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGksCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbiwKICAgICAgICAgICAgICAgICAgICAgICAgdG1wLAogICAgICAgICAgICAgICAgICAgICAgICB1LAogICAgICAgICAgICAgICAgICAgICAgICB1eCwKICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RQb2ludCA9IHBvaW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFBvaW50ID0gcG9pbnRzW3BvaW50cy5sZW5ndGggLSAxXTsKICAgICAgICAgICAgICAgICAgICBiZXpDdXJ2ZSA9IFtmaXJzdFBvaW50LCBudWxsLCBudWxsLCBsYXN0UG9pbnRdOwogICAgICAgICAgICAgICAgICAgIEEgPSBtYXRocy56ZXJvc19YeDJ4MihwYXJhbWV0ZXJzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcGFyYW1ldGVycy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB1ID0gcGFyYW1ldGVyc1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgdXggPSAxIC0gdTsKICAgICAgICAgICAgICAgICAgICAgICAgYSA9IEFbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGFbMF0gPSBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgMyAqIHUgKiAodXggKiB1eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBhWzFdID0gbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCAzICogdXggKiAodSAqIHUpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQyA9IFtbMCwgMF0sIFswLCAwXV07CiAgICAgICAgICAgICAgICAgICAgWCA9IFswLCAwXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBwb2ludHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdSA9IHBhcmFtZXRlcnNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGEgPSBBW2ldOwogICAgICAgICAgICAgICAgICAgICAgICBDWzBdWzBdICs9IG1hdGhzLmRvdChhWzBdLCBhWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ1swXVsxXSArPSBtYXRocy5kb3QoYVswXSwgYVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENbMV1bMF0gKz0gbWF0aHMuZG90KGFbMF0sIGFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICBDWzFdWzFdICs9IG1hdGhzLmRvdChhWzFdLCBhWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gbWF0aHMuc3VidHJhY3QocG9pbnRzW2ldLCBiZXppZXIucShbZmlyc3RQb2ludCwgZmlyc3RQb2ludCwgbGFzdFBvaW50LCBsYXN0UG9pbnRdLCB1KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMF0gKz0gbWF0aHMuZG90KGFbMF0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMV0gKz0gbWF0aHMuZG90KGFbMV0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSA9IENbMF1bMF0gKiBDWzFdWzFdIC0gQ1sxXVswXSAqIENbMF1bMV07CiAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1ggPSBDWzBdWzBdICogWFsxXSAtIENbMV1bMF0gKiBYWzBdOwogICAgICAgICAgICAgICAgICAgIGRldF9YX0MxID0gWFswXSAqIENbMV1bMV0gLSBYWzFdICogQ1swXVsxXTsKICAgICAgICAgICAgICAgICAgICBhbHBoYV9sID0gZGV0X0MwX0MxID09PSAwID8gMCA6IGRldF9YX0MxIC8gZGV0X0MwX0MxOwogICAgICAgICAgICAgICAgICAgIGFscGhhX3IgPSBkZXRfQzBfQzEgPT09IDAgPyAwIDogZGV0X0MwX1ggLyBkZXRfQzBfQzE7CiAgICAgICAgICAgICAgICAgICAgc2VnTGVuZ3RoID0gbWF0aHMudmVjdG9yTGVuKG1hdGhzLnN1YnRyYWN0KGZpcnN0UG9pbnQsIGxhc3RQb2ludCkpOwogICAgICAgICAgICAgICAgICAgIGVwc2lsb24gPSAxLjBlLTYgKiBzZWdMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFscGhhX2wgPCBlcHNpbG9uIHx8IGFscGhhX3IgPCBlcHNpbG9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBzZWdMZW5ndGggLyAzLjApKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmVbMl0gPSBtYXRocy5hZGRBcnJheXMobGFzdFBvaW50LCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIHNlZ0xlbmd0aCAvIDMuMCkpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBhbHBoYV9sKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzJdID0gbWF0aHMuYWRkQXJyYXlzKGxhc3RQb2ludCwgbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCBhbHBoYV9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXpDdXJ2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlcGFyYW1ldGVyaXplKGJlemllciwgcG9pbnRzLCBwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcmFtZXRlcnMubWFwKChwLCBpKSA9PiBuZXd0b25SYXBoc29uUm9vdEZpbmQoYmV6aWVyLCBwb2ludHNbaV0sIHApKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG5ld3RvblJhcGhzb25Sb290RmluZChiZXosIHBvaW50LCB1KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGQgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHUpLCBwb2ludCksCiAgICAgICAgICAgICAgICAgICAgICAgIHFwcmltZSA9IGJlemllci5xcHJpbWUoYmV6LCB1KSwKICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJhdG9yID0gbWF0aHMubXVsTWF0cml4KGQsIHFwcmltZSksCiAgICAgICAgICAgICAgICAgICAgICAgIGRlbm9taW5hdG9yID0gbWF0aHMuc3VtKG1hdGhzLnNxdWFyZUl0ZW1zKHFwcmltZSkpICsgMiAqIG1hdGhzLm11bE1hdHJpeChkLCBiZXppZXIucXByaW1lcHJpbWUoYmV6LCB1KSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlbm9taW5hdG9yID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1IC0gbnVtZXJhdG9yIC8gZGVub21pbmF0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY2hvcmRMZW5ndGhQYXJhbWV0ZXJpemUocG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHUgPSBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgY3VyclUsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZVLAogICAgICAgICAgICAgICAgICAgICAgICBwcmV2UDsKICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaCgocCwgaSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjdXJyVSA9IGkgPyBwcmV2VSArIG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChwLCBwcmV2UCkpIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgdS5wdXNoKGN1cnJVKTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlUgPSBjdXJyVTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlAgPSBwOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHUgPSB1Lm1hcCh4ID0+IHggLyBwcmV2VSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICA7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wdXRlTWF4RXJyb3IocG9pbnRzLCBiZXosIHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZGlzdCwgbWF4RGlzdCwgc3BsaXRQb2ludCwgdiwgaSwgY291bnQsIHBvaW50LCB0OwogICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSAwOwogICAgICAgICAgICAgICAgICAgIHNwbGl0UG9pbnQgPSBNYXRoLmZsb29yKHBvaW50cy5sZW5ndGggLyAyKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0X2Rpc3RNYXAgPSBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyhiZXosIDEwKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBjb3VudCA9IHBvaW50cy5sZW5ndGg7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ID0gcG9pbnRzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICB0ID0gZmluZF90KGJleiwgcGFyYW1ldGVyc1tpXSwgdF9kaXN0TWFwLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHQpLCBwb2ludCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSB2WzBdICogdlswXSArIHZbMV0gKiB2WzFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IG1heERpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaXRQb2ludCA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFttYXhEaXN0LCBzcGxpdFBvaW50XTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIHZhciBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyA9IGZ1bmN0aW9uIChiZXosIEJfcGFydHMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQl90X2N1cnI7CiAgICAgICAgICAgICAgICAgICAgdmFyIEJfdF9kaXN0ID0gWzBdOwogICAgICAgICAgICAgICAgICAgIHZhciBCX3RfcHJldiA9IGJlelswXTsKICAgICAgICAgICAgICAgICAgICB2YXIgc3VtTGVuID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8PSBCX3BhcnRzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2N1cnIgPSBiZXppZXIucShiZXosIGkgLyBCX3BhcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtTGVuICs9IG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChCX3RfY3VyciwgQl90X3ByZXYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2Rpc3QucHVzaChzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgICAgICBCX3RfcHJldiA9IEJfdF9jdXJyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBCX3RfZGlzdCA9IEJfdF9kaXN0Lm1hcCh4ID0+IHggLyBzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBCX3RfZGlzdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaW5kX3QoYmV6LCBwYXJhbSwgdF9kaXN0TWFwLCBCX3BhcnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbk1heCwgbGVuTWluLCB0TWF4LCB0TWluLCB0OwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAxOyBpIDw9IEJfcGFydHM7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW0gPD0gdF9kaXN0TWFwW2ldKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWluID0gKGkgLSAxKSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWF4ID0gaSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5NaW4gPSB0X2Rpc3RNYXBbaSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuTWF4ID0gdF9kaXN0TWFwW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IChwYXJhbSAtIGxlbk1pbikgLyAobGVuTWF4IC0gbGVuTWluKSAqICh0TWF4IC0gdE1pbikgKyB0TWluOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVUYW5nZW50KHBvaW50QSwgcG9pbnRCKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLm5vcm1hbGl6ZShtYXRocy5zdWJ0cmFjdChwb2ludEEsIHBvaW50QikpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgbWF0aHMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB6ZXJvc19YeDJ4Mih4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB6cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoeC0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB6cy5wdXNoKFswLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHpzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgbXVsSXRlbXMoaXRlbXMsIG11bHRpcGxpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggKiBtdWx0aXBsaWVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG11bE1hdHJpeChtMSwgbTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG0xLnJlZHVjZSgoc3VtLCB4MSwgaSkgPT4gc3VtICsgeDEgKiBtMltpXSwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzdWJ0cmFjdChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLm1hcCgoeDEsIGkpID0+IHgxIC0gYXJyMltpXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhZGRBcnJheXMoYXJyMSwgYXJyMikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5tYXAoKHgxLCBpKSA9PiB4MSArIGFycjJbaV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYWRkSXRlbXMoaXRlbXMsIGFkZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICsgYWRkaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc3VtKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5yZWR1Y2UoKHN1bSwgeCkgPT4gc3VtICsgeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkb3QobTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtYXRocy5tdWxNYXRyaXgobTEsIG0yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHZlY3Rvckxlbih2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmh5cG90KC4uLnYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGl2SXRlbXMoaXRlbXMsIGRpdmlzb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggLyBkaXZpc29yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNxdWFyZUl0ZW1zKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICogeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemUodikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXZJdGVtcyh2LCB0aGlzLnZlY3Rvckxlbih2KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgYmV6aWVyIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcShjdHJsUG9seSwgdCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHggPSAxLjAgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgcEEgPSBtYXRocy5tdWxJdGVtcyhjdHJsUG9seVswXSwgdHggKiB0eCAqIHR4KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBCID0gbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMV0sIDMgKiB0eCAqIHR4ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQyA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzJdLCAzICogdHggKiB0ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwRCA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzNdLCB0ICogdCAqIHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWF0aHMuYWRkQXJyYXlzKG1hdGhzLmFkZEFycmF5cyhwQSwgcEIpLCBtYXRocy5hZGRBcnJheXMocEMsIHBEKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBxcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHR4ID0gMS4wIC0gdDsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBBID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMV0sIGN0cmxQb2x5WzBdKSwgMyAqIHR4ICogdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcEIgPSBtYXRocy5tdWxJdGVtcyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVsyXSwgY3RybFBvbHlbMV0pLCA2ICogdHggKiB0KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbM10sIGN0cmxQb2x5WzJdKSwgMyAqIHQgKiB0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5hZGRBcnJheXMocEEsIHBCKSwgcEMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcXByaW1lcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5tdWxJdGVtcyhtYXRocy5hZGRBcnJheXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMl0sIG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzFdLCAyKSksIGN0cmxQb2x5WzBdKSwgNiAqICgxLjAgLSB0KSksIG1hdGhzLm11bEl0ZW1zKG1hdGhzLmFkZEFycmF5cyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVszXSwgbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMl0sIDIpKSwgY3RybFBvbHlbMV0pLCA2ICogdCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZml0Q3VydmU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cy5maXRDdWJpYyA9IGZpdEN1YmljOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuY3JlYXRlVGFuZ2VudCA9IGNyZWF0ZVRhbmdlbnQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25MYXllciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fc3RvcmFnZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM5KTsKICAgICAgICAgICAgICAgIHZhciBfc2NyaXB0aW5nX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjgpOwogICAgICAgICAgICAgICAgdmFyIF94ZmFfbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2OSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHJlY2VpdmVyLCBjbGFzc0NvbnN0cnVjdG9yLCBtZXRob2QpIHsgX2NsYXNzQ2hlY2tQcml2YXRlU3RhdGljQWNjZXNzKHJlY2VpdmVyLCBjbGFzc0NvbnN0cnVjdG9yKTsg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gICBjb25zdCBERUZBVUxUX0ZPTlRfU0laRSA9IDk7CiAgICAgICAgICAgICAgICBjb25zdCBHZXRFbGVtZW50c0J5TmFtZVNldCA9IG5ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRSZWN0RGltcyhyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGg6IHJlY3RbMl0gLSByZWN0WzBdLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQ6IHJlY3RbM10gLSByZWN0WzFdCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25FbGVtZW50RmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGNyZWF0ZShwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YnR5cGUgPSBwYXJhbWV0ZXJzLmRhdGEuYW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoc3VidHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5MSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTGlua0Fubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5URVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5XSURHRVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRUeXBlID0gcGFyYW1ldGVycy5kYXRhLmZpZWxkVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGZpZWxkVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJUeCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFRleHRXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQnRuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbWV0ZXJzLmRhdGEucmFkaW9CdXR0b24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlvQnV0dG9uV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhcmFtZXRlcnMuZGF0YS5jaGVja0JveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2hlY2tib3hXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHVzaEJ1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJDaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT1BVUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRnJlZVRleHRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IExpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVQVJFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgU3F1YXJlQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNJUkNMRToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENpcmNsZUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT0xZTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNBUkVUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2FyZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSW5rQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT046CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQb2x5Z29uQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkhJR0hMSUdIVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEhpZ2hsaWdodEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5VTkRFUkxJTkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVbmRlcmxpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5TVFJJS0VPVVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdHJpa2VPdXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RBTVA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGFtcEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5GSUxFQVRUQUNITUVOVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEZpbGVBdHRhY2htZW50QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXIgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNSZW5kZXJhYmxlID0gaXNSZW5kZXJhYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEgPSBwYXJhbWV0ZXJzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGF5ZXIgPSBwYXJhbWV0ZXJzLmxheWVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2UgPSBwYXJhbWV0ZXJzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSBwYXJhbWV0ZXJzLnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmtTZXJ2aWNlID0gcGFyYW1ldGVycy5saW5rU2VydmljZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZE1hbmFnZXIgPSBwYXJhbWV0ZXJzLmRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbWFnZVJlc291cmNlc1BhdGggPSBwYXJhbWV0ZXJzLmltYWdlUmVzb3VyY2VzUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJGb3JtcyA9IHBhcmFtZXRlcnMucmVuZGVyRm9ybXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRmFjdG9yeSA9IHBhcmFtZXRlcnMuc3ZnRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZSA9IHBhcmFtZXRlcnMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlU2NyaXB0aW5nID0gcGFyYW1ldGVycy5lbmFibGVTY3JpcHRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGFzSlNBY3Rpb25zID0gcGFyYW1ldGVycy5oYXNKU0FjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZWxkT2JqZWN0cyA9IHBhcmFtZXRlcnMuZmllbGRPYmplY3RzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lciA9IHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjcmVhdGVRdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5xdWFkcmlsYXRlcmFscyA9IHRoaXMuX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKGlnbm9yZUJvcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUNvbnRhaW5lcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlnbm9yZUJvcmRlciA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNlY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnNldEF0dHJpYnV0ZSgiZGF0YS1hbm5vdGF0aW9uLWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLm5vUm90YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgibm9yb3RhdGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW2RhdGEucmVjdFswXSwgcGFnZS52aWV3WzNdIC0gZGF0YS5yZWN0WzFdICsgcGFnZS52aWV3WzFdLCBkYXRhLnJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIGRhdGEucmVjdFszXSArIHBhZ2Uudmlld1sxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlnbm9yZUJvcmRlciAmJiBkYXRhLmJvcmRlclN0eWxlLndpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlcldpZHRoID0gYCR7ZGF0YS5ib3JkZXJTdHlsZS53aWR0aH1weGA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBob3Jpem9udGFsUmFkaXVzID0gZGF0YS5ib3JkZXJTdHlsZS5ob3Jpem9udGFsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGljYWxSYWRpdXMgPSBkYXRhLmJvcmRlclN0eWxlLnZlcnRpY2FsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhvcml6b250YWxSYWRpdXMgPiAwIHx8IHZlcnRpY2FsUmFkaXVzID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhZGl1cyA9IGBjYWxjKCR7aG9yaXpvbnRhbFJhZGl1c31weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke3ZlcnRpY2FsUmFkaXVzfXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJSYWRpdXMgPSByYWRpdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMgaW5zdGFuY2VvZiBSYWRpb0J1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFkaXVzID0gYGNhbGMoJHt3aWR0aH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke2hlaWdodH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyUmFkaXVzID0gcmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChkYXRhLmJvcmRlclN0eWxlLnN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLlNPTElEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuREFTSEVEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAiZGFzaGVkIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLkJFVkVMRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBib3JkZXIgc3R5bGU6IGJldmVsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLklOU0VUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuaW1wbGVtZW50ZWQgYm9yZGVyIHN0eWxlOiBpbnNldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuVU5ERVJMSU5FOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyQm90dG9tU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlckNvbG9yID0gZGF0YS5ib3JkZXJDb2xvciB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJvcmRlckNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlckNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoYm9yZGVyQ29sb3JbMF0gfCAwLCBib3JkZXJDb2xvclsxXSB8IDAsIGJvcmRlckNvbG9yWzJdIHwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJXaWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocmVjdFswXSAtIHBhZ2VYKSAvIHBhZ2VXaWR0aH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLnRvcCA9IGAkezEwMCAqIChyZWN0WzFdIC0gcGFnZVkpIC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmhhc093bkNhbnZhcyB8fCByb3RhdGlvbiA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLndpZHRoID0gYCR7MTAwICogd2lkdGggLyBwYWdlV2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogaGVpZ2h0IC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24ocm90YXRpb24sIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Um90YXRpb24oYW5nbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRhaW5lciA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMudmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKHRoaXMuZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRXaWR0aCwgZWxlbWVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuZ2xlICUgMTgwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50V2lkdGggPSAxMDAgKiB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRIZWlnaHQgPSAxMDAgKiBoZWlnaHQgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFdpZHRoID0gMTAwICogaGVpZ2h0IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudEhlaWdodCA9IDEwMCAqIHdpZHRoIC8gcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUud2lkdGggPSBgJHtlbGVtZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5oZWlnaHQgPSBgJHtlbGVtZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc2V0QXR0cmlidXRlKCJkYXRhLW1haW4tcm90YXRpb24iLCAoMzYwIC0gYW5nbGUpICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9jb21tb25BY3Rpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXRDb2xvciA9IChqc05hbWUsIHN0eWxlTmFtZSwgZXZlbnQpID0+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/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1bnBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaGlkZUVsZW1lbnQuaGlkZGVuICYmICF0aGlzLnBpbm5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4ID0gcGFyc2VJbnQodGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4KSAtIDEwMDA7CiAgICAgICAgICAgICAgICAgICAg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AgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0Q29udGVudCA9IHBhcmFtZXRlcnMuZGF0YS50ZXh0Q29udGVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQuY2xhc3NMaXN0LmFkZCgiYW5ub3RhdGlvblRleHRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LnNldEF0dHJpYnV0ZSgicm9sZSIsICJjb21tZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpbmUgb2YgdGhpcy50ZXh0Q29udGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVTcGFuID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVTcGFuLnRleHRDb250ZW50ID0gbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LmFwcGVuZChsaW5lU3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoY29udGVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIExpbmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250MyA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDMuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2gzID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMy5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmxpbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoIngxIiwgZGF0YS5yZWN0WzJdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgieTEiLCBkYXRhLnJlY3RbM10gLSBkYXRhLmxpbmVDb29yZGluYXRlc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmUuc2V0QXR0cmlidXRlKCJ4MiIsIGRhdGEucmVjdFsyXSAtIGRhdGEubGluZUNvb3JkaW5hdGVzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInkyIiwgZGF0YS5yZWN0WzNdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbM10pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInN0cm9rZSIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKGxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobGluZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVhcmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LCBfcGFyYW1ldGVycyRkYXRhJGNvbnQ0LCBfcGFyYW1ldGVycyRkYXRhJHJpY2g0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250NCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250NCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDQuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2g0ID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g0ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNC5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgic3F1YXJlQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZSh3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9yZGVyV2lkdGggPSBkYXRhLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcXVhcmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgieCIsIGJvcmRlcldpZHRoIC8gMik7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInkiLCBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIHdpZHRoIC0gYm9yZGVyV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCBoZWlnaHQgLSBib3JkZXJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInN0cm9rZS13aWR0aCIsIGJvcmRlcldpZHRoIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKHNxdWFyZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChzcXVhcmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQ2lyY2xlQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNSwgX3BhcmFtZXRlcnMkZGF0YSRjb250NSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw1ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw1ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ1LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDUuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNpcmNsZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gZGF0YS5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzplbGxpcHNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImN4Iiwgd2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgiY3kiLCBoZWlnaHQgLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgicngiLCB3aWR0aCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJyeSIsIGhlaWdodCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJzdHJva2Utd2lkdGgiLCBib3JkZXJXaWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChjaXJjbGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAoY2lyY2xlLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNiwgX3BhcmFtZXRlcnMkZGF0YSRjb250NiwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw2ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw2ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ2LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDYuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSA9ICJwb2x5bGluZUFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5bGluZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCh0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBnZXRSZWN0RGltcyhkYXRhLnJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29vcmRpbmF0ZSBvZiBkYXRhLnZlcnRpY2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4ID0gY29vcmRpbmF0ZS54IC0gZGF0YS5yZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHggKyAiLCIgKyB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb2x5bGluZSA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KHRoaXMuc3ZnRWxlbWVudE5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoInBvaW50cyIsIHBvaW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJmaWxsIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAocG9seWxpbmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9seWdvbkFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgUG9seWxpbmVBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAicG9seWdvbkFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5Z29uIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYXJldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAg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zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g4LnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAiaW5rQW5ub3RhdGlvbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRWxlbWVudE5hbWUgPSAic3ZnOnBvbHlsaW5lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKHRoaXMuY29udGFpbmVyQ2xhc3NOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5rTGlzdCBvZiBkYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNvb3JkaW5hdGUgb2YgaW5rTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBjb29yZGluYXRlLnggLSBkYXRhLnJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChgJHt4fSwke3l9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9seWxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCh0aGlzLnN2Z0VsZW1lbnROYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgicG9pbnRzIiwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKHBvbHlsaW5lLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSGlnaGxpZ2h0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOSwgX3BhcmFtZXRlcnMkZGF0YSRjb250OSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw5ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw5ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ5LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDkuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygiaGlnaGxpZ2h0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImhpZ2hsaWdodEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFVuZGVybGluZUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICA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gICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInVuZGVybGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJ1bmRlcmxpbmVBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MTEgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhp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V0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygic3RyaWtlb3V0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0cmlrZW91dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YW1wQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMyA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMy5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0YW1wQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZGF0YS5oYXNQb3B1cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobnVsbCwgdGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgRmlsZUF0dGFjaG1lbnRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmUxMDsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5maWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGVuYW1lID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEZpbGVuYW1lRnJvbVVybCkoZmlsZW5hbWUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnQgPSBjb250ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUxMCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAuZGlzcGF0Y2goImZpbGVhdHRhY2htZW50YW5ub3RhdGlvbiIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSR0aXRsZU9iaiwgX3RoaXMkZGF0YSRjb250ZW50c09iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmaWxlQXR0YWNobWVudEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyaWdnZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuaGFzQXBwZWFyYW5jZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImltZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5zcmMgPSBgJHt0aGlzLmltYWdlUmVzb3VyY2VzUGF0aH1hbm5vdGF0aW9uLSR7L3BhcGVyY2xpcC9pLnRlc3QodGhpcy5kYXRhLm5hbWUpID8gInBhcGVyY2xpcCIgOiAicHVzaHBpbiJ9LnN2Z2A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5jbGFzc0xpc3QuYWRkKCJwb3B1cFRyaWdnZXJBcmVhIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuYWRkRXZlbnRMaXN0ZW5lcigiZGJsY2xpY2siLCB0aGlzLl9kb3dubG9hZC5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXAgJiYgKChfdGhpcyRkYXRhJHRpdGxlT2JqID0gdGhpcy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSR0aXRsZU9iai5zdHIgfHwgKF90aGlzJGRhdGEkY29udGVudHNPYiA9IHRoaXMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iLnN0ciB8fCB0aGlzLmRhdGEucmljaFRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cCh0cmlnZ2VyLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZG93bmxvYWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkb3dubG9hZE1hbmFnZXIyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZG93bmxvYWRNYW5hZ2VyMiA9IHRoaXMuZG93bmxvYWRNYW5hZ2VyKSA9PT0gbnVsbCB8fCBfdGhpcyRkb3dubG9hZE1hbmFnZXIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIyLm9wZW5PckRvd25sb2FkRGF0YSh0aGlzLmNvbnRhaW5lciwgdGhpcy5jb250ZW50LCB0aGlzLmZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlcgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShkaXYsIHZpZXdwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcjogZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlOiBwYXJhbXMubGlua1NlcnZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZE1hbmFnZXI6IHBhcmFtcy5kb3dubG9hZE1hbmFnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWFnZVJlc291cmNlc1BhdGg6IHBhcmFtcy5pbWFnZVJlc291cmNlc1BhdGggfHwgIiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJGb3JtczogcGFyYW1zLnJlbmRlckZvcm1zICE9PSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Z0ZhY3Rvcnk6IG5ldyBfZGlzcGxheV91dGlscy5ET01TVkdGYWN0b3J5KCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogcGFyYW1zLmFubm90YXRpb25TdG9yYWdlIHx8IG5ldyBfYW5ub3RhdGlvbl9zdG9yYWdlLkFubm90YXRpb25TdG9yYWdlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVTY3JpcHRpbmc6IHBhcmFtcy5lbmFibGVTY3JpcHRpbmcgPT09IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnM6IHBhcmFtcy5oYXNKU0FjdGlvbnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZE9iamVjdHM6IHBhcmFtcy5maWVsZE9iamVjdHMKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHpJbmRleCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZGF0YSBvZiBhbm5vdGF0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubm9IVE1MKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5hbm5vdGF0aW9uVHlwZSAhPT0gX3V0aWwuQW5ub3RhdGlvblR5cGUuUE9QVVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggPD0gMCB8fCBoZWlnaHQgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50UGFyYW1zLmRhdGEgPSBkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IEFubm90YXRpb25FbGVtZW50RmFjdG9yeS5jcmVhdGUoZWxlbWVudFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQuaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZW5kZXJlZCA9IGVsZW1lbnQucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5oaWRkZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZW5kZXJlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlbmRlcmVkRWxlbWVudCBvZiByZW5kZXJlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZEVsZW1lbnQuc3R5bGUuekluZGV4ID0gekluZGV4Kys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQoQW5ub3RhdGlvbkxheWVyLCBBbm5vdGF0aW9uTGF5ZXIsIF9hcHBlbmRFbGVtZW50KS5jYWxsKEFubm90YXRpb25MYXllciwgcmVuZGVyZWRFbGVtZW50LCBkYXRhLmlkLCBkaXYsIGFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmVkLnN0eWxlLnpJbmRleCA9IHpJbmRleCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50IGluc3RhbmNlb2YgUG9wdXBBbm5vdGF0aW9uRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucHJlcGVuZChyZW5kZXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChBbm5vdGF0aW9uTGF5ZXIsIEFubm90YXRpb25MYXllciwgX2FwcGVuZEVsZW1lbnQpLmNhbGwoQW5ub3RhdGlvbkxheWVyLCByZW5kZXJlZCwgZGF0YS5pZCwgZGl2LCBhY2Nlc3NpYmlsaXR5TWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQodGhpcywgQW5ub3RhdGlvbkxheWVyLCBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcCkuY2FsbCh0aGlzLCBkaXYsIHBhcmFtcy5hbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGRpdiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHZpZXdwb3J0LnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIEFubm90YXRpb25MYXllciwgX3NldEFubm90YXRpb25DYW52YXNNYXApLmNhbGwodGhpcywgZGl2LCBhbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkxheWVyID0gQW5ub3RhdGlvbkxheWVyOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2FwcGVuZEVsZW1lbnQoZWxlbWVudCwgaWQsIGRpdiwgYWNjZXNzaWJpbGl0eU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50RWxlbWVudCA9IGVsZW1lbnQuZmlyc3RDaGlsZCB8fCBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnRFbGVtZW50LmlkID0gYCR7X2Rpc3BsYXlfdXRpbHMuQW5ub3RhdGlvblByZWZpeH0ke2lkfWA7CiAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gbnVsbCB8fCBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogYWNjZXNzaWJpbGl0eU1hbmFnZXIubW92ZUVsZW1lbnRJbkRPTShkaXYsIGVsZW1lbnQsIGNvbnRlbnRFbGVtZW50LCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcChkaXYsIGFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtpZCwgY2FudmFzXSBvZiBhbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBkaXYucXVlcnlTZWxlY3RvcihgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0Q2hpbGQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlyc3RDaGlsZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hcHBlbmQoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaXJzdENoaWxkLm5vZGVOYW1lID09PSAiQ0FOVkFTIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5yZXBsYWNlV2l0aChjYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5iZWZvcmUoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLmNsZWFyKCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG1ha2VDb2xvckNvbXAobikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmZsb29yKE1hdGgubWF4KDAsIE1hdGgubWluKDEsIG4pKSAqIDI1NSkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvckNvbnZlcnRlcnMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0coX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2MsIHksIG0sIGtdID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiRyIsIDEgLSBNYXRoLm1pbigxLCAwLjMgKiBjICsgMC41OSAqIG0gKyAwLjExICogeSArIGspXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIEdfQ01ZSyhfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCAwLCAwLCAwLCAxIC0gZ107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBHX1JHQihfcmVmMykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIlJHQiIsIGcsIGcsIGddOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgR19IVE1MKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbZ10gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRyA9IG1ha2VDb2xvckNvbXAoZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7R30ke0d9JHtHfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfRyhfcmVmNSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjU7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkciLCAwLjMgKiByICsgMC41OSAqIGcgKyAwLjExICogYl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfSFRNTChfcmVmNikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFIgPSBtYWtlQ29sb3JDb21wKHIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBHID0gbWFrZUNvbG9yQ29tcChnKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQiA9IG1ha2VDb2xvckNvbXAoYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7Un0ke0d9JHtCfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBUX0hUTUwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiIzAwMDAwMDAwIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIENNWUtfUkdCKF9yZWY3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbYywgeSwgbSwga10gPSBfcmVmNzsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiUkdCIiwgMSAtIE1hdGgubWluKDEsIGMgKyBrKSwgMSAtIE1hdGgubWluKDEsIG0gKyBrKSwgMSAtIE1hdGgubWluKDEsIHkgKyBrKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0hUTUwoY29tcG9uZW50cykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZ2IgPSB0aGlzLkNNWUtfUkdCKGNvbXBvbmVudHMpLnNsaWNlKDEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5SR0JfSFRNTChyZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUkdCX0NNWUsoX3JlZjgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtyLCBnLCBiXSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gMSAtIHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAxIC0gZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IDEgLSBiOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrID0gTWF0aC5taW4oYywgbSwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCBjLCBtLCB5LCBrXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IENvbG9yQ29udmVydGVyczsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTY5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+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",s="LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUg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GFzayh0YXNrKTsKICAgICAgICBhd2FpdCBQcm9taXNlLmFsbChbcGRmTWFuYWdlci5sb2FkWGZhRm9udHMoaGFuZGxlciwgdGFzaykuY2F0Y2gocmVhc29uID0+IHt9KS50aGVuKCgpID0+IGZpbmlzaFdvcmtlclRhc2sodGFzaykpLCBwZGZNYW5hZ2VyLmxvYWRYZmFJbWFnZXMoKV0pOwogICAgICB9CiAgICAgIGNvbnN0IFtudW1QYWdlcywgZmluZ2VycHJpbnRzXSA9IGF3YWl0IFByb21pc2UuYWxsKFtwZGZNYW5hZ2VyLmVuc3VyZURvYygibnVtUGFnZXMiKSwgcGRmTWFuYWdlci5lbnN1cmVEb2MoImZpbmdlcnByaW50cyIpXSk7CiAgICAgIGNvbnN0IGh0bWxGb3JYZmEgPSBpc1B1cmVYZmEgPyBhd2FpdCBwZGZNYW5hZ2VyLmVuc3VyZURvYygiaHRtbEZvclhmYSIpIDogbnVsbDsKICAgICAgcmV0dXJuIHsKICAgICAgICBudW1QYWdlcywKICAgICAgICBmaW5nZXJwcmludHMsCiAgICAgICAgaHRtbEZvclhmYQogICAgICB9OwogICAgfQogICAgZnVuY3Rpb24gZ2V0UGRmTWFuYWdlcihfcmVmKSB7CiAgICAgIGxldCB7CiAgICAgICAgZGF0YSwKICAgICAgICBwYXNzd29yZCwKICAgICAgICBkaXNhYmxlQXV0b0ZldGNoLAogICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgIGxlbmd0aCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdWF0b3JPcHRpb25zCiAgICAgIH0gPSBfcmVmOwogICAgICBjb25zdCBwZGZNYW5hZ2VyQXJncyA9IHsKICAgICAgICBzb3VyY2U6IG51bGwsCiAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGRvY0lkLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdW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LCBfY29yZV91dGlscy5hcnJheUJ1ZmZlcnNUb0J5dGVzKShjYWNoZWRDaHVua3MpOwogICAgICAgIGlmIChsZW5ndGggJiYgcGRmRmlsZS5sZW5ndGggIT09IGxlbmd0aCkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJyZXBvcnRlZCBIVFRQIGxlbmd0aCBpcyBkaWZmZXJlbnQgZnJvbSBhY3R1YWwiKTsKICAgICAgICB9CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHBkZk1hbmFnZXJBcmdzLnNvdXJjZSA9IHBkZkZpbGU7CiAgICAgICAgICBuZXdQZGZNYW5hZ2VyID0gbmV3IF9wZGZfbWFuYWdlci5Mb2NhbFBkZk1hbmFnZXIocGRmTWFuYWdlckFyZ3MpOwogICAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVzb2x2ZShuZXdQZGZNYW5hZ2VyKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVqZWN0KGV4KTsKICAgICAgICB9CiAgICAgICAgY2FjaGVkQ2h1bmtzID0gW107CiAgICAgIH07CiAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICBjb25zdCByZWFkQ2h1bmsgPSBmdW5jdGlvbiAoX3JlZjIpIHsKICAgICAgICAgIGxldCB7CiAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICBkb25lCiAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgaWYgKCFuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICBmbHVzaENodW5rcygpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYW5jZWxYSFJzID0gbnVsbDsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgIGlmICghZnVsbFJlcXVlc3QuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICBoYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICAgICAgICAgICAgbG9hZGVkLAogICAgICAgICAgICAgICAgdG90YWw6IE1hdGgubWF4KGxvYWRlZCwgZnVsbFJlcXVlc3QuY29udGVudExlbmd0aCB8fCAwKQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgbmV3UGRmTWFuYWdlci5zZW5kUHJvZ3Jlc3NpdmVEYXRhKHZhbHVlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjYWNoZWRDaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVsbFJlcXVlc3QucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgICB9CiAgICAgICAgfTsKICAgICAgICBmdWxsUmVxdWVzdC5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChlKSB7CiAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVqZWN0KGUpOwogICAgICAgIGNhbmNlbFhIUnMgPSBudWxsOwogICAgICB9KTsKICAgICAgY2FuY2VsWEhScyA9IGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICBwZGZTdHJlYW0uY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKTsKICAgICAgfTsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXJDYXBhYmlsaXR5LnByb21pc2U7CiAgICB9CiAgICBmdW5jdGlvbiBzZXR1cERvYyhkYXRhKSB7CiAgICAgIGZ1bmN0aW9uIG9uU3VjY2Vzcyhkb2MpIHsKICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgaGFuZGxlci5zZW5kKCJHZXREb2MiLCB7CiAgICAgICAgICBwZGZJbmZvOiBkb2MKICAgICAgICB9KTsKICAgICAgfQogICAgICBmdW5jdGlvbiBvbkZhaWx1cmUoZXgpIHsKICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX3V0aWwuUGFzc3dvcmRFeGNlcHRpb24pIHsKICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgUGFzc3dvcmRFeGNlcHRpb246IHJlc3BvbnNlICR7ZXguY29kZX1gKTsKICAgICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJQYXNzd29yZFJlcXVlc3QiLCBleCkudGhlbihmdW5jdGlvbiAoX3JlZjMpIHsKICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICBwYXNzd29yZAogICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgIGZpbmlzaFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgICAgIHBkZk1hbmFnZXIudXBkYXRlUGFzc3dvcmQocGFzc3dvcmQpOwogICAgICAgICAgICBwZGZNYW5hZ2VyUmVhZHkoKTsKICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgICAgaGFuZGxlci5zZW5kKCJEb2NFeGNlcHRpb24iLCBleCk7CiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgX3V0aWwuSW52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w7CiAgICAgICAgaWYgKGlzUHVyZVhmYSkgewogICAgICAgICAgeGZhRGF0YSA9IHJlZnNbMF07CiAgICAgICAgICBpZiAoIXhmYURhdGEpIHsKICAgICAgICAgICAgcmV0dXJuIHN0cmVhbS5ieXRlczsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgbmV3UmVmcyA9IHJlZnMuZmxhdCgyKTsKICAgICAgICAgIGlmIChuZXdSZWZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gc3RyZWFtLmJ5dGVzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb25zdCBuZWVkQXBwZWFyYW5jZXMgPSBhY3JvRm9ybVJlZiAmJiBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgbmV3UmVmcy5zb21lKHJlZiA9PiByZWYubmVlZEFwcGVhcmFuY2VzKTsKICAgICAgICBjb25zdCB4ZmEgPSBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgYWNyb0Zvcm0uZ2V0KCJYRkEiKSB8fCBudWxsOwogICAgICAgIGxldCB4ZmFEYXRhc2V0c1JlZiA9IG51bGw7CiAgICAgICAgbGV0IGhhc1hmYURhdGFzZXRzRW50cnkgPSBmYWxzZTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh4ZmEpKSB7CiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB4ZmEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBpZiAoeGZhW2ldID09PSAiZGF0YXNldHMiKSB7CiAgICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4ZmFbaSArIDFdOwogICAgICAgICAgICAgIGhhc1hmYURhdGFzZXRzRW50cnkgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoeGZhRGF0YXNldHNSZWYgPT09IG51bGwpIHsKICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoeGZhKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIFhGQSB0eXBlLiIpOwogICAgICAgIH0KICAgICAgICBsZXQgbmV3WHJlZkluZm8gPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgIGlmICh4cmVmLnRyYWlsZXIpIHsKICAgICAgICAgIGNvbnN0IGluZm9PYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgY29uc3QgeHJlZkluZm8gPSB4cmVmLnRyYWlsZXIuZ2V0KCJJbmZvIikgfHwgbnVsbDsKICAgICAgICAgIGlmICh4cmVmSW5mbyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgeHJlZkluZm8uZm9yRWFjaCgoa2V5LCB2YWx1ZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBpbmZvT2JqW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgbGFzdFhSZWZTdHJlYW1Qb3MgPSB4cmVmLmxhc3RYUmVmU3RyZWFtUG9zOwogICAgICAgICAgbmV3WHJlZkluZm8gPSB7CiAgICAgICAgICAgIHJvb3RSZWY6IHhyZWYudHJhaWxlci5nZXRSYXcoIlJvb3QiKSB8fCBudWxsLAogICAgICAgICAgICBlbmNyeXB0UmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJFbmNyeXB0IikgfHwgbnVsbCwKICAgICAgICAgICAgbmV3UmVmOiB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpLAogICAgICAgICAgICBpbmZvUmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJJbmZvIikgfHwgbnVsbCwKICAgICAgICAgICAgaW5mbzogaW5mb09iaiwKICAgICAgICAgICAgZmlsZUlkczogeHJlZi50cmFpbGVyLmdldCgiSUQiKSB8fCBudWxsLAogICAgICAgICAgICBzdGFydFhSZWY6IGxhc3RYUmVmU3RyZWFtUG9zID09PSBudWxsID8gc3RhcnRYUmVmIDogbGFzdFhSZWZTdHJlYW1Qb3MsCiAgICAgICAgICAgIGZpbGVuYW1lCiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgcmV0dXJuICgwLCBfd3JpdGVyLmluY3JlbWVudGFsVXBkYXRlKSh7CiAgICAgICAgICAgIG9yaWdpbmFsRGF0YTogc3RyZWFtLmJ5dGVzLAogICAgICAgICAgICB4cmVmSW5mbzogbmV3WHJlZkluZm8sCiAgICAgICAgICAgIG5ld1JlZnMsCiAgICAgICAgICAgIHhyZWYsCiAgICAgICAgICAgIGhhc1hmYTogISF4ZmEsCiAgICAgICAgICAgIHhmYURhdGFzZXRzUmVmLAogICAgICAgICAgICBoYXNYZmFEYXRhc2V0c0VudHJ5LAogICAgICAgICAgICBuZWVkQXBwZWFyYW5jZXMsCiAgICAgICAgICAgIGFjcm9Gb3JtUmVmLAogICAgICAgICAgICBhY3JvRm9ybSwKICAgICAgICAgICAgeGZhRGF0YQogICAgICAgICAgfSk7CiAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgIHhyZWYucmVzZXROZXdUZW1wb3JhcnlSZWYoKTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRPcGVyYXRvckxpc3QiLCBmdW5jdGlvbiAoZGF0YSwgc2luaykgewogICAgICBjb25zdCBwYWdlSW5kZXggPSBkYXRhLnBhZ2VJbmRleDsKICAgICAgcGRmTWFuYWdlci5nZXRQYWdlKHBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgR2V0T3BlcmF0b3JMaXN0OiBwYWdlICR7cGFnZUluZGV4fWApOwogICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICBjb25zdCBzdGFydCA9IHZlcmJvc2l0eSA+PSBfdXRpbC5WZXJib3NpdHlMZXZlbC5JTkZPUyA/IERhdGUubm93KCkgOiAwOwogICAgICAgIHBhZ2UuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIGhhbmRsZXIsCiAgICAgICAgICBzaW5rLAogICAgICAgICAgdGFzaywKICAgICAgICAgIGludGVudDogZGF0YS5pbnRlbnQsCiAgICAgICAgICBjYWNoZUtleTogZGF0YS5jYWNoZUtleSwKICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBkYXRhLmFubm90YXRpb25TdG9yYWdlCiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAob3BlcmF0b3JMaXN0SW5mbykgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldE9wZXJhdG9yTGlzdDogdGltZT1gICsgYCR7RGF0ZS5ub3coKSAtIHN0YXJ0fW1zLCBsZW49JHtvcGVyYXRvckxpc3RJbmZvLmxlbmd0aH1gKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRUZXh0Q29udGVudCIsIGZ1bmN0aW9uIChkYXRhLCBzaW5rKSB7CiAgICAgIGNvbnN0IHBhZ2VJbmRleCA9IGRhdGEucGFnZUluZGV4OwogICAgICBwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgY29uc3QgdGFzayA9IG5ldyBXb3JrZXJUYXNrKCJHZXRUZXh0Q29udGVudDogcGFnZSAiICsgcGFnZUluZGV4KTsKICAgICAgICBzdGFydFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgY29uc3Qgc3RhcnQgPSB2ZXJib3NpdHkgPj0gX3V0aWwuVmVyYm9zaXR5TGV2ZWwuSU5GT1MgPyBEYXRlLm5vdygpIDogMDsKICAgICAgICBwYWdlLmV4dHJhY3RUZXh0Q29udGVudCh7CiAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgdGFzaywKICAgICAgICAgIHNpbmssCiAgICAgICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogZGF0YS5pbmNsdWRlTWFya2VkQ29udGVudCwKICAgICAgICAgIGNvbWJpbmVUZXh0SXRlbXM6IGRhdGEuY29tYmluZVRleHRJdGVtcwogICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldFRleHRDb250ZW50OiB0aW1lPWAgKyBgJHtEYXRlLm5vdygpIC0gc3RhcnR9bXNgKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOw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AgICAgaWYgKHRyYW5zZm9ybVswXSA8IDApIHsKICAgICAgICB0ZW1wID0gbWluTWF4WzBdOwogICAgICAgIG1pbk1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICB9CiAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgIGlmICh0cmFuc2Zvcm1bM10gPCAwKSB7CiAgICAgICAgdGVtcCA9IG1pbk1heFsyXTsKICAgICAgICBtaW5NYXhbMl0gPSBtaW5NYXhbM107CiAgICAgICAgbWluTWF4WzNdID0gdGVtcDsKICAgICAgfQogICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICBtaW5NYXhbM10gKj0gdHJhbnNmb3JtWzNdOwogICAgfSBlbHNlIHsKICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgbWluTWF4WzBdID0gbWluTWF4WzJdOwogICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICB0ZW1wID0gbWluTWF4WzFdOwogICAgICBtaW5NYXhbMV0gPSBtaW5NYXhbM107CiAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgIGlmICh0cmFuc2Zvcm1bMV0gPCAwKSB7CiAgICAgICAgdGVtcCA9IG1pbk1heFsyXTsKICAgICAgICBtaW5NYXhbMl0gPSBtaW5NYXhbM107CiAgICAgICAgbWluTWF4WzNdID0gdGVtcDsKICAgICAgfQogICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICBtaW5NYXhbM10gKj0gdHJhbnNmb3JtWzFdOwogICAgICBpZiAodHJhbnNmb3JtWzJdIDwgMCkgewogICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgbWluTWF4WzBdID0gbWluTWF4WzFdOwogICAgICAgIG1pbk1heFsxXSA9IHRlbXA7CiAgICAgIH0KICAgICAg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9CiAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgIHR2YWx1ZXMucHVzaCh0KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgYjJhYyA9IGIgKiBiIC0gNCAqIGMgKiBhOwogICAgICBzcXJ0YjJhYyA9IE1hdGguc3FydChiMmFjKTsKICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdDEgPSAoLWIgKyBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgIH0KICAgICAgdDIgPSAoLWIgLSBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgIH0KICAgIH0KICAgIGxldCBqID0gdHZhbHVlcy5sZW5ndGgsCiAgICAgIG10OwogICAgY29uc3QgamxlbiA9IGo7CiAgICB3aGlsZSAoai0tKSB7CiAgICAgIHQgPSB0dmFsdWVzW2pdOwogICAgICBtdCA9IDEgLSB0OwogICAgICBib3VuZHNbMF1bal0gPSBtdCAqIG10ICogbXQgKiB4MCArIDMgKiBtdCAqIG10ICogdCAqIHgxICsgMyAqIG10ICogdCAqIHQgKiB4MiArIHQgKiB0ICogdCAqIHgzOwogICAgICBib3VuZHNbMV1bal0gPSBtdCAqIG10ICogbXQgKiB5MCArIDMgKiBtdCAqIG10ICogdCAqIHkxICsgMyAqIG10ICogdCAqIHQgKiB5MiArIHQgKiB0ICogdCAqIHkzOwogICAgfQogICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICBib3VuZHNbMV1bamxlbl0gPSB5MDsKICAgIGJvdW5kc1swXVtqbGVuICsgMV0gPSB4MzsKICAgIGJvdW5k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W5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHZhbHVlc1swXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBzdWJEaWN0ID0gbmV3IERpY3QoeHJlZik7CiAgICAgIGZvciAoY29uc3QgZGljdCBvZiB2YWx1ZXMpIHsKICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBPYmplY3QuZW50cmllcyhkaWN0Ll9tYXApKSB7CiAgICAgICAgICBpZiAoc3ViRGljdC5fbWFwW2tleV0gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBzdWJEaWN0Ll9tYXBba2V5XSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoc3ViRGljdC5zaXplID4gMCkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHN1YkRpY3Q7CiAgICAgIH0KICAgIH0KICAgIHByb3BlcnRpZXMuY2xlYXIoKTsKICAgIHJldHVybiBtZXJnZWREaWN0LnNpemUgPiAwID8gbWVyZ2VkRGljdCA6IERpY3QuZW1wdHk7CiAgfQp9CmV4cG9ydHMuRGljdCA9IERpY3Q7CmNvbnN0IFJlZiA9IGZ1bmN0aW9uIFJlZkNsb3N1cmUoKSB7CiAgbGV0IHJlZkNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICBjbGFzcyBSZWYgewogICAgY29uc3RydWN0b3IobnVtLCBnZW4pIHsKICAgICAgdGhpcy5udW0gPSBudW07CiAgICAgIHRoaXMuZ2VuID0gZ2VuOwogICAgfQogICAgdG9TdHJpbmcoKSB7CiAgICAgIGlmICh0aGlzLmdlbiA9PT0gMCkgewogICAgICAgIHJldHVybiBgJHt0aGlzLm51bX1SYDsKICAgICAgfQogICAgICByZXR1cm4gYCR7dGhpcy5udW19UiR7dGhpcy5nZW59YDsKICAgIH0KICAgIHN0YXRpYyBnZXQobnVtL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3RTdWNjZXNzZnVsRW5zdXJlQnl0ZUNodW5rID0gY2h1bms7CiAgfQogIGVuc3VyZVJhbmdlKGJlZ2luLCBlbmQpIHsKICAgIGlmIChiZWdpbiA+PSBlbmQpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgaWYgKGVuZCA8PSB0aGlzLnByb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBiZWdpbkNodW5rID0gTWF0aC5mbG9vcihiZWdpbiAvIHRoaXMuY2h1bmtTaXplKTsKICAgIGlmIChiZWdpbkNodW5rID4gdGhpcy5udW1DaHVua3MpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgZW5kQ2h1bmsgPSBNYXRoLm1pbihNYXRoLmZsb29yKChlbmQgLSAxKSAvIHRoaXMuY2h1bmtTaXplKSArIDEsIHRoaXMubnVtQ2h1bmtzKTsKICAgIGZvciAobGV0IGNodW5rID0gYmVnaW5DaHVuazsgY2h1bmsgPCBlbmRDaHVuazsgKytjaHVuaykgewogICAgICBpZiAoIXRoaXMuX2xvYWRlZENodW5rcy5oYXMoY2h1bmspKSB7CiAgICAgICAgdGhyb3cgbmV3IF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKGJlZ2luLCBlbmQpOwogICAgICB9CiAgICB9CiAgfQogIG5leHRFbXB0eUNodW5rKGJlZ2luQ2h1bmspIHsKICAgIGNvbnN0IG51bUNodW5rcyA9IHRoaXMubnVtQ2h1bmtzOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBudW1DaHVua3M7ICsraSkgewogICAgICBjb25zdCBjaHVuayA9IChiZWdpbkNodW5rICsgaSkgJSBudW1DaHVua3M7CiAgICAgIGlmICghdGhpcy5fbG9hZGVkQ2h1bmtzLmhhcyhjaHVuaykpIHsKICAgICAgICByZXR1cm4gY2h1bms7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBudWxsOwogIH0KICBoYXNDaHVu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iAgICBpZiAoIXJhbmdlUmVhZGVyLmlzU3RyZWFtaW5nU3VwcG9ydGVkKSB7CiAgICAgIHJhbmdlUmVhZGVyLm9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MuYmluZCh0aGlzKTsKICAgIH0KICAgIGxldCBjaHVua3MgPSBbXSwKICAgICAgbG9hZGVkID0gMDsKICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgIGNvbnN0IHJlYWRDaHVuayA9IF9yZWYgPT4gewogICAgICAgIGxldCB7CiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRvbmUKICAgICAgICB9ID0gX3JlZjsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgY29uc3QgY2h1bmtEYXRhID0gKDAsIF9jb3JlX3V0aWxzLmFycmF5QnVmZmVyc1RvQnl0ZXMpKGNodW5rcyk7CiAgICAgICAgICAgIGNodW5rcyA9IG51bGw7CiAgICAgICAgICAgIHJlc29sdmUoY2h1bmtEYXRhKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICBpZiAocmFuZ2VSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgdGhpcy5vblByb2dyZXNzKHsKICAgICAgICAgICAgICBsb2FkZWQKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgICBjaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICByYW5nZVJlYWRlci5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4ocmVhZENodW5rL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5kQ2h1bms7ICsrY2h1bmspIHsKICAgICAgICBpZiAoIWNodW5rc1RvUmVxdWVzdC5pbmNsdWRlcyhjaHVuaykpIHsKICAgICAgICAgIGNodW5rc1RvUmVxdWVzdC5wdXNoKGNodW5rKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNodW5rc1RvUmVxdWVzdC5zb3J0KGZ1bmN0aW9uIChhLCBiKSB7CiAgICAgIHJldHVybiBhIC0gYjsKICAgIH0pOwogICAgcmV0dXJuIHRoaXMuX3JlcXVlc3RDaHVua3MoY2h1bmtzVG9SZXF1ZXN0KTsKICB9CiAgZ3JvdXBDaHVua3MoY2h1bmtzKSB7CiAgICBjb25zdCBncm91cGVkQ2h1bmtzID0gW107CiAgICBsZXQgYmVnaW5DaHVuayA9IC0xOwogICAgbGV0IHByZXZDaHVuayA9IC0xOwogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2h1bmtzLmxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgY2h1bmsgPSBjaHVua3NbaV07CiAgICAgIGlmIChiZWdpbkNodW5rIDwgMCkgewogICAgICAgIGJlZ2luQ2h1bmsgPSBjaHVuazsKICAgICAgfQogICAgICBpZiAocHJldkNodW5rID49IDAgJiYgcHJldkNodW5rICsgMSAhPT0gY2h1bmspIHsKICAgICAgICBncm91cGVkQ2h1bmtzLnB1c2goewogICAgICAgICAgYmVnaW5DaHVuaywKICAgICAgICAgIGVuZENodW5rOiBwcmV2Q2h1bmsgKyAxCiAgICAgICAgfSk7CiAgICAgICAgYmVnaW5DaHVuayA9IGNodW5rOwogICAgICB9CiAgICAgIGlmIChpICsgMSA9PT0gY2h1bmtzLmxlbmd0aCkgewogICAgICAgIGdyb3VwZWRDaHVua3MucHVzaCh7CiAgICAgICAgICBiZWdpbkNodW5rLAogICAgICAgICAgZW5kQ2h1bms6IGNodW5rICsgMQogICAgICAgIH0pOwogICAgICB9CiAgICAgIHByZXZDaHVuayA9IGNodW5rOwog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AgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1lZGlhQm94IiwgdGhpcy5fZ2V0Qm91bmRpbmdCb3goIk1lZGlhQm94IikgfHwgTEVUVEVSX1NJWkVfTUVESUFCT1gpOwogIH0KICBnZXQgY3JvcEJveCgpIHsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiY3JvcEJveCIsIHRoaXMuX2dldEJvdW5kaW5nQm94KCJDcm9wQm94IikgfHwgdGhpcy5tZWRpYUJveCk7CiAgfQogIGdldCB1c2VyVW5pdCgpIHsKICAgIGxldCBvYmogPSB0aGlzLnBhZ2VEaWN0LmdldCgiVXNlclVuaXQiKTsKICAgIGlmICh0eXBlb2Ygb2JqICE9PSAibnVtYmVyIiB8fCBvYmogPD0gMCkgewogICAgICBvYmogPSBERUZBVUxUX1VTRVJfVU5JVDsKICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAidXNlclVuaXQiLCBvYmopOwogIH0KICBnZXQgdmlldygpIHsKICAgIGNvbnN0IHsKICAgICAgY3JvcEJveCwKICAgICAgbWVkaWFCb3gKICAgIH0gPSB0aGlzOwogICAgaWYgKGNyb3BCb3ggIT09IG1lZGlhQm94ICYmICEoMCwgX3V0aWwuaXNBcnJheUVxdWFsKShjcm9wQm94LCBtZWRpYUJveCkpIHsKICAgICAgY29uc3QgYm94ID0gX3V0aWwuVXRpbC5pbnRlcnNlY3QoY3JvcEJveCwgbWVkaWFCb3gpOwogICAgICBpZiAoYm94ICYmIGJveFsyXSAtIGJveFswXSA+IDAgJiYgYm94WzNdIC0gYm94WzFdID4gMCkgewogICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAidmlldyIsIGJveCk7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKCJFbXB0eSAvQ3JvcEJveCBhbmQgL01lZGlhQm94IGludGVyc2VjdGlvbi4iKTsKICAgIH0KICAgI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F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJzYXZlIC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChuZXdSZWZzUHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG5ld1JlZnMpIHsKICAgICAgICByZXR1cm4gbmV3UmVmcy5maWx0ZXIobmV3UmVmID0+ICEhbmV3UmVmKTsKICAgICAgfSk7CiAgICB9KTsKICB9CiAgbG9hZFJlc291cmNlcyhrZXlzKSB7CiAgICBpZiAoIXRoaXMucmVzb3VyY2VzUHJvbWlzZSkgewogICAgICB0aGlzLnJlc291cmNlc1Byb21pc2UgPSB0aGlzLnBkZk1hbmFnZXIuZW5zdXJlKHRoaXMsICJyZXNvdXJjZXMiKTsKICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlc1Byb21pc2UudGhlbigoKSA9PiB7CiAgICAgIGNvbnN0IG9iamVjdExvYWRlciA9IG5ldyBfb2JqZWN0X2xvYWRlci5PYmplY3RMb2FkZXIodGhpcy5yZXNvdXJjZXMsIGtleXMsIHRoaXMueHJlZik7CiAgICAgIHJldHVybiBvYmplY3RMb2FkZXIubG9hZCgpOwogICAgfSk7CiAgfQogIGdldE9wZXJhdG9yTGlzdChfcmVmMikgewogICAgbGV0IHsKICAgICAgaGFuZGxlciwKICAgICAgc2luaywKICAgICAgdGFzaywKICAgICAgaW50ZW50LAogICAgICBjYWNoZUtleSwKICAgICAgYW5ub3RhdGlvblN0b3JhZ2UgPSBudWxsCiAgICB9ID0gX3JlZjI7CiAgICBjb25zdCBjb250ZW50U3RyZWFtUHJvbWlzZSA9IHRoaXMuZ2V0Q29udGVudFN0cmVhbSgpOwogICAg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CBpbnRlbnREaXNwbGF5ICYmIGFubm90YXRpb24ubXVzdEJlVmlld2VkKGFubm90YXRpb25TdG9yYWdlKSB8fCBpbnRlbnRQcmludCAmJiBhbm5vdGF0aW9uLm11c3RCZVByaW50ZWQoYW5ub3RhdGlvblN0b3JhZ2UpKSB7CiAgICAgICAgICBvcExpc3RQcm9taXNlcy5wdXNoKGFubm90YXRpb24uZ2V0T3BlcmF0b3JMaXN0KHBhcnRpYWxFdmFsdWF0b3IsIHRhc2ssIGludGVudCwgcmVuZGVyRm9ybXMsIGFubm90YXRpb25TdG9yYWdlKS5jYXRjaChmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgIG9wTGlzdDogbnVsbCwKICAgICAgICAgICAgICBzZXBhcmF0ZUZvcm06IGZhbHNlLAogICAgICAgICAgICAgIHNlcGFyYXRlQ2FudmFzOiBmYWxzZQogICAgICAgICAgICB9OwogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwob3BMaXN0UHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG9wTGlzdHMpIHsKICAgICAgICBsZXQgZm9ybSA9IGZhbHNlLAogICAgICAgICAgY2FudmFzID0gZmFsc2U7CiAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICBvcExpc3QsCiAgICAgICAgICBzZXBhcmF0ZUZvcm0sCiAgICAgICAgICBzZXBhcmF0ZUNhbnZhcwogICAgICAgIH0gb2Ygb3BMaXN0cykgewogICAgICAgICAgcGFnZU9wTGlzdC5hZGRPcExpc3Qob3BMaXN0KTsKICAgICAgICAgIGlmIChzZXBhcmF0ZUZvcm0pIHsKICAgICAgICAgICAgZm9ybSA9IHNlcGFyYXRlRm9ybTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzZXBhcmF0ZUNhbnZhcykgewogICAgICAgICAgICBjYW52YXMgPSBzZXBhcmF0ZUNhbnZhczsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcGFnZU9wTGlzdC5mbHVzaCh0cnVlLCB7CiAgICAgICAgICBmb3JtLAogICAgICAgICAgY2FudmFzCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGxlbmd0aDogcGFnZU9wTGlzdC50b3RhbExlbmd0aAogICAgICAgIH07CiAgICAgIH0pOwogICAgfSk7CiAgfQogIGV4dHJhY3RUZXh0Q29udGVudChfcmVmNSkgewogICAgbGV0IHsKICAgICAgaGFuZGxlciwKICAgICAgdGFzaywKICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQsCiAgICAgIHNpbmssCiAgICAgIGNvbWJpbmVUZXh0SXRlbXMKICAgIH0gPSBfcmVmNTsKICAgIGNvbnN0IGNvbnRlbnRTdHJlYW1Qcm9taXNlID0gdGhpcy5nZXRDb250ZW50U3RyZWFtKCk7CiAgICBjb25zdCByZXNvdXJjZXNQcm9taXNlID0gdGhpcy5sb2FkUmVzb3VyY2VzKFsiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUHJvcGVydGllcyIsICJYT2JqZWN0Il0pOwogICAgY29uc3QgZGF0YVByb21pc2VzID0gUHJvbWlzZS5hbGwoW2NvbnRlbnRTdHJlYW1Qcm9taXNlLCByZXNvdXJjZXNQcm9taXNlXSk7CiAgICByZXR1cm4gZGF0YVByb21pc2VzLnRoZW4oX3JlZjYgPT4gewogICAgICBsZXQgW2NvbnRlbnRTdHJlYW1dID0gX3JlZjY7CiAgICAgIGNvbnN0IHBhcnRpYWxFdmFsdWF0b3IgPSBuZXcgX2V2YWx1YXRvci5QYXJ0aWFsRXZhbHVhdG9yKHsKICAgICAgICB4cmVm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9uIChhbm5vdGF0aW9ucykgewogICAgICAgIGlmIChhbm5vdGF0aW9ucy5sZW5ndGggPT09IDApIHsKICAgICAgICAgIHJldHVybiBhbm5vdGF0aW9uczsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc29ydGVkQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICBsZXQgcG9wdXBBbm5vdGF0aW9uczsKICAgICAgICBmb3IgKGNvbnN0IGFubm90YXRpb24gb2YgYW5ub3RhdGlvbnMpIHsKICAgICAgICAgIGlmICghYW5ub3RhdGlvbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhbm5vdGF0aW9uIGluc3RhbmNlb2YgX2Fubm90YXRpb24uUG9wdXBBbm5vdGF0aW9uKSB7CiAgICAgICAgICAgIGlmICghcG9wdXBBbm5vdGF0aW9ucykgewogICAgICAgICAgICAgIHBvcHVwQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3B1cEFubm90YXRpb25zLnB1c2goYW5ub3RhdGlvbik7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgc29ydGVkQW5ub3RhdGlvbnMucHVzaChhbm5vdGF0aW9uKTsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcHVwQW5ub3RhdGlvbnMpIHsKICAgICAgICAgIHNvcnRlZEFubm90YXRpb25zLnB1c2goLi4ucG9wdXBBbm5vdGF0aW9ucyk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzb3J0ZWRBbm5vdGF0aW9uczsKICAgICAgfSk7CiAgICB9KTsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX3BhcnNlZEFubm90YXRpb25zIiwgcGFyc2VkQW5ub3RhdGlvbnMpOwogIH0KICBnZXQganNBY3Rpb25zKCkgewogICAgY29uc3QgYWN0aW9ucyA9ICgwLCBfY29yZV91dGlscy5jb2xsZWN0QWN0aW9ucyk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9IHN0cmVhbS5lbmQ7CiAgICAgIHdoaWxlICghZm91bmQgJiYgcG9zID4gMCkgewogICAgICAgIHBvcyAtPSBzdGVwIC0gc3RhcnRYUmVmTGVuZ3RoOwogICAgICAgIGlmIChwb3MgPCAwKSB7CiAgICAgICAgICBwb3MgPSAwOwogICAgICAgIH0KICAgICAgICBzdHJlYW0ucG9zID0gcG9zOwogICAgICAgIGZvdW5kID0gZmluZChzdHJlYW0sIFNUQVJUWFJFRl9TSUdOQVRVUkUsIHN0ZXAsIHRydWUpOwogICAgICB9CiAgICAgIGlmIChmb3VuZCkgewogICAgICAgIHN0cmVhbS5za2lwKDkpOwogICAgICAgIGxldCBjaDsKICAgICAgICBkbyB7CiAgICAgICAgICBjaCA9IHN0cmVhbS5nZXRCeXRlKCk7CiAgICAgICAgfSB3aGlsZSAoKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpKTsKICAgICAgICBsZXQgc3RyID0gIiI7CiAgICAgICAgd2hpbGUgKGNoID49IDB4MjAgJiYgY2ggPD0gMHgzOSkgewogICAgICAgICAgc3RyICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgICAgICAgY2ggPSBzdHJlYW0uZ2V0Qnl0ZSgpOwogICAgICAgIH0KICAgICAgICBzdGFydFhSZWYgPSBwYXJzZUludChzdHIsIDEwKTsKICAgICAgICBpZiAoaXNOYU4oc3RhcnRYUmVmKSkgewogICAgICAgICAgc3RhcnRYUmVmID0gMDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAic3RhcnRYUmVmIiwgc3RhcnRYUmVmKTsKICB9CiAgY2hlY2tIZWFkZXIoKSB7CiAgICBjb25zdCBzdHJlYW0gPSB0aGlzLnN0cmVhbTsKICAgIHN0cmVhbS5yZXNldCgpOwogICAgaWYgKCFmaW5kKHN0cmVhbSwgUERGX0hFQURFUl9TSUdOQVRVUkUpKSB7Ci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BpaSAtIDIpIHsKICAgICAgICBuYW1lID0gIi94ZHA6eGRwIjsKICAgICAgfSBlbHNlIHsKICAgICAgICBuYW1lID0geGZhW2ldOwogICAgICB9CiAgICAgIGlmICghZW50cmllcy5oYXNPd25Qcm9wZXJ0eShuYW1lKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZih4ZmFbaSArIDFdKTsKICAgICAgaWYgKCEoZGF0YSBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB8fCBkYXRhLmlzRW1wdHkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBlbnRyaWVzW25hbWVdID0gZGF0YTsKICAgIH0KICAgIHJldHVybiBlbnRyaWVzOwogIH0KICBnZXQgeGZhRGF0YXNldHMoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbnVsbCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImRhdGFzZXRzIiwgInhkcDp4ZHAiXSkgewogICAgICBjb25zdCBzdHJlYW0gPSBzdHJlYW1zW2tleV07CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBzdHIgPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICAgIGNvbnN0IGRhdGEgPSB7CiAgICAgICAgICBba2V5XTogc3RyCiAgICAgICAgfTsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbmV3IF9kYXRhc2V0X3JlYWRlci5EYXRhc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ICAgZm9udENhY2hlOiB0aGlzLmNhdGFsb2cuZm9udENhY2hlLAogICAgICBidWlsdEluQ01hcENhY2hlOiB0aGlzLmNhdGFsb2cuYnVpbHRJbkNNYXBDYWNoZSwKICAgICAgc3RhbmRhcmRGb250RGF0YUNhY2hlOiB0aGlzLmNhdGFsb2cuc3RhbmRhcmRGb250RGF0YUNhY2hlLAogICAgICBvcHRpb25zCiAgICB9KTsKICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgIGNvbnN0IHBkZkZvbnRzID0gW107CiAgICBjb25zdCBpbml0aWFsU3RhdGUgPSB7CiAgICAgIGdldCBmb250KCkgewogICAgICAgIHJldHVybiBwZGZGb250cy5hdCgtMSk7CiAgICAgIH0sCiAgICAgIHNldCBmb250KGZvbnQpIHsKICAgICAgICBwZGZGb250cy5wdXNoKGZvbnQpOwogICAgICB9LAogICAgICBjbG9uZSgpIHsKICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfQogICAgfTsKICAgIGNvbnN0IGZvbnRzID0gbmV3IE1hcCgpOwogICAgZm9udFJlcy5mb3JFYWNoKChmb250TmFtZSwgZm9udCkgPT4gewogICAgICBmb250cy5zZXQoZm9udE5hbWUsIGZvbnQpOwogICAgfSk7CiAgICBjb25zdCBwcm9taXNlcyA9IFtdOwogICAgZm9yIChjb25zdCBbZm9udE5hbWUsIGZvbnRdIG9mIGZvbnRzKSB7CiAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSBmb250LmdldCgiRm9udERlc2NyaXB0b3IiKTsKICAgICAgaWYgKCEoZGVzY3JpcHRvciBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbGV0IGZvbnRGYW1pbHkgPSBkZXNjcmlwdG9yLmdldCgiRm9udEZhbWlseSIpOwogICAgICBmb250RmFtaWx5ID0gZm9udEZhbWlseS5yZXBsYWNlQWxsKC9bIF0rKFxkKS9nLCAiJDEiKTsKICAgICAgY29uc3QgZm9udFdlaWdodCA9IGRlc2NyaXB0b3IuZ2V0KCJGb250V2VpZ2h0Iik7CiAgICAgIGNvbnN0IGl0YWxpY0FuZ2xlID0gLWRlc2NyaXB0b3IuZ2V0KCJJdGFsaWNBbmdsZSIpOwogICAgICBjb25zdCBjc3NGb250SW5mbyA9IHsKICAgICAgICBmb250RmFtaWx5LAogICAgICAgIGZvbnRXZWlnaHQsCiAgICAgICAgaXRhbGljQW5nbGUKICAgICAgfTsKICAgICAgaWYgKCEoMCwgX2NvcmVfdXRpbHMudmFsaWRhdGVDU1NGb250KShjc3NGb250SW5mbykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBwcm9taXNlcy5wdXNoKHBhcnRpYWxFdmFsdWF0b3IuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIFtfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSksIDFdLCBudWxsLCBvcGVyYXRvckxpc3QsIHRhc2ssIGluaXRpYWxTdGF0ZSwgbnVsbCwgY3NzRm9udEluZm8pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGxvYWRYZmFGb250czogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0pKTsKICAgIH0KICAgIGF3YWl0IFByb21pc2UuYWxsKHByb21pc2VzKTsKICAgIGNvbnN0IG1pc3NpbmdGb250cyA9IHRoaXMueGZhRmFjdG9yeS5zZXRGb250cyhwZGZGb250cyk7CiAgICBpZiAoIW1pc3NpbmdGb250cykgewogICAgICByZXR1cm47CiAgICB9CiAgICBvcHRpb25zLmlnbm9yZUVycm9ycyA9IHRydWU7CiAgICBwcm9taXNlcy5sZW5ndGggPSAwOwogICAgcGRmRm9udHMubGVuZ3RoID0gMDsKICAgIGNvbnN0IHJlYWxseU1pc3NpbmdGb250cyA9IG5ldyBTZXQoKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiBtaXNzaW5nRm9udHMpIHsKICAgICAgaWYgKCEoMCwgX3hmYV9mb250cy5nZXRYZmFGb250TmFtZSkoYCR7bWlzc2luZ30tUmVndWxhcmApKSB7CiAgICAgICAgcmVhbGx5TWlzc2luZ0ZvbnRzLmFkZChtaXNzaW5nKTsKICAgICAgfQogICAgfQogICAgaWYgKHJlYWxseU1pc3NpbmdGb250cy5zaXplKSB7CiAgICAgIG1pc3NpbmdGb250cy5wdXNoKCJQZGZKUy1GYWxsYmFjayIpOwogICAgfQogICAgZm9yIChjb25zdCBtaXNzaW5nIG9mIG1pc3NpbmdGb250cykgewogICAgICBpZiAocmVhbGx5TWlzc2luZ0ZvbnRzLmhhcyhtaXNzaW5nKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAoY29uc3QgZm9udEluZm8gb2YgW3sKICAgICAgICBuYW1lOiAiUmVndWxhciIsCiAgICAgICAgZm9udFdlaWdodDogNDAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZCIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiSXRhbGljIiwKICAgICAgICBmb250V2VpZ2h0OiA0MDAsCiAgICAgICAgaXRhbGljQW5nbGU6IDEyCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZEl0YWxpYyIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAxMgogICAgICB9XSkgewogICAgICAgIGNvbnN0IG5hbWUgPSBgJHttaXNzaW5nfS0ke2ZvbnRJbmZvLm5hbWV9YDsKICAgICAgICBjb25zdCBkaWN0ID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udERpY3Q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ewogICAgICAgIHRocm93IGVycjsKICAgICAgfQogICAgICAoMCwgX3V0aWwuaW5mbykoIlRoZSBkb2N1bWVudCBpbmZvcm1hdGlvbiBkaWN0aW9uYXJ5IGlzIGludmFsaWQuIik7CiAgICB9CiAgICBpZiAoIShpbmZvRGljdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiZG9jdW1lbnRJbmZvIiwgZG9jSW5mbyk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBpbmZvRGljdC5nZXRLZXlzKCkpIHsKICAgICAgY29uc3QgdmFsdWUgPSBpbmZvRGljdC5nZXQoa2V5KTsKICAgICAgc3dpdGNoIChrZXkpIHsKICAgICAgICBjYXNlICJUaXRsZSI6CiAgICAgICAgY2FzZSAiQXV0aG9yIjoKICAgICAgICBjYXNlICJTdWJqZWN0IjoKICAgICAgICBjYXNlICJLZXl3b3JkcyI6CiAgICAgICAgY2FzZSAiQ3JlYXRvciI6CiAgICAgICAgY2FzZSAiUHJvZHVjZXIiOgogICAgICAgIGNhc2UgIkNyZWF0aW9uRGF0ZSI6CiAgICAgICAgY2FzZSAiTW9kRGF0ZSI6CiAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAic3RyaW5nIikgewogICAgICAgICAgICBkb2NJbmZvW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJUcmFwcGVkIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgZG9jSW5mb1trZXldID0gdmFsdWU7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGxldCBjdXN0b21WYWx1ZTsKICAgICAgICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7CiAgICAgICAgICAgIGNhc2UgInN0cmluZyI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAibnVtYmVyIjoKICAgICAgICAgICAgY2FzZSAiYm9vbGVhbiI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBjdXN0b21WYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjdXN0b21WYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQmFkIHZhbHVlLCBmb3IgY3VzdG9tIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCFkb2NJbmZvLkN1c3RvbSkgewogICAgICAgICAgICBkb2NJbmZvLkN1c3RvbSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICB9CiAgICAgICAgICBkb2NJbmZvLkN1c3RvbVtrZXldID0gY3VzdG9tVmFsdWU7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYEJhZCB2YWx1ZSwgZm9yIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7Ci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VGb250UmVmLAogICAgICAgICAgICAgIGRhdGE6IGJ1ZmZlci5qb2luKCIiKQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHByb21pc2VzLnB1c2goRnJlZVRleHRBbm5vdGF0aW9uLmNyZWF0ZU5ld0Fubm90YXRpb24oeHJlZiwgYW5ub3RhdGlvbiwgZGVwZW5kZW5jaWVzLCB7CiAgICAgICAgICAgIGV2YWx1YXRvciwKICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgYmFzZUZvbnRSZWYKICAgICAgICAgIH0pKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LOgogICAgICAgICAgcHJvbWlzZXMucHVzaChJbmtBbm5vdGF0aW9uLmNyZWF0ZU5ld0Fubm90YXRpb24oeHJlZiwgYW5ub3RhdGlvbiwgZGVwZW5kZW5jaWVzKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB7CiAgICAgIGFubm90YXRpb25zOiBhd2FpdCBQcm9taXNlLmFsbChwcm9taXNlcyksCiAgICAgIGRlcGVuZGVuY2llcwogICAgfTsKICB9CiAgc3RhdGljIGFzeW5jIHByaW50TmV3QW5ub3RhdGlvbnMoZXZhbHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9ucykgewogICAgaWYgKCFhbm5vdGF0aW9ucykgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IHhyZWYgPSBldmFsdWF0b3IueHJlZjsKICAgIGNvbnN0IHsKICAgICAgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQKICAgIH0gPSBldmFsdWF0b3Iub3B0aW9uczsKICAgIGNvbnN0IHByb21pc2VzID0gW107CiAgICBmb3IgKGNvbnN0IGFubm90YXRpb24gb2YgYW5ub3RhdGlvbnMpIHsKICAgICAgc3dpdGNoIChhbm5vdGF0aW9uLmFubm90YXRpb25UeXBlKSB7CiAgICAgICAgY2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bWF4WCA9IC1JbmZpbml0eSwKICAgICAgbWluWSA9IEluZmluaXR5LAogICAgICBtYXhZID0gLUluZmluaXR5OwogICAgZm9yIChsZXQgaiA9IGkgKiA4LCBqaiA9IGkgKiA4ICsgODsgaiA8IGpqOyBqICs9IDIpIHsKICAgICAgY29uc3QgeCA9IHF1YWRQb2ludHNbal07CiAgICAgIGNvbnN0IHkgPSBxdWFkUG9pbnRzW2ogKyAxXTsKICAgICAgbWluWCA9IE1hdGgubWluKHgsIG1pblgpOwogICAgICBtYXhYID0gTWF0aC5tYXgoeCwgbWF4WCk7CiAgICAgIG1pblkgPSBNYXRoLm1pbih5LCBtaW5ZKTsKICAgICAgbWF4WSA9IE1hdGgubWF4KHksIG1heFkpOwogICAgfQogICAgaWYgKHJlY3QgIT09IG51bGwgJiYgKG1pblggPCByZWN0WzBdIHx8IG1heFggPiByZWN0WzJdIHx8IG1pblkgPCByZWN0WzFdIHx8IG1heFkgPiByZWN0WzNdKSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIHF1YWRQb2ludHNMaXN0cy5wdXNoKFt7CiAgICAgIHg6IG1pblgsCiAgICAgIHk6IG1heFkKICAgIH0sIHsKICAgICAgeDogbWF4WCwKICAgICAgeTogbWF4WQogICAgfSwgewogICAgICB4OiBtaW5YLAogICAgICB5OiBtaW5ZCiAgICB9LCB7CiAgICAgIHg6IG1heFgsCiAgICAgIHk6IG1pblkKICAgIH1dKTsKICB9CiAgcmV0dXJuIHF1YWRQb2ludHNMaXN0czsKfQpmdW5jdGlvbiBnZXRUcmFuc2Zvcm1NYXRyaXgocmVjdCwgYmJveCwgbWF0cml4KSB7CiAgY29uc3QgW21pblgsIG1pblksIG1heFgsIG1heFldID0gX3V0aWwuVXRpbC5nZXRBeGlhbEFsaWduZWRCb3VuZGluZ0JveChiYm94LCBtYXRyaXgpOwogIGlmIChtaW5YID09PSBtYXhYIHx8IG1pblkgPT09IG1heFkpIHsKICAgIHJldHVybiBbMSwgMCwgMC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XMubGluZUVuZGluZ3MgPSBbIk5vbmUiLCAiTm9uZSJdOwogICAgaWYgKEFycmF5LmlzQXJyYXkobGluZUVuZGluZ3MpICYmIGxpbmVFbmRpbmdzLmxlbmd0aCA9PT0gMikgewogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7IGkrKykgewogICAgICAgIGNvbnN0IG9iaiA9IGxpbmVFbmRpbmdzW2ldOwogICAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBzd2l0Y2ggKG9iai5uYW1lKSB7CiAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBjYXNlICJTcXVhcmUiOgogICAgICAgICAgICBjYXNlICJDaXJjbGUiOgogICAgICAgICAgICBjYXNlICJEaWFtb25kIjoKICAgICAgICAgICAgY2FzZSAiT3BlbkFycm93IjoKICAgICAgICAgICAgY2FzZSAiQ2xvc2VkQXJyb3ciOgogICAgICAgICAgICBjYXNlICJCdXR0IjoKICAgICAgICAgICAgY2FzZSAiUk9wZW5BcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlJDbG9zZWRBcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlNsYXNoIjoKICAgICAgICAgICAgICB0aGlzLmxpbmVFbmRpbmdzW2ldID0gb2JqLm5hbWU7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3JpbmcgaW52YWxpZCBsaW5lRW5kaW5nOiAke29ian1gKTsKICAgICAgfQogICAgfQogIH0KICBzZXRSb3RhdGlvbihtaykgewogICAgdGhpcy5yb3RhdGlvbiA9IDA7CiAgICBpZiAobWsgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGxldCBhbmdsZSA9IG1rLmdldCgiUiIpIHx8IDA7CiAgICAgIGlmIChOd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yY2VzKFsiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUHJvcGVydGllcyIsICJYT2JqZWN0Il0sIHRoaXMuYXBwZWFyYW5jZSk7CiAgICBjb25zdCB0ZXh0ID0gW107CiAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgIGNvbnN0IHNpbmsgPSB7CiAgICAgIGRlc2lyZWRTaXplOiBNYXRoLkluZmluaXR5LAogICAgICByZWFkeTogdHJ1ZSwKICAgICAgZW5xdWV1ZShjaHVuaywgc2l6ZSkgewogICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBjaHVuay5pdGVtcykgewogICAgICAgICAgYnVmZmVyLnB1c2goaXRlbS5zdHIpOwogICAgICAgICAgaWYgKGl0ZW0uaGFzRU9MKSB7CiAgICAgICAgICAgIHRleHQucHVzaChidWZmZXIuam9pbigiIikpOwogICAgICAgICAgICBidWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgICBhd2FpdCBldmFsdWF0b3IuZ2V0VGV4dENvbnRlbnQoewogICAgICBzdHJlYW06IHRoaXMuYXBwZWFyYW5jZSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogdHJ1ZSwKICAgICAgY29tYmluZVRleHRJdGVtczogdHJ1ZSwKICAgICAgc2luaywKICAgICAgdmlld0JveAogICAgfSk7CiAgICB0aGlzLnJlc2V0KCk7CiAgICBpZiAoYnVmZmVyLmxlbmd0aCkgewogICAgICB0ZXh0LnB1c2goYnVmZmVyLmpvaW4oIiIpKTsKICAgIH0KICAgIGlmICh0ZXh0Lmxlbmd0aCA+IDApIHsKICAgICAgdGhpcy5kYXRhLnRleHRDb250ZW50ID0gdGV4dDsKICAgIH0KICB9CiAgZ2V0RmllbGRPYmplY3QoKSB7CiAgICBpZiAodGhpcy5kYXRhLmtpZElkcykgewogICAgICByZXR1cm4gewogICAgICAgIGlkOiB0aGlzLmRhdGEuaWQsCiAgICAgICAgYWN0aW9uczogdGhpcy5kYXRhLmFjdGlvbnMsCiAgICAgICAgbmFtZTogdGhpcy5kYXRhLmZpZWxkTmFtZSwKICAgICAgICBzdHJva2VDb2xvcjogdGhpcy5kYXRhLmJvcmRlckNvbG9yLAogICAgICAgIGZpbGxDb2xvcjogdGhpcy5kYXRhLmJhY2tncm91bmRDb2xvciwKICAgICAgICB0eXBlOiAiIiwKICAgICAgICBraWRJZHM6IHRoaXMuZGF0YS5raWRJZHMsCiAgICAgICAgcGFnZTogdGhpcy5kYXRhLnBhZ2VJbmRleCwKICAgICAgICByb3RhdGlvbjogdGhpcy5yb3RhdGlvbgogICAgICB9OwogICAgfQogICAgcmV0dXJuIG51bGw7CiAgfQogIHJlc2V0KCkgewogICAgZm9yIChjb25zdCBzdHJlYW0gb2YgdGhpcy5fc3RyZWFtcykgewogICAgICBzdHJlYW0ucmVzZXQoKTsKICAgIH0KICB9CiAgX2NvbnN0cnVjdEZpZWxkTmFtZShkaWN0KSB7CiAgICBpZiAoIWRpY3QuaGFzKCJUIikgJiYgIWRpY3QuaGFzKCJQYXJlbnQiKSkgewogICAgICAoMCwgX3V0aWwud2FybikoIlVua25vd24gZmllbGQgbmFtZSwgZmFsbGluZyBiYWNrIHRvIGVtcHR5IGZpZWxkIG5hbWUuIik7CiAgICAgIHJldHVybiAiIjsKICAgIH0KICAgIGlmICghZGljdC5oYXMoIlBhcmVudCIpKSB7CiAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRpY3QuZ2V0KCJUIikpOwogICAgfQogICAgY29uc3QgZmllbGROYW1lID0gW107CiAgICBpZiAoZGljdC5oYXMoIlQiKSkgewogICAgICBmaWVsZE5hbWUudW5zaGlmdCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRpY3QuZ2V0KCJUIikpKTsKICAgIH0KICAgIGxldCBsb29wRGljdCA9IGRpY3Q7CiAgICBjb25zdCB2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AoZWxlbWVudCA+IDApIHsKICAgICAgICAgIGFsbFplcm9zID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChpc1ZhbGlkICYmICFhbGxaZXJvcykgewogICAgICAgIHRoaXMuZGFzaEFycmF5ID0gZGFzaEFycmF5OwogICAgICAgIGlmIChmb3JjZVN0eWxlKSB7CiAgICAgICAgICB0aGlzLnNldFN0eWxlKF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEIikpOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB0aGlzLndpZHRoID0gMDsKICAgICAgfQogICAgfSBlbHNlIGlmIChkYXNoQXJyYXkpIHsKICAgICAgdGhpcy53aWR0aCA9IDA7CiAgICB9CiAgfQogIHNldEhvcml6b250YWxDb3JuZXJSYWRpdXMocmFkaXVzKSB7CiAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihyYWRpdXMpKSB7CiAgICAgIHRoaXMuaG9yaXpvbnRhbENvcm5lclJhZGl1cyA9IHJhZGl1czsKICAgIH0KICB9CiAgc2V0VmVydGljYWxDb3JuZXJSYWRpdXMocmFkaXVzKSB7CiAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihyYWRpdXMpKSB7CiAgICAgIHRoaXMudmVydGljYWxDb3JuZXJSYWRpdXMgPSByYWRpdXM7CiAgICB9CiAgfQp9CmV4cG9ydHMuQW5ub3RhdGlvbkJvcmRlclN0eWxlID0gQW5ub3RhdGlvbkJvcmRlclN0eWxlOwpjbGFzcyBNYXJrdXBBbm5vdGF0aW9uIGV4dGVuZHMgQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0CiAgICB9ID0gcGFyYW1zOwogICAgaWYgKGRpY3QuaGFzKCJJUlQiKSkgewogICAgICBjb25zdCByYXdJUlQgPSBkaWN0LmdldFJhdygiSVJUIik7CiAgICAgIHRoaXMuZGF0Y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RBcHBlYXJhbmNlKF9yZWYyKSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBleHRyYSwKICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgIGZpbGxDb2xvciwKICAgICAgYmxlbmRNb2RlLAogICAgICBzdHJva2VBbHBoYSwKICAgICAgZmlsbEFscGhhLAogICAgICBwb2ludHNDYWxsYmFjawogICAgfSA9IF9yZWYyOwogICAgbGV0IG1pblggPSBOdW1iZXIuTUFYX1ZBTFVFOwogICAgbGV0IG1pblkgPSBOdW1iZXIuTUFYX1ZBTFVFOwogICAgbGV0IG1heFggPSBOdW1iZXIuTUlOX1ZBTFVFOwogICAgbGV0IG1heFkgPSBOdW1iZXIuTUlOX1ZBTFVFOwogICAgY29uc3QgYnVmZmVyID0gWyJxIl07CiAgICBpZiAoZXh0cmEpIHsKICAgICAgYnVmZmVyLnB1c2goZXh0cmEpOwogICAgfQogICAgaWYgKHN0cm9rZUNvbG9yKSB7CiAgICAgIGJ1ZmZlci5wdXNoKGAke3N0cm9rZUNvbG9yWzBdfSAke3N0cm9rZUNvbG9yWzFdfSAke3N0cm9rZUNvbG9yWzJdfSBSR2ApOwogICAgfQogICAgaWYgKGZpbGxDb2xvcikgewogICAgICBidWZmZXIucHVzaChgJHtmaWxsQ29sb3JbMF19ICR7ZmlsbENvbG9yWzFdfSAke2ZpbGxDb2xvclsyXX0gcmdgKTsKICAgIH0KICAgIGxldCBwb2ludHNBcnJheSA9IHRoaXMuZGF0YS5xdWFkUG9pbnRzOwogICAgaWYgKCFwb2ludHNBcnJheSkgewogICAgICBwb2ludHNBcnJheSA9IFtbewogICAgICAgIHg6IHRoaXMucmVjdGFuZ2xlWzBdLAogICAgICAgIHk6IHRoaXMucmVjdGFuZ2xlWzNdCiAgICAgIH0sIHsKICAgICAgICB4OiB0aGlzLnJlY3RhbmdsZVsyXSwKICAgICAgICB5OiB0aGlzLnJlY3RhbmdsZVszXQogICAgICB9LCB7CiAgICAgICAgeDogdGhpcy5yZW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ICAgbnVtYmVyT2ZMaW5lcyA9IE1hdGgucm91bmQoaGVpZ2h0IC8gbGluZUhlaWdodCk7CiAgICBpZiAoIWZvbnRTaXplKSB7CiAgICAgIGNvbnN0IHJvdW5kV2l0aFR3b0RpZ2l0cyA9IHggPT4gTWF0aC5mbG9vcih4ICogMTAwKSAvIDEwMDsKICAgICAgaWYgKGxpbmVDb3VudCA9PT0gLTEpIHsKICAgICAgICBjb25zdCB0ZXh0V2lkdGggPSB0aGlzLl9nZXRUZXh0V2lkdGgodGV4dCwgZm9udCk7CiAgICAgICAgZm9udFNpemUgPSByb3VuZFdpdGhUd29EaWdpdHMoTWF0aC5taW4oaGVpZ2h0IC8gX3V0aWwuTElORV9GQUNUT1IsIHRleHRXaWR0aCA+IHdpZHRoID8gd2lkdGggLyB0ZXh0V2lkdGggOiBJbmZpbml0eSkpOwogICAgICAgIG51bWJlck9mTGluZXMgPSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGxpbmVzID0gdGV4dC5zcGxpdCgvXHJcbj98XG4vKTsKICAgICAgICBjb25zdCBjYWNoZWRMaW5lcyA9IFtdOwogICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBsaW5lcykgewogICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGZvbnQuZW5jb2RlU3RyaW5nKGxpbmUpLmpvaW4oIiIpOwogICAgICAgICAgY29uc3QgZ2x5cGhzID0gZm9udC5jaGFyc1RvR2x5cGhzKGVuY29kZWQpOwogICAgICAgICAgY29uc3QgcG9zaXRpb25zID0gZm9udC5nZXRDaGFyUG9zaXRpb25zKGVuY29kZWQpOwogICAgICAgICAgY2FjaGVkTGluZXMucHVzaCh7CiAgICAgICAgICAgIGxpbmU6IGVuY29kZWQsCiAgICAgICAgICAgIGdseXBocywKICAgICAgICAgICAgcG9zaXRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgaXNUb29CaWcgPSBmc2l6ZSA9PiB7CiAgICAgICAgICBsZXQgdG90YWxIZWlnaHQgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiBjYWNoZWRMaW5lcykgewogICAgICAgICAgICBjb25zdCBjaHVua3MgPSB0aGlzLl9zcGxpdExpbmUobnVsbCwgZm9udCwgZnNpemUsIHdpZHRoLCBjYWNoZSk7CiAgICAgICAgICAgIHRvdGFsSGVpZ2h0ICs9IGNodW5rcy5sZW5ndGggKiBmc2l6ZTsKICAgICAgICAgICAgaWYgKHRvdGFsSGVpZ2h0ID4gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9OwogICAgICAgIG51bWJlck9mTGluZXMgPSBNYXRoLm1heChudW1iZXJPZkxpbmVzLCBsaW5lQ291bnQpOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBsaW5lSGVpZ2h0ID0gaGVpZ2h0IC8gbnVtYmVyT2ZMaW5lczsKICAgICAgICAgIGZvbnRTaXplID0gcm91bmRXaXRoVHdvRGlnaXRzKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUik7CiAgICAgICAgICBpZiAoaXNUb29CaWcoZm9udFNpemUpKSB7CiAgICAgICAgICAgIG51bWJlck9mTGluZXMrKzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9ID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YTsKICAgICAgdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UgPSAoMCwgX2RlZmF1bHRfYXBwZWFyYW5jZS5jcmVhdGVEZWZhdWx0QXBwZWFyYW5jZSkoewogICAgICAgIGZvbnRTaXplLAogICAgICA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lkdGggKiBzY2FsZTsKICAgICAgaWYgKGdseXBoLnVuaWNvZGUgPT09ICIgIikgewogICAgICAgIGlmIChjdXJyZW50V2lkdGggKyBnbHlwaFdpZHRoID4gd2lkdGgpIHsKICAgICAgICAgIGNodW5rcy5wdXNoKGxpbmUuc3Vic3RyaW5nKHN0YXJ0Q2h1bmssIHN0YXJ0KSk7CiAgICAgICAgICBzdGFydENodW5rID0gc3RhcnQ7CiAgICAgICAgICBjdXJyZW50V2lkdGggPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGN1cnJlbnRXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IHN0YXJ0OwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQgPSBlbmQ7CiAgICAgICAgICBsYXN0U3BhY2VQb3MgPSBpOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoY3VycmVudFdpZHRoICsgZ2x5cGhXaWR0aCA+IHdpZHRoKSB7CiAgICAgICAgICBpZiAobGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCAhPT0gLTEpIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IGxhc3RTcGFjZVBvc0luU3RyaW5nRW5kOwogICAgICAgICAgICBpID0gbGFzdFNwYWNlUG9zICsgMTsKICAgICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAg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JpbWl0aXZlcy5OYW1lLmdldCgiV2luQW5zaUVuY29kaW5nIikpOwogICAgICBmb250LnNldCgiSGVsdiIsIGJhc2VGb250KTsKICAgIH0KICAgIHJlc291cmNlcy5zZXQoIkZvbnQiLCBmb250KTsKICAgIGNvbnN0IGhlbHYgPSBhd2FpdCBXaWRnZXRBbm5vdGF0aW9uLl9nZXRGb250RGF0YShldmFsdWF0b3IsIHRhc2ssIHsKICAgICAgZm9udE5hbWU6ICJIZWx2ZXRpY2EiLAogICAgICBmb250U2l6ZQogICAgfSwgcmVzb3VyY2VzKTsKICAgIGNvbnN0IFt4MSwgeTEsIHgyLCB5Ml0gPSByZWN0OwogICAgbGV0IHcgPSB4MiAtIHgxOwogICAgbGV0IGggPSB5MiAtIHkxOwogICAgaWYgKHJvdGF0aW9uICUgMTgwICE9PSAwKSB7CiAgICAgIFt3LCBoXSA9IFtoLCB3XTsKICAgIH0KICAgIGNvbnN0IGxpbmVzID0gdmFsdWUuc3BsaXQoIlxuIik7CiAgICBjb25zdCBzY2FsZSA9IGZvbnRTaXplIC8gMTAwMDsKICAgIGxldCB0b3RhbFdpZHRoID0gLUluZmluaXR5OwogICAgY29uc3QgZW5jb2RlZExpbmVzID0gW107CiAgICBmb3IgKGxldCBsaW5lIG9mIGxpbmVzKSB7CiAgICAgIGNvbnN0IGVuY29kZWQgPSBoZWx2LmVuY29kZVN0cmluZyhsaW5lKTsKICAgICAgaWYgKGVuY29kZWQubGVuZ3RoID4gMSkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGxpbmUgPSBlbmNvZGVkLmpvaW4oIiIpOwogICAgICBlbmNvZGVkTGluZXMucHVzaChsaW5lKTsKICAgICAgbGV0IGxpbmVXaWR0aCA9IDA7CiAgICAgIGNvbnN0IGdseXBocyA9IGhlbHYuY2hhcnNUb0dseXBocyhsaW5lKTsKICAgICAgZm9yIChjb25zdCBnbHlwaCBvZiBnbHlwaHMpIHsKICAgICAgICBsaW5lV2lkdGggK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R7dGhpcy5ib3JkZXJTdHlsZS53aWR0aH0gd2AsCiAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgZmlsbENvbG9yLAogICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgIGZpbGxBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB4ID0gcG9pbnRzWzJdLnggKyB0aGlzLmJvcmRlclN0eWxlLndpZHRoIC8gMjsKICAgICAgICAgIGNvbnN0IHkgPSBwb2ludHNbMl0ueSArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3Qgd2lkdGggPSBwb2ludHNbM10ueCAtIHBvaW50c1syXS54IC0gdGhpcy5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHBvaW50c1sxXS55IC0gcG9pbnRzWzNdLnkgLSB0aGlzLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5fSAke3dpZHRofSAke2hlaWdodH0gcmVgKTsKICAgICAgICAgIGlmIChmaWxsQ29sb3IpIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIkIiKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJ1ZmZlci5wdXNoKCJTIik7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gW3BvaW50c1swXS54LCBwb2ludHNbMV0ueCwgcG9pbnRzWzNdLnksIHBvaW50c1sxXS55XTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfQogIH0KfQpjbGFzcyBDaXJjbGVBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW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ICBpZiAoIXRoaXMuYXBwZWFyYW5jZSkgewogICAgICBjb25zdCBzdHJva2VDb2xvciA9IHRoaXMuY29sb3IgPyBnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICBjb25zdCBzdHJva2VBbHBoYSA9IGRpY3QuZ2V0KCJDQSIpOwogICAgICBjb25zdCBib3JkZXJXaWR0aCA9IHRoaXMuYm9yZGVyU3R5bGUud2lkdGggfHwgMSwKICAgICAgICBib3JkZXJBZGp1c3QgPSAyICogYm9yZGVyV2lkdGg7CiAgICAgIGNvbnN0IGJib3ggPSBbSW5maW5pdHksIEluZmluaXR5LCAtSW5maW5pdHksIC1JbmZpbml0eV07CiAgICAgIGZvciAoY29uc3QgdmVydGV4IG9mIHRoaXMuZGF0YS52ZXJ0aWNlcykgewogICAgICAgIGJib3hbMF0gPSBNYXRoLm1pbihiYm94WzBdLCB2ZXJ0ZXgueCAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgYmJveFsxXSA9IE1hdGgubWluKGJib3hbMV0sIHZlcnRleC55IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgIGJib3hbM10gPSBNYXRoLm1heChiYm94WzNdLCB2ZXJ0ZXgueSArIGJvcmRlckFkanVzdCk7CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxs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pdHksIC1JbmZpbml0eSwgLUluZmluaXR5XTsKICAgICAgZm9yIChjb25zdCBpbmtMaXN0cyBvZiB0aGlzLmRhdGEuaW5rTGlzdHMpIHsKICAgICAgICBmb3IgKGNvbnN0IHZlcnRleCBvZiBpbmtMaXN0cykgewogICAgICAgICAgYmJveFswXSA9IE1hdGgubWluKGJib3hbMF0sIHZlcnRleC54IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICAgIGJib3hbMV0gPSBNYXRoLm1pbihiYm94WzFdLCB2ZXJ0ZXgueSAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgICAgYmJveFszXSA9IE1hdGgubWF4KGJib3hbM10sIHZlcnRleC55ICsgYm9yZGVyQWRqdXN0KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBmb3IgKGNvbnN0IGlua0xpc3Qgb2YgdGhpcy5kYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGlua0xpc3QubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke2lua0xpc3RbaV0ueH0gJHtpbmtMaXN0W2ldLnl9ICR7aSA9PT0gMCA/ICJtIiA6ICJsIn1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLngsIHBvaW50c1szXS55LCBwb2ludHNbMV0ueV07CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICB9CiAgc3RhdGljIGNyZWF0ZU5ld0RpY3QoYW5ub3RhdGlvbiwgeHJlZiwgX3JlZjUpIHsKICAgIGxldCB7CiAgICAgIGFwUmVmLAogICAgICBhcAogICAgfSA9IF9yZWY1OwogICAgY29uc3QgewogICAgICBwYXRocywKICAgICAgcmVjdCwKICAgICAgcm90YXRpb24KICAgIH0gPSBhbm5vdGF0aW9uOwogICAgY29uc3QgaW5rID0gbmV3IF9wcmltaXRpdmVzLkRpY3QoeHJlZik7CiAgICBpbmsuc2V0KCJUeXBlIiwgX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkFubm90IikpOwogICAgaW5rLnNldCgiU3VidHlwZSIsIF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJJbmsiKSk7CiAgICBpbmsuc2V0KCJDcmVhdGlvbkRhdGUiLCBgRDokeygwLCBfdXRpbC5nZXRNb2RpZmljYXRpb25EYXRlKSgpfWApOwogICAgaW5rLnNldCgiUmVjdCIsIHJlY3QpOwogICAgaW5rLnNldCgiSW5rTGlzdCIsIHBhdGhzLm1hcChwID0+IHAucG9pbnRzKSk7CiAgICBpbmsuc2V0KCJGIiwgNCk7CiAgICBpbmsuc2V0KCJCb3JkZXIiLCBbMCwgMCwgMF0pOwogICAgaW5rLnNldCgiUm90YXRlIiwgcm90YXRpb24pOwogICAgY29uc3QgbiA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KHhyZWYpOwogICAgaW5rLnNldCgiQVAiLCBuKTsKICAgIGlmIChhcFJlZikgewogICAgICBuLnNldCgiTiIsIGFwUmVmKTsKICAgIH0gZWxzZSB7CiAgICAgIG4uc2V0KCJOIiwgYXApOwogICAgfQogICAgcmV0dXJuIGluazsKICB9CiAgc3RhdGljIGFzeW5jIGNyZWF0ZU5ld0FwcGVhcmFuY2VTdHJlYW0oYW5ub3RhdGlvbiwgeHJlZiwgcGFyYW1zKSB7CiAgICBjb25zdCB7CiAgICAgIGNvbG9yLAogICAgICByZWN0LAogICAgICByb3RhdGlvbiwKICAgICAgcGF0aHMsCiAgICAgIHRoaWNrbmVzcywKICAgICAgb3BhY2l0eQogICAgfSA9IGFubm90YXRpb247CiAgICBjb25zdCBbeDEsIHkxLCB4MiwgeTJdID0gcmVjdDsKICAgIGxldCB3ID0geDIgLSB4MTsKICAgIGxldCBoID0geTIgLSB5MTsKICAgIGlmIChyb3RhdGlvbiAlIDE4MCAhPT0gMCkgewogICAgICBbdywgaF0gPSBbaCwgd107CiAgICB9CiAgICBjb25zdCBhcHBlYXJhbmNlQnVmZmVyID0gW2Ake3RoaWNrbmVzc30gdyAxIEogMSBqYCwgYCR7KDAsIF9kZWZhdWx0X2FwcGVhcmFuY2UuZ2V0UGRmQ29sb3IpKGNvbG9yLCBmYWxzZSl9YF07CiAgICBpZiAob3BhY2l0eSAhPT0gMSkgewogICAgICBhcHBlYXJhbmNlQnVmZmVyLnB1c2goIi9SMCBncyIpOwogICAgfQogICAgY29uc3QgYnVmZmVyID0gW107CiAgICBmb3IgKGNvbnN0IHsKICAgICAgYmV6aWVyCiAgICB9IG9mIHBhdGhzKSB7CiAgICAgIGJ1ZmZlci5sZW5ndGggPSAwOwogICAgICBidWZmZXIucHVzaChgJHsoMCwgX2NvcmVfdXRpbHMubnVtYmVyVG9TdHJpbmcpKGJlemllclswXSl9ICR7KDAsIF9jb3JlX3V0aWxzLm51bWJlclRvU3RyaW5nKShiZXppZXJbMV0pfSBtYCk7CiAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgY29uc3QgY3VydmUgPSB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AgICB9IGVsc2UgewogICAgICB0aGlzLmRhdGEuaGFzUG9wdXAgPSBmYWxzZTsKICAgIH0KICB9Cn0KY2xhc3MgU3F1aWdnbHlBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk7CiAgICBjb25zdCBxdWFkUG9pbnRzID0gdGhpcy5kYXRhLnF1YWRQb2ludHMgPSBnZXRRdWFkUG9pbnRzKGRpY3QsIG51bGwpOwogICAgaWYgKHF1YWRQb2ludHMpIHsKICAgICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgICBjb25zdCBzdHJva2VDb2xvciA9IHRoaXMuY29sb3IgPyBnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgICAgeHJlZiwKICAgICAgICAgIGV4dHJhOiAiW10gMCBkIDEgdyIsCiAgICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgICBjb25zdCBkeSA9IChwb2ludHNbMF0ueSAtIHBvaW50c1syXS55KSAvIDY7CiAgICAgICAgICAgIGxldCBzaGlmdCA9IGR5OwogICAgICAgICAgICBsZXQgeCA9IHBvaW50c1syXS54OwogICAgICAgICAgICBjb25zdCB5ID0gcG9pbnRzWzJdLnk7CiAgICAgICA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AwLCAwXTsKICAgICAgICBjb25zdCBzdHJva2VBbHBoYSA9IGRpY3QuZ2V0KCJDQSIpOwogICAgICAgIHRoaXMuX3NldERlZmF1bHRBcHBlYXJhbmNlKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBleHRyYTogIltdIDAgZCAxIHciLAogICAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICAgIHBvaW50c0NhbGxiYWNrOiAoYnVmZmVyLCBwb2ludHMpID0+IHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7KHBvaW50c1swXS54ICsgcG9pbnRzWzJdLngpIC8gMn0gYCArIGAkeyhwb2ludHNbMF0ueSArIHBvaW50c1syXS55KSAvIDJ9IG1gLCBgJHsocG9pbnRzWzFdLnggKyBwb2ludHNbM10ueCkgLyAyfSBgICsgYCR7KHBvaW50c1sxXS55ICsgcG9pbnRzWzNdLnkpIC8gMn0gbGAsICJTIik7CiAgICAgICAgICAgIHJldHVybiBbcG9pbnRzWzBdLngsIHBvaW50c1sxXS54LCBwb2ludHNbM10ueSwgcG9pbnRzWzFdLnldOwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmRhdGEuaGFzUG9wdXAgPSBmYWxzZTsKICAgIH0KICB9Cn0KY2xhc3MgU3RhbXBBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RBTVA7CiAgICB0aGlzLmRhdGEuaGFzT3duQ2FudmFzID0gdGhpcy5kYXRhLm5vUm90YXRlOwogIH0KfQpjbGFzcyBGaWxlQXR0YWNobWVudEFubm90YXRpb24gZXh0ZW5kcyBNYXJrdXBBbm5vdGF0aW9uIH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SA9IG9wZXJhdGlvbjsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgY29uc3QgW2ZvbnROYW1lLCBmb250U2l6ZV0gPSBhcmdzOwogICAgICAgICAgICBpZiAoZm9udE5hbWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgcmVzdWx0LmZvbnROYW1lID0gZm9udE5hbWUubmFtZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHlwZW9mIGZvbnRTaXplID09PSAibnVtYmVyIiAmJiBmb250U2l6ZSA+IDApIHsKICAgICAgICAgICAgICByZXN1bHQuZm9udFNpemUgPSBmb250U2l6ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYi5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxHcmF5OgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuZ3JheS5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxDb2xvclNwYWNlOgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuY215ay5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0gY2F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uc2V0KCJEVyIsIDEwMDApOwogICAgY29uc3Qgd2lkdGhzID0gW107CiAgICBjb25zdCBjaGFycyA9IFsuLi50aGlzLndpZHRocy5lbnRyaWVzKCldLnNvcnQoKTsKICAgIGxldCBjdXJyZW50Q2hhciA9IG51bGw7CiAgICBsZXQgY3VycmVudFdpZHRocyA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtjaGFyLCB3aWR0aF0gb2YgY2hhcnMpIHsKICAgICAgaWYgKCFjdXJyZW50Q2hhcikgewogICAgICAgIGN1cnJlbnRDaGFyID0gY2hhcjsKICAgICAgICBjdXJyZW50V2lkdGhzID0gW3dpZHRoXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2hhciA9PT0gY3VycmVudENoYXIgKyBjdXJyZW50V2lkdGhzLmxlbmd0aCkgewogICAgICAgIGN1cnJlbnRXaWR0aHMucHVzaCh3aWR0aCk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgd2lkdGhzLnB1c2goY3VycmVudENoYXIsIGN1cnJlbnRXaWR0aHMpOwogICAgICAgIGN1cnJlbnRDaGFyID0gY2hhcjsKICAgICAgICBjdXJyZW50V2lkdGhzID0gW3dpZHRoXTsKICAgICAgfQogICAgfQogICAgaWYgKGN1cnJlbnRDaGFyKSB7CiAgICAgIHdpZHRocy5wdXNoKGN1cnJlbnRDaGFyLCBjdXJyZW50V2lkdGhzKTsKICAgIH0KICAgIGRlc2NlbmRhbnRGb250LnNldCgiVyIsIHdpZHRocyk7CiAgICBjb25zdCBjaWRTeXN0ZW1JbmZvID0gbmV3IF9wcmltaXRpdmVzLkRpY3QodGhpcy54cmVmKTsKICAgIGNpZFN5c3RlbUluZm8uc2V0KCJPcmRlcmluZyIsICJJZGVudGl0eSIpOwogICAgY2lkU3lzdGVtSW5mby5zZXQoIlJlZ2lzdHJ5IiwgIkFkb2JlIik7CiAgICBjaWRTeXN0ZW1JbmZvLnNldCgiU3VwcGxlbWVudCIsIDApOwogICAgZGV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FdpZHRoID0gLUluZmluaXR5OwogICAgZm9yIChjb25zdCBsaW5lIG9mIHRleHQuc3BsaXQoL1xyXG4/fFxuLykpIHsKICAgICAgbGluZXMucHVzaChsaW5lKTsKICAgICAgY29uc3QgbGluZVdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGxpbmUpLndpZHRoOwogICAgICBtYXhXaWR0aCA9IE1hdGgubWF4KG1heFdpZHRoLCBsaW5lV2lkdGgpOwogICAgICBmb3IgKGNvbnN0IGNoYXIgb2YgbGluZS5zcGxpdCgiIikpIHsKICAgICAgICBjb25zdCBjb2RlID0gY2hhci5jaGFyQ29kZUF0KDApOwogICAgICAgIGxldCB3aWR0aCA9IHRoaXMud2lkdGhzLmdldChjb2RlKTsKICAgICAgICBpZiAod2lkdGggPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgY29uc3QgbWV0cmljcyA9IGN0eC5tZWFzdXJlVGV4dChjaGFyKTsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKG1ldHJpY3Mud2lkdGgpOwogICAgICAgICAgdGhpcy53aWR0aHMuc2V0KGNvZGUsIHdpZHRoKTsKICAgICAgICAgIHRoaXMuZmlyc3RDaGFyID0gTWF0aC5taW4oY29kZSwgdGhpcy5maXJzdENoYXIpOwogICAgICAgICAgdGhpcy5sYXN0Q2hhciA9IE1hdGgubWF4KGNvZGUsIHRoaXMubGFzdENoYXIpOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgbWF4V2lkdGggKj0gZm9udFNpemUgLyAxMDAwOwogICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICBsZXQgdyA9IHgyIC0geDE7CiAgICBsZXQgaCA9IHkyIC0geTE7CiAgICBpZiAocm90YXRpb24gJSAxODAgIT09IDApIHsKICAgICAgW3csIGhdID0gW2gsIHddOwogICAgfQogICAgbGV0IGhzY2FsZSA9IDE7CiAgICBpZiAobWF4V2lkdGggPiB3KSB7CiAgICAgIGhzY2FsZSA9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UmVzaXppbmcpIHsKICAgICAgICBsZXQgZGVzdFBvcyA9IDA7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgKytpKSB7CiAgICAgICAgICBjb25zdCBrZXkgPSBjb21wc1tpXSAqIDM7CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gY29sb3JNYXBba2V5ICsgMV07CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXkgKyAyXTsKICAgICAgICAgIGRlc3RQb3MgKz0gYWxwaGEwMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmdiQnVmID0gbmV3IFVpbnQ4QXJyYXkoY291bnQgKiAzKTsKICAgICAgICBsZXQgcmdiUG9zID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvdW50OyArK2kpIHsKICAgICAgICAgIGNvbnN0IGtleSA9IGNvbXBzW2ldICogMzsKICAgICAgICAgIHJnYkJ1ZltyZ2JQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDFdOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDJdOwogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgaWYgKCFuZWVkc1Jlc2l6aW5nKSB7CiAgICAgICAgdGhpcy5nZXRSZ2JCdWZmZXIoY29tcHMsIDAsIHdpZHRoICogYWN0dWFsSGVpZ2h0LCBkZXN0LCAwLCBicGMsIGFscGhhMDEpOwogICAgICB9IGVsc2UgewogICAgICAgIHJnYkJ1ZiA9IG5ldyBVaW50OENsYW1wZWRBcnJheShjb3VudCAqIDMpOwogICAgICAgIHRoaXMuZ2V0UmdiQnVmZmVyKGNvbXBzLCAwLCBjb3VudCwgcmdi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IkNNWUsiOgogICAgICAgIGNhc2UgIkRldmljZUNNWUsiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5jbXlrOwogICAgICAgIGNhc2UgIlBhdHRlcm4iOgogICAgICAgICAgcmV0dXJuIG5ldyBQYXR0ZXJuQ1MobnVsbCk7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChyZXNvdXJjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yU3BhY2VzID0gcmVzb3VyY2VzLmdldCgiQ29sb3JTcGFjZSIpOwogICAgICAgICAgICBpZiAoY29sb3JTcGFjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgICAgY29uc3QgcmVzb3VyY2VzQ1MgPSBjb2xvclNwYWNlcy5nZXQoY3MubmFtZSk7CiAgICAgICAgICAgICAgaWYgKHJlc291cmNlc0NTKSB7CiAgICAgICAgICAgICAgICBpZiAocmVzb3VyY2VzQ1MgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXJzZShyZXNvdXJjZXNDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY3MgPSByZXNvdXJjZXNDUzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnJlY29nbml6ZWQgQ29sb3JTcGFjZTogJHtjcy5uYW1lfWApOwogICAgICB9CiAgICB9CiAgICBpZiAoQXJyYXkuaXNBcnJheShjcykpIHsKICAgICAgY29uc3QgbW9kZSA9IHhyZWYuZmV0Y2hJZlJlZihjc1swXSk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W1tYSIpOwogICAgICAgICAgY29uc3QgbWF0cml4ID0gcGFyYW1zLmdldEFycmF5KCJNYXRyaXgiKTsKICAgICAgICAgIHJldHVybiBuZXcgQ2FsUkdCQ1Mod2hpdGVQb2ludCwgYmxhY2tQb2ludCwgZ2FtbWEsIG1hdHJpeCk7CiAgICAgICAgY2FzZSAiSUNDQmFzZWQiOgogICAgICAgICAgY29uc3Qgc3RyZWFtID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIGNvbnN0IGRpY3QgPSBzdHJlYW0uZGljdDsKICAgICAgICAgIG51bUNvbXBzID0gZGljdC5nZXQoIk4iKTsKICAgICAgICAgIGNvbnN0IGFsdCA9IGRpY3QuZ2V0KCJBbHRlcm5hdGUiKTsKICAgICAgICAgIGlmIChhbHQpIHsKICAgICAgICAgICAgY29uc3QgYWx0Q1MgPSB0aGlzLl9wYXJzZShhbHQsIHhyZWYsIHJlc291cmNlcywgcGRmRnVuY3Rpb25GYWN0b3J5KTsKICAgICAgICAgICAgaWYgKGFsdENTLm51bUNvbXBzID09PSBudW1Db21wcykgewogICAgICAgICAgICAgIHJldHVybiBhbHRDUzsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIklDQ0Jhc2VkIGNvbG9yIHNwYWNlOiBJZ25vcmluZyBpbmNvcnJlY3QgL0FsdGVybmF0ZSBlbnRyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChudW1Db21wcyA9PT0gMSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUNvbXBzID09PSAzKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgICAgfSBlbHNlIGlmIChudW1Db21wcyA9PT0gNCkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmNteWs7CiAgICAgICAgICB9CiAgIC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vbnN0IG5vZGVzID0gW3Jlc291cmNlc10sCiAgICAgIHhyZWYgPSB0aGlzLnhyZWY7CiAgICB3aGlsZSAobm9kZXMubGVuZ3RoKSB7CiAgICAgIGNvbnN0IG5vZGUgPSBub2Rlcy5zaGlmdCgpOwogICAgICBjb25zdCBncmFwaGljU3RhdGVzID0gbm9kZS5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICBpZiAoZ3JhcGhpY1N0YXRlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICBmb3IgKGxldCBncmFwaGljU3RhdGUgb2YgZ3JhcGhpY1N0YXRlcy5nZXRSYXdWYWx1ZXMoKSkgewogICAgICAgICAgaWYgKGdyYXBoaWNTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICBpZiAocHJvY2Vzc2VkLmhhcyhncmFwaGljU3RhdGUpKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBncmFwaGljU3RhdGUgPSB4cmVmLmZldGNoKGdyYXBoaWNTdGF0ZSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgcHJvY2Vzc2VkLnB1dChncmFwaGljU3RhdGUpOwogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIEV4dEdTdGF0ZTogIiR7ZXh9Ii5gKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCEoZ3JhcGhpY1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZ3JhcGhpY1N0YXRlLm9iaklkKSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoZ3JhcGhpY1N0YXRlLm9iaklkKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGJtID0gZ3JhcGhpY1N0YXRlLmdldCgiQk0iKTsKICAgICAgICAgIGlmIChibSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgaWYgKGJtLm5hbWUgIT09ICJOb3JtYWwiKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYm0gIT09IHVuZGVmaW5lZCAmJiBBcnJheS5pc0FycmF5KGJtKSkgewogICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgYm0pIHsKICAgICAgICAgICAgICBpZiAoZWxlbWVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUgJiYgZWxlbWVudC5uYW1lICE9PSAiTm9ybWFsIikgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHhPYmplY3RzID0gbm9kZS5nZXQoIlhPYmplY3QiKTsKICAgICAgaWYgKCEoeE9iamVjdHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IHhPYmplY3Qgb2YgeE9iamVjdHMuZ2V0UmF3VmFsdWVzKCkpIHsKICAgICAgICBpZiAoeE9iamVjdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaWYgKHByb2Nlc3NlZC5oYXMoeE9iamVjdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cnkgewogICAgICAgICAgICB4T2JqZWN0ID0geHJlZi5mZXRjaCh4T2JqZWN0KTsKICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeE9iamVjdCk7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoISh4T2JqZWN0IGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhPYmplY3QuZGljdC5vYmpJZCkgewogICAgICAgICAgcHJvY2Vzc2VkLnB1dCh4T2JqZWN0LmRpY3Qub2JqSWQpOwogICAgICAgIH0KICAgICAgICBjb25zdCB4UmVzb3VyY2VzID0geE9iamVjdC5kaWN0LmdldCgiUmVzb3VyY2VzIik7CiAgICAgICAgaWYgKCEoeFJlc291cmNlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQgJiYgcHJvY2Vzc2VkLmhhcyh4UmVzb3VyY2VzLm9iaklkKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5vZGVzLnB1c2goeFJlc291cmNlcyk7CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQpIHsKICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeFJlc291cmNlcy5vYmpJZCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IHJlZiBvZiBwcm9jZXNzZWQpIHsKICAgICAgbm9uQmxlbmRNb2Rlc1NldC5wdXQocmVmKTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKICB9CiAgYXN5bmMgZmV0Y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hlZENvbG9yU3BhY2U7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb2xvclNwYWNlID0gYXdhaXQgdGhpcy5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgIGNzLAogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKHNtYXNrICYmIHNtYXNrLmJhY2tkcm9wKSB7CiAgICAgICAgY29sb3JTcGFjZSA9IGNvbG9yU3BhY2UgfHwgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYjsKICAgICAgICBzbWFzay5iYWNrZHJvcCA9IGNvbG9yU3BhY2UuZ2V0UmdiKHNtYXNrLmJhY2tkcm9wLCAwKTsKICAgICAgfQogICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLmJlZ2luR3JvdXAsIFtncm91cE9wdGlvbnNdKTsKICAgIH0KICAgIGNvbnN0IGFyZ3MgPSBncm91cCA/IFttYXRyaXgsIG51bGxdIDogW21hdHJpeCwgYmJveF07CiAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnBhaW50Rm9ybVhPYmplY3RCZWdpbiwgYXJncyk7CiAgICByZXR1cm4gdGhpcy5nZXRPcGVyYXRvckxpc3QoewogICAgICBzdHJlYW06IHhvYmosCiAgICAgIHRhc2ssCiAgICAgIHJlc291cmNlczogZGljdC5nZXQoIlJlc291cmNlcyIpIHx8IHJlc291cmNlcywKICAgICAgb3BlcmF0b3JMaXN0LAogICAgICBpbml0aWFsU3RhdGUKICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnBhaW50Rm9ybVhPYmplY3RFbmQsIFtdKTsKICAgICAgaWYgKGdyb3VwKSB7CiAgIC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CwKICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGltZ0RhdGEgPSBhd2FpdCBfaW1hZ2UuUERGSW1hZ2UuY3JlYXRlTWFzayh7CiAgICAgICAgaW1nQXJyYXksCiAgICAgICAgd2lkdGg6IHcsCiAgICAgICAgaGVpZ2h0OiBoLAogICAgICAgIGltYWdlSXNGcm9tRGVjb2RlU3RyZWFtOiBpbWFnZSBpbnN0YW5jZW9mIF9kZWNvZGVfc3RyZWFtLkRlY29kZVN0cmVhbSwKICAgICAgICBpbnZlcnNlRGVjb2RlOiAhIWRlY29kZSAmJiBkZWNvZGVbMF0gPiAwLAogICAgICAgIGludGVycG9sYXRlLAogICAgICAgIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkOiB0aGlzLm9wdGlvbnMuaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQKICAgICAgfSk7CiAgICAgIGlmIChpbWdEYXRhLmlzU2luZ2xlT3BhcXVlUGl4ZWwpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkSW1hZ2VPcHMoX3V0aWwuT1BTLnBhaW50U29saWRDb2xvckltYWdlTWFzaywgW10sIG9wdGlvbmFsQ29udGVudCk7CiAgICAgICAgaWYgKGNhY2hlS2V5KSB7CiAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUuc2V0KGNhY2hlS2V5LCBpbWFnZVJlZiwgewogICAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50U29saWRDb2xvckltYWdlTWFzaywKICAgICAgICAgICAgYXJnczogW10sCiAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBvYmpJZCA9IGBtYXNrXyR7dGhpcy5pZEZhY3RvcnkuY3JlYXRlT2JqSW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W5jIHNldEdTdGF0ZShfcmVmMykgewogICAgbGV0IHsKICAgICAgcmVzb3VyY2VzLAogICAgICBnU3RhdGUsCiAgICAgIG9wZXJhdG9yTGlzdCwKICAgICAgY2FjaGVLZXksCiAgICAgIHRhc2ssCiAgICAgIHN0YXRlTWFuYWdlciwKICAgICAgbG9jYWxHU3RhdGVDYWNoZSwKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgIH0gPSBfcmVmMzsKICAgIGNvbnN0IGdTdGF0ZVJlZiA9IGdTdGF0ZS5vYmpJZDsKICAgIGxldCBpc1NpbXBsZUdTdGF0ZSA9IHRydWU7CiAgICBjb25zdCBnU3RhdGVPYmogPSBbXTsKICAgIGxldCBwcm9taXNlID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICBmb3IgKGNvbnN0IGtleSBvZiBnU3RhdGUuZ2V0S2V5cygpKSB7CiAgICAgIGNvbnN0IHZhbHVlID0gZ1N0YXRlLmdldChrZXkpOwogICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgIGNhc2UgIlR5cGUiOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiTFciOgogICAgICAgIGNhc2UgIkxDIjoKICAgICAgICBjYXNlICJMSiI6CiAgICAgICAgY2FzZSAiTUwiOgogICAgICAgIGNhc2UgIkQiOgogICAgICAgIGNhc2UgIlJJIjoKICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgY2FzZSAiQ0EiOgogICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHZhbHVlXSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgIGlzU2ltcGxlR1N0YXRlID0gZmFsc2U7CiAgICAgICAgICBwcm9taXNlID0gcHJvbWlzZS50aGVuKCgpID0+IHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIG51bGwsIHZhbH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QgU01hc2sgdHlwZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiVFIiOgogICAgICAgICAgY29uc3QgdHJhbnNmZXJNYXBzID0gdGhpcy5oYW5kbGVUcmFuc2ZlckZ1bmN0aW9uKHZhbHVlKTsKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRyYW5zZmVyTWFwc10pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT1AiOgogICAgICAgIGNhc2UgIm9wIjoKICAgICAgICBjYXNlICJPUE0iOgogICAgICAgIGNhc2UgIkJHIjoKICAgICAgICBjYXNlICJCRzIiOgogICAgICAgIGNhc2UgIlVDUiI6CiAgICAgICAgY2FzZSAiVUNSMiI6CiAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgY2FzZSAiU00iOgogICAgICAgIGNhc2UgIlNBIjoKICAgICAgICBjYXNlICJBSVMiOgogICAgICAgIGNhc2UgIlRLIjoKICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICsga2V5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoIlVua25vd24gZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICsga2V5KTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcHJvbWlzZS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgaWYgKGdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRHU3RhdGUsIFtnU3RhdGVPYmpdKTsKICAgICAgfQogICAgICBpZiAoaXNTaW1wbGVHU3RhdGUpIHsKICAgICAgICBsb2NhbEdTdGF0ZUNhY2hlLnNldChjYWNoZUtleSwgZ1N0YXRlUmVmLCBnU3RhdGVPYmopOwogICAgICB9CiAgICB9KTsKICB9CiAgbG9hZEZvbnQoZm9udE5hbWUsIGZvbnQsIHJlc291cmNlcykgewogICAgbGV0IGZhbGxiYWNrRm9udERpY3QgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IG51bGw7CiAgICBsZXQgY3NzRm9udEluZm8gPSBhcmd1bWVudHMubGVuZ3RoID4gNCAmJiBhcmd1bWVudHNbNF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1s0XSA6IG51bGw7CiAgICBjb25zdCBlcnJvckZvbnQgPSBhc3luYyAoKSA9PiB7CiAgICAgIHJldHVybiBuZXcgVHJhbnNsYXRlZEZvbnQoewogICAgICAgIGxvYWRlZE5hbWU6ICJnX2ZvbnRfZXJyb3IiLAogICAgICAgIGZvbnQ6IG5ldyBfZm9udHMuRXJyb3JGb250KGBGb250ICIke2ZvbnROYW1lfSIgaXMgbm90IGF2YWlsYWJsZS5gKSwKICAgICAgICBkaWN0OiBmb250LAogICAgICAgIGV2YWx1YXRvck9wdGlvbnM6IHRoaXMub3B0aW9ucwogICAgICB9KTsKICAgIH07CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGZvbnRSZWY7CiAgICBpZiAoZm9udCkgewogICAgICBpZiAoZm9udCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGZvbnRSZWYgPSBmb250OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmb250UmVzID0gcmVzb3VyY2VzLmdldCgiRm9udCIpOwogICAgICBpZiAoZm9udFJlcykgewogICAgICAgIGZvbnRSZWYgPSBmb250UmVzLmdldFJhdyhmb250TmFtZSk7CiAgICAgIH0KICAgIH0KICAgIGlmICghZm9udFJlZikgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gYEZ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gICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuY29uc3RydWN0UGF0aCwgW1tmbl0sIGFyZ3MsIG1pbk1heF0pOwogICAgICBpZiAocGFyc2luZ1RleHQpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnJlc3RvcmUsIG51bGwpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBvcEFyZ3MgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5W2xhc3RJbmRleF07CiAgICAgIG9wQXJnc1swXS5wdXNoKGZuKTsKICAgICAgb3BBcmdzWzFdLnB1c2goLi4uYXJncyk7CiAgICAgIGNvbnN0IG1pbk1heCA9IG9wQXJnc1syXTsKICAgICAgc3dpdGNoIChmbikgewogICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgIGNvbnN0IHggPSBhcmdzWzBdICsgYXJnc1syXTsKICAgICAgICAgIGNvbnN0IHkgPSBhcmdzWzFdICsgYXJnc1szXTsKICAgICAgICAgIG1pbk1heFswXSA9IE1hdGgubWluKG1pbk1heFswXSwgYXJnc1swXSwgeCk7CiAgICAgICAgICBtaW5NYXhbMV0gPSBNYXRoLm1heChtaW5NYXhbMV0sIGFyZ3NbMF0sIHgpOwogICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBhcmdzWzFdLCB5KTsKICAgICAgICAgIG1pbk1heFszXSA9IE1hdGgubWF4KG1pbk1heFszXSwgYXJnc1sxXSwgeSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4WzBdID0gTWF0aC5taW4obWluTWF4WzBdLCBhcmdzWzBdKTsKICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYXJnc1swXSk7CiAgICAgICAgICBtaW5NYXhbMl0gPSBNYXRoLm1pbihtaW5NYXhbMl0sIGFyZ3NbMV0pOwogICAgICAgICAgbWluTWF4WzNdID0gTWF0aC5tYXgobWluTWF4WzNdLCBhcmdzWzFdKTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlQ29sb3JTcGFjZShfcmVmNCkgewogICAgbGV0IHsKICAgICAgY3MsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgIH0gPSBfcmVmNDsKICAgIHJldHVybiBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlQXN5bmMoewogICAgICBjcywKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICByZXNvdXJjZXMsCiAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeTogdGhpcy5fcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlQ29sb3JTcGFjZSAtIGlnbm9yaW5nIENvbG9yU3BhY2U6ICIke3JlYXNvbn0iLmApOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICAgIH0pOwogIH0KICBwYXJzZVNoYWRpbmcoX3JlZjUpIHsKICAgIGxldCB7CiAgICAgIHNoYWRpbmcsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgIGxvY2FsU2hhZGluZ1BhdHRlcm5DYWN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lIikubmFtZTsKICAgIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NHIikgewogICAgICByZXR1cm4gewogICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgaWQ6IG9wdGlvbmFsQ29udGVudC5vYmpJZAogICAgICB9OwogICAgfSBlbHNlIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NNRCIpIHsKICAgICAgY29uc3QgZXhwcmVzc2lvbiA9IG9wdGlvbmFsQ29udGVudC5nZXQoIlZFIik7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KGV4cHJlc3Npb24pKSB7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gW107CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihleHByZXNzaW9uLCAwLCByZXN1bHQpOwogICAgICAgIGlmIChyZXN1bHQubGVuZ3RoID4gMCkgewogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgdHlwZTogIk9DTUQiLAogICAgICAgICAgICBleHByZXNzaW9uOiByZXN1bHQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudEdyb3VwcyA9IG9wdGlvbmFsQ29udGVudC5nZXQoIk9DR3MiKTsKICAgICAgaWYgKEFycmF5LmlzQXJyYXkob3B0aW9uYWxDb250ZW50R3JvdXBzKSB8fCBvcHRpb25hbENvbnRlbnRHcm91cHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgY29uc3QgZ3JvdXBJZHMgPSBbXTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvcHRpb25hbENvbnRlbnRHcm91cHMpKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IG9jZyBvZiBvcHRpb25hbENvbnRlbnRHcm91cHMpIHsKICAgICAgICAgICAgZ3JvdXBJZHMucHVzaChvY2cudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGdyb3VwSWRzLnB1c2gob3B0aW9uYWxDb250ZW50R3JvdXBzLm9iaklkKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZHM6IGdyb3VwSWRzLAogICAgICAgICAgcG9saWN5OiBvcHRpb25hbENvbnRlbnQuZ2V0KCJQIikgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gb3B0aW9uYWxDb250ZW50LmdldCgiUCIpLm5hbWUgOiBudWxsLAogICAgICAgICAgZXhwcmVzc2lvbjogbnVsbAogICAgICAgIH07CiAgICAgIH0gZWxzZSBpZiAob3B0aW9uYWxDb250ZW50R3JvdXBzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZDogb3B0aW9uYWxDb250ZW50R3JvdXBzLnRvU3RyaW5nKCkKICAgICAgICB9OwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbnVsbDsKICB9CiAgZ2V0T3BlcmF0b3JMaXN0KF9yZWY2KSB7CiAgICBsZXQgewogICAgICBzdHJlYW0sCiAgICAgIHRhc2ssCiAgICAgIHJlc291cmNlcywKICAgICAgb3BlcmF0b3JMaXN0LAogICAgICBpbml0aWFsU3RhdGUgPSBudWxsLAogICAgICBmYWxsYmFja0ZvbnREaWN0ID0gbnVsbAogICAgfSA9IF9yZWY2OwogICAgcmVzb3VyY2VzID0gcmVzb3VyY2VzIHx8IF9wcmltaXRpdmVzLkRpY3QuZW1wdHk7CiAgICBpbml0aWFsU3RhdGUgPSBpbml0aWFsU3RhdGUgfHwgbmV3IEV2YWxTdGF0ZSgpOwogICAgaWYgKCFvcGVyYXRvckxpc3QpIHsKICAgICAgdGhy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GFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBsZXQgZm4gPSBvcGVyYXRpb24uZm47CiAgICAgICAgc3dpdGNoIChmbiB8IDApIHsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50WE9iamVjdDoKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeU5hbWUobmFtZSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZVhPYmplY3QsIHJlamVjdFhPYmplY3QpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlhPYmplY3QgbXVzdCBiZSByZWZlcnJlZCB0byBieSBuYW1lLiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZXQgeG9iaiA9IHhvYmpzLmdldFJhdyhuYW1lKTsKICAgICAgICAgICAgICBpZiAoeG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeVJlZih4b2JqKTsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgICAgaW5jcmVtZW50Q2FjaGVkSW1hZ2VNYXNrQ291bnQobG9jYWxJbWFnZSk7CiAgICAgICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGdsb2JhbEltYWdlID0gc2VsZi5nbG9iYWxJbWFnZUNhY2hlLmdldERhdGEoeG9iaiwgc2VsZi5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgaWYgKGdsb2JhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGdsb2JhbEltYWdlLm9iaklkKTsKICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKGdsb2JhbEltYWdlLmZuLCBnbG9iYWxJbWFnZS5hcmdzLCBnbG9iYWxJbWFnZS5vcHRpb25hbENvbnRlbnQpOwogICAgICAgICAgICAgICAgICByZXNvbHZlWE9iamVjdCgpOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB4b2JqID0geHJlZi5mZXRjaCh4b2JqKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKCEoeG9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBiZSBhIHN0cmVhbSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCB0eXBlID0geG9iai5kaWN0LmdldCgiU3VidHlwZSIpOwogICAgICAgICAgICAgIGlmICghKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBoYXZlIGEgTmFtZSBzdWJ0eXBlIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICh0eXBlLm5hbWUgPT09ICJGb3JtIikgewogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICAgICAgICAgIHNlbGYuYnVpbGRGb3JtWE9iamVjdChyZXNvdXJjZXMsIHhvYmosIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCksIGxvY2FsQ29sb3JTcGFjZUNhY2hlKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIH0sIHJlamVjdFhPYmplY3QpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZS5uYW1lID09PSAiSW1hZ2UiKSB7CiAgICAgICAgICAgICAgICBzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICAgIGltYWdlOiB4b2JqLAogICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUsCiAgICAgICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgICAgICB9KS50aGVuKHJlc29sdmVYT2JqZWN0LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGUubmFtZSA9PT0gIlBTIikgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJJZ25vcmVkIFhPYmplY3Qgc3VidHlwZSBQUyIpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVuaGFuZGxlZCBYT2JqZWN0IHN1YnR5cGUgJHt0eXBlLm5hbWV9YCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgWE9iamVjdDogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICB2YXIgZm9udFNpemUgPSBhcmdzWzFdOwogICAgICAgICAgICBuZXh0KHNlbGYuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIGFyZ3MsIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLCBmYWxsYmFja0ZvbnREaWN0KS50aGVuKGZ1bmN0aW9uIChsb2FkZWROYW1lKSB7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZERlcGVuZGVuY3kobG9hZGVkTmFtZSk7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRGb250LCBbbG9hZGVkTmFtZSwgZm9udFNpemVdKTsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHBhcnNpbmdUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lbmRUZXh0OgogICAgICAgICAgICBwYXJzaW5nVGV4dCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZElubGluZUltYWdlOgogICAgICAgICAgICB2YXIgY2FjaGVLZXkgPSBhcmdzWzBdLmNhY2hlS2V5OwogICAgICAgICAgICBpZiAoY2FjaGVLZXkpIHsKICAgICAgICAgICAgICBjb25zdCBsb2NhbEltYWdlID0gbG9jYWxJbWFnZUNhY2hlLmdldEJ5TmFtZShjYWNoZUtleSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBpbWFnZTogYXJnc1swXSwKICAgICAgICAgICAgICBpc0lubGluZTogdHJ1ZSwKICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgY2FjaGVLZXksCiAgICAgICAgICAgICAgbG9jYWxJbWFnZUNhY2hlLAogICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGFyZ3NbMF0gPSBzZWxmLmhhbmRsZVRleHQoYXJnc1swXSwgc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNvbWJpbmVkR2x5cGhzID0gW107CiAgICAgICAgICAgIHZhciBzdGF0ZSA9IHN0YXRlTWFuYWdlci5zdGF0ZTsKICAgICAgICAgICAgZm9yIChjb25zdCBhcnJJdGVtIG9mIGFyZ3NbMF0pIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKC4uLnNlbGYuaGFuZGxlVGV4dChhcnJJdGVtLCBzdGF0ZSkpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKGFyckl0ZW0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzWzBdID0gY29tYmluZWRHbHlwaHM7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMubmV4dExpbmUpOwogICAgICAgICAgICBhcmdzWzBdID0gc2VsZi5oYW5kbGVUZXh0KGFyZ3NbMF0sIHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2V0U3BhY2luZ1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GUuZmlsbENvbG9yU3BhY2UgPSBjYWNoZWRDb2xvclNwYWNlOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIG5leHQoc2VsZi5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgICAgY3M6IGFyZ3NbMF0sCiAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIGlmIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JTcGFjZToKICAgICAgICAgICAgewogICAgICAgICAgICAgIGNvbnN0IGNhY2hlZENvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLmdldENhY2hlZChhcmdzWzBdLCB4cmVmLCBsb2NhbENvbG9yU3BhY2VDYWNoZSk7CiAgICAgICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlID0gY2FjaGVkQ29sb3JTcGFjZTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VDb2xvclNwYWNlKHsKICAgICAgICAgICAgICAgIGNzOiBhcmdzWzBdLAogICAgICAgICAgICAgICAgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBpZiAoY29sb3JTcGFjZSkgewogICAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuc3Ryb2tlQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZTsKICAgICAgICAgICAgYXJncyA9IGNzLmdldFJnYihhcmdzLCAwKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2V0RmlsbFJHQkNvbG9yOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlOwogICAgICAgICAgICBhcmdzID0gY3MuZ2V0UmdiKGFyZ3MsIDApOwogICAgICAgICAgICBmbiA9IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvcjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsR3JheToKICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnN0YXRlLmZpbGxDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICAgIGFyZ3MgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuZ3JheS5nZXRSZ2IoYXJncywgMCk7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnN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mICghc2hhZGluZykgewogICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTm8gc2hhZGluZyBvYmplY3QgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBwYXR0ZXJuSWQgPSBzZWxmLnBhcnNlU2hhZGluZyh7CiAgICAgICAgICAgICAgc2hhZGluZywKICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgICAgICAgICAgbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBhcmdzID0gW3BhdHRlcm5JZF07CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNoYWRpbmdGaWxsOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxHU3RhdGVPYmogPSBsb2NhbEdTdGF0ZUNhY2hlLmdldEJ5TmFtZShuYW1lKTsKICAgICAgICAgICAgICBpZiAobG9jYWxHU3RhdGVPYmopIHsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuc2V0R1N0YXRlLCBbbG9jYWxHU3RhdGVPYmpdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGFyZ3MgPSBudWxsOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQobmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIG11c3QgYmUgcmVmZXJyZWQgdG8gYnkgbmFtZS4iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZXh0R1N0YXRlID0gcmVzb3VyY2VzLmdldCgiRXh0R1N0YXRlIik7CiAgICAgICAgICAgICAgaWYgKCEoZXh0R1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiRXh0R1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGdTdGF0ZSA9IGV4dEdTdGF0ZS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgaWYgKCEoZ1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNlbGYuc2V0R1N0YXRlKHsKICAgICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICAgIGdTdGF0ZSwKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlciwKICAgICAgICAgICAgICAgIGxvY2FsR1N0YXRlQ2FjaGUsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4ocmVzb2x2ZUdTdGF0ZSwgcmVqZWN0R1N0YXRlKTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubW92ZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8yOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzM6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZVBhdGg6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5yZWN0YW5nbGU6CiAgICAgICAgICAgIHNlbGYuYnVpbGRQYXRoKG9wZXJhdG9yTGlzdCwgZm4sIGFyZ3MsIHBhcnNpbmdUZXh0KTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnQ6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnRQcm9wczoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luQ29tcGF0OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kQ29tcGF0OgogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudFByb3BzOgogICAgICAgICAgICBpZiAoIShhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEV4cGVjdGVkIG5hbWUgZm9yIGJlZ2luTWFya2VkQ29udGVudFByb3BzIGFyZzA9JHthcmdzWzBdfWApOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcmdzWzBdLm5hbWUgPT09ICJPQyIpIHsKICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VNYXJrZWRDb250ZW50UHJvcHMoYXJnc1sxXSwgcmVzb3VyY2VzKS50aGVuKGRhdGEgPT4gewogICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywgWyJPQyIsIGRhdGFdKTsKICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzZWxmLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzID0gW2FyZ3NbMF0ubmFtZSwgYXJnc1sxXSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgPyBhcmdzWzFdLmdldCgiTUNJRCIpIDogbnVsbF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGlmIChhcmdzICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgZm9yIChpID0gMCwgaWkgPSBhcmdzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChhcmdzW2ldIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKGkgPCBpaSkgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBvcGVyYXRvcjogIiArIGZuKTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoZm4sIGFyZ3MpOwogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNsb3NlUGVuZGluZ1Jlc3RvcmVPUFMoKTsKICAgICAgcmVzb2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5hbWVdID0gewogICAgICAgICAgZm9udEZhbWlseTogZm9udC5mYWxsYmFja05hbWUsCiAgICAgICAgICBhc2NlbnQ6IGZvbnQuYXNjZW50LAogICAgICAgICAgZGVzY2VudDogZm9udC5kZXNjZW50LAogICAgICAgICAgdmVydGljYWw6IGZvbnQudmVydGljYWwKICAgICAgICB9OwogICAgICB9CiAgICAgIHRleHRDb250ZW50SXRlbS5mb250TmFtZSA9IGxvYWRlZE5hbWU7CiAgICAgIGNvbnN0IHRybSA9IHRleHRDb250ZW50SXRlbS50cmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICBpZiAoIWZvbnQudmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggPSB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCA9IDA7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9IE1hdGguaHlwb3QodHJtWzJdLCB0cm1bM10pOwogICAgICAgIHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCA9IGZhbHNlOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50SXRlbS53aWR0aCA9IHRleHRDb250ZW50SXRlbS50b3RhbFdpZHRoID0gTWF0aC5oeXBvdCh0cm1bMF0sIHRybVsxXSk7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9IDA7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLnZlcnRpY2FsID0gdHJ1ZTsKICAgICAgfQogICAgICBjb25zdCBzY2FsZUxpbmVYID0gTWF0aC5oeXBvdCh0ZXh0U3RhdGUudGV4dExpbmVNYXRyaXhbMF0sIHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeFsxXSk7CiAgICAgIGNvbnN0IHNjYWxlQ3RtWCA9IE1hdGguaHl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cG9zWV0gPSBhcHBseUludmVyc2VSb3RhdGlvbihwb3NYLCBwb3NZLCBjdXJyZW50VHJhbnNmb3JtKTsKICAgICAgICAgIFtsYXN0UG9zWCwgbGFzdFBvc1ldID0gYXBwbHlJbnZlcnNlUm90YXRpb24obGFzdFBvc1gsIGxhc3RQb3NZLCB0ZXh0Q29udGVudEl0ZW0ucHJldlRyYW5zZm9ybSk7CiAgICAgIH0KICAgICAgaWYgKHRleHRTdGF0ZS5mb250LnZlcnRpY2FsKSB7CiAgICAgICAgY29uc3QgYWR2YW5jZVkgPSAobGFzdFBvc1kgLSBwb3NZKSAvIHRleHRDb250ZW50SXRlbS50ZXh0QWR2YW5jZVNjYWxlOwogICAgICAgIGNvbnN0IGFkdmFuY2VYID0gcG9zWCAtIGxhc3RQb3NYOwogICAgICAgIGNvbnN0IHRleHRPcmllbnRhdGlvbiA9IE1hdGguc2lnbih0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0KTsKICAgICAgICBpZiAoYWR2YW5jZVkgPCB0ZXh0T3JpZW50YXRpb24gKiB0ZXh0Q29udGVudEl0ZW0ubmVnYXRpdmVTcGFjZU1heCkgewogICAgICAgICAgaWYgKE1hdGguYWJzKGFkdmFuY2VYKSA+IDAuNSAqIHRleHRDb250ZW50SXRlbS53aWR0aCkgewogICAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVgpID4gdGV4dENvbnRlbnRJdGVtLndpZHRoKSB7CiAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoYWR2YW5jZVkgPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLm5vdEFTcGFjZSkgewogICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICB9CiAgICAgICAgaWYgKGFkdmFuY2VZIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS50cmFja2luZ1NwYWNlTWluKSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICs9IGFkdmFuY2VZOwogICAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVksIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgICBpZiAodGV4dENvbnRlbnRJdGVtLnN0ci5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgICAgc3RyOiAiICIsCiAgICAgICAgICAgICAgZGlyOiAibHRyIiwKICAgICAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgICAgICBoZWlnaHQ6IE1hdGguYWJzKGFkdmFuY2VZKSwKICAgICAgICAgICAgICB0cmFuc2Zvcm06IHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLAogICAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRDb250ZW50SXRlbS5oZWlnaHQgKz0gYWR2YW5jZVk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWCkgPiB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiBWRVJUSUNBTF9TSElGVF9SQVRJTykgewogICAgICAgICAgZmx1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WR2YW5jZVg7CiAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVgsIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5zdHIubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgIHN0cjogIiAiLAogICAgICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgICAgICB3aWR0aDogTWF0aC5hYnMoYWR2YW5jZVgpLAogICAgICAgICAgICBoZWlnaHQ6IDAsCiAgICAgICAgICAgIHRyYW5zZm9ybTogdGV4dENvbnRlbnRJdGVtLnByZXZUcmFuc2Zvcm0sCiAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgIGhhc0VPTDogZmFsc2UKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWSkgPiB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICogVkVSVElDQUxfU0hJRlRfUkFUSU8pIHsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZnVuY3Rpb24gYnVpbGRUZXh0Q29udGVudEl0ZW0oX3JlZjgpIHsKICAgICAgbGV0IHsKICAgICAgICBjaGFycywKICAgICAgICBleHRyYVNwYWNpbmcKICAgICAgfSA9IF9yZWY4OwogICAgICBjb25zdCBmb250ID0gdGV4dFN0YXRlLmZvbnQ7CiAgICAgIGlmICghY2hhcnMpIHsKICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IHRleHRTdGF0ZS5jaGFyU3BhY2luZyArIGV4dHJhU3BhY2luZzsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBnbHlwaHMgPSBmb250LmNoYXJzVG9HbHlwaHMoY2hhcnMpOwogICAgICBjb25zdCBzY2FsZSA9IHRleHRTdGF0ZS5mb250TWF0cml4WzBdICogdGV4dFN0YXRlLmZvbnRTaXplOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBnbHlwaHMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgIGNvbnN0IHsKICAgICAgICAgIGNhdGVnb3J5CiAgICAgICAgfSA9IGdseXBoOwogICAgICAgIGlmIChjYXRlZ29yeS5pc0ludmlzaWJsZUZvcm1hdE1hcmspIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsZXQgY2hhclNwYWNpbmcgPSB0ZXh0U3RhdGUuY2hhclNwYWNpbmcgKyAoaSArIDEgPT09IGlpID8gZXh0cmFTcGFjaW5nIDogMCk7CiAgICAgICAgbGV0IGdseXBoV2lkdGggPSBnbHlwaC53aWR0aDsKICAgICAgICBpZiAoZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgZ2x5cGhXaWR0aCA9IGdseXBoLnZtZXRyaWMgPyBnbHlwaC52bWV0cmljWzBdIDogLWdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGxldCBzY2FsZWREaW0gPSBnbHlwaFdpZHRoICogc2NhbGU7CiAgICAgICAgaWYgKGNhdGVnb3J5LmlzV2hpdGVzcGFjZSkgewogICAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICAgIGNoYXJTcGFjaW5nICs9IHNjYWxlZERpbSArIHRleHRTdGF0ZS53b3JkU3BhY2luZzsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoY2hhclNwYWNpbmcgKiB0ZXh0U3RhdGUudGV4dEhTY2FsZSwgMCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjaGFyU3BhY2luZyArPSAtc2NhbGVkRGltICsgdGV4dFN0YXRlLndvcmRTcGFjaW5nOwogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeCgwLCAtY2hhclNwYWNpbmcpOwogICAgICAgICAgfQogICAgICAgICAgc2F2ZUxhc3RDaGFyKCIgIik7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKCFjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYyAmJiAhY29tcGFyZVdpdGhMYXN0UG9zaXRpb24oKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHRleHRDaHVuayA9IGVuc3VyZVRleHRDb250ZW50SXRlbSgpOwogICAgICAgIGlmIChjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYykgewogICAgICAgICAgc2NhbGVkRGltID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICBzY2FsZWREaW0gKj0gdGV4dFN0YXRlLnRleHRIU2NhbGU7CiAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChzY2FsZWREaW0sIDApOwogICAgICAgICAgdGV4dENodW5rLndpZHRoICs9IHNjYWxlZERpbTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoMCwgc2NhbGVkRGltKTsKICAgICAgICAgIHNjYWxlZERpbSA9IE1hdGguYWJzKHNjYWxlZERpbSk7CiAgICAgICAgICB0ZXh0Q2h1bmsuaGVpZ2h0ICs9IHNjYWxlZERpbTsKICAgICAgICB9CiAgICAgICAgaWYgKHNjYWxlZERpbSkgewogICAgICAgICAgdGV4dENodW5rLnByZXZUcmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICAgIH0KICAgICAgICBjb25zdCBnbHlwaFVuaWNvZGUgPSBnbHlwaC5ub3JtYWxpemVkVW5pY29kZTsKICAgICAgICBpZiAoc2F2ZUxhc3RDaGFyKGdseXBoVW5pY29kZSkpIHsKICAgICAgICAgIHRleHRDaHVuay5zdHIucHVzaCgiICIpOwogICAgICAgIH0KICAgICAgICB0ZXh0Q2h1bmsuc3RyLnB1c2goZ2x5cGhVbmljb2RlKTsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhcHBlbmRFT0woKSB7CiAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGFzRU9MID0gdHJ1ZTsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgc3RyOiAiIiwKICAgICAgICAgIGRpcjogImx0ciIsCiAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgIGhlaWdodDogMCwKICAgICAgICAgIHRyYW5zZm9ybTogZ2V0Q3VycmVudFRleHRUcmFuc2Zvcm0oKSwKICAgICAgICAgIGZvbnROYW1lOiB0ZXh0U3RhdGUubG9hZGVkTmFtZSwKICAgICAgICAgIGhhc0VPTDogdHJ1ZQogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhZGRGYWtlU3BhY2VzKHdpZHRoLCB0cmFuc2YsIHRleHRPcmllbnRhdGlvbikgewogICAgICBpZiAodGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnNwYWNlSW5GbG93TWluIDw9IHdpZHRoICYmIHdpZHRoIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5zcGFjZUluRmxvd01heCkgewogICAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uc3RyLnB1c2goIiAiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnROYW1lID0gdGV4dENvbnRlbnRJdGVtLmZvbnROYW1lOwogICAgICBsZXQgaGVpZ2h0ID0gMDsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCkgewogICAgICAgIGhlaWdodCA9IHdpZHRoOwogICAgICAgIHdpZHRoID0gMDsKICAgICAgfQogICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICByZXNldExhc3RDaGFycygpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICBzdHI6ICIgIiwKICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgIHdpZHRoOiBNYXRoLmFicyh3aWR0aCksCiAgICAgICAgaGVpZ2h0OiBNYXRoLmFicyhoZWlnaHQpLAogICAgICAgIHRyYW5zZm9ybTogdHJhbnNmIHx8IGdldEN1cnJlbnRUZXh0VHJhbnNmb3JtKCksCiAgICAgICAgZm9udE5hbWUsCiAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICB9KTsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBmdW5jdGlvbiBmbHVzaFRleHRDb250ZW50SXRlbSgpIHsKICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQgfHwgIXRleHRDb250ZW50SXRlbS5zdHIpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0udmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCArPSB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiB0ZXh0Q29udGVudEl0ZW0udGV4dEFkdmFuY2VTY2FsZTsKICAgICAgfSBlbHNlIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0udG90YWxIZWlnaHQgKz0gdGV4dENvbnRlbnRJdGVtLmhlaWdodCAqIHRleHRDb250ZW50SXRlbS50ZXh0QWR2YW5jZVNjYWxlOwogICAgICB9CiAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2gocnVuQmlkaVRyYW5zZm9ybSh0ZXh0Q29udGVudEl0ZW0pKTsKICAgICAgdGV4dENvbnRlbnRJdGVtLmluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgIHRleHRDb250ZW50SXRlbS5zdHIubGVuZ3RoID0gMDsKICAgIH0KICAgIGZ1bmN0aW9uIGVucXVldWVDaHVuaygpIHsKICAgICAgbGV0IGJhdGNoID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgY29uc3QgbGVuZ3RoID0gdGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoOwogICAgICBpZiAobGVuZ3RoID09PSAwKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGlmIChiYXRjaCAmJiBsZW5ndGggPCBURVhUX0NIVU5LX0JBVENIX1NJWkUpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgc2luay5lbnF1ZXVlKHRleHRDb250ZW50LCBsZW5ndGgpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcyA9IFtdOwogICAgICB0ZXh0Q29udGVudC5zdHlsZXMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgfQogICAgY29uc3QgdGltZVNsb3RNYW5hZ2VyID0gbmV3IFRpbWVTbG90TWFuYWdlcigpOwogICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCkgewogICAgICBjb25zdCBuZXh0ID0gZnVuY3Rpb24gKHByb21pc2UpIHsKICAgICAgICBlbnF1ZXVlQ2h1bmsodHJ1ZSk7CiAgICAgICAgUHJvbWlzZS5hbGwoW3Byb21pc2UsIHNpbmsucmVhZHldKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCk7CiAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICByZWplY3QoZXgpOwogICAgICAgICAgfQogICAgICAgIH0sIHJlamVjdCk7CiAgICAgIH07CiAgICAgIHRhc2suZW5zdXJlTm90VGVybWluYXRlZCgpOwogICAgICB0aW1lU2xvdE1hbmFnZXIucmVzZXQoKTsKICAgICAgY29uc3Qgb3BlcmF0aW9uID0ge307CiAgICAgIGxldCBzdG9wLAogICAgICAgIGFyZ3MgPSBbXTsKICAgICAgd2hpbGUgKCEoc3RvcCA9IHRpbWVTbG90TWFuYWdlci5jaGVjaygpKSkgewogICAgICAgIGFyZ3MubGVuZ3RoID0gMDsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IGFyZ3M7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGV4dFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlOwogICAgICAgIGNvbnN0IGZuID0gb3BlcmF0aW9uLmZuOwogICAgICAgIGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgdmFyIGZvbnROYW1lQXJnID0gYXJnc1swXS5uYW1lLAogICAgICAgICAgICAgIGZvbnRTaXplQXJnID0gYXJnc1sxXTsKICAgICAgICAgICAgaWYgKHRleHRTdGF0ZS5mb250ICYmIGZvbnROYW1lQXJnID09PSB0ZXh0U3RhdGUuZm9udE5hbWUgJiYgZm9udFNpemVBcmcgPT09IHRleHRTdGF0ZS5mb250U2l6ZSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS5mb250TmFtZSA9IGZvbnROYW1lQXJnOwogICAgICAgICAgICB0ZXh0U3RhdGUuZm9udFNpemUgPSBmb250U2l6ZUFyZzsKICAgICAgICAgICAgbmV4dChoYW5kbGVTZXRGb250KGZvbnROYW1lQXJnLCBudWxsKSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSaXNlOgogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dFJpc2UgPSBhcmdzWzBdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgdGV4dFN0YXRlLnRleHRIU2NhbGUgPSBhcmdzWzBdIC8gMTAwOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmc6CiAgICAgICAgICAgIHRleHRTdGF0ZS5sZWFkaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmdNb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLmxlYWRpbmcgPSAtYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lOgogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRUZXh0TWF0cml4OgogICAgICAgICAgICB0ZXh0U3RhdGUuc2V0VGV4dE1hdHJpeChhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdLCBhcmdzWzNdLCBhcmdzWzRdLCBhcmdzWzVdKTsKICAgICAgICAgICAgdGV4dFN0YXRlLnNldFRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMl0sIGFyZ3NbM10sIGFyZ3NbNF0sIGFyZ3NbNV0pOwogICAgICAgICAgICB1cGRhdGVBZHZhbmNlU2NhbGUoKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZzoKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRXb3JkU3BhY2luZzoKICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYLnNsaWNlKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBzcGFjZUZhY3RvciA9ICh0ZXh0U3RhdGUuZm9udC52ZXJ0aWNhbCA/IDEgOiAtMSkgKiB0ZXh0U3RhdGUuZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICBjb25zdCBlbGVtZW50cyA9IGFyZ3NbMF07CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGVsZW1lbnRzLmxlbmd0aDsgaSA8IGlpIC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGVsZW1lbnRzW2ldOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0QnVmZmVyLnB1c2goaXRlbSk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gIm51bWJlciIgJiYgaXRlbSAhPT0gMCkgewogICAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IGl0ZW0gKiBzcGFjZUZhY3RvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBlbGVtZW50cy5hdCgtMSk7CiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5wdXNoKGl0ZW0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgc2hvd1NwYWNlZFRleHRCdWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgICAgICBidWlsZFRleHRDb250ZW50SXRlbSh7CiAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgZXh0cmFTcGFjaW5nOiAwCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNhcnJpYWdlUmV0dXJuKCk7CiAgICAgICAgICAgIGJ1aWxkVGV4dENvbnRlbnRJdGVtKHsKICAgICAgICAgICAgICBjaGFyczogYXJnc1syXSwKICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IDAKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRYT2JqZWN0OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoIXhvYmpzKSB7CiAgICAgICAgICAgICAgeG9ianMgPSByZXNvdXJjZXMuZ2V0KCJYT2JqZWN0IikgfHwgX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgdmFyIG5hbWUgPSBhcmdzWzBdLm5hbWU7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkTmFtZSAmJiBlbXB0eVhPYmplY3RDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlWE9iamVjdCwgcmVqZWN0WE9iamVjdCkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxldCB4b2JqID0geG9ianMuZ2V0UmF3KG5hbWUpOwogICAgICAgICAgICAgIGlmICh4b2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHlYT2JqZWN0Q2FjaGUuZ2V0QnlSZWYoeG9iaikpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgZ2xvYmFsSW1hZ2UgPSBzZWxmLmdsb2JhbEltYWdlQ2FjaGUuZ2V0RGF0YSh4b2JqLCBzZWxmLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsSW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgeG9iaiA9IHhyZWYuZmV0Y2goeG9iaik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICghKHhvYmogaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgYmUgYSBzdHJlYW0iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHhvYmouZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICAgICAgICBpZiAoISh0eXBlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgaGF2ZSBhIE5hbWUgc3VidHlwZSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZS5uYW1lICE9PSAiRm9ybSIpIHsKICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgY3VycmVudFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCk7CiAgICAgICAgICAgICAgY29uc3QgeE9ialN0YXRlTWFuYWdlciA9IG5ldyBTdGF0ZU1hbmFnZXIoY3VycmVudFN0YXRlKTsKICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSB4b2JqLmRpY3QuZ2V0QXJyYXkoIk1hdHJpeCIpOwogICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KG1hdHJpeCkgJiYgbWF0cml4Lmxlbmd0aCA9PT0gNikgewogICAgICAgICAgICAgICAgeE9ialN0YXRlTWFuYWdlci50cmFuc2Zvcm0obWF0cml4KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgICAgICAgY29uc3Qgc2lua1dyYXBwZXIgPSB7CiAgICAgICAgICAgICAgICBlbnF1ZXVlSW52b2tlZDogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgIHRoaXMuZW5xdWV1ZUludm9rZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUoY2h1bmssIHNpemUpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGdldCBkZXNpcmVkU2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHNpbmsuZGVzaXJlZFNpemU7CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZ2V0IHJlYWR5KCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gc2luay5yZWFkeTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIHNlbGYuZ2V0VGV4dENvbnRlbnQoewogICAgICAgICAgICAgICAgc3RyZWFtOiB4b2JqLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHJlc291cmNlczogeG9iai5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyOiB4T2JqU3RhdGVNYW5hZ2VyLAogICAgICAgICAgICAgICAgY29tYmluZVRleHRJdGVtcywKICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50LAogICAgICAgICAgICAgICAgc2luazogc2lua1dyYXBwZXIsCiAgICAgICAgICAgICAgICBzZWVuU3R5bGVzLAogICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhCiAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBpZiAoIXNpbmtXcmFwcGVyLmVucXVldWVJbnZva2VkKSB7CiAgICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICB9LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRUZXh0Q29udGVudCAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0R1N0YXRlOgogICAgICAgICAgICBpc1ZhbGlkTmFtZSA9IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lOwogICAgICAgICAgICBuYW1lID0gYXJnc1swXS5uYW1lOwogICAgICAgICAgICBpZiAoaXNWYWxpZE5hbWUgJiYgZW1wdHlHU3RhdGVDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlR1N0YXRlLCByZWplY3RHU3RhdGUpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGV4dEdTdGF0ZSA9IHJlc291cmNlcy5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICAgICAgICAgIGlmICghKGV4dEdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkV4dEdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGUgPSBleHRHU3RhdGUuZ2V0KG5hbWUpOwogICAgICAgICAgICAgIGlmICghKGdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGVGb250ID0gZ1N0YXRlLmdldCgiRm9udCIpOwogICAgICAgICAgICAgIGlmICghZ1N0YXRlRm9udCkgewogICAgICAgICAgICAgICAgZW1wdHlHU3RhdGVDYWNoZS5zZXQobmFtZSwgZ1N0YXRlLm9iaklkLCB0cnVlKTsKICAgICAgICAgICAgICAgIHJlc29sdmVHU3RhdGUoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgICB0ZXh0U3RhdGUuZm9udE5hbWUgPSBudWxsOwogICAgICAgICAgICAgIHRleHRTdGF0ZS5mb250U2l6ZSA9IGdTdGF0ZUZvbnRbMV07CiAgICAgICAgICAgICAgaGFuZGxlU2V0Rm9udChudWxsLCBnU3RhdGVGb250WzBdKS50aGVuKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0VGV4dENvbnRlbnQgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoaW5jbHVkZU1hcmtlZENvbnRlbnQpIHsKICAgICAgICAgICAgICBtYXJrZWRDb250ZW50RGF0YS5sZXZlbCsrOwogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudCIsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIGlmIChpbmNsdWRlTWFya2VkQ29udGVudCkgewogICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhLmxldmVsKys7CiAgICAgICAgICAgICAgbGV0IG1jaWQgPSBudWxsOwogICAgICAgICAgICAgIGlmIChhcmdzWzFdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgbWNpZCA9IGFyZ3NbMV0uZ2V0KCJNQ0lEIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudFByb3BzIiwKICAgICAgICAgICAgICAgIGlkOiBOdW1iZXIuaXNJbnRlZ2VyKG1jaWQpID8gYCR7c2VsZi5pZEZhY3RvcnkuZ2V0UGFnZU9iaklkKCl9X21jaWQke21jaWR9YCA6IG51bGwsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgaWYgKGluY2x1ZGVNYXJrZWRDb250ZW50KSB7CiAgICAgICAgICAgICAgaWYgKG1hcmtlZENvbnRlbnREYXRhLmxldmVsID09PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgbWFya2VkQ29udGVudERhdGEubGV2ZWwtLTsKICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICAgICAgICAgIHR5cGU6ICJlbmRNYXJrZWRDb250ZW50IgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoID49IHNpbmsuZGVzaXJlZFNpemUpIHsKICAgICAgICAgIHN0b3AgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgIGVucXVldWVDaHVuaygpOwogICAgICByZXNvbHZlKCk7CiAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFRleHRDb250ZW50IC0gaWdub3JpbmcgZXJyb3JzIGR1cmluZyAiJHt0YXNrLm5hbWV9IiBgICsgYHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICAgIH0pOwogIH0KICBleHRyYWN0RGF0YVN0cnVjdHVyZXMoZGljdCwgYmFzZURpY3QsIHByb3BlcnRpZXMpIHsKICAgIGNvbnN0IHhyZWYgPSB0aGlzLnhyZWY7CiAgICBsZXQgY2lkVG9HaWRCeXRlczsKICAgIGNvbnN0IHRvVW5pY29kZVByb21pc2UgPSB0aGlzLnJlYWRUb1VuaWNvZGUocHJvcGVydGllcy50b1VuaWNvZGUgfHwgZGljdC5nZXQoIlRvVW5pY29kZSIpIHx8IGJhc2VEaWN0LmdldCgiVG9Vbmljb2RlIikpOwogICA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iAoZ2x5cGhOYW1lID09PSAiLm5vdGRlZiIpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBlbmNvZGluZ1tjaGFyY29kZV0gPSBnbHlwaE5hbWU7CiAgICB9CiAgICBjb25zdCBnbHlwaHNVbmljb2RlTWFwID0gKDAsIF9nbHlwaGxpc3QuZ2V0R2x5cGhzVW5pY29kZSkoKTsKICAgIGZvciAoY29uc3QgY2hhcmNvZGUgaW4gZW5jb2RpbmcpIHsKICAgICAgbGV0IGdseXBoTmFtZSA9IGVuY29kaW5nW2NoYXJjb2RlXTsKICAgICAgaWYgKGdseXBoTmFtZSA9PT0gIiIpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdW5pY29kZSA9IGdseXBoc1VuaWNvZGVNYXBbZ2x5cGhOYW1lXTsKICAgICAgaWYgKHVuaWNvZGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCBjb2RlID0gMDsKICAgICAgc3dpdGNoIChnbHlwaE5hbWVbMF0pIHsKICAgICAgICBjYXNlICJHIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSAzKSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSA1KSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJDIjoKICAgICAgICBjYXNlICJjIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID49IDMgJiYgZ2x5cGhOYW1lLmxlbmd0aCA8PSA0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGVTdHIgPSBnbHlwaE5hbWUuc3Vic3RyaW5nKDEpOwogICAgICAgICAgICBpZiAoZm9yY2VHbHlwaHMpIHsKICAgICAgICAgICAgICBjb2RlID0gcGFyc2VJbnQoY29kZVN0ciwgMTYpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvZGUgPSArY29kZVN0cjsKICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihjb2RlKSAmJiBOdW1iZXIuaXNJbnRlZ2VyKHBhcnNlSW50KGNvZGVTdHIsIDE2KSkpIHsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc2ltcGxlRm9udFRvVW5pY29kZShwcm9wZXJ0aWVzLCB0cnVlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidSI6CiAgICAgICAgICB1bmljb2RlID0gKDAsIF91bmljb2RlLmdldFVuaWNvZGVGb3JHbHlwaCkoZ2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGlmICh1bmljb2RlICE9PSAtMSkgewogICAgICAgICAgICBjb2RlID0gdW5pY29kZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzd2l0Y2ggKGdseXBoTmFtZSkgewogICAgICAgICAgICBjYXNlICJmX2giOgogICAgICAgICAgICBjYXNlICJmX3QiOgogICAgICAgICAgICBjYXNlICJUX2giOgogICAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBnbHlwaE5hbWUucmVwbGFjZUFsbCgiXyIsICIiKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAg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VpbHRJbkNNYXBCb3VuZCwKICAgICAgICB1c2VDTWFwOiBudWxsCiAgICAgIH0pOwogICAgICBjb25zdCB0b1VuaWNvZGUgPSBbXSwKICAgICAgICBidWYgPSBbXTsKICAgICAgcHJvcGVydGllcy5jTWFwLmZvckVhY2goZnVuY3Rpb24gKGNoYXJjb2RlLCBjaWQpIHsKICAgICAgICBpZiAoY2lkID4gMHhmZmZmKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk1heCBzaXplIG9mIENJRCBpcyA2NSw1MzUiKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdWNzMiA9IHVjczJDTWFwLmxvb2t1cChjaWQpOwogICAgICAgIGlmICh1Y3MyKSB7CiAgICAgICAgICBidWYubGVuZ3RoID0gMDsKICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHVjczIubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBidWYucHVzaCgodWNzMi5jaGFyQ29kZUF0KGkpIDw8IDgpICsgdWNzMi5jaGFyQ29kZUF0KGkgKyAxKSk7CiAgICAgICAgICB9CiAgICAgICAgICB0b1VuaWNvZGVbY2hhcmNvZGVdID0gU3RyaW5nLmZyb21DaGFyQ29kZSguLi5idWYpOwogICAgICAgIH0KICAgICAgfSk7CiAgICAgIHJldHVybiBuZXcgX3RvX3VuaWNvZGVfbWFwLlRvVW5pY29kZU1hcCh0b1VuaWNvZGUpOwogICAgfQogICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuSWRlbnRpdHlUb1VuaWNvZGVNYXAocHJvcGVydGllcy5maXJzdENoYXIsIHByb3BlcnRpZXMubGFzdENoYXIpOwogIH0KICByZWFkVG9Vbmljb2RlKGNtYXBPYmopIHsKICAgIGlmICghY21hcE9iaikgewogICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKG51bGwpOwogICAgfQogICAgaWYgKGNtYXBPYmogaW5zdGFuY2Vv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Y2goZnVuY3Rpb24gKGNoYXJDb2RlLCB0b2tlbikgewogICAgICAgICAgaWYgKHR5cGVvZiB0b2tlbiA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KHRva2VuKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RyID0gW107CiAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IHRva2VuLmxlbmd0aDsgayArPSAyKSB7CiAgICAgICAgICAgIGNvbnN0IHcxID0gdG9rZW4uY2hhckNvZGVBdChrKSA8PCA4IHwgdG9rZW4uY2hhckNvZGVBdChrICsgMSk7CiAgICAgICAgICAgIGlmICgodzEgJiAweGY4MDApICE9PSAweGQ4MDApIHsKICAgICAgICAgICAgICBzdHIucHVzaCh3MSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgayArPSAyOwogICAgICAgICAgICBjb25zdCB3MiA9IHRva2VuLmNoYXJDb2RlQXQoaykgPDwgOCB8IHRva2VuLmNoYXJDb2RlQXQoayArIDEpOwogICAgICAgICAgICBzdHIucHVzaCgoKHcxICYgMHgzZmYpIDw8IDEwKSArICh3MiAmIDB4M2ZmKSArIDB4MTAwMDApOwogICAgICAgICAgfQogICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KC4uLnN0cik7CiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuVG9Vbmljb2RlTWFwKG1hcCk7CiAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgcmVhZFRvVW5pY29kZSAtIGlnbm9yaW5nIFRvVW5pY29kZSBkYXRhOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgICB0aHJvdyByZWFzb247CiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShudWxsKTsKICB9CiAgcmVhZENpZFRvR2lkTWFwKGdseXBoc0RhdGEsIHRvVW5pY29kZSkgewogICAgY29uc3QgcmVzdWx0ID0gW107CiAgICBmb3IgKGxldCBqID0gMCwgamogPSBnbHlwaHNEYXRhLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgZ2x5cGhJRCA9IGdseXBoc0RhdGFbaisrXSA8PCA4IHwgZ2x5cGhzRGF0YVtqXTsKICAgICAgY29uc3QgY29kZSA9IGogPj4gMTsKICAgICAgaWYgKGdseXBoSUQgPT09IDAgJiYgIXRvVW5pY29kZS5oYXMoY29kZSkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByZXN1bHRbY29kZV0gPSBnbHlwaElEOwogICAgfQogICAgcmV0dXJuIHJlc3VsdDsKICB9CiAgZXh0cmFjdFdpZHRocyhkaWN0LCBkZXNjcmlwdG9yLCBwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGdseXBoc1dpZHRocyA9IFtdOwogICAgbGV0IGRlZmF1bHRXaWR0aCA9IDA7CiAgICBjb25zdCBnbHlwaHNWTWV0cmljcyA9IFtdOwogICAgbGV0IGRlZmF1bHRWTWV0cmljczsKICAgIGxldCBpLCBpaSwgaiwgamosIHN0YXJ0LCBjb2RlLCB3aWR0aHM7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgZGVmYXVsdFdpZHRoID0gZGljdC5oYXMoIkRXIikgPyBkaWN0LmdldCgiRFciKSA6IDEwMDA7CiAgICAgIHdpZHRocyA9IGRpY3QuZ2V0KCJXIik7CiAgICAgIGlmICh3aWR0aHMpIHsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBzdGFydCA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaSsrXSk7CiAgICAgICAgICBjb2RlID0geHJlZi5mZXRjaElmUmVmKHdpZHRoc1tpXSk7CiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGUubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgICAgIGdseXBoc1dpZHRoc1tzdGFydCsrXSA9IHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3Qgd2lkdGggPSB4cmVmLmZldGNoSWZSZWYod2lkdGhzWysraV0pOwogICAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBjb2RlOyBqKyspIHsKICAgICAgICAgICAgICBnbHlwaHNXaWR0aHNbal0gPSB3aWR0aDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocHJvcGVydGllcy52ZXJ0aWNhbCkgewogICAgICAgIGxldCB2bWV0cmljcyA9IGRpY3QuZ2V0QXJyYXkoIkRXMiIpIHx8IFs4ODAsIC0xMDAwXTsKICAgICAgICBkZWZhdWx0Vk1ldHJpY3MgPSBbdm1ldHJpY3NbMV0sIGRlZmF1bHRXaWR0aCAqIDAuNSwgdm1ldHJpY3NbMF1dOwogICAgICAgIHZtZXRyaWNzID0gZGljdC5nZXQoIlcyIik7CiAgICAgICAgaWYgKHZtZXRyaWNzKSB7CiAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHZtZXRyaWNzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgc3RhcnQgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaSsrXSk7CiAgICAgICAgICAgIGNvZGUgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaV0pOwogICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICAgIGZvciAoaiA9IDAsIGpqID0gY29kZS5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tzdGFydCsrXSA9IFt4cmVmLmZldGNoSWZSZWYoY29kZVtqKytdKSwgeHJlZi5mZXRjaElmUmVmKGNvZGVbaisrXSksIHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBbeHJlZi5mZXRjaElmUmVmKHZtZXRyaWNzWysraV0pLCB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbKytpXSksIHhyZWYuZmV0Y2hJZlJlZih2bWV0cmljc1srK2ldKV07CiAgICAgICAgICAgICAgZm9yIChqID0gc3RhcnQ7IGogPD0gY29kZTsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tqXSA9IHZtZXRyaWM7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmaXJzdENoYXIgPSBwcm9wZXJ0aWVzLmZpcnN0Q2hhcjsKICAgICAgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICBpZiAod2lkdGhzKSB7CiAgICAgICAgaiA9IGZpcnN0Q2hhcjsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSs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vbnN0IGNvbXBvc2l0ZVdpZHRocyA9IGRpY3QuZ2V0KCJXIikgfHwgYmFzZURpY3QuZ2V0KCJXIik7CiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoY29tcG9zaXRlV2lkdGhzKSkgewogICAgICAgICAgY29uc3Qgd2lkdGhzQnVmID0gW107CiAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGNvbXBvc2l0ZVdpZHRocykgewogICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAibnVtYmVyIiB8fCBlbnRyeSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHdpZHRoc0J1Zi5wdXNoKGVudHJ5LnRvU3RyaW5nKCkpOwogICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoZW50cnkpKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3ViV2lkdGhzQnVmID0gW107CiAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIGVudHJ5KSB7CiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVsZW1lbnQgPT09ICJudW1iZXIiIHx8IGVsZW1lbnQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICAgICAgc3ViV2lkdGhzQnVmLnB1c2goZWxlbWVudC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goYFske3N1YldpZHRoc0J1Zi5qb2luKCl9XWApOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoLnVwZGF0ZSh3aWR0aHNCdWYuam9pbigpKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgY2lkVG9HaWRNYXAgPSBkaWN0LmdldFJhdygiQ0lEVG9HSURNYXAiKSB8fCBiYXNlRGljdC5nZXRSYXcoIkNJRFRvR0lETWFwIik7CiAgICA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2xpYyA6IF9mb250c191dGlscy5Gb250RmxhZ3MuTm9uc3ltYm9saWMpOwogICAgICAgIHByb3BlcnRpZXMgPSB7CiAgICAgICAgICB0eXBlLAogICAgICAgICAgbmFtZTogYmFzZUZvbnROYW1lLAogICAgICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgICAgIHdpZHRoczogbWV0cmljcy53aWR0aHMsCiAgICAgICAgICBkZWZhdWx0V2lkdGg6IG1ldHJpY3MuZGVmYXVsdFdpZHRoLAogICAgICAgICAgaXNTaW11bGF0ZWRGbGFnczogdHJ1ZSwKICAgICAgICAgIGZsYWdzLAogICAgICAgICAgZmlyc3RDaGFyLAogICAgICAgICAgbGFzdENoYXIsCiAgICAgICAgICB0b1VuaWNvZGUsCiAgICAgICAgICB4SGVpZ2h0OiAwLAogICAgICAgICAgY2FwSGVpZ2h0OiAwLAogICAgICAgICAgaXRhbGljQW5nbGU6IDAsCiAgICAgICAgICBpc1R5cGUzRm9udAogICAgICAgIH07CiAgICAgICAgY29uc3Qgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGJhc2VGb250TmFtZSk7CiAgICAgICAgbGV0IGZpbGUgPSBudWxsOwogICAgICAgIGlmIChzdGFuZGFyZEZvbnROYW1lKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLmlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICAgIGZpbGUgPSBhd2FpdCB0aGlzLmZldGNoU3RhbmRhcmRGb250RGF0YShzdGFuZGFyZEZvbnROYW1lKTsKICAgICAgICAgIHByb3BlcnRpZXMuaXNJbnRlcm5hbEZvbnQgPSAhIWZpbGU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLmV4dHJhY3REYXRhU3RydWN0dXJlcyhkaWN0LCBkaWN0LCBwcm9wZXJ0aWVzKS50aGVuKG5ld1Byb3BlcnRpZXMgPT4gewogICAgICAgICAgaWYgKHdpZHRocykgewogICAgICAgICAgICBjb25zdCBnbHlwaFdpZHRocyA9IFtdOwogICAgICAgICAgICBsZXQgaiA9IGZpcnN0Q2hhcjsKICAgICAgICAgICAgZm9yIChjb25zdCB3aWR0aCBvZiB3aWR0aHMpIHsKICAgICAgICAgICAgICBnbHlwaFdpZHRoc1tqKytdID0gdGhpcy54cmVmLmZldGNoSWZSZWYod2lkdGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5ld1Byb3BlcnRpZXMud2lkdGhzID0gZ2x5cGhXaWR0aHM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBuZXdQcm9wZXJ0aWVzLndpZHRocyA9IHRoaXMuYnVpbGRDaGFyQ29kZVRvV2lkdGgobWV0cmljcy53aWR0aHMsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBfZm9udHMuRm9udChiYXNlRm9udE5hbWUsIGZpbGUsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBsZXQgZm9udE5hbWUgPSBkZXNjcmlwdG9yLmdldCgiRm9udE5hbWUiKTsKICAgIGxldCBiYXNlRm9udCA9IGRpY3QuZ2V0KCJCYXNlRm9udCIpOwogICAgaWYgKHR5cGVvZiBmb250TmFtZSA9PT0gInN0cmluZyIpIHsKICAgICAgZm9udE5hbWUgPSBfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSk7CiAgICB9CiAgICBpZiAodHlwZW9mIGJhc2VGb250ID09PSAic3RyaW5nIikgewogICAgICBiYXNlRm9udCA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KGJhc2VGb250KTsKICAgIH0KICAgIGlmICghaXNUeXBlM0ZvbnQpIHsKICAgICAgY29uc3QgZm9udE5hbWVTdHIgPSBmb250TmFtZS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WUuZmFjdG9ycyB8fCBudWxsOwogICAgICAgIGZvbnRGaWxlID0gYXdhaXQgdGhpcy5mZXRjaFN0YW5kYXJkRm9udERhdGEoc3RhbmRhcmRGb250TmFtZS5uYW1lKTsKICAgICAgICBpc0ludGVybmFsRm9udCA9ICEhZm9udEZpbGU7CiAgICAgICAgYmFzZURpY3QgPSBkaWN0ID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udERpY3QpKGZvbnROYW1lLm5hbWUpOwogICAgICAgIGNvbXBvc2l0ZSA9IHRydWU7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAoIWlzVHlwZTNGb250KSB7CiAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGZvbnROYW1lLm5hbWUpOwogICAgICBpZiAoc3RhbmRhcmRGb250TmFtZSkgewogICAgICAgIGlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICBmb250RmlsZSA9IGF3YWl0IHRoaXMuZmV0Y2hTdGFuZGFyZEZvbnREYXRhKHN0YW5kYXJkRm9udE5hbWUpOwogICAgICAgIGlzSW50ZXJuYWxGb250ID0gISFmb250RmlsZTsKICAgICAgfQogICAgfQogICAgcHJvcGVydGllcyA9IHsKICAgICAgdHlwZSwKICAgICAgbmFtZTogZm9udE5hbWUubmFtZSwKICAgICAgc3VidHlwZSwKICAgICAgZmlsZTogZm9udEZpbGUsCiAgICAgIGxlbmd0aDEsCiAgICAgIGxlbmd0aDIsCiAgICAgIGxlbmd0aDMsCiAgICAgIGlzU3RhbmRhcmRGb250LAogICAgICBpc0ludGVybmFsRm9udCwKICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgY29tcG9zaXRlLAogICAgICBmaXhlZFBpdGNoOiBmYWxzZSwKICAgICAgZm9udE1hdHJpeDogZGljdC5nZXRBcnJheSgiRm9udE1hdHJpe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BlcmF0b3JMaXN0LmFyZ3NBcnJheVtpXTsKICAgICAgICAgIGxldCBqID0gMCwKICAgICAgICAgICAgamogPSBnU3RhdGVPYmoubGVuZ3RoOwogICAgICAgICAgd2hpbGUgKGogPCBqaikgewogICAgICAgICAgICBjb25zdCBbZ1N0YXRlS2V5XSA9IGdTdGF0ZU9ialtqXTsKICAgICAgICAgICAgc3dpdGNoIChnU3RhdGVLZXkpIHsKICAgICAgICAgICAgICBjYXNlICJUUiI6CiAgICAgICAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgICAgICAgY2FzZSAiQkciOgogICAgICAgICAgICAgIGNhc2UgIkJHMiI6CiAgICAgICAgICAgICAgY2FzZSAiVUNSIjoKICAgICAgICAgICAgICBjYXNlICJVQ1IyIjoKICAgICAgICAgICAgICAgIGdTdGF0ZU9iai5zcGxpY2UoaiwgMSk7CiAgICAgICAgICAgICAgICBqai0tOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaisrOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaSsrOwogICAgfQogIH0KfQpjbGFzcyBTdGF0ZU1hbmFnZXIgewogIGNvbnN0cnVjdG9yKCkgewogICAgbGV0IGluaXRpYWxTdGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IEV2YWxTdGF0ZSgpOwogICAgdGhpcy5zdGF0ZSA9IGluaXRpYWxTdGF0ZTsKICAgIHRoaXMuc3RhdGVTdGFjayA9IFtdOwogIH0KICBzYXZlKCkgewogICAgY29uc3Qgb2xkID0gdGhpcy5zdGF0ZTsKICAgIHRoaXMuc3RhdGVTdGFjay5wdXNoKHRoaXMuc3RhdGUpOwogICAgdGhpcy5zdGF0ZSA9IG9sZC5jbG9uZSgpOwogI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ZXRNaXRlckxpbWl0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXREYXNoLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJpID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0UmVuZGVyaW5nSW50ZW50LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGbGF0bmVzcywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5ncyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEdTdGF0ZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5xID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2F2ZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5RID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVzdG9yZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5jbSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnRyYW5zZm9ybSwKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5tID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRvLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmwgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5saW5lVG8sCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuYyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8sCiAgICAgICAgbnVtQXJnczogNiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQudiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jdXJ2ZVRvMywKICAgICAgICBudW1BcmdzOiA0LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5oID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xvc2VQYXRoLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJlID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVjdGFuZ2xlLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQucyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmNsb3NlU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJmKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJCKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUZpbGxTdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHRbImIqIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5uID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW5kUGF0aCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5XID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdFsiVyoiXSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVvQ2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luVGV4dCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVuZFRleHQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UdyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFdvcmRTcGFjaW5nLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlR6ID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0SFNjYWxlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRMID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0TGVhZGluZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UZiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZvbnQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVHIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0UmVuZGVyaW5nTW9kZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UcyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFRleHRSaXNlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRkID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVEQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVG0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0TWF0cml4LAogICAgICAgIG51bUFyZ3M6IDYsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJUKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubmV4dExpbmUsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGogPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5USiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyInIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyciJ10gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aCwKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aEFuZEJvdW5kcywKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5DUyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yU3BhY2UsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuY3MgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ29sb3JTcGFjZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5TQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuU0NOID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JOLAogICAgICAgIG51bUFyZ3M6IDMzLAogICAgICAgIHZhcmlhYmxlQXJnczogdHJ1ZQogICAgICB9OwogICAgICB0LnNjID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuc2NuID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yTiwKICAgICAgICBudW1BcmdzOiAzMywKICAgICAgICB2YXJpYWJsZUFyZ3M6IHRydWUKICAgICAgfTsKICAgICAgdC5HID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlR3JheSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5nID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbEdyYXksCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuUkcgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5yZyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5LID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmsgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnNoID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2hhZGluZ0ZpbGwsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQkkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbklubGluZUltYWdlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LklEID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5JbWFnZURhdGEsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRUkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRJbmxpbmVJbWFnZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EbyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnBhaW50WE9iamVjdCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5NUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludFByb3BzLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJNQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CREMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FTUMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRNYXJrZWRDb250ZW50LAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJYID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5Db21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRVggPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRDb21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQk0gPSBudWxsOwogICAgICB0LkJEID0gbnVsbDsKICAgICAgdC50cnVlID0gbnVsbDsKICAgICAgdC5mYSA9IG51bGw7CiAgICAgIHQuZmFsID0gbnVsbDsKICAgICAgdC5mYWxzID0gbnVsbDsKICAgICAgdC5mYWxzZSA9IG51bGw7CiAgICAgIHQubnUgPSBudWxsOwogICAgICB0Lm51bCA9IG51bGw7CiAgICAgIHQubnVsbCA9IG51bGw7CiAgICB9KTsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAib3BNYXAiLCBnZXRPUE1hcCgpKTsKICB9CiAgc3RhdGljIGdld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AgICAgaWYgKCFvcFNwZWMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBjb21tYW5kICIke2NtZH0iLmApOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGZuID0gb3BTcGVjLmlkOwogICAgICAgIGNvbnN0IG51bUFyZ3MgPSBvcFNwZWMubnVtQXJnczsKICAgICAgICBsZXQgYXJnc0xlbmd0aCA9IGFyZ3MgIT09IG51bGwgPyBhcmdzLmxlbmd0aCA6IDA7CiAgICAgICAgaWYgKCF0aGlzLl9pc1BhdGhPcCkgewogICAgICAgICAgdGhpcy5fbnVtSW52YWxpZFBhdGhPUFMgPSAwOwogICAgICAgIH0KICAgICAgICB0aGlzLl9pc1BhdGhPcCA9IGZuID49IF91dGlsLk9QUy5tb3ZlVG8gJiYgZm4gPD0gX3V0aWwuT1BTLmVuZFBhdGg7CiAgICAgICAgaWYgKCFvcFNwZWMudmFyaWFibGVBcmdzKSB7CiAgICAgICAgICBpZiAoYXJnc0xlbmd0aCAhPT0gbnVtQXJncykgewogICAgICAgICAgICBjb25zdCBub25Qcm9jZXNzZWRBcmdzID0gdGhpcy5ub25Qcm9jZXNzZWRBcmdzOwogICAgICAgICAgICB3aGlsZSAoYXJnc0xlbmd0aCA+IG51bUFyZ3MpIHsKICAgICAgICAgICAgICBub25Qcm9jZXNzZWRBcmdzLnB1c2goYXJncy5zaGlmdCgpKTsKICAgICAgICAgICAgICBhcmdzTGVuZ3RoLS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKGFyZ3NMZW5ndGggPCBudW1BcmdzICYmIG5vblByb2Nlc3NlZEFyZ3MubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYXJncy51bnNoaWZ0KG5vblByb2Nlc3NlZEFyZ3MucG9wKCkpOwogICAgICAgICAgICAgIGFyZ3NMZW5ndGgrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGFyZ3NMZW5ndGggPCBudW1BcmdzKSB7CiAgICAgICAgICAgIGNvbnN0IHBhcnRpYWxNc2cgPSBgY29tbWFuZCAke2NtZH06IGV4cGVjdGVkICR7bnVtQXJnc30gYXJncywgYCArIGBidXQgcmVjZWl2ZWQgJHthcmdzTGVuZ3RofSBhcmdzLmA7CiAgICAgICAgICAgIGlmICh0aGlzLl9pc1BhdGhPcCAmJiArK3RoaXMuX251bUludmFsaWRQYXRoT1BTID4gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLk1BWF9JTlZBTElEX1BBVEhfT1BTKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFNraXBwaW5nICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgaWYgKGFyZ3MgIT09IG51bGwpIHsKICAgICAgICAgICAgICBhcmdzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChhcmdzTGVuZ3RoID4gbnVtQXJncykgewogICAgICAgICAgKDAsIF91dGlsLmluZm8pKGBDb21tYW5kICR7Y21kfTogZXhwZWN0ZWQgWzAsICR7bnVtQXJnc31dIGFyZ3MsIGAgKyBgYnV0IHJlY2VpdmVkICR7YXJnc0xlbmd0aH0gYXJncy5gKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5wcmVwcm9jZXNzQ29tbWFuZChmbiwgYXJncyk7CiAgICAgICAgb3BlcmF0aW9uLmZuID0gZm47CiAgICAgICAgb3BlcmF0aW9uLmFyZ3MgPSBhcmdzOwogICAgICAgIHJldHVybiB0c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MucG9zKytdOwogICAgfQogICAgcmVhZE51bWJlcigpIHsKICAgICAgbGV0IG4gPSAwOwogICAgICBsZXQgbGFzdDsKICAgICAgZG8gewogICAgICAgIGNvbnN0IGIgPSB0aGlzLnJlYWRCeXRlKCk7CiAgICAgICAgaWYgKGIgPCAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoInVuZXhwZWN0ZWQgRU9GIGluIGJjbWFwIik7CiAgICAgICAgfQogICAgICAgIGxhc3QgPSAhKGIgJiAweDgwKTsKICAgICAgICBuID0gbiA8PCA3IHwgYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZWFkU2lnbmVkKCkgewogICAgICBjb25zdCBuID0gdGhpcy5yZWFkTnVtYmVyKCk7CiAgICAgIHJldHVybiBuICYgMSA/IH4obiA+Pj4gMSkgOiBuID4+PiAxOwogICAgfQogICAgcmVhZEhleChudW0sIHNpemUpIHsKICAgICAgbnVtLnNldCh0aGlzLmJ1ZmZlci5zdWJhcnJheSh0aGlzLnBvcywgdGhpcy5wb3MgKyBzaXplICsgMSkpOwogICAgICB0aGlzLnBvcyArPSBzaXplICsgMTsKICAgIH0KICAgIHJlYWRIZXhOdW1iZXIobnVtLCBzaXplKSB7CiAgICAgIGxldCBsYXN0OwogICAgICBjb25zdCBzdGFjayA9IHRoaXMudG1wQnVmOwogICAgICBsZXQgc3AgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgYiA9IHRoaXMucmVhZEJ5dGUoKTsKICAgICAgICBpZiAoYiA8IDApIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigidW5leHBlY3RlZCBFT0YgaW4gYmNtYXAiKTsKICAgICAgICB9CiAgICAgICAgbGFzdCA9ICEoYiAmIDB4ODApOwogICAgICAgIHN0YWNrW3NwKytdID0gYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgbGV0IGkgPSBzaXplLAogICAgICAgIGJ1ZmZlciA9IDAsCiAgICAgICAgYnVmZmVyU2l6ZSA9IDA7CiAgICAgIHdoaWxlIChpID49IDApIHsKICAgICAgICB3aGlsZSAoYnVmZmVyU2l6ZSA8IDggJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgYnVmZmVyIHw9IHN0YWNrWy0tc3BdIDw8IGJ1ZmZlclNpemU7CiAgICAgICAgICBidWZmZXJTaXplICs9IDc7CiAgICAgICAgfQogICAgICAgIG51bVtpXSA9IGJ1ZmZlciAmIDI1NTsKICAgICAgICBpLS07CiAgICAgICAgYnVmZmVyID4+PSA4OwogICAgICAgIGJ1ZmZlclNpemUgLT0gODsKICAgICAgfQogICAgfQogICAgcmVhZEhleFNpZ25lZChudW0sIHNpemUpIHsKICAgICAgdGhpcy5yZWFkSGV4TnVtYmVyKG51bSwgc2l6ZSk7CiAgICAgIGNvbnN0IHNpZ24gPSBudW1bc2l6ZV0gJiAxID8gMjU1IDogMDsKICAgICAgbGV0IGMgPSAwOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBzaXplOyBpKyspIHsKICAgICAgICBjID0gKGMgJiAxKSA8PCA4IHwgbnVtW2ldOwogICAgICAgIG51bVtpXSA9IGMgPj4gMSBeIHNpZ247CiAgICAgIH0KICAgIH0KICAgIHJlYWRTdHJpbmcoKSB7CiAgICAgIGNvbnN0IGxlbiA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICBsZXQgcyA9ICIiOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHRoaXMucmVhZE51bWJlcigpKTsKICAgICAgfQogICAgICByZXR1cm4gczsKICAgIH0KICB9CiAgY2xhc3MgQmluYXJ5Q01hcFJlYWRlciB7CiAgICBhc3luYyBwcm9jZXNzKGRhdGEsIGNNYXAsIGV4dGVuZCkgewogICAgICBjb25zdCBzdHJlYW0gPSBuZXcgQmluYXJ5Q01hcFN0cmVhbShkYXRhKTsKICAgICAgY29uc3QgaGVhZGVyID0gc3RyZWFtLnJlYWRCeXRlKCk7CiAgICAgIGNNYXAudmVydGljYWwgPSAhIShoZWFkZXIgJiAxKTsKICAgICAgbGV0IHVzZUNNYXAgPSBudWxsOwogICAgICBjb25zdCBzdGFydCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGVuZCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGNoYXIgPSBuZXcgVWludDhBcnJheShNQVhfTlVNX1NJWkUpOwogICAgICBjb25zdCBjaGFyQ29kZSA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IHRtcCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGxldCBjb2RlOwogICAgICBsZXQgYjsKICAgICAgd2hpbGUgKChiID0gc3RyZWFtLnJlYWRCeXRlKCkpID49IDApIHsKICAgICAgICBjb25zdCB0eXBlID0gYiA+PiA1OwogICAgICAgIGlmICh0eXBlID09PSA3KSB7CiAgICAgICAgICBzd2l0Y2ggKGIgJiAweDFmKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBzdHJlYW0ucmVhZFN0cmluZygpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgdXNlQ01hcCA9IHN0cmVhbS5yZWFkU3RyaW5nKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc2VxdWVuY2UgPSAhIShiICYgMHgxMCk7CiAgICAgICAgY29uc3QgZGF0YVNpemUgPSBiICYgMTU7CiAgICAgICAgaWYgKGRhd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JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGlmICghc2VxdWVuY2UpIHsKICAgICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgICAgYWRkSGV4KGNoYXIsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWRTaWduZWQoKSArIChjb2RlICsgMSk7CiAgICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICBjTWFwLm1hcENpZFJhbmdlKGhleFRvSW50KHN0YXJ0LCBkYXRhU2l6ZSksIGhleFRvSW50KGVuZCwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHN0YXJ0LnNldChlbmQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICAgIGNNYXAubWFwQ2lkUmFuZ2UoaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSksIGNvZGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLm1hcE9uZShoZXhUb0ludChjaGFyLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBpZiAoIXNlcXVlbmNlKSB7CiAgICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcih0bXAsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoY2hhciwgdG1wLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpbmNIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleFNpZ25lZCh0bXAsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoY2hhckNvZGUsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwT25lKGhleFRvSW50KGNoYXIsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA1OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgY01hcC5tYXBCZlJhbmdlKGhleFRvSW50KHN0YXJ0LCB1Y3MyRGF0YVNpemUpLCBoZXhUb0ludChlbmQsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgc3RhcnQuc2V0KGVuZCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZ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gICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJNYWxmb3JtZWQgQ01hcDogZXhwZWN0ZWQgaW50LiIpOwogICAgfQogIH0KICBmdW5jdGlvbiBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRiZmNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VCZlJhbmdlKGNNYXAsIGxleGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgImVuZGJmcmFuZ2UiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3QgbG93ID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBoaWdoID0gc3RyVG9JbnQob2JqKTsKICAgICAg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jsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdEludChvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRSYW5nZShjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRjaWRyYW5nZSIpKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBsb3cgPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0U3RyaW5nKG9iaik7CiAgICAgIGNvbnN0IGhpZ2ggPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0SW50KG9iaik7CiAgICAgIGNvbnN0IGRzdExvdyA9IG9iajsKICAgICAgY01hcC5tYXBDaWRSYW5nZShsb3csIGhpZ2gsIGRzdExvdyk7CiAgICB9CiAgfQogIGZ1bmN0aW9uIHBhcnNlQ29kZXNwYWNlUmFuZ2UoY01hcCwgbGV4ZXIpIHsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGxldCBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgaWYgKG9iaiA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKCgwL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ewogICAgICB0cnkgewogICAgICAgIGNvbnN0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBpZiAob2JqLm5hbWUgPT09ICJXTW9kZSIpIHsKICAgICAgICAgICAgcGFyc2VXTW9kZShjTWFwLCBsZXhlcik7CiAgICAgICAgICB9IGVsc2UgaWYgKG9iai5uYW1lID09PSAiQ01hcE5hbWUiKSB7CiAgICAgICAgICAgIHBhcnNlQ01hcE5hbWUoY01hcCwgbGV4ZXIpOwogICAgICAgICAgfQogICAgICAgICAgcHJldmlvdXMgPSBvYmo7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5DbWQpIHsKICAgICAgICAgIHN3aXRjaCAob2JqLmNtZCkgewogICAgICAgICAgICBjYXNlICJlbmRjbWFwIjoKICAgICAgICAgICAgICBicmVhayBvYmpMb29wOwogICAgICAgICAgICBjYXNlICJ1c2VjbWFwIjoKICAgICAgICAgICAgICBpZiAocHJldmlvdXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBlbWJlZGRlZFVzZUNNYXAgPSBwcmV2aW91cy5uYW1lOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5jb2Rlc3BhY2VyYW5nZSI6CiAgICAgICAgICAgICAgcGFyc2VDb2Rlc3BhY2VSYW5nZShjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luYmZjaGFyIjoKICAgICAgICAgICAgICBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luY2lkY2hhciI6CiAgICAgICAgICAgICAgcGFyc2VDaWRDaGFyKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5iZnJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUJmUmFuZ2UoY01hcCwgbGV4ZXIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJiZWdpbmNpZHJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUNpZFJhbmdlKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGV4OwogICAgICAgIH0KICAgICAgICAoMCwgX3V0aWwud2FybikoIkludmFsaWQgY01hcCBkYXRhOiAiICsgZXgpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICBpZiAoIXVzZUNNYXAgJiYgZW1iZWRkZWRVc2VDTWFwKSB7CiAgICAgIHVzZUNNYXAgPSBlbWJlZGRlZFVzZUNNYXA7CiAgICB9CiAgICBpZiAodXNlQ01hcCkgewogICAgICByZXR1cm4gZXh0ZW5kQ01hcChjTWFwLCBmZXRjaEJ1aWx0SW5DTWFwLCB1c2VDTWFwKTsKICAgIH0KICAgIHJldHVybiBjTWFwOwogIH0KICBhc3luYyBmdW5jdGlvbiBleHRlbmRDTWFwKGNNYXAsIGZldGNoQnVpbHRJbkNNYXAsIHVzZUNNYXApIHsKICAgIGNNYXAudXNlQ01hcCA9IGF3YWl0IGNyZWF0ZUJ1aWx0SW5DTWFwKHVzZUNNYXAsIGZldGNoQnVpbHRJbkNNYXApOwogICAgaWYgKGNNYXAubnVtQ29kZXNw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MuUGFyc2VyRU9GRXhjZXB0aW9uKCJFbmQgb2YgZmlsZSBpbnNpZGUgYXJyYXkuIik7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICByZXR1cm4gYXJyYXk7CiAgICAgICAgY2FzZSAiPDwiOgogICAgICAgICAgY29uc3QgZGljdCA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KHRoaXMueHJlZik7CiAgICAgICAgICB3aGlsZSAoISgwLCBfcHJpbWl0aXZlcy5pc0NtZCkodGhpcy5idWYxLCAiPj4iKSAmJiB0aGlzLmJ1ZjEgIT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAoISh0aGlzLmJ1ZjEgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiTWFsZm9ybWVkIGRpY3Rpb25hcnk6IGtleSBtdXN0IGJlIGEgbmFtZSBvYmplY3QiKTsKICAgICAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3Qga2V5ID0gdGhpcy5idWYxLm5hbWU7CiAgICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZGljdC5zZXQoa2V5LCB0aGlzLmdldE9iaihjaXBoZXJUcmFuc2Zvcm0pKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLmJ1ZjEgPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAodGhpcy5yZWNvdmVyeU1vZGUpIHsKICAgICAgICAgICAgICByZXR1cm4gZGljdDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZX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CBFID0gMHg0NSwKICAgICAgSSA9IDB4NDksCiAgICAgIFNQQUNFID0gMHgyMCwKICAgICAgTEYgPSAweGEsCiAgICAgIENSID0gMHhkLAogICAgICBOVUwgPSAweDA7CiAgICBjb25zdCBsZXhlciA9IHRoaXMubGV4ZXIsCiAgICAgIHN0YXJ0UG9zID0gc3RyZWFtLnBvcywKICAgICAgbiA9IDEwOwogICAgbGV0IHN0YXRlID0gMCwKICAgICAgY2gsCiAgICAgIG1heWJlRUlQb3M7CiAgICB3aGlsZSAoKGNoID0gc3RyZWFtLmdldEJ5dGUoKSkgIT09IC0xKSB7CiAgICAgIGlmIChzdGF0ZSA9PT0gMCkgewogICAgICAgIHN0YXRlID0gY2ggPT09IEUgPyAxIDogMDsKICAgICAgfSBlbHNlIGlmIChzdGF0ZSA9PT0gMSkgewogICAgICAgIHN0YXRlID0gY2ggPT09IEkgPyAyIDogMDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoY2ggPT09IFNQQUNFIHx8IGNoID09PSBMRiB8fCBjaCA9PT0gQ1IpIHsKICAgICAgICAgIG1heWJlRUlQb3MgPSBzdHJlYW0ucG9zOwogICAgICAgICAgY29uc3QgZm9sbG93aW5nQnl0ZXMgPSBzdHJlYW0ucGVla0J5dGVzKG4pOwogICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm9sbG93aW5nQnl0ZXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICBjaCA9IGZvbGxvd2luZ0J5dGVzW2ldOwogICAgICAgICAgICBpZiAoY2ggPT09IE5VTCAmJiBmb2xsb3dpbmdCeXRlc1tpICsgMV0gIT09IE5VTCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjaCAhPT0gTEYgJiYgY2ggIT09IENSICYmIChjaCA8IFNQQUNFIHx8IGNoID4gMHg3ZikpIHsKICAgICAgICAgICAgICBzdGF0ZSA9IDA7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZSAhPT0gMikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChsZXhlci5rbm93bkNvbW1hbmRzKSB7CiAgICAgICAgICAgIGNvbnN0IG5leHRPYmogPSBsZXhlci5wZWVrT2JqKCk7CiAgICAgICAgICAgIGlmIChuZXh0T2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuQ21kICYmICFsZXhlci5rbm93bkNvbW1hbmRzW25leHRPYmouY21kXSkgewogICAgICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZCAtIGBsZXhlci5rbm93bkNvbW1hbmRzYCBpcyB1bmRlZmluZWQuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdGUgPT09IDIpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChjaCA9PT0gLTEpIHsKICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZDogIiArICJSZWFjaGVkIHRoZSBlbmQgb2YgdGhlIHN0cmVhbSB3aXRob3V0IGZpbmRpbmcgYSB2YWxpZCBFSSBtYXJrZXIiKTsKICAgICAgaWYgKG1heWJlRUlQb3MpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoJy4uLiB0cnlpbmcgdG8gcmVjb3ZlciBieSB1c2luZyB0aGUgbGFzdCAiRUkiIG9jY3VycmVuY2UuJyk7CiAgICAgICAgc3RyZWFtLnNraXAoLShzdHJlYW0ucG9zIC0gbWF5YmVFSVBvcykpOwogICAgICB9CiAgICB9CiAgICBsZXQgZW5kT2Zmc2V0ID0gNDsKICAgIHN0cmVhbS5za2lwKC1lbmRPZmZzZXQpOwogICAgY2ggPSBzdHJlYW0ucGVla0J5dGUoKTsKICAgIHN0cmVhbS5za2lwKGVuZE9mZnNldCk7CiAgICBpZiAoISgwLCBfY29yZV91dGlscy5pc1doaXRlU3BhY2UpKGNoKSkgewogICAgICBlbmRPZmZzZXQtLTsKICAgIH0KICAgIHJldHVybiBzdHJlYW0ucG9zIC0gZW5kT2Zmc2V0IC0gc3RhcnRQb3M7CiAgfQogIGZpbmREQ1REZWNvZGVJbmxpbmVTdHJlYW1FbmQoc3RyZWFtKSB7CiAgICBjb25zdCBzdGFydFBvcyA9IHN0cmVhbS5wb3M7CiAgICBsZXQgZm91bmRFT0kgPSBmYWxzZSwKICAgICAgYiwKICAgICAgbWFya2VyTGVuZ3RoOwogICAgd2hpbGUgKChiID0gc3RyZWFtLmdldEJ5dGUoKSkgIT09IC0xKSB7CiAgICAgIGlmIChiICE9PSAweGZmKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChzdHJlYW0uZ2V0Qnl0ZSgpKSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmOgogICAgICAgICAgc3RyZWFtLnNraXAoLTEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGQ5OgogICAgICAgICAgZm91bmRFT0kgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGMwOgogICAgICAgIGNhc2UgMHhjMToKICAgICAgICBjYXNlIDB4YzI6CiAgICAgICAgY2FzZSAweGMzOgogICAgICAgIGNhc2UgMHhjNToKICAgICAgICBjYXNlIDB4YzY6CiAgICAgICAgY2FzZSAweGM3OgogICAgICAgIGNhc2UgMHhjOToKICAgICAgICBjYXNlIDB4Y2E6CiAgICAgICAgY2FzZSAweGNiOgogICAgICAgIGNhc2UgMHhjZDoKICAgICAgICBjYXNlIDB4Y2U6CiAgICAgICAgY2FzZSAweGNmOgogICAgICAgIGNhc2UgMHhjNDoKICAgICAgICBjYXNlIDB4Y2M6CiAgICAgICAgY2FzZSAweGRhOgogICAgICAgIGNhc2UgMHhkYjoKICAgICAgICBjYXNlIDB4ZGM6CiAgICAgICAgY2FzZSAweGRkOgogICAgICAgIGNhc2UgMHhkZToKICAgICAgICBjYXNlIDB4ZGY6CiAgICAgICAgY2FzZSAweGUwOgogICAgICAgIGNhc2UgMHhlMToKICAgICAgICBjYXNlIDB4ZTI6CiAgICAgICAgY2FzZSAweGUzOgogICAgICAgIGNhc2UgMHhlNDoKICAgICAgICBjYXNlIDB4ZTU6CiAgICAgICAgY2FzZSAweGU2OgogICAgICAgIGNhc2UgMHhlNzoKICAgICAgICBjYXNlIDB4ZTg6CiAgICAgICAgY2FzZSAweGU5OgogICAgICAgIGNhc2UgMHhlYToKICAgICAgICBjYXNlIDB4ZWI6CiAgICAgICAgY2FzZSAweGVjOgogICAgICAgIGNhc2UgMHhlZDoKICAgICAgICBjYXNlIDB4ZWU6CiAgICAgICAgY2FzZSAweGVmOgogICAgICAgIGNhc2UgMHhmZToKICAgICAgICAgIG1hcmtlckxlbmd0aCA9IHN0cmVhbS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmIChtYXJrZXJMZW5ndGggPiAyKSB7CiAgICAgICAgICAgIHN0cmVhbS5za2lwKG1hcmtlckxlbmd0aCAtIDIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyZWFtLnNraXAoLTIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGZvdW5kRU9JKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGxlbmd0aCA9IHN0cmVhbS5wb3MgLSBzdGFydFBvczsKICAgIGlmIChiID09PSAtMSkgewogICAgICAoMCwgX3V0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2l0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgICAgICAgZGl2aWRlQnkgKj0gMTA7CiAgICAgICAgICB9CiAgICAgICAgICBiYXNlVmFsdWUgPSBiYXNlVmFsdWUgKiAxMCArIGN1cnJlbnREaWdpdDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MmUpIHsKICAgICAgICBpZiAoZGl2aWRlQnkgPT09IDApIHsKICAgICAgICAgIGRpdmlkZUJ5ID0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDJkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJCYWRseSBmb3JtYXR0ZWQgbnVtYmVyOiBtaW51cyBzaWduIGluIHRoZSBtaWRkbGUiKTsKICAgICAgfSBlbHNlIGlmIChjaCA9PT0gMHg0NSB8fCBjaCA9PT0gMHg2NSkgewogICAgICAgIGNoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICAgIGlmIChjaCA9PT0gMHgyYiB8fCBjaCA9PT0gMHgyZCkgewogICAgICAgICAgcG93ZXJWYWx1ZVNpZ24gPSBjaCA9PT0gMHgyZCA/IC0xIDogMTsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB9IGVsc2UgaWYgKGNoIDwgMHgzMCB8fCBjaCA+IDB4MzkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBlTm90YXRpb24gPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgYmFzZVZhbHVlIC89IGRpdmlkZUJ5OwogICAgfQogICAgaWYgKGVOb3RhdGlvbikgewogICAgICBiYXNlVmFsdWUgKj0gMTAgKiogKHBvd2VyVmFsdWVTaWduICogcG93ZXJWYWx1ZSk7CiAgICB9CiAgICByZXR1cm4gc2lnbiAqIGJhc2VWYWx1ZTsKICB9CiAgZ2V0U3RyaW5nKCkgewogICAgbGV0IG51bVBhcmVuID0gMTsKICAgIGxldCBkb25lID0gZmFsc2U7CiAgICBjb25zdCBzdHJCdWYgPSB0aGlzLnN0ckJ1ZjsKICAgIHN0ckJ1Zi5sZW5ndGggPSAwOwogICAgbGV0IGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IGNoYXJCdWZmZXJlZCA9IGZhbHNlOwogICAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICAgIGNhc2UgLTE6CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBzdHJpbmciKTsKICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI4OgogICAgICAgICAgKytudW1QYXJlbjsKICAgICAgICAgIHN0ckJ1Zi5wdXNoKCIoIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4Mjk6CiAgICAgICAgICBpZiAoLS1udW1QYXJlbiA9PT0gMCkgewogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyQnVmLnB1c2goIikiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHg1YzoKICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgc3dpdGNoIChjaCkgewogICAgICAgICAgICBjYXNlIC0xOgogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW50ZXJtaW5hdGVkIHN0cmluZyIpOwogICAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NmU6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxuIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg3MjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXHIiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDc0OgogICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKCJcdCIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NjI6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxiIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg2NjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXGYiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDVjOgogICAgICAgICAgICBjYXNlIDB4Mjg6CiAgICAgICAgICAgIGNhc2UgMHgyOToKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgzMDoKICAgICAgICAgICAgY2FzZSAweDMxOgogICAgICAgICAgICBjYXNlIDB4MzI6CiAgICAgICAgICAgIGNhc2UgMHgzMzoKICAgICAgICAgICAgY2FzZSAweDM0OgogICAgICAgICAgICBjYXNlIDB4MzU6CiAgICAgICAgICAgIGNhc2UgMHgzNjoKICAgICAgICAgICAgY2FzZSAweDM3OgogICAgICAgICAgICAgIGxldCB4ID0gY2ggJiAweDBmOwogICAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICAgIGNoYXJCdWZmZXJlZCA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzNykgewogICAgICAgICAgICAgICAgeCA9ICh4IDw8IDMpICsgKGNoICYgMHgwZik7CiAgICAgICAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICAgIGlmIChjaCA+PSAweDMwICYmIGNoIDw9IDB4MzcpIHsKICAgICAgICAgICAgICAgICAgY2hhckJ1ZmZlcmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHggPSAoeCA8PCAzKSArIChjaCAmIDB4MGYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKHgpKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDBkOgogICAgICAgICAgICAgIGlmICh0aGlzLnBlZWtDaGFyKCkgPT09IDB4MGEpIHsKICAgICAgICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgwYToKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgc3RyQnVmLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShjaCkpOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGRvbmUpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoIWNoYXJCdWZmZXJlZCkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXROYW1lKCkgewogICAgbGV0IGNoLCBwcmV2aW91c0NoOwogICAgY29uc3Qgc3RyQnVmID0gdGhpcy5zdHJCdWY7CiAgICBzdHJCdWYubGVuZ3RoID0gMDsKICAgIHdoaWxlICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDAgJiYgIXNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgaWYgKGNoID09PSAweDIzKSB7CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKHNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiTGV4ZXJfZ2V0TmFtZTogIiArICJOVU1CRVIgU0lHTiAoIykgc2hvdWxkIGJlIGZvbGxvd2VkIGJ5IGEgaGV4YWRlY2ltYWwgbnVtYmVyLiIpOwogICAgICAgICAgc3RyQnVmLnB1c2goIiMiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBjb25zdCB4ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgaWYgKHggIT09IC0xKSB7CiAgICAgICAgICBwcmV2aW91c0NoID0gY2g7CiAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIGNvbnN0IHgyID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoeDIgPT09IC0xKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgTGV4ZXJfZ2V0TmFtZTogSWxsZWdhbCBkaWdpdCAoJHtTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKX0pIGAgKyAiaW4gaGV4YWRlY2ltYWwgbnVtYmVyLiIpOwogICAgICAgICAgICBzdHJCdWYucHVzaCgiIyIsIFN0cmluZy5mcm9tQ2hhckNvZGUocHJldmlvdXNDaCkpOwogICAgICAgICAgICBpZiAoc3BlY2lhbENoYXJzW2NoXSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpKTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9C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cy5zdHJCdWY7CiAgICBzdHJCdWYubGVuZ3RoID0gMDsKICAgIGxldCBjaCA9IHRoaXMuY3VycmVudENoYXI7CiAgICBsZXQgaXNGaXJzdEhleCA9IHRydWU7CiAgICBsZXQgZmlyc3REaWdpdCwgc2Vjb25kRGlnaXQ7CiAgICB0aGlzLl9oZXhTdHJpbmdOdW1XYXJuID0gMDsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBoZXggc3RyaW5nIik7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSA9PT0gMSkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGlmIChpc0ZpcnN0SGV4KSB7CiAgICAgICAgICBmaXJzdERpZ2l0ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoZmlyc3REaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgc2Vjb25kRGlnaXQgPSB0b0hleERpZ2l0KGNoKTsKICAgICAgICAgIGlmIChzZWNvbmREaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoZmlyc3REaWdpdCA8PCA0IHwgc2Vjb25kRGlnaXQpKTsKICAgICAgICB9CiAgICAgICAgaXNGaXJzdEhleCA9ICFpc0ZpcnN0SGV4OwogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXRPYmooKSB7CiAgICBsZXQgY29tbWVudCA9IGZhbHNlOwogICAgbGV0IGNoID0gdGhpcy5jdXJyZW50Q2hhcjsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuRU9GOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSAhPT0gMSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgc3dpdGNoIChjaCB8IDApIHsKICAgICAgY2FzZSAweDMwOgogICAgICBjYXNlIDB4MzE6CiAgICAgIGNhc2UgMHgzMjoKICAgICAgY2FzZSAweDMzOgogICAgICBjYXNlIDB4MzQ6CiAgICAgIGNhc2UgMHgzNToKICAgICAgY2FzZSAweDM2OgogICAgICBjYXNlIDB4Mzc6CiAgICAgIGNhc2UgMHgzODoKICAgICAgY2FzZSAweDM5OgogICAgICBjYXNlIDB4MmI6CiAgICAgIGNhc2UgMHgyZDoKICAgICAgY2FzZSAweDJlOgogICAgICAgIHJldHVybiB0aGlzLmdldE51bWJlcigpOwogIC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aXMubmV4dENoYXIoKTsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYElsbGVnYWwgY2hhcmFjdGVyOiAke2NofWApOwogICAgfQogICAgbGV0IHN0ciA9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgaWYgKGNoIDwgMHgyMCB8fCBjaCA+IDB4N2YpIHsKICAgICAgY29uc3QgbmV4dENoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICBpZiAobmV4dENoID49IDB4MjAgJiYgbmV4dENoIDw9IDB4N2YpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICAgICAgfQogICAgfQogICAgY29uc3Qga25vd25Db21tYW5kcyA9IHRoaXMua25vd25Db21tYW5kczsKICAgIGxldCBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB3aGlsZSAoKGNoID0gdGhpcy5uZXh0Q2hhcigpKSA+PSAwICYmICFzcGVjaWFsQ2hhcnNbY2hdKSB7CiAgICAgIGNvbnN0IHBvc3NpYmxlQ29tbWFuZCA9IHN0ciArIFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgICBpZiAoa25vd25Db21tYW5kRm91bmQgJiYga25vd25Db21tYW5kc1twb3NzaWJsZUNvbW1hbmRdID09PSB1bmRlZmluZWQpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoc3RyLmxlbmd0aCA9PT0gMTI4KSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBDb21tYW5kIHRva2VuIHRvbyBsb25nOiAke3N0ci5sZW5ndGh9YCk7CiAgICAgIH0KICAgICAgc3RyID0gcG9zc2libGVDb21tYW5kOwogICAgICBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB9CiAgICBpZiAoc3RyID09PSAidHJ1ZSIpIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBpZiAoc3RyID09PSAiZmFsc2UiKSB7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGlmIChzdHIgPT09ICJudWxsIikgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGlmIChzdHIgPT09ICJCSSIpIHsKICAgICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5zdHJlYW0ucG9zOwogICAgfQogICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICB9CiAgcGVla09iaigpIHsKICAgIGNvbnN0IHN0cmVhbVBvcyA9IHRoaXMuc3RyZWFtLnBvcywKICAgICAgY3VycmVudENoYXIgPSB0aGlzLmN1cnJlbnRDaGFyLAogICAgICBiZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5iZWdpbklubGluZUltYWdlUG9zOwogICAgbGV0IG5leHRPYmo7CiAgICB0cnkgewogICAgICBuZXh0T2JqID0gdGhpcy5nZXRPYmooKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKGBwZWVrT2JqOiAke2V4fWApOwogICAgfQogICAgdGhpcy5zdHJlYW0ucG9zID0gc3RyZWFtUG9zOwogICAgdGhpcy5jdXJyZW50Q2hhciA9IGN1cnJlbnRDaGFyOwogICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gYmVnaW5JbmxpbmVJbWFnZVBvczsKICAgIHJldHVybiBuZXh0T2JqOwogIH0KICBza2lwVG9OZXh0TGluZSgpIHsKICAgIGx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IGhpbnRzTGVuZ3RoOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShoaW50cykgJiYgKChoaW50c0xlbmd0aCA9IGhpbnRzLmxlbmd0aCkgPT09IDIgfHwgaGludHNMZW5ndGggPT09IDQpKSB7CiAgICAgICAgZm9yIChsZXQgaW5kZXggPSAwOyBpbmRleCA8IGhpbnRzTGVuZ3RoOyBpbmRleCsrKSB7CiAgICAgICAgICBjb25zdCBoaW50ID0gaGludHNbaW5kZXhdOwogICAgICAgICAgaWYgKCEoTnVtYmVyLmlzSW50ZWdlcihoaW50KSAmJiBoaW50ID4gMCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBIaW50ICgke2luZGV4fSkgaW4gdGhlIGxpbmVhcml6YXRpb24gZGljdGlvbmFyeSBpcyBpbnZhbGlkLmApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gaGludHM7CiAgICAgIH0KICAgICAgdGhyb3cgbmV3IEVycm9yKCJIaW50IGFycmF5IGluIHRoZSBsaW5lYXJpemF0aW9uIGRpY3Rpb25hcnkgaXMgaW52YWxpZC4iKTsKICAgIH0KICAgIGNvbnN0IHBhcnNlciA9IG5ldyBQYXJzZXIoewogICAgICBsZXhlcjogbmV3IExleGVyKHN0cmVhbSksCiAgICAgIHhyZWY6IG51bGwKICAgIH0pOwogICAgY29uc3Qgb2JqMSA9IHBhcnNlci5nZXRPYmooKTsKICAgIGNvbnN0IG9iajIgPSBwYXJzZXIuZ2V0T2JqKCk7CiAgICBjb25zdCBvYmozID0gcGFyc2VyLmdldE9iaigpOwogICAgY29uc3QgbGluRGljdCA9IHBhcnNlci5nZXRPYmooKTsKICAgIGxldCBvYmosIGxlbmd0aDsKICAgIGlmICghKE51bWJlci5pc0ludGVnZXIob2JqMSkgJiYgTnVtYmVyLmlzSW50ZWdlcihvYmoyKSAmJiAoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iajMsICJvYmoiKSAmJiBsaW5EaWN0IG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XMuY29sdW1uczsKICAgIHRoaXMuY29kaW5nUG9zID0gMDsKICAgIHRoaXMucm93ID0gMDsKICAgIHRoaXMubmV4dExpbmUyRCA9IHRoaXMuZW5jb2RpbmcgPCAwOwogICAgdGhpcy5pbnB1dEJpdHMgPSAwOwogICAgdGhpcy5pbnB1dEJ1ZiA9IDA7CiAgICB0aGlzLm91dHB1dEJpdHMgPSAwOwogICAgdGhpcy5yb3dzRG9uZSA9IGZhbHNlOwogICAgbGV0IGNvZGUxOwogICAgd2hpbGUgKChjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKSkgPT09IDApIHsKICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIH0KICAgIGlmIChjb2RlMSA9PT0gMSkgewogICAgICB0aGlzLl9lYXRCaXRzKDEyKTsKICAgIH0KICAgIGlmICh0aGlzLmVuY29kaW5nID4gMCkgewogICAgICB0aGlzLm5leHRMaW5lMkQgPSAhdGhpcy5fbG9va0JpdHMoMSk7CiAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICB9CiAgfQogIHJlYWROZXh0Q2hhcigpIHsKICAgIGlmICh0aGlzLmVvZikgewogICAgICByZXR1cm4gLTE7CiAgICB9CiAgICBjb25zdCByZWZMaW5lID0gdGhpcy5yZWZMaW5lOwogICAgY29uc3QgY29kaW5nTGluZSA9IHRoaXMuY29kaW5nTGluZTsKICAgIGNvbnN0IGNvbHVtbnMgPSB0aGlzLmNvbHVtbnM7CiAgICBsZXQgcmVmUG9zLCBibGFja1BpeGVscywgYml0cywgaTsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPT09IDApIHsKICAgICAgaWYgKHRoaXMucm93c0RvbmUpIHsKICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9mKSB7CiAgICAgICAgcmV0dXJuIC0xOwogICAgICB9CiAgICAgIHRoaXMuZXJyID0gZmFsc2U7CiAgICAgIGxldCBjb2RlMSwgY29kZTIsIGNvZGUzOwogICAgICBpZiAodGhpcy5uZXh0TGluZTJEKSB7CiAgICAgICAgZm9yIChpID0gMDsgY29kaW5nTGluZVtpXSA8IGNvbHVtbnM7ICsraSkgewogICAgICAgICAgcmVmTGluZVtpXSA9IGNvZGluZ0xpbmVbaV07CiAgICAgICAgfQogICAgICAgIHJlZkxpbmVbaSsrXSA9IGNvbHVtbnM7CiAgICAgICAgcmVmTGluZVtpXSA9IGNvbHVtbnM7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIHJlZlBvcyA9IDA7CiAgICAgICAgYmxhY2tQaXhlbHMgPSAwOwogICAgICAgIHdoaWxlIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fZ2V0VHdvRGltQ29kZSgpOwogICAgICAgICAgc3dpdGNoIChjb2RlMSkgewogICAgICAgICAgICBjYXNlIHR3b0RpbVBhc3M6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zICsgMV0sIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBpZiAocmVmTGluZVtyZWZQb3MgKyAxXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1Ib3JpejoKICAgICAgICAgICAgICBjb2RlMSA9IGNvZGUyID0gMDsKICAgICAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTEgKz0gY29kZTMgPSB0aGlzLl9nZXRCbGFja0NvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTIgKz0gY29kZTMgPSB0aGlzLl9nZXRXaGl0ZUNvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMiArPSBjb2RlMyA9IHRoaXMuX2dldEJsYWNrQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVscyhjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSArIGNvZGUyLCBibGFja1BpeGVscyBeIDEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjM6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDMsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjE6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDEsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0MDoKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMocmVmTGluZVtyZWZQb3NdLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgdHdvRGltVmVydEwzOgogICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVsc05lZyhyZWZMaW5lW3JlZlBvc10gLSAzLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICBpZiAocmVmUG9zID4gMCkgewogICAgICAgICAgICAgICAgICAtLXJlZlBvczsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0TDI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzTmVnKHJlZkxpbmVbcmVmUG9zXSAtIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIGlmIChyZWZQb3MgPiAwKSB7CiAgICAgICAgICAgICAgICAgIC0tcmVmUG9zOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgKytyZWZQb3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICAgcmVmUG9zICs9IDI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIHR3b0RpbVZlcnRMMToKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHNOZWcocmVmTGluZVtyZWZQb3NdIC0gMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGJsYWNrUGl4ZWxzIF49IDE7CiAgICAgICAgICAgICAgaWYgKGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgaWYgKHJlZlBvcyA+IDApIHsKICAgICAgICAgICAgICAgICAgLS1yZWZQb3M7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgY2NpdHRFT0Y6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCAyZCBjb2RlIik7CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIGJsYWNrUGl4ZWxzID0gMDsKICAgICAgICB3aGlsZSAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICBjb2RlMSA9IDA7CiAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGNvZGUxICs9IGNvZGUzID0gdGhpcy5fZ2V0QmxhY2tDb2RlKCk7CiAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICB9IHdoaWxlIChjb2RlMyA+PSA2NCk7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGdvdEVPTCA9IGZhbHNlOwogICAgICBpZiAodGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICB0aGlzLmlucHV0Qml0cyAmPSB+NzsKICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9ibG9jayAmJiB0aGlzLnJvdyA9PT0gdGhpcy5yb3dzIC0gMSkgewogICAgICAgIHRoaXMucm93c0RvbmUgPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgIGlmICh0aGlzLmVvbGluZSkgewogICAgICAgICAgd2hpbGUgKGNvZGUxICE9PSBjY2l0dEVPRiAmJiBjb2RlMSAhPT0gMSkgewogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2hpbGUgKGNvZGUxID09PSAwKSB7CiAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgZ290RU9MID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9mICYmIHRoaXMuZW5jb2RpbmcgPiAwICYmICF0aGlzLnJvd3NEb25lKSB7CiAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIXRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9ibG9jayAmJiBnb3RFT0wgJiYgdGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgIHRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPj0gMCkgewogICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgICAgICAgY29kZTEgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgICAgICAgICAgaWYgKGNvZGUxICE9PSAxKSB7CiAgICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBydGMgY29kZTogIiArIGNvZGUxKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLl9sb29rQml0cygxKTsKICAgICAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHRoaXMuZXJyICYmIHRoaXMuZW9saW5lKSB7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTMpOwogICAgICAgICAgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjb2RlMSA+PiAxID09PSAxKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIShjb2RlMSAmIDEpOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29kaW5nTGluZVswXSA+IDApIHsKICAgICAgICB0aGlzLm91dHB1dEJpdHMgPSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zID0gMF07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyA9IDFdOwogICAgICB9CiAgICAgIHRoaXMucm93Kys7CiAgICB9CiAgICBsZXQgYzsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPj0gOCkgewogICAgICBjID0gdGhpcy5jb2RpbmdQb3MgJiAxID8gMCA6IDB4ZmY7CiAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSA4OwogICAgICBpZiAodGhpcy5vdXRwdXRCaXRzID09PSAwICYmIGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gLSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zIC0gMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGJpdHMgPSA4OwogICAgICBjID0gMDsKICAgICAgZG8gewogICAgICAgIGlmICh0eXBlb2YgdGhpcy5vdXRwdXRCaXRzICE9PSAibnVtYmVyIikgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdJbnZhbGlkIC9DQ0lUVEZheERlY29kZSBkYXRhLCAib3V0cHV0Qml0cyIgbXVzdCBiZSBhIG51bWJlci4nKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3V0cHV0Qml0cyA+IGJpdHMpIHsKICAgICAgICAgIGMgPDw9IGJpdHM7CiAgICAgICAgICBpZiAoISh0aGlzLmNvZGluZ1BvcyAmIDEpKSB7CiAgICAgICAgICAgIGMgfD0gMHhmZiA+PiA4IC0gYml0czsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSBiaXRzOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGMgPDw9IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIGlmICghKHRoaXMuY29kaW5nUG9zICYgMSkpIHsKICAgICAgICAgICAgYyB8PSAweGZmID4+IDggLSB0aGlzLm91dHB1dEJpdHM7CiAgICAgICAgICB9CiAgICAgICAgICBiaXRzIC09IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IDA7CiAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIC0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyAtIDFdOwogICAgICAgICAgfSBlbHNlIGlmIChiaXRzID4gMCkgewogICAgICAgICAgICBjIDw8PSBiaXRzOwogICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gd2hpbGUgKGJpdHMpOwogICAgfQogICAgaWYgKHRoaXMuYmxhY2spIHsKICAgICAgYyBePSAweGZmOwogICAgfQogICAgcmV0dXJuIGM7CiAgfQogIF9hZGRQaXhlbHMoYTEsIGJsYWNrUGl4ZWxzKSB7CiAgICBjb25zdCBjb2RpbmdMaW5lID0gdGhpcy5jb2RpbmdMaW5lOwogICAgbGV0IGNvZGluZ1BvcyA9IHRoaXMuY29kaW5nUG9zOwogICAgaWYgKGExID4gY29kaW5nTGluZVtjb2RpbmdQb3NdKSB7CiAgICAgIGlmIChhMSA+IHRoaXMuY29sdW1ucykgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgicm93IGlzIHdyb25nIGxlbmd0aCIpOwogICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICBhMSA9IHRoaXMuY29sdW1uczsKICAgICAgfQogICAgICBpZiAoY29kaW5nUG9zICYgMSBeIGJsYWNrUGl4ZWxzKSB7CiAgICAgICAgKytjb2RpbmdQb3M7CiAgICAgIH0KICAgICAgY29kaW5nTGluZVtjb2RpbmdQb3NdID0gYTE7CiAgICB9CiAgICB0aGlzLmNvZGluZ1BvcyA9IGNvZGluZ1BvczsKICB9CiAgX2FkZFBpe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IGxldCBjb2RlID0gdGhpcy5fbG9va0JpdHMoaSk7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiBbdHJ1ZSwgMSwgZmFsc2VdOwogICAgICB9CiAgICAgIGlmIChpIDwgZW5kKSB7CiAgICAgICAgY29kZSA8PD0gZW5kIC0gaTsKICAgICAgfQogICAgICBpZiAoIWxpbWl0VmFsdWUgfHwgY29kZSA+PSBsaW1pdFZhbHVlKSB7CiAgICAgICAgY29uc3QgcCA9IHRhYmxlW2NvZGUgLSBsaW1pdFZhbHVlXTsKICAgICAgICBpZiAocFswXSA9PT0gaSkgewogICAgICAgICAgdGhpcy5fZWF0Qml0cyhpKTsKICAgICAgICAgIHJldHVybiBbdHJ1ZSwgcFsxXSwgdHJ1ZV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gW2ZhbHNlLCAwLCBmYWxzZV07CiAgfQogIF9nZXRUd29EaW1Db2RlKCkgewogICAgbGV0IGNvZGUgPSAwOwogICAgbGV0IHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cyg3KTsKICAgICAgcCA9IHR3b0RpbVRhYmxlW2NvZGVdOwogICAgICBpZiAocCAmJiBwWzBdID4gMCkgewogICAgICAgIHRoaXMuX2VhdEJpdHMocFswXSk7CiAgICAgICAgcmV0dXJuIHBbMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGNvbnN0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgNywgdHdvRGltVGFibGUpOwogICAgICBpZiAocmVzdWx0WzBdICYmIHJlc3VsdFsyXSkgewogICAgICAgIHJldHVybiByZXN1bHRbMV07CiAgICAgIH0KICAgIH0KICAgICgwLCBfdXRpbC5pbmZvKSgiQmFkIHR3byBkaW0gY29kZSIpOwogICAgcmV0dXJuIGNjaXR0RU9GOwogIH0KICBfZ2V0V2hpdGVDb2RlKCkgewogICAgbGV0IGNvZGUgPSAwOwogICAgbGV0IHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDUgPT09IDApIHsKICAgICAgICBwID0gd2hpdGVUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcCA9IHdoaXRlVGFibGUyW2NvZGUgPj4gM107CiAgICAgIH0KICAgICAgaWYgKHBbMF0gPiAwKSB7CiAgICAgICAgdGhpcy5fZWF0Qml0cyhwWzBdKTsKICAgICAgICByZXR1cm4gcFsxXTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgOSwgd2hpdGVUYWJsZTIpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgICByZXN1bHQgPSB0aGlzLl9maW5kVGFibGVDb2RlKDExLCAxMiwgd2hpdGVUYWJsZTEpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgfQogICAgKDAsIF91dGlsLmluZm8pKCJiYWQgd2hpdGUgY29kZSIpOwogICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIHJldHVybiAxOwogIH0KICBfZ2V0QmxhY2tDb2RlKCkgewogICAgbGV0IGNvZGUsIHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMyk7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDcgPT09IDApIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSBpZiAoY29kZSA+PiA5ID09PSAwICYmIGNvZGUgPj4gNyAhPT0gMCkgewogICAgICAgIHAgPSBibGFja1RhYmxlMlsoY29kZSA+PiAxKSAtIDY0XTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTNbY29kZSA+PiA3XTsKICAgICAgfQogICAgICBpZiAocFswXSA+IDApIHsKICAgICAgICB0aGlzLl9lYXRCaXRzKHBbMF0pOwogICAgICAgIHJldHVybiBwWzFdOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBsZXQgcmVzdWx0ID0gdGhpcy5fZmluZFRhYmxlQ29kZSgyLCA2LCBibGFja1RhYmxlMyk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoNywgMTIsIGJsYWNrVGFibGUyLCA2NCk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMTAsIDEzLCBibGFja1RhYmxlMSk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICB9CiAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBibGFjayBjb2RlIik7CiAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgcmV0dXJuIDE7CiAgfQogIF9sb29rQml0cyhuKSB7CiAgICBsZXQgYzsKICAgIHdoaWxlICh0aGlzLmlucHV0Qml0cyA8IG4pIHsKICAgICAgaWYgKChjID0gdGhpcy5zb3VyY2UubmV4dCgpKSA9PT0gLTEpIHsKICAgICAgICBpZiAodGhpcy5pbnB1dEJpdHMgPT09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ZhbF0gPT09IGxlbikgewogICAgICAgICAgbGV0IGNvZGUyID0gMDsKICAgICAgICAgIGxldCB0ID0gY29kZTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgICBjb2RlMiA9IGNvZGUyIDw8IDEgfCB0ICYgMTsKICAgICAgICAgICAgdCA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGNvZGUyOyBpIDwgc2l6ZTsgaSArPSBza2lwKSB7CiAgICAgICAgICAgIGNvZGVzW2ldID0gbGVuIDw8IDE2IHwgdmFsOwogICAgICAgICAgfQogICAgICAgICAgKytjb2RlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIFtjb2RlcywgbWF4TGVuXTsKICB9CiAgcmVhZEJsb2NrKCkgewogICAgbGV0IGJ1ZmZlciwgbGVuOwogICAgY29uc3Qgc3RyID0gdGhpcy5zdHI7CiAgICBsZXQgaGRyID0gdGhpcy5nZXRCaXRzKDMpOwogICAgaWYgKGhkciAmIDEpIHsKICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgfQogICAgaGRyID4+PSAxOwogICAgaWYgKGhkciA9PT0gMCkgewogICAgICBsZXQgYjsKICAgICAgaWYgKChiID0gc3RyLmdldEJ5dGUoKSkgPT09IC0xKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJCYWQgYmxvY2sgaGVhZGVyIGluIGZsYXRlIHN0cmVhbSIpOwogICAgICB9CiAgICAgIGxldCBibG9ja0xlbiA9IGI7CiAgICAgIGlmICgoYiA9IHN0ci5nZXRCeXRlKCkpID09PSAtMSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiQmFkIGJsb2NrIGhlYWRlciBpbiBmbGF0ZSBzdHJlYW0iKTsKICAgICAgfQogICAgICBibG9ja0xlbiB8PSBiIDw8IDg7CiAgICAgIGlmICgoYiA9IHN0ci5nZXR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4QXJyYXkoY29kZXMpOwogICAgICBsZXQgYml0c0xlbmd0aCwgYml0c09mZnNldCwgd2hhdDsKICAgICAgd2hpbGUgKGkgPCBjb2RlcykgewogICAgICAgIGNvbnN0IGNvZGUgPSB0aGlzLmdldENvZGUoY29kZUxlbkNvZGVUYWIpOwogICAgICAgIGlmIChjb2RlID09PSAxNikgewogICAgICAgICAgYml0c0xlbmd0aCA9IDI7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW47CiAgICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAxNykgewogICAgICAgICAgYml0c0xlbmd0aCA9IDM7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW4gPSAwOwogICAgICAgIH0gZWxzZSBpZiAoY29kZSA9PT0gMTgpIHsKICAgICAgICAgIGJpdHNMZW5ndGggPSA3OwogICAgICAgICAgYml0c09mZnNldCA9IDExOwogICAgICAgICAgd2hhdCA9IGxlbiA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSBsZW4gPSBjb2RlOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGxldCByZXBlYXRMZW5ndGggPSB0aGlzLmdldEJpdHMoYml0c0xlbmd0aCkgKyBiaXRzT2Zmc2V0OwogICAgICAgIHdoaWxlIChyZXBlYXRMZW5ndGgtLSA+IDApIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSB3aGF0OwogICAgICAgIH0KICAgICAgfQogICAgICBsaXRDb2RlVGFibGUgPSB0aGlzLmdlbmVyYXRlSHVmZm1hblRhYmxlKGNvZGVMZW5ndGhzLnN1YmFycmF5KDAsIG51bUxpdENvZGVzKSk7CiAgICAgIGRpc3RDb2RlVGFibGUgPSB0aGlzLmdlbmVyYXRlSHVmZm1hblRhYmxlKGNvZGVMZW5ndGhzLnN1YmFycmF5KG51bUxp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DogMSwKICB5OiAtMgp9LCB7CiAgeDogLTIsCiAgeTogLTEKfSwgewogIHg6IC0xLAogIHk6IC0xCn0sIHsKICB4OiAwLAogIHk6IC0xCn0sIHsKICB4OiAxLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAwCn0sIHsKICB4OiAtMSwKICB5OiAwCn1dLCBbewogIHg6IC0zLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAtMQp9LCB7CiAgeDogLTEsCiAgeTogLTEKfSwgewogIHg6IDAsCiAgeTogLTEKfSwgewogIHg6IDEsCiAgeTogLTEKfSwgewogIHg6IC00LAogIHk6IDAKfSwgewogIHg6IC0zLAogIHk6IDAKfSwgewogIHg6IC0yLAogIHk6IDAKfSwgewogIHg6IC0xLAogIHk6IDAKfV1dOwpjb25zdCBSZWZpbmVtZW50VGVtcGxhdGVzID0gW3sKICBjb2Rpbmc6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9XSwKICByZWZlcmVuY2U6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAwLAogICAgeTogMAogIH0sIHsKICAgIHg6IDEsCiAgICB5OiAwCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAxCiAgfSwgewogICAgeDogMCwKICAgIHk6IDEKICB9LCB7CiAgICB4OiAxLAogICAgeTogMQogIH1dCn0sIHsKICBjb2Rpbmc6IFt7CiAgICB4OiAtMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMCwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAwCiAgfV0sCiAgcmVmZXJlbmNlOiBbewogICAgeDogMCwKICAgIHk6IC0xCiAgfS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vZGluZ0NvbnRleHQuY29udGV4dENhY2hlLmdldENvbnRleHRzKCJHQiIpOwogIGxldCBsdHAgPSAwLAogICAgaiwKICAgIGkwLAogICAgajAsCiAgICBjb250ZXh0TGFiZWwgPSAwLAogICAgYml0LAogICAgc2hpZnQ7CiAgZm9yIChsZXQgaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgaWYgKHByZWRpY3Rpb24pIHsKICAgICAgY29uc3Qgc2x0cCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgcHNldWRvUGl4ZWxDb250ZXh0KTsKICAgICAgbHRwIF49IHNsdHA7CiAgICAgIGlmIChsdHApIHsKICAgICAgICBiaXRtYXAucHVzaChyb3cpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICByb3cgPSBuZXcgVWludDhBcnJheShyb3cpOwogICAgYml0bWFwLnB1c2gocm93KTsKICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGlmICh1c2Vza2lwICYmIHNraXBbaV1bal0pIHsKICAgICAgICByb3dbal0gPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChqID49IHNiYl9sZWZ0ICYmIGogPCBzYmJfcmlnaHQgJiYgaSA+PSBzYmJfdG9wKSB7CiAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgJiByZXVzZU1hc2s7CiAgICAgICAgZm9yIChrID0gMDsgayA8IGNoYW5naW5nRW50cmllc0xlbmd0aDsgaysrKSB7CiAgICAgICAgICBpMCA9IGkgKyBjaGFuZ2luZ1RlbXBsYXRlWVtrXTsKICAgICAgICAgIGowID0gaiArIGNoYW5naW5nVGVtcGxhdGVYW2tdOwogICAgICAgICAgYml0ID0gYml0bWFwW2kwXVtqMF07CiAgICAgICAgICBpZiAoYml0KSB7CiAgICAgICAgICAgIGJpdCA9IGNoYW5naW5nVGVtcGxhdGVCaXRba107CiAgICAgICAgICAgIGN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EJpdG1hcDsKICAgICAgICBmb3IgKGkgPSBmaXJzdFN5bWJvbDsgaSA8IG51bWJlck9mU3ltYm9sc0RlY29kZWQ7IGkrKykgewogICAgICAgICAgYml0bWFwV2lkdGggPSBzeW1ib2xXaWR0aHNbaV07CiAgICAgICAgICB4TWF4ID0geE1pbiArIGJpdG1hcFdpZHRoOwogICAgICAgICAgc3ltYm9sQml0bWFwID0gW107CiAgICAgICAgICBmb3IgKHkgPSAwOyB5IDwgY3VycmVudEhlaWdodDsgeSsrKSB7CiAgICAgICAgICAgIHN5bWJvbEJpdG1hcC5wdXNoKGNvbGxlY3RpdmVCaXRtYXBbeV0uc3ViYXJyYXkoeE1pbiwgeE1heCkpOwogICAgICAgICAgfQogICAgICAgICAgbmV3U3ltYm9scy5wdXNoKHN5bWJvbEJpdG1hcCk7CiAgICAgICAgICB4TWluID0geE1heDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgY29uc3QgZXhwb3J0ZWRTeW1ib2xzID0gW10sCiAgICBmbGFncyA9IFtdOwogIGxldCBjdXJyZW50RmxhZyA9IGZhbHNlLAogICAgaSwKICAgIGlpOwogIGNvbnN0IHRvdGFsU3ltYm9sc0xlbmd0aCA9IHN5bWJvbHMubGVuZ3RoICsgbnVtYmVyT2ZOZXdTeW1ib2xzOwogIHdoaWxlIChmbGFncy5sZW5ndGggPCB0b3RhbFN5bWJvbHNMZW5ndGgpIHsKICAgIGxldCBydW5MZW5ndGggPSBodWZmbWFuID8gdGFibGVCMS5kZWNvZGUoaHVmZm1hbklucHV0KSA6IGRlY29kZUludGVnZXIoY29udGV4dENhY2hlLCAiSUFFWCIsIGRlY29kZXIpOwogICAgd2hpbGUgKHJ1bkxlbmd0aC0tKSB7CiAgICAgIGZsYWdzLnB1c2goY3VycmVudEZsYWcpOwogICAgfQogICAgY3VycmVudEZsYWcgPSAhY3VycmVudEZsYWc7CiAgfQogIGZvciAoaSA9IDAsIGlpID0gc3ltYm9scy5sZW5ndGg7IGkg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m93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gXj0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpiaWcyRXJyb3IoYG9wZXJhdG9yICR7Y29tYmluYXRpb25PcGVyYXRvcn0gaXMgbm90IHN1cHBvcnRlZGApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjdXJyZW50UyArPSBzeW1ib2xIZWlnaHQgLSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAodDIgPSAwOyB0MiA8IHN5bWJvbEhlaWdodDsgdDIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFQgKyB0Ml07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFt0Ml07CiAgICAgICAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSB8PSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSBePSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgSmJpZzJFcnJvcihgb3BlcmF0b3IgJHtjb21iaW5hdGlvbk9wZXJhdG9yfSBpcyBub3Qgc3VwcG9ydGVkYCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGN1cnJlbnRTICs9IHN5bWJvbFdpZHRoIC0gMTsKICAgICAgfQogICAgICBpKys7CiAgICAgIGNvbnN0IGRlbHRhUyA9IGh1ZmZtYW4gPyBodWZmbWFuVGFibGVzLnRhYmxlRGVsdGFTLmRlY29kZShodWZmbWFuSW5wdXQpIDogZGVjb2RlSW50ZWdlcihjb250ZXh0Q2FjaGUsICJJQURTIiwgZGVjb2Rlcik7CiAgICAgIGlmIChkZWx0YVMgPT09IG51bGwpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBjdXJyZW50UyArPSBkZWx0YVMgKyBkc09mZnNldDsKICAgIH0gd2hpbGUgKHRydWUpOwogIH0KICByZXR1cm4gYml0bWFwOwp9CmZ1bmN0aW9uIGRlY29kZVBhdHRlcm5EaWN0aW9uYXJ5KG1tciwgcGF0dGVybldpZHRoLCBwYXR0ZXJuSGVpZ2h0LCBtYXhQYXR0ZXJuSW5kZXgsIHRlbXBsYXRlLCBkZWNvZGluZ0NvbnRleHQpIHsKICBjb25zdCBhdCA9IFtdOwogIGlmICghbW1yKSB7CiAgICBhdC5wdXNoKHsKICAgICAgeDogLXBhdHRlcm5XaWR0aCwKICAgICAgeTogMAogICAgfSk7CiAgICBpZiAodGVtcGxhdGUgPT09IDApIHsKICAgICAgYXQucHVzaCh7CiAgICAgICAgeDogLTMsCiAgICAgICAgeTogLTEKICAgICAgfSwgewogICAgICAgIHg6IDIsCiAgICAgICAgeTogLTIKICAgICAgfSwgewogICAgICAgIHg6IC0yLAogICAgICAgIHk6IC0yCiAgICAgIH0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uYXJ5RmxhZ3MgPj4gMTAgJiAzOwogICAgICBkaWN0aW9uYXJ5LnJlZmluZW1lbnRUZW1wbGF0ZSA9IGRpY3Rpb25hcnlGbGFncyA+PiAxMiAmIDE7CiAgICAgIHBvc2l0aW9uICs9IDI7CiAgICAgIGlmICghZGljdGlvbmFyeS5odWZmbWFuKSB7CiAgICAgICAgYXRMZW5ndGggPSBkaWN0aW9uYXJ5LnRlbXBsYXRlID09PSAwID8gNCA6IDE7CiAgICAgICAgYXQgPSBbXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgYXRMZW5ndGg7IGkrKykgewogICAgICAgICAgYXQucHVzaCh7CiAgICAgICAgICAgIHg6ICgwLCBfY29yZV91dGlscy5yZWFkSW50OCkoZGF0YSwgcG9zaXRpb24pLAogICAgICAgICAgICB5OiAoMCwgX2NvcmVfdXRpbHMucmVhZEludDgpKGRhdGEsIHBvc2l0aW9uICsgMSkKICAgICAgICAgIH0pOwogICAgICAgICAgcG9zaXRpb24gKz0gMjsKICAgICAgICB9CiAgICAgICAgZGljdGlvbmFyeS5hdCA9IGF0OwogICAgICB9CiAgICAgIGlmIChkaWN0aW9uYXJ5LnJlZmluZW1lbnQgJiYgIWRpY3Rpb25hcnkucmVmaW5lbWVudFRlbXBsYXRlKSB7CiAgICAgICAgYXQgPSBbXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgMjsgaSsrKSB7CiAgICAgICAgICBhdC5wdXNoKHsKICAgICAgICAgICAgeDogKDAsIF9jb3JlX3V0aWxzLnJlYWRJbnQ4KShkYXRhLCBwb3NpdGlvbiksCiAgICAgICAgICAgIHk6ICgwLCBfY29yZV91dGlscy5yZWFkSW50OCkoZGF0YSwgcG9zaXRpb24gKyAxKQogICAgICAgICAgfSk7CiAgICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIH0KICAgICAgICBkaWN0aW9uYXJ5LnJlZmluZW1lbnRBdCA9IGF0OwogICAgICB9CiAgICAgIGRpY3Rpb25hcn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1hcCkgewogICAgY29uc3QgcGFnZUluZm8gPSB0aGlzLmN1cnJlbnRQYWdlSW5mbzsKICAgIGNvbnN0IHdpZHRoID0gcmVnaW9uSW5mby53aWR0aCwKICAgICAgaGVpZ2h0ID0gcmVnaW9uSW5mby5oZWlnaHQ7CiAgICBjb25zdCByb3dTaXplID0gcGFnZUluZm8ud2lkdGggKyA3ID4+IDM7CiAgICBjb25zdCBjb21iaW5hdGlvbk9wZXJhdG9yID0gcGFnZUluZm8uY29tYmluYXRpb25PcGVyYXRvck92ZXJyaWRlID8gcmVnaW9uSW5mby5jb21iaW5hdGlvbk9wZXJhdG9yIDogcGFnZUluZm8uY29tYmluYXRpb25PcGVyYXRvcjsKICAgIGNvbnN0IGJ1ZmZlciA9IHRoaXMuYnVmZmVyOwogICAgY29uc3QgbWFzazAgPSAxMjggPj4gKHJlZ2lvbkluZm8ueCAmIDcpOwogICAgbGV0IG9mZnNldDAgPSByZWdpb25JbmZvLnkgKiByb3dTaXplICsgKHJlZ2lvbkluZm8ueCA+PiAzKTsKICAgIGxldCBpLCBqLCBtYXNrLCBvZmZzZXQ7CiAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgY2FzZSAwOgogICAgICAgIGZvciAoaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgICAgICAgbWFzayA9IG1hc2swOwogICAgICAgICAgb2Zmc2V0ID0gb2Zmc2V0MDsKICAgICAgICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgICAgICAgIGlmIChiaXRtYXBbaV1bal0pIHsKICAgICAgICAgICAgICBidWZmZXJbb2Zmc2V0XSB8PSBtYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgIGlmICghbWFzaykgewogICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgb2Zmc2V0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldDAgKz0gcm93U2l6ZTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgIG1hc2sgPSBtYXNrMDsKICAgICAgICAgIG9mZnNldCA9IG9mZnNldDA7CiAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICBpZiAoYml0bWFwW2ldW2pdKSB7CiAgICAgICAgICAgICAgYnVmZmVyW29mZnNldF0gXj0gbWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgICBpZiAoIW1hc2spIHsKICAgICAgICAgICAgICBtYXNrID0gMTI4OwogICAgICAgICAgICAgIG9mZnNldCsrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBvZmZzZXQwICs9IHJvd1NpemU7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBKYmlnMkVycm9yKGBvcGVyYXRvciAke2NvbWJpbmF0aW9uT3BlcmF0b3J9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgIH0KICB9CiAgb25JbW1lZGlhdGVHZW5lcmljUmVnaW9uKHJlZ2lvbiwgZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgcmVnaW9uSW5mbyA9IHJlZ2lvbi5pbmZvOwogICAgY29uc3QgZGVjb2RpbmdDb250ZXh0ID0gbmV3IERlY29kaW5nQ29udGV4dChkYXRhLCBzdGFydCwgZW5kKTsKICAgIGNvbnN0IGJpdG1hcCA9IGRlY29kZUJpdG1hcChyZWdpb24ubW1yLCByZWdpb25JbmZvLndpZHRoLCByZWdpb25JbmZvLmhlaWdodCwgcmVnaW9uLnRlbXBsYXRlLCByZWdpb24ucHJlZGljdGlvbiwgbnVsbCwgcmVn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iAxNjsKICAgICAgdGhpcy5jbG93ICY9IDB4ZmZmZjsKICAgIH0KICB9CiAgcmVhZEJpdChjb250ZXh0cywgcG9zKSB7CiAgICBsZXQgY3hfaW5kZXggPSBjb250ZXh0c1twb3NdID4+IDEsCiAgICAgIGN4X21wcyA9IGNvbnRleHRzW3Bvc10gJiAxOwogICAgY29uc3QgcWVUYWJsZUljeCA9IFFlVGFibGVbY3hfaW5kZXhdOwogICAgY29uc3QgcWVJY3ggPSBxZVRhYmxlSWN4LnFlOwogICAgbGV0IGQ7CiAgICBsZXQgYSA9IHRoaXMuYSAtIHFlSWN4OwogICAgaWYgKHRoaXMuY2hpZ2ggPCBxZUljeCkgewogICAgICBpZiAoYSA8IHFlSWN4KSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSBjeF9tcHM7CiAgICAgICAgY3hfaW5kZXggPSBxZVRhYmxlSWN4Lm5tcHM7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSAxIF4gY3hfbXBzOwogICAgICAgIGlmIChxZVRhYmxlSWN4LnN3aXRjaEZsYWcgPT09IDEpIHsKICAgICAgICAgIGN4X21wcyA9IGQ7CiAgICAgICAgfQogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubHBzOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmNoaWdoIC09IHFlSWN4OwogICAgICBpZiAoKGEgJiAweDgwMDApICE9PSAwKSB7CiAgICAgICAgdGhpcy5hID0gYTsKICAgICAgICByZXR1cm4gY3hfbXBzOwogICAgICB9CiAgICAgIGlmIChhIDwgcWVJY3gpIHsKICAgICAgICBkID0gMSBeIGN4X21wczsKICAgICAgICBpZiAocWVUYWJsZUljeC5zd2l0Y2hGbGFnID09PSAxKSB7CiAgICAgICAgICBjeF9tcHMgPSBkOwogICAgICAgIH0KICAgICAgICBjeF9pbmRleCA9IHFlVGFibGVJY3gubmxwczsKICAgICAgfSBlbH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AyODk2OwpmdW5jdGlvbiBidWlsZEh1ZmZtYW5UYWJsZShjb2RlTGVuZ3RocywgdmFsdWVzKSB7CiAgbGV0IGsgPSAwLAogICAgaSwKICAgIGosCiAgICBsZW5ndGggPSAxNjsKICB3aGlsZSAobGVuZ3RoID4gMCAmJiAhY29kZUxlbmd0aHNbbGVuZ3RoIC0gMV0pIHsKICAgIGxlbmd0aC0tOwogIH0KICBjb25zdCBjb2RlID0gW3sKICAgIGNoaWxkcmVuOiBbXSwKICAgIGluZGV4OiAwCiAgfV07CiAgbGV0IHAgPSBjb2RlWzBdLAogICAgcTsKICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgIGZvciAoaiA9IDA7IGogPCBjb2RlTGVuZ3Roc1tpXTsgaisrKSB7CiAgICAgIHAgPSBjb2RlLnBvcCgpOwogICAgICBwLmNoaWxkcmVuW3AuaW5kZXhdID0gdmFsdWVzW2tdOwogICAgICB3aGlsZSAocC5pbmRleCA+IDApIHsKICAgICAgICBwID0gY29kZS5wb3AoKTsKICAgICAgfQogICAgICBwLmluZGV4Kys7CiAgICAgIGNvZGUucHVzaChwKTsKICAgICAgd2hpbGUgKGNvZGUubGVuZ3RoIDw9IGkpIHsKICAgICAgICBjb2RlLnB1c2gocSA9IHsKICAgICAgICAgIGNoaWxkcmVuOiBbXSwKICAgICAgICAgIGluZGV4OiAwCiAgICAgICAgfSk7CiAgICAgICAgcC5jaGlsZHJlbltwLmluZGV4XSA9IHEuY2hpbGRyZW47CiAgICAgICAgcCA9IHE7CiAgICAgIH0KICAgICAgaysrOwogICAgfQogICAgaWYgKGkgKyAxIDwgbGVuZ3RoKSB7CiAgICAgIGNvZGUucHVzaChxID0gewogICAgICAgIGNoaWxkcmVuOiBbXSwKICAgICAgICBpbmRleDogMAogICAgICB9KTsKICAgICAgcC5jaGlsZHJlbltwLmluZGV4XSA9IHEuY2hpbGRyZW47CiAgICAgIHAgPSBxOwogICAgfQogIH0KICByZXR1cm4gY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AgICAgICBjb25zdCBzY2FuTGluZXMgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgaWYgKHNjYW5MaW5lcyA+IDAgJiYgc2NhbkxpbmVzICE9PSBmcmFtZS5zY2FuTGluZXMpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEROTE1hcmtlckVycm9yKCJGb3VuZCBETkwgbWFya2VyICgweEZGREMpIHdoaWxlIHBhcnNpbmcgc2NhbiBkYXRhIiwgc2NhbkxpbmVzKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG5leHRCeXRlID09PSAweGQ5KSB7CiAgICAgICAgICBpZiAocGFyc2VETkxNYXJrZXIpIHsKICAgICAgICAgICAgY29uc3QgbWF5YmVTY2FuTGluZXMgPSBibG9ja1JvdyAqIChmcmFtZS5wcmVjaXNpb24gPT09IDggPyA4IDogMCk7CiAgICAgICAgICAgIGlmIChtYXliZVNjYW5MaW5lcyA+IDAgJiYgTWF0aC5yb3VuZChmcmFtZS5zY2FuTGluZXMgLyBtYXliZVNjYW5MaW5lcykgPj0gNSkgewogICAgICAgICAgICAgIHRocm93IG5ldyBETkxNYXJrZXJFcnJvcigiRm91bmQgRU9JIG1hcmtlciAoMHhGRkQ5KSB3aGlsZSBwYXJzaW5nIHNjYW4gZGF0YSwgIiArICJwb3NzaWJseSBjYXVzZWQgYnkgaW5jb3JyZWN0IGBzY2FuTGluZXNgIHBhcmFtZXRlciIsIG1heWJlU2NhbkxpbmVzKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IEVPSU1hcmtlckVycm9yKCJGb3VuZCBFT0kgbWFya2VyICgweEZGRDkpIHdoaWxlIHBhcnNpbmcgc2NhbiBkYXRhIik7CiAgICAgICAgfQogICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoYHVuZXhwZWN0ZWQgbWFya2V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9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZURDKTsKICAgIGNvbnN0IGRpZmYgPSB0ID09PSAwID8gMCA6IHJlY2VpdmVBbmRFeHRlbmQodCk7CiAgICBjb21wb25lbnQuYmxvY2tEYXRhW2Jsb2NrT2Zmc2V0XSA9IGNvbXBvbmVudC5wcmVkICs9IGRpZmY7CiAgICBsZXQgayA9IDE7CiAgICB3aGlsZSAoayA8IDY0KSB7CiAgICAgIGNvbnN0IHJzID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlQUMpOwogICAgICBjb25zdCBzID0gcnMgJiAxNSwKICAgICAgICByID0gcnMgPj4gNDsKICAgICAgaWYgKHMgPT09IDApIHsKICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgKyB6XSA9IHJlY2VpdmVBbmRFeHRlbmQocyk7CiAgICAgIGsrKzsKICAgIH0KICB9CiAgZnVuY3Rpb24gZGVjb2RlRENGaXJzdChjb21wb25lbnQsIGJsb2NrT2Zmc2V0KSB7CiAgICBjb25zdCB0ID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlREMpOwogICAgY29uc3QgZGlmZiA9IHQgPT09IDAgPyAwIDogcmVjZWl2ZUFuZEV4dGVuZCh0KSA8PCBzdWNjZXNzaXZlOwogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gPSBjb21wb25lbnQucHJlZCArPSBkaWZmOwogIH0KICBmdW5jdGlvbiBkZWNvZGVEQ1N1Y2Nlc3NpdmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29tcG9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iAgICBsZXQgciA9IDA7CiAgICBsZXQgczsKICAgIGxldCByczsKICAgIHdoaWxlIChrIDw9IGUpIHsKICAgICAgY29uc3Qgb2Zmc2V0WiA9IGJsb2NrT2Zmc2V0ICsgZGN0WmlnWmFnW2tdOwogICAgICBjb25zdCBzaWduID0gY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSA8IDAgPyAtMSA6IDE7CiAgICAgIHN3aXRjaCAoc3VjY2Vzc2l2ZUFDU3RhdGUpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBycyA9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZUFDKTsKICAgICAgICAgIHMgPSBycyAmIDE1OwogICAgICAgICAgciA9IHJzID4+IDQ7CiAgICAgICAgICBpZiAocyA9PT0gMCkgewogICAgICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICAgICAgZW9icnVuID0gcmVjZWl2ZShyKSArICgxIDw8IHIpOwogICAgICAgICAgICAgIHN1Y2Nlc3NpdmVBQ1N0YXRlID0gNDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICByID0gMTY7CiAgICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZiAocyAhPT0gMSkgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoImludmFsaWQgQUNuIGVuY29kaW5nIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlID0gcmVjZWl2ZUFuZEV4dGVuZChzKTsKICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSByID8gMiA6IDM7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICBjYXNlIDE6CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaWYgKGNvbXBvbmVudC5ibG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B7CiAgICAgICAgICBkZWNvZGVCbG9jayhjb21wb25lbnQsIGRlY29kZUZuLCBtY3UpOwogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobiA9IDA7IG4gPCBtY3VUb1JlYWQ7IG4rKykgewogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGNvbXBvbmVudHNMZW5ndGg7IGkrKykgewogICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRzW2ldOwogICAgICAgICAgICBoID0gY29tcG9uZW50Lmg7CiAgICAgICAgICAgIHYgPSBjb21wb25lbnQudjsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IHY7IGorKykgewogICAgICAgICAgICAgIGZvciAoayA9IDA7IGsgPCBoOyBrKyspIHsKICAgICAgICAgICAgICAgIGRlY29kZU1jdShjb21wb25lbnQsIGRlY29kZUZuLCBtY3UsIGosIGspOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBiaXRzQ291bnQgPSAwOwogICAgZmlsZU1hcmtlciA9IGZpbmROZXh0RmlsZU1hcmtlcihkYXRhLCBvZmZzZXQpOwogICAgaWYgKCFmaWxlTWFya2VyKSB7CiAgICAgIGJyZWFrOwogICAgfQogICAgaWYgKGZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gbWN1VG9SZWFkID4gMCA/ICJ1bmV4cGVjdGVkIiA6ICJleGNlc3NpdmUiOwogICAgICAoMCwgX3V0aWwud2FybikoYGRlY29kZVNjYW4gLSAke3BhcnRpYWxNc2d9IE1DVSBkYXRhLCBjdXJyZW50IG1hcmtlciBpczogJHtmaWxlTWFya2VyLmludmFsaWR9YCk7CiAgICAgIG9mZnNldCA9IGZpbGVNYXJrZXIub2Zmc2V0OwogICAgfQogICAgaWYgKGZpbGVNYXJrZXIubWFya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gfSBlbHNlIGlmIChwMCA+PSA0MDgwKSB7CiAgICAgIHAwID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDAgPj49IDQ7CiAgICB9CiAgICBpZiAocDEgPCAxNikgewogICAgICBwMSA9IDA7CiAgICB9IGVsc2UgaWYgKHAxID49IDQwODApIHsKICAgICAgcDEgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwMSA+Pj0gNDsKICAgIH0KICAgIGlmIChwMiA8IDE2KSB7CiAgICAgIHAyID0gMDsKICAgIH0gZWxzZSBpZiAocDIgPj0gNDA4MCkgewogICAgICBwMiA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHAyID4+PSA0OwogICAgfQogICAgaWYgKHAzIDwgMTYpIHsKICAgICAgcDMgPSAwOwogICAgfSBlbHNlIGlmIChwMyA+PSA0MDgwKSB7CiAgICAgIHAzID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDMgPj49IDQ7CiAgICB9CiAgICBpZiAocDQgPCAxNikgewogICAgICBwNCA9IDA7CiAgICB9IGVsc2UgaWYgKHA0ID49IDQwODApIHsKICAgICAgcDQgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNCA+Pj0gNDsKICAgIH0KICAgIGlmIChwNSA8IDE2KSB7CiAgICAgIHA1ID0gMDsKICAgIH0gZWxzZSBpZiAocDUgPj0gNDA4MCkgewogICAgICBwNSA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHA1ID4+PSA0OwogICAgfQogICAgaWYgKHA2IDwgMTYpIHsKICAgICAgcDYgPSAwOwogICAgfSBlbHNlIGlmIChwNiA+PSA0MDgwKSB7CiAgICAgIHA2ID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDYgPj49IDQ7CiAgICB9CiAgICBpZiAocDcgPCAxNikgewogICAgICBwNyA9IDA7CiAgICB9IGVsc2UgaWYgKHA3ID49IDQwODApIHsKICAgICAgcDcgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNyA+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IgIT09IDB4ZmZkOSkgewogICAgICBsZXQgaSwgaiwgbDsKICAgICAgc3dpdGNoIChmaWxlTWFya2VyKSB7CiAgICAgICAgY2FzZSAweGZmZTA6CiAgICAgICAgY2FzZSAweGZmZTE6CiAgICAgICAgY2FzZSAweGZmZTI6CiAgICAgICAgY2FzZSAweGZmZTM6CiAgICAgICAgY2FzZSAweGZmZTQ6CiAgICAgICAgY2FzZSAweGZmZTU6CiAgICAgICAgY2FzZSAweGZmZTY6CiAgICAgICAgY2FzZSAweGZmZTc6CiAgICAgICAgY2FzZSAweGZmZTg6CiAgICAgICAgY2FzZSAweGZmZTk6CiAgICAgICAgY2FzZSAweGZmZWE6CiAgICAgICAgY2FzZSAweGZmZWI6CiAgICAgICAgY2FzZSAweGZmZWM6CiAgICAgICAgY2FzZSAweGZmZWQ6CiAgICAgICAgY2FzZSAweGZmZWU6CiAgICAgICAgY2FzZSAweGZmZWY6CiAgICAgICAgY2FzZSAweGZmZmU6CiAgICAgICAgICBjb25zdCBhcHBEYXRhID0gcmVhZERhdGFCbG9jaygpOwogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlMCkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0YSAmJiBhcHBEYXRhWzFdID09PSAweDQ2ICYmIGFwcERhdGFbMl0gPT09IDB4NDkgJiYgYXBwRGF0YVszXSA9PT0gMHg0NiAmJiBhcHBEYXRhWzRdID09PSAwKSB7CiAgICAgICAgICAgICAgamZpZiA9IHsKICAgICAgICAgICAgICAgIHZlcnNpb246IHsKICAgICAgICAgICAgICAgICAgbWFqb3I6IGFwcERhdGFbNV0sCiAgICAgICAgICAgICAgICAgIG1pbm9yOiBhcHBEYXRhWzZdCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZGVuc2l0eVVuaXRzOiBhcHBEYXRhWzddLAogICAgICAgICAgICAgICAgeERlbnNpdHk6IGFwcERhdGFbOF0gPDwgOCB8IGFwcERhdGFbOV0sCiAgICAgICAgICAgICAgICB5RGVuc2l0eTogYXBwRGF0YVsxMF0gPDwgOCB8IGFwcERhdGFbMTFdLAogICAgICAgICAgICAgICAgdGh1bWJXaWR0aDogYXBwRGF0YVsxMl0sCiAgICAgICAgICAgICAgICB0aHVtYkhlaWdodDogYXBwRGF0YVsxM10sCiAgICAgICAgICAgICAgICB0aHVtYkRhdGE6IGFwcERhdGEuc3ViYXJyYXkoMTQsIDE0ICsgMyAqIGFwcERhdGFbMTJdICogYXBwRGF0YVsxM10pCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlZSkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0MSAmJiBhcHBEYXRhWzFdID09PSAweDY0ICYmIGFwcERhdGFbMl0gPT09IDB4NmYgJiYgYXBwRGF0YVszXSA9PT0gMHg2MiAmJiBhcHBEYXRhWzRdID09PSAweDY1KSB7CiAgICAgICAgICAgICAgYWRvYmUgPSB7CiAgICAgICAgICAgICAgICB2ZXJzaW9uOiBhcHBEYXRhWzVdIDw8IDggfCBhcHBEYXRhWzZdLAogICAgICAgICAgICAgICAgZmxhZ3MwOiBhcHBEYXRhWzddIDw8IDggfCBhcHBEYXRhWzhdLAogICAgICAgICAgICAgICAgZmxhZ3MxOiBhcHBEYXRhWzldIDw8IDggfCBhcHBEYXRhWzEwXSwKICAgICAgICAgICAgICAgIHRyYW5zZm9ybUNvZGU6IGFwcERhdGFbMTFdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGI6CiAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZXNMZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgY29uc3QgcXVhbnRpemF0aW9uVGFibGVzRW5kID0gcXVhbnRpemF0aW9uVGFibGVzTGVuZ3RoICsgb2Zmc2V0IC0gMjsKICAgICAgICAgIGxldCB6OwogICAgICAgICAgd2hpbGUgKG9mZnNldCA8IHF1YW50aXphdGlvblRhYmxlc0VuZCkgewogICAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZVNwZWMgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgY29uc3QgdGFibGVEYXRhID0gbmV3IFVpbnQxNkFycmF5KDY0KTsKICAgICAgICAgICAgaWYgKHF1YW50aXphdGlvblRhYmxlU3BlYyA+PiA0ID09PSAwKSB7CiAgICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyBqKyspIHsKICAgICAgICAgICAgICAgIHogPSBkY3RaaWdaYWdbal07CiAgICAgICAgICAgICAgICB0YWJsZURhdGFbel0gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSBpZiAocXVhbnRpemF0aW9uVGFibGVTcGVjID4+IDQgPT09IDEpIHsKICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7IGorKykgewogICAgICAgICAgICAgICAgeiA9IGRjdFppZ1phZ1tqXTsKICAgICAgICAgICAgICAgIHRhYmxlRGF0YVt6XSA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIkRRVCAtIGludmFsaWQgdGFibGUgc3BlYyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlc1txdWFudGl6YXRpb25UYWJsZVNwZWMgJiAxNV0gPSB0YWJsZURhdGE7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZjMDoKICAgICAgICBjYXNlIDB4ZmZjMToKICAgICAgICBjYXNlIDB4ZmZjMjoKICAgICAgICAgIGlmIChmcmFtZSkgewogICAgICAgICAgICB0aHJvdyBuZXcgSnBlZ0Vycm9yKCJPbmx5IHNpbmdsZSBmcmFtZSBKUEVHcyBzdXBwb3J0ZWQiKTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUgPSB7fTsKICAgICAgICAgIGZyYW1lLmV4dGVuZGVkID0gZmlsZU1hcmtlciA9PT0gMHhmZmMxOwogICAgICAgICAgZnJhbWUucHJvZ3Jlc3NpdmUgPSBmaWxlTWFya2VyID09PSAweGZmYzI7CiAgICAgICAgICBmcmFtZS5wcmVjaXNpb24gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGNvbnN0IHNvZlNjYW5MaW5lcyA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmcmFtZS5zY2FuTGluZXMgPSBkbmxTY2FuTGluZXMgfHwgc29mU2NhbkxpbmVzOwogICAgICAgICAgZnJhbWUuc2FtcGxlc1BlckxpbmUgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50cyA9IFtdOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50SWRzID0ge307CiAgICAgICAgICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGxldCBtYXhIID0gMCwKICAgICAgICAgICAgbWF4ViA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3QgY29tcG9uZW50SWQgPSBkYXRhW29mZnNldF07CiAgICAgICAgICAgIGNvbnN0IGggPSBkYXRhW29mZnNldCArIDFdID4+IDQ7CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhW29mZnNldCArIDFdICYgMTU7CiAgICAgICAgICAgIGlmIChtYXhIIDwgaCkgewogICAgICAgICAgICAgIG1heEggPSBoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChtYXhWIDwgdikgewogICAgICAgICAgICAgIG1heFYgPSB2OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHFJZCA9IGRhdGFbb2Zmc2V0ICsgMl07CiAgICAgICAgICAgIGwgPSBmcmFtZS5jb21wb25lbnRzLnB1c2goewogICAgICAgICAgICAgIGgsCiAgICAgICAgICAgICAgdiwKICAgICAgICAgICAgICBxdWFudGl6YXRpb25JZDogcUlkLAogICAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlOiBudWxsCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBmcmFtZS5jb21wb25lbnRJZHNbY29tcG9uZW50SWRdID0gbCAtIDE7CiAgICAgICAgICAgIG9mZnNldCArPSAzOwogICAgICAgICAgfQogICAgICAgICAgZnJhbWUubWF4SCA9IG1heEg7CiAgICAgICAgICBmcmFtZS5tYXhWID0gbWF4VjsKICAgICAgICAgIHByZXBhcmVDb21wb25lbnRzKGZyYW1lKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmM0OgogICAgICAgICAgY29uc3QgaHVmZm1hbkxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmb3IgKGkgPSAyOyBpIDwgaHVmZm1hbkxlbmd0aDspIHsKICAgICAgICAgICAgY29uc3QgaHVmZm1hblRhYmxlU3BlYyA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb2RlTGVuZ3RocyA9IG5ldyBVaW50OEFycmF5KDE2KTsKICAgICAgICAgICAgbGV0IGNvZGVMZW5ndGhTdW0gPSAwOwogICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgMTY7IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBjb2RlTGVuZ3RoU3VtICs9IGNvZGVMZW5ndGhzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGh1ZmZtYW5WYWx1ZXMgPSBuZXcgVWludDhBcnJheShjb2RlTGVuZ3RoU3VtKTsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IGNvZGVMZW5ndGhTdW07IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBodWZmbWFuVmFsdWVzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGkgKz0gMTcgKyBjb2RlTGVuZ3RoU3VtOwogICAgICAgICAgICAoaHVmZm1hblRhYmxlU3BlYyA+PiA0ID09PSAwID8gaHVmZm1hblRhYmxlc0RDIDogaHVmZm1hblRhYmxlc0FDKVtodWZmbWFuVGFibGVTcGVjICYgMTVdID0gYnVpbGRIdWZmbWFuVGFibGUoY29kZUxlbmd0aHMsIGh1ZmZtYW5WYWx1ZXMpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGQ6CiAgICAgICAgICBvZmZzZXQgKz0gMjsKICAgICAgICAgIHJlc2V0SW50ZXJ2YWwgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGE6CiAgICAgICAgICBjb25zdCBwYXJzZUROTE1hcmtlciA9ICsrbnVtU09TTWFya2VycyA9PT0gMSAmJiAhZG5sU2NhbkxpbmVzOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBjb25zdCBzZWxlY3RvcnNDb3VudCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBjb21wb25lbnRzID0gW107CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgc2VsZWN0b3JzQ291bnQ7IGkrKykgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb21wb25lbnRJbmRleCA9IGZyYW1lLmNvbXBvbmVudElkc1tpbmRleF07CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudCA9IGZyYW1lLmNvbXBvbmVudHNbY29tcG9uZW50SW5kZXhdOwogICAgICAgICAgICBjb21wb25lbnQuaW5kZXggPSBpbmRleDsKICAgICAgICAgICAgY29uc3QgdGFibGVTcGVjID0gZGF0YVtvZmZzZXQrK107CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVEQyA9IGh1ZmZtYW5UYWJsZXNEQ1t0YWJsZVNwZWMgPj4gNF07CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyA9IGh1ZmZtYW5UYWJsZXNBQ1t0YWJsZVNwZWMgJiAxNV07CiAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3BlY3RyYWxTdGFydCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzcGVjdHJhbEVuZCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzdWNjZXNzaXZlQXBwcm94aW1hdGlvbiA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkID0gZGVjb2RlU2NhbihkYXRhLCBvZmZzZXQsIGZyYW1lLCBjb21wb25lbnRzLCByZXNldEludGVydmFsLCBzcGVjdHJhbFN0YXJ0LCBzcGVjdHJhbEVuZCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gPj4gNCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gJiAxNSwgcGFyc2VETkxNYXJrZXIpOwogICAgICAgICAgICBvZmZzZXQgKz0gcHJvY2Vzc2VkOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgRE5MTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gYXR0ZW1wdGluZyB0byByZS1wYXJzZSB0aGUgSlBFRyBpbWFnZS5gKTsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5wYXJzZShkYXRhLCB7CiAgICAgICAgICAgICAgICBkbmxTY2FuTGluZXM6IGV4LnNjYW5MaW5lcwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgRU9JTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gaWdub3JpbmcgdGhlIHJlc3Qgb2YgdGhlIGltYWdlIGRhdGEuYCk7CiAgICAgICAgICAgICAgYnJlYWsgbWFya2VyTG9vcDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmRjOgogICAgICAgICAgb2Zmc2V0ICs9IDQ7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZmZjoKICAgICAgICAgIGlmIChkYXRhW29mZnNldF0gIT09IDB4ZmYpIHsKICAgICAgICAgICAgb2Zmc2V0LS07CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgY29uc3QgbmV4dEZpbGVNYXJrZXIgPSBmaW5kTmV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HRoaXMuY29tcG9uZW50cyA9IFtdOwogICAgZm9yIChjb25zdCBjb21wb25lbnQgb2YgZnJhbWUuY29tcG9uZW50cykgewogICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZSA9IHF1YW50aXphdGlvblRhYmxlc1tjb21wb25lbnQucXVhbnRpemF0aW9uSWRdOwogICAgICBpZiAocXVhbnRpemF0aW9uVGFibGUpIHsKICAgICAgICBjb21wb25lbnQucXVhbnRpemF0aW9uVGFibGUgPSBxdWFudGl6YXRpb25UYWJsZTsKICAgICAgfQogICAgICB0aGlzLmNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgaW5kZXg6IGNvbXBvbmVudC5pbmRleCwKICAgICAgICBvdXRwdXQ6IGJ1aWxkQ29tcG9uZW50RGF0YShmcmFtZSwgY29tcG9uZW50KSwKICAgICAgICBzY2FsZVg6IGNvbXBvbmVudC5oIC8gZnJhbWUubWF4SCwKICAgICAgICBzY2FsZVk6IGNvbXBvbmVudC52IC8gZnJhbWUubWF4ViwKICAgICAgICBibG9ja3NQZXJMaW5lOiBjb21wb25lbnQuYmxvY2tzUGVyTGluZSwKICAgICAgICBibG9ja3NQZXJDb2x1bW46IGNvbXBvbmVudC5ibG9ja3NQZXJDb2x1bW4KICAgICAgfSk7CiAgICB9CiAgICB0aGlzLm51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogICAgcmV0dXJuIHVuZGVmaW5lZDsKICB9CiAgX2dldExpbmVhcml6ZWRCbG9ja0RhdGEod2lkdGgsIGhlaWdodCkgewogICAgbGV0IGlzU291cmNlUERGID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBmYWxzZTsKICAgIGNvbnN0IHNjYWxlWCA9IHRoaXMud2lkdGggLyB3aWR0aCwKICAgICAgc2NhbGVZID0gdGhpcy5oZWlnaHQgLyBoZWlnaHQ7CiAgICBsZXQgY29tcG9uZW50LCBjb21wb25lbnRTY2FsZVgsIGNvbXBvbmVudFNjYWxlWSwgYmxvY2tzUGVyU2NhbmxpbmU7CiAgICBsZXQgeCwgeSwgaSwgaiwgazsKICAgIGxldCBpbmRleDsKICAgIGxldCBvZmZzZXQgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGNvbnN0IG51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogICAgY29uc3QgZGF0YUxlbmd0aCA9IHdpZHRoICogaGVpZ2h0ICogbnVtQ29tcG9uZW50czsKICAgIGNvbnN0IGRhdGEgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoZGF0YUxlbmd0aCk7CiAgICBjb25zdCB4U2NhbGVCbG9ja09mZnNldCA9IG5ldyBVaW50MzJBcnJheSh3aWR0aCk7CiAgICBjb25zdCBtYXNrM0xTQiA9IDB4ZmZmZmZmZjg7CiAgICBsZXQgbGFzdENvbXBvbmVudFNjYWxlWDsKICAgIGZvciAoaSA9IDA7IGkgPCBudW1Db21wb25lbnRzOyBpKyspIHsKICAgICAgY29tcG9uZW50ID0gdGhpcy5jb21wb25lbnRzW2ldOwogICAgICBjb21wb25lbnRTY2FsZVggPSBjb21wb25lbnQuc2NhbGVYICogc2NhbGVYOwogICAgICBjb21wb25lbnRTY2FsZVkgPSBjb21wb25lbnQuc2NhbGVZICogc2NhbGVZOwogICAgICBvZmZzZXQgPSBpOwogICAgICBvdXRwdXQgPSBjb21wb25lbnQub3V0cHV0OwogICAgICBibG9ja3NQZXJTY2FubGluZSA9IGNvbXBvbmVudC5ibG9ja3NQZXJMaW5lICsgMSA8PCAzOwogICAgICBpZiAoY29tcG9uZW50U2NhbGVYICE9PSBsYXN0Q29tcG9uZW50U2NhbGVYKSB7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGogPSAwIHwgeCAqIGNvbXBvbmVudFNjYWxlWDsKICAgICAgICAg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IChmb3JjZVJHQkEpIHsKICAgICAgICAoMCwgX2ltYWdlX3V0aWxzLmdyYXlUb1JHQkEpKGRhdGEsIG5ldyBVaW50MzJBcnJheShyZ2JhRGF0YS5idWZmZXIpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBmb3IgKGNvbnN0IGdyYXlDb2xvciBvZiBkYXRhKSB7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiByZ2JhRGF0YTsKICAgIH0gZWxzZSBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSAzICYmIHRoaXMuX2lzQ29sb3JDb252ZXJzaW9uTmVlZGVkKSB7CiAgICAgIGlmIChmb3JjZVJHQkEpIHsKICAgICAgICBjb25zdCByZ2JhRGF0YSA9IG5ldyBVaW50OENsYW1wZWRBcnJheShkYXRhLmxlbmd0aCAvIDMgKiA0KTsKICAgICAgICByZXR1cm4gdGhpcy5fY29udmVydFljY1RvUmdiYShkYXRhLCByZ2JhRGF0YSk7CiAgICAgIH0KICAgICAgcmV0dXJuIHRoaXMuX2NvbnZlcnRZY2NUb1JnYihkYXRhKTsKICAgIH0gZWxzZSBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSA0KSB7CiAgICAgIGlmICh0aGlzLl9pc0NvbG9yQ29udmVyc2lvbk5lZWRlZCkgewogICAgICAgIGlmIChmb3JjZVJHQkEpIHsKICAgICAgICAgIHJldHVybiB0aGlzLl9jb252ZXJ0WWNja1RvUmdiYShkYXRhKTsKICAgICAgICB9CiAgICAgICAgaWYgKGZvcmNlUkdCKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5fY29udmVydFljY2tUb1JnYihkYXRhKTsKICAgICAgICB9CiAgICAgICAgcmV0d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291bnQgPSBqcHhJbWFnZS50aWxlcy5sZW5ndGg7CiAgICBpZiAodGlsZUNvdW50ID09PSAxKSB7CiAgICAgIHRoaXMuYnVmZmVyID0ganB4SW1hZ2UudGlsZXNbMF0uaXRlbXM7CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhID0gbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0ICogY29tcG9uZW50c0NvdW50KTsKICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCB0aWxlQ291bnQ7IGsrKykgewogICAgICAgIGNvbnN0IHRpbGVDb21wb25lbnRzID0ganB4SW1hZ2UudGlsZXNba107CiAgICAgICAgY29uc3QgdGlsZVdpZHRoID0gdGlsZUNvbXBvbmVudHMud2lkdGg7CiAgICAgICAgY29uc3QgdGlsZUhlaWdodCA9IHRpbGVDb21wb25lbnRzLmhlaWdodDsKICAgICAgICBjb25zdCB0aWxlTGVmdCA9IHRpbGVDb21wb25lbnRzLmxlZnQ7CiAgICAgICAgY29uc3QgdGlsZVRvcCA9IHRpbGVDb21wb25lbnRzLnRvcDsKICAgICAgICBjb25zdCBzcmMgPSB0aWxlQ29tcG9uZW50cy5pdGVtczsKICAgICAgICBsZXQgc3JjUG9zaXRpb24gPSAwOwogICAgICAgIGxldCBkYXRhUG9zaXRpb24gPSAod2lkdGggKiB0aWxlVG9wICsgdGlsZUxlZnQpICogY29tcG9uZW50c0NvdW50OwogICAgICAgIGNvbnN0IGltZ1Jvd1NpemUgPSB3aWR0aCAqIGNvbXBvbmVudHNDb3VudDsKICAgICAgICBjb25zdCB0aWxlUm93U2l6ZSA9IHRpbGVXaWR0aCAqIGNvbXBvbmVudHNDb3VudDsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRpbGVIZWlnaHQ7IGorKykgewogICAgICAgICAgY29uc3Qgcm93Qnl0ZXMgPSBzcmMuc3ViYXJyYXkoc3JjUG9zaXRpb24sIHNyY1Bvc2l0aW9uICsgdGlsZ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BmaWVsZCBzaXplIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUxlbmd0aCA9IGxib3ggLSBoZWFkZXJTaXplOwogICAgICBsZXQganVtcERhdGFMZW5ndGggPSB0cnVlOwogICAgICBzd2l0Y2ggKHRib3gpIHsKICAgICAgICBjYXNlIDB4NmE3MDMyNjg6CiAgICAgICAgICBqdW1wRGF0YUxlbmd0aCA9IGZhbHNlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDYzNmY2YzcyOgogICAgICAgICAgY29uc3QgbWV0aG9kID0gZGF0YVtwb3NpdGlvbl07CiAgICAgICAgICBpZiAobWV0aG9kID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yc3BhY2UgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzKTsKICAgICAgICAgICAgc3dpdGNoIChjb2xvcnNwYWNlKSB7CiAgICAgICAgICAgICAgY2FzZSAxNjoKICAgICAgICAgICAgICBjYXNlIDE3OgogICAgICAgICAgICAgIGNhc2UgMTg6CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmtub3duIGNvbG9yc3BhY2UgIiArIGNvbG9yc3BhY2UpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAobWV0aG9kID09PSAyKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSUNDIHByb2ZpbGUgbm90IHN1cHBvcnRlZCIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDZhNzAzMjYzOgogICAgICAgICAgdGhpcy5wYXJzZUNvZGVzdHJlYW0oZGF0YSwgcG9zaXRpb24sIHBvc2l0aW9uICsgZGF0YUxlbmd0aCk7CiAgICAgICAgICBicmVhazsKICAgIC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8IDggfCBuZXdCeXRlOwogICAgICBpZiAoY29kZSA9PT0gMHhmZjUxKSB7CiAgICAgICAgc3RyZWFtLnNraXAoNCk7CiAgICAgICAgY29uc3QgWHNpeiA9IHN0cmVhbS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgIGNvbnN0IFlzaXogPSBzdHJlYW0uZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICBjb25zdCBYT3NpeiA9IHN0cmVhbS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgIGNvbnN0IFlPc2l6ID0gc3RyZWFtLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgc3RyZWFtLnNraXAoMTYpOwogICAgICAgIGNvbnN0IENzaXogPSBzdHJlYW0uZ2V0VWludDE2KCk7CiAgICAgICAgdGhpcy53aWR0aCA9IFhzaXogLSBYT3NpejsKICAgICAgICB0aGlzLmhlaWdodCA9IFlzaXogLSBZT3NpejsKICAgICAgICB0aGlzLmNvbXBvbmVudHNDb3VudCA9IENzaXo7CiAgICAgICAgdGhpcy5iaXRzUGVyQ29tcG9uZW50ID0gODsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiTm8gc2l6ZSBtYXJrZXIgZm91bmQgaW4gSlBYIHN0cmVhbSIpOwogIH0KICBwYXJzZUNvZGVzdHJlYW0oZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgY29udGV4dCA9IHt9OwogICAgbGV0IGRvTm90UmVjb3ZlciA9IGZhbHNlOwogICAgdHJ5IHsKICAgICAgbGV0IHBvc2l0aW9uID0gc3RhcnQ7CiAgICAgIHdoaWxlIChwb3NpdGlvbiArIDEgPCBlbmQpIHsKICAgICAgICBjb25zdCBjb2RlID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIGxldCBsZW5ndGggPSAwLAogICAgICAgICAgaiwKICAgICAgICAgIHNxY2QsCiAgICAgICAgICBzcHFjZHMsCiAgICAgICAgICBzcHFjZFNpemUsCiAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQsCiAgICAgICAgICB0aWxlOwogICAgICAgIHN3aXRjaCAoY29kZSkgewogICAgICAgICAgY2FzZSAweGZmNGY6CiAgICAgICAgICAgIGNvbnRleHQubWFpbkhlYWRlciA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmZDk6CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTE6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHNpeiA9IHt9OwogICAgICAgICAgICBzaXouWHNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICBzaXouWXNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDgpOwogICAgICAgICAgICBzaXouWE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAxMik7CiAgICAgICAgICAgIHNpei5ZT3NpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDE2KTsKICAgICAgICAgICAgc2l6LlhUc2l6ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uICsgMjApOwogICAgICAgICAgICBzaXouWVRzaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyNCk7CiAgICAgICAgICAgIHNpei5YVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyOCk7CiAgICAgICAgICAgIHNpei5ZVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzMik7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDM2KTsKICAgICAgICAgICAgc2l6LkNzaXogPSBjb21wb25lbnRzQ291bnQ7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHMgPSBbXTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMzg7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB7CiAgICAgICAgICAgICAgICBwcmVjaXNpb246IChkYXRhW2pdICYgMHg3ZikgKyAxLAogICAgICAgICAgICAgICAgaXNTaWduZWQ6ICEhKGRhdGFbal0gJiAweDgwKSwKICAgICAgICAgICAgICAgIFhSc2l6OiBkYXRhW2ogKyAxXSwKICAgICAgICAgICAgICAgIFlSc2l6OiBkYXRhW2ogKyAyXQogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgaiArPSAzOwogICAgICAgICAgICAgIGNhbGN1bGF0ZUNvbXBvbmVudERpbWVuc2lvbnMoY29tcG9uZW50LCBzaXopOwogICAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnRleHQuU0laID0gc2l6OwogICAgICAgICAgICBjb250ZXh0LmNvbXBvbmVudHMgPSBjb21wb25lbnRzOwogICAgICAgICAgICBjYWxjdWxhdGVUaWxlR3JpZHMoY29udGV4dCwgY29tcG9uZW50cyk7CiAgICAgICAgICAgIGNvbnRleHQuUUNDID0gW107CiAgICAgICAgICAgIGNvbnRleHQuQ09DID0gW107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNWM6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHFjZCA9IHt9OwogICAgICAgICAgICBqID0gcG9zaXRpb24gKyAyOwogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Qubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjZC5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjZC5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2QuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0QgPSBxY2Q7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0QgPSBxY2Q7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0MgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMHhmZjVkOgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBjb25zdCBxY2MgPSB7fTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMjsKICAgICAgICAgICAgbGV0IGNxY2M7CiAgICAgICAgICAgIGlmIChjb250ZXh0LlNJWi5Dc2l6IDwgMjU3KSB7CiAgICAgICAgICAgICAgY3FjYyA9IGRhdGFbaisrXTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjcWNjID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIGopOwogICAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgfQogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Mubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjYy5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjYy5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2MuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDB4ZmY1MjoKICAgICAgICAgICAgbGVuZ3RoID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICAgICAgY29uc3QgY29kID0ge307CiAgICAgICAgICAgIGogPSBwb3NpdGlvbiArIDI7CiAgICAgICAgICAgIGNvbnN0IHNjb2QgPSBkYXRhW2orK107CiAgICAgICAgICAgIGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzID0gISEoc2NvZCAmIDEpOwogICAgICAgICAgICBjb2Quc29wTWFya2VyVXNlZCA9ICEhKHNjb2QgJiAyKTsKICAgICAgICAgICAgY29kLmVwaE1hcmtlclVzZWQgPSAhIShzY29kICYgNCk7CiAgICAgICAgICAgIGNvZC5wcm9ncmVzc2lvbk9yZGVyID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QubGF5ZXJzQ291bnQgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgaik7CiAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgY29kLm11bHRpcGxlQ29tcG9uZW50VHJhbnNmb3JtID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QueGNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb2QueWNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb25zdCBibG9ja1N0eWxlID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2Quc2VsZWN0aXZlQXJpdGhtZXRpY0NvZGluZ0J5cGFzcyA9ICEhKGJsb2NrU3R5bGUgJiAxKTsKICAgICAgICAgICAgY29kLnJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMgPSAhIShibG9ja1N0eWxlICYgMik7CiAgICAgICAgICAgIGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MgPSAhIShibG9ja1N0eWxlICYgNCk7CiAgICAgICAgICAgIGNvZC52ZXJ0aWNhbGx5U3RyaXBlID0gISEoYmxvY2tTdHlsZSAmIDgpOwogICAgICAgICAgICBjb2QucHJlZGljdGFibGVUZXJtaW5hdGlvbiA9ICEhKGJsb2NrU3R5bGUgJiAxNik7CiAgICAgICAgICAgIGNvZC5zZWdtZW50YXRpb25TeW1ib2xVc2VkID0gISEoYmxvY2tTdHlsZSAmIDMyKTsKICAgICAgICAgICAgY29kLnJldmVyc2libGVUcmFuc2Zvcm1hdGlvbiA9IGRhdGFbaisrXTsKICAgICAgICAgICAgaWYgKGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzKSB7CiAgICAgICAgICAgICAgY29uc3QgcHJlY2luY3RzU2l6ZXMgPSBbXTsKICAgICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwcmVjaW5jdHNTaXplID0gZGF0YVtqKytdOwogICAgICAgICAgICAgICAgcHJlY2luY3RzU2l6ZXMucHVzaCh7CiAgICAgICAgICAgICAgICAgIFBQeDogcHJlY2luY3RzU2l6ZSAmIDB4ZiwKICAgICAgICAgICAgICAgICAgUFB5OiBwcmVjaW5jdHNTaXplID4+IDQKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2QucHJlY2luY3RzU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCB1bnN1cHBvcnRlZCA9IFtdOwogICAgICAgICAgICBpZiAoY29kLnNlbGVjdGl2ZUFyaXRobWV0aWNDb2RpbmdCeXBhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJzZWxlY3RpdmVBcml0aG1ldGljQ29kaW5nQnlwYXNzIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ0ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY29kLnZlcnRpY2FsbHlTdHJpcGUpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ2ZXJ0aWNhbGx5U3RyaXBlIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC5wcmVkaWN0YWJsZVRlcm1pbmF0aW9uKSB7CiAgICAgICAgICAgICAgdW5zdXBwb3J0ZWQucHVzaCgicHJlZGljdGFibGVUZXJtaW5hdGlvbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh1bnN1cHBvcnRlZC5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgZG9Ob3RSZWNvdmVyID0gdHJ1ZTsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEpQWDogVW5zdXBwb3J0ZWQgQ09EIG9wdGlvbnMgKCR7dW5zdXBwb3J0ZWQuam9pbigiLCAiKX0pLmApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb250ZXh0Lm1haW5IZWFkZXIpIHsKICAgICAgICAgICAgICBjb250ZXh0LkNPRCA9IGNvZDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPRCA9IGNvZDsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPQyA9IFtdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTA6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIHRpbGUgPSB7fTsKICAgICAgICAgICAgdGlsZS5pbmRleCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDIpOwogICAgICAgICAgICB0aWxlLmxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICB0aWxlLmRhdGFFbmQgPSB0aWxlLmxlbmd0aCArIHBvc2l0aW9uIC0gMjsKICAgICAgICAgICAgdGlsZS5wYXJ0SW5kZXggPSBkYXRhW3Bvc2l0aW9uICsgOF07CiAgICAgICAgICAgIHRpbGUucGFydHNDb3VudCA9IGRhdGFbcG9zaXRpb24gKyA5XTsKICAgICAgICAgICAgY29udGV4dC5tYWluSGVhZGVyID0gZmFsc2U7CiAgICAgICAgICAgIGlmICh0aWxlLnBhcnRJbmRleCA9PT0gMCkgewogICAgICAgICAgICAgIHRpbGUuQ09EID0gY29udGV4dC5DT0Q7CiAgICAgICAgICAgICAgdGlsZS5DT0MgPSBjb250ZXh0LkNPQy5zbGljZSgwKTsKICAgICAgICAgICAgICB0aWxlLlFDRCA9IGNvbnRleHQuUUNEOwogICAgICAgICAgICAgIHRpbGUuUUNDID0gY29udGV4dC5RQ0Muc2xpY2UoMCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZSA9IHRpbGU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTM6CiAgICAgICAgICAgIHRpbGUgPSBjb250ZXh0LmN1cnJlbnRUaWxlOwogICAgICAgICAgICBpZiAodGlsZS5wYXJ0SW5kZXggPT09IDApIHsKICAgICAgICAgICAgICBpbml0aWFsaXplVGlsZShjb250ZXh0LCB0aWxlLmluZGV4KTsKICAgICAgICAgICAgICBidWlsZFBhY2tldHMoY29udGV4dCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGVuZ3RoID0gdGlsZS5kYXRhRW5kIC0gcG9zaXRpb247CiAgICAgICAgICAgIHBhcnNlVGlsZVBhY2tldHMoY29udGV4dCwgZGF0YSwgcG9zaXRpb24sIGxlbmd0aCk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTM6CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSlBYOiBDb2Rlc3RyZWFtIGNvZGUgMHhGRjUzIChDT0MpIGlzIG5vdCBpbXBsZW1lbnRlZC4iKTsKICAgICAgICAgIGNhc2UgMHhmZjU1OgogICAgICAgICAgY2FzZSAweGZmNTc6CiAgICAgICAgICBjYXNlIDB4ZmY1ODoKICAgICAgICAgIGNhc2UgMHhmZjY0OgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZ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50YnkxXyA9IE1hdGgubWluKHN1YmJhbmQudGJ5MSwgY29kZWJsb2NrLnRieTEpOwogICAgICBjb25zdCBwaSA9IE1hdGguZmxvb3IoKGNvZGVibG9jay50YngwXyAtIHN1YmJhbmQudGJ4MCkgLyBwcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RXaWR0aEluU3ViYmFuZCk7CiAgICAgIGNvbnN0IHBqID0gTWF0aC5mbG9vcigoY29kZWJsb2NrLnRieTBfIC0gc3ViYmFuZC50YnkwKSAvIHByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdEhlaWdodEluU3ViYmFuZCk7CiAgICAgIHByZWNpbmN0TnVtYmVyID0gcGkgKyBwaiAqIHByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHN3aWRlOwogICAgICBjb2RlYmxvY2sucHJlY2luY3ROdW1iZXIgPSBwcmVjaW5jdE51bWJlcjsKICAgICAgY29kZWJsb2NrLnN1YmJhbmRUeXBlID0gc3ViYmFuZC50eXBlOwogICAgICBjb2RlYmxvY2suTGJsb2NrID0gMzsKICAgICAgaWYgKGNvZGVibG9jay50YngxXyA8PSBjb2RlYmxvY2sudGJ4MF8gfHwgY29kZWJsb2NrLnRieTFfIDw9IGNvZGVibG9jay50YnkwXykgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvZGVibG9ja3MucHVzaChjb2RlYmxvY2spOwogICAgICBsZXQgcHJlY2luY3QgPSBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdOwogICAgICBpZiAocHJlY2luY3QgIT09IHVuZGVmaW5lZCkgewogICAgICAgIGlmIChpIDwgcHJlY2luY3QuY2J4TWluKSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnhNaW4gPSBpOwogICAgICAgIH0gZWxzZSBpZiAoaSA+IHByZWNpbmN0LmNieE1heCkgewogICAgICAgICAgcHJlY2luY3QuY2J4TWF4ID0gaTsKICAgICAgICB9CiAgICAgICAgaWYgKGogPCBwcm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IDAsCiAgICBpID0gMCwKICAgIGsgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OyBsKyspIHsKICAgICAgZm9yICg7IHIgPD0gbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50OyByKyspIHsKICAgICAgICBmb3IgKDsgaSA8IGNvbXBvbmVudHNDb3VudDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICByID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25MYXllckNvbXBvbmVudFBvc2l0aW9uSXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGN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NvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICBsID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25Qb3NpdGlvbkNvbXBvbmVudExheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBsZXQgbCwgciwgYywgcDsKICBsZXQgbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gMDsKICBmb3IgKGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgIG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudCA9IE1hdGgubWF4KG1heERlY29tcG9zaXRpb25MZXZlbH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WYgKHIgPiBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICBjb25zdCBudW1wcmVjaW5jdHMgPSByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHM7CiAgICAgICAgICBpZiAocCA+PSBudW1wcmVjaW5jdHMpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgcCwgbCk7CiAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGwgPSAwOwogICAgICAgIH0KICAgICAgICBjID0gMDsKICAgICAgfQogICAgICBwID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFBvc2l0aW9uQ29tcG9uZW50UmVzb2x1dGlvbkxheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBjb25zdCBwcmVjaW5jdHNTaXplcyA9IGdldFByZWNpbmN0U2l6ZXNJbkltYWdlU2NhbGUodGlsZSk7CiAgY29uc3QgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICBsZXQgbCA9IDAsCiAgICByID0gMCwKICAgIGMgPSAwLAogICAgcHggPSAwLAogICAgcHkgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgcHkgPCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5tYXhOdW1IaWdoOyBweSsrKSB7CiAgICAgIGZvciAoOyBweCA8IHByZWNpbmN0c0l0ZXJhdGlvblNpemVzLm1heE51bVdpZGU7IHB4KyspIHsKICAgICAgICBmb3IgKDsgYyA8IGNvbXBvbmVudHNDb3VudDsgYysrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbY107CiAgICAgICAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdLnJlc29sdXRpb25zW3JdOwogICAgICAgICAgICBjb25zdCBrID0gZ2V0UHJlY2luY3RJbmRleElmRXhpc3QocHgsIHB5LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcywgcmVzb2x1dGlvbik7CiAgICAgICAgICAgIGlmIChrID09PSBudWxsKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yICg7IGwgPCBsYXllcnNDb3VudDspIHsKICAgICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgICAgbCsrOwogICAgICAgICAgICAgIHJldHVybiBwYWNrZXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgYyA9IDA7CiAgICAgIH0KICAgICAgcHggPSAwOwogICAgfQogICAgdGhyb3cgbmV3IEpweEVycm9yKCJPdXQgb2YgcGFja2V0cyIpOwogIH07Cn0KZnVuY3Rpb24gQ29tcG9uZW50UG9zaXRpb25SZXNvbHV0aW9uTGF5ZXJJdGVyYXRvcihjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGxheWVyc0NvdW50ID0gdGlsZS5jb2RpbmdTdHlsZURlZmF1bHRQYXJhbWV0ZXJzLmxheWVyc0NvdW50OwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGNvbnN0IHByZWNpbmN0c1NpemVzID0gZ2V0UHJlY2luY3RTaXplc0luSW1hZ2VTY2FsZSh0aWxlKTsKICBsZXQgbCA9IDAsCiAgICByID0gMCwKICAgIGMgPSAwLAogICAgcHggPSAwLAogICAgcHkgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgYyA8IGNvbXBvbmVudHNDb3VudDsgKytjKSB7CiAgICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgICAgY29uc3QgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdOwogICAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgZm9yICg7IHB5IDwgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMubWF4TnVtSGlnaDsgcHkrKykgewogICAgICAgIGZvciAoOyBweCA8IHByZWNpbmN0c0l0ZXJhdGlvblNpemVzLm1heE51bVdpZGU7IHB4KyspIHsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgICAgY29uc3QgayA9IGdldFByZWNpbmN0SW5kZXhJZkV4aXN0KHB4LCBweSwgc2l6ZUluSW1hZ2VTY2FsZSwgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMsIHJlc29sdXRpb24pOwogICAgICAgICAgICBpZiAoayA9PT0gbnVsbCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoOyBsIDwgbGF5ZXJzQ291bnQ7KSB7CiAgICAgICAgICAgICAgY29uc3QgcGFja2V0ID0gY3JlYXRlUGFja2V0KHJlc29sdXRpb24sIGssIGwpOwogICAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgICByZXR1cm4gcGFja2V0OwogICAgICAgICAgICB9C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7CiAgICBzaXplUGVyQ29tcG9uZW50W2NdID0gewogICAgICByZXNvbHV0aW9uczogc2l6ZVBlclJlc29sdXRpb24sCiAgICAgIG1pbldpZHRoOiBtaW5XaWR0aEN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1pbkhlaWdodDogbWluSGVpZ2h0Q3VycmVudENvbXBvbmVudCwKICAgICAgbWF4TnVtV2lkZTogbWF4TnVtV2lkZUN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1heE51bUhpZ2g6IG1heE51bUhpZ2hDdXJyZW50Q29tcG9uZW50CiAgICB9OwogIH0KICByZXR1cm4gewogICAgY29tcG9uZW50czogc2l6ZVBlckNvbXBvbmVudCwKICAgIG1pbldpZHRoLAogICAgbWluSGVpZ2h0LAogICAgbWF4TnVtV2lkZSwKICAgIG1heE51bUhpZ2gKICB9Owp9CmZ1bmN0aW9uIGJ1aWxkUGFja2V0cyhjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgIGNvbnN0IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudCA9IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50OwogICAgY29uc3QgcmVzb2x1dGlvbnMgPSBbXTsKICAgIGNvbnN0IHN1YmJhbmRzID0gW107CiAgICBmb3IgKGxldCByID0gMDsgciA8PSBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQ7IHIrKykgew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wogICAgICBpZiAoY29kZWJsb2NrLmluY2x1ZGVkICE9PSB1bmRlZmluZWQpIHsKICAgICAgICBjb2RlYmxvY2tJbmNsdWRlZCA9ICEhcmVhZEJpdHMoMSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcHJlY2luY3QgPSBjb2RlYmxvY2sucHJlY2luY3Q7CiAgICAgICAgbGV0IGluY2x1c2lvblRyZWU7CiAgICAgICAgaWYgKHByZWNpbmN0LmluY2x1c2lvblRyZWUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgaW5jbHVzaW9uVHJlZSA9IHByZWNpbmN0LmluY2x1c2lvblRyZWU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnN0IHdpZHRoID0gcHJlY2luY3QuY2J4TWF4IC0gcHJlY2luY3QuY2J4TWluICsgMTsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHByZWNpbmN0LmNieU1heCAtIHByZWNpbmN0LmNieU1pbiArIDE7CiAgICAgICAgICBpbmNsdXNpb25UcmVlID0gbmV3IEluY2x1c2lvblRyZWUod2lkdGgsIGhlaWdodCwgbGF5ZXJOdW1iZXIpOwogICAgICAgICAgemVyb0JpdFBsYW5lc1RyZWUgPSBuZXcgVGFnVHJlZSh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgIHByZWNpbmN0LmluY2x1c2lvblRyZWUgPSBpbmNsdXNpb25UcmVlOwogICAgICAgICAgcHJlY2luY3QuemVyb0JpdFBsYW5lc1RyZWUgPSB6ZXJvQml0UGxhbmVzVHJlZTsKICAgICAgICAgIGZvciAobGV0IGwgPSAwOyBsIDwgbGF5ZXJOdW1iZXI7IGwrKykgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkgIT09IDApIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIkludmFsaWQgdGFnIHRyZWUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoaW5jbHVzaW9uVHJlZS5yZXNldChjb2RlYmxvY2tDb2x1bW4sIGNvZGVibG9ja1JvdywgbGF5ZXJOdW1iZXIpKSB7CiAgICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkpIHsKICAgICAgICAgICAgICB2YWx1ZVJlYWR5ID0gIWluY2x1c2lvblRyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgICAgaWYgKHZhbHVlUmVhZHkpIHsKICAgICAgICAgICAgICAgIGNvZGVibG9jay5pbmNsdWRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBjb2RlYmxvY2tJbmNsdWRlZCA9IGZpcnN0VGltZUluY2x1c2lvbiA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaW5jbHVzaW9uVHJlZS5pbmNyZW1lbnRWYWx1ZShsYXllck51bWJlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFjb2RlYmxvY2tJbmNsdWRlZCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChmaXJzdFRpbWVJbmNsdXNpb24pIHsKICAgICAgICB6ZXJvQml0UGxhbmVzVHJlZSA9IHByZWNpbmN0Lnplcm9CaXRQbGFuZXNUcmVlOwogICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLnJlc2V0KGNvZGVibG9ja0NvbHVtbiwgY29kZWJsb2NrUm93KTsKICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgaWYgKHJlYWRCaXRzKDEpKSB7CiAgICAgICAgICAgIHZhbHVlUmVhZHkgPSAhemVyb0JpdFBsYW5lc1RyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgIGlmICh2YWx1ZVJlYWR5KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLmluY3JlbWVudFZhbHVlKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvZGVibG9jay56ZXJvQml0UGxhbmVzID0gemVyb0JpdFBsYW5lc1RyZWUudmFsdWU7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzID0gcmVhZENvZGluZ3Bhc3NlcygpOwogICAgICB3aGlsZSAocmVhZEJpdHMoMSkpIHsKICAgICAgICBjb2RlYmxvY2suTGJsb2NrKys7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzTG9nMiA9ICgwLCBfY29yZV91dGlscy5sb2cyKShjb2RpbmdwYXNzZXMpOwogICAgICBjb25zdCBiaXRzID0gKGNvZGluZ3Bhc3NlcyA8IDEgPDwgY29kaW5ncGFzc2VzTG9nMiA/IGNvZGluZ3Bhc3Nlc0xvZzIgLSAxIDogY29kaW5ncGFzc2VzTG9nMikgKyBjb2RlYmxvY2suTGJsb2NrOwogICAgICBjb25zdCBjb2RlZERhdGFMZW5ndGggPSByZWFkQml0cyhiaXRzKTsKICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgY29kZWJsb2NrLAogICAgICAgIGNvZGluZ3Bhc3NlcywKICAgICAgICBkYXRhTGVuZ3RoOiBjb2RlZERhdGFMZW5ndGgKICAgICAgfSk7CiAgICB9CiAgICBhbGlnblRvQnl0ZSgpOwogICAgaWYgKGVwaE1hcmtlclVzZWQpIHsKICAgICAgc2tpcE1hcmtlcklmRXF1YWwoMHg5Mik7CiAgICB9CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBwYWNrZXRJdGVtID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29kZWJsb2NrID0gcGFja2V0SXRlbS5jb2RlYmxvY2s7CiAgICAgIGlmIChjb2RlYmxvY2suZGF0YSA9PT0g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XQgb2Zmc2V0ID0gY29kZWJsb2NrLnRieDBfIC0geDAgKyAoY29kZWJsb2NrLnRieTBfIC0geTApICogd2lkdGg7CiAgICBjb25zdCBzaWduID0gYml0TW9kZWwuY29lZmZpY2VudHNTaWduOwogICAgY29uc3QgbWFnbml0dWRlID0gYml0TW9kZWwuY29lZmZpY2VudHNNYWduaXR1ZGU7CiAgICBjb25zdCBiaXRzRGVjb2RlZCA9IGJpdE1vZGVsLmJpdHNEZWNvZGVkOwogICAgY29uc3QgbWFnbml0dWRlQ29ycmVjdGlvbiA9IHJldmVyc2libGUgPyAwIDogMC41OwogICAgbGV0IGssIG4sIG5iOwogICAgcG9zaXRpb24gPSAwOwogICAgY29uc3QgaW50ZXJsZWF2ZSA9IHN1YmJhbmQudHlwZSAhPT0gIkxMIjsKICAgIGZvciAoaiA9IDA7IGogPCBibG9ja0hlaWdodDsgaisrKSB7CiAgICAgIGNvbnN0IHJvdyA9IG9mZnNldCAvIHdpZHRoIHwgMDsKICAgICAgY29uc3QgbGV2ZWxPZmZzZXQgPSAyICogcm93ICogKGxldmVsV2lkdGggLSB3aWR0aCkgKyByaWdodCArIGJvdHRvbTsKICAgICAgZm9yIChrID0gMDsgayA8IGJsb2NrV2lkdGg7IGsrKykgewogICAgICAgIG4gPSBtYWduaXR1ZGVbcG9zaXRpb25dOwogICAgICAgIGlmIChuICE9PSAwKSB7CiAgICAgICAgICBuID0gKG4gKyBtYWduaXR1ZGVDb3JyZWN0aW9uKSAqIGRlbHRhOwogICAgICAgICAgaWYgKHNpZ25bcG9zaXRpb25dICE9PSAwKSB7CiAgICAgICAgICAgIG4gPSAtbjsKICAgICAgICAgIH0KICAgICAgICAgIG5iID0gYml0c0RlY29kZWRbcG9zaXRpb25dOwogICAgICAgICAgY29uc3QgcG9zID0gaW50ZXJsZWF2ZSA/IGxldmVsT2Zmc2V0ICsgKG9mZnNldCA8PCAxKSA6IG9mZnNldDsKICAgICAgICAgIGlmIChyZXZlcnNpYmxlICYmIG5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AgICAgeTAgPSB5MGl0ZW1zW2pdICsgb2Zmc2V0OwogICAgICAgICAgeTEgPSB5MWl0ZW1zW2pdOwogICAgICAgICAgeTIgPSB5Mml0ZW1zW2pdOwogICAgICAgICAgY29uc3QgZyA9IHkwIC0gKHkyICsgeTEgPj4gMik7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkyID4+IHNoaWZ0OwogICAgICAgICAgb3V0W3BvcysrXSA9IGcgPj4gc2hpZnQ7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkxID4+IHNoaWZ0OwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZm91ckNvbXBvbmVudHMpIHsKICAgICAgICBmb3IgKGogPSAwLCBwb3MgPSAzOyBqIDwgamo7IGorKywgcG9zICs9IDQpIHsKICAgICAgICAgIG91dFtwb3NdID0geTNpdGVtc1tqXSArIG9mZnNldCA+PiBzaGlmdDsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgICAgICBjb25zdCBpdGVtcyA9IHRyYW5zZm9ybWVkVGlsZXNbY10uaXRlbXM7CiAgICAgICAgc2hpZnQgPSBjb21wb25lbnRzW2NdLnByZWNpc2lvbiAtIDg7CiAgICAgICAgb2Zmc2V0ID0gKDEyOCA8PCBzaGlmdCkgKyAwLjU7CiAgICAgICAgZm9yIChwb3MgPSBjLCBqID0gMCwgamogPSBpdGVtcy5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICBvdXRbcG9zXSA9IGl0ZW1zW2pdICsgb2Zmc2V0ID4+IHNoaWZ0OwogICAgICAgICAgcG9zICs9IGNvbXBvbmVudHNDb3VudDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJlc3VsdEltYWdlcy5wdXNoKHJlc3VsdCk7CiAgfQogIHJldHVybiByZXN1bHRJbWFnZXM7Cn0KZnVuY3Rpb24gaW5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3QgbGV2ZWwgPSB7CiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIGl0ZW1zOiBbXQogICAgICB9OwogICAgICB0aGlzLmxldmVscy5wdXNoKGxldmVsKTsKICAgICAgd2lkdGggPSBNYXRoLmNlaWwod2lkdGggLyAyKTsKICAgICAgaGVpZ2h0ID0gTWF0aC5jZWlsKGhlaWdodCAvIDIpOwogICAgfQogIH0KICByZXNldChpLCBqKSB7CiAgICBsZXQgY3VycmVudExldmVsID0gMCwKICAgICAgdmFsdWUgPSAwLAogICAgICBsZXZlbDsKICAgIHdoaWxlIChjdXJyZW50TGV2ZWwgPCB0aGlzLmxldmVscy5sZW5ndGgpIHsKICAgICAgbGV2ZWwgPSB0aGlzLmxldmVsc1tjdXJyZW50TGV2ZWxdOwogICAgICBjb25zdCBpbmRleCA9IGkgKyBqICogbGV2ZWwud2lkdGg7CiAgICAgIGlmIChsZXZlbC5pdGVtc1tpbmRleF0gIT09IHVuZGVmaW5lZCkgewogICAgICAgIHZhbHVlID0gbGV2ZWwuaXRlbXNbaW5kZXhdOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldmVsLmluZGV4ID0gaW5kZXg7CiAgICAgIGkgPj49IDE7CiAgICAgIGogPj49IDE7CiAgICAgIGN1cnJlbnRMZXZlbCsrOwogICAgfQogICAgY3VycmVudExldmVsLS07CiAgICBsZXZlbCA9IHRoaXMubGV2ZWxzW2N1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0gPSB2YWx1ZTsKICAgIHRoaXMuY3VycmVudExldmVsID0gY3VycmVudExldmVsOwogICAgZGVsZXRlIHRoaXMudmFsdWU7CiAgfQogIGluY3JlbWVudFZhbHVlKCkgewogICAgY29uc3QgbGV2ZWwgPSB0aGlzLmxldmVsc1t0aGlzLmN1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0rKzsKICB9CiAgbmV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wgemVyb0JpdFBsYW5lcywgbWIpIHsKICAgICAgdGhpcy53aWR0aCA9IHdpZHRoOwogICAgICB0aGlzLmhlaWdodCA9IGhlaWdodDsKICAgICAgbGV0IGNvbnRleHRMYWJlbFRhYmxlOwogICAgICBpZiAoc3ViYmFuZCA9PT0gIkhIIikgewogICAgICAgIGNvbnRleHRMYWJlbFRhYmxlID0gSEhDb250ZXh0TGFiZWw7CiAgICAgIH0gZWxzZSBpZiAoc3ViYmFuZCA9PT0gIkhMIikgewogICAgICAgIGNvbnRleHRMYWJlbFRhYmxlID0gSExDb250ZXh0TGFiZWw7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udGV4dExhYmVsVGFibGUgPSBMTEFuZExIQ29udGV4dHNMYWJlbDsKICAgICAgfQogICAgICB0aGlzLmNvbnRleHRMYWJlbFRhYmxlID0gY29udGV4dExhYmVsVGFibGU7CiAgICAgIGNvbnN0IGNvZWZmaWNpZW50Q291bnQgPSB3aWR0aCAqIGhlaWdodDsKICAgICAgdGhpcy5uZWlnaGJvcnNTaWduaWZpY2FuY2UgPSBuZXcgVWludDhBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgdGhpcy5jb2VmZmljZW50c1NpZ24gPSBuZXcgVWludDhBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgbGV0IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICBpZiAobWIgPiAxNCkgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQzMkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgaWYgKG1iID4gNikgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQxNkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQ4QXJyYXkoY29lZmZpY2llbnRDb3VudCk7CiAgICAgI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3QgbGVmdCA9IGNvbHVtbiA+IDA7CiAgICAgIGNvbnN0IHJpZ2h0ID0gY29sdW1uICsgMSA8IHdpZHRoOwogICAgICBsZXQgaTsKICAgICAgaWYgKHJvdyA+IDApIHsKICAgICAgICBpID0gaW5kZXggLSB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKHJvdyArIDEgPCBoZWlnaHQpIHsKICAgICAgICBpID0gaW5kZXggKyB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKGxlZnQpIHsKICAgICAgICBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXggLSAxXSArPSAweDAxOwogICAgICB9CiAgICAgIGlmIChyaWdodCkgewogICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpbmRleCArIDFdICs9IDB4MDE7CiAgICAgIH0KICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSB8PSAweDgwOwogICAgfQogICAgcnVuU2lnbmlmaWNhbmNlUHJvcGFnYXRpb25QYXNzKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdG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c2luZ0ZsYWdzW2luZGV4XSAmPSBwcm9jZXNzZWRJbnZlcnNlTWFzazsKICAgICAgICAgICAgaWYgKGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSB8fCAhbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGNvbnRleHRMYWJlbCA9IGxhYmVsc1tuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdXTsKICAgICAgICAgICAgY29uc3QgZGVjaXNpb24gPSBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIGNvbnRleHRMYWJlbCk7CiAgICAgICAgICAgIGlmIChkZWNpc2lvbikgewogICAgICAgICAgICAgIGNvbnN0IHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzU2lnbltpbmRleF0gPSBzaWduOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSA9IDE7CiAgICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gZmlyc3RNYWduaXR1ZGVCaXRNYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4XSsrOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IHByb2Nlc3NlZE1hc2s7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBkZWNvZGVTaWduQml0KHJvdywgY29sdW1uLCBpbmRleCkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IGNvZWZmaWNlbnRzTWFnbml0dWRlID0gdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZTsKICAgICAgY29uc3QgY29lZmZpY2VudHNTaWduID0gdGhpcy5jb2VmZmljZW50c1NpZ247CiAgICAgIGxldCBjb250cmlidXRpb24sIHNpZ24wLCBzaWduMSwgc2lnbmlmaWNhbmNlMTsKICAgICAgbGV0IGNvbnRleHRMYWJlbCwgZGVjb2RlZDsKICAgICAgc2lnbmlmaWNhbmNlMSA9IGNvbHVtbiA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSAxXSAhPT0gMDsKICAgICAgaWYgKGNvbHVtbiArIDEgPCB3aWR0aCAmJiBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleCArIDFdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyAxXTsKICAgICAgICBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgICAgc2lnbjAgPSBjb2VmZmljZW50c1NpZ25baW5kZXggLSAxXTsKICAgICAgICAgIGNvbnRyaWJ1dGlvbiA9IDEgLSBzaWduMSAtIHNpZ24wOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gMV07CiAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24wIC0gc2lnbjA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gMDsKICAgICAgfQogICAgICBjb25zdCBob3Jpem9udGFsQ29udHJpYnV0aW9uID0gMyAqIGNvbnRyaWJ1dGlvbjsKICAgICAgc2lnbmlmaWNhbmNlMSA9IHJvdyA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSB3aWR0aF0gIT09IDA7CiAgICAgIGlmIChyb3cgKyAxIDwgaGVpZ2h0ICYmIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4ICsgd2lkdGhdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyB3aWR0aF07CiAgICAgICAgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gd2lkdGhdOwogICAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24xIC0gc2lnbjAgKyBob3Jpem9udGFsQ29udHJpYnV0aW9uOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMSArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICBzaWduMCA9IGNvZWZmaWNlbnRzU2lnbltpbmRleCAtIHdpZHRoXTsKICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjAgLSBzaWduMCArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gaG9yaXpvbnRhbENvbnRyaWJ1dGlvbjsKICAgICAgfQogICAgICBpZiAoY29udHJpYnV0aW9uID49IDApIHsKICAgICAgICBjb250ZXh0TGFiZWwgPSA5ICsgY29udHJpYnV0aW9uOwogICAgICAgIGRlY29kZWQgPSB0aGlzLmRlY29kZXIucmVhZEJpdCh0aGlzLmNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDkgLSBjb250cmlidXRpb247CiAgICAgICAgZGVjb2RlZCA9IHRoaXMuZGVjb2Rlci5yZWFkQml0KHRoaXMuY29udGV4dHMsIGNvbnR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ICAgIGlmICghY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgY29udGV4dExhYmVsID0gMTY7CiAgICAgICAgICAgIGlmICgocHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmIGZpcnN0TWFnbml0dWRlQml0TWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIF49IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgICBjb25zdCBzaWduaWZpY2FuY2UgPSBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdICYgMTI3OwogICAgICAgICAgICAgIGNvbnRleHRMYWJlbCA9IHNpZ25pZmljYW5jZSA9PT0gMCA/IDE1IDogMTQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgYml0ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPDwgMSB8IGJpdDsKICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gcHJvY2Vzc2VkTWFzazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJ1bkNsZWFudXBQYXNzKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IG5laWdoYm9yc1N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Nlc3NpbmdGbGFnc1tpbmRleDBdID09PSAwICYmIHByb2Nlc3NpbmdGbGFnc1tpbmRleDAgKyBvbmVSb3dEb3duXSA9PT0gMCAmJiBwcm9jZXNzaW5nRmxhZ3NbaW5kZXgwICsgdHdvUm93c0Rvd25dID09PSAwICYmIHByb2Nlc3NpbmdGbGFnc1tpbmRleDAgKyB0aHJlZVJvd3NEb3duXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwICsgb25lUm93RG93bl0gPT09IDAgJiYgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4MCArIHR3b1Jvd3NEb3duXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0gPT09IDA7CiAgICAgICAgICBsZXQgaTEgPSAwLAogICAgICAgICAgICBpbmRleCA9IGluZGV4MDsKICAgICAgICAgIGxldCBpID0gaTAsCiAgICAgICAgICAgIHNpZ247CiAgICAgICAgICBpZiAoYWxsRW1wdHkpIHsKICAgICAgICAgICAgY29uc3QgaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBSVU5MRU5HVEhfQ09OVEVYVCk7CiAgICAgICAgICAgIGlmICghaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50KSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwXSsrOwogICAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4MCArIG9uZVJvd0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdHdvUm93c0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0rKzsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpMSA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAxIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpOwogICAgICAgICAgICBpZiAoaTEgIT09IDApIHsKICAgICAgICAgICAgICBpID0gaTAgKyBpMTsKICAgICAgICAgICAgICBpbmRleCArPSBpMSAqIHdpZHRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdID0gMTsKICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgaW5kZXggPSBpbmRleDA7CiAgICAgICAgICAgIGZvciAobGV0IGkyID0gaTA7IGkyIDw9IGk7IGkyKyssIGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaTErKzsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGkwICsgaTE7IGkgPCBpTmV4dDsgaSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBpZiAoY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBjb250ZXh0TGFiZWwgPSBsYWJlbHNbbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XV07CiAgICAgICAgICAgIGNvbnN0IGRlY2lzaW9uID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBpZiAoZGVjaXNpb24gPT09IDEpIHsKICAgICAgICAgICAgICBzaWduID0gdGhpcy5kZWNvZGVTaWduQml0KGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSAxOwogICAgICAgICAgICAgIHRoaXMuc2V0TmVpZ2hib3JzU2lnbmlmaWNhbmNlKGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBiaXRzRGVjb2RlZFtpbmRleF0rKzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNoZWNrU2VnbWVudGF0aW9uU3ltYm9sKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCBjb250ZXh0cyA9IHRoaXMuY29udGV4dHM7CiAgICAgIGNvbnN0IHN5bWJvbCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAzIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpIDw8IDIgfCBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIFVOSUZPUk1fQ09OVEVYVCkgPDwgMSB8IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKTsKICAgICAgaWYgKHN5bWJvbCAhPT0gMHhhKSB7CiAgICAgICAgdGhyb3cg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Hw9IDA7CiAgICBsZXQgaiwgbiwgY3VycmVudCwgbmV4dDsKICAgIGNvbnN0IGFscGhhID0gLTEuNTg2MTM0MzQyMDU5OTI0OwogICAgY29uc3QgYmV0YSA9IC0wLjA1Mjk4MDExODU3Mjk2MTsKICAgIGNvbnN0IGdhbW1hID0gMC44ODI5MTEwNzU1MzA5MzQ7CiAgICBjb25zdCBkZWx0YSA9IDAuNDQzNTA2ODUyMDQzOTcxOwogICAgY29uc3QgSyA9IDEuMjMwMTc0MTA0OTE0MDAxOwogICAgY29uc3QgS18gPSAxIC8gSzsKICAgIGogPSBvZmZzZXQgLSAzOwogICAgZm9yIChuID0gbGVuICsgNDsgbi0tOyBqICs9IDIpIHsKICAgICAgeFtqXSAqPSBLXzsKICAgIH0KICAgIGogPSBvZmZzZXQgLSAyOwogICAgY3VycmVudCA9IGRlbHRhICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAzOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZGVsdGEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSA9IEsgKiB4W2pdIC0gY3VycmVudCAtIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGRlbHRhICogeFtqICsgMV07CiAgICAgICAgeFtqXSA9IEsgKiB4W2pdIC0gY3VycmVudCAtIG5leHQ7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGogPSBvZmZzZXQgLSAxOwogICAgY3VycmVudCA9IGdhbW1hICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAyOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSAtPSBjdXJyZW50ICsgbmV4dDsKICAgICAgaWYgKG4tLSkgewogICAgICAgIGogKz0gMjsKICAgICAgICBjdXJyZW50ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBqID0gb2Zmc2V0OwogICAgY3VycmVudCA9IGJldGEgKiB4W2ogLSAxXTsKICAgIGZvciAobiA9IGxlbiArIDE7IG4tLTsgaiArPSAyKSB7CiAgICAgIG5leHQgPSBiZXRhICogeFtqICsgMV07CiAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGJldGEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAobGVuICE9PSAwKSB7CiAgICAgIGogPSBvZmZzZXQgKyAxOwogICAgICBjdXJyZW50ID0gYWxwaGEgKiB4W2ogLSAxXTsKICAgICAgZm9yIChuID0gbGVuOyBuLS07IGogKz0gMikgewogICAgICAgIG5leHQgPSBhbHBoYSAqIHhbaiArIDFdOwogICAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgICAgaWYgKG4tLSkgewogICAgICAgICAgaiArPSAyOwogICAgICAgICAgY3VycmVudCA9IGFscGhhICogeFtqICsgMV07CiAgICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9Cn0KY2xhc3MgUmV2ZXJzaWJsZVRyYW5zZm9ybSBleHRlbmRzIFRyYW5zZm9ybSB7CiAgZmlsdGVyKHgsIG9mZnNldCwgbGVuZ3RoKSB7CiAgICBjb25zdCBsZW4gPSBsZW5ndGggPj4gMTsKICAgIG9mZnNldCB8PSAwOwogICAgbGV0IGosIG47CiAgICBmb3IgKGogPSBv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l0ZXNbaisrXSAmIDB4ZmY7CiAgICAgICAgICAgIGluYml0cyArPSA4OwogICAgICAgICAgfQogICAgICAgICAgY29tcEFycmF5W2trXSA9IGNvbXBBcnJheVtra10gKyAoaW5idWYgPj4gaW5iaXRzIC0gYml0cykgJiBiaXRNYXNrOwogICAgICAgICAgaW5iaXRzIC09IGJpdHM7CiAgICAgICAgICBvdXRidWYgPSBvdXRidWYgPDwgYml0cyB8IGNvbXBBcnJheVtra107CiAgICAgICAgICBvdXRiaXRzICs9IGJpdHM7CiAgICAgICAgICBpZiAob3V0Yml0cyA+PSA4KSB7CiAgICAgICAgICAgIGJ1ZmZlcltrKytdID0gb3V0YnVmID4+IG91dGJpdHMgLSA4ICYgMHhmZjsKICAgICAgICAgICAgb3V0Yml0cyAtPSA4OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAob3V0Yml0cyA+IDApIHsKICAgICAgICBidWZmZXJbaysrXSA9IChvdXRidWYgPDwgOCAtIG91dGJpdHMpICsgKGluYnVmICYgKDEgPDwgOCAtIG91dGJpdHMpIC0gMSk7CiAgICAgIH0KICAgIH0KICAgIHRoaXMuYnVmZmVyTGVuZ3RoICs9IHJvd0J5dGVzOwogIH0KICByZWFkQmxvY2tQbmcoKSB7CiAgICBjb25zdCByb3dCeXRlcyA9IHRoaXMucm93Qnl0ZXM7CiAgICBjb25zdCBwaXhCeXRlcyA9IHRoaXMucGl4Qnl0ZXM7CiAgICBjb25zdCBwcmVkaWN0b3IgPSB0aGlzLnN0ci5nZXRCeXRlKCk7CiAgICBjb25zdCByYXdCeXRlcyA9IHRoaXMuc3RyLmdldEJ5dGVzKHJvd0J5dGVzKTsKICAgIHRoaXMuZW9mID0gIXJhd0J5dGVzLmxlbmd0aDsKICAgIGlmICh0aGlzLmVvZikgewogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBidWZmZXJMZW5ndGggPSB0aGlzLmJ1ZmZlckxlbmd0aDsKICAgIGNvbnN0IGJ1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ICAgYnVmZmVyW2orK10gPSAocHJldlJvd1tpXSA+PiAxKSArIHJhd0J5dGVzW2ldOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqXSA9IChwcmV2Um93W2ldICsgYnVmZmVyW2ogLSBwaXhCeXRlc10gPj4gMSkgKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDQ6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGMgPSByYXdCeXRlc1tpXTsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gdXAgKyBjOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGNvbnN0IHVwTGVmdCA9IHByZXZSb3dbaSAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IGxlZnQgPSBidWZmZXJbaiAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IHAgPSBsZWZ0ICsgdXAgLSB1cExlZnQ7CiAgICAgICAgICBsZXQgcGEgPSBwIC0gbGVmdDsKICAgICAgICAgIGlmIChwYSA8IDApIHsKICAgICAgICAgICAgcGEgPSAtcGE7CiAgICAgICAgICB9CiAgICAgICAgICBsZXQgcGIgPSBwIC0gdXA7CiAgICAgICAgICBpZiAocGIgPCAwKSB7CiAgICAgICAgICAgIHBiID0gLXBiOwogICAgICAgICAgfQogICAgICAgICAgbGV0IHBjID0gcCAtIHVwTGVmdDsKICAgICAgICAgIGlmIChwYyA8IDApIHsKICAgICAgICAgICAgcGMgPSAtcGM7CiAgICAgICAgICB9CiAgICAgICAgICBjID0gcmF3Qnl0ZXNbaV07C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IHRoaXMuY29udmVydChuYW1lLCBjZmYsIHByb3BlcnRpZXMpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT3BlblR5cGUiOgogICAgICAgIGNhc2UgIlRydWVUeXBlIjoKICAgICAgICBjYXNlICJDSURGb250VHlwZTIiOgogICAgICAgICAgdGhpcy5taW1ldHlwZSA9ICJmb250L29wZW50eXBlIjsKICAgICAgICAgIGRhdGEgPSB0aGlzLmNoZWNrQW5kUmVwYWlyKG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgaWYgKHRoaXMuaXNPcGVuVHlwZSkgewogICAgICAgICAgICBhZGp1c3RXaWR0aHMocHJvcGVydGllcyk7CiAgICAgICAgICAgIHR5cGUgPSAiT3BlblR5cGUiOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgRm9udCAke3R5cGV9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgICAgfQogICAgfSBjYXRjaCAoZSkgewogICAgICAoMCwgX3V0aWwud2FybikoZSk7CiAgICAgIHRoaXMuZmFsbGJhY2tUb1N5c3RlbUZvbnQocHJvcGVydGllcyk7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGFtZW5kRmFsbGJhY2tUb1VuaWNvZGUocHJvcGVydGllcyk7CiAgICB0aGlzLmRhdGEgPSBkYXRhOwogICAgdGhpcy50eXBlID0gdHlwZTsKICAgIHRoaXMuc3VidHlwZSA9IHN1YnR5cGU7CiAgICB0aGlzLmZvbnRNYXRyaXggPSBwcm9wZXJ0aWVzLmZvbnRNYXRyaXg7CiAgICB0aGlzLndpZHRocyA9IHByb3BlcnRpZXMud2lkdGhzOwogICAgdGhpcy5kZWZhdWx0V2lkdGggPSBwcm9wZXJ0aWVzLmRlZmF1bHRXaWR0aDsKICAgIHRoaXMudG9Vbmljb2RlID0gcHJvcGVydGllcy50b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ICAgICAgYXBwbHlTdGFuZGFyZEZvbnRHbHlwaE1hcChtYXAsICgwLCBfc3RhbmRhcmRfZm9udHMuZ2V0U3VwcGxlbWVudGFsR2x5cGhNYXBGb3JDYWxpYnJpKSgpKTsKICAgICAgfQogICAgICBpZiAoY2lkVG9HaWRNYXApIHsKICAgICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIGluIG1hcCkgewogICAgICAgICAgY29uc3QgY2lkID0gbWFwW2NoYXJDb2RlXTsKICAgICAgICAgIGlmIChjaWRUb0dpZE1hcFtjaWRdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgbWFwWytjaGFyQ29kZV0gPSBjaWRUb0dpZE1hcFtjaWRdOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY2lkVG9HaWRNYXAubGVuZ3RoICE9PSB0aGlzLnRvVW5pY29kZS5sZW5ndGggJiYgcHJvcGVydGllcy5oYXNJbmNsdWRlZFRvVW5pY29kZU1hcCAmJiB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkgewogICAgICAgICAgdGhpcy50b1VuaWNvZGUuZm9yRWFjaChmdW5jdGlvbiAoY2hhckNvZGUsIHVuaWNvZGVDaGFyQ29kZSkgewogICAgICAgICAgICBjb25zdCBjaWQgPSBtYXBbY2hhckNvZGVdOwogICAgICAgICAgICBpZiAoY2lkVG9HaWRNYXBbY2lkXSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgbWFwWytjaGFyQ29kZV0gPSB1bmljb2RlQ2hhckNvZGU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICB0aGlzLnRvVW5pY29kZS5mb3JFYWNoKGZ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JsZXMucG9zdCA9IG51bGw7CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtVGFibGVzOyBpKyspIHsKICAgICAgICBjb25zdCB0YWJsZSA9IHJlYWRUYWJsZUVudHJ5KGZpbGUpOwogICAgICAgIGlmICghVkFMSURfVEFCTEVTLmluY2x1ZGVzKHRhYmxlLnRhZykpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGFibGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdGFibGVzW3RhYmxlLnRhZ10gPSB0YWJsZTsKICAgICAgfQogICAgICByZXR1cm4gdGFibGVzOwogICAgfQogICAgZnVuY3Rpb24gcmVhZFRhYmxlRW50cnkoZmlsZSkgewogICAgICBjb25zdCB0YWcgPSBmaWxlLmdldFN0cmluZyg0KTsKICAgICAgY29uc3QgY2hlY2tzdW0gPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgY29uc3QgbGVuZ3RoID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICBjb25zdCBwcmV2aW91c1Bvc2l0aW9uID0gZmlsZS5wb3M7CiAgICAgIGZpbGUucG9zID0gZmlsZS5zdGFydCB8fCAwOwogICAgICBmaWxlLnNraXAob2Zmc2V0KTsKICAgICAgY29uc3QgZGF0YSA9IGZpbGUuZ2V0Qnl0ZXMobGVuZ3RoKTsKICAgICAgZmlsZS5wb3MgPSBwcmV2aW91c1Bvc2l0aW9uOwogICAgICBpZiAodGFnID09PSAiaGVhZCIpIHsKICAgICAgICBkYXRhWzhdID0gZGF0YVs5XSA9IGRhdGFbMTBdID0gZGF0YVsxMV0gPSAwOwogICAgICAgIGRhdGFbMTddIHw9IDB4MjA7CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICB0YWcsCiAgICAg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ModHRjLCBwb3RlbnRpYWxIZWFkZXIubnVtVGFibGVzKTsKICAgICAgICBpZiAoIXBvdGVudGlhbFRhYmxlcy5uYW1lKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoJ1RydWVUeXBlIENvbGxlY3Rpb24gZm9udCBtdXN0IGNvbnRhaW4gYSAibmFtZSIgdGFibGUuJyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IFtuYW1lVGFibGVdID0gcmVhZE5hbWVUYWJsZShwb3RlbnRpYWxUYWJsZXMubmFtZSk7CiAgICAgICAgZm9yIChsZXQgaiA9IDAsIGpqID0gbmFtZVRhYmxlLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGsgPSAwLCBrayA9IG5hbWVUYWJsZVtqXS5sZW5ndGg7IGsgPCBrazsgaysrKSB7CiAgICAgICAgICAgIGNvbnN0IG5hbWVFbnRyeSA9IG5hbWVUYWJsZVtqXVtrXSAmJiBuYW1lVGFibGVbal1ba10ucmVwbGFjZUFsbCgvXHMvZywgIiIpOwogICAgICAgICAgICBpZiAoIW5hbWVFbnRyeSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IGZvbnROYW1lKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIGhlYWRlcjogcG90ZW50aWFsSGVhZGVyLAogICAgICAgICAgICAgICAgdGFibGVzOiBwb3RlbnRpYWxUYWJsZXMKICAgICAgICAgICAgICB9OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmb250TmFtZVBhcnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3IgKGNvbnN0IHBhcnQgb2YgZm9udE5hbWVQYXJ0cykgewogICAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IHBhcnQpIHsKICAgICAgICAgICAgICAgIGZhbGxiYWNrRGF0YSA9IHsKICAgICAgICAgICAgICAgICAgbmFtZTogcGFydCwKICAgICAgICAgICAgICAgICAgaGVhZGVyOiBwb3RlbnRpYWxIZWFkZXIsCiAgICAgICAgICAgICAgICAgIHRhYmxlczogcG90ZW50aWFsVGFibGVzCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZmFsbGJhY2tEYXRhKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUcnVlVHlwZSBDb2xsZWN0aW9uIGRvZXMgbm90IGNvbnRhaW4gIiR7Zm9udE5hbWV9IiBmb250LCBgICsgYGZhbGxpbmcgYmFjayB0byAiJHtmYWxsYmFja0RhdGEubmFtZX0iIGZvbnQgaW5zdGVhZC5gKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgaGVhZGVyOiBmYWxsYmFja0RhdGEuaGVhZGVyLAogICAgICAgICAgdGFibGVzOiBmYWxsYmFja0RhdGEudGFibGVzCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFRydWVUeXBlIENvbGxlY3Rpb24gZG9lcyBub3QgY29udGFpbiAiJHtmb250TmFtZX0iIGZvbnQuYCk7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkQ21hcFRhYmxlKGNtYXAsIGZpbGUsIGlzU3ltYm9saWNGb250LCBoYXNFbmNvZGluZykgewogICAgICBpZiAoIWNtYXApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vIGNtYXAgdGFibGUgYXZhaWxhYmxlLiIpOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBwbGF0Zm9ybUlkOiAtMSwKICAgICAgICAgIGVuY29kaW5nSWQ6IC0xLAogICAgICAgICAgbWFwcGluZ3M6IFtdLAogICAgICAgICAgaGFzU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kID09PSAzICYmIGVuY29kaW5nSWQgPT09IDEgJiYgKGhhc0VuY29kaW5nIHx8ICFwb3RlbnRpYWxUYWJsZSkpIHsKICAgICAgICAgIHVzZVRhYmxlID0gdHJ1ZTsKICAgICAgICAgIGlmICghaXNTeW1ib2xpY0ZvbnQpIHsKICAgICAgICAgICAgY2FuQnJlYWsgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoaXNTeW1ib2xpY0ZvbnQgJiYgcGxhdGZvcm1JZCA9PT0gMyAmJiBlbmNvZGluZ0lkID09PSAwKSB7CiAgICAgICAgICB1c2VUYWJsZSA9IHRydWU7CiAgICAgICAgICBsZXQgY29ycmVjdGx5U29ydGVkID0gdHJ1ZTsKICAgICAgICAgIGlmIChpIDwgbnVtVGFibGVzIC0gMSkgewogICAgICAgICAgICBjb25zdCBuZXh0Qnl0ZXMgPSBmaWxlLnBlZWtCeXRlcygyKSwKICAgICAgICAgICAgICBuZXh0UGxhdGZvcm1JZCA9IGludDE2KG5leHRCeXRlc1swXSwgbmV4dEJ5dGVzWzFdKTsKICAgICAgICAgICAgaWYgKG5leHRQbGF0Zm9ybUlkIDwgcGxhdGZvcm1JZCkgewogICAgICAgICAgICAgIGNvcnJlY3RseVNvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29ycmVjdGx5U29ydGVkKSB7CiAgICAgICAgICAgIGNhbkJyZWFrID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVzZVRhYmxlKSB7CiAgICAgICAgICBwb3RlbnRpYWxUYWJsZSA9IHsKICAgICAgICAgICAgcGxhdGZvcm1JZCwKICAgICAgICAgICAgZW5jb2RpbmdJZCwKICAgICAgICAgICAgb2Zmc2V0CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICBpZiAoY2FuQnJlYWspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocG90ZW50aWFsVGFibGUpIHsKICAgICAgICBmaWxlLnBvcyA9IHN0YXJ0ICsgcG90ZW50aWFsVGFibGUub2Zmc2V0OwogICAgICB9CiAgICAgIGlmICghcG90ZW50aWFsVGFibGUgfHwgZmlsZS5wZWVrQnl0ZSgpID09PSAtMSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiQ291bGQgbm90IGZpbmQgYSBwcmVmZXJyZWQgY21hcCB0YWJsZS4iKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGxldCBoYXNTaG9ydENtYXAgPSBmYWxzZTsKICAgICAgY29uc3QgbWFwcGluZ3MgPSBbXTsKICAgICAgbGV0IGosIGdseXBoSWQ7CiAgICAgIGlmIChmb3JtYXQgPT09IDApIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAyNTY7IGorKykgewogICAgICAgICAgY29uc3QgaW5kZXggPSBmaWxlLmdldEJ5dGUoKTsKICAgICAgICAgIGlmICghaW5kZXgpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgIGdseXBoSWQ6IGluZGV4CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaGFzU2hvcnRDbWFwID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmIChmb3JtYXQgPT09IDIpIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGNvbnN0IHN1YkhlYWRlcktleXMgPSBbXTsKICAgICAgICBsZXQgbWF4U3ViSGVhZGVyS2V5ID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICBjb25zdCBzdWJIZWFkZXJLZXkgPSBmaWxlLmdldFVpbnQxNigpID4+IDM7CiAgICAgICAgICBzdWJIZWFkZXJLZXlzLnB1c2goc3ViSGVhZGVyS2V5KTsKICAgICAgICAgIG1heFN1YkhlYWRlcktleSA9IE1hdGgubWF4KHN1YkhlYWRlcktleSwgbWF4U3ViSGVhZGVyS2V5KTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc3ViSGVhZGVycyA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IG1heFN1YkhlYWRlcktleTsgaSsrKSB7CiAgICAgICAgICBzdWJIZWFkZXJzLnB1c2goewogICAgICAgICAgICBmaXJzdENvZGU6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGVudHJ5Q291bnQ6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGlkRGVsdGE6IHNpZ25lZEludDE2KGZpbGUuZ2V0Qnl0ZSgpLCBmaWxlLmdldEJ5dGUoKSksCiAgICAgICAgICAgIGlkUmFuZ2VQb3M6IGZpbGUucG9zICsgZmlsZS5nZXRVaW50MTYoKQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgIGlmIChzdWJIZWFkZXJLZXlzW2ldID09PSAwKSB7CiAgICAgICAgICAgIGZpbGUucG9zID0gc3ViSGVhZGVyc1swXS5pZFJhbmdlUG9zICsgMiAqIGk7CiAgICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBjaGFyQ29kZTogaSwKICAgICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgcyA9IHN1YkhlYWRlcnNbc3ViSGVhZGVyS2V5c1tpXV07CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBzLmVudHJ5Q291bnQ7IGorKykgewogICAgICAgICAgICAgIGNvbnN0IGNoYXJDb2RlID0gKGkgPDwgOCkgKyBqICsgcy5maXJzdENvZGU7CiAgICAgICAgICAgICAgZmlsZS5wb3MgPSBzLmlkUmFuZ2VQb3MgKyAyICogajsKICAgICAgICAgICAgICBnbHlwaElkID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgICAgICBpZiAoZ2x5cGhJZCAhPT0gMCkgewogICAgICAgICAgICAgICAgZ2x5cGhJZCA9IChnbHlwaElkICsgcy5pZERlbHRhKSAlIDY1NTM2OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gNCkgewogICAgICAgIGZpbGUuc2tpcCgyICsgMik7CiAgICAgICAgY29uc3Qgc2VnQ291bnQgPSBmaWxlLmdldFVpbnQxNigpID4+IDE7CiAgICAgICAgZmlsZS5za2lwKDYpOwogICAgICAgIGNvbnN0IHNlZ21lbnRzID0gW107CiAgICAgICAgbGV0IHNlZ0luZGV4OwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50cy5wdXNoKHsKICAgICAgICAgICAgZW5kOiBmaWxlLmdldFVpbnQxNigpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgZmlsZS5za2lwKDIpOwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50c1tzZWdJbmRleF0uc3RhcnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIH0KICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudHNbc2VnSW5kZXhdLmRlbHRhID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICB9CiAgICAgICAgbGV0IG9mZnNldHNDb3VudCA9IDAsCiAgICAgICAgICBvZmZzZXRJbmRleDsKICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudCA9IHNlZ21lbnRzW3NlZ0luZGV4XTsKICAgICAgICAgIGNvbnN0IHJhbmdlT2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmICghcmFuZ2VPZmZzZXQpIHsKICAgICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IC0xOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldEluZGV4ID0gKHJhbmdlT2Zmc2V0ID4+IDEpIC0gKHNlZ0NvdW50IC0gc2VnSW5kZXgpOwogICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IG9mZnNldEluZGV4OwogICAgICAgICAgb2Zmc2V0c0NvdW50ID0gTWF0aC5tYXgob2Zmc2V0c0NvdW50LCBvZmZzZXRJbmRleCArIHNlZ21lbnQuZW5kIC0gc2VnbWVudC5zdGFydCArIDEpOwogICAgICAgIH0KICAgICAgICBjb25zdCBvZmZzZXRzID0gW107CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG9mZnNldHNDb3VudDsgaisrKSB7CiAgICAgICAgICBvZmZzZXRzLnB1c2goZmlsZS5nZXRVaW50MTYoKSk7CiAgICAgICAgfQogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50ID0gc2VnbWVudHNbc2VnSW5kZXhdOwogICAgICAgICAgc3RhcnQgPSBzZWdtZW50LnN0YXJ0OwogICAgICAgICAgY29uc3QgZW5kID0gc2VnbWVudC5lbmQ7CiAgICAgICAgICBjb25zdCBkZWx0YSA9IHNlZ21lbnQuZGVsdGE7CiAgICAgICAgICBvZmZzZXRJbmRleCA9IHNlZ21lbnQub2Zmc2V0SW5kZXg7CiAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBlbmQ7IGorKykgewogICAgICAgICAgICBpZiAoaiA9PT0gMHhmZmZmKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhJZCA9IG9mZnNldEluZGV4IDwgMCA/IGogOiBvZmZzZXRzW29mZnNldEluZGV4ICsgaiAtIHN0YXJ0XTsKICAgICAgICAgICAgZ2x5cGhJZCA9IGdseXBoSWQgKyBkZWx0YSAmIDB4ZmZmZjsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSA2KSB7CiAgICAgICAgZmlsZS5za2lwKDIgKyAyKTsKICAgICAgICBjb25zdCBmaXJzdENvZGUgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVudHJ5Q291bnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCBlbnRyeUNvdW50OyBqKyspIHsKICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgY29uc3QgY2hhckNvZGUgPSBmaXJzdENvZGUgKyBqOwogICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgICAgIGZpbGUuc2tpcCgyICsgNCArIDQpOwogICAgICAgIGNvbnN0IG5Hcm91cHMgPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG5Hcm91cHM7IGorKykgewogICAgICAgICAgY29uc3Qgc3RhcnRDaGFyQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGNvbnN0IGVuZENoYXJDb2RlID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgbGV0IGdseXBoQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGZvciAobGV0IGNoYXJDb2RlID0gc3RhcnRDaGFyQ29kZTsgY2hhckNvZGUgPD0gZW5kQ2hhckNvZGU7IGNoYXJDb2RlKyspIHsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGUsCiAgICAgICAgICAgICAgZ2x5cGhJZDogZ2x5cGhDb2RlKysKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiY21hcCB0YWJsZSBoYXMgdW5zdXBwb3J0ZWQgZm9ybWF0OiAiICsgZm9ybWF0KTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc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IChtZXRyaWNzLmxlbmd0aCAtIG51bU9mTWV0cmljcyAqIDQgPj4gMSk7CiAgICAgIGlmIChudW1NaXNzaW5nID4gMCkgewogICAgICAgIGNvbnN0IGVudHJpZXMgPSBuZXcgVWludDhBcnJheShtZXRyaWNzLmxlbmd0aCArIG51bU1pc3NpbmcgKiAyKTsKICAgICAgICBlbnRyaWVzLnNldChtZXRyaWNzLmRhdGEpOwogICAgICAgIGlmIChkdXBGaXJzdEVudHJ5KSB7CiAgICAgICAgICBlbnRyaWVzW21ldHJpY3MubGVuZ3RoXSA9IG1ldHJpY3MuZGF0YVsyXTsKICAgICAgICAgIGVudHJpZXNbbWV0cmljcy5sZW5ndGggKyAxXSA9IG1ldHJpY3MuZGF0YVszXTsKICAgICAgICB9CiAgICAgICAgbWV0cmljcy5kYXRhID0gZW50cmllczsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVHbHlwaChzb3VyY2UsIHNvdXJjZVN0YXJ0LCBzb3VyY2VFbmQsIGRlc3QsIGRlc3RTdGFydCwgaGludHNWYWxpZCkgewogICAgICBjb25zdCBnbHlwaFByb2ZpbGUgPSB7CiAgICAgICAgbGVuZ3RoOiAwLAogICAgICAgIHNpemVPZkluc3RydWN0aW9uczogMAogICAgICB9OwogICAgICBpZiAoc291cmNlRW5kIC0gc291cmNlU3RhcnQgPD0gMTIpIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGNvbnN0IGdseWYgPSBzb3VyY2Uuc3ViYXJyYXkoc291cmNlU3RhcnQsIHNvdXJjZUVuZCk7CiAgICAgIGxldCBjb250b3Vyc0NvdW50ID0gc2lnbmVkSW50MTYoZ2x5ZlswXSwgZ2x5ZlsxXSk7CiAgICAgIGlmIChjb250b3Vyc0NvdW50IDwgMCkgewogICAgICAgIGNvbnRvdXJzQ291bnQgPSAtMTsKICAgICAgICB3cml0ZVNpZ25lZEludDE2KGdseWYsIDAsIGNvbnRvdXJzQ291bnQpOwogICAgICAgIGRlc3Quc2V0KGdseWYsIGRlc3RTdGFydCk7CiAgICAgICAgZ2x5cGhQcm9maWxlLmxlbmd0aCA9IGdseWYubGVuZ3RoOwogICAgICAgIHJldHVybiBnbHlwaFByb2ZpbGU7CiAgICAgIH0KICAgICAgbGV0IGksCiAgICAgICAgaiA9IDEwLAogICAgICAgIGZsYWdzQ291bnQgPSAwOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29udG91cnNDb3VudDsgaSsrKSB7CiAgICAgICAgY29uc3QgZW5kUG9pbnQgPSBnbHlmW2pdIDw8IDggfCBnbHlmW2ogKyAxXTsKICAgICAgICBmbGFnc0NvdW50ID0gZW5kUG9pbnQgKyAxOwogICAgICAgIGogKz0gMjsKICAgICAgfQogICAgICBjb25zdCBpbnN0cnVjdGlvbnNTdGFydCA9IGo7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0xlbmd0aCA9IGdseWZbal0gPDwgOCB8IGdseWZbaiArIDFdOwogICAgICBnbHlwaFByb2ZpbGUuc2l6ZU9mSW5zdHJ1Y3Rpb25zID0gaW5zdHJ1Y3Rpb25zTGVuZ3RoOwogICAgICBqICs9IDIgKyBpbnN0cnVjdGlvbnNMZW5ndGg7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0VuZCA9IGo7CiAgICAgIGxldCBjb29yZGluYXRlc0xlbmd0aCA9IDA7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBmbGFnc0NvdW50OyBpKyspIHsKICAgICAgICBjb25zdCBmbGFnID0gZ2x5ZltqKytdOwogICAgICAgIGlmIChmbGFnICYgMHhjMCkgewogICAgICAgICAgZ2x5ZltqIC0gMV0gPSBmbGFnICYgMHgzZjsKICAgICAgICB9CiAgICAgICAgbGV0IHhMZW5ndGggPSAyOwogICAgICAgIGlmIChmbGFnICYgMikgewogICAgICAgICAgeExlbmd0aCA9IDE7CiAgICAgICAgfSBlbHNlIGlmIChmbGFnICYgMTYpIHsKICAgICAgICAgIHhMZW5ndGggPSAwOwogICAgICAgIH0KICAgICAgICBsZXQgeUxlbmd0aCA9IDI7CiAgICAgICAgaWYgKGZsYWcgJiA0KSB7CiAgICAgICAgICB5TGVuZ3RoID0gMTsKICAgICAgICB9IGVsc2UgaWYgKGZsYWcgJiAzMikgewogICAgICAgICAgeUxlbmd0aCA9IDA7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHh5TGVuZ3RoID0geExlbmd0aCArIHlMZW5ndGg7CiAgICAgICAgY29vcmRpbmF0ZXNMZW5ndGggKz0geHlMZW5ndGg7CiAgICAgICAgaWYgKGZsYWcgJiA4KSB7CiAgICAgICAgICBjb25zdCByZXBlYXQgPSBnbHlmW2orK107CiAgICAgICAgICBpICs9IHJlcGVhdDsKICAgICAgICAgIGNvb3JkaW5hdGVzTGVuZ3RoICs9IHJlcGVhdCAqIHh5TGVuZ3RoOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29vcmRpbmF0ZXNMZW5ndGggPT09IDApIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGxldCBnbHlwaERhdGFMZW5ndGggPSBqICsgY29vcmRpbmF0ZXNMZW5ndGg7CiAgICAgIGlmIChnbHlwaERhdGFMZW5ndGggPiBnbHlmLmxlbmd0aCkgewogICAgICAgIHJldHVybiBnbHlwaFByb2ZpbGU7CiAgICAgIH0KICAgICAgaWYgKCFoaW50c1ZhbGlkICYmIGluc3RydWN0aW9uc0xlbmd0aCA+IDApIHsKICAgICAgICBkZXN0LnNldChnbHlmLnN1YmFycmF5KDAsIGluc3RydWN0aW9uc1N0YXJ0KSwgZGVzdFN0YXJ0KTsKICAgICAgICBkZXN0LnNldChbMCwgMF0sIGRlc3RTdGFydCArIGluc3RydWN0aW9uc1N0YXJ0KTsKICAgICAgICBkZXN0LnNldChnbHlmLnN1YmFycmF5KGluc3RydWN0aW9uc0VuZCwgZ2x5cGhEYXRhTGVuZ3RoKSwgZGVzdFN0YXJ0ICs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HsKICAgICAgICAgIGluZGV4OiBpLAogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0OiAwCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgbG9jYUVudHJpZXMuc29ydCgoYSwgYikgPT4gewogICAgICAgIHJldHVybiBhLm9mZnNldCAtIGIub2Zmc2V0OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgbG9jYUVudHJpZXNbaV0uZW5kT2Zmc2V0ID0gbG9jYUVudHJpZXNbaSArIDFdLm9mZnNldDsKICAgICAgfQogICAgICBsb2NhRW50cmllcy5zb3J0KChhLCBiKSA9PiB7CiAgICAgICAgcmV0dXJuIGEuaW5kZXggLSBiLmluZGV4OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0CiAgICAgICAgfSA9IGxvY2FFbnRyaWVzW2ldOwogICAgICAgIGlmIChvZmZzZXQgIT09IDAgfHwgZW5kT2Zmc2V0ICE9PSAwKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY29uc3QgbmV4dE9mZnNldCA9IGxvY2FFbnRyaWVzW2kgKyAxXS5vZmZzZXQ7CiAgICAgICAgaWYgKG5leHRPZmZzZXQgPT09IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsb2NhRW50cmllc1tpXS5lbmRPZmZzZXQgPSBuZXh0T2Zmc2V0OwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNvbnN0IG1pc3NpbmdHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgd3JpdGVPZmZzZXQgPSAwOwogICAgICBpdGVtRW5jb2RlKGxvY2FEYXRhLCAwLCB3cml0ZU9mZnNldCk7CiAgIC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wb3N0LCBwcm9wZXJ0aWVzT2JqLCBtYXhwTnVtR2x5cGhzKSB7CiAgICAgIGNvbnN0IHN0YXJ0ID0gKGZvbnQuc3RhcnQgfHwgMCkgKyBwb3N0Lm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbGVuZ3RoID0gcG9zdC5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IHZlcnNpb24gPSBmb250LmdldEludDMyKCk7CiAgICAgIGZvbnQuc2tpcCgyOCk7CiAgICAgIGxldCBnbHlwaE5hbWVzOwogICAgICBsZXQgdmFsaWQgPSB0cnVlOwogICAgICBsZXQgaTsKICAgICAgc3dpdGNoICh2ZXJzaW9uKSB7CiAgICAgICAgY2FzZSAweDAwMDEwMDAwOgogICAgICAgICAgZ2x5cGhOYW1lcyA9IF9mb250c191dGlscy5NYWNTdGFuZGFyZEdseXBoT3JkZXJpbmc7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDAwMjAwMDA6CiAgICAgICAgICBjb25zdCBudW1HbHlwaHMgPSBmb250LmdldFVpbnQxNigpOwogICAgICAgICAgaWYgKG51bUdseXBocyAhPT0gbWF4cE51bUdseXBocykgewogICAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGdseXBoTmFtZUluZGV4ZXMgPSBbXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1HbHlwaHM7ICsraSkgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgICAgICAgIGlmIChpbmRleCA+PSAzMjc2OCkgewogICAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhOYW1lSW5kZXhlcy5wdXNoKGluZGV4KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjdXN0b21OYW1lcyA9IFtdLAogICAgICAgICAgICBzdHJCdWYgPSBbXTsKICAgICAgICAgIHdoaWxlIChmb250LnBvcyA8IGVuZCkgewogICAgICAgICAgICBjb25zdCBzdHJpbmdMZW5ndGggPSBmb250LmdldEJ5dGUoKTsKICAgICAgICAgICAgc3RyQnVmLmxlbmd0aCA9IHN0cmluZ0xlbmd0aDsKICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHN0cmluZ0xlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgc3RyQnVmW2ldID0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldEJ5dGUoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3VzdG9tTmFtZXMucHVzaChzdHJCdWYuam9pbigiIikpOwogICAgICAgICAgfQogICAgICAgICAgZ2x5cGhOYW1lcyA9IFtdOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgKytpKSB7CiAgICAgICAgICAgIGNvbnN0IGogPSBnbHlwaE5hbWVJbmRleGVzW2ldOwogICAgICAgICAgICBpZiAoaiA8IDI1OCkgewogICAgICAgICAgICAgIGdseXBoTmFtZXMucHVzaChfZm9udHNfdXRpbHMuTWFjU3RhbmRhcmRHbHlwaE9yZGVyaW5nW2pdKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBnbHlwaE5hbWVzLnB1c2goY3VzdG9tTmFtZXNbaiAtIDI1OF0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDAwMDMwMDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5rbm93bi91bnN1cHBvcnRlZCBwb3N0IHRhYmxlIHZlcnNpb24gIiArIHZlcnNpb24pOwogICAgICAgICAgdmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGlmIChwcm9wZXJ0aWVzT2JqLmRlZmF1bHRFbmNvZGluZykgewogICAgICAgICAgICBnbHlwaE5hbWVzID0gcHJvcGVydGllc09iai5kZWZhdWx0RW5jb2Rpbmc7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwcm9wZXJ0aWVzT2JqLmdseXBoTmFtZXMgPSBnbHlwaE5hbWVzOwogICAgICByZXR1cm4gdmFsaWQ7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkTmFtZVRhYmxlKG5hbWVUYWJsZSkgewogICAgICBjb25zdCBzdGFydCA9IChmb250LnN0YXJ0IHx8IDApICsgbmFtZVRhYmxlLm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbmFtZXMgPSBbW10sIFtdXSwKICAgICAgICByZWNvcmRzID0gW107CiAgICAgIGNvbnN0IGxlbmd0aCA9IG5hbWVUYWJsZS5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IEZPUk1BVF8wX0hFQURFUl9MRU5HVEggPSA2OwogICAgICBpZiAoZm9ybWF0ICE9PSAwIHx8IGxlbmd0aCA8IEZPUk1BVF8wX0hFQURFUl9MRU5HVEgpIHsKICAgICAgICByZXR1cm4gW25hbWVzLCByZWNvcmRzXTsKICAgICAgfQogICAgICBjb25zdCBudW1SZWNvcmRzID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3Qgc3RyaW5nc1N0YXJ0ID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3QgTkFNRV9SRUNPUkRfTEVOR1RIID0gMTI7CiAgICAgIGxldCBpLCBpaTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bVJlY29yZHMgJiYgZm9udC5wb3MgKyBOQU1FX1JFQ09SRF9MRU5HVEggPD0gZW5kOyBpKyspIHsKICAgICAgICBjb25zdCByID0gewogICAgICAgICAgcGxhdGZvcm06IGZvbnQuZ2V0VWludDE2KCksCiAgICAgICAgICBlbmNvZGluZzogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxhbmd1YWdlOiBmb250LmdldFVpbnQxNigpLAogICAgICAgICAgbmFtZTogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxlbmd0aDogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIG9mZnNldDogZm9udC5nZXRVaW50MTYoKQogICAgICAgIH07CiAgICAgICAgaWYgKGlzTWFjTmFtZVJlY29yZChyKSB8fCBpc1dpbk5hbWVSZWNvcmQocikpIHsKICAgICAgICAgIHJlY29yZHMucHVzaChyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChpID0gMCwgaWkgPSByZWNvcmRzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCByZWNvcmQgPSByZWNvcmRzW2ldOwogICAgICAgIGlmIChyZWNvcmQubGVuZ3RoIDw9IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBwb3MgPSBzdGFydCArIHN0cmluZ3NTdGFydCArIHJlY29yZC5vZmZzZXQ7CiAgICAgICAgaWYgKHBvcyArIHJlY29yZC5sZW5ndGggPiBlbmQpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBmb250LnBvcyA9IHBvczsKICAgICAgICBjb25zdCBuYW1lSW5kZXggPSByZWNvcmQubmFtZTsKICAgICAgICBpZiAocmVjb3JkLmVuY29kaW5nKSB7CiAgICAgICAgICBsZXQgc3RyID0gIiI7CiAgICAgICAgICBmb3IgKGxldCBqID0gMCwgamogPSByZWNvcmQubGVuZ3RoOyBqIDwgamo7IGogKz0gMikg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TEsIC0xLCAtMl07CiAgICBmdW5jdGlvbiBzYW5pdGl6ZVRUUHJvZ3JhbSh0YWJsZSwgdHRDb250ZXh0KSB7CiAgICAgIGxldCBkYXRhID0gdGFibGUuZGF0YTsKICAgICAgbGV0IGkgPSAwLAogICAgICAgIGosCiAgICAgICAgbiwKICAgICAgICBiLAogICAgICAgIGZ1bmNJZCwKICAgICAgICBwYywKICAgICAgICBsYXN0RW5kZiA9IDAsCiAgICAgICAgbGFzdERlZmYgPSAwOwogICAgICBjb25zdCBzdGFjayA9IFtdOwogICAgICBjb25zdCBjYWxsc3RhY2sgPSBbXTsKICAgICAgY29uc3QgZnVuY3Rpb25zQ2FsbGVkID0gW107CiAgICAgIGxldCB0b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMgPSB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBsZXQgaW5GREVGID0gZmFsc2UsCiAgICAgICAgaWZMZXZlbCA9IDAsCiAgICAgICAgaW5FTFNFID0gMDsKICAgICAgZm9yIChsZXQgaWkgPSBkYXRhLmxlbmd0aDsgaSA8IGlpOykgewogICAgICAgIGNvbnN0IG9wID0gZGF0YVtpKytdOwogICAgICAgIGlmIChvcCA9PT0gMHg0MCkgewogICAgICAgICAgbiA9IGRhdGFbaSsrXTsKICAgICAgICAgIGlmIChpbkZERUYgfHwgaW5FTFNFKSB7CiAgICAgICAgICAgIGkgKz0gbjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBzdGFjay5wdXNoKGRhdGFbaSsrXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDQxKSB7CiAgICAgICAgICBuID0gZGF0YVtpKytdOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjApIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjAgKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IG47IGorKykgewogICAgICAgICAgICAgIHN0YWNrLnB1c2goZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjgpIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjggKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmIgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKCFpbkZERUYgJiYgIWluRUxTRSkgewogICAgICAgICAgICBmdW5jSWQgPSBzdGFjay5hdCgtMSk7CiAgICAgICAgICAgIGlmIChpc05hTihmdW5jSWQpKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUVDogQ0FMTCBlbXB0eSBzdGFjayAob3IgaW52YWxpZCBlbnRyeSkuIik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1VzZWRbZnVuY0lkXSA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGZ1bmNJZCBpbiB0dENvbnRleHQuZnVuY3Rpb25zU3RhY2tEZWx0YXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG5ld1N0YWNrTGVuZ3RoID0gc3RhY2subGVuZ3RoICsgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF07CiAgICAgICAgICAgICAgICBpZiAobmV3U3RhY2tMZW5ndGggPCAwKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IENBTEwgaW52YWxpZCBmdW5jdGlvbnMgc3RhY2sgZGVsdGEuIik7CiAgICAgICAgICAgICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YWNrLmxlbmd0aCA9IG5ld1N0YWNrTGVuZ3RoOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoZnVuY0lkIGluIHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkICYmICFmdW5jdGlvbnNDYWxsZWQuaW5jbHVkZXMoZnVuY0lkKSkgewogICAgICAgICAgICAgICAgY2FsbHN0YWNrLnB1c2goewogICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICBpLAogICAgICAgICAgICAgICAgICBzdGFja1RvcDogc3RhY2subGVuZ3RoIC0gMQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbnNDYWxsZWQucHVzaChmdW5jSWQpOwogICAgICAgICAgICAgICAgcGMgPSB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdOwogICAgICAgICAgICAgICAgaWYgKCFwYykgewogICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBDQUxMIG5vbi1leGlzdGVudCBmdW5jdGlvbiIpOwogICAgICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBkYXRhID0gcGMuZGF0YTsKICAgICAgICAgICAgICAgIGkgPSBwYy5pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmMgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogbmVzdGVkIEZERUZzIG5vdCBhbGxvd2VkIik7CiAgICAgICAgICAgIHRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucyA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBpbkZERUYgPSB0cnVlOwogICAgICAgICAgbGFzdERlZmYgPSBpOwogICAgICAgICAgZnVuY0lkID0gc3RhY2sucG9wKCk7CiAgICAgICAgICB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdID0gewogICAgICAgICAgICBkYXRhLAogICAgICAgICAgICBpCiAgICAgICAgICB9OwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmQpIHsKICAgICAgICAgIGlmIChpbkZERUYpIHsKICAgICAgICAgICAgaW5GREVGID0gZmFsc2U7CiAgICAgICAgICAgIGxhc3RFbmRmID0gaTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBjID0gY2FsbHN0YWNrLnBvcCgpOwogICAgICAgICAgICBpZiAoIXBjKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogRU5ERiBiYWQgc3RhY2siKTsKICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jSWQgPSBmdW5jdGlvbnNDYWxsZWQucG9wKCk7CiAgICAgICAgICAgIGRhdGEgPSBwYy5kYXRhOwogICAgICAgICAgICBpID0gcGMuaTsKICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF0gPSBzdGFjay5sZW5ndGggLSBwYy5zdGFja1RvcDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDg5KSB7CiAgICAgICAgICBpZiAoaW5GREVGIHx8IGluRUxTRSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBuZXN0ZWQgSURFRnMgbm90IGFsbG93ZWQiKTsKICAgICAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGluRkRFRiA9IHRydWU7CiAgICAgICAgICBsYXN0RGVmZiA9IGk7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OCkgewogICAgICAgICAgKytpZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWIpIHsKICAgICAgICAgIGluRUxTRSA9IGlmTGV2ZWw7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OSkgewogICAgICAgICAgaWYgKGluRUxTRSA9PT0gaWZMZXZlbCkgewogICAgICAgICAgICBpbkVMU0UgPSAwOwogICAgICAgICAgfQogICAgICAgICAgLS1pZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWMpIHsKICAgICAgICAgIGlmICghaW5GREVGICYmICFpbkVMU0UpIHsKICAgICAgICAgICAgY29uc3Qgb2Zmc2V0ID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICBpZiAob2Zmc2V0ID4gMCkgewogICAgICAgICAgICAgIGkgKz0gb2Zmc2V0IC0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIWluRkRFRiAmJiAhaW5FTFNFKSB7CiAgICAgICAgICBsZXQgc3RhY2tEZWx0YSA9IDA7CiAgICAgICAgICBpZiAob3AgPD0gMHg4ZSkgewogICAgICAgICAgICBzdGFja0RlbHRhID0gVFRPcHNTdGFja0RlbHRhc1tvcF07CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4YzAgJiYgb3AgPD0gMHhkZikgewogICAgICAgICAgICBzdGFja0RlbHRhID0gLTE7CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4ZTApIHsKICAgICAgICAgICAgc3RhY2tEZWx0YSA9IC0yOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG9wID49IDB4NzEgJiYgb3AgPD0gMHg3NSkgewogICAgICAgICAgICBuID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghaXNOYU4obikpIHsKICAgICAgICAgICAgICBzdGFja0RlbHRhID0gLW4gKiAyOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2tEZWx0YSA8IDAgJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgICAgc3RhY2tEZWx0YSsrOwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN0YWNrRGVsdGEgPiAwKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goTmFOKTsKICAgICAgICAgICAgc3RhY2tEZWx0YS0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBjb25zdCBjb250ZW50ID0gW2RhdGFdOwogICAgICBpZiAoaSA+IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgY29udGVudC5wdXNoKG5ldyBVaW50OEFycmF5KGkgLSBkYXRhLmxlbmd0aCkpOwogICAgICB9CiAgICAgIGlmIChsYXN0RGVmZiA+IGxhc3RFbmRmKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogY29tcGxlbWVudGluZyBhIG1pc3NpbmcgZnVuY3Rpb24gdGFpbCIpOwogICAgICAgIGNvbnRlbnQucHVzaChuZXcgVWludDhBcnJheShbMHgyMiwgMHgyZF0pKTsKICAgICAgfQogICAgICBmb2xkVFRUYWJsZSh0YWJsZSwgY29udGVudCk7CiAgICB9CiAgICBmdW5jdGlvbiBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpIHsKICAgICAgaWYgKHR0Q29udGV4dC50b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkLmxlbmd0aCA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IG1vcmUgZnVuY3Rpb25zIGRlZmluZWQgdGhhbiBleHBlY3RlZCIpOwogICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICBpZiAoaiA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogaW52YWxpZCBmdW5jdGlvbiBpZDogIiArIGopOwogICAgICAgICAgdHRDb250ZXh0LmhpbnRzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkW2pdICYmICF0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtqXSkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogdW5kZWZpbmVkIGZ1bmN0aW9uOiAiICsgaik7CiAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gZm9sZFRUVGFibGUodGFibGUsIGNvbnRlbnQpIHsKICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID4gMSkgewogICAgICAgIGxldCBuZXdMZW5ndGggPSAwOwogICAgICAgIGxldCBqLCBqajsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgbmV3TGVuZ3RoICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBuZXdMZW5ndGggPSBuZXdMZW5ndGggKyAzICYgfjM7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkobmV3TGVuZ3RoKTsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgcmVzdWx0LnNldChjb250ZW50W2pdLCBwb3MpOwogICAgICAgICAgcG9zICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICB0YWJsZS5kYXRhID0gcmVzdWx0OwogICAgICAgIHRhYmxlLmxlbmd0aCA9IG5ld0xlbmd0aDsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVUV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ibGVzLmZwZ207CiAgICAgIGRlbGV0ZSB0YWJsZXMucHJlcDsKICAgICAgZGVsZXRlIHRhYmxlc1siY3Z0ICJdOwogICAgICB0aGlzLmlzT3BlblR5cGUgPSB0cnVlOwogICAgfSBlbHNlIHsKICAgICAgaWYgKCF0YWJsZXMubG9jYSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcignUmVxdWlyZWQgImxvY2EiIHRhYmxlIGlzIG5vdCBmb3VuZCcpOwogICAgICB9CiAgICAgIGlmICghdGFibGVzLmdseWYpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoJ1JlcXVpcmVkICJnbHlmIiB0YWJsZSBpcyBub3QgZm91bmQgLS0gdHJ5aW5nIHRvIHJlY292ZXIuJyk7CiAgICAgICAgdGFibGVzLmdseWYgPSB7CiAgICAgICAgICB0YWc6ICJnbHlmIiwKICAgICAgICAgIGRhdGE6IG5ldyBVaW50OEFycmF5KDApCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aGlzLmlzT3BlblR5cGUgPSBmYWxzZTsKICAgIH0KICAgIGlmICghdGFibGVzLm1heHApIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdSZXF1aXJlZCAibWF4cCIgdGFibGUgaXMgbm90IGZvdW5kJyk7CiAgICB9CiAgICBmb250LnBvcyA9IChmb250LnN0YXJ0IHx8IDApICsgdGFibGVzLm1heHAub2Zmc2V0OwogICAgY29uc3QgdmVyc2lvbiA9IGZvbnQuZ2V0SW50MzIoKTsKICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICBpZiAocHJvcGVydGllcy5zY2FsZUZhY3RvcnMgJiYgcHJvcGVydGllcy5zY2FsZUZhY3RvcnMubGVuZ3RoID09PSBudW1HbHlwaHMgJiYgaXNUcnVlVHlwZSkgewogICAgICBjb25zdCB7CiAgICAgICAgc2NhbGVGYWN0b3JzCiAgICAgIH0gPSBwcm9wZXJ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wRW5jb2RpbmdJZCA9PT0gMCkgewogICAgICAgICAgICB1bmljb2RlT3JDaGFyQ29kZSA9IF9lbmNvZGluZ3MuTWFjUm9tYW5FbmNvZGluZy5pbmRleE9mKHN0YW5kYXJkR2x5cGhOYW1lKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh1bmljb2RlT3JDaGFyQ29kZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgIGlmICghcHJvcGVydGllcy5nbHlwaE5hbWVzICYmIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgJiYgISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICAgICAgICBjb25zdCB1bmljb2RlID0gdGhpcy50b1VuaWNvZGUuZ2V0KGNoYXJDb2RlKTsKICAgICAgICAgICAgICBpZiAodW5pY29kZSkgewogICAgICAgICAgICAgICAgdW5pY29kZU9yQ2hhckNvZGUgPSB1bmljb2RlLmNvZGVQb2ludEF0KDApOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodW5pY29kZU9yQ2hhckNvZGUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGNvbnN0IG1hcHBpbmcgb2YgY21hcE1hcHBpbmdzKSB7CiAgICAgICAgICAgIGlmIChtYXBwaW5nLmNoYXJDb2RlICE9PSB1bmljb2RlT3JDaGFyQ29kZSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSA9IG1hcHBpbmcuZ2x5cGhJZDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNtYXB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GF0YTogY3JlYXRlT1MyVGFibGUocHJvcGVydGllcywgbmV3TWFwcGluZy5jaGFyQ29kZVRvR2x5cGhJZCwgbWV0cmljc092ZXJyaWRlKQogICAgICAgIH07CiAgICAgIH0KICAgIH0KICAgIGlmICghaXNUcnVlVHlwZSkgewogICAgICB0cnkgewogICAgICAgIGNmZkZpbGUgPSBuZXcgX3N0cmVhbS5TdHJlYW0odGFibGVzWyJDRkYgIl0uZGF0YSk7CiAgICAgICAgY29uc3QgcGFyc2VyID0gbmV3IF9jZmZfcGFyc2VyLkNGRlBhcnNlcihjZmZGaWxlLCBwcm9wZXJ0aWVzLCBfZm9udHNfdXRpbHMuU0VBQ19BTkFMWVNJU19FTkFCTEVEKTsKICAgICAgICBjZmYgPSBwYXJzZXIucGFyc2UoKTsKICAgICAgICBjZmYuZHVwbGljYXRlRmlyc3RHbHlwaCgpOwogICAgICAgIGNvbnN0IGNvbXBpbGVyID0gbmV3IF9jZmZfcGFyc2VyLkNGRkNvbXBpbGVyKGNmZik7CiAgICAgICAgdGFibGVzWyJDRkYgIl0uZGF0YSA9IGNvbXBpbGVyLmNvbXBpbGUoKTsKICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiRmFpbGVkIHRvIGNvbXBpbGUgZm9udCAiICsgcHJvcGVydGllcy5sb2FkZWROYW1lKTsKICAgICAgfQogICAgfQogICAgaWYgKCF0YWJsZXMubmFtZSkgewogICAgICB0YWJsZXMubmFtZSA9IHsKICAgICAgICB0YWc6ICJuYW1lIiwKICAgICAgICBkYXRhOiBjcmVhdGVOYW1lVGFibGUodGhpcy5uYW1lKQogICAgICB9OwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgW25hbWVQcm90b3R5cGUsIG5hbWVSZWNvcmRzXSA9IHJlYWROYW1lVGFibGUodGFibGVzLm5hbWUpOwogICAgICB0YWJsZXMubmFtZS5kYXRhID0gY3JlYXRlTmFtZVRhYmxlKG5hbWUsIG5hbWVQcm90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UV4dHJhTWFwID0gbnVsbDsKICAgIGlmICghcHJvcGVydGllcy5jc3NGb250SW5mbykgewogICAgICBuZXdNYXBwaW5nID0gYWRqdXN0TWFwcGluZyhtYXBwaW5nLCBmb250Lmhhc0dseXBoSWQuYmluZChmb250KSwgZ2x5cGhaZXJvSWQsIHRoaXMudG9Vbmljb2RlKTsKICAgICAgdGhpcy50b0ZvbnRDaGFyID0gbmV3TWFwcGluZy50b0ZvbnRDaGFyOwogICAgICBuZXdDaGFyQ29kZVRvR2x5cGhJZCA9IG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWQ7CiAgICAgIHRvVW5pY29kZUV4dHJhTWFwID0gbmV3TWFwcGluZy50b1VuaWNvZGVFeHRyYU1hcDsKICAgIH0KICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQubnVtR2x5cGhzOwogICAgZnVuY3Rpb24gZ2V0Q2hhckNvZGVzKGNoYXJDb2RlVG9HbHlwaElkLCBnbHlwaElkKSB7CiAgICAgIGxldCBjaGFyQ29kZXMgPSBudWxsOwogICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIGluIGNoYXJDb2RlVG9HbHlwaElkKSB7CiAgICAgICAgaWYgKGdseXBoSWQgPT09IGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSkgewogICAgICAgICAgaWYgKCFjaGFyQ29kZXMpIHsKICAgICAgICAgICAgY2hhckNvZGVzID0gW107CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZXMucHVzaChjaGFyQ29kZSB8IDApOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gY2hhckNvZGVzOwogICAgfQogICAgZnVuY3Rpb24gY3JlYXRlQ2hhckNvZGUoY2hhckNvZGVUb0dseXBoSWQsIGdseXBoSWQpIHsKICAgICAgZm9yIChjb25zdCBjaGFyQ29kZSBpbiBjaGFyQ29kZVRvR2x5cGhJZCkgewogICAgICAgIGlmIChnbHlwaElkID09PSBjaGFyQ29kZVRvR2x5c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hbWUpOwogICAgICAgIGlmIChiYXNlR2x5cGhJZCA8IDAgfHwgYWNjZW50R2x5cGhJZCA8IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBhY2NlbnRPZmZzZXQgPSB7CiAgICAgICAgICB4OiBzZWFjWzBdICogbWF0cml4WzBdICsgc2VhY1sxXSAqIG1hdHJpeFsyXSArIG1hdHJpeFs0XSwKICAgICAgICAgIHk6IHNlYWNbMF0gKiBtYXRyaXhbMV0gKyBzZWFjWzFdICogbWF0cml4WzNdICsgbWF0cml4WzVdCiAgICAgICAgfTsKICAgICAgICBjb25zdCBjaGFyQ29kZXMgPSBnZXRDaGFyQ29kZXMobWFwcGluZywgZ2x5cGhJZCk7CiAgICAgICAgaWYgKCFjaGFyQ29kZXMpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIG9mIGNoYXJDb2RlcykgewogICAgICAgICAgY29uc3QgY2hhckNvZGVUb0dseXBoSWQgPSBuZXdNYXBwaW5nLmNoYXJDb2RlVG9HbHlwaElkOwogICAgICAgICAgY29uc3QgYmFzZUZvbnRDaGFyQ29kZSA9IGNyZWF0ZUNoYXJDb2RlKGNoYXJDb2RlVG9HbHlwaElkLCBiYXNlR2x5cGhJZCk7CiAgICAgICAgICBjb25zdCBhY2NlbnRGb250Q2hhckNvZGUgPSBjcmVhdGVDaGFyQ29kZShjaGFyQ29kZVRvR2x5cGhJZCwgYWNjZW50R2x5cGhJZCk7CiAgICAgICAgICBzZWFjTWFwW2NoYXJDb2RlXSA9IHsKICAgICAgICAgICAgYmFzZUZvbnRDaGFyQ29kZSwKICAgICAgICAgICAgYWNjZW50Rm9udENoYXJDb2RlLAogICAgICAgICAgICBhY2NlbnRPZmZzZXQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIHByb3BlcnRpZXMuc2VhY01hcCA9IHNlYWNNYXA7CiA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weDIwKTsKICAgICAgICBnbHlwaHMucHVzaChnbHlwaCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLl9jaGFyc0NhY2hlW2NoYXJzXSA9IGdseXBoczsKICB9CiAgZ2V0Q2hhclBvc2l0aW9ucyhjaGFycykgewogICAgY29uc3QgcG9zaXRpb25zID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgY2hhcnMubGVuZ3RoKSB7CiAgICAgICAgdGhpcy5jTWFwLnJlYWRDaGFyQ29kZShjaGFycywgaSwgYyk7CiAgICAgICAgY29uc3QgbGVuZ3RoID0gYy5sZW5ndGg7CiAgICAgICAgcG9zaXRpb25zLnB1c2goW2ksIGkgKyBsZW5ndGhdKTsKICAgICAgICBpICs9IGxlbmd0aDsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2hhcnMubGVuZ3RoOyBpIDwgaWk7ICsraSkgewogICAgICAgIHBvc2l0aW9ucy5wdXNoKFtpLCBpICsgMV0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zaXRpb25zOwogIH0KICBnZXQgZ2x5cGhDYWNoZVZhbHVlcygpIHsKICAgIHJldHVybiBPYmplY3QudmFsdWVzKHRoaXMuX2dseXBoQ2FjaGUpOwogIH0KICBlbmNvZGVTdHJpbmcoc3RyKSB7CiAgICBjb25zdCBidWZmZXJzID0gW107CiAgICBjb25zdCBjdXJyZW50QnVmID0gW107CiAgICBjb25zdCBoYXNDdXJyZW50QnVmRXJyb3JzID0gKCkgPT4gYnVmZmVycy5sZW5ndGggJSAyID09PSAxOwogICAgY29uc3QgZ2V0Q2hhckNvZGUgPSB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCA/IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZih1bmljb2RlKSA6IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZihTdHJpbmcuZnJvbUNvZGVQb2ludCh1bmljb2RlKSk7CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBzdHIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICBjb25zdCB1bmljb2RlID0gc3RyLmNvZGVQb2ludEF0KGkpOwogICAgICBpZiAodW5pY29kZSA+IDB4ZDdmZiAmJiAodW5pY29kZSA8IDB4ZTAwMCB8fCB1bmljb2RlID4gMHhmZmZkKSkgewogICAgICAgIGkrKzsKICAgICAgfQogICAgICBpZiAodGhpcy50b1VuaWNvZGUpIHsKICAgICAgICBjb25zdCBjaGFyQ29kZSA9IGdldENoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGlmIChjaGFyQ29kZSAhPT0gLTEpIHsKICAgICAgICAgIGlmIChoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICAgICAgYnVmZmVycy5wdXNoKGN1cnJlbnRCdWYuam9pbigiIikpOwogICAgICAgICAgICBjdXJyZW50QnVmLmxlbmd0aCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjaGFyQ29kZUxlbmd0aCA9IHRoaXMuY01hcCA/IHRoaXMuY01hcC5nZXRDaGFyQ29kZUxlbmd0aChjaGFyQ29kZSkgOiAxOwogICAgICAgICAgZm9yIChsZXQgaiA9IGNoYXJDb2RlTGVuZ3RoIC0gMTsgaiA+PSAwOyBqLS0pIHsKICAgICAgICAgICAgY3VycmVudEJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoY2hhckNvZGUgPj4gOCAqIGogJiAweGZmKSk7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFoYXNDdXJyZW50QnVmRXJyb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Bsb29rdXBbYjJdOwogICAgICB9CiAgICAgIHJldHVybiBwYXJzZUZsb2F0KHN0cik7CiAgICB9CiAgICBsZXQgb3BlcmFuZHMgPSBbXTsKICAgIGNvbnN0IGVudHJpZXMgPSBbXTsKICAgIHBvcyA9IDA7CiAgICBjb25zdCBlbmQgPSBkaWN0Lmxlbmd0aDsKICAgIHdoaWxlIChwb3MgPCBlbmQpIHsKICAgICAgbGV0IGIgPSBkaWN0W3Bvc107CiAgICAgIGlmIChiIDw9IDIxKSB7CiAgICAgICAgaWYgKGIgPT09IDEyKSB7CiAgICAgICAgICBiID0gYiA8PCA4IHwgZGljdFsrK3Bvc107CiAgICAgICAgfQogICAgICAgIGVudHJpZXMucHVzaChbYiwgb3BlcmFuZHNdKTsKICAgICAgICBvcGVyYW5kcyA9IFtdOwogICAgICAgICsrcG9zOwogICAgICB9IGVsc2UgewogICAgICAgIG9wZXJhbmRzLnB1c2gocGFyc2VPcGVyYW5kKCkpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW50cmllczsKICB9CiAgcGFyc2VJbmRleChwb3MpIHsKICAgIGNvbnN0IGNmZkluZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBjb25zdCBieXRlcyA9IHRoaXMuYnl0ZXM7CiAgICBjb25zdCBjb3VudCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgY29uc3Qgb2Zmc2V0cyA9IFtdOwogICAgbGV0IGVuZCA9IHBvczsKICAgIGxldCBpLCBpaTsKICAgIGlmIChjb3VudCAhPT0gMCkgewogICAgICBjb25zdCBvZmZzZXRTaXplID0gYnl0ZXNbcG9zKytdOwogICAgICBjb25zdCBzdGFydFBvcyA9IHBvcyArIChjb3VudCArIDEpICogb2Zmc2V0U2l6ZSAtIDE7CiAgICAgIGZvciAoaSA9IDAsIGlpID0gY291bnQgKyAxOyBpIDwgaWk7ICsraSkgewogICAgICAgIGxldCBvZmZzZXQgPSAwOwogICAgICAgIGZ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DE2IHwgZGF0YVtqICsgMl0gPDwgOCB8IGRhdGFbaiArIDNdKSAvIDY1NTM2OwogICAgICAgIGogKz0gNDsKICAgICAgICBzdGFja1NpemUrKzsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMTkgfHwgdmFsdWUgPT09IDIwKSB7CiAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgaiArPSBzdGF0ZS5oaW50cyArIDcgPj4gMzsKICAgICAgICBzdGFja1NpemUgJT0gMjsKICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPT09IDEwIHx8IHZhbHVlID09PSAyOSkgewogICAgICAgIGxldCBzdWJyc0luZGV4OwogICAgICAgIGlmICh2YWx1ZSA9PT0gMTApIHsKICAgICAgICAgIHN1YnJzSW5kZXggPSBsb2NhbFN1YnJJbmRleDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3VicnNJbmRleCA9IGdsb2JhbFN1YnJJbmRleDsKICAgICAgICB9CiAgICAgICAgaWYgKCFzdWJyc0luZGV4KSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk1pc3Npbmcgc3VicnNJbmRleCBmb3IgIiArIHZhbGlkYXRpb25Db21tYW5kLmlkKTsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgbGV0IGJpYXMgPSAzMjc2ODsKICAgICAgICBpZiAoc3VicnNJbmRleC5jb3VudCA8IDEyNDApIHsKICAgICAgICAgIGJpYXMgPSAxMDc7CiAgICAgICAgfSBlbHNlIGlmIChzdWJyc0luZGV4LmNvdW50IDwgMzM5MDApIHsKICAgICAgICAgIGJpYXMgPSAxMTMxOwogICAgICAgIH0KICAgICAgICBjb25zdCBzdWJyTnVtYmVyID0gc3RhY2tbLS1zdGFja1NpemVdICsgYmlhczsKICAgICAgICBpZiAoc3Vick51bWJlciA8IDAgfHwgc3Vick51bWJlciA+PSBzdWJyc0luZGV4LmNvdW50IHx8IGlzTmFOKHN1YnJOdW1iZXIpKSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk91dCBvZiBib3VuZHMgc3VickluZGV4IGZvciAiICsgdmFsaWRhdGlvbkNvbW1hbmQuaWQpOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5zdGFja1NpemUgPSBzdGFja1NpemU7CiAgICAgICAgc3RhdGUuY2FsbERlcHRoKys7CiAgICAgICAgY29uc3QgdmFsaWQgPSB0aGlzLnBhcnNlQ2hhclN0cmluZyhzdGF0ZSwgc3VicnNJbmRleC5nZXQoc3Vick51bWJlciksIGxvY2FsU3VickluZGV4LCBnbG9iYWxTdWJySW5kZXgpOwogICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgc3RhdGUuY2FsbERlcHRoLS07CiAgICAgICAgc3RhY2tTaXplID0gc3RhdGUuc3RhY2tTaXplOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSAxMSkgewogICAgICAgIHN0YXRlLnN0YWNrU2l6ZSA9IHN0YWNrU2l6ZTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMCAmJiBqID09PSBkYXRhLmxlbmd0aCkgewogICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgdmFsaWRhdGlvbkNvbW1hbmQgPSBDaGFyc3RyaW5nVmFsaWRhdGlvbkRhdGFbMTRdOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSA5KSB7CiAgICAgICAgZGF0YS5jb3B5V2l0aGluKGogLSAxLCBqLCAtMSk7CiAgICAgICAgaiAtPSAxOwogICAgICAgIGxlbmd0aCAtPSAxOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHZhbGlkYXRpb25Db21tYW5kID0gQ2hhcnN0cmluZ1ZhbGlkYXRpb25EYXRhW3ZhbHVlXTsKICAgICAgfQogICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQuc3RlbSkgewogICAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgICBpZiAodmFsdWUgPT09IDMgfHwgdmFsdWUgPT09IDIzKSB7CiAgICAgICAgICAgIHN0YXRlLmhhc1ZTdGVtcyA9IHRydWU7CiAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlLmhhc1ZTdGVtcyAmJiAodmFsdWUgPT09IDEgfHwgdmFsdWUgPT09IDE4KSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkNGRiBzdGVtIGhpbnRzIGFyZSBpbiB3cm9uZyBvcmRlciIpOwogICAgICAgICAgICBkYXRhW2ogLSAxXSA9IHZhbHVlID09PSAxID8gMyA6IDIzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIm1pbiIgaW4gdmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICAgIGlmICghc3RhdGUudW5kZWZTdGFjayAmJiBzdGFja1NpemUgPCB2YWxpZGF0aW9uQ29tbWFuZC5taW4pIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJOb3QgZW5vdWdoIHBhcmFtZXRlcnMgZm9yICIgKyB2YWxpZGF0aW9uQ29tbWFuZC5pZCArICI7IGFjdHVhbDogIiArIHN0YWNrU2l6ZSArICIsIGV4cGVjdGVkOiAiICsgdmFsaWRhdGlvbkNvbW1hbmQubWluKTsKICAgICAgICAgICAgaWYgKHN0YWNrU2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUuZmlyc3RTdGFja0NsZWFyaW5nICYmIHZhbGlkYXRpb25Db21tYW5kLnN0YWNrQ2xlYXJpbmcpIHsKICAgICAgICAgIHN0YXRlLmZpcnN0U3RhY2tDbGVhcmluZyA9IGZhbHNlOwogICAgICAgICAgc3RhY2tTaXplIC09IHZhbGlkYXRpb25Db21tYW5kLm1pbjsKICAgICAgICAgIGlmIChzdGFja1NpemUgPj0gMiAmJiB2YWxpZGF0aW9uQ29tbWFuZC5zdGVtKSB7CiAgICAgICAgICAgIHN0YWNrU2l6ZSAlPSAyOwogICAgICAgICAgfSBlbHNlIGlmIChzdGFja1NpemUgPiAxKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRm91bmQgdG9vIG1hbnkgcGFyYW1ldGVycyBmb3Igc3RhY2stY2xlYXJpbmcgY29tbWFuZCIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0YWNrU2l6ZSA+IDApIHsKICAgICAgICAgICAgc3RhdGUud2lkdGggPSBzdGFja1tzdGFja1NpemUgLSAxXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKCJzdGFja0RlbHRhIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgaWYgKCJzdGFja0ZuIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZC5zdGFja0ZuKHN0YWNrLCBzdGFja1NpemUpOwogICAgICAgICAgfQogICA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RyaW5nID0gY2hhclN0cmluZ3MuZ2V0KGkpOwogICAgICBjb25zdCBzdGF0ZSA9IHsKICAgICAgICBjYWxsRGVwdGg6IDAsCiAgICAgICAgc3RhY2tTaXplOiAwLAogICAgICAgIHN0YWNrOiBbXSwKICAgICAgICB1bmRlZlN0YWNrOiB0cnVlLAogICAgICAgIGhpbnRzOiAwLAogICAgICAgIGZpcnN0U3RhY2tDbGVhcmluZzogdHJ1ZSwKICAgICAgICBzZWFjOiBudWxsLAogICAgICAgIHdpZHRoOiBudWxsLAogICAgICAgIGhhc1ZTdGVtczogZmFsc2UKICAgICAgfTsKICAgICAgbGV0IHZhbGlkID0gdHJ1ZTsKICAgICAgbGV0IGxvY2FsU3ViclRvVXNlID0gbnVsbDsKICAgICAgbGV0IHByaXZhdGVEaWN0VG9Vc2UgPSBwcml2YXRlRGljdDsKICAgICAgaWYgKGZkU2VsZWN0ICYmIGZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgY29uc3QgZmRJbmRleCA9IGZkU2VsZWN0LmdldEZESW5kZXgoaSk7CiAgICAgICAgaWYgKGZkSW5kZXggPT09IC0xKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkdseXBoIGluZGV4IGlzIG5vdCBpbiBmZCBzZWxlY3QuIik7CiAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgIH0KICAgICAgICBpZiAoZmRJbmRleCA+PSBmZEFycmF5Lmxlbmd0aCkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZGV4IGZvciBnbHlwaCBpbmRleC4iKTsKICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGlmICh2YWxpZCkgewogICAgICAgICAgcHJpdmF0ZURpY3RUb1VzZSA9IGZkQXJyYXlbZmRJbmRleF0ucHJpdmF0ZURpY3Q7CiAgICAgICAgICBsb2NhbFN1YnJUb1VzZSA9IHByaXZhdGVEaWN0VG9Vc2Uuc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bnN0IGNvZGUgPSBieXRlc1twb3MrK107CiAgICAgICAgY29uc3Qgc2lkID0gKGJ5dGVzW3BvcysrXSA8PCA4KSArIChieXRlc1twb3MrK10gJiAweGZmKTsKICAgICAgICBlbmNvZGluZ1tjb2RlXSA9IGNoYXJzZXQuaW5kZXhPZihzdHJpbmdzLmdldChzaWQpKTsKICAgICAgfQogICAgfQogICAgaWYgKHBvcyA9PT0gMCB8fCBwb3MgPT09IDEpIHsKICAgICAgcHJlZGVmaW5lZCA9IHRydWU7CiAgICAgIGZvcm1hdCA9IHBvczsKICAgICAgY29uc3QgYmFzZUVuY29kaW5nID0gcG9zID8gX2VuY29kaW5ncy5FeHBlcnRFbmNvZGluZyA6IF9lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZzsKICAgICAgZm9yIChpID0gMCwgaWkgPSBjaGFyc2V0Lmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCBpbmRleCA9IGJhc2VFbmNvZGluZy5pbmRleE9mKGNoYXJzZXRbaV0pOwogICAgICAgIGlmIChpbmRleCAhPT0gLTEpIHsKICAgICAgICAgIGVuY29kaW5nW2luZGV4XSA9IGk7CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhU3RhcnQgPSBwb3M7CiAgICAgIGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgICAgc3dpdGNoIChmb3JtYXQgJiAweDdmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgY29uc3QgZ2x5cGhzQ291bnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICBmb3IgKGkgPSAxOyBpIDw9IGdseXBoc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgZW5jb2RpbmdbYnl0ZXNbcG9zKytdXSA9IGk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDE6CiAgICAgICAgICBjb25zdCByYW5nZXNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGxldCBnaWQgPSAxOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJhbmdlc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc3RhcnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGNvbnN0IGxlZnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGZvciAobGV0IGogPSBzdGFydDsgaiA8PSBzdGFydCArIGxlZnQ7IGorKykgewogICAgICAgICAgICAgIGVuY29kaW5nW2pdID0gZ2lkKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVua25vd24gZW5jb2RpbmcgZm9ybWF0OiAke2Zvcm1hdH0gaW4gQ0ZGYCk7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUVuZCA9IHBvczsKICAgICAgaWYgKGZvcm1hdCAmIDB4ODApIHsKICAgICAgICBieXRlc1tkYXRhU3RhcnRdICY9IDB4N2Y7CiAgICAgICAgcmVhZFN1cHBsZW1lbnQoKTsKICAgICAgfQogICAgICByYXcgPSBieXRlcy5zdWJhcnJheShkYXRhU3RhcnQsIGRhdGFFbmQpOwogICAgfQogICAgZm9ybWF0ICY9IDB4N2Y7CiAgICByZXR1cm4gbmV3IENGRkVuY29kaW5nKHByZWRlZmluZWQsIGZvcm1hdCwgZW5jb2RpbmcsIHJhdyk7CiAgfQogIHBhcnNlRkRTZWxlY3QocG9zLCBsZW5ndGgpIHsKICAgIGNvbnN0IGJ5dGVzID0gdGhpcy5ieXRlczsKICAgIGNvbnN0IGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgIGNvbnN0IGZkU2VsZWN0ID0gW107CiAgICBsZXQgaTsKICAgIHN3aXRjaCAoZm9ybWF0KSB7CiAgICAgIGNhc2UgMDoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGNvbnN0IGlkID0gYnl0ZXNbcG9zKytdOwogICAgICAgICAgZmRTZWxlY3QucHVzaChpZCk7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDM6CiAgICAgICAgY29uc3QgcmFuZ2VzQ291bnQgPSBieXRlc1twb3MrK10gPDwgOCB8IGJ5dGVzW3BvcysrXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcmFuZ2VzQ291bnQ7ICsraSkgewogICAgICAgICAgbGV0IGZpcnN0ID0gYnl0ZXNbcG9zKytdIDw8IDggfCBieXRlc1twb3MrK107CiAgICAgICAgICBpZiAoaSA9PT0gMCAmJiBmaXJzdCAhPT0gMCkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoInBhcnNlRkRTZWxlY3Q6IFRoZSBmaXJzdCByYW5nZSBtdXN0IGhhdmUgYSBmaXJzdCBHSUQgb2YgMCIgKyAiIC0tIHRyeWluZyB0byByZWNvdmVyLiIpOwogICAgICAgICAgICBmaXJzdCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBmZEluZGV4ID0gYnl0ZXNbcG9zKytdOwogICAgICAgICAgY29uc3QgbmV4dCA9IGJ5dGVzW3Bvc10gPDwgOCB8IGJ5dGVzW3BvcyArIDFdOwogICAgICAgICAgZm9yIChsZXQgaiA9IGZpcnN0OyBqIDwgbmV4dDsgKytqKSB7CiAgICAgICAgICAgIGZkU2VsZWN0LnB1c2goZmRJbmRleCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHBvcyArPSAyOwogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgcGFyc2VGRFNlbGVjdDogVW5rbm93biBmb3JtYXQgIiR7Zm9ybWF0fSIuYCk7CiAgICB9CiAgICBpZiAoZmRTZWxlY3QubGVuZ3RoICE9PSBsZW5ndGg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pIHsKICAgICAgICBmb250RGljdC5yZW1vdmVCeU5hbWUoIkNJREZvbnRWZXJzaW9uIik7CiAgICAgICAgZm9udERpY3QucmVtb3ZlQnlOYW1lKCJDSURGb250UmV2aXNpb24iKTsKICAgICAgICBmb250RGljdC5yZW1vdmVCeU5hbWUoIkNJREZvbnRUeXBlIik7CiAgICAgICAgZm9udERpY3QucmVtb3ZlQnlOYW1lKCJDSURDb3VudCIpOwogICAgICAgIGZvbnREaWN0LnJlbW92ZUJ5TmFtZSgiVUlEQmFzZSIpOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnREaWN0VHJhY2tlciA9IG5ldyBDRkZPZmZzZXRUcmFja2VyKCk7CiAgICAgIGNvbnN0IGZvbnREaWN0RGF0YSA9IHRoaXMuY29tcGlsZURpY3QoZm9udERpY3QsIGZvbnREaWN0VHJhY2tlcik7CiAgICAgIGZvbnREaWN0VHJhY2tlcnMucHVzaChmb250RGljdFRyYWNrZXIpOwogICAgICBmZEFycmF5SW5kZXguYWRkKGZvbnREaWN0RGF0YSk7CiAgICAgIGZvbnREaWN0VHJhY2tlci5vZmZzZXQobGVuZ3RoKTsKICAgIH0KICAgIGZkQXJyYXlJbmRleCA9IHRoaXMuY29tcGlsZUluZGV4KGZkQXJyYXlJbmRleCwgZm9udERpY3RUcmFja2Vycyk7CiAgICByZXR1cm4gewogICAgICB0cmFja2VyczogZm9udERpY3RUcmFja2VycywKICAgICAgb3V0cHV0OiBmZEFycmF5SW5kZXgKICAgIH07CiAgfQogIGNvbXBpbGVQcml2YXRlRGljdHMoZGljdHMsIHRyYWNrZXJzLCBvdXRwdXQpIHsKICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRpY3RzLmxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgZm9udERpY3QgPSBkaWN0c1tpXTsKICAgICAgY29uc3QgcHJpdmF0ZURpY3QgPSBmb250RGljdC5wcml2YXRlRGljdDsKICAgICAgaWYgKCFwcml2YXRlRGlj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CBvZmZzZXRUcmFja2VyKSB7CiAgICBjb25zdCBvdXQgPSBbXTsKICAgIGZvciAoY29uc3Qga2V5IG9mIGRpY3Qub3JkZXIpIHsKICAgICAgaWYgKCEoa2V5IGluIGRpY3QudmFsdWVzKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCB2YWx1ZXMgPSBkaWN0LnZhbHVlc1trZXldOwogICAgICBsZXQgdHlwZXMgPSBkaWN0LnR5cGVzW2tleV07CiAgICAgIGlmICghQXJyYXkuaXNBcnJheSh0eXBlcykpIHsKICAgICAgICB0eXBlcyA9IFt0eXBlc107CiAgICAgIH0KICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHZhbHVlcykpIHsKICAgICAgICB2YWx1ZXMgPSBbdmFsdWVzXTsKICAgICAgfQogICAgICBpZiAodmFsdWVzLmxlbmd0aCA9PT0gMCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR5cGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBjb25zdCB0eXBlID0gdHlwZXNbal07CiAgICAgICAgY29uc3QgdmFsdWUgPSB2YWx1ZXNbal07CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlICJudW0iOgogICAgICAgICAgY2FzZSAic2lkIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJvZmZzZXQiOgogICAgICAgICAgICBjb25zdCBuYW1lID0gZGljdC5rZXlUb05hbWVNYXBba2V5XTsKICAgICAgICAgICAgaWYgKCFvZmZzZXRUcmFja2VyLmlzVHJhY2tpbmcobmFtZSkpIHsKICAgICAgICAgICAgICBvZmZzZXRUcmFja2VyLnRyYWNrKG5hbWUsIG91dC5sZW5ndGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG91dC5wdXNoKDB4MWQsIDAsIDAsIDAsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgImFycmF5IjoKICAgICAgICAgIGNhc2UgImRlbHRhIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDEsIGtrID0gdmFsdWVzLmxlbmd0aDsgayA8IGtrOyArK2spIHsKICAgICAgICAgICAgICBvdXQucHVzaCguLi50aGlzLmVuY29kZU51bWJlcih2YWx1ZXNba10pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5rbm93biBkYXRhIHR5cGUgb2YgJHt0eXBlfWApOwogICAgICAgIH0KICAgICAgfQogICAgICBvdXQucHVzaCguLi5kaWN0Lm9wY29kZXNba2V5XSk7CiAgICB9CiAgICByZXR1cm4gb3V0OwogIH0KICBjb21waWxlU3RyaW5nSW5kZXgoc3RyaW5ncykgewogICAgY29uc3Qgc3RyaW5nSW5kZXggPSBuZXcgQ0ZGSW5kZXgoKTsKICAgIGZvciAoY29uc3Qgc3RyaW5nIG9mIHN0cmluZ3MpIHsKICAgICAgc3RyaW5nSW5kZXguYWRkKCgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShzdHJpbmcpKTsKICAgIH0KICAgIHJldHVybiB0aGlzLmNvbXBpbGVJbmRleChzdHJpbmdJbmRleCk7CiAgfQogIGNvbXBpbGVHbG9iYWxTdWJySW5kZXgoKSB7CiAgICBjb25zdCBnbG9iYWxTdWJySW5kZXggPSB0aGlzLmNmZi5nbG9iYWxTdWJySW5kZXg7CiAgICB0aGlzLm91dC53cml0ZUJ5dGVBcnJheSh0aGlzLmNvbXBpbGVJbmRleChnbG9iYWxTdWJySW5kZXgpKTsKICB9CiAgY29tcGlsZUNoYXJTdHJpbmdzKGNoYXJTdHJpbmdzKSB7CiAgICBjb25zdCBjaGFyU3RyaW5nc0luZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNoYXJTdHJpbmdzLmNvdW50OyBpKyspIHsKICAgICAgY29uc3QgZ2x5cGggPSBjaGFyU3RyaW5ncy5nZXQoaSk7CiAgICAgIGlmIChnbHlwaC5sZW5ndGggPT09IDApIHsKICAgICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChuZXcgVWludDhBcnJheShbMHg4YiwgMHgwZV0pKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChnbHlwaCk7CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlSW5kZXgoY2hhclN0cmluZ3NJbmRleCk7CiAgfQogIGNvbXBpbGVDaGFyc2V0KGNoYXJzZXQsIG51bUdseXBocywgc3RyaW5ncywgaXNDSURGb250KSB7CiAgICBsZXQgb3V0OwogICAgY29uc3QgbnVtR2x5cGhzTGVzc05vdERlZiA9IG51bUdseXBocyAtIDE7CiAgICBpZiAoaXNDSURGb250KSB7CiAgICAgIG91dCA9IG5ldyBVaW50OEFycmF5KFsyLCAwLCAwLCBudW1HbHlwaHNMZXNzTm90RGVmID4+IDggJiAweGZmLCBudW1HbHlwaHNMZXNzTm90RGVmICYgMHhmZl0pOwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgbGVuZ3RoID0gMSArIG51bUdseXBoc0xlc3NOb3REZWYgKiAyOwogICAgICBvdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgICBvdXRbMF0gPSAwOwogICAgICBsZXQgY2hhcnNldEluZGV4ID0gMDsKICAgICAgY29uc3QgbnVtQ2hhcnNldHMgPSBjaGFyc2V0LmNoYXJzZXQubGVuZ3RoOwogICAgICBsZXQgd2FybmVkID0gZmFsc2U7CiAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgb3V0Lmxlbmd0aDsgaSArPSAyKSB7CiAgICAgICAgbGV0IHNpZCA9IDA7CiAgICAgICAgaWYgKGNoYXJzZXRJbmRleCA8IG51bUNoYXJzZXRzKSB7CiAgICAgICAgICBjb25zdCBuYW1lID0gY2hhcnNldC5jaGFyc2V0W2NoYXJzZXRJbmRleCsrXTsKICAgICAgICAgIHNpZCA9IHN0cmluZ3MuZ2V0U0lEKG5hbWUpOwogICAgICAgICAgaWYgKHNpZCA9PT0gLTEpIHsKICAgICAgICAgICAgc2lkID0gMDsKICAgICAgICAgICAgaWYgKCF3YXJuZWQpIHsKICAgICAgICAgICAgICB3YXJuZWQgPSB0cnVlOwogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQ291bGRuJ3QgZmluZCAke25hbWV9IGluIENGRiBzdHJpbmdzYCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0W2ldID0gc2lkID4+IDggJiAweGZmOwogICAgICAgIG91dFtpICsgMV0gPSBzaWQgJiAweGZmOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlVHlwZWRBcnJheShvdXQpOwogIH0KICBjb21waWxlRW5jb2RpbmcoZW5jb2RpbmcpIHsKICAgIHJldHVybiB0aGlzLmNvbXBpbGVUeXBlZEFycmF5KGVuY29kaW5nLnJhdyk7CiAgfQogIGNvbXBpbGVGRFNlbGVjdChmZFNlbGVjdCkgewogICAgY29uc3QgZm9ybWF0ID0gZmRTZWxlY3QuZm9ybWF0OwogICAgbGV0IG91dCwgaTsKICAgIHN3aXRjaCAoZm9ybWF0KSB7CiAgICAgIGNhc2UgMDoKICAgICAgICBvdXQgPSBuZXcgVWludDhBcnJheSgxICsgZmRTZWxlY3QuZmRTZWxlY3QubGVuZ3RoKTsKICAgICAgICBvdXRbMF0gPSBmb3JtYXQ7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IGZkU2VsZWN0LmZkU2VsZWN0Lmxlbm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WFhcm1lbmlhbiIsCiAgMHgwNTVkLAogICJjb21tYWluZmVyaW9yIiwKICAweGY2ZTEsCiAgImNvbW1hbW9ub3NwYWNlIiwKICAweGZmMGMsCiAgImNvbW1hcmV2ZXJzZWRhYm92ZWNtYiIsCiAgMHgwMzE0LAogICJjb21tYXJldmVyc2VkbW9kIiwKICAweDAyYmQsCiAgImNvbW1hc21hbGwiLAogIDB4ZmU1MCwKICAiY29tbWFzdXBlcmlvciIsCiAgMHhmNmUyLAogICJjb21tYXR1cm5lZGFib3ZlY21iIiwKICAweDAzMTIsCiAgImNvbW1hdHVybmVkbW9kIiwKICAweDAyYmIsCiAgImNvbXBhc3MiLAogIDB4MjYzYywKICAiY29uZ3J1ZW50IiwKICAweDIyNDUsCiAgImNvbnRvdXJpbnRlZ3JhbCIsCiAgMHgyMjJlLAogICJjb250cm9sIiwKICAweDIzMDMsCiAgImNvbnRyb2xBQ0siLAogIDB4MDAwNiwKICAiY29udHJvbEJFTCIsCiAgMHgwMDA3LAogICJjb250cm9sQlMiLAogIDB4MDAwOCwKICAiY29udHJvbENBTiIsCiAgMHgwMDE4LAogICJjb250cm9sQ1IiLAogIDB4MDAwZCwKICAiY29udHJvbERDMSIsCiAgMHgwMDExLAogICJjb250cm9sREMyIiwKICAweDAwMTIsCiAgImNvbnRyb2xEQzMiLAogIDB4MDAxMywKICAiY29udHJvbERDNCIsCiAgMHgwMDE0LAogICJjb250cm9sREVMIiwKICAweDAwN2YsCiAgImNvbnRyb2xETEUiLAogIDB4MDAxMCwKICAiY29udHJvbEVNIiwKICAweDAwMTksCiAgImNvbnRyb2xFTlEiLAogIDB4MDAwNSwKICAiY29udHJvbEVPVCIsCiAgMHgwMDA0LAogICJjb250cm9sRVNDIiwKICAweDAwMWIsCiAgImNvbnRyb2xFVEIiLAogIDB4MDAxNywKICAiY29udHJvbEVUWCIsCiAgMHgwMDAzLAogICJjb250cm9sRkYiLAogIDB4MDAwYywKICAiY29udHJvbEZTIiwKICAweDAwMWM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LAogICJob2xhbXF1YXJ0ZXJoZWJyZXciLAogIDB4MDViOSwKICAiaG9sYW13aWRlaGVicmV3IiwKICAweDA1YjksCiAgImhvbm9raHVrdGhhaSIsCiAgMHgwZTJlLAogICJob29rYWJvdmVjb21iIiwKICAweDAzMDksCiAgImhvb2tjbWIiLAogIDB4MDMwOSwKICAiaG9va3BhbGF0YWxpemVkYmVsb3djbWIiLAogIDB4MDMyMSwKICAiaG9va3JldHJvZmxleGJlbG93Y21iIiwKICAweDAzMjIsCiAgImhvb25zcXVhcmUiLAogIDB4MzM0MiwKICAiaG9yaWNvcHRpYyIsCiAgMHgwM2U5LAogICJob3Jpem9udGFsYmFyIiwKICAweDIwMTUsCiAgImhvcm5jbWIiLAogIDB4MDMxYiwKICAiaG90c3ByaW5ncyIsCiAgMHgyNjY4LAogICJob3VzZSIsCiAgMHgyMzAyLAogICJocGFyZW4iLAogIDB4MjRhMywKICAiaHN1cGVyaW9yIiwKICAweDAyYjAsCiAgImh0dXJuZWQiLAogIDB4MDI2NSwKICAiaHVoaXJhZ2FuYSIsCiAgMHgzMDc1LAogICJodWlpdG9zcXVhcmUiLAogIDB4MzMzMywKICAiaHVrYXRha2FuYSIsCiAgMHgzMGQ1LAogICJodWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOGMsCiAgImh1bmdhcnVtbGF1dCIsCiAgMHgwMmRkLAogICJodW5nYXJ1bWxhdXRjbWIiLAogIDB4MDMwYiwKICAiaHYiLAogIDB4MDE5NSwKICAiaHlwaGVuIiwKICAweDAwMmQsCiAgImh5cGhlbmluZmVyaW9yIiwKICAweGY2ZTUsCiAgImh5cGhlbm1vbm9zcGFjZSIsCiAgMHhmZjBkLAogICJoeXBoZW5zbWFsbCIsCiAgMHhmZTYzLAogICJoeXBoZW5zdXBlcmlvciIsCiAgMHhmNmU2LAogICJoeXBoZW50d28iLAogIDB4MjAxMCwKICAiaSIsCiAgMHgwMDY5LAogICJpYWN1dGUiLAogIDB4MDBlZCwKICAiaWF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YW4iLAogIDB4MDU3YiwKICAiamlzIiwKICAweDMwMDQsCiAgImptb25vc3BhY2UiLAogIDB4ZmY0YSwKICAianBhcmVuIiwKICAweDI0YTUsCiAgImpzdXBlcmlvciIsCiAgMHgwMmIyLAogICJrIiwKICAweDAwNmIsCiAgImthYmFzaGtpcmN5cmlsbGljIiwKICAweDA0YTEsCiAgImthYmVuZ2FsaSIsCiAgMHgwOTk1LAogICJrYWN1dGUiLAogIDB4MWUzMSwKICAia2FjeXJpbGxpYyIsCiAgMHgwNDNhLAogICJrYWRlc2NlbmRlcmN5cmlsbGljIiwKICAweDA0OWIsCiAgImthZGV2YSIsCiAgMHgwOTE1LAogICJrYWYiLAogIDB4MDVkYiwKICAia2FmYXJhYmljIiwKICAweDA2NDMsCiAgImthZmRhZ2VzaCIsCiAgMHhmYjNiLAogICJrYWZkYWdlc2hoZWJyZXciLAogIDB4ZmIzYiwKICAia2FmZmluYWxhcmFiaWMiLAogIDB4ZmVkYSwKICAia2FmaGVicmV3IiwKICAweDA1ZGIsCiAgImthZmluaXRpYWxhcmFiaWMiLAogIDB4ZmVkYiwKICAia2FmbWVkaWFsYXJhYmljIiwKICAweGZlZGMsCiAgImthZnJhZmVoZWJyZXciLAogIDB4ZmI0ZCwKICAia2FndWphcmF0aSIsCiAgMHgwYTk1LAogICJrYWd1cm11a2hpIiwKICAweDBhMTUsCiAgImthaGlyYWdhbmEiLAogIDB4MzA0YiwKICAia2Fob29rY3lyaWxsaWMiLAogIDB4MDRjNCwKICAia2FrYXRha2FuYSIsCiAgMHgzMGFiLAogICJrYWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzYsCiAgImthcHBhIiwKICAweDAzYmEsCiAgImthcHBhc3ltYm9sZ3JlZWsiLAogIDB4MDNmMCwKICAia2FweWVvdW5taWV1bWtvcmVhbiIsCiAgMHgzMTcxLAogICJrYXB5ZW91bnBoaWV1cGhrb3JlYW4iLAogIDB4MzE4NCwKICAia2FweWVvdW5waWV1cGtvcmVhb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MHgwOTE2LAogICJraGFndWphcmF0aSIsCiAgMHgwYTk2LAogICJraGFndXJtdWtoaSIsCiAgMHgwYTE2LAogICJraGFoYXJhYmljIiwKICAweDA2MmUsCiAgImtoYWhmaW5hbGFyYWJpYyIsCiAgMHhmZWE2LAogICJraGFoaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWE3LAogICJraGFobWVkaWFsYXJhYmljIiwKICAweGZlYTgsCiAgImtoZWljb3B0aWMiLAogIDB4MDNlNywKICAia2hoYWRldmEiLAogIDB4MDk1OSwKICAia2hoYWd1cm11a2hpIiwKICAweDBhNTksCiAgImtoaWV1a2hhY2lyY2xla29yZWFuIiwKICAweDMyNzgsCiAgImtoaWV1a2hhcGFyZW5rb3JlYW4iLAogIDB4MzIxOCwKICAia2hpZXVraGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZhLAogICJraGlldWtoa29yZWFuIiwKICAweDMxNGIsCiAgImtoaWV1a2hwYXJlbmtvcmVhbiIsCiAgMHgzMjBhLAogICJraG9raGFpdGhhaSIsCiAgMHgwZTAyLAogICJraG9raG9udGhhaSIsCiAgMHgwZTA1LAogICJraG9raHVhdHRoYWkiLAogIDB4MGUwMywKICAia2hva2h3YWl0aGFpIiwKICAweDBlMDQsCiAgImtob211dHRoYWkiLAogIDB4MGU1YiwKICAia2hvb2siLAogIDB4MDE5OSwKICAia2hvcmFraGFuZ3RoYWkiLAogIDB4MGUwNiwKICAia2h6c3F1YXJlIiwKICAweDMzOTEsCiAgImtpaGlyYWdhbmEiLAogIDB4MzA0ZCwKICAia2lrYXRha2FuYSIsCiAgMHgzMGFkLAogICJraWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzcsCiAgImtpcm9ndXJhbXVzcXVhcmUiLAogIDB4MzMxNSwKICAia2lyb21lZXRvcnVzcXVhcmUiLAogIDB4MzMxNiwKICAia2lyb3NxdWFyZSIsCiAgMHgzMzE0LAogICJraXllb2thY2lyY2xla29yZWFuIiwKICAweDMyNmUsCiAgImtp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iAgMHgyMTViLAogICJvbmVmaXR0ZWQiLAogIDB4ZjZkYywKICAib25lZ3VqYXJhdGkiLAogIDB4MGFlNywKICAib25lZ3VybXVraGkiLAogIDB4MGE2NywKICAib25laGFja2FyYWJpYyIsCiAgMHgwNjYxLAogICJvbmVoYWxmIiwKICAweDAwYmQsCiAgIm9uZWhhbmd6aG91IiwKICAweDMwMjEsCiAgIm9uZWlkZW9ncmFwaGljcGFyZW4iLAogIDB4MzIyMCwKICAib25laW5mZXJpb3IiLAogIDB4MjA4MSwKICAib25lbW9ub3NwYWNlIiwKICAweGZmMTEsCiAgIm9uZW51bWVyYXRvcmJlbmdhbGkiLAogIDB4MDlmNCwKICAib25lb2xkc3R5bGUiLAogIDB4ZjczMSwKICAib25lcGFyZW4iLAogIDB4MjQ3NCwKICAib25lcGVyaW9kIiwKICAweDI0ODgsCiAgIm9uZXBlcnNpYW4iLAogIDB4MDZmMSwKICAib25lcXVhcnRlciIsCiAgMHgwMGJjLAogICJvbmVyb21hbiIsCiAgMHgyMTcwLAogICJvbmVzdXBlcmlvciIsCiAgMHgwMGI5LAogICJvbmV0aGFpIiwKICAweDBlNTEsCiAgIm9uZXRoaXJkIiwKICAweDIxNTMsCiAgIm9vZ29uZWsiLAogIDB4MDFlYiwKICAib29nb25la21hY3JvbiIsCiAgMHgwMWVkLAogICJvb2d1cm11a2hpIiwKICAweDBhMTMsCiAgIm9vbWF0cmFndXJtdWtoaSIsCiAgMHgwYTRiLAogICJvb3BlbiIsCiAgMHgwMjU0LAogICJvcGFyZW4iLAogIDB4MjRhYSwKICAib3BlbmJ1bGxldCIsCiAgMHgyNWU2LAogICJvcHRpb24iLAogIDB4MjMyNSwKICAib3JkZmVtaW5pbmUiLAogIDB4MDBhYSwKICAib3JkbWFzY3VsaW5lIiwKICAweDAwYmEsCiAgIm9ydGhvZ29uYWwiLAogIDB4MjIxZiwKICAib3Nob3J0ZGV2YSIsCiAgMHgwOTEyLAogICJvc2hvcnR2b3dlbHNpZ25k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WdodHN1cGVyaW9yIiwKICAweDIwN2UsCiAgInBhcmVucmlnaHR0cCIsCiAgMHhmOGY2LAogICJwYXJlbnJpZ2h0dmVydGljYWwiLAogIDB4ZmUzNiwKICAicGFydGlhbGRpZmYiLAogIDB4MjIwMiwKICAicGFzZXFoZWJyZXciLAogIDB4MDVjMCwKICAicGFzaHRhaGVicmV3IiwKICAweDA1OTksCiAgInBhc3F1YXJlIiwKICAweDMzYTksCiAgInBhdGFoIiwKICAweDA1YjcsCiAgInBhdGFoMTEiLAogIDB4MDViNywKICAicGF0YWgxZCIsCiAgMHgwNWI3LAogICJwYXRhaDJhIiwKICAweDA1YjcsCiAgInBhdGFoaGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFobmFycm93aGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFocXVhcnRlcmhlYnJldyIsCiAgMHgwNWI3LAogICJwYXRhaHdpZGVoZWJyZXciLAogIDB4MDViNywKICAicGF6ZXJoZWJyZXciLAogIDB4MDVhMSwKICAicGJvcG9tb2ZvIiwKICAweDMxMDYsCiAgInBjaXJjbGUiLAogIDB4MjRkZiwKICAicGRvdGFjY2VudCIsCiAgMHgxZTU3LAogICJwZSIsCiAgMHgwNWU0LAogICJwZWN5cmlsbGljIiwKICAweDA0M2YsCiAgInBlZGFnZXNoIiwKICAweGZiNDQsCiAgInBlZGFnZXNoaGVicmV3IiwKICAweGZiNDQsCiAgInBlZXppc3F1YXJlIiwKICAweDMzM2IsCiAgInBlZmluYWxkYWdlc2hoZWJyZXciLAogIDB4ZmI0MywKICAicGVoYXJhYmljIiwKICAweDA2N2UsCiAgInBlaGFybWVuaWFuIiwKICAweDA1N2EsCiAgInBlaGVicmV3IiwKICAweDA1ZTQsCiAgInBlaGZpbmFsYXJhYmljIiwKICAweGZiNTcsCiAgInBlaGluaXRpYWxhcmFiaWMiLAogIDB4ZmI1OCwKICAicGVoaXJhZ2FuYSIsCiAgMHgzMDdhLAogICJwZWhtZWRpYWxhcmFiaWMiLA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aGlldXBoa29yZWFuIiwKICAweDMxNGQsCiAgInBoaWV1cGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBjLAogICJwaGlsYXRpbiIsCiAgMHgwMjc4LAogICJwaGludGh1dGhhaSIsCiAgMHgwZTNhLAogICJwaGlzeW1ib2xncmVlayIsCiAgMHgwM2Q1LAogICJwaG9vayIsCiAgMHgwMWE1LAogICJwaG9waGFudGhhaSIsCiAgMHgwZTFlLAogICJwaG9waHVuZ3RoYWkiLAogIDB4MGUxYywKICAicGhvc2FtcGhhb3RoYWkiLAogIDB4MGUyMCwKICAicGkiLAogIDB4MDNjMCwKICAicGlldXBhY2lyY2xla29yZWFuIiwKICAweDMyNzMsCiAgInBpZXVwYXBhcmVua29yZWFuIiwKICAweDMyMTMsCiAgInBpZXVwY2lldWNrb3JlYW4iLAogIDB4MzE3NiwKICAicGlldXBjaXJjbGVrb3JlYW4iLAogIDB4MzI2NSwKICAicGlldXBraXllb2trb3JlYW4iLAogIDB4MzE3MiwKICAicGlldXBrb3JlYW4iLAogIDB4MzE0MiwKICAicGlldXBwYXJlbmtvcmVhbiIsCiAgMHgzMjA1LAogICJwaWV1cHNpb3NraXllb2trb3JlYW4iLAogIDB4MzE3NCwKICAicGlldXBzaW9za29yZWFuIiwKICAweDMxNDQsCiAgInBpZXVwc2lvc3Rpa2V1dGtvcmVhbiIsCiAgMHgzMTc1LAogICJwaWV1cHRoaWV1dGhrb3JlYW4iLAogIDB4MzE3NywKICAicGlldXB0aWtldXRrb3JlYW4iLAogIDB4MzE3MywKICAicGloaXJhZ2FuYSIsCiAgMHgzMDc0LAogICJwaWthdGFrYW5hIiwKICAweDMwZDQsCiAgInBpc3ltYm9sZ3JlZWsiLAogIDB4MDNkNiwKICAicGl3cmFybWVuaWFuIiwKICAweDA1ODMsCiAgInBsdXMiLAogIDB4MDAyYiwKICAicGx1c2JlbG93Y21iIiwKICAweDAzMWYsCiAgInBsdXNjaXJjbGUiLAogIDB4MjI5NSwKICAicGx1c21p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KICAicHNpbGlwbmV1bWF0YWN5cmlsbGljY21iIiwKICAweDA0ODYsCiAgInBzc3F1YXJlIiwKICAweDMzYjAsCiAgInB1aGlyYWdhbmEiLAogIDB4MzA3NywKICAicHVrYXRha2FuYSIsCiAgMHgzMGQ3LAogICJwdnNxdWFyZSIsCiAgMHgzM2I0LAogICJwd3NxdWFyZSIsCiAgMHgzM2JhLAogICJxIiwKICAweDAwNzEsCiAgInFhZGV2YSIsCiAgMHgwOTU4LAogICJxYWRtYWhlYnJldyIsCiAgMHgwNWE4LAogICJxYWZhcmFiaWMiLAogIDB4MDY0MiwKICAicWFmZmluYWxhcmFiaWMiLAogIDB4ZmVkNiwKICAicWFmaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWQ3LAogICJxYWZtZWRpYWxhcmFiaWMiLAogIDB4ZmVkOCwKICAicWFtYXRzIiwKICAweDA1YjgsCiAgInFhbWF0czEwIiwKICAweDA1YjgsCiAgInFhbWF0czFhIiwKICAweDA1YjgsCiAgInFhbWF0czFjIiwKICAweDA1YjgsCiAgInFhbWF0czI3IiwKICAweDA1YjgsCiAgInFhbWF0czI5IiwKICAweDA1YjgsCiAgInFhbWF0czMzIiwKICAweDA1YjgsCiAgInFhbWF0c2RlIiwKICAweDA1YjgsCiAgInFhbWF0c2hlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNuYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5oZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5uYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5xdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3FhdGFud2lkZWhlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNxdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3dpZGVoZWJyZXciLAogIDB4MDViOCwKICAicWFybmV5cGFyYWhlYnJldyIsCiAgMHgwNTlmLAog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4MDI2NCwKICAicmF0aW8iLAogIDB4MjIzNiwKICAicmJvcG9tb2ZvIiwKICAweDMxMTYsCiAgInJjYXJvbiIsCiAgMHgwMTU5LAogICJyY2VkaWxsYSIsCiAgMHgwMTU3LAogICJyY2lyY2xlIiwKICAweDI0ZTEsCiAgInJjb21tYWFjY2VudCIsCiAgMHgwMTU3LAogICJyZGJsZ3JhdmUiLAogIDB4MDIxMSwKICAicmRvdGFjY2VudCIsCiAgMHgxZTU5LAogICJyZG90YmVsb3ciLAogIDB4MWU1YiwKICAicmRvdGJlbG93bWFjcm9uIiwKICAweDFlNWQsCiAgInJlZmVyZW5jZW1hcmsiLAogIDB4MjAzYiwKICAicmVmbGV4c3Vic2V0IiwKICAweDIyODYsCiAgInJlZmxleHN1cGVyc2V0IiwKICAweDIyODcsCiAgInJlZ2lzdGVyZWQiLAogIDB4MDBhZSwKICAicmVnaXN0ZXJzYW5zIiwKICAweGY4ZTgsCiAgInJlZ2lzdGVyc2VyaWYiLAogIDB4ZjZkYSwKICAicmVoYXJhYmljIiwKICAweDA2MzEsCiAgInJlaGFybWVuaWFuIiwKICAweDA1ODAsCiAgInJlaGZpbmFsYXJhYmljIiwKICAweGZlYWUsCiAgInJlaGlyYWdhbmEiLAogIDB4MzA4YywKICAicmVrYXRha2FuYSIsCiAgMHgzMGVjLAogICJyZWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOWEsCiAgInJlc2giLAogIDB4MDVlOCwKICAicmVzaGRhZ2VzaGhlYnJldyIsCiAgMHhmYjQ4LAogICJyZXNoaGVicmV3IiwKICAweDA1ZTgsCiAgInJldmVyc2VkdGlsZGUiLAogIDB4MjIzZCwKICAicmV2aWFoZWJyZXciLAogIDB4MDU5NywKICAicmV2aWFtdWdyYXNoaGVicmV3IiwKICAweDA1OTcsCiAgInJldmxvZ2ljYWxub3QiLAogIDB4MjMxMCwKICAicmZpc2hob29rIiwKICAweDAyN2UsCiAgInJmaXNoaG9va3JldmVyc2VkIiwKICAweDAy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GVicmV3IiwKICAweDA1OTMsCiAgInNoYm9wb21vZm8iLAogIDB4MzExNSwKICAic2hjaGFjeXJpbGxpYyIsCiAgMHgwNDQ5LAogICJzaGVlbmFyYWJpYyIsCiAgMHgwNjM0LAogICJzaGVlbmZpbmFsYXJhYmljIiwKICAweGZlYjYsCiAgInNoZWVuaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWI3LAogICJzaGVlbm1lZGlhbGFyYWJpYyIsCiAgMHhmZWI4LAogICJzaGVpY29wdGljIiwKICAweDAzZTMsCiAgInNoZXFlbCIsCiAgMHgyMGFhLAogICJzaGVxZWxoZWJyZXciLAogIDB4MjBhYSwKICAic2hldmEiLAogIDB4MDViMCwKICAic2hldmExMTUiLAogIDB4MDViMCwKICAic2hldmExNSIsCiAgMHgwNWIwLAogICJzaGV2YTIyIiwKICAweDA1YjAsCiAgInNoZXZhMmUiLAogIDB4MDViMCwKICAic2hldmFoZWJyZXciLAogIDB4MDViMCwKICAic2hldmFuYXJyb3doZWJyZXciLAogIDB4MDViMCwKICAic2hldmFxdWFydGVyaGVicmV3IiwKICAweDA1YjAsCiAgInNoZXZhd2lkZWhlYnJldyIsCiAgMHgwNWIwLAogICJzaGhhY3lyaWxsaWMiLAogIDB4MDRiYiwKICAic2hpbWFjb3B0aWMiLAogIDB4MDNlZCwKICAic2hpbiIsCiAgMHgwNWU5LAogICJzaGluZGFnZXNoIiwKICAweGZiNDksCiAgInNoaW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0OSwKICAic2hpbmRhZ2VzaHNoaW5kb3QiLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNoaW5kb3RoZWJyZXciLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNpbmRvdCIsCiAgMHhmYjJkLAogICJzaGluZGFnZXNoc2luZG90aGVicmV3IiwKICAweGZiMmQsCiAgInNoaW5kb3RoZWJyZXciLAogIDB4MDVjMSwKICAic2hpbmhlYnJldyIsCiAgMHgwNWU5LAogICJzaGluc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FudGhha2hhdGxvd3JpZ2h0dGhhaSIsCiAgMHhmODk3LAogICJ0aGFudGhha2hhdHRoYWkiLAogIDB4MGU0YywKICAidGhhbnRoYWtoYXR1cHBlcmxlZnR0aGFpIiwKICAweGY4OTYsCiAgInRoZWhhcmFiaWMiLAogIDB4MDYyYiwKICAidGhlaGZpbmFsYXJhYmljIiwKICAweGZlOWEsCiAgInRoZWhpbml0aWFsYXJhYmljIiwKICAweGZlOWIsCiAgInRoZWhtZWRpYWxhcmFiaWMiLAogIDB4ZmU5YywKICAidGhlcmVleGlzdHMiLAogIDB4MjIwMywKICAidGhlcmVmb3JlIiwKICAweDIyMzQsCiAgInRoZXRhIiwKICAweDAzYjgsCiAgInRoZXRhMSIsCiAgMHgwM2QxLAogICJ0aGV0YXN5bWJvbGdyZWVrIiwKICAweDAzZDEsCiAgInRoaWV1dGhhY2lyY2xla29yZWFuIiwKICAweDMyNzksCiAgInRoaWV1dGhhcGFyZW5rb3JlYW4iLAogIDB4MzIxOSwKICAidGhpZXV0aGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZiLAogICJ0aGlldXRoa29yZWFuIiwKICAweDMxNGMsCiAgInRoaWV1dGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBiLAogICJ0aGlydGVlbmNpcmNsZSIsCiAgMHgyNDZjLAogICJ0aGlydGVlbnBhcmVuIiwKICAweDI0ODAsCiAgInRoaXJ0ZWVucGVyaW9kIiwKICAweDI0OTQsCiAgInRob25hbmdtb250aG90aGFpIiwKICAweDBlMTEsCiAgInRob29rIiwKICAweDAxYWQsCiAgInRob3BodXRoYW90aGFpIiwKICAweDBlMTIsCiAgInRob3JuIiwKICAweDAwZmUsCiAgInRob3RoYWhhbnRoYWkiLAogIDB4MGUxNywKICAidGhvdGhhbnRoYWkiLAogIDB4MGUxMCwKICAidGhvdGhvbmd0aGFpIiwKICAweDBlMTgsCiAgInRob3RodW5ndGhhaSIsCiAgMHgwZTE2LAogICJ0aG91c2FuZGN5cmlsbG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5dXlla29yZWFuIiwKICAweDMxOGIsCiAgInl1eWVva29yZWFuIiwKICAweDMxOGEsCiAgInl5YWJlbmdhbGkiLAogIDB4MDlkZiwKICAieXlhZGV2YSIsCiAgMHgwOTVmLAogICJ6IiwKICAweDAwN2EsCiAgInphYXJtZW5pYW4iLAogIDB4MDU2NiwKICAiemFjdXRlIiwKICAweDAxN2EsCiAgInphZGV2YSIsCiAgMHgwOTViLAogICJ6YWd1cm11a2hpIiwKICAweDBhNWIsCiAgInphaGFyYWJpYyIsCiAgMHgwNjM4LAogICJ6YWhmaW5hbGFyYWJpYyIsCiAgMHhmZWM2LAogICJ6YWhpbml0aWFsYXJhYmljIiwKICAweGZlYzcsCiAgInphaGlyYWdhbmEiLAogIDB4MzA1NiwKICAiemFobWVkaWFsYXJhYmljIiwKICAweGZlYzgsCiAgInphaW5hcmFiaWMiLAogIDB4MDYzMiwKICAiemFpbmZpbmFsYXJhYmljIiwKICAweGZlYjAsCiAgInpha2F0YWthbmEiLAogIDB4MzBiNiwKICAiemFxZWZnYWRvbGhlYnJldyIsCiAgMHgwNTk1LAogICJ6YXFlZnFhdGFuaGVicmV3IiwKICAweDA1OTQsCiAgInphcnFhaGVicmV3IiwKICAweDA1OTgsCiAgInpheWluIiwKICAweDA1ZDYsCiAgInpheWluZGFnZXNoIiwKICAweGZiMzYsCiAgInpheWluZGFnZXNoaGVicmV3IiwKICAweGZiMzYsCiAgInpheWluaGVicmV3IiwKICAweDA1ZDYsCiAgInpib3BvbW9mbyIsCiAgMHgzMTE3LAogICJ6Y2Fyb24iLAogIDB4MDE3ZSwKICAiemNpcmNsZSIsCiAgMHgyNGU5LAogICJ6Y2lyY3VtZmxleCIsCiAgMHgxZTkxLAogICJ6Y3VybCIsCiAgMHgwMjkxLAogICJ6ZG90IiwKICAweDAxN2MsCiAgInpkb3RhY2NlbnQiLAogIDB4MDE3YywKICAiemRvdGJlbG93IiwKICAweDFlOTMsCiAgInplY3lyaWxsaWMiLAogIDB4MDQzN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3MGUsCiAgImExNiIsCiAgMHgyNzBmLAogICJhMTA1IiwKICAweDI3MTAsCiAgImExNyIsCiAgMHgyNzExLAogICJhMTgiLAogIDB4MjcxMiwKICAiYTE5IiwKICAweDI3MTMsCiAgImEyMCIsCiAgMHgyNzE0LAogICJhMjEiLAogIDB4MjcxNSwKICAiYTIyIiwKICAweDI3MTYsCiAgImEyMyIsCiAgMHgyNzE3LAogICJhMjQiLAogIDB4MjcxOCwKICAiYTI1IiwKICAweDI3MTksCiAgImEyNiIsCiAgMHgyNzFhLAogICJhMjciLAogIDB4MjcxYiwKICAiYTI4IiwKICAweDI3MWMsCiAgImE2IiwKICAweDI3MWQsCiAgImE3IiwKICAweDI3MWUsCiAgImE4IiwKICAweDI3MWYsCiAgImE5IiwKICAweDI3MjAsCiAgImExMCIsCiAgMHgyNzIxLAogICJhMjkiLAogIDB4MjcyMiwKICAiYTMwIiwKICAweDI3MjMsCiAgImEzMSIsCiAgMHgyNzI0LAogICJhMzIiLAogIDB4MjcyNSwKICAiYTMzIiwKICAweDI3MjYsCiAgImEzNCIsCiAgMHgyNzI3LAogICJhMzUiLAogIDB4MjYwNSwKICAiYTM2IiwKICAweDI3MjksCiAgImEzNyIsCiAgMHgyNzJhLAogICJhMzgiLAogIDB4MjcyYiwKICAiYTM5IiwKICAweDI3MmMsCiAgImE0MCIsCiAgMHgyNzJkLAogICJhNDEiLAogIDB4MjcyZSwKICAiYTQyIiwKICAweDI3MmYsCiAgImE0MyIsCiAgMHgyNzMwLAogICJhNDQiLAogIDB4MjczMSwKICAiYTQ1IiwKICAweDI3MzIsCiAgImE0NiIsCiAgMHgyNzMzLAogICJhNDciLAogIDB4MjczNCwKICAiYTQ4IiwKICAweDI3MzUsCiAgImE0OSIsCiAgMHgyNzM2LAogICJhNTAiLAogIDB4MjczNywKICAiYTUxIiwKICAweDI3MzgsCiAgImE1MiIsCiAgMHgyNzM5LAogICJhNTMiLAogIDB4MjczYSwKICAiYTU0IiwKICAweDI3M2IsCi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jc5MywKICAiYTE2MCIsCiAgMHgyNzk0LAogICJhMTYxIiwKICAweDIxOTIsCiAgImExNjMiLAogIDB4MjE5NCwKICAiYTE2NCIsCiAgMHgyMTk1LAogICJhMTk2IiwKICAweDI3OTgsCiAgImExNjUiLAogIDB4Mjc5OSwKICAiYTE5MiIsCiAgMHgyNzlhLAogICJhMTY2IiwKICAweDI3OWIsCiAgImExNjciLAogIDB4Mjc5YywKICAiYTE2OCIsCiAgMHgyNzlkLAogICJhMTY5IiwKICAweDI3OWUsCiAgImExNzAiLAogIDB4Mjc5ZiwKICAiYTE3MSIsCiAgMHgyN2EwLAogICJhMTcyIiwKICAweDI3YTEsCiAgImExNzMiLAogIDB4MjdhMiwKICAiYTE2MiIsCiAgMHgyN2EzLAogICJhMTc0IiwKICAweDI3YTQsCiAgImExNzUiLAogIDB4MjdhNSwKICAiYTE3NiIsCiAgMHgyN2E2LAogICJhMTc3IiwKICAweDI3YTcsCiAgImExNzgiLAogIDB4MjdhOCwKICAiYTE3OSIsCiAgMHgyN2E5LAogICJhMTkzIiwKICAweDI3YWEsCiAgImExODAiLAogIDB4MjdhYiwKICAiYTE5OSIsCiAgMHgyN2FjLAogICJhMTgxIiwKICAweDI3YWQsCiAgImEyMDAiLAogIDB4MjdhZSwKICAiYTE4MiIsCiAgMHgyN2FmLAogICJhMjAxIiwKICAweDI3YjEsCiAgImExODMiLAogIDB4MjdiMiwKICAiYTE4NCIsCiAgMHgyN2IzLAogICJhMTk3IiwKICAweDI3YjQsCiAgImExODUiLAogIDB4MjdiNSwKICAiYTE5NCIsCiAgMHgyN2I2LAogICJhMTk4IiwKICAweDI3YjcsCiAgImExODYiLAogIDB4MjdiOCwKICAiYTE5NSIsCiAgMHgyN2I5LAogICJhMTg3IiwKICAweDI3YmEsCiAgImExODgiLAogIDB4MjdiYiwKICAiYTE4OSIsCiAgMHgyN2JjLAogICJhMTkwIiwKICAweDI3YmQsCiAgImExOTEiLAogIDB4MjdiZSwKICAiYTg5IiwKIC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NDlcdTAwNEEiLAogICJcdTAxMzMiLAogICJcdTAwNjlcdTAwNkEiLAogICJcdTAxM0YiLAogICJcdTAwNENcdTAwQjciLAogICJcdTAxNDAiLAogICJcdTAwNkNcdTAwQjciLAogICJcdTAxNDkiLAogICJcdTAyQkNcdTAwNkUiLAogICJcdTAxN0YiLAogICJcdTAwNzMiLAogICJcdTAxQzQiLAogICJcdTAwNDRcdTAxN0QiLAogICJcdTAxQzUiLAogICJcdTAwNDRcdTAxN0UiLAogICJcdTAxQzYiLAogICJcdTAwNjRcdTAxN0UiLAogICJcdTAxQzciLAogICJcdTAwNENcdTAwNEEiLAogICJcdTAxQzgiLAogICJcdTAwNENcdTAwNkEiLAogICJcdTAxQzkiLAogICJcdTAwNkNcdTAwNkEiLAogICJcdTAxQ0EiLAogICJcdTAwNEVcdTAwNEEiLAogICJcdTAxQ0IiLAogICJcdTAwNEVcdTAwNkEiLAogICJcdTAxQ0MiLAogICJcdTAwNkVcdTAwNkEiLAogICJcdTAxRjEiLAogICJcdTAwNDRcdTAwNUEiLAogICJcdTAxRjIiLAogICJcdTAwNDRcdTAwN0EiLAogICJcdTAxRjMiLAogICJcdTAwNjRcdTAwN0EiLAogICJcdTAyRDgiLAogICJcdTAwMjBcdTAzMDYiLAogICJcdTAyRDkiLAogICJcdTAwMjBcdTAzMDciLAogICJcdTAyREEiLAogICJcdTAwMjBcdTAzMEEiLAogICJcdTAyREIiLAogICJcdTAwMjBcdTAzMjgiLAogICJcdTAyREMiLAogICJcdTAwMjBcdTAzMDMiLAogICJcdTAyREQiLAogICJcdTAwMjBcdTAzMEIiLAogICJcdTAzN0EiLAogICJcdTAwMjBcdTAzNDUiLAogICJcdTAzODQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAzRDAiLAogICJcdTAzQjIiLAogICJcdTAzRDEiLAogICJcdTAzQjgiLAogICJcdTAzRDIiLAogICJcdTAzQTUiLAogICJcdTAzRDUiLAogICJcdTAzQzYiLAogICJcdTAzRDYiLAogICJcdTAzQzAiLAogICJcdTAzRjAiLAogICJcdTAzQkEiLAogICJcdTAzRjEiLAogICJcdTAzQzEiLAogICJcdTAzRjIiLAogICJcdTAzQzIiLAogICJcdTAzRjQiLAogICJcdTAzOTgiLAogICJcdTAzRjUiLAogICJcdTAzQjUiLAogICJcdTAzRjkiLAogICJcdTAzQTMiLAogICJcdTA1ODciLAogICJcdTA1NjVcdTA1ODIiLAogICJcdTA2NzUiLAogICJcdTA2MjdcdTA2NzQiLAogICJcdTA2NzYiLAogICJcdTA2NDhcdTA2NzQiLAogICJcdTA2NzciLAogICJcdTA2QzdcdTA2NzQiLAogICJcdTA2NzgiLAogICJcdTA2NEFcdTA2NzQiLAogICJcdTBFMzMiLAogICJcdTBFNERcdTBFMzIiLAogICJcdTBFQjMiLAogICJcdTBFQ0RcdTBFQjIiLAogICJcdTBFREMiLAogICJcdTBFQUJcdTBFOTkiLAogICJcdTBFREQiLAogICJcdTBFQUJcdTBFQTEiLAogICJcdTBGNzciLAogICJcdTBGQjJcdTBGODEiLAogICJcdTBGNzkiLAogICJcdTBGQjNcdTBGODEiLAogICJcdTFFOUEiLAogICJcdTAwNjFcdTAyQkUiLAogICJcdTFGQkQiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQkYiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQzAiLAogICJcdTAwMjBcdTAzNDIiLAogICJcdTFGRkUiLAogICJcdTAwMjBcdTAzMTQiLAogICJcdTIwMDIiLAogICJcdTAwMjAiLAogICJcdTIwMDMiLAogICJcdTAwMjAiLAogICJcdTIwMDQiLAogICJcdTAwMjAiLAogICJcdTIwMDUiLAogICJcdTAwMjAiLAogICJcdTIwMDYiLAogICJcdTAwMjAiLAogICJcdTIwMDgiLAogICJcdTAwMjAiLAogICJcdTIwMDkiLAogICJcdTAwMjAiLAogICJcdTIwMEEiLAogICJcdTAwMjAiLAogICJcdTIwMTciLAogICJcdTAwMjBcdTAzMzMiLAogICJcdTIwMjQiLAogICJcdTAwMkUiLAogICJcdTIwMjUiLAogICJcdTAwMkVcdTAwMkUiLAogICJcdTIwMjYiLAogICJcdTAwMkVcdTAwMkVcdTAwMkUiLAogICJcdTIwMzMiLAogICJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzQiLAogICJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzYiLAogICJcdTIwMzVcdTIwMzUiLAogICJcdTIwMzciLAogICJcdTIwMzVcdTIwMzVcdTIwMzUiLAogICJcdTIwM0MiLAogICJcdTAwMjFcdTAwMjEiLAogICJcdTIwM0UiLAogICJcdTAwMjBcdTAzMDUiLAogICJcdTIwNDciLAogICJcdTAwM0ZcdTAwM0YiLAogICJcdTIwNDgiLAogICJcdTAwM0ZcdTAwMjEiLAogICJcdTIwNDkiLAogICJcdTAwMjFcdTAwM0YiLAogICJcdTIwNTciLAogICJcdTIwMzJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwNUYiLAogICJcdTAwMjAiLAogICJcdTIwQTgiLAogICJcdTAwNTJcdTAwNzMiLAogICJcdTIxMDAiLAogICJcdTAwNjFcdTAwMkZcdTAwNjMiLAogICJcdTIxMDEiLAogICJcdTAwNjFcdTAwMkZcdTAwNzMiLAogICJcdTIxMDMiLAogICJcdTAwQjBcdTAwNDMiLAogICJcdTIxMDUiLAogICJcdTAwNjNcdTAwMkZcdTAwNkYiLAogICJcdTIxMDYiLAogICJcdTAwNjNcdTAwMkZcdTAwNzUiLAogICJcdTIxMDciLAogICJcdTAxOTAiLAogICJcdTIxMDkiLAogICJcdTAwQjBcdTAwNDYiLAogICJcdTIxMTYiLAogICJcdTAwNEVcdTAwNkYiLAogICJcdTIxMjEiLAogICJcdTAwNTRcdTAwNDVcdTAwNEMiLAogICJcdTIxMzUiLAogICJcdTA1RDAiLAogICJcdTIxMzYiLAogICJcdTA1RDEiLAogICJcdTIxMzciLAogICJcdTA1RDIiLAogICJcdTIxMzgiLAogICJcdTA1RDMiLAogICJcdTIxM0IiLAogICJcdTAwNDZcdTAwNDFcdTAwNTgiLAogICJcdTIxNjAiLAogICJcdTAwNDkiLAogICJcdTIxNjEiLAogICJcdTAwNDlcdTAwNDkiLAogICJcdTIxNjIiLAogICJcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjMiLAogICJcdTAwNDlcdTAwNTYiLAogICJcdTIxNjQiLAogICJcdTAwNTYiLAogICJcdTIxNjUiLAogICJcdTAwNTZcdTAwNDkiLAogICJcdTIxNjYiLAogICJcdTAwNTZcdTAwNDlcdTAwNDkiLAogICJcdTIxNjciLAogICJcdTAwNTZcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjgiLAogICJcdTAwNDlcdTAwNTgiLAogICJcdTIxNjkiLAogICJcdTAwNTgiLAogICJcdTIxNkEiLAogICJcdTAwNThcdTAwNDkiLAogICJcdTIxNkIiLAogICJcdTAwNThcdTAwNDlcdTAwNDkiLAogICJcdTIxNkMiLAogICJcdTAwNEMiLAogICJcdTIxNkQiLAogICJcdTAwNDMiLAogICJcdTIxNkUiLAogICJcdTAwNDQiLAogICJcdTIxNkYiLAogICJcdTAwNEQiLAogICJcdTIxNzAiLAogICJcdTAwNjkiLAogICJcdTIxNzEiLAogICJcdTAwNjlcdTAwNjkiLAogICJcdTIxNzIiLAogICJcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzMiLAogICJcdTAwNjlcdTAwNzYiLAogICJcdTIxNzQiLAogICJcdTAwNzYiLAogICJcdTIxNzUiLAogICJcdTAwNzZcdTAwNjkiLAogICJcdTIxNzYiLAogICJcdTAwNzZcdTAwNjlcdTAwNjkiLAogICJcdTIxNzciLAogICJcdTAwNzZcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzgiLAogICJcdTAwNjlcdTAwNzgiLAogICJcdTIxNzkiLAogICJcdTAwNzgiLAogICJcdTIxN0EiLAogICJcdTAwNzhcdTAwNjkiLAogICJcdTIxN0IiLAogICJcdTAwNzhcdTAw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JcdTI0QjMiLAogICJcdTAwMjhcdTAwNzhcdTAwMjkiLAogICJcdTI0QjQiLAogICJcdTAwMjhcdTAwNzlcdTAwMjkiLAogICJcdTI0QjUiLAogICJcdTAwMjhcdTAwN0FcdTAwMjkiLAogICJcdTJBMEMiLAogICJcdTIyMkJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTJBNzQiLAogICJcdTAwM0FcdTAwM0FcdTAwM0QiLAogICJcdTJBNzUiLAogICJcdTAwM0RcdTAwM0QiLAogICJcdTJBNzYiLAogICJcdTAwM0RcdTAwM0RcdTAwM0QiLAogICJcdTJFOUYiLAogICJcdTZCQ0QiLAogICJcdTJFRjMiLAogICJcdTlGOUYiLAogICJcdTJGMDAiLAogICJcdTRFMDAiLAogICJcdTJGMDEiLAogICJcdTRFMjgiLAogICJcdTJGMDIiLAogICJcdTRFMzYiLAogICJcdTJGMDMiLAogICJcdTRFM0YiLAogICJcdTJGMDQiLAogICJcdTRFNTkiLAogICJcdTJGMDUiLAogICJcdTRFODUiLAogICJcdTJGMDYiLAogICJcdTRFOEMiLAogICJcdTJGMDciLAogICJcdTRFQTAiLAogICJcdTJGMDgiLAogICJcdTRFQkEiLAogICJcdTJGMDkiLAogICJcdTUxM0YiLAogICJcdTJGMEEiLAogICJcdTUxNjUiLAogICJcdTJGMEIiLAogICJcdTUxNkIiLAogICJcdTJGMEMiLAogICJcdTUxODIiLAogICJcdTJGMEQiLAogICJcdTUxOTYiLAogICJcdTJGMEUiLAogICJcdTUxQUIiLAogICJcdTJGMEYiLAogICJcdTUxRTAiLAogICJcdTJGMTAiLAogICJcdTUxRjUiLAogICJcdTJGMTEiLAogICJcdTUyMDAiLAogICJcdTJGMTIiLAogICJcdTUyOUIiLAogICJcdTJGMTMiLAogICJcdTUyRjkiLAogICJcdTJGMTQiLAogICJcdTUzMTUiLAogICJcdTJGMTUiLAogICJcdTUzMUEiLAogICJcdTJGMTYiLAogICJcdTUzMzgiLAogICJcdTJGMTciLAogICJcdTUzNDEiLAogICJcdTJGMTgiLAogICJcdTUzNUMiLAogICJcdTJGMTkiLAogICJcdTUzNjkiLAogICJcdTJGMUEiLAogICJcdTUzODIiLAogICJcdTJGMUIiLAogICJcdTUzQjYiLAogICJcdTJGMUMiLAogICJcdTUzQzgiLAogICJcdTJGMUQiLAogICJcdTUzRTMiLAogICJcdTJGMUUiLAogICJcdTU2RDciLAogICJcdTJGMUYiLAogICJcdTU3MUYiLAogICJcdTJGMjAiLAogICJcdTU4RUIiLAogICJcdTJGMjEiLAogICJcdTU5MDIiLAogICJcdTJGMjIiLAogICJcdTU5MEEiLAogICJcdTJGMjMiLAogICJcdTU5MTUiLAogICJcdTJGMjQiLAogICJcdTU5MjciLAogICJcdTJGMjUiLAogICJcdTU5NzMiLAogICJcdTJGMjYiLAogICJcdTVCNTAiLAogICJcdTJGMjciLAogICJcdTVCODAiLAogICJcdTJGMjgiLAogICJcdTVCRjgiLAogICJcdTJGMjkiLAogICJcdTVDMEYiLAogICJcdTJGMkEiLAogICJcdTVDMjIiLAogICJcdTJGMkIiLAogICJcdTVDMzgiLAogICJcdTJGMkMiLAogICJcdTVDNkUiLAogICJcdTJGMkQiLAogICJcdTVDNzEiLAogICJcdTJGMkUiLAogICJcdTVEREIiLAogICJcdTJGMkYiLAogICJcdTVERTUiLAogICJcdTJGMzAiLAogICJcdTVERjEiLAogICJcdTJGMzEiLAogICJcdTVERkUiLAogICJcdTJGMzIiLAogICJcdTVFNzIiLAogICJcdTJGMzMiLAogICJcdTVFN0EiLAogICJcdTJGMzQiLAogICJcdTVFN0YiLAogICJcdTJGMzUiLAogICJcdTVFRjQiLAogICJcdTJGMzYiLAogICJcdTVFRkUiLAogICJcdTJGMzciLAogICJcdTVGMEIiLAogICJcdTJGMzgiLAogICJcdTVGMTMiLAogICJcdTJGMzkiLAogICJcdTVGNTAiLAogICJcdTJGM0EiLAogICJcdTVGNjEiLAogICJcdTJGM0IiLAogICJcdTVGNzMiLAogICJcdTJGM0MiLAogICJcdTVGQzMiLAogICJcdTJGM0QiLAogICJcdTYyMDgiLAogICJcdTJGM0UiLAogICJcdTYyMzYiLAogICJcdTJGM0YiLAogICJcdTYyNEIiLAogICJcdTJGNDAiLAogICJcdTY1MkYiLAogICJcdTJGNDEiLAogICJcdTY1MzQiLAogICJcdTJGNDIiLAogICJcdTY1ODciLAogICJcdTJGNDMiLAogICJcdTY1OTciLAogICJcdTJGNDQiLAogICJcdTY1QTQiLAogICJcdTJGNDUiLAogICJcdTY1QjkiLAogICJcdTJGNDYiLAogICJcdTY1RTAiLAogICJcdTJGNDciLAogICJcdTY1RTUiLAogICJcdTJGNDgiLAogICJcdTY2RjAiLAogICJcdTJGNDkiLAogICJcdTY3MDgiLAogICJcdTJGNEEiLAogICJcdTY3MjgiLAogICJcdTJGNEIiLAogICJcdTZCMjAiLAogICJcdTJGNEMiLAogICJcdTZCNjIiLAogICJcdTJGNEQiLAogICJcdTZCNzkiLAogICJcdTJGNEUiLAogICJcdTZCQjMiLAogICJcdTJGNEYiLAogICJcdTZCQ0IiLAogICJcdTJGNTAiLAogICJcdTZCRDQiLAogICJcdTJGNTEiLAogICJcdTZCREIiLAogICJcdTJGNTIiLAogICJcdTZDMEYiLAogICJcdTJGNTMiLAogICJcdTZDMTQiLAogICJcdTJGNTQiLAogICJcdTZDMzQiLAogICJcdTJGNTUiLAogICJcdTcwNkIiLAogICJcdTJGNTYiLAogICJcdTcyMkEiLAogICJcdTJGNTciLAogICJcdTcyMzYiLAogICJcdTJGNTgiLAogICJcdTcyM0IiLAogICJcdTJGNTkiLAogICJcdTcyM0YiLAogICJcdTJGNUEiLAogICJcdTcyNDciLAogICJcdTJGNUIiLAogICJcdTcyNTkiLAogICJcdTJGNUMiLAogICJcdTcyNUIiLAogICJcdTJGNUQiLAogICJcdTcyQUMiLAogICJcdTJGNUUiLAogICJcdTczODQiLAogICJcdTJGNUYiLAogICJcdTczODkiLAogICJcdTJGNjAiLAogICJcdTc0REMiLAogICJcdTJGNjEiLAogICJcdTc0RTYiLAogICJcdTJGNjIiLAogICJcdTc1MTgiLAogICJcdTJGNjMiLAogICJcdTc1MUYiLAogICJcdTJGNjQiLAogICJcdTc1MjgiLAogICJcdTJGNjUiLAogICJcdTc1MzAiLAogICJcdTJGNjYiLAogICJcdTc1OEIiLAogICJcdTJGNjciLAogICJcdTc1OTIiLAogICJcdTJGNjgiLAogICJcdTc2NzYiLAogICJcdTJGNjkiLAogICJcdTc2N0QiLAogICJcdTJGNkEiLAogICJcdTc2QUUiLAogICJcdTJGNkIiLAogICJcdTc2QkYiLAogICJcdTJGNkMiLAogICJcdTc2RUUiLAogICJcdTJGNkQiLAogICJcdTc3REIiLAogICJcdTJGNkUiLAogICJcdTc3RTIiLAogICJcdTJGNkYiLAogICJcdTc3RjMiLAogICJcdTJGNzAiLAogICJcdTc5M0EiLAogICJcdTJGNzEiLAogICJcdTc5QjgiLAogICJcdTJGNzIiLAogICJcdTc5QkUiLAogICJcdTJGNzMiLAogICJcdTdBNzQiLAogICJcdTJGNzQiLAogICJcdTdBQ0IiLAogICJcdTJGNzUiLAogICJcdTdBRjkiLAogICJcdTJGNzYiLAogICJcdTdDNzMiLAogICJcdTJGNzciLAogICJcdTdDRjgiLAogICJcdTJGNzgiLAogICJcdTdGMzYiLAogICJcdTJGNzkiLAogICJcdTdGNTEiLAogICJcdTJGN0EiLAogICJcdTdGOEEiLAogICJcdTJGN0IiLAogICJcdTdGQkQiLAogICJcdTJGN0MiLAogICJcdTgwMDEiLAogICJcdTJGN0QiLAogICJcdTgwMEMiLAogICJcdTJGN0UiLAogICJcdTgwMTIiLAogICJcdTJGN0YiLAogICJcdTgwMzMiLAogICJcdTJGODAiLAogICJcdTgwN0YiLAogICJcdTJGODEiLAogICJcdTgwODkiLAogICJcdTJGODIiLAogICJcdTgxRTMiLAogICJcdTJGODMiLAogICJcdTgxRUEiLAogICJcdTJGODQiLAogICJcdTgxRjMiLAogICJcdTJGODUiLAogICJcdTgxRkMiLAogICJcdTJGODYiLAogICJcdTgyMEMiLAogICJcdTJGODciLAogICJcdTgyMUIiLAogICJcdTJGODgiLAogICJcdTgyMUYiLAogICJcdTJGODkiLAogICJcdTgyNkUiLAogICJcdTJGOEEiLAogICJcdTgyNzIiLAogICJcdTJGOEIiLAogICJcdTgyNzgiLAogICJcdTJGOEMiLAogICJcdTg2NEQiLAogICJcdTJGOEQiLAogICJcdTg2NkIiLAogICJcdTJGOEUiLAogICJcdTg4NDAiLAogICJcdTJGOEYiLAogICJcdTg4NEMiLAogICJcdTJGOTAiLAogICJcdTg4NjMiLAogICJcdTJGOTEiLAogICJcdTg5N0UiLAogICJcdTJGOTIiLAogICJcdTg5OEIiLAogICJcdTJGOTMiLAogICJcdTg5RDIiLAogICJcdTJGOTQiLAogICJcdThBMDAiLAogICJcdTJGOTUiLAogICJcdThDMzciLAogICJcdTJGOTYiLAogICJcdThDNDYiLAogICJcdTJGOTciLAogICJcdThDNTUiLAogICJcdTJGOTgiLAogICJcdThDNzgiLAogICJcdTJGOTkiLAogICJcdThDOUQiLAogICJcdTJGOUEiLAogICJcdThENjQiLAogICJcdTJGOUIiLAogICJcdThENzAiLAogICJcdTJGOUMiLAogICJcdThEQjMiLAogICJcdTJGOUQiLAogICJcdThFQUIiLAogICJcdTJGOUUiLAogICJcdThFQ0EiLAogICJcdTJGOUYiLAogICJcdThGOUIiLAogICJcdTJGQTAiLAogICJcdThGQjAiLAogICJcdTJGQTEiLAogICJcdThGQjUiLAogICJcdTJGQTIiLAogICJcdTkwOTEiLAogICJcdTJGQTMiLAogICJcdTkxNDkiLAogICJcdTJGQTQiLAogICJcdTkxQzYiLAogICJcdTJGQTUiLAogICJcdTkxQ0MiLAogICJcdTJGQTYiLAogICJcdTkxRDEiLAogICJcdTJGQTciLAogICJcdTk1NzciLAogICJcdTJGQTgiLAogICJcdTk1ODAiLAogICJcdTJGQTkiLAogICJcdTk2MUMiLAogICJcdTJGQUEiLAogICJcdTk2QjYiLAogICJcdTJGQUIiLAogICJcdTk2QjkiLAogICJcdTJGQUMiLAogICJcdTk2RTgiLAogICJcdTJGQUQiLAogICJcdTk3NTEiLAogICJcdTJGQUUiLAogICJcdTk3NUUiLAogICJcdTJGQUYiLAogICJcdTk3NjIiLAogICJcdTJGQjAiLAogICJcdTk3NjkiLAogICJcdTJGQjEiLAogICJcdTk3Q0IiLAogICJcdTJGQjIiLAogICJcdTk3RUQiLAogICJcdTJGQjMiLAogICJcdTk3RjMiLAogICJcdTJGQjQiLAogICJcdTk4MDEiLAogICJcdTJGQjUiLAogICJcdTk4QTgiLAogICJcdTJGQjYiLAogICJcdTk4REIiLAogICJcdTJGQjciLAogICJcdTk4REYiLAogICJcdTJGQjgiLAogICJcdTk5OTYiLAogICJcdTJGQjkiLAogICJcdTk5OTkiLAogICJcdTJGQkEiLAogICJcdTk5QUMiLAogICJcdTJGQkIiLAogICJcdTlBQTgiLAogICJcdTJGQkMiLAogICJcdTlBRDgiLAogICJcdTJGQkQiLAogICJcdTlBREYiLAogICJcdTJGQkUiLAogICJcdTlCMjUiLAogICJcdTJGQkYiLAogICJcdTlCMkYiLAogICJcdTJGQzAiLAogICJcdTlCMzIiLAogICJcdTJGQzEiLAogICJcdTlCM0MiLAogICJcdTJGQzIiLAogICJcdTlCNUEiLAogICJcdTJGQzMiLAogICJcdTlDRTUiLAogICJcdTJGQzQiLAogICJcdTlFNzUiLAogICJcdTJGQzUiLAogICJcdTlFN0YiLAogICJcdTJGQzYiLAogICJcdTlFQTUiLAogICJcdTJGQzciLAogICJcdTlFQkIiLAogICJcdTJGQzgiLAogICJcdTlFQzMiLAogICJcdTJGQzkiLAogICJcdTlFQ0QiLAogICJcdTJGQ0EiLAogICJcdTlFRDEiLAogICJcdTJGQ0IiLAogICJcdTlFRjkiLAogICJcdTJGQ0MiLAogICJcdTlFRkQiLAogICJcdTJGQ0QiLAogICJcdTlGMEUiLAogICJcdTJGQ0UiLAogICJcdTlGMTMiLAogICJcdTJGQ0YiLAogICJcdTlGMjAiLAogICJcdTJGRDAiLAogICJcdTlGM0IiLAogICJcdTJGRDEiLAogICJcdTlGNEEiLAogICJcdTJGRDIiLAogICJcdTlGNTIiLAogICJcdTJGRDMiLAogICJcdTlGOEQiLAogICJcdTJGRDQiLAogICJcdTlGOUMiLAogICJcdTJGRDUiLAogICJcdTlGQTAiLAogICJcdTMwMzYiLAogICJcdTMwMTIiLAogICJcdTMwMzgiLAogICJcdTUzNDEiLAogICJcdTMwMzkiLAogICJcdTUzNDQiLAogICJcdTMwM0EiLAogICJcdTUzNDUiLAogICJcdTMwOUIiLAogICJcdTAwMjBcdTMwOTkiLAogICJcdTMwOUMiLAogICJcdTAwMjBcdTMwOUEiLAogICJcdTMxMzEiLAogICJcdTExMDAiLAogICJcdTMxMzIiLAogICJcdTExMDEiLAogICJcdTMxMzMiLAogICJcdTExQUEiLAogICJcdTMxMzQiLAogICJcdTExMDIiLAogICJcdTMxMzUiLAogICJcdTExQUMiLAogICJcdTMxMzYiLAogICJcdTExQUQiLAogICJcdTMxMzciLAogICJcdTExMDMiLAogICJcdTMxMzgiLAogICJcdTExMDQiLAogICJcdTMxMzkiLAogICJcdTExMDUiLAogICJcdTMxM0EiLAogICJcdTExQjAiLAogICJcdTMxM0IiLAogICJcdTExQjEiLAogICJcdTMxM0MiLAogICJcdTExQjIiLAogICJcdTMxM0QiLAogICJcdTExQjMiLAogICJcdTMxM0UiLAogICJcdTExQjQiLAogICJcdTMxM0YiLAogICJcdTExQjUiLAogICJcdTMxNDAiLAogICJcdTExMUEiLAogICJcdTMxNDEiLAogICJcdTExMDYiLAogICJcdTMxNDIiLAogICJcdTExMDciLAogICJcdTMxNDMiLAogICJcdTExMDgiLAogICJcdTMxNDQiLAogICJcdTExMjEiLAogICJcdTMxNDUiLAogICJcdTExMDkiLAogICJcdTMxNDYiLAogICJcdTExMEEiLAogICJcdTMxNDciLAogICJcdTExMEIiLAogICJcdTMxNDgiLAogICJcdTExMEMiLAogICJcdTMxNDkiLAogICJcdTExMEQiLAogICJcdTMxNEEiLAogICJcdTExMEUiLAogICJcdTMxNEIiLAogICJcdTExMEYiLAogICJcdTMxNEMiLAogICJcdTExMTAiLAogICJcdTMxNEQiLAogICJcdTExMTEiLAogICJcdTMxNEUiLAogICJcdTExMTIiLAogICJcdTMxNEYiLAogICJcdTExNjEiLAogICJcdTMxNTAiLAogICJcdTExNjIiLAogICJcdTMxNTEiLAogICJcdTExNjMiLAogICJcdTMxNTIiLAogICJcdTExNjQiLAogICJcdTMxNTMiLAogICJcdTExNjUiLAogICJcdTMxNTQiLAogICJcdTExNjYiLAogICJcdTMxNTUiLAogICJcdTExNjciLAogICJcdTMxNTYiLAogICJcdTExNjgiLAogICJcdTMxNTciLAogICJcdTExNjkiLAogICJcdTMxNTgiLAogICJcdTExNkEiLAogICJcdTMxNTkiLAogICJcdTExNkIiLAogICJcdTMxNUEiLAogICJcdTExNkMiLAogICJcdTMxNUIiLAogICJcdTExNkQiLAogICJcdTMxNUMiLAogICJcdTExNkUiLAogICJcdTMxNUQiLAogICJcdTExNkYiLAogICJcdTMxNUUiLAogICJcdTExNzAiLAogICJcdTMxNUYiLAogICJcdTExNzEiLAogICJcdTMxNjAiLAogICJcdTExNzIiLAogICJcdTMxNjEiLAogICJcdTExNzMiLAogICJcdTMxNjIiLAogICJcdTExNzQiLAogICJcdTMxNjMiLAogICJcdTExNzUiLAogICJcdTMxNjQiLAogICJcdTExNjAiLAogICJcdTMxNjUiLAogICJcdTExMTQiLAogICJcdTMxNjYiLAogICJcdTExMTUiLAogICJcdTMxNjciLAogICJcdTExQzciLAogICJcdTMxNjgiLAogICJcdTExQzgiLAogICJcdTMxNjkiLAogICJcdTExQ0MiLAogICJcdTMxNkEiLAogICJcdTExQ0UiLAogICJcdTMxNkIiLAogICJcdTExRDMiLAogICJcdTMxNkMiLAogICJcdTExRDciLAogICJcdTMxNkQiLAogICJcdTExRDkiLAogICJcdTMxNkUiLAogICJcdTExMUMiLAogICJcdTMxNkYiLAogICJcdTExREQiLAogICJcdTMxNzAiLAogICJcdTExREYiLAogICJcdTMxNzEiLAogICJcdTExMUQiLAogICJcdTMxNzIiLAogICJcdTExMUUiLAogICJcdTMxNzMiLAogICJcdTExMjAiLAogICJcdTMxNzQiLAogICJcdTExMjIiLAogICJcdTMxNzUiLAogICJcdTExMjMiLAogICJcdTMxNzYiLAogICJcdTExMjciLAogICJcdTMxNzciLAogICJcdTExMjkiLAogICJcdTMxNzgiLAogICJcdTExMkIiLAogICJcdTMxNzkiLAogICJcdTExMkMiLAogICJcdTMxN0EiLAogICJcdTExMkQiLAogICJcdTMxN0IiLAogICJcdTExMkUiLAogICJcdTMxN0MiLAogICJcdTExMkYiLAogICJcdTMxN0QiLAogICJcdTExMzIiLAogICJcdTMxN0UiLAogICJcdTExMzYiLAogICJcdTMxN0YiLAogICJcdTExNDAiLAogICJcdTMxODAiLAogICJcdTExNDciLAogICJcdTMxODEiLAogICJcdTExNEMiLAogICJcdTMxODIiLAogICJcdTExRjEiLAogICJcdTMxODMiLAogICJcdTExRjIiLAogICJcdTMxODQiLAogICJcdTExNTciLAogICJcdTMxODUiLAogICJcdTExNTgiLAogICJcdTMxODYiLAogICJcdTExNTkiLAogICJcdTMxODciLAogICJcdTExODQiLAogICJcdTMxODgiLAogICJcdTExODUiLAogICJcdTMxODkiLAogICJcdTExODgiLAogICJcdTMxOEEiLAogICJcdTExOTEiLAogICJcdTMxOEIiLAogICJcdTExOTIiLAogICJcdTMxOEMiLAogICJcdTExOTQiLAogICJcdTMxOEQiLAogICJcdTExOUUiLAogICJcdTMxOEUiLAogICJcdTExQTEiLAogICJcdTMyMDAiLAogICJcdTAwMjhcdTExMDBcdTAwMjkiLAogICJcdTMyMDEiLAogICJcdTAwMjhcdTExMDJcdTAwMjkiLAogICJcdTMyMDIiLAogICJcdTAwMjhcdTExMDNcdTAwMjkiLAogICJcdTMyMDMiLAogICJcdTAwMjhcdTExMDVcdTAwMjkiLAogICJcdTMyMDQiLAogICJcdTAwMjhcdTExMDZcdTAwMjkiLAogICJcdTMyMDUiLAogICJcdTAwMjhcdTExMDdcdTAwMjkiLAogICJcdTMyMDYiLAogICJcdTAwMjhcdTExMDlcdTAwMjkiLAogICJcdTMyMDciLAogICJcdTAwMjhcdTExMEJcdTAwMjkiLAogICJcdTMyMDgiLAogICJcdTAwMjhcdTExMENcdTAwMjkiLAogICJcdTMyMDkiLAogICJcdTAwMjhcdTExMEVcdTAwMjkiLAogICJcdTMyMEEiLAogICJcdTAwMjhcdTExMEZcdTAwMjkiLAogICJcdTMyMEIiLAogICJcdTAwMjhcdTExMTBcdTAwMjkiLAogICJcdTMyMEMiLAogICJcdTAwMjhcdTExMTFcdTAwMjkiLAogICJcdTMyMEQiLAogICJcdTAwMjhcdTExMTJcdTAwMjkiLAogICJcdTMyMEUiLAogICJcdTAwMjhcdTExMDBcdTExNjFcdTAwMjkiLAogICJcdTMyMEYiLAogICJcdTAwMjhcdTExMDJcdTExNjFcdTAwMjkiLAogICJcdTMyMTAiLAogICJcdTAwMjhcdTExMDNcdTExNjFcdTAwMjkiLAogICJcdTMyMTEiLAogICJcdTAwMjhcdTExMDVcdTExNjFcdTAwMjkiLAogICJcdTMyMTIiLAogICJcdTAwMjhcdTExMDZcdTExNjFcdTAwMjkiLAogICJcdTMyMTMiLAogICJcdTAwMjhcdTExMDdcdTExNjFcdTAwMjkiLAogICJcdTMyMTQiLAogICJcdTAwMjhcdTExMDlcdTExNjFcdTAwMjkiLAogICJcdTMyMTUiLAogICJcdTAwMjhcdTExMEJcdTExNjFcdTAwMjkiLAogICJcdTMyMTYiLAogICJcdTAwMjhcdTExMENcdTExNjFcdTAwMjkiLAogICJcdTMyMTciLAogICJcdTAwMjhcdTExMEVcdTExNjFcdTAwMjkiLAogICJcdTMyMTgiLAogICJcdTAwMjhcdTExMEZcdTExNjFcdTAwMjkiLAogICJcdTMyMTkiLAogICJcdTAwMjhcdTExMTBcdTExNjFcdTAwMjkiLAogICJcdTMyMUEiLAogICJcdTAwMjhcdTExMTFcdTExNjFcdTAwMjkiLAogICJcdTMyMUIiLAogICJcdTAwMjhcdTExMTJcdTExNjFcdTAwMjkiLAogICJcdTMyMUMiLAogICJcdTAwMjhcdTExMENcdTExNkVcdTAwMjkiLAogICJcdTMyMUQiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMENcdTExNjVcdTExQUJcdTAwMjkiLAogICJcdTMyMUUiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMTJcdTExNkVcdTAwMjkiLAogICJcdTMyMjAiLAogICJcdTAwMjhcdTRFMDBcdTAwMjkiLAogICJcdTMyMjEiLAogICJcdTAwMjhcdTRFOENcdTAwMjkiLAogICJcdTMyMjIiLAogICJcdTAwMjhcdTRFMDlcdTAwMjkiLAogICJcdTMyMjMiLAogICJcdTAwMjhcdTU2REJcdTAwMjkiLAogICJcdTMyMjQiLAogICJcdTAwMjhcdTRFOTRcdTAwMjkiLAogICJcdTMyMjUiLAogICJcdTAwMjhcdTUxNkRcdTAwMjkiLAogICJcdTMyMjYiLAogICJcdTAwMjhcdTRFMDNcdTAwMjkiLAogICJcdTMyMjciLAogICJcdTAwMjhcdTUxNkJcdTAwMjkiLAogICJcdTMyMjgiLAogICJcdTAwMjhcdTRFNURcdTAwMjkiLAogICJcdTMyMjkiLAogICJcdTAwMjhcdTUzNDFcdTAwMjkiLAogICJcdTMyMkEiLAogICJcdTAwMjhcdTY3MDhcdTAwMjkiLAogICJcdTMyMkIiLAogICJcdTAwMjhcdTcwNkJcdTAwMjkiLAogICJcdTMyMkMiLAogICJcdTAwMjhcdTZDMzRcdTAwMjkiLAogICJcdTMyMkQiLAogICJcdTAwMjhcdTY3MjhcdTAwMjkiLAogICJcdTMyMkUiLAogICJcdTAwMjhcdTkxRDFcdTAwMjkiLAogICJcdTMyMkYiLAogICJcdTAwMjhcdTU3MUZcdTAwMjkiLAogICJcdTMyMzAiLAogICJcdTAwMjhcdTY1RTVcdTAwMjkiLAogICJcdTMyMzEiLAogICJcdTAwMjhcdTY4MkFcdTAwMjkiLAogICJcdTMyMzIiLAogICJcdTAwMjhcdTY3MDlcdTAwMjkiLAogICJcdTMyMzMiLAogICJcdTAwMjhcdTc5M0VcdTAwMjkiLAogICJcdTMyMzQiLAogICJcdTAwMjhcdTU0MERcdTAwMjkiLAogICJcdTMyMzUiLAogICJcdTAwMjhcdTcyNzlcdTAwMjkiLAogICJcdTMyMzYiLAogICJcdTAwMjhcdThDQTFcdTAwMjkiLAogICJcdTMyMzciLAogICJcdTAwMjhcdTc5NURcdTAwMjkiLAogICJcdTMyMzgiLAogICJcdTAwMjhcdTUyQjRcdTAwMjkiLAogICJcdTMyMzkiLAogICJcdTAwMjhcdTRFRTNcdTAwMjkiLAogICJcdTMyM0EiLAogICJcdTAwMjhcdTU0N0NcdTAwMjkiLAogICJcdTMyM0IiLAogICJcdTAwMjhcdTVCNjZcdTAwMjkiLAogICJcdTMyM0MiLAogICJcdTAwMjhcdTc2RTNcdTAwMjkiLAogICJcdTMyM0QiLAogICJcdTAwMjhcdTRGMDFcdTAwMjkiLAogICJcdTMyM0UiLAogICJcdTAwMjhcdThDQzdcdTAwMjkiLAogICJcdTMyM0YiLAogICJcdTAwMjhcdTUzNTRcdTAwMjkiLAogICJcdTMyNDAiLAogICJcdTAwMjhcdTc5NkRcdTAwMjkiLAogICJcdTMyNDEiLAogICJcdTAwMjhcdTRGMTFcdTAwMjkiLAogICJcdTMyNDIiLAogICJcdTAwMjhcdTgxRUFcdTAwMjkiLAogICJcdTMyNDMiLAogICJcdTAwMjhcdTgxRjNcdTAwMjkiLAogICJcdTMyQzAiLAogICJcdTAwMzFcdTY3MDgiLAogICJcdTMyQzEiLAogICJcdTAwMzJcdTY3MDgiLAogICJcdTMyQzIiLAogICJcdTAwMzNcdTY3MDgiLAogICJcdTMyQzMiLAogICJcdTAwMzRcdTY3MDgiLAogICJcdTMyQzQiLAogICJcdTAwMzVcdTY3MDgiLAogICJcdTMyQzUiLAogICJcdTAwMzZcdTY3MDgiLAogICJcdTMyQzYiLAogICJc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AogICJcdTMzRjQiLAogICJcdTAwMzJcdTAwMzFcdTY1RTUiLAogICJcdTMzRjUiLAogICJcdTAwMzJcdTAwMzJcdTY1RTUiLAogICJcdTMzRjYiLAogICJcdTAwMzJcdTAwMzNcdTY1RTUiLAogICJcdTMzRjciLAogICJcdTAwMzJcdTAwMzRcdTY1RTUiLAogICJcdTMzRjgiLAogICJcdTAwMzJcdTAwMzVcdTY1RTUiLAogICJcdTMzRjkiLAogICJcdTAwMzJcdTAwMzZcdTY1RTUiLAogICJcdTMzRkEiLAogICJcdTAwMzJcdTAwMzdcdTY1RTUiLAogICJcdTMzRkIiLAogICJcdTAwMzJcdTAwMzhcdTY1RTUiLAogICJcdTMzRkMiLAogICJcdTAwMzJcdTAwMzlcdTY1RTUiLAogICJcdTMzRkQiLAogICJcdTAwMzNcdTAwMzBcdTY1RTUiLAogICJcdTMzRkUiLAogICJcdTAwMzNcdTAwMzFcdTY1RTUiLAogICJcdUZCMDAiLAogICJcdTAwNjZcdTAwNjYiLAogICJcdUZCMDEiLAogICJcdTAwNjZcdTAwNjkiLAogICJcdUZCMDIiLAogICJcdTAwNjZcdTAwNkMiLAogICJcdUZCMDMiLAogICJcdTAwNjZcdTAwNjZcdTAwNjkiLAogICJcdUZCMDQiLAogICJcdTAwNjZcdTAwNjZcdTAwNkMiLAogICJcdUZCMDUiLAogICJcdTAxN0ZcdTAwNzQiLAogICJcdUZCMDYiLAogICJcdTAwNzNcdTAwNzQiLAogICJcdUZCMTMiLAogICJcdTA1NzRcdTA1NzYiLAogICJcdUZCMTQiLAogICJcdTA1NzRcdTA1NjUiLAogICJcdUZCMTUiLAogICJcdTA1NzRcdTA1NkIiLAogICJcdUZCMTYiLAogICJcdTA1N0VcdTA1NzYiLAogICJcdUZCMTciLAogICJcdTA1NzRcdTA1NkQiLAogICJcdUZCNEYiLAogICJcdTA1RDBcdTA1REMiLAogICJcdUZCNTAiLAogICJcdTA2NzEiLAogICJcdUZCNTEiLAogICJcdTA2NzEiLAogICJcdUZCNTIiLAogICJcdTA2N0IiLAogICJcdUZCNTMiLAogICJcdTA2N0IiLAogICJcdUZCNTQiLAogICJcdTA2N0IiLAogICJcdUZCNTUiLAogICJcdTA2N0IiLAogICJcdUZCNTYiLAogICJcdTA2N0UiLAogICJcdUZCNTciLAogICJcdTA2N0UiLAogICJcdUZCNTgiLAogICJcdTA2N0UiLAogICJcdUZCNTkiLAogICJcdTA2N0UiLAogICJcdUZCNUEiLAogICJcdTA2ODAiLAogICJcdUZCNUIiLAogICJcdTA2ODAiLAogICJcdUZCNUMiLAogICJcdTA2ODAiLAogICJcdUZCNUQiLAogICJcdTA2ODAiLAogICJcdUZCNUUiLAogICJcdTA2N0EiLAogICJcdUZCNUYiLAogICJcdTA2N0EiLAogICJcdUZCNjAiLAogICJcdTA2N0EiLAogICJcdUZCNjEiLAogICJcdTA2N0EiLAogICJcdUZCNjIiLAogICJcdTA2N0YiLAogICJcdUZCNjMiLAogICJcdTA2N0YiLAogICJcdUZCNjQiLAogICJcdTA2N0YiLAogICJcdUZCNjUiLAogICJcdTA2N0YiLAogICJcdUZCNjYiLAogICJcdTA2NzkiLAogICJcdUZCNjciLAogICJcdTA2NzkiLAogICJcdUZCNjgiLAogICJcdTA2NzkiLAogICJcdUZCNjkiLAogICJcdTA2NzkiLAogICJcdUZCNkEiLAogICJcdTA2QTQiLAogICJcdUZCNkIiLAogICJcdTA2QTQiLAogICJcdUZCNkMiLAogICJcdTA2QTQiLAogICJcdUZCNkQiLAogICJcdTA2QTQiLAogICJcdUZCNkUiLAogICJcdTA2QTYiLAogICJcdUZCNkYiLAogICJcdTA2QTYiLAogICJcdUZCNzAiLAogICJcdTA2QTYiLAogICJcdUZCNzEiLAogICJcdTA2QTYiLAogICJcdUZCNzIiLAogICJcdTA2ODQiLAogICJcdUZCNzMiLAogICJcdTA2ODQiLAogICJcdUZCNzQiLAogICJcdTA2ODQiLAogICJcdUZCNzUiLAogICJcdTA2ODQiLAogICJcdUZCNzYiLAogICJcdTA2ODMiLAogICJcdUZCNzciLAogICJcdTA2ODMiLAogICJcdUZCNzgiLAogICJcdTA2ODMiLAogICJcdUZCNzkiLAogICJcdTA2ODMiLAogICJcdUZCN0EiLAogICJcdTA2ODYiLAogICJcdUZCN0IiLAogICJcdTA2ODYiLAogICJcdUZCN0MiLAogICJcdTA2ODYiLAogICJcdUZCN0QiLAogICJcdTA2ODYiLAogICJcdUZCN0UiLAogICJcdTA2ODciLAogICJcdUZCN0YiLAogICJcdTA2ODciLAogICJcdUZCODAiLAogICJcdTA2ODciLAogICJcdUZCODEiLAogICJcdTA2ODciLAogICJcdUZCODIiLAogICJcdTA2OEQiLAogICJcdUZCODMiLAogICJcdTA2OEQiLAogICJcdUZCODQiLAogICJcdTA2OEMiLAogICJcdUZCODUiLAogICJcdTA2OEMiLAogICJcdUZCODYiLAogICJcdTA2OEUiLAogICJcdUZCODciLAogICJcdTA2OEUiLAogICJcdUZCODgiLAogICJcdTA2ODgiLAogICJcdUZCODkiLAogICJcdTA2ODgiLAogICJcdUZCOEEiLAogICJcdTA2OTgiLAogICJcdUZCOEIiLAogICJcdTA2OTgiLAogICJcdUZCOEMiLAogICJcdTA2OTEiLAogICJcdUZCOEQiLAogICJcdTA2OTEiLAogICJcdUZCOEUiLAogICJcdTA2QTkiLAogICJcdUZCOEYiLAogICJcdTA2QTkiLAogICJcdUZCOTAiLAogICJcdTA2QTkiLAogICJcdUZCOTEiLAogICJcdTA2QTkiLAogICJcdUZCOTIiLAogICJcdTA2QUYiLAogICJcdUZCOTMiLAogICJcdTA2QUYiLAogICJcdUZCOTQiLAogICJcdTA2QUYiLAogICJcdUZCOTUiLAogICJcdTA2QUYiLAogICJcdUZCOTYiLAogICJcdTA2QjMiLAogICJcdUZCOTciLAogICJcdTA2QjMiLAogICJcdUZCOTgiLAogICJcdTA2QjMiLAogICJcdUZCOTkiLAogICJcdTA2QjMiLAogICJcdUZCOUEiLAogICJcdTA2QjEiLAogICJcdUZCOUIiLAogICJcdTA2QjEiLAogICJcdUZCOUMiLAogICJcdTA2QjEiLAogICJcdUZCOUQiLAogICJcdTA2QjEiLAogICJcdUZCOUUiLAogICJcdTA2QkEiLAogICJcdUZCOUYiLAogICJcdTA2QkEiLAogICJcdUZCQTAiLAogICJcdTA2QkIiLAogICJcdUZCQTEiLAogICJcdTA2QkIiLAogICJcdUZCQTIiLAogICJcdTA2QkIiLAogICJcdUZCQTMiLAogICJcdTA2QkIiLAogICJcdUZCQTQiLAogICJcdTA2QzAiLAogICJcdUZCQTUiLAogICJcdTA2QzAiLAogICJcdUZCQTYiLAogICJcdTA2QzEiLAogICJcdUZCQTciLAogICJcdTA2QzEiLAogICJcdUZCQTgiLAogICJcdTA2QzEiLAogICJcdUZCQTkiLAogICJcdTA2QzEiLAogICJcdUZCQUEiLAogICJcdTA2QkUiLAogICJcdUZCQUIiLAogICJcdTA2QkUiLAogICJcdUZCQUMiLAogICJcdTA2QkUiLAogICJcdUZCQUQiLAogICJcdTA2QkUiLAogICJcdUZCQUUiLAogICJcdTA2RDIiLAogICJcdUZCQUYiLAogICJcdTA2RDIiLAogICJcdUZCQjAiLAogICJcdTA2RDMiLAogICJcdUZCQjEiLAogICJcdTA2RDMiLAogICJcdUZCRDMiLAogICJcdTA2QUQiLAogICJcdUZCRDQiLAogICJcdTA2QUQiLAogICJcdUZCRDUiLAogICJcdTA2QUQiLAogICJcdUZCRDYiLAogICJcdTA2QUQiLAogICJcdUZCRDciLAogICJcdTA2QzciLAogICJcdUZCRDgiLAogICJcdTA2QzciLAogICJcdUZCRDkiLAogICJcdTA2QzYiLAogICJcdUZCREEiLAogICJcdTA2QzYiLAogICJcdUZCREIiLAogICJcdTA2QzgiLAogICJcdUZCREMiLAogICJcdTA2QzgiLAogICJcdUZCREQiLAogICJcdTA2NzciLAogICJcdUZCREUiLAogICJcdTA2Q0IiLAogICJcdUZCREYiLAogICJcdTA2Q0IiLAogICJcdUZCRTAiLAogICJcdTA2QzUiLAogICJcdUZCRTEiLAogICJcdTA2QzUiLAogICJcdUZCRTIiLAogICJcdTA2QzkiLAogICJcdUZCRTMiLAogICJcdTA2QzkiLAogICJcdUZCRTQiLAogICJcdTA2RDAiLAogICJcdUZCRTUiLAogICJcdTA2RDAiLAogICJcdUZCRTYiLAogICJcdTA2RDAiLAogICJcdUZCRTciLAogICJcdTA2RDAiLAogICJcdUZCRTgiLAogICJcdTA2NDkiLAogICJcdUZCRTkiLAogICJcdTA2NDkiLAogICJcdUZCRUEiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUIiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUMiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUQiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUUiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRUYiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRjAiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjEiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjIiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjMiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjQiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjUiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjYiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjciLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjgiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjkiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkEiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkIiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkMiLAogICJcdTA2Q0MiLAogICJcdUZCRkQiLAogICJcdTA2Q0MiLAogICJcdUZCRkUiLAogICJcdTA2Q0MiLAogICJcdUZCRkYiLAogICJcdTA2Q0MiLAogICJcdUZDMDAiLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDMDEiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDMDIiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDMDMiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDMDQiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDMDUiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDMDYiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDMDciLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDMDgiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDMDkiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDMEEiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDMEIiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDMEMiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDMEQiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDMEUiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDMEYiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDMTAiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDMTEiLAogICJcdTA2MkJcdTA2MkMiLAogICJcdUZDMTIiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDMTMiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDMTQiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDMTUiLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDMTYiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDMTciLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDMTgiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDMTkiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDMUEiLAogICJcdTA2MkVcdTA2MkQiLAogICJcdUZDMUIiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDMUMiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDMUQiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDMUUiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDMUYiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDMjAiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDMjEiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDMjIiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDMjMiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDMjQiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDMjUiLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDMjYiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDMjciLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZDMjgiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDMjkiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDMkEiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDMkIiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDMkMiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDMkQiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDMkUiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDMkYiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDMzAiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDMzEiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDMzIiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDMzMiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDMzQiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDMzUiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDMzYiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDMzciLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDMzgiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDMzkiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDM0EiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDM0IiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDM0MiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDM0QiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDM0UiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDM0YiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDNDAiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDNDEiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDNDIiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDNDMiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDNDQiLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDNDUiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDNDYiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDNDciLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDNDgiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDNDkiLAogICJcdTA2NDVcdTA2NDkiLAogICJcdUZDNEEiLAogICJcdTA2NDVcdTA2NEEiLAogICJcdUZDNEIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDNEMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDNEQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDNEUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDNEYiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDNTAiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDNTEiLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDNTIiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDNTMiLAogICJcdTA2NDdcdTA2NDkiLAogICJcdUZDNTQiLAogICJcdTA2NDdcdTA2NEEiLAogICJcdUZDNTUiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDNTYiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDNTciLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDNTgiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDNTkiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDNUEiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDNUIiLAogICJcdTA2MzBcdTA2NzAiLAogICJcdUZDNUMiLAogICJcdTA2MzFcdTA2NzAiLAogICJcdUZDNUQiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDNUUiLAogICJcdTAwMjBcdTA2NENcdTA2NTEiLAogICJcdUZDNUYiLAogICJcdTAwMjBcdTA2NERcdTA2NTEiLAogICJcdUZDNjAiLAogICJcdTAwMjBcdTA2NEVcdTA2NTEiLAogICJcdUZDNjEiLAogICJcdTAwMjBcdTA2NEZcdTA2NTEiLAogICJcdUZDNjIiLAogICJcdTAwMjBcdTA2NTBcdTA2NTEiLAogICJcdUZDNjMiLAogICJcdTAwMjBcdTA2NTFcdTA2NzAiLAogICJcdUZDNjQiLAogICJcdTA2MjZcdTA2MzEiLAogICJcdUZDNjUiLAogICJcdTA2MjZcdTA2MzIiLAogICJcdUZDNjYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDNjciLAogICJcdTA2MjZcdTA2NDYiLAogICJcdUZDNjgiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDNjkiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDNkEiLAogICJcdTA2MjhcdTA2MzEiLAogICJcdUZDNkIiLAogICJcdTA2MjhcdTA2MzIiLAogICJcdUZDNkMiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDNkQiLAogICJcdTA2MjhcdTA2NDYiLAogICJcdUZDNkUiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDNkYiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDNzAiLAogICJcdTA2MkFcdTA2MzEiLAogICJcdUZDNzEiLAogICJcdTA2MkFcdTA2MzIiLAogICJcdUZDNzIiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDNzMiLAogICJcdTA2MkFcdTA2NDYiLAogICJcdUZDNzQiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDNzUiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDNzYiLAogICJcdTA2MkJcdTA2MzEiLAogICJcdUZDNzciLAogICJcdTA2MkJcdTA2MzIiLAogICJcdUZDNzgiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDNzkiLAogICJcdTA2MkJcdTA2NDYiLAogICJcdUZDN0EiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDN0IiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDN0MiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDN0QiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDN0UiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDN0YiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDODAiLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDODEiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDODIiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDODMiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDODQiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDODUiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDODYiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDODciLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDODgiLAogICJcdTA2NDVcdTA2MjciLAogICJcdUZDODkiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDOEEiLAogICJcdTA2NDZcdTA2MzEiLAogICJcdUZDOEIiLAogICJcdTA2NDZcdTA2MzIiLAogICJcdUZDOEMiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDOEQiLAogICJcdTA2NDZcdTA2NDYiLAogICJcdUZDOEUiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDOEYiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDOTAiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDOTEiLAogICJcdTA2NEFcdTA2MzEiLAogICJcdUZDOTIiLAogICJcdTA2NEFcdTA2MzIiLAogICJcdUZDOTMiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDOTQiLAogICJcdTA2NEFcdTA2NDYiLAogICJcdUZDOTUiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDOTYiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDOTciLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDOTgiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDOTkiLAogICJcdTA2MjZcdTA2MkUiLAogICJcdUZDOUEiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDOUIiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDOUMiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDOUQiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDOUUiLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDOUYiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDQTAiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDQTEiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDQTIiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDQTMiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDQTQiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDQTUiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDQTYiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDQTciLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDQTgiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDQTkiLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDQUEiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDQUIiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDQUMiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDQUQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDQUUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDQUYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDQjAiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDQjEiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDQjIiLAogICJcdTA2MzVcdTA2MkUiLAogICJcdUZDQjMiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDQjQiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDQjUiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDQjYiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDQjciLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDQjgiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDQjkiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDQkEiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDQkIiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDQkMiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDQkQiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDQkUiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDQkYiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDQzAiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDQzEiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDQzIiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDQzMiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDQzQiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDQzUiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDQzYiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDQzciLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDQzgiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDQzkiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDQ0EiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDQ0IiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDQ0MiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDQ0QiLAogICJcdTA2NDRcdTA2NDciLAogICJcdUZDQ0UiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDQ0YiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDRDAiLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDRDEiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDRDIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDRDMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDRDQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDRDUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRDYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRDciLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDRDgiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDRDkiLAogICJcdTA2NDdcdTA2NzAiLAogICJcdUZDREEiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDREIiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDREMiLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDREQiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDREUiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDREYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDRTAiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDRTEiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDRTIiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDRTMiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDRTQiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDRTUiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDRTYiLAogICJcdTA2MkJcdTA2NDciLAogICJcdUZDRTciLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDRTgiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZDRTkiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZDRUEiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZDRUIiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDRUMiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDRUQiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDRUUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRUYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRjAiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDRjEiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDRjIiLAogICJcdTA2NDBcdTA2NEVcdTA2NTEiLAogICJcdUZDRjMiLAogICJcdTA2NDBcdTA2NEZcdTA2NTEiLAogICJcdUZDRjQiLAogICJcdTA2NDBcdTA2NTBcdTA2NTEiLAogICJcdUZDRjUiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZDRjYiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZDRjciLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZDRjgiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZDRjkiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZDRkEiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZDRkIiLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZDRkMiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZDRkQiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZDRkUiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZDRkYiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMDAiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMDEiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMDIiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMDMiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMDQiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMDUiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMDYiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMDciLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMDgiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMDkiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMEEiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMEIiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMEMiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMEQiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMEUiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMEYiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMTAiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMTEiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZEMTIiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZEMTMiLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZEMTQiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZEMTUiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZEMTYiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZEMTciLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZEMTgiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZEMTkiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZEMUEiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZEMUIiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMUMiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMUQiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMUUiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMUYiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMjAiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMjEiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMjIiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMjMiLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMjQiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMjUiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMjYiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMjciLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMjgiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMjkiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMkEiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMkIiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMkMiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMkQiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMkUiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMkYiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMzAiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMzEiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZEMzIiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZEMzMiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEMzQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZEMzUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZEMzYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZEMzciLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMzgiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMzkiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEM0EiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEM0IiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZEM0MiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZEM0QiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZENTAiLAogICJcdTA2MkFcdTA2MkNcdTA2NDUiLAogICJcdUZENTEiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTIiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTMiLAogICJcdTA2MkFcdTA2MkRcdTA2NDUiLAogICJcdUZENTQiLAogICJcdTA2MkFcdTA2MkVcdTA2NDUiLAogICJcdUZENTUiLAogICJcdTA2MkFcdTA2NDVcdTA2MkMiLAogICJcdUZENTYiLAogICJcdTA2MkFcdTA2NDVcdTA2MkQiLAogICJcdUZENTciLAogICJcdTA2MkFcdTA2NDVcdTA2MkUiLAogICJcdUZENTgiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENTkiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENUEiLAogICJcdTA2MkRcdTA2NDVcdTA2NEEiLAogICJcdUZENUIiLAogICJcdTA2MkRcdTA2NDVcdTA2NDkiLAogICJcdUZENUMiLAogICJcdTA2MzNcdTA2MkRcdTA2MkMiLAogICJcdUZENUQiLAogICJcdTA2MzNcdTA2MkNcdTA2MkQiLAogICJcdUZENUUiLAogICJcdTA2MzNcdTA2MkNcdTA2NDkiLAogICJcdUZENUYiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjAiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjEiLAogICJcdTA2MzNcdTA2NDVcdTA2MkMiLAogICJcdUZENjIiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjMiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjQiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjUiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjYiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZENjciLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjgiLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjkiLAogICJcdTA2MzRcdTA2MkNcdTA2NEEiLAogICJcdUZENkEiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkIiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkMiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkQiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkUiLAogICJcdTA2MzZcdTA2MkRcdTA2NDkiLAogICJcdUZENkYiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzAiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzEiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzIiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzMiLAogICJcdTA2MzdcdTA2NDVcdTA2NDUiLAogICJcdUZENzQiLAogICJcdTA2MzdcdTA2NDVcdTA2NEEiLAogICJcdUZENzUiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZENzYiLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzciLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzgiLAogICJcdTA2MzlcdTA2NDVcdTA2NDkiLAogICJcdUZENzkiLAogICJcdTA2M0FcdTA2NDVcdTA2NDUiLAogICJcdUZEN0EiLAogICJcdTA2M0FcdTA2NDVcdTA2NEEiLAogICJcdUZEN0IiLAogICJcdTA2M0FcdTA2NDVcdTA2NDkiLAogICJcdUZEN0MiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0QiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0UiLAogICJcdTA2NDJcdTA2NDVcdTA2MkQiLAogICJcdUZEN0YiLAogICJcdTA2NDJcdTA2NDVcdTA2NDUiLAogICJcdUZEODAiLAogICJcdTA2NDRcdTA2MkRcdTA2NDUiLAogICJcdUZEODEiLAogICJcdTA2NDRcdTA2MkRcdTA2NEEiLAogICJcdUZEODIiLAogICJcdTA2NDRcdTA2MkRcdTA2NDkiLAogICJcdUZEODMiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODQiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODUiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODYiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODciLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODgiLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODkiLAogICJcdTA2NDVcdTA2MkRcdTA2MkMiLAogICJcdUZEOEEiLAogICJcdTA2NDVcdTA2MkRcdTA2NDUiLAogICJcdUZEOEIiLAogICJcdTA2NDVcdTA2MkRcdTA2NEEiLAogICJcdUZEOEMiLAogICJcdTA2NDVcdTA2MkNcdTA2MkQiLAogICJcdUZEOEQiLAogICJcdTA2NDVcdTA2MkNcdTA2NDUiLAogICJcdUZEOEUiLAogICJcdTA2NDVcdTA2MkVcdTA2MkMiLAogICJcdUZEOEYiLAogICJcdTA2NDVcdTA2MkVcdTA2NDUiLAogICJcdUZEOTIiLAogICJcdTA2NDVcdTA2MkNcdTA2MkUiLAogICJcdUZEOTMiLAogICJcdTA2NDdcdTA2NDVcdTA2MkMiLAogICJcdUZEOTQiLAogICJcdTA2NDdcdTA2NDVcdTA2NDUiLAogICJcdUZEOT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2NDUiLAogICJcdUZEQzQiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZEQzUiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZEQzYiLAogICJcdTA2MzNcdTA2MkVcdTA2NEEiLAogICJcdUZEQzciLAogICJcdTA2NDZcdTA2MkNcdTA2NEEiLAogICJcdUZFNDkiLAogICJcdTIwM0UiLAogICJcdUZFNEEiLAogICJcdTIwM0UiLAogICJcdUZFNEIiLAogICJcdTIwM0UiLAogICJcdUZFNEMiLAogICJcdTIwM0UiLAogICJcdUZFNEQiLAogICJcdTAwNUYiLAogICJcdUZFNEUiLAogICJcdTAwNUYiLAogICJcdUZFNEYiLAogICJcdTAwNUYiLAogICJcdUZFODAiLAogICJcdTA2MjEiLAogICJcdUZFODEiLAogICJcdTA2MjIiLAogICJcdUZFODIiLAogICJcdTA2MjIiLAogICJcdUZFODMiLAogICJcdTA2MjMiLAogICJcdUZFODQiLAogICJcdTA2MjMiLAogICJcdUZFODUiLAogICJcdTA2MjQiLAogICJcdUZFODYiLAogICJcdTA2MjQiLAogICJcdUZFODciLAogICJcdTA2MjUiLAogICJcdUZFODgiLAogICJcdTA2MjUiLAogICJcdUZFODkiLAogICJcdTA2MjYiLAogICJcdUZFOEEiLAogICJcdTA2MjYiLAogICJcdUZFOEIiLAogICJcdTA2MjYiLAogICJcdUZFOEMiLAogICJcdTA2MjYiLAogICJcdUZFOEQiLAogICJcdTA2MjciLAogICJcdUZFOEUiLAogICJcdTA2MjciLAogICJcdUZFOEYiLAogICJcdTA2MjgiLAogICJcdUZFOTAiLAogICJcdTA2MjgiLAogICJcdUZFOTEiLAogICJcdTA2MjgiLAogICJcdUZFOTIiLAogICJcdTA2MjgiLAogICJcdUZFOTMiLAogICJcdTA2MjkiLAogICJcdUZFOTQiLAogICJcdTA2MjkiLAogICJcdUZFOTUiLAogICJcdTA2MkEiLAogICJcdUZFOTYiLAogICJcdTA2MkEiLAogICJcdUZFOTciLAogICJcdTA2MkEiLAogICJcdUZFOTgiLAogICJcdTA2MkEiLAogICJcdUZFOTkiLAogICJcdTA2MkIiLAogICJcdUZFOUEiLAogICJcdTA2MkIiLAogICJcdUZFOUIiLAogICJcdTA2MkIiLAogICJcdUZFOUMiLAogICJcdTA2MkIiLAogICJcdUZFOUQiLAogICJcdTA2MkMiLAogICJcdUZFOUUiLAogICJcdTA2MkMiLAogICJcdUZFOUYiLAogICJcdTA2MkMiLAogICJcdUZFQTAiLAogICJcdTA2MkMiLAogICJcdUZFQTEiLAogICJcdTA2MkQiLAogICJcdUZFQTIiLAogICJcdTA2MkQiLAogICJcdUZFQTMiLAogICJcdTA2MkQiLAogICJcdUZFQTQiLAogICJcdTA2MkQiLAogICJcdUZFQTUiLAogICJcdTA2MkUiLAogICJcdUZFQTYiLAogICJcdTA2MkUiLAogICJcdUZFQTciLAogICJcdTA2MkUiLAogICJcdUZFQTgiLAogICJcdTA2MkUiLAogICJcdUZFQTkiLAogICJcdTA2MkYiLAogICJcdUZFQUEiLAogICJcdTA2MkYiLAogICJcdUZFQUIiLAogICJcdTA2MzAiLAogICJcdUZFQUMiLAogICJcdTA2MzAiLAogICJcdUZFQUQiLAogICJcdTA2MzEiLAogICJcdUZFQUUiLAogICJcdTA2MzEiLAogICJcdUZFQUYiLAogICJcdTA2MzIiLAogICJcdUZFQjAiLAogICJcdTA2MzIiLAogICJcdUZFQjEiLAogICJcdTA2MzMiLAogICJcdUZFQjIiLAogICJcdTA2MzMiLAogICJcdUZFQjMiLAogICJcdTA2MzMiLAogICJcdUZFQjQiLAogICJcdTA2MzMiLAogICJcdUZFQjUiLAogICJcdTA2MzQiLAogICJcdUZFQjYiLAogICJcdTA2MzQiLAogICJcdUZFQjciLAogICJcdTA2MzQiLAogICJcdUZFQjgiLAogICJcdTA2MzQiLAogICJcdUZFQjkiLAogICJcdTA2MzUiLAogICJcdUZFQkEiLAogICJcdTA2MzUiLAogICJcdUZFQkIiLAogICJcdTA2MzUiLAogICJcdUZFQkMiLAogICJcdTA2MzUiLAogICJcdUZFQkQiLAogICJcdTA2MzYiLAogICJcdUZFQkUiLAogICJcdTA2MzYiLAogICJcdUZFQkYiLAogICJcdTA2MzYiLAogICJcdUZFQzAiLAogICJcdTA2MzYiLAogICJcdUZFQzEiLAogICJcdTA2MzciLAogICJcdUZFQzIiLAogICJcdTA2MzciLAogICJcdUZFQzMiLAogICJcdTA2MzciLAogICJcdUZFQzQiLAogICJcdTA2MzciLAogICJcdUZFQzUiLAogICJcdTA2MzgiLAogICJcdUZFQzYiLAogICJcdTA2MzgiLAogICJcdUZFQzciLAogICJcdTA2MzgiLAogICJcdUZFQzgiLAogICJcdTA2MzgiLAogICJcdUZFQzkiLAogICJcdTA2MzkiLAogICJcdUZFQ0EiLAogICJcdTA2MzkiLAogICJcdUZFQ0IiLAogICJcdTA2MzkiLAogICJcdUZFQ0MiLAogICJcdTA2MzkiLAogICJcdUZFQ0QiLAogICJcdTA2M0EiLAogICJcdUZFQ0UiLAogICJcdTA2M0EiLAogICJcdUZFQ0YiLAogICJcdTA2M0EiLAogICJcdUZFRDAiLAogICJcdTA2M0EiLAogICJcdUZFRDEiLAogICJcdTA2NDEiLAogICJcdUZFRDIiLAogICJcdTA2NDEiLAogICJcdUZFRDMiLAogICJcdTA2NDEiLAogICJcdUZFRDQiLAogICJcdTA2NDEiLAogICJcdUZFRDUiLAogICJcdTA2NDIiLAogICJcdUZFRDYiLAogICJcdTA2NDIiLAogICJcdUZFRDciLAogICJcdTA2NDIiLAogICJcdUZFRDgiLAogICJcdTA2NDIiLAogICJcdUZFRDkiLAogICJcdTA2NDMiLAogICJcdUZFREEiLAogICJcdTA2NDMiLAogICJcdUZFREIiLAogICJcdTA2NDMiLAogICJcdUZFREMiLAogICJcdTA2NDMiLAogICJcdUZFREQiLAogICJcdTA2NDQiLAogICJcdUZFREUiLAogICJcdTA2NDQiLAogICJcdUZFREYiLAogICJcdTA2NDQiLAogICJcdUZFRTAiLAogICJcdTA2NDQiLAogICJcdUZFRTEiLAogICJcdTA2NDUiLAogICJcdUZFRTIiLAogICJcdTA2NDUiLAogICJcdUZFRTMiLAogICJcdTA2NDUiLAogICJcdUZFRTQiLAogICJcdTA2NDUiLAogICJcdUZFRTUiLAogICJcdTA2NDYiLAogICJcdUZFRTYiLAogICJcdTA2NDYiLAogICJcdUZFRTciLAogICJcdTA2NDYiLAogICJcdUZFRTgiLAogICJcdTA2NDYiLAogICJcdUZFRTkiLAogICJcdTA2NDciLAogICJcdUZFRUEiLAogICJcdTA2NDciLAogICJcdUZFRUIiLAogICJcdTA2NDciLAogICJcdUZFRUMiLAogICJcdTA2NDciLAogICJcdUZFRUQiLAogICJcdTA2NDgiLAogICJcdUZFRUUiLAogICJcdTA2NDgiLAogICJcdUZFRUYiLAogICJcdTA2NDkiLAogICJcdUZFRjAiLAogICJcdTA2NDkiLAogICJcdUZFRjEiLAogICJcdTA2NEEiLAogICJcdUZFRjIiLAogICJcdTA2NEEiLAogICJcdUZFRjMiLAogICJcdTA2NEEiLAogICJcdUZFRjQiLAogICJcdTA2NEEiLAogICJcdUZFRjUiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjYiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjciLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjgiLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjkiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkEiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkIiLAogICJcdTA2NDRcdTA2MjciLAogICJcdUZFRkMiLAogICJcdTA2NDRcdTA2MjciCiBdOwp9KTsKZnVuY3Rpb24gcmV2ZXJzZUlmUnRsKGNoYXJzKSB7CiBjb25zdCBjaGFyc0xlbmd0aCA9IGNoYXJzLmxlbmd0aDsKIGlmIChjaGFyc0xlbmd0aCA8PSAxIHx8ICFpc1JUTFJhbmdlRm9yKGNoYXJzLmNoYXJDb2RlQXQoMCkpKSB7CiA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iAgICB9KTsKICB9CiAgZnVuY3Rpb24gbGluZVRvKHgsIHkpIHsKICAgIGNtZHMucHVzaCh7CiAgICAgIGNtZDogImxpbmVUbyIsCiAgICAgIGFyZ3M6IFt4LCB5XQogICAgfSk7CiAgfQogIGZ1bmN0aW9uIHF1YWRyYXRpY0N1cnZlVG8oeGEsIHlhLCB4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJxdWFkcmF0aWNDdXJ2ZVRvIiwKICAgICAgYXJnczogW3hhLCB5YSwgeCwgeV0KICAgIH0pOwogIH0KICBsZXQgaSA9IDA7CiAgY29uc3QgbnVtYmVyT2ZDb250b3VycyA9IGdldEludDE2KGNvZGUsIGkpOwogIGxldCBmbGFnczsKICBsZXQgeCA9IDAsCiAgICB5ID0gMDsKICBpICs9IDEwOwogIGlmIChudW1iZXJPZkNvbnRvdXJzIDwgMCkgewogICAgZG8gewogICAgICBmbGFncyA9IGdldFVpbnQxNihjb2RlLCBpKTsKICAgICAgY29uc3QgZ2x5cGhJbmRleCA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgIGkgKz0gNDsKICAgICAgbGV0IGFyZzEsIGFyZzI7CiAgICAgIGlmIChmbGFncyAmIDB4MDEpIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBhcmcyID0gZ2V0SW50MTYoY29kZSwgaSArIDIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBhcmcxID0gZ2V0VWludDE2KGNvZGUsIGkpOwogICAgICAgICAgYXJnMiA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgICAgfQogICAgICAgIGkgKz0gNDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50OChjb2RlLCBpKyspOwogICAgICAgICAgYXJnMiA9IGdldEludDgoY29kZSwgaSsrKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYXJnMSA9IGNvZGVbaSsrXTsKICAgICAgICAgIGFyZzIgPSBjb2RlW2krK107CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChmbGFncyAmIDB4MDIpIHsKICAgICAgICB4ID0gYXJnMTsKICAgICAgICB5ID0gYXJnMjsKICAgICAgfSBlbHNlIHsKICAgICAgICB4ID0gMDsKICAgICAgICB5ID0gMDsKICAgICAgfQogICAgICBsZXQgc2NhbGVYID0gMSwKICAgICAgICBzY2FsZVkgPSAxLAogICAgICAgIHNjYWxlMDEgPSAwLAogICAgICAgIHNjYWxlMTAgPSAwOwogICAgICBpZiAoZmxhZ3MgJiAweDA4KSB7CiAgICAgICAgc2NhbGVYID0gc2NhbGVZID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgaSArPSAyOwogICAgICB9IGVsc2UgaWYgKGZsYWdzICYgMHg0MCkgewogICAgICAgIHNjYWxlWCA9IGdldEZsb2F0MjE0KGNvZGUsIGkpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0gZWxzZSBpZiAoZmxhZ3MgJiAweDgwKSB7CiAgICAgICAgc2NhbGVYID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgc2NhbGUwMSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBzY2FsZTEwID0gZ2V0RmxvYXQyMTQoY29kZSwgaSArIDQpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyA2KTsKICAgICAgICBpICs9IDg7CiAgICAgIH0KICAgICAgY29uc3Qgc3ViZ2x5cGggPSBmb250LmdseXBoc1tnbHlwaEluZGV4XTsKICAgICAgaWYgKHN1YmdseXBoKSB7CiAgICAgICAgY21kcy5wdXNoKHsKICAgICAgICAgIGNtZDogInNhdmUiCiAgICAgICAgfSwgewogICAgICAgICAgY21kOiAidHJhbnNmb3JtIiwKICAgICAgICAgIGFyZ3M6IFtzY2FsZVgsIHNjYWxlMDEsIHNjYWxlMTAsIHNjYWxlWSwgeCwgeV0KICAgICAgICB9KTsKICAgICAgICBpZiAoIShmbGFncyAmIDB4MDIpKSB7fQogICAgICAgIGNvbXBpbGVHbHlmKHN1YmdseXBoLCBjbWRzLCBmb250KTsKICAgICAgICBjbWRzLnB1c2goewogICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICB9KTsKICAgICAgfQogICAgfSB3aGlsZSAoZmxhZ3MgJiAweDIwKTsKICB9IGVsc2UgewogICAgY29uc3QgZW5kUHRzT2ZDb250b3VycyA9IFtdOwogICAgbGV0IGosIGpqOwogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mQ29udG91cnM7IGorKykgewogICAgICBlbmRQdHNPZkNvbnRvdXJzLnB1c2goZ2V0VWludDE2KGNvZGUsIGkpKTsKICAgICAgaSArPSAyOwogICAgfQogICAgY29uc3QgaW5zdHJ1Y3Rpb25MZW5ndGggPSBnZXRVaW50MTYoY29kZSwgaSk7CiAgICBpICs9IDIgKyBpbnN0cnVjdGlvbkxlbmd0aDsKICAgIGNvbnN0IG51bWJlck9mUG9pbnRzID0gZW5kUHRzT2ZDb250b3Vycy5hdCgtMSkgKyAxOwogICAgY29uc3QgcG9pbnRzID0gW107CiAgICB3aGlsZSAocG9pbnRzLmxlbmd0aCA8IG51bWJlck9mUG9pbnRzKSB7CiAgICAgIGZsYWdzID0gY29kZVtpKytdOwogICAgICBsZXQgcmVwZWF0ID0gMTsKICAgICAgaWYgKGZsYWdzICYgMHgwOCkgewogICAgICAgIHJlcGVhdCArPSBjb2RlW2krK107CiAgICAgIH0KICAgICAgd2hpbGUgKHJlcGVhdC0tID4gMCkgewogICAgICAgIHBvaW50cy5wdXNoKHsKICAgICAgICAgIGZsYWdzCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIGZvciAoaiA9IDA7IGogPCBudW1iZXJPZlBvaW50czsgaisrKSB7CiAgICAgIHN3aXRjaCAocG9pbnRzW2pdLmZsYWdzICYgMHgxMikgewogICAgICAgIGNhc2UgMHgwMDoKICAgICAgICAgIHggKz0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBpICs9IDI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDI6CiAgICAgICAgICB4IC09IGNvZGVbaSsrXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgxMjoKICAgICAgICAgIHggKz0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgcG9pbnRzW2pdLnggPSB4OwogICAgfQogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mUG9pbnRzOyBqKyspIHsKICAgICAgc3dpdGNoIChwb2ludHNbal0uZmxhZ3MgJiAweDI0KSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgeSArPSBnZXRJbnQxNihjb2RlLCBpKTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgwNDoKICAgICAgICAgIHkgLT0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI0OgogICAgICAgICAgeSArPSBjb2RlW2krK107CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwb2ludHNbal0ueSA9IHk7CiAgICB9CiAgICBsZXQgc3RhcnRQb2ludCA9IDA7CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtYmVyT2ZDb250b3VyczsgaSsrKSB7CiAgICAgIGNvbnN0IGVuZFBvaW50ID0gZW5kUHRzT2ZDb250b3Vyc1tpXTsKICAgICAgY29uc3QgY29udG91ciA9IHBvaW50cy5zbGljZShzdGFydFBvaW50LCBlbmRQb2ludCArIDEpOwogICAgICBpZiAoY29udG91clswXS5mbGFncyAmIDEpIHsKICAgICAgICBjb250b3VyLnB1c2goY29udG91clswXSk7CiAgICAgIH0gZWxzZSBpZiAoY29udG91ci5hdCgtMSkuZmxhZ3MgJiAxKSB7CiAgICAgICAgY29udG91ci51bnNoaWZ0KGNvbnRvdXIuYXQoLTEpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBwID0gewogICAgICAgICAgZmxhZ3M6IDEsCiAgICAgICAgICB4OiAoY29udG91clswXS54ICsgY29udG91ci5hdCgtMSkueCkgLyAyLAogICAgICAgICAgeTogKGNvbnRvdXJbMF0ueSArIGNvbnRvdXIuYXQoLTEpLnkpIC8gMgogICAgICAgIH07CiAgICAgICAgY29udG91ci51bnNoaWZ0KHApOwogICAgICAgIGNvbnRvdXIucHVzaChwKTsKICAgICAgfQogICAgICBtb3ZlVG8oY29udG91clswXS54LCBjb250b3VyWzBdLnkpOwogICAgICBmb3IgKGogPSAxLCBqaiA9IGNvbnRvdXIubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgIGlmIChjb250b3VyW2pdLmZsYWdzICYgMSkgewogICAgICAgICAgbGluZVRvKGNvbnRvdXJbal0ueCwgY29udG91cltqXS55KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbnRvdXJbaiArIDFdLmZsYWdzICYgMSkgewogICAgICAgICAgcXVhZHJhdGljQ3VydmVUbyhjb250b3VyW2pdLngsIGNvbnRvdXJbal0ueSwgY29udG91cltqICsgMV0ueCwgY29udG91cltqICsgMV0ueSk7CiAgICAgICAgICBqKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHF1YWRyYXRpY0N1cnZlVG8oY29udG91cltqXS54LCBjb250b3VyW2pdLnksIChjb250b3VyW2pdLnggKyBjb250b3VyW2ogKyAxXS54KSAvIDIsIChjb250b3VyW2pdLnkgKyBjb250b3VyW2ogKyAxXS55KSAvIDIpOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGFydFBvaW50ID0gZW5kUG9pbnQgKyAxOwogICAgfQogIH0KfQp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AgICBicmVhazsKICAgICAgICBjYXNlIDQ6CiAgICAgICAgICB5ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA2OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNzoKICAgICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDg6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxMDoKICAgICAgICAgIG4gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN1YnJDb2RlID0gbnVsbDsKICAgICAgICAgIGlmIChmb250LmlzQ0ZGQ0lERm9udCkgewogICAgICAgICAgICBjb25zdCBmZEluZGV4ID0gZm9udC5mZFNlbGVjdC5nZXRGREluZGV4KGdseXBoSWQpOwogICAgICAgICAgICBpZiAoZmRJbmRleCA+PSAwICYmIGZkSW5kZXggPCBmb250LmZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgY29uc3QgZm9udERpY3QgPSBmb250LmZkQXJyYXlbZmRJbmRleF07CiAgICAgICAgICAgICAgbGV0IHN1YnJzOwogICAgICAgICAgICAgIGlmIChmb250RGljdC5wcml2YXRlRGljdCAmJiBmb250RGljdC5wcml2YXRlRGljdC5zdWJyc0luZGV4KSB7CiAgICAgICAgICAgICAgICBzdWJycyA9IGZvbnREaWN0LnByaXZhdGVEaWN0LnN1YnJzSW5kZXgub2JqZWN0czsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHN1YnJzKSB7CiAgICAgICAgICAgICAgICBuICs9IGdldFN1YnJvdXRpbmVCaWFzKHN1YnJzKTsKICAgICAgICAgICAgICAgIHN1YnJDb2RlID0gc3VicnNbbl07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSW52YWxpZCBmZCBpbmRleCBmb3IgZ2x5cGggaW5kZXguIik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN1YnJDb2RlID0gZm9udC5zdWJyc1tuICsgZm9udC5zdWJyc0JpYXNdOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTE6CiAgICAgICAgICByZXR1cm47CiAgICAgICAgY2FzZSAxMjoKICAgICAgICAgIHYgPSBjb2RlW2krK107CiAgICAgICAgICBzd2l0Y2ggKHYpIHsKICAgICAgICAgICAgY2FzZSAzNDoKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkxID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5LCB4YiwgeTEsIHgsIHkxKTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5LCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNToKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMzY6CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5MSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkyID0geTEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5MiwgeCwgeTIpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeTMgPSB5MiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5MiwgeGIsIHkzLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNzoKICAgICAgICAgICAgICBjb25zdCB4MCA9IHgsCiAgICAgICAgICAgICAgICB5MCA9IHk7CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICAgIHkgPSB5YjsKICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoeCAtIHgwKSA+IE1hdGguYWJzKHkgLSB5MCkpIHsKICAgICAgICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgeSArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYHVua25vd24gb3BlcmF0b3I6IDEyICR7dn1gKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTQ6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID49IDQpIHsKICAgICAgICAgICAgY29uc3QgYWNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgYmNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgeSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICB4ID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAic2F2ZSIKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgIGNtZDogInRyYW5zbGF0ZSIsCiAgICAgICAgICAgICAgYXJnczogW3gsIHldCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBsZXQgY21hcCA9IGxvb2t1cENtYXAoZm9udC5jbWFwLCBTdHJpbmcuZnJvbUNoYXJDb2RlKGZvbnQuZ2x5cGhOYW1lTWFwW19lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZ1thY2hhcl1dKSk7CiAgICAgICAgICAgIGNvbXBpbGVDaGFyU3RyaW5nKGZvbnQuZ2x5cGhzW2NtYXAuZ2x5cGhJZF0sIGNtZHMsIGZvbnQsIGNtYXAuZ2x5cGhJZCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGNtYXAgPSBsb29rdXBDbWFwKGZvbnQuY21hcCwgU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdseXBoTmFtZU1hcFtfZW5jb2RpbmdzLlN0YW5kYXJkRW5jb2RpbmdbYmNoYXJdXSkpOwogICAgICAgICAgICBjb21waWxlQ2hhclN0cmluZyhmb250LmdseXBoc1tjbWFwLmdseXBoSWRdLCBjbWRzLCBmb250LCBjbWFwLmdseXBoSWQpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIGNhc2UgMTg6CiAgICAgICAgICBzdGVtcyArPSBzdGFjay5sZW5ndGggPj4gMTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOToKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMDoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMToKICAgICAgICAgIHkgKz0gc3RhY2sucG9wKCk7CiAgICAgICAgICB4ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDIyOgogICAgICAgICAgeCArPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG1vdmVUbyh4LCB5KTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI0OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDIpIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gNikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjY6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjc6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjg6CiAgICAgICAgICBzdGFjay5wdXNoKChjb2RlW2ldIDw8IDI0IHwgY29kZVtpICsgMV0gPDwgMTYpID4+IDE2KTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjk6CiAgICAgICAgICBuID0gc3RhY2sucG9wKCkgKyBmb250LmdzdWJyc0JpYXM7CiAgICAgICAgICBzdWJyQ29kZSA9IGZvbnQuZ3N1YnJzW25dOwogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzA6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDMxOgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5OwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeGEgPSB4OwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmICh2IDwgMzIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGB1bmtub3duIG9wZXJhdG9yOiAke3Z9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodiA8IDI0NykgewogICAgICAgICAgICBzdGFjay5wdXNoKHYgLSAxMzkpOwogICAgICAgICAgfSBlbHNlIGlmICh2IDwgMjUxKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goKHYgLSAyNDcpICogMjU2ICsgY29kZVtpKytdICsgMTA4KTsKICAgICAgICAgIH0gZWxzZSBpZiAodiA8IDI1NSkgewogICAgICAgICAgICBzdGFjay5wdXNoKC0odiAtIDI1MSkgKiAyNTYgLSBjb2RlW2krK10gLSAxMDgpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaCgoY29kZVtpXSA8PCAyNCB8IGNvZGVbaSArIDFdIDw8IDE2IHwgY29kZVtpICsgMl0gPDwgOCB8IGNvZGVbaSArIDNdKSAvIDY1NTM2KTsKICAgICAgICAgICAgaSArPSA0OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHN0YWNrQ2xlYW4pIHsKICAgICAgICBzdGFjay5sZW5ndGggPSAwOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlKGNoYXJTdHJpbmdDb2RlKTsKfQpjb25zdCBOT09QID0gW107CmNsYXNzIENvbXBpbGVkRm9udCB7CiAgY29uc3RydWN0b3IoZm9udE1hdHJpeCkgewogICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IENvbXBpbGVkRm9udCkgewogICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJDYW5ub3QgaW5pdGlhbGl6ZSBDb21waWxlZEZvbnQuIik7CiAgICB9CiAgICB0aGlzLmZvbnRNYXRyaXggPSBmb250TWF0cml4OwogICAgdGhpcy5jb21waWxlZEdseXBocyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIH0KICBnZXRQYXRoSnModW5pY29kZSkgewogICAgY29uc3QgewogICAgICBjaGFyQ29kZSwKICAgICAgZ2x5cGhJZAogICAgfSA9IGxvb2t1cENtYXAodGhpcy5jbWFwLCB1bmljb2RlKTsKICAgIGxldCBmbiA9IHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF07CiAgICBpZiAoIWZuKSB7CiAgICAgIHRyeSB7CiAgICAgICAgZm4gPSB0aGlzLmNvbXBpbGVHbHlwaCh0aGlzLmdseXBoc1tnbHlwaElkXSwgZ2x5cGhJZCk7CiAgICAgICAgdGhpcy5jb21waWxlZEdseXBoc1tnbHlwaElkXSA9IGZuOwogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF0gPSBOT09QOwogICAgICAgIGlmICh0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPT09IHVuZGVmaW5lZCkgewogICAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgIH0KICAgIHJldHVybiBmbjsKICB9CiAgY29tcGlsZUdseXBoKGNvZGUsIGdseXBoSWQpIHsKICAgIGlmICghY29kZSB8fCBjb2RlLmxlbmd0aCA9PT0gMCB8fCBjb2RlWzBdID09PSAxNCkgewogICAgICByZXR1cm4gTk9PUDsKICAgIH0KICAgIGxldCBmb250TWF0cml4ID0gdGhpcy5mb250TWF0cml4OwogICAgaWYgKHRoaXMuaXNDRkZDSURGb250KSB7CiAgICAgIGNvbnN0IGZkSW5kZXggPSB0aGlzLmZkU2VsZWN0LmdldEZESW5kZXgoZ2x5cGhJZCk7CiAgICAgIGlmIChmZEluZGV4ID49IDAgJiYgZmRJbmRleCA8IHRoaXMuZmRBcnJheS5sZW5ndGgpIHsKICAgICAgICBjb25zdCBmb250RGljdCA9IHRoaXMuZmRBcnJheVtmZEluZGV4XTsKICAgICAgICBmb250TWF0cml4ID0gZm9udERpY3QuZ2V0QnlOYW1lKCJGb250TWF0cml4IikgfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZGV4IGZvciBnbHlwaCBpbmRleC4iKTsKICAgICAgfQogICAgfQogICAgY29uc3QgY21kcyA9IFt7CiAgICAgIGNtZDogInNhdmUiCiAgICB9LCB7CiAgICAgIGNtZDogInRyYW5zZm9ybSIsCiAgICAgIGFyZ3M6IGZvbnRNYXRyaXguc2xpY2UoKQogICAgfSwgewogICAgICBjbWQ6ICJzY2FsZSIsCiAgICAgIGFyZ3M6IFsic2l6ZSIsICItc2l6ZSJdCiAgICB9XTsKICAgIHRoaXMuY29tcGlsZUdseXBoSW1wbChjb2RlLCBjbWRzLCBnbHlwaElkKTsKICAgIGNtZHMucHVzaCh7CiAgICAgIGNtZDogInJlc3RvcmUiCiAgICB9KTsKICAgIHJldHVybiBjbWRzOwogIH0KICBjb21waWxlR2x5cGhJbXBsKCkgewogICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2hpbGRyZW4gY2xhc3NlcyBzaG91bGQgaW1wbGVtZW50IHRoaXMuIik7CiAgfQogIGhhc0J1aWx0UGF0aCh1bmljb2RlKSB7CiAgICBjb25zdCB7CiAgICAgIGNoYXJDb2RlLAogICAgICBnbHlwaElkCiAgICB9ID0gbG9va3VwQ21hcCh0aGlz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Mjc4OwogICAgdC5oeXBoZW4gPSAzMzM7CiAgICB0LnBlcmlvZCA9IDI3ODsKICAgIHQuc2xhc2ggPSAyNzg7CiAgICB0Lnplcm8gPSA1NTY7CiAgICB0Lm9uZSA9IDU1NjsKICAgIHQudHdvID0gNTU2OwogICAgdC50aHJlZSA9IDU1NjsKICAgIHQuZm91ciA9IDU1NjsKICAgIHQuZml2ZSA9IDU1NjsKICAgIHQuc2l4ID0gNTU2OwogICAgdC5zZXZlbiA9IDU1NjsKICAgIHQuZWlnaHQgPSA1NTY7CiAgICB0Lm5pbmUgPSA1NTY7CiAgICB0LmNvbG9uID0gMjc4OwogICAgdC5zZW1pY29sb24gPSAyNzg7CiAgICB0Lmxlc3MgPSA1ODQ7CiAgICB0LmVxdWFsID0gNTg0OwogICAgdC5ncmVhdGVyID0gNTg0OwogICAgdC5xdWVzdGlvbiA9IDU1NjsKICAgIHQuYXQgPSAxMDE1OwogICAgdC5BID0gNjY3OwogICAgdC5CID0gNjY3OwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTAwOwogICAgdC5LID0gNjY3OwogICAgdC5MID0gNTU2OwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgdC5XID0gOTQ0OwogICAgdC5YID0gNjY3OwogICAgdC5ZID0gNjY3OwogICAgdC5aID0gNjExOwogICAgdC5icmFja2V0bGVmdCA9IDI3ODsKICAgIHQuYmFja3NsYXNoID0gMjc4OwogICAgdC5icmFja2V0cmlnaHQgPSAyNzg7CiAgICB0LmFzY2lpY2l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Nzg7CiAgICB0LnNsYXNoID0gMjc4OwogICAgdC56ZXJvID0gNTU2OwogICAgdC5vbmUgPSA1NTY7CiAgICB0LnR3byA9IDU1NjsKICAgIHQudGhyZWUgPSA1NTY7CiAgICB0LmZvdXIgPSA1NTY7CiAgICB0LmZpdmUgPSA1NTY7CiAgICB0LnNpeCA9IDU1NjsKICAgIHQuc2V2ZW4gPSA1NTY7CiAgICB0LmVpZ2h0ID0gNTU2OwogICAgdC5uaW5lID0gNTU2OwogICAgdC5jb2xvbiA9IDMzMzsKICAgIHQuc2VtaWNvbG9uID0gMzMzOwogICAgdC5sZXNzID0gNTg0OwogICAgdC5lcXVhbCA9IDU4NDsKICAgIHQuZ3JlYXRlciA9IDU4NDsKICAgIHQucXVlc3Rpb24gPSA2MTE7CiAgICB0LmF0ID0gOTc1OwogICAgdC5BID0gNzIyOwogICAgdC5CID0gNzIyOwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTU2OwogICAgdC5LID0gNzIyOwogICAgdC5MID0gNjExOwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgdC5XID0gOTQ0OwogICAgdC5YID0gNjY3OwogICAgdC5ZID0gNjY3OwogICAgdC5aID0gNjExOwogICAgdC5icmFja2V0bGVmdCA9IDMzMzsKICAgIHQuYmFja3NsYXNoID0gMjc4OwogICAgdC5icmFja2V0cmlnaHQgPSAzMzM7CiAgICB0LmFzY2lpY2lyY3VtID0gNTg0OwogICAgdC51bmRlcnNjb3JlID0gNTU2OwogICAgdC5xdW90ZW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ICAgdC5hID0gNTU2OwogICAgdC5iID0gNjExOwogICAgdC5jID0gNTU2OwogICAgdC5kID0gNjExOwogICAgdC5lID0gNTU2OwogICAgdC5mID0gMzMzOwogICAgdC5nID0gNjExOwogICAgdC5oID0gNjExOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNTU2OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gODg5OwogICAgdC5uID0gNjExOwogICAgdC5vID0gNjExOwogICAgdC5wID0gNjExOwogICAgdC5xID0gNjExOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gNTU2OwogICAgdC50ID0gMzMzOwogICAgdC51ID0gNjExOwogICAgdC52ID0gNTU2OwogICAgdC53ID0gNzc4OwogICAgdC54ID0gNTU2OwogICAgdC55ID0gNTU2OwogICAgdC56ID0gNTAwOwogICAgdC5icmFjZWxlZnQgPSAzODk7CiAgICB0LmJhciA9IDI4MDsKICAgIHQuYnJhY2VyaWdodCA9IDM4OTsKICAgIHQuYXNjaWl0aWxkZSA9IDU4NDsKICAgIHQuZXhjbGFtZG93biA9IDMzMzsKICAgIHQuY2VudCA9IDU1NjsKICAgIHQuc3RlcmxpbmcgPSA1NTY7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1NTY7CiAgICB0LmZsb3JpbiA9IDU1NjsKICAgIHQuc2VjdGlvbiA9IDU1NjsKICAgIHQuY3VycmVuY3kgPSA1NTY7CiAgICB0LnF1b3Rlc2luZ2xlID0gMjM4OwogICAgdC5xdW90ZWRibGxlZnQgPSA1MDA7CiAgICB0Lmd1aWxsZW1vdGxlZnQgPSA1NTY7CiAgICB0Lmd1aWxzaW5nbGxlZnQgPSAzMzM7CiAgICB0Lmd1aWxzaW5nbHJpZ2h0ID0gMzMzOwogICAgdC5maSA9IDYxMTsKICAgIHQuZmwgPSA2MTE7CiAgICB0LmVuZGFzaCA9IDU1NjsKICAgIHQuZGFnZ2VyID0gNTU2OwogICAgdC5kYWdnZ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bXBvc2l0ZXMpIHsKICAgICAgICBjb21wb3NpdGUuc2NhbGUoeE1pZGRsZSwgZmFjdG9yKTsKICAgICAgfQogICAgfQogIH0KfQpjbGFzcyBHbHlwaEhlYWRlciB7CiAgY29uc3RydWN0b3IoX3JlZjMpIHsKICAgIGxldCB7CiAgICAgIG51bWJlck9mQ29udG91cnMsCiAgICAgIHhNaW4sCiAgICAgIHlNaW4sCiAgICAgIHhNYXgsCiAgICAgIHlNYXgKICAgIH0gPSBfcmVmMzsKICAgIHRoaXMubnVtYmVyT2ZDb250b3VycyA9IG51bWJlck9mQ29udG91cnM7CiAgICB0aGlzLnhNaW4gPSB4TWluOwogICAgdGhpcy55TWluID0geU1pbjsKICAgIHRoaXMueE1heCA9IHhNYXg7CiAgICB0aGlzLnlNYXggPSB5TWF4OwogIH0KICBzdGF0aWMgcGFyc2UocG9zLCBnbHlmKSB7CiAgICByZXR1cm4gWzEwLCBuZXcgR2x5cGhIZWFkZXIoewogICAgICBudW1iZXJPZkNvbnRvdXJzOiBnbHlmLmdldEludDE2KHBvcyksCiAgICAgIHhNaW46IGdseWYuZ2V0SW50MTYocG9zICsgMiksCiAgICAgIHlNaW46IGdseWYuZ2V0SW50MTYocG9zICsgNCksCiAgICAgIHhNYXg6IGdseWYuZ2V0SW50MTYocG9zICsgNiksCiAgICAgIHlNYXg6IGdseWYuZ2V0SW50MTYocG9zICsgOCkKICAgIH0pXTsKICB9CiAgZ2V0U2l6ZSgpIHsKICAgIHJldHVybiAxMDsKICB9CiAgd3JpdGUocG9zLCBidWYpIHsKICAgIGJ1Zi5zZXRJbnQxNihwb3MsIHRoaXMubnVtYmVyT2ZDb250b3Vycyk7CiAgICBidWYuc2V0SW50MTYocG9zICsgMiwgdGhpcy54TWluKTsKICAgIGJ1Zi5zZXRJbnQxNihwb3MgKyA0LCB0aGlzLnlNaW4pOwogICAgYnVmLnNldEludDE2KHBvcyArIDYsIHRoaXMueE1heCk7CiAgICBidWYuc2V0SW50MTYocG9zICs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XQgc2l6ZSA9IHRoaXMuY29udG91cnMubGVuZ3RoICogMiArIDIgKyB0aGlzLmluc3RydWN0aW9ucy5sZW5ndGg7CiAgICBsZXQgbGFzdFggPSAwOwogICAgbGV0IGxhc3RZID0gMDsKICAgIGZvciAoY29uc3QgY29udG91ciBvZiB0aGlzLmNvbnRvdXJzKSB7CiAgICAgIHNpemUgKz0gY29udG91ci5mbGFncy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGNvbnRvdXIueENvb3JkaW5hdGVzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCB4ID0gY29udG91ci54Q29vcmRpbmF0ZXNbaV07CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGxldCBhYnMgPSBNYXRoLmFicyh4IC0gbGFzdFgpOwogICAgICAgIGlmIChhYnMgPiAyNTUpIHsKICAgICAgICAgIHNpemUgKz0gMjsKICAgICAgICB9IGVsc2UgaWYgKGFicyA+IDApIHsKICAgICAgICAgIHNpemUgKz0gMTsKICAgICAgICB9CiAgICAgICAgbGFzdFggPSB4OwogICAgICAgIGFicyA9IE1hdGguYWJzKHkgLSBsYXN0WSk7CiAgICAgICAgaWYgKGFicyA+IDI1NSkgewogICAgICAgICAgc2l6ZSArPSAyOwogICAgICAgIH0gZWxzZSBpZiAoYWJzID4gMCkgewogICAgICAgICAgc2l6ZSArPSAxOwogICAgICAgIH0KICAgICAgICBsYXN0WSA9IHk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBzaXplOwogIH0KICB3cml0ZShwb3MsIGJ1ZikgewogICAgY29uc3Qgc3BvcyA9IHBvczsKICAgIGNvbnN0IHhDb29yZGluYXRlcyA9IFtdOwogICAgY29uc3QgeUNvb3JkaW5hdGVzID0gW107CiAgICBjb25zdCBmbGFncyA9IFtdOwogICAgbGV0IGxhc3RYID0gMDsKICAgIGxldCBsYXN0WSA9IDA7CiAgICBmb3IgKGNvbnN0IGNvbnRvdXIgb2YgdGhpcy5jb250b3VycykgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjb250b3VyLnhDb29yZGluYXRlcy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgbGV0IGZsYWcgPSBjb250b3VyLmZsYWdzW2ldOwogICAgICAgIGNvbnN0IHggPSBjb250b3VyLnhDb29yZGluYXRlc1tpXTsKICAgICAgICBsZXQgZGVsdGEgPSB4IC0gbGFzdFg7CiAgICAgICAgaWYgKGRlbHRhID09PSAwKSB7CiAgICAgICAgICBmbGFnIHw9IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgIHhDb29yZGluYXRlcy5wdXNoKDApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBhYnMgPSBNYXRoLmFicyhkZWx0YSk7CiAgICAgICAgICBpZiAoYWJzIDw9IDI1NSkgewogICAgICAgICAgICBmbGFnIHw9IGRlbHRhID49IDAgPyBYX1NIT1JUX1ZFQ1RPUiB8IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUiA6IFhfU0hPUlRfVkVDVE9SOwogICAgICAgICAgICB4Q29vcmRpbmF0ZXMucHVzaChhYnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgeENvb3JkaW5hdGVzLnB1c2goZGVsdGEpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsYXN0WCA9IHg7CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGRlbHRhID0geSAtIGxhc3RZOwogICAgICAgIGlmIChkZWx0YSA9PT0gMCkgewogICAgICAgICAgZmxhZyB8PSBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1I7CiAgICAgICAgICB5Q29vcmRpbmF0ZXMucHVzaCgwKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgYWJzID0gTWF0aC5hYnMoZGVsdGEpOwogICAgICAgICAgaWYgKGFicyA8PSAyNTUpIHsKICAgICAgICAgICAgZmxhZyB8PSBkZWx0YSA+PSAwID8gWV9TSE9SVF9WRUNUT1IgfCBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1IgOiBZX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgICAgeUNvb3JkaW5hdGVzLnB1c2goYWJzKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHlDb29yZGluYXRlcy5wdXNoKGRlbHRhKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgbGFzdFkgPSB5OwogICAgICAgIGZsYWdzLnB1c2goZmxhZyk7CiAgICAgIH0KICAgICAgYnVmLnNldFVpbnQxNihwb3MsIHhDb29yZGluYXRlcy5sZW5ndGggLSAxKTsKICAgICAgcG9zICs9IDI7CiAgICB9CiAgICBidWYuc2V0VWludDE2KHBvcywgdGhpcy5pbnN0cnVjdGlvbnMubGVuZ3RoKTsKICAgIHBvcyArPSAyOwogICAgaWYgKHRoaXMuaW5zdHJ1Y3Rpb25zLmxlbmd0aCkgewogICAgICBuZXcgVWludDhBcnJheShidWYuYnVmZmVyLCAwLCBidWYuYnVmZmVyLmJ5dGVMZW5ndGgpLnNldCh0aGlzLmluc3RydWN0aW9ucywgcG9zKTsKICAgICAgcG9zICs9IHRoaXMuaW5zdHJ1Y3Rpb25zLmxlbmd0aDsKICAgIH0KICAgIGZvciAoY29uc3QgZmxhZyBvZiBmbGFncykgewogICAgICBidWYuc2V0VWludDgocG9zKyssIGZsYWcpOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0geENvb3JkaW5hdGVzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgY29uc3QgeCA9IHhDb29yZGluYXRlc1tpXTsKICAgICAgY29uc3QgZmxhZyA9IGZsY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vdW50LCBlbnRyeVNpemUpIHsKICAgIGxldCBtYXhQb3dlcjIgPSAxLAogICAgICBsb2cyID0gMDsKICAgIHdoaWxlICgobWF4UG93ZXIyIF4gZW50cmllc0NvdW50KSA+IG1heFBvd2VyMikgewogICAgICBtYXhQb3dlcjIgPDw9IDE7CiAgICAgIGxvZzIrKzsKICAgIH0KICAgIGNvbnN0IHNlYXJjaFJhbmdlID0gbWF4UG93ZXIyICogZW50cnlTaXplOwogICAgcmV0dXJuIHsKICAgICAgcmFuZ2U6IHNlYXJjaFJhbmdlLAogICAgICBlbnRyeTogbG9nMiwKICAgICAgcmFuZ2VTaGlmdDogZW50cnlTaXplICogZW50cmllc0NvdW50IC0gc2VhcmNoUmFuZ2UKICAgIH07CiAgfQogIHRvQXJyYXkoKSB7CiAgICBsZXQgc2ZudCA9IHRoaXMuc2ZudDsKICAgIGNvbnN0IHRhYmxlcyA9IHRoaXMudGFibGVzOwogICAgY29uc3QgdGFibGVzTmFtZXMgPSBPYmplY3Qua2V5cyh0YWJsZXMpOwogICAgdGFibGVzTmFtZXMuc29ydCgpOwogICAgY29uc3QgbnVtVGFibGVzID0gdGFibGVzTmFtZXMubGVuZ3RoOwogICAgbGV0IGksIGosIGpqLCB0YWJsZSwgdGFibGVOYW1lOwogICAgbGV0IG9mZnNldCA9IE9URl9IRUFERVJfU0laRSArIG51bVRhYmxlcyAqIE9URl9UQUJMRV9FTlRSWV9TSVpFOwogICAgY29uc3QgdGFibGVPZmZzZXRzID0gW29mZnNldF07CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtVGFibGVzOyBpKyspIHsKICAgICAgdGFibGUgPSB0YWJsZXNbdGFibGVzTmFtZXNbaV1dOwogICAgICBjb25zdCBwYWRkZWRMZW5ndGggPSAodGFibGUubGVuZ3RoICsgMyAmIH4zKSA+Pj4gMDsKICAgICAgb2Zmc2V0ICs9IHBhZGRlZExlbmd0aDsKICAgICAgdGFibGVPZmZzZXRzLnB1c2gob2Zmc2V0KTsKIC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gICAgICAgdmFsdWUgPSAodmFsdWUgPDwgOCkgKyBlbmNvZGVkWysraV07CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAodmFsdWUpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLmhzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC52c3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMSkgewogICAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGR5ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCwgZHkpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bW92ZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5ybGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDY6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC5obGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDc6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDg6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg2LCBDT01NQU5EX01BUC5ycmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgOToKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMTA6CiAgICAgICAgICAgIGlmICh0aGlzLnN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3Vick51bWJlciA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghc3VicnNbc3Vick51bWJlcl0pIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmNvbnZlcnQoc3VicnNbc3Vick51bWJlcl0sIHN1YnJzLCBzZWFjQW5hbHlzaXNFbmFibGVkKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDExOgogICAgICAgICAgICByZXR1cm4gZXJyb3I7CiAgICAgICAgICBjYXNlIDEzOgogICAgICAgICAgICBpZiAodGhpcy5zdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHd4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgc2J4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgdGhpcy5sc2IgPSBzYng7CiAgICAgICAgICAgIHRoaXMud2lkdGggPSB3eDsKICAgICAgICAgICAgdGhpcy5zdGFjay5wdXNoKHd4LCBzYngpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMiwgQ09NTUFORF9NQVAuaG1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxNDoKICAgICAgICAgICAgdGhpcy5vdXRwdXQucHVzaChDT01NQU5EX01BUC5lbmRjaGFyWzBdKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDIxOgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnJtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjI6CiAgICAgICAgICAgIGlmICh0aGlzLmZsZXhpbmcpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEsIENPTU1BTkRfTUFQLmhtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzA6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC52aGN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzE6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5odmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMDoKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnZzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDI6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5oc3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyA2OgogICAgICAgICAgICBpZiAoc2VhY0FuYWx5c2lzRW5hYmxlZCkgewogICAgICAgICAgICAgIGNvbnN0IGFzYiA9IHRoaXMuc3RhY2suYXQoLTUpOwogICAgICAgICAgICAgIHRoaXMuc2VhYyA9IHRoaXMuc3RhY2suc3BsaWNlKC00LCA0KTsKICAgICAgICAgICAgICB0aGlzLnNlYWNbMF0gKz0gdGhpcy5sc2IgLSBhc2I7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDAsIENPTU1BTkRfTUFQLmVuZGNoYXIpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5lbmRjaGFyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgNzoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgNCkgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnN0YWNrLnBvcCgpOwogICAgICAgICAgICB3eCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNvbnN0IHNieSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHNieCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMubHNiID0gc2J4OwogICAgICAgICAgICB0aGlzLndpZHRoID0gd3g7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaCh3eCwgc2J4LCBzYnkpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMywgQ09NTUFORF9NQVAucm1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxMjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBudW0yID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtMSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChudW0xIC8gbnVtMik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxNjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdWJyTnVtYmVyID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtQXJncyA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmIChzdWJyTnVtYmVyID09PSAwICYmIG51bUFyZ3MgPT09IDMpIHsKICAgICAgICAgICAgICBjb25zdCBmbGV4QXJncyA9IHRoaXMuc3RhY2suc3BsaWNlKC0xNywgMTcpOwogICAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChmbGV4QXJnc1syXSArIGZsZXhBcmdzWzBdLCBmbGV4QXJnc1szXSArIGZsZXhBcmdzWzFdLCBmbGV4QXJnc1s0XSwgZmxleEFyZ3NbNV0sIGZsZXhBcmdzWzZdLCBmbGV4QXJnc1s3XSwgZmxleEFyZ3NbOF0sIGZsZXhBcmdzWzldLCBmbGV4QXJnc1sxMF0sIGZsZXhBcmdzWzExXSwgZmxleEFyZ3NbMTJdLCBmbGV4QXJnc1sxM10sIGZsZXhBcmdzWzE0XSk7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEzLCBDT01NQU5EX01BUC5mbGV4LCB0cnVlKTsKICAgICAgICAgICAgICB0aGlzLmZsZXhpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goZmxleEFyZ3NbMTVdLCBmbGV4QXJnc1sxNl0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKHN1YnJOdW1iZXIgPT09IDEgJiYgbnVtQXJncyA9PT0gMCkgewogICAgICAgICAgICAgIHRoaXMuZmxleGluZyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDE3OgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMzM6CiAgICAgICAgICAgIHRoaXMuc3RhY2sgPSBbXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoJ1Vua25vd24gdHlwZSAxIGNoYXJzdHJpbmcgY29tbWFuZCBvZiAiJyArIHZhbHVlICsgJyInKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChlcnJvcikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlIDw9IDI0NikgewogICAgICAgIHZhbHVlIC09IDEzOTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA8PSAyNTApIHsKICAgICAgICB2YWx1ZSA9ICh2YWx1ZSAtIDI0NykgKiAyNTYgKyBlbmNvZGVkWysraV0gKyAxMDg7CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPD0gMjU0KSB7CiAgICAgICAgdmFsdWUgPSAtKCh2YWx1ZSAtIDI1MSkgKiAyNTYpIC0gZW5jb2RlZFsrK2ldIC0gMTA4OwogICAgICB9IGVsc2UgewogICAgICAgIHZhbHVlID0gKGVuY29kZWRbKytpXSAmIDB4ZmYpIDw8IDI0IHwgKGVuY29kZWRbKytpXSAmIDB4ZmYpIDw8IDE2IHwgKGVuY29kZWRbKytpXSAmIDB4ZmYpIDw8IDggfCAoZW5jb2RlZFsrK2ldICYgMHhmZikgPDwgMDsKICAgICAgfQogICAgICB0aGlzLnN0YWNrLnB1c2godmFsdWUpOwogICAgfQogICAgcmV0dXJuIGVycm9yOwogIH0KICBleGVjdXRlQ29tbWFuZChob3dNYW55QXJncywgY29tbWFuZCwga2Vl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ldHVybiBwYXJzZUludCh0b2tlbiB8fCAwLCAxMCkgfCAwOwogIH0KICByZWFkQm9vbGVhbigpIHsKICAgIGNvbnN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHRva2VuID09PSAidHJ1ZSIgPyAxIDogMDsKICB9CiAgbmV4dENoYXIoKSB7CiAgICByZXR1cm4gdGhpcy5jdXJyZW50Q2hhciA9IHRoaXMuc3RyZWFtLmdldEJ5dGUoKTsKICB9CiAgcHJldkNoYXIoKSB7CiAgICB0aGlzLnN0cmVhbS5za2lwKC0yKTsKICAgIHJldHVybiB0aGlzLmN1cnJlbnRDaGFyID0gdGhpcy5zdHJlYW0uZ2V0Qnl0ZSgpOwogIH0KICBnZXRUb2tlbigpIHsKICAgIGxldCBjb21tZW50ID0gZmFsc2U7CiAgICBsZXQgY2ggPSB0aGlzLmN1cnJlbnRDaGFyOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgaWYgKGNoID09PSAtMSkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoISgwLCBfY29yZV91dGlscy5pc1doaXRlU3BhY2UpKGNoKSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgaWYgKGlzU3BlY2lhbChjaCkpIHsKICAgICAgdGhpcy5uZXh0Q2hhcigpOwogICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICB9CiAgICBsZXQgdG9rZW4gPSAiIjsKICAgIGRvIHsKICAgICAgdG9rZW4gKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfSB3aGlsZSAoY2ggPj0gMCAmJiAhKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpICYmICFpc1NwZWNpYWwoY2gpKTsKICAgIHJldHVybiB0b2tlbjsKICB9CiAgcmVhZENoYXJTdHJpbmdzKGJ5dGVzLCBsZW5JVikgewogICAgaWYgKGxlbklWID09PSAtMSkgewogICAgICByZXR1cm4gYnl0ZXM7CiAgICB9CiAgICByZXR1cm4gZGVjcnlwdChieXRlcywgQ0hBUl9TVFJTX0VOQ1JZUFRfS0VZLCBsZW5JVik7CiAgfQogIGV4dHJhY3RGb250UHJvZ3JhbShwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCBzdHJlYW0gPSB0aGlzLnN0cmVhbTsKICAgIGNvbnN0IHN1YnJzID0gW10sCiAgICAgIGNoYXJzdHJpbmdzID0gW107CiAgICBjb25zdCBwcml2YXRlRGF0YSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBwcml2YXRlRGF0YS5sZW5JViA9IDQ7CiAgICBjb25zdCBwcm9ncmFtID0gewogICAgICBzdWJyczogW10sCiAgICAgIGNoYXJzdHJpbmdzOiBbXSwKICAgICAgcHJvcGVydGllczogewogICAgICAgIHByaXZhdGVEYXRhCiAgICAgIH0KICAgIH07CiAgICBsZXQgdG9rZW4sIGxlbmd0aCwgZGF0YSwgbGVuSVY7CiAgICB3aGlsZSAoKHRva2VuID0gdGhpcy5nZXRUb2tlbigpKSAhPT0gbnVsbCkgewogICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICBzd2l0Y2ggKHRva2VuKSB7CiAgICAgICAgY2FzZSAiQ2hhclN0cmluZ3MiOgogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gbnVsbCB8fCB0b2tlbiA9PT0gImVuZCIpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodG9rZW4gPT09ICIvIikgewogICAgICAgICAgICAgIHRoaXMucHJldkNoYXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjaGFyc3RyaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBnbHlwaCwKICAgICAgICAgICAgICBlbmNvZGVkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU3VicnMiOgogICAgICAgICAgdGhpcy5yZWFkSW50KCk7CiAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICB3aGlsZSAodGhpcy5nZXRUb2tlbigpID09PSAiZHVwIikgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IHRoaXMucmVhZEludCgpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VicnNbaW5kZXhdID0gZW5jb2RlZDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVWYWx1ZXMiOgogICAgICAgIGNhc2UgIk90aGVyQmx1ZXMiOgogICAgICAgIGNhc2UgIkZhbWlseUJsdWVzIjoKICAgICAgICBjYXNlICJGYW1pbHlPdGhlckJsdWVzIjoKICAgICAgICAgIGNvbnN0IGJsdWVBcnJheSA9IHRoaXMucmVhZE51bWJlckFycmF5KC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dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWRCb29sZWFuKCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIGVuY29kZWQsCiAgICAgIGdseXBoCiAgICB9IG9mIGNoYXJzdHJpbmdzKSB7CiAgICAgIGNvbnN0IGNoYXJTdHJpbmcgPSBuZXcgVHlwZTFDaGFyU3RyaW5nKCk7CiAgICAgIGNvbnN0IGVycm9yID0gY2hhclN0cmluZy5jb252ZXJ0KGVuY29kZWQsIHN1YnJzLCB0aGlzLnNlYWNBbmFseXNpc0VuYWJsZWQpOwogICAgICBsZXQgb3V0cHV0ID0gY2hhclN0cmluZy5vdXRwdXQ7CiAgICAgIGlmIChlcnJvcikgewogICAgICAgIG91dHB1dCA9IFsxNF07CiAgICAgIH0KICAgICAgY29uc3QgY2hhclN0cmluZ09iamVjdCA9IHsKICAgICAgICBnbHlwaE5hbWU6IGdseXBoLAogICAgICAgIGNoYXJzdHJpbmc6IG91dHB1dCwKICAgICAgICB3aWR0aDogY2hhclN0cmluZy53aWR0aCwKICAgICAgICBsc2I6IGNoYXJTdHJpbmcubHNiLAogICAgICAgIHNlYWM6IGNoYXJTdHJpbmcuc2VhYwogICAgICB9OwogICAgICBpZiAoZ2x5cGggPT09ICIubm90ZGVmIikgewogICAgICAgIHByb2dyYW0uY2hhcnN0cmluZ3MudW5zaGlmdChjaGFyU3RyaW5nT2JqZWN0KTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwcm9ncmFtLmNoYXJzdHJpbmdzLnB1c2goY2hhclN0cmluZ09iamVjdCk7CiAgICAgIH0KICAgICAgaWYgKHByb3BlcnRpZXMuYnVpbHRJbkVuY29kaW5nKSB7CiAgICAgICAgY29uc3QgaW5kZXggPSBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZy5pbmRleE9mKGdseXBoKTsKICAgICAgICBpZiAoaW5kZXggPiAtMSAmJiBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPT09IHVuZGVmaW5lZCAmJiBpbmRleCA+PSBwcm9wZXJ0aWVzLmZpcnN0Q2hhciAmJiBpbmRleCA8PSBwcm9wZXJ0aWVzLmxhc3RDaGFyKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPSBjaGFyU3RyaW5nLndpZHRoOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIHByb2dyYW07CiAgfQogIGV4dHJhY3RGb250SGVhZGVyKHByb3BlcnRpZXMpIHsKICAgIGxldCB0b2tlbjsKICAgIHdoaWxlICgodG9rZW4gPSB0aGlzLmdldFRva2VuKCkpICE9PSBudWxsKSB7CiAgICAgIGlmICh0b2tlbiAhPT0gIi8iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgIHN3aXRjaCAodG9rZW4pIHsKICAgICAgICBjYXNlICJGb250TWF0cml4IjoKICAgICAgICAgIGNvbnN0IG1hdHJpeCA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBwcm9wZXJ0aWVzLmZvbnRNYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJFbmNvZGluZyI6CiAgICAgICAgICBjb25zdCBlbmNvZGluZ0FyZyA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgIGxldCBlbmNvZGluZzsKICAgICAgICAgIGlmICghL15cZCskLy50ZXN0KGVuY29kaW5nQXJnKSkgewogICAgICAgICAgICBlbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShlbmNvZGluZ0FyZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBlbmNvZGluZyA9IFtdOwogICAgICAgICAgICBjb25zdCBzaXplID0gcGFyc2VJbnQoZW5jb2RpbmdBcmcsIDEwKSB8IDA7CiAgICAgICAgICAgIHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBzaXplOyBqKyspIHsKICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgICB3aGlsZSAodG9rZW4gIT09ICJkdXAiICYmIHRva2VuICE9PSAiZGVmIikgewogICAgICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICBpZiAodG9rZW4gPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodG9rZW4gPT09ICJkZWYiKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgY29uc3QgZ2x5cGggPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgZW5jb2RpbmdbaW5kZXhdID0gZ2x5cGg7CiAgICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZyA9IGVuY29kaW5nOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9udEJCb3giOgogICAgICAgICAgY29uc3QgZm9udEJCb3ggPSB0aGlzLnJlYWROdW1iZXJBcnJheSgpOwogICAgICAgICAgcHJvcGVydGllcy5hc2NlbnQgPSBNYXRoLm1heChmb250QkJveFszXSwgZm9udEJCb3hbMV0pOwogICAgICAgICAgcHJvcGVydGllcy5kZXNjZW50ID0gTWF0aC5taW4oZm9udEJCb3hbMV0sIGZvbnRCQm94WzNdKTsKICAg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JkczsKICAgIGNvbnN0IGNvbG9ycyA9IHRoaXMuY29sb3JzOwogICAgY29uc3Qgb3BlcmF0b3JzID0gW107CiAgICBjb25zdCBwcyA9IFtdOwogICAgbGV0IHZlcnRpY2VzTGVmdCA9IDA7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBjb25zdCBjb29yZCA9IHJlYWRlci5yZWFkQ29vcmRpbmF0ZSgpOwogICAgICBjb25zdCBjb2xvciA9IHJlYWRlci5yZWFkQ29tcG9uZW50cygpOwogICAgICBpZiAodmVydGljZXNMZWZ0ID09PSAwKSB7CiAgICAgICAgaWYgKCEoMCA8PSBmICYmIGYgPD0gMikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNCBmbGFnIik7CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAoZikgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICB2ZXJ0aWNlc0xlZnQgPSAzOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgcHMucHVzaChwcy5hdCgtMiksIHBzLmF0KC0xKSk7CiAgICAgICAgICAgIHZlcnRpY2VzTGVmdCA9IDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBwcy5wdXNoKHBzLmF0KC0zKSwgcHMuYXQoLTEpKTsKICAgICAgICAgICAgdmVydGljZXNMZWZ0ID0gMTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9ycy5wdXNoKGYpOwogICAgICB9CiAgICAgIHBzLnB1c2goY29vcmRzLmxlbmd0aCk7CiAgICAgIGNvb3Jkcy5wdXNoKGNvb3JkKTsKICAgICAgY29sb3JzLnB1c2goY29sb3IpOwogICAgICB2ZXJ0aWNlc0xlZnQtLTsKICAgICAgcmVhZGVyLmFsaWduKCk7CiAgICB9CiAgICB0aGlzLmZpZ3VyZXMucHVzaCh7CiAgICAgIHR5cGU6ICJ0cmlhbmdsZXMiLAogICAgICBjb29yZHM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgY29sb3JzOiBuZXcgSW50MzJBcnJheShwcykKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTVTaGFkaW5nKHJlYWRlciwgdmVydGljZXNQZXJSb3cpIHsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzOwogICAgY29uc3QgY29sb3JzID0gdGhpcy5jb2xvcnM7CiAgICBjb25zdCBwcyA9IFtdOwogICAgd2hpbGUgKHJlYWRlci5oYXNEYXRhKSB7CiAgICAgIGNvbnN0IGNvb3JkID0gcmVhZGVyLnJlYWRDb29yZGluYXRlKCk7CiAgICAgIGNvbnN0IGNvbG9yID0gcmVhZGVyLnJlYWRDb21wb25lbnRzKCk7CiAgICAgIHBzLnB1c2goY29vcmRzLmxlbmd0aCk7CiAgICAgIGNvb3Jkcy5wdXNoKGNvb3JkKTsKICAgICAgY29sb3JzLnB1c2goY29sb3IpOwogICAgfQogICAgdGhpcy5maWd1cmVzLnB1c2goewogICAgICB0eXBlOiAibGF0dGljZSIsCiAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICBjb2xvcnM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgdmVydGljZXNQZXJSb3cKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTZTaGFkaW5nKHJlYWRlcikgewogICAgY29uc3QgY29vcmRzID0gdGhpcy5jb29yZHM7CiAgICBjb25zdCBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBzID0gbmV3IEludDMyQXJyYXkoMTYpOwogICAgY29uc3QgY3MgPSBuZXcgSW50MzJBcnJheSg0KTsKICAgIHdoaWxlIChyZWFkZXIuaGFzRGF0YSkgewogICAgICBjb25zdCBmID0gcmVhZGVyLnJlYWRGbGFnKCk7CiAgICAgIGlmICghKDAgPD0gZiAmJiBmIDw9IDMpKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIHR5cGU2IGZsYWciKTsKICAgICAgfQogICAgICBjb25zdCBwaSA9IGNvb3Jkcy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGYgIT09IDAgPyA4IDogMTI7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29vcmRzLnB1c2gocmVhZGVyLnJlYWRDb29yZGluYXRlKCkpOwogICAgICB9CiAgICAgIGNvbnN0IGNpID0gY29sb3JzLmxlbmd0aDsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZiAhPT0gMCA/IDIgOiA0OyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbG9ycy5wdXNoKHJlYWRlci5yZWFkQ29tcG9uZW50cygpKTsKICAgICAgfQogICAgICBsZXQgdG1wMSwgdG1wMiwgdG1wMywgdG1wNDsKICAgICAgc3dpdGNoIChmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgcHNbMTJdID0gcGkgKyAzOwogICAgICAgICAgcHNbMTNdID0gcGkgKyA0OwogICAgICAgICAgcHNbMTRdID0gcGkgKyA1OwogICAgICAgICAgcHNbMTVdID0gcGkgKyA2OwogICAgICAgICAgcHNbOF0gPSBwaSArIDI7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbN10gPSBwaSArIDQ7CiAgICAgICAgICBwc1swXSA9IHRtcDE7CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICB0bXAxID0gY3NbMl07CiAgICAgICAgICB0bXAyID0gY3NbM107CiAgICAgICAgICBjc1syXSA9IHRtcDI7CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICB0bXAxID0gcHNbMTVdOwogICAgICAgICAgdG1wMiA9IHBzWzExXTsKICAgICAgICAgIHBzWzEyXSA9IHBzWzNdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1s3XTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gdG1wMjsKICAgICAgICAgIHBzWzddID0gcGkgKyA0OwogICAgICAgICAgcHNbMF0gPSB0bXAxOwogICAgICAgICAgcHNbMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1syXSA9IHBpICsgNjsKICAgICAgICAgIHBzWzNdID0gcGkgKyA1OwogICAgICAgICAgdG1wMSA9IGNzWzNdOwogICAgICAgICAgY3NbMl0gPSBjc1sxXTsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHBzWzEyXSA9IHBzWzBdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1sxXTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gcHNbMl07CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHBzWzVdID0gY29vcmRzLmxlbmd0aDsKICAgICAgY29vcmRzLnB1c2goWygtNCAqIGNvb3Jkc1twc1swXV1bMF0gLSBjb29yZHNbcHNbMTVdXVswXSArIDYgKiAoY29vcmRzW3BzWzRdXVswXSArIGNvb3Jkc1twc1sxXV1bMF0pIC0gMiAqIChjb29yZHNbcHNbMTJdXVswXSArI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U3U2hhZGluZyhyZWFkZXIpIHsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzOwogICAgY29uc3QgY29sb3JzID0gdGhpcy5jb2xvcnM7CiAgICBjb25zdCBwcyA9IG5ldyBJbnQzMkFycmF5KDE2KTsKICAgIGNvbnN0IGNzID0gbmV3IEludDMyQXJyYXkoNCk7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBpZiAoISgwIDw9IGYgJiYgZiA8PSAzKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNyBmbGFnIik7CiAgICAgIH0KICAgICAgY29uc3QgcGkgPSBjb29yZHMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMTIgOiAxNjsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb29yZHMucHVzaChyZWFkZXIucmVhZENvb3JkaW5hdGUoKSk7CiAgICAgIH0KICAgICAgY29uc3QgY2kgPSBjb2xvcnMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMiA6IDQ7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29sb3JzLnB1c2gocmVhZGVyLnJlYWRDb21wb25lbnRzKCkpOwogICAgICB9CiAgICAgIGxldCB0bXAxLCB0bXAyLCB0bXAzLCB0bXA0OwogICAgICBzd2l0Y2ggKGYpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBwc1sxMl0gPSBwaSArIDM7CiAgICAgICAgICBwc1sxM10gPSBwaSArIDQ7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDU7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDY7CiAgICAgICAgICBwc1s4XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzldID0gcGkgKyAxMzsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTQ7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzVdID0gcGkgKyAxMjsKICAgICAgICAgIHBzWzZdID0gcGkgKyAxNTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1syXTsKICAgICAgICAgIHRtcDIgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gdG1wMjsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIHRtcDEgPSBwc1sxNV07CiAgICAgICAgICB0bXAyID0gcHNbMTFdOwogICAgICAgICAgcHNbMTJdID0gcHNbM107CiAgICAgICAgICBwc1sxM10gPSBwaSArIDA7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDE7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDI7CiAgICAgICAgICBwc1s4XSA9IHBzWzddOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gY3NbMV07CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDM6CiAgICAgICAgICBwc1sxMl0gPSBwc1swXTsKICAgICAgICAgIHBzWzEzXSA9IHBpICsgMDsKICAgICAgICAgIHBzWzE0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzE1XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzhdID0gcHNbMV07CiAgICAgICAgICBwc1s5XSA9IHBpICsgOTsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTA7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDM7CiAgICAgICAgICBwc1s0XSA9IHBzWzJdOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMuZmlndXJlcy5wdXNoKHsKICAgICAgICB0eXBlOiAicGF0Y2giLAogICAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICAgIGNvbG9yczogbmV3IEludDMyQXJyYXkoY3MpCiAgICAgIH0pOwogICAgfQogIH0KICBfYnVpbGRGaWd1cmVGcm9tUGF0Y2goaW5kZXgpIHsKICAgIGNvbnN0IGZpZ3VyZSA9IHRoaXMuZmlndXJlc1tpbmRleF07CiAgICAoMCwgX3V0aWwuYXNzZXJ0KShmaWd1cmUudHlwZSA9PT0gInBhdGNoIiwgIlVuZXhwZWN0ZWQgcGF0Y2ggbWVzaCBmaWd1cmUiKTsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzLAogICAgICBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBpID0gZmlndXJlLmNvb3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gYzJbMl0gKiByb3cpIC8gc3BsaXRZQnkgfCAwOwogICAgICBjclswXSA9IChjMVswXSAqIChzcGxpdFlCeSAtIHJvdykgKyBjM1swXSAqIHJvdykgLyBzcGxpdFlCeSB8IDA7CiAgICAgIGNyWzFdID0gKGMxWzFdICogKHNwbGl0WUJ5IC0gcm93KSArIGMzWzFdICogcm93KSAvIHNwbGl0WUJ5IHwgMDsKICAgICAgY3JbMl0gPSAoYzFbMl0gKiAoc3BsaXRZQnkgLSByb3cpICsgYzNbMl0gKiByb3cpIC8gc3BsaXRZQnkgfCAwOwogICAgICBmb3IgKGxldCBjb2wgPSAwOyBjb2wgPD0gc3BsaXRYQnk7IGNvbCsrLCBrKyspIHsKICAgICAgICBpZiAoKHJvdyA9PT0gMCB8fCByb3cgPT09IHNwbGl0WUJ5KSAmJiAoY29sID09PSAwIHx8IGNvbCA9PT0gc3BsaXRYQnkpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgbGV0IHggPSAwLAogICAgICAgICAgeSA9IDA7CiAgICAgICAgbGV0IHEgPSAwOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IDM7IGkrKykgewogICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPD0gMzsgaisrLCBxKyspIHsKICAgICAgICAgICAgY29uc3QgbSA9IGJSb3dbcm93XVtpXSAqIGJDb2xbY29sXVtqXTsKICAgICAgICAgICAgeCArPSBjb29yZHNbcGlbcV1dWzBdICogbTsKICAgICAgICAgICAgeSArPSBjb29yZHNbcGlbcV1dWzFdICogbTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZmlndXJlQ29vcmRzW2tdID0gY29vcmRzLmxlbmd0aDsKICAgICAgICBjb29yZHMucHVzaChbeCwgeV0pOwogICAgICAgIGZpZ3VyZUNvbG9yc1trXSA9IGNvbG9ycy5sZW5ndGg7CiAgICAgICAgY29uc3QgbmV3Q29sb3IgPSBuZXcgVWludDhBcnJheSgzKTsK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ogICAgICBjb2RlU2l6ZSAtPSBicHM7CiAgICAgIGFycmF5W2ldID0gKGNvZGVCdWYgPj4gY29kZVNpemUpICogc2FtcGxlTXVsOwogICAgICBjb2RlQnVmICY9ICgxIDw8IGNvZGVTaXplKSAtIDE7CiAgICB9CiAgICByZXR1cm4gYXJyYXk7CiAgfQogIHN0YXRpYyBwYXJzZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICBmbgogICAgfSA9IF9yZWYyOwogICAgY29uc3QgZGljdCA9IGZuLmRpY3QgfHwgZm47CiAgICBjb25zdCB0eXBlTnVtID0gZGljdC5nZXQoIkZ1bmN0aW9uVHlwZSIpOwogICAgc3dpdGNoICh0eXBlTnVtKSB7CiAgICAgIGNhc2UgMDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTYW1wbGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgICAgY2FzZSAxOgogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgcmV0dXJuIHRoaXMuY29uc3RydWN0SW50ZXJwb2xhdGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgMzoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTdGljaGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgNDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RQb3N0U2NyaXB0KHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZW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KGogPSAwOyBqIDwgY3ViZVZlcnRpY2VzOyBqKyspIHsKICAgICAgICBjdWJlTltqXSA9IDE7CiAgICAgIH0KICAgICAgbGV0IGsgPSBvdXRwdXRTaXplLAogICAgICAgIHBvcyA9IDE7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBpbnB1dFNpemU7ICsraSkgewogICAgICAgIGNvbnN0IGRvbWFpbl8yaSA9IGRvbWFpbltpXVswXTsKICAgICAgICBjb25zdCBkb21haW5fMmlfMSA9IGRvbWFpbltpXVsxXTsKICAgICAgICBjb25zdCB4aSA9IE1hdGgubWluKE1hdGgubWF4KHNyY1tzcmNPZmZzZXQgKyBpXSwgZG9tYWluXzJpKSwgZG9tYWluXzJpXzEpOwogICAgICAgIGxldCBlID0gaW50ZXJwb2xhdGUoeGksIGRvbWFpbl8yaSwgZG9tYWluXzJpXzEsIGVuY29kZVtpXVswXSwgZW5jb2RlW2ldWzFdKTsKICAgICAgICBjb25zdCBzaXplX2kgPSBzaXplW2ldOwogICAgICAgIGUgPSBNYXRoLm1pbihNYXRoLm1heChlLCAwKSwgc2l6ZV9pIC0gMSk7CiAgICAgICAgY29uc3QgZTAgPSBlIDwgc2l6ZV9pIC0gMSA/IE1hdGguZmxvb3IoZSkgOiBlIC0gMTsKICAgICAgICBjb25zdCBuMCA9IGUwICsgMSAtIGU7CiAgICAgICAgY29uc3QgbjEgPSBlIC0gZTA7CiAgICAgICAgY29uc3Qgb2Zmc2V0MCA9IGUwICogazsKICAgICAgICBjb25zdCBvZmZzZXQxID0gb2Zmc2V0MCArIGs7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IGN1YmVWZXJ0aWNlczsgaisrKSB7CiAgICAgICAgICBpZiAoaiAmIHBvcykgewogICAgICAgICAgICBjdWJlTltqXSAqPSBuMTsKICAgICAgICAgICAgY3ViZVZlcnRleFtqXSArPSBvZmZzZXQxOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY3ViZU5bal0gKj0gbjA7CiAgICAgICAgICAgIGN1YmVWZXJ0ZXhbal0gKz0gb2Zmc2V0MDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgayAqPSBzaXplX2k7CiAgICAgICAgcG9zIDw8PSAxOwogICAgICB9CiAgICAgIGZvciAoaiA9IDA7IGogPCBvdXRwdXRTaXplOyArK2opIHsKICAgICAgICBsZXQgcmogPSAwOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBjdWJlVmVydGljZXM7IGkrKykgewogICAgICAgICAgcmogKz0gc2FtcGxlc1tjdWJlVmVydGV4W2ldICsgal0gKiBjdWJlTltpXTsKICAgICAgICB9CiAgICAgICAgcmogPSBpbnRlcnBvbGF0ZShyaiwgMCwgMSwgZGVjb2RlW2pdWzBdLCBkZWNvZGVbal1bMV0pOwogICAgICAgIGRlc3RbZGVzdE9mZnNldCArIGpdID0gTWF0aC5taW4oTWF0aC5tYXgocmosIHJhbmdlW2pdWzBdKSwgcmFuZ2Vbal1bMV0pOwogICAgICB9CiAgICB9OwogIH0KICBzdGF0aWMgY29uc3RydWN0SW50ZXJwb2xhdGVkKF9yZWY1KSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGRpY3QKICAgIH0gPSBfcmVmNTsKICAgIGNvbnN0IGMwID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJDMCIpKSB8fCBbMF07CiAgICBjb25zdCBjMSA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQzEiKSkgfHwgWzFdOwogICAgY29uc3QgbiA9IGRpY3QuZ2V0KCJOIik7CiAgICBjb25zdCBkaWZmID0gW107CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjMC5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgIGRpZmYucHVzaChjMVtpXSAtIGMwW2ldKTsKICAgIH0KICAgIGNvbnN0IGxlbmd0aCA9IGRpZmYubGVuZ3RoOwogICAgcmV0dXJ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yQXJyYXkoZGljdC5nZXRBcnJheSgiQm91bmRzIikpOwogICAgY29uc3QgZW5jb2RlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJFbmNvZGUiKSk7CiAgICBjb25zdCB0bXBCdWYgPSBuZXcgRmxvYXQzMkFycmF5KDEpOwogICAgcmV0dXJuIGZ1bmN0aW9uIGNvbnN0cnVjdFN0aWNoZWRGbihzcmMsIHNyY09mZnNldCwgZGVzdCwgZGVzdE9mZnNldCkgewogICAgICBjb25zdCBjbGlwID0gZnVuY3Rpb24gY29uc3RydWN0U3RpY2hlZEZyb21JUkNsaXAodiwgbWluLCBtYXgpIHsKICAgICAgICBpZiAodiA+IG1heCkgewogICAgICAgICAgdiA9IG1heDsKICAgICAgICB9IGVsc2UgaWYgKHYgPCBtaW4pIHsKICAgICAgICAgIHYgPSBtaW47CiAgICAgICAgfQogICAgICAgIHJldHVybiB2OwogICAgICB9OwogICAgICBjb25zdCB2ID0gY2xpcChzcmNbc3JjT2Zmc2V0XSwgZG9tYWluWzBdLCBkb21haW5bMV0pOwogICAgICBjb25zdCBsZW5ndGggPSBib3VuZHMubGVuZ3RoOwogICAgICBsZXQgaTsKICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgaWYgKHYgPCBib3VuZHNbaV0pIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBsZXQgZG1pbiA9IGRvbWFpblswXTsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgZG1pbiA9IGJvdW5kc1tpIC0gMV07CiAgICAgIH0KICAgICAgbGV0IGRtYXggPSBkb21haW5bMV07CiAgICAgIGlmIChpIDwgYm91bmRzLmxlbmd0aCkgewogICAgICAgIGRtYXggPSBib3VuZHNbaV07CiAgICAgIH0KICAgICAgY29uc3Qgcm1pbiA9IGVuY29kZVsyICogaV07CiAgICAgIGNvbnN0IHJtYXggPSBlbmNvZGVbMiAqIGkgKyAxXT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oZWRWYWx1ZSwgZGVzdE9mZnNldCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IG91dHB1dCA9IG5ldyBGbG9hdDMyQXJyYXkobnVtT3V0cHV0cyk7CiAgICAgIGNvbnN0IHN0YWNrID0gZXZhbHVhdG9yLmV4ZWN1dGUoaW5wdXQpOwogICAgICBjb25zdCBzdGFja0luZGV4ID0gc3RhY2subGVuZ3RoIC0gbnVtT3V0cHV0czsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bU91dHB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3RhY2tbc3RhY2tJbmRleCArIGldOwogICAgICAgIGxldCBib3VuZCA9IHJhbmdlW2kgKiAyXTsKICAgICAgICBpZiAodmFsdWUgPCBib3VuZCkgewogICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYm91bmQgPSByYW5nZVtpICogMiArIDFdOwogICAgICAgICAgaWYgKHZhbHVlID4gYm91bmQpIHsKICAgICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgIH0KICAgICAgaWYgKGNhY2hlX2F2YWlsYWJsZSA+IDApIHsKICAgICAgICBjYWNoZV9hdmFpbGFibGUtLTsKICAgICAgICBjYWNoZVtrZXldID0gb3V0cHV0OwogICAgICB9CiAgICAgIGRlc3Quc2V0KG91dHB1dCwgZGVzdE9mZnNldCk7CiAgICB9OwogIH0KfQpmdW5jdGlvbiBpc1BERkZ1bmN0aW9uKHYpIHsKICBsZXQgZm5EaWN0OwogIGlmICh2IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgZm5EaWN0ID0gdjsKICB9IGVsc2UgaWYgKHYgaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkgewogICAgZm5EaWN0ID0gdi5kaWN0OwogIH0gZ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gbiAtIDE7IGogPj0gMDsgai0tLCBpKyspIHsKICAgICAgc3RhY2sucHVzaChzdGFja1tpXSk7CiAgICB9CiAgfQogIGluZGV4KG4pIHsKICAgIHRoaXMucHVzaCh0aGlzLnN0YWNrW3RoaXMuc3RhY2subGVuZ3RoIC0gbiAtIDFdKTsKICB9CiAgcm9sbChuLCBwKSB7CiAgICBjb25zdCBzdGFjayA9IHRoaXMuc3RhY2s7CiAgICBjb25zdCBsID0gc3RhY2subGVuZ3RoIC0gbjsKICAgIGNvbnN0IHIgPSBzdGFjay5sZW5ndGggLSAxOwogICAgY29uc3QgYyA9IGwgKyAocCAtIE1hdGguZmxvb3IocCAvIG4pICogbik7CiAgICBmb3IgKGxldCBpID0gbCwgaiA9IHI7IGkgPCBqOyBpKyssIGotLSkgewogICAgICBjb25zdCB0ID0gc3RhY2tbaV07CiAgICAgIHN0YWNrW2ldID0gc3RhY2tbal07CiAgICAgIHN0YWNrW2pdID0gdDsKICAgIH0KICAgIGZvciAobGV0IGkgPSBsLCBqID0gYyAtIDE7IGkgPCBqOyBpKyssIGotLSkgewogICAgICBjb25zdCB0ID0gc3RhY2tbaV07CiAgICAgIHN0YWNrW2ldID0gc3RhY2tbal07CiAgICAgIHN0YWNrW2pdID0gdDsKICAgIH0KICAgIGZvciAobGV0IGkgPSBjLCBqID0gcjsgaSA8IGo7IGkrKywgai0tKSB7CiAgICAgIGNvbnN0IHQgPSBzdGFja1tpXTsKICAgICAgc3RhY2tbaV0gPSBzdGFja1tqXTsKICAgICAgc3RhY2tbal0gPSB0OwogICAgfQogIH0KfQpjbGFzcyBQb3N0U2NyaXB0RXZhbHVhdG9yIHsKICBjb25zdHJ1Y3RvcihvcGVyYXRvcnMpIHsKICAgIHRoaXMub3BlcmF0b3JzID0gb3BlcmF0b3JzOwogIH0KICBleGVjdXRlKGluaXRpYWxTdGFjaykgewogICAgY29uc3Qgc3RhY2sgPSBuZXcgUG9zdFNjcmlwdFN0YWNrKGluaXRpYWxTdGFjayk7CiAgICBsZXQgY291bnRlciA9IDA7CiAgICBjb25zdCBvcGVyYXRvcnMgPSB0aGlzLm9wZXJhdG9yczsKICAgIGNvbnN0IGxlbmd0aCA9IG9wZXJhdG9ycy5sZW5ndGg7CiAgICBsZXQgb3BlcmF0b3IsIGEsIGI7CiAgICB3aGlsZSAoY291bnRlciA8IGxlbmd0aCkgewogICAgICBvcGVyYXRvciA9IG9wZXJhdG9yc1tjb3VudGVyKytdOwogICAgICBpZiAodHlwZW9mIG9wZXJhdG9yID09PSAibnVtYmVyIikgewogICAgICAgIHN0YWNrLnB1c2gob3BlcmF0b3IpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICBjYXNlICJqeiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoIWEpIHsKICAgICAgICAgICAgY291bnRlciA9IGI7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJqIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGNvdW50ZXIgPSBhOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWJzIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5hYnMoYSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSArIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYW5kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGlmICh0eXBlb2YgYSA9PT0gImJvb2xlYW4iICYmIHR5cGVvZiBiID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYmIGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYgYik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJhdGFuIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBNYXRoLmF0YW4yKGEsIGIpIC8gTWF0aC5QSSAqIDE4MDsKICAgICAgICAgIGlmIChhIDwgMCkgewogICAgICAgICAgICBhICs9IDM2MDsKICAgICAgICAgIH0KICAgICAgICAgIHN0YWNrLnB1c2goYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJiaXRzaGlmdCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoYSA+IDApIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhIDw8IGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhID4+IGIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY2VpbGluZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguY2VpbChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3B5IjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLmNvcHkoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3MiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLmNvcyhhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZpIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKSB8IDA7CiAgICAgICAgICBzdGFjay5wdXNoKGEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZyIjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImRpdiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgLyBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImR1cCI6CiAgICAgICAgICBzdGFjay5jb3B5KDEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXEiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhID09PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4Y2giOgogICAgICAgICAgc3RhY2sucm9sbCgyLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4cCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgKiogYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmYWxzZSI6CiAgICAgICAgICBzdGFjay5wdXNoKGZhbHNlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZsb29yIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5mbG9vcihhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPj0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPiBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImlkaXYiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC8gYiB8IDApOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiaW5kZXgiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2suaW5kZXgoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPD0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsbiI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImxvZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpIC8gTWF0aC5MTjEwKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImx0IjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSA8IGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibW9kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAlIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibXVsIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAqIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibmUiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhICE9PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5lZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKC1hKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5vdCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKCFhKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2gofmEpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAib3IiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKHR5cGVvZiBhID09PSAiYm9vbGVhbiIgJiYgdHlwZW9mIGIgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfHwgYik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfCBiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInBvcCI6CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvbGwiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucm9sbChhLCBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvdW5kIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5yb3VuZChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzaW4iOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLnNpbihhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAic3FydCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguc3FydChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzdWIiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVlIjoKICAgICAgICAgIHN0YWNrLnB1c2godHJ1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVuY2F0ZSI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gYSA8IDAgPyBNYXRoLmNlaWwoYSkgOiBNYXRoLmZsb29yKGEpOwogICAgICAgICAgc3RhY2sucHVzaChhKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInhvciI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIiAmJi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ICB9IGVsc2UgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICAgIHJldHVybiBuZXcgQXN0TGl0ZXJhbChudW0xLm51bWJlciAqIG51bTIubnVtYmVyKTsKICAgIH0KICB9CiAgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICBpZiAobnVtMS5udW1iZXIgPT09IDApIHsKICAgICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKDApOwogICAgfSBlbHNlIGlmIChudW0xLm51bWJlciA9PT0gMSkgewogICAgICByZXR1cm4gbnVtMjsKICAgIH0KICB9CiAgY29uc3QgbWluID0gTWF0aC5taW4obnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgY29uc3QgbWF4ID0gTWF0aC5tYXgobnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgcmV0dXJuIG5ldyBBc3RCaW5hcnlPcGVyYXRpb24oIioiLCBudW0xLCBudW0yLCBtaW4sIG1heCk7Cn0KZnVuY3Rpb24gYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBudW0xOwogICAgfSBlbHNlIGlmIChudW0xLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgLSBudW0yLm51bWJlcik7CiAgICB9CiAgfQogIGlmIChudW0yLnR5cGUgPT09ICJiaW5hcnkiICYmIG51bTIub3AgPT09ICItIiAmJiBudW0xLnR5cGUgPT09ICJsaXRlcmFsIiAmJiBudW0xLm51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RlW2ldOwogICAgICBpZiAodHlwZW9mIGl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgc3RhY2sucHVzaChuZXcgQXN0TGl0ZXJhbChpdGVtKSk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChpdGVtKSB7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjdnIiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtdWwiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBudW0yID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBudW0xID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTXVsT3BlcmF0aW9uKG51bTEsIG51bTIpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInN1YiI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIG51bTIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG51bTEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXhjaCI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIGFzdDEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGFzdDIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYXN0MSwgYXN0Mik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJwb3AiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImluZGV4IjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKG4pIHx8IHN0YWNrLmxlbmd0aCA8IG4pIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gbiAtIDFdOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSBuIC0gMV0gPSB0bXBWYXI7CiAgICAgICAgICBzdGFjay5wdXNoKHRtcFZhcik7CiAgICAgICAgICBpbnN0cnVjdGlvbnMucHVzaChuZXcgQXN0VmFyaWFibGVEZWZpbml0aW9uKHRtcFZhciwgYXN0MSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZHVwIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBjb2RlW2kgKyAxXSA9PT0gIm51bWJlciIgJiYgY29kZVtpICsgMl0gPT09ICJndCIgJiYgY29kZVtpICsgM10gPT09IGkgKyA3ICYmIGNvZGVbaSArIDRdID09PSAianoiICYmIGNvZGVbaSArIDVdID09PSAicG9wIiAmJiBjb2RlW2kgKyA2XSA9PT0gY29kZVtpICsgMV0pIHsKICAgICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTWluT3BlcmF0aW9uKG51bTEsIGNvZGVbaSArIDFdKSk7CiAgICAgICAgICAgIGkgKz0gNjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSAxXSA9IHRtcFZhcjsKICAgICAgICAgIHN0YWNrLnB1c2godG1wVmFyKTsKICAgICAgICAgIGluc3RydWN0aW9ucy5wdXNoKG5ldyBBc3RWYXJpYWJsZURlZmluaXRpb24odG1wVmFyLCBhc3QxKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyb2xsIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTIudHlwZSAhPT0gImxpdGVyYWwiIHx8IG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IG51bTIubnVtYmVyOwogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPD0gMCB8fCAhTnVtYmVyLmlzSW50ZWdlcihuKSB8fCAhTnVtYmVyLmlzSW50ZWdlcihqKSB8fCBzdGFjay5sZW5ndGggPCBuKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IChqICUgbiArIG4pICUgbjsKICAgICAgICAgIGlmIChqID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgc3RhY2sucHVzaCguLi5zdGFjay5zcGxpY2Uoc3RhY2subGVuZ3RoIC0gbiwgbiAtIGopKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgfQogICAgaWYgKHN0YWNrLmxlbmd0aCAhPT0gb3V0cHV0U2l6ZSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICA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AgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gaSArIDE7IGogPCBzdHJMZW5ndGg7ICsraikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgfQogIH0KICBmb3IgKGkgPSAwOyBpIDwgc3RyTGVuZ3RoOyArK2kpIHsKICAgIHQgPSB0eXBlc1tpXTsKICAgIGlmICh0ID09PSAiV1MiIHx8IHQgPT09ICJFUyIgfHwgdCA9PT0gIkVUIiB8fCB0ID09PSAiQ1MiKSB7CiAgICAgIHR5cGVzW2ldID0gIk9OIjsKICAgIH0KICB9CiAgbGFzdFR5cGUgPSBzb3I7CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAodCA9PT0gIkVOIikgewogICAgICB0eXBlc1tpXSA9IGxhc3RUeXBlID09PSAiTCIgPyAiTCIgOiAiRU4iOwogICAgfSBlbHNlIGlmICh0ID09PSAiUiIgfHwgdCA9PT0gIkwiKSB7CiAgICAgIGxhc3RUeXBlID0gdDsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJPTiIpIHsKICAgICAgY29uc3QgZW5kID0gZmluZFVuZXF1YWwodHlwZXMsIGkgKyAxLCAiT04iKTsKICAgICAgbGV0IGJlZm9yZSA9IHNvcjsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgYmVmb3JlID0gdHlwZXNbaSAtIDFdOwogICAgICB9CiAgICAgIGxldCBhZnRlciA9IGVvcjsKICAgICAgaWYgKGVuZCArIDEgPCBzdHJMZW5ndGgpIHsKICAgICAgICBhZnRlciA9IHR5cGVzW2VuZCArIDFdOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgIT09ICJMIikgewogICAgICAgIGJlZm9yZSA9ICJSIjsKICAgICAgfQogICAgICBpZiAoYWZ0ZXIgIT09ICJMIikgewogICAgICAgIGFmdGVyID0gIlIiOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgPT09IGFmdGVyKSB7CiAgICAgICAgc2V0VmFsdWVzKHR5cGVzLCBpLCBlbmQsIGJlZm9yZSk7CiAgICAgIH0KICAgICAgaSA9IGVuZCAtIDE7CiAgICB9CiAgfQogIGZvciAoaSA9IDA7IGkgPCBzdHJMZW5ndGg7ICsraSkgewogICAgaWYgKHR5cGVzW2ldID09PSAiT04iKSB7CiAgICAgIHR5cGVzW2ldID0gZTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAoaXNFdmVuKGxldmVsc1tpXSkpIHsKICAgICAgaWYgKHQgPT09ICJSIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9IGVsc2UgaWYgKHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAyOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBpZiAodCA9PT0gIkwiIHx8IHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9CiAgICB9CiAgfQogIGxldCBoaWdoZXN0TGV2ZWwgPSAtMTsKICBsZXQgbG93ZXN0T2RkTGV2ZWwgPSA5OTsKICBsZXQgbGV2ZWw7CiAgZm9yIChpID0gMCwgaWkgPSBsZXZlbHMubGVuZ3RoOyBpIDwgaWk7ICsraSkgewogICAgbGV2ZWwgPSBsZXZlbHNbaV07CiAgICBpZiAoaGlnaGVzdExldmVsIDwgbGV2ZWwpIHsKICAgICAgaGlnaGVzdExldmVsID0gbGV2ZWw7CiAgICB9CiAgICBpZiAobG93ZXN0T2RkTGV2Z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gVWludDhBcnJheSgwKTsKICAgIGxldCBtYXNrVGFibGUgPSBjb2xvclRhYmxlOwogICAgbGV0IGNvbXByZXNzaW9uID0gMDsKICAgIHN3aXRjaCAoa2luZCkgewogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICB7CiAgICAgICAgICBiaXRQZXJQaXhlbCA9IDE7CiAgICAgICAgICBjb2xvclRhYmxlID0gbmV3IFVpbnQ4QXJyYXkodGhpcy5faXNNYXNrID8gWzI1NSwgMjU1LCAyNTUsIDI1NSwgMCwgMCwgMCwgMF0gOiBbMCwgMCwgMCwgMCwgMjU1LCAyNTUsIDI1NSwgMjU1XSk7CiAgICAgICAgICBjb25zdCByb3dMZW4gPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgIGNvbnN0IHJvd1NpemUgPSByb3dMZW4gKyAzICYgLTQ7CiAgICAgICAgICBpZiAocm93TGVuICE9PSByb3dTaXplKSB7CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4sIGsgKz0gcm93U2l6ZSkgewogICAgICAgICAgICAgIG5ld0RhdGEuc2V0KGRhdGEuc3ViYXJyYXkoaSwgaSArIHJvd0xlbiksIGspOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgewogICAgICAgICAgYml0UGVyUGl4ZWwgPSAyNDsKICAgICAgICAgIGlmICh3aWR0aCAmIDMpIHsKICAgICAgICAgICAgY29uc3Qgcm93TGVuID0gMyAqIHdpZHRoOwogICAgICAgICAgICBjb25zdCByb3dTaXplID0gcm93TGVuICsgMyAmIC00OwogICAgICAgICAgICBjb25zdCBleHRyYUxlbiA9IHJvd1NpemUgLSByb3dMZW47CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4pIHsKICAgICAgICAgICAgICBjb25zdCByb3cgPSBkYXRhLnN1YmFycmF5KGksIGkgKyByb3dMZW4pOwogICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgcm93TGVuOyBqICs9IDMpIHsKICAgICAgICAgICAgICAgIG5ld0RhdGFbaysrXSA9IHJvd1tqICsgMl07CiAgICAgICAgICAgICAgICBuZXdEYXRhW2srK10gPSByb3dbaiArIDFdOwogICAgICAgICAgICAgICAgbmV3RGF0YVtrKytdID0gcm93W2pdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBrICs9IGV4dHJhTGVuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGF0YS5sZW5ndGg7IGkgPCBpaTsgaSArPSAzKSB7CiAgICAgICAgICAgICAgY29uc3QgdG1wID0gZGF0YVtpXTsKICAgICAgICAgICAgICBkYXRhW2ldID0gZGF0YVtpICsgMl07CiAgICAgICAgICAgICAgZGF0YVtpICsgMl0gPSB0bXA7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgY2FzZSBfdXRpbC5JbWFnZUtpbmQuUkdCQV8zMkJQUDoKICAgICAgICBiaXRQZXJQaXhlbCA9IDMyOwogICAgIC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AgIGNvbnN0IEMxX0xPVyA9IEMxICYgTUFTS19MT1csCiAgICAgIEMyX0xPVyA9IEMyICYgTUFTS19MT1c7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGJsb2NrQ291bnRzOyBpKyspIHsKICAgICAgaWYgKGkgJiAxKSB7CiAgICAgICAgazEgPSBkYXRhVWludDMyW2ldOwogICAgICAgIGsxID0gazEgKiBDMSAmIE1BU0tfSElHSCB8IGsxICogQzFfTE9XICYgTUFTS19MT1c7CiAgICAgICAgazEgPSBrMSA8PCAxNSB8IGsxID4+PiAxNzsKICAgICAgICBrMSA9IGsxICogQzIgJiBNQVNLX0hJR0ggfCBrMSAqIEMyX0xPVyAmIE1BU0tfTE9XOwogICAgICAgIGgxIF49IGsxOwogICAgICAgIGgxID0gaDEgPDwgMTMgfCBoMSA+Pj4gMTk7CiAgICAgICAgaDEgPSBoMSAqIDUgKyAweGU2NTQ2YjY0OwogICAgICB9IGVsc2UgewogICAgICAgIGsyID0gZGF0YVVpbnQzMltpXTsKICAgICAgICBrMiA9IGsyICogQzEgJiBNQVNLX0hJR0ggfCBrMiAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgIGsyID0gazIgPDwgMTUgfCBrMiA+Pj4gMTc7CiAgICAgICAgazIgPSBrMiAqIEMyICYgTUFTS19ISUdIIHwgazIgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICBoMiBePSBrMjsKICAgICAgICBoMiA9IGgyIDw8IDEzIHwgaDIgPj4+IDE5OwogICAgICAgIGgyID0gaDIgKiA1ICsgMHhlNjU0NmI2NDsKICAgICAgfQogICAgfQogICAgazEgPSAwOwogICAgc3dpdGNoICh0YWlsTGVuZ3RoKSB7CiAgICAgIGNhc2UgMzoKICAgICAgICBrMSBePSBkYXRhW2Jsb2NrQ291bnRzICogNCArIDJdIDw8IDE2OwogICAgICBjYXNlIDI6CiAgICAgICAgazEgXj0gZGF0YVtibG9ja0NvdW50cyAqIDQgKyAxXSA8PCA4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gICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEJpdHMgcGVyIGNvbXBvbmVudCBtaXNzaW5nIGluIGltYWdlOiAke3RoaXMuaW1hZ2VNYXNrfWApOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgdGhpcy5icGMgPSBiaXRzUGVyQ29tcG9uZW50OwogICAgaWYgKCF0aGlzLmltYWdlTWFzaykgewogICAgICBsZXQgY29sb3JTcGFjZSA9IGRpY3QuZ2V0UmF3KCJDUyIpIHx8IGRpY3QuZ2V0UmF3KCJDb2xvclNwYWNlIik7CiAgICAgIGlmICghY29sb3JTcGFjZSkgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSlBYIGltYWdlcyAod2hpY2ggZG8gbm90IHJlcXVpcmUgY29sb3Igc3BhY2VzKSIpOwogICAgICAgIHN3aXRjaCAoaW1hZ2UubnVtQ29tcHMpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VHcmF5Iik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICBjb2xvclNwYWNlID0gX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkRldmljZVJHQiIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VDTVlLIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBKUFggaW1hZ2VzIHdpdGggJHtpbWFnZS5udW1Db21wc30gY29sb3IgY29tcG9uZW50cyBub3Qgc3VwcG9ydGVkLmApOwogICAgICAgIH0KICAgICAgfQogICAgICB0aGlzLmNvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYW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sgMV07CiAgICAgICAgdGhpcy5kZWNvZGVDb2VmZmljaWVudHNbal0gPSBpc0luZGV4ZWQgPyAoZG1heCAtIGRtaW4pIC8gbWF4IDogZG1heCAtIGRtaW47CiAgICAgICAgdGhpcy5kZWNvZGVBZGRlbmRzW2pdID0gaXNJbmRleGVkID8gZG1pbiA6IG1heCAqIGRtaW47CiAgICAgIH0KICAgIH0KICAgIGlmIChzbWFzaykgewogICAgICB0aGlzLnNtYXNrID0gbmV3IFBERkltYWdlKHsKICAgICAgICB4cmVmLAogICAgICAgIHJlcywKICAgICAgICBpbWFnZTogc21hc2ssCiAgICAgICAgaXNJbmxpbmUsCiAgICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgIH0pOwogICAgfSBlbHNlIGlmIChtYXNrKSB7CiAgICAgIGlmIChtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBtYXNrRGljdCA9IG1hc2suZGljdCwKICAgICAgICAgIGltYWdlTWFzayA9IG1hc2tEaWN0LmdldCgiSU0iLCAiSW1hZ2VNYXNrIik7CiAgICAgICAgaWYgKCFpbWFnZU1hc2spIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSWdub3JpbmcgL01hc2sgaW4gaW1hZ2Ugd2l0aG91dCAvSW1hZ2VNYXNrLiIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aGlzLm1hc2sgPSBuZXcgUERGSW1hZ2UoewogICAgICAgICAgICB4cmVmLAogICAgICAgICAgICByZXMsCiAgICAgICAgICAgIGltYWdlOiBtYXNrLAogICAgICAgICAgICBpc0lubGluZSwKICAgICAgICAgICAgaXNNYXNrOiB0cnVlLAogICAgICAgICAgICBwZGZGdW5jdGlvbkZhY3RvcnksCiAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5tYXNrID0gbWFzazsKICAgICAgfQogICAgfQogIH0KICBzdGF0aWMgYXN5bmMgYnVpbGRJbWFnZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgcmVzLAogICAgICBpbWFnZSwKICAgICAgaXNJbmxpbmUgPSBmYWxzZSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSA9IF9yZWYyOwogICAgY29uc3QgaW1hZ2VEYXRhID0gaW1hZ2U7CiAgICBsZXQgc21hc2tEYXRhID0gbnVsbDsKICAgIGxldCBtYXNrRGF0YSA9IG51bGw7CiAgICBjb25zdCBzbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJTTWFzayIpOwogICAgY29uc3QgbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJNYXNrIik7CiAgICBpZiAoc21hc2spIHsKICAgICAgaWYgKHNtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBzbWFza0RhdGEgPSBzbWFzazsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIC9TTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAobWFzaykgewogICAgICBpZiAobWFzayBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtIHx8IEFycmF5LmlzQXJyYXkobWFzaykpIHsKICAgICAgICBtYXNrRGF0YSA9IG1hc2s7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbnN1cHBvcnRlZCAvTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBuZXcgUERGSW1hZ2UoewogICAgICB4cmVmLAogICAgICByZXMsCiAgICAgIGltYWd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dGEsCiAgICAgICAgICB3aWR0aCwKICAgICAgICAgIGhlaWdodCwKICAgICAgICAgIG5vbkJsYWNrQ29sb3I6IDAsCiAgICAgICAgICBpbnZlcnNlRGVjb2RlCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIF9pbWFnZV9yZXNpemVyLkltYWdlUmVzaXplci5jcmVhdGVJbWFnZSh7CiAgICAgICAgICBraW5kOiBfdXRpbC5JbWFnZUtpbmQuUkdCQV8zMkJQUCwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICB3aWR0aCwKICAgICAgICAgIGhlaWdodCwKICAgICAgICAgIGludGVycG9sYXRlCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uc3QgY2FudmFzID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgY29uc3QgY3R4ID0gY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGltZ0RhdGEgPSBjdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBoZWlnaHQpOwogICAgICAoMCwgX2ltYWdlX3V0aWxzLmNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBKSh7CiAgICAgICAgc3JjOiBpbWdBcnJheSwKICAgICAgICBkZXN0OiBpbWdEYXRhLmRhdGEsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIG5vbkJsYWNrQ29sb3I6IDAsCiAgICAgICAgaW52ZXJzZURlY29kZQogICAgICB9KTsKICAgICAgY3R4LnB1dEltYWdlRGF0YShpbWdEYXRhLCAwLCAwKTsKICAgICAgY29uc3QgYml0bWFwID0gY2FudmFzLnRyYW5zZmVyVG9JbWFnZUJpdG1hcCgpOwogICAgICByZXR1cm4gewogICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIGludGVycG9sYXRlLAogICAgICAgIGJpdG1hcAogICAgICB9OwogICAg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dGggKiB0aGlzLmhlaWdodDsgaSA8IGlpOyBpKyspIHsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBudW1Db21wczsgaisrKSB7CiAgICAgICAgYnVmZmVyW2luZGV4XSA9IGRlY29kZUFuZENsYW1wKGJ1ZmZlcltpbmRleF0sIGRlY29kZUFkZGVuZHNbal0sIGRlY29kZUNvZWZmaWNpZW50c1tqXSwgbWF4KTsKICAgICAgICBpbmRleCsrOwogICAgICB9CiAgICB9CiAgfQogIGdldENvbXBvbmVudHMoYnVmZmVyKSB7CiAgICBjb25zdCBicGMgPSB0aGlzLmJwYzsKICAgIGlmIChicGMgPT09IDgpIHsKICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgIH0KICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDsKICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0OwogICAgY29uc3QgbnVtQ29tcHMgPSB0aGlzLm51bUNvbXBzOwogICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiBudW1Db21wczsKICAgIGxldCBidWZmZXJQb3MgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGlmIChicGMgPD0gOCkgewogICAgICBvdXRwdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgfSBlbHNlIGlmIChicGMgPD0gMTYpIHsKICAgICAgb3V0cHV0ID0gbmV3IFVpbnQxNkFycmF5KGxlbmd0aCk7CiAgICB9IGVsc2UgewogICAgICBvdXRwdXQgPSBuZXcgVWludDMyQXJyYXkobGVuZ3RoKTsKICAgIH0KICAgIGNvbnN0IHJvd0NvbXBzID0gd2lkdGggKiBudW1Db21wczsKICAgIGNvbnN0IG1heCA9ICgxIDw8IGJwYykgLSAxOwogICAgbGV0IGkgPSAwLAogICAgICBpaSwKICAgICAgYnVmOwogICAgaWYgKGJwYyA9PT0gMSkgewogICAgICBsZXQgbWFzaywgbG9vcDFFbmQsIGxvb3AyRW5kOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGhlaWdodDsgaisrKSB7CiAgICAgICAgbG9vcDFFbmQgPSBpICsgKHJvd0NvbXBzICYgfjcpOwogICAgICAgIGxvb3AyRW5kID0gaSArIHJvd0NvbXBzOwogICAgICAgIHdoaWxlIChpIDwgbG9vcDFFbmQpIHsKICAgICAgICAgIGJ1ZiA9IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBvdXRwdXRbaV0gPSBidWYgPj4gNyAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDFdID0gYnVmID4+IDYgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyAyXSA9IGJ1ZiA+PiA1ICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgM10gPSBidWYgPj4gNCAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDRdID0gYnVmID4+IDMgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyA1XSA9IGJ1ZiA+PiAyICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgNl0gPSBidWYgPj4gMSAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDddID0gYnVmICYgMTsKICAgICAgICAgIGkgKz0gODsKICAgICAgICB9CiAgICAgICAgaWYgKGkgPCBsb29wMkVuZCkgewogICAgICAgICAgYnVmID0gYnVmZmVyW2J1ZmZlclBvcysrXTsKICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICB3aGlsZSAoaSA8IGxvb3AyRW5kKSB7CiAgICAgICAgICAgIG91dHB1dFtpKytdID0gKyEhKGJ1ZiAmIG1hc2spOwogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IGJpdHMgPSAwOwogICAgICBidWYgPSAwOwogICAgICBmb3IgKGkgPSAwLCBpaSA9IGxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgICBpZiAoaSAlIHJvd0NvbXBzID09PSAwKSB7CiAgICAgICAgICBidWYgPSAwOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChiaXRzIDwgYnBjKSB7CiAgICAgICAgICBidWYgPSBidWYgPDwgOCB8IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHJlbWFpbmluZ0JpdHMgPSBiaXRzIC0gYnBjOwogICAgICAgIGxldCB2YWx1ZSA9IGJ1ZiA+PiByZW1haW5pbmdCaXRzOwogICAgICAgIGlmICh2YWx1ZSA8IDApIHsKICAgICAgICAgIHZhbHVlID0gMDsKICAgICAgICB9IGVsc2UgaWYgKHZhbHVlID4gbWF4KSB7CiAgICAgICAgICB2YWx1ZSA9IG1heDsKICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgICAgYnVmICY9ICgxIDw8IHJlbWFpbmluZ0JpdHMpIC0gMTsKICAgICAgICBiaXRzID0gcmVtYWluaW5nQml0czsKICAgICAgfQogICAgfQogICAgcmV0dXJuIG91dHB1dDsKICB9CiAgZmlsbE9wYWNpdHkocmdiYUJ1Ziwgd2lkdGgsIGhlaWdodCwgYWN0dWFsSGVpZ2h0LCBpbWFnZSkgewogICAgY29uc3Qgc21hc2sgPSB0aGlzLnNtYXNrOwogICAgY29uc3QgbWFzayA9IHRoaXMubWFzazsKICAgIGxldCBhbHBoYUJ1Ziwgc3csIHNoLCBpLCBpaSwgajsKICAgIGlmIChzbWFzaykgewogICAgICBzdyA9IHNtYXNrLndpZHRoOwogICAgICBzaCA9IHNtYXNrLmhlaWdodDsKICAgICAgYWxwaGFCdWYgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoc3cgKiBzaCk7CiAgICAgIHNtYXNrLmZpbGxHcmF5QnVmZmVyKGFscGhhQnVmKTsKICAgICAgaWYgKHN3ICE9PSB3aWR0aCB8fCBzaCAhPT0gaGVpZ2h0KSB7CiAgICAgICA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hdGE7CiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBidWZmZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICBidWZmZXJbaV0gXj0gMHhmZjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGltZ0RhdGE7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuaW1hZ2UgaW5zdGFuY2VvZiBfanBlZ19zdHJlYW0uSnBlZ1N0cmVhbSAmJiAhdGhpcy5zbWFzayAmJiAhdGhpcy5tYXNrKSB7CiAgICAgICAgbGV0IGltYWdlTGVuZ3RoID0gb3JpZ2luYWxIZWlnaHQgKiByb3dCeXRlczsKICAgICAgICBpZiAoaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQgJiYgIW11c3RCZVJlc2l6ZWQpIHsKICAgICAgICAgIGxldCBpc0hhbmRsZWQgPSBmYWxzZTsKICAgICAgICAgIHN3aXRjaCAodGhpcy5jb2xvclNwYWNlLm5hbWUpIHsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlR3JheSI6CiAgICAgICAgICAgICAgaW1hZ2VMZW5ndGggKj0gNDsKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJEZXZpY2VSR0IiOgogICAgICAgICAgICAgIGltYWdlTGVuZ3RoID0gaW1hZ2VMZW5ndGggLyAzICogNDsKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJEZXZpY2VDTVlLIjoKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGlzSGFuZGxlZCkgewogICAgICAgICAgICBjb25zdCByZ2JhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKGltYWdlTGVuZ3RoLCB7CiAgICAgICAgICAgICAgZHJhd1dpZHRoLAogICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgZm9yY2VSR0JBOiB0cnVlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gdGhpcy5jcmVhdGVCaXRtYXAoX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFAsIGRyYXdXaWR0aCwgZHJhd0hlaWdodCwgcmdiYSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN3aXRjaCAodGhpcy5jb2xvclNwYWNlLm5hbWUpIHsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlR3JheSI6CiAgICAgICAgICAgICAgaW1hZ2VMZW5ndGggKj0gMzsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgICAgY2FzZSAiRGV2aWNlQ01ZSyI6CiAgICAgICAgICAgICAgaW1nRGF0YS5raW5kID0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDsKICAgICAgICAgICAgICBpbWdEYXRhLmRhdGEgPSB0aGlzLmdldEltYWdlQnl0ZXMoaW1hZ2VMZW5ndGgsIHsKICAgICAgICAgICAgICAgIGRyYXdXaWR0aCwKICAgICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgICBmb3JjZVJHQjogdHJ1ZQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIGlmIChtdXN0QmVSZXNpemVkKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gX2ltYWdlX3Jlc2l6ZXIuSW1hZ2VSZXNpemVyLmNyZWF0ZUltYWdlKGltZ0RhdGEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICByZXR1cm4gaW1nRGF0YTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGltZ0FycmF5ID0gdGhpcy5nZXRJbWFnZUJ5dGVzKG9yaWdpbmF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KICAgIH0pOwogIH0KICBfcGFyc2VDb250ZW50KHMsIHN0YXJ0KSB7CiAgICBjb25zdCBhdHRyaWJ1dGVzID0gW107CiAgICBsZXQgcG9zID0gc3RhcnQ7CiAgICBmdW5jdGlvbiBza2lwV3MoKSB7CiAgICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiBpc1doaXRlc3BhY2UocywgcG9zKSkgewogICAgICAgICsrcG9zOwogICAgICB9CiAgICB9CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj4iICYmIHNbcG9zXSAhPT0gIi8iKSB7CiAgICAgICsrcG9zOwogICAgfQogICAgY29uc3QgbmFtZSA9IHMuc3Vic3RyaW5nKHN0YXJ0LCBwb3MpOwogICAgc2tpcFdzKCk7CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiLyIgJiYgc1twb3NdICE9PSAiPyIpIHsKICAgICAgc2tpcFdzKCk7CiAgICAgIGxldCBhdHRyTmFtZSA9ICIiLAogICAgICAgIGF0dHJWYWx1ZSA9ICIiOwogICAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj0iKSB7CiAgICAgICAgYXR0ck5hbWUgKz0gc1twb3NdOwogICAgICAgICsrcG9zOwogICAgICB9CiAgICAgIHNraXBXcygpOwogICAgICBpZiAoc1twb3NdICE9PSAiPSIpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICArK3BvczsKICAgICAgc2tpcFdzKCk7CiAgICAgIGNvbnN0IGF0dHJFbmRDaGFyID0gc1twb3NdOwogICAgICBpZiAoYXR0ckVuZENoYXIgIT09ICciJyAmJiBhdHRyRW5kQ2hhciAhPT0gIiciKSB7CiAgICAgICAgcmV0dXJuIG51bGw7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SAiPyIgfHwgc1twb3MgKyAxXSAhPT0gIj4iKSkgewogICAgICArK3BvczsKICAgIH0KICAgIGNvbnN0IHZhbHVlID0gcy5zdWJzdHJpbmcoYXR0clN0YXJ0LCBwb3MpOwogICAgcmV0dXJuIHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUsCiAgICAgIHBhcnNlZDogcG9zIC0gc3RhcnQKICAgIH07CiAgfQogIHBhcnNlWG1sKHMpIHsKICAgIGxldCBpID0gMDsKICAgIHdoaWxlIChpIDwgcy5sZW5ndGgpIHsKICAgICAgY29uc3QgY2ggPSBzW2ldOwogICAgICBsZXQgaiA9IGk7CiAgICAgIGlmIChjaCA9PT0gIjwiKSB7CiAgICAgICAgKytqOwogICAgICAgIGNvbnN0IGNoMiA9IHNbal07CiAgICAgICAgbGV0IHE7CiAgICAgICAgc3dpdGNoIChjaDIpIHsKICAgICAgICAgIGNhc2UgIi8iOgogICAgICAgICAgICArK2o7CiAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqKTsKICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkVuZEVsZW1lbnQocy5zdWJzdHJpbmcoaiwgcSkpOwogICAgICAgICAgICBqID0gcSArIDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiPyI6CiAgICAgICAgICAgICsrajsKICAgICAgICAgICAgY29uc3QgcGkgPSB0aGlzLl9wYXJzZVByb2Nlc3NpbmdJbnN0cnVjdGlvbihzLCBqKTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBwaS5wYXJzZWQsIGogKyBwaS5wYXJzZWQgKyAyKSAhPT0gIj8+IikgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuVW50ZXJtaW5hdGVkWG1sRGVjbGFyYXRpb24pOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLm9uUGkocGkubmFtZSwgcGkudmFsdWUpOwogICAgICAgICAgICBqICs9IHBpLnBhcnNlZCArIDI7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiISI6CiAgICAgICAgICAgIGlmIChzLnN1YnN0cmluZyhqICsgMSwgaiArIDMpID09PSAiLS0iKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiLS0+IiwgaiArIDMpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDb21tZW50KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNvbW1lbnQocy5zdWJzdHJpbmcoaiArIDMsIHEpKTsKICAgICAgICAgICAgICBqID0gcSArIDM7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIDEsIGogKyA4KSA9PT0gIltDREFUQVsiKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiXV0+IiwgaiArIDgpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDZGF0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNkYXRhKHMuc3Vic3RyaW5nKGogKyA4LCBxKSk7CiAgICAgICAgICAgICAgaiA9IHEgKyAzOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMuc3Vic3RyaW5nKGogKyAxLCBqICsgOCkgPT09ICJET0NUWVBFIikgewogICAgICAgICAgICAgIGNvbnN0IHEyID0gcy5pbmRleE9mKCJbIiwgaiArIDgpOwogICAgICAgICAgICAgIGxldCBjb21wbGV4RG9jdHlwZSA9IGZhbHNlOwogICAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqICsgOCk7CiAgICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChxMiA+IDAgJiYgcSA+IHEyKSB7CiAgICAgICAgICAgICAgICBxID0gcy5pbmRleE9mKCJdPiIsIGogKyA4KTsKICAgICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbXBsZXhEb2N0eXBlID0gdHJ1ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZG9jdHlwZUNvbnRlbnQgPSBzLnN1YnN0cmluZyhqICsgOCwgcSArIChjb21wbGV4RG9jdHlwZSA/IDEgOiAwKSk7CiAgICAgICAgICAgICAgdGhpcy5vbkRvY3R5cGUoZG9jdHlwZUNvbnRlbnQpOwogICAgICAgICAgICAgIGogPSBxICsgKGNvbXBsZXhEb2N0eXBlID8gMiA6IDEpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuTWFsZm9ybWVkRWxlbWVudCk7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgY29uc3QgY29udGVudCA9IHRoaXMuX3BhcnNlQ29udGVudChzLCBqKTsKICAgICAgICAgICAgaWYgKGNvbnRlbnQgPT09IG51bGwpIHsKICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLk1hbGZvcm1lZEVsZW1lbnQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaXNDbG9zZWQgPSBmYWxzZTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBjb250ZW50LnBhcnNlZCwgaiArIGNvbnRlbnQucGFyc2VkICsgMikgPT09ICIvPiIpIHsKICAgICAgICAgICAgICBpc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIGNvbnRlbnQucGFyc2VkLCBqICsgY29udGVudC5wYXJzZWQgKyAxKSAhPT0gIj4iKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkJlZ2luRWxlbWVudChjb250ZW50Lm5hbWUsIGNvbnRlbnQuYXR0cmlidXRlcywgaXNDbG9zZWQpOwogICAgICAgICAgICBqICs9IGNvbnRlbnQucGFyc2VkICsgKGlzQ2xvc2VkID8gMiA6IDEpOwogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgd2hpbGUgKGogPCBzLmxlbmd0aCAmJiBzW2pdICE9PSAiPCIpIHsKICAgICAgICAgIGorKzsKICAgICAgICB9CiAgICAgICAgY29uc3QgdGV4dCA9IHMuc3Vic3RyaW5nKGksIGopOwog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Tm9kZXMuaW5kZXhPZih0aGlzKTsKICAgIGlmIChpbmRleCA9PT0gLTEpIHsKICAgICAgcmV0dXJuIHVuZGVmaW5lZDsKICAgIH0KICAgIHJldHVybiBjaGlsZE5vZGVzW2luZGV4ICsgMV07CiAgfQogIGdldCB0ZXh0Q29udGVudCgpIHsKICAgIGlmICghdGhpcy5jaGlsZE5vZGVzKSB7CiAgICAgIHJldHVybiB0aGlzLm5vZGVWYWx1ZSB8fCAiIjsKICAgIH0KICAgIHJldHVybiB0aGlzLmNoaWxkTm9kZXMubWFwKGZ1bmN0aW9uIChjaGlsZCkgewogICAgICByZXR1cm4gY2hpbGQudGV4dENvbnRlbnQ7CiAgICB9KS5qb2luKCIiKTsKICB9CiAgZ2V0IGNoaWxkcmVuKCkgewogICAgcmV0dXJuIHRoaXMuY2hpbGROb2RlcyB8fCBbXTsKICB9CiAgaGFzQ2hpbGROb2RlcygpIHsKICAgIHJldHVybiB0aGlzLmNoaWxkTm9kZXMgJiYgdGhpcy5jaGlsZE5vZGVzLmxlbmd0aCA+IDA7CiAgfQogIHNlYXJjaE5vZGUocGF0aHMsIHBvcykgewogICAgaWYgKHBvcyA+PSBwYXRocy5sZW5ndGgpIHsKICAgICAgcmV0dXJuIHRoaXM7CiAgICB9CiAgICBjb25zdCBjb21wb25lbnQgPSBwYXRoc1twb3NdOwogICAgY29uc3Qgc3RhY2sgPSBbXTsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjb21wb25lbnQubmFtZSA9PT0gbm9kZS5ub2RlTmFtZSkgewogICAgICAgIGlmIChjb21wb25lbnQucG9zID09PSAwKSB7CiAgICAgICAgICBjb25zdCByZXMgPSBub2RlLnNlYXJjaE5vZGUocGF0aHMsIHBvcyArIDEpOwogICAgICAgICAgaWYgKHJlcyAhPT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm4gcmVzOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgW3BhcmVudF0gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGxldCBzaWJsaW5nUG9zID0gMDsKICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgcGFyZW50LmNoaWxkTm9kZXMpIHsKICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5uYW1lID09PSBjaGlsZC5ub2RlTmFtZSkgewogICAgICAgICAgICAgIGlmIChzaWJsaW5nUG9zID09PSBjb21wb25lbnQucG9zKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gY2hpbGQuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNpYmxpbmdQb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5vZGUuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChub2RlLmNoaWxkTm9kZXMgJiYgbm9kZS5jaGlsZE5vZGVzLmxlbmd0aCAhPT0gMCkgewogICAgICAgIHN0YWNrLnB1c2goW25vZGUsIDBdKTsKICAgICAgICBub2RlID0gbm9kZS5jaGlsZE5vZGVzWzBdOwogICAgICB9IGVsc2UgaWYgKHN0YWNrLmxlbmd0aCA9PT0gMCkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9IGVsc2UgewogICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGN1cnJlbnRQb3NdID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBjb25zdCBuZXdQb3MgPSBjdXJyZW50UG9zICsgMTsKICAgICAgICAgIGlmIChuZXdQb3MgPCBwYXJlbnQuY2hpbGROb2Rlcy5sZW5ndGgpIHsKICAgICAgICAgICAgc3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pIDwgbGVuZ3RoOyArK2kpIHsKICAgICAgcGFkZGVkW2ldID0gZGF0YVtvZmZzZXQrK107CiAgICB9CiAgICBwYWRkZWRbaSsrXSA9IDB4ODA7CiAgICBjb25zdCBuID0gcGFkZGVkTGVuZ3RoIC0gODsKICAgIHdoaWxlIChpIDwgbikgewogICAgICBwYWRkZWRbaSsrXSA9IDA7CiAgICB9CiAgICBwYWRkZWRbaSsrXSA9IGxlbmd0aCA8PCAzICYgMHhmZjsKICAgIHBhZGRlZFtpKytdID0gbGVuZ3RoID4+IDUgJiAweGZmOwogICAgcGFkZGVkW2krK10gPSBsZW5ndGggPj4gMTMgJiAweGZmOwogICAgcGFkZGVkW2krK10gPSBsZW5ndGggPj4gMjEgJiAweGZmOwogICAgcGFkZGVkW2krK10gPSBsZW5ndGggPj4+IDI5ICYgMHhmZjsKICAgIHBhZGRlZFtpKytdID0gMDsKICAgIHBhZGRlZFtpKytdID0gMDsKICAgIHBhZGRlZFtpKytdID0gMDsKICAgIGNvbnN0IHcgPSBuZXcgSW50MzJBcnJheSgxNik7CiAgICBmb3IgKGkgPSAwOyBpIDwgcGFkZGVkTGVuZ3RoOykgewogICAgICBmb3IgKGogPSAwOyBqIDwgMTY7ICsraiwgaSArPSA0KSB7CiAgICAgICAgd1tqXSA9IHBhZGRlZFtpXSB8IHBhZGRlZFtpICsgMV0gPDwgOCB8IHBhZGRlZFtpICsgMl0gPDwgMTYgfCBwYWRkZWRbaSArIDNdIDw8IDI0OwogICAgICB9CiAgICAgIGxldCBhID0gaDAsCiAgICAgICAgYiA9IGgxLAogICAgICAgIGMgPSBoMiwKICAgICAgICBkID0gaDMsCiAgICAgICAgZiwKICAgICAgICBnOwogICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7ICsraikgewogICAgICAgIGlmIChqIDwgMTYpIHsKICAgICAgICAgIGYgPSBiICYgYyB8IH5iICYgZDsKICAgICAgICAgIGcgPSBqOwogICAgICAgIH0gZWxzZSBpZiAoaiA8IDMyKSB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Gxlbmd0aCA+PiA1ICYgMHhmZjsKICAgIHBhZGRlZFtpKytdID0gbGVuZ3RoIDw8IDMgJiAweGZmOwogICAgY29uc3QgdyA9IG5ldyBVaW50MzJBcnJheSg2NCk7CiAgICBmb3IgKGkgPSAwOyBpIDwgcGFkZGVkTGVuZ3RoOykgewogICAgICBmb3IgKGogPSAwOyBqIDwgMTY7ICsraikgewogICAgICAgIHdbal0gPSBwYWRkZWRbaV0gPDwgMjQgfCBwYWRkZWRbaSArIDFdIDw8IDE2IHwgcGFkZGVkW2kgKyAyXSA8PCA4IHwgcGFkZGVkW2kgKyAzXTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0KICAgICAgZm9yIChqID0gMTY7IGogPCA2NDsgKytqKSB7CiAgICAgICAgd1tqXSA9IGxpdHRsZVNpZ21hUHJpbWUod1tqIC0gMl0pICsgd1tqIC0gN10gKyBsaXR0bGVTaWdtYSh3W2ogLSAxNV0pICsgd1tqIC0gMTZdIHwgMDsKICAgICAgfQogICAgICBsZXQgYSA9IGgwLAogICAgICAgIGIgPSBoMSwKICAgICAgICBjID0gaDIsCiAgICAgICAgZCA9IGgzLAogICAgICAgIGUgPSBoNCwKICAgICAgICBmID0gaDUsCiAgICAgICAgZyA9IGg2LAogICAgICAgIGggPSBoNywKICAgICAgICB0MSwKICAgICAgICB0MjsKICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyArK2opIHsKICAgICAgICB0MSA9IGggKyBzaWdtYVByaW1lKGUpICsgY2goZSwgZiwgZykgKyBrW2pdICsgd1tqXTsKICAgICAgICB0MiA9IHNpZ21hKGEpICsgbWFqKGEsIGIsIGMpOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGUgPSBkICsgdDEgfCAwOwogICAgICAgIGQgPSBjOwogICAgICAgIGMgPSBiOwogICAgICAgIGIgPSBhOwogICAgICAgIGEgPSB0MSArIHQyIHwgMDsKICAgICAgfQogICAgICBoMCA9IGgw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wMSwgYSwgYiwgYywgdG1wMik7CiAgICAgICAgdDIuYWRkKHRtcDEpOwogICAgICAgIHRtcDMgPSBoOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGQuYWRkKHQxKTsKICAgICAgICBlID0gZDsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYTsKICAgICAgICB0bXAzLmFzc2lnbih0MSk7CiAgICAgICAgdG1wMy5hZGQodDIpOwogICAgICAgIGEgPSB0bXAzOwogICAgICB9CiAgICAgIGgwLmFkZChhKTsKICAgICAgaDEuYWRkKGIpOwogICAgICBoMi5hZGQoYyk7CiAgICAgIGgzLmFkZChkKTsKICAgICAgaDQuYWRkKGUpOwogICAgICBoNS5hZGQoZik7CiAgICAgIGg2LmFkZChnKTsKICAgICAgaDcuYWRkKGgpOwogICAgfQogICAgbGV0IHJlc3VsdDsKICAgIGlmICghbW9kZTM4NCkgewogICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheSg2NCk7CiAgICAgIGgwLmNvcHlUbyhyZXN1bHQsIDApOwogICAgICBoMS5jb3B5VG8ocmVzdWx0LCA4KTsKICAgICAgaDIuY29weVRvKHJlc3VsdCwgMTYpOwogICAgICBoMy5jb3B5VG8ocmVzdWx0LCAyNCk7CiAgICAgIGg0LmNvcHlUbyhyZXN1bHQsIDMyKTsKICAgICAgaDUuY29weVRvKHJlc3VsdCwgNDApOwogICAgICBoNi5jb3B5VG8ocmVzdWx0LCA0OCk7CiAgICAgIGg3LmNvcHlUbyhyZXN1bHQsIDU2KTsKICAgIH0gZWxzZSB7CiAgICAgIHJlc3VsdCA9IG5ldyBVaW50OEFycmF5KDQ4KTsKICAgICAgaDAuY29weVRvKHJlc3VsdCwgMCk7CiAgICAgIGgxLmNvcHlUbyhyZXN1bHQsIDgpOwogICAgICBoMi5jb3B5VG8ocmVzdWx0LCAxNik7CiAgICAgIGgzLmNvcHlUbyhyZXN1bHQsI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hdGVbMTNdID0gdjsKICAgICAgdiA9IHN0YXRlWzJdOwogICAgICB1ID0gc3RhdGVbNl07CiAgICAgIHN0YXRlWzJdID0gc3RhdGVbMTBdOwogICAgICBzdGF0ZVs2XSA9IHN0YXRlWzE0XTsKICAgICAgc3RhdGVbMTBdID0gdjsKICAgICAgc3RhdGVbMTRdID0gdTsKICAgICAgdiA9IHN0YXRlWzNdOwogICAgICB1ID0gc3RhdGVbN107CiAgICAgIHQgPSBzdGF0ZVsxMV07CiAgICAgIHN0YXRlWzNdID0gc3RhdGVbMTVdOwogICAgICBzdGF0ZVs3XSA9IHY7CiAgICAgIHN0YXRlWzExXSA9IHU7CiAgICAgIHN0YXRlWzE1XSA9IHQ7CiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7IGogKz0gNCkgewogICAgICAgIGNvbnN0IHMwID0gc3RhdGVbaiArIDBdOwogICAgICAgIGNvbnN0IHMxID0gc3RhdGVbaiArIDFdOwogICAgICAgIGNvbnN0IHMyID0gc3RhdGVbaiArIDJdOwogICAgICAgIGNvbnN0IHMzID0gc3RhdGVbaiArIDNdOwogICAgICAgIHQgPSBzMCBeIHMxIF4gczIgXiBzMzsKICAgICAgICBzdGF0ZVtqICsgMF0gXj0gdCBeIHRoaXMuX21peENvbFtzMCBeIHMxXTsKICAgICAgICBzdGF0ZVtqICsgMV0gXj0gdCBeIHRoaXMuX21peENvbFtzMSBeIHMyXTsKICAgICAgICBzdGF0ZVtqICsgMl0gXj0gdCBeIHRoaXMuX21peENvbFtzMiBeIHMzXTsKICAgICAgICBzdGF0ZVtqICsgM10gXj0gdCBeIHRoaXMuX21peENvbFtzMyBeIHMwXTsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gMCwgayA9IGkgKiAxNjsgaiA8IDE2OyArK2osICsraykgewogICAgICAgIHN0YXRlW2pdIF49IGtleVtrXTsKICAgICAgfQogICAgfQogICAgZm9yIChsZXQgaiA9IDA7IGogPCAxNjsgKytqKSB7CiAgICAgIH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BpZiAoYnVmZmVyTGVuZ3RoIDwgMTYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBwbGFpbiA9IHRoaXMuX2RlY3J5cHQoYnVmZmVyLCB0aGlzLl9rZXkpOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IDE2OyArK2opIHsKICAgICAgICBwbGFpbltqXSBePSBpdltqXTsKICAgICAgfQogICAgICBpdiA9IGJ1ZmZlcjsKICAgICAgcmVzdWx0LnB1c2gocGxhaW4pOwogICAgICBidWZmZXIgPSBuZXcgVWludDhBcnJheSgxNik7CiAgICAgIGJ1ZmZlckxlbmd0aCA9IDA7CiAgICB9CiAgICB0aGlzLmJ1ZmZlciA9IGJ1ZmZlcjsKICAgIHRoaXMuYnVmZmVyTGVuZ3RoID0gYnVmZmVyTGVuZ3RoOwogICAgdGhpcy5pdiA9IGl2OwogICAgaWYgKHJlc3VsdC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIG5ldyBVaW50OEFycmF5KDApOwogICAgfQogICAgbGV0IG91dHB1dExlbmd0aCA9IDE2ICogcmVzdWx0Lmxlbmd0aDsKICAgIGlmIChmaW5hbGl6ZSkgewogICAgICBjb25zdCBsYXN0QmxvY2sgPSByZXN1bHQuYXQoLTEpOwogICAgICBsZXQgcHNMZW4gPSBsYXN0QmxvY2tbMTVdOwogICAgICBpZiAocHNMZW4gPD0gMTYpIHsKICAgICAgICBmb3IgKGxldCBpID0gMTUsIGlpID0gMTYgLSBwc0xlbjsgaSA+PSBpaTsgLS1pKSB7CiAgICAgICAgICBpZiAobGFzdEJsb2NrW2ldICE9PSBwc0xlbikgewogICAgICAgICAgICBwc0xlbiA9IDA7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvdXRwdXRMZW5ndGggLT0gcHNMZW47CiAgICAgICAgcmVzdWx0W3Jlc3VsdC5sZW5ndGggLSAxXSA9IGxhc3RCbG9jay5zdWJhcnJheSg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ZXN1bHQubGVuZ3RoID09PSAwKSB7CiAgICAgIHJldHVybiBuZXcgVWludDhBcnJheSgwKTsKICAgIH0KICAgIGNvbnN0IG91dHB1dExlbmd0aCA9IDE2ICogcmVzdWx0Lmxlbmd0aDsKICAgIGNvbnN0IG91dHB1dCA9IG5ldyBVaW50OEFycmF5KG91dHB1dExlbmd0aCk7CiAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGlpOyArK2ksIGogKz0gMTYpIHsKICAgICAgb3V0cHV0LnNldChyZXN1bHRbaV0sIGopOwogICAgfQogICAgcmV0dXJuIG91dHB1dDsKICB9Cn0KY2xhc3MgQUVTMTI4Q2lwaGVyIGV4dGVuZHMgQUVTQmFzZUNpcGhlciB7CiAgY29uc3RydWN0b3Ioa2V5KSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5fY3ljbGVzT2ZSZXBldGl0aW9uID0gMTA7CiAgICB0aGlzLl9rZXlTaXplID0gMTYwOwogICAgdGhpcy5fcmNvbiA9IG5ldyBVaW50OEFycmF5KFsweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkXSk7CiAgICB0aGlzLl9rZXkgPSB0aGlzLl9leHBhbmRLZXkoa2V5KTsKICB9CiAgX2V4cGFuZEtleShjaXBoZXJLZXkpIHsKICAgIGNvbnN0IGIgPSAxNzY7CiAgICBjb25zdCBzID0gdGhpcy5fczsKICAgIGNvbnN0IHJjb24gPSB0aGlzLl9yY29uOwogICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkoYik7CiAgICByZXN1bHQuc2V0KGNpcGhlcktleSk7CiAgICBmb3IgKGxldCBqID0gMTYsIGkgPSAxOyBqIDwgYjsgKytpKSB7CiAgICAgIGxldCB0MSA9IHJlc3VsdFtqIC0gM107CiAgICAgIGxldCB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgIGxldCB0MyA9IHJlc3VsdFtqIC0gMV07CiAgICAgIGxldCB0NCA9IHJlc3VsdFtqIC0gNF07CiAgICAgIHQxID0gc1t0MV07CiAgICAgIHQyID0gc1t0Ml07CiAgICAgIHQzID0gc1t0M107CiAgICAgIHQ0ID0gc1t0NF07CiAgICAgIHQxIF49IHJjb25baV07CiAgICAgIGZvciAobGV0IG4gPSAwOyBuIDwgNDsgKytuKSB7CiAgICAgICAgcmVzdWx0W2pdID0gdDEgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQyIF49IHJlc3VsdFtqIC0gMTZdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0MyBePSByZXN1bHRbaiAtIDE2XTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDQgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzdWx0OwogIH0KfQpleHBvcnRzLkFFUzEyOENpcGhlciA9IEFFUzEyOENpcGhlcjsKY2xhc3MgQUVTMjU2Q2lwaGVyIGV4dGVuZHMgQUVTQmFzZUNpcGhlciB7CiAgY29uc3RydWN0b3Ioa2V5KSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5fY3ljbGVzT2ZSZXBldGl0aW9uID0gMTQ7CiAgICB0aGlzLl9rZXlTaXplID0gMjI0OwogICAgdGhpcy5fa2V5ID0gdGhpcy5fZXhwYW5kS2V5KGtleSk7CiAgfQogIF9leHBhbmRLZXkoY2lwaGVyS2V5KSB7CiAgICBjb25zdCBiID0gMjQwOwogICAgY29uc3QgcyA9IHRoaXMuX3M7CiAgICBjb25zdCByZXN1bHQgPSBuZXcgVWludDhBcnJheShiKTsKICAgIHJlc3VsdC5zZXQoY2lwaGVyS2V5KTsKICAgIGxldCByID0gMTsKICAgIGxldCB0MSwgdDIsIHQzLCB0NDsKICAgIGZvciAobGV0IGogPSAzMiwgaSA9IDE7IGogPCBiOyArK2kpIHsKICAgICAgaWYgKGogJSAzMiA9PT0gMTYpIHsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICB9IGVsc2UgaWYgKGogJSAzMiA9PT0gMCkgewogICAgICAgIHQxID0gcmVzdWx0W2ogLSAzXTsKICAgICAgICB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgICAgdDMgPSByZXN1bHRbaiAtIDFdOwogICAgICAgIHQ0ID0gcmVzdWx0W2ogLSA0XTsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICAgIHQxIF49IHI7CiAgICAgICAgaWYgKChyIDw8PSAxKSA+PSAyNTYpIHsKICAgICAgICAgIHIgPSAociBeIDB4MWIpICYgMHhmZjsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCA0OyArK24pIHsKICAgICAgICByZXN1bHRbal0gPSB0MSBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDIgXj0gcmVzdWx0W2ogLSAzMl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQzIF49IHJlc3VsdFtqIC0gMzJdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0NCBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByZXN1bHQ7CiAgfQp9CmV4cG9ydHMuQUVTMjU2Q2lwaGVyID0gQUVTMjU2Q2lwaGVyOwpjbGFzcyBQREYxNyB7CiAgY2hlY2tPd25lclBhc3N3b3JkKHBhc3N3b3JkLCBvd25lclZhbGlkYXRpb25TYWx0LCB1c2VyQnl0ZXMsIG93bmVyUGFzc3dvcmQpIHsKICAgIGNvbnN0IGhhc2hEYXRhID0gbmV3IFVpbnQ4QXJyYXkocGFzc3dvcmQubGVuZ3RoICsgNTYpOwogICAgaGFzaERhdGEuc2V0KHBhc3N3b3JkLCAwKTsKICAgIGhhc2hEYXRhLnNldChvd25lclZhbGlkYXRpb25TYWx0LCBwYXNzd29yZC5sZW5ndGgpOwogICAgaGFzaERhdGEuc2V0KHVzZXJCeXRlcywgcGFzc3dvcmQubGVuZ3RoICsgb3duZXJWYWxpZGF0aW9uU2FsdC5sZW5ndGgpOwogICAgY29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gICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwuaW5mbykoYFNraXBwaW5nIGludmFsaWQgTWV0YWRhdGE6ICIke2V4fSIuYCk7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1ldGFkYXRhIiwgbWV0YWRhdGEpOwogIH0KICBnZXQgbWFya0luZm8oKSB7CiAgICBsZXQgbWFya0luZm8gPSBudWxsOwogICAgdHJ5IHsKICAgICAgbWFya0luZm8gPSB0aGlzLl9yZWFkTWFya0luZm8oKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmFibGUgdG8gcmVhZCBtYXJrIGluZm8uIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1hcmtJbmZvIiwgbWFya0luZm8pOwogIH0KICBfcmVhZE1hcmtJbmZvKCkgewogICAgY29uc3Qgb2JqID0gdGhpcy5fY2F0RGljdC5nZXQoIk1hcmtJbmZvIik7CiAgICBpZiAoIShvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IG1hcmtJbmZvID0gewogICAgICBNYXJrZWQ6IGZhbHNlLAogICAgICBVc2VyUHJvcGVydGllczogZmFsc2UsCiAgICAgIFN1c3BlY3RzOiBmYWxzZQogICAgfTsKICAgIGZvciAoY29uc3Qga2V5IGluIG1hcmtJbmZvKSB7CiAgICAgIGNvbnN0IHZhbHVlID0gb2JqLmdldChrZXkpOwogICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAiYm9vbGVhbiIpIHsKICAgICAgICBtYXJrSW5mb1trZXldID0gdmFsdWU7CiA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YgPSB0aGlzLnhyZWYsCiAgICAgIGJsYWNrQ29sb3IgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoMyk7CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBpID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29uc3Qgb3V0bGluZURpY3QgPSB4cmVmLmZldGNoSWZSZWYoaS5vYmopOwogICAgICBpZiAob3V0bGluZURpY3QgPT09IG51bGwpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIW91dGxpbmVEaWN0LmhhcygiVGl0bGUiKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBvdXRsaW5lIGl0ZW0gZW5jb3VudGVyZWQuIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YSA9IHsKICAgICAgICB1cmw6IG51bGwsCiAgICAgICAgZGVzdDogbnVsbCwKICAgICAgICBhY3Rpb246IG51bGwKICAgICAgfTsKICAgICAgQ2F0YWxvZy5wYXJzZURlc3REaWN0aW9uYXJ5KHsKICAgICAgICBkZXN0RGljdDogb3V0bGluZURpY3QsCiAgICAgICAgcmVzdWx0T2JqOiBkYXRhLAogICAgICAgIGRvY0Jhc2VVcmw6IHRoaXMucGRmTWFuYWdlci5kb2NCYXNlVXJsLAogICAgICAgIGRvY0F0dGFjaG1lbnRzOiB0aGlzLmF0dGFjaG1lbnRzCiAgICAgIH0pOwogICAgICBjb25zdCB0aXRsZSA9IG91dGxpbmVEaWN0LmdldCgiVGl0bGUiKTsKICAgICAgY29uc3QgZmxhZ3MgPSBvdXRsaW5lRGljdC5nZXQoIkYiKSB8fCAwOwogICAgICBjb25zdCBjb2xvciA9IG91dGxpbmVEaWN0LmdldEFycmF5KCJDIik7CiAgICAgIGNvbnN0IGNvdW50ID0gb3V0bGluZURpY3QuZ2V0KCJDb3VudCIpOwogICAgICBsZXQgcmdiQ29sb3IgPSBibGFja0NvbG9yOw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AgICAgICBvYmosCiAgICAgICAgICBwYXJlbnQ6IG91dGxpbmVJdGVtCiAgICAgICAgfSk7CiAgICAgICAgcHJvY2Vzc2VkLnB1dChvYmopOwogICAgICB9CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiTmV4dCIpOwogICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmICYmICFwcm9jZXNzZWQuaGFzKG9iaikpIHsKICAgICAgICBxdWV1ZS5wdXNoKHsKICAgICAgICAgIG9iaiwKICAgICAgICAgIHBhcmVudDogaS5wYXJlbnQKICAgICAgICB9KTsKICAgICAgICBwcm9jZXNzZWQucHV0KG9iaik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByb290Lml0ZW1zLmxlbmd0aCA+IDAgPyByb290Lml0ZW1zIDogbnVsbDsKICB9CiAgZ2V0IHBlcm1pc3Npb25zKCkgewogICAgbGV0IHBlcm1pc3Npb25zID0gbnVsbDsKICAgIHRyeSB7CiAgICAgIHBlcm1pc3Npb25zID0gdGhpcy5fcmVhZFBlcm1pc3Npb25zKCk7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoZXggaW5zdGFuY2VvZiBfY29yZV91dGlscy5NaXNzaW5nRGF0YUV4Y2VwdGlvbikgewogICAgICAgIHRocm93IGV4OwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5hYmxlIHRvIHJlYWQgcGVybWlzc2lvbnMuIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInBlcm1pc3Npb25zIiwgcGVybWlzc2lvbnMpOwogIH0KICBfcmVhZFBlcm1pc3Npb25zKCkgewogICAgY29uc3QgZW5jcnlwdCA9IHRoaXMueHJlZi50cmFpbGVyLmdldCgiRW5jcnlwdCIpOwogICAgaWYgKCEoZW5jcnlwdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IGZsYWdzID0gZW5jcnlwdC5nZXQoIlAiKTsKICAgIGlmICh0eXBlb2YgZmxhZ3MgIT09ICJudW1iZXIiKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgZmxhZ3MgKz0gMiAqKiAzMjsKICAgIGNvbnN0IHBlcm1pc3Npb25zID0gW107CiAgICBmb3IgKGNvbnN0IGtleSBpbiBfdXRpbC5QZXJtaXNzaW9uRmxhZykgewogICAgICBjb25zdCB2YWx1ZSA9IF91dGlsLlBlcm1pc3Npb25GbGFnW2tleV07CiAgICAgIGlmIChmbGFncyAmIHZhbHVlKSB7CiAgICAgICAgcGVybWlzc2lvbnMucHVzaCh2YWx1ZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBwZXJtaXNzaW9uczsKICB9CiAgZ2V0IG9wdGlvbmFsQ29udGVudENvbmZpZygpIHsKICAgIGxldCBjb25maWcgPSBudWxsOwogICAgdHJ5IHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPQ1Byb3BlcnRpZXMiKTsKICAgICAgaWYgKCFwcm9wZXJ0aWVzKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBkZWZhdWx0Q29uZmlnID0gcHJvcGVydGllcy5nZXQoIkQiKTsKICAgICAgaWYgKCFkZWZhdWx0Q29uZmlnKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHNEYXRhID0gcHJvcGVydGllcy5nZXQoIk9DR3MiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGdyb3Vwc0RhdGEpKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHMgPSBbXTsKICAgICAgY29uc3QgZ3JvdXBSZWZzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgZ3JvdXBzRGF0YSkgewogICAgICAgIGlmICghKGdyb3VwUmVmIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGdyb3VwUmVmcy5wdXNoKGdyb3VwUmVmKTsKICAgICAgICBjb25zdCBncm91cCA9IHRoaXMueHJlZi5mZXRjaElmUmVmKGdyb3VwUmVmKTsKICAgICAgICBncm91cHMucHVzaCh7CiAgICAgICAgICBpZDogZ3JvdXBSZWYudG9TdHJpbmcoKSwKICAgICAgICAgIG5hbWU6IHR5cGVvZiBncm91cC5nZXQoIk5hbWUiKSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGdyb3VwLmdldCgiTmFtZSIpKSA6IG51bGwsCiAgICAgICAgICBpbnRlbnQ6IHR5cGVvZiBncm91cC5nZXQoIkludGVudCIpID09PSAic3RyaW5nIiA/ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykoZ3JvdXAuZ2V0KCJJbnRlbnQiKSkgOiBudWxsCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uZmlnID0gdGhpcy5fcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhkZWZhdWx0Q29uZmlnLCBncm91cFJlZnMpOwogICAgICBjb25maWcuZ3JvdXBzID0gZ3JvdXBzOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYFVuYWJsZSB0byByZWFkIG9wdGlvbmFsIGNvbnRlbnQgY29uZmlnOiAke2V4fWApOwogICAgfQogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBjb25maWcpOwogIH0KICBfcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhjb25maWcsIGNvbnRlbnRHcm91cFJlZnMpIHsKICAgIGZ1bmN0aW9uIHBhcnNlT25PZmYocmVmcykgewogICAgICBjb25zdCBvblBhcnNlZCA9IFtdOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShyZWZzKSkgewogICAgICAgIGZvciAoY29uc3QgdmFsdWUgb2YgcmVmcykgewogICAgICAgICAgaWYgKCEodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvbnRlbnRHcm91cFJlZnMuaW5jbHVkZXModmFsdWUpKSB7CiAgICAgICAgICAgIG9uUGFyc2VkLnB1c2godmFsdWUudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBvblBhcnNlZDsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlT3JkZXIocmVmcykgewogICAgICBsZXQgbmVzdGVkTGV2ZWxzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkocmVmcykpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBvcmRlciA9IFtdOwogICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIHJlZnMpIHsKICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYgJiYgY29udGVudEdyb3VwUmVmcy5pbmNsdWRlcyh2YWx1ZSkpIHsKICAgICAgICAgIHBhcnNlZE9yZGVyUmVmcy5wdXQodmFsdWUpOwogICAgICAgICAgb3JkZXIucHVzaCh2YWx1ZS50b1N0cmluZygpKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBuZXN0ZWRPcmRlciA9IHBhcnNlTmVzdGVkT3JkZXIodmFsdWUsIG5lc3RlZExldmVscyk7CiAgICAgICAgaWYgKG5lc3RlZE9yZGVyKSB7CiAgICAgICAgICBvcmRlci5wdXNoKG5lc3RlZE9yZGVyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKG5lc3RlZExldmVscyA+IDApIHsKICAgICAgICByZXR1cm4gb3JkZXI7CiAgICAgIH0KICAgICAgY29uc3QgaGlkZGVuR3JvdXBzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgY29udGVudEdyb3VwUmVmcykgewogICAgICAgIGlmIChwYXJzZWRPcmRlclJlZnMuaGFzKGdyb3VwUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGhpZGRlbkdyb3Vwcy5wdXNoKGdyb3VwUmVmLnRvU3RyaW5nKCkpOwogICAgICB9CiAgICAgIGlmIChoaWRkZW5Hcm91cHMubGVuZ3RoKSB7CiAgICAgICAgb3JkZXIucHVzaCh7CiAgICAgICAgICBuYW1lOiBudWxsLAogICAgICAgICAgb3JkZXI6IGhpZGRlbkdyb3VwcwogICAgICAgIH0pOwogICAgICB9CiAgICAgIHJldHVybiBvcmRlcjsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlTmVzdGVkT3JkZXIocmVmLCBuZXN0ZWRMZXZlbHMpIHsKICAgICAgaWYgKCsrbmVzdGVkTGV2ZWxzID4gTUFYX05FU1RFRF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoInBhcnNlTmVzdGVkT3JkZXIgLSBy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gICAgaWYgKGxhYmVsRGljdC5oYXMoIlR5cGUiKSAmJiAhKDAsIF9wcmltaXRpdmVzLmlzTmFtZSkobGFiZWxEaWN0LmdldCgiVHlwZSIpLCAiUGFnZUxhYmVsIikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCB0eXBlIGluIFBhZ2VMYWJlbCBkaWN0aW9uYXJ5LiIpOwogICAgICAgIH0KICAgICAgICBpZiAobGFiZWxEaWN0LmhhcygiUyIpKSB7CiAgICAgICAgICBjb25zdCBzID0gbGFiZWxEaWN0LmdldCgiUyIpOwogICAgICAgICAgaWYgKCEocyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdHlsZSBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIHN0eWxlID0gcy5uYW1lOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBzdHlsZSA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmIChsYWJlbERpY3QuaGFzKCJQIikpIHsKICAgICAgICAgIGNvbnN0IHAgPSBsYWJlbERpY3QuZ2V0KCJQIik7CiAgICAgICAgICBpZiAodHlwZW9mIHAgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBwcmVmaXggaW4gUGFnZUxhYmVsIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICB9CiAgICAgICAgICBwcmVmaXggPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcmVmaXggPSAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGxhYmVsRGljdC5oYXMoIlN0IikpIHsKICAgICAgICAgIGNvbnN0IHN0ID0gbGFiZWxEaWN0LmdldCgiU3QiKTsKICAgICAgICAgIGlmICghKE51bWJlci5pc0ludGVnZXIoc3QpICYmIHN0ID49IDEpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdGFydCBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRJbmRleCA9IHN0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50SW5kZXggPSAxOwogICAgICAgIH0KICAgICAgfQogICAgICBzd2l0Y2ggKHN0eWxlKSB7CiAgICAgICAgY2FzZSAiRCI6CiAgICAgICAgICBjdXJyZW50TGFiZWwgPSBjdXJyZW50SW5kZXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJSIjoKICAgICAgICBjYXNlICJyIjoKICAgICAgICAgIGN1cnJlbnRMYWJlbCA9ICgwLCBfY29yZV91dGlscy50b1JvbWFuTnVtZXJhbHMpKGN1cnJlbnRJbmRleCwgc3R5bGUgPT09ICJyIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJBIjoKICAgICAgICBjYXNlICJhIjoKICAgICAgICAgIGNvbnN0IExJTUlUID0gMjY7CiAgICAgICAgICBjb25zdCBBX1VQUEVSX0NBU0UgPSAweDQxLAogICAgICAgICAgICBBX0xPV0VSX0NBU0UgPSAweDYxOwogICAgICAgICAgY29uc3QgYmFzZUNoYXJDb2RlID0gc3R5bGUgPT09ICJhIiA/IEFfTE9XRVJfQ0FTRSA6IEFfVVBQRVJfQ0FTRTsKICAgICAgICAgIGNvbnN0IGxldHRlckluZGV4ID0gY3VycmVudEluZGV4IC0gMTsKICAgICAgICAgIGNvbnN0IGNoYXJhY3RlciA9IFN0cmluZy5mcm9tQ2hhckNvZGUoYmFzZUNoYXJDb2RlICsgbGV0dGVySW5kZXggJSBMSU1JVCk7CiAgICAgICAgICBjdXJyZW50T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ogICAgICAgIGNhc2UgIkZpdFdpbmRvdyI6CiAgICAgICAgY2FzZSAiQ2VudGVyV2luZG93IjoKICAgICAgICBjYXNlICJEaXNwbGF5RG9jVGl0bGUiOgogICAgICAgIGNhc2UgIlBpY2tUcmF5QnlQREZTaXplIjoKICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk5vbkZ1bGxTY3JlZW5QYWdlTW9kZSI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlVzZU5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU91dGxpbmVzIjoKICAgICAgICAgICAgICBjYXNlICJVc2VUaHVtYnMiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU9DIjoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlLm5hbWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gIlVzZU5vbmUiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJEaXJlY3Rpb24iOgogICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICBzd2l0Y2ggKHZhbHVlLm5hbWUpIHsKICAgICAgICAgICAgICBjYXNlICJMMlIiOgogICAgICAgICAgICAgIGNhc2UgIlIyTCI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJMMlIiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJWaWV3QXJlYSI6CiAgICAgICAgY2FzZSAiVmlld0NsaXAiOgogICAgICAgIGNhc2UgIlByaW50QXJlYSI6CiAgICAgICAgY2FzZSAiUHJpbnRDbGlwIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgc3dpdGNoICh2YWx1ZS5uYW1lKSB7CiAgICAgICAgICAgICAgY2FzZSAiTWVkaWFCb3giOgogICAgICAgICAgICAgIGNhc2UgIkNyb3BCb3giOgogICAgICAgICAgICAgIGNhc2UgIkJsZWVkQm94IjoKICAgICAgICAgICAgICBjYXNlICJUcmltQm94IjoKICAgICAgICAgICAgICBjYXNlICJBcnRCb3giOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQ3JvcEJveCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlByaW50U2NhbGluZyI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIkFwcERlZmF1bHQiOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQXBwRGVmYXVsdCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkR1cGxleCI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlNpbXBsZXgiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBTaG9ydEVkZ2UiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBMb25nRWRnZSI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJOb25lIjsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiUHJpbnRQYWdlUmFuZ2UiOgogICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIHZhbHVlLmxlbmd0aCAlIDIgPT09IDApIHsKICAgICAgICAgICAgY29uc3QgaXNWYWxpZCA9IHZhbHVlLmV2ZXJ5KChwYWdlLCBpLCBhcnIpID0+IHsKICAgICAgICAgICAgICByZXR1cm4gTnVtYmVyLmlzSW50ZWdlcihwYWdlKSAmJiBwYWdlID4gMCAmJiAoaSA9PT0gMCB8fCBwYWdlID49IGFycltpIC0gMV0pICYmIHBhZ2UgPD0gdGhpcy5udW1QYWdlczsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkKSB7CiAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk51bUNvcGllcyI6CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkgJiYgdmFsdWUgPiAwKSB7CiAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3Jpbmcgbm9uLXN0YW5kYXJkIGtleSBpbiBWaWV3ZXJQcmVmZXJlbmNlczogJHtrZXl9LmApOwogICAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByZWZWYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBCYWQgdmFsdWUsIGZvciBrZXkgIiR7a2V5fSIsIGluIFZpZXdlclByZWZlcmVuY2VzOiAke3ZhbHVlfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIXByZWZzKSB7CiAgICAgICAgcHJlZnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICB9CiAgICAgIHByZWZzW2tleV0gPSBwcmVmVmFsdWU7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInZpZXdlclByZWZlcmVuY2VzIiwgcHJlZnMpOwogIH0KICBnZXQgb3BlbkFjdGlvbigpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPcGVuQWN0aW9uIik7CiAgICBjb25zdCBvcGVuQWN0aW9uID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGNvbnN0IGRlc3REaWN0ID0gbmV3IF9wcmltaXRpdmVzLkRpY3QodGhpcy54cmVmKTsKICAgICAgZGVzdERpY3Quc2V0KCJBIiwgb2JqKTsKICAgICAgY29uc3QgcmVzdWx0T2JqID0gewogICAgICAgIHVyb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j0gMCAmJiBjdXJyZW50UGFnZUluZGV4ICsgY291bnQgPD0gcGFnZUluZGV4KSB7CiAgICAgICAgICBjdXJyZW50UGFnZUluZGV4ICs9IGNvdW50OwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh2aXNpdGVkTm9kZXMuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKTsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChjdXJyZW50Tm9kZSk7CiAgICAgICAgY29uc3Qgb2JqID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGN1cnJlbnROb2RlKTsKICAgICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgbGV0IHR5cGUgPSBvYmouZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCgwLCBfcHJpbWl0aXZlcy5pc05hbWUpKHR5cGUsICJQYWdlIikgfHwgIW9iai5oYXMoIktpZHMiKSkgewogICAgICAgICAgICBpZiAoIXBhZ2VLaWRzQ291bnRDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUtpZHNDb3VudENhY2hlLnB1dChjdXJyZW50Tm9kZSwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKCFwYWdlSW5kZXhDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUluZGV4Q2FjaGUucHV0KGN1cnJlbnROb2RlLCBjdXJyZW50UGFnZUluZGV4KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY3VycmVudFBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgcmV0dXJuIFtvYmosIGN1cnJlbnROb2RlXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjdXJyZW50UGFnZUluZGV4Kys7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChvYmopOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWQgcmVmZXJlbmNlIHBvaW50cyB0byB3cm9uZyB0eXBlIG9mIG9iamVjdC4iKTsKICAgICAgfQogICAgICBjb25zdCB7CiAgICAgICAgb2JqSWQKICAgICAgfSA9IGN1cnJlbnROb2RlOwogICAgICBsZXQgY291bnQgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIkNvdW50Iik7CiAgICAgIGlmIChjb3VudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGNvdW50ID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGNvdW50KTsKICAgICAgfQogICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgJiYgY291bnQgPj0gMCkgewogICAgICAgIGlmIChvYmpJZCAmJiAhcGFnZUtpZHNDb3VudENhY2hlLmhhcyhvYmpJZCkpIHsKICAgICAgICAgIHBhZ2VLaWRzQ291bnRDYWNoZS5wdXQob2JqSWQsIGNvdW50KTsKICAgICAgICB9CiAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggKyBjb3VudCA8PSBwYWdlSW5kZXgpIHsKICAgICAgICAgIGN1cnJlbnRQYWdlSW5kZXggKz0gY291bnQ7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGtpZHMgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIktpZHMiKTsKICAgICAgaWYgKGtpZHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGxldCB0eXBlID0gY3VycmVudE5vZGUuZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgaWYgKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgIHR5cGUgPSBhd2FpdCB4cmVmLmZldGNoQXN5bmModHlwZSk7CiAgICAgICAgfQogICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFjdXJyZW50Tm9kZS5oYXMoIktpZHMiKSkgewogICAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggPT09IHBhZ2VJbmRleCkgewogICAgICAgICAgICByZXR1cm4gW2N1cnJlbnROb2RlLCBudWxsXTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRQYWdlSW5kZXgrKzsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWRzIG9iamVjdCBpcyBub3QgYW4gYXJyYXkuIik7CiAgICAgIH0KICAgICAgZm9yIChsZXQgbGFzdCA9IGtpZHMubGVuZ3RoIC0gMTsgbGFzdCA+PSAwOyBsYXN0LS0pIHsKICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChraWRzW2xhc3RdKTsKICAgICAgfQogICAgfQogICAgdGhyb3cgbmV3IE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mRleCsrLCBbcGFnZURpY3QsIHBhZ2VSZWZdKTsKICAgIH0KICAgIGZ1bmN0aW9uIGFkZFBhZ2VFcnJvcihlcnJvcikgewogICAgICBpZiAoZXJyb3IgaW5zdGFuY2VvZiBfY29yZV91dGlscy5YUmVmRW50cnlFeGNlcHRpb24gJiYgIXJlY292ZXJ5TW9kZSkgewogICAgICAgIHRocm93IGVycm9yOwogICAgICB9CiAgICAgIGlmIChyZWNvdmVyeU1vZGUgJiYgaWdub3JlRXJyb3JzICYmIHBhZ2VJbmRleCA9PT0gMCkgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0QWxsUGFnZURpY3RzIC0gU2tpcHBpbmcgaW52YWxpZCBmaXJzdCBwYWdlOiAiJHtlcnJvcn0iLmApOwogICAgICAgIGVycm9yID0gX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgfQogICAgICBtYXAuc2V0KHBhZ2VJbmRleCsrLCBbZXJyb3IsIG51bGxdKTsKICAgIH0KICAgIHdoaWxlIChxdWV1ZS5sZW5ndGggPiAwKSB7CiAgICAgIGNvbnN0IHF1ZXVlSXRlbSA9IHF1ZXVlLmF0KC0xKTsKICAgICAgY29uc3QgewogICAgICAgIGN1cnJlbnROb2RlLAogICAgICAgIHBvc0luS2lkcwogICAgICB9ID0gcXVldWVJdGVtOwogICAgICBsZXQga2lkcyA9IGN1cnJlbnROb2RlLmdldFJhdygiS2lkcyIpOwogICAgICBpZiAoa2lkcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGFkZFBhZ2VFcnJvcihuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWRzIG9iamVjdCBpcyBub3QgYW4gYXJyYXkuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChwb3NJbktpZHMgPj0ga2lkcy5sZW5ndGgpIHsKICAgICAgICBxdWV1ZS5wb3AoKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBraWRPYmogPSBraWRzW3Bvc0luS2lkc107CiAgICAgIGxldCBvYmo7CiAgICAgIGlmIChraWRPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodmlzaXRlZE5vZGVzLmhhcyhraWRPYmopKSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChraWRPYmopOwogICAgICAgIHRyeSB7CiAgICAgICAgICBvYmogPSBhd2FpdCB4cmVmLmZldGNoQXN5bmMoa2lkT2JqKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgYWRkUGFnZUVycm9yKGV4KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBvYmogPSBraWRPYmo7CiAgICAgIH0KICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlIGRpY3Rpb25hcnkga2lkIHJlZmVyZW5jZSBwb2ludHMgdG8gd3JvbmcgdHlwZSBvZiBvYmplY3QuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldCB0eXBlID0gb2JqLmdldFJhdygiVHlwZSIpOwogICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBhZGRQYWdlRGljdChvYmosIGtpZE9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiA/IGtpZE9iaiA6IG51bGwpOwogICAgICB9IGVsc2UgewogICAgICAgIHF1ZXVlLnB1c2goewogICAgICAgICAgY3VycmVudE5vZGU6IG9iaiwKICAgICAgICAgIHBvc0luS2lkczogMAogICAgICAgIH0pOwogICAgICB9CiAgICAgIHF1ZXVlSXRlbS5wb3NJbktpZHMrKzsKICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldFBhZ2VJbmRleChwYWdlUmVmKSB7CiAgICBjb25zdCBjYWNoZWRQYWdlSW5kZXggPSB0aGlzLnBhZ2VJbmRleENhY2hlLmdldChwYWdlUmVmKTsKICAgIGlmIChjYWNoZWRQYWdlSW5kZXggIT09IHVuZGVmaW5lZCkgewogICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKGNhY2hlZFBhZ2VJbmRleCk7CiAgICB9CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgZnVuY3Rpb24gcGFnZXNCZWZvcmVSZWYoa2lkUmVmKSB7CiAgICAgIGxldCB0b3RhbCA9IDAsCiAgICAgICAgcGFyZW50UmVmOwogICAgICByZXR1cm4geHJlZi5mZXRjaEFzeW5jKGtpZFJlZikud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wogICAgICB9KS50aGVuKGZ1bmN0aW9uIChraWRzKSB7CiAgICAgICAgaWYgKCFraWRzKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3Qga2lkUHJvbWlzZXMgPSBbXTsKICAgICAgICBsZXQgZm91bmQgPSBmYWxzZTsKICAgICAgICBmb3IgKGNvbnN0IGtpZCBvZiBraWRzKSB7CiAgICAgICAgICBpZiAoIShraWQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiS2lkIG11c3QgYmUgYSByZWZlcmVuY2UuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzUmVmc0VxdWFsKShraWQsIGtpZFJlZikpIHsKICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGtpZFByb21pc2VzLnB1c2goeHJlZi5mZXRjaEFzeW5jKGtpZCkudGhlbihmdW5jdGlvbiAob2JqKSB7CiAgICAgICAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJLaWQgbm9kZSBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAob2JqLmhhcygiQ291bnQiKSkgewogICAgICAgICAgICAgIHRvdGFsICs9IG9iai5nZXQoIkNvdW50Iik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdG90YWwrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIktpZCByZWZlcmVuY2Ugbm90IGZvdW5kIGluIHBhcmVudCdzIGtpZHMuIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBQcm9taXNlLmFsbChraWRQcm9taXNlcykudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICByZXR1cm4gW3RvdGFsLCBwYXJlbnRSZWZdOwogICAgICAgIH0pOwogICAgICB9KTsKICAgIH0KICAgIGxldCB0b3RhbCA9IDA7CiAgICBjb25zdCBuZXh0ID0gcmVmID0+IHBhZ2VzQmVmb3JlUmVmKHJlZikudGhlbihhcmdzID0+IHsKICAgICAgaWYgKCFhcmdzKSB7CiAgICAgICAgdGhpcy5wYWdlSW5kZXhDYWNoZS5wdXQocGFnZVJlZiwgdG90YWwpOwogICAgICAgIHJldHVybiB0b3RhbDsKICAgICAgfQogICAgICBjb25zdCBbY291bnQsIHBhcmVudFJlZl0gPSBhcmdzOwogICAgICB0b3RhbCArPSBjb3VudDsKICAgICAgcmV0dXJuIG5leHQocGFyZW50UmVmKTsKICAgIH0pOwogICAgcmV0dXJuIG5leHQocGFnZVJlZik7CiAgfQogIGdldCBiYXNlVXJsKCkgewogICAgY29uc3QgdXJpID0gdGhpcy5fY2F0RGljdC5nZXQoIlVSSSIpOwogICAgaWYgKHVyaSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgY29uc3QgYmFzZSA9IHVyaS5nZXQoIkJhc2UiKTsKICAgICAgaWYgKHR5cGVvZiBiYXNlID09PSAic3RyaW5nIikgewogICAgICAgIGNvbnN0IGFic29sdXRlVXJsID0gKDAsIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmwpKGJhc2UsIG51bGwsIHsKICAgICAgICAgIHRyeUNvbnZlcnRFbmNvZGluZzogdHJ1ZQogICAgICAgIH0pOwogICAgICAgIGlmIChhYnNvbHV0ZVVybCkgewogICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJiYXNlVXJs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gaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHJlZnMucHVzaChvYmoudG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG9iaiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBmaWVsZHMucHVzaCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKG9iaikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHRPYmoucmVzZXRGb3JtID0gewogICAgICAgICAgICBmaWVsZHMsCiAgICAgICAgICAgIHJlZnMsCiAgICAgICAgICAgIGluY2x1ZGUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJVUkkiOgogICAgICAgICAgdXJsID0gYWN0aW9uLmdldCgiVVJJIik7CiAgICAgICAgICBpZiAodXJsIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICB1cmwgPSAiLyIgKyB1cmwubmFtZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkdvVG8iOgogICAgICAgICAgZGVzdCA9IGFjdGlvbi5nZXQoIkQiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkxhdW5jaCI6CiAgICAgICAgY2FzZSAiR29Ub1IiOgogICAgICAgICAgY29uc3QgdXJsRGljdCA9IGFjdGlvbi5nZXQoIkYiKTsKICAgICAgICAgIGlmICh1cmxEaWN0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0LmdldCgiRiIpIHx8IG51bGw7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB1cmxEaWN0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0OwogICAgICAgICAgfQogICAgICAgICAgbGV0IHJlbW90ZURlc3QgPSBhY3Rpb24uZ2V0KCJEIik7CiAgICAgICAgICBpZiAocmVtb3RlRGVzdCkgewogICAgICAgICAgICBpZiAocmVtb3RlRGVzdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICByZW1vdGVEZXN0ID0gcmVtb3RlRGVzdC5uYW1lOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgdXJsID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgIGNvbnN0IGJhc2VVcmwgPSB1cmwuc3BsaXQoIiMiKVswXTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbW90ZURlc3QgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICB1cmwgPSBiYXNlVXJsICsgIiMiICsgcmVtb3RlRGVzdDsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkocmVtb3RlRGVzdCkpIHsKICAgICAgICAgICAgICAgIHVybCA9IGJhc2VVcmwgKyAiIyIgKyBKU09OLnN0cmluZ2lmeShyZW1vdGVEZXN0KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG5ld1dpbmRvdyA9IGFjdGlvbi5nZXQoIk5ld1dpbmRvdyIpOwogICAgICAgICAgaWYgKHR5cGVvZiBuZXdXaW5kb3cgPT09ICJib29sZWFuIikgewogICAgICAgICAgICByZXN1bHRPYmoubmV3V2luZG93ID0gbmV3V2luZG93OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiR29Ub0UiOgogICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYWN0aW9uLmdldCgiVCIpOwogICAgICAgICAgbGV0IGF0dGFjaG1lbnQ7CiAgICAgICAgICBpZiAoZG9jQXR0YWNobWVudHMgJiYgdGFyZ2V0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICBjb25zdCByZWxhdGlvbnNoaXAgPSB0YXJnZXQuZ2V0KCJSIik7CiAgICAgICAgICAgIGNvbnN0IG5hbWUgPSB0YXJnZXQuZ2V0KCJOIik7CiAgICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKShyZWxhdGlvbnNoaXAsICJDIikgJiYgdHlwZW9mIG5hbWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgYXR0YWNobWVudCA9IGRvY0F0dGFjaG1lbnRzWygwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykobmFtZSldOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYXR0YWNobWVudCkgewogICAgICAgICAgICByZXN1bHRPYmouYXR0YWNobWVudCA9IGF0dGFjaG1lbnQ7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVzdERpY3Rpb25hcnkgLSB1bmltcGxlbWVudGVkICJHb1RvRSIgYWN0aW9uLmApOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiTmFtZWQiOgogICAgICAgICAgY29uc3QgbmFtZWRBY3Rpb24gPSBhY3Rpb24uZ2V0KCJOIik7CiAgICAgICAgICBpZiAobmFtZWRBY3Rpb24gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHJlc3VsdE9iai5hY3Rpb24gPSBuYW1lZEFjdGlvbi5uYW1lOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU2V0T0NHU3RhdGUiOgogICAgICAgICAgY29uc3Qgc3RhdGUgPSBhY3Rpb24uZ2V0KCJTdGF0ZSIpOwogICAgICAgICAgY29uc3QgcHJlc2VydmVSQiA9IGFjdGlvbi5nZXQoIlByZXNlcnZlUkIiKTsKICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShzdGF0ZSkgfHwgc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RhdGVBcnIgPSBbXTsKICAgICAgICAgIGZvciAoY29uc3QgZWxlbSBvZiBzdGF0ZSkgewogICAgICAgICAgICBpZiAoZWxlbSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICBzd2l0Y2ggKGVsZW0ubmFtZSkgewogICAgICAgICAgICAgICAgY2FzZSAiT04iOgogICAgICAgICAgICAgICAgY2FzZSAiT0ZGIjoKICAgICAgICAgICAgICAgIGNhc2UgIlRvZ2dsZSI6CiAgICAgICAgICAgICAgICAgIHN0YXRlQXJyLnB1c2goZWxlbS5uYW1lKTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgaWYgKGVsZW0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICBzdGF0ZUFyci5wdXNoKGVsZW0udG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZUFyci5sZW5ndGggIT09IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHJlc3VsdE9iai5zZXRPQ0dTdGF0ZSA9IHsKICAgICAgICAgICAgc3RhdGU6IHN0YXRlQXJyLAogICAgICAgICAgICBwcmVzZXJ2ZVJCOiB0eXBlb2YgcHJlc2VydmVSQiA9PT0gImJvb2xlYW4iID8gcHJlc2VydmVSQiA6IHRydWUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJKYXZhU2NyaXB0IjoKICAgICAgICAgIGNvbnN0IGpzQWN0aW9uID0gYWN0aW9uLmdldCgiSlMiKTsKICAgICAgICAgIGxldCBqczsKICAgICAgICAgIGlmI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cm1hdEVycm9yKGBEdXBsaWNhdGUgZW50cnkgaW4gIiR7dGhpcy5fdHlwZX0iIHRyZWUuYCk7CiAgICAgICAgICB9CiAgICAgICAgICBxdWV1ZS5wdXNoKGtpZCk7CiAgICAgICAgICBwcm9jZXNzZWQucHV0KGtpZCk7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGVudHJpZXMgPSBvYmouZ2V0KHRoaXMuX3R5cGUpOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZW50cmllcykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBlbnRyaWVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBtYXAuc2V0KHhyZWYuZmV0Y2hJZlJlZihlbnRyaWVzW2ldKSwgeHJlZi5mZXRjaElmUmVmKGVudHJpZXNbaSArIDFdKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldChrZXkpIHsKICAgIGlmICghdGhpcy5yb290KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29uc3QgeHJlZiA9IHRoaXMueHJlZjsKICAgIGxldCBraWRzT3JFbnRyaWVzID0geHJlZi5mZXRjaElmUmVmKHRoaXMucm9vdCk7CiAgICBsZXQgbG9vcENvdW50ID0gMDsKICAgIGNvbnN0IE1BWF9MRVZFTFMgPSAxMDsKICAgIHdoaWxlIChraWRzT3JFbnRyaWVzLmhhcygiS2lkcyIpKSB7CiAgICAgIGlmICgrK2xvb3BDb3VudCA+IE1BWF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFNlYXJjaCBkZXB0aCBsaW1pdCByZWFjaGVkIGZvciAiJHt0aGlzLl90eXBlfSIgdHJlZS5gKTsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBraWRzID0ga2lkc09yRW50cmllcy5nZXQoIktpZHMiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGtpZHMpKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgbGV0IGwgPSAwLAogICAgICAgIHIgPSBraWRzLmxlbmd0aCAtIDE7CiAgICAgIHdoaWxlIChsIDw9IHIpIHsKICAgICAgICBjb25zdCBtID0gbCArIHIgPj4gMTsKICAgICAgICBjb25zdCBraWQgPSB4cmVmLmZldGNoSWZSZWYoa2lkc1ttXSk7CiAgICAgICAgY29uc3QgbGltaXRzID0ga2lkLmdldCgiTGltaXRzIik7CiAgICAgICAgaWYgKGtleSA8IHhyZWYuZmV0Y2hJZlJlZihsaW1pdHNbMF0pKSB7CiAgICAgICAgICByID0gbSAtIDE7CiAgICAgICAgfSBlbHNlIGlmIChrZXkgPiB4cmVmLmZldGNoSWZSZWYobGltaXRzWzFdKSkgewogICAgICAgICAgbCA9IG0gKyAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBraWRzT3JFbnRyaWVzID0ga2lkOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChsID4gcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICB9CiAgICBjb25zdCBlbnRyaWVzID0ga2lkc09yRW50cmllcy5nZXQodGhpcy5fdHlwZSk7CiAgICBpZiAoQXJyYXkuaXNBcnJheShlbnRyaWVzKSkgewogICAgICBsZXQgbCA9IDAsCiAgICAgICAgciA9IGVudHJpZXMubGVuZ3RoIC0gMjsKICAgICAgd2hpbGUgKGwgPD0gcikgewogICAgICAgIGNvbnN0IHRtcCA9IGwgKyByID4+IDEsCiAgICAgICAgICBtID0gdG1wICsgKHRtcCAmIDEpOwogICAgICAgIGNvbnN0IGN1cnJlbnRLZXkgPSB4cmVmLmZldGNoSWZSZWYoZW50cmllc1ttXSk7CiAgICAgICAgaWYgKGtleSA8IGN1cnJlbnRLZXkpIHsKICAgICAgICAgIHIgPSBt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pcy5jb250ZW50QXZhaWxhYmxlKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgaWYgKCF0aGlzLmNvbnRlbnRSZWYgJiYgdGhpcy5yb290KSB7CiAgICAgIHRoaXMuY29udGVudFJlZiA9IHBpY2tQbGF0Zm9ybUl0ZW0odGhpcy5yb290LmdldCgiRUYiKSk7CiAgICB9CiAgICBsZXQgY29udGVudCA9IG51bGw7CiAgICBpZiAodGhpcy5jb250ZW50UmVmKSB7CiAgICAgIGNvbnN0IGZpbGVPYmogPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZih0aGlzLmNvbnRlbnRSZWYpOwogICAgICBpZiAoZmlsZU9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgY29udGVudCA9IGZpbGVPYmouZ2V0Qnl0ZXMoKTsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIkVtYmVkZGVkIGZpbGUgc3BlY2lmaWNhdGlvbiBwb2ludHMgdG8gbm9uLWV4aXN0aW5nL2ludmFsaWQgY29udGVudCIpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICAoMCwgX3V0aWwud2FybikoIkVtYmVkZGVkIGZpbGUgc3BlY2lmaWNhdGlvbiBkb2VzIG5vdCBoYXZlIGEgY29udGVudCIpOwogICAgfQogICAgcmV0dXJuIGNvbnRlbnQ7CiAgfQogIGdldCBzZXJpYWxpemFibGUoKSB7CiAgICByZXR1cm4gewogICAgICBmaWxlbmFtZTogdGhpcy5maWxlbmFtZSwKICAgICAgY29udGVudDogdGhpcy5jb250ZW50CiAgICB9OwogIH0KfQpleHBvcnRzLkZpbGVTcGVjID0gRmlsZVNwZWM7CgovKioqLyB9KSwKLyogMjA4ICovCi8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiJ1c2Ugc3RyaWN0IjsKCg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YW1lKSB7CiAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICBjYXNlICJhbXAiOgogICAgICAgICAgICByZXR1cm4gIiYiOwogICAgICAgICAgY2FzZSAiYXBvcyI6CiAgICAgICAgICAgIHJldHVybiAiJyI7CiAgICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICAgIHJldHVybiAiPCI7CiAgICAgICAgICBjYXNlICJxdW90IjoKICAgICAgICAgICAgcmV0dXJuICciJzsKICAgICAgICB9CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBfcmVwYWlyOiAke25hbWV9IGlzbid0IGRlZmluZWQuYCk7CiAgICAgIH0pOwogICAgICBjb25zdCBjaGFyQnVmID0gWyI+Il07CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBjb25zdCBjb2RlID0gYnl0ZXMuY2hhckNvZGVBdChpKSAqIDI1NiArIGJ5dGVzLmNoYXJDb2RlQXQoaSArIDEpOwogICAgICAgIGlmIChjb2RlID49IDMyICYmIGNvZGUgPCAxMjcgJiYgY29kZSAhPT0gNjAgJiYgY29kZSAhPT0gNjIgJiYgY29kZSAhPT0gMzgpIHsKICAgICAgICAgIGNoYXJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY2hhckJ1Zi5wdXNoKCImI3giICsgKDB4MTAwMDAgKyBjb2RlKS50b1N0cmluZygxNikuc3Vic3RyaW5nKDEpICsgIjsiKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIGNoYXJCdWYuam9pbigiIik7CiAgICB9KTsKICB9CiAgX2dldFNlcXVlbmNlKGVudHJ5KSB7CiAgICBjb25zdCBuYW1lID0gZW50cnkubm9kZU5hbWU7CiAgICBpZiA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KICAgICAgfQogICAgICByZXR1cm4gZWxlbWVudDsKICAgIH0KICAgIGNvbnN0IHBhcmVudE5vZGUgPSB0aGlzLmFkZE5vZGUocGFyZW50LCBtYXAsIGxldmVsICsgMSk7CiAgICBpZiAoIXBhcmVudE5vZGUpIHsKICAgICAgcmV0dXJuIGVsZW1lbnQ7CiAgICB9CiAgICBsZXQgc2F2ZSA9IGZhbHNlOwogICAgZm9yIChjb25zdCBraWQgb2YgcGFyZW50Tm9kZS5raWRzKSB7CiAgICAgIGlmIChraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuRUxFTUVOVCAmJiBraWQuZGljdCA9PT0gZGljdCkgewogICAgICAgIGtpZC5wYXJlbnROb2RlID0gZWxlbWVudDsKICAgICAgICBzYXZlID0gdHJ1ZTsKICAgICAgfQogICAgfQogICAgaWYgKCFzYXZlKSB7CiAgICAgIG1hcC5kZWxldGUoZGljdCk7CiAgICB9CiAgICByZXR1cm4gZWxlbWVudDsKICB9CiAgYWRkVG9wTGV2ZWxOb2RlKGRpY3QsIGVsZW1lbnQpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXMucm9vdERpY3QuZ2V0KCJLIik7CiAgICBpZiAoIW9iaikgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBpZiAob2JqLm9iaklkICE9PSBkaWN0Lm9iaklkKSB7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIHRoaXMubm9kZXNbMF0gPSBlbGVtZW50OwogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGlmICghQXJyYXkuaXNBcnJheShvYmopKSB7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgbGV0IHNhdmUgPSBmYWxzZTsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgb2JqLmxlbmd0aDsgaSsrKSB7CiAgICAgIGNvbnN0IGtpZFJ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hbmcpOwogICAgICB9CiAgICAgIGZvciAoY29uc3Qga2lkIG9mIG5vZGUua2lkcykgewogICAgICAgIGNvbnN0IGtpZEVsZW1lbnQgPSBraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuRUxFTUVOVCA/IGtpZC5wYXJlbnROb2RlIDogbnVsbDsKICAgICAgICBpZiAoa2lkRWxlbWVudCkgewogICAgICAgICAgbm9kZVRvU2VyaWFsaXphYmxlKGtpZEVsZW1lbnQsIG9iaiwgbGV2ZWwgKyAxKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLlBBR0VfQ09OVEVOVCB8fCBraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuU1RSRUFNX0NPTlRFTlQpIHsKICAgICAgICAgIG9iai5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgdHlwZTogImNvbnRlbnQiLAogICAgICAgICAgICBpZDogYHBhZ2Uke2tpZC5wYWdlT2JqSWR9X21jaWQke2tpZC5tY2lkfWAKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLk9CSkVDVCkgewogICAgICAgICAgb2JqLmNoaWxkcmVuLnB1c2goewogICAgICAgICAgICB0eXBlOiAib2JqZWN0IiwKICAgICAgICAgICAgaWQ6IGtpZC5yZWZPYmpJZAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBjb25zdCByb290ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIHJvb3QuY2hpbGRyZW4gPSBbXTsKICAgIHJvb3Qucm9sZSA9ICJSb290IjsKICAgIGZvciAoY29uc3QgY2hpbGQgb2YgdGhpcy5ub2RlcykgewogICAgICBpZiAoIWNoaWxkKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbm9kZV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kZXNUb1JldmlzaXQgPSBbXTsKICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0cyA9IFtdOwogICAgd2hpbGUgKG5vZGVzVG9WaXNpdC5sZW5ndGgpIHsKICAgICAgbGV0IGN1cnJlbnROb2RlID0gbm9kZXNUb1Zpc2l0LnBvcCgpOwogICAgICBpZiAoY3VycmVudE5vZGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodGhpcy5yZWZTZXQuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHRyeSB7CiAgICAgICAgICB0aGlzLnJlZlNldC5wdXQoY3VycmVudE5vZGUpOwogICAgICAgICAgY3VycmVudE5vZGUgPSB0aGlzLnhyZWYuZmV0Y2goY3VycmVudE5vZGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBpZiAoIShleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9iamVjdExvYWRlci5fd2FsayAtIHJlcXVlc3RpbmcgYWxsIGRhdGE6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIHRoaXMucmVmU2V0ID0gbnVsbDsKICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgIG1hbmFnZXIKICAgICAgICAgICAgfSA9IHRoaXMueHJlZi5zdHJlYW07CiAgICAgICAgICAgIHJldHVybiBtYW5hZ2VyLnJlcXVlc3RBbGxDaHVua3MoKTsKICAgICAgICAgIH0KICAgICAgICAgIG5vZGVzVG9SZXZpc2l0LnB1c2goY3VycmVudE5vZGUpOwogICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICBiZWdpbjogZXguYmVnaW4sCiAgICAgICAgICAgIGVuZDogZXguZW5kCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAg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jb25zdCBwcm90byA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0aGlzKTsKICAgIGlmICghcHJvdG8uX2F0dHJpYnV0ZXMpIHsKICAgICAgY29uc3QgYXR0cmlidXRlcyA9IHByb3RvLl9hdHRyaWJ1dGVzID0gbmV3IFNldCgpOwogICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgICBpZiAodGhpc1tuYW1lXSA9PT0gbnVsbCB8fCB0aGlzW25hbWVdIGluc3RhbmNlb2YgWEZBT2JqZWN0IHx8IHRoaXNbbmFtZV0gaW5zdGFuY2VvZiBYRkFPYmplY3RBcnJheSkgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGF0dHJpYnV0ZXMuYWRkKG5hbWUpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgX2F0dHJpYnV0ZU5hbWVzLCBwcm90by5fYXR0cmlidXRlcyk7CiAgfQogIFskaXNEZXNjZW5kZW50XShwYXJlbnQpIHsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlIChub2RlKSB7CiAgICAgIGlmIChub2RlID09PSBwYXJlbnQpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBub2RlID0gbm9kZVskZ2V0UGFyZW50XSgpOwogICAgfQogICAgcmV0dXJuIGZhbHNlOwogIH0KICBbJGdldFBhcmVudF0oKSB7CiAgICByZXR1cm4gdGhpc1tfcGFyZW50XTsKICB9CiAgWyRnZXRTdWJmb3JtUGFyZW50XSgpIHsKICAgIHJldHVybiB0aGlzWyRnZXRQYXJlbnRdKCk7CiAgfQogIFskZ2V0Q2hpbGRyZW5dKCkgewogICAgbGV0IG5hbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA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k7CiAgICAgICAgICBpZiAodmFsdWUucHVzaChjaGlsZCkpIHsKICAgICAgICAgICAgY2hpbGRbX3BhcmVudF0gPSB0aGlzOwogICAgICAgICAgICB0aGlzW19jaGlsZHJlbl0ucHVzaChjaGlsZCk7CiAgICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWx1ZSAhPT0gbnVsbCkgewogICAgICAgIHZhbHVlWyRyZXNvbHZlUHJvdG90eXBlc10oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIGlmIChwcm90b1ZhbHVlKSB7CiAgICAgICAgICB2YWx1ZVtfYXBwbHlQcm90b3R5cGVdKHByb3RvVmFsdWUsIGlkcywgYW5jZXN0b3JzKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByb3RvVmFsdWUgIT09IG51bGwpIHsKICAgICAgICBjb25zdCBjaGlsZCA9IHByb3RvVmFsdWVbJGNsb25lXSgpOwogICAgICAgIGNoaWxkW19wYXJlbnRdID0gdGhpczsKICAgICAgICB0aGlzW25hbWVdID0gY2hpbGQ7CiAgICAgICAgdGhpc1tfY2hpbGRyZW5dLnB1c2goY2hpbGQpOwogICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICB9CiAgICB9CiAgfQogIHN0YXRpYyBbX2Nsb25lQXR0cmlidXRlXShvYmopIHsKICAgIGlmIChBcnJheS5pc0FycmF5KG9iaikpIHsKICAgICAgcmV0dXJuIG9iai5tYXAoeCA9PiBYRkFPYmplY3RbX2Nsb25lQXR0cmlidXRlXSh4KSk7CiAgICB9CiAgICBpZiAodHlwZW9mIG9i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pmdW5jdGlvbiBnZXRSZWxldmFudChkYXRhKSB7CiAgaWYgKCFkYXRhKSB7CiAgICByZXR1cm4gW107CiAgfQogIHJldHVybiBkYXRhLnRyaW0oKS5zcGxpdCgvXHMrLykubWFwKGUgPT4gewogICAgcmV0dXJuIHsKICAgICAgZXhjbHVkZWQ6IGVbMF0gPT09ICItIiwKICAgICAgdmlld25hbWU6IGUuc3Vic3RyaW5nKDEpCiAgICB9OwogIH0pOwp9CmZ1bmN0aW9uIGdldENvbG9yKGRhdGEpIHsKICBsZXQgZGVmID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBbMCwgMCwgMF07CiAgbGV0IFtyLCBnLCBiXSA9IGRlZjsKICBpZiAoIWRhdGEpIHsKICAgIHJldHVybiB7CiAgICAgIHIsCiAgICAgIGcsCiAgICAgIGIKICAgIH07CiAgfQogIGNvbnN0IGNvbG9yID0gZGF0YS50cmltKCkuc3BsaXQoL1xzKixccyovKS5tYXAoYyA9PiBNYXRoLm1pbihNYXRoLm1heCgwLCBwYXJzZUludChjLnRyaW0oKSwgMTApKSwgMjU1KSkubWFwKGMgPT4gaXNOYU4oYykgPyAwIDogYyk7CiAgaWYgKGNvbG9yLmxlbmd0aCA8IDMpIHsKICAgIHJldHVybiB7CiAgICAgIHIsCiAgICAgIGcsCiAgICAgIGIKICAgIH07CiAgfQogIFtyLCBnLCBiXSA9IGNvbG9yOwogIHJldHVybiB7CiAgICByLAogICAgZywKICAgIGIKICB9Owp9CmZ1bmN0aW9uIGdldEJCb3goZGF0YSkgewogIGNvbnN0IGRlZiA9IC0xOwogIGlmICghZGF0YSkgewogICAgcmV0dXJuIHsKICAgICAgeDogZGVmLAogICAgICB5OiBkZWYsCiAgICAgIHdpZHRoOiBkZWYsCiAgICAgIGhlaWdodDogZGVmCiAgICB9OwogIH0KICBjb25zdCBiYm94ID0gZGF0YS50cmltKCkuc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AgcG9zICs9IG1hdGNoWzBdLmxlbmd0aCArIDE7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgbGV0IG9wZXJhdG9yOwogICAgc3dpdGNoIChleHByLmNoYXJBdChwb3MpKSB7CiAgICAgIGNhc2UgIi4iOgogICAgICAgIGlmICghZG90RG90QWxsb3dlZCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIHBvcysrOwogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdERvdDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiIyI6CiAgICAgICAgcG9zKys7CiAgICAgICAgb3BlcmF0b3IgPSBvcGVyYXRvcnMuZG90SGFzaDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiWyI6CiAgICAgICAgaWYgKG5vRXhwcikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBTT00gZXhwcmVzc2lvbiBjb250YWlucyBhIEZvcm1DYWxjIHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdEJyYWNrZXQ7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIigiOgogICAgICAgIGlmIChub0V4cHIpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gU09NIGV4cHJlc3Npb24gY29udGFpbnMgYSBKYXZhU2NyaXB0IHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdFBhcmVuOwogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzL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kID0gY29udGFpbmVyID09PSBudWxsOwogICAgcm9vdCA9IFtjb250YWluZXIgfHwgcm9vdF07CiAgfQogIGZvciAobGV0IGlpID0gcGFyc2VkLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgIGNvbnN0IHsKICAgICAgbmFtZSwKICAgICAgY2FjaGVOYW1lLAogICAgICBvcGVyYXRvciwKICAgICAgaW5kZXgKICAgIH0gPSBwYXJzZWRbaV07CiAgICBjb25zdCBub2RlcyA9IFtdOwogICAgZm9yIChjb25zdCBub2RlIG9mIHJvb3QpIHsKICAgICAgaWYgKCEobm9kZSBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgY2hpbGRyZW4sIGNhY2hlZDsKICAgICAgaWYgKHVzZUNhY2hlKSB7CiAgICAgICAgY2FjaGVkID0gc29tQ2FjaGUuZ2V0KG5vZGUpOwogICAgICAgIGlmICghY2FjaGVkKSB7CiAgICAgICAgICBjYWNoZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICBzb21DYWNoZS5zZXQobm9kZSwgY2FjaGVkKTsKICAgICAgICB9CiAgICAgICAgY2hpbGRyZW4gPSBjYWNoZWQuZ2V0KGNhY2hlTmFtZSk7CiAgICAgIH0KICAgICAgaWYgKCFjaGlsZHJlbikgewogICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgZmFsc2UpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdERvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgdHJ1ZSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBvcGVyYXRvcnMuZG90SGFzaDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5Q2xhc3NdKG5hbWUpOwogICAgICAgICAgICBpZiAoY2hpbGRyZW4gaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSkgewogICAgICAgICAgICAgIGNoaWxkcmVuID0gY2hpbGRyZW4uY2hpbGRyZW47CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY2hpbGRyZW4gPSBbY2hpbGRyZW5dOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICh1c2VDYWNoZSkgewogICAgICAgICAgY2FjaGVkLnNldChjYWNoZU5hbWUsIGNoaWxkcmVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICBub2Rlcy5wdXNoKGNoaWxkcmVuKTsKICAgICAgfQogICAgfQogICAgaWYgKG5vZGVzLmxlbmd0aCA9PT0gMCAmJiAhaXNRdWFsaWZpZWQgJiYgaSA9PT0gMCkgewogICAgICBjb25zdCBwYXJlbnQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgICAgY29udGFpbmVyID0gcGFyZW50OwogICAgICBpZiAoIWNvbnRhaW5lcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGkgPSAtMTsKICAgICAgcm9vdCA9IFtjb250YWluZXJdOwogICAgICBjb250aW51ZTsKICAgIH0KICAgIGlmIChpc0Zpbml0ZShpbmRleCkpIHsKICAgICAgcm9vdCA9IG5vZGVzLmZpbHRlcihub2RlID0+IGluZGV4IDwgbm9kZS5sZW5ndGgp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W51ZTsKICAgICAgfQogICAgICBjb25zdCBub2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZGF0YU5vZGUsIHJlZiwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCFub2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCByZWZlcmVuY2U6ICR7cmVmfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbbm9kZV0gPSBub2RlczsKICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YSkpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgbm9kZTogbXVzdCBiZSBhIGRhdGEgbm9kZS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0YXJnZXROb2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZm9ybU5vZGUsIHRhcmdldCwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCF0YXJnZXROb2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCB0YXJnZXQ6ICR7dGFyZ2V0fS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbdGFyZ2V0Tm9kZV0gPSB0YXJnZXROb2RlczsKICAgICAgaWYgKCF0YXJnZXROb2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKGZvcm1Ob2RlKSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCB0YXJnZXQ6IG11c3QgYmUgYSBwcm9wZXJ0eSBvciBzdWJwcm9wZXJ0eS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0YXJnZXRQYXJlbnQgPSB0YXJnZXROb2RlW194ZmFfb2JqZW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ybU5vZGVbX3hmYV9vYmplY3QuJGFwcGVuZENoaWxkXSh2YWx1ZXMpOwogICAgZm9ybU5vZGUuaXRlbXMucHVzaCh2YWx1ZXMpOwogICAgZm9yIChjb25zdCB7CiAgICAgIHJlZiwKICAgICAgbGFiZWxSZWYsCiAgICAgIHZhbHVlUmVmLAogICAgICBjb25uZWN0aW9uCiAgICB9IG9mIGZvcm1Ob2RlLmJpbmRJdGVtcy5jaGlsZHJlbikgewogICAgICBpZiAoY29ubmVjdGlvbikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghcmVmKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3Qgbm9kZXMgPSAoMCwgX3NvbS5zZWFyY2hOb2RlKSh0aGlzLnJvb3QsIGRhdGFOb2RlLCByZWYsIGZhbHNlLCBmYWxzZSk7CiAgICAgIGlmICghbm9kZXMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgcmVmZXJlbmNlOiAke3JlZn0uYCk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChjb25zdCBub2RlIG9mIG5vZGVzKSB7CiAgICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YXNldHMpKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgcmVmICgke3JlZn0pOiBtdXN0IGJlIGEgZGF0YXNldHMgY2hpbGQuYCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgbGFiZWxOb2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgbm9kZSwgbGFiZWxSZWYsIHRydWUsIGZhbHNlKTsKICAgICAgICBpZiAoIWxhYmVsTm9kZXMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCBsYWJl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09IE5TX0RBVEFTRVRTID8gLTEgOiBkYXRhTm9kZVtfeGZhX29iamVjdC4kbmFtZXNwYWNlSWRdOwogICAgICAgICAgY29uc3QgZGF0YUNoaWxkID0gY2hpbGRbX3hmYV9vYmplY3QuJGRhdGFdID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBjaGlsZC5uYW1lIHx8ICJyb290Iik7CiAgICAgICAgICBkYXRhTm9kZVtfeGZhX29iamVjdC4kYXBwZW5kQ2hpbGRdKGRhdGFDaGlsZCk7CiAgICAgICAgICB0aGlzLl9iaW5kRWxlbWVudChjaGlsZCwgZGF0YUNoaWxkKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKCFjaGlsZFtfeGZhX29iamVjdC4kaXNCaW5kYWJsZV0oKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCBnbG9iYWwgPSBmYWxzZTsKICAgICAgbGV0IHBpY3R1cmUgPSBudWxsOwogICAgICBsZXQgcmVmID0gbnVsbDsKICAgICAgbGV0IG1hdGNoID0gbnVsbDsKICAgICAgaWYgKGNoaWxkLmJpbmQpIHsKICAgICAgICBzd2l0Y2ggKGNoaWxkLmJpbmQubWF0Y2gpIHsKICAgICAgICAgIGNhc2UgIm5vbmUiOgogICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgY2FzZSAiZ2xvYmFsIjoKICAgICAgICAgICAgZ2xvYmFsID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJkYXRhUmVmIjoKICAgICAgICAgICAgaWYgKCFjaGlsZC5iaW5kLnJlZikgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gcmVmIGlzIGVtcHR5IGluIG5vZGUgJHtjaGlsZFtfeGZhX29iamVjdC4kbm9kZU5hbWVdfS5gKTsKICAgICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVmID0gY2hpbGQuYmluZC5yZWY7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChjaGlsZC5iaW5kLnBpY3R1cmUpIHsKICAgICAgICAgIHBpY3R1cmUgPSBjaGlsZC5iaW5kLnBpY3R1cmVbX3hmYV9vYmplY3QuJGNvbnRlbnRdOwogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBbbWluLCBtYXhdID0gdGhpcy5fZ2V0T2NjdXJJbmZvKGNoaWxkKTsKICAgICAgaWYgKHJlZikgewogICAgICAgIG1hdGNoID0gKDAsIF9zb20uc2VhcmNoTm9kZSkodGhpcy5yb290LCBkYXRhTm9kZSwgcmVmLCB0cnVlLCBmYWxzZSk7CiAgICAgICAgaWYgKG1hdGNoID09PSBudWxsKSB7CiAgICAgICAgICBtYXRjaCA9ICgwLCBfc29tLmNyZWF0ZURhdGFOb2RlKSh0aGlzLmRhdGEsIGRhdGFOb2RlLCByZWYpOwogICAgICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgICAgbWF0Y2hbX3hmYV9vYmplY3QuJGNvbnN1bWVkXSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKHRoaXMuX2lzQ29uc3VtZURhdGEoKSkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLmZpbHRlcihub2RlID0+ICFub2RlW194ZmFfb2JqZWN0LiRjb25zdW1lZF0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG1hdGNoLmxlbmd0aCA+IG1heCkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLnNsaWNlKDAsIG1heCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICBtYXRjaCA9IG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobWF0Y2ggJiYgdGhpcy5faXNDb25zdW1lRGF0YSgpKSB7CiAgICAgICAgICAgIG1hdGNoLmZvckVhY2gobm9kZSA9PiB7CiAgICAgICAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29uc3VtZWRdID0gdHJ1ZTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICghY2hpbGQubmFtZSkgewogICAgICAgICAgdGhpcy5fc2V0QW5kQmluZChjaGlsZCwgZGF0YU5vZGUpOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgIHdoaWxlIChtYXRjaGVzLmxlbmd0aCA8IG1heCkgewogICAgICAgICAgICBjb25zdCBmb3VuZCA9IHRoaXMuX2ZpbmREYXRhQnlOYW1lVG9Db25zdW1lKGNoaWxkLm5hbWUsIGNoaWxkW194ZmFfb2JqZWN0LiRoYXNTZXR0YWJsZVZhbHVlXSgpLCBkYXRhTm9kZSwgZ2xvYmFsKTsKICAgICAgICAgICAgaWYgKCFmb3VuZCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvdW5kW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICBtYXRjaGVzLnB1c2goZm91bmQpOwogICAgICAgICAgfQogICAgICAgICAgbWF0Y2ggPSBtYXRjaGVzLmxlbmd0aCA+IDAgPyBtYXRjaGVzIDogbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbWF0Y2ggPSBkYXRhTm9kZVtfeGZhX29iamVjdC4kZ2V0UmVhbENoaWxkcmVuQnlOYW1lSXRdKGNoaWxkLm5hbWUsIGZhbHNlLCB0aGlzLmVtcHR5TWVyZ2UpLm5leHQoKS52YWx1ZTsKICAgICAgICAgIGlmICghbWF0Y2gpIHsKICAgICAgICAgICAgaWYgKG1pbiA9PT0gMCkgewogICAgICAgICAgICAgIHVzZWxlc3NOb2Rlcy5wdXNoKGNoaWxkKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBuc0lkID0gZGF0YU5vZGVbX3hmYV9vYmplY3QuJG5hbWVzcGFjZUlkXSA9PT0gTlNfREFUQVNFVFMgPyAtMSA6IGRhdGFOb2RlW194ZmFfb2JqZWN0LiRuYW1lc3BhY2VJZF07CiAgICAgICAgICAgIG1hdGNoID0gY2hpbGRbX3hmYV9vYmplY3QuJGRhdGFdID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBjaGlsZC5uYW1lKTsKICAgICAgICAgICAgaWYgKHRoaXMuZW1wdHlNZXJnZSkgewogICAgICAgICAgICAgIG1hdGNoW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGFOb2RlW194ZmFfb2JqZWN0LiRhcHBlbmRDaGlsZF0obWF0Y2gpOwogICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW1wdHlNZXJnZSkgewogICAgICAgICAgICBtYXRjaFtfeGZhX29i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LiR0YWJJbmRleF0pIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgbGV0IG5leHQgPSBudWxsOwogICAgZm9yIChjb25zdCBjaGlsZCBvZiBub2RlLnRyYXZlcnNhbFtfeGZhX29iamVjdC4kZ2V0Q2hpbGRyZW5dKCkpIHsKICAgICAgaWYgKGNoaWxkLm9wZXJhdGlvbiA9PT0gIm5leHQiKSB7CiAgICAgICAgbmV4dCA9IGNoaWxkOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoIW5leHQgfHwgIW5leHQucmVmKSB7CiAgICAgIG5vZGVbX3hmYV9vYmplY3QuJHRhYkluZGV4XSA9IG5vZGVbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKVtfeGZhX29iamVjdC4kdGFiSW5kZXhdOwogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCByb290ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0VGVtcGxhdGVSb290XSgpOwogICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gKytyb290W194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICBjb25zdCByZWYgPSByb290W194ZmFfb2JqZWN0LiRzZWFyY2hOb2RlXShuZXh0LnJlZiwgbm9kZSk7CiAgICBpZiAoIXJlZikgewogICAgICByZXR1cm47CiAgICB9CiAgICBub2RlID0gcmVmWzBdOwogIH0KfQpmdW5jdGlvbiBhcHBseUFzc2lzdChvYmosIGF0dHJpYnV0ZXMpIHsKICBjb25zdCBhc3Npc3QgPSBvYmouYXNzaXN0OwogIGlmIChhc3Npc3QpIHsKICAgIGNvbnN0IGFzc2lzdFRpdGxlID0gYXNzaXN0W194ZmFfb2JqZWN0LiR0b0hUTUxdKCk7CiAgICBpZiAoYXNzaXN0VGl0bGUpIHsKICAgICAgYXR0cmlidXRlcy50aXRsZSA9IGFzc2lzdFRpdGxlOwogICAgfQogICAgY29uc3Qgcm9sZSA9IGFzc2lzdC5yb2xlOwogICAgY29uc3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2V0UGFyZW50XSgpOwogICAgY29uc3QgaHRtbEJ1dHRvbiA9IHsKICAgICAgbmFtZTogImJ1dHRvbiIsCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICBpZDogdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICBjbGFzczogWyJ4ZmFCdXR0b24iXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW46IFtdCiAgICB9OwogICAgZm9yIChjb25zdCBldmVudCBvZiBncmFuZHBhLmV2ZW50LmNoaWxkcmVuKSB7CiAgICAgIGlmIChldmVudC5hY3Rpdml0eSAhPT0gImNsaWNrIiB8fCAhZXZlbnQuc2NyaXB0KSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QganNVUkwgPSAoMCwgX2NvcmVfdXRpbHMucmVjb3ZlckpzVVJMKShldmVudC5zY3JpcHRbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgaWYgKCFqc1VSTCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGhyZWYgPSAoMCwgX2h0bWxfdXRpbHMuZml4VVJMKShqc1VSTC51cmwpOwogICAgICBpZiAoIWhyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBodG1sQnV0dG9uLmNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICJhIiwKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBpZDogImxpbmsiICsgdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGhyZWYsCiAgICAgICAgICBuZXdXaW5kb3c6IGpzVVJMLm5ld1dpbmRvdywKICAgICAgICAgIGNsYXNzOiBbInhmYUxpbmsiXSwKICAgICAgICAgIHN0eWxlOiB7fQogICAgICAgIH0sCiAgICAgICAgY2hpbGRyZW46IFtdCiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIF91dGlscy5IVE1MUmV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VhazsKICAgICAgfQogICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0gPSAoMCwgX2h0bWxfdXRpbHMubGF5b3V0Tm9kZSkodGhpcywgewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodAogICAgICB9KTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV07CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgaWYgKCF0aGlzLnZhbHVlKSB7CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5FTVBUWTsKICAgIH0KICAgIHRoaXNbX3hmYV9vYmplY3QuJHB1c2hQYXJhXSgpOwogICAgY29uc3QgdmFsdWUgPSB0aGlzLnZhbHVlW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKS5odG1sOwogICAgaWYgKCF2YWx1ZSkgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuRU1QVFk7CiAgICB9CiAgICBjb25zdCBzYXZlZFJlc2VydmUgPSB0aGlzLnJlc2VydmU7CiAgICBpZiAodGhpcy5yZXNlcnZlIDw9IDApIHsKICAgICAgY29uc3QgewogICAgICAgIHcsCiAgICAgICAgaAogICAgICB9ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0RXh0cmFdKGF2YWlsYWJsZVNwYWNlKTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgdGhpcy5yZXNlcnZlID0gdzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInRvcCI6CiAgICAgICAgY2FzZSAiYm90dG9tIjoKICAgICAgICAgIHRoaXMucmVzZXJ2ZSA9I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eGZhX29iamVjdC4kdWlkXTsKICAgIGxldCBkYXRhSWQ7CiAgICBpZiAoY29udGFpbmVyIGluc3RhbmNlb2YgRXhjbEdyb3VwKSB7CiAgICAgIGdyb3VwSWQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJHVpZF07CiAgICAgIHR5cGUgPSAicmFkaW8iOwogICAgICBjbGFzc05hbWUgPSAieGZhUmFkaW8iOwogICAgICBkYXRhSWQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGRhdGFdICYmIGNvbnRhaW5lcltfeGZhX29iamVjdC4kZGF0YV1bX3hmYV9vYmplY3QuJHVpZF0gfHwgY29udGFpbmVyW194ZmFfb2JqZWN0LiR1aWRdOwogICAgfSBlbHNlIHsKICAgICAgdHlwZSA9ICJjaGVja2JveCI7CiAgICAgIGNsYXNzTmFtZSA9ICJ4ZmFDaGVja2JveCI7CiAgICAgIGRhdGFJZCA9IGZpZWxkW194ZmFfb2JqZWN0LiRkYXRhXSAmJiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV1bX3hmYV9vYmplY3QuJHVpZF0gfHwgZmllbGRbX3hmYV9vYmplY3QuJHVpZF07CiAgICB9CiAgICBjb25zdCBpbnB1dCA9IHsKICAgICAgbmFtZTogImlucHV0IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBbY2xhc3NOYW1lXSwKICAgICAgICBzdHlsZSwKICAgICAgICBmaWVsZElkLAogICAgICAgIGRhdGFJZCwKICAgICAgICB0eXBlLAogICAgICAgIGNoZWNrZWQsCiAgICAgICAgeGZhT246IGV4cG9ydGVkVmFsdWUub24sCiAgICAgICAgeGZhT2ZmOiBleHBvcnRlZFZhbHVlLm9mZiwKICAgICAgICAiYXJpYS1sYWJlbCI6IGFyaWFMYWJlbChmaWVsZCksCiAgICAgICAgImFyaWEtcmVxdWlyZWQiOiBmYWxzZQogICAgICB9CiAgICB9OwogICAgaWYgKGdyb3VwSWQpIHsKICAgICAgaW5wdXQuYXR0cml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BpdGVtcy5jaGlsZHJlbltkaXNwbGF5ZWRJbmRleF1bX3hmYV9vYmplY3QuJHRvSFRNTF0oKS5odG1sOwogICAgICBjb25zdCB2YWx1ZXMgPSBpdGVtcy5jaGlsZHJlbltzYXZlSW5kZXhdW194ZmFfb2JqZWN0LiR0b0hUTUxdKCkuaHRtbDsKICAgICAgbGV0IHNlbGVjdGVkID0gZmFsc2U7CiAgICAgIGNvbnN0IHZhbHVlID0gZmllbGQudmFsdWUgJiYgZmllbGQudmFsdWVbX3hmYV9vYmplY3QuJHRleHRdKCkgfHwgIiI7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRpc3BsYXllZC5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29uc3Qgb3B0aW9uID0gewogICAgICAgICAgbmFtZTogIm9wdGlvbiIsCiAgICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICAgIHZhbHVlOiB2YWx1ZXNbaV0gfHwgZGlzcGxheWVkW2ldLAogICAgICAgICAgICBzdHlsZTogb3B0aW9uU3R5bGUKICAgICAgICAgIH0sCiAgICAgICAgICB2YWx1ZTogZGlzcGxheWVkW2ldCiAgICAgICAgfTsKICAgICAgICBpZiAodmFsdWVzW2ldID09PSB2YWx1ZSkgewogICAgICAgICAgb3B0aW9uLmF0dHJpYnV0ZXMuc2VsZWN0ZWQgPSBzZWxlY3RlZCA9IHRydWU7CiAgICAgICAgfQogICAgICAgIGNoaWxkcmVuLnB1c2gob3B0aW9uKTsKICAgICAgfQogICAgICBpZiAoIXNlbGVjdGVkKSB7CiAgICAgICAgY2hpbGRyZW4uc3BsaWNlKDAsIDAsIHsKICAgICAgICAgIG5hbWU6ICJvcHRpb24iLAogICAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgICBoaWRkZW46IHRydWUsCiAgICAgICAgICAgIHNlbGVjdGVkOiB0cnVlCiAgICAgICAgICB9LAogICAgICAgICAgdmFsdWU6ICIgIgogICAgICAgIH0p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ZhbHVlKSB7CiAgICBfc2V0VmFsdWUodGhpcywgdmFsdWUpOwogIH0KICBbX3hmYV9vYmplY3QuJHRvSFRNTF0oYXZhaWxhYmxlU3BhY2UpIHsKICAgIHNldFRhYkluZGV4KHRoaXMpOwogICAgaWYgKCF0aGlzLnVpKSB7CiAgICAgIHRoaXMudWkgPSBuZXcgVWkoe30pOwogICAgICB0aGlzLnVpW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXSA9IHRoaXNbX3hmYV9vYmplY3QuJGdsb2JhbERhdGFdOwogICAgICB0aGlzW194ZmFfb2JqZWN0LiRhcHBlbmRDaGlsZF0odGhpcy51aSk7CiAgICAgIGxldCBub2RlOwogICAgICBzd2l0Y2ggKHRoaXMuaXRlbXMuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgbm9kZSA9IG5ldyBUZXh0RWRpdCh7fSk7CiAgICAgICAgICB0aGlzLnVpLnRleHRFZGl0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIG5vZGUgPSBuZXcgQ2hlY2tCdXR0b24oe30pOwogICAgICAgICAgdGhpcy51aS5jaGVja0J1dHRvbiA9IG5vZGU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICBub2RlID0gbmV3IENob2ljZUxpc3Qoe30pOwogICAgICAgICAgdGhpcy51aS5jaG9pY2VMaXN0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMudWlbX3hmYV9vYmplY3QuJGFwcGVuZENoaWxkXShub2RlKTsKICAgIH0KICAgIGlmICghdGhpcy51aSB8fCB0aGlzLnByZXNlbmNlID09PSAiaGlkZGVuIiB8fCB0aGlzLnByZXNlbmNlID09PSAiaW5hY3RpdmUiIHx8IHRoaXMuaCA9PT0gMCB8fCB0aGlzLncgPT09IDApIHsKICAgICAgcmV0dXJuIF91dGlscy5IV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AgICAgICBpZiAodyAhPT0gbnVsbCkgewogICAgICAgICAgdWlXID0gdzsKICAgICAgICAgIHVpSCA9IGg7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHVpSCA9ICgwLCBfZm9udHMuZ2V0TWV0cmljcykodGhpcy5mb250LCB0cnVlKS5saW5lTm9HYXA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGJvcmRlckRpbXMgPSBnZXRCb3JkZXJEaW1zKHRoaXMudWlbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpKTsKICAgICAgdWlXICs9IGJvcmRlckRpbXMudzsKICAgICAgdWlIICs9IGJvcmRlckRpbXMuaDsKICAgICAgaWYgKHRoaXMuY2FwdGlvbikgewogICAgICAgIGNvbnN0IHsKICAgICAgICAgIHcsCiAgICAgICAgICBoLAogICAgICAgICAgaXNCcm9rZW4KICAgICAgICB9ID0gdGhpcy5jYXB0aW9uW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oYXZhaWxhYmxlU3BhY2UpOwogICAgICAgIGlmIChpc0Jyb2tlbiAmJiB0aGlzW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpW194ZmFfb2JqZWN0LiRpc1RoZXJlTW9yZVdpZHRoXSgpKSB7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkZBSUxVUkU7CiAgICAgICAgfQogICAgICAgIHdpZHRoID0gdzsKICAgICAgICBoZWlnaHQgPSBoOwogICAgICAgIHN3aXRjaCAodGhpcy5jYXB0aW9uLnBsYWNlbWVudCkgewogICAgICAgICAgY2FzZSAibGVmdCI6CiAgICAgICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgICB3aWR0aCArPSB1aVc7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgICAgIGhlaWdodCArPSB1aUg7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB3aWR0aCA9IHVpVzsKICAgICAgICBoZWlnaHQgPSB1aUg7CiAgICAgIH0KICAgICAgaWYgKHdpZHRoICYmIHRoaXMudyA9PT0gIiIpIHsKICAgICAgICB3aWR0aCArPSBtYXJnaW5IOwogICAgICAgIHRoaXMudyA9IE1hdGgubWluKHRoaXMubWF4VyA8PSAwID8gSW5maW5pdHkgOiB0aGlzLm1heFcsIHRoaXMubWluVyArIDEgPCB3aWR0aCA/IHdpZHRoIDogdGhpcy5taW5XKTsKICAgICAgfQogICAgICBpZiAoaGVpZ2h0ICYmIHRoaXMuaCA9PT0gIiIpIHsKICAgICAgICBoZWlnaHQgKz0gbWFyZ2luVjsKICAgICAgICB0aGlzLmggPSBNYXRoLm1pbih0aGlzLm1heEggPD0gMCA/IEluZmluaXR5IDogdGhpcy5tYXhILCB0aGlzLm1pbkggKyAxIDwgaGVpZ2h0ID8gaGVpZ2h0IDogdGhpcy5taW5IKTsKICAgICAgfQogICAgfQogICAgdGhpc1tfeGZhX29iamVjdC4kcG9wUGFyYV0oKTsKICAgICgwLCBfaHRtbF91dGlscy5maXhEaW1lbnNpb25zKSh0aGlzKTsKICAgIHNldEZpcnN0VW5zcGxpdHRhYmxlKHRoaXMpOwogICAgaWYgKCEoMCwgX2xheW91dC5jaGVja0RpbWVuc2lvbnMpKHRoaXMsIGF2YWlsYWJsZVNwYWNlKSkgewogICAgICB0aGlzLncgPSBzYXZlZFc7CiAgICAgIHRoaXMuaCA9IHNhdmVkSDsKICAgICAgdGhpc1tfeGZhX29iamVjdC4kcG9wUGFyYV0oKTsKICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkZBSUxVUkU7CiAgICB9CiAgICB1bnNldEZpcnN0VW5zcGxpdHRhYmxlKHRoaXMpOwogICAgY29uc3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0gImJhY2tncm91bmQtY29sb3IiOwogICAgICBhbHRQcm9wTmFtZSA9ICJiYWNrZ3JvdW5kIjsKICAgICAgaWYgKGdncmFuZHBhIGluc3RhbmNlb2YgVWkpIHsKICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSAid2hpdGUiOwogICAgICB9CiAgICB9CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgUmVjdGFuZ2xlIHx8IHBhcmVudCBpbnN0YW5jZW9mIEFyYykgewogICAgICBwcm9wTmFtZSA9IGFsdFByb3BOYW1lID0gImZpbGwiOwogICAgICBzdHlsZS5maWxsID0gIndoaXRlIjsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImV4dHJhcyIgfHwgbmFtZSA9PT0gImNvbG9yIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBjb2xvciA9IG9ialtfeGZhX29iamVjdC4kdG9TdHlsZV0odGhpcy5jb2xvcik7CiAgICAgIGlmIChjb2xvcikgewogICAgICAgIHN0eWxlW2NvbG9yLnN0YXJ0c1dpdGgoIiMiKSA/IHByb3BOYW1lIDogYWx0UHJvcE5hbWVdID0gY29sb3I7CiAgICAgIH0KICAgICAgcmV0dXJuIHN0eWxlOwogICAgfQogICAgaWYgKHRoaXMuY29sb3IgJiYgdGhpcy5jb2xvci52YWx1ZSkgewogICAgICBjb25zdCBjb2xvciA9IHRoaXMuY29sb3JbX3hmYV9vYmplY3QuJHRvU3R5bGVdKCk7CiAgICAgIHN0eWxlW2NvbG9yLnN0YXJ0c1dpdGgoIiMiKSA/IHByb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TdHJpbmcpKHRoaXMubGV0dGVyU3BhY2luZyk7CiAgICBpZiAodGhpcy5saW5lVGhyb3VnaCAhPT0gMCkgewogICAgICBzdHlsZS50ZXh0RGVjb3JhdGlvbiA9ICJsaW5lLXRocm91Z2giOwogICAgICBpZiAodGhpcy5saW5lVGhyb3VnaCA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMub3ZlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAib3ZlcmxpbmUiOwogICAgICBpZiAodGhpcy5vdmVybGluZSA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgc3R5bGUuZm9udFN0eWxlID0gdGhpcy5wb3N0dXJlOwogICAgc3R5bGUuZm9udFNpemUgPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKSgwLjk5ICogdGhpcy5zaXplKTsKICAgICgwLCBfaHRtbF91dGlscy5zZXRGb250RmFtaWx5KSh0aGlzLCB0aGlzLCB0aGlzW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXS5mb250RmluZGVyLCBzdHlsZSk7CiAgICBpZiAodGhpcy51bmRlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAidW5kZXJsaW5lIjsKICAgICAgaWYgKHRoaXMudW5kZXJsaW5lID09PSAyKSB7CiAgICAgICAgc3R5bGUudGV4dERlY29yYXRpb25TdHlsZSA9ICJkb3VibGUiOwogICAgICB9CiAgICB9CiAgICBzdHlsZS5mb250V2VpZ2h0ID0gdGhpcy53ZWlnaHQ7CiAgICByZXR1cm4gc3R5bGU7CiAgfQp9CmNsYXNzIEZvcm1hdCBleHRlbmRzIF94ZmFfb2JqZWN0LlhGQU9iamVjdCB7CiAgY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DAlIiwgIjUwJSJdOwogICAgICBoZWlnaHQgPSBzdHlsZS5zdHJva2VXaWR0aDsKICAgIH0gZWxzZSB7CiAgICAgIGlmICh0aGlzLnNsb3BlID09PSAiXFwiKSB7CiAgICAgICAgW3gxLCB5MSwgeDIsIHkyXSA9IFswLCAwLCAiMTAwJSIsICIxMDAlIl07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgW3gxLCB5MSwgeDIsIHkyXSA9IFswLCAiMTAwJSIsICIxMDAlIiwgMF07CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGxpbmUgPSB7CiAgICAgIG5hbWU6ICJsaW5lIiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIHhtbG5zOiBTVkdfTlMsCiAgICAgICAgeDEsCiAgICAgICAgeTEsCiAgICAgICAgeDIsCiAgICAgICAgeTIsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbbGluZV0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBzdHlsZTogewogICAgICAgICAgb3ZlcmZsb3c6ICJ2aXNpYmxlIgogICAgICAgIH0KICAgICAgfQogICAgfTsKICAgIGlmIChoYXNNYXJnaW4ocGFyZW50KSkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgc3R5bGU6IHsKICAgICAgICAgICAgZGlzcGxheTogImlubGluZSIsCiAgICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBjaGlsZHJlbjogW3N2Z10KICAgICAgfSk7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N0eWxlXSgpOwogICAgY29uc3QgcmVjdCA9IHsKICAgICAgbmFtZTogInJlY3QiLAogICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgeG1sbnM6IFNWR19OUywKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiLAogICAgICAgIHg6IDAsCiAgICAgICAgeTogMCwKICAgICAgICByeDogY29ybmVyU3R5bGUucmFkaXVzLAogICAgICAgIHJ5OiBjb3JuZXJTdHlsZS5yYWRpdXMsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbcmVjdF0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICBvdmVyZmxvdzogInZpc2libGUiCiAgICAgICAgfSwKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgIH0KICAgIH07CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKClbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgIGlmIChoYXNNYXJnaW4ocGFyZW50KSkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgc3R5bGU6IHsKICAgICAgICAgICAgZGlzcGxheTogImlubGluZSIsCiAgICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBjaGlsZHJlbjogW3N2Z10KICAgICAgfSk7CiAgICB9CiAgICBzdmcuYXR0cmlidXRlcy5zdHlsZS5wb3Npd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ldGhpbmcgPSBoYXNTb21ldGhpbmcgfHwgaHRtbC5jaGlsZHJlbiAmJiBodG1sLmNoaWxkcmVuLmxlbmd0aCAhPT0gMDsKICAgICAgICAgIGh0bWxDb250ZW50QXJlYXNbaW5kZXhdLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleCwgaWkgPSBjb250ZW50QXJlYXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGNvbnRlbnRBcmVhID0gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmN1cnJlbnRDb250ZW50QXJlYSA9IGNvbnRlbnRBcmVhc1tpXTsKICAgICAgICBjb25zdCBzcGFjZSA9IHsKICAgICAgICAgIHdpZHRoOiBjb250ZW50QXJlYS53LAogICAgICAgICAgaGVpZ2h0OiBjb250ZW50QXJlYS5oCiAgICAgICAgfTsKICAgICAgICBzdGFydEluZGV4ID0gMDsKICAgICAgICBpZiAobGVhZGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2gobGVhZGVyW194ZmFfb2JqZWN0LiR0b0hUTUxdKHNwYWNlKS5odG1sKTsKICAgICAgICAgIGxlYWRlciA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICh0cmFpbGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2godHJhaWxlcltfeGZhX29iamVjdC4kdG9IVE1MXShzcGFjZSkuaHRtbCk7CiAgICAgICAgICB0cmFpbGVyID0gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3QgaHRtbCA9IHJvb3RbX3hmYV9vYmplY3QuJHRvSFRNTF0oc3BhY2UpOwogICAgICAgIGlmIChodG1sLnN1Y2Nlc3MpIHsKICAgICAgICAgIGlmIChodG1sLmh0bWwpIHsKICAgICAgICAgICAgaGFzU29tZXRoaW5nID0gaGFzU29tZXRoaW5nIHx8IGh0bWwuaHRtbC5jaGlsZHJlbiAmJiBodG1sLmh0bWwuY2hpbGRyZW4ubGVuZ3RoICE9PSAwOwogICAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2goaHRtbC5odG1sKTsKICAgICAgICAgIH0gZWxzZSBpZiAoIWhhc1NvbWV0aGluZyAmJiBtYWluSHRtbC5jaGlsZHJlbi5sZW5ndGggPiAxKSB7CiAgICAgICAgICAgIG1haW5IdG1sLmNoaWxkcmVuLnBvcCgpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG1haW5IdG1sOwogICAgICAgIH0KICAgICAgICBpZiAoaHRtbC5pc0JyZWFrKCkpIHsKICAgICAgICAgIGNvbnN0IG5vZGUgPSBodG1sLmJyZWFrTm9kZTsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gImF1dG8iKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUubGVhZGVyKSB7CiAgICAgICAgICAgIGxlYWRlciA9IHRoaXNbX3hmYV9vYmplY3QuJHNlYXJjaE5vZGVdKG5vZGUubGVhZGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICBsZWFkZXIgPSBsZWFkZXIgPyBsZWFkZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudHJhaWxlcikgewogICAgICAgICAgICB0cmFpbGVyID0gdGhpc1tfeGZhX29iamVjdC4kc2VhcmNoTm9kZV0obm9kZS50cmFpbGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICB0cmFpbGVyID0gdHJhaWxlciA/IHRyYWlsZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudGFy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0gbnVsbDsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgY29uc3QgY3VycmVudEluZGV4ID0gaTsKICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIGlmICh0YXJnZXQgaW5zdGFuY2VvZiBQYWdlQXJlYSkgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IHRhcmdldDsKICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0IGluc3RhbmNlb2YgQ29udGVudEFyZWEpIHsKICAgICAgICAgICAgY29uc3QgaW5kZXggPSBjb250ZW50QXJlYXMuaW5kZXhPZih0YXJnZXQpOwogICAgICAgICAgICBpZiAoaW5kZXggIT09IC0xKSB7CiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gY3VycmVudEluZGV4KSB7CiAgICAgICAgICAgICAgICBpID0gaW5kZXggLSAxOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaW5kZXg7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gdGFyZ2V0W194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICAgICAgICAgICAgc3RhcnRJbmRleCA9IHRhcmdldFBhZ2VBcmVhLmNvbnRlbnRBcmVhLmNoaWxkcmVuLmluZGV4T2YodGFyZ2V0KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZsdXNoKGkpOwogICAgICB9CiAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXS5wYWdlTnVtYmVyICs9IDE7CiAgICAgIGlmICh0YXJnZXRQYWdlQXJlYSkgewogICAgICAgIGlmICh0YXJnZXRQYWdlQXJlYVtfeGZhX29iamVjdC4kaXNVc2FibGVdKCkpIHsKICAgICAgICAgIHRhcmdldFBhZ2VBcmVhW194ZmFfb2JqZWN0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bWVzcGFjZUlkcy54aHRtbC5pZCkgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XSA9IGNoaWxkOwogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCBjb250ZW50IGluIFRleHQ6ICR7Y2hpbGRbX3hmYV9vYmplY3QuJG5vZGVOYW1lXX0uYCk7CiAgICByZXR1cm4gZmFsc2U7CiAgfQogIFtfeGZhX29iamVjdC4kb25UZXh0XShzdHIpIHsKICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XSBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkgewogICAgICByZXR1cm47CiAgICB9CiAgICBzdXBlcltfeGZhX29iamVjdC4kb25UZXh0XShzdHIpOwogIH0KICBbX3hmYV9vYmplY3QuJGZpbmFsaXplXSgpIHsKICAgIGlmICh0eXBlb2YgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gPT09ICJzdHJpbmciKSB7CiAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID0gdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0ucmVwbGFjZUFsbCgiXHJcbiIsICJcbiIpOwogICAgfQogIH0KICBbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpIHsKICAgIGlmICh0eXBlb2YgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gPT09ICJzdHJpbmciKSB7CiAgICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOVx1MjAyOFxuXS8pLnJlZHVjZSgoYWNjLCBsaW5lKSA9PiB7CiAgICAgICAgaWYgKGxpbmUpIHsKICAgICAgICAgIGFjYy5wdXNoKGxpbmUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYWNjOwogICAgICB9LCBbXSkuam9pbigiXG4iKTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XVtfeGZhX29iamVjdC4kdGV4dF0oKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBpZiAodHlwZW9mIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID09PSAic3RyaW5nIikgewogICAgICBjb25zdCBodG1sID0gdmFsdWVUb0h0bWwodGhpc1tfeGZhX29iamVjdC4kY29udGVudF0pLmh0bWw7CiAgICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5pbmNsdWRlcygiXHUyMDI5IikpIHsKICAgICAgICBodG1sLm5hbWUgPSAiZGl2IjsKICAgICAgICBodG1sLmNoaWxkcmVuID0gW107CiAgICAgICAgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0uc3BsaXQoIlx1MjAyOSIpLm1hcChwYXJhID0+IHBhcmEuc3BsaXQoL1tcdTIwMjhcbl0vKS5yZWR1Y2UoKGFjYywgbGluZSkgPT4gewogICAgICAgICAgYWNjLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIGFjYzsKICAgICAgICB9LCBbXSkpLmZvckVhY2gobGluZXMgPT4gewogICAgICAgICAgaHRtbC5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgbmFtZTogInAiLAogICAgICAgICAgICBjaGlsZHJlbjogbGluZXMKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKC9bXHUyMDI4XG5dLy50ZXN0KHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdKSkgewogICAgICAgIGh0bWwubmFtZSA9ICJkaXYiOwogICAgICAgIGh0bWwuY2hpbGRyZW4gPSBbXTsKICAgICAgICB0aGlzW194ZmFf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kW194ZmFfb2JqZWN0LiRkYXRhXVtfeGZhX29iamVjdC4kdWlkXSB8fCBmaWVsZFtfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGZpZWxkSWQ6IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgY2xhc3M6IFsieGZhVGV4dGZpZWxkIl0sCiAgICAgICAgICBzdHlsZSwKICAgICAgICAgICJhcmlhLWxhYmVsIjogYXJpYUxhYmVsKGZpZWxkKSwKICAgICAgICAgICJhcmlhLXJlcXVpcmVkIjogZmFsc2UKICAgICAgICB9CiAgICAgIH07CiAgICB9IGVsc2UgewogICAgICBodG1sID0gewogICAgICAgIG5hbWU6ICJpbnB1dCIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgdHlwZTogInRleHQiLAogICAgICAgICAgZGF0YUlkOiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV0gJiYgZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdW194ZmFfb2JqZWN0LiR1aWRdIHx8IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgZmllbGRJZDogZmllbGRbX3hmYV9vYmplY3QuJHVpZF0sCiAgICAgICAgICBjbGFzczogWyJ4ZmFUZXh0ZmllbGQiXSwKICAgICAgICAgIHN0eWxlLAogICAgICAgICAgImFyaWEtbGFiZWwiOiBhcmlhTGFiZWwoZmllbGQpLAogICAgICAgICAgImFyaWEtcmVxdWlyZWQiOiBmYWxzZQogICAgICAgIH0KICAgICAgfTsKICAgIH0KICAgIGlmIChpc1JlcXVpcmVkKGZpZWxkKSkgewogICAgICBodG1sLmF0dHJpYnV0ZXNbImFyaWEtcmVxdWlyZWQiXSA9IHRydWU7CiAgICAgIGh0bWwuYXR0cmlidXRlcy5yZXF1aXJlZCA9IHRydWU7CiAgICB9CiAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgIG5hbWU6ICJsYWJlbCIsCiAgIC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AgIHRoaXMucGljdHVyZSA9IG51bGw7CiAgICB0aGlzLmJhcmNvZGUgPSBudWxsOwogICAgdGhpcy5idXR0b24gPSBudWxsOwogICAgdGhpcy5jaGVja0J1dHRvbiA9IG51bGw7CiAgICB0aGlzLmNob2ljZUxpc3QgPSBudWxsOwogICAgdGhpcy5kYXRlVGltZUVkaXQgPSBudWxsOwogICAgdGhpcy5kZWZhdWx0VWkgPSBudWxsOwogICAgdGhpcy5pbWFnZUVkaXQgPSBudWxsOwogICAgdGhpcy5udW1lcmljRWRpdCA9IG51bGw7CiAgICB0aGlzLnBhc3N3b3JkRWRpdCA9IG51bGw7CiAgICB0aGlzLnNpZ25hdHVyZSA9IG51bGw7CiAgICB0aGlzLnRleHRFZGl0ID0gbnVsbDsKICB9CiAgW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oKSB7CiAgICBpZiAodGhpc1tfeGZhX29iamVjdC4kZXh0cmFdID09PSB1bmRlZmluZWQpIHsKICAgICAgZm9yIChjb25zdCBuYW1lIG9mIE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzKHRoaXMpKSB7CiAgICAgICAgaWYgKG5hbWUgPT09ICJleHRyYXMiIHx8IG5hbWUgPT09ICJwaWN0dXJlIikgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3hmYV9vYmplY3QuWEZBT2JqZWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXSA9IG9iajsKICAgICAgICByZXR1cm4gb2JqOwogICAgICB9CiAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXSA9IG51bGw7CiAgICB9CiAgICByZXR1cm4gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdOwogIH0KICBbX3hmYV9vYmplY3QuJHRvSFRNTF0oY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lKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0ZXh0XSgpIHsKICAgIGlmICh0aGlzLmV4RGF0YSkgewogICAgICBpZiAodHlwZW9mIHRoaXMuZXhEYXRhW194ZmFfb2JqZWN0LiRjb250ZW50XSA9PT0gInN0cmluZyIpIHsKICAgICAgICByZXR1cm4gdGhpcy5leERhdGFbX3hmYV9vYmplY3QuJGNvbnRlbnRdLnRyaW0oKTsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5leERhdGFbX3hmYV9vYmplY3QuJGNvbnRlbnRdW194ZmFfb2JqZWN0LiR0ZXh0XSgpLnRyaW0oKTsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImltYWdlIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3QpIHsKICAgICAgICByZXR1cm4gKG9ialtfeGZhX29iamVjdC4kY29udGVudF0gfHwgIiIpLnRvU3RyaW5nKCkudHJpbSgpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbnVsbDsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgY29uc3Qgb2JqID0gdGhpc1tuYW1lXTsKICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3hmYV9vYmplY3QuWEZBT2JqZWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHJldHVybiBvYmpbX3hmYV9vYmplY3QuJHRvSFRNTF0oYXZhaWxhYmxlU3BhY2UpOwogICAgfQogICAgcmV0dXJ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AicmwtdGIiOgogICAgICBpZiAoIWV4dHJhLmxpbmUgfHwgZXh0cmEuYXR0ZW1wdCA9PT0gMSkgewogICAgICAgIGV4dHJhLmxpbmUgPSBjcmVhdGVMaW5lKG5vZGUsIFtdKTsKICAgICAgICBleHRyYS5jaGlsZHJlbi5wdXNoKGV4dHJhLmxpbmUpOwogICAgICAgIGV4dHJhLm51bWJlckluTGluZSA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEubnVtYmVySW5MaW5lICs9IDE7CiAgICAgIGV4dHJhLmxpbmUuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgaWYgKGV4dHJhLmF0dGVtcHQgPT09IDApIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGV4dHJhLnByZXZIZWlnaHQgKyBoKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggPSB3OwogICAgICAgIGV4dHJhLnByZXZIZWlnaHQgPSBleHRyYS5oZWlnaHQ7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuYXR0ZW1wdCA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEud2lkdGggPSBNYXRoLm1heChleHRyYS53aWR0aCwgZXh0cmEuY3VycmVudFdpZHRoKTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJybC1yb3ciOgogICAgY2FzZSAicm93IjoKICAgICAgewogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgZXh0cmEud2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGgpOwogICAgICAgIGNvbnN0IGhlaWdodCA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKGV4dHJhLmhlaWdodCk7CiAgICAgICAgZm9yIChjb25zdCBjaGlsZCBvZiBleHRyYS5jaGlsZHJlbikgewogICAgICAgICAgY2hpbGQuYXR0cmlidXRlcy5zdHlsZS5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICBjYXNlICJ0YWJsZSI6CiAgICAgIHsKICAgICAgICBleHRyYS53aWR0aCA9IE1hdGgubWluKGF2YWlsYWJsZVNwYWNlLndpZHRoLCBNYXRoLm1heChleHRyYS53aWR0aCwgdykpOwogICAgICAgIGV4dHJhLmhlaWdodCArPSBoOwogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIGNhc2UgInRiIjoKICAgICAgewogICAgICAgIGV4dHJhLndpZHRoID0gTWF0aC5taW4oYXZhaWxhYmxlU3BhY2Uud2lkdGgsIE1hdGgubWF4KGV4dHJhLndpZHRoLCB3KSk7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgICBicmVhazsKICAgICAgfQogIH0KfQpmdW5jdGlvbiBnZXRBdmFpbGFibGVTcGFjZShub2RlKSB7CiAgY29uc3QgYXZhaWxhYmxlU3BhY2UgPSBub2RlW194ZmFfb2JqZWN0LiRleHRyYV0uYXZhaWxhYmxlU3BhY2U7CiAgY29uc3QgbWFyZ2luViA9IG5vZGUubWFyZ2luID8gbm9kZS5tYXJnaW4udG9wSW5zZXQgKyBub2RlLm1hcmdpbi5ib3R0b21JbnNldCA6IDA7CiAgY29uc3QgbWFyZ2luSCA9IG5vZGUubWFyZ2luID8gbm9kZS5tYXJnaW4ubGVmdEluc2V0ICsgbm9kZS5tYXJnaW4ucmlnaHRJbnNldCA6IDA7CiAgc3dpdGNoIChub2RlLmxheW91dCkgewogICAgY2FzZSAibHItdGIiOgogICAgY2FzZSAicmwtdGIiOgogICAgICBpZiAobm9kZV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ICAgY2FzZSAicG9zaXRpb24iOgogICAgZGVmYXVsdDoKICAgICAgcmV0dXJuIGF2YWlsYWJsZVNwYWNlOwogIH0KfQpmdW5jdGlvbiBnZXRUcmFuc2Zvcm1lZEJCb3gobm9kZSkgewogIGxldCB3ID0gbm9kZS53ID09PSAiIiA/IE5hTiA6IG5vZGUudzsKICBsZXQgaCA9IG5vZGUuaCA9PT0gIiIgPyBOYU4gOiBub2RlLmg7CiAgbGV0IFtjZW50ZXJYLCBjZW50ZXJZXSA9IFswLCAwXTsKICBzd2l0Y2ggKG5vZGUuYW5jaG9yVHlwZSB8fCAiIikgewogICAgY2FzZSAiYm90dG9tQ2VudGVyIjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3cgLyAyLCBoXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJib3R0b21MZWZ0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gWzAsIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgImJvdHRvbVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUNlbnRlciI6CiAgICAgIFtjZW50ZXJYLCBjZW50ZXJZXSA9IFt3IC8gMiwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUxlZnQiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbMCwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGggLyAyXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJ0b3BDZW50ZXIiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbdyAvIDIsIDBdOwogICAgICBicmVhazsKICAgIGNhc2UgInRvcFJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIDBdOwogICAgICBicmVhazsKICB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HQgfHwgMDsKICBjb25zdCBbLCB5LCB3LCBoXSA9IGdldFRyYW5zZm9ybWVkQkJveChub2RlKTsKICBzd2l0Y2ggKHBhcmVudC5sYXlvdXQpIHsKICAgIGNhc2UgImxyLXRiIjoKICAgIGNhc2UgInJsLXRiIjoKICAgICAgaWYgKGF0dGVtcHQgPT09IDApIHsKICAgICAgICBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgICAgaWYgKG5vZGUuaCAhPT0gIiIgJiYgTWF0aC5yb3VuZChoIC0gc3BhY2UuaGVpZ2h0KSA+IEVSUk9SKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChub2RlLncgIT09ICIiKSB7CiAgICAgICAgICAgIGlmIChNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocGFyZW50W194ZmFfb2JqZWN0LiRleHRyYV0ubnVtYmVySW5MaW5lID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHNwYWNlLmhlaWdodCA+IEVSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzcGFjZS53aWR0aCA+IEVSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAobm9kZS53ICE9PSAiIikgewogICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQodyAtIHNwYWNlLndpZHRoKSA8PSBFUlJPUjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHNwYWNlLndpZHRoID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKG5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9v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gICAgICByZXR1cm4gZmFsc2U7CiAgICAgIH0KICAgICAgcmV0dXJuIHNwYWNlLmhlaWdodCA+IEVSUk9SOwogICAgY2FzZSAicG9zaXRpb24iOgogICAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kZ2V0VGVtcGxhdGVSb290XSgpW194ZmFfb2JqZWN0LiRleHRyYV0ubm9MYXlvdXRGYWlsdXJlKSB7CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH0KICAgICAgaWYgKG5vZGUuaCA9PT0gIiIgfHwgTWF0aC5yb3VuZChoICsgeSAtIHNwYWNlLmhlaWdodCkgPD0gRVJST1IpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBjb25zdCBhcmVhID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0VGVtcGxhdGVSb290XSgpW194ZmFfb2JqZWN0LiRleHRyYV0uY3VycmVudENvbnRlbnRBcmVhOwogICAgICByZXR1cm4gaCArIHkgPiBhcmVhLmg7CiAgICBjYXNlICJybC1yb3ciOgogICAgY2FzZSAicm93IjoKICAgICAgaWYgKG5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChub2RlLmggIT09ICIiKSB7CiAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoaCAtIHNwYWNlLmhlaWdodCkgPD0gRVJST1I7CiAgICAgIH0KICAgICAgcmV0dXJuIHRydWU7CiAgICBkZWZhdWx0OgogICAgICByZXR1cm4gdHJ1ZTsKICB9Cn0KCi8qKiovIH0pLAovKiAyMTkgKi8KLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKInVzZSBzdHJpY3QiOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ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Zvcm0gKz0gYHJvdGF0ZSgtJHtub2RlLnJvdGF0ZX1kZWcpYDsKICAgICAgc3R5bGUudHJhbnNmb3JtT3JpZ2luID0gInRvcCBsZWZ0IjsKICAgIH0KICB9LAogIHByZXNlbmNlKG5vZGUsIHN0eWxlKSB7CiAgICBzd2l0Y2ggKG5vZGUucHJlc2VuY2UpIHsKICAgICAgY2FzZSAiaW52aXNpYmxlIjoKICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhpZGRlbiI6CiAgICAgIGNhc2UgImluYWN0aXZlIjoKICAgICAgICBzdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgICAgIGJyZWFrOwogICAgfQogIH0sCiAgaEFsaWduKG5vZGUsIHN0eWxlKSB7CiAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kbm9kZU5hbWVdID09PSAicGFyYSIpIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImp1c3RpZnlBbGwiOgogICAgICAgICAgc3R5bGUudGV4dEFsaWduID0gImp1c3RpZnktYWxsIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJhZGl4IjoKICAgICAgICAgIHN0eWxlLnRleHRBbGlnbiA9ICJsZWZ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBub2RlLmhBbGlnbjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgICAgc3R5bGUuYWxpZ25TZWxmID0gInN0YXJ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImNlbnRlciI6CiAgICAgICAgICBzdHlsZS5hbGlnblNlbGYgPSAiY2VudGVyIjsKICAgICAgICAgIGJyZWFrOwogICAg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GV0IHdpZHRoID0gbm9kZS53OwogICAgaWYgKHdpZHRoID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhXID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQudyAhPT0gIiIpIHsKICAgICAgICAgIHdpZHRoID0gMDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2lkdGggPSBub2RlLm1pblc7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIHdpZHRoID0gTWF0aC5taW4obm9kZS5tYXhXLCBhdmFpbGFibGVTcGFjZS53aWR0aCk7CiAgICAgIH0KICAgICAgaHRtbC5hdHRyaWJ1dGVzLnN0eWxlLndpZHRoID0gbWVhc3VyZVRvU3RyaW5nKHdpZHRoKTsKICAgIH0KICAgIGxldCBoZWlnaHQgPSBub2RlLmg7CiAgICBpZiAoaGVpZ2h0ID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhIID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQuaCAhPT0gIiIpIHsKICAgICAgICAgIGhlaWdodCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGhlaWdodCA9IG5vZGUubWluSDsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgaGVpZ2h0ID0gTWF0aC5taW4obm9kZS5tYXhILCBhdmFpbGFibGVTcGFjZS5oZWlnaHQpOwogICAgICB9CiAgICAgIGh0bWwuYXR0cmlidXRlcy5zdHlsZS5oZWlnaHQgPSBtZWFzdXJlVG9TdHJpbmcoaGVpZ2h0KTsKICAg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oYSwgeCkgPT4gYSArIHgsIDApOwogICAgfQogIH0KfQpmdW5jdGlvbiBsYXlvdXRDbGFzcyhub2RlKSB7CiAgc3dpdGNoIChub2RlLmxheW91dCkgewogICAgY2FzZSAicG9zaXRpb24iOgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICAgIGNhc2UgImxyLXRiIjoKICAgICAgcmV0dXJuICJ4ZmFMclRiIjsKICAgIGNhc2UgInJsLXJvdyI6CiAgICAgIHJldHVybiAieGZhUmxSb3ciOwogICAgY2FzZSAicmwtdGIiOgogICAgICByZXR1cm4gInhmYVJsVGIiOwogICAgY2FzZSAicm93IjoKICAgICAgcmV0dXJuICJ4ZmFSb3ciOwogICAgY2FzZSAidGFibGUiOgogICAgICByZXR1cm4gInhmYVRhYmxlIjsKICAgIGNhc2UgInRiIjoKICAgICAgcmV0dXJuICJ4ZmFUYiI7CiAgICBkZWZhdWx0OgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICB9Cn0KZnVuY3Rpb24gdG9TdHlsZShub2RlKSB7CiAgY29uc3Qgc3R5bGUgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIGZvciAodmFyIF9sZW4gPSBhcmd1bWVudHMubGVuZ3RoLCBuYW1lcyA9IG5ldyBBcnJheShfbGVuID4gMSA/IF9sZW4gLSAxIDogMCksIF9rZXkgPSAxOyBfa2V5IDwgX2xlbjsgX2tleSsrKSB7CiAgICBuYW1lc1tfa2V5IC0gMV0gPSBhcmd1bWVudHNbX2tleV07CiAgfQogIGZvciAoY29uc3QgbmFtZSBvZiBuYW1lcykgewogICAgY29uc3QgdmFsdWUgPSBub2RlW25hbWVdOwogICAgaWYgKHZhbHVlID09PSBudWxsKSB7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgaWYgKGNvbnZlcnRlcnMuaGFzT3duUHJvcGVydHkobmFtZSkpIHsKICAgICAgY29udmVydGVyc1tuYW1lXShub2RlLCBzdHlsZSk7CiAgICAgIGNvbnRpbnVlO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WM7CiAgICAgIH0KICAgIH0KICAgIGlmICghcmVhbGx5TWlzc2luZ0ZvbnRzIHx8IHJlYWxseU1pc3NpbmdGb250cy5zaXplID09PSAwKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGNvbnN0IG15cmlhZCA9IHRoaXMuZm9udHMuZ2V0KCJQZGZKUy1GYWxsYmFjay1QZGZKUy1YRkEiKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiByZWFsbHlNaXNzaW5nRm9udHMpIHsKICAgICAgdGhpcy5mb250cy5zZXQobWlzc2luZywgbXlyaWFkKTsKICAgIH0KICB9CiAgYWRkUGRmRm9udChwZGZGb250KSB7CiAgICBjb25zdCBjc3NGb250SW5mbyA9IHBkZkZvbnQuY3NzRm9udEluZm87CiAgICBjb25zdCBuYW1lID0gY3NzRm9udEluZm8uZm9udEZhbWlseTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoIWZvbnQpIHsKICAgICAgZm9udCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgIHRoaXMuZm9udHMuc2V0KG5hbWUsIGZvbnQpOwogICAgICBpZiAoIXRoaXMuZGVmYXVsdEZvbnQpIHsKICAgICAgICB0aGlzLmRlZmF1bHRGb250ID0gZm9udDsKICAgICAgfQogICAgfQogICAgbGV0IHByb3BlcnR5ID0gIiI7CiAgICBjb25zdCBmb250V2VpZ2h0ID0gcGFyc2VGbG9hdChjc3NGb250SW5mby5mb250V2VpZ2h0KTsKICAgIGlmIChwYXJzZUZsb2F0KGNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSAhPT0gMCkgewogICAgICBwcm9wZXJ0eSA9IGZvbnRXZWlnaHQgPj0gNzAwID8gImJvbGRpdGFsaWMiIDogIml0YWxpYyI7CiAgICB9IGVsc2UgaWYgKGZvbnRXZWlnaHQgPj0gNzAwKSB7CiAgICAgIHByb3BlcnR5ID0gImJvbGQiOwogICAgfQogICAgaWYgKCFwcm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dGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoZm9udCkgewogICAgICB0aGlzLmNhY2hlLnNldChmb250TmFtZSwgZm9udCk7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgbmFtZSA9IG5hbWUudG9Mb3dlckNhc2UoKTsKICAgIGNvbnN0IG1heWJlID0gW107CiAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgIGlmIChmYW1pbHkucmVwbGFjZUFsbChwYXR0ZXJuLCAiIikudG9Mb3dlckNhc2UoKS5zdGFydHNXaXRoKG5hbWUpKSB7CiAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgfQogICAgfQogICAgaWYgKG1heWJlLmxlbmd0aCA9PT0gMCkgewogICAgICBmb3IgKGNvbnN0IFssIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPT09IDApIHsKICAgICAgbmFtZSA9IG5hbWUucmVwbGFjZUFsbCgvcHNtdHxtdC9naSwgIiIpOwogICAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKGZhbWlseS5yZXBsYWNlQWxsKHBhdHRlcm4sICIiKS50b0xvd2VyQ2FzZSgpLnN0YXJ0c1dpdGgobmFtZSkpIHsKICAgICAgICAgIG1heWJlLnB1c2gocGRmRm9udCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiA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Z2h0OwogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICAgIGxhc3RTcGFjZVBvcyA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSAwOwogICAgICAgICAgaXNCcm9rZW4gPSB0cnVlOwogICAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSBjdXJyZW50TGluZVdpZHRoOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gaTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnRMaW5lV2lkdGggKyBnbHlwaFdpZHRoID4gbWF4V2lkdGgpIHsKICAgICAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQ7CiAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICBpZiAobGFzdFNwYWNlUG9zICE9PSAtMSkgewogICAgICAgICAgaSA9IGxhc3RTcGFjZVBvczsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGxhc3RTcGFjZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgICBsYXN0U3BhY2VXaWR0aCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGN1cnJlbnRMaW5lV2lkdGgpOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCA9IGdseXBoV2lkdGg7CiAgICAgICAgfQogICAgIC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hY2UgZGVmaW5pdGlvbiBpbiA8JHt0YWdOYW1lfT5gKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAobmFtZS5zdGFydHNXaXRoKCJ4bWxuczoiKSkgewogICAgICAgIGNvbnN0IHByZWZpeCA9IG5hbWUuc3Vic3RyaW5nKCJ4bWxuczoiLmxlbmd0aCk7CiAgICAgICAgaWYgKCFwcmVmaXhlcykgewogICAgICAgICAgcHJlZml4ZXMgPSBbXTsKICAgICAgICB9CiAgICAgICAgcHJlZml4ZXMucHVzaCh7CiAgICAgICAgICBwcmVmaXgsCiAgICAgICAgICB2YWx1ZQogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGkgPSBuYW1lLmluZGV4T2YoIjoiKTsKICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgIGF0dHJpYnV0ZU9ialtuYW1lXSA9IHZhbHVlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBsZXQgbnNBdHRycyA9IGF0dHJpYnV0ZU9ialtfeGZhX29iamVjdC4kbnNBdHRyaWJ1dGVzXTsKICAgICAgICAgIGlmICghbnNBdHRycykgewogICAgICAgICAgICBuc0F0dHJzID0gYXR0cmlidXRlT2JqW194ZmFfb2JqZWN0LiRuc0F0dHJpYnV0ZXNdID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IFtucywgYXR0ck5hbWVdID0gW25hbWUuc2xpY2UoMCwgaSksIG5hbWUuc2xpY2UoaSArIDEpXTsKICAgICAgICAgIGxldCBhdHRycyA9IG5zQXR0cnNbbnNdOwogICAgICAgICAgaWYgKCFhdHRycykgewogICAgICAgICAgICBhdHRycyA9IG5zQXR0cnNbbnNdID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgIH0KICAgICAgICAgIGF0dHJzW2F0dHJOYW1lXSA9IHZhbHVlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcm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2RlOwogIH0KICBpc05zQWdub3N0aWMoKSB7CiAgICByZXR1cm4gdGhpcy5fbnNBZ25vc3RpY0xldmVsID4gMDsKICB9CiAgX3NlYXJjaE5hbWVzcGFjZShuc05hbWUpIHsKICAgIGxldCBucyA9IHRoaXMuX25hbWVzcGFjZXMuZ2V0KG5zTmFtZSk7CiAgICBpZiAobnMpIHsKICAgICAgcmV0dXJuIG5zOwogICAgfQogICAgZm9yIChjb25zdCBbbmFtZSwgewogICAgICBjaGVjawogICAgfV0gb2YgT2JqZWN0LmVudHJpZXMoX25hbWVzcGFjZXMuTmFtZXNwYWNlSWRzKSkgewogICAgICBpZiAoY2hlY2sobnNOYW1lKSkgewogICAgICAgIG5zID0gX3NldHVwLk5hbWVzcGFjZVNldFVwW25hbWVdOwogICAgICAgIGlmIChucykgewogICAgICAgICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICAgICAgICByZXR1cm4gbnM7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBucyA9IG5ldyBfdW5rbm93bi5Vbmtub3duTmFtZXNwYWNlKCsrdGhpcy5fbmV4dE5zSWQpOwogICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICByZXR1cm4gbnM7CiAgfQogIF9hZGROYW1lc3BhY2VQcmVmaXgocHJlZml4ZXMpIHsKICAgIGZvciAoY29uc3QgewogICAgICBwcmVmaXgsCiAgICAgIHZhbHVlCiAgICB9IG9mIHByZWZpeGVzKSB7CiAgICAgIGNvbnN0IG5hbWVzcGFjZSA9IHRoaXMuX3NlYXJjaE5hbWVzcGFjZSh2YWx1ZSk7CiAgICAgIGxldCBwcmVmaXhTdGFjayA9IHRoaXMuX25hbWVzcGFjZVByZWZpeGVzLmdldChwcmVmaXgpOwogICAgICBpZiAoIXByZWZpeFN0YWNrKSB7CiAgICAgICAgcHJlZml4U3RhY2sgPSBbXTsKICAgICAgICB0aGlzLl9uYW1lc3BhY2VQcmVmaXhlcy5zZXQocHJlZml4LCBwcmVmaXhTdGFjayk7CiAgICAgIH0KICAgICAgcHJlZml4U3RhY2sucHVzaChuYW1lc3BhY2UpOwogICAgfQogIH0KICBfZ2V0TmFtZXNwYWNlVG9Vc2UocHJlZml4KSB7CiAgICBpZiAoIXByZWZpeCkgewogICAgICByZXR1cm4gdGhpcy5fY3VycmVudE5hbWVzcGFjZTsKICAgIH0KICAgIGNvbnN0IHByZWZpeFN0YWNrID0gdGhpcy5fbmFtZXNwYWNlUHJlZml4ZXMuZ2V0KHByZWZpeCk7CiAgICBpZiAocHJlZml4U3RhY2sgJiYgcHJlZml4U3RhY2subGVuZ3RoID4gMCkgewogICAgICByZXR1cm4gcHJlZml4U3RhY2suYXQoLTEpOwogICAgfQogICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG5hbWVzcGFjZSBwcmVmaXg6ICR7cHJlZml4fS5gKTsKICAgIHJldHVybiBudWxsOwogIH0KICBjbGVhbihkYXRhKSB7CiAgICBjb25zdCB7CiAgICAgIGhhc05hbWVzcGFjZSwKICAgICAgcHJlZml4ZXMsCiAgICAgIG5zQWdub3N0aWMKICAgIH0gPSBkYXRhOwogICAgaWYgKGhhc05hbWVzcGFjZSkgewogICAgICB0aGlzLl9jdXJyZW50TmFtZXNwYWNlID0gdGhpcy5fbmFtZXNwYWNlU3RhY2sucG9wKCk7CiAgICB9CiAgICBpZiAocHJlZml4ZXMpIHsKICAgICAgcHJlZml4ZXMuZm9yRWFjaChfcmVmMyA9PiB7CiAgICAgICAgbGV0IHsKICAgICAgICAgIHByZWZpeAogICAgICAgIH0gPSBfcmVmMzsKICAgICAgICB0aGlzLl9uYW1lc3BhY2VQcmVmaXhlcy5nZXQocHJlZml4KS5wb3AoKTsKICAgICAgfSk7CiAgICB9CiAgICBpZiAobnNBZ25vc3RpYykgewogICAgICB0aGlzLl9uc0Fnbm9zdGljTGV2ZWwtLTsKICAgIH0KICB9Cn0KZXhwb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ZmFGb250ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGNvbnN0IG1hcmdpbiA9IHsKICAgICAgdG9wOiBOYU4sCiAgICAgIGJvdHRvbTogTmFOLAogICAgICBsZWZ0OiBOYU4sCiAgICAgIHJpZ2h0OiBOYU4KICAgIH07CiAgICBsZXQgbGluZUhlaWdodCA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiB0aGlzLnN0eWxlLnNwbGl0KCI7IikubWFwKHMgPT4gcy5zcGxpdCgiOiIsIDIpKSkgewogICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgIGNhc2UgImZvbnQtZmFtaWx5IjoKICAgICAgICAgIHhmYUZvbnQudHlwZWZhY2UgPSAoMCwgX3V0aWxzLnN0cmlwUXVvdGVzKSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmb250LXNpemUiOgogICAgICAgICAgeGZhRm9udC5zaXplID0gKDAsIF91dGlscy5nZXRNZWFzdXJlbWVudCkodmFsdWUpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZm9udC13ZWlnaHQiOgogICAgICAgICAgeGZhRm9udC53ZWlnaHQgPSB2YWx1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZvbnQtc3R5bGUiOgogICAgICAgICAgeGZhRm9udC5wb3N0dXJlID0gdmFsdWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZXR0ZXItc3BhY2luZyI6CiAgICAgICAgICB4ZmFGb250LmxldHRlclNwYWNpbmcgPSAoMCwgX3V0aWxzLmdldE1lYXN1cmVtZW50KSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtYXJnaW4iOgogICAgICAgICAgY29uc3QgdmFsdWVzID0gdmFsdWUuc3BsaXQoLyBcdC8pLm1hcCh4ID0+ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHgpKTsKICAgICAgICAgIHN3aXRjaCAodmFsdWVzLmxlbmd0aCkgewogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IG1hcmdpbi5ib3R0b20gPSBtYXJnaW4ubGVmdCA9IG1hcmdpbi5yaWdodCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIG1hcmdpbi50b3AgPSBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzBdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4ubGVmdCA9IHZhbHVlc1sxXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5yaWdodCA9IHZhbHVlc1szXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm1hcmdpbi10b3AiOgogICAgICAgICAgbWFyZ2luLnRvcCA9ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHZhbHVlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm1hcmdpbi1ib3R0b20iOgogICAgICAgICAgbWFyZ2luLmJvdHRvbS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ocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBYUmVmIGJ5dGVXaWR0aHMgJ2dlbmVyYXRpb24nLiIpOwogICAgICAgICAgfQogICAgICAgICAgZ2VuZXJhdGlvbiA9IGdlbmVyYXRpb24gPDwgOCB8IGdlbmVyYXRpb25CeXRlOwogICAgICAgIH0KICAgICAgICBjb25zdCBlbnRyeSA9IHt9OwogICAgICAgIGVudHJ5Lm9mZnNldCA9IG9mZnNldDsKICAgICAgICBlbnRyeS5nZW4gPSBnZW5lcmF0aW9uOwogICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICBlbnRyeS5mcmVlID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgIGVudHJ5LnVuY29tcHJlc3NlZCA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgSW52YWxpZCBYUmVmIGVudHJ5IHR5cGU6ICR7dHlwZX1gKTsKICAgICAgICB9CiAgICAgICAgaWYgKCF0aGlzLmVudHJpZXNbZmlyc3QgKyBpXSkgewogICAgICAgICAgdGhpcy5lbnRyaWVzW2ZpcnN0ICsgaV0gPSBlbnRyeTsKICAgICAgICB9CiAgICAgIH0KICAgICAgc3RyZWFtU3RhdGUuZW50cnlOdW0gPSAwOwogICAgICBzdHJlYW1TdGF0ZS5zdHJlYW1Qb3MgPSBzdHJlYW0ucG9zOwogICAgICBlbnRyeVJhbmdlcy5zcGxpY2UoMCwgMik7CiAgICB9CiAgfQogIGluZGV4T2JqZWN0cygpIHsKICAgIGNvbnN0IFRBQiA9IDB4OSwKICAgICAgTEYgPSAweGEsCiAgICAgIENSID0gMHhkLAogICAgICBTUEFDRSA9IDB4MjA7CiAgICBjb25zdCBQRVJDRU5UID0gMHgyNSwKICAgICAgTFQgPSAweDNjOwogICAgZnVuY3Rpb24gcmVhZFRva2VuKGRhdGEsIG9mZnNldCkgewogICAgICBsZXQgdG9rZW4gPSAiIiwKICAgICAgICBjaCA9IGRhdGFbb2Zmc2V0XTsKICAgICAgd2hpbGUgKGNoICE9PSBMRiAmJiBjaCAhPT0gQ1IgJiYgY2ggIT09IExUKSB7CiAgICAgICAgaWYgKCsrb2Zmc2V0ID49IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdG9rZW4gKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICAgICAgY2ggPSBkYXRhW29mZnNldF07CiAgICAgIH0KICAgICAgcmV0dXJuIHRva2VuOwogICAgfQogICAgZnVuY3Rpb24gc2tpcFVudGlsKGRhdGEsIG9mZnNldCwgd2hhdCkgewogICAgICBjb25zdCBsZW5ndGggPSB3aGF0Lmxlbmd0aCwKICAgICAgICBkYXRhTGVuZ3RoID0gZGF0YS5sZW5ndGg7CiAgICAgIGxldCBza2lwcGVkID0gMDsKICAgICAgd2hpbGUgKG9mZnNldCA8IGRhdGFMZW5ndGgpIHsKICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgd2hpbGUgKGkgPCBsZW5ndGggJiYgZGF0YVtvZmZzZXQgKyBpXSA9PT0gd2hhdFtpXSkgewogICAgICAgICAgKytpOwogICAgICAgIH0KICAgICAgICBpZiAoaSA+PSBsZW5ndGgpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBvZmZzZXQrKzsKICAgICAgICBza2lwcGVkKys7CiAgICAgIH0KICAgICAgcmV0dXJuIHNraXBwZWQ7CiAgICB9CiAgICBjb25zdCBnRW5kb2JqUmVnRXhwID0gL1xiKGVuZG9ianxcZCtccytcZCtccytvYmp8eHJlZnx0cmFpbGVyKVxiL2c7CiAgICBjb25zdCBnU3Rhc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pZiAoY2ggPT09IFBFUkNFTlQpIHsKICAgICAgICBkbyB7CiAgICAgICAgICArK3Bvc2l0aW9uOwogICAgICAgICAgaWYgKHBvc2l0aW9uID49IGxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNoID0gYnVmZmVyW3Bvc2l0aW9uXTsKICAgICAgICB9IHdoaWxlIChjaCAhPT0gTEYgJiYgY2ggIT09IENSKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0b2tlbiA9IHJlYWRUb2tlbihidWZmZXIsIHBvc2l0aW9uKTsKICAgICAgbGV0IG07CiAgICAgIGlmICh0b2tlbi5zdGFydHNXaXRoKCJ4cmVmIikgJiYgKHRva2VuLmxlbmd0aCA9PT0gNCB8fCAvXHMvLnRlc3QodG9rZW5bNF0pKSkgewogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCB0cmFpbGVyQnl0ZXMpOwogICAgICAgIHRyYWlsZXJzLnB1c2gocG9zaXRpb24pOwogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCBzdGFydHhyZWZCeXRlcyk7CiAgICAgIH0gZWxzZSBpZiAobSA9IG9ialJlZ0V4cC5leGVjKHRva2VuKSkgewogICAgICAgIGNvbnN0IG51bSA9IG1bMV0gfCAwLAogICAgICAgICAgZ2VuID0gbVsyXSB8IDA7CiAgICAgICAgY29uc3Qgc3RhcnRQb3MgPSBwb3NpdGlvbiArIHRva2VuLmxlbmd0aDsKICAgICAgICBsZXQgY29udGVudExlbmd0aCwKICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSBmYWxzZTsKICAgICAgICBpZiAoIXRoaXMuZW50cmllc1tudW1dKSB7CiAgICAgICAgICB1cGRhdGVFbnRyaWVzID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKHRoaXMuZW50cmllc1tudW1dLmdlbiA9PT0gZ2VuKSB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBwYXJzZXIgPSBuZXcgX3BhcnNlci5QYXJzZXIoewogICAgICAgICAgICAgIGxleGVyOiBuZXcgX3BhcnNlci5MZXhlcihzdHJlYW0ubWFrZVN1YlN0cmVhbShzdGFydFBvcykpCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBwYXJzZXIuZ2V0T2JqKCk7CiAgICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSB0cnVlOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBpbmRleE9iamVjdHMgLS0gY2hlY2tpbmcgb2JqZWN0ICgke3Rva2VufSk6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdXBkYXRlRW50cmllcyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVwZGF0ZUVudHJpZXMpIHsKICAgICAgICAgIHRoaXMuZW50cmllc1tudW1dID0gewogICAgICAgICAgICBvZmZzZXQ6IHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0LAogICAgICAgICAgICBnZW4sCiAgICAgICAgICAgIHVuY29tcHJlc3NlZDogdHJ1ZQogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggPSBzdGFydFBvczsKICAgICAgICBjb25zdCBtYXRjaCA9IGdFbmRvYmpSZWdFeHAuZXhlYyhidWZmZXJTdHIpOwogICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgY29uc3QgZW5kUG9zID0gZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggKyAxOwogICAgICAgICAgY29udGVudExlbmd0aCA9IGVuZFBvcyAtIHBvc2l0aW9uOwogICAgICAgICAgaWYgKG1hdGNoWzFdICE9PSAiZW5kb2JqIikgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGluZGV4T2JqZWN0czogRm91bmQgIiR7bWF0Y2hbMV19IiBpbnNpZGUgb2YgYW5vdGhlciAib2JqIiwgYCArICdjYXVzZWQgYnkgbWlzc2luZyAiZW5kb2JqIiAtLSB0cnlpbmcgdG8gcmVjb3Zlci4nKTsKICAgICAgICAgICAgY29udGVudExlbmd0aCAtPSBtYXRjaFsxXS5sZW5ndGggKyAxOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250ZW50TGVuZ3RoID0gbGVuZ3RoIC0gcG9zaXRpb247CiAgICAgICAgfQogICAgICAgIGNvbnN0IGNvbnRlbnQgPSBidWZmZXIuc3ViYXJyYXkocG9zaXRpb24sIHBvc2l0aW9uICsgY29udGVudExlbmd0aCk7CiAgICAgICAgY29uc3QgeHJlZlRhZ09mZnNldCA9IHNraXBVbnRpbChjb250ZW50LCAwLCB4cmVmQnl0ZXMpOwogICAgICAgIGlmICh4cmVmVGFnT2Zmc2V0IDwgY29udGVudExlbmd0aCAmJiBjb250ZW50W3hyZWZUYWdPZmZzZXQgKyA1XSA8IDY0KSB7CiAgICAgICAgICB4cmVmU3Rtcy5wdXNoKHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0KTsKICAgICAgICAgIHRoaXMuX3hyZWZTdG1zLmFkZChwb3NpdGlvbiAtIHN0cmVhbS5zdGFydCk7CiAgICAgICAgfQogICAgICAgIHBvc2l0aW9uICs9IGNvbnRlbnRMZW5ndGg7CiAgICAgIH0gZWxzZSBpZiAodG9rZW4uc3RhcnRzV2l0aCgidHJhaWxlciIpICYmICh0b2tlbi5sZW5ndGggPT09IDcgfHwgL1xzLy50ZXN0KHRva2VuWzddKSkpIHsKICAgICAgICB0cmFpbGVycy5wdXNoKHBvc2l0aW9uKTsKICAgICAg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ID0gdHJ1ZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdmFsaWRQYWdlc0RpY3QgPSBmYWxzZTsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCByb290RGljdCA9IGRpY3QuZ2V0KCJSb290Iik7CiAgICAgICAgaWYgKCEocm9vdERpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzRGljdCA9IHJvb3REaWN0LmdldCgiUGFnZXMiKTsKICAgICAgICBpZiAoIShwYWdlc0RpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzQ291bnQgPSBwYWdlc0RpY3QuZ2V0KCJDb3VudCIpOwogICAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKHBhZ2VzQ291bnQpKSB7CiAgICAgICAgICB2YWxpZFBhZ2VzRGljdCA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRyYWlsZXJFcnJvciA9IGV4OwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWxpZFBhZ2VzRGljdCAmJiAoIWlzRW5jcnlwdGVkIHx8IGRpY3QuaGFzKCJFbmNyeXB0IikpICYmIGRpY3QuaGFzKCJJRCIpKSB7CiAgICAgICAgcmV0dXJuIGRpY3Q7CiAgICAgIH0KICAgICAgdHJhaWxlckRpY3QgPSBkaWN0OwogICAgfQogICAgaWYgKHRyYWlsZXJEaWN0KSB7CiAgICAgIHJldHVybiB0cmFpbGVyRGljdDsKICAgIH0KICAgIGlmICh0aGlzLnRvcERpY3QpIHsKICAgICAgcmV0dXJuIHRoaXMudG9wRGljdDsKICAgIH0KICAgIHRocm93IG5ldyBfdXRpbC5JbnZhbGlkUERGRXhjZXB0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kaWN0OwogICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgInhyZWYiKSkgewogICAgICAgICAgZGljdCA9IHRoaXMucHJvY2Vzc1hSZWZUYWJsZShwYXJzZXIpOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGRpY3QuZ2V0KCJYUmVmU3RtIik7CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihvYmopICYmICF0aGlzLl94cmVmU3Rtcy5oYXMob2JqKSkgewogICAgICAgICAgICB0aGlzLl94cmVmU3Rtcy5hZGQob2JqKTsKICAgICAgICAgICAgdGhpcy5zdGFydFhSZWZRdWV1ZS5wdXNoKG9iaik7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChOdW1iZXIuaXNJbnRlZ2VyKG9iaikpIHsKICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihwYXJzZXIuZ2V0T2JqKCkpIHx8ICEoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKHBhcnNlci5nZXRPYmooKSwgIm9iaiIpIHx8ICEoKG9iaiA9IHBhcnNlci5nZXRPYmooKSkgaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJJbnZhbGlkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgICBkaWN0ID0gdGhpcy5wcm9jZXNzWFJlZlN0cmVhbShvYmopOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghZGljdCkgewogICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RX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IGRhdGEuc291cmNlTmFtZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShhY3Rpb24oZGF0YS5kYXRhKSk7CiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lOiBjYlNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgIGRhdGE6IHJlc3VsdAogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lOiBjYlRhcmdldE5hbWUsCiAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgIGNhbGxiYWNrSWQ6IGRhdGEuY2FsbGJhY2tJZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBpZiAoZGF0YS5zdHJlYW1JZCkgewogICAgICAgIHRoaXMuX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGFjdGlvbihkYXRhLmRhdGEpOwogICAgfTsKICAgIGNvbU9iai5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UpOw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AgICAgICAgdGhpcy5zaW5rQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgfQogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICBjaHVuawogICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgIH0sCiAgICAgIGNsb3NlKCkgewogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMuaXNDYW5jZWxsZWQgPSB0cnVlOwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DTE9TRSwKICAgICAgICAgIHN0cmVhbUlkCiAgICAgICAgfSk7CiAgICAgICAgZGVsZXRlIHNlbGYuc3RyZWFtU2lua3Nbc3RyZWFtSWRdOwogICAgICB9LAogICAgICBlcnJvcihyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImVycm9yIG11c3QgaGF2ZSBhIHZhbGlkIHJlYXNvbiIpOwogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMuaXNDYW5jZWxsZWQgPSB0cnVlOwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICB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cFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgIH0KICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLlBVTEw6CiAgICAgICAgaWYgKCFzdHJlYW1TaW5rKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgIHN1Y2Nlc3M6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgIH0KICAgICAgICBzdHJlYW1TaW5rLmRlc2lyZWRTaXplID0gZGF0YS5kZXNpcmVkU2l6ZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uUHVsbCAmJiBzdHJlYW1TaW5rLm9uUHVsbCgpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgU3RyZWFtS2luZC5FTlFVRVVFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlbnF1ZXVlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNvbnRyb2xsZXIuZW5xdWV1ZShkYXRhLmNodW5rKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLkNMT1NFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJjbG9zZSBzaG91bGQgaGF2ZSBzdHJlYW0gY29udHJvbGxlciIpOwogICAgICAgIGlmIChzdHJlYW1Db250cm9sbGVyLmlzQ2xvc2VkKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgc3RyZWFtQ29udHJvbGxlci5pc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jb250cm9sbGVyLmNsb3NlKCk7CiAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgU3RyZWFtS2luZC5FUlJPUjoKICAgIC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BvZiB0aGUgbW9kdWxlCi8qKioqKiovIAkJcmV0dXJuIG1vZHVsZS5leHBvcnRzOwovKioqKioqLyAJfQovKioqKioqLyAJCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qKioqKiovIAkvKiB3ZWJwYWNrL3J1bnRpbWUvZGVmaW5lIHByb3BlcnR5IGdldHRlcnMgKi8KLyoqKioqKi8gCSgoKSA9PiB7Ci8qKioqKiovIAkJLy8gZGVmaW5lIGdldHRlciBmdW5jdGlvbnMgZm9yIGhhcm1vbnkgZXhwb3J0cwovKioqKioqLyAJCV9fd19wZGZqc19yZXF1aXJlX18uZCA9IChleHBvcnRzLCBkZWZpbml0aW9uKSA9PiB7Ci8qKioqKiovIAkJCWZvcih2YXIga2V5IGluIGRlZmluaXRpb24pIHsKLyoqKioqKi8gCQkJCWlmKF9fd19wZGZqc19yZXF1aXJlX18ubyhkZWZpbml0aW9uLCBrZXkpICYmICFfX3dfcGRmanNfcmVxdWlyZV9fLm8oZXhwb3J0cywga2V5KSkgewovKioqKioqLyAJCQkJCU9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCBrZXksIHsgZW51bWVyYWJsZTogdHJ1ZSwgZ2V0OiBkZWZpbml0aW9uW2tleV0gfSk7Ci8qKioqKiovIAkJCQl9Ci8qKioqKiovIAkJCX0KLyoqKioqKi8gCQl9OwovKioqKioqLyAJfSkoKTsKLyoqKioqKi8gCQovKioqKioqLyAJLyogd2VicGFjay9ydW50aW1lL2hhc093blByb3BlcnR5IHNob3J0aGFuZCAqLwovKioqKioqLyAJKCgpID0+IHsKLyoqKioqKi8gCQlfX3dfcGRmanNfcmVxdWlyZV9fLm8gPSAob2JqLCBwcm9wKSA9PiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKG9iaiwgcHJvcCkpCi8qKioqKiovIAl9KSgpOwovKioqKioqLy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KHsKICBlbnVtZXJhYmxlOiB0cnVlLAogIGdldDogZnVuY3Rpb24gKCkgewogICAgcmV0dXJuIF93b3JrZXIuV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgfQp9KSk7CnZhciBfd29ya2VyID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwpjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7Cn0pKCk7CgovKioqKioqLyAJcmV0dXJuIF9fd2VicGFja19leHBvcnRzX187Ci8qKioqKiovIH0pKCkKOwp9KTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cGRmLndvcmtlci5qcy5tYXA=",y=`data:text/javascript;base64,${N}`,o=`data:text/javascript;base64,${s}`;class h{constructor(g,I){G(this,"pdfDoc"),G(this,"pageNumber"),G(this,"total"),G(this,"dom"),G(this,"pdf"),G(this,"getPdfPage",C=>new Promise((Z,i)=>{this.pdfDoc?this.pdfDoc.getPage(C).then(b=>{const l=b.getViewport(),d=document.createElement("canvas");this.dom.appendChild(d);const V=d.getContext("2d"),m=document.body.clientWidth-20,[K,J,c,W]=l.viewBox,B=c>m?m/c:1;d.width=c,d.height=W,l.width=c,l.height=W,d.style.width=Math.floor(l.width)*B+"px",d.style.height=Math.floor(l.height)*B+"px";const X={canvasContext:V,viewport:l,transform:[1,0,0,-1,0,l.height]};b.render(X),Z({success:!0,data:b})}):i({success:!1,data:null,message:"pdfDoc is undefined"})})),G(this,"pdfPreview",()=>{Y(y).then(()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=o,window.pdfjsLib.getDocument(this.pdf).promise.then(async C=>{this.pdfDoc=C,this.total=C.numPages;for(let Z=1;Z<=this.total;Z++)await this.getPdfPage(Z)})})}),G(this,"prevPage",()=>{this.pageNumber>1?this.pageNumber-=1:this.pageNumber=1,this.getPdfPage(this.pageNumber)}),G(this,"nextPage",()=>{this.pageNumbernew Promise((g,I)=>{const C=new FileReader;C.readAsDataURL(A),C.onload=()=>{g(C.result)},C.onerror=Z=>{I(Z)},C.onabort=Z=>{I(Z)}}),p=async(A,g)=>{try{if(typeof window<"u"){const I=await H(A);I&&new h(I,g).pdfPreview()}}catch(I){console.log("renderPdf",I)}};export{p as renderPdf}; diff --git a/assets/index.md.1171a754.lean.js b/assets/index.md.0769705f.js similarity index 95% rename from assets/index.md.1171a754.lean.js rename to assets/index.md.0769705f.js index 210c79391..1b0eea8df 100644 --- a/assets/index.md.1171a754.lean.js +++ b/assets/index.md.0769705f.js @@ -1 +1 @@ -import{_ as t,o as e,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"brand","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每当遇到问题或者可以改进的事情的时候,会把想法先写下来,如果这是你遇到的问题,那么很可能有一群人也遇到同样的困难。"},{"icon":"🖖","title":"解决","details":"过一段时间后,再回来看看这些问题是否还有意义。然后再研究这个问题,确定是否存在解决方案。"},{"icon":"🛠️","title":"改进","details":"通常会发现一个工具是为了解决一个问题,我会去考虑如何改进或者简化这个工具。创造一个更好的轮子。"}]},"headers":[],"relativePath":"index.md","lastUpdated":1694741410000}'),i={name:"index.md"};function o(s,n,r,c,l,h){return e(),a("div")}const p=t(i,[["render",o]]);export{m as __pageData,p as default}; +import{_ as t,o as e,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"brand","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每当遇到问题或者可以改进的事情的时候,会把想法先写下来,如果这是你遇到的问题,那么很可能有一群人也遇到同样的困难。"},{"icon":"🖖","title":"解决","details":"过一段时间后,再回来看看这些问题是否还有意义。然后再研究这个问题,确定是否存在解决方案。"},{"icon":"🛠️","title":"改进","details":"通常会发现一个工具是为了解决一个问题,我会去考虑如何改进或者简化这个工具。创造一个更好的轮子。"}]},"headers":[],"relativePath":"index.md","lastUpdated":1695392177000}'),i={name:"index.md"};function o(s,n,r,c,l,h){return e(),a("div")}const p=t(i,[["render",o]]);export{m as __pageData,p as default}; diff --git a/assets/index.md.1171a754.js b/assets/index.md.0769705f.lean.js similarity index 95% rename from assets/index.md.1171a754.js rename to assets/index.md.0769705f.lean.js index 210c79391..1b0eea8df 100644 --- a/assets/index.md.1171a754.js +++ b/assets/index.md.0769705f.lean.js @@ -1 +1 @@ -import{_ as t,o as e,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"brand","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每当遇到问题或者可以改进的事情的时候,会把想法先写下来,如果这是你遇到的问题,那么很可能有一群人也遇到同样的困难。"},{"icon":"🖖","title":"解决","details":"过一段时间后,再回来看看这些问题是否还有意义。然后再研究这个问题,确定是否存在解决方案。"},{"icon":"🛠️","title":"改进","details":"通常会发现一个工具是为了解决一个问题,我会去考虑如何改进或者简化这个工具。创造一个更好的轮子。"}]},"headers":[],"relativePath":"index.md","lastUpdated":1694741410000}'),i={name:"index.md"};function o(s,n,r,c,l,h){return e(),a("div")}const p=t(i,[["render",o]]);export{m as __pageData,p as default}; +import{_ as t,o as e,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"brand","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每当遇到问题或者可以改进的事情的时候,会把想法先写下来,如果这是你遇到的问题,那么很可能有一群人也遇到同样的困难。"},{"icon":"🖖","title":"解决","details":"过一段时间后,再回来看看这些问题是否还有意义。然后再研究这个问题,确定是否存在解决方案。"},{"icon":"🛠️","title":"改进","details":"通常会发现一个工具是为了解决一个问题,我会去考虑如何改进或者简化这个工具。创造一个更好的轮子。"}]},"headers":[],"relativePath":"index.md","lastUpdated":1695392177000}'),i={name:"index.md"};function o(s,n,r,c,l,h){return e(),a("div")}const p=t(i,[["render",o]]);export{m as __pageData,p as default}; diff --git a/assets/src_article_astParse_tokenizer.md.4a99ed19.js b/assets/src_article_astParse_tokenizer.md.191befd6.js similarity index 99% rename from assets/src_article_astParse_tokenizer.md.4a99ed19.js rename to assets/src_article_astParse_tokenizer.md.191befd6.js index 3d84825d1..7df5e70c4 100644 --- a/assets/src_article_astParse_tokenizer.md.4a99ed19.js +++ b/assets/src_article_astParse_tokenizer.md.191befd6.js @@ -1,4 +1,4 @@ -import{_ as a,o as n,c as l,N as o}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/Literal.4f8173cf.jpeg",e="/ran/assets/Identifier.91b58315.jpeg",t="/ran/assets/Statement.98dca542.jpeg",c="/ran/assets/Declaration.1f7b4e23.jpeg",r="/ran/assets/Expression.d8010e56.jpeg",D="/ran/assets/ExpressionStatement.15a42b4e.jpeg",y="/ran/assets/Class.614486e5.jpeg",F="/ran/assets/import.32c7331a.jpeg",B="/ran/assets/export.84f41d4d.jpeg",i="/ran/assets/Program.e2066113.jpeg",d="/ran/assets/File.9a43a095.jpeg",E="/ran/assets/axtexplorer.2ebc951a.jpeg",A="/ran/assets/axtexplorerSave.21965993.jpeg",s="/ran/assets/Comment.4c895119.jpeg",C="/ran/assets/extra.ff9e7b7d.jpeg",v=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/astParse/tokenizer.md","lastUpdated":1694741410000}'),u={name:"src/article/astParse/tokenizer.md"},h=o('

Abstract Syntax Tree

一.(abstract syntax tree)抽象语法树的作用

源码是一串按照语法格式来组织的字符串,人能够认识,但是计算机并不认识,想让计算机认识就要转成一种数据结构,通过不同的对象来保存不同的数据,并且按照依赖关系组织起来,这种数据结构就是抽象语法树(abstract syntax tree)。

之所以叫“抽象”语法树是因为数据结构中省略掉了一些无具体意义的分隔符比如 ; { } 等。

有了 AST,计算机就能理解源码字符串的意思,而理解是能够转换的前提,所以编译的第一步需要把源码 parseAST

转成 AST 之后就可以通过修改 AST ,分析 AST 的方式来修改和分析代码,比如 babel 就通过这种方式进行代码的转换,比如 rollupTree Shaking ,就是通过分析 AST的 导入导出语法,从而分析出没有使用的代码,进行去除。

二.常见的 AST 节点

常见的 AST 节点 AST 是对源码的抽象,字面量、标识符、表达式、语句、模块语法、class 语法都有各自的 AST。

我们分别来了解一下:

Literal

Literal 是字面量的意思,比如 let name = 'value'中,'value'就是一个字符串字面量 StringLiteral,相应的还有数字字面量 NumericLiteral,布尔字面量 BooleanLiteral,字符串字面量 StringLiteral,正则表达式字面量 RegExpLiteral 等。

下面这些字面量都有对应的 Literal 节点:

代码中的字面量很多,babel 就是通过 xxLiteral 来抽象这部分内容的。

Identifier

Identifer 是标识符的意思,变量名、属性名、参数名等各种声明和引用的名字,都是Identifer

我们知道, JS 中的标识符只能包含字母或数字或下划线 (“_”) 或美元符号 (“$”) ,且不能以数字开头。这是 Identifier 的词法特点。

尝试分析一下,下面这一段代码里面有多少 Identifier 呢?

js
const name = 'value'
+import{_ as a,o as n,c as l,N as o}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/Literal.4f8173cf.jpeg",e="/ran/assets/Identifier.91b58315.jpeg",t="/ran/assets/Statement.98dca542.jpeg",c="/ran/assets/Declaration.1f7b4e23.jpeg",r="/ran/assets/Expression.d8010e56.jpeg",D="/ran/assets/ExpressionStatement.15a42b4e.jpeg",y="/ran/assets/Class.614486e5.jpeg",F="/ran/assets/import.32c7331a.jpeg",B="/ran/assets/export.84f41d4d.jpeg",i="/ran/assets/Program.e2066113.jpeg",d="/ran/assets/File.9a43a095.jpeg",E="/ran/assets/axtexplorer.2ebc951a.jpeg",A="/ran/assets/axtexplorerSave.21965993.jpeg",s="/ran/assets/Comment.4c895119.jpeg",C="/ran/assets/extra.ff9e7b7d.jpeg",v=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/astParse/tokenizer.md","lastUpdated":1695392177000}'),u={name:"src/article/astParse/tokenizer.md"},h=o('

Abstract Syntax Tree

一.(abstract syntax tree)抽象语法树的作用

源码是一串按照语法格式来组织的字符串,人能够认识,但是计算机并不认识,想让计算机认识就要转成一种数据结构,通过不同的对象来保存不同的数据,并且按照依赖关系组织起来,这种数据结构就是抽象语法树(abstract syntax tree)。

之所以叫“抽象”语法树是因为数据结构中省略掉了一些无具体意义的分隔符比如 ; { } 等。

有了 AST,计算机就能理解源码字符串的意思,而理解是能够转换的前提,所以编译的第一步需要把源码 parseAST

转成 AST 之后就可以通过修改 AST ,分析 AST 的方式来修改和分析代码,比如 babel 就通过这种方式进行代码的转换,比如 rollupTree Shaking ,就是通过分析 AST的 导入导出语法,从而分析出没有使用的代码,进行去除。

二.常见的 AST 节点

常见的 AST 节点 AST 是对源码的抽象,字面量、标识符、表达式、语句、模块语法、class 语法都有各自的 AST。

我们分别来了解一下:

Literal

Literal 是字面量的意思,比如 let name = 'value'中,'value'就是一个字符串字面量 StringLiteral,相应的还有数字字面量 NumericLiteral,布尔字面量 BooleanLiteral,字符串字面量 StringLiteral,正则表达式字面量 RegExpLiteral 等。

下面这些字面量都有对应的 Literal 节点:

代码中的字面量很多,babel 就是通过 xxLiteral 来抽象这部分内容的。

Identifier

Identifer 是标识符的意思,变量名、属性名、参数名等各种声明和引用的名字,都是Identifer

我们知道, JS 中的标识符只能包含字母或数字或下划线 (“_”) 或美元符号 (“$”) ,且不能以数字开头。这是 Identifier 的词法特点。

尝试分析一下,下面这一段代码里面有多少 Identifier 呢?

js
const name = 'value'
 
 function say(name) {
   console.log(name)
@@ -113,7 +113,7 @@ import{_ as a,o as n,c as l,N as o}from"./chunks/framework.6fe2e870.js";const p=
 // 单字符到 Token 生成器的映射
 const KNOWN_SINGLE_CHAR_TOKENS = new Map<
   SingleCharTokens,
-  typeof TOKENS_GENERATOR[keyof typeof TOKENS_GENERATOR]
+  (typeof TOKENS_GENERATOR)[keyof typeof TOKENS_GENERATOR]
 >([
   ['(', TOKENS_GENERATOR.leftParen],
   [')', TOKENS_GENERATOR.rightParen],
diff --git a/assets/src_article_astParse_tokenizer.md.4a99ed19.lean.js b/assets/src_article_astParse_tokenizer.md.191befd6.lean.js
similarity index 93%
rename from assets/src_article_astParse_tokenizer.md.4a99ed19.lean.js
rename to assets/src_article_astParse_tokenizer.md.191befd6.lean.js
index 5b92e7cce..a9f5e039f 100644
--- a/assets/src_article_astParse_tokenizer.md.4a99ed19.lean.js
+++ b/assets/src_article_astParse_tokenizer.md.191befd6.lean.js
@@ -1 +1 @@
-import{_ as a,o as n,c as l,N as o}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/Literal.4f8173cf.jpeg",e="/ran/assets/Identifier.91b58315.jpeg",t="/ran/assets/Statement.98dca542.jpeg",c="/ran/assets/Declaration.1f7b4e23.jpeg",r="/ran/assets/Expression.d8010e56.jpeg",D="/ran/assets/ExpressionStatement.15a42b4e.jpeg",y="/ran/assets/Class.614486e5.jpeg",F="/ran/assets/import.32c7331a.jpeg",B="/ran/assets/export.84f41d4d.jpeg",i="/ran/assets/Program.e2066113.jpeg",d="/ran/assets/File.9a43a095.jpeg",E="/ran/assets/axtexplorer.2ebc951a.jpeg",A="/ran/assets/axtexplorerSave.21965993.jpeg",s="/ran/assets/Comment.4c895119.jpeg",C="/ran/assets/extra.ff9e7b7d.jpeg",v=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/astParse/tokenizer.md","lastUpdated":1694741410000}'),u={name:"src/article/astParse/tokenizer.md"},h=o("",150),f=[h];function m(g,b,T,k,x,_){return n(),l("div",null,f)}const j=a(u,[["render",m]]);export{v as __pageData,j as default};
+import{_ as a,o as n,c as l,N as o}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/Literal.4f8173cf.jpeg",e="/ran/assets/Identifier.91b58315.jpeg",t="/ran/assets/Statement.98dca542.jpeg",c="/ran/assets/Declaration.1f7b4e23.jpeg",r="/ran/assets/Expression.d8010e56.jpeg",D="/ran/assets/ExpressionStatement.15a42b4e.jpeg",y="/ran/assets/Class.614486e5.jpeg",F="/ran/assets/import.32c7331a.jpeg",B="/ran/assets/export.84f41d4d.jpeg",i="/ran/assets/Program.e2066113.jpeg",d="/ran/assets/File.9a43a095.jpeg",E="/ran/assets/axtexplorer.2ebc951a.jpeg",A="/ran/assets/axtexplorerSave.21965993.jpeg",s="/ran/assets/Comment.4c895119.jpeg",C="/ran/assets/extra.ff9e7b7d.jpeg",v=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/astParse/tokenizer.md","lastUpdated":1695392177000}'),u={name:"src/article/astParse/tokenizer.md"},h=o("",150),f=[h];function m(g,b,T,k,x,_){return n(),l("div",null,f)}const j=a(u,[["render",m]]);export{v as __pageData,j as default};
diff --git a/assets/src_article_babel.md.fa7e2aa7.js b/assets/src_article_babel.md.ec7666af.js
similarity index 95%
rename from assets/src_article_babel.md.fa7e2aa7.js
rename to assets/src_article_babel.md.ec7666af.js
index 8cf628ffc..5d65d1818 100644
--- a/assets/src_article_babel.md.fa7e2aa7.js
+++ b/assets/src_article_babel.md.ec7666af.js
@@ -1 +1 @@
-import{_ as e,o as a,c as t,N as l}from"./chunks/framework.6fe2e870.js";const u=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/babel.md","lastUpdated":1694741410000}'),r={name:"src/article/babel.md"},i=l('

Babel

babel 核心库主要是:

  • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
  • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
  • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
  • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
  • @babel/code-frame 可以创建友好的报错信息
  • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
  • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。
',3),s=[i];function b(o,c,p,n,_,d){return a(),t("div",null,s)}const T=e(r,[["render",b]]);export{u as __pageData,T as default}; +import{_ as e,o as a,c as t,N as l}from"./chunks/framework.6fe2e870.js";const u=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/babel.md","lastUpdated":1695392177000}'),r={name:"src/article/babel.md"},i=l('

Babel

babel 核心库主要是:

  • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
  • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
  • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
  • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
  • @babel/code-frame 可以创建友好的报错信息
  • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
  • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。
',3),s=[i];function b(o,c,p,n,_,d){return a(),t("div",null,s)}const T=e(r,[["render",b]]);export{u as __pageData,T as default}; diff --git a/assets/src_article_babel.md.fa7e2aa7.lean.js b/assets/src_article_babel.md.ec7666af.lean.js similarity index 83% rename from assets/src_article_babel.md.fa7e2aa7.lean.js rename to assets/src_article_babel.md.ec7666af.lean.js index cfe82c289..00f7b217d 100644 --- a/assets/src_article_babel.md.fa7e2aa7.lean.js +++ b/assets/src_article_babel.md.ec7666af.lean.js @@ -1 +1 @@ -import{_ as e,o as a,c as t,N as l}from"./chunks/framework.6fe2e870.js";const u=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/babel.md","lastUpdated":1694741410000}'),r={name:"src/article/babel.md"},i=l("",3),s=[i];function b(o,c,p,n,_,d){return a(),t("div",null,s)}const T=e(r,[["render",b]]);export{u as __pageData,T as default}; +import{_ as e,o as a,c as t,N as l}from"./chunks/framework.6fe2e870.js";const u=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/babel.md","lastUpdated":1695392177000}'),r={name:"src/article/babel.md"},i=l("",3),s=[i];function b(o,c,p,n,_,d){return a(),t("div",null,s)}const T=e(r,[["render",b]]);export{u as __pageData,T as default}; diff --git a/assets/src_article_bundle.md.9ad74b74.js b/assets/src_article_bundle.md.846064e5.js similarity index 93% rename from assets/src_article_bundle.md.9ad74b74.js rename to assets/src_article_bundle.md.846064e5.js index d503be34d..1813eb736 100644 --- a/assets/src_article_bundle.md.9ad74b74.js +++ b/assets/src_article_bundle.md.846064e5.js @@ -1 +1 @@ -import{_ as l,o as t,c as a,x as e,a as n}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/bundle.md","lastUpdated":1694741410000}'),s={name:"src/article/bundle.md"},d=e("h1",{id:"bundle",tabindex:"-1"},[n("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),o=e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),r=e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1),c=[d,o,r];function i(u,_,p,h,m,b){return t(),a("div",null,c)}const x=l(s,[["render",i]]);export{B as __pageData,x as default}; +import{_ as l,o as t,c as a,x as e,a as n}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/bundle.md","lastUpdated":1695392177000}'),s={name:"src/article/bundle.md"},d=e("h1",{id:"bundle",tabindex:"-1"},[n("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),o=e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),r=e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1),c=[d,o,r];function i(u,_,p,h,m,b){return t(),a("div",null,c)}const x=l(s,[["render",i]]);export{B as __pageData,x as default}; diff --git a/assets/src_article_bundle.md.9ad74b74.lean.js b/assets/src_article_bundle.md.846064e5.lean.js similarity index 93% rename from assets/src_article_bundle.md.9ad74b74.lean.js rename to assets/src_article_bundle.md.846064e5.lean.js index d503be34d..1813eb736 100644 --- a/assets/src_article_bundle.md.9ad74b74.lean.js +++ b/assets/src_article_bundle.md.846064e5.lean.js @@ -1 +1 @@ -import{_ as l,o as t,c as a,x as e,a as n}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/bundle.md","lastUpdated":1694741410000}'),s={name:"src/article/bundle.md"},d=e("h1",{id:"bundle",tabindex:"-1"},[n("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),o=e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),r=e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1),c=[d,o,r];function i(u,_,p,h,m,b){return t(),a("div",null,c)}const x=l(s,[["render",i]]);export{B as __pageData,x as default}; +import{_ as l,o as t,c as a,x as e,a as n}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/bundle.md","lastUpdated":1695392177000}'),s={name:"src/article/bundle.md"},d=e("h1",{id:"bundle",tabindex:"-1"},[n("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),o=e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),r=e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1),c=[d,o,r];function i(u,_,p,h,m,b){return t(),a("div",null,c)}const x=l(s,[["render",i]]);export{B as __pageData,x as default}; diff --git a/assets/src_article_designMode.md.a215a004.js b/assets/src_article_designMode.md.3ac9a4d9.js similarity index 99% rename from assets/src_article_designMode.md.a215a004.js rename to assets/src_article_designMode.md.3ac9a4d9.js index 928345a14..4060571f1 100644 --- a/assets/src_article_designMode.md.a215a004.js +++ b/assets/src_article_designMode.md.3ac9a4d9.js @@ -1,4 +1,4 @@ -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/继承.d41dee10.png",o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmQAAAFCCAMAAABo0jE4AAAAtFBMVEX///8yMjKYmJjS0tL6+vqrq6uFhYXv7+/9/f319fXNzc1CQkLX19dVVVVlZWVJSUk1NTVwcHA4ODhYWFjz8/Pn5+evr6+KiopNTU08PDzj4+PIyMjy8vJAQEDc3NyNjY1QUFDDw8O8vLxra2vs7OyTk5OGhoZ0dHRFRUVdXV2ysrKlpaWgoKDZ2dm2trZ/f3+bm5vPz8+EhITe3t78/Px6enphYWHp6enU1NT39/fKysqQkJDndjM/AAAKY0lEQVR42uza2W7aYBQE4JlghDFgg9l3AqRszdKkSdP2/d+rQAJqSyOo2uDlzCdFP0i+OaORrZgDERERERERERERERERERERERERERERERERERERERERERERERERkffkNvwCU63gN1xIhNwKDaioZVFqsOTVkGo1r8QGJDo+PaSeRx8SnQJTfh/bqLEAiQ4JA2xMGVs24rcxZWzZiN/GlLFlI34bU8aWjfhtTBlbNuK3MWVsnSF+n1dAr8wVsOQEXAO4cfH65VDyppRI47+jD4zJGfCBH9HkpnRk8+qq+/rlUPKmlEjjz7Dt4p7tArBgETkSAJkDsP3yR4mbUiKN321zgFbL54MT9l2VzJ5zxF9ho8P7C2afOXvp1e5xqZKZcI74V7zPcuzxccXsvmQbFyqZCeeIf8DqjDknDG75AD0u7TlL/PNwXgV8BgFUMoPOEv8jOQTuyFtg/wojB0CvMEw4S/wN8hLIkEsAXNuVTC9jTbARv40pY8tG/DamjC0b8duYMrZsxG9jytiyEb+NKWPLRvw2powtG/HbmDK2bMRvY8rYshG/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rjJPJOA06N2hcPQVu+794eNpr1MsMe493wHXq7vnWKIOXmwKL1AV3aIxRA/An8s3bN1+3QMszfmtYGPlG/ZTvYaMRc3Z7jZiz22vEnN1eI+bs9hoxZ7fXiDm7vUbM2e01Ys5urxFzdnuNmLPba8Sc3V4j5uz2GjFnt9eIObu9RszZ7TVizm6vEXN2e42Ys9trxJzdXiPm7PYaMWe314g5u71GzM9HsNeI+dkh9hp13eUgxBGFg388V0eNfviZU6MDAdTIyPPYfk0jEREREREREREREREREREREREREREREREREREROYo/dWMhiL/l5rAAAAAASUVORK5CYII=",r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZEAAACDCAMAAAB7ltZBAAAApVBMVEX///8yMjL8/PxBQUE7Ozuvr69kZGTl5eUzMzP09PTNzc3z8/Pu7u5WVlZSUlLY2Nhubm5HR0f+/v7s7OzOzs7KyspwcHBEREQ3Nzf29vbo6OihoaGOjo52dnZMTEw+Pj7Dw8NmZmb4+Pjw8PDg4OC8vLybm5uWlpaCgoJ/f396enpycnJpaWlfX1/c3Ny3t7eTk5OGhoZbW1uzs7Opqamnp6fS0tIlKBnqAAADP0lEQVR42u3dWVMaURQE4D73zsAMDLvIviPKEuMS8/9/WgBRgw9EqCLMOfZXVlm+cLvtYn8YEBERERERERERERERERERERERERERERERERHRV7kw4+WMfCZ0OISN9rmynN31oQJs9EkohasYZxRfFSTEIWy0JyNXOLOcZHAIG+3xEuPM8uJxCBvtEcFnKs+w00h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7/q16y1Aj7fk3Ss1iyU4j7fk3SkVp/qpaaXTMbedd+vJvxXci18k3XESy6cu/83MglfoJp+UfAdR68WycmkanLOK9r8BJEARy8fxvsj8kunVHnxYuAbT71e5I3SKuvV0kwVqw+XECID2LwD1E8iN77GlPgfeoVTC5GSbKFrkpbhaZ+nxaFwHqFRncHHfa8KkKzEfRqvc4yypb5LqzWQTl249FGo1GqhZBUha5ax1z2qrYaCxctelS9Mz4xdtuN2vbRX4H699RpdKEi464j3zA2ln/Kh7z36ohAlr3fva46nd0LdLt7Z7ZR93dfaQ1MLAINos89QfLzvB+rGqRSVDaLTIMktdF2pGBR61rL74AzEN0HnQ9anXL769+i7evi9R7Bp7ZgQhr4eK5X9O1SK70vkgpgXhfQfc5XYuc9uoXEXJAEvSn7YWqRdZil5Uatu4ATIvjVC1y4jtEF80L7j7jl66+1LbIQmRUxZtsfwjn2tHF8//1KUruhNNyzdmk5zutUab8om2RuJbgw6oD1KOod/H8W/H85E8ap+s1J4B76cbaFtk3xoa7fP7v/Wl8Ws/gN1apO4Pf6qbwDDuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtF8bwl4j7ddPsdcolEIujzPK5/51jSE2+v/X4aoeCMBGxq5V9y0aEREREREREREREREREREREREREan0Byk3I1baApDQAAAAAElFTkSuQmCC",y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcoAAAGBCAMAAADR3QFBAAAAt1BMVEX///8yMjKrq6uFhYX8/Pw4ODiYmJj19fVZWVlISEhEREQ7Ozv5+flRUVFOTk5BQUFCQkLz8/NlZWWvr6/y8vI+Pj7r6+vNzc3Y2Nhvb2/l5eXh4eFhYWGKioo0NDTOzs5VVVVeXl7+/v7Jycm7u7uenp5KSkro6Ojd3d2BgYGTk5Pv7+/FxcV4eHi0tLRWVlbT09OoqKhqamp9fX2/v79ycnLt7e24uLiioqKOjo7Q0NCHh4fa2toZwSUUAAAMWUlEQVR42uzd627aMACG4c/gNE0akgCDciYUCAdx6KBr2br7v645h3Vs1YQiLay2vkeAhBKElFcxTvhhEBERERERERERERERERERERERERERERERERERERERERERERERkZlksxGKEoWNpgRdgeyK0nXZ8hqaYj+uo0T18V40QeVriDFK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otFzvFT6ZBlyvg1YQP622pnYyKSV5Nz6m/N4rf19uk5obtpku281dk77sM7PjBlk+DwvO3fJy7TzaLJdOm+DFamd+zQBss3myu+8Q+6x9u3va/bt6ZNxuHkQYa/OS6VSQmciI3j77oLs+qd+3HnXAdNjuLTJBDlPPLqNjny99ACyUXeeYs6/PCCE17la6mRinPu4wNgAQOUA6i2PDC87runRR+DmpL/k3Ct/O0ab6hcJ12S2SibJ+QOVaQpg8oI51qS2PDK+RZ+oghnNW4pwPpoc69rreUKpLZJJcl7zOjVEiY8kU/SOcI/lR/I9llTJONwwWguP6zkMKmTiXio3Mt6mTDwzwY2stykLz0ZxI1dtylWYkAyGUOfcyFWbchUmJIMh1Dk3ctWmXIX53c4d2wAMAkEQdGARugT6L9MZAQESwUtwmung/vMdLhzh56eJOlPUmFl8jsOYWX52x5gaI6/VnjJtmdcyZk92Rs+YSu/XK3OZfZXLNAYAAAAAAAAAAAAArvMD6brkIaU8kEwAAAAASUVORK5CYII=",D="/ran/assets/抽象工厂.786dc879.png",A="/ran/assets/单例.c53b9bde.jpg",B="/ran/assets/建造者.8aaf3334.jpeg",i="/ran/assets/原型.38aa29a0.jpg",E="/ran/assets/装饰.54bb2dbb.jpg",d="/ran/assets/外观.77eeb1fd.png",C="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAs8AAACQCAMAAADA63aOAAAAvVBMVEX///8yMjJERET9/f0+Pj5OTk47Ozvy8vJKSkr6+vpBQUHOzs7g4OBUVFRRUVH09PRkZGRXV1c3Nzfv7+9CQkL29vaCgoKvr6+5ubnKyspHR0erq6s0NDS+vr6np6eVlZX8/Pzc3NzY2Nhvb2+1tbWJiYnl5eWamprFxcVgYGBdXV2SkpJNTU2ysrKNjY1oaGjr6+vX19d+fn5ycnLS0tKioqJ5eXnp6ena2tqenp52dnbn5+dsbGwzMzN/f39aW3v0AAAJD0lEQVR42uzBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAACYXTvaTRQIowB8jqOgBQF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xd/v+/1QESI3a7D2QfZrnzxeiDT3fup5mEk0PV5/cR+j/DfXNQczjG535g+pEo+xxFAMQcd8zxqTE+U/b5WdaXP1RcEkD+BsObuBt8CozPhH3O/gRB8OOQqvc9ZPiC1xMYKviNobwvU9A+62t8puuzm7pnicV5XkRQnI/5wLaZbdtLABYUJ2BatsoUdM/6Gp/p+nxcwt2IjYVNBoUn5A5gaChetxAMJ79dpqB71tf4TNdnJOCYNKyhWDg3nyMR83g0Q7xslynonvU1PhP2OcUYCg7FfjB7sRXMVmBrr/OynFdft8oUtM/6Gp+J++xPJiv1/wxgBiD0sEJF+Wviwj38U6agezbS+EzN5ybie/OZo341PudDgRWEA0UWIXt+KFPQP+trfKbm8x2pGLR9lt+AFeZpwmvYgCvuyhT0z/oanyn7vA0amcW49vnpS6I+rMRHzVe2zx/KFLTP+hqfCfuM3ab2+XIoEO1n8ioB7KeBhMI78uw6SfBQpqB51rfL4YfMAwUsFvbbZ9mUV3EIYH1++pmOQ87Hg2Gaj5zj+FwCWbqw2mUKmmd9uxy+zxxQwGF+v312ElTsoBgJAHnkWV40ykfT6XcXFdb10ipT0D3r2+XwYxY4FvqO5QQs7rfP/yfCDW0fbX/Y4YuC0aAQgJbXMYuF+v3GtKDToCL2Q9Z3Qj8WALS8jjnMNz7THrQrGl7H6puQWTPtQbui53WsEGbNtAftiobXseomZNZMfFDakFkzmUFpQ2bNZAalDZk1kxmUNmTWTGZQ2pBZM5lBaUNmzWQGpQ2ZNZMZlDYm4vu3XTsQAAAAYBjkb32PvTiiRPGlRPGlRPElRfEFAAAAAAAAAAAAAAAAAAAAAIADA572v7F9OdVZAAAAAElFTkSuQmCC",u="/ran/assets/享元.6ee46b37.png",h="/ran/assets/桥接.de284493.png",f="/ran/assets/适配器.1e901e8e.png",g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvYAAACUCAMAAADPnJ1qAAAAvVBMVEX///8yMjLS0tL9/f319fU+Pj5kZGT5+fn7+/vx8fGvr69vb2/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RaQgotIYWWkEJLSKElpNASUmgJKbSEFFpCCi0hhZaQQktIoSWk0BJS/H0JezNexZ3Ls1RmEUYwvcRXx8Jzx8f0vhxxv2C2YsMEppcI08JzU/6XD5YAe3UaJjC3xOfjRhJgD2Al3dhOFmFudRpLkX6gzCyA+C5MYGyJc65Fww9P+WE9F1lvI8yV4szyzmOJIj8BmM7DBMaWyHH+8XQqchHYiiHMBWA69lhiilkAaVZhAMNK2CTX4dlLVNL+Uz5FjxVmFEjT/rGEBQMYVmKQFc/7T3mOKf/tewaYT+ChxAwXAGy4MIGxJVKb1c/lSSxwLQu0bnL24hrCPIwuZA4eSyCxB+B6CSYwtsS5U3AuAJQaeaC4EissnyLM/XysZAH03P+zaTIzDxMYW+JnwoziiZPyJ0w7RrxNjHgJbNRnnCkYYcRLGGSkShhNS0ihJaQYzRJfV9zG+rnuE74A94mjz9niUl33CU+g+4QN4JS27hOeAPcJz15e9wlfkPsEUF2+0n3CE+w+AbTPLN0nfEHuE4g7Rd0nfIHuE83Oie4TvkD3iW6nCN0nfAL2CUv3CY+Ez2J1n5BSQvcJMSUMMlIljKYlpNASUoxsiRajuk/4AtwngOljRnWf8AS6T+A2ccSo/vyEL8h9onkYZlT3CV+A+8RX96RXQvcJT6D7xNIReiV0n/AFt09cdKp3JXSf8AS5T9zEyuUYy1u6T3iC2yf8KlHdJzxB7hN+Cf35iXsSPovVfUJKCd0nvrdjxzYMw1AMBSUjbhL/BQTV3n/ErJAiBSXfrfDAhjElFrJViaUpkUKJFEqkUCKFEimUSKFECiVSKJFCiRRKpFihRF/52PvVrN7ivWpc2xt1tnhH3WNeW5vjrqPle9cDfNoKjrPX1vq5wiIAAAAAAAAAAPiXLxzIGjRPzWNQAAAAAElFTkSuQmCC",S="/ran/assets/访问者.4ef81e5c.png",L=JSON.parse('{"title":"23 种经典设计模式","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/designMode.md","lastUpdated":1694741410000}'),J={name:"src/article/designMode.md"},M=l(`

23 种经典设计模式

设计模式 Design Pattern 是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结,使用设计模式是为了可重用代码、让代码更容易被他人理解并且保证代码可靠性。。

在《设计模式:可复用面向对象软件的基础》一书中所介绍的 23 种经典设计模式,不过设计模式并不仅仅只有这 23 种,随着软件开发行业的发展,越来越多的新模式不断诞生并得以应用。有经验的开发者在学习设计模式可以和过往的经验互相印证,更容易理解这些设计模式。

设计模式一般包含模式名称、问题、目的、解决方案、效果等组成要素。问题描述了应该在何时使用模式,它包含了设计中存在的问题以及问题存在的原因。解决方案描述了一个设计模式的组成成分,以及这些组成成分之间的相互关系,各自的职责和协作方式,通常解决方案通过 UML 类图和核心代码来进行描述。效果描述了模式的优缺点以及在使用模式时应权衡的问题。

为什么要学习设计模式:

  • 设计模式来源众多专家的经验和智慧,它们是从许多优秀的软件系统中总结出的成功的、能够实现可维护性复用的设计方案,使用这些方案将可以让我们避免做一些重复性的工作

  • 设计模式提供了一套通用的设计词汇和一种通用的形式来方便开发人员之间沟通和交流,使得设计方案更加通俗易懂

  • 大部分设计模式都兼顾了系统的可重用性和可扩展性,这使得我们可以更好地重用一些已有的设计方案、功能模块甚至一个完整的软件系统,避免我们经常做一些重复的设计、编写一些重复的代码

  • 合理使用设计模式并对设计模式的使用情况进行文档化,将有助于别人更快地理解系统

  • 学习设计模式将有助于初学者更加深入地理解面向对象思想

储备知识

  • 抽象类:一般抽象类都是作为基类,比如说「电脑」就可以作为一个抽象类,根据抽象类派生出「台式电脑」和「笔记本电脑」2 种具体类。一般不对抽象类进行实例化。

  • 组合优于继承:不能滥用继承来拓展功能,配合组合会更灵活。同样拿「电脑」抽象类来举例,如果使用继承,区分不同类型的「电脑」我们可以派生出「台式电脑」和「笔记本电脑」,如果再增加一个维度,根据品牌又能继续细分出「联想台式电脑」、「联想笔记本电脑」、「苹果台式电脑」和「苹果笔记本电脑」等等,如果再增加一个维度继续细分下去,显然继承是无法胜任的。这个时候可以使用继承加组合方式,组合的对象也可以进行抽象化设计:

    ts
    // 品牌
    +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/继承.d41dee10.png",o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmQAAAFCCAMAAABo0jE4AAAAtFBMVEX///8yMjKYmJjS0tL6+vqrq6uFhYXv7+/9/f319fXNzc1CQkLX19dVVVVlZWVJSUk1NTVwcHA4ODhYWFjz8/Pn5+evr6+KiopNTU08PDzj4+PIyMjy8vJAQEDc3NyNjY1QUFDDw8O8vLxra2vs7OyTk5OGhoZ0dHRFRUVdXV2ysrKlpaWgoKDZ2dm2trZ/f3+bm5vPz8+EhITe3t78/Px6enphYWHp6enU1NT39/fKysqQkJDndjM/AAAKY0lEQVR42uza2W7aYBQE4JlghDFgg9l3AqRszdKkSdP2/d+rQAJqSyOo2uDlzCdFP0i+OaORrZgDERERERERERERERERERERERERERERERERERERERERERERERERkffkNvwCU63gN1xIhNwKDaioZVFqsOTVkGo1r8QGJDo+PaSeRx8SnQJTfh/bqLEAiQ4JA2xMGVs24rcxZWzZiN/GlLFlI34bU8aWjfhtTBlbNuK3MWVsnSF+n1dAr8wVsOQEXAO4cfH65VDyppRI47+jD4zJGfCBH9HkpnRk8+qq+/rlUPKmlEjjz7Dt4p7tArBgETkSAJkDsP3yR4mbUiKN321zgFbL54MT9l2VzJ5zxF9ho8P7C2afOXvp1e5xqZKZcI74V7zPcuzxccXsvmQbFyqZCeeIf8DqjDknDG75AD0u7TlL/PNwXgV8BgFUMoPOEv8jOQTuyFtg/wojB0CvMEw4S/wN8hLIkEsAXNuVTC9jTbARv40pY8tG/DamjC0b8duYMrZsxG9jytiyEb+NKWPLRvw2powtG/HbmDK2bMRvY8rYshG/jSlji0ZATqaSqWTJYyN+G1PGlo34bUwZW/83/soEQL58B2BVcEkiw7USNh+B8aLeusYpYj2lRBV/Z+QA2bYDjMtPAGaPyNBZ/+UBbD8i1y9iWXJxXGynlMji39eoTg+498t5uP3lQcmuJoAb3O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LPba8Sc3V4j5uz2GjFnt9eIObu9RszZ7TVizm6vEXN2e42Ys9trxJzdXiPm7PYaMWe314g5u71GzM9HsNeI+dkh9hp13eUgxBGFg388V0eNfviZU6MDAdTIyPPYfk0jEREREREREREREREREREREREREREREREREREROYo/dWMhiL/l5rAAAAAASUVORK5CYII=",r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZEAAACDCAMAAAB7ltZBAAAApVBMVEX///8yMjL8/PxBQUE7Ozuvr69kZGTl5eUzMzP09PTNzc3z8/Pu7u5WVlZSUlLY2Nhubm5HR0f+/v7s7OzOzs7KyspwcHBEREQ3Nzf29vbo6OihoaGOjo52dnZMTEw+Pj7Dw8NmZmb4+Pjw8PDg4OC8vLybm5uWlpaCgoJ/f396enpycnJpaWlfX1/c3Ny3t7eTk5OGhoZbW1uzs7Opqamnp6fS0tIlKBnqAAADP0lEQVR42u3dWVMaURQE4D73zsAMDLvIviPKEuMS8/9/WgBRgw9EqCLMOfZXVlm+cLvtYn8YEBERERERERERERERERERERERERERERERERHRV7kw4+WMfCZ0OISN9rmynN31oQJs9EkohasYZxRfFSTEIWy0JyNXOLOcZHAIG+3xEuPM8uJxCBvtEcFnKs+w00h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7/q16y1Aj7fk3Ss1iyU4j7fk3SkVp/qpaaXTMbedd+vJvxXci18k3XESy6cu/83MglfoJp+UfAdR68WycmkanLOK9r8BJEARy8fxvsj8kunVHnxYuAbT71e5I3SKuvV0kwVqw+XECID2LwD1E8iN77GlPgfeoVTC5GSbKFrkpbhaZ+nxaFwHqFRncHHfa8KkKzEfRqvc4yypb5LqzWQTl249FGo1GqhZBUha5ax1z2qrYaCxctelS9Mz4xdtuN2vbRX4H699RpdKEi464j3zA2ln/Kh7z36ohAlr3fva46nd0LdLt7Z7ZR93dfaQ1MLAINos89QfLzvB+rGqRSVDaLTIMktdF2pGBR61rL74AzEN0HnQ9anXL769+i7evi9R7Bp7ZgQhr4eK5X9O1SK70vkgpgXhfQfc5XYuc9uoXEXJAEvSn7YWqRdZil5Uatu4ATIvjVC1y4jtEF80L7j7jl66+1LbIQmRUxZtsfwjn2tHF8//1KUruhNNyzdmk5zutUab8om2RuJbgw6oD1KOod/H8W/H85E8ap+s1J4B76cbaFtk3xoa7fP7v/Wl8Ws/gN1apO4Pf6qbwDDuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtF8bwl4j7ddPsdcolEIujzPK5/51jSE2+v/X4aoeCMBGxq5V9y0aEREREREREREREREREREREREREan0Byk3I1baApDQAAAAAElFTkSuQmCC",y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcoAAAGBCAMAAADR3QFBAAAAt1BMVEX///8yMjKrq6uFhYX8/Pw4ODiYmJj19fVZWVlISEhEREQ7Ozv5+flRUVFOTk5BQUFCQkLz8/NlZWWvr6/y8vI+Pj7r6+vNzc3Y2Nhvb2/l5eXh4eFhYWGKioo0NDTOzs5VVVVeXl7+/v7Jycm7u7uenp5KSkro6Ojd3d2BgYGTk5Pv7+/FxcV4eHi0tLRWVlbT09OoqKhqamp9fX2/v79ycnLt7e24uLiioqKOjo7Q0NCHh4fa2toZwSUUAAAMWUlEQVR42uzd627aMACG4c/gNE0akgCDciYUCAdx6KBr2br7v645h3Vs1YQiLay2vkeAhBKElFcxTvhhEBERERERERERERERERERERERERERERERERERERERERERERERkZlksxGKEoWNpgRdgeyK0nXZ8hqaYj+uo0T18V40QeVriDFKdi8aoPKFoo6S1UUIKp8Q+JOW30FMaQ6mNAZTGoMpjcGUxmBKYzClMf5Lyh4ooXvK/nzCszSjdcrlzV4IDrg5bVM+dNY1lbF1ZMqcninl41dfdQxWG4/ToJyWKe+HjuoYVqcyfX+B1Q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XAdNjuLTJBDlPPLqNjny99ACyUXeeYs6/PCCE17la6mRinPu4wNgAQOUA6i2PDC87runRR+DmpL/k3Ct/O0ab6hcJ12S2SibJ+QOVaQpg8oI51qS2PDK+RZ+oghnNW4pwPpoc69rreUKpLZJJcl7zOjVEiY8kU/SOcI/lR/I9llTJONwwWguP6zkMKmTiXio3Mt6mTDwzwY2stykLz0ZxI1dtylWYkAyGUOfcyFWbchUmJIMh1Dk3ctWmXIX53c4d2wAMAkEQdGARugT6L9MZAQESwUtwmung/vMdLhzh56eJOlPUmFl8jsOYWX52x5gaI6/VnjJtmdcyZk92Rs+YSu/XK3OZfZXLNAYAAAAAAAAAAAAArvMD6brkIaU8kEwAAAAASUVORK5CYII=",D="/ran/assets/抽象工厂.786dc879.png",A="/ran/assets/单例.c53b9bde.jpg",B="/ran/assets/建造者.8aaf3334.jpeg",i="/ran/assets/原型.38aa29a0.jpg",E="/ran/assets/装饰.54bb2dbb.jpg",d="/ran/assets/外观.77eeb1fd.png",C="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAs8AAACQCAMAAADA63aOAAAAvVBMVEX///8yMjJERET9/f0+Pj5OTk47Ozvy8vJKSkr6+vpBQUHOzs7g4OBUVFRRUVH09PRkZGRXV1c3Nzfv7+9CQkL29vaCgoKvr6+5ubnKyspHR0erq6s0NDS+vr6np6eVlZX8/Pzc3NzY2Nhvb2+1tbWJiYnl5eWamprFxcVgYGBdXV2SkpJNTU2ysrKNjY1oaGjr6+vX19d+fn5ycnLS0tKioqJ5eXnp6ena2tqenp52dnbn5+dsbGwzMzN/f39aW3v0AAAJD0lEQVR42uzBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAACYXTvaTRQIowB8jqOgBQFdqlWQbletsba1S6WN3dT3f6xFG0ftLt4JE5jvwsQLE//zn5iJjKZpWrmJvuez7HyvL3Q458IpCzFmNYyFDifTuDSF7rNjuSg71+qwr8M5F05JeLRQBRY9Hc65cErCZ/l/gLZM+jqcc+GUBIlq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8puuzm7pnicV5XkRQnI/5wLaZbdtLABYUJ2BatsoUdM/6Gp/p+nxcwt2IjYVNBoUn5A5gaChetxAMJ79dpqB71tf4TNdnJOCYNKyhWDg3nyMR83g0Q7xslynonvU1PhP2OcUYCg7FfjB7sRXMVmBrr/OynFdft8oUtM/6Gp+J++xPJiv1/wxgBiD0sEJF+Wviwj38U6agezbS+EzN5ybie/OZo341PudDgRWEA0UWIXt+KFPQP+trfKbm8x2pGLR9lt+AFeZpwmvYgCvuyhT0z/oanyn7vA0amcW49vnpS6I+rMRHzVe2zx/KFLTP+hqfCfuM3ab2+XIoEO1n8ioB7KeBhMI78uw6SfBQpqB51rfL4YfMAwUsFvbbZ9mUV3EIYH1++pmOQ87Hg2Gaj5zj+FwCWbqw2mUKmmd9uxy+zxxQwGF+v312ElTsoBgJAHnkWV40ykfT6XcXFdb10ipT0D3r2+XwYxY4FvqO5QQs7rfP/yfCDW0fbX/Y4YuC0aAQgJbXMYuF+v3GtKDToCL2Q9Z3Qj8WALS8jjnMNz7THrQrGl7H6puQWTPtQbui53WsEGbNtAftiobXseomZNZMfFDakFkzmUFpQ2bNZAalDZk1kxmUNmTWTGZQ2pBZM5lBaUNmzWQGpQ2ZNZMZlDYm4vu3XTsQAAAAYBjkb32PvTiiRPGlRPGlRPElRfEFAAAAAAAAAAAAAAAAAAAAAIADA572v7F9OdVZAAAAAElFTkSuQmCC",u="/ran/assets/享元.6ee46b37.png",h="/ran/assets/桥接.de284493.png",f="/ran/assets/适配器.1e901e8e.png",g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvYAAACUCAMAAADPnJ1qAAAAvVBMVEX///8yMjLS0tL9/f319fU+Pj5kZGT5+fn7+/vx8fGvr69vb2/o6OjOzs5RUVFCQkLz8/PKyso7Ozvh4eE4ODiTk5Ps7OwzMzOWlpZKSko2NjaMjIxoaGhWVlZAQEDZ2dlgYGBcXFzu7u7d3d3FxcXj4+Orq6tZWVlHR0e3t7dERET39/dycnLQ0NC/v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udRpLkX6gzCyA+C5MYGyJc65Fww9P+WE9F1lvI8yV4szyzmOJIj8BmM7DBMaWyHH+8XQqchHYiiHMBWA69lhiilkAaVZhAMNK2CTX4dlLVNL+Uz5FjxVmFEjT/rGEBQMYVmKQFc/7T3mOKf/tewaYT+ChxAwXAGy4MIGxJVKb1c/lSSxwLQu0bnL24hrCPIwuZA4eSyCxB+B6CSYwtsS5U3AuAJQaeaC4EissnyLM/XysZAH03P+zaTIzDxMYW+JnwoziiZPyJ0w7RrxNjHgJbNRnnCkYYcRLGGSkShhNS0ihJaQYzRJfV9zG+rnuE74A94mjz9niUl33CU+g+4QN4JS27hOeAPcJz15e9wlfkPsEUF2+0n3CE+w+AbTPLN0nfEHuE4g7Rd0nfIHuE83Oie4TvkD3iW6nCN0nfAL2CUv3CY+Ez2J1n5BSQvcJMSUMMlIljKYlpNASUoxsiRajuk/4AtwngOljRnWf8AS6T+A2ccSo/vyEL8h9onkYZlT3CV+A+8RX96RXQvcJT6D7xNIReiV0n/AFt09cdKp3JXSf8AS5T9zEyuUYy1u6T3iC2yf8KlHdJzxB7hN+Cf35iXsSPovVfUJKCd0nvrdjxzYMw1AMBSUjbhL/BQTV3n/ErJAiBSXfrfDAhjElFrJViaUpkUKJFEqkUCKFEimUSKFECiVSKJFCiRRKpFihRF/52PvVrN7ivWpc2xt1tnhH3WNeW5vjrqPle9cDfNoKjrPX1vq5wiIAAAAAAAAAAPiXLxzIGjRPzWNQAAAAAElFTkSuQmCC",S="/ran/assets/访问者.4ef81e5c.png",L=JSON.parse('{"title":"23 种经典设计模式","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/designMode.md","lastUpdated":1695392177000}'),J={name:"src/article/designMode.md"},M=l(`

    23 种经典设计模式

    设计模式 Design Pattern 是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结,使用设计模式是为了可重用代码、让代码更容易被他人理解并且保证代码可靠性。。

    在《设计模式:可复用面向对象软件的基础》一书中所介绍的 23 种经典设计模式,不过设计模式并不仅仅只有这 23 种,随着软件开发行业的发展,越来越多的新模式不断诞生并得以应用。有经验的开发者在学习设计模式可以和过往的经验互相印证,更容易理解这些设计模式。

    设计模式一般包含模式名称、问题、目的、解决方案、效果等组成要素。问题描述了应该在何时使用模式,它包含了设计中存在的问题以及问题存在的原因。解决方案描述了一个设计模式的组成成分,以及这些组成成分之间的相互关系,各自的职责和协作方式,通常解决方案通过 UML 类图和核心代码来进行描述。效果描述了模式的优缺点以及在使用模式时应权衡的问题。

    为什么要学习设计模式:

    • 设计模式来源众多专家的经验和智慧,它们是从许多优秀的软件系统中总结出的成功的、能够实现可维护性复用的设计方案,使用这些方案将可以让我们避免做一些重复性的工作

    • 设计模式提供了一套通用的设计词汇和一种通用的形式来方便开发人员之间沟通和交流,使得设计方案更加通俗易懂

    • 大部分设计模式都兼顾了系统的可重用性和可扩展性,这使得我们可以更好地重用一些已有的设计方案、功能模块甚至一个完整的软件系统,避免我们经常做一些重复的设计、编写一些重复的代码

    • 合理使用设计模式并对设计模式的使用情况进行文档化,将有助于别人更快地理解系统

    • 学习设计模式将有助于初学者更加深入地理解面向对象思想

    储备知识

    • 抽象类:一般抽象类都是作为基类,比如说「电脑」就可以作为一个抽象类,根据抽象类派生出「台式电脑」和「笔记本电脑」2 种具体类。一般不对抽象类进行实例化。

    • 组合优于继承:不能滥用继承来拓展功能,配合组合会更灵活。同样拿「电脑」抽象类来举例,如果使用继承,区分不同类型的「电脑」我们可以派生出「台式电脑」和「笔记本电脑」,如果再增加一个维度,根据品牌又能继续细分出「联想台式电脑」、「联想笔记本电脑」、「苹果台式电脑」和「苹果笔记本电脑」等等,如果再增加一个维度继续细分下去,显然继承是无法胜任的。这个时候可以使用继承加组合方式,组合的对象也可以进行抽象化设计:

      ts
      // 品牌
       interface Brand {
         // ...
       }
      diff --git a/assets/src_article_designMode.md.a215a004.lean.js b/assets/src_article_designMode.md.3ac9a4d9.lean.js
      similarity index 99%
      rename from assets/src_article_designMode.md.a215a004.lean.js
      rename to assets/src_article_designMode.md.3ac9a4d9.lean.js
      index db09b4409..9ad36bfec 100644
      --- a/assets/src_article_designMode.md.a215a004.lean.js
      +++ b/assets/src_article_designMode.md.3ac9a4d9.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/继承.d41dee10.png",o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmQAAAFCCAMAAABo0jE4AAAAtFBMVEX///8yMjKYmJjS0tL6+vqrq6uFhYXv7+/9/f319fXNzc1CQkLX19dVVVVlZWVJSUk1NTVwcHA4ODhYWFjz8/Pn5+evr6+KiopNTU08PDzj4+PIyMjy8vJAQEDc3NyNjY1QUFDDw8O8vLxra2vs7OyTk5OGhoZ0dHRFRUVdXV2ysrKlpaWgoKDZ2dm2trZ/f3+bm5vPz8+EhITe3t78/Px6enphYWHp6enU1NT39/fKysqQkJDndjM/AAAKY0lEQVR42uza2W7aYBQE4JlghDFgg9l3AqRszdKkSdP2/d+rQAJqSyOo2uDlzCdFP0i+OaORrZgDERERERERERERERERERERERERERERERERERERERERERERERERkffkNvwCU63gN1xIhNwKDaioZVFqsOTVkGo1r8QGJDo+PaSeRx8SnQJTfh/bqLEAiQ4JA2xMGVs24rcxZWzZiN/GlLFlI34bU8aWjfhtTBlbNuK3MWVsnSF+n1dAr8wVsOQEXAO4cfH65VDyppRI47+jD4zJGfCBH9HkpnRk8+qq+/rlUPKmlEjjz7Dt4p7tArBgETkSAJkDsP3yR4mbUiKN321zgFbL54MT9l2VzJ5zxF9ho8P7C2afOXvp1e5xqZKZcI74V7zPcuzxccXsvmQbFyqZCeeIf8DqjDknDG75AD0u7TlL/PNwXgV8BgFUMoPOEv8jOQTuyFtg/wojB0CvMEw4S/wN8hLIkEsAXNuVTC9jTbARv40pY8tG/DamjC0b8duYMrZsxG9jytiyEb+NKWPLRvw2powtG/HbmDK2bMRvY8rYshG/jSlji0ZATqaSqWTJYyN+G1PGlo34bUwZW/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7vnWKIOXmwKL1AV3aIxRA/An8s3bN1+3QMszfmtYGPlG/ZTvYaMRc3Z7jZiz22vEnN1eI+bs9hoxZ7fXiDm7vUbM2e01Ys5urxFzdnuNmLPba8Sc3V4j5uz2GjFnt9eIObu9RszZ7TVizm6vEXN2e42Ys9trxJzdXiPm7PYaMWe314g5u71GzM9HsNeI+dkh9hp13eUgxBGFg388V0eNfviZU6MDAdTIyPPYfk0jEREREREREREREREREREREREREREREREREREROYo/dWMhiL/l5rAAAAAASUVORK5CYII=",r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZEAAACDCAMAAAB7ltZBAAAApVBMVEX///8yMjL8/PxBQUE7Ozuvr69kZGTl5eUzMzP09PTNzc3z8/Pu7u5WVlZSUlLY2Nhubm5HR0f+/v7s7OzOzs7KyspwcHBEREQ3Nzf29vbo6OihoaGOjo52dnZMTEw+Pj7Dw8NmZmb4+Pjw8PDg4OC8vLybm5uWlpaCgoJ/f396enpycnJpaWlfX1/c3Ny3t7eTk5OGhoZbW1uzs7Opqamnp6fS0tIlKBnqAAADP0lEQVR42u3dWVMaURQE4D73zsAMDLvIviPKEuMS8/9/WgBRgw9EqCLMOfZXVlm+cLvtYn8YEBERERERERERERERERERERERERERERERERHRV7kw4+WMfCZ0OISN9rmynN31oQJs9EkohasYZxRfFSTEIWy0JyNXOLOcZHAIG+3xEuPM8uJxCBvtEcFnKs+w00h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7/q16y1Aj7fk3Ss1iyU4j7fk3SkVp/qpaaXTMbedd+vJvxXci18k3XESy6cu/83MglfoJp+UfAdR68WycmkanLOK9r8BJEARy8fxvsj8kunVHnxYuAbT71e5I3SKuvV0kwVqw+XECID2LwD1E8iN77GlPgfeoVTC5GSbKFrkpbhaZ+nxaFwHqFRncHHfa8KkKzEfRqvc4yypb5LqzWQTl249FGo1GqhZBUha5ax1z2qrYaCxctelS9Mz4xdtuN2vbRX4H699RpdKEi464j3zA2ln/Kh7z36ohAlr3fva46nd0LdLt7Z7ZR93dfaQ1MLAINos89QfLzvB+rGqRSVDaLTIMktdF2pGBR61rL74AzEN0HnQ9anXL769+i7evi9R7Bp7ZgQhr4eK5X9O1SK70vkgpgXhfQfc5XYuc9uoXEXJAEvSn7YWqRdZil5Uatu4ATIvjVC1y4jtEF80L7j7jl66+1LbIQmRUxZtsfwjn2tHF8//1KUruhNNyzdmk5zutUab8om2RuJbgw6oD1KOod/H8W/H85E8ap+s1J4B76cbaFtk3xoa7fP7v/Wl8Ws/gN1apO4Pf6qbwDDuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtF8bwl4j7ddPsdcolEIujzPK5/51jSE2+v/X4aoeCMBGxq5V9y0aEREREREREREREREREREREREREan0Byk3I1baApDQAAAAAElFTkSuQmCC",y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcoAAAGBCAMAAADR3QFBAAAAt1BMVEX///8yMjKrq6uFhYX8/Pw4ODiYmJj19fVZWVlISEhEREQ7Ozv5+flRUVFOTk5BQUFCQkLz8/NlZWWvr6/y8vI+Pj7r6+vNzc3Y2Nhvb2/l5eXh4eFhYWGKioo0NDTOzs5VVVVeXl7+/v7Jycm7u7uenp5KSkro6Ojd3d2BgYGTk5Pv7+/FxcV4eHi0tLRWVlbT09OoqKhqamp9fX2/v79ycnLt7e24uLiioqKOjo7Q0NCHh4fa2toZwSUUAAAMWUlEQVR42uzd627aMACG4c/gNE0akgCDciYUCAdx6KBr2br7v645h3Vs1YQiLay2vkeAhBKElFcxTvhhEBERERERERERERERERERERERERERERERERERERERERERERERkZlksxGKEoWNpgRdgeyK0nXZ8hqaYj+uo0T18V40QeVriDFKdi8aoPKFoo6S1UUIKp8Q+JOW30FMaQ6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/N4rf19uk5obtpku281dk77sM7PjBlk+DwvO3fJy7TzaLJdOm+DFamd+zQBss3myu+8Q+6x9u3va/bt6ZNxuHkQYa/OS6VSQmciI3j77oLs+qd+3HnXAdNjuLTJBDlPPLqNjny99ACyUXeeYs6/PCCE17la6mRinPu4wNgAQOUA6i2PDC87runRR+DmpL/k3Ct/O0ab6hcJ12S2SibJ+QOVaQpg8oI51qS2PDK+RZ+oghnNW4pwPpoc69rreUKpLZJJcl7zOjVEiY8kU/SOcI/lR/I9llTJONwwWguP6zkMKmTiXio3Mt6mTDwzwY2stykLz0ZxI1dtylWYkAyGUOfcyFWbchUmJIMh1Dk3ctWmXIX53c4d2wAMAkEQdGARugT6L9MZAQESwUtwmung/vMdLhzh56eJOlPUmFl8jsOYWX52x5gaI6/VnjJtmdcyZk92Rs+YSu/XK3OZfZXLNAYAAAAAAAAAAAAArvMD6brkIaU8kEwAAAAASUVORK5CYII=",D="/ran/assets/抽象工厂.786dc879.png",A="/ran/assets/单例.c53b9bde.jpg",B="/ran/assets/建造者.8aaf3334.jpeg",i="/ran/assets/原型.38aa29a0.jpg",E="/ran/assets/装饰.54bb2dbb.jpg",d="/ran/assets/外观.77eeb1fd.png",C="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAs8AAACQCAMAAADA63aOAAAAvVBMVEX///8yMjJERET9/f0+Pj5OTk47Ozvy8vJKSkr6+vpBQUHOzs7g4OBUVFRRUVH09PRkZGRXV1c3Nzfv7+9CQkL29vaCgoKvr6+5ubnKyspHR0erq6s0NDS+vr6np6eVlZX8/Pzc3NzY2Nhvb2+1tbWJiYnl5eWamprFxcVgYGBdXV2SkpJNTU2ysrKNjY1oaGjr6+vX19d+fn5ycnLS0tKioqJ5eXnp6ena2tqenp52dnbn5+dsbGwzMzN/f39aW3v0AAAJD0lEQVR42uzBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAACYXTvaTRQIowB8jqOgBQFdqlWQbletsba1S6WN3dT3f6xFG0ftLt4JE5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k0PV5/cR+j/DfXNQczjG535g+pEo+xxFAMQcd8zxqTE+U/b5WdaXP1RcEkD+BsObuBt8CozPhH3O/gRB8OOQqvc9ZPiC1xMYKviNobwvU9A+62t8puuzm7pnicV5XkRQnI/5wLaZbdtLABYUJ2BatsoUdM/6Gp/p+nxcwt2IjYVNBoUn5A5gaChetxAMJ79dpqB71tf4TNdnJOCYNKyhWDg3nyMR83g0Q7xslynonvU1PhP2OcUYCg7FfjB7sRXMVmBrr/OynFdft8oUtM/6Gp+J++xPJiv1/wxgBiD0sEJF+Wviwj38U6agezbS+EzN5ybie/OZo341PudDgRWEA0UWIXt+KFPQP+trfKbm8x2pGLR9lt+AFeZpwmvYgCvuyhT0z/oanyn7vA0amcW49vnpS6I+rMRHzVe2zx/KFLTP+hqfCfuM3ab2+XIoEO1n8ioB7KeBhMI78uw6SfBQpqB51rfL4YfMAwUsFvbbZ9mUV3EIYH1++pmOQ87Hg2Gaj5zj+FwCWbqw2mUKmmd9uxy+zxxQwGF+v312ElTsoBgJAHnkWV40ykfT6XcXFdb10ipT0D3r2+XwYxY4FvqO5QQs7rfP/yfCDW0fbX/Y4YuC0aAQgJbXMYuF+v3GtKDToCL2Q9Z3Qj8WALS8jjnMNz7THrQrGl7H6puQWTPtQbui53WsEGbNtAftiobXseomZNZMfFDakFkzmUFpQ2bNZAalDZk1kxmUNmTWTGZQ2pBZM5lBaUNmzWQGpQ2ZNZMZlDYm4vu3XTsQAAAAYBjkb32PvTiiRPGlRPGlRPElRfEFAAAAAAAAAAAAAAAAAAAAAIADA572v7F9OdVZAAAAAElFTkSuQmCC",u="/ran/assets/享元.6ee46b37.png",h="/ran/assets/桥接.de284493.png",f="/ran/assets/适配器.1e901e8e.png",g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvYAAACUCAMAAADPnJ1qAAAAvVBMVEX///8yMjLS0tL9/f319fU+Pj5kZGT5+fn7+/vx8fGvr69vb2/o6OjOzs5RUVFCQkLz8/PKyso7Ozvh4eE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i0hhZaQQktIoSWk0BJS/H0JezNexZ3Ls1RmEUYwvcRXx8Jzx8f0vhxxv2C2YsMEppcI08JzU/6XD5YAe3UaJjC3xOfjRhJgD2Al3dhOFmFudRpLkX6gzCyA+C5MYGyJc65Fww9P+WE9F1lvI8yV4szyzmOJIj8BmM7DBMaWyHH+8XQqchHYiiHMBWA69lhiilkAaVZhAMNK2CTX4dlLVNL+Uz5FjxVmFEjT/rGEBQMYVmKQFc/7T3mOKf/tewaYT+ChxAwXAGy4MIGxJVKb1c/lSSxwLQu0bnL24hrCPIwuZA4eSyCxB+B6CSYwtsS5U3AuAJQaeaC4EissnyLM/XysZAH03P+zaTIzDxMYW+JnwoziiZPyJ0w7RrxNjHgJbNRnnCkYYcRLGGSkShhNS0ihJaQYzRJfV9zG+rnuE74A94mjz9niUl33CU+g+4QN4JS27hOeAPcJz15e9wlfkPsEUF2+0n3CE+w+AbTPLN0nfEHuE4g7Rd0nfIHuE83Oie4TvkD3iW6nCN0nfAL2CUv3CY+Ez2J1n5BSQvcJMSUMMlIljKYlpNASUoxsiRajuk/4AtwngOljRnWf8AS6T+A2ccSo/vyEL8h9onkYZlT3CV+A+8RX96RXQvcJT6D7xNIReiV0n/AFt09cdKp3JXSf8AS5T9zEyuUYy1u6T3iC2yf8KlHdJzxB7hN+Cf35iXsSPovVfUJKCd0nvrdjxzYMw1AMBSUjbhL/BQTV3n/ErJAiBSXfrfDAhjElFrJViaUpkUKJFEqkUCKFEimUSKFECiVSKJFCiRRKpFihRF/52PvVrN7ivWpc2xt1tnhH3WNeW5vjrqPle9cDfNoKjrPX1vq5wiIAAAAAAAAAAPiXLxzIGjRPzWNQAAAAAElFTkSuQmCC",S="/ran/assets/访问者.4ef81e5c.png",L=JSON.parse('{"title":"23 种经典设计模式","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/designMode.md","lastUpdated":1694741410000}'),J={name:"src/article/designMode.md"},M=l("",384),j=[M];function N(Q,O,I,Z,U,w){return n(),a("div",null,j)}const K=s(J,[["render",N]]);export{L as __pageData,K as default};
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/继承.d41dee10.png",o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmQAAAFCCAMAAABo0jE4AAAAtFBMVEX///8yMjKYmJjS0tL6+vqrq6uFhYXv7+/9/f319fXNzc1CQkLX19dVVVVlZWVJSUk1NTVwcHA4ODhYWFjz8/Pn5+evr6+KiopNTU08PDzj4+PIyMjy8vJAQEDc3NyNjY1QUFDDw8O8vLxra2vs7OyTk5OGhoZ0dHRFRUVdXV2ysrKlpaWgoKDZ2dm2trZ/f3+bm5vPz8+EhITe3t78/Px6enphYWHp6enU1NT39/fKysqQkJDndjM/AAAKY0lEQVR42uza2W7aYBQE4JlghDFgg9l3AqRszdKkSdP2/d+rQAJqSyOo2uDlzCdFP0i+OaORrZgDERERERERERERERERERERERERERERERERERERERERERERERERkffkNvwCU63gN1xIhNwKDaioZVFqsOTVkGo1r8QGJDo+PaSeRx8SnQJTfh/bqLEAiQ4JA2xMGVs24rcxZWzZiN/GlLFlI34bU8aWjfhtTBlbNuK3MWVsnSF+n1dAr8wVsOQEXAO4cfH65VDyppRI47+jD4zJGfCBH9HkpnRk8+qq+/rlUPKmlEjjz7Dt4p7tArBgETkSAJkDsP3yR4mbUiKN321zgFbL54MT9l2VzJ5zxF9ho8P7C2afOXvp1e5xqZKZcI74V7zPcuzxccXsvmQbFyqZCeeIf8DqjDknDG75AD0u7TlL/PNwXgV8BgFUMoPOEv8jOQTuyFtg/wojB0CvMEw4S/wN8hLIkEsAXNuVTC9jTbARv40pY8tG/DamjC0b8duYMrZsxG9jytiyEb+NKWPLRvw2powtG/HbmDK2bMRvY8rYshG/jSlji0ZATqaSqWTJYyN+G1PGlo34bUwZW/83/soEQL58B2BVcEkiw7USNh+B8aLeusYpYj2lRBV/Z+QA2bYDjMtPAGaPyNBZ/+UBbD8i1y9iWXJxXGynlMji39eoTg+498t5uP3lQ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urxFzdnuNmLPba8Sc3V4j5uz2GjFnt9eIObu9RszZ7TVizm6vEXN2e42Ys9trxJzdXiPm7PYaMWe314g5u71GzM9HsNeI+dkh9hp13eUgxBGFg388V0eNfviZU6MDAdTIyPPYfk0jEREREREREREREREREREREREREREREREREREROYo/dWMhiL/l5rAAAAAASUVORK5CYII=",r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZEAAACDCAMAAAB7ltZBAAAApVBMVEX///8yMjL8/PxBQUE7Ozuvr69kZGTl5eUzMzP09PTNzc3z8/Pu7u5WVlZSUlLY2Nhubm5HR0f+/v7s7OzOzs7KyspwcHBEREQ3Nzf29vbo6OihoaGOjo52dnZMTEw+Pj7Dw8NmZmb4+Pjw8PDg4OC8vLybm5uWlpaCgoJ/f396enpycnJpaWlfX1/c3Ny3t7eTk5OGhoZbW1uzs7Opqamnp6fS0tIlKBnqAAADP0lEQVR42u3dWVMaURQE4D73zsAMDLvIviPKEuMS8/9/WgBRgw9EqCLMOfZXVlm+cLvtYn8YEBERERERERERERERERERERERERERERERERHRV7kw4+WMfCZ0OISN9rmynN31oQJs9EkohasYZxRfFSTEIWy0JyNXOLOcZHAIG+3xEuPM8uJxCBvtEcFnKs+w00h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7/q16y1Aj7fk3Ss1iyU4j7fk3SkVp/qpaaXTMbedd+vJvxXci18k3XESy6cu/83MglfoJp+UfAdR68WycmkanLOK9r8BJEARy8fxvsj8kunVHnxYuAbT71e5I3SKuvV0kwVqw+XECID2LwD1E8iN77GlPgfeoVTC5GSbKFrkpbhaZ+nxaFwHqFRncHHfa8KkKzEfRqvc4yypb5LqzWQTl249FGo1GqhZBUha5ax1z2qrYaCxctelS9Mz4xdtuN2vbRX4H699RpdKEi464j3zA2ln/Kh7z36ohAlr3fva46nd0LdLt7Z7ZR93dfaQ1MLAINos89QfLzvB+rGqRSVDaLTIMktdF2pGBR61rL74AzEN0HnQ9anXL769+i7evi9R7Bp7ZgQhr4eK5X9O1SK70vkgpgXhfQfc5XYuc9uoXEXJAEvSn7YWqRdZil5Uatu4ATIvjVC1y4jtEF80L7j7jl66+1LbIQmRUxZtsfwjn2tHF8//1KUruhNNyzdmk5zutUab8om2RuJbgw6oD1KOod/H8W/H85E8ap+s1J4B76cbaFtk3xoa7fP7v/Wl8Ws/gN1apO4Pf6qbwDDuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtOe310h7fnuNtF8bwl4j7ddPsdcolEIujzPK5/51jSE2+v/X4aoeCMBGxq5V9y0aEREREREREREREREREREREREREan0Byk3I1baApDQAAAAAElFTkSuQmCC",y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcoAAAGBCAMAAADR3QFBAAAAt1BMVEX///8yMjKrq6uFhYX8/Pw4ODiYmJj19fVZWVlISEhEREQ7Ozv5+flRUVFOTk5BQUFCQkLz8/NlZWWvr6/y8vI+Pj7r6+vNzc3Y2Nhvb2/l5eXh4eFhYWGKioo0NDTOzs5VVVVeXl7+/v7Jycm7u7uenp5KSkro6Ojd3d2BgYGTk5Pv7+/FxcV4eHi0tLRWVlbT09OoqKhqamp9fX2/v79ycnLt7e24uLiioqKOjo7Q0NCHh4fa2toZwSUUAAAMWUlEQVR42uzd627aMACG4c/gNE0akgCDciYUCAdx6KBr2br7v645h3Vs1YQiLay2vkeAhBKElFcxTvhhEBERERERERERERERERERERERERERERERERERERERERERERERkZlksxGKEoWNpgRdgeyK0nXZ8hqaYj+uo0T18V40QeVriDFKdi8aoPKFoo6S1UUIKp8Q+JOW30FMaQ6mNAZTGoMpjcGUxmBKYzClMf5Lyh4ooXvK/nzCszSjdcrlzV4IDrg5bVM+dNY1lbF1ZMqcninl41dfdQxWG4/ToJyWKe+HjuoYV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Ls+qd+3HnXAdNjuLTJBDlPPLqNjny99ACyUXeeYs6/PCCE17la6mRinPu4wNgAQOUA6i2PDC87runRR+DmpL/k3Ct/O0ab6hcJ12S2SibJ+QOVaQpg8oI51qS2PDK+RZ+oghnNW4pwPpoc69rreUKpLZJJcl7zOjVEiY8kU/SOcI/lR/I9llTJONwwWguP6zkMKmTiXio3Mt6mTDwzwY2stykLz0ZxI1dtylWYkAyGUOfcyFWbchUmJIMh1Dk3ctWmXIX53c4d2wAMAkEQdGARugT6L9MZAQESwUtwmung/vMdLhzh56eJOlPUmFl8jsOYWX52x5gaI6/VnjJtmdcyZk92Rs+YSu/XK3OZfZXLNAYAAAAAAAAAAAAArvMD6brkIaU8kEwAAAAASUVORK5CYII=",D="/ran/assets/抽象工厂.786dc879.png",A="/ran/assets/单例.c53b9bde.jpg",B="/ran/assets/建造者.8aaf3334.jpeg",i="/ran/assets/原型.38aa29a0.jpg",E="/ran/assets/装饰.54bb2dbb.jpg",d="/ran/assets/外观.77eeb1fd.png",C="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAs8AAACQCAMAAADA63aOAAAAvVBMVEX///8yMjJERET9/f0+Pj5OTk47Ozvy8vJKSkr6+vpBQUHOzs7g4OBUVFRRUVH09PRkZGRXV1c3Nzfv7+9CQkL29vaCgoKvr6+5ubnKyspHR0erq6s0NDS+vr6np6eVlZX8/Pzc3NzY2Nhvb2+1tbWJiYnl5eWamprFxcVgYGBdXV2SkpJNTU2ysrKNjY1oaGjr6+vX19d+fn5ycnLS0tKioqJ5eXnp6ena2tqenp52dnbn5+dsbGwzMzN/f39aW3v0AAAJD0lEQVR42uzBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAACYXTvaTRQIowB8jqOgBQFdqlWQbletsba1S6WN3dT3f6xFG0ftLt4JE5jvwsQLE//zn5iJjKZpWrmJvuez7HyvL3Q458IpCzFmNYyFDifTuDSF7rNjuSg71+qwr8M5F05JeLRQBRY9Hc65cErCZ/l/gLZM+jq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obwvU9A+62t8puuzm7pnicV5XkRQnI/5wLaZbdtLABYUJ2BatsoUdM/6Gp/p+nxcwt2IjYVNBoUn5A5gaChetxAMJ79dpqB71tf4TNdnJOCYNKyhWDg3nyMR83g0Q7xslynonvU1PhP2OcUYCg7FfjB7sRXMVmBrr/OynFdft8oUtM/6Gp+J++xPJiv1/wxgBiD0sEJF+Wviwj38U6agezbS+EzN5ybie/OZo341PudDgRWEA0UWIXt+KFPQP+trfKbm8x2pGLR9lt+AFeZpwmvYgCvuyhT0z/oanyn7vA0amcW49vnpS6I+rMRHzVe2zx/KFLTP+hqfCfuM3ab2+XIoEO1n8ioB7KeBhMI78uw6SfBQpqB51rfL4YfMAwUsFvbbZ9mUV3EIYH1++pmOQ87Hg2Gaj5zj+FwCWbqw2mUKmmd9uxy+zxxQwGF+v312ElTsoBgJAHnkWV40ykfT6XcXFdb10ipT0D3r2+XwYxY4FvqO5QQs7rfP/yfCDW0fbX/Y4YuC0aAQgJbXMYuF+v3GtKDToCL2Q9Z3Qj8WALS8jjnMNz7THrQrGl7H6puQWTPtQbui53WsEGbNtAftiobXseomZNZMfFDakFkzmUFpQ2bNZAalDZk1kxmUNmTWTGZQ2pBZM5lBaUNmzWQGpQ2ZNZMZlDYm4vu3XTsQAAAAYBjkb32PvTiiRPGlRPGlRPElRfEFAAAAAAAAAAAAAAAAAAAAAIADA572v7F9OdVZAAAAAElFTkSuQmCC",u="/ran/assets/享元.6ee46b37.png",h="/ran/assets/桥接.de284493.png",f="/ran/assets/适配器.1e901e8e.png",g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvYAAACUCAMAAADPnJ1qAAAAvVBMVEX///8yMjLS0tL9/f319fU+Pj5kZGT5+fn7+/vx8fGvr69vb2/o6OjOzs5RUVFCQkLz8/PKyso7Ozvh4eE4ODiTk5Ps7OwzMzOWlpZKSko2NjaMjIxoaGhWVlZAQEDZ2dlgYGBcXFzu7u7d3d3FxcXj4+Orq6tZWVlHR0e3t7dERET39/dyc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Al3dhOFmFudRpLkX6gzCyA+C5MYGyJc65Fww9P+WE9F1lvI8yV4szyzmOJIj8BmM7DBMaWyHH+8XQqchHYiiHMBWA69lhiilkAaVZhAMNK2CTX4dlLVNL+Uz5FjxVmFEjT/rGEBQMYVmKQFc/7T3mOKf/tewaYT+ChxAwXAGy4MIGxJVKb1c/lSSxwLQu0bnL24hrCPIwuZA4eSyCxB+B6CSYwtsS5U3AuAJQaeaC4EissnyLM/XysZAH03P+zaTIzDxMYW+JnwoziiZPyJ0w7RrxNjHgJbNRnnCkYYcRLGGSkShhNS0ihJaQYzRJfV9zG+rnuE74A94mjz9niUl33CU+g+4QN4JS27hOeAPcJz15e9wlfkPsEUF2+0n3CE+w+AbTPLN0nfEHuE4g7Rd0nfIHuE83Oie4TvkD3iW6nCN0nfAL2CUv3CY+Ez2J1n5BSQvcJMSUMMlIljKYlpNASUoxsiRajuk/4AtwngOljRnWf8AS6T+A2ccSo/vyEL8h9onkYZlT3CV+A+8RX96RXQvcJT6D7xNIReiV0n/AFt09cdKp3JXSf8AS5T9zEyuUYy1u6T3iC2yf8KlHdJzxB7hN+Cf35iXsSPovVfUJKCd0nvrdjxzYMw1AMBSUjbhL/BQTV3n/ErJAiBSXfrfDAhjElFrJViaUpkUKJFEqkUCKFEimUSKFECiVSKJFCiRRKpFihRF/52PvVrN7ivWpc2xt1tnhH3WNeW5vjrqPle9cDfNoKjrPX1vq5wiIAAAAAAAAAAPiXLxzIGjRPzWNQAAAAAElFTkSuQmCC",S="/ran/assets/访问者.4ef81e5c.png",L=JSON.parse('{"title":"23 种经典设计模式","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/designMode.md","lastUpdated":1695392177000}'),J={name:"src/article/designMode.md"},M=l("",384),j=[M];function N(Q,O,I,Z,U,w){return n(),a("div",null,j)}const K=s(J,[["render",N]]);export{L as __pageData,K as default};
      diff --git a/assets/src_article_functionalProgramming.md.a3014e39.js b/assets/src_article_functionalProgramming.md.a03bc09c.js
      similarity index 99%
      rename from assets/src_article_functionalProgramming.md.a3014e39.js
      rename to assets/src_article_functionalProgramming.md.a03bc09c.js
      index fed24eaae..bf20bdab9 100644
      --- a/assets/src_article_functionalProgramming.md.a3014e39.js
      +++ b/assets/src_article_functionalProgramming.md.a03bc09c.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"函数式编程","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/functionalProgramming.md","lastUpdated":1694741410000}'),p={name:"src/article/functionalProgramming.md"},o=l(`

      函数式编程

      • 概述: 函数式编程(Functional Programming)FP就是编程规范之一,我们常听说的编程规范还有面向对象编程,面向过程编程。
      • 面向对象的编程思维方式:把现实世界中的事物抽象成程序世界的类和对象,通过封装,继承和多态演示事物事件的联系
      • 函数编程的思维方式:把现实世界的事物和事物之间的联系抽象到程序世界(对运算过程进行抽象)
        • 程序的本质:根据输入,通过某种运算,获得相应的输出
        • 函数式编程中的函数不是指程序中的(函数)方法,而是数学中的函数,即映射关系
        • 相同的输入始终要得到相同的输出(纯函数)
        • 函数式编程用来描述数据(函数)之间的映射关系
      js
      //非函数式编程,面向过程的编程方式
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"函数式编程","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/functionalProgramming.md","lastUpdated":1695392177000}'),p={name:"src/article/functionalProgramming.md"},o=l(`

      函数式编程

      • 概述: 函数式编程(Functional Programming)FP就是编程规范之一,我们常听说的编程规范还有面向对象编程,面向过程编程。
      • 面向对象的编程思维方式:把现实世界中的事物抽象成程序世界的类和对象,通过封装,继承和多态演示事物事件的联系
      • 函数编程的思维方式:把现实世界的事物和事物之间的联系抽象到程序世界(对运算过程进行抽象)
        • 程序的本质:根据输入,通过某种运算,获得相应的输出
        • 函数式编程中的函数不是指程序中的(函数)方法,而是数学中的函数,即映射关系
        • 相同的输入始终要得到相同的输出(纯函数)
        • 函数式编程用来描述数据(函数)之间的映射关系
      js
      //非函数式编程,面向过程的编程方式
       let num1 = 1
       let num2 = 2
       let sum = num1 + num2
      diff --git a/assets/src_article_functionalProgramming.md.a3014e39.lean.js b/assets/src_article_functionalProgramming.md.a03bc09c.lean.js
      similarity index 85%
      rename from assets/src_article_functionalProgramming.md.a3014e39.lean.js
      rename to assets/src_article_functionalProgramming.md.a03bc09c.lean.js
      index 1b5a9e58c..06092b380 100644
      --- a/assets/src_article_functionalProgramming.md.a3014e39.lean.js
      +++ b/assets/src_article_functionalProgramming.md.a03bc09c.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"函数式编程","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/functionalProgramming.md","lastUpdated":1694741410000}'),p={name:"src/article/functionalProgramming.md"},o=l("",66),e=[o];function t(c,r,y,F,D,B){return n(),a("div",null,e)}const E=s(p,[["render",t]]);export{A as __pageData,E as default};
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"函数式编程","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/functionalProgramming.md","lastUpdated":1695392177000}'),p={name:"src/article/functionalProgramming.md"},o=l("",66),e=[o];function t(c,r,y,F,D,B){return n(),a("div",null,e)}const E=s(p,[["render",t]]);export{A as __pageData,E as default};
      diff --git a/assets/src_article_imagemin.md.0a9c8df2.js b/assets/src_article_imagemin.md.c9b5bd01.js
      similarity index 90%
      rename from assets/src_article_imagemin.md.0a9c8df2.js
      rename to assets/src_article_imagemin.md.c9b5bd01.js
      index 01f45f202..a60fe6ae9 100644
      --- a/assets/src_article_imagemin.md.0a9c8df2.js
      +++ b/assets/src_article_imagemin.md.c9b5bd01.js
      @@ -1 +1 @@
      -import{_ as a,o as t,c as i,x as e,a as n}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"imagemin 图片压缩源码分析","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/imagemin.md","lastUpdated":1694741410000}'),r={name:"src/article/imagemin.md"},s=e("h1",{id:"imagemin-图片压缩源码分析",tabindex:"-1"},[n("imagemin 图片压缩源码分析 "),e("a",{class:"header-anchor",href:"#imagemin-图片压缩源码分析","aria-label":'Permalink to "imagemin 图片压缩源码分析"'},"​")],-1),c=[s];function m(o,d,l,_,p,g){return t(),i("div",null,c)}const x=a(r,[["render",m]]);export{f as __pageData,x as default};
      +import{_ as a,o as t,c as i,x as e,a as n}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"imagemin 图片压缩源码分析","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/imagemin.md","lastUpdated":1695392177000}'),r={name:"src/article/imagemin.md"},s=e("h1",{id:"imagemin-图片压缩源码分析",tabindex:"-1"},[n("imagemin 图片压缩源码分析 "),e("a",{class:"header-anchor",href:"#imagemin-图片压缩源码分析","aria-label":'Permalink to "imagemin 图片压缩源码分析"'},"​")],-1),c=[s];function m(o,d,l,_,p,g){return t(),i("div",null,c)}const x=a(r,[["render",m]]);export{f as __pageData,x as default};
      diff --git a/assets/src_article_imagemin.md.0a9c8df2.lean.js b/assets/src_article_imagemin.md.c9b5bd01.lean.js
      similarity index 90%
      rename from assets/src_article_imagemin.md.0a9c8df2.lean.js
      rename to assets/src_article_imagemin.md.c9b5bd01.lean.js
      index 01f45f202..a60fe6ae9 100644
      --- a/assets/src_article_imagemin.md.0a9c8df2.lean.js
      +++ b/assets/src_article_imagemin.md.c9b5bd01.lean.js
      @@ -1 +1 @@
      -import{_ as a,o as t,c as i,x as e,a as n}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"imagemin 图片压缩源码分析","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/imagemin.md","lastUpdated":1694741410000}'),r={name:"src/article/imagemin.md"},s=e("h1",{id:"imagemin-图片压缩源码分析",tabindex:"-1"},[n("imagemin 图片压缩源码分析 "),e("a",{class:"header-anchor",href:"#imagemin-图片压缩源码分析","aria-label":'Permalink to "imagemin 图片压缩源码分析"'},"​")],-1),c=[s];function m(o,d,l,_,p,g){return t(),i("div",null,c)}const x=a(r,[["render",m]]);export{f as __pageData,x as default};
      +import{_ as a,o as t,c as i,x as e,a as n}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"imagemin 图片压缩源码分析","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/imagemin.md","lastUpdated":1695392177000}'),r={name:"src/article/imagemin.md"},s=e("h1",{id:"imagemin-图片压缩源码分析",tabindex:"-1"},[n("imagemin 图片压缩源码分析 "),e("a",{class:"header-anchor",href:"#imagemin-图片压缩源码分析","aria-label":'Permalink to "imagemin 图片压缩源码分析"'},"​")],-1),c=[s];function m(o,d,l,_,p,g){return t(),i("div",null,c)}const x=a(r,[["render",m]]);export{f as __pageData,x as default};
      diff --git a/assets/src_article_javascript_domLoad.md.c5bd0e6b.js b/assets/src_article_javascript_domLoad.md.638b7c04.js
      similarity index 97%
      rename from assets/src_article_javascript_domLoad.md.c5bd0e6b.js
      rename to assets/src_article_javascript_domLoad.md.638b7c04.js
      index 228259402..d1fd85f96 100644
      --- a/assets/src_article_javascript_domLoad.md.c5bd0e6b.js
      +++ b/assets/src_article_javascript_domLoad.md.638b7c04.js
      @@ -1 +1 @@
      -import{_ as a,o as e,c as o,N as t}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"页面加载完成后事件","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/javascript/domLoad.md","lastUpdated":1694741410000}'),n={name:"src/article/javascript/domLoad.md"},s=t('

      页面加载完成后事件

      window.onload

      DOMContentLoaded

      js
      document.addEventListener('DOMContentLoaded', fun)

      <body onload="fun()">

      readyState

      js
      document.readyState\n\ndocument.onreadystatechange

      一个文档的 readyState 可以是以下之一:

      • loading / 加载 。document 仍在加载。
      • interactive / 互动。文档已经完成加载,文档已被解析,但是诸如图像,样式表和框架之类的子资源仍在加载。
      • complete / 完成。T 文档和所有子资源已完成加载。状态表示 load 事件即将被触发。
      ',9),l=[s];function d(r,c,p,i,h,u){return e(),o("div",null,l)}const _=a(n,[["render",d]]);export{m as __pageData,_ as default}; +import{_ as a,o as e,c as o,N as t}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"页面加载完成后事件","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/javascript/domLoad.md","lastUpdated":1695392177000}'),n={name:"src/article/javascript/domLoad.md"},s=t('

      页面加载完成后事件

      window.onload

      DOMContentLoaded

      js
      document.addEventListener('DOMContentLoaded', fun)

      <body onload="fun()">

      readyState

      js
      document.readyState\n\ndocument.onreadystatechange

      一个文档的 readyState 可以是以下之一:

      • loading / 加载 。document 仍在加载。
      • interactive / 互动。文档已经完成加载,文档已被解析,但是诸如图像,样式表和框架之类的子资源仍在加载。
      • complete / 完成。T 文档和所有子资源已完成加载。状态表示 load 事件即将被触发。
      ',9),l=[s];function d(r,c,p,i,h,u){return e(),o("div",null,l)}const _=a(n,[["render",d]]);export{m as __pageData,_ as default}; diff --git a/assets/src_article_javascript_domLoad.md.c5bd0e6b.lean.js b/assets/src_article_javascript_domLoad.md.638b7c04.lean.js similarity index 85% rename from assets/src_article_javascript_domLoad.md.c5bd0e6b.lean.js rename to assets/src_article_javascript_domLoad.md.638b7c04.lean.js index ca14a956e..4d4333d5e 100644 --- a/assets/src_article_javascript_domLoad.md.c5bd0e6b.lean.js +++ b/assets/src_article_javascript_domLoad.md.638b7c04.lean.js @@ -1 +1 @@ -import{_ as a,o as e,c as o,N as t}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"页面加载完成后事件","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/javascript/domLoad.md","lastUpdated":1694741410000}'),n={name:"src/article/javascript/domLoad.md"},s=t("",9),l=[s];function d(r,c,p,i,h,u){return e(),o("div",null,l)}const _=a(n,[["render",d]]);export{m as __pageData,_ as default}; +import{_ as a,o as e,c as o,N as t}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"页面加载完成后事件","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/javascript/domLoad.md","lastUpdated":1695392177000}'),n={name:"src/article/javascript/domLoad.md"},s=t("",9),l=[s];function d(r,c,p,i,h,u){return e(),o("div",null,l)}const _=a(n,[["render",d]]);export{m as __pageData,_ as default}; diff --git a/assets/src_article_typescript_calculate.md.426c7cc5.js b/assets/src_article_typescript_calculate.md.082753d2.js similarity index 99% rename from assets/src_article_typescript_calculate.md.426c7cc5.js rename to assets/src_article_typescript_calculate.md.082753d2.js index 53680ea8d..1bcfe9434 100644 --- a/assets/src_article_typescript_calculate.md.426c7cc5.js +++ b/assets/src_article_typescript_calculate.md.082753d2.js @@ -1,4 +1,4 @@ -import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"数组长度做计数","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/calculate.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/calculate.md"},o=p(`

      数组长度做计数

      类型系统不是图灵完备,各种逻辑都能写么,但好像没发现数值相关的逻辑。

      没错,数值相关的逻辑比较绕,被我单独摘了出来,就是这节要讲的内容。

      这是类型体操的第四个套路:数组长度做计数。

      TypeScript 类型系统没有加减乘除运算符,怎么做数值运算呢?

      不知道大家有没有注意到数组类型取 length 就是数值。

      比如:

      ts
      type num1 = [unknown]['length']
      +import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"数组长度做计数","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/calculate.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/calculate.md"},o=p(`

      数组长度做计数

      类型系统不是图灵完备,各种逻辑都能写么,但好像没发现数值相关的逻辑。

      没错,数值相关的逻辑比较绕,被我单独摘了出来,就是这节要讲的内容。

      这是类型体操的第四个套路:数组长度做计数。

      TypeScript 类型系统没有加减乘除运算符,怎么做数值运算呢?

      不知道大家有没有注意到数组类型取 length 就是数值。

      比如:

      ts
      type num1 = [unknown]['length']
       // type num1 = 1
       type num2 = [unknown, unknown]['length']
       // type num1 = 2
      diff --git a/assets/src_article_typescript_calculate.md.426c7cc5.lean.js b/assets/src_article_typescript_calculate.md.082753d2.lean.js
      similarity index 85%
      rename from assets/src_article_typescript_calculate.md.426c7cc5.lean.js
      rename to assets/src_article_typescript_calculate.md.082753d2.lean.js
      index 0d76a9413..86d4119a1 100644
      --- a/assets/src_article_typescript_calculate.md.426c7cc5.lean.js
      +++ b/assets/src_article_typescript_calculate.md.082753d2.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"数组长度做计数","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/calculate.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/calculate.md"},o=p("",99),e=[o];function t(r,c,B,y,F,D){return n(),a("div",null,e)}const i=s(l,[["render",t]]);export{E as __pageData,i as default};
      +import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"数组长度做计数","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/calculate.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/calculate.md"},o=p("",99),e=[o];function t(r,c,B,y,F,D){return n(),a("div",null,e)}const i=s(l,[["render",t]]);export{E as __pageData,i as default};
      diff --git a/assets/src_article_typescript_index.md.a7682bcc.js b/assets/src_article_typescript_index.md.e906a582.js
      similarity index 99%
      rename from assets/src_article_typescript_index.md.a7682bcc.js
      rename to assets/src_article_typescript_index.md.e906a582.js
      index 06b2f2998..84a90a38f 100644
      --- a/assets/src_article_typescript_index.md.a7682bcc.js
      +++ b/assets/src_article_typescript_index.md.e906a582.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"TypeScript 的类型系统","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/index.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/index.md"},o=p(`

      TypeScript 的类型系统

      一.类型是什么

      类型具体点来说就是指 number、boolean、string 等基础类型和 Object、Function 等复合类型,它们是编程语言提供的对不同内容的抽象:

      • 不同类型变量占据的内存大小不同: boolean 类型的变量会分配 4 个字节的内存,而 number 类型的变量则会分配 8 个字节的内存,给变量声明了不同的类型就代表了会占据不同的内存空间。

      • 不同类型变量可做的操作不同: number 类型可以做加减乘除等运算,boolean 就不可以,复合类型中不同类型的对象可用的方法不同,比如 Date 和 RegExp,变量的类型不同代表可以对该变量做的操作就不同。

      有了类型,那我们的操作必须和类型相匹配,否则就会报错,这就是类型检查。

      如果能保证对某种类型只做该类型允许的操作,这就叫做类型安全。

      类型检查可以在运行时做,也可以运行之前的编译期做。这是两种不同的类型,前者叫做动态类型检查,后者叫做静态类型检查。

      两种类型检查各有优缺点。动态类型检查 在源码中不保留类型信息,对某个变量赋什么值、做什么操作都是允许的,写代码很灵活。但这也埋下了类型不安全的隐患,比如对 string 做了乘除,对 Date 对象调用了 exec 方法,这些都是运行时才能检查出来的错误。

      其中,最常见的错误应该是 “null is not an object”、“undefined is not a function” 之类的了,写代码时没发现类型不匹配,到了运行的时候才发现,就会有很多这种报错。

      所以,动态类型虽然代码写起来简单,但代码中很容易藏着一些类型不匹配的隐患。

      静态类型检查则是在源码中保留类型信息,声明变量要指定类型,对变量做的操作要和类型匹配,会有专门的编译器在编译期间做检查。

      静态类型给写代码增加了一些难度,因为你除了要考虑代码要表达的逻辑之外,还要考虑类型逻辑:变量是什么类型的、是不是匹配、要不要做类型转换等。

      不过,静态类型也消除了类型不安全的隐患,因为在编译期间就做了类型检查,就不会出现对 string 做了乘除,调用了 Date 的 exec 方法这类问题。

      所以,静态类型虽然代码写起来要考虑的问题多一些,会复杂一些,但是却消除了代码中潜藏类型不安全问题的可能。

      知道了动态类型检查和静态类型检查的区别,我们自然可以得出这样的结论:

      动态类型只适合简单的场景,对于大项目却不太合适,因为代码中可能藏着的隐患太多了,万一线上报一个类型不匹配的错误,那可能就是大问题。

      而静态类型虽然会增加写代码的成本,但是却能更好的保证代码的健壮性,减少 Bug 率。

      所以,大型项目注定会用静态类型语言开发。

      二.类型系统的分类

      1.简单的类型系统

      变量、函数、类等都可以声明类型,编译器会基于声明的类型做类型检查,类型不匹配时会报错。

      这是最基础的类型系统,能保证类型安全,但有些死板。

      比如一个 add 函数既可以做整数加法、又可以做浮点数加法,却需要声明两个函数:

      c
      int add(int a, int b) {
      +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"TypeScript 的类型系统","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/index.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/index.md"},o=p(`

      TypeScript 的类型系统

      一.类型是什么

      类型具体点来说就是指 number、boolean、string 等基础类型和 Object、Function 等复合类型,它们是编程语言提供的对不同内容的抽象:

      • 不同类型变量占据的内存大小不同: boolean 类型的变量会分配 4 个字节的内存,而 number 类型的变量则会分配 8 个字节的内存,给变量声明了不同的类型就代表了会占据不同的内存空间。

      • 不同类型变量可做的操作不同: number 类型可以做加减乘除等运算,boolean 就不可以,复合类型中不同类型的对象可用的方法不同,比如 Date 和 RegExp,变量的类型不同代表可以对该变量做的操作就不同。

      有了类型,那我们的操作必须和类型相匹配,否则就会报错,这就是类型检查。

      如果能保证对某种类型只做该类型允许的操作,这就叫做类型安全。

      类型检查可以在运行时做,也可以运行之前的编译期做。这是两种不同的类型,前者叫做动态类型检查,后者叫做静态类型检查。

      两种类型检查各有优缺点。动态类型检查 在源码中不保留类型信息,对某个变量赋什么值、做什么操作都是允许的,写代码很灵活。但这也埋下了类型不安全的隐患,比如对 string 做了乘除,对 Date 对象调用了 exec 方法,这些都是运行时才能检查出来的错误。

      其中,最常见的错误应该是 “null is not an object”、“undefined is not a function” 之类的了,写代码时没发现类型不匹配,到了运行的时候才发现,就会有很多这种报错。

      所以,动态类型虽然代码写起来简单,但代码中很容易藏着一些类型不匹配的隐患。

      静态类型检查则是在源码中保留类型信息,声明变量要指定类型,对变量做的操作要和类型匹配,会有专门的编译器在编译期间做检查。

      静态类型给写代码增加了一些难度,因为你除了要考虑代码要表达的逻辑之外,还要考虑类型逻辑:变量是什么类型的、是不是匹配、要不要做类型转换等。

      不过,静态类型也消除了类型不安全的隐患,因为在编译期间就做了类型检查,就不会出现对 string 做了乘除,调用了 Date 的 exec 方法这类问题。

      所以,静态类型虽然代码写起来要考虑的问题多一些,会复杂一些,但是却消除了代码中潜藏类型不安全问题的可能。

      知道了动态类型检查和静态类型检查的区别,我们自然可以得出这样的结论:

      动态类型只适合简单的场景,对于大项目却不太合适,因为代码中可能藏着的隐患太多了,万一线上报一个类型不匹配的错误,那可能就是大问题。

      而静态类型虽然会增加写代码的成本,但是却能更好的保证代码的健壮性,减少 Bug 率。

      所以,大型项目注定会用静态类型语言开发。

      二.类型系统的分类

      1.简单的类型系统

      变量、函数、类等都可以声明类型,编译器会基于声明的类型做类型检查,类型不匹配时会报错。

      这是最基础的类型系统,能保证类型安全,但有些死板。

      比如一个 add 函数既可以做整数加法、又可以做浮点数加法,却需要声明两个函数:

      c
      int add(int a, int b) {
           return a + b;
       }
       
      diff --git a/assets/src_article_typescript_index.md.a7682bcc.lean.js b/assets/src_article_typescript_index.md.e906a582.lean.js
      similarity index 85%
      rename from assets/src_article_typescript_index.md.a7682bcc.lean.js
      rename to assets/src_article_typescript_index.md.e906a582.lean.js
      index df81e8b44..a9b0f8ee8 100644
      --- a/assets/src_article_typescript_index.md.a7682bcc.lean.js
      +++ b/assets/src_article_typescript_index.md.e906a582.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"TypeScript 的类型系统","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/index.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/index.md"},o=p("",253),e=[o];function t(c,r,y,B,D,F){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{A as __pageData,E as default};
      +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"TypeScript 的类型系统","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/index.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/index.md"},o=p("",253),e=[o];function t(c,r,y,B,D,F){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{A as __pageData,E as default};
      diff --git a/assets/src_article_typescript_pattern.md.1fd07afd.js b/assets/src_article_typescript_pattern.md.7d9a7a5d.js
      similarity index 99%
      rename from assets/src_article_typescript_pattern.md.1fd07afd.js
      rename to assets/src_article_typescript_pattern.md.7d9a7a5d.js
      index 5354b37f1..e431dc2fe 100644
      --- a/assets/src_article_typescript_pattern.md.1fd07afd.js
      +++ b/assets/src_article_typescript_pattern.md.7d9a7a5d.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"模式匹配提取","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/pattern.md","lastUpdated":1694741410000}'),p={name:"src/article/typescript/pattern.md"},o=l(`

      模式匹配提取

      字符串可以和正则做模式匹配,找到匹配的部分,提取子组,之后可以用 1,2 等引用匹配的子组。

      ts
      'abc'.replace(/a(b)c/, '$1,$1,$1')
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"模式匹配提取","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/pattern.md","lastUpdated":1695392177000}'),p={name:"src/article/typescript/pattern.md"},o=l(`

      模式匹配提取

      字符串可以和正则做模式匹配,找到匹配的部分,提取子组,之后可以用 1,2 等引用匹配的子组。

      ts
      'abc'.replace(/a(b)c/, '$1,$1,$1')
       // 'b,b,b'

      Typescript 的类型也同样可以做模式匹配。

      比如这样一个 Promise 类型:

      ts
      type p = Promise<'value'>

      我们想提取 value 的类型,可以这样做:

      ts
      type GetValueType<P> = P extends Promise<infer Value> ? Value : never

      通过 extends 对传入的类型参数 P 做模式匹配,其中值的类型是需要提取的,通过 infer 声明一个局部变量 Value 来保存,如果匹配,就返回匹配到的 Value,否则就返回 never 代表没匹配到。

      ts
      // type GetValueResult = 'value'
       type GetValueResult = GetValueType<Promise<'value'>>

      这就是 Typescript 类型的模式匹配:

      Typescript 类型的模式匹配是通过 extends 对类型参数做匹配,结果保存到通过 infer 声明的局部类型变量里,如果匹配就能从该局部变量里拿到提取出的类型。

      这个模式匹配的套路有多有用呢?我们来看下在数组、字符串、函数、构造器等类型里的应用。

      1.数组类型

      提取第一个元素

      数组类型想提取第一个元素的类型怎么做呢?

      ts
      type arr = [1, 2, 3]

      用它来匹配一个模式类型,提取第一个元素的类型到通过 infer 声明的局部变量里返回。

      ts
      type GetFirst<Arr extends unknown[]> = Arr extends [infer First, ...unknown[]]
         ? First
      diff --git a/assets/src_article_typescript_pattern.md.1fd07afd.lean.js b/assets/src_article_typescript_pattern.md.7d9a7a5d.lean.js
      similarity index 85%
      rename from assets/src_article_typescript_pattern.md.1fd07afd.lean.js
      rename to assets/src_article_typescript_pattern.md.7d9a7a5d.lean.js
      index 0551be099..5f7e81852 100644
      --- a/assets/src_article_typescript_pattern.md.1fd07afd.lean.js
      +++ b/assets/src_article_typescript_pattern.md.7d9a7a5d.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"模式匹配提取","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/pattern.md","lastUpdated":1694741410000}'),p={name:"src/article/typescript/pattern.md"},o=l("",145),e=[o];function t(r,c,y,B,F,D){return a(),n("div",null,e)}const A=s(p,[["render",t]]);export{E as __pageData,A as default};
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"模式匹配提取","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/pattern.md","lastUpdated":1695392177000}'),p={name:"src/article/typescript/pattern.md"},o=l("",145),e=[o];function t(r,c,y,B,F,D){return a(),n("div",null,e)}const A=s(p,[["render",t]]);export{E as __pageData,A as default};
      diff --git a/assets/src_article_typescript_reconstruction.md.64c91658.js b/assets/src_article_typescript_reconstruction.md.2ba3370e.js
      similarity index 99%
      rename from assets/src_article_typescript_reconstruction.md.64c91658.js
      rename to assets/src_article_typescript_reconstruction.md.2ba3370e.js
      index a4aa3c691..13a41d15c 100644
      --- a/assets/src_article_typescript_reconstruction.md.64c91658.js
      +++ b/assets/src_article_typescript_reconstruction.md.2ba3370e.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"重新构造做变换","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/reconstruction.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/reconstruction.md"},o=p(`

      重新构造做变换

      类型编程主要的目的就是对类型做各种转换,那么如何对类型做修改呢?

      TypeScript 类型系统支持 3 种可以声明任意类型的变量: type、infer、类型参数。

      type 叫做类型别名,其实就是声明一个变量存储某个类型:

      ts
      type ttt = Promise<number>

      infer 用于类型的提取,然后存到一个变量里,相当于局部变量:

      ts
      type GetValueType<P> = P extends Promise<infer Value> ? Value : never

      类型参数用于接受具体的类型,在类型运算中也相当于局部变量:

      ts
      type isTwo<T> = T extends 2 ? true : false

      但是,严格来说这三种也都不叫变量,因为它们不能被重新赋值。

      TypeScript 设计可以做类型编程的类型系统的目的就是为了产生各种复杂的类型,那不能修改怎么产生新类型呢?

      答案是重新构造。

      这就涉及到了第二个类型体操套路:重新构造做变换。

      重新构造

      TypeScript 的 type、infer、类型参数声明的变量都不能修改,想对类型做各种变换产生新的类型就需要重新构造。

      数组、字符串、函数等类型的重新构造比较简单。

      索引类型,也就是多个元素的聚合类型的重新构造复杂一些,涉及到了映射类型的语法。

      我们先从简单的开始:

      数组类型的重新构造

      Push

      有这样一个元组类型:

      ts
      type tuple = [1, 2, 3]

      我想给这个元组类型再添加一些类型,怎么做呢?

      TypeScript 类型变量不支持修改,我们可以构造一个新的元组类型:

      ts
      type Push<Arr extends unknown[], Ele> = [...Arr, Ele]

      类型参数 Arr 是要修改的数组/元组类型,元素的类型任意,也就是 unknown。

      类型参数 Ele 是添加的元素的类型。

      返回的是用 Arr 已有的元素加上 Ele 构造的新的元组类型。

      ts
      type PushResult = Push<[1, 2, 3], 4>
      +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"重新构造做变换","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/reconstruction.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/reconstruction.md"},o=p(`

      重新构造做变换

      类型编程主要的目的就是对类型做各种转换,那么如何对类型做修改呢?

      TypeScript 类型系统支持 3 种可以声明任意类型的变量: type、infer、类型参数。

      type 叫做类型别名,其实就是声明一个变量存储某个类型:

      ts
      type ttt = Promise<number>

      infer 用于类型的提取,然后存到一个变量里,相当于局部变量:

      ts
      type GetValueType<P> = P extends Promise<infer Value> ? Value : never

      类型参数用于接受具体的类型,在类型运算中也相当于局部变量:

      ts
      type isTwo<T> = T extends 2 ? true : false

      但是,严格来说这三种也都不叫变量,因为它们不能被重新赋值。

      TypeScript 设计可以做类型编程的类型系统的目的就是为了产生各种复杂的类型,那不能修改怎么产生新类型呢?

      答案是重新构造。

      这就涉及到了第二个类型体操套路:重新构造做变换。

      重新构造

      TypeScript 的 type、infer、类型参数声明的变量都不能修改,想对类型做各种变换产生新的类型就需要重新构造。

      数组、字符串、函数等类型的重新构造比较简单。

      索引类型,也就是多个元素的聚合类型的重新构造复杂一些,涉及到了映射类型的语法。

      我们先从简单的开始:

      数组类型的重新构造

      Push

      有这样一个元组类型:

      ts
      type tuple = [1, 2, 3]

      我想给这个元组类型再添加一些类型,怎么做呢?

      TypeScript 类型变量不支持修改,我们可以构造一个新的元组类型:

      ts
      type Push<Arr extends unknown[], Ele> = [...Arr, Ele]

      类型参数 Arr 是要修改的数组/元组类型,元素的类型任意,也就是 unknown。

      类型参数 Ele 是添加的元素的类型。

      返回的是用 Arr 已有的元素加上 Ele 构造的新的元组类型。

      ts
      type PushResult = Push<[1, 2, 3], 4>
       // type PushResult = [1,2,3,4]

      这就是数组/元组的重新构造。

      数组和元组的区别:数组类型是指任意多个同一类型的元素构成的,比如 number[]Array<number>,而元组则是数量固定,类型可以不同的元素构成的,比如 [1, true, 'name']

      Unshift

      可以在后面添加,同样也可以在前面添加:

      ts
      type Unshift<Arr extends unknown[], Ele> = [Ele, ...Arr]

      Zip

      有这样两个元组:

      ts
      type tuple1 = [1, 2]
       type tuple2 = ['name', 'value']

      我们想把它们合并成这样的元组:

      ts
      type tuple = [[1, 'name'], [2, 'value']]

      思路很容易想到,提取元组中的两个元素,构造成新的元组:

      ts
      type Zip<
         One extends [unknown, unknown],
      diff --git a/assets/src_article_typescript_reconstruction.md.64c91658.lean.js b/assets/src_article_typescript_reconstruction.md.2ba3370e.lean.js
      similarity index 85%
      rename from assets/src_article_typescript_reconstruction.md.64c91658.lean.js
      rename to assets/src_article_typescript_reconstruction.md.2ba3370e.lean.js
      index 7db7adc9d..c183ca6a2 100644
      --- a/assets/src_article_typescript_reconstruction.md.64c91658.lean.js
      +++ b/assets/src_article_typescript_reconstruction.md.2ba3370e.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"重新构造做变换","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/reconstruction.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/reconstruction.md"},o=p("",144),e=[o];function t(r,c,B,y,F,D){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{A as __pageData,E as default};
      +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"重新构造做变换","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/reconstruction.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/reconstruction.md"},o=p("",144),e=[o];function t(r,c,B,y,F,D){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{A as __pageData,E as default};
      diff --git a/assets/src_article_typescript_recursion.md.a921b72b.js b/assets/src_article_typescript_recursion.md.0d25062b.js
      similarity index 99%
      rename from assets/src_article_typescript_recursion.md.a921b72b.js
      rename to assets/src_article_typescript_recursion.md.0d25062b.js
      index 4e53c9e24..60545e398 100644
      --- a/assets/src_article_typescript_recursion.md.a921b72b.js
      +++ b/assets/src_article_typescript_recursion.md.0d25062b.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"递归复用","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/recursion.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/recursion.md"},o=p(`

      递归复用

      递归是把问题分解为一系列相似的小问题,通过函数不断调用自身来解决这一个个小问题,直到满足结束条件,就完成了问题的求解。

      TypeScript 的高级类型支持类型参数,可以做各种类型运算逻辑,返回新的类型,和函数调用是对应的,自然也支持递归。

      TypeScript 类型系统不支持循环,但支持递归。当处理数量(个数、长度、层数)不固定的类型的时候,可以只处理一个类型,然后递归的调用自身处理下一个类型,直到结束条件也就是所有的类型都处理完了,就完成了不确定数量的类型编程,达到循环的效果。

      既然提到了数组、字符串、对象等类型,那么我们就来看一下这些类型的递归案例吧。

      Promise 的递归复用

      DeepPromiseValueType

      先用 Promise 热热身,实现一个提取不确定层数的 Promise 中的 value 类型的高级类型。

      ts
      type ttt = Promise<Promise<Promise<Record<string, any>>>>

      这里是 3 层 Promise,value 类型是索引类型。

      数量不确定,一涉及到这个就要想到用递归来做,每次只处理一层的提取,然后剩下的到下次递归做,直到结束条件。

      所以高级类型是这样的:

      ts
      type DeepPromiseValueType<P extends Promise<unknown>> = P extends Promise<
      +import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"递归复用","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/recursion.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/recursion.md"},o=p(`

      递归复用

      递归是把问题分解为一系列相似的小问题,通过函数不断调用自身来解决这一个个小问题,直到满足结束条件,就完成了问题的求解。

      TypeScript 的高级类型支持类型参数,可以做各种类型运算逻辑,返回新的类型,和函数调用是对应的,自然也支持递归。

      TypeScript 类型系统不支持循环,但支持递归。当处理数量(个数、长度、层数)不固定的类型的时候,可以只处理一个类型,然后递归的调用自身处理下一个类型,直到结束条件也就是所有的类型都处理完了,就完成了不确定数量的类型编程,达到循环的效果。

      既然提到了数组、字符串、对象等类型,那么我们就来看一下这些类型的递归案例吧。

      Promise 的递归复用

      DeepPromiseValueType

      先用 Promise 热热身,实现一个提取不确定层数的 Promise 中的 value 类型的高级类型。

      ts
      type ttt = Promise<Promise<Promise<Record<string, any>>>>

      这里是 3 层 Promise,value 类型是索引类型。

      数量不确定,一涉及到这个就要想到用递归来做,每次只处理一层的提取,然后剩下的到下次递归做,直到结束条件。

      所以高级类型是这样的:

      ts
      type DeepPromiseValueType<P extends Promise<unknown>> = P extends Promise<
         infer ValueType
       >
         ? ValueType extends Promise<unknown>
      diff --git a/assets/src_article_typescript_recursion.md.a921b72b.lean.js b/assets/src_article_typescript_recursion.md.0d25062b.lean.js
      similarity index 85%
      rename from assets/src_article_typescript_recursion.md.a921b72b.lean.js
      rename to assets/src_article_typescript_recursion.md.0d25062b.lean.js
      index 8cf88eaf7..33be26fdb 100644
      --- a/assets/src_article_typescript_recursion.md.a921b72b.lean.js
      +++ b/assets/src_article_typescript_recursion.md.0d25062b.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"递归复用","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/recursion.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/recursion.md"},o=p("",123),e=[o];function t(r,c,B,y,F,D){return n(),a("div",null,e)}const i=s(l,[["render",t]]);export{E as __pageData,i as default};
      +import{_ as s,o as n,c as a,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"递归复用","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/recursion.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/recursion.md"},o=p("",123),e=[o];function t(r,c,B,y,F,D){return n(),a("div",null,e)}const i=s(l,[["render",t]]);export{E as __pageData,i as default};
      diff --git a/assets/src_article_typescript_unionType.md.08fc2c93.js b/assets/src_article_typescript_unionType.md.7f4c08c9.js
      similarity index 99%
      rename from assets/src_article_typescript_unionType.md.08fc2c93.js
      rename to assets/src_article_typescript_unionType.md.7f4c08c9.js
      index db9af7031..28e8ea66e 100644
      --- a/assets/src_article_typescript_unionType.md.08fc2c93.js
      +++ b/assets/src_article_typescript_unionType.md.7f4c08c9.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const i=JSON.parse('{"title":"分布式条件类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/unionType.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/unionType.md"},o=p('

      分布式条件类型

      当类型参数为联合类型,并且在条件类型左边直接引用该类型参数的时候,TypeScript 会把每一个元素单独传入来做类型运算,最后再合并成联合类型,这种语法叫做分布式条件类型。

      比如这样一个联合类型:

      ts
      type Union = 'a' | 'b' | 'c'

      我们想把其中的 a 大写,就可以这样写:

      ts
      type UppercaseA<Item extends string> = Item extends 'a' ? Uppercase<Item> : Item
      ts
      type result = UppercaseA<Union>\n// type result = 'A' | 'b' | 'c';

      可以看到,我们类型参数 Item 约束为 string,条件类型的判断中也是判断是否是 a,但传入的是联合类型。

      这就是 TypeScript 对联合类型在条件类型中使用时的特殊处理:会把联合类型的每一个元素单独传入做类型计算,最后合并。

      这和联合类型遇到字符串时的处理一样:

      这样确实是简化了类型编程逻辑的,不需要递归提取每个元素再处理。

      TypeScript 之所以这样处理联合类型也很容易理解,因为联合类型的每个元素都是互不相关的,不像数组、索引、字符串那样元素之间是有关系的。所以设计成了每一个单独处理,最后合并。

      知道了 TypeScript 怎么处理的联合类型,趁热打铁来练习一下:

      CamelcaseUnion

      Camelcase 我们实现过,就是提取字符串中的字符,首字母大写以后重新构造一个新的。

      ts
      type Camelcase<Str extends string> =\n  Str extends `${infer Left}_${infer Right}${infer Rest}`\n    ? `${Left}${Uppercase<Right>}${Camelcase<Rest>}`\n    : Str

      提取 _ 左右的字符,把右边字符大写之后构造成新的字符串,余下的字符串递归处理。

      ts
      type CamelcaseResult = Camelcase<'aa_aa_aa'>\n// type CamelcaseResult = 'aaAaAa'

      如果是对字符串数组做 Camelcase,那就要递归处理每一个元素:

      ts
      type CamelcaseArr<Arr extends unknown[]> = Arr extends [\n  infer Item,\n  ...infer RestArr,\n]\n  ? [Camelcase<Item & string>, ...CamelcaseArr<RestArr>]\n  : []

      类型参数 Arr 为待处理数组。

      递归提取每一个元素做 Camelcase,因为 Camelcase 要求传入 string,这里要 & string 来变成 string 类型。

      那如果是联合类型呢?

      联合类型不需要递归提取每个元素,TypeScript 内部会把每一个元素传入单独做计算,之后把每个元素的计算结果合并成联合类型。

      ts
      type CamelcaseUnion<Item extends string> =\n  Item extends `${infer Left}_${infer Right}${infer Rest}`\n    ? `${Left}${Uppercase<Right>}${CamelcaseUnion<Rest>}`\n    : Item

      这不和单个字符串的处理没区别么?

      没错,对联合类型的处理和对单个类型的处理没什么区别,TypeScript 会把每个单独的类型拆开传入。不需要像数组类型那样需要递归提取每个元素做处理。

      确实简化了很多,好像都是优点?

      也不全是,其实这样处理也增加了一些认知成本,不信我们再来看个例子:

      IsUnion

      判断联合类型我们会这样写:

      ts
      type IsUnion<A, B = A> = A extends A ? ([B] extends [A] ? false : true) : never

      当传入联合类型时,会返回 true:

      ts
      type IsUnionResult = IsUnion<'a' | 'b' 'c'>\n// type IsUnionResult = true

      当传入其他类型时,会返回 false:

      ts
      type IsUnionResult = IsUnion<['a' | 'b' 'c']>\n// type IsUnionResult = false

      这就是分布式条件类型带来的认知成本。

      我们先来看这样一个类型:

      ts
      type TestUnion<A, B = A> = A extends A ? { a: A; b: B } : never\n\ntype TestUnionResult = TestUnion<'a' | 'b' | 'c'>

      传入联合类型 'a' | 'b' | 'c' 的时候,结果是这样的:

      A 和 B 都是同一个联合类型,为啥值还不一样呢?

      因为条件类型中如果左边的类型是联合类型,会把每个元素单独传入做计算,而右边不会。

      所以 A 是 'a' 的时候,B 是 'a' | 'b' | 'c', A 是 'b' 的时候,B 是 'a' | 'b' | 'c'。。。

      那么利用这个特点就可以实现 Union 类型的判断:

      ts
      type IsUnion<A, B = A> = A extends A ? ([B] extends [A] ? false : true) : never

      类型参数 A、B 是待判断的联合类型,B 默认值为 A,也就是同一个类型。

      A extends A 这段看似没啥意义,主要是为了触发分布式条件类型,让 A 的每个类型单独传入。

      [B] extends [A] 这样不直接写 B 就可以避免触发分布式条件类型,那么 B 就是整个联合类型。

      B 是联合类型整体,而 A 是单个类型,自然不成立,而其它类型没有这种特殊处理,A 和 B 都是同一个,怎么判断都成立。

      利用这个特点就可以判断出是否是联合类型。

      其中有两个点比较困惑,我们重点记一下:

      当 A 是联合类型时:

      A extends A 这种写法是为了触发分布式条件类型,让每个类型单独传入处理的,没别的意义。

      A extends A 和 [A] extends [A] 是不同的处理,前者是单个类型和整个类型做判断,后者两边都是整个联合类型,因为只有 extends 左边直接是类型参数才会触发分布式条件类型。

      理解了这两点,分布式条件类型就算掌握了。

      BEM

      bem 是 css 命名规范,用 block__element--modifier 的形式来描述某个区块下面的某个元素的某个状态的样式。

      那么我们可以写这样一个高级类型,传入 block、element、modifier,返回构造出的 class 名:

      这样使用:

      ts
      type bemResult = BEM<'guang', ['aaa', 'bbb'], ['warning', 'success']>

      它的实现就是三部分的合并,但传入的是数组,要递归遍历取出每一个元素来和其他部分组合,这样太麻烦了。

      而如果是联合类型就不用递归遍历了,因为联合类型遇到字符串也是会单独每个元素单独传入做处理。

      数组转联合类型可以这样写:

      ts
      type union = ['aaa', 'bbb'][number]\n// type union = 'aaa' | 'bbb'

      那么 BEM 就可以这样实现:

      ts
      type BEM<\n  Block extends string,\n  Element extends string[],\n  Modifiers extends string[],\n> = `${Block}__${Element[number]}--${Modifiers[number]}`

      类型参数 Block、Element、Modifiers 分别是 bem 规范的三部分,其中 Element 和 Modifiers 都可能多个,约束为 string[]。

      构造一个字符串类型,其中 Element 和 Modifiers 通过索引访问来变为联合类型。

      字符串类型中遇到联合类型的时候,会每个元素单独传入计算,也就是这样的效果:

      ts
      type RemResult = BEM<'a', ['b', 'c'], ['d', 'e']>\n// type RemResult = 'a__b--d' | 'a__b--e' | 'a__c--d' | 'a__b--e'

      可以看到,用好了联合类型,确实能简化类型编程逻辑。

      AllCombinations

      我们再来实现一个全组合的高级类型,也是联合类型相关的:

      希望传入 'A' | 'B' 的时候,能够返回所有的组合: 'A' | 'B' | 'BA' | 'AB'。

      这种全组合问题的实现思路就是两两组合,组合出的字符串再和其他字符串两两组和:

      比如 'A' | 'B' | 'c',就是 A 和 B、C 组合,B 和 A、C 组合,C 和 A、B 组合。然后组合出来的字符串再和其他字符串组合。

      任何两个类型的组合有四种:A、B、AB、BA

      ts
      type Combination<A extends string, B extends string> =\n  | A\n  | B\n  | `${A}${B}`\n  | `${B}${A}`

      然后构造出来的字符串再和其他字符串组合。

      所以全组合的高级类型就是这样:

      ts
      type AllCombinations<A extends string, B extends string = A> = A extends A\n  ? Combination<A, AllCombinations<Exclude<B, A>>>\n  : never

      类型参数 A、B 是待组合的两个联合类型,B 默认是 A 也就是同一个。

      A extends A 的意义就是让联合类型每个类型单独传入做处理,上面我们刚学会。

      A 的处理就是 A 和 B 中去掉 A 以后的所有类型组合,也就是 Combination<A, B 去掉 A 以后的所有组合>。

      而 B 去掉 A 以后的所有组合就是 AllCombinations<Exclude<B, A>>,所以全组合就是 Combination<A, AllCombinations<Exclude<B, A>>>。

      总结

      联合类型中的每个类型都是相互独立的,TypeScript 对它做了特殊处理,也就是遇到字符串类型、条件类型的时候会把每个类型单独传入做计算,最后把每个类型的计算结果合并成联合类型。

      条件类型左边是联合类型的时候就会触法这种处理,叫做分布式条件类型。

      有两点特别要注意:

      • A extends A 不是没意义,意义是取出联合类型中的单个类型放入 A

      • A extends A 才是分布式条件类型, [A] extends [A] 就不是了,只有左边是单独的类型参数才可以。

      我们后面做了一些案例,发现联合类型的这种 distributive 的特性确实能简化类型编程,但是也增加了认知成本,不过这也是不可避免的事。

      ',91),e=[o];function t(c,r,B,y,F,D){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{i as __pageData,E as default}; +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const i=JSON.parse('{"title":"分布式条件类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/unionType.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/unionType.md"},o=p('

      分布式条件类型

      当类型参数为联合类型,并且在条件类型左边直接引用该类型参数的时候,TypeScript 会把每一个元素单独传入来做类型运算,最后再合并成联合类型,这种语法叫做分布式条件类型。

      比如这样一个联合类型:

      ts
      type Union = 'a' | 'b' | 'c'

      我们想把其中的 a 大写,就可以这样写:

      ts
      type UppercaseA<Item extends string> = Item extends 'a' ? Uppercase<Item> : Item
      ts
      type result = UppercaseA<Union>\n// type result = 'A' | 'b' | 'c';

      可以看到,我们类型参数 Item 约束为 string,条件类型的判断中也是判断是否是 a,但传入的是联合类型。

      这就是 TypeScript 对联合类型在条件类型中使用时的特殊处理:会把联合类型的每一个元素单独传入做类型计算,最后合并。

      这和联合类型遇到字符串时的处理一样:

      这样确实是简化了类型编程逻辑的,不需要递归提取每个元素再处理。

      TypeScript 之所以这样处理联合类型也很容易理解,因为联合类型的每个元素都是互不相关的,不像数组、索引、字符串那样元素之间是有关系的。所以设计成了每一个单独处理,最后合并。

      知道了 TypeScript 怎么处理的联合类型,趁热打铁来练习一下:

      CamelcaseUnion

      Camelcase 我们实现过,就是提取字符串中的字符,首字母大写以后重新构造一个新的。

      ts
      type Camelcase<Str extends string> =\n  Str extends `${infer Left}_${infer Right}${infer Rest}`\n    ? `${Left}${Uppercase<Right>}${Camelcase<Rest>}`\n    : Str

      提取 _ 左右的字符,把右边字符大写之后构造成新的字符串,余下的字符串递归处理。

      ts
      type CamelcaseResult = Camelcase<'aa_aa_aa'>\n// type CamelcaseResult = 'aaAaAa'

      如果是对字符串数组做 Camelcase,那就要递归处理每一个元素:

      ts
      type CamelcaseArr<Arr extends unknown[]> = Arr extends [\n  infer Item,\n  ...infer RestArr,\n]\n  ? [Camelcase<Item & string>, ...CamelcaseArr<RestArr>]\n  : []

      类型参数 Arr 为待处理数组。

      递归提取每一个元素做 Camelcase,因为 Camelcase 要求传入 string,这里要 & string 来变成 string 类型。

      那如果是联合类型呢?

      联合类型不需要递归提取每个元素,TypeScript 内部会把每一个元素传入单独做计算,之后把每个元素的计算结果合并成联合类型。

      ts
      type CamelcaseUnion<Item extends string> =\n  Item extends `${infer Left}_${infer Right}${infer Rest}`\n    ? `${Left}${Uppercase<Right>}${CamelcaseUnion<Rest>}`\n    : Item

      这不和单个字符串的处理没区别么?

      没错,对联合类型的处理和对单个类型的处理没什么区别,TypeScript 会把每个单独的类型拆开传入。不需要像数组类型那样需要递归提取每个元素做处理。

      确实简化了很多,好像都是优点?

      也不全是,其实这样处理也增加了一些认知成本,不信我们再来看个例子:

      IsUnion

      判断联合类型我们会这样写:

      ts
      type IsUnion<A, B = A> = A extends A ? ([B] extends [A] ? false : true) : never

      当传入联合类型时,会返回 true:

      ts
      type IsUnionResult = IsUnion<'a' | 'b' 'c'>\n// type IsUnionResult = true

      当传入其他类型时,会返回 false:

      ts
      type IsUnionResult = IsUnion<['a' | 'b' 'c']>\n// type IsUnionResult = false

      这就是分布式条件类型带来的认知成本。

      我们先来看这样一个类型:

      ts
      type TestUnion<A, B = A> = A extends A ? { a: A; b: B } : never\n\ntype TestUnionResult = TestUnion<'a' | 'b' | 'c'>

      传入联合类型 'a' | 'b' | 'c' 的时候,结果是这样的:

      A 和 B 都是同一个联合类型,为啥值还不一样呢?

      因为条件类型中如果左边的类型是联合类型,会把每个元素单独传入做计算,而右边不会。

      所以 A 是 'a' 的时候,B 是 'a' | 'b' | 'c', A 是 'b' 的时候,B 是 'a' | 'b' | 'c'。。。

      那么利用这个特点就可以实现 Union 类型的判断:

      ts
      type IsUnion<A, B = A> = A extends A ? ([B] extends [A] ? false : true) : never

      类型参数 A、B 是待判断的联合类型,B 默认值为 A,也就是同一个类型。

      A extends A 这段看似没啥意义,主要是为了触发分布式条件类型,让 A 的每个类型单独传入。

      [B] extends [A] 这样不直接写 B 就可以避免触发分布式条件类型,那么 B 就是整个联合类型。

      B 是联合类型整体,而 A 是单个类型,自然不成立,而其它类型没有这种特殊处理,A 和 B 都是同一个,怎么判断都成立。

      利用这个特点就可以判断出是否是联合类型。

      其中有两个点比较困惑,我们重点记一下:

      当 A 是联合类型时:

      A extends A 这种写法是为了触发分布式条件类型,让每个类型单独传入处理的,没别的意义。

      A extends A 和 [A] extends [A] 是不同的处理,前者是单个类型和整个类型做判断,后者两边都是整个联合类型,因为只有 extends 左边直接是类型参数才会触发分布式条件类型。

      理解了这两点,分布式条件类型就算掌握了。

      BEM

      bem 是 css 命名规范,用 block__element--modifier 的形式来描述某个区块下面的某个元素的某个状态的样式。

      那么我们可以写这样一个高级类型,传入 block、element、modifier,返回构造出的 class 名:

      这样使用:

      ts
      type bemResult = BEM<'guang', ['aaa', 'bbb'], ['warning', 'success']>

      它的实现就是三部分的合并,但传入的是数组,要递归遍历取出每一个元素来和其他部分组合,这样太麻烦了。

      而如果是联合类型就不用递归遍历了,因为联合类型遇到字符串也是会单独每个元素单独传入做处理。

      数组转联合类型可以这样写:

      ts
      type union = ['aaa', 'bbb'][number]\n// type union = 'aaa' | 'bbb'

      那么 BEM 就可以这样实现:

      ts
      type BEM<\n  Block extends string,\n  Element extends string[],\n  Modifiers extends string[],\n> = `${Block}__${Element[number]}--${Modifiers[number]}`

      类型参数 Block、Element、Modifiers 分别是 bem 规范的三部分,其中 Element 和 Modifiers 都可能多个,约束为 string[]。

      构造一个字符串类型,其中 Element 和 Modifiers 通过索引访问来变为联合类型。

      字符串类型中遇到联合类型的时候,会每个元素单独传入计算,也就是这样的效果:

      ts
      type RemResult = BEM<'a', ['b', 'c'], ['d', 'e']>\n// type RemResult = 'a__b--d' | 'a__b--e' | 'a__c--d' | 'a__b--e'

      可以看到,用好了联合类型,确实能简化类型编程逻辑。

      AllCombinations

      我们再来实现一个全组合的高级类型,也是联合类型相关的:

      希望传入 'A' | 'B' 的时候,能够返回所有的组合: 'A' | 'B' | 'BA' | 'AB'。

      这种全组合问题的实现思路就是两两组合,组合出的字符串再和其他字符串两两组和:

      比如 'A' | 'B' | 'c',就是 A 和 B、C 组合,B 和 A、C 组合,C 和 A、B 组合。然后组合出来的字符串再和其他字符串组合。

      任何两个类型的组合有四种:A、B、AB、BA

      ts
      type Combination<A extends string, B extends string> =\n  | A\n  | B\n  | `${A}${B}`\n  | `${B}${A}`

      然后构造出来的字符串再和其他字符串组合。

      所以全组合的高级类型就是这样:

      ts
      type AllCombinations<A extends string, B extends string = A> = A extends A\n  ? Combination<A, AllCombinations<Exclude<B, A>>>\n  : never

      类型参数 A、B 是待组合的两个联合类型,B 默认是 A 也就是同一个。

      A extends A 的意义就是让联合类型每个类型单独传入做处理,上面我们刚学会。

      A 的处理就是 A 和 B 中去掉 A 以后的所有类型组合,也就是 Combination<A, B 去掉 A 以后的所有组合>。

      而 B 去掉 A 以后的所有组合就是 AllCombinations<Exclude<B, A>>,所以全组合就是 Combination<A, AllCombinations<Exclude<B, A>>>。

      总结

      联合类型中的每个类型都是相互独立的,TypeScript 对它做了特殊处理,也就是遇到字符串类型、条件类型的时候会把每个类型单独传入做计算,最后把每个类型的计算结果合并成联合类型。

      条件类型左边是联合类型的时候就会触法这种处理,叫做分布式条件类型。

      有两点特别要注意:

      • A extends A 不是没意义,意义是取出联合类型中的单个类型放入 A

      • A extends A 才是分布式条件类型, [A] extends [A] 就不是了,只有左边是单独的类型参数才可以。

      我们后面做了一些案例,发现联合类型的这种 distributive 的特性确实能简化类型编程,但是也增加了认知成本,不过这也是不可避免的事。

      ',91),e=[o];function t(c,r,B,y,F,D){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{i as __pageData,E as default}; diff --git a/assets/src_article_typescript_unionType.md.08fc2c93.lean.js b/assets/src_article_typescript_unionType.md.7f4c08c9.lean.js similarity index 85% rename from assets/src_article_typescript_unionType.md.08fc2c93.lean.js rename to assets/src_article_typescript_unionType.md.7f4c08c9.lean.js index 63fd29df2..cab0710f3 100644 --- a/assets/src_article_typescript_unionType.md.08fc2c93.lean.js +++ b/assets/src_article_typescript_unionType.md.7f4c08c9.lean.js @@ -1 +1 @@ -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const i=JSON.parse('{"title":"分布式条件类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/unionType.md","lastUpdated":1694741410000}'),l={name:"src/article/typescript/unionType.md"},o=p("",91),e=[o];function t(c,r,B,y,F,D){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{i as __pageData,E as default}; +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const i=JSON.parse('{"title":"分布式条件类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/article/typescript/unionType.md","lastUpdated":1695392177000}'),l={name:"src/article/typescript/unionType.md"},o=p("",91),e=[o];function t(c,r,B,y,F,D){return a(),n("div",null,e)}const E=s(l,[["render",t]]);export{i as __pageData,E as default}; diff --git a/assets/src_ranui_button_index.md.fc18e80f.js b/assets/src_ranui_button_index.md.f2904501.js similarity index 99% rename from assets/src_ranui_button_index.md.fc18e80f.js rename to assets/src_ranui_button_index.md.f2904501.js index dce106017..4c3e66d2b 100644 --- a/assets/src_ranui_button_index.md.fc18e80f.js +++ b/assets/src_ranui_button_index.md.f2904501.js @@ -1,4 +1,4 @@ -import{_ as n,o,c as t,N as s,x as a}from"./chunks/framework.6fe2e870.js";const h=JSON.parse('{"title":"Button 按钮","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/button/index.md","lastUpdated":1694741410000}'),l={name:"src/ranui/button/index.md"},p=s(`

      Button 按钮

      按钮用于开始一个即时操作。

      代码演示

      Button
      xml
      <r-button >Button</r-button>

      属性

      类型type

      按钮有四种类型

      主要按钮
      警告按钮
      文本按钮
      默认按钮
      xml
      <r-button type="primary">主要按钮</r-button>
      +import{_ as n,o,c as t,N as s,x as a}from"./chunks/framework.6fe2e870.js";const h=JSON.parse('{"title":"Button 按钮","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/button/index.md","lastUpdated":1695392177000}'),l={name:"src/ranui/button/index.md"},p=s(`

      Button 按钮

      按钮用于开始一个即时操作。

      代码演示

      Button
      xml
      <r-button >Button</r-button>

      属性

      类型type

      按钮有四种类型

      主要按钮
      警告按钮
      文本按钮
      默认按钮
      xml
      <r-button type="primary">主要按钮</r-button>
        <r-button type="warning">警告按钮</r-button>
        <r-button type="text">文本按钮</r-button>
        <r-button >默认按钮</r-button>

      不可用状态disabled

      添加 disabled 属性即可让按钮处于不可用状态,同时按钮样式也会改变。

      主要按钮
      警告按钮
      文本按钮
      默认按钮
      xml
      <r-button type="primary" disabled>主要按钮</r-button>
      diff --git a/assets/src_ranui_button_index.md.fc18e80f.lean.js b/assets/src_ranui_button_index.md.f2904501.lean.js
      similarity index 88%
      rename from assets/src_ranui_button_index.md.fc18e80f.lean.js
      rename to assets/src_ranui_button_index.md.f2904501.lean.js
      index f84defec4..b5761e658 100644
      --- a/assets/src_ranui_button_index.md.fc18e80f.lean.js
      +++ b/assets/src_ranui_button_index.md.f2904501.lean.js
      @@ -1 +1 @@
      -import{_ as n,o,c as t,N as s,x as a}from"./chunks/framework.6fe2e870.js";const h=JSON.parse('{"title":"Button 按钮","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/button/index.md","lastUpdated":1694741410000}'),l={name:"src/ranui/button/index.md"},p=s("",28),e=a("r-button",{type:"default",effect:"fase",icon:"user"},"默认按钮",-1),r=a("r-button",{type:"primary",effect:"fase",icon:"home"},"主要按钮",-1),c=s("",1),D=[p,e,r,c];function y(F,i,u,d,b,g){return o(),t("div",null,D)}const E=n(l,[["render",y]]);export{h as __pageData,E as default};
      +import{_ as n,o,c as t,N as s,x as a}from"./chunks/framework.6fe2e870.js";const h=JSON.parse('{"title":"Button 按钮","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/button/index.md","lastUpdated":1695392177000}'),l={name:"src/ranui/button/index.md"},p=s("",28),e=a("r-button",{type:"default",effect:"fase",icon:"user"},"默认按钮",-1),r=a("r-button",{type:"primary",effect:"fase",icon:"home"},"主要按钮",-1),c=s("",1),D=[p,e,r,c];function y(F,i,u,d,b,g){return o(),t("div",null,D)}const E=n(l,[["render",y]]);export{h as __pageData,E as default};
      diff --git a/assets/src_ranui_icon_index.md.fb0d6bc2.js b/assets/src_ranui_icon_index.md.f70b076f.js
      similarity index 99%
      rename from assets/src_ranui_icon_index.md.fb0d6bc2.js
      rename to assets/src_ranui_icon_index.md.f70b076f.js
      index a278381fd..580404f5e 100644
      --- a/assets/src_ranui_icon_index.md.fb0d6bc2.js
      +++ b/assets/src_ranui_icon_index.md.f70b076f.js
      @@ -1,4 +1,4 @@
      -import{_ as c,o as r,c as F,N as t,x as a}from"./chunks/framework.6fe2e870.js";const D=()=>{setTimeout(()=>{const e=["add-user","book","check-circle","close-circle","eye-close","eye","info-circle","loading","lock","message","power-off","setting","team","unlock","user"];if(typeof document<"u"){const o=document.getElementById("icon-list");e.forEach(l=>{const s=document.createElement("div");s.style.setProperty("display","flex"),s.style.setProperty("align-items","center"),s.style.setProperty("margin","15px"),s.style.setProperty("justify-content","center"),s.style.setProperty("flex-flow","column nowrap");const n=document.createElement("r-icon");n.setAttribute("name",l),n.setAttribute("size","50"),s.appendChild(n);const p=document.createElement("span");p.innerHTML=l,s.appendChild(p),o==null||o.appendChild(s)})}},0)};D();const q=JSON.parse('{"title":"Icon 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/icon/index.md","lastUpdated":1694741410000}'),y={name:"src/ranui/icon/index.md"},i=t(`

      Icon 图标

      语义化的矢量图形

      代码演示

      xml
      <r-icon name="lock"  ></r-icon>
      +import{_ as c,o as r,c as F,N as t,x as a}from"./chunks/framework.6fe2e870.js";const D=()=>{setTimeout(()=>{const e=["add-user","book","check-circle","close-circle","eye-close","eye","info-circle","loading","lock","message","power-off","setting","team","unlock","user"];if(typeof document<"u"){const o=document.getElementById("icon-list");e.forEach(l=>{const s=document.createElement("div");s.style.setProperty("display","flex"),s.style.setProperty("align-items","center"),s.style.setProperty("margin","15px"),s.style.setProperty("justify-content","center"),s.style.setProperty("flex-flow","column nowrap");const n=document.createElement("r-icon");n.setAttribute("name",l),n.setAttribute("size","50"),s.appendChild(n);const p=document.createElement("span");p.innerHTML=l,s.appendChild(p),o==null||o.appendChild(s)})}},0)};D();const q=JSON.parse('{"title":"Icon 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/icon/index.md","lastUpdated":1695392177000}'),y={name:"src/ranui/icon/index.md"},i=t(`

      Icon 图标

      语义化的矢量图形

      代码演示

      xml
      <r-icon name="lock"  ></r-icon>
        <r-icon name="eye"  ></r-icon>
        <r-icon name="user"  ></r-icon>

      属性

      名称name

      根据名称选择不同的图标

      html
      <r-icon name="lock"></r-icon>
       <r-icon name="eye"></r-icon>
      diff --git a/assets/src_ranui_icon_index.md.fb0d6bc2.lean.js b/assets/src_ranui_icon_index.md.f70b076f.lean.js
      similarity index 95%
      rename from assets/src_ranui_icon_index.md.fb0d6bc2.lean.js
      rename to assets/src_ranui_icon_index.md.f70b076f.lean.js
      index 09f85db6c..66df8a425 100644
      --- a/assets/src_ranui_icon_index.md.fb0d6bc2.lean.js
      +++ b/assets/src_ranui_icon_index.md.f70b076f.lean.js
      @@ -1 +1 @@
      -import{_ as c,o as r,c as F,N as t,x as a}from"./chunks/framework.6fe2e870.js";const D=()=>{setTimeout(()=>{const e=["add-user","book","check-circle","close-circle","eye-close","eye","info-circle","loading","lock","message","power-off","setting","team","unlock","user"];if(typeof document<"u"){const o=document.getElementById("icon-list");e.forEach(l=>{const s=document.createElement("div");s.style.setProperty("display","flex"),s.style.setProperty("align-items","center"),s.style.setProperty("margin","15px"),s.style.setProperty("justify-content","center"),s.style.setProperty("flex-flow","column nowrap");const n=document.createElement("r-icon");n.setAttribute("name",l),n.setAttribute("size","50"),s.appendChild(n);const p=document.createElement("span");p.innerHTML=l,s.appendChild(p),o==null||o.appendChild(s)})}},0)};D();const q=JSON.parse('{"title":"Icon 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/icon/index.md","lastUpdated":1694741410000}'),y={name:"src/ranui/icon/index.md"},i=t("",18),u=a("div",{style:{display:"flex"}},[a("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:"0.7"}),a("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:""}),a("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:"5"})],-1),d=t("",3),E=[i,u,d];function m(e,o,l,s,n,p){return r(),F("div",null,E)}const h=c(y,[["render",m]]);export{q as __pageData,h as default};
      +import{_ as c,o as r,c as F,N as t,x as a}from"./chunks/framework.6fe2e870.js";const D=()=>{setTimeout(()=>{const e=["add-user","book","check-circle","close-circle","eye-close","eye","info-circle","loading","lock","message","power-off","setting","team","unlock","user"];if(typeof document<"u"){const o=document.getElementById("icon-list");e.forEach(l=>{const s=document.createElement("div");s.style.setProperty("display","flex"),s.style.setProperty("align-items","center"),s.style.setProperty("margin","15px"),s.style.setProperty("justify-content","center"),s.style.setProperty("flex-flow","column nowrap");const n=document.createElement("r-icon");n.setAttribute("name",l),n.setAttribute("size","50"),s.appendChild(n);const p=document.createElement("span");p.innerHTML=l,s.appendChild(p),o==null||o.appendChild(s)})}},0)};D();const q=JSON.parse('{"title":"Icon 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/icon/index.md","lastUpdated":1695392177000}'),y={name:"src/ranui/icon/index.md"},i=t("",18),u=a("div",{style:{display:"flex"}},[a("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:"0.7"}),a("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:""}),a("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:"5"})],-1),d=t("",3),E=[i,u,d];function m(e,o,l,s,n,p){return r(),F("div",null,E)}const h=c(y,[["render",m]]);export{q as __pageData,h as default};
      diff --git a/assets/src_ranui_image_index.md.0bb00ae4.js b/assets/src_ranui_image_index.md.586060f5.js
      similarity index 98%
      rename from assets/src_ranui_image_index.md.0bb00ae4.js
      rename to assets/src_ranui_image_index.md.586060f5.js
      index dfc77c0ad..9365e3427 100644
      --- a/assets/src_ranui_image_index.md.0bb00ae4.js
      +++ b/assets/src_ranui_image_index.md.586060f5.js
      @@ -1 +1 @@
      -import{_ as A,o as a,c as E,N as Q,x as o}from"./chunks/framework.6fe2e870.js";const I=JSON.parse('{"title":"Image 图片","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/image/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/image/index.md"},s=Q('

      Image 图片

      代码演示

      xml
      <r-img src="" fallback=""></r-img>

      属性

      图片加载地址src

      图片的地址

      图片加载失败fallback

      src配置的图片加载失败,兜底的图片地址,下面是默认加载失败图片

      ',8),n=o("r-img",{fallback:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKO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8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="},null,-1),g=[s,n];function l(t,c,i,r,B,d){return a(),E("div",null,g)}const C=A(e,[["render",l]]);export{I as __pageData,C as default}; +import{_ as A,o as a,c as E,N as Q,x as o}from"./chunks/framework.6fe2e870.js";const I=JSON.parse('{"title":"Image 图片","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/image/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/image/index.md"},s=Q('

      Image 图片

      代码演示

      xml
      <r-img src="" fallback=""></r-img>

      属性

      图片加载地址src

      图片的地址

      图片加载失败fallback

      src配置的图片加载失败,兜底的图片地址,下面是默认加载失败图片

      ',8),n=o("r-img",{fallback:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZ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2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="},null,-1),g=[s,n];function l(t,c,i,r,B,d){return a(),E("div",null,g)}const C=A(e,[["render",l]]);export{I as __pageData,C as default}; diff --git a/assets/src_ranui_image_index.md.0bb00ae4.lean.js b/assets/src_ranui_image_index.md.586060f5.lean.js similarity index 98% rename from assets/src_ranui_image_index.md.0bb00ae4.lean.js rename to assets/src_ranui_image_index.md.586060f5.lean.js index b953f3436..eb79f9e54 100644 --- a/assets/src_ranui_image_index.md.0bb00ae4.lean.js +++ b/assets/src_ranui_image_index.md.586060f5.lean.js @@ -1 +1 @@ -import{_ as A,o as a,c as E,N as Q,x as o}from"./chunks/framework.6fe2e870.js";const I=JSON.parse('{"title":"Image 图片","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/image/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/image/index.md"},s=Q("",8),n=o("r-img",{fallback:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv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wJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="},null,-1),g=[s,n];function l(t,c,i,r,B,d){return a(),E("div",null,g)}const C=A(e,[["render",l]]);export{I as __pageData,C as default}; +import{_ as A,o as a,c as E,N as Q,x as o}from"./chunks/framework.6fe2e870.js";const I=JSON.parse('{"title":"Image 图片","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/image/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/image/index.md"},s=Q("",8),n=o("r-img",{fallback:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAAB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bUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="},null,-1),g=[s,n];function l(t,c,i,r,B,d){return a(),E("div",null,g)}const C=A(e,[["render",l]]);export{I as __pageData,C as default}; diff --git a/assets/src_ranui_index.md.dd236557.js b/assets/src_ranui_index.md.fd55dba2.js similarity index 98% rename from assets/src_ranui_index.md.dd236557.js rename to assets/src_ranui_index.md.fd55dba2.js index 0454a0c5f..deea477de 100644 --- a/assets/src_ranui_index.md.dd236557.js +++ b/assets/src_ranui_index.md.fd55dba2.js @@ -1,4 +1,4 @@ -import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/customElements.ed27d2e2.png",w=JSON.parse('{"title":"ranui","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/index.md"},t=a(`

      ranui

      基于 Web Components UI组件库

      Feature 特点

      1. 基于Web Components开发,跨框架复用,统一所有情况。
      2. TypeScript开发,有声明和类型文件。
      3. 纯原生手写,基础组件无依赖。
      4. 文档基于vitepress,所有组件实例可交互。
      5. MIT协议。

      Situation 项目情况

      Build Statusnpm-vnpm-dbrotlimodule formats: umd, esm

      Usage 使用

      大多数情况都可以像原生的 div 标签一样使用。

      接下来是一些使用例子

      1. html
      2. js
      3. jsx
      4. vue
      5. tsx

      1.html

      html
      <script src="./ranui/dist/umd/index.umd.cjs"></script>
      +import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/customElements.ed27d2e2.png",w=JSON.parse('{"title":"ranui","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/index.md"},t=a(`

      ranui

      基于 Web Components UI组件库

      Feature 特点

      1. 基于Web Components开发,跨框架复用,统一所有情况。
      2. TypeScript开发,有声明和类型文件。
      3. 纯原生手写,基础组件无依赖。
      4. 文档基于vitepress,所有组件实例可交互。
      5. MIT协议。

      Situation 项目情况

      Build Statusnpm-vnpm-dbrotlimodule formats: umd, esm

      Usage 使用

      大多数情况都可以像原生的 div 标签一样使用。

      接下来是一些使用例子

      1. html
      2. js
      3. jsx
      4. vue
      5. tsx

      1.html

      html
      <script src="./ranui/dist/umd/index.umd.cjs"></script>
       
       <body>
         <r-button>Button</r-button>
      @@ -78,10 +78,10 @@ import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";c
       import 'ranui/style'

      也可以全局导入,更加方便,这样什么都不用考虑了,梭哈完事。

      • ES module
      js
      import 'ranui'
      • UMD, IIFE, CJS
      html
      <script src="./ranui/dist/umd/index.umd.cjs"></script>

      Overview 组件总览

      • Button
      主要按钮
      警告按钮
      文本按钮
      默认按钮
      • Icon
      `,40),c=s("div",{style:{display:"flex"}},[s("r-icon",{name:"lock",size:"50"}),s("r-icon",{name:"user",size:"50"}),s("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:""})],-1),r=a('
      • Skeleton
      • Input
      • message
      ',9),F=s("r-button",{onclick:"message.info('这是一条提示')"},"信息提示",-1),y=s("r-button",{onclick:"message.warning('这是一条提示')"},"警告提示",-1),i=s("r-button",{onclick:"message.error('这是一条提示')"},"错误提示",-1),D=s("r-button",{onclick:"message.success('这是一条提示')"},"成功提示",-1),B=s("r-button",{onclick:"message.toast('这是一条提示')"},"toast 提示",-1),d=s("ul",null,[s("li",null,[s("code",null,"Tab")])],-1),u=s("div",{style:{display:"block","margin-right":"8px","margin-bottom":"12px"}},[s("r-tabs",null,[s("r-tab",{label:"home",icon:"home"},"tab1"),s("r-tab",{label:"message",icon:"message"},"tab2"),s("r-tab",{label:"user",icon:"user"},"tab3")])],-1),h=s("ul",null,[s("li",null,[s("code",null,"Radar")])],-1),m=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),E=a(`

      Event 事件

      HTML元素中,你可以使用on属性来定义事件处理程序。这是旧的事件处理程序的方法,现代的web开发推荐使用addEventListener方法。

      html
      <r-button id="button">按钮</r-button>
       
       <script>
      -  const button = document.getElementById('button');  
      -  button.addEventListener('click', function(event) {  
      -    alert('新的点击事件!');  
      -  });
      +  const button = document.getElementById('button')
      +  button.addEventListener('click', function (event) {
      +    alert('新的点击事件!')
      +  })
       </script>

      然而,如果你确实需要使用on属性,下面是一个示例:

      html
      <r-input onchange="change(this.value)"></r-input>
       
       <script>
      diff --git a/assets/src_ranui_index.md.dd236557.lean.js b/assets/src_ranui_index.md.fd55dba2.lean.js
      similarity index 96%
      rename from assets/src_ranui_index.md.dd236557.lean.js
      rename to assets/src_ranui_index.md.fd55dba2.lean.js
      index e6c4b0acd..94015750a 100644
      --- a/assets/src_ranui_index.md.dd236557.lean.js
      +++ b/assets/src_ranui_index.md.fd55dba2.lean.js
      @@ -1 +1 @@
      -import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/customElements.ed27d2e2.png",w=JSON.parse('{"title":"ranui","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/index.md"},t=a("",40),c=s("div",{style:{display:"flex"}},[s("r-icon",{name:"lock",size:"50"}),s("r-icon",{name:"user",size:"50"}),s("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:""})],-1),r=a("",9),F=s("r-button",{onclick:"message.info('这是一条提示')"},"信息提示",-1),y=s("r-button",{onclick:"message.warning('这是一条提示')"},"警告提示",-1),i=s("r-button",{onclick:"message.error('这是一条提示')"},"错误提示",-1),D=s("r-button",{onclick:"message.success('这是一条提示')"},"成功提示",-1),B=s("r-button",{onclick:"message.toast('这是一条提示')"},"toast 提示",-1),d=s("ul",null,[s("li",null,[s("code",null,"Tab")])],-1),u=s("div",{style:{display:"block","margin-right":"8px","margin-bottom":"12px"}},[s("r-tabs",null,[s("r-tab",{label:"home",icon:"home"},"tab1"),s("r-tab",{label:"message",icon:"message"},"tab2"),s("r-tab",{label:"user",icon:"user"},"tab3")])],-1),h=s("ul",null,[s("li",null,[s("code",null,"Radar")])],-1),m=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),E=a("",16),g=[t,c,r,F,y,i,D,B,d,u,h,m,E];function A(b,C,f,v,_,k){return l(),o("div",null,g)}const q=n(e,[["render",A]]);export{w as __pageData,q as default};
      +import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/customElements.ed27d2e2.png",w=JSON.parse('{"title":"ranui","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/index.md"},t=a("",40),c=s("div",{style:{display:"flex"}},[s("r-icon",{name:"lock",size:"50"}),s("r-icon",{name:"user",size:"50"}),s("r-icon",{name:"loading",size:"50",color:"#1E90FF",spin:""})],-1),r=a("",9),F=s("r-button",{onclick:"message.info('这是一条提示')"},"信息提示",-1),y=s("r-button",{onclick:"message.warning('这是一条提示')"},"警告提示",-1),i=s("r-button",{onclick:"message.error('这是一条提示')"},"错误提示",-1),D=s("r-button",{onclick:"message.success('这是一条提示')"},"成功提示",-1),B=s("r-button",{onclick:"message.toast('这是一条提示')"},"toast 提示",-1),d=s("ul",null,[s("li",null,[s("code",null,"Tab")])],-1),u=s("div",{style:{display:"block","margin-right":"8px","margin-bottom":"12px"}},[s("r-tabs",null,[s("r-tab",{label:"home",icon:"home"},"tab1"),s("r-tab",{label:"message",icon:"message"},"tab2"),s("r-tab",{label:"user",icon:"user"},"tab3")])],-1),h=s("ul",null,[s("li",null,[s("code",null,"Radar")])],-1),m=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),E=a("",16),g=[t,c,r,F,y,i,D,B,d,u,h,m,E];function A(b,C,f,v,_,k){return l(),o("div",null,g)}const q=n(e,[["render",A]]);export{w as __pageData,q as default};
      diff --git a/assets/src_ranui_input_index.md.648aa27c.js b/assets/src_ranui_input_index.md.12be9d3c.js
      similarity index 99%
      rename from assets/src_ranui_input_index.md.648aa27c.js
      rename to assets/src_ranui_input_index.md.12be9d3c.js
      index 2b34c1282..ab4073078 100644
      --- a/assets/src_ranui_input_index.md.648aa27c.js
      +++ b/assets/src_ranui_input_index.md.12be9d3c.js
      @@ -1,4 +1,4 @@
      -import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/input-input.f80a45d3.jpg",q=JSON.parse('{"title":"Input 输入框","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/input/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/input/index.md"},t=a('

      Input 输入框

      通过鼠标或键盘输入内容,是最基础的表单域的包装。

      代码演示

      输入框:
      xml
      <r-input></r-input>

      属性

      标签label

      提供类似于 Metiral Design 的输入体验。

      html
      <r-input label="user"></r-input>

      占位placeholder

      与原生placeholder一致。

      html
      <r-input placeholder="user"></r-input>

      禁用disabled

      通过disabled可以禁用输入框,禁用后该按钮上的事件失效。

      html
      <r-input label="user" disabled></r-input>

      value

      设置或返回输入框的value属性值。

      类型type

      目前支持passwordnumber这几种类型,设置后会出现额外的ui控件。

      密码输入框

      支持密码明文和密文切换。

      html
      <r-input icon="lock" type="password"></r-input>

      图标icon

      可以设置一个icon来表示标签标识。

      html
      <r-input icon="user"></r-input>

      数字输入框

      数字输入框,类似于原生input[type=number],支持minmaxstep属性,支持键盘上下键切换数字。

      html
      <r-input type="number" min="-10" max="10" step="0.5"></r-input>

      name 属性名

      跟 form 组件联动的时候有效,form 提交时收集的字段名字

      status 状态

      • error

      默认色值: #ff4d4f

      ',40),c=s("div",null,[s("r-input",{status:"error"})],-1),r=a('
      xml
      <r-input status="error"></r-input>
      • warning

      默认色值: #ff7875

      ',3),D=s("div",null,[s("r-input",{status:"warning"})],-1),i=a('
      xml
      <r-input  status="warning"></r-input>

      事件event

      常见的回调事件。

      onchange

      文本改变的时候触发。

      ',5),F=s("r-input",{onchange:"console.log(this.value)"},null,-1),y=a(`
      html
      <r-input onchange="func(this.value)"></r-input>
      js
      const input = document.createElement('r-input')
      +import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/input-input.f80a45d3.jpg",q=JSON.parse('{"title":"Input 输入框","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/input/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/input/index.md"},t=a('

      Input 输入框

      通过鼠标或键盘输入内容,是最基础的表单域的包装。

      代码演示

      输入框:
      xml
      <r-input></r-input>

      属性

      标签label

      提供类似于 Metiral Design 的输入体验。

      html
      <r-input label="user"></r-input>

      占位placeholder

      与原生placeholder一致。

      html
      <r-input placeholder="user"></r-input>

      禁用disabled

      通过disabled可以禁用输入框,禁用后该按钮上的事件失效。

      html
      <r-input label="user" disabled></r-input>

      value

      设置或返回输入框的value属性值。

      类型type

      目前支持passwordnumber这几种类型,设置后会出现额外的ui控件。

      密码输入框

      支持密码明文和密文切换。

      html
      <r-input icon="lock" type="password"></r-input>

      图标icon

      可以设置一个icon来表示标签标识。

      html
      <r-input icon="user"></r-input>

      数字输入框

      数字输入框,类似于原生input[type=number],支持minmaxstep属性,支持键盘上下键切换数字。

      html
      <r-input type="number" min="-10" max="10" step="0.5"></r-input>

      name 属性名

      跟 form 组件联动的时候有效,form 提交时收集的字段名字

      status 状态

      • error

      默认色值: #ff4d4f

      ',40),c=s("div",null,[s("r-input",{status:"error"})],-1),r=a('
      xml
      <r-input status="error"></r-input>
      • warning

      默认色值: #ff7875

      ',3),D=s("div",null,[s("r-input",{status:"warning"})],-1),i=a('
      xml
      <r-input  status="warning"></r-input>

      事件event

      常见的回调事件。

      onchange

      文本改变的时候触发。

      ',5),F=s("r-input",{onchange:"console.log(this.value)"},null,-1),y=a(`
      html
      <r-input onchange="func(this.value)"></r-input>
      js
      const input = document.createElement('r-input')
       input.setAttribute('label', 'home')
       const func = (e) => {
         console.log(e)
      diff --git a/assets/src_ranui_input_index.md.648aa27c.lean.js b/assets/src_ranui_input_index.md.12be9d3c.lean.js
      similarity index 91%
      rename from assets/src_ranui_input_index.md.648aa27c.lean.js
      rename to assets/src_ranui_input_index.md.12be9d3c.lean.js
      index de5e2a18f..d96ce34da 100644
      --- a/assets/src_ranui_input_index.md.648aa27c.lean.js
      +++ b/assets/src_ranui_input_index.md.12be9d3c.lean.js
      @@ -1 +1 @@
      -import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/input-input.f80a45d3.jpg",q=JSON.parse('{"title":"Input 输入框","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/input/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/input/index.md"},t=a("",40),c=s("div",null,[s("r-input",{status:"error"})],-1),r=a("",3),D=s("div",null,[s("r-input",{status:"warning"})],-1),i=a("",5),F=s("r-input",{onchange:"console.log(this.value)"},null,-1),y=a("",4),d=s("r-input",{oninput:"console.log(this.value)"},null,-1),u=a("",2),h=[t,c,r,D,i,F,y,d,u];function _(m,A,E,g,b,B){return l(),o("div",null,h)}const v=n(e,[["render",_]]);export{q as __pageData,v as default};
      +import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/input-input.f80a45d3.jpg",q=JSON.parse('{"title":"Input 输入框","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/input/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/input/index.md"},t=a("",40),c=s("div",null,[s("r-input",{status:"error"})],-1),r=a("",3),D=s("div",null,[s("r-input",{status:"warning"})],-1),i=a("",5),F=s("r-input",{onchange:"console.log(this.value)"},null,-1),y=a("",4),d=s("r-input",{oninput:"console.log(this.value)"},null,-1),u=a("",2),h=[t,c,r,D,i,F,y,d,u];function _(m,A,E,g,b,B){return l(),o("div",null,h)}const v=n(e,[["render",_]]);export{q as __pageData,v as default};
      diff --git a/assets/src_ranui_message_index.md.0f2c0223.js b/assets/src_ranui_message_index.md.0cd3b7b1.js
      similarity index 99%
      rename from assets/src_ranui_message_index.md.0f2c0223.js
      rename to assets/src_ranui_message_index.md.0cd3b7b1.js
      index acfddef2e..20e6e4c82 100644
      --- a/assets/src_ranui_message_index.md.0f2c0223.js
      +++ b/assets/src_ranui_message_index.md.0cd3b7b1.js
      @@ -1,4 +1,4 @@
      -import{_ as n,o as t,c as l,x as s,a as o,N as a}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"message 全局提示","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/message/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/message/index.md"},p=s("h1",{id:"message-全局提示",tabindex:"-1"},[o("message 全局提示 "),s("a",{class:"header-anchor",href:"#message-全局提示","aria-label":'Permalink to "message 全局提示"'},"​")],-1),c=s("p",null,"全局展示操作反馈信息。",-1),r=s("h2",{id:"代码演示",tabindex:"-1"},[o("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),D=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{type:"primary",onclick:"message.info('这是一条提示')"},"点击触发全局提示")],-1),F=a('
      xml
      <r-button type="primary" onclick="message.info('这是一条提示')">点击触发全局提示</r-button>

      属性

      类型type

      不同的提示类型

      ',4),i=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.info('这是一条提示')"},"信息提示")],-1),y=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.warning('这是一条提示')"},"警告提示")],-1),d=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.error('这是一条提示')"},"错误提示")],-1),g=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.success('这是一条提示')"},"成功提示")],-1),m=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.toast('这是一条提示')"},"toast提示")],-1),u=a(`
      html
      <r-button onclick="message.info('这是一条提示')">信息提示</r-button>
      +import{_ as n,o as t,c as l,x as s,a as o,N as a}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"message 全局提示","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/message/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/message/index.md"},p=s("h1",{id:"message-全局提示",tabindex:"-1"},[o("message 全局提示 "),s("a",{class:"header-anchor",href:"#message-全局提示","aria-label":'Permalink to "message 全局提示"'},"​")],-1),c=s("p",null,"全局展示操作反馈信息。",-1),r=s("h2",{id:"代码演示",tabindex:"-1"},[o("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),D=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{type:"primary",onclick:"message.info('这是一条提示')"},"点击触发全局提示")],-1),F=a('
      xml
      <r-button type="primary" onclick="message.info('这是一条提示')">点击触发全局提示</r-button>

      属性

      类型type

      不同的提示类型

      ',4),i=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.info('这是一条提示')"},"信息提示")],-1),y=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.warning('这是一条提示')"},"警告提示")],-1),d=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.error('这是一条提示')"},"错误提示")],-1),g=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.success('这是一条提示')"},"成功提示")],-1),m=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.toast('这是一条提示')"},"toast提示")],-1),u=a(`
      html
      <r-button onclick="message.info('这是一条提示')">信息提示</r-button>
       <r-button onclick="message.warning('这是一条提示')">警告提示</r-button>
       <r-button onclick="message.error('这是一条提示')">错误提示</r-button>
       <r-button onclick="message.success('这是一条提示')">成功提示</r-button>
      diff --git a/assets/src_ranui_message_index.md.0f2c0223.lean.js b/assets/src_ranui_message_index.md.0cd3b7b1.lean.js
      similarity index 96%
      rename from assets/src_ranui_message_index.md.0f2c0223.lean.js
      rename to assets/src_ranui_message_index.md.0cd3b7b1.lean.js
      index 689fae3c6..d90e0038b 100644
      --- a/assets/src_ranui_message_index.md.0f2c0223.lean.js
      +++ b/assets/src_ranui_message_index.md.0cd3b7b1.lean.js
      @@ -1 +1 @@
      -import{_ as n,o as t,c as l,x as s,a as o,N as a}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"message 全局提示","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/message/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/message/index.md"},p=s("h1",{id:"message-全局提示",tabindex:"-1"},[o("message 全局提示 "),s("a",{class:"header-anchor",href:"#message-全局提示","aria-label":'Permalink to "message 全局提示"'},"​")],-1),c=s("p",null,"全局展示操作反馈信息。",-1),r=s("h2",{id:"代码演示",tabindex:"-1"},[o("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),D=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{type:"primary",onclick:"message.info('这是一条提示')"},"点击触发全局提示")],-1),F=a("",4),i=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.info('这是一条提示')"},"信息提示")],-1),y=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.warning('这是一条提示')"},"警告提示")],-1),d=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.error('这是一条提示')"},"错误提示")],-1),g=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.success('这是一条提示')"},"成功提示")],-1),m=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.toast('这是一条提示')"},"toast提示")],-1),u=a("",16),h=[p,c,r,D,F,i,y,d,g,m,u];function _(b,E,A,C,k,x){return t(),l("div",null,h)}const f=n(e,[["render",_]]);export{q as __pageData,f as default};
      +import{_ as n,o as t,c as l,x as s,a as o,N as a}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"message 全局提示","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/message/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/message/index.md"},p=s("h1",{id:"message-全局提示",tabindex:"-1"},[o("message 全局提示 "),s("a",{class:"header-anchor",href:"#message-全局提示","aria-label":'Permalink to "message 全局提示"'},"​")],-1),c=s("p",null,"全局展示操作反馈信息。",-1),r=s("h2",{id:"代码演示",tabindex:"-1"},[o("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),D=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{type:"primary",onclick:"message.info('这是一条提示')"},"点击触发全局提示")],-1),F=a("",4),i=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.info('这是一条提示')"},"信息提示")],-1),y=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.warning('这是一条提示')"},"警告提示")],-1),d=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.error('这是一条提示')"},"错误提示")],-1),g=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.success('这是一条提示')"},"成功提示")],-1),m=s("div",{style:{display:"inline-block","margin-right":"8px","margin-bottom":"12px"}},[s("r-button",{onclick:"message.toast('这是一条提示')"},"toast提示")],-1),u=a("",16),h=[p,c,r,D,F,i,y,d,g,m,u];function _(b,E,A,C,k,x){return t(),l("div",null,h)}const f=n(e,[["render",_]]);export{q as __pageData,f as default};
      diff --git a/assets/src_ranui_modal_index.md.8a1d5440.js b/assets/src_ranui_modal_index.md.528db34a.js
      similarity index 82%
      rename from assets/src_ranui_modal_index.md.8a1d5440.js
      rename to assets/src_ranui_modal_index.md.528db34a.js
      index bd0c1e780..cd553924f 100644
      --- a/assets/src_ranui_modal_index.md.8a1d5440.js
      +++ b/assets/src_ranui_modal_index.md.528db34a.js
      @@ -1 +1 @@
      -import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/modal/index.md","lastUpdated":1694741410000}'),r={name:"src/ranui/modal/index.md"};function n(o,s,c,d,i,p){return t(),a("div")}const l=e(r,[["render",n]]);export{m as __pageData,l as default};
      +import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/modal/index.md","lastUpdated":1695392177000}'),r={name:"src/ranui/modal/index.md"};function n(o,s,c,d,i,p){return t(),a("div")}const l=e(r,[["render",n]]);export{m as __pageData,l as default};
      diff --git a/assets/src_ranui_modal_index.md.8a1d5440.lean.js b/assets/src_ranui_modal_index.md.528db34a.lean.js
      similarity index 82%
      rename from assets/src_ranui_modal_index.md.8a1d5440.lean.js
      rename to assets/src_ranui_modal_index.md.528db34a.lean.js
      index bd0c1e780..cd553924f 100644
      --- a/assets/src_ranui_modal_index.md.8a1d5440.lean.js
      +++ b/assets/src_ranui_modal_index.md.528db34a.lean.js
      @@ -1 +1 @@
      -import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/modal/index.md","lastUpdated":1694741410000}'),r={name:"src/ranui/modal/index.md"};function n(o,s,c,d,i,p){return t(),a("div")}const l=e(r,[["render",n]]);export{m as __pageData,l as default};
      +import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/modal/index.md","lastUpdated":1695392177000}'),r={name:"src/ranui/modal/index.md"};function n(o,s,c,d,i,p){return t(),a("div")}const l=e(r,[["render",n]]);export{m as __pageData,l as default};
      diff --git a/assets/src_ranui_preview_index.md.df81865f.js b/assets/src_ranui_preview_index.md.63eefe48.js
      similarity index 99%
      rename from assets/src_ranui_preview_index.md.df81865f.js
      rename to assets/src_ranui_preview_index.md.63eefe48.js
      index a614a61fb..05bc8a37d 100644
      --- a/assets/src_ranui_preview_index.md.df81865f.js
      +++ b/assets/src_ranui_preview_index.md.63eefe48.js
      @@ -1,4 +1,4 @@
      -import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"preview 文件预览","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/preview/index.md","lastUpdated":1694741410000}'),p={name:"src/ranui/preview/index.md"},e=a('

      preview 文件预览

      支持docxpptxpdf,xlsx文件的预览

      代码演示

      ',3),t=s("div",{style:{width:"100px","margin-top":"10px"}},[s("r-preview",{id:"preview"}),s("r-button",{type:"primary",onclick:"uploadFile('preview')"},"choose file to preview")],-1),c=a(`
      html
      <r-preview id="preview"></r-preview>
      +import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"preview 文件预览","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/preview/index.md","lastUpdated":1695392177000}'),p={name:"src/ranui/preview/index.md"},e=a('

      preview 文件预览

      支持docxpptxpdf,xlsx文件的预览

      代码演示

      ',3),t=s("div",{style:{width:"100px","margin-top":"10px"}},[s("r-preview",{id:"preview"}),s("r-button",{type:"primary",onclick:"uploadFile('preview')"},"choose file to preview")],-1),c=a(`
      html
      <r-preview id="preview"></r-preview>
       <r-button type="primary" onclick="uploadFile()"
         >choose file to preview</r-button
       >
      diff --git a/assets/src_ranui_preview_index.md.df81865f.lean.js b/assets/src_ranui_preview_index.md.63eefe48.lean.js
      similarity index 89%
      rename from assets/src_ranui_preview_index.md.df81865f.lean.js
      rename to assets/src_ranui_preview_index.md.63eefe48.lean.js
      index c80fda4fe..42e5cb154 100644
      --- a/assets/src_ranui_preview_index.md.df81865f.lean.js
      +++ b/assets/src_ranui_preview_index.md.63eefe48.lean.js
      @@ -1 +1 @@
      -import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"preview 文件预览","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/preview/index.md","lastUpdated":1694741410000}'),p={name:"src/ranui/preview/index.md"},e=a("",3),t=s("div",{style:{width:"100px","margin-top":"10px"}},[s("r-preview",{id:"preview"}),s("r-button",{type:"primary",onclick:"uploadFile('preview')"},"choose file to preview")],-1),c=a("",8),r=[e,t,c];function F(y,D,i,d,A,u){return l(),o("div",null,r)}const h=n(p,[["render",F]]);export{E as __pageData,h as default};
      +import{_ as n,o as l,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"preview 文件预览","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/preview/index.md","lastUpdated":1695392177000}'),p={name:"src/ranui/preview/index.md"},e=a("",3),t=s("div",{style:{width:"100px","margin-top":"10px"}},[s("r-preview",{id:"preview"}),s("r-button",{type:"primary",onclick:"uploadFile('preview')"},"choose file to preview")],-1),c=a("",8),r=[e,t,c];function F(y,D,i,d,A,u){return l(),o("div",null,r)}const h=n(p,[["render",F]]);export{E as __pageData,h as default};
      diff --git a/assets/src_ranui_radar_index.md.98db9ce7.lean.js b/assets/src_ranui_radar_index.md.98db9ce7.lean.js
      deleted file mode 100644
      index cce58c410..000000000
      --- a/assets/src_ranui_radar_index.md.98db9ce7.lean.js
      +++ /dev/null
      @@ -1 +0,0 @@
      -import{_ as t,o as l,c as n,x as s,a,N as o}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"Radar 雷达图","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/radar/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/radar/index.md"},p=s("h1",{id:"radar-雷达图",tabindex:"-1"},[a("Radar 雷达图 "),s("a",{class:"header-anchor",href:"#radar-雷达图","aria-label":'Permalink to "Radar 雷达图"'},"​")],-1),r=s("p",null,"以二维形式综合对比多组数据的差异,常用于比较2组或更多组数据集",-1),c=s("h2",{id:"代码演示",tabindex:"-1"},[a("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),u=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),D=o("",5),y=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),i=o("",2),q=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorPolygon:"green",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),F=o("",2),d=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorLine:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),b=o("",2),m=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},fillColor:"red",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),h=o("",2),_=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},strokeColor:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),C=o("",4),E=[p,r,c,u,D,y,i,q,F,d,b,m,h,_,C];function N(R,A,g,B,x,k){return l(),n("div",null,E)}const S=t(e,[["render",N]]);export{f as __pageData,S as default};
      diff --git a/assets/src_ranui_radar_index.md.98db9ce7.js b/assets/src_ranui_radar_index.md.9aef7e94.js
      similarity index 61%
      rename from assets/src_ranui_radar_index.md.98db9ce7.js
      rename to assets/src_ranui_radar_index.md.9aef7e94.js
      index 822754039..0d099e781 100644
      --- a/assets/src_ranui_radar_index.md.98db9ce7.js
      +++ b/assets/src_ranui_radar_index.md.9aef7e94.js
      @@ -1,55 +1,55 @@
      -import{_ as t,o as l,c as n,x as s,a,N as o}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"Radar 雷达图","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/radar/index.md","lastUpdated":1694741410000}'),e={name:"src/ranui/radar/index.md"},p=s("h1",{id:"radar-雷达图",tabindex:"-1"},[a("Radar 雷达图 "),s("a",{class:"header-anchor",href:"#radar-雷达图","aria-label":'Permalink to "Radar 雷达图"'},"​")],-1),r=s("p",null,"以二维形式综合对比多组数据的差异,常用于比较2组或更多组数据集",-1),c=s("h2",{id:"代码演示",tabindex:"-1"},[a("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),u=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),D=o(`
      xml
      <r-radar 
      +import{_ as t,o as l,c as n,x as s,a,N as o}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"Radar 雷达图","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/radar/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/radar/index.md"},p=s("h1",{id:"radar-雷达图",tabindex:"-1"},[a("Radar 雷达图 "),s("a",{class:"header-anchor",href:"#radar-雷达图","aria-label":'Permalink to "Radar 雷达图"'},"​")],-1),r=s("p",null,"以二维形式综合对比多组数据的差异,常用于比较 2 组或更多组数据集",-1),c=s("h2",{id:"代码演示",tabindex:"-1"},[a("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),u=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),D=o(`
      xml
      <r-radar
           abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
      -    style="width:300px;height:300px;display: block;" 
      +    style="width:300px;height:300px;display: block;"
       >
      -</r-radar>

      属性

      需要展示的数据abilitys

      一个数组对象,对象中属性如下

      参数说明类型
      abilityName展示的属性名称必传参数string
      scoreRate展示维度的数值,最大100必传参数number
      backgroundColor属性名称的背景颜色可选参数string
      fontSize属性名称的字体大小可选参数number
      fontFamily属性名称的字体可选参数string
      fontColor属性名称的字体颜色可选参数string
      `,5),y=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),i=o(`
      xml
      <r-radar 
      +</r-radar>

      属性

      需要展示的数据abilitys

      一个数组对象,对象中属性如下

      参数说明类型
      abilityName展示的属性名称必传参数string
      scoreRate展示维度的数值,最大 100必传参数number
      backgroundColor属性名称的背景颜色可选参数string
      fontSize属性名称的字体大小可选参数number
      fontFamily属性名称的字体可选参数string
      fontColor属性名称的字体颜色可选参数string
      `,5),y=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),i=o(`
      xml
      <r-radar
           abilitys='[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
           style="width:300px;height:300px;display: block;"
       >
      -</r-radar>

      多边形颜色colorPolygon

      `,2),q=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorPolygon:"green",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),F=o(`
      xml
      <r-radar 
      -    colorPolygon="green" 
      +</r-radar>

      多边形颜色colorPolygon

      `,2),q=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorPolygon:"green",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),F=o(`
      xml
      <r-radar
      +    colorPolygon="green"
           abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
           style="width:300px;height:300px;display: block;"
       >
      -</r-radar>

      顶点连线颜色colorLine

      `,2),d=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorLine:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),b=o(`
      xml
      <r-radar 
      -    colorLine="blue" 
      +</r-radar>

      顶点连线颜色colorLine

      `,2),d=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorLine:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),b=o(`
      xml
      <r-radar
      +    colorLine="blue"
           abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
      -></r-radar>

      数据渲染处的颜色fillColor

      `,2),m=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},fillColor:"red",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),h=o(`
      xml
      <r-radar 
      -    fillColor="red" 
      +></r-radar>

      数据渲染处的颜色fillColor

      `,2),m=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},fillColor:"red",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),h=o(`
      xml
      <r-radar
      +    fillColor="red"
           abilitys='[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
           style="width:300px;height:300px;display: block;"
       >
      -</r-radar>

      数据渲染处线和点的颜色strokeColor

      `,2),_=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},strokeColor:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),C=o(`
      xml
      <r-radar 
      -    strokeColor="blue"  
      +</r-radar>

      数据渲染处线和点的颜色strokeColor

      `,2),_=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},strokeColor:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),E=o(`
      xml
      <r-radar
      +    strokeColor="blue"
           abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
      -    style="width:300px;height:300px;display: block;" 
      +    style="width:300px;height:300px;display: block;"
       >
       </r-radar>

      使用的例子数据

      由于HTMlattribute只能获取string。因此需要传入的数据需要是json字符串格式,然后通过JSON.parse解析程数组对象,如果JSON格式有误,则无法解析。

      json
      [
      -    {
      -        "abilityName":"生命",
      -        "scoreRate":"10",
      -        "backgroundColor":"red",
      -        "fontSize":"30",
      -        "fontColor":"blue"
      -    },
      -    {
      -        "abilityName":"攻击",
      -        "scoreRate":"90"
      -    },
      -    {
      -        "abilityName":"防御",
      -        "scoreRate":"20"
      -    },
      -    {
      -        "abilityName":"元素精通",
      -        "scoreRate":"50"
      -    },
      -    {
      -        "abilityName":"暴击率",
      -        "scoreRate":"80"
      -    },
      -    {
      -        "abilityName":"暴击伤害",
      -        "scoreRate":"50"
      -    }
      -]
      `,4),E=[p,r,c,u,D,y,i,q,F,d,b,m,h,_,C];function N(R,A,g,B,x,k){return l(),n("div",null,E)}const S=t(e,[["render",N]]);export{f as __pageData,S as default}; + { + "abilityName": "生命", + "scoreRate": "10", + "backgroundColor": "red", + "fontSize": "30", + "fontColor": "blue" + }, + { + "abilityName": "攻击", + "scoreRate": "90" + }, + { + "abilityName": "防御", + "scoreRate": "20" + }, + { + "abilityName": "元素精通", + "scoreRate": "50" + }, + { + "abilityName": "暴击率", + "scoreRate": "80" + }, + { + "abilityName": "暴击伤害", + "scoreRate": "50" + } +]
      `,4),C=[p,r,c,u,D,y,i,q,F,d,b,m,h,_,E];function N(A,R,B,g,x,k){return l(),n("div",null,C)}const S=t(e,[["render",N]]);export{f as __pageData,S as default}; diff --git a/assets/src_ranui_radar_index.md.9aef7e94.lean.js b/assets/src_ranui_radar_index.md.9aef7e94.lean.js new file mode 100644 index 000000000..968d5bc16 --- /dev/null +++ b/assets/src_ranui_radar_index.md.9aef7e94.lean.js @@ -0,0 +1 @@ +import{_ as t,o as l,c as n,x as s,a,N as o}from"./chunks/framework.6fe2e870.js";const f=JSON.parse('{"title":"Radar 雷达图","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/radar/index.md","lastUpdated":1695392177000}'),e={name:"src/ranui/radar/index.md"},p=s("h1",{id:"radar-雷达图",tabindex:"-1"},[a("Radar 雷达图 "),s("a",{class:"header-anchor",href:"#radar-雷达图","aria-label":'Permalink to "Radar 雷达图"'},"​")],-1),r=s("p",null,"以二维形式综合对比多组数据的差异,常用于比较 2 组或更多组数据集",-1),c=s("h2",{id:"代码演示",tabindex:"-1"},[a("代码演示 "),s("a",{class:"header-anchor",href:"#代码演示","aria-label":'Permalink to "代码演示"'},"​")],-1),u=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),D=o("",5),y=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},abilitys:'[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),i=o("",2),q=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorPolygon:"green",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),F=o("",2),d=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},colorLine:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),b=o("",2),m=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},fillColor:"red",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),h=o("",2),_=s("r-radar",{style:{width:"300px",height:"300px",display:"block"},strokeColor:"blue",abilitys:'[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'},null,-1),E=o("",4),C=[p,r,c,u,D,y,i,q,F,d,b,m,h,_,E];function N(A,R,B,g,x,k){return l(),n("div",null,C)}const S=t(e,[["render",N]]);export{f as __pageData,S as default}; diff --git a/assets/src_ranui_skeleton_index.md.71efc826.js b/assets/src_ranui_skeleton_index.md.018b869c.js similarity index 95% rename from assets/src_ranui_skeleton_index.md.71efc826.js rename to assets/src_ranui_skeleton_index.md.018b869c.js index e736e90b4..915bdeb60 100644 --- a/assets/src_ranui_skeleton_index.md.71efc826.js +++ b/assets/src_ranui_skeleton_index.md.018b869c.js @@ -1 +1 @@ -import{_ as e,o as t,c as s,N as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"skeleton 骨架屏","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/skeleton/index.md","lastUpdated":1694741410000}'),n={name:"src/ranui/skeleton/index.md"},o=a('

      skeleton 骨架屏

      在需要等待加载内容的位置提供一个占位图形组合。

      代码演示

      骨架长度跟随父级元素的长度

      xml
      <r-skeleton ></r-skeleton>
      ',9),l=[o];function r(i,p,c,d,_,k){return t(),s("div",null,l)}const x=e(n,[["render",r]]);export{m as __pageData,x as default}; +import{_ as e,o as t,c as s,N as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"skeleton 骨架屏","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/skeleton/index.md","lastUpdated":1695392177000}'),n={name:"src/ranui/skeleton/index.md"},o=a('

      skeleton 骨架屏

      在需要等待加载内容的位置提供一个占位图形组合。

      代码演示

      骨架长度跟随父级元素的长度

      xml
      <r-skeleton ></r-skeleton>
      ',9),l=[o];function r(i,p,c,d,_,k){return t(),s("div",null,l)}const x=e(n,[["render",r]]);export{m as __pageData,x as default}; diff --git a/assets/src_ranui_skeleton_index.md.71efc826.lean.js b/assets/src_ranui_skeleton_index.md.018b869c.lean.js similarity index 84% rename from assets/src_ranui_skeleton_index.md.71efc826.lean.js rename to assets/src_ranui_skeleton_index.md.018b869c.lean.js index d720c5eb1..8ef4aa823 100644 --- a/assets/src_ranui_skeleton_index.md.71efc826.lean.js +++ b/assets/src_ranui_skeleton_index.md.018b869c.lean.js @@ -1 +1 @@ -import{_ as e,o as t,c as s,N as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"skeleton 骨架屏","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/skeleton/index.md","lastUpdated":1694741410000}'),n={name:"src/ranui/skeleton/index.md"},o=a("",9),l=[o];function r(i,p,c,d,_,k){return t(),s("div",null,l)}const x=e(n,[["render",r]]);export{m as __pageData,x as default}; +import{_ as e,o as t,c as s,N as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"skeleton 骨架屏","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/skeleton/index.md","lastUpdated":1695392177000}'),n={name:"src/ranui/skeleton/index.md"},o=a("",9),l=[o];function r(i,p,c,d,_,k){return t(),s("div",null,l)}const x=e(n,[["render",r]]);export{m as __pageData,x as default}; diff --git a/assets/src_ranui_tab_index.md.17f1ce4b.js b/assets/src_ranui_tab_index.md.7cc8e01b.js similarity index 99% rename from assets/src_ranui_tab_index.md.17f1ce4b.js rename to assets/src_ranui_tab_index.md.7cc8e01b.js index bb0ee59dc..ae3c027e4 100644 --- a/assets/src_ranui_tab_index.md.17f1ce4b.js +++ b/assets/src_ranui_tab_index.md.7cc8e01b.js @@ -1,4 +1,4 @@ -import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"Tab 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tab/index.md","lastUpdated":1694741410000}'),p={name:"src/ranui/tab/index.md"},t=a(`

      Tab 图标

      标签页,其中r-tab需要和r-tabs搭配使用

      代码演示

      111112222233333
      xml
      <r-tabs >
      +import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"Tab 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tab/index.md","lastUpdated":1695392177000}'),p={name:"src/ranui/tab/index.md"},t=a(`

      Tab 图标

      标签页,其中r-tab需要和r-tabs搭配使用

      代码演示

      111112222233333
      xml
      <r-tabs >
             <r-tab label="tab1">11111</r-tab>
             <r-tab label="tab2">22222</r-tab>
             <r-tab label="tab3">33333</r-tab>
      diff --git a/assets/src_ranui_tab_index.md.17f1ce4b.lean.js b/assets/src_ranui_tab_index.md.7cc8e01b.lean.js
      similarity index 94%
      rename from assets/src_ranui_tab_index.md.17f1ce4b.lean.js
      rename to assets/src_ranui_tab_index.md.7cc8e01b.lean.js
      index 272823719..636907d65 100644
      --- a/assets/src_ranui_tab_index.md.17f1ce4b.lean.js
      +++ b/assets/src_ranui_tab_index.md.7cc8e01b.lean.js
      @@ -1 +1 @@
      -import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"Tab 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tab/index.md","lastUpdated":1694741410000}'),p={name:"src/ranui/tab/index.md"},t=a("",13),e=s("div",{style:{width:"100%"}},[s("r-tabs",{active:"1"},[s("r-tab",{label:"tab1"},"11111"),s("r-tab",{label:"tab2"},"22222"),s("r-tab",{label:"tab3"},"33333")])],-1),r=a("",2),c=s("div",{style:{width:"100%"}},[s("r-tabs",{active:"c"},[s("r-tab",{label:"tab1",ranKey:"a"},"11111"),s("r-tab",{label:"tab2",ranKey:"b"},"22222"),s("r-tab",{label:"tab3",ranKey:"c"},"33333"),s("r-tab",{label:"tab4"},"4")])],-1),D=a("",3),F=s("div",{style:{width:"100%"}},[s("r-tabs",{active:"c"},[s("r-tab",{label:"tab1",ranKey:"a",disabled:""},"11111"),s("r-tab",{label:"tab2",ranKey:"b"},"22222"),s("r-tab",{label:"tab3",ranKey:"c"},"33333"),s("r-tab",{label:"tab4"},"4")])],-1),y=a("",20),b=[t,e,r,c,D,F,y];function i(d,E,u,B,g,A){return n(),o("div",null,b)}const h=l(p,[["render",i]]);export{q as __pageData,h as default};
      +import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const q=JSON.parse('{"title":"Tab 图标","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tab/index.md","lastUpdated":1695392177000}'),p={name:"src/ranui/tab/index.md"},t=a("",13),e=s("div",{style:{width:"100%"}},[s("r-tabs",{active:"1"},[s("r-tab",{label:"tab1"},"11111"),s("r-tab",{label:"tab2"},"22222"),s("r-tab",{label:"tab3"},"33333")])],-1),r=a("",2),c=s("div",{style:{width:"100%"}},[s("r-tabs",{active:"c"},[s("r-tab",{label:"tab1",ranKey:"a"},"11111"),s("r-tab",{label:"tab2",ranKey:"b"},"22222"),s("r-tab",{label:"tab3",ranKey:"c"},"33333"),s("r-tab",{label:"tab4"},"4")])],-1),D=a("",3),F=s("div",{style:{width:"100%"}},[s("r-tabs",{active:"c"},[s("r-tab",{label:"tab1",ranKey:"a",disabled:""},"11111"),s("r-tab",{label:"tab2",ranKey:"b"},"22222"),s("r-tab",{label:"tab3",ranKey:"c"},"33333"),s("r-tab",{label:"tab4"},"4")])],-1),y=a("",20),b=[t,e,r,c,D,F,y];function i(d,E,u,B,g,A){return n(),o("div",null,b)}const h=l(p,[["render",i]]);export{q as __pageData,h as default};
      diff --git a/assets/src_ranui_tabs_index.md.9404d616.js b/assets/src_ranui_tabs_index.md.d1c61126.js
      similarity index 99%
      rename from assets/src_ranui_tabs_index.md.9404d616.js
      rename to assets/src_ranui_tabs_index.md.d1c61126.js
      index 15d550510..c776ae380 100644
      --- a/assets/src_ranui_tabs_index.md.9404d616.js
      +++ b/assets/src_ranui_tabs_index.md.d1c61126.js
      @@ -1,4 +1,4 @@
      -import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Tab","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tabs/index.md","lastUpdated":1694741410000}'),p={name:"src/ranui/tabs/index.md"},t=a(`

      Tab

      代码展示

      tab1tab2tab3
      xml
      <r-tabs>
      +import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Tab","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tabs/index.md","lastUpdated":1695392177000}'),p={name:"src/ranui/tabs/index.md"},t=a(`

      Tab

      代码展示

      tab1tab2tab3
      xml
      <r-tabs>
           <r-tab label="tab1">tab1</r-tab>
           <r-tab label="tab2">tab2</r-tab>
           <r-tab label="tab3">tab3</r-tab>
      diff --git a/assets/src_ranui_tabs_index.md.9404d616.lean.js b/assets/src_ranui_tabs_index.md.d1c61126.lean.js
      similarity index 91%
      rename from assets/src_ranui_tabs_index.md.9404d616.lean.js
      rename to assets/src_ranui_tabs_index.md.d1c61126.lean.js
      index 012aa69b8..8fe829d72 100644
      --- a/assets/src_ranui_tabs_index.md.9404d616.lean.js
      +++ b/assets/src_ranui_tabs_index.md.d1c61126.lean.js
      @@ -1 +1 @@
      -import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Tab","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tabs/index.md","lastUpdated":1694741410000}'),p={name:"src/ranui/tabs/index.md"},t=a("",16),e=s("r-tabs",{active:"B"},[s("r-tab",{label:"tab1","r-key":"A"},"tab1"),s("r-tab",{label:"tab2","r-key":"B"},"tab2"),s("r-tab",{label:"tab3","r-key":"C"},"tab3")],-1),c=a("",6),r=s("r-tabs",null,[s("r-tab",{icon:"home",iconSize:"22"},"tab1"),s("r-tab",{icon:"message",iconSize:"22"},"tab2"),s("r-tab",{icon:"user",iconSize:"22"},"tab3")],-1),D=a("",7),F=[t,e,c,r,D];function y(b,i,d,u,h,E){return n(),o("div",null,F)}const q=l(p,[["render",y]]);export{B as __pageData,q as default};
      +import{_ as l,o as n,c as o,N as a,x as s}from"./chunks/framework.6fe2e870.js";const B=JSON.parse('{"title":"Tab","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranui/tabs/index.md","lastUpdated":1695392177000}'),p={name:"src/ranui/tabs/index.md"},t=a("",16),e=s("r-tabs",{active:"B"},[s("r-tab",{label:"tab1","r-key":"A"},"tab1"),s("r-tab",{label:"tab2","r-key":"B"},"tab2"),s("r-tab",{label:"tab3","r-key":"C"},"tab3")],-1),c=a("",6),r=s("r-tabs",null,[s("r-tab",{icon:"home",iconSize:"22"},"tab1"),s("r-tab",{icon:"message",iconSize:"22"},"tab2"),s("r-tab",{icon:"user",iconSize:"22"},"tab3")],-1),D=a("",7),F=[t,e,c,r,D];function y(b,i,d,u,h,E){return n(),o("div",null,F)}const q=l(p,[["render",y]]);export{B as __pageData,q as default};
      diff --git a/assets/src_ranuts_binaryTree_index.md.bfc58cc9.js b/assets/src_ranuts_binaryTree_index.md.355ccc5a.js
      similarity index 99%
      rename from assets/src_ranuts_binaryTree_index.md.bfc58cc9.js
      rename to assets/src_ranuts_binaryTree_index.md.355ccc5a.js
      index 60ea7a240..450498979 100644
      --- a/assets/src_ranuts_binaryTree_index.md.bfc58cc9.js
      +++ b/assets/src_ranuts_binaryTree_index.md.355ccc5a.js
      @@ -1 +1 @@
      -import{_ as a,o as e,c as r,N as i}from"./chunks/framework.6fe2e870.js";const t="/ran/assets/balanceTree.3d01d012.png",m=JSON.parse('{"title":"二叉树的定义","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/binaryTree/index.md","lastUpdated":1694741410000}'),h={name:"src/ranuts/binaryTree/index.md"},l=i('

      二叉树的定义

      在计算机科学中,二叉树(Binary tree)是每个节点最多只有两个分支(即不存在分支度大于 2 的节点)的树结构。通常分支被称作“左子树”或“右子树”。二叉树的分支具有左右次序,不能随意颠倒[1]。。

      二叉树的性质

      • 在二叉树的第 i 层上最多有 2^(i-1)个结点(i>=1)
      • 深度为 h 的二叉树,最多有 2^h-1 个结点,最少有 h 个结点(h>=1)
      • 包含 n 个结点的二叉树的高度至少为(log2n)+1
      • 非空的二叉树,分支度为 0 的总数为 n0,分支度为 2 的总数为 n2,则 n0=n2+1
      • 二叉树的总结点数 n = n1 + n2 + n0
      • 总连线数等于总节点数减一(B = n - 1)
      • 总连线数等于分支度为 2 的节点的两倍加上分支度为 1 的节点(B = n2 _ 2 + n1 _ 1)

      二叉树的类型

      满二叉树

      一棵深度为 k 且有 2k-1 个节点的二叉树称为满二叉树。 除最后一层无任何子节点外,每一层上的所有结点都有两个子结点的二叉树[2]

      完全二叉树

      一棵深度为 k 的有 n 个结点的二叉树,对树中的结点按从上至下、从左到右的顺序进行编号,如果编号为 i(1≤i≤n)的结点与满二叉树中编号为 i 的结点在二叉树中的位置相同,则这棵二叉树称为完全二叉树。

      二叉搜索树

      二叉搜索树(BST)又称二叉查找树或二叉排序树。它或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉排序树。

      平衡二叉树

      平衡二叉树(AVL)一定是二叉搜索树,且左子树和右子树的高度差的绝对值不超过 1。 平衡二叉树

      B 树

      B 树属于多叉树又名平衡多路查找树(查找路径不只两个)

      B+树

      B+树是 B 树的变体,也是一种多路搜索树。

      B*树

      B* 树是 B+树的变体,在 B+树的非根和非叶子结点再增加指向兄弟的指针;B* 树定义了非叶子结点关键字个数至少为(2/3)M,即块的最低使用率为 2/3(代替 B+树的 1/2)。B 树分配新结点的概率比 B+树要低,空间使用率更高;

      红黑树

      红黑树是一种平衡二叉查找树的变体,它的左右子树高差有可能大于 1,所以红黑树不是严格意义上的平衡二叉树(AVL),但对它进行平衡的代价较低, 其平均统计性能要强于 AVL 。

      遍历

      前序遍历

      后序遍历

      中序遍历

      层序遍历

      常见算法题

      镜像二叉树

      重建二叉树

      二叉树深度

      二叉树节点总数

      判断二叉树子结构

      输入两棵二叉树 A 和 B,判断 B 是不是 A 的子结构。(ps:约定空树不是任意一个树的子结构)

      参考文档

      1. 维基百科二叉树
      2. 百度百科满二叉树
      ',36),o=[l];function n(d,s,c,u,b,q){return e(),r("div",null,o)}const f=a(h,[["render",n]]);export{m as __pageData,f as default}; +import{_ as a,o as e,c as r,N as i}from"./chunks/framework.6fe2e870.js";const t="/ran/assets/balanceTree.3d01d012.png",m=JSON.parse('{"title":"二叉树的定义","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/binaryTree/index.md","lastUpdated":1695392177000}'),h={name:"src/ranuts/binaryTree/index.md"},l=i('

      二叉树的定义

      在计算机科学中,二叉树(Binary tree)是每个节点最多只有两个分支(即不存在分支度大于 2 的节点)的树结构。通常分支被称作“左子树”或“右子树”。二叉树的分支具有左右次序,不能随意颠倒[1]。。

      二叉树的性质

      • 在二叉树的第 i 层上最多有 2^(i-1)个结点(i>=1)
      • 深度为 h 的二叉树,最多有 2^h-1 个结点,最少有 h 个结点(h>=1)
      • 包含 n 个结点的二叉树的高度至少为(log2n)+1
      • 非空的二叉树,分支度为 0 的总数为 n0,分支度为 2 的总数为 n2,则 n0=n2+1
      • 二叉树的总结点数 n = n1 + n2 + n0
      • 总连线数等于总节点数减一(B = n - 1)
      • 总连线数等于分支度为 2 的节点的两倍加上分支度为 1 的节点(B = n2 _ 2 + n1 _ 1)

      二叉树的类型

      满二叉树

      一棵深度为 k 且有 2k-1 个节点的二叉树称为满二叉树。 除最后一层无任何子节点外,每一层上的所有结点都有两个子结点的二叉树[2]

      完全二叉树

      一棵深度为 k 的有 n 个结点的二叉树,对树中的结点按从上至下、从左到右的顺序进行编号,如果编号为 i(1≤i≤n)的结点与满二叉树中编号为 i 的结点在二叉树中的位置相同,则这棵二叉树称为完全二叉树。

      二叉搜索树

      二叉搜索树(BST)又称二叉查找树或二叉排序树。它或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉排序树。

      平衡二叉树

      平衡二叉树(AVL)一定是二叉搜索树,且左子树和右子树的高度差的绝对值不超过 1。 平衡二叉树

      B 树

      B 树属于多叉树又名平衡多路查找树(查找路径不只两个)

      B+树

      B+树是 B 树的变体,也是一种多路搜索树。

      B*树

      B* 树是 B+树的变体,在 B+树的非根和非叶子结点再增加指向兄弟的指针;B* 树定义了非叶子结点关键字个数至少为(2/3)M,即块的最低使用率为 2/3(代替 B+树的 1/2)。B 树分配新结点的概率比 B+树要低,空间使用率更高;

      红黑树

      红黑树是一种平衡二叉查找树的变体,它的左右子树高差有可能大于 1,所以红黑树不是严格意义上的平衡二叉树(AVL),但对它进行平衡的代价较低, 其平均统计性能要强于 AVL 。

      遍历

      前序遍历

      后序遍历

      中序遍历

      层序遍历

      常见算法题

      镜像二叉树

      重建二叉树

      二叉树深度

      二叉树节点总数

      判断二叉树子结构

      输入两棵二叉树 A 和 B,判断 B 是不是 A 的子结构。(ps:约定空树不是任意一个树的子结构)

      参考文档

      1. 维基百科二叉树
      2. 百度百科满二叉树
      ',36),o=[l];function n(d,s,c,u,b,q){return e(),r("div",null,o)}const f=a(h,[["render",n]]);export{m as __pageData,f as default}; diff --git a/assets/src_ranuts_binaryTree_index.md.bfc58cc9.lean.js b/assets/src_ranuts_binaryTree_index.md.355ccc5a.lean.js similarity index 86% rename from assets/src_ranuts_binaryTree_index.md.bfc58cc9.lean.js rename to assets/src_ranuts_binaryTree_index.md.355ccc5a.lean.js index 9bae9fea7..bf867cc1f 100644 --- a/assets/src_ranuts_binaryTree_index.md.bfc58cc9.lean.js +++ b/assets/src_ranuts_binaryTree_index.md.355ccc5a.lean.js @@ -1 +1 @@ -import{_ as a,o as e,c as r,N as i}from"./chunks/framework.6fe2e870.js";const t="/ran/assets/balanceTree.3d01d012.png",m=JSON.parse('{"title":"二叉树的定义","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/binaryTree/index.md","lastUpdated":1694741410000}'),h={name:"src/ranuts/binaryTree/index.md"},l=i("",36),o=[l];function n(d,s,c,u,b,q){return e(),r("div",null,o)}const f=a(h,[["render",n]]);export{m as __pageData,f as default}; +import{_ as a,o as e,c as r,N as i}from"./chunks/framework.6fe2e870.js";const t="/ran/assets/balanceTree.3d01d012.png",m=JSON.parse('{"title":"二叉树的定义","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/binaryTree/index.md","lastUpdated":1695392177000}'),h={name:"src/ranuts/binaryTree/index.md"},l=i("",36),o=[l];function n(d,s,c,u,b,q){return e(),r("div",null,o)}const f=a(h,[["render",n]]);export{m as __pageData,f as default}; diff --git a/assets/src_ranuts_bundler_index.md.f1a2bc24.js b/assets/src_ranuts_bundler_index.md.d8142e57.js similarity index 96% rename from assets/src_ranuts_bundler_index.md.f1a2bc24.js rename to assets/src_ranuts_bundler_index.md.d8142e57.js index 6357d091e..a31c1b1ac 100644 --- a/assets/src_ranuts_bundler_index.md.f1a2bc24.js +++ b/assets/src_ranuts_bundler_index.md.d8142e57.js @@ -1,4 +1,4 @@ -import{_ as n,o as s,c as a,N as e}from"./chunks/framework.6fe2e870.js";const l="/ran/assets/bundle.9ebe4911.png",m=JSON.parse('{"title":"Bundler","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/bundler/index.md","lastUpdated":1694741410000}'),t={name:"src/ranuts/bundler/index.md"},p=e(`

      Bundler

      Bundler的使用: 传入 options 参数

      function build(options: Options):Promise<Build> {
      +import{_ as n,o as s,c as a,N as e}from"./chunks/framework.6fe2e870.js";const l="/ran/assets/bundle.9ebe4911.png",m=JSON.parse('{"title":"Bundler","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/bundler/index.md","lastUpdated":1695392177000}'),t={name:"src/ranuts/bundler/index.md"},p=e(`

      Bundler

      Bundler的使用: 传入 options 参数

      function build(options: Options):Promise<Build> {
         const bundle = new Bundle({
           entry: options.input
         });
      diff --git a/assets/src_ranuts_bundler_index.md.f1a2bc24.lean.js b/assets/src_ranuts_bundler_index.md.d8142e57.lean.js
      similarity index 85%
      rename from assets/src_ranuts_bundler_index.md.f1a2bc24.lean.js
      rename to assets/src_ranuts_bundler_index.md.d8142e57.lean.js
      index 7ac0a7fde..a44285ad2 100644
      --- a/assets/src_ranuts_bundler_index.md.f1a2bc24.lean.js
      +++ b/assets/src_ranuts_bundler_index.md.d8142e57.lean.js
      @@ -1 +1 @@
      -import{_ as n,o as s,c as a,N as e}from"./chunks/framework.6fe2e870.js";const l="/ran/assets/bundle.9ebe4911.png",m=JSON.parse('{"title":"Bundler","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/bundler/index.md","lastUpdated":1694741410000}'),t={name:"src/ranuts/bundler/index.md"},p=e("",5),o=[p];function r(c,d,i,b,u,_){return s(),a("div",null,o)}const y=n(t,[["render",r]]);export{m as __pageData,y as default};
      +import{_ as n,o as s,c as a,N as e}from"./chunks/framework.6fe2e870.js";const l="/ran/assets/bundle.9ebe4911.png",m=JSON.parse('{"title":"Bundler","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/bundler/index.md","lastUpdated":1695392177000}'),t={name:"src/ranuts/bundler/index.md"},p=e("",5),o=[p];function r(c,d,i,b,u,_){return s(),a("div",null,o)}const y=n(t,[["render",r]]);export{m as __pageData,y as default};
      diff --git a/assets/src_ranuts_file_index.md.4a078d51.js b/assets/src_ranuts_file_index.md.c559e8ec.js
      similarity index 96%
      rename from assets/src_ranuts_file_index.md.4a078d51.js
      rename to assets/src_ranuts_file_index.md.c559e8ec.js
      index f894ffb39..469444c69 100644
      --- a/assets/src_ranuts_file_index.md.4a078d51.js
      +++ b/assets/src_ranuts_file_index.md.c559e8ec.js
      @@ -1 +1 @@
      -import{_ as t,o as e,c as a,N as d}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"文件操作函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/file/index.md","lastUpdated":1694741410000}'),r={name:"src/ranuts/file/index.md"},o=d('

      文件操作函数

      watchFile

      观察一个文件是否改变

      API

      Return

      • Promise
      参数说明类型描述
      status文件是否被改变booleantrue 文件改变 false 文件没变

      Options

      参数说明类型默认值
      path文件路径,需要监听的文件stringundefined
      interval监听文件改变的时间,单位毫秒。number20
      ',9),h=[o];function i(n,l,s,c,u,_){return e(),a("div",null,h)}const f=t(r,[["render",i]]);export{b as __pageData,f as default}; +import{_ as t,o as e,c as a,N as d}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"文件操作函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/file/index.md","lastUpdated":1695392177000}'),r={name:"src/ranuts/file/index.md"},o=d('

      文件操作函数

      watchFile

      观察一个文件是否改变

      API

      Return

      • Promise
      参数说明类型描述
      status文件是否被改变booleantrue 文件改变 false 文件没变

      Options

      参数说明类型默认值
      path文件路径,需要监听的文件stringundefined
      interval监听文件改变的时间,单位毫秒。number20
      ',9),h=[o];function i(n,l,s,c,u,_){return e(),a("div",null,h)}const f=t(r,[["render",i]]);export{b as __pageData,f as default}; diff --git a/assets/src_ranuts_file_index.md.4a078d51.lean.js b/assets/src_ranuts_file_index.md.c559e8ec.lean.js similarity index 84% rename from assets/src_ranuts_file_index.md.4a078d51.lean.js rename to assets/src_ranuts_file_index.md.c559e8ec.lean.js index 521e2b785..efc13ee5a 100644 --- a/assets/src_ranuts_file_index.md.4a078d51.lean.js +++ b/assets/src_ranuts_file_index.md.c559e8ec.lean.js @@ -1 +1 @@ -import{_ as t,o as e,c as a,N as d}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"文件操作函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/file/index.md","lastUpdated":1694741410000}'),r={name:"src/ranuts/file/index.md"},o=d("",9),h=[o];function i(n,l,s,c,u,_){return e(),a("div",null,h)}const f=t(r,[["render",i]]);export{b as __pageData,f as default}; +import{_ as t,o as e,c as a,N as d}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"文件操作函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/file/index.md","lastUpdated":1695392177000}'),r={name:"src/ranuts/file/index.md"},o=d("",9),h=[o];function i(n,l,s,c,u,_){return e(),a("div",null,h)}const f=t(r,[["render",i]]);export{b as __pageData,f as default}; diff --git a/assets/src_ranuts_index.md.04b76820.js b/assets/src_ranuts_index.md.9270416e.js similarity index 81% rename from assets/src_ranuts_index.md.04b76820.js rename to assets/src_ranuts_index.md.9270416e.js index 275fc129f..3adfe25ff 100644 --- a/assets/src_ranuts_index.md.04b76820.js +++ b/assets/src_ranuts_index.md.9270416e.js @@ -1 +1 @@ -import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/index.md","lastUpdated":1694741410000}'),r={name:"src/ranuts/index.md"};function s(n,c,o,d,i,p){return t(),a("div")}const f=e(r,[["render",s]]);export{m as __pageData,f as default}; +import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/index.md","lastUpdated":1695392177000}'),r={name:"src/ranuts/index.md"};function s(n,c,o,d,i,p){return t(),a("div")}const f=e(r,[["render",s]]);export{m as __pageData,f as default}; diff --git a/assets/src_ranuts_index.md.04b76820.lean.js b/assets/src_ranuts_index.md.9270416e.lean.js similarity index 81% rename from assets/src_ranuts_index.md.04b76820.lean.js rename to assets/src_ranuts_index.md.9270416e.lean.js index 275fc129f..3adfe25ff 100644 --- a/assets/src_ranuts_index.md.04b76820.lean.js +++ b/assets/src_ranuts_index.md.9270416e.lean.js @@ -1 +1 @@ -import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/index.md","lastUpdated":1694741410000}'),r={name:"src/ranuts/index.md"};function s(n,c,o,d,i,p){return t(),a("div")}const f=e(r,[["render",s]]);export{m as __pageData,f as default}; +import{_ as e,o as t,c as a}from"./chunks/framework.6fe2e870.js";const m=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/index.md","lastUpdated":1695392177000}'),r={name:"src/ranuts/index.md"};function s(n,c,o,d,i,p){return t(),a("div")}const f=e(r,[["render",s]]);export{m as __pageData,f as default}; diff --git a/assets/src_ranuts_sort_bubble_index.md.470927dd.js b/assets/src_ranuts_sort_bubble_index.md.652859bb.js similarity index 99% rename from assets/src_ranuts_sort_bubble_index.md.470927dd.js rename to assets/src_ranuts_sort_bubble_index.md.652859bb.js index 6c6377241..816808fd2 100644 --- a/assets/src_ranuts_sort_bubble_index.md.470927dd.js +++ b/assets/src_ranuts_sort_bubble_index.md.652859bb.js @@ -1,4 +1,4 @@ -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/bubble.287f9a70.gif",E=JSON.parse('{"title":"冒泡排序(Bubble Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bubble/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/bubble/index.md"},e=l('

      冒泡排序(Bubble Sort)

      冒泡排序是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果它们的顺序错误就把它们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由来是因为越小的元素会经由交换慢慢“浮”到数列的顶端。

      算法描述

      • 比较相邻的元素。如果第一个比第二个大,就交换它们两个;
      • 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对,这样在最后的元素应该会是最大的数;
      • 针对所有的元素重复以上的步骤,除了最后一个;
      • 重复步骤 1~3,直到排序完成。

      动图演示

      冒泡排序

      代码演示

      js
      function bubbleSort(arr) {
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/bubble.287f9a70.gif",E=JSON.parse('{"title":"冒泡排序(Bubble Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bubble/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/bubble/index.md"},e=l('

      冒泡排序(Bubble Sort)

      冒泡排序是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果它们的顺序错误就把它们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由来是因为越小的元素会经由交换慢慢“浮”到数列的顶端。

      算法描述

      • 比较相邻的元素。如果第一个比第二个大,就交换它们两个;
      • 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对,这样在最后的元素应该会是最大的数;
      • 针对所有的元素重复以上的步骤,除了最后一个;
      • 重复步骤 1~3,直到排序完成。

      动图演示

      冒泡排序

      代码演示

      js
      function bubbleSort(arr) {
         var len = arr.length
         for (var i = 0; i < len - 1; i++) {
           for (var j = 0; j < len - 1 - i; j++) {
      diff --git a/assets/src_ranuts_sort_bubble_index.md.470927dd.lean.js b/assets/src_ranuts_sort_bubble_index.md.652859bb.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_bubble_index.md.470927dd.lean.js
      rename to assets/src_ranuts_sort_bubble_index.md.652859bb.lean.js
      index 9bff8d933..a125f07db 100644
      --- a/assets/src_ranuts_sort_bubble_index.md.470927dd.lean.js
      +++ b/assets/src_ranuts_sort_bubble_index.md.652859bb.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/bubble.287f9a70.gif",E=JSON.parse('{"title":"冒泡排序(Bubble Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bubble/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/bubble/index.md"},e=l("",8),t=[e];function r(c,y,F,D,i,B){return a(),n("div",null,t)}const b=s(p,[["render",r]]);export{E as __pageData,b as default};
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/bubble.287f9a70.gif",E=JSON.parse('{"title":"冒泡排序(Bubble Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bubble/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/bubble/index.md"},e=l("",8),t=[e];function r(c,y,F,D,i,B){return a(),n("div",null,t)}const b=s(p,[["render",r]]);export{E as __pageData,b as default};
      diff --git a/assets/src_ranuts_sort_bucket_index.md.dda27ddc.js b/assets/src_ranuts_sort_bucket_index.md.d882f777.js
      similarity index 99%
      rename from assets/src_ranuts_sort_bucket_index.md.dda27ddc.js
      rename to assets/src_ranuts_sort_bucket_index.md.d882f777.js
      index 69b342a14..7e2612151 100644
      --- a/assets/src_ranuts_sort_bucket_index.md.dda27ddc.js
      +++ b/assets/src_ranuts_sort_bucket_index.md.d882f777.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"桶排序 (Bucket Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bucket/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/bucket/index.md"},o=l(`

      桶排序 (Bucket Sort)

      高效与否的关键在于这个分桶函数。将数据分到有限数量的桶里,每个桶再分别排序(有可能再使用别的排序算法或是以递归方式继续使用桶排序进行排)。

      算法描述

      • 设置一个定量的数组当作空桶;
      • 遍历输入数据,并且把数据一个一个放到对应的桶里去;
      • 对每个不是空的桶进行排序;
      • 从不是空的桶里把排好序的数据拼接起来。

      代码演示

      ts
      const count = (list: Array<number>, max: number = 100): Array<number> => {
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"桶排序 (Bucket Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bucket/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/bucket/index.md"},o=l(`

      桶排序 (Bucket Sort)

      高效与否的关键在于这个分桶函数。将数据分到有限数量的桶里,每个桶再分别排序(有可能再使用别的排序算法或是以递归方式继续使用桶排序进行排)。

      算法描述

      • 设置一个定量的数组当作空桶;
      • 遍历输入数据,并且把数据一个一个放到对应的桶里去;
      • 对每个不是空的桶进行排序;
      • 从不是空的桶里把排好序的数据拼接起来。

      代码演示

      ts
      const count = (list: Array<number>, max: number = 100): Array<number> => {
         const countList = new Array(max + 1)
         for (let i = 0; i < list.length; i++) {
           if (!countList[list[i]]) {
      diff --git a/assets/src_ranuts_sort_bucket_index.md.dda27ddc.lean.js b/assets/src_ranuts_sort_bucket_index.md.d882f777.lean.js
      similarity index 85%
      rename from assets/src_ranuts_sort_bucket_index.md.dda27ddc.lean.js
      rename to assets/src_ranuts_sort_bucket_index.md.d882f777.lean.js
      index 439ce7a09..7169664db 100644
      --- a/assets/src_ranuts_sort_bucket_index.md.dda27ddc.lean.js
      +++ b/assets/src_ranuts_sort_bucket_index.md.d882f777.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"桶排序 (Bucket Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bucket/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/bucket/index.md"},o=l("",8),t=[o];function e(c,r,y,F,D,B){return n(),a("div",null,t)}const E=s(p,[["render",e]]);export{A as __pageData,E as default};
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"桶排序 (Bucket Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/bucket/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/bucket/index.md"},o=l("",8),t=[o];function e(c,r,y,F,D,B){return n(),a("div",null,t)}const E=s(p,[["render",e]]);export{A as __pageData,E as default};
      diff --git a/assets/src_ranuts_sort_count_index.md.177b24c1.js b/assets/src_ranuts_sort_count_index.md.92c99ed2.js
      similarity index 99%
      rename from assets/src_ranuts_sort_count_index.md.177b24c1.js
      rename to assets/src_ranuts_sort_count_index.md.92c99ed2.js
      index bdb6b2406..b88ecf87c 100644
      --- a/assets/src_ranuts_sort_count_index.md.177b24c1.js
      +++ b/assets/src_ranuts_sort_count_index.md.92c99ed2.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/count.9e7ca98e.gif",E=JSON.parse('{"title":"计数排序( Count Sort )","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/count/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/count/index.md"},t=l('

      计数排序( Count Sort )

      计数排序(counting sort)就是一种牺牲内存空间来换取低时间复杂度的排序算法,同时它也是一种不基于比较的算法。这里的不基于比较指的是数组元素之间不存在比较大小的排序算法,我们知道,用分治法来解决排序问题最快也只能使算法的时间复杂度接近 Θ(nlogn),即基于比较的时间复杂度存在下界 Ω(nlog⁡n),而不基于比较的排序算法可以突破这一下界。

      算法描述

      • 找出待排序的数组中最大和最小的元素;
      • 统计数组中每个值为 i 的元素出现的次数,存入数组 C 的第 i 项;
      • 对所有的计数累加(从 C 中的第一个元素开始,每一项和前一项相加);
      • 反向填充目标数组:将每个元素 i 放在新数组的第 C(i)项,每放一个元素就将 C(i)减去 1。

      动图演示

      计数排序

      代码演示

      ts
      const getMax = (list: Array<number>) => {
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/count.9e7ca98e.gif",E=JSON.parse('{"title":"计数排序( Count Sort )","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/count/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/count/index.md"},t=l('

      计数排序( Count Sort )

      计数排序(counting sort)就是一种牺牲内存空间来换取低时间复杂度的排序算法,同时它也是一种不基于比较的算法。这里的不基于比较指的是数组元素之间不存在比较大小的排序算法,我们知道,用分治法来解决排序问题最快也只能使算法的时间复杂度接近 Θ(nlogn),即基于比较的时间复杂度存在下界 Ω(nlog⁡n),而不基于比较的排序算法可以突破这一下界。

      算法描述

      • 找出待排序的数组中最大和最小的元素;
      • 统计数组中每个值为 i 的元素出现的次数,存入数组 C 的第 i 项;
      • 对所有的计数累加(从 C 中的第一个元素开始,每一项和前一项相加);
      • 反向填充目标数组:将每个元素 i 放在新数组的第 C(i)项,每放一个元素就将 C(i)减去 1。

      动图演示

      计数排序

      代码演示

      ts
      const getMax = (list: Array<number>) => {
         let max = list[0]
         for (let i = 0; i < list.length; i++) {
           if (max < list[i]) {
      diff --git a/assets/src_ranuts_sort_count_index.md.177b24c1.lean.js b/assets/src_ranuts_sort_count_index.md.92c99ed2.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_count_index.md.177b24c1.lean.js
      rename to assets/src_ranuts_sort_count_index.md.92c99ed2.lean.js
      index 18efd6bcb..56fd2d05a 100644
      --- a/assets/src_ranuts_sort_count_index.md.177b24c1.lean.js
      +++ b/assets/src_ranuts_sort_count_index.md.92c99ed2.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/count.9e7ca98e.gif",E=JSON.parse('{"title":"计数排序( Count Sort )","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/count/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/count/index.md"},t=l("",10),e=[t];function c(r,y,F,D,i,B){return n(),a("div",null,e)}const f=s(p,[["render",c]]);export{E as __pageData,f as default};
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/count.9e7ca98e.gif",E=JSON.parse('{"title":"计数排序( Count Sort )","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/count/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/count/index.md"},t=l("",10),e=[t];function c(r,y,F,D,i,B){return n(),a("div",null,e)}const f=s(p,[["render",c]]);export{E as __pageData,f as default};
      diff --git a/assets/src_ranuts_sort_heap_index.md.a866a7bc.js b/assets/src_ranuts_sort_heap_index.md.bfff8633.js
      similarity index 99%
      rename from assets/src_ranuts_sort_heap_index.md.a866a7bc.js
      rename to assets/src_ranuts_sort_heap_index.md.bfff8633.js
      index 481c3f83a..bed7fd0d2 100644
      --- a/assets/src_ranuts_sort_heap_index.md.a866a7bc.js
      +++ b/assets/src_ranuts_sort_heap_index.md.bfff8633.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/heap.0c214e72.gif",E=JSON.parse('{"title":"堆排序(Heap Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/heap/index.md","lastUpdated":1694741410000}'),o={name:"src/ranuts/sort/heap/index.md"},t=l('

      堆排序(Heap Sort)

      堆排序(Heapsort)是指利用堆这种数据结构所设计的一种排序算法。堆积是一个近似完全二叉树的结构,并同时满足堆积的性质:即子结点的键值或索引总是小于(或者大于)它的父节点。

      算法描述

      • 将初始待排序关键字序列(R1,R2….Rn)构建成大顶堆,此堆为初始的无序区;
      • 将堆顶元素 R[1]与最后一个元素 R[n]交换,此时得到新的无序区(R1,R2,……Rn-1)和新的有序区(Rn),且满足 R[1,2…n-1]<=R[n];
      • 由于交换后新的堆顶 R[1]可能违反堆的性质,因此需要对当前无序区(R1,R2,……Rn-1)调整为新堆,然后再次将 R[1]与无序区最后一个元素交换,得到新的无序区(R1,R2….Rn-2)和新的有序区(Rn-1,Rn)。不断重复此过程直到有序区的元素个数为 n-1,则整个排序过程完成。
      • 升序用大根堆,降序用小根堆

      动图演示

      堆排序

      代码演示

      ts
      class Heap {
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/heap.0c214e72.gif",E=JSON.parse('{"title":"堆排序(Heap Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/heap/index.md","lastUpdated":1695392177000}'),o={name:"src/ranuts/sort/heap/index.md"},t=l('

      堆排序(Heap Sort)

      堆排序(Heapsort)是指利用堆这种数据结构所设计的一种排序算法。堆积是一个近似完全二叉树的结构,并同时满足堆积的性质:即子结点的键值或索引总是小于(或者大于)它的父节点。

      算法描述

      • 将初始待排序关键字序列(R1,R2….Rn)构建成大顶堆,此堆为初始的无序区;
      • 将堆顶元素 R[1]与最后一个元素 R[n]交换,此时得到新的无序区(R1,R2,……Rn-1)和新的有序区(Rn),且满足 R[1,2…n-1]<=R[n];
      • 由于交换后新的堆顶 R[1]可能违反堆的性质,因此需要对当前无序区(R1,R2,……Rn-1)调整为新堆,然后再次将 R[1]与无序区最后一个元素交换,得到新的无序区(R1,R2….Rn-2)和新的有序区(Rn-1,Rn)。不断重复此过程直到有序区的元素个数为 n-1,则整个排序过程完成。
      • 升序用大根堆,降序用小根堆

      动图演示

      堆排序

      代码演示

      ts
      class Heap {
         arr: Array<number>
         size: number
         constructor(arr: Array<number>) {
      diff --git a/assets/src_ranuts_sort_heap_index.md.a866a7bc.lean.js b/assets/src_ranuts_sort_heap_index.md.bfff8633.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_heap_index.md.a866a7bc.lean.js
      rename to assets/src_ranuts_sort_heap_index.md.bfff8633.lean.js
      index 56391ecc1..df54f9bb7 100644
      --- a/assets/src_ranuts_sort_heap_index.md.a866a7bc.lean.js
      +++ b/assets/src_ranuts_sort_heap_index.md.bfff8633.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/heap.0c214e72.gif",E=JSON.parse('{"title":"堆排序(Heap Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/heap/index.md","lastUpdated":1694741410000}'),o={name:"src/ranuts/sort/heap/index.md"},t=l("",8),e=[t];function r(c,y,F,D,B,i){return a(),n("div",null,e)}const h=s(o,[["render",r]]);export{E as __pageData,h as default};
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const p="/ran/assets/heap.0c214e72.gif",E=JSON.parse('{"title":"堆排序(Heap Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/heap/index.md","lastUpdated":1695392177000}'),o={name:"src/ranuts/sort/heap/index.md"},t=l("",8),e=[t];function r(c,y,F,D,B,i){return a(),n("div",null,e)}const h=s(o,[["render",r]]);export{E as __pageData,h as default};
      diff --git a/assets/src_ranuts_sort_index.md.4bc20df7.js b/assets/src_ranuts_sort_index.md.2b3ea8db.js
      similarity index 96%
      rename from assets/src_ranuts_sort_index.md.4bc20df7.js
      rename to assets/src_ranuts_sort_index.md.2b3ea8db.js
      index 7e01df587..fa3524247 100644
      --- a/assets/src_ranuts_sort_index.md.4bc20df7.js
      +++ b/assets/src_ranuts_sort_index.md.2b3ea8db.js
      @@ -1 +1 @@
      -import{_ as t,o as a,c as s,N as e}from"./chunks/framework.6fe2e870.js";const r="/ran/assets/sort.0e02a465.png",n="/ran/assets/complexity.aded73a0.png",b=JSON.parse('{"title":"十大经典排序","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/index.md","lastUpdated":1694741410000}'),o={name:"src/ranuts/sort/index.md"},i=e('

      十大经典排序

      十种常见排序算法可以分为两大类:

      • 比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破 O(nlogn),因此也称为非线性时间比较类排序。
      • 非比较类排序:不通过比较来决定元素间的相对次序,它可以突破基于比较排序的时间下界,以线性时间运行,因此也称为线性时间非比较类排序。 排序分类 0.2 算法复杂度

      算法复杂度 0.3 相关概念

      • 稳定:如果 a 原本在 b 前面,而 a=b,排序之后 a 仍然在 b 的前面。
      • 不稳定:如果 a 原本在 b 的前面,而 a=b,排序之后 a 可能会出现在 b 的后面。
      • 时间复杂度:对排序数据的总的操作次数。反映当 n 变化时,操作次数呈现什么规律。
      • 空间复杂度:是指算法在计算机内执行时所需存储空间的度量,它也是数据规模 n 的函数。
      ',5),l=[i];function _(c,d,p,m,u,g){return a(),s("div",null,l)}const f=t(o,[["render",_]]);export{b as __pageData,f as default}; +import{_ as t,o as a,c as s,N as e}from"./chunks/framework.6fe2e870.js";const r="/ran/assets/sort.0e02a465.png",n="/ran/assets/complexity.aded73a0.png",b=JSON.parse('{"title":"十大经典排序","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/index.md","lastUpdated":1695392177000}'),o={name:"src/ranuts/sort/index.md"},i=e('

      十大经典排序

      十种常见排序算法可以分为两大类:

      • 比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破 O(nlogn),因此也称为非线性时间比较类排序。
      • 非比较类排序:不通过比较来决定元素间的相对次序,它可以突破基于比较排序的时间下界,以线性时间运行,因此也称为线性时间非比较类排序。 排序分类 0.2 算法复杂度

      算法复杂度 0.3 相关概念

      • 稳定:如果 a 原本在 b 前面,而 a=b,排序之后 a 仍然在 b 的前面。
      • 不稳定:如果 a 原本在 b 的前面,而 a=b,排序之后 a 可能会出现在 b 的后面。
      • 时间复杂度:对排序数据的总的操作次数。反映当 n 变化时,操作次数呈现什么规律。
      • 空间复杂度:是指算法在计算机内执行时所需存储空间的度量,它也是数据规模 n 的函数。
      ',5),l=[i];function _(c,d,p,m,u,g){return a(),s("div",null,l)}const f=t(o,[["render",_]]);export{b as __pageData,f as default}; diff --git a/assets/src_ranuts_sort_index.md.4bc20df7.lean.js b/assets/src_ranuts_sort_index.md.2b3ea8db.lean.js similarity index 86% rename from assets/src_ranuts_sort_index.md.4bc20df7.lean.js rename to assets/src_ranuts_sort_index.md.2b3ea8db.lean.js index a529fd500..a15348d62 100644 --- a/assets/src_ranuts_sort_index.md.4bc20df7.lean.js +++ b/assets/src_ranuts_sort_index.md.2b3ea8db.lean.js @@ -1 +1 @@ -import{_ as t,o as a,c as s,N as e}from"./chunks/framework.6fe2e870.js";const r="/ran/assets/sort.0e02a465.png",n="/ran/assets/complexity.aded73a0.png",b=JSON.parse('{"title":"十大经典排序","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/index.md","lastUpdated":1694741410000}'),o={name:"src/ranuts/sort/index.md"},i=e("",5),l=[i];function _(c,d,p,m,u,g){return a(),s("div",null,l)}const f=t(o,[["render",_]]);export{b as __pageData,f as default}; +import{_ as t,o as a,c as s,N as e}from"./chunks/framework.6fe2e870.js";const r="/ran/assets/sort.0e02a465.png",n="/ran/assets/complexity.aded73a0.png",b=JSON.parse('{"title":"十大经典排序","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/index.md","lastUpdated":1695392177000}'),o={name:"src/ranuts/sort/index.md"},i=e("",5),l=[i];function _(c,d,p,m,u,g){return a(),s("div",null,l)}const f=t(o,[["render",_]]);export{b as __pageData,f as default}; diff --git a/assets/src_ranuts_sort_insert_index.md.ae885a3c.js b/assets/src_ranuts_sort_insert_index.md.41df7c24.js similarity index 99% rename from assets/src_ranuts_sort_insert_index.md.ae885a3c.js rename to assets/src_ranuts_sort_insert_index.md.41df7c24.js index da86bc410..fad6cf09f 100644 --- a/assets/src_ranuts_sort_insert_index.md.ae885a3c.js +++ b/assets/src_ranuts_sort_insert_index.md.41df7c24.js @@ -1,4 +1,4 @@ -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/insert.4cd822c8.gif",A=JSON.parse('{"title":"插入排序(Insert Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/insert/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/insert/index.md"},t=l('

      插入排序(Insert Sort)

      表现稳定的排序算法,因为无论什么数据进去都是 O(n2)的时间复杂度,所以用到它的时候,数据规模越小越好。优点是不占用额外的内存空间。工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入。

      算法描述

      • 从第一个元素开始,该元素可以认为已经被排序;
      • 取出下一个元素,在已经排序的元素序列中从后向前扫描;
      • 如果该元素(已排序)大于新元素,将该元素移到下一位置;
      • 重复步骤 3,直到找到已排序的元素小于或者等于新元素的位置;
      • 将新元素插入到该位置后;
      • 重复步骤 2~5。

      动图演示

      插入排序

      代码演示

      ts
      const insert = (list: Array<string>): Array<string> => {
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/insert.4cd822c8.gif",A=JSON.parse('{"title":"插入排序(Insert Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/insert/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/insert/index.md"},t=l('

      插入排序(Insert Sort)

      表现稳定的排序算法,因为无论什么数据进去都是 O(n2)的时间复杂度,所以用到它的时候,数据规模越小越好。优点是不占用额外的内存空间。工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入。

      算法描述

      • 从第一个元素开始,该元素可以认为已经被排序;
      • 取出下一个元素,在已经排序的元素序列中从后向前扫描;
      • 如果该元素(已排序)大于新元素,将该元素移到下一位置;
      • 重复步骤 3,直到找到已排序的元素小于或者等于新元素的位置;
      • 将新元素插入到该位置后;
      • 重复步骤 2~5。

      动图演示

      插入排序

      代码演示

      ts
      const insert = (list: Array<string>): Array<string> => {
         const { length } = list
         for (let i = 1; i < length; i++) {
           let preIndex = i - 1
      diff --git a/assets/src_ranuts_sort_insert_index.md.ae885a3c.lean.js b/assets/src_ranuts_sort_insert_index.md.41df7c24.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_insert_index.md.ae885a3c.lean.js
      rename to assets/src_ranuts_sort_insert_index.md.41df7c24.lean.js
      index 9a2a95467..ea111ac39 100644
      --- a/assets/src_ranuts_sort_insert_index.md.ae885a3c.lean.js
      +++ b/assets/src_ranuts_sort_insert_index.md.41df7c24.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/insert.4cd822c8.gif",A=JSON.parse('{"title":"插入排序(Insert Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/insert/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/insert/index.md"},t=l("",10),e=[t];function r(c,y,F,D,i,B){return a(),n("div",null,e)}const E=s(p,[["render",r]]);export{A as __pageData,E as default};
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/insert.4cd822c8.gif",A=JSON.parse('{"title":"插入排序(Insert Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/insert/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/insert/index.md"},t=l("",10),e=[t];function r(c,y,F,D,i,B){return a(),n("div",null,e)}const E=s(p,[["render",r]]);export{A as __pageData,E as default};
      diff --git a/assets/src_ranuts_sort_merge_index.md.0e0ee551.js b/assets/src_ranuts_sort_merge_index.md.a444075a.js
      similarity index 99%
      rename from assets/src_ranuts_sort_merge_index.md.0e0ee551.js
      rename to assets/src_ranuts_sort_merge_index.md.a444075a.js
      index 6326cc2b1..4423833a1 100644
      --- a/assets/src_ranuts_sort_merge_index.md.0e0ee551.js
      +++ b/assets/src_ranuts_sort_merge_index.md.a444075a.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/merge.7613b4a8.gif",E=JSON.parse('{"title":"归并排序(Merge Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/merge/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/merge/index.md"},t=l('

      归并排序(Merge Sort)

      归并排序是建立在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。将已有序的子序列合并,得到完全有序的序列;即先使每个子序列有序,再使子序列段间有序。若将两个有序表合并成一个有序表,称为 2-路归并。

      算法描述

      • 把长度为 n 的输入序列分成两个长度为 n/2 的子序列;
      • 对这两个子序列分别采用归并排序;
      • 将两个排序好的子序列合并成一个最终的排序序列。

      动图演示

      归并排序

      代码演示

      ts
      const combine = (left: Array<number>, right: Array<number>) => {
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/merge.7613b4a8.gif",E=JSON.parse('{"title":"归并排序(Merge Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/merge/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/merge/index.md"},t=l('

      归并排序(Merge Sort)

      归并排序是建立在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。将已有序的子序列合并,得到完全有序的序列;即先使每个子序列有序,再使子序列段间有序。若将两个有序表合并成一个有序表,称为 2-路归并。

      算法描述

      • 把长度为 n 的输入序列分成两个长度为 n/2 的子序列;
      • 对这两个子序列分别采用归并排序;
      • 将两个排序好的子序列合并成一个最终的排序序列。

      动图演示

      归并排序

      代码演示

      ts
      const combine = (left: Array<number>, right: Array<number>) => {
         const list: Array<number> = []
         while (left.length > 0 && right.length > 0) {
           if (left[0] <= right[0]) {
      diff --git a/assets/src_ranuts_sort_merge_index.md.0e0ee551.lean.js b/assets/src_ranuts_sort_merge_index.md.a444075a.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_merge_index.md.0e0ee551.lean.js
      rename to assets/src_ranuts_sort_merge_index.md.a444075a.lean.js
      index 9268bf459..b9132df20 100644
      --- a/assets/src_ranuts_sort_merge_index.md.0e0ee551.lean.js
      +++ b/assets/src_ranuts_sort_merge_index.md.a444075a.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/merge.7613b4a8.gif",E=JSON.parse('{"title":"归并排序(Merge Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/merge/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/merge/index.md"},t=l("",10),e=[t];function c(r,y,F,D,i,B){return n(),a("div",null,e)}const f=s(p,[["render",c]]);export{E as __pageData,f as default};
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/merge.7613b4a8.gif",E=JSON.parse('{"title":"归并排序(Merge Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/merge/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/merge/index.md"},t=l("",10),e=[t];function c(r,y,F,D,i,B){return n(),a("div",null,e)}const f=s(p,[["render",c]]);export{E as __pageData,f as default};
      diff --git a/assets/src_ranuts_sort_quick_index.md.aeca65b0.js b/assets/src_ranuts_sort_quick_index.md.a098262a.js
      similarity index 99%
      rename from assets/src_ranuts_sort_quick_index.md.aeca65b0.js
      rename to assets/src_ranuts_sort_quick_index.md.a098262a.js
      index dcb68a3f0..bd55c9dfd 100644
      --- a/assets/src_ranuts_sort_quick_index.md.aeca65b0.js
      +++ b/assets/src_ranuts_sort_quick_index.md.a098262a.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as l,c as n,N as a}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/quick.e1c33863.gif",f=JSON.parse('{"title":"快速排序(Quick Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/quick/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/quick/index.md"},t=a('

      快速排序(Quick Sort)

      快速排序的基本思想:通过一趟排序将待排记录分隔成独立的两部分,其中一部分记录的关键字均比另一部分的关键字小,则可分别对这两部分记录继续进行排序,以达到整个序列有序。

      算法描述

      快速排序使用分治法来把一个串(list)分为两个子串(sub-lists)。具体算法描述如下:

      • 从数列中挑出一个元素,称为 “基准”(pivot);
      • 重新排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面(相同的数可以到任一边)。在这个分区退出之后,该基准就处于数列的中间位置。这个称为分区(partition)操作;
      • 递归地(recursive)把小于基准值元素的子数列和大于基准值元素的子数列排序。

      动图演示

      快速排序

      代码演示

      ts
      /**
      +import{_ as s,o as l,c as n,N as a}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/quick.e1c33863.gif",f=JSON.parse('{"title":"快速排序(Quick Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/quick/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/quick/index.md"},t=a('

      快速排序(Quick Sort)

      快速排序的基本思想:通过一趟排序将待排记录分隔成独立的两部分,其中一部分记录的关键字均比另一部分的关键字小,则可分别对这两部分记录继续进行排序,以达到整个序列有序。

      算法描述

      快速排序使用分治法来把一个串(list)分为两个子串(sub-lists)。具体算法描述如下:

      • 从数列中挑出一个元素,称为 “基准”(pivot);
      • 重新排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面(相同的数可以到任一边)。在这个分区退出之后,该基准就处于数列的中间位置。这个称为分区(partition)操作;
      • 递归地(recursive)把小于基准值元素的子数列和大于基准值元素的子数列排序。

      动图演示

      快速排序

      代码演示

      ts
      /**
        * @description: 设置基准值pivot
        * @param {Array} list
        * @param {number} left
      diff --git a/assets/src_ranuts_sort_quick_index.md.aeca65b0.lean.js b/assets/src_ranuts_sort_quick_index.md.a098262a.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_quick_index.md.aeca65b0.lean.js
      rename to assets/src_ranuts_sort_quick_index.md.a098262a.lean.js
      index a5c72f5ad..1229c0bb2 100644
      --- a/assets/src_ranuts_sort_quick_index.md.aeca65b0.lean.js
      +++ b/assets/src_ranuts_sort_quick_index.md.a098262a.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as l,c as n,N as a}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/quick.e1c33863.gif",f=JSON.parse('{"title":"快速排序(Quick Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/quick/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/quick/index.md"},t=a("",9),e=[t];function c(r,y,i,F,D,B){return l(),n("div",null,e)}const A=s(p,[["render",c]]);export{f as __pageData,A as default};
      +import{_ as s,o as l,c as n,N as a}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/quick.e1c33863.gif",f=JSON.parse('{"title":"快速排序(Quick Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/quick/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/quick/index.md"},t=a("",9),e=[t];function c(r,y,i,F,D,B){return l(),n("div",null,e)}const A=s(p,[["render",c]]);export{f as __pageData,A as default};
      diff --git a/assets/src_ranuts_sort_radix_index.md.3884546e.js b/assets/src_ranuts_sort_radix_index.md.6aa13c07.js
      similarity index 99%
      rename from assets/src_ranuts_sort_radix_index.md.3884546e.js
      rename to assets/src_ranuts_sort_radix_index.md.6aa13c07.js
      index 2cd30f353..6d9785830 100644
      --- a/assets/src_ranuts_sort_radix_index.md.3884546e.js
      +++ b/assets/src_ranuts_sort_radix_index.md.6aa13c07.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/radix.101a451a.gif",E=JSON.parse('{"title":"基数排序(Radix Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/radix/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/radix/index.md"},t=l('

      基数排序(Radix Sort)

      基数排序是按照低位先排序,然后收集;再按照高位排序,然后再收集;依次类推,直到最高位。有时候有些属性是有优先级顺序的,先按低优先级排序,再按高优先级排序。最后的次序就是高优先级高的在前,高优先级相同的低优先级高的在前。桶排序扩展,类似于指定桶排序按位数排序规则,同时能利用计数排序适用于小范围数的特点。

      算法描述

      • 取得数组中的最大数,并取得位数;
      • arr 为原始数组,从最低位开始取每个位组成 radix 数组;
      • 对 radix 进行计数排序(利用计数排序适用于小范围数的特点);

      动图演示

      基数排序

      代码演示

      ts
      const getMax = (list: Array<number>) => {
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/radix.101a451a.gif",E=JSON.parse('{"title":"基数排序(Radix Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/radix/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/radix/index.md"},t=l('

      基数排序(Radix Sort)

      基数排序是按照低位先排序,然后收集;再按照高位排序,然后再收集;依次类推,直到最高位。有时候有些属性是有优先级顺序的,先按低优先级排序,再按高优先级排序。最后的次序就是高优先级高的在前,高优先级相同的低优先级高的在前。桶排序扩展,类似于指定桶排序按位数排序规则,同时能利用计数排序适用于小范围数的特点。

      算法描述

      • 取得数组中的最大数,并取得位数;
      • arr 为原始数组,从最低位开始取每个位组成 radix 数组;
      • 对 radix 进行计数排序(利用计数排序适用于小范围数的特点);

      动图演示

      基数排序

      代码演示

      ts
      const getMax = (list: Array<number>) => {
         let max = list[0]
         for (let i = 0; i < list.length; i++) {
           if (max < list[i]) {
      diff --git a/assets/src_ranuts_sort_radix_index.md.3884546e.lean.js b/assets/src_ranuts_sort_radix_index.md.6aa13c07.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_radix_index.md.3884546e.lean.js
      rename to assets/src_ranuts_sort_radix_index.md.6aa13c07.lean.js
      index d3ac8fcd1..7fb56d354 100644
      --- a/assets/src_ranuts_sort_radix_index.md.3884546e.lean.js
      +++ b/assets/src_ranuts_sort_radix_index.md.6aa13c07.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/radix.101a451a.gif",E=JSON.parse('{"title":"基数排序(Radix Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/radix/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/radix/index.md"},t=l("",11),e=[t];function c(r,y,F,D,i,B){return a(),n("div",null,e)}const d=s(p,[["render",c]]);export{E as __pageData,d as default};
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/radix.101a451a.gif",E=JSON.parse('{"title":"基数排序(Radix Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/radix/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/radix/index.md"},t=l("",11),e=[t];function c(r,y,F,D,i,B){return a(),n("div",null,e)}const d=s(p,[["render",c]]);export{E as __pageData,d as default};
      diff --git a/assets/src_ranuts_sort_select_index.md.0ee7b8b9.js b/assets/src_ranuts_sort_select_index.md.b30d74cc.js
      similarity index 99%
      rename from assets/src_ranuts_sort_select_index.md.0ee7b8b9.js
      rename to assets/src_ranuts_sort_select_index.md.b30d74cc.js
      index bf44bb6a5..b7df2f8d3 100644
      --- a/assets/src_ranuts_sort_select_index.md.0ee7b8b9.js
      +++ b/assets/src_ranuts_sort_select_index.md.b30d74cc.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/select.5aa51d89.gif",E=JSON.parse('{"title":"选择排序(Selection Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/select/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/select/index.md"},e=l('

      选择排序(Selection Sort)

      选择排序(Selection-sort)是一种简单直观的排序算法。它的工作原理:首先在未排序序列中找到最小(大)元素,存放到排序序列的起始位置,然后,再从剩余未排序元素中继续寻找最小(大)元素,然后放到已排序序列的末尾。以此类推,直到所有元素均排序完毕。

      算法描述

      n 个记录的直接选择排序可经过 n-1 趟直接选择排序得到有序结果。具体算法描述如下:

      • 初始状态:无序区为 R[1..n],有序区为空;
      • 第 i 趟排序(i=1,2,3…n-1)开始时,当前有序区和无序区分别为 R[1..i-1]和 R(i..n)。该趟排序从当前无序区中-选出关键字最小的记录 R[k],将它与无序区的第 1 个记录 R 交换,使 R[1..i]和 R[i+1..n)分别变为记录个数增加 1 个的新有序区和记录个数减少 1 个的新无序区;
      • n-1 趟结束,数组有序化了。

      动图演示

      选择排序

      代码实现

      js
      function selectionSort(arr) {
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/select.5aa51d89.gif",E=JSON.parse('{"title":"选择排序(Selection Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/select/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/select/index.md"},e=l('

      选择排序(Selection Sort)

      选择排序(Selection-sort)是一种简单直观的排序算法。它的工作原理:首先在未排序序列中找到最小(大)元素,存放到排序序列的起始位置,然后,再从剩余未排序元素中继续寻找最小(大)元素,然后放到已排序序列的末尾。以此类推,直到所有元素均排序完毕。

      算法描述

      n 个记录的直接选择排序可经过 n-1 趟直接选择排序得到有序结果。具体算法描述如下:

      • 初始状态:无序区为 R[1..n],有序区为空;
      • 第 i 趟排序(i=1,2,3…n-1)开始时,当前有序区和无序区分别为 R[1..i-1]和 R(i..n)。该趟排序从当前无序区中-选出关键字最小的记录 R[k],将它与无序区的第 1 个记录 R 交换,使 R[1..i]和 R[i+1..n)分别变为记录个数增加 1 个的新有序区和记录个数减少 1 个的新无序区;
      • n-1 趟结束,数组有序化了。

      动图演示

      选择排序

      代码实现

      js
      function selectionSort(arr) {
         var len = arr.length
         var minIndex, temp
         for (var i = 0; i < len - 1; i++) {
      diff --git a/assets/src_ranuts_sort_select_index.md.0ee7b8b9.lean.js b/assets/src_ranuts_sort_select_index.md.b30d74cc.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_select_index.md.0ee7b8b9.lean.js
      rename to assets/src_ranuts_sort_select_index.md.b30d74cc.lean.js
      index e3ad79631..e516f29d9 100644
      --- a/assets/src_ranuts_sort_select_index.md.0ee7b8b9.lean.js
      +++ b/assets/src_ranuts_sort_select_index.md.b30d74cc.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/select.5aa51d89.gif",E=JSON.parse('{"title":"选择排序(Selection Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/select/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/select/index.md"},e=l("",11),t=[e];function r(c,y,F,i,D,B){return a(),n("div",null,t)}const d=s(p,[["render",r]]);export{E as __pageData,d as default};
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/select.5aa51d89.gif",E=JSON.parse('{"title":"选择排序(Selection Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/select/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/select/index.md"},e=l("",11),t=[e];function r(c,y,F,i,D,B){return a(),n("div",null,t)}const d=s(p,[["render",r]]);export{E as __pageData,d as default};
      diff --git a/assets/src_ranuts_sort_shell_index.md.95e50a19.js b/assets/src_ranuts_sort_shell_index.md.bd6b216b.js
      similarity index 99%
      rename from assets/src_ranuts_sort_shell_index.md.95e50a19.js
      rename to assets/src_ranuts_sort_shell_index.md.bd6b216b.js
      index 68377ba3b..88831a1aa 100644
      --- a/assets/src_ranuts_sort_shell_index.md.95e50a19.js
      +++ b/assets/src_ranuts_sort_shell_index.md.bd6b216b.js
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as l,N as n}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/shell.7f63988c.gif",E=JSON.parse('{"title":"希尔排序(Shell Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/shell/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/shell/index.md"},t=n('

      希尔排序(Shell Sort)

      1959 年 Shell 发明,第一个突破 O(n2)的排序算法,是简单插入排序的改进版。它与插入排序的不同之处在于,它会优先比较距离较远的元素。希尔排序又叫缩小增量排序。

      算法描述

      先将整个待排序的记录序列分割成为若干子序列分别进行直接插入排序,具体算法描述:

      • 选择一个增量序列 t1,t2,…,tk,其中 ti>tj,tk=1;
      • 按增量序列个数 k,对序列进行 k 趟排序;
      • 每趟排序,根据对应的增量 ti,将待排序列分割成若干长度为 m 的子序列,分别对各子表进行直接插入排序。仅增量因子为 1 时,整个序列作为一个表来处理,表长度即为整个序列的长度。

      动图演示

      希尔排序

      代码实现

      js
      /**
      +import{_ as s,o as a,c as l,N as n}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/shell.7f63988c.gif",E=JSON.parse('{"title":"希尔排序(Shell Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/shell/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/shell/index.md"},t=n('

      希尔排序(Shell Sort)

      1959 年 Shell 发明,第一个突破 O(n2)的排序算法,是简单插入排序的改进版。它与插入排序的不同之处在于,它会优先比较距离较远的元素。希尔排序又叫缩小增量排序。

      算法描述

      先将整个待排序的记录序列分割成为若干子序列分别进行直接插入排序,具体算法描述:

      • 选择一个增量序列 t1,t2,…,tk,其中 ti>tj,tk=1;
      • 按增量序列个数 k,对序列进行 k 趟排序;
      • 每趟排序,根据对应的增量 ti,将待排序列分割成若干长度为 m 的子序列,分别对各子表进行直接插入排序。仅增量因子为 1 时,整个序列作为一个表来处理,表长度即为整个序列的长度。

      动图演示

      希尔排序

      代码实现

      js
      /**
        * @description: 希尔排序,是简单插入排序的改进版。它与插入排序的不同之处在于,它会优先比较距离较远的元素。希尔排序又叫缩小增量排序。
        * @param {Array} list
        * @return {Array}
      diff --git a/assets/src_ranuts_sort_shell_index.md.95e50a19.lean.js b/assets/src_ranuts_sort_shell_index.md.bd6b216b.lean.js
      similarity index 86%
      rename from assets/src_ranuts_sort_shell_index.md.95e50a19.lean.js
      rename to assets/src_ranuts_sort_shell_index.md.bd6b216b.lean.js
      index 3545d0756..42d98509e 100644
      --- a/assets/src_ranuts_sort_shell_index.md.95e50a19.lean.js
      +++ b/assets/src_ranuts_sort_shell_index.md.bd6b216b.lean.js
      @@ -1 +1 @@
      -import{_ as s,o as a,c as l,N as n}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/shell.7f63988c.gif",E=JSON.parse('{"title":"希尔排序(Shell Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/shell/index.md","lastUpdated":1694741410000}'),p={name:"src/ranuts/sort/shell/index.md"},t=n("",11),e=[t];function c(r,y,F,D,i,B){return a(),l("div",null,e)}const h=s(p,[["render",c]]);export{E as __pageData,h as default};
      +import{_ as s,o as a,c as l,N as n}from"./chunks/framework.6fe2e870.js";const o="/ran/assets/shell.7f63988c.gif",E=JSON.parse('{"title":"希尔排序(Shell Sort)","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/sort/shell/index.md","lastUpdated":1695392177000}'),p={name:"src/ranuts/sort/shell/index.md"},t=n("",11),e=[t];function c(r,y,F,D,i,B){return a(),l("div",null,e)}const h=s(p,[["render",c]]);export{E as __pageData,h as default};
      diff --git a/assets/src_ranuts_utils_index.md.528940e0.js b/assets/src_ranuts_utils_index.md.d9268c55.js
      similarity index 97%
      rename from assets/src_ranuts_utils_index.md.528940e0.js
      rename to assets/src_ranuts_utils_index.md.d9268c55.js
      index 04ea3e6a0..6c1128fd1 100644
      --- a/assets/src_ranuts_utils_index.md.528940e0.js
      +++ b/assets/src_ranuts_utils_index.md.d9268c55.js
      @@ -1 +1 @@
      -import{_ as t,o as e,c as d,N as a}from"./chunks/framework.6fe2e870.js";const p=JSON.parse('{"title":"通用函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/index.md","lastUpdated":1694741410000}'),r={name:"src/ranuts/utils/index.md"},o=a('

      通用函数

      filterObj

      过滤对象的属性,去除对象中在 list 数组里面有的属性,返回一个新对象,一般是用于去除空字符和 null

      API

      Return

      参数说明类型
      run启动轮询(...params: TParams) => void
      runAsync启动轮询(...params: TParams) => Promise<TData>
      cancel停止轮询() => void

      Options

      参数说明类型默认值
      pollingInterval轮询间隔,单位为毫秒。如果值大于 0,则启动轮询模式。number0
      pollingWhenHidden在页面隐藏时,是否继续轮询。如果设置为 false,在页面隐藏时会暂时停止轮询,页面重新显示时继续上次轮询。booleantrue
      pollingErrorRetryCount轮询错误重试次数。如果设置为 -1,则无限次number-1
      ',8),n=[o];function i(l,c,s,h,u,_){return e(),d("div",null,n)}const m=t(r,[["render",i]]);export{p as __pageData,m as default}; +import{_ as t,o as e,c as d,N as a}from"./chunks/framework.6fe2e870.js";const p=JSON.parse('{"title":"通用函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/index.md","lastUpdated":1695392177000}'),r={name:"src/ranuts/utils/index.md"},o=a('

      通用函数

      filterObj

      过滤对象的属性,去除对象中在 list 数组里面有的属性,返回一个新对象,一般是用于去除空字符和 null

      API

      Return

      参数说明类型
      run启动轮询(...params: TParams) => void
      runAsync启动轮询(...params: TParams) => Promise<TData>
      cancel停止轮询() => void

      Options

      参数说明类型默认值
      pollingInterval轮询间隔,单位为毫秒。如果值大于 0,则启动轮询模式。number0
      pollingWhenHidden在页面隐藏时,是否继续轮询。如果设置为 false,在页面隐藏时会暂时停止轮询,页面重新显示时继续上次轮询。booleantrue
      pollingErrorRetryCount轮询错误重试次数。如果设置为 -1,则无限次number-1
      ',8),n=[o];function i(l,c,s,h,u,_){return e(),d("div",null,n)}const m=t(r,[["render",i]]);export{p as __pageData,m as default}; diff --git a/assets/src_ranuts_utils_index.md.528940e0.lean.js b/assets/src_ranuts_utils_index.md.d9268c55.lean.js similarity index 84% rename from assets/src_ranuts_utils_index.md.528940e0.lean.js rename to assets/src_ranuts_utils_index.md.d9268c55.lean.js index 160a82107..4346a6ad5 100644 --- a/assets/src_ranuts_utils_index.md.528940e0.lean.js +++ b/assets/src_ranuts_utils_index.md.d9268c55.lean.js @@ -1 +1 @@ -import{_ as t,o as e,c as d,N as a}from"./chunks/framework.6fe2e870.js";const p=JSON.parse('{"title":"通用函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/index.md","lastUpdated":1694741410000}'),r={name:"src/ranuts/utils/index.md"},o=a("",8),n=[o];function i(l,c,s,h,u,_){return e(),d("div",null,n)}const m=t(r,[["render",i]]);export{p as __pageData,m as default}; +import{_ as t,o as e,c as d,N as a}from"./chunks/framework.6fe2e870.js";const p=JSON.parse('{"title":"通用函数","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/index.md","lastUpdated":1695392177000}'),r={name:"src/ranuts/utils/index.md"},o=a("",8),n=[o];function i(l,c,s,h,u,_){return e(),d("div",null,n)}const m=t(r,[["render",i]]);export{p as __pageData,m as default}; diff --git a/assets/src_ranuts_utils_task.md.c82636a6.js b/assets/src_ranuts_utils_task.md.c229cafb.js similarity index 99% rename from assets/src_ranuts_utils_task.md.c82636a6.js rename to assets/src_ranuts_utils_task.md.c229cafb.js index 49f441e03..3e7270515 100644 --- a/assets/src_ranuts_utils_task.md.c82636a6.js +++ b/assets/src_ranuts_utils_task.md.c229cafb.js @@ -1 +1 @@ -import{_ as e,o as a,c as t,N as o}from"./chunks/framework.6fe2e870.js";const k=JSON.parse('{"title":"统计执行时间","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/task.md","lastUpdated":1694741410000}'),s={name:"src/ranuts/utils/task.md"},n=o('

      统计执行时间

      有的时候,我们需要统计一个函数的执行时间,用于分析性能。因此封装了startTasktaskEnd函数。同时介绍其他三种统计方法

      1. new Date().getTime(),
      2. console.time()console.timeEnd(),
      3. performance.now()

      一.startTask,taskEnd

      1.startTask

      任务开始之前执行

      Return

      参数说明类型
      taskId任务标识unique symbol

      2.taskEnd

      任务结束的时候执行,需要传入startTask返回的任务标识

      Options

      参数说明类型默认值
      taskId任务标识unique symbol 无默认值,参数必传,否则无法识别是哪个任务

      Return

      参数说明类型
      timetask执行的时间number

      3.使用例子

      js
      const taskId = startTask()\n\n// do something\n\nconst time = taskEnd(taskId)\n\nconsole.log('task 执行花费的时间', time)

      二.new Date().getTime()

      new Date().getTime() 返回一个数值,表示从 1970 年 1 月 1 日 0 时 0 分 0 秒(UTC,即协调世界时)距离该日期对象所代表时间的毫秒数。用来计算 JS 执行时间会有两个问题:

      1. 某些情况下,毫秒级精度可能不够。
      2. new Date() 解析的时间在不同浏览器,或者不同设备上可能并不一致。MDN 说明

        由于浏览器之间的差异与不一致性,强烈不推荐使用 Date 构造函数来解析日期字符串 (或使用与其等价的 Date.parse)。对 RFC 2822 格式的日期仅有约定俗成的支持。对 ISO 8601 格式的支持中,仅有日期的串 (例如 "1970-01-01") 会被处理为 UTC 而不是本地时间,与其他格式的串的处理不同。

      三.console.time(), console.timeEnd()

      启动一个计时器来跟踪某一个操作的占用时长。每一个计时器必须拥有唯一的名字,页面中最多能同时运行 10,000 个计时器。当以此计时器名字为参数调用 console.timeEnd() 时,浏览器将以毫秒为单位,输出对应计时器所经过的时间。比起new Date().getTime(),统计时间更加精确,可以统计到 0.001 毫秒(比如:0.134ms)

      四.performance.now()

      performance.now()返回的时间精度最高可达微秒级,且不会受到系统时间的影响(系统时钟可能会被手动调整或被 NTP 等软件篡改)。另外,performance.timing.navigationStart + performance.now() 约等于 Date.now()。因此对于统计 JS 执行耗时方面,更推荐使用performance.now()

      注意:为了提供对定时攻击和指纹的保护,performance.now() 的精度可能会根据浏览器的设置而被舍弃。 在 Firefox 中,privacy.reduceTimerPrecision 偏好是默认启用的,默认值为 1ms。可以启用 privacy.resistFingerprinting 这将精度改为 100ms 或privacy.resistFingerprinting.reduceTimerPrecision.microseconds 的值,以较大者为准。

      ',24),r=[n];function c(d,l,i,p,h,m){return a(),t("div",null,r)}const b=e(s,[["render",c]]);export{k as __pageData,b as default}; +import{_ as e,o as a,c as t,N as o}from"./chunks/framework.6fe2e870.js";const k=JSON.parse('{"title":"统计执行时间","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/task.md","lastUpdated":1695392177000}'),s={name:"src/ranuts/utils/task.md"},n=o('

      统计执行时间

      有的时候,我们需要统计一个函数的执行时间,用于分析性能。因此封装了startTasktaskEnd函数。同时介绍其他三种统计方法

      1. new Date().getTime(),
      2. console.time()console.timeEnd(),
      3. performance.now()

      一.startTask,taskEnd

      1.startTask

      任务开始之前执行

      Return

      参数说明类型
      taskId任务标识unique symbol

      2.taskEnd

      任务结束的时候执行,需要传入startTask返回的任务标识

      Options

      参数说明类型默认值
      taskId任务标识unique symbol 无默认值,参数必传,否则无法识别是哪个任务

      Return

      参数说明类型
      timetask执行的时间number

      3.使用例子

      js
      const taskId = startTask()\n\n// do something\n\nconst time = taskEnd(taskId)\n\nconsole.log('task 执行花费的时间', time)

      二.new Date().getTime()

      new Date().getTime() 返回一个数值,表示从 1970 年 1 月 1 日 0 时 0 分 0 秒(UTC,即协调世界时)距离该日期对象所代表时间的毫秒数。用来计算 JS 执行时间会有两个问题:

      1. 某些情况下,毫秒级精度可能不够。
      2. new Date() 解析的时间在不同浏览器,或者不同设备上可能并不一致。MDN 说明

        由于浏览器之间的差异与不一致性,强烈不推荐使用 Date 构造函数来解析日期字符串 (或使用与其等价的 Date.parse)。对 RFC 2822 格式的日期仅有约定俗成的支持。对 ISO 8601 格式的支持中,仅有日期的串 (例如 "1970-01-01") 会被处理为 UTC 而不是本地时间,与其他格式的串的处理不同。

      三.console.time(), console.timeEnd()

      启动一个计时器来跟踪某一个操作的占用时长。每一个计时器必须拥有唯一的名字,页面中最多能同时运行 10,000 个计时器。当以此计时器名字为参数调用 console.timeEnd() 时,浏览器将以毫秒为单位,输出对应计时器所经过的时间。比起new Date().getTime(),统计时间更加精确,可以统计到 0.001 毫秒(比如:0.134ms)

      四.performance.now()

      performance.now()返回的时间精度最高可达微秒级,且不会受到系统时间的影响(系统时钟可能会被手动调整或被 NTP 等软件篡改)。另外,performance.timing.navigationStart + performance.now() 约等于 Date.now()。因此对于统计 JS 执行耗时方面,更推荐使用performance.now()

      注意:为了提供对定时攻击和指纹的保护,performance.now() 的精度可能会根据浏览器的设置而被舍弃。 在 Firefox 中,privacy.reduceTimerPrecision 偏好是默认启用的,默认值为 1ms。可以启用 privacy.resistFingerprinting 这将精度改为 100ms 或privacy.resistFingerprinting.reduceTimerPrecision.microseconds 的值,以较大者为准。

      ',24),r=[n];function c(d,l,i,p,h,m){return a(),t("div",null,r)}const b=e(s,[["render",c]]);export{k as __pageData,b as default}; diff --git a/assets/src_ranuts_utils_task.md.c82636a6.lean.js b/assets/src_ranuts_utils_task.md.c229cafb.lean.js similarity index 84% rename from assets/src_ranuts_utils_task.md.c82636a6.lean.js rename to assets/src_ranuts_utils_task.md.c229cafb.lean.js index cf41c9e5a..825397367 100644 --- a/assets/src_ranuts_utils_task.md.c82636a6.lean.js +++ b/assets/src_ranuts_utils_task.md.c229cafb.lean.js @@ -1 +1 @@ -import{_ as e,o as a,c as t,N as o}from"./chunks/framework.6fe2e870.js";const k=JSON.parse('{"title":"统计执行时间","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/task.md","lastUpdated":1694741410000}'),s={name:"src/ranuts/utils/task.md"},n=o("",24),r=[n];function c(d,l,i,p,h,m){return a(),t("div",null,r)}const b=e(s,[["render",c]]);export{k as __pageData,b as default}; +import{_ as e,o as a,c as t,N as o}from"./chunks/framework.6fe2e870.js";const k=JSON.parse('{"title":"统计执行时间","description":"","frontmatter":{},"headers":[],"relativePath":"src/ranuts/utils/task.md","lastUpdated":1695392177000}'),s={name:"src/ranuts/utils/task.md"},n=o("",24),r=[n];function c(d,l,i,p,h,m){return a(),t("div",null,r)}const b=e(s,[["render",c]]);export{k as __pageData,b as default}; diff --git "a/assets/src_types_TS\347\261\273\345\236\213.md.ae69f8e2.js" "b/assets/src_types_TS\347\261\273\345\236\213.md.b85d8306.js" similarity index 99% rename from "assets/src_types_TS\347\261\273\345\236\213.md.ae69f8e2.js" rename to "assets/src_types_TS\347\261\273\345\236\213.md.b85d8306.js" index 1c4ef7fcf..59d523909 100644 --- "a/assets/src_types_TS\347\261\273\345\236\213.md.ae69f8e2.js" +++ "b/assets/src_types_TS\347\261\273\345\236\213.md.b85d8306.js" @@ -1,4 +1,4 @@ -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/TS类型.md","lastUpdated":1694741410000}'),p={name:"src/types/TS类型.md"},o=l(`

      TypeScript 类型系统中的类型

      1. 基本类型: number、boolean、string、object、bigint、symbol、undefined、null
      2. 复合类型: class、Array、元组(Tuple)、接口(Interface)、枚举(Enum)
      3. 特殊的类型:void、never、any、unknown

      Tuple

      元组(Tuple)就是元素个数和类型固定的数组类型:

      ts
      type Tuple = [number, string]

      Interface

      接口(Interface)可以描述函数、对象、构造器的结构:

      • 对象
      ts
      interface IPerson {
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/TS类型.md","lastUpdated":1695392177000}'),p={name:"src/types/TS类型.md"},o=l(`

      TypeScript 类型系统中的类型

      1. 基本类型: number、boolean、string、object、bigint、symbol、undefined、null
      2. 复合类型: class、Array、元组(Tuple)、接口(Interface)、枚举(Enum)
      3. 特殊的类型:void、never、any、unknown

      Tuple

      元组(Tuple)就是元素个数和类型固定的数组类型:

      ts
      type Tuple = [number, string]

      Interface

      接口(Interface)可以描述函数、对象、构造器的结构:

      • 对象
      ts
      interface IPerson {
         name: string
         age: number
       }
      diff --git "a/assets/src_types_TS\347\261\273\345\236\213.md.ae69f8e2.lean.js" "b/assets/src_types_TS\347\261\273\345\236\213.md.b85d8306.lean.js"
      similarity index 84%
      rename from "assets/src_types_TS\347\261\273\345\236\213.md.ae69f8e2.lean.js"
      rename to "assets/src_types_TS\347\261\273\345\236\213.md.b85d8306.lean.js"
      index 8d6771598..99609b27d 100644
      --- "a/assets/src_types_TS\347\261\273\345\236\213.md.ae69f8e2.lean.js"
      +++ "b/assets/src_types_TS\347\261\273\345\236\213.md.b85d8306.lean.js"
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/TS类型.md","lastUpdated":1694741410000}'),p={name:"src/types/TS类型.md"},o=l("",33),e=[o];function t(c,r,y,D,F,B){return a(),n("div",null,e)}const A=s(p,[["render",t]]);export{E as __pageData,A as default};
      +import{_ as s,o as a,c as n,N as l}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/TS类型.md","lastUpdated":1695392177000}'),p={name:"src/types/TS类型.md"},o=l("",33),e=[o];function t(c,r,y,D,F,B){return a(),n("div",null,e)}const A=s(p,[["render",t]]);export{E as __pageData,A as default};
      diff --git "a/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.443f232b.js" "b/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.cf789a64.js"
      similarity index 99%
      rename from "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.443f232b.js"
      rename to "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.cf789a64.js"
      index f1b977d4a..fb71ad6cb 100644
      --- "a/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.443f232b.js"
      +++ "b/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.cf789a64.js"
      @@ -1,4 +1,4 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"模式匹配","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/模式匹配.md","lastUpdated":1694741410000}'),p={name:"src/types/模式匹配.md"},o=l(`

      模式匹配

      Typescript 的类型也同样可以做模式匹配。

      比如这样一个 Promise 类型:

      ts
      type p = Promise<'value'>

      我们想提取 value 的类型,可以这样做:

      ts
      type GetPromiseValue<T> = T extends Promise<infer value> ? value : never

      通过 extends 对传入的类型参数 P 做模式匹配,其中值的类型是需要提取的,通过 infer 声明一个局部变量 Value 来保存,如果匹配,就返回匹配到的 Value,否则就返回 never 代表没匹配到。

      ts
      type result = GetPromiseValue<Promise<'name'>> // name

      数组类型

      数组类型想提取第一个元素的类型怎么做呢?

      ts
      type arr = [1, 2, 3]

      用它来匹配一个模式类型,提取第一个元素的类型到通过 infer 声明的局部变量里返回。

      ts
      type GetArrayFirstItem<T extends unknown[]> = T extends [
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"模式匹配","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/模式匹配.md","lastUpdated":1695392177000}'),p={name:"src/types/模式匹配.md"},o=l(`

      模式匹配

      Typescript 的类型也同样可以做模式匹配。

      比如这样一个 Promise 类型:

      ts
      type p = Promise<'value'>

      我们想提取 value 的类型,可以这样做:

      ts
      type GetPromiseValue<T> = T extends Promise<infer value> ? value : never

      通过 extends 对传入的类型参数 P 做模式匹配,其中值的类型是需要提取的,通过 infer 声明一个局部变量 Value 来保存,如果匹配,就返回匹配到的 Value,否则就返回 never 代表没匹配到。

      ts
      type result = GetPromiseValue<Promise<'name'>> // name

      数组类型

      数组类型想提取第一个元素的类型怎么做呢?

      ts
      type arr = [1, 2, 3]

      用它来匹配一个模式类型,提取第一个元素的类型到通过 infer 声明的局部变量里返回。

      ts
      type GetArrayFirstItem<T extends unknown[]> = T extends [
         infer value,
         ...unknown[],
       ]
      diff --git "a/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.443f232b.lean.js" "b/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.cf789a64.lean.js"
      similarity index 84%
      rename from "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.443f232b.lean.js"
      rename to "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.cf789a64.lean.js"
      index 7b4acb5ba..a64a5f5fa 100644
      --- "a/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.443f232b.lean.js"
      +++ "b/assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.cf789a64.lean.js"
      @@ -1 +1 @@
      -import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"模式匹配","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/模式匹配.md","lastUpdated":1694741410000}'),p={name:"src/types/模式匹配.md"},o=l("",79),e=[o];function t(r,c,B,y,F,D){return n(),a("div",null,e)}const E=s(p,[["render",t]]);export{A as __pageData,E as default};
      +import{_ as s,o as n,c as a,N as l}from"./chunks/framework.6fe2e870.js";const A=JSON.parse('{"title":"模式匹配","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/模式匹配.md","lastUpdated":1695392177000}'),p={name:"src/types/模式匹配.md"},o=l("",79),e=[o];function t(r,c,B,y,F,D){return n(),a("div",null,e)}const E=s(p,[["render",t]]);export{A as __pageData,E as default};
      diff --git "a/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.6f272ff9.js" "b/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.651abbf7.js"
      similarity index 99%
      rename from "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.6f272ff9.js"
      rename to "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.651abbf7.js"
      index 4deacde4c..e6a7b013f 100644
      --- "a/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.6f272ff9.js"
      +++ "b/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.651abbf7.js"
      @@ -1,4 +1,4 @@
      -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型运算","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/类型运算.md","lastUpdated":1694741410000}'),l={name:"src/types/类型运算.md"},o=p(`

      TypeScript 类型系统中的类型运算

      条件:extends ? :

      TypeScript 里的条件判断是 extends ? :,叫做条件类型(Conditional Type)比如:

      ts
      type isTwo<T> = T extends 2 ? true : false
      +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型运算","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/类型运算.md","lastUpdated":1695392177000}'),l={name:"src/types/类型运算.md"},o=p(`

      TypeScript 类型系统中的类型运算

      条件:extends ? :

      TypeScript 里的条件判断是 extends ? :,叫做条件类型(Conditional Type)比如:

      ts
      type isTwo<T> = T extends 2 ? true : false
       
       type res = isTwo<1> // true
       type res2 = isTwo<2> // false

      这种类型也叫做高级类型。

      高级类型的特点是传入类型参数,经过一系列类型运算逻辑后,返回新的类型。

      推导:infer

      如何提取类型的一部分呢?答案是 infer。

      比如提取元组类型的第一个元素:

      ts
      type FirstTupleItem<Tuple extends unknown[]> = Tuple extends [infer T, ...inter R] ? T : never;
      diff --git "a/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.6f272ff9.lean.js" "b/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.651abbf7.lean.js"
      similarity index 70%
      rename from "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.6f272ff9.lean.js"
      rename to "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.651abbf7.lean.js"
      index 49116ee3e..acf0d7157 100644
      --- "a/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.6f272ff9.lean.js"
      +++ "b/assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.651abbf7.lean.js"
      @@ -1 +1 @@
      -import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型运算","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/类型运算.md","lastUpdated":1694741410000}'),l={name:"src/types/类型运算.md"},o=p("",35),e=[o];function t(c,r,y,B,F,D){return a(),n("div",null,e)}const A=s(l,[["render",t]]);export{E as __pageData,A as default};
      +import{_ as s,o as a,c as n,N as p}from"./chunks/framework.6fe2e870.js";const E=JSON.parse('{"title":"TypeScript 类型系统中的类型运算","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/类型运算.md","lastUpdated":1695392177000}'),l={name:"src/types/类型运算.md"},o=p("",35),e=[o];function t(c,r,y,B,F,D){return a(),n("div",null,e)}const A=s(l,[["render",t]]);export{E as __pageData,A as default};
      diff --git "a/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.d2dad7c8.js" "b/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.5c7fd978.js"
      similarity index 98%
      rename from "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.d2dad7c8.js"
      rename to "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.5c7fd978.js"
      index 6b99fc446..1ae4386cf 100644
      --- "a/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.d2dad7c8.js"
      +++ "b/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.5c7fd978.js"
      @@ -1 +1 @@
      -import{_ as a,o as e,c as r,N as t}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"TypeScript 内置的高级类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/高级类型.md","lastUpdated":1694741410000}'),i={name:"src/types/高级类型.md"},o=t('

      TypeScript 内置的高级类型

      Parameters

      Parameters 用于提取函数类型的参数类型。

      ReturnType

      ReturnType 用于提取函数类型的返回值类型。

      ConstructorParameters

      构造器类型和函数类型的区别就是可以被 new。

      Parameters 用于提取函数参数的类型,而 ConstructorParameters 用于提取构造器参数的类型。

      InstanceType

      提取了构造器参数的类型,自然也可以提取构造器返回值的类型,就是 InstanceType。

      ThisParameterType

      OmitThisParameter

      Partial

      Required

      Readonly

      Pick

      Record

      Exclude

      Extract

      Omit

      Awaited

      NonNullable

      Uppercase

      Lowercase

      Capitalize

      Uncapitalize

      总结

      比如用模式匹配可以实现:Parameters、ReturnType、ConstructorParameters、InstanceType、ThisParameterType。

      用模式匹配 + 重新构造可以实现:OmitThisParameter

      用重新构造可以实现:Partial、Required、Readonly、Pick、Record

      用模式匹配 + 递归可以实现: Awaited

      用联合类型在分布式条件类型的特性可以实现: Exclude

      此外还有 NonNullable 和四个编译器内部实现的类型:Uppercase、Lowercase、Capitalize、Uncapitalize。

      ',33),l=[o];function n(h,c,s,d,p,u){return e(),r("div",null,l)}const q=a(i,[["render",n]]);export{b as __pageData,q as default}; +import{_ as a,o as e,c as r,N as t}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"TypeScript 内置的高级类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/高级类型.md","lastUpdated":1695392177000}'),i={name:"src/types/高级类型.md"},o=t('

      TypeScript 内置的高级类型

      Parameters

      Parameters 用于提取函数类型的参数类型。

      ReturnType

      ReturnType 用于提取函数类型的返回值类型。

      ConstructorParameters

      构造器类型和函数类型的区别就是可以被 new。

      Parameters 用于提取函数参数的类型,而 ConstructorParameters 用于提取构造器参数的类型。

      InstanceType

      提取了构造器参数的类型,自然也可以提取构造器返回值的类型,就是 InstanceType。

      ThisParameterType

      OmitThisParameter

      Partial

      Required

      Readonly

      Pick

      Record

      Exclude

      Extract

      Omit

      Awaited

      NonNullable

      Uppercase

      Lowercase

      Capitalize

      Uncapitalize

      总结

      比如用模式匹配可以实现:Parameters、ReturnType、ConstructorParameters、InstanceType、ThisParameterType。

      用模式匹配 + 重新构造可以实现:OmitThisParameter

      用重新构造可以实现:Partial、Required、Readonly、Pick、Record

      用模式匹配 + 递归可以实现: Awaited

      用联合类型在分布式条件类型的特性可以实现: Exclude

      此外还有 NonNullable 和四个编译器内部实现的类型:Uppercase、Lowercase、Capitalize、Uncapitalize。

      ',33),l=[o];function n(h,c,s,d,p,u){return e(),r("div",null,l)}const q=a(i,[["render",n]]);export{b as __pageData,q as default}; diff --git "a/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.d2dad7c8.lean.js" "b/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.5c7fd978.lean.js" similarity index 85% rename from "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.d2dad7c8.lean.js" rename to "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.5c7fd978.lean.js" index 1d99bc270..9cab68d94 100644 --- "a/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.d2dad7c8.lean.js" +++ "b/assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.5c7fd978.lean.js" @@ -1 +1 @@ -import{_ as a,o as e,c as r,N as t}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"TypeScript 内置的高级类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/高级类型.md","lastUpdated":1694741410000}'),i={name:"src/types/高级类型.md"},o=t("",33),l=[o];function n(h,c,s,d,p,u){return e(),r("div",null,l)}const q=a(i,[["render",n]]);export{b as __pageData,q as default}; +import{_ as a,o as e,c as r,N as t}from"./chunks/framework.6fe2e870.js";const b=JSON.parse('{"title":"TypeScript 内置的高级类型","description":"","frontmatter":{},"headers":[],"relativePath":"src/types/高级类型.md","lastUpdated":1695392177000}'),i={name:"src/types/高级类型.md"},o=t("",33),l=[o];function n(h,c,s,d,p,u){return e(),r("div",null,l)}const q=a(i,[["render",n]]);export{b as __pageData,q as default}; diff --git a/hashmap.json b/hashmap.json index e73af1315..b4e35eeda 100644 --- a/hashmap.json +++ b/hashmap.json @@ -1 +1 @@ -{"index.md":"1171a754","src_article_imagemin.md":"0a9c8df2","src_article_javascript_domload.md":"c5bd0e6b","src_article_bundle.md":"9ad74b74","src_article_functionalprogramming.md":"a3014e39","src_article_babel.md":"fa7e2aa7","src_article_typescript_calculate.md":"426c7cc5","src_article_astparse_tokenizer.md":"4a99ed19","src_article_typescript_index.md":"a7682bcc","src_article_typescript_reconstruction.md":"64c91658","src_article_designmode.md":"a215a004","src_article_typescript_pattern.md":"1fd07afd","src_ranui_preview_index.md":"df81865f","src_ranui_image_index.md":"0bb00ae4","src_ranui_input_index.md":"648aa27c","src_ranui_modal_index.md":"8a1d5440","src_ranui_button_index.md":"fc18e80f","src_article_typescript_recursion.md":"a921b72b","src_ranui_message_index.md":"0f2c0223","src_ranui_index.md":"dd236557","src_article_typescript_uniontype.md":"08fc2c93","src_ranui_icon_index.md":"fb0d6bc2","src_ranuts_index.md":"04b76820","src_ranuts_sort_bubble_index.md":"470927dd","src_ranuts_file_index.md":"4a078d51","src_ranui_radar_index.md":"98db9ce7","src_ranuts_sort_merge_index.md":"0e0ee551","src_ranuts_utils_task.md":"c82636a6","src_ranuts_sort_index.md":"4bc20df7","src_ranuts_bundler_index.md":"f1a2bc24","src_ranui_tabs_index.md":"9404d616","src_ranui_tab_index.md":"17f1ce4b","src_ranuts_binarytree_index.md":"bfc58cc9","src_ranuts_sort_heap_index.md":"a866a7bc","src_ranuts_sort_select_index.md":"0ee7b8b9","src_ranuts_sort_shell_index.md":"95e50a19","src_ranuts_utils_index.md":"528940e0","src_ranuts_sort_insert_index.md":"ae885a3c","src_types_高级类型.md":"d2dad7c8","src_types_类型运算.md":"6f272ff9","src_ranuts_sort_bucket_index.md":"dda27ddc","src_ranuts_sort_count_index.md":"177b24c1","src_ranuts_sort_radix_index.md":"3884546e","src_ranui_skeleton_index.md":"71efc826","src_types_模式匹配.md":"443f232b","src_ranuts_sort_quick_index.md":"aeca65b0","src_types_ts类型.md":"ae69f8e2"} +{"src_ranui_image_index.md":"586060f5","src_ranui_index.md":"fd55dba2","src_ranui_input_index.md":"12be9d3c","src_ranui_message_index.md":"0cd3b7b1","src_ranui_modal_index.md":"528db34a","src_ranuts_binarytree_index.md":"355ccc5a","src_article_astparse_tokenizer.md":"191befd6","src_article_babel.md":"ec7666af","src_article_bundle.md":"846064e5","src_article_functionalprogramming.md":"a03bc09c","src_article_imagemin.md":"c9b5bd01","src_article_javascript_domload.md":"638b7c04","src_article_typescript_calculate.md":"082753d2","src_article_typescript_index.md":"e906a582","src_article_typescript_pattern.md":"7d9a7a5d","src_article_typescript_reconstruction.md":"2ba3370e","src_article_typescript_uniontype.md":"7f4c08c9","src_ranui_button_index.md":"f2904501","src_ranui_preview_index.md":"63eefe48","src_ranui_icon_index.md":"f70b076f","src_ranui_radar_index.md":"9aef7e94","src_ranui_skeleton_index.md":"018b869c","src_ranui_tab_index.md":"7cc8e01b","src_ranuts_bundler_index.md":"d8142e57","src_ranuts_file_index.md":"c559e8ec","src_ranuts_index.md":"9270416e","src_ranuts_sort_bubble_index.md":"652859bb","src_ranuts_sort_bucket_index.md":"d882f777","src_ranuts_sort_count_index.md":"92c99ed2","src_ranuts_sort_heap_index.md":"bfff8633","src_ranuts_sort_index.md":"2b3ea8db","src_ranuts_sort_insert_index.md":"41df7c24","src_ranuts_sort_merge_index.md":"a444075a","src_ranuts_sort_quick_index.md":"a098262a","src_ranuts_sort_radix_index.md":"6aa13c07","src_ranuts_sort_select_index.md":"b30d74cc","index.md":"0769705f","src_types_模式匹配.md":"cf789a64","src_ranuts_sort_shell_index.md":"bd6b216b","src_ranuts_utils_index.md":"d9268c55","src_ranuts_utils_task.md":"c229cafb","src_types_ts类型.md":"b85d8306","src_types_高级类型.md":"5c7fd978","src_types_类型运算.md":"651abbf7","src_article_typescript_recursion.md":"0d25062b","src_ranui_tabs_index.md":"d1c61126","src_article_designmode.md":"3ac9a4d9"} diff --git a/index.html b/index.html index 0e8aa4b79..22df0503c 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,9 @@ Home | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + +
      Skip to content

      ran

      风起于青萍之末

      A ship in harbor is safe, but that is not what ships are built for.

      logo
      ⚡️

      记录

      每当遇到问题或者可以改进的事情的时候,会把想法先写下来,如果这是你遇到的问题,那么很可能有一群人也遇到同样的困难。

      🖖

      解决

      过一段时间后,再回来看看这些问题是否还有意义。然后再研究这个问题,确定是否存在解决方案。

      🛠️

      改进

      通常会发现一个工具是为了解决一个问题,我会去考虑如何改进或者简化这个工具。创造一个更好的轮子。

      Released under the MIT License.

      - + \ No newline at end of file diff --git a/src/article/astParse/tokenizer.html b/src/article/astParse/tokenizer.html index 02b633548..3e1bc9ab9 100644 --- a/src/article/astParse/tokenizer.html +++ b/src/article/astParse/tokenizer.html @@ -4,9 +4,9 @@ Abstract Syntax Tree | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -164,7 +172,7 @@ // 单字符到 Token 生成器的映射 const KNOWN_SINGLE_CHAR_TOKENS = new Map< SingleCharTokens, - typeof TOKENS_GENERATOR[keyof typeof TOKENS_GENERATOR] + (typeof TOKENS_GENERATOR)[keyof typeof TOKENS_GENERATOR] >([ ['(', TOKENS_GENERATOR.leftParen], [')', TOKENS_GENERATOR.rightParen], @@ -240,9 +248,9 @@ { type: 'RightParen', value: ')', start: 17, end: 18 }, { type: 'LeftCurly', value: '{', start: 19, end: 20 }, { type: 'RightCurly', value: '}', start: 20, end: 21 }, -]

      一个简易版本的分词器已经被我们开发出来了,不过目前的分词器还比较简陋,仅仅支持有限的语法,不过在明确了核心的开发步骤之后,后面继续完善的过程就比较简单了。

      四.编写语法分析器(Parser)

      在解析出词法 token 之后,我们就可以进入语法分析阶段了。在这个阶段,我们会依次遍历 token ,对代码进行语法结构层面的分析,最后的目标是生成 AST 数据结构。至于代码的 AST 结构到底是什么样子,你可以去 AST Explorer 网站进行在线预览:

      接下来,我们要做的就是将 token 数组转换为上图所示的 AST 数据。

      开发步骤主要分为:

      • 初始化类型声明

      Released under the MIT License.

      - +]

      一个简易版本的分词器已经被我们开发出来了,不过目前的分词器还比较简陋,仅仅支持有限的语法,不过在明确了核心的开发步骤之后,后面继续完善的过程就比较简单了。

      四.编写语法分析器(Parser)

      在解析出词法 token 之后,我们就可以进入语法分析阶段了。在这个阶段,我们会依次遍历 token ,对代码进行语法结构层面的分析,最后的目标是生成 AST 数据结构。至于代码的 AST 结构到底是什么样子,你可以去 AST Explorer 网站进行在线预览:

      接下来,我们要做的就是将 token 数组转换为上图所示的 AST 数据。

      开发步骤主要分为:

      • 初始化类型声明

      Released under the MIT License.

      + \ No newline at end of file diff --git a/src/article/babel.html b/src/article/babel.html index 9c087cdc2..433033cff 100644 --- a/src/article/babel.html +++ b/src/article/babel.html @@ -4,9 +4,9 @@ Babel | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
      Skip to content
      On this page

      Babel

      babel 核心库主要是:

      • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
      • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
      • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
      • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
      • @babel/code-frame 可以创建友好的报错信息
      • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
      • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。

      Released under the MIT License.

      - +
      Skip to content
      On this page

      Babel

      babel 核心库主要是:

      • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
      • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
      • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
      • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
      • @babel/code-frame 可以创建友好的报错信息
      • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
      • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。

      Released under the MIT License.

      + \ No newline at end of file diff --git a/src/article/bundle.html b/src/article/bundle.html index b0b020a04..69579dbf1 100644 --- a/src/article/bundle.html +++ b/src/article/bundle.html @@ -4,9 +4,9 @@ Bundle | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
      Skip to content
      On this page

      Bundle

      Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:

      • 编译能力
      • 插件机制
      • HMR
      • cli 和命令行能力

      Released under the MIT License.

      - +
      Skip to content
      On this page

      Bundle

      Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:

      • 编译能力
      • 插件机制
      • HMR
      • cli 和命令行能力

      Released under the MIT License.

      + \ No newline at end of file diff --git a/src/article/designMode.html b/src/article/designMode.html index d45ea4a7a..aea069e34 100644 --- a/src/article/designMode.html +++ b/src/article/designMode.html @@ -4,9 +4,9 @@ 23 种经典设计模式 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -800,9 +808,9 @@ Visitor.push(a,1,2,3,4); Visitor.push(a,4,5,6); Visitor.pop(a); -Visitor.splice(a,2);

      访问者模式解决了数据与数据的操作方法之间的耦合,让数据的操作方法独立于数据,使其可以自由演变。因此,访问者模式更适合于那些数据稳定、但数据的操作方法易变的环境下。

      优点:

      • 增加新的访问操作很方便。使用访问者模式,增加新的访问操作就意味着增加一个新的具体访问者类,实现简单,无须修改源代码,符合“开闭原则”。
      • 将有关元素对象的访问行为集中到一个访问者对象中,而不是分散在一个个的元素类中。类的职责更加清晰,有利于对象结构中元素对象的复用,相同的对象结构可以供多个不同的访问者访问。
      • 让用户能够在不修改现有元素类层次结构的情况下,定义作用于该层次结构的操作。

      缺点:

      • 增加新的元素类很困难。在访问者模式中,每增加一个新的元素类都意味着要在抽象访问者角色中增加一个新的抽象操作,并在每一个具体访问者类中增加相应的具体操作,这违背了“开闭原则”的要求。
      • 破坏封装。访问者模式要求访问者对象访问并调用每一个元素对象的操作,这意味着元素对象有时候必须暴露一些自己的内部操作和内部状态,否则无法供访问者访问。

      总结

      系统地学习设计模式后,你可以在过往的开发经历中发现,设计模式是无处不在的。在学习设计模式之前的很多时候我们是凭借过往经验和智慧来完善系统的设计,而这些经验很多和某个设计模式的思想不谋而合。

      还有一些地方没有完全理解,文中有误之处还望不吝指出。

      参考资料

      Released under the MIT License.

      - +Visitor.splice(a,2);

      访问者模式解决了数据与数据的操作方法之间的耦合,让数据的操作方法独立于数据,使其可以自由演变。因此,访问者模式更适合于那些数据稳定、但数据的操作方法易变的环境下。

      优点:

      • 增加新的访问操作很方便。使用访问者模式,增加新的访问操作就意味着增加一个新的具体访问者类,实现简单,无须修改源代码,符合“开闭原则”。
      • 将有关元素对象的访问行为集中到一个访问者对象中,而不是分散在一个个的元素类中。类的职责更加清晰,有利于对象结构中元素对象的复用,相同的对象结构可以供多个不同的访问者访问。
      • 让用户能够在不修改现有元素类层次结构的情况下,定义作用于该层次结构的操作。

      缺点:

      • 增加新的元素类很困难。在访问者模式中,每增加一个新的元素类都意味着要在抽象访问者角色中增加一个新的抽象操作,并在每一个具体访问者类中增加相应的具体操作,这违背了“开闭原则”的要求。
      • 破坏封装。访问者模式要求访问者对象访问并调用每一个元素对象的操作,这意味着元素对象有时候必须暴露一些自己的内部操作和内部状态,否则无法供访问者访问。

      总结

      系统地学习设计模式后,你可以在过往的开发经历中发现,设计模式是无处不在的。在学习设计模式之前的很多时候我们是凭借过往经验和智慧来完善系统的设计,而这些经验很多和某个设计模式的思想不谋而合。

      还有一些地方没有完全理解,文中有误之处还望不吝指出。

      参考资料

      Released under the MIT License.

      + \ No newline at end of file diff --git a/src/article/functionalProgramming.html b/src/article/functionalProgramming.html index 14af6a210..d9bed42a7 100644 --- a/src/article/functionalProgramming.html +++ b/src/article/functionalProgramming.html @@ -4,9 +4,9 @@ 函数式编程 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -386,9 +394,9 @@ } let r = readFile('package.json') //这里可以用map去处理内容 .flatMap(print) - .join()

      参考资料

      Released under the MIT License.

      - + .join()

      参考资料

    Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/imagemin.html b/src/article/imagemin.html index c77d85564..b634dc840 100644 --- a/src/article/imagemin.html +++ b/src/article/imagemin.html @@ -4,9 +4,9 @@ imagemin 图片压缩源码分析 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

imagemin 图片压缩源码分析

Released under the MIT License.

- +
Skip to content
On this page

imagemin 图片压缩源码分析

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/javascript/domLoad.html b/src/article/javascript/domLoad.html index c69b8773f..20c25fe98 100644 --- a/src/article/javascript/domLoad.html +++ b/src/article/javascript/domLoad.html @@ -4,9 +4,9 @@ 页面加载完成后事件 | ran - + - + @@ -35,25 +35,33 @@ - - - + + + - + + + + + + + + + - - + +
Skip to content
On this page

页面加载完成后事件

window.onload

DOMContentLoaded

js
document.addEventListener('DOMContentLoaded', fun)

<body onload="fun()">

readyState

js
document.readyState
 
-document.onreadystatechange

一个文档的 readyState 可以是以下之一:

  • loading / 加载 。document 仍在加载。
  • interactive / 互动。文档已经完成加载,文档已被解析,但是诸如图像,样式表和框架之类的子资源仍在加载。
  • complete / 完成。T 文档和所有子资源已完成加载。状态表示 load 事件即将被触发。

Released under the MIT License.

- +document.onreadystatechange

一个文档的 readyState 可以是以下之一:

  • loading / 加载 。document 仍在加载。
  • interactive / 互动。文档已经完成加载,文档已被解析,但是诸如图像,样式表和框架之类的子资源仍在加载。
  • complete / 完成。T 文档和所有子资源已完成加载。状态表示 load 事件即将被触发。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/typescript/calculate.html b/src/article/typescript/calculate.html index 9c5095d6a..cd97ecc68 100644 --- a/src/article/typescript/calculate.html +++ b/src/article/typescript/calculate.html @@ -4,9 +4,9 @@ 数组长度做计数 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -108,9 +116,9 @@ Num > -type Fibonacci<Num extends number> = FibonacciLoop<[1], [], [], Num>

类型参数 PrevArr 是代表之前的累加值的数组。类型参数 CurrentArr 是代表当前数值的数组。

类型参数 IndexArr 用于记录 index,每次递归加一,默认值是 [],代表从 0 开始。

类型参数 Num 代表求数列的第几个数。

判断当前 index 也就是 IndexArr['length'] 是否到了 Num,到了就返回当前的数值 CurrentArr['length']。

否则求出当前 index 对应的数值,用之前的数加上当前的数 [...PrevArr, ... CurrentArr]。

然后继续递归,index + 1,也就是 [...IndexArr, unknown]。

这就是递归计算 Fibinacci 数列的数的过程。

可以正确的算出第 8 个数是 21:

Released under the MIT License.

- +type Fibonacci<Num extends number> = FibonacciLoop<[1], [], [], Num>

类型参数 PrevArr 是代表之前的累加值的数组。类型参数 CurrentArr 是代表当前数值的数组。

类型参数 IndexArr 用于记录 index,每次递归加一,默认值是 [],代表从 0 开始。

类型参数 Num 代表求数列的第几个数。

判断当前 index 也就是 IndexArr['length'] 是否到了 Num,到了就返回当前的数值 CurrentArr['length']。

否则求出当前 index 对应的数值,用之前的数加上当前的数 [...PrevArr, ... CurrentArr]。

然后继续递归,index + 1,也就是 [...IndexArr, unknown]。

这就是递归计算 Fibinacci 数列的数的过程。

可以正确的算出第 8 个数是 21:

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/typescript/index.html b/src/article/typescript/index.html index e6e2f927b..988a28cda 100644 --- a/src/article/typescript/index.html +++ b/src/article/typescript/index.html @@ -4,9 +4,9 @@ TypeScript 的类型系统 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -230,9 +238,9 @@ ? R : never

类型参数 U 是要转换的联合类型。

U extends U 是为了触发联合类型的 distributive 的性质,让每个类型单独传入做计算,最后合并。

利用 U 做为参数构造个函数,通过模式匹配取参数的类型。

结果就是交叉类型

函数参数的逆变性质一般就联合类型转交叉类型会用,记住就行。

GetOptional

如何提取索引类型中的可选索引呢?

这也要利用可选索引的特性:可选索引的值为 undefined 和值类型的联合类型。

过滤可选索引,就要构造一个新的索引类型,过程中做过滤:

ts
type GetOptional<Obj extends Record<string, any>> = {
   [Key in keyof Obj as {} extends Pick<Obj, Key> ? Key : never]: Obj[Key]
-}

类型参数 Obj 为待处理的索引类型,类型约束为索引为 string、值为任意类型的索引类型 Record<string, any>。

用映射类型的语法重新构造索引类型,索引是之前的索引也就是 Key in keyof Obj,但要做一些过滤,也就是 as 之后的部分。

过滤的方式就是单独取出该索引之后,判断空对象是否是其子类型。

这里的 Pick 是 ts 提供的内置高级类型,就是取出某个 Key 构造新的索引类型:

ts
type Pick<T, K extends keyof T> = { [P in K]: T[P] }

比如单独取出 age 构造的新的索引类型是这样的:

可选的意思是这个索引可能没有,没有的时候,那 Pick<Obj, Key> 就是空的,所以 {} extends Pick<Obj, Key> 就能过滤出可选索引。

值的类型依然是之前的,也就是 Obj[Key]。

这样,就能过滤出所有可选索引,构造成新的索引类型:

总结

  • any 类型与任何类型的交叉都是 any,也就是 1 & any 结果是 any,可以用这个特性判断 any 类型。
  • 联合类型作为类型参数出现在条件类型左侧时,会分散成单个类型传入,最后合并。
  • never 作为类型参数出现在条件类型左侧时,会直接返回 never。
  • any 作为类型参数出现在条件类型左侧时,会直接返回 trueType 和 falseType 的联合类型。
  • 元组类型也是数组类型,但 length 是数字字面量,而数组的 length 是 number。可以用来判断元组类型。
  • 函数参数处会发生逆变,可以用来实现联合类型转交叉类型。
  • 可选索引的索引可能没有,那 Pick 出来的就可能是 {},可以用来过滤可选索引,反过来也可以过滤非可选索引。
  • 索引类型的索引为字符串字面量类型,而可索引签名不是,可以用这个特性过滤掉可索引签名。
  • keyof 只能拿到 class 的 public 的索引,可以用来过滤出 public 的属性。
  • 默认推导出来的不是字面量类型,加上 as const 可以推导出字面量类型,但带有 readonly 修饰,这样模式匹配的时候也得加上 readonly 才行。

Released under the MIT License.

- +}

类型参数 Obj 为待处理的索引类型,类型约束为索引为 string、值为任意类型的索引类型 Record<string, any>。

用映射类型的语法重新构造索引类型,索引是之前的索引也就是 Key in keyof Obj,但要做一些过滤,也就是 as 之后的部分。

过滤的方式就是单独取出该索引之后,判断空对象是否是其子类型。

这里的 Pick 是 ts 提供的内置高级类型,就是取出某个 Key 构造新的索引类型:

ts
type Pick<T, K extends keyof T> = { [P in K]: T[P] }

比如单独取出 age 构造的新的索引类型是这样的:

可选的意思是这个索引可能没有,没有的时候,那 Pick<Obj, Key> 就是空的,所以 {} extends Pick<Obj, Key> 就能过滤出可选索引。

值的类型依然是之前的,也就是 Obj[Key]。

这样,就能过滤出所有可选索引,构造成新的索引类型:

总结

  • any 类型与任何类型的交叉都是 any,也就是 1 & any 结果是 any,可以用这个特性判断 any 类型。
  • 联合类型作为类型参数出现在条件类型左侧时,会分散成单个类型传入,最后合并。
  • never 作为类型参数出现在条件类型左侧时,会直接返回 never。
  • any 作为类型参数出现在条件类型左侧时,会直接返回 trueType 和 falseType 的联合类型。
  • 元组类型也是数组类型,但 length 是数字字面量,而数组的 length 是 number。可以用来判断元组类型。
  • 函数参数处会发生逆变,可以用来实现联合类型转交叉类型。
  • 可选索引的索引可能没有,那 Pick 出来的就可能是 {},可以用来过滤可选索引,反过来也可以过滤非可选索引。
  • 索引类型的索引为字符串字面量类型,而可索引签名不是,可以用这个特性过滤掉可索引签名。
  • keyof 只能拿到 class 的 public 的索引,可以用来过滤出 public 的属性。
  • 默认推导出来的不是字面量类型,加上 as const 可以推导出字面量类型,但带有 readonly 修饰,这样模式匹配的时候也得加上 readonly 才行。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/typescript/pattern.html b/src/article/typescript/pattern.html index 8f1f14e70..d2193c3ed 100644 --- a/src/article/typescript/pattern.html +++ b/src/article/typescript/pattern.html @@ -4,9 +4,9 @@ 模式匹配提取 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -169,9 +177,9 @@ : never : never

类型参数 Props 为待处理的类型。

通过 keyof Props 取出 Props 的所有索引构成的联合类型,判断下 ref 是否在其中,也就是 'ref' extends keyof Props。

为什么要做这个判断,上面注释里写了:

在 ts3.0 里面如果没有对应的索引,Obj[Key] 返回的是 {} 而不是 never,所以这样做下兼容处理。

如果有 ref 这个索引的话,就通过 infer 提取 Value 的类型返回,否则返回 never。

ts
type GetPropsRefResult = GetPropsRef<{ ref: 1; name: 'str' }>
 // type GetPropsRefResult = 1

当 ref 为 undefined 时:

ts
type GetPropsRefResult = GetPropsRef<{ ref: undefined; name: 'str' }>
-// type GetPropsRefResult = undefined

Released under the MIT License.

- +// type GetPropsRefResult = undefined

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/typescript/reconstruction.html b/src/article/typescript/reconstruction.html index 8b63847a4..a64bd1704 100644 --- a/src/article/typescript/reconstruction.html +++ b/src/article/typescript/reconstruction.html @@ -4,9 +4,9 @@ 重新构造做变换 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -109,9 +117,9 @@ [Key in keyof T]-?: T[Key] }

给索引类型 T 的索引去掉 ? 的修饰 ,其余保持不变。

FilterByValueType

可以在构造新索引类型的时候根据值的类型做下过滤:

ts
type FilterByValueType<Obj extends Record<string, any>, ValueType> = {
   [Key in keyof Obj as Obj[Key] extends ValueType ? Key : never]: Obj[Key]
-}

类型参数 Obj 为要处理的索引类型,通过 extends 约束为索引为 string,值为任意类型的索引类型 Record<string, any>。

类型参数 ValueType 为要过滤出的值的类型。

构造新的索引类型,索引为 Obj 的索引,也就是 Key in keyof Obj,但要做一些变换,也就是 as 之后的部分。

如果原来索引的值 Obj[Key] 是 ValueType 类型,索引依然为之前的索引 Key,否则索引设置为 never,never 的索引会在生成新的索引类型时被去掉。

值保持不变,依然为原来索引的值,也就是 Obj[Key]。

这样就达到了过滤索引类型的索引,产生新的索引类型的目的:

Released under the MIT License.

- +}

类型参数 Obj 为要处理的索引类型,通过 extends 约束为索引为 string,值为任意类型的索引类型 Record<string, any>。

类型参数 ValueType 为要过滤出的值的类型。

构造新的索引类型,索引为 Obj 的索引,也就是 Key in keyof Obj,但要做一些变换,也就是 as 之后的部分。

如果原来索引的值 Obj[Key] 是 ValueType 类型,索引依然为之前的索引 Key,否则索引设置为 never,never 的索引会在生成新的索引类型时被去掉。

值保持不变,依然为原来索引的值,也就是 Obj[Key]。

这样就达到了过滤索引类型的索引,产生新的索引类型的目的:

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/typescript/recursion.html b/src/article/typescript/recursion.html index 40fa00348..5d7b32af6 100644 --- a/src/article/typescript/recursion.html +++ b/src/article/typescript/recursion.html @@ -4,9 +4,9 @@ 递归复用 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -145,9 +153,9 @@ : DeepReadonly<Obj[Key]> : Obj[Key] } - : never

Released under the MIT License.

- + : never

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/article/typescript/unionType.html b/src/article/typescript/unionType.html index 7ff915a5c..e86313ecf 100644 --- a/src/article/typescript/unionType.html +++ b/src/article/typescript/unionType.html @@ -4,9 +4,9 @@ 分布式条件类型 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -78,9 +86,9 @@ | `${A}${B}` | `${B}${A}`

然后构造出来的字符串再和其他字符串组合。

所以全组合的高级类型就是这样:

ts
type AllCombinations<A extends string, B extends string = A> = A extends A
   ? Combination<A, AllCombinations<Exclude<B, A>>>
-  : never

类型参数 A、B 是待组合的两个联合类型,B 默认是 A 也就是同一个。

A extends A 的意义就是让联合类型每个类型单独传入做处理,上面我们刚学会。

A 的处理就是 A 和 B 中去掉 A 以后的所有类型组合,也就是 Combination<A, B 去掉 A 以后的所有组合>。

而 B 去掉 A 以后的所有组合就是 AllCombinations<Exclude<B, A>>,所以全组合就是 Combination<A, AllCombinations<Exclude<B, A>>>。

总结

联合类型中的每个类型都是相互独立的,TypeScript 对它做了特殊处理,也就是遇到字符串类型、条件类型的时候会把每个类型单独传入做计算,最后把每个类型的计算结果合并成联合类型。

条件类型左边是联合类型的时候就会触法这种处理,叫做分布式条件类型。

有两点特别要注意:

  • A extends A 不是没意义,意义是取出联合类型中的单个类型放入 A

  • A extends A 才是分布式条件类型, [A] extends [A] 就不是了,只有左边是单独的类型参数才可以。

我们后面做了一些案例,发现联合类型的这种 distributive 的特性确实能简化类型编程,但是也增加了认知成本,不过这也是不可避免的事。

Released under the MIT License.

- + : never

类型参数 A、B 是待组合的两个联合类型,B 默认是 A 也就是同一个。

A extends A 的意义就是让联合类型每个类型单独传入做处理,上面我们刚学会。

A 的处理就是 A 和 B 中去掉 A 以后的所有类型组合,也就是 Combination<A, B 去掉 A 以后的所有组合>。

而 B 去掉 A 以后的所有组合就是 AllCombinations<Exclude<B, A>>,所以全组合就是 Combination<A, AllCombinations<Exclude<B, A>>>。

总结

联合类型中的每个类型都是相互独立的,TypeScript 对它做了特殊处理,也就是遇到字符串类型、条件类型的时候会把每个类型单独传入做计算,最后把每个类型的计算结果合并成联合类型。

条件类型左边是联合类型的时候就会触法这种处理,叫做分布式条件类型。

有两点特别要注意:

  • A extends A 不是没意义,意义是取出联合类型中的单个类型放入 A

  • A extends A 才是分布式条件类型, [A] extends [A] 就不是了,只有左边是单独的类型参数才可以。

我们后面做了一些案例,发现联合类型的这种 distributive 的特性确实能简化类型编程,但是也增加了认知成本,不过这也是不可避免的事。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/button/index.html b/src/ranui/button/index.html index 6bf108bae..f942d266f 100644 --- a/src/ranui/button/index.html +++ b/src/ranui/button/index.html @@ -4,9 +4,9 @@ Button 按钮 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -57,9 +65,9 @@ <r-button type="text" disabled>文本按钮</r-button> <r-button disabled>默认按钮</r-button>

图标icon

当需要在 Button 内嵌入 Icon 时,可以设置 icon 属性,或者直接在 Button 内使用 Icon 组件。

如果想控制 Icon 具体的位置,只能直接使用 Icon 组件,而非 icon 属性。

默认按钮
主要按钮
xml
<r-button type="default" icon="user">默认按钮</r-button>
 <r-button type="primary" icon="home">主要按钮</r-button>

特效 effect

如果需要纯净的 Button ,可以加上 effect = false ,屏蔽点击时候的水波纹特效

默认按钮主要按钮
xml
<r-button type="default" icon="user">默认按钮</r-button>
-<r-button type="primary" icon="home">主要按钮</r-button>

Released under the MIT License.

- +<r-button type="primary" icon="home">主要按钮</r-button>

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/icon/index.html b/src/ranui/icon/index.html index 89407c3fe..15bae2eca 100644 --- a/src/ranui/icon/index.html +++ b/src/ranui/icon/index.html @@ -4,9 +4,9 @@ Icon 图标 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -60,9 +68,9 @@ <r-icon name="lock" size="50" color="#F44336"></r-icon> <r-icon name="lock" size="50" color="#3F51B5"></r-icon>

旋转spin

设置 spin 开启旋转,传入数字控制旋转的速度,数字越小旋转越快

html
<r-icon name="loading" size="50" color="#1E90FF" spin="0.7"></r-icon>
 <r-icon name="loading" size="50" color="#1E90FF" spin></r-icon>
-<r-icon name="loading" size="50" color="#1E90FF" spin="5"></r-icon>

图标列表

Released under the MIT License.

- +<r-icon name="loading" size="50" color="#1E90FF" spin="5"></r-icon>

图标列表

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/image/index.html b/src/ranui/image/index.html index e5f40620c..49594d997 100644 --- a/src/ranui/image/index.html +++ b/src/ranui/image/index.html @@ -4,9 +4,9 @@ Image 图片 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

Image 图片

代码演示

xml
<r-img src="" fallback=""></r-img>

属性

图片加载地址src

图片的地址

图片加载失败fallback

src配置的图片加载失败,兜底的图片地址,下面是默认加载失败图片

Released under the MIT License.

- +
Skip to content
On this page

Image 图片

代码演示

xml
<r-img src="" fallback=""></r-img>

属性

图片加载地址src

图片的地址

图片加载失败fallback

src配置的图片加载失败,兜底的图片地址,下面是默认加载失败图片

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/index.html b/src/ranui/index.html index 9697105ac..7f30b6845 100644 --- a/src/ranui/index.html +++ b/src/ranui/index.html @@ -4,9 +4,9 @@ ranui | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -129,10 +137,10 @@ import 'ranui/style'

也可以全局导入,更加方便,这样什么都不用考虑了,梭哈完事。

  • ES module
js
import 'ranui'
  • UMD, IIFE, CJS
html
<script src="./ranui/dist/umd/index.umd.cjs"></script>

Overview 组件总览

  • Button
主要按钮
警告按钮
文本按钮
默认按钮
  • Icon
  • Skeleton
  • Input
  • message
信息提示警告提示错误提示成功提示toast 提示
  • Tab
tab1tab2tab3
  • Radar

Event 事件

HTML元素中,你可以使用on属性来定义事件处理程序。这是旧的事件处理程序的方法,现代的web开发推荐使用addEventListener方法。

html
<r-button id="button">按钮</r-button>
 
 <script>
-  const button = document.getElementById('button');  
-  button.addEventListener('click', function(event) {  
-    alert('新的点击事件!');  
-  });
+  const button = document.getElementById('button')
+  button.addEventListener('click', function (event) {
+    alert('新的点击事件!')
+  })
 </script>

然而,如果你确实需要使用on属性,下面是一个示例:

html
<r-input onchange="change(this.value)"></r-input>
 
 <script>
@@ -146,9 +154,9 @@
   input.onchange = (e) {
     console.log('e--->', e)
   }
-</script>

Compatibility 兼容性

  • 不支持 IE,其他均有较好支持

Contributors 贡献者

Other 相关资源

  1. 优秀的组件设计
  2. 在线生成 CSS 渐变色
  3. 优秀设计作品,有 psd 和 sketch
  4. 3D UI 设计,类似于 3D 版的 figma
  5. 设计规范
  6. 优秀设计作品
  7. element UI 中文网
  8. Ant design 中文网
  9. 在线绘制 CSS 动画
  10. tailwindcss 组件库
  11. animate css 非常优秀的 css 动画
  12. can i use 检测兼容性 API 网站
  13. figma

协议和标准

  1. RFCs
  2. ECMA
  3. w3c

Released under the MIT License.

- +</script>

Compatibility 兼容性

  • 不支持 IE,其他均有较好支持

Contributors 贡献者

Other 相关资源

  1. 优秀的组件设计
  2. 在线生成 CSS 渐变色
  3. 优秀设计作品,有 psd 和 sketch
  4. 3D UI 设计,类似于 3D 版的 figma
  5. 设计规范
  6. 优秀设计作品
  7. element UI 中文网
  8. Ant design 中文网
  9. 在线绘制 CSS 动画
  10. tailwindcss 组件库
  11. animate css 非常优秀的 css 动画
  12. can i use 检测兼容性 API 网站
  13. figma

协议和标准

  1. RFCs
  2. ECMA
  3. w3c

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/input/index.html b/src/ranui/input/index.html index 6afa69583..3c1aedd42 100644 --- a/src/ranui/input/index.html +++ b/src/ranui/input/index.html @@ -4,9 +4,9 @@ Input 输入框 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -59,9 +67,9 @@ const func = (e) => { console.log(e) } -input.addEventListener('input', func)

事件的e参数结构 input方法

Released under the MIT License.

- +input.addEventListener('input', func)

事件的e参数结构 input方法

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/message/index.html b/src/ranui/message/index.html index 87aa1c6a4..cea035ff4 100644 --- a/src/ranui/message/index.html +++ b/src/ranui/message/index.html @@ -4,9 +4,9 @@ message 全局提示 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -53,9 +61,9 @@ <r-button onclick="message.warning('这是一条提示')">警告提示</r-button> <r-button onclick="message.error('这是一条提示')">错误提示</r-button> <r-button onclick="message.success('这是一条提示')">成功提示</r-button> -<r-button onclick="message.toast('这是一条提示')">toast提示</r-button>

方法

组件提供了一些静态方法,使用方式和参数如下:

  1. 可以只传一个参数,提示的内容,默认提示 3000 毫秒

message.info('这是一条提示')

message.warning('这是一条提示')

message.error('这是一条提示')

message.success('这是一条提示')

message.toast('这是一条提示')"

  1. 也可以传一个对象,设置提示内容,关闭延时,关闭时触发的回调函数

message.info({content:'这是一条提示', duration: 2000, close: () => {}})

message.warning({content:'这是一条提示', duration: 2000, close: () => {}})

message.error({content:'这是一条提示', duration: 2000, close: () => {}})

message.success({content:'这是一条提示', duration: 2000, close: () => {}})

message.toast({content:'这是一条提示', duration: 2000, close: () => {}})

参数说明类型
content提示内容string
duration自动关闭的延时,单位毫秒。默认 3000 毫秒number
close关闭时触发的回调函数() => void

Released under the MIT License.

- +<r-button onclick="message.toast('这是一条提示')">toast提示</r-button>

方法

组件提供了一些静态方法,使用方式和参数如下:

  1. 可以只传一个参数,提示的内容,默认提示 3000 毫秒

message.info('这是一条提示')

message.warning('这是一条提示')

message.error('这是一条提示')

message.success('这是一条提示')

message.toast('这是一条提示')"

  1. 也可以传一个对象,设置提示内容,关闭延时,关闭时触发的回调函数

message.info({content:'这是一条提示', duration: 2000, close: () => {}})

message.warning({content:'这是一条提示', duration: 2000, close: () => {}})

message.error({content:'这是一条提示', duration: 2000, close: () => {}})

message.success({content:'这是一条提示', duration: 2000, close: () => {}})

message.toast({content:'这是一条提示', duration: 2000, close: () => {}})

参数说明类型
content提示内容string
duration自动关闭的延时,单位毫秒。默认 3000 毫秒number
close关闭时触发的回调函数() => void

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/modal/index.html b/src/ranui/modal/index.html index 4292c5c8a..bee00b22c 100644 --- a/src/ranui/modal/index.html +++ b/src/ranui/modal/index.html @@ -4,9 +4,9 @@ ran | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

Released under the MIT License.

- +
Skip to content
On this page

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/preview/index.html b/src/ranui/preview/index.html index 8c3205e48..ec33f23a6 100644 --- a/src/ranui/preview/index.html +++ b/src/ranui/preview/index.html @@ -4,9 +4,9 @@ preview 文件预览 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -70,9 +78,9 @@ } } } -</script>

属性

资源地址src

src 地址即可打开弹窗,没有src就不展示

html
<r-preview src=""></r-preview>

是否可关闭closeable

closeable 默认为 true ,可以关闭,设置成 false 时, 表示不可关闭,将不会展示右上角的关闭按钮

html
<r-preview closeable="false"></r-preview>

Released under the MIT License.

- +</script>

属性

资源地址src

src 地址即可打开弹窗,没有src就不展示

html
<r-preview src=""></r-preview>

是否可关闭closeable

closeable 默认为 true ,可以关闭,设置成 false 时, 表示不可关闭,将不会展示右上角的关闭按钮

html
<r-preview closeable="false"></r-preview>

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/radar/index.html b/src/ranui/radar/index.html index 61cd5c741..e2a2233d1 100644 --- a/src/ranui/radar/index.html +++ b/src/ranui/radar/index.html @@ -4,9 +4,9 @@ Radar 雷达图 | ran - + - + @@ -35,77 +35,85 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

Radar 雷达图

以二维形式综合对比多组数据的差异,常用于比较2组或更多组数据集

代码演示

xml
<r-radar 
+    
Skip to content
On this page

Radar 雷达图

以二维形式综合对比多组数据的差异,常用于比较 2 组或更多组数据集

代码演示

xml
<r-radar
     abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
-    style="width:300px;height:300px;display: block;" 
+    style="width:300px;height:300px;display: block;"
 >
-</r-radar>

属性

需要展示的数据abilitys

一个数组对象,对象中属性如下

参数说明类型
abilityName展示的属性名称必传参数string
scoreRate展示维度的数值,最大100必传参数number
backgroundColor属性名称的背景颜色可选参数string
fontSize属性名称的字体大小可选参数number
fontFamily属性名称的字体可选参数string
fontColor属性名称的字体颜色可选参数string
xml
<r-radar 
+</r-radar>

属性

需要展示的数据abilitys

一个数组对象,对象中属性如下

参数说明类型
abilityName展示的属性名称必传参数string
scoreRate展示维度的数值,最大 100必传参数number
backgroundColor属性名称的背景颜色可选参数string
fontSize属性名称的字体大小可选参数number
fontFamily属性名称的字体可选参数string
fontColor属性名称的字体颜色可选参数string
xml
<r-radar
     abilitys='[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
     style="width:300px;height:300px;display: block;"
 >
-</r-radar>

多边形颜色colorPolygon

xml
<r-radar 
-    colorPolygon="green" 
+</r-radar>

多边形颜色colorPolygon

xml
<r-radar
+    colorPolygon="green"
     abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
     style="width:300px;height:300px;display: block;"
 >
-</r-radar>

顶点连线颜色colorLine

xml
<r-radar 
-    colorLine="blue" 
+</r-radar>

顶点连线颜色colorLine

xml
<r-radar
+    colorLine="blue"
     abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
-></r-radar>

数据渲染处的颜色fillColor

xml
<r-radar 
-    fillColor="red" 
+></r-radar>

数据渲染处的颜色fillColor

xml
<r-radar
+    fillColor="red"
     abilitys='[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
     style="width:300px;height:300px;display: block;"
 >
-</r-radar>

数据渲染处线和点的颜色strokeColor

xml
<r-radar 
-    strokeColor="blue"  
+</r-radar>

数据渲染处线和点的颜色strokeColor

xml
<r-radar
+    strokeColor="blue"
     abilitys='[{"abilityName":"生命","scoreRate":"10"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'
-    style="width:300px;height:300px;display: block;" 
+    style="width:300px;height:300px;display: block;"
 >
 </r-radar>

使用的例子数据

由于HTMlattribute只能获取string。因此需要传入的数据需要是json字符串格式,然后通过JSON.parse解析程数组对象,如果JSON格式有误,则无法解析。

json
[
-    {
-        "abilityName":"生命",
-        "scoreRate":"10",
-        "backgroundColor":"red",
-        "fontSize":"30",
-        "fontColor":"blue"
-    },
-    {
-        "abilityName":"攻击",
-        "scoreRate":"90"
-    },
-    {
-        "abilityName":"防御",
-        "scoreRate":"20"
-    },
-    {
-        "abilityName":"元素精通",
-        "scoreRate":"50"
-    },
-    {
-        "abilityName":"暴击率",
-        "scoreRate":"80"
-    },
-    {
-        "abilityName":"暴击伤害",
-        "scoreRate":"50"
-    }
-]

Released under the MIT License.

- + { + "abilityName": "生命", + "scoreRate": "10", + "backgroundColor": "red", + "fontSize": "30", + "fontColor": "blue" + }, + { + "abilityName": "攻击", + "scoreRate": "90" + }, + { + "abilityName": "防御", + "scoreRate": "20" + }, + { + "abilityName": "元素精通", + "scoreRate": "50" + }, + { + "abilityName": "暴击率", + "scoreRate": "80" + }, + { + "abilityName": "暴击伤害", + "scoreRate": "50" + } +]

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/skeleton/index.html b/src/ranui/skeleton/index.html index ced88a025..3797b6ae5 100644 --- a/src/ranui/skeleton/index.html +++ b/src/ranui/skeleton/index.html @@ -4,9 +4,9 @@ skeleton 骨架屏 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

skeleton 骨架屏

在需要等待加载内容的位置提供一个占位图形组合。

代码演示

骨架长度跟随父级元素的长度

xml
<r-skeleton ></r-skeleton>

Released under the MIT License.

- +
Skip to content
On this page

skeleton 骨架屏

在需要等待加载内容的位置提供一个占位图形组合。

代码演示

骨架长度跟随父级元素的长度

xml
<r-skeleton ></r-skeleton>

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/tab/index.html b/src/ranui/tab/index.html index 6e20b5420..373f37aab 100644 --- a/src/ranui/tab/index.html +++ b/src/ranui/tab/index.html @@ -4,9 +4,9 @@ Tab 图标 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -91,9 +99,9 @@ <r-tab label="tab1">11111</r-tab> <r-tab label="tab2">22222</r-tab> <r-tab label="tab3">33333</r-tab> - </r-tabs>

Released under the MIT License.

- + </r-tabs>

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranui/tabs/index.html b/src/ranui/tabs/index.html index 5aa947267..29d35089e 100644 --- a/src/ranui/tabs/index.html +++ b/src/ranui/tabs/index.html @@ -4,9 +4,9 @@ Tab | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -73,9 +81,9 @@ <r-tab icon="home" iconSize="22">tab1</r-tab> <r-tab icon="message" iconSize="22">tab2</r-tab> <r-tab icon="user" iconSize="22">tab3</r-tab> -</r-tabs>

风格type

风格有 text,clean,

对齐align

事件event

onchange

切换完成时触发。

Released under the MIT License.

- +</r-tabs>

风格type

风格有 text,clean,

对齐align

事件event

onchange

切换完成时触发。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/binaryTree/index.html b/src/ranuts/binaryTree/index.html index e4ad047d2..0a8e7b013 100644 --- a/src/ranuts/binaryTree/index.html +++ b/src/ranuts/binaryTree/index.html @@ -4,9 +4,9 @@ 二叉树的定义 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

二叉树的定义

在计算机科学中,二叉树(Binary tree)是每个节点最多只有两个分支(即不存在分支度大于 2 的节点)的树结构。通常分支被称作“左子树”或“右子树”。二叉树的分支具有左右次序,不能随意颠倒[1]。。

二叉树的性质

  • 在二叉树的第 i 层上最多有 2^(i-1)个结点(i>=1)
  • 深度为 h 的二叉树,最多有 2^h-1 个结点,最少有 h 个结点(h>=1)
  • 包含 n 个结点的二叉树的高度至少为(log2n)+1
  • 非空的二叉树,分支度为 0 的总数为 n0,分支度为 2 的总数为 n2,则 n0=n2+1
  • 二叉树的总结点数 n = n1 + n2 + n0
  • 总连线数等于总节点数减一(B = n - 1)
  • 总连线数等于分支度为 2 的节点的两倍加上分支度为 1 的节点(B = n2 _ 2 + n1 _ 1)

二叉树的类型

满二叉树

一棵深度为 k 且有 2k-1 个节点的二叉树称为满二叉树。 除最后一层无任何子节点外,每一层上的所有结点都有两个子结点的二叉树[2]

完全二叉树

一棵深度为 k 的有 n 个结点的二叉树,对树中的结点按从上至下、从左到右的顺序进行编号,如果编号为 i(1≤i≤n)的结点与满二叉树中编号为 i 的结点在二叉树中的位置相同,则这棵二叉树称为完全二叉树。

二叉搜索树

二叉搜索树(BST)又称二叉查找树或二叉排序树。它或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉排序树。

平衡二叉树

平衡二叉树(AVL)一定是二叉搜索树,且左子树和右子树的高度差的绝对值不超过 1。 平衡二叉树

B 树

B 树属于多叉树又名平衡多路查找树(查找路径不只两个)

B+树

B+树是 B 树的变体,也是一种多路搜索树。

B*树

B* 树是 B+树的变体,在 B+树的非根和非叶子结点再增加指向兄弟的指针;B* 树定义了非叶子结点关键字个数至少为(2/3)M,即块的最低使用率为 2/3(代替 B+树的 1/2)。B 树分配新结点的概率比 B+树要低,空间使用率更高;

红黑树

红黑树是一种平衡二叉查找树的变体,它的左右子树高差有可能大于 1,所以红黑树不是严格意义上的平衡二叉树(AVL),但对它进行平衡的代价较低, 其平均统计性能要强于 AVL 。

遍历

前序遍历

后序遍历

中序遍历

层序遍历

常见算法题

镜像二叉树

重建二叉树

二叉树深度

二叉树节点总数

判断二叉树子结构

输入两棵二叉树 A 和 B,判断 B 是不是 A 的子结构。(ps:约定空树不是任意一个树的子结构)

参考文档

  1. 维基百科二叉树
  2. 百度百科满二叉树

Released under the MIT License.

- +
Skip to content
On this page

二叉树的定义

在计算机科学中,二叉树(Binary tree)是每个节点最多只有两个分支(即不存在分支度大于 2 的节点)的树结构。通常分支被称作“左子树”或“右子树”。二叉树的分支具有左右次序,不能随意颠倒[1]。。

二叉树的性质

  • 在二叉树的第 i 层上最多有 2^(i-1)个结点(i>=1)
  • 深度为 h 的二叉树,最多有 2^h-1 个结点,最少有 h 个结点(h>=1)
  • 包含 n 个结点的二叉树的高度至少为(log2n)+1
  • 非空的二叉树,分支度为 0 的总数为 n0,分支度为 2 的总数为 n2,则 n0=n2+1
  • 二叉树的总结点数 n = n1 + n2 + n0
  • 总连线数等于总节点数减一(B = n - 1)
  • 总连线数等于分支度为 2 的节点的两倍加上分支度为 1 的节点(B = n2 _ 2 + n1 _ 1)

二叉树的类型

满二叉树

一棵深度为 k 且有 2k-1 个节点的二叉树称为满二叉树。 除最后一层无任何子节点外,每一层上的所有结点都有两个子结点的二叉树[2]

完全二叉树

一棵深度为 k 的有 n 个结点的二叉树,对树中的结点按从上至下、从左到右的顺序进行编号,如果编号为 i(1≤i≤n)的结点与满二叉树中编号为 i 的结点在二叉树中的位置相同,则这棵二叉树称为完全二叉树。

二叉搜索树

二叉搜索树(BST)又称二叉查找树或二叉排序树。它或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉排序树。

平衡二叉树

平衡二叉树(AVL)一定是二叉搜索树,且左子树和右子树的高度差的绝对值不超过 1。 平衡二叉树

B 树

B 树属于多叉树又名平衡多路查找树(查找路径不只两个)

B+树

B+树是 B 树的变体,也是一种多路搜索树。

B*树

B* 树是 B+树的变体,在 B+树的非根和非叶子结点再增加指向兄弟的指针;B* 树定义了非叶子结点关键字个数至少为(2/3)M,即块的最低使用率为 2/3(代替 B+树的 1/2)。B 树分配新结点的概率比 B+树要低,空间使用率更高;

红黑树

红黑树是一种平衡二叉查找树的变体,它的左右子树高差有可能大于 1,所以红黑树不是严格意义上的平衡二叉树(AVL),但对它进行平衡的代价较低, 其平均统计性能要强于 AVL 。

遍历

前序遍历

后序遍历

中序遍历

层序遍历

常见算法题

镜像二叉树

重建二叉树

二叉树深度

二叉树节点总数

判断二叉树子结构

输入两棵二叉树 A 和 B,判断 B 是不是 A 的子结构。(ps:约定空树不是任意一个树的子结构)

参考文档

  1. 维基百科二叉树
  2. 百度百科满二叉树

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/bundler/index.html b/src/ranuts/bundler/index.html index e7e718459..23a3b8233 100644 --- a/src/ranuts/bundler/index.html +++ b/src/ranuts/bundler/index.html @@ -4,9 +4,9 @@ Bundler | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -58,9 +66,9 @@ generate: () => bundle.render() }; }); -}

架构图

Released under the MIT License.

- +}

架构图

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/file/index.html b/src/ranuts/file/index.html index 3736f8cdd..e86b4e564 100644 --- a/src/ranuts/file/index.html +++ b/src/ranuts/file/index.html @@ -4,9 +4,9 @@ 文件操作函数 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

文件操作函数

watchFile

观察一个文件是否改变

API

Return

  • Promise
参数说明类型描述
status文件是否被改变booleantrue 文件改变 false 文件没变

Options

参数说明类型默认值
path文件路径,需要监听的文件stringundefined
interval监听文件改变的时间,单位毫秒。number20

Released under the MIT License.

- +
Skip to content
On this page

文件操作函数

watchFile

观察一个文件是否改变

API

Return

  • Promise
参数说明类型描述
status文件是否被改变booleantrue 文件改变 false 文件没变

Options

参数说明类型默认值
path文件路径,需要监听的文件stringundefined
interval监听文件改变的时间,单位毫秒。number20

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/index.html b/src/ranuts/index.html index 327d7a63d..f7986f374 100644 --- a/src/ranuts/index.html +++ b/src/ranuts/index.html @@ -4,9 +4,9 @@ ran | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

Released under the MIT License.

- +
Skip to content
On this page

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/bubble/index.html b/src/ranuts/sort/bubble/index.html index f7a0a7e8e..8ee3c21c1 100644 --- a/src/ranuts/sort/bubble/index.html +++ b/src/ranuts/sort/bubble/index.html @@ -4,9 +4,9 @@ 冒泡排序(Bubble Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -62,9 +70,9 @@ } } return arr -}

Released under the MIT License.

- +}

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/bucket/index.html b/src/ranuts/sort/bucket/index.html index 01f17c013..2e1b1bde4 100644 --- a/src/ranuts/sort/bucket/index.html +++ b/src/ranuts/sort/bucket/index.html @@ -4,9 +4,9 @@ 桶排序 (Bucket Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -110,9 +118,9 @@ list = list.concat(count(buckets[i])) } return list -}

算法分析

桶排序最好情况下使用线性时间 O(n),桶排序的时间复杂度,取决与对各个桶之间数据进行排序的时间复杂度,因为其它部分的时间复杂度都为 O(n)。很显然,桶划分的越小,各个桶之间的数据越少,排序所用的时间也会越少。但相应的空间消耗就会增大。

Released under the MIT License.

- +}

算法分析

桶排序最好情况下使用线性时间 O(n),桶排序的时间复杂度,取决与对各个桶之间数据进行排序的时间复杂度,因为其它部分的时间复杂度都为 O(n)。很显然,桶划分的越小,各个桶之间的数据越少,排序所用的时间也会越少。但相应的空间消耗就会增大。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/count/index.html b/src/ranuts/sort/count/index.html index b7ca08be4..9e7b5c1fa 100644 --- a/src/ranuts/sort/count/index.html +++ b/src/ranuts/sort/count/index.html @@ -4,9 +4,9 @@ 计数排序( Count Sort ) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -81,9 +89,9 @@ } } return list -}

算法分析

计数排序是一个稳定的排序算法。当输入的元素是 n 个 0 到 k 之间的整数时,时间复杂度是 O(n+k),空间复杂度也是 O(n+k),其排序速度快于任何比较排序算法。当 k 不是很大并且序列比较集中时,计数排序是一个很有效的排序算法。

Released under the MIT License.

- +}

算法分析

计数排序是一个稳定的排序算法。当输入的元素是 n 个 0 到 k 之间的整数时,时间复杂度是 O(n+k),空间复杂度也是 O(n+k),其排序速度快于任何比较排序算法。当 k 不是很大并且序列比较集中时,计数排序是一个很有效的排序算法。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/heap/index.html b/src/ranuts/sort/heap/index.html index 7423f7e33..53b84e27e 100644 --- a/src/ranuts/sort/heap/index.html +++ b/src/ranuts/sort/heap/index.html @@ -4,9 +4,9 @@ 堆排序(Heap Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -97,9 +105,9 @@ const heap = (list: Array<number>): Array<number> => { const { arr } = new Heap(list) return arr -}

Released under the MIT License.

- +}

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/index.html b/src/ranuts/sort/index.html index dbf8dee11..17512d74b 100644 --- a/src/ranuts/sort/index.html +++ b/src/ranuts/sort/index.html @@ -4,9 +4,9 @@ 十大经典排序 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

十大经典排序

十种常见排序算法可以分为两大类:

  • 比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破 O(nlogn),因此也称为非线性时间比较类排序。
  • 非比较类排序:不通过比较来决定元素间的相对次序,它可以突破基于比较排序的时间下界,以线性时间运行,因此也称为线性时间非比较类排序。 排序分类 0.2 算法复杂度

算法复杂度 0.3 相关概念

  • 稳定:如果 a 原本在 b 前面,而 a=b,排序之后 a 仍然在 b 的前面。
  • 不稳定:如果 a 原本在 b 的前面,而 a=b,排序之后 a 可能会出现在 b 的后面。
  • 时间复杂度:对排序数据的总的操作次数。反映当 n 变化时,操作次数呈现什么规律。
  • 空间复杂度:是指算法在计算机内执行时所需存储空间的度量,它也是数据规模 n 的函数。

Released under the MIT License.

- +
Skip to content
On this page

十大经典排序

十种常见排序算法可以分为两大类:

  • 比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破 O(nlogn),因此也称为非线性时间比较类排序。
  • 非比较类排序:不通过比较来决定元素间的相对次序,它可以突破基于比较排序的时间下界,以线性时间运行,因此也称为线性时间非比较类排序。 排序分类 0.2 算法复杂度

算法复杂度 0.3 相关概念

  • 稳定:如果 a 原本在 b 前面,而 a=b,排序之后 a 仍然在 b 的前面。
  • 不稳定:如果 a 原本在 b 的前面,而 a=b,排序之后 a 可能会出现在 b 的后面。
  • 时间复杂度:对排序数据的总的操作次数。反映当 n 变化时,操作次数呈现什么规律。
  • 空间复杂度:是指算法在计算机内执行时所需存储空间的度量,它也是数据规模 n 的函数。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/insert/index.html b/src/ranuts/sort/insert/index.html index e74c619cc..044b5b794 100644 --- a/src/ranuts/sort/insert/index.html +++ b/src/ranuts/sort/insert/index.html @@ -4,9 +4,9 @@ 插入排序(Insert Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -61,9 +69,9 @@ list[preIndex + 1] = current } return list -}

算法分析

插入排序在实现上,通常采用 in-place 排序(即只需用到 O(1)的额外空间的排序),因而在从后向前扫描过程中,需要反复把已排序元素逐步向后挪位,为最新元素提供插入空间。

Released under the MIT License.

- +}

算法分析

插入排序在实现上,通常采用 in-place 排序(即只需用到 O(1)的额外空间的排序),因而在从后向前扫描过程中,需要反复把已排序元素逐步向后挪位,为最新元素提供插入空间。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/merge/index.html b/src/ranuts/sort/merge/index.html index 305f12cc4..0b351371a 100644 --- a/src/ranuts/sort/merge/index.html +++ b/src/ranuts/sort/merge/index.html @@ -4,9 +4,9 @@ 归并排序(Merge Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -81,9 +89,9 @@ const left = list.slice(0, middle) const right = list.slice(middle) return combine(merge(left), merge(right)) -}

算法分析

归并排序是一种稳定的排序方法。和选择排序一样,归并排序的性能不受输入数据的影响,但表现比选择排序好的多,因为始终都是 O(nlogn)的时间复杂度。代价是需要额外的内存空间。

Released under the MIT License.

- +}

算法分析

归并排序是一种稳定的排序方法。和选择排序一样,归并排序的性能不受输入数据的影响,但表现比选择排序好的多,因为始终都是 O(nlogn)的时间复杂度。代价是需要额外的内存空间。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/quick/index.html b/src/ranuts/sort/quick/index.html index 99b709404..42efaa5ab 100644 --- a/src/ranuts/sort/quick/index.html +++ b/src/ranuts/sort/quick/index.html @@ -4,9 +4,9 @@ 快速排序(Quick Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -96,9 +104,9 @@ const quick = (list: Array<number>): Array<number> => { const { length } = list return combine(list, 0, length - 1) -}

Released under the MIT License.

- +}

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/radix/index.html b/src/ranuts/sort/radix/index.html index f117da422..678150f12 100644 --- a/src/ranuts/sort/radix/index.html +++ b/src/ranuts/sort/radix/index.html @@ -4,9 +4,9 @@ 基数排序(Radix Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -84,9 +92,9 @@ list = list.concat(count(buckets[i])) } return list -}

算法分析

基数排序基于分配排序,所以是稳定的。但基数排序的性能比桶排序要略差,每一次关键字的桶分配都需要 O(n)的时间复杂度,而且分配之后得到新的关键字序列又需要 O(n)的时间复杂度。假如待排数据可以分为 d 个关键字,则基数排序的时间复杂度将是 O(d*2n) ,当然 d 要远远小于 n,因此基本上还是线性级别的。

基数排序的空间复杂度为 O(n+k),其中 k 为桶的数量。一般来说 n>>k,因此额外空间需要大概 n 个左右。

Released under the MIT License.

- +}

算法分析

基数排序基于分配排序,所以是稳定的。但基数排序的性能比桶排序要略差,每一次关键字的桶分配都需要 O(n)的时间复杂度,而且分配之后得到新的关键字序列又需要 O(n)的时间复杂度。假如待排数据可以分为 d 个关键字,则基数排序的时间复杂度将是 O(d*2n) ,当然 d 要远远小于 n,因此基本上还是线性级别的。

基数排序的空间复杂度为 O(n+k),其中 k 为桶的数量。一般来说 n>>k,因此额外空间需要大概 n 个左右。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/select/index.html b/src/ranuts/sort/select/index.html index b47b4844c..fcfc1239a 100644 --- a/src/ranuts/sort/select/index.html +++ b/src/ranuts/sort/select/index.html @@ -4,9 +4,9 @@ 选择排序(Selection Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -65,9 +73,9 @@ arr[minIndex] = temp } return arr -}

算法分析

表现最稳定的排序算法之一,因为无论什么数据进去都是 O(n2)的时间复杂度,所以用到它的时候,数据规模越小越好。唯一的好处可能就是不占用额外的内存空间了吧。理论上讲,选择排序可能也是平时排序一般人想到的最多的排序方法了吧。

Released under the MIT License.

- +}

算法分析

表现最稳定的排序算法之一,因为无论什么数据进去都是 O(n2)的时间复杂度,所以用到它的时候,数据规模越小越好。唯一的好处可能就是不占用额外的内存空间了吧。理论上讲,选择排序可能也是平时排序一般人想到的最多的排序方法了吧。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/sort/shell/index.html b/src/ranuts/sort/shell/index.html index ba3d3d6c3..a4d6f9fb0 100644 --- a/src/ranuts/sort/shell/index.html +++ b/src/ranuts/sort/shell/index.html @@ -4,9 +4,9 @@ 希尔排序(Shell Sort) | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -68,9 +76,9 @@ } } return list -}

算法分析

希尔排序的核心在于间隔序列的设定。既可以提前设定好间隔序列,也可以动态的定义间隔序列。动态定义间隔序列的算法是《算法(第 4 版)》的合著者 Robert Sedgewick 提出的。

Released under the MIT License.

- +}

算法分析

希尔排序的核心在于间隔序列的设定。既可以提前设定好间隔序列,也可以动态的定义间隔序列。动态定义间隔序列的算法是《算法(第 4 版)》的合著者 Robert Sedgewick 提出的。

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/utils/index.html b/src/ranuts/utils/index.html index b373ee81f..fb60d8c16 100644 --- a/src/ranuts/utils/index.html +++ b/src/ranuts/utils/index.html @@ -4,9 +4,9 @@ 通用函数 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

通用函数

filterObj

过滤对象的属性,去除对象中在 list 数组里面有的属性,返回一个新对象,一般是用于去除空字符和 null

API

Return

参数说明类型
run启动轮询(...params: TParams) => void
runAsync启动轮询(...params: TParams) => Promise<TData>
cancel停止轮询() => void

Options

参数说明类型默认值
pollingInterval轮询间隔,单位为毫秒。如果值大于 0,则启动轮询模式。number0
pollingWhenHidden在页面隐藏时,是否继续轮询。如果设置为 false,在页面隐藏时会暂时停止轮询,页面重新显示时继续上次轮询。booleantrue
pollingErrorRetryCount轮询错误重试次数。如果设置为 -1,则无限次number-1

Released under the MIT License.

- +
Skip to content
On this page

通用函数

filterObj

过滤对象的属性,去除对象中在 list 数组里面有的属性,返回一个新对象,一般是用于去除空字符和 null

API

Return

参数说明类型
run启动轮询(...params: TParams) => void
runAsync启动轮询(...params: TParams) => Promise<TData>
cancel停止轮询() => void

Options

参数说明类型默认值
pollingInterval轮询间隔,单位为毫秒。如果值大于 0,则启动轮询模式。number0
pollingWhenHidden在页面隐藏时,是否继续轮询。如果设置为 false,在页面隐藏时会暂时停止轮询,页面重新显示时继续上次轮询。booleantrue
pollingErrorRetryCount轮询错误重试次数。如果设置为 -1,则无限次number-1

Released under the MIT License.

+ \ No newline at end of file diff --git a/src/ranuts/utils/task.html b/src/ranuts/utils/task.html index 66cbb54a2..b75951f55 100644 --- a/src/ranuts/utils/task.html +++ b/src/ranuts/utils/task.html @@ -4,9 +4,9 @@ 统计执行时间 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -55,9 +63,9 @@ const time = taskEnd(taskId) -console.log('task 执行花费的时间', time)

二.new Date().getTime()

new Date().getTime() 返回一个数值,表示从 1970 年 1 月 1 日 0 时 0 分 0 秒(UTC,即协调世界时)距离该日期对象所代表时间的毫秒数。用来计算 JS 执行时间会有两个问题:

  1. 某些情况下,毫秒级精度可能不够。
  2. new Date() 解析的时间在不同浏览器,或者不同设备上可能并不一致。MDN 说明

    由于浏览器之间的差异与不一致性,强烈不推荐使用 Date 构造函数来解析日期字符串 (或使用与其等价的 Date.parse)。对 RFC 2822 格式的日期仅有约定俗成的支持。对 ISO 8601 格式的支持中,仅有日期的串 (例如 "1970-01-01") 会被处理为 UTC 而不是本地时间,与其他格式的串的处理不同。

三.console.time(), console.timeEnd()

启动一个计时器来跟踪某一个操作的占用时长。每一个计时器必须拥有唯一的名字,页面中最多能同时运行 10,000 个计时器。当以此计时器名字为参数调用 console.timeEnd() 时,浏览器将以毫秒为单位,输出对应计时器所经过的时间。比起new Date().getTime(),统计时间更加精确,可以统计到 0.001 毫秒(比如:0.134ms)

四.performance.now()

performance.now()返回的时间精度最高可达微秒级,且不会受到系统时间的影响(系统时钟可能会被手动调整或被 NTP 等软件篡改)。另外,performance.timing.navigationStart + performance.now() 约等于 Date.now()。因此对于统计 JS 执行耗时方面,更推荐使用performance.now()

注意:为了提供对定时攻击和指纹的保护,performance.now() 的精度可能会根据浏览器的设置而被舍弃。 在 Firefox 中,privacy.reduceTimerPrecision 偏好是默认启用的,默认值为 1ms。可以启用 privacy.resistFingerprinting 这将精度改为 100ms 或privacy.resistFingerprinting.reduceTimerPrecision.microseconds 的值,以较大者为准。

Released under the MIT License.

- +console.log('task 执行花费的时间', time)

二.new Date().getTime()

new Date().getTime() 返回一个数值,表示从 1970 年 1 月 1 日 0 时 0 分 0 秒(UTC,即协调世界时)距离该日期对象所代表时间的毫秒数。用来计算 JS 执行时间会有两个问题:

  1. 某些情况下,毫秒级精度可能不够。
  2. new Date() 解析的时间在不同浏览器,或者不同设备上可能并不一致。MDN 说明

    由于浏览器之间的差异与不一致性,强烈不推荐使用 Date 构造函数来解析日期字符串 (或使用与其等价的 Date.parse)。对 RFC 2822 格式的日期仅有约定俗成的支持。对 ISO 8601 格式的支持中,仅有日期的串 (例如 "1970-01-01") 会被处理为 UTC 而不是本地时间,与其他格式的串的处理不同。

三.console.time(), console.timeEnd()

启动一个计时器来跟踪某一个操作的占用时长。每一个计时器必须拥有唯一的名字,页面中最多能同时运行 10,000 个计时器。当以此计时器名字为参数调用 console.timeEnd() 时,浏览器将以毫秒为单位,输出对应计时器所经过的时间。比起new Date().getTime(),统计时间更加精确,可以统计到 0.001 毫秒(比如:0.134ms)

四.performance.now()

performance.now()返回的时间精度最高可达微秒级,且不会受到系统时间的影响(系统时钟可能会被手动调整或被 NTP 等软件篡改)。另外,performance.timing.navigationStart + performance.now() 约等于 Date.now()。因此对于统计 JS 执行耗时方面,更推荐使用performance.now()

注意:为了提供对定时攻击和指纹的保护,performance.now() 的精度可能会根据浏览器的设置而被舍弃。 在 Firefox 中,privacy.reduceTimerPrecision 偏好是默认启用的,默认值为 1ms。可以启用 privacy.resistFingerprinting 这将精度改为 100ms 或privacy.resistFingerprinting.reduceTimerPrecision.microseconds 的值,以较大者为准。

Released under the MIT License.

+ \ No newline at end of file diff --git "a/src/types/TS\347\261\273\345\236\213.html" "b/src/types/TS\347\261\273\345\236\213.html" index 3e5bf3cbc..600307fa4 100644 --- "a/src/types/TS\347\261\273\345\236\213.html" +++ "b/src/types/TS\347\261\273\345\236\213.html" @@ -4,9 +4,9 @@ TypeScript 类型系统中的类型 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -96,9 +104,9 @@ age?: number } -type tuple = [string, number?]

Last updated:

Released under the MIT License.

- +type tuple = [string, number?]

Last updated:

Released under the MIT License.

+ \ No newline at end of file diff --git "a/src/types/\346\250\241\345\274\217\345\214\271\351\205\215.html" "b/src/types/\346\250\241\345\274\217\345\214\271\351\205\215.html" index 014373058..4062cbc28 100644 --- "a/src/types/\346\250\241\345\274\217\345\214\271\351\205\215.html" +++ "b/src/types/\346\250\241\345\274\217\345\214\271\351\205\215.html" @@ -4,9 +4,9 @@ 模式匹配 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -90,9 +98,9 @@ interface PersonConstructor { new (name: string): Person }

这里的 PersonConstructor 返回的是 Person 类型的实例对象,这个也可以通过模式匹配取出来。

ts
type GetInstanceType<C extends new (...args: unknown[]) => unknown> =
-  C extends new (...args: unknown[]) => infer T ? T : unknown

Last updated:

Released under the MIT License.

- + C extends new (...args: unknown[]) => infer T ? T : unknown

Last updated:

Released under the MIT License.

+ \ No newline at end of file diff --git "a/src/types/\347\261\273\345\236\213\350\277\220\347\256\227.html" "b/src/types/\347\261\273\345\236\213\350\277\220\347\256\227.html" index c91967572..6fa7b8c7e 100644 --- "a/src/types/\347\261\273\345\236\213\350\277\220\347\256\227.html" +++ "b/src/types/\347\261\273\345\236\213\350\277\220\347\256\227.html" @@ -4,9 +4,9 @@ TypeScript 类型系统中的类型运算 | ran - + - + @@ -35,16 +35,24 @@ - - - + + + - + + + + + + + + + - - + + @@ -79,9 +87,9 @@ // type res = { // aaa:[1,1,1] // bbb:[2,2,2] -// }

这里的 & string 可能大家会迷惑,解释一下:

因为索引类型(对象、class 等)可以用 string、number 和 symbol 作为 key,这里 keyof T 取出的索引就是 string | number | symbol 的联合类型,和 string 取交叉部分就只剩下 string 了。就像前面所说,交叉类型会把同一类型做合并,不同类型舍弃。

因为 js 处理对象比较多,所以索引类型的映射比较重要。

Last updated:

Released under the MIT License.

- +// }

这里的 & string 可能大家会迷惑,解释一下:

因为索引类型(对象、class 等)可以用 string、number 和 symbol 作为 key,这里 keyof T 取出的索引就是 string | number | symbol 的联合类型,和 string 取交叉部分就只剩下 string 了。就像前面所说,交叉类型会把同一类型做合并,不同类型舍弃。

因为 js 处理对象比较多,所以索引类型的映射比较重要。

Last updated:

Released under the MIT License.

+ \ No newline at end of file diff --git "a/src/types/\351\253\230\347\272\247\347\261\273\345\236\213.html" "b/src/types/\351\253\230\347\272\247\347\261\273\345\236\213.html" index 8db63b398..1ed395920 100644 --- "a/src/types/\351\253\230\347\272\247\347\261\273\345\236\213.html" +++ "b/src/types/\351\253\230\347\272\247\347\261\273\345\236\213.html" @@ -4,9 +4,9 @@ TypeScript 内置的高级类型 | ran - + - + @@ -35,23 +35,31 @@ - - - + + + - + + + + + + + + + - - + + -
Skip to content
On this page

TypeScript 内置的高级类型

Parameters

Parameters 用于提取函数类型的参数类型。

ReturnType

ReturnType 用于提取函数类型的返回值类型。

ConstructorParameters

构造器类型和函数类型的区别就是可以被 new。

Parameters 用于提取函数参数的类型,而 ConstructorParameters 用于提取构造器参数的类型。

InstanceType

提取了构造器参数的类型,自然也可以提取构造器返回值的类型,就是 InstanceType。

ThisParameterType

OmitThisParameter

Partial

Required

Readonly

Pick

Record

Exclude

Extract

Omit

Awaited

NonNullable

Uppercase

Lowercase

Capitalize

Uncapitalize

总结

比如用模式匹配可以实现:Parameters、ReturnType、ConstructorParameters、InstanceType、ThisParameterType。

用模式匹配 + 重新构造可以实现:OmitThisParameter

用重新构造可以实现:Partial、Required、Readonly、Pick、Record

用模式匹配 + 递归可以实现: Awaited

用联合类型在分布式条件类型的特性可以实现: Exclude

此外还有 NonNullable 和四个编译器内部实现的类型:Uppercase、Lowercase、Capitalize、Uncapitalize。

Last updated:

Released under the MIT License.

- +
Skip to content
On this page

TypeScript 内置的高级类型

Parameters

Parameters 用于提取函数类型的参数类型。

ReturnType

ReturnType 用于提取函数类型的返回值类型。

ConstructorParameters

构造器类型和函数类型的区别就是可以被 new。

Parameters 用于提取函数参数的类型,而 ConstructorParameters 用于提取构造器参数的类型。

InstanceType

提取了构造器参数的类型,自然也可以提取构造器返回值的类型,就是 InstanceType。

ThisParameterType

OmitThisParameter

Partial

Required

Readonly

Pick

Record

Exclude

Extract

Omit

Awaited

NonNullable

Uppercase

Lowercase

Capitalize

Uncapitalize

总结

比如用模式匹配可以实现:Parameters、ReturnType、ConstructorParameters、InstanceType、ThisParameterType。

用模式匹配 + 重新构造可以实现:OmitThisParameter

用重新构造可以实现:Partial、Required、Readonly、Pick、Record

用模式匹配 + 递归可以实现: Awaited

用联合类型在分布式条件类型的特性可以实现: Exclude

此外还有 NonNullable 和四个编译器内部实现的类型:Uppercase、Lowercase、Capitalize、Uncapitalize。

Last updated:

Released under the MIT License.

+ \ No newline at end of file