@basmilius/apple-devices 0.8.1 → 0.8.2

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.mjs CHANGED
@@ -1,2 +1,2827 @@
1
- import{EventEmitter as e}from"node:events";import*as t from"@basmilius/apple-airplay";import{DataStreamMessage as n,Proto as r,Protocol as i}from"@basmilius/apple-airplay";import{waitFor as a}from"@basmilius/apple-common";import{Protocol as o,convertAttentionState as s}from"@basmilius/apple-companion-link";const c=Symbol(`com.basmilius.airplay:protocol`),l=Symbol(`com.basmilius.airplay:subscribe`),u=Symbol(`com.basmilius.airplay:unsubscribe`);var d=class{get#e(){return this.#t.dataStream}get#t(){return this.#n[c]}#n;constructor(e){this.#n=e}async up(){await this.pressAndRelease(1,140)}async down(){await this.pressAndRelease(1,141)}async left(){await this.pressAndRelease(1,139)}async right(){await this.pressAndRelease(1,138)}async menu(){await this.pressAndRelease(1,134)}async play(){await this.pressAndRelease(12,176)}async playPause(){this.#n.state.nowPlayingClient?.playbackState===r.PlaybackState_Enum.Playing?await this.pause():await this.play()}async pause(){await this.pressAndRelease(12,177)}async next(){await this.pressAndRelease(12,181)}async previous(){await this.pressAndRelease(12,182)}async suspend(){await this.pressAndRelease(1,130)}async select(){await this.pressAndRelease(1,137)}async wake(){await this.pressAndRelease(1,131)}async home(){await this.pressAndRelease(12,64)}async volumeUp(){await this.pressAndRelease(12,233)}async volumeDown(){await this.pressAndRelease(12,234)}async mute(){await this.pressAndRelease(12,226)}async doublePress(e,t){await this.pressAndRelease(e,t),await a(150),await this.pressAndRelease(e,t)}async longPress(e,t,r=1e3){await this.#e.exchange(n.sendHIDEvent(e,t,!0)),await a(r),await this.#e.exchange(n.sendHIDEvent(e,t,!1))}async pressAndRelease(e,t){await this.#e.exchange(n.sendHIDEvent(e,t,!0)),await a(25),await this.#e.exchange(n.sendHIDEvent(e,t,!1))}},f=typeof global==`object`&&global&&global.Object===Object&&global,p=typeof self==`object`&&self&&self.Object===Object&&self,m=f||p||Function(`return this`)(),h=m.Symbol,g=Object.prototype,ee=g.hasOwnProperty,te=g.toString,_=h?h.toStringTag:void 0;function ne(e){var t=ee.call(e,_),n=e[_];try{e[_]=void 0;var r=!0}catch{}var i=te.call(e);return r&&(t?e[_]=n:delete e[_]),i}var re=Object.prototype.toString;function ie(e){return re.call(e)}var ae=`[object Null]`,oe=`[object Undefined]`,se=h?h.toStringTag:void 0;function v(e){return e==null?e===void 0?oe:ae:se&&se in Object(e)?ne(e):ie(e)}function y(e){return typeof e==`object`&&!!e}var b=Array.isArray;function x(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function S(e){return e}var ce=`[object AsyncFunction]`,le=`[object Function]`,ue=`[object GeneratorFunction]`,de=`[object Proxy]`;function C(e){if(!x(e))return!1;var t=v(e);return t==le||t==ue||t==ce||t==de}var w=m[`__core-js_shared__`],T=function(){var e=/[^.]+$/.exec(w&&w.keys&&w.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function fe(e){return!!T&&T in e}var pe=Function.prototype.toString;function me(e){if(e!=null){try{return pe.call(e)}catch{}try{return e+``}catch{}}return``}var he=/[\\^$.*+?()[\]{}|]/g,ge=/^\[object .+?Constructor\]$/,_e=Function.prototype,ve=Object.prototype,ye=_e.toString,be=ve.hasOwnProperty,xe=RegExp(`^`+ye.call(be).replace(he,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Se(e){return!x(e)||fe(e)?!1:(C(e)?xe:ge).test(me(e))}function Ce(e,t){return e?.[t]}function E(e,t){var n=Ce(e,t);return Se(n)?n:void 0}var we=Object.create,Te=function(){function e(){}return function(t){if(!x(t))return{};if(we)return we(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Ee(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function De(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var Oe=800,ke=16,Ae=Date.now;function je(e){var t=0,n=0;return function(){var r=Ae(),i=ke-(r-n);if(n=r,i>0){if(++t>=Oe)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function Me(e){return function(){return e}}var D=function(){try{var e=E(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),Ne=je(D?function(e,t){return D(e,`toString`,{configurable:!0,enumerable:!1,value:Me(t),writable:!0})}:S),Pe=9007199254740991,Fe=/^(?:0|[1-9]\d*)$/;function Ie(e,t){var n=typeof e;return t??=Pe,!!t&&(n==`number`||n!=`symbol`&&Fe.test(e))&&e>-1&&e%1==0&&e<t}function O(e,t,n){t==`__proto__`&&D?D(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function k(e,t){return e===t||e!==e&&t!==t}var Le=Object.prototype.hasOwnProperty;function Re(e,t,n){var r=e[t];(!(Le.call(e,t)&&k(r,n))||n===void 0&&!(t in e))&&O(e,t,n)}function ze(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?O(n,s,c):Re(n,s,c)}return n}var A=Math.max;function Be(e,t,n){return t=A(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=A(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),Ee(e,this,s)}}function Ve(e,t){return Ne(Be(e,t,S),e+``)}var He=9007199254740991;function Ue(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=He}function j(e){return e!=null&&Ue(e.length)&&!C(e)}function We(e,t,n){if(!x(n))return!1;var r=typeof t;return(r==`number`?j(n)&&Ie(t,n.length):r==`string`&&t in n)?k(n[t],e):!1}function Ge(e){return Ve(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&We(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var Ke=Object.prototype;function qe(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Ke)}function Je(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Ye=`[object Arguments]`;function M(e){return y(e)&&v(e)==Ye}var N=Object.prototype,Xe=N.hasOwnProperty,Ze=N.propertyIsEnumerable,P=M(function(){return arguments}())?M:function(e){return y(e)&&Xe.call(e,`callee`)&&!Ze.call(e,`callee`)};function Qe(){return!1}var $e=typeof exports==`object`&&exports&&!exports.nodeType&&exports,et=$e&&typeof module==`object`&&module&&!module.nodeType&&module,tt=et&&et.exports===$e?m.Buffer:void 0,nt=(tt?tt.isBuffer:void 0)||Qe,rt=`[object Arguments]`,it=`[object Array]`,at=`[object Boolean]`,ot=`[object Date]`,st=`[object Error]`,ct=`[object Function]`,lt=`[object Map]`,ut=`[object Number]`,dt=`[object Object]`,ft=`[object RegExp]`,pt=`[object Set]`,mt=`[object String]`,ht=`[object WeakMap]`,gt=`[object ArrayBuffer]`,_t=`[object DataView]`,vt=`[object Float32Array]`,yt=`[object Float64Array]`,bt=`[object Int8Array]`,xt=`[object Int16Array]`,St=`[object Int32Array]`,Ct=`[object Uint8Array]`,wt=`[object Uint8ClampedArray]`,Tt=`[object Uint16Array]`,Et=`[object Uint32Array]`,F={};F[vt]=F[yt]=F[bt]=F[xt]=F[St]=F[Ct]=F[wt]=F[Tt]=F[Et]=!0,F[rt]=F[it]=F[gt]=F[at]=F[_t]=F[ot]=F[st]=F[ct]=F[lt]=F[ut]=F[dt]=F[ft]=F[pt]=F[mt]=F[ht]=!1;function Dt(e){return y(e)&&Ue(e.length)&&!!F[v(e)]}function Ot(e){return function(t){return e(t)}}var I=typeof exports==`object`&&exports&&!exports.nodeType&&exports,L=I&&typeof module==`object`&&module&&!module.nodeType&&module,R=L&&L.exports===I&&f.process,z=function(){try{return L&&L.require&&L.require(`util`).types||R&&R.binding&&R.binding(`util`)}catch{}}(),B=z&&z.isTypedArray,V=B?Ot(B):Dt,kt=Object.prototype.hasOwnProperty;function At(e,t){var n=b(e),r=!n&&P(e),i=!n&&!r&&nt(e),a=!n&&!r&&!i&&V(e),o=n||r||i||a,s=o?Je(e.length,String):[],c=s.length;for(var l in e)(t||kt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||Ie(l,c)))&&s.push(l);return s}function jt(e,t){return function(n){return e(t(n))}}function Mt(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Nt=Object.prototype.hasOwnProperty;function Pt(e){if(!x(e))return Mt(e);var t=qe(e),n=[];for(var r in e)r==`constructor`&&(t||!Nt.call(e,r))||n.push(r);return n}function H(e){return j(e)?At(e,!0):Pt(e)}var U=E(Object,`create`);function Ft(){this.__data__=U?U(null):{},this.size=0}function It(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Lt=`__lodash_hash_undefined__`,Rt=Object.prototype.hasOwnProperty;function zt(e){var t=this.__data__;if(U){var n=t[e];return n===Lt?void 0:n}return Rt.call(t,e)?t[e]:void 0}var Bt=Object.prototype.hasOwnProperty;function Vt(e){var t=this.__data__;return U?t[e]!==void 0:Bt.call(t,e)}var Ht=`__lodash_hash_undefined__`;function Ut(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=U&&t===void 0?Ht:t,this}function W(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}W.prototype.clear=Ft,W.prototype.delete=It,W.prototype.get=zt,W.prototype.has=Vt,W.prototype.set=Ut;function Wt(){this.__data__=[],this.size=0}function G(e,t){for(var n=e.length;n--;)if(k(e[n][0],t))return n;return-1}var Gt=Array.prototype.splice;function Kt(e){var t=this.__data__,n=G(t,e);return n<0?!1:(n==t.length-1?t.pop():Gt.call(t,n,1),--this.size,!0)}function qt(e){var t=this.__data__,n=G(t,e);return n<0?void 0:t[n][1]}function Jt(e){return G(this.__data__,e)>-1}function Yt(e,t){var n=this.__data__,r=G(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function K(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}K.prototype.clear=Wt,K.prototype.delete=Kt,K.prototype.get=qt,K.prototype.has=Jt,K.prototype.set=Yt;var Xt=E(m,`Map`);function Zt(){this.size=0,this.__data__={hash:new W,map:new(Xt||K),string:new W}}function Qt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function q(e,t){var n=e.__data__;return Qt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function $t(e){var t=q(this,e).delete(e);return this.size-=t?1:0,t}function en(e){return q(this,e).get(e)}function tn(e){return q(this,e).has(e)}function nn(e,t){var n=q(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function J(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}J.prototype.clear=Zt,J.prototype.delete=$t,J.prototype.get=en,J.prototype.has=tn,J.prototype.set=nn;var Y=jt(Object.getPrototypeOf,Object),rn=`[object Object]`,an=Function.prototype,on=Object.prototype,sn=an.toString,cn=on.hasOwnProperty,ln=sn.call(Object);function un(e){if(!y(e)||v(e)!=rn)return!1;var t=Y(e);if(t===null)return!0;var n=cn.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&sn.call(n)==ln}function dn(){this.__data__=new K,this.size=0}function fn(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function pn(e){return this.__data__.get(e)}function mn(e){return this.__data__.has(e)}var hn=200;function gn(e,t){var n=this.__data__;if(n instanceof K){var r=n.__data__;if(!Xt||r.length<hn-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new J(r)}return n.set(e,t),this.size=n.size,this}function X(e){this.size=(this.__data__=new K(e)).size}X.prototype.clear=dn,X.prototype.delete=fn,X.prototype.get=pn,X.prototype.has=mn,X.prototype.set=gn;var _n=typeof exports==`object`&&exports&&!exports.nodeType&&exports,vn=_n&&typeof module==`object`&&module&&!module.nodeType&&module,yn=vn&&vn.exports===_n?m.Buffer:void 0,bn=yn?yn.allocUnsafe:void 0;function xn(e,t){if(t)return e.slice();var n=e.length,r=bn?bn(n):new e.constructor(n);return e.copy(r),r}var Sn=m.Uint8Array;function Cn(e){var t=new e.constructor(e.byteLength);return new Sn(t).set(new Sn(e)),t}function wn(e,t){var n=t?Cn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Tn(e){return typeof e.constructor==`function`&&!qe(e)?Te(Y(e)):{}}function En(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Dn=En();function Z(e,t,n){(n!==void 0&&!k(e[t],n)||n===void 0&&!(t in e))&&O(e,t,n)}function On(e){return y(e)&&j(e)}function Q(e,t){if(!(t===`constructor`&&typeof e[t]==`function`)&&t!=`__proto__`)return e[t]}function kn(e){return ze(e,H(e))}function An(e,t,n,r,i,a,o){var s=Q(e,n),c=Q(t,n),l=o.get(c);if(l){Z(e,n,l);return}var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=b(c),p=!f&&nt(c),m=!f&&!p&&V(c);u=c,f||p||m?b(s)?u=s:On(s)?u=De(s):p?(d=!1,u=xn(c,!0)):m?(d=!1,u=wn(c,!0)):u=[]:un(c)||P(c)?(u=s,P(s)?u=kn(s):(!x(s)||C(s))&&(u=Tn(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),Z(e,n,u)}function jn(e,t,n,r,i){e!==t&&Dn(t,function(a,o){if(i||=new X,x(a))An(e,t,o,n,jn,r,i);else{var s=r?r(Q(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),Z(e,o,s)}},H)}var Mn=Ge(function(e,t,n){jn(e,t,n)}),Nn=class{get bundleIdentifier(){return this.#e}get displayName(){return this.#t}get playbackQueue(){return this.#n}get playbackState(){return this.#r}get playbackStateTimestamp(){return this.#i}get supportedCommands(){return this.#a}#e;#t;#n=null;#r;#i;#a=[];constructor(e,t){this.#e=e,this.#t=t,this.#r=r.PlaybackState_Enum.Unknown,this.#a=[]}isCommandSupported(e){return this.#a.some(t=>t.command===e)}setPlaybackQueue(e){this.#n=e}setPlaybackState(e,t){t<this.#i||(this.#r=e,this.#i=t)}setSupportedCommands(e){this.#a=e}updateContentItem(e){if(!this.#n)return;let t=this.#n.contentItems.findIndex(t=>t.identifier===e.identifier);t!==-1&&(this.#n.contentItems[t]=Mn(e,this.#n.contentItems[t]))}},Pn=class extends e{get#e(){return this.#t.dataStream}get#t(){return this.#n[c]}get clients(){return this.#r}get nowPlayingClient(){return this.#i?this.#r[this.#i]??null:null}get outputDeviceUID(){return this.#a}get volume(){return this.#o}get volumeAvailable(){return this.#s}get volumeCapabilities(){return this.#c}#n;#r;#i;#a;#o;#s;#c;constructor(e){super(),this.#n=e,this.clear(),this.onDeviceInfo=this.onDeviceInfo.bind(this),this.onDeviceInfoUpdate=this.onDeviceInfoUpdate.bind(this),this.onOriginClientProperties=this.onOriginClientProperties.bind(this),this.onPlayerClientProperties=this.onPlayerClientProperties.bind(this),this.onRemoveClient=this.onRemoveClient.bind(this),this.onSendCommandResult=this.onSendCommandResult.bind(this),this.onSetArtwork=this.onSetArtwork.bind(this),this.onSetDefaultSupportedCommands=this.onSetDefaultSupportedCommands.bind(this),this.onSetNowPlayingClient=this.onSetNowPlayingClient.bind(this),this.onSetNowPlayingPlayer=this.onSetNowPlayingPlayer.bind(this),this.onSetState=this.onSetState.bind(this),this.onUpdateClient=this.onUpdateClient.bind(this),this.onUpdateContentItem=this.onUpdateContentItem.bind(this),this.onUpdateContentItemArtwork=this.onUpdateContentItemArtwork.bind(this),this.onUpdatePlayer=this.onUpdatePlayer.bind(this),this.onUpdateOutputDevice=this.onUpdateOutputDevice.bind(this),this.onVolumeControlAvailability=this.onVolumeControlAvailability.bind(this),this.onVolumeControlCapabilitiesDidChange=this.onVolumeControlCapabilitiesDidChange.bind(this),this.onVolumeDidChange=this.onVolumeDidChange.bind(this)}[l](){this.#e.on(`deviceInfo`,this.onDeviceInfo),this.#e.on(`deviceInfoUpdate`,this.onDeviceInfoUpdate),this.#e.on(`originClientProperties`,this.onOriginClientProperties),this.#e.on(`playerClientProperties`,this.onPlayerClientProperties),this.#e.on(`removeClient`,this.onRemoveClient),this.#e.on(`sendCommandResult`,this.onSendCommandResult),this.#e.on(`setArtwork`,this.onSetArtwork),this.#e.on(`setDefaultSupportedCommands`,this.onSetDefaultSupportedCommands),this.#e.on(`setNowPlayingClient`,this.onSetNowPlayingClient),this.#e.on(`setNowPlayingPlayer`,this.onSetNowPlayingPlayer),this.#e.on(`setState`,this.onSetState),this.#e.on(`updateClient`,this.onUpdateClient),this.#e.on(`updateContentItem`,this.onUpdateContentItem),this.#e.on(`updateContentItemArtwork`,this.onUpdateContentItemArtwork),this.#e.on(`updatePlayer`,this.onUpdatePlayer),this.#e.on(`updateOutputDevice`,this.onUpdateOutputDevice),this.#e.on(`volumeControlAvailability`,this.onVolumeControlAvailability),this.#e.on(`volumeControlCapabilitiesDidChange`,this.onVolumeControlCapabilitiesDidChange),this.#e.on(`volumeDidChange`,this.onVolumeDidChange)}[u](){let e=this.#e;e&&(e.off(`deviceInfo`,this.onDeviceInfo),e.off(`deviceInfoUpdate`,this.onDeviceInfoUpdate),e.off(`originClientProperties`,this.onOriginClientProperties),e.off(`playerClientProperties`,this.onPlayerClientProperties),e.off(`removeClient`,this.onRemoveClient),e.off(`sendCommandResult`,this.onSendCommandResult),e.off(`setArtwork`,this.onSetArtwork),e.off(`setDefaultSupportedCommands`,this.onSetDefaultSupportedCommands),e.off(`setNowPlayingClient`,this.onSetNowPlayingClient),e.off(`setNowPlayingPlayer`,this.onSetNowPlayingPlayer),e.off(`setState`,this.onSetState),e.off(`updateClient`,this.onUpdateClient),e.off(`updateContentItem`,this.onUpdateContentItem),e.off(`updateContentItemArtwork`,this.onUpdateContentItemArtwork),e.off(`updatePlayer`,this.onUpdatePlayer),e.off(`updateOutputDevice`,this.onUpdateOutputDevice),e.off(`volumeControlAvailability`,this.onVolumeControlAvailability),e.off(`volumeControlCapabilitiesDidChange`,this.onVolumeControlCapabilitiesDidChange),e.off(`volumeDidChange`,this.onVolumeDidChange))}clear(){this.#r={},this.#i=null,this.#a=null,this.#o=0,this.#s=!1,this.#c=r.VolumeCapabilities_Enum.None}onDeviceInfo(e){e.clusterID?this.#a=e.clusterID:e.deviceUID?this.#a=e.deviceUID:e.uniqueIdentifier&&(this.#a=e.uniqueIdentifier),this.emit(`deviceInfo`,e)}onDeviceInfoUpdate(e){e.clusterID?this.#a=e.clusterID:e.deviceUID?this.#a=e.deviceUID:e.uniqueIdentifier&&(this.#a=e.uniqueIdentifier),this.emit(`deviceInfoUpdate`,e)}onOriginClientProperties(e){this.emit(`originClientProperties`,e)}onPlayerClientProperties(e){this.emit(`playerClientProperties`,e)}onRemoveClient(e){e.client.bundleIdentifier in this.#r&&(delete this.#r[e.client.bundleIdentifier],this.emit(`clients`,this.#r))}onSendCommandResult(e){this.emit(`sendCommandResult`,e)}onSetArtwork(e){this.emit(`setArtwork`,e)}onSetDefaultSupportedCommands(e){this.emit(`setDefaultSupportedCommands`,e)}onSetNowPlayingClient(e){this.#i=e.client?.bundleIdentifier??null,this.emit(`setNowPlayingClient`,e)}onSetNowPlayingPlayer(e){this.emit(`setNowPlayingPlayer`,e)}onSetState(e){let t=this.#l(e.playerPath.client.bundleIdentifier,e.displayName);e.playbackState&&t.setPlaybackState(e.playbackState,e.playbackStateTimestamp),e.supportedCommands&&t.setSupportedCommands(e.supportedCommands.supportedCommands),e.playbackQueue&&t.setPlaybackQueue(e.playbackQueue),this.emit(`setState`,e)}onUpdateContentItem(e){let t=this.#l(e.playerPath.client.bundleIdentifier,e.playerPath.client.displayName);if(t){for(let n of e.contentItems)t.updateContentItem(n);this.emit(`updateContentItem`,e)}}onUpdateContentItemArtwork(e){this.emit(`updateContentItemArtwork`,e)}onUpdatePlayer(e){this.emit(`updatePlayer`,e)}onUpdateClient(e){this.#l(e.client.bundleIdentifier,e.client.displayName),this.emit(`clients`,this.#r)}onUpdateOutputDevice(e){this.emit(`updateOutputDevice`,e)}onVolumeControlAvailability(e){this.#s=e.volumeControlAvailable,this.#c=e.volumeCapabilities,this.emit(`volumeControlAvailability`,e.volumeControlAvailable,e.volumeCapabilities)}onVolumeControlCapabilitiesDidChange(e){this.#s=e.capabilities.volumeControlAvailable,this.#c=e.capabilities.volumeCapabilities,this.emit(`volumeControlCapabilitiesDidChange`,e.capabilities.volumeControlAvailable,e.capabilities.volumeCapabilities)}onVolumeDidChange(e){this.#o=e.volume,this.emit(`volumeDidChange`,e.volume)}#l(e,t){if(e in this.#r)return this.#r[e];{let n=new Nn(e,t);return this.#r[e]=n,this.emit(`clients`,this.#r),n}}};const Fn=.05;var In=class{get#e(){return this.#n[c]}get#t(){return this.#n.state}#n;constructor(e){this.#n=e}async down(){switch(this.#t.volumeCapabilities){case r.VolumeCapabilities_Enum.Absolute:case r.VolumeCapabilities_Enum.Both:let e=Math.max(0,this.#t.volume-Fn);await this.set(e);break;case r.VolumeCapabilities_Enum.Relative:await this.#n.remote.volumeDown();break;default:throw Error(`Volume control is not available.`)}}async up(){switch(this.#t.volumeCapabilities){case r.VolumeCapabilities_Enum.Absolute:case r.VolumeCapabilities_Enum.Both:let e=Math.max(0,this.#t.volume+Fn);await this.set(e);break;case r.VolumeCapabilities_Enum.Relative:await this.#n.remote.volumeUp();break;default:throw Error(`Volume control is not available.`)}}async get(){if(!this.#t.outputDeviceUID)throw Error(`No output device active.`);let e=await this.#e.dataStream.exchange(n.getVolume(this.#t.outputDeviceUID));if(e.type===r.ProtocolMessage_Type.GET_VOLUME_RESULT_MESSAGE)return n.getExtension(e,r.getVolumeResultMessage).volume;throw Error(`Failed to get volume.`)}async set(e){if(!this.#t.outputDeviceUID)throw Error(`No output device active.`);if(![r.VolumeCapabilities_Enum.Absolute,r.VolumeCapabilities_Enum.Both].includes(this.#t.volumeCapabilities))throw Error(`Absolute volume control is not available.`);e=Math.min(1,Math.max(0,e)),this.#e.context.logger.info(`Setting volume to ${e} for device ${this.#t.outputDeviceUID}`),await this.#e.dataStream.exchange(n.setVolume(this.#t.outputDeviceUID,e))}},$=class extends e{get[c](){return this.#c}get discoveryResult(){return this.#a}set discoveryResult(e){this.#a=e}get isConnected(){return this.#c?.controlStream?.isConnected??!1}get remote(){return this.#e}get state(){return this.#t}get volume(){return this.#n}get timingServer(){return this.#l}set timingServer(e){this.#l=e}#e;#t;#n;#r;#i=!1;#a;#o;#s;#c;#l;constructor(e){super(),this.#a=e,this.#e=new d(this),this.#t=new Pn(this),this.#n=new In(this)}async connect(){this.#i=!1,this.#t.clear(),this.#c=new i(this.#a),this.#c.controlStream.on(`close`,this.#d.bind(this)),this.#c.controlStream.on(`error`,this.#f.bind(this)),this.#c.controlStream.on(`timeout`,this.#p.bind(this)),await this.#c.connect(),this.#r?this.#s=await this.#c.verify.start(this.#r):(await this.#c.pairing.start(),this.#s=await this.#c.pairing.transient()),await this.#m(),this.emit(`connected`)}disconnect(){this.#i=!0,this.#o&&=(clearInterval(this.#o),void 0),this.#g(),this.#c.disconnect()}disconnectSafely(){try{this.disconnect()}catch{}}async requestPlaybackQueue(e){await this.#c.dataStream.exchange(n.playbackQueueRequest(0,e))}async sendCommand(e,t){await this.#c.dataStream.exchange(n.sendCommand(e,t))}setCredentials(e){this.#r=e}async#u(){try{await this.#c.feedback()}catch(e){this.#c.context.logger.error(`Feedback error`,e)}}#d(){this.#c.context.logger.net(`#onClose() called on airplay device.`),this.#i?this.emit(`disconnected`,!1):(this.disconnectSafely(),this.emit(`disconnected`,!0))}#f(e){this.#c.context.logger.error(`AirPlay error`,e)}#p(){this.#c.context.logger.error(`AirPlay timeout`),this.#c.controlStream.destroy()}async#m(){let e=this.#s;this.#c.controlStream.enableEncryption(e.accessoryToControllerKey,e.controllerToAccessoryKey),this.#g(),this.#l&&this.#c.useTimingServer(this.#l),await this.#c.setupEventStream(e.sharedSecret,e.pairingId),await this.#c.setupDataStream(e.sharedSecret,()=>this.#h()),this.#c.dataStream.on(`error`,this.#f.bind(this)),this.#c.dataStream.on(`timeout`,this.#p.bind(this)),this.#c.eventStream.on(`error`,this.#f.bind(this)),this.#c.eventStream.on(`timeout`,this.#p.bind(this)),this.#o=setInterval(async()=>await this.#u(),2e3);try{await this.#c.dataStream.exchange(n.setConnectionState(r.SetConnectionStateMessage_ConnectionState.Connecting)),await a(500);let t=this.#a.txt.gid;t&&await this.#c.dataStream.exchange(n.configureConnection(t)),await Promise.race([new Promise(async t=>{this.#c.dataStream.once(`deviceInfo`,async()=>{await this.#c.dataStream.exchange(n.setConnectionState()),await this.#c.dataStream.exchange(n.clientUpdatesConfig()),t(!0)}),await this.#c.dataStream.exchange(n.deviceInfo(e.pairingId))}),async()=>(await a(3e3),!1)])?this.#c.context.logger.info(`Device info received successfully, protocol should be ready.`):this.#f(Error(`Device did not respond in time with its info.`))}catch(e){throw clearInterval(this.#o),this.#o=void 0,e}}#h(){this.#t[l]()}#g(){try{this.#t[u]()}catch(e){this.#c.context.logger.error(`State unsubscribe error`,e)}}};const Ln=Symbol(`com.basmilius.companion-link:protocol`);var Rn=class extends e{get[Ln](){return this.#a}get discoveryResult(){return this.#n}set discoveryResult(e){this.#n=e}get isConnected(){return this.#a?.stream?.isConnected??!1}#e;#t=!1;#n;#r;#i;#a;constructor(e){super(),this.#n=e,this.onSystemStatus=this.onSystemStatus.bind(this),this.onTVSystemStatus=this.onTVSystemStatus.bind(this)}async connect(){if(!this.#e)throw Error(`Credentials are required to connect to a Companion Link device.`);this.#t=!1,this.#a=new o(this.#n),this.#a.stream.on(`close`,async()=>this.#s()),this.#a.stream.on(`error`,async e=>this.#c(e)),this.#a.stream.on(`timeout`,async()=>this.#l()),await this.#a.connect(),this.#i=await this.#a.verify.start(this.#e),await this.#u(),this.emit(`connected`)}async disconnect(){this.#t=!0,this.#r&&=(clearInterval(this.#r),void 0),await this.#f(),await this.#a.disconnect()}async disconnectSafely(){try{await this.disconnect()}catch{}}async setCredentials(e){this.#e=e}async getAttentionState(){return await this.#a.getAttentionState()}async getLaunchableApps(){return await this.#a.getLaunchableApps()}async getUserAccounts(){return await this.#a.getUserAccounts()}async launchApp(e){await this.#a.launchApp(e)}async launchUrl(e){await this.#a.launchUrl(e)}async mediaControlCommand(e,t){await this.#a.mediaControlCommand(e,t)}async pressButton(e,t,n){await this.#a.pressButton(e,t,n)}async switchUserAccount(e){await this.#a.switchUserAccount(e)}async#o(){try{this.#a.noOp()}catch(e){this.#a.context.logger.error(`Heartbeat error`,e)}}async#s(){this.#a.context.logger.net(`#onClose() called on companion link device.`),this.#t?this.emit(`disconnected`,!1):(await this.disconnectSafely(),this.emit(`disconnected`,!0))}async#c(e){this.#a.context.logger.error(`Companion Link error`,e)}async#l(){this.#a.context.logger.error(`Companion Link timeout`),await this.#a.stream.destroy()}async#u(){let e=this.#i;this.#a.stream.enableEncryption(e.accessoryToControllerKey,e.controllerToAccessoryKey);try{await this.#a.systemInfo(this.#e.pairingId),await this.#a.sessionStart(),await this.#a.tvrcSessionStart(),await this.#a.touchStart(),await this.#a.tiStart(),await this.#a.unsubscribe(`_iMC`),this.#r=setInterval(async()=>await this.#o(),15e3),await this.#d()}catch(e){throw clearInterval(this.#r),this.#r=void 0,e}}async#d(){await this.#a.subscribe(`SystemStatus`,this.onSystemStatus),await this.#a.subscribe(`TVSystemStatus`,this.onTVSystemStatus);let e=await this.getAttentionState();this.emit(`power`,e)}async#f(){try{await this.#a.unsubscribe(`SystemStatus`,this.onSystemStatus),await this.#a.unsubscribe(`TVSystemStatus`,this.onTVSystemStatus)}catch{}}async onSystemStatus(e){this.#a.context.logger.info(`System Status`,e),this.emit(`power`,s(e.state))}async onTVSystemStatus(e){this.#a.context.logger.info(`TV System Status`,e),this.emit(`power`,s(e.state))}},zn=class extends e{get airplay(){return this.#e}get companionLink(){return this.#t}get bundleIdentifier(){return this.#e.state.nowPlayingClient?.bundleIdentifier??null}get displayName(){return this.#e.state.nowPlayingClient?.displayName??null}get isConnected(){return this.#e.isConnected&&this.#t.isConnected}get isPlaying(){return this.playbackState===t.Proto.PlaybackState_Enum.Playing}get playbackQueue(){return this.#e.state.nowPlayingClient?.playbackQueue??null}get playbackState(){return this.#e.state.nowPlayingClient?.playbackState??t.Proto.PlaybackState_Enum.Unknown}get playbackStateTimestamp(){return this.#e.state.nowPlayingClient?.playbackStateTimestamp??-1}#e;#t;#n=!1;constructor(e,t){super(),this.#e=new $(e),this.#t=new Rn(t),this.#e.on(`connected`,()=>this.#r()),this.#e.on(`disconnected`,e=>this.#i(e)),this.#t.on(`connected`,()=>this.#r()),this.#t.on(`disconnected`,e=>this.#i(e))}async connect(e){await this.#e.setCredentials(e),await this.#t.setCredentials(e),await this.#e.connect(),await this.#t.connect(),this.#n=!1}async disconnect(){await this.#e.disconnect(),await this.#t.disconnect()}async turnOff(){await this.#e.remote.suspend()}async turnOn(){await this.#e.remote.wake()}async pause(){await this.#e.sendCommand(t.Proto.Command.Pause)}async playPause(){await this.#e.sendCommand(t.Proto.Command.TogglePlayPause)}async play(){await this.#e.sendCommand(t.Proto.Command.Play)}async stop(){await this.#e.sendCommand(t.Proto.Command.Stop)}async next(){await this.#e.sendCommand(t.Proto.Command.NextInContext)}async previous(){await this.#e.sendCommand(t.Proto.Command.PreviousInContext)}async volumeDown(){await this.#e.remote.volumeDown()}async volumeMute(){await this.#e.remote.mute()}async volumeUp(){await this.#e.remote.volumeUp()}async getCommandInfo(e){let t=this.#e.state.nowPlayingClient;return t?t.supportedCommands.find(t=>t.command===e)??null:null}async isCommandSupported(e){let t=this.#e.state.nowPlayingClient;return t?t.isCommandSupported(e):!1}async#r(){!this.#e.isConnected||!this.#t.isConnected||this.emit(`connected`)}async#i(e){this.#n||(this.#n=!0,await this.disconnect(),this.emit(`disconnected`,e))}},Bn=class extends e{get airplay(){return this.#e}get bundleIdentifier(){return this.#e.state.nowPlayingClient?.bundleIdentifier??null}get displayName(){return this.#e.state.nowPlayingClient?.displayName??null}get isConnected(){return this.#e.isConnected}get isPlaying(){return this.playbackState===t.Proto.PlaybackState_Enum.Playing}get playbackQueue(){return this.#e.state.nowPlayingClient?.playbackQueue??null}get playbackState(){return this.#e.state.nowPlayingClient?.playbackState??t.Proto.PlaybackState_Enum.Unknown}get playbackStateTimestamp(){return this.#e.state.nowPlayingClient?.playbackStateTimestamp??-1}get volume(){return this.#e.state.volume??0}#e;#t=!1;constructor(e){super(),this.#e=new $(e),this.#e.on(`connected`,()=>this.#n()),this.#e.on(`disconnected`,e=>this.#r(e))}async connect(){await this.#e.connect(),this.#t=!1}async disconnect(){await this.#e.disconnect()}async pause(){await this.#e.sendCommand(t.Proto.Command.Pause)}async playPause(){await this.#e.sendCommand(t.Proto.Command.TogglePlayPause)}async play(){await this.#e.sendCommand(t.Proto.Command.Play)}async stop(){await this.#e.sendCommand(t.Proto.Command.Stop)}async next(){await this.#e.sendCommand(t.Proto.Command.NextInContext)}async previous(){await this.#e.sendCommand(t.Proto.Command.PreviousInContext)}async getCommandInfo(e){let t=this.#e.state.nowPlayingClient;return t?t.supportedCommands.find(t=>t.command===e)??null:null}async isCommandSupported(e){let t=this.#e.state.nowPlayingClient;return t?t.isCommandSupported(e):!1}async#n(){this.emit(`connected`)}async#r(e){this.#t||(this.#t=!0,await this.disconnect(),this.emit(`disconnected`,e))}},Vn=class extends Bn{},Hn=class extends Bn{};export{c as AIRPLAY,$ as AirPlayDevice,zn as AppleTV,Ln as COMPANION_LINK,Rn as CompanionLinkDevice,Vn as HomePod,Hn as HomePodMini};
1
+ import { EventEmitter } from "node:events";
2
+ import * as AirPlay from "@basmilius/apple-airplay";
3
+ import { DataStreamMessage, Proto, Protocol } from "@basmilius/apple-airplay";
4
+ import { waitFor } from "@basmilius/apple-common";
5
+ import { Protocol as Protocol$1, convertAttentionState } from "@basmilius/apple-companion-link";
6
+
7
+ //#region src/airplay/const.ts
8
+ const FEEDBACK_INTERVAL = 2e3;
9
+ const PROTOCOL = Symbol("com.basmilius.airplay:protocol");
10
+ const STATE_SUBSCRIBE_SYMBOL = Symbol("com.basmilius.airplay:subscribe");
11
+ const STATE_UNSUBSCRIBE_SYMBOL = Symbol("com.basmilius.airplay:unsubscribe");
12
+
13
+ //#endregion
14
+ //#region src/airplay/remote.ts
15
+ var remote_default = class {
16
+ get #dataStream() {
17
+ return this.#protocol.dataStream;
18
+ }
19
+ get #protocol() {
20
+ return this.#device[PROTOCOL];
21
+ }
22
+ #device;
23
+ constructor(device) {
24
+ this.#device = device;
25
+ }
26
+ async up() {
27
+ await this.pressAndRelease(1, 140);
28
+ }
29
+ async down() {
30
+ await this.pressAndRelease(1, 141);
31
+ }
32
+ async left() {
33
+ await this.pressAndRelease(1, 139);
34
+ }
35
+ async right() {
36
+ await this.pressAndRelease(1, 138);
37
+ }
38
+ async menu() {
39
+ await this.pressAndRelease(1, 134);
40
+ }
41
+ async play() {
42
+ await this.pressAndRelease(12, 176);
43
+ }
44
+ async playPause() {
45
+ if (this.#device.state.nowPlayingClient?.playbackState === Proto.PlaybackState_Enum.Playing) await this.pause();
46
+ else await this.play();
47
+ }
48
+ async pause() {
49
+ await this.pressAndRelease(12, 177);
50
+ }
51
+ async next() {
52
+ await this.pressAndRelease(12, 181);
53
+ }
54
+ async previous() {
55
+ await this.pressAndRelease(12, 182);
56
+ }
57
+ async suspend() {
58
+ await this.pressAndRelease(1, 130);
59
+ }
60
+ async select() {
61
+ await this.pressAndRelease(1, 137);
62
+ }
63
+ async wake() {
64
+ await this.pressAndRelease(1, 131);
65
+ }
66
+ async home() {
67
+ await this.pressAndRelease(12, 64);
68
+ }
69
+ async volumeUp() {
70
+ await this.pressAndRelease(12, 233);
71
+ }
72
+ async volumeDown() {
73
+ await this.pressAndRelease(12, 234);
74
+ }
75
+ async mute() {
76
+ await this.pressAndRelease(12, 226);
77
+ }
78
+ async doublePress(usePage, usage) {
79
+ await this.pressAndRelease(usePage, usage);
80
+ await waitFor(150);
81
+ await this.pressAndRelease(usePage, usage);
82
+ }
83
+ async longPress(usePage, usage, duration = 1e3) {
84
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, true));
85
+ await waitFor(duration);
86
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, false));
87
+ }
88
+ async pressAndRelease(usePage, usage) {
89
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, true));
90
+ await waitFor(25);
91
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, false));
92
+ }
93
+ };
94
+
95
+ //#endregion
96
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js
97
+ /** Detect free variable `global` from Node.js. */
98
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
99
+
100
+ //#endregion
101
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js
102
+ /** Detect free variable `self`. */
103
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
104
+ /** Used as a reference to the global object. */
105
+ var root = freeGlobal || freeSelf || Function("return this")();
106
+
107
+ //#endregion
108
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js
109
+ /** Built-in value references. */
110
+ var Symbol$1 = root.Symbol;
111
+
112
+ //#endregion
113
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js
114
+ /** Used for built-in method references. */
115
+ var objectProto$4 = Object.prototype;
116
+ /** Used to check objects for own properties. */
117
+ var hasOwnProperty$8 = objectProto$4.hasOwnProperty;
118
+ /**
119
+ * Used to resolve the
120
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
121
+ * of values.
122
+ */
123
+ var nativeObjectToString$1 = objectProto$4.toString;
124
+ /** Built-in value references. */
125
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
126
+ /**
127
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
128
+ *
129
+ * @private
130
+ * @param {*} value The value to query.
131
+ * @returns {string} Returns the raw `toStringTag`.
132
+ */
133
+ function getRawTag(value) {
134
+ var isOwn = hasOwnProperty$8.call(value, symToStringTag$1), tag = value[symToStringTag$1];
135
+ try {
136
+ value[symToStringTag$1] = void 0;
137
+ var unmasked = true;
138
+ } catch (e) {}
139
+ var result = nativeObjectToString$1.call(value);
140
+ if (unmasked) if (isOwn) value[symToStringTag$1] = tag;
141
+ else delete value[symToStringTag$1];
142
+ return result;
143
+ }
144
+
145
+ //#endregion
146
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js
147
+ /**
148
+ * Used to resolve the
149
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
150
+ * of values.
151
+ */
152
+ var nativeObjectToString = Object.prototype.toString;
153
+ /**
154
+ * Converts `value` to a string using `Object.prototype.toString`.
155
+ *
156
+ * @private
157
+ * @param {*} value The value to convert.
158
+ * @returns {string} Returns the converted string.
159
+ */
160
+ function objectToString(value) {
161
+ return nativeObjectToString.call(value);
162
+ }
163
+
164
+ //#endregion
165
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js
166
+ /** `Object#toString` result references. */
167
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
168
+ /** Built-in value references. */
169
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
170
+ /**
171
+ * The base implementation of `getTag` without fallbacks for buggy environments.
172
+ *
173
+ * @private
174
+ * @param {*} value The value to query.
175
+ * @returns {string} Returns the `toStringTag`.
176
+ */
177
+ function baseGetTag(value) {
178
+ if (value == null) return value === void 0 ? undefinedTag : nullTag;
179
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
180
+ }
181
+
182
+ //#endregion
183
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js
184
+ /**
185
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
186
+ * and has a `typeof` result of "object".
187
+ *
188
+ * @static
189
+ * @memberOf _
190
+ * @since 4.0.0
191
+ * @category Lang
192
+ * @param {*} value The value to check.
193
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
194
+ * @example
195
+ *
196
+ * _.isObjectLike({});
197
+ * // => true
198
+ *
199
+ * _.isObjectLike([1, 2, 3]);
200
+ * // => true
201
+ *
202
+ * _.isObjectLike(_.noop);
203
+ * // => false
204
+ *
205
+ * _.isObjectLike(null);
206
+ * // => false
207
+ */
208
+ function isObjectLike(value) {
209
+ return value != null && typeof value == "object";
210
+ }
211
+
212
+ //#endregion
213
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js
214
+ /**
215
+ * Checks if `value` is classified as an `Array` object.
216
+ *
217
+ * @static
218
+ * @memberOf _
219
+ * @since 0.1.0
220
+ * @category Lang
221
+ * @param {*} value The value to check.
222
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
223
+ * @example
224
+ *
225
+ * _.isArray([1, 2, 3]);
226
+ * // => true
227
+ *
228
+ * _.isArray(document.body.children);
229
+ * // => false
230
+ *
231
+ * _.isArray('abc');
232
+ * // => false
233
+ *
234
+ * _.isArray(_.noop);
235
+ * // => false
236
+ */
237
+ var isArray = Array.isArray;
238
+
239
+ //#endregion
240
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js
241
+ /**
242
+ * Checks if `value` is the
243
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
244
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
245
+ *
246
+ * @static
247
+ * @memberOf _
248
+ * @since 0.1.0
249
+ * @category Lang
250
+ * @param {*} value The value to check.
251
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
252
+ * @example
253
+ *
254
+ * _.isObject({});
255
+ * // => true
256
+ *
257
+ * _.isObject([1, 2, 3]);
258
+ * // => true
259
+ *
260
+ * _.isObject(_.noop);
261
+ * // => true
262
+ *
263
+ * _.isObject(null);
264
+ * // => false
265
+ */
266
+ function isObject(value) {
267
+ var type = typeof value;
268
+ return value != null && (type == "object" || type == "function");
269
+ }
270
+
271
+ //#endregion
272
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js
273
+ /**
274
+ * This method returns the first argument it receives.
275
+ *
276
+ * @static
277
+ * @since 0.1.0
278
+ * @memberOf _
279
+ * @category Util
280
+ * @param {*} value Any value.
281
+ * @returns {*} Returns `value`.
282
+ * @example
283
+ *
284
+ * var object = { 'a': 1 };
285
+ *
286
+ * console.log(_.identity(object) === object);
287
+ * // => true
288
+ */
289
+ function identity(value) {
290
+ return value;
291
+ }
292
+
293
+ //#endregion
294
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js
295
+ /** `Object#toString` result references. */
296
+ var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
297
+ /**
298
+ * Checks if `value` is classified as a `Function` object.
299
+ *
300
+ * @static
301
+ * @memberOf _
302
+ * @since 0.1.0
303
+ * @category Lang
304
+ * @param {*} value The value to check.
305
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
306
+ * @example
307
+ *
308
+ * _.isFunction(_);
309
+ * // => true
310
+ *
311
+ * _.isFunction(/abc/);
312
+ * // => false
313
+ */
314
+ function isFunction(value) {
315
+ if (!isObject(value)) return false;
316
+ var tag = baseGetTag(value);
317
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
318
+ }
319
+
320
+ //#endregion
321
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js
322
+ /** Used to detect overreaching core-js shims. */
323
+ var coreJsData = root["__core-js_shared__"];
324
+
325
+ //#endregion
326
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js
327
+ /** Used to detect methods masquerading as native. */
328
+ var maskSrcKey = function() {
329
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
330
+ return uid ? "Symbol(src)_1." + uid : "";
331
+ }();
332
+ /**
333
+ * Checks if `func` has its source masked.
334
+ *
335
+ * @private
336
+ * @param {Function} func The function to check.
337
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
338
+ */
339
+ function isMasked(func) {
340
+ return !!maskSrcKey && maskSrcKey in func;
341
+ }
342
+
343
+ //#endregion
344
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js
345
+ /** Used to resolve the decompiled source of functions. */
346
+ var funcToString$2 = Function.prototype.toString;
347
+ /**
348
+ * Converts `func` to its source code.
349
+ *
350
+ * @private
351
+ * @param {Function} func The function to convert.
352
+ * @returns {string} Returns the source code.
353
+ */
354
+ function toSource(func) {
355
+ if (func != null) {
356
+ try {
357
+ return funcToString$2.call(func);
358
+ } catch (e) {}
359
+ try {
360
+ return func + "";
361
+ } catch (e) {}
362
+ }
363
+ return "";
364
+ }
365
+
366
+ //#endregion
367
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js
368
+ /**
369
+ * Used to match `RegExp`
370
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
371
+ */
372
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
373
+ /** Used to detect host constructors (Safari). */
374
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
375
+ /** Used for built-in method references. */
376
+ var funcProto$1 = Function.prototype, objectProto$3 = Object.prototype;
377
+ /** Used to resolve the decompiled source of functions. */
378
+ var funcToString$1 = funcProto$1.toString;
379
+ /** Used to check objects for own properties. */
380
+ var hasOwnProperty$7 = objectProto$3.hasOwnProperty;
381
+ /** Used to detect if a method is native. */
382
+ var reIsNative = RegExp("^" + funcToString$1.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
383
+ /**
384
+ * The base implementation of `_.isNative` without bad shim checks.
385
+ *
386
+ * @private
387
+ * @param {*} value The value to check.
388
+ * @returns {boolean} Returns `true` if `value` is a native function,
389
+ * else `false`.
390
+ */
391
+ function baseIsNative(value) {
392
+ if (!isObject(value) || isMasked(value)) return false;
393
+ return (isFunction(value) ? reIsNative : reIsHostCtor).test(toSource(value));
394
+ }
395
+
396
+ //#endregion
397
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js
398
+ /**
399
+ * Gets the value at `key` of `object`.
400
+ *
401
+ * @private
402
+ * @param {Object} [object] The object to query.
403
+ * @param {string} key The key of the property to get.
404
+ * @returns {*} Returns the property value.
405
+ */
406
+ function getValue(object, key) {
407
+ return object == null ? void 0 : object[key];
408
+ }
409
+
410
+ //#endregion
411
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js
412
+ /**
413
+ * Gets the native function at `key` of `object`.
414
+ *
415
+ * @private
416
+ * @param {Object} object The object to query.
417
+ * @param {string} key The key of the method to get.
418
+ * @returns {*} Returns the function if it's native, else `undefined`.
419
+ */
420
+ function getNative(object, key) {
421
+ var value = getValue(object, key);
422
+ return baseIsNative(value) ? value : void 0;
423
+ }
424
+
425
+ //#endregion
426
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js
427
+ /** Built-in value references. */
428
+ var objectCreate = Object.create;
429
+ /**
430
+ * The base implementation of `_.create` without support for assigning
431
+ * properties to the created object.
432
+ *
433
+ * @private
434
+ * @param {Object} proto The object to inherit from.
435
+ * @returns {Object} Returns the new object.
436
+ */
437
+ var baseCreate = function() {
438
+ function object() {}
439
+ return function(proto) {
440
+ if (!isObject(proto)) return {};
441
+ if (objectCreate) return objectCreate(proto);
442
+ object.prototype = proto;
443
+ var result = new object();
444
+ object.prototype = void 0;
445
+ return result;
446
+ };
447
+ }();
448
+
449
+ //#endregion
450
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js
451
+ /**
452
+ * A faster alternative to `Function#apply`, this function invokes `func`
453
+ * with the `this` binding of `thisArg` and the arguments of `args`.
454
+ *
455
+ * @private
456
+ * @param {Function} func The function to invoke.
457
+ * @param {*} thisArg The `this` binding of `func`.
458
+ * @param {Array} args The arguments to invoke `func` with.
459
+ * @returns {*} Returns the result of `func`.
460
+ */
461
+ function apply(func, thisArg, args) {
462
+ switch (args.length) {
463
+ case 0: return func.call(thisArg);
464
+ case 1: return func.call(thisArg, args[0]);
465
+ case 2: return func.call(thisArg, args[0], args[1]);
466
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
467
+ }
468
+ return func.apply(thisArg, args);
469
+ }
470
+
471
+ //#endregion
472
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js
473
+ /**
474
+ * Copies the values of `source` to `array`.
475
+ *
476
+ * @private
477
+ * @param {Array} source The array to copy values from.
478
+ * @param {Array} [array=[]] The array to copy values to.
479
+ * @returns {Array} Returns `array`.
480
+ */
481
+ function copyArray(source, array) {
482
+ var index = -1, length = source.length;
483
+ array || (array = Array(length));
484
+ while (++index < length) array[index] = source[index];
485
+ return array;
486
+ }
487
+
488
+ //#endregion
489
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js
490
+ /** Used to detect hot functions by number of calls within a span of milliseconds. */
491
+ var HOT_COUNT = 800, HOT_SPAN = 16;
492
+ var nativeNow = Date.now;
493
+ /**
494
+ * Creates a function that'll short out and invoke `identity` instead
495
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
496
+ * milliseconds.
497
+ *
498
+ * @private
499
+ * @param {Function} func The function to restrict.
500
+ * @returns {Function} Returns the new shortable function.
501
+ */
502
+ function shortOut(func) {
503
+ var count = 0, lastCalled = 0;
504
+ return function() {
505
+ var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
506
+ lastCalled = stamp;
507
+ if (remaining > 0) {
508
+ if (++count >= HOT_COUNT) return arguments[0];
509
+ } else count = 0;
510
+ return func.apply(void 0, arguments);
511
+ };
512
+ }
513
+
514
+ //#endregion
515
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js
516
+ /**
517
+ * Creates a function that returns `value`.
518
+ *
519
+ * @static
520
+ * @memberOf _
521
+ * @since 2.4.0
522
+ * @category Util
523
+ * @param {*} value The value to return from the new function.
524
+ * @returns {Function} Returns the new constant function.
525
+ * @example
526
+ *
527
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
528
+ *
529
+ * console.log(objects);
530
+ * // => [{ 'a': 1 }, { 'a': 1 }]
531
+ *
532
+ * console.log(objects[0] === objects[1]);
533
+ * // => true
534
+ */
535
+ function constant(value) {
536
+ return function() {
537
+ return value;
538
+ };
539
+ }
540
+
541
+ //#endregion
542
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js
543
+ var defineProperty = function() {
544
+ try {
545
+ var func = getNative(Object, "defineProperty");
546
+ func({}, "", {});
547
+ return func;
548
+ } catch (e) {}
549
+ }();
550
+
551
+ //#endregion
552
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js
553
+ /**
554
+ * The base implementation of `setToString` without support for hot loop shorting.
555
+ *
556
+ * @private
557
+ * @param {Function} func The function to modify.
558
+ * @param {Function} string The `toString` result.
559
+ * @returns {Function} Returns `func`.
560
+ */
561
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
562
+ return defineProperty(func, "toString", {
563
+ "configurable": true,
564
+ "enumerable": false,
565
+ "value": constant(string),
566
+ "writable": true
567
+ });
568
+ };
569
+
570
+ //#endregion
571
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js
572
+ /**
573
+ * Sets the `toString` method of `func` to return `string`.
574
+ *
575
+ * @private
576
+ * @param {Function} func The function to modify.
577
+ * @param {Function} string The `toString` result.
578
+ * @returns {Function} Returns `func`.
579
+ */
580
+ var setToString = shortOut(baseSetToString);
581
+
582
+ //#endregion
583
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js
584
+ /** Used as references for various `Number` constants. */
585
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
586
+ /** Used to detect unsigned integer values. */
587
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
588
+ /**
589
+ * Checks if `value` is a valid array-like index.
590
+ *
591
+ * @private
592
+ * @param {*} value The value to check.
593
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
594
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
595
+ */
596
+ function isIndex(value, length) {
597
+ var type = typeof value;
598
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
599
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
600
+ }
601
+
602
+ //#endregion
603
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js
604
+ /**
605
+ * The base implementation of `assignValue` and `assignMergeValue` without
606
+ * value checks.
607
+ *
608
+ * @private
609
+ * @param {Object} object The object to modify.
610
+ * @param {string} key The key of the property to assign.
611
+ * @param {*} value The value to assign.
612
+ */
613
+ function baseAssignValue(object, key, value) {
614
+ if (key == "__proto__" && defineProperty) defineProperty(object, key, {
615
+ "configurable": true,
616
+ "enumerable": true,
617
+ "value": value,
618
+ "writable": true
619
+ });
620
+ else object[key] = value;
621
+ }
622
+
623
+ //#endregion
624
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js
625
+ /**
626
+ * Performs a
627
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
628
+ * comparison between two values to determine if they are equivalent.
629
+ *
630
+ * @static
631
+ * @memberOf _
632
+ * @since 4.0.0
633
+ * @category Lang
634
+ * @param {*} value The value to compare.
635
+ * @param {*} other The other value to compare.
636
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
637
+ * @example
638
+ *
639
+ * var object = { 'a': 1 };
640
+ * var other = { 'a': 1 };
641
+ *
642
+ * _.eq(object, object);
643
+ * // => true
644
+ *
645
+ * _.eq(object, other);
646
+ * // => false
647
+ *
648
+ * _.eq('a', 'a');
649
+ * // => true
650
+ *
651
+ * _.eq('a', Object('a'));
652
+ * // => false
653
+ *
654
+ * _.eq(NaN, NaN);
655
+ * // => true
656
+ */
657
+ function eq(value, other) {
658
+ return value === other || value !== value && other !== other;
659
+ }
660
+
661
+ //#endregion
662
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js
663
+ /** Used to check objects for own properties. */
664
+ var hasOwnProperty$6 = Object.prototype.hasOwnProperty;
665
+ /**
666
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
667
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
668
+ * for equality comparisons.
669
+ *
670
+ * @private
671
+ * @param {Object} object The object to modify.
672
+ * @param {string} key The key of the property to assign.
673
+ * @param {*} value The value to assign.
674
+ */
675
+ function assignValue(object, key, value) {
676
+ var objValue = object[key];
677
+ if (!(hasOwnProperty$6.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) baseAssignValue(object, key, value);
678
+ }
679
+
680
+ //#endregion
681
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js
682
+ /**
683
+ * Copies properties of `source` to `object`.
684
+ *
685
+ * @private
686
+ * @param {Object} source The object to copy properties from.
687
+ * @param {Array} props The property identifiers to copy.
688
+ * @param {Object} [object={}] The object to copy properties to.
689
+ * @param {Function} [customizer] The function to customize copied values.
690
+ * @returns {Object} Returns `object`.
691
+ */
692
+ function copyObject(source, props, object, customizer) {
693
+ var isNew = !object;
694
+ object || (object = {});
695
+ var index = -1, length = props.length;
696
+ while (++index < length) {
697
+ var key = props[index];
698
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
699
+ if (newValue === void 0) newValue = source[key];
700
+ if (isNew) baseAssignValue(object, key, newValue);
701
+ else assignValue(object, key, newValue);
702
+ }
703
+ return object;
704
+ }
705
+
706
+ //#endregion
707
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js
708
+ var nativeMax = Math.max;
709
+ /**
710
+ * A specialized version of `baseRest` which transforms the rest array.
711
+ *
712
+ * @private
713
+ * @param {Function} func The function to apply a rest parameter to.
714
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
715
+ * @param {Function} transform The rest array transform.
716
+ * @returns {Function} Returns the new function.
717
+ */
718
+ function overRest(func, start, transform) {
719
+ start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
720
+ return function() {
721
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
722
+ while (++index < length) array[index] = args[start + index];
723
+ index = -1;
724
+ var otherArgs = Array(start + 1);
725
+ while (++index < start) otherArgs[index] = args[index];
726
+ otherArgs[start] = transform(array);
727
+ return apply(func, this, otherArgs);
728
+ };
729
+ }
730
+
731
+ //#endregion
732
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js
733
+ /**
734
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
735
+ *
736
+ * @private
737
+ * @param {Function} func The function to apply a rest parameter to.
738
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
739
+ * @returns {Function} Returns the new function.
740
+ */
741
+ function baseRest(func, start) {
742
+ return setToString(overRest(func, start, identity), func + "");
743
+ }
744
+
745
+ //#endregion
746
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js
747
+ /** Used as references for various `Number` constants. */
748
+ var MAX_SAFE_INTEGER = 9007199254740991;
749
+ /**
750
+ * Checks if `value` is a valid array-like length.
751
+ *
752
+ * **Note:** This method is loosely based on
753
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
754
+ *
755
+ * @static
756
+ * @memberOf _
757
+ * @since 4.0.0
758
+ * @category Lang
759
+ * @param {*} value The value to check.
760
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
761
+ * @example
762
+ *
763
+ * _.isLength(3);
764
+ * // => true
765
+ *
766
+ * _.isLength(Number.MIN_VALUE);
767
+ * // => false
768
+ *
769
+ * _.isLength(Infinity);
770
+ * // => false
771
+ *
772
+ * _.isLength('3');
773
+ * // => false
774
+ */
775
+ function isLength(value) {
776
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
777
+ }
778
+
779
+ //#endregion
780
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js
781
+ /**
782
+ * Checks if `value` is array-like. A value is considered array-like if it's
783
+ * not a function and has a `value.length` that's an integer greater than or
784
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
785
+ *
786
+ * @static
787
+ * @memberOf _
788
+ * @since 4.0.0
789
+ * @category Lang
790
+ * @param {*} value The value to check.
791
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
792
+ * @example
793
+ *
794
+ * _.isArrayLike([1, 2, 3]);
795
+ * // => true
796
+ *
797
+ * _.isArrayLike(document.body.children);
798
+ * // => true
799
+ *
800
+ * _.isArrayLike('abc');
801
+ * // => true
802
+ *
803
+ * _.isArrayLike(_.noop);
804
+ * // => false
805
+ */
806
+ function isArrayLike(value) {
807
+ return value != null && isLength(value.length) && !isFunction(value);
808
+ }
809
+
810
+ //#endregion
811
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIterateeCall.js
812
+ /**
813
+ * Checks if the given arguments are from an iteratee call.
814
+ *
815
+ * @private
816
+ * @param {*} value The potential iteratee value argument.
817
+ * @param {*} index The potential iteratee index or key argument.
818
+ * @param {*} object The potential iteratee object argument.
819
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
820
+ * else `false`.
821
+ */
822
+ function isIterateeCall(value, index, object) {
823
+ if (!isObject(object)) return false;
824
+ var type = typeof index;
825
+ if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) return eq(object[index], value);
826
+ return false;
827
+ }
828
+
829
+ //#endregion
830
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createAssigner.js
831
+ /**
832
+ * Creates a function like `_.assign`.
833
+ *
834
+ * @private
835
+ * @param {Function} assigner The function to assign values.
836
+ * @returns {Function} Returns the new assigner function.
837
+ */
838
+ function createAssigner(assigner) {
839
+ return baseRest(function(object, sources) {
840
+ var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0;
841
+ customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0;
842
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
843
+ customizer = length < 3 ? void 0 : customizer;
844
+ length = 1;
845
+ }
846
+ object = Object(object);
847
+ while (++index < length) {
848
+ var source = sources[index];
849
+ if (source) assigner(object, source, index, customizer);
850
+ }
851
+ return object;
852
+ });
853
+ }
854
+
855
+ //#endregion
856
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js
857
+ /** Used for built-in method references. */
858
+ var objectProto$2 = Object.prototype;
859
+ /**
860
+ * Checks if `value` is likely a prototype object.
861
+ *
862
+ * @private
863
+ * @param {*} value The value to check.
864
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
865
+ */
866
+ function isPrototype(value) {
867
+ var Ctor = value && value.constructor;
868
+ return value === (typeof Ctor == "function" && Ctor.prototype || objectProto$2);
869
+ }
870
+
871
+ //#endregion
872
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js
873
+ /**
874
+ * The base implementation of `_.times` without support for iteratee shorthands
875
+ * or max array length checks.
876
+ *
877
+ * @private
878
+ * @param {number} n The number of times to invoke `iteratee`.
879
+ * @param {Function} iteratee The function invoked per iteration.
880
+ * @returns {Array} Returns the array of results.
881
+ */
882
+ function baseTimes(n, iteratee) {
883
+ var index = -1, result = Array(n);
884
+ while (++index < n) result[index] = iteratee(index);
885
+ return result;
886
+ }
887
+
888
+ //#endregion
889
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js
890
+ /** `Object#toString` result references. */
891
+ var argsTag$1 = "[object Arguments]";
892
+ /**
893
+ * The base implementation of `_.isArguments`.
894
+ *
895
+ * @private
896
+ * @param {*} value The value to check.
897
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
898
+ */
899
+ function baseIsArguments(value) {
900
+ return isObjectLike(value) && baseGetTag(value) == argsTag$1;
901
+ }
902
+
903
+ //#endregion
904
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js
905
+ /** Used for built-in method references. */
906
+ var objectProto$1 = Object.prototype;
907
+ /** Used to check objects for own properties. */
908
+ var hasOwnProperty$5 = objectProto$1.hasOwnProperty;
909
+ /** Built-in value references. */
910
+ var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
911
+ /**
912
+ * Checks if `value` is likely an `arguments` object.
913
+ *
914
+ * @static
915
+ * @memberOf _
916
+ * @since 0.1.0
917
+ * @category Lang
918
+ * @param {*} value The value to check.
919
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
920
+ * else `false`.
921
+ * @example
922
+ *
923
+ * _.isArguments(function() { return arguments; }());
924
+ * // => true
925
+ *
926
+ * _.isArguments([1, 2, 3]);
927
+ * // => false
928
+ */
929
+ var isArguments = baseIsArguments(function() {
930
+ return arguments;
931
+ }()) ? baseIsArguments : function(value) {
932
+ return isObjectLike(value) && hasOwnProperty$5.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
933
+ };
934
+
935
+ //#endregion
936
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js
937
+ /**
938
+ * This method returns `false`.
939
+ *
940
+ * @static
941
+ * @memberOf _
942
+ * @since 4.13.0
943
+ * @category Util
944
+ * @returns {boolean} Returns `false`.
945
+ * @example
946
+ *
947
+ * _.times(2, _.stubFalse);
948
+ * // => [false, false]
949
+ */
950
+ function stubFalse() {
951
+ return false;
952
+ }
953
+
954
+ //#endregion
955
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js
956
+ /** Detect free variable `exports`. */
957
+ var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
958
+ /** Detect free variable `module`. */
959
+ var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
960
+ /** Built-in value references. */
961
+ var Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? root.Buffer : void 0;
962
+ /**
963
+ * Checks if `value` is a buffer.
964
+ *
965
+ * @static
966
+ * @memberOf _
967
+ * @since 4.3.0
968
+ * @category Lang
969
+ * @param {*} value The value to check.
970
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
971
+ * @example
972
+ *
973
+ * _.isBuffer(new Buffer(2));
974
+ * // => true
975
+ *
976
+ * _.isBuffer(new Uint8Array(2));
977
+ * // => false
978
+ */
979
+ var isBuffer = (Buffer$1 ? Buffer$1.isBuffer : void 0) || stubFalse;
980
+
981
+ //#endregion
982
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js
983
+ /** `Object#toString` result references. */
984
+ var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag$1 = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", weakMapTag = "[object WeakMap]";
985
+ var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
986
+ /** Used to identify `toStringTag` values of typed arrays. */
987
+ var typedArrayTags = {};
988
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
989
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
990
+ /**
991
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
992
+ *
993
+ * @private
994
+ * @param {*} value The value to check.
995
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
996
+ */
997
+ function baseIsTypedArray(value) {
998
+ return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
999
+ }
1000
+
1001
+ //#endregion
1002
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js
1003
+ /**
1004
+ * The base implementation of `_.unary` without support for storing metadata.
1005
+ *
1006
+ * @private
1007
+ * @param {Function} func The function to cap arguments for.
1008
+ * @returns {Function} Returns the new capped function.
1009
+ */
1010
+ function baseUnary(func) {
1011
+ return function(value) {
1012
+ return func(value);
1013
+ };
1014
+ }
1015
+
1016
+ //#endregion
1017
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js
1018
+ /** Detect free variable `exports`. */
1019
+ var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports;
1020
+ /** Detect free variable `module`. */
1021
+ var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module;
1022
+ /** Detect free variable `process` from Node.js. */
1023
+ var freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && freeGlobal.process;
1024
+ /** Used to access faster Node.js helpers. */
1025
+ var nodeUtil = function() {
1026
+ try {
1027
+ var types = freeModule$1 && freeModule$1.require && freeModule$1.require("util").types;
1028
+ if (types) return types;
1029
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
1030
+ } catch (e) {}
1031
+ }();
1032
+
1033
+ //#endregion
1034
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js
1035
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1036
+ /**
1037
+ * Checks if `value` is classified as a typed array.
1038
+ *
1039
+ * @static
1040
+ * @memberOf _
1041
+ * @since 3.0.0
1042
+ * @category Lang
1043
+ * @param {*} value The value to check.
1044
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1045
+ * @example
1046
+ *
1047
+ * _.isTypedArray(new Uint8Array);
1048
+ * // => true
1049
+ *
1050
+ * _.isTypedArray([]);
1051
+ * // => false
1052
+ */
1053
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1054
+
1055
+ //#endregion
1056
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js
1057
+ /** Used to check objects for own properties. */
1058
+ var hasOwnProperty$4 = Object.prototype.hasOwnProperty;
1059
+ /**
1060
+ * Creates an array of the enumerable property names of the array-like `value`.
1061
+ *
1062
+ * @private
1063
+ * @param {*} value The value to query.
1064
+ * @param {boolean} inherited Specify returning inherited property names.
1065
+ * @returns {Array} Returns the array of property names.
1066
+ */
1067
+ function arrayLikeKeys(value, inherited) {
1068
+ var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
1069
+ for (var key in value) if ((inherited || hasOwnProperty$4.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex(key, length)))) result.push(key);
1070
+ return result;
1071
+ }
1072
+
1073
+ //#endregion
1074
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js
1075
+ /**
1076
+ * Creates a unary function that invokes `func` with its argument transformed.
1077
+ *
1078
+ * @private
1079
+ * @param {Function} func The function to wrap.
1080
+ * @param {Function} transform The argument transform.
1081
+ * @returns {Function} Returns the new function.
1082
+ */
1083
+ function overArg(func, transform) {
1084
+ return function(arg) {
1085
+ return func(transform(arg));
1086
+ };
1087
+ }
1088
+
1089
+ //#endregion
1090
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js
1091
+ /**
1092
+ * This function is like
1093
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1094
+ * except that it includes inherited enumerable properties.
1095
+ *
1096
+ * @private
1097
+ * @param {Object} object The object to query.
1098
+ * @returns {Array} Returns the array of property names.
1099
+ */
1100
+ function nativeKeysIn(object) {
1101
+ var result = [];
1102
+ if (object != null) for (var key in Object(object)) result.push(key);
1103
+ return result;
1104
+ }
1105
+
1106
+ //#endregion
1107
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js
1108
+ /** Used to check objects for own properties. */
1109
+ var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1110
+ /**
1111
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
1112
+ *
1113
+ * @private
1114
+ * @param {Object} object The object to query.
1115
+ * @returns {Array} Returns the array of property names.
1116
+ */
1117
+ function baseKeysIn(object) {
1118
+ if (!isObject(object)) return nativeKeysIn(object);
1119
+ var isProto = isPrototype(object), result = [];
1120
+ for (var key in object) if (!(key == "constructor" && (isProto || !hasOwnProperty$3.call(object, key)))) result.push(key);
1121
+ return result;
1122
+ }
1123
+
1124
+ //#endregion
1125
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js
1126
+ /**
1127
+ * Creates an array of the own and inherited enumerable property names of `object`.
1128
+ *
1129
+ * **Note:** Non-object values are coerced to objects.
1130
+ *
1131
+ * @static
1132
+ * @memberOf _
1133
+ * @since 3.0.0
1134
+ * @category Object
1135
+ * @param {Object} object The object to query.
1136
+ * @returns {Array} Returns the array of property names.
1137
+ * @example
1138
+ *
1139
+ * function Foo() {
1140
+ * this.a = 1;
1141
+ * this.b = 2;
1142
+ * }
1143
+ *
1144
+ * Foo.prototype.c = 3;
1145
+ *
1146
+ * _.keysIn(new Foo);
1147
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
1148
+ */
1149
+ function keysIn(object) {
1150
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
1151
+ }
1152
+
1153
+ //#endregion
1154
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js
1155
+ var nativeCreate = getNative(Object, "create");
1156
+
1157
+ //#endregion
1158
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js
1159
+ /**
1160
+ * Removes all key-value entries from the hash.
1161
+ *
1162
+ * @private
1163
+ * @name clear
1164
+ * @memberOf Hash
1165
+ */
1166
+ function hashClear() {
1167
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
1168
+ this.size = 0;
1169
+ }
1170
+
1171
+ //#endregion
1172
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js
1173
+ /**
1174
+ * Removes `key` and its value from the hash.
1175
+ *
1176
+ * @private
1177
+ * @name delete
1178
+ * @memberOf Hash
1179
+ * @param {Object} hash The hash to modify.
1180
+ * @param {string} key The key of the value to remove.
1181
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1182
+ */
1183
+ function hashDelete(key) {
1184
+ var result = this.has(key) && delete this.__data__[key];
1185
+ this.size -= result ? 1 : 0;
1186
+ return result;
1187
+ }
1188
+
1189
+ //#endregion
1190
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js
1191
+ /** Used to stand-in for `undefined` hash values. */
1192
+ var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
1193
+ /** Used to check objects for own properties. */
1194
+ var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1195
+ /**
1196
+ * Gets the hash value for `key`.
1197
+ *
1198
+ * @private
1199
+ * @name get
1200
+ * @memberOf Hash
1201
+ * @param {string} key The key of the value to get.
1202
+ * @returns {*} Returns the entry value.
1203
+ */
1204
+ function hashGet(key) {
1205
+ var data = this.__data__;
1206
+ if (nativeCreate) {
1207
+ var result = data[key];
1208
+ return result === HASH_UNDEFINED$1 ? void 0 : result;
1209
+ }
1210
+ return hasOwnProperty$2.call(data, key) ? data[key] : void 0;
1211
+ }
1212
+
1213
+ //#endregion
1214
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js
1215
+ /** Used to check objects for own properties. */
1216
+ var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1217
+ /**
1218
+ * Checks if a hash value for `key` exists.
1219
+ *
1220
+ * @private
1221
+ * @name has
1222
+ * @memberOf Hash
1223
+ * @param {string} key The key of the entry to check.
1224
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1225
+ */
1226
+ function hashHas(key) {
1227
+ var data = this.__data__;
1228
+ return nativeCreate ? data[key] !== void 0 : hasOwnProperty$1.call(data, key);
1229
+ }
1230
+
1231
+ //#endregion
1232
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js
1233
+ /** Used to stand-in for `undefined` hash values. */
1234
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
1235
+ /**
1236
+ * Sets the hash `key` to `value`.
1237
+ *
1238
+ * @private
1239
+ * @name set
1240
+ * @memberOf Hash
1241
+ * @param {string} key The key of the value to set.
1242
+ * @param {*} value The value to set.
1243
+ * @returns {Object} Returns the hash instance.
1244
+ */
1245
+ function hashSet(key, value) {
1246
+ var data = this.__data__;
1247
+ this.size += this.has(key) ? 0 : 1;
1248
+ data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
1249
+ return this;
1250
+ }
1251
+
1252
+ //#endregion
1253
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js
1254
+ /**
1255
+ * Creates a hash object.
1256
+ *
1257
+ * @private
1258
+ * @constructor
1259
+ * @param {Array} [entries] The key-value pairs to cache.
1260
+ */
1261
+ function Hash(entries) {
1262
+ var index = -1, length = entries == null ? 0 : entries.length;
1263
+ this.clear();
1264
+ while (++index < length) {
1265
+ var entry = entries[index];
1266
+ this.set(entry[0], entry[1]);
1267
+ }
1268
+ }
1269
+ Hash.prototype.clear = hashClear;
1270
+ Hash.prototype["delete"] = hashDelete;
1271
+ Hash.prototype.get = hashGet;
1272
+ Hash.prototype.has = hashHas;
1273
+ Hash.prototype.set = hashSet;
1274
+
1275
+ //#endregion
1276
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js
1277
+ /**
1278
+ * Removes all key-value entries from the list cache.
1279
+ *
1280
+ * @private
1281
+ * @name clear
1282
+ * @memberOf ListCache
1283
+ */
1284
+ function listCacheClear() {
1285
+ this.__data__ = [];
1286
+ this.size = 0;
1287
+ }
1288
+
1289
+ //#endregion
1290
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js
1291
+ /**
1292
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
1293
+ *
1294
+ * @private
1295
+ * @param {Array} array The array to inspect.
1296
+ * @param {*} key The key to search for.
1297
+ * @returns {number} Returns the index of the matched value, else `-1`.
1298
+ */
1299
+ function assocIndexOf(array, key) {
1300
+ var length = array.length;
1301
+ while (length--) if (eq(array[length][0], key)) return length;
1302
+ return -1;
1303
+ }
1304
+
1305
+ //#endregion
1306
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js
1307
+ /** Built-in value references. */
1308
+ var splice = Array.prototype.splice;
1309
+ /**
1310
+ * Removes `key` and its value from the list cache.
1311
+ *
1312
+ * @private
1313
+ * @name delete
1314
+ * @memberOf ListCache
1315
+ * @param {string} key The key of the value to remove.
1316
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1317
+ */
1318
+ function listCacheDelete(key) {
1319
+ var data = this.__data__, index = assocIndexOf(data, key);
1320
+ if (index < 0) return false;
1321
+ if (index == data.length - 1) data.pop();
1322
+ else splice.call(data, index, 1);
1323
+ --this.size;
1324
+ return true;
1325
+ }
1326
+
1327
+ //#endregion
1328
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js
1329
+ /**
1330
+ * Gets the list cache value for `key`.
1331
+ *
1332
+ * @private
1333
+ * @name get
1334
+ * @memberOf ListCache
1335
+ * @param {string} key The key of the value to get.
1336
+ * @returns {*} Returns the entry value.
1337
+ */
1338
+ function listCacheGet(key) {
1339
+ var data = this.__data__, index = assocIndexOf(data, key);
1340
+ return index < 0 ? void 0 : data[index][1];
1341
+ }
1342
+
1343
+ //#endregion
1344
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js
1345
+ /**
1346
+ * Checks if a list cache value for `key` exists.
1347
+ *
1348
+ * @private
1349
+ * @name has
1350
+ * @memberOf ListCache
1351
+ * @param {string} key The key of the entry to check.
1352
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1353
+ */
1354
+ function listCacheHas(key) {
1355
+ return assocIndexOf(this.__data__, key) > -1;
1356
+ }
1357
+
1358
+ //#endregion
1359
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js
1360
+ /**
1361
+ * Sets the list cache `key` to `value`.
1362
+ *
1363
+ * @private
1364
+ * @name set
1365
+ * @memberOf ListCache
1366
+ * @param {string} key The key of the value to set.
1367
+ * @param {*} value The value to set.
1368
+ * @returns {Object} Returns the list cache instance.
1369
+ */
1370
+ function listCacheSet(key, value) {
1371
+ var data = this.__data__, index = assocIndexOf(data, key);
1372
+ if (index < 0) {
1373
+ ++this.size;
1374
+ data.push([key, value]);
1375
+ } else data[index][1] = value;
1376
+ return this;
1377
+ }
1378
+
1379
+ //#endregion
1380
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js
1381
+ /**
1382
+ * Creates an list cache object.
1383
+ *
1384
+ * @private
1385
+ * @constructor
1386
+ * @param {Array} [entries] The key-value pairs to cache.
1387
+ */
1388
+ function ListCache(entries) {
1389
+ var index = -1, length = entries == null ? 0 : entries.length;
1390
+ this.clear();
1391
+ while (++index < length) {
1392
+ var entry = entries[index];
1393
+ this.set(entry[0], entry[1]);
1394
+ }
1395
+ }
1396
+ ListCache.prototype.clear = listCacheClear;
1397
+ ListCache.prototype["delete"] = listCacheDelete;
1398
+ ListCache.prototype.get = listCacheGet;
1399
+ ListCache.prototype.has = listCacheHas;
1400
+ ListCache.prototype.set = listCacheSet;
1401
+
1402
+ //#endregion
1403
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js
1404
+ var Map = getNative(root, "Map");
1405
+
1406
+ //#endregion
1407
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js
1408
+ /**
1409
+ * Removes all key-value entries from the map.
1410
+ *
1411
+ * @private
1412
+ * @name clear
1413
+ * @memberOf MapCache
1414
+ */
1415
+ function mapCacheClear() {
1416
+ this.size = 0;
1417
+ this.__data__ = {
1418
+ "hash": new Hash(),
1419
+ "map": new (Map || ListCache)(),
1420
+ "string": new Hash()
1421
+ };
1422
+ }
1423
+
1424
+ //#endregion
1425
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js
1426
+ /**
1427
+ * Checks if `value` is suitable for use as unique object key.
1428
+ *
1429
+ * @private
1430
+ * @param {*} value The value to check.
1431
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1432
+ */
1433
+ function isKeyable(value) {
1434
+ var type = typeof value;
1435
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
1436
+ }
1437
+
1438
+ //#endregion
1439
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js
1440
+ /**
1441
+ * Gets the data for `map`.
1442
+ *
1443
+ * @private
1444
+ * @param {Object} map The map to query.
1445
+ * @param {string} key The reference key.
1446
+ * @returns {*} Returns the map data.
1447
+ */
1448
+ function getMapData(map, key) {
1449
+ var data = map.__data__;
1450
+ return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
1451
+ }
1452
+
1453
+ //#endregion
1454
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js
1455
+ /**
1456
+ * Removes `key` and its value from the map.
1457
+ *
1458
+ * @private
1459
+ * @name delete
1460
+ * @memberOf MapCache
1461
+ * @param {string} key The key of the value to remove.
1462
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1463
+ */
1464
+ function mapCacheDelete(key) {
1465
+ var result = getMapData(this, key)["delete"](key);
1466
+ this.size -= result ? 1 : 0;
1467
+ return result;
1468
+ }
1469
+
1470
+ //#endregion
1471
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js
1472
+ /**
1473
+ * Gets the map value for `key`.
1474
+ *
1475
+ * @private
1476
+ * @name get
1477
+ * @memberOf MapCache
1478
+ * @param {string} key The key of the value to get.
1479
+ * @returns {*} Returns the entry value.
1480
+ */
1481
+ function mapCacheGet(key) {
1482
+ return getMapData(this, key).get(key);
1483
+ }
1484
+
1485
+ //#endregion
1486
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js
1487
+ /**
1488
+ * Checks if a map value for `key` exists.
1489
+ *
1490
+ * @private
1491
+ * @name has
1492
+ * @memberOf MapCache
1493
+ * @param {string} key The key of the entry to check.
1494
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1495
+ */
1496
+ function mapCacheHas(key) {
1497
+ return getMapData(this, key).has(key);
1498
+ }
1499
+
1500
+ //#endregion
1501
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js
1502
+ /**
1503
+ * Sets the map `key` to `value`.
1504
+ *
1505
+ * @private
1506
+ * @name set
1507
+ * @memberOf MapCache
1508
+ * @param {string} key The key of the value to set.
1509
+ * @param {*} value The value to set.
1510
+ * @returns {Object} Returns the map cache instance.
1511
+ */
1512
+ function mapCacheSet(key, value) {
1513
+ var data = getMapData(this, key), size = data.size;
1514
+ data.set(key, value);
1515
+ this.size += data.size == size ? 0 : 1;
1516
+ return this;
1517
+ }
1518
+
1519
+ //#endregion
1520
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js
1521
+ /**
1522
+ * Creates a map cache object to store key-value pairs.
1523
+ *
1524
+ * @private
1525
+ * @constructor
1526
+ * @param {Array} [entries] The key-value pairs to cache.
1527
+ */
1528
+ function MapCache(entries) {
1529
+ var index = -1, length = entries == null ? 0 : entries.length;
1530
+ this.clear();
1531
+ while (++index < length) {
1532
+ var entry = entries[index];
1533
+ this.set(entry[0], entry[1]);
1534
+ }
1535
+ }
1536
+ MapCache.prototype.clear = mapCacheClear;
1537
+ MapCache.prototype["delete"] = mapCacheDelete;
1538
+ MapCache.prototype.get = mapCacheGet;
1539
+ MapCache.prototype.has = mapCacheHas;
1540
+ MapCache.prototype.set = mapCacheSet;
1541
+
1542
+ //#endregion
1543
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js
1544
+ /** Built-in value references. */
1545
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
1546
+
1547
+ //#endregion
1548
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js
1549
+ /** `Object#toString` result references. */
1550
+ var objectTag = "[object Object]";
1551
+ /** Used for built-in method references. */
1552
+ var funcProto = Function.prototype, objectProto = Object.prototype;
1553
+ /** Used to resolve the decompiled source of functions. */
1554
+ var funcToString = funcProto.toString;
1555
+ /** Used to check objects for own properties. */
1556
+ var hasOwnProperty = objectProto.hasOwnProperty;
1557
+ /** Used to infer the `Object` constructor. */
1558
+ var objectCtorString = funcToString.call(Object);
1559
+ /**
1560
+ * Checks if `value` is a plain object, that is, an object created by the
1561
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
1562
+ *
1563
+ * @static
1564
+ * @memberOf _
1565
+ * @since 0.8.0
1566
+ * @category Lang
1567
+ * @param {*} value The value to check.
1568
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
1569
+ * @example
1570
+ *
1571
+ * function Foo() {
1572
+ * this.a = 1;
1573
+ * }
1574
+ *
1575
+ * _.isPlainObject(new Foo);
1576
+ * // => false
1577
+ *
1578
+ * _.isPlainObject([1, 2, 3]);
1579
+ * // => false
1580
+ *
1581
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
1582
+ * // => true
1583
+ *
1584
+ * _.isPlainObject(Object.create(null));
1585
+ * // => true
1586
+ */
1587
+ function isPlainObject(value) {
1588
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) return false;
1589
+ var proto = getPrototype(value);
1590
+ if (proto === null) return true;
1591
+ var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
1592
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
1593
+ }
1594
+
1595
+ //#endregion
1596
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js
1597
+ /**
1598
+ * Removes all key-value entries from the stack.
1599
+ *
1600
+ * @private
1601
+ * @name clear
1602
+ * @memberOf Stack
1603
+ */
1604
+ function stackClear() {
1605
+ this.__data__ = new ListCache();
1606
+ this.size = 0;
1607
+ }
1608
+
1609
+ //#endregion
1610
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js
1611
+ /**
1612
+ * Removes `key` and its value from the stack.
1613
+ *
1614
+ * @private
1615
+ * @name delete
1616
+ * @memberOf Stack
1617
+ * @param {string} key The key of the value to remove.
1618
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1619
+ */
1620
+ function stackDelete(key) {
1621
+ var data = this.__data__, result = data["delete"](key);
1622
+ this.size = data.size;
1623
+ return result;
1624
+ }
1625
+
1626
+ //#endregion
1627
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js
1628
+ /**
1629
+ * Gets the stack value for `key`.
1630
+ *
1631
+ * @private
1632
+ * @name get
1633
+ * @memberOf Stack
1634
+ * @param {string} key The key of the value to get.
1635
+ * @returns {*} Returns the entry value.
1636
+ */
1637
+ function stackGet(key) {
1638
+ return this.__data__.get(key);
1639
+ }
1640
+
1641
+ //#endregion
1642
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js
1643
+ /**
1644
+ * Checks if a stack value for `key` exists.
1645
+ *
1646
+ * @private
1647
+ * @name has
1648
+ * @memberOf Stack
1649
+ * @param {string} key The key of the entry to check.
1650
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1651
+ */
1652
+ function stackHas(key) {
1653
+ return this.__data__.has(key);
1654
+ }
1655
+
1656
+ //#endregion
1657
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js
1658
+ /** Used as the size to enable large array optimizations. */
1659
+ var LARGE_ARRAY_SIZE = 200;
1660
+ /**
1661
+ * Sets the stack `key` to `value`.
1662
+ *
1663
+ * @private
1664
+ * @name set
1665
+ * @memberOf Stack
1666
+ * @param {string} key The key of the value to set.
1667
+ * @param {*} value The value to set.
1668
+ * @returns {Object} Returns the stack cache instance.
1669
+ */
1670
+ function stackSet(key, value) {
1671
+ var data = this.__data__;
1672
+ if (data instanceof ListCache) {
1673
+ var pairs = data.__data__;
1674
+ if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
1675
+ pairs.push([key, value]);
1676
+ this.size = ++data.size;
1677
+ return this;
1678
+ }
1679
+ data = this.__data__ = new MapCache(pairs);
1680
+ }
1681
+ data.set(key, value);
1682
+ this.size = data.size;
1683
+ return this;
1684
+ }
1685
+
1686
+ //#endregion
1687
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js
1688
+ /**
1689
+ * Creates a stack cache object to store key-value pairs.
1690
+ *
1691
+ * @private
1692
+ * @constructor
1693
+ * @param {Array} [entries] The key-value pairs to cache.
1694
+ */
1695
+ function Stack(entries) {
1696
+ this.size = (this.__data__ = new ListCache(entries)).size;
1697
+ }
1698
+ Stack.prototype.clear = stackClear;
1699
+ Stack.prototype["delete"] = stackDelete;
1700
+ Stack.prototype.get = stackGet;
1701
+ Stack.prototype.has = stackHas;
1702
+ Stack.prototype.set = stackSet;
1703
+
1704
+ //#endregion
1705
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js
1706
+ /** Detect free variable `exports`. */
1707
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
1708
+ /** Detect free variable `module`. */
1709
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
1710
+ /** Built-in value references. */
1711
+ var Buffer = freeModule && freeModule.exports === freeExports ? root.Buffer : void 0, allocUnsafe = Buffer ? Buffer.allocUnsafe : void 0;
1712
+ /**
1713
+ * Creates a clone of `buffer`.
1714
+ *
1715
+ * @private
1716
+ * @param {Buffer} buffer The buffer to clone.
1717
+ * @param {boolean} [isDeep] Specify a deep clone.
1718
+ * @returns {Buffer} Returns the cloned buffer.
1719
+ */
1720
+ function cloneBuffer(buffer, isDeep) {
1721
+ if (isDeep) return buffer.slice();
1722
+ var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
1723
+ buffer.copy(result);
1724
+ return result;
1725
+ }
1726
+
1727
+ //#endregion
1728
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js
1729
+ /** Built-in value references. */
1730
+ var Uint8Array = root.Uint8Array;
1731
+
1732
+ //#endregion
1733
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js
1734
+ /**
1735
+ * Creates a clone of `arrayBuffer`.
1736
+ *
1737
+ * @private
1738
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1739
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
1740
+ */
1741
+ function cloneArrayBuffer(arrayBuffer) {
1742
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1743
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1744
+ return result;
1745
+ }
1746
+
1747
+ //#endregion
1748
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js
1749
+ /**
1750
+ * Creates a clone of `typedArray`.
1751
+ *
1752
+ * @private
1753
+ * @param {Object} typedArray The typed array to clone.
1754
+ * @param {boolean} [isDeep] Specify a deep clone.
1755
+ * @returns {Object} Returns the cloned typed array.
1756
+ */
1757
+ function cloneTypedArray(typedArray, isDeep) {
1758
+ var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1759
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1760
+ }
1761
+
1762
+ //#endregion
1763
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js
1764
+ /**
1765
+ * Initializes an object clone.
1766
+ *
1767
+ * @private
1768
+ * @param {Object} object The object to clone.
1769
+ * @returns {Object} Returns the initialized clone.
1770
+ */
1771
+ function initCloneObject(object) {
1772
+ return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
1773
+ }
1774
+
1775
+ //#endregion
1776
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js
1777
+ /**
1778
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1779
+ *
1780
+ * @private
1781
+ * @param {boolean} [fromRight] Specify iterating from right to left.
1782
+ * @returns {Function} Returns the new base function.
1783
+ */
1784
+ function createBaseFor(fromRight) {
1785
+ return function(object, iteratee, keysFunc) {
1786
+ var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
1787
+ while (length--) {
1788
+ var key = props[fromRight ? length : ++index];
1789
+ if (iteratee(iterable[key], key, iterable) === false) break;
1790
+ }
1791
+ return object;
1792
+ };
1793
+ }
1794
+
1795
+ //#endregion
1796
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js
1797
+ /**
1798
+ * The base implementation of `baseForOwn` which iterates over `object`
1799
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
1800
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
1801
+ *
1802
+ * @private
1803
+ * @param {Object} object The object to iterate over.
1804
+ * @param {Function} iteratee The function invoked per iteration.
1805
+ * @param {Function} keysFunc The function to get the keys of `object`.
1806
+ * @returns {Object} Returns `object`.
1807
+ */
1808
+ var baseFor = createBaseFor();
1809
+
1810
+ //#endregion
1811
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js
1812
+ /**
1813
+ * This function is like `assignValue` except that it doesn't assign
1814
+ * `undefined` values.
1815
+ *
1816
+ * @private
1817
+ * @param {Object} object The object to modify.
1818
+ * @param {string} key The key of the property to assign.
1819
+ * @param {*} value The value to assign.
1820
+ */
1821
+ function assignMergeValue(object, key, value) {
1822
+ if (value !== void 0 && !eq(object[key], value) || value === void 0 && !(key in object)) baseAssignValue(object, key, value);
1823
+ }
1824
+
1825
+ //#endregion
1826
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js
1827
+ /**
1828
+ * This method is like `_.isArrayLike` except that it also checks if `value`
1829
+ * is an object.
1830
+ *
1831
+ * @static
1832
+ * @memberOf _
1833
+ * @since 4.0.0
1834
+ * @category Lang
1835
+ * @param {*} value The value to check.
1836
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
1837
+ * else `false`.
1838
+ * @example
1839
+ *
1840
+ * _.isArrayLikeObject([1, 2, 3]);
1841
+ * // => true
1842
+ *
1843
+ * _.isArrayLikeObject(document.body.children);
1844
+ * // => true
1845
+ *
1846
+ * _.isArrayLikeObject('abc');
1847
+ * // => false
1848
+ *
1849
+ * _.isArrayLikeObject(_.noop);
1850
+ * // => false
1851
+ */
1852
+ function isArrayLikeObject(value) {
1853
+ return isObjectLike(value) && isArrayLike(value);
1854
+ }
1855
+
1856
+ //#endregion
1857
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js
1858
+ /**
1859
+ * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
1860
+ *
1861
+ * @private
1862
+ * @param {Object} object The object to query.
1863
+ * @param {string} key The key of the property to get.
1864
+ * @returns {*} Returns the property value.
1865
+ */
1866
+ function safeGet(object, key) {
1867
+ if (key === "constructor" && typeof object[key] === "function") return;
1868
+ if (key == "__proto__") return;
1869
+ return object[key];
1870
+ }
1871
+
1872
+ //#endregion
1873
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js
1874
+ /**
1875
+ * Converts `value` to a plain object flattening inherited enumerable string
1876
+ * keyed properties of `value` to own properties of the plain object.
1877
+ *
1878
+ * @static
1879
+ * @memberOf _
1880
+ * @since 3.0.0
1881
+ * @category Lang
1882
+ * @param {*} value The value to convert.
1883
+ * @returns {Object} Returns the converted plain object.
1884
+ * @example
1885
+ *
1886
+ * function Foo() {
1887
+ * this.b = 2;
1888
+ * }
1889
+ *
1890
+ * Foo.prototype.c = 3;
1891
+ *
1892
+ * _.assign({ 'a': 1 }, new Foo);
1893
+ * // => { 'a': 1, 'b': 2 }
1894
+ *
1895
+ * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
1896
+ * // => { 'a': 1, 'b': 2, 'c': 3 }
1897
+ */
1898
+ function toPlainObject(value) {
1899
+ return copyObject(value, keysIn(value));
1900
+ }
1901
+
1902
+ //#endregion
1903
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMergeDeep.js
1904
+ /**
1905
+ * A specialized version of `baseMerge` for arrays and objects which performs
1906
+ * deep merges and tracks traversed objects enabling objects with circular
1907
+ * references to be merged.
1908
+ *
1909
+ * @private
1910
+ * @param {Object} object The destination object.
1911
+ * @param {Object} source The source object.
1912
+ * @param {string} key The key of the value to merge.
1913
+ * @param {number} srcIndex The index of `source`.
1914
+ * @param {Function} mergeFunc The function to merge values.
1915
+ * @param {Function} [customizer] The function to customize assigned values.
1916
+ * @param {Object} [stack] Tracks traversed source values and their merged
1917
+ * counterparts.
1918
+ */
1919
+ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
1920
+ var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue);
1921
+ if (stacked) {
1922
+ assignMergeValue(object, key, stacked);
1923
+ return;
1924
+ }
1925
+ var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0;
1926
+ var isCommon = newValue === void 0;
1927
+ if (isCommon) {
1928
+ var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue);
1929
+ newValue = srcValue;
1930
+ if (isArr || isBuff || isTyped) if (isArray(objValue)) newValue = objValue;
1931
+ else if (isArrayLikeObject(objValue)) newValue = copyArray(objValue);
1932
+ else if (isBuff) {
1933
+ isCommon = false;
1934
+ newValue = cloneBuffer(srcValue, true);
1935
+ } else if (isTyped) {
1936
+ isCommon = false;
1937
+ newValue = cloneTypedArray(srcValue, true);
1938
+ } else newValue = [];
1939
+ else if (isPlainObject(srcValue) || isArguments(srcValue)) {
1940
+ newValue = objValue;
1941
+ if (isArguments(objValue)) newValue = toPlainObject(objValue);
1942
+ else if (!isObject(objValue) || isFunction(objValue)) newValue = initCloneObject(srcValue);
1943
+ } else isCommon = false;
1944
+ }
1945
+ if (isCommon) {
1946
+ stack.set(srcValue, newValue);
1947
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
1948
+ stack["delete"](srcValue);
1949
+ }
1950
+ assignMergeValue(object, key, newValue);
1951
+ }
1952
+
1953
+ //#endregion
1954
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMerge.js
1955
+ /**
1956
+ * The base implementation of `_.merge` without support for multiple sources.
1957
+ *
1958
+ * @private
1959
+ * @param {Object} object The destination object.
1960
+ * @param {Object} source The source object.
1961
+ * @param {number} srcIndex The index of `source`.
1962
+ * @param {Function} [customizer] The function to customize merged values.
1963
+ * @param {Object} [stack] Tracks traversed source values and their merged
1964
+ * counterparts.
1965
+ */
1966
+ function baseMerge(object, source, srcIndex, customizer, stack) {
1967
+ if (object === source) return;
1968
+ baseFor(source, function(srcValue, key) {
1969
+ stack || (stack = new Stack());
1970
+ if (isObject(srcValue)) baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
1971
+ else {
1972
+ var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : void 0;
1973
+ if (newValue === void 0) newValue = srcValue;
1974
+ assignMergeValue(object, key, newValue);
1975
+ }
1976
+ }, keysIn);
1977
+ }
1978
+
1979
+ //#endregion
1980
+ //#region ../../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/merge.js
1981
+ /**
1982
+ * This method is like `_.assign` except that it recursively merges own and
1983
+ * inherited enumerable string keyed properties of source objects into the
1984
+ * destination object. Source properties that resolve to `undefined` are
1985
+ * skipped if a destination value exists. Array and plain object properties
1986
+ * are merged recursively. Other objects and value types are overridden by
1987
+ * assignment. Source objects are applied from left to right. Subsequent
1988
+ * sources overwrite property assignments of previous sources.
1989
+ *
1990
+ * **Note:** This method mutates `object`.
1991
+ *
1992
+ * @static
1993
+ * @memberOf _
1994
+ * @since 0.5.0
1995
+ * @category Object
1996
+ * @param {Object} object The destination object.
1997
+ * @param {...Object} [sources] The source objects.
1998
+ * @returns {Object} Returns `object`.
1999
+ * @example
2000
+ *
2001
+ * var object = {
2002
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
2003
+ * };
2004
+ *
2005
+ * var other = {
2006
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
2007
+ * };
2008
+ *
2009
+ * _.merge(object, other);
2010
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
2011
+ */
2012
+ var merge = createAssigner(function(object, source, srcIndex) {
2013
+ baseMerge(object, source, srcIndex);
2014
+ });
2015
+
2016
+ //#endregion
2017
+ //#region src/airplay/client.ts
2018
+ var Client = class {
2019
+ get bundleIdentifier() {
2020
+ return this.#bundleIdentifier;
2021
+ }
2022
+ get displayName() {
2023
+ return this.#displayName;
2024
+ }
2025
+ get playbackQueue() {
2026
+ return this.#playbackQueue;
2027
+ }
2028
+ get playbackState() {
2029
+ return this.#playbackState;
2030
+ }
2031
+ get playbackStateTimestamp() {
2032
+ return this.#playbackStateTimestamp;
2033
+ }
2034
+ get supportedCommands() {
2035
+ return this.#supportedCommands;
2036
+ }
2037
+ #bundleIdentifier;
2038
+ #displayName;
2039
+ #playbackQueue = null;
2040
+ #playbackState;
2041
+ #playbackStateTimestamp;
2042
+ #supportedCommands = [];
2043
+ constructor(bundleIdentifier, displayName) {
2044
+ this.#bundleIdentifier = bundleIdentifier;
2045
+ this.#displayName = displayName;
2046
+ this.#playbackState = Proto.PlaybackState_Enum.Unknown;
2047
+ this.#supportedCommands = [];
2048
+ }
2049
+ isCommandSupported(command) {
2050
+ return this.#supportedCommands.some((c) => c.command === command);
2051
+ }
2052
+ setPlaybackQueue(playbackQueue) {
2053
+ this.#playbackQueue = playbackQueue;
2054
+ }
2055
+ setPlaybackState(playbackState, playbackStateTimestamp) {
2056
+ if (playbackStateTimestamp < this.#playbackStateTimestamp) return;
2057
+ this.#playbackState = playbackState;
2058
+ this.#playbackStateTimestamp = playbackStateTimestamp;
2059
+ }
2060
+ setSupportedCommands(supportedCommands) {
2061
+ this.#supportedCommands = supportedCommands;
2062
+ }
2063
+ updateContentItem(item) {
2064
+ if (!this.#playbackQueue) return;
2065
+ const index = this.#playbackQueue.contentItems.findIndex((i) => i.identifier === item.identifier);
2066
+ if (index === -1) return;
2067
+ this.#playbackQueue.contentItems[index] = merge(item, this.#playbackQueue.contentItems[index]);
2068
+ }
2069
+ };
2070
+
2071
+ //#endregion
2072
+ //#region src/airplay/state.ts
2073
+ var state_default = class extends EventEmitter {
2074
+ get #dataStream() {
2075
+ return this.#protocol.dataStream;
2076
+ }
2077
+ get #protocol() {
2078
+ return this.#device[PROTOCOL];
2079
+ }
2080
+ get clients() {
2081
+ return this.#clients;
2082
+ }
2083
+ get nowPlayingClient() {
2084
+ return this.#nowPlayingClientBundleIdentifier ? this.#clients[this.#nowPlayingClientBundleIdentifier] ?? null : null;
2085
+ }
2086
+ get outputDeviceUID() {
2087
+ return this.#outputDeviceUID;
2088
+ }
2089
+ get volume() {
2090
+ return this.#volume;
2091
+ }
2092
+ get volumeAvailable() {
2093
+ return this.#volumeAvailable;
2094
+ }
2095
+ get volumeCapabilities() {
2096
+ return this.#volumeCapabilities;
2097
+ }
2098
+ #device;
2099
+ #clients;
2100
+ #nowPlayingClientBundleIdentifier;
2101
+ #outputDeviceUID;
2102
+ #volume;
2103
+ #volumeAvailable;
2104
+ #volumeCapabilities;
2105
+ constructor(device) {
2106
+ super();
2107
+ this.#device = device;
2108
+ this.clear();
2109
+ this.onDeviceInfo = this.onDeviceInfo.bind(this);
2110
+ this.onDeviceInfoUpdate = this.onDeviceInfoUpdate.bind(this);
2111
+ this.onOriginClientProperties = this.onOriginClientProperties.bind(this);
2112
+ this.onPlayerClientProperties = this.onPlayerClientProperties.bind(this);
2113
+ this.onRemoveClient = this.onRemoveClient.bind(this);
2114
+ this.onSendCommandResult = this.onSendCommandResult.bind(this);
2115
+ this.onSetArtwork = this.onSetArtwork.bind(this);
2116
+ this.onSetDefaultSupportedCommands = this.onSetDefaultSupportedCommands.bind(this);
2117
+ this.onSetNowPlayingClient = this.onSetNowPlayingClient.bind(this);
2118
+ this.onSetNowPlayingPlayer = this.onSetNowPlayingPlayer.bind(this);
2119
+ this.onSetState = this.onSetState.bind(this);
2120
+ this.onUpdateClient = this.onUpdateClient.bind(this);
2121
+ this.onUpdateContentItem = this.onUpdateContentItem.bind(this);
2122
+ this.onUpdateContentItemArtwork = this.onUpdateContentItemArtwork.bind(this);
2123
+ this.onUpdatePlayer = this.onUpdatePlayer.bind(this);
2124
+ this.onUpdateOutputDevice = this.onUpdateOutputDevice.bind(this);
2125
+ this.onVolumeControlAvailability = this.onVolumeControlAvailability.bind(this);
2126
+ this.onVolumeControlCapabilitiesDidChange = this.onVolumeControlCapabilitiesDidChange.bind(this);
2127
+ this.onVolumeDidChange = this.onVolumeDidChange.bind(this);
2128
+ }
2129
+ [STATE_SUBSCRIBE_SYMBOL]() {
2130
+ this.#dataStream.on("deviceInfo", this.onDeviceInfo);
2131
+ this.#dataStream.on("deviceInfoUpdate", this.onDeviceInfoUpdate);
2132
+ this.#dataStream.on("originClientProperties", this.onOriginClientProperties);
2133
+ this.#dataStream.on("playerClientProperties", this.onPlayerClientProperties);
2134
+ this.#dataStream.on("removeClient", this.onRemoveClient);
2135
+ this.#dataStream.on("sendCommandResult", this.onSendCommandResult);
2136
+ this.#dataStream.on("setArtwork", this.onSetArtwork);
2137
+ this.#dataStream.on("setDefaultSupportedCommands", this.onSetDefaultSupportedCommands);
2138
+ this.#dataStream.on("setNowPlayingClient", this.onSetNowPlayingClient);
2139
+ this.#dataStream.on("setNowPlayingPlayer", this.onSetNowPlayingPlayer);
2140
+ this.#dataStream.on("setState", this.onSetState);
2141
+ this.#dataStream.on("updateClient", this.onUpdateClient);
2142
+ this.#dataStream.on("updateContentItem", this.onUpdateContentItem);
2143
+ this.#dataStream.on("updateContentItemArtwork", this.onUpdateContentItemArtwork);
2144
+ this.#dataStream.on("updatePlayer", this.onUpdatePlayer);
2145
+ this.#dataStream.on("updateOutputDevice", this.onUpdateOutputDevice);
2146
+ this.#dataStream.on("volumeControlAvailability", this.onVolumeControlAvailability);
2147
+ this.#dataStream.on("volumeControlCapabilitiesDidChange", this.onVolumeControlCapabilitiesDidChange);
2148
+ this.#dataStream.on("volumeDidChange", this.onVolumeDidChange);
2149
+ }
2150
+ [STATE_UNSUBSCRIBE_SYMBOL]() {
2151
+ const dataStream = this.#dataStream;
2152
+ if (!dataStream) return;
2153
+ dataStream.off("deviceInfo", this.onDeviceInfo);
2154
+ dataStream.off("deviceInfoUpdate", this.onDeviceInfoUpdate);
2155
+ dataStream.off("originClientProperties", this.onOriginClientProperties);
2156
+ dataStream.off("playerClientProperties", this.onPlayerClientProperties);
2157
+ dataStream.off("removeClient", this.onRemoveClient);
2158
+ dataStream.off("sendCommandResult", this.onSendCommandResult);
2159
+ dataStream.off("setArtwork", this.onSetArtwork);
2160
+ dataStream.off("setDefaultSupportedCommands", this.onSetDefaultSupportedCommands);
2161
+ dataStream.off("setNowPlayingClient", this.onSetNowPlayingClient);
2162
+ dataStream.off("setNowPlayingPlayer", this.onSetNowPlayingPlayer);
2163
+ dataStream.off("setState", this.onSetState);
2164
+ dataStream.off("updateClient", this.onUpdateClient);
2165
+ dataStream.off("updateContentItem", this.onUpdateContentItem);
2166
+ dataStream.off("updateContentItemArtwork", this.onUpdateContentItemArtwork);
2167
+ dataStream.off("updatePlayer", this.onUpdatePlayer);
2168
+ dataStream.off("updateOutputDevice", this.onUpdateOutputDevice);
2169
+ dataStream.off("volumeControlAvailability", this.onVolumeControlAvailability);
2170
+ dataStream.off("volumeControlCapabilitiesDidChange", this.onVolumeControlCapabilitiesDidChange);
2171
+ dataStream.off("volumeDidChange", this.onVolumeDidChange);
2172
+ }
2173
+ clear() {
2174
+ this.#clients = {};
2175
+ this.#nowPlayingClientBundleIdentifier = null;
2176
+ this.#outputDeviceUID = null;
2177
+ this.#volume = 0;
2178
+ this.#volumeAvailable = false;
2179
+ this.#volumeCapabilities = Proto.VolumeCapabilities_Enum.None;
2180
+ }
2181
+ onDeviceInfo(message) {
2182
+ if (message.clusterID) this.#outputDeviceUID = message.clusterID;
2183
+ else if (message.deviceUID) this.#outputDeviceUID = message.deviceUID;
2184
+ else if (message.uniqueIdentifier) this.#outputDeviceUID = message.uniqueIdentifier;
2185
+ this.emit("deviceInfo", message);
2186
+ }
2187
+ onDeviceInfoUpdate(message) {
2188
+ if (message.clusterID) this.#outputDeviceUID = message.clusterID;
2189
+ else if (message.deviceUID) this.#outputDeviceUID = message.deviceUID;
2190
+ else if (message.uniqueIdentifier) this.#outputDeviceUID = message.uniqueIdentifier;
2191
+ this.emit("deviceInfoUpdate", message);
2192
+ }
2193
+ onOriginClientProperties(message) {
2194
+ this.emit("originClientProperties", message);
2195
+ }
2196
+ onPlayerClientProperties(message) {
2197
+ this.emit("playerClientProperties", message);
2198
+ }
2199
+ onRemoveClient(message) {
2200
+ if (!(message.client.bundleIdentifier in this.#clients)) return;
2201
+ delete this.#clients[message.client.bundleIdentifier];
2202
+ this.emit("clients", this.#clients);
2203
+ }
2204
+ onSendCommandResult(message) {
2205
+ this.emit("sendCommandResult", message);
2206
+ }
2207
+ onSetArtwork(message) {
2208
+ this.emit("setArtwork", message);
2209
+ }
2210
+ onSetDefaultSupportedCommands(message) {
2211
+ this.emit("setDefaultSupportedCommands", message);
2212
+ }
2213
+ onSetNowPlayingClient(message) {
2214
+ this.#nowPlayingClientBundleIdentifier = message.client?.bundleIdentifier ?? null;
2215
+ this.emit("setNowPlayingClient", message);
2216
+ }
2217
+ onSetNowPlayingPlayer(message) {
2218
+ this.emit("setNowPlayingPlayer", message);
2219
+ }
2220
+ onSetState(message) {
2221
+ const client = this.#client(message.playerPath.client.bundleIdentifier, message.displayName);
2222
+ if (message.playbackState) client.setPlaybackState(message.playbackState, message.playbackStateTimestamp);
2223
+ if (message.supportedCommands) client.setSupportedCommands(message.supportedCommands.supportedCommands);
2224
+ if (message.playbackQueue) client.setPlaybackQueue(message.playbackQueue);
2225
+ this.emit("setState", message);
2226
+ }
2227
+ onUpdateContentItem(message) {
2228
+ const client = this.#client(message.playerPath.client.bundleIdentifier, message.playerPath.client.displayName);
2229
+ if (!client) return;
2230
+ for (const item of message.contentItems) client.updateContentItem(item);
2231
+ this.emit("updateContentItem", message);
2232
+ }
2233
+ onUpdateContentItemArtwork(message) {
2234
+ this.emit("updateContentItemArtwork", message);
2235
+ }
2236
+ onUpdatePlayer(message) {
2237
+ this.emit("updatePlayer", message);
2238
+ }
2239
+ onUpdateClient(message) {
2240
+ this.#client(message.client.bundleIdentifier, message.client.displayName);
2241
+ this.emit("clients", this.#clients);
2242
+ }
2243
+ onUpdateOutputDevice(message) {
2244
+ this.emit("updateOutputDevice", message);
2245
+ }
2246
+ onVolumeControlAvailability(message) {
2247
+ this.#volumeAvailable = message.volumeControlAvailable;
2248
+ this.#volumeCapabilities = message.volumeCapabilities;
2249
+ this.emit("volumeControlAvailability", message.volumeControlAvailable, message.volumeCapabilities);
2250
+ }
2251
+ onVolumeControlCapabilitiesDidChange(message) {
2252
+ this.#volumeAvailable = message.capabilities.volumeControlAvailable;
2253
+ this.#volumeCapabilities = message.capabilities.volumeCapabilities;
2254
+ this.emit("volumeControlCapabilitiesDidChange", message.capabilities.volumeControlAvailable, message.capabilities.volumeCapabilities);
2255
+ }
2256
+ onVolumeDidChange(message) {
2257
+ this.#volume = message.volume;
2258
+ this.emit("volumeDidChange", message.volume);
2259
+ }
2260
+ #client(bundleIdentifier, displayName) {
2261
+ if (bundleIdentifier in this.#clients) return this.#clients[bundleIdentifier];
2262
+ else {
2263
+ const client = new Client(bundleIdentifier, displayName);
2264
+ this.#clients[bundleIdentifier] = client;
2265
+ this.emit("clients", this.#clients);
2266
+ return client;
2267
+ }
2268
+ }
2269
+ };
2270
+
2271
+ //#endregion
2272
+ //#region src/airplay/volume.ts
2273
+ const VOLUME_STEP = .05;
2274
+ var volume_default = class {
2275
+ get #protocol() {
2276
+ return this.#device[PROTOCOL];
2277
+ }
2278
+ get #state() {
2279
+ return this.#device.state;
2280
+ }
2281
+ #device;
2282
+ constructor(device) {
2283
+ this.#device = device;
2284
+ }
2285
+ async down() {
2286
+ switch (this.#state.volumeCapabilities) {
2287
+ case Proto.VolumeCapabilities_Enum.Absolute:
2288
+ case Proto.VolumeCapabilities_Enum.Both:
2289
+ const newVolume = Math.max(0, this.#state.volume - VOLUME_STEP);
2290
+ await this.set(newVolume);
2291
+ break;
2292
+ case Proto.VolumeCapabilities_Enum.Relative:
2293
+ await this.#device.remote.volumeDown();
2294
+ break;
2295
+ default: throw new Error("Volume control is not available.");
2296
+ }
2297
+ }
2298
+ async up() {
2299
+ switch (this.#state.volumeCapabilities) {
2300
+ case Proto.VolumeCapabilities_Enum.Absolute:
2301
+ case Proto.VolumeCapabilities_Enum.Both:
2302
+ const newVolume = Math.max(0, this.#state.volume + VOLUME_STEP);
2303
+ await this.set(newVolume);
2304
+ break;
2305
+ case Proto.VolumeCapabilities_Enum.Relative:
2306
+ await this.#device.remote.volumeUp();
2307
+ break;
2308
+ default: throw new Error("Volume control is not available.");
2309
+ }
2310
+ }
2311
+ async get() {
2312
+ if (!this.#state.outputDeviceUID) throw new Error("No output device active.");
2313
+ const response = await this.#protocol.dataStream.exchange(DataStreamMessage.getVolume(this.#state.outputDeviceUID));
2314
+ if (response.type === Proto.ProtocolMessage_Type.GET_VOLUME_RESULT_MESSAGE) return DataStreamMessage.getExtension(response, Proto.getVolumeResultMessage).volume;
2315
+ throw new Error("Failed to get volume.");
2316
+ }
2317
+ async set(volume) {
2318
+ if (!this.#state.outputDeviceUID) throw new Error("No output device active.");
2319
+ if (![Proto.VolumeCapabilities_Enum.Absolute, Proto.VolumeCapabilities_Enum.Both].includes(this.#state.volumeCapabilities)) throw new Error("Absolute volume control is not available.");
2320
+ volume = Math.min(1, Math.max(0, volume));
2321
+ this.#protocol.context.logger.info(`Setting volume to ${volume} for device ${this.#state.outputDeviceUID}`);
2322
+ await this.#protocol.dataStream.exchange(DataStreamMessage.setVolume(this.#state.outputDeviceUID, volume));
2323
+ }
2324
+ };
2325
+
2326
+ //#endregion
2327
+ //#region src/airplay/device.ts
2328
+ var device_default = class extends EventEmitter {
2329
+ get [PROTOCOL]() {
2330
+ return this.#protocol;
2331
+ }
2332
+ get discoveryResult() {
2333
+ return this.#discoveryResult;
2334
+ }
2335
+ set discoveryResult(discoveryResult) {
2336
+ this.#discoveryResult = discoveryResult;
2337
+ }
2338
+ get isConnected() {
2339
+ return this.#protocol?.controlStream?.isConnected ?? false;
2340
+ }
2341
+ get remote() {
2342
+ return this.#remote;
2343
+ }
2344
+ get state() {
2345
+ return this.#state;
2346
+ }
2347
+ get volume() {
2348
+ return this.#volume;
2349
+ }
2350
+ get timingServer() {
2351
+ return this.#timingServer;
2352
+ }
2353
+ set timingServer(timingServer) {
2354
+ this.#timingServer = timingServer;
2355
+ }
2356
+ #remote;
2357
+ #state;
2358
+ #volume;
2359
+ #credentials;
2360
+ #disconnect = false;
2361
+ #discoveryResult;
2362
+ #feedbackInterval;
2363
+ #keys;
2364
+ #protocol;
2365
+ #timingServer;
2366
+ constructor(discoveryResult) {
2367
+ super();
2368
+ this.#discoveryResult = discoveryResult;
2369
+ this.#remote = new remote_default(this);
2370
+ this.#state = new state_default(this);
2371
+ this.#volume = new volume_default(this);
2372
+ }
2373
+ async connect() {
2374
+ this.#disconnect = false;
2375
+ this.#state.clear();
2376
+ this.#protocol = new Protocol(this.#discoveryResult);
2377
+ this.#protocol.controlStream.on("close", this.#onClose.bind(this));
2378
+ this.#protocol.controlStream.on("error", this.#onError.bind(this));
2379
+ this.#protocol.controlStream.on("timeout", this.#onTimeout.bind(this));
2380
+ await this.#protocol.connect();
2381
+ if (this.#credentials) this.#keys = await this.#protocol.verify.start(this.#credentials);
2382
+ else {
2383
+ await this.#protocol.pairing.start();
2384
+ this.#keys = await this.#protocol.pairing.transient();
2385
+ }
2386
+ await this.#setup();
2387
+ this.emit("connected");
2388
+ }
2389
+ disconnect() {
2390
+ this.#disconnect = true;
2391
+ if (this.#feedbackInterval) {
2392
+ clearInterval(this.#feedbackInterval);
2393
+ this.#feedbackInterval = void 0;
2394
+ }
2395
+ this.#unsubscribe();
2396
+ this.#protocol.disconnect();
2397
+ }
2398
+ disconnectSafely() {
2399
+ try {
2400
+ this.disconnect();
2401
+ } catch (_) {}
2402
+ }
2403
+ async requestPlaybackQueue(length) {
2404
+ await this.#protocol.dataStream.exchange(DataStreamMessage.playbackQueueRequest(0, length));
2405
+ }
2406
+ async sendCommand(command, options) {
2407
+ await this.#protocol.dataStream.exchange(DataStreamMessage.sendCommand(command, options));
2408
+ }
2409
+ setCredentials(credentials) {
2410
+ this.#credentials = credentials;
2411
+ }
2412
+ async #feedback() {
2413
+ try {
2414
+ await this.#protocol.feedback();
2415
+ } catch (err) {
2416
+ this.#protocol.context.logger.error("Feedback error", err);
2417
+ }
2418
+ }
2419
+ #onClose() {
2420
+ this.#protocol.context.logger.net("#onClose() called on airplay device.");
2421
+ if (!this.#disconnect) {
2422
+ this.disconnectSafely();
2423
+ this.emit("disconnected", true);
2424
+ } else this.emit("disconnected", false);
2425
+ }
2426
+ #onError(err) {
2427
+ this.#protocol.context.logger.error("AirPlay error", err);
2428
+ }
2429
+ #onTimeout() {
2430
+ this.#protocol.context.logger.error("AirPlay timeout");
2431
+ this.#protocol.controlStream.destroy();
2432
+ }
2433
+ async #setup() {
2434
+ const keys = this.#keys;
2435
+ this.#protocol.controlStream.enableEncryption(keys.accessoryToControllerKey, keys.controllerToAccessoryKey);
2436
+ this.#unsubscribe();
2437
+ if (this.#timingServer) this.#protocol.useTimingServer(this.#timingServer);
2438
+ await this.#protocol.setupEventStream(keys.sharedSecret, keys.pairingId);
2439
+ await this.#protocol.setupDataStream(keys.sharedSecret, () => this.#subscribe());
2440
+ this.#protocol.dataStream.on("error", this.#onError.bind(this));
2441
+ this.#protocol.dataStream.on("timeout", this.#onTimeout.bind(this));
2442
+ this.#protocol.eventStream.on("error", this.#onError.bind(this));
2443
+ this.#protocol.eventStream.on("timeout", this.#onTimeout.bind(this));
2444
+ this.#feedbackInterval = setInterval(async () => await this.#feedback(), FEEDBACK_INTERVAL);
2445
+ try {
2446
+ await this.#protocol.dataStream.exchange(DataStreamMessage.setConnectionState(Proto.SetConnectionStateMessage_ConnectionState.Connecting));
2447
+ await waitFor(500);
2448
+ const gid = this.#discoveryResult.txt.gid;
2449
+ if (gid) await this.#protocol.dataStream.exchange(DataStreamMessage.configureConnection(gid));
2450
+ if (!await Promise.race([new Promise(async (resolve) => {
2451
+ this.#protocol.dataStream.once("deviceInfo", async () => {
2452
+ await this.#protocol.dataStream.exchange(DataStreamMessage.setConnectionState());
2453
+ await this.#protocol.dataStream.exchange(DataStreamMessage.clientUpdatesConfig());
2454
+ resolve(true);
2455
+ });
2456
+ await this.#protocol.dataStream.exchange(DataStreamMessage.deviceInfo(keys.pairingId));
2457
+ }), async () => {
2458
+ await waitFor(3e3);
2459
+ return false;
2460
+ }])) this.#onError(/* @__PURE__ */ new Error("Device did not respond in time with its info."));
2461
+ else this.#protocol.context.logger.info("Device info received successfully, protocol should be ready.");
2462
+ } catch (err) {
2463
+ clearInterval(this.#feedbackInterval);
2464
+ this.#feedbackInterval = void 0;
2465
+ throw err;
2466
+ }
2467
+ }
2468
+ #subscribe() {
2469
+ this.#state[STATE_SUBSCRIBE_SYMBOL]();
2470
+ }
2471
+ #unsubscribe() {
2472
+ try {
2473
+ this.#state[STATE_UNSUBSCRIBE_SYMBOL]();
2474
+ } catch (err) {
2475
+ this.#protocol.context.logger.error("State unsubscribe error", err);
2476
+ }
2477
+ }
2478
+ };
2479
+
2480
+ //#endregion
2481
+ //#region src/companion-link/const.ts
2482
+ const PROTOCOL$1 = Symbol("com.basmilius.companion-link:protocol");
2483
+
2484
+ //#endregion
2485
+ //#region src/companion-link/device.ts
2486
+ var device_default$1 = class extends EventEmitter {
2487
+ get [PROTOCOL$1]() {
2488
+ return this.#protocol;
2489
+ }
2490
+ get discoveryResult() {
2491
+ return this.#discoveryResult;
2492
+ }
2493
+ set discoveryResult(discoveryResult) {
2494
+ this.#discoveryResult = discoveryResult;
2495
+ }
2496
+ get isConnected() {
2497
+ return this.#protocol?.stream?.isConnected ?? false;
2498
+ }
2499
+ #credentials;
2500
+ #disconnect = false;
2501
+ #discoveryResult;
2502
+ #heartbeatInterval;
2503
+ #keys;
2504
+ #protocol;
2505
+ constructor(discoveryResult) {
2506
+ super();
2507
+ this.#discoveryResult = discoveryResult;
2508
+ this.onSystemStatus = this.onSystemStatus.bind(this);
2509
+ this.onTVSystemStatus = this.onTVSystemStatus.bind(this);
2510
+ }
2511
+ async connect() {
2512
+ if (!this.#credentials) throw new Error("Credentials are required to connect to a Companion Link device.");
2513
+ this.#disconnect = false;
2514
+ this.#protocol = new Protocol$1(this.#discoveryResult);
2515
+ this.#protocol.stream.on("close", async () => this.#onClose());
2516
+ this.#protocol.stream.on("error", async (err) => this.#onError(err));
2517
+ this.#protocol.stream.on("timeout", async () => this.#onTimeout());
2518
+ await this.#protocol.connect();
2519
+ this.#keys = await this.#protocol.verify.start(this.#credentials);
2520
+ await this.#setup();
2521
+ this.emit("connected");
2522
+ }
2523
+ async disconnect() {
2524
+ this.#disconnect = true;
2525
+ if (this.#heartbeatInterval) {
2526
+ clearInterval(this.#heartbeatInterval);
2527
+ this.#heartbeatInterval = void 0;
2528
+ }
2529
+ await this.#unsubscribe();
2530
+ await this.#protocol.disconnect();
2531
+ }
2532
+ async disconnectSafely() {
2533
+ try {
2534
+ await this.disconnect();
2535
+ } catch (_) {}
2536
+ }
2537
+ async setCredentials(credentials) {
2538
+ this.#credentials = credentials;
2539
+ }
2540
+ async getAttentionState() {
2541
+ return await this.#protocol.getAttentionState();
2542
+ }
2543
+ async getLaunchableApps() {
2544
+ return await this.#protocol.getLaunchableApps();
2545
+ }
2546
+ async getUserAccounts() {
2547
+ return await this.#protocol.getUserAccounts();
2548
+ }
2549
+ async launchApp(bundleId) {
2550
+ await this.#protocol.launchApp(bundleId);
2551
+ }
2552
+ async launchUrl(url) {
2553
+ await this.#protocol.launchUrl(url);
2554
+ }
2555
+ async mediaControlCommand(command, content) {
2556
+ await this.#protocol.mediaControlCommand(command, content);
2557
+ }
2558
+ async pressButton(command, type, holdDelayMs) {
2559
+ await this.#protocol.pressButton(command, type, holdDelayMs);
2560
+ }
2561
+ async switchUserAccount(accountId) {
2562
+ await this.#protocol.switchUserAccount(accountId);
2563
+ }
2564
+ async #heartbeat() {
2565
+ try {
2566
+ this.#protocol.noOp();
2567
+ } catch (err) {
2568
+ this.#protocol.context.logger.error("Heartbeat error", err);
2569
+ }
2570
+ }
2571
+ async #onClose() {
2572
+ this.#protocol.context.logger.net("#onClose() called on companion link device.");
2573
+ if (!this.#disconnect) {
2574
+ await this.disconnectSafely();
2575
+ this.emit("disconnected", true);
2576
+ } else this.emit("disconnected", false);
2577
+ }
2578
+ async #onError(err) {
2579
+ this.#protocol.context.logger.error("Companion Link error", err);
2580
+ }
2581
+ async #onTimeout() {
2582
+ this.#protocol.context.logger.error("Companion Link timeout");
2583
+ await this.#protocol.stream.destroy();
2584
+ }
2585
+ async #setup() {
2586
+ const keys = this.#keys;
2587
+ this.#protocol.stream.enableEncryption(keys.accessoryToControllerKey, keys.controllerToAccessoryKey);
2588
+ try {
2589
+ await this.#protocol.systemInfo(this.#credentials.pairingId);
2590
+ await this.#protocol.sessionStart();
2591
+ await this.#protocol.tvrcSessionStart();
2592
+ await this.#protocol.touchStart();
2593
+ await this.#protocol.tiStart();
2594
+ await this.#protocol.unsubscribe("_iMC");
2595
+ this.#heartbeatInterval = setInterval(async () => await this.#heartbeat(), 15e3);
2596
+ await this.#subscribe();
2597
+ } catch (err) {
2598
+ clearInterval(this.#heartbeatInterval);
2599
+ this.#heartbeatInterval = void 0;
2600
+ throw err;
2601
+ }
2602
+ }
2603
+ async #subscribe() {
2604
+ await this.#protocol.subscribe("SystemStatus", this.onSystemStatus);
2605
+ await this.#protocol.subscribe("TVSystemStatus", this.onTVSystemStatus);
2606
+ const state = await this.getAttentionState();
2607
+ this.emit("power", state);
2608
+ }
2609
+ async #unsubscribe() {
2610
+ try {
2611
+ await this.#protocol.unsubscribe("SystemStatus", this.onSystemStatus);
2612
+ await this.#protocol.unsubscribe("TVSystemStatus", this.onTVSystemStatus);
2613
+ } catch (_) {}
2614
+ }
2615
+ async onSystemStatus(data) {
2616
+ this.#protocol.context.logger.info("System Status", data);
2617
+ this.emit("power", convertAttentionState(data.state));
2618
+ }
2619
+ async onTVSystemStatus(data) {
2620
+ this.#protocol.context.logger.info("TV System Status", data);
2621
+ this.emit("power", convertAttentionState(data.state));
2622
+ }
2623
+ };
2624
+
2625
+ //#endregion
2626
+ //#region src/model/apple-tv.ts
2627
+ var apple_tv_default = class extends EventEmitter {
2628
+ get airplay() {
2629
+ return this.#airplay;
2630
+ }
2631
+ get companionLink() {
2632
+ return this.#companionLink;
2633
+ }
2634
+ get bundleIdentifier() {
2635
+ return this.#airplay.state.nowPlayingClient?.bundleIdentifier ?? null;
2636
+ }
2637
+ get displayName() {
2638
+ return this.#airplay.state.nowPlayingClient?.displayName ?? null;
2639
+ }
2640
+ get isConnected() {
2641
+ return this.#airplay.isConnected && this.#companionLink.isConnected;
2642
+ }
2643
+ get isPlaying() {
2644
+ return this.playbackState === AirPlay.Proto.PlaybackState_Enum.Playing;
2645
+ }
2646
+ get playbackQueue() {
2647
+ return this.#airplay.state.nowPlayingClient?.playbackQueue ?? null;
2648
+ }
2649
+ get playbackState() {
2650
+ return this.#airplay.state.nowPlayingClient?.playbackState ?? AirPlay.Proto.PlaybackState_Enum.Unknown;
2651
+ }
2652
+ get playbackStateTimestamp() {
2653
+ return this.#airplay.state.nowPlayingClient?.playbackStateTimestamp ?? -1;
2654
+ }
2655
+ #airplay;
2656
+ #companionLink;
2657
+ #disconnect = false;
2658
+ constructor(airplayDiscoveryResult, companionLinkDiscoveryResult) {
2659
+ super();
2660
+ this.#airplay = new device_default(airplayDiscoveryResult);
2661
+ this.#companionLink = new device_default$1(companionLinkDiscoveryResult);
2662
+ this.#airplay.on("connected", () => this.#onConnected());
2663
+ this.#airplay.on("disconnected", (unexpected) => this.#onDisconnected(unexpected));
2664
+ this.#companionLink.on("connected", () => this.#onConnected());
2665
+ this.#companionLink.on("disconnected", (unexpected) => this.#onDisconnected(unexpected));
2666
+ }
2667
+ async connect(credentials) {
2668
+ await this.#airplay.setCredentials(credentials);
2669
+ await this.#companionLink.setCredentials(credentials);
2670
+ await this.#airplay.connect();
2671
+ await this.#companionLink.connect();
2672
+ this.#disconnect = false;
2673
+ }
2674
+ async disconnect() {
2675
+ await this.#airplay.disconnect();
2676
+ await this.#companionLink.disconnect();
2677
+ }
2678
+ async turnOff() {
2679
+ await this.#airplay.remote.suspend();
2680
+ }
2681
+ async turnOn() {
2682
+ await this.#airplay.remote.wake();
2683
+ }
2684
+ async pause() {
2685
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.Pause);
2686
+ }
2687
+ async playPause() {
2688
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.TogglePlayPause);
2689
+ }
2690
+ async play() {
2691
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.Play);
2692
+ }
2693
+ async stop() {
2694
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.Stop);
2695
+ }
2696
+ async next() {
2697
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.NextInContext);
2698
+ }
2699
+ async previous() {
2700
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.PreviousInContext);
2701
+ }
2702
+ async volumeDown() {
2703
+ await this.#airplay.remote.volumeDown();
2704
+ }
2705
+ async volumeMute() {
2706
+ await this.#airplay.remote.mute();
2707
+ }
2708
+ async volumeUp() {
2709
+ await this.#airplay.remote.volumeUp();
2710
+ }
2711
+ async getCommandInfo(command) {
2712
+ const client = this.#airplay.state.nowPlayingClient;
2713
+ if (!client) return null;
2714
+ return client.supportedCommands.find((c) => c.command === command) ?? null;
2715
+ }
2716
+ async isCommandSupported(command) {
2717
+ const client = this.#airplay.state.nowPlayingClient;
2718
+ if (!client) return false;
2719
+ return client.isCommandSupported(command);
2720
+ }
2721
+ async #onConnected() {
2722
+ if (!this.#airplay.isConnected || !this.#companionLink.isConnected) return;
2723
+ this.emit("connected");
2724
+ }
2725
+ async #onDisconnected(unexpected) {
2726
+ if (this.#disconnect) return;
2727
+ this.#disconnect = true;
2728
+ await this.disconnect();
2729
+ this.emit("disconnected", unexpected);
2730
+ }
2731
+ };
2732
+
2733
+ //#endregion
2734
+ //#region src/model/homepod-base.ts
2735
+ var homepod_base_default = class extends EventEmitter {
2736
+ get airplay() {
2737
+ return this.#airplay;
2738
+ }
2739
+ get bundleIdentifier() {
2740
+ return this.#airplay.state.nowPlayingClient?.bundleIdentifier ?? null;
2741
+ }
2742
+ get displayName() {
2743
+ return this.#airplay.state.nowPlayingClient?.displayName ?? null;
2744
+ }
2745
+ get isConnected() {
2746
+ return this.#airplay.isConnected;
2747
+ }
2748
+ get isPlaying() {
2749
+ return this.playbackState === AirPlay.Proto.PlaybackState_Enum.Playing;
2750
+ }
2751
+ get playbackQueue() {
2752
+ return this.#airplay.state.nowPlayingClient?.playbackQueue ?? null;
2753
+ }
2754
+ get playbackState() {
2755
+ return this.#airplay.state.nowPlayingClient?.playbackState ?? AirPlay.Proto.PlaybackState_Enum.Unknown;
2756
+ }
2757
+ get playbackStateTimestamp() {
2758
+ return this.#airplay.state.nowPlayingClient?.playbackStateTimestamp ?? -1;
2759
+ }
2760
+ get volume() {
2761
+ return this.#airplay.state.volume ?? 0;
2762
+ }
2763
+ #airplay;
2764
+ #disconnect = false;
2765
+ constructor(discoveryResult) {
2766
+ super();
2767
+ this.#airplay = new device_default(discoveryResult);
2768
+ this.#airplay.on("connected", () => this.#onConnected());
2769
+ this.#airplay.on("disconnected", (unexpected) => this.#onDisconnected(unexpected));
2770
+ }
2771
+ async connect() {
2772
+ await this.#airplay.connect();
2773
+ this.#disconnect = false;
2774
+ }
2775
+ async disconnect() {
2776
+ await this.#airplay.disconnect();
2777
+ }
2778
+ async pause() {
2779
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.Pause);
2780
+ }
2781
+ async playPause() {
2782
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.TogglePlayPause);
2783
+ }
2784
+ async play() {
2785
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.Play);
2786
+ }
2787
+ async stop() {
2788
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.Stop);
2789
+ }
2790
+ async next() {
2791
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.NextInContext);
2792
+ }
2793
+ async previous() {
2794
+ await this.#airplay.sendCommand(AirPlay.Proto.Command.PreviousInContext);
2795
+ }
2796
+ async getCommandInfo(command) {
2797
+ const client = this.#airplay.state.nowPlayingClient;
2798
+ if (!client) return null;
2799
+ return client.supportedCommands.find((c) => c.command === command) ?? null;
2800
+ }
2801
+ async isCommandSupported(command) {
2802
+ const client = this.#airplay.state.nowPlayingClient;
2803
+ if (!client) return false;
2804
+ return client.isCommandSupported(command);
2805
+ }
2806
+ async #onConnected() {
2807
+ this.emit("connected");
2808
+ }
2809
+ async #onDisconnected(unexpected) {
2810
+ if (this.#disconnect) return;
2811
+ this.#disconnect = true;
2812
+ await this.disconnect();
2813
+ this.emit("disconnected", unexpected);
2814
+ }
2815
+ };
2816
+
2817
+ //#endregion
2818
+ //#region src/model/homepod.ts
2819
+ var homepod_default = class extends homepod_base_default {};
2820
+
2821
+ //#endregion
2822
+ //#region src/model/homepod-mini.ts
2823
+ var homepod_mini_default = class extends homepod_base_default {};
2824
+
2825
+ //#endregion
2826
+ export { PROTOCOL as AIRPLAY, device_default as AirPlayDevice, apple_tv_default as AppleTV, PROTOCOL$1 as COMPANION_LINK, device_default$1 as CompanionLinkDevice, homepod_default as HomePod, homepod_mini_default as HomePodMini };
2
2827
  //# sourceMappingURL=index.mjs.map