-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimjoy-core.min.js
More file actions
245 lines (245 loc) · 927 KB
/
imjoy-core.min.js
File metadata and controls
245 lines (245 loc) · 927 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("imjoyCore",[],t):"object"==typeof exports?exports.imjoyCore=t():e.imjoyCore=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=216)}([function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"cacheUrlInServiceWorker",(function(){return cacheUrlInServiceWorker})),__webpack_require__.d(__webpack_exports__,"html2string",(function(){return html2string})),__webpack_require__.d(__webpack_exports__,"assert",(function(){return assert})),__webpack_require__.d(__webpack_exports__,"isTouchDevice",(function(){return isTouchDevice})),__webpack_require__.d(__webpack_exports__,"Whenable",(function(){return Whenable})),__webpack_require__.d(__webpack_exports__,"compareVersions",(function(){return compareVersions})),__webpack_require__.d(__webpack_exports__,"pathJoin",(function(){return pathJoin})),__webpack_require__.d(__webpack_exports__,"dirName",(function(){return dirName})),__webpack_require__.d(__webpack_exports__,"url_regex",(function(){return url_regex})),__webpack_require__.d(__webpack_exports__,"debounce",(function(){return debounce})),__webpack_require__.d(__webpack_exports__,"animalGenerator",(function(){return animalGenerator})),__webpack_require__.d(__webpack_exports__,"colourGenerator",(function(){return colourGenerator})),__webpack_require__.d(__webpack_exports__,"randId",(function(){return randId})),__webpack_require__.d(__webpack_exports__,"_clone",(function(){return _clone})),__webpack_require__.d(__webpack_exports__,"MessageEmitter",(function(){return MessageEmitter})),__webpack_require__.d(__webpack_exports__,"Filters",(function(){return Filters})),__webpack_require__.d(__webpack_exports__,"isUrl",(function(){return isUrl})),__webpack_require__.d(__webpack_exports__,"githubUrlToObject",(function(){return githubUrlToObject})),__webpack_require__.d(__webpack_exports__,"githubUrlRaw",(function(){return githubUrlRaw})),__webpack_require__.d(__webpack_exports__,"githubImJoyManifest",(function(){return githubImJoyManifest})),__webpack_require__.d(__webpack_exports__,"githubRepo",(function(){return githubRepo})),__webpack_require__.d(__webpack_exports__,"hot_lut",(function(){return hot_lut}));var axios__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(11),axios__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__),_pluginParser_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(28);function cacheUrlInServiceWorker(e){return new Promise((function(t,n){const r={command:"add",url:e};if(!navigator.serviceWorker||!navigator.serviceWorker.register)return void n("Service worker is not supported.");const i=new MessageChannel;i.port1.onmessage=function(e){e.data&&e.data.error?n(e.data.error):t(e.data&&e.data.result)},navigator.serviceWorker&&navigator.serviceWorker.controller?navigator.serviceWorker.controller.postMessage(r,[i.port2]):n("Service worker controller is not available")}))}function html2string(e){return e&&e.replace(/\n/gm,"").replace(/<br>/gm,"\n").replace(/<[^>]*>?/gm,"")}function assert(e,t){if(!e){if(t=t||"Assertion failed","undefined"!=typeof Error)throw new Error(t);throw t}}function isTouchDevice(){return"ontouchstart"in window||navigator.MaxTouchPoints>0||navigator.msMaxTouchPoints>0}__webpack_require__.d(__webpack_exports__,"parseComponent",(function(){return _pluginParser_js__WEBPACK_IMPORTED_MODULE_1__.a}));const Whenable=function(e){this._multi_emit=e,this._emitted=!1,this._handlers=[]};function compareVersions(v1,comparator,v2){if(comparator="="==comparator?"==":comparator,-1==["==","===","<","<=",">",">=","!=","!=="].indexOf(comparator))throw new Error("Invalid comparator. "+comparator);for(var v1parts=v1.split("."),v2parts=v2.split("."),maxLen=Math.max(v1parts.length,v2parts.length),part1,part2,cmp=0,i=0;i<maxLen&&!cmp;i++)part1=parseInt(v1parts[i],10)||0,part2=parseInt(v2parts[i],10)||0,part1<part2&&(cmp=1),part1>part2&&(cmp=-1);return eval("0"+comparator+cmp)}function pathJoin(){for(var e=[],t=0,n=arguments.length;t<n;t++)e=e.concat(arguments[t].split("/"));var r=[];for(t=0,n=e.length;t<n;t++){var i=e[t];i&&"."!==i&&(".."===i?r.pop():r.push(i))}return""===e[0]&&r.unshift(""),r.join("/")||(r.length?"/":".")}function dirName(e){return pathJoin(e,"..")}Whenable.prototype.emit=function(e){if(this._multi_emit){this._emitted=!0,this._e=e;for(let t of this._handlers)setTimeout(t.bind(null,e),0)}else if(!this._emitted){var t;for(this._emitted=!0,this._e=e;t=this._handlers.pop();)setTimeout(t.bind(null,e),0)}},Whenable.prototype.whenEmitted=function(e){e=this._checkHandler(e),this._emitted?setTimeout(e.bind(null,this._e),0):this._handlers.push(e)},Whenable.prototype._checkHandler=function(e){var t=typeof e;if("function"!==t)throw new Error("A function may only be subsribed to the event, "+t+" was provided instead");return e};const arrAnimals=["Aardvark","Albatross","Alligator","Alpaca","Ant","Anteater","Antelope","Ape","Armadillo","Ass_Donkey","Baboon","Badger","Barracuda","Bat","Bear","Beaver","Bee","Bison","Boa","Buffalo","Butterfly","Camel","Capybara","Caribou","Cassowary","Cat","Caterpillar","Cattle","Chamois","Cheetah","Chicken","Chimpanzee","Chinchilla","Chough","Clam","Cobra","Cockroach","Cod","Cormorant","Coyote","Crab","Crane","Crocodile","Crow","Curlew","Deer","Dinosaur","Dog","Dogfish","Dolphin","Donkey","Dotterel","Dove","Dragonfly","Duck","Dugong","Dunlin","Eagle","Echidna","Eel","Eland","Elephant","Elephantseal","Elk","Emu","Falcon","Ferret","Finch","Fish","Flamingo","Fox","Frog","Gaur","Gazelle","Gerbil","GiantPanda","Giraffe","Gnat","Gnu","Goat","Goose","Goldfinch","Goldfish","Gorilla","Goshawk","Grasshopper","Grouse","Guanaco","Guineafowl","Guineapig","Gull","Hamster","Hare","Hawk","Hedgehog","Heron","Herring","Hippopotamus","Hornet","Horse","Human","Hummingbird","Hyena","Ibex","Ibis","Jackal","Jaguar","Jay","Jellyfish","Kangaroo","Kingfisher","Koala","Komodo","Kookabura","Kouprey","Kudu","Lapwing","Lark","Lemur","Leopard","Lion","Llama","Lobster","Locust","Loris","Louse","Lyrebird","Magpie","Mallard","Manatee","Mandrill","Mantis","Marten","Meerkat","Mink","Mole","Mongoose","Monkey","Moose","Mouse","Mosquito","Mule","Narwhal","Newt","Nightingale","Octopus","Okapi","Opossum","Oryx","Ostrich","Otter","Owl","Ox","Oyster","Panther","Parrot","Partridge","Peafowl","Pelican","Penguin","Pheasant","Pig","Pigeon","PolarBear","Pony","Porcupine","Porpoise","PrairieDog","Quail","Quelea","Quetzal","Rabbit","Raccoon","Rail","Ram","Rat","Raven","Reddeer","Redpanda","Reindeer","Rhinoceros","Rook","Salamander","Salmon","SandDollar","Sandpiper","Sardine","Scorpion","Sealion","SeaUrchin","Seahorse","Seal","Shark","Sheep","Shrew","Skunk","Snail","Snake","Sparrow","Spider","Spoonbill","Squid","Squirrel","Starling","Stingray","Stinkbug","Stork","Swallow","Swan","Tapir","Tarsier","Termite","Tiger","Toad","Trout","Turkey","Turtle","Vicu�a","Viper","Vulture","Wallaby","Walrus","Wasp","Waterbuffalo","Weasel","Whale","Wolf","Wolverine","Wombat","Woodcock","Woodpecker","Worm","Wren","Yak","Zebra"],arrColours=["almond","amaranthine","amber","amethyst","antique","apple","apricot","aqua","aquamarine","argent","auburn","avocado","azure","babyblue","banana","battleshipgray","bay","beige","Bermudagreen","beryl","biceblue","bicegreen","bice","biscuit","bisque","black","blanchedalmond","blazeorange","blonde","bloodred","bluegreen","blueviolet","blue","blueberry","bone","bottlegreen","brass","brickred","bronzeyellow","bronze","brown","buckskin","buff","burgundy","burlywood","burntorange","burntsienna","burntumber","butterscotch","cadetblue","Cambridgeblue","canary","cardinal","carmine","carnation","carnelian","carroty","celadon","cerise","cerulean","chamois","champagne","charcoal","chartreuse","cherryred","chestnut","Chinesered","chocolate","cinereous","cinnabar","cinnamon","citrine","clairdelune","claret","coalblack","cobaltblue","cocoa","coffee","coolgray","Copenhagenblue","copper","coral","cornflowerblue","cornflower","cornsilk","cream","crimson","cupreous","cyan","daffodil","damask","dandelion","dovegray","duckeggblue","dun","Dodgerblue","eaudenil","ebony","ecru","eggshellblue","eggshell","electricblue","emeraldgreen","emerald","fawn","federalyellow","firebrick","fireenginered","flame","flamingo","flaxen","flesh","floralwhite","forestgreen","fuchsia","fuscous","gainsboro","gamboge","garnet","gentianblue","gentianviolet","geranium","ginger","glaucous","gold","goldenbrown","goldenrod","goldochre","grape","grassgreen","gray","green","grizzle","gules","gunmetalgray","hazel","heather","heliotrope","henna","hepatic","hoar","honey","honeydew","hotpink","huntergreen","iceblue","incarnadine","Indianred","indigo","internationalorange","irongray","ivory","jadegreen","jade","jet","jonquil","kellygreen","Kendalgreen","khaki","khakigreen","lapislazuli","laurelgreen","lavender","lemonchiffon","lemon","lilac","lime","Lincolngreen","linen","liver","loden","lovat","macaroniandcheese","madder","magenta","magicmint","magnolia","mahogany","malachite","maroon","mauve","mazarine","melon","midnightblue","mignonette","militarygrey","mint","mintcream","mistyrose","moccasin","mocha","mossgreen","mulberry","mustard","natural","navajowhite","navy","Nileblue","Nilegreen","oak","oatmeal","oceangrey","ochre","offwhite","oldgold","oldlace","olivedrab","olive","orange","orchid","outerspace","oxblood","Oxfordblue","oyster","pansy","paprika","Parisgreen","patina","peagreen","peach","peacockblue","pearlgray","pearly","periwinkle","perse","petrolblue","petunia","pewter","pillarboxred","pinegreen","pink","pistachiogreen","platinumblond","platinum","plum","Pompeianred","poppy","powderblue","primrose","Prussianblue","puce","puke","purple","purpure","quartz","quince","raspberry","rawsienna","redviolet","red","reseda","riflegreen","robin_seggblue","rose","rouge","royalblue","royalpurple","ruby","russet","rust","sable","saddlebrown","safetyorange","saffron","sagegreen","salmon","sand","sandy","sanguine","sapphire","sard","saxeblue","scarlet","schoolbusyellow","seagreen","seashell","sepia","shockingpink","sienna","silver","silvergray","skyblue","slate","slateblack","slateblue","slategray","smoke","snow","sorrel","springgreen","stammel","steelblue","stone","straw","strawberry","sulfur","sunflower","tan","tangerine","taupe","taxiyellow","teak","teal","terracotta","timberwolf","titian","topaz","towcolored","Turkeyred","turquoise","Tyrianpurple","ultramarine","umber","Vandykebrown","venetianred","verdant","vermilion","vert","violetred","violet","virid","viridian","vividorange","walnut","Wedgewoodblue","wheat","wheaten","white","wine","xanthic","yellow","zaffre"],expression=/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9][^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi,url_regex=new RegExp(expression);function debounce(e,t,n){var r;return function(){var i=this,o=arguments,s=function(){r=null,n||e.apply(i,o)},a=n&&!r;clearTimeout(r),r=setTimeout(s,t),a&&e.apply(i,o)}}function animalGenerator(){return arrAnimals[Math.floor(Math.random()*arrAnimals.length)].toLowerCase()}function colourGenerator(){return arrColours[Math.floor(Math.random()*arrColours.length)].toLowerCase()}function randId(){return Math.random().toString(36).substr(2,5)+Date.now()}function _clone(e){if(!e)return e;var t,n,r;for(r in t=Array.isArray(e)?[]:{},e)n=e[r],t[r]="object"==typeof n?_clone(n):n;return t}class MessageEmitter{constructor(e){this._event_handlers={},this._once_handlers={},this._debug=e}emit(){throw new Error("emit is not implemented")}on(e,t){this._event_handlers[e]||(this._event_handlers[e]=[]),this._event_handlers[e].push(t)}once(e,t){t.___event_run_once=!0,this.on(e,t)}off(e,t){if(e||t){if(e&&!t)this._event_handlers[e]&&(this._event_handlers[e]=[]);else if(this._event_handlers[e]){const n=this._event_handlers[e].indexOf(t);n>=0&&this._event_handlers[e].splice(n,1)}}else this._event_handlers={}}_fire(e,t){if(this._event_handlers[e])for(var n=this._event_handlers[e].length;n--;){const r=this._event_handlers[e][n];try{r(t)}catch(e){console.error(e)}finally{r.___event_run_once&&this._event_handlers[e].splice(n,1)}}else this._debug&&console.warn("unhandled event",e,t)}}const Filters={getPixels:function(e){var t=e;return t.getContext("2d").getImageData(0,0,t.width,t.height)},filterImage:function(e,t){for(var n=[e],r=2;r<arguments.length;r++)n.push(arguments[r]);return t.apply(null,n)},grayscale:function(e){for(var t=e.data,n=0;n<t.length;n+=4){var r=.2126*t[n]+.7152*t[n+1]+.0722*t[n+2];t[n]=t[n+1]=t[n+2]=r}return e},brightness:function(e,t,n){for(var r,i=e.data,o=0;o<i.length;o+=4)(r=parseInt((i[o]-t)*n))>255?r=255:r<0&&(r=0),i[o]=r,i[o+1]=r,i[o+2]=r,i[o+3]=255;return e},min_max:function(e){for(var t=e.data,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=0,o=0;o<t.length;o+=4)t[o]<n&&(n=t[o]),t[o]>r&&(r=t[o]),i+=t[o]/(t.length/4);return{min:n,max:r,avg:i}},lut:function(e,t){for(var n,r=e.data,i=0;i<r.length;i+=4)n=r[i],r[i]=t[n][0],r[i+1]=t[n][1],r[i+2]=t[n][2],r[i+3]=255;return e}},protocolAndDomainRE=/^(?:\w+:)?\/\/([\s\S]+)$/,localhostDomainRE=/^localhost[\:?\d]*(?:[^\:?\d][\s\S]*)?$/,nonLocalhostDomainRE=/^[^\s\.]+\.[\s\S]{2,}$/;function isUrl(e){if("string"!=typeof e)return!1;var t=e.match(protocolAndDomainRE);if(!t)return!1;var n=t[1];return!!n&&!(!localhostDomainRE.test(n)&&!nonLocalhostDomainRE.test(n))}const laxUrlRegex=/(?:(?:[^:]+:)?[/][/])?(?:.+@)?([^/]+)([/][^?#]+)/;function githubUrlToObject(e,t){var n={};if(t=t||{},!e)return null;if(e.url&&(e=e.url),"string"!=typeof e)return null;var r=e.match(/^([\w-_]+)\/([\w-_\.]+)(?:#([\w-_\.]+))?$/),i=e.match(/^github:([\w-_]+)\/([\w-_\.]+)(?:#([\w-_\.]+))?$/),o=e.match(/^git@[\w-_\.]+:([\w-_]+)\/([\w-_\.]+)$/);if(r)n.user=r[1],n.repo=r[2],n.branch=r[3]||"master",n.host="github.com";else if(i)n.user=i[1],n.repo=i[2],n.branch=i[3]||"master",n.host="github.com";else if(o)n.user=o[1],n.repo=o[2].replace(/\.git$/i,""),n.branch="master",n.host="github.com";else{if(!isUrl(e=e.replace(/^git\+/,"")))return null;const[,r,i]=e.match(laxUrlRegex)||[];if(!r)return null;if("github.com"!==r&&"www.github.com"!==r&&!t.enterprise)return null;var s=i.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\s\w-_\.\/]+)?/);if(!s)return null;n.user=s[1],n.repo=s[2].replace(/\.git$/i,""),n.host=r||"github.com",s[3]&&/^\/tree\/master\//.test(s[3])?(n.branch="master",n.path=s[3].replace(/\/$/,"")):s[3]?n.branch=s[3].replace(/^\/tree\//,"").match(/[\w-_.]+\/{0,1}[\w-_]+/)[0]:s[4]?n.branch=s[4].replace(/^\/blob\//,"").match(/[\w-_.]+\/{0,1}[\w-_]+/)[0]:n.branch="master"}return"github.com"===n.host?n.apiHost="api.github.com":n.apiHost=n.host+"/api/v3",n.tarball_url=`https://${n.apiHost}/repos/${n.user}/${n.repo}/tarball/${n.branch}`,n.clone_url=`https://${n.host}/${n.user}/${n.repo}`,"master"===n.branch?(n.https_url=`https://${n.host}/${n.user}/${n.repo}`,n.travis_url=`https://travis-ci.org/${n.user}/${n.repo}`,n.zip_url=`https://${n.host}/${n.user}/${n.repo}/archive/master.zip`):(n.https_url=`https://${n.host}/${n.user}/${n.repo}/blob/${n.branch}`,n.travis_url=`https://travis-ci.org/${n.user}/${n.repo}?branch=${n.branch}`,n.zip_url=`https://${n.host}/${n.user}/${n.repo}/archive/${n.branch}.zip`),n.path&&(n.https_url+=n.path),n.api_url=`https://${n.apiHost}/repos/${n.user}/${n.repo}`,n}async function githubUrlRaw(e){if(e.includes("gist.github.com")){const t=e.split("/").slice(-1)[0],n=await axios__WEBPACK_IMPORTED_MODULE_0___default.a.get("https://api.github.com/gists/"+t);if(200===n.status){return Object.values(n.data.files).filter(e=>e.filename.endsWith(".imjoy.html"))[0].raw_url}throw"Failed to fetch from Gist: "+n.statusText}if(!e.includes("blob")||!e.includes("github"))return null;var t=githubUrlToObject(e),n=t.user,r=t.repo,i=new RegExp("^https://github.com/"+n+"/"+r+"/blob/","g");return"https://raw.githubusercontent.com/"+n+"/"+r+"/"+e.replace(i,"")}function githubImJoyManifest(e){var t=githubUrlToObject(e);return"https://raw.githubusercontent.com/"+t.user+"/"+t.repo+"/"+t.branch+"/manifest.imjoy.json"}function githubRepo(e){var t=githubUrlToObject(e);return t.user+"/"+t.repo}const hot_lut=[[10,0,0],[13,0,0],[15,0,0],[18,0,0],[21,0,0],[23,0,0],[26,0,0],[28,0,0],[31,0,0],[34,0,0],[36,0,0],[39,0,0],[42,0,0],[44,0,0],[47,0,0],[49,0,0],[52,0,0],[55,0,0],[57,0,0],[60,0,0],[63,0,0],[65,0,0],[68,0,0],[70,0,0],[73,0,0],[76,0,0],[78,0,0],[81,0,0],[84,0,0],[86,0,0],[89,0,0],[91,0,0],[94,0,0],[97,0,0],[99,0,0],[102,0,0],[105,0,0],[107,0,0],[110,0,0],[112,0,0],[115,0,0],[118,0,0],[120,0,0],[123,0,0],[126,0,0],[128,0,0],[131,0,0],[133,0,0],[136,0,0],[139,0,0],[141,0,0],[144,0,0],[147,0,0],[149,0,0],[152,0,0],[154,0,0],[157,0,0],[160,0,0],[162,0,0],[165,0,0],[168,0,0],[170,0,0],[173,0,0],[175,0,0],[178,0,0],[181,0,0],[183,0,0],[186,0,0],[189,0,0],[191,0,0],[194,0,0],[196,0,0],[199,0,0],[202,0,0],[204,0,0],[207,0,0],[210,0,0],[212,0,0],[215,0,0],[217,0,0],[220,0,0],[223,0,0],[225,0,0],[228,0,0],[231,0,0],[233,0,0],[236,0,0],[238,0,0],[241,0,0],[244,0,0],[246,0,0],[249,0,0],[252,0,0],[254,0,0],[255,2,0],[255,5,0],[255,7,0],[255,10,0],[255,12,0],[255,15,0],[255,18,0],[255,20,0],[255,23,0],[255,26,0],[255,28,0],[255,31,0],[255,33,0],[255,36,0],[255,39,0],[255,41,0],[255,44,0],[255,47,0],[255,49,0],[255,52,0],[255,54,0],[255,57,0],[255,60,0],[255,62,0],[255,65,0],[255,68,0],[255,70,0],[255,73,0],[255,75,0],[255,78,0],[255,81,0],[255,83,0],[255,86,0],[255,89,0],[255,91,0],[255,94,0],[255,96,0],[255,99,0],[255,102,0],[255,104,0],[255,107,0],[255,110,0],[255,112,0],[255,115,0],[255,117,0],[255,120,0],[255,123,0],[255,125,0],[255,128,0],[255,131,0],[255,133,0],[255,136,0],[255,138,0],[255,141,0],[255,144,0],[255,146,0],[255,149,0],[255,151,0],[255,154,0],[255,157,0],[255,159,0],[255,162,0],[255,165,0],[255,167,0],[255,170,0],[255,172,0],[255,175,0],[255,178,0],[255,180,0],[255,183,0],[255,186,0],[255,188,0],[255,191,0],[255,193,0],[255,196,0],[255,199,0],[255,201,0],[255,204,0],[255,207,0],[255,209,0],[255,212,0],[255,214,0],[255,217,0],[255,220,0],[255,222,0],[255,225,0],[255,228,0],[255,230,0],[255,233,0],[255,235,0],[255,238,0],[255,241,0],[255,243,0],[255,246,0],[255,249,0],[255,251,0],[255,254,0],[255,255,2],[255,255,6],[255,255,10],[255,255,14],[255,255,18],[255,255,22],[255,255,26],[255,255,30],[255,255,34],[255,255,38],[255,255,42],[255,255,46],[255,255,50],[255,255,54],[255,255,58],[255,255,62],[255,255,65],[255,255,69],[255,255,73],[255,255,77],[255,255,81],[255,255,85],[255,255,89],[255,255,93],[255,255,97],[255,255,101],[255,255,105],[255,255,109],[255,255,113],[255,255,117],[255,255,121],[255,255,125],[255,255,128],[255,255,132],[255,255,136],[255,255,140],[255,255,144],[255,255,148],[255,255,152],[255,255,156],[255,255,160],[255,255,164],[255,255,168],[255,255,172],[255,255,176],[255,255,180],[255,255,184],[255,255,188],[255,255,191],[255,255,195],[255,255,199],[255,255,203],[255,255,207],[255,255,211],[255,255,215],[255,255,219],[255,255,223],[255,255,227],[255,255,231],[255,255,235],[255,255,239],[255,255,243],[255,255,247],[255,255,251],[255,255,255]]},function(e,t,n){"use strict";var r=n(17),i=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],o=["scalar","sequence","mapping"];e.exports=function(e,t){var n,s;if(t=t||{},Object.keys(t).forEach((function(t){if(-1===i.indexOf(t))throw new r('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=(n=t.styleAliases||null,s={},null!==n&&Object.keys(n).forEach((function(e){n[e].forEach((function(t){s[String(t)]=e}))})),s),-1===o.indexOf(this.kind))throw new r('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}},function(e,t,n){"use strict";n.d(t,"a",(function(){return h})),n.d(t,"b",(function(){return p}));var r=n(20),i=n.n(r),o=n(21),s=n.n(o),a=n(22),c=n.n(a),u=n(23),l=n.n(u);function h(e){return new Promise((t,n)=>{const r=document.createElement("script");r.src=e,r.addEventListener("load",t),r.addEventListener("error",()=>{document.head.removeChild(r),n("Error loading script: "+e)}),r.addEventListener("abort",()=>n("Script loading aborted.")),document.head.appendChild(r)})}function d(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))}async function p(e){let t;await h("https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"),await h("https://imjoy-team.github.io/vue-js-modal/index.js"),function(e){const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("type","text/css"),t.setAttribute("href",e),document.getElementsByTagName("head")[0].appendChild(t)}("https://imjoy-team.github.io/vue-js-modal/styles.css"),await h("https://cdn.jsdelivr.net/npm/@oeway/vue-window@2.4.1-a/lib/index.js");const n={showDialog:(e,t,n)=>((n=n||{}).dialog=!0,r.pm.createWindow(e,t,n)),createWindow:(t,n,i)=>(i=i||{},e.window_manager_container||(i.dialog=!0),r.pm.createWindow(t,n,i)),showSnackbar(e,n,r){t.showSnackbar(n,r)},showMessage(e,n){t.showSnackbar(n,5)},showStatus(e,n){t.showSnackbar(n,5)},showProgress(e,n){(n=n||0)<1&&(n*=100),t.progress=n,t.$forceUpdate()}};if((e=e||{}).imjoy_api)for(let t of Object.keys(e.imjoy_api))n[t]=e.imjoy_api[t];const r=new((await loadImJoyCore(e)).ImJoy)({imjoy_api:n,expose_api:e.expose_api,client_id:e.client_id,default_base_frame:e.default_base_frame,default_rpc_base_url:e.default_rpc_base_url,debug:e.debug,flags:e.flags||[],engine_selector:e.engine_selector});let o,a,u;if(await r.start(e),console.log("ImJoy Core started successfully!"),Vue.use(window["vue-js-modal"].default),Vue.use(window.VueWindow),e.main_container?o="string"==typeof e.main_container?document.getElementById(e.main_container):e.main_container:(o=document.createElement("div"),document.body.appendChild(o)),o.style.visibility="hidden",o.innerHTML=s.a,document.head.insertAdjacentHTML("beforeend",`<style>${i.a}</style>`),e.window_manager_container){let n;n="string"==typeof e.window_manager_container?document.getElementById(e.window_manager_container):e.window_manager_container,n.innerHTML=l.a,a=new Vue({el:n,data:{type:e.window_manager_type||"standard",windowSizePosChanging:!1,windowStyle:e.window_style||{},showEmpty:e.show_empty_window||!1,showWindowTitle:e.show_window_title||!1,windows:[],activeWindow:null},watch:{windowSizePosChanging:function(e){t.$emit("window-size-pos-changing",e)}},methods:{closeWindow(e){this.windowSizePosChanging=!1,e.hidden=!0,this.$forceUpdate(),e.close()}}})}if(e.menu_container){let t;t="string"==typeof e.menu_container?document.getElementById(e.menu_container):e.menu_container,t.innerHTML=c.a,t.style.minHeight="30px",u=new Vue({el:t,data:{menuPos:e.menu_pos||"right",menuStyle:e.menu_style||{"z-index":999},activeWindow:null,closeWindow:null,showAboutImJoy:null,extraMenuItems:[],loadedPlugins:[],allWindows:[],showContent:!0},mounted(){this.menuStyle=this.menuStyle||{},this.menuStyle.float="left"===this.menuPos?"left":"right"},methods:{menuClicked(){this.showContent=!1,this.$forceUpdate(),setTimeout(()=>{this.showContent=!0,this.$forceUpdate()},0)}}})}return t=new Vue({el:o,data:{dialogWindows:[],selectedDialogWindow:null,selectedWindowsStack:[],selectedRegularWindow:null,fullscreen:!1,loading:!1,snackBarContent:!1,snackBarTimer:null,progress:0,loadedPlugins:[],allWindows:[],extraMenuItems:[],showProgressBar:e.show_progress_bar,showLoaderCallback:e.show_loader,showWindows:e.show_windows},mounted(){this.$el.style.visibility="visible",r.event_bus.on("close_window",e=>{this.closeWindow(e),this.$forceUpdate()}),r.event_bus.on("add_window",e=>{this.allWindows.push(e),this.addWindow(e)}),this.imjoy=r,e.process_url_query&&this.processURLQuery(),u&&(u.closeWindow=e=>{this.closeWindow(e)},e.hide_about_imjoy||(u.showAboutImJoy=()=>{r.api.showDialog({src:"https://imjoy.io/docs/",passive:!0})}))},computed:{regularWindows:function(){return this.allWindows.filter(e=>!this.dialogWindows.includes(e)&&!e.inline)}},watch:{regularWindows:function(e){a&&(a.windows=e,a.$forceUpdate())},selectedRegularWindow:function(t){a&&(a.activeWindow=t,a.$forceUpdate()),u&&"simple"===e.window_manager_type&&(u.activeWindow=t,u.$forceUpdate())},extraMenuItems:function(e){u&&(u.extraMenuItems=e,u.$forceUpdate())},allWindows:function(e){u&&(u.allWindows=e,u.$forceUpdate())},loadedPlugins:function(e){u&&(u.loadedPlugins=e,u.$forceUpdate())}},methods:{async processURLQuery(){const e=d("engine"),t=d("plugin")||d("p"),n=d("binder");if(e){const t=d("token"),n=d("name");await this.setupPluginEngine(e,t,n)}if(n){const e=d("name"),t=d("spec");await this.setupBinderEngine(n,t,e)}t&&this.loadPlugin(t).then(e=>{let t,n={},r={};t=d("data"),t&&(r=JSON.parse(t)),t=d("config"),t&&(n=JSON.parse(t)),this.runPlugin(e,n,r)})},runPlugin:async(e,t,n)=>(!t&&e.config.ui&&e.config.ui.indexOf("{")>-1&&(t=await r.pm.imjoy_api.showDialog(e,e.config)),n=n||{},await e.api.run({config:t,data:n})),async setupPluginEngine(e,t,n){try{console.log("Loading Jupyter-Engine-Manager from Gist..."),r.em.getFactory("Jupyter-Engine")||(await r.pm.reloadPluginRecursively({uri:"https://imjoy-team.github.io/jupyter-engine-manager/Jupyter-Engine-Manager.imjoy.html"}),console.log("Jupyter-Engine-Manager loaded."),await r.em.unregister("https://mybinder.org"));const i=r.em.getFactory("Jupyter-Engine");await i.addEngine({name:n,url:e,nbUrl:e+"?token="+t}),console.log("plugin engine added:",e)}catch(e){console.error(e),alert("Failed to connect to the engine: "+e)}},async setupBinderEngine(e,t,n){try{console.log("Loading Jupyter-Engine-Manager from Gist..."),r.em.getFactory("MyBinder-Engine")||(await r.pm.reloadPluginRecursively({uri:"https://imjoy-team.github.io/jupyter-engine-manager/Jupyter-Engine-Manager.imjoy.html"}),console.log("Jupyter-Engine-Manager loaded."),await r.em.unregister("https://mybinder.org"));const i=r.em.getFactory("MyBinder-Engine");await i.addEngine({name:n,spec:t,url:e}),console.log("Binder engine added:",e)}catch(e){console.error(e),alert("Failed to connect to the engine: "+e)}},async loadPlugin(e){try{this.loading=!0;const t=await r.pm.reloadPluginRecursively({uri:e});return this.loadedPlugins.push(t),this.showSnackbar(`Plugin ${t.name} successfully loaded.`),t}finally{this.loading=!1}},addMenuItem(e){this.extraMenuItems.push(e),this.$forceUpdate()},removeMenuItem(e){const t=this.extraMenuItems.filter(t=>t.label===e)[0],n=this.extraMenuItems.indexOf(t);n>=0&&this.extraMenuItems.splice(n,1)},showSnackbar(e,t){this.snackBarTimer&&clearTimeout(this.snackBarTimer),t=t||3,this.snackBarContent=e,this.$forceUpdate(),this.snackBarTimer=setTimeout(()=>{this.snackBarContent=null,this.snackBarTimer=null,this.$forceUpdate()},1e3*t)},showLoader(e){this.showLoaderCallback?this.showLoaderCallback(e):this.loading=e,this.$forceUpdate()},addWindow(e){e.api=e.api||{};const t=document.getElementById(e.window_id);if(t)return e.window_style&&Object.assign(t.style,e.window_style),e.inline=!0,void(e.api.show=e.show=()=>{t.scrollIntoView()});if(e.dialog)this.dialogWindows.push(e),this.selectedDialogWindow&&this.selectedWindowsStack.push(this.selectedDialogWindow),this.selectedDialogWindow=e,e.fullscreen||e.standalone?this.fullscreen=!0:this.fullscreen=!1,this.$modal.show("window-modal-dialog"),this.$forceUpdate(),e.api.show=e.show=()=>{this.selectedDialogWindow=e,this.$modal.show("window-modal-dialog"),r.wm.selectWindow(e),e.api.emit("show")},e.api.hide=e.hide=()=>{this.selectedDialogWindow===e&&this.$modal.hide("window-modal-dialog"),e.api.emit("hide")},setTimeout(()=>{try{e.show()}catch(e){console.error(e)}},500);else{this.selectedRegularWindow=e,setTimeout(()=>{e.fullscreen||e.standalone?e.sizeState="maximized":e.sizeState="normal",this.$forceUpdate()},0);const t=this;e.api.show=e.show=()=>{e.sizeState="restore",t.selectedRegularWindow=e,t.$forceUpdate(),r.wm.selectWindow(e),e.api.emit("show")}}},showWindow(e){e.fullscreen||e.standalone?this.fullscreen=!0:this.fullscreen=!1,e&&(this.selectedDialogWindow=e),this.$modal.show("window-modal-dialog")},closeWindow(e){let t=this.dialogWindows.indexOf(e);t>=0&&this.dialogWindows.splice(t,1),t=this.allWindows.indexOf(e),t>=0&&this.allWindows.splice(t,1),e===this.selectedDialogWindow&&(this.selectedDialogWindow=this.selectedWindowsStack.pop()),this.selectedDialogWindow||this.$modal.hide("window-modal-dialog"),e===this.selectedRegularWindow&&(this.regularWindows.length>0?this.selectedRegularWindow=this.regularWindows[this.regularWindows.length-1]||null:this.selectedRegularWindow=null),this.$forceUpdate()},minimizeWindow(){this.$modal.hide("window-modal-dialog")},maximizeWindow(){this.fullscreen=!this.fullscreen}}}),t}},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function h(e,t,n,r){var i,o,s,a;if(u(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=l(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=d.bind(r);return i.listener=n,r.wrapFn=i,i}function f(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):g(i,i.length)}function m(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function g(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return l(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,l=g(c,u);for(n=0;n<u;++n)o(l[n],this,t)}return!0},a.prototype.addListener=function(e,t){return h(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return h(this,e,t,!0)},a.prototype.once=function(e,t){return u(t),this.on(e,p(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,p(this,e,t)),this},a.prototype.removeListener=function(e,t){var n,r,i,o,s;if(u(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},a.prototype.listeners=function(e){return f(this,e,!0)},a.prototype.rawListeners=function(e){return f(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";var r=n(58),i=Object.prototype.toString;function o(e){return"[object Array]"===i.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===i.call(e)}function l(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),o(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:o,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:c,isUndefined:s,isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:u,isStream:function(e){return a(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:l,merge:function e(){var t={};function n(n,r){c(t[r])&&c(n)?t[r]=e(t[r],n):c(n)?t[r]=e({},n):o(n)?t[r]=n.slice():t[r]=n}for(var r=0,i=arguments.length;r<i;r++)l(arguments[r],n);return t},extend:function(e,t,n){return l(t,(function(t,i){e[i]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},function(e,t,n){"use strict";var r,i,o,s=[n(131),n(132),n(133),n(134),n(135),n(136)],a=-1,c=[],u=!1;function l(){r&&i&&(r=!1,i.length?c=i.concat(c):a=-1,c.length&&h())}function h(){if(!r){u=!1,r=!0;for(var e=c.length,t=setTimeout(l);e;){for(i=c,c=[];i&&++a<e;)i[a].run();a=-1,e=c.length}i=null,a=-1,r=!1,clearTimeout(t)}}for(var d=-1,p=s.length;++d<p;)if(s[d]&&s[d].test&&s[d].test()){o=s[d].install(h);break}function f(e,t){this.fun=e,this.array=t}f.prototype.run=function(){var e=this.fun,t=this.array;switch(t.length){case 0:return e();case 1:return e(t[0]);case 2:return e(t[0],t[1]);case 3:return e(t[0],t[1],t[2]);default:return e.apply(null,t)}},e.exports=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),u||r||(u=!0,o())}},function(e,t,n){"use strict";(function(e){var r,i,o=n(6),s=n.n(o),a=n(82),c=n(31),u=n.n(c),l=n(42),h=n.n(l),d=n(12),p=n.n(d),f=n(5),m=n.n(f),g=n(3),_=n.n(g);function y(e){return"$"+e}function v(e){return e.substring(1)}function b(){this._store={}}function w(e){if(this._store=new b,e&&Array.isArray(e))for(var t=0,n=e.length;t<n;t++)this.add(e[t])}function x(e){if(e instanceof ArrayBuffer)return function(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}b.prototype.get=function(e){var t=y(e);return this._store[t]},b.prototype.set=function(e,t){var n=y(e);return this._store[n]=t,!0},b.prototype.has=function(e){return y(e)in this._store},b.prototype.delete=function(e){var t=y(e),n=t in this._store;return delete this._store[t],n},b.prototype.forEach=function(e){for(var t=Object.keys(this._store),n=0,r=t.length;n<r;n++){var i=t[n];e(this._store[i],i=v(i))}},Object.defineProperty(b.prototype,"size",{get:function(){return Object.keys(this._store).length}}),w.prototype.add=function(e){return this._store.set(e,!0)},w.prototype.has=function(e){return this._store.has(e)},w.prototype.forEach=function(e){this._store.forEach((function(t,n){e(n)}))},Object.defineProperty(w.prototype,"size",{get:function(){return this._store.size}}),!function(){if("undefined"==typeof Symbol||"undefined"==typeof Map||"undefined"==typeof Set)return!1;var e=Object.getOwnPropertyDescriptor(Map,Symbol.species);return e&&"get"in e&&Map[Symbol.species]===Map}()?(r=w,i=b):(r=Set,i=Map);var k=Function.prototype.toString,E=k.call(Object);function j(e){var t,n,r;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,r=e.length;n<r;n++)t[n]=j(e[n]);return t}if(e instanceof Date)return e.toISOString();if(function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}(e))return x(e);if(!function(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&k.call(n)==E}(e))return e;for(n in t={},e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=j(e[n]);void 0!==i&&(t[n]=i)}return t}function A(e){var t=!1;return p()((function(n){if(t)throw new Error("once called more than once");t=!0,e.apply(this,n)}))}function D(e){return p()((function(t){t=j(t);var n=this,r="function"==typeof t[t.length-1]&&t.pop(),i=new Promise((function(r,i){var o;try{var s=A((function(e,t){e?i(e):r(t)}));t.push(s),(o=e.apply(n,t))&&"function"==typeof o.then&&r(o)}catch(e){i(e)}}));return r&&i.then((function(e){r(null,e)}),r),i}))}function S(e,t){return D(p()((function(n){if(this._closed)return Promise.reject(new Error("database is closed"));if(this._destroyed)return Promise.reject(new Error("database is destroyed"));var r=this;return function(e,t,n){if(e.constructor.listeners("debug").length){for(var r=["api",e.name,t],i=0;i<n.length-1;i++)r.push(n[i]);e.constructor.emit("debug",r);var o=n[n.length-1];n[n.length-1]=function(n,r){var i=["api",e.name,t];i=i.concat(n?["error",n]:["success",r]),e.constructor.emit("debug",i),o(n,r)}}}(r,e,n),this.taskqueue.isReady?t.apply(this,n):new Promise((function(t,i){r.taskqueue.addTask((function(o){o?i(o):t(r[e].apply(r,n))}))}))})))}function C(e,t){for(var n={},r=0,i=t.length;r<i;r++){var o=t[r];o in e&&(n[o]=e[o])}return n}var O;function P(e){return e}function F(e){return[{ok:e}]}function I(e,t,n){var r=t.docs,o=new i;r.forEach((function(e){o.has(e.id)?o.get(e.id).push(e):o.set(e.id,[e])}));var s=o.size,a=0,c=new Array(s);function u(){var e;++a===s&&(e=[],c.forEach((function(t){t.docs.forEach((function(n){e.push({id:t.id,docs:[n]})}))})),n(null,{results:e}))}var l=[];o.forEach((function(e,t){l.push(t)}));var h=0;function d(){if(!(h>=l.length)){var n=Math.min(h+6,l.length),r=l.slice(h,n);!function(n,r){n.forEach((function(n,i){var s=r+i,a=o.get(n),l=C(a[0],["atts_since","attachments"]);l.open_revs=a.map((function(e){return e.rev})),l.open_revs=l.open_revs.filter(P);var h=P;0===l.open_revs.length&&(delete l.open_revs,h=F),["revs","attachments","binary","ajax","latest"].forEach((function(e){e in t&&(l[e]=t[e])})),e.get(n,l,(function(e,t){var r,i,o;r=e?[{error:e}]:h(t),i=n,o=r,c[s]={id:i,docs:o},u(),d()}))}))}(r,h),h+=r.length}}d()}try{localStorage.setItem("_pouch_check_localstorage",1),O=!!localStorage.getItem("_pouch_check_localstorage")}catch(e){O=!1}function T(){return O}function R(){_.a.call(this),this._listeners={},function(e){T()&&addEventListener("storage",(function(t){e.emit(t.key)}))}(this)}function B(e){if("undefined"!=typeof console&&"function"==typeof console[e]){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}function M(e){var t=0;return e||(t=2e3),function(e,t){return e=parseInt(e,10)||0,(t=parseInt(t,10))!=t||t<=e?t=(e||1)<<1:t+=1,t>6e5&&(e=3e5,t=6e5),~~((t-e)*Math.random()+e)}(e,t)}function q(e,t){B("info","The above "+e+" is totally normal. "+t)}m()(R,_.a),R.prototype.addListener=function(e,t,n,r){if(!this._listeners[t]){var i=this,o=!1;this._listeners[t]=a,this.on(e,a)}function a(){if(i._listeners[t])if(o)o="waiting";else{o=!0;var e=C(r,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary","return_docs"]);n.changes(e).on("change",(function(e){e.seq>r.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))})).on("complete",(function(){"waiting"===o&&s()(a),o=!1})).on("error",(function(){o=!1}))}}},R.prototype.removeListener=function(e,t){t in this._listeners&&(_.a.prototype.removeListener.call(this,e,this._listeners[t]),delete this._listeners[t])},R.prototype.notifyLocalWindows=function(e){T()&&(localStorage[e]="a"===localStorage[e]?"b":"a")},R.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)};var L="function"==typeof Object.assign?Object.assign:function(e){for(var t=Object(e),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};function N(e,t,n){Error.call(this,n),this.status=e,this.name=t,this.message=n,this.error=!0}m()(N,Error),N.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};new N(401,"unauthorized","Name or password is incorrect.");var U=new N(400,"bad_request","Missing JSON list of 'docs'"),W=new N(404,"not_found","missing"),$=new N(409,"conflict","Document update conflict"),z=new N(400,"bad_request","_id field must contain a string"),J=new N(412,"missing_id","_id is required for puts"),H=new N(400,"bad_request","Only reserved document ids may start with underscore."),K=(new N(412,"precondition_failed","Database not open"),new N(500,"unknown_error","Database encountered an unknown error")),V=new N(500,"badarg","Some query argument is invalid"),X=(new N(400,"invalid_request","Request was invalid"),new N(400,"query_parse_error","Some query parameter is invalid")),Y=new N(500,"doc_validation","Bad special document member"),G=new N(400,"bad_request","Something wrong with the request"),Q=new N(400,"bad_request","Document must be a JSON object"),Z=(new N(404,"not_found","Database not found"),new N(500,"indexed_db_went_bad","unknown")),ee=(new N(500,"web_sql_went_bad","unknown"),new N(500,"levelDB_went_went_bad","unknown"),new N(403,"forbidden","Forbidden by design doc validate_doc_update function"),new N(400,"bad_request","Invalid rev format")),te=(new N(412,"file_exists","The database could not be created, the file already exists."),new N(412,"missing_stub","A pre-existing attachment stub wasn't found"));new N(413,"invalid_url","Provided URL is invalid");function ne(e,t){function n(t){for(var n=Object.getOwnPropertyNames(e),r=0,i=n.length;r<i;r++)"function"!=typeof e[n[r]]&&(this[n[r]]=e[n[r]]);void 0!==t&&(this.reason=t)}return n.prototype=N.prototype,new n(t)}function re(e){if("object"!=typeof e){var t=e;(e=K).data=t}return"error"in e&&"conflict"===e.error&&(e.name="conflict",e.status=409),"name"in e||(e.name=e.error||"unknown"),"status"in e||(e.status=500),"message"in e||(e.message=e.message||e.reason),e}function ie(e){var t={},n=e.filter&&"function"==typeof e.filter;return t.query=e.query_params,function(r){r.doc||(r.doc={});var i=n&&function(e,t,n){try{return!e(t,n)}catch(e){var r="Filter function threw: "+e.toString();return ne(G,r)}}(e.filter,r.doc,t);if("object"==typeof i)return i;if(i)return!1;if(e.include_docs){if(!e.attachments)for(var o in r.doc._attachments)r.doc._attachments.hasOwnProperty(o)&&(r.doc._attachments[o].stub=!0)}else delete r.doc;return!0}}function oe(e){for(var t=[],n=0,r=e.length;n<r;n++)t=t.concat(e[n]);return t}function se(e){var t;if(e?"string"!=typeof e?t=ne(z):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=ne(H)):t=ne(J),t)throw t}function ae(e){return"boolean"==typeof e._remote?e._remote:"function"==typeof e.type&&(B("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),"http"===e.type())}function ce(e){if(!e)return null;var t=e.split("/");return 2===t.length?t:1===t.length?[e,e]:null}function ue(e){var t=ce(e);return t?t.join("/"):null}var le=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],he=/(?:^|&)([^&=]*)=?([^&]*)/g,de=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;function pe(e){for(var t=de.exec(e),n={},r=14;r--;){var i=le[r],o=t[r]||"",s=-1!==["user","password"].indexOf(i);n[i]=s?decodeURIComponent(o):o}return n.queryKey={},n[le[12]].replace(he,(function(e,t,r){t&&(n.queryKey[t]=r)})),n}function fe(e,t){var n=[],r=[];for(var i in t)t.hasOwnProperty(i)&&(n.push(i),r.push(t[i]));return n.push(e),Function.apply(null,n).apply(null,r)}function me(e,t,n){return new Promise((function(r,i){e.get(t,(function(o,s){if(o){if(404!==o.status)return i(o);s={}}var a=s._rev,c=n(s);if(!c)return r({updated:!1,rev:a});c._id=t,c._rev=a,r(function(e,t,n){return e.put(t).then((function(e){return{updated:!0,rev:e.rev}}),(function(r){if(409!==r.status)throw r;return me(e,t._id,n)}))}(e,c,n))}))}))}var ge=function(e){return atob(e)},_e=function(e){return btoa(e)};function ye(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}function ve(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),i=0;i<t;i++)r[i]=e.charCodeAt(i);return n}function be(e,t){return ye([ve(e)],{type:t})}function we(e,t){return be(ge(e),t)}function xe(e,t){var n=new FileReader,r="function"==typeof n.readAsBinaryString;n.onloadend=function(e){var n=e.target.result||"";if(r)return t(n);t(function(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,i=0;i<r;i++)t+=String.fromCharCode(n[i]);return t}(n))},r?n.readAsBinaryString(e):n.readAsArrayBuffer(e)}function ke(e,t){xe(e,(function(e){t(e)}))}function Ee(e,t){ke(e,(function(e){t(_e(e))}))}var je=self.setImmediate||self.setTimeout;function Ae(e,t,n,r,i){(n>0||r<t.size)&&(t=function(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.slice(t,n)}(t,n,r)),function(e,t){var n=new FileReader;n.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},n.readAsArrayBuffer(e)}(t,(function(t){e.append(t),i()}))}function De(e,t,n,r,i){(n>0||r<t.length)&&(t=t.substring(n,r)),e.appendBinary(t),i()}function Se(e,t){var n="string"==typeof e,r=n?e.length:e.size,i=Math.min(32768,r),o=Math.ceil(r/i),s=0,a=n?new u.a:new u.a.ArrayBuffer,c=n?De:Ae;function l(){je(d)}function h(){var e=function(e){return _e(e)}(a.end(!0));t(e),a.destroy()}function d(){var t=s*i,n=t+i;s++,c(a,e,t,n,s<o?l:h)}d()}function Ce(e){return u.a.hash(e)}function Oe(e,t){var n=j(e);return t?(delete n._rev_tree,Ce(JSON.stringify(n))):Object(a.a)().replace(/-/g,"").toLowerCase()}var Pe=a.a;function Fe(e){for(var t,n,r,i,o=e.rev_tree.slice();i=o.pop();){var s=i.ids,a=s[2],c=i.pos;if(a.length)for(var u=0,l=a.length;u<l;u++)o.push({pos:c+1,ids:a[u]});else{var h=!!s[1].deleted,d=s[0];t&&!(r!==h?r:n!==c?n<c:t<d)||(t=d,n=c,r=h)}}return n+"-"+t}function Ie(e,t){for(var n,r=e.slice();n=r.pop();)for(var i=n.pos,o=n.ids,s=o[2],a=t(0===s.length,i,o[0],n.ctx,o[1]),c=0,u=s.length;c<u;c++)r.push({pos:i+1,ids:s[c],ctx:a})}function Te(e,t){return e.pos-t.pos}function Re(e){var t=[];Ie(e,(function(e,n,r,i,o){e&&t.push({rev:n+"-"+r,pos:n,opts:o})})),t.sort(Te).reverse();for(var n=0,r=t.length;n<r;n++)delete t[n].pos;return t}function Be(e){for(var t=Fe(e),n=Re(e.rev_tree),r=[],i=0,o=n.length;i<o;i++){var s=n[i];s.rev===t||s.opts.deleted||r.push(s.rev)}return r}function Me(e){for(var t,n=[],r=e.slice();t=r.pop();){var i=t.pos,o=t.ids,s=o[0],a=o[1],c=o[2],u=0===c.length,l=t.history?t.history.slice():[];l.push({id:s,opts:a}),u&&n.push({pos:i+1-l.length,ids:l});for(var h=0,d=c.length;h<d;h++)r.push({pos:i+1,ids:c[h],history:l})}return n.reverse()}function qe(e,t){return e.pos-t.pos}function Le(e,t,n){var r=function(e,t,n){for(var r,i=0,o=e.length;i<o;)n(e[r=i+o>>>1],t)<0?i=r+1:o=r;return i}(e,t,n);e.splice(r,0,t)}function Ne(e,t){for(var n,r,i=t,o=e.length;i<o;i++){var s=e[i],a=[s.id,s.opts,[]];r?(r[2].push(a),r=a):n=r=a}return n}function Ue(e,t){return e[0]<t[0]?-1:1}function We(e,t){for(var n=[{tree1:e,tree2:t}],r=!1;n.length>0;){var i=n.pop(),o=i.tree1,s=i.tree2;(o[1].status||s[1].status)&&(o[1].status="available"===o[1].status||"available"===s[1].status?"available":"missing");for(var a=0;a<s[2].length;a++)if(o[2][0]){for(var c=!1,u=0;u<o[2].length;u++)o[2][u][0]===s[2][a][0]&&(n.push({tree1:o[2][u],tree2:s[2][a]}),c=!0);c||(r="new_branch",Le(o[2],s[2][a],Ue))}else r="new_leaf",o[2][0]=s[2][a]}return{conflicts:r,tree:e}}function $e(e,t,n){var r,i=[],o=!1,s=!1;if(!e.length)return{tree:[t],conflicts:"new_leaf"};for(var a=0,c=e.length;a<c;a++){var u=e[a];if(u.pos===t.pos&&u.ids[0]===t.ids[0])r=We(u.ids,t.ids),i.push({pos:u.pos,ids:r.tree}),o=o||r.conflicts,s=!0;else if(!0!==n){var l=u.pos<t.pos?u:t,h=u.pos<t.pos?t:u,d=h.pos-l.pos,p=[],f=[];for(f.push({ids:l.ids,diff:d,parent:null,parentIdx:null});f.length>0;){var m=f.pop();if(0!==m.diff)for(var g=m.ids[2],_=0,y=g.length;_<y;_++)f.push({ids:g[_],diff:m.diff-1,parent:m.ids,parentIdx:_});else m.ids[0]===h.ids[0]&&p.push(m)}var v=p[0];v?(r=We(v.ids,h.ids),v.parent[2][v.parentIdx]=r.tree,i.push({pos:l.pos,ids:l.ids}),o=o||r.conflicts,s=!0):i.push(u)}else i.push(u)}return s||i.push(t),i.sort(qe),{tree:i,conflicts:o||"internal_node"}}function ze(e,t,n){var r=$e(e,t),i=function(e,t){for(var n,r,i=Me(e),o=0,s=i.length;o<s;o++){var a,c=i[o],u=c.ids;if(u.length>t){n||(n={});var l=u.length-t;a={pos:c.pos+l,ids:Ne(u,l)};for(var h=0;h<l;h++){var d=c.pos+h+"-"+u[h].id;n[d]=!0}}else a={pos:c.pos,ids:Ne(u,0)};r=r?$e(r,a,!0).tree:[a]}return n&&Ie(r,(function(e,t,r){delete n[t+"-"+r]})),{tree:r,revs:n?Object.keys(n):[]}}(r.tree,n);return{tree:i.tree,stemmedRevs:i.revs,conflicts:r.conflicts}}function Je(e){return e.ids}function He(e,t){t||(t=Fe(e));for(var n,r=t.substring(t.indexOf("-")+1),i=e.rev_tree.map(Je);n=i.pop();){if(n[0]===r)return!!n[1].deleted;i=i.concat(n[2])}}function Ke(e){return/^_local/.test(e)}function Ve(e,t,n){_.a.call(this);var r=this;this.db=e;var i=(t=t?j(t):{}).complete=A((function(t,n){var i,s;t?(s="error",("listenerCount"in(i=r)?i.listenerCount(s):_.a.listenerCount(i,s))>0&&r.emit("error",t)):r.emit("complete",n),r.removeAllListeners(),e.removeListener("destroyed",o)}));function o(){r.cancel()}n&&(r.on("complete",(function(e){n(null,e)})),r.on("error",n)),e.once("destroyed",o),t.onChange=function(e,t,n){r.isCancelled||function(e,t,n,r){try{e.emit("change",t,n,r)}catch(e){B("error",'Error in .on("change", function):',e)}}(r,e,t,n)};var s=new Promise((function(e,n){t.complete=function(t,r){t?n(t):e(r)}}));r.once("cancel",(function(){e.removeListener("destroyed",o),t.complete(null,{status:"cancelled"})})),this.then=s.then.bind(s),this.catch=s.catch.bind(s),this.then((function(e){i(null,e)}),i),e.taskqueue.isReady?r.validateChanges(t):e.taskqueue.addTask((function(e){e?t.complete(e):r.isCancelled?r.emit("cancel"):r.validateChanges(t)}))}function Xe(e,t,n){var r=[{rev:e._rev}];"all_docs"===n.style&&(r=Re(t.rev_tree).map((function(e){return{rev:e.rev}})));var i={id:t.id,changes:r,doc:e};return He(t,e._rev)&&(i.deleted=!0),n.conflicts&&(i.doc._conflicts=Be(t),i.doc._conflicts.length||delete i.doc._conflicts),i}function Ye(e,t){return e<t?-1:e>t?1:0}function Ge(e,t){return function(n,r){n||r[0]&&r[0].error?((n=n||r[0]).docId=t,e(n)):e(null,r.length?r[0]:r)}}function Qe(e,t){var n=Ye(e._id,t._id);return 0!==n?n:Ye(e._revisions?e._revisions.start:0,t._revisions?t._revisions.start:0)}function Ze(){for(var e in _.a.call(this),Ze.prototype)"function"==typeof this[e]&&(this[e]=this[e].bind(this))}function et(){this.isReady=!1,this.failed=!1,this.queue=[]}function tt(e,t){if(!(this instanceof tt))return new tt(e,t);var n=this;if(t=t||{},e&&"object"==typeof e&&(e=(t=e).name,delete t.name),void 0===t.deterministic_revs&&(t.deterministic_revs=!0),this.__opts=t=j(t),n.auto_compaction=t.auto_compaction,n.prefix=tt.prefix,"string"!=typeof e)throw new Error("Missing/invalid DB name");var r=function(e,t){var n=e.match(/([a-z-]*):\/\/(.*)/);if(n)return{name:/https?/.test(n[1])?n[1]+"://"+n[2]:n[2],adapter:n[1]};var r=tt.adapters,i=tt.preferredAdapters,o=tt.prefix,s=t.adapter;if(!s)for(var a=0;a<i.length&&("idb"===(s=i[a])&&"websql"in r&&T()&&localStorage["_pouch__websqldb_"+o+e]);++a)B("log",'PouchDB is downgrading "'+e+'" to WebSQL to avoid data loss, because it was already opened with WebSQL.');var c=r[s];return{name:!c||!("use_prefix"in c)||c.use_prefix?o+e:e,adapter:s}}((t.prefix||"")+e,t);if(t.name=r.name,t.adapter=t.adapter||r.adapter,n.name=e,n._adapter=t.adapter,tt.emit("debug",["adapter","Picked adapter: ",t.adapter]),!tt.adapters[t.adapter]||!tt.adapters[t.adapter].valid())throw new Error("Invalid Adapter: "+t.adapter);Ze.call(n),n.taskqueue=new et,n.adapter=t.adapter,tt.adapters[t.adapter].call(n,t,(function(e){if(e)return n.taskqueue.fail(e);!function(e){function t(t){e.removeListener("closed",n),t||e.constructor.emit("destroyed",e.name)}function n(){e.removeListener("destroyed",t),e.constructor.emit("unref",e)}e.once("destroyed",t),e.once("closed",n),e.constructor.emit("ref",e)}(n),n.emit("created",n),tt.emit("created",n.name),n.taskqueue.ready(n)}))}m()(Ve,_.a),Ve.prototype.cancel=function(){this.isCancelled=!0,this.db.taskqueue.isReady&&this.emit("cancel")},Ve.prototype.validateChanges=function(e){var t=e.complete,n=this;tt._changesFilterPlugin?tt._changesFilterPlugin.validate(e,(function(r){if(r)return t(r);n.doChanges(e)})):n.doChanges(e)},Ve.prototype.doChanges=function(e){var t=this,n=e.complete;if("live"in(e=j(e))&&!("continuous"in e)&&(e.continuous=e.live),e.processChange=Xe,"latest"===e.since&&(e.since="now"),e.since||(e.since=0),"now"!==e.since){if(tt._changesFilterPlugin){if(tt._changesFilterPlugin.normalize(e),tt._changesFilterPlugin.shouldFilter(this,e))return tt._changesFilterPlugin.filter(this,e)}else["doc_ids","filter","selector","view"].forEach((function(t){t in e&&B("warn",'The "'+t+'" option was passed in to changes/replicate, but pouchdb-changes-filter plugin is not installed, so it was ignored. Please install the plugin to enable filtering.')}));"descending"in e||(e.descending=!1),e.limit=0===e.limit?1:e.limit,e.complete=n;var r=this.db._changes(e);if(r&&"function"==typeof r.cancel){var i=t.cancel;t.cancel=p()((function(e){r.cancel(),i.apply(this,e)}))}}else this.db.info().then((function(r){t.isCancelled?n(null,{status:"cancelled"}):(e.since=r.update_seq,t.doChanges(e))}),n)},m()(Ze,_.a),Ze.prototype.post=S("post",(function(e,t,n){if("function"==typeof t&&(n=t,t={}),"object"!=typeof e||Array.isArray(e))return n(ne(Q));this.bulkDocs({docs:[e]},t,Ge(n,e._id))})),Ze.prototype.put=S("put",(function(e,t,n){if("function"==typeof t&&(n=t,t={}),"object"!=typeof e||Array.isArray(e))return n(ne(Q));if(se(e._id),Ke(e._id)&&"function"==typeof this._putLocal)return e._deleted?this._removeLocal(e,n):this._putLocal(e,n);var r,i,o,s,a=this;function c(n){"function"==typeof a._put&&!1!==t.new_edits?a._put(e,t,n):a.bulkDocs({docs:[e]},t,Ge(n,e._id))}t.force&&e._rev?(r=e._rev.split("-"),i=r[1],o=parseInt(r[0],10)+1,s=Oe(),e._revisions={start:o,ids:[s,i]},e._rev=o+"-"+s,t.new_edits=!1,c((function(t){var r=t?null:{ok:!0,id:e._id,rev:e._rev};n(t,r)}))):c(n)})),Ze.prototype.putAttachment=S("putAttachment",(function(e,t,n,r,i){var o=this;function s(e){var n="_rev"in e?parseInt(e._rev,10):0;return e._attachments=e._attachments||{},e._attachments[t]={content_type:i,data:r,revpos:++n},o.put(e)}return"function"==typeof i&&(i=r,r=n,n=null),void 0===i&&(i=r,r=n,n=null),i||B("warn","Attachment",t,"on document",e,"is missing content_type"),o.get(e).then((function(e){if(e._rev!==n)throw ne($);return s(e)}),(function(t){if(t.reason===W.message)return s({_id:e});throw t}))})),Ze.prototype.removeAttachment=S("removeAttachment",(function(e,t,n,r){var i=this;i.get(e,(function(e,o){if(e)r(e);else if(o._rev===n){if(!o._attachments)return r();delete o._attachments[t],0===Object.keys(o._attachments).length&&delete o._attachments,i.put(o,r)}else r(ne($))}))})),Ze.prototype.remove=S("remove",(function(e,t,n,r){var i;"string"==typeof t?(i={_id:e,_rev:t},"function"==typeof n&&(r=n,n={})):(i=e,"function"==typeof t?(r=t,n={}):(r=n,n=t)),(n=n||{}).was_delete=!0;var o={_id:i._id,_rev:i._rev||n.rev,_deleted:!0};if(Ke(o._id)&&"function"==typeof this._removeLocal)return this._removeLocal(i,r);this.bulkDocs({docs:[o]},n,Ge(r,o._id))})),Ze.prototype.revsDiff=S("revsDiff",(function(e,t,n){"function"==typeof t&&(n=t,t={});var r=Object.keys(e);if(!r.length)return n(null,{});var o=0,s=new i;function a(e,t){s.has(e)||s.set(e,{missing:[]}),s.get(e).missing.push(t)}r.map((function(t){this._getRevisionTree(t,(function(i,c){if(i&&404===i.status&&"missing"===i.message)s.set(t,{missing:e[t]});else{if(i)return n(i);!function(t,n){var r=e[t].slice(0);Ie(n,(function(e,n,i,o,s){var c=n+"-"+i,u=r.indexOf(c);-1!==u&&(r.splice(u,1),"available"!==s.status&&a(t,c))})),r.forEach((function(e){a(t,e)}))}(t,c)}if(++o===r.length){var u={};return s.forEach((function(e,t){u[t]=e})),n(null,u)}}))}),this)})),Ze.prototype.bulkGet=S("bulkGet",(function(e,t){I(this,e,t)})),Ze.prototype.compactDocument=S("compactDocument",(function(e,t,n){var r=this;this._getRevisionTree(e,(function(i,o){if(i)return n(i);var s=function(e){var t={},n=[];return Ie(e,(function(e,r,i,o){var s=r+"-"+i;return e&&(t[s]=0),void 0!==o&&n.push({from:o,to:s}),s})),n.reverse(),n.forEach((function(e){void 0===t[e.from]?t[e.from]=1+t[e.to]:t[e.from]=Math.min(t[e.from],1+t[e.to])})),t}(o),a=[],c=[];Object.keys(s).forEach((function(e){s[e]>t&&a.push(e)})),Ie(o,(function(e,t,n,r,i){var o=t+"-"+n;"available"===i.status&&-1!==a.indexOf(o)&&c.push(o)})),r._doCompaction(e,c,n)}))})),Ze.prototype.compact=S("compact",(function(e,t){"function"==typeof e&&(t=e,e={});e=e||{},this._compactionQueue=this._compactionQueue||[],this._compactionQueue.push({opts:e,callback:t}),1===this._compactionQueue.length&&function e(t){var n=t._compactionQueue[0],r=n.opts,i=n.callback;t.get("_local/compaction").catch((function(){return!1})).then((function(n){n&&n.last_seq&&(r.last_seq=n.last_seq),t._compact(r,(function(n,r){n?i(n):i(null,r),s()((function(){t._compactionQueue.shift(),t._compactionQueue.length&&e(t)}))}))}))}(this)})),Ze.prototype._compact=function(e,t){var n=this,r={return_docs:!1,last_seq:e.last_seq||0},i=[];n.changes(r).on("change",(function(e){i.push(n.compactDocument(e.id,0))})).on("complete",(function(e){var r=e.last_seq;Promise.all(i).then((function(){return me(n,"_local/compaction",(function(e){return(!e.last_seq||e.last_seq<r)&&(e.last_seq=r,e)}))})).then((function(){t(null,{ok:!0})})).catch(t)})).on("error",t)},Ze.prototype.get=S("get",(function(e,t,n){if("function"==typeof t&&(n=t,t={}),"string"!=typeof e)return n(ne(z));if(Ke(e)&&"function"==typeof this._getLocal)return this._getLocal(e,n);var r=[],i=this;function o(){var o=[],s=r.length;if(!s)return n(null,o);r.forEach((function(r){i.get(e,{rev:r,revs:t.revs,latest:t.latest,attachments:t.attachments,binary:t.binary},(function(e,t){if(e)o.push({missing:r});else{for(var i,a=0,c=o.length;a<c;a++)if(o[a].ok&&o[a].ok._rev===t._rev){i=!0;break}i||o.push({ok:t})}--s||n(null,o)}))}))}if(!t.open_revs)return this._get(e,t,(function(r,o){if(r)return r.docId=e,n(r);var s=o.doc,a=o.metadata,c=o.ctx;if(t.conflicts){var u=Be(a);u.length&&(s._conflicts=u)}if(He(a,s._rev)&&(s._deleted=!0),t.revs||t.revs_info){for(var l=s._rev.split("-"),h=parseInt(l[0],10),d=l[1],p=Me(a.rev_tree),f=null,m=0;m<p.length;m++){var g=p[m],_=g.ids.map((function(e){return e.id})).indexOf(d);(_===h-1||!f&&-1!==_)&&(f=g)}if(!f)return(r=new Error("invalid rev tree")).docId=e,n(r);var y=f.ids.map((function(e){return e.id})).indexOf(s._rev.split("-")[1])+1,v=f.ids.length-y;if(f.ids.splice(y,v),f.ids.reverse(),t.revs&&(s._revisions={start:f.pos+f.ids.length-1,ids:f.ids.map((function(e){return e.id}))}),t.revs_info){var b=f.pos+f.ids.length;s._revs_info=f.ids.map((function(e){return{rev:--b+"-"+e.id,status:e.opts.status}}))}}if(t.attachments&&s._attachments){var w=s._attachments,x=Object.keys(w).length;if(0===x)return n(null,s);Object.keys(w).forEach((function(e){this._getAttachment(s._id,e,w[e],{rev:s._rev,binary:t.binary,ctx:c},(function(t,r){var i=s._attachments[e];i.data=r,delete i.stub,delete i.length,--x||n(null,s)}))}),i)}else{if(s._attachments)for(var k in s._attachments)s._attachments.hasOwnProperty(k)&&(s._attachments[k].stub=!0);n(null,s)}}));if("all"===t.open_revs)this._getRevisionTree(e,(function(e,t){if(e)return n(e);r=Re(t).map((function(e){return e.rev})),o()}));else{if(!Array.isArray(t.open_revs))return n(ne(K,"function_clause"));r=t.open_revs;for(var s=0;s<r.length;s++){var a=r[s];if("string"!=typeof a||!/^\d+-/.test(a))return n(ne(ee))}o()}})),Ze.prototype.getAttachment=S("getAttachment",(function(e,t,n,r){var i=this;n instanceof Function&&(r=n,n={}),this._get(e,n,(function(o,s){return o?r(o):s.doc._attachments&&s.doc._attachments[t]?(n.ctx=s.ctx,n.binary=!0,void i._getAttachment(e,t,s.doc._attachments[t],n,r)):r(ne(W))}))})),Ze.prototype.allDocs=S("allDocs",(function(e,t){if("function"==typeof e&&(t=e,e={}),e.skip=void 0!==e.skip?e.skip:0,e.start_key&&(e.startkey=e.start_key),e.end_key&&(e.endkey=e.end_key),"keys"in e){if(!Array.isArray(e.keys))return t(new TypeError("options.keys must be an array"));var n=["startkey","endkey","key"].filter((function(t){return t in e}))[0];if(n)return void t(ne(X,"Query parameter `"+n+"` is not compatible with multi-get"));if(!ae(this)&&(function(e){var t="limit"in e?e.keys.slice(e.skip,e.limit+e.skip):e.skip>0?e.keys.slice(e.skip):e.keys;e.keys=t,e.skip=0,delete e.limit,e.descending&&(t.reverse(),e.descending=!1)}(e),0===e.keys.length))return this._allDocs({limit:0},t)}return this._allDocs(e,t)})),Ze.prototype.changes=function(e,t){return"function"==typeof e&&(t=e,e={}),(e=e||{}).return_docs="return_docs"in e?e.return_docs:!e.live,new Ve(this,e,t)},Ze.prototype.close=S("close",(function(e){return this._closed=!0,this.emit("closed"),this._close(e)})),Ze.prototype.info=S("info",(function(e){var t=this;this._info((function(n,r){if(n)return e(n);r.db_name=r.db_name||t.name,r.auto_compaction=!(!t.auto_compaction||ae(t)),r.adapter=t.adapter,e(null,r)}))})),Ze.prototype.id=S("id",(function(e){return this._id(e)})),Ze.prototype.type=function(){return"function"==typeof this._type?this._type():this.adapter},Ze.prototype.bulkDocs=S("bulkDocs",(function(e,t,n){if("function"==typeof t&&(n=t,t={}),t=t||{},Array.isArray(e)&&(e={docs:e}),!e||!e.docs||!Array.isArray(e.docs))return n(ne(U));for(var r=0;r<e.docs.length;++r)if("object"!=typeof e.docs[r]||Array.isArray(e.docs[r]))return n(ne(Q));var i;if(e.docs.forEach((function(e){e._attachments&&Object.keys(e._attachments).forEach((function(t){i=i||function(e){return"_"===e.charAt(0)&&e+" is not a valid attachment name, attachment names cannot start with '_'"}(t),e._attachments[t].content_type||B("warn","Attachment",t,"on document",e._id,"is missing content_type")}))})),i)return n(ne(G,i));"new_edits"in t||(t.new_edits=!("new_edits"in e)||e.new_edits);var o=this;t.new_edits||ae(o)||e.docs.sort(Qe),function(e){for(var t=0;t<e.length;t++){var n=e[t];if(n._deleted)delete n._attachments;else if(n._attachments)for(var r=Object.keys(n._attachments),i=0;i<r.length;i++){var o=r[i];n._attachments[o]=C(n._attachments[o],["data","digest","content_type","length","revpos","stub"])}}}(e.docs);var s=e.docs.map((function(e){return e._id}));return this._bulkDocs(e,t,(function(e,r){if(e)return n(e);if(t.new_edits||(r=r.filter((function(e){return e.error}))),!ae(o))for(var i=0,a=r.length;i<a;i++)r[i].id=r[i].id||s[i];n(null,r)}))})),Ze.prototype.registerDependentDatabase=S("registerDependentDatabase",(function(e,t){var n=new this.constructor(e,this.__opts);me(this,"_local/_pouch_dependentDbs",(function(t){return t.dependentDbs=t.dependentDbs||{},!t.dependentDbs[e]&&(t.dependentDbs[e]=!0,t)})).then((function(){t(null,{db:n})})).catch(t)})),Ze.prototype.destroy=S("destroy",(function(e,t){"function"==typeof e&&(t=e,e={});var n=this,r=!("use_prefix"in n)||n.use_prefix;function i(){n._destroy(e,(function(e,r){if(e)return t(e);n._destroyed=!0,n.emit("destroyed"),t(null,r||{ok:!0})}))}if(ae(n))return i();n.get("_local/_pouch_dependentDbs",(function(e,o){if(e)return 404!==e.status?t(e):i();var s=o.dependentDbs,a=n.constructor,c=Object.keys(s).map((function(e){var t=r?e.replace(new RegExp("^"+a.prefix),""):e;return new a(t,n.__opts).destroy()}));Promise.all(c).then(i,t)}))})),et.prototype.execute=function(){var e;if(this.failed)for(;e=this.queue.shift();)e(this.failed);else for(;e=this.queue.shift();)e()},et.prototype.fail=function(e){this.failed=e,this.execute()},et.prototype.ready=function(e){this.isReady=!0,this.db=e,this.execute()},et.prototype.addTask=function(e){this.queue.push(e),this.failed&&this.execute()},m()(tt,Ze);var nt="undefined"!=typeof AbortController?AbortController:function(){return{abort:function(){}}},rt=fetch,it=Headers;tt.adapters={},tt.preferredAdapters=[],tt.prefix="_pouch_";var ot=new _.a;!function(e){Object.keys(_.a.prototype).forEach((function(t){"function"==typeof _.a.prototype[t]&&(e[t]=ot[t].bind(ot))}));var t=e._destructionListeners=new i;e.on("ref",(function(e){t.has(e.name)||t.set(e.name,[]),t.get(e.name).push(e)})),e.on("unref",(function(e){if(t.has(e.name)){var n=t.get(e.name),r=n.indexOf(e);r<0||(n.splice(r,1),n.length>1?t.set(e.name,n):t.delete(e.name))}})),e.on("destroyed",(function(e){if(t.has(e)){var n=t.get(e);t.delete(e),n.forEach((function(e){e.emit("destroyed",!0)}))}}))}(tt),tt.adapter=function(e,t,n){t.valid()&&(tt.adapters[e]=t,n&&tt.preferredAdapters.push(e))},tt.plugin=function(e){if("function"==typeof e)e(tt);else{if("object"!=typeof e||0===Object.keys(e).length)throw new Error('Invalid plugin: got "'+e+'", expected an object or a function');Object.keys(e).forEach((function(t){tt.prototype[t]=e[t]}))}return this.__defaults&&(tt.__defaults=L({},this.__defaults)),tt},tt.defaults=function(e){function t(e,n){if(!(this instanceof t))return new t(e,n);n=n||{},e&&"object"==typeof e&&(e=(n=e).name,delete n.name),n=L({},t.__defaults,n),tt.call(this,e,n)}return m()(t,tt),t.preferredAdapters=tt.preferredAdapters.slice(),Object.keys(tt).forEach((function(e){e in t||(t[e]=tt[e])})),t.__defaults=L({},this.__defaults,e),t},tt.fetch=function(e,t){return rt(e,t)};function st(e,t){for(var n=e,r=0,i=t.length;r<i;r++){if(!(n=n[t[r]]))break}return n}function at(e){for(var t=[],n="",r=0,i=e.length;r<i;r++){var o=e[r];"."===o?r>0&&"\\"===e[r-1]?n=n.substring(0,n.length-1)+".":(t.push(n),n=""):n+=o}return t.push(n),t}var ct=["$or","$nor","$not"];function ut(e){return ct.indexOf(e)>-1}function lt(e){return Object.keys(e)[0]}function ht(e){var t={};return e.forEach((function(e){Object.keys(e).forEach((function(n){var r=e[n];if("object"!=typeof r&&(r={$eq:r}),ut(n))t[n]=r instanceof Array?r.map((function(e){return ht([e])})):ht([r]);else{var i=t[n]=t[n]||{};Object.keys(r).forEach((function(e){var t=r[e];return"$gt"===e||"$gte"===e?function(e,t,n){if(void 0!==n.$eq)return;void 0!==n.$gte?"$gte"===e?t>n.$gte&&(n.$gte=t):t>=n.$gte&&(delete n.$gte,n.$gt=t):void 0!==n.$gt?"$gte"===e?t>n.$gt&&(delete n.$gt,n.$gte=t):t>n.$gt&&(n.$gt=t):n[e]=t}(e,t,i):"$lt"===e||"$lte"===e?function(e,t,n){if(void 0!==n.$eq)return;void 0!==n.$lte?"$lte"===e?t<n.$lte&&(n.$lte=t):t<=n.$lte&&(delete n.$lte,n.$lt=t):void 0!==n.$lt?"$lte"===e?t<n.$lt&&(delete n.$lt,n.$lte=t):t<n.$lt&&(n.$lt=t):n[e]=t}(e,t,i):"$ne"===e?function(e,t){"$ne"in t?t.$ne.push(e):t.$ne=[e]}(t,i):"$eq"===e?function(e,t){delete t.$gt,delete t.$gte,delete t.$lt,delete t.$lte,delete t.$ne,t.$eq=e}(t,i):void(i[e]=t)}))}}))})),t}function dt(e){var t=j(e),n=!1;(function e(t,n){for(var r in t){"$and"===r&&(n=!0);var i=t[r];"object"==typeof i&&(n=e(i,n))}return n})(t,!1)&&("$and"in(t=function e(t){for(var n in t){if(Array.isArray(t))for(var r in t)t[r].$and&&(t[r]=ht(t[r].$and));var i=t[n];"object"==typeof i&&e(i)}return t}(t))&&(t=ht(t.$and)),n=!0),["$or","$nor"].forEach((function(e){e in t&&t[e].forEach((function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var r=t[n],i=e[r];"object"==typeof i&&null!==i||(e[r]={$eq:i})}}))})),"$not"in t&&(t.$not=ht([t.$not]));for(var r=Object.keys(t),i=0;i<r.length;i++){var o=r[i],s=t[o];"object"!=typeof s||null===s?s={$eq:s}:"$ne"in s&&!n&&(s.$ne=[s.$ne]),t[o]=s}return t}function pt(e,t){if(e===t)return 0;e=ft(e),t=ft(t);var n=vt(e),r=vt(t);if(n-r!=0)return n-r;switch(typeof e){case"number":return e-t;case"boolean":return e<t?-1:1;case"string":return function(e,t){return e===t?0:e>t?1:-1}(e,t)}return Array.isArray(e)?function(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){var i=pt(e[r],t[r]);if(0!==i)return i}return e.length===t.length?0:e.length>t.length?1:-1}(e,t):function(e,t){for(var n=Object.keys(e),r=Object.keys(t),i=Math.min(n.length,r.length),o=0;o<i;o++){var s=pt(n[o],r[o]);if(0!==s)return s;if(0!==(s=pt(e[n[o]],t[r[o]])))return s}return n.length===r.length?0:n.length>r.length?1:-1}(e,t)}function ft(e){switch(typeof e){case"undefined":return null;case"number":return e===1/0||e===-1/0||isNaN(e)?null:e;case"object":var t=e;if(Array.isArray(e)){var n=e.length;e=new Array(n);for(var r=0;r<n;r++)e[r]=ft(t[r])}else{if(e instanceof Date)return e.toJSON();if(null!==e)for(var i in e={},t)if(t.hasOwnProperty(i)){var o=t[i];void 0!==o&&(e[i]=ft(o))}}}return e}function mt(e){if(null!==e)switch(typeof e){case"boolean":return e?1:0;case"number":return function(e){if(0===e)return"1";var t=e.toExponential().split(/e\+?/),n=parseInt(t[1],10),r=e<0,i=r?"0":"2",o=(s=((r?-n:n)- -324).toString(),a="0",c=3,function(e,t,n){for(var r="",i=n-e.length;r.length<i;)r+=t;return r}(s,a,c)+s);var s,a,c;i+=""+o;var u=Math.abs(parseFloat(t[0]));r&&(u=10-u);var l=u.toFixed(20);return l=l.replace(/\.?0+$/,""),i+=""+l}(e);case"string":return e.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var t=Array.isArray(e),n=t?e:Object.keys(e),r=-1,i=n.length,o="";if(t)for(;++r<i;)o+=gt(n[r]);else for(;++r<i;){var s=n[r];o+=gt(s)+gt(e[s])}return o}return""}function gt(e){return vt(e=ft(e))+""+mt(e)+"\0"}function _t(e,t){var n,r=t;if("1"===e[t])n=0,t++;else{var i="0"===e[t];t++;var o="",s=e.substring(t,t+3),a=parseInt(s,10)+-324;for(i&&(a=-a),t+=3;;){var c=e[t];if("\0"===c)break;o+=c,t++}n=1===(o=o.split(".")).length?parseInt(o,10):parseFloat(o[0]+"."+o[1]),i&&(n-=10),0!==a&&(n=parseFloat(n+"e"+a))}return{num:n,length:t-r}}function yt(e,t){var n=e.pop();if(t.length){var r=t[t.length-1];n===r.element&&(t.pop(),r=t[t.length-1]);var i=r.element,o=r.index;if(Array.isArray(i))i.push(n);else if(o===e.length-2){i[e.pop()]=n}else e.push(n)}}function vt(e){var t=["boolean","number","string","object"].indexOf(typeof e);return~t?null===e?1:Array.isArray(e)?5:t<3?t+2:t+3:Array.isArray(e)?5:void 0}function bt(e,t,n){if(e=e.filter((function(e){return wt(e.doc,t.selector,n)})),t.sort){var r=function(e){function t(t){return e.map((function(e){var n=at(lt(e));return st(t,n)}))}return function(e,n){var r,i,o=pt(t(e.doc),t(n.doc));return 0!==o?o:(r=e.doc._id,i=n.doc._id,r<i?-1:r>i?1:0)}}(t.sort);e=e.sort(r),"string"!=typeof t.sort[0]&&"desc"===(i=t.sort[0])[lt(i)]&&(e=e.reverse())}var i;if("limit"in t||"skip"in t){var o=t.skip||0,s=("limit"in t?t.limit:e.length)+o;e=e.slice(o,s)}return e}function wt(e,t,n){return n.every((function(n){var r=t[n],i=at(n),o=st(e,i);return ut(n)?function(e,t,n){if("$or"===e)return t.some((function(e){return wt(n,e,Object.keys(e))}));if("$not"===e)return!wt(n,t,Object.keys(t));return!t.find((function(e){return wt(n,e,Object.keys(e))}))}(n,r,e):xt(r,e,i,o)}))}function xt(e,t,n,r){return!e||("object"==typeof e?Object.keys(e).every((function(i){var o=e[i];return function(e,t,n,r,i){if(!At[e])throw new Error('unknown operator "'+e+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return At[e](t,n,r,i)}(i,t,o,n,r)})):e===r)}function kt(e){return null!=e}function Et(e){return void 0!==e}function jt(e,t){return t.some((function(t){return e instanceof Array?e.indexOf(t)>-1:e===t}))}var At={$elemMatch:function(e,t,n,r){return!!Array.isArray(r)&&(0!==r.length&&("object"==typeof r[0]?r.some((function(e){return wt(e,t,Object.keys(t))})):r.some((function(r){return xt(t,e,n,r)}))))},$allMatch:function(e,t,n,r){return!!Array.isArray(r)&&(0!==r.length&&("object"==typeof r[0]?r.every((function(e){return wt(e,t,Object.keys(t))})):r.every((function(r){return xt(t,e,n,r)}))))},$eq:function(e,t,n,r){return Et(r)&&0===pt(r,t)},$gte:function(e,t,n,r){return Et(r)&&pt(r,t)>=0},$gt:function(e,t,n,r){return Et(r)&&pt(r,t)>0},$lte:function(e,t,n,r){return Et(r)&&pt(r,t)<=0},$lt:function(e,t,n,r){return Et(r)&&pt(r,t)<0},$exists:function(e,t,n,r){return t?Et(r):!Et(r)},$mod:function(e,t,n,r){return kt(r)&&function(e,t){var n=t[0],r=t[1];if(0===n)throw new Error("Bad divisor, cannot divide by zero");if(parseInt(n,10)!==n)throw new Error("Divisor is not an integer");if(parseInt(r,10)!==r)throw new Error("Modulus is not an integer");return parseInt(e,10)===e&&e%n===r}(r,t)},$ne:function(e,t,n,r){return t.every((function(e){return 0!==pt(r,e)}))},$in:function(e,t,n,r){return kt(r)&&jt(r,t)},$nin:function(e,t,n,r){return kt(r)&&!jt(r,t)},$size:function(e,t,n,r){return kt(r)&&function(e,t){return e.length===t}(r,t)},$all:function(e,t,n,r){return Array.isArray(r)&&function(e,t){return t.every((function(t){return e.indexOf(t)>-1}))}(r,t)},$regex:function(e,t,n,r){return kt(r)&&function(e,t){return new RegExp(t).test(e)}(r,t)},$type:function(e,t,n,r){return function(e,t){switch(t){case"null":return null===e;case"boolean":return"boolean"==typeof e;case"number":return"number"==typeof e;case"string":return"string"==typeof e;case"array":return e instanceof Array;case"object":return"[object Object]"==={}.toString.call(e)}throw new Error(t+" not supported as a type.Please use one of object, string, array, number, boolean or null.")}(r,t)}};function Dt(e,t){if(e.selector&&e.filter&&"_selector"!==e.filter){var n="string"==typeof e.filter?e.filter:"function";return t(new Error('selector invalid for filter "'+n+'"'))}t()}function St(e){e.view&&!e.filter&&(e.filter="_view"),e.selector&&!e.filter&&(e.filter="_selector"),e.filter&&"string"==typeof e.filter&&("_view"===e.filter?e.view=ue(e.view):e.filter=ue(e.filter))}function Ct(e,t){return t.filter&&"string"==typeof t.filter&&!t.doc_ids&&!ae(e.db)}function Ot(e,t){var n=t.complete;if("_view"===t.filter){if(!t.view||"string"!=typeof t.view){var r=ne(G,"`view` filter parameter not found or invalid.");return n(r)}var i=ce(t.view);e.db.get("_design/"+i[0],(function(r,o){if(e.isCancelled)return n(null,{status:"cancelled"});if(r)return n(re(r));var s=o&&o.views&&o.views[i[1]]&&o.views[i[1]].map;if(!s)return n(ne(W,o.views?"missing json key: "+i[1]:"missing json key: views"));t.filter=fe(["return function(doc) {",' "use strict";'," var emitted = false;"," var emit = function (a, b) {"," emitted = true;"," };"," var view = "+s+";"," view(doc);"," if (emitted) {"," return true;"," }","};"].join("\n"),{}),e.doChanges(t)}))}else if(t.selector)t.filter=function(e){return function(e,t){if("object"!=typeof t)throw new Error("Selector error: expected a JSON object");var n=bt([{doc:e}],{selector:t=dt(t)},Object.keys(t));return n&&1===n.length}(e,t.selector)},e.doChanges(t);else{var o=ce(t.filter);e.db.get("_design/"+o[0],(function(r,i){if(e.isCancelled)return n(null,{status:"cancelled"});if(r)return n(re(r));var s=i&&i.filters&&i.filters[o[1]];if(!s)return n(ne(W,i&&i.filters?"missing json key: "+o[1]:"missing json key: filters"));t.filter=fe('"use strict";\nreturn '+s+";",{}),e.doChanges(t)}))}}function Pt(e){return e.reduce((function(e,t){return e[t]=!0,e}),{})}tt.plugin((function(e){e._changesFilterPlugin={validate:Dt,normalize:St,shouldFilter:Ct,filter:Ot}})),tt.version="7.2.2";var Ft=Pt(["_id","_rev","_attachments","_deleted","_revisions","_revs_info","_conflicts","_deleted_conflicts","_local_seq","_rev_tree","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats","_removed"]),It=Pt(["_attachments","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats"]);function Tt(e){if(!/^\d+-/.test(e))return ne(ee);var t=e.indexOf("-"),n=e.substring(0,t),r=e.substring(t+1);return{prefix:parseInt(n,10),id:r}}function Rt(e,t,n){var r,i,o;n||(n={deterministic_revs:!0});var s={status:"available"};if(e._deleted&&(s.deleted=!0),t)if(e._id||(e._id=Pe()),i=Oe(e,n.deterministic_revs),e._rev){if((o=Tt(e._rev)).error)return o;e._rev_tree=[{pos:o.prefix,ids:[o.id,{status:"missing"},[[i,s,[]]]]}],r=o.prefix+1}else e._rev_tree=[{pos:1,ids:[i,s,[]]}],r=1;else if(e._revisions&&(e._rev_tree=function(e,t){for(var n=e.start-e.ids.length+1,r=e.ids,i=[r[0],t,[]],o=1,s=r.length;o<s;o++)i=[r[o],{status:"missing"},[i]];return[{pos:n,ids:i}]}(e._revisions,s),r=e._revisions.start,i=e._revisions.ids[0]),!e._rev_tree){if((o=Tt(e._rev)).error)return o;r=o.prefix,i=o.id,e._rev_tree=[{pos:r,ids:[i,s,[]]}]}se(e._id),e._rev=r+"-"+i;var a={metadata:{},data:{}};for(var c in e)if(Object.prototype.hasOwnProperty.call(e,c)){var u="_"===c[0];if(u&&!Ft[c]){var l=ne(Y,c);throw l.message=Y.message+": "+c,l}u&&!It[c]?a.metadata[c.slice(1)]=e[c]:a.data[c]=e[c]}return a}function Bt(e,t,n){var r=function(e){try{return ge(e)}catch(e){return{error:ne(V,"Attachment is not a valid base64 string")}}}(e.data);if(r.error)return n(r.error);e.length=r.length,e.data="blob"===t?be(r,e.content_type):"base64"===t?_e(r):r,Se(r,(function(t){e.digest="md5-"+t,n()}))}function Mt(e,t,n){if(e.stub)return n();"string"==typeof e.data?Bt(e,t,n):function(e,t,n){Se(e.data,(function(r){e.digest="md5-"+r,e.length=e.data.size||e.data.length||0,"binary"===t?ke(e.data,(function(t){e.data=t,n()})):"base64"===t?Ee(e.data,(function(t){e.data=t,n()})):n()}))}(e,t,n)}function qt(e,t,n,r,i,o,s,a){if(function(e,t){for(var n,r=e.slice(),i=t.split("-"),o=parseInt(i[0],10),s=i[1];n=r.pop();){if(n.pos===o&&n.ids[0]===s)return!0;for(var a=n.ids[2],c=0,u=a.length;c<u;c++)r.push({pos:n.pos+1,ids:a[c]})}return!1}(t.rev_tree,n.metadata.rev)&&!a)return r[i]=n,o();var c=t.winningRev||Fe(t),u="deleted"in t?t.deleted:He(t,c),l="deleted"in n.metadata?n.metadata.deleted:He(n.metadata),h=/^1-/.test(n.metadata.rev);if(u&&!l&&a&&h){var d=n.data;d._rev=c,d._id=n.metadata.id,n=Rt(d,a)}var p=ze(t.rev_tree,n.metadata.rev_tree[0],e);if(a&&(u&&l&&"new_leaf"!==p.conflicts||!u&&"new_leaf"!==p.conflicts||u&&!l&&"new_branch"===p.conflicts)){var f=ne($);return r[i]=f,o()}var m=n.metadata.rev;n.metadata.rev_tree=p.tree,n.stemmedRevs=p.stemmedRevs||[],t.rev_map&&(n.metadata.rev_map=t.rev_map);var g=Fe(n.metadata),_=He(n.metadata,g),y=u===_?0:u<_?-1:1;s(n,g,_,m===g?_:He(n.metadata,m),!0,y,i,o)}function Lt(e,t,n,r,o,s,a,c,u){e=e||1e3;var l=c.new_edits,h=new i,d=0,p=t.length;function f(){++d===p&&u&&u()}t.forEach((function(e,t){if(e._id&&Ke(e._id)){var r=e._deleted?"_removeLocal":"_putLocal";n[r](e,{ctx:o},(function(e,n){s[t]=e||n,f()}))}else{var i=e.metadata.id;h.has(i)?(p--,h.get(i).push([e,t])):h.set(i,[[e,t]])}})),h.forEach((function(t,n){var i=0;function o(){++i<t.length?u():f()}function u(){var u=t[i],h=u[0],d=u[1];if(r.has(n))qt(e,r.get(n),h,s,d,o,a,l);else{var p=ze([],h.metadata.rev_tree[0],e);h.metadata.rev_tree=p.tree,h.stemmedRevs=p.stemmedRevs||[],function(e,t,n){var r=Fe(e.metadata),i=He(e.metadata,r);if("was_delete"in c&&i)return s[t]=ne(W,"deleted"),n();if(l&&function(e){return"missing"===e.metadata.rev_tree[0].ids[1].status}(e)){var o=ne($);return s[t]=o,n()}a(e,r,i,i,!1,i?0:1,t,n)}(h,d,o)}}u()}))}var Nt="document-store",Ut="meta-store";function Wt(e){try{return JSON.stringify(e)}catch(t){return h.a.stringify(e)}}function $t(e){return function(t){var n="unknown_error";t.target&&t.target.error&&(n=t.target.error.name||t.target.error.message),e(ne(Z,n,t.type))}}function zt(e,t,n){return{data:Wt(e),winningRev:t,deletedOrLocal:n?"1":"0",seq:e.seq,id:e.id}}function Jt(e){if(!e)return null;var t=function(e){try{return JSON.parse(e)}catch(t){return h.a.parse(e)}}(e.data);return t.winningRev=e.winningRev,t.deleted="1"===e.deletedOrLocal,t.seq=e.seq,t}function Ht(e){if(!e)return e;var t=e._doc_id_rev.lastIndexOf(":");return e._id=e._doc_id_rev.substring(0,t-1),e._rev=e._doc_id_rev.substring(t+1),delete e._doc_id_rev,e}function Kt(e,t,n,r){n?r(e?"string"!=typeof e?e:we(e,t):ye([""],{type:t})):e?"string"!=typeof e?xe(e,(function(e){r(_e(e))})):r(e):r("")}function Vt(e,t,n,r){var i=Object.keys(e._attachments||{});if(!i.length)return r&&r();var o=0;function s(){++o===i.length&&r&&r()}i.forEach((function(r){t.attachments&&t.include_docs?function(e,t){var r=e._attachments[t],i=r.digest;n.objectStore("attach-store").get(i).onsuccess=function(e){r.body=e.target.result.body,s()}}(e,r):(e._attachments[r].stub=!0,s())}))}function Xt(e,t){return Promise.all(e.map((function(e){if(e.doc&&e.doc._attachments){var n=Object.keys(e.doc._attachments);return Promise.all(n.map((function(n){var r=e.doc._attachments[n];if("body"in r){var i=r.body,o=r.content_type;return new Promise((function(s){Kt(i,o,t,(function(t){e.doc._attachments[n]=L(C(r,["digest","content_type"]),{data:t}),s()}))}))}})))}})))}function Yt(e,t,n){var r=[],i=n.objectStore("by-sequence"),o=n.objectStore("attach-store"),s=n.objectStore("attach-seq-store"),a=e.length;function c(){--a||function(){if(!r.length)return;r.forEach((function(e){s.index("digestSeq").count(IDBKeyRange.bound(e+"::",e+"::",!1,!1)).onsuccess=function(t){t.target.result||o.delete(e)}}))}()}e.forEach((function(e){var n=i.index("_doc_id_rev"),o=t+"::"+e;n.getKey(o).onsuccess=function(e){var t=e.target.result;if("number"!=typeof t)return c();i.delete(t),s.index("seq").openCursor(IDBKeyRange.only(t)).onsuccess=function(e){var t=e.target.result;if(t){var n=t.value.digestSeq.split("::")[0];r.push(n),s.delete(t.primaryKey),t.continue()}else c()}}}))}function Gt(e,t,n){try{return{txn:e.transaction(t,n)}}catch(e){return{error:e}}}var Qt=new R;function Zt(e,t,n,r,o,s){for(var a,c,u,l,h,d,p,f,m=t.docs,g=0,_=m.length;g<_;g++){var y=m[g];y._id&&Ke(y._id)||(y=m[g]=Rt(y,n.new_edits,e)).error&&!p&&(p=y)}if(p)return s(p);var v=!1,b=0,w=new Array(m.length),x=new i,k=!1,E=r._meta.blobSupport?"blob":"base64";function j(){v=!0,A()}function A(){f&&v&&(f.docCount+=b,d.put(f))}function D(){k||(Qt.notify(r._meta.name),s(null,w))}function S(e,t,n,r,i,o,s,a){e.metadata.winningRev=t,e.metadata.deleted=n;var c=e.data;if(c._id=e.metadata.id,c._rev=e.metadata.rev,r&&(c._deleted=!0),c._attachments&&Object.keys(c._attachments).length)return function(e,t,n,r,i,o){var s=e.data,a=0,c=Object.keys(s._attachments);function u(){a===c.length&&C(e,t,n,r,i,o)}function h(){a++,u()}c.forEach((function(n){var r=e.data._attachments[n];if(r.stub)a++,u();else{var i=r.data;delete r.data,r.revpos=parseInt(t,10),function(e,t,n){l.count(e).onsuccess=function(r){if(r.target.result)return n();var i={digest:e,body:t};l.put(i).onsuccess=n}}(r.digest,i,h)}}))}(e,t,n,i,s,a);b+=o,A(),C(e,t,n,i,s,a)}function C(e,t,n,i,o,s){var l=e.data,d=e.metadata;function p(o){var s=e.stemmedRevs||[];i&&r.auto_compaction&&(s=s.concat(function(e){var t=[];return Ie(e.rev_tree,(function(e,n,r,i,o){"available"!==o.status||e||(t.push(n+"-"+r),o.status="missing")})),t}(e.metadata))),s&&s.length&&Yt(s,e.metadata.id,a),d.seq=o.target.result;var u=zt(d,t,n);c.put(u).onsuccess=f}function f(){w[o]={ok:!0,id:d.id,rev:d.rev},x.set(e.metadata.id,e.metadata),function(e,t,n){var r=0,i=Object.keys(e.data._attachments||{});if(!i.length)return n();function o(){++r===i.length&&n()}function s(n){var r=e.data._attachments[n].digest,i=h.put({seq:t,digestSeq:r+"::"+t});i.onsuccess=o,i.onerror=function(e){e.preventDefault(),e.stopPropagation(),o()}}for(var a=0;a<i.length;a++)s(i[a])}(e,d.seq,s)}l._doc_id_rev=d.id+"::"+d.rev,delete l._id,delete l._rev;var m=u.put(l);m.onsuccess=p,m.onerror=function(e){e.preventDefault(),e.stopPropagation(),u.index("_doc_id_rev").getKey(l._doc_id_rev).onsuccess=function(e){u.put(l,e.target.result).onsuccess=p}}}!function(e,t,n){if(!e.length)return n();var r,i=0;function o(){i++,e.length===i&&(r?n(r):n())}e.forEach((function(e){var n=e.data&&e.data._attachments?Object.keys(e.data._attachments):[],i=0;if(!n.length)return o();function s(e){r=e,++i===n.length&&o()}for(var a in e.data._attachments)e.data._attachments.hasOwnProperty(a)&&Mt(e.data._attachments[a],t,s)}))}(m,E,(function(t){if(t)return s(t);!function(){var t=Gt(o,[Nt,"by-sequence","attach-store","local-store","attach-seq-store",Ut],"readwrite");if(t.error)return s(t.error);(a=t.txn).onabort=$t(s),a.ontimeout=$t(s),a.oncomplete=D,c=a.objectStore(Nt),u=a.objectStore("by-sequence"),l=a.objectStore("attach-store"),h=a.objectStore("attach-seq-store"),(d=a.objectStore(Ut)).get(Ut).onsuccess=function(e){f=e.target.result,A()},function(e){var t=[];if(m.forEach((function(e){e.data&&e.data._attachments&&Object.keys(e.data._attachments).forEach((function(n){var r=e.data._attachments[n];r.stub&&t.push(r.digest)}))})),!t.length)return e();var n,r=0;t.forEach((function(i){!function(e,t){l.get(e).onsuccess=function(n){if(n.target.result)t();else{var r=ne(te,"unknown stub attachment with digest "+e);r.status=412,t(r)}}}(i,(function(i){i&&!n&&(n=i),++r===t.length&&e(n)}))}))}((function(t){if(t)return k=!0,s(t);!function(){if(!m.length)return;var t=0;function i(){++t===m.length&&Lt(e.revs_limit,m,r,x,a,w,S,n,j)}function o(e){var t=Jt(e.target.result);t&&x.set(t.id,t),i()}for(var s=0,u=m.length;s<u;s++){var l=m[s];if(l._id&&Ke(l._id))i();else c.get(l.metadata.id).onsuccess=o}}()}))}()}))}function en(e,t,n,r,i){var o,s,a;function c(e){s=e.target.result,o&&i(o,s,a)}function u(e){o=e.target.result,s&&i(o,s,a)}function l(e){var t=e.target.result;if(!t)return i();i([t.key],[t.value],t)}-1===r&&(r=1e3),"function"==typeof e.getAll&&"function"==typeof e.getAllKeys&&r>1&&!n?(a={continue:function(){if(!o.length)return i();var n,a=o[o.length-1];if(t&&t.upper)try{n=IDBKeyRange.bound(a,t.upper,!0,t.upperOpen)}catch(e){if("DataError"===e.name&&0===e.code)return i()}else n=IDBKeyRange.lowerBound(a,!0);t=n,o=null,s=null,e.getAll(t,r).onsuccess=c,e.getAllKeys(t,r).onsuccess=u}},e.getAll(t,r).onsuccess=c,e.getAllKeys(t,r).onsuccess=u):n?e.openCursor(t,"prev").onsuccess=l:e.openCursor(t).onsuccess=l}function tn(e,t,n){var r,i,o="startkey"in e&&e.startkey,s="endkey"in e&&e.endkey,a="key"in e&&e.key,c="keys"in e&&e.keys,u=e.skip||0,l="number"==typeof e.limit?e.limit:-1,h=!1!==e.inclusive_end;if(!c&&(i=(r=function(e,t,n,r,i){try{if(e&&t)return i?IDBKeyRange.bound(t,e,!n,!1):IDBKeyRange.bound(e,t,!1,!n);if(e)return i?IDBKeyRange.upperBound(e):IDBKeyRange.lowerBound(e);if(t)return i?IDBKeyRange.lowerBound(t,!n):IDBKeyRange.upperBound(t,!n);if(r)return IDBKeyRange.only(r)}catch(e){return{error:e}}return null}(o,s,h,a,e.descending))&&r.error)&&("DataError"!==i.name||0!==i.code))return n(ne(Z,i.name,i.message));var d=[Nt,"by-sequence",Ut];e.attachments&&d.push("attach-store");var p=Gt(t,d,"readonly");if(p.error)return n(p.error);var f=p.txn;f.oncomplete=function(){e.attachments?Xt(x,e.binary).then(A):A()},f.onabort=$t(n);var m,g,_,y=f.objectStore(Nt),v=f.objectStore("by-sequence"),b=f.objectStore(Ut),w=v.index("_doc_id_rev"),x=[];function k(t,n){var r={id:n.id,key:n.id,value:{rev:t}};n.deleted?c&&(x.push(r),r.value.deleted=!0,r.doc=null):u--<=0&&(x.push(r),e.include_docs&&function(t,n,r){var i=t.id+"::"+r;w.get(i).onsuccess=function(r){if(n.doc=Ht(r.target.result)||{},e.conflicts){var i=Be(t);i.length&&(n.doc._conflicts=i)}Vt(n.doc,e,f)}}(n,r,t))}function E(e){for(var t=0,n=e.length;t<n&&x.length!==l;t++){var r=e[t];if(r.error&&c)x.push(r);else{var i=Jt(r);k(i.winningRev,i)}}}function j(e,t,n){n&&(E(t),x.length<l&&n.continue())}function A(){var t={total_rows:m,offset:e.skip,rows:x};e.update_seq&&void 0!==g&&(t.update_seq=g),n(null,t)}return b.get(Ut).onsuccess=function(e){m=e.target.result.docCount},e.update_seq&&(_=function(e){e.target.result&&e.target.result.length>0&&(g=e.target.result[0])},v.openCursor(null,"prev").onsuccess=function(e){var t=e.target.result,n=void 0;return t&&t.key&&(n=t.key),_({target:{result:[n]}})}),i||0===l?void 0:c?function(e,t,n){var r=new Array(e.length),i=0;e.forEach((function(o,s){t.get(o).onsuccess=function(t){t.target.result?r[s]=t.target.result:r[s]={key:o,error:"not_found"},++i===e.length&&n(e,r,{})}}))}(e.keys,y,j):-1===l?function(e,t,n){if("function"!=typeof e.getAll){var r=[];e.openCursor(t).onsuccess=function(e){var t=e.target.result;t?(r.push(t.value),t.continue()):n({target:{result:r}})}}else e.getAll(t).onsuccess=n}(y,r,(function(t){var n=t.target.result;e.descending&&(n=n.reverse()),E(n)})):void en(y,r,e.descending,l+u,j)}var nn=!1,rn=[];function on(){!nn&&rn.length&&(nn=!0,rn.shift()())}function sn(e,t,n,o){if((e=j(e)).continuous){var s=n+":"+Pe();return Qt.addListener(n,s,t,e),Qt.notify(n),{cancel:function(){Qt.removeListener(n,s)}}}var a=e.doc_ids&&new r(e.doc_ids);e.since=e.since||0;var c=e.since,u="limit"in e?e.limit:-1;0===u&&(u=1);var l,h,d,p,f=[],m=0,g=ie(e),_=new i;function y(e,t,n,r){if(n.seq!==t)return r();if(n.winningRev===e._rev)return r(n,e);var i=e._id+"::"+n.winningRev;p.get(i).onsuccess=function(e){r(n,Ht(e.target.result))}}function v(){e.complete(null,{results:f,last_seq:c})}var b=[Nt,"by-sequence"];e.attachments&&b.push("attach-store");var w=Gt(o,b,"readonly");if(w.error)return e.complete(w.error);(l=w.txn).onabort=$t(e.complete),l.oncomplete=function(){!e.continuous&&e.attachments?Xt(f).then(v):v()},h=l.objectStore("by-sequence"),d=l.objectStore(Nt),p=h.index("_doc_id_rev"),en(h,e.since&&!e.descending?IDBKeyRange.lowerBound(e.since,!0):null,e.descending,u,(function(t,n,r){if(r&&t.length){var i=new Array(t.length),o=new Array(t.length),s=0;n.forEach((function(n,c){!function(e,t,n){if(a&&!a.has(e._id))return n();var r=_.get(e._id);if(r)return y(e,t,r,n);d.get(e._id).onsuccess=function(i){r=Jt(i.target.result),_.set(e._id,r),y(e,t,r,n)}}(Ht(n),t[c],(function(n,a){o[c]=n,i[c]=a,++s===t.length&&function(){for(var t=[],n=0,s=i.length;n<s&&m!==u;n++){var a=i[n];if(a){var c=o[n];t.push(h(c,a))}}Promise.all(t).then((function(t){for(var n=0,r=t.length;n<r;n++)t[n]&&e.onChange(t[n])})).catch(e.complete),m!==u&&r.continue()}()}))}))}function h(t,n){var r=e.processChange(n,t,e);c=r.seq=t.seq;var i=g(r);return"object"==typeof i?Promise.reject(i):i?(m++,e.return_docs&&f.push(r),e.attachments&&e.include_docs?new Promise((function(t){Vt(n,e,l,(function(){Xt([r],e.binary).then((function(){t(r)}))}))})):Promise.resolve(r)):Promise.resolve()}}))}var an,cn=new i,un=new i;function ln(e,t){var n=this;!function(e,t,n){rn.push((function(){e((function(e,r){!function(e,t,n,r){try{e(t,n)}catch(t){r.emit("error",t)}}(t,e,r,n),nn=!1,s()((function(){on()}))}))})),on()}((function(t){!function(e,t,n){var r=t.name,i=null;function o(e,t){var n=e.objectStore(Nt);n.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),n.openCursor().onsuccess=function(e){var r=e.target.result;if(r){var i=r.value,o=He(i);i.deletedOrLocal=o?"1":"0",n.put(i),r.continue()}else t()}}function a(e,t){var n=e.objectStore("local-store"),r=e.objectStore(Nt),i=e.objectStore("by-sequence");r.openCursor().onsuccess=function(e){var o=e.target.result;if(o){var s=o.value,a=s.id,c=Ke(a),u=Fe(s);if(c){var l=a+"::"+u,h=a+"::",d=a+"::~",p=i.index("_doc_id_rev"),f=IDBKeyRange.bound(h,d,!1,!1),m=p.openCursor(f);m.onsuccess=function(e){if(m=e.target.result){var t=m.value;t._doc_id_rev===l&&n.put(t),i.delete(m.primaryKey),m.continue()}else r.delete(o.primaryKey),o.continue()}}else o.continue()}else t&&t()}}function c(e,t){var n=e.objectStore("by-sequence"),r=e.objectStore("attach-store"),i=e.objectStore("attach-seq-store");r.count().onsuccess=function(e){if(!e.target.result)return t();n.openCursor().onsuccess=function(e){var n=e.target.result;if(!n)return t();for(var r=n.value,o=n.primaryKey,s=Object.keys(r._attachments||{}),a={},c=0;c<s.length;c++){a[r._attachments[s[c]].digest]=!0}var u=Object.keys(a);for(c=0;c<u.length;c++){var l=u[c];i.put({seq:o,digestSeq:l+"::"+o})}n.continue()}}}function u(e){var t=e.objectStore("by-sequence"),n=e.objectStore(Nt);n.openCursor().onsuccess=function(e){var r=e.target.result;if(r){var i,o=(i=r.value).data?Jt(i):(i.deleted="1"===i.deletedOrLocal,i);if(o.winningRev=o.winningRev||Fe(o),o.seq)return s();!function(){var e=o.id+"::",n=o.id+"::",r=t.index("_doc_id_rev").openCursor(IDBKeyRange.bound(e,n)),i=0;r.onsuccess=function(e){var t=e.target.result;if(!t)return o.seq=i,s();var n=t.primaryKey;n>i&&(i=n),t.continue()}}()}function s(){var e=zt(o,o.winningRev,o.deleted);n.put(e).onsuccess=function(){r.continue()}}}}e._meta=null,e._remote=!1,e.type=function(){return"idb"},e._id=D((function(t){t(null,e._meta.instanceId)})),e._bulkDocs=function(n,r,o){Zt(t,n,r,e,i,o)},e._get=function(e,t,n){var r,o,s,a=t.ctx;if(!a){var c=Gt(i,[Nt,"by-sequence","attach-store"],"readonly");if(c.error)return n(c.error);a=c.txn}function u(){n(s,{doc:r,metadata:o,ctx:a})}a.objectStore(Nt).get(e).onsuccess=function(e){if(!(o=Jt(e.target.result)))return s=ne(W,"missing"),u();var n;if(t.rev)n=t.latest?function(e,t){for(var n,r=t.rev_tree.slice();n=r.pop();){var i=n.pos,o=n.ids,s=o[0],a=o[1],c=o[2],u=0===c.length,l=n.history?n.history.slice():[];if(l.push({id:s,pos:i,opts:a}),u)for(var h=0,d=l.length;h<d;h++){var p=l[h];if(p.pos+"-"+p.id===e)return i+"-"+s}for(var f=0,m=c.length;f<m;f++)r.push({pos:i+1,ids:c[f],history:l})}throw new Error("Unable to resolve latest revision for id "+t.id+", rev "+e)}(t.rev,o):t.rev;else if(n=o.winningRev,He(o))return s=ne(W,"deleted"),u();var i=a.objectStore("by-sequence"),c=o.id+"::"+n;i.index("_doc_id_rev").get(c).onsuccess=function(e){if((r=e.target.result)&&(r=Ht(r)),!r)return s=ne(W,"missing"),u();u()}}},e._getAttachment=function(e,t,n,r,o){var s;if(r.ctx)s=r.ctx;else{var a=Gt(i,[Nt,"by-sequence","attach-store"],"readonly");if(a.error)return o(a.error);s=a.txn}var c=n.digest,u=n.content_type;s.objectStore("attach-store").get(c).onsuccess=function(e){Kt(e.target.result.body,u,r.binary,(function(e){o(null,e)}))}},e._info=function(t){var n,r,o=Gt(i,[Ut,"by-sequence"],"readonly");if(o.error)return t(o.error);var s=o.txn;s.objectStore(Ut).get(Ut).onsuccess=function(e){r=e.target.result.docCount},s.objectStore("by-sequence").openCursor(null,"prev").onsuccess=function(e){var t=e.target.result;n=t?t.key:0},s.oncomplete=function(){t(null,{doc_count:r,update_seq:n,idb_attachment_format:e._meta.blobSupport?"binary":"base64"})}},e._allDocs=function(e,t){tn(e,i,t)},e._changes=function(t){return sn(t,e,r,i)},e._close=function(e){i.close(),cn.delete(r),e()},e._getRevisionTree=function(e,t){var n=Gt(i,[Nt],"readonly");if(n.error)return t(n.error);n.txn.objectStore(Nt).get(e).onsuccess=function(e){var n=Jt(e.target.result);n?t(null,n.rev_tree):t(ne(W))}},e._doCompaction=function(e,t,n){var r=Gt(i,[Nt,"by-sequence","attach-store","attach-seq-store"],"readwrite");if(r.error)return n(r.error);var o=r.txn;o.objectStore(Nt).get(e).onsuccess=function(n){var r=Jt(n.target.result);Ie(r.rev_tree,(function(e,n,r,i,o){var s=n+"-"+r;-1!==t.indexOf(s)&&(o.status="missing")})),Yt(t,e,o);var i=r.winningRev,s=r.deleted;o.objectStore(Nt).put(zt(r,i,s))},o.onabort=$t(n),o.oncomplete=function(){n()}},e._getLocal=function(e,t){var n=Gt(i,["local-store"],"readonly");if(n.error)return t(n.error);var r=n.txn.objectStore("local-store").get(e);r.onerror=$t(t),r.onsuccess=function(e){var n=e.target.result;n?(delete n._doc_id_rev,t(null,n)):t(ne(W))}},e._putLocal=function(e,t,n){"function"==typeof t&&(n=t,t={}),delete e._revisions;var r=e._rev,o=e._id;e._rev=r?"0-"+(parseInt(r.split("-")[1],10)+1):"0-1";var s,a=t.ctx;if(!a){var c=Gt(i,["local-store"],"readwrite");if(c.error)return n(c.error);(a=c.txn).onerror=$t(n),a.oncomplete=function(){s&&n(null,s)}}var u,l=a.objectStore("local-store");r?(u=l.get(o)).onsuccess=function(i){var o=i.target.result;o&&o._rev===r?l.put(e).onsuccess=function(){s={ok:!0,id:e._id,rev:e._rev},t.ctx&&n(null,s)}:n(ne($))}:((u=l.add(e)).onerror=function(e){n(ne($)),e.preventDefault(),e.stopPropagation()},u.onsuccess=function(){s={ok:!0,id:e._id,rev:e._rev},t.ctx&&n(null,s)})},e._removeLocal=function(e,t,n){"function"==typeof t&&(n=t,t={});var r,o=t.ctx;if(!o){var s=Gt(i,["local-store"],"readwrite");if(s.error)return n(s.error);(o=s.txn).oncomplete=function(){r&&n(null,r)}}var a=e._id,c=o.objectStore("local-store"),u=c.get(a);u.onerror=$t(n),u.onsuccess=function(i){var o=i.target.result;o&&o._rev===e._rev?(c.delete(a),r={ok:!0,id:a,rev:"0-0"},t.ctx&&n(null,r)):n(ne(W))}},e._destroy=function(e,t){Qt.removeAllListeners(r);var n=un.get(r);n&&n.result&&(n.result.close(),cn.delete(r));var i=indexedDB.deleteDatabase(r);i.onsuccess=function(){un.delete(r),T()&&r in localStorage&&delete localStorage[r],t(null,{ok:!0})},i.onerror=$t(t)};var l=cn.get(r);if(l)return i=l.idb,e._meta=l.global,s()((function(){n(null,e)}));var h=indexedDB.open(r,5);un.set(r,h),h.onupgradeneeded=function(e){var t=e.target.result;if(e.oldVersion<1)return function(e){var t=e.createObjectStore(Nt,{keyPath:"id"});e.createObjectStore("by-sequence",{autoIncrement:!0}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0}),e.createObjectStore("attach-store",{keyPath:"digest"}),e.createObjectStore(Ut,{keyPath:"id",autoIncrement:!1}),e.createObjectStore("detect-blob-support"),t.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),e.createObjectStore("local-store",{keyPath:"_id"});var n=e.createObjectStore("attach-seq-store",{autoIncrement:!0});n.createIndex("seq","seq"),n.createIndex("digestSeq","digestSeq",{unique:!0})}(t);var n=e.currentTarget.transaction;e.oldVersion<3&&function(e){e.createObjectStore("local-store",{keyPath:"_id"}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0})}(t),e.oldVersion<4&&function(e){var t=e.createObjectStore("attach-seq-store",{autoIncrement:!0});t.createIndex("seq","seq"),t.createIndex("digestSeq","digestSeq",{unique:!0})}(t);var r=[o,a,c,u],i=e.oldVersion;!function e(){var t=r[i-1];i++,t&&t(n,e)}()},h.onsuccess=function(t){(i=t.target.result).onversionchange=function(){i.close(),cn.delete(r)},i.onabort=function(e){B("error","Database has a global failure",e.target.error),i.close(),cn.delete(r)};var o,s,a,c,u=i.transaction([Ut,"detect-blob-support",Nt],"readwrite"),l=!1;function h(){void 0!==a&&l&&(e._meta={name:r,instanceId:c,blobSupport:a},cn.set(r,{idb:i,global:e._meta}),n(null,e))}function d(){if(void 0!==s&&void 0!==o){var e=r+"_id";e in o?c=o[e]:o[e]=c=Pe(),o.docCount=s,u.objectStore(Ut).put(o)}}u.objectStore(Ut).get(Ut).onsuccess=function(e){o=e.target.result||{id:Ut},d()},function(e,t){e.objectStore(Nt).index("deletedOrLocal").count(IDBKeyRange.only("0")).onsuccess=function(e){t(e.target.result)}}(u,(function(e){s=e,d()})),an||(an=function(e){return new Promise((function(t){var n=ye([""]),r=e.objectStore("detect-blob-support").put(n,"key");r.onsuccess=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)},r.onerror=e.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)}})).catch((function(){return!1}))}(u)),an.then((function(e){a=e,h()})),u.oncomplete=function(){l=!0,h()},u.onabort=$t(n)},h.onerror=function(e){var t=e.target.error&&e.target.error.message;t?-1!==t.indexOf("stored database is a higher version")&&(t=new Error('This DB was created with the newer "indexeddb" adapter, but you are trying to open it with the older "idb" adapter')):t="Failed to open indexedDB, are you in private browsing mode?",B("error",t),n(ne(Z,t))}}(n,e,t)}),t,n.constructor)}ln.valid=function(){try{return"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}};var hn={};function dn(e){var t=e.doc||e.ok,n=t&&t._attachments;n&&Object.keys(n).forEach((function(e){var t=n[e];t.data=we(t.data,t.content_type)}))}function pn(e){return/^_design/.test(e)?"_design/"+encodeURIComponent(e.slice(8)):/^_local/.test(e)?"_local/"+encodeURIComponent(e.slice(7)):encodeURIComponent(e)}function fn(e){return e._attachments&&Object.keys(e._attachments)?Promise.all(Object.keys(e._attachments).map((function(t){var n=e._attachments[t];if(n.data&&"string"!=typeof n.data)return new Promise((function(e){Ee(n.data,e)})).then((function(e){n.data=e}))}))):Promise.resolve()}function mn(e,t){if(function(e){if(!e.prefix)return!1;var t=pe(e.prefix).protocol;return"http"===t||"https"===t}(t)){var n=t.name.substr(t.prefix.length);e=t.prefix.replace(/\/?$/,"/")+encodeURIComponent(n)}var r=pe(e);(r.user||r.password)&&(r.auth={username:r.user,password:r.password});var i=r.path.replace(/(^\/|\/$)/g,"").split("/");return r.db=i.pop(),-1===r.db.indexOf("%")&&(r.db=encodeURIComponent(r.db)),r.path=i.join("/"),r}function gn(e,t){return _n(e,e.db+"/"+t)}function _n(e,t){var n=e.path?"/":"";return e.protocol+"://"+e.host+(e.port?":"+e.port:"")+"/"+e.path+n+t}function yn(e){return"?"+Object.keys(e).map((function(t){return t+"="+encodeURIComponent(e[t])})).join("&")}function vn(t,n){var r=this,i=mn(t.name,t),o=gn(i,"");t=j(t);var a,c=function(e,n){if((n=n||{}).headers=n.headers||new it,n.credentials="include",t.auth||i.auth){var r=t.auth||i.auth,o=r.username+":"+r.password,s=_e(unescape(encodeURIComponent(o)));n.headers.set("Authorization","Basic "+s)}var a=t.headers||{};return Object.keys(a).forEach((function(e){n.headers.append(e,a[e])})),function(e){var t="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",n=-1!==t.indexOf("msie"),r=-1!==t.indexOf("trident"),i=-1!==t.indexOf("edge"),o=!("method"in e)||"GET"===e.method;return(n||r||i)&&o}(n)&&(e+=(-1===e.indexOf("?")?"?":"&")+"_nonce="+Date.now()),(t.fetch||rt)(e,n)};function u(e,t){return S(e,p()((function(e){h().then((function(){return t.apply(this,e)})).catch((function(t){e.pop()(t)}))}))).bind(r)}function l(e,t,n){var r={};return(t=t||{}).headers=t.headers||new it,t.headers.get("Content-Type")||t.headers.set("Content-Type","application/json"),t.headers.get("Accept")||t.headers.set("Accept","application/json"),c(e,t).then((function(e){return r.ok=e.ok,r.status=e.status,e.json()})).then((function(e){if(r.data=e,!r.ok){r.data.status=r.status;var t=re(r.data);if(n)return n(t);throw t}if(Array.isArray(r.data)&&(r.data=r.data.map((function(e){return e.error||e.missing?re(e):e}))),!n)return r;n(null,r.data)}))}function h(){return t.skip_setup?Promise.resolve():a||((a=l(o).catch((function(e){return e&&e.status&&404===e.status?(q(404,"PouchDB is just detecting if the remote exists."),l(o,{method:"PUT"})):Promise.reject(e)})).catch((function(e){return!(!e||!e.status||412!==e.status)||Promise.reject(e)}))).catch((function(){a=null})),a)}function d(e){return e.split("/").map(encodeURIComponent).join("/")}s()((function(){n(null,r)})),r._remote=!0,r.type=function(){return"http"},r.id=u("id",(function(e){c(_n(i,"")).then((function(e){return e.json()})).catch((function(){return{}})).then((function(t){var n=t&&t.uuid?t.uuid+i.db:gn(i,"");e(null,n)}))})),r.compact=u("compact",(function(e,t){"function"==typeof e&&(t=e,e={}),e=j(e),l(gn(i,"_compact"),{method:"POST"}).then((function(){!function n(){r.info((function(r,i){i&&!i.compact_running?t(null,{ok:!0}):setTimeout(n,e.interval||200)}))}()}))})),r.bulkGet=S("bulkGet",(function(e,t){var n=this;function r(t){var n={};e.revs&&(n.revs=!0),e.attachments&&(n.attachments=!0),e.latest&&(n.latest=!0),l(gn(i,"_bulk_get"+yn(n)),{method:"POST",body:JSON.stringify({docs:e.docs})}).then((function(n){e.attachments&&e.binary&&n.data.results.forEach((function(e){e.docs.forEach(dn)})),t(null,n.data)})).catch(t)}function o(){var r=Math.ceil(e.docs.length/50),i=0,o=new Array(r);function s(e){return function(n,s){o[e]=s.results,++i===r&&t(null,{results:oe(o)})}}for(var a=0;a<r;a++){var c=C(e,["revs","attachments","binary","latest"]);c.docs=e.docs.slice(50*a,Math.min(e.docs.length,50*(a+1))),I(n,c,s(a))}}var s=_n(i,""),a=hn[s];"boolean"!=typeof a?r((function(e,n){e?(hn[s]=!1,q(e.status,"PouchDB is just detecting if the remote supports the _bulk_get API."),o()):(hn[s]=!0,t(null,n))})):a?r(t):o()})),r._info=function(e){h().then((function(){return c(gn(i,""))})).then((function(e){return e.json()})).then((function(t){t.host=gn(i,""),e(null,t)})).catch(e)},r.fetch=function(e,t){return h().then((function(){var n="/"===e.substring(0,1)?_n(i,e.substring(1)):gn(i,e);return c(n,t)}))},r.get=u("get",(function(e,t,n){"function"==typeof t&&(n=t,t={});var r={};function o(e){var n=e._attachments,r=n&&Object.keys(n);if(n&&r.length)return function(e,t){return new Promise((function(n,r){var i,o=0,s=0,a=0,c=e.length;function u(){++a===c?i?r(i):n():d()}function l(){o--,u()}function h(e){o--,i=i||e,u()}function d(){for(;o<t&&s<c;)o++,e[s++]().then(l,h)}d()}))}(r.map((function(r){return function(){return function(r){var o=n[r],s=pn(e._id)+"/"+d(r)+"?rev="+e._rev;return c(gn(i,s)).then((function(e){return"buffer"in e?e.buffer():e.blob()})).then((function(e){if(t.binary){var n=Object.getOwnPropertyDescriptor(e.__proto__,"type");return n&&!n.set||(e.type=o.content_type),e}return new Promise((function(t){Ee(e,t)}))})).then((function(e){delete o.stub,delete o.length,o.data=e}))}(r)}})),5)}(t=j(t)).revs&&(r.revs=!0),t.revs_info&&(r.revs_info=!0),t.latest&&(r.latest=!0),t.open_revs&&("all"!==t.open_revs&&(t.open_revs=JSON.stringify(t.open_revs)),r.open_revs=t.open_revs),t.rev&&(r.rev=t.rev),t.conflicts&&(r.conflicts=t.conflicts),t.update_seq&&(r.update_seq=t.update_seq),e=pn(e),l(gn(i,e+yn(r))).then((function(e){return Promise.resolve().then((function(){if(t.attachments)return n=e.data,Array.isArray(n)?Promise.all(n.map((function(e){if(e.ok)return o(e.ok)}))):o(n);var n})).then((function(){n(null,e.data)}))})).catch((function(t){t.docId=e,n(t)}))})),r.remove=u("remove",(function(e,t,n,r){var o;"string"==typeof t?(o={_id:e,_rev:t},"function"==typeof n&&(r=n,n={})):(o=e,"function"==typeof t?(r=t,n={}):(r=n,n=t));var s=o._rev||n.rev;l(gn(i,pn(o._id))+"?rev="+s,{method:"DELETE"},r).catch(r)})),r.getAttachment=u("getAttachment",(function(t,n,r,o){"function"==typeof r&&(o=r,r={});var s,a=r.rev?"?rev="+r.rev:"",u=gn(i,pn(t))+"/"+d(n)+a;c(u,{method:"GET"}).then((function(t){if(s=t.headers.get("content-type"),t.ok)return void 0===e||e.browser||"function"!=typeof t.buffer?t.blob():t.buffer();throw t})).then((function(t){void 0===e||e.browser||(t.type=s),o(null,t)})).catch((function(e){o(e)}))})),r.removeAttachment=u("removeAttachment",(function(e,t,n,r){l(gn(i,pn(e)+"/"+d(t))+"?rev="+n,{method:"DELETE"},r).catch(r)})),r.putAttachment=u("putAttachment",(function(e,t,n,r,o,s){"function"==typeof o&&(s=o,o=r,r=n,n=null);var a=pn(e)+"/"+d(t),c=gn(i,a);if(n&&(c+="?rev="+n),"string"==typeof r){var u;try{u=ge(r)}catch(e){return s(ne(V,"Attachment is not a valid base64 string"))}r=u?be(u,o):""}l(c,{headers:new it({"Content-Type":o}),method:"PUT",body:r},s).catch(s)})),r._bulkDocs=function(e,t,n){e.new_edits=t.new_edits,h().then((function(){return Promise.all(e.docs.map(fn))})).then((function(){return l(gn(i,"_bulk_docs"),{method:"POST",body:JSON.stringify(e)},n)})).catch(n)},r._put=function(e,t,n){h().then((function(){return fn(e)})).then((function(){return l(gn(i,pn(e._id)),{method:"PUT",body:JSON.stringify(e)})})).then((function(e){n(null,e.data)})).catch((function(t){t.docId=e&&e._id,n(t)}))},r.allDocs=u("allDocs",(function(e,t){"function"==typeof e&&(t=e,e={});var n,r={},o="GET";(e=j(e)).conflicts&&(r.conflicts=!0),e.update_seq&&(r.update_seq=!0),e.descending&&(r.descending=!0),e.include_docs&&(r.include_docs=!0),e.attachments&&(r.attachments=!0),e.key&&(r.key=JSON.stringify(e.key)),e.start_key&&(e.startkey=e.start_key),e.startkey&&(r.startkey=JSON.stringify(e.startkey)),e.end_key&&(e.endkey=e.end_key),e.endkey&&(r.endkey=JSON.stringify(e.endkey)),void 0!==e.inclusive_end&&(r.inclusive_end=!!e.inclusive_end),void 0!==e.limit&&(r.limit=e.limit),void 0!==e.skip&&(r.skip=e.skip);var s=yn(r);void 0!==e.keys&&(o="POST",n={keys:e.keys}),l(gn(i,"_all_docs"+s),{method:o,body:JSON.stringify(n)}).then((function(n){e.include_docs&&e.attachments&&e.binary&&n.data.rows.forEach(dn),t(null,n.data)})).catch(t)})),r._changes=function(e){var t="batch_size"in e?e.batch_size:25;(e=j(e)).continuous&&!("heartbeat"in e)&&(e.heartbeat=1e4);var n="timeout"in e?e.timeout:3e4;"timeout"in e&&e.timeout&&n-e.timeout<5e3&&(n=e.timeout+5e3),"heartbeat"in e&&e.heartbeat&&n-e.heartbeat<5e3&&(n=e.heartbeat+5e3);var r={};"timeout"in e&&e.timeout&&(r.timeout=e.timeout);var o=void 0!==e.limit&&e.limit,a=o;if(e.style&&(r.style=e.style),(e.include_docs||e.filter&&"function"==typeof e.filter)&&(r.include_docs=!0),e.attachments&&(r.attachments=!0),e.continuous&&(r.feed="longpoll"),e.seq_interval&&(r.seq_interval=e.seq_interval),e.conflicts&&(r.conflicts=!0),e.descending&&(r.descending=!0),e.update_seq&&(r.update_seq=!0),"heartbeat"in e&&e.heartbeat&&(r.heartbeat=e.heartbeat),e.filter&&"string"==typeof e.filter&&(r.filter=e.filter),e.view&&"string"==typeof e.view&&(r.filter="_view",r.view=e.view),e.query_params&&"object"==typeof e.query_params)for(var c in e.query_params)e.query_params.hasOwnProperty(c)&&(r[c]=e.query_params[c]);var u,d="GET";e.doc_ids?(r.filter="_doc_ids",d="POST",u={doc_ids:e.doc_ids}):e.selector&&(r.filter="_selector",d="POST",u={selector:e.selector});var p,f=new nt,m=function(n,s){if(!e.aborted){r.since=n,"object"==typeof r.since&&(r.since=JSON.stringify(r.since)),e.descending?o&&(r.limit=a):r.limit=!o||a>t?t:a;var c=gn(i,"_changes"+yn(r)),m={signal:f.signal,method:d,body:JSON.stringify(u)};p=n,e.aborted||h().then((function(){return l(c,m,s)})).catch(s)}},g={results:[]},_=function(n,r){if(!e.aborted){var i=0;if(r&&r.results){i=r.results.length,g.last_seq=r.last_seq;var c=null,u=null;"number"==typeof r.pending&&(c=r.pending),"string"!=typeof g.last_seq&&"number"!=typeof g.last_seq||(u=g.last_seq);e.query_params,r.results=r.results.filter((function(t){a--;var n=ie(e)(t);return n&&(e.include_docs&&e.attachments&&e.binary&&dn(t),e.return_docs&&g.results.push(t),e.onChange(t,c,u)),n}))}else if(n)return e.aborted=!0,void e.complete(n);r&&r.last_seq&&(p=r.last_seq);var l=o&&a<=0||r&&i<t||e.descending;(!e.continuous||o&&a<=0)&&l?e.complete(null,g):s()((function(){m(p,_)}))}};return m(e.since||0,_),{cancel:function(){e.aborted=!0,f.abort()}}},r.revsDiff=u("revsDiff",(function(e,t,n){"function"==typeof t&&(n=t,t={}),l(gn(i,"_revs_diff"),{method:"POST",body:JSON.stringify(e)},n).catch(n)})),r._close=function(e){e()},r._destroy=function(e,t){l(gn(i,""),{method:"DELETE"}).then((function(e){t(null,e)})).catch((function(e){404===e.status?t(null,{ok:!0}):t(e)}))}}function bn(e){this.status=400,this.name="query_parse_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,bn)}catch(e){}}function wn(e){this.status=404,this.name="not_found",this.message=e,this.error=!0;try{Error.captureStackTrace(this,wn)}catch(e){}}function xn(e){this.status=500,this.name="invalid_value",this.message=e,this.error=!0;try{Error.captureStackTrace(this,xn)}catch(e){}}function kn(e,t){return t&&e.then((function(e){s()((function(){t(null,e)}))}),(function(e){s()((function(){t(e)}))})),e}function En(e,t){return function(){var n=arguments,r=this;return e.add((function(){return t.apply(r,n)}))}}function jn(e){var t=new r(e),n=new Array(t.size),i=-1;return t.forEach((function(e){n[++i]=e})),n}function An(e){var t=new Array(e.size),n=-1;return e.forEach((function(e,r){t[++n]=r})),t}function Dn(e){return new xn("builtin "+e+" function requires map values to be numbers or number arrays")}function Sn(e){for(var t=0,n=0,r=e.length;n<r;n++){var i=e[n];if("number"!=typeof i){if(!Array.isArray(i))throw Dn("_sum");t="number"==typeof t?[t]:t;for(var o=0,s=i.length;o<s;o++){var a=i[o];if("number"!=typeof a)throw Dn("_sum");void 0===t[o]?t.push(a):t[o]+=a}}else"number"==typeof t?t+=i:t[0]+=i}return t}vn.valid=function(){return!0},m()(bn,Error),m()(wn,Error),m()(xn,Error);var Cn=B.bind(null,"log"),On=Array.isArray,Pn=JSON.parse;function Fn(e,t){return fe("return ("+e.replace(/;\s*$/,"")+");",{emit:t,sum:Sn,log:Cn,isArray:On,toJSON:Pn})}function In(){this.promise=new Promise((function(e){e()}))}function Tn(e){if(!e)return"undefined";switch(typeof e){case"function":case"string":return e.toString();default:return JSON.stringify(e)}}function Rn(e,t,n,r,i,o){var s,a=function(e,t){return Tn(e)+Tn(t)+"undefined"}(n,r);if(!i&&(s=e._cachedViews=e._cachedViews||{})[a])return s[a];var c=e.info().then((function(c){var u=c.db_name+"-mrview-"+(i?"temp":Ce(a));return me(e,"_local/"+o,(function(e){e.views=e.views||{};var n=t;-1===n.indexOf("/")&&(n=t+"/"+t);var r=e.views[n]=e.views[n]||{};if(!r[u])return r[u]=!0,e})).then((function(){return e.registerDependentDatabase(u).then((function(t){var i=t.db;i.auto_compaction=!0;var o={name:u,db:i,sourceDB:e,adapter:e.adapter,mapFun:n,reduceFun:r};return o.db.get("_local/lastSeq").catch((function(e){if(404!==e.status)throw e})).then((function(e){return o.seq=e?e.seq:0,s&&o.db.once("destroyed",(function(){delete s[a]})),o}))}))}))}));return s&&(s[a]=c),c}In.prototype.add=function(e){return this.promise=this.promise.catch((function(){})).then((function(){return e()})),this.promise},In.prototype.finish=function(){return this.promise};var Bn={},Mn=new In;function qn(e){return-1===e.indexOf("/")?[e,e]:e.split("/")}function Ln(e,t){try{e.emit("error",t)}catch(e){B("error","The user's map/reduce function threw an uncaught error.\nYou can debug this error by doing:\nmyDatabase.on('error', function (err) { debugger; });\nPlease double-check your map/reduce function."),B("error",t)}}var Nn=function(e,t){return Sn(t)},Un=function(e,t){return t.length},Wn=function(e,t){return{sum:Sn(t),min:Math.min.apply(null,t),max:Math.max.apply(null,t),count:t.length,sumsqr:function(e){for(var t=0,n=0,r=e.length;n<r;n++){var i=e[n];t+=i*i}return t}(t)}};var $n=function(e,t,n,o){function a(e,t,n){try{t(n)}catch(t){Ln(e,t)}}function c(e,t,n,r,i){try{return{output:t(n,r,i)}}catch(t){return Ln(e,t),{error:t}}}function u(e,t){var n=pt(e.key,t.key);return 0!==n?n:pt(e.value,t.value)}function l(e,t,n){return n=n||0,"number"==typeof t?e.slice(n,t+n):n>0?e.slice(n):e}function h(e){var t=e.value;return t&&"object"==typeof t&&t._id||e.id}function d(e){return function(t){return e.include_docs&&e.attachments&&e.binary&&function(e){e.rows.forEach((function(e){var t=e.doc&&e.doc._attachments;t&&Object.keys(t).forEach((function(e){var n=t[e];t[e].data=we(n.data,n.content_type)}))}))}(t),t}}function f(e,t,n,r){var i=t[e];void 0!==i&&(r&&(i=encodeURIComponent(JSON.stringify(i))),n.push(e+"="+i))}function m(e){if(void 0!==e){var t=Number(e);return isNaN(t)||t!==parseInt(e,10)?e:t}}function g(e,t){var n=e.descending?"endkey":"startkey",r=e.descending?"startkey":"endkey";if(void 0!==e[n]&&void 0!==e[r]&&pt(e[n],e[r])>0)throw new bn("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(t.reduce&&!1!==e.reduce){if(e.include_docs)throw new bn("{include_docs:true} is invalid for reduce");if(e.keys&&e.keys.length>1&&!e.group&&!e.group_level)throw new bn("Multi-key fetches for reduce views must use {group: true}")}["group_level","limit","skip"].forEach((function(t){var n=function(e){if(e){if("number"!=typeof e)return new bn('Invalid value for integer: "'+e+'"');if(e<0)return new bn('Invalid value for positive integer: "'+e+'"')}}(e[t]);if(n)throw n}))}function _(e){return function(t){if(404===t.status)return e;throw t}}function y(e,t,n){var i="_local/doc_"+e,o={_id:i,keys:[]},s=n.get(e),a=s[0];return(function(e){return 1===e.length&&/^1-/.test(e[0].rev)}(s[1])?Promise.resolve(o):t.db.get(i).catch(_(o))).then((function(e){return function(e){return e.keys.length?t.db.allDocs({keys:e.keys,include_docs:!0}):Promise.resolve({rows:[]})}(e).then((function(t){return function(e,t){for(var n=[],i=new r,o=0,s=t.rows.length;o<s;o++){var c=t.rows[o].doc;if(c&&(n.push(c),i.add(c._id),c._deleted=!a.has(c._id),!c._deleted)){var u=a.get(c._id);"value"in u&&(c.value=u.value)}}var l=An(a);return l.forEach((function(e){if(!i.has(e)){var t={_id:e},r=a.get(e);"value"in r&&(t.value=r.value),n.push(t)}})),e.keys=jn(l.concat(e.keys)),n.push(e),n}(e,t)}))}))}function v(e){var t="string"==typeof e?e:e.name,n=Bn[t];return n||(n=Bn[t]=new In),n}function b(e){return En(v(e),(function(){return function(e){var n,r;var o=t(e.mapFun,(function(e,t){var i={id:r._id,key:ft(e)};null!=t&&(i.value=ft(t)),n.push(i)})),s=e.seq||0;function c(t,n){return function(){return function(e,t,n){return e.db.get("_local/lastSeq").catch(_({_id:"_local/lastSeq",seq:0})).then((function(r){var i=An(t);return Promise.all(i.map((function(n){return y(n,e,t)}))).then((function(t){var i=oe(t);return r.seq=n,i.push(r),e.db.bulkDocs({docs:i})}))}))}(e,t,n)}}var l=new In;function h(){return e.sourceDB.changes({return_docs:!0,conflicts:!0,include_docs:!0,style:"all_docs",since:s,limit:50}).then(d)}function d(t){var d=t.results;if(d.length){var f=function(t){for(var c=new i,l=0,h=t.length;l<h;l++){var d=t[l];if("_"!==d.doc._id[0]){n=[],(r=d.doc)._deleted||a(e.sourceDB,o,r),n.sort(u);var f=p(n);c.set(d.doc._id,[f,d.changes])}s=d.seq}return c}(d);if(l.add(c(f,s)),!(d.length<50))return h()}}function p(e){for(var t,n=new i,r=0,o=e.length;r<o;r++){var s=e[r],a=[s.key,s.id];r>0&&0===pt(s.key,t)&&a.push(r),n.set(gt(a),s),t=s.key}return n}return h().then((function(){return l.finish()})).then((function(){e.seq=s}))}(e)}))()}function w(e,t){return En(v(e),(function(){return function(e,t){var r,o=e.reduceFun&&!1!==t.reduce,s=t.skip||0;void 0===t.keys||t.keys.length||(t.limit=0,delete t.keys);function a(t){return t.include_docs=!0,e.db.allDocs(t).then((function(e){return r=e.total_rows,e.rows.map((function(e){if("value"in e.doc&&"object"==typeof e.doc.value&&null!==e.doc.value){var t=Object.keys(e.doc.value).sort(),n=["id","key","value"];if(!(t<n||t>n))return e.doc.value}var r=function(e){for(var t=[],n=[],r=0;;){var i=e[r++];if("\0"!==i)switch(i){case"1":t.push(null);break;case"2":t.push("1"===e[r]),r++;break;case"3":var o=_t(e,r);t.push(o.num),r+=o.length;break;case"4":for(var s="";;){var a=e[r];if("\0"===a)break;s+=a,r++}s=s.replace(/\u0001\u0001/g,"\0").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),t.push(s);break;case"5":var c={element:[],index:t.length};t.push(c.element),n.push(c);break;case"6":var u={element:{},index:t.length};t.push(u.element),n.push(u);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+i)}else{if(1===t.length)return t.pop();yt(t,n)}}}(e.doc._id);return{key:r[0],id:r[1],value:"value"in e.doc?e.doc.value:null}}))}))}function u(a){var u;if(u=o?function(e,t,r){0===r.group_level&&delete r.group_level;var i=r.group||r.group_level,o=n(e.reduceFun),s=[],a=isNaN(r.group_level)?Number.POSITIVE_INFINITY:r.group_level;t.forEach((function(e){var t=s[s.length-1],n=i?e.key:null;if(i&&Array.isArray(n)&&(n=n.slice(0,a)),t&&0===pt(t.groupKey,n))return t.keys.push([e.key,e.id]),void t.values.push(e.value);s.push({keys:[[e.key,e.id]],values:[e.value],groupKey:n})})),t=[];for(var u=0,h=s.length;u<h;u++){var d=s[u],p=c(e.sourceDB,o,d.keys,d.values,!1);if(p.error&&p.error instanceof xn)throw p.error;t.push({value:p.error?null:p.output,key:d.groupKey})}return{rows:l(t,r.limit,r.skip)}}(e,a,t):{total_rows:r,offset:s,rows:a},t.update_seq&&(u.update_seq=e.seq),t.include_docs){var d=jn(a.map(h));return e.sourceDB.allDocs({keys:d,include_docs:!0,conflicts:t.conflicts,attachments:t.attachments,binary:t.binary}).then((function(e){var t=new i;return e.rows.forEach((function(e){t.set(e.id,e.doc)})),a.forEach((function(e){var n=h(e),r=t.get(n);r&&(e.doc=r)})),u}))}return u}if(void 0!==t.keys){var d=t.keys.map((function(e){var n={startkey:gt([e]),endkey:gt([e,{}])};return t.update_seq&&(n.update_seq=!0),a(n)}));return Promise.all(d).then(oe).then(u)}var p,f,m={descending:t.descending};if(t.update_seq&&(m.update_seq=!0),"start_key"in t&&(p=t.start_key),"startkey"in t&&(p=t.startkey),"end_key"in t&&(f=t.end_key),"endkey"in t&&(f=t.endkey),void 0!==p&&(m.startkey=t.descending?gt([p,{}]):gt([p])),void 0!==f){var g=!1!==t.inclusive_end;t.descending&&(g=!g),m.endkey=gt(g?[f,{}]:[f])}if(void 0!==t.key){var _=gt([t.key]),y=gt([t.key,{}]);m.descending?(m.endkey=_,m.startkey=y):(m.startkey=_,m.endkey=y)}return o||("number"==typeof t.limit&&(m.limit=t.limit),m.skip=s),a(m).then(u)}(e,t)}))()}function x(t,n,r){if("function"==typeof t._query)return function(e,t,n){return new Promise((function(r,i){e._query(t,n,(function(e,t){if(e)return i(e);r(t)}))}))}(t,n,r);if(ae(t))return function(e,t,n){var r,i,o,s=[],a="GET";if(f("reduce",n,s),f("include_docs",n,s),f("attachments",n,s),f("limit",n,s),f("descending",n,s),f("group",n,s),f("group_level",n,s),f("skip",n,s),f("stale",n,s),f("conflicts",n,s),f("startkey",n,s,!0),f("start_key",n,s,!0),f("endkey",n,s,!0),f("end_key",n,s,!0),f("inclusive_end",n,s),f("key",n,s,!0),f("update_seq",n,s),s=""===(s=s.join("&"))?"":"?"+s,void 0!==n.keys){var c="keys="+encodeURIComponent(JSON.stringify(n.keys));c.length+s.length+1<=2e3?s+=("?"===s[0]?"&":"?")+c:(a="POST","string"==typeof t?r={keys:n.keys}:t.keys=n.keys)}if("string"==typeof t){var u=qn(t);return e.fetch("_design/"+u[0]+"/_view/"+u[1]+s,{headers:new it({"Content-Type":"application/json"}),method:a,body:JSON.stringify(r)}).then((function(e){return i=e.ok,o=e.status,e.json()})).then((function(e){if(!i)throw e.status=o,re(e);return e.rows.forEach((function(e){if(e.value&&e.value.error&&"builtin_reduce_error"===e.value.error)throw new Error(e.reason)})),e})).then(d(n))}return r=r||{},Object.keys(t).forEach((function(e){Array.isArray(t[e])?r[e]=t[e]:r[e]=t[e].toString()})),e.fetch("_temp_view"+s,{headers:new it({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(r)}).then((function(e){return i=e.ok,o=e.status,e.json()})).then((function(e){if(!i)throw e.status=o,re(e);return e})).then(d(n))}(t,n,r);if("string"!=typeof n)return g(r,n),Mn.add((function(){return Rn(t,"temp_view/temp_view",n.map,n.reduce,!0,e).then((function(e){return t=b(e).then((function(){return w(e,r)})),n=function(){return e.db.destroy()},t.then((function(e){return n().then((function(){return e}))}),(function(e){return n().then((function(){throw e}))}));var t,n}))})),Mn.finish();var i=n,a=qn(i),c=a[0],u=a[1];return t.get("_design/"+c).then((function(n){var a=n.views&&n.views[u];if(!a)throw new wn("ddoc "+n._id+" has no view named "+u);return o(n,u),g(r,a),Rn(t,i,a.map,a.reduce,!1,e).then((function(e){return"ok"===r.stale||"update_after"===r.stale?("update_after"===r.stale&&s()((function(){b(e)})),w(e,r)):b(e).then((function(){return w(e,r)}))}))}))}var k;return{query:function(e,t,n){var r=this;"function"==typeof t&&(n=t,t={}),t=t?function(e){return e.group_level=m(e.group_level),e.limit=m(e.limit),e.skip=m(e.skip),e}(t):{},"function"==typeof e&&(e={map:e});var i=Promise.resolve().then((function(){return x(r,e,t)}));return kn(i,n),i},viewCleanup:(k=function(){var t=this;return"function"==typeof t._viewCleanup?function(e){return new Promise((function(t,n){e._viewCleanup((function(e,r){if(e)return n(e);t(r)}))}))}(t):ae(t)?function(e){return e.fetch("_view_cleanup",{headers:new it({"Content-Type":"application/json"}),method:"POST"}).then((function(e){return e.json()}))}(t):function(t){return t.get("_local/"+e).then((function(e){var n=new i;Object.keys(e.views).forEach((function(e){var t=qn(e),i="_design/"+t[0],o=t[1],s=n.get(i);s||(s=new r,n.set(i,s)),s.add(o)}));var o={keys:An(n),include_docs:!0};return t.allDocs(o).then((function(r){var i={};r.rows.forEach((function(t){var r=t.key.substring(8);n.get(t.key).forEach((function(n){var o=r+"/"+n;e.views[o]||(o=n);var s=Object.keys(e.views[o]),a=t.doc&&t.doc.views&&t.doc.views[n];s.forEach((function(e){i[e]=i[e]||a}))}))}));var o=Object.keys(i).filter((function(e){return!i[e]})).map((function(e){return En(v(e),(function(){return new t.constructor(e,t.__opts).destroy()}))()}));return Promise.all(o).then((function(){return{ok:!0}}))}))}),_({ok:!0}))}(t)},p()((function(e){var t=e.pop(),n=k.apply(this,e);return"function"==typeof t&&kn(n,t),n})))}}("mrviews",(function(e,t){if("function"==typeof e&&2===e.length){var n=e;return function(e){return n(e,t)}}return Fn(e.toString(),t)}),(function(e){var t=e.toString(),n=function(e){if(/^_sum/.test(e))return Nn;if(/^_count/.test(e))return Un;if(/^_stats/.test(e))return Wn;if(/^_/.test(e))throw new Error(e+" is not a supported reduce function.")}(t);return n||Fn(t)}),(function(e,t){var n=e.views&&e.views[t];if("string"!=typeof n.map)throw new wn("ddoc "+e._id+" has no string view named "+t+", instead found object of type: "+typeof n.map)}));var zn={query:function(e,t,n){return $n.query.call(this,e,t,n)},viewCleanup:function(e){return $n.viewCleanup.call(this,e)}};function Jn(e){return/^1-/.test(e)}function Hn(e,t){var n=Object.keys(t._attachments);return Promise.all(n.map((function(n){return e.getAttachment(t._id,n,{rev:t._rev})})))}function Kn(e,t,n,r){n=j(n);var i=[],o=!0;function s(t){return e.allDocs({keys:t,include_docs:!0,conflicts:!0}).then((function(e){if(r.cancelled)throw new Error("cancelled");e.rows.forEach((function(e){var t;e.deleted||!e.doc||!Jn(e.value.rev)||(t=e.doc,t._attachments&&Object.keys(t._attachments).length>0)||function(e){return e._conflicts&&e._conflicts.length>0}(e.doc)||(e.doc._conflicts&&delete e.doc._conflicts,i.push(e.doc),delete n[e.id])}))}))}return Promise.resolve().then((function(){var e=Object.keys(n).filter((function(e){var t=n[e].missing;return 1===t.length&&Jn(t[0])}));if(e.length>0)return s(e)})).then((function(){var s=function(e){var t=[];return Object.keys(e).forEach((function(n){e[n].missing.forEach((function(e){t.push({id:n,rev:e})}))})),{docs:t,revs:!0,latest:!0}}(n);if(s.docs.length)return e.bulkGet(s).then((function(n){if(r.cancelled)throw new Error("cancelled");return Promise.all(n.results.map((function(n){return Promise.all(n.docs.map((function(n){var r=n.ok;return n.error&&(o=!1),r&&r._attachments?function(e,t,n){var r=ae(t)&&!ae(e),i=Object.keys(n._attachments);return r?e.get(n._id).then((function(r){return Promise.all(i.map((function(i){return function(e,t,n){return!e._attachments||!e._attachments[n]||e._attachments[n].digest!==t._attachments[n].digest}(r,n,i)?t.getAttachment(n._id,i):e.getAttachment(r._id,i)})))})).catch((function(e){if(404!==e.status)throw e;return Hn(t,n)})):Hn(t,n)}(t,e,r).then((function(e){var t=Object.keys(r._attachments);return e.forEach((function(e,n){var i=r._attachments[t[n]];delete i.stub,delete i.length,i.data=e})),r})):r})))}))).then((function(e){i=i.concat(oe(e).filter(Boolean))}))}))})).then((function(){return{ok:o,docs:i}}))}function Vn(e,t,n,r,i){return e.get(t).catch((function(n){if(404===n.status)return"http"!==e.adapter&&"https"!==e.adapter||q(404,"PouchDB is just checking if a remote checkpoint exists."),{session_id:r,_id:t,history:[],replicator:"pouchdb",version:1};throw n})).then((function(o){if(!i.cancelled&&o.last_seq!==n)return o.history=(o.history||[]).filter((function(e){return e.session_id!==r})),o.history.unshift({last_seq:n,session_id:r}),o.history=o.history.slice(0,5),o.version=1,o.replicator="pouchdb",o.session_id=r,o.last_seq=n,e.put(o).catch((function(o){if(409===o.status)return Vn(e,t,n,r,i);throw o}))}))}function Xn(e,t,n,r,i){this.src=e,this.target=t,this.id=n,this.returnValue=r,this.opts=i||{}}Xn.prototype.writeCheckpoint=function(e,t){var n=this;return this.updateTarget(e,t).then((function(){return n.updateSource(e,t)}))},Xn.prototype.updateTarget=function(e,t){return this.opts.writeTargetCheckpoint?Vn(this.target,this.id,e,t,this.returnValue):Promise.resolve(!0)},Xn.prototype.updateSource=function(e,t){if(this.opts.writeSourceCheckpoint){var n=this;return Vn(this.src,this.id,e,t,this.returnValue).catch((function(e){if(Qn(e))return n.opts.writeSourceCheckpoint=!1,!0;throw e}))}return Promise.resolve(!0)};var Yn={undefined:function(e,t){return 0===pt(e.last_seq,t.last_seq)?t.last_seq:0},1:function(e,t){return function(e,t){if(e.session_id===t.session_id)return{last_seq:e.last_seq,history:e.history};return function e(t,n){var r=t[0],i=t.slice(1),o=n[0],s=n.slice(1);if(!r||0===n.length)return{last_seq:0,history:[]};if(Gn(r.session_id,n))return{last_seq:r.last_seq,history:t};if(Gn(o.session_id,i))return{last_seq:o.last_seq,history:s};return e(i,s)}(e.history,t.history)}(t,e).last_seq}};function Gn(e,t){var n=t[0],r=t.slice(1);return!(!e||0===t.length)&&(e===n.session_id||Gn(e,r))}function Qn(e){return"number"==typeof e.status&&4===Math.floor(e.status/100)}Xn.prototype.getCheckpoint=function(){var e=this;return e.opts&&e.opts.writeSourceCheckpoint&&!e.opts.writeTargetCheckpoint?e.src.get(e.id).then((function(e){return e.last_seq||0})).catch((function(e){if(404!==e.status)throw e;return 0})):e.target.get(e.id).then((function(t){return e.opts&&e.opts.writeTargetCheckpoint&&!e.opts.writeSourceCheckpoint?t.last_seq||0:e.src.get(e.id).then((function(e){return t.version!==e.version?0:(n=t.version?t.version.toString():"undefined")in Yn?Yn[n](t,e):0;var n}),(function(n){if(404===n.status&&t.last_seq)return e.src.put({_id:e.id,last_seq:0}).then((function(){return 0}),(function(n){return Qn(n)?(e.opts.writeSourceCheckpoint=!1,t.last_seq):0}));throw n}))})).catch((function(e){if(404!==e.status)throw e;return 0}))};function Zn(e,t,n){var r=n.doc_ids?n.doc_ids.sort(pt):"",i=n.filter?n.filter.toString():"",o="",s="",a="";return n.selector&&(a=JSON.stringify(n.selector)),n.filter&&n.query_params&&(o=JSON.stringify(function(e){return Object.keys(e).sort(pt).reduce((function(t,n){return t[n]=e[n],t}),{})}(n.query_params))),n.filter&&"_view"===n.filter&&(s=n.view.toString()),Promise.all([e.id(),t.id()]).then((function(e){var t=e[0]+e[1]+i+s+o+r+a;return new Promise((function(e){Se(t,e)}))})).then((function(e){return"_local/"+(e=e.replace(/\//g,".").replace(/\+/g,"_"))}))}function er(e,t,n,r,i){var o,a,c,u=[],l={seq:0,changes:[],docs:[]},h=!1,d=!1,p=!1,f=0,m=n.continuous||n.live||!1,g=n.batch_size||100,_=n.batches_limit||10,y=!1,v=n.doc_ids,b=n.selector,w=[],x=Pe();i=i||{ok:!0,start_time:(new Date).toISOString(),docs_read:0,docs_written:0,doc_write_failures:0,errors:[]};var k={};function E(){return c?Promise.resolve():Zn(e,t,n).then((function(i){a=i;var o={};o=!1===n.checkpoint?{writeSourceCheckpoint:!1,writeTargetCheckpoint:!1}:"source"===n.checkpoint?{writeSourceCheckpoint:!0,writeTargetCheckpoint:!1}:"target"===n.checkpoint?{writeSourceCheckpoint:!1,writeTargetCheckpoint:!0}:{writeSourceCheckpoint:!0,writeTargetCheckpoint:!0},c=new Xn(e,t,a,r,o)}))}function A(){if(w=[],0!==o.docs.length){var e=o.docs,s={timeout:n.timeout};return t.bulkDocs({docs:e,new_edits:!1},s).then((function(t){if(r.cancelled)throw F(),new Error("cancelled");var n=Object.create(null);t.forEach((function(e){e.error&&(n[e.id]=e)}));var o=Object.keys(n).length;i.doc_write_failures+=o,i.docs_written+=e.length-o,e.forEach((function(e){var t=n[e._id];if(t){i.errors.push(t);var o=(t.name||"").toLowerCase();if("unauthorized"!==o&&"forbidden"!==o)throw t;r.emit("denied",j(t))}else w.push(e)}))}),(function(t){throw i.doc_write_failures+=e.length,t}))}}function D(){if(o.error)throw new Error("There was a problem getting docs.");i.last_seq=f=o.seq;var e=j(i);return w.length&&(e.docs=w,"number"==typeof o.pending&&(e.pending=o.pending,delete o.pending),r.emit("change",e)),h=!0,c.writeCheckpoint(o.seq,x).then((function(){if(h=!1,r.cancelled)throw F(),new Error("cancelled");o=void 0,B()})).catch((function(e){throw L(e),e}))}function S(){return Kn(e,t,o.diffs,r).then((function(e){o.error=!e.ok,e.docs.forEach((function(e){delete o.diffs[e._id],i.docs_read++,o.docs.push(e)}))}))}function C(){var e;r.cancelled||o||(0!==u.length?(o=u.shift(),(e={},o.changes.forEach((function(t){"_user/"!==t.id&&(e[t.id]=t.changes.map((function(e){return e.rev})))})),t.revsDiff(e).then((function(e){if(r.cancelled)throw F(),new Error("cancelled");o.diffs=e}))).then(S).then(A).then(D).then(C).catch((function(e){P("batch processing terminated with error",e)}))):O(!0))}function O(e){0!==l.changes.length?(e||d||l.changes.length>=g)&&(u.push(l),l={seq:0,changes:[],docs:[]},"pending"!==r.state&&"stopped"!==r.state||(r.state="active",r.emit("active")),C()):0!==u.length||o||((m&&k.live||d)&&(r.state="pending",r.emit("paused")),d&&F())}function P(e,t){p||(t.message||(t.message=e),i.ok=!1,i.status="aborting",u=[],l={seq:0,changes:[],docs:[]},F(t))}function F(o){if(!(p||r.cancelled&&(i.status="cancelled",h)))if(i.status=i.status||"complete",i.end_time=(new Date).toISOString(),i.last_seq=f,p=!0,o){(o=ne(o)).result=i;var s=(o.name||"").toLowerCase();"unauthorized"===s||"forbidden"===s?(r.emit("error",o),r.removeAllListeners()):function(e,t,n,r){if(!1===e.retry)return t.emit("error",n),void t.removeAllListeners();if("function"!=typeof e.back_off_function&&(e.back_off_function=M),t.emit("requestError",n),"active"===t.state||"pending"===t.state){t.emit("paused",n),t.state="stopped";var i=function(){e.current_back_off=0};t.once("paused",(function(){t.removeListener("active",i)})),t.once("active",i)}e.current_back_off=e.current_back_off||0,e.current_back_off=e.back_off_function(e.current_back_off),setTimeout(r,e.current_back_off)}(n,r,o,(function(){er(e,t,n,r)}))}else r.emit("complete",i),r.removeAllListeners()}function I(e,t,i){if(r.cancelled)return F();"number"==typeof t&&(l.pending=t),ie(n)(e)&&(l.seq=e.seq||i,l.changes.push(e),s()((function(){O(0===u.length&&k.live)})))}function T(e){if(y=!1,r.cancelled)return F();if(e.results.length>0)k.since=e.results[e.results.length-1].seq,B(),O(!0);else{var t=function(){m?(k.live=!0,B()):d=!0,O(!0)};o||0!==e.results.length?t():(h=!0,c.writeCheckpoint(e.last_seq,x).then((function(){h=!1,i.last_seq=f=e.last_seq,t()})).catch(L))}}function R(e){if(y=!1,r.cancelled)return F();P("changes rejected",e)}function B(){if(!y&&!d&&u.length<_){y=!0,r._changes&&(r.removeListener("cancel",r._abortChanges),r._changes.cancel()),r.once("cancel",i);var t=e.changes(k).on("change",I);t.then(o,o),t.then(T).catch(R),n.retry&&(r._changes=t,r._abortChanges=i)}function i(){t.cancel()}function o(){r.removeListener("cancel",i)}}function q(){E().then((function(){if(!r.cancelled)return c.getCheckpoint().then((function(e){k={since:f=e,limit:g,batch_size:g,style:"all_docs",doc_ids:v,selector:b,return_docs:!0},n.filter&&("string"!=typeof n.filter?k.include_docs=!0:k.filter=n.filter),"heartbeat"in n&&(k.heartbeat=n.heartbeat),"timeout"in n&&(k.timeout=n.timeout),n.query_params&&(k.query_params=n.query_params),n.view&&(k.view=n.view),B()}));F()})).catch((function(e){P("getCheckpoint rejected with ",e)}))}function L(e){h=!1,P("writeCheckpoint completed with error",e)}r.ready(e,t),r.cancelled?F():(r._addedListeners||(r.once("cancel",F),"function"==typeof n.complete&&(r.once("error",n.complete),r.once("complete",(function(e){n.complete(null,e)}))),r._addedListeners=!0),void 0===n.since?q():E().then((function(){return h=!0,c.writeCheckpoint(n.since,x)})).then((function(){h=!1,r.cancelled?F():(f=n.since,q())})).catch(L))}function tr(){_.a.call(this),this.cancelled=!1,this.state="pending";var e=this,t=new Promise((function(t,n){e.once("complete",t),e.once("error",n)}));e.then=function(e,n){return t.then(e,n)},e.catch=function(e){return t.catch(e)},e.catch((function(){}))}function nr(e,t){var n=t.PouchConstructor;return"string"==typeof e?new n(e,t):e}function rr(e,t,n,r){if("function"==typeof n&&(r=n,n={}),void 0===n&&(n={}),n.doc_ids&&!Array.isArray(n.doc_ids))throw ne(G,"`doc_ids` filter parameter is not a list.");n.complete=r,(n=j(n)).continuous=n.continuous||n.live,n.retry="retry"in n&&n.retry,n.PouchConstructor=n.PouchConstructor||this;var i=new tr(n);return er(nr(e,n),nr(t,n),n,i),i}function ir(e,t,n,r){return"function"==typeof n&&(r=n,n={}),void 0===n&&(n={}),(n=j(n)).PouchConstructor=n.PouchConstructor||this,new or(e=nr(e,n),t=nr(t,n),n,r)}function or(e,t,n,r){var i=this;this.canceled=!1;var o=n.push?L({},n,n.push):n,s=n.pull?L({},n,n.pull):n;function a(e){i.emit("change",{direction:"pull",change:e})}function c(e){i.emit("change",{direction:"push",change:e})}function u(e){i.emit("denied",{direction:"push",doc:e})}function l(e){i.emit("denied",{direction:"pull",doc:e})}function h(){i.pushPaused=!0,i.pullPaused&&i.emit("paused")}function d(){i.pullPaused=!0,i.pushPaused&&i.emit("paused")}function p(){i.pushPaused=!1,i.pullPaused&&i.emit("active",{direction:"push"})}function f(){i.pullPaused=!1,i.pushPaused&&i.emit("active",{direction:"pull"})}this.push=rr(e,t,o),this.pull=rr(t,e,s),this.pushPaused=!0,this.pullPaused=!0;var m={};function g(e){return function(t,n){("change"===t&&(n===a||n===c)||"denied"===t&&(n===l||n===u)||"paused"===t&&(n===d||n===h)||"active"===t&&(n===f||n===p))&&(t in m||(m[t]={}),m[t][e]=!0,2===Object.keys(m[t]).length&&i.removeAllListeners(t))}}function _(e,t,n){-1==e.listeners(t).indexOf(n)&&e.on(t,n)}n.live&&(this.push.on("complete",i.pull.cancel.bind(i.pull)),this.pull.on("complete",i.push.cancel.bind(i.push))),this.on("newListener",(function(e){"change"===e?(_(i.pull,"change",a),_(i.push,"change",c)):"denied"===e?(_(i.pull,"denied",l),_(i.push,"denied",u)):"active"===e?(_(i.pull,"active",f),_(i.push,"active",p)):"paused"===e&&(_(i.pull,"paused",d),_(i.push,"paused",h))})),this.on("removeListener",(function(e){"change"===e?(i.pull.removeListener("change",a),i.push.removeListener("change",c)):"denied"===e?(i.pull.removeListener("denied",l),i.push.removeListener("denied",u)):"active"===e?(i.pull.removeListener("active",f),i.push.removeListener("active",p)):"paused"===e&&(i.pull.removeListener("paused",d),i.push.removeListener("paused",h))})),this.pull.on("removeListener",g("pull")),this.push.on("removeListener",g("push"));var y=Promise.all([this.push,this.pull]).then((function(e){var t={push:e[0],pull:e[1]};return i.emit("complete",t),r&&r(null,t),i.removeAllListeners(),t}),(function(e){if(i.cancel(),r?r(e):i.emit("error",e),i.removeAllListeners(),r)throw e}));this.then=function(e,t){return y.then(e,t)},this.catch=function(e){return y.catch(e)}}m()(tr,_.a),tr.prototype.cancel=function(){this.cancelled=!0,this.state="cancelled",this.emit("cancel")},tr.prototype.ready=function(e,t){var n=this;function r(){n.cancel()}n._readyCalled||(n._readyCalled=!0,e.once("destroyed",r),t.once("destroyed",r),n.once("complete",(function(){e.removeListener("destroyed",r),t.removeListener("destroyed",r)})))},m()(or,_.a),or.prototype.cancel=function(){this.canceled||(this.canceled=!0,this.push.cancel(),this.pull.cancel())},tt.plugin((function(e){e.adapter("idb",ln,!0)})).plugin((function(e){e.adapter("http",vn,!1),e.adapter("https",vn,!1)})).plugin(zn).plugin((function(e){e.replicate=rr,e.sync=ir,Object.defineProperty(e.prototype,"replicate",{get:function(){var e=this;return void 0===this.replicateMethods&&(this.replicateMethods={from:function(t,n,r){return e.constructor.replicate(t,e,n,r)},to:function(t,n,r){return e.constructor.replicate(e,t,n,r)}}),this.replicateMethods}}),e.prototype.sync=function(e,t,n){return this.constructor.sync(this,e,t,n)}})),t.a=tt}).call(this,n(57))},function(e,t,n){var r=n(47),i=n(107),o=n(108),s=n(36),a=n(55),c=n(117),u=Object.prototype.hasOwnProperty,l=o((function(e,t){if(a(t)||s(t))i(t,c(t),e);else for(var n in t)u.call(t,n)&&r(e,n,t[n])}));e.exports=l},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e){e.exports=JSON.parse('{"b":"0.14.5","a":{"ajv":"^6.9.1","axios":"^0.21.1","dompurify":"^2.0.8","file-saver":"^1.3.3","imjoy-rpc":"^0.5.9","js-yaml":"^3.13.1","lodash":"^4.17.15","lz-string":"^1.4.4","minibus":"^3.1.0","pouchdb-browser":"^7.2.2","socket.io-client":"^2.3.0","spark-md5":"^3.0.0"}}')},function(e,t,n){e.exports=n(137)},function(e,t,n){"use strict";e.exports=function(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e){return null==e}e.exports.isNothing=r,e.exports.isObject=function(e){return"object"==typeof e&&null!==e},e.exports.toArray=function(e){return Array.isArray(e)?e:r(e)?[]:[e]},e.exports.repeat=function(e,t){var n,r="";for(n=0;n<t;n+=1)r+=e;return r},e.exports.isNegativeZero=function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},e.exports.extend=function(e,t){var n,r,i,o;if(t)for(n=0,r=(o=Object.keys(t)).length;n<r;n+=1)e[i=o[n]]=t[i];return e}},function(e,t,n){"use strict";var r=n(14),i=n(17),o=n(1);function s(e,t,n){var r=[];return e.include.forEach((function(e){n=s(e,t,n)})),e[t].forEach((function(e){n.forEach((function(t,n){t.tag===e.tag&&t.kind===e.kind&&r.push(n)})),n.push(e)})),n.filter((function(e,t){return-1===r.indexOf(t)}))}function a(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach((function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new i("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")})),this.compiledImplicit=s(this,"implicit",[]),this.compiledExplicit=s(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{}};function r(e){n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(r);return n}(this.compiledImplicit,this.compiledExplicit)}a.DEFAULT=null,a.create=function(){var e,t;switch(arguments.length){case 1:e=a.DEFAULT,t=arguments[0];break;case 2:e=arguments[0],t=arguments[1];break;default:throw new i("Wrong number of arguments for Schema.create function")}if(e=r.toArray(e),t=r.toArray(t),!e.every((function(e){return e instanceof a})))throw new i("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!t.every((function(e){return e instanceof o})))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new a({include:e,explicit:t})},e.exports=a},function(e,t,n){"use strict";function r(e,t,n,r){var i=r?" !== ":" === ",o=r?" || ":" && ",s=r?"!":"",a=r?"":"!";switch(e){case"null":return t+i+"null";case"array":return s+"Array.isArray("+t+")";case"object":return"("+s+t+o+"typeof "+t+i+'"object"'+o+a+"Array.isArray("+t+"))";case"integer":return"(typeof "+t+i+'"number"'+o+a+"("+t+" % 1)"+o+t+i+t+(n?o+s+"isFinite("+t+")":"")+")";case"number":return"(typeof "+t+i+'"'+e+'"'+(n?o+s+"isFinite("+t+")":"")+")";default:return"typeof "+t+i+'"'+e+'"'}}e.exports={copy:function(e,t){for(var n in t=t||{},e)t[n]=e[n];return t},checkDataType:r,checkDataTypes:function(e,t,n){switch(e.length){case 1:return r(e[0],t,n,!0);default:var i="",s=o(e);for(var a in s.array&&s.object&&(i=s.null?"(":"(!"+t+" || ",i+="typeof "+t+' !== "object")',delete s.null,delete s.array,delete s.object),s.number&&delete s.integer,s)i+=(i?" && ":"")+r(a,t,n,!0);return i}},coerceToTypes:function(e,t){if(Array.isArray(t)){for(var n=[],r=0;r<t.length;r++){var o=t[r];(i[o]||"array"===e&&"array"===o)&&(n[n.length]=o)}if(n.length)return n}else{if(i[t])return[t];if("array"===e&&"array"===t)return["array"]}},toHash:o,getProperty:c,escapeQuotes:u,equal:n(40),ucs2length:n(185),varOccurences:function(e,t){t+="[^0-9]";var n=e.match(new RegExp(t,"g"));return n?n.length:0},varReplace:function(e,t,n){return t+="([^0-9])",n=n.replace(/\$/g,"$$$$"),e.replace(new RegExp(t,"g"),n+"$1")},schemaHasRules:function(e,t){if("boolean"==typeof e)return!e;for(var n in e)if(t[n])return!0},schemaHasRulesExcept:function(e,t,n){if("boolean"==typeof e)return!e&&"not"!=n;for(var r in e)if(r!=n&&t[r])return!0},schemaUnknownRules:function(e,t){if("boolean"==typeof e)return;for(var n in e)if(!t[n])return n},toQuotedString:l,getPathExpr:function(e,t,n,r){return p(e,n?"'/' + "+t+(r?"":".replace(/~/g, '~0').replace(/\\//g, '~1')"):r?"'[' + "+t+" + ']'":"'[\\'' + "+t+" + '\\']'")},getPath:function(e,t,n){var r=l(n?"/"+f(t):c(t));return p(e,r)},getData:function(e,t,n){var r,i,o,s;if(""===e)return"rootData";if("/"==e[0]){if(!h.test(e))throw new Error("Invalid JSON-pointer: "+e);i=e,o="rootData"}else{if(!(s=e.match(d)))throw new Error("Invalid JSON-pointer: "+e);if(r=+s[1],"#"==(i=s[2])){if(r>=t)throw new Error("Cannot access property/index "+r+" levels up, current level is "+t);return n[t-r]}if(r>t)throw new Error("Cannot access data "+r+" levels up, current level is "+t);if(o="data"+(t-r||""),!i)return o}for(var a=o,u=i.split("/"),l=0;l<u.length;l++){var p=u[l];p&&(o+=c(m(p)),a+=" && "+o)}return a},unescapeFragment:function(e){return m(decodeURIComponent(e))},unescapeJsonPointer:m,escapeFragment:function(e){return encodeURIComponent(f(e))},escapeJsonPointer:f};var i=o(["string","number","integer","boolean","null"]);function o(e){for(var t={},n=0;n<e.length;n++)t[e[n]]=!0;return t}var s=/^[a-z$_][a-z$_0-9]*$/i,a=/'|\\/g;function c(e){return"number"==typeof e?"["+e+"]":s.test(e)?"."+e:"['"+u(e)+"']"}function u(e){return e.replace(a,"\\$&").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\f/g,"\\f").replace(/\t/g,"\\t")}function l(e){return"'"+u(e)+"'"}var h=/^\/(?:[^~]|~0|~1)*$/,d=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function p(e,t){return'""'==e?t:(e+" + "+t).replace(/([^\\])' \+ '/g,"$1")}function f(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function m(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}},function(e,t,n){"use strict";function r(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.prototype.toString=function(e){var t=this.name+": ";return t+=this.reason||"(unknown reason)",!e&&this.mark&&(t+=" "+this.mark.toString()),t},e.exports=r},function(e,t,n){"use strict";var r=n(15);e.exports=new r({include:[n(66)],implicit:[n(165),n(166)],explicit:[n(167),n(172),n(173),n(174)]})},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"loadImJoyCore",(function(){return loadImJoyCore})),__webpack_require__.d(__webpack_exports__,"latest_rpc_version",(function(){return latest_rpc_version})),__webpack_require__.d(__webpack_exports__,"loadImJoyRPC",(function(){return loadImJoyRPC})),__webpack_require__.d(__webpack_exports__,"loadImJoyRPCSocketIO",(function(){return loadImJoyRPCSocketIO}));var _package_json__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(10),_package_json__WEBPACK_IMPORTED_MODULE_0___namespace=__webpack_require__.t(10,1),_imjoyBasicApp_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(2);__webpack_require__.d(__webpack_exports__,"loadImJoyBasicApp",(function(){return _imjoyBasicApp_js__WEBPACK_IMPORTED_MODULE_1__.b}));var _getParams=function(e){var t={},n=document.createElement("a");n.href=e;for(var r=n.search.substring(1).split("&"),i=0;i<r.length;i++){var o=r[i].split("=");t[o[0]]=decodeURIComponent(o[1])}return t};function loadImJoyCore(config){return config=config||{},new Promise(async(resolve,reject)=>{try{var baseUrl=config.base_url;if(!baseUrl){const e=config.version||"latest";baseUrl=`https://cdn.jsdelivr.net/npm/imjoy-core@${e}/dist/`}if(delete window.imjoyCore,config.debug?await Object(_imjoyBasicApp_js__WEBPACK_IMPORTED_MODULE_1__.a)(baseUrl+"imjoy-core.js"):await Object(_imjoyBasicApp_js__WEBPACK_IMPORTED_MODULE_1__.a)(baseUrl+"imjoy-core.min.js"),window.imjoyCore){const e=window.imjoyCore;delete window.imjoyCore,resolve(e)}else"function"==typeof define&&__webpack_require__(9)?eval("require")(["imjoyCore"],resolve):reject("Failed to import imjoy-core.")}catch(e){reject(e)}})}const _rpc_registry={},latest_rpc_version=_package_json__WEBPACK_IMPORTED_MODULE_0__.a["imjoy-rpc"].replace(/[^\d.-]/g,""),_rpc_api_versions={"0.2.0":{from:"0.1.10",to:"0.1.17",skips:[]},"0.2.1":{from:"0.1.18",to:"0.2.5",skips:[]},"0.2.2":{from:"0.2.6",to:"0.2.6",skips:[]},"0.2.3":{from:"0.2.7",to:latest_rpc_version,skips:["0.2.9","0.2.15","0.2.16","0.2.18","0.2.23","0.2.24","0.2.25"]}};function findRPCVersionByAPIVersion(e,t){if(!e||!e.includes("."))return;let n=Object.keys(_rpc_registry);if(_rpc_api_versions[e]){if(n.length<=0||t)return _rpc_api_versions[e].to;r=(e,t)=>e.map(e=>e.replace(/\d+/g,e=>+e+1e5*t)),n=r(r(n,1).sort(),-1);for(let t of n.reverse())if(_rpc_registry[t].API_VERSION===e)return t;return _rpc_api_versions[e].to}return null;var r}function loadImJoyRPC(config){return config=config||{},new Promise((resolve,reject)=>{var baseUrl=config.base_url;let version=config.version;if(!baseUrl)if(config.version)baseUrl=`https://cdn.jsdelivr.net/npm/imjoy-rpc@${config.version}/dist/`;else if(config.api_version){if(version=findRPCVersionByAPIVersion(config.api_version,!0),!version)return void reject(Error("Cannot find a version of imjoy-rpc that supports api v"+config.api_version));baseUrl=`https://cdn.jsdelivr.net/npm/imjoy-rpc@${version}/dist/`}else baseUrl="https://cdn.jsdelivr.net/npm/imjoy-rpc@latest/dist/",version="latest",console.info(`Using imjoy-rpc library from ${baseUrl}.`);if(version&&_rpc_registry[version])return console.info(`Using cached imjoy-rpc library v${version}.`),void resolve(_rpc_registry[version]);let rpc_url=baseUrl+"imjoy-rpc.min.js";function checkAndCacheLib(e){if(version&&"latest"!==version&&version!==e.VERSION)throw new Error(`imjoy-rpc version mismatch ${version} != ${e.VERSION}`);if(config.api_version&&config.api_version!==e.API_VERSION)throw new Error(`imjoy-rpc api version mismatch ${config.api_version} != ${e.API_VERSION}`);_rpc_registry[e.VERSION]=e}config.debug&&(rpc_url=baseUrl+"imjoy-rpc.js"),delete window.imjoyRPC,Object(_imjoyBasicApp_js__WEBPACK_IMPORTED_MODULE_1__.a)(rpc_url).then(()=>{if(window.imjoyRPC){const e=window.imjoyRPC;delete window.imjoyRPC;try{checkAndCacheLib(e),resolve(e)}catch(e){reject(e)}}else{if("function"!=typeof define||!__webpack_require__(9))return void reject("Failed to import imjoy-rpc.");eval("require")(["imjoyRPC"],e=>{try{checkAndCacheLib(e),resolve(e)}catch(e){reject(e)}})}}).catch(reject)})}function loadImJoyRPCSocketIO(config){return config=config||{},new Promise((resolve,reject)=>{var baseUrl=config.base_url;let version=config.version;if(!baseUrl)if(config.version)baseUrl=`https://cdn.jsdelivr.net/npm/imjoy-rpc-socketio@${config.version}/dist/`;else if(config.api_version){if(version=findRPCVersionByAPIVersion(config.api_version,!0),!version)return void reject(Error("Cannot find a version of imjoy-rpc-socketio that supports api v"+config.api_version));baseUrl=`https://cdn.jsdelivr.net/npm/imjoy-rpc-socketio@${version}/dist/`}else baseUrl="https://cdn.jsdelivr.net/npm/imjoy-rpc-socketio@latest/dist/",version="latest",console.info(`Using imjoy-rpc-socketio library from ${baseUrl}.`);let rpc_url=baseUrl+"imjoy-rpc-socketio.min.js";config.debug&&(rpc_url=baseUrl+"imjoy-rpc-socketio.js"),delete window.imjoyRPCSocketIO,Object(_imjoyBasicApp_js__WEBPACK_IMPORTED_MODULE_1__.a)(rpc_url).then(()=>{if(window.imjoyRPCSocketIO){const e=window.imjoyRPCSocketIO;delete window.imjoyRPCSocketIO,resolve(e)}else"function"==typeof define&&__webpack_require__(9)?eval("require")(["imjoyRPCSocketIO"],resolve):reject("Failed to import imjoy-rpc-socketio.")}).catch(reject)})}async function loadImJoyRPCByQueryString(){const e=_getParams(window.location);return await loadImJoyRPC(e)}window.loadImJoyRPCByQueryString=loadImJoyRPCByQueryString,window.loadImJoyRPC=loadImJoyRPC,window.loadImJoyRPCSocketIO=loadImJoyRPCSocketIO,window.loadImJoyCore=loadImJoyCore,window.loadImJoyBasicApp=_imjoyBasicApp_js__WEBPACK_IMPORTED_MODULE_1__.b},function(e,t){e.exports=".vm--modal {\n max-height: 100% !important;\n max-width: 100% !important;\n}\n\n.imjoy-inline-window {\n width: 100%;\n height: 600px;\n}\n\n.imjoy-progress-border > div {\n background-color: #448aff;\n height: 3px;\n}\n\n.imjoy-progress-border {\n top: 0;\n left: 0;\n position: absolute;\n width: 100%;\n height: 3px;\n}\n\n.imjoy-noselect {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\nbody {\n margin: 0px;\n}\n.imjoy-dialog-control {\n padding: 0px;\n line-height: 10px;\n height: 23px;\n width: 25px;\n border: 0px;\n font-size: 1rem;\n position: absolute;\n color: white;\n top: 1px;\n}\n\n.imjoy-dialog-control:focus {\n outline: none;\n}\n\n.imjoy-loader {\n position: fixed;\n top: 40%;\n left: 50%;\n transform: translate(-50%, -50%);\n transform: -webkit-translate(-50%, -50%);\n transform: -moz-translate(-50%, -50%);\n transform: -ms-translate(-50%, -50%);\n border: 10px solid #f3f3f3;\n /* Light grey */\n border-top: 10px solid #448aff;\n /* Blue */\n border-radius: 50%;\n width: 40px;\n height: 40px;\n animation: spin 2s linear infinite;\n}\n\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n}\n\n/* The snackbar - position it at the bottom and in the middle of the screen */\n.imjoy-snackbar {\n font-family: Arial, Helvetica, sans-serif;\n visibility: hidden;\n /* Hidden by default. Visible on click */\n min-width: 250px;\n /* Set a default minimum width */\n background-color: #333333c2;\n /* Black background color */\n color: #fff;\n /* White text color */\n text-align: center;\n /* Centered text */\n border-radius: 5px;\n /* Rounded borders */\n padding: 16px;\n /* Padding */\n position: fixed;\n /* Sit on top of the screen */\n z-index: 9999;\n /* Add a z-index if needed */\n left: 50%;\n /* Center the snackbar */\n transform: translate(-50%, 0);\n bottom: 20px;\n /* 20px from the bottom */\n}\n\n.imjoy-window-title-bar {\n cursor: move;\n background-color: #448aff;\n color: white;\n text-align: center;\n height: 24px;\n}\n\n.imjoy-window-title {\n text-align: center;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 16px;\n line-height: 23px;\n margin: 0px;\n}\n\n/* Show the snackbar when clicking on a button (class added with JavaScript) */\n.imjoy-snackbar.show-snackbar {\n visibility: visible;\n /* Show the snackbar */\n /* Add animation: Take 0.5 seconds to fade in and out the snackbar.\n However, delay the fade out process for 2.5 seconds */\n -webkit-animation: imjoy-fadein 0.5s;\n animation: imjoy-fadein 0.5s;\n}\n\n/* Animations to fade the snackbar in and out */\n@-webkit-keyframes imjoy-fadein {\n from {\n bottom: 0;\n opacity: 0;\n }\n\n to {\n bottom: 30px;\n opacity: 1;\n }\n}\n\n@keyframes imjoy-fadein {\n from {\n bottom: 0;\n opacity: 0;\n }\n\n to {\n bottom: 30px;\n opacity: 1;\n }\n}\n\n.imjoy-dropdown-btn {\n padding: 4px;\n font-size: 16px;\n border: none;\n cursor: pointer;\n}\n\n.imjoy-dropdown {\n position: relative;\n display: inline-block;\n}\n\n.imjoy-dropdown-content {\n display: none;\n position: absolute;\n right: 0;\n background-color: #f9f9f9;\n min-width: 200px;\n box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);\n z-index: 1;\n}\n\n.imjoy-dropdown-content a {\n font-family: Arial, Helvetica, sans-serif;\n color: black;\n padding: 6px 10px;\n text-decoration: none;\n display: block;\n}\n\n.imjoy-dropdown-content a:hover {\n background-color: #f1f1f1;\n}\n\n.imjoy-dropdown:hover .imjoy-dropdown-content {\n display: block;\n}\n\n.imjoy-window-container {\n width: 100%;\n height: 100%;\n}\n\n.imjoy-windows {\n position: relative;\n min-height: 100px;\n height: calc(100% - 30px);\n}\n\n.block-pointer-events {\n pointer-events: none;\n}\n"},function(e,t){e.exports='<div v-if="showLoader" class="imjoy-loader" v-show="loading"></div>\n<div v-if="showProgressBar" class="imjoy-progress-border" v-show="progress">\n <div :style="{width: progress+\'%\'}"></div>\n</div>\n<div\n v-show="snackBarContent"\n :class="{\'show-snackbar\': snackBarContent}"\n class="imjoy-snackbar"\n>\n {{snackBarContent}}\n</div>\n<modal\n name="window-modal-dialog"\n height="500px"\n style="max-height: 100%; max-width: 100%"\n :fullscreen="fullscreen"\n :resizable="true"\n draggable=".imjoy-drag-handle"\n :scrollable="true"\n>\n <div\n v-if="selectedDialogWindow"\n @dblclick="maximizeWindow()"\n class="imjoy-drag-handle imjoy-window-title-bar"\n >\n <span class="imjoy-noselect imjoy-window-title"\n >{{ selectedDialogWindow.name}}</span\n >\n <button\n @click="closeWindow(selectedDialogWindow)"\n class="imjoy-noselect imjoy-dialog-control"\n style="background:#ff0000c4;left:1px;"\n >\n x\n </button>\n <button\n @click="minimizeWindow()"\n class="imjoy-noselect imjoy-dialog-control"\n style="background:#00cdff61;left:28px;"\n >\n -\n </button>\n <button\n @click="maximizeWindow()"\n class="imjoy-noselect imjoy-dialog-control"\n style="background:#00cdff61;left:55px;"\n >\n {{fullscreen?\'=\': \'+\'}}\n </button>\n </div>\n <template v-for="wdialog in dialogWindows">\n <div\n :key="wdialog.window_id"\n v-show="wdialog === selectedDialogWindow"\n style="height: calc(100% - 18px);"\n >\n <div :id="wdialog.window_id" style="width: 100%;height: 100%;"></div>\n </div>\n </template>\n</modal>\n'},function(e,t){e.exports='<div class="imjoy-dropdown" :style="menuStyle">\n <a class="imjoy-dropdown-btn"\n ><img\n style="width:24px;"\n src="https://imjoy.io/static/img/imjoy-icon.svg"\n />\n </a>\n <div\n class="imjoy-dropdown-content"\n v-if="showContent"\n @click="menuClicked"\n :style="{left: menuPos===\'left\'? 0: null}"\n >\n <a\n href="#"\n v-for="item in extraMenuItems"\n :key="item.label"\n @click.prevent="item.callback()"\n >{{item.label}}</a\n >\n <hr\n style="margin: 0;border-style: solid;color: rgb(157 205 255 / 45%);"\n v-show="extraMenuItems.length>0 && loadedPlugins.length>0"\n />\n <a\n href="#"\n v-for="p in loadedPlugins"\n :key="p.id"\n @click.prevent="p.api.run()"\n >🧩 {{p.name}}</a\n >\n <hr\n style="margin: 0;border-style: solid;color: rgb(157 205 255 / 45%);"\n v-show="allWindows.length>0 && loadedPlugins.length>0"\n />\n <a href="#" v-if="showAboutImJoy" @click.prevent="showAboutImJoy()"\n >ℹ️ About ImJoy</a\n >\n <hr\n style="margin: 0;border-style: solid;color: rgb(157 205 255 / 45%);"\n v-show="allWindows.length>0 && loadedPlugins.length>0"\n />\n <a\n href="#"\n v-for="w in allWindows"\n :style="{\'background-color\': activeWindow===w?\'#adcafb78\':\'\', \'font-weight\': activeWindow===w? 600:300}"\n :key="w.id"\n @click.prevent="w.api.show()"\n >🔳 {{w.name}}</a\n >\n <a\n href="#"\n v-if="activeWindow && closeWindow"\n @click.prevent="closeWindow(activeWindow)"\n >❌ Close Window</a\n >\n </div>\n</div>\n'},function(e,t){e.exports='<template v-if="type===\'standard\'">\n <hsc-window-style-material>\n <hsc-window\n v-for="w in windows"\n :key="w.id"\n v-show="!w.hidden"\n :title="w.name"\n :minimize-style="{display: \'none\'}"\n :close-button="!w.disable_close"\n @close="closeWindow(w)"\n :size-state.sync="w.sizeState"\n :maximize-button="true"\n :resizable="true"\n :width="w.w*30"\n :height="w.h*30"\n :resizable="true"\n @resize-start="windowSizePosChanging = true"\n @resize-end="windowSizePosChanging = false"\n @move-start="windowSizePosChanging = true"\n @move-end="windowSizePosChanging = false"\n >\n <div\n :class="{\'block-pointer-events\': windowSizePosChanging }"\n :id="w.window_id"\n class="imjoy-window-container"\n ></div>\n </hsc-window>\n </hsc-window-style-material>\n</template>\n<template v-else>\n <div\n v-for="w in windows"\n v-show="w === activeWindow"\n :key="w.id"\n class="imjoy-windows"\n :style="windowStyle"\n >\n <div\n v-if="showWindowTitle"\n style="text-align: center;height:24px; background: #cacaca66;"\n >\n <span\n style="font-size:1rem;font-family: Arial, Helvetica, sans-serif;line-height: 24px;"\n >{{ w.name }}</span\n >\n </div>\n <div\n :id="w.window_id"\n class="imjoy-window-container"\n :style="{height: showWindowTitle?\'calc(100% - 24px)\': \'100%\'}"\n ></div>\n </div>\n</template>\n<div\n v-if="showEmpty && (!activeWindow || windows.length <= 0)"\n class="imjoy-windows"\n :style="windowStyle"\n>\n <img\n style="width:80px; position:absolute; left:50%; top: 50%; transform: translate(-50%, -50%);"\n src="https://imjoy.io/static/img/imjoy-icon.svg"\n />\n</div>\n'},function(e,t,n){var r,i=function(){var e=String.fromCharCode,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",r={};function i(e,t){if(!r[e]){r[e]={};for(var n=0;n<e.length;n++)r[e][e.charAt(n)]=n}return r[e][t]}var o={compressToBase64:function(e){if(null==e)return"";var n=o._compress(e,6,(function(e){return t.charAt(e)}));switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(e){return null==e?"":""==e?null:o._decompress(e.length,32,(function(n){return i(t,e.charAt(n))}))},compressToUTF16:function(t){return null==t?"":o._compress(t,15,(function(t){return e(t+32)}))+" "},decompressFromUTF16:function(e){return null==e?"":""==e?null:o._decompress(e.length,16384,(function(t){return e.charCodeAt(t)-32}))},compressToUint8Array:function(e){for(var t=o.compress(e),n=new Uint8Array(2*t.length),r=0,i=t.length;r<i;r++){var s=t.charCodeAt(r);n[2*r]=s>>>8,n[2*r+1]=s%256}return n},decompressFromUint8Array:function(t){if(null==t)return o.decompress(t);for(var n=new Array(t.length/2),r=0,i=n.length;r<i;r++)n[r]=256*t[2*r]+t[2*r+1];var s=[];return n.forEach((function(t){s.push(e(t))})),o.decompress(s.join(""))},compressToEncodedURIComponent:function(e){return null==e?"":o._compress(e,6,(function(e){return n.charAt(e)}))},decompressFromEncodedURIComponent:function(e){return null==e?"":""==e?null:(e=e.replace(/ /g,"+"),o._decompress(e.length,32,(function(t){return i(n,e.charAt(t))})))},compress:function(t){return o._compress(t,16,(function(t){return e(t)}))},_compress:function(e,t,n){if(null==e)return"";var r,i,o,s={},a={},c="",u="",l="",h=2,d=3,p=2,f=[],m=0,g=0;for(o=0;o<e.length;o+=1)if(c=e.charAt(o),Object.prototype.hasOwnProperty.call(s,c)||(s[c]=d++,a[c]=!0),u=l+c,Object.prototype.hasOwnProperty.call(s,u))l=u;else{if(Object.prototype.hasOwnProperty.call(a,l)){if(l.charCodeAt(0)<256){for(r=0;r<p;r++)m<<=1,g==t-1?(g=0,f.push(n(m)),m=0):g++;for(i=l.charCodeAt(0),r=0;r<8;r++)m=m<<1|1&i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i>>=1}else{for(i=1,r=0;r<p;r++)m=m<<1|i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i=0;for(i=l.charCodeAt(0),r=0;r<16;r++)m=m<<1|1&i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i>>=1}0==--h&&(h=Math.pow(2,p),p++),delete a[l]}else for(i=s[l],r=0;r<p;r++)m=m<<1|1&i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i>>=1;0==--h&&(h=Math.pow(2,p),p++),s[u]=d++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(a,l)){if(l.charCodeAt(0)<256){for(r=0;r<p;r++)m<<=1,g==t-1?(g=0,f.push(n(m)),m=0):g++;for(i=l.charCodeAt(0),r=0;r<8;r++)m=m<<1|1&i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i>>=1}else{for(i=1,r=0;r<p;r++)m=m<<1|i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i=0;for(i=l.charCodeAt(0),r=0;r<16;r++)m=m<<1|1&i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i>>=1}0==--h&&(h=Math.pow(2,p),p++),delete a[l]}else for(i=s[l],r=0;r<p;r++)m=m<<1|1&i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i>>=1;0==--h&&(h=Math.pow(2,p),p++)}for(i=2,r=0;r<p;r++)m=m<<1|1&i,g==t-1?(g=0,f.push(n(m)),m=0):g++,i>>=1;for(;;){if(m<<=1,g==t-1){f.push(n(m));break}g++}return f.join("")},decompress:function(e){return null==e?"":""==e?null:o._decompress(e.length,32768,(function(t){return e.charCodeAt(t)}))},_decompress:function(t,n,r){var i,o,s,a,c,u,l,h=[],d=4,p=4,f=3,m="",g=[],_={val:r(0),position:n,index:1};for(i=0;i<3;i+=1)h[i]=i;for(s=0,c=Math.pow(2,2),u=1;u!=c;)a=_.val&_.position,_.position>>=1,0==_.position&&(_.position=n,_.val=r(_.index++)),s|=(a>0?1:0)*u,u<<=1;switch(s){case 0:for(s=0,c=Math.pow(2,8),u=1;u!=c;)a=_.val&_.position,_.position>>=1,0==_.position&&(_.position=n,_.val=r(_.index++)),s|=(a>0?1:0)*u,u<<=1;l=e(s);break;case 1:for(s=0,c=Math.pow(2,16),u=1;u!=c;)a=_.val&_.position,_.position>>=1,0==_.position&&(_.position=n,_.val=r(_.index++)),s|=(a>0?1:0)*u,u<<=1;l=e(s);break;case 2:return""}for(h[3]=l,o=l,g.push(l);;){if(_.index>t)return"";for(s=0,c=Math.pow(2,f),u=1;u!=c;)a=_.val&_.position,_.position>>=1,0==_.position&&(_.position=n,_.val=r(_.index++)),s|=(a>0?1:0)*u,u<<=1;switch(l=s){case 0:for(s=0,c=Math.pow(2,8),u=1;u!=c;)a=_.val&_.position,_.position>>=1,0==_.position&&(_.position=n,_.val=r(_.index++)),s|=(a>0?1:0)*u,u<<=1;h[p++]=e(s),l=p-1,d--;break;case 1:for(s=0,c=Math.pow(2,16),u=1;u!=c;)a=_.val&_.position,_.position>>=1,0==_.position&&(_.position=n,_.val=r(_.index++)),s|=(a>0?1:0)*u,u<<=1;h[p++]=e(s),l=p-1,d--;break;case 2:return g.join("")}if(0==d&&(d=Math.pow(2,f),f++),h[l])m=h[l];else{if(l!==p)return null;m=o+o.charAt(0)}g.push(m),h[p++]=o+m.charAt(0),o=m,0==--d&&(d=Math.pow(2,f),f++)}}};return o}();void 0===(r=function(){return i}.call(t,n,t,e))||(e.exports=r)},function(e,t,n){var r=n(33),i=n(85),o=n(86),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?i(e):o(e)}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,n){"use strict";var r=n(15);e.exports=r.DEFAULT=new r({include:[n(18)],explicit:[n(175),n(176),n(177)]})},function(e,t,n){"use strict";n.d(t,"a",(function(){return F}));var r=/\r?\n/g,i=/^\s*$/,o=/^(\r?\n)*[\t\s]/;function s(e,t){for(var n=0;e.charAt(n)===t;)n++;return n}Object.freeze({});Object.prototype.toString;function a(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i<r.length;i++)n[r[i]]=!0;return t?function(e){return n[e.toLowerCase()]}:function(e){return n[e]}}a("slot,component",!0),a("key,ref,slot,slot-scope,is");Object.prototype.hasOwnProperty;var c,u,l=/-(\w)/g;c=function(e){return e.replace(l,(function(e,t){return t?t.toUpperCase():""}))},u=Object.create(null);Function.prototype.bind;var h=function(e,t,n){return!1};a("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),a("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source");var d=a("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),p=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,f="((?:[a-zA-Z_][\\w\\-\\.]*\\:)?[a-zA-Z_][\\w\\-\\.]*)",m=new RegExp("^<"+f),g=/^\s*(\/?)>/,_=new RegExp("^<\\/"+f+"[^>]*>"),y=/^<!DOCTYPE [^>]+>/i,v=/^<!\--/,b=/^<!\[/,w=!1;"x".replace(/x(.)?/g,(function(e,t){w=""===t}));var x=a("script,style,textarea",!0),k={},E={"<":"<",">":">",""":'"',"&":"&"," ":"\n","	":"\t"},j=/&(?:lt|gt|quot|amp);/g,A=/&(?:lt|gt|quot|amp|#10|#9);/g,D=a("pre,textarea",!0),S=function(e,t){return e&&D(e)&&"\n"===t[0]};function C(e,t){var n=t?A:j;return e.replace(n,(function(e){return E[e]}))}var O=/\r?\n/g,P=/./g;a("script,style,template",!0);function F(e,t){void 0===t&&(t={});var n={script:[],style:[],config:[],window:[],docs:[],attachment:[],link:[],others:[]},a=0,c=null;return function(e,t){for(var n,r,i=[],o=t.expectHTML,s=t.isUnaryTag||h,a=t.canBeLeftOpenTag||h,c=0;e;){if(n=e,r&&x(r)){var u=0,l=r.toLowerCase(),f=k[l]||(k[l]=new RegExp("([\\s\\S]*?)(</"+l+"[^>]*>)","i")),E=e.replace(f,(function(e,n,r){return u=r.length,x(l)||"noscript"===l||(n=n.replace(/<!\--([\s\S]*?)-->/g,"$1").replace(/<!\[CDATA\[([\s\S]*?)]]>/g,"$1")),S(l,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""}));c+=e.length-E.length,e=E,N(l,c-u,c)}else{var j=e.indexOf("<");if(0===j){if(v.test(e)){var A=e.indexOf("--\x3e");if(A>=0){t.shouldKeepComment&&t.comment(e.substring(4,A)),M(A+3);continue}}if(b.test(e)){var D=e.indexOf("]>");if(D>=0){M(D+2);continue}}var O=e.match(y);if(O){M(O[0].length);continue}var P=e.match(_);if(P){var F=c;M(P[0].length),N(P[1],F,c);continue}var I=q();if(I){L(I),S(r,e)&&M(1);continue}}var T=void 0,R=void 0,B=void 0;if(j>=0){for(R=e.slice(j);!(_.test(R)||m.test(R)||v.test(R)||b.test(R)||(B=R.indexOf("<",1))<0);)j+=B,R=e.slice(j);T=e.substring(0,j),M(j)}j<0&&(T=e,e=""),t.chars&&T&&t.chars(T)}if(e===n){t.chars&&t.chars(e),!i.length&&t.warn&&t.warn('Mal-formatted tag at end of template: "'+e+'"');break}}function M(t){c+=t,e=e.substring(t)}function q(){var t=e.match(m);if(t){var n,r,i={tagName:t[1],attrs:[],start:c};for(M(t[0].length);!(n=e.match(g))&&(r=e.match(p));)M(r[0].length),i.attrs.push(r);if(n)return i.unarySlash=n[1],M(n[0].length),i.end=c,i}}function L(e){var n=e.tagName,c=e.unarySlash;o&&("p"===r&&d(n)&&N(r),a(n)&&r===n&&N(n));for(var u=s(n)||!!c,l=e.attrs.length,h=new Array(l),p=0;p<l;p++){var f=e.attrs[p];w&&-1===f[0].indexOf('""')&&(""===f[3]&&delete f[3],""===f[4]&&delete f[4],""===f[5]&&delete f[5]);var m=f[3]||f[4]||f[5]||"",g="a"===n&&"href"===f[1]?t.shouldDecodeNewlinesForHref:t.shouldDecodeNewlines;h[p]={name:f[1],value:C(m,g)}}u||(i.push({tag:n,lowerCasedTag:n.toLowerCase(),attrs:h}),r=n),t.start&&t.start(n,h,u,e.start,e.end)}function N(e,n,o){var s,a;if(null==n&&(n=c),null==o&&(o=c),e&&(a=e.toLowerCase()),e)for(s=i.length-1;s>=0&&i[s].lowerCasedTag!==a;s--);else s=0;if(s>=0){for(var u=i.length-1;u>=s;u--)(u>s||!e)&&t.warn&&t.warn("tag <"+i[u].tag+"> has no matching end tag."),t.end&&t.end(i[u].tag,n,o);i.length=s,r=s&&i[s-1].tag}else"br"===a?t.start&&t.start(e,[],!0,n,o):"p"===a&&(t.start&&t.start(e,[],!1,n,o),t.end&&t.end(e,n,o))}N()}(e,{start:function(e,t,r,i,o){0===a&&(c={type:e,content:"",start:o,attrs:t.reduce((function(e,t){var n=t.name,r=t.value;return e[n]=r||!0,e}),{})},n[e]?(!function(e,t){for(var n=0;n<t.length;n++){var r=t[n];"lang"===r.name&&(e.lang=r.value),"scoped"===r.name&&(e.scoped=!0),"module"===r.name&&(e.module=r.value||!0),"src"===r.name&&(e.src=r.value)}}(c,t),n[e].push(c)):n.others.push(c)),r||a++},end:function(n,u,l){if(1===a&&c){c.end=u;var h=function(e){if(!o.test(e))return e;for(var t,n,a,c=e.split(r),u=1/0,l=0;l<c.length;l++){var h=c[l];if(!i.test(h))if(t)(n=s(h,t))<u&&(u=n);else{if(" "!==(a=h.charAt(0))&&"\t"!==a)return e;(n=s(h,t=a))<u&&(u=n)}}return c.map((function(e){return e.slice(u)})).join("\n")}(e.slice(c.start,c.end));"template"!==c.type&&t.pad&&(h=function(t,n){if("space"===n)return e.slice(0,t.start).replace(P," ");var r=e.slice(0,t.start).split(O).length,i="script"!==t.type||t.lang?"\n":"//\n";return Array(r).join(i)}(c,t.pad)+h),c.content=h,c=null}a--}}),n}},function(e,t,n){
/*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.0.8/LICENSE */
e.exports=function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.keys,i=Object.freeze,o=Object.seal,s=Object.create,a="undefined"!=typeof Reflect&&Reflect,c=a.apply,u=a.construct;c||(c=function(e,t,n){return e.apply(t,n)}),i||(i=function(e){return e}),o||(o=function(e){return e}),u||(u=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))});var l=E(Array.prototype.forEach),h=E(Array.prototype.indexOf),d=E(Array.prototype.join),p=E(Array.prototype.pop),f=E(Array.prototype.push),m=E(Array.prototype.slice),g=E(String.prototype.toLowerCase),_=E(String.prototype.match),y=E(String.prototype.replace),v=E(String.prototype.indexOf),b=E(String.prototype.trim),w=E(RegExp.prototype.test),x=j(RegExp),k=j(TypeError);function E(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return c(e,t,r)}}function j(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return u(e,n)}}function A(e,r){t&&t(e,null);for(var i=r.length;i--;){var o=r[i];if("string"==typeof o){var s=g(o);s!==o&&(n(r)||(r[i]=s),o=s)}e[o]=!0}return e}function D(t){var n=s(null),r=void 0;for(r in t)c(e,t,[r])&&(n[r]=t[r]);return n}var S=i(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),C=i(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","audio","canvas","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","video","view","vkern"]),O=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),P=i(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),F=i(["#text"]),I=i(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns"]),T=i(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),R=i(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),B=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),M=o(/\{\{[\s\S]*|[\s\S]*\}\}/gm),q=o(/<%[\s\S]*|[\s\S]*%>/gm),L=o(/^data-[\-\w.\u00B7-\uFFFF]/),N=o(/^aria-[\-\w]+$/),U=o(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=o(/^(?:\w+script|data):/i),$=o(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function J(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var H=function(){return"undefined"==typeof window?null:window},K=function(e,t){if("object"!==(void 0===e?"undefined":z(e))||"function"!=typeof e.createPolicy)return null;var n=null;t.currentScript&&t.currentScript.hasAttribute("data-tt-policy-suffix")&&(n=t.currentScript.getAttribute("data-tt-policy-suffix"));var r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:H(),n=function(t){return e(t)};if(n.version="2.0.17",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var o=t.document,s=!1,a=t.document,c=t.DocumentFragment,u=t.HTMLTemplateElement,E=t.Node,j=t.NodeFilter,V=t.NamedNodeMap,X=void 0===V?t.NamedNodeMap||t.MozNamedAttrMap:V,Y=t.Text,G=t.Comment,Q=t.DOMParser,Z=t.trustedTypes;if("function"==typeof u){var ee=a.createElement("template");ee.content&&ee.content.ownerDocument&&(a=ee.content.ownerDocument)}var te=K(Z,o),ne=te&&Re?te.createHTML(""):"",re=a,ie=re.implementation,oe=re.createNodeIterator,se=re.getElementsByTagName,ae=re.createDocumentFragment,ce=o.importNode,ue={};try{ue=D(a).documentMode?a.documentMode:{}}catch(e){}var le={};n.isSupported=ie&&void 0!==ie.createHTMLDocument&&9!==ue;var he=M,de=q,pe=L,fe=N,me=W,ge=$,_e=U,ye=null,ve=A({},[].concat(J(S),J(C),J(O),J(P),J(F))),be=null,we=A({},[].concat(J(I),J(T),J(R),J(B))),xe=null,ke=null,Ee=!0,je=!0,Ae=!1,De=!1,Se=!1,Ce=!1,Oe=!1,Pe=!1,Fe=!1,Ie=!1,Te=!1,Re=!1,Be=!0,Me=!0,qe=!1,Le={},Ne=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","plaintext","script","style","svg","template","thead","title","video","xmp"]),Ue=null,We=A({},["audio","video","img","source","image","track"]),$e=null,ze=A({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),Je=null,He=a.createElement("form"),Ke=function(e){Je&&Je===e||(e&&"object"===(void 0===e?"undefined":z(e))||(e={}),e=D(e),ye="ALLOWED_TAGS"in e?A({},e.ALLOWED_TAGS):ve,be="ALLOWED_ATTR"in e?A({},e.ALLOWED_ATTR):we,$e="ADD_URI_SAFE_ATTR"in e?A(D(ze),e.ADD_URI_SAFE_ATTR):ze,Ue="ADD_DATA_URI_TAGS"in e?A(D(We),e.ADD_DATA_URI_TAGS):We,xe="FORBID_TAGS"in e?A({},e.FORBID_TAGS):{},ke="FORBID_ATTR"in e?A({},e.FORBID_ATTR):{},Le="USE_PROFILES"in e&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,je=!1!==e.ALLOW_DATA_ATTR,Ae=e.ALLOW_UNKNOWN_PROTOCOLS||!1,De=e.SAFE_FOR_JQUERY||!1,Se=e.SAFE_FOR_TEMPLATES||!1,Ce=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,Ie=e.RETURN_DOM_FRAGMENT||!1,Te=e.RETURN_DOM_IMPORT||!1,Re=e.RETURN_TRUSTED_TYPE||!1,Pe=e.FORCE_BODY||!1,Be=!1!==e.SANITIZE_DOM,Me=!1!==e.KEEP_CONTENT,qe=e.IN_PLACE||!1,_e=e.ALLOWED_URI_REGEXP||_e,Se&&(je=!1),Ie&&(Fe=!0),Le&&(ye=A({},[].concat(J(F))),be=[],!0===Le.html&&(A(ye,S),A(be,I)),!0===Le.svg&&(A(ye,C),A(be,T),A(be,B)),!0===Le.svgFilters&&(A(ye,O),A(be,T),A(be,B)),!0===Le.mathMl&&(A(ye,P),A(be,R),A(be,B))),e.ADD_TAGS&&(ye===ve&&(ye=D(ye)),A(ye,e.ADD_TAGS)),e.ADD_ATTR&&(be===we&&(be=D(be)),A(be,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&A($e,e.ADD_URI_SAFE_ATTR),Me&&(ye["#text"]=!0),Ce&&A(ye,["html","head","body"]),ye.table&&(A(ye,["tbody"]),delete xe.tbody),i&&i(e),Je=e)},Ve=function(e){f(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.outerHTML=ne}},Xe=function(e,t){try{f(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(n.removed,{attribute:null,from:t})}t.removeAttribute(e)},Ye=function(e){var t=void 0,n=void 0;if(Pe)e="<remove></remove>"+e;else{var r=_(e,/^[\r\n\t ]+/);n=r&&r[0]}var i=te?te.createHTML(e):e;try{t=(new Q).parseFromString(i,"text/html")}catch(e){}if(s&&A(xe,["title"]),!t||!t.documentElement){var o=(t=ie.createHTMLDocument("")).body;o.parentNode.removeChild(o.parentNode.firstElementChild),o.outerHTML=i}return e&&n&&t.body.insertBefore(a.createTextNode(n),t.body.childNodes[0]||null),se.call(t,Ce?"html":"body")[0]};n.isSupported&&function(){try{var e=Ye("<x/><title></title><img>");w(/<\/title/,e.querySelector("title").innerHTML)&&(s=!0)}catch(e){}}();var Ge=function(e){return oe.call(e.ownerDocument||e,e,j.SHOW_ELEMENT|j.SHOW_COMMENT|j.SHOW_TEXT,(function(){return j.FILTER_ACCEPT}),!1)},Qe=function(e){return!(e instanceof Y||e instanceof G||"string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof X&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI)},Ze=function(e){return"object"===(void 0===E?"undefined":z(E))?e instanceof E:e&&"object"===(void 0===e?"undefined":z(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},et=function(e,t,r){le[e]&&l(le[e],(function(e){e.call(n,t,r,Je)}))},tt=function(e){var t=void 0;if(et("beforeSanitizeElements",e,null),Qe(e))return Ve(e),!0;if(_(e.nodeName,/[\u0080-\uFFFF]/))return Ve(e),!0;var r=g(e.nodeName);if(et("uponSanitizeElement",e,{tagName:r,allowedTags:ye}),("svg"===r||"math"===r)&&0!==e.querySelectorAll("p, br, form, table").length)return Ve(e),!0;if(!ye[r]||xe[r]){if(Me&&!Ne[r]&&"function"==typeof e.insertAdjacentHTML)try{var i=e.innerHTML;e.insertAdjacentHTML("AfterEnd",te?te.createHTML(i):i)}catch(e){}return Ve(e),!0}return"noscript"===r&&w(/<\/noscript/i,e.innerHTML)||"noembed"===r&&w(/<\/noembed/i,e.innerHTML)?(Ve(e),!0):(!De||Ze(e.firstElementChild)||Ze(e.content)&&Ze(e.content.firstElementChild)||!w(/</g,e.textContent)||(f(n.removed,{element:e.cloneNode()}),e.innerHTML?e.innerHTML=y(e.innerHTML,/</g,"<"):e.innerHTML=y(e.textContent,/</g,"<")),Se&&3===e.nodeType&&(t=e.textContent,t=y(t,he," "),t=y(t,de," "),e.textContent!==t&&(f(n.removed,{element:e.cloneNode()}),e.textContent=t)),et("afterSanitizeElements",e,null),!1)},nt=function(e,t,n){if(Be&&("id"===t||"name"===t)&&(n in a||n in He))return!1;if(je&&w(pe,t));else if(Ee&&w(fe,t));else{if(!be[t]||ke[t])return!1;if($e[t]);else if(w(_e,y(n,ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!Ue[e])if(Ae&&!w(me,y(n,ge,"")));else if(n)return!1}return!0},rt=function(e){var t=void 0,i=void 0,o=void 0,s=void 0,a=void 0;et("beforeSanitizeAttributes",e,null);var c=e.attributes;if(c){var u={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:be};for(a=c.length;a--;){var l=t=c[a],f=l.name,_=l.namespaceURI;if(i=b(t.value),o=g(f),u.attrName=o,u.attrValue=i,u.keepAttr=!0,u.forceKeepAttr=void 0,et("uponSanitizeAttribute",e,u),i=u.attrValue,!u.forceKeepAttr){if("name"===o&&"IMG"===e.nodeName&&c.id)s=c.id,c=m(c,[]),Xe("id",e),Xe(f,e),h(c,s)>a&&e.setAttribute("id",s.value);else{if("INPUT"===e.nodeName&&"type"===o&&"file"===i&&u.keepAttr&&(be[o]||!ke[o]))continue;"id"===f&&e.setAttribute(f,""),Xe(f,e)}if(u.keepAttr)if(De&&w(/\/>/i,i))Xe(f,e);else if(w(/svg|math/i,e.namespaceURI)&&w(x("</("+d(r(Ne),"|")+")","i"),i))Xe(f,e);else{Se&&(i=y(i,he," "),i=y(i,de," "));var v=e.nodeName.toLowerCase();if(nt(v,o,i))try{_?e.setAttributeNS(_,f,i):e.setAttribute(f,i),p(n.removed)}catch(e){}}}}et("afterSanitizeAttributes",e,null)}},it=function e(t){var n=void 0,r=Ge(t);for(et("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)et("uponSanitizeShadowNode",n,null),tt(n)||(n.content instanceof c&&e(n.content),rt(n));et("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,r){var i=void 0,s=void 0,a=void 0,u=void 0,l=void 0;if(e||(e="\x3c!--\x3e"),"string"!=typeof e&&!Ze(e)){if("function"!=typeof e.toString)throw k("toString is not a function");if("string"!=typeof(e=e.toString()))throw k("dirty is not a string, aborting")}if(!n.isSupported){if("object"===z(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Ze(e))return t.toStaticHTML(e.outerHTML)}return e}if(Oe||Ke(r),n.removed=[],"string"==typeof e&&(qe=!1),qe);else if(e instanceof E)1===(s=(i=Ye("\x3c!--\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s);else{if(!Fe&&!Se&&!Ce&&-1===e.indexOf("<"))return te&&Re?te.createHTML(e):e;if(!(i=Ye(e)))return Fe?null:ne}i&&Pe&&Ve(i.firstChild);for(var h=Ge(qe?e:i);a=h.nextNode();)3===a.nodeType&&a===u||tt(a)||(a.content instanceof c&&it(a.content),rt(a),u=a);if(u=null,qe)return e;if(Fe){if(Ie)for(l=ae.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return Te&&(l=ce.call(o,l,!0)),l}var d=Ce?i.outerHTML:i.innerHTML;return Se&&(d=y(d,he," "),d=y(d,de," ")),te&&Re?te.createHTML(d):d},n.setConfig=function(e){Ke(e),Oe=!0},n.clearConfig=function(){Je=null,Oe=!1},n.isValidAttribute=function(e,t,n){Je||Ke({});var r=g(e),i=g(t);return nt(r,i,n)},n.addHook=function(e,t){"function"==typeof t&&(le[e]=le[e]||[],f(le[e],t))},n.removeHook=function(e){le[e]&&p(le[e])},n.removeHooks=function(e){le[e]&&(le[e]=[])},n.removeAllHooks=function(){le={}},n}()}()},function(e,t,n){e.exports={imjoyRPC:n(181),imjoyRPCSocketIO:n(182)}},function(e,t,n){e.exports=function(e){"use strict";var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],o=e[3];r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|o>>>20)+n|0)&n|~o&r)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|o>>>20)+n|0)&n|~o&r)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|o>>>20)+n|0)&n|~o&r)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|o>>>20)+n|0)&n|~o&r)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|o>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+o|0)&n|o&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|o>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+o|0)&n|o&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|o>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+o|0)&n|o&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|o>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&n|o&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|o>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|o>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|o>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|o>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function o(e){var t,i,o,s,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)n(l,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),c=parseInt(s[1],16)||0,o[14]=a,o[15]=c,n(l,o),l}function s(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function a(e){var t;for(t=0;t<e.length;t+=1)e[t]=s(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function u(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function l(){this.reset()}return a(o("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,s,a,c=this.byteLength,u=t(n,c),l=c;return r!==e&&(l=t(r,c)),u>l?new ArrayBuffer(0):(i=l-u,o=new ArrayBuffer(i),s=new Uint8Array(o),a=new Uint8Array(this,u,i),s.set(a),o)}}(),l.prototype.append=function(e){return this.appendBinary(c(e)),this},l.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},l.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=a(this._hash),e&&(n=u(n)),this.reset(),n},l.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},l.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},l.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},l.prototype._finish=function(e,t){var r,i,o,s=t;if(e[s>>2]|=128<<(s%4<<3),s>55)for(n(this._hash,e),s=0;s<16;s+=1)e[s]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,n(this._hash,e)},l.hash=function(e,t){return l.hashBinary(c(e),t)},l.hashBinary=function(e,t){var n=a(o(e));return t?u(n):n},l.ArrayBuffer=function(){this.reset()},l.ArrayBuffer.prototype.append=function(e){var t,r,o,s,a,c=(r=this._buff.buffer,o=e,s=!0,(a=new Uint8Array(r.byteLength+o.byteLength)).set(new Uint8Array(r)),a.set(new Uint8Array(o),r.byteLength),s?a:a.buffer),u=c.length;for(this._length+=e.byteLength,t=64;t<=u;t+=64)n(this._hash,i(c.subarray(t-64,t)));return this._buff=t-64<u?new Uint8Array(c.buffer.slice(t-64)):new Uint8Array(0),this},l.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=a(this._hash),e&&(n=u(n)),this.reset(),n},l.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.ArrayBuffer.prototype.getState=function(){var e,t=l.prototype.getState.call(this);return t.buff=(e=t.buff,String.fromCharCode.apply(null,new Uint8Array(e))),t},l.ArrayBuffer.prototype.setState=function(e){return e.buff=function(e,t){var n,r=e.length,i=new ArrayBuffer(r),o=new Uint8Array(i);for(n=0;n<r;n+=1)o[n]=e.charCodeAt(n);return t?o:i}(e.buff,!0),l.prototype.setState.call(this,e)},l.ArrayBuffer.prototype.destroy=l.prototype.destroy,l.ArrayBuffer.prototype._finish=l.prototype._finish,l.ArrayBuffer.hash=function(e,t){var r=a(function(e){var t,r,o,s,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)n(l,i(e.subarray(t-64,t)));for(e=t-64<u?e.subarray(t-64):new Uint8Array(0),r=e.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)o[t>>2]|=e[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),c=parseInt(s[1],16)||0,o[14]=a,o[15]=c,n(l,o),l}(new Uint8Array(e)));return t?u(r):r},l}()},function(e,t,n){e.exports=function(e){"use strict";var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],o=e[3];r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|o>>>20)+n|0)&n|~o&r)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|o>>>20)+n|0)&n|~o&r)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|o>>>20)+n|0)&n|~o&r)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|o>>>20)+n|0)&n|~o&r)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|o>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+o|0)&n|o&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|o>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+o|0)&n|o&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|o>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+o|0)&n|o&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|o>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&n|o&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|o>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|o>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|o>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|o>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function o(e){var t,i,o,s,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)n(l,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),c=parseInt(s[1],16)||0,o[14]=a,o[15]=c,n(l,o),l}function s(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function a(e){var t;for(t=0;t<e.length;t+=1)e[t]=s(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function u(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function l(){this.reset()}return a(o("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,s,a,c=this.byteLength,u=t(n,c),l=c;return r!==e&&(l=t(r,c)),u>l?new ArrayBuffer(0):(i=l-u,o=new ArrayBuffer(i),s=new Uint8Array(o),a=new Uint8Array(this,u,i),s.set(a),o)}}(),l.prototype.append=function(e){return this.appendBinary(c(e)),this},l.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},l.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=a(this._hash),e&&(n=u(n)),this.reset(),n},l.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},l.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},l.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},l.prototype._finish=function(e,t){var r,i,o,s=t;if(e[s>>2]|=128<<(s%4<<3),s>55)for(n(this._hash,e),s=0;s<16;s+=1)e[s]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,n(this._hash,e)},l.hash=function(e,t){return l.hashBinary(c(e),t)},l.hashBinary=function(e,t){var n=a(o(e));return t?u(n):n},l.ArrayBuffer=function(){this.reset()},l.ArrayBuffer.prototype.append=function(e){var t,r,o,s,a,c=(r=this._buff.buffer,o=e,s=!0,(a=new Uint8Array(r.byteLength+o.byteLength)).set(new Uint8Array(r)),a.set(new Uint8Array(o),r.byteLength),s?a:a.buffer),u=c.length;for(this._length+=e.byteLength,t=64;t<=u;t+=64)n(this._hash,i(c.subarray(t-64,t)));return this._buff=t-64<u?new Uint8Array(c.buffer.slice(t-64)):new Uint8Array(0),this},l.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=a(this._hash),e&&(n=u(n)),this.reset(),n},l.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.ArrayBuffer.prototype.getState=function(){var e,t=l.prototype.getState.call(this);return t.buff=(e=t.buff,String.fromCharCode.apply(null,new Uint8Array(e))),t},l.ArrayBuffer.prototype.setState=function(e){return e.buff=function(e,t){var n,r=e.length,i=new ArrayBuffer(r),o=new Uint8Array(i);for(n=0;n<r;n+=1)o[n]=e.charCodeAt(n);return t?o:i}(e.buff,!0),l.prototype.setState.call(this,e)},l.ArrayBuffer.prototype.destroy=l.prototype.destroy,l.ArrayBuffer.prototype._finish=l.prototype._finish,l.ArrayBuffer.hash=function(e,t){var r=a(function(e){var t,r,o,s,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)n(l,i(e.subarray(t-64,t)));for(e=t-64<u?e.subarray(t-64):new Uint8Array(0),r=e.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)o[t>>2]|=e[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(l,o),t=0;t<16;t+=1)o[t]=0;return s=(s=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),c=parseInt(s[1],16)||0,o[14]=a,o[15]=c,n(l,o),l}(new Uint8Array(e)));return t?u(r):r},l}()},function(e,t,n){var r=n(34).Symbol;e.exports=r},function(e,t,n){var r=n(44),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();e.exports=o},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,n){var r=n(50),i=n(53);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},function(e,t,n){"use strict";(function(t){var r=n(4),i=n(142),o=n(60),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==t&&"[object process]"===Object.prototype.toString.call(t))&&(c=n(61)),c),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),JSON.stringify(e)):e}],transformResponse:[function(e){var t=this.transitional,n=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||i&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw o(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){u.headers[e]=r.merge(s)})),e.exports=u}).call(this,n(57))},function(e,t,n){"use strict";var r=n(15);e.exports=new r({explicit:[n(158),n(159),n(160)]})},function(e,t,n){"use strict";var r=n(184),i=n(40),o=n(16),s=n(68),a=n(186);function c(e,t,n){var r=this._refs[n];if("string"==typeof r){if(!this._refs[r])return c.call(this,e,t,r);r=this._refs[r]}if((r=r||this._schemas[n])instanceof s)return f(r.schema,this._opts.inlineRefs)?r.schema:r.validate||this._compile(r);var i,o,a,l=u.call(this,t,n);return l&&(i=l.schema,t=l.root,a=l.baseId),i instanceof s?o=i.validate||e.call(this,i.schema,t,void 0,a):void 0!==i&&(o=f(i,this._opts.inlineRefs)?i:e.call(this,i,t,void 0,a)),o}function u(e,t){var n=r.parse(t),i=g(n),o=m(this._getId(e.schema));if(0===Object.keys(e.schema).length||i!==o){var a=y(i),c=this._refs[a];if("string"==typeof c)return l.call(this,e,c,n);if(c instanceof s)c.validate||this._compile(c),e=c;else{if(!((c=this._schemas[a])instanceof s))return;if(c.validate||this._compile(c),a==y(t))return{schema:c,root:e,baseId:o};e=c}if(!e.schema)return;o=m(this._getId(e.schema))}return d.call(this,n,o,e.schema,e)}function l(e,t,n){var r=u.call(this,e,t);if(r){var i=r.schema,o=r.baseId;e=r.root;var s=this._getId(i);return s&&(o=v(o,s)),d.call(this,n,o,i,e)}}e.exports=c,c.normalizeId=y,c.fullPath=m,c.url=v,c.ids=function(e){var t=y(this._getId(e)),n={"":t},s={"":m(t,!1)},c={},u=this;return a(e,{allKeys:!0},(function(e,t,a,l,h,d,p){if(""!==t){var f=u._getId(e),m=n[l],g=s[l]+"/"+h;if(void 0!==p&&(g+="/"+("number"==typeof p?p:o.escapeFragment(p))),"string"==typeof f){f=m=y(m?r.resolve(m,f):f);var _=u._refs[f];if("string"==typeof _&&(_=u._refs[_]),_&&_.schema){if(!i(e,_.schema))throw new Error('id "'+f+'" resolves to more than one schema')}else if(f!=y(g))if("#"==f[0]){if(c[f]&&!i(e,c[f]))throw new Error('id "'+f+'" resolves to more than one schema');c[f]=e}else u._refs[f]=g}n[t]=m,s[t]=g}})),c},c.inlineRef=f,c.schema=u;var h=o.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function d(e,t,n,r){if(e.fragment=e.fragment||"","/"==e.fragment.slice(0,1)){for(var i=e.fragment.split("/"),s=1;s<i.length;s++){var a=i[s];if(a){if(void 0===(n=n[a=o.unescapeFragment(a)]))break;var c;if(!h[a]&&((c=this._getId(n))&&(t=v(t,c)),n.$ref)){var l=v(t,n.$ref),d=u.call(this,r,l);d&&(n=d.schema,r=d.root,t=d.baseId)}}}return void 0!==n&&n!==r.schema?{schema:n,root:r,baseId:t}:void 0}}var p=o.toHash(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum"]);function f(e,t){return!1!==t&&(void 0===t||!0===t?function e(t){var n;if(Array.isArray(t)){for(var r=0;r<t.length;r++)if("object"==typeof(n=t[r])&&!e(n))return!1}else for(var i in t){if("$ref"==i)return!1;if("object"==typeof(n=t[i])&&!e(n))return!1}return!0}(e):t?function e(t){var n,r=0;if(Array.isArray(t)){for(var i=0;i<t.length;i++)if("object"==typeof(n=t[i])&&(r+=e(n)),r==1/0)return 1/0}else for(var o in t){if("$ref"==o)return 1/0;if(p[o])r++;else if("object"==typeof(n=t[o])&&(r+=e(n)+1),r==1/0)return 1/0}return r}(e)<=t:void 0)}function m(e,t){return!1!==t&&(e=y(e)),g(r.parse(e))}function g(e){return r.serialize(e).split("#")[0]+"#"}var _=/#\/?$/;function y(e){return e?e.replace(_,""):""}function v(e,t){return t=y(t),r.resolve(e,t)}},function(e,t,n){"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n}},function(e,t,n){"use strict";var r=n(39);function i(e,t,n){this.message=n||i.message(e,t),this.missingRef=r.url(e,t),this.missingSchema=r.normalizeId(r.fullPath(this.missingRef))}function o(e){return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}e.exports={Validation:o((function(e){this.message="validation failed",this.errors=e,this.ajv=this.validation=!0})),MissingRef:o(i)},i.message=function(e,t){return"can't resolve reference "+t+" from id "+e}},function(e,t,n){"use strict";function r(e,t,n){var r=n[n.length-1];e===r.element&&(n.pop(),r=n[n.length-1]);var i=r.element,o=r.index;if(Array.isArray(i))i.push(e);else if(o===t.length-2){i[t.pop()]=e}else t.push(e)}t.stringify=function(e){var t=[];t.push({obj:e});for(var n,r,i,o,s,a,c,u,l,h,d="";n=t.pop();)if(r=n.obj,d+=n.prefix||"",i=n.val||"")d+=i;else if("object"!=typeof r)d+=void 0===r?null:JSON.stringify(r);else if(null===r)d+="null";else if(Array.isArray(r)){for(t.push({val:"]"}),o=r.length-1;o>=0;o--)s=0===o?"":",",t.push({obj:r[o],prefix:s});t.push({val:"["})}else{for(c in a=[],r)r.hasOwnProperty(c)&&a.push(c);for(t.push({val:"}"}),o=a.length-1;o>=0;o--)l=r[u=a[o]],h=o>0?",":"",h+=JSON.stringify(u)+":",t.push({obj:l,prefix:h});t.push({val:"{"})}return d},t.parse=function(e){for(var t,n,i,o,s,a,c,u,l,h=[],d=[],p=0;;)if("}"!==(t=e[p++])&&"]"!==t&&void 0!==t)switch(t){case" ":case"\t":case"\n":case":":case",":break;case"n":p+=3,r(null,h,d);break;case"t":p+=3,r(!0,h,d);break;case"f":p+=4,r(!1,h,d);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"-":for(n="",p--;;){if(i=e[p++],!/[\d\.\-e\+]/.test(i)){p--;break}n+=i}r(parseFloat(n),h,d);break;case'"':for(o="",s=void 0,a=0;'"'!==(c=e[p++])||"\\"===s&&a%2==1;)o+=c,"\\"===(s=c)?a++:a=0;r(JSON.parse('"'+o+'"'),h,d);break;case"[":u={element:[],index:h.length},h.push(u.element),d.push(u);break;case"{":l={element:{},index:h.length},h.push(l.element),d.push(l);break;default:throw new Error("unexpectedly reached end of input: "+t)}else{if(1===h.length)return h.pop();r(h.pop(),h,d)}}},function(e,t,n){var r=n(33),i=n(83),o=n(45),s=n(84),a=r?r.prototype:void 0,c=a?a.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return i(t,e)+"";if(s(t))return c?c.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}},function(e,t,n){(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(13))},function(e,t){var n=Array.isArray;e.exports=n},function(e,t,n){var r=n(92),i=n(93),o=n(94);e.exports=function(e,t,n){return t==t?o(e,t,n):r(e,i,n)}},function(e,t,n){var r=n(48),i=n(51),o=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];o.call(e,t)&&i(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){var r=n(49);e.exports=function(e,t,n){"__proto__"==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},function(e,t,n){var r=n(101),i=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=i},function(e,t,n){var r=n(25),i=n(35);e.exports=function(e){if(!i(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},function(e,t){e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t){e.exports=function(e){return e}},function(e,t){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},function(e,t){var n=/^(?:0|[1-9]\d*)$/;e.exports=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&n.test(e))&&e>-1&&e%1==0&&e<t}},function(e,t){var n=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||n)}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],l=!1,h=-1;function d(){l&&c&&(l=!1,c.length?u=c.concat(u):h=-1,u.length&&p())}function p(){if(!l){var e=a(d);l=!0;for(var t=u.length;t;){for(c=u,u=[];++h<t;)c&&c[h].run();h=-1,t=u.length}c=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new f(e,t)),1!==u.length||l||a(p)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(4);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(r.isURLSearchParams(t))o=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(i(t)+"="+i(e))})))})),o=s.join("&")}if(o){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,i){return e.config=t,n&&(e.code=n),e.request=r,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(4),i=n(143),o=n(144),s=n(59),a=n(145),c=n(148),u=n(149),l=n(62);e.exports=function(e){return new Promise((function(t,n){var h=e.data,d=e.headers,p=e.responseType;r.isFormData(h)&&delete d["Content-Type"];var f=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",g=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(m+":"+g)}var _=a(e.baseURL,e.url);function y(){if(f){var r="getAllResponseHeaders"in f?c(f.getAllResponseHeaders()):null,o={data:p&&"text"!==p&&"json"!==p?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:r,config:e,request:f};i(t,n,o),f=null}}if(f.open(e.method.toUpperCase(),s(_,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,"onloadend"in f?f.onloadend=y:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(y)},f.onabort=function(){f&&(n(l("Request aborted",e,"ECONNABORTED",f)),f=null)},f.onerror=function(){n(l("Network Error",e,null,f)),f=null},f.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(l(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",f)),f=null},r.isStandardBrowserEnv()){var v=(e.withCredentials||u(_))&&e.xsrfCookieName?o.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}"setRequestHeader"in f&&r.forEach(d,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete d[t]:f.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(f.withCredentials=!!e.withCredentials),p&&"json"!==p&&(f.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){f&&(f.abort(),n(e),f=null)})),h||(h=null),f.send(h)}))}},function(e,t,n){"use strict";var r=n(60);e.exports=function(e,t,n,i,o){var s=new Error(e);return r(s,t,n,i,o)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var r=n(4);e.exports=function(e,t){t=t||{};var n={},i=["url","method","data"],o=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function u(i){r.isUndefined(t[i])?r.isUndefined(e[i])||(n[i]=c(void 0,e[i])):n[i]=c(e[i],t[i])}r.forEach(i,(function(e){r.isUndefined(t[e])||(n[e]=c(void 0,t[e]))})),r.forEach(o,u),r.forEach(s,(function(i){r.isUndefined(t[i])?r.isUndefined(e[i])||(n[i]=c(void 0,e[i])):n[i]=c(void 0,t[i])})),r.forEach(a,(function(r){r in t?n[r]=c(e[r],t[r]):r in e&&(n[r]=c(void 0,e[r]))}));var l=i.concat(o).concat(s).concat(a),h=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return r.forEach(h,u),n}},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){"use strict";var r=n(15);e.exports=new r({include:[n(67)]})},function(e,t,n){"use strict";var r=n(15);e.exports=new r({include:[n(38)],implicit:[n(161),n(162),n(163),n(164)]})},function(e,t,n){"use strict";var r=n(16);e.exports=function(e){r.copy(e,this)}},function(e,t,n){"use strict";e.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,s;if(Array.isArray(t)){for(s="[",n=0;n<t.length;n++)n&&(s+=","),s+=e(t[n])||"null";return s+"]"}if(null===t)return"null";if(-1!==o.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(t)-1,c=Object.keys(t).sort(i&&i(t));for(s="",n=0;n<c.length;n++){var u=c[n],l=e(t[u]);l&&(s&&(s+=","),s+=JSON.stringify(u)+":"+l)}return o.splice(a,1),"{"+s+"}"}}(e)}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r="",i=!0===e.schema.$async,o=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),s=e.self._getId(e.schema);if(e.opts.strictKeywords){var a=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(a){var c="unknown keyword: "+a;if("log"!==e.opts.strictKeywords)throw new Error(c);e.logger.warn(c)}}if(e.isTop&&(r+=" var validate = ",i&&(e.async=!0,r+="async "),r+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",s&&(e.opts.sourceCode||e.opts.processCode)&&(r+=" /*# sourceURL="+s+" */ ")),"boolean"==typeof e.schema||!o&&!e.schema.$ref){var u=e.level,l=e.dataLevel,h=e.schema["false schema"],d=e.schemaPath+e.util.getProperty("false schema"),p=e.errSchemaPath+"/false schema",f=!e.opts.allErrors,m="data"+(l||""),g="valid"+u;if(!1===e.schema){e.isTop?f=!0:r+=" var "+g+" = false; ",(G=G||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'false schema' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: {} ",!1!==e.opts.messages&&(r+=" , message: 'boolean schema is false' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var _=r;r=G.pop(),!e.compositeRule&&f?e.async?r+=" throw new ValidationError(["+_+"]); ":r+=" validate.errors = ["+_+"]; return false; ":r+=" var err = "+_+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?r+=i?" return data; ":" validate.errors = null; return true; ":r+=" var "+g+" = true; ";return e.isTop&&(r+=" }; return validate; "),r}if(e.isTop){var y=e.isTop;u=e.level=0,l=e.dataLevel=0,m="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[void 0],void 0!==e.schema.default&&e.opts.useDefaults&&e.opts.strictDefaults){var v="default is ignored in the schema root";if("log"!==e.opts.strictDefaults)throw new Error(v);e.logger.warn(v)}r+=" var vErrors = null; ",r+=" var errors = 0; ",r+=" if (rootData === undefined) rootData = data; "}else{u=e.level,m="data"+((l=e.dataLevel)||"");if(s&&(e.baseId=e.resolve.url(e.baseId,s)),i&&!e.async)throw new Error("async schema in sync schema");r+=" var errs_"+u+" = errors;"}g="valid"+u,f=!e.opts.allErrors;var b="",w="",x=e.schema.type,k=Array.isArray(x);if(x&&e.opts.nullable&&!0===e.schema.nullable&&(k?-1==x.indexOf("null")&&(x=x.concat("null")):"null"!=x&&(x=[x,"null"],k=!0)),k&&1==x.length&&(x=x[0],k=!1),e.schema.$ref&&o){if("fail"==e.opts.extendRefs)throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');!0!==e.opts.extendRefs&&(o=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(r+=" "+e.RULES.all.$comment.code(e,"$comment")),x){if(e.opts.coerceTypes)var E=e.util.coerceToTypes(e.opts.coerceTypes,x);var j=e.RULES.types[x];if(E||k||!0===j||j&&!Q(j)){d=e.schemaPath+".type",p=e.errSchemaPath+"/type",d=e.schemaPath+".type",p=e.errSchemaPath+"/type";var A=k?"checkDataTypes":"checkDataType";if(r+=" if ("+e.util[A](x,m,e.opts.strictNumbers,!0)+") { ",E){var D="dataType"+u,S="coerced"+u;r+=" var "+D+" = typeof "+m+"; ","array"==e.opts.coerceTypes&&(r+=" if ("+D+" == 'object' && Array.isArray("+m+")) "+D+" = 'array'; "),r+=" var "+S+" = undefined; ";var C="",O=E;if(O)for(var P,F=-1,I=O.length-1;F<I;)P=O[F+=1],F&&(r+=" if ("+S+" === undefined) { ",C+="}"),"array"==e.opts.coerceTypes&&"array"!=P&&(r+=" if ("+D+" == 'array' && "+m+".length == 1) { "+S+" = "+m+" = "+m+"[0]; "+D+" = typeof "+m+"; } "),"string"==P?r+=" if ("+D+" == 'number' || "+D+" == 'boolean') "+S+" = '' + "+m+"; else if ("+m+" === null) "+S+" = ''; ":"number"==P||"integer"==P?(r+=" if ("+D+" == 'boolean' || "+m+" === null || ("+D+" == 'string' && "+m+" && "+m+" == +"+m+" ","integer"==P&&(r+=" && !("+m+" % 1)"),r+=")) "+S+" = +"+m+"; "):"boolean"==P?r+=" if ("+m+" === 'false' || "+m+" === 0 || "+m+" === null) "+S+" = false; else if ("+m+" === 'true' || "+m+" === 1) "+S+" = true; ":"null"==P?r+=" if ("+m+" === '' || "+m+" === 0 || "+m+" === false) "+S+" = null; ":"array"==e.opts.coerceTypes&&"array"==P&&(r+=" if ("+D+" == 'string' || "+D+" == 'number' || "+D+" == 'boolean' || "+m+" == null) "+S+" = ["+m+"]; ");r+=" "+C+" if ("+S+" === undefined) { ",(G=G||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",r+=k?""+x.join(","):""+x,r+="' } ",!1!==e.opts.messages&&(r+=" , message: 'should be ",r+=k?""+x.join(","):""+x,r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+d+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";_=r;r=G.pop(),!e.compositeRule&&f?e.async?r+=" throw new ValidationError(["+_+"]); ":r+=" validate.errors = ["+_+"]; return false; ":r+=" var err = "+_+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { ";var T=l?"data"+(l-1||""):"parentData";r+=" "+m+" = "+S+"; ",l||(r+="if ("+T+" !== undefined)"),r+=" "+T+"["+(l?e.dataPathArr[l]:"parentDataProperty")+"] = "+S+"; } "}else{(G=G||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",r+=k?""+x.join(","):""+x,r+="' } ",!1!==e.opts.messages&&(r+=" , message: 'should be ",r+=k?""+x.join(","):""+x,r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+d+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";_=r;r=G.pop(),!e.compositeRule&&f?e.async?r+=" throw new ValidationError(["+_+"]); ":r+=" validate.errors = ["+_+"]; return false; ":r+=" var err = "+_+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}r+=" } "}}if(e.schema.$ref&&!o)r+=" "+e.RULES.all.$ref.code(e,"$ref")+" ",f&&(r+=" } if (errors === ",r+=y?"0":"errs_"+u,r+=") { ",w+="}");else{var R=e.RULES;if(R)for(var B=-1,M=R.length-1;B<M;)if(Q(j=R[B+=1])){if(j.type&&(r+=" if ("+e.util.checkDataType(j.type,m,e.opts.strictNumbers)+") { "),e.opts.useDefaults)if("object"==j.type&&e.schema.properties){h=e.schema.properties;var q=Object.keys(h);if(q)for(var L,N=-1,U=q.length-1;N<U;){if(void 0!==(z=h[L=q[N+=1]]).default){var W=m+e.util.getProperty(L);if(e.compositeRule){if(e.opts.strictDefaults){v="default is ignored for: "+W;if("log"!==e.opts.strictDefaults)throw new Error(v);e.logger.warn(v)}}else r+=" if ("+W+" === undefined ","empty"==e.opts.useDefaults&&(r+=" || "+W+" === null || "+W+" === '' "),r+=" ) "+W+" = ","shared"==e.opts.useDefaults?r+=" "+e.useDefault(z.default)+" ":r+=" "+JSON.stringify(z.default)+" ",r+="; "}}}else if("array"==j.type&&Array.isArray(e.schema.items)){var $=e.schema.items;if($){F=-1;for(var z,J=$.length-1;F<J;)if(void 0!==(z=$[F+=1]).default){W=m+"["+F+"]";if(e.compositeRule){if(e.opts.strictDefaults){v="default is ignored for: "+W;if("log"!==e.opts.strictDefaults)throw new Error(v);e.logger.warn(v)}}else r+=" if ("+W+" === undefined ","empty"==e.opts.useDefaults&&(r+=" || "+W+" === null || "+W+" === '' "),r+=" ) "+W+" = ","shared"==e.opts.useDefaults?r+=" "+e.useDefault(z.default)+" ":r+=" "+JSON.stringify(z.default)+" ",r+="; "}}}var H=j.rules;if(H)for(var K,V=-1,X=H.length-1;V<X;)if(Z(K=H[V+=1])){var Y=K.code(e,K.keyword,j.type);Y&&(r+=" "+Y+" ",f&&(b+="}"))}if(f&&(r+=" "+b+" ",b=""),j.type&&(r+=" } ",x&&x===j.type&&!E)){r+=" else { ";var G;d=e.schemaPath+".type",p=e.errSchemaPath+"/type";(G=G||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",r+=k?""+x.join(","):""+x,r+="' } ",!1!==e.opts.messages&&(r+=" , message: 'should be ",r+=k?""+x.join(","):""+x,r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+d+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";_=r;r=G.pop(),!e.compositeRule&&f?e.async?r+=" throw new ValidationError(["+_+"]); ":r+=" validate.errors = ["+_+"]; return false; ":r+=" var err = "+_+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } "}f&&(r+=" if (errors === ",r+=y?"0":"errs_"+u,r+=") { ",w+="}")}}function Q(e){for(var t=e.rules,n=0;n<t.length;n++)if(Z(t[n]))return!0}function Z(t){return void 0!==e.schema[t.keyword]||t.implements&&function(t){for(var n=t.implements,r=0;r<n.length;r++)if(void 0!==e.schema[n[r]])return!0}(t)}return f&&(r+=" "+w+" "),y?(i?(r+=" if (errors === 0) return data; ",r+=" else throw new ValidationError(vErrors); "):(r+=" validate.errors = vErrors; ",r+=" return errors === 0; "),r+=" }; return validate;"):r+=" var "+g+" = errors === errs_"+u+";",r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i=" ",o=e.level,s=e.dataLevel,a=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(s||""),d=e.opts.$data&&a&&a.$data;d?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",r="schema"+o):r=a;var p="maximum"==t,f=p?"exclusiveMaximum":"exclusiveMinimum",m=e.schema[f],g=e.opts.$data&&m&&m.$data,_=p?"<":">",y=p?">":"<",v=void 0;if(!d&&"number"!=typeof a&&void 0!==a)throw new Error(t+" must be number");if(!g&&void 0!==m&&"number"!=typeof m&&"boolean"!=typeof m)throw new Error(f+" must be number or boolean");if(g){var b=e.util.getData(m.$data,s,e.dataPathArr),w="exclusive"+o,x="exclType"+o,k="exclIsNumber"+o,E="' + "+(D="op"+o)+" + '";i+=" var schemaExcl"+o+" = "+b+"; ",i+=" var "+w+"; var "+x+" = typeof "+(b="schemaExcl"+o)+"; if ("+x+" != 'boolean' && "+x+" != 'undefined' && "+x+" != 'number') { ";var j;v=f;(j=j||[]).push(i),i="",!1!==e.createErrors?(i+=" { keyword: '"+(v||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",!1!==e.opts.messages&&(i+=" , message: '"+f+" should be boolean' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var A=i;i=j.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+A+"]); ":i+=" validate.errors = ["+A+"]; return false; ":i+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } else if ( ",d&&(i+=" ("+r+" !== undefined && typeof "+r+" != 'number') || "),i+=" "+x+" == 'number' ? ( ("+w+" = "+r+" === undefined || "+b+" "+_+"= "+r+") ? "+h+" "+y+"= "+b+" : "+h+" "+y+" "+r+" ) : ( ("+w+" = "+b+" === true) ? "+h+" "+y+"= "+r+" : "+h+" "+y+" "+r+" ) || "+h+" !== "+h+") { var op"+o+" = "+w+" ? '"+_+"' : '"+_+"='; ",void 0===a&&(v=f,u=e.errSchemaPath+"/"+f,r=b,d=g)}else{E=_;if((k="number"==typeof m)&&d){var D="'"+E+"'";i+=" if ( ",d&&(i+=" ("+r+" !== undefined && typeof "+r+" != 'number') || "),i+=" ( "+r+" === undefined || "+m+" "+_+"= "+r+" ? "+h+" "+y+"= "+m+" : "+h+" "+y+" "+r+" ) || "+h+" !== "+h+") { "}else{k&&void 0===a?(w=!0,v=f,u=e.errSchemaPath+"/"+f,r=m,y+="="):(k&&(r=Math[p?"min":"max"](m,a)),m===(!k||r)?(w=!0,v=f,u=e.errSchemaPath+"/"+f,y+="="):(w=!1,E+="="));D="'"+E+"'";i+=" if ( ",d&&(i+=" ("+r+" !== undefined && typeof "+r+" != 'number') || "),i+=" "+h+" "+y+" "+r+" || "+h+" !== "+h+") { "}}v=v||t,(j=j||[]).push(i),i="",!1!==e.createErrors?(i+=" { keyword: '"+(v||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { comparison: "+D+", limit: "+r+", exclusive: "+w+" } ",!1!==e.opts.messages&&(i+=" , message: 'should be "+E+" ",i+=d?"' + "+r:r+"'"),e.opts.verbose&&(i+=" , schema: ",i+=d?"validate.schema"+c:""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";A=i;return i=j.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+A+"]); ":i+=" validate.errors = ["+A+"]; return false; ":i+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",l&&(i+=" else { "),i}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i=" ",o=e.level,s=e.dataLevel,a=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(s||""),d=e.opts.$data&&a&&a.$data;if(d?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",r="schema"+o):r=a,!d&&"number"!=typeof a)throw new Error(t+" must be number");i+="if ( ",d&&(i+=" ("+r+" !== undefined && typeof "+r+" != 'number') || "),i+=" "+h+".length "+("maxItems"==t?">":"<")+" "+r+") { ";var p=t,f=f||[];f.push(i),i="",!1!==e.createErrors?(i+=" { keyword: '"+(p||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+r+" } ",!1!==e.opts.messages&&(i+=" , message: 'should NOT have ",i+="maxItems"==t?"more":"fewer",i+=" than ",i+=d?"' + "+r+" + '":""+a,i+=" items' "),e.opts.verbose&&(i+=" , schema: ",i+=d?"validate.schema"+c:""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var m=i;return i=f.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+m+"]); ":i+=" validate.errors = ["+m+"]; return false; ":i+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",l&&(i+=" else { "),i}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i=" ",o=e.level,s=e.dataLevel,a=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(s||""),d=e.opts.$data&&a&&a.$data;if(d?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",r="schema"+o):r=a,!d&&"number"!=typeof a)throw new Error(t+" must be number");var p="maxLength"==t?">":"<";i+="if ( ",d&&(i+=" ("+r+" !== undefined && typeof "+r+" != 'number') || "),!1===e.opts.unicode?i+=" "+h+".length ":i+=" ucs2length("+h+") ",i+=" "+p+" "+r+") { ";var f=t,m=m||[];m.push(i),i="",!1!==e.createErrors?(i+=" { keyword: '"+(f||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+r+" } ",!1!==e.opts.messages&&(i+=" , message: 'should NOT be ",i+="maxLength"==t?"longer":"shorter",i+=" than ",i+=d?"' + "+r+" + '":""+a,i+=" characters' "),e.opts.verbose&&(i+=" , schema: ",i+=d?"validate.schema"+c:""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var g=i;return i=m.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+g+"]); ":i+=" validate.errors = ["+g+"]; return false; ":i+=" var err = "+g+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",l&&(i+=" else { "),i}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i=" ",o=e.level,s=e.dataLevel,a=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(s||""),d=e.opts.$data&&a&&a.$data;if(d?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",r="schema"+o):r=a,!d&&"number"!=typeof a)throw new Error(t+" must be number");i+="if ( ",d&&(i+=" ("+r+" !== undefined && typeof "+r+" != 'number') || "),i+=" Object.keys("+h+").length "+("maxProperties"==t?">":"<")+" "+r+") { ";var p=t,f=f||[];f.push(i),i="",!1!==e.createErrors?(i+=" { keyword: '"+(p||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+r+" } ",!1!==e.opts.messages&&(i+=" , message: 'should NOT have ",i+="maxProperties"==t?"more":"fewer",i+=" than ",i+=d?"' + "+r+" + '":""+a,i+=" properties' "),e.opts.verbose&&(i+=" , schema: ",i+=d?"validate.schema"+c:""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var m=i;return i=f.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+m+"]); ":i+=" validate.errors = ["+m+"]; return false; ":i+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",l&&(i+=" else { "),i}},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')},function(e,t,n){var r=n(43),i=n(87),o=n(89),s=n(91),a=n(95),c=n(96),u=n(100);e.exports=function(e,t,n){if((e=u(e))&&(n||void 0===t))return i(e);if(!e||!(t=r(t)))return e;var l=c(e),h=c(t),d=a(l,h),p=s(l,h)+1;return o(l,d,p).join("")}},function(e,t,n){"use strict";var r=n(155);e.exports=r},function(e,t,n){var r,i=i||function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in r,o=/constructor/i.test(e.HTMLElement)||e.safari,s=/CriOS\/[\d]+/.test(navigator.userAgent),a=function(t){(e.setImmediate||e.setTimeout)((function(){throw t}),0)},c=function(e){setTimeout((function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()}),4e4)},u=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},l=function(t,l,h){h||(t=u(t));var d,p=this,f="application/octet-stream"===t.type,m=function(){!function(e,t,n){for(var r=(t=[].concat(t)).length;r--;){var i=e["on"+t[r]];if("function"==typeof i)try{i.call(e,n||e)}catch(e){a(e)}}}(p,"writestart progress write writeend".split(" "))};if(p.readyState=p.INIT,i)return d=n().createObjectURL(t),void setTimeout((function(){var e,t;r.href=d,r.download=l,e=r,t=new MouseEvent("click"),e.dispatchEvent(t),m(),c(d),p.readyState=p.DONE}));!function(){if((s||f&&o)&&e.FileReader){var r=new FileReader;return r.onloadend=function(){var t=s?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,p.readyState=p.DONE,m()},r.readAsDataURL(t),void(p.readyState=p.INIT)}(d||(d=n().createObjectURL(t)),f)?e.location.href=d:e.open(d,"_blank")||(e.location.href=d);p.readyState=p.DONE,m(),c(d)}()},h=l.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=u(e)),navigator.msSaveOrOpenBlob(e,t)}:(h.abort=function(){},h.readyState=h.INIT=0,h.WRITING=1,h.DONE=2,h.error=h.onwritestart=h.onprogress=h.onwrite=h.onabort=h.onerror=h.onwriteend=null,function(e,t,n){return new l(e,t||e.name||"download",n)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */e.exports?e.exports.saveAs=i:null!==n(180)&&null!==n(9)&&(void 0===(r=function(){return i}.call(t,n,t,e))||(e.exports=r))},function(e,t,n){"use strict";var r=n(183),i=n(39),o=n(187),s=n(68),a=n(69),c=n(188),u=n(189),l=n(210),h=n(16);e.exports=_,_.prototype.validate=function(e,t){var n;if("string"==typeof e){if(!(n=this.getSchema(e)))throw new Error('no schema with key or ref "'+e+'"')}else{var r=this._addSchema(e);n=r.validate||this._compile(r)}var i=n(t);!0!==n.$async&&(this.errors=n.errors);return i},_.prototype.compile=function(e,t){var n=this._addSchema(e,void 0,t);return n.validate||this._compile(n)},_.prototype.addSchema=function(e,t,n,r){if(Array.isArray(e)){for(var o=0;o<e.length;o++)this.addSchema(e[o],void 0,n,r);return this}var s=this._getId(e);if(void 0!==s&&"string"!=typeof s)throw new Error("schema id must be string");return k(this,t=i.normalizeId(t||s)),this._schemas[t]=this._addSchema(e,n,r,!0),this},_.prototype.addMetaSchema=function(e,t,n){return this.addSchema(e,t,n,!0),this},_.prototype.validateSchema=function(e,t){var n=e.$schema;if(void 0!==n&&"string"!=typeof n)throw new Error("$schema must be a string");if(!(n=n||this._opts.defaultMeta||function(e){var t=e._opts.meta;return e._opts.defaultMeta="object"==typeof t?e._getId(t)||t:e.getSchema(f)?f:void 0,e._opts.defaultMeta}(this)))return this.logger.warn("meta-schema not available"),this.errors=null,!0;var r=this.validate(n,e);if(!r&&t){var i="schema is invalid: "+this.errorsText();if("log"!=this._opts.validateSchema)throw new Error(i);this.logger.error(i)}return r},_.prototype.getSchema=function(e){var t=y(this,e);switch(typeof t){case"object":return t.validate||this._compile(t);case"string":return this.getSchema(t);case"undefined":return function(e,t){var n=i.schema.call(e,{schema:{}},t);if(n){var o=n.schema,a=n.root,c=n.baseId,u=r.call(e,o,a,void 0,c);return e._fragments[t]=new s({ref:t,fragment:!0,schema:o,root:a,baseId:c,validate:u}),u}}(this,e)}},_.prototype.removeSchema=function(e){if(e instanceof RegExp)return v(this,this._schemas,e),v(this,this._refs,e),this;switch(typeof e){case"undefined":return v(this,this._schemas),v(this,this._refs),this._cache.clear(),this;case"string":var t=y(this,e);return t&&this._cache.del(t.cacheKey),delete this._schemas[e],delete this._refs[e],this;case"object":var n=this._opts.serialize,r=n?n(e):e;this._cache.del(r);var o=this._getId(e);o&&(o=i.normalizeId(o),delete this._schemas[o],delete this._refs[o])}return this},_.prototype.addFormat=function(e,t){"string"==typeof t&&(t=new RegExp(t));return this._formats[e]=t,this},_.prototype.errorsText=function(e,t){if(!(e=e||this.errors))return"No errors";for(var n=void 0===(t=t||{}).separator?", ":t.separator,r=void 0===t.dataVar?"data":t.dataVar,i="",o=0;o<e.length;o++){var s=e[o];s&&(i+=r+s.dataPath+" "+s.message+n)}return i.slice(0,-n.length)},_.prototype._addSchema=function(e,t,n,r){if("object"!=typeof e&&"boolean"!=typeof e)throw new Error("schema should be object or boolean");var o=this._opts.serialize,a=o?o(e):e,c=this._cache.get(a);if(c)return c;r=r||!1!==this._opts.addUsedSchema;var u=i.normalizeId(this._getId(e));u&&r&&k(this,u);var l,h=!1!==this._opts.validateSchema&&!t;h&&!(l=u&&u==i.normalizeId(e.$schema))&&this.validateSchema(e,!0);var d=i.ids.call(this,e),p=new s({id:u,schema:e,localRefs:d,cacheKey:a,meta:n});"#"!=u[0]&&r&&(this._refs[u]=p);this._cache.put(a,p),h&&l&&this.validateSchema(e,!0);return p},_.prototype._compile=function(e,t){if(e.compiling)return e.validate=o,o.schema=e.schema,o.errors=null,o.root=t||o,!0===e.schema.$async&&(o.$async=!0),o;var n,i;e.compiling=!0,e.meta&&(n=this._opts,this._opts=this._metaOpts);try{i=r.call(this,e.schema,t,e.localRefs)}catch(t){throw delete e.validate,t}finally{e.compiling=!1,e.meta&&(this._opts=n)}return e.validate=i,e.refs=i.refs,e.refVal=i.refVal,e.root=i.root,i;function o(){var t=e.validate,n=t.apply(this,arguments);return o.errors=t.errors,n}},_.prototype.compileAsync=n(211);var d=n(212);_.prototype.addKeyword=d.add,_.prototype.getKeyword=d.get,_.prototype.removeKeyword=d.remove,_.prototype.validateKeyword=d.validate;var p=n(41);_.ValidationError=p.Validation,_.MissingRefError=p.MissingRef,_.$dataMetaSchema=l;var f="http://json-schema.org/draft-07/schema",m=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],g=["/properties"];function _(e){if(!(this instanceof _))return new _(e);e=this._opts=h.copy(e)||{},function(e){var t=e._opts.logger;if(!1===t)e.logger={log:E,warn:E,error:E};else{if(void 0===t&&(t=console),!("object"==typeof t&&t.log&&t.warn&&t.error))throw new Error("logger must implement log, warn and error methods");e.logger=t}}(this),this._schemas={},this._refs={},this._fragments={},this._formats=c(e.format),this._cache=e.cache||new o,this._loadingSchemas={},this._compilations=[],this.RULES=u(),this._getId=function(e){switch(e.schemaId){case"auto":return x;case"id":return b;default:return w}}(e),e.loopRequired=e.loopRequired||1/0,"property"==e.errorDataPath&&(e._errorDataPathProperty=!0),void 0===e.serialize&&(e.serialize=a),this._metaOpts=function(e){for(var t=h.copy(e._opts),n=0;n<m.length;n++)delete t[m[n]];return t}(this),e.formats&&function(e){for(var t in e._opts.formats){var n=e._opts.formats[t];e.addFormat(t,n)}}(this),e.keywords&&function(e){for(var t in e._opts.keywords){var n=e._opts.keywords[t];e.addKeyword(t,n)}}(this),function(e){var t;e._opts.$data&&(t=n(215),e.addMetaSchema(t,t.$id,!0));if(!1===e._opts.meta)return;var r=n(75);e._opts.$data&&(r=l(r,g));e.addMetaSchema(r,f,!0),e._refs["http://json-schema.org/schema"]=f}(this),"object"==typeof e.meta&&this.addMetaSchema(e.meta),e.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),function(e){var t=e._opts.schemas;if(!t)return;if(Array.isArray(t))e.addSchema(t);else for(var n in t)e.addSchema(t[n],n)}(this)}function y(e,t){return t=i.normalizeId(t),e._schemas[t]||e._refs[t]||e._fragments[t]}function v(e,t,n){for(var r in t){var i=t[r];i.meta||n&&!n.test(r)||(e._cache.del(i.cacheKey),delete t[r])}}function b(e){return e.$id&&this.logger.warn("schema $id ignored",e.$id),e.id}function w(e){return e.id&&this.logger.warn("schema id ignored",e.id),e.$id}function x(e){if(e.$id&&e.id&&e.$id!=e.id)throw new Error("schema $id is different from id");return e.$id||e.id}function k(e,t){if(e._schemas[t]||e._refs[t])throw new Error('schema with key or id "'+t+'" already exists')}function E(){}},function(e){e.exports=JSON.parse('{"BrowserFS":{"src":"https://imjoy-team.github.io/imjoy-core-plugins/BrowserFS.imjoy.html","startup":false},"Jupyter-Engine-Manager":{"src":"https://imjoy-team.github.io/jupyter-engine-manager/Jupyter-Engine-Manager.imjoy.html","startup":true},"WebPythonWorker":{"src":"https://imjoy-team.github.io/imjoy-core-plugins/WebPythonWorker.imjoy.html","startup":true}}')},function(e,t,n){var r,i,o;
/*! minibus - v3.1.0 - 2014-11-22
* https://github.com/axelpale/minibus
*
* Copyright (c) 2014 Akseli Palen <akseli.palen@gmail.com>;
* Licensed under the MIT license */!function(n,s){"use strict";i=[t],void 0===(o="function"==typeof(r=function(e){var t=function(){this.eventMap={},this.routeMap={},this.busContext={}};e.create=function(){return new t},e.extension=t.prototype;var n=function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},i=function(e){this.name="InvalidEventStringError",this.message="Invalid event string given: "+e},o=function(e){this.name="InvalidRouteStringError",this.message="Invalid route string given: "+e},s=function(e){this.name="InvalidEventHandlerError",this.message="Invalid event handler function given: "+e},a=function(e){var t,r,o,s,a,c;for(n(e)||(e=[e]),r=0;r<e.length;r+=1)if("string"!=typeof e[r])throw new i(e[r]);for(t=[],r=1;r<arguments.length;r+=1)t.push(arguments[r]);for(a=[],r=0;r<e.length;r+=1)if(this.eventMap.hasOwnProperty(e[r]))for(s in o=this.eventMap[e[r]])o.hasOwnProperty(s)&&a.push(o[s].eventHandler);for(c=this.busContext,r=0;r<a.length;r+=1)a[r].apply(c,t)};t.prototype.emit=a,t.prototype.trigger=a;var c=function(e,t){var r,o,a,c,u;for((r=n(e))||(e=[e]),o=0;o<e.length;o+=1)if("string"!=typeof e[o])throw new i(e[o]);if("function"!=typeof t)throw new s(t);for(u=[],o=0;o<e.length;o+=1)a={eventString:e[o],eventHandler:t},c=l.create(),u.push(c),this.eventMap.hasOwnProperty(e[o])||(this.eventMap[e[o]]={}),this.eventMap[e[o]][c]=a,this.routeMap[c]=a;return r?u:u[0]};t.prototype.on=c,t.prototype.listen=c;t.prototype.once=function(e,t){var n,r,i;if("function"!=typeof t)throw new s(t);return n=this,i=!1,r=this.on(e,(function(){i||(i=!0,n.off(r),t.apply(this,arguments))}))};var u=function(e){var t,i,s,a,c;if(void 0===e)return this.routeMap={},void(this.eventMap={});n(e)||(e=[e]);var u=[];for(e=u=u.concat.apply(u,e),t=0;t<e.length;t+=1)if("string"!=typeof e[t])throw new o(e[t]);for(t=0;t<e.length;t+=1)if(this.routeMap.hasOwnProperty(e[t]))i=this.routeMap[e[t]],delete this.routeMap[e[t]],delete this.eventMap[i.eventString][e[t]],r(this.eventMap[i.eventString])&&delete this.eventMap[i.eventString];else if(s=e[t],this.eventMap.hasOwnProperty(s)){for(c in a=this.eventMap[s])a.hasOwnProperty(c)&&delete this.routeMap[c];delete this.eventMap[s]}};t.prototype.off=u,t.prototype.removeListener=u;var l=function(){var e={create:function(){return Math.random().toString().substring(2)}};return e}();e.version="3.1.0"})?r.apply(t,i):r)||(e.exports=o)}()},function(e,t,n){"use strict";var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),i=new Uint8Array(16);function o(){if(!r)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(i)}for(var s=[],a=0;a<256;++a)s.push((a+256).toString(16).substr(1));var c=function(e,t){var n=t||0,r=s;return(r[e[n+0]]+r[e[n+1]]+r[e[n+2]]+r[e[n+3]]+"-"+r[e[n+4]]+r[e[n+5]]+"-"+r[e[n+6]]+r[e[n+7]]+"-"+r[e[n+8]]+r[e[n+9]]+"-"+r[e[n+10]]+r[e[n+11]]+r[e[n+12]]+r[e[n+13]]+r[e[n+14]]+r[e[n+15]]).toLowerCase()};t.a=function(e,t,n){"string"==typeof e&&(t="binary"===e?new Uint8Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){for(var i=n||0,s=0;s<16;++s)t[i+s]=r[s];return t}return c(r)}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}},function(e,t,n){var r=n(25),i=n(26);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},function(e,t,n){var r=n(33),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var i=s.call(e);return r&&(t?e[a]=n:delete e[a]),i}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return n.call(e)}},function(e,t,n){var r=n(88),i=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(i,""):e}},function(e,t){var n=/\s/;e.exports=function(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}},function(e,t,n){var r=n(90);e.exports=function(e,t,n){var i=e.length;return n=void 0===n?i:n,!t&&n>=i?e:r(e,t,n)}},function(e,t){e.exports=function(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=e[r+t];return o}},function(e,t,n){var r=n(46);e.exports=function(e,t){for(var n=e.length;n--&&r(t,e[n],0)>-1;);return n}},function(e,t){e.exports=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}},function(e,t){e.exports=function(e){return e!=e}},function(e,t){e.exports=function(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}},function(e,t,n){var r=n(46);e.exports=function(e,t){for(var n=-1,i=e.length;++n<i&&r(t,e[n],0)>-1;);return n}},function(e,t,n){var r=n(97),i=n(98),o=n(99);e.exports=function(e){return i(e)?o(e):r(e)}},function(e,t){e.exports=function(e){return e.split("")}},function(e,t){var n=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");e.exports=function(e){return n.test(e)}},function(e,t){var n="[\\ud800-\\udfff]",r="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",i="\\ud83c[\\udffb-\\udfff]",o="[^\\ud800-\\udfff]",s="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",c="(?:"+r+"|"+i+")"+"?",u="[\\ufe0e\\ufe0f]?"+c+("(?:\\u200d(?:"+[o,s,a].join("|")+")[\\ufe0e\\ufe0f]?"+c+")*"),l="(?:"+[o+r+"?",r,s,a,n].join("|")+")",h=RegExp(i+"(?="+i+")|"+l+u,"g");e.exports=function(e){return e.match(h)||[]}},function(e,t,n){var r=n(43);e.exports=function(e){return null==e?"":r(e)}},function(e,t,n){var r=n(102),i=n(106);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},function(e,t,n){var r=n(50),i=n(103),o=n(35),s=n(105),a=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,h=u.hasOwnProperty,d=RegExp("^"+l.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!o(e)||i(e))&&(r(e)?d:a).test(s(e))}},function(e,t,n){var r,i=n(104),o=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!o&&o in e}},function(e,t,n){var r=n(34)["__core-js_shared__"];e.exports=r},function(e,t){var n=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return n.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},function(e,t){e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){var r=n(47),i=n(48);e.exports=function(e,t,n,o){var s=!n;n||(n={});for(var a=-1,c=t.length;++a<c;){var u=t[a],l=o?o(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?i(n,u,l):r(n,u,l)}return n}},function(e,t,n){var r=n(109),i=n(116);e.exports=function(e){return r((function(t,n){var r=-1,o=n.length,s=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,a&&i(n[0],n[1],a)&&(s=o<3?void 0:s,o=1),t=Object(t);++r<o;){var c=n[r];c&&e(t,c,r,s)}return t}))}},function(e,t,n){var r=n(52),i=n(110),o=n(112);e.exports=function(e,t){return o(i(e,t,r),e+"")}},function(e,t,n){var r=n(111),i=Math.max;e.exports=function(e,t,n){return t=i(void 0===t?e.length-1:t,0),function(){for(var o=arguments,s=-1,a=i(o.length-t,0),c=Array(a);++s<a;)c[s]=o[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=o[s];return u[t]=n(c),r(e,this,u)}}},function(e,t){e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t,n){var r=n(113),i=n(115)(r);e.exports=i},function(e,t,n){var r=n(114),i=n(49),o=n(52),s=i?function(e,t){return i(e,"toString",{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:o;e.exports=s},function(e,t){e.exports=function(e){return function(){return e}}},function(e,t){var n=Date.now;e.exports=function(e){var t=0,r=0;return function(){var i=n(),o=16-(i-r);if(r=i,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){var r=n(51),i=n(36),o=n(54),s=n(35);e.exports=function(e,t,n){if(!s(n))return!1;var a=typeof t;return!!("number"==a?i(n)&&o(t,n.length):"string"==a&&t in n)&&r(n[t],e)}},function(e,t,n){var r=n(118),i=n(128),o=n(36);e.exports=function(e){return o(e)?r(e):i(e)}},function(e,t,n){var r=n(119),i=n(120),o=n(45),s=n(122),a=n(54),c=n(124),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=o(e),l=!n&&i(e),h=!n&&!l&&s(e),d=!n&&!l&&!h&&c(e),p=n||l||h||d,f=p?r(e.length,String):[],m=f.length;for(var g in e)!t&&!u.call(e,g)||p&&("length"==g||h&&("offset"==g||"parent"==g)||d&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||a(g,m))||f.push(g);return f}},function(e,t){e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},function(e,t,n){var r=n(121),i=n(26),o=Object.prototype,s=o.hasOwnProperty,a=o.propertyIsEnumerable,c=r(function(){return arguments}())?r:function(e){return i(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=c},function(e,t,n){var r=n(25),i=n(26);e.exports=function(e){return i(e)&&"[object Arguments]"==r(e)}},function(e,t,n){(function(e){var r=n(34),i=n(123),o=t&&!t.nodeType&&t,s=o&&"object"==typeof e&&e&&!e.nodeType&&e,a=s&&s.exports===o?r.Buffer:void 0,c=(a?a.isBuffer:void 0)||i;e.exports=c}).call(this,n(56)(e))},function(e,t){e.exports=function(){return!1}},function(e,t,n){var r=n(125),i=n(126),o=n(127),s=o&&o.isTypedArray,a=s?i(s):r;e.exports=a},function(e,t,n){var r=n(25),i=n(53),o=n(26),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return o(e)&&i(e.length)&&!!s[r(e)]}},function(e,t){e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){(function(e){var r=n(44),i=t&&!t.nodeType&&t,o=i&&"object"==typeof e&&e&&!e.nodeType&&e,s=o&&o.exports===i&&r.process,a=function(){try{var e=o&&o.require&&o.require("util").types;return e||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a}).call(this,n(56)(e))},function(e,t,n){var r=n(55),i=n(129),o=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))o.call(e,n)&&"constructor"!=n&&t.push(n);return t}},function(e,t,n){var r=n(130)(Object.keys,Object);e.exports=r},function(e,t){e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t){},function(e,t,n){"use strict";(function(e){t.test=function(){return"function"==typeof e.queueMicrotask},t.install=function(t){return function(){e.queueMicrotask(t)}}}).call(this,n(13))},function(e,t,n){"use strict";(function(e){var n=e.MutationObserver||e.WebKitMutationObserver;t.test=function(){return n},t.install=function(t){var r=0,i=new n(t),o=e.document.createTextNode("");return i.observe(o,{characterData:!0}),function(){o.data=r=++r%2}}}).call(this,n(13))},function(e,t,n){"use strict";(function(e){t.test=function(){return!e.setImmediate&&void 0!==e.MessageChannel},t.install=function(t){var n=new e.MessageChannel;return n.port1.onmessage=t,function(){n.port2.postMessage(0)}}}).call(this,n(13))},function(e,t,n){"use strict";(function(e){t.test=function(){return"document"in e&&"onreadystatechange"in e.document.createElement("script")},t.install=function(t){return function(){var n=e.document.createElement("script");return n.onreadystatechange=function(){t(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},e.document.documentElement.appendChild(n),t}}}).call(this,n(13))},function(e,t,n){"use strict";t.test=function(){return!0},t.install=function(e){return function(){setTimeout(e,0)}}},function(e,t,n){"use strict";var r=n(4),i=n(58),o=n(138),s=n(64);function a(e){var t=new o(e),n=i(o.prototype.request,t);return r.extend(n,o.prototype,t),r.extend(n,t),n}var c=a(n(37));c.Axios=o,c.create=function(e){return a(s(c.defaults,e))},c.Cancel=n(65),c.CancelToken=n(152),c.isCancel=n(63),c.all=function(e){return Promise.all(e)},c.spread=n(153),c.isAxiosError=n(154),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";var r=n(4),i=n(59),o=n(139),s=n(140),a=n(64),c=n(150),u=c.validators;function l(e){this.defaults=e,this.interceptors={request:new o,response:new o}}l.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var i,o=[];if(this.interceptors.response.forEach((function(e){o.push(e.fulfilled,e.rejected)})),!r){var l=[s,void 0];for(Array.prototype.unshift.apply(l,n),l.concat(o),i=Promise.resolve(e);l.length;)i=i.then(l.shift(),l.shift());return i}for(var h=e;n.length;){var d=n.shift(),p=n.shift();try{h=d(h)}catch(e){p(e);break}}try{i=s(h)}catch(e){return Promise.reject(e)}for(;o.length;)i=i.then(o.shift(),o.shift());return i},l.prototype.getUri=function(e){return e=a(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){l.prototype[e]=function(t,n,r){return this.request(a(r||{},{method:e,url:t,data:n}))}})),e.exports=l},function(e,t,n){"use strict";var r=n(4);function i(){this.handlers=[]}i.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,n){"use strict";var r=n(4),i=n(141),o=n(63),s=n(37);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return a(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(a(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,n){"use strict";var r=n(4),i=n(37);e.exports=function(e,t,n){var o=this||i;return r.forEach(n,(function(n){e=n.call(o,e,t)})),e}},function(e,t,n){"use strict";var r=n(4);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},function(e,t,n){"use strict";var r=n(62);e.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(4);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,i,o,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var r=n(146),i=n(147);e.exports=function(e,t){return e&&!r(t)?i(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(4),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,o,s={};return e?(r.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t){if(s[t]&&i.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},function(e,t,n){"use strict";var r=n(4);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=i(window.location.href),function(t){var n=r.isString(t)?i(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r=n(151),i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var o={},s=r.version.split(".");function a(e,t){for(var n=t?t.split("."):s,r=e.split("."),i=0;i<3;i++){if(n[i]>r[i])return!0;if(n[i]<r[i])return!1}return!1}i.transitional=function(e,t,n){var i=t&&a(t);function s(e,t){return"[Axios v"+r.version+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,a){if(!1===e)throw new Error(s(r," has been removed in "+t));return i&&!o[r]&&(o[r]=!0,console.warn(s(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,a)}},e.exports={isOlderVersion:a,assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),i=r.length;i-- >0;){var o=r[i],s=t[o];if(s){var a=e[o],c=void 0===a||s(a,o,e);if(!0!==c)throw new TypeError("option "+o+" must be "+c)}else if(!0!==n)throw Error("Unknown option "+o)}},validators:i}},function(e){e.exports=JSON.parse('{"name":"axios","version":"0.21.2","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.2.tgz","_integrity":"sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==","_from":"axios@0.21.2"}')},function(e,t,n){"use strict";var r=n(65);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},function(e,t,n){"use strict";var r=n(156),i=n(179);function o(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}e.exports.Type=n(1),e.exports.Schema=n(15),e.exports.FAILSAFE_SCHEMA=n(38),e.exports.JSON_SCHEMA=n(67),e.exports.CORE_SCHEMA=n(66),e.exports.DEFAULT_SAFE_SCHEMA=n(18),e.exports.DEFAULT_FULL_SCHEMA=n(27),e.exports.load=r.load,e.exports.loadAll=r.loadAll,e.exports.safeLoad=r.safeLoad,e.exports.safeLoadAll=r.safeLoadAll,e.exports.dump=i.dump,e.exports.safeDump=i.safeDump,e.exports.YAMLException=n(17),e.exports.MINIMAL_SCHEMA=n(38),e.exports.SAFE_SCHEMA=n(18),e.exports.DEFAULT_SCHEMA=n(27),e.exports.scan=o("scan"),e.exports.parse=o("parse"),e.exports.compose=o("compose"),e.exports.addConstructor=o("addConstructor")},function(e,t,n){"use strict";var r=n(14),i=n(17),o=n(157),s=n(18),a=n(27),c=Object.prototype.hasOwnProperty,u=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,l=/[\x85\u2028\u2029]/,h=/[,\[\]\{\}]/,d=/^(?:!|!!|![a-z\-]+!)$/i,p=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function f(e){return Object.prototype.toString.call(e)}function m(e){return 10===e||13===e}function g(e){return 9===e||32===e}function _(e){return 9===e||32===e||10===e||13===e}function y(e){return 44===e||91===e||93===e||123===e||125===e}function v(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function b(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function w(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var x=new Array(256),k=new Array(256),E=0;E<256;E++)x[E]=b(E)?1:0,k[E]=b(E);function j(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||a,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function A(e,t){return new i(t,new o(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function D(e,t){throw A(e,t)}function S(e,t){e.onWarning&&e.onWarning.call(null,A(e,t))}var C={YAML:function(e,t,n){var r,i,o;null!==e.version&&D(e,"duplication of %YAML directive"),1!==n.length&&D(e,"YAML directive accepts exactly one argument"),null===(r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&D(e,"ill-formed argument of the YAML directive"),i=parseInt(r[1],10),o=parseInt(r[2],10),1!==i&&D(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&S(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var r,i;2!==n.length&&D(e,"TAG directive accepts exactly two arguments"),r=n[0],i=n[1],d.test(r)||D(e,"ill-formed tag handle (first argument) of the TAG directive"),c.call(e.tagMap,r)&&D(e,'there is a previously declared suffix for "'+r+'" tag handle'),p.test(i)||D(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagMap[r]=i}};function O(e,t,n,r){var i,o,s,a;if(t<n){if(a=e.input.slice(t,n),r)for(i=0,o=a.length;i<o;i+=1)9===(s=a.charCodeAt(i))||32<=s&&s<=1114111||D(e,"expected valid JSON character");else u.test(a)&&D(e,"the stream contains non-printable characters");e.result+=a}}function P(e,t,n,i){var o,s,a,u;for(r.isObject(n)||D(e,"cannot merge mappings; the provided source object is unacceptable"),a=0,u=(o=Object.keys(n)).length;a<u;a+=1)s=o[a],c.call(t,s)||(t[s]=n[s],i[s]=!0)}function F(e,t,n,r,i,o,s,a){var u,l;if(Array.isArray(i))for(u=0,l=(i=Array.prototype.slice.call(i)).length;u<l;u+=1)Array.isArray(i[u])&&D(e,"nested arrays are not supported inside keys"),"object"==typeof i&&"[object Object]"===f(i[u])&&(i[u]="[object Object]");if("object"==typeof i&&"[object Object]"===f(i)&&(i="[object Object]"),i=String(i),null===t&&(t={}),"tag:yaml.org,2002:merge"===r)if(Array.isArray(o))for(u=0,l=o.length;u<l;u+=1)P(e,t,o[u],n);else P(e,t,o,n);else e.json||c.call(n,i)||!c.call(t,i)||(e.line=s||e.line,e.position=a||e.position,D(e,"duplicated mapping key")),t[i]=o,delete n[i];return t}function I(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):D(e,"a line break is expected"),e.line+=1,e.lineStart=e.position}function T(e,t,n){for(var r=0,i=e.input.charCodeAt(e.position);0!==i;){for(;g(i);)i=e.input.charCodeAt(++e.position);if(t&&35===i)do{i=e.input.charCodeAt(++e.position)}while(10!==i&&13!==i&&0!==i);if(!m(i))break;for(I(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;32===i;)e.lineIndent++,i=e.input.charCodeAt(++e.position)}return-1!==n&&0!==r&&e.lineIndent<n&&S(e,"deficient indentation"),r}function R(e){var t,n=e.position;return!(45!==(t=e.input.charCodeAt(n))&&46!==t||t!==e.input.charCodeAt(n+1)||t!==e.input.charCodeAt(n+2)||(n+=3,0!==(t=e.input.charCodeAt(n))&&!_(t)))}function B(e,t){1===t?e.result+=" ":t>1&&(e.result+=r.repeat("\n",t-1))}function M(e,t){var n,r,i=e.tag,o=e.anchor,s=[],a=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=s),r=e.input.charCodeAt(e.position);0!==r&&45===r&&_(e.input.charCodeAt(e.position+1));)if(a=!0,e.position++,T(e,!0,-1)&&e.lineIndent<=t)s.push(null),r=e.input.charCodeAt(e.position);else if(n=e.line,N(e,t,3,!1,!0),s.push(e.result),T(e,!0,-1),r=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==r)D(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!a&&(e.tag=i,e.anchor=o,e.kind="sequence",e.result=s,!0)}function q(e){var t,n,r,i,o=!1,s=!1;if(33!==(i=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&D(e,"duplication of a tag property"),60===(i=e.input.charCodeAt(++e.position))?(o=!0,i=e.input.charCodeAt(++e.position)):33===i?(s=!0,n="!!",i=e.input.charCodeAt(++e.position)):n="!",t=e.position,o){do{i=e.input.charCodeAt(++e.position)}while(0!==i&&62!==i);e.position<e.length?(r=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):D(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==i&&!_(i);)33===i&&(s?D(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),d.test(n)||D(e,"named tag handle cannot contain such characters"),s=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);r=e.input.slice(t,e.position),h.test(r)&&D(e,"tag suffix cannot contain flow indicator characters")}return r&&!p.test(r)&&D(e,"tag name cannot contain such characters: "+r),o?e.tag=r:c.call(e.tagMap,n)?e.tag=e.tagMap[n]+r:"!"===n?e.tag="!"+r:"!!"===n?e.tag="tag:yaml.org,2002:"+r:D(e,'undeclared tag handle "'+n+'"'),!0}function L(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&D(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!_(n)&&!y(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&D(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function N(e,t,n,i,o){var s,a,u,l,h,d,p,f,b=1,E=!1,j=!1;if(null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,s=a=u=4===n||3===n,i&&T(e,!0,-1)&&(E=!0,e.lineIndent>t?b=1:e.lineIndent===t?b=0:e.lineIndent<t&&(b=-1)),1===b)for(;q(e)||L(e);)T(e,!0,-1)?(E=!0,u=s,e.lineIndent>t?b=1:e.lineIndent===t?b=0:e.lineIndent<t&&(b=-1)):u=!1;if(u&&(u=E||o),1!==b&&4!==n||(p=1===n||2===n?t:t+1,f=e.position-e.lineStart,1===b?u&&(M(e,f)||function(e,t,n){var r,i,o,s,a,c=e.tag,u=e.anchor,l={},h={},d=null,p=null,f=null,m=!1,y=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=l),a=e.input.charCodeAt(e.position);0!==a;){if(r=e.input.charCodeAt(e.position+1),o=e.line,s=e.position,63!==a&&58!==a||!_(r)){if(!N(e,n,2,!1,!0))break;if(e.line===o){for(a=e.input.charCodeAt(e.position);g(a);)a=e.input.charCodeAt(++e.position);if(58===a)_(a=e.input.charCodeAt(++e.position))||D(e,"a whitespace character is expected after the key-value separator within a block mapping"),m&&(F(e,l,h,d,p,null),d=p=f=null),y=!0,m=!1,i=!1,d=e.tag,p=e.result;else{if(!y)return e.tag=c,e.anchor=u,!0;D(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!y)return e.tag=c,e.anchor=u,!0;D(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===a?(m&&(F(e,l,h,d,p,null),d=p=f=null),y=!0,m=!0,i=!0):m?(m=!1,i=!0):D(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,a=r;if((e.line===o||e.lineIndent>t)&&(N(e,t,4,!0,i)&&(m?p=e.result:f=e.result),m||(F(e,l,h,d,p,f,o,s),d=p=f=null),T(e,!0,-1),a=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==a)D(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return m&&F(e,l,h,d,p,null),y&&(e.tag=c,e.anchor=u,e.kind="mapping",e.result=l),y}(e,f,p))||function(e,t){var n,r,i,o,s,a,c,u,l,h,d=!0,p=e.tag,f=e.anchor,m={};if(91===(h=e.input.charCodeAt(e.position)))i=93,a=!1,r=[];else{if(123!==h)return!1;i=125,a=!0,r={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=r),h=e.input.charCodeAt(++e.position);0!==h;){if(T(e,!0,t),(h=e.input.charCodeAt(e.position))===i)return e.position++,e.tag=p,e.anchor=f,e.kind=a?"mapping":"sequence",e.result=r,!0;d||D(e,"missed comma between flow collection entries"),l=null,o=s=!1,63===h&&_(e.input.charCodeAt(e.position+1))&&(o=s=!0,e.position++,T(e,!0,t)),n=e.line,N(e,t,1,!1,!0),u=e.tag,c=e.result,T(e,!0,t),h=e.input.charCodeAt(e.position),!s&&e.line!==n||58!==h||(o=!0,h=e.input.charCodeAt(++e.position),T(e,!0,t),N(e,t,1,!1,!0),l=e.result),a?F(e,r,m,u,c,l):o?r.push(F(e,null,m,u,c,l)):r.push(c),T(e,!0,t),44===(h=e.input.charCodeAt(e.position))?(d=!0,h=e.input.charCodeAt(++e.position)):d=!1}D(e,"unexpected end of the stream within a flow collection")}(e,p)?j=!0:(a&&function(e,t){var n,i,o,s,a,c=1,u=!1,l=!1,h=t,d=0,p=!1;if(124===(s=e.input.charCodeAt(e.position)))i=!1;else{if(62!==s)return!1;i=!0}for(e.kind="scalar",e.result="";0!==s;)if(43===(s=e.input.charCodeAt(++e.position))||45===s)1===c?c=43===s?3:2:D(e,"repeat of a chomping mode identifier");else{if(!((o=48<=(a=s)&&a<=57?a-48:-1)>=0))break;0===o?D(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):l?D(e,"repeat of an indentation width identifier"):(h=t+o-1,l=!0)}if(g(s)){do{s=e.input.charCodeAt(++e.position)}while(g(s));if(35===s)do{s=e.input.charCodeAt(++e.position)}while(!m(s)&&0!==s)}for(;0!==s;){for(I(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!l||e.lineIndent<h)&&32===s;)e.lineIndent++,s=e.input.charCodeAt(++e.position);if(!l&&e.lineIndent>h&&(h=e.lineIndent),m(s))d++;else{if(e.lineIndent<h){3===c?e.result+=r.repeat("\n",u?1+d:d):1===c&&u&&(e.result+="\n");break}for(i?g(s)?(p=!0,e.result+=r.repeat("\n",u?1+d:d)):p?(p=!1,e.result+=r.repeat("\n",d+1)):0===d?u&&(e.result+=" "):e.result+=r.repeat("\n",d):e.result+=r.repeat("\n",u?1+d:d),u=!0,l=!0,d=0,n=e.position;!m(s)&&0!==s;)s=e.input.charCodeAt(++e.position);O(e,n,e.position,!1)}}return!0}(e,p)||function(e,t){var n,r,i;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(O(e,r,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;r=e.position,e.position++,i=e.position}else m(n)?(O(e,r,i,!0),B(e,T(e,!1,t)),r=i=e.position):e.position===e.lineStart&&R(e)?D(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);D(e,"unexpected end of the stream within a single quoted scalar")}(e,p)||function(e,t){var n,r,i,o,s,a,c;if(34!==(a=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;0!==(a=e.input.charCodeAt(e.position));){if(34===a)return O(e,n,e.position,!0),e.position++,!0;if(92===a){if(O(e,n,e.position,!0),m(a=e.input.charCodeAt(++e.position)))T(e,!1,t);else if(a<256&&x[a])e.result+=k[a],e.position++;else if((s=120===(c=a)?2:117===c?4:85===c?8:0)>0){for(i=s,o=0;i>0;i--)(s=v(a=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+s:D(e,"expected hexadecimal character");e.result+=w(o),e.position++}else D(e,"unknown escape sequence");n=r=e.position}else m(a)?(O(e,n,r,!0),B(e,T(e,!1,t)),n=r=e.position):e.position===e.lineStart&&R(e)?D(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}D(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?j=!0:!function(e){var t,n,r;if(42!==(r=e.input.charCodeAt(e.position)))return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!_(r)&&!y(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&D(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(n)||D(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],T(e,!0,-1),!0}(e)?function(e,t,n){var r,i,o,s,a,c,u,l,h=e.kind,d=e.result;if(_(l=e.input.charCodeAt(e.position))||y(l)||35===l||38===l||42===l||33===l||124===l||62===l||39===l||34===l||37===l||64===l||96===l)return!1;if((63===l||45===l)&&(_(r=e.input.charCodeAt(e.position+1))||n&&y(r)))return!1;for(e.kind="scalar",e.result="",i=o=e.position,s=!1;0!==l;){if(58===l){if(_(r=e.input.charCodeAt(e.position+1))||n&&y(r))break}else if(35===l){if(_(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&R(e)||n&&y(l))break;if(m(l)){if(a=e.line,c=e.lineStart,u=e.lineIndent,T(e,!1,-1),e.lineIndent>=t){s=!0,l=e.input.charCodeAt(e.position);continue}e.position=o,e.line=a,e.lineStart=c,e.lineIndent=u;break}}s&&(O(e,i,o,!1),B(e,e.line-a),i=o=e.position,s=!1),g(l)||(o=e.position+1),l=e.input.charCodeAt(++e.position)}return O(e,i,o,!1),!!e.result||(e.kind=h,e.result=d,!1)}(e,p,1===n)&&(j=!0,null===e.tag&&(e.tag="?")):(j=!0,null===e.tag&&null===e.anchor||D(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===b&&(j=u&&M(e,f))),null!==e.tag&&"!"!==e.tag)if("?"===e.tag){for(l=0,h=e.implicitTypes.length;l<h;l+=1)if((d=e.implicitTypes[l]).resolve(e.result)){e.result=d.construct(e.result),e.tag=d.tag,null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);break}}else c.call(e.typeMap[e.kind||"fallback"],e.tag)?(d=e.typeMap[e.kind||"fallback"][e.tag],null!==e.result&&d.kind!==e.kind&&D(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+d.kind+'", not "'+e.kind+'"'),d.resolve(e.result)?(e.result=d.construct(e.result),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):D(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):D(e,"unknown tag !<"+e.tag+">");return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||j}function U(e){var t,n,r,i,o=e.position,s=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(i=e.input.charCodeAt(e.position))&&(T(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==i));){for(s=!0,i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!_(i);)i=e.input.charCodeAt(++e.position);for(r=[],(n=e.input.slice(t,e.position)).length<1&&D(e,"directive name must not be less than one character in length");0!==i;){for(;g(i);)i=e.input.charCodeAt(++e.position);if(35===i){do{i=e.input.charCodeAt(++e.position)}while(0!==i&&!m(i));break}if(m(i))break;for(t=e.position;0!==i&&!_(i);)i=e.input.charCodeAt(++e.position);r.push(e.input.slice(t,e.position))}0!==i&&I(e),c.call(C,n)?C[n](e,n,r):S(e,'unknown document directive "'+n+'"')}T(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,T(e,!0,-1)):s&&D(e,"directives end mark is expected"),N(e,e.lineIndent-1,4,!1,!0),T(e,!0,-1),e.checkLineBreaks&&l.test(e.input.slice(o,e.position))&&S(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&R(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,T(e,!0,-1)):e.position<e.length-1&&D(e,"end of the stream or a document separator is expected")}function W(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new j(e,t);for(n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)U(n);return n.documents}function $(e,t,n){var r,i,o=W(e,n);if("function"!=typeof t)return o;for(r=0,i=o.length;r<i;r+=1)t(o[r])}function z(e,t){var n=W(e,t);if(0!==n.length){if(1===n.length)return n[0];throw new i("expected a single document in the stream, but found more")}}e.exports.loadAll=$,e.exports.load=z,e.exports.safeLoadAll=function(e,t,n){if("function"!=typeof t)return $(e,r.extend({schema:s},n));$(e,t,r.extend({schema:s},n))},e.exports.safeLoad=function(e,t){return z(e,r.extend({schema:s},t))}},function(e,t,n){"use strict";var r=n(14);function i(e,t,n,r,i){this.name=e,this.buffer=t,this.position=n,this.line=r,this.column=i}i.prototype.getSnippet=function(e,t){var n,i,o,s,a;if(!this.buffer)return null;for(e=e||4,t=t||75,n="",i=this.position;i>0&&-1==="\0\r\n
\u2028\u2029".indexOf(this.buffer.charAt(i-1));)if(i-=1,this.position-i>t/2-1){n=" ... ",i+=5;break}for(o="",s=this.position;s<this.buffer.length&&-1==="\0\r\n
\u2028\u2029".indexOf(this.buffer.charAt(s));)if((s+=1)-this.position>t/2-1){o=" ... ",s-=5;break}return a=this.buffer.slice(i,s),r.repeat(" ",e)+n+a+o+"\n"+r.repeat(" ",e+this.position-i+n.length)+"^"},i.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},e.exports=i},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}})},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}})},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})},function(e,t,n){"use strict";var r=n(14),i=n(1);function o(e){return 48<=e&&e<=55}function s(e){return 48<=e&&e<=57}e.exports=new i("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,r=e.length,i=0,a=!1;if(!r)return!1;if("-"!==(t=e[i])&&"+"!==t||(t=e[++i]),"0"===t){if(i+1===r)return!0;if("b"===(t=e[++i])){for(i++;i<r;i++)if("_"!==(t=e[i])){if("0"!==t&&"1"!==t)return!1;a=!0}return a&&"_"!==t}if("x"===t){for(i++;i<r;i++)if("_"!==(t=e[i])){if(!(48<=(n=e.charCodeAt(i))&&n<=57||65<=n&&n<=70||97<=n&&n<=102))return!1;a=!0}return a&&"_"!==t}for(;i<r;i++)if("_"!==(t=e[i])){if(!o(e.charCodeAt(i)))return!1;a=!0}return a&&"_"!==t}if("_"===t)return!1;for(;i<r;i++)if("_"!==(t=e[i])){if(":"===t)break;if(!s(e.charCodeAt(i)))return!1;a=!0}return!(!a||"_"===t)&&(":"!==t||/^(:[0-5]?[0-9])+$/.test(e.slice(i)))},construct:function(e){var t,n,r=e,i=1,o=[];return-1!==r.indexOf("_")&&(r=r.replace(/_/g,"")),"-"!==(t=r[0])&&"+"!==t||("-"===t&&(i=-1),t=(r=r.slice(1))[0]),"0"===r?0:"0"===t?"b"===r[1]?i*parseInt(r.slice(2),2):"x"===r[1]?i*parseInt(r,16):i*parseInt(r,8):-1!==r.indexOf(":")?(r.split(":").forEach((function(e){o.unshift(parseInt(e,10))})),r=0,n=1,o.forEach((function(e){r+=e*n,n*=60})),i*r):i*parseInt(r,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!r.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})},function(e,t,n){"use strict";var r=n(14),i=n(1),o=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var s=/^[-+]?[0-9]+e/;e.exports=new i("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!o.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n,r,i;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:t.indexOf(":")>=0?(t.split(":").forEach((function(e){i.unshift(parseFloat(e,10))})),t=0,r=1,i.forEach((function(e){t+=e*r,r*=60})),n*t):n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||r.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(r.isNegativeZero(e))return"-0.0";return n=e.toString(10),s.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"})},function(e,t,n){"use strict";var r=n(1),i=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),o=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");e.exports=new r("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==i.exec(e)||null!==o.exec(e))},construct:function(e){var t,n,r,s,a,c,u,l,h=0,d=null;if(null===(t=i.exec(e))&&(t=o.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(n,r,s));if(a=+t[4],c=+t[5],u=+t[6],t[7]){for(h=t[7].slice(0,3);h.length<3;)h+="0";h=+h}return t[9]&&(d=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(d=-d)),l=new Date(Date.UTC(n,r,s,a,c,u,h)),d&&l.setTime(l.getTime()-d),l},instanceOf:Date,represent:function(e){return e.toISOString()}})},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}})},function(e,t,n){"use strict";var r;try{r=n(168).Buffer}catch(e){}var i=n(1),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";e.exports=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,r=0,i=e.length,s=o;for(n=0;n<i;n++)if(!((t=s.indexOf(e.charAt(n)))>64)){if(t<0)return!1;r+=6}return r%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),s=i.length,a=o,c=0,u=[];for(t=0;t<s;t++)t%4==0&&t&&(u.push(c>>16&255),u.push(c>>8&255),u.push(255&c)),c=c<<6|a.indexOf(i.charAt(t));return 0===(n=s%4*6)?(u.push(c>>16&255),u.push(c>>8&255),u.push(255&c)):18===n?(u.push(c>>10&255),u.push(c>>2&255)):12===n&&u.push(c>>4&255),r?r.from?r.from(u):new r(u):u},predicate:function(e){return r&&r.isBuffer(e)},represent:function(e){var t,n,r="",i=0,s=e.length,a=o;for(t=0;t<s;t++)t%3==0&&t&&(r+=a[i>>18&63],r+=a[i>>12&63],r+=a[i>>6&63],r+=a[63&i]),i=(i<<8)+e[t];return 0===(n=s%3)?(r+=a[i>>18&63],r+=a[i>>12&63],r+=a[i>>6&63],r+=a[63&i]):2===n?(r+=a[i>>10&63],r+=a[i>>4&63],r+=a[i<<2&63],r+=a[64]):1===n&&(r+=a[i>>2&63],r+=a[i<<4&63],r+=a[64],r+=a[64]),r}})},function(e,t,n){"use strict";(function(e){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var r=n(169),i=n(170),o=n(171);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=d(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|f(t,n),i=(e=a(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):d(e,t);if("Buffer"===t.type&&o(t.data))return d(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function h(e,t){if(l(t),e=a(e,t<0?0:0|p(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function d(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return N(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return U(e).length;default:if(r)return N(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return D(this,t,n);case"latin1":case"binary":return S(this,t,n);case"base64":return j(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=n;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function v(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return W(N(t,e.length-n),e,n,r)}function w(e,t,n,r){return W(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function x(e,t,n,r){return w(e,t,n,r)}function k(e,t,n,r){return W(U(t),e,n,r)}function E(e,t,n,r){return W(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function j(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,u=e[i],l=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return l(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return h(null,e)},c.allocUnsafeSlow=function(e){return h(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=f,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):m.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(r,i),l=e.slice(t,n),h=0;h<a;++h)if(u[h]!==l[h]){o=u[h],s=l[h];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return _(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return _(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return v(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return k(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function D(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function S(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=L(e[o]);return i}function O(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function F(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function I(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function T(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function R(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(e,t,n,r,o){return o||R(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function M(e,t,n,r,o){return o||R(e,0,n,8),i.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;n=new c(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},c.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||F(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||F(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):T(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):T(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);F(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);F(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):T(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):T(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return M(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return M(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=c.isBuffer(e)?e:N(new c(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function L(e){return e<16?"0"+e.toString(16):e.toString(16)}function N(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function U(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(13))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],a=r[1],c=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),l=0,h=a>0?s-4:s;for(n=0;n<h;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[l++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(l(e,s,s+16383>a?a:s+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,u=c>>1,l=-7,h=n?i-1:0,d=n?-1:1,p=e[t+h];for(h+=d,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=u}return(p?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&a,p+=f,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[n+p]=255&s,p+=f,s/=256,u-=8);e[n+p-f]|=128*m}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";var r=n(1),i=Object.prototype.hasOwnProperty,o=Object.prototype.toString;e.exports=new r("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,r,s,a,c=[],u=e;for(t=0,n=u.length;t<n;t+=1){if(r=u[t],a=!1,"[object Object]"!==o.call(r))return!1;for(s in r)if(i.call(r,s)){if(a)return!1;a=!0}if(!a)return!1;if(-1!==c.indexOf(s))return!1;c.push(s)}return!0},construct:function(e){return null!==e?e:[]}})},function(e,t,n){"use strict";var r=n(1),i=Object.prototype.toString;e.exports=new r("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,r,o,s,a=e;for(s=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],"[object Object]"!==i.call(r))return!1;if(1!==(o=Object.keys(r)).length)return!1;s[t]=[o[0],r[o[0]]]}return!0},construct:function(e){if(null===e)return[];var t,n,r,i,o,s=e;for(o=new Array(s.length),t=0,n=s.length;t<n;t+=1)r=s[t],i=Object.keys(r),o[t]=[i[0],r[i[0]]];return o}})},function(e,t,n){"use strict";var r=n(1),i=Object.prototype.hasOwnProperty;e.exports=new r("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var t,n=e;for(t in n)if(i.call(n,t)&&null!==n[t])return!1;return!0},construct:function(e){return null!==e?e:{}}})},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:function(){return!0},construct:function(){},predicate:function(e){return void 0===e},represent:function(){return""}})},function(e,t,n){"use strict";var r=n(1);e.exports=new r("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:function(e){if(null===e)return!1;if(0===e.length)return!1;var t=e,n=/\/([gim]*)$/.exec(e),r="";if("/"===t[0]){if(n&&(r=n[1]),r.length>3)return!1;if("/"!==t[t.length-r.length-1])return!1}return!0},construct:function(e){var t=e,n=/\/([gim]*)$/.exec(e),r="";return"/"===t[0]&&(n&&(r=n[1]),t=t.slice(1,t.length-r.length-1)),new RegExp(t,r)},predicate:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},represent:function(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}})},function(e,t,n){"use strict";var r;try{r=n(178)}catch(e){"undefined"!=typeof window&&(r=window.esprima)}var i=n(1);e.exports=new i("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:function(e){if(null===e)return!1;try{var t="("+e+")",n=r.parse(t,{range:!0});return"Program"===n.type&&1===n.body.length&&"ExpressionStatement"===n.body[0].type&&("ArrowFunctionExpression"===n.body[0].expression.type||"FunctionExpression"===n.body[0].expression.type)}catch(e){return!1}},construct:function(e){var t,n="("+e+")",i=r.parse(n,{range:!0}),o=[];if("Program"!==i.type||1!==i.body.length||"ExpressionStatement"!==i.body[0].type||"ArrowFunctionExpression"!==i.body[0].expression.type&&"FunctionExpression"!==i.body[0].expression.type)throw new Error("Failed to resolve function");return i.body[0].expression.params.forEach((function(e){o.push(e.name)})),t=i.body[0].expression.body.range,"BlockStatement"===i.body[0].expression.body.type?new Function(o,n.slice(t[0]+1,t[1]-1)):new Function(o,"return "+n.slice(t[0],t[1]))},predicate:function(e){return"[object Function]"===Object.prototype.toString.call(e)},represent:function(e){return e.toString()}})},function(e,t,n){var r;r=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.m=e,n.c=t,n.p="",n(0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(3),o=n(8),s=n(15);function a(e,t,n){var s=null,a=function(e,t){n&&n(e,t),s&&s.visit(e,t)},c="function"==typeof n?a:null,u=!1;if(t){u="boolean"==typeof t.comment&&t.comment;var l="boolean"==typeof t.attachComment&&t.attachComment;(u||l)&&((s=new r.CommentHandler).attach=l,t.comment=!0,c=a)}var h,d=!1;t&&"string"==typeof t.sourceType&&(d="module"===t.sourceType),h=t&&"boolean"==typeof t.jsx&&t.jsx?new i.JSXParser(e,t,c):new o.Parser(e,t,c);var p=d?h.parseModule():h.parseScript();return u&&s&&(p.comments=s.comments),h.config.tokens&&(p.tokens=h.tokens),h.config.tolerant&&(p.errors=h.errorHandler.errors),p}t.parse=a,t.parseModule=function(e,t,n){var r=t||{};return r.sourceType="module",a(e,r,n)},t.parseScript=function(e,t,n){var r=t||{};return r.sourceType="script",a(e,r,n)},t.tokenize=function(e,t,n){var r,i=new s.Tokenizer(e,t);r=[];try{for(;;){var o=i.getNextToken();if(!o)break;n&&(o=n(o)),r.push(o)}}catch(e){i.errorHandler.tolerate(e)}return i.errorHandler.tolerant&&(r.errors=i.errors()),r};var c=n(2);t.Syntax=c.Syntax,t.version="4.0.1"},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(){function e(){this.attach=!1,this.comments=[],this.stack=[],this.leading=[],this.trailing=[]}return e.prototype.insertInnerComments=function(e,t){if(e.type===r.Syntax.BlockStatement&&0===e.body.length){for(var n=[],i=this.leading.length-1;i>=0;--i){var o=this.leading[i];t.end.offset>=o.start&&(n.unshift(o.comment),this.leading.splice(i,1),this.trailing.splice(i,1))}n.length&&(e.innerComments=n)}},e.prototype.findTrailingComments=function(e){var t=[];if(this.trailing.length>0){for(var n=this.trailing.length-1;n>=0;--n){var r=this.trailing[n];r.start>=e.end.offset&&t.unshift(r.comment)}return this.trailing.length=0,t}var i=this.stack[this.stack.length-1];if(i&&i.node.trailingComments){var o=i.node.trailingComments[0];o&&o.range[0]>=e.end.offset&&(t=i.node.trailingComments,delete i.node.trailingComments)}return t},e.prototype.findLeadingComments=function(e){for(var t,n=[];this.stack.length>0&&((o=this.stack[this.stack.length-1])&&o.start>=e.start.offset);)t=o.node,this.stack.pop();if(t){for(var r=(t.leadingComments?t.leadingComments.length:0)-1;r>=0;--r){var i=t.leadingComments[r];i.range[1]<=e.start.offset&&(n.unshift(i),t.leadingComments.splice(r,1))}return t.leadingComments&&0===t.leadingComments.length&&delete t.leadingComments,n}for(r=this.leading.length-1;r>=0;--r){var o;(o=this.leading[r]).start<=e.start.offset&&(n.unshift(o.comment),this.leading.splice(r,1))}return n},e.prototype.visitNode=function(e,t){if(!(e.type===r.Syntax.Program&&e.body.length>0)){this.insertInnerComments(e,t);var n=this.findTrailingComments(t),i=this.findLeadingComments(t);i.length>0&&(e.leadingComments=i),n.length>0&&(e.trailingComments=n),this.stack.push({node:e,start:t.start.offset})}},e.prototype.visitComment=function(e,t){var n="L"===e.type[0]?"Line":"Block",r={type:n,value:e.value};if(e.range&&(r.range=e.range),e.loc&&(r.loc=e.loc),this.comments.push(r),this.attach){var i={comment:{type:n,value:e.value,range:[t.start.offset,t.end.offset]},start:t.start.offset};e.loc&&(i.comment.loc=e.loc),e.type=n,this.leading.push(i),this.trailing.push(i)}},e.prototype.visit=function(e,t){"LineComment"===e.type||"BlockComment"===e.type?this.visitComment(e,t):this.attach&&this.visitNode(e,t)},e}();t.CommentHandler=i},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForOfStatement:"ForOfStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"}},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(4),s=n(5),a=n(6),c=n(7),u=n(8),l=n(13),h=n(14);function d(e){var t;switch(e.type){case a.JSXSyntax.JSXIdentifier:t=e.name;break;case a.JSXSyntax.JSXNamespacedName:var n=e;t=d(n.namespace)+":"+d(n.name);break;case a.JSXSyntax.JSXMemberExpression:var r=e;t=d(r.object)+"."+d(r.property)}return t}l.TokenName[100]="JSXIdentifier",l.TokenName[101]="JSXText";var p=function(e){function t(t,n,r){return e.call(this,t,n,r)||this}return i(t,e),t.prototype.parsePrimaryExpression=function(){return this.match("<")?this.parseJSXRoot():e.prototype.parsePrimaryExpression.call(this)},t.prototype.startJSX=function(){this.scanner.index=this.startMarker.index,this.scanner.lineNumber=this.startMarker.line,this.scanner.lineStart=this.startMarker.index-this.startMarker.column},t.prototype.finishJSX=function(){this.nextToken()},t.prototype.reenterJSX=function(){this.startJSX(),this.expectJSX("}"),this.config.tokens&&this.tokens.pop()},t.prototype.createJSXNode=function(){return this.collectComments(),{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}},t.prototype.createJSXChildNode=function(){return{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}},t.prototype.scanXHTMLEntity=function(e){for(var t="&",n=!0,r=!1,i=!1,s=!1;!this.scanner.eof()&&n&&!r;){var a=this.scanner.source[this.scanner.index];if(a===e)break;if(r=";"===a,t+=a,++this.scanner.index,!r)switch(t.length){case 2:i="#"===a;break;case 3:i&&(n=(s="x"===a)||o.Character.isDecimalDigit(a.charCodeAt(0)),i=i&&!s);break;default:n=(n=n&&!(i&&!o.Character.isDecimalDigit(a.charCodeAt(0))))&&!(s&&!o.Character.isHexDigit(a.charCodeAt(0)))}}if(n&&r&&t.length>2){var c=t.substr(1,t.length-2);i&&c.length>1?t=String.fromCharCode(parseInt(c.substr(1),10)):s&&c.length>2?t=String.fromCharCode(parseInt("0"+c.substr(1),16)):i||s||!h.XHTMLEntities[c]||(t=h.XHTMLEntities[c])}return t},t.prototype.lexJSX=function(){var e=this.scanner.source.charCodeAt(this.scanner.index);if(60===e||62===e||47===e||58===e||61===e||123===e||125===e)return{type:7,value:a=this.scanner.source[this.scanner.index++],lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index-1,end:this.scanner.index};if(34===e||39===e){for(var t=this.scanner.index,n=this.scanner.source[this.scanner.index++],r="";!this.scanner.eof()&&(c=this.scanner.source[this.scanner.index++])!==n;)r+="&"===c?this.scanXHTMLEntity(n):c;return{type:8,value:r,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:t,end:this.scanner.index}}if(46===e){var i=this.scanner.source.charCodeAt(this.scanner.index+1),s=this.scanner.source.charCodeAt(this.scanner.index+2),a=46===i&&46===s?"...":".";return t=this.scanner.index,this.scanner.index+=a.length,{type:7,value:a,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:t,end:this.scanner.index}}if(96===e)return{type:10,value:"",lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index,end:this.scanner.index};if(o.Character.isIdentifierStart(e)&&92!==e){for(t=this.scanner.index,++this.scanner.index;!this.scanner.eof();){var c=this.scanner.source.charCodeAt(this.scanner.index);if(o.Character.isIdentifierPart(c)&&92!==c)++this.scanner.index;else{if(45!==c)break;++this.scanner.index}}return{type:100,value:this.scanner.source.slice(t,this.scanner.index),lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:t,end:this.scanner.index}}return this.scanner.lex()},t.prototype.nextJSXToken=function(){this.collectComments(),this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart;var e=this.lexJSX();return this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.config.tokens&&this.tokens.push(this.convertToken(e)),e},t.prototype.nextJSXText=function(){this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart;for(var e=this.scanner.index,t="";!this.scanner.eof();){var n=this.scanner.source[this.scanner.index];if("{"===n||"<"===n)break;++this.scanner.index,t+=n,o.Character.isLineTerminator(n.charCodeAt(0))&&(++this.scanner.lineNumber,"\r"===n&&"\n"===this.scanner.source[this.scanner.index]&&++this.scanner.index,this.scanner.lineStart=this.scanner.index)}this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart;var r={type:101,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:e,end:this.scanner.index};return t.length>0&&this.config.tokens&&this.tokens.push(this.convertToken(r)),r},t.prototype.peekJSXToken=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.lexJSX();return this.scanner.restoreState(e),t},t.prototype.expectJSX=function(e){var t=this.nextJSXToken();7===t.type&&t.value===e||this.throwUnexpectedToken(t)},t.prototype.matchJSX=function(e){var t=this.peekJSXToken();return 7===t.type&&t.value===e},t.prototype.parseJSXIdentifier=function(){var e=this.createJSXNode(),t=this.nextJSXToken();return 100!==t.type&&this.throwUnexpectedToken(t),this.finalize(e,new s.JSXIdentifier(t.value))},t.prototype.parseJSXElementName=function(){var e=this.createJSXNode(),t=this.parseJSXIdentifier();if(this.matchJSX(":")){var n=t;this.expectJSX(":");var r=this.parseJSXIdentifier();t=this.finalize(e,new s.JSXNamespacedName(n,r))}else if(this.matchJSX("."))for(;this.matchJSX(".");){var i=t;this.expectJSX(".");var o=this.parseJSXIdentifier();t=this.finalize(e,new s.JSXMemberExpression(i,o))}return t},t.prototype.parseJSXAttributeName=function(){var e,t=this.createJSXNode(),n=this.parseJSXIdentifier();if(this.matchJSX(":")){var r=n;this.expectJSX(":");var i=this.parseJSXIdentifier();e=this.finalize(t,new s.JSXNamespacedName(r,i))}else e=n;return e},t.prototype.parseJSXStringLiteralAttribute=function(){var e=this.createJSXNode(),t=this.nextJSXToken();8!==t.type&&this.throwUnexpectedToken(t);var n=this.getTokenRaw(t);return this.finalize(e,new c.Literal(t.value,n))},t.prototype.parseJSXExpressionAttribute=function(){var e=this.createJSXNode();this.expectJSX("{"),this.finishJSX(),this.match("}")&&this.tolerateError("JSX attributes must only be assigned a non-empty expression");var t=this.parseAssignmentExpression();return this.reenterJSX(),this.finalize(e,new s.JSXExpressionContainer(t))},t.prototype.parseJSXAttributeValue=function(){return this.matchJSX("{")?this.parseJSXExpressionAttribute():this.matchJSX("<")?this.parseJSXElement():this.parseJSXStringLiteralAttribute()},t.prototype.parseJSXNameValueAttribute=function(){var e=this.createJSXNode(),t=this.parseJSXAttributeName(),n=null;return this.matchJSX("=")&&(this.expectJSX("="),n=this.parseJSXAttributeValue()),this.finalize(e,new s.JSXAttribute(t,n))},t.prototype.parseJSXSpreadAttribute=function(){var e=this.createJSXNode();this.expectJSX("{"),this.expectJSX("..."),this.finishJSX();var t=this.parseAssignmentExpression();return this.reenterJSX(),this.finalize(e,new s.JSXSpreadAttribute(t))},t.prototype.parseJSXAttributes=function(){for(var e=[];!this.matchJSX("/")&&!this.matchJSX(">");){var t=this.matchJSX("{")?this.parseJSXSpreadAttribute():this.parseJSXNameValueAttribute();e.push(t)}return e},t.prototype.parseJSXOpeningElement=function(){var e=this.createJSXNode();this.expectJSX("<");var t=this.parseJSXElementName(),n=this.parseJSXAttributes(),r=this.matchJSX("/");return r&&this.expectJSX("/"),this.expectJSX(">"),this.finalize(e,new s.JSXOpeningElement(t,r,n))},t.prototype.parseJSXBoundaryElement=function(){var e=this.createJSXNode();if(this.expectJSX("<"),this.matchJSX("/")){this.expectJSX("/");var t=this.parseJSXElementName();return this.expectJSX(">"),this.finalize(e,new s.JSXClosingElement(t))}var n=this.parseJSXElementName(),r=this.parseJSXAttributes(),i=this.matchJSX("/");return i&&this.expectJSX("/"),this.expectJSX(">"),this.finalize(e,new s.JSXOpeningElement(n,i,r))},t.prototype.parseJSXEmptyExpression=function(){var e=this.createJSXChildNode();return this.collectComments(),this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.finalize(e,new s.JSXEmptyExpression)},t.prototype.parseJSXExpressionContainer=function(){var e,t=this.createJSXNode();return this.expectJSX("{"),this.matchJSX("}")?(e=this.parseJSXEmptyExpression(),this.expectJSX("}")):(this.finishJSX(),e=this.parseAssignmentExpression(),this.reenterJSX()),this.finalize(t,new s.JSXExpressionContainer(e))},t.prototype.parseJSXChildren=function(){for(var e=[];!this.scanner.eof();){var t=this.createJSXChildNode(),n=this.nextJSXText();if(n.start<n.end){var r=this.getTokenRaw(n),i=this.finalize(t,new s.JSXText(n.value,r));e.push(i)}if("{"!==this.scanner.source[this.scanner.index])break;var o=this.parseJSXExpressionContainer();e.push(o)}return e},t.prototype.parseComplexJSXElement=function(e){for(var t=[];!this.scanner.eof();){e.children=e.children.concat(this.parseJSXChildren());var n=this.createJSXChildNode(),r=this.parseJSXBoundaryElement();if(r.type===a.JSXSyntax.JSXOpeningElement){var i=r;if(i.selfClosing){var o=this.finalize(n,new s.JSXElement(i,[],null));e.children.push(o)}else t.push(e),e={node:n,opening:i,closing:null,children:[]}}if(r.type===a.JSXSyntax.JSXClosingElement){e.closing=r;var c=d(e.opening.name);if(c!==d(e.closing.name)&&this.tolerateError("Expected corresponding JSX closing tag for %0",c),!(t.length>0))break;o=this.finalize(e.node,new s.JSXElement(e.opening,e.children,e.closing)),(e=t[t.length-1]).children.push(o),t.pop()}}return e},t.prototype.parseJSXElement=function(){var e=this.createJSXNode(),t=this.parseJSXOpeningElement(),n=[],r=null;if(!t.selfClosing){var i=this.parseComplexJSXElement({node:e,opening:t,closing:r,children:n});n=i.children,r=i.closing}return this.finalize(e,new s.JSXElement(t,n,r))},t.prototype.parseJSXRoot=function(){this.config.tokens&&this.tokens.pop(),this.startJSX();var e=this.parseJSXElement();return this.finishJSX(),e},t.prototype.isStartOfExpression=function(){return e.prototype.isStartOfExpression.call(this)||this.match("<")},t}(u.Parser);t.JSXParser=p},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/};t.Character={fromCodePoint:function(e){return e<65536?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10))+String.fromCharCode(56320+(e-65536&1023))},isWhiteSpace:function(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0},isLineTerminator:function(e){return 10===e||13===e||8232===e||8233===e},isIdentifierStart:function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&n.NonAsciiIdentifierStart.test(t.Character.fromCodePoint(e))},isIdentifierPart:function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&n.NonAsciiIdentifierPart.test(t.Character.fromCodePoint(e))},isDecimalDigit:function(e){return e>=48&&e<=57},isHexDigit:function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},isOctalDigit:function(e){return e>=48&&e<=55}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),i=function(e){this.type=r.JSXSyntax.JSXClosingElement,this.name=e};t.JSXClosingElement=i;var o=function(e,t,n){this.type=r.JSXSyntax.JSXElement,this.openingElement=e,this.children=t,this.closingElement=n};t.JSXElement=o;var s=function(){this.type=r.JSXSyntax.JSXEmptyExpression};t.JSXEmptyExpression=s;var a=function(e){this.type=r.JSXSyntax.JSXExpressionContainer,this.expression=e};t.JSXExpressionContainer=a;var c=function(e){this.type=r.JSXSyntax.JSXIdentifier,this.name=e};t.JSXIdentifier=c;var u=function(e,t){this.type=r.JSXSyntax.JSXMemberExpression,this.object=e,this.property=t};t.JSXMemberExpression=u;var l=function(e,t){this.type=r.JSXSyntax.JSXAttribute,this.name=e,this.value=t};t.JSXAttribute=l;var h=function(e,t){this.type=r.JSXSyntax.JSXNamespacedName,this.namespace=e,this.name=t};t.JSXNamespacedName=h;var d=function(e,t,n){this.type=r.JSXSyntax.JSXOpeningElement,this.name=e,this.selfClosing=t,this.attributes=n};t.JSXOpeningElement=d;var p=function(e){this.type=r.JSXSyntax.JSXSpreadAttribute,this.argument=e};t.JSXSpreadAttribute=p;var f=function(e,t){this.type=r.JSXSyntax.JSXText,this.value=e,this.raw=t};t.JSXText=f},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JSXSyntax={JSXAttribute:"JSXAttribute",JSXClosingElement:"JSXClosingElement",JSXElement:"JSXElement",JSXEmptyExpression:"JSXEmptyExpression",JSXExpressionContainer:"JSXExpressionContainer",JSXIdentifier:"JSXIdentifier",JSXMemberExpression:"JSXMemberExpression",JSXNamespacedName:"JSXNamespacedName",JSXOpeningElement:"JSXOpeningElement",JSXSpreadAttribute:"JSXSpreadAttribute",JSXText:"JSXText"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(e){this.type=r.Syntax.ArrayExpression,this.elements=e};t.ArrayExpression=i;var o=function(e){this.type=r.Syntax.ArrayPattern,this.elements=e};t.ArrayPattern=o;var s=function(e,t,n){this.type=r.Syntax.ArrowFunctionExpression,this.id=null,this.params=e,this.body=t,this.generator=!1,this.expression=n,this.async=!1};t.ArrowFunctionExpression=s;var a=function(e,t,n){this.type=r.Syntax.AssignmentExpression,this.operator=e,this.left=t,this.right=n};t.AssignmentExpression=a;var c=function(e,t){this.type=r.Syntax.AssignmentPattern,this.left=e,this.right=t};t.AssignmentPattern=c;var u=function(e,t,n){this.type=r.Syntax.ArrowFunctionExpression,this.id=null,this.params=e,this.body=t,this.generator=!1,this.expression=n,this.async=!0};t.AsyncArrowFunctionExpression=u;var l=function(e,t,n){this.type=r.Syntax.FunctionDeclaration,this.id=e,this.params=t,this.body=n,this.generator=!1,this.expression=!1,this.async=!0};t.AsyncFunctionDeclaration=l;var h=function(e,t,n){this.type=r.Syntax.FunctionExpression,this.id=e,this.params=t,this.body=n,this.generator=!1,this.expression=!1,this.async=!0};t.AsyncFunctionExpression=h;var d=function(e){this.type=r.Syntax.AwaitExpression,this.argument=e};t.AwaitExpression=d;var p=function(e,t,n){var i="||"===e||"&&"===e;this.type=i?r.Syntax.LogicalExpression:r.Syntax.BinaryExpression,this.operator=e,this.left=t,this.right=n};t.BinaryExpression=p;var f=function(e){this.type=r.Syntax.BlockStatement,this.body=e};t.BlockStatement=f;var m=function(e){this.type=r.Syntax.BreakStatement,this.label=e};t.BreakStatement=m;var g=function(e,t){this.type=r.Syntax.CallExpression,this.callee=e,this.arguments=t};t.CallExpression=g;var _=function(e,t){this.type=r.Syntax.CatchClause,this.param=e,this.body=t};t.CatchClause=_;var y=function(e){this.type=r.Syntax.ClassBody,this.body=e};t.ClassBody=y;var v=function(e,t,n){this.type=r.Syntax.ClassDeclaration,this.id=e,this.superClass=t,this.body=n};t.ClassDeclaration=v;var b=function(e,t,n){this.type=r.Syntax.ClassExpression,this.id=e,this.superClass=t,this.body=n};t.ClassExpression=b;var w=function(e,t){this.type=r.Syntax.MemberExpression,this.computed=!0,this.object=e,this.property=t};t.ComputedMemberExpression=w;var x=function(e,t,n){this.type=r.Syntax.ConditionalExpression,this.test=e,this.consequent=t,this.alternate=n};t.ConditionalExpression=x;var k=function(e){this.type=r.Syntax.ContinueStatement,this.label=e};t.ContinueStatement=k;var E=function(){this.type=r.Syntax.DebuggerStatement};t.DebuggerStatement=E;var j=function(e,t){this.type=r.Syntax.ExpressionStatement,this.expression=e,this.directive=t};t.Directive=j;var A=function(e,t){this.type=r.Syntax.DoWhileStatement,this.body=e,this.test=t};t.DoWhileStatement=A;var D=function(){this.type=r.Syntax.EmptyStatement};t.EmptyStatement=D;var S=function(e){this.type=r.Syntax.ExportAllDeclaration,this.source=e};t.ExportAllDeclaration=S;var C=function(e){this.type=r.Syntax.ExportDefaultDeclaration,this.declaration=e};t.ExportDefaultDeclaration=C;var O=function(e,t,n){this.type=r.Syntax.ExportNamedDeclaration,this.declaration=e,this.specifiers=t,this.source=n};t.ExportNamedDeclaration=O;var P=function(e,t){this.type=r.Syntax.ExportSpecifier,this.exported=t,this.local=e};t.ExportSpecifier=P;var F=function(e){this.type=r.Syntax.ExpressionStatement,this.expression=e};t.ExpressionStatement=F;var I=function(e,t,n){this.type=r.Syntax.ForInStatement,this.left=e,this.right=t,this.body=n,this.each=!1};t.ForInStatement=I;var T=function(e,t,n){this.type=r.Syntax.ForOfStatement,this.left=e,this.right=t,this.body=n};t.ForOfStatement=T;var R=function(e,t,n,i){this.type=r.Syntax.ForStatement,this.init=e,this.test=t,this.update=n,this.body=i};t.ForStatement=R;var B=function(e,t,n,i){this.type=r.Syntax.FunctionDeclaration,this.id=e,this.params=t,this.body=n,this.generator=i,this.expression=!1,this.async=!1};t.FunctionDeclaration=B;var M=function(e,t,n,i){this.type=r.Syntax.FunctionExpression,this.id=e,this.params=t,this.body=n,this.generator=i,this.expression=!1,this.async=!1};t.FunctionExpression=M;var q=function(e){this.type=r.Syntax.Identifier,this.name=e};t.Identifier=q;var L=function(e,t,n){this.type=r.Syntax.IfStatement,this.test=e,this.consequent=t,this.alternate=n};t.IfStatement=L;var N=function(e,t){this.type=r.Syntax.ImportDeclaration,this.specifiers=e,this.source=t};t.ImportDeclaration=N;var U=function(e){this.type=r.Syntax.ImportDefaultSpecifier,this.local=e};t.ImportDefaultSpecifier=U;var W=function(e){this.type=r.Syntax.ImportNamespaceSpecifier,this.local=e};t.ImportNamespaceSpecifier=W;var $=function(e,t){this.type=r.Syntax.ImportSpecifier,this.local=e,this.imported=t};t.ImportSpecifier=$;var z=function(e,t){this.type=r.Syntax.LabeledStatement,this.label=e,this.body=t};t.LabeledStatement=z;var J=function(e,t){this.type=r.Syntax.Literal,this.value=e,this.raw=t};t.Literal=J;var H=function(e,t){this.type=r.Syntax.MetaProperty,this.meta=e,this.property=t};t.MetaProperty=H;var K=function(e,t,n,i,o){this.type=r.Syntax.MethodDefinition,this.key=e,this.computed=t,this.value=n,this.kind=i,this.static=o};t.MethodDefinition=K;var V=function(e){this.type=r.Syntax.Program,this.body=e,this.sourceType="module"};t.Module=V;var X=function(e,t){this.type=r.Syntax.NewExpression,this.callee=e,this.arguments=t};t.NewExpression=X;var Y=function(e){this.type=r.Syntax.ObjectExpression,this.properties=e};t.ObjectExpression=Y;var G=function(e){this.type=r.Syntax.ObjectPattern,this.properties=e};t.ObjectPattern=G;var Q=function(e,t,n,i,o,s){this.type=r.Syntax.Property,this.key=t,this.computed=n,this.value=i,this.kind=e,this.method=o,this.shorthand=s};t.Property=Q;var Z=function(e,t,n,i){this.type=r.Syntax.Literal,this.value=e,this.raw=t,this.regex={pattern:n,flags:i}};t.RegexLiteral=Z;var ee=function(e){this.type=r.Syntax.RestElement,this.argument=e};t.RestElement=ee;var te=function(e){this.type=r.Syntax.ReturnStatement,this.argument=e};t.ReturnStatement=te;var ne=function(e){this.type=r.Syntax.Program,this.body=e,this.sourceType="script"};t.Script=ne;var re=function(e){this.type=r.Syntax.SequenceExpression,this.expressions=e};t.SequenceExpression=re;var ie=function(e){this.type=r.Syntax.SpreadElement,this.argument=e};t.SpreadElement=ie;var oe=function(e,t){this.type=r.Syntax.MemberExpression,this.computed=!1,this.object=e,this.property=t};t.StaticMemberExpression=oe;var se=function(){this.type=r.Syntax.Super};t.Super=se;var ae=function(e,t){this.type=r.Syntax.SwitchCase,this.test=e,this.consequent=t};t.SwitchCase=ae;var ce=function(e,t){this.type=r.Syntax.SwitchStatement,this.discriminant=e,this.cases=t};t.SwitchStatement=ce;var ue=function(e,t){this.type=r.Syntax.TaggedTemplateExpression,this.tag=e,this.quasi=t};t.TaggedTemplateExpression=ue;var le=function(e,t){this.type=r.Syntax.TemplateElement,this.value=e,this.tail=t};t.TemplateElement=le;var he=function(e,t){this.type=r.Syntax.TemplateLiteral,this.quasis=e,this.expressions=t};t.TemplateLiteral=he;var de=function(){this.type=r.Syntax.ThisExpression};t.ThisExpression=de;var pe=function(e){this.type=r.Syntax.ThrowStatement,this.argument=e};t.ThrowStatement=pe;var fe=function(e,t,n){this.type=r.Syntax.TryStatement,this.block=e,this.handler=t,this.finalizer=n};t.TryStatement=fe;var me=function(e,t){this.type=r.Syntax.UnaryExpression,this.operator=e,this.argument=t,this.prefix=!0};t.UnaryExpression=me;var ge=function(e,t,n){this.type=r.Syntax.UpdateExpression,this.operator=e,this.argument=t,this.prefix=n};t.UpdateExpression=ge;var _e=function(e,t){this.type=r.Syntax.VariableDeclaration,this.declarations=e,this.kind=t};t.VariableDeclaration=_e;var ye=function(e,t){this.type=r.Syntax.VariableDeclarator,this.id=e,this.init=t};t.VariableDeclarator=ye;var ve=function(e,t){this.type=r.Syntax.WhileStatement,this.test=e,this.body=t};t.WhileStatement=ve;var be=function(e,t){this.type=r.Syntax.WithStatement,this.object=e,this.body=t};t.WithStatement=be;var we=function(e,t){this.type=r.Syntax.YieldExpression,this.argument=e,this.delegate=t};t.YieldExpression=we},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(10),o=n(11),s=n(7),a=n(12),c=n(2),u=n(13),l=function(){function e(e,t,n){void 0===t&&(t={}),this.config={range:"boolean"==typeof t.range&&t.range,loc:"boolean"==typeof t.loc&&t.loc,source:null,tokens:"boolean"==typeof t.tokens&&t.tokens,comment:"boolean"==typeof t.comment&&t.comment,tolerant:"boolean"==typeof t.tolerant&&t.tolerant},this.config.loc&&t.source&&null!==t.source&&(this.config.source=String(t.source)),this.delegate=n,this.errorHandler=new i.ErrorHandler,this.errorHandler.tolerant=this.config.tolerant,this.scanner=new a.Scanner(e,this.errorHandler),this.scanner.trackComment=this.config.comment,this.operatorPrecedence={")":0,";":0,",":0,"=":0,"]":0,"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":11,"/":11,"%":11},this.lookahead={type:2,value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0},this.hasLineTerminator=!1,this.context={isModule:!1,await:!1,allowIn:!0,allowStrictDirective:!0,allowYield:!0,firstCoverInitializedNameError:null,isAssignmentTarget:!1,isBindingElement:!1,inFunctionBody:!1,inIteration:!1,inSwitch:!1,labelSet:{},strict:!1},this.tokens=[],this.startMarker={index:0,line:this.scanner.lineNumber,column:0},this.lastMarker={index:0,line:this.scanner.lineNumber,column:0},this.nextToken(),this.lastMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}return e.prototype.throwError=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=Array.prototype.slice.call(arguments,1),o=e.replace(/%(\d)/g,(function(e,t){return r.assert(t<i.length,"Message reference must be in range"),i[t]})),s=this.lastMarker.index,a=this.lastMarker.line,c=this.lastMarker.column+1;throw this.errorHandler.createError(s,a,c,o)},e.prototype.tolerateError=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=Array.prototype.slice.call(arguments,1),o=e.replace(/%(\d)/g,(function(e,t){return r.assert(t<i.length,"Message reference must be in range"),i[t]})),s=this.lastMarker.index,a=this.scanner.lineNumber,c=this.lastMarker.column+1;this.errorHandler.tolerateError(s,a,c,o)},e.prototype.unexpectedTokenError=function(e,t){var n,r=t||o.Messages.UnexpectedToken;if(e?(t||(r=2===e.type?o.Messages.UnexpectedEOS:3===e.type?o.Messages.UnexpectedIdentifier:6===e.type?o.Messages.UnexpectedNumber:8===e.type?o.Messages.UnexpectedString:10===e.type?o.Messages.UnexpectedTemplate:o.Messages.UnexpectedToken,4===e.type&&(this.scanner.isFutureReservedWord(e.value)?r=o.Messages.UnexpectedReserved:this.context.strict&&this.scanner.isStrictModeReservedWord(e.value)&&(r=o.Messages.StrictReservedWord))),n=e.value):n="ILLEGAL",r=r.replace("%0",n),e&&"number"==typeof e.lineNumber){var i=e.start,s=e.lineNumber,a=this.lastMarker.index-this.lastMarker.column,c=e.start-a+1;return this.errorHandler.createError(i,s,c,r)}return i=this.lastMarker.index,s=this.lastMarker.line,c=this.lastMarker.column+1,this.errorHandler.createError(i,s,c,r)},e.prototype.throwUnexpectedToken=function(e,t){throw this.unexpectedTokenError(e,t)},e.prototype.tolerateUnexpectedToken=function(e,t){this.errorHandler.tolerate(this.unexpectedTokenError(e,t))},e.prototype.collectComments=function(){if(this.config.comment){var e=this.scanner.scanComments();if(e.length>0&&this.delegate)for(var t=0;t<e.length;++t){var n=e[t],r=void 0;r={type:n.multiLine?"BlockComment":"LineComment",value:this.scanner.source.slice(n.slice[0],n.slice[1])},this.config.range&&(r.range=n.range),this.config.loc&&(r.loc=n.loc);var i={start:{line:n.loc.start.line,column:n.loc.start.column,offset:n.range[0]},end:{line:n.loc.end.line,column:n.loc.end.column,offset:n.range[1]}};this.delegate(r,i)}}else this.scanner.scanComments()},e.prototype.getTokenRaw=function(e){return this.scanner.source.slice(e.start,e.end)},e.prototype.convertToken=function(e){var t={type:u.TokenName[e.type],value:this.getTokenRaw(e)};if(this.config.range&&(t.range=[e.start,e.end]),this.config.loc&&(t.loc={start:{line:this.startMarker.line,column:this.startMarker.column},end:{line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}),9===e.type){var n=e.pattern,r=e.flags;t.regex={pattern:n,flags:r}}return t},e.prototype.nextToken=function(){var e=this.lookahead;this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.collectComments(),this.scanner.index!==this.startMarker.index&&(this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart);var t=this.scanner.lex();return this.hasLineTerminator=e.lineNumber!==t.lineNumber,t&&this.context.strict&&3===t.type&&this.scanner.isStrictModeReservedWord(t.value)&&(t.type=4),this.lookahead=t,this.config.tokens&&2!==t.type&&this.tokens.push(this.convertToken(t)),e},e.prototype.nextRegexToken=function(){this.collectComments();var e=this.scanner.scanRegExp();return this.config.tokens&&(this.tokens.pop(),this.tokens.push(this.convertToken(e))),this.lookahead=e,this.nextToken(),e},e.prototype.createNode=function(){return{index:this.startMarker.index,line:this.startMarker.line,column:this.startMarker.column}},e.prototype.startNode=function(e,t){void 0===t&&(t=0);var n=e.start-e.lineStart,r=e.lineNumber;return n<0&&(n+=t,r--),{index:e.start,line:r,column:n}},e.prototype.finalize=function(e,t){if(this.config.range&&(t.range=[e.index,this.lastMarker.index]),this.config.loc&&(t.loc={start:{line:e.line,column:e.column},end:{line:this.lastMarker.line,column:this.lastMarker.column}},this.config.source&&(t.loc.source=this.config.source)),this.delegate){var n={start:{line:e.line,column:e.column,offset:e.index},end:{line:this.lastMarker.line,column:this.lastMarker.column,offset:this.lastMarker.index}};this.delegate(t,n)}return t},e.prototype.expect=function(e){var t=this.nextToken();7===t.type&&t.value===e||this.throwUnexpectedToken(t)},e.prototype.expectCommaSeparator=function(){if(this.config.tolerant){var e=this.lookahead;7===e.type&&","===e.value?this.nextToken():7===e.type&&";"===e.value?(this.nextToken(),this.tolerateUnexpectedToken(e)):this.tolerateUnexpectedToken(e,o.Messages.UnexpectedToken)}else this.expect(",")},e.prototype.expectKeyword=function(e){var t=this.nextToken();4===t.type&&t.value===e||this.throwUnexpectedToken(t)},e.prototype.match=function(e){return 7===this.lookahead.type&&this.lookahead.value===e},e.prototype.matchKeyword=function(e){return 4===this.lookahead.type&&this.lookahead.value===e},e.prototype.matchContextualKeyword=function(e){return 3===this.lookahead.type&&this.lookahead.value===e},e.prototype.matchAssign=function(){if(7!==this.lookahead.type)return!1;var e=this.lookahead.value;return"="===e||"*="===e||"**="===e||"/="===e||"%="===e||"+="===e||"-="===e||"<<="===e||">>="===e||">>>="===e||"&="===e||"^="===e||"|="===e},e.prototype.isolateCoverGrammar=function(e){var t=this.context.isBindingElement,n=this.context.isAssignmentTarget,r=this.context.firstCoverInitializedNameError;this.context.isBindingElement=!0,this.context.isAssignmentTarget=!0,this.context.firstCoverInitializedNameError=null;var i=e.call(this);return null!==this.context.firstCoverInitializedNameError&&this.throwUnexpectedToken(this.context.firstCoverInitializedNameError),this.context.isBindingElement=t,this.context.isAssignmentTarget=n,this.context.firstCoverInitializedNameError=r,i},e.prototype.inheritCoverGrammar=function(e){var t=this.context.isBindingElement,n=this.context.isAssignmentTarget,r=this.context.firstCoverInitializedNameError;this.context.isBindingElement=!0,this.context.isAssignmentTarget=!0,this.context.firstCoverInitializedNameError=null;var i=e.call(this);return this.context.isBindingElement=this.context.isBindingElement&&t,this.context.isAssignmentTarget=this.context.isAssignmentTarget&&n,this.context.firstCoverInitializedNameError=r||this.context.firstCoverInitializedNameError,i},e.prototype.consumeSemicolon=function(){this.match(";")?this.nextToken():this.hasLineTerminator||(2===this.lookahead.type||this.match("}")||this.throwUnexpectedToken(this.lookahead),this.lastMarker.index=this.startMarker.index,this.lastMarker.line=this.startMarker.line,this.lastMarker.column=this.startMarker.column)},e.prototype.parsePrimaryExpression=function(){var e,t,n,r=this.createNode();switch(this.lookahead.type){case 3:(this.context.isModule||this.context.await)&&"await"===this.lookahead.value&&this.tolerateUnexpectedToken(this.lookahead),e=this.matchAsyncFunction()?this.parseFunctionExpression():this.finalize(r,new s.Identifier(this.nextToken().value));break;case 6:case 8:this.context.strict&&this.lookahead.octal&&this.tolerateUnexpectedToken(this.lookahead,o.Messages.StrictOctalLiteral),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,t=this.nextToken(),n=this.getTokenRaw(t),e=this.finalize(r,new s.Literal(t.value,n));break;case 1:this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,t=this.nextToken(),n=this.getTokenRaw(t),e=this.finalize(r,new s.Literal("true"===t.value,n));break;case 5:this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,t=this.nextToken(),n=this.getTokenRaw(t),e=this.finalize(r,new s.Literal(null,n));break;case 10:e=this.parseTemplateLiteral();break;case 7:switch(this.lookahead.value){case"(":this.context.isBindingElement=!1,e=this.inheritCoverGrammar(this.parseGroupExpression);break;case"[":e=this.inheritCoverGrammar(this.parseArrayInitializer);break;case"{":e=this.inheritCoverGrammar(this.parseObjectInitializer);break;case"/":case"/=":this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.scanner.index=this.startMarker.index,t=this.nextRegexToken(),n=this.getTokenRaw(t),e=this.finalize(r,new s.RegexLiteral(t.regex,n,t.pattern,t.flags));break;default:e=this.throwUnexpectedToken(this.nextToken())}break;case 4:!this.context.strict&&this.context.allowYield&&this.matchKeyword("yield")?e=this.parseIdentifierName():!this.context.strict&&this.matchKeyword("let")?e=this.finalize(r,new s.Identifier(this.nextToken().value)):(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.matchKeyword("function")?e=this.parseFunctionExpression():this.matchKeyword("this")?(this.nextToken(),e=this.finalize(r,new s.ThisExpression)):e=this.matchKeyword("class")?this.parseClassExpression():this.throwUnexpectedToken(this.nextToken()));break;default:e=this.throwUnexpectedToken(this.nextToken())}return e},e.prototype.parseSpreadElement=function(){var e=this.createNode();this.expect("...");var t=this.inheritCoverGrammar(this.parseAssignmentExpression);return this.finalize(e,new s.SpreadElement(t))},e.prototype.parseArrayInitializer=function(){var e=this.createNode(),t=[];for(this.expect("[");!this.match("]");)if(this.match(","))this.nextToken(),t.push(null);else if(this.match("...")){var n=this.parseSpreadElement();this.match("]")||(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.expect(",")),t.push(n)}else t.push(this.inheritCoverGrammar(this.parseAssignmentExpression)),this.match("]")||this.expect(",");return this.expect("]"),this.finalize(e,new s.ArrayExpression(t))},e.prototype.parsePropertyMethod=function(e){this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var t=this.context.strict,n=this.context.allowStrictDirective;this.context.allowStrictDirective=e.simple;var r=this.isolateCoverGrammar(this.parseFunctionSourceElements);return this.context.strict&&e.firstRestricted&&this.tolerateUnexpectedToken(e.firstRestricted,e.message),this.context.strict&&e.stricted&&this.tolerateUnexpectedToken(e.stricted,e.message),this.context.strict=t,this.context.allowStrictDirective=n,r},e.prototype.parsePropertyMethodFunction=function(){var e=this.createNode(),t=this.context.allowYield;this.context.allowYield=!0;var n=this.parseFormalParameters(),r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new s.FunctionExpression(null,n.params,r,!1))},e.prototype.parsePropertyMethodAsyncFunction=function(){var e=this.createNode(),t=this.context.allowYield,n=this.context.await;this.context.allowYield=!1,this.context.await=!0;var r=this.parseFormalParameters(),i=this.parsePropertyMethod(r);return this.context.allowYield=t,this.context.await=n,this.finalize(e,new s.AsyncFunctionExpression(null,r.params,i))},e.prototype.parseObjectPropertyKey=function(){var e,t=this.createNode(),n=this.nextToken();switch(n.type){case 8:case 6:this.context.strict&&n.octal&&this.tolerateUnexpectedToken(n,o.Messages.StrictOctalLiteral);var r=this.getTokenRaw(n);e=this.finalize(t,new s.Literal(n.value,r));break;case 3:case 1:case 5:case 4:e=this.finalize(t,new s.Identifier(n.value));break;case 7:"["===n.value?(e=this.isolateCoverGrammar(this.parseAssignmentExpression),this.expect("]")):e=this.throwUnexpectedToken(n);break;default:e=this.throwUnexpectedToken(n)}return e},e.prototype.isPropertyKey=function(e,t){return e.type===c.Syntax.Identifier&&e.name===t||e.type===c.Syntax.Literal&&e.value===t},e.prototype.parseObjectProperty=function(e){var t,n=this.createNode(),r=this.lookahead,i=null,a=null,c=!1,u=!1,l=!1,h=!1;if(3===r.type){var d=r.value;this.nextToken(),c=this.match("["),i=(h=!(this.hasLineTerminator||"async"!==d||this.match(":")||this.match("(")||this.match("*")||this.match(",")))?this.parseObjectPropertyKey():this.finalize(n,new s.Identifier(d))}else this.match("*")?this.nextToken():(c=this.match("["),i=this.parseObjectPropertyKey());var p=this.qualifiedPropertyName(this.lookahead);if(3===r.type&&!h&&"get"===r.value&&p)t="get",c=this.match("["),i=this.parseObjectPropertyKey(),this.context.allowYield=!1,a=this.parseGetterMethod();else if(3===r.type&&!h&&"set"===r.value&&p)t="set",c=this.match("["),i=this.parseObjectPropertyKey(),a=this.parseSetterMethod();else if(7===r.type&&"*"===r.value&&p)t="init",c=this.match("["),i=this.parseObjectPropertyKey(),a=this.parseGeneratorMethod(),u=!0;else if(i||this.throwUnexpectedToken(this.lookahead),t="init",this.match(":")&&!h)!c&&this.isPropertyKey(i,"__proto__")&&(e.value&&this.tolerateError(o.Messages.DuplicateProtoProperty),e.value=!0),this.nextToken(),a=this.inheritCoverGrammar(this.parseAssignmentExpression);else if(this.match("("))a=h?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction(),u=!0;else if(3===r.type)if(d=this.finalize(n,new s.Identifier(r.value)),this.match("=")){this.context.firstCoverInitializedNameError=this.lookahead,this.nextToken(),l=!0;var f=this.isolateCoverGrammar(this.parseAssignmentExpression);a=this.finalize(n,new s.AssignmentPattern(d,f))}else l=!0,a=d;else this.throwUnexpectedToken(this.nextToken());return this.finalize(n,new s.Property(t,i,c,a,u,l))},e.prototype.parseObjectInitializer=function(){var e=this.createNode();this.expect("{");for(var t=[],n={value:!1};!this.match("}");)t.push(this.parseObjectProperty(n)),this.match("}")||this.expectCommaSeparator();return this.expect("}"),this.finalize(e,new s.ObjectExpression(t))},e.prototype.parseTemplateHead=function(){r.assert(this.lookahead.head,"Template literal must start with a template head");var e=this.createNode(),t=this.nextToken(),n=t.value,i=t.cooked;return this.finalize(e,new s.TemplateElement({raw:n,cooked:i},t.tail))},e.prototype.parseTemplateElement=function(){10!==this.lookahead.type&&this.throwUnexpectedToken();var e=this.createNode(),t=this.nextToken(),n=t.value,r=t.cooked;return this.finalize(e,new s.TemplateElement({raw:n,cooked:r},t.tail))},e.prototype.parseTemplateLiteral=function(){var e=this.createNode(),t=[],n=[],r=this.parseTemplateHead();for(n.push(r);!r.tail;)t.push(this.parseExpression()),r=this.parseTemplateElement(),n.push(r);return this.finalize(e,new s.TemplateLiteral(n,t))},e.prototype.reinterpretExpressionAsPattern=function(e){switch(e.type){case c.Syntax.Identifier:case c.Syntax.MemberExpression:case c.Syntax.RestElement:case c.Syntax.AssignmentPattern:break;case c.Syntax.SpreadElement:e.type=c.Syntax.RestElement,this.reinterpretExpressionAsPattern(e.argument);break;case c.Syntax.ArrayExpression:e.type=c.Syntax.ArrayPattern;for(var t=0;t<e.elements.length;t++)null!==e.elements[t]&&this.reinterpretExpressionAsPattern(e.elements[t]);break;case c.Syntax.ObjectExpression:for(e.type=c.Syntax.ObjectPattern,t=0;t<e.properties.length;t++)this.reinterpretExpressionAsPattern(e.properties[t].value);break;case c.Syntax.AssignmentExpression:e.type=c.Syntax.AssignmentPattern,delete e.operator,this.reinterpretExpressionAsPattern(e.left)}},e.prototype.parseGroupExpression=function(){var e;if(this.expect("("),this.match(")"))this.nextToken(),this.match("=>")||this.expect("=>"),e={type:"ArrowParameterPlaceHolder",params:[],async:!1};else{var t=this.lookahead,n=[];if(this.match("..."))e=this.parseRestElement(n),this.expect(")"),this.match("=>")||this.expect("=>"),e={type:"ArrowParameterPlaceHolder",params:[e],async:!1};else{var r=!1;if(this.context.isBindingElement=!0,e=this.inheritCoverGrammar(this.parseAssignmentExpression),this.match(",")){var i=[];for(this.context.isAssignmentTarget=!1,i.push(e);2!==this.lookahead.type&&this.match(",");){if(this.nextToken(),this.match(")")){this.nextToken();for(var o=0;o<i.length;o++)this.reinterpretExpressionAsPattern(i[o]);r=!0,e={type:"ArrowParameterPlaceHolder",params:i,async:!1}}else if(this.match("...")){for(this.context.isBindingElement||this.throwUnexpectedToken(this.lookahead),i.push(this.parseRestElement(n)),this.expect(")"),this.match("=>")||this.expect("=>"),this.context.isBindingElement=!1,o=0;o<i.length;o++)this.reinterpretExpressionAsPattern(i[o]);r=!0,e={type:"ArrowParameterPlaceHolder",params:i,async:!1}}else i.push(this.inheritCoverGrammar(this.parseAssignmentExpression));if(r)break}r||(e=this.finalize(this.startNode(t),new s.SequenceExpression(i)))}if(!r){if(this.expect(")"),this.match("=>")&&(e.type===c.Syntax.Identifier&&"yield"===e.name&&(r=!0,e={type:"ArrowParameterPlaceHolder",params:[e],async:!1}),!r)){if(this.context.isBindingElement||this.throwUnexpectedToken(this.lookahead),e.type===c.Syntax.SequenceExpression)for(o=0;o<e.expressions.length;o++)this.reinterpretExpressionAsPattern(e.expressions[o]);else this.reinterpretExpressionAsPattern(e);e={type:"ArrowParameterPlaceHolder",params:e.type===c.Syntax.SequenceExpression?e.expressions:[e],async:!1}}this.context.isBindingElement=!1}}}return e},e.prototype.parseArguments=function(){this.expect("(");var e=[];if(!this.match(")"))for(;;){var t=this.match("...")?this.parseSpreadElement():this.isolateCoverGrammar(this.parseAssignmentExpression);if(e.push(t),this.match(")"))break;if(this.expectCommaSeparator(),this.match(")"))break}return this.expect(")"),e},e.prototype.isIdentifierName=function(e){return 3===e.type||4===e.type||1===e.type||5===e.type},e.prototype.parseIdentifierName=function(){var e=this.createNode(),t=this.nextToken();return this.isIdentifierName(t)||this.throwUnexpectedToken(t),this.finalize(e,new s.Identifier(t.value))},e.prototype.parseNewExpression=function(){var e,t=this.createNode(),n=this.parseIdentifierName();if(r.assert("new"===n.name,"New expression must start with `new`"),this.match("."))if(this.nextToken(),3===this.lookahead.type&&this.context.inFunctionBody&&"target"===this.lookahead.value){var i=this.parseIdentifierName();e=new s.MetaProperty(n,i)}else this.throwUnexpectedToken(this.lookahead);else{var o=this.isolateCoverGrammar(this.parseLeftHandSideExpression),a=this.match("(")?this.parseArguments():[];e=new s.NewExpression(o,a),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}return this.finalize(t,e)},e.prototype.parseAsyncArgument=function(){var e=this.parseAssignmentExpression();return this.context.firstCoverInitializedNameError=null,e},e.prototype.parseAsyncArguments=function(){this.expect("(");var e=[];if(!this.match(")"))for(;;){var t=this.match("...")?this.parseSpreadElement():this.isolateCoverGrammar(this.parseAsyncArgument);if(e.push(t),this.match(")"))break;if(this.expectCommaSeparator(),this.match(")"))break}return this.expect(")"),e},e.prototype.parseLeftHandSideExpressionAllowCall=function(){var e,t=this.lookahead,n=this.matchContextualKeyword("async"),r=this.context.allowIn;for(this.context.allowIn=!0,this.matchKeyword("super")&&this.context.inFunctionBody?(e=this.createNode(),this.nextToken(),e=this.finalize(e,new s.Super),this.match("(")||this.match(".")||this.match("[")||this.throwUnexpectedToken(this.lookahead)):e=this.inheritCoverGrammar(this.matchKeyword("new")?this.parseNewExpression:this.parsePrimaryExpression);;)if(this.match(".")){this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect(".");var i=this.parseIdentifierName();e=this.finalize(this.startNode(t),new s.StaticMemberExpression(e,i))}else if(this.match("(")){var o=n&&t.lineNumber===this.lookahead.lineNumber;this.context.isBindingElement=!1,this.context.isAssignmentTarget=!1;var a=o?this.parseAsyncArguments():this.parseArguments();if(e=this.finalize(this.startNode(t),new s.CallExpression(e,a)),o&&this.match("=>")){for(var c=0;c<a.length;++c)this.reinterpretExpressionAsPattern(a[c]);e={type:"ArrowParameterPlaceHolder",params:a,async:!0}}}else if(this.match("["))this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect("["),i=this.isolateCoverGrammar(this.parseExpression),this.expect("]"),e=this.finalize(this.startNode(t),new s.ComputedMemberExpression(e,i));else{if(10!==this.lookahead.type||!this.lookahead.head)break;var u=this.parseTemplateLiteral();e=this.finalize(this.startNode(t),new s.TaggedTemplateExpression(e,u))}return this.context.allowIn=r,e},e.prototype.parseSuper=function(){var e=this.createNode();return this.expectKeyword("super"),this.match("[")||this.match(".")||this.throwUnexpectedToken(this.lookahead),this.finalize(e,new s.Super)},e.prototype.parseLeftHandSideExpression=function(){r.assert(this.context.allowIn,"callee of new expression always allow in keyword.");for(var e=this.startNode(this.lookahead),t=this.matchKeyword("super")&&this.context.inFunctionBody?this.parseSuper():this.inheritCoverGrammar(this.matchKeyword("new")?this.parseNewExpression:this.parsePrimaryExpression);;)if(this.match("[")){this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect("[");var n=this.isolateCoverGrammar(this.parseExpression);this.expect("]"),t=this.finalize(e,new s.ComputedMemberExpression(t,n))}else if(this.match("."))this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect("."),n=this.parseIdentifierName(),t=this.finalize(e,new s.StaticMemberExpression(t,n));else{if(10!==this.lookahead.type||!this.lookahead.head)break;var i=this.parseTemplateLiteral();t=this.finalize(e,new s.TaggedTemplateExpression(t,i))}return t},e.prototype.parseUpdateExpression=function(){var e,t=this.lookahead;if(this.match("++")||this.match("--")){var n=this.startNode(t),r=this.nextToken();e=this.inheritCoverGrammar(this.parseUnaryExpression),this.context.strict&&e.type===c.Syntax.Identifier&&this.scanner.isRestrictedWord(e.name)&&this.tolerateError(o.Messages.StrictLHSPrefix),this.context.isAssignmentTarget||this.tolerateError(o.Messages.InvalidLHSInAssignment);var i=!0;e=this.finalize(n,new s.UpdateExpression(r.value,e,i)),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}else if(e=this.inheritCoverGrammar(this.parseLeftHandSideExpressionAllowCall),!this.hasLineTerminator&&7===this.lookahead.type&&(this.match("++")||this.match("--"))){this.context.strict&&e.type===c.Syntax.Identifier&&this.scanner.isRestrictedWord(e.name)&&this.tolerateError(o.Messages.StrictLHSPostfix),this.context.isAssignmentTarget||this.tolerateError(o.Messages.InvalidLHSInAssignment),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var a=this.nextToken().value;i=!1,e=this.finalize(this.startNode(t),new s.UpdateExpression(a,e,i))}return e},e.prototype.parseAwaitExpression=function(){var e=this.createNode();this.nextToken();var t=this.parseUnaryExpression();return this.finalize(e,new s.AwaitExpression(t))},e.prototype.parseUnaryExpression=function(){var e;if(this.match("+")||this.match("-")||this.match("~")||this.match("!")||this.matchKeyword("delete")||this.matchKeyword("void")||this.matchKeyword("typeof")){var t=this.startNode(this.lookahead),n=this.nextToken();e=this.inheritCoverGrammar(this.parseUnaryExpression),e=this.finalize(t,new s.UnaryExpression(n.value,e)),this.context.strict&&"delete"===e.operator&&e.argument.type===c.Syntax.Identifier&&this.tolerateError(o.Messages.StrictDelete),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}else e=this.context.await&&this.matchContextualKeyword("await")?this.parseAwaitExpression():this.parseUpdateExpression();return e},e.prototype.parseExponentiationExpression=function(){var e=this.lookahead,t=this.inheritCoverGrammar(this.parseUnaryExpression);if(t.type!==c.Syntax.UnaryExpression&&this.match("**")){this.nextToken(),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var n=t,r=this.isolateCoverGrammar(this.parseExponentiationExpression);t=this.finalize(this.startNode(e),new s.BinaryExpression("**",n,r))}return t},e.prototype.binaryPrecedence=function(e){var t=e.value;return 7===e.type?this.operatorPrecedence[t]||0:4===e.type&&("instanceof"===t||this.context.allowIn&&"in"===t)?7:0},e.prototype.parseBinaryExpression=function(){var e=this.lookahead,t=this.inheritCoverGrammar(this.parseExponentiationExpression),n=this.lookahead,r=this.binaryPrecedence(n);if(r>0){this.nextToken(),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;for(var i=[e,this.lookahead],o=t,a=this.isolateCoverGrammar(this.parseExponentiationExpression),c=[o,n.value,a],u=[r];!((r=this.binaryPrecedence(this.lookahead))<=0);){for(;c.length>2&&r<=u[u.length-1];){a=c.pop();var l=c.pop();u.pop(),o=c.pop(),i.pop();var h=this.startNode(i[i.length-1]);c.push(this.finalize(h,new s.BinaryExpression(l,o,a)))}c.push(this.nextToken().value),u.push(r),i.push(this.lookahead),c.push(this.isolateCoverGrammar(this.parseExponentiationExpression))}var d=c.length-1;t=c[d];for(var p=i.pop();d>1;){var f=i.pop(),m=p&&p.lineStart;h=this.startNode(f,m),l=c[d-1],t=this.finalize(h,new s.BinaryExpression(l,c[d-2],t)),d-=2,p=f}}return t},e.prototype.parseConditionalExpression=function(){var e=this.lookahead,t=this.inheritCoverGrammar(this.parseBinaryExpression);if(this.match("?")){this.nextToken();var n=this.context.allowIn;this.context.allowIn=!0;var r=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowIn=n,this.expect(":");var i=this.isolateCoverGrammar(this.parseAssignmentExpression);t=this.finalize(this.startNode(e),new s.ConditionalExpression(t,r,i)),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}return t},e.prototype.checkPatternParam=function(e,t){switch(t.type){case c.Syntax.Identifier:this.validateParam(e,t,t.name);break;case c.Syntax.RestElement:this.checkPatternParam(e,t.argument);break;case c.Syntax.AssignmentPattern:this.checkPatternParam(e,t.left);break;case c.Syntax.ArrayPattern:for(var n=0;n<t.elements.length;n++)null!==t.elements[n]&&this.checkPatternParam(e,t.elements[n]);break;case c.Syntax.ObjectPattern:for(n=0;n<t.properties.length;n++)this.checkPatternParam(e,t.properties[n].value)}e.simple=e.simple&&t instanceof s.Identifier},e.prototype.reinterpretAsCoverFormalsList=function(e){var t,n=[e],r=!1;switch(e.type){case c.Syntax.Identifier:break;case"ArrowParameterPlaceHolder":n=e.params,r=e.async;break;default:return null}t={simple:!0,paramSet:{}};for(var i=0;i<n.length;++i)(s=n[i]).type===c.Syntax.AssignmentPattern?s.right.type===c.Syntax.YieldExpression&&(s.right.argument&&this.throwUnexpectedToken(this.lookahead),s.right.type=c.Syntax.Identifier,s.right.name="yield",delete s.right.argument,delete s.right.delegate):r&&s.type===c.Syntax.Identifier&&"await"===s.name&&this.throwUnexpectedToken(this.lookahead),this.checkPatternParam(t,s),n[i]=s;if(this.context.strict||!this.context.allowYield)for(i=0;i<n.length;++i){var s;(s=n[i]).type===c.Syntax.YieldExpression&&this.throwUnexpectedToken(this.lookahead)}if(t.message===o.Messages.StrictParamDupe){var a=this.context.strict?t.stricted:t.firstRestricted;this.throwUnexpectedToken(a,t.message)}return{simple:t.simple,params:n,stricted:t.stricted,firstRestricted:t.firstRestricted,message:t.message}},e.prototype.parseAssignmentExpression=function(){var e;if(!this.context.allowYield&&this.matchKeyword("yield"))e=this.parseYieldExpression();else{var t=this.lookahead,n=t;if(e=this.parseConditionalExpression(),3===n.type&&n.lineNumber===this.lookahead.lineNumber&&"async"===n.value&&(3===this.lookahead.type||this.matchKeyword("yield"))){var r=this.parsePrimaryExpression();this.reinterpretExpressionAsPattern(r),e={type:"ArrowParameterPlaceHolder",params:[r],async:!0}}if("ArrowParameterPlaceHolder"===e.type||this.match("=>")){this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var i=e.async,a=this.reinterpretAsCoverFormalsList(e);if(a){this.hasLineTerminator&&this.tolerateUnexpectedToken(this.lookahead),this.context.firstCoverInitializedNameError=null;var u=this.context.strict,l=this.context.allowStrictDirective;this.context.allowStrictDirective=a.simple;var h=this.context.allowYield,d=this.context.await;this.context.allowYield=!0,this.context.await=i;var p=this.startNode(t);this.expect("=>");var f=void 0;if(this.match("{")){var m=this.context.allowIn;this.context.allowIn=!0,f=this.parseFunctionSourceElements(),this.context.allowIn=m}else f=this.isolateCoverGrammar(this.parseAssignmentExpression);var g=f.type!==c.Syntax.BlockStatement;this.context.strict&&a.firstRestricted&&this.throwUnexpectedToken(a.firstRestricted,a.message),this.context.strict&&a.stricted&&this.tolerateUnexpectedToken(a.stricted,a.message),e=i?this.finalize(p,new s.AsyncArrowFunctionExpression(a.params,f,g)):this.finalize(p,new s.ArrowFunctionExpression(a.params,f,g)),this.context.strict=u,this.context.allowStrictDirective=l,this.context.allowYield=h,this.context.await=d}}else if(this.matchAssign()){if(this.context.isAssignmentTarget||this.tolerateError(o.Messages.InvalidLHSInAssignment),this.context.strict&&e.type===c.Syntax.Identifier){var _=e;this.scanner.isRestrictedWord(_.name)&&this.tolerateUnexpectedToken(n,o.Messages.StrictLHSAssignment),this.scanner.isStrictModeReservedWord(_.name)&&this.tolerateUnexpectedToken(n,o.Messages.StrictReservedWord)}this.match("=")?this.reinterpretExpressionAsPattern(e):(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1);var y=(n=this.nextToken()).value,v=this.isolateCoverGrammar(this.parseAssignmentExpression);e=this.finalize(this.startNode(t),new s.AssignmentExpression(y,e,v)),this.context.firstCoverInitializedNameError=null}}return e},e.prototype.parseExpression=function(){var e=this.lookahead,t=this.isolateCoverGrammar(this.parseAssignmentExpression);if(this.match(",")){var n=[];for(n.push(t);2!==this.lookahead.type&&this.match(",");)this.nextToken(),n.push(this.isolateCoverGrammar(this.parseAssignmentExpression));t=this.finalize(this.startNode(e),new s.SequenceExpression(n))}return t},e.prototype.parseStatementListItem=function(){var e;if(this.context.isAssignmentTarget=!0,this.context.isBindingElement=!0,4===this.lookahead.type)switch(this.lookahead.value){case"export":this.context.isModule||this.tolerateUnexpectedToken(this.lookahead,o.Messages.IllegalExportDeclaration),e=this.parseExportDeclaration();break;case"import":this.context.isModule||this.tolerateUnexpectedToken(this.lookahead,o.Messages.IllegalImportDeclaration),e=this.parseImportDeclaration();break;case"const":e=this.parseLexicalDeclaration({inFor:!1});break;case"function":e=this.parseFunctionDeclaration();break;case"class":e=this.parseClassDeclaration();break;case"let":e=this.isLexicalDeclaration()?this.parseLexicalDeclaration({inFor:!1}):this.parseStatement();break;default:e=this.parseStatement()}else e=this.parseStatement();return e},e.prototype.parseBlock=function(){var e=this.createNode();this.expect("{");for(var t=[];!this.match("}");)t.push(this.parseStatementListItem());return this.expect("}"),this.finalize(e,new s.BlockStatement(t))},e.prototype.parseLexicalBinding=function(e,t){var n=this.createNode(),r=this.parsePattern([],e);this.context.strict&&r.type===c.Syntax.Identifier&&this.scanner.isRestrictedWord(r.name)&&this.tolerateError(o.Messages.StrictVarName);var i=null;return"const"===e?this.matchKeyword("in")||this.matchContextualKeyword("of")||(this.match("=")?(this.nextToken(),i=this.isolateCoverGrammar(this.parseAssignmentExpression)):this.throwError(o.Messages.DeclarationMissingInitializer,"const")):(!t.inFor&&r.type!==c.Syntax.Identifier||this.match("="))&&(this.expect("="),i=this.isolateCoverGrammar(this.parseAssignmentExpression)),this.finalize(n,new s.VariableDeclarator(r,i))},e.prototype.parseBindingList=function(e,t){for(var n=[this.parseLexicalBinding(e,t)];this.match(",");)this.nextToken(),n.push(this.parseLexicalBinding(e,t));return n},e.prototype.isLexicalDeclaration=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.scanner.lex();return this.scanner.restoreState(e),3===t.type||7===t.type&&"["===t.value||7===t.type&&"{"===t.value||4===t.type&&"let"===t.value||4===t.type&&"yield"===t.value},e.prototype.parseLexicalDeclaration=function(e){var t=this.createNode(),n=this.nextToken().value;r.assert("let"===n||"const"===n,"Lexical declaration must be either let or const");var i=this.parseBindingList(n,e);return this.consumeSemicolon(),this.finalize(t,new s.VariableDeclaration(i,n))},e.prototype.parseBindingRestElement=function(e,t){var n=this.createNode();this.expect("...");var r=this.parsePattern(e,t);return this.finalize(n,new s.RestElement(r))},e.prototype.parseArrayPattern=function(e,t){var n=this.createNode();this.expect("[");for(var r=[];!this.match("]");)if(this.match(","))this.nextToken(),r.push(null);else{if(this.match("...")){r.push(this.parseBindingRestElement(e,t));break}r.push(this.parsePatternWithDefault(e,t)),this.match("]")||this.expect(",")}return this.expect("]"),this.finalize(n,new s.ArrayPattern(r))},e.prototype.parsePropertyPattern=function(e,t){var n,r,i=this.createNode(),o=!1,a=!1;if(3===this.lookahead.type){var c=this.lookahead;n=this.parseVariableIdentifier();var u=this.finalize(i,new s.Identifier(c.value));if(this.match("=")){e.push(c),a=!0,this.nextToken();var l=this.parseAssignmentExpression();r=this.finalize(this.startNode(c),new s.AssignmentPattern(u,l))}else this.match(":")?(this.expect(":"),r=this.parsePatternWithDefault(e,t)):(e.push(c),a=!0,r=u)}else o=this.match("["),n=this.parseObjectPropertyKey(),this.expect(":"),r=this.parsePatternWithDefault(e,t);return this.finalize(i,new s.Property("init",n,o,r,!1,a))},e.prototype.parseObjectPattern=function(e,t){var n=this.createNode(),r=[];for(this.expect("{");!this.match("}");)r.push(this.parsePropertyPattern(e,t)),this.match("}")||this.expect(",");return this.expect("}"),this.finalize(n,new s.ObjectPattern(r))},e.prototype.parsePattern=function(e,t){var n;return this.match("[")?n=this.parseArrayPattern(e,t):this.match("{")?n=this.parseObjectPattern(e,t):(!this.matchKeyword("let")||"const"!==t&&"let"!==t||this.tolerateUnexpectedToken(this.lookahead,o.Messages.LetInLexicalBinding),e.push(this.lookahead),n=this.parseVariableIdentifier(t)),n},e.prototype.parsePatternWithDefault=function(e,t){var n=this.lookahead,r=this.parsePattern(e,t);if(this.match("=")){this.nextToken();var i=this.context.allowYield;this.context.allowYield=!0;var o=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowYield=i,r=this.finalize(this.startNode(n),new s.AssignmentPattern(r,o))}return r},e.prototype.parseVariableIdentifier=function(e){var t=this.createNode(),n=this.nextToken();return 4===n.type&&"yield"===n.value?this.context.strict?this.tolerateUnexpectedToken(n,o.Messages.StrictReservedWord):this.context.allowYield||this.throwUnexpectedToken(n):3!==n.type?this.context.strict&&4===n.type&&this.scanner.isStrictModeReservedWord(n.value)?this.tolerateUnexpectedToken(n,o.Messages.StrictReservedWord):(this.context.strict||"let"!==n.value||"var"!==e)&&this.throwUnexpectedToken(n):(this.context.isModule||this.context.await)&&3===n.type&&"await"===n.value&&this.tolerateUnexpectedToken(n),this.finalize(t,new s.Identifier(n.value))},e.prototype.parseVariableDeclaration=function(e){var t=this.createNode(),n=this.parsePattern([],"var");this.context.strict&&n.type===c.Syntax.Identifier&&this.scanner.isRestrictedWord(n.name)&&this.tolerateError(o.Messages.StrictVarName);var r=null;return this.match("=")?(this.nextToken(),r=this.isolateCoverGrammar(this.parseAssignmentExpression)):n.type===c.Syntax.Identifier||e.inFor||this.expect("="),this.finalize(t,new s.VariableDeclarator(n,r))},e.prototype.parseVariableDeclarationList=function(e){var t={inFor:e.inFor},n=[];for(n.push(this.parseVariableDeclaration(t));this.match(",");)this.nextToken(),n.push(this.parseVariableDeclaration(t));return n},e.prototype.parseVariableStatement=function(){var e=this.createNode();this.expectKeyword("var");var t=this.parseVariableDeclarationList({inFor:!1});return this.consumeSemicolon(),this.finalize(e,new s.VariableDeclaration(t,"var"))},e.prototype.parseEmptyStatement=function(){var e=this.createNode();return this.expect(";"),this.finalize(e,new s.EmptyStatement)},e.prototype.parseExpressionStatement=function(){var e=this.createNode(),t=this.parseExpression();return this.consumeSemicolon(),this.finalize(e,new s.ExpressionStatement(t))},e.prototype.parseIfClause=function(){return this.context.strict&&this.matchKeyword("function")&&this.tolerateError(o.Messages.StrictFunction),this.parseStatement()},e.prototype.parseIfStatement=function(){var e,t=this.createNode(),n=null;this.expectKeyword("if"),this.expect("(");var r=this.parseExpression();return!this.match(")")&&this.config.tolerant?(this.tolerateUnexpectedToken(this.nextToken()),e=this.finalize(this.createNode(),new s.EmptyStatement)):(this.expect(")"),e=this.parseIfClause(),this.matchKeyword("else")&&(this.nextToken(),n=this.parseIfClause())),this.finalize(t,new s.IfStatement(r,e,n))},e.prototype.parseDoWhileStatement=function(){var e=this.createNode();this.expectKeyword("do");var t=this.context.inIteration;this.context.inIteration=!0;var n=this.parseStatement();this.context.inIteration=t,this.expectKeyword("while"),this.expect("(");var r=this.parseExpression();return!this.match(")")&&this.config.tolerant?this.tolerateUnexpectedToken(this.nextToken()):(this.expect(")"),this.match(";")&&this.nextToken()),this.finalize(e,new s.DoWhileStatement(n,r))},e.prototype.parseWhileStatement=function(){var e,t=this.createNode();this.expectKeyword("while"),this.expect("(");var n=this.parseExpression();if(!this.match(")")&&this.config.tolerant)this.tolerateUnexpectedToken(this.nextToken()),e=this.finalize(this.createNode(),new s.EmptyStatement);else{this.expect(")");var r=this.context.inIteration;this.context.inIteration=!0,e=this.parseStatement(),this.context.inIteration=r}return this.finalize(t,new s.WhileStatement(n,e))},e.prototype.parseForStatement=function(){var e,t,n,r=null,i=null,a=null,u=!0,l=this.createNode();if(this.expectKeyword("for"),this.expect("("),this.match(";"))this.nextToken();else if(this.matchKeyword("var")){r=this.createNode(),this.nextToken();var h=this.context.allowIn;this.context.allowIn=!1;var d=this.parseVariableDeclarationList({inFor:!0});if(this.context.allowIn=h,1===d.length&&this.matchKeyword("in")){var p=d[0];p.init&&(p.id.type===c.Syntax.ArrayPattern||p.id.type===c.Syntax.ObjectPattern||this.context.strict)&&this.tolerateError(o.Messages.ForInOfLoopInitializer,"for-in"),r=this.finalize(r,new s.VariableDeclaration(d,"var")),this.nextToken(),e=r,t=this.parseExpression(),r=null}else 1===d.length&&null===d[0].init&&this.matchContextualKeyword("of")?(r=this.finalize(r,new s.VariableDeclaration(d,"var")),this.nextToken(),e=r,t=this.parseAssignmentExpression(),r=null,u=!1):(r=this.finalize(r,new s.VariableDeclaration(d,"var")),this.expect(";"))}else if(this.matchKeyword("const")||this.matchKeyword("let")){r=this.createNode();var f=this.nextToken().value;this.context.strict||"in"!==this.lookahead.value?(h=this.context.allowIn,this.context.allowIn=!1,d=this.parseBindingList(f,{inFor:!0}),this.context.allowIn=h,1===d.length&&null===d[0].init&&this.matchKeyword("in")?(r=this.finalize(r,new s.VariableDeclaration(d,f)),this.nextToken(),e=r,t=this.parseExpression(),r=null):1===d.length&&null===d[0].init&&this.matchContextualKeyword("of")?(r=this.finalize(r,new s.VariableDeclaration(d,f)),this.nextToken(),e=r,t=this.parseAssignmentExpression(),r=null,u=!1):(this.consumeSemicolon(),r=this.finalize(r,new s.VariableDeclaration(d,f)))):(r=this.finalize(r,new s.Identifier(f)),this.nextToken(),e=r,t=this.parseExpression(),r=null)}else{var m=this.lookahead;if(h=this.context.allowIn,this.context.allowIn=!1,r=this.inheritCoverGrammar(this.parseAssignmentExpression),this.context.allowIn=h,this.matchKeyword("in"))this.context.isAssignmentTarget&&r.type!==c.Syntax.AssignmentExpression||this.tolerateError(o.Messages.InvalidLHSInForIn),this.nextToken(),this.reinterpretExpressionAsPattern(r),e=r,t=this.parseExpression(),r=null;else if(this.matchContextualKeyword("of"))this.context.isAssignmentTarget&&r.type!==c.Syntax.AssignmentExpression||this.tolerateError(o.Messages.InvalidLHSInForLoop),this.nextToken(),this.reinterpretExpressionAsPattern(r),e=r,t=this.parseAssignmentExpression(),r=null,u=!1;else{if(this.match(",")){for(var g=[r];this.match(",");)this.nextToken(),g.push(this.isolateCoverGrammar(this.parseAssignmentExpression));r=this.finalize(this.startNode(m),new s.SequenceExpression(g))}this.expect(";")}}if(void 0===e&&(this.match(";")||(i=this.parseExpression()),this.expect(";"),this.match(")")||(a=this.parseExpression())),!this.match(")")&&this.config.tolerant)this.tolerateUnexpectedToken(this.nextToken()),n=this.finalize(this.createNode(),new s.EmptyStatement);else{this.expect(")");var _=this.context.inIteration;this.context.inIteration=!0,n=this.isolateCoverGrammar(this.parseStatement),this.context.inIteration=_}return void 0===e?this.finalize(l,new s.ForStatement(r,i,a,n)):u?this.finalize(l,new s.ForInStatement(e,t,n)):this.finalize(l,new s.ForOfStatement(e,t,n))},e.prototype.parseContinueStatement=function(){var e=this.createNode();this.expectKeyword("continue");var t=null;if(3===this.lookahead.type&&!this.hasLineTerminator){var n=this.parseVariableIdentifier();t=n;var r="$"+n.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,r)||this.throwError(o.Messages.UnknownLabel,n.name)}return this.consumeSemicolon(),null!==t||this.context.inIteration||this.throwError(o.Messages.IllegalContinue),this.finalize(e,new s.ContinueStatement(t))},e.prototype.parseBreakStatement=function(){var e=this.createNode();this.expectKeyword("break");var t=null;if(3===this.lookahead.type&&!this.hasLineTerminator){var n=this.parseVariableIdentifier(),r="$"+n.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,r)||this.throwError(o.Messages.UnknownLabel,n.name),t=n}return this.consumeSemicolon(),null!==t||this.context.inIteration||this.context.inSwitch||this.throwError(o.Messages.IllegalBreak),this.finalize(e,new s.BreakStatement(t))},e.prototype.parseReturnStatement=function(){this.context.inFunctionBody||this.tolerateError(o.Messages.IllegalReturn);var e=this.createNode();this.expectKeyword("return");var t=(this.match(";")||this.match("}")||this.hasLineTerminator||2===this.lookahead.type)&&8!==this.lookahead.type&&10!==this.lookahead.type?null:this.parseExpression();return this.consumeSemicolon(),this.finalize(e,new s.ReturnStatement(t))},e.prototype.parseWithStatement=function(){this.context.strict&&this.tolerateError(o.Messages.StrictModeWith);var e,t=this.createNode();this.expectKeyword("with"),this.expect("(");var n=this.parseExpression();return!this.match(")")&&this.config.tolerant?(this.tolerateUnexpectedToken(this.nextToken()),e=this.finalize(this.createNode(),new s.EmptyStatement)):(this.expect(")"),e=this.parseStatement()),this.finalize(t,new s.WithStatement(n,e))},e.prototype.parseSwitchCase=function(){var e,t=this.createNode();this.matchKeyword("default")?(this.nextToken(),e=null):(this.expectKeyword("case"),e=this.parseExpression()),this.expect(":");for(var n=[];!(this.match("}")||this.matchKeyword("default")||this.matchKeyword("case"));)n.push(this.parseStatementListItem());return this.finalize(t,new s.SwitchCase(e,n))},e.prototype.parseSwitchStatement=function(){var e=this.createNode();this.expectKeyword("switch"),this.expect("(");var t=this.parseExpression();this.expect(")");var n=this.context.inSwitch;this.context.inSwitch=!0;var r=[],i=!1;for(this.expect("{");!this.match("}");){var a=this.parseSwitchCase();null===a.test&&(i&&this.throwError(o.Messages.MultipleDefaultsInSwitch),i=!0),r.push(a)}return this.expect("}"),this.context.inSwitch=n,this.finalize(e,new s.SwitchStatement(t,r))},e.prototype.parseLabelledStatement=function(){var e,t=this.createNode(),n=this.parseExpression();if(n.type===c.Syntax.Identifier&&this.match(":")){this.nextToken();var r=n,i="$"+r.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,i)&&this.throwError(o.Messages.Redeclaration,"Label",r.name),this.context.labelSet[i]=!0;var a=void 0;if(this.matchKeyword("class"))this.tolerateUnexpectedToken(this.lookahead),a=this.parseClassDeclaration();else if(this.matchKeyword("function")){var u=this.lookahead,l=this.parseFunctionDeclaration();this.context.strict?this.tolerateUnexpectedToken(u,o.Messages.StrictFunction):l.generator&&this.tolerateUnexpectedToken(u,o.Messages.GeneratorInLegacyContext),a=l}else a=this.parseStatement();delete this.context.labelSet[i],e=new s.LabeledStatement(r,a)}else this.consumeSemicolon(),e=new s.ExpressionStatement(n);return this.finalize(t,e)},e.prototype.parseThrowStatement=function(){var e=this.createNode();this.expectKeyword("throw"),this.hasLineTerminator&&this.throwError(o.Messages.NewlineAfterThrow);var t=this.parseExpression();return this.consumeSemicolon(),this.finalize(e,new s.ThrowStatement(t))},e.prototype.parseCatchClause=function(){var e=this.createNode();this.expectKeyword("catch"),this.expect("("),this.match(")")&&this.throwUnexpectedToken(this.lookahead);for(var t=[],n=this.parsePattern(t),r={},i=0;i<t.length;i++){var a="$"+t[i].value;Object.prototype.hasOwnProperty.call(r,a)&&this.tolerateError(o.Messages.DuplicateBinding,t[i].value),r[a]=!0}this.context.strict&&n.type===c.Syntax.Identifier&&this.scanner.isRestrictedWord(n.name)&&this.tolerateError(o.Messages.StrictCatchVariable),this.expect(")");var u=this.parseBlock();return this.finalize(e,new s.CatchClause(n,u))},e.prototype.parseFinallyClause=function(){return this.expectKeyword("finally"),this.parseBlock()},e.prototype.parseTryStatement=function(){var e=this.createNode();this.expectKeyword("try");var t=this.parseBlock(),n=this.matchKeyword("catch")?this.parseCatchClause():null,r=this.matchKeyword("finally")?this.parseFinallyClause():null;return n||r||this.throwError(o.Messages.NoCatchOrFinally),this.finalize(e,new s.TryStatement(t,n,r))},e.prototype.parseDebuggerStatement=function(){var e=this.createNode();return this.expectKeyword("debugger"),this.consumeSemicolon(),this.finalize(e,new s.DebuggerStatement)},e.prototype.parseStatement=function(){var e;switch(this.lookahead.type){case 1:case 5:case 6:case 8:case 10:case 9:e=this.parseExpressionStatement();break;case 7:var t=this.lookahead.value;e="{"===t?this.parseBlock():"("===t?this.parseExpressionStatement():";"===t?this.parseEmptyStatement():this.parseExpressionStatement();break;case 3:e=this.matchAsyncFunction()?this.parseFunctionDeclaration():this.parseLabelledStatement();break;case 4:switch(this.lookahead.value){case"break":e=this.parseBreakStatement();break;case"continue":e=this.parseContinueStatement();break;case"debugger":e=this.parseDebuggerStatement();break;case"do":e=this.parseDoWhileStatement();break;case"for":e=this.parseForStatement();break;case"function":e=this.parseFunctionDeclaration();break;case"if":e=this.parseIfStatement();break;case"return":e=this.parseReturnStatement();break;case"switch":e=this.parseSwitchStatement();break;case"throw":e=this.parseThrowStatement();break;case"try":e=this.parseTryStatement();break;case"var":e=this.parseVariableStatement();break;case"while":e=this.parseWhileStatement();break;case"with":e=this.parseWithStatement();break;default:e=this.parseExpressionStatement()}break;default:e=this.throwUnexpectedToken(this.lookahead)}return e},e.prototype.parseFunctionSourceElements=function(){var e=this.createNode();this.expect("{");var t=this.parseDirectivePrologues(),n=this.context.labelSet,r=this.context.inIteration,i=this.context.inSwitch,o=this.context.inFunctionBody;for(this.context.labelSet={},this.context.inIteration=!1,this.context.inSwitch=!1,this.context.inFunctionBody=!0;2!==this.lookahead.type&&!this.match("}");)t.push(this.parseStatementListItem());return this.expect("}"),this.context.labelSet=n,this.context.inIteration=r,this.context.inSwitch=i,this.context.inFunctionBody=o,this.finalize(e,new s.BlockStatement(t))},e.prototype.validateParam=function(e,t,n){var r="$"+n;this.context.strict?(this.scanner.isRestrictedWord(n)&&(e.stricted=t,e.message=o.Messages.StrictParamName),Object.prototype.hasOwnProperty.call(e.paramSet,r)&&(e.stricted=t,e.message=o.Messages.StrictParamDupe)):e.firstRestricted||(this.scanner.isRestrictedWord(n)?(e.firstRestricted=t,e.message=o.Messages.StrictParamName):this.scanner.isStrictModeReservedWord(n)?(e.firstRestricted=t,e.message=o.Messages.StrictReservedWord):Object.prototype.hasOwnProperty.call(e.paramSet,r)&&(e.stricted=t,e.message=o.Messages.StrictParamDupe)),"function"==typeof Object.defineProperty?Object.defineProperty(e.paramSet,r,{value:!0,enumerable:!0,writable:!0,configurable:!0}):e.paramSet[r]=!0},e.prototype.parseRestElement=function(e){var t=this.createNode();this.expect("...");var n=this.parsePattern(e);return this.match("=")&&this.throwError(o.Messages.DefaultRestParameter),this.match(")")||this.throwError(o.Messages.ParameterAfterRestParameter),this.finalize(t,new s.RestElement(n))},e.prototype.parseFormalParameter=function(e){for(var t=[],n=this.match("...")?this.parseRestElement(t):this.parsePatternWithDefault(t),r=0;r<t.length;r++)this.validateParam(e,t[r],t[r].value);e.simple=e.simple&&n instanceof s.Identifier,e.params.push(n)},e.prototype.parseFormalParameters=function(e){var t;if(t={simple:!0,params:[],firstRestricted:e},this.expect("("),!this.match(")"))for(t.paramSet={};2!==this.lookahead.type&&(this.parseFormalParameter(t),!this.match(")"))&&(this.expect(","),!this.match(")")););return this.expect(")"),{simple:t.simple,params:t.params,stricted:t.stricted,firstRestricted:t.firstRestricted,message:t.message}},e.prototype.matchAsyncFunction=function(){var e=this.matchContextualKeyword("async");if(e){var t=this.scanner.saveState();this.scanner.scanComments();var n=this.scanner.lex();this.scanner.restoreState(t),e=t.lineNumber===n.lineNumber&&4===n.type&&"function"===n.value}return e},e.prototype.parseFunctionDeclaration=function(e){var t=this.createNode(),n=this.matchContextualKeyword("async");n&&this.nextToken(),this.expectKeyword("function");var r,i=!n&&this.match("*");i&&this.nextToken();var a=null,c=null;if(!e||!this.match("(")){var u=this.lookahead;a=this.parseVariableIdentifier(),this.context.strict?this.scanner.isRestrictedWord(u.value)&&this.tolerateUnexpectedToken(u,o.Messages.StrictFunctionName):this.scanner.isRestrictedWord(u.value)?(c=u,r=o.Messages.StrictFunctionName):this.scanner.isStrictModeReservedWord(u.value)&&(c=u,r=o.Messages.StrictReservedWord)}var l=this.context.await,h=this.context.allowYield;this.context.await=n,this.context.allowYield=!i;var d=this.parseFormalParameters(c),p=d.params,f=d.stricted;c=d.firstRestricted,d.message&&(r=d.message);var m=this.context.strict,g=this.context.allowStrictDirective;this.context.allowStrictDirective=d.simple;var _=this.parseFunctionSourceElements();return this.context.strict&&c&&this.throwUnexpectedToken(c,r),this.context.strict&&f&&this.tolerateUnexpectedToken(f,r),this.context.strict=m,this.context.allowStrictDirective=g,this.context.await=l,this.context.allowYield=h,n?this.finalize(t,new s.AsyncFunctionDeclaration(a,p,_)):this.finalize(t,new s.FunctionDeclaration(a,p,_,i))},e.prototype.parseFunctionExpression=function(){var e=this.createNode(),t=this.matchContextualKeyword("async");t&&this.nextToken(),this.expectKeyword("function");var n,r=!t&&this.match("*");r&&this.nextToken();var i,a=null,c=this.context.await,u=this.context.allowYield;if(this.context.await=t,this.context.allowYield=!r,!this.match("(")){var l=this.lookahead;a=this.context.strict||r||!this.matchKeyword("yield")?this.parseVariableIdentifier():this.parseIdentifierName(),this.context.strict?this.scanner.isRestrictedWord(l.value)&&this.tolerateUnexpectedToken(l,o.Messages.StrictFunctionName):this.scanner.isRestrictedWord(l.value)?(i=l,n=o.Messages.StrictFunctionName):this.scanner.isStrictModeReservedWord(l.value)&&(i=l,n=o.Messages.StrictReservedWord)}var h=this.parseFormalParameters(i),d=h.params,p=h.stricted;i=h.firstRestricted,h.message&&(n=h.message);var f=this.context.strict,m=this.context.allowStrictDirective;this.context.allowStrictDirective=h.simple;var g=this.parseFunctionSourceElements();return this.context.strict&&i&&this.throwUnexpectedToken(i,n),this.context.strict&&p&&this.tolerateUnexpectedToken(p,n),this.context.strict=f,this.context.allowStrictDirective=m,this.context.await=c,this.context.allowYield=u,t?this.finalize(e,new s.AsyncFunctionExpression(a,d,g)):this.finalize(e,new s.FunctionExpression(a,d,g,r))},e.prototype.parseDirective=function(){var e=this.lookahead,t=this.createNode(),n=this.parseExpression(),r=n.type===c.Syntax.Literal?this.getTokenRaw(e).slice(1,-1):null;return this.consumeSemicolon(),this.finalize(t,r?new s.Directive(n,r):new s.ExpressionStatement(n))},e.prototype.parseDirectivePrologues=function(){for(var e=null,t=[];;){var n=this.lookahead;if(8!==n.type)break;var r=this.parseDirective();t.push(r);var i=r.directive;if("string"!=typeof i)break;"use strict"===i?(this.context.strict=!0,e&&this.tolerateUnexpectedToken(e,o.Messages.StrictOctalLiteral),this.context.allowStrictDirective||this.tolerateUnexpectedToken(n,o.Messages.IllegalLanguageModeDirective)):!e&&n.octal&&(e=n)}return t},e.prototype.qualifiedPropertyName=function(e){switch(e.type){case 3:case 8:case 1:case 5:case 6:case 4:return!0;case 7:return"["===e.value}return!1},e.prototype.parseGetterMethod=function(){var e=this.createNode(),t=this.context.allowYield;this.context.allowYield=!0;var n=this.parseFormalParameters();n.params.length>0&&this.tolerateError(o.Messages.BadGetterArity);var r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new s.FunctionExpression(null,n.params,r,!1))},e.prototype.parseSetterMethod=function(){var e=this.createNode(),t=this.context.allowYield;this.context.allowYield=!0;var n=this.parseFormalParameters();1!==n.params.length?this.tolerateError(o.Messages.BadSetterArity):n.params[0]instanceof s.RestElement&&this.tolerateError(o.Messages.BadSetterRestParameter);var r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new s.FunctionExpression(null,n.params,r,!1))},e.prototype.parseGeneratorMethod=function(){var e=this.createNode(),t=this.context.allowYield;this.context.allowYield=!0;var n=this.parseFormalParameters();this.context.allowYield=!1;var r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new s.FunctionExpression(null,n.params,r,!0))},e.prototype.isStartOfExpression=function(){var e=!0,t=this.lookahead.value;switch(this.lookahead.type){case 7:e="["===t||"("===t||"{"===t||"+"===t||"-"===t||"!"===t||"~"===t||"++"===t||"--"===t||"/"===t||"/="===t;break;case 4:e="class"===t||"delete"===t||"function"===t||"let"===t||"new"===t||"super"===t||"this"===t||"typeof"===t||"void"===t||"yield"===t}return e},e.prototype.parseYieldExpression=function(){var e=this.createNode();this.expectKeyword("yield");var t=null,n=!1;if(!this.hasLineTerminator){var r=this.context.allowYield;this.context.allowYield=!1,(n=this.match("*"))?(this.nextToken(),t=this.parseAssignmentExpression()):this.isStartOfExpression()&&(t=this.parseAssignmentExpression()),this.context.allowYield=r}return this.finalize(e,new s.YieldExpression(t,n))},e.prototype.parseClassElement=function(e){var t=this.lookahead,n=this.createNode(),r="",i=null,a=null,c=!1,u=!1,l=!1,h=!1;if(this.match("*"))this.nextToken();else if(c=this.match("["),"static"===(i=this.parseObjectPropertyKey()).name&&(this.qualifiedPropertyName(this.lookahead)||this.match("*"))&&(t=this.lookahead,l=!0,c=this.match("["),this.match("*")?this.nextToken():i=this.parseObjectPropertyKey()),3===t.type&&!this.hasLineTerminator&&"async"===t.value){var d=this.lookahead.value;":"!==d&&"("!==d&&"*"!==d&&(h=!0,t=this.lookahead,i=this.parseObjectPropertyKey(),3===t.type&&"constructor"===t.value&&this.tolerateUnexpectedToken(t,o.Messages.ConstructorIsAsync))}var p=this.qualifiedPropertyName(this.lookahead);return 3===t.type?"get"===t.value&&p?(r="get",c=this.match("["),i=this.parseObjectPropertyKey(),this.context.allowYield=!1,a=this.parseGetterMethod()):"set"===t.value&&p&&(r="set",c=this.match("["),i=this.parseObjectPropertyKey(),a=this.parseSetterMethod()):7===t.type&&"*"===t.value&&p&&(r="init",c=this.match("["),i=this.parseObjectPropertyKey(),a=this.parseGeneratorMethod(),u=!0),!r&&i&&this.match("(")&&(r="init",a=h?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction(),u=!0),r||this.throwUnexpectedToken(this.lookahead),"init"===r&&(r="method"),c||(l&&this.isPropertyKey(i,"prototype")&&this.throwUnexpectedToken(t,o.Messages.StaticPrototype),!l&&this.isPropertyKey(i,"constructor")&&(("method"!==r||!u||a&&a.generator)&&this.throwUnexpectedToken(t,o.Messages.ConstructorSpecialMethod),e.value?this.throwUnexpectedToken(t,o.Messages.DuplicateConstructor):e.value=!0,r="constructor")),this.finalize(n,new s.MethodDefinition(i,c,a,r,l))},e.prototype.parseClassElementList=function(){var e=[],t={value:!1};for(this.expect("{");!this.match("}");)this.match(";")?this.nextToken():e.push(this.parseClassElement(t));return this.expect("}"),e},e.prototype.parseClassBody=function(){var e=this.createNode(),t=this.parseClassElementList();return this.finalize(e,new s.ClassBody(t))},e.prototype.parseClassDeclaration=function(e){var t=this.createNode(),n=this.context.strict;this.context.strict=!0,this.expectKeyword("class");var r=e&&3!==this.lookahead.type?null:this.parseVariableIdentifier(),i=null;this.matchKeyword("extends")&&(this.nextToken(),i=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall));var o=this.parseClassBody();return this.context.strict=n,this.finalize(t,new s.ClassDeclaration(r,i,o))},e.prototype.parseClassExpression=function(){var e=this.createNode(),t=this.context.strict;this.context.strict=!0,this.expectKeyword("class");var n=3===this.lookahead.type?this.parseVariableIdentifier():null,r=null;this.matchKeyword("extends")&&(this.nextToken(),r=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall));var i=this.parseClassBody();return this.context.strict=t,this.finalize(e,new s.ClassExpression(n,r,i))},e.prototype.parseModule=function(){this.context.strict=!0,this.context.isModule=!0,this.scanner.isModule=!0;for(var e=this.createNode(),t=this.parseDirectivePrologues();2!==this.lookahead.type;)t.push(this.parseStatementListItem());return this.finalize(e,new s.Module(t))},e.prototype.parseScript=function(){for(var e=this.createNode(),t=this.parseDirectivePrologues();2!==this.lookahead.type;)t.push(this.parseStatementListItem());return this.finalize(e,new s.Script(t))},e.prototype.parseModuleSpecifier=function(){var e=this.createNode();8!==this.lookahead.type&&this.throwError(o.Messages.InvalidModuleSpecifier);var t=this.nextToken(),n=this.getTokenRaw(t);return this.finalize(e,new s.Literal(t.value,n))},e.prototype.parseImportSpecifier=function(){var e,t,n=this.createNode();return 3===this.lookahead.type?(t=e=this.parseVariableIdentifier(),this.matchContextualKeyword("as")&&(this.nextToken(),t=this.parseVariableIdentifier())):(t=e=this.parseIdentifierName(),this.matchContextualKeyword("as")?(this.nextToken(),t=this.parseVariableIdentifier()):this.throwUnexpectedToken(this.nextToken())),this.finalize(n,new s.ImportSpecifier(t,e))},e.prototype.parseNamedImports=function(){this.expect("{");for(var e=[];!this.match("}");)e.push(this.parseImportSpecifier()),this.match("}")||this.expect(",");return this.expect("}"),e},e.prototype.parseImportDefaultSpecifier=function(){var e=this.createNode(),t=this.parseIdentifierName();return this.finalize(e,new s.ImportDefaultSpecifier(t))},e.prototype.parseImportNamespaceSpecifier=function(){var e=this.createNode();this.expect("*"),this.matchContextualKeyword("as")||this.throwError(o.Messages.NoAsAfterImportNamespace),this.nextToken();var t=this.parseIdentifierName();return this.finalize(e,new s.ImportNamespaceSpecifier(t))},e.prototype.parseImportDeclaration=function(){this.context.inFunctionBody&&this.throwError(o.Messages.IllegalImportDeclaration);var e,t=this.createNode();this.expectKeyword("import");var n=[];if(8===this.lookahead.type)e=this.parseModuleSpecifier();else{if(this.match("{")?n=n.concat(this.parseNamedImports()):this.match("*")?n.push(this.parseImportNamespaceSpecifier()):this.isIdentifierName(this.lookahead)&&!this.matchKeyword("default")?(n.push(this.parseImportDefaultSpecifier()),this.match(",")&&(this.nextToken(),this.match("*")?n.push(this.parseImportNamespaceSpecifier()):this.match("{")?n=n.concat(this.parseNamedImports()):this.throwUnexpectedToken(this.lookahead))):this.throwUnexpectedToken(this.nextToken()),!this.matchContextualKeyword("from")){var r=this.lookahead.value?o.Messages.UnexpectedToken:o.Messages.MissingFromClause;this.throwError(r,this.lookahead.value)}this.nextToken(),e=this.parseModuleSpecifier()}return this.consumeSemicolon(),this.finalize(t,new s.ImportDeclaration(n,e))},e.prototype.parseExportSpecifier=function(){var e=this.createNode(),t=this.parseIdentifierName(),n=t;return this.matchContextualKeyword("as")&&(this.nextToken(),n=this.parseIdentifierName()),this.finalize(e,new s.ExportSpecifier(t,n))},e.prototype.parseExportDeclaration=function(){this.context.inFunctionBody&&this.throwError(o.Messages.IllegalExportDeclaration);var e,t=this.createNode();if(this.expectKeyword("export"),this.matchKeyword("default"))if(this.nextToken(),this.matchKeyword("function")){var n=this.parseFunctionDeclaration(!0);e=this.finalize(t,new s.ExportDefaultDeclaration(n))}else this.matchKeyword("class")?(n=this.parseClassDeclaration(!0),e=this.finalize(t,new s.ExportDefaultDeclaration(n))):this.matchContextualKeyword("async")?(n=this.matchAsyncFunction()?this.parseFunctionDeclaration(!0):this.parseAssignmentExpression(),e=this.finalize(t,new s.ExportDefaultDeclaration(n))):(this.matchContextualKeyword("from")&&this.throwError(o.Messages.UnexpectedToken,this.lookahead.value),n=this.match("{")?this.parseObjectInitializer():this.match("[")?this.parseArrayInitializer():this.parseAssignmentExpression(),this.consumeSemicolon(),e=this.finalize(t,new s.ExportDefaultDeclaration(n)));else if(this.match("*")){if(this.nextToken(),!this.matchContextualKeyword("from")){var r=this.lookahead.value?o.Messages.UnexpectedToken:o.Messages.MissingFromClause;this.throwError(r,this.lookahead.value)}this.nextToken();var i=this.parseModuleSpecifier();this.consumeSemicolon(),e=this.finalize(t,new s.ExportAllDeclaration(i))}else if(4===this.lookahead.type){switch(n=void 0,this.lookahead.value){case"let":case"const":n=this.parseLexicalDeclaration({inFor:!1});break;case"var":case"class":case"function":n=this.parseStatementListItem();break;default:this.throwUnexpectedToken(this.lookahead)}e=this.finalize(t,new s.ExportNamedDeclaration(n,[],null))}else if(this.matchAsyncFunction())n=this.parseFunctionDeclaration(),e=this.finalize(t,new s.ExportNamedDeclaration(n,[],null));else{var a=[],c=null,u=!1;for(this.expect("{");!this.match("}");)u=u||this.matchKeyword("default"),a.push(this.parseExportSpecifier()),this.match("}")||this.expect(",");this.expect("}"),this.matchContextualKeyword("from")?(this.nextToken(),c=this.parseModuleSpecifier(),this.consumeSemicolon()):u?(r=this.lookahead.value?o.Messages.UnexpectedToken:o.Messages.MissingFromClause,this.throwError(r,this.lookahead.value)):this.consumeSemicolon(),e=this.finalize(t,new s.ExportNamedDeclaration(null,a,c))}return e},e}();t.Parser=l},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assert=function(e,t){if(!e)throw new Error("ASSERT: "+t)}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this.errors=[],this.tolerant=!1}return e.prototype.recordError=function(e){this.errors.push(e)},e.prototype.tolerate=function(e){if(!this.tolerant)throw e;this.recordError(e)},e.prototype.constructError=function(e,t){var n=new Error(e);try{throw n}catch(e){Object.create&&Object.defineProperty&&(n=Object.create(e),Object.defineProperty(n,"column",{value:t}))}return n},e.prototype.createError=function(e,t,n,r){var i="Line "+t+": "+r,o=this.constructError(i,n);return o.index=e,o.lineNumber=t,o.description=r,o},e.prototype.throwError=function(e,t,n,r){throw this.createError(e,t,n,r)},e.prototype.tolerateError=function(e,t,n,r){var i=this.createError(e,t,n,r);if(!this.tolerant)throw i;this.recordError(i)},e}();t.ErrorHandler=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Messages={BadGetterArity:"Getter must not have any formal parameters",BadSetterArity:"Setter must have exactly one formal parameter",BadSetterRestParameter:"Setter function argument must not be a rest parameter",ConstructorIsAsync:"Class constructor may not be an async method",ConstructorSpecialMethod:"Class constructor may not be an accessor",DeclarationMissingInitializer:"Missing initializer in %0 declaration",DefaultRestParameter:"Unexpected token =",DuplicateBinding:"Duplicate binding %0",DuplicateConstructor:"A class may only have one constructor",DuplicateProtoProperty:"Duplicate __proto__ fields are not allowed in object literals",ForInOfLoopInitializer:"%0 loop variable declaration may not have an initializer",GeneratorInLegacyContext:"Generator declarations are not allowed in legacy contexts",IllegalBreak:"Illegal break statement",IllegalContinue:"Illegal continue statement",IllegalExportDeclaration:"Unexpected token",IllegalImportDeclaration:"Unexpected token",IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list",IllegalReturn:"Illegal return statement",InvalidEscapedReservedWord:"Keyword must not contain escaped characters",InvalidHexEscapeSequence:"Invalid hexadecimal escape sequence",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",InvalidLHSInForLoop:"Invalid left-hand side in for-loop",InvalidModuleSpecifier:"Unexpected token",InvalidRegExp:"Invalid regular expression",LetInLexicalBinding:"let is disallowed as a lexically bound name",MissingFromClause:"Unexpected token",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NewlineAfterThrow:"Illegal newline after throw",NoAsAfterImportNamespace:"Unexpected token",NoCatchOrFinally:"Missing catch or finally after try",ParameterAfterRestParameter:"Rest parameter must be last formal parameter",Redeclaration:"%0 '%1' has already been declared",StaticPrototype:"Classes may not have static property named prototype",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictModeWith:"Strict mode code may not include a with statement",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictReservedWord:"Use of future reserved word in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",TemplateOctalLiteral:"Octal literals are not allowed in template strings.",UnexpectedEOS:"Unexpected end of input",UnexpectedIdentifier:"Unexpected identifier",UnexpectedNumber:"Unexpected number",UnexpectedReserved:"Unexpected reserved word",UnexpectedString:"Unexpected string",UnexpectedTemplate:"Unexpected quasi %0",UnexpectedToken:"Unexpected token %0",UnexpectedTokenIllegal:"Unexpected token ILLEGAL",UnknownLabel:"Undefined label '%0'",UnterminatedRegExp:"Invalid regular expression: missing /"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(4),o=n(11);function s(e){return"0123456789abcdef".indexOf(e.toLowerCase())}function a(e){return"01234567".indexOf(e)}var c=function(){function e(e,t){this.source=e,this.errorHandler=t,this.trackComment=!1,this.isModule=!1,this.length=e.length,this.index=0,this.lineNumber=e.length>0?1:0,this.lineStart=0,this.curlyStack=[]}return e.prototype.saveState=function(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart}},e.prototype.restoreState=function(e){this.index=e.index,this.lineNumber=e.lineNumber,this.lineStart=e.lineStart},e.prototype.eof=function(){return this.index>=this.length},e.prototype.throwUnexpectedToken=function(e){return void 0===e&&(e=o.Messages.UnexpectedTokenIllegal),this.errorHandler.throwError(this.index,this.lineNumber,this.index-this.lineStart+1,e)},e.prototype.tolerateUnexpectedToken=function(e){void 0===e&&(e=o.Messages.UnexpectedTokenIllegal),this.errorHandler.tolerateError(this.index,this.lineNumber,this.index-this.lineStart+1,e)},e.prototype.skipSingleLineComment=function(e){var t,n,r=[];for(this.trackComment&&(r=[],t=this.index-e,n={start:{line:this.lineNumber,column:this.index-this.lineStart-e},end:{}});!this.eof();){var o=this.source.charCodeAt(this.index);if(++this.index,i.Character.isLineTerminator(o)){if(this.trackComment){n.end={line:this.lineNumber,column:this.index-this.lineStart-1};var s={multiLine:!1,slice:[t+e,this.index-1],range:[t,this.index-1],loc:n};r.push(s)}return 13===o&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,r}}return this.trackComment&&(n.end={line:this.lineNumber,column:this.index-this.lineStart},s={multiLine:!1,slice:[t+e,this.index],range:[t,this.index],loc:n},r.push(s)),r},e.prototype.skipMultiLineComment=function(){var e,t,n=[];for(this.trackComment&&(n=[],e=this.index-2,t={start:{line:this.lineNumber,column:this.index-this.lineStart-2},end:{}});!this.eof();){var r=this.source.charCodeAt(this.index);if(i.Character.isLineTerminator(r))13===r&&10===this.source.charCodeAt(this.index+1)&&++this.index,++this.lineNumber,++this.index,this.lineStart=this.index;else if(42===r){if(47===this.source.charCodeAt(this.index+1)){if(this.index+=2,this.trackComment){t.end={line:this.lineNumber,column:this.index-this.lineStart};var o={multiLine:!0,slice:[e+2,this.index-2],range:[e,this.index],loc:t};n.push(o)}return n}++this.index}else++this.index}return this.trackComment&&(t.end={line:this.lineNumber,column:this.index-this.lineStart},o={multiLine:!0,slice:[e+2,this.index],range:[e,this.index],loc:t},n.push(o)),this.tolerateUnexpectedToken(),n},e.prototype.scanComments=function(){var e;this.trackComment&&(e=[]);for(var t=0===this.index;!this.eof();){var n=this.source.charCodeAt(this.index);if(i.Character.isWhiteSpace(n))++this.index;else if(i.Character.isLineTerminator(n))++this.index,13===n&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,t=!0;else if(47===n)if(47===(n=this.source.charCodeAt(this.index+1))){this.index+=2;var r=this.skipSingleLineComment(2);this.trackComment&&(e=e.concat(r)),t=!0}else{if(42!==n)break;this.index+=2,r=this.skipMultiLineComment(),this.trackComment&&(e=e.concat(r))}else if(t&&45===n){if(45!==this.source.charCodeAt(this.index+1)||62!==this.source.charCodeAt(this.index+2))break;this.index+=3,r=this.skipSingleLineComment(3),this.trackComment&&(e=e.concat(r))}else{if(60!==n||this.isModule)break;if("!--"!==this.source.slice(this.index+1,this.index+4))break;this.index+=4,r=this.skipSingleLineComment(4),this.trackComment&&(e=e.concat(r))}}return e},e.prototype.isFutureReservedWord=function(e){switch(e){case"enum":case"export":case"import":case"super":return!0;default:return!1}},e.prototype.isStrictModeReservedWord=function(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}},e.prototype.isRestrictedWord=function(e){return"eval"===e||"arguments"===e},e.prototype.isKeyword=function(e){switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}},e.prototype.codePointAt=function(e){var t=this.source.charCodeAt(e);if(t>=55296&&t<=56319){var n=this.source.charCodeAt(e+1);n>=56320&&n<=57343&&(t=1024*(t-55296)+n-56320+65536)}return t},e.prototype.scanHexEscape=function(e){for(var t="u"===e?4:2,n=0,r=0;r<t;++r){if(this.eof()||!i.Character.isHexDigit(this.source.charCodeAt(this.index)))return null;n=16*n+s(this.source[this.index++])}return String.fromCharCode(n)},e.prototype.scanUnicodeCodePointEscape=function(){var e=this.source[this.index],t=0;for("}"===e&&this.throwUnexpectedToken();!this.eof()&&(e=this.source[this.index++],i.Character.isHexDigit(e.charCodeAt(0)));)t=16*t+s(e);return(t>1114111||"}"!==e)&&this.throwUnexpectedToken(),i.Character.fromCodePoint(t)},e.prototype.getIdentifier=function(){for(var e=this.index++;!this.eof();){var t=this.source.charCodeAt(this.index);if(92===t)return this.index=e,this.getComplexIdentifier();if(t>=55296&&t<57343)return this.index=e,this.getComplexIdentifier();if(!i.Character.isIdentifierPart(t))break;++this.index}return this.source.slice(e,this.index)},e.prototype.getComplexIdentifier=function(){var e,t=this.codePointAt(this.index),n=i.Character.fromCodePoint(t);for(this.index+=n.length,92===t&&(117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this.scanUnicodeCodePointEscape()):null!==(e=this.scanHexEscape("u"))&&"\\"!==e&&i.Character.isIdentifierStart(e.charCodeAt(0))||this.throwUnexpectedToken(),n=e);!this.eof()&&(t=this.codePointAt(this.index),i.Character.isIdentifierPart(t));)n+=e=i.Character.fromCodePoint(t),this.index+=e.length,92===t&&(n=n.substr(0,n.length-1),117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this.scanUnicodeCodePointEscape()):null!==(e=this.scanHexEscape("u"))&&"\\"!==e&&i.Character.isIdentifierPart(e.charCodeAt(0))||this.throwUnexpectedToken(),n+=e);return n},e.prototype.octalToDecimal=function(e){var t="0"!==e,n=a(e);return!this.eof()&&i.Character.isOctalDigit(this.source.charCodeAt(this.index))&&(t=!0,n=8*n+a(this.source[this.index++]),"0123".indexOf(e)>=0&&!this.eof()&&i.Character.isOctalDigit(this.source.charCodeAt(this.index))&&(n=8*n+a(this.source[this.index++]))),{code:n,octal:t}},e.prototype.scanIdentifier=function(){var e,t=this.index,n=92===this.source.charCodeAt(t)?this.getComplexIdentifier():this.getIdentifier();if(3!=(e=1===n.length?3:this.isKeyword(n)?4:"null"===n?5:"true"===n||"false"===n?1:3)&&t+n.length!==this.index){var r=this.index;this.index=t,this.tolerateUnexpectedToken(o.Messages.InvalidEscapedReservedWord),this.index=r}return{type:e,value:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}},e.prototype.scanPunctuator=function(){var e=this.index,t=this.source[this.index];switch(t){case"(":case"{":"{"===t&&this.curlyStack.push("{"),++this.index;break;case".":++this.index,"."===this.source[this.index]&&"."===this.source[this.index+1]&&(this.index+=2,t="...");break;case"}":++this.index,this.curlyStack.pop();break;case")":case";":case",":case"[":case"]":case":":case"?":case"~":++this.index;break;default:">>>="===(t=this.source.substr(this.index,4))?this.index+=4:"==="===(t=t.substr(0,3))||"!=="===t||">>>"===t||"<<="===t||">>="===t||"**="===t?this.index+=3:"&&"===(t=t.substr(0,2))||"||"===t||"=="===t||"!="===t||"+="===t||"-="===t||"*="===t||"/="===t||"++"===t||"--"===t||"<<"===t||">>"===t||"&="===t||"|="===t||"^="===t||"%="===t||"<="===t||">="===t||"=>"===t||"**"===t?this.index+=2:(t=this.source[this.index],"<>=!+-*%&|^/".indexOf(t)>=0&&++this.index)}return this.index===e&&this.throwUnexpectedToken(),{type:7,value:t,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanHexLiteral=function(e){for(var t="";!this.eof()&&i.Character.isHexDigit(this.source.charCodeAt(this.index));)t+=this.source[this.index++];return 0===t.length&&this.throwUnexpectedToken(),i.Character.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:6,value:parseInt("0x"+t,16),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanBinaryLiteral=function(e){for(var t,n="";!this.eof()&&("0"===(t=this.source[this.index])||"1"===t);)n+=this.source[this.index++];return 0===n.length&&this.throwUnexpectedToken(),this.eof()||(t=this.source.charCodeAt(this.index),(i.Character.isIdentifierStart(t)||i.Character.isDecimalDigit(t))&&this.throwUnexpectedToken()),{type:6,value:parseInt(n,2),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanOctalLiteral=function(e,t){var n="",r=!1;for(i.Character.isOctalDigit(e.charCodeAt(0))?(r=!0,n="0"+this.source[this.index++]):++this.index;!this.eof()&&i.Character.isOctalDigit(this.source.charCodeAt(this.index));)n+=this.source[this.index++];return r||0!==n.length||this.throwUnexpectedToken(),(i.Character.isIdentifierStart(this.source.charCodeAt(this.index))||i.Character.isDecimalDigit(this.source.charCodeAt(this.index)))&&this.throwUnexpectedToken(),{type:6,value:parseInt(n,8),octal:r,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}},e.prototype.isImplicitOctalLiteral=function(){for(var e=this.index+1;e<this.length;++e){var t=this.source[e];if("8"===t||"9"===t)return!1;if(!i.Character.isOctalDigit(t.charCodeAt(0)))return!0}return!0},e.prototype.scanNumericLiteral=function(){var e=this.index,t=this.source[e];r.assert(i.Character.isDecimalDigit(t.charCodeAt(0))||"."===t,"Numeric literal must start with a decimal digit or a decimal point");var n="";if("."!==t){if(n=this.source[this.index++],t=this.source[this.index],"0"===n){if("x"===t||"X"===t)return++this.index,this.scanHexLiteral(e);if("b"===t||"B"===t)return++this.index,this.scanBinaryLiteral(e);if("o"===t||"O"===t)return this.scanOctalLiteral(t,e);if(t&&i.Character.isOctalDigit(t.charCodeAt(0))&&this.isImplicitOctalLiteral())return this.scanOctalLiteral(t,e)}for(;i.Character.isDecimalDigit(this.source.charCodeAt(this.index));)n+=this.source[this.index++];t=this.source[this.index]}if("."===t){for(n+=this.source[this.index++];i.Character.isDecimalDigit(this.source.charCodeAt(this.index));)n+=this.source[this.index++];t=this.source[this.index]}if("e"===t||"E"===t)if(n+=this.source[this.index++],"+"!==(t=this.source[this.index])&&"-"!==t||(n+=this.source[this.index++]),i.Character.isDecimalDigit(this.source.charCodeAt(this.index)))for(;i.Character.isDecimalDigit(this.source.charCodeAt(this.index));)n+=this.source[this.index++];else this.throwUnexpectedToken();return i.Character.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:6,value:parseFloat(n),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanStringLiteral=function(){var e=this.index,t=this.source[e];r.assert("'"===t||'"'===t,"String literal must starts with a quote"),++this.index;for(var n=!1,s="";!this.eof();){var a=this.source[this.index++];if(a===t){t="";break}if("\\"===a)if((a=this.source[this.index++])&&i.Character.isLineTerminator(a.charCodeAt(0)))++this.lineNumber,"\r"===a&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index;else switch(a){case"u":if("{"===this.source[this.index])++this.index,s+=this.scanUnicodeCodePointEscape();else{var c=this.scanHexEscape(a);null===c&&this.throwUnexpectedToken(),s+=c}break;case"x":var u=this.scanHexEscape(a);null===u&&this.throwUnexpectedToken(o.Messages.InvalidHexEscapeSequence),s+=u;break;case"n":s+="\n";break;case"r":s+="\r";break;case"t":s+="\t";break;case"b":s+="\b";break;case"f":s+="\f";break;case"v":s+="\v";break;case"8":case"9":s+=a,this.tolerateUnexpectedToken();break;default:if(a&&i.Character.isOctalDigit(a.charCodeAt(0))){var l=this.octalToDecimal(a);n=l.octal||n,s+=String.fromCharCode(l.code)}else s+=a}else{if(i.Character.isLineTerminator(a.charCodeAt(0)))break;s+=a}}return""!==t&&(this.index=e,this.throwUnexpectedToken()),{type:8,value:s,octal:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanTemplate=function(){var e="",t=!1,n=this.index,r="`"===this.source[n],s=!1,a=2;for(++this.index;!this.eof();){var c=this.source[this.index++];if("`"===c){a=1,s=!0,t=!0;break}if("$"===c){if("{"===this.source[this.index]){this.curlyStack.push("${"),++this.index,t=!0;break}e+=c}else if("\\"===c)if(c=this.source[this.index++],i.Character.isLineTerminator(c.charCodeAt(0)))++this.lineNumber,"\r"===c&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index;else switch(c){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"u":if("{"===this.source[this.index])++this.index,e+=this.scanUnicodeCodePointEscape();else{var u=this.index,l=this.scanHexEscape(c);null!==l?e+=l:(this.index=u,e+=c)}break;case"x":var h=this.scanHexEscape(c);null===h&&this.throwUnexpectedToken(o.Messages.InvalidHexEscapeSequence),e+=h;break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:"0"===c?(i.Character.isDecimalDigit(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(o.Messages.TemplateOctalLiteral),e+="\0"):i.Character.isOctalDigit(c.charCodeAt(0))?this.throwUnexpectedToken(o.Messages.TemplateOctalLiteral):e+=c}else i.Character.isLineTerminator(c.charCodeAt(0))?(++this.lineNumber,"\r"===c&&"\n"===this.source[this.index]&&++this.index,this.lineStart=this.index,e+="\n"):e+=c}return t||this.throwUnexpectedToken(),r||this.curlyStack.pop(),{type:10,value:this.source.slice(n+1,this.index-a),cooked:e,head:r,tail:s,lineNumber:this.lineNumber,lineStart:this.lineStart,start:n,end:this.index}},e.prototype.testRegExp=function(e,t){var n=e,r=this;t.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,(function(e,t,n){var i=parseInt(t||n,16);return i>1114111&&r.throwUnexpectedToken(o.Messages.InvalidRegExp),i<=65535?String.fromCharCode(i):""})).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,""));try{RegExp(n)}catch(e){this.throwUnexpectedToken(o.Messages.InvalidRegExp)}try{return new RegExp(e,t)}catch(e){return null}},e.prototype.scanRegExpBody=function(){var e=this.source[this.index];r.assert("/"===e,"Regular expression literal must start with a slash");for(var t=this.source[this.index++],n=!1,s=!1;!this.eof();)if(t+=e=this.source[this.index++],"\\"===e)e=this.source[this.index++],i.Character.isLineTerminator(e.charCodeAt(0))&&this.throwUnexpectedToken(o.Messages.UnterminatedRegExp),t+=e;else if(i.Character.isLineTerminator(e.charCodeAt(0)))this.throwUnexpectedToken(o.Messages.UnterminatedRegExp);else if(n)"]"===e&&(n=!1);else{if("/"===e){s=!0;break}"["===e&&(n=!0)}return s||this.throwUnexpectedToken(o.Messages.UnterminatedRegExp),t.substr(1,t.length-2)},e.prototype.scanRegExpFlags=function(){for(var e="";!this.eof();){var t=this.source[this.index];if(!i.Character.isIdentifierPart(t.charCodeAt(0)))break;if(++this.index,"\\"!==t||this.eof())e+=t;else if("u"===(t=this.source[this.index])){++this.index;var n=this.index,r=this.scanHexEscape("u");if(null!==r)for(e+=r;n<this.index;++n)this.source[n];else this.index=n,e+="u";this.tolerateUnexpectedToken()}else this.tolerateUnexpectedToken()}return e},e.prototype.scanRegExp=function(){var e=this.index,t=this.scanRegExpBody(),n=this.scanRegExpFlags();return{type:9,value:"",pattern:t,flags:n,regex:this.testRegExp(t,n),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.lex=function(){if(this.eof())return{type:2,value:"",lineNumber:this.lineNumber,lineStart:this.lineStart,start:this.index,end:this.index};var e=this.source.charCodeAt(this.index);return i.Character.isIdentifierStart(e)?this.scanIdentifier():40===e||41===e||59===e?this.scanPunctuator():39===e||34===e?this.scanStringLiteral():46===e?i.Character.isDecimalDigit(this.source.charCodeAt(this.index+1))?this.scanNumericLiteral():this.scanPunctuator():i.Character.isDecimalDigit(e)?this.scanNumericLiteral():96===e||125===e&&"${"===this.curlyStack[this.curlyStack.length-1]?this.scanTemplate():e>=55296&&e<57343&&i.Character.isIdentifierStart(this.codePointAt(this.index))?this.scanIdentifier():this.scanPunctuator()},e}();t.Scanner=c},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TokenName={},t.TokenName[1]="Boolean",t.TokenName[2]="<end>",t.TokenName[3]="Identifier",t.TokenName[4]="Keyword",t.TokenName[5]="Null",t.TokenName[6]="Numeric",t.TokenName[7]="Punctuator",t.TokenName[8]="String",t.TokenName[9]="RegularExpression",t.TokenName[10]="Template"},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XHTMLEntities={quot:'"',amp:"&",apos:"'",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",lang:"⟨",rang:"⟩"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(10),i=n(12),o=n(13),s=function(){function e(){this.values=[],this.curly=this.paren=-1}return e.prototype.beforeFunctionExpression=function(e){return["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","**=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","**","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="].indexOf(e)>=0},e.prototype.isRegexStart=function(){var e=this.values[this.values.length-1],t=null!==e;switch(e){case"this":case"]":t=!1;break;case")":var n=this.values[this.paren-1];t="if"===n||"while"===n||"for"===n||"with"===n;break;case"}":if(t=!1,"function"===this.values[this.curly-3])t=!!(r=this.values[this.curly-4])&&!this.beforeFunctionExpression(r);else if("function"===this.values[this.curly-4]){var r;t=!(r=this.values[this.curly-5])||!this.beforeFunctionExpression(r)}}return t},e.prototype.push=function(e){7===e.type||4===e.type?("{"===e.value?this.curly=this.values.length:"("===e.value&&(this.paren=this.values.length),this.values.push(e.value)):this.values.push(null)},e}(),a=function(){function e(e,t){this.errorHandler=new r.ErrorHandler,this.errorHandler.tolerant=!!t&&"boolean"==typeof t.tolerant&&t.tolerant,this.scanner=new i.Scanner(e,this.errorHandler),this.scanner.trackComment=!!t&&"boolean"==typeof t.comment&&t.comment,this.trackRange=!!t&&"boolean"==typeof t.range&&t.range,this.trackLoc=!!t&&"boolean"==typeof t.loc&&t.loc,this.buffer=[],this.reader=new s}return e.prototype.errors=function(){return this.errorHandler.errors},e.prototype.getNextToken=function(){if(0===this.buffer.length){var e=this.scanner.scanComments();if(this.scanner.trackComment)for(var t=0;t<e.length;++t){var n=e[t],r=this.scanner.source.slice(n.slice[0],n.slice[1]),i={type:n.multiLine?"BlockComment":"LineComment",value:r};this.trackRange&&(i.range=n.range),this.trackLoc&&(i.loc=n.loc),this.buffer.push(i)}if(!this.scanner.eof()){var s=void 0;this.trackLoc&&(s={start:{line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},end:{}});var a="/"===this.scanner.source[this.scanner.index]&&this.reader.isRegexStart()?this.scanner.scanRegExp():this.scanner.lex();this.reader.push(a);var c={type:o.TokenName[a.type],value:this.scanner.source.slice(a.start,a.end)};if(this.trackRange&&(c.range=[a.start,a.end]),this.trackLoc&&(s.end={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},c.loc=s),9===a.type){var u=a.pattern,l=a.flags;c.regex={pattern:u,flags:l}}this.buffer.push(c)}}return this.buffer.shift()},e}();t.Tokenizer=a}])},e.exports=r()},function(e,t,n){"use strict";var r=n(14),i=n(17),o=n(27),s=n(18),a=Object.prototype.toString,c=Object.prototype.hasOwnProperty,u={0:"\\0",7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r",27:"\\e",34:'\\"',92:"\\\\",133:"\\N",160:"\\_",8232:"\\L",8233:"\\P"},l=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function h(e){var t,n,o;if(t=e.toString(16).toUpperCase(),e<=255)n="x",o=2;else if(e<=65535)n="u",o=4;else{if(!(e<=4294967295))throw new i("code point within a string may not be greater than 0xFFFFFFFF");n="U",o=8}return"\\"+n+r.repeat("0",o-t.length)+t}function d(e){this.schema=e.schema||o,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=r.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=function(e,t){var n,r,i,o,s,a,u;if(null===t)return{};for(n={},i=0,o=(r=Object.keys(t)).length;i<o;i+=1)s=r[i],a=String(t[s]),"!!"===s.slice(0,2)&&(s="tag:yaml.org,2002:"+s.slice(2)),(u=e.compiledTypeMap.fallback[s])&&c.call(u.styleAliases,a)&&(a=u.styleAliases[a]),n[s]=a;return n}(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function p(e,t){for(var n,i=r.repeat(" ",t),o=0,s=-1,a="",c=e.length;o<c;)-1===(s=e.indexOf("\n",o))?(n=e.slice(o),o=c):(n=e.slice(o,s+1),o=s+1),n.length&&"\n"!==n&&(a+=i),a+=n;return a}function f(e,t){return"\n"+r.repeat(" ",e.indent*t)}function m(e){return 32===e||9===e}function g(e){return 32<=e&&e<=126||161<=e&&e<=55295&&8232!==e&&8233!==e||57344<=e&&e<=65533&&65279!==e||65536<=e&&e<=1114111}function _(e){return g(e)&&65279!==e&&44!==e&&91!==e&&93!==e&&123!==e&&125!==e&&58!==e&&35!==e}function y(e){return/^\n* /.test(e)}function v(e,t,n,r,i){var o,s,a,c=!1,u=!1,l=-1!==r,h=-1,d=g(a=e.charCodeAt(0))&&65279!==a&&!m(a)&&45!==a&&63!==a&&58!==a&&44!==a&&91!==a&&93!==a&&123!==a&&125!==a&&35!==a&&38!==a&&42!==a&&33!==a&&124!==a&&62!==a&&39!==a&&34!==a&&37!==a&&64!==a&&96!==a&&!m(e.charCodeAt(e.length-1));if(t)for(o=0;o<e.length;o++){if(!g(s=e.charCodeAt(o)))return 5;d=d&&_(s)}else{for(o=0;o<e.length;o++){if(10===(s=e.charCodeAt(o)))c=!0,l&&(u=u||o-h-1>r&&" "!==e[h+1],h=o);else if(!g(s))return 5;d=d&&_(s)}u=u||l&&o-h-1>r&&" "!==e[h+1]}return c||u?n>9&&y(e)?5:u?4:3:d&&!i(e)?1:2}function b(e,t,n,r){e.dump=function(){if(0===t.length)return"''";if(!e.noCompatMode&&-1!==l.indexOf(t))return"'"+t+"'";var o=e.indent*Math.max(1,n),s=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),a=r||e.flowLevel>-1&&n>=e.flowLevel;switch(v(t,a,e.indent,s,(function(t){return function(e,t){var n,r;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}(e,t)}))){case 1:return t;case 2:return"'"+t.replace(/'/g,"''")+"'";case 3:return"|"+w(t,e.indent)+x(p(t,o));case 4:return">"+w(t,e.indent)+x(p(function(e,t){var n,r,i=/(\n+)([^\n]*)/g,o=(a=e.indexOf("\n"),a=-1!==a?a:e.length,i.lastIndex=a,k(e.slice(0,a),t)),s="\n"===e[0]||" "===e[0];var a;for(;r=i.exec(e);){var c=r[1],u=r[2];n=" "===u[0],o+=c+(s||n||""===u?"":"\n")+k(u,t),s=n}return o}(t,s),o));case 5:return'"'+function(e){for(var t,n,r,i="",o=0;o<e.length;o++)(t=e.charCodeAt(o))>=55296&&t<=56319&&(n=e.charCodeAt(o+1))>=56320&&n<=57343?(i+=h(1024*(t-55296)+n-56320+65536),o++):(r=u[t],i+=!r&&g(t)?e[o]:r||h(t));return i}(t)+'"';default:throw new i("impossible error: invalid scalar style")}}()}function w(e,t){var n=y(e)?String(t):"",r="\n"===e[e.length-1];return n+(r&&("\n"===e[e.length-2]||"\n"===e)?"+":r?"":"-")+"\n"}function x(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function k(e,t){if(""===e||" "===e[0])return e;for(var n,r,i=/ [^ ]/g,o=0,s=0,a=0,c="";n=i.exec(e);)(a=n.index)-o>t&&(r=s>o?s:a,c+="\n"+e.slice(o,r),o=r+1),s=a;return c+="\n",e.length-o>t&&s>o?c+=e.slice(o,s)+"\n"+e.slice(s+1):c+=e.slice(o),c.slice(1)}function E(e,t,n){var r,o,s,u,l,h;for(s=0,u=(o=n?e.explicitTypes:e.implicitTypes).length;s<u;s+=1)if(((l=o[s]).instanceOf||l.predicate)&&(!l.instanceOf||"object"==typeof t&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(e.tag=n?l.tag:"?",l.represent){if(h=e.styleMap[l.tag]||l.defaultStyle,"[object Function]"===a.call(l.represent))r=l.represent(t,h);else{if(!c.call(l.represent,h))throw new i("!<"+l.tag+'> tag resolver accepts not "'+h+'" style');r=l.represent[h](t,h)}e.dump=r}return!0}return!1}function j(e,t,n,r,o,s){e.tag=null,e.dump=n,E(e,n,!1)||E(e,n,!0);var c=a.call(e.dump);r&&(r=e.flowLevel<0||e.flowLevel>t);var u,l,h="[object Object]"===c||"[object Array]"===c;if(h&&(l=-1!==(u=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||l||2!==e.indent&&t>0)&&(o=!1),l&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(h&&l&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),"[object Object]"===c)r&&0!==Object.keys(e.dump).length?(!function(e,t,n,r){var o,s,a,c,u,l,h="",d=e.tag,p=Object.keys(n);if(!0===e.sortKeys)p.sort();else if("function"==typeof e.sortKeys)p.sort(e.sortKeys);else if(e.sortKeys)throw new i("sortKeys must be a boolean or a function");for(o=0,s=p.length;o<s;o+=1)l="",r&&0===o||(l+=f(e,t)),c=n[a=p[o]],j(e,t+1,a,!0,!0,!0)&&((u=null!==e.tag&&"?"!==e.tag||e.dump&&e.dump.length>1024)&&(e.dump&&10===e.dump.charCodeAt(0)?l+="?":l+="? "),l+=e.dump,u&&(l+=f(e,t)),j(e,t+1,c,!0,u)&&(e.dump&&10===e.dump.charCodeAt(0)?l+=":":l+=": ",h+=l+=e.dump));e.tag=d,e.dump=h||"{}"}(e,t,e.dump,o),l&&(e.dump="&ref_"+u+e.dump)):(!function(e,t,n){var r,i,o,s,a,c="",u=e.tag,l=Object.keys(n);for(r=0,i=l.length;r<i;r+=1)a=e.condenseFlow?'"':"",0!==r&&(a+=", "),s=n[o=l[r]],j(e,t,o,!1,!1)&&(e.dump.length>1024&&(a+="? "),a+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),j(e,t,s,!1,!1)&&(c+=a+=e.dump));e.tag=u,e.dump="{"+c+"}"}(e,t,e.dump),l&&(e.dump="&ref_"+u+" "+e.dump));else if("[object Array]"===c){var d=e.noArrayIndent&&t>0?t-1:t;r&&0!==e.dump.length?(!function(e,t,n,r){var i,o,s="",a=e.tag;for(i=0,o=n.length;i<o;i+=1)j(e,t+1,n[i],!0,!0)&&(r&&0===i||(s+=f(e,t)),e.dump&&10===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=a,e.dump=s||"[]"}(e,d,e.dump,o),l&&(e.dump="&ref_"+u+e.dump)):(!function(e,t,n){var r,i,o="",s=e.tag;for(r=0,i=n.length;r<i;r+=1)j(e,t,n[r],!1,!1)&&(0!==r&&(o+=","+(e.condenseFlow?"":" ")),o+=e.dump);e.tag=s,e.dump="["+o+"]"}(e,d,e.dump),l&&(e.dump="&ref_"+u+" "+e.dump))}else{if("[object String]"!==c){if(e.skipInvalid)return!1;throw new i("unacceptable kind of an object to dump "+c)}"?"!==e.tag&&b(e,e.dump,t,s)}null!==e.tag&&"?"!==e.tag&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function A(e,t){var n,r,i=[],o=[];for(function e(t,n,r){var i,o,s;if(null!==t&&"object"==typeof t)if(-1!==(o=n.indexOf(t)))-1===r.indexOf(o)&&r.push(o);else if(n.push(t),Array.isArray(t))for(o=0,s=t.length;o<s;o+=1)e(t[o],n,r);else for(i=Object.keys(t),o=0,s=i.length;o<s;o+=1)e(t[i[o]],n,r)}(e,i,o),n=0,r=o.length;n<r;n+=1)t.duplicates.push(i[o[n]]);t.usedDuplicates=new Array(r)}function D(e,t){var n=new d(t=t||{});return n.noRefs||A(e,n),j(n,0,e,!0,!0)?n.dump+"\n":""}e.exports.dump=D,e.exports.safeDump=function(e,t){return D(e,r.extend({schema:s},t))}},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(module,exports,__webpack_require__){var factory;window,factory=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./src/main.js")}({"./node_modules/worker-loader/dist/workers/InlineWorker.js":
/*!*****************************************************************!*\
!*** ./node_modules/worker-loader/dist/workers/InlineWorker.js ***!
\*****************************************************************/
/*! no static exports found */function(e,t,n){"use strict";var r=window.URL||window.webkitURL;e.exports=function(e,t){try{try{var n;try{(n=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(e),n=n.getBlob()}catch(t){n=new Blob([e])}return new Worker(r.createObjectURL(n))}catch(t){return new Worker("data:application/javascript,"+encodeURIComponent(e))}}catch(e){if(!t)throw Error("Inline worker is not supported");return new Worker(t)}}},"./package.json":
/*!**********************!*\
!*** ./package.json ***!
\**********************/
/*! exports provided: name, version, description, module, scripts, repository, keywords, author, license, bugs, homepage, dependencies, devDependencies, eslintConfig, default */function(e){e.exports=JSON.parse('{"name":"imjoy-rpc","version":"0.5.9","description":"Remote procedure calls for ImJoy.","module":"index.js","scripts":{"build":"rm -rf dist && npm run build-umd","build-umd":"webpack --config webpack.config.js --mode development && NODE_ENV=production webpack --config webpack.config.js --mode production --devtool source-map ","watch":"NODE_ENV=production webpack --watch --progress --config webpack.config.js --mode production --devtool source-map","publish-npm":"npm install && npm run build && npm publish","serve":"webpack-dev-server","stats":"webpack --profile --json > stats.json","stats-prod":"webpack --profile --json --mode production > stats-prod.json","analyze":"webpack-bundle-analyzer -p 9999 stats.json","analyze-prod":"webpack-bundle-analyzer -p 9999 stats-prod.json","clean":"rimraf dist/*","deploy":"npm run build && node deploy-site.js","format":"prettier --write \\"{src,tests}/**/**\\"","check-format":"prettier --check \\"{src,tests}/**/**\\"","test":"karma start --single-run --browsers ChromeHeadless,FirefoxHeadless karma.conf.js","test-watch":"karma start --auto-watch --browsers ChromeDebugging karma.conf.js --debug"},"repository":{"type":"git","url":"git+https://github.com/imjoy-team/imjoy-rpc.git"},"keywords":["imjoy","rpc"],"author":"imjoy-team <imjoy.team@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/imjoy-team/imjoy-rpc/issues"},"homepage":"https://github.com/imjoy-team/imjoy-rpc","dependencies":{"@msgpack/msgpack":"^2.7.1","socket.io-client":"^4.4.1"},"devDependencies":{"@babel/core":"^7.16.12","@babel/plugin-syntax-dynamic-import":"^7.8.3","@babel/polyfill":"^7.12.1","@babel/preset-env":"^7.16.11","@types/requirejs":"^2.1.34","babel-core":"^6.26.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.3","babel-runtime":"^6.26.0","chai":"^4.3.6","clean-webpack-plugin":"^0.1.19","copy-webpack-plugin":"^5.1.2","eslint":"^6.8.0","eslint-config-prettier":"^4.2.0","eslint-loader":"^4.0.2","file-loader":"^0.11.2","fs-extra":"^0.30.0","gh-pages":"^2.0.1","html-loader":"^0.5.5","html-webpack-plugin":"^3.2.0","json-loader":"^0.5.4","karma":"^6.3.12","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^1.3.0","karma-mocha":"^1.3.0","karma-sourcemap-loader":"^0.3.8","karma-spec-reporter":"0.0.32","karma-webpack":"^4.0.2","lerna":"^3.22.1","lodash.debounce":"^4.0.8","mocha":"^7.2.0","postcss":"^7.0.36","prettier":"^1.6.1","rimraf":"^2.6.2","schema-utils":"^0.4.3","style-loader":"^0.18.1","url-loader":"^0.5.9","webpack":"^4.46.0","webpack-bundle-analyzer":"^3.9.0","webpack-cli":"^3.3.12","webpack-dev-server":"^3.11.3","webpack-merge":"^4.1.1","workbox-webpack-plugin":"^4.3.1","worker-loader":"^2.0.0","write-file-webpack-plugin":"^4.5.1"},"eslintConfig":{"globals":{"document":true,"window":true}}}')},"./src/main.js":
/*!*********************!*\
!*** ./src/main.js ***!
\*********************/
/*! exports provided: RPC, API_VERSION, VERSION, loadRequirements, waitForInitialization, setupRPC */function(e,t,n){"use strict";n.r(t),n.d(t,"waitForInitialization",(function(){return l})),n.d(t,"setupRPC",(function(){return h}));var r=n(/*! ./plugin.webworker.js */"./src/plugin.webworker.js"),i=n.n(r),o=n(/*! ./pluginIframe.js */"./src/pluginIframe.js"),s=n(/*! ./utils.js */"./src/utils.js");n.d(t,"loadRequirements",(function(){return s.loadRequirements}));var a=n(/*! ./rpc.js */"./src/rpc.js");n.d(t,"RPC",(function(){return a.RPC})),n.d(t,"API_VERSION",(function(){return a.API_VERSION}));var c=n(/*! ../package.json */"./package.json");function u(){return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope}function l(e){u()&&(globalThis.parent=self),(e=e||{}).enable_service_worker&&(Object(s.setupServiceWorker)(e.base_url,e.target_origin,e.cache_requirements),e.enable_service_worker=!1),e.cache_requirements&&delete e.cache_requirements;const t=e.target_origin||"*";if(e.credential_required&&"function"!=typeof e.verify_credential)throw new Error("Please also provide the `verify_credential` function with `credential_required`.");if(e.credential_required&&"*"===t)throw new Error("`target_origin` was set to `*` with `credential_required=true`, there is a security risk that you may leak the credential to website from other origin. Please specify the `target_origin` explicitly.");const n=Object(s.randId)(),r=i=>{if("message"===i.type&&(!i.origin||"*"===t||i.origin===t)){if("initialize"!==i.data.type)throw new Error("unrecognized message: "+i.data);{globalThis.removeEventListener("message",r),i.data.peer_id!==n&&console.warn(`${i.data.config&&i.data.config.name}: connection peer id mismatch ${i.data.peer_id} !== ${n}`);const o=i.data.config;"*"!==t&&(o.target_origin=t),e.credential_required?e.verify_credential(o.credential).then(e=>{if(!e||!e.auth||e.error)throw new Error("Failed to verify the credentail:"+(e&&e.error));o.auth=e.auth,h(o).then(()=>{console.log("ImJoy RPC loaded successfully!")})}):h(o).then(()=>{console.log("ImJoy RPC loaded successfully!")})}}};globalThis.addEventListener("message",r),u()?parent.postMessage({type:"imjoyRPCReady",config:e,peer_id:n}):parent.postMessage({type:"imjoyRPCReady",config:e,peer_id:n},"*")}function h(e){return(e=e||{}).name=e.name||Object(s.randId)(),(e=Object(s.normalizeConfig)(e)).enable_service_worker&&Object(s.setupServiceWorker)(e.base_url,e.target_origin,e.cache_requirements),e.cache_requirements&&delete e.cache_requirements,new Promise((t,n)=>{const r=n=>{const i=n.detail;e.expose_api_globally&&(globalThis.api=i),t(i),globalThis.removeEventListener("imjoy_remote_api_ready",r)};if(function(){try{return window.self!==window.top}catch(e){return!0}}()){if("web-worker"===e.type)try{!function(e){if(!e.allow_execution)throw new Error("web-worker plugin can only work with allow_execution=true");let t=null;e.broadcastChannel&&(t=new BroadcastChannel(e.broadcastChannel));const n=new i.a,r=setTimeout((function(){n.terminate(),console.warn("Plugin failed to start as a web-worker, running in an iframe instead."),Object(o.default)(e)}),2e3),a=Object(s.randId)();n.addEventListener("message",(function(i){let o=void 0;const s=i.data;if("worker-ready"===s.type)return n.postMessage({type:"connectRPC",config:e}),void clearTimeout(r);"initialized"===s.type?(s.config=Object.assign({},e,s.config),s.origin=window.location.origin,s.peer_id=a):"imjoy_remote_api_ready"===s.type?window.dispatchEvent(new CustomEvent("imjoy_remote_api_ready",{detail:null})):"cacheRequirements"===s.type&&"function"==typeof cache_requirements?cache_requirements(s.requirements):"disconnect"===s.type?n.terminate():s.__transferables__&&(o=s.__transferables__,delete s.__transferables__),t?t.postMessage(s):parent.postMessage(s,e.target_origin||"*",o)})),(t||window).addEventListener("message",(function(r){if("message"===r.type&&(t||"*"===e.target_origin||r.origin===e.target_origin)){let t=void 0;const i=r.data;i.__transferables__&&(t=i.__transferables__,delete i.__transferables__),i.peer_id===a?n.postMessage(i,t):e.debug&&console.log(`connection peer id mismatch ${i.peer_id} !== ${a}`)}}))}(e)}catch(t){Object(o.default)(e)}else{if(!["rpc-window","rpc-worker","iframe","window"].includes(e.type))return console.error("Unsupported plugin type: "+e.type),void n("Unsupported plugin type: "+e.type);Object(o.default)(e)}globalThis.addEventListener("imjoy_remote_api_ready",r)}else u()?Object(o.default)(e):n(new Error("imjoy-rpc should only run inside an iframe or a webworker."))})}n.d(t,"VERSION",(function(){return c.version}))},"./src/plugin.webworker.js":
/*!*********************************!*\
!*** ./src/plugin.webworker.js ***!
\*********************************/
/*! no static exports found */function(e,t,n){e.exports=function(){return n(/*! !./node_modules/worker-loader/dist/workers/InlineWorker.js */"./node_modules/worker-loader/dist/workers/InlineWorker.js")('/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== \'undefined\' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: \'Module\' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, \'__esModule\', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__webpack_require__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __webpack_require__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === \'object\' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__webpack_require__.r(ns);\n/******/ \t\tObject.defineProperty(ns, \'default\', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != \'string\') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module[\'default\']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, \'a\', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = "";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = "./src/plugin.webworker.js");\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ "./src/plugin.webworker.js":\n/*!*********************************!*\\\n !*** ./src/plugin.webworker.js ***!\n \\*********************************/\n/*! no exports provided */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _pluginCore_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pluginCore.js */ "./src/pluginCore.js");\n/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rpc.js */ "./src/rpc.js");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ "./src/utils.js");\n/**\n * Contains the routines loaded by the plugin Worker under web-browser.\n *\n * Initializes the web environment version of the platform-dependent\n * connection object for the plugin site\n */\n\n\n\n\n// make sure this runs inside a webworker\nif (\n typeof WorkerGlobalScope === "undefined" ||\n !self ||\n !(self instanceof WorkerGlobalScope)\n) {\n throw new Error("This script can only loaded in a webworker");\n}\n\nasync function executeEsModule(content) {\n const dataUri =\n "data:text/javascript;charset=utf-8," + encodeURIComponent(content);\n await import(/* webpackIgnore: true */ dataUri);\n}\n\n/**\n * Connection object provided to the RPC constructor,\n * plugin site implementation for the web-based environment.\n * Global will be then cleared to prevent exposure into the\n * Worker, so we put this local connection object into a closure\n */\nclass Connection extends _utils_js__WEBPACK_IMPORTED_MODULE_2__["MessageEmitter"] {\n constructor(config) {\n super(config && config.debug);\n this.config = config || {};\n }\n connect() {\n self.addEventListener("message", e => {\n this._fire(e.data.type, e.data);\n });\n this.emit({\n type: "initialized",\n config: this.config\n });\n }\n disconnect() {\n this._fire("beforeDisconnect");\n self.close();\n this._fire("disconnected");\n }\n emit(data) {\n let transferables = undefined;\n if (data.__transferables__) {\n transferables = data.__transferables__;\n delete data.__transferables__;\n }\n self.postMessage(data, transferables);\n }\n async execute(code) {\n if (code.type === "requirements") {\n await Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__["loadRequirementsInWebworker"])(code.requirements);\n } else if (code.type === "script") {\n try {\n if (code.attrs.type === "module") {\n await executeEsModule(code.content);\n } else {\n eval(code.content);\n }\n } catch (e) {\n console.error(e.message, e.stack);\n throw e;\n }\n } else {\n throw "unsupported code type.";\n }\n if (code.type === "requirements") {\n self.postMessage({\n type: "cacheRequirements",\n requirements: code.requirements\n });\n }\n }\n}\nconst config = {\n type: "web-worker",\n dedicated_thread: true,\n allow_execution: true,\n lang: "javascript",\n api_version: _rpc_js__WEBPACK_IMPORTED_MODULE_1__["API_VERSION"]\n};\nconst conn = new Connection(config);\nconn.on("connectRPC", data => {\n Object(_pluginCore_js__WEBPACK_IMPORTED_MODULE_0__["connectRPC"])(conn, Object.assign(data.config, config));\n});\nconn.connect();\nself.postMessage({\n type: "worker-ready"\n});\n\n\n/***/ }),\n\n/***/ "./src/pluginCore.js":\n/*!***************************!*\\\n !*** ./src/pluginCore.js ***!\n \\***************************/\n/*! exports provided: connectRPC */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "connectRPC", function() { return connectRPC; });\n/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.js */ "./src/rpc.js");\n/**\n * Core plugin script loaded into the plugin process/thread.\n *\n * Initializes the plugin-site API global methods.\n */\n\nfunction connectRPC(connection, config) {\n config = config || {};\n const codecs = {};\n const rpc = new _rpc_js__WEBPACK_IMPORTED_MODULE_0__["RPC"](connection, config, codecs);\n rpc.on("getInterface", function () {\n launchConnected();\n });\n rpc.on("remoteReady", function () {\n const api = rpc.getRemote() || {};\n\n api.registerCodec = function (config) {\n if (!config["name"] || !config["encoder"] && !config["decoder"]) {\n throw new Error("Invalid codec format, please make sure you provide a name, type, encoder and decoder.");\n } else {\n if (config.type) {\n for (let k of Object.keys(codecs)) {\n if (codecs[k].type === config.type || k === config.name) {\n delete codecs[k];\n console.warn("Remove duplicated codec: " + k);\n }\n }\n }\n\n codecs[config["name"]] = config;\n }\n };\n\n api.init = function (config) {\n // register a minimal plugin api\n rpc.setInterface({\n setup() {}\n\n }, config);\n };\n\n api.disposeObject = function (obj) {\n rpc.disposeObject(obj);\n };\n\n api.export = function (_interface, config) {\n rpc.setInterface(_interface, config);\n };\n\n api.onLoad = function (handler) {\n handler = checkHandler(handler);\n\n if (connected) {\n handler();\n } else {\n connectedHandlers.push(handler);\n }\n };\n\n api.dispose = function (_interface) {\n rpc.disconnect();\n };\n\n api._rpc = rpc;\n\n if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {\n self.api = api;\n self.postMessage({\n type: "imjoy_remote_api_ready"\n });\n self.dispatchEvent(new CustomEvent("imjoy_remote_api_ready", {\n detail: api\n }));\n } else if (typeof window) {\n window.dispatchEvent(new CustomEvent("imjoy_remote_api_ready", {\n detail: api\n }));\n }\n });\n let connected = false;\n const connectedHandlers = [];\n\n const launchConnected = function () {\n if (!connected) {\n connected = true;\n let handler;\n\n while (handler = connectedHandlers.pop()) {\n handler();\n }\n }\n };\n\n const checkHandler = function (handler) {\n const type = typeof handler;\n\n if (type !== "function") {\n const msg = "A function may only be subsribed to the event, " + type + " was provided instead";\n throw new Error(msg);\n }\n\n return handler;\n };\n\n return rpc;\n}\n\n/***/ }),\n\n/***/ "./src/rpc.js":\n/*!********************!*\\\n !*** ./src/rpc.js ***!\n \\********************/\n/*! exports provided: API_VERSION, RPC */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "API_VERSION", function() { return API_VERSION; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RPC", function() { return RPC; });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./src/utils.js");\n/**\n * Contains the RPC object used both by the application\n * site, and by each plugin\n */\n\nconst API_VERSION = "0.2.3";\nconst ArrayBufferView = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())).constructor;\n\nfunction _appendBuffer(buffer1, buffer2) {\n const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);\n tmp.set(new Uint8Array(buffer1), 0);\n tmp.set(new Uint8Array(buffer2), buffer1.byteLength);\n return tmp.buffer;\n}\n\nfunction indexObject(obj, is) {\n if (!is) throw new Error("undefined index");\n if (typeof is === "string") return indexObject(obj, is.split("."));else if (is.length === 0) return obj;else return indexObject(obj[is[0]], is.slice(1));\n}\n/**\n * RPC object represents a single site in the\n * communication protocol between the application and the plugin\n *\n * @param {Object} connection a special object allowing to send\n * and receive messages from the opposite site (basically it\n * should only provide send() and onMessage() methods)\n */\n\n\nclass RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__["MessageEmitter"] {\n constructor(connection, config, codecs) {\n super(config && config.debug);\n this._connection = connection;\n this.config = config || {};\n this._codecs = codecs || {};\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._remote_set = false; // make sure there is an execute function\n\n const name = this.config.name;\n\n this._connection.execute = this._connection.execute || function () {\n throw new Error(`connection.execute not implemented (in "${name}")`);\n };\n\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n\n this._method_refs.onReady(() => {\n this._fire("remoteIdle");\n });\n\n this._method_refs.onBusy(() => {\n this._fire("remoteBusy");\n });\n\n this._setupMessageHanlders();\n }\n\n init() {\n this._connection.emit({\n type: "initialized",\n config: this.config,\n peer_id: this._connection.peer_id\n });\n }\n\n setConfig(config) {\n if (config) for (const k of Object.keys(config)) {\n this.config[k] = config[k];\n }\n }\n /**\n * Set a handler to be called when received a responce from the\n * remote site reporting that the previously provided interface\n * has been successfully set as remote for that site\n *\n * @param {Function} handler\n */\n\n\n getRemoteCallStack() {\n return this._method_refs.getStack();\n }\n /**\n * @returns {Object} set of remote interface methods\n */\n\n\n getRemote() {\n return this._remote_interface;\n }\n /**\n * Sets the interface of this site making it available to the\n * remote site by sending a message with a set of methods names\n *\n * @param {Object} _interface to set\n */\n\n\n setInterface(_interface, config) {\n config = config || {};\n this.config.name = config.name || this.config.name;\n this.config.description = config.description || this.config.description;\n\n if (this.config.forwarding_functions) {\n for (let func_name of this.config.forwarding_functions) {\n const _remote = this._remote_interface;\n\n if (_remote[func_name]) {\n if (_interface.constructor === Object) {\n if (!_interface[func_name]) {\n _interface[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n } else if (_interface.constructor.constructor === Function) {\n if (!_interface.constructor.prototype[func_name]) {\n _interface.constructor.prototype[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n }\n }\n }\n }\n\n this._local_api = _interface;\n if (!this._remote_set) this._fire("interfaceAvailable");else this.sendInterface();\n return new Promise(resolve => {\n this.once("interfaceSetAsRemote", resolve);\n });\n }\n /**\n * Sends the actual interface to the remote site upon it was\n * updated or by a special request of the remote site\n */\n\n\n sendInterface() {\n if (!this._local_api) {\n throw new Error("interface is not set.");\n }\n\n this._encode(this._local_api, true).then(api => {\n this._connection.emit({\n type: "setInterface",\n api: api\n });\n });\n }\n\n _disposeObject(objectId) {\n if (this._object_store[objectId]) {\n delete this._object_store[objectId];\n } else {\n throw new Error(`Object (id=${objectId}) not found.`);\n }\n }\n\n disposeObject(obj) {\n return new Promise((resolve, reject) => {\n if (this._object_weakmap.has(obj)) {\n const objectId = this._object_weakmap.get(obj);\n\n this._connection.once("disposed", data => {\n if (data.error) reject(new Error(data.error));else resolve();\n });\n\n this._connection.emit({\n type: "disposeObject",\n object_id: objectId\n });\n } else {\n throw new Error("Invalid object");\n }\n });\n }\n /**\n * Handles a message from the remote site\n */\n\n\n _setupMessageHanlders() {\n this._connection.on("init", this.init);\n\n this._connection.on("execute", data => {\n Promise.resolve(this._connection.execute(data.code)).then(() => {\n this._connection.emit({\n type: "executed"\n });\n }).catch(e => {\n console.error(e);\n\n this._connection.emit({\n type: "executed",\n error: String(e)\n });\n });\n });\n\n this._connection.on("method", async data => {\n let resolve, reject, method, method_this, args, result;\n\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n\n const _interface = this._object_store[data.object_id];\n method = indexObject(_interface, data.name);\n\n if (data.name.includes(".")) {\n const tmp = data.name.split(".");\n const intf_index = tmp.slice(0, tmp.length - 1).join(".");\n method_this = indexObject(_interface, intf_index);\n } else {\n method_this = _interface;\n }\n\n args = await this._unwrap(data.args, true);\n\n if (data.promise) {\n result = method.apply(method_this, args);\n\n if (result instanceof Promise || method.constructor && method.constructor.name === "AsyncFunction") {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method.apply(method_this, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n\n if (reject) {\n reject(err);\n }\n }\n });\n\n this._connection.on("callback", async data => {\n let resolve, reject, method, args, result;\n\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n\n if (data.promise) {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n\n if (!method) {\n throw new Error("Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");\n }\n\n result = method.apply(null, args);\n\n if (result instanceof Promise || method.constructor && method.constructor.name === "AsyncFunction") {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n\n if (!method) {\n throw new Error("Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");\n }\n\n method.apply(null, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n\n if (reject) {\n reject(err);\n }\n }\n });\n\n this._connection.on("disposeObject", data => {\n try {\n this._disposeObject(data.object_id);\n\n this._connection.emit({\n type: "disposed"\n });\n } catch (e) {\n console.error(e);\n\n this._connection.emit({\n type: "disposed",\n error: String(e)\n });\n }\n });\n\n this._connection.on("setInterface", data => {\n this._setRemoteInterface(data.api);\n });\n\n this._connection.on("getInterface", () => {\n this._fire("getInterface");\n\n if (this._local_api) {\n this.sendInterface();\n } else {\n this.once("interfaceAvailable", () => {\n this.sendInterface();\n });\n }\n });\n\n this._connection.on("interfaceSetAsRemote", () => {\n this._remote_set = true;\n\n this._fire("interfaceSetAsRemote");\n });\n\n this._connection.on("disconnect", () => {\n this._fire("beforeDisconnect");\n\n this._connection.disconnect();\n\n this._fire("disconnected");\n });\n }\n /**\n * Sends a requests to the remote site asking it to provide its\n * current interface\n */\n\n\n requestRemote() {\n this._connection.emit({\n type: "getInterface"\n });\n }\n\n _ndarray(typedArray, shape, dtype) {\n const _dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["typedArrayToDtype"])(typedArray);\n\n if (dtype && dtype !== _dtype) {\n throw "dtype doesn\'t match the type of the array: " + _dtype + " != " + dtype;\n }\n\n shape = shape || [typedArray.length];\n return {\n _rtype: "ndarray",\n _rvalue: typedArray.buffer,\n _rshape: shape,\n _rdtype: _dtype\n };\n }\n /**\n * Sets the new remote interface provided by the other site\n *\n * @param {Array} names list of function names\n */\n\n\n _setRemoteInterface(api) {\n this._decode(api).then(intf => {\n // update existing interface instead of recreating it\n // this will preserve the object reference\n if (this._remote_interface) {\n // clear the interface\n for (let k in this._remote_interface) delete this._remote_interface[k]; // then assign the new interfaces\n\n\n Object.assign(this._remote_interface, intf);\n } else this._remote_interface = intf;\n\n this._fire("remoteReady");\n\n this._reportRemoteSet();\n });\n }\n /**\n * Generates the wrapped function corresponding to a single remote\n * method. When the generated function is called, it will send the\n * corresponding message to the remote site asking it to execute\n * the particular method of its interface\n *\n * @param {String} name of the remote method\n *\n * @returns {Function} wrapped remote method\n */\n\n\n _genRemoteMethod(targetId, name, objectId) {\n const me = this;\n\n const remoteMethod = function () {\n return new Promise(async (resolve, reject) => {\n let id = null;\n\n try {\n id = me._method_refs.put(objectId ? objectId + "/" + name : name);\n\n const wrapped_resolve = function () {\n if (id !== null) me._method_refs.fetch(id);\n return resolve.apply(this, arguments);\n };\n\n const wrapped_reject = function () {\n if (id !== null) me._method_refs.fetch(id);\n return reject.apply(this, arguments);\n };\n\n const encodedPromise = await me._wrap([wrapped_resolve, wrapped_reject]); // store the key id for removing them from the reference store together\n\n wrapped_resolve.__promise_pair = encodedPromise[1]._rvalue;\n wrapped_reject.__promise_pair = encodedPromise[0]._rvalue;\n let args = Array.prototype.slice.call(arguments);\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\n\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === "object" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n\n if (name === "register" || name === "registerService" || name === "register_service" || name === "export" || name === "on") {\n args = await me._wrap(args, true);\n } else {\n args = await me._wrap(args);\n }\n\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n\n me._connection.emit({\n type: "method",\n target_id: targetId,\n name: name,\n object_id: objectId,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n }, transferables);\n } catch (e) {\n if (id) me._method_refs.fetch(id);\n reject(`Failed to exectue remote method (interface: ${objectId || me.id}, method: ${name}), error: ${e}`);\n }\n });\n };\n\n remoteMethod.__remote_method = true;\n return remoteMethod;\n }\n /**\n * Sends a responce reporting that interface just provided by the\n * remote site was successfully set by this site as remote\n */\n\n\n _reportRemoteSet() {\n this._connection.emit({\n type: "interfaceSetAsRemote"\n });\n }\n /**\n * Prepares the provided set of remote method arguments for\n * sending to the remote site, replaces all the callbacks with\n * identifiers\n *\n * @param {Array} args to wrap\n *\n * @returns {Array} wrapped arguments\n */\n\n\n async _encode(aObject, asInterface, objectId) {\n const aType = typeof aObject;\n\n if (aType === "number" || aType === "string" || aType === "boolean" || aObject === null || aObject === undefined || aObject instanceof ArrayBuffer) {\n return aObject;\n }\n\n let bObject;\n\n if (typeof aObject === "function") {\n if (asInterface) {\n if (!objectId) throw new Error("objectId is not specified.");\n bObject = {\n _rtype: "interface",\n _rtarget_id: this._connection.peer_id,\n _rintf: objectId,\n _rvalue: asInterface\n };\n\n this._method_weakmap.set(aObject, bObject);\n } else if (this._method_weakmap.has(aObject)) {\n bObject = this._method_weakmap.get(aObject);\n } else {\n const cid = this._store.put(aObject);\n\n bObject = {\n _rtype: "callback",\n _rtarget_id: this._connection.peer_id,\n _rname: aObject.constructor && aObject.constructor.name || cid,\n _rvalue: cid\n };\n }\n\n return bObject;\n } // skip if already encoded\n\n\n if (aObject.constructor instanceof Object && aObject._rtype) {\n // make sure the interface functions are encoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._encode(aObject, asInterface, objectId);\n bObject._rtype = temp;\n } else {\n bObject = aObject;\n }\n\n return bObject;\n }\n\n const transferables = [];\n const _transfer = aObject._transfer;\n const isarray = Array.isArray(aObject);\n\n for (let tp of Object.keys(this._codecs)) {\n const codec = this._codecs[tp];\n\n if (codec.encoder && aObject instanceof codec.type) {\n // TODO: what if multiple encoders found\n let encodedObj = await Promise.resolve(codec.encoder(aObject));\n if (encodedObj && !encodedObj._rtype) encodedObj._rtype = codec.name; // encode the functions in the interface object\n\n if (encodedObj && encodedObj._rintf) {\n const temp = encodedObj._rtype;\n delete encodedObj._rtype;\n encodedObj = await this._encode(encodedObj, asInterface, objectId);\n encodedObj._rtype = temp;\n }\n\n bObject = encodedObj;\n return bObject;\n }\n }\n\n if (\n /*global tf*/\n typeof tf !== "undefined" && tf.Tensor && aObject instanceof tf.Tensor) {\n const v_buffer = aObject.dataSync();\n\n if (aObject._transfer || _transfer) {\n transferables.push(v_buffer.buffer);\n delete aObject._transfer;\n }\n\n bObject = {\n _rtype: "ndarray",\n _rvalue: v_buffer.buffer,\n _rshape: aObject.shape,\n _rdtype: aObject.dtype\n };\n } else if (\n /*global nj*/\n typeof nj !== "undefined" && nj.NdArray && aObject instanceof nj.NdArray) {\n const dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["typedArrayToDtype"])(aObject.selection.data);\n\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.selection.data.buffer);\n delete aObject._transfer;\n }\n\n bObject = {\n _rtype: "ndarray",\n _rvalue: aObject.selection.data.buffer,\n _rshape: aObject.shape,\n _rdtype: dtype\n };\n } else if (aObject instanceof Error) {\n console.error(aObject);\n bObject = {\n _rtype: "error",\n _rvalue: aObject.toString()\n };\n } else if (typeof File !== "undefined" && aObject instanceof File) {\n bObject = {\n _rtype: "file",\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n } // send objects supported by structure clone algorithm\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n else if (aObject !== Object(aObject) || aObject instanceof Boolean || aObject instanceof String || aObject instanceof Date || aObject instanceof RegExp || aObject instanceof ImageData || typeof FileList !== "undefined" && aObject instanceof FileList || typeof FileSystemDirectoryHandle !== "undefined" && aObject instanceof FileSystemDirectoryHandle || typeof FileSystemFileHandle !== "undefined" && aObject instanceof FileSystemFileHandle || typeof FileSystemHandle !== "undefined" && aObject instanceof FileSystemHandle || typeof FileSystemWritableFileStream !== "undefined" && aObject instanceof FileSystemWritableFileStream) {\n bObject = aObject; // TODO: avoid object such as DynamicPlugin instance.\n } else if (typeof File !== "undefined" && aObject instanceof File) {\n bObject = {\n _rtype: "file",\n _rname: aObject.name,\n _rmime: aObject.type,\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n } else if (aObject instanceof Blob) {\n bObject = {\n _rtype: "blob",\n _rvalue: aObject\n };\n } else if (aObject instanceof ArrayBufferView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n\n const dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["typedArrayToDtype"])(aObject);\n bObject = {\n _rtype: "typedarray",\n _rvalue: aObject.buffer,\n _rdtype: dtype\n };\n } else if (aObject instanceof DataView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n\n bObject = {\n _rtype: "memoryview",\n _rvalue: aObject.buffer\n };\n } else if (aObject instanceof Set) {\n bObject = {\n _rtype: "set",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (aObject instanceof Map) {\n bObject = {\n _rtype: "orderedmap",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (aObject.constructor instanceof Object || Array.isArray(aObject)) {\n bObject = isarray ? [] : {};\n let keys; // an object/array\n\n if (aObject.constructor === Object || Array.isArray(aObject)) {\n keys = Object.keys(aObject);\n } // a class\n else if (aObject.constructor === Function) {\n throw new Error("Please instantiate the class before exportting it.");\n } // instance of a class\n else if (aObject.constructor.constructor === Function) {\n keys = Object.getOwnPropertyNames(Object.getPrototypeOf(aObject)).concat(Object.keys(aObject)); // TODO: use a proxy object to represent the actual object\n // always encode class instance as interface\n\n asInterface = true;\n } else {\n throw Error("Unsupported interface type");\n }\n\n let hasFunction = false; // encode interfaces\n\n if (aObject._rintf || asInterface) {\n if (!objectId) {\n if (typeof aObject._rintf === "string" && aObject._rintf.length > 0) {\n objectId = aObject._rintf; // enable custom object id\n } else {\n objectId = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["randId"])();\n } // Note: object with the same id will be overwritten\n\n\n if (this._object_store[objectId]) console.warn(`Overwritting interface object with the same id: ${objectId}`);\n this._object_store[objectId] = aObject;\n }\n\n for (let k of keys) {\n if (k === "constructor") continue;\n\n if (k.startsWith("_")) {\n continue;\n }\n\n bObject[k] = await this._encode(aObject[k], typeof asInterface === "string" ? asInterface + "." + k : k, objectId);\n\n if (typeof aObject[k] === "function") {\n hasFunction = true;\n }\n } // object id for dispose the object remotely\n\n\n if (hasFunction) bObject._rintf = objectId; // remove interface when closed\n\n if (aObject.on && typeof aObject.on === "function") {\n aObject.on("close", () => {\n delete this._object_store[objectId];\n });\n }\n } else {\n for (let k of keys) {\n if (["hasOwnProperty", "constructor"].includes(k)) continue;\n bObject[k] = await this._encode(aObject[k]);\n }\n } // for example, browserFS object\n\n } else if (typeof aObject === "object") {\n const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(aObject)).concat(Object.keys(aObject));\n const objectId = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["randId"])();\n\n for (let k of keys) {\n if (["hasOwnProperty", "constructor"].includes(k)) continue; // encode as interface\n\n bObject[k] = await this._encode(aObject[k], k, bObject);\n } // object id, used for dispose the object\n\n\n bObject._rintf = objectId;\n } else {\n throw "imjoy-rpc: Unsupported data type:" + aObject;\n }\n\n if (transferables.length > 0) {\n bObject.__transferables__ = transferables;\n }\n\n if (!bObject) {\n throw new Error("Failed to encode object");\n }\n\n return bObject;\n }\n\n async _decode(aObject, withPromise) {\n if (!aObject) {\n return aObject;\n }\n\n let bObject;\n\n if (aObject["_rtype"]) {\n if (this._codecs[aObject._rtype] && this._codecs[aObject._rtype].decoder) {\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n aObject = await this._decode(aObject, withPromise);\n aObject._rtype = temp;\n }\n\n bObject = await Promise.resolve(this._codecs[aObject._rtype].decoder(aObject));\n } else if (aObject._rtype === "callback") {\n bObject = this._genRemoteCallback(aObject._rtarget_id, aObject._rvalue, withPromise);\n } else if (aObject._rtype === "interface") {\n bObject = this._genRemoteMethod(aObject._rtarget_id, aObject._rvalue, aObject._rintf);\n } else if (aObject._rtype === "ndarray") {\n /*global nj tf*/\n //create build array/tensor if used in the plugin\n if (typeof nj !== "undefined" && nj.array) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n\n bObject = nj.array(new Uint8(aObject._rvalue), aObject._rdtype).reshape(aObject._rshape);\n } else if (typeof tf !== "undefined" && tf.Tensor) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n\n const arraytype = _utils_js__WEBPACK_IMPORTED_MODULE_0__["dtypeToTypedArray"][aObject._rdtype];\n bObject = tf.tensor(new arraytype(aObject._rvalue), aObject._rshape, aObject._rdtype);\n } else {\n //keep it as regular if transfered to the main app\n bObject = aObject;\n }\n } else if (aObject._rtype === "error") {\n bObject = new Error(aObject._rvalue);\n } else if (aObject._rtype === "file") {\n if (aObject._rvalue instanceof File) {\n bObject = aObject._rvalue; //patch _path\n\n bObject._path = aObject._rpath;\n } else {\n bObject = new File([aObject._rvalue], aObject._rname, {\n type: aObject._rmime\n });\n bObject._path = aObject._rpath;\n }\n } else if (aObject._rtype === "typedarray") {\n const arraytype = _utils_js__WEBPACK_IMPORTED_MODULE_0__["dtypeToTypedArray"][aObject._rdtype];\n if (!arraytype) throw new Error("unsupported dtype: " + aObject._rdtype);\n bObject = new arraytype(aObject._rvalue);\n } else if (aObject._rtype === "memoryview") {\n bObject = new DataView(aObject._rvalue);\n } else if (aObject._rtype === "blob") {\n if (aObject._rvalue instanceof Blob) {\n bObject = aObject._rvalue;\n } else {\n bObject = new Blob([aObject._rvalue], {\n type: aObject._rmime\n });\n }\n } else if (aObject._rtype === "orderedmap") {\n bObject = new Map(await this._decode(aObject._rvalue, withPromise));\n } else if (aObject._rtype === "set") {\n bObject = new Set(await this._decode(aObject._rvalue, withPromise));\n } else {\n // make sure all the interface functions are decoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._decode(aObject, withPromise);\n bObject._rtype = temp;\n } else bObject = aObject;\n }\n } else if (aObject.constructor === Object || Array.isArray(aObject)) {\n const isarray = Array.isArray(aObject);\n bObject = isarray ? [] : {};\n\n for (let k of Object.keys(aObject)) {\n if (isarray || aObject.hasOwnProperty(k)) {\n const v = aObject[k];\n bObject[k] = await this._decode(v, withPromise);\n }\n }\n } else {\n bObject = aObject;\n }\n\n if (bObject === undefined) {\n throw new Error("Failed to decode object");\n } // store the object id for dispose\n\n\n if (aObject._rintf) {\n this._object_weakmap.set(bObject, aObject._rintf);\n }\n\n return bObject;\n }\n\n async _wrap(args, asInterface) {\n return await this._encode(args, asInterface);\n }\n /**\n * Unwraps the set of arguments delivered from the remote site,\n * replaces all callback identifiers with a function which will\n * initiate sending that callback identifier back to other site\n *\n * @param {Object} args to unwrap\n *\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Array} unwrapped args\n */\n\n\n async _unwrap(args, withPromise) {\n return await this._decode(args, withPromise);\n }\n /**\n * Generates the wrapped function corresponding to a single remote\n * callback. When the generated function is called, it will send\n * the corresponding message to the remote site asking it to\n * execute the particular callback previously saved during a call\n * by the remote site a method from the interface of this site\n *\n * @param {Number} id of the remote callback to execute\n * @param {Number} argNum argument index of the callback\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Function} wrapped remote callback\n */\n\n\n _genRemoteCallback(targetId, cid, withPromise) {\n const me = this;\n let remoteCallback;\n\n if (withPromise) {\n remoteCallback = function () {\n return new Promise(async (resolve, reject) => {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\n\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === "object" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n const encodedPromise = await me._wrap([resolve, reject]); // store the key id for removing them from the reference store together\n\n resolve.__promise_pair = encodedPromise[1]._rvalue;\n reject.__promise_pair = encodedPromise[0]._rvalue;\n\n try {\n me._connection.emit({\n type: "callback",\n target_id: targetId,\n id: cid,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n }, transferables);\n } catch (e) {\n reject(`Failed to exectue remote callback ( id: ${cid}).`);\n }\n });\n };\n\n return remoteCallback;\n } else {\n remoteCallback = async function () {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\n\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === "object" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n return me._connection.emit({\n type: "callback",\n target_id: targetId,\n id: cid,\n args: args,\n with_kwargs: withKwargs\n }, transferables);\n };\n\n return remoteCallback;\n }\n }\n\n reset() {\n this._event_handlers = {};\n this._once_handlers = {};\n this._remote_interface = null;\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n }\n /**\n * Sends the notification message and breaks the connection\n */\n\n\n disconnect() {\n this._connection.emit({\n type: "disconnect"\n });\n\n this.reset();\n setTimeout(() => {\n this._connection.disconnect();\n }, 2000);\n }\n\n}\n/**\n * ReferenceStore is a special object which stores other objects\n * and provides the references (number) instead. This reference\n * may then be sent over a json-based communication channel (IPC\n * to another Node.js process or a message to the Worker). Other\n * site may then provide the reference in the responce message\n * implying the given object should be activated.\n *\n * Primary usage for the ReferenceStore is a storage for the\n * callbacks, which therefore makes it possible to initiate a\n * callback execution by the opposite site (which normally cannot\n * directly execute functions over the communication channel).\n *\n * Each stored object can only be fetched once and is not\n * available for the second time. Each stored object must be\n * fetched, since otherwise it will remain stored forever and\n * consume memory.\n *\n * Stored object indeces are simply the numbers, which are however\n * released along with the objects, and are later reused again (in\n * order to postpone the overflow, which should not likely happen,\n * but anyway).\n */\n\nclass ReferenceStore {\n constructor() {\n this._store = {}; // stored object\n\n this._indices = [0]; // smallest available indices\n\n this._readyHandler = function () {};\n\n this._busyHandler = function () {};\n\n this._readyHandler();\n }\n /**\n * call handler when the store is empty\n *\n * @param {FUNCTION} id of a handler\n */\n\n\n onReady(readyHandler) {\n this._readyHandler = readyHandler || function () {};\n }\n /**\n * call handler when the store is not empty\n *\n * @param {FUNCTION} id of a handler\n */\n\n\n onBusy(busyHandler) {\n this._busyHandler = busyHandler || function () {};\n }\n /**\n * get the length of the store\n *\n */\n\n\n getStack() {\n return Object.keys(this._store).length;\n }\n /**\n * @function _genId() generates the new reference id\n *\n * @returns {Number} smallest available id and reserves it\n */\n\n\n _genId() {\n let id;\n\n if (this._indices.length === 1) {\n id = this._indices[0]++;\n } else {\n id = this._indices.shift();\n }\n\n return id;\n }\n /**\n * Releases the given reference id so that it will be available by\n * another object stored\n *\n * @param {Number} id to release\n */\n\n\n _releaseId(id) {\n for (let i = 0; i < this._indices.length; i++) {\n if (id < this._indices[i]) {\n this._indices.splice(i, 0, id);\n\n break;\n }\n } // cleaning-up the sequence tail\n\n\n for (let i = this._indices.length - 1; i >= 0; i--) {\n if (this._indices[i] - 1 === this._indices[i - 1]) {\n this._indices.pop();\n } else {\n break;\n }\n }\n }\n /**\n * Stores the given object and returns the refernce id instead\n *\n * @param {Object} obj to store\n *\n * @returns {Number} reference id of the stored object\n */\n\n\n put(obj) {\n if (this._busyHandler && Object.keys(this._store).length === 0) {\n this._busyHandler();\n }\n\n const id = this._genId();\n\n this._store[id] = obj;\n return id;\n }\n /**\n * Retrieves previously stored object and releases its reference\n *\n * @param {Number} id of an object to retrieve\n */\n\n\n fetch(id) {\n const obj = this._store[id];\n\n if (obj && !obj.__remote_method) {\n delete this._store[id];\n\n this._releaseId(id);\n\n if (this._readyHandler && Object.keys(this._store).length === 0) {\n this._readyHandler();\n }\n }\n\n if (obj && obj.__promise_pair) {\n this.fetch(obj.__promise_pair);\n }\n\n return obj;\n }\n\n}\n\n/***/ }),\n\n/***/ "./src/utils.js":\n/*!**********************!*\\\n !*** ./src/utils.js ***!\n \\**********************/\n/*! exports provided: randId, dtypeToTypedArray, loadRequirementsInWindow, loadRequirementsInWebworker, loadRequirements, normalizeConfig, typedArrayToDtypeMapping, typedArrayToDtype, cacheRequirements, setupServiceWorker, urlJoin, MessageEmitter */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "randId", function() { return randId; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dtypeToTypedArray", function() { return dtypeToTypedArray; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadRequirementsInWindow", function() { return loadRequirementsInWindow; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadRequirementsInWebworker", function() { return loadRequirementsInWebworker; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadRequirements", function() { return loadRequirements; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalizeConfig", function() { return normalizeConfig; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "typedArrayToDtypeMapping", function() { return typedArrayToDtypeMapping; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "typedArrayToDtype", function() { return typedArrayToDtype; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cacheRequirements", function() { return cacheRequirements; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupServiceWorker", function() { return setupServiceWorker; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "urlJoin", function() { return urlJoin; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MessageEmitter", function() { return MessageEmitter; });\nfunction randId() {\n return Math.random().toString(36).substr(2, 10) + new Date().getTime();\n}\nconst dtypeToTypedArray = {\n int8: Int8Array,\n int16: Int16Array,\n int32: Int32Array,\n uint8: Uint8Array,\n uint16: Uint16Array,\n uint32: Uint32Array,\n float32: Float32Array,\n float64: Float64Array,\n array: Array\n};\nasync function loadRequirementsInWindow(requirements) {\n function _importScript(url) {\n //url is URL of external file, implementationCode is the code\n //to be called from the file, location is the location to\n //insert the <script> element\n return new Promise((resolve, reject) => {\n var scriptTag = document.createElement("script");\n scriptTag.src = url;\n scriptTag.type = "text/javascript";\n scriptTag.onload = resolve;\n\n scriptTag.onreadystatechange = function () {\n if (this.readyState === "loaded" || this.readyState === "complete") {\n resolve();\n }\n };\n\n scriptTag.onerror = reject;\n document.head.appendChild(scriptTag);\n });\n } // support importScripts outside web worker\n\n\n async function importScripts() {\n var args = Array.prototype.slice.call(arguments),\n len = args.length,\n i = 0;\n\n for (; i < len; i++) {\n await _importScript(args[i]);\n }\n }\n\n if (requirements && (Array.isArray(requirements) || typeof requirements === "string")) {\n try {\n var link_node;\n requirements = typeof requirements === "string" ? [requirements] : requirements;\n\n if (Array.isArray(requirements)) {\n for (var i = 0; i < requirements.length; i++) {\n if (requirements[i].toLowerCase().endsWith(".css") || requirements[i].startsWith("css:")) {\n if (requirements[i].startsWith("css:")) {\n requirements[i] = requirements[i].slice(4);\n }\n\n link_node = document.createElement("link");\n link_node.rel = "stylesheet";\n link_node.href = requirements[i];\n document.head.appendChild(link_node);\n } else if (requirements[i].toLowerCase().endsWith(".mjs") || requirements[i].startsWith("mjs:")) {\n // import esmodule\n if (requirements[i].startsWith("mjs:")) {\n requirements[i] = requirements[i].slice(4);\n }\n\n await import(\n /* webpackIgnore: true */\n requirements[i]);\n } else if (requirements[i].toLowerCase().endsWith(".js") || requirements[i].startsWith("js:")) {\n if (requirements[i].startsWith("js:")) {\n requirements[i] = requirements[i].slice(3);\n }\n\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith("http")) {\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith("cache:")) {//ignore cache\n } else {\n console.log("Unprocessed requirements url: " + requirements[i]);\n }\n }\n } else {\n throw "unsupported requirements definition";\n }\n } catch (e) {\n throw "failed to import required scripts: " + requirements.toString();\n }\n }\n}\nasync function loadRequirementsInWebworker(requirements) {\n if (requirements && (Array.isArray(requirements) || typeof requirements === "string")) {\n try {\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n\n for (var i = 0; i < requirements.length; i++) {\n if (requirements[i].toLowerCase().endsWith(".css") || requirements[i].startsWith("css:")) {\n throw "unable to import css in a webworker";\n } else if (requirements[i].toLowerCase().endsWith(".js") || requirements[i].startsWith("js:")) {\n if (requirements[i].startsWith("js:")) {\n requirements[i] = requirements[i].slice(3);\n }\n\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith("http")) {\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith("cache:")) {//ignore cache\n } else {\n console.log("Unprocessed requirements url: " + requirements[i]);\n }\n }\n } catch (e) {\n throw "failed to import required scripts: " + requirements.toString();\n }\n }\n}\nfunction loadRequirements(requirements) {\n if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {\n return loadRequirementsInWebworker(requirements);\n } else {\n return loadRequirementsInWindow(requirements);\n }\n}\nfunction normalizeConfig(config) {\n config.version = config.version || "0.1.0";\n config.description = config.description || `[TODO: add description for ${config.name} ]`;\n config.type = config.type || "rpc-window";\n config.id = config.id || randId();\n config.target_origin = config.target_origin || "*";\n config.allow_execution = config.allow_execution || false; // remove functions\n\n config = Object.keys(config).reduce((p, c) => {\n if (typeof config[c] !== "function") p[c] = config[c];\n return p;\n }, {});\n return config;\n}\nconst typedArrayToDtypeMapping = {\n Int8Array: "int8",\n Int16Array: "int16",\n Int32Array: "int32",\n Uint8Array: "uint8",\n Uint16Array: "uint16",\n Uint32Array: "uint32",\n Float32Array: "float32",\n Float64Array: "float64",\n Array: "array"\n};\nconst typedArrayToDtypeKeys = [];\n\nfor (const arrType of Object.keys(typedArrayToDtypeMapping)) {\n typedArrayToDtypeKeys.push(eval(arrType));\n}\n\nfunction typedArrayToDtype(obj) {\n let dtype = typedArrayToDtypeMapping[obj.constructor.name];\n\n if (!dtype) {\n const pt = Object.getPrototypeOf(obj);\n\n for (const arrType of typedArrayToDtypeKeys) {\n if (pt instanceof arrType) {\n dtype = typedArrayToDtypeMapping[arrType.name];\n break;\n }\n }\n }\n\n return dtype;\n}\n\nfunction cacheUrlInServiceWorker(url) {\n return new Promise(function (resolve, reject) {\n const message = {\n command: "add",\n url: url\n };\n\n if (!navigator.serviceWorker || !navigator.serviceWorker.register) {\n reject("Service worker is not supported.");\n return;\n }\n\n const messageChannel = new MessageChannel();\n\n messageChannel.port1.onmessage = function (event) {\n if (event.data && event.data.error) {\n reject(event.data.error);\n } else {\n resolve(event.data && event.data.result);\n }\n };\n\n if (navigator.serviceWorker && navigator.serviceWorker.controller) {\n navigator.serviceWorker.controller.postMessage(message, [messageChannel.port2]);\n } else {\n reject("Service worker controller is not available");\n }\n });\n}\n\nasync function cacheRequirements(requirements) {\n requirements = requirements || [];\n\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n\n for (let req of requirements) {\n //remove prefix\n if (req.startsWith("js:")) req = req.slice(3);\n if (req.startsWith("css:")) req = req.slice(4);\n if (req.startsWith("cache:")) req = req.slice(6);\n if (!req.startsWith("http")) continue;\n await cacheUrlInServiceWorker(req).catch(e => {\n console.error(e);\n });\n }\n}\nfunction setupServiceWorker(baseUrl, targetOrigin, cacheCallback) {\n // register service worker for offline access\n if ("serviceWorker" in navigator) {\n baseUrl = baseUrl || "/";\n navigator.serviceWorker.register(baseUrl + "plugin-service-worker.js").then(function (registration) {\n // Registration was successful\n console.log("ServiceWorker registration successful with scope: ", registration.scope);\n }, function (err) {\n // registration failed :(\n console.log("ServiceWorker registration failed: ", err);\n });\n targetOrigin = targetOrigin || "*";\n cacheCallback = cacheCallback || cacheRequirements;\n\n if (cacheCallback && typeof cacheCallback !== "function") {\n throw new Error("config.cache_requirements must be a function");\n }\n\n window.addEventListener("message", function (e) {\n if (targetOrigin === "*" || e.origin === targetOrigin) {\n const m = e.data;\n\n if (m.type === "cacheRequirements") {\n cacheCallback(m.requirements);\n }\n }\n });\n }\n} //#Source https://bit.ly/2neWfJ2\n\nfunction urlJoin(...args) {\n return args.join("/").replace(/[\\/]+/g, "/").replace(/^(.+):\\//, "$1://").replace(/^file:/, "file:/").replace(/\\/(\\?|&|#[^!])/g, "$1").replace(/\\?/g, "&").replace("&", "?");\n}\nclass MessageEmitter {\n constructor(debug) {\n this._event_handlers = {};\n this._once_handlers = {};\n this._debug = debug;\n }\n\n emit() {\n throw new Error("emit is not implemented");\n }\n\n on(event, handler) {\n if (!this._event_handlers[event]) {\n this._event_handlers[event] = [];\n }\n\n this._event_handlers[event].push(handler);\n }\n\n once(event, handler) {\n handler.___event_run_once = true;\n this.on(event, handler);\n }\n\n off(event, handler) {\n if (!event && !handler) {\n // remove all events handlers\n this._event_handlers = {};\n } else if (event && !handler) {\n // remove all hanlders for the event\n if (this._event_handlers[event]) this._event_handlers[event] = [];\n } else {\n // remove a specific handler\n if (this._event_handlers[event]) {\n const idx = this._event_handlers[event].indexOf(handler);\n\n if (idx >= 0) {\n this._event_handlers[event].splice(idx, 1);\n }\n }\n }\n }\n\n _fire(event, data) {\n if (this._event_handlers[event]) {\n var i = this._event_handlers[event].length;\n\n while (i--) {\n const handler = this._event_handlers[event][i];\n\n try {\n handler(data);\n } catch (e) {\n console.error(e);\n } finally {\n if (handler.___event_run_once) {\n this._event_handlers[event].splice(i, 1);\n }\n }\n }\n } else {\n if (this._debug) {\n console.warn("unhandled event", event, data);\n }\n }\n }\n\n}\n\n/***/ })\n\n/******/ });\n//# sourceMappingURL=plugin.webworker.js.map',null)}},"./src/pluginCore.js":
/*!***************************!*\
!*** ./src/pluginCore.js ***!
\***************************/
/*! exports provided: connectRPC */function(e,t,n){"use strict";n.r(t),n.d(t,"connectRPC",(function(){return i}));var r=n(/*! ./rpc.js */"./src/rpc.js");function i(e,t){t=t||{};const n={},i=new r.RPC(e,t,n);i.on("getInterface",(function(){a()})),i.on("remoteReady",(function(){const e=i.getRemote()||{};e.registerCodec=function(e){if(!e.name||!e.encoder&&!e.decoder)throw new Error("Invalid codec format, please make sure you provide a name, type, encoder and decoder.");if(e.type)for(let t of Object.keys(n))n[t].type!==e.type&&t!==e.name||(delete n[t],console.warn("Remove duplicated codec: "+t));n[e.name]=e},e.init=function(e){i.setInterface({setup(){}},e)},e.disposeObject=function(e){i.disposeObject(e)},e.export=function(e,t){i.setInterface(e,t)},e.onLoad=function(e){e=c(e),o?e():s.push(e)},e.dispose=function(e){i.disconnect()},e._rpc=i,"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?(self.api=e,self.postMessage({type:"imjoy_remote_api_ready"}),self.dispatchEvent(new CustomEvent("imjoy_remote_api_ready",{detail:e}))):window.dispatchEvent(new CustomEvent("imjoy_remote_api_ready",{detail:e}))}));let o=!1;const s=[],a=function(){if(!o){let e;for(o=!0;e=s.pop();)e()}},c=function(e){const t=typeof e;if("function"!==t)throw new Error("A function may only be subsribed to the event, "+t+" was provided instead");return e};return i}},"./src/pluginIframe.js":
/*!*****************************!*\
!*** ./src/pluginIframe.js ***!
\*****************************/
/*! exports provided: Connection, default */function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"Connection",(function(){return Connection})),__webpack_require__.d(__webpack_exports__,"default",(function(){return setupIframe}));var _pluginCore_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(/*! ./pluginCore.js */"./src/pluginCore.js"),_rpc_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(/*! ./rpc.js */"./src/rpc.js"),_utils_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(/*! ./utils.js */"./src/utils.js");function _htmlToElement(e){var t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild}const _inWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;async function executeEsModule(e){const t="data:text/javascript;charset=utf-8,"+encodeURIComponent(e);await import(t)}class Connection extends _utils_js__WEBPACK_IMPORTED_MODULE_2__.MessageEmitter{constructor(e){super(e&&e.debug),this.config=e||{},this.peer_id=Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__.randId)()}connect(){this.config.target_origin=this.config.target_origin||"*",this.config.broadcastChannel?this.broadcastChannel=new BroadcastChannel(this.config.broadcastChannel):this.broadcastChannel=null,this.broadcastChannel?this.broadcastChannel.addEventListener("message",this):globalThis.addEventListener("message",this),this.emit({type:"initialized",config:this.config,origin:globalThis.location.origin,peer_id:this.peer_id}),this._fire("connected")}handleEvent(e){"message"!==e.type||!this.broadcastChannel&&"*"!==this.config.target_origin&&e.origin&&e.origin!==this.config.target_origin||(e.data.peer_id===this.peer_id?this._fire(e.data.type,e.data):this.config.debug&&console.log(`connection peer id mismatch ${e.data.peer_id} !== ${this.peer_id}`))}disconnect(){this._fire("beforeDisconnect"),globalThis.removeEventListener("message",this),this._fire("disconnected")}emit(e){let t;this.broadcastChannel?this.broadcastChannel.postMessage(e):e.__transferables__?(t=e.__transferables__,delete e.__transferables__):_inWebWorker?self.postMessage(e,t):parent.postMessage(e,this.config.target_origin,t)}async execute(code){try{if("requirements"===code.type)await Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__.loadRequirementsInWindow)(code.requirements);else if("script"===code.type)if(code.src){var script_node=document.createElement("script");script_node.setAttribute("type",code.attrs.type),script_node.setAttribute("src",code.src),document.head.appendChild(script_node)}else if(code.content&&"javascript"===code.attrs.lang)"module"===code.attrs.type?await executeEsModule(code.content):eval(code.content);else{var node=document.createElement("script");for(let e in code.attrs)node.setAttribute(e,code.attrs[e]);node.appendChild(document.createTextNode(code.content)),document.body.appendChild(node)}else if("style"===code.type){const e=document.createElement("style");code.src&&(e.src=code.src),e.innerHTML=code.content,document.head.appendChild(e)}else if("link"===code.type){const e=document.createElement("link");code.rel&&(e.rel=code.rel),code.href&&(e.href=code.href),code.attrs&&code.attrs.type&&(e.type=code.attrs.type),document.head.appendChild(e)}else{if("html"!==code.type)throw"unsupported code type.";document.body.appendChild(_htmlToElement(code.content))}_inWebWorker?self.postMessage({type:"executed"}):parent.postMessage({type:"executed"},this.config.target_origin)}catch(e){console.error("failed to execute scripts: ",code,e),_inWebWorker?self.postMessage({type:"executed",error:e.stack||String(e)}):parent.postMessage({type:"executed",error:e.stack||String(e)},this.config.target_origin)}}}function setupIframe(e){(e=e||{}).dedicated_thread=!1,e.lang="javascript",e.api_version=_rpc_js__WEBPACK_IMPORTED_MODULE_1__.API_VERSION;const t=new Connection(e);Object(_pluginCore_js__WEBPACK_IMPORTED_MODULE_0__.connectRPC)(t,e),t.connect()}},"./src/rpc.js":
/*!********************!*\
!*** ./src/rpc.js ***!
\********************/
/*! exports provided: API_VERSION, RPC */function(e,t,n){"use strict";n.r(t),n.d(t,"API_VERSION",(function(){return i})),n.d(t,"RPC",(function(){return c}));var r=n(/*! ./utils.js */"./src/utils.js");const i="0.2.3",o=Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array)).constructor;function s(e,t){const n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}function a(e,t){if(!t)throw new Error("undefined index");return"string"==typeof t?a(e,t.split(".")):0===t.length?e:a(e[t[0]],t.slice(1))}class c extends r.MessageEmitter{constructor(e,t,n){super(t&&t.debug),this._connection=e,this.config=t||{},this._codecs=n||{},this._object_store={},this._method_weakmap=new WeakMap,this._object_weakmap=new WeakMap,this._local_api=null,this._remote_set=!1;const r=this.config.name;this._connection.execute=this._connection.execute||function(){throw new Error(`connection.execute not implemented (in "${r}")`)},this._store=new u,this._method_refs=new u,this._method_refs.onReady(()=>{this._fire("remoteIdle")}),this._method_refs.onBusy(()=>{this._fire("remoteBusy")}),this._setupMessageHanlders()}init(){this._connection.emit({type:"initialized",config:this.config,peer_id:this._connection.peer_id})}setConfig(e){if(e)for(const t of Object.keys(e))this.config[t]=e[t]}getRemoteCallStack(){return this._method_refs.getStack()}getRemote(){return this._remote_interface}setInterface(e,t){if(t=t||{},this.config.name=t.name||this.config.name,this.config.description=t.description||this.config.description,this.config.forwarding_functions)for(let t of this.config.forwarding_functions){const n=this._remote_interface;n[t]&&(e.constructor===Object?e[t]||(e[t]=(...e)=>{n[t](...e)}):e.constructor.constructor===Function&&(e.constructor.prototype[t]||(e.constructor.prototype[t]=(...e)=>{n[t](...e)})))}return this._local_api=e,this._remote_set?this.sendInterface():this._fire("interfaceAvailable"),new Promise(e=>{this.once("interfaceSetAsRemote",e)})}sendInterface(){if(!this._local_api)throw new Error("interface is not set.");this._encode(this._local_api,!0).then(e=>{this._connection.emit({type:"setInterface",api:e})})}_disposeObject(e){if(!this._object_store[e])throw new Error(`Object (id=${e}) not found.`);delete this._object_store[e]}disposeObject(e){return new Promise((t,n)=>{if(!this._object_weakmap.has(e))throw new Error("Invalid object");{const r=this._object_weakmap.get(e);this._connection.once("disposed",e=>{e.error?n(new Error(e.error)):t()}),this._connection.emit({type:"disposeObject",object_id:r})}})}_setupMessageHanlders(){this._connection.on("init",this.init),this._connection.on("execute",e=>{Promise.resolve(this._connection.execute(e.code)).then(()=>{this._connection.emit({type:"executed"})}).catch(e=>{console.error(e),this._connection.emit({type:"executed",error:String(e)})})}),this._connection.on("method",async e=>{let t,n,r,i,o,s;try{e.promise&&([t,n]=await this._unwrap(e.promise,!1));const c=this._object_store[e.object_id];if(r=a(c,e.name),e.name.includes(".")){const t=e.name.split(".");i=a(c,t.slice(0,t.length-1).join("."))}else i=c;o=await this._unwrap(e.args,!0),e.promise?(s=r.apply(i,o),s instanceof Promise||r.constructor&&"AsyncFunction"===r.constructor.name?s.then(t).catch(n):t(s)):r.apply(i,o)}catch(e){console.error(this.config.name,e),n&&n(e)}}),this._connection.on("callback",async e=>{let t,n,r,i,o;try{if(e.promise&&([t,n]=await this._unwrap(e.promise,!1)),e.promise){if(r=this._store.fetch(e.id),i=await this._unwrap(e.args,!0),!r)throw new Error("Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");o=r.apply(null,i),o instanceof Promise||r.constructor&&"AsyncFunction"===r.constructor.name?o.then(t).catch(n):t(o)}else{if(r=this._store.fetch(e.id),i=await this._unwrap(e.args,!0),!r)throw new Error("Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");r.apply(null,i)}}catch(e){console.error(this.config.name,e),n&&n(e)}}),this._connection.on("disposeObject",e=>{try{this._disposeObject(e.object_id),this._connection.emit({type:"disposed"})}catch(e){console.error(e),this._connection.emit({type:"disposed",error:String(e)})}}),this._connection.on("setInterface",e=>{this._setRemoteInterface(e.api)}),this._connection.on("getInterface",()=>{this._fire("getInterface"),this._local_api?this.sendInterface():this.once("interfaceAvailable",()=>{this.sendInterface()})}),this._connection.on("interfaceSetAsRemote",()=>{this._remote_set=!0,this._fire("interfaceSetAsRemote")}),this._connection.on("disconnect",()=>{this._fire("beforeDisconnect"),this._connection.disconnect(),this._fire("disconnected")})}requestRemote(){this._connection.emit({type:"getInterface"})}_ndarray(e,t,n){const i=Object(r.typedArrayToDtype)(e);if(n&&n!==i)throw"dtype doesn't match the type of the array: "+i+" != "+n;return t=t||[e.length],{_rtype:"ndarray",_rvalue:e.buffer,_rshape:t,_rdtype:i}}_setRemoteInterface(e){this._decode(e).then(e=>{if(this._remote_interface){for(let e in this._remote_interface)delete this._remote_interface[e];Object.assign(this._remote_interface,e)}else this._remote_interface=e;this._fire("remoteReady"),this._reportRemoteSet()})}_genRemoteMethod(e,t,n){const r=this,i=function(){return new Promise(async(i,o)=>{let s=null;try{s=r._method_refs.put(n?n+"/"+t:t);const a=function(){return null!==s&&r._method_refs.fetch(s),i.apply(this,arguments)},c=function(){return null!==s&&r._method_refs.fetch(s),o.apply(this,arguments)},u=await r._wrap([a,c]);a.__promise_pair=u[1]._rvalue,c.__promise_pair=u[0]._rvalue;let l=Array.prototype.slice.call(arguments);const h=l.length,d=h>0&&"object"==typeof l[h-1]&&null!==l[h-1]&&l[h-1]._rkwargs;d&&delete l[h-1]._rkwargs,l="register"===t||"registerService"===t||"register_service"===t||"export"===t||"on"===t?await r._wrap(l,!0):await r._wrap(l);const p=l.__transferables__;p&&delete l.__transferables__,r._connection.emit({type:"method",target_id:e,name:t,object_id:n,args:l,promise:u,with_kwargs:d},p)}catch(e){s&&r._method_refs.fetch(s),o(`Failed to exectue remote method (interface: ${n||r.id}, method: ${t}), error: ${e}`)}})};return i.__remote_method=!0,i}_reportRemoteSet(){this._connection.emit({type:"interfaceSetAsRemote"})}async _encode(e,t,n){const i=typeof e;if("number"===i||"string"===i||"boolean"===i||null==e||e instanceof ArrayBuffer)return e;let s;if("function"==typeof e){if(t){if(!n)throw new Error("objectId is not specified.");s={_rtype:"interface",_rtarget_id:this._connection.peer_id,_rintf:n,_rvalue:t},this._method_weakmap.set(e,s)}else if(this._method_weakmap.has(e))s=this._method_weakmap.get(e);else{const t=this._store.put(e);s={_rtype:"callback",_rtarget_id:this._connection.peer_id,_rname:e.constructor&&e.constructor.name||t,_rvalue:t}}return s}if(e.constructor instanceof Object&&e._rtype){if(e._rintf){const r=e._rtype;delete e._rtype,s=await this._encode(e,t,n),s._rtype=r}else s=e;return s}const a=[],c=e._transfer,u=Array.isArray(e);for(let r of Object.keys(this._codecs)){const i=this._codecs[r];if(i.encoder&&e instanceof i.type){let r=await Promise.resolve(i.encoder(e));if(r&&!r._rtype&&(r._rtype=i.name),r&&r._rintf){const e=r._rtype;delete r._rtype,r=await this._encode(r,t,n),r._rtype=e}return s=r,s}}if("undefined"!=typeof tf&&tf.Tensor&&e instanceof tf.Tensor){const t=e.dataSync();(e._transfer||c)&&(a.push(t.buffer),delete e._transfer),s={_rtype:"ndarray",_rvalue:t.buffer,_rshape:e.shape,_rdtype:e.dtype}}else if("undefined"!=typeof nj&&nj.NdArray&&e instanceof nj.NdArray){const t=Object(r.typedArrayToDtype)(e.selection.data);(e._transfer||c)&&(a.push(e.selection.data.buffer),delete e._transfer),s={_rtype:"ndarray",_rvalue:e.selection.data.buffer,_rshape:e.shape,_rdtype:t}}else if(e instanceof Error)console.error(e),s={_rtype:"error",_rvalue:e.toString()};else if("undefined"!=typeof File&&e instanceof File)s={_rtype:"file",_rvalue:e,_rpath:e._path||e.webkitRelativePath};else if(e!==Object(e)||e instanceof Boolean||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof ImageData||"undefined"!=typeof FileList&&e instanceof FileList||"undefined"!=typeof FileSystemDirectoryHandle&&e instanceof FileSystemDirectoryHandle||"undefined"!=typeof FileSystemFileHandle&&e instanceof FileSystemFileHandle||"undefined"!=typeof FileSystemHandle&&e instanceof FileSystemHandle||"undefined"!=typeof FileSystemWritableFileStream&&e instanceof FileSystemWritableFileStream)s=e;else if("undefined"!=typeof File&&e instanceof File)s={_rtype:"file",_rname:e.name,_rmime:e.type,_rvalue:e,_rpath:e._path||e.webkitRelativePath};else if(e instanceof Blob)s={_rtype:"blob",_rvalue:e};else if(e instanceof o){(e._transfer||c)&&(a.push(e.buffer),delete e._transfer);const t=Object(r.typedArrayToDtype)(e);s={_rtype:"typedarray",_rvalue:e.buffer,_rdtype:t}}else if(e instanceof DataView)(e._transfer||c)&&(a.push(e.buffer),delete e._transfer),s={_rtype:"memoryview",_rvalue:e.buffer};else if(e instanceof Set)s={_rtype:"set",_rvalue:await this._encode(Array.from(e),t)};else if(e instanceof Map)s={_rtype:"orderedmap",_rvalue:await this._encode(Array.from(e),t)};else if(e.constructor instanceof Object||Array.isArray(e)){let i;if(s=u?[]:{},e.constructor===Object||Array.isArray(e))i=Object.keys(e);else{if(e.constructor===Function)throw new Error("Please instantiate the class before exportting it.");if(e.constructor.constructor!==Function)throw Error("Unsupported interface type");i=Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)),t=!0}let o=!1;if(e._rintf||t){n||(n="string"==typeof e._rintf&&e._rintf.length>0?e._rintf:Object(r.randId)(),this._object_store[n]&&console.warn("Overwritting interface object with the same id: "+n),this._object_store[n]=e);for(let r of i)"constructor"!==r&&(r.startsWith("_")||(s[r]=await this._encode(e[r],"string"==typeof t?t+"."+r:r,n),"function"==typeof e[r]&&(o=!0)));o&&(s._rintf=n),e.on&&"function"==typeof e.on&&e.on("close",()=>{delete this._object_store[n]})}else for(let t of i)["hasOwnProperty","constructor"].includes(t)||(s[t]=await this._encode(e[t]))}else{if("object"!=typeof e)throw"imjoy-rpc: Unsupported data type:"+e;{const t=Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)),n=Object(r.randId)();for(let n of t)["hasOwnProperty","constructor"].includes(n)||(s[n]=await this._encode(e[n],n,s));s._rintf=n}}if(a.length>0&&(s.__transferables__=a),!s)throw new Error("Failed to encode object");return s}async _decode(e,t){if(!e)return e;let n;if(e._rtype)if(this._codecs[e._rtype]&&this._codecs[e._rtype].decoder){if(e._rintf){const n=e._rtype;delete e._rtype,(e=await this._decode(e,t))._rtype=n}n=await Promise.resolve(this._codecs[e._rtype].decoder(e))}else if("callback"===e._rtype)n=this._genRemoteCallback(e._rtarget_id,e._rvalue,t);else if("interface"===e._rtype)n=this._genRemoteMethod(e._rtarget_id,e._rvalue,e._rintf);else if("ndarray"===e._rtype)if("undefined"!=typeof nj&&nj.array)Array.isArray(e._rvalue)&&(e._rvalue=e._rvalue.reduce(s)),n=nj.array(new Uint8(e._rvalue),e._rdtype).reshape(e._rshape);else if("undefined"!=typeof tf&&tf.Tensor){Array.isArray(e._rvalue)&&(e._rvalue=e._rvalue.reduce(s));const t=r.dtypeToTypedArray[e._rdtype];n=tf.tensor(new t(e._rvalue),e._rshape,e._rdtype)}else n=e;else if("error"===e._rtype)n=new Error(e._rvalue);else if("file"===e._rtype)e._rvalue instanceof File?(n=e._rvalue,n._path=e._rpath):(n=new File([e._rvalue],e._rname,{type:e._rmime}),n._path=e._rpath);else if("typedarray"===e._rtype){const t=r.dtypeToTypedArray[e._rdtype];if(!t)throw new Error("unsupported dtype: "+e._rdtype);n=new t(e._rvalue)}else if("memoryview"===e._rtype)n=new DataView(e._rvalue);else if("blob"===e._rtype)n=e._rvalue instanceof Blob?e._rvalue:new Blob([e._rvalue],{type:e._rmime});else if("orderedmap"===e._rtype)n=new Map(await this._decode(e._rvalue,t));else if("set"===e._rtype)n=new Set(await this._decode(e._rvalue,t));else if(e._rintf){const r=e._rtype;delete e._rtype,n=await this._decode(e,t),n._rtype=r}else n=e;else if(e.constructor===Object||Array.isArray(e)){const r=Array.isArray(e);n=r?[]:{};for(let i of Object.keys(e))if(r||e.hasOwnProperty(i)){const r=e[i];n[i]=await this._decode(r,t)}}else n=e;if(void 0===n)throw new Error("Failed to decode object");return e._rintf&&this._object_weakmap.set(n,e._rintf),n}async _wrap(e,t){return await this._encode(e,t)}async _unwrap(e,t){return await this._decode(e,t)}_genRemoteCallback(e,t,n){const r=this;let i;return n?(i=function(){return new Promise(async(n,i)=>{const o=await r._wrap(Array.prototype.slice.call(arguments)),s=o.length,a=s>0&&"object"==typeof o[s-1]&&null!==o[s-1]&&o[s-1]._rkwargs;a&&delete o[s-1]._rkwargs;const c=o.__transferables__;c&&delete o.__transferables__;const u=await r._wrap([n,i]);n.__promise_pair=u[1]._rvalue,i.__promise_pair=u[0]._rvalue;try{r._connection.emit({type:"callback",target_id:e,id:t,args:o,promise:u,with_kwargs:a},c)}catch(e){i(`Failed to exectue remote callback ( id: ${t}).`)}})},i):(i=async function(){const n=await r._wrap(Array.prototype.slice.call(arguments)),i=n.length,o=i>0&&"object"==typeof n[i-1]&&null!==n[i-1]&&n[i-1]._rkwargs;o&&delete n[i-1]._rkwargs;const s=n.__transferables__;return s&&delete n.__transferables__,r._connection.emit({type:"callback",target_id:e,id:t,args:n,with_kwargs:o},s)},i)}reset(){this._event_handlers={},this._once_handlers={},this._remote_interface=null,this._object_store={},this._method_weakmap=new WeakMap,this._object_weakmap=new WeakMap,this._local_api=null,this._store=new u,this._method_refs=new u}disconnect(){this._connection.emit({type:"disconnect"}),this.reset(),setTimeout(()=>{this._connection.disconnect()},2e3)}}class u{constructor(){this._store={},this._indices=[0],this._readyHandler=function(){},this._busyHandler=function(){},this._readyHandler()}onReady(e){this._readyHandler=e||function(){}}onBusy(e){this._busyHandler=e||function(){}}getStack(){return Object.keys(this._store).length}_genId(){let e;return e=1===this._indices.length?this._indices[0]++:this._indices.shift(),e}_releaseId(e){for(let t=0;t<this._indices.length;t++)if(e<this._indices[t]){this._indices.splice(t,0,e);break}for(let e=this._indices.length-1;e>=0&&this._indices[e]-1===this._indices[e-1];e--)this._indices.pop()}put(e){this._busyHandler&&0===Object.keys(this._store).length&&this._busyHandler();const t=this._genId();return this._store[t]=e,t}fetch(e){const t=this._store[e];return t&&!t.__remote_method&&(delete this._store[e],this._releaseId(e),this._readyHandler&&0===Object.keys(this._store).length&&this._readyHandler()),t&&t.__promise_pair&&this.fetch(t.__promise_pair),t}}},"./src/utils.js":
/*!**********************!*\
!*** ./src/utils.js ***!
\**********************/
/*! exports provided: randId, dtypeToTypedArray, loadRequirementsInWindow, loadRequirementsInWebworker, loadRequirements, normalizeConfig, typedArrayToDtypeMapping, typedArrayToDtype, cacheRequirements, setupServiceWorker, urlJoin, MessageEmitter */function(module,__webpack_exports__,__webpack_require__){"use strict";function randId(){return Math.random().toString(36).substr(2,10)+(new Date).getTime()}__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"randId",(function(){return randId})),__webpack_require__.d(__webpack_exports__,"dtypeToTypedArray",(function(){return dtypeToTypedArray})),__webpack_require__.d(__webpack_exports__,"loadRequirementsInWindow",(function(){return loadRequirementsInWindow})),__webpack_require__.d(__webpack_exports__,"loadRequirementsInWebworker",(function(){return loadRequirementsInWebworker})),__webpack_require__.d(__webpack_exports__,"loadRequirements",(function(){return loadRequirements})),__webpack_require__.d(__webpack_exports__,"normalizeConfig",(function(){return normalizeConfig})),__webpack_require__.d(__webpack_exports__,"typedArrayToDtypeMapping",(function(){return typedArrayToDtypeMapping})),__webpack_require__.d(__webpack_exports__,"typedArrayToDtype",(function(){return typedArrayToDtype})),__webpack_require__.d(__webpack_exports__,"cacheRequirements",(function(){return cacheRequirements})),__webpack_require__.d(__webpack_exports__,"setupServiceWorker",(function(){return setupServiceWorker})),__webpack_require__.d(__webpack_exports__,"urlJoin",(function(){return urlJoin})),__webpack_require__.d(__webpack_exports__,"MessageEmitter",(function(){return MessageEmitter}));const dtypeToTypedArray={int8:Int8Array,int16:Int16Array,int32:Int32Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,float32:Float32Array,float64:Float64Array,array:Array};async function loadRequirementsInWindow(e){function t(e){return new Promise((t,n)=>{var r=document.createElement("script");r.src=e,r.type="text/javascript",r.onload=t,r.onreadystatechange=function(){"loaded"!==this.readyState&&"complete"!==this.readyState||t()},r.onerror=n,document.head.appendChild(r)})}async function n(){for(var e=Array.prototype.slice.call(arguments),n=e.length,r=0;r<n;r++)await t(e[r])}if(e&&(Array.isArray(e)||"string"==typeof e))try{var r;if(e="string"==typeof e?[e]:e,!Array.isArray(e))throw"unsupported requirements definition";for(var i=0;i<e.length;i++)e[i].toLowerCase().endsWith(".css")||e[i].startsWith("css:")?(e[i].startsWith("css:")&&(e[i]=e[i].slice(4)),(r=document.createElement("link")).rel="stylesheet",r.href=e[i],document.head.appendChild(r)):e[i].toLowerCase().endsWith(".mjs")||e[i].startsWith("mjs:")?(e[i].startsWith("mjs:")&&(e[i]=e[i].slice(4)),await import(e[i])):e[i].toLowerCase().endsWith(".js")||e[i].startsWith("js:")?(e[i].startsWith("js:")&&(e[i]=e[i].slice(3)),await n(e[i])):e[i].startsWith("http")?await n(e[i]):e[i].startsWith("cache:")||console.log("Unprocessed requirements url: "+e[i])}catch(t){throw"failed to import required scripts: "+e.toString()}}async function loadRequirementsInWebworker(e){if(e&&(Array.isArray(e)||"string"==typeof e))try{Array.isArray(e)||(e=[e]);for(var t=0;t<e.length;t++){if(e[t].toLowerCase().endsWith(".css")||e[t].startsWith("css:"))throw"unable to import css in a webworker";e[t].toLowerCase().endsWith(".js")||e[t].startsWith("js:")?(e[t].startsWith("js:")&&(e[t]=e[t].slice(3)),importScripts(e[t])):e[t].startsWith("http")?importScripts(e[t]):e[t].startsWith("cache:")||console.log("Unprocessed requirements url: "+e[t])}}catch(t){throw"failed to import required scripts: "+e.toString()}}function loadRequirements(e){return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?loadRequirementsInWebworker(e):loadRequirementsInWindow(e)}function normalizeConfig(e){return e.version=e.version||"0.1.0",e.description=e.description||`[TODO: add description for ${e.name} ]`,e.type=e.type||"rpc-window",e.id=e.id||randId(),e.target_origin=e.target_origin||"*",e.allow_execution=e.allow_execution||!1,e=Object.keys(e).reduce((t,n)=>("function"!=typeof e[n]&&(t[n]=e[n]),t),{})}const typedArrayToDtypeMapping={Int8Array:"int8",Int16Array:"int16",Int32Array:"int32",Uint8Array:"uint8",Uint16Array:"uint16",Uint32Array:"uint32",Float32Array:"float32",Float64Array:"float64",Array:"array"},typedArrayToDtypeKeys=[];for(const arrType of Object.keys(typedArrayToDtypeMapping))typedArrayToDtypeKeys.push(eval(arrType));function typedArrayToDtype(e){let t=typedArrayToDtypeMapping[e.constructor.name];if(!t){const n=Object.getPrototypeOf(e);for(const e of typedArrayToDtypeKeys)if(n instanceof e){t=typedArrayToDtypeMapping[e.name];break}}return t}function cacheUrlInServiceWorker(e){return new Promise((function(t,n){const r={command:"add",url:e};if(!navigator.serviceWorker||!navigator.serviceWorker.register)return void n("Service worker is not supported.");const i=new MessageChannel;i.port1.onmessage=function(e){e.data&&e.data.error?n(e.data.error):t(e.data&&e.data.result)},navigator.serviceWorker&&navigator.serviceWorker.controller?navigator.serviceWorker.controller.postMessage(r,[i.port2]):n("Service worker controller is not available")}))}async function cacheRequirements(e){e=e||[],Array.isArray(e)||(e=[e]);for(let t of e)t.startsWith("js:")&&(t=t.slice(3)),t.startsWith("css:")&&(t=t.slice(4)),t.startsWith("cache:")&&(t=t.slice(6)),t.startsWith("http")&&await cacheUrlInServiceWorker(t).catch(e=>{console.error(e)})}function setupServiceWorker(e,t,n){if("serviceWorker"in navigator){if(e=e||"/",navigator.serviceWorker.register(e+"plugin-service-worker.js").then((function(e){console.log("ServiceWorker registration successful with scope: ",e.scope)}),(function(e){console.log("ServiceWorker registration failed: ",e)})),t=t||"*",(n=n||cacheRequirements)&&"function"!=typeof n)throw new Error("config.cache_requirements must be a function");window.addEventListener("message",(function(e){if("*"===t||e.origin===t){const t=e.data;"cacheRequirements"===t.type&&n(t.requirements)}}))}}function urlJoin(...e){return e.join("/").replace(/[\/]+/g,"/").replace(/^(.+):\//,"$1://").replace(/^file:/,"file:/").replace(/\/(\?|&|#[^!])/g,"$1").replace(/\?/g,"&").replace("&","?")}class MessageEmitter{constructor(e){this._event_handlers={},this._once_handlers={},this._debug=e}emit(){throw new Error("emit is not implemented")}on(e,t){this._event_handlers[e]||(this._event_handlers[e]=[]),this._event_handlers[e].push(t)}once(e,t){t.___event_run_once=!0,this.on(e,t)}off(e,t){if(e||t){if(e&&!t)this._event_handlers[e]&&(this._event_handlers[e]=[]);else if(this._event_handlers[e]){const n=this._event_handlers[e].indexOf(t);n>=0&&this._event_handlers[e].splice(n,1)}}else this._event_handlers={}}_fire(e,t){if(this._event_handlers[e])for(var n=this._event_handlers[e].length;n--;){const r=this._event_handlers[e][n];try{r(t)}catch(e){console.error(e)}finally{r.___event_run_once&&this._event_handlers[e].splice(n,1)}}else this._debug&&console.warn("unhandled event",e,t)}}}})},module.exports=factory()},function(module,exports,__webpack_require__){var factory;window,factory=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./src/socketIOMain.js")}({"./node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js":
/*!***********************************************************************************!*\
!*** ./node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js ***!
\***********************************************************************************/
/*! exports provided: decode, encode */function(e,t,n){"use strict";n.r(t),n.d(t,"decode",(function(){return a})),n.d(t,"encode",(function(){return s}));for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i="undefined"==typeof Uint8Array?[]:new Uint8Array(256),o=0;o<r.length;o++)i[r.charCodeAt(o)]=o;var s=function(e){var t,n=new Uint8Array(e),i=n.length,o="";for(t=0;t<i;t+=3)o+=r[n[t]>>2],o+=r[(3&n[t])<<4|n[t+1]>>4],o+=r[(15&n[t+1])<<2|n[t+2]>>6],o+=r[63&n[t+2]];return i%3==2?o=o.substring(0,o.length-1)+"=":i%3==1&&(o=o.substring(0,o.length-2)+"=="),o},a=function(e){var t,n,r,o,s,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var l=new ArrayBuffer(a),h=new Uint8Array(l);for(t=0;t<c;t+=4)n=i[e.charCodeAt(t)],r=i[e.charCodeAt(t+1)],o=i[e.charCodeAt(t+2)],s=i[e.charCodeAt(t+3)],h[u++]=n<<2|r>>4,h[u++]=(15&r)<<4|o>>2,h[u++]=(3&o)<<6|63&s;return l}},"./node_modules/@socket.io/component-emitter/index.js":
/*!************************************************************!*\
!*** ./node_modules/@socket.io/component-emitter/index.js ***!
\************************************************************/
/*! no static exports found */function(e,t){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}t.Emitter=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},n.prototype.emitReserved=n.prototype.emit,n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}},"./node_modules/backo2/index.js":
/*!**************************************!*\
!*** ./node_modules/backo2/index.js ***!
\**************************************/
/*! no static exports found */function(e,t){function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}e.exports=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},"./node_modules/base64-js/index.js":
/*!*****************************************!*\
!*** ./node_modules/base64-js/index.js ***!
\*****************************************/
/*! no static exports found */function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],a=r[1],c=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),l=0,h=a>0?s-4:s;for(n=0;n<h;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(l(e,s,s+16383>a?a:s+16383));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},"./node_modules/buffer/index.js":
/*!**************************************!*\
!*** ./node_modules/buffer/index.js ***!
\**************************************/
/*! no static exports found */function(e,t,n){"use strict";(function(e){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var r=n(/*! base64-js */"./node_modules/base64-js/index.js"),i=n(/*! ieee754 */"./node_modules/ieee754/index.js"),o=n(/*! isarray */"./node_modules/isarray/index.js");function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=d(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|f(t,n),i=(e=a(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):d(e,t);if("Buffer"===t.type&&o(t.data))return d(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function h(e,t){if(l(t),e=a(e,t<0?0:0|p(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function d(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(r)return L(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return D(this,t,n);case"latin1":case"binary":return S(this,t,n);case"base64":return j(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=n;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function v(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return U(L(t,e.length-n),e,n,r)}function w(e,t,n,r){return U(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function x(e,t,n,r){return w(e,t,n,r)}function k(e,t,n,r){return U(N(t),e,n,r)}function E(e,t,n,r){return U(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function j(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,u=e[i],l=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}function D(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function S(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){var r,i=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>i)&&(n=i);for(var o="",s=t;s<n;++s)o+=(r=e[s])<16?"0"+r.toString(16):r.toString(16);return o}function O(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function F(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function I(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function T(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function R(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(e,t,n,r,o){return o||R(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function M(e,t,n,r,o){return o||R(e,0,n,8),i.write(e,t,n,r,52,8),n+8}t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return l(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return h(null,e)},c.allocUnsafeSlow=function(e){return h(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=f,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):m.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(r,i),l=e.slice(t,n),h=0;h<a;++h)if(u[h]!==l[h]){o=u[h],s=l[h];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return _(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return _(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return v(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return k(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;n=new c(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},c.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||F(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||F(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):T(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):T(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);F(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);F(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):T(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):T(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return M(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return M(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=c.isBuffer(e)?e:L(new c(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function L(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function N(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function U(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(/*! ./../webpack/buildin/global.js */"./node_modules/webpack/buildin/global.js"))},"./node_modules/engine.io-client/build/esm/globalThis.browser.js":
/*!***********************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/globalThis.browser.js ***!
\***********************************************************************/
/*! exports provided: default */function(e,t,n){"use strict";n.r(t),t.default="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},"./node_modules/engine.io-client/build/esm/index.js":
/*!**********************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/index.js ***!
\**********************************************************/
/*! exports provided: Socket, protocol, Transport, transports, installTimerFunctions */function(e,t,n){"use strict";n.r(t),n.d(t,"protocol",(function(){return a}));var r=n(/*! ./socket.js */"./node_modules/engine.io-client/build/esm/socket.js");n.d(t,"Socket",(function(){return r.Socket}));var i=n(/*! ./transport.js */"./node_modules/engine.io-client/build/esm/transport.js");n.d(t,"Transport",(function(){return i.Transport}));var o=n(/*! ./transports/index.js */"./node_modules/engine.io-client/build/esm/transports/index.js");n.d(t,"transports",(function(){return o.transports}));var s=n(/*! ./util.js */"./node_modules/engine.io-client/build/esm/util.js");n.d(t,"installTimerFunctions",(function(){return s.installTimerFunctions}));const a=r.Socket.protocol},"./node_modules/engine.io-client/build/esm/socket.js":
/*!***********************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/socket.js ***!
\***********************************************************/
/*! exports provided: Socket */function(e,t,n){"use strict";n.r(t),n.d(t,"Socket",(function(){return h}));var r=n(/*! ./transports/index.js */"./node_modules/engine.io-client/build/esm/transports/index.js"),i=n(/*! ./util.js */"./node_modules/engine.io-client/build/esm/util.js"),o=n(/*! parseqs */"./node_modules/parseqs/index.js"),s=n.n(o),a=n(/*! parseuri */"./node_modules/parseuri/index.js"),c=n.n(a),u=n(/*! @socket.io/component-emitter */"./node_modules/@socket.io/component-emitter/index.js"),l=n(/*! engine.io-parser */"./node_modules/engine.io-parser/build/esm/index.js");class h extends u.Emitter{constructor(e,t={}){super(),e&&"object"==typeof e&&(t=e,e=null),e?(e=c()(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=c()(t.host).host),Object(i.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+"/","string"==typeof this.opts.query&&(this.opts.query=s.a.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener("beforeunload",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close")},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=function(e){const t={};for(let n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.opts.query);t.EIO=l.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new r.transports[e](n)}open(){let e;if(this.opts.rememberUpgrade&&h.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",()=>{this.onClose("transport close")})}probe(e){let t=this.createTransport(e),n=!1;h.priorWebsocketSuccess=!1;const r=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;h.priorWebsocketSuccess="websocket"===t.name,this.transport.pause(()=>{n||"closed"!==this.readyState&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}}))};function i(){n||(n=!0,u(),t.close(),t=null)}const o=e=>{const n=new Error("probe error: "+e);n.transport=t.name,i(),this.emitReserved("upgradeError",n)};function s(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&i()}const u=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",c),t.open()}onOpen(){if(this.readyState="open",h.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emitReserved("flush"))}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){h.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}h.protocol=l.protocol},"./node_modules/engine.io-client/build/esm/transport.js":
/*!**************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/transport.js ***!
\**************************************************************/
/*! exports provided: Transport */function(e,t,n){"use strict";n.r(t),n.d(t,"Transport",(function(){return s}));var r=n(/*! engine.io-parser */"./node_modules/engine.io-parser/build/esm/index.js"),i=n(/*! @socket.io/component-emitter */"./node_modules/@socket.io/component-emitter/index.js"),o=n(/*! ./util.js */"./node_modules/engine.io-client/build/esm/util.js");class s extends i.Emitter{constructor(e){super(),this.writable=!1,Object(o.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,t){const n=new Error(e);return n.type="TransportError",n.description=t,super.emit("error",n),this}open(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emit("open")}onData(e){const t=Object(r.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emit("packet",e)}onClose(){this.readyState="closed",super.emit("close")}}},"./node_modules/engine.io-client/build/esm/transports/index.js":
/*!*********************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/transports/index.js ***!
\*********************************************************************/
/*! exports provided: transports */function(e,t,n){"use strict";n.r(t),n.d(t,"transports",(function(){return i}));var r=n(/*! ./polling-xhr.js */"./node_modules/engine.io-client/build/esm/transports/polling-xhr.js");const i={websocket:n(/*! ./websocket.js */"./node_modules/engine.io-client/build/esm/transports/websocket.js").WS,polling:r.XHR}},"./node_modules/engine.io-client/build/esm/transports/polling-xhr.js":
/*!***************************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/transports/polling-xhr.js ***!
\***************************************************************************/
/*! exports provided: XHR, Request */function(e,t,n){"use strict";n.r(t),n.d(t,"XHR",(function(){return l})),n.d(t,"Request",(function(){return h}));var r=n(/*! ./xmlhttprequest.js */"./node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.js"),i=n(/*! ../globalThis.js */"./node_modules/engine.io-client/build/esm/globalThis.browser.js"),o=n(/*! ../util.js */"./node_modules/engine.io-client/build/esm/util.js"),s=n(/*! @socket.io/component-emitter */"./node_modules/@socket.io/component-emitter/index.js"),a=n(/*! ./polling.js */"./node_modules/engine.io-client/build/esm/transports/polling.js");function c(){}const u=null!=new r.default({xdomain:!1}).responseType;class l extends a.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port,this.xs=e.secure!==t}const t=e&&e.forceBase64;this.supportsBinary=u&&!t}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new h(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",e=>{this.onError("xhr post error",e)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",e=>{this.onError("xhr poll error",e)}),this.pollXhr=e}}class h extends s.Emitter{constructor(e,t){super(),Object(o.installTimerFunctions)(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=!1!==t.async,this.data=void 0!==t.data?t.data:null,this.create()}create(){const e=Object(o.pick)(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const t=this.xhr=new r.default(e);try{t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&t.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{4===t.readyState&&(200===t.status||1223===t.status?this.onLoad():this.setTimeoutFn(()=>{this.onError("number"==typeof t.status?t.status:0)},0))},t.send(this.data)}catch(e){return void this.setTimeoutFn(()=>{this.onError(e)},0)}"undefined"!=typeof document&&(this.index=h.requestsCount++,h.requests[this.index]=this)}onSuccess(){this.emit("success"),this.cleanup()}onData(e){this.emit("data",e),this.onSuccess()}onError(e){this.emit("error",e),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=c,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete h.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&this.onData(e)}abort(){this.cleanup()}}if(h.requestsCount=0,h.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",d);else if("function"==typeof addEventListener){const e="onpagehide"in i.default?"pagehide":"unload";addEventListener(e,d,!1)}function d(){for(let e in h.requests)h.requests.hasOwnProperty(e)&&h.requests[e].abort()}},"./node_modules/engine.io-client/build/esm/transports/polling.js":
/*!***********************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/transports/polling.js ***!
\***********************************************************************/
/*! exports provided: Polling */function(e,t,n){"use strict";n.r(t),n.d(t,"Polling",(function(){return u}));var r=n(/*! ../transport.js */"./node_modules/engine.io-client/build/esm/transport.js"),i=n(/*! yeast */"./node_modules/yeast/index.js"),o=n.n(i),s=n(/*! parseqs */"./node_modules/parseqs/index.js"),a=n.n(s),c=n(/*! engine.io-parser */"./node_modules/engine.io-parser/build/esm/index.js");class u extends r.Transport{constructor(){super(...arguments),this.polling=!1}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emit("poll")}onData(e){Object(c.decodePayload)(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose(),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,Object(c.encodePayload)(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emit("drain")})})}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let n="";!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()()),this.supportsBinary||e.sid||(e.b64=1),this.opts.port&&("https"===t&&443!==Number(this.opts.port)||"http"===t&&80!==Number(this.opts.port))&&(n=":"+this.opts.port);const r=a.a.encode(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(r.length?"?"+r:"")}}},"./node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.js":
/*!*********************************************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.js ***!
\*********************************************************************************************/
/*! exports provided: nextTick, WebSocket, usingBrowserWebSocket, defaultBinaryType */function(e,t,n){"use strict";n.r(t),n.d(t,"nextTick",(function(){return i})),n.d(t,"WebSocket",(function(){return o})),n.d(t,"usingBrowserWebSocket",(function(){return s})),n.d(t,"defaultBinaryType",(function(){return a}));var r=n(/*! ../globalThis.js */"./node_modules/engine.io-client/build/esm/globalThis.browser.js");const i="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),o=r.default.WebSocket||r.default.MozWebSocket,s=!0,a="arraybuffer"},"./node_modules/engine.io-client/build/esm/transports/websocket.js":
/*!*************************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/transports/websocket.js ***!
\*************************************************************************/
/*! exports provided: WS */function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"WS",(function(){return d}));var r=n(/*! ../transport.js */"./node_modules/engine.io-client/build/esm/transport.js"),i=n(/*! parseqs */"./node_modules/parseqs/index.js"),o=n.n(i),s=n(/*! yeast */"./node_modules/yeast/index.js"),a=n.n(s),c=n(/*! ../util.js */"./node_modules/engine.io-client/build/esm/util.js"),u=n(/*! ./websocket-constructor.js */"./node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.js"),l=n(/*! engine.io-parser */"./node_modules/engine.io-parser/build/esm/index.js");const h="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class d extends r.Transport{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=h?{}:Object(c.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=u.usingBrowserWebSocket&&!h?t?new u.WebSocket(e,t):new u.WebSocket(e):new u.WebSocket(e,t,n)}catch(e){return this.emit("error",e)}this.ws.binaryType=this.socket.binaryType||u.defaultBinaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;Object(l.encodePacket)(r,this.supportsBinary,t=>{const n={};!u.usingBrowserWebSocket&&(r.options&&(n.compress=r.options.compress),this.opts.perMessageDeflate)&&("string"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(n.compress=!1);try{u.usingBrowserWebSocket?this.ws.send(t):this.ws.send(t,n)}catch(e){}i&&Object(u.nextTick)(()=>{this.writable=!0,this.emit("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?"wss":"ws";let n="";this.opts.port&&("wss"===t&&443!==Number(this.opts.port)||"ws"===t&&80!==Number(this.opts.port))&&(n=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=a()()),this.supportsBinary||(e.b64=1);const r=o.a.encode(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(r.length?"?"+r:"")}check(){return!(!u.WebSocket||"__initialize"in u.WebSocket&&this.name===d.prototype.name)}}}.call(this,n(/*! ./../../../../buffer/index.js */"./node_modules/buffer/index.js").Buffer)},"./node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.js":
/*!**************************************************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.js ***!
\**************************************************************************************/
/*! exports provided: default */function(e,t,n){"use strict";n.r(t);var r=n(/*! has-cors */"./node_modules/has-cors/index.js"),i=n.n(r),o=n(/*! ../globalThis.js */"./node_modules/engine.io-client/build/esm/globalThis.browser.js");t.default=function(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||i.a))return new XMLHttpRequest}catch(e){}if(!t)try{return new(o.default[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}},"./node_modules/engine.io-client/build/esm/util.js":
/*!*********************************************************!*\
!*** ./node_modules/engine.io-client/build/esm/util.js ***!
\*********************************************************/
/*! exports provided: pick, installTimerFunctions */function(e,t,n){"use strict";n.r(t),n.d(t,"pick",(function(){return i})),n.d(t,"installTimerFunctions",(function(){return a}));var r=n(/*! ./globalThis.js */"./node_modules/engine.io-client/build/esm/globalThis.browser.js");function i(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const o=setTimeout,s=clearTimeout;function a(e,t){t.useNativeTimers?(e.setTimeoutFn=o.bind(r.default),e.clearTimeoutFn=s.bind(r.default)):(e.setTimeoutFn=setTimeout.bind(r.default),e.clearTimeoutFn=clearTimeout.bind(r.default))}},"./node_modules/engine.io-parser/build/esm/commons.js":
/*!************************************************************!*\
!*** ./node_modules/engine.io-parser/build/esm/commons.js ***!
\************************************************************/
/*! exports provided: PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET */function(e,t,n){"use strict";n.r(t),n.d(t,"PACKET_TYPES",(function(){return r})),n.d(t,"PACKET_TYPES_REVERSE",(function(){return i})),n.d(t,"ERROR_PACKET",(function(){return o}));const r=Object.create(null);r.open="0",r.close="1",r.ping="2",r.pong="3",r.message="4",r.upgrade="5",r.noop="6";const i=Object.create(null);Object.keys(r).forEach(e=>{i[r[e]]=e});const o={type:"error",data:"parser error"}},"./node_modules/engine.io-parser/build/esm/decodePacket.browser.js":
/*!*************************************************************************!*\
!*** ./node_modules/engine.io-parser/build/esm/decodePacket.browser.js ***!
\*************************************************************************/
/*! exports provided: default */function(e,t,n){"use strict";n.r(t);var r=n(/*! ./commons.js */"./node_modules/engine.io-parser/build/esm/commons.js"),i=n(/*! @socket.io/base64-arraybuffer */"./node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js");const o="function"==typeof ArrayBuffer,s=(e,t)=>{if(o){const n=Object(i.decode)(e);return a(n,t)}return{base64:!0,data:e}},a=(e,t)=>{switch(t){case"blob":return e instanceof ArrayBuffer?new Blob([e]):e;case"arraybuffer":default:return e}};t.default=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:s(e.substring(1),t)}:r.PACKET_TYPES_REVERSE[n]?e.length>1?{type:r.PACKET_TYPES_REVERSE[n],data:e.substring(1)}:{type:r.PACKET_TYPES_REVERSE[n]}:r.ERROR_PACKET}},"./node_modules/engine.io-parser/build/esm/encodePacket.browser.js":
/*!*************************************************************************!*\
!*** ./node_modules/engine.io-parser/build/esm/encodePacket.browser.js ***!
\*************************************************************************/
/*! exports provided: default */function(e,t,n){"use strict";n.r(t);var r=n(/*! ./commons.js */"./node_modules/engine.io-parser/build/esm/commons.js");const i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),o="function"==typeof ArrayBuffer,s=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+e)},n.readAsDataURL(e)};t.default=({type:e,data:t},n,a)=>{return i&&t instanceof Blob?n?a(t):s(t,a):o&&(t instanceof ArrayBuffer||(c=t,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(c):c&&c.buffer instanceof ArrayBuffer))?n?a(t):s(new Blob([t]),a):a(r.PACKET_TYPES[e]+(t||""));var c}},"./node_modules/engine.io-parser/build/esm/index.js":
/*!**********************************************************!*\
!*** ./node_modules/engine.io-parser/build/esm/index.js ***!
\**********************************************************/
/*! exports provided: protocol, encodePacket, encodePayload, decodePacket, decodePayload */function(e,t,n){"use strict";n.r(t),n.d(t,"protocol",(function(){return c})),n.d(t,"encodePayload",(function(){return s})),n.d(t,"decodePayload",(function(){return a}));var r=n(/*! ./encodePacket.js */"./node_modules/engine.io-parser/build/esm/encodePacket.browser.js");n.d(t,"encodePacket",(function(){return r.default}));var i=n(/*! ./decodePacket.js */"./node_modules/engine.io-parser/build/esm/decodePacket.browser.js");n.d(t,"decodePacket",(function(){return i.default}));const o=String.fromCharCode(30),s=(e,t)=>{const n=e.length,i=new Array(n);let s=0;e.forEach((e,a)=>{Object(r.default)(e,!1,e=>{i[a]=e,++s===n&&t(i.join(o))})})},a=(e,t)=>{const n=e.split(o),r=[];for(let e=0;e<n.length;e++){const o=Object(i.default)(n[e],t);if(r.push(o),"error"===o.type)break}return r},c=4},"./node_modules/has-cors/index.js":
/*!****************************************!*\
!*** ./node_modules/has-cors/index.js ***!
\****************************************/
/*! no static exports found */function(e,t){try{e.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){e.exports=!1}},"./node_modules/ieee754/index.js":
/*!***************************************!*\
!*** ./node_modules/ieee754/index.js ***!
\***************************************/
/*! no static exports found */function(e,t){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,u=c>>1,l=-7,h=n?i-1:0,d=n?-1:1,p=e[t+h];for(h+=d,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=u}return(p?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&a,p+=f,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[n+p]=255&s,p+=f,s/=256,u-=8);e[n+p-f]|=128*m}},"./node_modules/isarray/index.js":
/*!***************************************!*\
!*** ./node_modules/isarray/index.js ***!
\***************************************/
/*! no static exports found */function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},"./node_modules/parseqs/index.js":
/*!***************************************!*\
!*** ./node_modules/parseqs/index.js ***!
\***************************************/
/*! no static exports found */function(e,t){t.encode=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){for(var t={},n=e.split("&"),r=0,i=n.length;r<i;r++){var o=n[r].split("=");t[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return t}},"./node_modules/parseuri/index.js":
/*!****************************************!*\
!*** ./node_modules/parseuri/index.js ***!
\****************************************/
/*! no static exports found */function(e,t){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(e){var t,i,o=e,s=e.indexOf("["),a=e.indexOf("]");-1!=s&&-1!=a&&(e=e.substring(0,s)+e.substring(s,a).replace(/:/g,";")+e.substring(a,e.length));for(var c,u,l=n.exec(e||""),h={},d=14;d--;)h[r[d]]=l[d]||"";return-1!=s&&-1!=a&&(h.source=o,h.host=h.host.substring(1,h.host.length-1).replace(/;/g,":"),h.authority=h.authority.replace("[","").replace("]","").replace(/;/g,":"),h.ipv6uri=!0),h.pathNames=(t=h.path,i=t.replace(/\/{2,9}/g,"/").split("/"),"/"!=t.substr(0,1)&&0!==t.length||i.splice(0,1),"/"==t.substr(t.length-1,1)&&i.splice(i.length-1,1),i),h.queryKey=(c=h.query,u={},c.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(u[t]=n)})),u),h}},"./node_modules/socket.io-client/build/esm/index.js":
/*!**********************************************************!*\
!*** ./node_modules/socket.io-client/build/esm/index.js ***!
\**********************************************************/
/*! exports provided: protocol, Manager, Socket, io, connect, default */function(e,t,n){"use strict";n.r(t),n.d(t,"io",(function(){return c})),n.d(t,"connect",(function(){return c})),n.d(t,"default",(function(){return c}));var r=n(/*! ./url.js */"./node_modules/socket.io-client/build/esm/url.js"),i=n(/*! ./manager.js */"./node_modules/socket.io-client/build/esm/manager.js");n.d(t,"Manager",(function(){return i.Manager}));var o=n(/*! ./socket.js */"./node_modules/socket.io-client/build/esm/socket.js");n.d(t,"Socket",(function(){return o.Socket}));var s=n(/*! socket.io-parser */"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/index.js");n.d(t,"protocol",(function(){return s.protocol}));const a={};function c(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=Object(r.url)(e,t.path||"/socket.io"),o=n.source,s=n.id,c=n.path,u=a[s]&&c in a[s].nsps;let l;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?l=new i.Manager(o,t):(a[s]||(a[s]=new i.Manager(o,t)),l=a[s]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(c,{Manager:i.Manager,Socket:o.Socket,io:c,connect:c})},"./node_modules/socket.io-client/build/esm/manager.js":
/*!************************************************************!*\
!*** ./node_modules/socket.io-client/build/esm/manager.js ***!
\************************************************************/
/*! exports provided: Manager */function(e,t,n){"use strict";n.r(t),n.d(t,"Manager",(function(){return l}));var r=n(/*! engine.io-client */"./node_modules/engine.io-client/build/esm/index.js"),i=n(/*! ./socket.js */"./node_modules/socket.io-client/build/esm/socket.js"),o=n(/*! socket.io-parser */"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/index.js"),s=n(/*! ./on.js */"./node_modules/socket.io-client/build/esm/on.js"),a=n(/*! backo2 */"./node_modules/backo2/index.js"),c=n.n(a),u=n(/*! @socket.io/component-emitter */"./node_modules/@socket.io/component-emitter/index.js");class l extends u.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,Object(r.installTimerFunctions)(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new c.a({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||o;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new r.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=Object(s.on)(t,"open",(function(){n.onopen(),e&&e()})),o=Object(s.on)(t,"error",t=>{n.cleanup(),n._readyState="closed",this.emitReserved("error",t),e?e(t):n.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;0===e&&i();const n=this.setTimeoutFn(()=>{i(),t.close(),t.emit("error",new Error("timeout"))},e);this.opts.autoUnref&&n.unref(),this.subs.push((function(){clearTimeout(n)}))}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Object(s.on)(e,"ping",this.onping.bind(this)),Object(s.on)(e,"data",this.ondata.bind(this)),Object(s.on)(e,"error",this.onerror.bind(this)),Object(s.on)(e,"close",this.onclose.bind(this)),Object(s.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved("packet",e)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n||(n=new i.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push((function(){clearTimeout(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}},"./node_modules/socket.io-client/build/esm/on.js":
/*!*******************************************************!*\
!*** ./node_modules/socket.io-client/build/esm/on.js ***!
\*******************************************************/
/*! exports provided: on */function(e,t,n){"use strict";function r(e,t,n){return e.on(t,n),function(){e.off(t,n)}}n.r(t),n.d(t,"on",(function(){return r}))},"./node_modules/socket.io-client/build/esm/socket.js":
/*!***********************************************************!*\
!*** ./node_modules/socket.io-client/build/esm/socket.js ***!
\***********************************************************/
/*! exports provided: Socket */function(e,t,n){"use strict";n.r(t),n.d(t,"Socket",(function(){return a}));var r=n(/*! socket.io-parser */"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/index.js"),i=n(/*! ./on.js */"./node_modules/socket.io-client/build/esm/on.js"),o=n(/*! @socket.io/component-emitter */"./node_modules/@socket.io/component-emitter/index.js");const s=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class a extends o.Emitter{constructor(e,t,n){super(),this.connected=!1,this.disconnected=!0,this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Object(i.on)(e,"open",this.onopen.bind(this)),Object(i.on)(e,"packet",this.onpacket.bind(this)),Object(i.on)(e,"error",this.onerror.bind(this)),Object(i.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(s.hasOwnProperty(e))throw new Error('"'+e+'" is a reserved event name');t.unshift(e);const n={type:r.PacketType.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?this.packet(n):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){const n=this.flags.timeout;if(void 0===n)return void(this.acks[e]=t);const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,[null,...e])}}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth(e=>{this.packet({type:r.PacketType.CONNECT,data:e})}):this.packet({type:r.PacketType.CONNECT,data:this.auth})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e){this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved("disconnect",e)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case r.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case r.PacketType.EVENT:case r.PacketType.BINARY_EVENT:this.onevent(e);break;case r.PacketType.ACK:case r.PacketType.BINARY_ACK:this.onack(e);break;case r.PacketType.DISCONNECT:this.ondisconnect();break;case r.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e)}ack(e){const t=this;let n=!1;return function(...i){n||(n=!0,t.packet({type:r.PacketType.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e){this.id=e,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>this.packet(e)),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:r.PacketType.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}},"./node_modules/socket.io-client/build/esm/url.js":
/*!********************************************************!*\
!*** ./node_modules/socket.io-client/build/esm/url.js ***!
\********************************************************/
/*! exports provided: url */function(e,t,n){"use strict";n.r(t),n.d(t,"url",(function(){return o}));var r=n(/*! parseuri */"./node_modules/parseuri/index.js"),i=n.n(r);function o(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=i()(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}},"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/binary.js":
/*!*****************************************************************************************!*\
!*** ./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/binary.js ***!
\*****************************************************************************************/
/*! exports provided: deconstructPacket, reconstructPacket */function(e,t,n){"use strict";n.r(t),n.d(t,"deconstructPacket",(function(){return i})),n.d(t,"reconstructPacket",(function(){return o}));var r=n(/*! ./is-binary.js */"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/is-binary.js");function i(e){const t=[],n=e.data,i=e;return i.data=function e(t,n){if(!t)return t;if(Object(r.isBinary)(t)){const e={_placeholder:!0,num:n.length};return n.push(t),e}if(Array.isArray(t)){const r=new Array(t.length);for(let i=0;i<t.length;i++)r[i]=e(t[i],n);return r}if("object"==typeof t&&!(t instanceof Date)){const r={};for(const i in t)t.hasOwnProperty(i)&&(r[i]=e(t[i],n));return r}return t}(n,t),i.attachments=t.length,{packet:i,buffers:t}}function o(e,t){return e.data=function e(t,n){if(!t)return t;if(t&&t._placeholder)return n[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=e(t[r],n);else if("object"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=e(t[r],n));return t}(e.data,t),e.attachments=void 0,e}},"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/index.js":
/*!****************************************************************************************!*\
!*** ./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/index.js ***!
\****************************************************************************************/
/*! exports provided: protocol, PacketType, Encoder, Decoder */function(e,t,n){"use strict";n.r(t),n.d(t,"protocol",(function(){return s})),n.d(t,"PacketType",(function(){return a})),n.d(t,"Encoder",(function(){return c})),n.d(t,"Decoder",(function(){return u}));var r=n(/*! @socket.io/component-emitter */"./node_modules/@socket.io/component-emitter/index.js"),i=n(/*! ./binary.js */"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/binary.js"),o=n(/*! ./is-binary.js */"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/is-binary.js");const s=5;var a;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(a||(a={}));class c{encode(e){return e.type!==a.EVENT&&e.type!==a.ACK||!Object(o.hasBinary)(e)?[this.encodeAsString(e)]:(e.type=e.type===a.EVENT?a.BINARY_EVENT:a.BINARY_ACK,this.encodeAsBinary(e))}encodeAsString(e){let t=""+e.type;return e.type!==a.BINARY_EVENT&&e.type!==a.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data)),t}encodeAsBinary(e){const t=Object(i.deconstructPacket)(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}}class u extends r.Emitter{constructor(){super()}add(e){let t;if("string"==typeof e)t=this.decodeString(e),t.type===a.BINARY_EVENT||t.type===a.BINARY_ACK?(this.reconstructor=new l(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t);else{if(!Object(o.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===a[n.type])throw new Error("unknown packet type "+n.type);if(n.type===a.BINARY_EVENT||n.type===a.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=function(e){try{return JSON.parse(e)}catch(e){return!1}}(e.substr(t));if(!u.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}static isPayloadValid(e,t){switch(e){case a.CONNECT:return"object"==typeof t;case a.DISCONNECT:return void 0===t;case a.CONNECT_ERROR:return"string"==typeof t||"object"==typeof t;case a.EVENT:case a.BINARY_EVENT:return Array.isArray(t)&&t.length>0;case a.ACK:case a.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}class l{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Object(i.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}},"./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/is-binary.js":
/*!********************************************************************************************!*\
!*** ./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/is-binary.js ***!
\********************************************************************************************/
/*! exports provided: isBinary, hasBinary */function(e,t,n){"use strict";n.r(t),n.d(t,"isBinary",(function(){return a})),n.d(t,"hasBinary",(function(){return c}));const r="function"==typeof ArrayBuffer,i=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===i.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===i.call(File);function a(e){return r&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||o&&e instanceof Blob||s&&e instanceof File}function c(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(c(e[t]))return!0;return!1}if(a(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return c(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&c(e[t]))return!0;return!1}},"./node_modules/webpack/buildin/global.js":
/*!***********************************!*\
!*** (webpack)/buildin/global.js ***!
\***********************************/
/*! no static exports found */function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},"./node_modules/worker-loader/dist/workers/InlineWorker.js":
/*!*****************************************************************!*\
!*** ./node_modules/worker-loader/dist/workers/InlineWorker.js ***!
\*****************************************************************/
/*! no static exports found */function(e,t,n){"use strict";var r=window.URL||window.webkitURL;e.exports=function(e,t){try{try{var n;try{(n=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(e),n=n.getBlob()}catch(t){n=new Blob([e])}return new Worker(r.createObjectURL(n))}catch(t){return new Worker("data:application/javascript,"+encodeURIComponent(e))}}catch(e){if(!t)throw Error("Inline worker is not supported");return new Worker(t)}}},"./node_modules/yeast/index.js":
/*!*************************************!*\
!*** ./node_modules/yeast/index.js ***!
\*************************************/
/*! no static exports found */function(e,t,n){"use strict";var r,i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),o={},s=0,a=0;function c(e){var t="";do{t=i[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function u(){var e=c(+new Date);return e!==r?(s=0,r=e):e+"."+c(s++)}for(;a<64;a++)o[i[a]]=a;u.encode=c,u.decode=function(e){var t=0;for(a=0;a<e.length;a++)t=64*t+o[e.charAt(a)];return t},e.exports=u},"./package.json":
/*!**********************!*\
!*** ./package.json ***!
\**********************/
/*! exports provided: name, version, description, module, scripts, repository, keywords, author, license, bugs, homepage, dependencies, devDependencies, eslintConfig, default */function(e){e.exports=JSON.parse('{"name":"imjoy-rpc","version":"0.5.9","description":"Remote procedure calls for ImJoy.","module":"index.js","scripts":{"build":"rm -rf dist && npm run build-umd","build-umd":"webpack --config webpack.config.js --mode development && NODE_ENV=production webpack --config webpack.config.js --mode production --devtool source-map ","watch":"NODE_ENV=production webpack --watch --progress --config webpack.config.js --mode production --devtool source-map","publish-npm":"npm install && npm run build && npm publish","serve":"webpack-dev-server","stats":"webpack --profile --json > stats.json","stats-prod":"webpack --profile --json --mode production > stats-prod.json","analyze":"webpack-bundle-analyzer -p 9999 stats.json","analyze-prod":"webpack-bundle-analyzer -p 9999 stats-prod.json","clean":"rimraf dist/*","deploy":"npm run build && node deploy-site.js","format":"prettier --write \\"{src,tests}/**/**\\"","check-format":"prettier --check \\"{src,tests}/**/**\\"","test":"karma start --single-run --browsers ChromeHeadless,FirefoxHeadless karma.conf.js","test-watch":"karma start --auto-watch --browsers ChromeDebugging karma.conf.js --debug"},"repository":{"type":"git","url":"git+https://github.com/imjoy-team/imjoy-rpc.git"},"keywords":["imjoy","rpc"],"author":"imjoy-team <imjoy.team@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/imjoy-team/imjoy-rpc/issues"},"homepage":"https://github.com/imjoy-team/imjoy-rpc","dependencies":{"@msgpack/msgpack":"^2.7.1","socket.io-client":"^4.4.1"},"devDependencies":{"@babel/core":"^7.16.12","@babel/plugin-syntax-dynamic-import":"^7.8.3","@babel/polyfill":"^7.12.1","@babel/preset-env":"^7.16.11","@types/requirejs":"^2.1.34","babel-core":"^6.26.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.3","babel-runtime":"^6.26.0","chai":"^4.3.6","clean-webpack-plugin":"^0.1.19","copy-webpack-plugin":"^5.1.2","eslint":"^6.8.0","eslint-config-prettier":"^4.2.0","eslint-loader":"^4.0.2","file-loader":"^0.11.2","fs-extra":"^0.30.0","gh-pages":"^2.0.1","html-loader":"^0.5.5","html-webpack-plugin":"^3.2.0","json-loader":"^0.5.4","karma":"^6.3.12","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^1.3.0","karma-mocha":"^1.3.0","karma-sourcemap-loader":"^0.3.8","karma-spec-reporter":"0.0.32","karma-webpack":"^4.0.2","lerna":"^3.22.1","lodash.debounce":"^4.0.8","mocha":"^7.2.0","postcss":"^7.0.36","prettier":"^1.6.1","rimraf":"^2.6.2","schema-utils":"^0.4.3","style-loader":"^0.18.1","url-loader":"^0.5.9","webpack":"^4.46.0","webpack-bundle-analyzer":"^3.9.0","webpack-cli":"^3.3.12","webpack-dev-server":"^3.11.3","webpack-merge":"^4.1.1","workbox-webpack-plugin":"^4.3.1","worker-loader":"^2.0.0","write-file-webpack-plugin":"^4.5.1"},"eslintConfig":{"globals":{"document":true,"window":true}}}')},"./src/main.js":
/*!*********************!*\
!*** ./src/main.js ***!
\*********************/
/*! exports provided: RPC, API_VERSION, VERSION, loadRequirements, waitForInitialization, setupRPC */function(e,t,n){"use strict";n.r(t),n.d(t,"waitForInitialization",(function(){return l})),n.d(t,"setupRPC",(function(){return h}));var r=n(/*! ./plugin.webworker.js */"./src/plugin.webworker.js"),i=n.n(r),o=n(/*! ./pluginIframe.js */"./src/pluginIframe.js"),s=n(/*! ./utils.js */"./src/utils.js");n.d(t,"loadRequirements",(function(){return s.loadRequirements}));var a=n(/*! ./rpc.js */"./src/rpc.js");n.d(t,"RPC",(function(){return a.RPC})),n.d(t,"API_VERSION",(function(){return a.API_VERSION}));var c=n(/*! ../package.json */"./package.json");function u(){return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope}function l(e){u()&&(globalThis.parent=self),(e=e||{}).enable_service_worker&&(Object(s.setupServiceWorker)(e.base_url,e.target_origin,e.cache_requirements),e.enable_service_worker=!1),e.cache_requirements&&delete e.cache_requirements;const t=e.target_origin||"*";if(e.credential_required&&"function"!=typeof e.verify_credential)throw new Error("Please also provide the `verify_credential` function with `credential_required`.");if(e.credential_required&&"*"===t)throw new Error("`target_origin` was set to `*` with `credential_required=true`, there is a security risk that you may leak the credential to website from other origin. Please specify the `target_origin` explicitly.");const n=Object(s.randId)(),r=i=>{if("message"===i.type&&(!i.origin||"*"===t||i.origin===t)){if("initialize"!==i.data.type)throw new Error("unrecognized message: "+i.data);{globalThis.removeEventListener("message",r),i.data.peer_id!==n&&console.warn(`${i.data.config&&i.data.config.name}: connection peer id mismatch ${i.data.peer_id} !== ${n}`);const o=i.data.config;"*"!==t&&(o.target_origin=t),e.credential_required?e.verify_credential(o.credential).then(e=>{if(!e||!e.auth||e.error)throw new Error("Failed to verify the credentail:"+(e&&e.error));o.auth=e.auth,h(o).then(()=>{console.log("ImJoy RPC loaded successfully!")})}):h(o).then(()=>{console.log("ImJoy RPC loaded successfully!")})}}};globalThis.addEventListener("message",r),u()?parent.postMessage({type:"imjoyRPCReady",config:e,peer_id:n}):parent.postMessage({type:"imjoyRPCReady",config:e,peer_id:n},"*")}function h(e){return(e=e||{}).name=e.name||Object(s.randId)(),(e=Object(s.normalizeConfig)(e)).enable_service_worker&&Object(s.setupServiceWorker)(e.base_url,e.target_origin,e.cache_requirements),e.cache_requirements&&delete e.cache_requirements,new Promise((t,n)=>{const r=n=>{const i=n.detail;e.expose_api_globally&&(globalThis.api=i),t(i),globalThis.removeEventListener("imjoy_remote_api_ready",r)};if(function(){try{return window.self!==window.top}catch(e){return!0}}()){if("web-worker"===e.type)try{!function(e){if(!e.allow_execution)throw new Error("web-worker plugin can only work with allow_execution=true");let t=null;e.broadcastChannel&&(t=new BroadcastChannel(e.broadcastChannel));const n=new i.a,r=setTimeout((function(){n.terminate(),console.warn("Plugin failed to start as a web-worker, running in an iframe instead."),Object(o.default)(e)}),2e3),a=Object(s.randId)();n.addEventListener("message",(function(i){let o=void 0;const s=i.data;if("worker-ready"===s.type)return n.postMessage({type:"connectRPC",config:e}),void clearTimeout(r);"initialized"===s.type?(s.config=Object.assign({},e,s.config),s.origin=window.location.origin,s.peer_id=a):"imjoy_remote_api_ready"===s.type?window.dispatchEvent(new CustomEvent("imjoy_remote_api_ready",{detail:null})):"cacheRequirements"===s.type&&"function"==typeof cache_requirements?cache_requirements(s.requirements):"disconnect"===s.type?n.terminate():s.__transferables__&&(o=s.__transferables__,delete s.__transferables__),t?t.postMessage(s):parent.postMessage(s,e.target_origin||"*",o)})),(t||window).addEventListener("message",(function(r){if("message"===r.type&&(t||"*"===e.target_origin||r.origin===e.target_origin)){let t=void 0;const i=r.data;i.__transferables__&&(t=i.__transferables__,delete i.__transferables__),i.peer_id===a?n.postMessage(i,t):e.debug&&console.log(`connection peer id mismatch ${i.peer_id} !== ${a}`)}}))}(e)}catch(t){Object(o.default)(e)}else{if(!["rpc-window","rpc-worker","iframe","window"].includes(e.type))return console.error("Unsupported plugin type: "+e.type),void n("Unsupported plugin type: "+e.type);Object(o.default)(e)}globalThis.addEventListener("imjoy_remote_api_ready",r)}else u()?Object(o.default)(e):n(new Error("imjoy-rpc should only run inside an iframe or a webworker."))})}n.d(t,"VERSION",(function(){return c.version}))},"./src/plugin.webworker.js":
/*!*********************************!*\
!*** ./src/plugin.webworker.js ***!
\*********************************/
/*! no static exports found */function(e,t,n){e.exports=function(){return n(/*! !./node_modules/worker-loader/dist/workers/InlineWorker.js */"./node_modules/worker-loader/dist/workers/InlineWorker.js")('/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== \'undefined\' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: \'Module\' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, \'__esModule\', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__webpack_require__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __webpack_require__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === \'object\' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__webpack_require__.r(ns);\n/******/ \t\tObject.defineProperty(ns, \'default\', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != \'string\') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module[\'default\']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, \'a\', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = "";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = "./src/plugin.webworker.js");\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ "./src/plugin.webworker.js":\n/*!*********************************!*\\\n !*** ./src/plugin.webworker.js ***!\n \\*********************************/\n/*! no exports provided */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _pluginCore_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pluginCore.js */ "./src/pluginCore.js");\n/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rpc.js */ "./src/rpc.js");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ "./src/utils.js");\n/**\n * Contains the routines loaded by the plugin Worker under web-browser.\n *\n * Initializes the web environment version of the platform-dependent\n * connection object for the plugin site\n */\n\n\n\n\n// make sure this runs inside a webworker\nif (\n typeof WorkerGlobalScope === "undefined" ||\n !self ||\n !(self instanceof WorkerGlobalScope)\n) {\n throw new Error("This script can only loaded in a webworker");\n}\n\nasync function executeEsModule(content) {\n const dataUri =\n "data:text/javascript;charset=utf-8," + encodeURIComponent(content);\n await import(/* webpackIgnore: true */ dataUri);\n}\n\n/**\n * Connection object provided to the RPC constructor,\n * plugin site implementation for the web-based environment.\n * Global will be then cleared to prevent exposure into the\n * Worker, so we put this local connection object into a closure\n */\nclass Connection extends _utils_js__WEBPACK_IMPORTED_MODULE_2__["MessageEmitter"] {\n constructor(config) {\n super(config && config.debug);\n this.config = config || {};\n }\n connect() {\n self.addEventListener("message", e => {\n this._fire(e.data.type, e.data);\n });\n this.emit({\n type: "initialized",\n config: this.config\n });\n }\n disconnect() {\n this._fire("beforeDisconnect");\n self.close();\n this._fire("disconnected");\n }\n emit(data) {\n let transferables = undefined;\n if (data.__transferables__) {\n transferables = data.__transferables__;\n delete data.__transferables__;\n }\n self.postMessage(data, transferables);\n }\n async execute(code) {\n if (code.type === "requirements") {\n await Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__["loadRequirementsInWebworker"])(code.requirements);\n } else if (code.type === "script") {\n try {\n if (code.attrs.type === "module") {\n await executeEsModule(code.content);\n } else {\n eval(code.content);\n }\n } catch (e) {\n console.error(e.message, e.stack);\n throw e;\n }\n } else {\n throw "unsupported code type.";\n }\n if (code.type === "requirements") {\n self.postMessage({\n type: "cacheRequirements",\n requirements: code.requirements\n });\n }\n }\n}\nconst config = {\n type: "web-worker",\n dedicated_thread: true,\n allow_execution: true,\n lang: "javascript",\n api_version: _rpc_js__WEBPACK_IMPORTED_MODULE_1__["API_VERSION"]\n};\nconst conn = new Connection(config);\nconn.on("connectRPC", data => {\n Object(_pluginCore_js__WEBPACK_IMPORTED_MODULE_0__["connectRPC"])(conn, Object.assign(data.config, config));\n});\nconn.connect();\nself.postMessage({\n type: "worker-ready"\n});\n\n\n/***/ }),\n\n/***/ "./src/pluginCore.js":\n/*!***************************!*\\\n !*** ./src/pluginCore.js ***!\n \\***************************/\n/*! exports provided: connectRPC */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "connectRPC", function() { return connectRPC; });\n/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.js */ "./src/rpc.js");\n/**\n * Core plugin script loaded into the plugin process/thread.\n *\n * Initializes the plugin-site API global methods.\n */\n\nfunction connectRPC(connection, config) {\n config = config || {};\n const codecs = {};\n const rpc = new _rpc_js__WEBPACK_IMPORTED_MODULE_0__["RPC"](connection, config, codecs);\n rpc.on("getInterface", function () {\n launchConnected();\n });\n rpc.on("remoteReady", function () {\n const api = rpc.getRemote() || {};\n\n api.registerCodec = function (config) {\n if (!config["name"] || !config["encoder"] && !config["decoder"]) {\n throw new Error("Invalid codec format, please make sure you provide a name, type, encoder and decoder.");\n } else {\n if (config.type) {\n for (let k of Object.keys(codecs)) {\n if (codecs[k].type === config.type || k === config.name) {\n delete codecs[k];\n console.warn("Remove duplicated codec: " + k);\n }\n }\n }\n\n codecs[config["name"]] = config;\n }\n };\n\n api.init = function (config) {\n // register a minimal plugin api\n rpc.setInterface({\n setup() {}\n\n }, config);\n };\n\n api.disposeObject = function (obj) {\n rpc.disposeObject(obj);\n };\n\n api.export = function (_interface, config) {\n rpc.setInterface(_interface, config);\n };\n\n api.onLoad = function (handler) {\n handler = checkHandler(handler);\n\n if (connected) {\n handler();\n } else {\n connectedHandlers.push(handler);\n }\n };\n\n api.dispose = function (_interface) {\n rpc.disconnect();\n };\n\n api._rpc = rpc;\n\n if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {\n self.api = api;\n self.postMessage({\n type: "imjoy_remote_api_ready"\n });\n self.dispatchEvent(new CustomEvent("imjoy_remote_api_ready", {\n detail: api\n }));\n } else if (typeof window) {\n window.dispatchEvent(new CustomEvent("imjoy_remote_api_ready", {\n detail: api\n }));\n }\n });\n let connected = false;\n const connectedHandlers = [];\n\n const launchConnected = function () {\n if (!connected) {\n connected = true;\n let handler;\n\n while (handler = connectedHandlers.pop()) {\n handler();\n }\n }\n };\n\n const checkHandler = function (handler) {\n const type = typeof handler;\n\n if (type !== "function") {\n const msg = "A function may only be subsribed to the event, " + type + " was provided instead";\n throw new Error(msg);\n }\n\n return handler;\n };\n\n return rpc;\n}\n\n/***/ }),\n\n/***/ "./src/rpc.js":\n/*!********************!*\\\n !*** ./src/rpc.js ***!\n \\********************/\n/*! exports provided: API_VERSION, RPC */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "API_VERSION", function() { return API_VERSION; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RPC", function() { return RPC; });\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./src/utils.js");\n/**\n * Contains the RPC object used both by the application\n * site, and by each plugin\n */\n\nconst API_VERSION = "0.2.3";\nconst ArrayBufferView = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())).constructor;\n\nfunction _appendBuffer(buffer1, buffer2) {\n const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);\n tmp.set(new Uint8Array(buffer1), 0);\n tmp.set(new Uint8Array(buffer2), buffer1.byteLength);\n return tmp.buffer;\n}\n\nfunction indexObject(obj, is) {\n if (!is) throw new Error("undefined index");\n if (typeof is === "string") return indexObject(obj, is.split("."));else if (is.length === 0) return obj;else return indexObject(obj[is[0]], is.slice(1));\n}\n/**\n * RPC object represents a single site in the\n * communication protocol between the application and the plugin\n *\n * @param {Object} connection a special object allowing to send\n * and receive messages from the opposite site (basically it\n * should only provide send() and onMessage() methods)\n */\n\n\nclass RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__["MessageEmitter"] {\n constructor(connection, config, codecs) {\n super(config && config.debug);\n this._connection = connection;\n this.config = config || {};\n this._codecs = codecs || {};\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._remote_set = false; // make sure there is an execute function\n\n const name = this.config.name;\n\n this._connection.execute = this._connection.execute || function () {\n throw new Error(`connection.execute not implemented (in "${name}")`);\n };\n\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n\n this._method_refs.onReady(() => {\n this._fire("remoteIdle");\n });\n\n this._method_refs.onBusy(() => {\n this._fire("remoteBusy");\n });\n\n this._setupMessageHanlders();\n }\n\n init() {\n this._connection.emit({\n type: "initialized",\n config: this.config,\n peer_id: this._connection.peer_id\n });\n }\n\n setConfig(config) {\n if (config) for (const k of Object.keys(config)) {\n this.config[k] = config[k];\n }\n }\n /**\n * Set a handler to be called when received a responce from the\n * remote site reporting that the previously provided interface\n * has been successfully set as remote for that site\n *\n * @param {Function} handler\n */\n\n\n getRemoteCallStack() {\n return this._method_refs.getStack();\n }\n /**\n * @returns {Object} set of remote interface methods\n */\n\n\n getRemote() {\n return this._remote_interface;\n }\n /**\n * Sets the interface of this site making it available to the\n * remote site by sending a message with a set of methods names\n *\n * @param {Object} _interface to set\n */\n\n\n setInterface(_interface, config) {\n config = config || {};\n this.config.name = config.name || this.config.name;\n this.config.description = config.description || this.config.description;\n\n if (this.config.forwarding_functions) {\n for (let func_name of this.config.forwarding_functions) {\n const _remote = this._remote_interface;\n\n if (_remote[func_name]) {\n if (_interface.constructor === Object) {\n if (!_interface[func_name]) {\n _interface[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n } else if (_interface.constructor.constructor === Function) {\n if (!_interface.constructor.prototype[func_name]) {\n _interface.constructor.prototype[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n }\n }\n }\n }\n\n this._local_api = _interface;\n if (!this._remote_set) this._fire("interfaceAvailable");else this.sendInterface();\n return new Promise(resolve => {\n this.once("interfaceSetAsRemote", resolve);\n });\n }\n /**\n * Sends the actual interface to the remote site upon it was\n * updated or by a special request of the remote site\n */\n\n\n sendInterface() {\n if (!this._local_api) {\n throw new Error("interface is not set.");\n }\n\n this._encode(this._local_api, true).then(api => {\n this._connection.emit({\n type: "setInterface",\n api: api\n });\n });\n }\n\n _disposeObject(objectId) {\n if (this._object_store[objectId]) {\n delete this._object_store[objectId];\n } else {\n throw new Error(`Object (id=${objectId}) not found.`);\n }\n }\n\n disposeObject(obj) {\n return new Promise((resolve, reject) => {\n if (this._object_weakmap.has(obj)) {\n const objectId = this._object_weakmap.get(obj);\n\n this._connection.once("disposed", data => {\n if (data.error) reject(new Error(data.error));else resolve();\n });\n\n this._connection.emit({\n type: "disposeObject",\n object_id: objectId\n });\n } else {\n throw new Error("Invalid object");\n }\n });\n }\n /**\n * Handles a message from the remote site\n */\n\n\n _setupMessageHanlders() {\n this._connection.on("init", this.init);\n\n this._connection.on("execute", data => {\n Promise.resolve(this._connection.execute(data.code)).then(() => {\n this._connection.emit({\n type: "executed"\n });\n }).catch(e => {\n console.error(e);\n\n this._connection.emit({\n type: "executed",\n error: String(e)\n });\n });\n });\n\n this._connection.on("method", async data => {\n let resolve, reject, method, method_this, args, result;\n\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n\n const _interface = this._object_store[data.object_id];\n method = indexObject(_interface, data.name);\n\n if (data.name.includes(".")) {\n const tmp = data.name.split(".");\n const intf_index = tmp.slice(0, tmp.length - 1).join(".");\n method_this = indexObject(_interface, intf_index);\n } else {\n method_this = _interface;\n }\n\n args = await this._unwrap(data.args, true);\n\n if (data.promise) {\n result = method.apply(method_this, args);\n\n if (result instanceof Promise || method.constructor && method.constructor.name === "AsyncFunction") {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method.apply(method_this, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n\n if (reject) {\n reject(err);\n }\n }\n });\n\n this._connection.on("callback", async data => {\n let resolve, reject, method, args, result;\n\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n\n if (data.promise) {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n\n if (!method) {\n throw new Error("Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");\n }\n\n result = method.apply(null, args);\n\n if (result instanceof Promise || method.constructor && method.constructor.name === "AsyncFunction") {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n\n if (!method) {\n throw new Error("Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");\n }\n\n method.apply(null, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n\n if (reject) {\n reject(err);\n }\n }\n });\n\n this._connection.on("disposeObject", data => {\n try {\n this._disposeObject(data.object_id);\n\n this._connection.emit({\n type: "disposed"\n });\n } catch (e) {\n console.error(e);\n\n this._connection.emit({\n type: "disposed",\n error: String(e)\n });\n }\n });\n\n this._connection.on("setInterface", data => {\n this._setRemoteInterface(data.api);\n });\n\n this._connection.on("getInterface", () => {\n this._fire("getInterface");\n\n if (this._local_api) {\n this.sendInterface();\n } else {\n this.once("interfaceAvailable", () => {\n this.sendInterface();\n });\n }\n });\n\n this._connection.on("interfaceSetAsRemote", () => {\n this._remote_set = true;\n\n this._fire("interfaceSetAsRemote");\n });\n\n this._connection.on("disconnect", () => {\n this._fire("beforeDisconnect");\n\n this._connection.disconnect();\n\n this._fire("disconnected");\n });\n }\n /**\n * Sends a requests to the remote site asking it to provide its\n * current interface\n */\n\n\n requestRemote() {\n this._connection.emit({\n type: "getInterface"\n });\n }\n\n _ndarray(typedArray, shape, dtype) {\n const _dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["typedArrayToDtype"])(typedArray);\n\n if (dtype && dtype !== _dtype) {\n throw "dtype doesn\'t match the type of the array: " + _dtype + " != " + dtype;\n }\n\n shape = shape || [typedArray.length];\n return {\n _rtype: "ndarray",\n _rvalue: typedArray.buffer,\n _rshape: shape,\n _rdtype: _dtype\n };\n }\n /**\n * Sets the new remote interface provided by the other site\n *\n * @param {Array} names list of function names\n */\n\n\n _setRemoteInterface(api) {\n this._decode(api).then(intf => {\n // update existing interface instead of recreating it\n // this will preserve the object reference\n if (this._remote_interface) {\n // clear the interface\n for (let k in this._remote_interface) delete this._remote_interface[k]; // then assign the new interfaces\n\n\n Object.assign(this._remote_interface, intf);\n } else this._remote_interface = intf;\n\n this._fire("remoteReady");\n\n this._reportRemoteSet();\n });\n }\n /**\n * Generates the wrapped function corresponding to a single remote\n * method. When the generated function is called, it will send the\n * corresponding message to the remote site asking it to execute\n * the particular method of its interface\n *\n * @param {String} name of the remote method\n *\n * @returns {Function} wrapped remote method\n */\n\n\n _genRemoteMethod(targetId, name, objectId) {\n const me = this;\n\n const remoteMethod = function () {\n return new Promise(async (resolve, reject) => {\n let id = null;\n\n try {\n id = me._method_refs.put(objectId ? objectId + "/" + name : name);\n\n const wrapped_resolve = function () {\n if (id !== null) me._method_refs.fetch(id);\n return resolve.apply(this, arguments);\n };\n\n const wrapped_reject = function () {\n if (id !== null) me._method_refs.fetch(id);\n return reject.apply(this, arguments);\n };\n\n const encodedPromise = await me._wrap([wrapped_resolve, wrapped_reject]); // store the key id for removing them from the reference store together\n\n wrapped_resolve.__promise_pair = encodedPromise[1]._rvalue;\n wrapped_reject.__promise_pair = encodedPromise[0]._rvalue;\n let args = Array.prototype.slice.call(arguments);\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\n\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === "object" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n\n if (name === "register" || name === "registerService" || name === "register_service" || name === "export" || name === "on") {\n args = await me._wrap(args, true);\n } else {\n args = await me._wrap(args);\n }\n\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n\n me._connection.emit({\n type: "method",\n target_id: targetId,\n name: name,\n object_id: objectId,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n }, transferables);\n } catch (e) {\n if (id) me._method_refs.fetch(id);\n reject(`Failed to exectue remote method (interface: ${objectId || me.id}, method: ${name}), error: ${e}`);\n }\n });\n };\n\n remoteMethod.__remote_method = true;\n return remoteMethod;\n }\n /**\n * Sends a responce reporting that interface just provided by the\n * remote site was successfully set by this site as remote\n */\n\n\n _reportRemoteSet() {\n this._connection.emit({\n type: "interfaceSetAsRemote"\n });\n }\n /**\n * Prepares the provided set of remote method arguments for\n * sending to the remote site, replaces all the callbacks with\n * identifiers\n *\n * @param {Array} args to wrap\n *\n * @returns {Array} wrapped arguments\n */\n\n\n async _encode(aObject, asInterface, objectId) {\n const aType = typeof aObject;\n\n if (aType === "number" || aType === "string" || aType === "boolean" || aObject === null || aObject === undefined || aObject instanceof ArrayBuffer) {\n return aObject;\n }\n\n let bObject;\n\n if (typeof aObject === "function") {\n if (asInterface) {\n if (!objectId) throw new Error("objectId is not specified.");\n bObject = {\n _rtype: "interface",\n _rtarget_id: this._connection.peer_id,\n _rintf: objectId,\n _rvalue: asInterface\n };\n\n this._method_weakmap.set(aObject, bObject);\n } else if (this._method_weakmap.has(aObject)) {\n bObject = this._method_weakmap.get(aObject);\n } else {\n const cid = this._store.put(aObject);\n\n bObject = {\n _rtype: "callback",\n _rtarget_id: this._connection.peer_id,\n _rname: aObject.constructor && aObject.constructor.name || cid,\n _rvalue: cid\n };\n }\n\n return bObject;\n } // skip if already encoded\n\n\n if (aObject.constructor instanceof Object && aObject._rtype) {\n // make sure the interface functions are encoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._encode(aObject, asInterface, objectId);\n bObject._rtype = temp;\n } else {\n bObject = aObject;\n }\n\n return bObject;\n }\n\n const transferables = [];\n const _transfer = aObject._transfer;\n const isarray = Array.isArray(aObject);\n\n for (let tp of Object.keys(this._codecs)) {\n const codec = this._codecs[tp];\n\n if (codec.encoder && aObject instanceof codec.type) {\n // TODO: what if multiple encoders found\n let encodedObj = await Promise.resolve(codec.encoder(aObject));\n if (encodedObj && !encodedObj._rtype) encodedObj._rtype = codec.name; // encode the functions in the interface object\n\n if (encodedObj && encodedObj._rintf) {\n const temp = encodedObj._rtype;\n delete encodedObj._rtype;\n encodedObj = await this._encode(encodedObj, asInterface, objectId);\n encodedObj._rtype = temp;\n }\n\n bObject = encodedObj;\n return bObject;\n }\n }\n\n if (\n /*global tf*/\n typeof tf !== "undefined" && tf.Tensor && aObject instanceof tf.Tensor) {\n const v_buffer = aObject.dataSync();\n\n if (aObject._transfer || _transfer) {\n transferables.push(v_buffer.buffer);\n delete aObject._transfer;\n }\n\n bObject = {\n _rtype: "ndarray",\n _rvalue: v_buffer.buffer,\n _rshape: aObject.shape,\n _rdtype: aObject.dtype\n };\n } else if (\n /*global nj*/\n typeof nj !== "undefined" && nj.NdArray && aObject instanceof nj.NdArray) {\n const dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["typedArrayToDtype"])(aObject.selection.data);\n\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.selection.data.buffer);\n delete aObject._transfer;\n }\n\n bObject = {\n _rtype: "ndarray",\n _rvalue: aObject.selection.data.buffer,\n _rshape: aObject.shape,\n _rdtype: dtype\n };\n } else if (aObject instanceof Error) {\n console.error(aObject);\n bObject = {\n _rtype: "error",\n _rvalue: aObject.toString()\n };\n } else if (typeof File !== "undefined" && aObject instanceof File) {\n bObject = {\n _rtype: "file",\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n } // send objects supported by structure clone algorithm\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n else if (aObject !== Object(aObject) || aObject instanceof Boolean || aObject instanceof String || aObject instanceof Date || aObject instanceof RegExp || aObject instanceof ImageData || typeof FileList !== "undefined" && aObject instanceof FileList || typeof FileSystemDirectoryHandle !== "undefined" && aObject instanceof FileSystemDirectoryHandle || typeof FileSystemFileHandle !== "undefined" && aObject instanceof FileSystemFileHandle || typeof FileSystemHandle !== "undefined" && aObject instanceof FileSystemHandle || typeof FileSystemWritableFileStream !== "undefined" && aObject instanceof FileSystemWritableFileStream) {\n bObject = aObject; // TODO: avoid object such as DynamicPlugin instance.\n } else if (typeof File !== "undefined" && aObject instanceof File) {\n bObject = {\n _rtype: "file",\n _rname: aObject.name,\n _rmime: aObject.type,\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n } else if (aObject instanceof Blob) {\n bObject = {\n _rtype: "blob",\n _rvalue: aObject\n };\n } else if (aObject instanceof ArrayBufferView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n\n const dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["typedArrayToDtype"])(aObject);\n bObject = {\n _rtype: "typedarray",\n _rvalue: aObject.buffer,\n _rdtype: dtype\n };\n } else if (aObject instanceof DataView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n\n bObject = {\n _rtype: "memoryview",\n _rvalue: aObject.buffer\n };\n } else if (aObject instanceof Set) {\n bObject = {\n _rtype: "set",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (aObject instanceof Map) {\n bObject = {\n _rtype: "orderedmap",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (aObject.constructor instanceof Object || Array.isArray(aObject)) {\n bObject = isarray ? [] : {};\n let keys; // an object/array\n\n if (aObject.constructor === Object || Array.isArray(aObject)) {\n keys = Object.keys(aObject);\n } // a class\n else if (aObject.constructor === Function) {\n throw new Error("Please instantiate the class before exportting it.");\n } // instance of a class\n else if (aObject.constructor.constructor === Function) {\n keys = Object.getOwnPropertyNames(Object.getPrototypeOf(aObject)).concat(Object.keys(aObject)); // TODO: use a proxy object to represent the actual object\n // always encode class instance as interface\n\n asInterface = true;\n } else {\n throw Error("Unsupported interface type");\n }\n\n let hasFunction = false; // encode interfaces\n\n if (aObject._rintf || asInterface) {\n if (!objectId) {\n if (typeof aObject._rintf === "string" && aObject._rintf.length > 0) {\n objectId = aObject._rintf; // enable custom object id\n } else {\n objectId = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["randId"])();\n } // Note: object with the same id will be overwritten\n\n\n if (this._object_store[objectId]) console.warn(`Overwritting interface object with the same id: ${objectId}`);\n this._object_store[objectId] = aObject;\n }\n\n for (let k of keys) {\n if (k === "constructor") continue;\n\n if (k.startsWith("_")) {\n continue;\n }\n\n bObject[k] = await this._encode(aObject[k], typeof asInterface === "string" ? asInterface + "." + k : k, objectId);\n\n if (typeof aObject[k] === "function") {\n hasFunction = true;\n }\n } // object id for dispose the object remotely\n\n\n if (hasFunction) bObject._rintf = objectId; // remove interface when closed\n\n if (aObject.on && typeof aObject.on === "function") {\n aObject.on("close", () => {\n delete this._object_store[objectId];\n });\n }\n } else {\n for (let k of keys) {\n if (["hasOwnProperty", "constructor"].includes(k)) continue;\n bObject[k] = await this._encode(aObject[k]);\n }\n } // for example, browserFS object\n\n } else if (typeof aObject === "object") {\n const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(aObject)).concat(Object.keys(aObject));\n const objectId = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__["randId"])();\n\n for (let k of keys) {\n if (["hasOwnProperty", "constructor"].includes(k)) continue; // encode as interface\n\n bObject[k] = await this._encode(aObject[k], k, bObject);\n } // object id, used for dispose the object\n\n\n bObject._rintf = objectId;\n } else {\n throw "imjoy-rpc: Unsupported data type:" + aObject;\n }\n\n if (transferables.length > 0) {\n bObject.__transferables__ = transferables;\n }\n\n if (!bObject) {\n throw new Error("Failed to encode object");\n }\n\n return bObject;\n }\n\n async _decode(aObject, withPromise) {\n if (!aObject) {\n return aObject;\n }\n\n let bObject;\n\n if (aObject["_rtype"]) {\n if (this._codecs[aObject._rtype] && this._codecs[aObject._rtype].decoder) {\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n aObject = await this._decode(aObject, withPromise);\n aObject._rtype = temp;\n }\n\n bObject = await Promise.resolve(this._codecs[aObject._rtype].decoder(aObject));\n } else if (aObject._rtype === "callback") {\n bObject = this._genRemoteCallback(aObject._rtarget_id, aObject._rvalue, withPromise);\n } else if (aObject._rtype === "interface") {\n bObject = this._genRemoteMethod(aObject._rtarget_id, aObject._rvalue, aObject._rintf);\n } else if (aObject._rtype === "ndarray") {\n /*global nj tf*/\n //create build array/tensor if used in the plugin\n if (typeof nj !== "undefined" && nj.array) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n\n bObject = nj.array(new Uint8(aObject._rvalue), aObject._rdtype).reshape(aObject._rshape);\n } else if (typeof tf !== "undefined" && tf.Tensor) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n\n const arraytype = _utils_js__WEBPACK_IMPORTED_MODULE_0__["dtypeToTypedArray"][aObject._rdtype];\n bObject = tf.tensor(new arraytype(aObject._rvalue), aObject._rshape, aObject._rdtype);\n } else {\n //keep it as regular if transfered to the main app\n bObject = aObject;\n }\n } else if (aObject._rtype === "error") {\n bObject = new Error(aObject._rvalue);\n } else if (aObject._rtype === "file") {\n if (aObject._rvalue instanceof File) {\n bObject = aObject._rvalue; //patch _path\n\n bObject._path = aObject._rpath;\n } else {\n bObject = new File([aObject._rvalue], aObject._rname, {\n type: aObject._rmime\n });\n bObject._path = aObject._rpath;\n }\n } else if (aObject._rtype === "typedarray") {\n const arraytype = _utils_js__WEBPACK_IMPORTED_MODULE_0__["dtypeToTypedArray"][aObject._rdtype];\n if (!arraytype) throw new Error("unsupported dtype: " + aObject._rdtype);\n bObject = new arraytype(aObject._rvalue);\n } else if (aObject._rtype === "memoryview") {\n bObject = new DataView(aObject._rvalue);\n } else if (aObject._rtype === "blob") {\n if (aObject._rvalue instanceof Blob) {\n bObject = aObject._rvalue;\n } else {\n bObject = new Blob([aObject._rvalue], {\n type: aObject._rmime\n });\n }\n } else if (aObject._rtype === "orderedmap") {\n bObject = new Map(await this._decode(aObject._rvalue, withPromise));\n } else if (aObject._rtype === "set") {\n bObject = new Set(await this._decode(aObject._rvalue, withPromise));\n } else {\n // make sure all the interface functions are decoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._decode(aObject, withPromise);\n bObject._rtype = temp;\n } else bObject = aObject;\n }\n } else if (aObject.constructor === Object || Array.isArray(aObject)) {\n const isarray = Array.isArray(aObject);\n bObject = isarray ? [] : {};\n\n for (let k of Object.keys(aObject)) {\n if (isarray || aObject.hasOwnProperty(k)) {\n const v = aObject[k];\n bObject[k] = await this._decode(v, withPromise);\n }\n }\n } else {\n bObject = aObject;\n }\n\n if (bObject === undefined) {\n throw new Error("Failed to decode object");\n } // store the object id for dispose\n\n\n if (aObject._rintf) {\n this._object_weakmap.set(bObject, aObject._rintf);\n }\n\n return bObject;\n }\n\n async _wrap(args, asInterface) {\n return await this._encode(args, asInterface);\n }\n /**\n * Unwraps the set of arguments delivered from the remote site,\n * replaces all callback identifiers with a function which will\n * initiate sending that callback identifier back to other site\n *\n * @param {Object} args to unwrap\n *\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Array} unwrapped args\n */\n\n\n async _unwrap(args, withPromise) {\n return await this._decode(args, withPromise);\n }\n /**\n * Generates the wrapped function corresponding to a single remote\n * callback. When the generated function is called, it will send\n * the corresponding message to the remote site asking it to\n * execute the particular callback previously saved during a call\n * by the remote site a method from the interface of this site\n *\n * @param {Number} id of the remote callback to execute\n * @param {Number} argNum argument index of the callback\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Function} wrapped remote callback\n */\n\n\n _genRemoteCallback(targetId, cid, withPromise) {\n const me = this;\n let remoteCallback;\n\n if (withPromise) {\n remoteCallback = function () {\n return new Promise(async (resolve, reject) => {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\n\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === "object" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n const encodedPromise = await me._wrap([resolve, reject]); // store the key id for removing them from the reference store together\n\n resolve.__promise_pair = encodedPromise[1]._rvalue;\n reject.__promise_pair = encodedPromise[0]._rvalue;\n\n try {\n me._connection.emit({\n type: "callback",\n target_id: targetId,\n id: cid,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n }, transferables);\n } catch (e) {\n reject(`Failed to exectue remote callback ( id: ${cid}).`);\n }\n });\n };\n\n return remoteCallback;\n } else {\n remoteCallback = async function () {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\n\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === "object" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n return me._connection.emit({\n type: "callback",\n target_id: targetId,\n id: cid,\n args: args,\n with_kwargs: withKwargs\n }, transferables);\n };\n\n return remoteCallback;\n }\n }\n\n reset() {\n this._event_handlers = {};\n this._once_handlers = {};\n this._remote_interface = null;\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n }\n /**\n * Sends the notification message and breaks the connection\n */\n\n\n disconnect() {\n this._connection.emit({\n type: "disconnect"\n });\n\n this.reset();\n setTimeout(() => {\n this._connection.disconnect();\n }, 2000);\n }\n\n}\n/**\n * ReferenceStore is a special object which stores other objects\n * and provides the references (number) instead. This reference\n * may then be sent over a json-based communication channel (IPC\n * to another Node.js process or a message to the Worker). Other\n * site may then provide the reference in the responce message\n * implying the given object should be activated.\n *\n * Primary usage for the ReferenceStore is a storage for the\n * callbacks, which therefore makes it possible to initiate a\n * callback execution by the opposite site (which normally cannot\n * directly execute functions over the communication channel).\n *\n * Each stored object can only be fetched once and is not\n * available for the second time. Each stored object must be\n * fetched, since otherwise it will remain stored forever and\n * consume memory.\n *\n * Stored object indeces are simply the numbers, which are however\n * released along with the objects, and are later reused again (in\n * order to postpone the overflow, which should not likely happen,\n * but anyway).\n */\n\nclass ReferenceStore {\n constructor() {\n this._store = {}; // stored object\n\n this._indices = [0]; // smallest available indices\n\n this._readyHandler = function () {};\n\n this._busyHandler = function () {};\n\n this._readyHandler();\n }\n /**\n * call handler when the store is empty\n *\n * @param {FUNCTION} id of a handler\n */\n\n\n onReady(readyHandler) {\n this._readyHandler = readyHandler || function () {};\n }\n /**\n * call handler when the store is not empty\n *\n * @param {FUNCTION} id of a handler\n */\n\n\n onBusy(busyHandler) {\n this._busyHandler = busyHandler || function () {};\n }\n /**\n * get the length of the store\n *\n */\n\n\n getStack() {\n return Object.keys(this._store).length;\n }\n /**\n * @function _genId() generates the new reference id\n *\n * @returns {Number} smallest available id and reserves it\n */\n\n\n _genId() {\n let id;\n\n if (this._indices.length === 1) {\n id = this._indices[0]++;\n } else {\n id = this._indices.shift();\n }\n\n return id;\n }\n /**\n * Releases the given reference id so that it will be available by\n * another object stored\n *\n * @param {Number} id to release\n */\n\n\n _releaseId(id) {\n for (let i = 0; i < this._indices.length; i++) {\n if (id < this._indices[i]) {\n this._indices.splice(i, 0, id);\n\n break;\n }\n } // cleaning-up the sequence tail\n\n\n for (let i = this._indices.length - 1; i >= 0; i--) {\n if (this._indices[i] - 1 === this._indices[i - 1]) {\n this._indices.pop();\n } else {\n break;\n }\n }\n }\n /**\n * Stores the given object and returns the refernce id instead\n *\n * @param {Object} obj to store\n *\n * @returns {Number} reference id of the stored object\n */\n\n\n put(obj) {\n if (this._busyHandler && Object.keys(this._store).length === 0) {\n this._busyHandler();\n }\n\n const id = this._genId();\n\n this._store[id] = obj;\n return id;\n }\n /**\n * Retrieves previously stored object and releases its reference\n *\n * @param {Number} id of an object to retrieve\n */\n\n\n fetch(id) {\n const obj = this._store[id];\n\n if (obj && !obj.__remote_method) {\n delete this._store[id];\n\n this._releaseId(id);\n\n if (this._readyHandler && Object.keys(this._store).length === 0) {\n this._readyHandler();\n }\n }\n\n if (obj && obj.__promise_pair) {\n this.fetch(obj.__promise_pair);\n }\n\n return obj;\n }\n\n}\n\n/***/ }),\n\n/***/ "./src/utils.js":\n/*!**********************!*\\\n !*** ./src/utils.js ***!\n \\**********************/\n/*! exports provided: randId, dtypeToTypedArray, loadRequirementsInWindow, loadRequirementsInWebworker, loadRequirements, normalizeConfig, typedArrayToDtypeMapping, typedArrayToDtype, cacheRequirements, setupServiceWorker, urlJoin, MessageEmitter */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n"use strict";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "randId", function() { return randId; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dtypeToTypedArray", function() { return dtypeToTypedArray; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadRequirementsInWindow", function() { return loadRequirementsInWindow; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadRequirementsInWebworker", function() { return loadRequirementsInWebworker; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadRequirements", function() { return loadRequirements; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalizeConfig", function() { return normalizeConfig; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "typedArrayToDtypeMapping", function() { return typedArrayToDtypeMapping; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "typedArrayToDtype", function() { return typedArrayToDtype; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cacheRequirements", function() { return cacheRequirements; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupServiceWorker", function() { return setupServiceWorker; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "urlJoin", function() { return urlJoin; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MessageEmitter", function() { return MessageEmitter; });\nfunction randId() {\n return Math.random().toString(36).substr(2, 10) + new Date().getTime();\n}\nconst dtypeToTypedArray = {\n int8: Int8Array,\n int16: Int16Array,\n int32: Int32Array,\n uint8: Uint8Array,\n uint16: Uint16Array,\n uint32: Uint32Array,\n float32: Float32Array,\n float64: Float64Array,\n array: Array\n};\nasync function loadRequirementsInWindow(requirements) {\n function _importScript(url) {\n //url is URL of external file, implementationCode is the code\n //to be called from the file, location is the location to\n //insert the <script> element\n return new Promise((resolve, reject) => {\n var scriptTag = document.createElement("script");\n scriptTag.src = url;\n scriptTag.type = "text/javascript";\n scriptTag.onload = resolve;\n\n scriptTag.onreadystatechange = function () {\n if (this.readyState === "loaded" || this.readyState === "complete") {\n resolve();\n }\n };\n\n scriptTag.onerror = reject;\n document.head.appendChild(scriptTag);\n });\n } // support importScripts outside web worker\n\n\n async function importScripts() {\n var args = Array.prototype.slice.call(arguments),\n len = args.length,\n i = 0;\n\n for (; i < len; i++) {\n await _importScript(args[i]);\n }\n }\n\n if (requirements && (Array.isArray(requirements) || typeof requirements === "string")) {\n try {\n var link_node;\n requirements = typeof requirements === "string" ? [requirements] : requirements;\n\n if (Array.isArray(requirements)) {\n for (var i = 0; i < requirements.length; i++) {\n if (requirements[i].toLowerCase().endsWith(".css") || requirements[i].startsWith("css:")) {\n if (requirements[i].startsWith("css:")) {\n requirements[i] = requirements[i].slice(4);\n }\n\n link_node = document.createElement("link");\n link_node.rel = "stylesheet";\n link_node.href = requirements[i];\n document.head.appendChild(link_node);\n } else if (requirements[i].toLowerCase().endsWith(".mjs") || requirements[i].startsWith("mjs:")) {\n // import esmodule\n if (requirements[i].startsWith("mjs:")) {\n requirements[i] = requirements[i].slice(4);\n }\n\n await import(\n /* webpackIgnore: true */\n requirements[i]);\n } else if (requirements[i].toLowerCase().endsWith(".js") || requirements[i].startsWith("js:")) {\n if (requirements[i].startsWith("js:")) {\n requirements[i] = requirements[i].slice(3);\n }\n\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith("http")) {\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith("cache:")) {//ignore cache\n } else {\n console.log("Unprocessed requirements url: " + requirements[i]);\n }\n }\n } else {\n throw "unsupported requirements definition";\n }\n } catch (e) {\n throw "failed to import required scripts: " + requirements.toString();\n }\n }\n}\nasync function loadRequirementsInWebworker(requirements) {\n if (requirements && (Array.isArray(requirements) || typeof requirements === "string")) {\n try {\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n\n for (var i = 0; i < requirements.length; i++) {\n if (requirements[i].toLowerCase().endsWith(".css") || requirements[i].startsWith("css:")) {\n throw "unable to import css in a webworker";\n } else if (requirements[i].toLowerCase().endsWith(".js") || requirements[i].startsWith("js:")) {\n if (requirements[i].startsWith("js:")) {\n requirements[i] = requirements[i].slice(3);\n }\n\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith("http")) {\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith("cache:")) {//ignore cache\n } else {\n console.log("Unprocessed requirements url: " + requirements[i]);\n }\n }\n } catch (e) {\n throw "failed to import required scripts: " + requirements.toString();\n }\n }\n}\nfunction loadRequirements(requirements) {\n if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) {\n return loadRequirementsInWebworker(requirements);\n } else {\n return loadRequirementsInWindow(requirements);\n }\n}\nfunction normalizeConfig(config) {\n config.version = config.version || "0.1.0";\n config.description = config.description || `[TODO: add description for ${config.name} ]`;\n config.type = config.type || "rpc-window";\n config.id = config.id || randId();\n config.target_origin = config.target_origin || "*";\n config.allow_execution = config.allow_execution || false; // remove functions\n\n config = Object.keys(config).reduce((p, c) => {\n if (typeof config[c] !== "function") p[c] = config[c];\n return p;\n }, {});\n return config;\n}\nconst typedArrayToDtypeMapping = {\n Int8Array: "int8",\n Int16Array: "int16",\n Int32Array: "int32",\n Uint8Array: "uint8",\n Uint16Array: "uint16",\n Uint32Array: "uint32",\n Float32Array: "float32",\n Float64Array: "float64",\n Array: "array"\n};\nconst typedArrayToDtypeKeys = [];\n\nfor (const arrType of Object.keys(typedArrayToDtypeMapping)) {\n typedArrayToDtypeKeys.push(eval(arrType));\n}\n\nfunction typedArrayToDtype(obj) {\n let dtype = typedArrayToDtypeMapping[obj.constructor.name];\n\n if (!dtype) {\n const pt = Object.getPrototypeOf(obj);\n\n for (const arrType of typedArrayToDtypeKeys) {\n if (pt instanceof arrType) {\n dtype = typedArrayToDtypeMapping[arrType.name];\n break;\n }\n }\n }\n\n return dtype;\n}\n\nfunction cacheUrlInServiceWorker(url) {\n return new Promise(function (resolve, reject) {\n const message = {\n command: "add",\n url: url\n };\n\n if (!navigator.serviceWorker || !navigator.serviceWorker.register) {\n reject("Service worker is not supported.");\n return;\n }\n\n const messageChannel = new MessageChannel();\n\n messageChannel.port1.onmessage = function (event) {\n if (event.data && event.data.error) {\n reject(event.data.error);\n } else {\n resolve(event.data && event.data.result);\n }\n };\n\n if (navigator.serviceWorker && navigator.serviceWorker.controller) {\n navigator.serviceWorker.controller.postMessage(message, [messageChannel.port2]);\n } else {\n reject("Service worker controller is not available");\n }\n });\n}\n\nasync function cacheRequirements(requirements) {\n requirements = requirements || [];\n\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n\n for (let req of requirements) {\n //remove prefix\n if (req.startsWith("js:")) req = req.slice(3);\n if (req.startsWith("css:")) req = req.slice(4);\n if (req.startsWith("cache:")) req = req.slice(6);\n if (!req.startsWith("http")) continue;\n await cacheUrlInServiceWorker(req).catch(e => {\n console.error(e);\n });\n }\n}\nfunction setupServiceWorker(baseUrl, targetOrigin, cacheCallback) {\n // register service worker for offline access\n if ("serviceWorker" in navigator) {\n baseUrl = baseUrl || "/";\n navigator.serviceWorker.register(baseUrl + "plugin-service-worker.js").then(function (registration) {\n // Registration was successful\n console.log("ServiceWorker registration successful with scope: ", registration.scope);\n }, function (err) {\n // registration failed :(\n console.log("ServiceWorker registration failed: ", err);\n });\n targetOrigin = targetOrigin || "*";\n cacheCallback = cacheCallback || cacheRequirements;\n\n if (cacheCallback && typeof cacheCallback !== "function") {\n throw new Error("config.cache_requirements must be a function");\n }\n\n window.addEventListener("message", function (e) {\n if (targetOrigin === "*" || e.origin === targetOrigin) {\n const m = e.data;\n\n if (m.type === "cacheRequirements") {\n cacheCallback(m.requirements);\n }\n }\n });\n }\n} //#Source https://bit.ly/2neWfJ2\n\nfunction urlJoin(...args) {\n return args.join("/").replace(/[\\/]+/g, "/").replace(/^(.+):\\//, "$1://").replace(/^file:/, "file:/").replace(/\\/(\\?|&|#[^!])/g, "$1").replace(/\\?/g, "&").replace("&", "?");\n}\nclass MessageEmitter {\n constructor(debug) {\n this._event_handlers = {};\n this._once_handlers = {};\n this._debug = debug;\n }\n\n emit() {\n throw new Error("emit is not implemented");\n }\n\n on(event, handler) {\n if (!this._event_handlers[event]) {\n this._event_handlers[event] = [];\n }\n\n this._event_handlers[event].push(handler);\n }\n\n once(event, handler) {\n handler.___event_run_once = true;\n this.on(event, handler);\n }\n\n off(event, handler) {\n if (!event && !handler) {\n // remove all events handlers\n this._event_handlers = {};\n } else if (event && !handler) {\n // remove all hanlders for the event\n if (this._event_handlers[event]) this._event_handlers[event] = [];\n } else {\n // remove a specific handler\n if (this._event_handlers[event]) {\n const idx = this._event_handlers[event].indexOf(handler);\n\n if (idx >= 0) {\n this._event_handlers[event].splice(idx, 1);\n }\n }\n }\n }\n\n _fire(event, data) {\n if (this._event_handlers[event]) {\n var i = this._event_handlers[event].length;\n\n while (i--) {\n const handler = this._event_handlers[event][i];\n\n try {\n handler(data);\n } catch (e) {\n console.error(e);\n } finally {\n if (handler.___event_run_once) {\n this._event_handlers[event].splice(i, 1);\n }\n }\n }\n } else {\n if (this._debug) {\n console.warn("unhandled event", event, data);\n }\n }\n }\n\n}\n\n/***/ })\n\n/******/ });\n//# sourceMappingURL=plugin.webworker.js.map',null)}},"./src/pluginCore.js":
/*!***************************!*\
!*** ./src/pluginCore.js ***!
\***************************/
/*! exports provided: connectRPC */function(e,t,n){"use strict";n.r(t),n.d(t,"connectRPC",(function(){return i}));var r=n(/*! ./rpc.js */"./src/rpc.js");function i(e,t){t=t||{};const n={},i=new r.RPC(e,t,n);i.on("getInterface",(function(){a()})),i.on("remoteReady",(function(){const e=i.getRemote()||{};e.registerCodec=function(e){if(!e.name||!e.encoder&&!e.decoder)throw new Error("Invalid codec format, please make sure you provide a name, type, encoder and decoder.");if(e.type)for(let t of Object.keys(n))n[t].type!==e.type&&t!==e.name||(delete n[t],console.warn("Remove duplicated codec: "+t));n[e.name]=e},e.init=function(e){i.setInterface({setup(){}},e)},e.disposeObject=function(e){i.disposeObject(e)},e.export=function(e,t){i.setInterface(e,t)},e.onLoad=function(e){e=c(e),o?e():s.push(e)},e.dispose=function(e){i.disconnect()},e._rpc=i,"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?(self.api=e,self.postMessage({type:"imjoy_remote_api_ready"}),self.dispatchEvent(new CustomEvent("imjoy_remote_api_ready",{detail:e}))):window.dispatchEvent(new CustomEvent("imjoy_remote_api_ready",{detail:e}))}));let o=!1;const s=[],a=function(){if(!o){let e;for(o=!0;e=s.pop();)e()}},c=function(e){const t=typeof e;if("function"!==t)throw new Error("A function may only be subsribed to the event, "+t+" was provided instead");return e};return i}},"./src/pluginIframe.js":
/*!*****************************!*\
!*** ./src/pluginIframe.js ***!
\*****************************/
/*! exports provided: Connection, default */function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"Connection",(function(){return Connection})),__webpack_require__.d(__webpack_exports__,"default",(function(){return setupIframe}));var _pluginCore_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(/*! ./pluginCore.js */"./src/pluginCore.js"),_rpc_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(/*! ./rpc.js */"./src/rpc.js"),_utils_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(/*! ./utils.js */"./src/utils.js");function _htmlToElement(e){var t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild}const _inWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;async function executeEsModule(e){const t="data:text/javascript;charset=utf-8,"+encodeURIComponent(e);await import(t)}class Connection extends _utils_js__WEBPACK_IMPORTED_MODULE_2__.MessageEmitter{constructor(e){super(e&&e.debug),this.config=e||{},this.peer_id=Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__.randId)()}connect(){this.config.target_origin=this.config.target_origin||"*",this.config.broadcastChannel?this.broadcastChannel=new BroadcastChannel(this.config.broadcastChannel):this.broadcastChannel=null,this.broadcastChannel?this.broadcastChannel.addEventListener("message",this):globalThis.addEventListener("message",this),this.emit({type:"initialized",config:this.config,origin:globalThis.location.origin,peer_id:this.peer_id}),this._fire("connected")}handleEvent(e){"message"!==e.type||!this.broadcastChannel&&"*"!==this.config.target_origin&&e.origin&&e.origin!==this.config.target_origin||(e.data.peer_id===this.peer_id?this._fire(e.data.type,e.data):this.config.debug&&console.log(`connection peer id mismatch ${e.data.peer_id} !== ${this.peer_id}`))}disconnect(){this._fire("beforeDisconnect"),globalThis.removeEventListener("message",this),this._fire("disconnected")}emit(e){let t;this.broadcastChannel?this.broadcastChannel.postMessage(e):e.__transferables__?(t=e.__transferables__,delete e.__transferables__):_inWebWorker?self.postMessage(e,t):parent.postMessage(e,this.config.target_origin,t)}async execute(code){try{if("requirements"===code.type)await Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__.loadRequirementsInWindow)(code.requirements);else if("script"===code.type)if(code.src){var script_node=document.createElement("script");script_node.setAttribute("type",code.attrs.type),script_node.setAttribute("src",code.src),document.head.appendChild(script_node)}else if(code.content&&"javascript"===code.attrs.lang)"module"===code.attrs.type?await executeEsModule(code.content):eval(code.content);else{var node=document.createElement("script");for(let e in code.attrs)node.setAttribute(e,code.attrs[e]);node.appendChild(document.createTextNode(code.content)),document.body.appendChild(node)}else if("style"===code.type){const e=document.createElement("style");code.src&&(e.src=code.src),e.innerHTML=code.content,document.head.appendChild(e)}else if("link"===code.type){const e=document.createElement("link");code.rel&&(e.rel=code.rel),code.href&&(e.href=code.href),code.attrs&&code.attrs.type&&(e.type=code.attrs.type),document.head.appendChild(e)}else{if("html"!==code.type)throw"unsupported code type.";document.body.appendChild(_htmlToElement(code.content))}_inWebWorker?self.postMessage({type:"executed"}):parent.postMessage({type:"executed"},this.config.target_origin)}catch(e){console.error("failed to execute scripts: ",code,e),_inWebWorker?self.postMessage({type:"executed",error:e.stack||String(e)}):parent.postMessage({type:"executed",error:e.stack||String(e)},this.config.target_origin)}}}function setupIframe(e){(e=e||{}).dedicated_thread=!1,e.lang="javascript",e.api_version=_rpc_js__WEBPACK_IMPORTED_MODULE_1__.API_VERSION;const t=new Connection(e);Object(_pluginCore_js__WEBPACK_IMPORTED_MODULE_0__.connectRPC)(t,e),t.connect()}},"./src/rpc.js":
/*!********************!*\
!*** ./src/rpc.js ***!
\********************/
/*! exports provided: API_VERSION, RPC */function(e,t,n){"use strict";n.r(t),n.d(t,"API_VERSION",(function(){return i})),n.d(t,"RPC",(function(){return c}));var r=n(/*! ./utils.js */"./src/utils.js");const i="0.2.3",o=Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array)).constructor;function s(e,t){const n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}function a(e,t){if(!t)throw new Error("undefined index");return"string"==typeof t?a(e,t.split(".")):0===t.length?e:a(e[t[0]],t.slice(1))}class c extends r.MessageEmitter{constructor(e,t,n){super(t&&t.debug),this._connection=e,this.config=t||{},this._codecs=n||{},this._object_store={},this._method_weakmap=new WeakMap,this._object_weakmap=new WeakMap,this._local_api=null,this._remote_set=!1;const r=this.config.name;this._connection.execute=this._connection.execute||function(){throw new Error(`connection.execute not implemented (in "${r}")`)},this._store=new u,this._method_refs=new u,this._method_refs.onReady(()=>{this._fire("remoteIdle")}),this._method_refs.onBusy(()=>{this._fire("remoteBusy")}),this._setupMessageHanlders()}init(){this._connection.emit({type:"initialized",config:this.config,peer_id:this._connection.peer_id})}setConfig(e){if(e)for(const t of Object.keys(e))this.config[t]=e[t]}getRemoteCallStack(){return this._method_refs.getStack()}getRemote(){return this._remote_interface}setInterface(e,t){if(t=t||{},this.config.name=t.name||this.config.name,this.config.description=t.description||this.config.description,this.config.forwarding_functions)for(let t of this.config.forwarding_functions){const n=this._remote_interface;n[t]&&(e.constructor===Object?e[t]||(e[t]=(...e)=>{n[t](...e)}):e.constructor.constructor===Function&&(e.constructor.prototype[t]||(e.constructor.prototype[t]=(...e)=>{n[t](...e)})))}return this._local_api=e,this._remote_set?this.sendInterface():this._fire("interfaceAvailable"),new Promise(e=>{this.once("interfaceSetAsRemote",e)})}sendInterface(){if(!this._local_api)throw new Error("interface is not set.");this._encode(this._local_api,!0).then(e=>{this._connection.emit({type:"setInterface",api:e})})}_disposeObject(e){if(!this._object_store[e])throw new Error(`Object (id=${e}) not found.`);delete this._object_store[e]}disposeObject(e){return new Promise((t,n)=>{if(!this._object_weakmap.has(e))throw new Error("Invalid object");{const r=this._object_weakmap.get(e);this._connection.once("disposed",e=>{e.error?n(new Error(e.error)):t()}),this._connection.emit({type:"disposeObject",object_id:r})}})}_setupMessageHanlders(){this._connection.on("init",this.init),this._connection.on("execute",e=>{Promise.resolve(this._connection.execute(e.code)).then(()=>{this._connection.emit({type:"executed"})}).catch(e=>{console.error(e),this._connection.emit({type:"executed",error:String(e)})})}),this._connection.on("method",async e=>{let t,n,r,i,o,s;try{e.promise&&([t,n]=await this._unwrap(e.promise,!1));const c=this._object_store[e.object_id];if(r=a(c,e.name),e.name.includes(".")){const t=e.name.split(".");i=a(c,t.slice(0,t.length-1).join("."))}else i=c;o=await this._unwrap(e.args,!0),e.promise?(s=r.apply(i,o),s instanceof Promise||r.constructor&&"AsyncFunction"===r.constructor.name?s.then(t).catch(n):t(s)):r.apply(i,o)}catch(e){console.error(this.config.name,e),n&&n(e)}}),this._connection.on("callback",async e=>{let t,n,r,i,o;try{if(e.promise&&([t,n]=await this._unwrap(e.promise,!1)),e.promise){if(r=this._store.fetch(e.id),i=await this._unwrap(e.args,!0),!r)throw new Error("Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");o=r.apply(null,i),o instanceof Promise||r.constructor&&"AsyncFunction"===r.constructor.name?o.then(t).catch(n):t(o)}else{if(r=this._store.fetch(e.id),i=await this._unwrap(e.args,!0),!r)throw new Error("Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.");r.apply(null,i)}}catch(e){console.error(this.config.name,e),n&&n(e)}}),this._connection.on("disposeObject",e=>{try{this._disposeObject(e.object_id),this._connection.emit({type:"disposed"})}catch(e){console.error(e),this._connection.emit({type:"disposed",error:String(e)})}}),this._connection.on("setInterface",e=>{this._setRemoteInterface(e.api)}),this._connection.on("getInterface",()=>{this._fire("getInterface"),this._local_api?this.sendInterface():this.once("interfaceAvailable",()=>{this.sendInterface()})}),this._connection.on("interfaceSetAsRemote",()=>{this._remote_set=!0,this._fire("interfaceSetAsRemote")}),this._connection.on("disconnect",()=>{this._fire("beforeDisconnect"),this._connection.disconnect(),this._fire("disconnected")})}requestRemote(){this._connection.emit({type:"getInterface"})}_ndarray(e,t,n){const i=Object(r.typedArrayToDtype)(e);if(n&&n!==i)throw"dtype doesn't match the type of the array: "+i+" != "+n;return t=t||[e.length],{_rtype:"ndarray",_rvalue:e.buffer,_rshape:t,_rdtype:i}}_setRemoteInterface(e){this._decode(e).then(e=>{if(this._remote_interface){for(let e in this._remote_interface)delete this._remote_interface[e];Object.assign(this._remote_interface,e)}else this._remote_interface=e;this._fire("remoteReady"),this._reportRemoteSet()})}_genRemoteMethod(e,t,n){const r=this,i=function(){return new Promise(async(i,o)=>{let s=null;try{s=r._method_refs.put(n?n+"/"+t:t);const a=function(){return null!==s&&r._method_refs.fetch(s),i.apply(this,arguments)},c=function(){return null!==s&&r._method_refs.fetch(s),o.apply(this,arguments)},u=await r._wrap([a,c]);a.__promise_pair=u[1]._rvalue,c.__promise_pair=u[0]._rvalue;let l=Array.prototype.slice.call(arguments);const h=l.length,d=h>0&&"object"==typeof l[h-1]&&null!==l[h-1]&&l[h-1]._rkwargs;d&&delete l[h-1]._rkwargs,l="register"===t||"registerService"===t||"register_service"===t||"export"===t||"on"===t?await r._wrap(l,!0):await r._wrap(l);const p=l.__transferables__;p&&delete l.__transferables__,r._connection.emit({type:"method",target_id:e,name:t,object_id:n,args:l,promise:u,with_kwargs:d},p)}catch(e){s&&r._method_refs.fetch(s),o(`Failed to exectue remote method (interface: ${n||r.id}, method: ${t}), error: ${e}`)}})};return i.__remote_method=!0,i}_reportRemoteSet(){this._connection.emit({type:"interfaceSetAsRemote"})}async _encode(e,t,n){const i=typeof e;if("number"===i||"string"===i||"boolean"===i||null==e||e instanceof ArrayBuffer)return e;let s;if("function"==typeof e){if(t){if(!n)throw new Error("objectId is not specified.");s={_rtype:"interface",_rtarget_id:this._connection.peer_id,_rintf:n,_rvalue:t},this._method_weakmap.set(e,s)}else if(this._method_weakmap.has(e))s=this._method_weakmap.get(e);else{const t=this._store.put(e);s={_rtype:"callback",_rtarget_id:this._connection.peer_id,_rname:e.constructor&&e.constructor.name||t,_rvalue:t}}return s}if(e.constructor instanceof Object&&e._rtype){if(e._rintf){const r=e._rtype;delete e._rtype,s=await this._encode(e,t,n),s._rtype=r}else s=e;return s}const a=[],c=e._transfer,u=Array.isArray(e);for(let r of Object.keys(this._codecs)){const i=this._codecs[r];if(i.encoder&&e instanceof i.type){let r=await Promise.resolve(i.encoder(e));if(r&&!r._rtype&&(r._rtype=i.name),r&&r._rintf){const e=r._rtype;delete r._rtype,r=await this._encode(r,t,n),r._rtype=e}return s=r,s}}if("undefined"!=typeof tf&&tf.Tensor&&e instanceof tf.Tensor){const t=e.dataSync();(e._transfer||c)&&(a.push(t.buffer),delete e._transfer),s={_rtype:"ndarray",_rvalue:t.buffer,_rshape:e.shape,_rdtype:e.dtype}}else if("undefined"!=typeof nj&&nj.NdArray&&e instanceof nj.NdArray){const t=Object(r.typedArrayToDtype)(e.selection.data);(e._transfer||c)&&(a.push(e.selection.data.buffer),delete e._transfer),s={_rtype:"ndarray",_rvalue:e.selection.data.buffer,_rshape:e.shape,_rdtype:t}}else if(e instanceof Error)console.error(e),s={_rtype:"error",_rvalue:e.toString()};else if("undefined"!=typeof File&&e instanceof File)s={_rtype:"file",_rvalue:e,_rpath:e._path||e.webkitRelativePath};else if(e!==Object(e)||e instanceof Boolean||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof ImageData||"undefined"!=typeof FileList&&e instanceof FileList||"undefined"!=typeof FileSystemDirectoryHandle&&e instanceof FileSystemDirectoryHandle||"undefined"!=typeof FileSystemFileHandle&&e instanceof FileSystemFileHandle||"undefined"!=typeof FileSystemHandle&&e instanceof FileSystemHandle||"undefined"!=typeof FileSystemWritableFileStream&&e instanceof FileSystemWritableFileStream)s=e;else if("undefined"!=typeof File&&e instanceof File)s={_rtype:"file",_rname:e.name,_rmime:e.type,_rvalue:e,_rpath:e._path||e.webkitRelativePath};else if(e instanceof Blob)s={_rtype:"blob",_rvalue:e};else if(e instanceof o){(e._transfer||c)&&(a.push(e.buffer),delete e._transfer);const t=Object(r.typedArrayToDtype)(e);s={_rtype:"typedarray",_rvalue:e.buffer,_rdtype:t}}else if(e instanceof DataView)(e._transfer||c)&&(a.push(e.buffer),delete e._transfer),s={_rtype:"memoryview",_rvalue:e.buffer};else if(e instanceof Set)s={_rtype:"set",_rvalue:await this._encode(Array.from(e),t)};else if(e instanceof Map)s={_rtype:"orderedmap",_rvalue:await this._encode(Array.from(e),t)};else if(e.constructor instanceof Object||Array.isArray(e)){let i;if(s=u?[]:{},e.constructor===Object||Array.isArray(e))i=Object.keys(e);else{if(e.constructor===Function)throw new Error("Please instantiate the class before exportting it.");if(e.constructor.constructor!==Function)throw Error("Unsupported interface type");i=Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)),t=!0}let o=!1;if(e._rintf||t){n||(n="string"==typeof e._rintf&&e._rintf.length>0?e._rintf:Object(r.randId)(),this._object_store[n]&&console.warn("Overwritting interface object with the same id: "+n),this._object_store[n]=e);for(let r of i)"constructor"!==r&&(r.startsWith("_")||(s[r]=await this._encode(e[r],"string"==typeof t?t+"."+r:r,n),"function"==typeof e[r]&&(o=!0)));o&&(s._rintf=n),e.on&&"function"==typeof e.on&&e.on("close",()=>{delete this._object_store[n]})}else for(let t of i)["hasOwnProperty","constructor"].includes(t)||(s[t]=await this._encode(e[t]))}else{if("object"!=typeof e)throw"imjoy-rpc: Unsupported data type:"+e;{const t=Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)),n=Object(r.randId)();for(let n of t)["hasOwnProperty","constructor"].includes(n)||(s[n]=await this._encode(e[n],n,s));s._rintf=n}}if(a.length>0&&(s.__transferables__=a),!s)throw new Error("Failed to encode object");return s}async _decode(e,t){if(!e)return e;let n;if(e._rtype)if(this._codecs[e._rtype]&&this._codecs[e._rtype].decoder){if(e._rintf){const n=e._rtype;delete e._rtype,(e=await this._decode(e,t))._rtype=n}n=await Promise.resolve(this._codecs[e._rtype].decoder(e))}else if("callback"===e._rtype)n=this._genRemoteCallback(e._rtarget_id,e._rvalue,t);else if("interface"===e._rtype)n=this._genRemoteMethod(e._rtarget_id,e._rvalue,e._rintf);else if("ndarray"===e._rtype)if("undefined"!=typeof nj&&nj.array)Array.isArray(e._rvalue)&&(e._rvalue=e._rvalue.reduce(s)),n=nj.array(new Uint8(e._rvalue),e._rdtype).reshape(e._rshape);else if("undefined"!=typeof tf&&tf.Tensor){Array.isArray(e._rvalue)&&(e._rvalue=e._rvalue.reduce(s));const t=r.dtypeToTypedArray[e._rdtype];n=tf.tensor(new t(e._rvalue),e._rshape,e._rdtype)}else n=e;else if("error"===e._rtype)n=new Error(e._rvalue);else if("file"===e._rtype)e._rvalue instanceof File?(n=e._rvalue,n._path=e._rpath):(n=new File([e._rvalue],e._rname,{type:e._rmime}),n._path=e._rpath);else if("typedarray"===e._rtype){const t=r.dtypeToTypedArray[e._rdtype];if(!t)throw new Error("unsupported dtype: "+e._rdtype);n=new t(e._rvalue)}else if("memoryview"===e._rtype)n=new DataView(e._rvalue);else if("blob"===e._rtype)n=e._rvalue instanceof Blob?e._rvalue:new Blob([e._rvalue],{type:e._rmime});else if("orderedmap"===e._rtype)n=new Map(await this._decode(e._rvalue,t));else if("set"===e._rtype)n=new Set(await this._decode(e._rvalue,t));else if(e._rintf){const r=e._rtype;delete e._rtype,n=await this._decode(e,t),n._rtype=r}else n=e;else if(e.constructor===Object||Array.isArray(e)){const r=Array.isArray(e);n=r?[]:{};for(let i of Object.keys(e))if(r||e.hasOwnProperty(i)){const r=e[i];n[i]=await this._decode(r,t)}}else n=e;if(void 0===n)throw new Error("Failed to decode object");return e._rintf&&this._object_weakmap.set(n,e._rintf),n}async _wrap(e,t){return await this._encode(e,t)}async _unwrap(e,t){return await this._decode(e,t)}_genRemoteCallback(e,t,n){const r=this;let i;return n?(i=function(){return new Promise(async(n,i)=>{const o=await r._wrap(Array.prototype.slice.call(arguments)),s=o.length,a=s>0&&"object"==typeof o[s-1]&&null!==o[s-1]&&o[s-1]._rkwargs;a&&delete o[s-1]._rkwargs;const c=o.__transferables__;c&&delete o.__transferables__;const u=await r._wrap([n,i]);n.__promise_pair=u[1]._rvalue,i.__promise_pair=u[0]._rvalue;try{r._connection.emit({type:"callback",target_id:e,id:t,args:o,promise:u,with_kwargs:a},c)}catch(e){i(`Failed to exectue remote callback ( id: ${t}).`)}})},i):(i=async function(){const n=await r._wrap(Array.prototype.slice.call(arguments)),i=n.length,o=i>0&&"object"==typeof n[i-1]&&null!==n[i-1]&&n[i-1]._rkwargs;o&&delete n[i-1]._rkwargs;const s=n.__transferables__;return s&&delete n.__transferables__,r._connection.emit({type:"callback",target_id:e,id:t,args:n,with_kwargs:o},s)},i)}reset(){this._event_handlers={},this._once_handlers={},this._remote_interface=null,this._object_store={},this._method_weakmap=new WeakMap,this._object_weakmap=new WeakMap,this._local_api=null,this._store=new u,this._method_refs=new u}disconnect(){this._connection.emit({type:"disconnect"}),this.reset(),setTimeout(()=>{this._connection.disconnect()},2e3)}}class u{constructor(){this._store={},this._indices=[0],this._readyHandler=function(){},this._busyHandler=function(){},this._readyHandler()}onReady(e){this._readyHandler=e||function(){}}onBusy(e){this._busyHandler=e||function(){}}getStack(){return Object.keys(this._store).length}_genId(){let e;return e=1===this._indices.length?this._indices[0]++:this._indices.shift(),e}_releaseId(e){for(let t=0;t<this._indices.length;t++)if(e<this._indices[t]){this._indices.splice(t,0,e);break}for(let e=this._indices.length-1;e>=0&&this._indices[e]-1===this._indices[e-1];e--)this._indices.pop()}put(e){this._busyHandler&&0===Object.keys(this._store).length&&this._busyHandler();const t=this._genId();return this._store[t]=e,t}fetch(e){const t=this._store[e];return t&&!t.__remote_method&&(delete this._store[e],this._releaseId(e),this._readyHandler&&0===Object.keys(this._store).length&&this._readyHandler()),t&&t.__promise_pair&&this.fetch(t.__promise_pair),t}}},"./src/socketIOMain.js":
/*!*****************************!*\
!*** ./src/socketIOMain.js ***!
\*****************************/
/*! exports provided: setupRPC, waitForInitialization, VERSION, RPC, API_VERSION, loadRequirements, Connection, connectToServer */function(e,t,n){"use strict";n.r(t),n.d(t,"Connection",(function(){return u})),n.d(t,"connectToServer",(function(){return l}));var r=n(/*! ./pluginCore.js */"./src/pluginCore.js"),i=n(/*! ./rpc.js */"./src/rpc.js");n.d(t,"RPC",(function(){return i.RPC})),n.d(t,"API_VERSION",(function(){return i.API_VERSION}));var o=n(/*! ./utils.js */"./src/utils.js");n.d(t,"loadRequirements",(function(){return o.loadRequirements}));var s=n(/*! socket.io-client */"./node_modules/socket.io-client/build/esm/index.js"),a=n(/*! ./main.js */"./src/main.js");n.d(t,"setupRPC",(function(){return a.setupRPC})),n.d(t,"waitForInitialization",(function(){return a.waitForInitialization}));var c=n(/*! ../package.json */"./package.json");n.d(t,"VERSION",(function(){return c.version}));class u extends o.MessageEmitter{constructor(e){super(e&&e.debug),this.config=e||{},this.peer_id=Object(o.randId)()}init(){return new Promise((e,t)=>{const n=this.config,i=n.server_url,o={};n.token&&(o.Authorization="Bearer "+n.token);const a=new URL(i).pathname,c=Object(s.default)(i,{withCredentials:!0,extraHeaders:o,path:(a.endsWith("/")?a.slice(0,-1):a)+"/socket.io"});let u=!1;c.on("connect",()=>{u?console.warn("Skipping reconnect to the server"):(c.emit("register_plugin",n,i=>{if(!i.success)return console.error(i.detail),void t(i.detail);u=!0,this.plugin_id=i.plugin_id,c.on("plugin_message",e=>{e.peer_id===this.peer_id?this._fire(e.type,e):this.config.debug&&console.log(`connection peer id mismatch ${e.peer_id} !== ${this.peer_id}`)}),this.once("initialize",()=>{this.rpc?this.rpc.once("remoteReady",()=>{this.rpc.sendInterface()}):this.rpc=Object(r.connectRPC)(this,n),this.connect(),e()}),this.emit({type:"imjoyRPCReady",config:n,peer_id:this.peer_id})}),this._disconnected=!1)}),c.on("connect_error",()=>{t("connection error"),this._fire("connectFailure")}),c.on("disconnect",()=>{t("disconnected"),this.disconnect(),this._fire("disconnected")}),this.socket=c})}connect(){this.emit({type:"initialized",config:this.config,origin:globalThis.location.origin,peer_id:this.peer_id}),this._fire("connected")}reset(){this._event_handlers={},this._once_handlers={}}execute(){throw new Error("Execution is not allowed for socketio connection")}disconnect(){this._fire("beforeDisconnect"),this.socket.disconnect(),this.init(),this._fire("disconnected")}emit(e){e.plugin_id=this.plugin_id,this.socket.emit("plugin_message",e,t=>{t.success||this._fire("error",e.detail)})}}function l(e){if(!(e=e||{}).server_url)throw new Error("Server URL is not specified.");return e.name=e.name||Object(o.randId)(),e=Object(o.normalizeConfig)(e),new Promise((t,n)=>{const r=n=>{const i=n.detail;e.expose_api_globally&&(globalThis.api=i),t(i),globalThis.removeEventListener("imjoy_remote_api_ready",r)};globalThis.addEventListener("imjoy_remote_api_ready",r),(e=e||{}).dedicated_thread=!1,e.lang="javascript",e.api_version=i.API_VERSION,new u(e).init().catch(n)})}},"./src/utils.js":
/*!**********************!*\
!*** ./src/utils.js ***!
\**********************/
/*! exports provided: randId, dtypeToTypedArray, loadRequirementsInWindow, loadRequirementsInWebworker, loadRequirements, normalizeConfig, typedArrayToDtypeMapping, typedArrayToDtype, cacheRequirements, setupServiceWorker, urlJoin, MessageEmitter */function(module,__webpack_exports__,__webpack_require__){"use strict";function randId(){return Math.random().toString(36).substr(2,10)+(new Date).getTime()}__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"randId",(function(){return randId})),__webpack_require__.d(__webpack_exports__,"dtypeToTypedArray",(function(){return dtypeToTypedArray})),__webpack_require__.d(__webpack_exports__,"loadRequirementsInWindow",(function(){return loadRequirementsInWindow})),__webpack_require__.d(__webpack_exports__,"loadRequirementsInWebworker",(function(){return loadRequirementsInWebworker})),__webpack_require__.d(__webpack_exports__,"loadRequirements",(function(){return loadRequirements})),__webpack_require__.d(__webpack_exports__,"normalizeConfig",(function(){return normalizeConfig})),__webpack_require__.d(__webpack_exports__,"typedArrayToDtypeMapping",(function(){return typedArrayToDtypeMapping})),__webpack_require__.d(__webpack_exports__,"typedArrayToDtype",(function(){return typedArrayToDtype})),__webpack_require__.d(__webpack_exports__,"cacheRequirements",(function(){return cacheRequirements})),__webpack_require__.d(__webpack_exports__,"setupServiceWorker",(function(){return setupServiceWorker})),__webpack_require__.d(__webpack_exports__,"urlJoin",(function(){return urlJoin})),__webpack_require__.d(__webpack_exports__,"MessageEmitter",(function(){return MessageEmitter}));const dtypeToTypedArray={int8:Int8Array,int16:Int16Array,int32:Int32Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,float32:Float32Array,float64:Float64Array,array:Array};async function loadRequirementsInWindow(e){function t(e){return new Promise((t,n)=>{var r=document.createElement("script");r.src=e,r.type="text/javascript",r.onload=t,r.onreadystatechange=function(){"loaded"!==this.readyState&&"complete"!==this.readyState||t()},r.onerror=n,document.head.appendChild(r)})}async function n(){for(var e=Array.prototype.slice.call(arguments),n=e.length,r=0;r<n;r++)await t(e[r])}if(e&&(Array.isArray(e)||"string"==typeof e))try{var r;if(e="string"==typeof e?[e]:e,!Array.isArray(e))throw"unsupported requirements definition";for(var i=0;i<e.length;i++)e[i].toLowerCase().endsWith(".css")||e[i].startsWith("css:")?(e[i].startsWith("css:")&&(e[i]=e[i].slice(4)),(r=document.createElement("link")).rel="stylesheet",r.href=e[i],document.head.appendChild(r)):e[i].toLowerCase().endsWith(".mjs")||e[i].startsWith("mjs:")?(e[i].startsWith("mjs:")&&(e[i]=e[i].slice(4)),await import(e[i])):e[i].toLowerCase().endsWith(".js")||e[i].startsWith("js:")?(e[i].startsWith("js:")&&(e[i]=e[i].slice(3)),await n(e[i])):e[i].startsWith("http")?await n(e[i]):e[i].startsWith("cache:")||console.log("Unprocessed requirements url: "+e[i])}catch(t){throw"failed to import required scripts: "+e.toString()}}async function loadRequirementsInWebworker(e){if(e&&(Array.isArray(e)||"string"==typeof e))try{Array.isArray(e)||(e=[e]);for(var t=0;t<e.length;t++){if(e[t].toLowerCase().endsWith(".css")||e[t].startsWith("css:"))throw"unable to import css in a webworker";e[t].toLowerCase().endsWith(".js")||e[t].startsWith("js:")?(e[t].startsWith("js:")&&(e[t]=e[t].slice(3)),importScripts(e[t])):e[t].startsWith("http")?importScripts(e[t]):e[t].startsWith("cache:")||console.log("Unprocessed requirements url: "+e[t])}}catch(t){throw"failed to import required scripts: "+e.toString()}}function loadRequirements(e){return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?loadRequirementsInWebworker(e):loadRequirementsInWindow(e)}function normalizeConfig(e){return e.version=e.version||"0.1.0",e.description=e.description||`[TODO: add description for ${e.name} ]`,e.type=e.type||"rpc-window",e.id=e.id||randId(),e.target_origin=e.target_origin||"*",e.allow_execution=e.allow_execution||!1,e=Object.keys(e).reduce((t,n)=>("function"!=typeof e[n]&&(t[n]=e[n]),t),{})}const typedArrayToDtypeMapping={Int8Array:"int8",Int16Array:"int16",Int32Array:"int32",Uint8Array:"uint8",Uint16Array:"uint16",Uint32Array:"uint32",Float32Array:"float32",Float64Array:"float64",Array:"array"},typedArrayToDtypeKeys=[];for(const arrType of Object.keys(typedArrayToDtypeMapping))typedArrayToDtypeKeys.push(eval(arrType));function typedArrayToDtype(e){let t=typedArrayToDtypeMapping[e.constructor.name];if(!t){const n=Object.getPrototypeOf(e);for(const e of typedArrayToDtypeKeys)if(n instanceof e){t=typedArrayToDtypeMapping[e.name];break}}return t}function cacheUrlInServiceWorker(e){return new Promise((function(t,n){const r={command:"add",url:e};if(!navigator.serviceWorker||!navigator.serviceWorker.register)return void n("Service worker is not supported.");const i=new MessageChannel;i.port1.onmessage=function(e){e.data&&e.data.error?n(e.data.error):t(e.data&&e.data.result)},navigator.serviceWorker&&navigator.serviceWorker.controller?navigator.serviceWorker.controller.postMessage(r,[i.port2]):n("Service worker controller is not available")}))}async function cacheRequirements(e){e=e||[],Array.isArray(e)||(e=[e]);for(let t of e)t.startsWith("js:")&&(t=t.slice(3)),t.startsWith("css:")&&(t=t.slice(4)),t.startsWith("cache:")&&(t=t.slice(6)),t.startsWith("http")&&await cacheUrlInServiceWorker(t).catch(e=>{console.error(e)})}function setupServiceWorker(e,t,n){if("serviceWorker"in navigator){if(e=e||"/",navigator.serviceWorker.register(e+"plugin-service-worker.js").then((function(e){console.log("ServiceWorker registration successful with scope: ",e.scope)}),(function(e){console.log("ServiceWorker registration failed: ",e)})),t=t||"*",(n=n||cacheRequirements)&&"function"!=typeof n)throw new Error("config.cache_requirements must be a function");window.addEventListener("message",(function(e){if("*"===t||e.origin===t){const t=e.data;"cacheRequirements"===t.type&&n(t.requirements)}}))}}function urlJoin(...e){return e.join("/").replace(/[\/]+/g,"/").replace(/^(.+):\//,"$1://").replace(/^file:/,"file:/").replace(/\/(\?|&|#[^!])/g,"$1").replace(/\?/g,"&").replace("&","?")}class MessageEmitter{constructor(e){this._event_handlers={},this._once_handlers={},this._debug=e}emit(){throw new Error("emit is not implemented")}on(e,t){this._event_handlers[e]||(this._event_handlers[e]=[]),this._event_handlers[e].push(t)}once(e,t){t.___event_run_once=!0,this.on(e,t)}off(e,t){if(e||t){if(e&&!t)this._event_handlers[e]&&(this._event_handlers[e]=[]);else if(this._event_handlers[e]){const n=this._event_handlers[e].indexOf(t);n>=0&&this._event_handlers[e].splice(n,1)}}else this._event_handlers={}}_fire(e,t){if(this._event_handlers[e])for(var n=this._event_handlers[e].length;n--;){const r=this._event_handlers[e][n];try{r(t)}catch(e){console.error(e)}finally{r.___event_run_once&&this._event_handlers[e].splice(n,1)}}else this._debug&&console.warn("unhandled event",e,t)}}}})},module.exports=factory()},function(e,t,n){"use strict";var r=n(39),i=n(16),o=n(41),s=n(69),a=n(70),c=i.ucs2length,u=n(40),l=o.Validation;function h(e,t,n){var r=p.call(this,e,t,n);return r>=0?{index:r,compiling:!0}:(r=this._compilations.length,this._compilations[r]={schema:e,root:t,baseId:n},{index:r,compiling:!1})}function d(e,t,n){var r=p.call(this,e,t,n);r>=0&&this._compilations.splice(r,1)}function p(e,t,n){for(var r=0;r<this._compilations.length;r++){var i=this._compilations[r];if(i.schema==e&&i.root==t&&i.baseId==n)return r}return-1}function f(e,t){return"var pattern"+e+" = new RegExp("+i.toQuotedString(t[e])+");"}function m(e){return"var default"+e+" = defaults["+e+"];"}function g(e,t){return void 0===t[e]?"":"var refVal"+e+" = refVal["+e+"];"}function _(e){return"var customRule"+e+" = customRules["+e+"];"}function y(e,t){if(!e.length)return"";for(var n="",r=0;r<e.length;r++)n+=t(r,e);return n}e.exports=function e(t,n,p,v){var b=this,w=this._opts,x=[void 0],k={},E=[],j={},A=[],D={},S=[];n=n||{schema:t,refVal:x,refs:k};var C=h.call(this,t,n,v),O=this._compilations[C.index];if(C.compiling)return O.callValidate=function e(){var t=O.validate,n=t.apply(this,arguments);return e.errors=t.errors,n};var P=this._formats,F=this.RULES;try{var I=R(t,n,p,v);O.validate=I;var T=O.callValidate;return T&&(T.schema=I.schema,T.errors=null,T.refs=I.refs,T.refVal=I.refVal,T.root=I.root,T.$async=I.$async,w.sourceCode&&(T.source=I.source)),I}finally{d.call(this,t,n,v)}function R(t,s,h,d){var p=!s||s&&s.schema==t;if(s.schema!=n.schema)return e.call(b,t,s,h,d);var v,j=!0===t.$async,D=a({isTop:!0,schema:t,isRoot:p,baseId:d,root:s,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:o.MissingRef,RULES:F,validate:a,util:i,resolve:r,resolveRef:B,usePattern:L,useDefault:N,useCustomRule:U,opts:w,formats:P,logger:b.logger,self:b});D=y(x,g)+y(E,f)+y(A,m)+y(S,_)+D,w.processCode&&(D=w.processCode(D,t));try{v=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",D)(b,F,P,n,x,A,S,u,c,l),x[0]=v}catch(e){throw b.logger.error("Error compiling schema, function code:",D),e}return v.schema=t,v.errors=null,v.refs=k,v.refVal=x,v.root=p?v:s,j&&(v.$async=!0),!0===w.sourceCode&&(v.source={code:D,patterns:E,defaults:A}),v}function B(t,i,o){i=r.url(t,i);var s,a,c=k[i];if(void 0!==c)return q(s=x[c],a="refVal["+c+"]");if(!o&&n.refs){var u=n.refs[i];if(void 0!==u)return q(s=n.refVal[u],a=M(i,s))}a=M(i);var l=r.call(b,R,n,i);if(void 0===l){var h=p&&p[i];h&&(l=r.inlineRef(h,w.inlineRefs)?h:e.call(b,h,n,p,t))}if(void 0!==l)return function(e,t){var n=k[e];x[n]=t}(i,l),q(l,a);!function(e){delete k[e]}(i)}function M(e,t){var n=x.length;return x[n]=t,k[e]=n,"refVal"+n}function q(e,t){return"object"==typeof e||"boolean"==typeof e?{code:t,schema:e,inline:!0}:{code:t,$async:e&&!!e.$async}}function L(e){var t=j[e];return void 0===t&&(t=j[e]=E.length,E[t]=e),"pattern"+t}function N(e){switch(typeof e){case"boolean":case"number":return""+e;case"string":return i.toQuotedString(e);case"object":if(null===e)return"null";var t=s(e),n=D[t];return void 0===n&&(n=D[t]=A.length,A[n]=e),"default"+n}}function U(e,t,n,r){if(!1!==b._opts.validateSchema){var i=e.definition.dependencies;if(i&&!i.every((function(e){return Object.prototype.hasOwnProperty.call(n,e)})))throw new Error("parent schema must have all required keywords: "+i.join(","));var o=e.definition.validateSchema;if(o)if(!o(t)){var s="keyword schema is invalid: "+b.errorsText(o.errors);if("log"!=b._opts.validateSchema)throw new Error(s);b.logger.error(s)}}var a,c=e.definition.compile,u=e.definition.inline,l=e.definition.macro;if(c)a=c.call(b,t,n,r);else if(l)a=l.call(b,t,n,r),!1!==w.validateSchema&&b.validateSchema(a,!0);else if(u)a=u.call(b,r,e.keyword,t,n);else if(!(a=e.definition.validate))return;if(void 0===a)throw new Error('custom keyword "'+e.keyword+'"failed to compile');var h=S.length;return S[h]=a,{code:"customRule"+h,validate:a}}}},function(e,t,n){
/** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
!function(e){"use strict";function t(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(t.length>1){t[0]=t[0].slice(0,-1);for(var r=t.length-1,i=1;i<r;++i)t[i]=t[i].slice(1,-1);return t[r]=t[r].slice(1),t.join("")}return t[0]}function n(e){return"(?:"+e+")"}function r(e){return void 0===e?"undefined":null===e?"null":Object.prototype.toString.call(e).split(" ").pop().split("]").shift().toLowerCase()}function i(e){return e.toUpperCase()}function o(e){var r=t("[0-9]","[A-Fa-f]"),i=n(n("%[EFef]"+r+"%"+r+r+"%"+r+r)+"|"+n("%[89A-Fa-f]"+r+"%"+r+r)+"|"+n("%"+r+r)),o="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",s=t("[\\:\\/\\?\\#\\[\\]\\@]",o),a=e?"[\\uE000-\\uF8FF]":"[]",c=t("[A-Za-z]","[0-9]","[\\-\\.\\_\\~]",e?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]"),u=n("[A-Za-z]"+t("[A-Za-z]","[0-9]","[\\+\\-\\.]")+"*"),l=n(n(i+"|"+t(c,o,"[\\:]"))+"*"),h=(n(n("25[0-5]")+"|"+n("2[0-4][0-9]")+"|"+n("1[0-9][0-9]")+"|"+n("[1-9][0-9]")+"|[0-9]"),n(n("25[0-5]")+"|"+n("2[0-4][0-9]")+"|"+n("1[0-9][0-9]")+"|"+n("0?[1-9][0-9]")+"|0?0?[0-9]")),d=n(h+"\\."+h+"\\."+h+"\\."+h),p=n(r+"{1,4}"),f=n(n(p+"\\:"+p)+"|"+d),m=n(n(p+"\\:")+"{6}"+f),g=n("\\:\\:"+n(p+"\\:")+"{5}"+f),_=n(n(p)+"?\\:\\:"+n(p+"\\:")+"{4}"+f),y=n(n(n(p+"\\:")+"{0,1}"+p)+"?\\:\\:"+n(p+"\\:")+"{3}"+f),v=n(n(n(p+"\\:")+"{0,2}"+p)+"?\\:\\:"+n(p+"\\:")+"{2}"+f),b=n(n(n(p+"\\:")+"{0,3}"+p)+"?\\:\\:"+p+"\\:"+f),w=n(n(n(p+"\\:")+"{0,4}"+p)+"?\\:\\:"+f),x=n(n(n(p+"\\:")+"{0,5}"+p)+"?\\:\\:"+p),k=n(n(n(p+"\\:")+"{0,6}"+p)+"?\\:\\:"),E=n([m,g,_,y,v,b,w,x,k].join("|")),j=n(n(c+"|"+i)+"+"),A=(n(E+"\\%25"+j),n(E+n("\\%25|\\%(?!"+r+"{2})")+j)),D=n("[vV]"+r+"+\\."+t(c,o,"[\\:]")+"+"),S=n("\\["+n(A+"|"+E+"|"+D)+"\\]"),C=n(n(i+"|"+t(c,o))+"*"),O=n(S+"|"+d+"(?!"+C+")|"+C),P=n("[0-9]*"),F=n(n(l+"@")+"?"+O+n("\\:"+P)+"?"),I=n(i+"|"+t(c,o,"[\\:\\@]")),T=n(I+"*"),R=n(I+"+"),B=n(n(i+"|"+t(c,o,"[\\@]"))+"+"),M=n(n("\\/"+T)+"*"),q=n("\\/"+n(R+M)+"?"),L=n(B+M),N=n(R+M),U="(?!"+I+")",W=(n(M+"|"+q+"|"+L+"|"+N+"|"+U),n(n(I+"|"+t("[\\/\\?]",a))+"*")),$=n(n(I+"|[\\/\\?]")+"*"),z=n(n("\\/\\/"+F+M)+"|"+q+"|"+N+"|"+U),J=n(u+"\\:"+z+n("\\?"+W)+"?"+n("\\#"+$)+"?"),H=n(n("\\/\\/"+F+M)+"|"+q+"|"+L+"|"+U),K=n(H+n("\\?"+W)+"?"+n("\\#"+$)+"?");return n(J+"|"+K),n(u+"\\:"+z+n("\\?"+W)+"?"),n(n("\\/\\/("+n("("+l+")@")+"?("+O+")"+n("\\:("+P+")")+"?)")+"?("+M+"|"+q+"|"+N+"|"+U+")"),n("\\?("+W+")"),n("\\#("+$+")"),n(n("\\/\\/("+n("("+l+")@")+"?("+O+")"+n("\\:("+P+")")+"?)")+"?("+M+"|"+q+"|"+L+"|"+U+")"),n("\\?("+W+")"),n("\\#("+$+")"),n(n("\\/\\/("+n("("+l+")@")+"?("+O+")"+n("\\:("+P+")")+"?)")+"?("+M+"|"+q+"|"+N+"|"+U+")"),n("\\?("+W+")"),n("\\#("+$+")"),n("("+l+")@"),n("\\:("+P+")"),{NOT_SCHEME:new RegExp(t("[^]","[A-Za-z]","[0-9]","[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(t("[^\\%\\:]",c,o),"g"),NOT_HOST:new RegExp(t("[^\\%\\[\\]\\:]",c,o),"g"),NOT_PATH:new RegExp(t("[^\\%\\/\\:\\@]",c,o),"g"),NOT_PATH_NOSCHEME:new RegExp(t("[^\\%\\/\\@]",c,o),"g"),NOT_QUERY:new RegExp(t("[^\\%]",c,o,"[\\:\\@\\/\\?]",a),"g"),NOT_FRAGMENT:new RegExp(t("[^\\%]",c,o,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(t("[^]",c,o),"g"),UNRESERVED:new RegExp(c,"g"),OTHER_CHARS:new RegExp(t("[^\\%]",c,s),"g"),PCT_ENCODED:new RegExp(i,"g"),IPV4ADDRESS:new RegExp("^("+d+")$"),IPV6ADDRESS:new RegExp("^\\[?("+E+")"+n(n("\\%25|\\%(?!"+r+"{2})")+"("+j+")")+"?\\]?$")}}var s=o(!1),a=o(!0),c=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},u=2147483647,l=/^xn--/,h=/[^\0-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,p={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=Math.floor,m=String.fromCharCode;function g(e){throw new RangeError(p[e])}function _(e,t){var n=e.split("@"),r="";n.length>1&&(r=n[0]+"@",e=n[1]);var i=function(e,t){for(var n=[],r=e.length;r--;)n[r]=t(e[r]);return n}((e=e.replace(d,".")).split("."),t).join(".");return r+i}function y(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){var o=e.charCodeAt(n++);56320==(64512&o)?t.push(((1023&i)<<10)+(1023&o)+65536):(t.push(i),n--)}else t.push(i)}return t}var v=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},b=function(e,t,n){var r=0;for(e=n?f(e/700):e>>1,e+=f(e/t);e>455;r+=36)e=f(e/35);return f(r+36*e/(e+38))},w=function(e){var t,n=[],r=e.length,i=0,o=128,s=72,a=e.lastIndexOf("-");a<0&&(a=0);for(var c=0;c<a;++c)e.charCodeAt(c)>=128&&g("not-basic"),n.push(e.charCodeAt(c));for(var l=a>0?a+1:0;l<r;){for(var h=i,d=1,p=36;;p+=36){l>=r&&g("invalid-input");var m=(t=e.charCodeAt(l++))-48<10?t-22:t-65<26?t-65:t-97<26?t-97:36;(m>=36||m>f((u-i)/d))&&g("overflow"),i+=m*d;var _=p<=s?1:p>=s+26?26:p-s;if(m<_)break;var y=36-_;d>f(u/y)&&g("overflow"),d*=y}var v=n.length+1;s=b(i-h,v,0==h),f(i/v)>u-o&&g("overflow"),o+=f(i/v),i%=v,n.splice(i++,0,o)}return String.fromCodePoint.apply(String,n)},x=function(e){var t=[],n=(e=y(e)).length,r=128,i=0,o=72,s=!0,a=!1,c=void 0;try{for(var l,h=e[Symbol.iterator]();!(s=(l=h.next()).done);s=!0){var d=l.value;d<128&&t.push(m(d))}}catch(e){a=!0,c=e}finally{try{!s&&h.return&&h.return()}finally{if(a)throw c}}var p=t.length,_=p;for(p&&t.push("-");_<n;){var w=u,x=!0,k=!1,E=void 0;try{for(var j,A=e[Symbol.iterator]();!(x=(j=A.next()).done);x=!0){var D=j.value;D>=r&&D<w&&(w=D)}}catch(e){k=!0,E=e}finally{try{!x&&A.return&&A.return()}finally{if(k)throw E}}var S=_+1;w-r>f((u-i)/S)&&g("overflow"),i+=(w-r)*S,r=w;var C=!0,O=!1,P=void 0;try{for(var F,I=e[Symbol.iterator]();!(C=(F=I.next()).done);C=!0){var T=F.value;if(T<r&&++i>u&&g("overflow"),T==r){for(var R=i,B=36;;B+=36){var M=B<=o?1:B>=o+26?26:B-o;if(R<M)break;var q=R-M,L=36-M;t.push(m(v(M+q%L,0))),R=f(q/L)}t.push(m(v(R,0))),o=b(i,S,_==p),i=0,++_}}}catch(e){O=!0,P=e}finally{try{!C&&I.return&&I.return()}finally{if(O)throw P}}++i,++r}return t.join("")},k=function(e){return _(e,(function(e){return h.test(e)?"xn--"+x(e):e}))},E=function(e){return _(e,(function(e){return l.test(e)?w(e.slice(4).toLowerCase()):e}))},j={};function A(e){var t=e.charCodeAt(0);return t<16?"%0"+t.toString(16).toUpperCase():t<128?"%"+t.toString(16).toUpperCase():t<2048?"%"+(t>>6|192).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase():"%"+(t>>12|224).toString(16).toUpperCase()+"%"+(t>>6&63|128).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase()}function D(e){for(var t="",n=0,r=e.length;n<r;){var i=parseInt(e.substr(n+1,2),16);if(i<128)t+=String.fromCharCode(i),n+=3;else if(i>=194&&i<224){if(r-n>=6){var o=parseInt(e.substr(n+4,2),16);t+=String.fromCharCode((31&i)<<6|63&o)}else t+=e.substr(n,6);n+=6}else if(i>=224){if(r-n>=9){var s=parseInt(e.substr(n+4,2),16),a=parseInt(e.substr(n+7,2),16);t+=String.fromCharCode((15&i)<<12|(63&s)<<6|63&a)}else t+=e.substr(n,9);n+=9}else t+=e.substr(n,3),n+=3}return t}function S(e,t){function n(e){var n=D(e);return n.match(t.UNRESERVED)?n:e}return e.scheme&&(e.scheme=String(e.scheme).replace(t.PCT_ENCODED,n).toLowerCase().replace(t.NOT_SCHEME,"")),void 0!==e.userinfo&&(e.userinfo=String(e.userinfo).replace(t.PCT_ENCODED,n).replace(t.NOT_USERINFO,A).replace(t.PCT_ENCODED,i)),void 0!==e.host&&(e.host=String(e.host).replace(t.PCT_ENCODED,n).toLowerCase().replace(t.NOT_HOST,A).replace(t.PCT_ENCODED,i)),void 0!==e.path&&(e.path=String(e.path).replace(t.PCT_ENCODED,n).replace(e.scheme?t.NOT_PATH:t.NOT_PATH_NOSCHEME,A).replace(t.PCT_ENCODED,i)),void 0!==e.query&&(e.query=String(e.query).replace(t.PCT_ENCODED,n).replace(t.NOT_QUERY,A).replace(t.PCT_ENCODED,i)),void 0!==e.fragment&&(e.fragment=String(e.fragment).replace(t.PCT_ENCODED,n).replace(t.NOT_FRAGMENT,A).replace(t.PCT_ENCODED,i)),e}function C(e){return e.replace(/^0*(.*)/,"$1")||"0"}function O(e,t){var n=e.match(t.IPV4ADDRESS)||[],r=c(n,2)[1];return r?r.split(".").map(C).join("."):e}function P(e,t){var n=e.match(t.IPV6ADDRESS)||[],r=c(n,3),i=r[1],o=r[2];if(i){for(var s=i.toLowerCase().split("::").reverse(),a=c(s,2),u=a[0],l=a[1],h=l?l.split(":").map(C):[],d=u.split(":").map(C),p=t.IPV4ADDRESS.test(d[d.length-1]),f=p?7:8,m=d.length-f,g=Array(f),_=0;_<f;++_)g[_]=h[_]||d[m+_]||"";p&&(g[f-1]=O(g[f-1],t));var y=g.reduce((function(e,t,n){if(!t||"0"===t){var r=e[e.length-1];r&&r.index+r.length===n?r.length++:e.push({index:n,length:1})}return e}),[]).sort((function(e,t){return t.length-e.length}))[0],v=void 0;if(y&&y.length>1){var b=g.slice(0,y.index),w=g.slice(y.index+y.length);v=b.join(":")+"::"+w.join(":")}else v=g.join(":");return o&&(v+="%"+o),v}return e}var F=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,I=void 0==="".match(/(){0}/)[1];function T(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={},r=!1!==t.iri?a:s;"suffix"===t.reference&&(e=(t.scheme?t.scheme+":":"")+"//"+e);var i=e.match(F);if(i){I?(n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5])):(n.scheme=i[1]||void 0,n.userinfo=-1!==e.indexOf("@")?i[3]:void 0,n.host=-1!==e.indexOf("//")?i[4]:void 0,n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=-1!==e.indexOf("?")?i[7]:void 0,n.fragment=-1!==e.indexOf("#")?i[8]:void 0,isNaN(n.port)&&(n.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?i[4]:void 0)),n.host&&(n.host=P(O(n.host,r),r)),void 0!==n.scheme||void 0!==n.userinfo||void 0!==n.host||void 0!==n.port||n.path||void 0!==n.query?void 0===n.scheme?n.reference="relative":void 0===n.fragment?n.reference="absolute":n.reference="uri":n.reference="same-document",t.reference&&"suffix"!==t.reference&&t.reference!==n.reference&&(n.error=n.error||"URI is not a "+t.reference+" reference.");var o=j[(t.scheme||n.scheme||"").toLowerCase()];if(t.unicodeSupport||o&&o.unicodeSupport)S(n,r);else{if(n.host&&(t.domainHost||o&&o.domainHost))try{n.host=k(n.host.replace(r.PCT_ENCODED,D).toLowerCase())}catch(e){n.error=n.error||"Host's domain name can not be converted to ASCII via punycode: "+e}S(n,s)}o&&o.parse&&o.parse(n,t)}else n.error=n.error||"URI can not be parsed.";return n}function R(e,t){var n=!1!==t.iri?a:s,r=[];return void 0!==e.userinfo&&(r.push(e.userinfo),r.push("@")),void 0!==e.host&&r.push(P(O(String(e.host),n),n).replace(n.IPV6ADDRESS,(function(e,t,n){return"["+t+(n?"%25"+n:"")+"]"}))),"number"==typeof e.port&&(r.push(":"),r.push(e.port.toString(10))),r.length?r.join(""):void 0}var B=/^\.\.?\//,M=/^\/\.(\/|$)/,q=/^\/\.\.(\/|$)/,L=/^\/?(?:.|\n)*?(?=\/|$)/;function N(e){for(var t=[];e.length;)if(e.match(B))e=e.replace(B,"");else if(e.match(M))e=e.replace(M,"/");else if(e.match(q))e=e.replace(q,"/"),t.pop();else if("."===e||".."===e)e="";else{var n=e.match(L);if(!n)throw new Error("Unexpected dot segment condition");var r=n[0];e=e.slice(r.length),t.push(r)}return t.join("")}function U(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.iri?a:s,r=[],i=j[(t.scheme||e.scheme||"").toLowerCase()];if(i&&i.serialize&&i.serialize(e,t),e.host)if(n.IPV6ADDRESS.test(e.host));else if(t.domainHost||i&&i.domainHost)try{e.host=t.iri?E(e.host):k(e.host.replace(n.PCT_ENCODED,D).toLowerCase())}catch(n){e.error=e.error||"Host's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+n}S(e,n),"suffix"!==t.reference&&e.scheme&&(r.push(e.scheme),r.push(":"));var o=R(e,t);if(void 0!==o&&("suffix"!==t.reference&&r.push("//"),r.push(o),e.path&&"/"!==e.path.charAt(0)&&r.push("/")),void 0!==e.path){var c=e.path;t.absolutePath||i&&i.absolutePath||(c=N(c)),void 0===o&&(c=c.replace(/^\/\//,"/%2F")),r.push(c)}return void 0!==e.query&&(r.push("?"),r.push(e.query)),void 0!==e.fragment&&(r.push("#"),r.push(e.fragment)),r.join("")}function W(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments[3],i={};return r||(e=T(U(e,n),n),t=T(U(t,n),n)),!(n=n||{}).tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=N(t.path||""),i.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=N(t.path||""),i.query=t.query):(t.path?("/"===t.path.charAt(0)?i.path=N(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path:i.path="/"+t.path,i.path=N(i.path)),i.query=t.query):(i.path=e.path,void 0!==t.query?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function $(e,t){return e&&e.toString().replace(t&&t.iri?a.PCT_ENCODED:s.PCT_ENCODED,D)}var z={scheme:"http",domainHost:!0,parse:function(e,t){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e},serialize:function(e,t){return e.port!==("https"!==String(e.scheme).toLowerCase()?80:443)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}},J={scheme:"https",domainHost:z.domainHost,parse:z.parse,serialize:z.serialize},H={},K="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",V="[0-9A-Fa-f]",X=n(n("%[EFef]"+V+"%"+V+V+"%"+V+V)+"|"+n("%[89A-Fa-f]"+V+"%"+V+V)+"|"+n("%"+V+V)),Y=t("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),G=new RegExp(K,"g"),Q=new RegExp(X,"g"),Z=new RegExp(t("[^]","[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]","[\\.]",'[\\"]',Y),"g"),ee=new RegExp(t("[^]",K,"[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]"),"g"),te=ee;function ne(e){var t=D(e);return t.match(G)?t:e}var re={scheme:"mailto",parse:function(e,t){var n=e,r=n.to=n.path?n.path.split(","):[];if(n.path=void 0,n.query){for(var i=!1,o={},s=n.query.split("&"),a=0,c=s.length;a<c;++a){var u=s[a].split("=");switch(u[0]){case"to":for(var l=u[1].split(","),h=0,d=l.length;h<d;++h)r.push(l[h]);break;case"subject":n.subject=$(u[1],t);break;case"body":n.body=$(u[1],t);break;default:i=!0,o[$(u[0],t)]=$(u[1],t)}}i&&(n.headers=o)}n.query=void 0;for(var p=0,f=r.length;p<f;++p){var m=r[p].split("@");if(m[0]=$(m[0]),t.unicodeSupport)m[1]=$(m[1],t).toLowerCase();else try{m[1]=k($(m[1],t).toLowerCase())}catch(e){n.error=n.error||"Email address's domain name can not be converted to ASCII via punycode: "+e}r[p]=m.join("@")}return n},serialize:function(e,t){var n,r=e,o=null!=(n=e.to)?n instanceof Array?n:"number"!=typeof n.length||n.split||n.setInterval||n.call?[n]:Array.prototype.slice.call(n):[];if(o){for(var s=0,a=o.length;s<a;++s){var c=String(o[s]),u=c.lastIndexOf("@"),l=c.slice(0,u).replace(Q,ne).replace(Q,i).replace(Z,A),h=c.slice(u+1);try{h=t.iri?E(h):k($(h,t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+e}o[s]=l+"@"+h}r.path=o.join(",")}var d=e.headers=e.headers||{};e.subject&&(d.subject=e.subject),e.body&&(d.body=e.body);var p=[];for(var f in d)d[f]!==H[f]&&p.push(f.replace(Q,ne).replace(Q,i).replace(ee,A)+"="+d[f].replace(Q,ne).replace(Q,i).replace(te,A));return p.length&&(r.query=p.join("&")),r}},ie=/^([^\:]+)\:(.*)/,oe={scheme:"urn",parse:function(e,t){var n=e.path&&e.path.match(ie),r=e;if(n){var i=t.scheme||r.scheme||"urn",o=n[1].toLowerCase(),s=n[2],a=i+":"+(t.nid||o),c=j[a];r.nid=o,r.nss=s,r.path=void 0,c&&(r=c.parse(r,t))}else r.error=r.error||"URN can not be parsed.";return r},serialize:function(e,t){var n=t.scheme||e.scheme||"urn",r=e.nid,i=n+":"+(t.nid||r),o=j[i];o&&(e=o.serialize(e,t));var s=e,a=e.nss;return s.path=(r||t.nid)+":"+a,s}},se=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,ae={scheme:"urn:uuid",parse:function(e,t){var n=e;return n.uuid=n.nss,n.nss=void 0,t.tolerant||n.uuid&&n.uuid.match(se)||(n.error=n.error||"UUID is not valid."),n},serialize:function(e,t){var n=e;return n.nss=(e.uuid||"").toLowerCase(),n}};j[z.scheme]=z,j[J.scheme]=J,j[re.scheme]=re,j[oe.scheme]=oe,j[ae.scheme]=ae,e.SCHEMES=j,e.pctEncChar=A,e.pctDecChars=D,e.parse=T,e.removeDotSegments=N,e.serialize=U,e.resolveComponents=W,e.resolve=function(e,t,n){var r=function(e,t){var n=e;if(t)for(var r in t)n[r]=t[r];return n}({scheme:"null"},n);return U(W(T(e,r),T(t,r),r,!0),r)},e.normalize=function(e,t){return"string"==typeof e?e=U(T(e,t),t):"object"===r(e)&&(e=T(U(e,t),t)),e},e.equal=function(e,t,n){return"string"==typeof e?e=U(T(e,n),n):"object"===r(e)&&(e=U(e,n)),"string"==typeof t?t=U(T(t,n),n):"object"===r(t)&&(t=U(t,n)),e===t},e.escapeComponent=function(e,t){return e&&e.toString().replace(t&&t.iri?a.ESCAPE:s.ESCAPE,A)},e.unescapeComponent=$,Object.defineProperty(e,"__esModule",{value:!0})}(t)},function(e,t,n){"use strict";e.exports=function(e){for(var t,n=0,r=e.length,i=0;i<r;)n++,(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<r&&56320==(64512&(t=e.charCodeAt(i)))&&i++;return n}},function(e,t,n){"use strict";var r=e.exports=function(e,t,n){"function"==typeof t&&(n=t,t={}),function e(t,n,i,o,s,a,c,u,l,h){if(o&&"object"==typeof o&&!Array.isArray(o)){for(var d in n(o,s,a,c,u,l,h),o){var p=o[d];if(Array.isArray(p)){if(d in r.arrayKeywords)for(var f=0;f<p.length;f++)e(t,n,i,p[f],s+"/"+d+"/"+f,a,s,d,o,f)}else if(d in r.propsKeywords){if(p&&"object"==typeof p)for(var m in p)e(t,n,i,p[m],s+"/"+d+"/"+m.replace(/~/g,"~0").replace(/\//g,"~1"),a,s,d,o,m)}else(d in r.keywords||t.allKeys&&!(d in r.skipKeywords))&&e(t,n,i,p,s+"/"+d,a,s,d,o)}i(o,s,a,c,u,l,h)}}(t,"function"==typeof(n=t.cb||n)?n:n.pre||function(){},n.post||function(){},e,"",e)};r.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},r.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},r.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},r.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},function(e,t,n){"use strict";var r=e.exports=function(){this._cache={}};r.prototype.put=function(e,t){this._cache[e]=t},r.prototype.get=function(e){return this._cache[e]},r.prototype.del=function(e){delete this._cache[e]},r.prototype.clear=function(){this._cache={}}},function(e,t,n){"use strict";var r=n(16),i=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,o=[0,31,28,31,30,31,30,31,31,30,31,30,31],s=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,a=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,c=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,u=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,l=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,h=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,d=/^(?:\/(?:[^~/]|~0|~1)*)*$/,p=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,f=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function m(e){return e="full"==e?"full":"fast",r.copy(m[e])}function g(e){var t=e.match(i);if(!t)return!1;var n=+t[1],r=+t[2],s=+t[3];return r>=1&&r<=12&&s>=1&&s<=(2==r&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(n)?29:o[r])}function _(e,t){var n=e.match(s);if(!n)return!1;var r=n[1],i=n[2],o=n[3],a=n[5];return(r<=23&&i<=59&&o<=59||23==r&&59==i&&60==o)&&(!t||a)}e.exports=m,m.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":u,url:l,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:a,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:w,uuid:h,"json-pointer":d,"json-pointer-uri-fragment":p,"relative-json-pointer":f},m.full={date:g,time:_,"date-time":function(e){var t=e.split(y);return 2==t.length&&g(t[0])&&_(t[1],!0)},uri:function(e){return v.test(e)&&c.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":u,url:l,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:a,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:w,uuid:h,"json-pointer":d,"json-pointer-uri-fragment":p,"relative-json-pointer":f};var y=/t|\s/i;var v=/\/|:/;var b=/[^\\]\\Z/;function w(e){if(b.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}}},function(e,t,n){"use strict";var r=n(190),i=n(16).toHash;e.exports=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],t=["type","$comment"];return e.all=i(t),e.types=i(["number","integer","string","array","object","boolean","null"]),e.forEach((function(n){n.rules=n.rules.map((function(n){var i;if("object"==typeof n){var o=Object.keys(n)[0];i=n[o],n=o,i.forEach((function(n){t.push(n),e.all[n]=!0}))}return t.push(n),e.all[n]={keyword:n,code:r[n],implements:i}})),e.all.$comment={keyword:"$comment",code:r.$comment},n.type&&(e.types[n.type]=n)})),e.keywords=i(t.concat(["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"])),e.custom={},e}},function(e,t,n){"use strict";e.exports={$ref:n(191),allOf:n(192),anyOf:n(193),$comment:n(194),const:n(195),contains:n(196),dependencies:n(197),enum:n(198),format:n(199),if:n(200),items:n(201),maximum:n(71),minimum:n(71),maxItems:n(72),minItems:n(72),maxLength:n(73),minLength:n(73),maxProperties:n(74),minProperties:n(74),multipleOf:n(202),not:n(203),oneOf:n(204),pattern:n(205),properties:n(206),propertyNames:n(207),required:n(208),uniqueItems:n(209),validate:n(70)}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i,o=" ",s=e.level,a=e.dataLevel,c=e.schema[t],u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(a||""),d="valid"+s;if("#"==c||"#/"==c)e.isRoot?(r=e.async,i="validate"):(r=!0===e.root.schema.$async,i="root.refVal[0]");else{var p=e.resolveRef(e.baseId,c,e.isRoot);if(void 0===p){var f=e.MissingRefError.message(e.baseId,c);if("fail"==e.opts.missingRefs){e.logger.error(f),(y=y||[]).push(o),o="",!1!==e.createErrors?(o+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { ref: '"+e.util.escapeQuotes(c)+"' } ",!1!==e.opts.messages&&(o+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(c)+"' "),e.opts.verbose&&(o+=" , schema: "+e.util.toQuotedString(c)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),o+=" } "):o+=" {} ";var m=o;o=y.pop(),!e.compositeRule&&l?e.async?o+=" throw new ValidationError(["+m+"]); ":o+=" validate.errors = ["+m+"]; return false; ":o+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",l&&(o+=" if (false) { ")}else{if("ignore"!=e.opts.missingRefs)throw new e.MissingRefError(e.baseId,c,f);e.logger.warn(f),l&&(o+=" if (true) { ")}}else if(p.inline){var g=e.util.copy(e);g.level++;var _="valid"+g.level;g.schema=p.schema,g.schemaPath="",g.errSchemaPath=c,o+=" "+e.validate(g).replace(/validate\.schema/g,p.code)+" ",l&&(o+=" if ("+_+") { ")}else r=!0===p.$async||e.async&&!1!==p.$async,i=p.code}if(i){var y;(y=y||[]).push(o),o="",e.opts.passContext?o+=" "+i+".call(this, ":o+=" "+i+"( ",o+=" "+h+", (dataPath || '')",'""'!=e.errorPath&&(o+=" + "+e.errorPath);var v=o+=" , "+(a?"data"+(a-1||""):"parentData")+" , "+(a?e.dataPathArr[a]:"parentDataProperty")+", rootData) ";if(o=y.pop(),r){if(!e.async)throw new Error("async schema referenced by sync schema");l&&(o+=" var "+d+"; "),o+=" try { await "+v+"; ",l&&(o+=" "+d+" = true; "),o+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",l&&(o+=" "+d+" = false; "),o+=" } ",l&&(o+=" if ("+d+") { ")}else o+=" if (!"+v+") { if (vErrors === null) vErrors = "+i+".errors; else vErrors = vErrors.concat("+i+".errors); errors = vErrors.length; } ",l&&(o+=" else { ")}return o}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,a=!e.opts.allErrors,c=e.util.copy(e),u="";c.level++;var l="valid"+c.level,h=c.baseId,d=!0,p=i;if(p)for(var f,m=-1,g=p.length-1;m<g;)f=p[m+=1],(e.opts.strictKeywords?"object"==typeof f&&Object.keys(f).length>0:e.util.schemaHasRules(f,e.RULES.all))&&(d=!1,c.schema=f,c.schemaPath=o+"["+m+"]",c.errSchemaPath=s+"/"+m,r+=" "+e.validate(c)+" ",c.baseId=h,a&&(r+=" if ("+l+") { ",u+="}"));return a&&(r+=d?" if (true) { ":" "+u.slice(0,-1)+" "),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d="errs__"+i,p=e.util.copy(e),f="";p.level++;var m="valid"+p.level;if(s.every((function(t){return e.opts.strictKeywords?"object"==typeof t&&Object.keys(t).length>0:e.util.schemaHasRules(t,e.RULES.all)}))){var g=p.baseId;r+=" var "+d+" = errors; var "+h+" = false; ";var _=e.compositeRule;e.compositeRule=p.compositeRule=!0;var y=s;if(y)for(var v,b=-1,w=y.length-1;b<w;)v=y[b+=1],p.schema=v,p.schemaPath=a+"["+b+"]",p.errSchemaPath=c+"/"+b,r+=" "+e.validate(p)+" ",p.baseId=g,r+=" "+h+" = "+h+" || "+m+"; if (!"+h+") { ",f+="}";e.compositeRule=p.compositeRule=_,r+=" "+f+" if (!"+h+") { var err = ",!1!==e.createErrors?(r+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: {} ",!1!==e.opts.messages&&(r+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&u&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),r+=" } else { errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } ",e.opts.allErrors&&(r+=" } ")}else u&&(r+=" if (true) { ");return r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.schema[t],o=e.errSchemaPath+"/"+t,s=(e.opts.allErrors,e.util.toQuotedString(i));return!0===e.opts.$comment?r+=" console.log("+s+");":"function"==typeof e.opts.$comment&&(r+=" self._opts.$comment("+s+", "+e.util.toQuotedString(o)+", validate.root.schema);"),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d=e.opts.$data&&s&&s.$data;d&&(r+=" var schema"+i+" = "+e.util.getData(s.$data,o,e.dataPathArr)+"; "),d||(r+=" var schema"+i+" = validate.schema"+a+";"),r+="var "+h+" = equal("+l+", schema"+i+"); if (!"+h+") { ";var p=p||[];p.push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { allowedValue: schema"+i+" } ",!1!==e.opts.messages&&(r+=" , message: 'should be equal to constant' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var f=r;return r=p.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+f+"]); ":r+=" validate.errors = ["+f+"]; return false; ":r+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" }",u&&(r+=" else { "),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d="errs__"+i,p=e.util.copy(e);p.level++;var f="valid"+p.level,m="i"+i,g=p.dataLevel=e.dataLevel+1,_="data"+g,y=e.baseId,v=e.opts.strictKeywords?"object"==typeof s&&Object.keys(s).length>0:e.util.schemaHasRules(s,e.RULES.all);if(r+="var "+d+" = errors;var "+h+";",v){var b=e.compositeRule;e.compositeRule=p.compositeRule=!0,p.schema=s,p.schemaPath=a,p.errSchemaPath=c,r+=" var "+f+" = false; for (var "+m+" = 0; "+m+" < "+l+".length; "+m+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0);var w=l+"["+m+"]";p.dataPathArr[g]=m;var x=e.validate(p);p.baseId=y,e.util.varOccurences(x,_)<2?r+=" "+e.util.varReplace(x,_,w)+" ":r+=" var "+_+" = "+w+"; "+x+" ",r+=" if ("+f+") break; } ",e.compositeRule=p.compositeRule=b,r+=" if (!"+f+") {"}else r+=" if ("+l+".length == 0) {";var k=k||[];k.push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: {} ",!1!==e.opts.messages&&(r+=" , message: 'should contain a valid item' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var E=r;return r=k.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+E+"]); ":r+=" validate.errors = ["+E+"]; return false; ":r+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { ",v&&(r+=" errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } "),e.opts.allErrors&&(r+=" } "),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="errs__"+i,d=e.util.copy(e),p="";d.level++;var f="valid"+d.level,m={},g={},_=e.opts.ownProperties;for(w in s)if("__proto__"!=w){var y=s[w],v=Array.isArray(y)?g:m;v[w]=y}r+="var "+h+" = errors;";var b=e.errorPath;for(var w in r+="var missing"+i+";",g)if((v=g[w]).length){if(r+=" if ( "+l+e.util.getProperty(w)+" !== undefined ",_&&(r+=" && Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(w)+"') "),u){r+=" && ( ";var x=v;if(x)for(var k=-1,E=x.length-1;k<E;){O=x[k+=1],k&&(r+=" || "),r+=" ( ( "+(T=l+(I=e.util.getProperty(O)))+" === undefined ",_&&(r+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(O)+"') "),r+=") && (missing"+i+" = "+e.util.toQuotedString(e.opts.jsonPointers?O:I)+") ) "}r+=")) { ";var j="missing"+i,A="' + "+j+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(b,j,!0):b+" + "+j);var D=D||[];D.push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { property: '"+e.util.escapeQuotes(w)+"', missingProperty: '"+A+"', depsCount: "+v.length+", deps: '"+e.util.escapeQuotes(1==v.length?v[0]:v.join(", "))+"' } ",!1!==e.opts.messages&&(r+=" , message: 'should have ",1==v.length?r+="property "+e.util.escapeQuotes(v[0]):r+="properties "+e.util.escapeQuotes(v.join(", ")),r+=" when property "+e.util.escapeQuotes(w)+" is present' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var S=r;r=D.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+S+"]); ":r+=" validate.errors = ["+S+"]; return false; ":r+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{r+=" ) { ";var C=v;if(C)for(var O,P=-1,F=C.length-1;P<F;){O=C[P+=1];var I=e.util.getProperty(O),T=(A=e.util.escapeQuotes(O),l+I);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(b,O,e.opts.jsonPointers)),r+=" if ( "+T+" === undefined ",_&&(r+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(O)+"') "),r+=") { var err = ",!1!==e.createErrors?(r+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { property: '"+e.util.escapeQuotes(w)+"', missingProperty: '"+A+"', depsCount: "+v.length+", deps: '"+e.util.escapeQuotes(1==v.length?v[0]:v.join(", "))+"' } ",!1!==e.opts.messages&&(r+=" , message: 'should have ",1==v.length?r+="property "+e.util.escapeQuotes(v[0]):r+="properties "+e.util.escapeQuotes(v.join(", ")),r+=" when property "+e.util.escapeQuotes(w)+" is present' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}r+=" } ",u&&(p+="}",r+=" else { ")}e.errorPath=b;var R=d.baseId;for(var w in m){y=m[w];(e.opts.strictKeywords?"object"==typeof y&&Object.keys(y).length>0:e.util.schemaHasRules(y,e.RULES.all))&&(r+=" "+f+" = true; if ( "+l+e.util.getProperty(w)+" !== undefined ",_&&(r+=" && Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(w)+"') "),r+=") { ",d.schema=y,d.schemaPath=a+e.util.getProperty(w),d.errSchemaPath=c+"/"+e.util.escapeFragment(w),r+=" "+e.validate(d)+" ",d.baseId=R,r+=" } ",u&&(r+=" if ("+f+") { ",p+="}"))}return u&&(r+=" "+p+" if ("+h+" == errors) {"),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d=e.opts.$data&&s&&s.$data;d&&(r+=" var schema"+i+" = "+e.util.getData(s.$data,o,e.dataPathArr)+"; ");var p="i"+i,f="schema"+i;d||(r+=" var "+f+" = validate.schema"+a+";"),r+="var "+h+";",d&&(r+=" if (schema"+i+" === undefined) "+h+" = true; else if (!Array.isArray(schema"+i+")) "+h+" = false; else {"),r+=h+" = false;for (var "+p+"=0; "+p+"<"+f+".length; "+p+"++) if (equal("+l+", "+f+"["+p+"])) { "+h+" = true; break; }",d&&(r+=" } "),r+=" if (!"+h+") { ";var m=m||[];m.push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { allowedValues: schema"+i+" } ",!1!==e.opts.messages&&(r+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var g=r;return r=m.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+g+"]); ":r+=" validate.errors = ["+g+"]; return false; ":r+=" var err = "+g+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" }",u&&(r+=" else { "),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||"");if(!1===e.opts.format)return u&&(r+=" if (true) { "),r;var h,d=e.opts.$data&&s&&s.$data;d?(r+=" var schema"+i+" = "+e.util.getData(s.$data,o,e.dataPathArr)+"; ",h="schema"+i):h=s;var p=e.opts.unknownFormats,f=Array.isArray(p);if(d){r+=" var "+(m="format"+i)+" = formats["+h+"]; var "+(g="isObject"+i)+" = typeof "+m+" == 'object' && !("+m+" instanceof RegExp) && "+m+".validate; var "+(_="formatType"+i)+" = "+g+" && "+m+".type || 'string'; if ("+g+") { ",e.async&&(r+=" var async"+i+" = "+m+".async; "),r+=" "+m+" = "+m+".validate; } if ( ",d&&(r+=" ("+h+" !== undefined && typeof "+h+" != 'string') || "),r+=" (","ignore"!=p&&(r+=" ("+h+" && !"+m+" ",f&&(r+=" && self._opts.unknownFormats.indexOf("+h+") == -1 "),r+=") || "),r+=" ("+m+" && "+_+" == '"+n+"' && !(typeof "+m+" == 'function' ? ",e.async?r+=" (async"+i+" ? await "+m+"("+l+") : "+m+"("+l+")) ":r+=" "+m+"("+l+") ",r+=" : "+m+".test("+l+"))))) {"}else{var m;if(!(m=e.formats[s])){if("ignore"==p)return e.logger.warn('unknown format "'+s+'" ignored in schema at path "'+e.errSchemaPath+'"'),u&&(r+=" if (true) { "),r;if(f&&p.indexOf(s)>=0)return u&&(r+=" if (true) { "),r;throw new Error('unknown format "'+s+'" is used in schema at path "'+e.errSchemaPath+'"')}var g,_=(g="object"==typeof m&&!(m instanceof RegExp)&&m.validate)&&m.type||"string";if(g){var y=!0===m.async;m=m.validate}if(_!=n)return u&&(r+=" if (true) { "),r;if(y){if(!e.async)throw new Error("async format in sync schema");r+=" if (!(await "+(v="formats"+e.util.getProperty(s)+".validate")+"("+l+"))) { "}else{r+=" if (! ";var v="formats"+e.util.getProperty(s);g&&(v+=".validate"),r+="function"==typeof m?" "+v+"("+l+") ":" "+v+".test("+l+") ",r+=") { "}}var b=b||[];b.push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { format: ",r+=d?""+h:""+e.util.toQuotedString(s),r+=" } ",!1!==e.opts.messages&&(r+=" , message: 'should match format \"",r+=d?"' + "+h+" + '":""+e.util.escapeQuotes(s),r+="\"' "),e.opts.verbose&&(r+=" , schema: ",r+=d?"validate.schema"+a:""+e.util.toQuotedString(s),r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var w=r;return r=b.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+w+"]); ":r+=" validate.errors = ["+w+"]; return false; ":r+=" var err = "+w+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",u&&(r+=" else { "),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d="errs__"+i,p=e.util.copy(e);p.level++;var f="valid"+p.level,m=e.schema.then,g=e.schema.else,_=void 0!==m&&(e.opts.strictKeywords?"object"==typeof m&&Object.keys(m).length>0:e.util.schemaHasRules(m,e.RULES.all)),y=void 0!==g&&(e.opts.strictKeywords?"object"==typeof g&&Object.keys(g).length>0:e.util.schemaHasRules(g,e.RULES.all)),v=p.baseId;if(_||y){var b;p.createErrors=!1,p.schema=s,p.schemaPath=a,p.errSchemaPath=c,r+=" var "+d+" = errors; var "+h+" = true; ";var w=e.compositeRule;e.compositeRule=p.compositeRule=!0,r+=" "+e.validate(p)+" ",p.baseId=v,p.createErrors=!0,r+=" errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } ",e.compositeRule=p.compositeRule=w,_?(r+=" if ("+f+") { ",p.schema=e.schema.then,p.schemaPath=e.schemaPath+".then",p.errSchemaPath=e.errSchemaPath+"/then",r+=" "+e.validate(p)+" ",p.baseId=v,r+=" "+h+" = "+f+"; ",_&&y?r+=" var "+(b="ifClause"+i)+" = 'then'; ":b="'then'",r+=" } ",y&&(r+=" else { ")):r+=" if (!"+f+") { ",y&&(p.schema=e.schema.else,p.schemaPath=e.schemaPath+".else",p.errSchemaPath=e.errSchemaPath+"/else",r+=" "+e.validate(p)+" ",p.baseId=v,r+=" "+h+" = "+f+"; ",_&&y?r+=" var "+(b="ifClause"+i)+" = 'else'; ":b="'else'",r+=" } "),r+=" if (!"+h+") { var err = ",!1!==e.createErrors?(r+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { failingKeyword: "+b+" } ",!1!==e.opts.messages&&(r+=" , message: 'should match \"' + "+b+" + '\" schema' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&u&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),r+=" } ",u&&(r+=" else { ")}else u&&(r+=" if (true) { ");return r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d="errs__"+i,p=e.util.copy(e),f="";p.level++;var m="valid"+p.level,g="i"+i,_=p.dataLevel=e.dataLevel+1,y="data"+_,v=e.baseId;if(r+="var "+d+" = errors;var "+h+";",Array.isArray(s)){var b=e.schema.additionalItems;if(!1===b){r+=" "+h+" = "+l+".length <= "+s.length+"; ";var w=c;c=e.errSchemaPath+"/additionalItems",r+=" if (!"+h+") { ";var x=x||[];x.push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+s.length+" } ",!1!==e.opts.messages&&(r+=" , message: 'should NOT have more than "+s.length+" items' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var k=r;r=x.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+k+"]); ":r+=" validate.errors = ["+k+"]; return false; ":r+=" var err = "+k+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",c=w,u&&(f+="}",r+=" else { ")}var E=s;if(E)for(var j,A=-1,D=E.length-1;A<D;)if(j=E[A+=1],e.opts.strictKeywords?"object"==typeof j&&Object.keys(j).length>0:e.util.schemaHasRules(j,e.RULES.all)){r+=" "+m+" = true; if ("+l+".length > "+A+") { ";var S=l+"["+A+"]";p.schema=j,p.schemaPath=a+"["+A+"]",p.errSchemaPath=c+"/"+A,p.errorPath=e.util.getPathExpr(e.errorPath,A,e.opts.jsonPointers,!0),p.dataPathArr[_]=A;var C=e.validate(p);p.baseId=v,e.util.varOccurences(C,y)<2?r+=" "+e.util.varReplace(C,y,S)+" ":r+=" var "+y+" = "+S+"; "+C+" ",r+=" } ",u&&(r+=" if ("+m+") { ",f+="}")}if("object"==typeof b&&(e.opts.strictKeywords?"object"==typeof b&&Object.keys(b).length>0:e.util.schemaHasRules(b,e.RULES.all))){p.schema=b,p.schemaPath=e.schemaPath+".additionalItems",p.errSchemaPath=e.errSchemaPath+"/additionalItems",r+=" "+m+" = true; if ("+l+".length > "+s.length+") { for (var "+g+" = "+s.length+"; "+g+" < "+l+".length; "+g+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,g,e.opts.jsonPointers,!0);S=l+"["+g+"]";p.dataPathArr[_]=g;C=e.validate(p);p.baseId=v,e.util.varOccurences(C,y)<2?r+=" "+e.util.varReplace(C,y,S)+" ":r+=" var "+y+" = "+S+"; "+C+" ",u&&(r+=" if (!"+m+") break; "),r+=" } } ",u&&(r+=" if ("+m+") { ",f+="}")}}else if(e.opts.strictKeywords?"object"==typeof s&&Object.keys(s).length>0:e.util.schemaHasRules(s,e.RULES.all)){p.schema=s,p.schemaPath=a,p.errSchemaPath=c,r+=" for (var "+g+" = 0; "+g+" < "+l+".length; "+g+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,g,e.opts.jsonPointers,!0);S=l+"["+g+"]";p.dataPathArr[_]=g;C=e.validate(p);p.baseId=v,e.util.varOccurences(C,y)<2?r+=" "+e.util.varReplace(C,y,S)+" ":r+=" var "+y+" = "+S+"; "+C+" ",u&&(r+=" if (!"+m+") break; "),r+=" }"}return u&&(r+=" "+f+" if ("+d+" == errors) {"),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i=" ",o=e.level,s=e.dataLevel,a=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(s||""),d=e.opts.$data&&a&&a.$data;if(d?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",r="schema"+o):r=a,!d&&"number"!=typeof a)throw new Error(t+" must be number");i+="var division"+o+";if (",d&&(i+=" "+r+" !== undefined && ( typeof "+r+" != 'number' || "),i+=" (division"+o+" = "+h+" / "+r+", ",e.opts.multipleOfPrecision?i+=" Math.abs(Math.round(division"+o+") - division"+o+") > 1e-"+e.opts.multipleOfPrecision+" ":i+=" division"+o+" !== parseInt(division"+o+") ",i+=" ) ",d&&(i+=" ) "),i+=" ) { ";var p=p||[];p.push(i),i="",!1!==e.createErrors?(i+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { multipleOf: "+r+" } ",!1!==e.opts.messages&&(i+=" , message: 'should be multiple of ",i+=d?"' + "+r:r+"'"),e.opts.verbose&&(i+=" , schema: ",i+=d?"validate.schema"+c:""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var f=i;return i=p.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+f+"]); ":i+=" validate.errors = ["+f+"]; return false; ":i+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",l&&(i+=" else { "),i}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="errs__"+i,d=e.util.copy(e);d.level++;var p="valid"+d.level;if(e.opts.strictKeywords?"object"==typeof s&&Object.keys(s).length>0:e.util.schemaHasRules(s,e.RULES.all)){d.schema=s,d.schemaPath=a,d.errSchemaPath=c,r+=" var "+h+" = errors; ";var f,m=e.compositeRule;e.compositeRule=d.compositeRule=!0,d.createErrors=!1,d.opts.allErrors&&(f=d.opts.allErrors,d.opts.allErrors=!1),r+=" "+e.validate(d)+" ",d.createErrors=!0,f&&(d.opts.allErrors=f),e.compositeRule=d.compositeRule=m,r+=" if ("+p+") { ";var g=g||[];g.push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: {} ",!1!==e.opts.messages&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var _=r;r=g.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+_+"]); ":r+=" validate.errors = ["+_+"]; return false; ":r+=" var err = "+_+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.opts.allErrors&&(r+=" } ")}else r+=" var err = ",!1!==e.createErrors?(r+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: {} ",!1!==e.opts.messages&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",u&&(r+=" if (false) { ");return r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d="errs__"+i,p=e.util.copy(e),f="";p.level++;var m="valid"+p.level,g=p.baseId,_="prevValid"+i,y="passingSchemas"+i;r+="var "+d+" = errors , "+_+" = false , "+h+" = false , "+y+" = null; ";var v=e.compositeRule;e.compositeRule=p.compositeRule=!0;var b=s;if(b)for(var w,x=-1,k=b.length-1;x<k;)w=b[x+=1],(e.opts.strictKeywords?"object"==typeof w&&Object.keys(w).length>0:e.util.schemaHasRules(w,e.RULES.all))?(p.schema=w,p.schemaPath=a+"["+x+"]",p.errSchemaPath=c+"/"+x,r+=" "+e.validate(p)+" ",p.baseId=g):r+=" var "+m+" = true; ",x&&(r+=" if ("+m+" && "+_+") { "+h+" = false; "+y+" = ["+y+", "+x+"]; } else { ",f+="}"),r+=" if ("+m+") { "+h+" = "+_+" = true; "+y+" = "+x+"; }";return e.compositeRule=p.compositeRule=v,r+=f+"if (!"+h+") { var err = ",!1!==e.createErrors?(r+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { passingSchemas: "+y+" } ",!1!==e.opts.messages&&(r+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&u&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),r+="} else { errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; }",e.opts.allErrors&&(r+=" } "),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i=" ",o=e.level,s=e.dataLevel,a=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(s||""),d=e.opts.$data&&a&&a.$data;d?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",r="schema"+o):r=a,i+="if ( ",d&&(i+=" ("+r+" !== undefined && typeof "+r+" != 'string') || "),i+=" !"+(d?"(new RegExp("+r+"))":e.usePattern(a))+".test("+h+") ) { ";var p=p||[];p.push(i),i="",!1!==e.createErrors?(i+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { pattern: ",i+=d?""+r:""+e.util.toQuotedString(a),i+=" } ",!1!==e.opts.messages&&(i+=" , message: 'should match pattern \"",i+=d?"' + "+r+" + '":""+e.util.escapeQuotes(a),i+="\"' "),e.opts.verbose&&(i+=" , schema: ",i+=d?"validate.schema"+c:""+e.util.toQuotedString(a),i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var f=i;return i=p.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+f+"]); ":i+=" validate.errors = ["+f+"]; return false; ":i+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",l&&(i+=" else { "),i}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="errs__"+i,d=e.util.copy(e),p="";d.level++;var f="valid"+d.level,m="key"+i,g="idx"+i,_=d.dataLevel=e.dataLevel+1,y="data"+_,v="dataProperties"+i,b=Object.keys(s||{}).filter(I),w=e.schema.patternProperties||{},x=Object.keys(w).filter(I),k=e.schema.additionalProperties,E=b.length||x.length,j=!1===k,A="object"==typeof k&&Object.keys(k).length,D=e.opts.removeAdditional,S=j||A||D,C=e.opts.ownProperties,O=e.baseId,P=e.schema.required;if(P&&(!e.opts.$data||!P.$data)&&P.length<e.opts.loopRequired)var F=e.util.toHash(P);function I(e){return"__proto__"!==e}if(r+="var "+h+" = errors;var "+f+" = true;",C&&(r+=" var "+v+" = undefined;"),S){if(r+=C?" "+v+" = "+v+" || Object.keys("+l+"); for (var "+g+"=0; "+g+"<"+v+".length; "+g+"++) { var "+m+" = "+v+"["+g+"]; ":" for (var "+m+" in "+l+") { ",E){if(r+=" var isAdditional"+i+" = !(false ",b.length)if(b.length>8)r+=" || validate.schema"+a+".hasOwnProperty("+m+") ";else{var T=b;if(T)for(var R=-1,B=T.length-1;R<B;)X=T[R+=1],r+=" || "+m+" == "+e.util.toQuotedString(X)+" "}if(x.length){var M=x;if(M)for(var q=-1,L=M.length-1;q<L;)oe=M[q+=1],r+=" || "+e.usePattern(oe)+".test("+m+") "}r+=" ); if (isAdditional"+i+") { "}if("all"==D)r+=" delete "+l+"["+m+"]; ";else{var N=e.errorPath,U="' + "+m+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers)),j)if(D)r+=" delete "+l+"["+m+"]; ";else{r+=" "+f+" = false; ";var W=c;c=e.errSchemaPath+"/additionalProperties",(ne=ne||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { additionalProperty: '"+U+"' } ",!1!==e.opts.messages&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is an invalid additional property":r+="should NOT have additional properties",r+="' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var $=r;r=ne.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+$+"]); ":r+=" validate.errors = ["+$+"]; return false; ":r+=" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c=W,u&&(r+=" break; ")}else if(A)if("failing"==D){r+=" var "+h+" = errors; ";var z=e.compositeRule;e.compositeRule=d.compositeRule=!0,d.schema=k,d.schemaPath=e.schemaPath+".additionalProperties",d.errSchemaPath=e.errSchemaPath+"/additionalProperties",d.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers);var J=l+"["+m+"]";d.dataPathArr[_]=m;var H=e.validate(d);d.baseId=O,e.util.varOccurences(H,y)<2?r+=" "+e.util.varReplace(H,y,J)+" ":r+=" var "+y+" = "+J+"; "+H+" ",r+=" if (!"+f+") { errors = "+h+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+l+"["+m+"]; } ",e.compositeRule=d.compositeRule=z}else{d.schema=k,d.schemaPath=e.schemaPath+".additionalProperties",d.errSchemaPath=e.errSchemaPath+"/additionalProperties",d.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers);J=l+"["+m+"]";d.dataPathArr[_]=m;H=e.validate(d);d.baseId=O,e.util.varOccurences(H,y)<2?r+=" "+e.util.varReplace(H,y,J)+" ":r+=" var "+y+" = "+J+"; "+H+" ",u&&(r+=" if (!"+f+") break; ")}e.errorPath=N}E&&(r+=" } "),r+=" } ",u&&(r+=" if ("+f+") { ",p+="}")}var K=e.opts.useDefaults&&!e.compositeRule;if(b.length){var V=b;if(V)for(var X,Y=-1,G=V.length-1;Y<G;){var Q=s[X=V[Y+=1]];if(e.opts.strictKeywords?"object"==typeof Q&&Object.keys(Q).length>0:e.util.schemaHasRules(Q,e.RULES.all)){var Z=e.util.getProperty(X),ee=(J=l+Z,K&&void 0!==Q.default);d.schema=Q,d.schemaPath=a+Z,d.errSchemaPath=c+"/"+e.util.escapeFragment(X),d.errorPath=e.util.getPath(e.errorPath,X,e.opts.jsonPointers),d.dataPathArr[_]=e.util.toQuotedString(X);H=e.validate(d);if(d.baseId=O,e.util.varOccurences(H,y)<2){H=e.util.varReplace(H,y,J);var te=J}else{te=y;r+=" var "+y+" = "+J+"; "}if(ee)r+=" "+H+" ";else{if(F&&F[X]){r+=" if ( "+te+" === undefined ",C&&(r+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(X)+"') "),r+=") { "+f+" = false; ";N=e.errorPath,W=c;var ne,re=e.util.escapeQuotes(X);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(N,X,e.opts.jsonPointers)),c=e.errSchemaPath+"/required",(ne=ne||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { missingProperty: '"+re+"' } ",!1!==e.opts.messages&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+re+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";$=r;r=ne.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+$+"]); ":r+=" validate.errors = ["+$+"]; return false; ":r+=" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c=W,e.errorPath=N,r+=" } else { "}else u?(r+=" if ( "+te+" === undefined ",C&&(r+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(X)+"') "),r+=") { "+f+" = true; } else { "):(r+=" if ("+te+" !== undefined ",C&&(r+=" && Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(X)+"') "),r+=" ) { ");r+=" "+H+" } "}}u&&(r+=" if ("+f+") { ",p+="}")}}if(x.length){var ie=x;if(ie)for(var oe,se=-1,ae=ie.length-1;se<ae;){Q=w[oe=ie[se+=1]];if(e.opts.strictKeywords?"object"==typeof Q&&Object.keys(Q).length>0:e.util.schemaHasRules(Q,e.RULES.all)){d.schema=Q,d.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(oe),d.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(oe),r+=C?" "+v+" = "+v+" || Object.keys("+l+"); for (var "+g+"=0; "+g+"<"+v+".length; "+g+"++) { var "+m+" = "+v+"["+g+"]; ":" for (var "+m+" in "+l+") { ",r+=" if ("+e.usePattern(oe)+".test("+m+")) { ",d.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers);J=l+"["+m+"]";d.dataPathArr[_]=m;H=e.validate(d);d.baseId=O,e.util.varOccurences(H,y)<2?r+=" "+e.util.varReplace(H,y,J)+" ":r+=" var "+y+" = "+J+"; "+H+" ",u&&(r+=" if (!"+f+") break; "),r+=" } ",u&&(r+=" else "+f+" = true; "),r+=" } ",u&&(r+=" if ("+f+") { ",p+="}")}}}return u&&(r+=" "+p+" if ("+h+" == errors) {"),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="errs__"+i,d=e.util.copy(e);d.level++;var p="valid"+d.level;if(r+="var "+h+" = errors;",e.opts.strictKeywords?"object"==typeof s&&Object.keys(s).length>0:e.util.schemaHasRules(s,e.RULES.all)){d.schema=s,d.schemaPath=a,d.errSchemaPath=c;var f="key"+i,m="idx"+i,g="i"+i,_="' + "+f+" + '",y="data"+(d.dataLevel=e.dataLevel+1),v="dataProperties"+i,b=e.opts.ownProperties,w=e.baseId;b&&(r+=" var "+v+" = undefined; "),r+=b?" "+v+" = "+v+" || Object.keys("+l+"); for (var "+m+"=0; "+m+"<"+v+".length; "+m+"++) { var "+f+" = "+v+"["+m+"]; ":" for (var "+f+" in "+l+") { ",r+=" var startErrs"+i+" = errors; ";var x=f,k=e.compositeRule;e.compositeRule=d.compositeRule=!0;var E=e.validate(d);d.baseId=w,e.util.varOccurences(E,y)<2?r+=" "+e.util.varReplace(E,y,x)+" ":r+=" var "+y+" = "+x+"; "+E+" ",e.compositeRule=d.compositeRule=k,r+=" if (!"+p+") { for (var "+g+"=startErrs"+i+"; "+g+"<errors; "+g+"++) { vErrors["+g+"].propertyName = "+f+"; } var err = ",!1!==e.createErrors?(r+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { propertyName: '"+_+"' } ",!1!==e.opts.messages&&(r+=" , message: 'property name \\'"+_+"\\' is invalid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&u&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),u&&(r+=" break; "),r+=" } }"}return u&&(r+=" if ("+h+" == errors) {"),r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=" ",i=e.level,o=e.dataLevel,s=e.schema[t],a=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,l="data"+(o||""),h="valid"+i,d=e.opts.$data&&s&&s.$data;d&&(r+=" var schema"+i+" = "+e.util.getData(s.$data,o,e.dataPathArr)+"; ");var p="schema"+i;if(!d)if(s.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var f=[],m=s;if(m)for(var g,_=-1,y=m.length-1;_<y;){g=m[_+=1];var v=e.schema.properties[g];v&&(e.opts.strictKeywords?"object"==typeof v&&Object.keys(v).length>0:e.util.schemaHasRules(v,e.RULES.all))||(f[f.length]=g)}}else f=s;if(d||f.length){var b=e.errorPath,w=d||f.length>=e.opts.loopRequired,x=e.opts.ownProperties;if(u)if(r+=" var missing"+i+"; ",w){d||(r+=" var "+p+" = validate.schema"+a+"; ");var k="' + "+(C="schema"+i+"["+(A="i"+i)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(b,C,e.opts.jsonPointers)),r+=" var "+h+" = true; ",d&&(r+=" if (schema"+i+" === undefined) "+h+" = true; else if (!Array.isArray(schema"+i+")) "+h+" = false; else {"),r+=" for (var "+A+" = 0; "+A+" < "+p+".length; "+A+"++) { "+h+" = "+l+"["+p+"["+A+"]] !== undefined ",x&&(r+=" && Object.prototype.hasOwnProperty.call("+l+", "+p+"["+A+"]) "),r+="; if (!"+h+") break; } ",d&&(r+=" } "),r+=" if (!"+h+") { ",(S=S||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { missingProperty: '"+k+"' } ",!1!==e.opts.messages&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+k+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";var E=r;r=S.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+E+"]); ":r+=" validate.errors = ["+E+"]; return false; ":r+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { "}else{r+=" if ( ";var j=f;if(j)for(var A=-1,D=j.length-1;A<D;){P=j[A+=1],A&&(r+=" || "),r+=" ( ( "+(R=l+(T=e.util.getProperty(P)))+" === undefined ",x&&(r+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(P)+"') "),r+=") && (missing"+i+" = "+e.util.toQuotedString(e.opts.jsonPointers?P:T)+") ) "}r+=") { ";var S;k="' + "+(C="missing"+i)+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(b,C,!0):b+" + "+C),(S=S||[]).push(r),r="",!1!==e.createErrors?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { missingProperty: '"+k+"' } ",!1!==e.opts.messages&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+k+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ";E=r;r=S.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+E+"]); ":r+=" validate.errors = ["+E+"]; return false; ":r+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { "}else if(w){d||(r+=" var "+p+" = validate.schema"+a+"; ");var C;k="' + "+(C="schema"+i+"["+(A="i"+i)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(b,C,e.opts.jsonPointers)),d&&(r+=" if ("+p+" && !Array.isArray("+p+")) { var err = ",!1!==e.createErrors?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { missingProperty: '"+k+"' } ",!1!==e.opts.messages&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+k+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+p+" !== undefined) { "),r+=" for (var "+A+" = 0; "+A+" < "+p+".length; "+A+"++) { if ("+l+"["+p+"["+A+"]] === undefined ",x&&(r+=" || ! Object.prototype.hasOwnProperty.call("+l+", "+p+"["+A+"]) "),r+=") { var err = ",!1!==e.createErrors?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { missingProperty: '"+k+"' } ",!1!==e.opts.messages&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+k+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",d&&(r+=" } ")}else{var O=f;if(O)for(var P,F=-1,I=O.length-1;F<I;){P=O[F+=1];var T=e.util.getProperty(P),R=(k=e.util.escapeQuotes(P),l+T);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(b,P,e.opts.jsonPointers)),r+=" if ( "+R+" === undefined ",x&&(r+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+e.util.escapeQuotes(P)+"') "),r+=") { var err = ",!1!==e.createErrors?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { missingProperty: '"+k+"' } ",!1!==e.opts.messages&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+k+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=b}else u&&(r+=" if (true) {");return r}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i=" ",o=e.level,s=e.dataLevel,a=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,l=!e.opts.allErrors,h="data"+(s||""),d="valid"+o,p=e.opts.$data&&a&&a.$data;if(p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",r="schema"+o):r=a,(a||p)&&!1!==e.opts.uniqueItems){p&&(i+=" var "+d+"; if ("+r+" === false || "+r+" === undefined) "+d+" = true; else if (typeof "+r+" != 'boolean') "+d+" = false; else { "),i+=" var i = "+h+".length , "+d+" = true , j; if (i > 1) { ";var f=e.schema.items&&e.schema.items.type,m=Array.isArray(f);if(!f||"object"==f||"array"==f||m&&(f.indexOf("object")>=0||f.indexOf("array")>=0))i+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+h+"[i], "+h+"[j])) { "+d+" = false; break outer; } } } ";else{i+=" var itemIndices = {}, item; for (;i--;) { var item = "+h+"[i]; ";var g="checkDataType"+(m?"s":"");i+=" if ("+e.util[g](f,"item",e.opts.strictNumbers,!0)+") continue; ",m&&(i+=" if (typeof item == 'string') item = '\"' + item; "),i+=" if (typeof itemIndices[item] == 'number') { "+d+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}i+=" } ",p&&(i+=" } "),i+=" if (!"+d+") { ";var _=_||[];_.push(i),i="",!1!==e.createErrors?(i+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(i+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(i+=" , schema: ",i+=p?"validate.schema"+c:""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var y=i;i=_.pop(),!e.compositeRule&&l?e.async?i+=" throw new ValidationError(["+y+"]); ":i+=" validate.errors = ["+y+"]; return false; ":i+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",l&&(i+=" else { ")}else l&&(i+=" if (true) { ");return i}},function(e,t,n){"use strict";var r=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];e.exports=function(e,t){for(var n=0;n<t.length;n++){e=JSON.parse(JSON.stringify(e));var i,o=t[n].split("/"),s=e;for(i=1;i<o.length;i++)s=s[o[i]];for(i=0;i<r.length;i++){var a=r[i],c=s[a];c&&(s[a]={anyOf:[c,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return e}},function(e,t,n){"use strict";var r=n(41).MissingRef;e.exports=function e(t,n,i){var o=this;if("function"!=typeof this._opts.loadSchema)throw new Error("options.loadSchema should be a function");"function"==typeof n&&(i=n,n=void 0);var s=a(t).then((function(){var e=o._addSchema(t,void 0,n);return e.validate||function e(t){try{return o._compile(t)}catch(e){if(e instanceof r)return i(e);throw e}function i(r){var i=r.missingSchema;if(u(i))throw new Error("Schema "+i+" is loaded but "+r.missingRef+" cannot be resolved");var s=o._loadingSchemas[i];return s||(s=o._loadingSchemas[i]=o._opts.loadSchema(i)).then(c,c),s.then((function(e){if(!u(i))return a(e).then((function(){u(i)||o.addSchema(e,i,void 0,n)}))})).then((function(){return e(t)}));function c(){delete o._loadingSchemas[i]}function u(e){return o._refs[e]||o._schemas[e]}}}(e)}));i&&s.then((function(e){i(null,e)}),i);return s;function a(t){var n=t.$schema;return n&&!o.getSchema(n)?e.call(o,{$ref:n},!0):Promise.resolve()}}},function(e,t,n){"use strict";var r=/^[a-z_$][a-z0-9_$-]*$/i,i=n(213),o=n(214);e.exports={add:function(e,t){var n=this.RULES;if(n.keywords[e])throw new Error("Keyword "+e+" is already defined");if(!r.test(e))throw new Error("Keyword "+e+" is not a valid identifier");if(t){this.validateKeyword(t,!0);var o=t.type;if(Array.isArray(o))for(var s=0;s<o.length;s++)c(e,o[s],t);else c(e,o,t);var a=t.metaSchema;a&&(t.$data&&this._opts.$data&&(a={anyOf:[a,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),t.validateSchema=this.compile(a,!0))}function c(e,t,r){for(var o,s=0;s<n.length;s++){var a=n[s];if(a.type==t){o=a;break}}o||(o={type:t,rules:[]},n.push(o));var c={keyword:e,definition:r,custom:!0,code:i,implements:r.implements};o.rules.push(c),n.custom[e]=c}return n.keywords[e]=n.all[e]=!0,this},get:function(e){var t=this.RULES.custom[e];return t?t.definition:this.RULES.keywords[e]||!1},remove:function(e){var t=this.RULES;delete t.keywords[e],delete t.all[e],delete t.custom[e];for(var n=0;n<t.length;n++)for(var r=t[n].rules,i=0;i<r.length;i++)if(r[i].keyword==e){r.splice(i,1);break}return this},validate:function e(t,n){e.errors=null;var r=this._validateKeyword=this._validateKeyword||this.compile(o,!0);if(r(t))return!0;if(e.errors=r.errors,n)throw new Error("custom keyword definition is invalid: "+this.errorsText(r.errors));return!1}}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r,i,o=" ",s=e.level,a=e.dataLevel,c=e.schema[t],u=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,h=!e.opts.allErrors,d="data"+(a||""),p="valid"+s,f="errs__"+s,m=e.opts.$data&&c&&c.$data;m?(o+=" var schema"+s+" = "+e.util.getData(c.$data,a,e.dataPathArr)+"; ",i="schema"+s):i=c;var g,_,y,v,b,w="definition"+s,x=this.definition,k="";if(m&&x.$data){b="keywordValidate"+s;var E=x.validateSchema;o+=" var "+w+" = RULES.custom['"+t+"'].definition; var "+b+" = "+w+".validate;"}else{if(!(v=e.useCustomRule(this,c,e.schema,e)))return;i="validate.schema"+u,b=v.code,g=x.compile,_=x.inline,y=x.macro}var j=b+".errors",A="i"+s,D="ruleErr"+s,S=x.async;if(S&&!e.async)throw new Error("async keyword in sync schema");if(_||y||(o+=j+" = null;"),o+="var "+f+" = errors;var "+p+";",m&&x.$data&&(k+="}",o+=" if ("+i+" === undefined) { "+p+" = true; } else { ",E&&(k+="}",o+=" "+p+" = "+w+".validateSchema("+i+"); if ("+p+") { ")),_)x.statements?o+=" "+v.validate+" ":o+=" "+p+" = "+v.validate+"; ";else if(y){var C=e.util.copy(e);k="";C.level++;var O="valid"+C.level;C.schema=v.validate,C.schemaPath="";var P=e.compositeRule;e.compositeRule=C.compositeRule=!0;var F=e.validate(C).replace(/validate\.schema/g,b);e.compositeRule=C.compositeRule=P,o+=" "+F}else{(B=B||[]).push(o),o="",o+=" "+b+".call( ",e.opts.passContext?o+="this":o+="self",g||!1===x.schema?o+=" , "+d+" ":o+=" , "+i+" , "+d+" , validate.schema"+e.schemaPath+" ",o+=" , (dataPath || '')",'""'!=e.errorPath&&(o+=" + "+e.errorPath);var I=a?"data"+(a-1||""):"parentData",T=a?e.dataPathArr[a]:"parentDataProperty",R=o+=" , "+I+" , "+T+" , rootData ) ";o=B.pop(),!1===x.errors?(o+=" "+p+" = ",S&&(o+="await "),o+=R+"; "):o+=S?" var "+(j="customErrors"+s)+" = null; try { "+p+" = await "+R+"; } catch (e) { "+p+" = false; if (e instanceof ValidationError) "+j+" = e.errors; else throw e; } ":" "+j+" = null; "+p+" = "+R+"; "}if(x.modifying&&(o+=" if ("+I+") "+d+" = "+I+"["+T+"];"),o+=""+k,x.valid)h&&(o+=" if (true) { ");else{var B;o+=" if ( ",void 0===x.valid?(o+=" !",o+=y?""+O:""+p):o+=" "+!x.valid+" ",o+=") { ",r=this.keyword,(B=B||[]).push(o),o="",(B=B||[]).push(o),o="",!1!==e.createErrors?(o+=" { keyword: '"+(r||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { keyword: '"+this.keyword+"' } ",!1!==e.opts.messages&&(o+=" , message: 'should pass \""+this.keyword+"\" keyword validation' "),e.opts.verbose&&(o+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),o+=" } "):o+=" {} ";var M=o;o=B.pop(),!e.compositeRule&&h?e.async?o+=" throw new ValidationError(["+M+"]); ":o+=" validate.errors = ["+M+"]; return false; ":o+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var q=o;o=B.pop(),_?x.errors?"full"!=x.errors&&(o+=" for (var "+A+"="+f+"; "+A+"<errors; "+A+"++) { var "+D+" = vErrors["+A+"]; if ("+D+".dataPath === undefined) "+D+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+D+".schemaPath === undefined) { "+D+'.schemaPath = "'+l+'"; } ',e.opts.verbose&&(o+=" "+D+".schema = "+i+"; "+D+".data = "+d+"; "),o+=" } "):!1===x.errors?o+=" "+q+" ":(o+=" if ("+f+" == errors) { "+q+" } else { for (var "+A+"="+f+"; "+A+"<errors; "+A+"++) { var "+D+" = vErrors["+A+"]; if ("+D+".dataPath === undefined) "+D+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+D+".schemaPath === undefined) { "+D+'.schemaPath = "'+l+'"; } ',e.opts.verbose&&(o+=" "+D+".schema = "+i+"; "+D+".data = "+d+"; "),o+=" } } "):y?(o+=" var err = ",!1!==e.createErrors?(o+=" { keyword: '"+(r||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { keyword: '"+this.keyword+"' } ",!1!==e.opts.messages&&(o+=" , message: 'should pass \""+this.keyword+"\" keyword validation' "),e.opts.verbose&&(o+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),o+=" } "):o+=" {} ",o+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&h&&(e.async?o+=" throw new ValidationError(vErrors); ":o+=" validate.errors = vErrors; return false; ")):!1===x.errors?o+=" "+q+" ":(o+=" if (Array.isArray("+j+")) { if (vErrors === null) vErrors = "+j+"; else vErrors = vErrors.concat("+j+"); errors = vErrors.length; for (var "+A+"="+f+"; "+A+"<errors; "+A+"++) { var "+D+" = vErrors["+A+"]; if ("+D+".dataPath === undefined) "+D+".dataPath = (dataPath || '') + "+e.errorPath+"; "+D+'.schemaPath = "'+l+'"; ',e.opts.verbose&&(o+=" "+D+".schema = "+i+"; "+D+".data = "+d+"; "),o+=" } } else { "+q+" } "),o+=" } ",h&&(o+=" else { ")}return o}},function(e,t,n){"use strict";var r=n(75);e.exports={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:r.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:r.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}}},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON Schema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},function(e,t,n){"use strict";n.r(t),n.d(t,"Joy",(function(){return y})),n.d(t,"ajv",(function(){return N})),n.d(t,"utils",(function(){return Ae})),n.d(t,"VERSION",(function(){return je.b})),n.d(t,"ImJoy",(function(){return De}));var r=n(76),i=n.n(r),o=n(8),s=n.n(o),a=n(7),c=n(32),u=n.n(c),l=n(11),h=n.n(l),d=n(77),p=n.n(d),f=n(29),m=n.n(f),g=n(24),_=n.n(g);function y(e){var t=this==window?{}:this;if(e.modules)for(var n=0;n<e.modules.length;n++)y.loadModule(e.modules[n]);return y.Op.call(t,e),y.initReferences(t),null==t.previewOps&&(t.previewOps=!1),null==t.previewNumbers&&(t.previewNumbers=!1),t.activePreview=null,t.canPreview=function(e){return e=e.charAt(0).toUpperCase()+e.slice(1),t["preview"+e]&&!t.activePreview},t.createWidget(),t.container&&("string"==typeof t.container&&(t.container=document.body.querySelector(t.container)),t.container.appendChild(t.dom)),y.ui.init(t),y.modal.init(t),t}y.normalizeUI=function(e){if(!e)return"";let t="";if(Array.isArray(e))for(let n of e)if("string"==typeof n)t=t+n+"<br>";else if("object"==typeof n)for(let e in n)t="string"==typeof n[e]?t+e+": "+n[e]+"<br>":t+e+": "+JSON.stringify(n[e])+"<br>";else t=t+JSON.stringify(n)+"<br>";else{if("object"==typeof e)throw"ui can not be an object, you can only use a string or an array.";"string"==typeof e?t=e.trim():(t="",console.log("Warning: removing ui string."))}return t},y.Op=function(e,t,n){var r=this;if(r._class_="Op",r.options=e,r.parent=t,r.top=r.parent?r.parent.top:r,r.type=e.type,r.type){var i=y.getTemplateByType(r.type);b(r,i)}if(b(r,r.options),t&&"object"==typeof t.onupdate&&t.onupdate[r.id]&&(r.onupdate=t.onupdate[r.id]),r.children=[],r.addChild=function(e,t){return"object"==typeof r.onupdate&&r.onupdate[e.id]&&(e.onupdate=r.onupdate[e.id]),"Op"!=e._class_&&(e=new y.Op(e,r,t)),r.children.push(e),e.id&&(r[e.id]=e),e},r.removeChild=function(e){w(r.children,e),e.kill()},r.onkill=r.onkill||function(){},r.kill=function(){for(r.dom&&r.dom.parentNode&&r.dom.parentNode.removeChild(r.dom);r.children.length>0;)r.removeChild(r.children[0]);r.onkill(r)},void 0===r.placeholder&&(r.placeholder={}),"function"==typeof r.placeholder&&(r.placeholder=r.placeholder()),("object"!=typeof r.placeholder||Array.isArray(r.placeholder))&&(r.placeholder={value:v(r.placeholder)}),r.placeholder.type||(r.placeholder.type=r.type),r.data=r.data||n,!r.data){t=r.parent;var o=r.dataID;t&&o?(t.data[o]||(t.data[o]=v(r.placeholder)),r.data=t.data[o]):r.data=v(r.placeholder)}r.getData=function(e){return r.data[e]},r.setData=function(e,t,n){void 0===t?delete r.data[e]:r.data[e]=t,n||r.update()},r.dom=null,r.initWidget=r.initWidget||function(){r.dom=document.createElement("span"),r.dom.innerHTML="[todo: define ui for '"+r.type+"']"},r.createWidget=function(){return r.initWidget(r),r.dom},r.previewData=null,r.onexecute=r.onexecute||function(){console.log("no execute function found.")},r.execute=async function(e,t){var n;return n=t?v(t):r.previewData?v(r.previewData):v(r.data),r.children.forEach((function(t){var r=t.dataID;if(r){var i=t.get(e);n[r]=i}})),await r.onexecute({op:r,target:e,data:n})},r.update=function(){if(r.parent&&r.parent.update(),r.onupdate&&"function"==typeof r.onupdate){var e;e=r.previewData?v(r.previewData):v(r.data),r.children.forEach((function(t){var n=t.dataID;if(n){var r=t.get({});e[n]=r}}));r.onupdate({data:e})}},r.get_config=function(e){var t;return e=e||{},t=r.previewData?v(r.previewData):v(r.data),r.children.forEach((function(n){var r=n.dataID;if(r&&e){var i=n.get(e);t[r]=i}})),t},r.onget=r.onget||function(e){return e.data},r.get=function(e){var t=r.previewData?r.previewData:r.data;return t=v(t),r.onget({op:r,target:e,data:t})},r.init&&("string"==typeof r.init&&y.initializeWithString(r,r.init),"function"==typeof r.init&&r.init(r))},y.templates=[],y.add=function(e){var t=y.templates.filter((function(t){return void 0!==t.type&&void 0!==e.type&&t.type===e.type}));if(t.length<=0)y.templates.push(e);else{for(var n=0;n<t.length;n++)w(y.templates,t[n]);y.templates.push(e)}},y.remove=function(e){var t=y.templates.filter((function(t){if(t.type===e)return!0}));if(t.length>0)for(var n=0;n<t.length;n++)w(y.templates,t[n])},y.reset=function(){y.templates=[]},y.getTemplateByType=function(e){var t=y.templates.find((function(t){return t.type===e}));if(!t)throw Error("No op template of type '"+e+"'!");return t},y.getTemplatesByTag=function(e){return y.templates.filter((function(t){return t.tags&&t.tags.indexOf(e)>=0}))},y.modify=function(){var e,t,n;2==arguments.length?(e=arguments[0],n=arguments[1]):(e=arguments[0],t=arguments[1],n=arguments[2]);var r={},i=y.getTemplateByType(e);b(r,i);var o=n(i);b(r,o),t?i.type=t:w(y.templates,i),y.add(r)},y.initializeWithString=function(e,t){try{t=m.a.sanitize(t)}catch(e){console.log("Failed to sanitize the ui string",e)}for(var n=[],r=t,i=-1,o=-1,s=0,a=0;a<r.length;a++){var c=r[a];if(0==s&&"{"==c&&(i=a),"{"==c&&s++,"}"==c&&s--,0==s&&"}"==c){o=a+1;var u=r.slice(i,o);u=(u=u.replace(/(\w+)\:/g,"'$1':")).replace(/\'/g,'"'),(u=JSON.parse(u)).dataID=u.dataID||u.id,n.push(u),r=r.substr(0,i)+"<span id='widget_"+u.id+"'></span>"+r.substr(o),a=0,i=-1,o=-1,s=0}}n.forEach((function(t){e.addChild(t)})),e.createWidget=function(){return e.dom=document.createElement("span"),e.dom.innerHTML=r,e.children.forEach((function(t){t.createWidget();var n="#widget_"+t.id,r=e.dom.querySelector(n);e.dom.replaceChild(t.dom,r)})),e.dom}},y.modules={},y.module=function(e,t){y.modules[e]=t},y.loadModule=function(e){var t=y.modules[e];if(!t)throw Error("There's no module called '"+e+"'!");t()},y.initReferences=function(e){var t=e.top.data;for(var n in t._references||(t._references={}),t._references){t._references[n].connected=0}},y.createReference=function(e,t,n){var r=e.top.data,i={id:A(r._references),tags:D(t),data:n,connected:0};return r._references[i.id]=i,i},y.getReferenceById=function(e,t){return e.top.data._references[t]},y.getReferencesByTag=function(e,t){var n=e.top.data,r=[];for(var i in n._references){var o=n._references[i];o.tags.indexOf(t)>=0&&r.push(o)}return r},y.connectReference=function(e,t){y.getReferenceById(e,t).connected++},y.disconnectReference=function(e,t){var n=y.getReferenceById(e,t);n.connected--,0==n.connected&&y.deleteReference(e,t)},y.deleteReference=function(e,t){var n=e.top.data;n._references[t];delete n._references[t]},y.encodeWorkflow=function(e){var t=JSON.stringify(e);return _.a.compressToEncodedURIComponent(t)},y.decodeWorkflow=function(e){var t=_.a.decompressFromEncodedURIComponent(e);return t?JSON.parse(t):null},y.saveToURL=function(e){var t=JSON.stringify(e),n=_.a.compressToEncodedURIComponent(t);return window.location.origin+window.location.pathname+"#/app?workflow="+n},y.loadFromURL=function(){var e=S("workflow"),t=_.a.decompressFromEncodedURIComponent(e);return t?JSON.parse(t):null},Math.TAU=2*Math.PI;var v=function(e){return JSON.parse(JSON.stringify(e))},b=function(e,t){for(var n in t){var r=t[n];e[n]=r}},w=function(e,t){var n=e.indexOf(t);return!(n<0)&&(e.splice(n,1),!0)},x=function(e){e.addEventListener("paste",(function(e){if(e.preventDefault(),e.clipboardData&&e.clipboardData.getData){var t=e.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,t)}else if(window.clipboardData&&window.clipboardData.getData){!function(e){var t,n;window.getSelection?(t=window.getSelection()).getRangeAt&&t.rangeCount&&((n=t.getRangeAt(0)).deleteContents(),n.insertNode(document.createTextNode(e))):document.selection&&document.selection.createRange&&(document.selection.createRange().text=e)}(t=window.clipboardData.getData("Text"))}}))},k=function(e,t){var n=document.createRange();n.selectNodeContents(e),t&&n.collapse(!1);var r=window.getSelection();r.removeAllRanges();try{r.addRange(n)}catch(e){}},E=function(){window.getSelection().removeAllRanges()},j=function(e){""==e.innerText&&(e.innerHTML=" ",k(e)),e.innerHTML.search("<br>")>=0&&(e.innerHTML=e.innerHTML.replace(/(\<br\>)+/g," "),k(e,!0))},A=function(e){var t,n=0;do{t="id"+n,n++}while(e[t]);return t},D=function(e){return Array.isArray(e)?e:[e]},S=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null};function C(e,t,n){var r,i,o,s,a,c,u,l;switch(1===arguments.length&&(t=e.s,n=e.v,e=e.h),c=n*(1-t),u=n*(1-(a=6*(e/=360)-(s=Math.floor(6*e)))*t),l=n*(1-(1-a)*t),s%6){case 0:r=n,i=l,o=c;break;case 1:r=u,i=n,o=c;break;case 2:r=c,i=n,o=l;break;case 3:r=c,i=u,o=n;break;case 4:r=l,i=c,o=n;break;case 5:r=n,i=c,o=u}return[Math.round(255*r),Math.round(255*i),Math.round(255*o)]}function O(e,t,n){1===arguments.length&&(t=e[1],n=e[2],e=e[0]);var r=C(e,t,n);return"rgb("+r[0]+","+r[1]+","+r[2]+")"}var P,F,I=0,T=[[0,.6,1],[30,.8,1],[210,.8,1],[260,.7,1],[310,.6,1]];P={},y.ui=P,P.init=function(e){e.dom.classList.add("joy-master"),e.container.addEventListener("wheel",(function(t){var n=t.deltaY;return e.container.scrollTop+=n,!1}))},P.Button=function(e){var t=this,n=document.createElement("div");n.className="joy-button",t.dom=n,e.label=e.label||"",t.label=document.createElement("span"),n.appendChild(t.label),t.setLabel=function(e){t.label.innerHTML=e},t.setLabel(e.label),n.onclick=function(){e.onclick()},t.styles=e.styles||[];for(var r=0;r<t.styles.length;r++)n.classList.add(t.styles[r])},P.ChooserButton=function(e){var t=this;t.value=e.value,t.options=e.options,t.onchange=e.onchange,t.value||(t.value=t.options[0].value),P.Button.call(t,{label:void 0===e.staticLabel?"":e.staticLabel,onclick:function(){y.modal.Chooser({source:t.dom,options:t.options,onchange:function(e){t.value=e,n(),t.onchange(e)},position:e.position})},styles:e.styles});var n=function(){if(void 0===e.staticLabel){var n=t.options.find((function(e){return e.value==t.value})).label;t.setLabel(n)}};n()},P.Scrubber=function(e){var t=this,n=e.min,r=e.max;t.value=e.value;var i=document.createElement("div");i.className="joy-scrubber",t.dom=i,t.setLabel=function(e){i.innerHTML=e.toFixed(t.sigfigs)};var o,s,a=function(n){n=parseFloat(n.toFixed(t.sigfigs)),e.onchange(n)},c=!1,u=!1,l=0,h=function(n){c=!0,o=n.clientX,s=t.value,l=0,e.onstart&&e.onstart()},d=function(e){if(c){u=!0;var n=Math.pow(.1,t.sigfigs);n=parseFloat(n.toPrecision(1));var r=e.clientX-o;o=e.clientX;var i=Math.abs(r/10);i<1&&(i=1),i>3&&(i=3),l+=r*i;var h=Math.floor(l/2),d=s+h*n;d=p(d),t.value!=d&&(t.value=d,t.setLabel(d),a(d))}},p=function(e){return void 0!==n&&e<n&&(e=n),void 0!==r&&e>r&&(e=r),e},f=function(){c=!1,e.onstop&&e.onstop(),setTimeout((function(){u=!1}),1)};i.addEventListener("mousedown",h),window.addEventListener("mousemove",d),window.addEventListener("mouseup",f),t.kill=function(){i.removeEventListener("mousedown",h),window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",f)};var m,g=!1;i.onblur=function(){g&&(g=!1,i.contentEditable=!1,E(),y(i.innerText),t.value=_(),t.setLabel(t.value),a(t.value),e.onstop&&e.onstop())},x(i),(m=i).addEventListener("keypress",(function(e){13===e.which&&(e.preventDefault(),m.blur())})),i.onclick=function(){u||(g=!0,i.contentEditable=!0,i.spellcheck=!1,k(i),e.onstart&&e.onstart())},i.oninput=function(e){if(g){var t=/[^0-9.\-]/g;i.innerText.match(t)&&(i.innerText=i.innerText.replace(t,"")),j(i),a(_())}};var _=function(){var e=parseFloat(i.innerText);return isNaN(e)&&(e=0),e=p(e)};t.sigfigs=0;var y=function(e){var n,r=(e=e.toString()).search(/\./);n=r>=0?e.length-1-r:0,t.sigfigs=n};y(t.value),t.setLabel(t.value)},P.String=function(e){var t=document.createElement("div");t.className="joy-string",this.dom=t;var n=document.createElement("span");n.contentEditable=!0,n.spellcheck=!1;var r=document.createElement("span"),i=document.createElement("span");r.innerHTML=e.prefix||"",i.innerHTML=e.suffix||"",t.appendChild(r),t.appendChild(n),t.appendChild(i),n.oninput=function(t){j(n);var r=n.innerText.replace(/(\xa0)+/g,"");e.onchange(r)},n.onfocus=function(){k(n)},n.onblur=function(){E()},x(n),n.onkeypress=function(e){return 13!=e.which||(n.blur(),!1)},this.setString=function(e){n.innerText=e,j(n)},this.setColor=function(e){e=function(e){return Array.isArray(e)&&(e=O(e[0],e[1],e[2])),e}(e),t.style.color=e,t.style.borderColor=e},e.color&&this.setColor(e.color),this.styles=e.styles||[];for(var o=0;o<this.styles.length;o++)t.classList.add(this.styles[o]);this.setString(e.value)},P.TextBox=function(e){var t,n=this;e.multiline?t=document.createElement("textarea"):(t=document.createElement("input")).type="text",e.placeholder&&(t.placeholder=e.placeholder),t.spellcheck=!1,t.className="joy-textbox",n.dom=t;var r=n.dom;e.readonly?(t.setAttribute("readonly",1),t.addEventListener("click",(function(){n.select()}))):t.oninput=function(n){e.onchange(t.value)},e.width&&(t.style.width="number"==typeof e.width?e.width+"px":e.width),n.getValue=function(){return t.value},n.setValue=function(e){t.value=e},n.select=function(){t.select()},n.styles=e.styles||[];for(var i=0;i<n.styles.length;i++)r.classList.add(n.styles[i]);e.value&&n.setValue(e.value),e.multiline&&(r.addEventListener("input",(function(){this.style.height="auto",this.style.height=this.scrollHeight+"px"}),!1),setTimeout((function(){r.setAttribute("style","height:"+r.scrollHeight+"px; overflow-y:hidden;")}),1))},F={},y.modal=F,F.init=function(e){for(var t=document.querySelectorAll("#joy-modal"),n=0;n<t.length;n++)t[n].parentNode.removeChild(t[n]);F.dom=document.createElement("div"),F.dom.id="joy-modal",document.body.appendChild(F.dom),F.bg=document.createElement("div"),F.bg.id="joy-bg",F.bg.onclick=function(){F.currentUI.kill()},F.dom.appendChild(F.bg),F.box=document.createElement("div"),F.box.id="joy-box",F.box.className="arrow_box",F.dom.appendChild(F.box),F.dom.addEventListener("wheel",(function(e){return"auto"==F.box.style.overflow||(e.preventDefault(),!1)}))},F.show=function(e){F.dom.style.display="block",F.currentUI=e,F.box.appendChild(e.dom);var t=e.config.position||"below",n=F.box.getBoundingClientRect(),r=e.config.source.getBoundingClientRect(),i=F.bg.getBoundingClientRect();switch("below"==t&&(s=r.top+r.height+20)+n.height>document.body.clientHeight&&(t="left"),F.box.setAttribute("position",t),t){case"below":var o=r.left+r.width/2,s=r.top+r.height+20;o-=n.width/2;break;case"left":o=r.left-20,s=r.top+r.height/2,o-=n.width,s-=n.height/2}o<0&&(o=1),s+n.height>i.height&&(s=i.height-n.height-1),F.box.style.left=o+"px",F.box.style.top=s+"px",F.currentUI.config.onopen&&F.currentUI.config.onopen()},F.hide=function(){!function(e){for(;e.hasChildNodes();)e.removeChild(e.lastChild)}(F.box),F.dom.style.display="none",F.currentUI.config.onclose&&F.currentUI.config.onclose()},F.Chooser=function(e){var t={};t.config=e;var n=document.createElement("div");n.className="joy-modal-chooser",t.dom=n;var r=document.createElement("div");n.appendChild(r),t.options=[],t.categories={};var i=function(e){var n=document.createElement("div");r.appendChild(n),t.categories[e]=n};t.populate=function(){for(var n=0;n<e.options.length;n++)(s=(r=e.options[n]).category)?t.categories[s]||i(s):t.categories._placeholder_||i("_placeholder_");for(n=0;n<e.options.length;n++){var r=e.options[n],o=document.createElement("div");o.innerHTML=r.label,r.color&&(o.style.color=r.color);var s=r.category||"_placeholder_";t.categories[s].appendChild(o),function(e){o.onclick=function(n){t.onchange(e.value),n.stopPropagation()}}(r)}},t.populate(),t.onchange=function(n){t.kill(),e.onchange(n)},t.kill=function(){F.hide()},F.show(t)},F.Color=function(e){var t={};t.config=e;var n=document.createElement("div");n.className="joy-modal-color",t.dom=n,e.value=e.value||[0,1,1],t.h=e.value[0],t.s=e.value[1],t.v=e.value[2],t.dom.style.width="195px",t.dom.style.height="170px";var r=document.createElement("canvas");r.id="joy-color-wheel";var i=r.getContext("2d");r.width=300,r.height=300,r.style.width=r.width/2+"px",r.style.height=r.height/2+"px",n.appendChild(r),r.style.top="10px",r.style.left="10px";var o=function(){var e=i;e.clearRect(0,0,e.canvas.width,e.canvas.height);for(var n=r.width,o=r.height,s=e.createImageData(n,o),a=s.data,c=n/2,u=o/2,l=n/2,h=l+2,d=0;d<n;d++)for(var p=0;p<o;p++){var f=d-c,m=p-u,g=Math.sqrt(f*f+m*m);if(g<h){g>=l&&(g=l);var _=Math.atan2(m,f),y=C(_=360*(_/Math.TAU+.5),g/=l,t.v),v=4*(d+p*n);a[v]=y[0],a[v+1]=y[1],a[v+2]=y[2],a[v+3]=255}}e.putImageData(s,0,0),e.save(),e.globalCompositeOperation="destination-in",e.beginPath(),e.fillStyle="#fff",e.arc(c,u,l,0,Math.TAU),e.fill(),e.restore()};o();var s=document.createElement("canvas");s.id="joy-color-value";var a=s.getContext("2d");s.width=30,s.height=300,s.style.width=s.width/2+"px",s.style.height=s.height/2+"px",n.appendChild(s),s.style.top="10px",s.style.right="10px";var c=function(){var e=a;e.clearRect(0,0,e.canvas.width,e.canvas.height);for(var n=s.width,r=s.height,i=e.createImageData(n,r),o=i.data,c=0;c<n;c++)for(var u=0;u<r;u++){var l=C(t.h,t.s,1-u/r),h=4*(c+u*n);o[h]=l[0],o[h+1]=l[1],o[h+2]=l[2],o[h+3]=255}e.putImageData(i,0,0)};c();var u=document.createElement("canvas");u.id="joy-color-picker";var l=u.getContext("2d");u.width=390,u.height=340,u.style.width=u.width/2+"px",u.style.height=u.height/2+"px",n.appendChild(u);var h,d=function(){var e,n,i=l;i.clearRect(0,0,i.canvas.width,i.canvas.height),i.fillStyle=O(t.h,t.s,t.v),i.strokeStyle="#fff",i.lineWidth=2;var o=20+r.width/2,a=20+r.height/2,c=t.h*(Math.TAU/360),u=t.s*(r.width/2);e=o-Math.cos(c)*u,n=a-Math.sin(c)*u,i.beginPath(),i.arc(e,n,15,0,Math.TAU),i.fill(),i.stroke(),e=20+r.width+20+s.width/2,n=20+s.height*(1-t.v),i.beginPath(),i.arc(e,n,15,0,Math.TAU),i.fill(),i.stroke()};d();var p=!1,f=function(e){if(e.target==u){var t=2*e.offsetX,n=2*e.offsetY;"hs"==h?m(t-=20,n-=20):(t-=20+r.width+20,g(t,n-=20)),b()}},m=function(e,n){var i=r.width/2,o=e-i,s=n-i,a=Math.atan2(s,o),u=Math.sqrt(o*o+s*s);(a=360*(a/Math.TAU+.5))<0&&(a=0),a>360&&(a=360),(u/=i)<0&&(u=0),u>1&&(u=1),t.h=a,t.s=u,c(),d()},g=function(e,n){t.v=1-n/s.height,t.v<0&&(t.v=0),t.v>1&&(t.v=1),o(),d()},_=function(e){p=!0,h=2*e.offsetX<20+r.width+10?"hs":"v",f(e)},y=function(e){p&&f(e)},v=function(){p=!1};u.addEventListener("mousedown",_),window.addEventListener("mousemove",y),window.addEventListener("mouseup",v);var b=function(){var n=[t.h,t.s,t.v];n[0]=parseFloat(n[0].toFixed(0)),n[1]=parseFloat(n[1].toFixed(2)),n[2]=parseFloat(n[2].toFixed(2)),e.onchange(n)};t.kill=function(){n.removeEventListener("mousedown",_),window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",v),F.hide()},F.show(t)},y.add({type:"number",tags:["ui"],initWidget:function(e){var t=e.options,n=new y.ui.Scrubber({min:t.min,max:t.max,step:t.step,value:e.getData("value"),onstart:function(){e.top.activePreview=e},onstop:function(){e.top.activePreview=null},onchange:function(t){e.setData("value",t)}});e.dom=n.dom;var r=null;e.dom.onmouseenter=function(){if(e.top.canPreview("numbers")){e.previewData=v(e.data);var t=Math.abs(.05*e.data.value);0==t&&(t=1);var n=0;r=setInterval((function(){if(!e.top.canPreview("numbers"))return i();n+=Math.TAU/30/.25,e.previewData.value=e.data.value+Math.sin(n)*t,e.update(),n>Math.TAU&&i()}),1e3/30)}};var i=function(){r&&clearInterval(r),e.previewData=null};e.dom.onmouseleave=i},onget:function(e){return e.data.value},placeholder:{value:3}}),y.add({type:"button",tags:["ui"],initWidget:function(e){var t=document.createElement("div");t.className="joy-save",e.dom=t,e.saveButton=new y.ui.Button({label:e.options.label||"--",onclick:function(){e.update()}}),t.appendChild(e.saveButton.dom)}}),y.add({type:"color",tags:["ui"],initWidget:function(e){var t=new y.ui.Button({label:" ",onclick:function(){y.modal.Color({source:e.dom,value:e.getData("value"),onchange:function(t){e.setData("value",t),n()},onopen:function(){e.top.activePreview=e},onclose:function(){e.top.activePreview=null}})},styles:["joy-color"]});e.dom=t.dom;var n=function(){var n=e.getData("value");t.dom.style.background=O(n)};n();var r,i,o=null;e.dom.onmouseenter=function(){e.top.canPreview("numbers")&&(e.data.value[2],e.previewData=v(e.data),i=0,r=2/30*2,o=setInterval((function(){if(!e.top.canPreview("numbers"))return s();var t=e.previewData.value;t[2]+=r,t[2]>1&&(t[2]=1,r*=-1),t[2]<0&&(t[2]=0,r*=-1),e.update(),(i+=2/30)>=1&&s()}),1e3/30))};var s=function(){o&&clearInterval(o),e.previewData=null,e.update()};e.dom.onmouseleave=s},onget:function(e){return O(e.data.value)},placeholder:function(){return[Math.floor(360*Math.random()),.8,1]}}),y.add({type:"choose",tags:["ui"],initWidget:function(e){for(var t=e.data,n=e.options,r=0;r<n.length;r++){var i=n[r];void 0!==i.label&&void 0!==i.value||(n[r]={label:i.toString(),value:i})}var o=new y.ui.ChooserButton({value:t.value,options:n,onchange:function(n){t.value=n,e.update()},styles:e.styles});e.dom=o.dom},onget:function(e){return e.data.value}}),y.add({type:"string",tags:["ui"],initWidget:function(e){var t=e.options;e.stringUI=new y.ui.String({prefix:t.prefix,suffix:t.suffix,color:t.color,value:e.getData("value"),onchange:function(t){e.setData("value",t)}}),e.dom=e.stringUI.dom,e.onDataChange=function(){var t=e.getData("value");e.stringUI.setString(t)}},onget:function(e){return e.data.value},placeholder:"???"}),y.add({type:"save",tags:["ui"],initWidget:function(e){var t=document.createElement("div");t.className="joy-save",e.dom=t,e.saveButton=new y.ui.Button({label:"save",onclick:function(){var t=y.saveToURL(e.top.data);e.url.setValue(t),e.url.select();t.length;e.info.innerHTML="P.S: you can shorten your link with <a href='http://tinyurl.com/' target='_blank'>TinyURL</a>!"}}),t.appendChild(e.saveButton.dom),e.url=new y.ui.TextBox({readonly:!0}),t.appendChild(e.url.dom),e.info=document.createElement("div"),e.info.id="joy-save-info",t.appendChild(e.info)}}),y.add({type:"ops",tags:["ui"],init:function(e){void 0!==e.resetVariables&&(e.data.resetVariables=e.resetVariables)},initWidget:function(e){var t=e.data.ops,n=document.createElement("div");n.className="joy-ops",e.dom=n;var r=document.createElement("list");r.id="joy-list",n.appendChild(r);var i=[{label:"Add op above",value:"op_above"},{label:"Add op below",value:"op_below"},{label:"Delete",value:"delete"}],o=function(n){var o=new y.ui.ChooserButton({position:"below",staticLabel:s(n),options:i,onchange:function(i){!function(n,i){var o=0;if("op_above"==i&&(o=-1),"op_below"==i&&(o=1),0!=o){var s=e.entries.indexOf(n);o>0&&(s+=1),y.modal.Chooser({position:"below",source:n.bullet.dom,options:h,onchange:function(t){l(t,s),e.update(),a()}})}"delete"==i&&(w(e.entries,n),w(t,n.opData),e.removeChild(n.op),r.removeChild(n.dom),e.update(),a())}(n,i)},styles:["joy-bullet"]});return o.dom.id="joy-bullet",o},s=function(t){for(var n,r=e.entries.indexOf(t)+1,i=0,o=e.parent;o;)"ops"==o.type&&i++,o=o.parent;switch(i%3){case 0:n=r;break;case 1:n=function(e){for(var t=0,n=1;e>=n;)t++,e-=n,n*=26;for(var r="",i=0;i<t;i++)r="abcdefghijklmnopqrstuvwxyz".charAt(e%26)+r,e=Math.floor(e/26);return r}(r);break;case 2:n=function(e){if(!+e)return NaN;for(var t=String(+e).split(""),n=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",i=3;i--;)r=(n[+t.pop()+10*i]||"")+r;return(Array(+t.join("")+1).join("M")+r).toLowerCase()}(r)}return n},a=function(){for(var t=0;t<e.entries.length;t++){var n=e.entries[t],r=n.bullet,i=s(n);r.setLabel(i)}};e.entries=[];for(var c=function(t,i){var s={},a=document.createElement("div");void 0===i&&(i=e.entries.length),e.entries.splice(i,0,s),r.insertBefore(a,r.children[i]);var c=o(s),u=document.createElement("div");u.id="joy-bullet-container",a.appendChild(u),u.appendChild(c.dom);var l=e.addChild({type:t.type},t),h=l.createWidget();h.id="joy-widget",a.appendChild(h),s.dom=a,s.bullet=c,s.op=l,s.widget=h,s.opData=t;var d,p,f=function(t){var n=t.offsetY/c.dom.getBoundingClientRect().height;n<0&&(n=0),n>1&&(n=1),d._PREVIEW=n,e.update()};return u.onmouseenter=function(t){if(e.top.canPreview("ops")){e.top.activePreview=e,e.previewData=v(e.data);var r=e.entries.indexOf(s);d=e.previewData.ops[r],e.previewData.ops.splice(r+1,0,{STOP:!0}),f(t),p=document.createElement("style"),document.head.appendChild(p),p.sheet.insertRule(".joy-ops.joy-previewing > #joy-list > div:nth-child(n+"+(r+2)+") { opacity:0.1; }"),p.sheet.insertRule(".joy-ops.joy-previewing > div.joy-bullet { opacity:0.1; }"),n.classList.add("joy-previewing")}},u.onmousemove=function(t){e.previewData&&f(t)},u.onmouseleave=function(){e.previewData&&(e.previewData=null,e.top.activePreview=null,e.update(),document.head.removeChild(p),n.classList.remove("joy-previewing"))},s},u=0;u<t.length;u++)c(t[u]);var l=function(e,n){var r={type:e};void 0===n?t.push(r):t.splice(n,0,r);c(r,n)},h=[];if(e.onlyOps)for(u=0;u<e.onlyOps.length;u++){var d=e.onlyOps[u],p=y.getTemplateByType(d),f=p.tags.filter((function(e){return"op"!=e}))[0];h.push({label:p.name,value:d,category:f})}else{var m=y.getTemplatesByTag("op");for(u=0;u<m.length;u++){var g=m[u];f=g.tags.filter((function(e){return"op"!=e}))[0];h.push({label:g.name,value:g.type,category:f})}}var _=new y.ui.ChooserButton({staticLabel:"+",options:h,onchange:function(t){l(t),e.update()},styles:["joy-bullet"]});n.appendChild(_.dom)},onexecute:async function(e){e.target._variables||(e.target._variables={}),e.data.resetVariables&&(e.target._variables={});for(var t=0;t<e.data.ops.length;t++){var n=e.data.ops[t];if(n.STOP)return"STOP";var r=e.op.entries[t].op,i=await r.execute(e.target,n);if(i&&i.target)e.target=i.target;else{if(i&&i.error)return console.error("ops stopped with error: ",i),i;if(i&&i.stop)return console.log("ops interrupted at step ",t,i),i;if("STOP"==i)return i}}return e},placeholder:{ops:[],resetVariables:!0}}),y.module("instructions",(function(){y.add({name:"Repeat the following...",type:"instructions/repeat",tags:["instructions","op"],init:"Repeat the following {id:'count', type:'number', min:1, placeholder:3} times: {id:'ops', type:'ops', resetVariables:false}",onexecute:async function(e){var t=1;void 0!==e.data._PREVIEW&&(t=e.data._PREVIEW);for(var n=Math.floor(e.data.count*t),r=0;r<n;r++){var i=await e.op.ops.execute(e.target);if(i&&i.target)e.target=i.target;else{if(i.error)return console.error("op stopped with error: ",i),i;if(i.stop)return console.log("op interrupted at step ",r,i),i;if("STOP"==i)return i}}return e}}),y.add({name:"// Write a note",type:"instructions/comment",tags:["instructions","op"],initWidget:function(e){e.dom=document.createElement("div"),e.box=new y.ui.TextBox({multiline:!0,placeholder:"// your notes here",value:e.getData("value"),onchange:function(t){e.setData("value",t)},styles:["box"]}),e.dom.appendChild(e.box.dom)}})})),y.add({type:"variableName",tags:["ui"],init:function(e){var t=e.variableType;e._createNewReference=function(){var n,r,i,o={value:(r=y.getReferencesByTag(e,t).map((function(e){return e.data.value})),i=0,r.forEach((function(e){var t;"variable"==e&&(t=1);var n=e.match(/variable\s(\d+)/);n&&(t=parseInt(n[1])),i<t&&(i=t)})),0==i?"variable":"variable "+(i+1)),color:(n=T[I],I=(I+1)%T.length,n)},s=y.createReference(e,t,o);e.setData("refID",s.id,!0),y.connectReference(e,s.id)};var n=e.getData("refID");if(n)y.connectReference(e,n);else{var r=y.getReferencesByTag(e,t);if(e.startWithExisting&&r.length>0)n=r[r.length-1].id,e.setData("refID",n,!0),y.connectReference(e,n);else e._createNewReference()}e._switchReference=function(t){var n=e.getData("refID");y.disconnectReference(e,n),e.setData("refID",t),y.connectReference(e,t)}},initWidget:function(e){e.dom=document.createElement("span");var t=e.getData("refID"),n=y.getReferenceById(e,t).data,r=e.addChild({type:"string",prefix:"[",suffix:"]",color:n.color},n),i=r.createWidget();e.dom.appendChild(i);var o=r.onDataChange;r.onDataChange=function(){o();var e=r.getData("color");r.stringUI.setColor(e)};var s=e.variableType;e.noChooser||(e.dom.onclick=function(){var t=[],n=y.getReferencesByTag(e,s),i=e.getData("refID");n.forEach((function(e){if(e.id!=i){var n=e.data.color;n=O(n[0],n[1],n[2]),t.push({label:"["+e.data.value+"]",value:e.id,color:n})}})),t.push({category:"meta",label:"(+new)",value:"NEW"}),t.push({category:"meta",label:"(change color)",value:"CHANGE_COLOR"}),y.modal.Chooser({source:e.dom,options:t,onchange:function(t){if("CHANGE_COLOR"==t)y.modal.Color({source:e.dom,value:r.getData("color"),onchange:function(e){r.setData("color",e),r.stringUI.setColor(e)}});else{if("NEW"==t){var n=e.getData("refID");y.disconnectReference(e,n),e._createNewReference(),e.update()}else e._switchReference(t);var i=e.getData("refID"),o=y.getReferenceById(e,i);r.switchData(o.data)}}})})},onget:function(e){var t=e.data.refID;return y.getReferenceById(e.op,t).data.value},onkill:function(e){var t=e.getData("refID");y.disconnectReference(e,t)}}),y.module("math",(function(){y.modify("number","number_raw",(function(e){return{init:function(e){if(!e.noVariables){var t=e.getData("value");"number"==typeof t&&(e.setData("value",void 0,!0),e.setData("chain",[{type:"number_raw",min:e.min,max:e.max,step:e.step,value:t}],!0)),e._makeNewChainOp=function(t,n){var r,i=t.type;switch(i){case"number_raw":r=e.addChild({type:i,min:t.min,max:t.max,step:t.step},t);break;case"variableName":r=e.addChild({type:i,variableType:"number",noChooser:!0},t);break;case"choose":r=e.addChild({type:i,options:[{label:"+",value:"+"},{label:"-",value:"-"},{label:"×",value:"*"},{label:"÷",value:"/"}],styles:["joy-math"]},t)}var o=e.getData("chain");return void 0!==n?(e.chainOps.splice(n,0,r),o.splice(n,0,t)):(e.chainOps.push(r),o.push(t)),r},e.chainOps=[];var n=e.getData("chain"),r=v(n);n.splice(0,n.length);for(var i=0;i<r.length;i++)e._makeNewChainOp(r[i]);e._replaceChainOp=function(t,n){var r=e._deleteChainOp(t),i=e._makeNewChainOp(n,r);return e.update(),i},e._deleteChainOp=function(t){var n=e.chainOps.indexOf(t);return w(e.chainOps,t),e.removeChild(t),e.getData("chain").splice(n,1),n}}},initWidget:function(t){if(t.noVariables)e.initWidget(t);else{t.dom=document.createElement("span"),t.dom.className="joy-number";t._chainEntries=[],t._makeChainEntry=function(e,r){var i,o,s=document.createElement("span");if(e.createWidget(),s.appendChild(e.dom),"choose"!=e.type){var a,c=new y.ui.Button({onclick:function(){n(a)},styles:["joy-more"]});s.appendChild(c.dom)}if(void 0!==r)if(r<t.dom.childNodes.length){var u=t.dom.childNodes[r];t.dom.insertBefore(s,u)}else t.dom.appendChild(s);else t.dom.appendChild(s);"choose"!=e.type&&((i=e).dom.addEventListener("mousedown",(function(){o=+new Date})),i.dom.addEventListener("mouseup",(function(){+new Date-o<500&&function(e){var n=[];if("number_raw"!=e.type){var r=t.placeholder.value;"number"==typeof r&&n.push({label:r,value:{type:"number_raw",value:r}})}var i,o=y.getReferencesByTag(t,"number");"variableName"==e.type&&(i=e.getData("refID")),o.forEach((function(e){if(e.id!=i){var t=e.data.color;t=O(t[0],t[1],t[2]),n.push({label:"["+e.data.value+"]",value:{type:"variableName",refID:e.id},color:t})}})),n.length>0&&y.modal.Chooser({source:e.dom,options:n,onchange:function(n){var r=t._replaceChainOp(e,n);t._replaceChainEntry(e,r)}})}(i)}))),a={widget:s,op:e},void 0!==r?t._chainEntries.splice(r,0,a):t._chainEntries.push(a)},t._deleteChainEntry=function(e){var n=t._chainEntries.find((function(t){return t.op==e})),r=t._chainEntries.indexOf(n),i=n.widget;return t.dom.removeChild(i),w(t._chainEntries,n),r},t._replaceChainEntry=function(e,n){var r=t._deleteChainEntry(e);t._makeChainEntry(n,r)};for(var n=function(e){var n=e.widget.innerText,r=[{label:n+" + 2",value:"+"},{label:n+" - 2",value:"-"},{label:n+" × 2",value:"*"},{label:n+" ÷ 2",value:"/"}],i=t._chainEntries.indexOf(e);if(t._chainEntries.length>1){var o,s;o=0==i?i+1:i-1;var a=t._chainEntries[o].widget.innerText;s=0==i?n+" "+a:a+" "+n;var c=[i,o].sort();r.push({category:"meta",label:"(delete “"+s+"”)",value:c})}y.modal.Chooser({source:e.widget,options:r,onchange:function(n){if("string"==typeof n){var r=t._chainEntries.indexOf(e);r++;var i=t._makeNewChainOp({type:"choose",value:n},r);t._makeChainEntry(i,r),r++;var o=t._makeNewChainOp({type:"number_raw",value:2},r);t._makeChainEntry(o,r)}else for(var s=n,a=s.length-1;a>=0;a--){var c=s[a],u=t._chainEntries[c].op;t._deleteChainOp(u),t._deleteChainEntry(u)}t.update()}})},r=0;r<t.chainOps.length;r++){var i=t.chainOps[r];t._makeChainEntry(i)}}},onget:function(t){if(t.op.noVariables)return e.onget(t);for(var n=[],r=0;r<t.data.chain.length;r+=2){var i,o=t.op.chainOps[r];switch(o.type){case"number_raw":i=o.get(t.target);break;case"variableName":i=t.target._variables[o.get(t.target)]}if(r>0){var s=t.op.chainOps[r-1].get();n.push(s)}n.push(i)}for(r=1;r<n.length;r+=2){if("*"==(s=n[r])||"/"==s){var a=n[r-1],c=n[r+1];u="*"==s?a*c:a/c,n.splice(r-1,3,u),r-=2}}for(r=1;r<n.length;r+=2){if("+"==(s=n[r])||"-"==s){var u;a=n[r-1],c=n[r+1];u="+"==s?a+c:a-c,n.splice(r-1,3,u),r-=2}}return n[0]}}})),y.add({name:"Set [number]",type:"math/set",tags:["math","op"],init:"Set {id:'varname', type:'variableName', variableType:'number'} to {id:'value', type:'number'}",onexecute:function(e){e.target._variables[e.data.varname]=e.data.value}}),y.add({name:"Do math to [number]",type:"math/operation",tags:["math","op"],init:JSON.stringify({id:"operation",type:"choose",placeholder:"+",options:[{label:"+ Increase",value:"+"},{label:"- Decrease",value:"-"},{label:"× Multiply",value:"*"},{label:"÷ Divide",value:"/"}]})+" {id:'varname', type:'variableName', variableType:'number', startWithExisting:true} by {id:'value', type:'number'}",onexecute:function(e){var t=e.target._variables,n=e.data.varname;switch(void 0===t[n]&&(t[n]=0),e.data.operation){case"+":t[n]+=e.data.value;break;case"-":t[n]-=e.data.value;break;case"*":t[n]*=e.data.value;break;case"/":t[n]/=e.data.value}}}),y.add({name:"If [math] then...",type:"math/if",tags:["math","op"],init:"If {id:'value1', type:'number'} {id:'test', type:'choose', options:['<','≤','=','≥','>'], placeholder:'='} {id:'value2', type:'number'}, then: {id:'ops', type:'ops', resetVariables:false}",onexecute:function(e){var t,n=e.data.value1,r=e.data.value2;switch(e.data.test){case"<":t=n<r;break;case"≤":t=n<=r;break;case"=":t=n==r;break;case"≥":t=n>=r;break;case">":t=n>r}if(t){var i=e.op.ops.execute(e.target);if("STOP"==i)return i}}})})),y.module("random",(function(){y.add({name:"With a X% chance...",type:"random/if",tags:["random","op"],init:"With a {id:'chance', type:'number', min:0, max:100, placeholder:50}% chance, do:{id:'ops', type:'ops', resetVariables:false}",onexecute:function(e){var t=e.data.chance/100;if(Math.random()<t){var n=e.op.ops.execute(e.target);if("STOP"==n)return n}}}),y.add({name:"Set random [number]",type:"random/set",tags:["random","op"],init:"Set {id:'varname', type:'variableName', variableType:'number'} to a random {id:'numtype', type:'choose', options:['number','integer'], placeholder:'number'} between {id:'min', type:'number', placeholder:1} and {id:'max', type:'number', placeholder:100}",onexecute:function(e){var t,n=e.target._variables,r=e.data.varname,i=e.data.min,o=e.data.max,s=Math.min(i,o),a=Math.max(i,o);t="integer"==e.data.numtype?s+Math.floor(Math.random()*(a-s+1)):s+Math.random()*(a-s),n[r]=t}})}));var R=n(78),B=n(30),M=n(0);const q={operator:{properties:{name:{type:"string"},ui:{type:["null","string","array","object"]},run:{instanceof:Function},inputs:{type:["null","object"]},outputs:{type:["null","object"]}}},"engine-factory":{properties:{name:{type:"string"},type:{enum:["engine-factory"]},icon:{type:"string"},url:{type:"string"},config:{type:"object"},addEngine:{instanceof:Function},removeEngine:{instanceof:Function}}},engine:{properties:{name:{type:"string"},type:{enum:["engine"]},pluginType:{type:"string"},factory:{type:"string"},icon:{type:"string"},url:{type:"string"},config:{type:"object"},enable:{instanceof:Function},disable:{instanceof:Function},connect:{instanceof:Function},disconnect:{instanceof:Function},listPlugins:{instanceof:Function},startPlugin:{instanceof:Function},getPlugin:{instanceof:Function},getEngineStatus:{instanceof:Function},getEngineConfig:{instanceof:[Function,null]},heartbeat:{instanceof:[Function,null]},killPlugin:{instanceof:[Function,null]},killPluginProcess:{instanceof:[Function,null]},restartPlugin:{instanceof:[Function,null]},about:{instanceof:[Function,null]}}},"file-manager":{properties:{name:{type:"string"},type:{enum:["file-manager"]},url:{type:"string"},shwoFileDialog:{instanceof:Function},listFiles:{instanceof:Function},getFile:{instanceof:Function},putFile:{instanceof:Function},requestUploadUrl:{instanceof:Function},getFileUrl:{instanceof:Function},removeFile:{instanceof:Function},heartbeat:{instanceof:[Function,null]}}},"@transformation":{properties:{name:{type:"string"},type:{enum:["transformation"]},transform:{instanceof:Function},fit:{instanceof:Function},fit_transform:{instanceof:Function}},required:["name","type","transform"]},"@model":{properties:{name:{type:"string"},type:{enum:["model"]},predict:{instanceof:Function},fit:{instanceof:Function}},required:["name","type","predict"]}};var L=n(79);const N=new(n.n(L).a);N.addKeyword("file",{compile:function(e){if(e&&!e.mime&&!e.ext&&"string"!=typeof e)throw new Error("Invalid config for keyword: file");if(e&&e.maxSize&&"number"!=typeof e.maxSize)throw new Error("maxSize must be a number");if(e&&e.minSize&&"number"!=typeof e.minSize)throw new Error("minSize must be a number");if(e&&e.size&&"number"!=typeof e.size&&!Array.isArray(e.size))throw new Error("size must be a number");return function(t){if(!(t instanceof File))return!1;if(!e)return!0;for(let n in e){if("mime"===n){const r=e[n];let i=!1;if("string"==typeof r)i=t.type.match(r);else if(Array.isArray(r))for(let e of r)t.type.match(e)&&(i=!0);if(!i)return!1}if("ext"===n){const r=e[n];let i=!1;if("string"==typeof r)i=t.name.endsWith(r);else if(Array.isArray(r))for(let e of r)t.name.endsWith(e)&&(i=!0);if(!i)return!1}if("maxSize"===n&&t.size>e[n])return!1;if("minSize"===n&&t.size<e[n])return!1;if("size"===n){if(Array.isArray(e[n])&&!e[n].includes(t.size))return!1;if(t.size!==e[n])return!1}}return!0}}});const U=Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array)).constructor,W=Object.values({Int8Array:"int8",Int16Array:"int16",Int32Array:"int32",Uint8Array:"uint8",Uint16Array:"uint16",Uint32Array:"uint32",Float32Array:"float32",Float64Array:"float64",Array:"array"});N.addKeyword("ndarray",{compile:function(e){if(e&&e.ndim&&"number"!=typeof e.ndim&&!Array.isArray(e.ndim))throw new Error("ndim must be a number");if(e&&e.shape){if(!Array.isArray(e.shape))throw new Error("shape must be an array");if(e.ndim&&("number"!=typeof e.ndim||e.shape.length!==e.ndim))throw new Error("mismatch between shape and ndim")}if(e&&e.dtype){if("string"!=typeof e.dtype&&!Array.isArray(e.dtype))throw new Error("Invalid dtype format");let t;t="string"==typeof e.dtype?[e.dtype]:e.dtype;for(let e of t)if("string"!=typeof e||!W.includes(e))throw new Error("Invalid dtype: "+e+", valid types: "+W.join(","))}return function(t){if(!("ndarray"===t._rtype&&t._rvalue&&t._rvalue instanceof U&&t._rshape&&Array.isArray(t._rshape)&&t._rdtype&&W.includes(t._rdtype)))return!1;if(!e)return!0;for(let n in e){if("shape"===n){const r=e[n];if(t._rshape.length!==r.length)return!1;for(let e=0;e<t._rshape.length;e++)if("number"==typeof r[e]&&t._rshape[e]!==r[e])return!1}if("dtype"===n){const r=e[n];let i=!1;if("string"==typeof r?i=t._rdtype===e[n]:Array.isArray(r)&&(i=r.includes(t._rdtype)),!i)return!1}if("ndim"===n){const r=e[n];let i=!1;if("number"==typeof r?i=t._rshape.length===r:Array.isArray(r)&&(i=r.includes(t._rshape.length)),!i)return!1}}return!0}}}),N.addKeyword("instanceof",{compile:function(e){return function(t){if(Array.isArray(e)){let n=!1;for(let r of e)if(t instanceof r){n=!0;break}return n}return t instanceof e}}});const $=["env","requirements","dependencies","icon","ui","type","flags","labels","cover","base_frame","base_worker","passive"],z=$.concat(["name","type","tags","version","api_version","defaults","inputs","outputs","permissions"]),J={"web-worker":{type:"internal",name:"Web Worker",lang:"javascript"},iframe:{type:"internal",name:"IFrame",lang:"javascript",icon:"⚙️"},window:{type:"internal",name:"Window",lang:"javascript"},"rpc-window":{type:"external",name:"RPC Window",lang:"*",icon:"🌟"},"rpc-worker":{type:"external",name:"RPC Worker",lang:"*",icon:"⚙️"},collection:{type:"-",name:"Collection",lang:"*",icon:""}};function H(e){return J[e]}const K=N.compile({properties:{_id:{type:["null","string"]},name:{type:"string"},code:{type:"string"},lang:{type:["null","string"]},script:{type:["null","string"]}}}),V=(N.compile({properties:{type:{type:"string"},name:{type:"string"},lang:{type:"string"},icon:{type:["null","string"]},connection:{}}}),N.compile({properties:{name:{type:"string"},type:{type:"string"},init:{type:["null","string","array","object"]}}})),X=N.compile({properties:{name:{type:"string"},type:{type:"string"},config:{type:["null","object"]},data:{type:["null","number","string","array","object"]},panel:{type:["null","object"]}}}),Y=N.compile(q.operator),G=N.compile(q["engine-factory"]),Q=N.compile(q.engine),Z=N.compile(q["file-manager"]),ee=N.compile({properties:{allow_execution:{type:"boolean"},auth:{type:["object","null"]},api_version:{type:"string",maxLength:32},cover:{type:["string","array"],maxLength:1024},dedicated_thread:{type:"boolean"},description:{type:"string",maxLength:256},flags:{type:"array",maxLength:32},icon:{type:"string"},id:{type:"string",maxLength:128},inputs:{type:["object","array"]},labels:{type:"array",maxLength:32},lang:{type:"string",maxLength:32},name:{type:"string",maxLength:48},outputs:{type:["object","array"]},tags:{type:"array",maxLength:32},type:{type:"string",enum:Object.keys(J)},ui:{type:"string",maxLength:2048},version:{type:"string",maxLength:32},docs:{type:["string","object"]}},required:["name","version","description","api_version","id","allow_execution"]}),te={};class ne extends M.MessageEmitter{constructor(e){super(),this._event_handlers={},this._disconnected=!1,this.pluginConfig={},this._frame=e,this._access_token=null,this._refresh_token=null,this._peer_id=null,this._plugin_origin=null,this.on("initialized",e=>{if(this.pluginConfig=e.config,this._peer_id=e.peer_id,this._plugin_origin=e.origin||"*",te[this._peer_id]=this,"*"!==this._plugin_origin&&console.log(`connection to the imjoy-rpc peer ${this._peer_id} is limited to origin ${this._plugin_origin}.`),!this._peer_id)throw new Error("Please provide a peer_id for the connection.");this.pluginConfig.auth&&("*"===this._plugin_origin&&(console.error("Refuse to transmit the token without an explicit origin, there is a security risk that you may leak the credential to website from other origin. Please specify the `origin` explicitly."),this._access_token=null,this._refresh_token=null),"jwt"!==this.pluginConfig.auth.type?console.error("Unsupported authentication type: "+this.pluginConfig.auth.type):(this._expires_in=this.pluginConfig.auth.expires_in,this._access_token=this.pluginConfig.auth.access_token,this._refresh_token=this.pluginConfig.auth.refresh_token))})}connect(){this._messageHandler=(e=>{if(this._frame.contentWindow&&e.source===this._frame.contentWindow){const t=e.data.target_id;if(t&&this._peer_id&&t!==this._peer_id){const n=te[t];n?n._fire(e.data.type,e.data):console.warn(`connection with target_id ${t} not found, discarding data: `,e.data)}else this._fire(e.data.type,e.data)}}).bind(this),window.addEventListener("message",this._messageHandler),this._fire("connected")}execute(e){return new Promise((t,n)=>{this.once("executed",e=>{e.error?n(new Error(e.error)):t()}),this.pluginConfig.allow_execution?this.emit({type:"execute",code:e}):n("Connection does not allow execution")})}emit(e){let t=void 0;if(e.__transferables__&&(t=e.__transferables__,delete e.__transferables__),this._access_token){if(Date.now()>=1e3*this._expires_in)throw new Error("Refresh token is not implemented.");e.access_token=this._access_token}e.peer_id=this._peer_id||e.peer_id,this._frame.contentWindow&&this._frame.contentWindow.postMessage(e,this._plugin_origin||"*",t)}disconnect(e){this._messageHandler&&window.removeEventListener("message",this._messageHandler),this._disconnected||(this._disconnected=!0,void 0!==this._frame&&this._frame.parentNode.removeChild(this._frame),this._fire("disconnected",e)),this._peer_id&&te[this._peer_id]&&delete te[this._peer_id]}}class re extends ne{constructor(e){super(),this._worker=e}connect(){this._worker.addEventListener("message",e=>{const t=e.data.target_id;if(t&&this._peer_id&&t!==this._peer_id){const n=te[t];n?n._fire(e.data.type,e.data):console.warn(`connection with target_id ${t} not found, discarding data: `,e.data)}else this._fire(e.data.type,e.data)}),this._fire("connected")}emit(e){let t=void 0;if(e.__transferables__&&(t=e.__transferables__,delete e.__transferables__),this._access_token){if(Date.now()>=1e3*this._expires_in)throw new Error("Refresh token is not implemented.");e.access_token=this._access_token}e.peer_id=this._peer_id||e.peer_id,this._worker.postMessage(e,t)}}var ie=n(19);
/**
* @fileoverview Jailed - safe yet flexible sandbox
*
* @license MIT, see http://github.com/imjoy-team/imjoy-core
* Copyright (c) 2020 ImJoy Team <imjoy.team@gmail.com>
*
* @license MIT, see http://github.com/asvd/jailed
* Copyright (c) 2014 asvd <heliosframework@gmail.com>
*/const oe={default_rpc_base_url:null,default_base_frame:null};let se=!1;function ae(e){var t=document.createElement("iframe");t.src=e.base_frame,t.sandbox="",t.frameBorder="0",t.style.width="100%",t.style.height="100%",t.style.margin="0",t.style.padding="0",t.style.display="none";const n=t.cloneNode(!1);var r="";return e.permissions&&(e.permissions.includes("midi")&&!r.includes("midi *;")&&(r+="midi *;"),e.permissions.includes("geolocation")&&!r.includes("geolocation *;")&&(r+="geolocation *;"),e.permissions.includes("microphone")&&!r.includes("microphone *;")&&(r+="microphone *;"),e.permissions.includes("camera")&&!r.includes("camera *;")&&(r+="camera *;"),e.permissions.includes("encrypted-media")&&!r.includes("encrypted-media *;")&&(r+="encrypted-media *;"),e.permissions.includes("full-screen")&&(n.allowfullscreen=""),e.permissions.includes("payment-request")&&(n.allowpaymentrequest="")),n.sandbox=["allow-scripts","allow-forms","allow-downloads","allow-modals","allow-popups","allow-same-origin"].join(" "),n.allow=r,n.id="iframe_"+e.id,n}class ce{constructor(e,t,n,r,i,o){if(!se)throw"Please call `initializeJailed()` before using Jailed.";this.config=e,this.id=e.id||Object(M.randId)(),this._id=e._id,this.name=e.name,this.tag=e.tag,this.tags=e.tags,this.type=e.type,this.initializing=!1,this.running=!1,this._log_history=[],this._callbacks=e._callbacks||{},this._is_proxy=r,this.backend=H(this.type),this.engine=n,this.allow_evil=i,this._hasVisibleWindow=["window","rpc-window"].includes(this.type),this._updateUI=t&&t.utils&&t.utils.$forceUpdate||function(){},this._bindInterface(t),r?this._disconnected=!1:(this._disconnected=!0,this._initialInterface.on||(this._initialInterface.on=this.on),this._initialInterface.off||(this._initialInterface.off=this.off),this._initialInterface.emit||(this._initialInterface.emit=this.emit),this.api=null,this._connected=new M.Whenable(!0),this._fail=new M.Whenable(!0),this._disconnect=new M.Whenable(!0),this.connected=new Promise((e,t)=>{this._resolveConnected=e,this._rejectConnected=t}),this._connected.whenEmitted(this._resolveConnected),this._fail.whenEmitted(this._rejectConnected),o?(this._setupRPC(o,e),this._initialized_from_connection=!0):this.backend?"web-worker"===this.type&&this.config.base_worker?this._setupViaWebWorker():this._setupViaIframe():this._setupViaEngine()),this._updateUI()}getBoundInterface(){return this._initialInterface}_bindInterface(e){for(var t in e=e||{},this._initialInterface={_rintf:!0},e)if(Object.prototype.hasOwnProperty.call(e,t))if("function"==typeof e[t])this._initialInterface[t]=e[t].bind(null,this);else if("object"==typeof e[t]){var n={};for(var r in e[t])Object.prototype.hasOwnProperty.call(e[t],r)&&"function"==typeof e[t][r]&&(n[r]=e[t][r].bind(null,this));this._initialInterface[t]=n}else this._initialInterface[t]=e[t]}_engineSetRemote(e){this.engine||console.warn("Plugin "+this.id+" is ready, but it was termianted."),this.api=e,this.api._rintf=!0,this.api.config={id:this.id,name:this.config.name,workspace:this.config.workspace,type:this.config.type,namespace:this.config.namespace,tag:this.config.tag,engine_mode:this.config.engine_mode,engine:this.engine.url,flags:this.config.flags},this.window_id&&(this.api.config.window_id=this.config.window_id),this._disconnected=!1,this.initializing&&(this.initializing=!1,this._updateUI(),this._connected.emit(),this.engine.registerPlugin(this))}async _setupViaEngine(){if(this.engine&&this.engine._is_evil&&"eval is evil"!==this.allow_evil)return this._fail.emit("Evil engine is not allowed."),this._connection=null,this.error("Evil engine is not allowed."),void this._set_disconnected();if(!this.engine||!this.engine.connected)return this._fail.emit("Please connect to the Plugin Engine 🚀."),this._connection=null,this.error("Please connect to the Plugin Engine 🚀."),void this._set_disconnected();this.initializing=!0,this._updateUI();const e=this,t={_rintf:!0,setPluginAPI(t){e._engineSetRemote(t)},terminatePlugin(){e.terminate()},setPluginStatus(t){e._disconnected||(e.running=t.running,e._updateUI())}};if(this.config.passive)this.engine.startPlugin(this.config,this._initialInterface,t),this._engineSetRemote({passive:!0,_rintf:!0,setup:async function(){},on:async function(){},off:async function(){},emit:async function(){}});else try{const e=await this.engine.startPlugin(this.config,this._initialInterface,t);e&&this._engineSetRemote(e)}catch(e){this.error(e),this._set_disconnected()}}_setupViaWebWorker(){if(!H(this.type))throw`Unsupported backend type (${this.type})`;let e;e=new Worker(this.config.base_worker,{name:this.id}),this.webworker=e;const t=new re(e);this._setupConnection(t)}_setupViaIframe(){if(!H(this.type))throw`Unsupported backend type (${this.type})`;if(!this.config.base_frame){let e=oe.default_base_frame;oe.default_rpc_base_url?(e=e+"?base_url="+oe.default_rpc_base_url,console.log("imjoy-rpc library will be loaded from "+oe.default_rpc_base_url)):e=e+"?version="+ie.latest_rpc_version,e=e+"&id="+this.config.id,this.config.base_frame=e}const e=ae(this.config);if(this._hasVisibleWindow){let t=this.config.window_id;if("string"==typeof t&&(t=document.getElementById(t)),!t)throw new Error(`Failed to load plugin ${this.config.name}, iframe container (id=${t}) not found.`);e.style.display="block",t.innerHTML="",t.appendChild(e),this.window_id=t}else document.body.appendChild(e);const t=new ne(e);this._setupConnection(t)}async _setupRPC(e,t){this._connection=e,this.initializing=!0,this._updateUI();try{if(!ee(t)){const e=ee.errors;throw console.error("Invalid config "+t.name||!1,t,e),e}const e=await Object(ie.loadImJoyRPC)({base_url:oe.default_rpc_base_url,api_version:t.api_version,debug:oe.debug});console.log(`loaded imjoy-rpc v${e.VERSION} for ${t.name}`),this._rpc||(this._rpc=new e.RPC(this._connection,{name:"imjoy-core"}),this._registerRPCEvents(this._rpc),this._rpc.setInterface(this._initialInterface)),await this._sendInterface(),this._allow_execution=t.allow_execution,t.allow_execution&&await this._executePlugin(),this.config.passive=this.config.passive||t.passive,this.config.passive?this.api={passive:!0,_rintf:!0,setup:async function(){},on:async function(){},off:async function(){},emit:async function(){}}:this.api=await this._requestRemote(),this.api.config={id:this.id,name:this.config.name,workspace:this.config.workspace,type:this.config.type,namespace:this.config.namespace,tag:this.config.tag,flags:this.config.flags},this.window_id&&(this.api.config.window_id=this.config.window_id),this._disconnected=!1,this.initializing=!1,this._updateUI(),this._connected.emit()}catch(e){if(this._fail.emit(e),this.disconnect(),this.initializing=!1,e&&this.error(e.toString()),this._hasVisibleWindow&&this.config.window_id){document.getElementById(this.config.window_id).innerHTML=`<h5>Oops! failed to load the window.</h5><code>Details: ${m.a.sanitize(String(e))}</code>`}this._updateUI()}}_setupConnection(e){this._connection=e,this.initializing=!0,this._updateUI(),ue(this._connection,this.config),this._connection.on("initialized",async e=>{if(e.error)throw console.error("Plugin failed to initialize",e.error),new Error(e.error);this._setupRPC(this._connection,e.config)}),this._connection.on("failed",e=>{this._fail.emit(e)}),this._connection.on("disconnected",e=>{e&&(e.error?this.error(e.error):e.info&&this.log(e.info)),this._set_disconnected()}),this._connection.connect()}_registerRPCEvents(e){e.on("disconnected",e=>{this._disconnect.emit(),e&&(e.error?this.error(e.message):e.info&&this.log(e.info)),this._set_disconnected()}),e.on("remoteIdle",()=>{this.running&&(this.running=!1,this._updateUI())}),e.on("remoteBusy",()=>{this._disconnected||this.running||(this.running=!0,this._updateUI())})}async hotReload(){if(this.backend){if(!this._rpc||this._disconnected)throw new Error("There is no RPC connection to the plugin.");if(this.initializing=!0,this._updateUI(),!this._allow_execution)throw this.initializing=!1,this._updateUI(),new Error("This plugin does not allow execution.");try{await this._executePlugin(!0),this.config.passive||(this.api=await this._requestRemote())}catch(e){throw this.error(e.toString()),e}finally{this.initializing=!1,this._updateUI()}}else this.config.hot_reloading=!0,await this._setupViaEngine()}async _executePlugin(e){if(e&&"window"===this.config.type&&await this._connection.execute({type:"script",content:"document.querySelectorAll('style,link[rel=\"stylesheet\"]').forEach(item => item.remove());document.body.innerHTML = '';",attrs:{type:"application/javascript"},lang:"javascript"}),this.config.requirements){const t={type:"requirements",lang:this.config.lang,requirements:this.config.requirements,env:this.config.env},n=JSON.stringify(t);e&&this._executed_requirements===n||(await this._connection.execute(t),this._executed_requirements=JSON.stringify(t))}if(this._hasVisibleWindow){if(this.config.styles)for(let e=0;e<this.config.styles.length;e++)await this._connection.execute({type:"style",content:this.config.styles[e].content,attrs:this.config.styles[e].attrs,src:this.config.styles[e].attrs.src});if(this.config.links)for(let e=0;e<this.config.links.length;e++)await this._connection.execute({type:"link",rel:this.config.links[e].attrs.rel,type_:this.config.links[e].attrs.type,attrs:this.config.links[e].attrs,href:this.config.links[e].attrs.href});if(this.config.windows)for(let e=0;e<this.config.windows.length;e++)await this._connection.execute({type:"html",content:this.config.windows[e].content,attrs:this.config.windows[e].attrs})}if(this.config.scripts){const t=[];let n="";for(let e=0;e<this.config.scripts.length;e++){const r={type:"script",content:this.config.scripts[e].content,lang:this.config.scripts[e].attrs.lang,attrs:this.config.scripts[e].attrs,src:this.config.scripts[e].attrs.src};n+=JSON.stringify(r),t.push(r)}if(!e||n!==this._executed_scripts){for(let e of t)await this._connection.execute(e);this._executed_scripts=n}}}_requestRemote(){return new Promise(e=>{this._rpc.once("remoteReady",()=>{e(this._rpc.getRemote())}),this._rpc.requestRemote()})}_sendInterface(){return new Promise(e=>{this._rpc.once("interfaceSetAsRemote",e),this._rpc.sendInterface()})}disconnect(){this._connection&&this._connection.disconnect(),this._disconnect.emit()}onFailed(e){this._fail.whenEmitted(e)}onConnected(e){this._connected.whenEmitted(e)}onDisconnected(e){this._disconnect.whenEmitted(e)}_set_disconnected(){this._disconnected=!0,this.running=!1,this.initializing=!1,this.terminating=!1,this.engine=null,this._updateUI()}_forceDisconnect(){this._set_disconnected(),this._rpc&&(this._rpc.disconnect(),this._rpc=null),this._connection&&(this._connection.disconnect(),this._connection=null)}async terminate(e){if(this._disconnected)this._set_disconnected();else if(!this.terminating){e&&this._forceDisconnect();try{this.api&&this.api.exit&&"function"==typeof this.api.exit&&this.api.exit()}catch(e){console.error("error occured when terminating the plugin",e)}finally{setTimeout((()=>{this._forceDisconnect()}).bind(this),1e3)}}}on(e,t,n){this._callbacks=this._callbacks||{},this._callbacks[e]?this._callbacks[e].push(t):this._callbacks[e]=[t],n&&this._callbacks[e].emitted&&t(this._callbacks[e].emitted_data)}off(e,t){if(this._callbacks[e])if(t){const n=this._callbacks[e],r=n.indexOf(t);r>=0?n.splice(r,1):console.warn(`callback ${e} does not exist.`)}else delete this._callbacks[e];else console.warn(`callback ${e} does not exist.`)}emit(e,t){return new Promise(async(n,r)=>{const i=[];try{if(this._callbacks[e])for(let n of this._callbacks[e])try{await n(void 0!==t?t:void 0)}catch(e){i.push(e),console.error(e)}else this._callbacks[e]=[],this._callbacks[e].emitted=!0,this._callbacks[e].emitted_data=t;i.length<=0?n():r(i)}catch(e){r(e)}})}log(e){if("object"==typeof e)this._log_history.push(e),console.log(`Plugin ${this.id}:`,e);else{const e=Array.prototype.slice.call(arguments).join(" ");this._log_history._info=e.slice(0,100),this._log_history.push({type:"info",value:e}),console.log(`Plugin ${this.id}: ${e}`)}}error(){const e=Array.prototype.slice.call(arguments).join(" ");this._log_history._error=e.slice(0,100),this._log_history.push({type:"error",value:e}),console.error(`Error in Plugin ${this.id}: ${e}`)}progress(e){this._progress=e<1?100*e:e}}function ue(e,t){e.once("imjoyRPCReady",async n=>{const r=n.config||{};let i,o=["close","on","off","emit"];if(["rpc-window","window"].includes(r.type||t.type)&&(o=o.concat(["resize","show","hide","refresh"])),r.credential_required){if(!Array.isArray(r.credential_fields))throw new Error("Please specify the `config.credential_fields` as an array of object.");if(t.credential_handler)i=await t.credential_handler(r.credential_fields);else{i={};for(let e in r.credential_fields)i[e.id]=window.prompt(e.label,e.value)}}e.emit({type:"initialize",config:{name:t.name,type:t.type,allow_execution:!0,enable_service_worker:!1,forwarding_functions:o,expose_api_globally:!0,credential:i},peer_id:n.peer_id})})}function le(e,t,n){return new Promise((r,i)=>{let o,s,a;t=t||document.body,"string"==typeof e?(a=ae({id:"external_"+Object(M.randId)(),type:"window",base_frame:e,permissions:[]}),n||(a.style.display="none"),t.appendChild(a),o=new ne(a),s=e):(s=e.url,o=e);const c=setTimeout(()=>{i("Timeout error: failed to connect to the plugin")},15e3);ue(o,{}),o.once("initialized",async e=>{a&&t.removeChild(a),clearTimeout(c);const n=e.config;if(e.error)throw console.error("Plugin failed to initialize",e.error),new Error(e.error);if(!ee(n)){const e=ee.errors;throw console.error("Invalid config "+n.name||!1,n,e),e}n.base_frame=s,n.code=`<config lang="json">\n${JSON.stringify(n,null," ")}\n</config>`,n.uri=s,n.origin=s,r(n)}),o.once("failed",e=>{clearTimeout(c),a&&t.removeChild(a),i(e)}),o.connect()})}var he=n(80),de=n(28);const pe={};for(let e of Object.keys(q))try{const t=e.startsWith("@")?e:"@"+e;pe[t]=N.compile(q[e])}catch(t){throw console.error(t),new Error(`Failed to compile service spec for ${e}, error: ${t}`)}class fe{constructor({event_bus:e=null,config_db:t=null,engine_manager:n=null,window_manager:r=null,file_manager:i=null,imjoy_api:o={},default_base_frame:a=null,default_rpc_base_url:c=null,debug:u=!1,flags:l=[]}){this.event_bus=e,this.em=n,this.em.setPluginManager(this),this.wm=r,this.fm=i,this.fm.setPluginManager(this),this.config_db=t,this.flags=l,Object(M.assert)(this.event_bus,"event bus is not available"),Object(M.assert)(this.em,"engine manager is not available"),Object(M.assert)(this.wm,"window manager is not available"),Object(M.assert)(this.config_db,"config database is not available"),this.default_base_frame=a,this.default_rpc_base_url=c,this.debug=u,this._allowed_evil_plugin={},this.internal_plugins=he,this.default_repository_list=[{name:"ImJoy Repository",url:"imjoy-team/imjoy-plugins",description:"The official plugin repository provided by ImJoy.io."},{name:"ImJoy Demos",url:"imjoy-team/imjoy-demo-plugins",description:"A set of demo plugins provided by ImJoy.io"}],this.repository_list=[],this.repository_names=[],this.available_plugins=[],this.installed_plugins=[],this.workspace_list=[],this.selected_workspace=null,this.selected_repository=null,this.workflow_list=[],this.service_registry={},this.db=null,o.utils=o.utils||{};const h=o.utils;this.imjoy_api={alert:(e,t)=>window.alert(Object(M.html2string)(t.content)||t),prompt:(e,t,n)=>window.prompt(Object(M.html2string)(t.content)||t,t.placeholder||n),confirm:(e,t)=>window.confirm(Object(M.html2string)(t.content)||t),requestUploadUrl:this.requestUploadUrl,getFileUrl:this.getFileUrl,getFilePath:this.getFilePath,log:(e,...t)=>{e.log(...t),this.event_bus.emit("update_ui")},error:(e,...t)=>{e.error(...t),this.event_bus.emit("update_ui")},progress:(e,t)=>{e.progress(t),this.event_bus.emit("update_ui")},exportFile(e,t,n){"string"==typeof t&&(t=new Blob([t],{type:"text/plain;charset=utf-8"})),Object(R.saveAs)(t,n||t._name||"file_export")},showDialog(){throw"`api.showDialog` is not implemented."},showFileDialog(){throw"`api.showFileDialog` is not implemented."},showProgress(e,t){console.log("api.showProgress: ",t)},showStatus(e,t){console.log("api.showStatus: ",t)},showSnackbar(e,t,n){console.log("api.showSnackbar: ",t,n)},showMessage:(e,t,n)=>{console.log("api.showMessage: ",t,n)},register:this.register,unregister:this.unregister,registerService:this.registerService,unregisterService:this.unregisterService,createWindow:this.createWindow,loadPlugin:this.getPlugin,getPlugin:this.getPlugin,getWindow:this.getWindow,run:this.runPlugin,call:this.callPlugin,connectToServer:(e,t)=>(console.warn("api.connectToServer is deprecated."),B.imjoyRPCSocketIO.connectToServer(t)),installPlugin:(e,t)=>{const n=t.tag,r=t.do_not_load;return delete t.tag,delete t.do_not_load,this.installPlugin(t,n,r)},uninstallPlugin:(e,t)=>this.removePlugin(t),getServices:this.getServices,getFileManager:this.getFileManager,getEngineFactory:this.getEngineFactory,getEngine:this.getEngine,setConfig:this.setPluginConfig,getConfig:this.getPluginConfig,getAttachment:this.getAttachment,onClose:(e,t)=>{console.warn('`api.onClose` is deprecated, please use `api.on("close", ...)` instead.'),e.on("close",t)},echo:(e,t)=>t,utils:{}};for(let e in this.imjoy_api)if("function"==typeof this.imjoy_api[e])this.imjoy_api[e]=this.imjoy_api[e].bind(this);else if("object"==typeof this.imjoy_api[e])for(let t in this.imjoy_api[e])this.imjoy_api[e][t]=this.imjoy_api[e][t].bind(this);if(o.utils.showOpenFilePicker=async(e,...t)=>{if(window.showOpenFilePicker)return await window.showOpenFilePicker(...t);throw new Error("showOpenFilePicker is not available, please make sure you have Google Chrome 86+")},o.utils.showSaveFilePicker=async(e,...t)=>{if(window.showSaveFilePicker)return await window.showSaveFilePicker(...t);throw new Error("showSaveFilePicker is not available, please make sure you have Google Chrome 86+")},o.utils.showDirectoryPicker=async(e,...t)=>{if(window.showDirectoryPicker)return await window.showDirectoryPicker(...t);throw new Error("showDirectoryPicker is not available, please make sure you have Google Chrome 86+")},this.imjoy_api=s()({},this.imjoy_api,o),h)for(let e in h)this.imjoy_api.utils[e]=h[e];this.imjoy_api.utils=this.imjoy_api.utils||{},this.imjoy_api.utils.openUrl=this.imjoy_api.utils.openUrl||((e,t)=>{Object(M.assert)(t),Object.assign(document.createElement("a"),{target:"_blank",href:t}).click()}),this.imjoy_api.utils.sleep=this.imjoy_api.utils.sleep||((e,t)=>(Object(M.assert)(t),new Promise(e=>setTimeout(e,Math.round(1e3*t))))),this.imjoy_api.utils.$forceUpdate=this.imjoy_api.utils.$forceUpdate||function(){},this.event_bus.on("engine_connected",async e=>{for(let t in this.plugins){const n=this.plugins[t];if(!n._initialized_from_connection)try{n.engine===e&&await this.reloadPlugin(n),"auto"===n.config.engine_mode&&(n._disconnected||n.terminating)&&await this.reloadPlugin(n),n.config.engine_mode===e.name&&await this.reloadPlugin(n)}catch(e){this.showMessage(e)}}}),this.event_bus.on("engine_disconnected",async e=>{for(let t in this.plugins){const n=this.plugins[t];n.engine===e&&this.unloadPlugin(n)}})}getFileUrl(e,t){if(console.warn("`api.getFileUrl` is deprecated, please use `api.getFileManager` (https://imjoy.io/docs/#/api?id=apigetfilemanager) and access `getFileUrl` from the file manager."),"object"!=typeof t||!t.path)throw"You must pass an object contains keys named `path` and `engine`";if(e=e||this.root_plugin,t.engine&&(console.warn("The `engine` option for `api.getFileUrl` is deprecated, please use `file_manager` instead of `engine`."),t.file_manager=t.engine,delete t.engine),!t.file_manager)throw"Please specify a file manager via the `file_manager` option.";const n=this.fm.getFileManagerByUrl(t.file_manager);if(!n)throw`File manager ${t.file_manager} not found`;if(!n.connected)throw this.showMessage(`File manager (${n.url}) is not connected.`),`File manager (${n.url}) is not connected.`;return n.getFileUrl(t)}requestUploadUrl(e,t){if(console.warn("`api.requestUploadUrl` is deprecated, please use `api.getFileManager` (https://imjoy.io/docs/#/api?id=apigetfilemanager) and access `requestUploadUrl` from the file manager."),"object"!=typeof t)throw"You must pass an object contains keys named `engine` and `path` (or `dir`, optionally `overwrite`)";if(e=e||this.root_plugin,t.engine&&(console.warn("The `engine` option for `api.requestUploadUrl` is deprecated, please use `file_manager` instead of `engine`."),t.file_manager=t.engine,delete t.engine),!t.file_manager)throw"Please specify a file manager via the `file_manager` option.";const n=this.fm.getFileManagerByUrl(t.file_manager);if(!n)throw`File manager ${t.file_manager} not found`;if(!n.connected)throw this.showMessage(`File manager (${n.url}) is not connected.`),`File manager (${n.url}) is not connected.`;return n.requestUploadUrl({path:t.path,overwrite:t.overwrite,dir:t.dir})}showMessage(e){this.event_bus.emit("show_message",e)}async init(){const e={};this.default_base_frame&&(e.default_base_frame=this.default_base_frame),this.default_rpc_base_url&&(e.default_rpc_base_url=this.default_rpc_base_url),e.debug=this.debug,"serviceWorker"in navigator?navigator.serviceWorker.ready.then(()=>{navigator.serviceWorker.addEventListener("controllerchange",()=>{console.log("Service worker is active and the controller is available, caching internal plugins...");for(let e in this.internal_plugins)this.normalizePluginUrl(this.internal_plugins[e].uri).then(e=>{e.uri&&Object(M.cacheUrlInServiceWorker)(e.uri).then(()=>{console.log("Internal plugin cached in the service worker",e.uri)}).catch(e=>{console.error(e)})})})}):console.log("Service workers are not supported."),(e=>{if(e)for(let t in e)oe[t]=e[t];oe.default_base_frame||(oe.default_base_frame="https://lib.imjoy.io/default_base_frame.html"),oe.default_rpc_base_url&&!oe.default_rpc_base_url.endsWith("/")&&(oe.default_rpc_base_url=oe.default_rpc_base_url+"/"),se=!0})(e),this.root_plugin=new ce({id:"imjoy-root",name:"ImJoy Root Plugin",type:"iframe"},this.imjoy_api,null,!0),this.plugins={},this.plugin_names={},this.registered={ops:{},windows:{},extensions:{},internal_inputs:{},inputs:{},outputs:{},loaders:{},engines:{}}}loadRepositoryList(){return new Promise((e,t)=>{this.config_db.get("repository_list").then(t=>{this.repository_list=t.list;for(let e of this.default_repository_list){let t=!1;for(let n of this.repository_list)if(n.url===e.url&&n.name===e.name){t=n;break}t||this.addRepository(e)}this.repository_names=[];for(let e of this.repository_list)this.repository_names.push(e.name);e(this.repository_list)}).catch(n=>{"not_found"!=n.name?console.error("Database Error",n):console.log("Failed to load repository list",n),this.repository_list=this.default_repository_list,this.repository_names=[];for(let e of this.repository_list)this.repository_names.push(e.name);this.config_db.put({_id:"repository_list",list:this.repository_list},{force:!0}).then(()=>{e(this.repository_list)}).catch(()=>{t("Failed to load the repository list or save the default repositories.")}),this.saveRepositoryList().then(()=>{e(this.repository_list)}).catch(t)})})}saveRepositoryList(){return new Promise((e,t)=>{let n=null;this.config_db.get("repository_list").then(e=>{n=e._rev}).finally(()=>{this.config_db.put({_id:"repository_list",_rev:n||void 0,list:this.repository_list},{force:!0}).then(()=>{e(this.repository_list)}).catch(e=>{this.showMessage("Failed to save repository, database Error:"+e.toString()),t("Failed to save repository, database Error:"+e.toString())})})})}addRepository(e){return new Promise((t,n)=>{"string"==typeof e&&(e={name:e,url:e,description:e}),e.name&&e.url?this.reloadRepository(e).then(r=>{e.name=r.name||e.name,e.description=r.description||e.description;const i=e.url&&e.url.replace("https://github.com/","").replace("http://github.com/","");for(let e of this.repository_list)e.url&&e.url.replace("https://github.com/","").replace("http://github.com/","")===i&&(this.repository_list.splice(this.repository_list.indexOf(e),1),this.showMessage("Repository with the same url already exists."));for(let t of this.repository_list)if(t.name===e.name){e.name=i;break}if(e.name&&e.url){this.repository_list.push(e),this.repository_names=[];for(let e of this.repository_list)this.repository_names.push(e.name);this.saveRepositoryList().then(()=>{t(e)}).catch(n)}else n("You need to provide name and url")}).catch(()=>{this.repository_names.indexOf(e.name)>=0&&this.repository_names.splice(this.repository_names.indexOf(e.name),1),this.showMessage("Failed to load repository from: "+e.url),n("Failed to load repository from: "+e.url)}):n("You need to provide name and url")})}removeRepository(e){return new Promise((t,n)=>{if(!e||!e.name||!e.url)return void n("You need to provide name and url");let r=!1;for(let t of this.repository_list)t.url!==e.url&&t.name!==e.name||(r=t);if(r){const e=this.repository_list.indexOf(r);this.repository_list.splice(e,1),this.repository_names=[];for(let e of this.repository_list)this.repository_names.push(e.name);this.saveRepositoryList().then(()=>{this.showMessage("Repository has been deleted."),t()}).catch(()=>{this.showMessage("Error occured when removing repository."),n("Error occured when removing repository.")})}else n("Repository not found: "+e.name)})}reloadRepository(e){return e=e||this.selected_repository,new Promise((t,n)=>{this.getRepoManifest(e.url).then(n=>{this.available_plugins=n.plugins;for(let e=0;e<this.available_plugins.length;e++){const t=this.available_plugins[e],n=this.installed_plugins.filter(e=>t.name===e.name);n.length>0&&(t.installed=!0,t.tag=n[0].tag)}this.selected_repository=e,t(n)}).catch(n)})}loadWorkspaceList(){return new Promise((e,t)=>{this.config_db.get("workspace_list").then(t=>{this.workspace_list=t.list,this.selected_workspace=this.workspace_list[0],e(this.workspace_list)}).catch(n=>{"not_found"!=n.name&&console.error("Database Error",n),this.workspace_list=["default"],this.config_db.put({_id:"workspace_list",list:this.workspace_list}).then(()=>{this.selected_workspace=this.workspace_list[0],e(this.workspace_list)}).catch(()=>{t("Failed to load Plugin Engine list, database Error:"+n.toString())})})})}loadWorkspace(e){return new Promise((t,n)=>{e=e||this.selected_workspace;const r=()=>{try{this.event_bus.emit("workspace_list_updated",this.workspace_list),this.db=new a.a(e+"_workspace",{revs_limit:2,auto_compaction:!0}),this.selected_workspace=e,t()}catch(e){n(e)}};this.workspace_list.includes(e)?r():(this.workspace_list.includes(e)||this.workspace_list.push(e),this.saveWorkspaceList().then(()=>{r()}).catch(n))})}saveWorkspaceList(){return new Promise((e,t)=>{this.config_db.get("workspace_list").then(n=>{this.config_db.put({_id:n._id,_rev:n._rev,list:this.workspace_list,default:"default"}).then(e).catch(e=>{t("Failed to save workspace, database Error: "+e.toString())})}).catch(e=>{t("Failed to save workspaces, database Error: "+e.toString())})})}removeWorkspace(e){return new Promise((t,n)=>{if(this.workspace_list.includes(e)){const r=this.workspace_list.indexOf(e);this.workspace_list.splice(r,1),this.saveWorkspaceList().then(()=>{t(),this.selected_workspace===e.name&&(this.selected_workspace=null)}).catch(n)}})}saveWorkflow(e){const t=prompt("Please enter a name for the workflow","default");if(!t)return;const n={};n.name=t,n._id=t+"_workflow",n.workflow=JSON.stringify(e.top.data),this.db.get(n._id).then(e=>{n._rev=e._rev}).finally(()=>{this.db.put(n).then(()=>{this.workflow_list.push(n),this.showMessage(`Workflow "${t}" has been successfully saved.`)}).catch(e=>{this.showMessage("Failed to save the workflow."),console.error(e)})})}async removeWorkflow(e){try{const n=await this.db.get(e._id);await this.db.remove(n);var t=this.workflow_list.indexOf(e);t>-1&&this.workflow_list.splice(t,1),this.showMessage(`Workflow "${e.name}" has been successfully removed.`)}catch(e){throw this.showMessage("Failed to remove the workflow."),console.error(e),e}}reloadDB(){return new Promise((e,t)=>{try{if(this.db)try{this.db.close().finally(()=>{this.db=new a.a(this.selected_workspace+"_workspace",{revs_limit:2,auto_compaction:!0}),this.db?"sandbox"===this.selected_workspace?(console.warn("All data in the sandbox stored workspace is going to be destroyed."),this.flags.includes("quiet"),this.db.destroy().then(()=>{this.db=new a.a(this.selected_workspace+"_workspace",{revs_limit:2,auto_compaction:!0}),e()}).catch(e=>{console.error(e),t(e)})):e():t("Failed to reload database.")})}catch(n){console.error("Failed to reload database: ",n),this.db=new a.a(this.selected_workspace+"_workspace",{revs_limit:2,auto_compaction:!0}),this.db?"sandbox"===this.selected_workspace?(console.warn("All data in the sandbox stored workspace is going to be destroyed."),this.flags.includes("quiet"),this.db.destroy().then(()=>{this.db=new a.a(this.selected_workspace+"_workspace",{revs_limit:2,auto_compaction:!0}),e()}).catch(e=>{console.error(e),t(e)})):e():t("Failed to reload database.")}else this.db=new a.a(this.selected_workspace+"_workspace",{revs_limit:2,auto_compaction:!0}),this.db?e():t("Failed to reload database.")}catch(e){console.error("Failed to reload database."),t("Failed to reload database.")}})}setInputLoaders(e){for(let t of e)this.wm.registerInputLoader(t.loader_key,t,t.loader)}reloadPlugins(){return new Promise((e,t)=>{if(this.plugins)for(let e in this.plugins){const t=this.plugins[e];if("function"==typeof t.terminate)try{t.terminate().then(()=>{this.event_bus.emit("update_ui")})}catch(e){console.error(e)}this.plugins[e]=null,this.plugin_names[t.name]=null}this.init().then(()=>{this.reloadDB().then(()=>{this.db.allDocs({include_docs:!0,attachments:!0,sort:"name"}).then(n=>{this.workflow_list=[],this.installed_plugins=[];for(let e=0;e<n.total_rows;e++){const t=n.rows[e].doc;if(t.workflow)this.workflow_list.push(t);else{if(t.hash&&u.a.hash(t.code)!==t.hash){console.error("Plugin source code signature mismatch, skip loading plugin",t);continue}t.installed=!0,this.installed_plugins.push(t);try{this.reloadPlugin(t)}catch(e){console.error(t,e),this.showMessage(`<${t.name}>: ${e}`)}}}this.reloadInternalPlugins(!0).then(e).catch(t)}).catch(e=>{console.error(e),t()})})}).catch(t)})}async reloadInternalPlugins(e){for(let t in this.internal_plugins){const n=this.internal_plugins[t];if(n.startup){if(e&&this.plugin_names[t])continue;console.log(`Loading internal plugin "${t}"...`);try{await this.reloadPluginRecursively({uri:n.src},null,"eval is evil"),console.log(t+" plugin loaded.")}catch(e){console.error(e)}}}}async normalizePluginUrl(e,t){let n,r=!1;t=t||this.available_plugins;const i=e.split("?")[0];if((i.includes("github.com")&&i.includes("/blob/")||i.includes("gist.github.com"))&&(e=await Object(M.githubUrlRaw)(e)),!/(http(s?)):\/\//i.test(e)&&e.includes("/")&&e.includes(":")){let[r,i]=e.split(":");n=i.split("@")[1],i=i.split("@")[0],i=i.trim();const o=r.split("@")[1];r=r.split("@")[0],r=r.trim(),Object(M.assert)(r&&i,'Wrong URI format, it must be "REPO_NAME:PLUGIN_NAME"');const s=await this.getRepoManifest(r,o);let a=null;for(let e of s.plugins)if(e.name===i){a=e;break}if(!a)throw`plugin not found ${r}:${i}`;e=a.uri,t=s.plugins}else if(e.match(M.url_regex))i.endsWith(".imjoy.html")||(r=!0),n=e.split(".imjoy.html@")[1],n&&(e=e.split("@"+n)[0]);else{let r=e.split("@");n=r[1];const i=t.filter(e=>r[0]&&e.name===r[0].trim());if(i.length<=0)throw`Plugin "${r[0]}" cannot be found in the repository.`;e=i[0].uri}return{uri:e,scoped_plugins:t,selected_tag:n,external:r}}async getPluginFromUrl(e,t){const n=await this.normalizePluginUrl(e,t);if(n.external){const t=await le(e);return t.badges=this.getBadges(t),t}e=n.uri,t=n.scoped_plugins;const r=n.selected_tag;-1===e.indexOf("?")&&(e=e+"?"+Object(M.randId)());const i=await h.a.get(e);if(!i||!i.data||""===i.data)throw alert("failed to get plugin code from "+e),"failed to get code.";const o=i.data;let s=this.parsePluginCode(o,{tag:r,origin:e,uri:e});return s.scoped_plugins=t,s}reloadPluginRecursively(e,t,n){return new Promise((r,i)=>{let o="string"==typeof e?e:e.uri,s=this.available_plugins;e.scoped_plugins&&(s=e.scoped_plugins,delete e.scoped_plugins),o?this.getPluginFromUrl(o,s).then(async a=>{if(e.engine_mode)a.engine_mode=e.engine_mode;else if(a.engine_mode){const e=this.plugin_names[a.name];e&&(a.engine_mode=e.config.engine_mode)}if(a.origin=e.origin||o,a.namespace=e.namespace,a.workspace=e.workspace,!a)return console.error(`Failed to fetch the plugin from "${o}".`),void i(`Failed to fetch the plugin from "${o}".`);if(H(a.type)||console.warn(`Installed plugin ${a.name} with unsupported plugin type: ${a.type}`),a.tag=t||this.plugin_names[a.name]&&this.plugin_names[a.name].config.tag||a.tag,a.tag){const e=a.origin.split(":");e[1]&&e[1].split("@")[1]&&(a.origin=e[0]+":"+e[1].split("@")[0])}a._id=a.name&&a.name.replace(/ /g,"_")||Object(M.randId)(),a.dependencies=a.dependencies||[];try{for(let t=0;t<a.dependencies.length;t++)await this.reloadPluginRecursively({uri:a.dependencies[t],scoped_plugins:a.scoped_plugins||s,namespace:e.namespace,hot_reloading:e.hot_reloading},null,n);this.reloadPlugin(a,n).then(e=>{r(e)}).catch(i)}catch(e){i(`Failed to load dependencies for ${a.name}: ${e}`)}}).catch(e=>{console.error(e),i(e)}):i("No url found for plugin "+e.name)})}installPlugin(e,t,n){return new Promise((r,i)=>{let o=this.available_plugins;if(e.scoped_plugins&&(o=e.scoped_plugins,delete e.scoped_plugins),e.src||e.uri){if(e.src=e.src||e.uri,t=t||e.tag,e.src.includes("\n")){const t=this.parsePluginCode(e.src),s=[];t.dependencies=t.dependencies||[];for(let e=0;e<t.dependencies.length;e++)s.push(this.installPlugin({src:t.dependencies[e],namespace:t.namespace,scoped_plugins:t.scoped_plugins||o},null,n));return e.code=e.src,void Promise.all(s).then(()=>{this.savePlugin(e).then(async e=>{this.showMessage(`Plugin "${e.name}" has been successfully installed.`),this.event_bus.emit("plugin_installed",e),r(e),n||this.reloadPlugin(e)}).catch(i)}).catch(i)}if(!/(http(s?)):\/\//i.test(e.src)&&e.src.includes("/")&&e.src.includes(":")||/(http(s?)):\/\//i.test(e.src)){let s=e.src;this.getPluginFromUrl(s,o).then(async a=>{if(a.engine_mode){const e=this.plugin_names[a.name];e&&(a.engine_mode=e.config.engine_mode)}if(a.origin=e.origin||s,!a)return console.error(`Failed to fetch the plugin from "${s}".`),void i(`Failed to fetch the plugin from "${s}".`);if(H(a.type)||console.warn(`Installed plugin ${a.name} with unsupported plugin type: ${a.type}`),a.tag=t||this.plugin_names[a.name]&&this.plugin_names[a.name].config.tag||a.tag,a.tag){const e=a.origin.split(":");e[1]&&e[1].split("@")[1]&&(a.origin=e[0]+":"+e[1].split("@")[0])}a._id=a.name&&a.name.replace(/ /g,"_")||Object(M.randId)(),a.dependencies=a.dependencies||[];try{for(let e=0;e<a.dependencies.length;e++)await this.installPlugin({src:a.dependencies[e],namespace:a.namespace,scoped_plugins:a.scoped_plugins||o},null,n);const e=await this.savePlugin(a);for(let n of this.available_plugins)n.name!==e.name||n.installed||(n.installed=!0,n.tag=t);this.showMessage(`Plugin "${e.name}" has been successfully installed.`),this.event_bus.emit("plugin_installed",e),r(e),n||this.reloadPlugin(e)}catch(e){i(`Failed to install dependencies for ${a.name}: ${e}`)}}).catch(e=>{console.error(e),i(e)})}}else i("Please provide the source via the `src` key.")})}removePlugin(e){return new Promise((t,n)=>{e._id=e._id||e.name.replace(/ /g,"_"),this.db.get(e._id).then(r=>{this.db.remove(r).then(()=>{for(let t=0;t<this.installed_plugins.length;t++)this.installed_plugins[t].name===e.name&&this.installed_plugins.splice(t,1);for(let t of this.available_plugins)t.name===e.name&&(t.installed=!1,t.tag=null);t(),this.showMessage(`"${e.name}" has been removed.`),this.unloadPlugin(e,!0)}).catch(t=>{this.showMessage(t.toString()),console.error("Failed to remove plugin: ",e,t),n(t)})}).catch(n=>{this.unloadPlugin(e,!0),this.showMessage(`"${e.name}" has been unloaded.`),console.log("Plugin does not exist in the database",e,n),t(n)})})}getPluginDocs(e){return new Promise((t,n)=>{this.db.get(e).then(e=>{const n=this.parsePluginCode(e.code).docs;t(n)}).catch(e=>{n(e)})})}getPluginSource(e){return new Promise((t,n)=>{this.db.get(e).then(e=>{t(e.code)}).catch(e=>{n(e)})})}unloadPlugin(e,t){const n=e.name;for(let e in this.plugins){const r=this.plugins[e];if(r.name===n)try{t&&(delete this.plugins[e],delete this.plugin_names[n]),r._unloaded=!0,this._unregister(r),"function"==typeof r.terminate&&r.terminate().then(()=>{this.event_bus.emit("update_ui")}),this.event_bus.emit("update_ui")}catch(e){console.error(e)}}this._unregister(e),"function"==typeof e.terminate&&e.terminate().finally(()=>{this.event_bus.emit("update_ui")}),this.event_bus.emit("update_ui"),this.event_bus.emit("plugin_unloaded",e)}connectPlugin(e){return new Promise((t,n)=>{le(e).then(r=>{r.runnable=!1!==r.runnable,r.badges=this.getBadges(r),this.unloadPlugin(r,!0),this.loadPlugin(r,{id:r.id},!1,e).then(e=>{t(e)}).catch(n)}).catch(n)})}async reloadPlugin(e,t){try{if(e.hot_reloading){let t;if(e.id)for(let n of Object.keys(this.plugins))if(n===e.id){t=this.plugins[n];break}const n=this.parsePluginCode(e.code,{tag:e.tag,_id:e._id,origin:e.origin,namespace:e.namespace,hot_reloading:e.hot_reloading,engine_mode:e.engine_mode});if(e.name=e.name||n.name,!t&&e.name)for(let n of Object.keys(this.plugins))if(this.plugins[n].name===e.name){t=this.plugins[n];break}if(t&&"window"!==t.type&&t.config.tag===n.tag&&t.config.engine_mode===n.engine_mode&&t.config.namespace===n.namespace){t.config.requirements=n.requirements,t.config.scripts=n.scripts,t.config.styles=n.styles,t.config.links=n.links,t.config.windows=n.windows;try{return await t.hotReload(),n.type&&this._register(t,n),t.api&&t.api.setup&&await t.api.setup(),t}catch(e){console.error("Failed to hot reload: ",e),this.showMessage("Failed to perform hot reloading, error: "+e)}}}e instanceof ce&&(e=e.config),this.unloadPlugin(e,!0);const n=this.parsePluginCode(e.code,{tag:e.tag,_id:e._id,origin:e.origin,namespace:e.namespace,hot_reloading:e.hot_reloading,engine_mode:e.engine_mode});if(n.engine=null,this.unloadPlugin(n,!0),e.load_dependencies||"collection"===n.type){n.dependencies=n.dependencies||[];for(let r=0;r<n.dependencies.length;r++)await this.reloadPluginRecursively({uri:n.dependencies[r],namespace:e.namespace,hot_reloading:e.hot_reloading},null,t)}if("collection"===n.type)return;let r;"rpc-window"===n.type||"window"===n.type?r=this.loadProxyPlugin(n):("eval is evil"===t?this._allowed_evil_plugin[n.name]=n.code:this._allowed_evil_plugin[n.name]===n.code&&(t="eval is evil"),r=this.loadPlugin(n,null,t));try{const t=await r;return t._id=e._id,e.name=t.name,e.type=t.type,e.plugin=t,this.event_bus.emit("update_ui"),t}catch(t){throw e.plugin=null,t}}catch(e){throw this.showMessage(e||"Error.",15),console.error(e),e}}savePlugin(e){return new Promise((t,n)=>{const r=e.code;try{const i=this.parsePluginCode(r,{tag:e.tag,origin:e.origin,engine_mode:e.engine_mode,namespace:e.namespace});i.code=r,i._id=i.name.replace(/ /g,"_"),i.hash=u.a.hash(i.code);const o=e=>{this.db.put(e).then(()=>{for(let t=0;t<this.installed_plugins.length;t++)this.installed_plugins[t].name===e.name&&this.installed_plugins.splice(t,1);e.installed=!0,this.installed_plugins.push(e),t(e),this.showMessage(e.name+" has been successfully saved.")}).catch(e=>{this.showMessage("Failed to save the plugin."),console.error(e),n("failed to save")})};this.db.get(i._id).then(e=>{i._rev=e._rev,o(i)}).catch(()=>{o(i)})}catch(e){this.showMessage(e||"Error."),n(e)}})}getBadges(e){const t=H(e.type);return t?t.icon||"":"🚀"}parsePluginCode(e,t){t=t||{};try{const n=Object(de.a)(e);let r;if("yaml"===n.config[0].attrs.lang)r=p.a.load(n.config[0].content);else if("json"===n.config[0].attrs.lang)r=JSON.parse(n.config[0].content);else if(r=JSON.parse(n.config[0].content),Object(M.compareVersions)(r.api_version,">","0.1.5"))throw`Unsupported config language ${n.config[0].attrs.lang}, please set lang="json" or lang="yaml"`;r.tag=t.tag||r.tags&&r.tags[0],r.hot_reloading=t.hot_reloading,r.scripts=[];for(let e=0;e<n.script.length;e++)n.script[e].attrs.tag===r.tag&&(r.script=n.script[e].content),n.script[e].attrs.tag&&n.script[e].attrs.tag!==r.tag||r.scripts.push(n.script[e]);!r.script&&n.script.length>0&&(r.script=n.script[0].content,r.lang=n.script[0].attrs.lang),r.links=n.link||null,r.windows=n.window||null,r.styles=n.style||null,r.docs=n.docs&&n.docs[0]||r.docs,r.attachments=n.attachment||null,r._id=t._id||r.name.replace(/ /g,"_"),r.uri=t.uri,r.origin=t.origin,r.namespace=t.namespace,r.code=e,r.id=r.name.trim().replace(/ /g,"_")+"_"+Object(M.randId)(),r.runnable=!1!==r.runnable,r.requirements=r.requirements||[];for(let e=0;e<$.length;e++){const t=r[$[e]];if(t&&"object"==typeof t&&!(t instanceof Array)){if(!r.tag)throw"You must use 'tags' with configurable fields.";r[$[e]]=t[r.tag],Object.prototype.hasOwnProperty.call(t,r.tag)||console.log("WARNING: "+$[e]+" do not contain a tag named: "+r.tag)}}if(r.lang=r.lang||"javascript",r=function(e){return Object(M.compareVersions)(e.api_version,"<=","0.1.1")&&(e.type=e.type||e.mode,delete e.mode,"pyworker"===e.type?e.type="native-python":"webworker"===e.type?e.type="web-worker":"webpython"===e.type&&(e.type="web-python")),e}(r),!K(r)){const e=K.errors;throw console.error("Invalid plugin config: "+r.name,e),e}const i=H(r.type);return r.badges=this.getBadges(r),r.engine_mode=i?null:t.engine_mode||"auto",r.flags&&(r.flags.indexOf("engine")>=0||r.flags.indexOf("engine-factory")>=0)&&(r.badges=r.badges+"⚙"),r.flags&&r.flags.indexOf("file-manager")>=0&&(r.badges=r.badges+"📁"),r}catch(e){throw console.error(e),"Failed to parse the plugin file, error: "+e}}validatePluginConfig(e){if(e.name.indexOf("/")<0)return!0;throw"Plugin name should not contain '/'."}loadProxyPlugin(e,t){const n={_id:e._id,name:e.name,type:e.type,ui:e.ui,tag:e.tag,inputs:e.inputs,outputs:e.outputs,docs:e.docs,attachments:e.attachments};return this.validatePluginConfig(n),new Promise((r,i)=>{t?(n.id=t.id,n.initialized=!0):(n.id=e.name.trim().replace(/ /g,"_")+"_"+Object(M.randId)(),n.initialized=!1);const o=s()({},e,n);o.workspace=this.selected_workspace;const a=s()({TAG:o.tag,WORKSPACE:this.selected_workspace,config:{tag:o.tag,workspace:this.selected_workspace}},this.imjoy_api);try{const t=new ce(o,a,null,!0);t.api={_rintf:!0,setup:async function(){},run:async t=>{const n=Object(M._clone)(e.defaults)||{};return n.type=e.name,n.name=e.name,n.tag=e.tag,n.data=t&&t.data||{},n.config=t&&t.config||{},n.id=t&&t.id,n.window_id=t&&t.window_id,n.as_dialog&&this.imjoy_api.showDialog?(n.standalone&&(n.fullscreen=!0,n.standalone=!1),await this.imjoy_api.showDialog(null,n)):await this.imjoy_api.createWindow(null,n)}},this._register(t,n),this.plugins[t.id]=t,this.plugin_names[t.name]=t,this.event_bus.emit("plugin_loaded",t),r(t)}catch(e){i(e)}})}loadPlugin(e,t,n,r){return e=Object(M._clone)(e),this.validatePluginConfig(e),new Promise(async(i,o)=>{const a={};t?(a.id=t.id,a.initialized=!0):(a.id=e.name.trim().replace(/ /g,"_")+"_"+Object(M.randId)(),a.initialized=!1),a._id=e._id;let c=null;H(e.type)||(c=await this.em.findEngine(e),c?this.showMessage("Running plugin with plugin engine: "+c.name):console.error(`Plugin engine not found for plugin type=${e.type}.`));const u=s()({},e,a);u.workspace=this.selected_workspace;const l=s()({TAG:u.tag,WORKSPACE:this.selected_workspace,ENGINE_URL:c&&c.url||void 0,config:{tag:u.tag,workspace:this.selected_workspace,engine:c&&c.url||void 0}},this.imjoy_api);try{const t=new ce(u,l,c,!1,n,r);t._log_history.push(`Loading plugin ${t.id} (config=${l.config})`),l.ENGINE_URL&&t._log_history.push("ENGINE_URL="+l.ENGINE_URL);const s=setTimeout(()=>{t.initializing=!1,console.warn(`Plugin ${t.name} failed to load in 180s.`)},18e4);t.onConnected(async()=>{if(clearTimeout(s),!t.api)throw console.error("Error occured when loading plugin."),this.showMessage("Error occured when loading plugin."),o("Error occured when loading plugin."),"Error occured when loading plugin.";if(t._log_history.push("Plugin connected."),t._unloaded)return console.log("WARNING: this plugin is ready but unloaded: "+t.id),void t.terminate().then(()=>{this.event_bus.emit("update_ui")});if(e.type&&this._register(t,e),t.config.flags&&t.config.flags.includes("browserfs")){(await this.getPlugin(null,{name:"BrowserFS"})).attachWebWorker(t.webworker)}t.config.resumed&&t.api.resume?(t._log_history.push("Resuming plugin."),t.api.resume().then(()=>{this.event_bus.emit("plugin_loaded",t),i(t)}).catch(n=>{console.error("error occured when loading plugin "+e.name+": ",n),this.showMessage(`<${e.name}>: ${n}`,15),o(n),t.terminate().then(()=>{this.event_bus.emit("update_ui")})})):t.api.setup?(t._log_history.push("Setting up plugin."),t.api.setup().then(()=>{this.event_bus.emit("plugin_loaded",t),i(t)}).catch(n=>{console.error("error occured when loading plugin "+e.name+": ",n),this.showMessage(`<${e.name}>: ${n}`,15),o(n),t.terminate().then(()=>{this.event_bus.emit("update_ui")})})):(console.warn(`No "setup()" function is defined in plugin "${t.name}".`),i(t))}),t.onFailed(n=>{clearTimeout(s),t.error(n),n?this.showMessage(`<${e.name}>: ${n}`):this.showMessage(`Error occured when loading ${e.name}.`),console.error("error occured when loading "+e.name+": ",n),t.terminate().then(()=>{this.event_bus.emit("update_ui")}),o(n)}),t.docs=e.docs,t.attachments=e.attachments,this.plugins[t.id]=t,this.plugin_names[t.name]=t}catch(e){o(e)}})}renderWindow(e){return new Promise((t,n)=>{const r=s()({},e.plugin,e);r.workspace=this.selected_workspace;const i=s()({},this.imjoy_api);for(let t in e.api)Object.prototype.hasOwnProperty.call(e.api,t)&&(i[t]=function(){var n=Array.prototype.slice.call(arguments,1);e.api[t].apply(e,n)});const o=s()({TAG:r.tag,WORKSPACE:this.selected_workspace,config:{tag:r.tag,workspace:this.selected_workspace}},i);try{const i=new ce(r,o);i.onConnected(()=>{!e.standalone&&e.api.focus&&e.api.focus(),i.api=i.api||{};for(let t in e.api)Object.prototype.hasOwnProperty.call(e.api,t)&&(i.api[t]=e.api[t]);(i.api.setup||async function(){})().then(()=>{if(this.event_bus.emit("plugin_loaded",i),e.data=e.data||{},e.data._source_op=e.data&&e.data._op,e.data._op=i.name,e.data._workflow_id=e.data&&e.data._workflow_id,e.plugin=i,e.update=i.api.run,i.config.runnable&&!i.api.run){const e="You should define a `run` function for "+i.name+" or set its `runnable` field to false.";console.warn(e)}i.api.run?i.api.run(this.filter4plugin(e)).then(n=>{if(n)for(let t in n)e[t]=n[t];t(i)}).catch(e=>{i.error(`<${i.name}>: (${e&&e.toString()} || "Error.")`),n(e)}):t(i)}).catch(t=>{i.error(`Error occured when loading the window plugin ${e.name}: ${t&&t.toString()}`),i.terminate().then(()=>{this.event_bus.emit("update_ui")}),n(t)})}),i.onFailed(t=>{!e.standalone&&e.focus&&e.focus(),i.error(`Error occured when loading ${e.name}: ${t}.`),i.terminate().then(()=>{this.event_bus.emit("update_ui")}),n(t)})}catch(e){n(e)}})}plugin2joy(e){if(!e)return null;const t={};return t._rintf=e._rintf,e.type&&e.data?(t.data=e.config,t.target=e.data,t.target.name=e.name||"",t.target.type=e.type||""):(t.data=null,t.target=e),t.target=t.target||{},Array.isArray(t.target)&&t.target.length>0&&void 0!==e.select&&t.target[e.select]&&(t.target=t.target[e.select]),"object"==typeof t.target?(t.target._variables=e._variables||{},t.target._workflow_id=e._workflow_id||null,t.target._op=e._op||null,t.target._source_op=e._source_op||null,t.target._transfer=e._transfer||!1,Object.keys(t.target).length>4?t:null):t}filter4plugin(e){return e&&{_variables:e._variables||null,_op:e._op,_source_op:e._source_op,_transfer:e._transfer,_workflow_id:e._workflow_id,config:e.config,data:e.data}}joy2plugin(e){if(!e)return null;e.target=e.target||{};const t={_rintf:e._rintf,_variables:e.target._variables||null,_op:e.target._op,_source_op:e.target._source_op,_transfer:e.target._transfer,_workflow_id:e.target._workflow_id,config:e.data,data:e.target,name:e.target.name||"",type:e.target.type||""};return delete e.target._op,delete e.target._workflow_id,delete e.target._variables,delete e.target._source_op,delete e.target._transfer,t}getRepoManifest(e,t){return new Promise((n,r)=>{const o=new RegExp("^[^/.]+/[^/.]+$");let s,a;e.match(o)?(a=e,t&&(e=e+"/tree/"+t,a=a+"@"+t),s=Object(M.githubImJoyManifest)("https://github.com/"+e)):e.includes("github.com")?(s=Object(M.githubImJoyManifest)(e),a=Object(M.githubRepo)(e)):(s=e,a=s),h.a.get(s).then(e=>{if(e&&e.data&&e.data.plugins){const t=e.data;t.plugins=t.plugins.filter(e=>!e.disabled),/(http(s?)):\/\//i.test(t.uri_root)||(t.uri_root=s.replace(new RegExp("manifest.imjoy.json$"),i()(t.uri_root,"/")));for(let e=0;e<t.plugins.length;e++){const n=t.plugins[e];n.uri=n.uri||n.name+".imjoy.html",n.origin=a+":"+n.name,n.uri.startsWith(t.uri_root)||/(http(s?)):\/\//i.test(n.uri)||(n.uri=t.uri_root+"/"+n.uri),n._id=n._id||n.name.replace(/ /g,"_"),n.badges=this.getBadges(n)}n(t)}else r("failed to load url: "+s)}).catch(r)})}destroy(){for(let e in this.plugins){const t=this.plugins[e];try{"function"==typeof t.terminate&&t.terminate()}catch(e){}}}registerOp(e,t){try{if(!e)throw"Plugin not found.";if((t=Object(M._clone)(t)).name=t.name||e.name,t.show_panel=t.show_panel||!1,e.name===t.name&&(t.ui=t.ui||e.config.description),t.inputs=t.inputs||null,t.outputs=t.outputs||null,t.run=t.run||null,t.run=t.run||e&&e.api&&e.api.run,!Y(t)){const e=Y.errors;throw console.error("Error occured during registering "+t.name,e),e}const n=e.name,r=t.name,i=r===n?n:n+"/"+r,o={name:t.name,tags:["op","plugin"],type:i,init:y.normalizeUI(t.ui)};"window"===t.type?o.tags.push("window"):"rpc-window"===t.type?o.tags.push("rpc-window"):"rpc-worker"===t.type?o.tags.push("rpc-worker"):"native-python"===t.type?o.tags.push("python"):"web-worker"===t.type?o.tags.push("web-worker"):"web-python"===t.type?o.tags.push("web-python"):"iframe"===t.type&&o.tags.push("iframe");let s=t.run;if(e&&s){const t=async t=>{try{const e=await s(this.joy2plugin(t));return this.plugin2joy(e)}catch(t){throw e.error(t&&t.toString()),t}};o.onexecute=t}else o.onexecute=()=>{e.log("WARNING: no run function defined.")};if(t.update&&"function"==typeof t.update){const e=async e=>{const n=await t.update(this.joy2plugin(e));return this.plugin2joy(n)};o.onupdate=Object(M.debounce)(e,300)}else if(e&&e.api&&e.api.update){const t=async t=>{const n=await e.api.update(this.joy2plugin(t));return this.plugin2joy(n)};o.onupdate=Object(M.debounce)(t,300)}if(!V(o)){const e=V.errors;throw console.error("Error occured during registering op to joy "+o.name,e),e}y.add(o);const a={plugin_id:e.id,name:o.name,ui:"{id: '__op__', type: '"+o.type+"'}",onexecute:o.onexecute};if(e.ops=e.ops||{},e.ops[t.name]=a,t.inputs)try{if(!("object"==t.inputs.type&&t.inputs.properties||"array"==t.inputs.type&&t.inputs.items)){if("object"!=typeof t.inputs)throw"inputs schema must be an object.";t.inputs={properties:t.inputs,type:"object"}}"object"===t.inputs.type&&t.inputs.properties&&!t.inputs.required&&(t.inputs.required=Object.keys(t.inputs.properties));const o=N.compile(t.inputs);a.inputs_schema=o,this.registered.inputs[i]={loader_key:i,op_name:r,plugin_name:n,schema:o},this.registered.loaders[i]=async t=>{let n={};e.config&&e.config.ui&&(n=await this.imjoy_api.showDialog(e,{type:"imjoy/joy",ui:e.config.ui,name:e.config.name})),t.transfer=t.transfer||!1,t._source_op=t._op,t._op=r,t._workflow_id=t._workflow_id||"data_loader_"+r.trim().replace(/ /g,"_")+Object(M.randId)();const i={op:{name:r},target:t,data:n},o=await e.api.run(this.joy2plugin(i));if(o){const t=this.plugin2joy(o);if(t&&!t._rintf){const n={};n.name=t.name||"result",n.type=t.type||"imjoy/generic",n.config=t.data||{},n.data=t.target||{},await this.imjoy_api.createWindow(e,n)}}},this.wm.registerInputLoader(i,this.registered.inputs[i],this.registered.loaders[i])}catch(e){console.error(`error occured when parsing the inputs schema of "${t.name}"`,e)}if(t.outputs)try{if("object"!=t.outputs.type||!t.outputs.properties){if("object"!=typeof t.outputs)throw"inputs schema must be an object.";t.outputs={properties:t.outputs,type:"object"}}"object"===t.outputs.type&&t.outputs.properties&&!t.outputs.required&&(t.outputs.required=Object.keys(t.outputs.properties));const n=N.compile(t.outputs);a.outputs_schema=n,this.registered.outputs[i]={op_name:t.name,plugin_name:e.name,schema:n}}catch(e){console.error(`error occured when parsing the outputs schema of "${t.name}"`,e)}return this.registered.ops[i]=a,this.registered.windows[t.name]=e.config,this.event_bus.emit("op_registered",a),!0}catch(e){throw console.error(e),e}}unregisterOp(e,t){if(!e)throw"Plugin not found.";const n=e.name;if(t){const r="string"==typeof t?t:t.name,i=r===n?n:n+"/"+r;this.registered.inputs[i]&&delete this.registered.inputs[i],this.registered.loaders[i]&&delete this.registered.loaders[i],r===n&&this.registered.windows[n]&&delete this.registered.windows[n],this.registered.ops[i]&&delete this.registered.ops[i],e.ops&&e.ops[r]&&delete e.ops[r],this.wm.unregisterInputLoader(i),y.remove(i)}else{if(e.ops&&Object.keys(e.ops).length>0)for(let t in e.ops){const n=e.ops[t];n.name&&this.unregisterOp(e,n.name)}e.name&&this.unregisterOp(e,e.name)}}async _register(e,t){return!t.type||t._id||"@operator"===t.type||"operator"===t.type?(this.registerOp(e,t),this.service_registry[t.name]={id:t.name,type:"@operator",name:t.name,ui:t.ui,inputs:t.inputs,outputs:t.outputs,run:t.run,provider:e.name,providerId:e.id},this.event_bus.emit("register",{config:t,plugin:e}),t.name):(t.id=t.id||Object(M.randId)(),t.provider=e.name,t.providerId=e.id,this.service_registry[t.id]=t,this.event_bus.emit("register",{config:t,plugin:e}),t.id)}_unregister(e,t){if(t&&"string"!=typeof t&&"@operator"!==t.type&&"operator"!==t.type)delete this.service_registry[t.id];else{if(!t){const t=this.getServices(e,{providerId:e.id});for(let n of t)this._unregister(e,n)}t=t||e,this.unregisterOp(e,t),delete this.service_registry[t.name]}return this.event_bus.emit("unregister",{config:t,plugin:e}),!0}async register(e,t){return console.warn("api.register is deprecated, please use `api.registerService` instead."),await this.registerService(e,t)}async unregister(e,t){return console.warn("api.unregister is deprecated, please use `api.registerService` instead."),await this.unregisterService(e,t)}async registerService(e,t){if(e=e||{},!t.type||!t.name)throw new Error("you must specify the service `type` and `name`.");if(t.type.startsWith("@")){if(!pe[t.type])throw new Error(`Registered service type "${t.type}" not found, please consider submit your type definition to the imjoy-core repo, see https://imjoy.io/docs/#/api?id=apiregisterservice for more details`);{const e=pe[t.type];if(!e(t)){const n=e.errors;throw console.error("Failed to register service "+t.name||!1,n),n}}}return this._register(e,t)}async unregisterService(e,t){return this._unregister(e,t)}getServices(e,t){return t=t||{},Object.values(this.service_registry).filter(e=>{let n=!0;for(let r of Object.keys(t))if(t[r]!==e[r]){n=!1;break}return n})}createWindow(e,t,n){let r={};return r="string"==typeof t?t.includes("\n")||/(http(s?)):\/\//i.test(t)||t.includes("/")&&t.includes(":")?{src:t}:{type:t}:t,n&&(r=Object.assign(r,n)),new Promise(async(e,t)=>{if(r.type||r.ui&&(r.type="imjoy/joy"),r.data=r.data||null,r.panel=r.panel||null,!X(r)){const e=X.errors;throw console.error("Error occured during creating window ",r,e),e}if(r.name=r.name||r.type,r.window_id=r.window_id||"plugin_window_"+r.id+Object(M.randId)(),r.window_type=r.type,r.type&&r.type.startsWith("imjoy/"))r.id="imjoy_"+Object(M.randId)(),this.wm.addWindow(r).then(()=>{r.api.on("ready",()=>{r.refresh(),r.api=r.api||{},r.api=Object.assign(r.api,{_rintf:!0,run:e=>{for(let t in e)r[t]=e[t]}}),e(r.api)},!0)}).catch(t);else{let n;if(r.src)if(r.src.includes("\n")){const e=await this.reloadPlugin({code:r.src,load_dependencies:!0,namespace:r.namespace,tag:r.tag,hot_reloading:r.hot_reloading});n=e.config,r.type=e.config.type,r.name=r.name||e.name||r.type}else if(!/(http(s?)):\/\//i.test(r.src)&&r.src.includes("/")&&r.src.includes(":")||/(http(s?)):\/\//i.test(r.src)&&(r.src.endsWith(".imjoy.html")||r.src.includes("github.com")&&r.src.includes("/blob/")||r.src.includes("gist.github.com"))){const e=await this.reloadPluginRecursively({uri:r.src,tag:r.tag,namespace:r.namespace,hot_reloading:r.hot_reloading});n=e.config,r.type=e.config.type,r.name=r.name||e.name||r.type}else{if(!/(http(s?)):\/\//i.test(r.src))return void t("Unsupported window spec "+r);if(r.type=r.type||r.src.split("?")[0],r.name=r.name||r.type,n=Object.assign({},r),delete n.data,delete n.config,"object"==typeof r.config)for(let e of z)r.config[e]&&(n[e]=r.config[e]);n.type="rpc-window",n.base_frame=r.src,n.id="rpc_window_"+Object(M.randId)()}else n=this.registered.windows[r.type];if(!n)throw console.error("No plugin registered for window type: "+r.type,this.registered.windows),t("No plugin registered for window type: "+r.type),"No plugin registered for window type: "+r.type;const i=r;if(i.id=i.id||n.id+"_"+Object(M.randId)(),i.type=n.type,"rpc-window"!==i.type&&"window"!==i.type)throw'Window plugin must be with type "window"';if(i.plugin=n,!X(i)){const e=X.errors;throw console.error("Error occured during creating window ",i,e),e}i.loading=!0;const o=setTimeout(()=>{i.loading=!1,console.warn(`Failed to load window "${i.name}" in 10s.`)},1e4);this.wm.addWindow(i).then(()=>{setTimeout(()=>{i.refresh();const r=this.renderWindow(i);"rpc-window"===i.type&&(clearTimeout(o),i.loading=!1),i.passive||n.passive?e({passive:!0,_rintf:!0,setup:async function(){},on:async function(){},off:async function(){},emit:async function(){}}):r.then(t=>{i.api.on("close",async()=>{this.event_bus.emit("closing_window_plugin",t),await t.terminate()}),i.refresh(),e(t.api)}).catch(e=>{i.refresh(),t(e)}).finally(()=>{clearTimeout(o),i.loading=!1})},0)})}})}async callPlugin(e,t,n){const r=this.plugin_names[t];if(r){if(!r.api[n])throw`function "${n}" of ${t} is not available.`;return await r.api[n].apply(null,Array.prototype.slice.call(arguments,3,arguments.length))}throw`plugin with type ${t} not found.`}async getPlugins(e){const t=[];for(let e in this.plugins)t.push({name:this.plugins[e].name,config:this.plugins[e].config,api:this.plugins[e].api});return t}async getPlugin(e,t,n){let r={};if("string"==typeof t?/(http(s?)):\/\//i.test(t)||t.includes("\n")?r.src=t:r.name=t:r=t,n&&(r=Object.assign(r,n)),r.src&&r.src.includes("\n")){const e=await this.reloadPlugin({code:r.src,load_dependencies:!0,namespace:r.namespace,tag:r.tag,hot_reloading:r.hot_reloading,engine_mode:r.engine_mode});return console.log(e.name+" loaded from source code"),e.api}if(r.src&&(/(http(s?)):\/\//i.test(r.src)||r.src.includes("/")&&r.src.includes(":"))){const e=await this.reloadPluginRecursively({uri:r.src,tag:r.tag,namespace:r.namespace,hot_reloading:r.hot_reloading,engine_mode:r.engine_mode},r.tag);return console.log(`${e.name} loaded from ${r.src}`),e.api}if(r.id&&this.plugins[r.id])return this.plugins[r.id].api;if(r.name){if(this.plugin_names[r.name])return this.plugin_names[r.name].api;if(this.internal_plugins[r.name]){const e=await this.reloadPluginRecursively({uri:this.internal_plugins[r.name].src,tag:r.tag,namespace:r.namespace,hot_reloading:r.hot_reloading,engine_mode:r.engine_mode},null,"eval is evil");return console.log(e.name+" loaded."),e.api}throw"Plugin not found: "+r.name}throw"Unsupported plugin spec: "+r}async getWindow(e,t){if("string"==typeof t&&(t={name:t}),t.plugin_id)for(let e of this.wm.windows)if(e.plugin.id===t.plugin_id)return e.plugin&&e.plugin.api;if(t.window_id)for(let e of this.wm.windows)if(e.window_id===t.window_id)return e.plugin&&e.plugin.api;if(!t.name&&!t.type)return null;for(let e of this.wm.windows)if(!(t.name&&e.name!==t.name||t.type&&e.window_type!==t.type))return e.plugin&&e.plugin.api;return null}async getFileManager(e,t){const n=this.fm.getFileManagerByUrl(t);if(n)return n.api;throw`file manager with url ${t} not found.`}async getEngine(e,t){const n=this.em.getEngineByUrl(t);if(n)return n.api;throw`engine with url ${t} not found.`}async getEngineFactory(e,t){const n=this.em.getFactory(t);if(n)return n.api;throw`engine factory with name ${t} not found.`}async runPlugin(e,t,n){if(!e||!e.id)throw"source plugin is not available.";const r=this.plugin_names[t];if(r)return await r.api.run(n||{});throw"plugin with type "+t+" not found."}setPluginConfig(e,t,n){if(!e)throw"setConfig Error: Plugin not found.";if(t.startsWith("_")&&e.config[t.slice(1)])throw`'${t.slice(1)}' is a readonly field defined in <config> block, please avoid using it`;return n?localStorage.setItem("config_"+e.name+"_"+t,n):localStorage.removeItem("config_"+e.name+"_"+t)}getPluginConfig(e,t){if(!e)throw"getConfig Error: Plugin not found.";return t.startsWith("_")&&e.config[t.slice(1)]?e.config[t.slice(1)]:localStorage.getItem("config_"+e.name+"_"+t)}getAttachment(e,t){if(!e.config.attachments)return null;for(let n=0;n<e.config.attachments.length;n++)if(e.config.attachments[n].attrs.name===t)return e.config.attachments[n].content}async checkPluginUpdate(e){const t=e.config,n=await this.getPluginFromUrl(t.origin,this.available_plugins);t.hash?t.hash!==u.a.hash(n.code)&&Object(M.compareVersions)(t.version,"<=",n.version)?e.update_available=!0:e.update_available=!1:Object(M.compareVersions)(t.version,"<",n.version)?e.update_available=!0:e.update_available=!1,this.event_bus.emit("update_ui")}checkUpdates(){for(let e in this.plugins){const t=this.plugins[e];if(t.config.origin)this.checkPluginUpdate(t);else{const e=this.available_plugins.find(e=>t.name===e.name);e&&(t.config.origin=e.uri,this.checkPluginUpdate(t))}}}}class me{constructor({event_bus:e=null}){this.event_bus=e,Object(M.assert)(this.event_bus),this.windows=[],this.window_ids={},this.active_windows=[],this.selected_window=null,this.window_mode="grid",this.registered_inputs={},this.registered_loaders={},this.default_window_pos={x:0,y:0,w:20,h:10,index:0}}generateGridPosition(e){e.i=Object(M.randId)(),e.index=this.default_window_pos.index,e.w=e.w||this.default_window_pos.w,e.h=e.h||this.default_window_pos.h,void 0===e.x&&(e.x=this.default_window_pos.x,this.default_window_pos.x=this.default_window_pos.x+this.default_window_pos.w),void 0===e.y&&(e.y=this.default_window_pos.y),this.default_window_pos.x>=20&&(this.default_window_pos.x=0,this.default_window_pos.y=this.default_window_pos.y+this.default_window_pos.h),this.default_window_pos.index=this.default_window_pos.index+1}registerInputLoader(e,t,n){this.registered_inputs[e]&&console.log(`WARNING: input loader ${e} already exists, it will be replaced.`),this.registered_inputs[e]=t,this.registered_loaders[e]=n}unregisterInputLoader(e){delete this.registered_inputs[e],delete this.registered_loaders[e]}getDataLoaders(e){const t={};for(let n in this.registered_inputs)if(this.registered_inputs[n].loader_key&&this.registered_inputs[n].schema(e))try{const e=this.registered_inputs[n].loader_key;this.registered_loaders[e]&&(t[e]=this.registered_loaders[e])}catch(e){console.error("Failed to get loaders.",e)}return t}closeWindow(e){const t=this.windows.indexOf(e);t>-1&&(this.windows.splice(t,1),delete this.window_ids[e.id]),(e.selected||this.selected_window===e)&&(e.selected=!1,"single"===this.window_mode?this.selected_window=this.windows[0]:this.selected_window=null),this.event_bus.emit("close_window",e)}setupCallbacks(e){e._callbacks=e._callbacks||{},e.api=e.api||{},e.api.on=(t,n,r)=>{e._callbacks[t]?e._callbacks[t].push(n):e._callbacks[t]=[n],r&&e._callbacks[t].emitted&&n(e._callbacks[t].emitted_data)},e.api.off=(t,n)=>{if(e._callbacks[t])if(n){const r=e._callbacks[t],i=r.indexOf(n);i>=0?r.splice(i,1):console.warn(`callback ${t} does not exist.`)}else delete e._callbacks[t];else console.warn(`callback ${t} does not exist.`)},e.api.emit=(t,n)=>new Promise(async(r,i)=>{const o=[];try{if(e._callbacks[t])for(let r of e._callbacks[t])try{await r(void 0!==n?n:void 0)}catch(e){o.push(e),console.error(e)}else e._callbacks[t]=[],e._callbacks[t].emitted=!0,e._callbacks[t].emitted_data=n;o.length<=0?r():i(o)}catch(e){i(e)}}),e._refresh_callbacks=[],e.api.refresh=e.refresh=async()=>{await Promise.all(e._refresh_callbacks.map(e=>e()))},e._resize_callbacks=[],e.api.resize=e.resize=async t=>{t=t||e.$el&&e.$el.getBoundingClientRect(),e.api.emit("resize",t)},e.api.focus=e.focus=()=>{e.api.emit("focus")},e.api.show=e.show=()=>{this.selectWindow(e),e.api.emit("show")},e.api.hide=e.hide=()=>{e.api.emit("hide")},e.api.close=e.close=()=>new Promise(t=>{e.api.emit("close"),setTimeout(()=>{this.closeWindow(e),t()},800)})}addWindow(e){return new Promise((t,n)=>{try{e.id=e.id||e.name+Object(M.randId)(),e.dialog||this.generateGridPosition(e),e.standalone&&(e.h=0,e.w=0),this.window_ids[e.id]&&this.windows.splice(this.windows.indexOf(this.window_ids[e.id]),1),this.windows.push(e),this.window_ids[e.id]=e,this.setupCallbacks(e),this.selectWindow(e),this.event_bus.emit("add_window",e);let r=null,i=40;r=setInterval((function(){document.getElementById(e.window_id)&&(clearInterval(r),t(e.id)),i--<0&&(clearInterval(r),n(`Failed to create window (element with id=${e.window_id} not detected in 2s).`))}),50),e.__test__mode__&&e.api.emit("ready")}catch(e){n(e)}})}selectWindow(e){if(e){if(e.dialog)e.selected=!0,this.active_windows=[e];else{for(let e=0;e<this.active_windows.length;e++)this.active_windows[e]&&(this.active_windows[e].selected=!1,this.active_windows[e].refresh());"single"===this.window_mode||e.standalone?this.selected_window=e:this.selected_window=null,this.active_windows=[e],!e.standalone&&e.focus&&e.focus()}e.selected=!0,e.refresh&&e.refresh()}}resizeAll(){for(var e=this.windows.length;e--;)try{this.windows[e].resize()}catch(e){}}closeAll(){const e=this.default_window_pos&&this.default_window_pos.index||0;this.default_window_pos={i:0,x:0,y:0,w:20,h:10,index:e},this.status_text="";for(var t=this.windows.length;t--;)"imjoy/plugin-editor"!=this.windows[t].type&&this.windows[t].close();0===this.windows.length&&(this.default_window_pos.index=0)}destroy(){this.disconnect()}}async function ge(e,t){const n=await h.a.get(e);if(!n||200!=n.status||!n.data)throw"Faild to fetch code from "+e;{const e=n.data;t.define=null,_e(e,t)}}function _e(e,t){var n=Object.keys(t),r=n.map((function(e){return t[e]}));return Function(n.join(", "),e).apply(void 0,r)}var ye=async function(e,t){if("requirements"==e.type){if(e.requirements&&(Array.isArray(e.requirements)||"string"==typeof e.requirements))try{if(e.requirements="string"==typeof e.requirements?[e.requirements]:e.requirements,!Array.isArray(e.requirements))throw"Unsupported requirements definition";for(var n=0;n<e.requirements.length;n++)e.requirements[n].toLowerCase().endsWith(".js")||e.requirements[n].startsWith("js:")?(e.requirements[n].startsWith("js:")&&(e.requirements[n]=e.requirements[n].slice(3)),await ge(e.requirements[n],{api:t})):e.requirements[n].startsWith("http")?await ge(e.requirements[n],{api:t}):e.requirements[n].startsWith("cache:")||console.log("Unprocessed requirements url: "+e.requirements[n])}catch(t){throw`Failed to import required scripts ${e.requirements}: ${t}`}}else{if("script"!==e.type)throw"unsupported code type.";if(e.src){var r=document.createElement("script");r.setAttribute("type",e.attrs.type),r.setAttribute("src",e.src),document.head.appendChild(r)}else if(!e.content||e.attrs.type&&"text/javascript"!==e.attrs.type){var i=document.createElement("script");i.setAttribute("type",e.attrs.type),i.appendChild(document.createTextNode(e.content)),document.body.appendChild(i)}else _e(e.content,{api:t})}};function ve(e){for(let t in e)if("function"==typeof e[t]){const n=e[t];"AsyncFunction"!==n.constructor.name&&(e[t]=function(...e){return Promise.resolve(n(...e))})}}const be={type:"engine",pluginType:"evil",icon:"😈",name:"imjoy engine",url:"https://imjoy.io",config:{},hide:!0,connect(){return this._disconnected=!1,!0},disconnect(){this._disconnected=!0},async startPlugin(e,t){if(this._disconnected)throw"engine is disconnected.";return new Promise(async(n,r)=>{(t=Object.assign({},t)).export=t=>{console.log(`plugin ${e.name} (id=${e.id}) initialized.`,Object.keys(t)),ve(t),n(t)};const i=t.register;t.register=e=>(ve(e),i(e));const o=t.on;t.on=(e,t)=>o(e,(function(...e){return Promise.resolve(t(...e))})),ve(t);try{await ye({type:"requirements",lang:e.lang,requirements:e.requirements,env:e.env},t);for(let n=0;n<e.scripts.length;n++)await ye({type:"script",content:e.scripts[n].content,lang:e.scripts[n].attrs.lang,attrs:e.scripts[n].attrs,src:e.scripts[n].attrs.src},t);await async function(e){if(e&&e.length>0)for(let t of e)if(t.startsWith("js:")&&(t=t.slice(3)),t.startsWith("css:")&&(t=t.slice(4)),t.startsWith("cache:")&&(t=t.slice(6)),t.startsWith("http"))try{await Object(M.cacheUrlInServiceWorker)(t)}catch(e){console.error(e)}}(e.requirements)}catch(e){r(e)}})},heartbeat:null};class we{constructor({event_bus:e=null,config_db:t=null,client_id:n=null,engine_selector:r=null}){this.event_bus=e,this.config_db=t,Object(M.assert)(this.event_bus),Object(M.assert)(this.config_db,"config database is not available"),this.client_id=n||Object(M.randId)(),this.engines=[],this.engine_factories=[],this.pm=null,this.engine_selector=r}setPluginManager(e){this.pm=e}async init(){this.register(be),this.event_bus.on("register",async({plugin:e,config:t})=>{try{if("engine-factory"===t.type){if(Object(M.assert)(e.config.flags&&e.config.flags.indexOf("engine-factory")>=0,"Please add `engine-factory` to `config.flags` before registering an engine factory."),!G(t)){const e=G.errors;throw console.error("Error occured registering engine factory",t,e),e}this.registerFactory(t),e.on("close",()=>{this.unregisterFactory(t)})}else if("engine"===t.type){if(Object(M.assert)(e.config.flags&&e.config.flags.indexOf("engine")>=0,"Please add `engine` to `config.flags` before registering an engine."),!Q(t)){const e=Q.errors;throw console.error("Error occured registering engine ",t,e),e}await this.register(t),e.on("close",()=>{this.unregister(t)})}}catch(n){throw this.pm.unregister(e,t),n}}),this.event_bus.on("unregister",async({config:e})=>{"engine"===e.type?this.unregister(e):"engine-factory"===e.type&&this.unregisterFactory(e)})}matchEngineByType(e){return this.engines.filter(t=>t.pluginType===e)}async findEngine(e){if(this.engine_selector)return await this.engine_selector(e,this.engines);const t=this.engines.filter(t=>e.type&&t.pluginType===e.type);if(!t||t.length<=0)return null;if("auto"===e.engine_mode){const e=t.filter(e=>e.connected);if(e.length<=0){try{const e=t[0];return await e.connect(),e.connected=!0,e}catch(e){console.error("Failed to connect",e)}return null}return e[e.length-1]}return t.filter(t=>t.name===e.engine_mode)[0]}getEngineByUrl(e){for(let t of this.engines)if(t.url===e)return t;return null}getEngineByName(e){for(let t of this.engines)if(t.name===e)return t;return null}async register(e){const t=Object.assign({},e);t.api=e,e&&e===be?"127.0.0.1"===window.location.hostname||"localhost"===window.location.hostname?t._is_evil=!1:t._is_evil=!0:t._is_evil=!1;for(let e=0;e<this.engines.length;e++)if(t.name&&this.engines[e].name===t.name)try{this.unregister(this.engines[e])}catch(e){console.error(e)}for(let e=0;e<this.engines.length;e++)if(t.url&&this.engines[e].url===t.url)try{this.unregister(this.engines[e])}catch(e){console.error(e)}t.connected=!1,t.engine_status=t.engine_status||{},t.getEngineConfig&&Promise.resolve(t.getEngineConfig()).then(e=>{t.engine_config=e});const n=()=>{t.connected?this.event_bus.emit("engine_connected",t):this.event_bus.emit("engine_disconnected",t)},r=async()=>{const e=await t.heartbeat();if(!t.connected&&e)t.connected=!0,n();else if(t.connected&&!e){t.connected=!1,n();for(let e of t._plugins)e.terminate()}else t.connected=e};t._plugins=[],t.registerPlugin=e=>{t._plugins.push(e)},this.engines.push(t),t.lazy_connection||(await t.connect(),t.connected=!0),n(),t.heartbeat&&(await r(),t.heartbeat_timer=setInterval(r,5e3))}async unregister(e){const t=e.url;if(!(e=this.getEngineByUrl(t)))return!1;const n=this.engines.indexOf(e);for(let t of e._plugins)t.terminate();return n>-1&&this.engines.splice(n,1),e.heartbeat_timer&&clearInterval(e.heartbeat_timer),await e.disconnect(),e.connected=!1,this.event_bus.emit("engine_disconnected",e),!0}registerFactory(e){const t=Object.assign({},e);t.api=e;for(let e=0;e<this.engine_factories.length;e++)if(this.engine_factories[e].name===t.name){this.engine_factories.splice(e,1);break}this.engine_factories.push(t)}unregisterFactory(e){if(!(e=this.getFactory(e.name)))return!1;const t=this.engine_factories.indexOf(e);return t>-1&&this.engine_factories.splice(t,1),!0}getFactory(e){for(let t of this.engine_factories)if(t.name===e)return t;return null}destroy(){for(let e of this.engines)this.unregister(e)}}class xe{constructor({event_bus:e=null,client_id:t=null}){this.event_bus=e,Object(M.assert)(this.event_bus),this.client_id=t||Object(M.randId)(),this.fileManagers=[],this.pm=null}setPluginManager(e){this.pm=e}async init(){this.event_bus.on("register",async({plugin:e,config:t})=>{if("file-manager"===t.type)try{if(Object(M.assert)(e.config.flags&&e.config.flags.indexOf("file-manager")>=0,"Please add `file-manager` to `config.flags` before registering a file manager."),!Z(t)){const e=Z.errors;throw console.error("Error occured registering file manager",t,e),e}await this.register(t),e.on("close",()=>{this.unregister(t)})}catch(e){throw this.pm.unregister(t),e}}),this.event_bus.on("register",async({config:e})=>{"file-manager"===e.type&&this.unregister(e)})}getFileManagerByName(e){for(let t of this.fileManagers)if(t.name===e)return t;return null}getFileManagerByUrl(e){for(let t of this.fileManagers)if(t.url===e)return t;return null}async register(e){const t=Object.assign({},e);t.api=e;for(let e=0;e<this.fileManagers.length;e++)if(this.fileManagers[e].name===t.name){this.fileManagers.splice(e,1);break}t.connected=!1;const n=async()=>{t.connected=await t.heartbeat()};await n(),t.heart_beat_timer=setInterval(n,1e4),this.fileManagers.push(t)}unregister(e){if(!(e=this.getFileManagerByUrl(e.url)))return!1;const t=this.fileManagers.indexOf(e);return t>-1&&this.fileManagers.splice(t,1),e.heart_beat_timer&&clearInterval(e.heart_beat_timer),!0}destroy(){for(let e of this.fileManagers)e.destroy()}}var ke=n(81),Ee=n.n(ke),je=n(10);const Ae=M;class De{constructor({name:e="ImJoy",imjoy_api:t=null,event_bus:n=null,client_id:r=null,config_db:i=null,default_base_frame:o=null,default_rpc_base_url:s=null,expose_api:c=!1,debug:u=!1,flags:l=[],engine_selector:h=null}){this.name=e,this.config_db=i||new a.a("imjoy_config",{revs_limit:2,auto_compaction:!0}),this.expose_api=c,this.event_bus=n||Ee.a.create(),this.client_id=r||"imjoy_web_"+Object(M.randId)(),this.imjoy_api=t||{},this.engine_selector=h,this.flags=l,this.em=new we({event_bus:this.event_bus,config_db:this.config_db,client_id:this.client_id,engine_selector:this.engine_selector}),this.wm=new me({event_bus:this.event_bus}),this.fm=new xe({event_bus:this.event_bus}),this.pm=new fe({event_bus:this.event_bus,config_db:this.config_db,engine_manager:this.em,window_manager:this.wm,file_manager:this.fm,imjoy_api:this.imjoy_api,default_base_frame:o,default_rpc_base_url:s,debug:u,flags:this.flags})}async init(){await this.fm.init(),await this.pm.init(),this.root_plugin=this.pm.root_plugin,this.root_plugin&&(this.api=this.pm.root_plugin.getBoundInterface());try{await this.pm.loadWorkspaceList()}catch(e){console.error(e),this.event_bus.emit("show_message","Failed to load the workspace list: "+e.toString())}try{await this.em.init(),console.log("Successfully initialized the engine manager.")}catch(e){console.error(e),this.event_bus.emit("show_message","Failed to initialize the engine manager: "+e.toString())}if(this.expose_api&&window.self!==window.top){const e=await B.imjoyRPC.setupRPC({name:this.name||"ImJoy"}),t={_id:"root",name:this.name||"ImJoy",type:"window",ui:null,tag:null,inputs:null,outputs:null,docs:"https://imjoy.io/docs/",attachments:[]},n=this.pm.imjoy_api,r={},i=new ce(t,n,null,!0);for(let e in n)if("function"==typeof n[e])r[e]=function(){return n[e].apply(n,[i].concat(Array.prototype.slice.call(arguments)))};else if("object"==typeof n[e]){r[e]={};for(let t in n[e])r[e][t]=function(){return n[e][t].apply(n,[i].concat(Array.prototype.slice.call(arguments)))}}r.setup=function(){e.log("ImJoy App loaded successfully.")};let o=!0;r.run=function(){if(!o)return n.run.apply(n,[i].concat(Array.prototype.slice.call(arguments)));o=!1},e.export(r)}}async start(e){e=e||{},await this.init(),e.workspace?(await this.pm.loadWorkspace(e.workspace),await this.pm.reloadPlugins()):await this.pm.reloadInternalPlugins(!0)}async destroy(){this.pm.destroy(),this.em.destroy()}}}])}));
//# sourceMappingURL=imjoy-core.min.js.map