1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2025-01-10 01:29:42 +00:00
8bitworkshop/gen/chunk-Q5ACPWUW.js

46 lines
224 KiB
JavaScript

import{a as cn,b as da,c as fl}from"./chunk-XWTSBLAW.js";import{a as Ps}from"./chunk-B2GOFULO.js";import{a as ks,b as As,c as dl}from"./chunk-MPSJCPTJ.js";import{D as ca,J as fa,l as K,u as Ts,v as Cs}from"./chunk-ARTNMEGN.js";import{A as Ir,E as bt,F as oa,G as Mr,H as ln,I as Es,J as la,T as ua,V as _s,a as Lt,b as oi,ba as un,ca as Ss,d as lt,da as li,e as sa,f as Je,g as Ae,k as bs,m as rn,n as nn,o as an,p as gr,q as ys,t as sn,w as xs,x as ws,y as on,z as ut}from"./chunk-RXF2JDJ3.js";import{c as ai,d as vs,e as si}from"./chunk-WAARL7ET.js";var pa=vs((Ds,ha)=>{(function(u){if(typeof Ds=="object"&&typeof ha!="undefined")ha.exports=u();else if(typeof define=="function"&&define.amd)define([],u);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=u()}})(function(){var u,t,r;return function a(l,d,g){function y(W,ae){if(!d[W]){if(!l[W]){var U=typeof ai=="function"&&ai;if(!ae&&U)return U(W,!0);if(b)return b(W,!0);var O=new Error("Cannot find module '"+W+"'");throw O.code="MODULE_NOT_FOUND",O}var B=d[W]={exports:{}};l[W][0].call(B.exports,function(oe){var Y=l[W][1][oe];return y(Y||oe)},B,B.exports,a,l,d,g)}return d[W].exports}for(var b=typeof ai=="function"&&ai,D=0;D<g.length;D++)y(g[D]);return y}({1:[function(a,l,d){(function(g){"use strict";var y=g.MutationObserver||g.WebKitMutationObserver,b;if(y){var D=0,W=new y(oe),ae=g.document.createTextNode("");W.observe(ae,{characterData:!0}),b=function(){ae.data=D=++D%2}}else if(!g.setImmediate&&typeof g.MessageChannel!="undefined"){var U=new g.MessageChannel;U.port1.onmessage=oe,b=function(){U.port2.postMessage(0)}}else"document"in g&&"onreadystatechange"in g.document.createElement("script")?b=function(){var ge=g.document.createElement("script");ge.onreadystatechange=function(){oe(),ge.onreadystatechange=null,ge.parentNode.removeChild(ge),ge=null},g.document.documentElement.appendChild(ge)}:b=function(){setTimeout(oe,0)};var O,B=[];function oe(){O=!0;for(var ge,Te,pe=B.length;pe;){for(Te=B,B=[],ge=-1;++ge<pe;)Te[ge]();pe=B.length}O=!1}l.exports=Y;function Y(ge){B.push(ge)===1&&!O&&b()}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(a,l,d){"use strict";var g=a(1);function y(){}var b={},D=["REJECTED"],W=["FULFILLED"],ae=["PENDING"];l.exports=U;function U(s){if(typeof s!="function")throw new TypeError("resolver must be a function");this.state=ae,this.queue=[],this.outcome=void 0,s!==y&&Y(this,s)}U.prototype.catch=function(s){return this.then(null,s)},U.prototype.then=function(s,se){if(typeof s!="function"&&this.state===W||typeof se!="function"&&this.state===D)return this;var X=new this.constructor(y);if(this.state!==ae){var Ce=this.state===W?s:se;B(X,Ce,this.outcome)}else this.queue.push(new O(X,s,se));return X};function O(s,se,X){this.promise=s,typeof se=="function"&&(this.onFulfilled=se,this.callFulfilled=this.otherCallFulfilled),typeof X=="function"&&(this.onRejected=X,this.callRejected=this.otherCallRejected)}O.prototype.callFulfilled=function(s){b.resolve(this.promise,s)},O.prototype.otherCallFulfilled=function(s){B(this.promise,this.onFulfilled,s)},O.prototype.callRejected=function(s){b.reject(this.promise,s)},O.prototype.otherCallRejected=function(s){B(this.promise,this.onRejected,s)};function B(s,se,X){g(function(){var Ce;try{Ce=se(X)}catch(je){return b.reject(s,je)}Ce===s?b.reject(s,new TypeError("Cannot resolve promise with itself")):b.resolve(s,Ce)})}b.resolve=function(s,se){var X=ge(oe,se);if(X.status==="error")return b.reject(s,X.value);var Ce=X.value;if(Ce)Y(s,Ce);else{s.state=W,s.outcome=se;for(var je=-1,Ke=s.queue.length;++je<Ke;)s.queue[je].callFulfilled(se)}return s},b.reject=function(s,se){s.state=D,s.outcome=se;for(var X=-1,Ce=s.queue.length;++X<Ce;)s.queue[X].callRejected(se);return s};function oe(s){var se=s&&s.then;if(s&&(typeof s=="object"||typeof s=="function")&&typeof se=="function")return function(){se.apply(s,arguments)}}function Y(s,se){var X=!1;function Ce(He){X||(X=!0,b.reject(s,He))}function je(He){X||(X=!0,b.resolve(s,He))}function Ke(){se(je,Ce)}var me=ge(Ke);me.status==="error"&&Ce(me.value)}function ge(s,se){var X={};try{X.value=s(se),X.status="success"}catch(Ce){X.status="error",X.value=Ce}return X}U.resolve=Te;function Te(s){return s instanceof this?s:b.resolve(new this(y),s)}U.reject=pe;function pe(s){var se=new this(y);return b.reject(se,s)}U.all=_e;function _e(s){var se=this;if(Object.prototype.toString.call(s)!=="[object Array]")return this.reject(new TypeError("must be an array"));var X=s.length,Ce=!1;if(!X)return this.resolve([]);for(var je=new Array(X),Ke=0,me=-1,He=new this(y);++me<X;)wt(s[me],me);return He;function wt(or,nt){se.resolve(or).then(lr,function(ct){Ce||(Ce=!0,b.reject(He,ct))});function lr(ct){je[nt]=ct,++Ke===X&&!Ce&&(Ce=!0,b.resolve(He,je))}}}U.race=$e;function $e(s){var se=this;if(Object.prototype.toString.call(s)!=="[object Array]")return this.reject(new TypeError("must be an array"));var X=s.length,Ce=!1;if(!X)return this.resolve([]);for(var je=-1,Ke=new this(y);++je<X;)me(s[je]);return Ke;function me(He){se.resolve(He).then(function(wt){Ce||(Ce=!0,b.resolve(Ke,wt))},function(wt){Ce||(Ce=!0,b.reject(Ke,wt))})}}},{"1":1}],3:[function(a,l,d){(function(g){"use strict";typeof g.Promise!="function"&&(g.Promise=a(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"2":2}],4:[function(a,l,d){"use strict";var g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function y(p,E){if(!(p instanceof E))throw new TypeError("Cannot call a class as a function")}function b(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(p){return}}var D=b();function W(){try{if(!D||!D.open)return!1;var p=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),E=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||E)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(m){return!1}}function ae(p,E){p=p||[],E=E||{};try{return new Blob(p,E)}catch(S){if(S.name!=="TypeError")throw S;for(var m=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,T=new m,k=0;k<p.length;k+=1)T.append(p[k]);return T.getBlob(E.type)}}typeof Promise=="undefined"&&a(3);var U=Promise;function O(p,E){E&&p.then(function(m){E(null,m)},function(m){E(m)})}function B(p,E,m){typeof E=="function"&&p.then(E),typeof m=="function"&&p.catch(m)}function oe(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function Y(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var ge="local-forage-detect-blob-support",Te=void 0,pe={},_e=Object.prototype.toString,$e="readonly",s="readwrite";function se(p){for(var E=p.length,m=new ArrayBuffer(E),T=new Uint8Array(m),k=0;k<E;k++)T[k]=p.charCodeAt(k);return m}function X(p){return new U(function(E){var m=p.transaction(ge,s),T=ae([""]);m.objectStore(ge).put(T,"key"),m.onabort=function(k){k.preventDefault(),k.stopPropagation(),E(!1)},m.oncomplete=function(){var k=navigator.userAgent.match(/Chrome\/(\d+)/),S=navigator.userAgent.match(/Edge\//);E(S||!k||parseInt(k[1],10)>=43)}}).catch(function(){return!1})}function Ce(p){return typeof Te=="boolean"?U.resolve(Te):X(p).then(function(E){return Te=E,Te})}function je(p){var E=pe[p.name],m={};m.promise=new U(function(T,k){m.resolve=T,m.reject=k}),E.deferredOperations.push(m),E.dbReady?E.dbReady=E.dbReady.then(function(){return m.promise}):E.dbReady=m.promise}function Ke(p){var E=pe[p.name],m=E.deferredOperations.pop();if(m)return m.resolve(),m.promise}function me(p,E){var m=pe[p.name],T=m.deferredOperations.pop();if(T)return T.reject(E),T.promise}function He(p,E){return new U(function(m,T){if(pe[p.name]=pe[p.name]||jr(),p.db)if(E)je(p),p.db.close();else return m(p.db);var k=[p.name];E&&k.push(p.version);var S=D.open.apply(D,k);E&&(S.onupgradeneeded=function(I){var j=S.result;try{j.createObjectStore(p.storeName),I.oldVersion<=1&&j.createObjectStore(ge)}catch(V){if(V.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+I.oldVersion+" to version "+I.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw V}}),S.onerror=function(I){I.preventDefault(),T(S.error)},S.onsuccess=function(){var I=S.result;I.onversionchange=function(j){j.target.close()},m(I),Ke(p)}})}function wt(p){return He(p,!1)}function or(p){return He(p,!0)}function nt(p,E){if(!p.db)return!0;var m=!p.db.objectStoreNames.contains(p.storeName),T=p.version<p.db.version,k=p.version>p.db.version;if(T&&(p.version!==E&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),k||m){if(m){var S=p.db.version+1;S>p.version&&(p.version=S)}return!0}return!1}function lr(p){return new U(function(E,m){var T=new FileReader;T.onerror=m,T.onloadend=function(k){var S=btoa(k.target.result||"");E({__local_forage_encoded_blob:!0,data:S,type:p.type})},T.readAsBinaryString(p)})}function ct(p){var E=se(atob(p.data));return ae([E],{type:p.type})}function Wr(p){return p&&p.__local_forage_encoded_blob}function Pi(p){var E=this,m=E._initReady().then(function(){var T=pe[E._dbInfo.name];if(T&&T.dbReady)return T.dbReady});return B(m,p,p),m}function ki(p){je(p);for(var E=pe[p.name],m=E.forages,T=0;T<m.length;T++){var k=m[T];k._dbInfo.db&&(k._dbInfo.db.close(),k._dbInfo.db=null)}return p.db=null,wt(p).then(function(S){return p.db=S,nt(p)?or(p):S}).then(function(S){p.db=E.db=S;for(var I=0;I<m.length;I++)m[I]._dbInfo.db=S}).catch(function(S){throw me(p,S),S})}function ft(p,E,m,T){T===void 0&&(T=1);try{var k=p.db.transaction(p.storeName,E);m(null,k)}catch(S){if(T>0&&(!p.db||S.name==="InvalidStateError"||S.name==="NotFoundError"))return U.resolve().then(function(){if(!p.db||S.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),or(p)}).then(function(){return ki(p).then(function(){ft(p,E,m,T-1)})}).catch(m);m(S)}}function jr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Ln(p){var E=this,m={db:null};if(p)for(var T in p)m[T]=p[T];var k=pe[m.name];k||(k=jr(),pe[m.name]=k),k.forages.push(E),E._initReady||(E._initReady=E.ready,E.ready=Pi);var S=[];function I(){return U.resolve()}for(var j=0;j<k.forages.length;j++){var V=k.forages[j];V!==E&&S.push(V._initReady().catch(I))}var G=k.forages.slice(0);return U.all(S).then(function(){return m.db=k.db,wt(m)}).then(function(H){return m.db=H,nt(m,E._defaultConfig.version)?or(m):H}).then(function(H){m.db=k.db=H,E._dbInfo=m;for(var ee=0;ee<G.length;ee++){var he=G[ee];he!==E&&(he._dbInfo.db=m.db,he._dbInfo.version=m.version)}})}function In(p,E){var m=this;p=oe(p);var T=new U(function(k,S){m.ready().then(function(){ft(m._dbInfo,$e,function(I,j){if(I)return S(I);try{var V=j.objectStore(m._dbInfo.storeName),G=V.get(p);G.onsuccess=function(){var H=G.result;H===void 0&&(H=null),Wr(H)&&(H=ct(H)),k(H)},G.onerror=function(){S(G.error)}}catch(H){S(H)}})}).catch(S)});return O(T,E),T}function Mn(p,E){var m=this,T=new U(function(k,S){m.ready().then(function(){ft(m._dbInfo,$e,function(I,j){if(I)return S(I);try{var V=j.objectStore(m._dbInfo.storeName),G=V.openCursor(),H=1;G.onsuccess=function(){var ee=G.result;if(ee){var he=ee.value;Wr(he)&&(he=ct(he));var Pe=p(he,ee.key,H++);Pe!==void 0?k(Pe):ee.continue()}else k()},G.onerror=function(){S(G.error)}}catch(ee){S(ee)}})}).catch(S)});return O(T,E),T}function Nn(p,E,m){var T=this;p=oe(p);var k=new U(function(S,I){var j;T.ready().then(function(){return j=T._dbInfo,_e.call(E)==="[object Blob]"?Ce(j.db).then(function(V){return V?E:lr(E)}):E}).then(function(V){ft(T._dbInfo,s,function(G,H){if(G)return I(G);try{var ee=H.objectStore(T._dbInfo.storeName);V===null&&(V=void 0);var he=ee.put(V,p);H.oncomplete=function(){V===void 0&&(V=null),S(V)},H.onabort=H.onerror=function(){var Pe=he.error?he.error:he.transaction.error;I(Pe)}}catch(Pe){I(Pe)}})}).catch(I)});return O(k,m),k}function Ai(p,E){var m=this;p=oe(p);var T=new U(function(k,S){m.ready().then(function(){ft(m._dbInfo,s,function(I,j){if(I)return S(I);try{var V=j.objectStore(m._dbInfo.storeName),G=V.delete(p);j.oncomplete=function(){k()},j.onerror=function(){S(G.error)},j.onabort=function(){var H=G.error?G.error:G.transaction.error;S(H)}}catch(H){S(H)}})}).catch(S)});return O(T,E),T}function pt(p){var E=this,m=new U(function(T,k){E.ready().then(function(){ft(E._dbInfo,s,function(S,I){if(S)return k(S);try{var j=I.objectStore(E._dbInfo.storeName),V=j.clear();I.oncomplete=function(){T()},I.onabort=I.onerror=function(){var G=V.error?V.error:V.transaction.error;k(G)}}catch(G){k(G)}})}).catch(k)});return O(m,p),m}function On(p){var E=this,m=new U(function(T,k){E.ready().then(function(){ft(E._dbInfo,$e,function(S,I){if(S)return k(S);try{var j=I.objectStore(E._dbInfo.storeName),V=j.count();V.onsuccess=function(){T(V.result)},V.onerror=function(){k(V.error)}}catch(G){k(G)}})}).catch(k)});return O(m,p),m}function Gt(p,E){var m=this,T=new U(function(k,S){if(p<0){k(null);return}m.ready().then(function(){ft(m._dbInfo,$e,function(I,j){if(I)return S(I);try{var V=j.objectStore(m._dbInfo.storeName),G=!1,H=V.openKeyCursor();H.onsuccess=function(){var ee=H.result;if(!ee){k(null);return}p===0||G?k(ee.key):(G=!0,ee.advance(p))},H.onerror=function(){S(H.error)}}catch(ee){S(ee)}})}).catch(S)});return O(T,E),T}function Tr(p){var E=this,m=new U(function(T,k){E.ready().then(function(){ft(E._dbInfo,$e,function(S,I){if(S)return k(S);try{var j=I.objectStore(E._dbInfo.storeName),V=j.openKeyCursor(),G=[];V.onsuccess=function(){var H=V.result;if(!H){T(G);return}G.push(H.key),H.continue()},V.onerror=function(){k(V.error)}}catch(H){k(H)}})}).catch(k)});return O(m,p),m}function Di(p,E){E=Y.apply(this,arguments);var m=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||m.name,p.storeName=p.storeName||m.storeName);var T=this,k;if(!p.name)k=U.reject("Invalid arguments");else{var S=p.name===m.name&&T._dbInfo.db,I=S?U.resolve(T._dbInfo.db):wt(p).then(function(j){var V=pe[p.name],G=V.forages;V.db=j;for(var H=0;H<G.length;H++)G[H]._dbInfo.db=j;return j});p.storeName?k=I.then(function(j){if(!!j.objectStoreNames.contains(p.storeName)){var V=j.version+1;je(p);var G=pe[p.name],H=G.forages;j.close();for(var ee=0;ee<H.length;ee++){var he=H[ee];he._dbInfo.db=null,he._dbInfo.version=V}var Pe=new U(function(ke,Re){var De=D.open(p.name,V);De.onerror=function(Xe){var fr=De.result;fr.close(),Re(Xe)},De.onupgradeneeded=function(){var Xe=De.result;Xe.deleteObjectStore(p.storeName)},De.onsuccess=function(){var Xe=De.result;Xe.close(),ke(Xe)}});return Pe.then(function(ke){G.db=ke;for(var Re=0;Re<H.length;Re++){var De=H[Re];De._dbInfo.db=ke,Ke(De._dbInfo)}}).catch(function(ke){throw(me(p,ke)||U.resolve()).catch(function(){}),ke})}}):k=I.then(function(j){je(p);var V=pe[p.name],G=V.forages;j.close();for(var H=0;H<G.length;H++){var ee=G[H];ee._dbInfo.db=null}var he=new U(function(Pe,ke){var Re=D.deleteDatabase(p.name);Re.onerror=function(){var De=Re.result;De&&De.close(),ke(Re.error)},Re.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},Re.onsuccess=function(){var De=Re.result;De&&De.close(),Pe(De)}});return he.then(function(Pe){V.db=Pe;for(var ke=0;ke<G.length;ke++){var Re=G[ke];Ke(Re._dbInfo)}}).catch(function(Pe){throw(me(p,Pe)||U.resolve()).catch(function(){}),Pe})})}return O(k,E),k}var $n={_driver:"asyncStorage",_initStorage:Ln,_support:W(),iterate:Mn,getItem:In,setItem:Nn,removeItem:Ai,clear:pt,length:On,key:Gt,keys:Tr,dropInstance:Di};function Ur(){return typeof openDatabase=="function"}var dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et="~~local_forage_type~",Fi=/^~~local_forage_type~([^~]+)~/,Cr="__lfsc__:",Br=Cr.length,at="arbf",Nt="blob",qt="si08",te="ui08",Ve="uic8",Ri="si16",Li="si32",Ii="ur16",Hr="ui32",zr="fl32",Yt="fl64",gt=Br+at.length,Pt=Object.prototype.toString;function Ot(p){var E=p.length*.75,m=p.length,T,k=0,S,I,j,V;p[p.length-1]==="="&&(E--,p[p.length-2]==="="&&E--);var G=new ArrayBuffer(E),H=new Uint8Array(G);for(T=0;T<m;T+=4)S=dt.indexOf(p[T]),I=dt.indexOf(p[T+1]),j=dt.indexOf(p[T+2]),V=dt.indexOf(p[T+3]),H[k++]=S<<2|I>>4,H[k++]=(I&15)<<4|j>>2,H[k++]=(j&3)<<6|V&63;return G}function Vr(p){var E=new Uint8Array(p),m="",T;for(T=0;T<E.length;T+=3)m+=dt[E[T]>>2],m+=dt[(E[T]&3)<<4|E[T+1]>>4],m+=dt[(E[T+1]&15)<<2|E[T+2]>>6],m+=dt[E[T+2]&63];return E.length%3==2?m=m.substring(0,m.length-1)+"=":E.length%3==1&&(m=m.substring(0,m.length-2)+"=="),m}function Pr(p,E){var m="";if(p&&(m=Pt.call(p)),p&&(m==="[object ArrayBuffer]"||p.buffer&&Pt.call(p.buffer)==="[object ArrayBuffer]")){var T,k=Cr;p instanceof ArrayBuffer?(T=p,k+=at):(T=p.buffer,m==="[object Int8Array]"?k+=qt:m==="[object Uint8Array]"?k+=te:m==="[object Uint8ClampedArray]"?k+=Ve:m==="[object Int16Array]"?k+=Ri:m==="[object Uint16Array]"?k+=Ii:m==="[object Int32Array]"?k+=Li:m==="[object Uint32Array]"?k+=Hr:m==="[object Float32Array]"?k+=zr:m==="[object Float64Array]"?k+=Yt:E(new Error("Failed to get type for BinaryArray"))),E(k+Vr(T))}else if(m==="[object Blob]"){var S=new FileReader;S.onload=function(){var I=Et+p.type+"~"+Vr(this.result);E(Cr+Nt+I)},S.readAsArrayBuffer(p)}else try{E(JSON.stringify(p))}catch(I){console.error("Couldn't convert value into a JSON string: ",p),E(null,I)}}function Mi(p){if(p.substring(0,Br)!==Cr)return JSON.parse(p);var E=p.substring(gt),m=p.substring(Br,gt),T;if(m===Nt&&Fi.test(E)){var k=E.match(Fi);T=k[1],E=E.substring(k[0].length)}var S=Ot(E);switch(m){case at:return S;case Nt:return ae([S],{type:T});case qt:return new Int8Array(S);case te:return new Uint8Array(S);case Ve:return new Uint8ClampedArray(S);case Ri:return new Int16Array(S);case Ii:return new Uint16Array(S);case Li:return new Int32Array(S);case Hr:return new Uint32Array(S);case zr:return new Float32Array(S);case Yt:return new Float64Array(S);default:throw new Error("Unkown type: "+m)}}var kr={serialize:Pr,deserialize:Mi,stringToBuffer:Ot,bufferToString:Vr};function Ni(p,E,m,T){p.executeSql("CREATE TABLE IF NOT EXISTS "+E.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],m,T)}function Xt(p){var E=this,m={db:null};if(p)for(var T in p)m[T]=typeof p[T]!="string"?p[T].toString():p[T];var k=new U(function(S,I){try{m.db=openDatabase(m.name,String(m.version),m.description,m.size)}catch(j){return I(j)}m.db.transaction(function(j){Ni(j,m,function(){E._dbInfo=m,S()},function(V,G){I(G)})},I)});return m.serializer=kr,k}function st(p,E,m,T,k,S){p.executeSql(m,T,k,function(I,j){j.code===j.SYNTAX_ERR?I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[E.storeName],function(V,G){G.rows.length?S(V,j):Ni(V,E,function(){V.executeSql(m,T,k,S)},S)},S):S(I,j)},S)}function Oi(p,E){var m=this;p=oe(p);var T=new U(function(k,S){m.ready().then(function(){var I=m._dbInfo;I.db.transaction(function(j){st(j,I,"SELECT * FROM "+I.storeName+" WHERE key = ? LIMIT 1",[p],function(V,G){var H=G.rows.length?G.rows.item(0).value:null;H&&(H=I.serializer.deserialize(H)),k(H)},function(V,G){S(G)})})}).catch(S)});return O(T,E),T}function $i(p,E){var m=this,T=new U(function(k,S){m.ready().then(function(){var I=m._dbInfo;I.db.transaction(function(j){st(j,I,"SELECT * FROM "+I.storeName,[],function(V,G){for(var H=G.rows,ee=H.length,he=0;he<ee;he++){var Pe=H.item(he),ke=Pe.value;if(ke&&(ke=I.serializer.deserialize(ke)),ke=p(ke,Pe.key,he+1),ke!==void 0){k(ke);return}}k()},function(V,G){S(G)})})}).catch(S)});return O(T,E),T}function Ze(p,E,m,T){var k=this;p=oe(p);var S=new U(function(I,j){k.ready().then(function(){E===void 0&&(E=null);var V=E,G=k._dbInfo;G.serializer.serialize(E,function(H,ee){ee?j(ee):G.db.transaction(function(he){st(he,G,"INSERT OR REPLACE INTO "+G.storeName+" (key, value) VALUES (?, ?)",[p,H],function(){I(V)},function(Pe,ke){j(ke)})},function(he){if(he.code===he.QUOTA_ERR){if(T>0){I(Ze.apply(k,[p,V,m,T-1]));return}j(he)}})})}).catch(j)});return O(S,m),S}function qe(p,E,m){return Ze.apply(this,[p,E,m,1])}function Gr(p,E){var m=this;p=oe(p);var T=new U(function(k,S){m.ready().then(function(){var I=m._dbInfo;I.db.transaction(function(j){st(j,I,"DELETE FROM "+I.storeName+" WHERE key = ?",[p],function(){k()},function(V,G){S(G)})})}).catch(S)});return O(T,E),T}function Wn(p){var E=this,m=new U(function(T,k){E.ready().then(function(){var S=E._dbInfo;S.db.transaction(function(I){st(I,S,"DELETE FROM "+S.storeName,[],function(){T()},function(j,V){k(V)})})}).catch(k)});return O(m,p),m}function Wi(p){var E=this,m=new U(function(T,k){E.ready().then(function(){var S=E._dbInfo;S.db.transaction(function(I){st(I,S,"SELECT COUNT(key) as c FROM "+S.storeName,[],function(j,V){var G=V.rows.item(0).c;T(G)},function(j,V){k(V)})})}).catch(k)});return O(m,p),m}function ji(p,E){var m=this,T=new U(function(k,S){m.ready().then(function(){var I=m._dbInfo;I.db.transaction(function(j){st(j,I,"SELECT key FROM "+I.storeName+" WHERE id = ? LIMIT 1",[p+1],function(V,G){var H=G.rows.length?G.rows.item(0).key:null;k(H)},function(V,G){S(G)})})}).catch(S)});return O(T,E),T}function Qt(p){var E=this,m=new U(function(T,k){E.ready().then(function(){var S=E._dbInfo;S.db.transaction(function(I){st(I,S,"SELECT key FROM "+S.storeName,[],function(j,V){for(var G=[],H=0;H<V.rows.length;H++)G.push(V.rows.item(H).key);T(G)},function(j,V){k(V)})})}).catch(k)});return O(m,p),m}function Jt(p){return new U(function(E,m){p.transaction(function(T){T.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(k,S){for(var I=[],j=0;j<S.rows.length;j++)I.push(S.rows.item(j).name);E({db:p,storeNames:I})},function(k,S){m(S)})},function(T){m(T)})})}function qr(p,E){E=Y.apply(this,arguments);var m=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||m.name,p.storeName=p.storeName||m.storeName);var T=this,k;return p.name?k=new U(function(S){var I;p.name===m.name?I=T._dbInfo.db:I=openDatabase(p.name,"","",0),p.storeName?S({db:I,storeNames:[p.storeName]}):S(Jt(I))}).then(function(S){return new U(function(I,j){S.db.transaction(function(V){function G(Pe){return new U(function(ke,Re){V.executeSql("DROP TABLE IF EXISTS "+Pe,[],function(){ke()},function(De,Xe){Re(Xe)})})}for(var H=[],ee=0,he=S.storeNames.length;ee<he;ee++)H.push(G(S.storeNames[ee]));U.all(H).then(function(){I()}).catch(function(Pe){j(Pe)})},function(V){j(V)})})}):k=U.reject("Invalid arguments"),O(k,E),k}var Ar={_driver:"webSQLStorage",_initStorage:Xt,_support:Ur(),iterate:$i,getItem:Oi,setItem:qe,removeItem:Gr,clear:Wn,length:Wi,key:ji,keys:Qt,dropInstance:qr};function jn(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(p){return!1}}function Ui(p,E){var m=p.name+"/";return p.storeName!==E.storeName&&(m+=p.storeName+"/"),m}function Un(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch(E){return!0}}function Bi(){return!Un()||localStorage.length>0}function Bn(p){var E=this,m={};if(p)for(var T in p)m[T]=p[T];return m.keyPrefix=Ui(p,E._defaultConfig),Bi()?(E._dbInfo=m,m.serializer=kr,U.resolve()):U.reject()}function Hn(p){var E=this,m=E.ready().then(function(){for(var T=E._dbInfo.keyPrefix,k=localStorage.length-1;k>=0;k--){var S=localStorage.key(k);S.indexOf(T)===0&&localStorage.removeItem(S)}});return O(m,p),m}function Hi(p,E){var m=this;p=oe(p);var T=m.ready().then(function(){var k=m._dbInfo,S=localStorage.getItem(k.keyPrefix+p);return S&&(S=k.serializer.deserialize(S)),S});return O(T,E),T}function zn(p,E){var m=this,T=m.ready().then(function(){for(var k=m._dbInfo,S=k.keyPrefix,I=S.length,j=localStorage.length,V=1,G=0;G<j;G++){var H=localStorage.key(G);if(H.indexOf(S)===0){var ee=localStorage.getItem(H);if(ee&&(ee=k.serializer.deserialize(ee)),ee=p(ee,H.substring(I),V++),ee!==void 0)return ee}}});return O(T,E),T}function Kt(p,E){var m=this,T=m.ready().then(function(){var k=m._dbInfo,S;try{S=localStorage.key(p)}catch(I){S=null}return S&&(S=S.substring(k.keyPrefix.length)),S});return O(T,E),T}function zi(p){var E=this,m=E.ready().then(function(){for(var T=E._dbInfo,k=localStorage.length,S=[],I=0;I<k;I++){var j=localStorage.key(I);j.indexOf(T.keyPrefix)===0&&S.push(j.substring(T.keyPrefix.length))}return S});return O(m,p),m}function Yr(p){var E=this,m=E.keys().then(function(T){return T.length});return O(m,p),m}function Xr(p,E){var m=this;p=oe(p);var T=m.ready().then(function(){var k=m._dbInfo;localStorage.removeItem(k.keyPrefix+p)});return O(T,E),T}function Dr(p,E,m){var T=this;p=oe(p);var k=T.ready().then(function(){E===void 0&&(E=null);var S=E;return new U(function(I,j){var V=T._dbInfo;V.serializer.serialize(E,function(G,H){if(H)j(H);else try{localStorage.setItem(V.keyPrefix+p,G),I(S)}catch(ee){(ee.name==="QuotaExceededError"||ee.name==="NS_ERROR_DOM_QUOTA_REACHED")&&j(ee),j(ee)}})})});return O(k,m),k}function Vi(p,E){if(E=Y.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var m=this.config();p.name=p.name||m.name,p.storeName=p.storeName||m.storeName}var T=this,k;return p.name?k=new U(function(S){p.storeName?S(Ui(p,T._defaultConfig)):S(p.name+"/")}).then(function(S){for(var I=localStorage.length-1;I>=0;I--){var j=localStorage.key(I);j.indexOf(S)===0&&localStorage.removeItem(j)}}):k=U.reject("Invalid arguments"),O(k,E),k}var Vn={_driver:"localStorageWrapper",_initStorage:Bn,_support:jn(),iterate:zn,getItem:Hi,setItem:Dr,removeItem:Xr,clear:Hn,length:Yr,key:Kt,keys:zi,dropInstance:Vi},ur=function(E,m){return E===m||typeof E=="number"&&typeof m=="number"&&isNaN(E)&&isNaN(m)},Gi=function(E,m){for(var T=E.length,k=0;k<T;){if(ur(E[k],m))return!0;k++}return!1},Qr=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Zt={},Jr={},er={INDEXEDDB:$n,WEBSQL:Ar,LOCALSTORAGE:Vn},Kr=[er.INDEXEDDB._driver,er.WEBSQL._driver,er.LOCALSTORAGE._driver],Fr=["dropInstance"],Zr=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Fr),qi={description:"",driver:Kr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Yi(p,E){p[E]=function(){var m=arguments;return p.ready().then(function(){return p[E].apply(p,m)})}}function cr(){for(var p=1;p<arguments.length;p++){var E=arguments[p];if(E)for(var m in E)E.hasOwnProperty(m)&&(Qr(E[m])?arguments[0][m]=E[m].slice():arguments[0][m]=E[m])}return arguments[0]}var Xi=function(){function p(E){y(this,p);for(var m in er)if(er.hasOwnProperty(m)){var T=er[m],k=T._driver;this[m]=k,Zt[k]||this.defineDriver(T)}this._defaultConfig=cr({},qi),this._config=cr({},this._defaultConfig,E),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(m){if((typeof m=="undefined"?"undefined":g(m))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var T in m){if(T==="storeName"&&(m[T]=m[T].replace(/\W/g,"_")),T==="version"&&typeof m[T]!="number")return new Error("Database version must be a number.");this._config[T]=m[T]}return"driver"in m&&m.driver?this.setDriver(this._config.driver):!0}else return typeof m=="string"?this._config[m]:this._config},p.prototype.defineDriver=function(m,T,k){var S=new U(function(I,j){try{var V=m._driver,G=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){j(G);return}for(var H=Zr.concat("_initStorage"),ee=0,he=H.length;ee<he;ee++){var Pe=H[ee],ke=!Gi(Fr,Pe);if((ke||m[Pe])&&typeof m[Pe]!="function"){j(G);return}}var Re=function(){for(var fr=function(Ji){return function(){var qn=new Error("Method "+Ji+" is not implemented by the current driver"),ei=U.reject(qn);return O(ei,arguments[arguments.length-1]),ei}},$t=0,Qi=Fr.length;$t<Qi;$t++){var dr=Fr[$t];m[dr]||(m[dr]=fr(dr))}};Re();var De=function(fr){Zt[V]&&console.info("Redefining LocalForage driver: "+V),Zt[V]=m,Jr[V]=fr,I()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(De,j):De(!!m._support):De(!0)}catch(Xe){j(Xe)}});return B(S,T,k),S},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(m,T,k){var S=Zt[m]?U.resolve(Zt[m]):U.reject(new Error("Driver not found."));return B(S,T,k),S},p.prototype.getSerializer=function(m){var T=U.resolve(kr);return B(T,m),T},p.prototype.ready=function(m){var T=this,k=T._driverSet.then(function(){return T._ready===null&&(T._ready=T._initDriver()),T._ready});return B(k,m,m),k},p.prototype.setDriver=function(m,T,k){var S=this;Qr(m)||(m=[m]);var I=this._getSupportedDrivers(m);function j(){S._config.driver=S.driver()}function V(ee){return S._extend(ee),j(),S._ready=S._initStorage(S._config),S._ready}function G(ee){return function(){var he=0;function Pe(){for(;he<ee.length;){var ke=ee[he];return he++,S._dbInfo=null,S._ready=null,S.getDriver(ke).then(V).catch(Pe)}j();var Re=new Error("No available storage method found.");return S._driverSet=U.reject(Re),S._driverSet}return Pe()}}var H=this._driverSet!==null?this._driverSet.catch(function(){return U.resolve()}):U.resolve();return this._driverSet=H.then(function(){var ee=I[0];return S._dbInfo=null,S._ready=null,S.getDriver(ee).then(function(he){S._driver=he._driver,j(),S._wrapLibraryMethodsWithReady(),S._initDriver=G(I)})}).catch(function(){j();var ee=new Error("No available storage method found.");return S._driverSet=U.reject(ee),S._driverSet}),B(this._driverSet,T,k),this._driverSet},p.prototype.supports=function(m){return!!Jr[m]},p.prototype._extend=function(m){cr(this,m)},p.prototype._getSupportedDrivers=function(m){for(var T=[],k=0,S=m.length;k<S;k++){var I=m[k];this.supports(I)&&T.push(I)}return T},p.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,T=Zr.length;m<T;m++)Yi(this,Zr[m])},p.prototype.createInstance=function(m){return new p(m)},p}(),Ye=new Xi;l.exports=Ye},{"3":3}]},{},[4])(4)})});var Ms=vs((Is,hn)=>{(function(u,t){"use strict";typeof hn=="object"&&typeof hn.exports=="object"?hn.exports=u.document?t(u,!0):function(r){if(!r.document)throw new Error("jQuery requires a window with a document");return t(r)}:t(u)})(typeof window!="undefined"?window:Is,function(u,t){"use strict";var r=[],a=Object.getPrototypeOf,l=r.slice,d=r.flat?function(e){return r.flat.call(e)}:function(e){return r.concat.apply([],e)},g=r.push,y=r.indexOf,b={},D=b.toString,W=b.hasOwnProperty,ae=W.toString,U=ae.call(Object),O={},B=function(i){return typeof i=="function"&&typeof i.nodeType!="number"&&typeof i.item!="function"},oe=function(i){return i!=null&&i===i.window},Y=u.document,ge={type:!0,src:!0,nonce:!0,noModule:!0};function Te(e,i,n){n=n||Y;var o,c,f=n.createElement("script");if(f.text=e,i)for(o in ge)c=i[o]||i.getAttribute&&i.getAttribute(o),c&&f.setAttribute(o,c);n.head.appendChild(f).parentNode.removeChild(f)}function pe(e){return e==null?e+"":typeof e=="object"||typeof e=="function"?b[D.call(e)]||"object":typeof e}var _e="3.7.1",$e=/HTML$/i,s=function(e,i){return new s.fn.init(e,i)};s.fn=s.prototype={jquery:_e,constructor:s,length:0,toArray:function(){return l.call(this)},get:function(e){return e==null?l.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var i=s.merge(this.constructor(),e);return i.prevObject=this,i},each:function(e){return s.each(this,e)},map:function(e){return this.pushStack(s.map(this,function(i,n){return e.call(i,n,i)}))},slice:function(){return this.pushStack(l.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(s.grep(this,function(e,i){return(i+1)%2}))},odd:function(){return this.pushStack(s.grep(this,function(e,i){return i%2}))},eq:function(e){var i=this.length,n=+e+(e<0?i:0);return this.pushStack(n>=0&&n<i?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:r.sort,splice:r.splice},s.extend=s.fn.extend=function(){var e,i,n,o,c,f,h=arguments[0]||{},w=1,x=arguments.length,C=!1;for(typeof h=="boolean"&&(C=h,h=arguments[w]||{},w++),typeof h!="object"&&!B(h)&&(h={}),w===x&&(h=this,w--);w<x;w++)if((e=arguments[w])!=null)for(i in e)o=e[i],!(i==="__proto__"||h===o)&&(C&&o&&(s.isPlainObject(o)||(c=Array.isArray(o)))?(n=h[i],c&&!Array.isArray(n)?f=[]:!c&&!s.isPlainObject(n)?f={}:f=n,c=!1,h[i]=s.extend(C,f,o)):o!==void 0&&(h[i]=o));return h},s.extend({expando:"jQuery"+(_e+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var i,n;return!e||D.call(e)!=="[object Object]"?!1:(i=a(e),i?(n=W.call(i,"constructor")&&i.constructor,typeof n=="function"&&ae.call(n)===U):!0)},isEmptyObject:function(e){var i;for(i in e)return!1;return!0},globalEval:function(e,i,n){Te(e,{nonce:i&&i.nonce},n)},each:function(e,i){var n,o=0;if(se(e))for(n=e.length;o<n&&i.call(e[o],o,e[o])!==!1;o++);else for(o in e)if(i.call(e[o],o,e[o])===!1)break;return e},text:function(e){var i,n="",o=0,c=e.nodeType;if(!c)for(;i=e[o++];)n+=s.text(i);return c===1||c===11?e.textContent:c===9?e.documentElement.textContent:c===3||c===4?e.nodeValue:n},makeArray:function(e,i){var n=i||[];return e!=null&&(se(Object(e))?s.merge(n,typeof e=="string"?[e]:e):g.call(n,e)),n},inArray:function(e,i,n){return i==null?-1:y.call(i,e,n)},isXMLDoc:function(e){var i=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!$e.test(i||n&&n.nodeName||"HTML")},merge:function(e,i){for(var n=+i.length,o=0,c=e.length;o<n;o++)e[c++]=i[o];return e.length=c,e},grep:function(e,i,n){for(var o,c=[],f=0,h=e.length,w=!n;f<h;f++)o=!i(e[f],f),o!==w&&c.push(e[f]);return c},map:function(e,i,n){var o,c,f=0,h=[];if(se(e))for(o=e.length;f<o;f++)c=i(e[f],f,n),c!=null&&h.push(c);else for(f in e)c=i(e[f],f,n),c!=null&&h.push(c);return d(h)},guid:1,support:O}),typeof Symbol=="function"&&(s.fn[Symbol.iterator]=r[Symbol.iterator]),s.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,i){b["[object "+i+"]"]=i.toLowerCase()});function se(e){var i=!!e&&"length"in e&&e.length,n=pe(e);return B(e)||oe(e)?!1:n==="array"||i===0||typeof i=="number"&&i>0&&i-1 in e}function X(e,i){return e.nodeName&&e.nodeName.toLowerCase()===i.toLowerCase()}var Ce=r.pop,je=r.sort,Ke=r.splice,me="[\\x20\\t\\r\\n\\f]",He=new RegExp("^"+me+"+|((?:^|[^\\\\])(?:\\\\.)*)"+me+"+$","g");s.contains=function(e,i){var n=i&&i.parentNode;return e===n||!!(n&&n.nodeType===1&&(e.contains?e.contains(n):e.compareDocumentPosition&&e.compareDocumentPosition(n)&16))};var wt=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function or(e,i){return i?e==="\0"?"\uFFFD":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e}s.escapeSelector=function(e){return(e+"").replace(wt,or)};var nt=Y,lr=g;(function(){var e,i,n,o,c,f=lr,h,w,x,C,L,N=s.expando,F=0,z=0,ce=Ki(),Ee=Ki(),ve=Ki(),Ge=Ki(),Ue=function(v,_){return v===_&&(c=!0),0},kt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",At="(?:\\\\[\\da-fA-F]{1,6}"+me+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",we="\\["+me+"*("+At+")(?:"+me+"*([*^$|!~]?=)"+me+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+At+"))|)"+me+"*\\]",hr=":("+At+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+we+")*)|.*)\\)|)",Se=new RegExp(me+"+","g"),Me=new RegExp("^"+me+"*,"+me+"*"),ri=new RegExp("^"+me+"*([>+~]|"+me+")"+me+"*"),Zn=new RegExp(me+"|>"),Dt=new RegExp(hr),ii=new RegExp("^"+At+"$"),Ft={ID:new RegExp("^#("+At+")"),CLASS:new RegExp("^\\.("+At+")"),TAG:new RegExp("^("+At+"|[*])"),ATTR:new RegExp("^"+we),PSEUDO:new RegExp("^"+hr),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+me+"*(even|odd|(([+-]|)(\\d*)n|)"+me+"*(?:([+-]|)"+me+"*(\\d+)|))"+me+"*\\)|)","i"),bool:new RegExp("^(?:"+kt+")$","i"),needsContext:new RegExp("^"+me+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+me+"*((?:-\\d)?\\d*)"+me+"*\\)|)(?=[^-]|$)","i")},tr=/^(?:input|select|textarea|button)$/i,rr=/^h\d$/i,mt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ea=/[+~]/,Wt=new RegExp("\\\\[\\da-fA-F]{1,6}"+me+"?|\\\\([^\\r\\n\\f])","g"),jt=function(v,_){var A="0x"+v.slice(1)-65536;return _||(A<0?String.fromCharCode(A+65536):String.fromCharCode(A>>10|55296,A&1023|56320))},nl=function(){ir()},al=en(function(v){return v.disabled===!0&&X(v,"fieldset")},{dir:"parentNode",next:"legend"});function sl(){try{return h.activeElement}catch(v){}}try{f.apply(r=l.call(nt.childNodes),nt.childNodes),r[nt.childNodes.length].nodeType}catch(v){f={apply:function(_,A){lr.apply(_,l.call(A))},call:function(_){lr.apply(_,l.call(arguments,1))}}}function Fe(v,_,A,R){var M,q,Q,re,J,ye,le,fe=_&&_.ownerDocument,xe=_?_.nodeType:9;if(A=A||[],typeof v!="string"||!v||xe!==1&&xe!==9&&xe!==11)return A;if(!R&&(ir(_),_=_||h,x)){if(xe!==11&&(J=mt.exec(v)))if(M=J[1]){if(xe===9)if(Q=_.getElementById(M)){if(Q.id===M)return f.call(A,Q),A}else return A;else if(fe&&(Q=fe.getElementById(M))&&Fe.contains(_,Q)&&Q.id===M)return f.call(A,Q),A}else{if(J[2])return f.apply(A,_.getElementsByTagName(v)),A;if((M=J[3])&&_.getElementsByClassName)return f.apply(A,_.getElementsByClassName(M)),A}if(!Ge[v+" "]&&(!C||!C.test(v))){if(le=v,fe=_,xe===1&&(Zn.test(v)||ri.test(v))){for(fe=ea.test(v)&&ta(_.parentNode)||_,(fe!=_||!O.scope)&&((re=_.getAttribute("id"))?re=s.escapeSelector(re):_.setAttribute("id",re=N)),ye=ni(v),q=ye.length;q--;)ye[q]=(re?"#"+re:":scope")+" "+Zi(ye[q]);le=ye.join(",")}try{return f.apply(A,fe.querySelectorAll(le)),A}catch(ne){Ge(v,!0)}finally{re===N&&_.removeAttribute("id")}}}return ms(v.replace(He,"$1"),_,A,R)}function Ki(){var v=[];function _(A,R){return v.push(A+" ")>i.cacheLength&&delete _[v.shift()],_[A+" "]=R}return _}function _t(v){return v[N]=!0,v}function Rr(v){var _=h.createElement("fieldset");try{return!!v(_)}catch(A){return!1}finally{_.parentNode&&_.parentNode.removeChild(_),_=null}}function ol(v){return function(_){return X(_,"input")&&_.type===v}}function ll(v){return function(_){return(X(_,"input")||X(_,"button"))&&_.type===v}}function ps(v){return function(_){return"form"in _?_.parentNode&&_.disabled===!1?"label"in _?"label"in _.parentNode?_.parentNode.disabled===v:_.disabled===v:_.isDisabled===v||_.isDisabled!==!v&&al(_)===v:_.disabled===v:"label"in _?_.disabled===v:!1}}function pr(v){return _t(function(_){return _=+_,_t(function(A,R){for(var M,q=v([],A.length,_),Q=q.length;Q--;)A[M=q[Q]]&&(A[M]=!(R[M]=A[M]))})})}function ta(v){return v&&typeof v.getElementsByTagName!="undefined"&&v}function ir(v){var _,A=v?v.ownerDocument||v:nt;return A==h||A.nodeType!==9||!A.documentElement||(h=A,w=h.documentElement,x=!s.isXMLDoc(h),L=w.matches||w.webkitMatchesSelector||w.msMatchesSelector,w.msMatchesSelector&&nt!=h&&(_=h.defaultView)&&_.top!==_&&_.addEventListener("unload",nl),O.getById=Rr(function(R){return w.appendChild(R).id=s.expando,!h.getElementsByName||!h.getElementsByName(s.expando).length}),O.disconnectedMatch=Rr(function(R){return L.call(R,"*")}),O.scope=Rr(function(){return h.querySelectorAll(":scope")}),O.cssHas=Rr(function(){try{return h.querySelector(":has(*,:jqfake)"),!1}catch(R){return!0}}),O.getById?(i.filter.ID=function(R){var M=R.replace(Wt,jt);return function(q){return q.getAttribute("id")===M}},i.find.ID=function(R,M){if(typeof M.getElementById!="undefined"&&x){var q=M.getElementById(R);return q?[q]:[]}}):(i.filter.ID=function(R){var M=R.replace(Wt,jt);return function(q){var Q=typeof q.getAttributeNode!="undefined"&&q.getAttributeNode("id");return Q&&Q.value===M}},i.find.ID=function(R,M){if(typeof M.getElementById!="undefined"&&x){var q,Q,re,J=M.getElementById(R);if(J){if(q=J.getAttributeNode("id"),q&&q.value===R)return[J];for(re=M.getElementsByName(R),Q=0;J=re[Q++];)if(q=J.getAttributeNode("id"),q&&q.value===R)return[J]}return[]}}),i.find.TAG=function(R,M){return typeof M.getElementsByTagName!="undefined"?M.getElementsByTagName(R):M.querySelectorAll(R)},i.find.CLASS=function(R,M){if(typeof M.getElementsByClassName!="undefined"&&x)return M.getElementsByClassName(R)},C=[],Rr(function(R){var M;w.appendChild(R).innerHTML="<a id='"+N+"' href='' disabled='disabled'></a><select id='"+N+"-\r\\' disabled='disabled'><option selected=''></option></select>",R.querySelectorAll("[selected]").length||C.push("\\["+me+"*(?:value|"+kt+")"),R.querySelectorAll("[id~="+N+"-]").length||C.push("~="),R.querySelectorAll("a#"+N+"+*").length||C.push(".#.+[+~]"),R.querySelectorAll(":checked").length||C.push(":checked"),M=h.createElement("input"),M.setAttribute("type","hidden"),R.appendChild(M).setAttribute("name","D"),w.appendChild(R).disabled=!0,R.querySelectorAll(":disabled").length!==2&&C.push(":enabled",":disabled"),M=h.createElement("input"),M.setAttribute("name",""),R.appendChild(M),R.querySelectorAll("[name='']").length||C.push("\\["+me+"*name"+me+"*="+me+`*(?:''|"")`)}),O.cssHas||C.push(":has"),C=C.length&&new RegExp(C.join("|")),Ue=function(R,M){if(R===M)return c=!0,0;var q=!R.compareDocumentPosition-!M.compareDocumentPosition;return q||(q=(R.ownerDocument||R)==(M.ownerDocument||M)?R.compareDocumentPosition(M):1,q&1||!O.sortDetached&&M.compareDocumentPosition(R)===q?R===h||R.ownerDocument==nt&&Fe.contains(nt,R)?-1:M===h||M.ownerDocument==nt&&Fe.contains(nt,M)?1:o?y.call(o,R)-y.call(o,M):0:q&4?-1:1)}),h}Fe.matches=function(v,_){return Fe(v,null,null,_)},Fe.matchesSelector=function(v,_){if(ir(v),x&&!Ge[_+" "]&&(!C||!C.test(_)))try{var A=L.call(v,_);if(A||O.disconnectedMatch||v.document&&v.document.nodeType!==11)return A}catch(R){Ge(_,!0)}return Fe(_,h,null,[v]).length>0},Fe.contains=function(v,_){return(v.ownerDocument||v)!=h&&ir(v),s.contains(v,_)},Fe.attr=function(v,_){(v.ownerDocument||v)!=h&&ir(v);var A=i.attrHandle[_.toLowerCase()],R=A&&W.call(i.attrHandle,_.toLowerCase())?A(v,_,!x):void 0;return R!==void 0?R:v.getAttribute(_)},Fe.error=function(v){throw new Error("Syntax error, unrecognized expression: "+v)},s.uniqueSort=function(v){var _,A=[],R=0,M=0;if(c=!O.sortStable,o=!O.sortStable&&l.call(v,0),je.call(v,Ue),c){for(;_=v[M++];)_===v[M]&&(R=A.push(M));for(;R--;)Ke.call(v,A[R],1)}return o=null,v},s.fn.uniqueSort=function(){return this.pushStack(s.uniqueSort(l.apply(this)))},i=s.expr={cacheLength:50,createPseudo:_t,match:Ft,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(v){return v[1]=v[1].replace(Wt,jt),v[3]=(v[3]||v[4]||v[5]||"").replace(Wt,jt),v[2]==="~="&&(v[3]=" "+v[3]+" "),v.slice(0,4)},CHILD:function(v){return v[1]=v[1].toLowerCase(),v[1].slice(0,3)==="nth"?(v[3]||Fe.error(v[0]),v[4]=+(v[4]?v[5]+(v[6]||1):2*(v[3]==="even"||v[3]==="odd")),v[5]=+(v[7]+v[8]||v[3]==="odd")):v[3]&&Fe.error(v[0]),v},PSEUDO:function(v){var _,A=!v[6]&&v[2];return Ft.CHILD.test(v[0])?null:(v[3]?v[2]=v[4]||v[5]||"":A&&Dt.test(A)&&(_=ni(A,!0))&&(_=A.indexOf(")",A.length-_)-A.length)&&(v[0]=v[0].slice(0,_),v[2]=A.slice(0,_)),v.slice(0,3))}},filter:{TAG:function(v){var _=v.replace(Wt,jt).toLowerCase();return v==="*"?function(){return!0}:function(A){return X(A,_)}},CLASS:function(v){var _=ce[v+" "];return _||(_=new RegExp("(^|"+me+")"+v+"("+me+"|$)"))&&ce(v,function(A){return _.test(typeof A.className=="string"&&A.className||typeof A.getAttribute!="undefined"&&A.getAttribute("class")||"")})},ATTR:function(v,_,A){return function(R){var M=Fe.attr(R,v);return M==null?_==="!=":_?(M+="",_==="="?M===A:_==="!="?M!==A:_==="^="?A&&M.indexOf(A)===0:_==="*="?A&&M.indexOf(A)>-1:_==="$="?A&&M.slice(-A.length)===A:_==="~="?(" "+M.replace(Se," ")+" ").indexOf(A)>-1:_==="|="?M===A||M.slice(0,A.length+1)===A+"-":!1):!0}},CHILD:function(v,_,A,R,M){var q=v.slice(0,3)!=="nth",Q=v.slice(-4)!=="last",re=_==="of-type";return R===1&&M===0?function(J){return!!J.parentNode}:function(J,ye,le){var fe,xe,ne,Ie,ot,Qe=q!==Q?"nextSibling":"previousSibling",vt=J.parentNode,Rt=re&&J.nodeName.toLowerCase(),Lr=!le&&!re,et=!1;if(vt){if(q){for(;Qe;){for(ne=J;ne=ne[Qe];)if(re?X(ne,Rt):ne.nodeType===1)return!1;ot=Qe=v==="only"&&!ot&&"nextSibling"}return!0}if(ot=[Q?vt.firstChild:vt.lastChild],Q&&Lr){for(xe=vt[N]||(vt[N]={}),fe=xe[v]||[],Ie=fe[0]===F&&fe[1],et=Ie&&fe[2],ne=Ie&&vt.childNodes[Ie];ne=++Ie&&ne&&ne[Qe]||(et=Ie=0)||ot.pop();)if(ne.nodeType===1&&++et&&ne===J){xe[v]=[F,Ie,et];break}}else if(Lr&&(xe=J[N]||(J[N]={}),fe=xe[v]||[],Ie=fe[0]===F&&fe[1],et=Ie),et===!1)for(;(ne=++Ie&&ne&&ne[Qe]||(et=Ie=0)||ot.pop())&&!((re?X(ne,Rt):ne.nodeType===1)&&++et&&(Lr&&(xe=ne[N]||(ne[N]={}),xe[v]=[F,et]),ne===J)););return et-=M,et===R||et%R==0&&et/R>=0}}},PSEUDO:function(v,_){var A,R=i.pseudos[v]||i.setFilters[v.toLowerCase()]||Fe.error("unsupported pseudo: "+v);return R[N]?R(_):R.length>1?(A=[v,v,"",_],i.setFilters.hasOwnProperty(v.toLowerCase())?_t(function(M,q){for(var Q,re=R(M,_),J=re.length;J--;)Q=y.call(M,re[J]),M[Q]=!(q[Q]=re[J])}):function(M){return R(M,0,A)}):R}},pseudos:{not:_t(function(v){var _=[],A=[],R=aa(v.replace(He,"$1"));return R[N]?_t(function(M,q,Q,re){for(var J,ye=R(M,null,re,[]),le=M.length;le--;)(J=ye[le])&&(M[le]=!(q[le]=J))}):function(M,q,Q){return _[0]=M,R(_,null,Q,A),_[0]=null,!A.pop()}}),has:_t(function(v){return function(_){return Fe(v,_).length>0}}),contains:_t(function(v){return v=v.replace(Wt,jt),function(_){return(_.textContent||s.text(_)).indexOf(v)>-1}}),lang:_t(function(v){return ii.test(v||"")||Fe.error("unsupported lang: "+v),v=v.replace(Wt,jt).toLowerCase(),function(_){var A;do if(A=x?_.lang:_.getAttribute("xml:lang")||_.getAttribute("lang"))return A=A.toLowerCase(),A===v||A.indexOf(v+"-")===0;while((_=_.parentNode)&&_.nodeType===1);return!1}}),target:function(v){var _=u.location&&u.location.hash;return _&&_.slice(1)===v.id},root:function(v){return v===w},focus:function(v){return v===sl()&&h.hasFocus()&&!!(v.type||v.href||~v.tabIndex)},enabled:ps(!1),disabled:ps(!0),checked:function(v){return X(v,"input")&&!!v.checked||X(v,"option")&&!!v.selected},selected:function(v){return v.parentNode&&v.parentNode.selectedIndex,v.selected===!0},empty:function(v){for(v=v.firstChild;v;v=v.nextSibling)if(v.nodeType<6)return!1;return!0},parent:function(v){return!i.pseudos.empty(v)},header:function(v){return rr.test(v.nodeName)},input:function(v){return tr.test(v.nodeName)},button:function(v){return X(v,"input")&&v.type==="button"||X(v,"button")},text:function(v){var _;return X(v,"input")&&v.type==="text"&&((_=v.getAttribute("type"))==null||_.toLowerCase()==="text")},first:pr(function(){return[0]}),last:pr(function(v,_){return[_-1]}),eq:pr(function(v,_,A){return[A<0?A+_:A]}),even:pr(function(v,_){for(var A=0;A<_;A+=2)v.push(A);return v}),odd:pr(function(v,_){for(var A=1;A<_;A+=2)v.push(A);return v}),lt:pr(function(v,_,A){var R;for(A<0?R=A+_:A>_?R=_:R=A;--R>=0;)v.push(R);return v}),gt:pr(function(v,_,A){for(var R=A<0?A+_:A;++R<_;)v.push(R);return v})}},i.pseudos.nth=i.pseudos.eq;for(e in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[e]=ol(e);for(e in{submit:!0,reset:!0})i.pseudos[e]=ll(e);function gs(){}gs.prototype=i.filters=i.pseudos,i.setFilters=new gs;function ni(v,_){var A,R,M,q,Q,re,J,ye=Ee[v+" "];if(ye)return _?0:ye.slice(0);for(Q=v,re=[],J=i.preFilter;Q;){(!A||(R=Me.exec(Q)))&&(R&&(Q=Q.slice(R[0].length)||Q),re.push(M=[])),A=!1,(R=ri.exec(Q))&&(A=R.shift(),M.push({value:A,type:R[0].replace(He," ")}),Q=Q.slice(A.length));for(q in i.filter)(R=Ft[q].exec(Q))&&(!J[q]||(R=J[q](R)))&&(A=R.shift(),M.push({value:A,type:q,matches:R}),Q=Q.slice(A.length));if(!A)break}return _?Q.length:Q?Fe.error(v):Ee(v,re).slice(0)}function Zi(v){for(var _=0,A=v.length,R="";_<A;_++)R+=v[_].value;return R}function en(v,_,A){var R=_.dir,M=_.next,q=M||R,Q=A&&q==="parentNode",re=z++;return _.first?function(J,ye,le){for(;J=J[R];)if(J.nodeType===1||Q)return v(J,ye,le);return!1}:function(J,ye,le){var fe,xe,ne=[F,re];if(le){for(;J=J[R];)if((J.nodeType===1||Q)&&v(J,ye,le))return!0}else for(;J=J[R];)if(J.nodeType===1||Q)if(xe=J[N]||(J[N]={}),M&&X(J,M))J=J[R]||J;else{if((fe=xe[q])&&fe[0]===F&&fe[1]===re)return ne[2]=fe[2];if(xe[q]=ne,ne[2]=v(J,ye,le))return!0}return!1}}function ra(v){return v.length>1?function(_,A,R){for(var M=v.length;M--;)if(!v[M](_,A,R))return!1;return!0}:v[0]}function ul(v,_,A){for(var R=0,M=_.length;R<M;R++)Fe(v,_[R],A);return A}function tn(v,_,A,R,M){for(var q,Q=[],re=0,J=v.length,ye=_!=null;re<J;re++)(q=v[re])&&(!A||A(q,R,M))&&(Q.push(q),ye&&_.push(re));return Q}function ia(v,_,A,R,M,q){return R&&!R[N]&&(R=ia(R)),M&&!M[N]&&(M=ia(M,q)),_t(function(Q,re,J,ye){var le,fe,xe,ne,Ie=[],ot=[],Qe=re.length,vt=Q||ul(_||"*",J.nodeType?[J]:J,[]),Rt=v&&(Q||!_)?tn(vt,Ie,v,J,ye):vt;if(A?(ne=M||(Q?v:Qe||R)?[]:re,A(Rt,ne,J,ye)):ne=Rt,R)for(le=tn(ne,ot),R(le,[],J,ye),fe=le.length;fe--;)(xe=le[fe])&&(ne[ot[fe]]=!(Rt[ot[fe]]=xe));if(Q){if(M||v){if(M){for(le=[],fe=ne.length;fe--;)(xe=ne[fe])&&le.push(Rt[fe]=xe);M(null,ne=[],le,ye)}for(fe=ne.length;fe--;)(xe=ne[fe])&&(le=M?y.call(Q,xe):Ie[fe])>-1&&(Q[le]=!(re[le]=xe))}}else ne=tn(ne===re?ne.splice(Qe,ne.length):ne),M?M(null,re,ne,ye):f.apply(re,ne)})}function na(v){for(var _,A,R,M=v.length,q=i.relative[v[0].type],Q=q||i.relative[" "],re=q?1:0,J=en(function(fe){return fe===_},Q,!0),ye=en(function(fe){return y.call(_,fe)>-1},Q,!0),le=[function(fe,xe,ne){var Ie=!q&&(ne||xe!=n)||((_=xe).nodeType?J(fe,xe,ne):ye(fe,xe,ne));return _=null,Ie}];re<M;re++)if(A=i.relative[v[re].type])le=[en(ra(le),A)];else{if(A=i.filter[v[re].type].apply(null,v[re].matches),A[N]){for(R=++re;R<M&&!i.relative[v[R].type];R++);return ia(re>1&&ra(le),re>1&&Zi(v.slice(0,re-1).concat({value:v[re-2].type===" "?"*":""})).replace(He,"$1"),A,re<R&&na(v.slice(re,R)),R<M&&na(v=v.slice(R)),R<M&&Zi(v))}le.push(A)}return ra(le)}function cl(v,_){var A=_.length>0,R=v.length>0,M=function(q,Q,re,J,ye){var le,fe,xe,ne=0,Ie="0",ot=q&&[],Qe=[],vt=n,Rt=q||R&&i.find.TAG("*",ye),Lr=F+=vt==null?1:Math.random()||.1,et=Rt.length;for(ye&&(n=Q==h||Q||ye);Ie!==et&&(le=Rt[Ie])!=null;Ie++){if(R&&le){for(fe=0,!Q&&le.ownerDocument!=h&&(ir(le),re=!x);xe=v[fe++];)if(xe(le,Q||h,re)){f.call(J,le);break}ye&&(F=Lr)}A&&((le=!xe&&le)&&ne--,q&&ot.push(le))}if(ne+=Ie,A&&Ie!==ne){for(fe=0;xe=_[fe++];)xe(ot,Qe,Q,re);if(q){if(ne>0)for(;Ie--;)ot[Ie]||Qe[Ie]||(Qe[Ie]=Ce.call(J));Qe=tn(Qe)}f.apply(J,Qe),ye&&!q&&Qe.length>0&&ne+_.length>1&&s.uniqueSort(J)}return ye&&(F=Lr,n=vt),ot};return A?_t(M):M}function aa(v,_){var A,R=[],M=[],q=ve[v+" "];if(!q){for(_||(_=ni(v)),A=_.length;A--;)q=na(_[A]),q[N]?R.push(q):M.push(q);q=ve(v,cl(M,R)),q.selector=v}return q}function ms(v,_,A,R){var M,q,Q,re,J,ye=typeof v=="function"&&v,le=!R&&ni(v=ye.selector||v);if(A=A||[],le.length===1){if(q=le[0]=le[0].slice(0),q.length>2&&(Q=q[0]).type==="ID"&&_.nodeType===9&&x&&i.relative[q[1].type]){if(_=(i.find.ID(Q.matches[0].replace(Wt,jt),_)||[])[0],_)ye&&(_=_.parentNode);else return A;v=v.slice(q.shift().value.length)}for(M=Ft.needsContext.test(v)?0:q.length;M--&&(Q=q[M],!i.relative[re=Q.type]);)if((J=i.find[re])&&(R=J(Q.matches[0].replace(Wt,jt),ea.test(q[0].type)&&ta(_.parentNode)||_))){if(q.splice(M,1),v=R.length&&Zi(q),!v)return f.apply(A,R),A;break}}return(ye||aa(v,le))(R,_,!x,A,!_||ea.test(v)&&ta(_.parentNode)||_),A}O.sortStable=N.split("").sort(Ue).join("")===N,ir(),O.sortDetached=Rr(function(v){return v.compareDocumentPosition(h.createElement("fieldset"))&1}),s.find=Fe,s.expr[":"]=s.expr.pseudos,s.unique=s.uniqueSort,Fe.compile=aa,Fe.select=ms,Fe.setDocument=ir,Fe.tokenize=ni,Fe.escape=s.escapeSelector,Fe.getText=s.text,Fe.isXML=s.isXMLDoc,Fe.selectors=s.expr,Fe.support=s.support,Fe.uniqueSort=s.uniqueSort})();var ct=function(e,i,n){for(var o=[],c=n!==void 0;(e=e[i])&&e.nodeType!==9;)if(e.nodeType===1){if(c&&s(e).is(n))break;o.push(e)}return o},Wr=function(e,i){for(var n=[];e;e=e.nextSibling)e.nodeType===1&&e!==i&&n.push(e);return n},Pi=s.expr.match.needsContext,ki=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function ft(e,i,n){return B(i)?s.grep(e,function(o,c){return!!i.call(o,c,o)!==n}):i.nodeType?s.grep(e,function(o){return o===i!==n}):typeof i!="string"?s.grep(e,function(o){return y.call(i,o)>-1!==n}):s.filter(i,e,n)}s.filter=function(e,i,n){var o=i[0];return n&&(e=":not("+e+")"),i.length===1&&o.nodeType===1?s.find.matchesSelector(o,e)?[o]:[]:s.find.matches(e,s.grep(i,function(c){return c.nodeType===1}))},s.fn.extend({find:function(e){var i,n,o=this.length,c=this;if(typeof e!="string")return this.pushStack(s(e).filter(function(){for(i=0;i<o;i++)if(s.contains(c[i],this))return!0}));for(n=this.pushStack([]),i=0;i<o;i++)s.find(e,c[i],n);return o>1?s.uniqueSort(n):n},filter:function(e){return this.pushStack(ft(this,e||[],!1))},not:function(e){return this.pushStack(ft(this,e||[],!0))},is:function(e){return!!ft(this,typeof e=="string"&&Pi.test(e)?s(e):e||[],!1).length}});var jr,Ln=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,In=s.fn.init=function(e,i,n){var o,c;if(!e)return this;if(n=n||jr,typeof e=="string")if(e[0]==="<"&&e[e.length-1]===">"&&e.length>=3?o=[null,e,null]:o=Ln.exec(e),o&&(o[1]||!i))if(o[1]){if(i=i instanceof s?i[0]:i,s.merge(this,s.parseHTML(o[1],i&&i.nodeType?i.ownerDocument||i:Y,!0)),ki.test(o[1])&&s.isPlainObject(i))for(o in i)B(this[o])?this[o](i[o]):this.attr(o,i[o]);return this}else return c=Y.getElementById(o[2]),c&&(this[0]=c,this.length=1),this;else return!i||i.jquery?(i||n).find(e):this.constructor(i).find(e);else{if(e.nodeType)return this[0]=e,this.length=1,this;if(B(e))return n.ready!==void 0?n.ready(e):e(s)}return s.makeArray(e,this)};In.prototype=s.fn,jr=s(Y);var Mn=/^(?:parents|prev(?:Until|All))/,Nn={children:!0,contents:!0,next:!0,prev:!0};s.fn.extend({has:function(e){var i=s(e,this),n=i.length;return this.filter(function(){for(var o=0;o<n;o++)if(s.contains(this,i[o]))return!0})},closest:function(e,i){var n,o=0,c=this.length,f=[],h=typeof e!="string"&&s(e);if(!Pi.test(e)){for(;o<c;o++)for(n=this[o];n&&n!==i;n=n.parentNode)if(n.nodeType<11&&(h?h.index(n)>-1:n.nodeType===1&&s.find.matchesSelector(n,e))){f.push(n);break}}return this.pushStack(f.length>1?s.uniqueSort(f):f)},index:function(e){return e?typeof e=="string"?y.call(s(e),this[0]):y.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,i){return this.pushStack(s.uniqueSort(s.merge(this.get(),s(e,i))))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}});function Ai(e,i){for(;(e=e[i])&&e.nodeType!==1;);return e}s.each({parent:function(e){var i=e.parentNode;return i&&i.nodeType!==11?i:null},parents:function(e){return ct(e,"parentNode")},parentsUntil:function(e,i,n){return ct(e,"parentNode",n)},next:function(e){return Ai(e,"nextSibling")},prev:function(e){return Ai(e,"previousSibling")},nextAll:function(e){return ct(e,"nextSibling")},prevAll:function(e){return ct(e,"previousSibling")},nextUntil:function(e,i,n){return ct(e,"nextSibling",n)},prevUntil:function(e,i,n){return ct(e,"previousSibling",n)},siblings:function(e){return Wr((e.parentNode||{}).firstChild,e)},children:function(e){return Wr(e.firstChild)},contents:function(e){return e.contentDocument!=null&&a(e.contentDocument)?e.contentDocument:(X(e,"template")&&(e=e.content||e),s.merge([],e.childNodes))}},function(e,i){s.fn[e]=function(n,o){var c=s.map(this,i,n);return e.slice(-5)!=="Until"&&(o=n),o&&typeof o=="string"&&(c=s.filter(o,c)),this.length>1&&(Nn[e]||s.uniqueSort(c),Mn.test(e)&&c.reverse()),this.pushStack(c)}});var pt=/[^\x20\t\r\n\f]+/g;function On(e){var i={};return s.each(e.match(pt)||[],function(n,o){i[o]=!0}),i}s.Callbacks=function(e){e=typeof e=="string"?On(e):s.extend({},e);var i,n,o,c,f=[],h=[],w=-1,x=function(){for(c=c||e.once,o=i=!0;h.length;w=-1)for(n=h.shift();++w<f.length;)f[w].apply(n[0],n[1])===!1&&e.stopOnFalse&&(w=f.length,n=!1);e.memory||(n=!1),i=!1,c&&(n?f=[]:f="")},C={add:function(){return f&&(n&&!i&&(w=f.length-1,h.push(n)),function L(N){s.each(N,function(F,z){B(z)?(!e.unique||!C.has(z))&&f.push(z):z&&z.length&&pe(z)!=="string"&&L(z)})}(arguments),n&&!i&&x()),this},remove:function(){return s.each(arguments,function(L,N){for(var F;(F=s.inArray(N,f,F))>-1;)f.splice(F,1),F<=w&&w--}),this},has:function(L){return L?s.inArray(L,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return c=h=[],f=n="",this},disabled:function(){return!f},lock:function(){return c=h=[],!n&&!i&&(f=n=""),this},locked:function(){return!!c},fireWith:function(L,N){return c||(N=N||[],N=[L,N.slice?N.slice():N],h.push(N),i||x()),this},fire:function(){return C.fireWith(this,arguments),this},fired:function(){return!!o}};return C};function Gt(e){return e}function Tr(e){throw e}function Di(e,i,n,o){var c;try{e&&B(c=e.promise)?c.call(e).done(i).fail(n):e&&B(c=e.then)?c.call(e,i,n):i.apply(void 0,[e].slice(o))}catch(f){n.apply(void 0,[f])}}s.extend({Deferred:function(e){var i=[["notify","progress",s.Callbacks("memory"),s.Callbacks("memory"),2],["resolve","done",s.Callbacks("once memory"),s.Callbacks("once memory"),0,"resolved"],["reject","fail",s.Callbacks("once memory"),s.Callbacks("once memory"),1,"rejected"]],n="pending",o={state:function(){return n},always:function(){return c.done(arguments).fail(arguments),this},catch:function(f){return o.then(null,f)},pipe:function(){var f=arguments;return s.Deferred(function(h){s.each(i,function(w,x){var C=B(f[x[4]])&&f[x[4]];c[x[1]](function(){var L=C&&C.apply(this,arguments);L&&B(L.promise)?L.promise().progress(h.notify).done(h.resolve).fail(h.reject):h[x[0]+"With"](this,C?[L]:arguments)})}),f=null}).promise()},then:function(f,h,w){var x=0;function C(L,N,F,z){return function(){var ce=this,Ee=arguments,ve=function(){var Ue,kt;if(!(L<x)){if(Ue=F.apply(ce,Ee),Ue===N.promise())throw new TypeError("Thenable self-resolution");kt=Ue&&(typeof Ue=="object"||typeof Ue=="function")&&Ue.then,B(kt)?z?kt.call(Ue,C(x,N,Gt,z),C(x,N,Tr,z)):(x++,kt.call(Ue,C(x,N,Gt,z),C(x,N,Tr,z),C(x,N,Gt,N.notifyWith))):(F!==Gt&&(ce=void 0,Ee=[Ue]),(z||N.resolveWith)(ce,Ee))}},Ge=z?ve:function(){try{ve()}catch(Ue){s.Deferred.exceptionHook&&s.Deferred.exceptionHook(Ue,Ge.error),L+1>=x&&(F!==Tr&&(ce=void 0,Ee=[Ue]),N.rejectWith(ce,Ee))}};L?Ge():(s.Deferred.getErrorHook?Ge.error=s.Deferred.getErrorHook():s.Deferred.getStackHook&&(Ge.error=s.Deferred.getStackHook()),u.setTimeout(Ge))}}return s.Deferred(function(L){i[0][3].add(C(0,L,B(w)?w:Gt,L.notifyWith)),i[1][3].add(C(0,L,B(f)?f:Gt)),i[2][3].add(C(0,L,B(h)?h:Tr))}).promise()},promise:function(f){return f!=null?s.extend(f,o):o}},c={};return s.each(i,function(f,h){var w=h[2],x=h[5];o[h[1]]=w.add,x&&w.add(function(){n=x},i[3-f][2].disable,i[3-f][3].disable,i[0][2].lock,i[0][3].lock),w.add(h[3].fire),c[h[0]]=function(){return c[h[0]+"With"](this===c?void 0:this,arguments),this},c[h[0]+"With"]=w.fireWith}),o.promise(c),e&&e.call(c,c),c},when:function(e){var i=arguments.length,n=i,o=Array(n),c=l.call(arguments),f=s.Deferred(),h=function(w){return function(x){o[w]=this,c[w]=arguments.length>1?l.call(arguments):x,--i||f.resolveWith(o,c)}};if(i<=1&&(Di(e,f.done(h(n)).resolve,f.reject,!i),f.state()==="pending"||B(c[n]&&c[n].then)))return f.then();for(;n--;)Di(c[n],h(n),f.reject);return f.promise()}});var $n=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;s.Deferred.exceptionHook=function(e,i){u.console&&u.console.warn&&e&&$n.test(e.name)&&u.console.warn("jQuery.Deferred exception: "+e.message,e.stack,i)},s.readyException=function(e){u.setTimeout(function(){throw e})};var Ur=s.Deferred();s.fn.ready=function(e){return Ur.then(e).catch(function(i){s.readyException(i)}),this},s.extend({isReady:!1,readyWait:1,ready:function(e){(e===!0?--s.readyWait:s.isReady)||(s.isReady=!0,!(e!==!0&&--s.readyWait>0)&&Ur.resolveWith(Y,[s]))}}),s.ready.then=Ur.then;function dt(){Y.removeEventListener("DOMContentLoaded",dt),u.removeEventListener("load",dt),s.ready()}Y.readyState==="complete"||Y.readyState!=="loading"&&!Y.documentElement.doScroll?u.setTimeout(s.ready):(Y.addEventListener("DOMContentLoaded",dt),u.addEventListener("load",dt));var Et=function(e,i,n,o,c,f,h){var w=0,x=e.length,C=n==null;if(pe(n)==="object"){c=!0;for(w in n)Et(e,i,w,n[w],!0,f,h)}else if(o!==void 0&&(c=!0,B(o)||(h=!0),C&&(h?(i.call(e,o),i=null):(C=i,i=function(L,N,F){return C.call(s(L),F)})),i))for(;w<x;w++)i(e[w],n,h?o:o.call(e[w],w,i(e[w],n)));return c?e:C?i.call(e):x?i(e[0],n):f},Fi=/^-ms-/,Cr=/-([a-z])/g;function Br(e,i){return i.toUpperCase()}function at(e){return e.replace(Fi,"ms-").replace(Cr,Br)}var Nt=function(e){return e.nodeType===1||e.nodeType===9||!+e.nodeType};function qt(){this.expando=s.expando+qt.uid++}qt.uid=1,qt.prototype={cache:function(e){var i=e[this.expando];return i||(i={},Nt(e)&&(e.nodeType?e[this.expando]=i:Object.defineProperty(e,this.expando,{value:i,configurable:!0}))),i},set:function(e,i,n){var o,c=this.cache(e);if(typeof i=="string")c[at(i)]=n;else for(o in i)c[at(o)]=i[o];return c},get:function(e,i){return i===void 0?this.cache(e):e[this.expando]&&e[this.expando][at(i)]},access:function(e,i,n){return i===void 0||i&&typeof i=="string"&&n===void 0?this.get(e,i):(this.set(e,i,n),n!==void 0?n:i)},remove:function(e,i){var n,o=e[this.expando];if(o!==void 0){if(i!==void 0)for(Array.isArray(i)?i=i.map(at):(i=at(i),i=i in o?[i]:i.match(pt)||[]),n=i.length;n--;)delete o[i[n]];(i===void 0||s.isEmptyObject(o))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var i=e[this.expando];return i!==void 0&&!s.isEmptyObject(i)}};var te=new qt,Ve=new qt,Ri=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Li=/[A-Z]/g;function Ii(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e===+e+""?+e:Ri.test(e)?JSON.parse(e):e}function Hr(e,i,n){var o;if(n===void 0&&e.nodeType===1)if(o="data-"+i.replace(Li,"-$&").toLowerCase(),n=e.getAttribute(o),typeof n=="string"){try{n=Ii(n)}catch(c){}Ve.set(e,i,n)}else n=void 0;return n}s.extend({hasData:function(e){return Ve.hasData(e)||te.hasData(e)},data:function(e,i,n){return Ve.access(e,i,n)},removeData:function(e,i){Ve.remove(e,i)},_data:function(e,i,n){return te.access(e,i,n)},_removeData:function(e,i){te.remove(e,i)}}),s.fn.extend({data:function(e,i){var n,o,c,f=this[0],h=f&&f.attributes;if(e===void 0){if(this.length&&(c=Ve.get(f),f.nodeType===1&&!te.get(f,"hasDataAttrs"))){for(n=h.length;n--;)h[n]&&(o=h[n].name,o.indexOf("data-")===0&&(o=at(o.slice(5)),Hr(f,o,c[o])));te.set(f,"hasDataAttrs",!0)}return c}return typeof e=="object"?this.each(function(){Ve.set(this,e)}):Et(this,function(w){var x;if(f&&w===void 0)return x=Ve.get(f,e),x!==void 0||(x=Hr(f,e),x!==void 0)?x:void 0;this.each(function(){Ve.set(this,e,w)})},null,i,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){Ve.remove(this,e)})}}),s.extend({queue:function(e,i,n){var o;if(e)return i=(i||"fx")+"queue",o=te.get(e,i),n&&(!o||Array.isArray(n)?o=te.access(e,i,s.makeArray(n)):o.push(n)),o||[]},dequeue:function(e,i){i=i||"fx";var n=s.queue(e,i),o=n.length,c=n.shift(),f=s._queueHooks(e,i),h=function(){s.dequeue(e,i)};c==="inprogress"&&(c=n.shift(),o--),c&&(i==="fx"&&n.unshift("inprogress"),delete f.stop,c.call(e,h,f)),!o&&f&&f.empty.fire()},_queueHooks:function(e,i){var n=i+"queueHooks";return te.get(e,n)||te.access(e,n,{empty:s.Callbacks("once memory").add(function(){te.remove(e,[i+"queue",n])})})}}),s.fn.extend({queue:function(e,i){var n=2;return typeof e!="string"&&(i=e,e="fx",n--),arguments.length<n?s.queue(this[0],e):i===void 0?this:this.each(function(){var o=s.queue(this,e,i);s._queueHooks(this,e),e==="fx"&&o[0]!=="inprogress"&&s.dequeue(this,e)})},dequeue:function(e){return this.each(function(){s.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,i){var n,o=1,c=s.Deferred(),f=this,h=this.length,w=function(){--o||c.resolveWith(f,[f])};for(typeof e!="string"&&(i=e,e=void 0),e=e||"fx";h--;)n=te.get(f[h],e+"queueHooks"),n&&n.empty&&(o++,n.empty.add(w));return w(),c.promise(i)}});var zr=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,Yt=new RegExp("^(?:([+-])=|)("+zr+")([a-z%]*)$","i"),gt=["Top","Right","Bottom","Left"],Pt=Y.documentElement,Ot=function(e){return s.contains(e.ownerDocument,e)},Vr={composed:!0};Pt.getRootNode&&(Ot=function(e){return s.contains(e.ownerDocument,e)||e.getRootNode(Vr)===e.ownerDocument});var Pr=function(e,i){return e=i||e,e.style.display==="none"||e.style.display===""&&Ot(e)&&s.css(e,"display")==="none"};function Mi(e,i,n,o){var c,f,h=20,w=o?function(){return o.cur()}:function(){return s.css(e,i,"")},x=w(),C=n&&n[3]||(s.cssNumber[i]?"":"px"),L=e.nodeType&&(s.cssNumber[i]||C!=="px"&&+x)&&Yt.exec(s.css(e,i));if(L&&L[3]!==C){for(x=x/2,C=C||L[3],L=+x||1;h--;)s.style(e,i,L+C),(1-f)*(1-(f=w()/x||.5))<=0&&(h=0),L=L/f;L=L*2,s.style(e,i,L+C),n=n||[]}return n&&(L=+L||+x||0,c=n[1]?L+(n[1]+1)*n[2]:+n[2],o&&(o.unit=C,o.start=L,o.end=c)),c}var kr={};function Ni(e){var i,n=e.ownerDocument,o=e.nodeName,c=kr[o];return c||(i=n.body.appendChild(n.createElement(o)),c=s.css(i,"display"),i.parentNode.removeChild(i),c==="none"&&(c="block"),kr[o]=c,c)}function Xt(e,i){for(var n,o,c=[],f=0,h=e.length;f<h;f++)o=e[f],!!o.style&&(n=o.style.display,i?(n==="none"&&(c[f]=te.get(o,"display")||null,c[f]||(o.style.display="")),o.style.display===""&&Pr(o)&&(c[f]=Ni(o))):n!=="none"&&(c[f]="none",te.set(o,"display",n)));for(f=0;f<h;f++)c[f]!=null&&(e[f].style.display=c[f]);return e}s.fn.extend({show:function(){return Xt(this,!0)},hide:function(){return Xt(this)},toggle:function(e){return typeof e=="boolean"?e?this.show():this.hide():this.each(function(){Pr(this)?s(this).show():s(this).hide()})}});var st=/^(?:checkbox|radio)$/i,Oi=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,$i=/^$|^module$|\/(?:java|ecma)script/i;(function(){var e=Y.createDocumentFragment(),i=e.appendChild(Y.createElement("div")),n=Y.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),i.appendChild(n),O.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,i.innerHTML="<textarea>x</textarea>",O.noCloneChecked=!!i.cloneNode(!0).lastChild.defaultValue,i.innerHTML="<option></option>",O.option=!!i.lastChild})();var Ze={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ze.tbody=Ze.tfoot=Ze.colgroup=Ze.caption=Ze.thead,Ze.th=Ze.td,O.option||(Ze.optgroup=Ze.option=[1,"<select multiple='multiple'>","</select>"]);function qe(e,i){var n;return typeof e.getElementsByTagName!="undefined"?n=e.getElementsByTagName(i||"*"):typeof e.querySelectorAll!="undefined"?n=e.querySelectorAll(i||"*"):n=[],i===void 0||i&&X(e,i)?s.merge([e],n):n}function Gr(e,i){for(var n=0,o=e.length;n<o;n++)te.set(e[n],"globalEval",!i||te.get(i[n],"globalEval"))}var Wn=/<|&#?\w+;/;function Wi(e,i,n,o,c){for(var f,h,w,x,C,L,N=i.createDocumentFragment(),F=[],z=0,ce=e.length;z<ce;z++)if(f=e[z],f||f===0)if(pe(f)==="object")s.merge(F,f.nodeType?[f]:f);else if(!Wn.test(f))F.push(i.createTextNode(f));else{for(h=h||N.appendChild(i.createElement("div")),w=(Oi.exec(f)||["",""])[1].toLowerCase(),x=Ze[w]||Ze._default,h.innerHTML=x[1]+s.htmlPrefilter(f)+x[2],L=x[0];L--;)h=h.lastChild;s.merge(F,h.childNodes),h=N.firstChild,h.textContent=""}for(N.textContent="",z=0;f=F[z++];){if(o&&s.inArray(f,o)>-1){c&&c.push(f);continue}if(C=Ot(f),h=qe(N.appendChild(f),"script"),C&&Gr(h),n)for(L=0;f=h[L++];)$i.test(f.type||"")&&n.push(f)}return N}var ji=/^([^.]*)(?:\.(.+)|)/;function Qt(){return!0}function Jt(){return!1}function qr(e,i,n,o,c,f){var h,w;if(typeof i=="object"){typeof n!="string"&&(o=o||n,n=void 0);for(w in i)qr(e,w,n,o,i[w],f);return e}if(o==null&&c==null?(c=n,o=n=void 0):c==null&&(typeof n=="string"?(c=o,o=void 0):(c=o,o=n,n=void 0)),c===!1)c=Jt;else if(!c)return e;return f===1&&(h=c,c=function(x){return s().off(x),h.apply(this,arguments)},c.guid=h.guid||(h.guid=s.guid++)),e.each(function(){s.event.add(this,i,c,o,n)})}s.event={global:{},add:function(e,i,n,o,c){var f,h,w,x,C,L,N,F,z,ce,Ee,ve=te.get(e);if(!!Nt(e))for(n.handler&&(f=n,n=f.handler,c=f.selector),c&&s.find.matchesSelector(Pt,c),n.guid||(n.guid=s.guid++),(x=ve.events)||(x=ve.events=Object.create(null)),(h=ve.handle)||(h=ve.handle=function(Ge){return typeof s!="undefined"&&s.event.triggered!==Ge.type?s.event.dispatch.apply(e,arguments):void 0}),i=(i||"").match(pt)||[""],C=i.length;C--;)w=ji.exec(i[C])||[],z=Ee=w[1],ce=(w[2]||"").split(".").sort(),!!z&&(N=s.event.special[z]||{},z=(c?N.delegateType:N.bindType)||z,N=s.event.special[z]||{},L=s.extend({type:z,origType:Ee,data:o,handler:n,guid:n.guid,selector:c,needsContext:c&&s.expr.match.needsContext.test(c),namespace:ce.join(".")},f),(F=x[z])||(F=x[z]=[],F.delegateCount=0,(!N.setup||N.setup.call(e,o,ce,h)===!1)&&e.addEventListener&&e.addEventListener(z,h)),N.add&&(N.add.call(e,L),L.handler.guid||(L.handler.guid=n.guid)),c?F.splice(F.delegateCount++,0,L):F.push(L),s.event.global[z]=!0)},remove:function(e,i,n,o,c){var f,h,w,x,C,L,N,F,z,ce,Ee,ve=te.hasData(e)&&te.get(e);if(!(!ve||!(x=ve.events))){for(i=(i||"").match(pt)||[""],C=i.length;C--;){if(w=ji.exec(i[C])||[],z=Ee=w[1],ce=(w[2]||"").split(".").sort(),!z){for(z in x)s.event.remove(e,z+i[C],n,o,!0);continue}for(N=s.event.special[z]||{},z=(o?N.delegateType:N.bindType)||z,F=x[z]||[],w=w[2]&&new RegExp("(^|\\.)"+ce.join("\\.(?:.*\\.|)")+"(\\.|$)"),h=f=F.length;f--;)L=F[f],(c||Ee===L.origType)&&(!n||n.guid===L.guid)&&(!w||w.test(L.namespace))&&(!o||o===L.selector||o==="**"&&L.selector)&&(F.splice(f,1),L.selector&&F.delegateCount--,N.remove&&N.remove.call(e,L));h&&!F.length&&((!N.teardown||N.teardown.call(e,ce,ve.handle)===!1)&&s.removeEvent(e,z,ve.handle),delete x[z])}s.isEmptyObject(x)&&te.remove(e,"handle events")}},dispatch:function(e){var i,n,o,c,f,h,w=new Array(arguments.length),x=s.event.fix(e),C=(te.get(this,"events")||Object.create(null))[x.type]||[],L=s.event.special[x.type]||{};for(w[0]=x,i=1;i<arguments.length;i++)w[i]=arguments[i];if(x.delegateTarget=this,!(L.preDispatch&&L.preDispatch.call(this,x)===!1)){for(h=s.event.handlers.call(this,x,C),i=0;(c=h[i++])&&!x.isPropagationStopped();)for(x.currentTarget=c.elem,n=0;(f=c.handlers[n++])&&!x.isImmediatePropagationStopped();)(!x.rnamespace||f.namespace===!1||x.rnamespace.test(f.namespace))&&(x.handleObj=f,x.data=f.data,o=((s.event.special[f.origType]||{}).handle||f.handler).apply(c.elem,w),o!==void 0&&(x.result=o)===!1&&(x.preventDefault(),x.stopPropagation()));return L.postDispatch&&L.postDispatch.call(this,x),x.result}},handlers:function(e,i){var n,o,c,f,h,w=[],x=i.delegateCount,C=e.target;if(x&&C.nodeType&&!(e.type==="click"&&e.button>=1)){for(;C!==this;C=C.parentNode||this)if(C.nodeType===1&&!(e.type==="click"&&C.disabled===!0)){for(f=[],h={},n=0;n<x;n++)o=i[n],c=o.selector+" ",h[c]===void 0&&(h[c]=o.needsContext?s(c,this).index(C)>-1:s.find(c,this,null,[C]).length),h[c]&&f.push(o);f.length&&w.push({elem:C,handlers:f})}}return C=this,x<i.length&&w.push({elem:C,handlers:i.slice(x)}),w},addProp:function(e,i){Object.defineProperty(s.Event.prototype,e,{enumerable:!0,configurable:!0,get:B(i)?function(){if(this.originalEvent)return i(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(n){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:n})}})},fix:function(e){return e[s.expando]?e:new s.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var i=this||e;return st.test(i.type)&&i.click&&X(i,"input")&&Ar(i,"click",!0),!1},trigger:function(e){var i=this||e;return st.test(i.type)&&i.click&&X(i,"input")&&Ar(i,"click"),!0},_default:function(e){var i=e.target;return st.test(i.type)&&i.click&&X(i,"input")&&te.get(i,"click")||X(i,"a")}},beforeunload:{postDispatch:function(e){e.result!==void 0&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}};function Ar(e,i,n){if(!n){te.get(e,i)===void 0&&s.event.add(e,i,Qt);return}te.set(e,i,!1),s.event.add(e,i,{namespace:!1,handler:function(o){var c,f=te.get(this,i);if(o.isTrigger&1&&this[i]){if(f)(s.event.special[i]||{}).delegateType&&o.stopPropagation();else if(f=l.call(arguments),te.set(this,i,f),this[i](),c=te.get(this,i),te.set(this,i,!1),f!==c)return o.stopImmediatePropagation(),o.preventDefault(),c}else f&&(te.set(this,i,s.event.trigger(f[0],f.slice(1),this)),o.stopPropagation(),o.isImmediatePropagationStopped=Qt)}})}s.removeEvent=function(e,i,n){e.removeEventListener&&e.removeEventListener(i,n)},s.Event=function(e,i){if(!(this instanceof s.Event))return new s.Event(e,i);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.defaultPrevented===void 0&&e.returnValue===!1?Qt:Jt,this.target=e.target&&e.target.nodeType===3?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,i&&s.extend(this,i),this.timeStamp=e&&e.timeStamp||Date.now(),this[s.expando]=!0},s.Event.prototype={constructor:s.Event,isDefaultPrevented:Jt,isPropagationStopped:Jt,isImmediatePropagationStopped:Jt,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Qt,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Qt,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Qt,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},s.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},s.event.addProp),s.each({focus:"focusin",blur:"focusout"},function(e,i){function n(o){if(Y.documentMode){var c=te.get(this,"handle"),f=s.event.fix(o);f.type=o.type==="focusin"?"focus":"blur",f.isSimulated=!0,c(o),f.target===f.currentTarget&&c(f)}else s.event.simulate(i,o.target,s.event.fix(o))}s.event.special[e]={setup:function(){var o;if(Ar(this,e,!0),Y.documentMode)o=te.get(this,i),o||this.addEventListener(i,n),te.set(this,i,(o||0)+1);else return!1},trigger:function(){return Ar(this,e),!0},teardown:function(){var o;if(Y.documentMode)o=te.get(this,i)-1,o?te.set(this,i,o):(this.removeEventListener(i,n),te.remove(this,i));else return!1},_default:function(o){return te.get(o.target,e)},delegateType:i},s.event.special[i]={setup:function(){var o=this.ownerDocument||this.document||this,c=Y.documentMode?this:o,f=te.get(c,i);f||(Y.documentMode?this.addEventListener(i,n):o.addEventListener(e,n,!0)),te.set(c,i,(f||0)+1)},teardown:function(){var o=this.ownerDocument||this.document||this,c=Y.documentMode?this:o,f=te.get(c,i)-1;f?te.set(c,i,f):(Y.documentMode?this.removeEventListener(i,n):o.removeEventListener(e,n,!0),te.remove(c,i))}}}),s.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){s.event.special[e]={delegateType:i,bindType:i,handle:function(n){var o,c=this,f=n.relatedTarget,h=n.handleObj;return(!f||f!==c&&!s.contains(c,f))&&(n.type=h.origType,o=h.handler.apply(this,arguments),n.type=i),o}}}),s.fn.extend({on:function(e,i,n,o){return qr(this,e,i,n,o)},one:function(e,i,n,o){return qr(this,e,i,n,o,1)},off:function(e,i,n){var o,c;if(e&&e.preventDefault&&e.handleObj)return o=e.handleObj,s(e.delegateTarget).off(o.namespace?o.origType+"."+o.namespace:o.origType,o.selector,o.handler),this;if(typeof e=="object"){for(c in e)this.off(c,i,e[c]);return this}return(i===!1||typeof i=="function")&&(n=i,i=void 0),n===!1&&(n=Jt),this.each(function(){s.event.remove(this,e,n,i)})}});var jn=/<script|<style|<link/i,Ui=/checked\s*(?:[^=]|=\s*.checked.)/i,Un=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Bi(e,i){return X(e,"table")&&X(i.nodeType!==11?i:i.firstChild,"tr")&&s(e).children("tbody")[0]||e}function Bn(e){return e.type=(e.getAttribute("type")!==null)+"/"+e.type,e}function Hn(e){return(e.type||"").slice(0,5)==="true/"?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Hi(e,i){var n,o,c,f,h,w,x;if(i.nodeType===1){if(te.hasData(e)&&(f=te.get(e),x=f.events,x)){te.remove(i,"handle events");for(c in x)for(n=0,o=x[c].length;n<o;n++)s.event.add(i,c,x[c][n])}Ve.hasData(e)&&(h=Ve.access(e),w=s.extend({},h),Ve.set(i,w))}}function zn(e,i){var n=i.nodeName.toLowerCase();n==="input"&&st.test(e.type)?i.checked=e.checked:(n==="input"||n==="textarea")&&(i.defaultValue=e.defaultValue)}function Kt(e,i,n,o){i=d(i);var c,f,h,w,x,C,L=0,N=e.length,F=N-1,z=i[0],ce=B(z);if(ce||N>1&&typeof z=="string"&&!O.checkClone&&Ui.test(z))return e.each(function(Ee){var ve=e.eq(Ee);ce&&(i[0]=z.call(this,Ee,ve.html())),Kt(ve,i,n,o)});if(N&&(c=Wi(i,e[0].ownerDocument,!1,e,o),f=c.firstChild,c.childNodes.length===1&&(c=f),f||o)){for(h=s.map(qe(c,"script"),Bn),w=h.length;L<N;L++)x=c,L!==F&&(x=s.clone(x,!0,!0),w&&s.merge(h,qe(x,"script"))),n.call(e[L],x,L);if(w)for(C=h[h.length-1].ownerDocument,s.map(h,Hn),L=0;L<w;L++)x=h[L],$i.test(x.type||"")&&!te.access(x,"globalEval")&&s.contains(C,x)&&(x.src&&(x.type||"").toLowerCase()!=="module"?s._evalUrl&&!x.noModule&&s._evalUrl(x.src,{nonce:x.nonce||x.getAttribute("nonce")},C):Te(x.textContent.replace(Un,""),x,C))}return e}function zi(e,i,n){for(var o,c=i?s.filter(i,e):e,f=0;(o=c[f])!=null;f++)!n&&o.nodeType===1&&s.cleanData(qe(o)),o.parentNode&&(n&&Ot(o)&&Gr(qe(o,"script")),o.parentNode.removeChild(o));return e}s.extend({htmlPrefilter:function(e){return e},clone:function(e,i,n){var o,c,f,h,w=e.cloneNode(!0),x=Ot(e);if(!O.noCloneChecked&&(e.nodeType===1||e.nodeType===11)&&!s.isXMLDoc(e))for(h=qe(w),f=qe(e),o=0,c=f.length;o<c;o++)zn(f[o],h[o]);if(i)if(n)for(f=f||qe(e),h=h||qe(w),o=0,c=f.length;o<c;o++)Hi(f[o],h[o]);else Hi(e,w);return h=qe(w,"script"),h.length>0&&Gr(h,!x&&qe(e,"script")),w},cleanData:function(e){for(var i,n,o,c=s.event.special,f=0;(n=e[f])!==void 0;f++)if(Nt(n)){if(i=n[te.expando]){if(i.events)for(o in i.events)c[o]?s.event.remove(n,o):s.removeEvent(n,o,i.handle);n[te.expando]=void 0}n[Ve.expando]&&(n[Ve.expando]=void 0)}}}),s.fn.extend({detach:function(e){return zi(this,e,!0)},remove:function(e){return zi(this,e)},text:function(e){return Et(this,function(i){return i===void 0?s.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=i)})},null,e,arguments.length)},append:function(){return Kt(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Bi(this,e);i.appendChild(e)}})},prepend:function(){return Kt(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Bi(this,e);i.insertBefore(e,i.firstChild)}})},before:function(){return Kt(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Kt(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,i=0;(e=this[i])!=null;i++)e.nodeType===1&&(s.cleanData(qe(e,!1)),e.textContent="");return this},clone:function(e,i){return e=e==null?!1:e,i=i==null?e:i,this.map(function(){return s.clone(this,e,i)})},html:function(e){return Et(this,function(i){var n=this[0]||{},o=0,c=this.length;if(i===void 0&&n.nodeType===1)return n.innerHTML;if(typeof i=="string"&&!jn.test(i)&&!Ze[(Oi.exec(i)||["",""])[1].toLowerCase()]){i=s.htmlPrefilter(i);try{for(;o<c;o++)n=this[o]||{},n.nodeType===1&&(s.cleanData(qe(n,!1)),n.innerHTML=i);n=0}catch(f){}}n&&this.empty().append(i)},null,e,arguments.length)},replaceWith:function(){var e=[];return Kt(this,arguments,function(i){var n=this.parentNode;s.inArray(this,e)<0&&(s.cleanData(qe(this)),n&&n.replaceChild(i,this))},e)}}),s.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,i){s.fn[e]=function(n){for(var o,c=[],f=s(n),h=f.length-1,w=0;w<=h;w++)o=w===h?this:this.clone(!0),s(f[w])[i](o),g.apply(c,o.get());return this.pushStack(c)}});var Yr=new RegExp("^("+zr+")(?!px)[a-z%]+$","i"),Xr=/^--/,Dr=function(e){var i=e.ownerDocument.defaultView;return(!i||!i.opener)&&(i=u),i.getComputedStyle(e)},Vi=function(e,i,n){var o,c,f={};for(c in i)f[c]=e.style[c],e.style[c]=i[c];o=n.call(e);for(c in i)e.style[c]=f[c];return o},Vn=new RegExp(gt.join("|"),"i");(function(){function e(){if(!!C){x.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",C.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",Pt.appendChild(x).appendChild(C);var L=u.getComputedStyle(C);n=L.top!=="1%",w=i(L.marginLeft)===12,C.style.right="60%",f=i(L.right)===36,o=i(L.width)===36,C.style.position="absolute",c=i(C.offsetWidth/3)===12,Pt.removeChild(x),C=null}}function i(L){return Math.round(parseFloat(L))}var n,o,c,f,h,w,x=Y.createElement("div"),C=Y.createElement("div");!C.style||(C.style.backgroundClip="content-box",C.cloneNode(!0).style.backgroundClip="",O.clearCloneStyle=C.style.backgroundClip==="content-box",s.extend(O,{boxSizingReliable:function(){return e(),o},pixelBoxStyles:function(){return e(),f},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),w},scrollboxSize:function(){return e(),c},reliableTrDimensions:function(){var L,N,F,z;return h==null&&(L=Y.createElement("table"),N=Y.createElement("tr"),F=Y.createElement("div"),L.style.cssText="position:absolute;left:-11111px;border-collapse:separate",N.style.cssText="box-sizing:content-box;border:1px solid",N.style.height="1px",F.style.height="9px",F.style.display="block",Pt.appendChild(L).appendChild(N).appendChild(F),z=u.getComputedStyle(N),h=parseInt(z.height,10)+parseInt(z.borderTopWidth,10)+parseInt(z.borderBottomWidth,10)===N.offsetHeight,Pt.removeChild(L)),h}}))})();function ur(e,i,n){var o,c,f,h,w=Xr.test(i),x=e.style;return n=n||Dr(e),n&&(h=n.getPropertyValue(i)||n[i],w&&h&&(h=h.replace(He,"$1")||void 0),h===""&&!Ot(e)&&(h=s.style(e,i)),!O.pixelBoxStyles()&&Yr.test(h)&&Vn.test(i)&&(o=x.width,c=x.minWidth,f=x.maxWidth,x.minWidth=x.maxWidth=x.width=h,h=n.width,x.width=o,x.minWidth=c,x.maxWidth=f)),h!==void 0?h+"":h}function Gi(e,i){return{get:function(){if(e()){delete this.get;return}return(this.get=i).apply(this,arguments)}}}var Qr=["Webkit","Moz","ms"],Zt=Y.createElement("div").style,Jr={};function er(e){for(var i=e[0].toUpperCase()+e.slice(1),n=Qr.length;n--;)if(e=Qr[n]+i,e in Zt)return e}function Kr(e){var i=s.cssProps[e]||Jr[e];return i||(e in Zt?e:Jr[e]=er(e)||e)}var Fr=/^(none|table(?!-c[ea]).+)/,Zr={position:"absolute",visibility:"hidden",display:"block"},qi={letterSpacing:"0",fontWeight:"400"};function Yi(e,i,n){var o=Yt.exec(i);return o?Math.max(0,o[2]-(n||0))+(o[3]||"px"):i}function cr(e,i,n,o,c,f){var h=i==="width"?1:0,w=0,x=0,C=0;if(n===(o?"border":"content"))return 0;for(;h<4;h+=2)n==="margin"&&(C+=s.css(e,n+gt[h],!0,c)),o?(n==="content"&&(x-=s.css(e,"padding"+gt[h],!0,c)),n!=="margin"&&(x-=s.css(e,"border"+gt[h]+"Width",!0,c))):(x+=s.css(e,"padding"+gt[h],!0,c),n!=="padding"?x+=s.css(e,"border"+gt[h]+"Width",!0,c):w+=s.css(e,"border"+gt[h]+"Width",!0,c));return!o&&f>=0&&(x+=Math.max(0,Math.ceil(e["offset"+i[0].toUpperCase()+i.slice(1)]-f-x-w-.5))||0),x+C}function Xi(e,i,n){var o=Dr(e),c=!O.boxSizingReliable()||n,f=c&&s.css(e,"boxSizing",!1,o)==="border-box",h=f,w=ur(e,i,o),x="offset"+i[0].toUpperCase()+i.slice(1);if(Yr.test(w)){if(!n)return w;w="auto"}return(!O.boxSizingReliable()&&f||!O.reliableTrDimensions()&&X(e,"tr")||w==="auto"||!parseFloat(w)&&s.css(e,"display",!1,o)==="inline")&&e.getClientRects().length&&(f=s.css(e,"boxSizing",!1,o)==="border-box",h=x in e,h&&(w=e[x])),w=parseFloat(w)||0,w+cr(e,i,n||(f?"border":"content"),h,o,w)+"px"}s.extend({cssHooks:{opacity:{get:function(e,i){if(i){var n=ur(e,"opacity");return n===""?"1":n}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(e,i,n,o){if(!(!e||e.nodeType===3||e.nodeType===8||!e.style)){var c,f,h,w=at(i),x=Xr.test(i),C=e.style;if(x||(i=Kr(w)),h=s.cssHooks[i]||s.cssHooks[w],n!==void 0){if(f=typeof n,f==="string"&&(c=Yt.exec(n))&&c[1]&&(n=Mi(e,i,c),f="number"),n==null||n!==n)return;f==="number"&&!x&&(n+=c&&c[3]||(s.cssNumber[w]?"":"px")),!O.clearCloneStyle&&n===""&&i.indexOf("background")===0&&(C[i]="inherit"),(!h||!("set"in h)||(n=h.set(e,n,o))!==void 0)&&(x?C.setProperty(i,n):C[i]=n)}else return h&&"get"in h&&(c=h.get(e,!1,o))!==void 0?c:C[i]}},css:function(e,i,n,o){var c,f,h,w=at(i),x=Xr.test(i);return x||(i=Kr(w)),h=s.cssHooks[i]||s.cssHooks[w],h&&"get"in h&&(c=h.get(e,!0,n)),c===void 0&&(c=ur(e,i,o)),c==="normal"&&i in qi&&(c=qi[i]),n===""||n?(f=parseFloat(c),n===!0||isFinite(f)?f||0:c):c}}),s.each(["height","width"],function(e,i){s.cssHooks[i]={get:function(n,o,c){if(o)return Fr.test(s.css(n,"display"))&&(!n.getClientRects().length||!n.getBoundingClientRect().width)?Vi(n,Zr,function(){return Xi(n,i,c)}):Xi(n,i,c)},set:function(n,o,c){var f,h=Dr(n),w=!O.scrollboxSize()&&h.position==="absolute",x=w||c,C=x&&s.css(n,"boxSizing",!1,h)==="border-box",L=c?cr(n,i,c,C,h):0;return C&&w&&(L-=Math.ceil(n["offset"+i[0].toUpperCase()+i.slice(1)]-parseFloat(h[i])-cr(n,i,"border",!1,h)-.5)),L&&(f=Yt.exec(o))&&(f[3]||"px")!=="px"&&(n.style[i]=o,o=s.css(n,i)),Yi(n,o,L)}}}),s.cssHooks.marginLeft=Gi(O.reliableMarginLeft,function(e,i){if(i)return(parseFloat(ur(e,"marginLeft"))||e.getBoundingClientRect().left-Vi(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),s.each({margin:"",padding:"",border:"Width"},function(e,i){s.cssHooks[e+i]={expand:function(n){for(var o=0,c={},f=typeof n=="string"?n.split(" "):[n];o<4;o++)c[e+gt[o]+i]=f[o]||f[o-2]||f[0];return c}},e!=="margin"&&(s.cssHooks[e+i].set=Yi)}),s.fn.extend({css:function(e,i){return Et(this,function(n,o,c){var f,h,w={},x=0;if(Array.isArray(o)){for(f=Dr(n),h=o.length;x<h;x++)w[o[x]]=s.css(n,o[x],!1,f);return w}return c!==void 0?s.style(n,o,c):s.css(n,o)},e,i,arguments.length>1)}});function Ye(e,i,n,o,c){return new Ye.prototype.init(e,i,n,o,c)}s.Tween=Ye,Ye.prototype={constructor:Ye,init:function(e,i,n,o,c,f){this.elem=e,this.prop=n,this.easing=c||s.easing._default,this.options=i,this.start=this.now=this.cur(),this.end=o,this.unit=f||(s.cssNumber[n]?"":"px")},cur:function(){var e=Ye.propHooks[this.prop];return e&&e.get?e.get(this):Ye.propHooks._default.get(this)},run:function(e){var i,n=Ye.propHooks[this.prop];return this.options.duration?this.pos=i=s.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=i=e,this.now=(this.end-this.start)*i+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Ye.propHooks._default.set(this),this}},Ye.prototype.init.prototype=Ye.prototype,Ye.propHooks={_default:{get:function(e){var i;return e.elem.nodeType!==1||e.elem[e.prop]!=null&&e.elem.style[e.prop]==null?e.elem[e.prop]:(i=s.css(e.elem,e.prop,""),!i||i==="auto"?0:i)},set:function(e){s.fx.step[e.prop]?s.fx.step[e.prop](e):e.elem.nodeType===1&&(s.cssHooks[e.prop]||e.elem.style[Kr(e.prop)]!=null)?s.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Ye.propHooks.scrollTop=Ye.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},s.easing={linear:function(e){return e},swing:function(e){return .5-Math.cos(e*Math.PI)/2},_default:"swing"},s.fx=Ye.prototype.init,s.fx.step={};var p,E,m=/^(?:toggle|show|hide)$/,T=/queueHooks$/;function k(){E&&(Y.hidden===!1&&u.requestAnimationFrame?u.requestAnimationFrame(k):u.setTimeout(k,s.fx.interval),s.fx.tick())}function S(){return u.setTimeout(function(){p=void 0}),p=Date.now()}function I(e,i){var n,o=0,c={height:e};for(i=i?1:0;o<4;o+=2-i)n=gt[o],c["margin"+n]=c["padding"+n]=e;return i&&(c.opacity=c.width=e),c}function j(e,i,n){for(var o,c=(H.tweeners[i]||[]).concat(H.tweeners["*"]),f=0,h=c.length;f<h;f++)if(o=c[f].call(n,i,e))return o}function V(e,i,n){var o,c,f,h,w,x,C,L,N="width"in i||"height"in i,F=this,z={},ce=e.style,Ee=e.nodeType&&Pr(e),ve=te.get(e,"fxshow");n.queue||(h=s._queueHooks(e,"fx"),h.unqueued==null&&(h.unqueued=0,w=h.empty.fire,h.empty.fire=function(){h.unqueued||w()}),h.unqueued++,F.always(function(){F.always(function(){h.unqueued--,s.queue(e,"fx").length||h.empty.fire()})}));for(o in i)if(c=i[o],m.test(c)){if(delete i[o],f=f||c==="toggle",c===(Ee?"hide":"show"))if(c==="show"&&ve&&ve[o]!==void 0)Ee=!0;else continue;z[o]=ve&&ve[o]||s.style(e,o)}if(x=!s.isEmptyObject(i),!(!x&&s.isEmptyObject(z))){N&&e.nodeType===1&&(n.overflow=[ce.overflow,ce.overflowX,ce.overflowY],C=ve&&ve.display,C==null&&(C=te.get(e,"display")),L=s.css(e,"display"),L==="none"&&(C?L=C:(Xt([e],!0),C=e.style.display||C,L=s.css(e,"display"),Xt([e]))),(L==="inline"||L==="inline-block"&&C!=null)&&s.css(e,"float")==="none"&&(x||(F.done(function(){ce.display=C}),C==null&&(L=ce.display,C=L==="none"?"":L)),ce.display="inline-block")),n.overflow&&(ce.overflow="hidden",F.always(function(){ce.overflow=n.overflow[0],ce.overflowX=n.overflow[1],ce.overflowY=n.overflow[2]})),x=!1;for(o in z)x||(ve?"hidden"in ve&&(Ee=ve.hidden):ve=te.access(e,"fxshow",{display:C}),f&&(ve.hidden=!Ee),Ee&&Xt([e],!0),F.done(function(){Ee||Xt([e]),te.remove(e,"fxshow");for(o in z)s.style(e,o,z[o])})),x=j(Ee?ve[o]:0,o,F),o in ve||(ve[o]=x.start,Ee&&(x.end=x.start,x.start=0))}}function G(e,i){var n,o,c,f,h;for(n in e)if(o=at(n),c=i[o],f=e[n],Array.isArray(f)&&(c=f[1],f=e[n]=f[0]),n!==o&&(e[o]=f,delete e[n]),h=s.cssHooks[o],h&&"expand"in h){f=h.expand(f),delete e[o];for(n in f)n in e||(e[n]=f[n],i[n]=c)}else i[o]=c}function H(e,i,n){var o,c,f=0,h=H.prefilters.length,w=s.Deferred().always(function(){delete x.elem}),x=function(){if(c)return!1;for(var N=p||S(),F=Math.max(0,C.startTime+C.duration-N),z=F/C.duration||0,ce=1-z,Ee=0,ve=C.tweens.length;Ee<ve;Ee++)C.tweens[Ee].run(ce);return w.notifyWith(e,[C,ce,F]),ce<1&&ve?F:(ve||w.notifyWith(e,[C,1,0]),w.resolveWith(e,[C]),!1)},C=w.promise({elem:e,props:s.extend({},i),opts:s.extend(!0,{specialEasing:{},easing:s.easing._default},n),originalProperties:i,originalOptions:n,startTime:p||S(),duration:n.duration,tweens:[],createTween:function(N,F){var z=s.Tween(e,C.opts,N,F,C.opts.specialEasing[N]||C.opts.easing);return C.tweens.push(z),z},stop:function(N){var F=0,z=N?C.tweens.length:0;if(c)return this;for(c=!0;F<z;F++)C.tweens[F].run(1);return N?(w.notifyWith(e,[C,1,0]),w.resolveWith(e,[C,N])):w.rejectWith(e,[C,N]),this}}),L=C.props;for(G(L,C.opts.specialEasing);f<h;f++)if(o=H.prefilters[f].call(C,e,L,C.opts),o)return B(o.stop)&&(s._queueHooks(C.elem,C.opts.queue).stop=o.stop.bind(o)),o;return s.map(L,j,C),B(C.opts.start)&&C.opts.start.call(e,C),C.progress(C.opts.progress).done(C.opts.done,C.opts.complete).fail(C.opts.fail).always(C.opts.always),s.fx.timer(s.extend(x,{elem:e,anim:C,queue:C.opts.queue})),C}s.Animation=s.extend(H,{tweeners:{"*":[function(e,i){var n=this.createTween(e,i);return Mi(n.elem,e,Yt.exec(i),n),n}]},tweener:function(e,i){B(e)?(i=e,e=["*"]):e=e.match(pt);for(var n,o=0,c=e.length;o<c;o++)n=e[o],H.tweeners[n]=H.tweeners[n]||[],H.tweeners[n].unshift(i)},prefilters:[V],prefilter:function(e,i){i?H.prefilters.unshift(e):H.prefilters.push(e)}}),s.speed=function(e,i,n){var o=e&&typeof e=="object"?s.extend({},e):{complete:n||!n&&i||B(e)&&e,duration:e,easing:n&&i||i&&!B(i)&&i};return s.fx.off?o.duration=0:typeof o.duration!="number"&&(o.duration in s.fx.speeds?o.duration=s.fx.speeds[o.duration]:o.duration=s.fx.speeds._default),(o.queue==null||o.queue===!0)&&(o.queue="fx"),o.old=o.complete,o.complete=function(){B(o.old)&&o.old.call(this),o.queue&&s.dequeue(this,o.queue)},o},s.fn.extend({fadeTo:function(e,i,n,o){return this.filter(Pr).css("opacity",0).show().end().animate({opacity:i},e,n,o)},animate:function(e,i,n,o){var c=s.isEmptyObject(e),f=s.speed(i,n,o),h=function(){var w=H(this,s.extend({},e),f);(c||te.get(this,"finish"))&&w.stop(!0)};return h.finish=h,c||f.queue===!1?this.each(h):this.queue(f.queue,h)},stop:function(e,i,n){var o=function(c){var f=c.stop;delete c.stop,f(n)};return typeof e!="string"&&(n=i,i=e,e=void 0),i&&this.queue(e||"fx",[]),this.each(function(){var c=!0,f=e!=null&&e+"queueHooks",h=s.timers,w=te.get(this);if(f)w[f]&&w[f].stop&&o(w[f]);else for(f in w)w[f]&&w[f].stop&&T.test(f)&&o(w[f]);for(f=h.length;f--;)h[f].elem===this&&(e==null||h[f].queue===e)&&(h[f].anim.stop(n),c=!1,h.splice(f,1));(c||!n)&&s.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var i,n=te.get(this),o=n[e+"queue"],c=n[e+"queueHooks"],f=s.timers,h=o?o.length:0;for(n.finish=!0,s.queue(this,e,[]),c&&c.stop&&c.stop.call(this,!0),i=f.length;i--;)f[i].elem===this&&f[i].queue===e&&(f[i].anim.stop(!0),f.splice(i,1));for(i=0;i<h;i++)o[i]&&o[i].finish&&o[i].finish.call(this);delete n.finish})}}),s.each(["toggle","show","hide"],function(e,i){var n=s.fn[i];s.fn[i]=function(o,c,f){return o==null||typeof o=="boolean"?n.apply(this,arguments):this.animate(I(i,!0),o,c,f)}}),s.each({slideDown:I("show"),slideUp:I("hide"),slideToggle:I("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,i){s.fn[e]=function(n,o,c){return this.animate(i,n,o,c)}}),s.timers=[],s.fx.tick=function(){var e,i=0,n=s.timers;for(p=Date.now();i<n.length;i++)e=n[i],!e()&&n[i]===e&&n.splice(i--,1);n.length||s.fx.stop(),p=void 0},s.fx.timer=function(e){s.timers.push(e),s.fx.start()},s.fx.interval=13,s.fx.start=function(){E||(E=!0,k())},s.fx.stop=function(){E=null},s.fx.speeds={slow:600,fast:200,_default:400},s.fn.delay=function(e,i){return e=s.fx&&s.fx.speeds[e]||e,i=i||"fx",this.queue(i,function(n,o){var c=u.setTimeout(n,e);o.stop=function(){u.clearTimeout(c)}})},function(){var e=Y.createElement("input"),i=Y.createElement("select"),n=i.appendChild(Y.createElement("option"));e.type="checkbox",O.checkOn=e.value!=="",O.optSelected=n.selected,e=Y.createElement("input"),e.value="t",e.type="radio",O.radioValue=e.value==="t"}();var ee,he=s.expr.attrHandle;s.fn.extend({attr:function(e,i){return Et(this,s.attr,e,i,arguments.length>1)},removeAttr:function(e){return this.each(function(){s.removeAttr(this,e)})}}),s.extend({attr:function(e,i,n){var o,c,f=e.nodeType;if(!(f===3||f===8||f===2)){if(typeof e.getAttribute=="undefined")return s.prop(e,i,n);if((f!==1||!s.isXMLDoc(e))&&(c=s.attrHooks[i.toLowerCase()]||(s.expr.match.bool.test(i)?ee:void 0)),n!==void 0){if(n===null){s.removeAttr(e,i);return}return c&&"set"in c&&(o=c.set(e,n,i))!==void 0?o:(e.setAttribute(i,n+""),n)}return c&&"get"in c&&(o=c.get(e,i))!==null?o:(o=s.find.attr(e,i),o==null?void 0:o)}},attrHooks:{type:{set:function(e,i){if(!O.radioValue&&i==="radio"&&X(e,"input")){var n=e.value;return e.setAttribute("type",i),n&&(e.value=n),i}}}},removeAttr:function(e,i){var n,o=0,c=i&&i.match(pt);if(c&&e.nodeType===1)for(;n=c[o++];)e.removeAttribute(n)}}),ee={set:function(e,i,n){return i===!1?s.removeAttr(e,n):e.setAttribute(n,n),n}},s.each(s.expr.match.bool.source.match(/\w+/g),function(e,i){var n=he[i]||s.find.attr;he[i]=function(o,c,f){var h,w,x=c.toLowerCase();return f||(w=he[x],he[x]=h,h=n(o,c,f)!=null?x:null,he[x]=w),h}});var Pe=/^(?:input|select|textarea|button)$/i,ke=/^(?:a|area)$/i;s.fn.extend({prop:function(e,i){return Et(this,s.prop,e,i,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[s.propFix[e]||e]})}}),s.extend({prop:function(e,i,n){var o,c,f=e.nodeType;if(!(f===3||f===8||f===2))return(f!==1||!s.isXMLDoc(e))&&(i=s.propFix[i]||i,c=s.propHooks[i]),n!==void 0?c&&"set"in c&&(o=c.set(e,n,i))!==void 0?o:e[i]=n:c&&"get"in c&&(o=c.get(e,i))!==null?o:e[i]},propHooks:{tabIndex:{get:function(e){var i=s.find.attr(e,"tabindex");return i?parseInt(i,10):Pe.test(e.nodeName)||ke.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),O.optSelected||(s.propHooks.selected={get:function(e){var i=e.parentNode;return i&&i.parentNode&&i.parentNode.selectedIndex,null},set:function(e){var i=e.parentNode;i&&(i.selectedIndex,i.parentNode&&i.parentNode.selectedIndex)}}),s.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){s.propFix[this.toLowerCase()]=this});function Re(e){var i=e.match(pt)||[];return i.join(" ")}function De(e){return e.getAttribute&&e.getAttribute("class")||""}function Xe(e){return Array.isArray(e)?e:typeof e=="string"?e.match(pt)||[]:[]}s.fn.extend({addClass:function(e){var i,n,o,c,f,h;return B(e)?this.each(function(w){s(this).addClass(e.call(this,w,De(this)))}):(i=Xe(e),i.length?this.each(function(){if(o=De(this),n=this.nodeType===1&&" "+Re(o)+" ",n){for(f=0;f<i.length;f++)c=i[f],n.indexOf(" "+c+" ")<0&&(n+=c+" ");h=Re(n),o!==h&&this.setAttribute("class",h)}}):this)},removeClass:function(e){var i,n,o,c,f,h;return B(e)?this.each(function(w){s(this).removeClass(e.call(this,w,De(this)))}):arguments.length?(i=Xe(e),i.length?this.each(function(){if(o=De(this),n=this.nodeType===1&&" "+Re(o)+" ",n){for(f=0;f<i.length;f++)for(c=i[f];n.indexOf(" "+c+" ")>-1;)n=n.replace(" "+c+" "," ");h=Re(n),o!==h&&this.setAttribute("class",h)}}):this):this.attr("class","")},toggleClass:function(e,i){var n,o,c,f,h=typeof e,w=h==="string"||Array.isArray(e);return B(e)?this.each(function(x){s(this).toggleClass(e.call(this,x,De(this),i),i)}):typeof i=="boolean"&&w?i?this.addClass(e):this.removeClass(e):(n=Xe(e),this.each(function(){if(w)for(f=s(this),c=0;c<n.length;c++)o=n[c],f.hasClass(o)?f.removeClass(o):f.addClass(o);else(e===void 0||h==="boolean")&&(o=De(this),o&&te.set(this,"__className__",o),this.setAttribute&&this.setAttribute("class",o||e===!1?"":te.get(this,"__className__")||""))}))},hasClass:function(e){var i,n,o=0;for(i=" "+e+" ";n=this[o++];)if(n.nodeType===1&&(" "+Re(De(n))+" ").indexOf(i)>-1)return!0;return!1}});var fr=/\r/g;s.fn.extend({val:function(e){var i,n,o,c=this[0];return arguments.length?(o=B(e),this.each(function(f){var h;this.nodeType===1&&(o?h=e.call(this,f,s(this).val()):h=e,h==null?h="":typeof h=="number"?h+="":Array.isArray(h)&&(h=s.map(h,function(w){return w==null?"":w+""})),i=s.valHooks[this.type]||s.valHooks[this.nodeName.toLowerCase()],(!i||!("set"in i)||i.set(this,h,"value")===void 0)&&(this.value=h))})):c?(i=s.valHooks[c.type]||s.valHooks[c.nodeName.toLowerCase()],i&&"get"in i&&(n=i.get(c,"value"))!==void 0?n:(n=c.value,typeof n=="string"?n.replace(fr,""):n==null?"":n)):void 0}}),s.extend({valHooks:{option:{get:function(e){var i=s.find.attr(e,"value");return i!=null?i:Re(s.text(e))}},select:{get:function(e){var i,n,o,c=e.options,f=e.selectedIndex,h=e.type==="select-one",w=h?null:[],x=h?f+1:c.length;for(f<0?o=x:o=h?f:0;o<x;o++)if(n=c[o],(n.selected||o===f)&&!n.disabled&&(!n.parentNode.disabled||!X(n.parentNode,"optgroup"))){if(i=s(n).val(),h)return i;w.push(i)}return w},set:function(e,i){for(var n,o,c=e.options,f=s.makeArray(i),h=c.length;h--;)o=c[h],(o.selected=s.inArray(s.valHooks.option.get(o),f)>-1)&&(n=!0);return n||(e.selectedIndex=-1),f}}}}),s.each(["radio","checkbox"],function(){s.valHooks[this]={set:function(e,i){if(Array.isArray(i))return e.checked=s.inArray(s(e).val(),i)>-1}},O.checkOn||(s.valHooks[this].get=function(e){return e.getAttribute("value")===null?"on":e.value})});var $t=u.location,Qi={guid:Date.now()},dr=/\?/;s.parseXML=function(e){var i,n;if(!e||typeof e!="string")return null;try{i=new u.DOMParser().parseFromString(e,"text/xml")}catch(o){}return n=i&&i.getElementsByTagName("parsererror")[0],(!i||n)&&s.error("Invalid XML: "+(n?s.map(n.childNodes,function(o){return o.textContent}).join(`
`):e)),i};var Gn=/^(?:focusinfocus|focusoutblur)$/,Ji=function(e){e.stopPropagation()};s.extend(s.event,{trigger:function(e,i,n,o){var c,f,h,w,x,C,L,N,F=[n||Y],z=W.call(e,"type")?e.type:e,ce=W.call(e,"namespace")?e.namespace.split("."):[];if(f=N=h=n=n||Y,!(n.nodeType===3||n.nodeType===8)&&!Gn.test(z+s.event.triggered)&&(z.indexOf(".")>-1&&(ce=z.split("."),z=ce.shift(),ce.sort()),x=z.indexOf(":")<0&&"on"+z,e=e[s.expando]?e:new s.Event(z,typeof e=="object"&&e),e.isTrigger=o?2:3,e.namespace=ce.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+ce.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),i=i==null?[e]:s.makeArray(i,[e]),L=s.event.special[z]||{},!(!o&&L.trigger&&L.trigger.apply(n,i)===!1))){if(!o&&!L.noBubble&&!oe(n)){for(w=L.delegateType||z,Gn.test(w+z)||(f=f.parentNode);f;f=f.parentNode)F.push(f),h=f;h===(n.ownerDocument||Y)&&F.push(h.defaultView||h.parentWindow||u)}for(c=0;(f=F[c++])&&!e.isPropagationStopped();)N=f,e.type=c>1?w:L.bindType||z,C=(te.get(f,"events")||Object.create(null))[e.type]&&te.get(f,"handle"),C&&C.apply(f,i),C=x&&f[x],C&&C.apply&&Nt(f)&&(e.result=C.apply(f,i),e.result===!1&&e.preventDefault());return e.type=z,!o&&!e.isDefaultPrevented()&&(!L._default||L._default.apply(F.pop(),i)===!1)&&Nt(n)&&x&&B(n[z])&&!oe(n)&&(h=n[x],h&&(n[x]=null),s.event.triggered=z,e.isPropagationStopped()&&N.addEventListener(z,Ji),n[z](),e.isPropagationStopped()&&N.removeEventListener(z,Ji),s.event.triggered=void 0,h&&(n[x]=h)),e.result}},simulate:function(e,i,n){var o=s.extend(new s.Event,n,{type:e,isSimulated:!0});s.event.trigger(o,null,i)}}),s.fn.extend({trigger:function(e,i){return this.each(function(){s.event.trigger(e,i,this)})},triggerHandler:function(e,i){var n=this[0];if(n)return s.event.trigger(e,i,n,!0)}});var qn=/\[\]$/,ei=/\r?\n/g,Ho=/^(?:submit|button|image|reset|file)$/i,zo=/^(?:input|select|textarea|keygen)/i;function Yn(e,i,n,o){var c;if(Array.isArray(i))s.each(i,function(f,h){n||qn.test(e)?o(e,h):Yn(e+"["+(typeof h=="object"&&h!=null?f:"")+"]",h,n,o)});else if(!n&&pe(i)==="object")for(c in i)Yn(e+"["+c+"]",i[c],n,o);else o(e,i)}s.param=function(e,i){var n,o=[],c=function(f,h){var w=B(h)?h():h;o[o.length]=encodeURIComponent(f)+"="+encodeURIComponent(w==null?"":w)};if(e==null)return"";if(Array.isArray(e)||e.jquery&&!s.isPlainObject(e))s.each(e,function(){c(this.name,this.value)});else for(n in e)Yn(n,e[n],i,c);return o.join("&")},s.fn.extend({serialize:function(){return s.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=s.prop(this,"elements");return e?s.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!s(this).is(":disabled")&&zo.test(this.nodeName)&&!Ho.test(e)&&(this.checked||!st.test(e))}).map(function(e,i){var n=s(this).val();return n==null?null:Array.isArray(n)?s.map(n,function(o){return{name:i.name,value:o.replace(ei,`\r
`)}}):{name:i.name,value:n.replace(ei,`\r
`)}}).get()}});var Vo=/%20/g,Go=/#.*$/,qo=/([?&])_=[^&]*/,Yo=/^(.*?):[ \t]*([^\r\n]*)$/mg,Xo=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Qo=/^(?:GET|HEAD)$/,Jo=/^\/\//,us={},Xn={},cs="*/".concat("*"),Qn=Y.createElement("a");Qn.href=$t.href;function fs(e){return function(i,n){typeof i!="string"&&(n=i,i="*");var o,c=0,f=i.toLowerCase().match(pt)||[];if(B(n))for(;o=f[c++];)o[0]==="+"?(o=o.slice(1)||"*",(e[o]=e[o]||[]).unshift(n)):(e[o]=e[o]||[]).push(n)}}function ds(e,i,n,o){var c={},f=e===Xn;function h(w){var x;return c[w]=!0,s.each(e[w]||[],function(C,L){var N=L(i,n,o);if(typeof N=="string"&&!f&&!c[N])return i.dataTypes.unshift(N),h(N),!1;if(f)return!(x=N)}),x}return h(i.dataTypes[0])||!c["*"]&&h("*")}function Jn(e,i){var n,o,c=s.ajaxSettings.flatOptions||{};for(n in i)i[n]!==void 0&&((c[n]?e:o||(o={}))[n]=i[n]);return o&&s.extend(!0,e,o),e}function Ko(e,i,n){for(var o,c,f,h,w=e.contents,x=e.dataTypes;x[0]==="*";)x.shift(),o===void 0&&(o=e.mimeType||i.getResponseHeader("Content-Type"));if(o){for(c in w)if(w[c]&&w[c].test(o)){x.unshift(c);break}}if(x[0]in n)f=x[0];else{for(c in n){if(!x[0]||e.converters[c+" "+x[0]]){f=c;break}h||(h=c)}f=f||h}if(f)return f!==x[0]&&x.unshift(f),n[f]}function Zo(e,i,n,o){var c,f,h,w,x,C={},L=e.dataTypes.slice();if(L[1])for(h in e.converters)C[h.toLowerCase()]=e.converters[h];for(f=L.shift();f;)if(e.responseFields[f]&&(n[e.responseFields[f]]=i),!x&&o&&e.dataFilter&&(i=e.dataFilter(i,e.dataType)),x=f,f=L.shift(),f){if(f==="*")f=x;else if(x!=="*"&&x!==f){if(h=C[x+" "+f]||C["* "+f],!h){for(c in C)if(w=c.split(" "),w[1]===f&&(h=C[x+" "+w[0]]||C["* "+w[0]],h)){h===!0?h=C[c]:C[c]!==!0&&(f=w[0],L.unshift(w[1]));break}}if(h!==!0)if(h&&e.throws)i=h(i);else try{i=h(i)}catch(N){return{state:"parsererror",error:h?N:"No conversion from "+x+" to "+f}}}}return{state:"success",data:i}}s.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:$t.href,type:"GET",isLocal:Xo.test($t.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":cs,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":s.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,i){return i?Jn(Jn(e,s.ajaxSettings),i):Jn(s.ajaxSettings,e)},ajaxPrefilter:fs(us),ajaxTransport:fs(Xn),ajax:function(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};var n,o,c,f,h,w,x,C,L,N,F=s.ajaxSetup({},i),z=F.context||F,ce=F.context&&(z.nodeType||z.jquery)?s(z):s.event,Ee=s.Deferred(),ve=s.Callbacks("once memory"),Ge=F.statusCode||{},Ue={},kt={},At="canceled",we={readyState:0,getResponseHeader:function(Se){var Me;if(x){if(!f)for(f={};Me=Yo.exec(c);)f[Me[1].toLowerCase()+" "]=(f[Me[1].toLowerCase()+" "]||[]).concat(Me[2]);Me=f[Se.toLowerCase()+" "]}return Me==null?null:Me.join(", ")},getAllResponseHeaders:function(){return x?c:null},setRequestHeader:function(Se,Me){return x==null&&(Se=kt[Se.toLowerCase()]=kt[Se.toLowerCase()]||Se,Ue[Se]=Me),this},overrideMimeType:function(Se){return x==null&&(F.mimeType=Se),this},statusCode:function(Se){var Me;if(Se)if(x)we.always(Se[we.status]);else for(Me in Se)Ge[Me]=[Ge[Me],Se[Me]];return this},abort:function(Se){var Me=Se||At;return n&&n.abort(Me),hr(0,Me),this}};if(Ee.promise(we),F.url=((e||F.url||$t.href)+"").replace(Jo,$t.protocol+"//"),F.type=i.method||i.type||F.method||F.type,F.dataTypes=(F.dataType||"*").toLowerCase().match(pt)||[""],F.crossDomain==null){w=Y.createElement("a");try{w.href=F.url,w.href=w.href,F.crossDomain=Qn.protocol+"//"+Qn.host!=w.protocol+"//"+w.host}catch(Se){F.crossDomain=!0}}if(F.data&&F.processData&&typeof F.data!="string"&&(F.data=s.param(F.data,F.traditional)),ds(us,F,i,we),x)return we;C=s.event&&F.global,C&&s.active++==0&&s.event.trigger("ajaxStart"),F.type=F.type.toUpperCase(),F.hasContent=!Qo.test(F.type),o=F.url.replace(Go,""),F.hasContent?F.data&&F.processData&&(F.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(F.data=F.data.replace(Vo,"+")):(N=F.url.slice(o.length),F.data&&(F.processData||typeof F.data=="string")&&(o+=(dr.test(o)?"&":"?")+F.data,delete F.data),F.cache===!1&&(o=o.replace(qo,"$1"),N=(dr.test(o)?"&":"?")+"_="+Qi.guid+++N),F.url=o+N),F.ifModified&&(s.lastModified[o]&&we.setRequestHeader("If-Modified-Since",s.lastModified[o]),s.etag[o]&&we.setRequestHeader("If-None-Match",s.etag[o])),(F.data&&F.hasContent&&F.contentType!==!1||i.contentType)&&we.setRequestHeader("Content-Type",F.contentType),we.setRequestHeader("Accept",F.dataTypes[0]&&F.accepts[F.dataTypes[0]]?F.accepts[F.dataTypes[0]]+(F.dataTypes[0]!=="*"?", "+cs+"; q=0.01":""):F.accepts["*"]);for(L in F.headers)we.setRequestHeader(L,F.headers[L]);if(F.beforeSend&&(F.beforeSend.call(z,we,F)===!1||x))return we.abort();if(At="abort",ve.add(F.complete),we.done(F.success),we.fail(F.error),n=ds(Xn,F,i,we),!n)hr(-1,"No Transport");else{if(we.readyState=1,C&&ce.trigger("ajaxSend",[we,F]),x)return we;F.async&&F.timeout>0&&(h=u.setTimeout(function(){we.abort("timeout")},F.timeout));try{x=!1,n.send(Ue,hr)}catch(Se){if(x)throw Se;hr(-1,Se)}}function hr(Se,Me,ri,Zn){var Dt,ii,Ft,tr,rr,mt=Me;x||(x=!0,h&&u.clearTimeout(h),n=void 0,c=Zn||"",we.readyState=Se>0?4:0,Dt=Se>=200&&Se<300||Se===304,ri&&(tr=Ko(F,we,ri)),!Dt&&s.inArray("script",F.dataTypes)>-1&&s.inArray("json",F.dataTypes)<0&&(F.converters["text script"]=function(){}),tr=Zo(F,tr,we,Dt),Dt?(F.ifModified&&(rr=we.getResponseHeader("Last-Modified"),rr&&(s.lastModified[o]=rr),rr=we.getResponseHeader("etag"),rr&&(s.etag[o]=rr)),Se===204||F.type==="HEAD"?mt="nocontent":Se===304?mt="notmodified":(mt=tr.state,ii=tr.data,Ft=tr.error,Dt=!Ft)):(Ft=mt,(Se||!mt)&&(mt="error",Se<0&&(Se=0))),we.status=Se,we.statusText=(Me||mt)+"",Dt?Ee.resolveWith(z,[ii,mt,we]):Ee.rejectWith(z,[we,mt,Ft]),we.statusCode(Ge),Ge=void 0,C&&ce.trigger(Dt?"ajaxSuccess":"ajaxError",[we,F,Dt?ii:Ft]),ve.fireWith(z,[we,mt]),C&&(ce.trigger("ajaxComplete",[we,F]),--s.active||s.event.trigger("ajaxStop")))}return we},getJSON:function(e,i,n){return s.get(e,i,n,"json")},getScript:function(e,i){return s.get(e,void 0,i,"script")}}),s.each(["get","post"],function(e,i){s[i]=function(n,o,c,f){return B(o)&&(f=f||c,c=o,o=void 0),s.ajax(s.extend({url:n,type:i,dataType:f,data:o,success:c},s.isPlainObject(n)&&n))}}),s.ajaxPrefilter(function(e){var i;for(i in e.headers)i.toLowerCase()==="content-type"&&(e.contentType=e.headers[i]||"")}),s._evalUrl=function(e,i,n){return s.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(o){s.globalEval(o,i,n)}})},s.fn.extend({wrapAll:function(e){var i;return this[0]&&(B(e)&&(e=e.call(this[0])),i=s(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&i.insertBefore(this[0]),i.map(function(){for(var n=this;n.firstElementChild;)n=n.firstElementChild;return n}).append(this)),this},wrapInner:function(e){return B(e)?this.each(function(i){s(this).wrapInner(e.call(this,i))}):this.each(function(){var i=s(this),n=i.contents();n.length?n.wrapAll(e):i.append(e)})},wrap:function(e){var i=B(e);return this.each(function(n){s(this).wrapAll(i?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){s(this).replaceWith(this.childNodes)}),this}}),s.expr.pseudos.hidden=function(e){return!s.expr.pseudos.visible(e)},s.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},s.ajaxSettings.xhr=function(){try{return new u.XMLHttpRequest}catch(e){}};var el={0:200,1223:204},ti=s.ajaxSettings.xhr();O.cors=!!ti&&"withCredentials"in ti,O.ajax=ti=!!ti,s.ajaxTransport(function(e){var i,n;if(O.cors||ti&&!e.crossDomain)return{send:function(o,c){var f,h=e.xhr();if(h.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(f in e.xhrFields)h[f]=e.xhrFields[f];e.mimeType&&h.overrideMimeType&&h.overrideMimeType(e.mimeType),!e.crossDomain&&!o["X-Requested-With"]&&(o["X-Requested-With"]="XMLHttpRequest");for(f in o)h.setRequestHeader(f,o[f]);i=function(w){return function(){i&&(i=n=h.onload=h.onerror=h.onabort=h.ontimeout=h.onreadystatechange=null,w==="abort"?h.abort():w==="error"?typeof h.status!="number"?c(0,"error"):c(h.status,h.statusText):c(el[h.status]||h.status,h.statusText,(h.responseType||"text")!=="text"||typeof h.responseText!="string"?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=i(),n=h.onerror=h.ontimeout=i("error"),h.onabort!==void 0?h.onabort=n:h.onreadystatechange=function(){h.readyState===4&&u.setTimeout(function(){i&&n()})},i=i("abort");try{h.send(e.hasContent&&e.data||null)}catch(w){if(i)throw w}},abort:function(){i&&i()}}}),s.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),s.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return s.globalEval(e),e}}}),s.ajaxPrefilter("script",function(e){e.cache===void 0&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),s.ajaxTransport("script",function(e){if(e.crossDomain||e.scriptAttrs){var i,n;return{send:function(o,c){i=s("<script>").attr(e.scriptAttrs||{}).prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(f){i.remove(),n=null,f&&c(f.type==="error"?404:200,f.type)}),Y.head.appendChild(i[0])},abort:function(){n&&n()}}}});var hs=[],Kn=/(=)\?(?=&|$)|\?\?/;s.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=hs.pop()||s.expando+"_"+Qi.guid++;return this[e]=!0,e}}),s.ajaxPrefilter("json jsonp",function(e,i,n){var o,c,f,h=e.jsonp!==!1&&(Kn.test(e.url)?"url":typeof e.data=="string"&&(e.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&Kn.test(e.data)&&"data");if(h||e.dataTypes[0]==="jsonp")return o=e.jsonpCallback=B(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,h?e[h]=e[h].replace(Kn,"$1"+o):e.jsonp!==!1&&(e.url+=(dr.test(e.url)?"&":"?")+e.jsonp+"="+o),e.converters["script json"]=function(){return f||s.error(o+" was not called"),f[0]},e.dataTypes[0]="json",c=u[o],u[o]=function(){f=arguments},n.always(function(){c===void 0?s(u).removeProp(o):u[o]=c,e[o]&&(e.jsonpCallback=i.jsonpCallback,hs.push(o)),f&&B(c)&&c(f[0]),f=c=void 0}),"script"}),O.createHTMLDocument=function(){var e=Y.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",e.childNodes.length===2}(),s.parseHTML=function(e,i,n){if(typeof e!="string")return[];typeof i=="boolean"&&(n=i,i=!1);var o,c,f;return i||(O.createHTMLDocument?(i=Y.implementation.createHTMLDocument(""),o=i.createElement("base"),o.href=Y.location.href,i.head.appendChild(o)):i=Y),c=ki.exec(e),f=!n&&[],c?[i.createElement(c[1])]:(c=Wi([e],i,f),f&&f.length&&s(f).remove(),s.merge([],c.childNodes))},s.fn.load=function(e,i,n){var o,c,f,h=this,w=e.indexOf(" ");return w>-1&&(o=Re(e.slice(w)),e=e.slice(0,w)),B(i)?(n=i,i=void 0):i&&typeof i=="object"&&(c="POST"),h.length>0&&s.ajax({url:e,type:c||"GET",dataType:"html",data:i}).done(function(x){f=arguments,h.html(o?s("<div>").append(s.parseHTML(x)).find(o):x)}).always(n&&function(x,C){h.each(function(){n.apply(this,f||[x.responseText,C,x])})}),this},s.expr.pseudos.animated=function(e){return s.grep(s.timers,function(i){return e===i.elem}).length},s.offset={setOffset:function(e,i,n){var o,c,f,h,w,x,C,L=s.css(e,"position"),N=s(e),F={};L==="static"&&(e.style.position="relative"),w=N.offset(),f=s.css(e,"top"),x=s.css(e,"left"),C=(L==="absolute"||L==="fixed")&&(f+x).indexOf("auto")>-1,C?(o=N.position(),h=o.top,c=o.left):(h=parseFloat(f)||0,c=parseFloat(x)||0),B(i)&&(i=i.call(e,n,s.extend({},w))),i.top!=null&&(F.top=i.top-w.top+h),i.left!=null&&(F.left=i.left-w.left+c),"using"in i?i.using.call(e,F):N.css(F)}},s.fn.extend({offset:function(e){if(arguments.length)return e===void 0?this:this.each(function(c){s.offset.setOffset(this,e,c)});var i,n,o=this[0];if(!!o)return o.getClientRects().length?(i=o.getBoundingClientRect(),n=o.ownerDocument.defaultView,{top:i.top+n.pageYOffset,left:i.left+n.pageXOffset}):{top:0,left:0}},position:function(){if(!!this[0]){var e,i,n,o=this[0],c={top:0,left:0};if(s.css(o,"position")==="fixed")i=o.getBoundingClientRect();else{for(i=this.offset(),n=o.ownerDocument,e=o.offsetParent||n.documentElement;e&&(e===n.body||e===n.documentElement)&&s.css(e,"position")==="static";)e=e.parentNode;e&&e!==o&&e.nodeType===1&&(c=s(e).offset(),c.top+=s.css(e,"borderTopWidth",!0),c.left+=s.css(e,"borderLeftWidth",!0))}return{top:i.top-c.top-s.css(o,"marginTop",!0),left:i.left-c.left-s.css(o,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&s.css(e,"position")==="static";)e=e.offsetParent;return e||Pt})}}),s.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,i){var n=i==="pageYOffset";s.fn[e]=function(o){return Et(this,function(c,f,h){var w;if(oe(c)?w=c:c.nodeType===9&&(w=c.defaultView),h===void 0)return w?w[i]:c[f];w?w.scrollTo(n?w.pageXOffset:h,n?h:w.pageYOffset):c[f]=h},e,o,arguments.length)}}),s.each(["top","left"],function(e,i){s.cssHooks[i]=Gi(O.pixelPosition,function(n,o){if(o)return o=ur(n,i),Yr.test(o)?s(n).position()[i]+"px":o})}),s.each({Height:"height",Width:"width"},function(e,i){s.each({padding:"inner"+e,content:i,"":"outer"+e},function(n,o){s.fn[o]=function(c,f){var h=arguments.length&&(n||typeof c!="boolean"),w=n||(c===!0||f===!0?"margin":"border");return Et(this,function(x,C,L){var N;return oe(x)?o.indexOf("outer")===0?x["inner"+e]:x.document.documentElement["client"+e]:x.nodeType===9?(N=x.documentElement,Math.max(x.body["scroll"+e],N["scroll"+e],x.body["offset"+e],N["offset"+e],N["client"+e])):L===void 0?s.css(x,C,w):s.style(x,C,L,w)},i,h?c:void 0,h)}})}),s.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,i){s.fn[i]=function(n){return this.on(i,n)}}),s.fn.extend({bind:function(e,i,n){return this.on(e,null,i,n)},unbind:function(e,i){return this.off(e,null,i)},delegate:function(e,i,n,o){return this.on(i,e,n,o)},undelegate:function(e,i,n){return arguments.length===1?this.off(e,"**"):this.off(i,e||"**",n)},hover:function(e,i){return this.on("mouseenter",e).on("mouseleave",i||e)}}),s.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,i){s.fn[i]=function(n,o){return arguments.length>0?this.on(i,null,n,o):this.trigger(i)}});var tl=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;s.proxy=function(e,i){var n,o,c;if(typeof i=="string"&&(n=e[i],i=e,e=n),!!B(e))return o=l.call(arguments,2),c=function(){return e.apply(i||this,o.concat(l.call(arguments)))},c.guid=e.guid=e.guid||s.guid++,c},s.holdReady=function(e){e?s.readyWait++:s.ready(!0)},s.isArray=Array.isArray,s.parseJSON=JSON.parse,s.nodeName=X,s.isFunction=B,s.isWindow=oe,s.camelCase=at,s.type=pe,s.now=Date.now,s.isNumeric=function(e){var i=s.type(e);return(i==="number"||i==="string")&&!isNaN(e-parseFloat(e))},s.trim=function(e){return e==null?"":(e+"").replace(tl,"$1")},typeof define=="function"&&define.amd&&define("jquery",[],function(){return s});var rl=u.jQuery,il=u.$;return s.noConflict=function(e){return u.$===s&&(u.$=il),e&&u.jQuery===s&&(u.jQuery=rl),s},typeof t=="undefined"&&(u.jQuery=u.$=s),s})});var Qa=si(pa());var fn=class{constructor(t,r){t=t||[],this.lines=t,this.text=r,this.offset2loc=new Map,this.line2offset=new Map;for(var a of t)a.offset>=0&&(this.offset2loc[a.offset]||(this.offset2loc[a.offset]=a),this.line2offset[a.line]||(this.line2offset[a.line]=a.offset))}findLineForOffset(t,r){if(this.offset2loc)for(var a=0;a<=r;a++){var l=this.offset2loc[t];if(l)return l;t--}return null}lineCount(){return this.lines.length}};function Fs(u){return"errors"in u}function Rs(u){return"output"in u}var Ls=si(pa()),ma=class{constructor(t){this.preset_id=ut(t)}async getRemoteFile(t){return new Promise((r,a)=>on(t,r,gr(t)?"arraybuffer":"text"))}async getFileData(t){var r="presets/"+this.preset_id+"/"+t,a=await this.getRemoteFile(r);return a&&console.log("read",r,a.length,"bytes"),a}async setFileData(t,r){}};var ui=class{constructor(t,r){this.basefs=t,this.overlayfs=r}async getFileData(t){var r=await this.overlayfs.getFileData(t);return r==null?this.basefs.getFileData(t):r}async setFileData(t,r){return await this.overlayfs.setFileData(t,r),this.basefs.setFileData(t,r)}},va=class{constructor(t){this.store=t}async getFileData(t){return this.store.getItem(t)}async setFileData(t,r){return this.store.setItem(t,r)}};var ba=class{constructor(t,r,a,l){this.filedata={};this.pendingWorkerMessages=0;this.tools_preloaded={};this.isCompiling=!1;this.filename2path={};this.worker=t,this.platform_id=r,this.platform=a,this.filesystem=l,t.onmessage=d=>{this.receiveWorkerMessage(d.data)}}receiveWorkerMessage(t){var r=this.pendingWorkerMessages>1;r?(this.sendBuild(),this.pendingWorkerMessages=1):(this.callbackBuildStatus&&this.callbackBuildStatus(!1),this.isCompiling||(console.log(this.pendingWorkerMessages),console.trace()),this.isCompiling=!1,this.pendingWorkerMessages=0),t&&Rs(t)?this.processBuildResult(t):Fs(t)&&this.processBuildListings(t),this.callbackBuildResult(t)}getToolForFilename(t){return this.remoteTool?"remote:"+this.remoteTool:this.platform.getToolForFilename(t)}preloadWorker(t){var r=this.getToolForFilename(t);r&&!this.tools_preloaded[r]&&(this.worker.postMessage({preload:r,platform:this.platform_id}),this.tools_preloaded[r]=!0)}pushAllFiles(t,r){t.push(r);var a=sa(this.mainPath);a.length>0&&a!="local"&&t.push(a+"/"+r)}parseIncludeDependencies(t){let r=[],a;if(this.platform_id.startsWith("verilog")){let l=/^\s*(`include|[.]include)\s+"(.+?)"/gmi;for(;a=l.exec(t);)this.pushAllFiles(r,a[2]);let d=/^\s*\$(include|\$dofile|\$write_image_in_table)\('(.+?)'/gmi;for(;a=d.exec(t);)this.pushAllFiles(r,a[2]);let g=/^\s*([.]arch)\s+(\w+)/gmi;for(;a=g.exec(t);)this.pushAllFiles(r,a[2]+".json");let y=/\$readmem[bh]\("(.+?)"/gmi;for(;a=y.exec(t);)this.pushAllFiles(r,a[1])}else{let l=/^\s*[.#%]?(include|incbin|embed)\s+"(.+?)"/gmi;for(;a=l.exec(t);)this.pushAllFiles(r,a[2]);let d=/^\s*([;']|[/][/])#(resource)\s+"(.+?)"/gm;for(;a=d.exec(t);)this.pushAllFiles(r,a[3]);let g=/^\s+(USE|ASM)\s+(\S+[.]\S+)/gm;for(;a=g.exec(t);)this.pushAllFiles(r,a[2]);let y=/^\s*(import|embed)\s*"(.+?)";/gmi;for(;a=y.exec(t);)a[1]=="import"?this.pushAllFiles(r,a[2]+".wiz"):this.pushAllFiles(r,a[2]);let b=/^\s*(import)\s*"(.+?)"/gmi;for(;a=b.exec(t);)this.pushAllFiles(r,a[2]);let D=/^[!]src\s+"(.+?)"/gmi;for(;a=D.exec(t);)this.pushAllFiles(r,a[1])}return r}parseLinkDependencies(t){let r=[],a;if(!this.platform_id.startsWith("verilog")){let l=/^\s*([;]|[/][/])#link\s+"(.+?)"/gm;for(;a=l.exec(t);)this.pushAllFiles(r,a[2])}return r}loadFileDependencies(t){let r=this.parseIncludeDependencies(t),a=this.parseLinkDependencies(t),l=r.concat(a);return this.loadFiles(l).then(d=>{if(d)for(let g of d)g.link=a.indexOf(g.path)>=0;return d})}okToSend(){return this.pendingWorkerMessages++==0&&this.mainPath!=null}updateFileInStore(t,r){this.filesystem.setFileData(t,r)}buildWorkerMessage(t){this.preloadWorker(this.mainPath);var r={updates:[],buildsteps:[]},a=this.stripLocalPath(this.mainPath),l=this.getFile(this.mainPath),d=[];r.updates.push({path:a,data:l}),this.filename2path[a]=this.mainPath;let y=this.getToolForFilename(this.mainPath).startsWith("remote:");for(var b of t)(!b.link||y)&&(r.updates.push({path:b.filename,data:b.data}),d.push(b.filename)),this.filename2path[b.filename]=b.path;r.buildsteps.push({path:a,files:[a].concat(d),platform:this.platform_id,tool:this.getToolForFilename(this.mainPath),mainfile:!0});for(var b of t)b.data&&b.link&&(this.preloadWorker(b.filename),r.updates.push({path:b.filename,data:b.data}),r.buildsteps.push({path:b.filename,files:[b.filename].concat(d),platform:this.platform_id,tool:this.getToolForFilename(b.path)}));return this.dataItems&&(r.setitems=this.dataItems),r}async loadFiles(t){var r=[],a=(g,y)=>{r.push({path:g,filename:this.stripLocalPath(g),link:!0,data:y})};for(var l of t)if(l in this.filedata){var d=this.filedata[l];d&&a(l,d)}else{var d=await this.filesystem.getFileData(l);d?(this.filedata[l]=d,a(l,d)):this.filedata[l]=null}return r}getFile(t){return this.filedata[t]}iterateFiles(t){for(var r in this.filedata)t(r,this.getFile(r))}sendBuild(){if(!this.mainPath)throw Error("need to call setMainFile first");var t=this.getFile(this.mainPath);if(t instanceof Uint8Array){this.isCompiling=!0,this.receiveWorkerMessage({output:t,errors:[],listings:null,symbolmap:null,params:{}});return}var r=typeof t=="string"?t:"";return this.loadFileDependencies(r).then(a=>{a||(a=[]);var l=this.buildWorkerMessage(a);this.worker.postMessage(l),this.isCompiling=!0})}updateFile(t,r){this.filedata[t]!=r&&(this.updateFileInStore(t,r),this.filedata[t]=r,this.okToSend()&&(this.callbackBuildStatus&&this.callbackBuildStatus(!0),this.sendBuild()))}setMainFile(t){this.mainPath=t,this.callbackBuildStatus&&this.callbackBuildStatus(!0),this.sendBuild()}processBuildListings(t){if(t.listings){this.listings=t.listings;for(var r in this.listings){var a=this.listings[r];a.lines&&(a.sourcefile=new fn(a.lines,a.text)),a.asmlines&&(a.assemblyfile=new fn(a.asmlines,a.text))}}}processBuildResult(t){this.processBuildListings(t),this.processBuildSegments(t)}processBuildSegments(t){var r=this.platform.getMemoryMap&&this.platform.getMemoryMap().main||[];(r==null?void 0:r.length)&&r.forEach(a=>a.source="native"),t.segments&&(t.segments.forEach(a=>a.source="linker"),r=r.concat(t.segments||[])),r.sort((a,l)=>a.start-l.start),this.segments=r}getListings(){return this.listings}getListingForFile(t){var r=Je(this.stripLocalPath(t)),a=this.getListings();for(var l in a)if(l==t)return a[l];for(var l in a)if(Je(l)==r)return a[l]}stripLocalPath(t){if(this.mainPath){var r=sa(this.mainPath);r!=""&&t.startsWith(r+"/")&&(t=t.substring(r.length+1))}return t}updateDataItems(t){this.dataItems=t,this.okToSend()&&this.sendBuild()}};function dn(u){var t=Ls.default.createInstance({name:"__"+u,version:2});return t}var ya=Ms(),xa=class{constructor(t,r){this.id2window={};this.id2createfn={};this.id2showfn={};this.id2div={};this.containerdiv=t,this.project=r,this.undofiles=[]}isWindow(t){return this.id2createfn[t]!=null}setCreateFunc(t,r){this.id2createfn[t]=r}setShowFunc(t,r){this.id2showfn[t]=r}create(t){var r=this.id2window[t];r||(console.log("creating window",t),r=this.id2window[t]=this.id2createfn[t](t));var a=this.id2div[t];return a||(a=this.id2div[t]=r.createDiv(this.containerdiv),ya(a).hide()),r}createOrShow(t,r){var a=this.create(t),l=this.id2div[t];return this.activewnd!=a?(this.activediv&&ya(this.activediv).hide(),this.activewnd&&this.activewnd.setVisible&&this.activewnd.setVisible(!1),this.activediv=l,this.activewnd=a,ya(l).show(),this.refresh(!0),this.refreshErrors(),a.setVisible&&a.setVisible(!0),this.id2showfn[t]&&this.id2showfn[t](t,a)):this.refresh(r),this.activeid=t,a}put(t,r){this.id2window[t]=r}refresh(t){this.activewnd&&this.activewnd.refresh&&this.activewnd.refresh(t)}tick(){this.activewnd&&this.activewnd.tick&&this.activewnd.tick()}setErrors(t){this.lasterrors=t,this.refreshErrors()}refreshErrors(){this.activewnd&&this.activewnd.markErrors&&(this.lasterrors&&this.lasterrors.length?this.activewnd.markErrors(this.lasterrors):this.activewnd.clearErrors())}getActive(){return this.activewnd}getActiveID(){return this.activeid}getCurrentText(){if(this.activewnd&&this.activewnd.getValue)return this.activewnd.getValue();bootbox.alert("Please switch to an editor window.")}resize(){this.activeid&&this.activewnd&&this.activewnd.recreateOnResize&&(this.activewnd=null,this.id2window[this.activeid]=null,this.id2div[this.activeid]=null,this.createOrShow(this.activeid))}updateFile(t,r){var a=this.id2window[t];a&&a.setText&&typeof r=="string"?(a.setText(r),this.undofiles.push(t)):this.project.updateFile(t,r)}undoStep(){var t=this.undofiles.pop(),r=this.id2window[t];r&&r.undoStep?r.undoStep():bootbox.alert("No more steps to undo.")}updateAllOpenWindows(t){for(var r in this.id2window){var a=this.id2window[r];a&&a.setText&&t.getItem(r).then(l=>{this.updateFile(r,l)})}}findWindowWithFilePrefix(t){t=lt(Je(t));for(var r in this.id2createfn)if(!(r.toLowerCase().endsWith(".h")||r.toLowerCase().endsWith(".inc")||r.toLowerCase().endsWith(".bas"))&&lt(Je(r))==t)return r;return null}};var hl=`$NAME
=====
[Open this project in 8bitworkshop](http://8bitworkshop.com/redir.html?platform=$PLATFORM&githubURL=$GITHUBURL&file=$MAINFILE).
`;function Nr(){for(var u={},t=0;t<localStorage.length;t++){var r=localStorage.key(t);if(r.startsWith("__repo__")){var a=JSON.parse(localStorage.getItem(r)),l=r.substring("__repo__".length);u[l]=a}}return u}function ci(u){var t=u.split("/",8);return t.length<5||t[0]!="https:"||t[2]!="github.com"||t[5]&&t[5]!="tree"?null:{user:t[3],repo:t[4],repopath:t[3]+"/"+t[4],branch:t[6],subtreepath:t[7]}}var wa=class{constructor(t,r,a,l){this.githubCons=t,this.githubToken=r,this.store=a,this.project=l,this.recreateGithub()}recreateGithub(){this.github=new this.githubCons({token:this.githubToken})}login(){if(this.githubToken&&this.githubToken.length)return new Promise((r,a)=>{r()});var t=new firebase.auth.GithubAuthProvider;return t.addScope("repo"),firebase.auth().signInWithPopup(t).then(r=>{this.githubToken=r.credential.accessToken;var a=r.user;this.recreateGithub(),document.cookie="__github_key="+this.githubToken+";path=/;max-age=31536000",console.log("Stored GitHub OAUTH key")})}logout(){return this.githubToken&&this.githubToken.length?firebase.auth().signOut().then(()=>{document.cookie="__github_key=;path=/;max-age=0",this.githubToken=null,this.recreateGithub()}):new Promise((t,r)=>{t()})}isFileIgnored(t){return t=t.toUpperCase(),!!(t.startsWith("LICENSE")||t.startsWith("README")||t.startsWith("."))}async getGithubSession(t){var r=ci(t);if(!r)throw new Error("Please enter a valid GitHub URL.");var a=Nr()[r.repopath],l=r.branch||a&&a.branch,d=this.github.repos(r.user,r.repo);try{l=(await d.fetch()).defaultBranch||"master"}catch(y){console.log("could not fetch default branch: "+y),l="main"}console.log("branch =",l);var g={url:t,user:r.user,reponame:r.repo,repopath:r.repopath,branch:l,subtreepath:r.subtreepath,prefix:"",repo:d,platform_id:this.project?this.project.platform_id:a?a.platform_id:null};return g}getGithubHEADTree(t){var r;return this.getGithubSession(t).then(a=>(r=a,r.repo.git.refs.heads(r.branch).fetch())).then(a=>(r.head=a,r.sha=a.object.sha,r.repo.git.trees(r.sha).fetch())).then(a=>{if(r.subtreepath){for(let l of a.tree)if(l.type=="tree"&&l.path==r.subtreepath&&l.sha)return r.repo.git.trees(l.sha).fetch();throw Error("Cannot find subtree '"+r.subtreepath+"' in tree "+a.sha)}return a}).then(a=>(r.tree=a,r))}bind(t,r){var a="__repo__"+t.repopath;if(r){var l={url:t.url,branch:t.branch,platform_id:t.platform_id,mainPath:t.mainPath,sha:t.sha};console.log("storing",l),localStorage.setItem(a,JSON.stringify(l))}else localStorage.removeItem(a)}import(t){var r;return this.getGithubSession(t).then(a=>(r=a,r.repo.contents("README.md").read())).catch(a=>(console.log(a),console.log("no README.md found"),r.repo.fetch().then(l=>""))).then(a=>{var l;if(l=/8bitworkshop.com[^)]+file=([^)&]+)/.exec(a),l&&l[1]&&(console.log("main path: '"+l[1]+"'"),r.mainPath=l[1]),l=/8bitworkshop.com[^)]+platform=([A-Za-z0-9._\-]+)/.exec(a),l){if(console.log("platform id: '"+l[1]+"'"),r.platform_id&&!r.platform_id.startsWith(l[1]))throw Error("Platform mismatch: Repository is "+l[1]+", you have "+r.platform_id+" selected.");r.platform_id=l[1]}return this.bind(r,!0),r})}pull(t,r){var a;return this.getGithubHEADTree(t).then(l=>{a=l;let d=[];return a.paths=[],a.tree.tree.forEach(g=>{if(console.log(g.path,g.type,g.size),a.paths.push(g.path),g.type=="blob"&&!this.isFileIgnored(g.path)){var y=a.repo.git.blobs(g.sha).fetch().then(b=>{var D=a.prefix+g.path,W=g.size,ae=b.encoding,U=b.content;if(b.encoding=="base64"){var O=rn(atob(U)),B=gr(g.path,O);U=B?O:an(O)}return b.size!=U.length&&(U=U.slice(0,b.size)),(r||this.store).setItem(D,U)});d.push(y)}else console.log("ignoring "+g.path)}),Promise.all(d)}).then(l=>a)}importAndPull(t){return this.import(t).then(r=>this.pull(t))}publish(t,r,a,l){var d,g=this.project.platform_id,y=this.project.stripLocalPath(this.project.mainPath);return this.github.user.repos.create({name:t,description:r,private:l,auto_init:!1,license_template:a}).then(b=>{d=b;var D=hl;D=D.replace(/\$NAME/g,encodeURIComponent(t)),D=D.replace(/\$PLATFORM/g,encodeURIComponent(g)),D=D.replace(/\$GITHUBURL/g,encodeURIComponent(d.htmlUrl)),D=D.replace(/\$MAINFILE/g,encodeURIComponent(y));var W={message:"8bitworkshop: updated metadata in README.md",content:btoa(D)};return d.contents("README.md").add(W)}).then(()=>this.getGithubSession(d.htmlUrl))}commit(t,r,a){var l;return r||(r="updated from 8bitworkshop.com"),this.getGithubHEADTree(t).then(d=>{if(l=d,l.subtreepath)throw Error("Sorry, right now you can only commit files to the root directory of a repository.");return Promise.all(a.map(g=>typeof g.data=="string"?l.repo.git.blobs.create({content:g.data,encoding:"utf-8"}):l.repo.git.blobs.create({content:btoa(nn(g.data)),encoding:"base64"})))}).then(d=>l.repo.git.trees.create({tree:a.map((g,y)=>({path:g.path,mode:"100644",type:"blob",sha:d[y].sha})),base_tree:l.tree.sha})).then(d=>l.repo.git.commits.create({message:r,tree:d.sha,parents:[l.head.object.sha]})).then(d=>l.repo.commits(d.sha).fetch()).then(d=>(l.commit=d,l))}push(t){return t.head.update({sha:t.commit.sha}).then(r=>t)}deleteRepository(t){return this.getGithubSession(t).then(r=>r.repo.remove())}};var fi=window.matchMedia&&window.matchMedia("only screen and (max-width: 760px)").matches;function Ut(u,t){var r=$(document.createElement("div"));return u&&r.appendTo(u),t&&r.addClass(t),r}function Ns(u,t){var r=u.charCoords({line:t,ch:0},"local").top,a=u.getScrollerElement().offsetHeight/2;u.scrollTo(null,r-a-5)}function Os(u,t){var r=document.createElement("span");return r.setAttribute("class",t),r.appendChild(document.createTextNode(u)),r}var pn=64,pl=200,Ea={default:{theme:"mbo"},"6502":{isAsm:!0},z80:{isAsm:!0},jsasm:{isAsm:!0},gas:{isAsm:!0},vasm:{isAsm:!0},inform6:{theme:"cobalt"},markdown:{lineWrap:!0},fastbasic:{noGutters:!0},basic:{noLineNumbers:!0,noGutters:!0},ecs:{theme:"mbo",isAsm:!0}},$s={input:null},di=class{constructor(t,r){this.updateTimer=null;this.dirtylisting=!0;this.errormsgs=[];this.errorwidgets=[];this.errormarks=[];this.refreshDelayMsec=300;this.path=t,this.mode=r}createDiv(t){var r=document.createElement("div");r.setAttribute("class","editor"),t.appendChild(r);var a=de.getFile(this.path),l=a&&this.mode=="verilog"&&/__asm\b([\s\S]+?)\b__endasm\b/.test(a);return this.newEditor(r,l),a&&(this.setText(a),this.editor.setSelection({line:0,ch:0},{line:0,ch:0},{scroll:!0})),this.setupEditor(),de.getToolForFilename(this.path).startsWith("remote:")&&(this.refreshDelayMsec=1e3),r}setVisible(t){t&&this.editor.focus()}newEditor(t,r){var a=Ea[this.mode]||Ea.default,l=r||a.isAsm,d=!!a.lineWrap,g=a.theme||Ea.default.theme,y=!a.noLineNumbers&&!fi;Z.embed&&(y=!1,l=!1);var b=["CodeMirror-linenumbers","gutter-offset","gutter-info"];l&&(b=["CodeMirror-linenumbers","gutter-offset","gutter-bytes","gutter-clock","gutter-info"]),(a.noGutters||fi)&&(b=["gutter-info"]),this.editor=CodeMirror(t,{theme:g,lineNumbers:y,matchBrackets:!0,tabSize:8,indentAuto:!0,lineWrapping:d,gutters:b})}editorChanged(){clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{de.updateFile(this.path,this.editor.getValue())},this.refreshDelayMsec),this.markHighlight&&(this.markHighlight.clear(),this.markHighlight=null)}setupEditor(){this.editor.on("changes",(t,r)=>{this.editorChanged()}),this.editor.on("cursorActivity",t=>{this.inspectUnderCursor()}),this.editor.on("gutterClick",(t,r)=>{this.toggleBreakpoint(r)}),this.editor.setOption("mode",this.mode),this.editor.on("beforeChange",(t,r)=>{$s.input&&r.text&&(r.text=r.text.map($s.input))})}inspectUnderCursor(){var t=this.editor.getCursor(!0),r=this.editor.getCursor(!1);if(t.line==r.line&&t.ch<r.ch&&r.ch-t.ch<80){var a=this.editor.getSelection();this.inspect(a)}else this.inspect(null)}inspect(t){var r;if(P.inspect&&(r=P.inspect(t)),this.inspectWidget&&(this.inspectWidget.clear(),this.inspectWidget=null),r){var a=Os(r,"tooltipinfoline"),l=this.editor.getCursor().line;this.inspectWidget=this.editor.addLineWidget(l,a,{above:!1})}}setText(t){var r,a,l=this.editor.getValue();l!=t&&(this.editor.setValue(t),l==""&&this.editor.clearHistory())}insertText(t){var r=this.editor.getCursor();this.editor.replaceRange(t,r,r)}highlightLines(t,r){var a="hilite-span",l={className:a,inclusiveLeft:!0};this.markHighlight=this.editor.markText({line:t,ch:0},{line:r,ch:0},l),this.editor.scrollIntoView({from:{line:t,ch:0},to:{line:r,ch:0}})}replaceSelection(t,r,a){this.editor.setSelection(this.editor.posFromIndex(t),this.editor.posFromIndex(r)),this.editor.replaceSelection(a)}getValue(){return this.editor.getValue()}getPath(){return this.path}addError(t){if(!t.path||this.path.endsWith(t.path)){var r=this.editor.lineCount(),a=t.line-1;if((isNaN(a)||a<0||a>=r)&&(a=0),this.addErrorMarker(a,t.msg),t.start!=null){var l={className:"mark-error",inclusiveLeft:!0},d={line:a,ch:t.end?t.start:t.start-1},g={line:a,ch:t.end?t.end:t.start},y=this.editor.markText(d,g,l);this.errormarks.push(y)}}}addErrorMarker(t,r){var a=document.createElement("div");a.setAttribute("class","tooltipbox tooltiperror"),a.appendChild(document.createTextNode("\u24CD")),this.editor.setGutterMarker(t,"gutter-info",a),this.errormsgs.push({line:t,msg:r}),$(a).mouseover(l=>{this.expandErrors()})}addErrorLine(t,r){var a=Os(r,"tooltiperrorline");this.errorwidgets.push(this.editor.addLineWidget(t,a))}expandErrors(){for(var t;t=this.errormsgs.shift();)this.addErrorLine(t.line,t.msg)}markErrors(t){this.clearErrors(),t=t.slice(0,pl);for(var r of t)this.addError(r)}clearErrors(){for(this.dirtylisting=!0,this.editor.clearGutter("gutter-info"),this.errormsgs=[];this.errorwidgets.length;)this.errorwidgets.shift().clear();for(;this.errormarks.length;)this.errormarks.shift().clear()}getSourceFile(){return this.sourcefile}updateListing(){this.clearErrors(),this.editor.clearGutter("gutter-bytes"),this.editor.clearGutter("gutter-offset"),this.editor.clearGutter("gutter-clock");var t=this.sourcefile.lines||[];for(var r of t)if(r.offset>=0&&this.setGutter("gutter-offset",r.line-1,Ae(r.offset&65535,4)),r.insns){var a=r.insns.length>9?"...":r.insns;if(this.setGutter("gutter-bytes",r.line-1,a),r.iscode){if(r.cycles)this.setGutter("gutter-clock",r.line-1,r.cycles+"");else if(P.getOpcodeMetadata){var l=parseInt(r.insns.split(" ")[0],16),d=P.getOpcodeMetadata(l,r.offset);if(d&&d.minCycles){var g=d.minCycles+"";this.setGutter("gutter-clock",r.line-1,g)}}}}}setGutter(t,r,a){var l=this.editor.lineInfo(r);if(!(l&&l.gutterMarkers&&l.gutterMarkers[t])){var d=document.createTextNode(a);this.editor.setGutterMarker(r,t,d)}}setGutterBytes(t,r){this.setGutter("gutter-bytes",t-1,r)}setTimingResult(t){if(this.editor.clearGutter("gutter-bytes"),this.sourcefile!=null)for(let d of Object.keys(this.sourcefile.line2offset)){let g=this.sourcefile.line2offset[d],y=t.pc2clockrange[g];var r=y&&y.minclocks,a=y&&y.maxclocks;if(r>=0&&a>=0){var l;a==r?l=r+"":l=r+"-"+a,a==t.MAX_CLOCKS&&(l+="+"),this.setGutterBytes(parseInt(d),l)}}}setCurrentLine(t,r){var a=P.isBlocked&&P.isBlocked(),l=y=>{var b=document.createElement("div"),D=a?"currentpc-marker-blocked":"currentpc-marker";b.classList.add(D),b.appendChild(document.createTextNode("\u25B6")),this.editor.setGutterMarker(y.line-1,"gutter-info",b)};if(this.clearCurrentLine(r),t){l(t),r&&this.editor.setCursor({line:t.line-1,ch:t.start||0},{scroll:!0});var d=a?"currentpc-span-blocked":"currentpc-span",g={className:d,inclusiveLeft:!0};t.start||t.end?this.markCurrentPC=this.editor.markText({line:t.line-1,ch:t.start},{line:t.line-1,ch:t.end||t.start+1},g):this.markCurrentPC=this.editor.markText({line:t.line-1,ch:0},{line:t.line,ch:0},g),this.currentDebugLine=t}}clearCurrentLine(t){this.currentDebugLine&&(this.editor.clearGutter("gutter-info"),t&&this.editor.setSelection(this.editor.getCursor()),this.currentDebugLine=null),this.markCurrentPC&&(this.markCurrentPC.clear(),this.markCurrentPC=null)}getActiveLine(){if(this.sourcefile){var t=nr&&nr.c;if(!t&&P.getCPUState&&!P.isRunning()&&(t=P.getCPUState()),t){var r=t&&(t.EPC||t.PC),a=this.sourcefile.findLineForOffset(r,pn);return a}}}refreshDebugState(t){this.clearCurrentLine(t);var r=this.getActiveLine();r&&this.setCurrentLine(r,t)}refreshListing(){var t=de.getListingForFile(this.path);t&&t.sourcefile&&t.sourcefile!==this.sourcefile&&(this.sourcefile=t.sourcefile,this.dirtylisting=!0),!(!this.sourcefile||!this.dirtylisting)&&(this.updateListing(),this.dirtylisting=!1)}refresh(t){this.refreshListing(),this.refreshDebugState(t)}tick(){this.refreshDebugState(!1)}getLine(t){return this.editor.getLine(t-1)}getCurrentLine(){return this.editor.getCursor().line+1}getCursorPC(){for(var t=this.getCurrentLine();this.sourcefile&&t>=0;){var r=this.sourcefile.line2offset[t];if(r>=0)return r;t--}return-1}undoStep(){this.editor.execCommand("undo")}toggleBreakpoint(t){if(this.sourcefile!=null){var r=this.sourcefile.line2offset[t+1];hi(r)}}},_a=1024,gn=class{getDisasmView(){return this.disasmview}createDiv(t){var r=document.createElement("div");return r.setAttribute("class","editor"),t.appendChild(r),this.newEditor(r),r}newEditor(t){this.disasmview=CodeMirror(t,{mode:"z80",theme:"cobalt",tabSize:8,readOnly:!0,styleActiveLine:!0})}refresh(t){let r=nr||P.saveState(),a=r.c?r.c.PC:0,l=0,d=0,g=P.debugSymbols&&P.debugSymbols.addr2symbol||{},y=(W,ae)=>{let U="",O=0;for(;O<ae;){let B=W+O|0,oe=P.disassemble(B,P.readAddress.bind(P)),Y="",ge="";for(let _e=0;_e<oe.nbytes;_e++)Y+=Ae(P.readAddress(B+_e));for(;Y.length<14;)Y+=" ";let Te=oe.line;if(g&&oe.isaddr&&(Te=Te.replace(/([^#])[$]([0-9A-F]+)/,(_e,...$e)=>{let s=parseInt($e[1],16),se=g[s];return se?$e[0]+se:(se=g[s-1],se?$e[0]+se+"+1":_e)})),g){let _e=g[B];_e&&(ge="; "+_e)}U+=Ae(B,4)+" "+oi(Y,14)+" "+oi(Te,30)+ge+`
`,B==a&&(d=l),l++,O+=oe.nbytes||1}return U};var b=a<0?a-_a:Math.max(0,a-_a);let D=y(b,a-b)+y(a,_a);this.disasmview.setValue(D),t&&this.disasmview.setCursor(d,0),Ns(this.disasmview,d)}getCursorPC(){var t=this.disasmview.getCursor().line;if(t>=0){var r=this.disasmview.getLine(t).trim().split(/\s+/);if(r&&r.length>=1){var a=parseInt(r[0],16);if(a>=0)return a}}return-1}},Sa=class extends gn{constructor(t){super();this.path=t}refreshListing(){var t=de.getListingForFile(this.path);this.assemblyfile=t&&(t.assemblyfile||t.sourcefile)}refresh(t){if(this.refreshListing(),!!this.assemblyfile){var r=this.assemblyfile.text,a=this.getDisasmView();if(a.setValue(r),!!P.saveState){var l=nr||P.saveState(),d=l.c?l.c.EPC||l.c.PC:0;if(d>=0&&this.assemblyfile){var g=this.assemblyfile.findLineForOffset(d,pn);g&&(t&&a.setCursor(g.line-1,0),Ns(a,g.line-1))}}}}};function Ws(u){return u.endsWith("_SIZE__")||u.endsWith("_LAST__")||u.endsWith("STACKSIZE__")||u.endsWith("FILEOFFS__")||u.startsWith("l__")||u.startsWith("s__")||u.startsWith(".__.")}var mn=class{constructor(){this.recreateOnResize=!0;this.hibits=0;this.totalRows=5120}createDiv(t){var r=document.createElement("div");return r.setAttribute("class","memdump"),t.appendChild(r),this.showMemoryWindow(t,r),this.maindiv=r}showMemoryWindow(t,r){this.memorylist=new Es({w:$(t).width(),h:$(t).height(),itemHeight:Ss(),totalRows:this.totalRows,generatorFn:l=>{var d=this.getMemoryLineAt(l),g=document.createElement("div");if(this.dumplines){var y=this.dumplines[l];y&&g.classList.add("seg_"+this.getMemorySegment(this.dumplines[l].a|this.hibits))}return g.appendChild(document.createTextNode(d)),g}}),$(r).append(this.memorylist.container),this.tick();let a=pi();a&&this.dumplines&&this.scrollToAddress(a.data_start)}scrollToAddress(t){this.dumplines&&(this.hibits=t&4294901760,this.memorylist.scrollToItem(this.findMemoryWindowLine(t&65535)))}refresh(){this.dumplines=null,this.tick()}tick(){this.memorylist&&$(this.maindiv).find("[data-index]").each((t,r)=>{var a=$(r),l=parseInt(a.attr("data-index")),d=a.text(),g=this.getMemoryLineAt(l);d!=g&&a.text(g)})}getMemoryLineAt(t){var r=t*16,a=0,l=16,d;if(this.getDumpLines()){var g=this.dumplines[t];if(g)r=g.a&65520,a=g.a-r,l=a+g.l,d=g.s;else return"."}for(var y=Ae(r+a,4)+" ",b=0;b<a;b++)y+=" ";a>8&&(y+=" ");for(var b=a;b<l;b++){var D=this.readAddress(r+b|this.hibits);b==8&&(y+=" "),y+=" "+(typeof D=="number"?Ae(D,2):"??")}for(var b=l;b<16;b++)y+=" ";return d&&(y+=" "+d),y}readAddress(t){return P.readAddress(t)}getDumpLineAt(t){var r=this.dumplines[t];if(r)return r.a+" "+r.s}getDumpLines(){var t=P.debugSymbols&&P.debugSymbols.addr2symbol||{};if(this.dumplines==null){this.dumplines=[];var r=0,a;for(let y of Object.keys(t)){var l=parseInt(y),d=t[l|this.hibits];if(a)for(Ws(a)&&(a="");r<l&&this.dumplines.length<65536;){var g=r+16&1048560;g>l&&(g=l),this.dumplines.push({a:r,l:g-r,s:a}),r=g}a=d}}return this.dumplines}getMemorySegment(t){let r=pi();if(r){if(t>=r.data_start&&t<r.data_start+r.data_size)return P.getSP&&t>=P.getSP()-15?"stack":"data";if(t>=r.code_start&&t<r.code_start+(r.code_size||r.rom_size))return"code"}var a=de.segments;if(a){for(var l of a)if(t>=l.start&&t<l.start+l.size){if(l.type=="rom")return"code";if(l.type=="ram")return"data";if(l.type=="io")return"io"}}return"unknown"}findMemoryWindowLine(t){for(var r=0;r<this.dumplines.length;r++)if(this.dumplines[r].a>=t)return r}},Ta=class extends mn{constructor(){super(...arguments);this.totalRows=2048}readAddress(t){return P.readVRAMAddress(t)}getMemorySegment(t){return"video"}getDumpLines(){return null}},Ca=class{constructor(t,r){this.recreateOnResize=!0;this.path=t,this.data=r}createDiv(t){return this.vlist=new li(t),this.vlist.create(t,this.data.length+15>>4,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){for(var r=t*16,a=0,l=16,d=Ae(r+a,4)+" ",g=0;g<a;g++)d+=" ";a>8&&(d+=" ");for(var g=a;g<l;g++){var y=this.data[r+g];g==8&&(d+=" "),d+=" "+(y>=0?Ae(y,2):" ")}return{text:d}}refresh(){this.vlist.refresh()}getPath(){return this.path}},Pa=class{createDiv(t){return this.maindiv=Ut(t,"vertical-scroll"),this.maindiv.css("display","grid"),this.maindiv.css("grid-template-columns","5em 40% 40%"),this.maindiv.css("align-content","start"),this.maindiv[0]}addSegment(t,r){if(r){var a=$('<div class="segment-offset" style="grid-column-start:1"/>');a.text("$"+Ae(t.start,4)),this.maindiv.append(a)}var l=$('<div class="segment"/>');l.text(t.name);let d=`$${Ae(t.start)} - $${Ae(t.last||t.start+t.size-1)}`;d+=` (${t.size} bytes)`,l.attr("title",d),(!r||t.source=="linker")&&l.css("grid-column-start",3);var g=Math.max(3,Math.log(t.size+1))*.5;l.css("height",g+"em"),t.type&&l.addClass("segment-"+t.type),this.maindiv.append(l),l.click(()=>{var y=ue.createOrShow("#memory");y.scrollToAddress(t.start)})}refresh(){this.maindiv.empty();var t=de.segments;if(t){var r=0,a=-1;for(var l of t)l.start>r&&this.addSegment({name:"",start:r,size:l.start-r},!0),this.addSegment(l,a!=l.start),a=l.start,r=l.start+l.size}}},St=4278190080,mr=class{constructor(){this.cumulativeData=!1;var t=160,r=262;try{t=Math.ceil(P.machine.cpuCyclesPerLine)||t,r=Math.ceil(P.machine.numTotalScanlines)||r}catch(a){}this.cyclesPerLine=t,this.totalScanlines=r}addr2symbol(t){var r=P.debugSymbols&&P.debugSymbols.addr2symbol||{};return r[t]}addr2str(t){var r=this.addr2symbol(t);return typeof r=="string"?"$"+Ae(t)+" ("+r+")":"$"+Ae(t)}showTooltip(t){t?(this.tooldiv||(this.tooldiv=document.createElement("div"),this.tooldiv.setAttribute("class","tooltiptrack"),document.body.appendChild(this.tooldiv)),$(this.tooldiv).text(t).show()):$(this.tooldiv).hide()}setVisible(t){t?(this.probe=P.startProbing(),this.probe.singleFrame=!this.cumulativeData,this.tick()):(this.probe&&(this.probe.singleFrame=!0),P.stopProbing(),this.probe=null)}redraw(t){var r=this.probe;if(!(!r||!r.idx)){var a=0,l=0,d=0;this.sp=0;for(var g=0;g<r.idx;g++){var y=r.buf[g],b=y&65535,D=y>>16&255,W=y&St;switch(W){case K.SCANLINE:a++,l=0;break;case K.FRAME:a=0,l=0;break;case K.CLOCKS:l+=b,d+=b;break;case K.SP_PUSH:case K.SP_POP:this.sp=b;default:t(W,b,l,a,d,D);break}}}}opToString(t,r,a){var l="";switch(t){case K.EXECUTE:l="Exec";break;case K.MEM_READ:l="Read";break;case K.MEM_WRITE:l="Write";break;case K.IO_READ:l="IO Read";break;case K.IO_WRITE:l="IO Write";break;case K.VRAM_READ:l="VRAM Read";break;case K.VRAM_WRITE:l="VRAM Write";break;case K.DMA_READ:l="DMA Read";break;case K.DMA_WRITE:l="DMA Write";break;case K.INTERRUPT:l="Interrupt";break;case K.ILLEGAL:l="Error";break;case K.WAIT:l="Wait";break;case K.SP_PUSH:l="Stack Push";break;case K.SP_POP:l="Stack Pop";break;default:return""}return typeof r=="number"&&(l+=" "+this.addr2str(r)),t&K.HAS_VALUE&&typeof a=="number"&&(l+=" = $"+Ae(a,2)),l}getOpRGB(t,r){switch(t){case K.EXECUTE:return 98305;case K.MEM_READ:return 8388865;case K.MEM_WRITE:return 65920;case K.IO_READ:return 98432;case K.IO_WRITE:return 12583296;case K.DMA_READ:case K.VRAM_READ:return 8421377;case K.DMA_WRITE:case K.VRAM_WRITE:return 4227264;case K.INTERRUPT:return 4177727;case K.ILLEGAL:return 4145151;case K.WAIT:return 16727871;default:return 0}}},js=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0}createCanvas(t,r,a){var l=document.createElement("div"),d=document.createElement("canvas");return d.width=r,d.height=a,d.classList.add("pixelated"),d.style.width="100%",d.style.height="90vh",d.style.backgroundColor="black",d.style.cursor="crosshair",d.onmousemove=g=>{var y=un(d,g);this.showTooltip(this.getTooltipText(y.x,y.y)),$(this.tooldiv).css("left",g.pageX+10).css("top",g.pageY-30)},d.onmouseout=g=>{$(this.tooldiv).hide()},t.appendChild(l),l.appendChild(d),this.canvas=d,this.ctx=d.getContext("2d"),this.initCanvas(),this.maindiv=l}initCanvas(){}getTooltipText(t,r){return null}getOpAtPos(t,r,a){t=t|0,r=r|0;let l=0;return this.redraw((d,g,y,b,D,W)=>{!l&&b==r&&y>=t&&(d&a)!=0&&(l=d|g)}),l}clear(){}tick(){this.clear(),this.redraw(this.drawEvent.bind(this))}},ka=class extends js{constructor(){super(...arguments);this.recreateOnResize=!1}createDiv(t){return this.createCanvas(t,this.cyclesPerLine,this.totalScanlines)}initCanvas(){this.imageData=this.ctx.createImageData(this.canvas.width,this.canvas.height),this.datau32=new Uint32Array(this.imageData.data.buffer)}getTooltipText(t,r){t=t|0,r=r|0;var a="",l=null,d=[],g=-1;return this.redraw((y,b,D,W,ae,U)=>{switch(y){case K.EXECUTE:l=this.addr2symbol(b)||l;break;case K.SP_PUSH:d.push(l);break;case K.SP_POP:l=d.pop();break}W==r&&D<=t&&(D!=g&&(a="",g=D),a==""&&l&&(a+=`
`+l),a+=`
`+this.opToString(y,b,U))}),"X: "+t+" Y: "+r+" "+a}refresh(){this.tick(),this.datau32.fill(St)}tick(){super.tick(),this.drawImage()}drawImage(){this.ctx.putImageData(this.imageData,0,0)}clear(){this.datau32.fill(St)}},Aa=class extends ka{createDiv(t){return this.createCanvas(t,256,256)}initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var r=un(this.canvas,t),a=Math.floor(r.x)+Math.floor(r.y)*256,l=-1,d=-1;this.redraw((g,y)=>{d<0&&l>=0&&y==a&&(d=l),g==K.EXECUTE&&(l=y)}),d>=0&&hi(d)}}clear(){for(var t=0;t<=65535;t++){var r=P.readAddress(t),a=r>>2|r&31;a|=a<<8|a<<16,this.datau32[t]=a|St}}drawEvent(t,r,a,l){var d=this.getOpRGB(t,r);if(!!d){var g=r&255,y=r>>8&255,b=this.datau32[r&65535];b=b|d|St,this.datau32[r&65535]=b}}getTooltipText(t,r){var a=(t&255)+(r<<8),l="",d=-1,g={},y=null,b=[];return this.redraw((D,W,ae,U,O,B)=>{switch(D){case K.EXECUTE:d=W,y=this.addr2symbol(W)||y;break;case K.SP_PUSH:b.push(y);break;case K.SP_POP:y=b.pop();break}var oe=D|d;W==a&&!g[oe]&&(l==""&&y&&(l+=`
`+y),l+=`
PC `+this.addr2str(d)+" "+this.opToString(D,null,B),g[oe]=1)}),this.addr2str(a)+l}},Us=class extends ka{initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var r=un(this.canvas,t),a=Math.floor(r.x),l=Math.floor(r.y),d=this.getOpAtPos(r.x,r.y,K.EXECUTE);d&&(It("toline"),P.runEval(()=>{let g=P.getRasterScanline&&P.getRasterScanline()>=l;return g&&P.getRasterLineClock?g&&P.getRasterLineClock()>a:g}))}}drawEvent(t,r,a,l){var d=this.getOpRGB(t,r);if(!!d){var g=a+l*this.canvas.width,y=d|St;this.datau32[g]|=y}}drawImage(){let t=St;for(let r=0;r<this.datau32.length;r++)this.datau32[r]==St?this.datau32[r]=t:t=this.datau32[r];super.drawImage()}},Da=class extends Us{constructor(){super(...arguments);this.interrupt=0;this.rgb=0;this.lastpc=0}drawEvent(t,r,a,l){var d=a+l*this.canvas.width;if(t==K.INTERRUPT&&(this.interrupt=1),this.interrupt==1&&t==K.SP_PUSH&&(this.interrupt=r),this.interrupt>1&&this.sp>this.interrupt&&(this.interrupt=0),t==K.MEM_WRITE&&(this.rgb|=47),t==K.VRAM_WRITE&&(this.rgb|=16256),t==K.IO_WRITE&&(this.rgb|=2047872),t==K.IO_READ&&(this.rgb|=7936),t==K.WAIT&&(this.rgb=32768),t==K.ILLEGAL||t==K.DMA_READ)this.datau32[d]=4279176975;else{let g=this.rgb;if(t==K.EXECUTE){let y=this.sp&15;y>=8&&(y=16-y),Math.abs(this.lastpc)-r>16&&(y+=1),Math.abs(this.lastpc)-r>256&&(y+=1),g=this.rgb=526344*y+2105376,this.lastpc=r}this.interrupt&&(g|=8388672),this.datau32[d]==St&&(this.datau32[d]=g|St)}}},Fa=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new li(t),this.vlist.create(t,this.cyclesPerLine*this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){var r="",a="seg_data",l=this.dumplines&&this.dumplines[t];if(l!=null){var d=l.info.join(", ");r="("+Lt(l.row,4)+", "+Lt(l.col,4)+") "+oi(l.asm||"",20)+d,d.indexOf("Write ")>=0&&(a="seg_io")}return{text:r,clas:a}}refresh(){this.tick()}tick(){let t=P instanceof fa||P instanceof ca;this.dumplines={},this.redraw((r,a,l,d,g,y)=>{t&&(g>>=2);var b=this.dumplines[g];switch(b==null&&(b={op:r,addr:a,row:d,col:l,asm:null,info:[]},this.dumplines[g]=b),r){case K.EXECUTE:if(P.disassemble){var D=P.disassemble(a,P.readAddress.bind(P));b.asm=D&&D.line}break;default:var W=this.opToString(r,a,y);W!=""&&b.info.push(W);break}}),this.vlist.refresh()}},Ra=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new li(t),this.vlist.create(t,this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){for(var r=Lt(t+"",3)+" ",a="seg_code",l=this.dumplines&&this.dumplines[t]||[],d=Math.round(this.cyclesPerLine/3.3),g=0;g<this.cyclesPerLine;g++){var y=l[g];if(y!==void 0){var b=y&65535,D=D&St;if(D==K.EXECUTE)r+=",";else{var W=Ae(b);r+=W,g+=W.length-1}}else r+=g==d?"|":"."}return l[-1]&&(r+=" "+l[-1]),{text:r,clas:a}}refresh(){this.tick()}tick(){let t=P instanceof fa||P instanceof ca;this.dumplines={},this.redraw((r,a,l,d,g,y)=>{var b=this.dumplines[d];switch(b==null&&(this.dumplines[d]=b=[]),r){case K.EXECUTE:var D=P.debugSymbols.addr2symbol[a];D&&(b[-1]=D);break;case K.IO_READ:case K.IO_WRITE:case K.VRAM_READ:case K.VRAM_WRITE:b[l]=r|a;break}}),this.vlist.refresh()}},La=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0;this.cumulativeData=!0}createDiv(t){return P.debugSymbols&&P.debugSymbols.symbolmap?this.keys=Array.from(Object.keys(P.debugSymbols.symbolmap).filter(r=>!Ws(r))):this.keys=["no symbols defined"],this.vlist=new li(t),this.vlist.create(t,this.keys.length+1,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){if(t==0)return{text:Lt("Symbol",35)+Lt("Reads",8)+Lt("Writes",8)};var r=this.keys[t-1],a=this.dumplines&&this.dumplines[r];function l(y){var b=a[y]|0;return Lt(b?b.toString():"",8)}var d,g;return a!=null?(d=Lt(r,35)+l(K.MEM_READ)+l(K.MEM_WRITE),a[K.EXECUTE]?g="seg_code":a[K.IO_READ]||a[K.IO_WRITE]?g="seg_io":g="seg_data"):(d=Lt(r,35),g="seg_unknown"),{text:d,clas:g}}refresh(){this.tick()}tick(){this.dumplines={},this.redraw((t,r,a,l,d,g)=>{var y=P.debugSymbols.addr2symbol[r];if(y!=null){var b=this.dumplines[y];b==null&&(b={},this.dumplines[y]=b),b[t]=(b[t]|0)+1}}),this.vlist.refresh(),this.probe&&this.probe.clear()}};var Rc=Ps(),vn=/([0#]?)([x$%]|\d'h)([0-9a-f]+)(?:[;].*)?|(\d'b|0b)([01]+)/gim;function gl(u){return u.replace(/(\shex\s+)([0-9a-f]+)/ig,function(t,r,a){for(var l=r,d=0;d<a.length;d+=2)l+="0x"+a.substr(d,2)+",";return l})}function ml(u){for(var t=[],r;r=vn.exec(u);){var a;typeof r[4]!="undefined"?a=parseInt(r[5],2):r[2].startsWith("%")||r[2].endsWith("b")?a=parseInt(r[3],2):r[2].startsWith("x")||r[2].startsWith("$")||r[2].endsWith("h")?a=parseInt(r[3],16):a=parseInt(r[3]),t.push(a)}return t}function vl(u,t){for(var r="",a,l=0,d=0;a=vn.exec(u);)r+=u.slice(l,vn.lastIndex-a[0].length),l=vn.lastIndex,typeof a[4]!="undefined"?r+=a[4]+t[d++].toString(2):a[2].startsWith("%")?r+=a[1]+"%"+t[d++].toString(2):a[2].endsWith("b")?r+=a[1]+a[2]+t[d++].toString(2):a[2].endsWith("h")?r+=a[1]+a[2]+t[d++].toString(16):a[2].startsWith("x")?r+=a[1]+"x"+Ae(t[d++]):a[2].startsWith("$")?r+=a[1]+"$"+Ae(t[d++]):r+=a[1]+t[d++].toString();return r+=u.slice(l),r=r.replace(/(\shex\s+)([,x0-9a-f]+)/ig,(g,y,b)=>{var D=y+b;return D=D.replace(/0x/ig,"").replace(/,/ig,""),D}),r}function Bs(u,t){if(!t)return u;for(var r=0,a=0;a<t.length;a++){var l=t[a];l<0&&(l=-l-1,r^=1<<l),u&1<<a&&(r^=1<<l)}return r}function Hs(u,t){var r=t[u%t.length];return[r>>3,r&7]}function bl(u,t){for(var r=t.w,a=t.h,l=t.count||1,d=t.bpp||1,g=t.np||1,y=t.bpw||8,b=t.sl||Math.ceil(r*d/y),D=(1<<d)-1,W=t.pofs||b*a*l,ae=t.skip||0,U=t.wpimg||b*a,O=[],B=0;B<l;B++){for(var oe=[],Y=0;Y<a;Y++)for(var ge=t.flip?a-1-Y:Y,Te=U*B+ge*b,pe=0,_e=0;_e<r;_e++){var $e=0,s=Bs(Te,t.remap);t.reindex&&([s,pe]=Hs(_e,t.reindex),s+=Te);for(var se=0;se<g;se++){var X=u[s+se*W+ae];$e|=((t.brev?X>>y-pe-d:X>>pe)&D)<<se*d}oe.push($e),pe+=d,pe>=y&&!t.reindex&&(Te+=1,pe=0)}O.push(new Uint8Array(oe))}return O}function yl(u,t){t.destfmt&&(t=t.destfmt);var r=t.w,a=t.h,l=t.count||1,d=t.bpp||1,g=t.np||1,y=t.bpw||8,b=t.sl||Math.ceil(t.w*d/y),D=(1<<d)-1,W=t.pofs||b*a*l,ae=t.skip||0,U=t.wpimg||b*a,O;g>0&&t.sl?O=new Uint8Array(U*l):y<=8?O=new Uint8Array(U*l*g):O=new Uint32Array(U*l*g);for(var B=0;B<l;B++)for(var oe=u[B],Y=0,ge=0;ge<a;ge++)for(var Te=t.flip?a-1-ge:ge,pe=B*U+Te*b,_e=0,$e=0;$e<r;$e++){var s=oe[Y++],se=Bs(pe,t.remap);t.reindex&&([se,_e]=Hs($e,t.reindex),se+=pe);for(var X=0;X<g;X++){var Ce=s>>X*d&D;O[se+X*W+ae]|=t.brev?Ce<<y-_e-d:Ce<<_e}_e+=d,_e>=y&&!t.reindex&&(pe+=1,_e=0)}return O}function zs(u,t,r,a,l,d,g){for(var y=[],b=0;b<u.length;b++){var D=u[b],W=4278190080;W|=(D>>t&(1<<r)-1)<<0+8-r,W|=(D>>a&(1<<l)-1)<<8+8-l,W|=(D>>d&(1<<g)-1)<<16+8-g,y.push(W)}return y}function xl(u){var t=u.pal;if(typeof t=="number"){var r=Math.floor(Math.abs(t/100)%10),a=Math.floor(Math.abs(t/10)%10),l=Math.floor(Math.abs(t)%10);return 1<<r+a+l}else{var d=Gs[t];if(d)return d.length;throw new Error("No palette named "+t)}}function Vs(u,t){var r=t.pal,a;if(typeof r=="number"){var l=Math.floor(Math.abs(r/100)%10),d=Math.floor(Math.abs(r/10)%10),g=Math.floor(Math.abs(r)%10);r>=0?a=zs(u,0,l,l,d,l+d,g):a=zs(u,l+d,g,l,d,0,l)}else{var y=Gs[r];if(y)a=new Uint32Array(u).map(b=>y[b&y.length-1]|4278190080);else throw new Error("No palette named "+r)}return a}var Gs={nes:[5395026,11796480,10485760,11599933,7602281,91,95,6208,12048,543240,26368,1196544,7153664,0,0,0,12899815,16728064,14421538,16729963,14090399,6818519,6588,21681,27227,35843,43776,2918400,10777088,0,0,0,16316664,16755516,16742785,16735173,16730354,14633471,4681215,46327,57599,58229,259115,7911470,15065624,7895160,0,0,16777215,16773822,16300216,16300248,16758527,16761855,13095423,10148607,8973816,8650717,12122296,16119980,16777136,16308472,0,0],ap2lores:[0,16711935,127,8323199,32512,8355711,191,255,12549888,16760576,12566463,16744319,65280,16776960,49023,16777215],vcs:[0,0,4210752,4210752,7105644,7105644,9474192,9474192,11579568,11579568,13158600,13158600,14474460,14474460,16053492,16053492,17476,17476,1074276,1074276,2393220,2393220,3448992,3448992,4241592,4241592,5296336,5296336,6088936,6088936,6880508,6880508,10352,10352,1328260,1328260,2645144,2645144,3963052,3963052,5016764,5016764,6070476,6070476,6862044,6862044,7915756,7915756,6276,6276,1586328,1586328,3166380,3166380,4745408,4745408,6062288,6062288,7378144,7378144,8431852,8431852,9747708,9747708,136,136,2105500,2105500,3947696,3947696,5789888,5789888,7368912,7368912,8947936,8947936,10526956,10526956,11842812,11842812,6029432,6029432,7610508,7610508,8928416,8928416,10246320,10246320,11563200,11563200,12616912,12616912,13671644,13671644,14725356,14725356,7864392,7864392,9445472,9445472,10763384,10763384,12081292,12081292,13398176,13398176,14451892,14451892,15506628,15506628,16560340,16560340,8650772,8650772,9969712,9969712,11287628,11287628,12605544,12605544,13660284,13660284,14715028,14715028,15507624,15507624,16561340,16561340,8912896,8912896,10231836,10231836,11550776,11550776,12606544,12606544,13661288,13661288,14716028,14716028,15508624,15508624,16562340,16562340,8132608,8132608,9451548,9451548,11031608,11031608,12349520,12349520,13404264,13404264,14457980,14457980,15512720,15512720,16566436,16566436,6040576,6040576,7883804,7883804,9463864,9463864,11306064,11306064,12622952,12622952,13939836,13939836,15256720,15256720,16572580,16572580,2898944,2898944,4742172,4742172,6585400,6585400,8428624,8428624,9745512,9745512,11325564,11325564,12641424,12641424,13958308,13958308,15360,15360,2120736,2120736,4226112,4226112,6069340,6069340,7648372,7648372,9228428,9228428,10806436,10806436,12123320,12123320,14356,14356,1858612,1858612,3701840,3701840,5281900,5281900,6861956,6861956,8178844,8178844,9495732,9495732,10812616,10812616,12332,12332,1855564,1855564,3436648,3436648,5016708,5016708,6596764,6596764,7913652,7913652,8967372,8967372,10284256,10284256,10308,10308,1591396,1591396,3172484,3172484,4490400,4490400,5807288,5807288,7124176,7124176,8178920,8178920,9232636,9232636],astrocade:[0,2368548,4737096,7171437,9539985,11974326,14342874,16777215,12255269,14680137,16716142,16725394,16734903,16744155,16753663,16762879,11534409,13959277,16318866,16721334,16730842,16740095,16749311,16758783,10420330,12779662,15138995,16718039,16727291,16736767,16745983,16755199,8847495,11206827,13631696,15994612,16724735,16733951,16743423,16752639,6946975,9306307,11731175,14092287,16461055,16732415,16741631,16751103,4784304,7143637,9568505,11929087,14297599,16731647,16741119,16750335,2425019,4784352,7209215,9570047,12004095,14372863,16741375,16750847,191,2359523,4718847,7146495,9515263,11949311,14318079,16752127,187,224,2294015,4658431,7092735,9461247,11895551,14264063,176,213,249,2367999,4736511,7105279,9539327,11908095,159,195,3303,209151,2577919,4946431,7380735,9749247,135,171,7888,17140,681983,3050495,5484543,7853311,106,3470,12723,22231,31483,1548031,3916799,6285311,73,8557,17810,27318,36570,373759,2742271,5176575,4389,13641,23150,32402,41911,51163,2026495,4456447,9472,18724,27976,37485,46737,56246,1834970,4194303,14080,23296,32803,42055,51564,60816,2031541,4456409,18176,27648,36864,46116,55624,392556,2752401,5177269,21760,30976,40192,49667,58919,1572683,3932016,6291348,24320,33536,43008,52224,716810,3079982,5504851,7864183,25856,35328,44544,250368,2619136,4980503,7405371,9764703,26624,35840,45312,2413824,4782336,7143173,9568041,11927374,26112,35584,2338560,4707328,7141376,9502464,11927326,14286659,24832,2393344,4762112,7196160,9564928,11992832,14352155,16711487,2447360,4815872,7250176,9618688,12052992,14417664,16776990,16777027,4803328,7172096,9606144,11974912,14343424,16776965,16777001,16777038,6962176,9330688,11764992,14133504,16502272,16773655,16777019,16777055,8858112,11226880,13660928,16029440,16759818,16769070,16777043,16777079,10426112,12794624,15163392,16745475,16754727,16764235,16773488,16777108,11534848,13969152,16337664,16740388,16749640,16759148,16768401,16777141,12255232,14684928,16725795,16735047,16744556,16753808,16763317,16772569],c64:[0,16777215,2832232,11707504,8797551,4427096,7940149,7325624,2445167,14659,5859226,4473924,7105644,8704666,11886188,9803157]},wl={nes:[["Screen Color",0,1],["Background 0",1,3],["Background 1",5,3],["Background 2",9,3],["Background 3",13,3],["Sprite 0",17,3],["Sprite 1",21,3],["Sprite 2",25,3],["Sprite 3",29,3]],astrocade:[["Left",0,-4],["Right",4,-4]]};function gi(u,t){if(u==null||t==null||u.length!==t.length)return!1;if(u===t)return!0;for(var r=0;r<u.length;r++)if(u[r]!==t[r])return!1;return!0}function bn(u,t){if(u==null||t==null||u.length!==t.length)return!1;if(u===t)return!0;for(var r=0;r<u.length;r++)if(!gi(u[r],t[r]))return!1;return!0}var Bt=class{refreshLeft(){for(var t=this;t;)t.updateLeft(),t=t.left}refreshRight(){for(var t=this;t;)t.updateRight(),t=t.right}addRight(t){return this.right=t,t.left=this,t}addLeft(t){return this.left=t,t.right=this,t}},Ia=class extends Bt{},yn=class extends Ia{constructor(t,r){super();this.project=t,this.fileid=r,this.label=r}updateLeft(){return this.words=this.right.words,this.project&&this.project.updateFile(this.fileid,this.words),!0}updateRight(){return this.project&&(this.words=this.project.project.getFile(this.fileid)),!0}},Ma=class extends Ia{constructor(t,r,a,l,d){super();this.project=t,this.fileid=r,this.label=a,this.start=l,this.end=d}updateLeft(){if(this.right.words.length!=this.words.length)throw Error("Cannot put "+this.right.words.length+" image bytes into array of "+this.words.length+" bytes");this.words=this.right.words;var t=this.text.substring(this.start,this.end);return t=vl(t,this.words),this.text=this.text.substring(0,this.start)+t+this.text.substring(this.end),this.project&&this.project.updateFile(this.fileid,this.text),!0}updateRight(){this.project&&(this.text=this.project.project.getFile(this.fileid));var t=this.text.substring(this.start,this.end);t=gl(t);var r=ml(t);return this.words=r,!0}},Na=class extends Bt{updateLeft(){return!1}updateRight(){return this.words=ws(new Uint8Array(this.left.words)),!0}},Oa=class extends Bt{constructor(t){super();this.fmt=t}updateLeft(){return this.images=this.right.images,this.words=yl(this.images,this.fmt),!0}updateRight(){return gi(this.words,this.left.words)?!1:(this.words=this.left.words,this.images=bl(this.words,this.fmt),!0)}},qs=class{constructor(t){this.palcols=t}indexOf(t){return this.palcols.indexOf(t)}},Or=class extends Bt{constructor(t,r){super();this.palindex=0;this.context=t,this.ncolors=1<<(r.bpp||1)*(r.np||1)}updateLeft(){this.right&&(this.rgbimgs=this.right.rgbimgs);var t=new qs(this.palette),r=this.rgbimgs.map(a=>{for(var l=new Uint8Array(a.length),d=0;d<a.length;d++)l[d]=t.indexOf(a[d]);return l});return this.images=r,!0}updateRight(){if(!this.updateRefs()&&bn(this.images,this.left.images))return!1;this.images=this.left.images;var t=this.palette.length-1;return this.rgbimgs=this.images.map(r=>{for(var a=new Uint32Array(r.length),l=0;l<r.length;l++)a[l]=this.palette[r[l]&t];return a}),!0}updateRefs(){var t;return this.context!=null&&(this.paloptions=this.context.getPalettes(this.ncolors),this.paloptions&&this.paloptions.length>0&&(t=this.paloptions[this.palindex].palette)),t==null&&(this.ncolors<=2?t=new Uint32Array([4278190080,4294967295]):t=new Uint32Array([4278190080,4294902015,4294967040,4294967295])),gi(this.palette,t)?!1:(this.palette=t,!0)}};function El(u){for(var t=new Map,r=new Uint32Array(u.length),a=0,l=0;l<u.length;l++){for(var d=u[l];t[d];)d^=++a;r[l]=d,t[d]=1}return r}var xn=class extends Bt{constructor(t){super();this.palfmt=t}updateLeft(){return!0}updateRight(){return gi(this.words,this.left.words)?!1:(this.words=this.left.words,this.palette=El(Vs(this.words,this.palfmt)),this.layout=wl[this.palfmt.layout],this.rgbimgs=[],this.palette.forEach(t=>{this.rgbimgs.push(new Uint32Array([t]))}),!0)}getAllColors(){for(var t=[],r=0;r<xl(this.palfmt);r++)t.push(r);return Vs(t,this.palfmt)}},Ys=class extends Bt{constructor(t){super();this.tileindex=0;this.context=t}updateRefs(){var t=this.tilemap;return this.context!=null&&(this.tileoptions=this.context.getTilemaps(256),this.tileoptions&&this.tileoptions.length>0&&(this.tilemap=this.tileoptions[this.tileindex].images)),!bn(t,this.tilemap)}};var $a=class extends Ys{constructor(t){super(t)}updateLeft(){return!1}updateRight(){if(!this.updateRefs()&&gi(this.words,this.left.words))return!1;this.words=this.left.words,this.cols=32,this.rows=30,this.width=this.cols*8,this.height=this.rows*8,this.baseofs=0;var t=new Uint8Array(this.width*this.height);this.images=[t];for(var r=0,a,l=0;l<this.rows;l++)for(var d=0;d<this.cols;d++){var g=this.words[this.baseofs+r];if(typeof g=="undefined")throw Error("No name for address "+this.baseofs+" + "+r);var y=this.tilemap[g];if(!y)throw Error("No tilemap found for tile index "+g);a=r&11264|960|r&3072|r>>4&56|r>>2&7;for(var b=this.words[a],D=g^b<<9^2147483648,W=l*this.cols*8*8+d*8,ae=0,U=(d&2)+((r&64)>>4),O=(b>>U&3)<<2,B=0;B<8;B++){for(var oe=0;oe<8;oe++){var Y=y[ae++];Y&&(Y+=O),t[W++]=Y}W+=this.cols*8-8}r++}return!0}},wn=class{recreate(t,r){var a=$('<div class="asset_grid"/>');t.empty().append(a);var l=Math.max(2,Math.ceil(16/this.width)),d=this.width<=8?16:8,g=null;this.rgbimgs.forEach((y,b)=>{var D=new En;D.width=this.width,D.height=this.height,D.recreate(),D.canvas.style.width=D.width*l+"px",D.canvas.title="$"+Ae(b),D.updateImage(y),$(D.canvas).addClass("asset_cell"),$(D.canvas).click(ae=>{r(b,D)}),g||(g=$("<span/>"),a.append(g)),g.append(D.canvas);var W=b%d==d-1;W&&(a.append($("<br/>")),g=null)})}};function vr(u,t){var r=$(document.createElement("div"));return u&&r.appendTo(u),t&&r.addClass(t),r}var Wa=class extends Bt{constructor(t,r,a){super();this.context=t,this.parentdiv=r,this.fmt=a}updateLeft(){return!0}updateRight(){if(bn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=vr(this.parentdiv.empty(),"asset_dual"),r=vr(t),a=vr(t,"asset_editor").hide(),l=this.chooser=new wn;l.rgbimgs=this.rgbimgs,l.width=this.fmt.w||1,l.height=this.fmt.h||1,l.recreate(r,(y,b)=>{var D=Math.ceil(256/this.fmt.w),W=D*(this.fmt.aspect||1),ae=this.createEditor(a,b,W,D);this.context.setCurrentEditor(a,$(b.canvas),this),this.rgbimgs[y]=b.rgbdata});var d=this.left;if(d instanceof Or&&d.paloptions.length>1){var g=$(document.createElement("select"));d.paloptions.forEach((y,b)=>{var D=$(document.createElement("option")).text(y.name).val(b).appendTo(g);b==d.palindex&&D.attr("selected","selected")}),g.appendTo(r).change(y=>{var b=$(y.target).val();d.palindex=b,d.refreshRight()})}return!0}createEditor(t,r,a,l){var d=new Xs;d.createWith(r),d.updateImage();for(var g=r.width*a,y=r.height*l;g>500||y>500;)g/=2,y/=2;return d.canvas.style.width=g+"px",d.canvas.style.height=y+"px",d.makeEditable(this,t,this.left.palette),d}},ja=class extends Bt{constructor(t,r,a){super();this.context=t,this.parentdiv=r,this.fmt=a}updateLeft(){return!0}updateRight(){if(bn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=vr(this.parentdiv.empty(),"asset_dual"),r=vr(t),a=vr(t,"asset_editor").hide(),l=new En;return l.width=this.fmt.w,l.height=this.fmt.h,l.recreate(),l.updateImage(this.rgbimgs[0]),r.append(l.canvas),!0}},En=class{recreate(){this.canvas=this.newCanvas(),this.imagedata=this.ctx.createImageData(this.width,this.height),this.rgbdata=new Uint32Array(this.imagedata.data.buffer),this.peerviewers=[this]}createWith(t){this.width=t.width,this.height=t.height,this.imagedata=t.imagedata,this.rgbdata=t.rgbdata,this.canvas=this.newCanvas(),this.peerviewers=[this,t]}newCanvas(){var t=document.createElement("canvas");return t.width=this.width,t.height=this.height,t.classList.add("pixels"),t.classList.add("pixelated"),this.ctx=t.getContext("2d"),t}updateImage(t){t&&this.rgbdata.set(t);for(let r of this.peerviewers)r.ctx.putImageData(this.imagedata,0,0)}},Xs=class extends En{constructor(){super(...arguments);this.curpalcol=-1;this.offscreen=new Map}getPositionFromEvent(t){var r=Math.floor(t.offsetX*this.width/$(this.canvas).width()),a=Math.floor(t.offsetY*this.height/$(this.canvas).height());return{x:r,y:a}}setPaletteColor(t){t&=this.palette.length-1,this.curpalcol!=t&&(this.curpalcol>=0&&this.palbtns[this.curpalcol].removeClass("selected"),this.curpalcol=t,this.currgba=this.palette[t&this.palette.length-1],this.palbtns[t].addClass("selected"))}makeEditable(t,r,a){this.left=t,this.palette=a;var l,d=!1,g=$(this.canvas);g.mousedown(y=>{var b=this.getPositionFromEvent(y);l=this.getPixel(b.x,b.y)==this.currgba?this.palette[0]:this.currgba,this.setPixel(b.x,b.y,this.currgba),d=!0,$(document).mouseup(D=>{$(document).off("mouseup");var W=this.getPositionFromEvent(D);this.setPixel(W.x,W.y,l),d=!1,this.commit()})}).mousemove(y=>{var b=this.getPositionFromEvent(y);d&&this.setPixel(b.x,b.y,l)}),r.empty(),this.createToolbarButtons(r[0]),r.append(this.canvas),r.append(this.createPaletteButtons()),this.setPaletteColor(1)}getPixel(t,r){if(t=Math.round(t),r=Math.round(r),t<0||t>=this.width||r<0||r>=this.height)return this.offscreen[t+","+r]|this.palette[0];var a=t+r*this.width;return this.rgbdata[a]}setPixel(t,r,a){if(t=Math.round(t),r=Math.round(r),t<0||t>=this.width||r<0||r>=this.height)this.offscreen[t+","+r]=a;else{var l=t+r*this.width,d=this.rgbdata[l];d!=a&&(this.rgbdata[l]=a,this.updateImage())}}createPaletteButtons(){this.palbtns=[];for(var t=vr(null,"asset_toolbar"),r=0;r<this.palette.length;r++){var a=$(document.createElement("button")).addClass("palbtn"),l=this.palette[r]&16777215,d="#"+Ae(sn(l),6);a.click(this.setPaletteColor.bind(this,r)),a.css("backgroundColor",d).text(r.toString(16)),a.css("color",l&32768?"black":"white"),t.append(a),this.palbtns.push(a)}return t}createToolbarButtons(t){var r=new cn(t,null);r.add("ctrl+shift+h","Flip X","glyphicon-resize-horizontal",this.flipX.bind(this)),r.add("ctrl+shift+v","Flip Y","glyphicon-resize-vertical",this.flipY.bind(this)),r.add("ctrl+shift+9","Rotate","glyphicon-repeat",this.rotate90.bind(this)),r.add("ctrl+shift+left","Move Left","glyphicon-arrow-left",this.translate.bind(this,1,0)),r.add("ctrl+shift+right","Move Right","glyphicon-arrow-right",this.translate.bind(this,-1,0)),r.add("ctrl+shift+up","Move Up","glyphicon-arrow-up",this.translate.bind(this,0,1)),r.add("ctrl+shift+down","Move Down","glyphicon-arrow-down",this.translate.bind(this,0,-1))}commit(){this.updateImage();try{this.left.refreshLeft()}catch(t){console.log(t),alert(`Could not update source code. ${t}`)}}remapPixels(t){for(var r=0,a=new Uint32Array(this.rgbdata.length),l=0;l<this.height;l++)for(var d=0;d<this.width;d++)a[r]=t(d,l),r++;this.rgbdata.set(a),this.commit()}rotate(t){var r=Math.sin(t*Math.PI/180),a=Math.cos(t*Math.PI/180);this.remapPixels((l,d)=>{var g=l+.5-this.width/2,y=d+.5-this.height/2,b=g*a-y*r+this.width/2-.5,D=y*a+g*r+this.height/2-.5;return this.getPixel(b,D)})}rotate90(){this.rotate(90)}flipX(){this.remapPixels((t,r)=>this.getPixel(this.width-1-t,r))}flipY(){this.remapPixels((t,r)=>this.getPixel(t,this.height-1-r))}translate(t,r){this.remapPixels((a,l)=>this.getPixel(a+t,l+r))}};var _n=Ps(),Ua=class{createDiv(t){return this.maindiv=Ut(t,"vertical-scroll"),this.maindiv[0]}clearAssets(){this.rootnodes=[],this.deferrednodes=[]}registerAsset(t,r,a){this.rootnodes.push(r),a?a>1?this.deferrednodes.push(r):this.deferrednodes.unshift(r):r.refreshRight()}getPalettes(t){var r=[];return this.rootnodes.forEach(a=>{for(;a!=null;){if(a instanceof xn){var l=a.palette;t==l.length&&r.push({node:a,name:"Palette",palette:l}),a.layout&&a.layout.forEach(([d,g,y])=>{if(g<l.length){if(y==t){var b=l.slice(g,g+y);r.push({node:a,name:d,palette:b})}else if(-y==t){var b=l.slice(g,g-y);b.reverse(),r.push({node:a,name:d,palette:b})}else if(y+1==t){var b=new Uint32Array(t);b[0]=l[0],b.set(l.slice(g,g+y),1),r.push({node:a,name:d,palette:b})}}});break}a=a.right}}),r}getTilemaps(t){var r=[];return this.rootnodes.forEach(a=>{for(;a!=null;){if(a instanceof Or){var l=a.rgbimgs;l&&l.length>=t&&r.push({node:a,name:"Tilemap",images:a.images,rgbimgs:l})}a=a.right}}),r}isEditing(){return this.cureditordiv!=null}getCurrentEditNode(){return this.cureditnode}setCurrentEditor(t,r,a){let l=250;for(this.cureditordiv!=t&&(this.cureditordiv&&(this.cureditordiv.hide(l),this.cureditordiv=null),t&&(this.cureditordiv=t,this.cureditordiv.show(),this.cureditordiv[0].scrollIntoView({behavior:"smooth",block:"center"}))),this.cureditelem&&(this.cureditelem.removeClass("selected"),this.cureditelem=null),r&&(this.cureditelem=r,this.cureditelem.addClass("selected"));a.left;)a=a.left;this.cureditnode=a}scanFileTextForAssets(t,r){for(var a=[],l=/[/;][*;]([{].+[}])[*;][/;]/g,d;d=l.exec(r);){var g=d.index+d[0].length,y;if(ie.includes("verilog")?y=r.indexOf("end",g):d[0].startsWith(";;")?y=r.indexOf(";;",g):y=r.indexOf(";",g),y>g)try{var b=d[1].replace(/([A-Za-z]+):/g,'"$1":'),D=JSON.parse(b);a.push({fileid:t,fmt:D,start:g,end:y})}catch(_e){console.log(_e)}}for(var W=/DEF_METASPRITE_(\d+)x(\d+)[(](\w+),\s*(\w+),\s*(\w+)/gi;d=W.exec(r);){for(var ae=parseInt(d[1]),U=parseInt(d[2]),O=d[3],B=parseInt(d[4]),oe=parseInt(d[5]),Y=[],ge=0;ge<ae;ge++)for(var Te=0;Te<U;Te++)Y.push({x:ge*8,y:Te*8,tile:B,attr:oe});var pe={defs:Y,width:ae*8,height:U*8};a.push({fileid:t,label:O,meta:pe})}return a}addPaletteEditorViews(t,r,a){var l=$('<div class="asset_dual"/>').appendTo(t),d=$('<div class="asset_editor"/>').hide(),g=[];r.getAllColors().forEach(O=>{g.push(new Uint32Array([O]))});var y=$("<table/>").appendTo(l);d.appendTo(l);var b=r.layout;if(!b){var D=r.palette.length,W=D>32?8:4;b=[];for(var ae=0;ae<D;ae+=W)b.push(["",ae,Math.min(D-ae,W)])}function U(O,B){var oe=r.words[B],Y=r.palette[B],ge="#"+Ae(sn(Y),6),Te=Y&32768?"black":"white";O.text(Ae(oe,2)).css("background-color",ge).css("color",Te)}b.forEach(([O,B,oe])=>{if(B<r.palette.length){var Y=$("<tr/>").appendTo(y);$("<td/>").text(O).appendTo(Y);for(var ge=[],Te=B;Te<B+Math.abs(oe);Te++)ge.push(Te);oe<0&&ge.reverse(),ge.forEach(pe=>{var _e=$("<td/>").addClass("asset_cell asset_editable").appendTo(Y);U(_e,pe),_e.click($e=>{var s=new wn;s.rgbimgs=g,s.width=1,s.height=1,s.recreate(d,(se,X)=>{a(pe,se),U(_e,pe)}),this.setCurrentEditor(d,_e,r)})})}})}addPixelEditor(t,r,a){a.xform="scale(2)";var l=new Oa(a);r.addRight(l);var d=new Or(this,a);l.addRight(d),d.addRight(new Wa(this,Ut(t),a))}addPaletteEditor(t,r,a){var l=new xn(a);r.addRight(l),r.refreshRight(),this.addPaletteEditorViews(t,l,(d,g)=>{console.log("set entry",d,"=",g),r.words[d]=g,l.words=null,l.updateRight(),l.refreshLeft()})}ensureFileDiv(t){var r=this.getFileDivId(t),a=$(document.getElementById(r));if(a.length===0){var l=Ut(this.maindiv,"asset_file"),d=Ut(l,"asset_file_header").text(t);a=Ut(l).attr("id",r).addClass("disable-select")}return a}refreshAssetsInFile(t,r){let a=0;if(ie.startsWith("nes")&&t.endsWith(".chr")&&r instanceof Uint8Array){let l=new yn(ue,t),d={w:8,h:8,bpp:1,count:r.length>>4,brev:!0,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]};this.addPixelEditor(this.ensureFileDiv(t),l,d),this.registerAsset("charmap",l,1),a++}else if(ie.startsWith("nes")&&t.endsWith(".pal")&&r instanceof Uint8Array){let l=new yn(ue,t),d={pal:"nes",layout:"nes"};this.addPaletteEditor(this.ensureFileDiv(t),l,d),this.registerAsset("palette",l,0),a++}else if(typeof r=="string"){let l=this.scanFileTextForAssets(t,r);for(let d of l)if(d.fmt){let g=t,y=new Ma(ue,t,g,d.start,d.end),b=y;if(d.fmt.comp=="rletag"&&(y=y.addRight(new Na)),d.fmt.map=="nesnt"){y=y.addRight(new $a(this)),y=y.addRight(new Or(this,{w:8,h:8,bpp:4}));let D={w:8*(d.fmt.w||32),h:8*(d.fmt.h||30),count:1};y=y.addRight(new ja(this,Ut(this.ensureFileDiv(t)),D)),this.registerAsset("nametable",b,2),a++}else d.fmt.w>0&&d.fmt.h>0?(this.addPixelEditor(this.ensureFileDiv(t),y,d.fmt),this.registerAsset("charmap",b,1),a++):d.fmt.pal&&(this.addPaletteEditor(this.ensureFileDiv(t),y,d.fmt),this.registerAsset("palette",b,0),a++)}}return a}getFileDivId(t){return"__asset__"+xs(t)}refresh(t){if(t)this.maindiv.empty(),this.clearAssets(),de.iterateFiles((a,l)=>{try{var d=this.refreshAssetsInFile(a,l)}catch(g){console.log(g),this.ensureFileDiv(a).text(g+"")}}),console.log("Found "+this.rootnodes.length+" assets"),this.deferrednodes.forEach(a=>{try{a.refreshRight()}catch(l){console.log(l),alert(l+"")}}),this.deferrednodes=[];else for(var r of this.rootnodes)r!==this.getCurrentEditNode()&&r.refreshRight()}setVisible(t){t?_n.bind&&_n.bind("ctrl+z",ue.undoStep.bind(ue)):_n.unbind&&_n.unbind("ctrl+z")}};var mi=256,Qs=100,Js=!1,vi=class{constructor(t,r){this.expanded=!1;this.parent=t,this.name=r,this.children=new Map,this.level=t?t.level+1:-1,this.view=t?t.view:null}getDiv(){return this._div==null&&(this._div=document.createElement("div"),this._div.classList.add("vertical-scroll"),this._div.classList.add("tree-content"),this._header=document.createElement("div"),this._header.classList.add("tree-header"),this._header.classList.add("tree-level-"+this.level),this._header.append(this.name),this._inline=document.createElement("span"),this._inline.classList.add("tree-value"),this._header.append(this._inline),this._div.append(this._header),this.parent._content.append(this._div),this._header.onclick=t=>{this.toggleExpanded()}),this.expanded&&this._content==null?(this._content=document.createElement("div"),this._div.append(this._content)):!this.expanded&&this._content!=null&&(this._content.remove(),this._content=null,this.children.clear()),this._div}toggleExpanded(){this.expanded=!this.expanded,this.view.tick()}remove(){this._div.remove(),this._div=null}update(t){this.getDiv();var r="";if(t&&t.$$&&typeof t.$$=="function"&&this._content!=null&&(t=t.$$()),t==null)r=t+"";else if(typeof t=="number")t!=(t|0)?r=t.toString():r=t+" ($"+Ae(t)+")";else if(typeof t=="boolean")r=t.toString();else if(typeof t=="string")t.length<Qs?r=t:r=t.substring(0,Qs)+"...";else if(t.buffer&&t.length<=mi)r=_s(t,0,t.length);else if(typeof t=="object"||typeof t=="function")if(this._content!=null){if(t.slice&&t.length>mi){let b={},D=t;for(var a=mi;t.length/a>mi;)a*=2;for(let W=0;W<D.length;W+=a)b["$"+Ae(W)]={$$:()=>D.slice(W,W+a)};t=b}if(t instanceof Map){let b={};for(let[D,W]of t.entries())b[D]=W;t=b}let g=t instanceof Array?Array.from(t.keys()):Object.getOwnPropertyNames(t);if(g.length>mi){let b={},D=t;for(var a=100;g.length/a>100;)a*=2;for(let ae=0;ae<g.length;ae+=a){for(var l={},d=ae;d<ae+a;d++)l[g[d]]=D[g[d]];b["["+ae+"...]"]=l}t=b,g=Object.getOwnPropertyNames(t)}let y=new Set(this.children.keys());g.forEach(b=>{var D=!Js&&typeof b=="string"&&b.startsWith("$$");if(!D){let W=this.children.get(b);W==null&&(W=new vi(this,b),this.children.set(b,W)),W.update(t[b])}y.delete(b)}),y.forEach(b=>{this.children.get(b).remove(),this.children.delete(b)}),this._header.classList.add("tree-expanded"),this._header.classList.remove("tree-collapsed")}else this._header.classList.add("tree-collapsed"),this._header.classList.remove("tree-expanded");else r=typeof t;this._inline.innerText!=r&&(this._inline.innerText=r)}};function Ks(u,t){var r=new vi(null,null);r.view=t,r._content=u;var a=new vi(r,"/");return a.expanded=!0,a.getDiv(),a._div.style.padding="0px",a}var Zs=class{createDiv(t){return this.root=Ks(t,this),this.root.getDiv()}refresh(){this.tick()}tick(){this.root.update(this.getRootObject())}};var Ba=class extends Zs{getRootObject(){return P.getDebugTree()}},Ha=class extends mr{constructor(){super(...arguments);this.cumulativeData=!0}createDiv(t){return this.clear(),this.treeroot=Ks(t,this),this.treeroot.getDiv()}refresh(){this.tick()}tick(){this.treeroot.update(this.getRootObject()),this.probe&&this.probe.clear()}clear(){this.graph=null,this.reset()}reset(){this.stack=[],this.lastsp=-1,this.lastpc=0,this.jsr=!1,this.rts=!1}newNode(t,r){return{$$SP:r,$$PC:t,count:0,startLine:null,endLine:null,calls:{}}}newRoot(t,r){this.stack.length==0?(this.graph=this.newNode(null,r),this.stack.unshift(this.graph)):r>this.stack[0].$$SP&&(this.graph=this.newNode(null,r),this.graph.calls[this.addr2str(t)]=this.stack[0],this.stack.unshift(this.graph))}getRootObject(){return this.redraw((t,r,a,l,d,g)=>{switch(t){case K.SP_POP:this.newRoot(this.lastpc,this.lastsp);case K.SP_PUSH:if(this.stack.length){let b=this.stack[this.stack.length-1];var y=this.lastsp-r;(y==2||y==3)&&r<b.$$SP&&(this.jsr=!0),(y==-2||y==-3)&&this.stack.length>1&&r>b.$$SP&&(this.rts=!0)}this.lastsp=r;break;case K.EXECUTE:if(Math.abs(r-this.lastpc)>=4){if(this.jsr&&this.stack.length){let b=this.stack[this.stack.length-1],D=this.addr2str(r),W=b.calls[D];W==null?W=b.calls[D]=this.newNode(r,this.lastsp):W.$$PC==null&&(W.$$PC=r),this.stack.push(W),W.count++,W.startLine=l}this.jsr=!1,this.rts&&this.stack.length&&(this.stack.pop().endLine=l),this.rts=!1}this.lastpc=r;break}}),this.graph&&(this.graph.$$Stack=this.stack),Js?this.graph:this.graph&&this.graph.calls}};var za=si(da());function Le(u){u?(Tt(0),$("#pleaseWaitModal").modal("show")):(Tt(1),$("#pleaseWaitModal").modal("hide"))}function Tt(u){$("#pleaseWaitProgressBar").css("width",u*100+"%").show()}function be(u){Le(!1),bootbox.alert({title:'<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Alert',message:za.default.sanitize(u)})}function ht(u){Le(!1),bootbox.alert(za.default.sanitize(u))}function eo(u){throw be(u),new Error(u)}var Va=si(da());function br(u,t,r,a){window.ga&&ga("send","event",u,t,r,a)}function to(u){window.ga&&ga("send","pageview",u)}var Ga;async function yr(){if(!Ga){await bt("lib/octokat.js"),await bt("https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js"),await bt("https://www.gstatic.com/firebasejs/8.8.1/firebase-auth.js"),await bt("https://8bitworkshop.com/config.js");var u=ln("__github_key");Ga=new wa(Octokat,u,ar(),Ht()),console.log("loaded github service")}return Ga}function bi(){var u=(Ne||"").split("/");return u.length!=2?(be("You are not in a GitHub repository. Choose one from the pulldown, or Import or Publish one."),null):"https://github.com/"+u[0]+"/"+u[1]}async function Sn(u,t){var r,a=ci(u);if(!a){be("Could not parse Github URL.");return}var l=Nr()[a.repopath];if(!(l&&!confirm("You've already imported "+a.repopath+" -- do you want to replace all local files?"))){Le(!0);var d=dn(a.repopath);Tt(.25);var g=await yr();return g.import(u).then(y=>(r=y,Tt(.75),g.pull(u,d))).then(y=>{Le(!1),br("sync","import",u),xr(t,{repo:a.repopath})}).catch(y=>{Le(!1),console.log(y),be("Could not import "+u+"."+y)})}}async function ro(u){var t=await yr();t.login().then(()=>{ht("You are signed in to Github.")}).catch(r=>{be("Could not sign in."+r)})}async function io(u){var t=await yr();t.logout().then(()=>{ht("You are logged out of Github.")})}function no(u){var t=$("#importGithubModal"),r=$("#importGithubButton");t.modal("show"),r.off("click").on("click",()=>{var a=$("#importGithubURL").val()+"";t.modal("hide"),Sn(a,!1)})}function ao(u){if(!(Ne&&!confirm("This project ("+Ht().mainPath+") is already bound to a Github repository. Do you want to re-publish to a new repository? (You can instead choose 'Push Changes' to update files in the existing repository.)"))){var t=$("#publishGithubModal"),r=$("#publishGithubButton");$("#githubRepoName").val(Je(lt(Ht().mainPath))),t.modal("show"),r.off("click").on("click",async()=>{var a=$("#githubRepoName").val()+"",l=$("#githubRepoDesc").val()+"",d=$("#githubRepoPrivate").val()=="private",g=$("#githubRepoLicense").val()+"",y;if(!a){be("You did not enter a project name.");return}t.modal("hide"),Le(!0);var b=await yr();b.login().then(()=>(Tt(.25),b.publish(a,l,g,d))).then(D=>(y=D,Tt(.5),lo("initial import from 8bitworkshop.com"))).then(()=>{br("sync","publish",d?"":a),Sn(y.url,!1)}).catch(D=>{Le(!1),console.log(D),be("Could not publish GitHub repository: "+D)})})}}function so(u){var t=bi();if(!!t){var r=$("#pushGithubModal"),a=$("#pushGithubButton");r.modal("show"),a.off("click").on("click",()=>{var l=$("#githubCommitMsg").val()+"";r.modal("hide"),lo(l)})}}function oo(u){var t=bi();!t||bootbox.confirm("Pull from repository and replace all local files? Any changes you've made will be overwritten.",async r=>{if(r){Le(!0);var a=await yr();a.pull(t).then(l=>{Le(!1),ue.updateAllOpenWindows(ar())})}})}function _l(u){return new Promise((t,r)=>{var a=u.commit.files;if(console.log(a),a.length==0){Le(!1),ht("No files changed.");return}var l="";for(var d of a)l+=Va.default.sanitize(d.filename)+": "+d.status,(d.additions||d.deletions||d.changes)&&(l+=" ("+d.additions+" additions, "+d.deletions+" deletions, "+d.changes+" changes)"),l+="<br/>";bootbox.confirm(l,g=>{g?t(u):Le(!1)})})}async function lo(u){var t=bi();if(!!t){var r=[];for(var a in Ht().filedata){var l=Ht().stripLocalPath(a),d=Ht().filedata[a];l&&d&&r.push({path:l,data:d})}if(tt()instanceof Uint8Array){let y="bin/"+ze()+".rom";r.push({path:y,data:tt()})}Le(!0);var g=await yr();return g.login().then(()=>(Tt(.5),g.commit(t,u,r))).then(y=>_l(y)).then(y=>g.push(y)).then(y=>(Le(!1),ht("Pushed files to "+t),y)).catch(y=>{Le(!1),console.log(y),be("Could not push GitHub repository: "+y)})}}function uo(){var u=bi();!u||bootbox.prompt("<p>Are you sure you want to delete this repository ("+Va.default.sanitize(u)+") from browser storage?</p><p>All changes since last commit will be lost.</p><p>Type DELETE to proceed.<p>",t=>{t.trim().toUpperCase()=="DELETE"&&Sl()})}async function Sl(){var u=bi();Le(!0);let t=await yr(),r=await t.getGithubSession(u);t.bind(r,!1),await ar().keys().then(a=>Promise.all(a.map(l=>ar().removeItem(l)))),Le(!1),xr(!1,{repo:"/"})}var qa=class{constructor(t){this.options=t,this.sampleRate=44100,this.soundData=[],this.tapData=[67,54,52,45,84,65,80,69,45,82,65,87,1,0,0,0,0,0,0,0]}getWAVHeader(){let t=new Uint8Array(44),r=new DataView(t.buffer);return r.setUint32(0,1380533830,!1),r.setUint32(4,44+this.soundData.length,!0),r.setUint32(8,1463899717,!1),r.setUint32(12,1718449184,!1),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,this.sampleRate,!0),r.setUint32(28,this.sampleRate*2,!0),r.setUint16(32,1,!0),r.setUint16(34,8,!0),r.setUint32(36,1684108385,!1),r.setUint32(40,this.soundData.length,!0),t}addSilence(t){let r=Math.floor(this.sampleRate*t);for(let l=0;l<r;l++)this.soundData.push(0);let a=We.CLOCK_RATE*t;this.tapData.push(0),this.tapData.push(a&255),this.tapData.push(a>>8&255),this.tapData.push(a>>16&255)}addCycle(t){this.tapData.push(t);let r=Math.floor(this.sampleRate*We.TAP_LENGTH_IN_SECONDS*t);for(let a=0;a<r;a++){let l;this.options.sine_wave?l=-Math.sin(a/r*2*Math.PI):a<r/2?l=-1:l=1,this.options.invert_waveform&&(l=-l),this.soundData.push(Math.round(128+l*127))}}updateTAPHeader(){let t=this.tapData.length-20;this.tapData[16]=t&255,this.tapData[17]=t>>8&255,this.tapData[18]=t>>16&255,this.tapData[19]=t>>24&255}getTAPData(){return this.updateTAPHeader(),new Uint8Array(this.tapData)}getSoundData(){let t=this.getWAVHeader(),r=new Uint8Array(t.length+this.soundData.length);return r.set(t,0),r.set(new Uint8Array(this.soundData),t.length),r}},Oe=class{constructor(t,r){this.options=r,this.checksum=0,this.data=new Uint8Array(0),this.filenameData=this.makeFilename(t),this.startAddress=0,this.endAddress=0,this.fileType=Oe.FILE_TYPE_NONE,this.waveFile=null}makeFilename(t){let r=[],a=32;t=t.toUpperCase();for(let l=0;l<Oe.FILENAME_BUFFER_SIZE;l++)if(t.length<=l)r.push(a);else{let d=t.charCodeAt(l);r.push(d)}return r}setContent(t){this.data=t.data,this.startAddress=t.startAddress,this.endAddress=t.startAddress+t.data.length,this.fileType=t.type}generateSound(t){this.waveFile=t,this.addHeader(!1),this.addHeader(!0),t.addSilence(.1),this.addFile()}addTapCycle(t){this.waveFile.addCycle(t)}addBit(t){t===0?(this.addTapCycle(Oe.SHORT_PULSE),this.addTapCycle(Oe.MEDIUM_PULSE)):(this.addTapCycle(Oe.MEDIUM_PULSE),this.addTapCycle(Oe.SHORT_PULSE))}addDataMarker(t){t?(this.addTapCycle(Oe.LONG_PULSE),this.addTapCycle(Oe.MEDIUM_PULSE)):(this.addTapCycle(Oe.LONG_PULSE),this.addTapCycle(Oe.SHORT_PULSE))}resetChecksum(){this.checksum=0}addByteFrame(t,r){let a=1;for(let l=0;l<8;l++){let d=(t&1<<l)!=0?1:0;this.addBit(d),a^=d}this.addBit(a),this.addDataMarker(r),this.checksum^=t}addLeader(t){let r;t===Oe.LEADER_TYPE_HEADER?r=27136:t===Oe.LEADER_TYPE_CONTENT?r=6656:r=79;for(let a=0;a<r;a++)this.addTapCycle(Oe.SHORT_PULSE)}addSyncChain(t){let r;t?r=9:r=137;let a=9;for(;a>0;)this.addByteFrame(r,!0),r-=1,a-=1}addData(){for(let t=0;t<this.data.length;t++)this.addByteFrame(this.data[t],!0)}addFilename(){for(let t=0;t<this.filenameData.length;t++)this.addByteFrame(this.filenameData[t],!0)}addHeader(t){t?this.addLeader(Oe.LEADER_TYPE_REPEATED):this.addLeader(Oe.LEADER_TYPE_HEADER),this.addDataMarker(!0),this.addSyncChain(t),this.resetChecksum(),this.addByteFrame(this.fileType,!0),this.addByteFrame(this.startAddress&255,!0),this.addByteFrame((this.startAddress&65280)>>8,!0),this.addByteFrame(this.endAddress&255,!0),this.addByteFrame((this.endAddress&65280)>>8,!0),this.addFilename();for(let r=0;r<Oe.NUMBER_OF_PADDING_BYTES;r++)this.addByteFrame(Oe.PADDING_CHARACTER,!0);this.addByteFrame(this.checksum,!1)}addFile(){let t=!1;for(let r=0;r<2;r++)t?this.addLeader(Oe.LEADER_TYPE_REPEATED):this.addLeader(Oe.LEADER_TYPE_CONTENT),this.addDataMarker(!0),this.addSyncChain(t),this.resetChecksum(),this.addData(),this.addByteFrame(this.checksum,!1),t=!0;this.addLeader(1)}},We=Oe;We.CLOCK_RATE=985248,We.TAP_LENGTH_IN_SECONDS=8/Oe.CLOCK_RATE,We.FILENAME_BUFFER_SIZE=16,We.FILE_TYPE_NONE=0,We.FILE_TYPE_RELOCATABLE=1,We.FILE_TYPE_SEQUENTIAL=2,We.FILE_TYPE_NON_RELOCATABLE=3,We.LEADER_TYPE_HEADER=0,We.LEADER_TYPE_CONTENT=1,We.LEADER_TYPE_REPEATED=2,We.NUMBER_OF_PADDING_BYTES=171,We.PADDING_CHARACTER=32,We.SHORT_PULSE=48,We.MEDIUM_PULSE=66,We.LONG_PULSE=86;var Mt=si(dl());function co(u){return tt()==null?(be("Please fix errors before sharing."),!0):tt()instanceof Uint8Array?(Tl(),bt("lib/liblzg.js").then(()=>{var t=ys(window.Module,Array.from(tt()));window.Module=null;var r=btoa(nn(t)),a={p:ie,r},l=$.param(a),d=Cl(l,"player.html"),g='<iframe width=640 height=600 src="'+d+'">';$("#embedLinkTextarea").text(d),$("#embedIframeTextarea").text(g),$("#embedLinkModal").modal("show"),$("#embedAdviceWarnAll").hide(),$("#embedAdviceWarnIE").hide(),d.length>=65536?$("#embedAdviceWarnAll").show():d.length>=5120&&$("#embedAdviceWarnIE").show()}),!0):(be("Can't share a Verilog executable yet. (It's not actually a ROM...)"),!0)}function Tl(){console.log("clipboard"),import("./clipboard-2SP4SJIP.js").then(u=>{let t=u.default;new t(".btn")})}function Cl(u,t){console.log(u);var r=window.location,a=r.pathname.replace("index.html",""),l=r.host=="8bitworkshop.com"?"https:":r.protocol,d=l+"//"+r.host+a+t+"?"+u;return d}function Pl(u){var r;var t=(r=pi())==null?void 0:r.code_start;bt("lib/c2t.js").then(()=>{var a="",l=function(U){a+=U+`
`},d=window.c2t({noInitialRun:!0,print:l,printErr:l}),g=d.FS,y=ze()+".bin",b=ze()+".wav";g.writeFile(y,tt(),{encoding:"binary"});var D=["-2bc",y+","+t.toString(16),b];d.callMain(D);var W=g.readFile(b,{encoding:"binary"});if(W){var ae=new Blob([W],{type:"audio/wav"});(0,Mt.saveAs)(ae,b),a+="Then connect your audio output to the cassette input, turn up the volume, and play the audio file.",ht(a)}})}function kl(u){bt("lib/makewav.js").then(()=>{let t="",r=function(y){t+=y+`
`};var a=Je(ze());let l=a+".bin",d=a+".wav";window.makewav({noInitialRun:!1,print:r,printErr:r,arguments:["-ts","-f0","-v10",l],preRun:y=>{y.FS.writeFile(l,tt(),{encoding:"binary"})}}).ready.then(y=>{let b=[l];y.run(b),console.log(t);let W=y.FS.readFile(d,{encoding:"binary"});if(W){let ae=new Blob([W],{type:"audio/wav"});(0,Mt.saveAs)(ae,d),t+=`
Connect your audio output to the SuperCharger input, turn up the volume, and play the audio file.`,ht(t)}})})}function Al(u){var t=Je(ze());let r=t+".tap",a=new We(t),l=new qa({sine_wave:!0}),d=tt(),g=d[0]+d[1]*256;d=d.slice(2),a.setContent({data:d,startAddress:g,type:We.FILE_TYPE_NON_RELOCATABLE}),a.generateSound(l);let y=l.getTAPData();if(y){let b=new Blob([y],{type:"application/octet-stream"});(0,Mt.saveAs)(b,r)}}function Ya(){switch(ut(ie)){case"vcs":return kl;case"apple2":return Pl;case"c64":return Al}}function fo(u){if(tt()==null)return be("Please fix errors before exporting."),!0;var t=Ya();if(t===void 0)return be("Cassette export is not supported on this platform."),!0;t(u)}function ho(u){if(tt()==null)return be("Please finish compiling with no errors before downloading ROM."),!0;var t=Je(ze());if(P.getDownloadFile){var r=P.getDownloadFile(),t=Je(ze());(0,Mt.saveAs)(r.blob,t+r.extension)}else if(tt()instanceof Uint8Array){var a=new Blob([tt()],{type:"application/octet-stream"}),l=P.getROMExtension&&P.getROMExtension(tt())||"-"+ut(ie)+".bin";(0,Mt.saveAs)(a,t+l)}else be(`The "${ie}" platform doesn't have downloadable ROMs.`)}function po(u){var t=ue.getCurrentText();if(!t)return!1;var r=new Blob([t],{type:"text/plain;charset=utf-8"});(0,Mt.saveAs)(r,xo(),{autoBom:!1})}async function go(){let u=(await import("./jszip.min-QZ4ZBVAS.js")).default;return new u}async function mo(u){var t=await go();Ht().iterateFiles((r,a)=>{a&&t.file(lt(r),a)}),t.generateAsync({type:"blob"}).then(r=>{(0,Mt.saveAs)(r,ze()+"-"+ut(ie)+".zip")})}function vo(u){let t=P.getDebugSymbolFile&&P.getDebugSymbolFile();if(!t){be("This project does not have debug information.");return}var r=Je(ze());(0,Mt.saveAs)(t.blob,r+t.extension,{autoBom:!1})}async function bo(u){var t=await go(),r=await ar().keys();Le(!0);try{var a=0;await Promise.all(r.map(d=>ar().getItem(d).then(g=>{Tt(a++/(r.length+1)),g&&t.file(d,g)})));var l=await t.generateAsync({type:"blob"});(0,Mt.saveAs)(l,ut(ie)+"-all.zip")}finally{Le(!1)}}var Xa=!1;function yo(){Xa||bt("lib/gif.js").then(()=>{var u=$("#emulator").find("canvas")[0];if(!u){be("Could not find canvas element to record video!");return}var t=0;u.style&&u.style.transform&&(u.style.transform.indexOf("rotate(-90deg)")>=0?t=-1:u.style.transform.indexOf("rotate(90deg)")>=0&&(t=1));var r=new GIF({workerScript:"lib/gif.worker.js",workers:4,quality:10,rotate:t}),a=$("#videoPreviewImage");r.on("progress",b=>{Tt(b)}),r.on("finished",b=>{a.attr("src",URL.createObjectURL(b)),Le(!1),P.resume(),$("#videoPreviewModal").modal("show")});var l=20,d=300,g=0;console.log("Recording video",u),$("#emulator").css("backgroundColor","#cc3333");var y=()=>{g++>d?(console.log("Rendering video"),$("#emulator").css("backgroundColor","inherit"),Le(!0),P.pause(),r.render(),Xa=!1):(r.addFrame(u,{delay:l,copy:!0}),setTimeout(y,l),Xa=!0)};y()})}var Dl=fl(),wr=da(),Z=oa(window.location.search||"?"),ie,Er,Ne,P,de,ue,nr,wo,Ja,yi=$("#controls_top"),Be,rt,Ka,_r,Tn,yt,xi=Mr(Z.electron),it=Mr(Z.embed),wi,Ei,Cn=!1,$r=!1,Pn=null,Eo=null,Za=!1,_o="c.PC == 0x6000";function ar(){return yt}function Ht(){return de}function tt(){return _r}function pi(){return wo}var Fl={dasm:"6502",acme:"6502",cc65:"text/x-csrc",ca65:"6502",nesasm:"6502",z80asm:"z80",sdasz80:"z80",sdcc:"text/x-csrc",verilator:"verilog",jsasm:"z80",zmac:"z80",bataribasic:"bataribasic",markdown:"markdown",js:"javascript",xasm6809:"z80",cmoc:"text/x-csrc",yasm:"gas",smlrc:"text/x-csrc",inform6:"inform6",fastbasic:"fastbasic",basic:"basic",silice:"verilog",wiz:"text/x-wiz",vasmarm:"vasm",armips:"vasm",ecs:"ecs","remote:llvm-mos":"text/x-csrc",cc7800:"text/x-csrc",armtcc:"text/x-csrc",oscar64:"text/x-csrc"},Rl={dasm:"https://raw.githubusercontent.com/sehugg/dasm/master/doc/dasm.txt",cc65:"https://cc65.github.io/doc/cc65.html",ca65:"https://cc65.github.io/doc/ca65.html",sdcc:"http://sdcc.sourceforge.net/doc/sdccman.pdf",verilator:"https://www.veripool.org/ftp/verilator_doc.pdf",fastbasic:"https://github.com/dmsc/fastbasic/blob/master/manual.md",bataribasic:"help/bataribasic/manual.html",wiz:"https://github.com/wiz-lang/wiz/blob/master/readme.md#wiz",silice:"https://github.com/sylefeb/Silice",zmac:"https://raw.githubusercontent.com/sehugg/zmac/master/doc.txt",cmoc:"http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html","remote:llvm-mos":"https://llvm-mos.org/wiki/Welcome",acme:"https://raw.githubusercontent.com/sehugg/acme/main/docs/QuickRef.txt"};function Ll(){return new Worker("./gen/worker/bundle.js")}var xt=function(){try{let t="__some_random_key_you_are_not_going_to_use__";localStorage.setItem(t,t);var u=localStorage.getItem(t)==t;return localStorage.removeItem(t),u}catch(t){return!1}}(),So=class{setLastPreset(t){xt&&!it&&(Ne&&ie&&!xi?localStorage.setItem("__lastrepo_"+ie,Ne):localStorage.removeItem("__lastrepo_"+ie),localStorage.setItem("__lastplatform",ie),localStorage.setItem("__lastid_"+Er,t))}unsetLastPreset(){xt&&!it&&(delete Z.file,localStorage.removeItem("__lastid_"+Er))}getLastPreset(){return xt&&!it&&localStorage.getItem("__lastid_"+Er)}getLastPlatformID(){return xt&&!it&&localStorage.getItem("__lastplatform")}getLastRepoID(t){return xt&&!it&&t&&localStorage.getItem("__lastrepo_"+t)}shouldCompleteTour(){return xt&&!it&&!localStorage.getItem("8bitworkshop.hello")}completedTour(){xt&&!it&&localStorage.setItem("8bitworkshop.hello","true")}},Sr=new So;function es(u,t){navigator.storage&&navigator.storage.persist?navigator.storage.persist().then(r=>{console.log("requestPersistPermission =",r),r?u&&!t&&ht("Your browser says it will persist your local file edits, but you may want to back up your work anyway."):u&&be("Your browser refused to expand the peristent storage quota. Your edits may not be preserved after closing the page.")}):u&&be("Your browser may not persist edits after closing the page. Try a different browser.")}function Il(){return Tn?Tn.title||Tn.name||de.mainPath||"ROM":de.mainPath||"ROM"}async function Ml(){var u=new ma(ie);return xi?(console.log("using electron with local filesystem",alternateLocalFilesystem),new ui(u,alternateLocalFilesystem)):Z.localfs!=null?new ui(u,await Gl(Z.localfs)):new ui(u,new va(yt))}async function Nl(){var u=await Ml();de=new ba(Ll(),ie,P,u),de.remoteTool=Z.tool||null,ue=new xa($("#workspace")[0],de),de.callbackBuildResult=t=>{Zl(t)},de.callbackBuildStatus=t=>{Ol(t)}}function Ol(u){u?yi.addClass("is-busy"):yi.removeClass("is-busy"),$("#compile_spinner").css("visibility",u?"visible":"hidden")}function ts(u,t){var r=document.createElement("li"),a=document.createElement("a");return a.setAttribute("class","dropdown-item"),a.setAttribute("href","#"),a.setAttribute("data-wndid",u),u==ue.getActiveID()&&$(a).addClass("dropdown-item-checked"),a.appendChild(document.createTextNode(t)),r.appendChild(a),{li:r,a}}function _i(){var u=$("#windowMenuList").empty(),t=!1;function r(b,D,W){t&&(u.append(document.createElement("hr")),t=!1);let{li:ae,a:U}=ts(b,D);if(u.append(ae),W){var O=(B,oe)=>{u.find("a").removeClass("dropdown-item-checked"),$(U).addClass("dropdown-item-checked")};ue.setCreateFunc(b,W),ue.setShowFunc(b,O),$(U).click(B=>{ue.createOrShow(b),Pn=b})}}function a(b){var D=P.getToolForFilename(b);D=="dasm"&&b.endsWith(".h")&&ze().endsWith(".c")&&(D="cc65");var W=D&&Fl[D];return new di(b,W)}function l(b){r(b,lt(b),()=>{var D=de.getFile(b);if(typeof D=="string")return a(b);if(D instanceof Uint8Array)return new Ca(b,D)})}l(de.mainPath),de.iterateFiles((b,D)=>{D&&b!=de.mainPath&&l(b)}),t=!0;var d=de.getListings();if(d)for(var g in d){var y=d[g];(y.assemblyfile&&y.assemblyfile.text||y.sourcefile&&y.sourcefile.text||y.text)&&r(g,lt(g),b=>new Sa(b))}t=!0,P.disassemble&&P.saveState&&r("#disasm","Disassembly",()=>new gn),P.readAddress&&r("#memory","Memory Browser",()=>new mn),de.segments&&de.segments.length&&r("#memmap","Memory Map",()=>new Pa),P.readVRAMAddress&&r("#memvram","VRAM Browser",()=>new Ta),P.startProbing&&(r("#memheatmap","Memory Probe",()=>new Aa),r("#crtheatmap","CRT Probe",()=>new Da),r("#probelog","Probe Log",()=>new Fa),r("#scanlineio","Scanline I/O",()=>new Ra),r("#symbolprobe","Symbol Profiler",()=>new La),r("#callstack","Call Stack",()=>new Ha)),P.getDebugTree&&r("#debugview","Debug Tree",()=>new Ba),r("#asseteditor","Asset Editor",()=>new Ua)}function $l(u,t){if(t){var r=Z.highlight.split(","),a=parseInt(r[0])-1,l=parseInt(r[1])-1,d=ue.createOrShow(u);d.highlightLines(a,l)}}function To(u){_i(),ue.createOrShow(u),de.setMainFile(u),$l(u,Z.highlight)}async function Wl(u){de.mainPath=u,Sr.setLastPreset(u);var t=await de.loadFiles([u]);if(t&&t.length)To(u);else{var r=await jl(u);de.filedata[u]=r||`
`,To(u),Z.newfile?es(!0,!0):ht('Could not find file "'+u+'". Loading default file.'),delete Z.newfile,Rn()}}function rs(u){if(u=="/")Z={repo:"/"};else if(u.indexOf("://")>=0){var t=ci(u);t&&(Z={repo:t.repopath})}else Z.platform=ie,Z.file=u;xr()}async function jl(u){var t=P.getToolForFilename(u);try{return await $.get("presets/"+ut(ie)+"/skeleton."+t,"text")}catch(r){be("Could not load skeleton for "+ie+"/"+t+"; using blank file")}}function is(u){return u.indexOf(" ")>=0?(be("No spaces in filenames, please."),!1):!0}function Ul(u){return bootbox.prompt({title:"Enter the name of your new main source file.",placeholder:"newfile"+P.getDefaultExtension(),callback:t=>{if(t&&t.trim().length>0){if(!is(t))return;t.indexOf(".")<0&&(t+=P.getDefaultExtension());var r=t;br("workspace","file","new"),Z.newfile="1",rs(r)}}}),!0}function Bl(u){let t=$('<input type="file" multiple accept="*" style="display:none">'),r=t[0];t.change(a=>{Hl(r.files)}),t.click()}function Hl(u){console.log(u);var t=0;function r(){var a=u[t++];if(!a)console.log("Done uploading",t),t>2?(ht("Files uploaded."),setTimeout(Si,1e3)):(Z.file=u[0].name,bootbox.confirm({message:"Open '"+wr.sanitize(Z.file)+"' as main project file?",buttons:{confirm:{label:"Open As New Project"},cancel:{label:"Include/Link With Project Later"}},callback:g=>{g?xr():setTimeout(Si,1e3)}})),br("workspace","file","upload");else{var l=a.name,d=new FileReader;d.onload=function(g){var y=g.target.result,b=new Uint8Array(y);gr(l,b)||(b=an(b).replace(`\r
`,`
`)),ue.updateFile(l,b),console.log("Uploaded "+l+" "+b.length+" bytes"),r()},d.readAsArrayBuffer(a)}}u&&r()}async function zl(u){var t=window.showDirectoryPicker;t||be("This browser can't open local files on your computer, yet. Try Chrome.");var r=await t(),a=r.name,l="__localfs__"+a,d={handle:r},g=Qa.createInstance({name:l,version:2});await g.setItem(l,d),Z={localfs:a},xr(!0)}async function Vl(u){return new Promise((t,r)=>{bootbox.prompt(wr.sanitize(u),a=>{t(a)})})}async function Gl(u){let t={mode:"readwrite"};var r="__localfs__"+u,a=Qa.createInstance({name:r,version:2}),l=await a.getItem(r),d=l.handle;console.log(l,d);var g=await d.queryPermission(t);if(console.log(g),g!=="granted"&&(await Vl("Request permissions to access filesystem?"),g=await d.requestPermission(t)),g!=="granted"){be("Could not get permission to access filesystem.");return}return{getFileData:async y=>{console.log("getFileData",y);let b=await d.getFileHandle(y,{create:!1});console.log("getFileData",b);let D=await b.getFile();console.log("getFileData",D);let W=await(gr(y)?D.binary():D.text());return console.log(b,D,W),W},setFileData:async(y,b)=>{}}}function ze(){return lt(de.mainPath)}function xo(){return lt(ue.getActiveID())}function ql(u){var t=ue.getActive();if(t&&t.setText){var r=ue.getActiveID();$.get("presets/"+ut(ie)+"/"+r,a=>{bootbox.confirm("Reset '"+wr.sanitize(r)+"' to default?",l=>{l&&t.setText(a)})},"text").fail(()=>{Ne?be("Can only revert built-in examples. If you want to revert all files, You can pull from the repository."):be("Can only revert built-in examples.")})}else be("Cannot revert the active window. Please choose a text file.")}function Yl(u){var t=ue.getActive();if(t&&t.getPath){var r=ue.getActiveID();bootbox.confirm("Delete '"+wr.sanitize(r)+"'?",a=>{a&&yt.removeItem(r).then(()=>{Z.file==r?(Sr.unsetLastPreset(),xr()):(Si(),ht("Deleted "+r))})})}else be("Cannot delete the active window.")}function Xl(u){var t=ue.getActive();if(t&&t.getPath&&de.getFile(t.getPath())){var r=ue.getActiveID();bootbox.prompt({title:"Rename '"+wr.sanitize(r)+"' to?",value:r,callback:a=>{var l=de.getFile(t.getPath());if(a&&a!=r&&l){if(!is(a))return;yt.removeItem(r).then(()=>yt.setItem(a,l)).then(()=>{Si(),alert("Renamed "+r+" to "+a),r==de.mainPath&&rs(a)})}}})}else be("Cannot rename the active window.")}function Ql(u){let t={},r,a=P.getPresets?P.getPresets():[];for(var l=0;l<a.length;l++){var d=a[l],g=d.chapter?d.chapter+". "+d.name:d.name,y=d.id==de.mainPath;d.category?r=$("<optgroup />").attr("label","Examples: "+d.category).appendTo(u):r||(r=$("<optgroup />").attr("label","Examples").appendTo(u)),r.append($("<option />").val(d.id).text(g).attr("selected",y?"selected":null)),y&&(Tn=d),t[d.id]=g}return t}function Jl(u){if(xt&&!xi){var t=0,r=Nr();if(r){let l=$("<optgroup />").attr("label","Repositories").appendTo(u);for(let d in r){var a=r[d];a.platform_id&&ut(a.platform_id)==ut(ie)&&l.append($("<option />").val(a.url).text(a.url.substring(a.url.indexOf("/"))))}}}}async function Co(u,t,r,a){let l=await yt.keys();l||(l=[]);let d;for(var g=0;g<l.length;g++){let y=l[g];if(y.startsWith(r)&&!a[y]){d||(d=$("<optgroup />").attr("label",t).appendTo(u));let b=y.substring(r.length);d.append($("<option />").val(y).text(b).attr("selected",y==de.mainPath?"selected":null))}}}function Po(u){u.css("visibility","visible");var t=de.mainPath;u.val()!=t&&u.append($("<option />").val(t).text(t).attr("selected","selected"))}async function Si(){var u=$("#preset_select").empty();if(Ne)u.append($("<option />").val("/").text("Leave Repository")),$("#repo_name").text(lt(Ne)+"/").show(),await Co(u,Ne,"",{}),Po(u);else{Jl(u);var t=Ql(u);await Co(u,"Local Files","",t),Po(u)}u.off("change").change(function(r){rs($(this).val().toString())})}function Kl(u){var t=$("<p/>");if(u.path!=null){var r=u.line?u.label?`(${u.path} @ ${u.label})`:`(${u.path}:${u.line})`:`(${u.path})`,a=$("<a/>").text(r),l=u.path;l==ze()&&(l=de.mainPath),ue.isWindow(l)&&a.click(d=>{var g=ue.createOrShow(l);g instanceof di&&g.setCurrentLine(u,!0)}),t.append(a),t.append("&nbsp;")}return t.append($("<span/>").text(u.msg)),t}function ko(){$("#error_alert").hide(),Za=!1}function ns(u,t){var r=$("#error_alert_msg").empty();for(var a of u.slice(0,10))r.append(Kl(a));$("#error_alert").show(),Za=t}function Ao(u,t){if(t!=null){var r={msg:t,line:0};u instanceof ua&&u.$loc&&(r=Object.create(u.$loc),r.msg=t,console.log(r)),ns([r],!0)}}async function Zl(u){if("errors"in u&&u.errors.length>0)yi.addClass("has-errors"),ue.setErrors(u.errors),_i(),ns(u.errors,!1);else{if(yi.removeClass("has-errors"),ue.setErrors(null),ko(),u==null||"unchanged"in u&&u.unchanged||!("output"in u))return;P.debugSymbols=new Ts(u.symbolmap,u.debuginfo),wo=u.params;var t=u.output;if(t!=null)try{Ci(),Mo(),await P.loadROM(Il(),t),_r=t,Ka||zt(),Hu()}catch(r){console.log(r),yi.addClass("has-errors"),Ao(r,r+""),_r=null,_i();return}_i(),ue.refresh(!1)}}async function eu(){if(P.loadBIOS){var u=ie+".rom",t=await yt.getItem(u);t instanceof Uint8Array?(console.log("loading BIOS",u,t.length+" bytes"),P.loadBIOS(u,t)):console.log("BIOS file must be binary")}}function Do(){var u=$("#mem_info");u.hide(),wi=null}function Ti(u){if(!!Cs(P)){var t=$("#mem_info"),r=$("#mem_info_msg"),a=P.getDebugCategories();a&&!Ei&&(Ei=a[0]);var l=u&&P.getDebugInfo(Ei,u);if(typeof l=="string"){var d=wi?bs(wi,l):l;t.show(),r.html(d);var g=$('<div class="mem_info_links">'),y=D=>{var W=$("<a>"+D+"</a>");D==Ei&&W.addClass("selected"),W.click(ae=>{Ei=D,wi=null,Ti(nr)}),g.append(W),g.append("<span> </span>")};for(var b of a)y(b);r.append("<br>"),r.append(g),wi=l}else Do()}}function kn(u,t){$("#debug_bar, #run_bar").find("button").removeClass("btn_active").removeClass("btn_stopped"),$("#dbg_"+u).addClass("btn_"+t)}function as(){return P&&_r!=null}function Ct(){return as()?!0:(be("Can't do this until build successfully completes."),!1)}function tu(u){if(Pn&&Pn.startsWith("#")||["toline","restart","tovsync","stepover"].includes(Eo)||!P.disassemble)return;let t=de.getListings(),r="#disasm",a=256;if(t){let l=u.c?u.c.EPC||u.c.PC:0;for(let d in t){let g=t[d],y=g.assemblyfile||g.sourcefile,b=de.filename2path[d]||d;if(y==g.sourcefile&&(b=ue.findWindowWithFilePrefix(d)),ue.isWindow(b)){let D=y&&y.findLineForOffset(l,pn);if(D){let W=y.lines[D.line+1];if(!W||l<W.offset){let ae=l-D.offset;ae<a&&(r=b,a=ae)}}}}}ue.createOrShow(r,!0)}function An(u){nr=u,Ti(u),tu(u),ue.refresh(!0),Cn=!0}function Fo(u){P.setupDebug&&(P.setupDebug((t,r)=>{An(t),kn(u||"pause","stopped"),r&&ns([{msg:"STOPPED: "+r,line:0}],!0)}),Eo=u)}function It(u){!Ct()||(os(),Fo(u),u&&kn(u,"active"))}function sr(){P&&P.isRunning()&&(P.pause(),console.log("Paused")),kn("pause","stopped")}function ru(){!Ct()||(Ci(),sr(),Ka=!0)}function zt(){P.isRunning()||(P.resume(),console.log("Resumed")),kn("go","active"),Za&&ko()}function Ro(){!Ct()||(Ci(),P.isRunning()||ue.refresh(!1),zt(),Ka=!1,Pn=null)}function iu(){!Ct()||(It("step"),P.step())}function nu(){!Ct()||(It("stepover"),P.stepOver())}function au(){!Ct()||(It("tovsync"),P.runToVsync())}function Lo(){var u=ue.getActive();return u&&u.getCursorPC&&u.getCursorPC()}function hi(u){!Ct()||!(u>=0)||(It("toline"),console.log("Run to",u.toString(16)),P.runToPC?P.runToPC(u):P.runEval(t=>t.PC==u))}function su(){P.restartAtPC(Lo())?Ro():be("Could not restart program at selected line.")}function ou(){hi(Lo())}function lu(){!Ct()||(It("stepout"),P.runUntilReturn())}function uu(){!Ct()||(It("stepback"),P.stepBack())}function Ci(){nr=null,P.clearDebug&&P.clearDebug(),Fo(),Ti()}function ss(){P.reset(),Mo()}function cu(){!Ct()||(Ci(),ss(),zt())}function fu(){if(!!Ct()){var u=$r;os(),P.setupDebug&&P.runEval?(Ci(),zt(),ss(),It("restart"),P.runEval(t=>!0)):(ss(),zt()),u&&No()}}function du(){var u=$("#debugExprModal"),t=$("#debugExprSubmit");$("#debugExprInput").val(_o),$("#debugExprExamples").text(hu()),u.modal("show"),t.off("click").on("click",()=>{var r=$("#debugExprInput").val()+"";u.modal("hide"),pu(r)})}function hu(){var u=P.saveState&&P.saveState(),t=u.c;console.log(t,u);var r="";return t.PC&&(r+="c.PC == 0x"+Ae(t.PC)+`
`),t.SP&&(r+="c.SP < 0x"+Ae(t.SP)+`
`),t.HL&&(r+=`c.HL == 0x4000
`),P.readAddress&&(r+=`this.readAddress(0x1234) == 0x0
`),P.readVRAMAddress&&(r+=`this.readVRAMAddress(0x1234) != 0x80
`),P.getRasterScanline&&(r+=`this.getRasterScanline() > 222
`),r}function pu(u){var t=new Function("c","return ("+u+");").bind(P);It(),P.runEval(t),_o=u}function Io(){P.isRunning()?(ue.tick(),Cn=!1):Cn||(ue.tick(),Cn=!0),setTimeout(Io,100)}function Dn(u){P.setFrameRate(u),u>.01?$("#fps_label").text(u.toFixed(2)):$("#fps_label").text("1/"+Math.round(1/u))}function gu(){var u=P.getFrameRate();u=u/2,u>1e-5&&Dn(u)}function mu(){var u=P.getFrameRate();u=Math.min(60,u*2),Dn(u)}function vu(){Dn(60/65536)}function bu(){zt(),Dn(60)}function yu(){ue.refresh(!1);var u=ue.getActive();if(u.getSourceFile&&u.setTimingResult){var t=P.newCodeAnalyzer();t.showLoopTimingForPC(0),u.setTimingResult(t)}}function os(){$r&&(P.setRecorder(null),$("#dbg_record").removeClass("btn_recording"),$("#replaydiv").hide(),Do(),$r=!1)}function Mo(){$r&&rt.reset()}function No(){rt.reset(),P.setRecorder(rt),$("#dbg_record").addClass("btn_recording"),$("#replaydiv").show(),$r=!0}function xu(){$r?os():No()}function Vt(u,t,r){var a=ue.getActive();a&&a.insertText?bootbox.prompt({title:"Add "+wr.sanitize(u)+" File to Project",value:"filename"+wr.sanitize(t),callback:l=>{if(l&&l.trim().length>0){if(!is(l))return;var d=l,g=`
`+r(l)+`
`;de.loadFiles([d]).then(y=>{y&&y.length?be(l+" already exists; including anyway"):de.updateFile(d,`
`),a.insertText(g),_i()})}}}):be("Can't insert text in this window -- switch back to main file")}function wu(){var u=ze(),t=P.getToolForFilename(u);u.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?Vt("Header",".h",r=>'#include "'+r+'"'):t=="dasm"||t=="zmac"?Vt("Include",".inc",r=>' include "'+r+'"'):t=="ca65"||t=="sdasz80"||t=="vasm"||t=="armips"?Vt("Include",".inc",r=>' .include "'+r+'"'):t=="verilator"?Vt("Verilog",".v",r=>'`include "'+r+'"'):t=="wiz"?Vt("Include",".wiz",r=>'import "'+r+'";'):t=="ecs"?Vt("Include",".ecs",r=>'import "'+r+'"'):t=="acme"?Vt("Include",".acme",r=>'!src "'+r+'"'):be("Can't add include file to this project type ("+t+")")}function Eu(){var u=ze(),t=P.getToolForFilename(u);u.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?Vt("Linked C (or .s)",".c",r=>'//#link "'+r+'"'):u.endsWith("asm")||u.endsWith(".s")||t=="ca65"||t=="lwasm"?Vt("Linked ASM",".inc",r=>';#link "'+r+'"'):be("Can't add linked file to this project type ("+t+")")}function _u(){if(Be=new cn($("#toolbar")[0],null),Be.grp.prop("id","run_bar"),Be.add("ctrl+alt+r","Reset","glyphicon-refresh",cu).prop("id","dbg_reset"),Be.add("ctrl+alt+,","Pause","glyphicon-pause",ru).prop("id","dbg_pause"),Be.add("ctrl+alt+.","Resume","glyphicon-play",Ro).prop("id","dbg_go"),P.restartAtPC&&Be.add("ctrl+alt+/","Restart at Cursor","glyphicon-play-circle",su).prop("id","dbg_restartatline"),Be.newGroup(),Be.grp.prop("id","debug_bar"),P.runEval&&Be.add("ctrl+alt+e","Reset and Debug","glyphicon-fast-backward",fu).prop("id","dbg_restart"),P.stepBack&&Be.add("ctrl+alt+b","Step Backwards","glyphicon-step-backward",uu).prop("id","dbg_stepback"),P.step&&Be.add("ctrl+alt+s","Single Step","glyphicon-step-forward",iu).prop("id","dbg_step"),P.stepOver&&Be.add("ctrl+alt+t","Step Over","glyphicon-hand-right",nu).prop("id","dbg_stepover"),P.runUntilReturn&&Be.add("ctrl+alt+o","Step Out of Subroutine","glyphicon-hand-up",lu).prop("id","dbg_stepout"),P.runToVsync&&Be.add("ctrl+alt+n","Next Frame/Interrupt","glyphicon-forward",au).prop("id","dbg_tovsync"),(P.runEval||P.runToPC)&&!ie.startsWith("verilog")&&Be.add("ctrl+alt+l","Run To Line","glyphicon-save",ou).prop("id","dbg_toline"),Be.newGroup(),Be.grp.prop("id","xtra_bar"),$(".dropdown-menu").collapse({toggle:!1}),$("#item_new_file").click(Ul),$("#item_upload_file").click(Bl),$("#item_open_directory").click(zl),$("#item_github_login").click(ro),$("#item_github_logout").click(io),$("#item_github_import").click(no),$("#item_github_publish").click(ao),$("#item_github_push").click(so),$("#item_github_pull").click(oo),$("#item_repo_delete").click(uo),$("#item_share_file").click(co),$("#item_reset_file").click(ql),$("#item_rename_file").click(Xl),$("#item_delete_file").click(Yl),P.runEval?$("#item_debug_expr").click(du).show():$("#item_debug_expr").hide(),$("#item_download_rom").click(ho),$("#item_download_file").click(po),$("#item_download_zip").click(mo),P.getDebugSymbolFile?$("#item_download_sym").click(vo):$("#item_download_sym").hide(),$("#item_download_allzip").click(bo),$("#item_record_video").click(yo),Ya()?$("#item_export_cassette").click(fo):$("#item_export_cassette").hide(),P.setFrameRate&&P.getFrameRate&&($("#dbg_slower").click(gu),$("#dbg_faster").click(mu),$("#dbg_slowest").click(vu),$("#dbg_fastest").click(bu)),$("#item_addfile_include").click(wu),$("#item_addfile_link").click(Eu),$("#item_request_persist").click(()=>es(!0,!1)),Io(),P.newCodeAnalyzer&&Be.add(null,"Analyze CPU Timing","glyphicon-time",yu),P.setRecorder&&P.advance&&Su(),P.showHelp){let{li:r,a}=ts("help__"+ie,Ja+" Help");$("#help_menu").append(r),$(a).click(()=>window.open(P.showHelp(),"_8bws_help"))}let u=P.getToolForFilename(ze()),t=Rl[u];if(t){let{li:r,a}=ts("help__"+u,u+" Help");$("#help_menu").append(r),$(a).click(()=>window.open(t,"_8bws_help"))}}function Su(){var u=$("#replayslider"),t=$("#clockslider"),r=$("#replay_frame"),a=$("#replay_clock");P.advanceFrameClock||$("#clockdiv").hide();var l=()=>{r.text(rt.lastSeekFrame+""),a.text(rt.lastSeekStep+"")},d=b=>{sr();var D=parseInt(u.val().toString()),W=parseInt(t.val().toString());rt.loadFrame(D,W)>=0&&(t.attr("min",0),t.attr("max",rt.lastStepCount),l(),An(P.saveState()))},g=b=>{sr(),rt.loadFrame(b)>=0&&(u.val(b),l(),An(P.saveState()))},y=b=>{sr();var D=parseInt(u.val().toString());rt.loadFrame(D,b)>=0&&(t.val(b),l(),An(P.saveState()))};rt.callbackStateChanged=()=>{u.attr("min",0),u.attr("max",rt.numFrames()),u.val(rt.currentFrame()),t.val(rt.currentStep()),l(),Ti(P.saveState())},u.on("input",d),t.on("input",d),$("#replay_min").click(()=>{g(1)}),$("#replay_max").click(()=>{g(rt.numFrames())}),$("#replay_back").click(()=>{g(parseInt(u.val().toString())-1)}),$("#replay_fwd").click(()=>{g(parseInt(u.val().toString())+1)}),$("#clock_back").click(()=>{y(parseInt(t.val().toString())-1)}),$("#clock_fwd").click(()=>{y(parseInt(t.val().toString())+1)}),$("#replay_bar").show(),Be.add("ctrl+alt+0","Start/Stop Replay Recording","glyphicon-record",xu).prop("id","dbg_record")}function Tu(){try{var u=window.screen.orientation||window.screen.msOrientation||window.screen.mozOrientation||null;if(u){if(u.type.indexOf("landscape")!==-1)return!0;if(u.type.indexOf("portrait")!==-1)return!1}if("orientation"in window){var t=window.orientation;if(t===0||t===180)return!1;if(t===90||t===270)return!0}}catch(r){}return window.innerWidth>window.innerHeight}async function Cu(){if(Sr.shouldCompleteTour()){await bt("lib/bootstrap-tourist.js");var u=ie.startsWith("vcs"),t=[{element:"#platformsMenuButton",placement:"right",title:"Platform Selector",content:`You're currently on the "<b>`+ie+'</b>" platform. You can choose a different one from the menu.'},{element:"#preset_select",title:"Project Selector",content:"You can choose different code examples, create your own files, or import projects from GitHub."},{element:"#workspace",title:"Code Editor",content:u?"Type your 6502 assembly code into the editor, and it'll be assembled in real-time.":"Type your source code into the editor, and it'll be compiled in real-time."},{element:"#emulator",placement:"left",title:"Emulator",content:"We'll load your compiled code into the emulator whenever you make changes."},{element:"#debug_bar",placement:"bottom",title:"Debug Tools",content:"Use these buttons to set breakpoints, single step through code, pause/resume, and use debugging tools."},{element:"#dropdownMenuButton",title:"Main Menu",content:"Click the menu to create new files, download your code, or share your work with others."},{element:"#sidebar",title:"Sidebar",content:"Pull right to expose the sidebar. It lets you switch between source files, view assembly listings, and use other tools like Disassembler, Memory Browser, and Asset Editor."}];Tu()||t.unshift({element:"#controls_top",placement:"bottom",title:"Portrait mode detected",content:"This site works best on desktop browsers. For best results, rotate your device to landscape orientation."}),window.location.host.endsWith("8bitworkshop.com")&&(t.unshift({element:"#dropdownMenuButton",placement:"right",title:"Cookie Consent",content:'Before we start, we should tell you that this website stores cookies and other data in your browser. You can review our <a href="/privacy.html" target="_new">privacy policy</a>.'}),t.push({element:"#booksMenuButton",placement:"left",title:"Books",content:"Get some books that explain how to program all of this stuff, and write some games!"})),xi&&(t.unshift({element:"#dropdownMenuButton",placement:"right",title:"Developer Analytics",content:"BTW, we send stack traces to sentry.io when exceptions are thrown. Hope that's ok."}),t.unshift({element:"#dropdownMenuButton",placement:"right",title:"Welcome to 8bitworkshop Desktop!",content:'The directory "~/8bitworkshop" contains all of your file edits and built ROM images. You can create new projects under the platform directories (e.g. "c64/myproject")'}));var r=new Tour({autoscroll:!1,steps:t,onEnd:()=>{Sr.completedTour()}});setTimeout(()=>{r.start()},2500)}}function Fn(u){var t=(u.message||u.error||u)+"";if(t.indexOf("QuotaExceededError")>=0)es(!1,!1);else{var r=u.error||u.reason;r!=null&&r instanceof ua&&Pu(r)}}function Pu(u){console.log("haltEmulation"),sr(),Bu(u)}function ku(){window.addEventListener("error",Fn),window.addEventListener("unhandledrejection",Fn)}function Oo(){window.removeEventListener("error",Fn),window.removeEventListener("unhandledrejection",Fn)}function xr(u,t){t&&(Z=t),Oo(),u?window.location.replace("?"+$.param(Z)):window.location.href="?"+$.param(Z)}function Rn(){ie&&(Z.platform=ie),delete Z[""],history.replaceState({},"","?"+$.param(Z))}function Au(){var u=!1;document.addEventListener("visibilitychange",()=>{document.visibilityState=="hidden"&&P&&P.isRunning()?(sr(),u=!0):document.visibilityState=="visible"&&u&&(zt(),u=!1)}),$(window).on("focus",()=>{u&&(zt(),u=!1)}),$(window).on("blur",()=>{P&&P.isRunning()&&(sr(),u=!0)}),$(window).on("orientationchange",()=>{P&&P.resize&&setTimeout(P.resize.bind(P),200)})}function Du(){var u=$(document).find(".emucontrols-"+Ir(ie));ie.endsWith(".mame")&&u.show();var t=$("#emulator").find("canvas");t&&(t.on("focus",()=>{P.isRunning()&&(u.fadeIn(200),P.pause(),P.resume())}),t.on("blur",()=>{u.fadeOut(200)}))}function Fu(){window.ga&&($(".dropdown-item").click(u=>{u.target&&u.target.id&&br("menu",u.target.id)}),to(location.pathname+"?platform="+ie+(Ne?"&repo="+Ne:"&file="+Z.file)))}async function Ru(){if(!la[ie])throw Error("Invalid platform '"+ie+"'.");let u=$("#emuscreen")[0],t=oa(Z.options||"");P=new la[ie](u,t),$u(),rt=new ks(P);let r=P.getPresets?P.getPresets():[];if(!Z.file){var a=Sr.getLastPreset(),l=a||(Ne?null:r[0].id);Z.file=l||"DEFAULT",l||be("There is no default main file for this project. Try selecting one from the pulldown.")}ie=="vcs"&&Z.file.startsWith("examples/")&&!Z.file.endsWith(".a")&&(Z.file+=".a"),Rn(),ku(),Fu(),await P.start(),await eu(),await Nl(),await Wl(Z.file),P.sourceFileFetch=d=>de.filedata[d],_u(),Au(),Du(),it?Lu():(Si(),Iu(),Cu()),$o()}function Lu(){$("#dropdownMenuButton").hide(),$("#platformsMenuButton").hide(),$("#booksMenuButton").hide()}function Iu(){Ir(ie)=="nes"?$(".book-nes").addClass("book-active"):Ir(ie)=="vcs"?$(".book-vcs").addClass("book-active"):Ir(ie)=="verilog"?$(".book-verilog").addClass("book-active"):P.getToolForFilename(ze())=="sdcc"&&$(".book-arcade").addClass("book-active")}function $o(){setTimeout(()=>{$("#controls_dynamic").css("visibility","inherit")},250)}function Mu(){var u="workspace-split3-"+ie;it&&(u="embed-"+u);var t;ie.startsWith("vcs")?t=[0,50,50]:it||fi?t=[0,55,45]:t=[12,44,44];var r=xt&&localStorage.getItem(u);if(r)try{t=JSON.parse(r)}catch(l){console.log(l)}var a=Dl(["#sidebar","#workspace","#emulator"],{sizes:t,minSize:[0,250,250],onDrag:()=>{P&&P.resize&&P.resize()},onDragEnd:()=>{xt&&localStorage.setItem(u,JSON.stringify(a.getSizes())),ue&&ue.resize()}})}function Nu(u){let t=Mr(Z.ignore)||it;Le(!0),on(u,async r=>{if(r){var a=lt(u);console.log("Importing "+r.length+" bytes as "+a);try{var l=await yt.getItem(a);Le(!1),l!=null&&t||(l==null||confirm("Replace existing file '"+a+"'?"))&&await yt.setItem(a,r),delete Z.importURL,Z.file=a,Rn(),jo()}finally{Le(!1)}}else be("Could not load source code from URL: "+u),Le(!1)},"text")}async function Ou(){var u=Mr(Z.ignore),t=Mr(Z.force);it?u=!t:t=!1;for(var r=0;r<20;r++){let l=Z["file"+r+"_name"],d=Z["file"+r+"_data"];if(l==null||d==null)break;var a=await yt.getItem(l);if(!(u&&a)){let g=d;Z["file"+r+"_type"]=="binary"&&(g=rn(atob(g))),(!a||t||confirm("Replace existing file '"+l+"'?"))&&await yt.setItem(l,g)}r==0&&(Z.file=l),delete Z["file"+r+"_name"],delete Z["file"+r+"_data"],delete Z["file"+r+"_type"]}delete Z.ignore,delete Z.force,Rn()}function $u(){var u=P.getPlatformName&&P.getPlatformName(),t=$('a[href="?platform='+ie+'"]');t.length&&(t.addClass("dropdown-item-checked"),u=u||t.text()||u),Ja=u||ie,$(".platform_name").text(Ja)}function Wu(){if(ie=Z.platform||Sr.getLastPlatformID(),Ne=Z.repo,!Z.repo&&!Z.file&&(Ne=Sr.getLastRepoID(ie)),xt&&Ne&&Ne!=="/"){var u=Nr()[Ne];u&&(console.log(ie,Z,u),Z.repo=Ne,u.platform_id&&!Z.platform&&(Z.platform=ie=u.platform_id),u.mainPath&&!Z.file&&(Z.file=u.mainPath))}else Ne="",delete Z.repo;ie||(it&&eo("The 'platform' must be specified when embed=1"),ie=Z.platform="vcs")}async function Wo(){if(Z.githubURL){Sn(Z.githubURL,!0);return}if(Wu(),Mu(),Er=Ne||ut(ie),it&&(Er=(document.referrer||document.location.href)+Er),yt=dn(Er),Z.importURL){Nu(Z.importURL);return}Z.file0_name&&await Ou(),jo()}async function jo(){try{var u=await As(Ir(ie));console.log("starting platform",ie),await Ru(),document.title=document.title+" ["+ie+"] - "+(Ne?"["+Ne+"] - ":"")+de.mainPath}catch(t){console.log(t),be('Platform "'+ie+'" failed to load.')}finally{$o()}}var ls="__use_https";function Uo(u){document.cookie=ls+"="+u+";domain=8bitworkshop.com;path=/;max-age=315360000"}function ju(){var u=ln(ls);if(typeof u=="string")return!!u;var t=xt&&!localStorage.getItem("__lastplatform")?1:0;return Uo(t),!!t}function Uu(){bootbox.confirm('<p>Do you want to force the browser to use HTTPS from now on?</p><p>WARNING: This will make all of your local files unavailable, so you should "Download All Changes" first for each platform where you have done work.</p><p>You can go back to HTTP by setting the "'+ls+'" cookie to 0.</p>',u=>{u&&(Uo(1),Bo())})}function Bo(){window.location.protocol=="http:"&&window.location.host=="8bitworkshop.com"&&(ju()?(Oo(),window.location.replace(window.location.href.replace(/^http:/,"https:"))):$("#item_switch_https").click(Uu).show())}Bo();function Mf(u,t){P.writeFile(u,t)}function Nf(u){return P.readFile(u)}function Of(){return P.saveState()}function Bu(u){var t=u&&u.message||t;Ao(u,t),ue.refresh(!1),P.saveState&&Ti(P.saveState())}async function $f(u){var t=de.filedata[u];t!=null&&(ue.updateFile(u,await alternateLocalFilesystem.getFileData(u)),console.log("updating file",u))}function Hu(){if(xi&&_r instanceof Uint8Array){var u=Je(ze()),t=P.getROMExtension&&P.getROMExtension(_r)||"-"+ut(ie)+".bin";alternateLocalFilesystem.setFileData(`bin/${u}${t}`,_r)}}function Wf(u){var t=ue.getActive();if(t instanceof di){var r=t.editor.getSearchCursor(u);r.findNext()&&t.editor.setSelection(r.pos.to,r.pos.from)}}function zu(){let u=!1;new IntersectionObserver((r,a)=>{for(var l of r)l.isIntersecting&&!u&&(Wo(),u=!0),l.intersectionRatio==0&&as()&&P.isRunning()&&sr(),l.intersectionRatio>0&&as()&&!P.isRunning()&&zt()},{}).observe($("#emulator")[0])}typeof process=="undefined"&&(it&&typeof IntersectionObserver=="function"?zu():Wo());export{$s as a,Z as b,ie as c,Er as d,Ne as e,P as f,de as g,ue as h,nr as i,ar as j,Ht as k,tt as l,pi as m,ze as n,xo as o,It as p,hi as q,Ci as r,Dn as s,Pu as t,xr as u,Mu as v,Wu as w,Wo as x,Mf as y,Nf as z,Of as A,Bu as B,$f as C,Wf as D};
/*!
localForage -- Offline Storage, Improved
Version 1.10.0
https://localforage.github.io/localForage
(c) 2013-2017 Mozilla, Apache License 2.0
*/
/*!
* jQuery JavaScript Library v3.7.1
* https://jquery.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2023-08-28T13:37Z
*/
//# sourceMappingURL=chunk-Q5ACPWUW.js.map