"use strict";"undefined"==typeof global&&(window.global=window);const numbersOnlyRE=/^\d+$/,objectHasOwnProperty=Object.prototype.hasOwnProperty,propertyIsEnumerable=Object.prototype.propertyIsEnumerable,regExpToString=RegExp.prototype.toString,dateToISOString=Date.prototype.toISOString;let CIRCULAR_ERROR_MESSAGE;function tryStringify(e){try{return JSON.stringify(e)}catch(e){if(!CIRCULAR_ERROR_MESSAGE)try{const e={};e.a=e,JSON.stringify(e)}catch(e){CIRCULAR_ERROR_MESSAGE=e.message}if("TypeError"===e.name&&e.message===CIRCULAR_ERROR_MESSAGE)return"[Circular]";throw e}}function format(e){if("string"!=typeof e){const e=new Array(arguments.length);for(let t=0;t<arguments.length;t++)e[t]=inspect(arguments[t]);return e.join(" ")}if(1===arguments.length)return e;let t="",r=1,n=0;for(let i=0;i<e.length;)if(37===e.charCodeAt(i)&&i+1<e.length){if(37!==e.charCodeAt(i+1)&&r>=arguments.length){++i;continue}switch(e.charCodeAt(i+1)){case 100:n<i&&(t+=e.slice(n,i)),t+=Number(arguments[r++]);break;case 105:n<i&&(t+=e.slice(n,i)),t+=parseInt(arguments[r++]);break;case 102:n<i&&(t+=e.slice(n,i)),t+=parseFloat(arguments[r++]);break;case 106:n<i&&(t+=e.slice(n,i)),t+=tryStringify(arguments[r++]);break;case 115:n<i&&(t+=e.slice(n,i)),t+=String(arguments[r++]);break;case 37:n<i&&(t+=e.slice(n,i)),t+="%";break;default:n<i&&(t+=e.slice(n,i)),t+="%",n=i+=1;continue}n=i+=2}else++i;for(0===n?t=e:n<e.length&&(t+=e.slice(n));r<arguments.length;){const e=arguments[r++];t+=null===e||"object"!=typeof e&&"symbol"!=typeof e?` ${e}`:` ${inspect(e)}`}return t}function inspect(e){return formatValue({seen:[],breakLength:60,maxArrayLength:20},e,2)}function arrayToHash(e){const t=Object.create(null);for(let r=0;r<e.length;r++){t[e[r]]=!0}return t}function formatValue(e,t,r){const n=formatPrimitive(e,t);if(n)return n;let i=Object.keys(t);const o=arrayToHash(i),a=Object.getOwnPropertySymbols(t).filter(e=>propertyIsEnumerable.call(t,e));let s;i=i.concat(a);let l=t;try{isDate(t)||(l=t.valueOf())}catch(e){}"string"==typeof l&&(i=i.filter(e=>"symbol"==typeof e||!(e>=0&&e<l.length))),isError(t)&&"iOS"===tabris.device.platform&&(i=i.filter(e=>!["line","column","sourceURL"].includes(e)));let c=getConstructorOf(t);if(0===i.length){if("function"==typeof t){return`[${c?c.name:"Function"}${t.name?`: ${t.name}`:""}]`}if(isRegExp(t))return regExpToString.call(t);if(isDate(t))return Number.isNaN(t.getTime())?t.toString():dateToISOString.call(t);if(isError(t))return formatError(t);if("string"==typeof l)return`[String: ${s=formatPrimitive(e,l)}]`;if("symbol"==typeof l)return`[Symbol: ${s=formatPrimitive(e,l)}]`;if("number"==typeof l)return`[Number: ${s=formatPrimitive(e,l)}]`;if("boolean"==typeof l)return`[Boolean: ${s=formatPrimitive(e,l)}]`}let u,h="",d=!1,p=formatObject;if(Array.isArray(t))c&&"Array"===c.name&&(c=null),u=["[","]"],d=0===t.length,p=formatArray;else if(isArrayBuffer(t))u=["{","}"],i.unshift("byteLength"),o.byteLength=!0;else if(isTypedArray(t))u=["[","]"],p=formatTypedArray;else if(isPromise(t))u=["{","}"],p=formatPromise;else{try{if(t instanceof Object&&t.toString!==Object.prototype.toString){const e=t.toString();if("string"==typeof e)return e}}catch(e){}c&&"Object"===c.name&&(c=null),u=["{","}"],d=!0}if(d=!0===d&&0===i.length,"function"==typeof t){h=` [${c?c.name:"Function"}${t.name?`: ${t.name}`:""}]`}if(isRegExp(t)&&(h=` ${regExpToString.call(t)}`),isDate(t)&&(h=` ${dateToISOString.call(t)}`),isError(t))return formatError(t);if("string"==typeof l&&(h=` [String: ${s=formatPrimitive(e,l)}]`),"number"==typeof l&&(h=` [Number: ${s=formatPrimitive(e,l)}]`),"boolean"==typeof l&&(h=` [Boolean: ${s=formatPrimitive(e,l)}]`),""===h&&c&&(u[0]=`${c.name} ${u[0]}`),!0===d)return`${u[0]}${h}${u[1]}`;if(r<0)return isRegExp(t)?regExpToString.call(t):Array.isArray(t)?"[Array]":"[Object]";e.seen.push(t);const f=p(e,t,r,o,i);return e.seen.pop(),reduceToSingleString(f,h,u,e.breakLength)}function formatNumber(e,t){return Object.is(t,-0)?"-0":`${t}`}function formatPrimitive(e,t){if(void 0===t)return"undefined";if(null===t)return"null";const r=typeof t;if("string"===r){return`'${JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')}'`}return"number"===r?formatNumber(e,t):"boolean"===r?`${t}`:"symbol"===r?t.toString():void 0}function formatObject(e,t,r,n,i){return i.map(i=>formatProperty(e,t,r,n,i,!1))}function formatArray(e,t,r,n,i){const o=[];let a=0,s=0;for(;s<t.length&&a<e.maxArrayLength;){let i=0;for(;s<t.length&&!hasOwnProperty(t,String(s));)i++,s++;if(i>0){const e=`<${i} empty item${i>1?"s":""}>`;o.push(e)}else o.push(formatProperty(e,t,r,n,String(s),!0)),s++;a++}const l=t.length-s;l>0&&o.push(`... ${l} more item${l>1?"s":""}`);for(let a=0;a<i.length;a++){const s=i[a];"symbol"!=typeof s&&numbersOnlyRE.test(s)||o.push(formatProperty(e,t,r,n,s,!0))}return o}function formatTypedArray(e,t,r,n,i){const o=Math.min(Math.max(0,e.maxArrayLength),t.length),a=t.length-o,s=new Array(o);for(let r=0;r<o;++r)s[r]=formatNumber(e,t[r]);a>0&&s.push(`... ${a} more item${a>1?"s":""}`);for(const o of i)"symbol"!=typeof o&&numbersOnlyRE.test(o)||s.push(formatProperty(e,t,r,n,o,!0));return s}function formatPromise(e,t,r,n,i){const o=[];if(isPending(t))o.push("<pending>");else{const n=null===r?null:r-1,i=formatValue(e,getPromiseResult(t),n);isRejected(t)?o.push(`<rejected> ${i}`):o.push(i)}for(let a=0;a<i.length;a++)o.push(formatProperty(e,t,r,n,i[a],!1));return o}function formatProperty(e,t,r,n,i,o){let a,s;const l=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(l.get?s=l.set?"[Getter/Setter]":"[Getter]":l.set&&(s="[Setter]"),hasOwnProperty(n,i)||(a="symbol"==typeof i?`[${i.toString()}]`:`[${i}]`),s||(e.seen.indexOf(l.value)<0?(s=formatValue(e,l.value,null===r?null:r-1)).indexOf("\n")>-1&&(s=o?s.replace(/\n/g,"\n  "):s.replace(/^|\n/g,"\n   ")):s="[Circular]"),void 0===a){if(o&&numbersOnlyRE.test(i))return s;a=JSON.stringify(`${i}`),a=/^"[a-zA-Z_][a-zA-Z_0-9]*"$/.test(a)?a.substr(1,a.length-2):a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/^"|"$/g,"'").replace(/\\\\/g,"\\")}return`${a}: ${s}`}function reduceToSingleString(e,t,r,n){return e.reduce((e,t)=>e+t.replace(/\u001b\[\d\d?m/g,"").length+1,0)>n?r[0]+(""===t&&1===r[0].length?"":`${t}\n `)+` ${e.join(",\n  ")} ${r[1]}`:`${r[0]}${t} ${e.join(", ")} ${r[1]}`}function hasOwnProperty(e,t){return objectHasOwnProperty.call(e,t)}function isError(e){return"[object Error]"===objectToString(e)||e instanceof Error}function isDate(e){return"[object Date]"===objectToString(e)||e instanceof Date}function isPromise(e){return"[object Promise]"===objectToString(e)||e instanceof Promise$1}function isRegExp(e){return"[object RegExp]"===objectToString(e)||e instanceof RegExp}const typedArrayTypes=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array"],typedArrayNames={};for(const e of typedArrayTypes)typedArrayNames[`[object ${e}]`]=!0;function isTypedArray(e){return typedArrayNames[objectToString(e)]}function isArrayBuffer(e){return"[object ArrayBuffer]"===objectToString(e)||e instanceof ArrayBuffer}function getConstructorOf(e){for(;e;){const t=Object.getOwnPropertyDescriptor(e,"constructor");if(void 0!==t&&"function"==typeof t.value&&""!==t.value.name)return t.value;e=Object.getPrototypeOf(e)}return null}function objectToString(e){return Object.prototype.toString.call(e)}const equals=Symbol("equals"),creationAllowed=Symbol("creationAllowed"),bytes=Symbol("bytes"),nativeObject=Symbol("nativeObject"),toXML=Symbol("toXML"),notify=Symbol("notify"),data=Symbol("data"),originalComponent=Symbol("originalComponent"),proxyHandler=Symbol("proxyHandler"),setterTargetType=Symbol("setterTargetType"),observable=Symbol("observable"),nativeObservables=Symbol("nativeObservables"),jsxFactory=Symbol("jsxFactory"),jsxType=Symbol("jsxType");var symbols=Object.freeze({equals:equals,creationAllowed:creationAllowed,bytes:bytes,nativeObject:nativeObject,toXML:toXML,notify:notify,data:data,originalComponent:originalComponent,proxyHandler:proxyHandler,setterTargetType:setterTargetType,observable:observable,nativeObservables:nativeObservables,jsxFactory:jsxFactory,jsxType:jsxType});const toXML$1=toXML;class Console{constructor(){Reflect.ownKeys(Console.prototype).forEach(e=>{this[e]instanceof Function&&(this[e]=this[e].bind(this))}),this._registerPrintMethods(arguments[0]),Object.defineProperties(this,{_prefixSpaces:{enumerable:!1,writable:!0,value:0},_count:{enumerable:!1,writable:!1,value:{}}})}trace(){this.log(getStackTrace(new Error("StackTrace")))}assert(e,...t){e||(t[0]=`Assertion failed${0===t.length?"":`: ${t[0]}`}`,this.error(...t))}count(e){e=e||"default",this._count[e]||(this._count[e]=0),this.log("%s: %s",e,++this._count[e])}countReset(e){e=e||"default",this.log("%s: %s",e,this._count[e]=0)}dirxml(e){e&&e[toXML$1]instanceof Function?this.log(e[toXML$1]()):this.log(e)}group(...e){this.log(...e),this._prefixSpaces+=2}groupEnd(){this._prefixSpaces>0&&(this._prefixSpaces-=2)}debug(...e){this._console.debug(...e)}info(...e){this._console.info(...e)}log(...e){this._console.log(...e)}warn(...e){this._console.warn(...e)}error(...e){this._console.error(...e)}_registerPrintMethods(e){Object.defineProperty(this,"_console",{enumerable:!1,writable:!1,value:{}});for(const t of["debug","info","log","warn","error"])this._console[t]=((...r)=>{const n=this._prepareOutput(...r);tabris.trigger("log",{level:t,message:n,logTime:Date.now()}),e.print(t,n)})}_prepareOutput(...e){let t=format(...e);return this._prefixSpaces>0&&(t=`${" ".repeat(this._prefixSpaces)}${t}`),t}}function createConsole(e){return new Console(e)}const defaultConsole=global.console.print?createConsole(global.console):global.console;defaultConsole.debug||(defaultConsole.debug=function(...e){defaultConsole.log(...e)});const log=function(...e){defaultConsole.log(...e)},warn=function(...e){defaultConsole.warn(...e)},error=function(...e){defaultConsole.error(...e)};let inHint=!1;const toValueString=function(e){try{if(e instanceof Array||e&&e._array instanceof Array){const t=`[${(e instanceof Array?e:e._array).map(toValueString).join(", ")}]`;if(t.length<=40)return t}if("string"==typeof e){const t=e.slice(0,40).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n");return e.length>40?`"${t}..."`:`"${t}"`}if(e&&e[toXML$1])return e._disposedToStringValue||e.toString();if(e&&e instanceof Function)return e.name;if(e&&e.constructor===Object){const t=JSON.stringify(e);if(t.length<=40)return t}return e instanceof Object&&e.constructor instanceof Function?e.constructor.name:e+""}catch(e){return"[unknown]"}},hint=function(e,t){if(inHint)return;inHint=!0;let r="",n="";r=getCurrentLine(new Error),e&&"string"==typeof e?n=e+": ":e&&(n=toValueString(e)+": "),defaultConsole.warn(n+t+(r?`\nSource: ${r}`:"")),inHint=!1};function pick(e,t){const r={};for(const n in e)t.includes(n)&&(r[n]=e[n]);return r}function omit(e,t){const r={};for(const n in e)t.includes(n)||(r[n]=e[n]);return r}function capitalizeFirstChar(e){return e.charAt(0).toUpperCase()+e.slice(1)}function normalizePath(e,t="unix"){if("string"!=typeof e)throw new Error("must be a string");if(""===e)throw new Error("must not be empty");const r=e.startsWith("/")?"/":"",n=[],i=e.split(/[\\/]/);for(let e=0;e<i.length;e++){const t=i[e];if(".."===t){const e=n.pop();if(!e||"."===e)throw new Error('Path must not start with ".."')}else"."!==t&&""!==t&&n.push(t)}return n.length?r+n.join("win"===t?"\\":"/"):r||"."}function normalizePathUrl(e){if("string"!=typeof e)throw new Error("must be a string");const t=/^([a-z-]+:(\/\/)?)?(.*)/.exec(e),r=t[1]||"",n=t[3]||"";return"data:"===r?e:r+normalizePath(n)}function dirname(e,t="unix"){return e?"unix"===t&&"."!==e[0]&&"/"!==e[0]?"./":e.slice(0,e.lastIndexOf("win"===t?"\\":"/")):""}function checkNumber(e,t=[-1/0,1/0],r){const n=r?r+": ":"";if("number"!=typeof e||isNaN(e)||!isFinite(e))throw new Error(`${n}Invalid number ${e}`);if(e<t[0]||e>t[1])throw new Error(`${n}Number ${e} out of range`)}function asArray(e){return Array.isArray(e)?e:e?e.constructor!==Object&&e.toArray instanceof Function?e.toArray():[e]:[]}const traps={getPrototypeOf:!1,setPrototypeOf:!0,isExtensible:!1,preventExtensions:!1,getOwnPropertyDescriptor:!1,defineProperty:!0,has:!1,get:!1,set:!0,deleteProperty:!0,ownKeys:!1,apply:!1,construct:!1};function proxify(e){const t={};return Object.keys(traps).forEach(r=>t[r]=((t,...n)=>{const i=Reflect[r](e(),...n);return"getOwnPropertyDescriptor"===r&&i?(i.configurable=!0,i):!!traps[r]||i})),new Proxy({},t)}function isReadable(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||!!getBytes(e)}function read(e){if(e instanceof ArrayBuffer)return 0===e.byteLength?new ArrayBuffer:e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(0);if(getBytes(e))return getBytes(e);throw new Error(`${typeof e} is not an ArrayBuffer, Blob or typed`)}function getBytes(e){return e[bytes]}function setBytes(e,t){return e[bytes]=t}function allowOnlyKeys(e,t){if("object"!=typeof e)throw new TypeError(toValueString(e)+" is not an object");for(const r in e)if(-1===t.indexOf(r))throw new TypeError(`${toValueString(e)} contains unexpected entry "${r}"`);return e}function allowOnlyValues(e,t,r="Value"){if(t&&-1===t.indexOf(e)){const n=1===t.length?`"${t}"`:`"${t.slice(0,-1).join('", "')}" or "${t.slice(-1)}"`;throw new TypeError(`${r} must be ${n}, got ${toValueString(e)}`)}return e}function setNativeObject(e,t){e[nativeObject]=t}function getNativeObject(e){return e instanceof Object?e[nativeObject]?e[nativeObject]:"string"==typeof e.cid&&e.isDisposed instanceof Function?e:null:null}function getCid(e){return getNativeObject(e).cid}function getBuffer(e){return e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?e.buffer:null}function createNativeCallback(e,t,r){const n=[(new Error).stack].concat(tabris._stackTraceStack.slice(0,10));return function(){const i=tabris._stackTraceStack;tabris._stackTraceStack=n;try{e.apply(t||global,r||arguments)}catch(e){console.error("Uncaught "+e)}tabris.flush(),tabris._stackTraceStack=i}}function equals$1(e,t){if(e===t)return!0;if(e instanceof Object&&t instanceof Object&&e[equals]instanceof Function&&t[equals]instanceof Function&&e[equals]===t[equals])return e[equals](t);if(e instanceof Object&&e.constructor===Object&&t instanceof Object&&t.constructor===Object){const r=Reflect.ownKeys(e).sort(),n=Reflect.ownKeys(t).sort();return r.length===n.length&&r.every((r,i)=>{const o=n[i];return r===o&&e[r]===t[o]})}return e instanceof Array&&e.constructor===Array&&t instanceof Array&&t.constructor===Array&&(e.length===t.length&&e.every((e,r)=>e===t[r]))}const androidStackLineRegex=/^ +at +(.+) +\((.*):([0-9]+):([0-9]+)\)/,androidStackLineNoNameRegex=/^ +at +(.*):([0-9]+):([0-9]+)/,iosStackLineRegex=/^(.*)@(.*):([0-9]+):([0-9]+)/,iosStackLineNoNameRegex=/@(.*):([0-9]+):([0-9]+)/,urlBaseRegEx=/^[a-z]+:\/\/[^/]+\//;function getStackTrace(e,t=!1){try{return getStackArray(e.stack).map(e=>t?"  at "+e:e).join("\n")}catch(t){const r=t&&t.constructor&&t.message?t.constructor.name+": "+t.message:"";return warn(`Could not process stack trace (${r||t}), printing original.`),e.stack}}function patchError(e){e.prototype.toString=function(){return formatError(this)}}function formatError(e){let t;try{if(!(e instanceof Object))return""+e;if(!(e instanceof Error))return e.constructor.name+": "+e.toString();t=getStackArray(e.stack).map(e=>"  at "+e).join("\n")}catch(r){t=e.stack}return e.constructor.name+": "+e.message+"\n"+t}function formatPromiseRejectionReason(e){let t;return t=e&&"function"==typeof e.toString?e.toString():void 0===e?"":e+"",e&&e.stack||(t+="\n"+getStackTrace(new Error,!0)),t}function getCurrentLine(e){try{return getStackArray(e.stack)[0].trim()}catch(e){return""}}function getStackArray(e){const t=limitStack([e].concat(tabris._stackTraceStack).join("\n").split("\n").filter(filterStackLine)).map(normalizeStackLine).filter(e=>!!e);if(!t.length)throw new Error("Empty stacktrace");return t}function limitStack(e){if(e.length>300){const t=e.length-300;return e.slice(0,150).concat(["["+t+" more lines...]"]).concat(e.slice(-150))}return e}function filterStackLine(e){return!("Android"===tabris.device.platform&&!androidStackLineNoNameRegex.test(e))&&(-1===e.indexOf("tabris/tabris.min.js:")&&-1===e.indexOf("@[native code]")&&-1===e.indexOf("<anonymous>:"))}function normalizeStackLine(e){if(e.endsWith("more lines...]"))return e;const t=applySourceMap(parseLine(e));return t?t.fn?`${t.fn} (${t.url}:${t.line}:${t.column})`:`${t.url}:${t.line}:${t.column}`:null}function parseLine(e){const t="Android"===tabris.device.platform?androidStackLineRegex:iosStackLineRegex,r="Android"===tabris.device.platform?androidStackLineNoNameRegex:iosStackLineNoNameRegex,n=e.match(t),i=e.match(r);if(n&&5===n.length){const[,e,t,r,i]=n;return{fn:normalizeFunctionName(e),url:fixUrl(t),line:parseInt(r,10),column:parseInt(i,10)}}if(i&&4===i.length){const[,e,t,r]=i;return{fn:null,url:fixUrl(e),line:parseInt(t,10),column:parseInt(r,10)}}return null}function normalizeFunctionName(e){let t=e.split(".").pop();return"then"!==t&&"<anonymous>"!==t||(t=null),t}function fixUrl(e){const t=e.match(urlBaseRegEx);return t?"./"+e.slice(t[0].length):e}function applySourceMap(e){if(!e)return null;const{fn:t}=e;let{url:r,line:n,column:i}=e;const o=tabris.Module.getSourceMap(r);if(o){o.decodedMappings||(o.decodedMappings=decodeMappings(o.mappings));const e=findMapping(o.decodedMappings,n,i);if(!(e&&e.length>=4))return null;{const[t,a,s,l]=e,c=/^[A-Za-z]:/.test(r)?"win":"unix";r=normalizePath(dirname(r,c)+"/"+o.sources[a],c),"unix"!==c||r.startsWith("/")||r.startsWith("./")||(r="./"+r),n=s+1,i+=l-t}}return{fn:t,url:r,line:n,column:i}}function findMapping(e,t,r){const n=e?e[t-1]:null;return n&&n.length?n.find((e,t)=>{if(!e)return!1;const i=n[t+1],o=e[0]+1,a=i?i[0]+1:1/0;return 0===t&&r<o||r>=o&&r<a}):null}const charToInteger={};function decodeMappings(e){let t=0,r=0,n=0,i=0;return e.split(";").map(e=>e.split(",").map(decodeVLQ)).map(e=>{let o=0;return e.map(e=>{if(0===e.length)return null;const a=[o+=e[0]];return 1===e.length?a:(t+=e[1],r+=e[2],n+=e[3],a.push(t,r,n),5===e.length&&(i+=e[4],a.push(i)),a)})})}function decodeVLQ(e){const t=[];let r=0,n=0;for(let i=0;i<e.length;i++){let o=charToInteger[e[i]];if(void 0===o)throw new Error("Invalid character ("+e[i]+")");const a=32&o;if(n+=(o&=31)<<r,a)r+=5;else{const e=1&n;n>>=1,t.push(e?-n:n),n=r=0}}return t}function asap(e){setTimeout(e,0)}function noop(){}"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach((e,t)=>{charToInteger[e]=t});let LAST_ERROR=null;const IS_ERROR={};function getThen(e){try{return e.then}catch(e){return LAST_ERROR=e,IS_ERROR}}function tryCallOne(e,t){try{return e(t)}catch(e){return LAST_ERROR=e,IS_ERROR}}function tryCallTwo(e,t,r){try{e(t,r)}catch(e){return LAST_ERROR=e,IS_ERROR}}function getStackTraceStack(){return global.tabris?global.tabris._stackTraceStack:[]}function setStackTraceStack(e){global.tabris&&(global.tabris._stackTraceStack=e)}const Promise$1=function Promise(e){const t=[(new Error).stack].concat(getStackTraceStack().slice(0,10));if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");Object.defineProperties(this,{_deferredState:{value:0,writable:!0},_state:{value:0,writable:!0},_value:{value:null,writable:!0},_stackTraceStack:{value:t,writable:!1},_deferreds:{value:null,writable:!0}}),e!==noop&&doResolve(e,this)};function safeThen(e,t,r){return new e.constructor((n,i)=>{const o=new Promise$1(noop);o.then(n,i),handle(e,new Handler(t,r,o))})}function handle(e,t){for(;3===e._state;)e=e._value;if(Promise$1._onHandle&&Promise$1._onHandle(e),0===e._state)return 0===e._deferredState?(e._deferredState=1,void(e._deferreds=t)):1===e._deferredState?(e._deferredState=2,void(e._deferreds=[e._deferreds,t])):void e._deferreds.push(t);handleResolved(e,t)}function handleResolved(e,t){asap(()=>{const r=1===e._state?t.onFulfilled:t.onRejected;if(null===r)return void(1===e._state?resolve(t.promise,e._value):reject(t.promise,e._value));const n=getStackTraceStack();setStackTraceStack(e._stackTraceStack);const i=tryCallOne(r,e._value);setStackTraceStack(n),i===IS_ERROR?reject(t.promise,LAST_ERROR):resolve(t.promise,i)})}function resolve(e,t){if(t===e)return reject(e,new TypeError("A promise cannot be resolved with itself."));if(t&&("object"==typeof t||"function"==typeof t)){const r=getThen(t);if(r===IS_ERROR)return reject(e,LAST_ERROR);if(r===e.then&&t instanceof Promise$1)return e._state=3,e._value=t,void finale(e);if("function"==typeof r)return void doResolve(r.bind(t),e)}e._state=1,e._value=t,finale(e)}function reject(e,t){e._state=2,e._value=t,Promise$1._onReject&&Promise$1._onReject(e,t),finale(e)}function finale(e){if(1===e._deferredState&&(handle(e,e._deferreds),e._deferreds=null),2===e._deferredState){for(let t=0;t<e._deferreds.length;t++)handle(e,e._deferreds[t]);e._deferreds=null}}function Handler(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}function doResolve(e,t){let r=!1;const n=tryCallTwo(e,e=>{r||(r=!0,resolve(t,e))},e=>{r||(r=!0,reject(t,e))});r||n!==IS_ERROR||(r=!0,reject(t,LAST_ERROR))}function valuePromise(e){const t=new Promise$1(Promise$1._noop);return t._state=1,t._value=e,t}function isPending(e){return 0===e._state}function isRejected(e){return 2===e._state}function getPromiseResult(e){return e._value}Promise$1._noop=noop,Promise$1.prototype.then=function(e,t){if(this.constructor!==Promise$1)return safeThen(this,e,t);const r=new Promise$1(noop);return handle(this,new Handler(e,t,r)),r},Promise$1.resolve=function(e){if(e instanceof Promise$1)return e;if(null===e)return valuePromise(null);if("object"==typeof e||"function"==typeof e)try{const t=e.then;if("function"==typeof t)return new Promise$1(t.bind(e))}catch(e){return new Promise$1((t,r)=>r(e))}return valuePromise(e)},Promise$1.all=function(e){const t=Array.prototype.slice.call(e);return new Promise$1((e,r)=>{if(0===t.length)return e([]);let n=t.length;function res(i,o){if(o&&("object"==typeof o||"function"==typeof o)){if(o instanceof Promise$1&&o.then===Promise$1.prototype.then){for(;3===o._state;)o=o._value;return 1===o._state?res(i,o._value):(2===o._state&&r(o._value),void o.then(e=>res(i,e),r))}{const e=o.then;if("function"==typeof e){return void new Promise$1(e.bind(o)).then(e=>res(i,e),r)}}}t[i]=o,0==--n&&e(t)}for(let e=0;e<t.length;e++)res(e,t[e])})},Promise$1.reject=function(e){return new Promise$1((t,r)=>r(e))},Promise$1.race=function(e){return new Promise$1((t,r)=>e.forEach(e=>Promise$1.resolve(e).then(t,r)))},Promise$1.prototype.catch=function(e){return this.then(null,e)};const rejectionId=Symbol("rejection id");let lastRejectionId=0,rejectionDisplayId=0;const rejections={};function assign(e){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");const t=Object(e);for(let e=1;e<arguments.length;e++){const r=arguments[e];if(void 0===r||null===r)continue;const n=Object.keys(Object(r));for(const e of n){const n=Object.getOwnPropertyDescriptor(r,e);void 0!==n&&n.enumerable&&(t[e]=r[e])}}return t}function checkVersion(e,t){if(!t)return;const r=e.split("."),n=t.split(".");r[0]===n[0]&&r[1]===n[1]||error(`Version mismatch: JavaScript module "tabris" (version ${e}) `+`is incompatible with the native tabris platform (version ${t}).`)}function __rest(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function __awaiter(e,t,r,n){return new(r||(r=Promise))(function(i,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n.throw(e))}catch(e){o(e)}}function step(e){e.done?i(e.value):function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})}Promise$1._onHandle=(e=>{2===e._state&&rejections[e[rejectionId]]&&(rejections[e[rejectionId]].logged?console.warn(`Uncaught promise rejection (id: ${rejections[e[rejectionId]].displayId}) handled.`):clearTimeout(rejections[e[rejectionId]].timeout),delete rejections[e[rejectionId]])}),Promise$1._onReject=((e,t)=>{0===e._deferredState&&(e[rejectionId]=lastRejectionId++,rejections[e[rejectionId]]={displayId:null,error:t,timeout:setTimeout(()=>{const r=e[rejectionId];rejections[r].displayId=rejectionDisplayId++,rejections[r].logged=!0,console.error(`Uncaught promise rejection (id: ${rejections[r].displayId}) ${formatPromiseRejectionReason(t)}`)},0),logged:!1})}),global.Promise=Promise$1,"undefined"==typeof window&&(global.window=global),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:assign});class EventObject{constructor(){Object.defineProperties(this,{type:{enumerable:!0,get:()=>this.$type},target:{enumerable:!0,get:()=>this.$target},timeStamp:{enumerable:!0,value:Date.now()},$type:{enumerable:!1,writable:!0,value:""},$target:{enumerable:!1,writable:!0,value:null},$defaultPrevented:{enumerable:!1,writable:!0,value:!1}})}static create(e,t,r){const n=r instanceof EventObject&&!r.type?r:new EventObject,i=e.$eventTarget||e;if(r&&r!==n){const e=omit(r,["type","target","timeStamp"]);for(const t in e){const r=/^[a-z]/.test(t);Object.defineProperty(n,t,{value:e[t],writable:!r,enumerable:r})}}return n._initEvent instanceof Function&&n._initEvent(t,i),n}get defaultPrevented(){return!!this.$defaultPrevented}preventDefault(){this.$defaultPrevented=!0}set originalEvent(e){if(this.$originalEvent)throw new Error("originalEvent already set");e&&(this.$originalEvent=e)}get originalEvent(){const e=this.$originalEvent;return e?e instanceof EventObject?e:e.dispatchObject instanceof EventObject?e.dispatchObject:this.$originalEvent=EventObject.create(e.target,e.type,e):null}toString(){return this.constructor.name+" { "+Object.keys(this).map(e=>`${e}: ${"string"==typeof this[e]?JSON.stringify(this[e]):format(this[e])}`).join(", ")+" }"}_initEvent(e,t){if(arguments.length<2)throw new Error("Not enough arguments to initEvent");this.$type=e,this.$target=t}}class EventsClass{on(e,t,r){if(e instanceof Object){for(const t in e)this.on(t,e[t]);return this}assertType(e),assertCallback(t),assertContext(r),this._isDisposed&&hint(this,`Event registration warning: Can not listen for event "${e}" on disposed object`);const n=this._isListening(e);return this._callbacks||Object.defineProperty(this,"_callbacks",{enumerable:!1,writable:!1,configurable:!0,value:[]}),this._callbacks[e]=(this._callbacks[e]||[]).concat(),this._callbacks[e].some(e=>(e.fn===t||"_callback"in t&&e.fn._callback===t._callback)&&e.ctx===r)||this._callbacks[e].push({fn:t,ctx:r}),n||this._listen(stripPrefix(e),!0),this}off(e,t,r){if(e instanceof Object){for(const t in e)this.off(t,e[t]);return this}if(!e||!t)throw new Error("Not enough arguments");if(this._callbacks&&e in this._callbacks){const n=this._callbacks[e].concat();for(let e=n.length-1;e>=0;e--)n[e].fn!==t&&n[e].fn._callback!==t||n[e].ctx!==r||n.splice(e,1);0===n.length?delete this._callbacks[e]:this._callbacks[e]=n}return this._isListening(e)||this._listen(stripPrefix(e),!1),this}once(e,t,r){if(e instanceof Object){for(const t in e)this.once(t,e[t]);return this}assertCallback(t);const n=this,i=function(){n._isDisposed||n.off(e,i,r),t.apply(this,arguments)};return i._callback=t,this.on(e,i,r)}trigger(e,t={}){return this[notify](e,t,!1),this}triggerAsync(e,t={}){return __awaiter(this,void 0,void 0,function*(){return yield this[notify](e,t,!0),this})}[notify](e,t,r){if(this._isDisposed)return hint(this,`Trigger warning: Can not dispatch event "${e}" on disposed object`),null;const n=[];let i=null;if(this._callbacks||(this._callbacks={}),e in this._callbacks){i=EventObject.create(this,e,t);for(const t of this._callbacks[e]){const r=notifyCallback(this,t,i);handlePromise(r,i,e),n.push(r)}}const o=getInternalListeners(this,e);if(o){const r=Object.assign({type:e,dispatchObject:i,target:this},t);for(const e of o)notifyCallback(this,e,r)}return r?Promise$1.all(n).then(()=>i):i}_isListening(e){return!(!this._callbacks||!e)&&(e in this._callbacks||"_"+e in this._callbacks)}_listen(e,t){}}const EventsMixin={};function handlePromise(e,t,r){e instanceof Promise$1&&e.catch(e=>{console.error(`Listener for ${t.target.constructor.name} event `+`"${r}" rejected: ${formatPromiseRejectionReason(e)}`)})}function assertCallback(e){if(!(e instanceof Function))throw new Error(toValueString(e)+" is not a function")}function assertType(e){if("string"!=typeof e)throw new Error(toValueString(e)+" is not a string")}function assertContext(e){if(e&&!(e instanceof Object))throw new Error(toValueString(e)+" is not an object")}function getInternalListeners(e,t){const r=e._callbacks["*"],n=e._callbacks["_"+t];return r&&n?r.concat(n):null!==r&&void 0!==r?r:n}function notifyCallback(e,t,r){return t.fn.call(t.ctx||e,r)}function stripPrefix(e){return e.startsWith("_")?e.slice(1):e}function checkType(e,t,r){if(!t)throw new TypeError("No type given");if(isBoxedValue(e))throw new TypeError("Boxed values are forbidden");const n=r instanceof Function?r:null,i=!r||n?{}:r,o=i.name||toValueString(e),a=i.typeName||getTypeName(t);if(!isType(e,t,i.nullable))throw new TypeError(`Expected ${o} to be ${a}, got ${getValueTypeName(e)}.`);if("number"==typeof e&&checkNumber$1(e,o),!n)return e;n(e)}function isType(e,t,r){return!(!r||null!==e&&void 0!==e)||!!(e instanceof t||isPrimitiveOfType(e,t))}function getTypeName(e){const t=e.name;return"Function"===t?"a function":"Object"===t?"an object":"Array"===t?"an array":isPrimitiveType(e)?"a "+t.toLowerCase():"of type "+t}function getValueTypeName(e){return null!=e&&isPrimitiveType(e.constructor)?e.constructor.name.toLowerCase():e&&e.constructor?e.constructor.name:null===e?"null":typeof e}function isPrimitiveOfType(e,t){return!!isPrimitiveType(t)&&typeof e===t.name.toLowerCase()}function checkNumber$1(e,t){if(isNaN(e))throw new TypeError(`Expected ${t} to be a valid number, got ${toValueString(e)}.`);if(!isFinite(e))throw new TypeError(`Expected ${t} to be a finite number, got ${toValueString(e)}.`)}function isBoxedValue(e){return e instanceof Boolean||e instanceof Number||e instanceof String}function isPrimitiveType(e){return e===Boolean||e===Number||e===String}Reflect.ownKeys(EventsClass.prototype).forEach(e=>{"constructor"!==e&&(EventsMixin[e]=EventsClass.prototype[e])});const noop$1=(...e)=>void 0;Symbol.observable||Object.defineProperty(Symbol,"observable",{value:observable});class Observable{constructor(e=noop$1){if(!(e instanceof Function))throw new TypeError(`Expected subscribe to be a function, got ${getValueTypeName(e)}.`);this._subscribe=e,this.subscribe=this.subscribe.bind(this)}static mutations(e){return new Observable(t=>{const r=()=>t.next(e);return r(),this.changeEvents(e,!0).subscribe({next:()=>this.defer(r),complete:t.complete,error:t.error})})}static changeEvents(e,t){return new Observable(r=>{const n=Listeners.getListenerStore(e),i=e[nativeObservables],o=()=>null,a=e=>{var n;e.type.endsWith("Changed")&&(!0===t?r.next(e):r.next(null!==(n=e.dispatchObject)&&void 0!==n?n:EventObject.create(e.target,e.type,e)))};return n.on({"*":a,dispose:r.complete}),null===i||void 0===i||i.forEach(e=>n.on(e,o)),()=>{n.off({"*":a,dispose:r.complete}),null===i||void 0===i||i.forEach(e=>n.off(e,o))}})}subscribe(e,t,r){const n="function"==typeof e||1!==arguments.length?{next:e,error:t,complete:r}:e;let i=!1,o=noop$1;const a={unsubscribe:()=>{o(),i=!0},get closed(){return i}},s=this._subscribe(createSubscriber(n,a));return o=getUnsubscribe(s),a.closed&&o(),a}[Symbol.observable](){return this}static defer(e){-1===this.deferred.indexOf(e)&&this.deferred.push(e),this.inFlush||tabris.once("tick",this.flush)}static flush(){let e=Observable.deferred.length+100;for(;Observable.deferred.length;)try{if(0===--e)throw Observable.deferred=[],new Error("Mutations observer recursion");Observable.deferred.shift()()}catch(e){console.error(null===e||void 0===e?void 0:e.message)}}}function createSubscriber(e,t){const r=e.next||noop$1,n=e.error||noop$1,i=e.complete||noop$1;return{next:n=>{t.closed||null===r||void 0===r||r.call(e,n)},error:r=>{t.closed||(t.unsubscribe(),null===n||void 0===n||n.call(e,r))},complete:()=>{t.closed||(t.unsubscribe(),null===i||void 0===i||i.call(e))},get closed(){return t.closed}}}function getUnsubscribe(e){let t=!1;return()=>{t||(t=!0,e instanceof Function?e():e&&e.unsubscribe instanceof Function&&e.unsubscribe())}}Observable.deferred=[],Observable.inFlush=!1;const eventStoreMap=new WeakMap,DELEGATE_FIELDS=["promise","addListener","removeListener","once","trigger","triggerAsync","subscribe",observable];class Listeners extends Observable{constructor(e,t){if(super(e=>this._handleSubscription(e)),this.target=e,this.type=t,arguments.length<1)throw new Error("Missing target instance");if(!(e instanceof Object))throw new Error(`Target ${toValueString(e)} is not an object`);if(arguments.length<2||!t)throw new Error("Missing event type string");if("string"!=typeof t)throw new Error(`Event type ${toValueString(t)} is not a string`);if(/^on[A-Z]/.test(t))throw new Error(`Invalid event type string, did you mean "${t[2].toLowerCase()+t.slice(3)}"?`);this.store=Listeners.getListenerStore(e);const r=this,n=Object.assign(this.addListener.bind(this),{original:r,target:e,type:t});for(const e of DELEGATE_FIELDS)n[e]=r[e]=r[e].bind(this);return n}static getListenerStore(e){return e.on instanceof Function?e:(eventStoreMap.has(e)||eventStoreMap.set(e,Object.assign({$eventTarget:e},EventsMixin)),eventStoreMap.get(e))}static trigger(e,t,r){const n=e.on instanceof Function?e:eventStoreMap.get(e);null===n||void 0===n||n.trigger(t,r)}get original(){return this}trigger(e){return this.store.trigger(this.type,e),this.target}triggerAsync(e){return __awaiter(this,void 0,void 0,function*(){return this.store.triggerAsync(this.type,e).then(()=>this.target)})}promise(){return __awaiter(this,void 0,void 0,function*(){return new Promise$1(e=>this.once(e))})}once(e){return this.store.once(this.type,e),this.target}addListener(e){return this.store.on(this.type,e),this.target}removeListener(e){return this.store.off(this.type,e),this.target}_handleSubscription(e){return this.addListener(e.next),this.store.on("_dispose",e.complete),()=>{this.removeListener(e.next),this.store.off("dispose",e.complete)}}}function attributesWithoutListener(e){return omit(e,Object.keys(e).filter(isListenerAttribute))}function registerListenerAttributes(e,t,r){e.jsxAttributes||(e.jsxAttributes={});const n=r||e.jsxAttributes,i=getEventListeners(t),o=Listeners.getListenerStore(e);Object.keys(i).forEach(e=>{const t=n[e];if(t){if(i[e]===t)return;o.off(e,t)}i[e]&&o.on(e,n[e]=i[e])})}function isListenerAttribute(e){return e.startsWith("on")&&e.charCodeAt(2)<=90}function getEventListeners(e){const t={};for(const r in e)if(isListenerAttribute(r)){t[r[2].toLocaleLowerCase()+r.slice(3)]=e[r]}return t}const PUBLIC_PROP=/^[a-z]/;var internal;!function(e){class ObservableData{static generateChangeEvents(e){var t;const r=e.target,n=e.target[e.property],i=`$${String(e.property)}Subscription`,o=e.subscriptions||r,a=String(e.property)+"Changed";let s=null;if(null===(t=o[i])||void 0===t||t.unsubscribe(),e.init||Listeners.trigger(r,a,{value:n}),n instanceof Object){let e=null;s=Observable.changeEvents(n,!0).subscribe(t=>{(null===e||void 0===e?void 0:e.type)===t.type&&(null===e||void 0===e?void 0:e.value)===t.value||(e=t,Listeners.trigger(r,a,{value:n,$originalEvent:e}),e=null)})}Object.defineProperty(o,i,{enumerable:!1,writable:!0,value:s})}constructor(e){const t={},r=new Proxy(this,{set(e,n,i,o){const a=!hasSetter(e,n),s=Reflect.set(e,n,i,o);return s&&!a&&isPublicProperty(n,i)&&ObservableData.generateChangeEvents({target:r,property:n,subscriptions:t}),s},defineProperty(e,n,...i){const o=Reflect.defineProperty(e,n,...i),a=e[n];return o&&isPublicProperty(n,a)&&ObservableData.generateChangeEvents({target:r,property:n,subscriptions:t}),o}});return Object.assign(r,e)}[Symbol.observable](){return Observable.changeEvents(this)}}e.ObservableData=ObservableData}(internal||(internal={}));const ObservableData=new Proxy(internal.ObservableData,{apply:(e,t,r)=>new internal.ObservableData(r[0]||{})});function hasSetter(e,t){var r;return t in(Reflect.getPrototypeOf(e)||{})||!!(null===(r=Reflect.getOwnPropertyDescriptor(e,t))||void 0===r?void 0:r.set)}function isPublicProperty(e,t){return"string"==typeof e&&PUBLIC_PROP.test(e)&&!(t instanceof Function&&t.original instanceof Listeners)}ObservableData.prototype.constructor=ObservableData;class ChangeListeners extends Listeners{constructor(e,t){propertyCheck(e,t),super(e,t+"Changed"),this.$current=(()=>e[t]),Object.defineProperty(this,"values",{get:()=>Reflect.get(ChangeListeners.prototype,"values",this)})}trigger(e){if(!(e&&"value"in e))throw new Error('Can not trigger change event without "value" property in event data');return super.trigger(e)}get values(){return this.$values||(this.$values=new Observable(e=>{e.next(this.$current());const t=this.subscribe({next:t=>e.next(t.value),error:e.error,complete:e.complete});return()=>t.unsubscribe()})),this.$values}}function propertyCheck(e,t){if(!(t in e||e instanceof ObservableData))throw new Error(`Target has no property "${t}"`)}function colorArrayToString(e){return"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+(3===e.length?1:Math.round(100*e[3]/255)/100)+")"}function colorStringToArray(e){if("transparent"===e)return[0,0,0,0];if(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?$/.test(e))return[parseInt(RegExp.$1,16),parseInt(RegExp.$2,16),parseInt(RegExp.$3,16),""===RegExp.$4?255:parseInt(RegExp.$4,16)];if(/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?$/.test(e))return[17*parseInt(RegExp.$1,16),17*parseInt(RegExp.$2,16),17*parseInt(RegExp.$3,16),""===RegExp.$4?255:17*parseInt(RegExp.$4,16)];if(/^rgb\s*\(\s*([+-]?[0-9]+)\s*,\s*([+-]?[0-9]+)\s*,\s*([+-]?[0-9]+)\s*\)$/.test(e))return[Math.max(0,Math.min(255,parseInt(RegExp.$1))),Math.max(0,Math.min(255,parseInt(RegExp.$2))),Math.max(0,Math.min(255,parseInt(RegExp.$3))),255];if(/^rgba\s*\(\s*([+-]?[0-9]+)\s*,\s*([+-]?[0-9]+)\s*,\s*([+-]?[0-9]+)\s*,\s*([+-]?([0-9]*\.)?[0-9]+)\s*\)$/.test(e))return[Math.max(0,Math.min(255,parseInt(RegExp.$1))),Math.max(0,Math.min(255,parseInt(RegExp.$2))),Math.max(0,Math.min(255,parseInt(RegExp.$3))),Math.round(255*Math.max(0,Math.min(1,parseFloat(RegExp.$4))))];if(e in NAMES){const t=NAMES[e];return[t[0],t[1],t[2],255]}throw new Error(`${toValueString(e)} is not a valid color`)}const NAMES={black:[0,0,0],silver:[192,192,192],gray:[128,128,128],white:[255,255,255],maroon:[128,0,0],red:[255,0,0],purple:[128,0,128],fuchsia:[255,0,255],green:[0,128,0],lime:[0,255,0],olive:[128,128,0],yellow:[255,255,0],navy:[0,0,128],blue:[0,0,255],teal:[0,128,128],aqua:[0,255,255],transparent:[0,0,0,0]};class Color{static isColorValue(e){return null==e||"initial"===e||Color.isValidColorValue(e)}static isValidColorValue(e){try{return Color.from(e),!0}catch(e){return!1}}static from(e){if(e instanceof Color)return e;if(e instanceof Array)return arrayToColorInstance(e);if(e instanceof Object)return colorLikeObjectToColorInstance(e);if("string"==typeof e)return arrayToColorInstance(colorStringToArray(e));throw new Error(`Not a valid ColorValue: ${toValueString(e)}`)}constructor(e,t,r,n=255){if(arguments.length>4)throw new Error("Too many arguments");if(arguments.length<3)throw new Error("Not enough arguments");setChannel(this,"red",e),setChannel(this,"green",t),setChannel(this,"blue",r),setChannel(this,"alpha",n)}toString(){return 255===this.alpha?`rgb(${this.red}, ${this.green}, ${this.blue})`:`rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round(100*this.alpha/255)/100})`}toArray(){return[this.red,this.green,this.blue,this.alpha]}equals(e){return e instanceof Color&&(e.red===this.red&&e.green===this.green&&e.blue===this.blue&&e.alpha===this.alpha)}}function setChannel(e,t,r){checkNumber(r,[0,255],`Invalid color value ${toValueString(t)}`),Object.defineProperty(e,t,{enumerable:!0,value:Math.round(r)})}function colorLikeObjectToColorInstance(e){return checkProperty(e,"red"),checkProperty(e,"green"),checkProperty(e,"blue"),"alpha"in e?new Color(e.red,e.green,e.blue,e.alpha):new Color(e.red,e.green,e.blue)}function arrayToColorInstance(e){if(e.length<3)throw new Error("Color array too short");if(e.length>4)throw new Error("Color array too long");return new Color(e[0],e[1],e[2],4===e.length?e[3]:255)}function checkProperty(e,t){if(!(t in e))throw new Error(`Color-like object missing ${t} value`)}Color.prototype[equals]=Color.prototype.equals,Object.keys(NAMES).forEach(e=>{let t;Object.defineProperty(Color,e,{get:()=>(t||(t=Color.from(NAMES[e])),t)})});const FONT_STYLES=["italic","normal"],FONT_WEIGHTS=["black","bold","medium","thin","light","normal"];function fontStringToObject(e){const t={family:[],size:0,style:"normal",weight:"normal"},r=e.split(/(?:\s|^)\d+px(?:\s|$)/);checkTruthy(2===r.length,"Invalid font syntax");const[n,i]=r;return t.size=parseInt(/(?:\s|^)(\d+)px(?:\s|$)/.exec(e)[1],10),parseSizePrefix(t,n),parseFamily(t,i),t}function fontObjectToString(e){return["normal"===e.style?"":e.style,"normal"===e.weight?"":e.weight,e.size+"px",e.family.join(", ")].filter(e=>!!e).join(" ").trim()}function validateFamily(e){checkTruthy(/(?:^\s*[^"']+\s*$)|(?:^\s*"[^"']+"\s*$)|(?:^\s*'[^"']+'\s*$)/.exec(e),"Invalid font family: "+e)}function validateStyle(e){checkTruthy(isStyle(e),`Invalid font style ${e}`)}function validateWeight(e){checkTruthy(isWeight(e),`Invalid font weight ${e}`)}function normalizeFamily(e){return/^\s*["']?([^"']*)/.exec(e)[1].trim()}function normalizeWeight(e){return e.trim()}function normalizeStyle(e){return e.trim()}function parseSizePrefix(e,t){const r=t.trim().split(/\s+/);checkTruthy(r.length<=2,"Too many font size prefixes");const{style:n,weight:i}=parseSizePrefixes(r);e.style=n,e.weight=i}function parseSizePrefixes(e){if(1===e.length){const t=e[0];if(isStyle(t))return{weight:"normal",style:normalizeStyle(t)};if(isWeight(t))return{weight:normalizeWeight(t),style:"normal"};if("normal"===t||""===t)return{style:"normal",weight:"normal"};throw new Error(`Invalid font style or weight ${t}`)}if(2===e.length)return validateStyle(e[0]),validateWeight(e[1]),{style:normalizeStyle(e[0]),weight:normalizeWeight(e[1])}}function isStyle(e){return"string"==typeof e&&FONT_STYLES.includes(e.trim())}function isWeight(e){return"string"==typeof e&&FONT_WEIGHTS.includes(e.trim())}function parseFamily(e,t){(t?t.split(","):[]).forEach(t=>{validateFamily(t),e.family.push(normalizeFamily(t))})}function checkTruthy(e,t){if(!e)throw new Error(t)}class Font{static isFontValue(e){return null==e||"initial"===e||Font.isValidFontValue(e)}static isValidFontValue(e){try{return Font.from(e),!0}catch(e){return!1}}static from(e){if(e instanceof Font)return e;if(e instanceof Object)return fontLikeObjectToFontInstance(e);if("string"==typeof e)return fontLikeObjectToFontInstance(fontStringToObject(e));throw new Error(`${toValueString(e)} is not a valid FontValue`)}static get sansSerif(){return"sans-serif"}static get serif(){return"serif"}static get monospace(){return"monospace"}static get condensed(){return"condensed"}constructor(e,t=[],r="normal",n="normal"){if(arguments.length<1)throw new Error("Not enough arguments");setSize(this,e),setFamily(this,t),setWeight(this,r),setStyle(this,n)}toString(){return fontObjectToString(this)}equals(e){return e instanceof Font&&(e.size===this.size&&e.weight===this.weight&&e.style===this.style&&e.family.length===this.family.length&&e.family.every((e,t)=>this.family[t]===e))}}function setFamily(e,t){if(!(t instanceof Array))throw new Error("family is not an array");t.forEach(validateFamily);const r=Object.freeze(t.map(normalizeFamily));Object.defineProperty(e,"family",{enumerable:!0,value:r})}function setSize(e,t){checkNumber(t,[0,1/0],"Invalid font size"),Object.defineProperty(e,"size",{enumerable:!0,value:t})}function setWeight(e,t){validateWeight(t),Object.defineProperty(e,"weight",{enumerable:!0,value:normalizeWeight(t)})}function setStyle(e,t){validateStyle(t),Object.defineProperty(e,"style",{enumerable:!0,value:normalizeStyle(t)})}function fontLikeObjectToFontInstance(e){return checkProperty$1(e,"size"),new Font(e.size,e.family||[],e.weight||"normal",e.style||"normal")}function checkProperty$1(e,t){if(!(t in e))throw new Error(`Font-like object missing ${t} value`)}Font.prototype[equals]=Font.prototype.equals;const COMMON_ATTR=Object.freeze({textColor:e=>Color.from(e).toString(),font:e=>Font.from(e).toString(),children:e=>{if(!(e instanceof Array))throw new Error("Not an array: "+toValueString(e));return e}}),MARKUP=Object.freeze({br:{},b:COMMON_ATTR,span:COMMON_ATTR,big:COMMON_ATTR,i:COMMON_ATTR,small:COMMON_ATTR,strong:COMMON_ATTR,ins:COMMON_ATTR,del:COMMON_ATTR,a:Object.assign({href:e=>{if("string"!=typeof e)throw new Error("Not a string: "+toValueString(e));return e}},COMMON_ATTR)});function createJsxProcessor(){return new JsxProcessor}class JsxProcessor{createElement(e,t,...r){if(!(e instanceof Function)&&"string"!=typeof e)throw new Error(`JSX: Unsupported type ${toValueString(e)}`);const n=e instanceof Function?e.name:e;if((null===t||void 0===t?void 0:t.children)&&r&&r.length)throw new Error(`JSX: Children for type ${n} given twice.`);const i=r.length?r:(null===t||void 0===t?void 0:t.children)||[],{finalChildren:o,additionalAttributes:a}=parseChildren(i,e),s=Object.assign({},t);return joinAttributes(s,a,e),o&&(s.children=o),"string"==typeof e?this.createIntrinsicElement(e,s):e.prototype&&e.prototype[JSX.jsxFactory]?this.createCustomComponent(e,s):this.createFunctionalComponent(e,s)}createCustomComponent(e,t){return e.prototype[JSX.jsxFactory].call(this,e,t)}createFunctionalComponent(e,t){try{const r=e.call(this,t);return e[jsxType]=!0,r instanceof Object&&(r[jsxType]=e),r}catch(e){throw new Error(`JSX: "${null===e||void 0===e?void 0:e.message}" ${getCurrentLine(e)}`)}}createIntrinsicElement(e,t){if(e in MARKUP){const r={};Object.keys(t||{}).forEach(n=>{const i=MARKUP[e][n];if(!i)throw"children"===n?new Error(`Element "${e}" can not have children`):new Error(`Element "${e}" does not support attribute "${n}"`);try{r[n]=i(t[n])}catch(t){throw new Error(`Element "${e}" attribute "${n}" can not bet set: ${null===t||void 0===t?void 0:t.message}`)}});const n=joinTextContent(r.children,!0),i=[e].concat(Object.keys(r||{}).filter(e=>"children"!==e).map(e=>`${e}='${r[e]}'`)).join(" ");return n?`<${i}>${n}</${e}>`:`<${i}/>`}throw new Error(`JSX: Unsupported type ${e}`)}createNativeObject(e,t){if(t&&"children"in t)throw new Error(`JSX: ${e.name} can not have children`);const r=attributesWithoutListener(t||{}),{data:n}=r,i=new e(__rest(r,["data"]));return registerListenerAttributes(i,t),n&&(i.data=n),i}getChildren(e){return e&&"children"in e?flattenChildren(e.children):null}withoutChildren(e){return omit(e,["children"])}withContentText(e,t,r,n){if(e&&e[r]&&t&&t.length)throw new Error(`JSX: ${r} given twice`);const i=e&&e[r]?e[r].toString():joinTextContent(t||[],n);return Object.assign(e||{},i?{[r]:i}:{})}withContentChildren(e,t,r){if(e&&e[r]&&t&&t.length)throw new Error(`JSX: ${r} given twice`);const n=e&&e[r]?e[r]:t||[];return Object.assign(e||{},n?{[r]:n}:{})}withShorthands(e,t,r){const n=Object.keys(t),i=n.filter(t=>t in e);if(!i.length)return e;const o=omit(e,n);return i.forEach(e=>{const n=t[e];o[n]=n in o?r(o[n],e):e}),o}makeFactories(e){const t={};return Object.keys(e).forEach(r=>{t[r]=this.makeFactory(e[r])}),t}makeFactory(e){if(1!==arguments.length)throw new Error(`Expected exactly one argument, got ${arguments.length}`);if(checkType(e,Function,"first parameter"),!e.prototype||!e.prototype[JSX.jsxFactory])throw new Error(`Function ${e.name} is not a valid constructor`);return e[originalComponent]?this.makeFactory(e[originalComponent]):createFactoryProxy(this,e)}}function createFactoryProxy(e,t){const r={apply(t,r,i){const[o,a]=i;if(i.length>1){if(!(a instanceof Function))throw new TypeError("Second parameter must be a function");if(a.prototype&&a.prototype[JSX.jsxFactory])throw new TypeError("Second parameter must be a factory")}const s=e.createElement(n,o);return i.length>1&&s instanceof Object&&(a[JSX.jsxType]=!0,s[JSX.jsxType]=a),s},get(e,i,o){if(o===n){if(i===originalComponent)return t;if(i===proxyHandler)return r}return Reflect.get(e,i,o)}},n=new Proxy(t,r);return n}function flattenChildren(e){if(e instanceof Array){let t=[];for(const r of e)r&&r.toArray?t=t.concat(flattenChildren(r.toArray())):r instanceof Array?t=t.concat(flattenChildren(r)):t.push(r);return t}return[e]}function joinTextContent(e,t){return e?t?e.map(e=>e+"").join("").replace(/\s+/g," ").replace(/\s*<br\s*\/>\s*/g,"<br/>"):e.join(""):null}const JSX={processor:null,jsxFactory:jsxFactory,jsxType:jsxType,install(e){this.processor=e},createElement(){return this.processor.createElement.apply(this.processor,arguments)}};function parseChildren(e,t){const r=null===e||void 0===e?void 0:e.filter(e=>!isAttributesObject(e)),n=null===e||void 0===e?void 0:e.filter(isAttributesObject).reduce((e,r)=>joinAttributes(e,r,t),{});return{finalChildren:r.length?r:null,additionalAttributes:omit(n,[jsxType,setterTargetType])}}function isAttributesObject(e){return e instanceof Object&&e[setterTargetType]instanceof Function}function joinAttributes(e,t,r){const n=t[setterTargetType],i="string"==typeof r?String:r;if(n&&i.prototype[JSX.jsxFactory]&&i.prototype!==n.prototype&&!(i.prototype instanceof n)){const e=Object.keys(t)[0],i=r instanceof Function?r.name:r;throw new TypeError(`Attribute "${e}" is targeting ${n.name}, but is set on ${i}`)}return Object.keys(t).forEach(r=>{if(r in e){if(!Array.isArray(e[r])||!Array.isArray(t[r]))throw new Error(`Attribute "${r}" is set multiple times`);e[r]=e[r].concat(t[r])}else e[r]=t[r]}),e}const MSG_FILTER_ERR="This may be a functional component that was not configured correctly. Please consult documentation on declarative UI.";function select(e,t,r,n){if(!e||0===e.length)return[];if("*"===t&&!r)return e.concat();const i=getFilter(t,n);return r?deepSelect([],e,i):e.filter(i)}function createSelectorArray(e,t){if(!e)return["*"];if(e instanceof Function)return[e];const r=e.split(">").map(e=>e.trim()),n=r.indexOf(":host");return-1!==n&&(r[n]=t),r}function getSelectorSpecificity(e){return 100*e.filter(isIdSelector).length+10*e.filter(isClassSelector).length+e.filter(isTypeSelector).length}function isTypeSelector(e){return e instanceof Function||"*"!==e&&!isIdSelector(e)&&!isClassSelector(e)}function isClassSelector(e){return"."===e[0]||":"===e[0]}function isIdSelector(e){return"#"===e[0]}function deepSelect(e,t,r){for(const n of t){r(n)&&e.push(n);const t=n.children?n.children():null;t instanceof WidgetCollection&&t.length&&deepSelect(e,t,r)}return e}function getFilter(e,t){const r={},n=isFilter(e)?e:createMatcher(e,t);return(e,i)=>{if(r[e.cid])return!1;let o=!1;try{o=n(e,i,t)}catch(e){let t=`Selector function ${n.name} caused exception "${e.message}".\n`;throw/^[A-Z]/.test(n.name)&&(t+=MSG_FILTER_ERR),new Error(t)}if(o instanceof NativeObject)throw new Error(`Selector function ${n.name} returned ${toValueString(o)}.\n${MSG_FILTER_ERR}`);return!!o&&(r[e.cid]=!0,!0)}}function createMatcher(e,t){let r=e;if(r instanceof Array){if(1!==r.length)return createChildMatcher(r,t);r=r[0]}if(r instanceof Function&&r[JSX.jsxType])return e=>e[JSX.jsxType]===r;if(r instanceof Function)return e=>e instanceof r;if(r instanceof NativeObject)return e=>e===r;if(-1!==r.indexOf(">"))return createChildMatcher(createSelectorArray(r,t.host),t);if("#"===r.charAt(0)){const e=r.slice(1);return t=>e===t.id}if("."===r.charAt(0)){const e=r.slice(1);return t=>-1!==t.classList.indexOf(e)}return"*"===r?()=>!0:e=>r===e.constructor.name||r===(!!e[JSX.jsxType]&&e[JSX.jsxType].name)}function createChildMatcher(e,t){const r=e.map(e=>createMatcher(e,t)).reverse();return e=>{let t=e;for(let e=0;e<r.length;e++){if(!t||!r[e](t))return!1;t=t.parent()}return!0}}function isFilter(e){return e instanceof Function&&!isWidgetConstructor(e)&&!e[JSX.jsxType]}function isWidgetConstructor(e){let t=e.prototype;for(;t;){if(t===NativeObject.prototype)return!0;t=Object.getPrototypeOf(t)}return!1}class WidgetCollection{constructor(e,{selector:t,deep:r,origin:n}={}){if(t&&!n)throw new Error("WidgetCollection can not be constructed with an selector but no origin");const i=e instanceof WidgetCollection?e.toArray():e;Object.defineProperty(this,"_host",{enumerable:!1,writable:!1,value:getHost(n)});const o=select(i,t||"*",r,n instanceof WidgetCollection?n:this);Object.defineProperty(this,"_array",{enumerable:!1,writable:!1,value:o});for(let e=0;e<o.length;e++)this[e]=o[e]}get length(){return this._array.length}get host(){return this._host}first(e){return e?this.filter(e).first():this._array[0]}last(e){return e?this.filter(e).last():this._array[this._array.length-1]}only(e){if(e)return this.filter(e).only();if(1!==this._array.length)throw new Error("Expected exactly one match, but found "+this.length);return this._array[0]}toArray(){return this._array.concat()}forEach(e){this._array.forEach((t,r)=>e(t,r,this))}map(e){return this._array.map((t,r)=>e(t,r,this))}indexOf(e){return this._array.indexOf(e)}slice(){return new WidgetCollection(this._array.slice.apply(this._array,arguments),{origin:this})}concat(){const e=Array.prototype.map.call(arguments,e=>e instanceof WidgetCollection?e.toArray():e);return new WidgetCollection(this._array.concat.apply(this._array,e),{origin:this})}includes(e){return-1!==this._array.indexOf(e)}filter(e){return new WidgetCollection(this._array,{selector:e,origin:this})}parent(){const e=[];for(const t of this._array){const r=t.parent();r&&-1===e.indexOf(r)&&e.push(r)}if(e.length)return new WidgetCollection(e,{origin:this})}children(e){const t=[];for(const e of this._array)e.children instanceof Function&&t.push.apply(t,e.children());return new WidgetCollection(t,{selector:e,origin:this})}appendTo(e){e.append(this)}set(...e){return this._array.forEach(t=>t.set(...e)),this}on(...e){return this._array.forEach(t=>t.on(...e)),this}off(...e){return this._array.forEach(t=>t.off(...e)),this}once(...e){return this._array.forEach(t=>t.once(...e)),this}trigger(...e){return this._array.forEach(t=>t.trigger(...e)),this}animate(...e){this._array.forEach(t=>t.animate(...e))}dispose(){this._array.forEach(e=>e.dispose())}detach(){this._array.forEach(e=>e.detach())}toString(){return this._array.length<4?"WidgetCollection { "+this._array.join(", ")+" }":"WidgetCollection {\n"+this._array.map(e=>"  "+e).join(",\n")+"\n}"}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this[e++],done:!1}:{done:!0}}}}function createElement(e,t){if(Object.keys(this.withoutChildren(t)).length)throw new Error("JSX: WidgetCollection can not have attributes");return new e(this.getChildren(t)||[])}function getHost(e){return e instanceof WidgetCollection?e.host:e||null}WidgetCollection.prototype[JSX.jsxFactory]=createElement;class Image{static isImageValue(e){return null==e||"initial"===e||Image.isValidImageValue(e)}static isValidImageValue(e){try{return Image.from(e),!0}catch(e){return!1}}static from(e){if(e instanceof Image){if(getNativeObject(e.src)&&getNativeObject(e.src).isDisposed())throw new Error("ImageBitmap is closed");return e}if("string"==typeof e||getNativeObject(e)||getBytes(e))return new Image({src:e});if(e instanceof Object)return hasInconsistentDimensions(e)?(hint(this===Image?"Image.from":this,'image "scale" is ignored when "width" and/or "height" are set to a number'),new Image(Object.assign({},e,{scale:"auto"}))):new Image(e);throw new Error(`${toValueString(e)} is not a valid ImageValue`)}constructor(e){if(arguments.length<1)throw new Error("Not enough arguments");checkConsistentDimensions(e),setSrc(this,e),setDimension(this,"width",hasExplicit(e,"width")?e.width:"auto"),setDimension(this,"height",hasExplicit(e,"height")?e.height:"auto"),setScale(this,e)}equals(e){return e instanceof Image&&(e.src===this.src&&e.scale===this.scale&&e.width===this.width&&e.height===this.height)}}Image.prototype[equals]=Image.prototype.equals;const initDimension=0,initSrc="";function setScale(e,t){let r=hasExplicit(t,"scale")?t.scale:"auto";if(null==t.scale&&!hasExplicit(t,"width")&&!hasExplicit(t,"height")&&"string"==typeof t.src){const e=/@([0-9]\.?[0-9]*)x/.exec(t.src.split("/").pop());e&&e[1]&&(r=parseFloat(e[1]))}setDimension(e,"scale",r)}function hasExplicit(e,t){return t in e&&"auto"!==e[t]&&null!=e[t]}function setSrc(e,t){if(checkSrc(t),getNativeObject(t.src)||getBytes(t.src))Object.defineProperty(e,"src",{enumerable:!0,value:t.src});else{let r;try{r=normalizePathUrl(t.src)}catch(e){throw new Error('Invalid image "src": '+e.message)}Object.defineProperty(e,"src",{enumerable:!0,value:r})}}function checkSrc(e){if(!("src"in e))throw new Error('Image "src" missing');if(getNativeObject(e.src)){if(getNativeObject(e.src).isDisposed())throw new Error("ImageBitmap is closed")}else if("string"==typeof e.src){if(!e.src.length)throw new Error('Image "src" must not be empty')}else{if(!getBytes(e.src))throw new Error(`Image "src" ${toValueString(e.src)} must be a string, ImageBitmap or Blob`);if(!e.src.size)throw new Error('Image "src" must not be empty')}}function checkConsistentDimensions(e){if(hasInconsistentDimensions(e))throw new Error('Image "scale" cannot be used with "width" and "height"')}function hasInconsistentDimensions(e){return hasExplicit(e,"scale")&&(hasExplicit(e,"width")||hasExplicit(e,"height"))}function setDimension(e,t,r){"auto"!==r&&checkNumber(r,[0,1/0],`Image "${t}" is not a dimension`),Object.defineProperty(e,t,{enumerable:!0,value:r})}Object.defineProperty(Image.prototype,"src",{value:""}),Object.defineProperty(Image.prototype,"width",{value:0}),Object.defineProperty(Image.prototype,"height",{value:0}),Object.defineProperty(Image.prototype,"scale",{value:0});class Percent{static isValidPercentValue(e){try{return Percent.from(e),!0}catch(e){return!1}}static from(e){if(e instanceof Percent)return e;if(e instanceof Object)return percentLikeObjectToPercentInstance(e);if("string"==typeof e)return checkPercentString(e),new Percent(percentNumberFromString(e));throw new Error(`${toValueString(e)} is not a valid PercentValue`)}constructor(e){if(arguments.length<1)throw new Error("Not enough arguments");checkNumber(e,[-1/0,1/0],"Invalid Percent"),Object.defineProperty(this,"percent",{enumerable:!0,value:e})}toString(){return`${this.percent}%`}valueOf(){return this.percent}}function percentLikeObjectToPercentInstance(e){return checkProperty$2(e,"percent"),new Percent(e.percent)}function checkPercentString(e){if(!/%$/.test(e)||isNaN(percentNumberFromString(e)))throw new Error("Invalid percent string "+e+': It must be a number followed by "%".');checkNumber(percentNumberFromString(e),[-1/0,1/0],`Invalid percent string ${e}`)}function percentNumberFromString(e){return parseInt(e.replace(/%$/,""))}function checkProperty$2(e,t){if(!(t in e))throw new Error(`Percent-like object missing ${t} value`)}const SIDES=["left","top","right","bottom"];class LinearGradient{static isLinearGradientValue(e){return null==e||"initial"===e||LinearGradient.isValidLinearGradientValue(e)}static isValidLinearGradientValue(e){try{return LinearGradient.from(e),!0}catch(e){return!1}}static from(e){if(e instanceof LinearGradient)return e;if(e instanceof Object)return gradientLikeObjectToGradientInstance(e);if("string"==typeof e)return gradientLikeObjectToGradientInstance(gradientStringToObject(e));throw new Error(`${toValueString(e)} is not a valid LinearGradient`)}constructor(e,t){if(arguments.length<1)throw new Error("Not enough arguments");let r=180;arguments.length>1&&(checkNumber(t,[-1/0,1/0],"Invalid direction angle"),r=t),checkColorStops(e),Object.defineProperty(this,"colorStops",{enumerable:!0,value:Object.freeze(e)}),Object.defineProperty(this,"direction",{enumerable:!0,value:r})}toString(){return`linear-gradient(${this.direction?this.direction+"deg, ":""}${this.colorStops.join(", ")})`}equals(e){return e instanceof LinearGradient&&(e.direction===this.direction&&e.colorStops.length===this.colorStops.length&&e.colorStops.every((e,t)=>equalColorStops(e,this.colorStops[t])))}}function equalColorStops(e,t){return e instanceof Color&&t instanceof Color?e.equals(t):e instanceof Array&&t instanceof Array&&(e[0].equals(t[0])&&e[1].percent===t[1].percent)}function gradientStringToObject(e){let t=e.trim();const r={colorStops:[]};if(0!==t.indexOf("linear-gradient"))throw new Error(`Argument ${toValueString(e)} is not a valid linear gradient definition`);if(0!==(t=t.substring(15).trim()).indexOf("(")&&t.lastIndexOf(")")!==t.length-1)throw new Error(`Argument ${toValueString(e)} is not a valid linear gradient definition`);const n=(t=encodeRGBColors(t=t.substring(1,t.length-1).trim())).split(",");let i=n[0].trim(),o=1;0===i.indexOf("to")?(checkSide(i=i.substring(3).trim()),r.direction=directionToDegrees(i)):i.indexOf("deg")===i.length-3?r.direction=parseInt(i.substring(0,i.length-3),10):o=0;for(let e=o;e<n.length;e++){const t=n[e].trim().split(" ");if(1===t.length&&""!==t[0]){const e=decodeRGBColor(t[0]);r.colorStops.push(e)}else{if(2!==t.length)throw new Error(`Invalid color stop value ${toValueString(t)}`);{const e=decodeRGBColor(t[0]),n=t[1];r.colorStops.push([e,n])}}}return r}function encodeRGBColors(e){let t="",r=!1;for(let n=0;n<e.length;n++){t.endsWith("rgb")&&(r=!0),r&&t.endsWith(")")&&(r=!1);const i=e.charAt(n);r?","===i?t+="&#44":" "!==i&&(t+=i):t+=i}return t}function decodeRGBColor(e){return e.replace(/&#44/g,",")}function gradientLikeObjectToGradientInstance(e){if(checkProperty$3(e,"colorStops"),"direction"in e){let{direction:t}=e;return"string"==typeof t&&(checkSide(t),t=directionToDegrees(t)),new LinearGradient(e.colorStops.map(translateGradientLikeColorStop),t)}return new LinearGradient(e.colorStops.map(translateGradientLikeColorStop))}function translateGradientLikeColorStop(e){return Color.isValidColorValue(e)?Color.from(e):e instanceof Array?(2!==e.length&&throwInvalidGradientLikeColorStop(e),[Color.from(e[0]),Percent.from(e[1])]):void throwInvalidGradientLikeColorStop(e)}function checkProperty$3(e,t){if(!(t in e))throw new Error(`LinearGradient-like object missing ${t} value`)}function directionToDegrees(e){return{left:270,top:0,right:90,bottom:180}[e]}function checkColorStops(e){if(!(e instanceof Array))throw new Error("colorStops must be an array");if(e.length<=0)throw new Error("colorStops must not be empty");e.forEach(checkColorStop)}function checkColorStop(e){e instanceof Array||e instanceof Color||throwInvalidColorStop(e),e instanceof Array&&(2===e.length&&e[0]instanceof Color&&e[1]instanceof Percent||throwInvalidColorStop(e))}function throwInvalidColorStop(e){throw new Error(`${toValueString(e)} is not a valid color stop. It must be either [Color, Percent] or Color.`)}function throwInvalidGradientLikeColorStop(e){throw new Error(`${toValueString(e)} is not a valid color stop. It must be either [ColorValue, Percent] or ColorValue.`)}function checkSide(e){if(e.indexOf(" ")>-1)throw new Error(`Invalid direction "${e}". Corners are not supported.`);if(!SIDES.includes(e))throw new Error(`Invalid direction side "${e}". Must be a side (e.g. "left") or a corner (e.g. "left top").`)}Object.defineProperty(LinearGradient.prototype,"direction",{value:0}),Object.defineProperty(LinearGradient.prototype,"colorStops",{value:[]});const numberRegex=/^[+-]?([0-9]+|[0-9]*\.[0-9]+)$/,transformDefaults={rotation:0,scaleX:1,scaleY:1,translationX:0,translationY:0,translationZ:0};class PropertyTypes{constructor(){const e=this;function convertToNumber(e){if(!1===e||null==e||""===e)return 0;if("string"==typeof e){const t=e.trim().replace("px","");if(numberRegex.test(t))return parseFloat(t)}if("number"!=typeof e)throw new Error(`${toValueString(e)} is not a number`);if(!isFinite(e))throw new Error(`${toValueString(e)} is not a valid number`);return e}this.any={},this.boolean={convert:e=>!!e,decode:e=>void 0!==e&&e},this.string={convert:e=>null==e?"":""+e,decode:e=>void 0===e?"":e},this.number={convert:convertToNumber,decode:e=>void 0===e?0:e},this.natural={convert:e=>Math.max(0,Math.round(convertToNumber(e))),decode:e=>void 0===e?0:e},this.integer={convert:e=>Math.round(convertToNumber(e)),decode:e=>void 0===e?0:e},this.fraction={convert:e=>Math.max(0,Math.min(1,convertToNumber(e)))},this.dimension={convert:e=>Math.max(0,convertToNumber(e)),decode:e=>void 0===e?0:e},this.Shader={convert(e){if(!e||"initial"===e)return"initial";if(function isIntendedLinearGradientValue(e){if(e instanceof LinearGradient)return!0;if(e instanceof Object)return"colorStops"in e;if("string"==typeof e)return/^linear-gradient/.test(e)}(e))return LinearGradient.from(e);if(Color.isValidColorValue(e))return Color.from(e);if(Image.isValidImageValue(e))return Image.from.call(this,e);throw new Error(`${toValueString(e)} must be a valid ImageValue, LinearGradientValue or ColorValue.`)},encode(t){if("initial"===t)return null;if(t instanceof LinearGradient){const{colorStops:e,direction:r}=t;return{type:"linearGradient",colors:e.map(e=>e instanceof Color?[e.toArray(),null]:[e[0].toArray(),e[1].valueOf()/100]),angle:r}}if(t instanceof Color)return{type:"color",color:t.toArray()};if(t instanceof Image)return{type:"image",image:e.ImageValue.encode(t)};throw new Error(`${toValueString(t)} must be a LinearGradient or Color instance.`)}},this.ColorValue={convert:e=>e&&"initial"!==e?Color.from(e):"initial",encode:e=>"initial"===e?void 0:e.toArray(),decode:e=>e?Color.from(e):"initial"},this.FontValue={convert:e=>e&&"initial"!==e?Font.from(e):"initial",encode:e=>"initial"===e?void 0:e},this.ImageValue={convert:e=>e&&"initial"!==e?Image.from(e):null,encode(e){if(!e)return null;const t=Image.from.call(this,e),r="auto"===t.width?null:t.width,n="auto"===t.height?null:t.height,i="auto"===t.scale?null:t.scale,o=t.src;return"string"==typeof o?{type:"uri",src:o,width:r,height:n,scale:i}:getBytes(o)?{type:"encodedImage",src:getBytes(o),width:r,height:n,scale:i}:{type:"imageBitmap",src:getNativeObject(o).cid,width:r,height:n,scale:i}}},this.BoxDimensions={convert(t){try{if(!t)return Object.freeze({left:0,right:0,top:0,bottom:0});if("number"==typeof t){const r=e.dimension.convert(t);return{left:r,right:r,top:r,bottom:r}}if(t instanceof Array||"string"==typeof t){const e=("string"==typeof t?t.trim().split(/\s+/):t).map(convertToNumber);if(0===e.length||e.length>4)throw new Error("Array must have between 1 and 4 entries");return Object.freeze({top:e[0],right:e.length>1?e[1]:e[0],bottom:e.length>2?e[2]:e[0],left:e.length>3?e[3]:e.length>1?e[1]:e[0]})}if("object"==typeof t){const e=allowOnlyKeys(t,["left","top","right","bottom"]);return Object.freeze({left:"left"in e?convertToNumber(e.left):0,top:"top"in e?convertToNumber(e.top):0,right:"right"in e?convertToNumber(e.right):0,bottom:"bottom"in e?convertToNumber(e.bottom):0})}throw new Error("Expected number, string or object")}catch(e){throw new Error(`${toValueString(t)} is not a valid BoxDimensions value: ${e.message}`)}}},this.Bounds={decode:e=>void 0===e?{left:0,top:0,width:0,height:0}:{left:e[0],top:e[1],width:e[2],height:e[3]}},this.Widget={convert(e){if(!e)return null;if(e instanceof WidgetCollection)return e.first()||null;if(e instanceof NativeObject&&Object.getPrototypeOf(e).animate instanceof Function)return e;throw new Error("Not a valid widget: "+toValueString(e))},encode:e=>e instanceof NativeObject?e.cid:null,decode:e=>tabris._nativeObjectRegistry.find(e)},this.Transformation={convert(e){const t=allowOnlyKeys(e,Object.keys(transformDefaults));return Object.freeze({rotation:"rotation"in t?convertToNumber(t.rotation):0,scaleX:"scaleX"in t?convertToNumber(t.scaleX):1,scaleY:"scaleY"in t?convertToNumber(t.scaleY):1,translationX:"translationX"in t?convertToNumber(t.translationX):0,translationY:"translationY"in t?convertToNumber(t.translationY):0,translationZ:"translationZ"in t?convertToNumber(t.translationZ):0})}},this.Date={convert(e){if(!(e instanceof Date))throw new Error(`${toValueString(e)} is not of type Date`);return e},encode:e=>e.getTime()}}}const types=Object.freeze(new PropertyTypes);class NativeObject extends EventsClass{constructor(e){super(),this.cid="",Object.defineProperty(this,"$props",{enumerable:!1,writable:!0,value:{}}),this._nativeCreate(e)}static defineProperties(e,t){for(const r in t)NativeObject.defineProperty(e,r,t[r])}static defineProperty(e,t,r){const n=normalizeProperty(r);Object.defineProperty(e,"$prop_"+t,{enumerable:!1,writable:!1,value:n}),Object.defineProperty(e,t,{set(e){this.$setProperty(t,e)},get(){return this.$getProperty(t)}}),n.const||this.defineChangeEvent(e,t)}static defineEvents(e,t){for(const r in t)NativeObject.defineEvent(e,r,t[r])}static defineEvent(e,t,r){const n="on"+t.charAt(0).toUpperCase()+t.slice(1),i="$"+n,o="$event_"+t;if(e[o])throw new Error("Event already defined");const a=e[o]=normalizeEvent.call(this.prototype,t,r);a.changes&&this.synthesizeChangeEvents(e,t,a),Object.defineProperty(e,n,{get(){return this[i]||(this[i]=new Listeners(this,t)),this[i]}})}static defineChangeEvents(e,t){t.forEach(t=>this.defineChangeEvent(e,t))}static defineChangeEvent(e,t){const r="on"+t.charAt(0).toUpperCase()+t.slice(1)+"Changed",n="$"+t+"Changed";Object.defineProperty(e,r,{get(){return this[n]||(this[n]=new ChangeListeners(this,t)),this[n]}})}static synthesizeChangeEvents(e,t,r){var n;const i=r.changes+"Changed",o=function(e){const t=r.changeValue;this.$trigger(i,{value:t(e)})},a="$event_"+i;null===(n=(e[a]=e[a]||{listen:[]}).listen)||void 0===n||n.push((e,r)=>{e._onoff(t,r,o)}),!1!==r.nativeObservable&&(e[nativeObservables]=(e[nativeObservables]||[]).concat(),e[nativeObservables].push(i))}static extend(e,t=NativeObject){return class extends t{get _nativeType(){return e}}}set(e){if(0===arguments.length)throw new Error("Not enough arguments");if(arguments.length>1)throw new Error("Too many arguments");return this._reorderProperties(Object.keys(e||{})).forEach(t=>setExistingProperty.call(this,t,e[t])),this}dispose(){this._dispose()}isDisposed(){return!!this._isDisposed}toString(){return this.constructor.name}[toXML](){if(this._isDisposed)return`<${this._getXMLElementName()} cid='${this.cid}' disposed='true'/>`;const e=this._getXMLContent();return e.length?`${this._getXMLHeader(!0)}\n${e.join("\n")}\n${this._getXMLFooter(!0)}`:this._getXMLHeader(!1)}_dispose(e){this._isDisposed||this._inDispose||(Object.defineProperties(this,{_inDispose:{enumerable:!1,writable:!1,value:!0},_disposedToStringValue:{enumerable:!1,writable:!1,value:this.toString()}}),this.toString=(()=>this._disposedToStringValue+" (disposed)"),this._trigger("dispose"),this._release(),e||tabris._nativeBridge.destroy(this.cid),tabris._nativeObjectRegistry.remove(this.cid),this.$props=null,Object.defineProperty(this,"_isDisposed",{enumerable:!1,writable:!1,value:!0}))}$getProperty(e){var t,r;if(this._isDisposed)return void hint(this,'Cannot get property "'+e+'" on disposed object');const n=this._getPropertyDefinition(e);if(n.nocache){const r=this._nativeGet(e);return(null===(t=n.type)||void 0===t?void 0:t.decode)?n.type.decode.call(null,r,this):r}const i=this._getStoredProperty(e);if(void 0!==i)return i;if(void 0!==n.default)return n.default;const o=this._nativeGet(e),a=(null===(r=n.type)||void 0===r?void 0:r.decode)?n.type.decode.call(this,o,this):o;return this._storeProperty(e,a),a}$setProperty(e,t){var r,n;if(this._isDisposed)return void hint(this,'Cannot set property "'+e+'" on disposed object');const i=this._getPropertyDefinition(e);if(i.readonly)return void hint(this,`Can not set read-only property "${e}"`);if(i.const&&this._wasSet(e))return void hint(this,`Can not set const property "${e}"`);let o;try{o=this._convertValue(i,t,t)}catch(t){return void this._printPropertyWarning(e,t)}const a=null===(n=null===(r=i.type)||void 0===r?void 0:r.encode)||void 0===n?void 0:n.call(null,o,this);i.nocache?(this._beforePropertyChange(e,o),this._nativeSet(e,a),i.const||this._triggerChangeEvent(e,o)):equals$1(this._getStoredProperty(e),o)&&this._wasSet(e)||(this._beforePropertyChange(e,o),this._nativeSet(e,a),this._storeProperty(e,o,i.const))}_convertValue(e,t,r){var n,i;return e.nullable&&null===t||(r=allowOnlyValues(null===(i=null===(n=e.type)||void 0===n?void 0:n.convert)||void 0===i?void 0:i.call(null,t,this),e.choice)),r}_printPropertyWarning(e,t){hint(this,'Ignored unsupported value for property "'+e+'": '+(null===t||void 0===t?void 0:t.message))}_storeProperty(e,t,r=!1){return(t!==this._getStoredProperty(e)||!this._wasSet(e))&&(void 0!==t&&(this.$props[e]=t,r||this._triggerChangeEvent(e,t),!0))}_getStoredProperty(e){let t=this.$props?this.$props[e]:void 0;return void 0===t&&(t=this._getPropertyDefinition(e).default),t}_wasSet(e){return e in(this.$props||{})}_getPropertyDefinition(e){return this["$prop_"+e]||{}}_decodeProperty(e,t){return e&&e.decode?e.decode.call(null,t,this):t}_triggerChangeEvent(e,t){this.$trigger(e+"Changed",{value:t})}get _nativeType(){throw new Error("Can not create instance of abstract class "+this.constructor.name)}_nativeCreate(e){this._register(),tabris._nativeBridge.create(this.cid,this._nativeType),e instanceof Object&&this.set(e)}_register(){if("undefined"==typeof tabris||!tabris._nativeBridge)throw new Error("tabris.js not started");const e=tabris._nativeObjectRegistry.register(this);Object.defineProperty(this,"cid",{value:e})}_reorderProperties(e){return e}_release(){}_beforePropertyChange(e,t){}_listen(e,t){var r;const n=this["$event_"+e];n&&(null===(r=n.listen)||void 0===r||r.forEach(e=>e(this,t)))}_nativeListen(e,t){this._checkDisposed(),tabris._nativeBridge.listen(this.cid,e,t)}_trigger(e,t={}){return this.$trigger(e,t)}$trigger(e,t={}){const r=this[notify](e,t,!1);return!!(null===r||void 0===r?void 0:r.defaultPrevented)}_onoff(e,t,r){t?this.on(e,r):this.off(e,r)}_checkDisposed(){if(this._isDisposed)throw new Error("Object is disposed")}_nativeSet(e,t){this._checkDisposed(),tabris._nativeBridge.set(this.cid,e,void 0===t?null:t)}_nativeGet(e){return this._checkDisposed(),tabris._nativeBridge.get(this.cid,e)}_nativeCall(e,t){return this._checkDisposed(),tabris._nativeBridge.call(this.cid,e,t)}_getXMLHeader(e){const t=this._getXMLAttributes().map(e=>`${e[0]}='${(""+e[1]).replace(/'/g,"\\'").replace(/\n/g,"\\n")}'`).join(" ");return`<${this._getXMLElementName()} ${t}${e?"":"/"}>`}_getXMLFooter(e){return e?`</${this._getXMLElementName()}>`:""}_getXMLElementName(){return this.constructor.name}_getXMLAttributes(){return[["cid",this.cid]]}_getXMLContent(){return[]}}function setExistingProperty(e,t){e in this||hint(this,'There is no setter for property "'+e+'"'),this[e]=t}function normalizeProperty(e){const t={type:normalizeType(e.type||{}),default:e.default,nullable:!!e.nullable,const:!!e.const,nocache:!!e.nocache,readonly:!!e.readonly,choice:e.choice};if(t.readonly&&void 0!==t.default)throw new Error('Can not combine "nocache" with "readonly"');if(t.readonly&&t.nullable)throw new Error('Can not combine "nullable" with "readonly"');if(t.readonly&&t.choice)throw new Error('Can not combine "choice" with "readonly"');if(t.choice&&t.choice.length<2)throw new Error('"choice" needs at least two entries');if(void 0===t.default&&!t.nocache&&!t.readonly)throw new Error('"default" must be given unless "nocache" or "readonly" is true.');return allowOnlyKeys(e,Object.keys(t)),t}function normalizeEvent(e,t){var r;const n={listen:[]};if(!0===t)return n;Object.assign(n,t),t.native&&(null===(r=n.listen)||void 0===r||r.push((t,r)=>{t._nativeListen(e,r)}));const i=n.changes;if(i){const e=n.changeValue;"string"==typeof e?n.changeValue=(t=>t[e]):e||(n.changeValue=(e=>e[i]))}return n}function normalizeType(e){if(e instanceof Function){if(!(e.prototype instanceof NativeObject))throw new Error("not a constructor of NativeObject");return{convert(t){if(!(t instanceof e))throw new Error("Not an instance of "+e.name);return t},encode:e=>e?e.cid:null,decode:e=>e?tabris._nativeObjectRegistry.find(e):null}}const t="string"==typeof e?types[e]:e;return allowOnlyKeys(t,["convert","encode","decode"]),{convert:t.convert||(e=>e),encode:t.encode||(e=>e),decode:t.decode||(e=>e)}}NativeObject.defineEvents(NativeObject.prototype,{dispose:!0});class NativeBridge{constructor(e){Object.defineProperties(this,{$bridge:{enumerable:!1,writable:!1,value:e},$operations:{enumerable:!1,writable:!0,value:[]},$currentOperation:{enumerable:!1,writable:!0,value:{id:null}},$propertyCache:{enumerable:!1,writable:!0,value:{}}})}create(e,t){const r={};this.$operations.push(["create",e,t,r]),this.$currentOperation={id:e,properties:r}}set(e,t,r){if(this.$currentOperation.id===e&&this.$currentOperation.properties)this.$currentOperation.properties[t]=r;else{const n={};n[t]=r,this.$operations.push(["set",e,n]),this.$currentOperation={id:e,properties:n}}this.cacheValue(e,t,r)}listen(e,t,r){this.$operations.push(["listen",e,t,r]),this.$currentOperation={id:void 0}}destroy(e){this.$operations.push(["destroy",e]),this.$currentOperation={id:void 0}}get(e,t){if(this.$propertyCache[e]&&t in this.$propertyCache[e])return this.$propertyCache[e][t];this.flush();const r=this.$bridge.get(e,t);return this.cacheValue(e,t,r),r}call(e,t,r){return this.flush(),this.$bridge.call(e,t,r)}flush(){tabris.trigger("layout");const e=this.$operations;this.$operations=[],this.$currentOperation={id:void 0};const t=e.length;if(t)if(this.$bridge.flush)this.$bridge.flush(e);else for(let r=0;r<t;r++){const t=e[r];switch(t[0]){case"create":this.$bridge.create(t[1],t[2],t[3]);break;case"set":this.$bridge.set(t[1],t[2]);break;case"listen":this.$bridge.listen(t[1],t[2],t[3]);break;case"destroy":this.$bridge.destroy(t[1])}}}clearCache(){this.$propertyCache={}}cacheValue(e,t,r){this.$propertyCache[e]||(this.$propertyCache[e]={}),this.$propertyCache[e][t]=r}}class NativeObjectRegistry{constructor(){Object.defineProperties(this,{$idSequence:{enumerable:!1,writable:!0,value:1},$objects:{enumerable:!1,writable:!1,value:{}}})}register(e){const t=this.$generateId();if(t in this.$objects)throw new Error("cid already in use: "+t);return this.$objects[t]=e,t}remove(e){delete this.$objects[e]}find(e){return this.$objects[e]||null}$generateId(){return"$"+this.$idSequence++}}const PHASE_CONSTANTS={NONE:{value:0},CAPTURING_PHASE:{value:1},AT_TARGET:{value:2},BUBBLING_PHASE:{value:3}};class Event{constructor(e,t){if(arguments.length<1)throw new Error("Not enough arguments to Event");Object.defineProperties(this,{$timeStamp:{enumerable:!1,writable:!0,value:Date.now()},$type:{enumerable:!1,writable:!0,value:e||""},$bubbles:{enumerable:!1,writable:!0,value:t&&!!t.bubbles||!1},$cancelable:{enumerable:!1,writable:!0,value:t&&!!t.cancelable||!1},$target:{enumerable:!1,writable:!0,value:null},$defaultPrevented:{enumerable:!1,writable:!0,value:!1}})}initEvent(e,t,r){if(arguments.length<3)throw new Error("Not enough arguments to initEvent");this.$type=e+"",this.$bubbles=!!t,this.$cancelable=!!r}get type(){return this.$type}get timeStamp(){return this.$timeStamp}get bubbles(){return this.$bubbles}get cancelable(){return this.$cancelable}get target(){return this.$target}get currentTarget(){return this.$target}get defaultPrevented(){return this.$defaultPrevented}get eventPhase(){return 0}get isTrusted(){return!1}stopPropagation(){}stopImmediatePropagation(){}preventDefault(){this.$cancelable&&(this.$defaultPrevented=!0)}}function addDOMEventTargetMethods(e){if("function"==typeof e.addEventListener)return;let t;e.addEventListener=function(e,r){if(arguments.length<2)throw new Error("Not enough arguments to addEventListener");t||(t=[]),e in t||(t[e]=[]),t[e].includes(r)||t[e].push(r)},e.removeEventListener=function(e,r){if(arguments.length<2)throw new Error("Not enough arguments to removeEventListener");if(t&&e in t){const n=t[e].indexOf(r);-1!==n&&t[e].splice(n,1)}},e.dispatchEvent=function(r){if(arguments.length<1)throw new Error("Not enough arguments to dispatchEvent");if(!(r instanceof Event))throw new Error("Invalid event given to dispatchEvent");if(r.$target=e,t&&r.type in t)for(const e of t[r.type])e.call(this,r);return!r.defaultPrevented}}function defineEventHandlerProperties(e,t){t.forEach(t=>defineEventHandlerProperty(e,t))}function defineEventHandlerProperty(e,t){const r="on"+t;if(r in e)return;let n=null;Object.defineProperty(e,r,{get:()=>n,set(r){"function"==typeof r&&(n&&e.removeEventListener(t,n),n=r,e.addEventListener(t,n))}})}Object.defineProperties(Event,PHASE_CONSTANTS),Object.defineProperties(Event.prototype,PHASE_CONSTANTS);class ImageData{constructor(){if(arguments.length<2)throw new TypeError("Not enough arguments to ImageData");let e,t,r;if(arguments[0]instanceof Uint8ClampedArray){if(e=checkArray(arguments[0]),t=checkSize(arguments[1]),r=arguments.length>2?checkSize(arguments[2]):e.byteLength/4/t,e.byteLength!==t*r*4)throw new Error("Wrong array size")}else t=checkSize(arguments[0]),r=checkSize(arguments[1]),e=new Uint8ClampedArray(t*r*4);Object.defineProperties(this,{data:{value:e},width:{value:t},height:{value:r}})}}function checkArray(e){if(e.byteLength%4!=0)throw new Error("Illegal array length");return e}function checkSize(e){const t=Math.floor(e);if(t<=0||!isFinite(t))throw new Error("Illegal size for ImageData");return t}Object.defineProperty(ImageData.prototype,"data",{value:null}),Object.defineProperty(ImageData.prototype,"width",{value:0}),Object.defineProperty(ImageData.prototype,"height",{value:0});const EVENT_TYPES=["message","error","messageerror"];class _Worker extends NativeObject{get _nativeType(){return"tabris.Worker"}postMessage(e){this._nativeCall("postMessage",e)}terminate(){this._nativeCall("terminate")}}NativeObject.defineProperties(_Worker.prototype,{scriptPath:{type:"string",const:!0,default:""}}),NativeObject.defineEvents(_Worker.prototype,{message:{native:!0},error:{native:!0},messageError:!0});class Worker{constructor(e){if("string"!=typeof e)throw new Error("The Worker script path has to be of type string");addDOMEventTargetMethods(this),defineEventHandlerProperties(this,EVENT_TYPES),Object.defineProperty(this,"_nativeObject",{enumerable:!1,writable:!1,value:this.$createNativeObject(e)})}$createNativeObject(e){return new _Worker({scriptPath:e}).on({_message:({data:e,logs:t,internal:r})=>{try{if(t instanceof Array)for(const e of t)tabris.trigger("log",e)}finally{r||this.dispatchEvent(Object.assign(new Event("message"),{data:e}))}},_error:({message:e})=>{this.dispatchEvent(Object.assign(new Event("error"),{message:e}))},_messageError:({message:e})=>{this.dispatchEvent(Object.assign(new Event("messageerror"),{message:e}))}})}postMessage(e,t){validateMessage(e),this._nativeObject._nativeCall("postMessage",{data:e,transferList:t})}terminate(){this._nativeObject._nativeCall("postMessage",{internal:!0,data:"terminate"}),this._nativeObject._nativeCall("terminate")}}function validateMessage(e){if(!isValidMessage(e))throw new TypeError("The message could not be cloned");if(e instanceof Array)for(const t of e)validateMessage(t);else if("object"==typeof e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&validateMessage(e[t])}function isValidMessage(e){return void 0===e||null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||e&&"object"==typeof e&&(e.constructor===Object||e.constructor===Array||e.constructor===DataView||e.constructor===ArrayBuffer||e.constructor===ImageData)}class Tabris extends NativeObject{constructor(){super(),this._logPushInterval=-1,this._logBuffer=null,this._pushBufferTimer=null,Object.defineProperties(this,{_started:{enumerable:!1,writable:!0,value:!1},_init:{enumerable:!1,writable:!0,value:this._init.bind(this)},postMessage:{enumerable:!1,value:this.postMessage.bind(this)},close:{enumerable:!1,value:this.close.bind(this)},$sendLogBufferInternal:{enumerable:!1,value:this.$sendLogBufferInternal.bind(this)},_notify:{enumerable:!1,writable:!0,value:this._notify.bind(this)},_stackTraceStack:{enumerable:!1,writable:!0,value:[]},_nativeObjectRegistry:{enumerable:!1,writable:!0,value:null},_client:{enumerable:!1,writable:!0,value:null},_nativeBridge:{enumerable:!1,writable:!0,value:null},_entryPoint:{enumerable:!1,writable:!0,value:null}}),this.$publishProxies()}get version(){return"3.10.0"}get started(){return!!this._started}get logPushInterval(){return this._logPushInterval}set logPushInterval(e){this._logPushInterval=e,this.headless&&this.logPushInterval>-1?(this.on("_log",this.$logToBuffer,this),this.$logToBuffer({})):(this._logBuffer=null,this.off("_log",this.$logToBuffer,this))}flush(){this.trigger("tick"),this.trigger("flush"),this._nativeBridge.clearCache(),this._nativeBridge.flush()}postMessage(e,t){if(this.headless){validateMessage(e);const r=this.logPushInterval>=0?this._logBuffer:null,n=!1;this._nativeCall("postMessage",{data:e,transferList:t,logs:r,internal:n}),r&&(this._logBuffer=null)}}close(){this.headless&&(this.$sendLogBufferInternal(),this._nativeCall("close",{}))}get _nativeType(){return"tabris.Tabris"}_nativeCreate(){}_register(){this._nativeObjectRegistry=new NativeObjectRegistry;const e=this._nativeObjectRegistry.register(this);Object.defineProperty(this,"cid",{value:e})}_init(e,t){var r;this._client=e,Object.defineProperty(this,"headless",{writable:!1,value:!!(null===t||void 0===t?void 0:t.headless)}),this._nativeBridge=new NativeBridge(e),this._register(),this._nativeBridge.create(this.cid,this._nativeType),this.headless&&(this.on("_log",this.$logToBuffer,this),this._listen("message",!0)),this.trigger("start",t||{headless:!1}),(null===(r=this.$app)||void 0===r?void 0:r.debugBuild)&&(this.logPushInterval=2e3),this._started=!0,global.postMessage=this.postMessage,global.close=this.close}_setEntryPoint(e){this._entryPoint=e}_notify(e,t,r){let n;try{const i=this._nativeObjectRegistry.find(e);if(i)try{const o=i["$event_"+t];o&&o.changes&&this._nativeBridge.cacheValue(e,o.changes,o.changeValue(r)),n=i._trigger(t,r)}catch(e){error(e)}this.flush()}catch(e){error(e)}return n}_trigger(e,t){return"message"===e?this.$handleMessage(t):"messageError"===e?this.$handleMessageError(t):super._trigger(e,t)}$publishProxies(){["contentView","drawer","navigationBar","statusBar","permission","printer","device","app","localStorage","secureStorage","crypto","fs","input","pkcs5","sizeMeasurement","devTools","process","authentication"].forEach(e=>{const t=proxify(()=>this["$"+e]);Object.defineProperty(this,e,{value:t})})}$logToBuffer({level:e,message:t}){this._logBuffer||(this._logBuffer=[]),e&&this._logBuffer.push({level:e,message:t,logTime:Date.now()}),this.logPushInterval>-1&&null===this._pushBufferTimer&&(this._pushBufferTimer=setTimeout(this.$sendLogBufferInternal,this.logPushInterval))}$handleMessage({internal:e,data:t}){if(e)"terminate"===t&&this.$sendLogBufferInternal();else{this.trigger("message",{data:t});const e=Object.assign(new Event("message"),{data:t});global.dispatchEvent(e)}return!1}$sendLogBufferInternal(){const e=this._logBuffer;this._pushBufferTimer=null,this._logBuffer=null,-1!==this.logPushInterval?e&&this._nativeCall("postMessage",{logs:e,internal:!0}):this.off("_log",this.$logToBuffer,this)}$handleMessageError(e){this.trigger("messageError",e);const t=Object.assign(new Event("messageerror"),{data:e.data});return global.dispatchEvent(t),!1}}NativeObject.defineEvents(Tabris.prototype,{start:{},flush:{},layout:{},log:{},message:{native:!0},messageError:{native:!0}});const SUPPORTED_ENCODINGS=["ascii","utf-8"];class TextEncoder extends NativeObject{encode(e,t){this._nativeListen("result",!0),this._nativeListen("error",!0),this._nativeCall("encode",{text:e,encoding:t})}encodeSync(e,t){return this._nativeCall("encodeSync",{text:e,encoding:t})}get _nativeType(){return"tabris.TextEncoder"}static getInstance(){return this._instance||Object.defineProperty(this,"_instance",{enumerable:!1,writable:!1,value:new TextEncoder}),this._instance}static encode(e,t){return new Promise$1((r,n)=>{paramCheck(e,t=t||"utf-8"),(new TextEncoder).on("result",({target:e,data:t})=>{r(t),e.dispose()}).on("error",({target:e})=>{n(new Error("Could not encode "+t)),e.dispose()}).encode(e,t)})}static encodeSync(e,t){return paramCheck(e,t=t||"utf-8"),TextEncoder.getInstance().encodeSync(e,t)}}function paramCheck(e,t){if("string"!=typeof e)throw new Error("Invalid text, must be a string");if(!SUPPORTED_ENCODINGS.includes(t))throw new Error(`Unsupported encoding: ${toValueString(t)}`)}TextEncoder._instance=null;const SUPPORTED_ENCODINGS$1=["ascii","utf-8"];class TextDecoder extends NativeObject{constructor(){super(),this._nativeListen("result",!0),this._nativeListen("error",!0)}decode(e,t){this._nativeCall("decode",{data:e,encoding:t})}static decode(e,t){return new Promise$1((r,n)=>{if(ArrayBuffer.isView(e)&&(e=e.buffer),!(e instanceof ArrayBuffer))throw new Error("Invalid buffer type");if(t=t||"utf-8",!SUPPORTED_ENCODINGS$1.includes(t))throw new Error(`Unsupported encoding: ${toValueString(t)}`);(new TextDecoder).on("result",({target:e,string:t})=>{r(t),e.dispose()}).on("error",({target:e})=>{n(new Error("Could not decode "+t)),e.dispose()}).decode(e,t)})}get _nativeType(){return"tabris.TextDecoder"}}class Blob{constructor(e=[],t={}){if(Object.getPrototypeOf(e)!==Array.prototype)throw new TypeError("Argument 1 of Blob.constructor can't be converted to a sequence.");if(Object.getPrototypeOf(t)!==Object.prototype)throw new TypeError("Argument 2 of Blob.constructor can't be converted to a dictionary.");setBytes(this,join(e)),Object.defineProperty(this,"type",{value:"type"in t?t.type+"":""})}get size(){return getBytes(this).byteLength}arrayBuffer(){return Promise$1.resolve(getBytes(this).slice(0))}text(){return TextDecoder.decode(getBytes(this))}}function join(e){let t=0;const r=[];for(let n=0;n<e.length;n++)r[n]=partToChunk(e[n]),t+=r[n].byteLength;const n=new Uint8Array(t);let i=0;for(let e=0;e<r.length;e++)n.set(r[e],i),i+=r[e].byteLength;return n.buffer}function partToChunk(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer):e instanceof Blob?new Uint8Array(getBytes(e)):new Uint8Array(TextEncoder.encodeSync(e+""))}Object.defineProperty(Blob.prototype,"type",{value:""}),Blob.prototype[Symbol.toStringTag]="Blob";class Camera extends NativeObject{constructor(e){if(!e||!e.cameraId)throw new Error("Camera requires cameraId");super(e)}get _nativeType(){return"tabris.Camera"}captureImage(e={}){return new Promise$1((t,r)=>{this.active?this._nativeCall("captureImage",{options:e,onResult:e=>{const r=new Blob([],{type:"image/jpg"});return setBytes(r,e.image),t({image:r,width:e.width,height:e.height})},onError:e=>r(new Error(e))}):r(new Error("Camera has to be active to capture an image"))})}}NativeObject.defineProperties(Camera.prototype,{cameraId:{type:types.string,const:!0,default:""},active:{type:types.boolean,default:!1},captureResolution:{type:{convert:e=>Object.freeze(allowOnlyKeys(e,["width","height"]))},default:null,nullable:!0},position:{type:types.string,const:!0,readonly:!0},availableCaptureResolutions:{type:{decode:e=>e.sort((e,t)=>e.width*e.height-t.width*t.height)},const:!0,readonly:!0},priority:{choice:["balanced","performance","quality"],default:"balanced"}});class Device extends NativeObject{get _nativeType(){return"tabris.Device"}_nativeCreate(e){if(!0!==e)throw new Error("Device can not be created");super._nativeCreate()}_listen(e,t){"orientationChanged"===e?this._nativeListen(e,t):super._listen(e,t)}_trigger(e,t){"orientationChanged"===e?this._triggerChangeEvent("orientation",t.orientation):super._trigger(e,t)}dispose(){throw new Error("Cannot dispose device object")}}function create(){return new Device(!0)}function publishDeviceProperties(e,t){t.devicePixelRatio=e.scaleFactor,t.device=createDevice(e),t.screen=createScreen(e),t.navigator=createNavigator(e)}function createDevice(e){const t={};return["model","vendor","platform","version","name"].forEach(r=>{defineReadOnlyProperty(t,r,()=>e[r])}),t}function createScreen(e){const t={};return defineReadOnlyProperty(t,"width",()=>e.screenWidth),defineReadOnlyProperty(t,"height",()=>e.screenHeight),t}function createNavigator(e){const t={};return defineReadOnlyProperty(t,"userAgent",()=>"tabris-js"),defineReadOnlyProperty(t,"language",()=>e.language),t}function defineReadOnlyProperty(e,t,r){Object.defineProperty(e,t,{get:r,set(){}})}NativeObject.defineProperties(Device.prototype,{model:{readonly:!0,const:!0},vendor:{readonly:!0,const:!0},platform:{readonly:!0,const:!0},version:{readonly:!0,const:!0},name:{readonly:!0,const:!0},language:{readonly:!0,const:!0},orientation:{readonly:!0,nocache:!0},screenWidth:{readonly:!0,const:!0},screenHeight:{readonly:!0,const:!0},scaleFactor:{readonly:!0,const:!0},cameras:{type:{decode:e=>Object.freeze(e.map(e=>new Camera({cameraId:e})))},readonly:!0,const:!0}});const OPCODES={arc:1,arcTo:2,beginPath:3,bezierCurveTo:4,clearRect:5,closePath:6,fill:7,fillRect:8,fillStyle:9,fillText:10,lineCap:11,lineJoin:12,lineTo:13,lineWidth:14,moveTo:15,quadraticCurveTo:16,rect:17,restore:18,rotate:19,save:20,scale:21,setTransform:22,stroke:23,strokeRect:24,strokeStyle:25,strokeText:26,textAlign:27,textBaseline:28,transform:29,translate:30,font:31,drawImage:32};class GC extends NativeObject{constructor(e){super(e),Object.defineProperties(this,{_operations:{enumerable:!1,writable:!0,value:[]},_doubles:{enumerable:!1,writable:!0,value:[]},_booleans:{enumerable:!1,writable:!0,value:[]},_strings:{enumerable:!1,writable:!0,value:[]},_ints:{enumerable:!1,writable:!0,value:[]}});const t=()=>this.flush();tabris.on("_flush",t),this.on("_dispose",()=>tabris.off("_flush",t))}init(e){this._nativeCall("init",e)}getImageData(e,t,r,n){const i=this._nativeCall("getImageData",{x:e,y:t,width:r,height:n});return i instanceof Uint8ClampedArray?i:new Uint8ClampedArray(i)}putImageData(e,t,r){this._nativeCall("putImageData",{data:e.data,width:e.width,height:e.height,x:t,y:r})}addOperation(e){const t=OPCODES[e];if(!t)throw new Error("Invalid operation");this._operations.push(t)}addBoolean(){Array.prototype.push.apply(this._booleans,arguments)}addDouble(){Array.prototype.push.apply(this._doubles,arguments)}addInt(){Array.prototype.push.apply(this._ints,arguments)}addString(){Array.prototype.push.apply(this._strings,arguments)}flush(){this._operations.length>0&&(this._nativeCall("draw",{packedOperations:[this._operations,this._doubles,this._booleans,this._strings,this._ints]}),this._operations=[],this._doubles=[],this._booleans=[],this._strings=[],this._ints=[])}get _nativeType(){return"tabris.GC"}}NativeObject.defineProperties(GC.prototype,{parent:{type:types.Widget,default:null}});const ANIMATABLE_PROPERTIES=["opacity","transform"],PROPERTIES={properties:{default:Object.freeze({})},delay:{type:types.natural,default:0},duration:{type:types.natural,default:null},repeat:{type:{convert(e){if("number"!=typeof e)throw new Error(`${toValueString(e)} is not a number`);if(!isFinite(e)&&!isNaN(e)&&e!==1/0)throw new Error(`${toValueString(e)} is not a valid number`);return e},encode:e=>e===1/0?-1:e},default:1},reverse:{type:types.boolean,default:!1},easing:{type:types.string,choice:["linear","ease-in","ease-out","ease-in-out"],default:"liniear"},target:{type:types.Widget,default:null}};class Animation extends NativeObject{constructor(e){super(e),this._nativeListen("completed",!0),this._nativeListen("rejected",!0)}get _nativeType(){return"tabris.Animation"}_trigger(e,t){"completed"===e?(this.target.off("_dispose",this.abort,this),this._resolve&&this._resolve(),this.dispose()):"rejected"===e?(this.target.off("_dispose",this.abort,this),this.abort()):super._trigger(e,t)}start(e,t){this.target.isDisposed()?this.abort():(this.target.on("_dispose",this.abort,this),Object.defineProperties(this,{_resolve:{enumerable:!1,writable:!1,value:e},_reject:{enumerable:!1,writable:!1,value:t}}),this._nativeCall("start"))}abort(){this._reject&&this._reject(),this.dispose()}}function animate(e,t){const r={};for(const t in e)if(-1!==ANIMATABLE_PROPERTIES.indexOf(t))try{const n=this._getPropertyDefinition(t);r[t]=this._convertValue(n,e[t]),this._storeProperty(t,r[t])}catch(e){hint(this,'Ignored invalid animation property value for "'+t+'"')}else hint(this,'Ignored invalid animation property "'+t+'"');for(const e in t)e in PROPERTIES||"name"===e||hint(this,'Ignored invalid animation option "'+e+'"');return new Promise$1((e,n)=>{new Animation(Object.assign({},t,{target:this,properties:r})).start(e,n)})}NativeObject.defineProperties(Animation.prototype,PROPERTIES);class GestureRecognizer extends NativeObject{get _nativeType(){return"tabris.GestureRecognizer"}_listen(e,t){"gesture"===e?this._nativeListen(e,t):super._listen(e,t)}}NativeObject.defineProperties(GestureRecognizer.prototype,{type:{type:types.string,default:null},target:{type:types.Widget,default:null},fingers:{type:types.natural,default:null},touches:{type:types.natural,default:null},duration:{type:types.natural,default:null},direction:{type:types.string,default:null}});const selectorRegex=/^(\*|([#.A-Z][A-Za-z0-9_-]+))$/,numberRegex$1=/^[+-]?([0-9]+|[0-9]*\.[0-9]+)$/,zeroPercent=new Percent(0);class Constraint{static from(e){if(!0===e)return zero;if("string"==typeof e){const t=e.trim();return-1!==t.indexOf(" ")?fromArray(t.split(/\s+/)):numberRegex$1.test(t)?new Constraint(zeroPercent,parseFloat(t)):new Constraint(normalizeReference(t),0)}if(Array.isArray(e))return fromArray(e);if("number"==typeof e)return 0===e?zero:new Constraint(zeroPercent,normalizeNumber(e));if(e instanceof Widget||"symbol"==typeof e||Percent.isValidPercentValue(e))return new Constraint(normalizeReference(e),0);if("reference"in e||"offset"in e)return fromArray([e.reference||zeroPercent,e.offset||0]);throw new Error(`Invalid constraint ${toValueString(e)}`)}constructor(e,t){if("string"==typeof e&&!selectorRegex.test(e))throw new Error(`Invalid sibling selector ${toValueString(e)}`);e instanceof Percent||checkIsValidSiblingReference(e),checkNumber(t),Object.defineProperty(this,"reference",{enumerable:!0,value:e}),Object.defineProperty(this,"offset",{enumerable:!0,value:t})}toString(){return`${referenceToString(this.reference)} ${this.offset}`}toArray(){return[this.reference,this.offset]}equals(e){return e instanceof Constraint&&(e.offset===this.offset&&(e.reference instanceof Percent&&this.reference instanceof Percent?e.reference.percent===this.reference.percent:e.reference===this.reference))}}function checkIsValidSiblingReference(e){if("string"==typeof e&&!selectorRegex.test(e))throw new Error(`Invalid sibling selector ${toValueString(e)}`);if("string"!=typeof e&&!(e instanceof Widget)&&e!==Constraint.next&&e!==Constraint.prev)throw new Error(`Invalid constraint reference ${toValueString(e)}`)}function referenceToString(e){return e instanceof Percent?e+"%":e instanceof Widget?`${e.constructor.name}[cid="${e.cid}"]`:e===Constraint.next?"next()":e===Constraint.prev?"prev()":e}function normalizeReference(e,t){if(!0===e&&void 0!==t)return t;if(Percent.isValidPercentValue(e))return Percent.from(e);if(e instanceof Widget||e===Constraint.next||e===Constraint.prev)return e;if("string"==typeof e){const t=e.trim();if("prev()"===t)return Constraint.prev;if("next()"===t)return Constraint.next;if(selectorRegex.test(t))return t}throw new Error(`${toValueString(e)} is not a percentage or widget reference`)}function normalizeNumber(e,t){return!0===e&&void 0!==t?t:"string"==typeof e&&numberRegex$1.test(e)?parseFloat(e):e}Constraint.next=Symbol("next()"),Constraint.prev=Symbol("prev()");const zero=new Constraint(new Percent(0),0);function fromArray(e){if(2!==e.length)throw new Error(`Constraint array requires exactly 2 elements but has ${e.length}`);return new Constraint(normalizeReference(e[0]),normalizeNumber(e[1]))}class LayoutData{static get next(){return Constraint.next}static get prev(){return Constraint.prev}static get stretch(){return this._stretch||Object.defineProperty(this,"_stretch",{enumerable:!1,writable:!1,value:new LayoutData({left:zero,top:zero,right:zero,bottom:zero})}),this._stretch}static get stretchX(){return this._stretchX||Object.defineProperty(this,"_stretchX",{enumerable:!1,writable:!1,value:new LayoutData({left:zero,right:zero})}),this._stretchX}static get stretchY(){return this._stretchY||Object.defineProperty(this,"_stretchY",{enumerable:!1,writable:!1,value:new LayoutData({top:zero,bottom:zero})}),this._stretchY}static get center(){return this._center||Object.defineProperty(this,"_center",{enumerable:!1,writable:!1,value:new LayoutData({centerX:0,centerY:0})}),this._center}static from(e){if("stretch"===e)return LayoutData.stretch;if("stretchX"===e)return LayoutData.stretchX;if("stretchY"===e)return LayoutData.stretchY;if("center"===e)return LayoutData.center;if(!(e instanceof Object))throw new Error(`${toValueString(e)} is not an object`);if(e instanceof LayoutData)return e;if(e.constructor!==Object)throw new Error(`${toValueString(e)} is not a parameter object`);return new LayoutData({left:has(e,"left")?Constraint.from(e.left):"auto",right:has(e,"right")?Constraint.from(e.right):"auto",top:has(e,"top")?Constraint.from(e.top):"auto",bottom:has(e,"bottom")?Constraint.from(e.bottom):"auto",centerX:has(e,"centerX")?normalizeNumber(e.centerX,0):"auto",centerY:has(e,"centerY")?normalizeNumber(e.centerY,0):"auto",baseline:has(e,"baseline")?normalizeReference(e.baseline,LayoutData.prev):"auto",width:has(e,"width")?normalizeNumber(e.width):"auto",height:has(e,"height")?normalizeNumber(e.height):"auto"})}constructor(e){if(!(e instanceof Object)||e.constructor!==Object)throw new Error(`${toValueString(e)} is not a parameter object`);setConstraintValue(this,e,"left"),setConstraintValue(this,e,"top"),setConstraintValue(this,e,"right"),setConstraintValue(this,e,"bottom"),setDimension$1(this,e,"width"),setDimension$1(this,e,"height"),setOffset(this,e,"centerX"),setOffset(this,e,"centerY"),setSiblingReference(this,e,"baseline")}toString(){return JSON.stringify({left:this.left.toString(),right:this.right.toString(),top:this.top.toString(),bottom:this.bottom.toString(),width:this.width,height:this.height,centerX:this.centerX,centerY:this.centerY,baseline:referenceToString(this.baseline)})}equals(e){return e instanceof LayoutData&&(equals$2(e.left,this.left)&&equals$2(e.right,this.right)&&equals$2(e.top,this.top)&&equals$2(e.bottom,this.bottom)&&equals$2(e.centerX,this.centerX)&&equals$2(e.centerY,this.centerY)&&equals$2(e.baseline,this.baseline)&&equals$2(e.width,this.width)&&equals$2(e.height,this.height))}}function mergeLayoutData(e,t){const r=LayoutData.from(e),n=LayoutData.from(t);return LayoutData.from({left:has(n,"left")?n.left:r.left,right:has(n,"right")?n.right:r.right,top:has(n,"top")?n.top:r.top,bottom:has(n,"bottom")?n.bottom:r.bottom,centerX:has(n,"centerX")?n.centerX:r.centerX,centerY:has(n,"centerY")?n.centerY:r.centerY,baseline:has(n,"baseline")?n.baseline:r.baseline,width:has(n,"width")?n.width:r.width,height:has(n,"height")?n.height:r.height})}function has(e,t){return null!=e[t]&&"auto"!==e[t]}function setConstraintValue(e,t,r){const n=r in t?t[r]:"auto";if("auto"===n||n instanceof Constraint)return Object.defineProperty(e,r,{enumerable:!0,value:n});throw new Error(`Invalid ${r} constraint ${toValueString(n)}`)}function setDimension$1(e,t,r){const n=r in t?t[r]:"auto";"auto"!==n&&checkNumber(n,[0,1/0]),Object.defineProperty(e,r,{enumerable:!0,value:n})}function setOffset(e,t,r){const n=r in t?t[r]:"auto";"auto"!==n&&checkNumber(n,[-1/0,1/0],`Invalid ${r}`),Object.defineProperty(e,r,{enumerable:!0,value:n})}function setSiblingReference(e,t,r){const n=r in t?t[r]:"auto";return"auto"!==n&&checkIsValidSiblingReference(n),Object.defineProperty(e,r,{enumerable:!0,value:n})}function equals$2(e,t){return e===t||e instanceof Constraint&&t instanceof Constraint&&e.equals(t)}const layoutDataProps=["left","right","top","bottom","width","height","centerX","centerY","baseline"],jsxShorthands={center:"layoutData",stretch:"layoutData",stretchX:"layoutData",stretchY:"layoutData"},defaultGestures={tap:{type:"tap"},longPress:{type:"longPress"},pan:{type:"pan"},panLeft:{type:"pan",direction:"left"},panRight:{type:"pan",direction:"right"},panUp:{type:"pan",direction:"up"},panDown:{type:"pan",direction:"down"},panHorizontal:{type:"pan",direction:"horizontal"},panVertical:{type:"pan",direction:"vertical"},swipeLeft:{type:"swipe",direction:"left"},swipeRight:{type:"swipe",direction:"right"},swipeUp:{type:"swipe",direction:"up"},swipeDown:{type:"swipe",direction:"down"}};class Widget extends NativeObject{appendTo(e){if(this._checkDisposed(),!((e=e instanceof WidgetCollection?e.first():e)instanceof NativeObject))throw new Error(`Cannot append to non-widget ${toValueString(e)}`);return this._setParent(e),this}insertBefore(e){if(this._checkDisposed(),!((e=e instanceof WidgetCollection?e.first():e)instanceof NativeObject))throw new Error(`Cannot insert before non-widget ${toValueString(e)}`);const t=e.parent();if(!t)throw new Error(`Cannot insert before orphan ${toValueString(e)}`);const r=t.$children.indexOf(e);return this._setParent(t,r),this}insertAfter(e){if(this._checkDisposed(),!((e=e instanceof WidgetCollection?e.first():e)instanceof NativeObject))throw new Error(`Cannot insert after non-widget ${toValueString(e)}`);const t=e.parent();if(!t)throw new Error(`Cannot insert after orphan ${toValueString(e)}`);this.detach();const r=t.$children.indexOf(e);return this._setParent(t,r+1),this}detach(){return this._checkDisposed(),this._setParent(null),this}parent(e){if(!e||!this._parent)return this._parent||null;let t=this._parent;const r=getFilter(e);for(;t&&!r(t);)t=t.parent();return t}siblings(e){return this._parent?this._parent._children(e=>e!==this).filter(e):new WidgetCollection([])}set class(e){this._isDisposed?hint(this,'Cannot set property "class" on disposed object'):(Object.defineProperty(this,"_classList",{enumerable:!0,writable:!0,value:types.string.convert(e).trim().split(/\s+/)}),this._triggerChangeEvent("class",this.class))}get class(){if(!this._isDisposed)return this.classList.join(" ")}set layoutData(e){if(this._isDisposed)return void hint(this,'Cannot set property "layoutData" on disposed object');const t=this._layoutData;t&&t.equals(e)||(Object.defineProperty(this,"_layoutData",{enumerable:!1,writable:!0,value:e?LayoutData.from(e):new LayoutData({})}),this._triggerChangeEvent("layoutData",this._layoutData),layoutDataProps.forEach(e=>{(t?t[e]:"auto")!==this._layoutData[e]&&this._triggerChangeEvent(e,this._layoutData[e])}))}get layoutData(){if(!this._isDisposed)return this._layoutData||Object.defineProperty(this,"_layoutData",{enumerable:!1,writable:!0,value:new LayoutData({})}),this._layoutData}get classList(){if(!this._isDisposed)return this._classList||Object.defineProperty(this,"_classList",{enumerable:!0,writable:!0,value:[]}),this._classList}set data(e){if(this._isDisposed||this.$data===e)return;checkType(e,Object,{name:"data",nullable:!0});let t=e;(null===e||void 0===e?void 0:e.constructor)===Object&&(t=ObservableData(t)),Object.defineProperty(this,"$data",{enumerable:!1,writable:!0,value:t}),ObservableData.generateChangeEvents({target:this,property:"data"})}get data(){if(!this._isDisposed){if(!("$data"in this)){const e=ObservableData();Object.defineProperty(this,"$data",{enumerable:!1,writable:!0,value:e}),ObservableData.generateChangeEvents({target:this,property:"data",init:!0})}return this.$data}}get absoluteBounds(){if(!this._isDisposed)return types.Bounds.decode(this._nativeGet("absoluteBounds"))}set id(e){const t=types.string.convert(e);t!==this._id&&Object.defineProperty(this,"_id",{enumerable:!1,writable:!0,value:t})}get id(){if(!this._isDisposed)return this._id||""}set gestures(e){const t=Object.assign({},defaultGestures,e);Object.defineProperty(this,"_gestures",{enumerable:!1,writable:!0,value:t})}get gestures(){if(!this._gestures){const e=Object.assign({},defaultGestures);Object.defineProperty(this,"_gestures",{enumerable:!1,writable:!0,value:e})}return this._gestures}set excludeFromLayout(e){this._excludeFromLayout!==!!e&&Object.defineProperty(this,"_excludeFromLayout",{enumerable:!1,writable:!0,value:!!e}),this._parent&&this._parent._scheduleRenderChildren(),this._triggerChangeEvent("excludeFromLayout",this._excludeFromLayout)}get excludeFromLayout(){return!!this._excludeFromLayout}toString(){return this.constructor.name+`[cid="${this.cid}"]`+(this.id?"#"+this.id:"")+(this.classList.length?"."+this.classList.join("."):"")}get[Symbol.toStringTag](){return this.constructor.name}_getXMLAttributes(){const e=super._getXMLAttributes();this.id&&e.push(["id",this.id]),this.class&&e.push(["class",this.class]);const t=this.bounds;return e.push(["bounds",`{left: ${Math.round(t.left)}, top: ${Math.round(t.top)}, `+`width: ${Math.round(t.width)}, height: ${Math.round(t.height)}}`]),this.enabled||e.push(["enabled","false"]),this.visible||e.push(["visible","false"]),e}_setParent(e,t){this._parent&&this._parent._removeChild(this),Object.defineProperty(this,"_parent",{enumerable:!1,writable:!0,value:e}),this._parent&&this._parent._addChild(this,t)}_listen(e,t){if(!this._isDisposed)if(this.gestures[e]){const r=e;if(t){const t=Object.assign({target:this},this.gestures[r]),n=new GestureRecognizer(t).on("_gesture",t=>{t.translation&&(t.translationX=t.translation.x,t.translationY=t.translation.y),t.velocity&&(t.velocityX=t.velocity.x,t.velocityY=t.velocity.y),super._trigger(e,t)});this._recognizers||Object.defineProperty(this,"_recognizers",{enumerable:!1,writable:!1,value:{}}),this._recognizers[r]=n,this.on("dispose",n.dispose,n)}else this._recognizers&&e in this._recognizers&&(this._recognizers[r].dispose(),delete this._recognizers[r])}else super._listen(e,t)}_trigger(e,t){return"resize"===e?super._trigger(e,types.Bounds.decode(t.bounds)):super._trigger(e,t)}_release(){this._parent&&(this._parent._removeChild(this),this._parent=null)}_reorderProperties(e){const t=e.indexOf("layoutData");if(-1!==t){return e.splice(t,1).concat(e)}return e}}function createElement$1(e,t){const r=this.withShorthands(t,jsxShorthands,mergeLayoutData);return this.createNativeObject(e,r)}NativeObject.defineProperties(Widget.prototype,{enabled:{type:types.boolean,default:!0},visible:{type:types.boolean,default:!0},elevation:{type:types.natural,default:0},bounds:{type:types.Bounds,readonly:!0,nocache:!0},background:{type:types.Shader,default:"initial"},opacity:{type:types.fraction,default:1},transform:{type:types.Transformation,default:Object.freeze({rotation:0,scaleX:1,scaleY:1,translationX:0,translationY:0,translationZ:0})},highlightOnTouch:{type:types.boolean,default:!1},cornerRadius:{type:types.number,default:0},padding:{type:types.BoxDimensions,default:Object.freeze({left:0,right:0,top:0,bottom:0})}}),layoutDataProps.forEach(e=>{Object.defineProperty(Widget.prototype,e,{set(t){this.layoutData=LayoutData.from(Object.assign({},this.layoutData,{[e]:t}))},get(){return this.layoutData[e]}}),NativeObject.defineEvent(Widget.prototype,e+"Changed",!0)}),NativeObject.defineChangeEvents(Widget.prototype,["layoutData","class","data"]),NativeObject.defineEvents(Widget.prototype,{tap:!0,longPress:!0,pan:!0,panLeft:!0,panRight:!0,panUp:!0,panDown:!0,panHorizontal:!0,panVertical:!0,swipeLeft:!0,swipeRight:!0,swipeUp:!0,swipeDown:!0,touchStart:{native:!0},touchMove:{native:!0},touchEnd:{native:!0},touchCancel:{native:!0},resize:{native:!0,nativeObservable:!1,changes:"bounds",changeValue:({left:e,top:t,width:r,height:n,bounds:i})=>i||{left:e,top:t,width:r,height:n}},addChild:!0,removeChild:!0}),Widget.prototype.animate=animate,Widget.prototype[jsxFactory]=createElement$1;const layoutDataProps$1=["left","right","top","bottom","width","height","centerX","centerY","baseline"];class Layout{constructor(e={},t){if(this.constructor===Layout)throw new Error('Can not create instance of abstract class "Layout"');if(Object.defineProperty(this,"_layoutQueue",{enumerable:!1,writable:!1,value:t||LayoutQueue.instance}),!(this._layoutQueue instanceof LayoutQueue))throw new Error("Not a LayoutQueue: "+this._layoutQueue);Object.defineProperties(this,{_handleAddChildEvent:{enumerable:!1,writable:!1,value:this._handleAddChildEvent.bind(this)},_handleRemoveChildEvent:{enumerable:!1,writable:!1,value:this._handleRemoveChildEvent.bind(this)},_handleChildPropertyChangedEvent:{enumerable:!1,writable:!1,value:this._handleChildPropertyChangedEvent.bind(this)},_getLayoutData:{enumerable:!1,writable:!1,value:this._getLayoutData.bind(this)},_renderLayoutData:{enumerable:!1,writable:!1,value:this._renderLayoutData.bind(this)},_addChild:{enumerable:!1,writable:!1,value:this._addChild.bind(this)},_removeChild:{enumerable:!1,writable:!1,value:this._removeChild.bind(this)}})}add(e){if(!e||e.layout!==this)throw new Error(`Invalid layout target ${toValueString(e)}. Do not call layout.add directly.`);e.on({_addChild:this._handleAddChildEvent,_removeChild:this._handleRemoveChildEvent}),e.$children&&e.$children.forEach(this._addChild),this._layoutQueue.add(e)}remove(e){e.off({_addChild:this._handleAddChildEvent,_removeChild:this._handleRemoveChildEvent}),e.$children&&e.$children.forEach(this._removeChild)}render(e){const t=getChildrenInLayout(e);if(!t.length)return;const r=t.map(this._getLayoutData);this._renderLayoutData(t,r)}_handleAddChildEvent({child:e}){this._addChild(e),this._layoutQueue.add(e._parent)}_handleRemoveChildEvent({child:e}){this._removeChild(e),this._layoutQueue.add(e._parent)}_addChild(e){e.on({_layoutDataChanged:this._handleChildPropertyChangedEvent,_excludeFromLayoutChanged:this._handleChildPropertyChangedEvent})}_removeChild(e){e.off({layoutDataChanged:this._handleChildPropertyChangedEvent,excludeFromLayoutChanged:this._handleChildPropertyChangedEvent})}_handleChildPropertyChangedEvent({target:e}){this._layoutQueue.add(e._parent)}_renderLayoutData(e,t){for(let r=0;r<e.length;r++){const n=this._resolveAttributes(t[r],e[r]);e[r]._nativeSet("layoutData",n)}}_getLayoutData(e,t){let r=e.layoutData;"auto"!==r.centerX&&("auto"===r.left&&"auto"===r.right||(warn("Inconsistent layoutData: centerX overrides left and right.\nTarget: "+getPath(e)),r=makeAuto(r,"left","right"))),"auto"!==r.baseline?"auto"===r.top&&"auto"===r.bottom&&"auto"===r.centerY||(warn("Inconsistent layoutData: baseline overrides top, bottom, and centerY.\nTarget: "+getPath(e)),r=makeAuto(r,"top","bottom","centerY")):"auto"!==r.centerY&&("auto"===r.top&&"auto"===r.bottom||(warn("Inconsistent layoutData: centerY overrides top and bottom.\nTarget: "+getPath(e)),r=makeAuto(r,"top","bottom"))),"auto"!==r.left&&"auto"!==r.right&&"auto"!==r.width&&(warn("Inconsistent layoutData: left and right are set, ignore width.\nTarget: "+getPath(e)),r=makeAuto(r,"width")),"auto"!==r.top&&"auto"!==r.bottom&&"auto"!==r.height&&(warn("Inconsistent layoutData: top and bottom are set, ignore height.\nTarget: "+getPath(e)),r=makeAuto(r,"height"));const n=["left","top","right","bottom"].find(e=>r[e].offset&&r[e].offset<0);if(n){warn("Negative edge offsets are not supported. Setting "+n+" to 0.\nTarget: "+getPath(e));const t=Object.assign({},r[n],{offset:0});r=LayoutData.from(Object.assign({},r,{[n]:t}))}return r}_resolveAttributes(e,t){const r={};for(let n=0;n<layoutDataProps$1.length;n++){const i=layoutDataProps$1[n];i in e&&"auto"!==e[i]&&(r[i]=resolveAttribute(e[i],t))}return r}}class ConstraintLayout extends Layout{static get default(){return this._default||Object.defineProperty(this,"_default",{enumerable:!1,writable:!0,configurable:!0,value:new ConstraintLayout}),this._default}}class LayoutQueue{static get instance(){return this._instance||(Object.defineProperty(this,"_instance",{enumerable:!1,writable:!0,configurable:!0,value:new LayoutQueue}),tabris.on("_layout",()=>this._instance.flush())),this._instance}constructor(){Object.defineProperties(this,{_map:{enumerable:!1,writable:!0,value:{}},_inFlush:{enumerable:!1,writable:!0,value:!1}})}add(e){this._inFlush?hint(this,"WARNING: Widget layout manipulation during layout flush may cause inconsistent state"):this._map[e.cid]=e}flush(){if(!this._inFlush){this._inFlush=!0;for(const e in this._map)!this._map[e]._isDisposed&&this._map[e].layout&&this._map[e].layout.render(this._map[e]);this._map={},this._inFlush=!1}}}function isValidConstraint(e){return"auto"===e||e.reference instanceof Percent&&0===e.reference.percent}function layoutWarn(e,t,r){warn(`Unsupported value for "${t}": ${r}\nTarget: ${getPath(e)}`)}function getPath(e){const t=[e];let r=e.parent();for(;r;)t.unshift(r),r=r.parent();return t.join(" > ")}function maxPositive(e,t){return e<0||t<0?0:Math.max(0,Math.max(e,t))}function resolveAttribute(e,t){return e instanceof Constraint?resolveConstraint(e,t):isNumber(e)?e:toCid(e,t)}function resolveConstraint(e,t){return e.reference instanceof Percent?0===e.reference.percent?e.offset:[e.reference.percent,e.offset]:[toCid(e.reference,t),e.offset]}function toCid(e,t){if(e===LayoutData.prev){const e=getChildrenInLayout(getParent(t)),r=e.indexOf(t);return r>0&&types.Widget.encode(e[r-1])||0}if(e===LayoutData.next){const e=getChildrenInLayout(getParent(t)),r=e.indexOf(t);return r+1<e.length&&types.Widget.encode(e[r+1])||0}if("string"==typeof e){const r=t.siblings(e)[0];return types.Widget.encode(r)||0}return t.siblings().toArray().includes(e)&&types.Widget.encode(e)||0}function isNumber(e){return"number"==typeof e&&isFinite(e)}function getParent(e){return e.parent()||emptyParent}function makeAuto(e,...t){const r={};for(let e=0;e<t.length;e++)r[t[e]]="auto";return LayoutData.from(Object.assign({},e,r))}function getChildrenInLayout(e){return e.$children?e.$children.filter(notExcluded):[]}function notExcluded(e){return!e.excludeFromLayout}const emptyParent={children:()=>[]};function apply(e){const t=e.host;if(1===e.args.length&&("string"==typeof e.args[0]||"symbol"==typeof e.args[0]))return triggerUpdate(e.args[0],t),t;const r=parseApplyArgs(e.args),n=e.protected?t._children():t.children(),i=new WidgetCollection(asArray(n).concat(t),{selector:"*",origin:t,deep:!0});return"*"!==r.trigger&&applyRules(r,t,i),setupTrigger(r,t,i),t}function applyRules(e,t,r,n){const i=e.rules instanceof Function?checkType(e.rules(t),Object,"returned rules"):e.rules;i&&asArray(i).forEach(i=>{if(i[setterTargetType])return applyRule(e.mode,r,[[i[setterTargetType]],i],t,!!n);Object.keys(i).map(e=>[createSelectorArray(e,t),i[e]]).sort((e,t)=>getSelectorSpecificity(e[0])-getSelectorSpecificity(t[0])).forEach(i=>{applyRule(e.mode,r,i,t,!!n)})})}function setupTrigger(e,t,r){var n;const i=e.trigger;if("rules"===i)return;const o=getApplyAttributeObject(t),a=e.rules?()=>applyRules(e,t,r):null;"string"==typeof i&&isListenerAttribute(i)?registerListenerAttributes(t,{[i]:a},o):"*"===i?(null===(n=o[i])||void 0===n||n.unsubscribe(),a&&(o[i]=Observable.mutations(t).subscribe(a))):o[i]=a}function triggerUpdate(e,t){const r=getApplyAttributeObject(t);if(!r[e])throw new Error(`No ruleset is associated with trigger "${String(e)}"`);r[e]()}function parseApplyArgs(e){if(0===e.length||e.length>2)throw new Error(`Expected 1-2 arguments, got ${e.length}`);const t=2===e.length,{mode:r,trigger:n}=normalizeApplyOptions(t?e[0]:{}),i=t?e[1]:e[0];if("symbol"!=typeof n&&checkType(n,String,"trigger"),checkType(i,Object,{nullable:"rules"!==n}),"default"!==r&&"strict"!==r)throw new Error(`Value "${r}" is not a valid mode.`);return{rules:i,mode:r,trigger:n}}function normalizeApplyOptions(e){return{mode:"string"==typeof e?e:e.mode||"default",trigger:(e instanceof Object?e:{}).trigger||"rules"}}function applyRule(e,t,r,n,i){const[o,a]=r;checkType(a,Object,{name:"rule attributes"});const s=a[setterTargetType],l=t.filter(o);"strict"===e&&checkApplyMatches(o,l,n),t.filter(o).forEach(e=>{if(s&&!(e instanceof s))throw new TypeError(`Can not set properties of ${s.name} on ${e}`);e.set(attributesWithoutListener(a)),registerListenerAttributes(e,a,i?{}:e.jsxAttributes)})}function checkApplyMatches(e,t,r){const n=e.map(e=>e===r?":host":e).join(" > ");if(0===t.length)throw new Error(`No widget matches the given selector "${n}"`);const i=e[e.length-1];if("string"==typeof i&&"#"===i[0]&&t.length>1)throw new Error(`More than one widget matches the given selector "${n}"`);if(!(1===e.length&&e[0]===r)&&1===t.length&&t[0]===r)throw new Error(`The only widget that matches the given selector "${n}" is the host widget`)}function getApplyAttributeObject(e){return e.jsxAttributes||(e.jsxAttributes={}),e.jsxAttributes.apply||(e.jsxAttributes.apply={}),e.jsxAttributes.apply}class Composite extends Widget{get layout(){return this._layout}set layout(e){hint(this,'Can not set read-only property "layout"')}append(...e){this._checkDisposed();const t=e=>{if(!(e instanceof NativeObject))throw new Error(`Cannot append non-widget ${toValueString(e)} to ${this}`);if(e===this)throw new Error(`Cannot append widget ${this} to itself`);e._setParent(this)};return arguments[0]instanceof WidgetCollection?arguments[0].toArray().forEach(t):Array.isArray(arguments[0])?arguments[0].forEach(t):Array.prototype.forEach.call(arguments,t),this}find(e){return new WidgetCollection(this.children(),{selector:e,origin:this,deep:!0})}apply(e,t){return apply({host:this,args:arguments,protected:!1})}children(e){return this._children(e)}set(e){if(e&&"children"in e&&!(e.children instanceof Function))throw new Error("You may not override children with a non-function");return super.set(e)}_nativeCreate(e){super._nativeCreate(omit(e||{},["layout"])),this._initLayout(e)}_initLayout(e={}){"layout"in e?e.layout?Object.defineProperty(this,"_layout",{enumerable:!1,writable:!1,value:e.layout}):Object.defineProperty(this,"_layout",{enumerable:!1,writable:!1,value:null}):Object.defineProperty(this,"_layout",{enumerable:!1,writable:!1,value:ConstraintLayout.default}),this._layout&&(this._checkLayout(this._layout),this._layout.add(this))}_children(e){return new WidgetCollection(this.$children,{selector:e,origin:this})}_find(e){return new WidgetCollection(this._children(),{selector:e,origin:this,deep:!0})}_apply(e,t,r){return apply({host:this,args:arguments,protected:!0})}get _nativeType(){return"tabris.Composite"}_acceptChild(e){return!0}_checkLayout(e){if(e&&!(e instanceof Layout))throw new Error(`${toValueString(e)} is not an instance of Layout`)}_addChild(e,t){if(!this._acceptChild(e))throw new Error(`${toValueString(e)} could not be appended to ${this}`);this.$children||Object.defineProperties(this,{$children:{enumerable:!1,writable:!0,value:[]}}),"number"==typeof t?this.$children.splice(t,0,e):t=this.$children.push(e)-1,this._scheduleRenderChildren(),super._trigger("addChild",{child:e,index:t})}_removeChild(e){if(this.$children){const t=this.$children.indexOf(e);-1!==t&&(this.$children.splice(t,1),this._scheduleRenderChildren(),super._trigger("removeChild",{child:e,index:t}))}}_release(){if(this.$children){const e=this.$children.concat();for(const t of e){const e=!t.excludeFromLayout;t._dispose(e)}this.$children=void 0}this._layout&&this._layout.remove(this),super._release()}_getXMLContent(){const e=super._getXMLContent();for(let t=0;t<(this.$children||[]).length;++t)e.push(this.$children[t][toXML]().split("\n").map(e=>"  "+e).join("\n"));return e}_scheduleRenderChildren(){tabris.once("layout",this.$flushChildren,this)}$flushChildren(){this.$children&&this._nativeSet("children",this.$children.filter(notExcluded$1).map(toCid$1))}[jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t),{apply:i}=n,o=__rest(n,["apply"]),a=super[jsxFactory](e,o);return r&&r.length&&a.append(r),i&&asArray(i).forEach(e=>a.apply({mode:"strict",trigger:e instanceof Function?"*":"rules"},e)),a}}function toCid$1(e){return e.cid}function notExcluded$1(e){return!e.excludeFromLayout}const MIME_TYPES=Object.freeze({"image/png":"image/png","image/jpeg":"image/jpeg","image/webp":"image/webp"}),TYPE_QUALITY=Object.freeze({"image/png":1,"image/jpeg":.92,"image/webp":.8});class Canvas extends Composite{get _nativeType(){return"tabris.Canvas"}getContext(e,t,r){return"2d"===e?CanvasContext.getContext(this,t,r):null}toBlob(e,t,r){if(0===arguments.length)throw new TypeError("Canvas.toBlob requires at least 1 argument, but only 0 were passed");if(!(e instanceof Function))throw new TypeError("Argument 1 of Canvas.toBlob is not a function");this._ctx&&this._ctx._gc.flush();const n="number"==typeof r&&!isNaN(r)&&r>=0&&r<=1,i=MIME_TYPES["string"==typeof t?t:""]||MIME_TYPES["image/png"];this._nativeCall("toBlob",{onSuccess:createNativeCallback((t,r)=>{if(t){const n=new Blob([],{type:r});setBytes(n,t),e(n)}else e(null)}),mimeType:i,quality:n?r:TYPE_QUALITY[i]})}}class ImageBitmap{static createImageBitmap(e){const t=getOptions(arguments);if(e instanceof Blob)return load(t,t=>t.loadEncodedImage(getBytes(e)));if(e instanceof ImageData)return load(t,t=>t.loadImageData(e.data,e.width,e.height));if(e instanceof ImageBitmap)return getNativeObject(e).isDisposed()?Promise$1.reject(new TypeError("Can not create ImageBitmap from another closed ImageBitmap")):load(t,t=>t.loadImageBitmap(getNativeObject(e).cid));if(e instanceof Canvas)return e.isDisposed()?Promise$1.reject(new TypeError("Can not create ImageBitmap from a disposed Canvas")):load(t,t=>t.loadCanvas(e));throw new TypeError("Argument 1 of createImageBitmap could not be converted to any of: Blob, ImageData, ImageBitmap, Canvas.")}constructor(e,t){if(!(e instanceof _ImageBitmap))throw new TypeError("Illegal constructor");setNativeObject(this,e),Object.defineProperty(this,"width",{value:t.width}),Object.defineProperty(this,"height",{value:t.height})}close(){getNativeObject(this).isDisposed()||getNativeObject(this).dispose()}}Object.defineProperty(ImageBitmap.prototype,"width",{value:0}),Object.defineProperty(ImageBitmap.prototype,"height",{value:0});class _ImageBitmap extends NativeObject{get _nativeType(){return"tabris.ImageBitmap"}loadEncodedImage(e){return new Promise$1((t,r)=>this._nativeCall("loadEncodedImage",{image:e,onSuccess:t,onError:r}))}loadImageData(e,t,r){return new Promise$1((n,i)=>this._nativeCall("loadImageData",{image:e,width:t,height:r,onSuccess:n,onError:i}))}loadImageBitmap(e){return new Promise$1((t,r)=>this._nativeCall("loadImageBitmap",{image:e,onSuccess:t,onError:r}))}loadCanvas(e){return new Promise$1((t,r)=>{e._ctx&&e._ctx._gc.flush(),this._nativeCall("loadCanvas",{image:e.cid,onSuccess:t,onError:r})})}}function getOptions(e){if(-1===[1,2,5,6].indexOf(e.length))throw new TypeError(`${e.length} is not a valid argument count for any overload of createImageBitmap.`);const t={};if(2===e.length&&null!=e[1]){if(!(e[1]instanceof Object))throw new TypeError("Argument 2 of createImageBitmap is not an object.");Object.assign(t,e[1])}else if(e.length>=5){if(6===e.length&&null!=e[5]&&!(e[5]instanceof Object))throw new TypeError("Argument 6 of createImageBitmap is not an object.");t.rect={sx:types.natural.convert(e[1]),sy:types.natural.convert(e[2]),sw:types.natural.convert(e[3]),sh:types.natural.convert(e[4])},Object.assign(t,e[5]||{})}return t}function load(e,t){const r=new _ImageBitmap(e);return t(r).then(e=>{const t=new ImageBitmap(r,e);return Object.defineProperty(t,"wrapper",{value:t}),t}).catch(e=>{throw r.dispose(),new Error(e)})}NativeObject.defineProperties(_ImageBitmap.prototype,{rect:{type:"any",default:null},resizeWidth:{type:"natural",default:null},resizeHeight:{type:"natural",default:null},resizeQuality:{type:"string",default:"low",choice:["pixelated","low","medium","high"]}});class CanvasContext{constructor(e){Object.defineProperties(this,{_gc:{enumerable:!1,writable:!1,value:e},_state:{enumerable:!1,writable:!0,value:createState()},_savedStates:{enumerable:!1,writable:!1,value:[]}}),this.canvas={width:0,height:0,style:{}};for(const e in properties)defineProperty(this,e)}measureText(e){return{width:5*e.length+5}}getImageData(e,t,r,n){checkRequiredArgs(arguments,4,"CanvasContext.getImageData"),this._gc.flush();const i=this._gc.getImageData(e,t,r,n);return new ImageData(i,r,n)}putImageData(e,t,r){checkRequiredArgs(arguments,3,"CanvasContext.putImageData"),this._gc.flush(),this._gc.putImageData(e,t,r)}createImageData(e,t){if(arguments[0]instanceof ImageData){const r=arguments[0];e=r.width,t=r.height}else checkRequiredArgs(arguments,2,"CanvasContext.createImageData");return new ImageData(e,t)}_init(e,t){this.canvas.width=e,this.canvas.height=t,this._gc.init({width:e,height:t})}}Object.defineProperty(CanvasContext.prototype,"_gc",{enumerable:!1,value:null}),Object.defineProperty(CanvasContext.prototype,"_state",{enumerable:!1,writable:!0,value:null}),Object.defineProperty(CanvasContext.prototype,"_savedStates",{enumerable:!1,writable:!1,value:null}),defineMethod("save",0,function(){this._savedStates.push(Object.assign({},this._state))}),defineMethod("restore",0,function(){this._state=this._savedStates.pop()||this._state}),defineMethod("beginPath"),defineMethod("closePath"),defineMethod("lineTo",2,function(e,t){this._gc.addDouble(e,t)}),defineMethod("moveTo",2,function(e,t){this._gc.addDouble(e,t)}),defineMethod("bezierCurveTo",6,function(e,t,r,n,i,o){this._gc.addDouble(e,t,r,n,i,o)}),defineMethod("quadraticCurveTo",4,function(e,t,r,n){this._gc.addDouble(e,t,r,n)}),defineMethod("rect",4,function(e,t,r,n){this._gc.addDouble(e,t,r,n)}),defineMethod("arc",5,function(e,t,r,n,i,o){this._gc.addDouble(e,t,r,n,i),this._gc.addBoolean(!!o)}),defineMethod("arcTo",5,function(e,t,r,n,i){this._gc.addDouble(e,t,r,n,i)}),defineMethod("scale",2,function(e,t){this._gc.addDouble(e,t)}),defineMethod("rotate",1,function(e){this._gc.addDouble(e)}),defineMethod("translate",2,function(e,t){this._gc.addDouble(e,t)}),defineMethod("transform",6,function(e,t,r,n,i,o){this._gc.addDouble(e,t,r,n,i,o)}),defineMethod("setTransform",6,function(e,t,r,n,i,o){this._gc.addDouble(e,t,r,n,i,o)}),defineMethod("clearRect",4,function(e,t,r,n){this._gc.addDouble(e,t,r,n)}),defineMethod("fillRect",4,function(e,t,r,n){this._gc.addDouble(e,t,r,n)}),defineMethod("strokeRect",4,function(e,t,r,n){this._gc.addDouble(e,t,r,n)}),defineMethod("fillText",3,function(e,t,r){this._gc.addString(e),this._gc.addBoolean(!1,!1,!1),this._gc.addDouble(t,r)}),defineMethod("strokeText",3,function(e,t,r){this._gc.addString(e),this._gc.addBoolean(!1,!1,!1),this._gc.addDouble(t,r)}),defineMethod("fill"),defineMethod("stroke"),defineMethod("drawImage",3,function(e,t,r,n,i,o,a,s,l){if(!(e instanceof ImageBitmap))throw new TypeError("First argument of CanvasContext.drawImage must be of type ImageBitmap");if(this._gc.addString(getNativeObject(e).cid),9===arguments.length)this._gc.addDouble(t,r,n,i,o,a,s,l);else if(5===arguments.length)this._gc.addDouble(0,0,e.width,e.height,t,r,n,i);else{if(3!==arguments.length)throw new TypeError(arguments.length+" is not a valid argument count for any overload of Canvas.drawImage.");this._gc.addDouble(0,0,e.width,e.height,t,r,e.width,e.height)}}),CanvasContext.getContext=function(e,t,r){if(!e._gc){const t=new GC({parent:e});e.on("_dispose",()=>t.dispose()),Object.defineProperty(e,"_gc",{enumerable:!1,writable:!1,value:t})}return e._ctx||Object.defineProperty(e,"_ctx",{enumerable:!1,writable:!1,value:new CanvasContext(e._gc)}),e._ctx._init(t,r),e._ctx};const properties={lineWidth:{init:1,encode(e){if(!isNaN(e)&&e>0)return e;throw new Error(`Invalid value ${toValueString(e)}`)},decode:passThrough,addOperations(e){this._gc.addDouble(e)}},lineCap:{init:"butt",values:toObject(["butt","round","square"]),encode:checkValue,decode:passThrough,addOperations(e){this._gc.addString(e)}},lineJoin:{init:"miter",values:toObject(["bevel","miter","round"]),encode:checkValue,decode:passThrough,addOperations(e){this._gc.addString(e)}},fillStyle:{init:[0,0,0,255],encode:e=>Color.from(e).toArray(),decode:colorArrayToString,addOperations(e){this._gc.addInt(e[0],e[1],e[2],e[3])}},strokeStyle:{init:[0,0,0,255],encode:e=>Color.from(e).toArray(),decode:colorArrayToString,addOperations(e){this._gc.addInt(e[0],e[1],e[2],e[3])}},textAlign:{init:"start",values:toObject(["start","end","left","right","center"]),encode:checkValue,decode:passThrough,addOperations(e){this._gc.addString(e)}},textBaseline:{init:"alphabetic",values:toObject(["top","hanging","middle","alphabetic","ideographic","bottom"]),encode:checkValue,decode:passThrough,addOperations(e){this._gc.addString(e)}},font:{init:{family:["sans-serif"],size:12,weight:"normal",style:"normal"},encode:fontStringToObject,decode:fontObjectToString,addOperations(e){this._gc.addString(e.family.join(", "),e.style,e.weight),this._gc.addDouble(e.size)}}};function passThrough(e){return e}function checkValue(e){if(e in this.values)return e;throw new Error(`Invalid value ${toValueString(e)}`)}function toObject(e){const t={};return e.forEach(e=>{t[e]=!0}),t}function createState(){const e={};for(const t in properties)e[t]=properties[t].init;return e}function defineMethod(e,t,r){CanvasContext.prototype[e]=function(){checkRequiredArgs(arguments,t,"CanvasContext."+e),this._gc.addOperation(e),r&&r.apply(this,arguments)}}function defineProperty(e,t){const r=properties[t];Object.defineProperty(e,t,{get:()=>r.decode(e._state[t]),set(n){try{e._state[t]=r.encode(n),e._gc.addOperation(t),r.addOperations.call(e,e._state[t])}catch(r){hint(e,"Unsupported value for "+t+": "+n)}}})}function checkRequiredArgs(e,t,r){if(e.length<t)throw new Error("Not enough arguments to "+r)}class Printer extends NativeObject{_nativeCreate(e){if(!0!==e)throw new Error("Printer can not be created");super._nativeCreate()}get _nativeType(){return"tabris.Printer"}print(e,t){return new Promise$1((r,n)=>{if(arguments.length<1)throw new Error("Not enough arguments to print");if(!isDataValid(e))throw new Error("data is not an ArrayBuffer or typed array");this._nativeCall("print",{data:e instanceof ArrayBuffer?e:e.buffer,options:t,onResult:e=>r({result:e}),onError:e=>n(new Error(e))})})}dispose(){throw new Error("Cannot dispose printer object")}}function isDataValid(e){return e instanceof ArrayBuffer||e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function create$1(){return new Printer(!0)}class Permission extends NativeObject{_nativeCreate(e){if(!0!==e)throw new Error("Permission can not be created");super._nativeCreate()}get _nativeType(){return"tabris.Permission"}getAuthorizationStatus(...e){Permission.validatePermissions(e,"get authorization status");const t=this._nativeCall("getAuthorizationStatus",{permissions:e});if(!t||t.error)throw new Error(t?t.error:"No result returned for getAuthorizationStatus()");return t.status}isAuthorized(...e){return Permission.validatePermissions(e,"check if permission is authorized"),"granted"===this.getAuthorizationStatus(...e)}isAuthorizationPossible(...e){Permission.validatePermissions(e,"check if authorization is possible");const t=this.getAuthorizationStatus(...e);return"undetermined"===t||"declined"===t}requestAuthorization(...e){return new Promise$1((t,r)=>{Permission.validatePermissions(e,"request permission authorization"),this._nativeCall("requestAuthorization",{permissions:e,onResult:e=>{!e||e.error?r(new Error(e?e.error:"Authorization could not be requested")):t(e.status)}})})}withAuthorization(e,t,r,n){if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new Error("Permissions need to be of type string")}else{if("string"!=typeof e)throw new Error("Permission needs to be of type string or an array of strings");e=[e]}this.requestAuthorization(...e).then(e=>{"granted"===e&&"function"==typeof t?t(e):"function"==typeof r&&r(e)}).catch(e=>{"function"==typeof n&&n(e)})}static validatePermissions(e,t){if(0===e.length)throw new Error(`Not enough arguments to ${t}`);if(!e.every(e=>"string"==typeof e))throw new Error("Permissions need to be of type string")}dispose(){throw new Error("Cannot dispose permission object")}}function create$2(){return new Permission(!0)}class Authentication extends NativeObject{_nativeCreate(e){if(!0!==e)throw new Error("Authentication can not be created");super._nativeCreate()}get _nativeType(){return"tabris.Authentication"}canAuthenticate(e={}){return checkType(e.allowCredentials,Boolean,{name:"allowCredentials",nullable:!0}),this._nativeCall("canAuthenticate",e)}authenticate(e={}){return new Promise$1((t,r)=>{checkType(e.title,String,{name:"title",nullable:!0}),checkType(e.subtitle,String,{name:"subtitle",nullable:!0}),checkType(e.message,String,{name:"message",nullable:!0}),checkType(e.allowCredentials,Boolean,{name:"allowCredentials",nullable:!0}),checkType(e.confirmationRequired,Boolean,{name:"confirmationRequired",nullable:!0}),this._nativeCall("authenticate",{options:e,onResult:e=>t(e),onError:e=>r(new Error(e))})})}cancel(){this._nativeCall("cancel")}dispose(){throw new Error("Cannot dispose authentication object")}}function create$3(){return new Authentication(!0)}NativeObject.defineProperties(Authentication.prototype,{availableBiometrics:{readonly:!0}});class File extends Blob{constructor(e,t,r={}){if(arguments.length<2)throw new TypeError(`File requires at least 2 arguments, but only ${arguments.length} were passed.`);super(e,r),Object.defineProperty(this,"name",{value:t+""});const n="lastModified"in r?r.lastModified:Date.now();isNaN(n)||!isFinite(n)?Object.defineProperty(this,"lastModified",{value:0}):Object.defineProperty(this,"lastModified",{value:Math.round("string"==typeof n?parseInt(n):0+n)})}}File.prototype[Symbol.toStringTag]="File",Object.defineProperty(File.prototype,"name",{value:""}),Object.defineProperty(File.prototype,"lastModified",{value:0});const CERTIFICATE_ALGORITHMS=["RSA2048","RSA4096","ECDSA256"];class App extends NativeObject{get _nativeType(){return"tabris.App"}_nativeCreate(e){if(!0!==e)throw new Error("App can not be created");super._nativeCreate(),this._nativeSet("encodeColor",e=>types.ColorValue.encode(types.ColorValue.convert(e))),this._nativeSet("encodeFont",e=>types.FontValue.encode(types.FontValue.convert(e)))}_beforePropertyChange(e){"pinnedCertificates"===e&&this.on("certificatesReceived",this._validateCertificate,this)}get id(){return this._nativeGet("appId")}get debugBuild(){return this._nativeGet("debugBuild")}get version(){return this._nativeGet("version")}get versionCode(){return this._nativeGet("versionId")}launch(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("Not enough arguments to launch");if("string"!=typeof e)throw new Error(`Invalid url: ${toValueString(e)} is not a string`);this._nativeCall("launch",{url:e,onError:e=>r(new Error(e)),onSuccess:()=>t()})})}share(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("The share functions requires a data object");if("object"!=typeof e||null==e.text&&null==e.title&&null==e.url&&null==e.files)throw new TypeError(`Invalid data object: ${JSON.stringify(e)}. At least one of title, text, url or files is required`);this._nativeCall("share",{data:this._prepareShareData(e),onSuccess:e=>t(e),onError:e=>r(new Error(e))})})}_prepareShareData(e){const t={};if(e.title&&(t.title=String(e.title)),e.text&&(t.text=String(e.text)),e.url&&(t.url=String(e.url)),e.files){if(!Array.isArray(e.files))throw new Error('The share data "files" is not an array');if(!e.files.every(e=>e instanceof File))throw new Error('The share data "files" array can only contain File objects');t.files=e.files.map(e=>({name:e.name,type:e.type,data:getBytes(e)}))}return t}getResourceLocation(e){this._resourceBaseUrl||Object.defineProperty(this,"_resourceBaseUrl",{enumerable:!1,writable:!1,value:this._nativeGet("resourceBaseUrl")});const t=null!=e?"/"+normalizePath$1(""+e):"";return this._resourceBaseUrl+t}dispose(){throw new Error("tabris.app can not be disposed")}reload(e){this._nativeCall("reload",{url:e})}close(){this._nativeCall("close")}registerFont(e,t){if(arguments.length<2)throw new Error("Not enough arguments to register a font");if("string"!=typeof e)throw new Error(`Invalid alias: ${toValueString(e)} is not a string`);if("string"!=typeof t)throw new Error(`Invalid file path: ${toValueString(t)} is not a string`);this._nativeCall("registerFont",{alias:e,file:t})}_validateCertificate(e){const t=this.$pinnedCerts[e.host];t&&!t.some(t=>e.hashes.includes(t))&&e.preventDefault()}get $pinnedCerts(){const e=this.pinnedCertificates,t={};for(const r of e)t[r.host]=t[r.host]||[],t[r.host].push(r.hash);return t}}function create$4(){return new App(!0)}function normalizePath$1(e){return e.split(/\/+/).map(t=>{if(".."===t)throw new Error(`Path ${toValueString(e)} must not contain ".."`);return"."===t?"":t}).filter(e=>!!e).join("/")}NativeObject.defineProperties(App.prototype,{pinnedCertificates:{type:{convert:e=>Object.freeze(e),encode(e){if(!Array.isArray(e))throw new Error("Not an Array");for(const t of e){if("string"!=typeof t.host)throw new Error(`Invalid host ${toValueString(t.host)}`);if("string"!=typeof t.hash||!t.hash.startsWith("sha256/"))throw new Error(`Invalid hash ${toValueString(t.hash)} for pinned certificate ${t.host}`);if("iOS"===tabris.device.platform){if(!("algorithm"in t))throw new Error(`Missing algorithm for pinned certificate ${t.host}`);if("string"!=typeof t.algorithm||-1===CERTIFICATE_ALGORITHMS.indexOf(t.algorithm))throw new Error(`Invalid algorithm ${toValueString(t.algorithm)} for pinned certificate ${t.host}`)}}return e}},default:Object.freeze([])},trustedCertificates:{type:{convert:e=>Object.freeze(e),encode(e){if(!Array.isArray(e))throw new Error("Not an Array");for(let t=0;t<e.length;t++){const r=e[t];if(!(r instanceof ArrayBuffer))throw new Error(`certificate entry ${toValueString(r)} is not an ArrayBuffer`)}return e}},default:Object.freeze([])},idleTimeoutEnabled:{type:{convert(e){if(!tabris.contentView)throw new Error('The device property "idleTimeoutEnabled" can only be changed in main context.');return types.boolean.convert(e)}},default:!0}}),NativeObject.defineEvents(App.prototype,{foreground:{native:!0},background:{native:!0},pause:{native:!0},resume:{native:!0},terminate:{native:!0},keyPress:{native:!0},backNavigation:{native:!0},certificatesReceived:{native:!0}});const ERRORS={EACCES:"Permission denied",EEXIST:"File exists",ENOENT:"No such file or directory",EISDIR:"Is a directory",ENOTDIR:"Not a directory",ENOTEMPTY:"Directory not empty"};class FileSystem extends NativeObject{get _nativeType(){return"tabris.FileSystem"}_nativeCreate(e){if(!0!==e)throw new Error("FileSystem can not be created");super._nativeCreate()}get filesDir(){return this._nativeGet("filesDir")}get cacheDir(){return this._nativeGet("cacheDir")}get externalFileDirs(){return this._nativeGet("externalFileDirs")}get externalCacheDirs(){return this._nativeGet("externalCacheDirs")}readFile(e,t){return new Promise$1((r,n)=>{if(arguments.length<1)throw new Error("Not enough arguments to readFile");this._nativeCall("readFile",{path:checkPath(e,"file name"),onError:t=>n(createError(t,e)),onSuccess:e=>t?TextDecoder.decode(e,t).then(r,n):r(e)})})}openFile(e){return new Promise$1((t,r)=>{let n={};if(arguments.length>=1){if(!(e instanceof Object))throw new Error("Options need to be an Object");const t="type"in e?e.type:"*/*";if("string"!=typeof t)throw new Error(`Invalid type: ${toValueString(t)} is not a string`);const r="quantity"in e?e.quantity:"single";if("string"!=typeof r)throw new Error(`Invalid quantity: ${toValueString(r)} is not a string`);if("single"!==r&&"multiple"!==r)throw new Error(`Quantity has to be "single" or "multiple" but is ${toValueString(r)}`);n={type:t,quantity:r}}this._nativeCall("openFile",{options:n,onSuccess:e=>{Array.isArray(e)&&e.length>0?t(e.map(e=>new File([e.data],e.name,{type:e.type,lastModified:e.lastModified}))):t([])},onError:e=>r(new Error(e))})})}writeFile(e,t,r){return new Promise$1((n,i)=>{if(arguments.length<2)throw new Error("Not enough arguments to writeFile");const o=t=>this._nativeCall("writeFile",{path:checkPath(e,"file name"),data:checkBuffer(t),onError:t=>i(createError(t,e)),onSuccess:()=>n()});"string"==typeof t?TextEncoder.encode(t,r||"utf-8").then(o,i):o(t)})}appendToFile(e,t,r){return new Promise$1((n,i)=>{if(arguments.length<2)throw new Error("Not enough arguments to appendToFile");const o=t=>this._nativeCall("appendToFile",{path:checkPath(e,"file name"),data:checkBuffer(t),onError:t=>i(createError(t,e)),onSuccess:e=>n(e)});"string"==typeof t?TextEncoder.encode(t,r||"utf-8").then(o,i):o(t)})}removeFile(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("Not enough arguments to removeFile");this._nativeCall("removeFile",{path:checkPath(e,"file name"),onError:t=>r(createError(t,e)),onSuccess:()=>t()})})}readDir(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("Not enough arguments to readDir");this._nativeCall("readDir",{path:checkPath(e,"directory"),onError:t=>r(createError(t,e)),onSuccess:e=>t(e)})})}createDir(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("Not enough arguments to createDir");this._nativeCall("createDir",{path:checkPath(e,"directory"),onError:t=>r(createError(t,e)),onSuccess:()=>t()})})}removeDir(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("Not enough arguments to removeDir");this._nativeCall("removeDir",{path:checkPath(e,"directory"),onError:t=>r(createError(t,e)),onSuccess:()=>t()})})}remove(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("Not enough arguments to remove");this._nativeCall("remove",{path:checkPath(e,"file or directory"),onError:t=>r(createError(t,e)),onSuccess:e=>t(e)})})}isFile(e){if(arguments.length<1)throw new Error("Not enough arguments to isFile");return this._nativeCall("isFile",{path:checkPath(e,"file name")})}isDir(e){if(arguments.length<1)throw new Error("Not enough arguments to isDir");return this._nativeCall("isDir",{path:checkPath(e,"directory")})}dispose(){throw new Error("Cannot dispose fs object")}}function create$5(){return new FileSystem(!0)}function createError(e,t){const r=`${ERRORS[e]||e}: ${t}`,n=e in ERRORS?e:null,i=new Error(r);return Object.defineProperties(i,{path:{value:t},code:{value:n}}),i}function checkPath(e,t){try{return normalizePath(e)}catch(r){throw new Error(`${toValueString(e)} is not a valid ${t}. ${r.message}`)}}function checkBuffer(e){if(ArrayBuffer.isView(e)&&(e=e.buffer),e instanceof Blob)return getBytes(e);if(!(e instanceof ArrayBuffer))throw new Error(`${toValueString(e)} is not an ArrayBuffer`);return e}class Input extends NativeObject{get _nativeType(){return"tabris.Input"}_nativeCreate(e){if(!0!==e)throw new Error("Input can not be created");super._nativeCreate(null)}dispose(){throw new Error("Cannot dispose input object")}}function create$6(){return new Input(!0)}NativeObject.defineEvents(Input.prototype,{pointerDown:{native:!0},pointerMove:{native:!0},pointerUp:{native:!0},pointerCancel:{native:!0},resize:{native:!0}});class DevTools extends NativeObject{get _nativeType(){return"tabris.DevTools"}_nativeCreate(e){if(!0!==e)throw new Error("DevTools can not be created");super._nativeCreate()}showUi(){return this._nativeCall("showUi")}hideUi(){this._nativeCall("hideUi")}isUiVisible(){return this._nativeCall("isUiVisible")}dispose(){throw new Error("Cannot dispose devTools object")}}function create$7(){return new DevTools(!0)}function addDOMDocument(e){class HTMLElement{constructor(e){this.tagName=(e||"").toUpperCase(),this.children=[]}setAttribute(){}appendChild(t){return this.children.push(t),handleElementInserted(this,t,e),t}cloneNode(){return new HTMLElement}lastChild(){return new HTMLElement}}e.document={documentElement:{},createDocumentFragment:()=>new HTMLElement,createElement:e=>new HTMLElement(e),location:{href:""},readyState:"loading",head:new HTMLElement("head"),getElementsByTagName(e){return this.head.children.filter(t=>t.tagName===e.toUpperCase())},createEvent:e=>new Event(e)},addDOMEventTargetMethods(e.document),void 0===e.location&&(e.location=e.document.location),tabris.once("start",()=>{e.document.readyState="complete";const t=new Event("DOMContentLoaded",!1,!1);e.document.dispatchEvent(t)})}function handleElementInserted(e,t,r){if("HEAD"===e.tagName&&"SCRIPT"===t.tagName&&t.src){let e;try{e=tabris._client.loadAndExecute(t.src,"","")}catch(e){return error("Error loading "+t.src+":",e),log(e.stack),void("function"==typeof t.onerror&&t.onerror.call(r,e))}e.loadError?"function"==typeof t.onerror&&t.onerror.call(r,new Error("Could not load "+t.src)):"function"==typeof t.onload&&t.onload.call(r)}}function addWindowTimerMethods(e){if("function"==typeof e.setTimeout)return;let t=0;function createTimer(r,n,i,o){const a=t++,s=()=>tabris.app._nativeCall("startTimer",{id:a,delay:n,repeat:i,callback:createNativeCallback(r,e,o)});return tabris.started?s():tabris.once("start",s),a}e.setTimeout=function(e,t){if(arguments.length<1)throw new TypeError("Not enough arguments to setTimeout");if("function"!=typeof e)throw new TypeError("Illegal argument to setTimeout: not a function");const r=Array.prototype.slice.call(arguments,2);return createTimer(e,adjustDelay(t),!1,r)},e.setInterval=function(e,t){if(arguments.length<1)throw new TypeError("Not enough arguments to setInterval");if("function"!=typeof e)throw new TypeError("Illegal argument to setInterval: not a function");const r=Array.prototype.slice.call(arguments,2);return createTimer(e,adjustDelay(t),!0,r)},e.clearTimeout=e.clearInterval=(e=>tabris.app._nativeCall("cancelTimer",{id:e}))}function adjustDelay(e){return"number"==typeof e&&isFinite(e)?Math.max(0,Math.round(e)):0}class NativeStore extends NativeObject{constructor(e){super(e)}get keys(){return this._nativeCall("keys")}_nativeCreate(e){this.secure=e,super._nativeCreate()}get _nativeType(){return this.secure?"tabris.SecureStore":"tabris.ClientStore"}_getXMLElementName(){return"Storage"}_getXMLAttributes(){return[["length",this.keys.length]]}_getXMLContent(){return this.keys.map(e=>{const t=this._nativeCall("get",{key:e}),r=e.replace(/[^a-zA-Z0-9_.:-]/g,""),n=t.split("\n");return 1===n.length?`  <${r}>${t}</${r}>`:`  <${r}>\n${n.map(e=>"    "+e).join("\n")}\n  </${r}>`})}}class Storage{constructor(){const e=arguments[0];if(!(e instanceof NativeObject))throw new Error("Cannot instantiate Storage");Object.defineProperty(this,"_nativeObject",{value:e})}setItem(e,t){if(arguments.length<2)throw new TypeError("Not enough arguments to 'setItem'");this._nativeObject._nativeCall("add",{key:encode(e),value:encode(t)})}getItem(e){if(arguments.length<1)throw new TypeError("Not enough arguments to 'getItem'");const t=this._nativeObject._nativeCall("get",{key:encode(e)});return void 0===t?null:t}removeItem(e){if(arguments.length<1)throw new TypeError("Not enough arguments to 'removeItem'");this._nativeObject._nativeCall("remove",{keys:[encode(e)]})}clear(){this._nativeObject._nativeCall("clear")}key(e){return this._nativeObject.keys[e]||null}[toXML$1](){return this._nativeObject[toXML$1]()}get length(){return this._nativeObject.keys.length}}function encode(e){return""+e}function create$8(e){return new Storage(new NativeStore(e))}class Action extends Widget{get _nativeType(){return"tabris.Action"}_getXMLAttributes(){return super._getXMLAttributes().concat([["title",this.title]])}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return super[JSX.jsxFactory](e,this.withContentText(n,r,"title"))}}NativeObject.defineProperties(Action.prototype,{image:{type:types.ImageValue,default:null},placement:{type:types.string,choice:["default","navigation","overflow"],default:"default"},title:{type:types.string,default:""}}),NativeObject.defineEvents(Action.prototype,{select:{native:!0}});class Popup extends NativeObject{open(){if(this.isDisposed())throw new Error("Can not open a popup that was disposed");return this._nativeCall("open",{}),this}close(){return this._handleClose({}),this}_trigger(e,t){return"close"===e?this._handleClose(t):super._trigger(e,t)}_handleClose(e){return!this._isDisposed&&!this._inDispose&&(super._trigger("close",e),this.dispose(),!1)}[JSX.jsxFactory](e,t){return this.createNativeObject(e,t)}}class ActionSheet extends Popup{static open(e){if(!(e instanceof ActionSheet))throw new Error("Not an ActionSheet: "+toValueString(e));return e.open()}constructor(e){super(e),Object.defineProperties(this,{_index:{enumerable:!1,writable:!0,value:null},_action:{enumerable:!1,writable:!0,value:null}}),this._nativeListen("select",!0)}get _nativeType(){return"tabris.ActionSheet"}_trigger(e,t){if("select"!==e)return super._trigger(e,t);this._index=t.index,this._action=this.actions[this._index],super._trigger("select",Object.assign(t,{action:this._action}))}_handleClose(e){return Object.assign(e,{index:this._index,action:this._action}),super._handleClose(e)}[JSX.jsxFactory](e,t){const r=this.getChildren(t)||[];let n=this.withoutChildren(t);return n=this.withContentChildren(n,r.filter(e=>e instanceof Object),"actions"),n=this.withContentText(n,r.filter(e=>!(e instanceof Object)),"message"),this.createNativeObject(e,n)}}NativeObject.defineProperties(ActionSheet.prototype,{title:{type:types.string,default:""},message:{type:types.string,default:""},actions:{type:{convert(e){if(!Array.isArray(e))throw new Error(toValueString(e)+" is not an array");return Object.freeze(e.map(ActionSheetItem.from))},encode:e=>e.map(e=>({title:e.title,image:types.ImageValue.encode(e.image),style:e.style}))},default:Object.freeze([])}}),NativeObject.defineEvents(ActionSheet.prototype,{close:{native:!0},select:{native:!0}});class ActionSheetItem{constructor({title:e,image:t,style:r}={}){Object.defineProperty(this,"title",{value:types.string.convert(e),enumerable:!0}),Object.defineProperty(this,"image",{value:types.ImageValue.convert(t),enumerable:!0}),Object.defineProperty(this,"style",{value:allowOnlyValues(r||"default",["default","cancel","destructive"],"style"),enumerable:!0})}toString(){return this.title||"[object ActionSheetItem]"}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return new e(this.withContentText(n,r,"title"))}static from(e){if(e instanceof ActionSheetItem)return e;if(e.constructor!==Object)throw new Error("Can not convert a non-object to an ActionSheetItem");try{return new ActionSheetItem(allowOnlyKeys(e,["title","image","style"]))}catch(e){throw new Error("Can not convert to an ActionSheetItem: "+e.message)}}}Object.defineProperty(ActionSheetItem.prototype,"title",{value:""}),Object.defineProperty(ActionSheetItem.prototype,"image",{value:null}),Object.defineProperty(ActionSheetItem.prototype,"style",{value:"default"});class ActivityIndicator extends Widget{get _nativeType(){return"tabris.ActivityIndicator"}}NativeObject.defineProperties(ActivityIndicator.prototype,{tintColor:{type:"ColorValue",default:"initial"}});class TextInput extends Widget{get _nativeType(){return"tabris.TextInput"}_getXMLContent(){let e=super._getXMLContent();return this._shouldPrintTextAsXMLContent()&&(e=e.concat(this.text.split("\n").map(e=>"  "+e))),e}_getXMLAttributes(){const e=super._getXMLAttributes();return"default"!==this.type&&e.push(["type",this.type]),this._shouldPrintTextAsXMLContent()||e.push(["text",this.text]),this.message&&e.push(["message",this.message]),this.editable||e.push(["editable","false"]),this.focused&&e.push(["focused","true"]),this.keepFocus&&e.push(["keepFocus","true"]),e}_shouldPrintTextAsXMLContent(){return this.text.length>25||-1!==this.text.indexOf("\n")}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return super[JSX.jsxFactory](e,this.withContentText(n,r,"text"))}}NativeObject.defineProperties(TextInput.prototype,{type:{type:types.string,choice:["default","password","search","multiline"],const:!0,default:"default"},style:{type:types.string,choice:["default","outline","fill","underline","none"],const:!0,default:"default"},text:{type:types.string,nocache:!0},message:{type:types.string,default:""},floatMessage:{type:types.boolean,default:!0},editable:{type:types.boolean,default:!0},maxChars:{type:{convert:e=>e<=0?null:types.natural.convert(e)},default:null,nullable:!0},keepFocus:{type:types.boolean,default:!1},alignment:{type:types.string,choice:["left","centerX","right"],default:"left"},autoCorrect:{type:types.boolean,default:!1},autoCapitalize:{type:{convert:e=>!0===e?"all":e||"none"},choice:["none","sentence","word","all"],default:!1},keyboard:{type:types.string,choice:["ascii","decimal","email","number","numbersAndPunctuation","phone","url","default"],default:"default"},enterKeyType:{type:types.string,choice:["default","done","next","send","search","go"],default:"default"},messageColor:{type:types.ColorValue,default:"initial"},focused:{type:types.boolean,nocache:!0},borderColor:{type:types.ColorValue,default:"initial"},textColor:{type:types.ColorValue,default:"initial"},revealPassword:{type:types.boolean,default:!1},cursorColor:{type:types.ColorValue,default:"initial"},selection:{type:{convert(e,t){if(!(e instanceof Array)||2!==e.length)throw new Error(`Selection has to be a two element array with start and end position but is ${toValueString(e)}`);const r=t.text.length,n=e.map(e=>types.number.convert(e));if(n[1]>r||n[0]>r||n[1]<0||n[0]<0)throw new Error(`The selection has to be in the range of 0 to text length [0-${r}] but is ${e}`);return Object.freeze(n)}},nocache:!0},font:{type:types.FontValue,default:"initial"},keyboardAppearanceMode:{type:types.string,choice:["never","ontouch","onfocus"],default:"onfocus"}}),NativeObject.defineEvents(TextInput.prototype,{focus:{native:!0,changes:"focused",changeValue:()=>!0},blur:{native:!0,changes:"focused",changeValue:()=>!1},accept:{native:!0},input:{native:!0,changes:"text"},beforeTextChange:{native:!0},select:{native:!0,changes:"selection"}});class ContentView extends Composite{_nativeCreate(e){if(!e||!0!==e[creationAllowed])throw new Error("ContentView can not be created");Object.defineProperties(this,{_childType:{enumerable:!1,writable:!1,value:e.childType},_phantom:{enumerable:!1,writable:!1,value:e.phantom}}),delete e[creationAllowed],delete e.childType,delete e.phantom,this._phantom?(this._register(),this._initLayout(e)):super._nativeCreate(e)}_nativeSet(e,t){this._phantom||super._nativeSet(e,t)}_nativeGet(e){if(!this._phantom)return super._nativeGet(e)}_nativeListen(e,t){if(!this._phantom)return super._nativeListen(e,t)}_nativeCall(e,t){if(!this._phantom)return super._nativeCall(e,t)}_acceptChild(e){return!this._childType||e instanceof this._childType}_setParent(e,t){if(this._parent)throw new Error("Parent of ContentView can not be changed");super._setParent(e,t)}_dispose(){throw new Error("ContentView can not be disposed")}}function create$9(e){return new ContentView(Object.assign({[creationAllowed]:!0},e))}class AlertDialog extends Popup{static open(e){let t;return(t=e instanceof AlertDialog?e:new AlertDialog({message:e,buttons:{ok:"OK"}})).open()}constructor(e){super(e),this._nativeListen("close",!0)}get _nativeType(){return"tabris.AlertDialog"}get textInputs(){return this._contentView||Object.defineProperty(this,"_contentView",{enumerable:!1,writable:!1,value:create$9({layout:null,childType:TextInput,phantom:!0})}),this._contentView}set textInputs(e){hint(this,'Property "textInputs" can not be set, append to it instead')}open(){return!this.isDisposed()&&this._contentView&&this._nativeSet("textInputs",this._contentView.children().toArray().map(e=>e.cid)),super.open()}_handleClose(e){return e.button=e.button||null,e.texts=[],this._contentView&&(e.texts=this._contentView.children().toArray().map(e=>e.text)),e.button&&this._trigger("close"+capitalizeFirstChar(e.button),e),super._handleClose(e)}_dispose(){!this.isDisposed()&&this._contentView&&Composite.prototype._dispose.call(this._contentView,!0),super._dispose()}}function createElement$2(e,t){const r=this.getChildren(t)||[];let n=this.withoutChildren(t);n=this.withContentText(n,r.filter(e=>!(e instanceof Object)),"message");const i=r.filter(e=>e instanceof Object),o=Popup.prototype[JSX.jsxFactory].call(this,e,n);return r&&r.length&&o.textInputs.append(i),o}NativeObject.defineProperties(AlertDialog.prototype,{title:{type:types.string,default:""},message:{type:types.string,default:""},buttons:{type:{convert(e){allowOnlyKeys(e,["ok","cancel","neutral"]);const t={};return"ok"in e&&(t.ok=e.ok+""),"cancel"in e&&(t.cancel=e.cancel+""),"neutral"in e&&(t.neutral=e.neutral+""),Object.freeze(t)}},default:Object.freeze({})}}),NativeObject.defineEvents(AlertDialog.prototype,{close:!0,closeOk:!0,closeCancel:!0,closeNeutral:!0}),AlertDialog.prototype[JSX.jsxFactory]=createElement$2;class Button extends Widget{constructor(e){super(Object.assign({style:"default"},e))}get _nativeType(){return"tabris.Button"}_reorderProperties(e){const t=e.indexOf("style");return-1===t?super._reorderProperties(e):super._reorderProperties(["style"].concat(e.slice(0,t)).concat(e.slice(t+1)))}_getXMLAttributes(){return super._getXMLAttributes().concat([["text",this.text]])}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return super[JSX.jsxFactory](e,this.withContentText(n,r,"text"))}}NativeObject.defineProperties(Button.prototype,{style:{type:types.string,choice:["default","elevate","flat","outline","text"],default:"default",const:!0},strokeColor:{type:{convert(e,t){if("outline"!==t.style)throw new Error(`The strokeColor can only be set on buttons with style "outline" but it has style ${t.style}.`);return types.ColorValue.convert(e)},encode:types.ColorValue.encode},default:"initial"},strokeWidth:{type:{convert(e,t){if("outline"!==t.style)throw new Error(`The strokeWidth can only be set on buttons with style "outline" but it has style ${t.style}.`);return types.dimension.convert(e)}},nullable:!0,default:null},alignment:{type:types.string,choice:["left","right","centerX"],default:"centerX"},autoCapitalize:{type:types.string,choice:["default","none","all"],default:"default"},image:{type:types.ImageValue,default:null},imageTintColor:{type:types.ColorValue,default:"initial"},text:{type:types.string,default:""},textColor:{type:types.ColorValue,default:"initial"},font:{type:types.FontValue,default:"initial"}}),NativeObject.defineEvents(Button.prototype,{select:{native:!0}});class CheckBox extends Widget{get _nativeType(){return"tabris.CheckBox"}_getXMLAttributes(){return super._getXMLAttributes().concat([["text",this.text],["checked",this.checked]])}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return super[JSX.jsxFactory](e,this.withContentText(n,r,"text"))}}NativeObject.defineProperties(CheckBox.prototype,{text:{type:"string",default:""},checked:{type:"boolean",nocache:!0},textColor:{type:"ColorValue",default:"initial"},tintColor:{type:"ColorValue",default:"initial"},checkedTintColor:{type:"ColorValue",default:"initial"},font:{type:"FontValue",default:"initial"}}),NativeObject.defineEvents(CheckBox.prototype,{select:{native:!0,changes:"checked"}});class CollectionView extends Composite{constructor(e){super(),Object.defineProperties(this,{_needsReload:{enumerable:!1,writable:!0,value:!1},_updateCell:{enumerable:!1,writable:!0,value:()=>{}},_itemCount:{enumerable:!1,writable:!0,value:0},_createCell:{enumerable:!1,writable:!0,value:()=>new Composite},_cellHeight:{enumerable:!1,writable:!0,value:"auto"},_cellType:{enumerable:!1,writable:!0,value:null},_cellMapping:{enumerable:!1,writable:!0,value:new Map},_itemMapping:{enumerable:!1,writable:!0,value:new Map}}),this.set(e||{}),this._nativeListen("requestInfo",!0),this._nativeListen("createCell",!0),this._nativeListen("updateCell",!0),tabris.on("_flush",this.$flush,this),this.on("_dispose",()=>tabris.off("_flush",this.$flush,this))}get _nativeType(){return"tabris.CollectionView"}set itemCount(e){try{const t=this._itemCount;this._itemCount=types.natural.convert(e),this._needsReload=!0,t!==this._itemCount&&this._triggerChangeEvent("itemCount",this._itemCount)}catch(e){this._printPropertyWarning("itemCount",e)}}get itemCount(){return this._itemCount}set cellType(e){null===e||"string"==typeof e||e instanceof Function?e!==this._cellType&&(this._cellType=e,this._needsReload=!0,this._triggerChangeEvent("cellType",this._itemCount)):this._printPropertyWarning("cellType",new Error("Not a string or function"))}get cellType(){return this._cellType}set cellHeight(e){try{const t=this._cellHeight;"auto"===e||e instanceof Function?this._cellHeight=e:this._cellHeight=types.dimension.convert(e),t!==this._cellHeight&&(this._needsReload=!0,this._triggerChangeEvent("cellHeight",this._cellHeight))}catch(e){this._printPropertyWarning("cellHeight",e)}}get cellHeight(){return this._cellHeight}set createCell(e){e instanceof Function?e!==this._createCell&&(this._createCell=e,this._needsReload=!0,this._triggerChangeEvent("createCell",this._createCell)):this._printPropertyWarning("createCell",new Error("Not a function"))}get createCell(){return this._createCell}set updateCell(e){e instanceof Function?this._updateCell!==e&&(this._updateCell=e,this._needsReload=!0,this._triggerChangeEvent("updateCell",this._updateCell)):this._printPropertyWarning("updateCell",new Error("Not a function"))}get updateCell(){return this._updateCell}load(e){if(!isNumber$1(e)||e<0)throw new Error(`Invalid itemCount ${toValueString(e)}`);this._itemCount=e,this._needsReload=!0}reveal(e,t){(e=this.$checkIndex(e))>=0&&e<this.itemCount&&(this.$flush(),this._nativeCall("reveal",{index:e,animate:!(t&&"animate"in t)||!!t.animate,offset:t&&"offset"in t?t.offset:null}))}refresh(e){if(0===arguments.length)return this.$flush(),void this._nativeCall("refresh",{index:0,count:this.itemCount});(e=this.$checkIndex(e))>=0&&e<this.itemCount&&(this.$flush(),this._nativeCall("refresh",{index:e,count:1}))}insert(e,t=1){if(e=Math.min(Math.max(0,this.$checkIndex(e)),this.itemCount),!isNumber$1(t)||t<=0)throw new Error(`Invalid insert count ${toValueString(t)}`);this._itemCount=this.itemCount+t,this.$flush();for(let r=e;r<e+t;r++)this._itemMapping.delete(r);for(const r of this._children()){const n=this._cellMapping.get(r);if(n>=e){const e=n+t;this._cellMapping.set(r,e),this._itemMapping.set(e,r)}}this._nativeCall("insert",{index:e,count:t})}remove(e,t=1){if(e=this.$checkIndex(e),!(isNumber$1(t)&&t>=0))throw new Error(`Invalid remove count ${toValueString(t)}`);if(t=Math.min(t,this.itemCount-e),e>=0&&e<this.itemCount&&t>0){this._itemCount=this.itemCount-t,this.$flush();for(let e=this._itemCount;e<this.itemCount+t;e++)this._itemMapping.delete(e);for(const r of this._children()){const n=this._cellMapping.get(r);if(n>=e)if(n<e+t)this._cellMapping.delete(r),this._itemMapping.delete(n);else{const e=n-t;this._cellMapping.set(r,e),this._itemMapping.set(e,r)}}this._nativeCall("remove",{index:e,count:t})}}itemIndex(e){if(!(e instanceof Widget))throw new Error(`${toValueString(e)} is not a widget`);let t=e;for(;t&&t.parent()!==this;)t=t.parent();if(!t)throw new Error(`${toValueString(e)} not a cell or child of a cell`);return this._cellMapping.has(t)?this._cellMapping.get(t):-1}cellByItemIndex(e){if(!isNumber$1(e)||e<0)throw new Error(`${toValueString(e)} is not a valid index`);return this._itemMapping.has(e)?this._itemMapping.get(e):null}set layout(e){e&&this._printPropertyWarning("layout",new Error("CollectionView does not support layouts"))}get layout(){return null}_listen(e,t){"firstVisibleIndexChanged"===e?this._onoff("_scroll",t,triggerChangeFirstVisibleIndex):"lastVisibleIndexChanged"===e?this._onoff("_scroll",t,triggerChangeLastVisibleIndex):super._listen(e,t)}_trigger(e,t){if("requestInfo"===e){const e=resolveProperty(this,"cellType",t.index),r=resolveProperty(this,"cellHeight",t.index,e);return{type:encodeCellType(this,e),height:encodeCellHeight(this,r)}}if("createCell"===e){return this.$createCell(t.type).cid}if("updateCell"!==e)return super._trigger(e,t);{const e=tabris._nativeObjectRegistry.find(t.widget);this._cellMapping.has(e)&&this._itemMapping.delete(this._cellMapping.get(e)),this._cellMapping.set(e,t.index),this._itemMapping.set(t.index,e),this.updateCell(e,t.index)}}_initLayout(){}_getXMLAttributes(){return super._getXMLAttributes().concat([["itemCount",this.itemCount],["firstVisibleIndex",this.firstVisibleIndex]])}$checkIndex(e){if(!isNumber$1(e))throw new Error(`${toValueString(e)} is not a valid index`);return e<0?e+this.itemCount:e}$flush(){this._needsReload&&(this._needsReload=!1,this._nativeCall("load",{itemCount:this.itemCount}))}$createCell(e){const t=this.createCell(decodeCellType(this,e));if(!(t instanceof Widget))throw new Error(`Created cell ${toValueString(t)} is not a widget`);if(t._parent)throw new Error(`Created cell ${toValueString(t)} already has a parent`);return t._parent=this,this._addChild(t),t._setParent=(()=>hint(this,"Cannot re-parent collection view cell")),t.dispose=(()=>hint(this,"Cannot dispose of collection view cell")),t}}function resolveProperty(e,t){const r=e[t];return"function"==typeof r?r.apply(null,Array.prototype.slice.call(arguments,2)):r}function encodeCellType(e,t){const r=e._cellTypes||(e._cellTypes=[]);let n=r.indexOf(t);return-1===n&&(n+=r.push(t)),n}function decodeCellType(e,t){return(e._cellTypes||[])[t]||null}function encodeCellHeight(e,t){return"auto"===t?-1:isNumber$1(t)?Math.max(-1,t):void hint(e,"Invalid cell height: "+t)}NativeObject.defineProperties(CollectionView.prototype,{refreshEnabled:{type:types.boolean,default:!1},refreshIndicator:{type:types.boolean,nocache:!0},refreshMessage:{type:types.string,default:""},fastScroll:{type:types.boolean,default:!1},firstVisibleIndex:{type:types.number,readonly:!0,nocache:!0},lastVisibleIndex:{type:types.number,readonly:!0,nocache:!0},columnCount:{type:types.number,default:1},scrollbarVisible:{type:types.boolean,default:!0}}),NativeObject.defineEvents(CollectionView.prototype,{refresh:{native:!0},scroll:{native:!0}}),NativeObject.defineChangeEvents(CollectionView.prototype,["createCell","cellType","cellHeight","itemCount","updateCell"]);const triggerChangeFirstVisibleIndex=createDelegate("firstVisibleIndex"),triggerChangeLastVisibleIndex=createDelegate("lastVisibleIndex");function createDelegate(e){return function(){const t=this,r=t[e];r!==t["_prev:"+e]&&t._triggerChangeEvent(e,r),t["_prev:"+e]=r}}function isNumber$1(e){return"number"==typeof e&&isFinite(e)}const refKey=Symbol();function processResources(e,t,r,n,i){const o=Object.assign({},t),a={};for(const t in e){const s=selectResource(e[t],r,tabris.device,n);if(isInherit(s)){if(!(t in o))throw new Error(`Resource "${t}" resolved to "inherit: true", but "${t}" does not exist in base object`)}else s instanceof Object&&refKey in s?a[t]=s[refKey]:o[t]=i(s)}return Object.assign(o,resolveReferences(o,a))}function isInherit(e){if(!(e instanceof Object)||e.constructor!==Object)return!1;const t=Object.keys(e).map(e=>e.toLowerCase());if(-1===t.indexOf("inherit"))return!1;if(1===t.length&&!0===e.inherit)return!0;throw new Error("Invalid inherit syntax "+JSON.stringify(e))}function resolveReferences(e,t){const r={};for(const n in t){const i=t[n];if(!(i in e))throw i in t?new Error(`"${n}": References can not be nested`):new Error(`"${n}": Can not resolve reference "${i}"`);r[n]=e[i]}return r}function selectResource(e,t,r,n){return isPlatformSelector(e)?selectResource(getValue(e,r.platform),t,r,n):isScaleSelector(e)?selectResource(getNearbyValue(e,r.scaleFactor,t.scaleFactor),t,r,n):isLangSelector(e,t.fallbackLanguage)?selectResource(getLocalValue(e,r.language,t.fallbackLanguage),t,r,n):isReference(e)?{[refKey]:getValue(e,"ref")}:(checkHasNoInvalidKeys(e),n&&n(e),e)}function isReference(e){if(!(e instanceof Object)||e.constructor!==Object)return!1;const t=Object.keys(e).map(e=>e.toLowerCase());if(-1===t.indexOf("ref"))return!1;if(1===t.length&&"string"==typeof e.ref)return!0;throw new Error("Invalid reference syntax "+JSON.stringify(e))}function isPlatformSelector(e){if(!(e instanceof Object))return!1;const t=Object.keys(e).map(e=>e.toLowerCase()),r=-1!==t.indexOf("android"),n=-1!==t.indexOf("ios");if(!r&&!n)return!1;if(r&&n&&2===t.length)return!0;throw new Error("Invalid platform selector "+JSON.stringify(e))}const SCALE_REGEX=/^([0-9]+|[0-9]\.[0-9]+)x$/,SCALE_REGEX_STRICT=/^([1-9]|[1-9]\.[0-9]+)x$/;function isScaleSelector(e){if(!(e instanceof Object))return!1;const t=Object.keys(e).map(e=>e.toLowerCase()),r=t.filter(e=>SCALE_REGEX.test(e));if(0===r.length)return!1;if(t.length===r.length&&!hasDuplicates(t)&&r.every(e=>SCALE_REGEX_STRICT.test(e)))return!0;throw new Error("Invalid scale selector "+JSON.stringify(e))}const SHORT_LANG_REGEX=/^[a-zA-Z][a-zA-Z][a-zA-Z]?$/,LONG_LANG_REGEX=/^[a-zA-Z][a-zA-Z][a-zA-Z]?-[a-zA-Z0-9][-a-zA-Z0-9]+$/,LANG_LIKE_REGEX=/^[a-zA-Z][-a-zA-Z0-9]$/;function isLangKey(e){return SHORT_LANG_REGEX.test(e)||LONG_LANG_REGEX.test(e)}function isLangSelector(e,t){if(!(e instanceof Object))return!1;const r=Object.keys(e).map(e=>e.toLowerCase());if(0===r.filter(e=>LANG_LIKE_REGEX.test(e)).length)return!1;if(!e[t.toLowerCase()]&&!e[t.toLowerCase().split("-")[0]])throw new Error(`Missing entry for fallback language (currently "${t}") `+"in selector "+JSON.stringify(e));const n=r.filter(isLangKey);if(r.length===n.length&&!hasDuplicates(r))return!0;throw new Error("Invalid language selector "+JSON.stringify(e))}const RESERVED=["","small","normal","large","xlarge","horizontal","vertical","landscape","portrait","debug","production","phone","tablet","browser","online","offline","wifi","cell","other","long","notlong","ldrtl","ldltr"],INVALID=[/^mcc[0-9]/,/^[a-z0-9]+dpi$/,/^!/,/[*:._$@#]/];function checkHasNoInvalidKeys(e){e instanceof Object&&e.constructor===Object&&Object.keys(e).forEach(e=>{if("string"==typeof e&&-1!==RESERVED.indexOf(e.toLowerCase().trim()))throw new Error(`Resource uses reserved property name "${e}".`);INVALID.forEach(t=>{if(t.test(e))throw new Error(`Resource uses reserved property name "${e}".`)})})}function getValue(e,t){const r=t.toLowerCase();for(const t in e)if(t.toLowerCase()===r)return e[t]}function getNearbyValue(e,t,r){const n=Object.keys(e).map(t=>[parseFloat(t),e[t]]).sort((e,t)=>e[0]-t[0]),i=n.length-1;for(let e=0;e<i;e++){const i=n[e],o=n[e+1];if(t>=i[0]&&t<o[0])return"lower"===r?i[1]:"higher"===r?o[1]:t-i[0]<o[0]-t?i[1]:o[1]}return n[i][1]}function getLocalValue(e,t,r){const n={};return Object.keys(e).forEach(t=>n[t.toLowerCase()]=e[t]),n[t.toLowerCase()]||n[t.toLowerCase().split("-")[0]]||n[r.toLowerCase()]||n[r.toLowerCase().split("-")[0]]}function hasDuplicates(e){for(let t=0;t<e.length;t++)if(-1!==e.indexOf(e[t],t+1))return!0;return!1}class ResourceBuilder{constructor(e){validateOptions(e),this.validator=e.validator||null,this.type=e.type||null,this.converter=e.converter||null,Object.freeze(this)}from(e,t){const r=2===arguments.length,n=r?e:{},i=r?t:e,o={},a={};Object.keys(i).forEach(e=>{CONFIG_KEYS[e]?o[e.slice(1)]=i[e]:"$schema"!==e&&(a[e]=i[e])});const s=Object.assign({data:a,base:n,config:o},this);return new Resources(s)}}const CONFIG_KEYS={$scaleFactor:!0,$fallbackLanguage:!0};function validateOptions(e){if(checkType(e,Object,{name:"parameter 1"}),!(e.converter||e.type||e.validator))throw new Error("At least one option required")}const RESOURCE_REGEX=/^[a-z][a-zA-Z][a-zA-Z0-9]+$/,SCALE_FACTOR=["nearest","lower","higher"],CONFIG_DEFAULTS={scaleFactor:SCALE_FACTOR[1],fallbackLanguage:"en"},ALLOWED_OPTIONS=["data","config","base","converter","type","validator"];class Resources{static build(e){if(1!==arguments.length)throw new Error(`Expected 1 parameter, got ${arguments.length}`);return new ResourceBuilder(e)}constructor(e){validateArguments(arguments);const t=wrap(this,e.type);return Object.assign(t,processResources(e.data,e.base||{},Object.assign({},CONFIG_DEFAULTS,e.config),createRawTypeCheck(e.validator,e.type),e.converter||(e=>e)))}}function validateArguments(e){if(1!==e.length)throw new Error(`Expected 1 parameter, got ${e.length}`);const t=e[0];if(checkType(t,Object,{name:"parameter 1"}),t.data instanceof Object||checkType(t.data,Object,{name:'option "data"'}),checkType(t.converter,Function,{name:'option "converter"',nullable:!0}),"type"in t&&null!=t.type&&!(t.type instanceof Function&&t.type.prototype))throw new Error(`Expected option "type" to be a constructor, got ${typeof t.type}`);checkType(t.base,Object,{name:'option "base"',nullable:!0}),Object.keys(t).forEach(e=>{if(-1===ALLOWED_OPTIONS.indexOf(e))throw new Error(`Unknown option "${e}"`)}),validateResourceNames(Object.keys(t.data)),validateResourceNames(Object.keys(t.base||{})),validateConfig(t.config)}function validateResourceNames(e){for(const t of e)if("$"!==t&&!RESOURCE_REGEX.test(t))throw new Error(`Invalid resource name ${t}`)}function validateConfig(e){if(void 0!==e){checkType(e,Object,{name:'option "config"'});for(const t of Object.keys(e))if(!(t in CONFIG_DEFAULTS))throw new Error(`Unknown configuration key "${t}"`);if("scaleFactor"in e&&-1===SCALE_FACTOR.indexOf(e.scaleFactor))throw new Error(`Invalid scaleFactor "${e.scaleFactor}"`)}}function wrap(e,t){return new Proxy(e,{set:(e,r,n)=>(t&&checkType(n,t,{name:"data",nullable:!0}),e[r]=n,!0)})}function createRawTypeCheck(e,t){const r=t?t.name:"resource";return t=>{if(!isInherit(t)&&e&&!e(t)){const e="string"==typeof t?t:JSON.stringify(t);throw new Error(`data entry "${e}" is not a valid selector or raw ${r} type`)}}}const COLOR_OPTIONS={type:Color,converter:Color.from,validator:Color.isValidColorValue};class ColorResources extends Resources{static from(){const e=Resources.build(COLOR_OPTIONS);return e.from.apply(e,arguments)}constructor(e){if(1!==arguments.length)throw new Error(`Expected 1 parameter, got ${arguments.length}`);checkType(e,Object,{name:"parameter 1"}),super(Object.assign({},COLOR_OPTIONS,e))}}const Align={top:"top",centerY:"centerY",baseline:"baseline",bottom:"bottom",stretchY:"stretchY"},zero$1=new Percent(0);class RowLayout extends Layout{static get default(){return this._default||Object.defineProperty(this,"_default",{enumerable:!1,writable:!0,configurable:!0,value:new RowLayout}),this._default}constructor(e={},t){super({},t);const r=Align[e.alignment]||Align.top;Object.defineProperties(this,{_spacing:{enumerable:!1,writable:!1,value:"spacing"in e?types.number.convert(e.spacing):0},_alignment:{enumerable:!1,writable:!1,value:r},_layoutDataVertical:{enumerable:!1,writable:!1,value:LayoutData.from({top:r===Align.top||r===Align.stretchY?0:"auto",bottom:r===Align.bottom||r===Align.stretchY?0:"auto",centerY:r===Align.centerY?0:"auto",baseline:r===Align.baseline?Constraint.prev:"auto"})}})}get spacing(){return this._spacing}get alignment(){return this._alignment}_getLayoutData(e){const t=e.layoutData;return["left","top","right","bottom"].filter(e=>!isValidConstraint(t[e])).forEach(t=>layoutWarn(e,t,'RowLayout only supports "auto" and numeric offset.')),["centerX"].filter(e=>"auto"!==t[e]).forEach(t=>layoutWarn(e,t,'StackLayout only supports "auto".')),"auto"===t.centerY||"auto"===t.top&&"auto"===t.bottom&&"auto"===t.baseline?"auto"===t.baseline||"auto"===t.top&&"auto"===t.bottom||warn("Inconsistent layoutData: baseline overrides top and bottom.\nTarget: "+getPath(e)):warn("Inconsistent layoutData: centerY overrides top, bottom and baseline.\nTarget: "+getPath(e)),"auto"!==t.top&&"auto"!==t.bottom&&"auto"!==t.height&&warn("Inconsistent layoutData: left and right are set, ignore width.\nTarget: "+getPath(e)),t}_renderLayoutData(e,t){const r=this._findStretchIndex(t);let n=!0;for(let i=0;i<e.length;i++){const o=Object.assign({},this._layoutDataVertical);this._layoutY(o,t,i),this._applyWidth(t[i],o),n&&this._applyLeft(o,t,i),i===r&&(n=!1,o.width="auto"),n||this._applyRight(o,t,i),e[i]._nativeSet("layoutData",this._resolveAttributes(o,e[i]))}}_layoutY(e,t,r){const n=t[r];"auto"!==n.top||"auto"!==n.bottom||"auto"!==n.centerY||"auto"!==n.baseline?"auto"!==n.centerY?Object.assign(e,{top:"auto",bottom:"auto",baseline:"auto",centerY:n.centerY}):"auto"!==n.baseline?Object.assign(e,{top:"auto",bottom:"auto",baseline:n.baseline}):Object.assign(e,{top:"auto"!==n.top?new Constraint(zero$1,n.top.offset):"auto",bottom:"auto"!==n.bottom?new Constraint(zero$1,n.bottom.offset):"auto",centerY:"auto",baseline:"auto"}):0===r&&"auto"!==e.baseline&&(e.baseline="auto",e.top=0),"auto"===n.height||"auto"!==n.top&&"auto"!==n.bottom||(e.height=n.height,this._alignment===Align.stretchY&&(e.bottom="auto"))}_applyLeft(e,t,r){const n=t[r].left,i=t[r-1],o=i?i.right:"auto",a=i?LayoutData.prev:zero$1;e.left=new Constraint(a,"auto"===n&&"auto"===o?i?this._spacing:0:maxPositive("auto"!==n?n.offset:0,"auto"!==o?o.offset:0))}_applyRight(e,t,r){const n=t[r].right,i=t[r+1],o=i?i.left:"auto",a=i?LayoutData.next:zero$1;e.right=new Constraint(a,"auto"===n&&"auto"===o?i?this._spacing:0:maxPositive("auto"!==n?n.offset:0,"auto"!==o?o.offset:0))}_applyWidth(e,t){"auto"!==e.width&&(t.width=e.width)}_findStretchIndex(e){for(let t=0;t<e.length;t++){const{left:r,width:n,right:i}=e[t];if("auto"!==r&&"auto"===n&&"auto"!==i)return t}return-1}}class Row extends Composite{constructor(e){super(e)}get spacing(){return this._layout.spacing}set spacing(e){}get alignment(){return this._layout.alignment}set alignment(e){}_initLayout(e={}){let t=e.layout||RowLayout.default;("spacing"in e||"alignment"in e)&&(t=new RowLayout({spacing:"spacing"in e?e.spacing:t.spacing,alignment:"alignment"in e?e.alignment:t.alignment})),this._checkLayout(t),Object.defineProperty(this,"_layout",{enumerable:!1,writable:!1,value:t}),this._layout.add(this)}_checkLayout(e){if(!(e instanceof RowLayout))throw new Error(`${toValueString(e)} is not an instance of RowLayout`)}_getXMLAttributes(){const e=super._getXMLAttributes();return e.push(["alignment",this.alignment]),e}}const Align$1={left:"left",centerX:"centerX",right:"right",stretchX:"stretchX"},zero$2=new Percent(0);class StackLayout extends Layout{static get default(){return this._default||Object.defineProperty(this,"_default",{enumerable:!1,writable:!0,configurable:!0,value:new StackLayout}),this._default}constructor(e={},t){super({},t);const r=Align$1[e.alignment]||Align$1.left;Object.defineProperties(this,{_spacing:{enumerable:!1,writable:!1,value:"spacing"in e?types.number.convert(e.spacing):0},_alignment:{enumerable:!1,writable:!1,value:r},_layoutDataHorizontal:{enumerable:!1,writable:!1,value:LayoutData.from({left:r===Align$1.left||r===Align$1.stretchX?0:"auto",right:r===Align$1.right||r===Align$1.stretchX?0:"auto",centerX:r===Align$1.centerX?0:"auto"})}})}get spacing(){return this._spacing}get alignment(){return this._alignment}_getLayoutData(e){const t=e.layoutData;return["left","top","right","bottom"].filter(e=>!isValidConstraint(t[e])).forEach(t=>layoutWarn(e,t,'StackLayout only supports "auto" and numeric offset.')),["centerY","baseline"].filter(e=>"auto"!==t[e]).forEach(t=>layoutWarn(e,t,'StackLayout only supports "auto".')),"auto"===t.centerX||"auto"===t.left&&"auto"===t.right||warn("Inconsistent layoutData: centerX overrides left and right.\nTarget: "+getPath(e)),"auto"!==t.left&&"auto"!==t.right&&"auto"!==t.width&&warn("Inconsistent layoutData: left and right are set, ignore width.\nTarget: "+getPath(e)),t}_renderLayoutData(e,t){const r=this._findStretchIndex(t);let n=!0;for(let i=0;i<e.length;i++){const o=Object.assign({},this._layoutDataHorizontal);this._layoutX(t[i],o),this._applyHeight(t[i],o),n&&this._applyTop(o,t,i),i===r&&(n=!1,o.height="auto"),n||this._applyBottom(o,t,i),e[i]._nativeSet("layoutData",this._resolveAttributes(o,e[i]))}}_layoutX(e,t){"auto"===e.left&&"auto"===e.right&&"auto"===e.centerX||("auto"!==e.centerX?Object.assign(t,{left:"auto",right:"auto",centerX:e.centerX}):Object.assign(t,{left:"auto"!==e.left?new Constraint(zero$2,e.left.offset):"auto",right:"auto"!==e.right?new Constraint(zero$2,e.right.offset):"auto",centerX:"auto"})),"auto"===e.width||"auto"!==e.left&&"auto"!==e.right||(t.width=e.width,this._alignment===Align$1.stretchX&&(t.right="auto"))}_applyTop(e,t,r){const n=t[r].top,i=t[r-1],o=i?i.bottom:"auto",a=i?LayoutData.prev:zero$2;e.top=new Constraint(a,"auto"===n&&"auto"===o?i?this._spacing:0:maxPositive("auto"!==n?n.offset:0,"auto"!==o?o.offset:0))}_applyBottom(e,t,r){const n=t[r].bottom,i=t[r+1],o=i?i.top:"auto",a=i?LayoutData.next:zero$2;e.bottom=new Constraint(a,"auto"===n&&"auto"===o?i?this._spacing:0:maxPositive("auto"!==n?n.offset:0,"auto"!==o?o.offset:0))}_applyHeight(e,t){"auto"!==e.height&&(t.height=e.height)}_findStretchIndex(e){for(let t=0;t<e.length;t++){const{top:r,height:n,bottom:i}=e[t];if("auto"!==r&&"auto"===n&&"auto"!==i)return t}return-1}}class Stack extends Composite{constructor(e){super(e)}get spacing(){return this._layout.spacing}set spacing(e){}get alignment(){return this._layout.alignment}set alignment(e){}_initLayout(e={}){let t=e.layout||StackLayout.default;("spacing"in e||"alignment"in e)&&(t=new StackLayout({spacing:"spacing"in e?e.spacing:t.spacing,alignment:"alignment"in e?e.alignment:t.alignment})),this._checkLayout(t),Object.defineProperty(this,"_layout",{enumerable:!1,writable:!1,value:t}),this._layout.add(this)}_checkLayout(e){if(!(e instanceof StackLayout))throw new Error(`${toValueString(e)} is not an instance of StackLayout`)}_getXMLAttributes(){const e=super._getXMLAttributes();return e.push(["alignment",this.alignment]),e}}class CameraView extends Widget{get _nativeType(){return"tabris.CameraView"}}NativeObject.defineProperties(CameraView.prototype,{camera:{type:Camera,default:null,nullable:!0},scaleMode:{type:"string",choice:["fit","fill"],default:"fit"}});class CryptoKey{constructor(e,t){if(!(e instanceof _CryptoKey))throw new TypeError("Illegal constructor");setNativeObject(this,e),Object.assign(this,t),Object.freeze(this)}}class _CryptoKey extends NativeObject{constructor(e,t){super(e?{parent:e.cid,type:t}:{})}get _nativeType(){return"tabris.CryptoKey"}import(e,t,r,n,i){return __awaiter(this,void 0,void 0,function*(){return new Promise$1((o,a)=>this._nativeCall("import",{format:e,keyData:getBuffer(t),algorithm:r,extractable:n,keyUsages:i,onSuccess:o,onError:wrapErrorCb(a)}))})}derive(e,t,r,n,i,o,a){return __awaiter(this,void 0,void 0,function*(){return new Promise$1((s,l)=>{if("string"==typeof e)throw new TypeError(e+" not supported");if("ECDH"===e.name)return this._nativeCall("derive",{algorithm:Object.assign(Object.assign({},e),{public:getCid(e.public)}),baseKey:getCid(t),derivedKeyAlgorithm:r,extractable:n,keyUsages:i,authPromptTitle:o,authPromptMessage:a,onSuccess:s,onError:wrapErrorCb(l)});if("HKDF"===e.name)return this._nativeCall("derive",{algorithm:Object.assign(Object.assign({},e),{salt:getBuffer(e.salt),info:getBuffer(e.info)}),baseKey:getCid(t),derivedKeyAlgorithm:r,extractable:n,keyUsages:i,authPromptTitle:o,authPromptMessage:a,onSuccess:s,onError:wrapErrorCb(l)});throw new TypeError("Algorithm not supported")})})}generate(e,t,r,n){return __awaiter(this,void 0,void 0,function*(){return new Promise$1((i,o)=>this._nativeCall("generate",{algorithm:e,extractable:t,keyUsages:r,usageRequiresAuth:n,onSuccess:i,onError:wrapErrorCb(o)}))})}}function wrapErrorCb(e){return t=>e(new Error(String(t)))}NativeObject.defineProperties(_CryptoKey.prototype,{parent:{type:"string",const:!0,nocache:!0},type:{type:"string",const:!0,nocache:!0,choice:["public","private"]}});class Crypto{constructor(){Object.defineProperties(this,{_nativeObject:{enumerable:!1,writable:!1,value:NativeCrypto.getInstance()},subtle:{enumerable:!1,writable:!1,value:new SubtleCrypto}})}getRandomValues(e){if(0===arguments.length)throw new Error("Not enough arguments to Crypto.getRandomValues");if(!ArrayBuffer.isView(e)||e instanceof Float32Array||e instanceof Float64Array)throw new Error(`Argument ${toValueString(e)} is not an accepted array type`);return this._nativeObject.getRandomValues(e)}}const validAlgorithms=new Set(["SHA-1","SHA-256","SHA-384","SHA-512"]);class SubtleCrypto{constructor(){Object.defineProperty(this,"_nativeObject",{enumerable:!1,writable:!1,value:NativeCrypto.getInstance()})}digest(e,t){return __awaiter(this,arguments,void 0,function*(){return arguments.length<2?Promise$1.reject(new TypeError("Not enough arguments to SubtleCrypto.digest")):validAlgorithms.has(e)?getBuffer(t)?new Promise$1((r,n)=>this._nativeObject.subtleDigest({algorithm:e,data:t,resolve:r,reject:n})):Promise$1.reject(new TypeError(`Argument ${toValueString(t)} is not an accepted array type`)):Promise$1.reject(new TypeError(`Algorithm: Unrecognized name ${e}`))})}importKey(e,t,r,n,i){return __awaiter(this,arguments,void 0,function*(){if(5!==arguments.length)throw new TypeError(`Expected 5 arguments, got ${arguments.length}`);allowOnlyValues(e,["spki","pkcs8","raw"],"format"),checkType(getBuffer(t),ArrayBuffer,{name:"keyData"}),"string"==typeof r?allowOnlyValues(r,["AES-GCM","HKDF"],"algorithm"):(checkType(r,Object,{name:"algorithm"}),allowOnlyValues(r.name,["ECDH","ECDSA","AES-GCM"],"algorithm.name"),"ECDH"===r.name||"ECDSA"===r.name?(allowOnlyKeys(r,["name","namedCurve"]),allowOnlyValues(r.namedCurve,["P-256"],"algorithm.namedCurve")):allowOnlyKeys(r,["name"])),checkType(n,Boolean,{name:"extractable"}),checkType(i,Array,{name:"keyUsages"});const o=new _CryptoKey,a=Object.keys(r),s=1===a.length&&"name"===a[0]?r.name:r;return yield o.import(e,t,s,n,i),new CryptoKey(o,{algorithm:s,extractable:n,usages:Object.freeze(i.concat())})})}deriveBits(e,t,r,n={}){return __awaiter(this,arguments,void 0,function*(){if(arguments.length<3)throw new TypeError(`Expected at least 3 arguments, got ${arguments.length}`);checkDeriveAlgorithm(e),checkType(t,CryptoKey,{name:"baseKey"}),checkType(r,Number,{name:"length"}),checkAuthPromptOptions(n);const i=new _CryptoKey;try{return yield i.derive(e,t,{length:r,name:"AES-GCM"},!0,[],n.authPromptTitle,n.authPromptMessage),new Promise$1((e,t)=>this._nativeObject.subtleExportKey("raw",i,e,t))}finally{i.dispose()}})}deriveKey(e,t,r,n,i,o={}){return __awaiter(this,arguments,void 0,function*(){if(arguments.length<5)throw new TypeError(`Expected at least 5 arguments, got ${arguments.length}`);checkDeriveAlgorithm(e),allowOnlyKeys(r,["name","length"]),allowOnlyValues(r.name,["AES-GCM"],"derivedKeyAlgorithm.name"),checkType(r.length,Number,{name:"derivedKeyAlgorithm.length"}),checkType(t,CryptoKey,{name:"baseKey"}),checkType(n,Boolean,{name:"extractable"}),checkType(i,Array,{name:"keyUsages"}),checkAuthPromptOptions(o);const a=new _CryptoKey;return yield a.derive(e,t,r,n,i,o.authPromptTitle,o.authPromptMessage),new CryptoKey(a,{algorithm:e,extractable:n,type:"secret",usages:Object.freeze(i.concat())})})}decrypt(e,t,r){return __awaiter(this,arguments,void 0,function*(){if(3!==arguments.length)throw new TypeError(`Expected 3 arguments, got ${arguments.length}`);return allowOnlyKeys(e,["name","iv","tagLength"]),allowOnlyValues(e.name,["AES-GCM"],"algorithm.name"),checkType(e.tagLength,Number,{name:"algorithm.tagLength",nullable:!0}),checkType(getBuffer(e.iv),ArrayBuffer,{name:"algorithm.iv"}),checkType(t,CryptoKey,{name:"key"}),checkType(getBuffer(r),ArrayBuffer,{name:"data"}),new Promise$1((n,i)=>this._nativeObject.subtleDecrypt(e,t,r,n,i))})}encrypt(e,t,r){return __awaiter(this,arguments,void 0,function*(){if(3!==arguments.length)throw new TypeError(`Expected 3 arguments, got ${arguments.length}`);return allowOnlyKeys(e,["name","iv","tagLength"]),allowOnlyValues(e.name,["AES-GCM"],"algorithm.name"),checkType(e.tagLength,Number,{name:"algorithm.tagLength",nullable:!0}),checkType(getBuffer(e.iv),ArrayBuffer,{name:"algorithm.iv"}),checkType(t,CryptoKey,{name:"key"}),checkType(getBuffer(r),ArrayBuffer,{name:"data"}),new Promise$1((n,i)=>this._nativeObject.subtleEncrypt(e,t,r,n,i))})}exportKey(e,t){return __awaiter(this,arguments,void 0,function*(){if(2!==arguments.length)throw new TypeError(`Expected 2 arguments, got ${arguments.length}`);return allowOnlyValues(e,["raw","spki"],"format"),checkType(t,CryptoKey,{name:"key"}),new Promise$1((r,n)=>this._nativeObject.subtleExportKey(e,t,r,n))})}generateKey(e,t,r,n){return __awaiter(this,arguments,void 0,function*(){if(arguments.length<3)throw new TypeError(`Expected at least 3 arguments, got ${arguments.length}`);if(allowOnlyKeys(e,["name","namedCurve"]),allowOnlyValues(e.name,["ECDH","ECDSA"],"algorithm.name"),allowOnlyValues(e.namedCurve,["P-256"],"algorithm.namedCurve"),checkType(t,Boolean,{name:"extractable"}),checkType(r,Array,{name:"keyUsages"}),null!=n&&(allowOnlyKeys(n,["usageRequiresAuth"]),"usageRequiresAuth"in n&&checkType(n.usageRequiresAuth,Boolean,{name:"options.usageRequiresAuth"}),n.usageRequiresAuth&&(t||!e.name.startsWith("EC"))))throw new TypeError("options.usageRequiresAuth is only supported for non-extractable EC keys");const i=null===n||void 0===n?void 0:n.usageRequiresAuth,o=new _CryptoKey;yield o.generate(e,t,r,i);const a=new _CryptoKey(o,"private"),s=new _CryptoKey(o,"public");return{privateKey:new CryptoKey(a,{algorithm:e,extractable:t}),publicKey:new CryptoKey(s,{algorithm:e,extractable:t})}})}sign(e,t,r,n={}){return __awaiter(this,arguments,void 0,function*(){if(arguments.length<3)throw new TypeError(`Expected at least 3 arguments, got ${arguments.length}`);return allowOnlyKeys(e,["name","hash"]),allowOnlyValues(e.name,["ECDSAinDERFormat"],"algorithm.name"),allowOnlyValues(e.hash,["SHA-256"],"algorithm.hash"),checkType(t,CryptoKey,{name:"key"}),checkType(e.name,String,{name:"algorithm.name"}),checkType(e.hash,String,{name:"algorithm.hash"}),checkType(getBuffer(r),ArrayBuffer,{name:"data"}),checkAuthPromptOptions(n),new Promise$1((i,o)=>this._nativeObject.subtleSign(e,t,r,n.authPromptTitle,n.authPromptMessage,i,o))})}verify(e,t,r,n){return __awaiter(this,arguments,void 0,function*(){if(4!==arguments.length)throw new TypeError(`Expected 4 arguments, got ${arguments.length}`);return allowOnlyKeys(e,["name","hash"]),allowOnlyValues(e.name,["ECDSAinDERFormat"],"algorithm.name"),allowOnlyValues(e.hash,["SHA-256"],"algorithm.hash"),checkType(t,CryptoKey,{name:"key"}),checkType(getBuffer(r),ArrayBuffer,{name:"signature"}),checkType(getBuffer(n),ArrayBuffer,{name:"data"}),new Promise$1((i,o)=>this._nativeObject.subtleVerify(e,t,r,n,i,o))})}}class NativeCrypto extends NativeObject{static getInstance(){return this.instance||(this.instance=new NativeCrypto),this.instance}get _nativeType(){return"tabris.Crypto"}getRandomValues(e){const t=e.byteLength,r=new Uint8Array(this._nativeCall("getRandomValues",{byteLength:t}));if(r.byteLength!==t)throw new Error("Not enough random bytes available");return new Uint8Array(e.buffer).set(r),e}subtleDigest(e){this._nativeCall("subtleDigest",{algorithm:e.algorithm,data:ArrayBuffer.isView(e.data)?e.data.buffer:e.data,onSuccess:t=>{if(!(t instanceof ArrayBuffer)||0===t.byteLength)throw new TypeError("Internal Type Error: result is not valid ArrayBuffer");e.resolve(t)},onError:t=>e.reject(new Error(String(t)))})}subtleDecrypt(e,t,r,n,i){const{name:o,iv:a,tagLength:s}=e;this._nativeCall("subtleDecrypt",{algorithm:{name:o,iv:getBuffer(a),tagLength:isNaN(s)?128:s},key:getNativeObject(t).cid,data:ArrayBuffer.isView(r)?r.buffer:r,onSuccess:n,onError:e=>i(new Error(String(e)))})}subtleExportKey(e,t,r,n){this._nativeCall("subtleExportKey",{format:e,key:getCid(t),onSuccess:r,onError:e=>n(new Error(String(e)))})}subtleEncrypt(e,t,r,n,i){const{name:o,iv:a,tagLength:s}=e;this._nativeCall("subtleEncrypt",{algorithm:{name:o,iv:getBuffer(a),tagLength:isNaN(s)?128:s},key:getCid(t),data:getBuffer(r),onSuccess:n,onError:e=>i(new Error(String(e)))})}subtleSign(e,t,r,n,i,o,a){this._nativeCall("subtleSign",{algorithm:e,key:getCid(t),data:getBuffer(r),authPromptTitle:n,authPromptMessage:i,onSuccess:o,onError:e=>a(new Error(String(e)))})}subtleVerify(e,t,r,n,i,o){this._nativeCall("subtleVerify",{algorithm:e,key:getCid(t),signature:getBuffer(r),data:getBuffer(n),onSuccess:i,onError:e=>o(new Error(String(e)))})}}function checkAuthPromptOptions(e){"authPromptTitle"in e&&checkType(e.authPromptTitle,String,{name:"options.authPromptTitle"}),"authPromptMessage"in e&&checkType(e.authPromptMessage,String,{name:"options.authPromptMessage"})}function checkDeriveAlgorithm(e){if("HKDF"!==e){if("AES-GCM"===e)throw new TypeError("AES-GCM not supported for this function");allowOnlyKeys(e,["name","namedCurve","public","hash","salt","info"]),allowOnlyValues(e.name,["ECDH","HKDF"],"algorithm.name"),"ECDH"===e.name?(allowOnlyValues(e.namedCurve,["P-256"],"algorithm.namedCurve"),checkType(e.public,CryptoKey,{name:"algorithm.public"})):"HKDF"===e.name&&(checkType(e.hash,String,{name:"algorithm.hash"}),checkType(getBuffer(e.salt),ArrayBuffer,{name:"algorithm.salt"}),checkType(getBuffer(e.info),ArrayBuffer,{name:"algorithm.info"}))}}class Drawer extends ContentView{get _nativeType(){return"tabris.Drawer"}_nativeCreate(e){if(!0!==e)throw new Error("Drawer can not be created");super._nativeCreate({[creationAllowed]:!0})}_setParent(){throw new Error("Parent of Drawer can not be changed")}_listen(e,t){"open"===e||"close"===e?this._nativeListen(e,t):super._listen(e,t)}_dispose(){throw new Error("Drawer can not be disposed")}open(){return this._nativeCall("open",{}),this}close(){return this._nativeCall("close",{}),this}}function create$a(){return new Drawer(!0)}NativeObject.defineProperties(Drawer.prototype,{enabled:{type:"boolean",default:!1}}),NativeObject.defineEvents(Drawer.prototype,{open:{native:!0},close:{native:!0}});class DateDialog extends Popup{static open(e){let t;return(t=e instanceof DateDialog?e:e instanceof Date?new DateDialog({date:e}):new DateDialog).open()}constructor(e){super(e),this._nativeListen("close",!0),this._nativeListen("select",!0)}get _nativeType(){return"tabris.DateDialog"}_trigger(e,t){return"select"===e?(t.date=new Date(t.date),super._trigger("select",t),this._handleClose(t)):super._trigger(e,t)}}NativeObject.defineProperties(DateDialog.prototype,{date:{type:types.Date,default:null},maxDate:{type:types.Date,default:null},minDate:{type:types.Date,default:null}}),NativeObject.defineEvents(DateDialog.prototype,{select:{native:!0},close:{native:!0}});class FormData{getAll(e){if(0===arguments.length)throw new TypeError("FormData.getAll requires at least 1 argument, but only 0 were passed");const t=data$1(this)[e];return t?t.concat():[]}get(e){if(0===arguments.length)throw new TypeError("FormData.get requires at least 1 argument, but only 0 were passed");const t=data$1(this)[e];return t?t[0]:null}has(e){if(0===arguments.length)throw new TypeError("FormData.has requires at least 1 argument, but only 0 were passed");return!!data$1(this)[e]}append(e,t,r){if(arguments.length<2)throw new TypeError(arguments.length+" is not a valid argument count for any overload of FormData.append.");if(3===arguments.length&&!(t instanceof Blob))throw new TypeError("Argument 2 of FormData.append is not an object.");const n=data$1(this)[e]||[];n.push(normalize(t,r)),data$1(this)[e]=n}set(e,t,r){if(arguments.length<2)throw new TypeError(arguments.length+" is not a valid argument count for any overload of FormData.set.");if(3===arguments.length&&!(t instanceof Blob))throw new TypeError("Argument 2 of FormData.set is not an object.");data$1(this)[e]=[normalize(t,r)]}delete(e){if(0===arguments.length)throw new TypeError("0 is not a valid argument count for any overload of FormData.delete.");delete data$1(this)[e]}keys(){const e=this.entries();return{next:()=>{const{done:t,value:r}=e.next();return{done:t,value:t?void 0:r[0]}},[Symbol.iterator](){return this}}}values(){const e=this.entries();return{next:()=>{const{done:t,value:r}=e.next();return{done:t,value:t?void 0:r[1]}},[Symbol.iterator](){return this}}}[Symbol.iterator](){return this.entries()}entries(){const e=Object.keys(data$1(this)).sort();let t=0,r=0;const n=()=>{if(t<e.length){const i=data$1(this)[e[t]];return i&&r<i.length?{done:!1,value:[e[t],i[r++]]}:(t++,r=0,n())}return{done:!0,value:void 0}};return{next:n,[Symbol.iterator](){return this}}}}function formDataToBlob(e){const t="----tabrisformdataboundary-"+Math.round(1e8*Math.random())+"-yradnuobatadmrofsirbat",r=[];for(const[n,i]of e)r.push(`--${t}\r\n`),i instanceof File?(r.push(`Content-Disposition: form-data; name="${n}"; filename="${i.name}"\r\n`),r.push(`Content-Type: ${i.type||"application/octet-stream"}\r\n\r\n`),r.push(i),r.push("\r\n")):r.push(`Content-Disposition: form-data; name="${n}"\r\n\r\n${i}\r\n`);return r.push(`--${t}--`),new Blob(r,{type:"multipart/form-data; boundary="+t})}function data$1(e){return e[data]||(e[data]={}),e[data]}function normalize(e,t){return e instanceof File&&void 0===t?e:e instanceof Blob?new File([e],void 0===t?"blob":t):e+""}FormData.prototype[Symbol.toStringTag]="FormData";const FONT_OPTIONS={type:Font,converter:Font.from,validator:Font.isValidFontValue};class FontResources extends Resources{static from(){const e=Resources.build(FONT_OPTIONS);return e.from.apply(e,arguments)}constructor(e){if(1!==arguments.length)throw new Error(`Expected 1 parameter, got ${arguments.length}`);checkType(e,Object,{name:"parameter 1"}),super(Object.assign({},FONT_OPTIONS,e))}}class ImageView extends Widget{get _nativeType(){return"tabris.ImageView"}_beforePropertyChange(e,t){"zoomEnabled"!==e||t?"minZoomLevel"===e&&t>this.zoomLevel?this.zoomLevel=t:"maxZoomLevel"===e&&t<this.zoomLevel&&(this.zoomLevel=t):(this.minZoomLevel=1,this.maxZoomLevel=3,this.zoomLevel=1)}_reorderProperties(e){return-1!==e.indexOf("maxZoomLevel")&&e.unshift(e.splice(e.indexOf("maxZoomLevel"),1)[0]),-1!==e.indexOf("minZoomLevel")&&e.unshift(e.splice(e.indexOf("minZoomLevel"),1)[0]),-1!==e.indexOf("zoomEnabled")&&e.unshift(e.splice(e.indexOf("zoomEnabled"),1)[0]),super._reorderProperties(e)}_getXMLAttributes(){return super._getXMLAttributes().concat([["image",(this.image||{src:""}).src]])}}NativeObject.defineProperties(ImageView.prototype,{image:{type:types.ImageValue,default:null},scaleMode:{type:types.string,choice:["auto","fit","fill","stretch","none"],default:"auto"},tintColor:{type:types.ColorValue,default:"initial"},zoomEnabled:{type:types.boolean,default:!1},zoomLevel:{type:{convert(e,t){if(!t.zoomEnabled&&1!==e)throw new Error("zoomLevel can not be set when zoomEnabled is false");const r=types.number.convert(e);if(r<t.minZoomLevel)throw new Error("zoomLevel can not be smaller than minZoomLevel");if(r>t.maxZoomLevel)throw new Error("zoomLevel can not be larger than maxZoomLevel");return r}},nocache:!0},minZoomLevel:{type:{convert(e,t){if(!t.zoomEnabled&&1!==e)throw new Error("minZoomLevel can not be set when zoomEnabled is false");const r=types.number.convert(e);if(r>t.maxZoomLevel)throw new Error("minZoomLevel can not be larger than maxZoomLevel");return r}},default:1},maxZoomLevel:{type:{convert(e,t){if(!t.zoomEnabled&&3!==e)throw new Error("maxZoomLevel can not be set when zoomEnabled is false");const r=types.number.convert(e);if(r<t.minZoomLevel)throw new Error("maxZoomLevel can not be smaller than minZoomLevel");return r}},default:3}}),NativeObject.defineEvents(ImageView.prototype,{load:{native:!0},zoom:{native:!0,changes:"zoomLevel"},nativeObservable:!1});class InactivityTimer extends NativeObject{constructor(e){super(e),this._nativeListen("timeout",!0)}start(){this._nativeCall("start")}cancel(){this._nativeCall("cancel")}get _nativeType(){return"tabris.InactivityTimer"}}NativeObject.defineProperties(InactivityTimer.prototype,{delay:{type:"natural",default:0}}),NativeObject.defineEvents(InactivityTimer.prototype,{timeout:!0});class SearchAction extends Widget{get _nativeType(){return"tabris.SearchAction"}open(){return this._nativeCall("open",{}),this}_getXMLAttributes(){const e=super._getXMLAttributes().concat([["title",this.title]]);return this.text&&e.push(["text",this.text]),this.message&&e.push(["message",this.message]),e}}NativeObject.defineProperties(SearchAction.prototype,{image:{type:types.ImageValue,default:null},placementPriority:{type:types.string,choice:["low","high","normal"],default:"normal"},title:{type:types.string,default:""},proposals:{type:{convert(e){if(!Array.isArray(e))throw new Error("Not an array");return Object.freeze(e.map(types.string.convert))}},default:Object.freeze([])},text:{type:types.string,nocache:!0},message:{type:types.string,default:""}}),NativeObject.defineEvents(SearchAction.prototype,{input:{native:!0},accept:{native:!0},select:{native:!0}});class NavigationView extends Composite{constructor(e){super(e),this._nativeListen("backNavigation",!0)}get _nativeType(){return"tabris.NavigationView"}_initLayout(){Object.defineProperty(this,"_layout",{enumerable:!1,writable:!1,value:null})}_acceptChild(e){return e instanceof Page||e instanceof Action||e instanceof SearchAction}_addChild(e,t){const r=e instanceof Page&&"number"!=typeof t||t===this.pages().length;r&&this.$triggerDisappear(),super._addChild(e,t),r&&this.$triggerAppear()}_removeChild(e){const t=e instanceof Page&&e===this.pages().last();t&&this.$triggerDisappear(),super._removeChild(e),t&&this.$triggerAppear()}$handleBackNavigation(){this.$pop(this.pages().last())}$pop(e){e&&e.autoDispose?e.dispose():e&&e._setParent(null)}_listen(e,t){"toolbarHeightChanged"===e?this._nativeListen(e,t):super._listen(e,t)}_trigger(e,t){if("backNavigation"===e)this.$handleBackNavigation();else{if("toolbarHeightChanged"!==e)return super._trigger(e,t);this._triggerChangeEvent("toolbarHeight",t.toolbarHeight)}}$triggerAppear(){const e=this.pages().last();e&&e.$trigger("appear")}$triggerDisappear(){const e=this.pages().last();e&&e.$trigger("disappear")}pages(e){return this.children(e).filter(e=>e instanceof Page)}_getXMLAttributes(){const e=super._getXMLAttributes();return this.drawerActionVisible||e.push(["drawerActionVisible","false"]),this.toolbarVisible||e.push(["toolbarVisible","false"]),e}}NativeObject.defineProperties(NavigationView.prototype,{drawerActionVisible:{type:types.boolean,default:!1},toolbarVisible:{type:types.boolean,default:!0},toolbarColor:{type:types.ColorValue,default:null},toolbarHeight:{readonly:!0},titleTextColor:{type:types.ColorValue,default:null},actionColor:{type:types.ColorValue,default:null},actionTextColor:{type:types.ColorValue,default:null},pageAnimation:{type:types.string,choice:["default","none"],default:"default"}}),NativeObject.defineEvents(NavigationView.prototype,{backNavigation:!0});class Page extends Composite{get _nativeType(){return"tabris.Page"}insertBefore(){throw new Error("insertBefore not supported on Page")}insertAfter(){throw new Error("insertAfter not supported on Page")}_setParent(e,t){if(e&&!(e instanceof NavigationView))throw new Error(`Page could not be appended to ${toValueString(e)}`);super._setParent(e,t)}_getXMLAttributes(){return super._getXMLAttributes().concat([["title",this.title]])}}NativeObject.defineProperties(Page.prototype,{image:{type:"ImageValue",default:null},title:{type:"string",default:""},autoDispose:{type:"boolean",default:!0}}),NativeObject.defineEvents(Page.prototype,{appear:!0,disappear:!0});class PdfView extends Widget{get _nativeType(){return"tabris.PdfView"}_getXMLAttributes(){return super._getXMLAttributes().concat([["src",this.src||""]])}set padding(e){"iOS"!==tabris.device.platform&&(super.padding=e)}}NativeObject.defineProperties(PdfView.prototype,{src:{type:{convert(e){if(null!=e&&"string"!=typeof e&&!(e instanceof Blob))throw new Error("Value must be of type string or Blob");return e||null},encode:e=>"string"==typeof e?{type:"uri",uri:e}:e instanceof Blob?{type:"buffer",buffer:getBytes(e)}:null},default:null},zoomEnabled:{type:types.boolean,default:!1},spacing:{type:"dimension",default:0},pageElevation:{type:"natural",default:0},pageBackground:{type:"ColorValue",default:"initial"}}),NativeObject.defineEvents(PdfView.prototype,{load:{native:!0}});class Picker extends Widget{constructor(e){super(pick(e,["style"])),Object.defineProperties(this,{_itemCount:{enumerable:!1,writable:!0,value:0},_itemText:{enumerable:!1,writable:!0,value:()=>""}}),this.set(omit(e,["style"])),tabris.on("flush",this.$flush,this),this.on("dispose",()=>tabris.off("flush",this.$flush,this))}get _nativeType(){return"tabris.Picker"}set itemCount(e){try{const t=this._itemCount;this._itemCount=types.natural.convert(e),this._itemCount!==t&&(Object.defineProperty(this,"$needsUpdateItems",{enumerable:!1,writable:!0,value:!0}),this._triggerChangeEvent("itemCount"))}catch(e){this._printPropertyWarning("itemCount",e)}}get itemCount(){return this._itemCount}set itemText(e){try{if(!(e instanceof Function))throw new Error("Not a Function");const t=this._itemText;this._itemText=e,this._itemText!==t&&(Object.defineProperty(this,"$needsUpdateItems",{enumerable:!1,writable:!0,value:!0}),this._triggerChangeEvent("itemText"))}catch(e){this._printPropertyWarning("itemText",e)}}get itemText(){return this._itemText}set selectionIndex(e){try{const t=this.$newSelectionIndex;this.$newSelectionIndex=types.integer.convert(e),this.$newSelectionIndex!==t&&this._triggerChangeEvent("selectionIndex")}catch(e){this._printPropertyWarning("selectionIndex",e)}}get selectionIndex(){return this.$newSelectionIndex>=-1?this.$newSelectionIndex:this._nativeGet("selectionIndex")}_getXMLAttributes(){return super._getXMLAttributes().concat([["itemCount",this.itemCount],["selectionIndex",this.selectionIndex]])}$flush(){if(this.$needsUpdateItems){const e=new Array(this.itemCount);for(let t=0;t<e.length;t++)e[t]=this.itemText(t)+"";this._nativeSet("items",e),tabris._nativeBridge.flush(),this.$needsUpdateItems=!1}this.$newSelectionIndex>=-1&&(this._nativeSet("selectionIndex",this.$newSelectionIndex),this._triggerChangeEvent("selectionIndex",this.$newSelectionIndex),tabris._nativeBridge.flush(),this.$newSelectionIndex=void 0)}_trigger(e,t){return"select"===e?super._trigger("select",{index:t.selectionIndex}):super._trigger(e,t)}}NativeObject.defineProperties(Picker.prototype,{style:{type:types.string,choice:["default","outline","fill","underline","none"],const:!0,default:"default"},message:{type:types.string,default:""},floatMessage:{type:types.boolean,default:!0},borderColor:{type:types.ColorValue,default:null},textColor:{type:types.ColorValue,default:null},font:{type:types.FontValue,default:null}}),NativeObject.defineChangeEvents(Picker.prototype,["selectionIndex","itemText","itemCount"]),NativeObject.defineEvents(Picker.prototype,{select:{native:!0,changes:"selectionIndex",changeValue:e=>"index"in e?e.index:e.selectionIndex}});class Pbkdf2 extends NativeObject{constructor(e){super(e),this._nativeListen("done",!0)}start(e){this._nativeCall("start",e)}pbkdf2Sync(e){return this._nativeCall("pbkdf2Sync",e)}get _nativeType(){return"tabris.pkcs5.Pbkdf2"}}class Pkcs5{pbkdf2(e,t,r,n){return new Promise$1(i=>{if(arguments.length<4)throw new Error("Not enough arguments to pbkdf2");validatePbkdf2Arguments(e,t,r,n);const o=new Pbkdf2;o.on("done",e=>{o.dispose(),i(e.key)}),o.start({password:e,salt:toArray(t),iterationCount:r,keySize:n})})}pbkdf2Sync(e,t,r,n){if(arguments.length<4)throw new Error("Not enough arguments to pbkdf2Sync");validatePbkdf2Arguments(e,t,r,n);const i=new Pbkdf2,o=i.pbkdf2Sync({password:e,salt:t,iterationCount:r,keySize:n});return i.dispose(),o}}function validatePbkdf2Arguments(e,t,r,n){if("string"!=typeof e)throw new Error("Invalid type for password in pbkdf2");if(!(t instanceof Uint8Array))throw new Error("Invalid type for salt in pbkdf2");if("number"!=typeof r||r<=0)throw new Error("Invalid number for iterationCount in pbkdf2");if("number"!=typeof n||n<=0)throw new Error("Invalid number for keySize in pbkdf2")}function toArray(e){const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r];return t}class Process{constructor(){if(!0!==arguments[0]||2!==arguments.length)throw new Error("Process can not be created");const e=arguments[1].app,t=arguments[1].device;this.env={NODE_ENV:e.debugBuild?"development":"production"},this.platform=(t.platform||"").toLowerCase(),this.argv=["tabris","./"]}}function create$b(e){return new Process(!0,e)}class ProgressEvent extends Event{constructor(e,t){if(arguments.length<1)throw new Error("Not enough arguments to ProgressEvent");super(e,t),Object.defineProperties(this,{$lengthComputable:{enumerable:!1,writable:!0,value:t&&t.lengthComputable||!1},$loaded:{enumerable:!1,writable:!0,value:t&&t.loaded||0},$total:{enumerable:!1,writable:!0,value:t&&t.total||0}})}get lengthComputable(){return this.$lengthComputable}get loaded(){return this.$loaded}get total(){return this.$total}}class ProgressBar extends Widget{get _nativeType(){return"tabris.ProgressBar"}_getXMLAttributes(){return super._getXMLAttributes().concat([["selection",this.selection],["minimum",this.minimum],["maximum",this.maximum]])}}NativeObject.defineProperties(ProgressBar.prototype,{minimum:{type:types.integer,default:0},maximum:{type:types.integer,default:100},tintColor:{type:types.ColorValue,default:null},selection:{type:types.integer,default:0},state:{type:types.string,choice:["normal","paused","error"],default:"normal"}});class Popover extends Popup{static open(e){let t;if(!(e instanceof Popover))throw new Error("Not a Popover: "+typeof e);return(t=e).open()}constructor(e){super(e),Object.defineProperty(this,"contentView",{value:create$9()}),this._nativeListen("close",!0),this._nativeSet("contentView",this.contentView.cid)}get _nativeType(){return"tabris.Popover"}_dispose(){this.isDisposed()||Composite.prototype._dispose.call(this.contentView),super._dispose()}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t),i=super[JSX.jsxFactory](e,n);return r&&r.length&&i.contentView.append(r),i}}NativeObject.defineProperties(Popover.prototype,{anchor:{type:"Widget",default:null},width:{type:"dimension",nocache:!0,nullable:!0},height:{type:"dimension",nocache:!0,nullable:!0}}),NativeObject.defineEvents(Popover.prototype,{close:{}});class NavigationBar extends NativeObject{get _nativeType(){return"tabris.NavigationBar"}_nativeCreate(e){if(!0!==e)throw new Error("NavigationBar can not be created");super._nativeCreate()}_setParent(){throw new Error("Parent of NavigationBar can not be changed")}_dispose(){throw new Error("NavigationBar can not be disposed")}}function create$c(){return new NavigationBar(!0)}NativeObject.defineProperties(NavigationBar.prototype,{theme:{type:types.string,choice:["default","light","dark"],default:"default"},displayMode:{type:types.string,choice:["default","float","hide"],default:"default"},height:{type:types.number,readonly:!0,nocache:!0},background:{type:types.ColorValue,nocache:!0}});class RadioButton extends Widget{get _nativeType(){return"tabris.RadioButton"}_getXMLAttributes(){return super._getXMLAttributes().concat([["text",this.text],["checked",this.checked]])}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return super[JSX.jsxFactory](e,this.withContentText(n,r,"text"))}}NativeObject.defineProperties(RadioButton.prototype,{text:{type:"string",default:""},checked:{type:"boolean",nocache:!0},textColor:{type:"ColorValue",default:"initial"},tintColor:{type:"ColorValue",default:"initial"},checkedTintColor:{type:"ColorValue",default:"initial"},font:{type:"FontValue",default:"initial"}}),NativeObject.defineEvents(RadioButton.prototype,{select:{native:!0,changes:"checked"}});class RefreshComposite extends Composite{get _nativeType(){return"tabris.RefreshComposite"}_listen(e,t){"refresh"===e?this._nativeListen(e,t):super._listen(e,t)}}NativeObject.defineProperties(RefreshComposite.prototype,{refreshEnabled:{type:"boolean",default:!0},refreshIndicator:{type:"boolean",nocache:!0},refreshMessage:{type:"string",default:""}}),NativeObject.defineEvents(RefreshComposite.prototype,{refresh:{native:!0}});class ScrollView extends Composite{get _nativeType(){return"tabris.ScrollView"}scrollToY(e,t){return this._nativeCall("scrollToY",{offset:e,animate:!(t&&"animate"in t)||!!t.animate}),this}scrollToX(e,t){return this._nativeCall("scrollToX",{offset:e,animate:!(t&&"animate"in t)||!!t.animate}),this}_listen(e,t){"scrollXStateChanged"===e?this._nativeListen("scrollXStateChanged",t):"scrollYStateChanged"===e?this._nativeListen("scrollYStateChanged",t):super._listen(e,t)}_getXMLAttributes(){const e="vertical"===this.direction?"offsetY":"offsetX";return super._getXMLAttributes().concat([["direction",this.direction],[e,this[e]]])}}function Setter(e,t,r){if(arguments.length<1||arguments.length>3)throw new TypeError(`Expected 1-2 arguments, got ${arguments.length}`);if(1===arguments.length){const t=e;if(checkType(t,Object,{name:"parameter 1"}),checkType(t.attribute,String,{name:"attribute"}),checkType(t.children,Array,{name:"children"}),t.children.length<1)throw new TypeError("value is missing");if(t.children.length>1)throw new TypeError("too many child elements");return Setter(t.target,{[t.attribute]:t.children[0]})}if(2===arguments.length){const r=e,n=t;checkType(r,Function,{name:"target",typeName:"a constructor"}),checkType(n,Object,{name:"parameter 2"}),checkType(r.prototype,NativeObject,{name:"target",typeName:"a widget or dialog constructor"});const i=Object.assign({},t);return Object.defineProperty(i,setterTargetType,{enumerable:!1,value:e}),i}{const n=e,i=t,o=r;return checkType(i,String,{name:"parameter 2"}),checkType(o,Object,{name:"parameter 3"}),{[i]:Setter(n,o)}}}NativeObject.defineProperties(ScrollView.prototype,{direction:{type:types.string,choice:["horizontal","vertical"],default:"vertical",const:!0},offsetX:{type:types.number,nocache:!0,readonly:!0},offsetY:{type:types.number,nocache:!0,readonly:!0},scrollbarVisible:{type:types.boolean,default:!0},scrollXState:{type:types.string,nocache:!0,readonly:!0},scrollYState:{type:types.string,nocache:!0,readonly:!0}}),NativeObject.defineEvents(ScrollView.prototype,{scrollX:{native:!0,nativeObservable:!1,changes:"offsetX",changeValue:"offset"},scrollY:{native:!0,nativeObservable:!1,changes:"offsetY",changeValue:"offset"}});const Apply=e=>{const t={target:Composite,attribute:"apply",children:null};if(e.attr instanceof Object&&e.children&&e.children[0]instanceof Object)throw new Error("RuleSet given twice");const r=e.attr||e.children[0];if(!(r instanceof Object))throw new TypeError("No RuleSet found");e.target&&e.selector?t.children=[{[e.selector]:Setter(e.target,r)}]:e.target?t.children=[Setter(e.target,r)]:e.selector?t.children=[{[e.selector]:r}]:t.children=[r];const n=Setter(t);return Array.isArray(n.apply)||(n.apply=[n.apply]),n};class SizeMeasurement extends NativeObject{_nativeCreate(e){if(!0!==e)throw new Error("SizeMeasurement can not be created");super._nativeCreate()}get _nativeType(){return"tabris.SizeMeasurement"}measureTexts(e){return new Promise$1((t,r)=>{if(arguments.length<1)throw new Error("Not enough arguments to measure texts");if(!Array.isArray(e))throw new Error("The text measurement configs have to be an array");this._nativeCall("measureTexts",{configs:this._createTextMeasureConfigs(e),onResult:e=>t(e),onError:e=>r(new Error(e))})})}measureTextsSync(e){if(arguments.length<1)throw new Error("Not enough arguments to measure texts");if(!Array.isArray(e))throw new Error("The text measurement configs have to be an array");return this._nativeCall("measureTextsSync",{configs:this._createTextMeasureConfigs(e)})}_createTextMeasureConfigs(e){return e.map(e=>({text:checkText(e.text),font:checkFont(e.font),markupEnabled:!!e.markupEnabled,maxWidth:"maxWidth"in e?types.dimension.convert(e.maxWidth):void 0}))}dispose(){throw new Error("Cannot dispose sizeMeasurement object")}}function checkText(e){if("string"!=typeof e)throw new Error('A text measurement configuration has to provide a "text" string');return e}function checkFont(e){const t=Font.from(e);if(!t.size)throw new Error('A text measurement configuration has to provide a font size via the "font" property');return t}function create$d(){return new SizeMeasurement(!0)}class Slider extends Widget{get _nativeType(){return"tabris.Slider"}_getXMLAttributes(){return super._getXMLAttributes().concat([["selection",this.selection],["minimum",this.minimum],["maximum",this.maximum]])}}NativeObject.defineProperties(Slider.prototype,{minimum:{type:"integer",default:0},maximum:{type:"integer",default:100},selection:{type:"integer",nocache:!0},tintColor:{type:"ColorValue",default:"initial"}}),NativeObject.defineEvents(Slider.prototype,{select:{native:!0,changes:"selection"}});class StatusBar extends NativeObject{get _nativeType(){return"tabris.StatusBar"}_nativeCreate(e){if(!0!==e)throw new Error("StatusBar can not be created");super._nativeCreate()}_listen(e,t){"tap"===e?this._nativeListen(e,t):super._listen(e,t)}_setParent(){throw new Error("Parent of StatusBar can not be changed")}_dispose(){throw new Error("StatusBar can not be disposed")}}function create$e(){return new StatusBar(!0)}NativeObject.defineProperties(StatusBar.prototype,{theme:{type:types.string,choice:["default","light","dark"],default:"default"},displayMode:{type:types.string,choice:["default","float","hide"],default:"default"},height:{type:types.number,readonly:!0,nocache:!0},background:{type:types.ColorValue,nocache:!0}}),NativeObject.defineEvents(StatusBar.prototype,{tap:!0});class Switch extends Widget{get _nativeType(){return"tabris.Switch"}_getXMLAttributes(){return super._getXMLAttributes().concat([["text",this.text],["checked",this.checked]])}}NativeObject.defineProperties(Switch.prototype,{checked:{type:"boolean",nocache:!0},thumbOnColor:{type:"ColorValue",default:"initial"},thumbOffColor:{type:"ColorValue",default:"initial"},trackOnColor:{type:"ColorValue",default:"initial"},trackOffColor:{type:"ColorValue",default:"initial"}}),NativeObject.defineEvents(Switch.prototype,{select:{native:!0,changes:"checked"}});class TabFolder extends Composite{constructor(e){super(e),Object.defineProperty(this,"$previousSelection",{enumerable:!1,writable:!0,value:void 0}),this._nativeListen("select",!0)}get _nativeType(){return"tabris.TabFolder"}set selectionIndex(e){const t=this._children();t[e]?this.selection=t[e]:hint(this,"Can not set selectionIndex to "+e+", value out of bounds")}get selectionIndex(){return this._children().indexOf(this.selection)}_scheduleRenderChildren(){this.$flushChildren()}_nativeListen(e,t){("select"!==e||t)&&super._nativeListen(e,t)}_initLayout(){Object.defineProperty(this,"_layout",{enumerable:!1,writable:!1,value:null})}_acceptChild(e){return e instanceof Tab}_addChild(e,t){super._addChild(e,t),0===this.$children.indexOf(e)&&(e.$trigger("appear"),this.$previousSelection=e)}_removeChild(e){if(!this._inDispose){const t=this.$children.indexOf(e),r=this.$children[t+1],n=this.$children[t-1],i=r||n;i?this.selection=i:this._triggerChangeEvent("selection",null)}super._removeChild(e)}_listen(e,t){"selectionIndexChanged"===e?this._onoff("selectionChanged",t,this.$triggerSelectionIndexChanged):super._listen(e,t)}_trigger(e,t){if("select"===e){const e=tabris._nativeObjectRegistry.find(t.selection),r=super._trigger("select",{selection:e});return e._trigger("select"),this.$previousSelection===e&&e._trigger("reselect"),this._triggerChangeEvent("selection",e),r}if("scroll"===e){const e=t.selection?tabris._nativeObjectRegistry.find(t.selection):null;return super._trigger("scroll",{selection:e,offset:t.offset})}return super._trigger(e,t)}_triggerChangeEvent(e,t){"selection"===e?this.$previousSelection!==t&&(super._triggerChangeEvent(e,t),this.$previousSelection&&this.$previousSelection._trigger("disappear"),t&&t._trigger("appear"),this.$previousSelection=t):super._triggerChangeEvent(e,t)}_getXMLAttributes(){const e=this.selection;return super._getXMLAttributes().concat([["selection",e?e.toString():""]])}$triggerSelectionIndexChanged({value:e}){super._triggerChangeEvent("selectionIndex",this._children().indexOf(e))}}function createElement$3(e,t){const r=Composite.prototype[JSX.jsxFactory].call(this,e,omit(t,["selection","selectionIndex"]));return r.set(pick(t,["selection","selectionIndex"])),r}NativeObject.defineProperties(TabFolder.prototype,{paging:{type:types.boolean,default:!1},tabBarLocation:{choice:["top","bottom","hidden","auto"],default:"auto",const:!0},tabMode:{type:types.string,choice:["fixed","scrollable"],default:"fixed",const:!0},selection:{type:{convert(e,t){const r=types.Widget.convert(e);if(!r||!(r instanceof Tab)||t._children().indexOf(r)<0)throw new Error("Can not set selection to "+toValueString(e));return r},encode:types.Widget.encode,decode:(e,t)=>t._children().length?types.Widget.decode(e):null},nocache:!0},tabTintColor:{type:types.ColorValue,default:"initial"},selectedTabTintColor:{type:types.ColorValue,default:"initial"},tabBarBackground:{type:types.ColorValue,default:"initial"},tabBarElevation:{type:types.number,nocache:!0},selectedTabIndicatorTintColor:{type:types.ColorValue,default:"initial"}}),NativeObject.defineChangeEvents(TabFolder.prototype,["selectionIndex"]),NativeObject.defineEvents(TabFolder.prototype,{scroll:{native:!0},select:{native:!0}}),TabFolder.prototype[JSX.jsxFactory]=createElement$3;class Tab extends Composite{get _nativeType(){return"tabris.Tab"}_setParent(e,t){if(e&&!(e instanceof TabFolder))throw new Error(`Tab could not be appended to ${toValueString(e)}`);super._setParent(e,t)}_getXMLAttributes(){return super._getXMLAttributes().concat([["title",this.title]])}}NativeObject.defineProperties(Tab.prototype,{title:{type:"string",default:""},image:{type:"ImageValue",default:null},selectedImage:{type:"ImageValue",default:null},badge:{type:"natural",default:0},badgeColor:{type:"ColorValue",default:"initial"}}),NativeObject.defineEvents(Tab.prototype,{disappear:!0,appear:!0,select:!0,reselect:!0});const TEXT_OPTIONS={validator:e=>"string"==typeof e};class TextResources extends Resources{static from(){const e=Resources.build(TEXT_OPTIONS);return e.from.apply(e,arguments)}constructor(e){if(1!==arguments.length)throw new Error(`Expected 1 parameter, got ${arguments.length}`);checkType(e,Object,{name:"parameter 1"}),super(Object.assign({},TEXT_OPTIONS,e))}}class TextView extends Widget{get _nativeType(){return"tabris.TextView"}_getXMLContent(){let e=super._getXMLContent();return this._shouldPrintTextAsXMLContent()&&(e=e.concat(this.text.split("\n").map(e=>"  "+e))),e}_getXMLAttributes(){const e=super._getXMLAttributes();return this.markupEnabled&&e.push(["markupEnabled","true"]),this._shouldPrintTextAsXMLContent()||e.push(["text",this.text]),e}_shouldPrintTextAsXMLContent(){return this.markupEnabled||this.text.length>25||-1!==this.text.indexOf("\n")}_listen(e,t){"tapLink"===e?this._nativeListen(e,t):super._listen(e,t)}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return super[JSX.jsxFactory](e,this.withContentText(n,r,"text",!!t&&t.markupEnabled))}}NativeObject.defineProperties(TextView.prototype,{alignment:{type:types.string,choice:["left","right","centerX"],default:"left"},markupEnabled:{type:types.boolean,default:!1},lineSpacing:{type:types.number,default:1},selectable:{type:types.boolean,default:!1},maxLines:{type:{convert:e=>e<=0?null:types.natural.convert(e)},default:null,nullable:!0},text:{type:types.string,default:""},textColor:{type:types.ColorValue,default:"initial"},font:{type:types.FontValue,default:"initial"}}),NativeObject.defineEvents(TextView.prototype,{tapLink:{native:!0}});class TimeDialog extends Popup{static open(e){let t;return(t=e instanceof TimeDialog?e:e instanceof Date?new TimeDialog({date:e}):new TimeDialog).open()}constructor(e){super(e),this._nativeListen("close",!0),this._nativeListen("select",!0)}get _nativeType(){return"tabris.TimeDialog"}_trigger(e,t){return"select"===e?(t.date=new Date(t.date),super._trigger("select",t),this._handleClose(t)):super._trigger(e,t)}}NativeObject.defineProperties(TimeDialog.prototype,{date:{type:types.Date,default:null}}),NativeObject.defineEvents(TimeDialog.prototype,{select:{native:!0},close:{native:!0}});class ToggleButton extends Widget{get _nativeType(){return"tabris.ToggleButton"}_getXMLAttributes(){return super._getXMLAttributes().concat([["text",this.text],["checked",this.checked]])}[JSX.jsxFactory](e,t){const r=this.getChildren(t),n=this.withoutChildren(t);return super[JSX.jsxFactory](e,this.withContentText(n,r,"text"))}}NativeObject.defineProperties(ToggleButton.prototype,{text:{type:types.string,default:""},image:{type:types.ImageValue,default:null},checked:{type:types.boolean,nocache:!0},alignment:{type:types.string,choice:["left","right","centerX"],default:"centerX"},textColor:{type:types.ColorValue,default:"initial"},font:{type:types.FontValue,default:"initial"}}),NativeObject.defineEvents(ToggleButton.prototype,{select:{native:!0,changes:"checked"}});class Video extends Widget{get _nativeType(){return"tabris.Video"}_listen(e,t){"stateChanged"===e||"speedChanged"===e?this._nativeListen(e,t):super._listen(e,t)}_trigger(e,t){return"stateChanged"===e?this._triggerChangeEvent("state",t.state):"speedChanged"===e?this._triggerChangeEvent("speed",t.speed):super._trigger(e,t)}pause(){this._nativeCall("pause")}play(e){this._nativeCall("play",{speed:arguments.length>0?types.number.convert(e):1})}seek(e){this._nativeCall("seek",{position:types.number.convert(e)})}_getXMLAttributes(){const e=super._getXMLAttributes();return this.url&&e.push(["url",this.url]),e.push(["state",this.state]),"play"===this.state&&e.push(["speed",this.speed]),"empty"!==this.state&&e.push(["position",this.position]),this.duration&&e.push(["duration",this.duration]),e}}NativeObject.defineProperties(Video.prototype,{url:{type:"string",default:""},controlsVisible:{type:"boolean",default:!0},autoPlay:{type:"boolean",default:!0},speed:{readonly:!0,nocache:!0},position:{readonly:!0,nocache:!0},duration:{readonly:!0,nocache:!0},state:{readonly:!0,nocache:!0}});const EVENT_TYPES$1=["navigate","load","download","message"];class WebView extends Widget{get _nativeType(){return"tabris.WebView"}_listen(e,t){EVENT_TYPES$1.includes(e)?this._nativeListen(e,t):super._listen(e,t)}postMessage(e,t){return this._nativeCall("postMessage",{data:e,origin:t}),this}goBack(){this._nativeCall("goBack")}goForward(){this._nativeCall("goForward")}_loadData(e,t){this._nativeCall("loadData",{data:e,mimeType:t})}_getXMLContent(){let e=super._getXMLContent();return this.html&&(e=e.concat(this.html.split("\n").map(e=>"  "+e))),e}_getXMLAttributes(){const e=super._getXMLAttributes();return this.url&&e.push(["url",this.url]),e}}NativeObject.defineProperties(WebView.prototype,{url:{type:"string",nocache:!0},html:{type:"string",nocache:!0},headers:{type:"any",default:Object.freeze({})},canGoBack:{type:"boolean",readonly:!0,nocache:!0},canGoForward:{type:"boolean",readonly:!0,nocache:!0},initScript:{type:"string",default:null,nullable:!0}}),NativeObject.defineEvents(WebView.prototype,{load:{native:!0},message:{native:!0}});const CONNECTING=0,OPEN=1,CLOSING=2,CLOSED=3,CONSTANTS={CONNECTING:{value:CONNECTING},OPEN:{value:OPEN},CLOSING:{value:CLOSING},CLOSED:{value:CLOSED}},EVENT_TYPES$2=["open","message","close","error"];class _WebSocket extends NativeObject{constructor(e){super(e),EVENT_TYPES$2.forEach(e=>this._nativeListen(e,!0))}get _nativeType(){return"tabris.WebSocket"}}NativeObject.defineProperties(_WebSocket.prototype,{url:{type:"string",default:""},protocol:{type:"any",default:""},binaryType:{type:"string",default:"blob"},bufferedAmount:{type:"number",nocache:!0}});class WebSocket{constructor(e,t=""){if("string"!=typeof e)throw new Error(`WebSocket url ${toValueString(e)} is not a string`);const r=extractScheme(e);if("ws"!==r&&"wss"!==r)throw new Error("The WebSocket url has to have a scheme of 'ws' or 'wss' but is '"+r+"'");if("string"!=typeof t&&!Array.isArray(t))throw new Error("The WebSocket protocol has too be a string or an array of strings");const n=Array.isArray(t)?t:[t];this.url=e,this.readyState=CONNECTING,this.protocol="",this.extensions="",addDOMEventTargetMethods(this),defineEventHandlerProperties(this,EVENT_TYPES$2),Object.defineProperty(this,"_nativeObject",{enumerable:!1,writable:!1,value:this.$createProxy(e,n)})}$createProxy(e,t){return new _WebSocket({url:e,protocol:t}).on("open",e=>{this.readyState=OPEN,this.protocol=e.protocol,this.extensions=e.extensions,this.dispatchEvent(Object.assign(new Event("open"),omit(e,["target","type","timeStamp"])))}).on("message",e=>{this.readyState===OPEN&&this.dispatchEvent(Object.assign(new Event("message"),omit(e,["target","type","timeStamp"])))}).on("close",e=>{this.readyState=CLOSED,this.dispatchEvent(Object.assign(new Event("close"),omit(e,["target","type","timeStamp"])))}).on("error",e=>{this.readyState=CLOSED,this.dispatchEvent(Object.assign(new Event("error"),omit(e,["target","type","timeStamp"])))})}set binaryType(e){this._nativeObject.binaryType=e}get binaryType(){return this._nativeObject.binaryType}set bufferedAmount(e){hint(this,'Can not set read-only property "bufferedAmount"')}get bufferedAmount(){return this._nativeObject.bufferedAmount}send(e){if(this.readyState===CONNECTING)throw new Error("Can not 'send' WebSocket message when WebSocket state is CONNECTING");if("string"==typeof e)this._nativeObject._nativeCall("send",{data:e});else{if(!isReadable(e))throw new Error("Data of type "+typeof e+" is not supported in WebSocket 'send' operation");this._nativeObject._nativeCall("send",{data:read(e)})}}close(e,t){if(e&&("number"!=typeof e||"number"!=typeof e||!(1e3===e||e>=3e3&&e<=4999)))throw new Error("A given close code has to be either 1000 or in the range 3000 - 4999 inclusive");if(t&&getStringByteSize(t)>123)throw new Error("The close reason can not be larger than 123 utf-8 bytes");if(this.readyState!==CLOSING&&this.readyState!==CLOSED){this.readyState=CLOSING;const r={};e&&(r.code=e),t&&(r.reason=t),this._nativeObject._nativeCall("close",r)}}}function getStringByteSize(e){let t=0;if(!e.length)return 0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);n<=127?t+=1:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,r++):t+=n<65535?3:4}return t}function extractScheme(e){const t=/^(\S+?):/.exec(e);return t?t[1]:null}Object.defineProperties(WebSocket,CONSTANTS),Object.defineProperties(WebSocket.prototype,CONSTANTS);class HttpRequest extends NativeObject{constructor(){super(),this._nativeListen("stateChanged",!0),this._nativeListen("downloadProgress",!0),this._nativeListen("uploadProgress",!0)}abort(){this._nativeCall("abort",{})}send(e){this._nativeCall("send",e)}get _nativeType(){return"tabris.HttpRequest"}}const UNSENT=0,OPENED=1,HEADERS_RECEIVED=2,LOADING=3,DONE=4,EVENT_TYPES$3=["loadstart","readystatechange","load","loadend","progress","timeout","abort","error"],UPLOAD_EVENT_TYPES=["progress","loadstart","load","loadend","timeout","abort","error"],SUPPORTED_SCHEMES=["http","https","file"];class XMLHttpRequest{constructor(){Object.defineProperties(this,{$authorRequestHeaders:{enumerable:!1,writable:!0,value:{}},$timeout:{enumerable:!1,writable:!0,value:0},$status:{enumerable:!1,writable:!0,value:0},$statusText:{enumerable:!1,writable:!0,value:""},$responseHeaders:{enumerable:!1,writable:!0,value:""},$readyState:{enumerable:!1,writable:!0,value:UNSENT},$responseData:{enumerable:!1,writable:!0,value:""},$withCredentials:{enumerable:!1,writable:!0,value:!1},$responseType:{enumerable:!1,writable:!0,value:""},$sendInvoked:{enumerable:!1,writable:!0,value:!1},$isSynchronous:{enumerable:!1,writable:!0,value:!1},$error:{enumerable:!1,writable:!0,value:!1},$uploadComplete:{enumerable:!1,writable:!0,value:!1},upload:{value:{}}}),defineEventHandlerProperties(this,EVENT_TYPES$3),defineEventHandlerProperties(this.upload,UPLOAD_EVENT_TYPES),addDOMEventTargetMethods(this),addDOMEventTargetMethods(this.upload)}get readyState(){return this.$readyState}get timeout(){return this.$timeout}set timeout(e){isNaN(e)||(this.$timeout=Math.round(e))}get responseText(){if(""!==this.$responseType&&"text"!==this.$responseType)throw new Error("XHR responseText not accessible for non-text responseType");return this.$readyState!==LOADING&&this.$readyState!==DONE?"":this.$responseData||""}get response(){return""===this.$responseType||"string"===this.$responseType?this.$readyState!==LOADING&&this.$readyState!==DONE?"":this.$responseData||"":this.$readyState!==DONE?null:this.$responseData}get responseType(){return this.$responseType}set responseType(e){if(this.$readyState===LOADING||this.$readyState===DONE)throw new Error("The response type cannot be set when state is LOADING or DONE.");if(!(["arraybuffer","blob","document","json","text"].indexOf(e)<0)){if(["blob","document","json"].indexOf(e)>-1)throw new Error("Unsupported responseType, only 'text' and 'arraybuffer' are supported");this.$responseType=e}}get status(){return[OPENED,UNSENT].indexOf(this.$readyState)>-1?0:this.$error?0:this.$status}get statusText(){return[OPENED,UNSENT].indexOf(this.$readyState)>-1?"":this.$error?"":this.$statusText}get withCredentials(){return this.$withCredentials}set withCredentials(e){if(this.$readyState!==UNSENT&&this.$readyState!==OPENED)throw new Error("InvalidStateError: state must be 'UNSENT' or 'OPENED' when setting withCredentials");if(this.$sendInvoked)throw new Error("InvalidStateError: 'send' invoked, failed to set 'withCredentials'");"boolean"==typeof e&&(this.$withCredentials=e)}open(e,t,r){const n={};if(validateRequiredOpenArgs(e,t),n.source=t,n.isRelative=!new RegExp("^(?:[a-z]+:)?//","i").test(t),void 0===r&&(r=!0),!r)throw new Error("Only asynchronous request supported.");this.$requestMethod=e,this.$requestUrl=n,this.$isSynchronous=!r,this.$authorRequestHeaders={},this.$sendInvoked=!1,this.$responseData=null,this.$readyState!==OPENED&&(this.$readyState=OPENED,dispatchEvent("readystatechange",this))}send(e){if(this.$nativeObject=(new HttpRequest).on("stateChanged",e=>handleStateChange(e,this)).on("downloadProgress",e=>dispatchProgressEvent("progress",this,e)).on("uploadProgress",e=>dispatchProgressEvent("progress",this.upload,e)),this.$readyState!==OPENED)throw new Error("InvalidStateError: Object's state must be 'OPENED', failed to execute 'send'");if(this.$sendInvoked)throw new Error("InvalidStateError: 'send' invoked, failed to execute 'send'");["GET","HEAD"].indexOf(this.$requestMethod)>-1&&(e=null),e instanceof FormData&&(e=formDataToBlob(e)),this.$requestBody=e&&getBytes(e)?getBytes(e):e,e instanceof Blob&&-1===Object.keys(this.$authorRequestHeaders).map(e=>e.toLowerCase()).indexOf("content-type")&&(this.$authorRequestHeaders["Content-Type"]=e.type),this.$error=this.$uploadComplete=!1,e||(this.$uploadComplete=!0),this.$sendInvoked=!0,dispatchProgressEvent("loadstart",this),this.$uploadComplete||dispatchProgressEvent("loadstart",this.upload),this.$nativeObject.send({url:this.$requestUrl.source,method:this.$requestMethod,timeout:this.timeout,headers:this.$authorRequestHeaders,data:this.$requestBody,responseType:this.$responseType})}abort(){this.$nativeObject&&this.$nativeObject.abort(),[UNSENT,OPENED].indexOf(this.$readyState)>-1&&!this.$sendInvoked||this.$readyState===DONE||(dispatchEvent("readystatechange",this),this.$uploadComplete||(this.$uploadComplete=!0,dispatchAbortProgressEvents(this.upload)),dispatchAbortProgressEvents(this)),this.$readyState=UNSENT}setRequestHeader(e,t){if(this.$readyState!==OPENED)throw new Error("InvalidStateError: Object's state must be 'OPENED', failed to execute 'setRequestHeader'");if(this.$sendInvoked)throw new Error("InvalidStateError: cannot set request header if 'send()' invoked and request not completed");if(!validHttpToken(e))throw new TypeError("Invalid HTTP header name, failed to execute 'open'");if(!isValidHttpHeaderValue(t))throw new TypeError("Invalid HTTP header value, failed to execute 'open'");e in this.$authorRequestHeaders?this.$authorRequestHeaders[e]=this.$authorRequestHeaders[e]+", "+t:this.$authorRequestHeaders[e]=t}getResponseHeader(e){if([UNSENT,OPENED].indexOf(this.readyState)>-1)return null;if(this.$error)return null;for(const t in this.$responseHeaders)if(t.toLowerCase()===e.toLowerCase())return this.$responseHeaders[t];return null}getAllResponseHeaders(){if([UNSENT,OPENED].indexOf(this.readyState)>-1)return"";if(this.$error)return"";const e=[];for(const t in this.$responseHeaders)e.push(t+": "+this.$responseHeaders[t]);return e.join("\r\n")}}function handleStateChange(e,t){switch(e.state){case"headers":t.$readyState=HEADERS_RECEIVED,t.$status=e.code,t.$statusText=e.message,t.$responseHeaders=e.headers,dispatchEvent("readystatechange",t),t.$uploadComplete=!0,dispatchFinishedProgressEvents(t.upload);break;case"loading":t.$readyState=LOADING,dispatchEvent("readystatechange",t);break;case"finished":t.$responseData=e.response,t.$readyState=DONE,dispatchEvent("readystatechange",t),dispatchFinishedProgressEvents(t),dispatchFinishedProgressEvents(t.upload),t.$nativeObject.dispose(),t.$nativeObject=null;break;case"error":handleRequestError("error",t);break;case"timeout":handleRequestError("timeout",t);break;case"abort":handleRequestError("abort",t)}}function handleRequestError(e,t){t.$error=!0,t.$readyState=DONE,dispatchEvent("readystatechange",t),dispatchErrorProgressEvents(e,t),t.$uploadComplete||(t.$uploadComplete=!0,dispatchErrorProgressEvents(e,t.upload)),t.$nativeObject.dispose(),t.$nativeObject=null}function validateRequiredOpenArgs(e,t){if(!e)throw new TypeError("Method argument should be specified to execute 'open'");if(!t)throw new TypeError("URL argument should be specified to execute 'open'");validateMethod(e),validateUrl(t)}function validateMethod(e){if(!validHttpToken(e))throw new TypeError("Invalid HTTP method, failed to execute 'open'");const t=e.toUpperCase();["CONNECT","DELETE","GET","HEAD","OPTIONS","POST","PUT","TRACE","TRACK"].indexOf(t)>=0&&(e=t);if(["CONNECT","TRACE","TRACK"].indexOf(e)>=0)throw new Error(`SecurityError: '${e}' HTTP method is not secure, failed to execute 'open'`)}function validHttpToken(e){return!(/[^\x21-\x7E]/.test(e)||["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"].indexOf(e)>=0)}function isValidHttpHeaderValue(e){return/^[\x09\x0A\x0D\x20-\x7E\xA0-\xFF]*$/.test(e)&&e.indexOf("\n")<0&&e.indexOf("\r")<0}function validateUrl(e){const t=extractScheme$1(e);if(t&&-1===SUPPORTED_SCHEMES.indexOf(t))throw new SyntaxError("Unsupported URL scheme, failed to execute 'open'")}function extractScheme$1(e){const t=/^(\S+?):/.exec(e);return t?t[1]:null}function dispatchEvent(e,t){t.dispatchEvent(new Event(e))}function dispatchProgressEvent(e,t,r){t.dispatchEvent(new ProgressEvent(e,r))}function dispatchAbortProgressEvents(e){dispatchProgressEvent("progress",e),dispatchProgressEvent("abort",e),dispatchProgressEvent("loadend",e)}function dispatchErrorProgressEvents(e,t){dispatchProgressEvent("progress",t),dispatchProgressEvent(e,t),dispatchProgressEvent("loadend",t)}function dispatchFinishedProgressEvents(e){dispatchProgressEvent("load",e),dispatchProgressEvent("loadend",e)}function $(e){if("number"==typeof e)return tabris._nativeObjectRegistry.find("$"+e);if("string"==typeof e||e instanceof Function||0===arguments.length)return tabris.contentView.find(e||"*");if(!(e instanceof Object))return""+e;if(!Object.keys(e).length)return new WidgetCollection;if(Object.keys(e).length>1||!("children"in e))throw new Error("$ does not support attributes");const t=flattenChildren(e.children);return t.some(e=>e instanceof Widget)||t.length<1?toWidgetCollection(t):joinTextContent(t,!1)}function toWidgetCollection(e){const t=[];let r=[];return e.forEach(e=>{e instanceof Widget?(r.length&&(t.push(new TextView({text:joinTextContent(r,!1)})),r=[]),t.push(e)):r.push(e)}),r.length&&t.push(new TextView({text:joinTextContent(r,!1)})),new WidgetCollection(t)}Object.defineProperties(XMLHttpRequest.prototype,{UNSENT:{value:UNSENT},OPENED:{value:OPENED},HEADERS_RECEIVED:{value:HEADERS_RECEIVED},LOADING:{value:LOADING},DONE:{value:DONE}});class Headers{constructor(e){Object.defineProperties(this,{$map:{enumerable:!1,writable:!0,value:{}}}),e instanceof Headers?e.forEach((e,t)=>this.append(t,e)):Array.isArray(e)?e.forEach(e=>this.append(e[0],e[1])):e&&Object.getOwnPropertyNames(e).forEach(t=>this.append(t,e[t]))}append(e,t){e=normalizeName(e);const r=this.$map[e];this.$map[e]=r?r+","+t:""+t}delete(e){delete this.$map[normalizeName(e)]}get(e){return e=normalizeName(e),this.has(e)?this.$map[e]:null}has(e){return Object.prototype.hasOwnProperty.call(this.$map,normalizeName(e))}set(e,t){this.$map[normalizeName(e)]=""+t}forEach(e,t){for(const r in this.$map)Object.prototype.hasOwnProperty.call(this.$map,r)&&e.call(t,this.$map[r],r,this)}keys(){const e=[];return this.forEach((t,r)=>e.push(r)),iteratorFor(e)}values(){const e=[];return this.forEach(t=>e.push(t)),iteratorFor(e)}entries(){const e=[];return this.forEach((t,r)=>e.push([r,t])),iteratorFor(e)}[iteratorSymbol()](){return this.entries()}}function normalizeName(e){if(/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e=""+e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function iteratorFor(e){const t={next(){const t=e.shift();return{done:void 0===t,value:t}}};return t[iteratorSymbol()]=function(){return t},t}function iteratorSymbol(){return"Symbol"in global&&"iterator"in global.Symbol?global.Symbol.iterator:"@@iterator"}class Body{constructor(){Object.defineProperties(this,{$bodyUsed:{enumerable:!1,writable:!0,value:!1}})}_initBody(e){if(Object.defineProperty(this,"_bodyInit",{enumerable:!1,writable:!1,value:e}),e)if("string"==typeof e)Object.defineProperty(this,"_bodyText",{enumerable:!1,writable:!1,value:e});else{if(!isReadable(e))throw new Error("unsupported BodyInit type");Object.defineProperty(this,"_bodyBuffer",{enumerable:!1,writable:!1,value:read(e)})}else Object.defineProperty(this,"_bodyText",{enumerable:!1,writable:!1,value:""})}text(){return this.$consumed()||Promise$1.resolve(this._bodyBuffer?TextDecoder.decode(this._bodyBuffer,this._encoding):this._bodyText)}json(){return this.text().then(JSON.parse)}blob(){return this.arrayBuffer().then(e=>{const t=new Blob([],{type:this.headers?this.headers.get("content-type"):""});return setBytes(t,e),t})}arrayBuffer(){return this.$consumed()||Promise$1.resolve(this._bodyBuffer?this._bodyBuffer:TextEncoder.encode(this._bodyText,this._encoding))}get bodyUsed(){return!!this.$bodyUsed}$consumed(){if(this.$bodyUsed)return Promise$1.reject(new TypeError("Already read"));this.$bodyUsed=!0}get _encoding(){}}const METHODS=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];class Request extends Body{constructor(e,t={}){super();let r=t.body;if(e instanceof Request){if(e.bodyUsed)throw new TypeError("Already read");r||null==e._bodyInit||(r=e._bodyInit,e.$bodyUsed=!0)}else e={url:e};if(Object.defineProperties(this,{url:{value:""+e.url},method:{value:normalizeMethod(t.method||e.method||"GET")},headers:{value:new Headers(t.headers||e.headers||{})},credentials:{value:t.credentials||e.credentials||"omit"},mode:{value:t.mode||e.mode||null},referrer:{value:""},timeout:{value:t.timeout||0}}),("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");r instanceof FormData&&(r=formDataToBlob(r)),r instanceof Blob&&!this.headers.has("Content-Type")&&this.headers.set("Content-Type",r.type),this._initBody(r)}clone(){return new Request(this,{body:this._bodyInit})}}function normalizeMethod(e){const t=e.toUpperCase();return METHODS.includes(t)?t:e}const REDIRECT_STATUSES=[301,302,303,307,308];class Response extends Body{constructor(e,t={}){super(),Object.defineProperties(this,{url:{value:t.url||""},type:{value:t._type||"default"},status:{value:"status"in t?t.status:200},statusText:{value:"statusText"in t?t.statusText:"OK"},headers:{value:new Headers(t.headers)}}),this._initBody(e)}get ok(){return this.status>=200&&this.status<300}clone(){return new Response(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Headers(this.headers),url:this.url})}get _encoding(){const e=(this.headers.get("content-type")||"").split(";").slice(1);for(const t of e){const e=/charset=(\S+)/i.exec(t.trim());if(e)return e[1].toLowerCase()}return null}static error(){return new Response(null,{status:0,statusText:"",_type:"error"})}static redirect(e,t){if(!REDIRECT_STATUSES.includes(t))throw new RangeError("Invalid status code");return new Response(null,{status:t,headers:{location:e}})}}function fetch(e,t){return new Promise$1((r,n)=>{const i=new Request(e,t),o=new HttpRequest,a={};o.on("_stateChanged",e=>{switch(e.state){case"headers":a.status=e.code,a.statusText=e.message,a.headers=new Headers(e.headers);break;case"finished":a.url=a.headers.get("X-Request-URL")||i.url,r(new Response(e.response,a)),o.dispose();break;case"error":n(new TypeError(e.message||"Network request failed")),o.dispose();break;case"timeout":n(new TypeError("Network request timed out")),o.dispose();break;case"abort":n(new TypeError("Network request aborted")),o.dispose()}}),o.send({url:i.url,method:i.method,responseType:"arraybuffer",data:void 0===i._bodyInit?null:i._bodyBuffer||i._bodyInit,headers:encodeHeaders(i.headers),timeout:i.timeout})})}function encodeHeaders(e){const t={};return e.forEach((e,r)=>t[r]=e),t}if(global.tabris&&global.tabris.version)throw new Error("tabris module already loaded. Ensure the module is installed only once.");const WIDGETS=Object.freeze({Action:Action,ActivityIndicator:ActivityIndicator,Button:Button,Canvas:Canvas,ContentView:ContentView,CheckBox:CheckBox,CollectionView:CollectionView,CameraView:CameraView,Composite:Composite,Drawer:Drawer,ImageView:ImageView,NavigationView:NavigationView,Page:Page,PdfView:PdfView,Picker:Picker,ProgressBar:ProgressBar,RadioButton:RadioButton,RefreshComposite:RefreshComposite,Row:Row,ScrollView:ScrollView,SearchAction:SearchAction,Slider:Slider,Stack:Stack,Switch:Switch,Tab:Tab,TabFolder:TabFolder,TextInput:TextInput,TextView:TextView,ToggleButton:ToggleButton,Video:Video,WebView:WebView,Widget:Widget}),POPUPS=Object.freeze({ActionSheet:ActionSheet,ActionSheetItem:ActionSheetItem,AlertDialog:AlertDialog,DateDialog:DateDialog,Popover:Popover,TimeDialog:TimeDialog}),WHATWG=Object.freeze({Blob:Blob,Crypto:Crypto,CryptoKey:CryptoKey,Event:Event,File:File,FormData:FormData,ImageData:ImageData,ImageBitmap:ImageBitmap,ProgressEvent:ProgressEvent,Promise:Promise$1,Storage:Storage,WebSocket:WebSocket,XMLHttpRequest:XMLHttpRequest,fetch:fetch,Headers:Headers,Request:Request,Response:Response,Worker:Worker,createImageBitmap:ImageBitmap.createImageBitmap}),NATIVE_OBJECT=Object.freeze({App:App,Camera:Camera,NavigationBar:NavigationBar,Device:Device,DevTools:DevTools,FileSystem:FileSystem,Input:Input,InactivityTimer:InactivityTimer,NativeObject:NativeObject,Printer:Printer,SizeMeasurement:SizeMeasurement,StatusBar:StatusBar}),UTILS={checkType:checkType,format:format,asFactory:e=>tabrisMain.JSX.processor.makeFactory(e),applyRules:applyRules},OTHER=Object.freeze({Apply:Apply,Authentication:Authentication,CanvasContext:CanvasContext,ChangeListeners:ChangeListeners,Color:Color,ColorResources:ColorResources,ConstraintLayout:ConstraintLayout,Constraint:Constraint,Console:Console,EventObject:EventObject,Font:Font,FontResources:FontResources,Image:Image,JsxProcessor:JsxProcessor,JSX:JSX,Layout:Layout,LayoutData:LayoutData,Listeners:Listeners,LinearGradient:LinearGradient,Observable:Observable,ObservableData:ObservableData,Percent:Percent,Permission:Permission,Process:Process,Resources:Resources,RowLayout:RowLayout,StackLayout:StackLayout,Setter:Setter,Set:Setter,symbols:symbols,propertyTypes:types,TextResources:TextResources,WidgetCollection:WidgetCollection,$:$}),tabrisMain=Object.assign(new Tabris,WIDGETS,POPUPS,WHATWG,NATIVE_OBJECT,UTILS,OTHER);"undefined"!=typeof module&&(module.exports=tabrisMain),global.document?(global.tabris=tabrisMain,global.JSX=tabrisMain.JSX):(global.tabris=tabrisMain,global.tabris.tabris=tabrisMain,Object.assign(global,WHATWG,{$:$}),addDOMDocument(global),addDOMEventTargetMethods(global),defineEventHandlerProperties(global,["message","messageerror","error"]),addWindowTimerMethods(global)),tabrisMain.on("start",e=>{global.console.print&&(global.console=createConsole(global.console)),patchError(Error),patchError(EvalError),patchError(RangeError),patchError(ReferenceError),patchError(SyntaxError),patchError(TypeError),patchError(URIError),tabris.$app=create$4(),checkVersion(tabris.version,tabris.app._nativeGet("tabrisJsVersion")),e&&e.headless||(tabris.$contentView=create$9(),tabris._nativeSet("contentView",tabris.contentView.cid),tabris.$drawer=create$a(),tabris.$navigationBar=create$c(),tabris.$statusBar=create$e(),tabris.$printer=create$1(),tabris.$permission=create$2(),tabris.$authentication=create$3(),tabris.JSX.install(createJsxProcessor()),tabris.widgets=omit(WIDGETS,["Widget","Drawer","ContentView"]),Object.assign(tabris,tabris.JSX.processor.makeFactories(tabris.widgets))),tabris.$devTools=create$7(),tabris.$sizeMeasurement=create$d(),tabris.$device=create(),tabris.$fs=create$5(),publishDeviceProperties(tabris.device,global),tabris.$input=create$6(),tabris.$localStorage=create$8(),tabris.$secureStorage=create$8(!0),tabris.$crypto=new Crypto,"print"in global.console&&(global.console=createConsole(global.console)),tabris.$pkcs5=new Pkcs5,tabris.$process=create$b(tabrisMain),global.localStorage=tabrisMain.localStorage,global.secureStorage=tabrisMain.secureStorage,global.crypto=tabrisMain.crypto,global.JSX=tabrisMain.JSX,global.process||(global.process=tabrisMain.process)});