text: window.videoPressUploadTrack=function(e,o,n,t,a){return new Promise((function(i,d){wp.media.ajax("videopress-get-upload-token",{async:!0,data:{filename:a.name}}).done((function(r){var p={},s={},c=new FormData;p.Authorization='X_UPLOAD_TOKEN token="'+r.upload_token+'" blog_id="'+r.upload_blog_id+'"',s.headers=p,s.method="POST",s.url="https://public-api.wordpress.com/rest/v1.1/videos/"+e+"/tracks",s.credentials="omit",c.append("kind",o),c.append("srclang",n),c.append("label",t),c.append("vtt",a),s.body=c,wp.apiFetch(s).then((function(e){i(e)})).catch((function(e){d(e)}))}))}))},window.videoPressDeleteTrack=function(e,o,n){return new Promise((function(t,a){wp.media.ajax("videopress-get-upload-token",{async:!0}).done((function(i){var d={},r={},p=new FormData;d.Authorization='X_UPLOAD_TOKEN token="'+i.upload_token+'" blog_id="'+i.upload_blog_id+'"',r.headers=d,r.method="POST",r.url="https://public-api.wordpress.com/rest/v1.1/videos/"+e+"/tracks/delete",r.credentials="omit",p.append("kind",o),p.append("srclang",n),r.body=p,wp.apiFetch(r).then((function(e){t(e)})).catch((function(e){a(e)}))}))}))},wp.apiFetch.use((function(e,o){var n=e.path,t=e.method,a=e.body,i=a?a.get("file"):null;if(!n||-1===n.indexOf("/wp/v2/media"))return o(e);if(!t||"post"!==t.toLowerCase())return o(e);if(!i||0!==i.type.indexOf("video/"))return o(e);wp.media.ajax("videopress-get-upload-token",{async:!1,data:{filename:i.name}}).done((function(o){var n=e.headers||{};n.Authorization='X_UPLOAD_TOKEN token="'+o.upload_token+'" blog_id="'+o.upload_blog_id+'"',e.headers=n,delete e.path,e.url=o.upload_action_url,e.credentials="omit",a.set("media[]",i),a.delete("file"),e.body=a}));var d=o(e);return new Promise((function(e,o){d.then((function(e){return e instanceof Response&&e.ok?e.json():e})).then((function(o){var n=lodash.get(o,"media[0]"),t=lodash.get(n,"ID"),a=wp.apiFetch({path:"/wp/v2/media/"+t});e(a)})).catch((function(e){"errors"in e&&"object"==typeof e.errors&&e.errors.length>0&&(e=e.errors.shift()),o(e)}))}))}));