@dodona/papyros 0.1.62 → 0.1.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.js +1 -0
- package/dist/Backend.d.ts +16 -6
- package/dist/Backend.js +1 -0
- package/dist/BackendManager.d.ts +10 -1
- package/dist/BackendManager.js +1 -0
- package/dist/CodeEditor.d.ts +86 -0
- package/dist/CodeEditor.js +1 -0
- package/dist/Constants.d.ts +17 -16
- package/dist/Constants.js +1 -0
- package/dist/InputManager.d.ts +24 -16
- package/dist/InputManager.js +1 -0
- package/dist/{inputServiceWorker.js → InputServiceWorker.js} +1 -1
- package/dist/{library.d.ts → Library.d.ts} +3 -2
- package/dist/Library.js +1 -0
- package/dist/OutputManager.d.ts +59 -5
- package/dist/OutputManager.js +1 -0
- package/dist/Papyros.d.ts +176 -33
- package/dist/Papyros.js +1 -0
- package/dist/PapyrosEvent.d.ts +19 -3
- package/dist/PapyrosEvent.js +1 -0
- package/dist/ProgrammingLanguage.d.ts +3 -0
- package/dist/ProgrammingLanguage.js +1 -0
- package/dist/RunListener.d.ts +13 -0
- package/dist/RunListener.js +1 -0
- package/dist/RunStateManager.d.ts +67 -0
- package/dist/RunStateManager.js +1 -0
- package/dist/Translations.js +1 -0
- package/dist/examples/Examples.js +1 -0
- package/dist/examples/JavaScriptExamples.js +1 -0
- package/dist/examples/PythonExamples.js +1 -0
- package/dist/input/BatchInputHandler.d.ts +32 -0
- package/dist/input/BatchInputHandler.js +1 -0
- package/dist/input/InteractiveInputHandler.d.ts +28 -0
- package/dist/input/InteractiveInputHandler.js +1 -0
- package/dist/input/UserInputHandler.d.ts +70 -0
- package/dist/input/UserInputHandler.js +1 -0
- package/dist/util/HTMLShapes.d.ts +13 -0
- package/dist/util/HTMLShapes.js +1 -0
- package/dist/util/Logging.d.ts +9 -0
- package/dist/util/Logging.js +1 -0
- package/dist/util/Util.d.ts +94 -2
- package/dist/util/Util.js +1 -0
- package/dist/workers/input/InputWorker.d.ts +19 -3
- package/dist/workers/input/InputWorker.js +1 -0
- package/dist/workers/python/Pyodide.d.ts +19 -0
- package/dist/workers/python/Pyodide.js +1 -0
- package/package.json +6 -5
- package/dist/StatusPanel.d.ts +0 -8
- package/dist/index.js +0 -2
- package/dist/index.js.LICENSE.txt +0 -7
package/dist/Backend.d.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { PapyrosEvent } from "./PapyrosEvent";
|
|
2
2
|
import { Channel } from "sync-message";
|
|
3
3
|
export declare abstract class Backend {
|
|
4
|
-
onEvent: (e: PapyrosEvent) => any;
|
|
5
|
-
runId: number;
|
|
4
|
+
protected onEvent: (e: PapyrosEvent) => any;
|
|
5
|
+
protected runId: number;
|
|
6
|
+
/**
|
|
7
|
+
* Constructor is limited as it is meant to be used as a WebWorker
|
|
8
|
+
* These are then exposed via Comlink. Proper initialization occurs
|
|
9
|
+
* in the launch method when the worker is started
|
|
10
|
+
*/
|
|
6
11
|
constructor();
|
|
7
12
|
/**
|
|
8
|
-
* Initialize the backend
|
|
13
|
+
* Initialize the backend by doing all setup-related work
|
|
9
14
|
* @param {function(PapyrosEvent):void} onEvent Callback for when events occur
|
|
10
15
|
* @param {Channel} channel for communication with the main thread
|
|
11
16
|
* @return {Promise<void>} Promise of launching
|
|
12
17
|
*/
|
|
13
18
|
launch(onEvent: (e: PapyrosEvent) => void, channel: Channel): Promise<void>;
|
|
14
|
-
abstract _runCodeInternal(code: string): Promise<any>;
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
20
|
+
* Internal helper method that actually executes the code
|
|
21
|
+
* Results or Errors must be passed by using the onEvent-callback
|
|
22
|
+
* @param code The code to run
|
|
23
|
+
*/
|
|
24
|
+
protected abstract _runCodeInternal(code: string): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Executes the given code
|
|
17
27
|
* @param {string} code The code to run
|
|
18
28
|
* @param {string} runId The uuid for this execution
|
|
19
29
|
* @return {Promise<void>} Promise of execution
|
|
20
30
|
*/
|
|
21
|
-
runCode(code: string, runId: number): Promise<
|
|
31
|
+
runCode(code: string, runId: number): Promise<any>;
|
|
22
32
|
}
|
package/dist/Backend.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Papyros=t():e.Papyros=t()}(self,(function(){return(()=>{var e={13:function(e,t,r){var n,o;o=this,n=function(){return function(e){"use strict";var t=e&&e.I18n||{},r=Array.prototype.slice,n=function(e){return("0"+e.toString()).substr(-2)},o=function(e,t){return h("round",e,-t).toFixed(t)},a=function(e){var t=typeof e;return"function"===t||"object"===t},i=function(e){return"function"==typeof e},u=function(e){return null!=e},s=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},l=function(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)},c=function(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)},f=function(e){return!0===e||!1===e},p=function(e){return null===e},h=function(e,t,r){return void 0===r||0==+r?Math[e](t):(t=+t,r=+r,isNaN(t)||"number"!=typeof r||r%1!=0?NaN:(t=t.toString().split("e"),+((t=(t=Math[e](+(t[0]+"e"+(t[1]?+t[1]-r:-r)))).toString().split("e"))[0]+"e"+(t[1]?+t[1]+r:r))))},d=function(e,t){return i(e)?e(t):e},m=function(e,t){var r,n;for(r in t)t.hasOwnProperty(r)&&(n=t[r],l(n)||c(n)||f(n)||s(n)||p(n)?e[r]=n:(null==e[r]&&(e[r]={}),m(e[r],n)));return e},y={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},g={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},v={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},b={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},S=[null,"kb","mb","gb","tb"],w={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return t.reset=function(){var e;for(e in w)this[e]=w[e]},t.initializeOptions=function(){var e;for(e in w)u(this[e])||(this[e]=w[e])},t.initializeOptions(),t.locales={},t.locales.get=function(e){var r=this[e]||this[t.locale]||this.default;return i(r)&&(r=r(e)),!1===s(r)&&(r=[r]),r},t.locales.default=function(e){var r=[],n=[];return e&&r.push(e),!e&&t.locale&&r.push(t.locale),t.fallbacks&&t.defaultLocale&&r.push(t.defaultLocale),r.forEach((function(e){var r=e.split("-"),o=null,a=null;3===r.length?(o=[r[0],r[1]].join("-"),a=r[0]):2===r.length&&(o=r[0]),-1===n.indexOf(e)&&n.push(e),t.fallbacks&&[o,a].forEach((function(t){null!=t&&t!==e&&-1===n.indexOf(t)&&n.push(t)}))})),r.length||r.push("en"),n},t.pluralization={},t.pluralization.get=function(e){return this[e]||this[t.locale]||this.default},t.pluralization.default=function(e){switch(e){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},t.currentLocale=function(){return this.locale||this.defaultLocale},t.isSet=u,t.lookup=function(e,t){t=t||{};var r,n,o,a,i=this.locales.get(t.locale).slice();for(o=this.getFullScope(e,t);i.length;)if(r=i.shift(),n=o.split(t.separator||this.defaultSeparator),a=this.translations[r]){for(;n.length&&null!=(a=a[n.shift()]););if(null!=a)return a}if(u(t.defaultValue))return d(t.defaultValue,e)},t.pluralizationLookupWithoutFallback=function(e,t,r){var n,o,i=this.pluralization.get(t)(e);if(a(r))for(;i.length;)if(n=i.shift(),u(r[n])){o=r[n];break}return o},t.pluralizationLookup=function(e,t,r){r=r||{};var n,o,i,s,l=this.locales.get(r.locale).slice();for(t=this.getFullScope(t,r);l.length;)if(n=l.shift(),o=t.split(r.separator||this.defaultSeparator),i=this.translations[n]){for(;o.length&&(i=i[o.shift()],a(i));)0===o.length&&(s=this.pluralizationLookupWithoutFallback(e,n,i));if(null!=s)break}return null==s&&u(r.defaultValue)&&(s=a(r.defaultValue)?this.pluralizationLookupWithoutFallback(e,r.locale,r.defaultValue):r.defaultValue,i=r.defaultValue),{message:s,translations:i}},t.meridian=function(){var e=this.lookup("time"),t=this.lookup("date");return e&&e.am&&e.pm?[e.am,e.pm]:t&&t.meridian?t.meridian:y.meridian},t.prepareOptions=function(){for(var e,t=r.call(arguments),n={};t.length;)if("object"==typeof(e=t.shift()))for(var o in e)e.hasOwnProperty(o)&&(u(n[o])||(n[o]=e[o]));return n},t.createTranslationOptions=function(e,t){var r=[{scope:e}];return u(t.defaults)&&(r=r.concat(t.defaults)),u(t.defaultValue)&&r.push({message:t.defaultValue}),r},t.translate=function(e,t){t=t||{};var r,n=this.createTranslationOptions(e,t),o=e,i=this.prepareOptions(t);return delete i.defaultValue,n.some((function(t){if(u(t.scope)?(o=t.scope,r=this.lookup(o,i)):u(t.message)&&(r=d(t.message,e)),null!=r)return!0}),this)?("string"==typeof r?r=this.interpolate(r,t):s(r)?r=r.map((function(e){return"string"==typeof e?this.interpolate(e,t):e}),this):a(r)&&u(t.count)&&(r=this.pluralize(t.count,o,t)),r):this.missingTranslation(e,t)},t.interpolate=function(e,t){if(null==e)return e;t=t||{};var r,n,o,a,i=e.match(this.placeholder);if(!i)return e;for(;i.length;)o=(r=i.shift()).replace(this.placeholder,"$1"),n=u(t[o])?t[o].toString().replace(/\$/gm,"_#$#_"):o in t?this.nullPlaceholder(r,e,t):this.missingPlaceholder(r,e,t),a=new RegExp(r.replace(/{/gm,"\\{").replace(/}/gm,"\\}")),e=e.replace(a,n);return e.replace(/_#\$#_/g,"$")},t.pluralize=function(e,t,r){var n,o;return r=this.prepareOptions({count:String(e)},r),void 0===(o=this.pluralizationLookup(e,t,r)).translations||null==o.translations?this.missingTranslation(t,r):void 0!==o.message&&null!=o.message?this.interpolate(o.message,r):(n=this.pluralization.get(r.locale),this.missingTranslation(t+"."+n(e)[0],r))},t.missingTranslation=function(e,t){if("guess"===this.missingBehaviour){var r=e.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+r.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(e,t,r){return t+" "+r.toLowerCase()}))}return'[missing "'+[null!=t&&null!=t.locale?t.locale:this.currentLocale(),this.getFullScope(e,t)].join(t.separator||this.defaultSeparator)+'" translation]'},t.missingPlaceholder=function(e,t,r){return"[missing "+e+" value]"},t.nullPlaceholder=function(){return t.missingPlaceholder.apply(t,arguments)},t.toNumber=function(e,t){t=this.prepareOptions(t,this.lookup("number.format"),g);var r,n,a=e<0,i=o(Math.abs(e),t.precision).toString().split("."),u=[],s=t.format||"%n",l=a?"-":"";for(e=i[0],r=i[1];e.length>0;)u.unshift(e.substr(Math.max(0,e.length-3),3)),e=e.substr(0,e.length-3);return n=u.join(t.delimiter),t.strip_insignificant_zeros&&r&&(r=r.replace(/0+$/,"")),t.precision>0&&r&&(n+=t.separator+r),n=(s=t.sign_first?"%s"+s:s.replace("%n","%s%n")).replace("%u",t.unit).replace("%n",n).replace("%s",l)},t.toCurrency=function(e,t){return t=this.prepareOptions(t,this.lookup("number.currency.format",t),this.lookup("number.format",t),v),this.toNumber(e,t)},t.localize=function(e,t,r){switch(r||(r={}),e){case"currency":return this.toCurrency(t,r);case"number":return e=this.lookup("number.format",r),this.toNumber(t,e);case"percentage":return this.toPercentage(t,r);default:var n;return n=e.match(/^(date|time)/)?this.toTime(e,t,r):t.toString(),this.interpolate(n,r)}},t.parseDate=function(e){var t,r,n;if(null==e)return e;if("object"==typeof e)return e;if(t=e.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/)){for(var o=1;o<=6;o++)t[o]=parseInt(t[o],10)||0;t[2]-=1,n=t[7]?1e3*("0"+t[7]):null,r=t[8]?new Date(Date.UTC(t[1],t[2],t[3],t[4],t[5],t[6],n)):new Date(t[1],t[2],t[3],t[4],t[5],t[6],n)}else"number"==typeof e?(r=new Date).setTime(e):e.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)?(r=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(e.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/),(r=new Date).setTime(Date.parse(e)));return r},t.strftime=function(e,r,o){o=this.lookup("date",o);var a=t.meridian();if(o||(o={}),o=this.prepareOptions(o,y),isNaN(e.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var i=e.getDay(),u=e.getDate(),s=e.getFullYear(),l=e.getMonth()+1,c=e.getHours(),f=c,p=c>11?1:0,h=e.getSeconds(),d=e.getMinutes(),m=e.getTimezoneOffset(),g=Math.floor(Math.abs(m/60)),v=Math.abs(m)-60*g,b=(m>0?"-":"+")+(g.toString().length<2?"0"+g:g)+(v.toString().length<2?"0"+v:v);return f>12?f-=12:0===f&&(f=12),r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=r.replace("%a",o.abbr_day_names[i])).replace("%A",o.day_names[i])).replace("%b",o.abbr_month_names[l])).replace("%B",o.month_names[l])).replace("%d",n(u))).replace("%e",u)).replace("%-d",u)).replace("%H",n(c))).replace("%-H",c)).replace("%k",c)).replace("%I",n(f))).replace("%-I",f)).replace("%l",f)).replace("%m",n(l))).replace("%-m",l)).replace("%M",n(d))).replace("%-M",d)).replace("%p",a[p])).replace("%P",a[p].toLowerCase())).replace("%S",n(h))).replace("%-S",h)).replace("%w",i)).replace("%y",n(s))).replace("%-y",n(s).replace(/^0+/,""))).replace("%Y",s)).replace("%z",b)).replace("%Z",b)},t.toTime=function(e,t,r){var n=this.parseDate(t),o=this.lookup(e,r);if(null==n)return n;var a=n.toString();return a.match(/invalid/i)?a:o?this.strftime(n,o,r):a},t.toPercentage=function(e,t){return t=this.prepareOptions(t,this.lookup("number.percentage.format",t),this.lookup("number.format",t),b),this.toNumber(e,t)},t.toHumanSize=function(e,t){for(var r,n,o,a=1024,i=e,u=0;i>=a&&u<4;)i/=a,u+=1;return 0===u?(o=this.getFullScope("number.human.storage_units.units.byte",t),r=this.t(o,{count:i}),n=0):(o=this.getFullScope("number.human.storage_units.units."+S[u],t),r=this.t(o),n=i-Math.floor(i)==0?0:1),t=this.prepareOptions(t,{unit:r,precision:n,format:"%n%u",delimiter:""}),this.toNumber(i,t)},t.getFullScope=function(e,t){return t=t||{},s(e)&&(e=e.join(t.separator||this.defaultSeparator)),t.scope&&(e=[t.scope,e].join(t.separator||this.defaultSeparator)),e},t.extend=function(e,t){return void 0===e&&void 0===t?{}:m(e,t)},t.t=t.translate.bind(t),t.l=t.localize.bind(t),t.p=t.pluralize.bind(t),t}(o)}.call(t,r,t,e),void 0===n||(e.exports=n)},137:e=>{self,e.exports=(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{serviceWorkerFetchListener:()=>s,asyncSleep:()=>l,ServiceWorkerError:()=>f,writeMessageAtomics:()=>p,writeMessageServiceWorker:()=>h,writeMessage:()=>d,makeChannel:()=>m,makeAtomicsChannel:()=>y,makeServiceWorkerChannel:()=>g,readMessage:()=>b,syncSleep:()=>S,uuidv4:()=>c});var r,n=(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function u(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}s((n=n.apply(e,t||[])).next())}))},a=function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},i="__SyncMessageServiceWorkerInput__",u="__sync-message-v2__";function s(){var e={},t={};return function(r){var n=r.request.url;return!!n.includes(i)&&(r.respondWith(function(){return o(this,void 0,void 0,(function(){function o(e){var t={message:e,version:u};return new Response(JSON.stringify(t),{status:200})}var i,s,l,c,f,p,h,d;return a(this,(function(a){switch(a.label){case 0:return n.endsWith("/read")?[4,r.request.json()]:[3,5];case 1:return i=a.sent(),s=i.messageId,l=i.timeout,(c=e[s])?(delete e[s],[2,o(c)]):[3,2];case 2:return[4,new Promise((function(e){t[s]=e,setTimeout((function(){delete t[s],e(new Response("",{status:408}))}),l)}))];case 3:return[2,a.sent()];case 4:return[3,8];case 5:return n.endsWith("/write")?[4,r.request.json()]:[3,7];case 6:return f=a.sent(),p=f.message,h=f.messageId,(d=t[h])?(d(o(p)),delete t[h]):e[h]=p,[2,o({early:!d})];case 7:if(n.endsWith("/version"))return[2,new Response(u,{status:200})];a.label=8;case 8:return[2]}}))}))}()),!0)}}function l(e){return new Promise((function(t){return setTimeout(t,e)}))}var c,f=function(e){function t(r,n){var o=e.call(this,"Received status ".concat(n," from ").concat(r,". Ensure the service worker is registered and active."))||this;return o.url=r,o.status=n,Object.setPrototypeOf(o,t.prototype),o}return n(t,e),t}(Error);function p(e,t){var r=(new TextEncoder).encode(JSON.stringify(t)),n=e.data,o=e.meta;if(r.length>n.length)throw"Input is too long";n.set(r,0),Atomics.store(o,0,r.length),Atomics.store(o,1,1),Atomics.notify(o,1)}function h(e,t,r){return o(this,void 0,void 0,(function(){var n,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:return[4,navigator.serviceWorker.ready];case 1:a.sent(),n=e.baseUrl+"/write",o=Date.now(),a.label=2;case 2:return i={message:t,messageId:r},[4,fetch(n,{method:"POST",body:JSON.stringify(i)})];case 3:return s=a.sent(),(c=200===s.status)?[4,s.json()]:[3,5];case 4:c=a.sent().version===u,a.label=5;case 5:return c?[2]:Date.now()-o<e.timeout?[4,l(100)]:[3,7];case 6:return a.sent(),[3,2];case 7:throw new f(n,s.status);case 8:return[2]}}))}))}function d(e,t,r){return o(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return"atomics"!==e.type?[3,1]:(p(e,t),[3,3]);case 1:return[4,h(e,t,r)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function m(e){return void 0===e&&(e={}),"undefined"!=typeof SharedArrayBuffer?y(e.atomics):"serviceWorker"in navigator?g(e.serviceWorker):null}function y(e){var t=(void 0===e?{}:e).bufferSize;return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(t||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function g(e){return void 0===e&&(e={}),{type:"serviceWorker",baseUrl:(e.scope||"/")+i,timeout:e.timeout||5e3}}function v(e,t){return e>0?+e:t}function b(e,t,r){var n=void 0===r?{}:r,o=n.checkInterrupt,a=n.checkTimeout,i=n.timeout,s=performance.now();a=v(a,o?100:5e3);var l,c=v(i,Number.POSITIVE_INFINITY);if("atomics"===e.type){var p=e.data,h=e.meta;l=function(){if("timed-out"===Atomics.wait(h,1,0,a))return null;var e=Atomics.exchange(h,0,0),t=p.slice(0,e);Atomics.store(h,1,0);var r=(new TextDecoder).decode(t);return JSON.parse(r)}}else l=function(){var r=new XMLHttpRequest,n=e.baseUrl+"/read";r.open("POST",n,!1);var o={messageId:t,timeout:a};r.send(JSON.stringify(o));var i=r.status;if(408===i)return null;if(200===i){var l=JSON.parse(r.responseText);return l.version!==u?null:l.message}if(performance.now()-s<e.timeout)return null;throw new f(n,i)};for(;;){var d=c-(performance.now()-s);if(d<=0)return null;a=Math.min(a,d);var m=l();if(null!==m)return m;if(null==o?void 0:o())return null}}function S(e,t){if(e=v(e,0))if("undefined"!=typeof SharedArrayBuffer){var r=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));r[0]=0,Atomics.wait(r,0,0,e)}else b(t,"sleep ".concat(e," ").concat(c()),{timeout:e})}return c="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(e){var t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))},t})()},155:(e,t,r)=>{"use strict";r.d(t,{LogType:()=>n,papyrosLog:()=>i});var n,o=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},a=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){e[e.Debug=0]="Debug",e[e.Error=1]="Error",e[e.Important=2]="Important"}(n||(n={}));function i(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var i=e!==n.Debug;i&&(e===n.Error?console.error.apply(console,a([],o(t),!1)):console.log.apply(console,a([],o(t),!1)))}},924:(e,t,r)=>{"use strict";r.d(t,{parseEventData:()=>u});var n=r(13),o=r.n(n),a=(r(963),r(155)),i=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};o().t;function u(e){var t=e.data,r=i(e.contentType.split("/"),2),n=r[0],o=r[1];switch(n){case"text":switch(o){case"plain":return t;case"json":return JSON.parse(t)}break;case"img":if("png;base64"===o)return t}return(0,a.papyrosLog)(a.LogType.Important,"Unhandled content type: ".concat(e.contentType)),t}},963:e=>{}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{Backend:()=>i});var e=r(137),t=r(924),o=function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function u(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}s((n=n.apply(e,t||[])).next())}))},a=function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},i=function(){function r(){this.onEvent=function(){},this.runId=0}return r.prototype.launch=function(r,n){var o=this;return this.onEvent=function(a){return a.runId=o.runId,"input"===a.type?function(o){var a=(0,t.parseEventData)(o),i=(0,e.uuidv4)();return a.messageId=i,o.data=JSON.stringify(a),o.contentType="text/json",r(o),(0,e.readMessage)(n,i)}(a):r(a)},Promise.resolve()},r.prototype.runCode=function(e,t){return o(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return this.runId=t,[4,this._runCodeInternal(e)];case 1:return[2,r.sent()]}}))}))},r}()})(),n})()}));
|
package/dist/BackendManager.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { Remote } from "comlink";
|
|
2
2
|
import { Backend } from "./Backend";
|
|
3
3
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Start a backend for the given language, while storing the worker
|
|
6
|
+
* @param {ProgrammingLanguage} language The programming language supported by the backend
|
|
7
|
+
* @return {Remote<Backend>} A Comlink proxy for the Backend
|
|
8
|
+
*/
|
|
9
|
+
export declare function startBackend(language: ProgrammingLanguage): Remote<Backend>;
|
|
10
|
+
/**
|
|
11
|
+
* Stop a backend by terminating the worker and releasing memory
|
|
12
|
+
* @param {Remote<Backend>} backend The proxy for the backend to stop
|
|
13
|
+
*/
|
|
5
14
|
export declare function stopBackend(backend: Remote<Backend>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Papyros=t():e.Papyros=t()}(self,(function(){return(()=>{"use strict";var e={905:(e,t,r)=>{var n;r.d(t,{ProgrammingLanguage:()=>n}),function(e){e.Python="Python",e.JavaScript="JavaScript"}(n||(n={}))},477:e=>{e.exports=function(e,t,r,n){var a=self||window;try{try{var o;try{o=new a.Blob([e])}catch(t){(o=new(a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder)).append(e),o=o.getBlob()}var i=a.URL||a.webkitURL,s=i.createObjectURL(o),u=new a[t](s,r);return i.revokeObjectURL(s),u}catch(n){return new a[t]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch(e){if(!n)throw Error("Inline worker is not supported");return new a[t](n,r)}}},375:(e,t,r)=>{r.d(t,{Yy:()=>o,Ud:()=>p});const n=Symbol("Comlink.proxy"),a=Symbol("Comlink.endpoint"),o=Symbol("Comlink.releaseProxy"),i=Symbol("Comlink.thrown"),s=e=>"object"==typeof e&&null!==e||"function"==typeof e,u=new Map([["proxy",{canHandle:e=>s(e)&&e[n],serialize(e){const{port1:t,port2:r}=new MessageChannel;return c(e,t),[r,[r]]},deserialize:e=>(e.start(),p(e))}],["throw",{canHandle:e=>s(e)&&i in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function c(e,t=self){t.addEventListener("message",(function r(a){if(!a||!a.data)return;const{id:o,type:s,path:u}=Object.assign({path:[]},a.data),p=(a.data.argumentList||[]).map(g);let f;try{const t=u.slice(0,-1).reduce(((e,t)=>e[t]),e),r=u.reduce(((e,t)=>e[t]),e);switch(s){case"GET":f=r;break;case"SET":t[u.slice(-1)[0]]=g(a.data.value),f=!0;break;case"APPLY":f=r.apply(t,p);break;case"CONSTRUCT":f=function(e){return Object.assign(e,{[n]:!0})}(new r(...p));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;c(e,r),f=function(e,t){return m.set(e,t),e}(t,[t])}break;case"RELEASE":f=void 0;break;default:return}}catch(e){f={value:e,[i]:0}}Promise.resolve(f).catch((e=>({value:e,[i]:0}))).then((e=>{const[n,a]=y(e);t.postMessage(Object.assign(Object.assign({},n),{id:o}),a),"RELEASE"===s&&(t.removeEventListener("message",r),l(t))}))})),t.start&&t.start()}function l(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function p(e,t){return d(e,[],t)}function f(e){if(e)throw new Error("Proxy has been released and is not useable")}function d(e,t=[],r=function(){}){let n=!1;const i=new Proxy(r,{get(r,a){if(f(n),a===o)return()=>b(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{l(e),n=!0}));if("then"===a){if(0===t.length)return{then:()=>i};const r=b(e,{type:"GET",path:t.map((e=>e.toString()))}).then(g);return r.then.bind(r)}return d(e,[...t,a])},set(r,a,o){f(n);const[i,s]=y(o);return b(e,{type:"SET",path:[...t,a].map((e=>e.toString())),value:i},s).then(g)},apply(r,o,i){f(n);const s=t[t.length-1];if(s===a)return b(e,{type:"ENDPOINT"}).then(g);if("bind"===s)return d(e,t.slice(0,-1));const[u,c]=h(i);return b(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:u},c).then(g)},construct(r,a){f(n);const[o,i]=h(a);return b(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:o},i).then(g)}});return i}function h(e){const t=e.map(y);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const m=new WeakMap;function y(e){for(const[t,r]of u)if(r.canHandle(e)){const[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},m.get(e)||[]]}function g(e){switch(e.type){case"HANDLER":return u.get(e.name).deserialize(e.value);case"RAW":return e.value}}function b(e,t,r){return new Promise((n=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(r){r.data&&r.data.id&&r.data.id===a&&(e.removeEventListener("message",t),n(r.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),r)}))}}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{startBackend:()=>l,stopBackend:()=>p});var e=r(375),t=r(905),a=r(477),o=r.n(a);function i(){return o()('(()=>{var e={13:function(e,t,n){var r,a;a=this,r=function(){return function(e){"use strict";var t=e&&e.I18n||{},n=Array.prototype.slice,r=function(e){return("0"+e.toString()).substr(-2)},a=function(e,t){return d("round",e,-t).toFixed(t)},o=function(e){var t=typeof e;return"function"===t||"object"===t},i=function(e){return"function"==typeof e},s=function(e){return null!=e},u=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},l=function(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)},c=function(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)},p=function(e){return!0===e||!1===e},f=function(e){return null===e},d=function(e,t,n){return void 0===n||0==+n?Math[e](t):(t=+t,n=+n,isNaN(t)||"number"!=typeof n||n%1!=0?NaN:(t=t.toString().split("e"),+((t=(t=Math[e](+(t[0]+"e"+(t[1]?+t[1]-n:-n)))).toString().split("e"))[0]+"e"+(t[1]?+t[1]+n:n))))},h=function(e,t){return i(e)?e(t):e},y=function(e,t){var n,r;for(n in t)t.hasOwnProperty(n)&&(r=t[n],l(r)||c(r)||p(r)||u(r)||f(r)?e[n]=r:(null==e[n]&&(e[n]={}),y(e[n],r)));return e},m={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},b={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},g={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},v={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},w=[null,"kb","mb","gb","tb"],_={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\\{\\{|%\\{)(.*?)(?:\\}\\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return t.reset=function(){var e;for(e in _)this[e]=_[e]},t.initializeOptions=function(){var e;for(e in _)s(this[e])||(this[e]=_[e])},t.initializeOptions(),t.locales={},t.locales.get=function(e){var n=this[e]||this[t.locale]||this.default;return i(n)&&(n=n(e)),!1===u(n)&&(n=[n]),n},t.locales.default=function(e){var n=[],r=[];return e&&n.push(e),!e&&t.locale&&n.push(t.locale),t.fallbacks&&t.defaultLocale&&n.push(t.defaultLocale),n.forEach((function(e){var n=e.split("-"),a=null,o=null;3===n.length?(a=[n[0],n[1]].join("-"),o=n[0]):2===n.length&&(a=n[0]),-1===r.indexOf(e)&&r.push(e),t.fallbacks&&[a,o].forEach((function(t){null!=t&&t!==e&&-1===r.indexOf(t)&&r.push(t)}))})),n.length||n.push("en"),r},t.pluralization={},t.pluralization.get=function(e){return this[e]||this[t.locale]||this.default},t.pluralization.default=function(e){switch(e){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},t.currentLocale=function(){return this.locale||this.defaultLocale},t.isSet=s,t.lookup=function(e,t){t=t||{};var n,r,a,o,i=this.locales.get(t.locale).slice();for(a=this.getFullScope(e,t);i.length;)if(n=i.shift(),r=a.split(t.separator||this.defaultSeparator),o=this.translations[n]){for(;r.length&&null!=(o=o[r.shift()]););if(null!=o)return o}if(s(t.defaultValue))return h(t.defaultValue,e)},t.pluralizationLookupWithoutFallback=function(e,t,n){var r,a,i=this.pluralization.get(t)(e);if(o(n))for(;i.length;)if(r=i.shift(),s(n[r])){a=n[r];break}return a},t.pluralizationLookup=function(e,t,n){n=n||{};var r,a,i,u,l=this.locales.get(n.locale).slice();for(t=this.getFullScope(t,n);l.length;)if(r=l.shift(),a=t.split(n.separator||this.defaultSeparator),i=this.translations[r]){for(;a.length&&(i=i[a.shift()],o(i));)0===a.length&&(u=this.pluralizationLookupWithoutFallback(e,r,i));if(null!=u)break}return null==u&&s(n.defaultValue)&&(u=o(n.defaultValue)?this.pluralizationLookupWithoutFallback(e,n.locale,n.defaultValue):n.defaultValue,i=n.defaultValue),{message:u,translations:i}},t.meridian=function(){var e=this.lookup("time"),t=this.lookup("date");return e&&e.am&&e.pm?[e.am,e.pm]:t&&t.meridian?t.meridian:m.meridian},t.prepareOptions=function(){for(var e,t=n.call(arguments),r={};t.length;)if("object"==typeof(e=t.shift()))for(var a in e)e.hasOwnProperty(a)&&(s(r[a])||(r[a]=e[a]));return r},t.createTranslationOptions=function(e,t){var n=[{scope:e}];return s(t.defaults)&&(n=n.concat(t.defaults)),s(t.defaultValue)&&n.push({message:t.defaultValue}),n},t.translate=function(e,t){t=t||{};var n,r=this.createTranslationOptions(e,t),a=e,i=this.prepareOptions(t);return delete i.defaultValue,r.some((function(t){if(s(t.scope)?(a=t.scope,n=this.lookup(a,i)):s(t.message)&&(n=h(t.message,e)),null!=n)return!0}),this)?("string"==typeof n?n=this.interpolate(n,t):u(n)?n=n.map((function(e){return"string"==typeof e?this.interpolate(e,t):e}),this):o(n)&&s(t.count)&&(n=this.pluralize(t.count,a,t)),n):this.missingTranslation(e,t)},t.interpolate=function(e,t){if(null==e)return e;t=t||{};var n,r,a,o,i=e.match(this.placeholder);if(!i)return e;for(;i.length;)a=(n=i.shift()).replace(this.placeholder,"$1"),r=s(t[a])?t[a].toString().replace(/\\$/gm,"_#$#_"):a in t?this.nullPlaceholder(n,e,t):this.missingPlaceholder(n,e,t),o=new RegExp(n.replace(/{/gm,"\\\\{").replace(/}/gm,"\\\\}")),e=e.replace(o,r);return e.replace(/_#\\$#_/g,"$")},t.pluralize=function(e,t,n){var r,a;return n=this.prepareOptions({count:String(e)},n),void 0===(a=this.pluralizationLookup(e,t,n)).translations||null==a.translations?this.missingTranslation(t,n):void 0!==a.message&&null!=a.message?this.interpolate(a.message,n):(r=this.pluralization.get(n.locale),this.missingTranslation(t+"."+r(e)[0],n))},t.missingTranslation=function(e,t){if("guess"===this.missingBehaviour){var n=e.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(e,t,n){return t+" "+n.toLowerCase()}))}return\'[missing "\'+[null!=t&&null!=t.locale?t.locale:this.currentLocale(),this.getFullScope(e,t)].join(t.separator||this.defaultSeparator)+\'" translation]\'},t.missingPlaceholder=function(e,t,n){return"[missing "+e+" value]"},t.nullPlaceholder=function(){return t.missingPlaceholder.apply(t,arguments)},t.toNumber=function(e,t){t=this.prepareOptions(t,this.lookup("number.format"),b);var n,r,o=e<0,i=a(Math.abs(e),t.precision).toString().split("."),s=[],u=t.format||"%n",l=o?"-":"";for(e=i[0],n=i[1];e.length>0;)s.unshift(e.substr(Math.max(0,e.length-3),3)),e=e.substr(0,e.length-3);return r=s.join(t.delimiter),t.strip_insignificant_zeros&&n&&(n=n.replace(/0+$/,"")),t.precision>0&&n&&(r+=t.separator+n),r=(u=t.sign_first?"%s"+u:u.replace("%n","%s%n")).replace("%u",t.unit).replace("%n",r).replace("%s",l)},t.toCurrency=function(e,t){return t=this.prepareOptions(t,this.lookup("number.currency.format",t),this.lookup("number.format",t),g),this.toNumber(e,t)},t.localize=function(e,t,n){switch(n||(n={}),e){case"currency":return this.toCurrency(t,n);case"number":return e=this.lookup("number.format",n),this.toNumber(t,e);case"percentage":return this.toPercentage(t,n);default:var r;return r=e.match(/^(date|time)/)?this.toTime(e,t,n):t.toString(),this.interpolate(r,n)}},t.parseDate=function(e){var t,n,r;if(null==e)return e;if("object"==typeof e)return e;if(t=e.toString().match(/(\\d{4})-(\\d{2})-(\\d{2})(?:[ T](\\d{2}):(\\d{2}):(\\d{2})([\\.,]\\d{1,3})?)?(Z|\\+00:?00)?/)){for(var a=1;a<=6;a++)t[a]=parseInt(t[a],10)||0;t[2]-=1,r=t[7]?1e3*("0"+t[7]):null,n=t[8]?new Date(Date.UTC(t[1],t[2],t[3],t[4],t[5],t[6],r)):new Date(t[1],t[2],t[3],t[4],t[5],t[6],r)}else"number"==typeof e?(n=new Date).setTime(e):e.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\\d+) (\\d+:\\d+:\\d+) ([+-]\\d+) (\\d+)/)?(n=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(e.match(/\\d+ \\d+:\\d+:\\d+ [+-]\\d+ \\d+/),(n=new Date).setTime(Date.parse(e)));return n},t.strftime=function(e,n,a){a=this.lookup("date",a);var o=t.meridian();if(a||(a={}),a=this.prepareOptions(a,m),isNaN(e.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var i=e.getDay(),s=e.getDate(),u=e.getFullYear(),l=e.getMonth()+1,c=e.getHours(),p=c,f=c>11?1:0,d=e.getSeconds(),h=e.getMinutes(),y=e.getTimezoneOffset(),b=Math.floor(Math.abs(y/60)),g=Math.abs(y)-60*b,v=(y>0?"-":"+")+(b.toString().length<2?"0"+b:b)+(g.toString().length<2?"0"+g:g);return p>12?p-=12:0===p&&(p=12),n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.replace("%a",a.abbr_day_names[i])).replace("%A",a.day_names[i])).replace("%b",a.abbr_month_names[l])).replace("%B",a.month_names[l])).replace("%d",r(s))).replace("%e",s)).replace("%-d",s)).replace("%H",r(c))).replace("%-H",c)).replace("%k",c)).replace("%I",r(p))).replace("%-I",p)).replace("%l",p)).replace("%m",r(l))).replace("%-m",l)).replace("%M",r(h))).replace("%-M",h)).replace("%p",o[f])).replace("%P",o[f].toLowerCase())).replace("%S",r(d))).replace("%-S",d)).replace("%w",i)).replace("%y",r(u))).replace("%-y",r(u).replace(/^0+/,""))).replace("%Y",u)).replace("%z",v)).replace("%Z",v)},t.toTime=function(e,t,n){var r=this.parseDate(t),a=this.lookup(e,n);if(null==r)return r;var o=r.toString();return o.match(/invalid/i)?o:a?this.strftime(r,a,n):o},t.toPercentage=function(e,t){return t=this.prepareOptions(t,this.lookup("number.percentage.format",t),this.lookup("number.format",t),v),this.toNumber(e,t)},t.toHumanSize=function(e,t){for(var n,r,a,o=1024,i=e,s=0;i>=o&&s<4;)i/=o,s+=1;return 0===s?(a=this.getFullScope("number.human.storage_units.units.byte",t),n=this.t(a,{count:i}),r=0):(a=this.getFullScope("number.human.storage_units.units."+w[s],t),n=this.t(a),r=i-Math.floor(i)==0?0:1),t=this.prepareOptions(t,{unit:n,precision:r,format:"%n%u",delimiter:""}),this.toNumber(i,t)},t.getFullScope=function(e,t){return t=t||{},u(e)&&(e=e.join(t.separator||this.defaultSeparator)),t.scope&&(e=[t.scope,e].join(t.separator||this.defaultSeparator)),e},t.extend=function(e,t){return void 0===e&&void 0===t?{}:y(e,t)},t.t=t.translate.bind(t),t.l=t.localize.bind(t),t.p=t.pluralize.bind(t),t}(a)}.call(t,n,t,e),void 0===r||(e.exports=r)},921:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});const r=\'import json\\nimport os\\nfrom collections.abc import Awaitable\\n\\nimport micropip\\nfrom pyodide import to_js\\n\\nawait micropip.install("python_runner")\\nimport python_runner\\n\\nft = micropip.install(\\\'friendly_traceback\\\')\\n\\n# Otherwise `import matplotlib` fails while assuming a browser backend\\nos.environ[\\\'MPLBACKEND\\\'] = \\\'AGG\\\'\\n\\n# Code is executed in a worker with less resources than ful environment\\nimport sys\\nsys.setrecursionlimit(500)\\n\\n# Global Papyros instance\\npapyros = None\\n\\n\\nclass Papyros(python_runner.PatchedStdinRunner):\\n def override_matplotlib(self):\\n # workaround from https://github.com/pyodide/pyodide/issues/1518\\n import base64\\n from io import BytesIO\\n import matplotlib.pyplot\\n\\n def show():\\n buf = BytesIO()\\n matplotlib.pyplot.savefig(buf, format=\\\'png\\\')\\n buf.seek(0)\\n # encode to a base64 str\\n img = base64.b64encode(buf.read()).decode(\\\'utf-8\\\')\\n matplotlib.pyplot.clf()\\n self.output("img", img, contentType="img/png;base64")\\n\\n matplotlib.pyplot.show = show\\n\\n async def run_async(self, source_code, mode="exec", top_level_await=True):\\n """\\n Mostly a copy of the parent `run_async` with `await ft` in case of an exception,\\n because `serialize_traceback` isn\\\'t async.\\n """\\n with self._execute_context(source_code):\\n try:\\n code_obj = self.pre_run(source_code, mode, top_level_await=top_level_await)\\n if code_obj:\\n result = self.execute(code_obj, source_code, mode)\\n while isinstance(result, Awaitable):\\n result = await result\\n return result\\n except:\\n await ft\\n # Let `_execute_context` and `serialize_traceback`\\n # handle the exception\\n raise\\n \\n def serialize_syntax_error(self, exc, source_code):\\n raise # Rethrow to ensure FriendlyTraceback library is imported correctly\\n\\n def serialize_traceback(self, exc, source_code):\\n import friendly_traceback # Delay import for faster startup\\n from friendly_traceback.core import FriendlyTraceback\\n\\n # Allow friendly_traceback to inspect the code\\n friendly_traceback.source_cache.cache.add(self.filename, source_code)\\n\\n # Initialize traceback\\n fr = FriendlyTraceback(type(exc), exc, exc.__traceback__)\\n fr.assign_generic()\\n fr.assign_cause()\\n # Translate properties to FriendlyError interface\\n tb = fr.info.get("shortened_traceback", "")\\n info = fr.info.get("generic", "")\\n why = fr.info.get("cause", "")\\n what = fr.info.get("message", "")\\n\\n name = type(exc).__name__\\n user_start = 0\\n tb_lines = tb.split("\\\\n")\\n # Find first line in traceback that involves code from the user\\n while user_start < len(tb_lines) and self.filename not in tb_lines[user_start]:\\n user_start += 1\\n # Find line containing Exception name, denoting end of location of issue\\n user_end = user_start + 1\\n while user_end < len(tb_lines) and name not in tb_lines[user_end]:\\n user_end += 1\\n where = "\\\\n".join(tb_lines[user_start:user_end]) or ""\\n # Format for callback\\n return dict(\\n text=json.dumps(\\n dict(\\n name=name,\\n traceback=tb,\\n info=info,\\n why=why,\\n where=where,\\n what=what\\n )\\n )\\n )\\n\\n\\ndef init_papyros(event_callback):\\n global papyros\\n def runner_callback(event_type, data):\\n def cb(typ, dat, **kwargs):\\n return event_callback(to_js(dict(type=typ, data=dat, depth=0, **kwargs)))\\n\\n # Translate python_runner events to papyros events\\n if event_type == "output":\\n for part in data["parts"]:\\n if part["type"] in ["stderr", "traceback", "syntax_error"]:\\n cb("error", part["text"], contentType="text/json")\\n elif part["type"] == "stdout":\\n cb("output", part["text"], contentType="text/plain")\\n elif part["type"] == "img":\\n cb("output", part["text"], contentType=part["contentType"])\\n elif part["type"] in ["input", "input_prompt"]:\\n continue\\n else:\\n raise ValueError(f"Unknown output part type {part[\\\'type\\\']}")\\n elif event_type == "input":\\n return cb("input", json.dumps(dict(prompt=data["prompt"])), contentType="text/json")\\n else:\\n raise ValueError(f"Unknown event type {event_type}")\\n\\n papyros = Papyros(callback=runner_callback)\\n\\n\\nasync def process_code(code, filename="my_code.py"):\\n with open(filename, "w") as f:\\n f.write(code)\\n papyros.filename = filename\\n\\n try:\\n import matplotlib\\n except ModuleNotFoundError:\\n pass\\n else:\\n # Only override matplotlib when required by the code\\n papyros.override_matplotlib()\\n\\n await papyros.run_async(code)\\n\'},137:e=>{self,e.exports=(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{serviceWorkerFetchListener:()=>u,asyncSleep:()=>l,ServiceWorkerError:()=>p,writeMessageAtomics:()=>f,writeMessageServiceWorker:()=>d,writeMessage:()=>h,makeChannel:()=>y,makeAtomicsChannel:()=>m,makeServiceWorkerChannel:()=>b,readMessage:()=>v,syncSleep:()=>w,uuidv4:()=>c});var n,r=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},o=function(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},i="__SyncMessageServiceWorkerInput__",s="__sync-message-v2__";function u(){var e={},t={};return function(n){var r=n.request.url;return!!r.includes(i)&&(n.respondWith(function(){return a(this,void 0,void 0,(function(){function a(e){var t={message:e,version:s};return new Response(JSON.stringify(t),{status:200})}var i,u,l,c,p,f,d,h;return o(this,(function(o){switch(o.label){case 0:return r.endsWith("/read")?[4,n.request.json()]:[3,5];case 1:return i=o.sent(),u=i.messageId,l=i.timeout,(c=e[u])?(delete e[u],[2,a(c)]):[3,2];case 2:return[4,new Promise((function(e){t[u]=e,setTimeout((function(){delete t[u],e(new Response("",{status:408}))}),l)}))];case 3:return[2,o.sent()];case 4:return[3,8];case 5:return r.endsWith("/write")?[4,n.request.json()]:[3,7];case 6:return p=o.sent(),f=p.message,d=p.messageId,(h=t[d])?(h(a(f)),delete t[d]):e[d]=f,[2,a({early:!h})];case 7:if(r.endsWith("/version"))return[2,new Response(s,{status:200})];o.label=8;case 8:return[2]}}))}))}()),!0)}}function l(e){return new Promise((function(t){return setTimeout(t,e)}))}var c,p=function(e){function t(n,r){var a=e.call(this,"Received status ".concat(r," from ").concat(n,". Ensure the service worker is registered and active."))||this;return a.url=n,a.status=r,Object.setPrototypeOf(a,t.prototype),a}return r(t,e),t}(Error);function f(e,t){var n=(new TextEncoder).encode(JSON.stringify(t)),r=e.data,a=e.meta;if(n.length>r.length)throw"Input is too long";r.set(n,0),Atomics.store(a,0,n.length),Atomics.store(a,1,1),Atomics.notify(a,1)}function d(e,t,n){return a(this,void 0,void 0,(function(){var r,a,i,u,c;return o(this,(function(o){switch(o.label){case 0:return[4,navigator.serviceWorker.ready];case 1:o.sent(),r=e.baseUrl+"/write",a=Date.now(),o.label=2;case 2:return i={message:t,messageId:n},[4,fetch(r,{method:"POST",body:JSON.stringify(i)})];case 3:return u=o.sent(),(c=200===u.status)?[4,u.json()]:[3,5];case 4:c=o.sent().version===s,o.label=5;case 5:return c?[2]:Date.now()-a<e.timeout?[4,l(100)]:[3,7];case 6:return o.sent(),[3,2];case 7:throw new p(r,u.status);case 8:return[2]}}))}))}function h(e,t,n){return a(this,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return"atomics"!==e.type?[3,1]:(f(e,t),[3,3]);case 1:return[4,d(e,t,n)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))}function y(e){return void 0===e&&(e={}),"undefined"!=typeof SharedArrayBuffer?m(e.atomics):"serviceWorker"in navigator?b(e.serviceWorker):null}function m(e){var t=(void 0===e?{}:e).bufferSize;return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(t||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function b(e){return void 0===e&&(e={}),{type:"serviceWorker",baseUrl:(e.scope||"/")+i,timeout:e.timeout||5e3}}function g(e,t){return e>0?+e:t}function v(e,t,n){var r=void 0===n?{}:n,a=r.checkInterrupt,o=r.checkTimeout,i=r.timeout,u=performance.now();o=g(o,a?100:5e3);var l,c=g(i,Number.POSITIVE_INFINITY);if("atomics"===e.type){var f=e.data,d=e.meta;l=function(){if("timed-out"===Atomics.wait(d,1,0,o))return null;var e=Atomics.exchange(d,0,0),t=f.slice(0,e);Atomics.store(d,1,0);var n=(new TextDecoder).decode(t);return JSON.parse(n)}}else l=function(){var n=new XMLHttpRequest,r=e.baseUrl+"/read";n.open("POST",r,!1);var a={messageId:t,timeout:o};n.send(JSON.stringify(a));var i=n.status;if(408===i)return null;if(200===i){var l=JSON.parse(n.responseText);return l.version!==s?null:l.message}if(performance.now()-u<e.timeout)return null;throw new p(r,i)};for(;;){var h=c-(performance.now()-u);if(h<=0)return null;o=Math.min(o,h);var y=l();if(null!==y)return y;if(null==a?void 0:a())return null}}function w(e,t){if(e=g(e,0))if("undefined"!=typeof SharedArrayBuffer){var n=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));n[0]=0,Atomics.wait(n,0,0,e)}else v(t,"sleep ".concat(e," ").concat(c()),{timeout:e})}return c="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(e){var t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))},t})()},963:e=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=Symbol("Comlink.proxy"),t=Symbol("Comlink.endpoint"),r=Symbol("Comlink.releaseProxy"),a=Symbol("Comlink.thrown"),o=e=>"object"==typeof e&&null!==e||"function"==typeof e,i=new Map([["proxy",{canHandle:t=>o(t)&&t[e],serialize(e){const{port1:t,port2:n}=new MessageChannel;return s(e,t),[n,[n]]},deserialize(e){return e.start(),c(e,[],t);var t}}],["throw",{canHandle:e=>o(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function s(t,n=self){n.addEventListener("message",(function r(o){if(!o||!o.data)return;const{id:i,type:l,path:c}=Object.assign({path:[]},o.data),p=(o.data.argumentList||[]).map(h);let y;try{const n=c.slice(0,-1).reduce(((e,t)=>e[t]),t),r=c.reduce(((e,t)=>e[t]),t);switch(l){case"GET":y=r;break;case"SET":n[c.slice(-1)[0]]=h(o.data.value),y=!0;break;case"APPLY":y=r.apply(n,p);break;case"CONSTRUCT":y=function(t){return Object.assign(t,{[e]:!0})}(new r(...p));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;s(t,n),y=function(e,t){return f.set(e,t),e}(e,[e])}break;case"RELEASE":y=void 0;break;default:return}}catch(e){y={value:e,[a]:0}}Promise.resolve(y).catch((e=>({value:e,[a]:0}))).then((e=>{const[t,a]=d(e);n.postMessage(Object.assign(Object.assign({},t),{id:i}),a),"RELEASE"===l&&(n.removeEventListener("message",r),u(n))}))})),n.start&&n.start()}function u(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function l(e){if(e)throw new Error("Proxy has been released and is not useable")}function c(e,n=[],a=function(){}){let o=!1;const i=new Proxy(a,{get(t,a){if(l(o),a===r)return()=>y(e,{type:"RELEASE",path:n.map((e=>e.toString()))}).then((()=>{u(e),o=!0}));if("then"===a){if(0===n.length)return{then:()=>i};const t=y(e,{type:"GET",path:n.map((e=>e.toString()))}).then(h);return t.then.bind(t)}return c(e,[...n,a])},set(t,r,a){l(o);const[i,s]=d(a);return y(e,{type:"SET",path:[...n,r].map((e=>e.toString())),value:i},s).then(h)},apply(r,a,i){l(o);const s=n[n.length-1];if(s===t)return y(e,{type:"ENDPOINT"}).then(h);if("bind"===s)return c(e,n.slice(0,-1));const[u,f]=p(i);return y(e,{type:"APPLY",path:n.map((e=>e.toString())),argumentList:u},f).then(h)},construct(t,r){l(o);const[a,i]=p(r);return y(e,{type:"CONSTRUCT",path:n.map((e=>e.toString())),argumentList:a},i).then(h)}});return i}function p(e){const t=e.map(d);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const f=new WeakMap;function d(e){for(const[t,n]of i)if(n.canHandle(e)){const[r,a]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},a]}return[{type:"RAW",value:e},f.get(e)||[]]}function h(e){switch(e.type){case"HANDLER":return i.get(e.name).deserialize(e.value);case"RAW":return e.value}}function y(e,t,n){return new Promise((r=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===a&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),n)}))}var m,b=n(137),g=n(13),v=n.n(g),w=(n(963),function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i}),_=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))};!function(e){e[e.Debug=0]="Debug",e[e.Error=1]="Error",e[e.Important=2]="Important"}(m||(m={}));function S(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=e!==m.Debug;r&&(e===m.Error?console.error.apply(console,_([],w(t),!1)):console.log.apply(console,_([],w(t),!1)))}var k=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i};v().t;var x,E=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},T=function(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},O=function(){function e(){this.onEvent=function(){},this.runId=0}return e.prototype.launch=function(e,t){var n=this,r=function(n){var r=function(e){var t=e.data,n=k(e.contentType.split("/"),2),r=n[0],a=n[1];switch(r){case"text":switch(a){case"plain":return t;case"json":return JSON.parse(t)}break;case"img":if("png;base64"===a)return t}return S(m.Important,"Unhandled content type: ".concat(e.contentType)),t}(n),a=(0,b.uuidv4)();return r.messageId=a,n.data=JSON.stringify(r),n.contentType="text/json",e(n),(0,b.readMessage)(t,a)};return this.onEvent=function(t){return t.runId=n.runId,"input"===t.type?r(t):e(t)},Promise.resolve()},e.prototype.runCode=function(e,t){return E(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return this.runId=t,[4,this._runCodeInternal(e)];case 1:return[2,n.sent()]}}))}))},e}(),A="https://cdn.jsdelivr.net/pyodide/".concat("v0.19.0","/full/"),P=A+"pyodide.js",j=(x=function(e,t){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},x(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}x(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),M=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},z=function(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},I=n(921).Z;importScripts(P),s(new(function(e){function t(){var t=e.call(this)||this;return t.pyodide={},t.initialized=!1,t}return j(t,e),t.prototype.launch=function(t,n){return M(this,void 0,void 0,(function(){var r,a,o=this;return z(this,(function(i){switch(i.label){case 0:return[4,e.prototype.launch.call(this,t,n)];case 1:return i.sent(),r=this,[4,loadPyodide({indexURL:A,fullStdLib:!1})];case 2:return r.pyodide=i.sent(),[4,this._runCodeInternal(I)];case 3:return i.sent(),a=function(e){var t="toJs"in e?e.toJs():Object.fromEntries(e);return o.onEvent(t)},this.pyodide.globals.get("init_papyros")(a),this.initialized=!0,[2]}}))}))},t.prototype._runCodeInternal=function(e){return M(this,void 0,void 0,(function(){var t;return z(this,(function(n){switch(n.label){case 0:if(!this.initialized)return[3,6];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.pyodide.loadPackagesFromImports(e)];case 2:return n.sent(),[3,4];case 3:return t=n.sent(),S(m.Debug,"Something went wrong while loading imports: ",t),[3,4];case 4:return[4,this.pyodide.globals.get("process_code")(e)];case 5:return n.sent(),[3,8];case 6:return[4,this.pyodide.loadPackage("micropip")];case 7:return n.sent(),[2,this.pyodide.runPythonAsync(e)];case 8:return[2]}}))}))},t}(O)))})()})();',"Worker",void 0,void 0)}function s(){return o()('(()=>{var __webpack_modules__={13:function(e,t,r){var n,a;a=this,n=function(){return function(e){"use strict";var t=e&&e.I18n||{},r=Array.prototype.slice,n=function(e){return("0"+e.toString()).substr(-2)},a=function(e,t){return h("round",e,-t).toFixed(t)},o=function(e){var t=typeof e;return"function"===t||"object"===t},i=function(e){return"function"==typeof e},s=function(e){return null!=e},u=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},c=function(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)},l=function(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)},p=function(e){return!0===e||!1===e},f=function(e){return null===e},h=function(e,t,r){return void 0===r||0==+r?Math[e](t):(t=+t,r=+r,isNaN(t)||"number"!=typeof r||r%1!=0?NaN:(t=t.toString().split("e"),+((t=(t=Math[e](+(t[0]+"e"+(t[1]?+t[1]-r:-r)))).toString().split("e"))[0]+"e"+(t[1]?+t[1]+r:r))))},d=function(e,t){return i(e)?e(t):e},m=function(e,t){var r,n;for(r in t)t.hasOwnProperty(r)&&(n=t[r],c(n)||l(n)||p(n)||u(n)||f(n)?e[r]=n:(null==e[r]&&(e[r]={}),m(e[r],n)));return e},y={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},g={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},v={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},_={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},b=[null,"kb","mb","gb","tb"],w={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\\{\\{|%\\{)(.*?)(?:\\}\\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return t.reset=function(){var e;for(e in w)this[e]=w[e]},t.initializeOptions=function(){var e;for(e in w)s(this[e])||(this[e]=w[e])},t.initializeOptions(),t.locales={},t.locales.get=function(e){var r=this[e]||this[t.locale]||this.default;return i(r)&&(r=r(e)),!1===u(r)&&(r=[r]),r},t.locales.default=function(e){var r=[],n=[];return e&&r.push(e),!e&&t.locale&&r.push(t.locale),t.fallbacks&&t.defaultLocale&&r.push(t.defaultLocale),r.forEach((function(e){var r=e.split("-"),a=null,o=null;3===r.length?(a=[r[0],r[1]].join("-"),o=r[0]):2===r.length&&(a=r[0]),-1===n.indexOf(e)&&n.push(e),t.fallbacks&&[a,o].forEach((function(t){null!=t&&t!==e&&-1===n.indexOf(t)&&n.push(t)}))})),r.length||r.push("en"),n},t.pluralization={},t.pluralization.get=function(e){return this[e]||this[t.locale]||this.default},t.pluralization.default=function(e){switch(e){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},t.currentLocale=function(){return this.locale||this.defaultLocale},t.isSet=s,t.lookup=function(e,t){t=t||{};var r,n,a,o,i=this.locales.get(t.locale).slice();for(a=this.getFullScope(e,t);i.length;)if(r=i.shift(),n=a.split(t.separator||this.defaultSeparator),o=this.translations[r]){for(;n.length&&null!=(o=o[n.shift()]););if(null!=o)return o}if(s(t.defaultValue))return d(t.defaultValue,e)},t.pluralizationLookupWithoutFallback=function(e,t,r){var n,a,i=this.pluralization.get(t)(e);if(o(r))for(;i.length;)if(n=i.shift(),s(r[n])){a=r[n];break}return a},t.pluralizationLookup=function(e,t,r){r=r||{};var n,a,i,u,c=this.locales.get(r.locale).slice();for(t=this.getFullScope(t,r);c.length;)if(n=c.shift(),a=t.split(r.separator||this.defaultSeparator),i=this.translations[n]){for(;a.length&&(i=i[a.shift()],o(i));)0===a.length&&(u=this.pluralizationLookupWithoutFallback(e,n,i));if(null!=u)break}return null==u&&s(r.defaultValue)&&(u=o(r.defaultValue)?this.pluralizationLookupWithoutFallback(e,r.locale,r.defaultValue):r.defaultValue,i=r.defaultValue),{message:u,translations:i}},t.meridian=function(){var e=this.lookup("time"),t=this.lookup("date");return e&&e.am&&e.pm?[e.am,e.pm]:t&&t.meridian?t.meridian:y.meridian},t.prepareOptions=function(){for(var e,t=r.call(arguments),n={};t.length;)if("object"==typeof(e=t.shift()))for(var a in e)e.hasOwnProperty(a)&&(s(n[a])||(n[a]=e[a]));return n},t.createTranslationOptions=function(e,t){var r=[{scope:e}];return s(t.defaults)&&(r=r.concat(t.defaults)),s(t.defaultValue)&&r.push({message:t.defaultValue}),r},t.translate=function(e,t){t=t||{};var r,n=this.createTranslationOptions(e,t),a=e,i=this.prepareOptions(t);return delete i.defaultValue,n.some((function(t){if(s(t.scope)?(a=t.scope,r=this.lookup(a,i)):s(t.message)&&(r=d(t.message,e)),null!=r)return!0}),this)?("string"==typeof r?r=this.interpolate(r,t):u(r)?r=r.map((function(e){return"string"==typeof e?this.interpolate(e,t):e}),this):o(r)&&s(t.count)&&(r=this.pluralize(t.count,a,t)),r):this.missingTranslation(e,t)},t.interpolate=function(e,t){if(null==e)return e;t=t||{};var r,n,a,o,i=e.match(this.placeholder);if(!i)return e;for(;i.length;)a=(r=i.shift()).replace(this.placeholder,"$1"),n=s(t[a])?t[a].toString().replace(/\\$/gm,"_#$#_"):a in t?this.nullPlaceholder(r,e,t):this.missingPlaceholder(r,e,t),o=new RegExp(r.replace(/{/gm,"\\\\{").replace(/}/gm,"\\\\}")),e=e.replace(o,n);return e.replace(/_#\\$#_/g,"$")},t.pluralize=function(e,t,r){var n,a;return r=this.prepareOptions({count:String(e)},r),void 0===(a=this.pluralizationLookup(e,t,r)).translations||null==a.translations?this.missingTranslation(t,r):void 0!==a.message&&null!=a.message?this.interpolate(a.message,r):(n=this.pluralization.get(r.locale),this.missingTranslation(t+"."+n(e)[0],r))},t.missingTranslation=function(e,t){if("guess"===this.missingBehaviour){var r=e.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+r.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(e,t,r){return t+" "+r.toLowerCase()}))}return\'[missing "\'+[null!=t&&null!=t.locale?t.locale:this.currentLocale(),this.getFullScope(e,t)].join(t.separator||this.defaultSeparator)+\'" translation]\'},t.missingPlaceholder=function(e,t,r){return"[missing "+e+" value]"},t.nullPlaceholder=function(){return t.missingPlaceholder.apply(t,arguments)},t.toNumber=function(e,t){t=this.prepareOptions(t,this.lookup("number.format"),g);var r,n,o=e<0,i=a(Math.abs(e),t.precision).toString().split("."),s=[],u=t.format||"%n",c=o?"-":"";for(e=i[0],r=i[1];e.length>0;)s.unshift(e.substr(Math.max(0,e.length-3),3)),e=e.substr(0,e.length-3);return n=s.join(t.delimiter),t.strip_insignificant_zeros&&r&&(r=r.replace(/0+$/,"")),t.precision>0&&r&&(n+=t.separator+r),n=(u=t.sign_first?"%s"+u:u.replace("%n","%s%n")).replace("%u",t.unit).replace("%n",n).replace("%s",c)},t.toCurrency=function(e,t){return t=this.prepareOptions(t,this.lookup("number.currency.format",t),this.lookup("number.format",t),v),this.toNumber(e,t)},t.localize=function(e,t,r){switch(r||(r={}),e){case"currency":return this.toCurrency(t,r);case"number":return e=this.lookup("number.format",r),this.toNumber(t,e);case"percentage":return this.toPercentage(t,r);default:var n;return n=e.match(/^(date|time)/)?this.toTime(e,t,r):t.toString(),this.interpolate(n,r)}},t.parseDate=function(e){var t,r,n;if(null==e)return e;if("object"==typeof e)return e;if(t=e.toString().match(/(\\d{4})-(\\d{2})-(\\d{2})(?:[ T](\\d{2}):(\\d{2}):(\\d{2})([\\.,]\\d{1,3})?)?(Z|\\+00:?00)?/)){for(var a=1;a<=6;a++)t[a]=parseInt(t[a],10)||0;t[2]-=1,n=t[7]?1e3*("0"+t[7]):null,r=t[8]?new Date(Date.UTC(t[1],t[2],t[3],t[4],t[5],t[6],n)):new Date(t[1],t[2],t[3],t[4],t[5],t[6],n)}else"number"==typeof e?(r=new Date).setTime(e):e.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\\d+) (\\d+:\\d+:\\d+) ([+-]\\d+) (\\d+)/)?(r=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(e.match(/\\d+ \\d+:\\d+:\\d+ [+-]\\d+ \\d+/),(r=new Date).setTime(Date.parse(e)));return r},t.strftime=function(e,r,a){a=this.lookup("date",a);var o=t.meridian();if(a||(a={}),a=this.prepareOptions(a,y),isNaN(e.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var i=e.getDay(),s=e.getDate(),u=e.getFullYear(),c=e.getMonth()+1,l=e.getHours(),p=l,f=l>11?1:0,h=e.getSeconds(),d=e.getMinutes(),m=e.getTimezoneOffset(),g=Math.floor(Math.abs(m/60)),v=Math.abs(m)-60*g,_=(m>0?"-":"+")+(g.toString().length<2?"0"+g:g)+(v.toString().length<2?"0"+v:v);return p>12?p-=12:0===p&&(p=12),r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=r.replace("%a",a.abbr_day_names[i])).replace("%A",a.day_names[i])).replace("%b",a.abbr_month_names[c])).replace("%B",a.month_names[c])).replace("%d",n(s))).replace("%e",s)).replace("%-d",s)).replace("%H",n(l))).replace("%-H",l)).replace("%k",l)).replace("%I",n(p))).replace("%-I",p)).replace("%l",p)).replace("%m",n(c))).replace("%-m",c)).replace("%M",n(d))).replace("%-M",d)).replace("%p",o[f])).replace("%P",o[f].toLowerCase())).replace("%S",n(h))).replace("%-S",h)).replace("%w",i)).replace("%y",n(u))).replace("%-y",n(u).replace(/^0+/,""))).replace("%Y",u)).replace("%z",_)).replace("%Z",_)},t.toTime=function(e,t,r){var n=this.parseDate(t),a=this.lookup(e,r);if(null==n)return n;var o=n.toString();return o.match(/invalid/i)?o:a?this.strftime(n,a,r):o},t.toPercentage=function(e,t){return t=this.prepareOptions(t,this.lookup("number.percentage.format",t),this.lookup("number.format",t),_),this.toNumber(e,t)},t.toHumanSize=function(e,t){for(var r,n,a,o=1024,i=e,s=0;i>=o&&s<4;)i/=o,s+=1;return 0===s?(a=this.getFullScope("number.human.storage_units.units.byte",t),r=this.t(a,{count:i}),n=0):(a=this.getFullScope("number.human.storage_units.units."+b[s],t),r=this.t(a),n=i-Math.floor(i)==0?0:1),t=this.prepareOptions(t,{unit:r,precision:n,format:"%n%u",delimiter:""}),this.toNumber(i,t)},t.getFullScope=function(e,t){return t=t||{},u(e)&&(e=e.join(t.separator||this.defaultSeparator)),t.scope&&(e=[t.scope,e].join(t.separator||this.defaultSeparator)),e},t.extend=function(e,t){return void 0===e&&void 0===t?{}:m(e,t)},t.t=t.translate.bind(t),t.l=t.localize.bind(t),t.p=t.pluralize.bind(t),t}(a)}.call(t,r,t,e),void 0===n||(e.exports=n)},137:e=>{self,e.exports=(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{serviceWorkerFetchListener:()=>u,asyncSleep:()=>c,ServiceWorkerError:()=>p,writeMessageAtomics:()=>f,writeMessageServiceWorker:()=>h,writeMessage:()=>d,makeChannel:()=>m,makeAtomicsChannel:()=>y,makeServiceWorkerChannel:()=>g,readMessage:()=>_,syncSleep:()=>b,uuidv4:()=>l});var r,n=(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(e,t,r,n){return new(r||(r=Promise))((function(a,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}u((n=n.apply(e,t||[])).next())}))},o=function(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},i="__SyncMessageServiceWorkerInput__",s="__sync-message-v2__";function u(){var e={},t={};return function(r){var n=r.request.url;return!!n.includes(i)&&(r.respondWith(function(){return a(this,void 0,void 0,(function(){function a(e){var t={message:e,version:s};return new Response(JSON.stringify(t),{status:200})}var i,u,c,l,p,f,h,d;return o(this,(function(o){switch(o.label){case 0:return n.endsWith("/read")?[4,r.request.json()]:[3,5];case 1:return i=o.sent(),u=i.messageId,c=i.timeout,(l=e[u])?(delete e[u],[2,a(l)]):[3,2];case 2:return[4,new Promise((function(e){t[u]=e,setTimeout((function(){delete t[u],e(new Response("",{status:408}))}),c)}))];case 3:return[2,o.sent()];case 4:return[3,8];case 5:return n.endsWith("/write")?[4,r.request.json()]:[3,7];case 6:return p=o.sent(),f=p.message,h=p.messageId,(d=t[h])?(d(a(f)),delete t[h]):e[h]=f,[2,a({early:!d})];case 7:if(n.endsWith("/version"))return[2,new Response(s,{status:200})];o.label=8;case 8:return[2]}}))}))}()),!0)}}function c(e){return new Promise((function(t){return setTimeout(t,e)}))}var l,p=function(e){function t(r,n){var a=e.call(this,"Received status ".concat(n," from ").concat(r,". Ensure the service worker is registered and active."))||this;return a.url=r,a.status=n,Object.setPrototypeOf(a,t.prototype),a}return n(t,e),t}(Error);function f(e,t){var r=(new TextEncoder).encode(JSON.stringify(t)),n=e.data,a=e.meta;if(r.length>n.length)throw"Input is too long";n.set(r,0),Atomics.store(a,0,r.length),Atomics.store(a,1,1),Atomics.notify(a,1)}function h(e,t,r){return a(this,void 0,void 0,(function(){var n,a,i,u,l;return o(this,(function(o){switch(o.label){case 0:return[4,navigator.serviceWorker.ready];case 1:o.sent(),n=e.baseUrl+"/write",a=Date.now(),o.label=2;case 2:return i={message:t,messageId:r},[4,fetch(n,{method:"POST",body:JSON.stringify(i)})];case 3:return u=o.sent(),(l=200===u.status)?[4,u.json()]:[3,5];case 4:l=o.sent().version===s,o.label=5;case 5:return l?[2]:Date.now()-a<e.timeout?[4,c(100)]:[3,7];case 6:return o.sent(),[3,2];case 7:throw new p(n,u.status);case 8:return[2]}}))}))}function d(e,t,r){return a(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return"atomics"!==e.type?[3,1]:(f(e,t),[3,3]);case 1:return[4,h(e,t,r)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function m(e){return void 0===e&&(e={}),"undefined"!=typeof SharedArrayBuffer?y(e.atomics):"serviceWorker"in navigator?g(e.serviceWorker):null}function y(e){var t=(void 0===e?{}:e).bufferSize;return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(t||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function g(e){return void 0===e&&(e={}),{type:"serviceWorker",baseUrl:(e.scope||"/")+i,timeout:e.timeout||5e3}}function v(e,t){return e>0?+e:t}function _(e,t,r){var n=void 0===r?{}:r,a=n.checkInterrupt,o=n.checkTimeout,i=n.timeout,u=performance.now();o=v(o,a?100:5e3);var c,l=v(i,Number.POSITIVE_INFINITY);if("atomics"===e.type){var f=e.data,h=e.meta;c=function(){if("timed-out"===Atomics.wait(h,1,0,o))return null;var e=Atomics.exchange(h,0,0),t=f.slice(0,e);Atomics.store(h,1,0);var r=(new TextDecoder).decode(t);return JSON.parse(r)}}else c=function(){var r=new XMLHttpRequest,n=e.baseUrl+"/read";r.open("POST",n,!1);var a={messageId:t,timeout:o};r.send(JSON.stringify(a));var i=r.status;if(408===i)return null;if(200===i){var c=JSON.parse(r.responseText);return c.version!==s?null:c.message}if(performance.now()-u<e.timeout)return null;throw new p(n,i)};for(;;){var d=l-(performance.now()-u);if(d<=0)return null;o=Math.min(o,d);var m=c();if(null!==m)return m;if(null==a?void 0:a())return null}}function b(e,t){if(e=v(e,0))if("undefined"!=typeof SharedArrayBuffer){var r=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));r[0]=0,Atomics.wait(r,0,0,e)}else _(t,"sleep ".concat(e," ").concat(l()),{timeout:e})}return l="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(e){var t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))},t})()},403:(e,t,r)=>{"use strict";r.d(t,{z:()=>h});var n,a=r(137),o=r(13),i=r.n(o),s=(r(963),function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i}),u=function(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){e[e.Debug=0]="Debug",e[e.Error=1]="Error",e[e.Important=2]="Important"}(n||(n={}));var c=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i};i().t;function l(e){var t=e.data,r=c(e.contentType.split("/"),2),a=r[0],o=r[1];switch(a){case"text":switch(o){case"plain":return t;case"json":return JSON.parse(t)}break;case"img":if("png;base64"===o)return t}return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];e!==n.Debug&&(e===n.Error?console.error.apply(console,u([],s(t),!1)):console.log.apply(console,u([],s(t),!1)))}(n.Important,"Unhandled content type: ".concat(e.contentType)),t}var p=function(e,t,r,n){return new(r||(r=Promise))((function(a,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}u((n=n.apply(e,t||[])).next())}))},f=function(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},h=function(){function e(){this.onEvent=function(){},this.runId=0}return e.prototype.launch=function(e,t){var r=this;return this.onEvent=function(n){return n.runId=r.runId,"input"===n.type?function(r){var n=l(r),o=(0,a.uuidv4)();return n.messageId=o,r.data=JSON.stringify(n),r.contentType="text/json",e(r),(0,a.readMessage)(t,o)}(n):e(n)},Promise.resolve()},e.prototype.runCode=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return this.runId=t,[4,this._runCodeInternal(e)];case 1:return[2,r.sent()]}}))}))},e}()},963:e=>{},375:(e,t,r)=>{"use strict";r.d(t,{Jj:()=>c});const n=Symbol("Comlink.proxy"),a=Symbol("Comlink.endpoint"),o=Symbol("Comlink.releaseProxy"),i=Symbol("Comlink.thrown"),s=e=>"object"==typeof e&&null!==e||"function"==typeof e,u=new Map([["proxy",{canHandle:e=>s(e)&&e[n],serialize(e){const{port1:t,port2:r}=new MessageChannel;return c(e,t),[r,[r]]},deserialize(e){return e.start(),f(e,[],t);var t}}],["throw",{canHandle:e=>s(e)&&i in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function c(e,t=self){t.addEventListener("message",(function r(a){if(!a||!a.data)return;const{id:o,type:s,path:u}=Object.assign({path:[]},a.data),p=(a.data.argumentList||[]).map(y);let f;try{const t=u.slice(0,-1).reduce(((e,t)=>e[t]),e),r=u.reduce(((e,t)=>e[t]),e);switch(s){case"GET":f=r;break;case"SET":t[u.slice(-1)[0]]=y(a.data.value),f=!0;break;case"APPLY":f=r.apply(t,p);break;case"CONSTRUCT":f=function(e){return Object.assign(e,{[n]:!0})}(new r(...p));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;c(e,r),f=function(e,t){return d.set(e,t),e}(t,[t])}break;case"RELEASE":f=void 0;break;default:return}}catch(e){f={value:e,[i]:0}}Promise.resolve(f).catch((e=>({value:e,[i]:0}))).then((e=>{const[n,a]=m(e);t.postMessage(Object.assign(Object.assign({},n),{id:o}),a),"RELEASE"===s&&(t.removeEventListener("message",r),l(t))}))})),t.start&&t.start()}function l(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function p(e){if(e)throw new Error("Proxy has been released and is not useable")}function f(e,t=[],r=function(){}){let n=!1;const i=new Proxy(r,{get(r,a){if(p(n),a===o)return()=>g(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{l(e),n=!0}));if("then"===a){if(0===t.length)return{then:()=>i};const r=g(e,{type:"GET",path:t.map((e=>e.toString()))}).then(y);return r.then.bind(r)}return f(e,[...t,a])},set(r,a,o){p(n);const[i,s]=m(o);return g(e,{type:"SET",path:[...t,a].map((e=>e.toString())),value:i},s).then(y)},apply(r,o,i){p(n);const s=t[t.length-1];if(s===a)return g(e,{type:"ENDPOINT"}).then(y);if("bind"===s)return f(e,t.slice(0,-1));const[u,c]=h(i);return g(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:u},c).then(y)},construct(r,a){p(n);const[o,i]=h(a);return g(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:o},i).then(y)}});return i}function h(e){const t=e.map(m);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const d=new WeakMap;function m(e){for(const[t,r]of u)if(r.canHandle(e)){const[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},d.get(e)||[]]}function y(e){switch(e.type){case"HANDLER":return u.get(e.name).deserialize(e.value);case"RAW":return e.value}}function g(e,t,r){return new Promise((n=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(r){r.data&&r.data.id&&r.data.id===a&&(e.removeEventListener("message",t),n(r.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),r)}))}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={};(()=>{"use strict";var comlink__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(375),_Backend__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(403),__extends=(extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},extendStatics(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),extendStatics,__read=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},__spreadArray=function(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))},JavaScriptWorker=function(_super){function JavaScriptWorker(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(JavaScriptWorker,_super),JavaScriptWorker.stringify=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.map((function(t){if(Array.isArray(t))return JSON.stringify(t);if("string"==typeof t)return t;if("number"==typeof t)return t+"";if("object"==typeof t&&"toString"in t){var r=t.toString();return"[object Object]"===r&&(r=JSON.stringify(t)),r}return JSON.stringify(e)})).join(" ");return r},JavaScriptWorker.prototype.prompt=function(e){return void 0===e&&(e=""),this.onEvent({type:"input",data:JavaScriptWorker.stringify({prompt:e}),contentType:"text/json",runId:this.runId})},JavaScriptWorker.prototype.consoleLog=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.onEvent({type:"output",data:JavaScriptWorker.stringify.apply(JavaScriptWorker,__spreadArray([],__read(e),!1))+"\\n",runId:this.runId,contentType:"text/plain"})},JavaScriptWorker.prototype.consoleError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.onEvent({type:"error",data:JavaScriptWorker.stringify.apply(JavaScriptWorker,__spreadArray([],__read(e),!1))+"\\n",contentType:"text/plain",runId:this.runId})},JavaScriptWorker.prototype._runCodeInternal=function(code){var oldContent={"console.log":console.log,"console.error":console.error},newContext={prompt:this.prompt.bind(this),"console.log":this.consoleLog.bind(this),"console.error":this.consoleError.bind(this)};new Function("ctx",Object.keys(newContext).map((function(e){return"".concat(e," = ctx[\'").concat(e,"\'];")})).join("\\n"))(newContext);try{return Promise.resolve(eval(code))}catch(e){return Error.captureStackTrace(e),Promise.resolve(this.onEvent({type:"error",runId:this.runId,contentType:"text/json",data:JSON.stringify({name:e.constructor.name,what:e.message,traceback:e.stack})}))}finally{new Function("ctx",Object.keys(oldContent).map((function(e){return"".concat(e," = ctx[\'").concat(e,"\'];")})).join("\\n"))(oldContent)}},JavaScriptWorker}(_Backend__WEBPACK_IMPORTED_MODULE_0__.z),__WEBPACK_DEFAULT_EXPORT__={};(0,comlink__WEBPACK_IMPORTED_MODULE_1__.Jj)(new JavaScriptWorker)})()})();',"Worker",void 0,void 0)}var u=new Map,c=new Map([[t.ProgrammingLanguage.Python,function(){return new i}],[t.ProgrammingLanguage.JavaScript,function(){return new s}]]);function l(t){if(c.has(t)){var r=c.get(t)(),n=(0,e.Ud)(r);return u.set(n,r),n}throw new Error("".concat(t," is not yet supported."))}function p(t){if(!u.has(t))throw new Error("Unknown backend supplied for backend ".concat(JSON.stringify(t)));u.get(t).terminate(),t[e.Yy](),u.delete(t)}})(),n})()}));
|
package/dist/CodeEditor.d.ts
CHANGED
|
@@ -3,21 +3,107 @@ import { Compartment, Extension } from "@codemirror/state";
|
|
|
3
3
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
4
4
|
import { EditorView } from "@codemirror/view";
|
|
5
5
|
import { RenderOptions } from "./util/Util";
|
|
6
|
+
/**
|
|
7
|
+
* Component that provides useful features to users writing code
|
|
8
|
+
*/
|
|
6
9
|
export declare class CodeEditor {
|
|
10
|
+
/**
|
|
11
|
+
* Reference to the user interface of the editor
|
|
12
|
+
*/
|
|
7
13
|
editorView: EditorView;
|
|
14
|
+
/**
|
|
15
|
+
* Compartment to change language at runtime
|
|
16
|
+
*/
|
|
8
17
|
languageCompartment: Compartment;
|
|
18
|
+
/**
|
|
19
|
+
* Compartment to configure indentation level at runtime
|
|
20
|
+
*/
|
|
9
21
|
indentCompartment: Compartment;
|
|
22
|
+
/**
|
|
23
|
+
* Compartment to configure the placeholder at runtime
|
|
24
|
+
*/
|
|
10
25
|
placeholderCompartment: Compartment;
|
|
26
|
+
/**
|
|
27
|
+
* Compartment to configure the panel at runtime
|
|
28
|
+
*/
|
|
11
29
|
panelCompartment: Compartment;
|
|
30
|
+
/**
|
|
31
|
+
* Construct a new CodeEditor
|
|
32
|
+
* @param {ProgrammingLanguage} language The used programming language
|
|
33
|
+
* @param {string} editorPlaceHolder The placeholder for the editor
|
|
34
|
+
* @param {string} initialCode The initial code to display
|
|
35
|
+
* @param {number} indentLength The length in spaces for the indent unit
|
|
36
|
+
*/
|
|
12
37
|
constructor(language: ProgrammingLanguage, editorPlaceHolder: string, initialCode?: string, indentLength?: number);
|
|
38
|
+
/**
|
|
39
|
+
* Render the editor with the given options and panel
|
|
40
|
+
* @param {RenderOptions} options Options for rendering
|
|
41
|
+
* @param {HTMLElement} panel The panel to display at the bottom
|
|
42
|
+
* @return {HTMLElement} The rendered element
|
|
43
|
+
*/
|
|
13
44
|
render(options: RenderOptions, panel?: HTMLElement): HTMLElement;
|
|
45
|
+
/**
|
|
46
|
+
* Set the language that is currently used, with a corresponding placeholder
|
|
47
|
+
* @param {ProgrammingLanguage} language The language to use
|
|
48
|
+
* @param {string} editorPlaceHolder Placeholder when empty
|
|
49
|
+
*/
|
|
14
50
|
setLanguage(language: ProgrammingLanguage, editorPlaceHolder: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Set the length in spaces of the indentation unit
|
|
53
|
+
* @param {number} indentLength The number of spaces to use
|
|
54
|
+
*/
|
|
15
55
|
setIndentLength(indentLength: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Set the panel that is displayed at the bottom of the editor
|
|
58
|
+
* @param {HTMLElement} panel The panel to display
|
|
59
|
+
*/
|
|
16
60
|
setPanel(panel: HTMLElement): void;
|
|
61
|
+
/**
|
|
62
|
+
* @return {string} The code within the editor
|
|
63
|
+
*/
|
|
17
64
|
getCode(): string;
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} code The new code to be shown in the editor
|
|
67
|
+
*/
|
|
18
68
|
setCode(code: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Put focus on the CodeEditor
|
|
71
|
+
*/
|
|
19
72
|
focus(): void;
|
|
73
|
+
/**
|
|
74
|
+
* @param {number} indentLength The amount of spaces to use
|
|
75
|
+
* @return {string} The indentation unit to use
|
|
76
|
+
*/
|
|
20
77
|
static getIndentUnit(indentLength: number): string;
|
|
78
|
+
/**
|
|
79
|
+
* @param {ProgrammingLanguage} language The language to support
|
|
80
|
+
* @return {LanguageSupport} CodeMirror LanguageSupport for the language
|
|
81
|
+
*/
|
|
21
82
|
static getLanguageSupport(language: ProgrammingLanguage): LanguageSupport;
|
|
83
|
+
/**
|
|
84
|
+
* - [syntax highlighting depending on the language](#getLanguageSupport)
|
|
85
|
+
* - [line numbers](#gutter.lineNumbers)
|
|
86
|
+
* - [special character highlighting](#view.highlightSpecialChars)
|
|
87
|
+
* - [the undo history](#history.history)
|
|
88
|
+
* - [a fold gutter](#fold.foldGutter)
|
|
89
|
+
* - [custom selection drawing](#view.drawSelection)
|
|
90
|
+
* - [multiple selections](#state.EditorState^allowMultipleSelections)
|
|
91
|
+
* - [reindentation on input](#language.indentOnInput)
|
|
92
|
+
* - [the default highlight style](#highlight.defaultHighlightStyle) (as fallback)
|
|
93
|
+
* - [bracket matching](#matchbrackets.bracketMatching)
|
|
94
|
+
* - [bracket closing](#closebrackets.closeBrackets)
|
|
95
|
+
* - [autocompletion](#autocomplete.autocompletion)
|
|
96
|
+
* - [rectangular selection](#rectangular-selection.rectangularSelection)
|
|
97
|
+
* - [active line highlighting](#view.highlightActiveLine)
|
|
98
|
+
* - [active line gutter highlighting](#gutter.highlightActiveLineGutter)
|
|
99
|
+
* - [selection match highlighting](#search.highlightSelectionMatches)
|
|
100
|
+
* Keymaps:
|
|
101
|
+
* - [the default command bindings](#commands.defaultKeymap)
|
|
102
|
+
* - [search](#search.searchKeymap)
|
|
103
|
+
* - [commenting](#comment.commentKeymap)
|
|
104
|
+
* - [linting](#lint.lintKeymap)
|
|
105
|
+
* - [indenting with tab](#commands.indentWithTab)
|
|
106
|
+
* @return {Array<Extension} Default extensions to use
|
|
107
|
+
*/
|
|
22
108
|
static getExtensions(): Array<Extension>;
|
|
23
109
|
}
|