@econ-v1/app-sdk 6.16.0 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ var qN=Object.create;var{getPrototypeOf:XN,defineProperty:ct,getOwnPropertyNames
12
12
  To resolve the conflict:`,zi(a,t))}o=c}else Ji.diag.warn("A view or instrument with the name ",t.name,` has already been registered and is incompatible with another registered view.
13
13
  `,`Details:
14
14
  `,Xi(a,t),`To resolve the conflict:
15
- `,zi(a,t))}}catch(u){n={error:u}}finally{try{if(_&&!_.done&&(i=s.return))i.call(s)}finally{if(n)throw n.error}}return o},e}()});var Hm;var Ym=S(()=>{Hm=function(){function e(t){this._backingStorages=t}return e.prototype.record=function(t,r,n,i){this._backingStorages.forEach(function(o){o.record(t,r,n,i)})},e}()});var fe,Fm,jm;var Km=S(()=>{wt();Qr();fe=l(f(),1),Fm=function(){function e(t,r){this._instrumentName=t,this._valueType=r,this._buffer=new Y}return e.prototype.observe=function(t,r){if(r===void 0)r={};if(typeof t!=="number"){fe.diag.warn("non-number value provided to metric "+this._instrumentName+": "+t);return}if(this._valueType===fe.ValueType.INT&&!Number.isInteger(t)){if(fe.diag.warn("INT value type cannot accept a floating-point value for "+this._instrumentName+", ignoring the fractional digits."),t=Math.trunc(t),!Number.isInteger(t))return}this._buffer.set(r,t)},e}(),jm=function(){function e(){this._buffer=new Map}return e.prototype.observe=function(t,r,n){if(n===void 0)n={};if(!Vt(t))return;var i=this._buffer.get(t);if(i==null)i=new Y,this._buffer.set(t,i);if(typeof r!=="number"){fe.diag.warn("non-number value provided to metric "+t._descriptor.name+": "+r);return}if(t._descriptor.valueType===fe.ValueType.INT&&!Number.isInteger(r)){if(fe.diag.warn("INT value type cannot accept a floating-point value for "+t._descriptor.name+", ignoring the fractional digits."),r=Math.trunc(r),!Number.isInteger(r))return}i.set(n,r)},e}()});var qm,$i=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},Zi=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},km=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o},Wm=function(e,t,r){if(r||arguments.length===2){for(var n=0,i=t.length,o;n<i;n++)if(o||!(n in t)){if(!o)o=Array.prototype.slice.call(t,0,n);o[n]=t[n]}}return e.concat(o||Array.prototype.slice.call(t))},Xm;var zm=S(()=>{Qr();Km();H();qm=l(f(),1),Xm=function(){function e(){this._callbacks=[],this._batchCallbacks=[]}return e.prototype.addCallback=function(t,r){var n=this._findCallback(t,r);if(n>=0)return;this._callbacks.push({callback:t,instrument:r})},e.prototype.removeCallback=function(t,r){var n=this._findCallback(t,r);if(n<0)return;this._callbacks.splice(n,1)},e.prototype.addBatchCallback=function(t,r){var n=new Set(r.filter(Vt));if(n.size===0){qm.diag.error("BatchObservableCallback is not associated with valid instruments",r);return}var i=this._findBatchCallback(t,n);if(i>=0)return;this._batchCallbacks.push({callback:t,instruments:n})},e.prototype.removeBatchCallback=function(t,r){var n=new Set(r.filter(Vt)),i=this._findBatchCallback(t,n);if(i<0)return;this._batchCallbacks.splice(i,1)},e.prototype.observe=function(t,r){return $i(this,void 0,void 0,function(){var n,i,o,s;return Zi(this,function(_){switch(_.label){case 0:return n=this._observeCallbacks(t,r),i=this._observeBatchCallbacks(t,r),[4,bh(Wm(Wm([],km(n),!1),km(i),!1))];case 1:return o=_.sent(),s=o.filter(Vh).map(function(c){return c.reason}),[2,s]}})})},e.prototype._observeCallbacks=function(t,r){var n=this;return this._callbacks.map(function(i){var{callback:o,instrument:s}=i;return $i(n,void 0,void 0,function(){var _,c;return Zi(this,function(a){switch(a.label){case 0:if(_=new Fm(s._descriptor.name,s._descriptor.valueType),c=Promise.resolve(o(_)),r!=null)c=pe(c,r);return[4,c];case 1:return a.sent(),s._metricStorages.forEach(function(u){u.record(_._buffer,t)}),[2]}})})})},e.prototype._observeBatchCallbacks=function(t,r){var n=this;return this._batchCallbacks.map(function(i){var{callback:o,instruments:s}=i;return $i(n,void 0,void 0,function(){var _,c;return Zi(this,function(a){switch(a.label){case 0:if(_=new jm,c=Promise.resolve(o(_)),r!=null)c=pe(c,r);return[4,c];case 1:return a.sent(),s.forEach(function(u){var E=_._buffer.get(u);if(E==null)return;u._metricStorages.forEach(function(A){A.record(E,t)})}),[2]}})})})},e.prototype._findCallback=function(t,r){return this._callbacks.findIndex(function(n){return n.callback===t&&n.instrument===r})},e.prototype._findBatchCallback=function(t,r){return this._batchCallbacks.findIndex(function(n){return n.callback===t&&wh(n.instruments,r)})},e}()});var c1,Qm;var Jm=S(()=>{Ki();ki();qi();c1=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),Qm=function(e){c1(t,e);function t(r,n,i,o,s){var _=e.call(this,r)||this;return _._attributesProcessor=i,_._aggregationCardinalityLimit=s,_._deltaMetricStorage=new $r(n,_._aggregationCardinalityLimit),_._temporalMetricStorage=new Zr(n,o),_}return t.prototype.record=function(r,n,i,o){n=this._attributesProcessor.process(n,i),this._deltaMetricStorage.record(r,n,i,o)},t.prototype.collect=function(r,n){var i=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,i,n)},t}(Jr)});var $m,ot,E1,Zm,T1;var ea=S(()=>{$m=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),ot=function(){function e(){}return e.Noop=function(){return T1},e}(),E1=function(e){$m(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.process=function(r,n){return r},t}(ot),Zm=function(e){$m(t,e);function t(r){var n=e.call(this)||this;return n._allowedAttributeNames=r,n}return t.prototype.process=function(r,n){var i=this,o={};return Object.keys(r).filter(function(s){return i._allowedAttributeNames.includes(s)}).forEach(function(s){return o[s]=r[s]}),o},t}(ot),T1=new E1});var S1=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},l1=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},p1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o},eM;var tM=S(()=>{ne();xm();H();wm();Gm();Ym();zm();Jm();ea();eM=function(){function e(t,r){this._meterProviderSharedState=t,this._instrumentationScope=r,this.metricStorageRegistry=new Bm,this.observableRegistry=new Xm,this.meter=new Dm(this)}return e.prototype.registerMetricStorage=function(t){var r=this._registerMetricStorage(t,Qm);if(r.length===1)return r[0];return new Hm(r)},e.prototype.registerAsyncMetricStorage=function(t){var r=this._registerMetricStorage(t,Vm);return r},e.prototype.collect=function(t,r,n){return S1(this,void 0,void 0,function(){var i,o,s;return l1(this,function(_){switch(_.label){case 0:return[4,this.observableRegistry.observe(r,n===null||n===void 0?void 0:n.timeoutMillis)];case 1:if(i=_.sent(),o=this.metricStorageRegistry.getStorages(t),o.length===0)return[2,null];if(s=o.map(function(c){return c.collect(t,r)}).filter(xh),s.length===0)return[2,{errors:i}];return[2,{scopeMetrics:{scope:this._instrumentationScope,metrics:s},errors:i}]}})})},e.prototype._registerMetricStorage=function(t,r){var n=this,i=this._meterProviderSharedState.viewRegistry.findViews(t,this._instrumentationScope),o=i.map(function(c){var a=Yh(c,t),u=n.metricStorageRegistry.findOrUpdateCompatibleStorage(a);if(u!=null)return u;var E=c.aggregation.createAggregator(a),A=new r(a,E,c.attributesProcessor,n._meterProviderSharedState.metricCollectors,c.aggregationCardinalityLimit);return n.metricStorageRegistry.register(A),A});if(o.length===0){var s=this._meterProviderSharedState.selectAggregations(t.type),_=s.map(function(c){var a=p1(c,2),u=a[0],E=a[1],A=n.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(u,t);if(A!=null)return A;var R=E.createAggregator(t),y=u.selectCardinalityLimit(t.type),de=new r(t,R,ot.Noop(),[u],y);return n.metricStorageRegistry.registerForCollector(u,de),de});o=o.concat(_)}return o},e}()});var A1=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&n>=e.length)e=void 0;return{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},rM;var nM=S(()=>{H();Mm();tM();rM=function(){function e(t){this.resource=t,this.viewRegistry=new mm,this.metricCollectors=[],this.meterSharedStates=new Map}return e.prototype.getMeterSharedState=function(t){var r=Uh(t),n=this.meterSharedStates.get(r);if(n==null)n=new eM(this,t),this.meterSharedStates.set(r,n);return n},e.prototype.selectAggregations=function(t){var r,n,i=[];try{for(var o=A1(this.metricCollectors),s=o.next();!s.done;s=o.next()){var _=s.value;i.push([_,_.selectAggregation(t)])}}catch(c){r={error:c}}finally{try{if(s&&!s.done&&(n=o.return))n.call(o)}finally{if(r)throw r.error}}return i},e}()});var oM,en=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},tn=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},f1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o},d1=function(e,t,r){if(r||arguments.length===2){for(var n=0,i=t.length,o;n<i;n++)if(o||!(n in t)){if(!o)o=Array.prototype.slice.call(t,0,n);o[n]=t[n]}}return e.concat(o||Array.prototype.slice.call(t))},iM;var aM=S(()=>{oM=l(M(),1),iM=function(){function e(t,r){this._sharedState=t,this._metricReader=r}return e.prototype.collect=function(t){return en(this,void 0,void 0,function(){var r,n,i,o,s=this;return tn(this,function(_){switch(_.label){case 0:return r=oM.millisToHrTime(Date.now()),n=[],i=[],o=Array.from(this._sharedState.meterSharedStates.values()).map(function(c){return en(s,void 0,void 0,function(){var a;return tn(this,function(u){switch(u.label){case 0:return[4,c.collect(this,r,t)];case 1:if(a=u.sent(),(a===null||a===void 0?void 0:a.scopeMetrics)!=null)n.push(a.scopeMetrics);if((a===null||a===void 0?void 0:a.errors)!=null)i.push.apply(i,d1([],f1(a.errors),!1));return[2]}})})}),[4,Promise.all(o)];case 1:return _.sent(),[2,{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:i}]}})})},e.prototype.forceFlush=function(t){return en(this,void 0,void 0,function(){return tn(this,function(r){switch(r.label){case 0:return[4,this._metricReader.forceFlush(t)];case 1:return r.sent(),[2]}})})},e.prototype.shutdown=function(t){return en(this,void 0,void 0,function(){return tn(this,function(r){switch(r.label){case 0:return[4,this._metricReader.shutdown(t)];case 1:return r.sent(),[2]}})})},e.prototype.selectAggregationTemporality=function(t){return this._metricReader.selectAggregationTemporality(t)},e.prototype.selectAggregation=function(t){return this._metricReader.selectAggregation(t)},e.prototype.selectCardinalityLimit=function(t){var r,n,i;return(i=(n=(r=this._metricReader).selectCardinalityLimit)===null||n===void 0?void 0:n.call(r,t))!==null&&i!==void 0?i:2000},e}()});function R1(e,t){var r=t!==null&&t!==void 0?t:h.empty();if(e)return h.default().merge(r);return r}var it,sM=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},_M=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},uM=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&n>=e.length)e=void 0;return{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},cM;var EM=S(()=>{gr();nM();aM();it=l(f(),1);cM=function(){function e(t){var r,n,i,o,s;if(this._shutdown=!1,this._sharedState=new rM(R1((s=t===null||t===void 0?void 0:t.mergeResourceWithDefaults)!==null&&s!==void 0?s:!0,t===null||t===void 0?void 0:t.resource)),(t===null||t===void 0?void 0:t.views)!=null&&t.views.length>0)try{for(var _=uM(t.views),c=_.next();!c.done;c=_.next()){var a=c.value;this._sharedState.viewRegistry.addView(a)}}catch(R){r={error:R}}finally{try{if(c&&!c.done&&(n=_.return))n.call(_)}finally{if(r)throw r.error}}if((t===null||t===void 0?void 0:t.readers)!=null&&t.readers.length>0)try{for(var u=uM(t.readers),E=u.next();!E.done;E=u.next()){var A=E.value;this.addMetricReader(A)}}catch(R){i={error:R}}finally{try{if(E&&!E.done&&(o=u.return))o.call(u)}finally{if(i)throw i.error}}}return e.prototype.getMeter=function(t,r,n){if(r===void 0)r="";if(n===void 0)n={};if(this._shutdown)return it.diag.warn("A shutdown MeterProvider cannot provide a Meter"),it.createNoopMeter();return this._sharedState.getMeterSharedState({name:t,version:r,schemaUrl:n.schemaUrl}).meter},e.prototype.addMetricReader=function(t){var r=new iM(this._sharedState,t);t.setMetricProducer(r),this._sharedState.metricCollectors.push(r)},e.prototype.shutdown=function(t){return sM(this,void 0,void 0,function(){return _M(this,function(r){switch(r.label){case 0:if(this._shutdown)return it.diag.warn("shutdown may only be called once per MeterProvider"),[2];return this._shutdown=!0,[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.shutdown(t)}))];case 1:return r.sent(),[2]}})})},e.prototype.forceFlush=function(t){return sM(this,void 0,void 0,function(){return _M(this,function(r){switch(r.label){case 0:if(this._shutdown)return it.diag.warn("invalid attempt to force flush after MeterProvider shutdown"),[2];return[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.forceFlush(t)}))];case 1:return r.sent(),[2]}})})},e}()});var O1,rn,at;var nn=S(()=>{O1=/[\^$\\.+?()[\]{}|]/g,rn=function(){function e(t){if(t==="*")this._matchAll=!0,this._regexp=/.*/;else this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t))}return e.prototype.match=function(t){if(this._matchAll)return!0;return this._regexp.test(t)},e.escapePattern=function(t){return"^"+t.replace(O1,"\\$&").replace("*",".*")+"$"},e.hasWildcard=function(t){return t.includes("*")},e}(),at=function(){function e(t){this._matchAll=t===void 0,this._pattern=t}return e.prototype.match=function(t){if(this._matchAll)return!0;if(t===this._pattern)return!0;return!1},e}()});var TM;var SM=S(()=>{nn();TM=function(){function e(t){var r;this._nameFilter=new rn((r=t===null||t===void 0?void 0:t.name)!==null&&r!==void 0?r:"*"),this._type=t===null||t===void 0?void 0:t.type,this._unitFilter=new at(t===null||t===void 0?void 0:t.unit)}return e.prototype.getType=function(){return this._type},e.prototype.getNameFilter=function(){return this._nameFilter},e.prototype.getUnitFilter=function(){return this._unitFilter},e}()});var lM;var pM=S(()=>{nn();lM=function(){function e(t){this._nameFilter=new at(t===null||t===void 0?void 0:t.name),this._versionFilter=new at(t===null||t===void 0?void 0:t.version),this._schemaUrlFilter=new at(t===null||t===void 0?void 0:t.schemaUrl)}return e.prototype.getNameFilter=function(){return this._nameFilter},e.prototype.getVersionFilter=function(){return this._versionFilter},e.prototype.getSchemaUrlFilter=function(){return this._schemaUrlFilter},e}()});function h1(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}var AM;var fM=S(()=>{nn();ea();SM();pM();Fr();AM=function(){function e(t){var r;if(h1(t))throw Error("Cannot create view with no selector arguments supplied");if(t.name!=null&&((t===null||t===void 0?void 0:t.instrumentName)==null||rn.hasWildcard(t.instrumentName)))throw Error("Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.");if(t.attributeKeys!=null)this.attributesProcessor=new Zm(t.attributeKeys);else this.attributesProcessor=ot.Noop();this.name=t.name,this.description=t.description,this.aggregation=(r=t.aggregation)!==null&&r!==void 0?r:v.Default(),this.instrumentSelector=new TM({name:t.instrumentName,type:t.instrumentType,unit:t.instrumentUnit}),this.meterSelector=new lM({name:t.meterName,version:t.meterVersion,schemaUrl:t.meterSchemaUrl}),this.aggregationCardinalityLimit=t.aggregationCardinalityLimit}return e}()});var dM={};F(dM,{Aggregation:()=>v,AggregationTemporality:()=>C,ConsoleMetricExporter:()=>Om,DataPointType:()=>L,DefaultAggregation:()=>Vi,DropAggregation:()=>Ii,ExplicitBucketHistogramAggregation:()=>Ui,ExponentialHistogramAggregation:()=>bi,HistogramAggregation:()=>xi,InMemoryMetricExporter:()=>fm,InstrumentType:()=>d,LastValueAggregation:()=>Di,MeterProvider:()=>cM,MetricReader:()=>Kr,PeriodicExportingMetricReader:()=>pm,SumAggregation:()=>yi,TimeoutError:()=>xt,View:()=>AM});var on=S(()=>{vr();tt();Yi();Am();dm();hm();ne();EM();Fr();fM();H()});function OM(e){var t=BigInt(1e9);return BigInt(e[0])*t+BigInt(e[1])}function m1(e){var t=Number(BigInt.asUintN(32,e)),r=Number(BigInt.asUintN(32,e>>BigInt(32)));return{low:t,high:r}}function hM(e){var t=OM(e);return m1(t)}function M1(e){var t=OM(e);return t.toString()}function RM(e){return e}function mM(e){if(e===void 0)return;return st.hexToBinary(e)}function an(e){var t,r;if(e===void 0)return g1;var n=(t=e.useLongBits)!==null&&t!==void 0?t:!0,i=(r=e.useHex)!==null&&r!==void 0?r:!1;return{encodeHrTime:n?hM:N1,encodeSpanContext:i?RM:st.hexToBinary,encodeOptionalSpanContext:i?RM:mM}}var st,N1,g1;var ta=S(()=>{st=l(M(),1);N1=typeof BigInt<"u"?M1:st.hrTimeToNanoseconds;g1={encodeHrTime:hM,encodeSpanContext:st.hexToBinary,encodeOptionalSpanContext:mM}});function sn(e){return{attributes:ae(e.attributes),droppedAttributesCount:0}}function _n(e){return{name:e.name,version:e.version}}function ae(e){return Object.keys(e).map(function(t){return MM(t,e[t])})}function MM(e,t){return{key:e,value:NM(t)}}function NM(e){var t=typeof e;if(t==="string")return{stringValue:e};if(t==="number"){if(!Number.isInteger(e))return{doubleValue:e};return{intValue:e}}if(t==="boolean")return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:e};if(Array.isArray(e))return{arrayValue:{values:e.map(NM)}};if(t==="object"&&e!=null)return{kvlistValue:{values:Object.entries(e).map(function(r){var n=P1(r,2),i=n[0],o=n[1];return MM(i,o)})}};return{}}var P1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o};function C1(e,t){var r=an(t);return{resource:sn(e.resource),schemaUrl:void 0,scopeMetrics:L1(e.scopeMetrics,r)}}function L1(e,t){return Array.from(e.map(function(r){return{scope:_n(r.scope),metrics:r.metrics.map(function(n){return v1(n,t)}),schemaUrl:r.scope.schemaUrl}}))}function v1(e,t){var r={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},n=x1(e.aggregationTemporality);switch(e.dataPointType){case L.SUM:r.sum={aggregationTemporality:n,isMonotonic:e.isMonotonic,dataPoints:gM(e,t)};break;case L.GAUGE:r.gauge={dataPoints:gM(e,t)};break;case L.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:y1(e,t)};break;case L.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:D1(e,t)};break}return r}function I1(e,t,r){var n={attributes:ae(e.attributes),startTimeUnixNano:r.encodeHrTime(e.startTime),timeUnixNano:r.encodeHrTime(e.endTime)};switch(t){case ra.ValueType.INT:n.asInt=e.value;break;case ra.ValueType.DOUBLE:n.asDouble=e.value;break}return n}function gM(e,t){return e.dataPoints.map(function(r){return I1(r,e.descriptor.valueType,t)})}function y1(e,t){return e.dataPoints.map(function(r){var n=r.value;return{attributes:ae(r.attributes),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function D1(e,t){return e.dataPoints.map(function(r){var n=r.value;return{attributes:ae(r.attributes),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function x1(e){switch(e){case C.DELTA:return 1;case C.CUMULATIVE:return 2}}function PM(e,t){return{resourceMetrics:e.map(function(r){return C1(r,t)})}}var ra;var CM=S(()=>{on();ta();ra=l(f(),1)});var un;var LM=S(()=>{CM();un={serializeRequest:function(e){var t=PM([e],{useLongBits:!1}),r=new TextEncoder;return r.encode(JSON.stringify(t))},deserializeResponse:function(e){var t=new TextDecoder;return JSON.parse(t.decode(e))}}});var vM=S(()=>{LM()});function V1(e,t){var r,n=e.spanContext(),i=e.status;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:t.encodeOptionalSpanContext(e.parentSpanId),traceState:(r=n.traceState)===null||r===void 0?void 0:r.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:ae(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(function(o){return B1(o,t)}),droppedEventsCount:e.droppedEventsCount,status:{code:i.code,message:i.message},links:e.links.map(function(o){return w1(o,t)}),droppedLinksCount:e.droppedLinksCount}}function w1(e,t){var r;return{attributes:e.attributes?ae(e.attributes):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(r=e.context.traceState)===null||r===void 0?void 0:r.serialize(),droppedAttributesCount:e.droppedAttributesCount||0}}function B1(e,t){return{attributes:e.attributes?ae(e.attributes):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function IM(e,t){var r=an(t);return{resourceSpans:H1(e,r)}}function G1(e){var t,r,n=new Map;try{for(var i=U1(e),o=i.next();!o.done;o=i.next()){var s=o.value,_=n.get(s.resource);if(!_)_=new Map,n.set(s.resource,_);var c=s.instrumentationLibrary.name+"@"+(s.instrumentationLibrary.version||"")+":"+(s.instrumentationLibrary.schemaUrl||""),a=_.get(c);if(!a)a=[],_.set(c,a);a.push(s)}}catch(u){t={error:u}}finally{try{if(o&&!o.done&&(r=i.return))r.call(i)}finally{if(t)throw t.error}}return n}function H1(e,t){var r=G1(e),n=[],i=r.entries(),o=i.next();while(!o.done){var s=b1(o.value,2),_=s[0],c=s[1],a=[],u=c.values(),E=u.next();while(!E.done){var A=E.value;if(A.length>0){var R=A.map(function(de){return V1(de,t)});a.push({scope:_n(A[0].instrumentationLibrary),spans:R,schemaUrl:A[0].instrumentationLibrary.schemaUrl})}E=u.next()}var y={resource:sn(_),scopeSpans:a,schemaUrl:void 0};n.push(y),o=i.next()}return n}var U1=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&n>=e.length)e=void 0;return{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},b1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o};var yM=S(()=>{ta()});var cn;var DM=S(()=>{yM();cn={serializeRequest:function(e){var t=IM(e,{useHex:!0,useLongBits:!1}),r=new TextEncoder;return r.encode(JSON.stringify(t))},deserializeResponse:function(e){var t=new TextDecoder;return JSON.parse(t.decode(e))}}});var xM=S(()=>{DM()});var na=S(()=>{vM();xM()});var VM=T(function(UM){Object.defineProperty(UM,"__esModule",{value:!0});UM.parseRetryAfterToMills=UM.isExportRetryable=void 0;function Y1(e){return[429,502,503,504].includes(e)}UM.isExportRetryable=Y1;function F1(e){if(e==null)return;let t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1000:-1;let r=new Date(e).getTime()-Date.now();if(r>=0)return r;return 0}UM.parseRetryAfterToMills=F1});var jM=T(function(YM){Object.defineProperty(YM,"__esModule",{value:!0});YM.createHttpAgent=YM.compressAndSend=YM.sendWithHttp=void 0;var BM=He("http"),GM=He("https"),K1=He("zlib"),k1=He("stream"),wM=VM(),W1=Lr();function q1(e,t,r,n,i){let o=new URL(e.url),s=Number(process.versions.node.split(".")[0]),_={hostname:o.hostname,port:o.port,path:o.pathname,method:"POST",headers:Object.assign({},e.headers()),agent:t},a=(o.protocol==="http:"?BM.request:GM.request)(_,(E)=>{let A=[];E.on("data",(R)=>A.push(R)),E.on("end",()=>{if(E.statusCode&&E.statusCode<299)n({status:"success",data:Buffer.concat(A)});else if(E.statusCode&&(0,wM.isExportRetryable)(E.statusCode))n({status:"retryable",retryInMillis:(0,wM.parseRetryAfterToMills)(E.headers["retry-after"])});else{let R=new W1.OTLPExporterError(E.statusMessage,E.statusCode,Buffer.concat(A).toString());n({status:"failure",error:R})}})});a.setTimeout(i,()=>{a.destroy(),n({status:"failure",error:Error("Request Timeout")})}),a.on("error",(E)=>{n({status:"failure",error:E})});let u=s>=14?"close":"abort";a.on(u,()=>{n({status:"failure",error:Error("Request timed out")})}),HM(a,e.compression,r,(E)=>{n({status:"failure",error:E})})}YM.sendWithHttp=q1;function HM(e,t,r,n){let i=X1(r);if(t==="gzip")e.setHeader("Content-Encoding","gzip"),i=i.on("error",n).pipe(K1.createGzip()).on("error",n);i.pipe(e).on("error",n)}YM.compressAndSend=HM;function X1(e){let t=new k1.Readable;return t.push(e),t.push(null),t}function z1(e,t){return new(new URL(e).protocol==="http:"?BM.Agent:GM.Agent)(t)}YM.createHttpAgent=z1});var qM=T(function(kM){Object.defineProperty(kM,"__esModule",{value:!0});kM.createHttpExporterTransport=void 0;class KM{constructor(e){this._parameters=e,this._send=null,this._agent=null}async send(e,t){if(this._send==null){let{sendWithHttp:r,createHttpAgent:n}=jM();this._agent=n(this._parameters.url,this._parameters.agentOptions),this._send=r}return new Promise((r)=>{var n;(n=this._send)===null||n===void 0||n.call(this,this._parameters,this._agent,e,(i)=>{r(i)},t)})}shutdown(){}}function $1(e){return new KM(e)}kM.createHttpExporterTransport=$1});var $M=T(function(QM){Object.defineProperty(QM,"__esModule",{value:!0});QM.createRetryingTransport=void 0;var Z1=5,eY=1000,tY=5000,rY=1.5,XM=0.2;function nY(){return Math.random()*(2*XM)-XM}class zM{constructor(e){this._transport=e}retry(e,t,r){return new Promise((n,i)=>{setTimeout(()=>{this._transport.send(e,t).then(n,i)},r)})}async send(e,t){var r;let n=Date.now()+t,i=await this._transport.send(e,t),o=Z1,s=eY;while(i.status==="retryable"&&o>0){o--;let _=Math.max(Math.min(s,tY)+nY(),0);s=s*rY;let c=(r=i.retryInMillis)!==null&&r!==void 0?r:_,a=n-Date.now();if(c>a)return i;i=await this.retry(e,a,c)}return i}shutdown(){return this._transport.shutdown()}}function oY(e){return new zM(e.transport)}QM.createRetryingTransport=oY});var tN=T(function(ZM){Object.defineProperty(ZM,"__esModule",{value:!0});ZM.createOtlpHttpExportDelegate=void 0;var iY=fi(),aY=qM(),sY=Ai(),_Y=$M();function uY(e,t){return(0,iY.createOtlpExportDelegate)({transport:(0,_Y.createRetryingTransport)({transport:(0,aY.createHttpExporterTransport)(e)}),serializer:t,promiseHandler:(0,sY.createBoundedQueueExportPromiseHandler)(e)},{timeout:e.timeoutMillis})}ZM.createOtlpHttpExportDelegate=uY});var oa=T(function(iN){Object.defineProperty(iN,"__esModule",{value:!0});iN.getSharedConfigurationFromEnvironment=void 0;var oN=f();function rN(e){var t;let r=(t=process.env[e])===null||t===void 0?void 0:t.trim();if(r!=null&&r!==""){let n=Number(r);if(!Number.isNaN(n)&&Number.isFinite(n)&&n>0)return n;oN.diag.warn(`Configuration: ${e} is invalid, expected number greater than 0 (actual: ${r})`)}return}function cY(e){let t=rN(`OTEL_EXPORTER_OTLP_${e}_TIMEOUT`),r=rN("OTEL_EXPORTER_OTLP_TIMEOUT");return t!==null&&t!==void 0?t:r}function nN(e){var t;let r=(t=process.env[e])===null||t===void 0?void 0:t.trim();if(r==="")return;if(r==null||r==="none"||r==="gzip")return r;oN.diag.warn(`Configuration: ${e} is invalid, expected 'none' or 'gzip' (actual: '${r}')`);return}function EY(e){let t=nN(`OTEL_EXPORTER_OTLP_${e}_COMPRESSION`),r=nN("OTEL_EXPORTER_OTLP_COMPRESSION");return t!==null&&t!==void 0?t:r}function TY(e){return{timeoutMillis:cY(e),compression:EY(e)}}iN.getSharedConfigurationFromEnvironment=TY});var uN=T(function(sN){Object.defineProperty(sN,"__esModule",{value:!0});sN.validateAndNormalizeHeaders=void 0;var SY=f();function lY(e){return()=>{var t;let r={};return Object.entries((t=e===null||e===void 0?void 0:e())!==null&&t!==void 0?t:{}).forEach(([n,i])=>{if(typeof i<"u")r[n]=String(i);else SY.diag.warn(`Header "${n}" has invalid value (${i}) and will be ignored`)}),r}}sN.validateAndNormalizeHeaders=lY});var SN=T(function(EN){Object.defineProperty(EN,"__esModule",{value:!0});EN.getHttpConfigurationDefaults=EN.mergeOtlpHttpConfigurationWithDefaults=void 0;var cN=Dt(),pY=uN();function AY(e,t,r){let n=Object.assign({},r()),i={};return()=>{if(t!=null)Object.assign(i,t());if(e!=null)Object.assign(i,e());return Object.assign(i,n)}}function fY(e){if(e==null)return;try{return new URL(e),e}catch(t){throw Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function dY(e,t,r){var n,i,o,s;return Object.assign(Object.assign({},(0,cN.mergeOtlpSharedConfigurationWithDefaults)(e,t,r)),{headers:AY((0,pY.validateAndNormalizeHeaders)(e.headers),t.headers,r.headers),url:(i=(n=fY(e.url))!==null&&n!==void 0?n:t.url)!==null&&i!==void 0?i:r.url,agentOptions:(s=(o=e.agentOptions)!==null&&o!==void 0?o:t.agentOptions)!==null&&s!==void 0?s:r.agentOptions})}EN.mergeOtlpHttpConfigurationWithDefaults=dY;function RY(e,t){return Object.assign(Object.assign({},(0,cN.getSharedConfigurationDefaults)()),{headers:()=>e,url:"http://localhost:4318/"+t,agentOptions:{keepAlive:!0}})}EN.getHttpConfigurationDefaults=RY});var AN=T(function(lN){Object.defineProperty(lN,"__esModule",{value:!0});lN.getHttpConfigurationFromEnvironment=void 0;var En=M(),ia=f(),hY=oa(),mY=Dt();function MY(e){var t,r;let n=(t=process.env[`OTEL_EXPORTER_OTLP_${e}_HEADERS`])===null||t===void 0?void 0:t.trim(),i=(r=process.env.OTEL_EXPORTER_OTLP_HEADERS)===null||r===void 0?void 0:r.trim(),o=En.baggageUtils.parseKeyPairsIntoRecord(n),s=En.baggageUtils.parseKeyPairsIntoRecord(i);if(Object.keys(o).length===0&&Object.keys(s).length===0)return;return Object.assign({},En.baggageUtils.parseKeyPairsIntoRecord(i),En.baggageUtils.parseKeyPairsIntoRecord(n))}function NY(e){try{return new URL(e).toString()}catch(t){ia.diag.warn(`Configuration: Could not parse environment-provided export URL: '${e}', falling back to undefined`);return}}function gY(e,t){try{new URL(e)}catch(r){ia.diag.warn(`Configuration: Could not parse environment-provided export URL: '${e}', falling back to undefined`);return}if(!e.endsWith("/"))e=e+"/";e+=t;try{new URL(e)}catch(r){ia.diag.warn(`Configuration: Provided URL appended with '${t}' is not a valid URL, using 'undefined' instead of '${e}'`);return}return e}function PY(e){var t;let r=(t=process.env.OTEL_EXPORTER_OTLP_ENDPOINT)===null||t===void 0?void 0:t.trim();if(r==null||r==="")return;return gY(r,e)}function CY(e){var t;let r=(t=process.env[`OTEL_EXPORTER_OTLP_${e}_ENDPOINT`])===null||t===void 0?void 0:t.trim();if(r==null||r==="")return;return NY(r)}function LY(e,t){var r;return Object.assign(Object.assign({},(0,hY.getSharedConfigurationFromEnvironment)(e)),{url:(r=CY(e))!==null&&r!==void 0?r:PY(t),headers:(0,mY.wrapStaticHeadersInFunction)(MY(e))})}lN.getHttpConfigurationFromEnvironment=LY});var ON=T(function(dN){Object.defineProperty(dN,"__esModule",{value:!0});dN.convertLegacyHttpOptions=void 0;var fN=SN(),vY=AN(),IY=f(),yY=Dt();function DY(e){if((e===null||e===void 0?void 0:e.keepAlive)!=null)if(e.httpAgentOptions!=null){if(e.httpAgentOptions.keepAlive==null)e.httpAgentOptions.keepAlive=e.keepAlive}else e.httpAgentOptions={keepAlive:e.keepAlive};return e.httpAgentOptions}function xY(e,t,r,n){if(e.metadata)IY.diag.warn("Metadata cannot be set when using http");return(0,fN.mergeOtlpHttpConfigurationWithDefaults)({url:e.url,headers:(0,yY.wrapStaticHeadersInFunction)(e.headers),concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis,compression:e.compression,agentOptions:DY(e)},(0,vY.getHttpConfigurationFromEnvironment)(t,r),(0,fN.getHttpConfigurationDefaults)(n,r))}dN.convertLegacyHttpOptions=xY});var aa=T(function(Bt){Object.defineProperty(Bt,"__esModule",{value:!0});Bt.convertLegacyHttpOptions=Bt.getSharedConfigurationFromEnvironment=Bt.createOtlpHttpExportDelegate=void 0;var UY=tN();Object.defineProperty(Bt,"createOtlpHttpExportDelegate",{enumerable:!0,get:function(){return UY.createOtlpHttpExportDelegate}});var bY=oa();Object.defineProperty(Bt,"getSharedConfigurationFromEnvironment",{enumerable:!0,get:function(){return bY.getSharedConfigurationFromEnvironment}});var VY=ON();Object.defineProperty(Bt,"convertLegacyHttpOptions",{enumerable:!0,get:function(){return VY.convertLegacyHttpOptions}})});var hN,Tn,BY,GY;var mN=S(()=>{na();hN=l(di(),1),Tn=l(aa(),1),BY=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),GY=function(e){BY(t,e);function t(r){if(r===void 0)r={};return e.call(this,Tn.createOtlpHttpExportDelegate(Tn.convertLegacyHttpOptions(r,"TRACES","v1/traces",{"User-Agent":"OTel-OTLP-Exporter-JavaScript/"+Ih,"Content-Type":"application/json"}),cn))||this}return t}(hN.OTLPExporterBase)});var MN=S(()=>{mN()});var NN=S(()=>{MN()});var gN={};F(gN,{OTLPTraceExporter:()=>GY});var PN=S(()=>{NN()});var Be;var sa=S(()=>{(function(e){e[e.DELTA=0]="DELTA",e[e.CUMULATIVE=1]="CUMULATIVE",e[e.LOWMEMORY=2]="LOWMEMORY"})(Be||(Be={}))});function YY(){var e=CN.getEnv(),t=e.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.trim().toLowerCase();if(t==="cumulative")return Gt;if(t==="delta")return Sn;if(t==="lowmemory")return ln;return vN.diag.warn("OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '"+e.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE+"', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead."),Gt}function FY(e){if(e!=null){if(e===Be.DELTA)return Sn;else if(e===Be.LOWMEMORY)return ln;return Gt}return YY()}function jY(e){if(e===null||e===void 0?void 0:e.aggregationPreference)return e.aggregationPreference;else return function(t){return v.Default()}}var CN,LN,vN,HY,Gt=function(){return C.CUMULATIVE},Sn=function(e){switch(e){case d.COUNTER:case d.OBSERVABLE_COUNTER:case d.GAUGE:case d.HISTOGRAM:case d.OBSERVABLE_GAUGE:return C.DELTA;case d.UP_DOWN_COUNTER:case d.OBSERVABLE_UP_DOWN_COUNTER:return C.CUMULATIVE}},ln=function(e){switch(e){case d.COUNTER:case d.HISTOGRAM:return C.DELTA;case d.GAUGE:case d.UP_DOWN_COUNTER:case d.OBSERVABLE_UP_DOWN_COUNTER:case d.OBSERVABLE_COUNTER:case d.OBSERVABLE_GAUGE:return C.CUMULATIVE}},pn;var _a=S(()=>{on();sa();CN=l(M(),1),LN=l(di(),1),vN=l(f(),1),HY=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}();pn=function(e){HY(t,e);function t(r,n){var i=e.call(this,r)||this;return i._aggregationSelector=jY(n),i._aggregationTemporalitySelector=FY(n===null||n===void 0?void 0:n.temporalityPreference),i}return t.prototype.selectAggregation=function(r){return this._aggregationSelector(r)},t.prototype.selectAggregationTemporality=function(r){return this._aggregationTemporalitySelector(r)},t}(LN.OTLPExporterBase)});var IN="0.57.2";var fn,KY,An=function(){return An=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e},An.apply(this,arguments)},kY,dn;var yN=S(()=>{_a();na();fn=l(aa(),1),KY=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),kY={"User-Agent":"OTel-OTLP-Exporter-JavaScript/"+IN},dn=function(e){KY(t,e);function t(r){return e.call(this,fn.createOtlpHttpExportDelegate(fn.convertLegacyHttpOptions(r!==null&&r!==void 0?r:{},"METRICS","v1/metrics",An(An({},kY),{"Content-Type":"application/json"})),un),r)||this}return t}(pn)});var DN=S(()=>{yN()});var xN=S(()=>{DN()});var UN={};F(UN,{AggregationTemporalityPreference:()=>Be,CumulativeTemporalitySelector:()=>Gt,DeltaTemporalitySelector:()=>Sn,LowMemoryTemporalitySelector:()=>ln,OTLPMetricExporter:()=>dn,OTLPMetricExporterBase:()=>pn});var bN=S(()=>{xN();sa();_a()});import{createConnection as zY}from"net";import{AsyncLocalStorage as QY}from"async_hooks";import{appendFileSync as JY,mkdirSync as $Y,existsSync as ZY}from"fs";import{join as eF}from"path";import{workerData as Ea,isMainThread as _t,parentPort as tF}from"worker_threads";import{Database as rF}from"bun:sqlite";var se=null,ua=!1,Rn="node-app";function WY(){let e=(process.env.NODE_OTEL_ENABLED??"").trim().toLowerCase();if(e==="")return!0;return e==="1"||e==="true"||e==="on"||e==="yes"}function VN(){return(process.env.NODE_OTEL_ENDPOINT??"").trim()||"http://127.0.0.1:4318"}async function ca(e){if(Rn=e||Rn,ua||!WY())return;ua=!0;try{let t=await Promise.resolve().then(() => l(f(),1)),{BasicTracerProvider:r,BatchSpanProcessor:n}=await Promise.resolve().then(() => (nh(),rh)),{OTLPTraceExporter:i}=await Promise.resolve().then(() => (PN(),gN)),o=await Promise.resolve().then(() => (gr(),KO)),{W3CTraceContextPropagator:s}=await Promise.resolve().then(() => l(M(),1)),_=new i({url:`${VN()}/v1/traces`}),c={"service.name":e},a=typeof o.resourceFromAttributes==="function"?o.resourceFromAttributes(c):new o.Resource(c);new r({resource:a,spanProcessors:[new n(_)]}).register({propagator:new s});try{let{MeterProvider:E,PeriodicExportingMetricReader:A}=await Promise.resolve().then(() => (on(),dM)),{OTLPMetricExporter:R}=await Promise.resolve().then(() => (bN(),UN)),y=new E({resource:a,readers:[new A({exporter:new R({url:`${VN()}/v1/metrics`})})]});t.metrics.setGlobalMeterProvider(y)}catch(E){console.debug(`[node-app-sdk] metrics init skipped: ${String(E)}`)}se=t}catch(t){ua=!1,console.debug(`[node-app-sdk] telemetry init skipped: ${String(t)}`)}}function qY(){return se!==null}var wN=new Map;function XY(e,t=1,r){if(!se)return;let n=wN.get(e);if(!n)n=se.metrics.getMeter(Rn).createCounter(e),wN.set(e,n);n.add(t,r)}function BN(e){if(se)se.propagation.inject(se.context.active(),e);return e}async function GN(e,t,r){if(!se)return r();let n=se,i=n.propagation.extract(n.context.active(),t??{});return n.context.with(i,()=>n.trace.getTracer(Rn).startActiveSpan(`capability ${e}`,{kind:n.SpanKind.SERVER},async(s)=>{try{return await r()}catch(_){throw s.recordException(_),s.setStatus({code:n.SpanStatusCode.ERROR}),_}finally{s.end()}}))}var nF=2048;function R4(e,t={}){let r=t.cacheSizeKb??nF;if(!Number.isInteger(r)||r<=0)throw RangeError("cacheSizeKb must be a positive integer");let n=new rF(e);try{return n.exec(`PRAGMA cache_size = -${r}`),n}catch(i){throw n.close(),i}}function oF(){if(!_t&&Ea&&typeof Ea==="object"){let e=Ea;return{socket:typeof e.socket==="string"?e.socket:void 0,logDir:typeof e.logDir==="string"?e.logDir:void 0,dataDir:typeof e.dataDir==="string"?e.dataDir:void 0}}return{socket:process.env.NODE_APP_SOCKET,logDir:process.env.NODE_APP_LOG_DIR,dataDir:process.env.NODE_APP_DATA_DIR}}var la=oF();function O4(){return la.socket}function Ta(e,t,r=process.exit){if(t){r(e);return}tF?.close()}var Yt=la.logDir,HN=Yt?eF(Yt,"app.log"):null,Sa=!1;function iF(){if(Sa||!Yt)return;try{if(!ZY(Yt))$Y(Yt,{recursive:!0});Sa=!0}catch{}}function aF(e,t){if(!HN)return;if(iF(),!Sa)return;let n=`${new Date().toISOString()} [${e.toUpperCase().padEnd(5)}] ${t}
15
+ `,zi(a,t))}}catch(u){n={error:u}}finally{try{if(_&&!_.done&&(i=s.return))i.call(s)}finally{if(n)throw n.error}}return o},e}()});var Hm;var Ym=S(()=>{Hm=function(){function e(t){this._backingStorages=t}return e.prototype.record=function(t,r,n,i){this._backingStorages.forEach(function(o){o.record(t,r,n,i)})},e}()});var fe,Fm,jm;var Km=S(()=>{wt();Qr();fe=l(f(),1),Fm=function(){function e(t,r){this._instrumentName=t,this._valueType=r,this._buffer=new Y}return e.prototype.observe=function(t,r){if(r===void 0)r={};if(typeof t!=="number"){fe.diag.warn("non-number value provided to metric "+this._instrumentName+": "+t);return}if(this._valueType===fe.ValueType.INT&&!Number.isInteger(t)){if(fe.diag.warn("INT value type cannot accept a floating-point value for "+this._instrumentName+", ignoring the fractional digits."),t=Math.trunc(t),!Number.isInteger(t))return}this._buffer.set(r,t)},e}(),jm=function(){function e(){this._buffer=new Map}return e.prototype.observe=function(t,r,n){if(n===void 0)n={};if(!Vt(t))return;var i=this._buffer.get(t);if(i==null)i=new Y,this._buffer.set(t,i);if(typeof r!=="number"){fe.diag.warn("non-number value provided to metric "+t._descriptor.name+": "+r);return}if(t._descriptor.valueType===fe.ValueType.INT&&!Number.isInteger(r)){if(fe.diag.warn("INT value type cannot accept a floating-point value for "+t._descriptor.name+", ignoring the fractional digits."),r=Math.trunc(r),!Number.isInteger(r))return}i.set(n,r)},e}()});var qm,$i=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},Zi=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},km=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o},Wm=function(e,t,r){if(r||arguments.length===2){for(var n=0,i=t.length,o;n<i;n++)if(o||!(n in t)){if(!o)o=Array.prototype.slice.call(t,0,n);o[n]=t[n]}}return e.concat(o||Array.prototype.slice.call(t))},Xm;var zm=S(()=>{Qr();Km();H();qm=l(f(),1),Xm=function(){function e(){this._callbacks=[],this._batchCallbacks=[]}return e.prototype.addCallback=function(t,r){var n=this._findCallback(t,r);if(n>=0)return;this._callbacks.push({callback:t,instrument:r})},e.prototype.removeCallback=function(t,r){var n=this._findCallback(t,r);if(n<0)return;this._callbacks.splice(n,1)},e.prototype.addBatchCallback=function(t,r){var n=new Set(r.filter(Vt));if(n.size===0){qm.diag.error("BatchObservableCallback is not associated with valid instruments",r);return}var i=this._findBatchCallback(t,n);if(i>=0)return;this._batchCallbacks.push({callback:t,instruments:n})},e.prototype.removeBatchCallback=function(t,r){var n=new Set(r.filter(Vt)),i=this._findBatchCallback(t,n);if(i<0)return;this._batchCallbacks.splice(i,1)},e.prototype.observe=function(t,r){return $i(this,void 0,void 0,function(){var n,i,o,s;return Zi(this,function(_){switch(_.label){case 0:return n=this._observeCallbacks(t,r),i=this._observeBatchCallbacks(t,r),[4,bh(Wm(Wm([],km(n),!1),km(i),!1))];case 1:return o=_.sent(),s=o.filter(Vh).map(function(c){return c.reason}),[2,s]}})})},e.prototype._observeCallbacks=function(t,r){var n=this;return this._callbacks.map(function(i){var{callback:o,instrument:s}=i;return $i(n,void 0,void 0,function(){var _,c;return Zi(this,function(a){switch(a.label){case 0:if(_=new Fm(s._descriptor.name,s._descriptor.valueType),c=Promise.resolve(o(_)),r!=null)c=pe(c,r);return[4,c];case 1:return a.sent(),s._metricStorages.forEach(function(u){u.record(_._buffer,t)}),[2]}})})})},e.prototype._observeBatchCallbacks=function(t,r){var n=this;return this._batchCallbacks.map(function(i){var{callback:o,instruments:s}=i;return $i(n,void 0,void 0,function(){var _,c;return Zi(this,function(a){switch(a.label){case 0:if(_=new jm,c=Promise.resolve(o(_)),r!=null)c=pe(c,r);return[4,c];case 1:return a.sent(),s.forEach(function(u){var E=_._buffer.get(u);if(E==null)return;u._metricStorages.forEach(function(A){A.record(E,t)})}),[2]}})})})},e.prototype._findCallback=function(t,r){return this._callbacks.findIndex(function(n){return n.callback===t&&n.instrument===r})},e.prototype._findBatchCallback=function(t,r){return this._batchCallbacks.findIndex(function(n){return n.callback===t&&wh(n.instruments,r)})},e}()});var c1,Qm;var Jm=S(()=>{Ki();ki();qi();c1=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),Qm=function(e){c1(t,e);function t(r,n,i,o,s){var _=e.call(this,r)||this;return _._attributesProcessor=i,_._aggregationCardinalityLimit=s,_._deltaMetricStorage=new $r(n,_._aggregationCardinalityLimit),_._temporalMetricStorage=new Zr(n,o),_}return t.prototype.record=function(r,n,i,o){n=this._attributesProcessor.process(n,i),this._deltaMetricStorage.record(r,n,i,o)},t.prototype.collect=function(r,n){var i=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,i,n)},t}(Jr)});var $m,ot,E1,Zm,T1;var ea=S(()=>{$m=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),ot=function(){function e(){}return e.Noop=function(){return T1},e}(),E1=function(e){$m(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.process=function(r,n){return r},t}(ot),Zm=function(e){$m(t,e);function t(r){var n=e.call(this)||this;return n._allowedAttributeNames=r,n}return t.prototype.process=function(r,n){var i=this,o={};return Object.keys(r).filter(function(s){return i._allowedAttributeNames.includes(s)}).forEach(function(s){return o[s]=r[s]}),o},t}(ot),T1=new E1});var S1=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},l1=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},p1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o},eM;var tM=S(()=>{ne();xm();H();wm();Gm();Ym();zm();Jm();ea();eM=function(){function e(t,r){this._meterProviderSharedState=t,this._instrumentationScope=r,this.metricStorageRegistry=new Bm,this.observableRegistry=new Xm,this.meter=new Dm(this)}return e.prototype.registerMetricStorage=function(t){var r=this._registerMetricStorage(t,Qm);if(r.length===1)return r[0];return new Hm(r)},e.prototype.registerAsyncMetricStorage=function(t){var r=this._registerMetricStorage(t,Vm);return r},e.prototype.collect=function(t,r,n){return S1(this,void 0,void 0,function(){var i,o,s;return l1(this,function(_){switch(_.label){case 0:return[4,this.observableRegistry.observe(r,n===null||n===void 0?void 0:n.timeoutMillis)];case 1:if(i=_.sent(),o=this.metricStorageRegistry.getStorages(t),o.length===0)return[2,null];if(s=o.map(function(c){return c.collect(t,r)}).filter(xh),s.length===0)return[2,{errors:i}];return[2,{scopeMetrics:{scope:this._instrumentationScope,metrics:s},errors:i}]}})})},e.prototype._registerMetricStorage=function(t,r){var n=this,i=this._meterProviderSharedState.viewRegistry.findViews(t,this._instrumentationScope),o=i.map(function(c){var a=Yh(c,t),u=n.metricStorageRegistry.findOrUpdateCompatibleStorage(a);if(u!=null)return u;var E=c.aggregation.createAggregator(a),A=new r(a,E,c.attributesProcessor,n._meterProviderSharedState.metricCollectors,c.aggregationCardinalityLimit);return n.metricStorageRegistry.register(A),A});if(o.length===0){var s=this._meterProviderSharedState.selectAggregations(t.type),_=s.map(function(c){var a=p1(c,2),u=a[0],E=a[1],A=n.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(u,t);if(A!=null)return A;var R=E.createAggregator(t),y=u.selectCardinalityLimit(t.type),de=new r(t,R,ot.Noop(),[u],y);return n.metricStorageRegistry.registerForCollector(u,de),de});o=o.concat(_)}return o},e}()});var A1=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&n>=e.length)e=void 0;return{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},rM;var nM=S(()=>{H();Mm();tM();rM=function(){function e(t){this.resource=t,this.viewRegistry=new mm,this.metricCollectors=[],this.meterSharedStates=new Map}return e.prototype.getMeterSharedState=function(t){var r=Uh(t),n=this.meterSharedStates.get(r);if(n==null)n=new eM(this,t),this.meterSharedStates.set(r,n);return n},e.prototype.selectAggregations=function(t){var r,n,i=[];try{for(var o=A1(this.metricCollectors),s=o.next();!s.done;s=o.next()){var _=s.value;i.push([_,_.selectAggregation(t)])}}catch(c){r={error:c}}finally{try{if(s&&!s.done&&(n=o.return))n.call(o)}finally{if(r)throw r.error}}return i},e}()});var oM,en=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},tn=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},f1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o},d1=function(e,t,r){if(r||arguments.length===2){for(var n=0,i=t.length,o;n<i;n++)if(o||!(n in t)){if(!o)o=Array.prototype.slice.call(t,0,n);o[n]=t[n]}}return e.concat(o||Array.prototype.slice.call(t))},iM;var aM=S(()=>{oM=l(M(),1),iM=function(){function e(t,r){this._sharedState=t,this._metricReader=r}return e.prototype.collect=function(t){return en(this,void 0,void 0,function(){var r,n,i,o,s=this;return tn(this,function(_){switch(_.label){case 0:return r=oM.millisToHrTime(Date.now()),n=[],i=[],o=Array.from(this._sharedState.meterSharedStates.values()).map(function(c){return en(s,void 0,void 0,function(){var a;return tn(this,function(u){switch(u.label){case 0:return[4,c.collect(this,r,t)];case 1:if(a=u.sent(),(a===null||a===void 0?void 0:a.scopeMetrics)!=null)n.push(a.scopeMetrics);if((a===null||a===void 0?void 0:a.errors)!=null)i.push.apply(i,d1([],f1(a.errors),!1));return[2]}})})}),[4,Promise.all(o)];case 1:return _.sent(),[2,{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:i}]}})})},e.prototype.forceFlush=function(t){return en(this,void 0,void 0,function(){return tn(this,function(r){switch(r.label){case 0:return[4,this._metricReader.forceFlush(t)];case 1:return r.sent(),[2]}})})},e.prototype.shutdown=function(t){return en(this,void 0,void 0,function(){return tn(this,function(r){switch(r.label){case 0:return[4,this._metricReader.shutdown(t)];case 1:return r.sent(),[2]}})})},e.prototype.selectAggregationTemporality=function(t){return this._metricReader.selectAggregationTemporality(t)},e.prototype.selectAggregation=function(t){return this._metricReader.selectAggregation(t)},e.prototype.selectCardinalityLimit=function(t){var r,n,i;return(i=(n=(r=this._metricReader).selectCardinalityLimit)===null||n===void 0?void 0:n.call(r,t))!==null&&i!==void 0?i:2000},e}()});function R1(e,t){var r=t!==null&&t!==void 0?t:h.empty();if(e)return h.default().merge(r);return r}var it,sM=function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function _(u){try{a(n.next(u))}catch(E){s(E)}}function c(u){try{a(n.throw(u))}catch(E){s(E)}}function a(u){u.done?o(u.value):i(u.value).then(_,c)}a((n=n.apply(e,t||[])).next())})},_M=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:_(0),throw:_(1),return:_(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function _(a){return function(u){return c([a,u])}}function c(a){if(n)throw TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if((o=r.trys,!(o=o.length>0&&o[o.length-1]))&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},uM=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&n>=e.length)e=void 0;return{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},cM;var EM=S(()=>{gr();nM();aM();it=l(f(),1);cM=function(){function e(t){var r,n,i,o,s;if(this._shutdown=!1,this._sharedState=new rM(R1((s=t===null||t===void 0?void 0:t.mergeResourceWithDefaults)!==null&&s!==void 0?s:!0,t===null||t===void 0?void 0:t.resource)),(t===null||t===void 0?void 0:t.views)!=null&&t.views.length>0)try{for(var _=uM(t.views),c=_.next();!c.done;c=_.next()){var a=c.value;this._sharedState.viewRegistry.addView(a)}}catch(R){r={error:R}}finally{try{if(c&&!c.done&&(n=_.return))n.call(_)}finally{if(r)throw r.error}}if((t===null||t===void 0?void 0:t.readers)!=null&&t.readers.length>0)try{for(var u=uM(t.readers),E=u.next();!E.done;E=u.next()){var A=E.value;this.addMetricReader(A)}}catch(R){i={error:R}}finally{try{if(E&&!E.done&&(o=u.return))o.call(u)}finally{if(i)throw i.error}}}return e.prototype.getMeter=function(t,r,n){if(r===void 0)r="";if(n===void 0)n={};if(this._shutdown)return it.diag.warn("A shutdown MeterProvider cannot provide a Meter"),it.createNoopMeter();return this._sharedState.getMeterSharedState({name:t,version:r,schemaUrl:n.schemaUrl}).meter},e.prototype.addMetricReader=function(t){var r=new iM(this._sharedState,t);t.setMetricProducer(r),this._sharedState.metricCollectors.push(r)},e.prototype.shutdown=function(t){return sM(this,void 0,void 0,function(){return _M(this,function(r){switch(r.label){case 0:if(this._shutdown)return it.diag.warn("shutdown may only be called once per MeterProvider"),[2];return this._shutdown=!0,[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.shutdown(t)}))];case 1:return r.sent(),[2]}})})},e.prototype.forceFlush=function(t){return sM(this,void 0,void 0,function(){return _M(this,function(r){switch(r.label){case 0:if(this._shutdown)return it.diag.warn("invalid attempt to force flush after MeterProvider shutdown"),[2];return[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.forceFlush(t)}))];case 1:return r.sent(),[2]}})})},e}()});var O1,rn,at;var nn=S(()=>{O1=/[\^$\\.+?()[\]{}|]/g,rn=function(){function e(t){if(t==="*")this._matchAll=!0,this._regexp=/.*/;else this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t))}return e.prototype.match=function(t){if(this._matchAll)return!0;return this._regexp.test(t)},e.escapePattern=function(t){return"^"+t.replace(O1,"\\$&").replace("*",".*")+"$"},e.hasWildcard=function(t){return t.includes("*")},e}(),at=function(){function e(t){this._matchAll=t===void 0,this._pattern=t}return e.prototype.match=function(t){if(this._matchAll)return!0;if(t===this._pattern)return!0;return!1},e}()});var TM;var SM=S(()=>{nn();TM=function(){function e(t){var r;this._nameFilter=new rn((r=t===null||t===void 0?void 0:t.name)!==null&&r!==void 0?r:"*"),this._type=t===null||t===void 0?void 0:t.type,this._unitFilter=new at(t===null||t===void 0?void 0:t.unit)}return e.prototype.getType=function(){return this._type},e.prototype.getNameFilter=function(){return this._nameFilter},e.prototype.getUnitFilter=function(){return this._unitFilter},e}()});var lM;var pM=S(()=>{nn();lM=function(){function e(t){this._nameFilter=new at(t===null||t===void 0?void 0:t.name),this._versionFilter=new at(t===null||t===void 0?void 0:t.version),this._schemaUrlFilter=new at(t===null||t===void 0?void 0:t.schemaUrl)}return e.prototype.getNameFilter=function(){return this._nameFilter},e.prototype.getVersionFilter=function(){return this._versionFilter},e.prototype.getSchemaUrlFilter=function(){return this._schemaUrlFilter},e}()});function h1(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}var AM;var fM=S(()=>{nn();ea();SM();pM();Fr();AM=function(){function e(t){var r;if(h1(t))throw Error("Cannot create view with no selector arguments supplied");if(t.name!=null&&((t===null||t===void 0?void 0:t.instrumentName)==null||rn.hasWildcard(t.instrumentName)))throw Error("Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.");if(t.attributeKeys!=null)this.attributesProcessor=new Zm(t.attributeKeys);else this.attributesProcessor=ot.Noop();this.name=t.name,this.description=t.description,this.aggregation=(r=t.aggregation)!==null&&r!==void 0?r:v.Default(),this.instrumentSelector=new TM({name:t.instrumentName,type:t.instrumentType,unit:t.instrumentUnit}),this.meterSelector=new lM({name:t.meterName,version:t.meterVersion,schemaUrl:t.meterSchemaUrl}),this.aggregationCardinalityLimit=t.aggregationCardinalityLimit}return e}()});var dM={};F(dM,{Aggregation:()=>v,AggregationTemporality:()=>C,ConsoleMetricExporter:()=>Om,DataPointType:()=>L,DefaultAggregation:()=>Vi,DropAggregation:()=>Ii,ExplicitBucketHistogramAggregation:()=>Ui,ExponentialHistogramAggregation:()=>bi,HistogramAggregation:()=>xi,InMemoryMetricExporter:()=>fm,InstrumentType:()=>d,LastValueAggregation:()=>Di,MeterProvider:()=>cM,MetricReader:()=>Kr,PeriodicExportingMetricReader:()=>pm,SumAggregation:()=>yi,TimeoutError:()=>xt,View:()=>AM});var on=S(()=>{vr();tt();Yi();Am();dm();hm();ne();EM();Fr();fM();H()});function OM(e){var t=BigInt(1e9);return BigInt(e[0])*t+BigInt(e[1])}function m1(e){var t=Number(BigInt.asUintN(32,e)),r=Number(BigInt.asUintN(32,e>>BigInt(32)));return{low:t,high:r}}function hM(e){var t=OM(e);return m1(t)}function M1(e){var t=OM(e);return t.toString()}function RM(e){return e}function mM(e){if(e===void 0)return;return st.hexToBinary(e)}function an(e){var t,r;if(e===void 0)return g1;var n=(t=e.useLongBits)!==null&&t!==void 0?t:!0,i=(r=e.useHex)!==null&&r!==void 0?r:!1;return{encodeHrTime:n?hM:N1,encodeSpanContext:i?RM:st.hexToBinary,encodeOptionalSpanContext:i?RM:mM}}var st,N1,g1;var ta=S(()=>{st=l(M(),1);N1=typeof BigInt<"u"?M1:st.hrTimeToNanoseconds;g1={encodeHrTime:hM,encodeSpanContext:st.hexToBinary,encodeOptionalSpanContext:mM}});function sn(e){return{attributes:ae(e.attributes),droppedAttributesCount:0}}function _n(e){return{name:e.name,version:e.version}}function ae(e){return Object.keys(e).map(function(t){return MM(t,e[t])})}function MM(e,t){return{key:e,value:NM(t)}}function NM(e){var t=typeof e;if(t==="string")return{stringValue:e};if(t==="number"){if(!Number.isInteger(e))return{doubleValue:e};return{intValue:e}}if(t==="boolean")return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:e};if(Array.isArray(e))return{arrayValue:{values:e.map(NM)}};if(t==="object"&&e!=null)return{kvlistValue:{values:Object.entries(e).map(function(r){var n=P1(r,2),i=n[0],o=n[1];return MM(i,o)})}};return{}}var P1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o};function C1(e,t){var r=an(t);return{resource:sn(e.resource),schemaUrl:void 0,scopeMetrics:L1(e.scopeMetrics,r)}}function L1(e,t){return Array.from(e.map(function(r){return{scope:_n(r.scope),metrics:r.metrics.map(function(n){return v1(n,t)}),schemaUrl:r.scope.schemaUrl}}))}function v1(e,t){var r={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},n=x1(e.aggregationTemporality);switch(e.dataPointType){case L.SUM:r.sum={aggregationTemporality:n,isMonotonic:e.isMonotonic,dataPoints:gM(e,t)};break;case L.GAUGE:r.gauge={dataPoints:gM(e,t)};break;case L.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:y1(e,t)};break;case L.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:D1(e,t)};break}return r}function I1(e,t,r){var n={attributes:ae(e.attributes),startTimeUnixNano:r.encodeHrTime(e.startTime),timeUnixNano:r.encodeHrTime(e.endTime)};switch(t){case ra.ValueType.INT:n.asInt=e.value;break;case ra.ValueType.DOUBLE:n.asDouble=e.value;break}return n}function gM(e,t){return e.dataPoints.map(function(r){return I1(r,e.descriptor.valueType,t)})}function y1(e,t){return e.dataPoints.map(function(r){var n=r.value;return{attributes:ae(r.attributes),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function D1(e,t){return e.dataPoints.map(function(r){var n=r.value;return{attributes:ae(r.attributes),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function x1(e){switch(e){case C.DELTA:return 1;case C.CUMULATIVE:return 2}}function PM(e,t){return{resourceMetrics:e.map(function(r){return C1(r,t)})}}var ra;var CM=S(()=>{on();ta();ra=l(f(),1)});var un;var LM=S(()=>{CM();un={serializeRequest:function(e){var t=PM([e],{useLongBits:!1}),r=new TextEncoder;return r.encode(JSON.stringify(t))},deserializeResponse:function(e){var t=new TextDecoder;return JSON.parse(t.decode(e))}}});var vM=S(()=>{LM()});function V1(e,t){var r,n=e.spanContext(),i=e.status;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:t.encodeOptionalSpanContext(e.parentSpanId),traceState:(r=n.traceState)===null||r===void 0?void 0:r.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:ae(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(function(o){return B1(o,t)}),droppedEventsCount:e.droppedEventsCount,status:{code:i.code,message:i.message},links:e.links.map(function(o){return w1(o,t)}),droppedLinksCount:e.droppedLinksCount}}function w1(e,t){var r;return{attributes:e.attributes?ae(e.attributes):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(r=e.context.traceState)===null||r===void 0?void 0:r.serialize(),droppedAttributesCount:e.droppedAttributesCount||0}}function B1(e,t){return{attributes:e.attributes?ae(e.attributes):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function IM(e,t){var r=an(t);return{resourceSpans:H1(e,r)}}function G1(e){var t,r,n=new Map;try{for(var i=U1(e),o=i.next();!o.done;o=i.next()){var s=o.value,_=n.get(s.resource);if(!_)_=new Map,n.set(s.resource,_);var c=s.instrumentationLibrary.name+"@"+(s.instrumentationLibrary.version||"")+":"+(s.instrumentationLibrary.schemaUrl||""),a=_.get(c);if(!a)a=[],_.set(c,a);a.push(s)}}catch(u){t={error:u}}finally{try{if(o&&!o.done&&(r=i.return))r.call(i)}finally{if(t)throw t.error}}return n}function H1(e,t){var r=G1(e),n=[],i=r.entries(),o=i.next();while(!o.done){var s=b1(o.value,2),_=s[0],c=s[1],a=[],u=c.values(),E=u.next();while(!E.done){var A=E.value;if(A.length>0){var R=A.map(function(de){return V1(de,t)});a.push({scope:_n(A[0].instrumentationLibrary),spans:R,schemaUrl:A[0].instrumentationLibrary.schemaUrl})}E=u.next()}var y={resource:sn(_),scopeSpans:a,schemaUrl:void 0};n.push(y),o=i.next()}return n}var U1=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&n>=e.length)e=void 0;return{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},b1=function(e,t){var r=typeof Symbol==="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],s;try{while((t===void 0||t-- >0)&&!(i=n.next()).done)o.push(i.value)}catch(_){s={error:_}}finally{try{if(i&&!i.done&&(r=n.return))r.call(n)}finally{if(s)throw s.error}}return o};var yM=S(()=>{ta()});var cn;var DM=S(()=>{yM();cn={serializeRequest:function(e){var t=IM(e,{useHex:!0,useLongBits:!1}),r=new TextEncoder;return r.encode(JSON.stringify(t))},deserializeResponse:function(e){var t=new TextDecoder;return JSON.parse(t.decode(e))}}});var xM=S(()=>{DM()});var na=S(()=>{vM();xM()});var VM=T(function(UM){Object.defineProperty(UM,"__esModule",{value:!0});UM.parseRetryAfterToMills=UM.isExportRetryable=void 0;function Y1(e){return[429,502,503,504].includes(e)}UM.isExportRetryable=Y1;function F1(e){if(e==null)return;let t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1000:-1;let r=new Date(e).getTime()-Date.now();if(r>=0)return r;return 0}UM.parseRetryAfterToMills=F1});var jM=T(function(YM){Object.defineProperty(YM,"__esModule",{value:!0});YM.createHttpAgent=YM.compressAndSend=YM.sendWithHttp=void 0;var BM=He("http"),GM=He("https"),K1=He("zlib"),k1=He("stream"),wM=VM(),W1=Lr();function q1(e,t,r,n,i){let o=new URL(e.url),s=Number(process.versions.node.split(".")[0]),_={hostname:o.hostname,port:o.port,path:o.pathname,method:"POST",headers:Object.assign({},e.headers()),agent:t},a=(o.protocol==="http:"?BM.request:GM.request)(_,(E)=>{let A=[];E.on("data",(R)=>A.push(R)),E.on("end",()=>{if(E.statusCode&&E.statusCode<299)n({status:"success",data:Buffer.concat(A)});else if(E.statusCode&&(0,wM.isExportRetryable)(E.statusCode))n({status:"retryable",retryInMillis:(0,wM.parseRetryAfterToMills)(E.headers["retry-after"])});else{let R=new W1.OTLPExporterError(E.statusMessage,E.statusCode,Buffer.concat(A).toString());n({status:"failure",error:R})}})});a.setTimeout(i,()=>{a.destroy(),n({status:"failure",error:Error("Request Timeout")})}),a.on("error",(E)=>{n({status:"failure",error:E})});let u=s>=14?"close":"abort";a.on(u,()=>{n({status:"failure",error:Error("Request timed out")})}),HM(a,e.compression,r,(E)=>{n({status:"failure",error:E})})}YM.sendWithHttp=q1;function HM(e,t,r,n){let i=X1(r);if(t==="gzip")e.setHeader("Content-Encoding","gzip"),i=i.on("error",n).pipe(K1.createGzip()).on("error",n);i.pipe(e).on("error",n)}YM.compressAndSend=HM;function X1(e){let t=new k1.Readable;return t.push(e),t.push(null),t}function z1(e,t){return new(new URL(e).protocol==="http:"?BM.Agent:GM.Agent)(t)}YM.createHttpAgent=z1});var qM=T(function(kM){Object.defineProperty(kM,"__esModule",{value:!0});kM.createHttpExporterTransport=void 0;class KM{constructor(e){this._parameters=e,this._send=null,this._agent=null}async send(e,t){if(this._send==null){let{sendWithHttp:r,createHttpAgent:n}=jM();this._agent=n(this._parameters.url,this._parameters.agentOptions),this._send=r}return new Promise((r)=>{var n;(n=this._send)===null||n===void 0||n.call(this,this._parameters,this._agent,e,(i)=>{r(i)},t)})}shutdown(){}}function $1(e){return new KM(e)}kM.createHttpExporterTransport=$1});var $M=T(function(QM){Object.defineProperty(QM,"__esModule",{value:!0});QM.createRetryingTransport=void 0;var Z1=5,eY=1000,tY=5000,rY=1.5,XM=0.2;function nY(){return Math.random()*(2*XM)-XM}class zM{constructor(e){this._transport=e}retry(e,t,r){return new Promise((n,i)=>{setTimeout(()=>{this._transport.send(e,t).then(n,i)},r)})}async send(e,t){var r;let n=Date.now()+t,i=await this._transport.send(e,t),o=Z1,s=eY;while(i.status==="retryable"&&o>0){o--;let _=Math.max(Math.min(s,tY)+nY(),0);s=s*rY;let c=(r=i.retryInMillis)!==null&&r!==void 0?r:_,a=n-Date.now();if(c>a)return i;i=await this.retry(e,a,c)}return i}shutdown(){return this._transport.shutdown()}}function oY(e){return new zM(e.transport)}QM.createRetryingTransport=oY});var tN=T(function(ZM){Object.defineProperty(ZM,"__esModule",{value:!0});ZM.createOtlpHttpExportDelegate=void 0;var iY=fi(),aY=qM(),sY=Ai(),_Y=$M();function uY(e,t){return(0,iY.createOtlpExportDelegate)({transport:(0,_Y.createRetryingTransport)({transport:(0,aY.createHttpExporterTransport)(e)}),serializer:t,promiseHandler:(0,sY.createBoundedQueueExportPromiseHandler)(e)},{timeout:e.timeoutMillis})}ZM.createOtlpHttpExportDelegate=uY});var oa=T(function(iN){Object.defineProperty(iN,"__esModule",{value:!0});iN.getSharedConfigurationFromEnvironment=void 0;var oN=f();function rN(e){var t;let r=(t=process.env[e])===null||t===void 0?void 0:t.trim();if(r!=null&&r!==""){let n=Number(r);if(!Number.isNaN(n)&&Number.isFinite(n)&&n>0)return n;oN.diag.warn(`Configuration: ${e} is invalid, expected number greater than 0 (actual: ${r})`)}return}function cY(e){let t=rN(`OTEL_EXPORTER_OTLP_${e}_TIMEOUT`),r=rN("OTEL_EXPORTER_OTLP_TIMEOUT");return t!==null&&t!==void 0?t:r}function nN(e){var t;let r=(t=process.env[e])===null||t===void 0?void 0:t.trim();if(r==="")return;if(r==null||r==="none"||r==="gzip")return r;oN.diag.warn(`Configuration: ${e} is invalid, expected 'none' or 'gzip' (actual: '${r}')`);return}function EY(e){let t=nN(`OTEL_EXPORTER_OTLP_${e}_COMPRESSION`),r=nN("OTEL_EXPORTER_OTLP_COMPRESSION");return t!==null&&t!==void 0?t:r}function TY(e){return{timeoutMillis:cY(e),compression:EY(e)}}iN.getSharedConfigurationFromEnvironment=TY});var uN=T(function(sN){Object.defineProperty(sN,"__esModule",{value:!0});sN.validateAndNormalizeHeaders=void 0;var SY=f();function lY(e){return()=>{var t;let r={};return Object.entries((t=e===null||e===void 0?void 0:e())!==null&&t!==void 0?t:{}).forEach(([n,i])=>{if(typeof i<"u")r[n]=String(i);else SY.diag.warn(`Header "${n}" has invalid value (${i}) and will be ignored`)}),r}}sN.validateAndNormalizeHeaders=lY});var SN=T(function(EN){Object.defineProperty(EN,"__esModule",{value:!0});EN.getHttpConfigurationDefaults=EN.mergeOtlpHttpConfigurationWithDefaults=void 0;var cN=Dt(),pY=uN();function AY(e,t,r){let n=Object.assign({},r()),i={};return()=>{if(t!=null)Object.assign(i,t());if(e!=null)Object.assign(i,e());return Object.assign(i,n)}}function fY(e){if(e==null)return;try{return new URL(e),e}catch(t){throw Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function dY(e,t,r){var n,i,o,s;return Object.assign(Object.assign({},(0,cN.mergeOtlpSharedConfigurationWithDefaults)(e,t,r)),{headers:AY((0,pY.validateAndNormalizeHeaders)(e.headers),t.headers,r.headers),url:(i=(n=fY(e.url))!==null&&n!==void 0?n:t.url)!==null&&i!==void 0?i:r.url,agentOptions:(s=(o=e.agentOptions)!==null&&o!==void 0?o:t.agentOptions)!==null&&s!==void 0?s:r.agentOptions})}EN.mergeOtlpHttpConfigurationWithDefaults=dY;function RY(e,t){return Object.assign(Object.assign({},(0,cN.getSharedConfigurationDefaults)()),{headers:()=>e,url:"http://localhost:4318/"+t,agentOptions:{keepAlive:!0}})}EN.getHttpConfigurationDefaults=RY});var AN=T(function(lN){Object.defineProperty(lN,"__esModule",{value:!0});lN.getHttpConfigurationFromEnvironment=void 0;var En=M(),ia=f(),hY=oa(),mY=Dt();function MY(e){var t,r;let n=(t=process.env[`OTEL_EXPORTER_OTLP_${e}_HEADERS`])===null||t===void 0?void 0:t.trim(),i=(r=process.env.OTEL_EXPORTER_OTLP_HEADERS)===null||r===void 0?void 0:r.trim(),o=En.baggageUtils.parseKeyPairsIntoRecord(n),s=En.baggageUtils.parseKeyPairsIntoRecord(i);if(Object.keys(o).length===0&&Object.keys(s).length===0)return;return Object.assign({},En.baggageUtils.parseKeyPairsIntoRecord(i),En.baggageUtils.parseKeyPairsIntoRecord(n))}function NY(e){try{return new URL(e).toString()}catch(t){ia.diag.warn(`Configuration: Could not parse environment-provided export URL: '${e}', falling back to undefined`);return}}function gY(e,t){try{new URL(e)}catch(r){ia.diag.warn(`Configuration: Could not parse environment-provided export URL: '${e}', falling back to undefined`);return}if(!e.endsWith("/"))e=e+"/";e+=t;try{new URL(e)}catch(r){ia.diag.warn(`Configuration: Provided URL appended with '${t}' is not a valid URL, using 'undefined' instead of '${e}'`);return}return e}function PY(e){var t;let r=(t=process.env.OTEL_EXPORTER_OTLP_ENDPOINT)===null||t===void 0?void 0:t.trim();if(r==null||r==="")return;return gY(r,e)}function CY(e){var t;let r=(t=process.env[`OTEL_EXPORTER_OTLP_${e}_ENDPOINT`])===null||t===void 0?void 0:t.trim();if(r==null||r==="")return;return NY(r)}function LY(e,t){var r;return Object.assign(Object.assign({},(0,hY.getSharedConfigurationFromEnvironment)(e)),{url:(r=CY(e))!==null&&r!==void 0?r:PY(t),headers:(0,mY.wrapStaticHeadersInFunction)(MY(e))})}lN.getHttpConfigurationFromEnvironment=LY});var ON=T(function(dN){Object.defineProperty(dN,"__esModule",{value:!0});dN.convertLegacyHttpOptions=void 0;var fN=SN(),vY=AN(),IY=f(),yY=Dt();function DY(e){if((e===null||e===void 0?void 0:e.keepAlive)!=null)if(e.httpAgentOptions!=null){if(e.httpAgentOptions.keepAlive==null)e.httpAgentOptions.keepAlive=e.keepAlive}else e.httpAgentOptions={keepAlive:e.keepAlive};return e.httpAgentOptions}function xY(e,t,r,n){if(e.metadata)IY.diag.warn("Metadata cannot be set when using http");return(0,fN.mergeOtlpHttpConfigurationWithDefaults)({url:e.url,headers:(0,yY.wrapStaticHeadersInFunction)(e.headers),concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis,compression:e.compression,agentOptions:DY(e)},(0,vY.getHttpConfigurationFromEnvironment)(t,r),(0,fN.getHttpConfigurationDefaults)(n,r))}dN.convertLegacyHttpOptions=xY});var aa=T(function(Bt){Object.defineProperty(Bt,"__esModule",{value:!0});Bt.convertLegacyHttpOptions=Bt.getSharedConfigurationFromEnvironment=Bt.createOtlpHttpExportDelegate=void 0;var UY=tN();Object.defineProperty(Bt,"createOtlpHttpExportDelegate",{enumerable:!0,get:function(){return UY.createOtlpHttpExportDelegate}});var bY=oa();Object.defineProperty(Bt,"getSharedConfigurationFromEnvironment",{enumerable:!0,get:function(){return bY.getSharedConfigurationFromEnvironment}});var VY=ON();Object.defineProperty(Bt,"convertLegacyHttpOptions",{enumerable:!0,get:function(){return VY.convertLegacyHttpOptions}})});var hN,Tn,BY,GY;var mN=S(()=>{na();hN=l(di(),1),Tn=l(aa(),1),BY=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),GY=function(e){BY(t,e);function t(r){if(r===void 0)r={};return e.call(this,Tn.createOtlpHttpExportDelegate(Tn.convertLegacyHttpOptions(r,"TRACES","v1/traces",{"User-Agent":"OTel-OTLP-Exporter-JavaScript/"+Ih,"Content-Type":"application/json"}),cn))||this}return t}(hN.OTLPExporterBase)});var MN=S(()=>{mN()});var NN=S(()=>{MN()});var gN={};F(gN,{OTLPTraceExporter:()=>GY});var PN=S(()=>{NN()});var Be;var sa=S(()=>{(function(e){e[e.DELTA=0]="DELTA",e[e.CUMULATIVE=1]="CUMULATIVE",e[e.LOWMEMORY=2]="LOWMEMORY"})(Be||(Be={}))});function YY(){var e=CN.getEnv(),t=e.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.trim().toLowerCase();if(t==="cumulative")return Gt;if(t==="delta")return Sn;if(t==="lowmemory")return ln;return vN.diag.warn("OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '"+e.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE+"', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead."),Gt}function FY(e){if(e!=null){if(e===Be.DELTA)return Sn;else if(e===Be.LOWMEMORY)return ln;return Gt}return YY()}function jY(e){if(e===null||e===void 0?void 0:e.aggregationPreference)return e.aggregationPreference;else return function(t){return v.Default()}}var CN,LN,vN,HY,Gt=function(){return C.CUMULATIVE},Sn=function(e){switch(e){case d.COUNTER:case d.OBSERVABLE_COUNTER:case d.GAUGE:case d.HISTOGRAM:case d.OBSERVABLE_GAUGE:return C.DELTA;case d.UP_DOWN_COUNTER:case d.OBSERVABLE_UP_DOWN_COUNTER:return C.CUMULATIVE}},ln=function(e){switch(e){case d.COUNTER:case d.HISTOGRAM:return C.DELTA;case d.GAUGE:case d.UP_DOWN_COUNTER:case d.OBSERVABLE_UP_DOWN_COUNTER:case d.OBSERVABLE_COUNTER:case d.OBSERVABLE_GAUGE:return C.CUMULATIVE}},pn;var _a=S(()=>{on();sa();CN=l(M(),1),LN=l(di(),1),vN=l(f(),1),HY=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}();pn=function(e){HY(t,e);function t(r,n){var i=e.call(this,r)||this;return i._aggregationSelector=jY(n),i._aggregationTemporalitySelector=FY(n===null||n===void 0?void 0:n.temporalityPreference),i}return t.prototype.selectAggregation=function(r){return this._aggregationSelector(r)},t.prototype.selectAggregationTemporality=function(r){return this._aggregationTemporalitySelector(r)},t}(LN.OTLPExporterBase)});var IN="0.57.2";var fn,KY,An=function(){return An=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e},An.apply(this,arguments)},kY,dn;var yN=S(()=>{_a();na();fn=l(aa(),1),KY=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o))n[o]=i[o]},e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),kY={"User-Agent":"OTel-OTLP-Exporter-JavaScript/"+IN},dn=function(e){KY(t,e);function t(r){return e.call(this,fn.createOtlpHttpExportDelegate(fn.convertLegacyHttpOptions(r!==null&&r!==void 0?r:{},"METRICS","v1/metrics",An(An({},kY),{"Content-Type":"application/json"})),un),r)||this}return t}(pn)});var DN=S(()=>{yN()});var xN=S(()=>{DN()});var UN={};F(UN,{AggregationTemporalityPreference:()=>Be,CumulativeTemporalitySelector:()=>Gt,DeltaTemporalitySelector:()=>Sn,LowMemoryTemporalitySelector:()=>ln,OTLPMetricExporter:()=>dn,OTLPMetricExporterBase:()=>pn});var bN=S(()=>{xN();sa();_a()});import{createConnection as zY}from"net";import{AsyncLocalStorage as QY}from"async_hooks";import{appendFileSync as JY,mkdirSync as $Y,existsSync as ZY}from"fs";import{join as eF}from"path";import{workerData as Ea,isMainThread as _t,parentPort as tF}from"worker_threads";import{Database as rF}from"bun:sqlite";var se=null,ua=!1,Rn="node-app";function WY(){let e=(process.env.NODE_OTEL_ENABLED??"").trim().toLowerCase();if(e==="")return!0;return e==="1"||e==="true"||e==="on"||e==="yes"}function VN(){return(process.env.NODE_OTEL_ENDPOINT??"").trim()||"http://127.0.0.1:4318"}async function ca(e){if(Rn=e||Rn,ua||!WY())return;ua=!0;try{let t=await Promise.resolve().then(() => l(f(),1)),{BasicTracerProvider:r,BatchSpanProcessor:n}=await Promise.resolve().then(() => (nh(),rh)),{OTLPTraceExporter:i}=await Promise.resolve().then(() => (PN(),gN)),o=await Promise.resolve().then(() => (gr(),KO)),{W3CTraceContextPropagator:s}=await Promise.resolve().then(() => l(M(),1)),_=new i({url:`${VN()}/v1/traces`}),c={"service.name":e},a=typeof o.resourceFromAttributes==="function"?o.resourceFromAttributes(c):new o.Resource(c);new r({resource:a,spanProcessors:[new n(_)]}).register({propagator:new s});try{let{MeterProvider:E,PeriodicExportingMetricReader:A}=await Promise.resolve().then(() => (on(),dM)),{OTLPMetricExporter:R}=await Promise.resolve().then(() => (bN(),UN)),y=new E({resource:a,readers:[new A({exporter:new R({url:`${VN()}/v1/metrics`})})]});t.metrics.setGlobalMeterProvider(y)}catch(E){console.debug(`[node-app-sdk] metrics init skipped: ${String(E)}`)}se=t}catch(t){ua=!1,console.debug(`[node-app-sdk] telemetry init skipped: ${String(t)}`)}}function qY(){return se!==null}var wN=new Map;function XY(e,t=1,r){if(!se)return;let n=wN.get(e);if(!n)n=se.metrics.getMeter(Rn).createCounter(e),wN.set(e,n);n.add(t,r)}function BN(e){if(se)se.propagation.inject(se.context.active(),e);return e}async function GN(e,t,r){if(!se)return r();let n=se,i=n.propagation.extract(n.context.active(),t??{});return n.context.with(i,()=>n.trace.getTracer(Rn).startActiveSpan(`capability ${e}`,{kind:n.SpanKind.SERVER},async(s)=>{try{return await r()}catch(_){throw s.recordException(_),s.setStatus({code:n.SpanStatusCode.ERROR}),_}finally{s.end()}}))}var nF=1024;function R4(e,t={}){let r=t.cacheSizeKb??nF;if(!Number.isInteger(r)||r<=0)throw RangeError("cacheSizeKb must be a positive integer");let n=new rF(e);try{return n.exec(`PRAGMA cache_size = -${r}`),n}catch(i){throw n.close(),i}}function oF(){if(!_t&&Ea&&typeof Ea==="object"){let e=Ea;return{socket:typeof e.socket==="string"?e.socket:void 0,logDir:typeof e.logDir==="string"?e.logDir:void 0,dataDir:typeof e.dataDir==="string"?e.dataDir:void 0}}return{socket:process.env.NODE_APP_SOCKET,logDir:process.env.NODE_APP_LOG_DIR,dataDir:process.env.NODE_APP_DATA_DIR}}var la=oF();function O4(){return la.socket}function Ta(e,t,r=process.exit){if(t){r(e);return}tF?.close()}var Yt=la.logDir,HN=Yt?eF(Yt,"app.log"):null,Sa=!1;function iF(){if(Sa||!Yt)return;try{if(!ZY(Yt))$Y(Yt,{recursive:!0});Sa=!0}catch{}}function aF(e,t){if(!HN)return;if(iF(),!Sa)return;let n=`${new Date().toISOString()} [${e.toUpperCase().padEnd(5)}] ${t}
16
16
  `;try{JY(HN,n)}catch{}}var _e=null,FN=new QY,Ft=new Map,Ge={trace:(e)=>Ht("trace",e),debug:(e)=>Ht("debug",e),info:(e)=>Ht("info",e),warn:(e)=>Ht("warn",e),error:(e)=>Ht("error",e)};function Ht(e,t){if(aF(e,t),_e)_e({type:"log",level:e,message:t});else console[e==="trace"?"debug":e](t)}function h4(e,t){if(!_e)return Promise.reject(Error("Not connected to host"));let r=t??30000,n=e.timeout_ms===void 0?{...e,timeout_ms:r}:e,i={...n,trace_context:BN({...n.trace_context??{}})},o=FN.getStore();if(o?.active&&o.id!==void 0)i.invocation_context_id=o.id;return new Promise((s,_)=>{Ft.set(e.id,{resolve:s,reject:_}),_e({type:"invoke_capability",id:e.id,request:i}),setTimeout(()=>{if(Ft.has(e.id))Ft.delete(e.id),_(Error(`Capability invocation timed out after ${r}ms: ${e.capability}`))},r)})}function m4(e,t){if(!_e)throw Error("Not connected to host");_e({type:"publish_event",event_name:e,data:t})}var sF=30000;function _F(){let e=process.env.NODE_APP_MEMORY_SAMPLE_INTERVAL_MS,t=e?Number.parseInt(e,10):NaN;return Number.isFinite(t)&&t>=1000?t:sF}var ut=null;function uF(){let e=process.memoryUsage(),t={heap_used_kb:Math.round(e.heapUsed/1024),heap_total_kb:Math.round(e.heapTotal/1024)};try{let r=He("bun:jsc").heapStats();return{heap_used_kb:typeof r.heapSize==="number"?Math.round(r.heapSize/1024):t.heap_used_kb,heap_total_kb:t.heap_total_kb,...typeof r.extraMemorySize==="number"?{external_kb:Math.round(r.extraMemorySize/1024)}:{},...typeof r.heapCapacity==="number"?{heap_capacity_kb:Math.round(r.heapCapacity/1024)}:{}}}catch{return t}}function YN(e){e({type:"app_memory",...uF()})}function cF(e){if(ut)return;YN(e),ut=setInterval(()=>YN(e),_F()),ut.unref?.()}function On(){if(ut)clearInterval(ut),ut=null}async function EF(e,t=()=>Bun.generateHeapSnapshot("v8","arraybuffer"),r=(n,i)=>Bun.write(n,i)){let n=t();return{size_bytes:await r(e,n)}}async function TF(e,t,r=EF){try{let n=await r(e.path);t({type:"heap_snapshot_response",id:e.id,success:!0,size_bytes:n.size_bytes})}catch{t({type:"heap_snapshot_response",id:e.id,success:!1,error:"heap_snapshot_failed"})}}function SF(e,t){let r=t.indexOf("?"),n=r>=0?t.slice(0,r):t,i=e.split("/"),o=n.split("/"),s=0,_=0;while(s<i.length){if(i[s]==="**")return!0;if(_>=o.length)return!1;if(i[s]!=="*"&&i[s]!==o[_])return!1;s++,_++}return _===o.length}class lF{_routes=[];route(e,t,r,n){this._routes.push({method:e,path:t,policy:r,handler:n})}async init(e){}async shutdown(){}async handleRequest(e){if(this._routes.length>0)return this._dispatchRoute(e);return{status:501,headers:{},body:{error:"Not implemented"}}}async _dispatchRoute(e){let t=e.method.toUpperCase(),r=e.path;for(let n of this._routes){if(!(n.method==="*"||n.method.toUpperCase()===t))continue;if(!SF(n.path,r))continue;let o=n.policy.requiredPermissions??[],s=e.caller?.granted_permissions??[],_=o.filter((c)=>!s.includes(c));if(_.length>0)return Ge.warn(`SDK scope denied: [${_.join(", ")}] missing for ${t} ${r}`),{status:403,headers:{},body:{error:`Missing permissions: ${_.join(", ")}`}};return n.handler(e)}return this.notFound()}async handleEvent(e){}providedCapabilities(){return[]}async handleCapability(e){return{id:e.id,success:!1,payload:{error:"Capability handling not implemented"}}}json(e,t=200){return{status:t,headers:{"Content-Type":"application/json"},body:e}}error(e,t=500){return{status:t,headers:{"Content-Type":"application/json"},body:{error:e}}}notFound(){return this.error("Not found",404)}}function M4(e){let t=la.socket;if(!t)console.error("[node-app-sdk] NODE_APP_SOCKET environment variable not set"),process.exit(1);ca(e.metadata?.name??"node-app");let r="",n=zY(t,()=>{Ge.debug(`Connected to host via ${t}`)}),i=(o)=>{n.write(JSON.stringify(o)+`
17
17
  `)};_e=i,n.on("data",async(o)=>{r+=o.toString("utf-8");let s;while((s=r.indexOf(`
18
18
  `))!==-1){let _=r.slice(0,s).trim();if(r=r.slice(s+1),!_)continue;try{let c=JSON.parse(_);await jN(e,c,i)}catch(c){Ge.error(`Failed to parse IPC message: ${c}`)}}}),n.on("error",(o)=>{console.error(`[node-app-sdk] Socket error: ${o.message}`),Ta(1,_t)}),n.on("close",()=>{Ge.debug("Socket closed, shutting down"),On(),Ta(0,_t)}),process.on("SIGTERM",async()=>{if(!_t)return;On(),await e.shutdown(),n.end(),process.exit(0)}),process.on("SIGINT",async()=>{if(!_t)return;On(),await e.shutdown(),n.end(),process.exit(0)})}async function jN(e,t,r){switch(t.type){case"init":{let n=t.config;await e.init(n),r({type:"ready",metadata:e.metadata}),cF(r);break}case"request":{let{id:n,request:i}=t;try{let o=await e.handleRequest(i);r({type:"response",id:n,response:o})}catch(o){r({type:"response",id:n,response:{status:500,headers:{},body:{error:`Internal app error: ${o}`}}})}break}case"event":{let{event:n}=t;try{await e.handleEvent(n)}catch(i){Ge.error(`Event handler error: ${i}`)}break}case"capability_request":{let{id:n,request:i}=t,o={id:i.invocation_context_id,active:!0};try{let s=await FN.run(o,async()=>{try{return await GN(i.capability,i.trace_context,()=>e.handleCapability(i))}finally{o.active=!1}});r({type:"capability_response",id:n,response:s})}catch(s){r({type:"capability_response",id:n,response:{id:i.id,success:!1,payload:{error:`Capability handler error: ${s}`}}})}break}case"invoke_capability_result":{let{id:n,response:i}=t,o=Ft.get(n);if(o)Ft.delete(n),o.resolve(i);break}case"shutdown":{Ge.info("Received shutdown signal from host"),On(),await e.shutdown(),Ta(0,_t);break}case"heap_snapshot_request":{await TF(t,r);break}default:Ge.warn(`Unknown IPC message type: ${t.type}`)}}async function N4(e,t,r){_e=r,await jN(e,t,_e)}export{lF as NodeApp,EF as _captureHeapSnapshotTo,TF as _handleHeapSnapshotRequest,oF as _resolveCtx,uF as _sampleMemory,Ta as _testExitWorker,N4 as _testHandleMessage,O4 as _testRunNodeAppPath,Ge as host,XY as incrementCounter,ca as initAppTelemetry,h4 as invokeCapability,R4 as openDatabase,m4 as publishEvent,M4 as runNodeApp,qY as telemetryActive};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The versioned managed-v1 SDK seam.
3
+ *
4
+ * This is intentionally separate from index.ts, whose newline-delimited IPC
5
+ * protocol is the legacy Bun app contract. The host and this module both own
6
+ * the managed-v1 length prefix and canonical JSON rules.
7
+ */
8
+ export declare const MANAGED_V1_VERSION: "managed-v1";
9
+ export declare const MAX_FRAME_BYTES: number;
10
+ export type ManagedErrorFamily = "protocol" | "limit" | "epoch" | "app";
11
+ export interface ManagedCapabilityRequest {
12
+ type: "capability_request";
13
+ id: string;
14
+ nonce: string;
15
+ epoch: number;
16
+ capability: string;
17
+ payload: unknown;
18
+ timeout_ms: number;
19
+ }
20
+ export interface ManagedCapabilityResponse {
21
+ type: "capability_response";
22
+ id: string;
23
+ nonce: string;
24
+ epoch: number;
25
+ success: boolean;
26
+ payload: unknown;
27
+ }
28
+ export declare class ManagedProtocolError extends Error {
29
+ readonly family: ManagedErrorFamily;
30
+ constructor(family: ManagedErrorFamily, message: string);
31
+ }
32
+ export declare function encodeManagedFrame(value: unknown): Buffer;
33
+ export declare function decodeManagedFrame(frame: Buffer): unknown;
34
+ export declare class SessionNonce {
35
+ readonly value: string;
36
+ readonly version: typeof MANAGED_V1_VERSION;
37
+ private constructor();
38
+ static generate(): SessionNonce;
39
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@econ-v1/app-sdk",
3
- "version": "6.16.0",
3
+ "version": "6.18.0",
4
4
  "description": "TypeScript SDK for building Node mini-app plugins (Bun runtime) on the Lightning-powered marketplace daemon",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "Node contributors",