UNPKG

@w2a-iiot/raw-javascript-parsers

Version:

This packages contain the raw built javascript parsers for WIKA's IIoT devices.

3 lines 63.4 kB
var __commonJSMin=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);function _typeof(e){"@babel/helpers - typeof";return _typeof=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},_typeof(e)}function toPrimitive(e,n){if(_typeof(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(_typeof(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function toPropertyKey(e){var r=toPrimitive(e,`string`);return _typeof(r)==`symbol`?r:r+``}function _defineProperty(e,t,n){return(t=toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function getGlobalConfig(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function _stringify(e){var t;let n=typeof e;return n===`string`?`"${e}"`:n===`number`||n===`bigint`||n===`boolean`?`${e}`:n===`object`||n===`function`?(e&&((t=Object.getPrototypeOf(e))==null||(t=t.constructor)==null?void 0:t.name))??`null`:n}function _addIssue(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??_stringify(a),l={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},u=e.kind===`schema`,d=i?.message??e.message??(e.reference,l.lang,void 0)??(u?(l.lang,void 0):null)??r.message??(l.lang,void 0);d!==void 0&&(l.message=typeof d==`function`?d(l):d),u&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function _getStandardProps(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},getGlobalConfig())}}}function _joinExpects(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function getDotPath(e){if(e.path){let t=``;for(let n of e.path)if(typeof n.key==`string`||typeof n.key==`number`)t?t+=`.${n.key}`:t+=n.key;else return null;return t}return null}const HEXADECIMAL_REGEX=/^(?:0[hx])?[\da-fA-F]+$/u;function hexadecimal(e){return{kind:`validation`,type:`hexadecimal`,reference:hexadecimal,async:!1,expects:null,requirement:HEXADECIMAL_REGEX,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&_addIssue(this,`hexadecimal`,e,t),e}}}function integer(e){return{kind:`validation`,type:`integer`,reference:integer,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&_addIssue(this,`integer`,e,t),e}}}function maxValue(e,t){return{kind:`validation`,type:`max_value`,reference:maxValue,async:!1,expects:`<=${e instanceof Date?e.toJSON():_stringify(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&_addIssue(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():_stringify(e.value)}),e}}}function minValue(e,t){return{kind:`validation`,type:`min_value`,reference:minValue,async:!1,expects:`>=${e instanceof Date?e.toJSON():_stringify(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&_addIssue(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():_stringify(e.value)}),e}}}function transform(e){return{kind:`transformation`,type:`transform`,reference:transform,async:!1,operation:e,"~run"(e){return e.value=this.operation(e.value),e}}}function getFallback(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function getDefault(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function array(e,t){return{kind:`schema`,type:`array`,reference:array,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let i=0;i<n.length;i++){let a=n[i],o=this.item[`~run`]({value:a},t);if(o.issues){let s={type:`array`,origin:`value`,input:n,key:i,value:a};for(let t of o.issues){var r;t.path?t.path.unshift(s):t.path=[s],(r=e.issues)==null||r.push(t)}if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else _addIssue(this,`type`,e,t);return e}}}function boolean(e){return{kind:`schema`,type:`boolean`,reference:boolean,expects:`boolean`,async:!1,message:e,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:_addIssue(this,`type`,e,t),e}}}function literal(e,t){return{kind:`schema`,type:`literal`,reference:literal,expects:_stringify(e),async:!1,literal:e,message:t,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:_addIssue(this,`type`,e,t),e}}}function number(e){return{kind:`schema`,type:`number`,reference:number,expects:`number`,async:!1,message:e,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:_addIssue(this,`type`,e,t),e}}}function object(e,t){return{kind:`schema`,type:`object`,reference:object,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let i in this.entries){let a=this.entries[i];if(i in n||(a.type===`exact_optional`||a.type===`optional`||a.type===`nullish`)&&a.default!==void 0){let o=i in n?n[i]:getDefault(a),s=a[`~run`]({value:o},t);if(s.issues){let a={type:`object`,origin:`value`,input:n,key:i,value:o};for(let t of s.issues){var r;t.path?t.path.unshift(a):t.path=[a],(r=e.issues)==null||r.push(t)}if(e.issues||=s.issues,t.abortEarly){e.typed=!1;break}}s.typed||(e.typed=!1),e.value[i]=s.value}else if(a.fallback!==void 0)e.value[i]=getFallback(a);else if(a.type!==`exact_optional`&&a.type!==`optional`&&a.type!==`nullish`&&(_addIssue(this,`key`,e,t,{input:void 0,expected:`"${i}"`,path:[{type:`object`,origin:`key`,input:n,key:i,value:n[i]}]}),t.abortEarly))break}}else _addIssue(this,`type`,e,t);return e}}}function optional(e,t){return{kind:`schema`,type:`optional`,reference:optional,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=getDefault(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function string(e){return{kind:`schema`,type:`string`,reference:string,expects:`string`,async:!1,message:e,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:_addIssue(this,`type`,e,t),e}}}function _subIssues(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function union(e,t){return{kind:`schema`,type:`union`,reference:union,expects:_joinExpects(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];_addIssue(this,`type`,e,t,{issues:_subIssues(r)}),e.typed=!0}else if(i?.length===1)return i[0];else _addIssue(this,`type`,e,t,{issues:_subIssues(i)});return e}}}function variant(e,t,n){return{kind:`schema`,type:`variant`,reference:variant,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return _getStandardProps(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},{abortEarly:!0}).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;_addIssue(this,`type`,e,t,{input:n[a],expected:_joinExpects(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else _addIssue(this,`type`,e,t);return e}}}function pipe(...e){return _objectSpread2(_objectSpread2({},e[0]),{},{pipe:e,get"~standard"(){return _getStandardProps(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}})}function safeParse(e,t,n){let r=e[`~run`]({value:t},getGlobalConfig(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}function summarize(e){let t=``;for(let n of e){t&&(t+=` `),t+=`× ${n.message}`;let e=getDotPath(n);e&&(t+=`\n → at ${e}`)}return t}function checkChannelsValidity(e,t){let n=new Set;e.forEach(e=>{if(e.start>=e.end)throw t?Error(`Invalid channel range in codec ${t}: ${e.start} >= ${e.end} in channel ${e.name}`):Error(`Invalid channel range: ${e.start} >= ${e.end} in channel ${e.name}`);if(n.has(e.name))throw t?Error(`Duplicate channel name found in codec ${t}: ${e.name}`):Error(`Duplicate channel name found: ${e.name}`);n.add(e.name)})}function checkCodecsValidity(e){if(e.length===0)throw Error(`At least one codec must be provided`);e.forEach(e=>{checkChannelsValidity(e.getChannels(),e.name)}),e.forEach((t,n)=>{if(e.filter((e,t)=>t!==n).some(e=>e.name===t.name))throw Error(`Codec names must be unique. Duplicate found: ${t.name}`)});let t=e[0].getChannels().map(e=>e.name);e.forEach((e,n)=>{if(n===0)return;let r=e.getChannels().map(e=>e.name),i={missing:[],extra:[]};if(r.forEach(e=>{t.includes(e)||i.extra.push(e)}),t.forEach(e=>{r.includes(e)||i.missing.push(e)}),i.extra.length>0)throw Error(`Codec ${e.name} has extra channels not present in other codecs: ${i.extra.join(`, `)}`);if(i.missing.length>0)throw Error(`Codec ${e.name} is missing channels present in other codecs: ${i.missing.join(`, `)}`)});let n=new Map,r={};return e.forEach(e=>{e.getChannels().forEach(e=>{let t=[e.start,e.end],i=e.adjustMeasurementRangeDisallowed??!1;if(n.has(e.name)){let a=n.get(e.name);if(a[0]!==t[0]||a[1]!==t[1])throw Error(`Channel ${e.name} has inconsistent ranges across codecs: ${JSON.stringify(a)} vs ${JSON.stringify(t)}`);let o=r[e.name];if(o!==i)throw Error(`Channel ${e.name} has inconsistent adjustMeasurementRangeDisallowed settings across codecs: ${o} vs ${i}`)}else n.set(e.name,t),r[e.name]=i})}),r}function createFPortSchema(){return pipe(number(),minValue(1),maxValue(255),integer())}function createRecvTimeSchema(){return optional(string())}function createUplinkInputSchema(){return object({bytes:array(pipe(number(),minValue(0),maxValue(255),integer())),fPort:optional(pipe(number(),minValue(1),maxValue(224),integer())),recvTime:optional(string())},"Uplink input should be an object with `bytes` and optional `fPort` and `recvTime` properties.")}function createHexUplinkInputSchema(){return pipe(union([object({bytes:pipe(string()),fPort:optional(createFPortSchema()),recvTime:createRecvTimeSchema()}),string()]),transform(e=>typeof e==`string`?{bytes:e}:e))}function nstr(e,t={}){let{threshold:n=4,maxDecimals:r=10}=t;if(Number.isNaN(e))return`NaN`;if(!isFinite(e)||Number.isInteger(e))return e.toString();let i=e.toFixed(r),a=-1,o=``,s=i.indexOf(`.`),c=s>=0?s+1:i.length;for(let e=c;e<i.length;e++){let t=i[e];if(t===`0`||t===`9`){let r=1,s=e+1;for(;s<i.length&&i[s]===t;)r++,s++;if(r>=n){a=e,o=t;break}e=s-1}}if(a!==-1){let e=i.substring(0,a);if(o===`9`){let t=e,n=Number.parseFloat(t),r=t.indexOf(`.`),i=r>=0?t.length-r-1:0,a=10**-i,o=n<0?n-a:n+a;e=i>0?o.toFixed(i):o.toString()}let t=e.replace(/\.?0+$/,``);return t.endsWith(`.`)&&(t=t.slice(0,-1)),(t===`-0.`||t===`0.`||t===`-0`||t===`0`)&&(t=`0`),t}let l=i.replace(/\.?0+$/,``);return l.endsWith(`.`)&&(l=l.slice(0,-1)),(l===`-0.`||l===`0.`||l===`-0`||l===`0`)&&(l=`0`),l}function getRoundingDecimals(e,t){let n=t??4;return e===void 0||Number.isNaN(e)||e===-1/0?n:e===1/0?1/0:Math.floor(e)>=0?Math.floor(e):n}function hexStringToIntArray(e){let t=e.replaceAll(` `,``);t=t.startsWith(`0x`)?t.slice(2):t;let n=safeParse(pipe(string(),hexadecimal()),t);if(!n.success)return null;let r=[];for(let e=0;e<n.output.length;e+=2){let t=Number.parseInt(n.output.slice(e,e+2),16);r.push(t)}return r}function percentageToValue(e,t){if(t.start>=t.end)throw RangeError(`Range start must be less than range end`);return(t.end-t.start)*(e/100)+t.start}function TULIPValueToValue(e,t){return percentageToValue((e-2500)*100/1e4+0,t)}function slopeValueToValue(e,t){if(e<0||e>1e4)throw RangeError(`Slope value must be between 0 and 10_000, is ${e}`);let n=e/100,r=t.end-t.start;return n/100*r}function roundValue(e,t){if(t=typeof t==`number`?Math.min(Math.max(0,Math.floor(t)),100):void 0,Number.isInteger(e))return e;let n=nstr(e+5*2**-52,{maxDecimals:t});return n===``?0:Number.parseFloat(n)}function intTuple4ToFloat32(e){let t=new ArrayBuffer(4),n=new DataView(t);return n.setUint8(0,e[0]&255),n.setUint8(1,e[1]&255),n.setUint8(2,e[2]&255),n.setUint8(3,e[3]&255),n.getFloat32(0)}function intTuple4ToFloat32WithThreshold(e,t=3){t=Math.max(0,Math.floor(t));let n=intTuple4ToFloat32(e);return Number.parseFloat(nstr(n,{threshold:t}))}function defineParser(e){let{codecs:t,throwOnMultipleDecode:n=!0,parserName:r}=e,i=getRoundingDecimals(e.roundingDecimals),a=checkCodecsValidity(e.codecs);function o(e){return{errors:[s(e)]}}function s(e){return`${r} (JS): ${e}`}function c(e){let r;if(t.forEach(t=>{if(t.canTryDecode(e)){if(!r)r=t;else if(n)throw Error(`Message could not be uniquely decoded. Multiple codecs matched the input.`)}}),!r)throw Error(`Message could not be decoded. No codec matched the input.`);return r.decode(e)}function l(e){try{let t=safeParse(createUplinkInputSchema(),e);if(!t.success)throw Error(`Input is not a valid for decoding. Check your input data.`);let n=c(t.output);return n.warnings&&=n.warnings.map(s),n}catch(t){return t instanceof Error?o(t.message):o(`Unknown error occurred during decoding in parser ${r} with input ${JSON.stringify(e)}`)}}function u(e){let t=safeParse(createHexUplinkInputSchema(),e);if(!t.success)return o(`Input is not a valid for decoding. Check your input data.`);let n=hexStringToIntArray(t.output.bytes);return n?l({bytes:n,fPort:t.output.fPort,recvTime:t.output.recvTime}):o(`Input bytes is not a valid hexadecimal string.`)}function d(e){try{let n=t.find(t=>t.protocol===e.protocol);if(!n)throw Error(`Codec with protocol ${e.protocol} not found in parser. Available protocols: ${t.map(e=>e.protocol).join(`, `)}`);if(!(`encode`in n))throw Error(`Codec with protocol ${e.protocol} does not support encoding. Input could not be encoded.`);return n.encode(e.input)}catch(t){return t instanceof Error?o(t.message):o(`Unknown error occurred during encoding in parser ${r} with input ${JSON.stringify(e)}`)}}function f(e){try{let n=t.find(t=>t.protocol===e.protocol);if(!n)throw Error(`Codec with protocol ${e.protocol} not found in parser. Available protocols: ${t.map(e=>e.protocol).join(`, `)}`);if(!(`encodeMultiple`in n))throw Error(`Codec with protocol ${e.protocol} does not support multiple encoding. Input could not be encoded.`);return n.encodeMultiple(e.input)}catch(t){return t instanceof Error?o(t.message):o(`Unknown error occurred during multiple encoding in parser ${r} with input ${JSON.stringify(e)}`)}}return{decodeUplink:l,decodeHexUplink:u,encodeDownlink:d,encodeMultipleDownlinks:f,adjustMeasuringRange:(e,n)=>{if(!(e in a))throw Error(`Channel ${e} does not exist in parser ${r}. Cannot adjust measuring range.`);if(a[e])throw Error(`Channel ${e} does not allow adjusting the measuring range in parser ${r}.`);t.forEach(t=>{t.adjustMeasuringRange(e,n)})},adjustRoundingDecimals:e=>{let n=getRoundingDecimals(e,i);t.forEach(e=>{e.adjustRoundingDecimals(n)})}}}function defineTULIP2Codec(e){let t=`${e.deviceName}TULIP2`,n=getRoundingDecimals(e.roundingDecimals);checkChannelsValidity(e.channels),e.channels.forEach((e,n,r)=>{let i=r.find((t,r)=>t.channelId===e.channelId&&r!==n);if(i)throw Error(`Duplicate channel ID found: ${e.channelId} for channels ${e.name} and ${i.name} in ${t} Codec`)});function r(t){let n=t.bytes[0];return typeof n==`number`&&n in e.handlers}function i(r){let i=r.bytes[0];if(typeof i!=`number`)throw TypeError(`Input must have at least one byte for ${t} Codec`);let a=e.handlers[i];if(a)return a(r,{roundingDecimals:n,channels:e.channels});throw TypeError(`No handler registered for byte ${i} in ${t} Codec`)}function a(){return e.channels.map(e=>_objectSpread2({end:e.end,name:e.name,start:e.start},e.adjustMeasurementRangeDisallowed?{adjustMeasurementRangeDisallowed:!0}:{}))}let s={name:t,protocol:`TULIP2`,getChannels:a,canTryDecode:r,decode:i,adjustMeasuringRange:(t,n)=>{let r=e.channels.find(e=>e.name===t);if(!r)throw Error(`Channel ${t} not found in ${e.deviceName}TULIP2 Codec`);r.start=n.start,r.end=n.end},adjustRoundingDecimals:e=>{n=getRoundingDecimals(e,n)}};return e.encoderFactory&&(s.encode=e.encoderFactory({getChannels:()=>e.channels})),e.multipleEncodeFactory&&(s.encodeMultiple=e.multipleEncodeFactory({getChannels:()=>e.channels})),s}function createConfigurationIdSchema(e){return optional(pipe(number(`configurationId needs to be a number`),minValue(1,`configurationId needs to be at least 1`),maxValue(e,`configurationId needs to be at most ${e}`),integer(`configurationId needs to be an integer`)))}function createByteLimitSchema(){return optional(pipe(number(),minValue(0),integer()))}function createGenericTULIP2DownlinkActionSchema(e){let t=e.meta?.configurationId??!0,n=e.meta?.byteLimit??!0,r=e.extension??{};return object(_objectSpread2(t&&n?{deviceAction:literal(e.action),configurationId:createConfigurationIdSchema(e.maxConfigId),byteLimit:createByteLimitSchema()}:t?{deviceAction:literal(e.action),configurationId:createConfigurationIdSchema(e.maxConfigId)}:n?{deviceAction:literal(e.action),byteLimit:createByteLimitSchema()}:{deviceAction:literal(e.action)},r))}function createTULIP2DownlinkActionSchemaFactory(e){return t=>createGenericTULIP2DownlinkActionSchema({action:t.action,maxConfigId:e,extension:t.extension,meta:t.meta})}function createTulip2DownlinkMainConfigurationSchema(e){let t={publicationFactorWhenAlarm:pipe(number(),minValue(1),maxValue(2880),integer()),publicationFactorWhenNoAlarm:pipe(number(),minValue(1),maxValue(2880),integer())};return e.mainConfigBLE&&Object.assign(t,{isBLEEnabled:boolean()}),e.mainConfigSingleMeasuringRate?Object.assign(t,{measuringRate:pipe(number(),minValue(60),maxValue(86400),integer())}):Object.assign(t,{measuringRateWhenNoAlarm:pipe(number(),minValue(60),maxValue(86400),integer()),measuringRateWhenAlarm:pipe(number(),minValue(60),maxValue(86400),integer())}),object(t)}function createTulip2DownlinkChannelSchema(e,t,n){let r=e.end-e.start,i=n?.deadBandMaxSpanFactor??1,a=n?.slopeMaxSpanFactor??1,o=n?.measureOffsetMinSpanFactor??1,s=n?.measureOffsetMaxSpanFactor??1,c={alarms:optional(object({deadBand:pipe(number(),minValue(0),maxValue(r*i),transform(e=>Math.round(e/r*100*100))),lowThreshold:optional(pipe(number(),minValue(e.start),maxValue(e.end),transform(t=>Math.round((t-e.start)/r*100*100+2500)))),highThreshold:optional(pipe(number(),minValue(e.start),maxValue(e.end),transform(t=>Math.round((t-e.start)/r*100*100+2500)))),lowThresholdWithDelay:optional(object({value:pipe(number(),minValue(e.start),maxValue(e.end),transform(t=>Math.round((t-e.start)/r*100*100+2500))),delay:pipe(number(),minValue(0),maxValue(65535),integer())})),highThresholdWithDelay:optional(object({value:pipe(number(),minValue(e.start),maxValue(e.end),transform(t=>Math.round((t-e.start)/r*100*100+2500))),delay:pipe(number(),minValue(0),maxValue(65535),integer())})),risingSlope:optional(pipe(number(),minValue(0),maxValue(r*a),transform(e=>Math.round(e/r*100*100)))),fallingSlope:optional(pipe(number(),minValue(0),maxValue(r*a),transform(e=>Math.round(e/r*100*100))))}))};return t.channelsStartupTime&&Object.assign(c,{startUpTime:optional(pipe(number(),minValue(.1),maxValue(15),transform(e=>Math.round(e*10))))}),t.channelsMeasureOffset&&Object.assign(c,{measureOffset:optional(pipe(number(),minValue(-o*r),maxValue(s*r),transform(e=>Math.round(e/r*100*100))))}),object(c)}function createTULIP2DownlinkConfigurationActionSchema(e,t,n){let r=createTULIP2DownlinkActionSchemaFactory(t.maxConfigId),i=new Set(t.channelsBooleanOnly??[]),a=e.reduce((e,r)=>{let a=`channel${r.channelId}`;return i.has(a)?(e[a]=optional(union([literal(!1),literal(!0)])),e):(e[a]=optional(union([literal(!1),literal(!0),createTulip2DownlinkChannelSchema(r,t,n)])),e)},{});return r({action:`configuration`,extension:_objectSpread2({mainConfiguration:optional(createTulip2DownlinkMainConfigurationSchema(t))},a)})}function createDownlinkResetToFactorySchema(){return object({deviceAction:literal(`resetToFactory`)})}function createDownlinkResetBatteryIndicatorSchema(e){return createTULIP2DownlinkActionSchemaFactory(e.maxConfigId)({action:`resetBatteryIndicator`,meta:{byteLimit:!1}})}function createTULIP2DownlinkSchema(e,t,n,r){return variant(`deviceAction`,[createDownlinkResetToFactorySchema(),createTULIP2DownlinkConfigurationActionSchema(e,t,r),...n??[]])}function validateTULIP2DownlinkInput(e,t,n,r,i){let a=safeParse(createTULIP2DownlinkSchema(t,n,r,i),e);if(!a.success)throw Error(summarize(a.issues));return a.output}const PGWTULIP2_CHANNEL_0={name:`pressure`,channelId:0,defaultRange:{start:0,end:10}},PGWTULIP2_CHANNEL_1={name:`device temperature`,channelId:1,defaultRange:{start:-40,end:60}};function createTULIP2PGWChannels(){return[{channelId:PGWTULIP2_CHANNEL_0.channelId,name:PGWTULIP2_CHANNEL_0.name,start:PGWTULIP2_CHANNEL_0.defaultRange.start,end:PGWTULIP2_CHANNEL_0.defaultRange.end},{channelId:PGWTULIP2_CHANNEL_1.channelId,name:PGWTULIP2_CHANNEL_1.name,start:PGWTULIP2_CHANNEL_1.defaultRange.start,end:PGWTULIP2_CHANNEL_1.defaultRange.end,adjustMeasurementRangeDisallowed:!0}]}const PGW_DOWNLINK_FEATURE_FLAGS={maxConfigId:127,channelsStartupTime:!1,channelsMeasureOffset:!1,channelsBooleanOnly:[`channel1`],mainConfigBLE:!1,mainConfigSingleMeasuringRate:!0},PGW_COMMANDS={RESET_FACTORY:1,SET_MAIN_CONFIG:2,DISABLE_PRESSURE:16,DISABLE_TEMPERATURE:17,SET_PRESSURE_ALARM:32,RESET_BATTERY:64};function getChannelKeys(e){return Object.keys(e).filter(e=>/^channel\d+$/.test(e))}function formatMainConfigurationInput(e){return e.mainConfiguration}function formatDisableChannelInput(e){let t={},n=!1,r=getChannelKeys(e);for(let i of r)e[i]===!1&&(t[i]=!0,n=!0);return n?t:void 0}function formatProcessAlarmInput(e){let t={},n=!1,r=getChannelKeys(e);for(let i of r){let r=e[i];r&&(r===!0?(t[i]=!0,n=!0):typeof r==`object`&&`alarms`in r&&typeof r.alarms==`object`&&(t[i]=r.alarms,n=!0))}return n?t:void 0}function formatDownlinkOutput(e){return{bytes:e,fPort:1}}function formatMultipleDownlinkOutput(e){return{frames:e,fPort:1}}function pushUint16(e,t){e.push(t>>8&255,t&255)}function buildResetFactoryCommand(){return[PGW_COMMANDS.RESET_FACTORY]}function buildResetBatteryCommand(){return[PGW_COMMANDS.RESET_BATTERY]}function buildPGWMainConfigCommand(e,t){if(!e)return[];if(e.measuringRate%10!=0)throw Error(`Main configuration measuringRate must be a multiple of 10 seconds.`);let n=e.measuringRate/10;if(n<1||n>65535)throw Error(`Main configuration measuringRate must be between 10 and 655350 seconds.`);let r=[PGW_COMMANDS.SET_MAIN_CONFIG];if(pushUint16(r,n),pushUint16(r,e.publicationFactorWhenNoAlarm),pushUint16(r,e.publicationFactorWhenAlarm),r.length>t)throw Error(`Main configuration command exceeds byte limit of ${t} bytes.`);return[r]}function buildPGWDisableChannelCommands(e){if(!e)return[];let t=[];return e.channel0===!0&&t.push([PGW_COMMANDS.DISABLE_PRESSURE]),e.channel1===!0&&t.push([PGW_COMMANDS.DISABLE_TEMPERATURE]),t}function buildPGWProcessAlarmCommands(e){if(!e)return[];if(e.channel1!==void 0)throw Error(`PGW TULIP2 does not support device temperature process-alarm configuration commands.`);return e.channel0===void 0?[]:[buildPGWProcessAlarmBytes(e.channel0)]}function buildPGWProcessAlarmBytes(e){let t=[PGW_COMMANDS.SET_PRESSURE_ALARM];if(e===!0)return t.push(0,0),t.push(0),t;pushUint16(t,e.deadBand);let n=0;return e.lowThreshold!==void 0&&(n|=128),e.highThreshold!==void 0&&(n|=64),e.fallingSlope!==void 0&&(n|=32),e.risingSlope!==void 0&&(n|=16),e.lowThresholdWithDelay!==void 0&&(n|=8),e.highThresholdWithDelay!==void 0&&(n|=4),t.push(n),e.lowThreshold!==void 0&&pushUint16(t,e.lowThreshold),e.highThreshold!==void 0&&pushUint16(t,e.highThreshold),e.fallingSlope!==void 0&&pushUint16(t,e.fallingSlope),e.risingSlope!==void 0&&pushUint16(t,e.risingSlope),e.lowThresholdWithDelay!==void 0&&(pushUint16(t,e.lowThresholdWithDelay.value),pushUint16(t,e.lowThresholdWithDelay.delay)),e.highThresholdWithDelay!==void 0&&(pushUint16(t,e.highThresholdWithDelay.value),pushUint16(t,e.highThresholdWithDelay.delay)),t}function ffd(e,t){if(t=Math.floor(t),t<=0)throw Error(`Limit must be greater than 0`);let n=[];return e.sort((e,t)=>t.length-e.length).forEach(e=>{let r=e.length;if(r>t)throw Error(`Packet is too big to fit in any bin`);let i=!1;for(let a of n)if(t-a.length>=r){a.push(...e),i=!0;break}i||n.push(e)}),n}function buildPGWDownlinkFrame(e,t){if(e.length===0)throw Error(`No Downlink commands were provided to build the downlink frame.`);let n=[t.configId,0];for(let t of e)n.push(...t);if(n.length>t.byteLimit)throw Error(`Downlink frame exceeds byte limit of ${t.byteLimit} bytes (got ${n.length} bytes).`);return n}function buildPGWDownlinkFrames(e,t){if(e.length===0)throw Error(`No Downlink commands were provided for encoding.`);let n=ffd(e,t.byteLimit-2),r=n.length-1,i=[];for(let e=0;e<n.length;e++){let a=e<<4|r;i.push([t.configId,a,...n[e]])}return i}function PGWTULIP2EncodeHandler(e,t=!1){switch(e.deviceAction){case`resetToFactory`:{let e=encodeResetToFactory();return t?formatMultipleDownlinkOutput([e]):formatDownlinkOutput(e)}case`resetBatteryIndicator`:{let n=encodeResetBatteryIndicator(e);return t?formatMultipleDownlinkOutput([n]):formatDownlinkOutput(n)}case`configuration`:return encodeDownlinkConfiguration(e,t);default:throw Error(`Unknown device action: ${e.deviceAction}`)}}function encodeResetToFactory(){return buildPGWDownlinkFrame([buildResetFactoryCommand()],{configId:1,maxConfigId:PGW_DOWNLINK_FEATURE_FLAGS.maxConfigId,byteLimit:1/0})}function encodeResetBatteryIndicator(e){let t=e.configurationId??1;return buildPGWDownlinkFrame([buildResetBatteryCommand()],{configId:t,maxConfigId:PGW_DOWNLINK_FEATURE_FLAGS.maxConfigId,byteLimit:1/0})}function encodeDownlinkConfiguration(e,t){let n=e.configurationId??1,r=e.byteLimit??51,i=r-2,a=[...buildPGWMainConfigCommand(formatMainConfigurationInput(e),i),...buildPGWDisableChannelCommands(formatDisableChannelInput(e)),...buildPGWProcessAlarmCommands(formatProcessAlarmInput(e))];if(a.length===0)throw Error(`No configuration commands were provided for the downlink frame.`);return t?formatMultipleDownlinkOutput(buildPGWDownlinkFrames(a,{configId:n,maxConfigId:PGW_DOWNLINK_FEATURE_FLAGS.maxConfigId,byteLimit:r})):formatDownlinkOutput(buildPGWDownlinkFrame(a,{configId:n,byteLimit:r,maxConfigId:PGW_DOWNLINK_FEATURE_FLAGS.maxConfigId}))}const MEASUREMENT_CHANNELS={pressure:0,"device temperature":1,"battery voltage":2},PROCESS_ALARM_TYPES={"low threshold":0,"high threshold":1,"falling slope":2,"rising slope":3,"low threshold with delay":4,"high threshold with delay":5},ALARM_EVENTS={triggered:0,disappeared:1},TECHNICAL_ALARM_CAUSE_OF_FAILURE={"":0,"general failure":1},DEVICE_ALARM_CAUSE_OF_FAILURE={"":0,"device dependent":1},DEVICE_ALARM_TYPES={"low temperature alarm":0},PRESSURE_TYPES={absolute:1,relative:2,differential:3},PRESSURE_UNITS={inH2O:1,inHg:2,ftH2O:3,mmH2O:4,mmHg:5,psi:6,bar:7,mbar:8,"g/cm²":9,"kg/cm²":10,Pa:11,kPa:12,Torr:13,at:14,"inH2O (60 °F)":145,"cmH2O (4 °C)":170,"mH2O (4 °C)":171,cmHg:172,"lb/ft²":173,hPa:174,psia:175,"kg/m²":176,"ftH2O (4 °C)":177,"ftH2O (60 °F)":178,mHg:179,Mpsi:180,MPa:237,"inH2O (4 °C)":238,"mmH2O (4 °C)":239},TEMPERATURE_UNITS={"°C":32,"°F":33},ERROR_VALUE=65535,pgwEncoderFactory=e=>{let t=PGW_DOWNLINK_FEATURE_FLAGS;return n=>PGWTULIP2EncodeHandler(validateTULIP2DownlinkInput(n,e.getChannels(),t,[createDownlinkResetBatteryIndicatorSchema(t)]))},pgwMultipleEncodeFactory=e=>{let t=PGW_DOWNLINK_FEATURE_FLAGS;return n=>PGWTULIP2EncodeHandler(validateTULIP2DownlinkInput(n,e.getChannels(),t,[createDownlinkResetBatteryIndicatorSchema(t)]),!0)},handleDataMessage=(e,t)=>{if(e.bytes.length!==7)throw Error(`Data message (0x01/0x02) requires 7 bytes, but received ${e.bytes.length} bytes`);let n=e.bytes[0],r=e.bytes[1],i=e.bytes[2],a=e.bytes[3]<<8|e.bytes[4],o=e.bytes[5]<<8|e.bytes[6],s=roundValue(TULIPValueToValue(a,t.channels[0]),t.roundingDecimals),c=roundValue(TULIPValueToValue(o,t.channels[1]),t.roundingDecimals),l=i/10;return{data:{messageType:n,configurationId:r,measurement:{channels:[{channelId:MEASUREMENT_CHANNELS.pressure,channelName:`pressure`,value:s},{channelId:MEASUREMENT_CHANNELS[`device temperature`],channelName:`device temperature`,value:c},{channelId:MEASUREMENT_CHANNELS[`battery voltage`],channelName:`battery voltage`,value:l}]}}}},handleProcessAlarmMessage=(e,t)=>{if(e.bytes.length<5||(e.bytes.length-2)%3!=0)throw Error(`Process alarm message (0x03) requires at least 5 bytes (and target byte count 3n+2), but received ${e.bytes.length} bytes`);let n=e.bytes[1],r=[];for(let n=2;n<e.bytes.length;n+=3){let i=e.bytes[n],a=(i&120)>>3,o=t.channels.find(e=>e.channelId===a);if(!o)throw TypeError(`Unknown channel ID: ${a} in process alarm message`);let s=i&7,c=(i&128)>>7,l=e.bytes[n+1]<<8|e.bytes[n+2],u=roundValue(s===PROCESS_ALARM_TYPES[`falling slope`]||s===PROCESS_ALARM_TYPES[`rising slope`]?slopeValueToValue(l,o):TULIPValueToValue(l,o),t.roundingDecimals);r.push({channelId:a,channelName:o.name,event:c,eventName:Object.keys(ALARM_EVENTS).find(e=>ALARM_EVENTS[e]===c),alarmType:s,alarmTypeName:Object.keys(PROCESS_ALARM_TYPES).find(e=>PROCESS_ALARM_TYPES[e]===s),value:u})}let i=[];for(let e of r)e.value===ERROR_VALUE&&i.push(`Invalid data for ${e.channelName}channel`);let a={data:{messageType:3,configurationId:n,processAlarms:r}};return i.length>0&&(a.warnings=i),a},handleTechnicalAlarmMessage=(e,t)=>{if(e.bytes.length<5||(e.bytes.length-2)%3!=0)throw Error(`Technical alarm message (0x04) requires at least 5 bytes (and target byte count 3n+2), but received ${e.bytes.length} bytes`);let n=e.bytes[1],r=[],i=[];for(let n=2;n<e.bytes.length;n+=3){let a=e.bytes[n],o=(a&128)>>7,s=(a&120)>>3,c=t.channels.find(e=>e.channelId===s);if(!c)throw TypeError(`Unknown channel ID: ${s} in technical alarm message`);let l=a&7,u=roundValue(TULIPValueToValue(e.bytes[n+1]<<8|e.bytes[n+2],c),t.roundingDecimals);u===ERROR_VALUE&&i.push(`Invalid data for ${c.name}channel`),r.push({event:o,eventName:Object.keys(ALARM_EVENTS).find(e=>ALARM_EVENTS[e]===o),channelId:s,channelName:c.name,causeOfFailure:l,causeOfFailureName:Object.keys(TECHNICAL_ALARM_CAUSE_OF_FAILURE).find(e=>TECHNICAL_ALARM_CAUSE_OF_FAILURE[e]===l)??``,value:u})}let a={data:{messageType:4,configurationId:n,technicalAlarms:r}};return i.length>0&&(a.warnings=i),a},handleDeviceAlarmMessage=e=>{if(e.bytes.length!==4)throw Error(`Device alarm message (0x05) requires 4 bytes, but received ${e.bytes.length} bytes`);let t=e.bytes[1],n=e.bytes[2],r=(n&128)>>7,i=(n&96)>>6,a=n&31,o=e.bytes[3]<<24>>24;return{data:{messageType:5,configurationId:t,deviceAlarm:{event:r,eventName:Object.keys(ALARM_EVENTS).find(e=>ALARM_EVENTS[e]===r),causeOfFailure:i,causeOfFailureName:Object.keys(DEVICE_ALARM_CAUSE_OF_FAILURE).find(e=>DEVICE_ALARM_CAUSE_OF_FAILURE[e]===i)??``,alarmType:a,alarmTypeName:Object.keys(DEVICE_ALARM_TYPES).find(e=>DEVICE_ALARM_TYPES[e]===a),value:o}}}},handleDeviceIdentificationMessage=e=>{if(e.bytes.length<41)throw Error(`Device identification message (0x07) requires at least 41 bytes, but received ${e.bytes.length} bytes`);let t=e.bytes[1],n=e.bytes[2],r=n===10?PGW23_100_11_NAME:`${n}`,i=`${e.bytes[3]>>4&15}.${e.bytes[3]&15}.${e.bytes[4]}`,a=`${e.bytes[5]>>4&15}.${e.bytes[5]&15}.${e.bytes[6]}`,o=`${e.bytes[7]>>4&15}.${e.bytes[7]&15}.${e.bytes[8]}`,s=`${e.bytes[9]>>4&15}.${e.bytes[9]&15}.${e.bytes[10]}`,c=``;for(let t=11;t<22;t++){let n=e.bytes[t];if(n===0)break;c+=String.fromCharCode(n)}let l=e.bytes[22],u=Object.entries(PRESSURE_TYPES).find(([,e])=>e===l);if(!u)throw Error(`Unknown pressure type ${l} in device identification message`);let d=u[0],f=intTuple4ToFloat32WithThreshold([e.bytes[26],e.bytes[25],e.bytes[24],e.bytes[23]]),p=intTuple4ToFloat32WithThreshold([e.bytes[30],e.bytes[29],e.bytes[28],e.bytes[27]]),m=intTuple4ToFloat32WithThreshold([e.bytes[34],e.bytes[33],e.bytes[32],e.bytes[31]]),h=intTuple4ToFloat32WithThreshold([e.bytes[38],e.bytes[37],e.bytes[36],e.bytes[35]]),g=e.bytes[39],_=Object.entries(PRESSURE_UNITS).find(([,e])=>e===g);if(!_)throw Error(`Unknown pressure unit ${g} in device identification message`);let v=_[0],y=e.bytes[40],b=Object.entries(TEMPERATURE_UNITS).find(([,e])=>e===y);if(!b)throw Error(`Unknown temperature unit ${y} in device identification message`);let x=b[0];return{data:{messageType:7,configurationId:t,deviceInformation:{productIdName:r,productId:n,wirelessModuleFirmwareVersion:i,wirelessModuleHardwareVersion:a,sensorModuleFirmwareVersion:o,sensorModuleHardwareVersion:s,serialNumber:c,pressureType:d,measurementRangeStartPressure:f,measurementRangeEndPressure:p,measurementRangeStartDeviceTemperature:m,measurementRangeEndDeviceTemperature:h,pressureUnit:g,pressureUnitName:v,deviceTemperatureUnit:y,deviceTemperatureUnitName:x}}}},handleKeepAliveMessage=e=>{if(e.bytes.length!==3)throw Error(`Keep alive message (0x08) requires 3 bytes, but received ${e.bytes.length} bytes`);let t=e.bytes[1],n=e.bytes[2];return{data:{messageType:8,configurationId:t,deviceStatistic:{batteryLevelNewEvent:(n&128)>>7==1,batteryLevelPercent:n&127}}}};function createTULIP2PGWCodec(){return defineTULIP2Codec({deviceName:PGW23_100_11_NAME,roundingDecimals:4,channels:createTULIP2PGWChannels(),handlers:{1:handleDataMessage,2:handleDataMessage,3:handleProcessAlarmMessage,4:handleTechnicalAlarmMessage,5:handleDeviceAlarmMessage,7:handleDeviceIdentificationMessage,8:handleKeepAliveMessage},encoderFactory:pgwEncoderFactory,multipleEncodeFactory:pgwMultipleEncodeFactory})}const PGW23_100_11_NAME=`PGW23.100.11`;function useParser(){return defineParser({parserName:PGW23_100_11_NAME,codecs:[createTULIP2PGWCodec()]})}var require_es7_array_prototype_includes=__commonJSMin((()=>{Array.prototype.includes||Object.defineProperty(Array.prototype,`includes`,{value:function(e,t){if(this==null)throw TypeError(`"this" is null or not defined`);var n=Object(this),r=n.length>>>0;if(r===0)return!1;var i=t|0,a=Math.max(i>=0?i:r-Math.abs(i),0);function o(e,t){return e===t||typeof e==`number`&&typeof t==`number`&&isNaN(e)&&isNaN(t)}for(;a<r;){if(o(n[a],e))return!0;a++}return!1}})})),require_is_implemented$9=__commonJSMin(((e,t)=>{t.exports=function(){var e=Number.isInteger;return typeof e==`function`?!e(`23`)&&e(34)&&!e(32.34):!1}})),require_shim$8=__commonJSMin(((e,t)=>{t.exports=function(e){return typeof e==`number`?e%1==0:!1}})),require_implement$2=__commonJSMin((()=>{require_is_implemented$9()()||Object.defineProperty(Number,`isInteger`,{value:require_shim$8(),configurable:!0,enumerable:!1,writable:!0})})),require_is_implemented$8=__commonJSMin(((e,t)=>{t.exports=function(){return typeof globalThis!=`object`||!globalThis?!1:globalThis.Array===Array}})),require_implementation=__commonJSMin(((e,t)=>{var n=function(){if(typeof self==`object`&&self)return self;if(typeof window==`object`&&window)return window;throw Error("Unable to resolve global `this`")};t.exports=(function(){if(this)return this;try{Object.defineProperty(Object.prototype,`__global__`,{get:function(){return this},configurable:!0})}catch{return n()}try{return __global__||n()}finally{delete Object.prototype.__global__}})()})),require_global_this=__commonJSMin(((e,t)=>{t.exports=require_is_implemented$8()()?globalThis:require_implementation()})),require_is_implemented$7=__commonJSMin(((e,t)=>{var n=require_global_this(),r={object:!0,symbol:!0};t.exports=function(){var e=n.Symbol;return!(typeof e!=`function`||(e(`test symbol`),!r[typeof e.iterator])||!r[typeof e.toPrimitive]||!r[typeof e.toStringTag])}})),require_is$4=__commonJSMin(((e,t)=>{var n=void 0;t.exports=function(e){return e!==n&&e!==null}})),require_is$3=__commonJSMin(((e,t)=>{var n=require_is$4(),r={object:!0,function:!0,undefined:!0};t.exports=function(e){return n(e)?hasOwnProperty.call(r,typeof e):!1}})),require_is$2=__commonJSMin(((e,t)=>{var n=require_is$3();t.exports=function(e){if(!n(e))return!1;try{return e.constructor?e.constructor.prototype===e:!1}catch{return!1}}})),require_is$1=__commonJSMin(((e,t)=>{var n=require_is$2();t.exports=function(e){if(typeof e!=`function`||!hasOwnProperty.call(e,`length`))return!1;try{if(typeof e.length!=`number`||typeof e.call!=`function`||typeof e.apply!=`function`)return!1}catch{return!1}return!n(e)}})),require_is=__commonJSMin(((e,t)=>{var n=require_is$1(),r=/^\s*class[\s{/}]/,i=Function.prototype.toString;t.exports=function(e){return!(!n(e)||r.test(i.call(e)))}})),require_is_implemented$6=__commonJSMin(((e,t)=>{t.exports=function(){var e=Object.assign,t;return typeof e==`function`?(t={foo:`raz`},e(t,{bar:`dwa`},{trzy:`trzy`}),t.foo+t.bar+t.trzy===`razdwatrzy`):!1}})),require_is_implemented$5=__commonJSMin(((e,t)=>{t.exports=function(){try{return!0}catch{return!1}}})),require_noop=__commonJSMin(((e,t)=>{t.exports=function(){}})),require_is_value=__commonJSMin(((e,t)=>{var n=require_noop()();t.exports=function(e){return e!==n&&e!==null}})),require_shim$7=__commonJSMin(((e,t)=>{var n=require_is_value(),r=Object.keys;t.exports=function(e){return r(n(e)?Object(e):e)}})),require_keys=__commonJSMin(((e,t)=>{t.exports=require_is_implemented$5()()?Object.keys:require_shim$7()})),require_valid_value=__commonJSMin(((e,t)=>{var n=require_is_value();t.exports=function(e){if(!n(e))throw TypeError(`Cannot use null or undefined`);return e}})),require_shim$6=__commonJSMin(((e,t)=>{var n=require_keys(),r=require_valid_value(),i=Math.max;t.exports=function(e,t){var a,o,s=i(arguments.length,2),c;for(e=Object(r(e)),c=function(n){try{e[n]=t[n]}catch(e){a||=e}},o=1;o<s;++o)t=arguments[o],n(t).forEach(c);if(a!==void 0)throw a;return e}})),require_assign=__commonJSMin(((e,t)=>{t.exports=require_is_implemented$6()()?Object.assign:require_shim$6()})),require_normalize_options=__commonJSMin(((e,t)=>{var n=require_is_value(),r=Array.prototype.forEach,i=Object.create,a=function(e,t){for(var n in e)t[n]=e[n]};t.exports=function(e){var t=i(null);return r.call(arguments,function(e){n(e)&&a(Object(e),t)}),t}})),require_is_implemented$4=__commonJSMin(((e,t)=>{var n=`razdwatrzy`;t.exports=function(){return typeof n.contains==`function`?n.contains(`dwa`)===!0&&n.contains(`foo`)===!1:!1}})),require_shim$5=__commonJSMin(((e,t)=>{var n=String.prototype.indexOf;t.exports=function(e){return n.call(this,e,arguments[1])>-1}})),require_contains=__commonJSMin(((e,t)=>{t.exports=require_is_implemented$4()()?String.prototype.contains:require_shim$5()})),require_d=__commonJSMin(((e,t)=>{var n=require_is$4(),r=require_is(),i=require_assign(),a=require_normalize_options(),o=require_contains(),s=t.exports=function(e,t){var r,s,c,l,u;return arguments.length<2||typeof e!=`string`?(l=t,t=e,e=null):l=arguments[2],n(e)?(r=o.call(e,`c`),s=o.call(e,`e`),c=o.call(e,`w`)):(r=c=!0,s=!1),u={value:t,configurable:r,enumerable:s,writable:c},l?i(a(l),u):u};s.gs=function(e,t,s){var c,l,u,d;return typeof e==`string`?u=arguments[3]:(u=s,s=t,t=e,e=null),n(t)?r(t)?n(s)?r(s)||(u=s,s=void 0):s=void 0:(u=t,t=s=void 0):t=void 0,n(e)?(c=o.call(e,`c`),l=o.call(e,`e`)):(c=!0,l=!1),d={get:t,set:s,configurable:c,enumerable:l},u?i(a(u),d):d}})),require_is_symbol=__commonJSMin(((e,t)=>{t.exports=function(e){return e?typeof e==`symbol`?!0:!e.constructor||e.constructor.name!==`Symbol`?!1:e[e.constructor.toStringTag]===`Symbol`:!1}})),require_validate_symbol=__commonJSMin(((e,t)=>{var n=require_is_symbol();t.exports=function(e){if(!n(e))throw TypeError(e+` is not a symbol`);return e}})),require_generate_name=__commonJSMin(((e,t)=>{var n=require_d(),r=Object.create,i=Object.defineProperty,a=Object.prototype,o=r(null);t.exports=function(e){for(var t=0,r,s;o[e+(t||``)];)++t;return e+=t||``,o[e]=!0,r=`@@`+e,i(a,r,n.gs(null,function(e){s||=(s=!0,i(this,r,n(e)),!1)})),r}})),require_standard_symbols=__commonJSMin(((e,t)=>{var n=require_d(),r=require_global_this().Symbol;t.exports=function(e){return Object.defineProperties(e,{hasInstance:n(``,r&&r.hasInstance||e(`hasInstance`)),isConcatSpreadable:n(``,r&&r.isConcatSpreadable||e(`isConcatSpreadable`)),iterator:n(``,r&&r.iterator||e(`iterator`)),match:n(``,r&&r.match||e(`match`)),replace:n(``,r&&r.replace||e(`replace`)),search:n(``,r&&r.search||e(`search`)),species:n(``,r&&r.species||e(`species`)),split:n(``,r&&r.split||e(`split`)),toPrimitive:n(``,r&&r.toPrimitive||e(`toPrimitive`)),toStringTag:n(``,r&&r.toStringTag||e(`toStringTag`)),unscopables:n(``,r&&r.unscopables||e(`unscopables`))})}})),require_symbol_registry=__commonJSMin(((e,t)=>{var n=require_d(),r=require_validate_symbol(),i=Object.create(null);t.exports=function(e){return Object.defineProperties(e,{for:n(function(t){return i[t]?i[t]:i[t]=e(String(t))}),keyFor:n(function(e){for(var t in r(e),i)if(i[t]===e)return t})})}})),require_polyfill=__commonJSMin(((e,t)=>{var n=require_d(),r=require_validate_symbol(),i=require_global_this().Symbol,a=require_generate_name(),o=require_standard_symbols(),s=require_symbol_registry(),c=Object.create,l=Object.defineProperties,u=Object.defineProperty,d,f,p;if(typeof i==`function`)try{String(i()),p=!0}catch{}else i=null;f=function(e){if(this instanceof f)throw TypeError(`Symbol is not a constructor`);return d(e)},t.exports=d=function e(t){var r;if(this instanceof e)throw TypeError(`Symbol is not a constructor`);return p?i(t):(r=c(f.prototype),t=t===void 0?``:String(t),l(r,{__description__:n(``,t),__name__:n(``,a(t))}))},o(d),s(d),l(f.prototype,{constructor:n(d),toString:n(``,function(){return this.__name__})}),l(d.prototype,{toString:n(function(){return`Symbol (`+r(this).__description__+`)`}),valueOf:n(function(){return r(this)})}),u(d.prototype,d.toPrimitive,n(``,function(){var e=r(this);return typeof e==`symbol`?e:e.toString()})),u(d.prototype,d.toStringTag,n(`c`,`Symbol`)),u(f.prototype,d.toStringTag,n(`c`,d.prototype[d.toStringTag])),u(f.prototype,d.toPrimitive,n(`c`,d.prototype[d.toPrimitive]))})),require_es6_symbol=__commonJSMin(((e,t)=>{t.exports=require_is_implemented$7()()?require_global_this().Symbol:require_polyfill()})),require_is_implemented$3=__commonJSMin(((e,t)=>{var n=require_es6_symbol().iterator;t.exports=function(){var e=[`foo`,1],t,r;return!(typeof e[n]!=`function`||(t=e[n](),!t)||typeof t.next!=`function`||(r=t.next(),!r)||r.value!==`foo`||r.done!==!1)}})),require_is_implemented$2=__commonJSMin(((e,t)=>{var n=Object.create,r=Object.getPrototypeOf,i={};t.exports=function(){var e=Object.setPrototypeOf,t=arguments[0]||n;return typeof e==`function`?r(e(t(null),i))===i:!1}})),require_is_object=__commonJSMin(((e,t)=>{var n=require_is_value(),r={function:!0,object:!0};t.exports=function(e){return n(e)&&r[typeof e]||!1}})),require_create=__commonJSMin(((e,t)=>{var n=Object.create,r;require_is_implemented$2()()||(r=require_shim$4()),t.exports=(function(){var e,t,i;return!r||r.level!==1?n:(e={},t={},i={configurable:!1,enumerable:!1,writable:!0,value:void 0},Object.getOwnPropertyNames(Object.prototype).forEach(function(e){if(e===`__proto__`){t[e]={configurable:!0,enumerable:!1,writable:!0,value:void 0};return}t[e]=i}),Object.defineProperties(e,t),Object.defineProperty(r,`nullPolyfill`,{configurable:!1,enumerable:!1,writable:!1,value:e}),function(t,r){return n(t===null?e:t,r)})})()})),require_shim$4=__commonJSMin(((e,t)=>{var n=require_is_object(),r=require_valid_value(),i=Object.prototype.isPrototypeOf,a=Object.defineProperty,o={configurable:!0,enumerable:!1,writable:!0,value:void 0},s=function(e,t){if(r(e),t===null||n(t))return e;throw TypeError(`Prototype must be null or an object`)};t.exports=(function(e){var t,n;return e?(e.level===2?e.set?(n=e.set,t=function(e,t){return n.call(s(e,t),t),e}):t=function(e,t){return s(e,t).__proto__=t,e}:t=function e(t,n){var r;return s(t,n),r=i.call(e.nullPolyfill,t),r&&delete e.nullPolyfill.__proto__,n===null&&(n=e.nullPolyfill),t.__proto__=n,r&&a(e.nullPolyfill,`__proto__`,o),t},Object.defineProperty(t,`level`,{configurable:!1,enumerable:!1,writable:!1,value:e.level})):null})((function(){var e=Object.create(null),t={},n,r=Object.getOwnPropertyDescriptor(Object.prototype,`__proto__`);if(r){try{n=r.set,n.call(e,t)}catch{}if(Object.getPrototypeOf(e)===t)return{set:n,level:2}}return e.__proto__=t,Object.getPrototypeOf(e)===t?{level:2}:(e={},e.__proto__=t,Object.getPrototypeOf(e)===t?{level:1}:!1)})()),require_create()})),require_set_prototype_of=__commonJSMin(((e,t)=>{t.exports=require_is_implemented$2()()?Object.setPrototypeOf:require_shim$4()})),require_clear=__commonJSMin(((e,t)=>{var n=require_valid_value();t.exports=function(){return n(this).length=0,this}})),require_valid_callable=__commonJSMin(((e,t)=>{t.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function`);return e}})),require_coerce=__commonJSMin(((e,t)=>{var n=require_is$4(),r=require_is$3(),i=Object.prototype.toString;t.exports=function(e){if(!n(e))return null;if(r(e)){var t=e.toString;if(typeof t!=`function`||t===i)return null}try{return``+e}catch{return null}}})),require_safe_to_string=__commonJSMin(((e,t)=>{t.exports=function(e){try{return e.toString()}catch{try{return String(e)}catch{return null}}}})),require_to_short_string=__commonJSMin(((e,t)=>{var n=require_safe_to_string(),r=/[\n\r\u2028\u2029]/g;t.exports=function(e){var t=n(e);return t===null?`<Non-coercible to string value>`:(t.length>100&&(t=t.slice(0,99)+`…`),t=t.replace(r,function(e){switch(e){case` `:return`\\n`;case`\r`:return`\\r`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:throw Error(`Unexpected character`)}}),t)}})),require_resolve_error_message=__commonJSMin(((e,t)=>{var n=require_coerce(),r=require_to_short_string();t.exports=function(e,t,i){i&&i.errorMessage&&(e=n(i.errorMessage));var a=e.indexOf(`%v`),o=a>-1?r(t):null;if(i&&i.name){var s=e.indexOf(`%n`);if(s>-1){if(a>-1){var c,l,u,d;return s>a?(c=o,u=a,l=i.name,d=s):(c=i.name,u=s,l=o,d=a),e.slice(0,u)+c+e.slice(u+2,d)+l+e.slice(d+2)}return e.slice(0,s)+i.name+e.slice(s+2)}}return a>-1?e.slice(0,a)+o+e.slice(a+2):e}})),require_resolve_exception=__commonJSMin(((e,t)=>{var n=require_is$4(),r=require_resolve_error_message();t.exports=function(e,t,i){if(i&&!n(e)){if(`default`in i)return i.default;if(i.isOptional)return null}var a=new(i&&i.Error||TypeError)(r(t,e,i));throw i&&i.errorCode&&(a.code=i.errorCode),a}})),require_ensure$1=__commonJSMin(((e,t)=>{var n=require_resolve_exception(),r=require_is$4();t.exports=function(e){if(r(e))return e;var t=arguments[1];return n(e,t&&t.name?`Expected a value for %n, received %v`:`Cannot use %v`,t)}})),require_ensure=__commonJSMin(((e,t)=>{var n=require_resolve_exception(),r=require_is();t.exports=function(e){if(r(e))return e;var t=arguments[1];return n(e,t&&t.name?`Expected a plain function for %n, received %v`:`%v is not a plain function`,t)}})),require_is_implemented$1=__commonJSMin(((e,t)=>{t.exports=function(){var e=Array.from,t,n;return typeof e==`function`?(t=[`raz`,`dwa`],n=e(t),!!(n&&n!==t&&n[1]===`dwa`)):!1}})),require_is_arguments=__commonJSMin(((e,t)=>{var n=Object.prototype.toString,r=n.call((function(){return arguments})());t.exports=function(e){return n.call(e)===r}})),require_is_function=__commonJSMin(((e,t)=>{var n=Object.prototype.toString,r=RegExp.prototype.test.bind(/^[object [A-Za-z0-9]*Function]$/);t.exports=function(e){return typeof e==`function`&&r(n.call(e))}})),require_is_implemented=__commonJSMin(((e,t)=>{t.exports=function(){var e=Math.sign;return typeof e==`function`?e(10)===1&&e(-20)===-1:!1}})),require_shim$3=__commonJSMin(((e,t)=>{t.exports=function(e){return e=Number(e),isNaN(e)||e===0?e:e>0?1:-1}})),require_sign=__commonJSMin(((e,t)=>{t.exports=require_is_implemented()()?Math.sign:require_shim$3()})),require_to_integer=__commonJSMin(((e,t)=>{var n=require_sign(),r=Math.abs,i=Math.floor;t.exports=function(e){return isNaN(e)?0:(e=Number(e),e===0||!isFinite(e)?e:n(e)*i(r(e)))}})),require_to_pos_integer=__commonJSMin(((e,t)=>{var n=require_to_integer(),r=Math.max;t.exports=function(e){return r(0,n(e))}})),require_is_string=__commonJSMin(((e,t)=>{var n=Object.prototype.toString,r=n.call(``);t.exports=function(e){return typeof e==`string`||e&&typeof e==`object`&&(e instanceof String||n.call(e)===r)||!1}})),require_shim$2=__commonJSMin(((e,t)=>{var n=require_es6_symbol().iterator,r=require_is_arguments(),i=require_is_function(),a=require_to_pos_integer(),o=require_valid_callable(),s=require_valid_val