8bitworkshop/gen/chunk-GBRUOVY7.js

49 lines
227 KiB
JavaScript

import{a as ln,b as nl,c as al}from"./chunk-SDBJC2RS.js";import{a as Is}from"./chunk-XMPGMPQ4.js";import{a as Ms,b as Ns,c as sl}from"./chunk-AGGKDGWZ.js";import{D as da,J as ha,l as te,u as Fs,v as Rs}from"./chunk-Z5TYMA6U.js";import{$ as on,D as Rt,E as ua,F as Fr,G as As,H as ca,R as fa,T as Ds,a as Ft,aa as Ls,b as ui,ba as ci,d as _t,e as la,f as ft,g as Le,j as Ts,l as tn,m as rn,n as nn,o as vr,p as Cs,s as an,v as ks,w as Ps,x as sn,y as vt,z as Lr}from"./chunk-6HNEHZRR.js";import{a as li,b as _s,c as oa}from"./chunk-RQFURXHW.js";var ma=_s((Os,pa)=>{(function(l){if(typeof Os=="object"&&typeof pa!="undefined")pa.exports=l();else if(typeof define=="function"&&define.amd)define([],l);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=l()}})(function(){var l,t,r;return function a(u,d,m){function b(W,de){if(!d[W]){if(!u[W]){var z=typeof li=="function"&&li;if(!de&&z)return z(W,!0);if(y)return y(W,!0);var H=new Error("Cannot find module '"+W+"'");throw H.code="MODULE_NOT_FOUND",H}var V=d[W]={exports:{}};u[W][0].call(V.exports,function(he){var K=u[W][1][he];return b(K||he)},V,V.exports,a,u,d,m)}return d[W].exports}for(var y=typeof li=="function"&&li,L=0;L<m.length;L++)b(m[L]);return b}({1:[function(a,u,d){(function(m){"use strict";var b=m.MutationObserver||m.WebKitMutationObserver,y;if(b){var L=0,W=new b(he),de=m.document.createTextNode("");W.observe(de,{characterData:!0}),y=function(){de.data=L=++L%2}}else if(!m.setImmediate&&typeof m.MessageChannel!="undefined"){var z=new m.MessageChannel;z.port1.onmessage=he,y=function(){z.port2.postMessage(0)}}else"document"in m&&"onreadystatechange"in m.document.createElement("script")?y=function(){var xe=m.document.createElement("script");xe.onreadystatechange=function(){he(),xe.onreadystatechange=null,xe.parentNode.removeChild(xe),xe=null},m.document.documentElement.appendChild(xe)}:y=function(){setTimeout(he,0)};var H,V=[];function he(){H=!0;for(var xe,Ce,be=V.length;be;){for(Ce=V,V=[],xe=-1;++xe<be;)Ce[xe]();be=V.length}H=!1}u.exports=K;function K(xe){V.push(xe)===1&&!H&&y()}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(a,u,d){"use strict";var m=a(1);function b(){}var y={},L=["REJECTED"],W=["FULFILLED"],de=["PENDING"];u.exports=z;function z(X){if(typeof X!="function")throw new TypeError("resolver must be a function");this.state=de,this.queue=[],this.outcome=void 0,X!==b&&K(this,X)}z.prototype.catch=function(X){return this.then(null,X)},z.prototype.then=function(X,ae){if(typeof X!="function"&&this.state===W||typeof ae!="function"&&this.state===L)return this;var oe=new this.constructor(b);if(this.state!==de){var _e=this.state===W?X:ae;V(oe,_e,this.outcome)}else this.queue.push(new H(oe,X,ae));return oe};function H(X,ae,oe){this.promise=X,typeof ae=="function"&&(this.onFulfilled=ae,this.callFulfilled=this.otherCallFulfilled),typeof oe=="function"&&(this.onRejected=oe,this.callRejected=this.otherCallRejected)}H.prototype.callFulfilled=function(X){y.resolve(this.promise,X)},H.prototype.otherCallFulfilled=function(X){V(this.promise,this.onFulfilled,X)},H.prototype.callRejected=function(X){y.reject(this.promise,X)},H.prototype.otherCallRejected=function(X){V(this.promise,this.onRejected,X)};function V(X,ae,oe){m(function(){var _e;try{_e=ae(oe)}catch(ze){return y.reject(X,ze)}_e===X?y.reject(X,new TypeError("Cannot resolve promise with itself")):y.resolve(X,_e)})}y.resolve=function(X,ae){var oe=xe(he,ae);if(oe.status==="error")return y.reject(X,oe.value);var _e=oe.value;if(_e)K(X,_e);else{X.state=W,X.outcome=ae;for(var ze=-1,Me=X.queue.length;++ze<Me;)X.queue[ze].callFulfilled(ae)}return X},y.reject=function(X,ae){X.state=L,X.outcome=ae;for(var oe=-1,_e=X.queue.length;++oe<_e;)X.queue[oe].callRejected(ae);return X};function he(X){var ae=X&&X.then;if(X&&(typeof X=="object"||typeof X=="function")&&typeof ae=="function")return function(){ae.apply(X,arguments)}}function K(X,ae){var oe=!1;function _e(Ke){oe||(oe=!0,y.reject(X,Ke))}function ze(Ke){oe||(oe=!0,y.resolve(X,Ke))}function Me(){ae(ze,_e)}var nt=xe(Me);nt.status==="error"&&_e(nt.value)}function xe(X,ae){var oe={};try{oe.value=X(ae),oe.status="success"}catch(_e){oe.status="error",oe.value=_e}return oe}z.resolve=Ce;function Ce(X){return X instanceof this?X:y.resolve(new this(b),X)}z.reject=be;function be(X){var ae=new this(b);return y.reject(ae,X)}z.all=Se;function Se(X){var ae=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var oe=X.length,_e=!1;if(!oe)return this.resolve([]);for(var ze=new Array(oe),Me=0,nt=-1,Ke=new this(b);++nt<oe;)bt(X[nt],nt);return Ke;function bt(nr,Sr){ae.resolve(nr).then(Nr,function(Jt){_e||(_e=!0,y.reject(Ke,Jt))});function Nr(Jt){ze[Sr]=Jt,++Me===oe&&!_e&&(_e=!0,y.resolve(Ke,ze))}}}z.race=o;function o(X){var ae=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var oe=X.length,_e=!1;if(!oe)return this.resolve([]);for(var ze=-1,Me=new this(b);++ze<oe;)nt(X[ze]);return Me;function nt(Ke){ae.resolve(Ke).then(function(bt){_e||(_e=!0,y.resolve(Me,bt))},function(bt){_e||(_e=!0,y.reject(Me,bt))})}}},{"1":1}],3:[function(a,u,d){(function(m){"use strict";typeof m.Promise!="function"&&(m.Promise=a(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"2":2}],4:[function(a,u,d){"use strict";var m=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 b(p,S){if(!(p instanceof S))throw new TypeError("Cannot call a class as a function")}function y(){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 L=y();function W(){try{if(!L||!L.open)return!1;var p=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),S=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||S)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(v){return!1}}function de(p,S){p=p||[],S=S||{};try{return new Blob(p,S)}catch(_){if(_.name!=="TypeError")throw _;for(var v=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,C=new v,k=0;k<p.length;k+=1)C.append(p[k]);return C.getBlob(S.type)}}typeof Promise=="undefined"&&a(3);var z=Promise;function H(p,S){S&&p.then(function(v){S(null,v)},function(v){S(v)})}function V(p,S,v){typeof S=="function"&&p.then(S),typeof v=="function"&&p.catch(v)}function he(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function K(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var xe="local-forage-detect-blob-support",Ce=void 0,be={},Se=Object.prototype.toString,o="readonly",X="readwrite";function ae(p){for(var S=p.length,v=new ArrayBuffer(S),C=new Uint8Array(v),k=0;k<S;k++)C[k]=p.charCodeAt(k);return v}function oe(p){return new z(function(S){var v=p.transaction(xe,X),C=de([""]);v.objectStore(xe).put(C,"key"),v.onabort=function(k){k.preventDefault(),k.stopPropagation(),S(!1)},v.oncomplete=function(){var k=navigator.userAgent.match(/Chrome\/(\d+)/),_=navigator.userAgent.match(/Edge\//);S(_||!k||parseInt(k[1],10)>=43)}}).catch(function(){return!1})}function _e(p){return typeof Ce=="boolean"?z.resolve(Ce):oe(p).then(function(S){return Ce=S,Ce})}function ze(p){var S=be[p.name],v={};v.promise=new z(function(C,k){v.resolve=C,v.reject=k}),S.deferredOperations.push(v),S.dbReady?S.dbReady=S.dbReady.then(function(){return v.promise}):S.dbReady=v.promise}function Me(p){var S=be[p.name],v=S.deferredOperations.pop();if(v)return v.resolve(),v.promise}function nt(p,S){var v=be[p.name],C=v.deferredOperations.pop();if(C)return C.reject(S),C.promise}function Ke(p,S){return new z(function(v,C){if(be[p.name]=be[p.name]||ar(),p.db)if(S)ze(p),p.db.close();else return v(p.db);var k=[p.name];S&&k.push(p.version);var _=L.open.apply(L,k);S&&(_.onupgradeneeded=function(N){var B=_.result;try{B.createObjectStore(p.storeName),N.oldVersion<=1&&B.createObjectStore(xe)}catch(q){if(q.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+N.oldVersion+" to version "+N.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw q}}),_.onerror=function(N){N.preventDefault(),C(_.error)},_.onsuccess=function(){var N=_.result;N.onversionchange=function(B){B.target.close()},v(N),Me(p)}})}function bt(p){return Ke(p,!1)}function nr(p){return Ke(p,!0)}function Sr(p,S){if(!p.db)return!0;var v=!p.db.objectStoreNames.contains(p.storeName),C=p.version<p.db.version,k=p.version>p.db.version;if(C&&(p.version!==S&&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||v){if(v){var _=p.db.version+1;_>p.version&&(p.version=_)}return!0}return!1}function Nr(p){return new z(function(S,v){var C=new FileReader;C.onerror=v,C.onloadend=function(k){var _=btoa(k.target.result||"");S({__local_forage_encoded_blob:!0,data:_,type:p.type})},C.readAsBinaryString(p)})}function Jt(p){var S=ae(atob(p.data));return de([S],{type:p.type})}function Or(p){return p&&p.__local_forage_encoded_blob}function yt(p){var S=this,v=S._initReady().then(function(){var C=be[S._dbInfo.name];if(C&&C.dbReady)return C.dbReady});return V(v,p,p),v}function Ln(p){ze(p);for(var S=be[p.name],v=S.forages,C=0;C<v.length;C++){var k=v[C];k._dbInfo.db&&(k._dbInfo.db.close(),k._dbInfo.db=null)}return p.db=null,bt(p).then(function(_){return p.db=_,Sr(p)?nr(p):_}).then(function(_){p.db=S.db=_;for(var N=0;N<v.length;N++)v[N]._dbInfo.db=_}).catch(function(_){throw nt(p,_),_})}function Ze(p,S,v,C){C===void 0&&(C=1);try{var k=p.db.transaction(p.storeName,S);v(null,k)}catch(_){if(C>0&&(!p.db||_.name==="InvalidStateError"||_.name==="NotFoundError"))return z.resolve().then(function(){if(!p.db||_.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),nr(p)}).then(function(){return Ln(p).then(function(){Ze(p,S,v,C-1)})}).catch(v);v(_)}}function ar(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Di(p){var S=this,v={db:null};if(p)for(var C in p)v[C]=p[C];var k=be[v.name];k||(k=ar(),be[v.name]=k),k.forages.push(S),S._initReady||(S._initReady=S.ready,S.ready=yt);var _=[];function N(){return z.resolve()}for(var B=0;B<k.forages.length;B++){var q=k.forages[B];q!==S&&_.push(q._initReady().catch(N))}var G=k.forages.slice(0);return z.all(_).then(function(){return v.db=k.db,bt(v)}).then(function(Y){return v.db=Y,Sr(v,S._defaultConfig.version)?nr(v):Y}).then(function(Y){v.db=k.db=Y,S._dbInfo=v;for(var Z=0;Z<G.length;Z++){var ye=G[Z];ye!==S&&(ye._dbInfo.db=v.db,ye._dbInfo.version=v.version)}})}function Fn(p,S){var v=this;p=he(p);var C=new z(function(k,_){v.ready().then(function(){Ze(v._dbInfo,o,function(N,B){if(N)return _(N);try{var q=B.objectStore(v._dbInfo.storeName),G=q.get(p);G.onsuccess=function(){var Y=G.result;Y===void 0&&(Y=null),Or(Y)&&(Y=Jt(Y)),k(Y)},G.onerror=function(){_(G.error)}}catch(Y){_(Y)}})}).catch(_)});return H(C,S),C}function $r(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){Ze(v._dbInfo,o,function(N,B){if(N)return _(N);try{var q=B.objectStore(v._dbInfo.storeName),G=q.openCursor(),Y=1;G.onsuccess=function(){var Z=G.result;if(Z){var ye=Z.value;Or(ye)&&(ye=Jt(ye));var ke=p(ye,Z.key,Y++);ke!==void 0?k(ke):Z.continue()}else k()},G.onerror=function(){_(G.error)}}catch(Z){_(Z)}})}).catch(_)});return H(C,S),C}function _r(p,S,v){var C=this;p=he(p);var k=new z(function(_,N){var B;C.ready().then(function(){return B=C._dbInfo,Se.call(S)==="[object Blob]"?_e(B.db).then(function(q){return q?S:Nr(S)}):S}).then(function(q){Ze(C._dbInfo,X,function(G,Y){if(G)return N(G);try{var Z=Y.objectStore(C._dbInfo.storeName);q===null&&(q=void 0);var ye=Z.put(q,p);Y.oncomplete=function(){q===void 0&&(q=null),_(q)},Y.onabort=Y.onerror=function(){var ke=ye.error?ye.error:ye.transaction.error;N(ke)}}catch(ke){N(ke)}})}).catch(N)});return H(k,v),k}function Ct(p,S){var v=this;p=he(p);var C=new z(function(k,_){v.ready().then(function(){Ze(v._dbInfo,X,function(N,B){if(N)return _(N);try{var q=B.objectStore(v._dbInfo.storeName),G=q.delete(p);B.oncomplete=function(){k()},B.onerror=function(){_(G.error)},B.onabort=function(){var Y=G.error?G.error:G.transaction.error;_(Y)}}catch(Y){_(Y)}})}).catch(_)});return H(C,S),C}function Rn(p){var S=this,v=new z(function(C,k){S.ready().then(function(){Ze(S._dbInfo,X,function(_,N){if(_)return k(_);try{var B=N.objectStore(S._dbInfo.storeName),q=B.clear();N.oncomplete=function(){C()},N.onabort=N.onerror=function(){var G=q.error?q.error:q.transaction.error;k(G)}}catch(G){k(G)}})}).catch(k)});return H(v,p),v}function In(p){var S=this,v=new z(function(C,k){S.ready().then(function(){Ze(S._dbInfo,o,function(_,N){if(_)return k(_);try{var B=N.objectStore(S._dbInfo.storeName),q=B.count();q.onsuccess=function(){C(q.result)},q.onerror=function(){k(q.error)}}catch(G){k(G)}})}).catch(k)});return H(v,p),v}function Mn(p,S){var v=this,C=new z(function(k,_){if(p<0){k(null);return}v.ready().then(function(){Ze(v._dbInfo,o,function(N,B){if(N)return _(N);try{var q=B.objectStore(v._dbInfo.storeName),G=!1,Y=q.openKeyCursor();Y.onsuccess=function(){var Z=Y.result;if(!Z){k(null);return}p===0||G?k(Z.key):(G=!0,Z.advance(p))},Y.onerror=function(){_(Y.error)}}catch(Z){_(Z)}})}).catch(_)});return H(C,S),C}function xt(p){var S=this,v=new z(function(C,k){S.ready().then(function(){Ze(S._dbInfo,o,function(_,N){if(_)return k(_);try{var B=N.objectStore(S._dbInfo.storeName),q=B.openKeyCursor(),G=[];q.onsuccess=function(){var Y=q.result;if(!Y){C(G);return}G.push(Y.key),Y.continue()},q.onerror=function(){k(q.error)}}catch(Y){k(Y)}})}).catch(k)});return H(v,p),v}function sr(p,S){S=K.apply(this,arguments);var v=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||v.name,p.storeName=p.storeName||v.storeName);var C=this,k;if(!p.name)k=z.reject("Invalid arguments");else{var _=p.name===v.name&&C._dbInfo.db,N=_?z.resolve(C._dbInfo.db):bt(p).then(function(B){var q=be[p.name],G=q.forages;q.db=B;for(var Y=0;Y<G.length;Y++)G[Y]._dbInfo.db=B;return B});p.storeName?k=N.then(function(B){if(!!B.objectStoreNames.contains(p.storeName)){var q=B.version+1;ze(p);var G=be[p.name],Y=G.forages;B.close();for(var Z=0;Z<Y.length;Z++){var ye=Y[Z];ye._dbInfo.db=null,ye._dbInfo.version=q}var ke=new z(function(Pe,We){var Fe=L.open(p.name,q);Fe.onerror=function(st){var Ht=Fe.result;Ht.close(),We(st)},Fe.onupgradeneeded=function(){var st=Fe.result;st.deleteObjectStore(p.storeName)},Fe.onsuccess=function(){var st=Fe.result;st.close(),Pe(st)}});return ke.then(function(Pe){G.db=Pe;for(var We=0;We<Y.length;We++){var Fe=Y[We];Fe._dbInfo.db=Pe,Me(Fe._dbInfo)}}).catch(function(Pe){throw(nt(p,Pe)||z.resolve()).catch(function(){}),Pe})}}):k=N.then(function(B){ze(p);var q=be[p.name],G=q.forages;B.close();for(var Y=0;Y<G.length;Y++){var Z=G[Y];Z._dbInfo.db=null}var ye=new z(function(ke,Pe){var We=L.deleteDatabase(p.name);We.onerror=function(){var Fe=We.result;Fe&&Fe.close(),Pe(We.error)},We.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},We.onsuccess=function(){var Fe=We.result;Fe&&Fe.close(),ke(Fe)}});return ye.then(function(ke){q.db=ke;for(var Pe=0;Pe<G.length;Pe++){var We=G[Pe];Me(We._dbInfo)}}).catch(function(ke){throw(nt(p,ke)||z.resolve()).catch(function(){}),ke})})}return H(k,S),k}var or={_driver:"asyncStorage",_initStorage:Di,_support:W(),iterate:$r,getItem:Fn,setItem:_r,removeItem:Ct,clear:Rn,length:In,key:Mn,keys:xt,dropInstance:sr};function le(){return typeof openDatabase=="function"}var $e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nn="~~local_forage_type~",Li=/^~~local_forage_type~([^~]+)~/,Tr="__lfsc__:",Cr=Tr.length,kr="arbf",$t="blob",wt="si08",Lt="ui08",Wt="uic8",Fi="si16",lr="si32",Wr="ur16",Br="ui32",Ri="fl32",Bt="fl64",Kt=Cr+kr.length,Ur=Object.prototype.toString;function jr(p){var S=p.length*.75,v=p.length,C,k=0,_,N,B,q;p[p.length-1]==="="&&(S--,p[p.length-2]==="="&&S--);var G=new ArrayBuffer(S),Y=new Uint8Array(G);for(C=0;C<v;C+=4)_=$e.indexOf(p[C]),N=$e.indexOf(p[C+1]),B=$e.indexOf(p[C+2]),q=$e.indexOf(p[C+3]),Y[k++]=_<<2|N>>4,Y[k++]=(N&15)<<4|B>>2,Y[k++]=(B&3)<<6|q&63;return G}function et(p){var S=new Uint8Array(p),v="",C;for(C=0;C<S.length;C+=3)v+=$e[S[C]>>2],v+=$e[(S[C]&3)<<4|S[C+1]>>4],v+=$e[(S[C+1]&15)<<2|S[C+2]>>6],v+=$e[S[C+2]&63];return S.length%3==2?v=v.substring(0,v.length-1)+"=":S.length%3==1&&(v=v.substring(0,v.length-2)+"=="),v}function tt(p,S){var v="";if(p&&(v=Ur.call(p)),p&&(v==="[object ArrayBuffer]"||p.buffer&&Ur.call(p.buffer)==="[object ArrayBuffer]")){var C,k=Tr;p instanceof ArrayBuffer?(C=p,k+=kr):(C=p.buffer,v==="[object Int8Array]"?k+=wt:v==="[object Uint8Array]"?k+=Lt:v==="[object Uint8ClampedArray]"?k+=Wt:v==="[object Int16Array]"?k+=Fi:v==="[object Uint16Array]"?k+=Wr:v==="[object Int32Array]"?k+=lr:v==="[object Uint32Array]"?k+=Br:v==="[object Float32Array]"?k+=Ri:v==="[object Float64Array]"?k+=Bt:S(new Error("Failed to get type for BinaryArray"))),S(k+et(C))}else if(v==="[object Blob]"){var _=new FileReader;_.onload=function(){var N=Nn+p.type+"~"+et(this.result);S(Tr+$t+N)},_.readAsArrayBuffer(p)}else try{S(JSON.stringify(p))}catch(N){console.error("Couldn't convert value into a JSON string: ",p),S(null,N)}}function Hr(p){if(p.substring(0,Cr)!==Tr)return JSON.parse(p);var S=p.substring(Kt),v=p.substring(Cr,Kt),C;if(v===$t&&Li.test(S)){var k=S.match(Li);C=k[1],S=S.substring(k[0].length)}var _=jr(S);switch(v){case kr:return _;case $t:return de([_],{type:C});case wt:return new Int8Array(_);case Lt:return new Uint8Array(_);case Wt:return new Uint8ClampedArray(_);case Fi:return new Int16Array(_);case Wr:return new Uint16Array(_);case lr:return new Int32Array(_);case Br:return new Uint32Array(_);case Ri:return new Float32Array(_);case Bt:return new Float64Array(_);default:throw new Error("Unkown type: "+v)}}var zr={serialize:tt,deserialize:Hr,stringToBuffer:jr,bufferToString:et};function Vr(p,S,v,C){p.executeSql("CREATE TABLE IF NOT EXISTS "+S.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],v,C)}function Ii(p){var S=this,v={db:null};if(p)for(var C in p)v[C]=typeof p[C]!="string"?p[C].toString():p[C];var k=new z(function(_,N){try{v.db=openDatabase(v.name,String(v.version),v.description,v.size)}catch(B){return N(B)}v.db.transaction(function(B){Vr(B,v,function(){S._dbInfo=v,_()},function(q,G){N(G)})},N)});return v.serializer=zr,k}function at(p,S,v,C,k,_){p.executeSql(v,C,k,function(N,B){B.code===B.SYNTAX_ERR?N.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[S.storeName],function(q,G){G.rows.length?_(q,B):Vr(q,S,function(){q.executeSql(v,C,k,_)},_)},_):_(N,B)},_)}function Zt(p,S){var v=this;p=he(p);var C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"SELECT * FROM "+N.storeName+" WHERE key = ? LIMIT 1",[p],function(q,G){var Y=G.rows.length?G.rows.item(0).value:null;Y&&(Y=N.serializer.deserialize(Y)),k(Y)},function(q,G){_(G)})})}).catch(_)});return H(C,S),C}function On(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"SELECT * FROM "+N.storeName,[],function(q,G){for(var Y=G.rows,Z=Y.length,ye=0;ye<Z;ye++){var ke=Y.item(ye),Pe=ke.value;if(Pe&&(Pe=N.serializer.deserialize(Pe)),Pe=p(Pe,ke.key,ye+1),Pe!==void 0){k(Pe);return}}k()},function(q,G){_(G)})})}).catch(_)});return H(C,S),C}function Mi(p,S,v,C){var k=this;p=he(p);var _=new z(function(N,B){k.ready().then(function(){S===void 0&&(S=null);var q=S,G=k._dbInfo;G.serializer.serialize(S,function(Y,Z){Z?B(Z):G.db.transaction(function(ye){at(ye,G,"INSERT OR REPLACE INTO "+G.storeName+" (key, value) VALUES (?, ?)",[p,Y],function(){N(q)},function(ke,Pe){B(Pe)})},function(ye){if(ye.code===ye.QUOTA_ERR){if(C>0){N(Mi.apply(k,[p,q,v,C-1]));return}B(ye)}})})}).catch(B)});return H(_,v),_}function qr(p,S,v){return Mi.apply(this,[p,S,v,1])}function Pr(p,S){var v=this;p=he(p);var C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"DELETE FROM "+N.storeName+" WHERE key = ?",[p],function(){k()},function(q,G){_(G)})})}).catch(_)});return H(C,S),C}function $n(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){at(N,_,"DELETE FROM "+_.storeName,[],function(){C()},function(B,q){k(q)})})}).catch(k)});return H(v,p),v}function Wn(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){at(N,_,"SELECT COUNT(key) as c FROM "+_.storeName,[],function(B,q){var G=q.rows.item(0).c;C(G)},function(B,q){k(q)})})}).catch(k)});return H(v,p),v}function Bn(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(B){at(B,N,"SELECT key FROM "+N.storeName+" WHERE id = ? LIMIT 1",[p+1],function(q,G){var Y=G.rows.length?G.rows.item(0).key:null;k(Y)},function(q,G){_(G)})})}).catch(_)});return H(C,S),C}function Ni(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){at(N,_,"SELECT key FROM "+_.storeName,[],function(B,q){for(var G=[],Y=0;Y<q.rows.length;Y++)G.push(q.rows.item(Y).key);C(G)},function(B,q){k(q)})})}).catch(k)});return H(v,p),v}function Un(p){return new z(function(S,v){p.transaction(function(C){C.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(k,_){for(var N=[],B=0;B<_.rows.length;B++)N.push(_.rows.item(B).name);S({db:p,storeNames:N})},function(k,_){v(_)})},function(C){v(C)})})}function jn(p,S){S=K.apply(this,arguments);var v=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||v.name,p.storeName=p.storeName||v.storeName);var C=this,k;return p.name?k=new z(function(_){var N;p.name===v.name?N=C._dbInfo.db:N=openDatabase(p.name,"","",0),p.storeName?_({db:N,storeNames:[p.storeName]}):_(Un(N))}).then(function(_){return new z(function(N,B){_.db.transaction(function(q){function G(ke){return new z(function(Pe,We){q.executeSql("DROP TABLE IF EXISTS "+ke,[],function(){Pe()},function(Fe,st){We(st)})})}for(var Y=[],Z=0,ye=_.storeNames.length;Z<ye;Z++)Y.push(G(_.storeNames[Z]));z.all(Y).then(function(){N()}).catch(function(ke){B(ke)})},function(q){B(q)})})}):k=z.reject("Invalid arguments"),H(k,S),k}var Oi={_driver:"webSQLStorage",_initStorage:Ii,_support:le(),iterate:On,getItem:Zt,setItem:qr,removeItem:Pr,clear:$n,length:Wn,key:Bn,keys:Ni,dropInstance:jn};function Hn(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(p){return!1}}function Ut(p,S){var v=p.name+"/";return p.storeName!==S.storeName&&(v+=p.storeName+"/"),v}function $i(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch(S){return!0}}function Gr(){return!$i()||localStorage.length>0}function Yr(p){var S=this,v={};if(p)for(var C in p)v[C]=p[C];return v.keyPrefix=Ut(p,S._defaultConfig),Gr()?(S._dbInfo=v,v.serializer=zr,z.resolve()):z.reject()}function Ar(p){var S=this,v=S.ready().then(function(){for(var C=S._dbInfo.keyPrefix,k=localStorage.length-1;k>=0;k--){var _=localStorage.key(k);_.indexOf(C)===0&&localStorage.removeItem(_)}});return H(v,p),v}function Wi(p,S){var v=this;p=he(p);var C=v.ready().then(function(){var k=v._dbInfo,_=localStorage.getItem(k.keyPrefix+p);return _&&(_=k.serializer.deserialize(_)),_});return H(C,S),C}function zn(p,S){var v=this,C=v.ready().then(function(){for(var k=v._dbInfo,_=k.keyPrefix,N=_.length,B=localStorage.length,q=1,G=0;G<B;G++){var Y=localStorage.key(G);if(Y.indexOf(_)===0){var Z=localStorage.getItem(Y);if(Z&&(Z=k.serializer.deserialize(Z)),Z=p(Z,Y.substring(N),q++),Z!==void 0)return Z}}});return H(C,S),C}function Bi(p,S){var v=this,C=v.ready().then(function(){var k=v._dbInfo,_;try{_=localStorage.key(p)}catch(N){_=null}return _&&(_=_.substring(k.keyPrefix.length)),_});return H(C,S),C}function Vn(p){var S=this,v=S.ready().then(function(){for(var C=S._dbInfo,k=localStorage.length,_=[],N=0;N<k;N++){var B=localStorage.key(N);B.indexOf(C.keyPrefix)===0&&_.push(B.substring(C.keyPrefix.length))}return _});return H(v,p),v}function ur(p){var S=this,v=S.keys().then(function(C){return C.length});return H(v,p),v}function Ui(p,S){var v=this;p=he(p);var C=v.ready().then(function(){var k=v._dbInfo;localStorage.removeItem(k.keyPrefix+p)});return H(C,S),C}function ji(p,S,v){var C=this;p=he(p);var k=C.ready().then(function(){S===void 0&&(S=null);var _=S;return new z(function(N,B){var q=C._dbInfo;q.serializer.serialize(S,function(G,Y){if(Y)B(Y);else try{localStorage.setItem(q.keyPrefix+p,G),N(_)}catch(Z){(Z.name==="QuotaExceededError"||Z.name==="NS_ERROR_DOM_QUOTA_REACHED")&&B(Z),B(Z)}})})});return H(k,v),k}function Hi(p,S){if(S=K.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var v=this.config();p.name=p.name||v.name,p.storeName=p.storeName||v.storeName}var C=this,k;return p.name?k=new z(function(_){p.storeName?_(Ut(p,C._defaultConfig)):_(p.name+"/")}).then(function(_){for(var N=localStorage.length-1;N>=0;N--){var B=localStorage.key(N);B.indexOf(_)===0&&localStorage.removeItem(B)}}):k=z.reject("Invalid arguments"),H(k,S),k}var zi={_driver:"localStorageWrapper",_initStorage:Yr,_support:Hn(),iterate:zn,getItem:Wi,setItem:ji,removeItem:Ui,clear:Ar,length:ur,key:Bi,keys:Vn,dropInstance:Hi},qn=function(S,v){return S===v||typeof S=="number"&&typeof v=="number"&&isNaN(S)&&isNaN(v)},Xr=function(S,v){for(var C=S.length,k=0;k<C;){if(qn(S[k],v))return!0;k++}return!1},Vi=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},cr={},Qr={},jt={INDEXEDDB:or,WEBSQL:Oi,LOCALSTORAGE:zi},Jr=[jt.INDEXEDDB._driver,jt.WEBSQL._driver,jt.LOCALSTORAGE._driver],fr=["dropInstance"],Qe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(fr),er={description:"",driver:Jr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Dr(p,S){p[S]=function(){var v=arguments;return p.ready().then(function(){return p[S].apply(p,v)})}}function Kr(){for(var p=1;p<arguments.length;p++){var S=arguments[p];if(S)for(var v in S)S.hasOwnProperty(v)&&(Vi(S[v])?arguments[0][v]=S[v].slice():arguments[0][v]=S[v])}return arguments[0]}var Gn=function(){function p(S){b(this,p);for(var v in jt)if(jt.hasOwnProperty(v)){var C=jt[v],k=C._driver;this[v]=k,cr[k]||this.defineDriver(C)}this._defaultConfig=Kr({},er),this._config=Kr({},this._defaultConfig,S),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(v){if((typeof v=="undefined"?"undefined":m(v))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var C in v){if(C==="storeName"&&(v[C]=v[C].replace(/\W/g,"_")),C==="version"&&typeof v[C]!="number")return new Error("Database version must be a number.");this._config[C]=v[C]}return"driver"in v&&v.driver?this.setDriver(this._config.driver):!0}else return typeof v=="string"?this._config[v]:this._config},p.prototype.defineDriver=function(v,C,k){var _=new z(function(N,B){try{var q=v._driver,G=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!v._driver){B(G);return}for(var Y=Qe.concat("_initStorage"),Z=0,ye=Y.length;Z<ye;Z++){var ke=Y[Z],Pe=!Xr(fr,ke);if((Pe||v[ke])&&typeof v[ke]!="function"){B(G);return}}var We=function(){for(var Ht=function(ri){return function(){var Yn=new Error("Method "+ri+" is not implemented by the current driver"),Gi=z.reject(Yn);return H(Gi,arguments[arguments.length-1]),Gi}},ei=0,qi=fr.length;ei<qi;ei++){var ti=fr[ei];v[ti]||(v[ti]=Ht(ti))}};We();var Fe=function(Ht){cr[q]&&console.info("Redefining LocalForage driver: "+q),cr[q]=v,Qr[q]=Ht,N()};"_support"in v?v._support&&typeof v._support=="function"?v._support().then(Fe,B):Fe(!!v._support):Fe(!0)}catch(st){B(st)}});return V(_,C,k),_},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(v,C,k){var _=cr[v]?z.resolve(cr[v]):z.reject(new Error("Driver not found."));return V(_,C,k),_},p.prototype.getSerializer=function(v){var C=z.resolve(zr);return V(C,v),C},p.prototype.ready=function(v){var C=this,k=C._driverSet.then(function(){return C._ready===null&&(C._ready=C._initDriver()),C._ready});return V(k,v,v),k},p.prototype.setDriver=function(v,C,k){var _=this;Vi(v)||(v=[v]);var N=this._getSupportedDrivers(v);function B(){_._config.driver=_.driver()}function q(Z){return _._extend(Z),B(),_._ready=_._initStorage(_._config),_._ready}function G(Z){return function(){var ye=0;function ke(){for(;ye<Z.length;){var Pe=Z[ye];return ye++,_._dbInfo=null,_._ready=null,_.getDriver(Pe).then(q).catch(ke)}B();var We=new Error("No available storage method found.");return _._driverSet=z.reject(We),_._driverSet}return ke()}}var Y=this._driverSet!==null?this._driverSet.catch(function(){return z.resolve()}):z.resolve();return this._driverSet=Y.then(function(){var Z=N[0];return _._dbInfo=null,_._ready=null,_.getDriver(Z).then(function(ye){_._driver=ye._driver,B(),_._wrapLibraryMethodsWithReady(),_._initDriver=G(N)})}).catch(function(){B();var Z=new Error("No available storage method found.");return _._driverSet=z.reject(Z),_._driverSet}),V(this._driverSet,C,k),this._driverSet},p.prototype.supports=function(v){return!!Qr[v]},p.prototype._extend=function(v){Kr(this,v)},p.prototype._getSupportedDrivers=function(v){for(var C=[],k=0,_=v.length;k<_;k++){var N=v[k];this.supports(N)&&C.push(N)}return C},p.prototype._wrapLibraryMethodsWithReady=function(){for(var v=0,C=Qe.length;v<C;v++)Dr(this,Qe[v])},p.prototype.createInstance=function(v){return new p(v)},p}(),Zr=new Gn;u.exports=Zr},{"3":3}]},{},[4])(4)})});var js=_s((Us,cn)=>{(function(l,t){"use strict";typeof cn=="object"&&typeof cn.exports=="object"?cn.exports=l.document?t(l,!0):function(r){if(!r.document)throw new Error("jQuery requires a window with a document");return t(r)}:t(l)})(typeof window!="undefined"?window:Us,function(l,t){"use strict";var r=[],a=Object.getPrototypeOf,u=r.slice,d=r.flat?function(e){return r.flat.call(e)}:function(e){return r.concat.apply([],e)},m=r.push,b=r.indexOf,y={},L=y.toString,W=y.hasOwnProperty,de=W.toString,z=de.call(Object),H={},V=function(i){return typeof i=="function"&&typeof i.nodeType!="number"&&typeof i.item!="function"},he=function(i){return i!=null&&i===i.window},K=l.document,xe={type:!0,src:!0,nonce:!0,noModule:!0};function Ce(e,i,n){n=n||K;var s,c,f=n.createElement("script");if(f.text=e,i)for(s in xe)c=i[s]||i.getAttribute&&i.getAttribute(s),c&&f.setAttribute(s,c);n.head.appendChild(f).parentNode.removeChild(f)}function be(e){return e==null?e+"":typeof e=="object"||typeof e=="function"?y[L.call(e)]||"object":typeof e}var Se="3.6.3",o=function(e,i){return new o.fn.init(e,i)};o.fn=o.prototype={jquery:Se,constructor:o,length:0,toArray:function(){return u.call(this)},get:function(e){return e==null?u.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var i=o.merge(this.constructor(),e);return i.prevObject=this,i},each:function(e){return o.each(this,e)},map:function(e){return this.pushStack(o.map(this,function(i,n){return e.call(i,n,i)}))},slice:function(){return this.pushStack(u.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(o.grep(this,function(e,i){return(i+1)%2}))},odd:function(){return this.pushStack(o.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:m,sort:r.sort,splice:r.splice},o.extend=o.fn.extend=function(){var e,i,n,s,c,f,h=arguments[0]||{},E=1,x=arguments.length,D=!1;for(typeof h=="boolean"&&(D=h,h=arguments[E]||{},E++),typeof h!="object"&&!V(h)&&(h={}),E===x&&(h=this,E--);E<x;E++)if((e=arguments[E])!=null)for(i in e)s=e[i],!(i==="__proto__"||h===s)&&(D&&s&&(o.isPlainObject(s)||(c=Array.isArray(s)))?(n=h[i],c&&!Array.isArray(n)?f=[]:!c&&!o.isPlainObject(n)?f={}:f=n,c=!1,h[i]=o.extend(D,f,s)):s!==void 0&&(h[i]=s));return h},o.extend({expando:"jQuery"+(Se+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var i,n;return!e||L.call(e)!=="[object Object]"?!1:(i=a(e),i?(n=W.call(i,"constructor")&&i.constructor,typeof n=="function"&&de.call(n)===z):!0)},isEmptyObject:function(e){var i;for(i in e)return!1;return!0},globalEval:function(e,i,n){Ce(e,{nonce:i&&i.nonce},n)},each:function(e,i){var n,s=0;if(X(e))for(n=e.length;s<n&&i.call(e[s],s,e[s])!==!1;s++);else for(s in e)if(i.call(e[s],s,e[s])===!1)break;return e},makeArray:function(e,i){var n=i||[];return e!=null&&(X(Object(e))?o.merge(n,typeof e=="string"?[e]:e):m.call(n,e)),n},inArray:function(e,i,n){return i==null?-1:b.call(i,e,n)},merge:function(e,i){for(var n=+i.length,s=0,c=e.length;s<n;s++)e[c++]=i[s];return e.length=c,e},grep:function(e,i,n){for(var s,c=[],f=0,h=e.length,E=!n;f<h;f++)s=!i(e[f],f),s!==E&&c.push(e[f]);return c},map:function(e,i,n){var s,c,f=0,h=[];if(X(e))for(s=e.length;f<s;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:H}),typeof Symbol=="function"&&(o.fn[Symbol.iterator]=r[Symbol.iterator]),o.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,i){y["[object "+i+"]"]=i.toLowerCase()});function X(e){var i=!!e&&"length"in e&&e.length,n=be(e);return V(e)||he(e)?!1:n==="array"||i===0||typeof i=="number"&&i>0&&i-1 in e}var ae=function(e){var i,n,s,c,f,h,E,x,D,R,U,F,I,ie,ve,re,qe,Ve,ht,De="sizzle"+1*new Date,me=e.document,ut=0,Te=0,Be=Ji(),ni=Ji(),Yi=Ji(),pt=Ji(),dr=function(g,w){return g===w&&(U=!0),0},hr={}.hasOwnProperty,ct=[],tr=ct.pop,Et=ct.push,rr=ct.push,gs=ct.slice,pr=function(g,w){for(var T=0,M=g.length;T<M;T++)if(g[T]===w)return T;return-1},Zn="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Ae="[\\x20\\t\\r\\n\\f]",gr="(?:\\\\[\\da-fA-F]{1,6}"+Ae+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",ms="\\["+Ae+"*("+gr+")(?:"+Ae+"*([*^$|!~]?=)"+Ae+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+gr+"))|)"+Ae+"*\\]",ea=":("+gr+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+ms+")*)|.*)\\)|)",zo=new RegExp(Ae+"+","g"),Xi=new RegExp("^"+Ae+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Ae+"+$","g"),Vo=new RegExp("^"+Ae+"*,"+Ae+"*"),vs=new RegExp("^"+Ae+"*([>+~]|"+Ae+")"+Ae+"*"),qo=new RegExp(Ae+"|>"),Go=new RegExp(ea),Yo=new RegExp("^"+gr+"$"),Qi={ID:new RegExp("^#("+gr+")"),CLASS:new RegExp("^\\.("+gr+")"),TAG:new RegExp("^("+gr+"|[*])"),ATTR:new RegExp("^"+ms),PSEUDO:new RegExp("^"+ea),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+Ae+"*(even|odd|(([+-]|)(\\d*)n|)"+Ae+"*(?:([+-]|)"+Ae+"*(\\d+)|))"+Ae+"*\\)|)","i"),bool:new RegExp("^(?:"+Zn+")$","i"),needsContext:new RegExp("^"+Ae+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+Ae+"*((?:-\\d)?\\d*)"+Ae+"*\\)|)(?=[^-]|$)","i")},Xo=/HTML$/i,Qo=/^(?:input|select|textarea|button)$/i,Jo=/^h\d$/i,ai=/^[^{]+\{\s*\[native \w/,Ko=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ta=/[+~]/,zt=new RegExp("\\\\[\\da-fA-F]{1,6}"+Ae+"?|\\\\([^\\r\\n\\f])","g"),Vt=function(g,w){var T="0x"+g.slice(1)-65536;return w||(T<0?String.fromCharCode(T+65536):String.fromCharCode(T>>10|55296,T&1023|56320))},bs=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ys=function(g,w){return w?g==="\0"?"\uFFFD":g.slice(0,-1)+"\\"+g.charCodeAt(g.length-1).toString(16)+" ":"\\"+g},xs=function(){F()},Zo=Zi(function(g){return g.disabled===!0&&g.nodeName.toLowerCase()==="fieldset"},{dir:"parentNode",next:"legend"});try{rr.apply(ct=gs.call(me.childNodes),me.childNodes),ct[me.childNodes.length].nodeType}catch(g){rr={apply:ct.length?function(w,T){Et.apply(w,gs.call(T))}:function(w,T){for(var M=w.length,P=0;w[M++]=T[P++];);w.length=M-1}}}function Re(g,w,T,M){var P,O,j,Q,J,ue,se,pe=w&&w.ownerDocument,we=w?w.nodeType:9;if(T=T||[],typeof g!="string"||!g||we!==1&&we!==9&&we!==11)return T;if(!M&&(F(w),w=w||I,ve)){if(we!==11&&(J=Ko.exec(g)))if(P=J[1]){if(we===9)if(j=w.getElementById(P)){if(j.id===P)return T.push(j),T}else return T;else if(pe&&(j=pe.getElementById(P))&&ht(w,j)&&j.id===P)return T.push(j),T}else{if(J[2])return rr.apply(T,w.getElementsByTagName(g)),T;if((P=J[3])&&n.getElementsByClassName&&w.getElementsByClassName)return rr.apply(T,w.getElementsByClassName(P)),T}if(n.qsa&&!pt[g+" "]&&(!re||!re.test(g))&&(we!==1||w.nodeName.toLowerCase()!=="object")){if(se=g,pe=w,we===1&&(qo.test(g)||vs.test(g))){for(pe=ta.test(g)&&ia(w.parentNode)||w,(pe!==w||!n.scope)&&((Q=w.getAttribute("id"))?Q=Q.replace(bs,ys):w.setAttribute("id",Q=De)),ue=h(g),O=ue.length;O--;)ue[O]=(Q?"#"+Q:":scope")+" "+Ki(ue[O]);se=ue.join(",")}try{if(n.cssSupportsSelector&&!CSS.supports("selector(:is("+se+"))"))throw new Error;return rr.apply(T,pe.querySelectorAll(se)),T}catch(Ie){pt(g,!0)}finally{Q===De&&w.removeAttribute("id")}}}return x(g.replace(Xi,"$1"),w,T,M)}function Ji(){var g=[];function w(T,M){return g.push(T+" ")>s.cacheLength&&delete w[g.shift()],w[T+" "]=M}return w}function kt(g){return g[De]=!0,g}function St(g){var w=I.createElement("fieldset");try{return!!g(w)}catch(T){return!1}finally{w.parentNode&&w.parentNode.removeChild(w),w=null}}function ra(g,w){for(var T=g.split("|"),M=T.length;M--;)s.attrHandle[T[M]]=w}function ws(g,w){var T=w&&g,M=T&&g.nodeType===1&&w.nodeType===1&&g.sourceIndex-w.sourceIndex;if(M)return M;if(T){for(;T=T.nextSibling;)if(T===w)return-1}return g?1:-1}function el(g){return function(w){var T=w.nodeName.toLowerCase();return T==="input"&&w.type===g}}function tl(g){return function(w){var T=w.nodeName.toLowerCase();return(T==="input"||T==="button")&&w.type===g}}function Es(g){return function(w){return"form"in w?w.parentNode&&w.disabled===!1?"label"in w?"label"in w.parentNode?w.parentNode.disabled===g:w.disabled===g:w.isDisabled===g||w.isDisabled!==!g&&Zo(w)===g:w.disabled===g:"label"in w?w.disabled===g:!1}}function mr(g){return kt(function(w){return w=+w,kt(function(T,M){for(var P,O=g([],T.length,w),j=O.length;j--;)T[P=O[j]]&&(T[P]=!(M[P]=T[P]))})})}function ia(g){return g&&typeof g.getElementsByTagName!="undefined"&&g}n=Re.support={},f=Re.isXML=function(g){var w=g&&g.namespaceURI,T=g&&(g.ownerDocument||g).documentElement;return!Xo.test(w||T&&T.nodeName||"HTML")},F=Re.setDocument=function(g){var w,T,M=g?g.ownerDocument||g:me;return M==I||M.nodeType!==9||!M.documentElement||(I=M,ie=I.documentElement,ve=!f(I),me!=I&&(T=I.defaultView)&&T.top!==T&&(T.addEventListener?T.addEventListener("unload",xs,!1):T.attachEvent&&T.attachEvent("onunload",xs)),n.scope=St(function(P){return ie.appendChild(P).appendChild(I.createElement("div")),typeof P.querySelectorAll!="undefined"&&!P.querySelectorAll(":scope fieldset div").length}),n.cssSupportsSelector=St(function(){return CSS.supports("selector(*)")&&I.querySelectorAll(":is(:jqfake)")&&!CSS.supports("selector(:is(*,:jqfake))")}),n.attributes=St(function(P){return P.className="i",!P.getAttribute("className")}),n.getElementsByTagName=St(function(P){return P.appendChild(I.createComment("")),!P.getElementsByTagName("*").length}),n.getElementsByClassName=ai.test(I.getElementsByClassName),n.getById=St(function(P){return ie.appendChild(P).id=De,!I.getElementsByName||!I.getElementsByName(De).length}),n.getById?(s.filter.ID=function(P){var O=P.replace(zt,Vt);return function(j){return j.getAttribute("id")===O}},s.find.ID=function(P,O){if(typeof O.getElementById!="undefined"&&ve){var j=O.getElementById(P);return j?[j]:[]}}):(s.filter.ID=function(P){var O=P.replace(zt,Vt);return function(j){var Q=typeof j.getAttributeNode!="undefined"&&j.getAttributeNode("id");return Q&&Q.value===O}},s.find.ID=function(P,O){if(typeof O.getElementById!="undefined"&&ve){var j,Q,J,ue=O.getElementById(P);if(ue){if(j=ue.getAttributeNode("id"),j&&j.value===P)return[ue];for(J=O.getElementsByName(P),Q=0;ue=J[Q++];)if(j=ue.getAttributeNode("id"),j&&j.value===P)return[ue]}return[]}}),s.find.TAG=n.getElementsByTagName?function(P,O){if(typeof O.getElementsByTagName!="undefined")return O.getElementsByTagName(P);if(n.qsa)return O.querySelectorAll(P)}:function(P,O){var j,Q=[],J=0,ue=O.getElementsByTagName(P);if(P==="*"){for(;j=ue[J++];)j.nodeType===1&&Q.push(j);return Q}return ue},s.find.CLASS=n.getElementsByClassName&&function(P,O){if(typeof O.getElementsByClassName!="undefined"&&ve)return O.getElementsByClassName(P)},qe=[],re=[],(n.qsa=ai.test(I.querySelectorAll))&&(St(function(P){var O;ie.appendChild(P).innerHTML="<a id='"+De+"'></a><select id='"+De+"-\r\\' msallowcapture=''><option selected=''></option></select>",P.querySelectorAll("[msallowcapture^='']").length&&re.push("[*^$]="+Ae+`*(?:''|"")`),P.querySelectorAll("[selected]").length||re.push("\\["+Ae+"*(?:value|"+Zn+")"),P.querySelectorAll("[id~="+De+"-]").length||re.push("~="),O=I.createElement("input"),O.setAttribute("name",""),P.appendChild(O),P.querySelectorAll("[name='']").length||re.push("\\["+Ae+"*name"+Ae+"*="+Ae+`*(?:''|"")`),P.querySelectorAll(":checked").length||re.push(":checked"),P.querySelectorAll("a#"+De+"+*").length||re.push(".#.+[+~]"),P.querySelectorAll("\\\f"),re.push("[\\r\\n\\f]")}),St(function(P){P.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var O=I.createElement("input");O.setAttribute("type","hidden"),P.appendChild(O).setAttribute("name","D"),P.querySelectorAll("[name=d]").length&&re.push("name"+Ae+"*[*^$|!~]?="),P.querySelectorAll(":enabled").length!==2&&re.push(":enabled",":disabled"),ie.appendChild(P).disabled=!0,P.querySelectorAll(":disabled").length!==2&&re.push(":enabled",":disabled"),P.querySelectorAll("*,:x"),re.push(",.*:")})),(n.matchesSelector=ai.test(Ve=ie.matches||ie.webkitMatchesSelector||ie.mozMatchesSelector||ie.oMatchesSelector||ie.msMatchesSelector))&&St(function(P){n.disconnectedMatch=Ve.call(P,"*"),Ve.call(P,"[s!='']:x"),qe.push("!=",ea)}),n.cssSupportsSelector||re.push(":has"),re=re.length&&new RegExp(re.join("|")),qe=qe.length&&new RegExp(qe.join("|")),w=ai.test(ie.compareDocumentPosition),ht=w||ai.test(ie.contains)?function(P,O){var j=P.nodeType===9&&P.documentElement||P,Q=O&&O.parentNode;return P===Q||!!(Q&&Q.nodeType===1&&(j.contains?j.contains(Q):P.compareDocumentPosition&&P.compareDocumentPosition(Q)&16))}:function(P,O){if(O){for(;O=O.parentNode;)if(O===P)return!0}return!1},dr=w?function(P,O){if(P===O)return U=!0,0;var j=!P.compareDocumentPosition-!O.compareDocumentPosition;return j||(j=(P.ownerDocument||P)==(O.ownerDocument||O)?P.compareDocumentPosition(O):1,j&1||!n.sortDetached&&O.compareDocumentPosition(P)===j?P==I||P.ownerDocument==me&&ht(me,P)?-1:O==I||O.ownerDocument==me&&ht(me,O)?1:R?pr(R,P)-pr(R,O):0:j&4?-1:1)}:function(P,O){if(P===O)return U=!0,0;var j,Q=0,J=P.parentNode,ue=O.parentNode,se=[P],pe=[O];if(!J||!ue)return P==I?-1:O==I?1:J?-1:ue?1:R?pr(R,P)-pr(R,O):0;if(J===ue)return ws(P,O);for(j=P;j=j.parentNode;)se.unshift(j);for(j=O;j=j.parentNode;)pe.unshift(j);for(;se[Q]===pe[Q];)Q++;return Q?ws(se[Q],pe[Q]):se[Q]==me?-1:pe[Q]==me?1:0}),I},Re.matches=function(g,w){return Re(g,null,null,w)},Re.matchesSelector=function(g,w){if(F(g),n.matchesSelector&&ve&&!pt[w+" "]&&(!qe||!qe.test(w))&&(!re||!re.test(w)))try{var T=Ve.call(g,w);if(T||n.disconnectedMatch||g.document&&g.document.nodeType!==11)return T}catch(M){pt(w,!0)}return Re(w,I,null,[g]).length>0},Re.contains=function(g,w){return(g.ownerDocument||g)!=I&&F(g),ht(g,w)},Re.attr=function(g,w){(g.ownerDocument||g)!=I&&F(g);var T=s.attrHandle[w.toLowerCase()],M=T&&hr.call(s.attrHandle,w.toLowerCase())?T(g,w,!ve):void 0;return M!==void 0?M:n.attributes||!ve?g.getAttribute(w):(M=g.getAttributeNode(w))&&M.specified?M.value:null},Re.escape=function(g){return(g+"").replace(bs,ys)},Re.error=function(g){throw new Error("Syntax error, unrecognized expression: "+g)},Re.uniqueSort=function(g){var w,T=[],M=0,P=0;if(U=!n.detectDuplicates,R=!n.sortStable&&g.slice(0),g.sort(dr),U){for(;w=g[P++];)w===g[P]&&(M=T.push(P));for(;M--;)g.splice(T[M],1)}return R=null,g},c=Re.getText=function(g){var w,T="",M=0,P=g.nodeType;if(P){if(P===1||P===9||P===11){if(typeof g.textContent=="string")return g.textContent;for(g=g.firstChild;g;g=g.nextSibling)T+=c(g)}else if(P===3||P===4)return g.nodeValue}else for(;w=g[M++];)T+=c(w);return T},s=Re.selectors={cacheLength:50,createPseudo:kt,match:Qi,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(g){return g[1]=g[1].replace(zt,Vt),g[3]=(g[3]||g[4]||g[5]||"").replace(zt,Vt),g[2]==="~="&&(g[3]=" "+g[3]+" "),g.slice(0,4)},CHILD:function(g){return g[1]=g[1].toLowerCase(),g[1].slice(0,3)==="nth"?(g[3]||Re.error(g[0]),g[4]=+(g[4]?g[5]+(g[6]||1):2*(g[3]==="even"||g[3]==="odd")),g[5]=+(g[7]+g[8]||g[3]==="odd")):g[3]&&Re.error(g[0]),g},PSEUDO:function(g){var w,T=!g[6]&&g[2];return Qi.CHILD.test(g[0])?null:(g[3]?g[2]=g[4]||g[5]||"":T&&Go.test(T)&&(w=h(T,!0))&&(w=T.indexOf(")",T.length-w)-T.length)&&(g[0]=g[0].slice(0,w),g[2]=T.slice(0,w)),g.slice(0,3))}},filter:{TAG:function(g){var w=g.replace(zt,Vt).toLowerCase();return g==="*"?function(){return!0}:function(T){return T.nodeName&&T.nodeName.toLowerCase()===w}},CLASS:function(g){var w=Be[g+" "];return w||(w=new RegExp("(^|"+Ae+")"+g+"("+Ae+"|$)"))&&Be(g,function(T){return w.test(typeof T.className=="string"&&T.className||typeof T.getAttribute!="undefined"&&T.getAttribute("class")||"")})},ATTR:function(g,w,T){return function(M){var P=Re.attr(M,g);return P==null?w==="!=":w?(P+="",w==="="?P===T:w==="!="?P!==T:w==="^="?T&&P.indexOf(T)===0:w==="*="?T&&P.indexOf(T)>-1:w==="$="?T&&P.slice(-T.length)===T:w==="~="?(" "+P.replace(zo," ")+" ").indexOf(T)>-1:w==="|="?P===T||P.slice(0,T.length+1)===T+"-":!1):!0}},CHILD:function(g,w,T,M,P){var O=g.slice(0,3)!=="nth",j=g.slice(-4)!=="last",Q=w==="of-type";return M===1&&P===0?function(J){return!!J.parentNode}:function(J,ue,se){var pe,we,Ie,ce,Ge,rt,gt=O!==j?"nextSibling":"previousSibling",Ne=J.parentNode,si=Q&&J.nodeName.toLowerCase(),oi=!se&&!Q,mt=!1;if(Ne){if(O){for(;gt;){for(ce=J;ce=ce[gt];)if(Q?ce.nodeName.toLowerCase()===si:ce.nodeType===1)return!1;rt=gt=g==="only"&&!rt&&"nextSibling"}return!0}if(rt=[j?Ne.firstChild:Ne.lastChild],j&&oi){for(ce=Ne,Ie=ce[De]||(ce[De]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),pe=we[g]||[],Ge=pe[0]===ut&&pe[1],mt=Ge&&pe[2],ce=Ge&&Ne.childNodes[Ge];ce=++Ge&&ce&&ce[gt]||(mt=Ge=0)||rt.pop();)if(ce.nodeType===1&&++mt&&ce===J){we[g]=[ut,Ge,mt];break}}else if(oi&&(ce=J,Ie=ce[De]||(ce[De]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),pe=we[g]||[],Ge=pe[0]===ut&&pe[1],mt=Ge),mt===!1)for(;(ce=++Ge&&ce&&ce[gt]||(mt=Ge=0)||rt.pop())&&!((Q?ce.nodeName.toLowerCase()===si:ce.nodeType===1)&&++mt&&(oi&&(Ie=ce[De]||(ce[De]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),we[g]=[ut,mt]),ce===J)););return mt-=P,mt===M||mt%M==0&&mt/M>=0}}},PSEUDO:function(g,w){var T,M=s.pseudos[g]||s.setFilters[g.toLowerCase()]||Re.error("unsupported pseudo: "+g);return M[De]?M(w):M.length>1?(T=[g,g,"",w],s.setFilters.hasOwnProperty(g.toLowerCase())?kt(function(P,O){for(var j,Q=M(P,w),J=Q.length;J--;)j=pr(P,Q[J]),P[j]=!(O[j]=Q[J])}):function(P){return M(P,0,T)}):M}},pseudos:{not:kt(function(g){var w=[],T=[],M=E(g.replace(Xi,"$1"));return M[De]?kt(function(P,O,j,Q){for(var J,ue=M(P,null,Q,[]),se=P.length;se--;)(J=ue[se])&&(P[se]=!(O[se]=J))}):function(P,O,j){return w[0]=P,M(w,null,j,T),w[0]=null,!T.pop()}}),has:kt(function(g){return function(w){return Re(g,w).length>0}}),contains:kt(function(g){return g=g.replace(zt,Vt),function(w){return(w.textContent||c(w)).indexOf(g)>-1}}),lang:kt(function(g){return Yo.test(g||"")||Re.error("unsupported lang: "+g),g=g.replace(zt,Vt).toLowerCase(),function(w){var T;do if(T=ve?w.lang:w.getAttribute("xml:lang")||w.getAttribute("lang"))return T=T.toLowerCase(),T===g||T.indexOf(g+"-")===0;while((w=w.parentNode)&&w.nodeType===1);return!1}}),target:function(g){var w=e.location&&e.location.hash;return w&&w.slice(1)===g.id},root:function(g){return g===ie},focus:function(g){return g===I.activeElement&&(!I.hasFocus||I.hasFocus())&&!!(g.type||g.href||~g.tabIndex)},enabled:Es(!1),disabled:Es(!0),checked:function(g){var w=g.nodeName.toLowerCase();return w==="input"&&!!g.checked||w==="option"&&!!g.selected},selected:function(g){return g.parentNode&&g.parentNode.selectedIndex,g.selected===!0},empty:function(g){for(g=g.firstChild;g;g=g.nextSibling)if(g.nodeType<6)return!1;return!0},parent:function(g){return!s.pseudos.empty(g)},header:function(g){return Jo.test(g.nodeName)},input:function(g){return Qo.test(g.nodeName)},button:function(g){var w=g.nodeName.toLowerCase();return w==="input"&&g.type==="button"||w==="button"},text:function(g){var w;return g.nodeName.toLowerCase()==="input"&&g.type==="text"&&((w=g.getAttribute("type"))==null||w.toLowerCase()==="text")},first:mr(function(){return[0]}),last:mr(function(g,w){return[w-1]}),eq:mr(function(g,w,T){return[T<0?T+w:T]}),even:mr(function(g,w){for(var T=0;T<w;T+=2)g.push(T);return g}),odd:mr(function(g,w){for(var T=1;T<w;T+=2)g.push(T);return g}),lt:mr(function(g,w,T){for(var M=T<0?T+w:T>w?w:T;--M>=0;)g.push(M);return g}),gt:mr(function(g,w,T){for(var M=T<0?T+w:T;++M<w;)g.push(M);return g})}},s.pseudos.nth=s.pseudos.eq;for(i in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})s.pseudos[i]=el(i);for(i in{submit:!0,reset:!0})s.pseudos[i]=tl(i);function Ss(){}Ss.prototype=s.filters=s.pseudos,s.setFilters=new Ss,h=Re.tokenize=function(g,w){var T,M,P,O,j,Q,J,ue=ni[g+" "];if(ue)return w?0:ue.slice(0);for(j=g,Q=[],J=s.preFilter;j;){(!T||(M=Vo.exec(j)))&&(M&&(j=j.slice(M[0].length)||j),Q.push(P=[])),T=!1,(M=vs.exec(j))&&(T=M.shift(),P.push({value:T,type:M[0].replace(Xi," ")}),j=j.slice(T.length));for(O in s.filter)(M=Qi[O].exec(j))&&(!J[O]||(M=J[O](M)))&&(T=M.shift(),P.push({value:T,type:O,matches:M}),j=j.slice(T.length));if(!T)break}return w?j.length:j?Re.error(g):ni(g,Q).slice(0)};function Ki(g){for(var w=0,T=g.length,M="";w<T;w++)M+=g[w].value;return M}function Zi(g,w,T){var M=w.dir,P=w.next,O=P||M,j=T&&O==="parentNode",Q=Te++;return w.first?function(J,ue,se){for(;J=J[M];)if(J.nodeType===1||j)return g(J,ue,se);return!1}:function(J,ue,se){var pe,we,Ie,ce=[ut,Q];if(se){for(;J=J[M];)if((J.nodeType===1||j)&&g(J,ue,se))return!0}else for(;J=J[M];)if(J.nodeType===1||j)if(Ie=J[De]||(J[De]={}),we=Ie[J.uniqueID]||(Ie[J.uniqueID]={}),P&&P===J.nodeName.toLowerCase())J=J[M]||J;else{if((pe=we[O])&&pe[0]===ut&&pe[1]===Q)return ce[2]=pe[2];if(we[O]=ce,ce[2]=g(J,ue,se))return!0}return!1}}function na(g){return g.length>1?function(w,T,M){for(var P=g.length;P--;)if(!g[P](w,T,M))return!1;return!0}:g[0]}function rl(g,w,T){for(var M=0,P=w.length;M<P;M++)Re(g,w[M],T);return T}function en(g,w,T,M,P){for(var O,j=[],Q=0,J=g.length,ue=w!=null;Q<J;Q++)(O=g[Q])&&(!T||T(O,M,P))&&(j.push(O),ue&&w.push(Q));return j}function aa(g,w,T,M,P,O){return M&&!M[De]&&(M=aa(M)),P&&!P[De]&&(P=aa(P,O)),kt(function(j,Q,J,ue){var se,pe,we,Ie=[],ce=[],Ge=Q.length,rt=j||rl(w||"*",J.nodeType?[J]:J,[]),gt=g&&(j||!w)?en(rt,Ie,g,J,ue):rt,Ne=T?P||(j?g:Ge||M)?[]:Q:gt;if(T&&T(gt,Ne,J,ue),M)for(se=en(Ne,ce),M(se,[],J,ue),pe=se.length;pe--;)(we=se[pe])&&(Ne[ce[pe]]=!(gt[ce[pe]]=we));if(j){if(P||g){if(P){for(se=[],pe=Ne.length;pe--;)(we=Ne[pe])&&se.push(gt[pe]=we);P(null,Ne=[],se,ue)}for(pe=Ne.length;pe--;)(we=Ne[pe])&&(se=P?pr(j,we):Ie[pe])>-1&&(j[se]=!(Q[se]=we))}}else Ne=en(Ne===Q?Ne.splice(Ge,Ne.length):Ne),P?P(null,Q,Ne,ue):rr.apply(Q,Ne)})}function sa(g){for(var w,T,M,P=g.length,O=s.relative[g[0].type],j=O||s.relative[" "],Q=O?1:0,J=Zi(function(pe){return pe===w},j,!0),ue=Zi(function(pe){return pr(w,pe)>-1},j,!0),se=[function(pe,we,Ie){var ce=!O&&(Ie||we!==D)||((w=we).nodeType?J(pe,we,Ie):ue(pe,we,Ie));return w=null,ce}];Q<P;Q++)if(T=s.relative[g[Q].type])se=[Zi(na(se),T)];else{if(T=s.filter[g[Q].type].apply(null,g[Q].matches),T[De]){for(M=++Q;M<P&&!s.relative[g[M].type];M++);return aa(Q>1&&na(se),Q>1&&Ki(g.slice(0,Q-1).concat({value:g[Q-2].type===" "?"*":""})).replace(Xi,"$1"),T,Q<M&&sa(g.slice(Q,M)),M<P&&sa(g=g.slice(M)),M<P&&Ki(g))}se.push(T)}return na(se)}function il(g,w){var T=w.length>0,M=g.length>0,P=function(O,j,Q,J,ue){var se,pe,we,Ie=0,ce="0",Ge=O&&[],rt=[],gt=D,Ne=O||M&&s.find.TAG("*",ue),si=ut+=gt==null?1:Math.random()||.1,oi=Ne.length;for(ue&&(D=j==I||j||ue);ce!==oi&&(se=Ne[ce])!=null;ce++){if(M&&se){for(pe=0,!j&&se.ownerDocument!=I&&(F(se),Q=!ve);we=g[pe++];)if(we(se,j||I,Q)){J.push(se);break}ue&&(ut=si)}T&&((se=!we&&se)&&Ie--,O&&Ge.push(se))}if(Ie+=ce,T&&ce!==Ie){for(pe=0;we=w[pe++];)we(Ge,rt,j,Q);if(O){if(Ie>0)for(;ce--;)Ge[ce]||rt[ce]||(rt[ce]=tr.call(J));rt=en(rt)}rr.apply(J,rt),ue&&!O&&rt.length>0&&Ie+w.length>1&&Re.uniqueSort(J)}return ue&&(ut=si,D=gt),Ge};return T?kt(P):P}return E=Re.compile=function(g,w){var T,M=[],P=[],O=Yi[g+" "];if(!O){for(w||(w=h(g)),T=w.length;T--;)O=sa(w[T]),O[De]?M.push(O):P.push(O);O=Yi(g,il(P,M)),O.selector=g}return O},x=Re.select=function(g,w,T,M){var P,O,j,Q,J,ue=typeof g=="function"&&g,se=!M&&h(g=ue.selector||g);if(T=T||[],se.length===1){if(O=se[0]=se[0].slice(0),O.length>2&&(j=O[0]).type==="ID"&&w.nodeType===9&&ve&&s.relative[O[1].type]){if(w=(s.find.ID(j.matches[0].replace(zt,Vt),w)||[])[0],w)ue&&(w=w.parentNode);else return T;g=g.slice(O.shift().value.length)}for(P=Qi.needsContext.test(g)?0:O.length;P--&&(j=O[P],!s.relative[Q=j.type]);)if((J=s.find[Q])&&(M=J(j.matches[0].replace(zt,Vt),ta.test(O[0].type)&&ia(w.parentNode)||w))){if(O.splice(P,1),g=M.length&&Ki(O),!g)return rr.apply(T,M),T;break}}return(ue||E(g,se))(M,w,!ve,T,!w||ta.test(g)&&ia(w.parentNode)||w),T},n.sortStable=De.split("").sort(dr).join("")===De,n.detectDuplicates=!!U,F(),n.sortDetached=St(function(g){return g.compareDocumentPosition(I.createElement("fieldset"))&1}),St(function(g){return g.innerHTML="<a href='#'></a>",g.firstChild.getAttribute("href")==="#"})||ra("type|href|height|width",function(g,w,T){if(!T)return g.getAttribute(w,w.toLowerCase()==="type"?1:2)}),(!n.attributes||!St(function(g){return g.innerHTML="<input/>",g.firstChild.setAttribute("value",""),g.firstChild.getAttribute("value")===""}))&&ra("value",function(g,w,T){if(!T&&g.nodeName.toLowerCase()==="input")return g.defaultValue}),St(function(g){return g.getAttribute("disabled")==null})||ra(Zn,function(g,w,T){var M;if(!T)return g[w]===!0?w.toLowerCase():(M=g.getAttributeNode(w))&&M.specified?M.value:null}),Re}(l);o.find=ae,o.expr=ae.selectors,o.expr[":"]=o.expr.pseudos,o.uniqueSort=o.unique=ae.uniqueSort,o.text=ae.getText,o.isXMLDoc=ae.isXML,o.contains=ae.contains,o.escapeSelector=ae.escape;var oe=function(e,i,n){for(var s=[],c=n!==void 0;(e=e[i])&&e.nodeType!==9;)if(e.nodeType===1){if(c&&o(e).is(n))break;s.push(e)}return s},_e=function(e,i){for(var n=[];e;e=e.nextSibling)e.nodeType===1&&e!==i&&n.push(e);return n},ze=o.expr.match.needsContext;function Me(e,i){return e.nodeName&&e.nodeName.toLowerCase()===i.toLowerCase()}var nt=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function Ke(e,i,n){return V(i)?o.grep(e,function(s,c){return!!i.call(s,c,s)!==n}):i.nodeType?o.grep(e,function(s){return s===i!==n}):typeof i!="string"?o.grep(e,function(s){return b.call(i,s)>-1!==n}):o.filter(i,e,n)}o.filter=function(e,i,n){var s=i[0];return n&&(e=":not("+e+")"),i.length===1&&s.nodeType===1?o.find.matchesSelector(s,e)?[s]:[]:o.find.matches(e,o.grep(i,function(c){return c.nodeType===1}))},o.fn.extend({find:function(e){var i,n,s=this.length,c=this;if(typeof e!="string")return this.pushStack(o(e).filter(function(){for(i=0;i<s;i++)if(o.contains(c[i],this))return!0}));for(n=this.pushStack([]),i=0;i<s;i++)o.find(e,c[i],n);return s>1?o.uniqueSort(n):n},filter:function(e){return this.pushStack(Ke(this,e||[],!1))},not:function(e){return this.pushStack(Ke(this,e||[],!0))},is:function(e){return!!Ke(this,typeof e=="string"&&ze.test(e)?o(e):e||[],!1).length}});var bt,nr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Sr=o.fn.init=function(e,i,n){var s,c;if(!e)return this;if(n=n||bt,typeof e=="string")if(e[0]==="<"&&e[e.length-1]===">"&&e.length>=3?s=[null,e,null]:s=nr.exec(e),s&&(s[1]||!i))if(s[1]){if(i=i instanceof o?i[0]:i,o.merge(this,o.parseHTML(s[1],i&&i.nodeType?i.ownerDocument||i:K,!0)),nt.test(s[1])&&o.isPlainObject(i))for(s in i)V(this[s])?this[s](i[s]):this.attr(s,i[s]);return this}else return c=K.getElementById(s[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(V(e))return n.ready!==void 0?n.ready(e):e(o)}return o.makeArray(e,this)};Sr.prototype=o.fn,bt=o(K);var Nr=/^(?:parents|prev(?:Until|All))/,Jt={children:!0,contents:!0,next:!0,prev:!0};o.fn.extend({has:function(e){var i=o(e,this),n=i.length;return this.filter(function(){for(var s=0;s<n;s++)if(o.contains(this,i[s]))return!0})},closest:function(e,i){var n,s=0,c=this.length,f=[],h=typeof e!="string"&&o(e);if(!ze.test(e)){for(;s<c;s++)for(n=this[s];n&&n!==i;n=n.parentNode)if(n.nodeType<11&&(h?h.index(n)>-1:n.nodeType===1&&o.find.matchesSelector(n,e))){f.push(n);break}}return this.pushStack(f.length>1?o.uniqueSort(f):f)},index:function(e){return e?typeof e=="string"?b.call(o(e),this[0]):b.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,i){return this.pushStack(o.uniqueSort(o.merge(this.get(),o(e,i))))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}});function Or(e,i){for(;(e=e[i])&&e.nodeType!==1;);return e}o.each({parent:function(e){var i=e.parentNode;return i&&i.nodeType!==11?i:null},parents:function(e){return oe(e,"parentNode")},parentsUntil:function(e,i,n){return oe(e,"parentNode",n)},next:function(e){return Or(e,"nextSibling")},prev:function(e){return Or(e,"previousSibling")},nextAll:function(e){return oe(e,"nextSibling")},prevAll:function(e){return oe(e,"previousSibling")},nextUntil:function(e,i,n){return oe(e,"nextSibling",n)},prevUntil:function(e,i,n){return oe(e,"previousSibling",n)},siblings:function(e){return _e((e.parentNode||{}).firstChild,e)},children:function(e){return _e(e.firstChild)},contents:function(e){return e.contentDocument!=null&&a(e.contentDocument)?e.contentDocument:(Me(e,"template")&&(e=e.content||e),o.merge([],e.childNodes))}},function(e,i){o.fn[e]=function(n,s){var c=o.map(this,i,n);return e.slice(-5)!=="Until"&&(s=n),s&&typeof s=="string"&&(c=o.filter(s,c)),this.length>1&&(Jt[e]||o.uniqueSort(c),Nr.test(e)&&c.reverse()),this.pushStack(c)}});var yt=/[^\x20\t\r\n\f]+/g;function Ln(e){var i={};return o.each(e.match(yt)||[],function(n,s){i[s]=!0}),i}o.Callbacks=function(e){e=typeof e=="string"?Ln(e):o.extend({},e);var i,n,s,c,f=[],h=[],E=-1,x=function(){for(c=c||e.once,s=i=!0;h.length;E=-1)for(n=h.shift();++E<f.length;)f[E].apply(n[0],n[1])===!1&&e.stopOnFalse&&(E=f.length,n=!1);e.memory||(n=!1),i=!1,c&&(n?f=[]:f="")},D={add:function(){return f&&(n&&!i&&(E=f.length-1,h.push(n)),function R(U){o.each(U,function(F,I){V(I)?(!e.unique||!D.has(I))&&f.push(I):I&&I.length&&be(I)!=="string"&&R(I)})}(arguments),n&&!i&&x()),this},remove:function(){return o.each(arguments,function(R,U){for(var F;(F=o.inArray(U,f,F))>-1;)f.splice(F,1),F<=E&&E--}),this},has:function(R){return R?o.inArray(R,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(R,U){return c||(U=U||[],U=[R,U.slice?U.slice():U],h.push(U),i||x()),this},fire:function(){return D.fireWith(this,arguments),this},fired:function(){return!!s}};return D};function Ze(e){return e}function ar(e){throw e}function Di(e,i,n,s){var c;try{e&&V(c=e.promise)?c.call(e).done(i).fail(n):e&&V(c=e.then)?c.call(e,i,n):i.apply(void 0,[e].slice(s))}catch(f){n.apply(void 0,[f])}}o.extend({Deferred:function(e){var i=[["notify","progress",o.Callbacks("memory"),o.Callbacks("memory"),2],["resolve","done",o.Callbacks("once memory"),o.Callbacks("once memory"),0,"resolved"],["reject","fail",o.Callbacks("once memory"),o.Callbacks("once memory"),1,"rejected"]],n="pending",s={state:function(){return n},always:function(){return c.done(arguments).fail(arguments),this},catch:function(f){return s.then(null,f)},pipe:function(){var f=arguments;return o.Deferred(function(h){o.each(i,function(E,x){var D=V(f[x[4]])&&f[x[4]];c[x[1]](function(){var R=D&&D.apply(this,arguments);R&&V(R.promise)?R.promise().progress(h.notify).done(h.resolve).fail(h.reject):h[x[0]+"With"](this,D?[R]:arguments)})}),f=null}).promise()},then:function(f,h,E){var x=0;function D(R,U,F,I){return function(){var ie=this,ve=arguments,re=function(){var Ve,ht;if(!(R<x)){if(Ve=F.apply(ie,ve),Ve===U.promise())throw new TypeError("Thenable self-resolution");ht=Ve&&(typeof Ve=="object"||typeof Ve=="function")&&Ve.then,V(ht)?I?ht.call(Ve,D(x,U,Ze,I),D(x,U,ar,I)):(x++,ht.call(Ve,D(x,U,Ze,I),D(x,U,ar,I),D(x,U,Ze,U.notifyWith))):(F!==Ze&&(ie=void 0,ve=[Ve]),(I||U.resolveWith)(ie,ve))}},qe=I?re:function(){try{re()}catch(Ve){o.Deferred.exceptionHook&&o.Deferred.exceptionHook(Ve,qe.stackTrace),R+1>=x&&(F!==ar&&(ie=void 0,ve=[Ve]),U.rejectWith(ie,ve))}};R?qe():(o.Deferred.getStackHook&&(qe.stackTrace=o.Deferred.getStackHook()),l.setTimeout(qe))}}return o.Deferred(function(R){i[0][3].add(D(0,R,V(E)?E:Ze,R.notifyWith)),i[1][3].add(D(0,R,V(f)?f:Ze)),i[2][3].add(D(0,R,V(h)?h:ar))}).promise()},promise:function(f){return f!=null?o.extend(f,s):s}},c={};return o.each(i,function(f,h){var E=h[2],x=h[5];s[h[1]]=E.add,x&&E.add(function(){n=x},i[3-f][2].disable,i[3-f][3].disable,i[0][2].lock,i[0][3].lock),E.add(h[3].fire),c[h[0]]=function(){return c[h[0]+"With"](this===c?void 0:this,arguments),this},c[h[0]+"With"]=E.fireWith}),s.promise(c),e&&e.call(c,c),c},when:function(e){var i=arguments.length,n=i,s=Array(n),c=u.call(arguments),f=o.Deferred(),h=function(E){return function(x){s[E]=this,c[E]=arguments.length>1?u.call(arguments):x,--i||f.resolveWith(s,c)}};if(i<=1&&(Di(e,f.done(h(n)).resolve,f.reject,!i),f.state()==="pending"||V(c[n]&&c[n].then)))return f.then();for(;n--;)Di(c[n],h(n),f.reject);return f.promise()}});var Fn=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;o.Deferred.exceptionHook=function(e,i){l.console&&l.console.warn&&e&&Fn.test(e.name)&&l.console.warn("jQuery.Deferred exception: "+e.message,e.stack,i)},o.readyException=function(e){l.setTimeout(function(){throw e})};var $r=o.Deferred();o.fn.ready=function(e){return $r.then(e).catch(function(i){o.readyException(i)}),this},o.extend({isReady:!1,readyWait:1,ready:function(e){(e===!0?--o.readyWait:o.isReady)||(o.isReady=!0,!(e!==!0&&--o.readyWait>0)&&$r.resolveWith(K,[o]))}}),o.ready.then=$r.then;function _r(){K.removeEventListener("DOMContentLoaded",_r),l.removeEventListener("load",_r),o.ready()}K.readyState==="complete"||K.readyState!=="loading"&&!K.documentElement.doScroll?l.setTimeout(o.ready):(K.addEventListener("DOMContentLoaded",_r),l.addEventListener("load",_r));var Ct=function(e,i,n,s,c,f,h){var E=0,x=e.length,D=n==null;if(be(n)==="object"){c=!0;for(E in n)Ct(e,i,E,n[E],!0,f,h)}else if(s!==void 0&&(c=!0,V(s)||(h=!0),D&&(h?(i.call(e,s),i=null):(D=i,i=function(R,U,F){return D.call(o(R),F)})),i))for(;E<x;E++)i(e[E],n,h?s:s.call(e[E],E,i(e[E],n)));return c?e:D?i.call(e):x?i(e[0],n):f},Rn=/^-ms-/,In=/-([a-z])/g;function Mn(e,i){return i.toUpperCase()}function xt(e){return e.replace(Rn,"ms-").replace(In,Mn)}var sr=function(e){return e.nodeType===1||e.nodeType===9||!+e.nodeType};function or(){this.expando=o.expando+or.uid++}or.uid=1,or.prototype={cache:function(e){var i=e[this.expando];return i||(i={},sr(e)&&(e.nodeType?e[this.expando]=i:Object.defineProperty(e,this.expando,{value:i,configurable:!0}))),i},set:function(e,i,n){var s,c=this.cache(e);if(typeof i=="string")c[xt(i)]=n;else for(s in i)c[xt(s)]=i[s];return c},get:function(e,i){return i===void 0?this.cache(e):e[this.expando]&&e[this.expando][xt(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,s=e[this.expando];if(s!==void 0){if(i!==void 0)for(Array.isArray(i)?i=i.map(xt):(i=xt(i),i=i in s?[i]:i.match(yt)||[]),n=i.length;n--;)delete s[i[n]];(i===void 0||o.isEmptyObject(s))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var i=e[this.expando];return i!==void 0&&!o.isEmptyObject(i)}};var le=new or,$e=new or,Nn=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Li=/[A-Z]/g;function Tr(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e===+e+""?+e:Nn.test(e)?JSON.parse(e):e}function Cr(e,i,n){var s;if(n===void 0&&e.nodeType===1)if(s="data-"+i.replace(Li,"-$&").toLowerCase(),n=e.getAttribute(s),typeof n=="string"){try{n=Tr(n)}catch(c){}$e.set(e,i,n)}else n=void 0;return n}o.extend({hasData:function(e){return $e.hasData(e)||le.hasData(e)},data:function(e,i,n){return $e.access(e,i,n)},removeData:function(e,i){$e.remove(e,i)},_data:function(e,i,n){return le.access(e,i,n)},_removeData:function(e,i){le.remove(e,i)}}),o.fn.extend({data:function(e,i){var n,s,c,f=this[0],h=f&&f.attributes;if(e===void 0){if(this.length&&(c=$e.get(f),f.nodeType===1&&!le.get(f,"hasDataAttrs"))){for(n=h.length;n--;)h[n]&&(s=h[n].name,s.indexOf("data-")===0&&(s=xt(s.slice(5)),Cr(f,s,c[s])));le.set(f,"hasDataAttrs",!0)}return c}return typeof e=="object"?this.each(function(){$e.set(this,e)}):Ct(this,function(E){var x;if(f&&E===void 0)return x=$e.get(f,e),x!==void 0||(x=Cr(f,e),x!==void 0)?x:void 0;this.each(function(){$e.set(this,e,E)})},null,i,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){$e.remove(this,e)})}}),o.extend({queue:function(e,i,n){var s;if(e)return i=(i||"fx")+"queue",s=le.get(e,i),n&&(!s||Array.isArray(n)?s=le.access(e,i,o.makeArray(n)):s.push(n)),s||[]},dequeue:function(e,i){i=i||"fx";var n=o.queue(e,i),s=n.length,c=n.shift(),f=o._queueHooks(e,i),h=function(){o.dequeue(e,i)};c==="inprogress"&&(c=n.shift(),s--),c&&(i==="fx"&&n.unshift("inprogress"),delete f.stop,c.call(e,h,f)),!s&&f&&f.empty.fire()},_queueHooks:function(e,i){var n=i+"queueHooks";return le.get(e,n)||le.access(e,n,{empty:o.Callbacks("once memory").add(function(){le.remove(e,[i+"queue",n])})})}}),o.fn.extend({queue:function(e,i){var n=2;return typeof e!="string"&&(i=e,e="fx",n--),arguments.length<n?o.queue(this[0],e):i===void 0?this:this.each(function(){var s=o.queue(this,e,i);o._queueHooks(this,e),e==="fx"&&s[0]!=="inprogress"&&o.dequeue(this,e)})},dequeue:function(e){return this.each(function(){o.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,i){var n,s=1,c=o.Deferred(),f=this,h=this.length,E=function(){--s||c.resolveWith(f,[f])};for(typeof e!="string"&&(i=e,e=void 0),e=e||"fx";h--;)n=le.get(f[h],e+"queueHooks"),n&&n.empty&&(s++,n.empty.add(E));return E(),c.promise(i)}});var kr=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,$t=new RegExp("^(?:([+-])=|)("+kr+")([a-z%]*)$","i"),wt=["Top","Right","Bottom","Left"],Lt=K.documentElement,Wt=function(e){return o.contains(e.ownerDocument,e)},Fi={composed:!0};Lt.getRootNode&&(Wt=function(e){return o.contains(e.ownerDocument,e)||e.getRootNode(Fi)===e.ownerDocument});var lr=function(e,i){return e=i||e,e.style.display==="none"||e.style.display===""&&Wt(e)&&o.css(e,"display")==="none"};function Wr(e,i,n,s){var c,f,h=20,E=s?function(){return s.cur()}:function(){return o.css(e,i,"")},x=E(),D=n&&n[3]||(o.cssNumber[i]?"":"px"),R=e.nodeType&&(o.cssNumber[i]||D!=="px"&&+x)&&$t.exec(o.css(e,i));if(R&&R[3]!==D){for(x=x/2,D=D||R[3],R=+x||1;h--;)o.style(e,i,R+D),(1-f)*(1-(f=E()/x||.5))<=0&&(h=0),R=R/f;R=R*2,o.style(e,i,R+D),n=n||[]}return n&&(R=+R||+x||0,c=n[1]?R+(n[1]+1)*n[2]:+n[2],s&&(s.unit=D,s.start=R,s.end=c)),c}var Br={};function Ri(e){var i,n=e.ownerDocument,s=e.nodeName,c=Br[s];return c||(i=n.body.appendChild(n.createElement(s)),c=o.css(i,"display"),i.parentNode.removeChild(i),c==="none"&&(c="block"),Br[s]=c,c)}function Bt(e,i){for(var n,s,c=[],f=0,h=e.length;f<h;f++)s=e[f],!!s.style&&(n=s.style.display,i?(n==="none"&&(c[f]=le.get(s,"display")||null,c[f]||(s.style.display="")),s.style.display===""&&lr(s)&&(c[f]=Ri(s))):n!=="none"&&(c[f]="none",le.set(s,"display",n)));for(f=0;f<h;f++)c[f]!=null&&(e[f].style.display=c[f]);return e}o.fn.extend({show:function(){return Bt(this,!0)},hide:function(){return Bt(this)},toggle:function(e){return typeof e=="boolean"?e?this.show():this.hide():this.each(function(){lr(this)?o(this).show():o(this).hide()})}});var Kt=/^(?:checkbox|radio)$/i,Ur=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,jr=/^$|^module$|\/(?:java|ecma)script/i;(function(){var e=K.createDocumentFragment(),i=e.appendChild(K.createElement("div")),n=K.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),i.appendChild(n),H.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,i.innerHTML="<textarea>x</textarea>",H.noCloneChecked=!!i.cloneNode(!0).lastChild.defaultValue,i.innerHTML="<option></option>",H.option=!!i.lastChild})();var et={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,"",""]};et.tbody=et.tfoot=et.colgroup=et.caption=et.thead,et.th=et.td,H.option||(et.optgroup=et.option=[1,"<select multiple='multiple'>","</select>"]);function tt(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&&Me(e,i)?o.merge([e],n):n}function Hr(e,i){for(var n=0,s=e.length;n<s;n++)le.set(e[n],"globalEval",!i||le.get(i[n],"globalEval"))}var zr=/<|&#?\w+;/;function Vr(e,i,n,s,c){for(var f,h,E,x,D,R,U=i.createDocumentFragment(),F=[],I=0,ie=e.length;I<ie;I++)if(f=e[I],f||f===0)if(be(f)==="object")o.merge(F,f.nodeType?[f]:f);else if(!zr.test(f))F.push(i.createTextNode(f));else{for(h=h||U.appendChild(i.createElement("div")),E=(Ur.exec(f)||["",""])[1].toLowerCase(),x=et[E]||et._default,h.innerHTML=x[1]+o.htmlPrefilter(f)+x[2],R=x[0];R--;)h=h.lastChild;o.merge(F,h.childNodes),h=U.firstChild,h.textContent=""}for(U.textContent="",I=0;f=F[I++];){if(s&&o.inArray(f,s)>-1){c&&c.push(f);continue}if(D=Wt(f),h=tt(U.appendChild(f),"script"),D&&Hr(h),n)for(R=0;f=h[R++];)jr.test(f.type||"")&&n.push(f)}return U}var Ii=/^([^.]*)(?:\.(.+)|)/;function at(){return!0}function Zt(){return!1}function On(e,i){return e===Mi()==(i==="focus")}function Mi(){try{return K.activeElement}catch(e){}}function qr(e,i,n,s,c,f){var h,E;if(typeof i=="object"){typeof n!="string"&&(s=s||n,n=void 0);for(E in i)qr(e,E,n,s,i[E],f);return e}if(s==null&&c==null?(c=n,s=n=void 0):c==null&&(typeof n=="string"?(c=s,s=void 0):(c=s,s=n,n=void 0)),c===!1)c=Zt;else if(!c)return e;return f===1&&(h=c,c=function(x){return o().off(x),h.apply(this,arguments)},c.guid=h.guid||(h.guid=o.guid++)),e.each(function(){o.event.add(this,i,c,s,n)})}o.event={global:{},add:function(e,i,n,s,c){var f,h,E,x,D,R,U,F,I,ie,ve,re=le.get(e);if(!!sr(e))for(n.handler&&(f=n,n=f.handler,c=f.selector),c&&o.find.matchesSelector(Lt,c),n.guid||(n.guid=o.guid++),(x=re.events)||(x=re.events=Object.create(null)),(h=re.handle)||(h=re.handle=function(qe){return typeof o!="undefined"&&o.event.triggered!==qe.type?o.event.dispatch.apply(e,arguments):void 0}),i=(i||"").match(yt)||[""],D=i.length;D--;)E=Ii.exec(i[D])||[],I=ve=E[1],ie=(E[2]||"").split(".").sort(),!!I&&(U=o.event.special[I]||{},I=(c?U.delegateType:U.bindType)||I,U=o.event.special[I]||{},R=o.extend({type:I,origType:ve,data:s,handler:n,guid:n.guid,selector:c,needsContext:c&&o.expr.match.needsContext.test(c),namespace:ie.join(".")},f),(F=x[I])||(F=x[I]=[],F.delegateCount=0,(!U.setup||U.setup.call(e,s,ie,h)===!1)&&e.addEventListener&&e.addEventListener(I,h)),U.add&&(U.add.call(e,R),R.handler.guid||(R.handler.guid=n.guid)),c?F.splice(F.delegateCount++,0,R):F.push(R),o.event.global[I]=!0)},remove:function(e,i,n,s,c){var f,h,E,x,D,R,U,F,I,ie,ve,re=le.hasData(e)&&le.get(e);if(!(!re||!(x=re.events))){for(i=(i||"").match(yt)||[""],D=i.length;D--;){if(E=Ii.exec(i[D])||[],I=ve=E[1],ie=(E[2]||"").split(".").sort(),!I){for(I in x)o.event.remove(e,I+i[D],n,s,!0);continue}for(U=o.event.special[I]||{},I=(s?U.delegateType:U.bindType)||I,F=x[I]||[],E=E[2]&&new RegExp("(^|\\.)"+ie.join("\\.(?:.*\\.|)")+"(\\.|$)"),h=f=F.length;f--;)R=F[f],(c||ve===R.origType)&&(!n||n.guid===R.guid)&&(!E||E.test(R.namespace))&&(!s||s===R.selector||s==="**"&&R.selector)&&(F.splice(f,1),R.selector&&F.delegateCount--,U.remove&&U.remove.call(e,R));h&&!F.length&&((!U.teardown||U.teardown.call(e,ie,re.handle)===!1)&&o.removeEvent(e,I,re.handle),delete x[I])}o.isEmptyObject(x)&&le.remove(e,"handle events")}},dispatch:function(e){var i,n,s,c,f,h,E=new Array(arguments.length),x=o.event.fix(e),D=(le.get(this,"events")||Object.create(null))[x.type]||[],R=o.event.special[x.type]||{};for(E[0]=x,i=1;i<arguments.length;i++)E[i]=arguments[i];if(x.delegateTarget=this,!(R.preDispatch&&R.preDispatch.call(this,x)===!1)){for(h=o.event.handlers.call(this,x,D),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,s=((o.event.special[f.origType]||{}).handle||f.handler).apply(c.elem,E),s!==void 0&&(x.result=s)===!1&&(x.preventDefault(),x.stopPropagation()));return R.postDispatch&&R.postDispatch.call(this,x),x.result}},handlers:function(e,i){var n,s,c,f,h,E=[],x=i.delegateCount,D=e.target;if(x&&D.nodeType&&!(e.type==="click"&&e.button>=1)){for(;D!==this;D=D.parentNode||this)if(D.nodeType===1&&!(e.type==="click"&&D.disabled===!0)){for(f=[],h={},n=0;n<x;n++)s=i[n],c=s.selector+" ",h[c]===void 0&&(h[c]=s.needsContext?o(c,this).index(D)>-1:o.find(c,this,null,[D]).length),h[c]&&f.push(s);f.length&&E.push({elem:D,handlers:f})}}return D=this,x<i.length&&E.push({elem:D,handlers:i.slice(x)}),E},addProp:function(e,i){Object.defineProperty(o.Event.prototype,e,{enumerable:!0,configurable:!0,get:V(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[o.expando]?e:new o.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var i=this||e;return Kt.test(i.type)&&i.click&&Me(i,"input")&&Pr(i,"click",at),!1},trigger:function(e){var i=this||e;return Kt.test(i.type)&&i.click&&Me(i,"input")&&Pr(i,"click"),!0},_default:function(e){var i=e.target;return Kt.test(i.type)&&i.click&&Me(i,"input")&&le.get(i,"click")||Me(i,"a")}},beforeunload:{postDispatch:function(e){e.result!==void 0&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}};function Pr(e,i,n){if(!n){le.get(e,i)===void 0&&o.event.add(e,i,at);return}le.set(e,i,!1),o.event.add(e,i,{namespace:!1,handler:function(s){var c,f,h=le.get(this,i);if(s.isTrigger&1&&this[i]){if(h.length)(o.event.special[i]||{}).delegateType&&s.stopPropagation();else if(h=u.call(arguments),le.set(this,i,h),c=n(this,i),this[i](),f=le.get(this,i),h!==f||c?le.set(this,i,!1):f={},h!==f)return s.stopImmediatePropagation(),s.preventDefault(),f&&f.value}else h.length&&(le.set(this,i,{value:o.event.trigger(o.extend(h[0],o.Event.prototype),h.slice(1),this)}),s.stopImmediatePropagation())}})}o.removeEvent=function(e,i,n){e.removeEventListener&&e.removeEventListener(i,n)},o.Event=function(e,i){if(!(this instanceof o.Event))return new o.Event(e,i);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.defaultPrevented===void 0&&e.returnValue===!1?at:Zt,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&&o.extend(this,i),this.timeStamp=e&&e.timeStamp||Date.now(),this[o.expando]=!0},o.Event.prototype={constructor:o.Event,isDefaultPrevented:Zt,isPropagationStopped:Zt,isImmediatePropagationStopped:Zt,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=at,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=at,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=at,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},o.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},o.event.addProp),o.each({focus:"focusin",blur:"focusout"},function(e,i){o.event.special[e]={setup:function(){return Pr(this,e,On),!1},trigger:function(){return Pr(this,e),!0},_default:function(n){return le.get(n.target,e)},delegateType:i}}),o.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){o.event.special[e]={delegateType:i,bindType:i,handle:function(n){var s,c=this,f=n.relatedTarget,h=n.handleObj;return(!f||f!==c&&!o.contains(c,f))&&(n.type=h.origType,s=h.handler.apply(this,arguments),n.type=i),s}}}),o.fn.extend({on:function(e,i,n,s){return qr(this,e,i,n,s)},one:function(e,i,n,s){return qr(this,e,i,n,s,1)},off:function(e,i,n){var s,c;if(e&&e.preventDefault&&e.handleObj)return s=e.handleObj,o(e.delegateTarget).off(s.namespace?s.origType+"."+s.namespace:s.origType,s.selector,s.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=Zt),this.each(function(){o.event.remove(this,e,n,i)})}});var $n=/<script|<style|<link/i,Wn=/checked\s*(?:[^=]|=\s*.checked.)/i,Bn=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Ni(e,i){return Me(e,"table")&&Me(i.nodeType!==11?i:i.firstChild,"tr")&&o(e).children("tbody")[0]||e}function Un(e){return e.type=(e.getAttribute("type")!==null)+"/"+e.type,e}function jn(e){return(e.type||"").slice(0,5)==="true/"?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Oi(e,i){var n,s,c,f,h,E,x;if(i.nodeType===1){if(le.hasData(e)&&(f=le.get(e),x=f.events,x)){le.remove(i,"handle events");for(c in x)for(n=0,s=x[c].length;n<s;n++)o.event.add(i,c,x[c][n])}$e.hasData(e)&&(h=$e.access(e),E=o.extend({},h),$e.set(i,E))}}function Hn(e,i){var n=i.nodeName.toLowerCase();n==="input"&&Kt.test(e.type)?i.checked=e.checked:(n==="input"||n==="textarea")&&(i.defaultValue=e.defaultValue)}function Ut(e,i,n,s){i=d(i);var c,f,h,E,x,D,R=0,U=e.length,F=U-1,I=i[0],ie=V(I);if(ie||U>1&&typeof I=="string"&&!H.checkClone&&Wn.test(I))return e.each(function(ve){var re=e.eq(ve);ie&&(i[0]=I.call(this,ve,re.html())),Ut(re,i,n,s)});if(U&&(c=Vr(i,e[0].ownerDocument,!1,e,s),f=c.firstChild,c.childNodes.length===1&&(c=f),f||s)){for(h=o.map(tt(c,"script"),Un),E=h.length;R<U;R++)x=c,R!==F&&(x=o.clone(x,!0,!0),E&&o.merge(h,tt(x,"script"))),n.call(e[R],x,R);if(E)for(D=h[h.length-1].ownerDocument,o.map(h,jn),R=0;R<E;R++)x=h[R],jr.test(x.type||"")&&!le.access(x,"globalEval")&&o.contains(D,x)&&(x.src&&(x.type||"").toLowerCase()!=="module"?o._evalUrl&&!x.noModule&&o._evalUrl(x.src,{nonce:x.nonce||x.getAttribute("nonce")},D):Ce(x.textContent.replace(Bn,""),x,D))}return e}function $i(e,i,n){for(var s,c=i?o.filter(i,e):e,f=0;(s=c[f])!=null;f++)!n&&s.nodeType===1&&o.cleanData(tt(s)),s.parentNode&&(n&&Wt(s)&&Hr(tt(s,"script")),s.parentNode.removeChild(s));return e}o.extend({htmlPrefilter:function(e){return e},clone:function(e,i,n){var s,c,f,h,E=e.cloneNode(!0),x=Wt(e);if(!H.noCloneChecked&&(e.nodeType===1||e.nodeType===11)&&!o.isXMLDoc(e))for(h=tt(E),f=tt(e),s=0,c=f.length;s<c;s++)Hn(f[s],h[s]);if(i)if(n)for(f=f||tt(e),h=h||tt(E),s=0,c=f.length;s<c;s++)Oi(f[s],h[s]);else Oi(e,E);return h=tt(E,"script"),h.length>0&&Hr(h,!x&&tt(e,"script")),E},cleanData:function(e){for(var i,n,s,c=o.event.special,f=0;(n=e[f])!==void 0;f++)if(sr(n)){if(i=n[le.expando]){if(i.events)for(s in i.events)c[s]?o.event.remove(n,s):o.removeEvent(n,s,i.handle);n[le.expando]=void 0}n[$e.expando]&&(n[$e.expando]=void 0)}}}),o.fn.extend({detach:function(e){return $i(this,e,!0)},remove:function(e){return $i(this,e)},text:function(e){return Ct(this,function(i){return i===void 0?o.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 Ut(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Ni(this,e);i.appendChild(e)}})},prepend:function(){return Ut(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Ni(this,e);i.insertBefore(e,i.firstChild)}})},before:function(){return Ut(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Ut(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&&(o.cleanData(tt(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 o.clone(this,e,i)})},html:function(e){return Ct(this,function(i){var n=this[0]||{},s=0,c=this.length;if(i===void 0&&n.nodeType===1)return n.innerHTML;if(typeof i=="string"&&!$n.test(i)&&!et[(Ur.exec(i)||["",""])[1].toLowerCase()]){i=o.htmlPrefilter(i);try{for(;s<c;s++)n=this[s]||{},n.nodeType===1&&(o.cleanData(tt(n,!1)),n.innerHTML=i);n=0}catch(f){}}n&&this.empty().append(i)},null,e,arguments.length)},replaceWith:function(){var e=[];return Ut(this,arguments,function(i){var n=this.parentNode;o.inArray(this,e)<0&&(o.cleanData(tt(this)),n&&n.replaceChild(i,this))},e)}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,i){o.fn[e]=function(n){for(var s,c=[],f=o(n),h=f.length-1,E=0;E<=h;E++)s=E===h?this:this.clone(!0),o(f[E])[i](s),m.apply(c,s.get());return this.pushStack(c)}});var Gr=new RegExp("^("+kr+")(?!px)[a-z%]+$","i"),Yr=/^--/,Ar=function(e){var i=e.ownerDocument.defaultView;return(!i||!i.opener)&&(i=l),i.getComputedStyle(e)},Wi=function(e,i,n){var s,c,f={};for(c in i)f[c]=e.style[c],e.style[c]=i[c];s=n.call(e);for(c in i)e.style[c]=f[c];return s},zn=new RegExp(wt.join("|"),"i"),Bi="[\\x20\\t\\r\\n\\f]",Vn=new RegExp("^"+Bi+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Bi+"+$","g");(function(){function e(){if(!!D){x.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",D.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",Lt.appendChild(x).appendChild(D);var R=l.getComputedStyle(D);n=R.top!=="1%",E=i(R.marginLeft)===12,D.style.right="60%",f=i(R.right)===36,s=i(R.width)===36,D.style.position="absolute",c=i(D.offsetWidth/3)===12,Lt.removeChild(x),D=null}}function i(R){return Math.round(parseFloat(R))}var n,s,c,f,h,E,x=K.createElement("div"),D=K.createElement("div");!D.style||(D.style.backgroundClip="content-box",D.cloneNode(!0).style.backgroundClip="",H.clearCloneStyle=D.style.backgroundClip==="content-box",o.extend(H,{boxSizingReliable:function(){return e(),s},pixelBoxStyles:function(){return e(),f},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),E},scrollboxSize:function(){return e(),c},reliableTrDimensions:function(){var R,U,F,I;return h==null&&(R=K.createElement("table"),U=K.createElement("tr"),F=K.createElement("div"),R.style.cssText="position:absolute;left:-11111px;border-collapse:separate",U.style.cssText="border:1px solid",U.style.height="1px",F.style.height="9px",F.style.display="block",Lt.appendChild(R).appendChild(U).appendChild(F),I=l.getComputedStyle(U),h=parseInt(I.height,10)+parseInt(I.borderTopWidth,10)+parseInt(I.borderBottomWidth,10)===U.offsetHeight,Lt.removeChild(R)),h}}))})();function ur(e,i,n){var s,c,f,h,E=Yr.test(i),x=e.style;return n=n||Ar(e),n&&(h=n.getPropertyValue(i)||n[i],E&&h&&(h=h.replace(Vn,"$1")||void 0),h===""&&!Wt(e)&&(h=o.style(e,i)),!H.pixelBoxStyles()&&Gr.test(h)&&zn.test(i)&&(s=x.width,c=x.minWidth,f=x.maxWidth,x.minWidth=x.maxWidth=x.width=h,h=n.width,x.width=s,x.minWidth=c,x.maxWidth=f)),h!==void 0?h+"":h}function Ui(e,i){return{get:function(){if(e()){delete this.get;return}return(this.get=i).apply(this,arguments)}}}var ji=["Webkit","Moz","ms"],Hi=K.createElement("div").style,zi={};function qn(e){for(var i=e[0].toUpperCase()+e.slice(1),n=ji.length;n--;)if(e=ji[n]+i,e in Hi)return e}function Xr(e){var i=o.cssProps[e]||zi[e];return i||(e in Hi?e:zi[e]=qn(e)||e)}var Vi=/^(none|table(?!-c[ea]).+)/,cr={position:"absolute",visibility:"hidden",display:"block"},Qr={letterSpacing:"0",fontWeight:"400"};function jt(e,i,n){var s=$t.exec(i);return s?Math.max(0,s[2]-(n||0))+(s[3]||"px"):i}function Jr(e,i,n,s,c,f){var h=i==="width"?1:0,E=0,x=0;if(n===(s?"border":"content"))return 0;for(;h<4;h+=2)n==="margin"&&(x+=o.css(e,n+wt[h],!0,c)),s?(n==="content"&&(x-=o.css(e,"padding"+wt[h],!0,c)),n!=="margin"&&(x-=o.css(e,"border"+wt[h]+"Width",!0,c))):(x+=o.css(e,"padding"+wt[h],!0,c),n!=="padding"?x+=o.css(e,"border"+wt[h]+"Width",!0,c):E+=o.css(e,"border"+wt[h]+"Width",!0,c));return!s&&f>=0&&(x+=Math.max(0,Math.ceil(e["offset"+i[0].toUpperCase()+i.slice(1)]-f-x-E-.5))||0),x}function fr(e,i,n){var s=Ar(e),c=!H.boxSizingReliable()||n,f=c&&o.css(e,"boxSizing",!1,s)==="border-box",h=f,E=ur(e,i,s),x="offset"+i[0].toUpperCase()+i.slice(1);if(Gr.test(E)){if(!n)return E;E="auto"}return(!H.boxSizingReliable()&&f||!H.reliableTrDimensions()&&Me(e,"tr")||E==="auto"||!parseFloat(E)&&o.css(e,"display",!1,s)==="inline")&&e.getClientRects().length&&(f=o.css(e,"boxSizing",!1,s)==="border-box",h=x in e,h&&(E=e[x])),E=parseFloat(E)||0,E+Jr(e,i,n||(f?"border":"content"),h,s,E)+"px"}o.extend({cssHooks:{opacity:{get:function(e,i){if(i){var n=ur(e,"opacity");return n===""?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!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,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,i,n,s){if(!(!e||e.nodeType===3||e.nodeType===8||!e.style)){var c,f,h,E=xt(i),x=Yr.test(i),D=e.style;if(x||(i=Xr(E)),h=o.cssHooks[i]||o.cssHooks[E],n!==void 0){if(f=typeof n,f==="string"&&(c=$t.exec(n))&&c[1]&&(n=Wr(e,i,c),f="number"),n==null||n!==n)return;f==="number"&&!x&&(n+=c&&c[3]||(o.cssNumber[E]?"":"px")),!H.clearCloneStyle&&n===""&&i.indexOf("background")===0&&(D[i]="inherit"),(!h||!("set"in h)||(n=h.set(e,n,s))!==void 0)&&(x?D.setProperty(i,n):D[i]=n)}else return h&&"get"in h&&(c=h.get(e,!1,s))!==void 0?c:D[i]}},css:function(e,i,n,s){var c,f,h,E=xt(i),x=Yr.test(i);return x||(i=Xr(E)),h=o.cssHooks[i]||o.cssHooks[E],h&&"get"in h&&(c=h.get(e,!0,n)),c===void 0&&(c=ur(e,i,s)),c==="normal"&&i in Qr&&(c=Qr[i]),n===""||n?(f=parseFloat(c),n===!0||isFinite(f)?f||0:c):c}}),o.each(["height","width"],function(e,i){o.cssHooks[i]={get:function(n,s,c){if(s)return Vi.test(o.css(n,"display"))&&(!n.getClientRects().length||!n.getBoundingClientRect().width)?Wi(n,cr,function(){return fr(n,i,c)}):fr(n,i,c)},set:function(n,s,c){var f,h=Ar(n),E=!H.scrollboxSize()&&h.position==="absolute",x=E||c,D=x&&o.css(n,"boxSizing",!1,h)==="border-box",R=c?Jr(n,i,c,D,h):0;return D&&E&&(R-=Math.ceil(n["offset"+i[0].toUpperCase()+i.slice(1)]-parseFloat(h[i])-Jr(n,i,"border",!1,h)-.5)),R&&(f=$t.exec(s))&&(f[3]||"px")!=="px"&&(n.style[i]=s,s=o.css(n,i)),jt(n,s,R)}}}),o.cssHooks.marginLeft=Ui(H.reliableMarginLeft,function(e,i){if(i)return(parseFloat(ur(e,"marginLeft"))||e.getBoundingClientRect().left-Wi(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),o.each({margin:"",padding:"",border:"Width"},function(e,i){o.cssHooks[e+i]={expand:function(n){for(var s=0,c={},f=typeof n=="string"?n.split(" "):[n];s<4;s++)c[e+wt[s]+i]=f[s]||f[s-2]||f[0];return c}},e!=="margin"&&(o.cssHooks[e+i].set=jt)}),o.fn.extend({css:function(e,i){return Ct(this,function(n,s,c){var f,h,E={},x=0;if(Array.isArray(s)){for(f=Ar(n),h=s.length;x<h;x++)E[s[x]]=o.css(n,s[x],!1,f);return E}return c!==void 0?o.style(n,s,c):o.css(n,s)},e,i,arguments.length>1)}});function Qe(e,i,n,s,c){return new Qe.prototype.init(e,i,n,s,c)}o.Tween=Qe,Qe.prototype={constructor:Qe,init:function(e,i,n,s,c,f){this.elem=e,this.prop=n,this.easing=c||o.easing._default,this.options=i,this.start=this.now=this.cur(),this.end=s,this.unit=f||(o.cssNumber[n]?"":"px")},cur:function(){var e=Qe.propHooks[this.prop];return e&&e.get?e.get(this):Qe.propHooks._default.get(this)},run:function(e){var i,n=Qe.propHooks[this.prop];return this.options.duration?this.pos=i=o.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):Qe.propHooks._default.set(this),this}},Qe.prototype.init.prototype=Qe.prototype,Qe.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=o.css(e.elem,e.prop,""),!i||i==="auto"?0:i)},set:function(e){o.fx.step[e.prop]?o.fx.step[e.prop](e):e.elem.nodeType===1&&(o.cssHooks[e.prop]||e.elem.style[Xr(e.prop)]!=null)?o.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Qe.propHooks.scrollTop=Qe.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},o.easing={linear:function(e){return e},swing:function(e){return .5-Math.cos(e*Math.PI)/2},_default:"swing"},o.fx=Qe.prototype.init,o.fx.step={};var er,Dr,Kr=/^(?:toggle|show|hide)$/,Gn=/queueHooks$/;function Zr(){Dr&&(K.hidden===!1&&l.requestAnimationFrame?l.requestAnimationFrame(Zr):l.setTimeout(Zr,o.fx.interval),o.fx.tick())}function p(){return l.setTimeout(function(){er=void 0}),er=Date.now()}function S(e,i){var n,s=0,c={height:e};for(i=i?1:0;s<4;s+=2-i)n=wt[s],c["margin"+n]=c["padding"+n]=e;return i&&(c.opacity=c.width=e),c}function v(e,i,n){for(var s,c=(_.tweeners[i]||[]).concat(_.tweeners["*"]),f=0,h=c.length;f<h;f++)if(s=c[f].call(n,i,e))return s}function C(e,i,n){var s,c,f,h,E,x,D,R,U="width"in i||"height"in i,F=this,I={},ie=e.style,ve=e.nodeType&&lr(e),re=le.get(e,"fxshow");n.queue||(h=o._queueHooks(e,"fx"),h.unqueued==null&&(h.unqueued=0,E=h.empty.fire,h.empty.fire=function(){h.unqueued||E()}),h.unqueued++,F.always(function(){F.always(function(){h.unqueued--,o.queue(e,"fx").length||h.empty.fire()})}));for(s in i)if(c=i[s],Kr.test(c)){if(delete i[s],f=f||c==="toggle",c===(ve?"hide":"show"))if(c==="show"&&re&&re[s]!==void 0)ve=!0;else continue;I[s]=re&&re[s]||o.style(e,s)}if(x=!o.isEmptyObject(i),!(!x&&o.isEmptyObject(I))){U&&e.nodeType===1&&(n.overflow=[ie.overflow,ie.overflowX,ie.overflowY],D=re&&re.display,D==null&&(D=le.get(e,"display")),R=o.css(e,"display"),R==="none"&&(D?R=D:(Bt([e],!0),D=e.style.display||D,R=o.css(e,"display"),Bt([e]))),(R==="inline"||R==="inline-block"&&D!=null)&&o.css(e,"float")==="none"&&(x||(F.done(function(){ie.display=D}),D==null&&(R=ie.display,D=R==="none"?"":R)),ie.display="inline-block")),n.overflow&&(ie.overflow="hidden",F.always(function(){ie.overflow=n.overflow[0],ie.overflowX=n.overflow[1],ie.overflowY=n.overflow[2]})),x=!1;for(s in I)x||(re?"hidden"in re&&(ve=re.hidden):re=le.access(e,"fxshow",{display:D}),f&&(re.hidden=!ve),ve&&Bt([e],!0),F.done(function(){ve||Bt([e]),le.remove(e,"fxshow");for(s in I)o.style(e,s,I[s])})),x=v(ve?re[s]:0,s,F),s in re||(re[s]=x.start,ve&&(x.end=x.start,x.start=0))}}function k(e,i){var n,s,c,f,h;for(n in e)if(s=xt(n),c=i[s],f=e[n],Array.isArray(f)&&(c=f[1],f=e[n]=f[0]),n!==s&&(e[s]=f,delete e[n]),h=o.cssHooks[s],h&&"expand"in h){f=h.expand(f),delete e[s];for(n in f)n in e||(e[n]=f[n],i[n]=c)}else i[s]=c}function _(e,i,n){var s,c,f=0,h=_.prefilters.length,E=o.Deferred().always(function(){delete x.elem}),x=function(){if(c)return!1;for(var U=er||p(),F=Math.max(0,D.startTime+D.duration-U),I=F/D.duration||0,ie=1-I,ve=0,re=D.tweens.length;ve<re;ve++)D.tweens[ve].run(ie);return E.notifyWith(e,[D,ie,F]),ie<1&&re?F:(re||E.notifyWith(e,[D,1,0]),E.resolveWith(e,[D]),!1)},D=E.promise({elem:e,props:o.extend({},i),opts:o.extend(!0,{specialEasing:{},easing:o.easing._default},n),originalProperties:i,originalOptions:n,startTime:er||p(),duration:n.duration,tweens:[],createTween:function(U,F){var I=o.Tween(e,D.opts,U,F,D.opts.specialEasing[U]||D.opts.easing);return D.tweens.push(I),I},stop:function(U){var F=0,I=U?D.tweens.length:0;if(c)return this;for(c=!0;F<I;F++)D.tweens[F].run(1);return U?(E.notifyWith(e,[D,1,0]),E.resolveWith(e,[D,U])):E.rejectWith(e,[D,U]),this}}),R=D.props;for(k(R,D.opts.specialEasing);f<h;f++)if(s=_.prefilters[f].call(D,e,R,D.opts),s)return V(s.stop)&&(o._queueHooks(D.elem,D.opts.queue).stop=s.stop.bind(s)),s;return o.map(R,v,D),V(D.opts.start)&&D.opts.start.call(e,D),D.progress(D.opts.progress).done(D.opts.done,D.opts.complete).fail(D.opts.fail).always(D.opts.always),o.fx.timer(o.extend(x,{elem:e,anim:D,queue:D.opts.queue})),D}o.Animation=o.extend(_,{tweeners:{"*":[function(e,i){var n=this.createTween(e,i);return Wr(n.elem,e,$t.exec(i),n),n}]},tweener:function(e,i){V(e)?(i=e,e=["*"]):e=e.match(yt);for(var n,s=0,c=e.length;s<c;s++)n=e[s],_.tweeners[n]=_.tweeners[n]||[],_.tweeners[n].unshift(i)},prefilters:[C],prefilter:function(e,i){i?_.prefilters.unshift(e):_.prefilters.push(e)}}),o.speed=function(e,i,n){var s=e&&typeof e=="object"?o.extend({},e):{complete:n||!n&&i||V(e)&&e,duration:e,easing:n&&i||i&&!V(i)&&i};return o.fx.off?s.duration=0:typeof s.duration!="number"&&(s.duration in o.fx.speeds?s.duration=o.fx.speeds[s.duration]:s.duration=o.fx.speeds._default),(s.queue==null||s.queue===!0)&&(s.queue="fx"),s.old=s.complete,s.complete=function(){V(s.old)&&s.old.call(this),s.queue&&o.dequeue(this,s.queue)},s},o.fn.extend({fadeTo:function(e,i,n,s){return this.filter(lr).css("opacity",0).show().end().animate({opacity:i},e,n,s)},animate:function(e,i,n,s){var c=o.isEmptyObject(e),f=o.speed(i,n,s),h=function(){var E=_(this,o.extend({},e),f);(c||le.get(this,"finish"))&&E.stop(!0)};return h.finish=h,c||f.queue===!1?this.each(h):this.queue(f.queue,h)},stop:function(e,i,n){var s=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=o.timers,E=le.get(this);if(f)E[f]&&E[f].stop&&s(E[f]);else for(f in E)E[f]&&E[f].stop&&Gn.test(f)&&s(E[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)&&o.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var i,n=le.get(this),s=n[e+"queue"],c=n[e+"queueHooks"],f=o.timers,h=s?s.length:0;for(n.finish=!0,o.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++)s[i]&&s[i].finish&&s[i].finish.call(this);delete n.finish})}}),o.each(["toggle","show","hide"],function(e,i){var n=o.fn[i];o.fn[i]=function(s,c,f){return s==null||typeof s=="boolean"?n.apply(this,arguments):this.animate(S(i,!0),s,c,f)}}),o.each({slideDown:S("show"),slideUp:S("hide"),slideToggle:S("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,i){o.fn[e]=function(n,s,c){return this.animate(i,n,s,c)}}),o.timers=[],o.fx.tick=function(){var e,i=0,n=o.timers;for(er=Date.now();i<n.length;i++)e=n[i],!e()&&n[i]===e&&n.splice(i--,1);n.length||o.fx.stop(),er=void 0},o.fx.timer=function(e){o.timers.push(e),o.fx.start()},o.fx.interval=13,o.fx.start=function(){Dr||(Dr=!0,Zr())},o.fx.stop=function(){Dr=null},o.fx.speeds={slow:600,fast:200,_default:400},o.fn.delay=function(e,i){return e=o.fx&&o.fx.speeds[e]||e,i=i||"fx",this.queue(i,function(n,s){var c=l.setTimeout(n,e);s.stop=function(){l.clearTimeout(c)}})},function(){var e=K.createElement("input"),i=K.createElement("select"),n=i.appendChild(K.createElement("option"));e.type="checkbox",H.checkOn=e.value!=="",H.optSelected=n.selected,e=K.createElement("input"),e.value="t",e.type="radio",H.radioValue=e.value==="t"}();var N,B=o.expr.attrHandle;o.fn.extend({attr:function(e,i){return Ct(this,o.attr,e,i,arguments.length>1)},removeAttr:function(e){return this.each(function(){o.removeAttr(this,e)})}}),o.extend({attr:function(e,i,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2)){if(typeof e.getAttribute=="undefined")return o.prop(e,i,n);if((f!==1||!o.isXMLDoc(e))&&(c=o.attrHooks[i.toLowerCase()]||(o.expr.match.bool.test(i)?N:void 0)),n!==void 0){if(n===null){o.removeAttr(e,i);return}return c&&"set"in c&&(s=c.set(e,n,i))!==void 0?s:(e.setAttribute(i,n+""),n)}return c&&"get"in c&&(s=c.get(e,i))!==null?s:(s=o.find.attr(e,i),s==null?void 0:s)}},attrHooks:{type:{set:function(e,i){if(!H.radioValue&&i==="radio"&&Me(e,"input")){var n=e.value;return e.setAttribute("type",i),n&&(e.value=n),i}}}},removeAttr:function(e,i){var n,s=0,c=i&&i.match(yt);if(c&&e.nodeType===1)for(;n=c[s++];)e.removeAttribute(n)}}),N={set:function(e,i,n){return i===!1?o.removeAttr(e,n):e.setAttribute(n,n),n}},o.each(o.expr.match.bool.source.match(/\w+/g),function(e,i){var n=B[i]||o.find.attr;B[i]=function(s,c,f){var h,E,x=c.toLowerCase();return f||(E=B[x],B[x]=h,h=n(s,c,f)!=null?x:null,B[x]=E),h}});var q=/^(?:input|select|textarea|button)$/i,G=/^(?:a|area)$/i;o.fn.extend({prop:function(e,i){return Ct(this,o.prop,e,i,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[o.propFix[e]||e]})}}),o.extend({prop:function(e,i,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2))return(f!==1||!o.isXMLDoc(e))&&(i=o.propFix[i]||i,c=o.propHooks[i]),n!==void 0?c&&"set"in c&&(s=c.set(e,n,i))!==void 0?s:e[i]=n:c&&"get"in c&&(s=c.get(e,i))!==null?s:e[i]},propHooks:{tabIndex:{get:function(e){var i=o.find.attr(e,"tabindex");return i?parseInt(i,10):q.test(e.nodeName)||G.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),H.optSelected||(o.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)}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});function Y(e){var i=e.match(yt)||[];return i.join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ye(e){return Array.isArray(e)?e:typeof e=="string"?e.match(yt)||[]:[]}o.fn.extend({addClass:function(e){var i,n,s,c,f,h;return V(e)?this.each(function(E){o(this).addClass(e.call(this,E,Z(this)))}):(i=ye(e),i.length?this.each(function(){if(s=Z(this),n=this.nodeType===1&&" "+Y(s)+" ",n){for(f=0;f<i.length;f++)c=i[f],n.indexOf(" "+c+" ")<0&&(n+=c+" ");h=Y(n),s!==h&&this.setAttribute("class",h)}}):this)},removeClass:function(e){var i,n,s,c,f,h;return V(e)?this.each(function(E){o(this).removeClass(e.call(this,E,Z(this)))}):arguments.length?(i=ye(e),i.length?this.each(function(){if(s=Z(this),n=this.nodeType===1&&" "+Y(s)+" ",n){for(f=0;f<i.length;f++)for(c=i[f];n.indexOf(" "+c+" ")>-1;)n=n.replace(" "+c+" "," ");h=Y(n),s!==h&&this.setAttribute("class",h)}}):this):this.attr("class","")},toggleClass:function(e,i){var n,s,c,f,h=typeof e,E=h==="string"||Array.isArray(e);return V(e)?this.each(function(x){o(this).toggleClass(e.call(this,x,Z(this),i),i)}):typeof i=="boolean"&&E?i?this.addClass(e):this.removeClass(e):(n=ye(e),this.each(function(){if(E)for(f=o(this),c=0;c<n.length;c++)s=n[c],f.hasClass(s)?f.removeClass(s):f.addClass(s);else(e===void 0||h==="boolean")&&(s=Z(this),s&&le.set(this,"__className__",s),this.setAttribute&&this.setAttribute("class",s||e===!1?"":le.get(this,"__className__")||""))}))},hasClass:function(e){var i,n,s=0;for(i=" "+e+" ";n=this[s++];)if(n.nodeType===1&&(" "+Y(Z(n))+" ").indexOf(i)>-1)return!0;return!1}});var ke=/\r/g;o.fn.extend({val:function(e){var i,n,s,c=this[0];return arguments.length?(s=V(e),this.each(function(f){var h;this.nodeType===1&&(s?h=e.call(this,f,o(this).val()):h=e,h==null?h="":typeof h=="number"?h+="":Array.isArray(h)&&(h=o.map(h,function(E){return E==null?"":E+""})),i=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],(!i||!("set"in i)||i.set(this,h,"value")===void 0)&&(this.value=h))})):c?(i=o.valHooks[c.type]||o.valHooks[c.nodeName.toLowerCase()],i&&"get"in i&&(n=i.get(c,"value"))!==void 0?n:(n=c.value,typeof n=="string"?n.replace(ke,""):n==null?"":n)):void 0}}),o.extend({valHooks:{option:{get:function(e){var i=o.find.attr(e,"value");return i!=null?i:Y(o.text(e))}},select:{get:function(e){var i,n,s,c=e.options,f=e.selectedIndex,h=e.type==="select-one",E=h?null:[],x=h?f+1:c.length;for(f<0?s=x:s=h?f:0;s<x;s++)if(n=c[s],(n.selected||s===f)&&!n.disabled&&(!n.parentNode.disabled||!Me(n.parentNode,"optgroup"))){if(i=o(n).val(),h)return i;E.push(i)}return E},set:function(e,i){for(var n,s,c=e.options,f=o.makeArray(i),h=c.length;h--;)s=c[h],(s.selected=o.inArray(o.valHooks.option.get(s),f)>-1)&&(n=!0);return n||(e.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(e,i){if(Array.isArray(i))return e.checked=o.inArray(o(e).val(),i)>-1}},H.checkOn||(o.valHooks[this].get=function(e){return e.getAttribute("value")===null?"on":e.value})}),H.focusin="onfocusin"in l;var Pe=/^(?:focusinfocus|focusoutblur)$/,We=function(e){e.stopPropagation()};o.extend(o.event,{trigger:function(e,i,n,s){var c,f,h,E,x,D,R,U,F=[n||K],I=W.call(e,"type")?e.type:e,ie=W.call(e,"namespace")?e.namespace.split("."):[];if(f=U=h=n=n||K,!(n.nodeType===3||n.nodeType===8)&&!Pe.test(I+o.event.triggered)&&(I.indexOf(".")>-1&&(ie=I.split("."),I=ie.shift(),ie.sort()),x=I.indexOf(":")<0&&"on"+I,e=e[o.expando]?e:new o.Event(I,typeof e=="object"&&e),e.isTrigger=s?2:3,e.namespace=ie.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+ie.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),i=i==null?[e]:o.makeArray(i,[e]),R=o.event.special[I]||{},!(!s&&R.trigger&&R.trigger.apply(n,i)===!1))){if(!s&&!R.noBubble&&!he(n)){for(E=R.delegateType||I,Pe.test(E+I)||(f=f.parentNode);f;f=f.parentNode)F.push(f),h=f;h===(n.ownerDocument||K)&&F.push(h.defaultView||h.parentWindow||l)}for(c=0;(f=F[c++])&&!e.isPropagationStopped();)U=f,e.type=c>1?E:R.bindType||I,D=(le.get(f,"events")||Object.create(null))[e.type]&&le.get(f,"handle"),D&&D.apply(f,i),D=x&&f[x],D&&D.apply&&sr(f)&&(e.result=D.apply(f,i),e.result===!1&&e.preventDefault());return e.type=I,!s&&!e.isDefaultPrevented()&&(!R._default||R._default.apply(F.pop(),i)===!1)&&sr(n)&&x&&V(n[I])&&!he(n)&&(h=n[x],h&&(n[x]=null),o.event.triggered=I,e.isPropagationStopped()&&U.addEventListener(I,We),n[I](),e.isPropagationStopped()&&U.removeEventListener(I,We),o.event.triggered=void 0,h&&(n[x]=h)),e.result}},simulate:function(e,i,n){var s=o.extend(new o.Event,n,{type:e,isSimulated:!0});o.event.trigger(s,null,i)}}),o.fn.extend({trigger:function(e,i){return this.each(function(){o.event.trigger(e,i,this)})},triggerHandler:function(e,i){var n=this[0];if(n)return o.event.trigger(e,i,n,!0)}}),H.focusin||o.each({focus:"focusin",blur:"focusout"},function(e,i){var n=function(s){o.event.simulate(i,s.target,o.event.fix(s))};o.event.special[i]={setup:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,i);c||s.addEventListener(e,n,!0),le.access(s,i,(c||0)+1)},teardown:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,i)-1;c?le.access(s,i,c):(s.removeEventListener(e,n,!0),le.remove(s,i))}}});var Fe=l.location,st={guid:Date.now()},Ht=/\?/;o.parseXML=function(e){var i,n;if(!e||typeof e!="string")return null;try{i=new l.DOMParser().parseFromString(e,"text/xml")}catch(s){}return n=i&&i.getElementsByTagName("parsererror")[0],(!i||n)&&o.error("Invalid XML: "+(n?o.map(n.childNodes,function(s){return s.textContent}).join(`
`):e)),i};var ei=/\[\]$/,qi=/\r?\n/g,ti=/^(?:submit|button|image|reset|file)$/i,us=/^(?:input|select|textarea|keygen)/i;function ri(e,i,n,s){var c;if(Array.isArray(i))o.each(i,function(f,h){n||ei.test(e)?s(e,h):ri(e+"["+(typeof h=="object"&&h!=null?f:"")+"]",h,n,s)});else if(!n&&be(i)==="object")for(c in i)ri(e+"["+c+"]",i[c],n,s);else s(e,i)}o.param=function(e,i){var n,s=[],c=function(f,h){var E=V(h)?h():h;s[s.length]=encodeURIComponent(f)+"="+encodeURIComponent(E==null?"":E)};if(e==null)return"";if(Array.isArray(e)||e.jquery&&!o.isPlainObject(e))o.each(e,function(){c(this.name,this.value)});else for(n in e)ri(n,e[n],i,c);return s.join("&")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=o.prop(this,"elements");return e?o.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!o(this).is(":disabled")&&us.test(this.nodeName)&&!ti.test(e)&&(this.checked||!Kt.test(e))}).map(function(e,i){var n=o(this).val();return n==null?null:Array.isArray(n)?o.map(n,function(s){return{name:i.name,value:s.replace(qi,`\r
`)}}):{name:i.name,value:n.replace(qi,`\r
`)}}).get()}});var Yn=/%20/g,Gi=/#.*$/,Ro=/([?&])_=[^&]*/,Io=/^(.*?):[ \t]*([^\r\n]*)$/mg,Mo=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,No=/^(?:GET|HEAD)$/,Oo=/^\/\//,cs={},Xn={},fs="*/".concat("*"),Qn=K.createElement("a");Qn.href=Fe.href;function ds(e){return function(i,n){typeof i!="string"&&(n=i,i="*");var s,c=0,f=i.toLowerCase().match(yt)||[];if(V(n))for(;s=f[c++];)s[0]==="+"?(s=s.slice(1)||"*",(e[s]=e[s]||[]).unshift(n)):(e[s]=e[s]||[]).push(n)}}function hs(e,i,n,s){var c={},f=e===Xn;function h(E){var x;return c[E]=!0,o.each(e[E]||[],function(D,R){var U=R(i,n,s);if(typeof U=="string"&&!f&&!c[U])return i.dataTypes.unshift(U),h(U),!1;if(f)return!(x=U)}),x}return h(i.dataTypes[0])||!c["*"]&&h("*")}function Jn(e,i){var n,s,c=o.ajaxSettings.flatOptions||{};for(n in i)i[n]!==void 0&&((c[n]?e:s||(s={}))[n]=i[n]);return s&&o.extend(!0,e,s),e}function $o(e,i,n){for(var s,c,f,h,E=e.contents,x=e.dataTypes;x[0]==="*";)x.shift(),s===void 0&&(s=e.mimeType||i.getResponseHeader("Content-Type"));if(s){for(c in E)if(E[c]&&E[c].test(s)){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 Wo(e,i,n,s){var c,f,h,E,x,D={},R=e.dataTypes.slice();if(R[1])for(h in e.converters)D[h.toLowerCase()]=e.converters[h];for(f=R.shift();f;)if(e.responseFields[f]&&(n[e.responseFields[f]]=i),!x&&s&&e.dataFilter&&(i=e.dataFilter(i,e.dataType)),x=f,f=R.shift(),f){if(f==="*")f=x;else if(x!=="*"&&x!==f){if(h=D[x+" "+f]||D["* "+f],!h){for(c in D)if(E=c.split(" "),E[1]===f&&(h=D[x+" "+E[0]]||D["* "+E[0]],h)){h===!0?h=D[c]:D[c]!==!0&&(f=E[0],R.unshift(E[1]));break}}if(h!==!0)if(h&&e.throws)i=h(i);else try{i=h(i)}catch(U){return{state:"parsererror",error:h?U:"No conversion from "+x+" to "+f}}}}return{state:"success",data:i}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fe.href,type:"GET",isLocal:Mo.test(Fe.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":fs,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":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,i){return i?Jn(Jn(e,o.ajaxSettings),i):Jn(o.ajaxSettings,e)},ajaxPrefilter:ds(cs),ajaxTransport:ds(Xn),ajax:function(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};var n,s,c,f,h,E,x,D,R,U,F=o.ajaxSetup({},i),I=F.context||F,ie=F.context&&(I.nodeType||I.jquery)?o(I):o.event,ve=o.Deferred(),re=o.Callbacks("once memory"),qe=F.statusCode||{},Ve={},ht={},De="canceled",me={readyState:0,getResponseHeader:function(Te){var Be;if(x){if(!f)for(f={};Be=Io.exec(c);)f[Be[1].toLowerCase()+" "]=(f[Be[1].toLowerCase()+" "]||[]).concat(Be[2]);Be=f[Te.toLowerCase()+" "]}return Be==null?null:Be.join(", ")},getAllResponseHeaders:function(){return x?c:null},setRequestHeader:function(Te,Be){return x==null&&(Te=ht[Te.toLowerCase()]=ht[Te.toLowerCase()]||Te,Ve[Te]=Be),this},overrideMimeType:function(Te){return x==null&&(F.mimeType=Te),this},statusCode:function(Te){var Be;if(Te)if(x)me.always(Te[me.status]);else for(Be in Te)qe[Be]=[qe[Be],Te[Be]];return this},abort:function(Te){var Be=Te||De;return n&&n.abort(Be),ut(0,Be),this}};if(ve.promise(me),F.url=((e||F.url||Fe.href)+"").replace(Oo,Fe.protocol+"//"),F.type=i.method||i.type||F.method||F.type,F.dataTypes=(F.dataType||"*").toLowerCase().match(yt)||[""],F.crossDomain==null){E=K.createElement("a");try{E.href=F.url,E.href=E.href,F.crossDomain=Qn.protocol+"//"+Qn.host!=E.protocol+"//"+E.host}catch(Te){F.crossDomain=!0}}if(F.data&&F.processData&&typeof F.data!="string"&&(F.data=o.param(F.data,F.traditional)),hs(cs,F,i,me),x)return me;D=o.event&&F.global,D&&o.active++==0&&o.event.trigger("ajaxStart"),F.type=F.type.toUpperCase(),F.hasContent=!No.test(F.type),s=F.url.replace(Gi,""),F.hasContent?F.data&&F.processData&&(F.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(F.data=F.data.replace(Yn,"+")):(U=F.url.slice(s.length),F.data&&(F.processData||typeof F.data=="string")&&(s+=(Ht.test(s)?"&":"?")+F.data,delete F.data),F.cache===!1&&(s=s.replace(Ro,"$1"),U=(Ht.test(s)?"&":"?")+"_="+st.guid+++U),F.url=s+U),F.ifModified&&(o.lastModified[s]&&me.setRequestHeader("If-Modified-Since",o.lastModified[s]),o.etag[s]&&me.setRequestHeader("If-None-Match",o.etag[s])),(F.data&&F.hasContent&&F.contentType!==!1||i.contentType)&&me.setRequestHeader("Content-Type",F.contentType),me.setRequestHeader("Accept",F.dataTypes[0]&&F.accepts[F.dataTypes[0]]?F.accepts[F.dataTypes[0]]+(F.dataTypes[0]!=="*"?", "+fs+"; q=0.01":""):F.accepts["*"]);for(R in F.headers)me.setRequestHeader(R,F.headers[R]);if(F.beforeSend&&(F.beforeSend.call(I,me,F)===!1||x))return me.abort();if(De="abort",re.add(F.complete),me.done(F.success),me.fail(F.error),n=hs(Xn,F,i,me),!n)ut(-1,"No Transport");else{if(me.readyState=1,D&&ie.trigger("ajaxSend",[me,F]),x)return me;F.async&&F.timeout>0&&(h=l.setTimeout(function(){me.abort("timeout")},F.timeout));try{x=!1,n.send(Ve,ut)}catch(Te){if(x)throw Te;ut(-1,Te)}}function ut(Te,Be,ni,Yi){var pt,dr,hr,ct,tr,Et=Be;x||(x=!0,h&&l.clearTimeout(h),n=void 0,c=Yi||"",me.readyState=Te>0?4:0,pt=Te>=200&&Te<300||Te===304,ni&&(ct=$o(F,me,ni)),!pt&&o.inArray("script",F.dataTypes)>-1&&o.inArray("json",F.dataTypes)<0&&(F.converters["text script"]=function(){}),ct=Wo(F,ct,me,pt),pt?(F.ifModified&&(tr=me.getResponseHeader("Last-Modified"),tr&&(o.lastModified[s]=tr),tr=me.getResponseHeader("etag"),tr&&(o.etag[s]=tr)),Te===204||F.type==="HEAD"?Et="nocontent":Te===304?Et="notmodified":(Et=ct.state,dr=ct.data,hr=ct.error,pt=!hr)):(hr=Et,(Te||!Et)&&(Et="error",Te<0&&(Te=0))),me.status=Te,me.statusText=(Be||Et)+"",pt?ve.resolveWith(I,[dr,Et,me]):ve.rejectWith(I,[me,Et,hr]),me.statusCode(qe),qe=void 0,D&&ie.trigger(pt?"ajaxSuccess":"ajaxError",[me,F,pt?dr:hr]),re.fireWith(I,[me,Et]),D&&(ie.trigger("ajaxComplete",[me,F]),--o.active||o.event.trigger("ajaxStop")))}return me},getJSON:function(e,i,n){return o.get(e,i,n,"json")},getScript:function(e,i){return o.get(e,void 0,i,"script")}}),o.each(["get","post"],function(e,i){o[i]=function(n,s,c,f){return V(s)&&(f=f||c,c=s,s=void 0),o.ajax(o.extend({url:n,type:i,dataType:f,data:s,success:c},o.isPlainObject(n)&&n))}}),o.ajaxPrefilter(function(e){var i;for(i in e.headers)i.toLowerCase()==="content-type"&&(e.contentType=e.headers[i]||"")}),o._evalUrl=function(e,i,n){return o.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(s){o.globalEval(s,i,n)}})},o.fn.extend({wrapAll:function(e){var i;return this[0]&&(V(e)&&(e=e.call(this[0])),i=o(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 V(e)?this.each(function(i){o(this).wrapInner(e.call(this,i))}):this.each(function(){var i=o(this),n=i.contents();n.length?n.wrapAll(e):i.append(e)})},wrap:function(e){var i=V(e);return this.each(function(n){o(this).wrapAll(i?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){o(this).replaceWith(this.childNodes)}),this}}),o.expr.pseudos.hidden=function(e){return!o.expr.pseudos.visible(e)},o.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},o.ajaxSettings.xhr=function(){try{return new l.XMLHttpRequest}catch(e){}};var Bo={0:200,1223:204},ii=o.ajaxSettings.xhr();H.cors=!!ii&&"withCredentials"in ii,H.ajax=ii=!!ii,o.ajaxTransport(function(e){var i,n;if(H.cors||ii&&!e.crossDomain)return{send:function(s,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&&!s["X-Requested-With"]&&(s["X-Requested-With"]="XMLHttpRequest");for(f in s)h.setRequestHeader(f,s[f]);i=function(E){return function(){i&&(i=n=h.onload=h.onerror=h.onabort=h.ontimeout=h.onreadystatechange=null,E==="abort"?h.abort():E==="error"?typeof h.status!="number"?c(0,"error"):c(h.status,h.statusText):c(Bo[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&&l.setTimeout(function(){i&&n()})},i=i("abort");try{h.send(e.hasContent&&e.data||null)}catch(E){if(i)throw E}},abort:function(){i&&i()}}}),o.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),o.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 o.globalEval(e),e}}}),o.ajaxPrefilter("script",function(e){e.cache===void 0&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),o.ajaxTransport("script",function(e){if(e.crossDomain||e.scriptAttrs){var i,n;return{send:function(s,c){i=o("<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)}),K.head.appendChild(i[0])},abort:function(){n&&n()}}}});var ps=[],Kn=/(=)\?(?=&|$)|\?\?/;o.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=ps.pop()||o.expando+"_"+st.guid++;return this[e]=!0,e}}),o.ajaxPrefilter("json jsonp",function(e,i,n){var s,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 s=e.jsonpCallback=V(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,h?e[h]=e[h].replace(Kn,"$1"+s):e.jsonp!==!1&&(e.url+=(Ht.test(e.url)?"&":"?")+e.jsonp+"="+s),e.converters["script json"]=function(){return f||o.error(s+" was not called"),f[0]},e.dataTypes[0]="json",c=l[s],l[s]=function(){f=arguments},n.always(function(){c===void 0?o(l).removeProp(s):l[s]=c,e[s]&&(e.jsonpCallback=i.jsonpCallback,ps.push(s)),f&&V(c)&&c(f[0]),f=c=void 0}),"script"}),H.createHTMLDocument=function(){var e=K.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",e.childNodes.length===2}(),o.parseHTML=function(e,i,n){if(typeof e!="string")return[];typeof i=="boolean"&&(n=i,i=!1);var s,c,f;return i||(H.createHTMLDocument?(i=K.implementation.createHTMLDocument(""),s=i.createElement("base"),s.href=K.location.href,i.head.appendChild(s)):i=K),c=nt.exec(e),f=!n&&[],c?[i.createElement(c[1])]:(c=Vr([e],i,f),f&&f.length&&o(f).remove(),o.merge([],c.childNodes))},o.fn.load=function(e,i,n){var s,c,f,h=this,E=e.indexOf(" ");return E>-1&&(s=Y(e.slice(E)),e=e.slice(0,E)),V(i)?(n=i,i=void 0):i&&typeof i=="object"&&(c="POST"),h.length>0&&o.ajax({url:e,type:c||"GET",dataType:"html",data:i}).done(function(x){f=arguments,h.html(s?o("<div>").append(o.parseHTML(x)).find(s):x)}).always(n&&function(x,D){h.each(function(){n.apply(this,f||[x.responseText,D,x])})}),this},o.expr.pseudos.animated=function(e){return o.grep(o.timers,function(i){return e===i.elem}).length},o.offset={setOffset:function(e,i,n){var s,c,f,h,E,x,D,R=o.css(e,"position"),U=o(e),F={};R==="static"&&(e.style.position="relative"),E=U.offset(),f=o.css(e,"top"),x=o.css(e,"left"),D=(R==="absolute"||R==="fixed")&&(f+x).indexOf("auto")>-1,D?(s=U.position(),h=s.top,c=s.left):(h=parseFloat(f)||0,c=parseFloat(x)||0),V(i)&&(i=i.call(e,n,o.extend({},E))),i.top!=null&&(F.top=i.top-E.top+h),i.left!=null&&(F.left=i.left-E.left+c),"using"in i?i.using.call(e,F):U.css(F)}},o.fn.extend({offset:function(e){if(arguments.length)return e===void 0?this:this.each(function(c){o.offset.setOffset(this,e,c)});var i,n,s=this[0];if(!!s)return s.getClientRects().length?(i=s.getBoundingClientRect(),n=s.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,s=this[0],c={top:0,left:0};if(o.css(s,"position")==="fixed")i=s.getBoundingClientRect();else{for(i=this.offset(),n=s.ownerDocument,e=s.offsetParent||n.documentElement;e&&(e===n.body||e===n.documentElement)&&o.css(e,"position")==="static";)e=e.parentNode;e&&e!==s&&e.nodeType===1&&(c=o(e).offset(),c.top+=o.css(e,"borderTopWidth",!0),c.left+=o.css(e,"borderLeftWidth",!0))}return{top:i.top-c.top-o.css(s,"marginTop",!0),left:i.left-c.left-o.css(s,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&o.css(e,"position")==="static";)e=e.offsetParent;return e||Lt})}}),o.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,i){var n=i==="pageYOffset";o.fn[e]=function(s){return Ct(this,function(c,f,h){var E;if(he(c)?E=c:c.nodeType===9&&(E=c.defaultView),h===void 0)return E?E[i]:c[f];E?E.scrollTo(n?E.pageXOffset:h,n?h:E.pageYOffset):c[f]=h},e,s,arguments.length)}}),o.each(["top","left"],function(e,i){o.cssHooks[i]=Ui(H.pixelPosition,function(n,s){if(s)return s=ur(n,i),Gr.test(s)?o(n).position()[i]+"px":s})}),o.each({Height:"height",Width:"width"},function(e,i){o.each({padding:"inner"+e,content:i,"":"outer"+e},function(n,s){o.fn[s]=function(c,f){var h=arguments.length&&(n||typeof c!="boolean"),E=n||(c===!0||f===!0?"margin":"border");return Ct(this,function(x,D,R){var U;return he(x)?s.indexOf("outer")===0?x["inner"+e]:x.document.documentElement["client"+e]:x.nodeType===9?(U=x.documentElement,Math.max(x.body["scroll"+e],U["scroll"+e],x.body["offset"+e],U["offset"+e],U["client"+e])):R===void 0?o.css(x,D,E):o.style(x,D,R,E)},i,h?c:void 0,h)}})}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,i){o.fn[i]=function(n){return this.on(i,n)}}),o.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,s){return this.on(i,e,n,s)},undelegate:function(e,i,n){return arguments.length===1?this.off(e,"**"):this.off(i,e||"**",n)},hover:function(e,i){return this.mouseenter(e).mouseleave(i||e)}}),o.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){o.fn[i]=function(n,s){return arguments.length>0?this.on(i,null,n,s):this.trigger(i)}});var Uo=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;o.proxy=function(e,i){var n,s,c;if(typeof i=="string"&&(n=e[i],i=e,e=n),!!V(e))return s=u.call(arguments,2),c=function(){return e.apply(i||this,s.concat(u.call(arguments)))},c.guid=e.guid=e.guid||o.guid++,c},o.holdReady=function(e){e?o.readyWait++:o.ready(!0)},o.isArray=Array.isArray,o.parseJSON=JSON.parse,o.nodeName=Me,o.isFunction=V,o.isWindow=he,o.camelCase=xt,o.type=be,o.now=Date.now,o.isNumeric=function(e){var i=o.type(e);return(i==="number"||i==="string")&&!isNaN(e-parseFloat(e))},o.trim=function(e){return e==null?"":(e+"").replace(Uo,"$1")},typeof define=="function"&&define.amd&&define("jquery",[],function(){return o});var jo=l.jQuery,Ho=l.$;return o.noConflict=function(e){return l.$===o&&(l.$=Ho),e&&l.jQuery===o&&(l.jQuery=jo),o},typeof t=="undefined"&&(l.jQuery=l.$=o),o})});var Ga=oa(ma());var un=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 u=this.offset2loc[t];if(u)return u;t--}return null}lineCount(){return this.lines.length}};function $s(l){return"errors"in l}function Ws(l){return"output"in l}var Bs=oa(ma()),va=class{constructor(t){this.preset_id=vt(t)}async getRemoteFile(t){return new Promise((r,a)=>sn(t,r,vr(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 fi=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)}},ba=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 ya=class{constructor(t,r,a,u){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=u,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&&Ws(t)?this.processBuildResult(t):$s(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=la(this.mainPath);a.length>0&&a!="local"&&t.push(a+"/"+r)}parseIncludeDependencies(t){let r=[],a;if(this.platform_id.startsWith("verilog")){let u=/^\s*(`include|[.]include)\s+"(.+?)"/gmi;for(;a=u.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 m=/^\s*([.]arch)\s+(\w+)/gmi;for(;a=m.exec(t);)this.pushAllFiles(r,a[2]+".json");let b=/\$readmem[bh]\("(.+?)"/gmi;for(;a=b.exec(t);)this.pushAllFiles(r,a[1])}else{let u=/^\s*[.#%]?(include|incbin|embed)\s+"(.+?)"/gmi;for(;a=u.exec(t);)this.pushAllFiles(r,a[2]);let d=/^\s*([;']|[/][/])#(resource)\s+"(.+?)"/gm;for(;a=d.exec(t);)this.pushAllFiles(r,a[3]);let m=/^\s+(USE|ASM)\s+(\S+[.]\S+)/gm;for(;a=m.exec(t);)this.pushAllFiles(r,a[2]);let b=/^\s*(import|embed)\s*"(.+?)";/gmi;for(;a=b.exec(t);)a[1]=="import"?this.pushAllFiles(r,a[2]+".wiz"):this.pushAllFiles(r,a[2]);let y=/^\s*(import)\s*"(.+?)"/gmi;for(;a=y.exec(t);)this.pushAllFiles(r,a[2]);let L=/^[!]src\s+"(.+?)"/gmi;for(;a=L.exec(t);)this.pushAllFiles(r,a[1])}return r}parseLinkDependencies(t){let r=[],a;if(!this.platform_id.startsWith("verilog")){let u=/^\s*([;]|[/][/])#link\s+"(.+?)"/gm;for(;a=u.exec(t);)this.pushAllFiles(r,a[2])}return r}loadFileDependencies(t){let r=this.parseIncludeDependencies(t),a=this.parseLinkDependencies(t),u=r.concat(a);return this.loadFiles(u).then(d=>{if(d)for(let m of d)m.link=a.indexOf(m.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),u=this.getFile(this.mainPath),d=[];r.updates.push({path:a,data:u}),this.filename2path[a]=this.mainPath;let m=this.getToolForFilename(a).startsWith("remote:");for(var b of t)(!b.link||m)&&(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=(m,b)=>{r.push({path:m,filename:this.stripLocalPath(m),link:!0,data:b})};for(var u of t)if(u in this.filedata){var d=this.filedata[u];d&&a(u,d)}else{var d=await this.filesystem.getFileData(u);d?(this.filedata[u]=d,a(u,d)):this.filedata[u]=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 u=this.buildWorkerMessage(a);this.worker.postMessage(u),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 un(a.lines,a.text)),a.asmlines&&(a.assemblyfile=new un(a.asmlines,a.text))}}}processBuildResult(t){this.processBuildListings(t),this.processBuildSegments(t)}processBuildSegments(t){var r=this.platform.getMemoryMap&&this.platform.getMemoryMap().main||[];t.segments&&(r=r.concat(t.segments||[])),r.sort((a,u)=>a.start-u.start),this.segments=r}getListings(){return this.listings}getListingForFile(t){var r=ft(this.stripLocalPath(t)),a=this.getListings();for(var u in a)if(u==t)return a[u];for(var u in a)if(ft(u)==r)return a[u]}stripLocalPath(t){if(this.mainPath){var r=la(this.mainPath);r!=""&&t.startsWith(r+"/")&&(t=t.substring(r.length+1))}return t}updateDataItems(t){this.dataItems=t,this.okToSend()&&this.sendBuild()}};function xa(l){var t=Bs.default.createInstance({name:"__"+l,version:2});return t}var wa=js(),Ea=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),wa(a).hide()),r}createOrShow(t,r){var a=this.create(t),u=this.id2div[t];return this.activewnd!=a?(this.activediv&&wa(this.activediv).hide(),this.activewnd&&this.activewnd.setVisible&&this.activewnd.setVisible(!1),this.activediv=u,this.activewnd=a,wa(u).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(u=>{this.updateFile(r,u)})}}findWindowWithFilePrefix(t){t=_t(ft(t));for(var r in this.id2createfn)if(!(r.toLowerCase().endsWith(".h")||r.toLowerCase().endsWith(".inc")||r.toLowerCase().endsWith(".bas"))&&_t(ft(r))==t)return r;return null}};var ol=`$NAME
=====
[Open this project in 8bitworkshop](http://8bitworkshop.com/redir.html?platform=$PLATFORM&githubURL=$GITHUBURL&file=$MAINFILE).
`;function di(){for(var l={},t=0;t<localStorage.length;t++){var r=localStorage.key(t);if(r.startsWith("__repo__")){var a=JSON.parse(localStorage.getItem(r)),u=r.substring("__repo__".length);l[u]=a}}return l}function fn(l){var t=l.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 Sa=class{constructor(t,r,a,u){this.githubCons=t,this.githubToken=r,this.store=a,this.project=u,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=fn(t);if(!r)throw new Error("Please enter a valid GitHub URL.");var a=di()[r.repopath],u=r.branch||a&&a.branch,d=this.github.repos(r.user,r.repo);try{u=(await d.fetch()).defaultBranch||"master"}catch(b){console.log("could not fetch default branch: "+b),u="main"}console.log("branch =",u);var m={url:t,user:r.user,reponame:r.repo,repopath:r.repopath,branch:u,subtreepath:r.subtreepath,prefix:"",repo:d,platform_id:this.project?this.project.platform_id:a?a.platform_id:null};return m}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 u of a.tree)if(u.type=="tree"&&u.path==r.subtreepath&&u.sha)return r.repo.git.trees(u.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 u={url:t.url,branch:t.branch,platform_id:t.platform_id,mainPath:t.mainPath,sha:t.sha};console.log("storing",u),localStorage.setItem(a,JSON.stringify(u))}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(u=>""))).then(a=>{var u;if(u=/8bitworkshop.com[^)]+file=([^)&]+)/.exec(a),u&&u[1]&&(console.log("main path: '"+u[1]+"'"),r.mainPath=u[1]),u=/8bitworkshop.com[^)]+platform=([A-Za-z0-9._\-]+)/.exec(a),u){if(console.log("platform id: '"+u[1]+"'"),r.platform_id&&!r.platform_id.startsWith(u[1]))throw Error("Platform mismatch: Repository is "+u[1]+", you have "+r.platform_id+" selected.");r.platform_id=u[1]}return this.bind(r,!0),r})}pull(t,r){var a;return this.getGithubHEADTree(t).then(u=>{a=u;let d=[];return a.paths=[],a.tree.tree.forEach(m=>{if(console.log(m.path,m.type,m.size),a.paths.push(m.path),m.type=="blob"&&!this.isFileIgnored(m.path)){var b=a.repo.git.blobs(m.sha).fetch().then(y=>{var L=a.prefix+m.path,W=m.size,de=y.encoding,z=y.content;if(y.encoding=="base64"){var H=tn(atob(z)),V=vr(m.path,H);z=V?H:nn(H)}return y.size!=z.length&&(z=z.slice(0,y.size)),(r||this.store).setItem(L,z)});d.push(b)}else console.log("ignoring "+m.path)}),Promise.all(d)}).then(u=>a)}importAndPull(t){return this.import(t).then(r=>this.pull(t))}publish(t,r,a,u){var d,m=this.project.platform_id,b=this.project.stripLocalPath(this.project.mainPath);return this.github.user.repos.create({name:t,description:r,private:u,auto_init:!1,license_template:a}).then(y=>{d=y;var L=ol;L=L.replace(/\$NAME/g,encodeURIComponent(t)),L=L.replace(/\$PLATFORM/g,encodeURIComponent(m)),L=L.replace(/\$GITHUBURL/g,encodeURIComponent(d.htmlUrl)),L=L.replace(/\$MAINFILE/g,encodeURIComponent(b));var W={message:"8bitworkshop: updated metadata in README.md",content:btoa(L)};return d.contents("README.md").add(W)}).then(()=>this.getGithubSession(d.htmlUrl))}commit(t,r,a){var u;return r||(r="updated from 8bitworkshop.com"),this.getGithubHEADTree(t).then(d=>{if(u=d,u.subtreepath)throw Error("Sorry, right now you can only commit files to the root directory of a repository.");return Promise.all(a.map(m=>typeof m.data=="string"?u.repo.git.blobs.create({content:m.data,encoding:"utf-8"}):u.repo.git.blobs.create({content:btoa(rn(m.data)),encoding:"base64"})))}).then(d=>u.repo.git.trees.create({tree:a.map((m,b)=>({path:m.path,mode:"100644",type:"blob",sha:d[b].sha})),base_tree:u.tree.sha})).then(d=>u.repo.git.commits.create({message:r,tree:d.sha,parents:[u.head.object.sha]})).then(d=>u.repo.commits(d.sha).fetch()).then(d=>(u.commit=d,u))}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 hi=window.matchMedia&&window.matchMedia("only screen and (max-width: 760px)").matches;function qt(l,t){var r=$(document.createElement("div"));return l&&r.appendTo(l),t&&r.addClass(t),r}function Hs(l,t){var r=l.charCoords({line:t,ch:0},"local").top,a=l.getScrollerElement().offsetHeight/2;l.scrollTo(null,r-a-5)}function zs(l,t){var r=document.createElement("span");return r.setAttribute("class",t),r.appendChild(document.createTextNode(l)),r}var dn=64,ll=200,_a={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}},Vs={input:null},pi=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=fe.getFile(this.path),u=a&&this.mode=="verilog"&&/__asm\b([\s\S]+?)\b__endasm\b/.test(a);return this.newEditor(r,u),a&&(this.setText(a),this.editor.setSelection({line:0,ch:0},{line:0,ch:0},{scroll:!0})),this.setupEditor(),fe.getToolForFilename(this.path).startsWith("remote:")&&(this.refreshDelayMsec=1e3),r}setVisible(t){t&&this.editor.focus()}newEditor(t,r){var a=_a[this.mode]||_a.default,u=r||a.isAsm,d=!!a.lineWrap,m=a.theme||_a.default.theme,b=!a.noLineNumbers&&!hi;ee.embed&&(b=!1,u=!1);var y=["CodeMirror-linenumbers","gutter-offset","gutter-info"];u&&(y=["CodeMirror-linenumbers","gutter-offset","gutter-bytes","gutter-clock","gutter-info"]),(a.noGutters||hi)&&(y=["gutter-info"]),this.editor=CodeMirror(t,{theme:m,lineNumbers:b,matchBrackets:!0,tabSize:8,indentAuto:!0,lineWrapping:d,gutters:y})}editorChanged(){clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{fe.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)=>{Vs.input&&r.text&&(r.text=r.text.map(Vs.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(A.inspect&&(r=A.inspect(t)),this.inspectWidget&&(this.inspectWidget.clear(),this.inspectWidget=null),r){var a=zs(r,"tooltipinfoline"),u=this.editor.getCursor().line;this.inspectWidget=this.editor.addLineWidget(u,a,{above:!1})}}setText(t){var r,a,u=this.editor.getValue();u!=t&&(this.editor.setValue(t),u==""&&this.editor.clearHistory())}insertText(t){var r=this.editor.getCursor();this.editor.replaceRange(t,r,r)}highlightLines(t,r){var a="hilite-span",u={className:a,inclusiveLeft:!0};this.markHighlight=this.editor.markText({line:t,ch:0},{line:r,ch:0},u),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 u={className:"mark-error",inclusiveLeft:!0},d={line:a,ch:t.end?t.start:t.start-1},m={line:a,ch:t.end?t.end:t.start},b=this.editor.markText(d,m,u);this.errormarks.push(b)}}}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(u=>{this.expandErrors()})}addErrorLine(t,r){var a=zs(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,ll);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,Le(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(A.getOpcodeMetadata){var u=parseInt(r.insns.split(" ")[0],16),d=A.getOpcodeMetadata(u,r.offset);if(d&&d.minCycles){var m=d.minCycles+"";this.setGutter("gutter-clock",r.line-1,m)}}}}}setGutter(t,r,a){var u=this.editor.lineInfo(r);if(!(u&&u.gutterMarkers&&u.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 m=this.sourcefile.line2offset[d],b=t.pc2clockrange[m];var r=b&&b.minclocks,a=b&&b.maxclocks;if(r>=0&&a>=0){var u;a==r?u=r+"":u=r+"-"+a,a==t.MAX_CLOCKS&&(u+="+"),this.setGutterBytes(parseInt(d),u)}}}setCurrentLine(t,r){var a=A.isBlocked&&A.isBlocked(),u=b=>{var y=document.createElement("div"),L=a?"currentpc-marker-blocked":"currentpc-marker";y.classList.add(L),y.appendChild(document.createTextNode("\u25B6")),this.editor.setGutterMarker(b.line-1,"gutter-info",y)};if(this.clearCurrentLine(r),t){u(t),r&&this.editor.setCursor({line:t.line-1,ch:t.start||0},{scroll:!0});var d=a?"currentpc-span-blocked":"currentpc-span",m={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},m):this.markCurrentPC=this.editor.markText({line:t.line-1,ch:0},{line:t.line,ch:0},m),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=ir&&ir.c;if(!t&&A.getCPUState&&!A.isRunning()&&(t=A.getCPUState()),t){var r=t&&(t.EPC||t.PC),a=this.sourcefile.findLineForOffset(r,dn);return a}}}refreshDebugState(t){this.clearCurrentLine(t);var r=this.getActiveLine();r&&this.setCurrentLine(r,t)}refreshListing(){var t=fe.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];gi(r)}}},Ta=1024,hn=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=ir||A.saveState(),a=r.c?r.c.PC:0,u=0,d=0,m=A.debugSymbols&&A.debugSymbols.addr2symbol||{},b=(W,de)=>{let z="",H=0;for(;H<de;){let V=W+H|0,he=A.disassemble(V,A.readAddress.bind(A)),K="",xe="";for(let Se=0;Se<he.nbytes;Se++)K+=Le(A.readAddress(V+Se));for(;K.length<14;)K+=" ";let Ce=he.line;if(m&&he.isaddr&&(Ce=Ce.replace(/([^#])[$]([0-9A-F]+)/,(Se,...o)=>{let X=parseInt(o[1],16),ae=m[X];return ae?o[0]+ae:(ae=m[X-1],ae?o[0]+ae+"+1":Se)})),m){let Se=m[V];Se&&(xe="; "+Se)}z+=Le(V,4)+" "+ui(K,14)+" "+ui(Ce,30)+xe+`
`,V==a&&(d=u),u++,H+=he.nbytes||1}return z};var y=a<0?a-Ta:Math.max(0,a-Ta);let L=b(y,a-y)+b(a,Ta);this.disasmview.setValue(L),t&&this.disasmview.setCursor(d,0),Hs(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}},Ca=class extends hn{constructor(t){super();this.path=t}refreshListing(){var t=fe.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),!!A.saveState){var u=ir||A.saveState(),d=u.c?u.c.EPC||u.c.PC:0;if(d>=0&&this.assemblyfile){var m=this.assemblyfile.findLineForOffset(d,dn);m&&(t&&a.setCursor(m.line-1,0),Hs(a,m.line-1))}}}}};function qs(l){return l.endsWith("_SIZE__")||l.endsWith("_LAST__")||l.endsWith("STACKSIZE__")||l.endsWith("FILEOFFS__")||l.startsWith("l__")||l.startsWith("s__")||l.startsWith(".__.")}var pn=class{constructor(){this.recreateOnResize=!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 As({w:$(t).width(),h:$(t).height(),itemHeight:Ls(),totalRows:this.totalRows,generatorFn:a=>{var u=this.getMemoryLineAt(a),d=document.createElement("div");if(this.dumplines){var m=this.dumplines[a];m&&d.classList.add("seg_"+this.getMemorySegment(this.dumplines[a].a))}return d.appendChild(document.createTextNode(u)),d}}),$(r).append(this.memorylist.container),this.tick(),dt&&this.dumplines&&this.scrollToAddress(dt.data_start)}scrollToAddress(t){this.dumplines&&this.memorylist.scrollToItem(this.findMemoryWindowLine(t))}refresh(){this.dumplines=null,this.tick()}tick(){this.memorylist&&$(this.maindiv).find("[data-index]").each((t,r)=>{var a=$(r),u=parseInt(a.attr("data-index")),d=a.text(),m=this.getMemoryLineAt(u);d!=m&&a.text(m)})}getMemoryLineAt(t){var r=t*16,a=0,u=16,d;if(this.getDumpLines()){var m=this.dumplines[t];if(m)r=m.a&65520,a=m.a-r,u=a+m.l,d=m.s;else return"."}for(var b=Le(r+a,4)+" ",y=0;y<a;y++)b+=" ";a>8&&(b+=" ");for(var y=a;y<u;y++){var L=this.readAddress(r+y);y==8&&(b+=" "),b+=" "+(typeof L=="number"?Le(L,2):"??")}for(var y=u;y<16;y++)b+=" ";return d&&(b+=" "+d),b}readAddress(t){return A.readAddress(t)}getDumpLineAt(t){var r=this.dumplines[t];if(r)return r.a+" "+r.s}getDumpLines(){var t=A.debugSymbols&&A.debugSymbols.addr2symbol||{};if(this.dumplines==null){this.dumplines=[];var r=0,a;for(let b of Object.keys(t)){var u=parseInt(b),d=t[u];if(a)for(qs(a)&&(a="");r<u&&this.dumplines.length<65536;){var m=r+16&1048560;m>u&&(m=u),this.dumplines.push({a:r,l:m-r,s:a}),r=m}a=d}}return this.dumplines}getMemorySegment(t){if(dt){if(t>=dt.data_start&&t<dt.data_start+dt.data_size)return A.getSP&&t>=A.getSP()-15?"stack":"data";if(t>=dt.code_start&&t<dt.code_start+(dt.code_size||dt.rom_size))return"code"}var r=fe.segments;if(r){for(var a of r)if(t>=a.start&&t<a.start+a.size){if(a.type=="rom")return"code";if(a.type=="ram")return"data";if(a.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}},ka=class extends pn{constructor(){super(...arguments);this.totalRows=2048}readAddress(t){return A.readVRAMAddress(t)}getMemorySegment(t){return"video"}getDumpLines(){return null}},Pa=class{constructor(t,r){this.recreateOnResize=!0;this.path=t,this.data=r}createDiv(t){return this.vlist=new ci(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,u=16,d=Le(r+a,4)+" ",m=0;m<a;m++)d+=" ";a>8&&(d+=" ");for(var m=a;m<u;m++){var b=this.data[r+m];m==8&&(d+=" "),d+=" "+(b>=0?Le(b,2):" ")}return{text:d}}refresh(){this.vlist.refresh()}getPath(){return this.path}},Aa=class{createDiv(t){return this.maindiv=qt(t,"vertical-scroll"),this.maindiv.css("display","grid"),this.maindiv.css("grid-template-columns","5em 40% 40%"),this.maindiv[0]}addSegment(t,r){if(r){var a=$('<div class="segment-offset" style="grid-column-start:1"/>');a.text("$"+Le(t.start,4)),this.maindiv.append(a)}var u=$('<div class="segment"/>');if(r||u.css("grid-column-start",3),t.last?u.text(t.name+" ("+(t.last-t.start)+" / "+t.size+" bytes used)"):u.text(t.name+" ("+t.size+" bytes)"),t.size>=256){var d=(Math.log(t.size)-Math.log(256))*.5;u.css("padding-top",d+"em"),u.css("padding-bottom",d+"em")}t.type&&u.addClass("segment-"+t.type),this.maindiv.append(u),u.click(()=>{var m=ge.createOrShow("#memory");m.scrollToAddress(t.start)})}refresh(){this.maindiv.empty();var t=fe.segments;if(t){var r=0,a=-1;for(var u of t)u.start>r&&this.addSegment({name:"",start:r,size:u.start-r},!0),this.addSegment(u,a!=u.start),a=u.start,r=u.start+u.size}}},Pt=4278190080,br=class{constructor(){this.cumulativeData=!1;var t=160,r=262;try{t=Math.ceil(A.machine.cpuCyclesPerLine)||t,r=Math.ceil(A.machine.numTotalScanlines)||r}catch(a){}this.cyclesPerLine=t,this.totalScanlines=r}addr2symbol(t){var r=A.debugSymbols&&A.debugSymbols.addr2symbol||{};return r[t]}addr2str(t){var r=this.addr2symbol(t);return typeof r=="string"?"$"+Le(t)+" ("+r+")":"$"+Le(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=A.startProbing(),this.probe.singleFrame=!this.cumulativeData,this.tick()):(this.probe&&(this.probe.singleFrame=!0),A.stopProbing(),this.probe=null)}redraw(t){var r=this.probe;if(!(!r||!r.idx)){var a=0,u=0,d=0;this.sp=0;for(var m=0;m<r.idx;m++){var b=r.buf[m],y=b&65535,L=b>>16&255,W=b&Pt;switch(W){case te.SCANLINE:a++,u=0;break;case te.FRAME:a=0,u=0;break;case te.CLOCKS:u+=y,d+=y;break;case te.SP_PUSH:case te.SP_POP:this.sp=y;default:t(W,y,u,a,d,L);break}}}}opToString(t,r,a){var u="";switch(t){case te.EXECUTE:u="Exec";break;case te.MEM_READ:u="Read";break;case te.MEM_WRITE:u="Write";break;case te.IO_READ:u="IO Read";break;case te.IO_WRITE:u="IO Write";break;case te.VRAM_READ:u="VRAM Read";break;case te.VRAM_WRITE:u="VRAM Write";break;case te.DMA_READ:u="DMA Read";break;case te.DMA_WRITE:u="DMA Write";break;case te.INTERRUPT:u="Interrupt";break;case te.ILLEGAL:u="Error";break;case te.WAIT:u="Wait";break;case te.SP_PUSH:u="Stack Push";break;case te.SP_POP:u="Stack Pop";break;default:return""}return typeof r=="number"&&(u+=" "+this.addr2str(r)),t&te.HAS_VALUE&&typeof a=="number"&&(u+=" = $"+Le(a,2)),u}getOpRGB(t,r){switch(t){case te.EXECUTE:return 98305;case te.MEM_READ:return 8388865;case te.MEM_WRITE:return 65920;case te.IO_READ:return 98432;case te.IO_WRITE:return 12583296;case te.DMA_READ:case te.VRAM_READ:return 8421377;case te.DMA_WRITE:case te.VRAM_WRITE:return 4227264;case te.INTERRUPT:return 4177727;case te.ILLEGAL:return 4145151;case te.WAIT:return 16727871;default:return 0}}},Gs=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0}createCanvas(t,r,a){var u=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=m=>{var b=on(d,m);this.showTooltip(this.getTooltipText(b.x,b.y)),$(this.tooldiv).css("left",m.pageX+10).css("top",m.pageY-30)},d.onmouseout=m=>{$(this.tooldiv).hide()},t.appendChild(u),u.appendChild(d),this.canvas=d,this.ctx=d.getContext("2d"),this.initCanvas(),this.maindiv=u}initCanvas(){}getTooltipText(t,r){return null}getOpAtPos(t,r,a){t=t|0,r=r|0;let u=0;return this.redraw((d,m,b,y,L,W)=>{!u&&y==r&&b>=t&&(d&a)!=0&&(u=d|m)}),u}clear(){}tick(){this.clear(),this.redraw(this.drawEvent.bind(this))}},Da=class extends Gs{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="",u=null,d=[],m=-1;return this.redraw((b,y,L,W,de,z)=>{switch(b){case te.EXECUTE:u=this.addr2symbol(y)||u;break;case te.SP_PUSH:d.push(u);break;case te.SP_POP:u=d.pop();break}W==r&&L<=t&&(L!=m&&(a="",m=L),a==""&&u&&(a+=`
`+u),a+=`
`+this.opToString(b,y,z))}),"X: "+t+" Y: "+r+" "+a}refresh(){this.tick(),this.datau32.fill(Pt)}tick(){super.tick(),this.drawImage()}drawImage(){this.ctx.putImageData(this.imageData,0,0)}clear(){this.datau32.fill(Pt)}},La=class extends Da{createDiv(t){return this.createCanvas(t,256,256)}initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var r=on(this.canvas,t),a=Math.floor(r.x)+Math.floor(r.y)*256,u=-1,d=-1;this.redraw((m,b)=>{d<0&&u>=0&&b==a&&(d=u),m==te.EXECUTE&&(u=b)}),d>=0&&gi(d)}}clear(){for(var t=0;t<=65535;t++){var r=A.readAddress(t),a=r>>2|r&31;a|=a<<8|a<<16,this.datau32[t]=a|Pt}}drawEvent(t,r,a,u){var d=this.getOpRGB(t,r);if(!!d){var m=r&255,b=r>>8&255,y=this.datau32[r&65535];y=y|d|Pt,this.datau32[r&65535]=y}}getTooltipText(t,r){var a=(t&255)+(r<<8),u="",d=-1,m={},b=null,y=[];return this.redraw((L,W,de,z,H,V)=>{switch(L){case te.EXECUTE:d=W,b=this.addr2symbol(W)||b;break;case te.SP_PUSH:y.push(b);break;case te.SP_POP:b=y.pop();break}var he=L|d;W==a&&!m[he]&&(u==""&&b&&(u+=`
`+b),u+=`
PC `+this.addr2str(d)+" "+this.opToString(L,null,V),m[he]=1)}),this.addr2str(a)+u}},Ys=class extends Da{initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var r=on(this.canvas,t),a=Math.floor(r.x),u=Math.floor(r.y),d=this.getOpAtPos(r.x,r.y,te.EXECUTE);d&&(It("toline"),A.runEval(()=>{let m=A.getRasterScanline&&A.getRasterScanline()>=u;return m&&A.getRasterLineClock?m&&A.getRasterLineClock()>a:m}))}}drawEvent(t,r,a,u){var d=this.getOpRGB(t,r);if(!!d){var m=a+u*this.canvas.width,b=d|Pt;this.datau32[m]|=b}}drawImage(){let t=Pt;for(let r=0;r<this.datau32.length;r++)this.datau32[r]==Pt?this.datau32[r]=t:t=this.datau32[r];super.drawImage()}},Fa=class extends Ys{constructor(){super(...arguments);this.interrupt=0;this.rgb=0;this.lastpc=0}drawEvent(t,r,a,u){var d=a+u*this.canvas.width;if(t==te.INTERRUPT&&(this.interrupt=1),this.interrupt==1&&t==te.SP_PUSH&&(this.interrupt=r),this.interrupt>1&&this.sp>this.interrupt&&(this.interrupt=0),t==te.MEM_WRITE&&(this.rgb|=47),t==te.VRAM_WRITE&&(this.rgb|=16256),t==te.IO_WRITE&&(this.rgb|=2047872),t==te.IO_READ&&(this.rgb|=7936),t==te.WAIT&&(this.rgb=32768),t==te.ILLEGAL||t==te.DMA_READ)this.datau32[d]=4279176975;else{let m=this.rgb;if(t==te.EXECUTE){let b=this.sp&15;b>=8&&(b=16-b),Math.abs(this.lastpc)-r>16&&(b+=1),Math.abs(this.lastpc)-r>256&&(b+=1),m=this.rgb=526344*b+2105376,this.lastpc=r}this.interrupt&&(m|=8388672),this.datau32[d]==Pt&&(this.datau32[d]=m|Pt)}}},Ra=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new ci(t),this.vlist.create(t,this.cyclesPerLine*this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){var r="",a="seg_data",u=this.dumplines&&this.dumplines[t];if(u!=null){var d=u.info.join(", ");r="("+Ft(u.row,4)+", "+Ft(u.col,4)+") "+ui(u.asm||"",20)+d,d.indexOf("Write ")>=0&&(a="seg_io")}return{text:r,clas:a}}refresh(){this.tick()}tick(){let t=A instanceof ha||A instanceof da;this.dumplines={},this.redraw((r,a,u,d,m,b)=>{t&&(m>>=2);var y=this.dumplines[m];switch(y==null&&(y={op:r,addr:a,row:d,col:u,asm:null,info:[]},this.dumplines[m]=y),r){case te.EXECUTE:if(A.disassemble){var L=A.disassemble(a,A.readAddress.bind(A));y.asm=L&&L.line}break;default:var W=this.opToString(r,a,b);W!=""&&y.info.push(W);break}}),this.vlist.refresh()}},Ia=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new ci(t),this.vlist.create(t,this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){for(var r=Ft(t+"",3)+" ",a="seg_code",u=this.dumplines&&this.dumplines[t]||[],d=Math.round(this.cyclesPerLine/3.3),m=0;m<this.cyclesPerLine;m++){var b=u[m];if(b!==void 0){var y=b&65535,L=L&Pt;if(L==te.EXECUTE)r+=",";else{var W=Le(y);r+=W,m+=W.length-1}}else r+=m==d?"|":"."}return u[-1]&&(r+=" "+u[-1]),{text:r,clas:a}}refresh(){this.tick()}tick(){let t=A instanceof ha||A instanceof da;this.dumplines={},this.redraw((r,a,u,d,m,b)=>{var y=this.dumplines[d];switch(y==null&&(this.dumplines[d]=y=[]),r){case te.EXECUTE:var L=A.debugSymbols.addr2symbol[a];L&&(y[-1]=L);break;case te.IO_READ:case te.IO_WRITE:case te.VRAM_READ:case te.VRAM_WRITE:y[u]=r|a;break}}),this.vlist.refresh()}},Ma=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0;this.cumulativeData=!0}createDiv(t){return A.debugSymbols&&A.debugSymbols.symbolmap?this.keys=Array.from(Object.keys(A.debugSymbols.symbolmap).filter(r=>!qs(r))):this.keys=["no symbols defined"],this.vlist=new ci(t),this.vlist.create(t,this.keys.length+1,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){if(t==0)return{text:Ft("Symbol",35)+Ft("Reads",8)+Ft("Writes",8)};var r=this.keys[t-1],a=this.dumplines&&this.dumplines[r];function u(b){var y=a[b]|0;return Ft(y?y.toString():"",8)}var d,m;return a!=null?(d=Ft(r,35)+u(te.MEM_READ)+u(te.MEM_WRITE),a[te.EXECUTE]?m="seg_code":a[te.IO_READ]||a[te.IO_WRITE]?m="seg_io":m="seg_data"):(d=Ft(r,35),m="seg_unknown"),{text:d,clas:m}}refresh(){this.tick()}tick(){this.dumplines={},this.redraw((t,r,a,u,d,m)=>{var b=A.debugSymbols.addr2symbol[r];if(b!=null){var y=this.dumplines[b];y==null&&(y={},this.dumplines[b]=y),y[t]=(y[t]|0)+1}}),this.vlist.refresh(),this.probe&&this.probe.clear()}};var Vc=Is(),gn=/([0#]?)([x$%]|\d'h)([0-9a-f]+)(?:[;].*)?|(\d'b|0b)([01]+)/gim;function ul(l){return l.replace(/(\shex\s+)([0-9a-f]+)/ig,function(t,r,a){for(var u=r,d=0;d<a.length;d+=2)u+="0x"+a.substr(d,2)+",";return u})}function cl(l){for(var t=[],r;r=gn.exec(l);){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 fl(l,t){for(var r="",a,u=0,d=0;a=gn.exec(l);)r+=l.slice(u,gn.lastIndex-a[0].length),u=gn.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"+Le(t[d++]):a[2].startsWith("$")?r+=a[1]+"$"+Le(t[d++]):r+=a[1]+t[d++].toString();return r+=l.slice(u),r=r.replace(/(\shex\s+)([,x0-9a-f]+)/ig,(m,b,y)=>{var L=b+y;return L=L.replace(/0x/ig,"").replace(/,/ig,""),L}),r}function Xs(l,t){if(!t)return l;for(var r=0,a=0;a<t.length;a++){var u=t[a];u<0&&(u=-u-1,r^=1<<u),l&1<<a&&(r^=1<<u)}return r}function Qs(l,t){var r=t[l%t.length];return[r>>3,r&7]}function dl(l,t){for(var r=t.w,a=t.h,u=t.count||1,d=t.bpp||1,m=t.np||1,b=t.bpw||8,y=t.sl||Math.ceil(r*d/b),L=(1<<d)-1,W=t.pofs||y*a*u,de=t.skip||0,z=t.wpimg||y*a,H=[],V=0;V<u;V++){for(var he=[],K=0;K<a;K++)for(var xe=t.flip?a-1-K:K,Ce=z*V+xe*y,be=0,Se=0;Se<r;Se++){var o=0,X=Xs(Ce,t.remap);t.reindex&&([X,be]=Qs(Se,t.reindex),X+=Ce);for(var ae=0;ae<m;ae++){var oe=l[X+ae*W+de];o|=((t.brev?oe>>b-be-d:oe>>be)&L)<<ae*d}he.push(o),be+=d,be>=b&&!t.reindex&&(Ce+=1,be=0)}H.push(new Uint8Array(he))}return H}function hl(l,t){t.destfmt&&(t=t.destfmt);var r=t.w,a=t.h,u=t.count||1,d=t.bpp||1,m=t.np||1,b=t.bpw||8,y=t.sl||Math.ceil(t.w*d/b),L=(1<<d)-1,W=t.pofs||y*a*u,de=t.skip||0,z=t.wpimg||y*a,H;m>0&&t.sl?H=new Uint8Array(z*u):b<=8?H=new Uint8Array(z*u*m):H=new Uint32Array(z*u*m);for(var V=0;V<u;V++)for(var he=l[V],K=0,xe=0;xe<a;xe++)for(var Ce=t.flip?a-1-xe:xe,be=V*z+Ce*y,Se=0,o=0;o<r;o++){var X=he[K++],ae=Xs(be,t.remap);t.reindex&&([ae,Se]=Qs(o,t.reindex),ae+=be);for(var oe=0;oe<m;oe++){var _e=X>>oe*d&L;H[ae+oe*W+de]|=t.brev?_e<<b-Se-d:_e<<Se}Se+=d,Se>=b&&!t.reindex&&(be+=1,Se=0)}return H}function Js(l,t,r,a,u,d,m){for(var b=[],y=0;y<l.length;y++){var L=l[y],W=4278190080;W|=(L>>t&(1<<r)-1)<<0+8-r,W|=(L>>a&(1<<u)-1)<<8+8-u,W|=(L>>d&(1<<m)-1)<<16+8-m,b.push(W)}return b}function pl(l){var t=l.pal;if(typeof t=="number"){var r=Math.floor(Math.abs(t/100)%10),a=Math.floor(Math.abs(t/10)%10),u=Math.floor(Math.abs(t)%10);return 1<<r+a+u}else{var d=Zs[t];if(d)return d.length;throw new Error("No palette named "+t)}}function Ks(l,t){var r=t.pal,a;if(typeof r=="number"){var u=Math.floor(Math.abs(r/100)%10),d=Math.floor(Math.abs(r/10)%10),m=Math.floor(Math.abs(r)%10);r>=0?a=Js(l,0,u,u,d,u+d,m):a=Js(l,u+d,m,u,d,0,u)}else{var b=Zs[r];if(b)a=new Uint32Array(l).map(y=>b[y&b.length-1]|4278190080);else throw new Error("No palette named "+r)}return a}var Zs={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]},gl={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 mi(l,t){if(l==null||t==null||l.length!==t.length)return!1;if(l===t)return!0;for(var r=0;r<l.length;r++)if(l[r]!==t[r])return!1;return!0}function mn(l,t){if(l==null||t==null||l.length!==t.length)return!1;if(l===t)return!0;for(var r=0;r<l.length;r++)if(!mi(l[r],t[r]))return!1;return!0}var Gt=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}},Na=class extends Gt{},vn=class extends Na{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}},Oa=class extends Na{constructor(t,r,a,u,d){super();this.project=t,this.fileid=r,this.label=a,this.start=u,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=fl(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=ul(t);var r=cl(t);return this.words=r,!0}},$a=class extends Gt{updateLeft(){return!1}updateRight(){return this.words=Ps(new Uint8Array(this.left.words)),!0}},Wa=class extends Gt{constructor(t){super();this.fmt=t}updateLeft(){return this.images=this.right.images,this.words=hl(this.images,this.fmt),!0}updateRight(){return mi(this.words,this.left.words)?!1:(this.words=this.left.words,this.images=dl(this.words,this.fmt),!0)}},eo=class{constructor(t){this.palcols=t}indexOf(t){return this.palcols.indexOf(t)}},Rr=class extends Gt{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 eo(this.palette),r=this.rgbimgs.map(a=>{for(var u=new Uint8Array(a.length),d=0;d<a.length;d++)u[d]=t.indexOf(a[d]);return u});return this.images=r,!0}updateRight(){if(!this.updateRefs()&&mn(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),u=0;u<r.length;u++)a[u]=this.palette[r[u]&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])),mi(this.palette,t)?!1:(this.palette=t,!0)}};function ml(l){for(var t=new Map,r=new Uint32Array(l.length),a=0,u=0;u<l.length;u++){for(var d=l[u];t[d];)d^=++a;r[u]=d,t[d]=1}return r}var bn=class extends Gt{constructor(t){super();this.palfmt=t}updateLeft(){return!0}updateRight(){return mi(this.words,this.left.words)?!1:(this.words=this.left.words,this.palette=ml(Ks(this.words,this.palfmt)),this.layout=gl[this.palfmt.layout],this.rgbimgs=[],this.palette.forEach(t=>{this.rgbimgs.push(new Uint32Array([t]))}),!0)}getAllColors(){for(var t=[],r=0;r<pl(this.palfmt);r++)t.push(r);return Ks(t,this.palfmt)}},to=class extends Gt{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)),!mn(t,this.tilemap)}};var Ba=class extends to{constructor(t){super(t)}updateLeft(){return!1}updateRight(){if(!this.updateRefs()&&mi(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,u=0;u<this.rows;u++)for(var d=0;d<this.cols;d++){var m=this.words[this.baseofs+r];if(typeof m=="undefined")throw Error("No name for address "+this.baseofs+" + "+r);var b=this.tilemap[m];if(!b)throw Error("No tilemap found for tile index "+m);a=r&11264|960|r&3072|r>>4&56|r>>2&7;for(var y=this.words[a],L=m^y<<9^2147483648,W=u*this.cols*8*8+d*8,de=0,z=(d&2)+((r&64)>>4),H=(y>>z&3)<<2,V=0;V<8;V++){for(var he=0;he<8;he++){var K=b[de++];K&&(K+=H),t[W++]=K}W+=this.cols*8-8}r++}return!0}},yn=class{recreate(t,r){var a=$('<div class="asset_grid"/>');t.empty().append(a);var u=Math.max(2,Math.ceil(16/this.width)),d=this.width<=8?16:8,m=null;this.rgbimgs.forEach((b,y)=>{var L=new xn;L.width=this.width,L.height=this.height,L.recreate(),L.canvas.style.width=L.width*u+"px",L.canvas.title="$"+Le(y),L.updateImage(b),$(L.canvas).addClass("asset_cell"),$(L.canvas).click(de=>{r(y,L)}),m||(m=$("<span/>"),a.append(m)),m.append(L.canvas);var W=y%d==d-1;W&&(a.append($("<br/>")),m=null)})}};function yr(l,t){var r=$(document.createElement("div"));return l&&r.appendTo(l),t&&r.addClass(t),r}var Ua=class extends Gt{constructor(t,r,a){super();this.context=t,this.parentdiv=r,this.fmt=a}updateLeft(){return!0}updateRight(){if(mn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=yr(this.parentdiv.empty(),"asset_dual"),r=yr(t),a=yr(t,"asset_editor").hide(),u=this.chooser=new yn;u.rgbimgs=this.rgbimgs,u.width=this.fmt.w||1,u.height=this.fmt.h||1,u.recreate(r,(b,y)=>{var L=Math.ceil(256/this.fmt.w),W=L*(this.fmt.aspect||1),de=this.createEditor(a,y,W,L);this.context.setCurrentEditor(a,$(y.canvas),this),this.rgbimgs[b]=y.rgbdata});var d=this.left;if(d instanceof Rr&&d.paloptions.length>1){var m=$(document.createElement("select"));d.paloptions.forEach((b,y)=>{var L=$(document.createElement("option")).text(b.name).val(y).appendTo(m);y==d.palindex&&L.attr("selected","selected")}),m.appendTo(r).change(b=>{var y=$(b.target).val();d.palindex=y,d.refreshRight()})}return!0}createEditor(t,r,a,u){var d=new ro;d.createWith(r),d.updateImage();for(var m=r.width*a,b=r.height*u;m>500||b>500;)m/=2,b/=2;return d.canvas.style.width=m+"px",d.canvas.style.height=b+"px",d.makeEditable(this,t,this.left.palette),d}},ja=class extends Gt{constructor(t,r,a){super();this.context=t,this.parentdiv=r,this.fmt=a}updateLeft(){return!0}updateRight(){if(mn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=yr(this.parentdiv.empty(),"asset_dual"),r=yr(t),a=yr(t,"asset_editor").hide(),u=new xn;return u.width=this.fmt.w,u.height=this.fmt.h,u.recreate(),u.updateImage(this.rgbimgs[0]),r.append(u.canvas),!0}},xn=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)}},ro=class extends xn{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 u,d=!1,m=$(this.canvas);m.mousedown(b=>{var y=this.getPositionFromEvent(b);u=this.getPixel(y.x,y.y)==this.currgba?this.palette[0]:this.currgba,this.setPixel(y.x,y.y,this.currgba),d=!0,$(document).mouseup(L=>{$(document).off("mouseup");var W=this.getPositionFromEvent(L);this.setPixel(W.x,W.y,u),d=!1,this.commit()})}).mousemove(b=>{var y=this.getPositionFromEvent(b);d&&this.setPixel(y.x,y.y,u)}),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 u=t+r*this.width,d=this.rgbdata[u];d!=a&&(this.rgbdata[u]=a,this.updateImage())}}createPaletteButtons(){this.palbtns=[];for(var t=yr(null,"asset_toolbar"),r=0;r<this.palette.length;r++){var a=$(document.createElement("button")).addClass("palbtn"),u=this.palette[r]&16777215,d="#"+Le(an(u),6);a.click(this.setPaletteColor.bind(this,r)),a.css("backgroundColor",d).text(r.toString(16)),a.css("color",u&32768?"black":"white"),t.append(a),this.palbtns.push(a)}return t}createToolbarButtons(t){var r=new ln(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),u=0;u<this.height;u++)for(var d=0;d<this.width;d++)a[r]=t(d,u),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((u,d)=>{var m=u+.5-this.width/2,b=d+.5-this.height/2,y=m*a-b*r+this.width/2-.5,L=b*a+m*r+this.height/2-.5;return this.getPixel(y,L)})}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,u)=>this.getPixel(a+t,u+r))}};var wn=Is(),Ha=class{createDiv(t){return this.maindiv=qt(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 bn){var u=a.palette;t==u.length&&r.push({node:a,name:"Palette",palette:u}),a.layout&&a.layout.forEach(([d,m,b])=>{if(m<u.length){if(b==t){var y=u.slice(m,m+b);r.push({node:a,name:d,palette:y})}else if(-b==t){var y=u.slice(m,m-b);y.reverse(),r.push({node:a,name:d,palette:y})}else if(b+1==t){var y=new Uint32Array(t);y[0]=u[0],y.set(u.slice(m,m+b),1),r.push({node:a,name:d,palette:y})}}});break}a=a.right}}),r}getTilemaps(t){var r=[];return this.rootnodes.forEach(a=>{for(;a!=null;){if(a instanceof Rr){var u=a.rgbimgs;u&&u.length>=t&&r.push({node:a,name:"Tilemap",images:a.images,rgbimgs:u})}a=a.right}}),r}isEditing(){return this.cureditordiv!=null}getCurrentEditNode(){return this.cureditnode}setCurrentEditor(t,r,a){let u=250;for(this.cureditordiv!=t&&(this.cureditordiv&&(this.cureditordiv.hide(u),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=[],u=/[/;][*;]([{].+[}])[*;][/;]/g,d;d=u.exec(r);){var m=d.index+d[0].length,b;if(ne.includes("verilog")?b=r.indexOf("end",m):d[0].startsWith(";;")?b=r.indexOf(";;",m):b=r.indexOf(";",m),b>m)try{var y=d[1].replace(/([A-Za-z]+):/g,'"$1":'),L=JSON.parse(y);a.push({fileid:t,fmt:L,start:m,end:b})}catch(Se){console.log(Se)}}for(var W=/DEF_METASPRITE_(\d+)x(\d+)[(](\w+),\s*(\w+),\s*(\w+)/gi;d=W.exec(r);){for(var de=parseInt(d[1]),z=parseInt(d[2]),H=d[3],V=parseInt(d[4]),he=parseInt(d[5]),K=[],xe=0;xe<de;xe++)for(var Ce=0;Ce<z;Ce++)K.push({x:xe*8,y:Ce*8,tile:V,attr:he});var be={defs:K,width:de*8,height:z*8};a.push({fileid:t,label:H,meta:be})}return a}addPaletteEditorViews(t,r,a){var u=$('<div class="asset_dual"/>').appendTo(t),d=$('<div class="asset_editor"/>').hide(),m=[];r.getAllColors().forEach(H=>{m.push(new Uint32Array([H]))});var b=$("<table/>").appendTo(u);d.appendTo(u);var y=r.layout;if(!y){var L=r.palette.length,W=L>32?8:4;y=[];for(var de=0;de<L;de+=W)y.push(["",de,Math.min(L-de,W)])}function z(H,V){var he=r.words[V],K=r.palette[V],xe="#"+Le(an(K),6),Ce=K&32768?"black":"white";H.text(Le(he,2)).css("background-color",xe).css("color",Ce)}y.forEach(([H,V,he])=>{if(V<r.palette.length){var K=$("<tr/>").appendTo(b);$("<td/>").text(H).appendTo(K);for(var xe=[],Ce=V;Ce<V+Math.abs(he);Ce++)xe.push(Ce);he<0&&xe.reverse(),xe.forEach(be=>{var Se=$("<td/>").addClass("asset_cell asset_editable").appendTo(K);z(Se,be),Se.click(o=>{var X=new yn;X.rgbimgs=m,X.width=1,X.height=1,X.recreate(d,(ae,oe)=>{a(be,ae),z(Se,be)}),this.setCurrentEditor(d,Se,r)})})}})}addPixelEditor(t,r,a){a.xform="scale(2)";var u=new Wa(a);r.addRight(u);var d=new Rr(this,a);u.addRight(d),d.addRight(new Ua(this,qt(t),a))}addPaletteEditor(t,r,a){var u=new bn(a);r.addRight(u),r.refreshRight(),this.addPaletteEditorViews(t,u,(d,m)=>{console.log("set entry",d,"=",m),r.words[d]=m,u.words=null,u.updateRight(),u.refreshLeft()})}ensureFileDiv(t){var r=this.getFileDivId(t),a=$(document.getElementById(r));if(a.length===0){var u=qt(this.maindiv,"asset_file"),d=qt(u,"asset_file_header").text(t);a=qt(u).attr("id",r).addClass("disable-select")}return a}refreshAssetsInFile(t,r){let a=0;if(ne.startsWith("nes")&&t.endsWith(".chr")&&r instanceof Uint8Array){let u=new vn(ge,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),u,d),this.registerAsset("charmap",u,1),a++}else if(ne.startsWith("nes")&&t.endsWith(".pal")&&r instanceof Uint8Array){let u=new vn(ge,t),d={pal:"nes",layout:"nes"};this.addPaletteEditor(this.ensureFileDiv(t),u,d),this.registerAsset("palette",u,0),a++}else if(typeof r=="string"){let u=this.scanFileTextForAssets(t,r);for(let d of u)if(d.fmt){let m=t,b=new Oa(ge,t,m,d.start,d.end),y=b;if(d.fmt.comp=="rletag"&&(b=b.addRight(new $a)),d.fmt.map=="nesnt"){b=b.addRight(new Ba(this)),b=b.addRight(new Rr(this,{w:8,h:8,bpp:4}));let L={w:8*(d.fmt.w||32),h:8*(d.fmt.h||30),count:1};b=b.addRight(new ja(this,qt(this.ensureFileDiv(t)),L)),this.registerAsset("nametable",y,2),a++}else d.fmt.w>0&&d.fmt.h>0?(this.addPixelEditor(this.ensureFileDiv(t),b,d.fmt),this.registerAsset("charmap",y,1),a++):d.fmt.pal&&(this.addPaletteEditor(this.ensureFileDiv(t),b,d.fmt),this.registerAsset("palette",y,0),a++)}}return a}getFileDivId(t){return"__asset__"+ks(t)}refresh(t){if(t)this.maindiv.empty(),this.clearAssets(),fe.iterateFiles((a,u)=>{try{var d=this.refreshAssetsInFile(a,u)}catch(m){console.log(m),this.ensureFileDiv(a).text(m+"")}}),console.log("Found "+this.rootnodes.length+" assets"),this.deferrednodes.forEach(a=>{try{a.refreshRight()}catch(u){console.log(u),alert(u+"")}}),this.deferrednodes=[];else for(var r of this.rootnodes)r!==this.getCurrentEditNode()&&r.refreshRight()}setVisible(t){t?wn.bind&&wn.bind("ctrl+z",ge.undoStep.bind(ge)):wn.unbind&&wn.unbind("ctrl+z")}};var vi=256,io=100,no=!1,bi=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+" ($"+Le(t)+")";else if(typeof t=="boolean")r=t.toString();else if(typeof t=="string")t.length<io?r=t:r=t.substring(0,io)+"...";else if(t.buffer&&t.length<=vi)r=Ds(t,0,t.length);else if(typeof t=="object"||typeof t=="function")if(this._content!=null){if(t.slice&&t.length>vi){let y={},L=t;for(var a=vi;t.length/a>vi;)a*=2;for(let W=0;W<L.length;W+=a)y["$"+Le(W)]={$$:()=>L.slice(W,W+a)};t=y}if(t instanceof Map){let y={};for(let[L,W]of t.entries())y[L]=W;t=y}let m=t instanceof Array?Array.from(t.keys()):Object.getOwnPropertyNames(t);if(m.length>vi){let y={},L=t;for(var a=100;m.length/a>100;)a*=2;for(let de=0;de<m.length;de+=a){for(var u={},d=de;d<de+a;d++)u[m[d]]=L[m[d]];y["["+de+"...]"]=u}t=y,m=Object.getOwnPropertyNames(t)}let b=new Set(this.children.keys());m.forEach(y=>{var L=!no&&typeof y=="string"&&y.startsWith("$$");if(!L){let W=this.children.get(y);W==null&&(W=new bi(this,y),this.children.set(y,W)),W.update(t[y])}b.delete(y)}),b.forEach(y=>{this.children.get(y).remove(),this.children.delete(y)}),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 ao(l,t){var r=new bi(null,null);r.view=t,r._content=l;var a=new bi(r,"/");return a.expanded=!0,a.getDiv(),a._div.style.padding="0px",a}var so=class{createDiv(t){return this.root=ao(t,this),this.root.getDiv()}refresh(){this.tick()}tick(){this.root.update(this.getRootObject())}};var za=class extends so{getRootObject(){return A.getDebugTree()}},Va=class extends br{constructor(){super(...arguments);this.cumulativeData=!0}createDiv(t){return this.clear(),this.treeroot=ao(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,u,d,m)=>{switch(t){case te.SP_POP:this.newRoot(this.lastpc,this.lastsp);case te.SP_PUSH:if(this.stack.length){let y=this.stack[this.stack.length-1];var b=this.lastsp-r;(b==2||b==3)&&r<y.$$SP&&(this.jsr=!0),(b==-2||b==-3)&&this.stack.length>1&&r>y.$$SP&&(this.rts=!0)}this.lastsp=r;break;case te.EXECUTE:if(Math.abs(r-this.lastpc)>=4){if(this.jsr&&this.stack.length){let y=this.stack[this.stack.length-1],L=this.addr2str(r),W=y.calls[L];W==null?W=y.calls[L]=this.newNode(r,this.lastsp):W.$$PC==null&&(W.$$PC=r),this.stack.push(W),W.count++,W.startLine=u}this.jsr=!1,this.rts&&this.stack.length&&(this.stack.pop().endLine=u),this.rts=!1}this.lastpc=r;break}}),this.graph&&(this.graph.$$Stack=this.stack),no?this.graph:this.graph&&this.graph.calls}};var Mt=oa(sl());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 u=0;u<r;u++)this.soundData.push(0);let a=He.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*He.TAP_LENGTH_IN_SECONDS*t);for(let a=0;a<r;a++){let u;this.options.sine_wave?u=-Math.sin(a/r*2*Math.PI):a<r/2?u=-1:u=1,this.options.invert_waveform&&(u=-u),this.soundData.push(Math.round(128+u*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}},Ue=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=Ue.FILE_TYPE_NONE,this.waveFile=null}makeFilename(t){let r=[],a=32;t=t.toUpperCase();for(let u=0;u<Ue.FILENAME_BUFFER_SIZE;u++)if(t.length<=u)r.push(a);else{let d=t.charCodeAt(u);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(Ue.SHORT_PULSE),this.addTapCycle(Ue.MEDIUM_PULSE)):(this.addTapCycle(Ue.MEDIUM_PULSE),this.addTapCycle(Ue.SHORT_PULSE))}addDataMarker(t){t?(this.addTapCycle(Ue.LONG_PULSE),this.addTapCycle(Ue.MEDIUM_PULSE)):(this.addTapCycle(Ue.LONG_PULSE),this.addTapCycle(Ue.SHORT_PULSE))}resetChecksum(){this.checksum=0}addByteFrame(t,r){let a=1;for(let u=0;u<8;u++){let d=(t&1<<u)!=0?1:0;this.addBit(d),a^=d}this.addBit(a),this.addDataMarker(r),this.checksum^=t}addLeader(t){let r;t===Ue.LEADER_TYPE_HEADER?r=27136:t===Ue.LEADER_TYPE_CONTENT?r=6656:r=79;for(let a=0;a<r;a++)this.addTapCycle(Ue.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(Ue.LEADER_TYPE_REPEATED):this.addLeader(Ue.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<Ue.NUMBER_OF_PADDING_BYTES;r++)this.addByteFrame(Ue.PADDING_CHARACTER,!0);this.addByteFrame(this.checksum,!1)}addFile(){let t=!1;for(let r=0;r<2;r++)t?this.addLeader(Ue.LEADER_TYPE_REPEATED):this.addLeader(Ue.LEADER_TYPE_CONTENT),this.addDataMarker(!0),this.addSyncChain(t),this.resetChecksum(),this.addData(),this.addByteFrame(this.checksum,!1),t=!0;this.addLeader(1)}},He=Ue;He.CLOCK_RATE=985248,He.TAP_LENGTH_IN_SECONDS=8/Ue.CLOCK_RATE,He.FILENAME_BUFFER_SIZE=16,He.FILE_TYPE_NONE=0,He.FILE_TYPE_RELOCATABLE=1,He.FILE_TYPE_SEQUENTIAL=2,He.FILE_TYPE_NON_RELOCATABLE=3,He.LEADER_TYPE_HEADER=0,He.LEADER_TYPE_CONTENT=1,He.LEADER_TYPE_REPEATED=2,He.NUMBER_OF_PADDING_BYTES=171,He.PADDING_CHARACTER=32,He.SHORT_PULSE=48,He.MEDIUM_PULSE=66,He.LONG_PULSE=86;var vl=al(),At=nl(),ee=ua(window.location.search||"?"),yi=Fr(ee.electron),ot=Fr(ee.embed),En,ne,xr,je,A,Ya,xi=$("#controls_top"),Ye,fe,ge,lt,Xa,Xe,Sn,Je,dt,ir,wi,Ei,_n=!1,Ir=!1,Tn=null,oo=null,Qa=!1,lo="c.PC == 0x6000",bl={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"},yl={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 Si(l,t,r,a){window.ga&&ga("send","event",l,t,r,a)}function Ee(l){Oe(!1),bootbox.alert({title:'<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Alert',message:At.sanitize(l)})}function Nt(l){Oe(!1),bootbox.alert(At.sanitize(l))}function xl(l){throw Ee(l),new Error(l)}function wl(){return new Worker("./gen/worker/bundle.js")}var Tt=function(){try{let t="__some_random_key_you_are_not_going_to_use__";localStorage.setItem(t,t);var l=localStorage.getItem(t)==t;return localStorage.removeItem(t),l}catch(t){return!1}}(),uo=class{setLastPreset(t){Tt&&!ot&&(je&&ne&&!yi?localStorage.setItem("__lastrepo_"+ne,je):localStorage.removeItem("__lastrepo_"+ne),localStorage.setItem("__lastplatform",ne),localStorage.setItem("__lastid_"+xr,t))}unsetLastPreset(){Tt&&!ot&&(delete ee.file,localStorage.removeItem("__lastid_"+xr))}getLastPreset(){return Tt&&!ot&&localStorage.getItem("__lastid_"+xr)}getLastPlatformID(){return Tt&&!ot&&localStorage.getItem("__lastplatform")}getLastRepoID(t){return Tt&&!ot&&t&&localStorage.getItem("__lastrepo_"+t)}shouldCompleteTour(){return Tt&&!ot&&!localStorage.getItem("8bitworkshop.hello")}completedTour(){Tt&&!ot&&localStorage.setItem("8bitworkshop.hello","true")}},wr=new uo;function Ja(l,t){navigator.storage&&navigator.storage.persist?navigator.storage.persist().then(r=>{console.log("requestPersistPermission =",r),r?l&&!t&&Nt("Your browser says it will persist your local file edits, but you may want to back up your work anyway."):l&&Ee("Your browser refused to expand the peristent storage quota. Your edits may not be preserved after closing the page.")}):l&&Ee("Your browser may not persist edits after closing the page. Try a different browser.")}function El(){return Sn?Sn.title||Sn.name||fe.mainPath||"ROM":fe.mainPath||"ROM"}async function Sl(){var l=new va(ne);return yi?(console.log("using electron with local filesystem",alternateLocalFilesystem),new fi(l,alternateLocalFilesystem)):ee.localfs!=null?new fi(l,await Il(ee.localfs)):new fi(l,new ba(Je))}async function _l(){var l=await Sl();fe=new ya(wl(),ne,A,l),fe.remoteTool=ee.tool||null,ge=new Ea($("#workspace")[0],fe),fe.callbackBuildResult=t=>{fu(t)},fe.callbackBuildStatus=t=>{Tl(t)}}function Tl(l){l?xi.addClass("is-busy"):xi.removeClass("is-busy"),$("#compile_spinner").css("visibility",l?"visible":"hidden")}function Ka(l,t){var r=document.createElement("li"),a=document.createElement("a");return a.setAttribute("class","dropdown-item"),a.setAttribute("href","#"),a.setAttribute("data-wndid",l),l==ge.getActiveID()&&$(a).addClass("dropdown-item-checked"),a.appendChild(document.createTextNode(t)),r.appendChild(a),{li:r,a}}function _i(){var l=$("#windowMenuList").empty(),t=!1;function r(y,L,W){t&&(l.append(document.createElement("hr")),t=!1);let{li:de,a:z}=Ka(y,L);if(l.append(de),W){var H=(V,he)=>{l.find("a").removeClass("dropdown-item-checked"),$(z).addClass("dropdown-item-checked")};ge.setCreateFunc(y,W),ge.setShowFunc(y,H),$(z).click(V=>{ge.createOrShow(y),Tn=y})}}function a(y){var L=A.getToolForFilename(y);L=="dasm"&&y.endsWith(".h")&&it().endsWith(".c")&&(L="cc65");var W=L&&bl[L];return new pi(y,W)}function u(y){r(y,_t(y),()=>{var L=fe.getFile(y);if(typeof L=="string")return a(y);if(L instanceof Uint8Array)return new Pa(y,L)})}u(fe.mainPath),fe.iterateFiles((y,L)=>{L&&y!=fe.mainPath&&u(y)}),t=!0;var d=fe.getListings();if(d)for(var m in d){var b=d[m];(b.assemblyfile&&b.assemblyfile.text||b.sourcefile&&b.sourcefile.text||b.text)&&r(m,_t(m),y=>new Ca(y))}t=!0,A.disassemble&&A.saveState&&r("#disasm","Disassembly",()=>new hn),A.readAddress&&r("#memory","Memory Browser",()=>new pn),fe.segments&&fe.segments.length&&r("#memmap","Memory Map",()=>new Aa),A.readVRAMAddress&&r("#memvram","VRAM Browser",()=>new ka),A.startProbing&&(r("#memheatmap","Memory Probe",()=>new La),r("#crtheatmap","CRT Probe",()=>new Fa),r("#probelog","Probe Log",()=>new Ra),r("#scanlineio","Scanline I/O",()=>new Ia),r("#symbolprobe","Symbol Profiler",()=>new Ma),r("#callstack","Call Stack",()=>new Va)),A.getDebugTree&&r("#debugview","Debug Tree",()=>new za),r("#asseteditor","Asset Editor",()=>new Ha)}function Cl(l,t){if(t){var r=ee.highlight.split(","),a=parseInt(r[0])-1,u=parseInt(r[1])-1,d=ge.createOrShow(l);d.highlightLines(a,u)}}function co(l){_i(),ge.createOrShow(l),fe.setMainFile(l),Cl(l,ee.highlight)}async function kl(l){fe.mainPath=l,wr.setLastPreset(l);var t=await fe.loadFiles([l]);if(ki=new Date,t&&t.length)co(l);else{var r=await Pl(l);fe.filedata[l]=r||`
`,co(l),ee.newfile?Ja(!0,!0):Nt('Could not find file "'+l+'". Loading default file.'),delete ee.newfile,Dn()}}function Za(l){if(l=="/")ee={repo:"/"};else if(l.indexOf("://")>=0){var t=fn(l);t&&(ee={repo:t.repopath})}else ee.platform=ne,ee.file=l;Mr()}async function Pl(l){var t=A.getToolForFilename(l);try{return await $.get("presets/"+vt(ne)+"/skeleton."+t,"text")}catch(r){Ee("Could not load skeleton for "+ne+"/"+t+"; using blank file")}}function es(l){return l.indexOf(" ")>=0?(Ee("No spaces in filenames, please."),!1):!0}function Al(l){return bootbox.prompt({title:"Enter the name of your new main source file.",placeholder:"newfile"+A.getDefaultExtension(),callback:t=>{if(t&&t.trim().length>0){if(!es(t))return;t.indexOf(".")<0&&(t+=A.getDefaultExtension());var r=t;Si("workspace","file","new"),ee.newfile="1",Za(r)}}}),!0}function Dl(l){let t=$('<input type="file" multiple accept="*" style="display:none">'),r=t[0];t.change(a=>{Ll(r.files)}),t.click()}function Ll(l){console.log(l);var t=0;function r(){var a=l[t++];if(!a)console.log("Done uploading",t),t>2?(Nt("Files uploaded."),setTimeout(Ci,1e3)):(ee.file=l[0].name,bootbox.confirm({message:"Open '"+At.sanitize(ee.file)+"' as main project file?",buttons:{confirm:{label:"Open As New Project"},cancel:{label:"Include/Link With Project Later"}},callback:m=>{m?Mr():setTimeout(Ci,1e3)}})),Si("workspace","file","upload");else{var u=a.name,d=new FileReader;d.onload=function(m){var b=m.target.result,y=new Uint8Array(b);vr(u,y)||(y=nn(y).replace(`\r
`,`
`)),ge.updateFile(u,y),console.log("Uploaded "+u+" "+y.length+" bytes"),r()},d.readAsArrayBuffer(a)}}l&&r()}async function Fl(l){var t=window.showDirectoryPicker;t||Ee("This browser can't open local files on your computer, yet. Try Chrome.");var r=await t(),a=r.name,u="__localfs__"+a,d={handle:r},m=Ga.createInstance({name:u,version:2});await m.setItem(u,d),ee={localfs:a},Mr(!0)}async function Rl(l){return new Promise((t,r)=>{bootbox.prompt(At.sanitize(l),a=>{t(a)})})}async function Il(l){let t={mode:"readwrite"};var r="__localfs__"+l,a=Ga.createInstance({name:r,version:2}),u=await a.getItem(r),d=u.handle;console.log(u,d);var m=await d.queryPermission(t);if(console.log(m),m!=="granted"&&(await Rl("Request permissions to access filesystem?"),m=await d.requestPermission(t)),m!=="granted"){Ee("Could not get permission to access filesystem.");return}return{getFileData:async b=>{console.log("getFileData",b);let y=await d.getFileHandle(b,{create:!1});console.log("getFileData",y);let L=await y.getFile();console.log("getFileData",L);let W=await(vr(b)?L.binary():L.text());return console.log(y,L,W),W},setFileData:async(b,y)=>{}}}function it(){return _t(fe.mainPath)}function Ml(){return _t(ge.getActiveID())}var ts;function fo(l){for(var t=l+"=",r=document.cookie.split(";"),a=0;a<r.length;a++){for(var u=r[a];u.charAt(0)==" ";)u=u.substring(1,u.length);if(u.indexOf(t)==0)return u.substring(t.length,u.length)}return null}async function Er(){if(!ts){await Rt("lib/octokat.js"),await Rt("https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js"),await Rt("https://www.gstatic.com/firebasejs/8.8.1/firebase-auth.js"),await Rt("https://8bitworkshop.com/config.js");var l=fo("__github_key");ts=new Sa(Octokat,l,Je,fe),console.log("loaded github service")}return ts}function Ti(){var l=(je||"").split("/");return l.length!=2?(Ee("You are not in a GitHub repository. Choose one from the pulldown, or Import or Publish one."),null):"https://github.com/"+l[0]+"/"+l[1]}async function rs(l,t){var r,a=fn(l);if(!a){Ee("Could not parse Github URL.");return}var u=di()[a.repopath];if(!(u&&!confirm("You've already imported "+a.repopath+" -- do you want to replace all local files?"))){Oe(!0);var d=xa(a.repopath);Xt(.25);var m=await Er();return m.import(l).then(b=>(r=b,Xt(.75),m.pull(l,d))).then(b=>{ee={repo:r.repopath},Oe(!1),Si("sync","import",l),Mr(t)}).catch(b=>{Oe(!1),console.log(b),Ee("Could not import "+l+"."+b)})}}async function Nl(l){var t=await Er();t.login().then(()=>{Nt("You are signed in to Github.")}).catch(r=>{Ee("Could not sign in."+r)})}async function Ol(l){var t=await Er();t.logout().then(()=>{Nt("You are logged out of Github.")})}function $l(l){var t=$("#importGithubModal"),r=$("#importGithubButton");t.modal("show"),r.off("click").on("click",()=>{var a=$("#importGithubURL").val()+"";t.modal("hide"),rs(a,!1)})}function Wl(l){if(!(je&&!confirm("This project ("+fe.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(ft(_t(fe.mainPath))),t.modal("show"),r.off("click").on("click",async()=>{var a=$("#githubRepoName").val()+"",u=$("#githubRepoDesc").val()+"",d=$("#githubRepoPrivate").val()=="private",m=$("#githubRepoLicense").val()+"",b;if(!a){Ee("You did not enter a project name.");return}t.modal("hide"),Oe(!0);var y=await Er();y.login().then(()=>(Xt(.25),y.publish(a,u,m,d))).then(L=>(b=L,Xt(.5),je=ee.repo=b.repopath,ho("initial import from 8bitworkshop.com"))).then(()=>{Si("sync","publish",d?"":a),rs(b.url,!1)}).catch(L=>{Oe(!1),console.log(L),Ee("Could not publish GitHub repository: "+L)})})}}function Bl(l){var t=Ti();if(!!t){var r=$("#pushGithubModal"),a=$("#pushGithubButton");r.modal("show"),a.off("click").on("click",()=>{var u=$("#githubCommitMsg").val()+"";r.modal("hide"),ho(u)})}}function Ul(l){var t=Ti();!t||bootbox.confirm("Pull from repository and replace all local files? Any changes you've made will be overwritten.",async r=>{if(r){Oe(!0);var a=await Er();a.pull(t).then(u=>{Oe(!1),ge.updateAllOpenWindows(Je)})}})}function jl(l){return new Promise((t,r)=>{var a=l.commit.files;if(console.log(a),a.length==0){Oe(!1),Nt("No files changed.");return}var u="";for(var d of a)u+=At.sanitize(d.filename)+": "+d.status,(d.additions||d.deletions||d.changes)&&(u+=" ("+d.additions+" additions, "+d.deletions+" deletions, "+d.changes+" changes)"),u+="<br/>";bootbox.confirm(u,m=>{m?t(l):Oe(!1)})})}async function ho(l){var t=Ti();if(!!t){var r=[];for(var a in fe.filedata){var u=fe.stripLocalPath(a),d=fe.filedata[a];u&&d&&r.push({path:u,data:d})}if(Xe instanceof Uint8Array){let b="bin/"+it()+".rom";r.push({path:b,data:Xe})}Oe(!0);var m=await Er();return m.login().then(()=>(Xt(.5),m.commit(t,l,r))).then(b=>jl(b)).then(b=>m.push(b)).then(b=>(Oe(!1),Nt("Pushed files to "+t),b)).catch(b=>{Oe(!1),console.log(b),Ee("Could not push GitHub repository: "+b)})}}function Hl(){var l=Ti();!l||bootbox.prompt("<p>Are you sure you want to delete this repository ("+At.sanitize(l)+") 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"&&zl()})}async function zl(){var l=Ti();Oe(!0);let t=await Er(),r=await t.getGithubSession(l);t.bind(r,!1),await Je.keys().then(a=>Promise.all(a.map(u=>Je.removeItem(u)))),Oe(!1),ee={repo:"/"},Mr()}function Vl(l){return Xe==null?(Ee("Please fix errors before sharing."),!0):Xe instanceof Uint8Array?(ql(),Rt("lib/liblzg.js").then(()=>{var t=Cs(window.Module,Array.from(Xe));window.Module=null;var r=btoa(rn(t)),a={p:ne,r},u=$.param(a),d=Gl(u,"player.html"),m='<iframe width=640 height=600 src="'+d+'">';$("#embedLinkTextarea").text(d),$("#embedIframeTextarea").text(m),$("#embedLinkModal").modal("show"),$("#embedAdviceWarnAll").hide(),$("#embedAdviceWarnIE").hide(),d.length>=65536?$("#embedAdviceWarnAll").show():d.length>=5120&&$("#embedAdviceWarnIE").show()}),!0):(Ee("Can't share a Verilog executable yet. (It's not actually a ROM...)"),!0)}function ql(){console.log("clipboard"),import("./clipboard-45L7WF2O.js").then(l=>{let t=l.default;new t(".btn")})}function Gl(l,t){console.log(l);var r=window.location,a=r.pathname.replace("index.html",""),u=r.host=="8bitworkshop.com"?"https:":r.protocol,d=u+"//"+r.host+a+t+"?"+l;return d}function Yl(l){var t=dt&&dt.code_start;Rt("lib/c2t.js").then(()=>{var r="",a=function(de){r+=de+`
`},u=window.c2t({noInitialRun:!0,print:a,printErr:a}),d=u.FS,m=it()+".bin",b=it()+".wav";d.writeFile(m,Xe,{encoding:"binary"});var y=["-2bc",m+","+t.toString(16),b];u.callMain(y);var L=d.readFile(b,{encoding:"binary"});if(L){var W=new Blob([L],{type:"audio/wav"});(0,Mt.saveAs)(W,b),r+="Then connect your audio output to the cassette input, turn up the volume, and play the audio file.",Nt(r)}})}function Xl(l){Rt("lib/makewav.js").then(()=>{let t="",r=function(b){t+=b+`
`};var a=ft(it());let u=a+".bin",d=a+".wav";window.makewav({noInitialRun:!1,print:r,printErr:r,arguments:["-ts","-f0","-v10",u],preRun:b=>{b.FS.writeFile(u,Xe,{encoding:"binary"})}}).ready.then(b=>{let y=[u];b.run(y),console.log(t);let W=b.FS.readFile(d,{encoding:"binary"});if(W){let de=new Blob([W],{type:"audio/wav"});(0,Mt.saveAs)(de,d),t+=`
Connect your audio output to the SuperCharger input, turn up the volume, and play the audio file.`,Nt(t)}})})}function Ql(l){var t=ft(it());let r=t+".tap",a=new He(t),u=new qa({sine_wave:!0}),d=Xe,m=d[0]+d[1]*256;d=d.slice(2),a.setContent({data:d,startAddress:m,type:He.FILE_TYPE_NON_RELOCATABLE}),a.generateSound(u);let b=u.getTAPData();if(b){let y=new Blob([b],{type:"application/octet-stream"});(0,Mt.saveAs)(y,r)}}function po(){switch(vt(ne)){case"vcs":return Xl;case"apple2":return Yl;case"c64":return Ql}}function Jl(l){if(Xe==null)return Ee("Please fix errors before exporting."),!0;var t=po();if(t===void 0)return Ee("Cassette export is not supported on this platform."),!0;t(l)}function Kl(l){var t=ge.getActive();if(t&&t.setText){var r=ge.getActiveID();$.get("presets/"+vt(ne)+"/"+r,a=>{bootbox.confirm("Reset '"+At.sanitize(r)+"' to default?",u=>{u&&t.setText(a)})},"text").fail(()=>{Ee(je?"Can only revert built-in examples. If you want to revert all files, You can pull from the repository.":"Can only revert built-in examples.")})}else Ee("Cannot revert the active window. Please choose a text file.")}function Zl(l){var t=ge.getActive();if(t&&t.getPath){var r=ge.getActiveID();bootbox.confirm("Delete '"+At.sanitize(r)+"'?",a=>{a&&Je.removeItem(r).then(()=>{ee.file==r?(wr.unsetLastPreset(),Mr()):(Ci(),Nt("Deleted "+r))})})}else Ee("Cannot delete the active window.")}function eu(l){var t=ge.getActive();if(t&&t.getPath&&fe.getFile(t.getPath())){var r=ge.getActiveID();bootbox.prompt({title:"Rename '"+At.sanitize(r)+"' to?",value:r,callback:a=>{var u=fe.getFile(t.getPath());if(a&&a!=r&&u){if(!es(a))return;Je.removeItem(r).then(()=>Je.setItem(a,u)).then(()=>{Ci(),alert("Renamed "+r+" to "+a),r==fe.mainPath&&Za(a)})}}})}else Ee("Cannot rename the active window.")}function tu(l){if(Xe==null)return Ee("Please finish compiling with no errors before downloading ROM."),!0;var t=ft(it());if(A.getDownloadFile){var r=A.getDownloadFile(),t=ft(it());(0,Mt.saveAs)(r.blob,t+r.extension)}else if(Xe instanceof Uint8Array){var a=new Blob([Xe],{type:"application/octet-stream"}),u=A.getROMExtension&&A.getROMExtension(Xe)||"-"+vt(ne)+".bin";(0,Mt.saveAs)(a,t+u)}else Ee(`The "${ne}" platform doesn't have downloadable ROMs.`)}function ru(l){var t=ge.getCurrentText();if(!t)return!1;var r=new Blob([t],{type:"text/plain;charset=utf-8"});(0,Mt.saveAs)(r,Ml(),{autoBom:!1})}async function go(){let l=(await import("./jszip.min-R7NPJJ5M.js")).default;return new l}async function iu(l){var t=await go();fe.iterateFiles((r,a)=>{a&&t.file(_t(r),a)}),t.generateAsync({type:"blob"}).then(r=>{(0,Mt.saveAs)(r,it()+"-"+vt(ne)+".zip")})}function nu(l){let t=A.getDebugSymbolFile&&A.getDebugSymbolFile();if(!t){Ee("This project does not have debug information.");return}var r=ft(it());(0,Mt.saveAs)(t.blob,r+t.extension,{autoBom:!1})}async function au(l){var t=await go(),r=await Je.keys();Oe(!0);try{var a=0;await Promise.all(r.map(d=>Je.getItem(d).then(m=>{Xt(a++/(r.length+1)),m&&t.file(d,m)})));var u=await t.generateAsync({type:"blob"});(0,Mt.saveAs)(u,vt(ne)+"-all.zip")}finally{Oe(!1)}}function su(l){let t={},r;for(var a=0;a<En.length;a++){var u=En[a],d=u.chapter?u.chapter+". "+u.name:u.name,m=u.id==fe.mainPath;u.category?r=$("<optgroup />").attr("label","Examples: "+u.category).appendTo(l):r||(r=$("<optgroup />").attr("label","Examples").appendTo(l)),r.append($("<option />").val(u.id).text(d).attr("selected",m?"selected":null)),m&&(Sn=u),t[u.id]=d}return t}function ou(l){if(Tt&&!yi){var t=0,r=di();if(r){let u=$("<optgroup />").attr("label","Repositories").appendTo(l);for(let d in r){var a=r[d];a.platform_id&&vt(a.platform_id)==vt(ne)&&u.append($("<option />").val(a.url).text(a.url.substring(a.url.indexOf("/"))))}}}}async function mo(l,t,r,a){let u=await Je.keys();u||(u=[]);let d;for(var m=0;m<u.length;m++){let b=u[m];if(b.startsWith(r)&&!a[b]){d||(d=$("<optgroup />").attr("label",t).appendTo(l));let y=b.substring(r.length);d.append($("<option />").val(b).text(y).attr("selected",b==fe.mainPath?"selected":null))}}}function vo(l){l.css("visibility","visible");var t=fe.mainPath;l.val()!=t&&l.append($("<option />").val(t).text(t).attr("selected","selected"))}async function Ci(){var l=$("#preset_select").empty();if(je)l.append($("<option />").val("/").text("Leave Repository")),$("#repo_name").text(_t(je)+"/").show(),await mo(l,je,"",{}),vo(l);else{ou(l);var t=su(l);await mo(l,"Local Files","",t),vo(l)}l.off("change").change(function(r){Za($(this).val().toString())})}function lu(l){var t=$("<p/>");if(l.path!=null){var r=l.line?l.label?`(${l.path} @ ${l.label})`:`(${l.path}:${l.line})`:`(${l.path})`,a=$("<a/>").text(r),u=l.path;u==it()&&(u=fe.mainPath),ge.isWindow(u)&&a.click(d=>{var m=ge.createOrShow(u);m instanceof pi&&m.setCurrentLine(l,!0)}),t.append(a),t.append("&nbsp;")}return t.append($("<span/>").text(l.msg)),t}function bo(){$("#error_alert").hide(),Qa=!1}function is(l,t){var r=$("#error_alert_msg").empty();for(var a of l.slice(0,10))r.append(lu(a));$("#error_alert").show(),Qa=t}function yo(l,t){if(t!=null){var r={msg:t,line:0};l instanceof fa&&l.$loc&&(r=Object.create(l.$loc),r.msg=t,console.log(r)),is([r],!0)}}var uu=new Date,ki;function cu(){if(window.ga&&ki){var l=new Date;ga("send","timing","load",ne,ki.getTime()-uu.getTime()),ga("send","timing","build",ne,l.getTime()-ki.getTime()),ki=null}}async function fu(l){if("errors"in l&&l.errors.length>0)xi.addClass("has-errors"),ge.setErrors(l.errors),_i(),is(l.errors,!1);else{if(xi.removeClass("has-errors"),ge.setErrors(null),bo(),l==null||"unchanged"in l&&l.unchanged||!("output"in l))return;A.debugSymbols=new Fs(l.symbolmap,l.debuginfo),dt=l.params;var t=l.output;if(t!=null)try{Ai(),To(),await A.loadROM(El(),t),Xe=t,Xa||Ot(),cu(),rc()}catch(r){console.log(r),xi.addClass("has-errors"),yo(r,r+""),Xe=null,_i();return}_i(),ge.refresh(!1)}}async function du(){if(A.loadBIOS){var l=ne+".rom",t=await Je.getItem(l);t instanceof Uint8Array?(console.log("loading BIOS",l,t.length+" bytes"),A.loadBIOS(l,t)):console.log("BIOS file must be binary")}}function xo(){var l=$("#mem_info");l.hide(),wi=null}function Pi(l){if(!!Rs(A)){var t=$("#mem_info"),r=A.getDebugCategories();r&&!Ei&&(Ei=r[0]);var a=l&&A.getDebugInfo(Ei,l);if(a){var u=wi?Ts(wi,a):a;t.show().html(u);var d=$('<div class="mem_info_links">'),m=y=>{var L=$("<a>"+y+"</a>");y==Ei&&L.addClass("selected"),L.click(W=>{Ei=y,wi=null,Pi(ir)}),d.append(L),d.append("<span> </span>")};for(var b of r)m(b);t.append("<br>"),t.append(d),wi=a}else xo()}}function Cn(l,t){$("#debug_bar, #run_bar").find("button").removeClass("btn_active").removeClass("btn_stopped"),$("#dbg_"+l).addClass("btn_"+t)}function ns(){return A&&Xe!=null}function Dt(){return ns()?!0:(Ee("Can't do this until build successfully completes."),!1)}function hu(l){if(Tn&&Tn.startsWith("#")||["toline","restart","tovsync","stepover"].includes(oo)||!A.disassemble)return;let t=fe.getListings(),r="#disasm",a=256;if(t){let u=l.c?l.c.EPC||l.c.PC:0;for(let d in t){let m=t[d],b=m.assemblyfile||m.sourcefile,y=fe.filename2path[d]||d;if(b==m.sourcefile&&(y=ge.findWindowWithFilePrefix(d)),ge.isWindow(y)){let L=b&&b.findLineForOffset(u,dn);if(L){let W=b.lines[L.line+1];if(!W||u<W.offset){let de=u-L.offset;de<a&&(r=y,a=de)}}}}}ge.createOrShow(r,!0)}function kn(l){ir=l,Pi(l),hu(l),ge.refresh(!0),_n=!0}function wo(l){A.setupDebug&&(A.setupDebug((t,r)=>{kn(t),Cn(l||"pause","stopped"),r&&is([{msg:"STOPPED: "+r,line:0}],!0)}),oo=l)}function It(l){!Dt()||(os(),wo(l),l&&Cn(l,"active"))}function Yt(){A&&A.isRunning()&&(A.pause(),console.log("Paused")),Cn("pause","stopped")}function pu(){!Dt()||(Ai(),Yt(),Xa=!0)}function Ot(){A.isRunning()||(A.resume(),console.log("Resumed")),Cn("go","active"),Qa&&bo()}function Eo(){!Dt()||(Ai(),A.isRunning()||ge.refresh(!1),Ot(),Xa=!1,Tn=null)}function gu(){!Dt()||(It("step"),A.step())}function mu(){!Dt()||(It("stepover"),A.stepOver())}function vu(){!Dt()||(It("tovsync"),A.runToVsync())}function So(){var l=ge.getActive();return l&&l.getCursorPC&&l.getCursorPC()}function gi(l){!Dt()||!(l>=0)||(It("toline"),console.log("Run to",l.toString(16)),A.runToPC?A.runToPC(l):A.runEval(t=>t.PC==l))}function bu(){A.restartAtPC(So())?Eo():Ee("Could not restart program at selected line.")}function yu(){gi(So())}function xu(){!Dt()||(It("stepout"),A.runUntilReturn())}function wu(){!Dt()||(It("stepback"),A.stepBack())}function Ai(){ir=null,A.clearDebug&&A.clearDebug(),wo(),Pi()}function as(){A.reset(),To()}function Eu(){!Dt()||(Ai(),as(),Ot())}function Su(){if(!!Dt()){var l=Ir;os(),A.setupDebug&&A.runEval?(Ai(),Ot(),as(),It("restart"),A.runEval(t=>!0)):(as(),Ot()),l&&Co()}}function _u(){var l=$("#debugExprModal"),t=$("#debugExprSubmit");$("#debugExprInput").val(lo),$("#debugExprExamples").text(Tu()),l.modal("show"),t.off("click").on("click",()=>{var r=$("#debugExprInput").val()+"";l.modal("hide"),Cu(r)})}function Tu(){var l=A.saveState&&A.saveState(),t=l.c;console.log(t,l);var r="";return t.PC&&(r+="c.PC == 0x"+Le(t.PC)+`
`),t.SP&&(r+="c.SP < 0x"+Le(t.SP)+`
`),t.HL&&(r+=`c.HL == 0x4000
`),A.readAddress&&(r+=`this.readAddress(0x1234) == 0x0
`),A.readVRAMAddress&&(r+=`this.readVRAMAddress(0x1234) != 0x80
`),A.getRasterScanline&&(r+=`this.getRasterScanline() > 222
`),r}function Cu(l){var t=new Function("c","return ("+l+");").bind(A);It(),A.runEval(t),lo=l}function _o(){A.isRunning()?(ge.tick(),_n=!1):_n||(ge.tick(),_n=!0),setTimeout(_o,100)}function Oe(l){l?(Xt(0),$("#pleaseWaitModal").modal("show")):(Xt(1),$("#pleaseWaitModal").modal("hide"))}function Xt(l){$("#pleaseWaitProgressBar").css("width",l*100+"%").show()}var ss=!1;function ku(){ss||Rt("lib/gif.js").then(()=>{var l=$("#emulator").find("canvas")[0];if(!l){Ee("Could not find canvas element to record video!");return}var t=0;l.style&&l.style.transform&&(l.style.transform.indexOf("rotate(-90deg)")>=0?t=-1:l.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",y=>{Xt(y)}),r.on("finished",y=>{a.attr("src",URL.createObjectURL(y)),Oe(!1),Ot(),$("#videoPreviewModal").modal("show")});var u=20,d=300,m=0;console.log("Recording video",l),$("#emulator").css("backgroundColor","#cc3333");var b=()=>{m++>d?(console.log("Rendering video"),$("#emulator").css("backgroundColor","inherit"),Oe(!0),Yt(),r.render(),ss=!1):(r.addFrame(l,{delay:u,copy:!0}),setTimeout(b,u),ss=!0)};b()})}function Pn(l){A.setFrameRate(l),l>.01?$("#fps_label").text(l.toFixed(2)):$("#fps_label").text("1/"+Math.round(1/l))}function Pu(){var l=A.getFrameRate();l=l/2,l>1e-5&&Pn(l)}function Au(){var l=A.getFrameRate();l=Math.min(60,l*2),Pn(l)}function Du(){Pn(60/65536)}function Lu(){Ot(),Pn(60)}function Fu(){ge.refresh(!1);var l=ge.getActive();if(l.getSourceFile&&l.setTimingResult){var t=A.newCodeAnalyzer();t.showLoopTimingForPC(0),l.setTimingResult(t)}}function os(){Ir&&(A.setRecorder(null),$("#dbg_record").removeClass("btn_recording"),$("#replaydiv").hide(),xo(),Ir=!1)}function To(){Ir&&lt.reset()}function Co(){lt.reset(),A.setRecorder(lt),$("#dbg_record").addClass("btn_recording"),$("#replaydiv").show(),Ir=!0}function Ru(){Ir?os():Co()}function Qt(l,t,r){var a=ge.getActive();a&&a.insertText?bootbox.prompt({title:"Add "+At.sanitize(l)+" File to Project",value:"filename"+At.sanitize(t),callback:u=>{if(u&&u.trim().length>0){if(!es(u))return;var d=u,m=`
`+r(u)+`
`;fe.loadFiles([d]).then(b=>{b&&b.length?Ee(u+" already exists; including anyway"):fe.updateFile(d,`
`),a.insertText(m),_i()})}}}):Ee("Can't insert text in this window -- switch back to main file")}function Iu(){var l=it(),t=A.getToolForFilename(l);l.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?Qt("Header",".h",r=>'#include "'+r+'"'):t=="dasm"||t=="zmac"?Qt("Include",".inc",r=>' include "'+r+'"'):t=="ca65"||t=="sdasz80"||t=="vasm"||t=="armips"?Qt("Include",".inc",r=>' .include "'+r+'"'):t=="verilator"?Qt("Verilog",".v",r=>'`include "'+r+'"'):t=="wiz"?Qt("Include",".wiz",r=>'import "'+r+'";'):t=="ecs"?Qt("Include",".ecs",r=>'import "'+r+'"'):t=="acme"?Qt("Include",".acme",r=>'!src "'+r+'"'):Ee("Can't add include file to this project type ("+t+")")}function Mu(){var l=it(),t=A.getToolForFilename(l);l.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?Qt("Linked C (or .s)",".c",r=>'//#link "'+r+'"'):l.endsWith("asm")||l.endsWith(".s")||t=="ca65"||t=="lwasm"?Qt("Linked ASM",".inc",r=>';#link "'+r+'"'):Ee("Can't add linked file to this project type ("+t+")")}function Nu(){if(Ye=new ln($("#toolbar")[0],null),Ye.grp.prop("id","run_bar"),Ye.add("ctrl+alt+r","Reset","glyphicon-refresh",Eu).prop("id","dbg_reset"),Ye.add("ctrl+alt+,","Pause","glyphicon-pause",pu).prop("id","dbg_pause"),Ye.add("ctrl+alt+.","Resume","glyphicon-play",Eo).prop("id","dbg_go"),A.restartAtPC&&Ye.add("ctrl+alt+/","Restart at Cursor","glyphicon-play-circle",bu).prop("id","dbg_restartatline"),Ye.newGroup(),Ye.grp.prop("id","debug_bar"),A.runEval&&Ye.add("ctrl+alt+e","Reset and Debug","glyphicon-fast-backward",Su).prop("id","dbg_restart"),A.stepBack&&Ye.add("ctrl+alt+b","Step Backwards","glyphicon-step-backward",wu).prop("id","dbg_stepback"),A.step&&Ye.add("ctrl+alt+s","Single Step","glyphicon-step-forward",gu).prop("id","dbg_step"),A.stepOver&&Ye.add("ctrl+alt+t","Step Over","glyphicon-hand-right",mu).prop("id","dbg_stepover"),A.runUntilReturn&&Ye.add("ctrl+alt+o","Step Out of Subroutine","glyphicon-hand-up",xu).prop("id","dbg_stepout"),A.runToVsync&&Ye.add("ctrl+alt+n","Next Frame/Interrupt","glyphicon-forward",vu).prop("id","dbg_tovsync"),(A.runEval||A.runToPC)&&!ne.startsWith("verilog")&&Ye.add("ctrl+alt+l","Run To Line","glyphicon-save",yu).prop("id","dbg_toline"),Ye.newGroup(),Ye.grp.prop("id","xtra_bar"),$(".dropdown-menu").collapse({toggle:!1}),$("#item_new_file").click(Al),$("#item_upload_file").click(Dl),$("#item_open_directory").click(Fl),$("#item_github_login").click(Nl),$("#item_github_logout").click(Ol),$("#item_github_import").click($l),$("#item_github_publish").click(Wl),$("#item_github_push").click(Bl),$("#item_github_pull").click(Ul),$("#item_repo_delete").click(Hl),$("#item_share_file").click(Vl),$("#item_reset_file").click(Kl),$("#item_rename_file").click(eu),$("#item_delete_file").click(Zl),A.runEval?$("#item_debug_expr").click(_u).show():$("#item_debug_expr").hide(),$("#item_download_rom").click(tu),$("#item_download_file").click(ru),$("#item_download_zip").click(iu),A.getDebugSymbolFile?$("#item_download_sym").click(nu):$("#item_download_sym").hide(),$("#item_download_allzip").click(au),$("#item_record_video").click(ku),po()?$("#item_export_cassette").click(Jl):$("#item_export_cassette").hide(),A.setFrameRate&&A.getFrameRate&&($("#dbg_slower").click(Pu),$("#dbg_faster").click(Au),$("#dbg_slowest").click(Du),$("#dbg_fastest").click(Lu)),$("#item_addfile_include").click(Iu),$("#item_addfile_link").click(Mu),$("#item_request_persist").click(()=>Ja(!0,!1)),_o(),A.newCodeAnalyzer&&Ye.add(null,"Analyze CPU Timing","glyphicon-time",Fu),A.setRecorder&&A.advance&&Ou(),A.showHelp){let{li:r,a}=Ka("help__"+ne,Ya+" Help");$("#help_menu").append(r),$(a).click(()=>window.open(A.showHelp(),"_8bws_help"))}let l=A.getToolForFilename(it()),t=yl[l];if(t){let{li:r,a}=Ka("help__"+l,l+" Help");$("#help_menu").append(r),$(a).click(()=>window.open(t,"_8bws_help"))}}function Ou(){var l=$("#replayslider"),t=$("#clockslider"),r=$("#replay_frame"),a=$("#replay_clock");A.advanceFrameClock||$("#clockdiv").hide();var u=()=>{r.text(lt.lastSeekFrame+""),a.text(lt.lastSeekStep+"")},d=y=>{Yt();var L=parseInt(l.val().toString()),W=parseInt(t.val().toString());lt.loadFrame(L,W)>=0&&(t.attr("min",0),t.attr("max",lt.lastStepCount),u(),kn(A.saveState()))},m=y=>{Yt(),lt.loadFrame(y)>=0&&(l.val(y),u(),kn(A.saveState()))},b=y=>{Yt();var L=parseInt(l.val().toString());lt.loadFrame(L,y)>=0&&(t.val(y),u(),kn(A.saveState()))};lt.callbackStateChanged=()=>{l.attr("min",0),l.attr("max",lt.numFrames()),l.val(lt.currentFrame()),t.val(lt.currentStep()),u(),Pi(A.saveState())},l.on("input",d),t.on("input",d),$("#replay_min").click(()=>{m(1)}),$("#replay_max").click(()=>{m(lt.numFrames())}),$("#replay_back").click(()=>{m(parseInt(l.val().toString())-1)}),$("#replay_fwd").click(()=>{m(parseInt(l.val().toString())+1)}),$("#clock_back").click(()=>{b(parseInt(t.val().toString())-1)}),$("#clock_fwd").click(()=>{b(parseInt(t.val().toString())+1)}),$("#replay_bar").show(),Ye.add("ctrl+alt+0","Start/Stop Replay Recording","glyphicon-record",Ru).prop("id","dbg_record")}function $u(){try{var l=window.screen.orientation||window.screen.msOrientation||window.screen.mozOrientation||null;if(l){if(l.type.indexOf("landscape")!==-1)return!0;if(l.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 Wu(){if(wr.shouldCompleteTour()){await Rt("lib/bootstrap-tourist.js");var l=ne.startsWith("vcs"),t=[{element:"#platformsMenuButton",placement:"right",title:"Platform Selector",content:`You're currently on the "<b>`+ne+'</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:l?"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."}];$u()||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!"})),yi&&(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:()=>{wr.completedTour()}});setTimeout(()=>{r.start()},2500)}}function An(l){var t=(l.message||l.error||l)+"";if(t.indexOf("QuotaExceededError")>=0)Ja(!1,!1);else{var r=l.error||l.reason;r!=null&&r instanceof fa&&Bu(r)}}function Bu(l){console.log("haltEmulation"),Yt(),tc(l)}function Uu(){window.addEventListener("error",An),window.addEventListener("unhandledrejection",An)}function ko(){window.removeEventListener("error",An),window.removeEventListener("unhandledrejection",An)}function Mr(l){ko(),l?window.location.replace("?"+$.param(ee)):window.location.href="?"+$.param(ee)}function Dn(){ne&&(ee.platform=ne),delete ee[""],history.replaceState({},"","?"+$.param(ee))}function ju(){var l=!1;document.addEventListener("visibilitychange",()=>{document.visibilityState=="hidden"&&A&&A.isRunning()?(Yt(),l=!0):document.visibilityState=="visible"&&l&&(Ot(),l=!1)}),$(window).on("focus",()=>{l&&(Ot(),l=!1)}),$(window).on("blur",()=>{A&&A.isRunning()&&(Yt(),l=!0)}),$(window).on("orientationchange",()=>{A&&A.resize&&setTimeout(A.resize.bind(A),200)})}function Hu(){var l=$(document).find(".emucontrols-"+Lr(ne));ne.endsWith(".mame")&&l.show();var t=$("#emulator").find("canvas");t&&(t.on("focus",()=>{A.isRunning()&&(l.fadeIn(200),A.pause(),A.resume())}),t.on("blur",()=>{l.fadeOut(200)}))}function zu(){window.ga&&($(".dropdown-item").click(l=>{l.target&&l.target.id&&Si("menu",l.target.id)}),ga("send","pageview",location.pathname+"?platform="+ne+(je?"&repo="+je:"&file="+ee.file)))}async function Vu(){if(!ca[ne])throw Error("Invalid platform '"+ne+"'.");let l=$("#emuscreen")[0],t=ua(ee.options||"");if(A=new ca[ne](l,t),Ju(),lt=new Ms(A),En=A.getPresets?A.getPresets():[],!ee.file){var r=wr.getLastPreset(),a=r||(je?null:En[0].id);ee.file=a||"DEFAULT",a||Ee("There is no default main file for this project. Try selecting one from the pulldown.")}ne=="vcs"&&ee.file.startsWith("examples/")&&!ee.file.endsWith(".a")&&(ee.file+=".a"),Dn(),Uu(),zu(),await A.start(),await du(),await _l(),await kl(ee.file),A.sourceFileFetch=u=>fe.filedata[u],Nu(),ju(),Hu(),ot?qu():(Ci(),Gu(),Wu()),Po()}function qu(){$("#dropdownMenuButton").hide(),$("#platformsMenuButton").hide(),$("#booksMenuButton").hide()}function Gu(){Lr(ne)=="nes"?$(".book-nes").addClass("book-active"):Lr(ne)=="vcs"?$(".book-vcs").addClass("book-active"):Lr(ne)=="verilog"?$(".book-verilog").addClass("book-active"):A.getToolForFilename(it())=="sdcc"&&$(".book-arcade").addClass("book-active")}function Po(){setTimeout(()=>{$("#controls_dynamic").css("visibility","inherit")},250)}function Yu(){var l="workspace-split3-"+ne;ot&&(l="embed-"+l);var t;ne.startsWith("vcs")?t=[0,50,50]:ot||hi?t=[0,55,45]:t=[12,44,44];var r=Tt&&localStorage.getItem(l);if(r)try{t=JSON.parse(r)}catch(u){console.log(u)}var a=vl(["#sidebar","#workspace","#emulator"],{sizes:t,minSize:[0,250,250],onDrag:()=>{A&&A.resize&&A.resize()},onDragEnd:()=>{Tt&&localStorage.setItem(l,JSON.stringify(a.getSizes())),ge&&ge.resize()}})}function Xu(l){let t=Fr(ee.ignore)||ot;Oe(!0),sn(l,async r=>{if(r){var a=_t(l);console.log("Importing "+r.length+" bytes as "+a);try{var u=await Je.getItem(a);Oe(!1),u!=null&&t||(u==null||confirm("Replace existing file '"+a+"'?"))&&await Je.setItem(a,r),delete ee.importURL,ee.file=a,Dn(),Do()}finally{Oe(!1)}}else Ee("Could not load source code from URL: "+l),Oe(!1)},"text")}async function Qu(){var l=Fr(ee.ignore),t=Fr(ee.force);ot?l=!t:t=!1;for(var r=0;r<20;r++){let u=ee["file"+r+"_name"],d=ee["file"+r+"_data"];if(u==null||d==null)break;var a=await Je.getItem(u);if(!(l&&a)){let m=d;ee["file"+r+"_type"]=="binary"&&(m=tn(atob(m))),(!a||t||confirm("Replace existing file '"+u+"'?"))&&await Je.setItem(u,m)}r==0&&(ee.file=u),delete ee["file"+r+"_name"],delete ee["file"+r+"_data"],delete ee["file"+r+"_type"]}delete ee.ignore,delete ee.force,Dn()}function Ju(){var l=A.getPlatformName&&A.getPlatformName(),t=$('a[href="?platform='+ne+'"]');t.length&&(t.addClass("dropdown-item-checked"),l=l||t.text()||l),Ya=l||ne,$(".platform_name").text(Ya)}function Ku(){if(ne=ee.platform||wr.getLastPlatformID(),je=ee.repo,!ee.repo&&!ee.file&&(je=wr.getLastRepoID(ne)),Tt&&je&&je!=="/"){var l=di()[je];l&&(console.log(ne,ee,l),ee.repo=je,l.platform_id&&!ee.platform&&(ee.platform=ne=l.platform_id),l.mainPath&&!ee.file&&(ee.file=l.mainPath))}else je="",delete ee.repo;ne||(ot&&xl("The 'platform' must be specified when embed=1"),ne=ee.platform="vcs")}async function Ao(){if(ee.githubURL){rs(ee.githubURL,!0);return}if(Ku(),Yu(),xr=je||vt(ne),ot&&(xr=(document.referrer||document.location.href)+xr),Je=xa(xr),ee.importURL){Xu(ee.importURL);return}ee.file0_name&&await Qu(),Do()}async function Do(){try{var l=await Ns(Lr(ne));console.log("starting platform",ne),await Vu(),document.title=document.title+" ["+ne+"] - "+(je?"["+je+"] - ":"")+fe.mainPath}catch(t){console.log(t),Ee('Platform "'+ne+'" failed to load.')}finally{Po()}}var ls="__use_https";function Lo(l){document.cookie=ls+"="+l+";domain=8bitworkshop.com;path=/;max-age=315360000"}function Zu(){var l=fo(ls);if(typeof l=="string")return!!l;var t=Tt&&!localStorage.getItem("__lastplatform")?1:0;return Lo(t),!!t}function ec(){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>',l=>{l&&(Lo(1),Fo())})}function Fo(){window.location.protocol=="http:"&&window.location.host=="8bitworkshop.com"&&(Zu()?(ko(),window.location.replace(window.location.href.replace(/^http:/,"https:"))):$("#item_switch_https").click(ec).show())}Fo();function Pf(l,t){A.writeFile(l,t)}function Af(l){return A.readFile(l)}function Df(){return A.saveState()}function tc(l){var t=l&&l.message||t;yo(l,t),ge.refresh(!1),A.saveState&&Pi(A.saveState())}async function Lf(l){var t=fe.filedata[l];t!=null&&(ge.updateFile(l,await alternateLocalFilesystem.getFileData(l)),console.log("updating file",l))}function rc(){if(yi&&Xe instanceof Uint8Array){var l=ft(it()),t=A.getROMExtension&&A.getROMExtension(Xe)||"-"+vt(ne)+".bin";alternateLocalFilesystem.setFileData(`bin/${l}${t}`,Xe)}}function Ff(l){var t=ge.getActive();if(t instanceof pi){var r=t.editor.getSearchCursor(l);r.findNext()&&t.editor.setSelection(r.pos.to,r.pos.from)}}function ic(){let l=!1;new IntersectionObserver((r,a)=>{for(var u of r)u.isIntersecting&&!l&&(Ao(),l=!0),u.intersectionRatio==0&&ns()&&A.isRunning()&&Yt(),u.intersectionRatio>0&&ns()&&!A.isRunning()&&Ot()},{}).observe($("#emulator")[0])}typeof process=="undefined"&&(ot&&typeof IntersectionObserver=="function"?ic():Ao());export{Vs as a,ee as b,ne as c,xr as d,je as e,A as f,fe as g,ge as h,dt as i,ir as j,It as k,gi as l,Ai as m,Pn as n,Bu as o,Yu as p,Ku as q,Ao as r,Pf as s,Af as t,Df as u,tc as v,Lf as w,Ff as x};
/*!
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.6.3
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2022-12-20T21:28Z
*/
//# sourceMappingURL=chunk-GBRUOVY7.js.map