@tbogard/itunes-search
Version:
An iTunes Search library that uses Apple Web Search API. It performes blazing fast searches on iTunes Web API to fetch anything you want to search related to music tracks, music videos, artists, albums, movies, apps in the appStore, books, audiobooks and
3 lines (2 loc) • 23.8 kB
JavaScript
(()=>{var Er=Object.create;var H=Object.defineProperty,Ar=Object.defineProperties,gr=Object.getOwnPropertyDescriptor,Or=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertyNames,le=Object.getOwnPropertySymbols,xr=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,qr=Object.prototype.propertyIsEnumerable;var fe=(t,e,r)=>e in t?H(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,y=(t,e)=>{for(var r in e||(e={}))he.call(e,r)&&fe(t,r,e[r]);if(le)for(var r of le(e))qr.call(e,r)&&fe(t,r,e[r]);return t},T=(t,e)=>Ar(t,Or(e));var l=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Cr=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Rr(e))!he.call(t,n)&&n!==r&&H(t,n,{get:()=>e[n],enumerable:!(i=gr(e,n))||i.enumerable});return t};var Pr=(t,e,r)=>(r=t!=null?Er(xr(t)):{},Cr(e||!t||!t.__esModule?H(r,"default",{value:t,enumerable:!0}):r,t));var S=(t,e,r)=>new Promise((i,n)=>{var s=c=>{try{o(r.next(c))}catch(h){n(h)}},u=c=>{try{o(r.throw(c))}catch(h){n(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,u);o((r=r.apply(t,e)).next())});var G=l((Ot,de)=>{"use strict";de.exports=function(e,r){return function(){for(var n=new Array(arguments.length),s=0;s<n.length;s++)n[s]=arguments[s];return e.apply(r,n)}}});var p=l((Rt,ve)=>{"use strict";var Nr=G(),A=Object.prototype.toString;function V(t){return Array.isArray(t)}function _(t){return typeof t>"u"}function Ir(t){return t!==null&&!_(t)&&t.constructor!==null&&!_(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function pe(t){return A.call(t)==="[object ArrayBuffer]"}function Mr(t){return A.call(t)==="[object FormData]"}function Br(t){var e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&pe(t.buffer),e}function kr(t){return typeof t=="string"}function Lr(t){return typeof t=="number"}function me(t){return t!==null&&typeof t=="object"}function I(t){if(A.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Ur(t){return A.call(t)==="[object Date]"}function Dr(t){return A.call(t)==="[object File]"}function jr(t){return A.call(t)==="[object Blob]"}function ye(t){return A.call(t)==="[object Function]"}function Fr(t){return me(t)&&ye(t.pipe)}function Hr(t){return A.call(t)==="[object URLSearchParams]"}function Gr(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function _r(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function K(t,e){if(!(t===null||typeof t>"u"))if(typeof t!="object"&&(t=[t]),V(t))for(var r=0,i=t.length;r<i;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}function J(){var t={};function e(n,s){I(t[s])&&I(n)?t[s]=J(t[s],n):I(n)?t[s]=J({},n):V(n)?t[s]=n.slice():t[s]=n}for(var r=0,i=arguments.length;r<i;r++)K(arguments[r],e);return t}function Jr(t,e,r){return K(e,function(n,s){r&&typeof n=="function"?t[s]=Nr(n,r):t[s]=n}),t}function Vr(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}ve.exports={isArray:V,isArrayBuffer:pe,isBuffer:Ir,isFormData:Mr,isArrayBufferView:Br,isString:kr,isNumber:Lr,isObject:me,isPlainObject:I,isUndefined:_,isDate:Ur,isFile:Dr,isBlob:jr,isFunction:ye,isStream:Fr,isURLSearchParams:Hr,isStandardBrowserEnv:_r,forEach:K,merge:J,extend:Jr,trim:Gr,stripBOM:Vr}});var W=l((xt,we)=>{"use strict";var R=p();function Se(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}we.exports=function(e,r,i){if(!r)return e;var n;if(i)n=i(r);else if(R.isURLSearchParams(r))n=r.toString();else{var s=[];R.forEach(r,function(c,h){c===null||typeof c>"u"||(R.isArray(c)?h=h+"[]":c=[c],R.forEach(c,function(f){R.isDate(f)?f=f.toISOString():R.isObject(f)&&(f=JSON.stringify(f)),s.push(Se(h)+"="+Se(f))}))}),n=s.join("&")}if(n){var u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e}});var Te=l((qt,be)=>{"use strict";var Kr=p();function M(){this.handlers=[]}M.prototype.use=function(e,r,i){return this.handlers.push({fulfilled:e,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1};M.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};M.prototype.forEach=function(e){Kr.forEach(this.handlers,function(i){i!==null&&e(i)})};be.exports=M});var Ae=l((Ct,Ee)=>{"use strict";var Wr=p();Ee.exports=function(e,r){Wr.forEach(e,function(n,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=n,delete e[s])})}});var $=l((Pt,ge)=>{"use strict";ge.exports=function(e,r,i,n,s){return e.config=r,i&&(e.code=i),e.request=n,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var z=l((Nt,Oe)=>{"use strict";var $r=$();Oe.exports=function(e,r,i,n,s){var u=new Error(e);return $r(u,r,i,n,s)}});var xe=l((It,Re)=>{"use strict";var zr=z();Re.exports=function(e,r,i){var n=i.config.validateStatus;!i.status||!n||n(i.status)?e(i):r(zr("Request failed with status code "+i.status,i.config,null,i.request,i))}});var Ce=l((Mt,qe)=>{"use strict";var B=p();qe.exports=B.isStandardBrowserEnv()?function(){return{write:function(r,i,n,s,u,o){var c=[];c.push(r+"="+encodeURIComponent(i)),B.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),B.isString(s)&&c.push("path="+s),B.isString(u)&&c.push("domain="+u),o===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var i=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var Ne=l((Bt,Pe)=>{"use strict";Pe.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}});var Me=l((kt,Ie)=>{"use strict";Ie.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var ke=l((Lt,Be)=>{"use strict";var Yr=Ne(),Zr=Me();Be.exports=function(e,r){return e&&!Yr(r)?Zr(e,r):r}});var Ue=l((Ut,Le)=>{"use strict";var Y=p(),Xr=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];Le.exports=function(e){var r={},i,n,s;return e&&Y.forEach(e.split(`
`),function(o){if(s=o.indexOf(":"),i=Y.trim(o.substr(0,s)).toLowerCase(),n=Y.trim(o.substr(s+1)),i){if(r[i]&&Xr.indexOf(i)>=0)return;i==="set-cookie"?r[i]=(r[i]?r[i]:[]).concat([n]):r[i]=r[i]?r[i]+", "+n:n}}),r}});var Fe=l((Dt,je)=>{"use strict";var De=p();je.exports=De.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),i;function n(s){var u=s;return e&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return i=n(window.location.href),function(u){var o=De.isString(u)?n(u):u;return o.protocol===i.protocol&&o.host===i.host}}():function(){return function(){return!0}}()});var C=l((jt,He)=>{"use strict";function Z(t){this.message=t}Z.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Z.prototype.__CANCEL__=!0;He.exports=Z});var Q=l((Ft,Ge)=>{"use strict";var k=p(),Qr=xe(),et=Ce(),rt=W(),tt=ke(),nt=Ue(),it=Fe(),X=z(),st=P(),at=C();Ge.exports=function(e){return new Promise(function(i,n){var s=e.data,u=e.headers,o=e.responseType,c;function h(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}k.isFormData(s)&&delete u["Content-Type"];var a=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",b=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";u.Authorization="Basic "+btoa(f+":"+b)}var m=tt(e.baseURL,e.url);a.open(e.method.toUpperCase(),rt(m,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function ue(){if(!!a){var w="getAllResponseHeaders"in a?nt(a.getAllResponseHeaders()):null,O=!o||o==="text"||o==="json"?a.responseText:a.response,g={data:O,status:a.status,statusText:a.statusText,headers:w,config:e,request:a};Qr(function(F){i(F),h()},function(F){n(F),h()},g),a=null}}if("onloadend"in a?a.onloadend=ue:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(ue)},a.onabort=function(){!a||(n(X("Request aborted",e,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(X("Network Error",e,null,a)),a=null},a.ontimeout=function(){var O=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",g=e.transitional||st.transitional;e.timeoutErrorMessage&&(O=e.timeoutErrorMessage),n(X(O,e,g.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",a)),a=null},k.isStandardBrowserEnv()){var ce=(e.withCredentials||it(m))&&e.xsrfCookieName?et.read(e.xsrfCookieName):void 0;ce&&(u[e.xsrfHeaderName]=ce)}"setRequestHeader"in a&&k.forEach(u,function(O,g){typeof s>"u"&&g.toLowerCase()==="content-type"?delete u[g]:a.setRequestHeader(g,O)}),k.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),o&&o!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(c=function(w){!a||(n(!w||w&&w.type?new at("canceled"):w),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),s||(s=null),a.send(s)})}});var P=l((Ht,Ve)=>{"use strict";var d=p(),_e=Ae(),ot=$(),ut={"Content-Type":"application/x-www-form-urlencoded"};function Je(t,e){!d.isUndefined(t)&&d.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function ct(){var t;return typeof XMLHttpRequest<"u"?t=Q():typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Q()),t}function lt(t,e,r){if(d.isString(t))try{return(e||JSON.parse)(t),d.trim(t)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(t)}var L={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:ct(),transformRequest:[function(e,r){return _e(r,"Accept"),_e(r,"Content-Type"),d.isFormData(e)||d.isArrayBuffer(e)||d.isBuffer(e)||d.isStream(e)||d.isFile(e)||d.isBlob(e)?e:d.isArrayBufferView(e)?e.buffer:d.isURLSearchParams(e)?(Je(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):d.isObject(e)||r&&r["Content-Type"]==="application/json"?(Je(r,"application/json"),lt(e)):e}],transformResponse:[function(e){var r=this.transitional||L.transitional,i=r&&r.silentJSONParsing,n=r&&r.forcedJSONParsing,s=!i&&this.responseType==="json";if(s||n&&d.isString(e)&&e.length)try{return JSON.parse(e)}catch(u){if(s)throw u.name==="SyntaxError"?ot(u,this,"E_JSON_PARSE"):u}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};d.forEach(["delete","get","head"],function(e){L.headers[e]={}});d.forEach(["post","put","patch"],function(e){L.headers[e]=d.merge(ut)});Ve.exports=L});var We=l((Gt,Ke)=>{"use strict";var ft=p(),ht=P();Ke.exports=function(e,r,i){var n=this||ht;return ft.forEach(i,function(u){e=u.call(n,e,r)}),e}});var ee=l((_t,$e)=>{"use strict";$e.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ze=l((Jt,Ye)=>{"use strict";var ze=p(),re=We(),dt=ee(),pt=P(),mt=C();function te(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new mt("canceled")}Ye.exports=function(e){te(e),e.headers=e.headers||{},e.data=re.call(e,e.data,e.headers,e.transformRequest),e.headers=ze.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ze.forEach(["delete","get","head","post","put","patch","common"],function(n){delete e.headers[n]});var r=e.adapter||pt.adapter;return r(e).then(function(n){return te(e),n.data=re.call(e,n.data,n.headers,e.transformResponse),n},function(n){return dt(n)||(te(e),n&&n.response&&(n.response.data=re.call(e,n.response.data,n.response.headers,e.transformResponse))),Promise.reject(n)})}});var ne=l((Vt,Xe)=>{"use strict";var v=p();Xe.exports=function(e,r){r=r||{};var i={};function n(a,f){return v.isPlainObject(a)&&v.isPlainObject(f)?v.merge(a,f):v.isPlainObject(f)?v.merge({},f):v.isArray(f)?f.slice():f}function s(a){if(v.isUndefined(r[a])){if(!v.isUndefined(e[a]))return n(void 0,e[a])}else return n(e[a],r[a])}function u(a){if(!v.isUndefined(r[a]))return n(void 0,r[a])}function o(a){if(v.isUndefined(r[a])){if(!v.isUndefined(e[a]))return n(void 0,e[a])}else return n(void 0,r[a])}function c(a){if(a in r)return n(e[a],r[a]);if(a in e)return n(void 0,e[a])}var h={url:u,method:u,data:u,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c};return v.forEach(Object.keys(e).concat(Object.keys(r)),function(f){var b=h[f]||s,m=b(f);v.isUndefined(m)&&b!==c||(i[f]=m)}),i}});var ie=l((Kt,Qe)=>{Qe.exports={version:"0.25.0"}});var tr=l((Wt,rr)=>{"use strict";var yt=ie().version,se={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){se[t]=function(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}});var er={};se.transitional=function(e,r,i){function n(s,u){return"[Axios v"+yt+"] Transitional option '"+s+"'"+u+(i?". "+i:"")}return function(s,u,o){if(e===!1)throw new Error(n(u," has been removed"+(r?" in "+r:"")));return r&&!er[u]&&(er[u]=!0,console.warn(n(u," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,u,o):!0}};function vt(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var i=Object.keys(t),n=i.length;n-- >0;){var s=i[n],u=e[s];if(u){var o=t[s],c=o===void 0||u(o,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}rr.exports={assertOptions:vt,validators:se}});var ur=l(($t,or)=>{"use strict";var sr=p(),St=W(),nr=Te(),ir=Ze(),U=ne(),ar=tr(),x=ar.validators;function N(t){this.defaults=t,this.interceptors={request:new nr,response:new nr}}N.prototype.request=function(e,r){if(typeof e=="string"?(r=r||{},r.url=e):r=e||{},!r.url)throw new Error("Provided config url is not valid");r=U(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var i=r.transitional;i!==void 0&&ar.assertOptions(i,{silentJSONParsing:x.transitional(x.boolean),forcedJSONParsing:x.transitional(x.boolean),clarifyTimeoutError:x.transitional(x.boolean)},!1);var n=[],s=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(r)===!1||(s=s&&m.synchronous,n.unshift(m.fulfilled,m.rejected))});var u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});var o;if(!s){var c=[ir,void 0];for(Array.prototype.unshift.apply(c,n),c=c.concat(u),o=Promise.resolve(r);c.length;)o=o.then(c.shift(),c.shift());return o}for(var h=r;n.length;){var a=n.shift(),f=n.shift();try{h=a(h)}catch(b){f(b);break}}try{o=ir(h)}catch(b){return Promise.reject(b)}for(;u.length;)o=o.then(u.shift(),u.shift());return o};N.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=U(this.defaults,e),St(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};sr.forEach(["delete","get","head","options"],function(e){N.prototype[e]=function(r,i){return this.request(U(i||{},{method:e,url:r,data:(i||{}).data}))}});sr.forEach(["post","put","patch"],function(e){N.prototype[e]=function(r,i,n){return this.request(U(n||{},{method:e,url:r,data:i}))}});or.exports=N});var lr=l((zt,cr)=>{"use strict";var wt=C();function q(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(n){e=n});var r=this;this.promise.then(function(i){if(!!r._listeners){var n,s=r._listeners.length;for(n=0;n<s;n++)r._listeners[n](i);r._listeners=null}}),this.promise.then=function(i){var n,s=new Promise(function(u){r.subscribe(u),n=u}).then(i);return s.cancel=function(){r.unsubscribe(n)},s},t(function(n){r.reason||(r.reason=new wt(n),e(r.reason))})}q.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};q.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};q.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};q.source=function(){var e,r=new q(function(n){e=n});return{token:r,cancel:e}};cr.exports=q});var hr=l((Yt,fr)=>{"use strict";fr.exports=function(e){return function(i){return e.apply(null,i)}}});var pr=l((Zt,dr)=>{"use strict";var bt=p();dr.exports=function(e){return bt.isObject(e)&&e.isAxiosError===!0}});var vr=l((Xt,ae)=>{"use strict";var mr=p(),Tt=G(),D=ur(),Et=ne(),At=P();function yr(t){var e=new D(t),r=Tt(D.prototype.request,e);return mr.extend(r,D.prototype,e),mr.extend(r,e),r.create=function(n){return yr(Et(t,n))},r}var E=yr(At);E.Axios=D;E.Cancel=C();E.CancelToken=lr();E.isCancel=ee();E.VERSION=ie().version;E.all=function(e){return Promise.all(e)};E.spread=hr();E.isAxiosError=pr();ae.exports=E;ae.exports.default=E});var wr=l((Qt,Sr)=>{Sr.exports=vr()});var oe=Pr(wr()),j=class{constructor(){this.options={};this.defaultOptions={limit:1,country:"US",language:"en",attribute:null,entity:null,timeout:2e3};this.searchAlbum=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{entity:"album"}),"searchAlbum")});this.searchSong=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{media:"music"}),"searchSong")});this.searchArtist=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{entity:"allArtist",attribute:"allArtistTerm"}),"searchArtist")});this.searchApp=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{entity:"software"}),"searchApp")});this.searchMovie=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{entity:"movie"}),"searchMovie")});this.searchMusicVideo=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{media:"musicVideo"}),"searchMusicVideo")});this.searchBook=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{entity:"ebook"}),"searchBook")});this.searchAudiobook=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{entity:"audiobook"}),"searchAudiobook")});this.searchPodcast=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,T(y({},r),{entity:"podcast"}),"searchPodcast")});this.searchAll=(e,r)=>S(this,null,function*(){return yield this.performSearch(e,y({},r),"searchAll")});this.performSearch=(e,r,i)=>S(this,null,function*(){let n=this.validate(e,r,i);try{let s=oe.default.create({baseURL:"https://itunes.apple.com",timeout:n.timeout});n.timeout&&delete n.timeout;let u=new URLSearchParams(n),o=`/search?term=${encodeURI(e)}&${u.toString()}`,{data:c}=yield s.get(o);return c}catch(s){if(oe.default.isAxiosError(s))throw s.code?new Error(`Error: ${s.code}. Reference: https://www.ibm.com/docs/en/zos/2.2.0?topic=codes-sockets-return-errnos`):new Error("Network Disconnected")}})}validate(e,r,i){let n=Object.fromEntries(Object.entries(y(y({},this.defaultOptions),r)).filter(([h,a])=>a!==null)),s=new RegExp(/^(AD|AE|AF|AG|AI|AL|AM|AO|AQ|AR|AS|AT|AU|AW|AX|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BJ|BL|BM|BN|BO|BQ|BR|BS|BT|BV|BW|BY|BZ|CA|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|CR|CU|CV|CW|CX|CY|CZ|DE|DJ|DK|DM|DO|DZ|EC|EE|EG|EH|ER|ES|ET|FI|FJ|FK|FM|FO|FR|GA|GB|GD|GE|GF|GG|GH|GI|GL|GM|GN|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|HU|ID|IE|IL|IM|IN|IO|IQ|IR|IS|IT|JE|JM|JO|JP|KE|KG|KH|KI|KM|KN|KP|KR|KW|KY|KZ|LA|LB|LC|LI|LK|LR|LS|LT|LU|LV|LY|MA|MC|MD|ME|MF|MG|MH|MK|ML|MM|MN|MO|MP|MQ|MR|MS|MT|MU|MV|MW|MX|MY|MZ|NA|NC|NE|NF|NG|NI|NL|NO|NP|NR|NU|NZ|OM|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PS|PT|PW|PY|QA|RE|RO|RS|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|SS|ST|SV|SX|SY|SZ|TC|TD|TF|TG|TH|TJ|TK|TL|TM|TN|TO|TR|TT|TV|TW|TZ|UA|UG|UM|US|UY|UZ|VA|VC|VE|VG|VI|VN|VU|WF|WS|YE|YT|ZA|ZM|ZW)$/,"g"),u=new RegExp(/^(ab|aa|af|ak|sq|am|ar|an|hy|as|av|ae|ay|az|bm|ba|eu|be|bn|bi|bs|br|bg|my|ca|ch|ce|ny|zh|cv|kw|co|cr|hr|cs|da|dv|nl|dz|en|eo|et|ee|fo|fj|fi|fr|ff|gl|ka|de|el|gn|gu|ht|ha|he|hz|hi|ho|hu|ia|id|ie|ga|ig|ik|io|is|it|iu|ja|jv|kl|kn|kr|ks|kk|km|ki|rw|ky|kv|kg|ko|ku|kj|la|lb|lg|li|ln|lo|lt|lu|lv|gv|mk|mg|ms|ml|mt|mi|mr|mh|mn|na|nv|nd|ne|ng|nb|nn|no|ii|nr|oc|oj|cu|om|or|os|pa|pi|fa|pl|ps|pt|qu|rm|rn|ro|ru|sa|sc|sd|se|sm|sg|sr|gd|sn|si|sk|sl|so|st|es|su|sw|ss|sv|ta|te|tg|th|ti|bo|tk|tl|tn|to|tr|ts|tt|tw|ty|ug|uk|ur|uz|ve|vi|vo|wa|cy|wo|fy|xh|yi|yo|za|zu)$/,"g"),o=["album","allArtist","allTrack","audiobook","audiobookAuthor","ebook","iPadSoftware","macSoftware","mix","movie","movieArtist","musicArtist","musicTrack","musicVideo","podcast","podcastAuthor","shortFilm","shortFilmArtist","software","song","tvEpisode","tvSeason"],c=["actorTerm","albumTerm","allArtistTerm","allTrackTerm","artistTerm","authorTerm","composerTerm","descriptionTerm","directorTerm","featureFilmTerm","genreIndex","keywordsTerm","languageTerm","mixTerm","movieArtistTerm","movieTerm","producerTerm","ratingIndex","ratingTerm","releaseYearTerm","shortFilmTerm","showTerm","softwareDeveloper","songTerm","titleTerm","tvEpisodeTerm","tvSeasonTerm"];if(i==="searchAll"){if(n.entity&&!o.includes(n.entity))throw new TypeError(`The entity with value ${JSON.stringify(n.entity)} is not valid. Expected one of the following list ${JSON.stringify(o)}`);if(n.attribute&&!c.includes(n.attribute))throw new TypeError(`The attribute with value ${JSON.stringify(n.attribute)} is not valid. Expected one of the following list ${JSON.stringify(c)}`);if(!n.entity||!n.attribute)throw new TypeError('searchAll expects to have both "entity" and "attribute" values in the options object')}if(typeof e!="string"||!e.trim().length)throw new TypeError('A "term" is a string required on any search. "term" cannot have empty spaces as well.');if(!Number.isInteger(n.limit))throw new TypeError(`Optional argument "limit" must be a number. Passed ${typeof n.limit}(${n.limit})`);if(!s.test(n.country))throw new TypeError(`Optional argument "country" must be a string and should be a valid ISO 3166-1 Alpha 2 country code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Passed ${typeof n.country}( ${JSON.stringify(n.country)} )`);if(!u.test(n.language))throw new TypeError(`Optional argument "language" must be a string and should be a valid ISO 639-1 language code (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). Passed ${typeof n.language}( ${JSON.stringify(n.language)} )`);return n}};var br=new j,{searchAlbum:tn,searchArtist:nn,searchAll:sn,searchApp:an,searchAudiobook:on,searchBook:un,searchMovie:cn,searchMusicVideo:ln,searchPodcast:fn,searchSong:hn}=br,dn=br;})();