import 'package:flutter_qjs/flutter_qjs.dart'; class JsPolyfills { late JavascriptRuntime runtime; JsPolyfills(this.runtime); void init() { runtime.evaluate(''' class FormData { constructor() { this.params = {}; } append(key, value) { this.params[key] = value; } toJSON() { return this.params; } } '''); runtime.evaluate(''' /**! * url-search-params-polyfill * * @author Jerry Bendy (https://github.com/jerrybendy) * @licence MIT */ !function(t){"use strict";var n,r=function(){try{if(t.URLSearchParams&&"bar"===new t.URLSearchParams("foo=bar").get("foo"))return t.URLSearchParams}catch(t){}return null}(),e=r&&"a=1"===new r({a:1}).toString(),o=r&&"+"===new r("s=%2B").get("s"),i=r&&"size"in r.prototype,a="__URLSearchParams__",c=!r||((n=new r).append("s"," &"),"s=+%26"===n.toString()),s=p.prototype,u=!(!t.Symbol||!t.Symbol.iterator);if(!(r&&e&&o&&c&&i)){s.append=function(t,n){d(this[a],t,n)},s.delete=function(t){delete this[a][t]},s.get=function(t){var n=this[a];return this.has(t)?n[t][0]:null},s.getAll=function(t){var n=this[a];return this.has(t)?n[t].slice(0):[]},s.has=function(t){return b(this[a],t)},s.set=function(t,n){this[a][t]=[""+n]},s.toString=function(){var t,n,r,e,o=this[a],i=[];for(n in o)for(r=g(n),t=0,e=o[n];t0?"#"+t.match(/^#*(.*)/)[1]:"",t}}),Object.defineProperty(this,"host",{get:function(){return o.length>0?r+":"+o:r},set:function(t){var e=t.split(":");return this.hostname=e[0],this.port=e[1],t}}),Object.defineProperty(this,"hostname",{get:function(){return r},set:function(t){return r=t.length>0?encodeURIComponent(t):r,t}}),Object.defineProperty(this,"href",{get:function(){var t=h+"//";return(u.length>0||i.length>0)&&(u.length>0&&(t+=u),i.length>0&&(t+=":"+i),t+="@"),t+=r,o.length>0&&(t+=":"+o),t+=s+c+n},set:function(t){this.protocol=t;var e=(t=t.replace(/.*?:\\/*/,"")).match(/([^:]*).*@/);this.username=e?e[1]:"";var n=(t=t.replace(/([^:]*):?(.*@)/,a)).match(/.*(?=@)/);this.password=n?n[0]:"",t=t.replace(/.*@/,""),this.hostname=t.match(/[^:/?]*/);var r=t.match(/:(\\d+)/);this.port=r?r[1]:"";var i=t.match(/\\/([^?#]*)/);this.pathname=i?i[1]:"";var s=t.match(/\\?[^#]*/);this.search=s?s[0]:"";var o=t.match(/\\#.*/);this.hash=o?o[0]:""}}),Object.defineProperty(this,"origin",{get:function(){var t=h+"//"+r;return o.length>0&&(t+=":"+o),t},set:function(t){this.protocol=t,t=t.replace(/.*?:\\/*/,""),this.hostname=t.match(/[^:/?]*/);var e=t.match(/:(\\d+)/);this.port=e?e[1]:""}}),Object.defineProperty(this,"password",{get:function(){return i},set:function(t){return i=encodeURIComponent(t),t}}),Object.defineProperty(this,"pathname",{get:function(){return s},set:function(t){return s="/"+t.match(/\\/?(.*)/)[1],t}}),Object.defineProperty(this,"port",{get:function(){return o},set:function(t){return o=isNaN(t)||""===t?"":Math.min(65535,t).toString(),t}}),Object.defineProperty(this,"protocol",{get:function(){return h},set:function(t){return h=t.match(/[^/:]*/)[0]+":",t}}),Object.defineProperty(this,"search",{get:function(){return c},set:function(t){return c=t.length>0?"?"+t.match(/\\??(.*)/)[1]:"",t}}),Object.defineProperty(this,"username",{get:function(){return u},set:function(t){u=t}}),"string"==typeof t){var f=/^[a-zA-z]+:\\/\\/.*/.test(t),p=/^[a-zA-z]+:\\/\\/.*/.test(e);if(f)this.href=t;else{if(!p)throw new TypeError('URL string is not valid. If using a relative url, a second argument needs to be passed representing the base URL. Example: new URL("relative/path", "http://www.example.com");');this.href=e+t}}else n=t.hash,r=t.hostname,i=t.password?t.password:"",s=t.pathname,o=t.port,h=t.protocol,c=t.search,u=t.username?t.username:"";this.searchParams=function(t){var e=[],n=[];t.search.length>0&&t.search.slice(1).split("&").forEach((function(t){var r=t.split("=");e.push(r[0]),n.push(r[1])}));function r(){0===e.length?t.search="":t.search=e.map((function(t,e){return t+"="+n[e]})).join("&")}return{append:function(t,i){e.push(t),n.push(i),r()},delete:function(t){for(;e.indexOf(t)>-1;)n.splice(e.indexOf(t),1),e.splice(e.indexOf(t),1);r()},entries:function(){return e.map((function(t,e){return[t,n[e]]}))},get:function(t){return n[e.indexOf(t)]},getAll:function(t){return n.filter((function(n,r){return e[r]===t}))},has:function(t){return e.indexOf(t)>-1},keys:function(){return e},set:function(t,i){if(-1===e.indexOf(t))this.append(t,i);else{var s=!0,o=[];e=e.filter((function(e,r){return e!==t?(o.push(n[r]),!0):!!s&&(s=!1,o.push(i),!0)})),n=o,r()}},sort:function(){var t=this.entries().sort();e=[],n=[],t.forEach((function(t){e.push(t[0]),n.push(t[1])})),r()},toString:function(){return t.search.slice(1)},values:function(){return n}}}(this)}}"function"!=typeof URL?t():"searchParams"in new URL(window.location)||t()}(); '''); runtime.evaluate(''' !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports.dayjs=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",\$=/^(\\d{4})[-/]?(\\d{1,2})?[-/]?(\\d{0,2})[Tt\\s]*(\\d{1,2})?:?(\\d{1,2})?:?(\\d{1,2})?[.:]?(\\d+)?\$/,y=/\\[([^\\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.\$L,utc:e.\$u,x:e.\$x,\$offset:e.\$offset})};var _=function(){function M(t){this.\$L=w(t.locale,null,!0),this.parse(t),this.\$x=this.\$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.\$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z\$/i.test(e)){var r=e.match(\$);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.\$d;this.\$y=t.getFullYear(),this.\$M=t.getMonth(),this.\$D=t.getDate(),this.\$W=t.getDay(),this.\$H=t.getHours(),this.\$m=t.getMinutes(),this.\$s=t.getSeconds(),this.\$ms=t.getMilliseconds()},m.\$utils=function(){return b},m.isValid=function(){return!(this.\$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)