var $t=Object.defineProperty;var _t=(t,s,e)=>s in t?$t(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var U=(t,s,e)=>(_t(t,typeof s!="symbol"?s+"":s,e),e);import{l as F,c as kt,j as St}from"./30130207-29136fc4.js";import"./43ce5d8f-58c900dd.js";import{g as vt}from"./5a058668-152615b1.js";import{d as bt}from"./36964411-cc15e919.js";import{g as Ut,W as N,i as It,K as Ct,a as Pt,A as Et}from"./8cd892b7-5775da35.js";import{a as ot}from"./vendor-vue-2ed788b2.js";import"./4e819c83-4616f5fb.js";import{a as P}from"./cf620680-730adf74.js";import"./8a5da52e-15c1d66c.js";const Ot="modulepreload",Lt=function(t,s){return t.startsWith(".")?new URL(t,s).href:t},X={},Ne=function(s,e,n){if(!e||e.length===0)return s();const o=document.getElementsByTagName("link");return Promise.all(e.map(i=>{if(i=Lt(i,n),i in X)return;X[i]=!0;const c=i.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(!!n)for(let w=o.length-1;w>=0;w--){const S=o[w];if(S.href===i&&(!c||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${i}"]${d}`))return;const p=document.createElement("link");if(p.rel=c?"stylesheet":Ot,c||(p.as="script",p.crossOrigin=""),p.href=i,document.head.appendChild(p),c)return new Promise((w,S)=>{p.addEventListener("load",w),p.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>s())},xt="utils",Dt="1.0.0",Tt="index.ts",At={lint:"eslint --ext .vue,.js,.ts ./lib && vue-tsc --noEmit"},Mt={dayjs:"^1.11.5"},Rt={"@types/crypto-js":"^4.1.3"},Nt={name:xt,version:Dt,private:!0,main:Tt,scripts:At,dependencies:Mt,devDependencies:Rt},Bt=()=>{const t={}.BK_CI_BUILD_NUM||"402";return`${Nt.version}.${t}`},jt=()=>"1.0.10",Wt=()=>"tiktok-downloader",C={version:Bt(),appVersion:jt(),appname:Wt()},rt=window.location.hostname.startsWith("www.")&&window.location.pathname.startsWith("/lab/"),Kt=()=>rt?`/lab/${window.location.pathname.split("/")[2]}`:`https://resource.media.io/${C.appname}`,Yt=Kt(),Be=t=>{const s=n=>rt?`/${["lab",t||"tiktok-downloader"].filter(i=>i).join("/")}${n}`:n;return{toPath:s,toLocationPath:n=>window.location.origin+s(n),routeBase:"/"}},je=t=>Yt+t,x={},Jt=t=>new Promise(s=>{fetch(t).then(e=>e.status!==200?"":e.text()).then(e=>{s(e)}).catch(()=>{s("")})}),Ft=async t=>{for(const s of t){const e=await Jt(s);if(e)return e}return""},We=(t,s)=>{for(const n of t){if(typeof x[n]=="string"){s(x[n]);return}if(x[n]instanceof Promise){x[n].then(o=>{s(o)});return}}const e=Ft(t);for(const n of t)x[n]=e;e.then(n=>(s(n),n))},it=()=>{let t=Date.now();return typeof performance<"u"&&typeof performance.now=="function"&&(t+=performance.now()),"fxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,s=>{const e=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s==="x"?e:e&3|8).toString(16)})},zt=()=>{let t=sessionStorage.getItem("MediaStudioSessionId");return t||(t=it(),sessionStorage.setItem("MediaStudioSessionId",t)),t},Ke=(t,s)=>{const e=Object.keys(s).filter(n=>!!s[n]).map(n=>`${n}=${s[n]}`).join("&");return`${t}?${e}`},Z=new Map,tt=(t,s,e=!1)=>new Promise((n,o)=>{var d;const i=document.querySelectorAll("script");let c=Array.from(i).filter(k=>k.src===t)[0];if(!c){c=document.createElement("script"),c.src=t,s&&(c.id=s),e&&(c.defer=!0);const k=document.getElementsByTagName("script")[0];(d=k.parentNode)==null||d.insertBefore(c,k)}Z.get(t)==="load"&&n(1),c.addEventListener("load",()=>{Z.set(t,"load"),n(1)}),c.addEventListener("error",()=>{o(new Error("load error"))})}),Gt=t=>{if(t==null)return!1;if(typeof t=="boolean")return t;if(typeof t=="number")return t!==0;if(typeof t=="string"){const s=t.trim().toLowerCase();return s!=="0"&&s!=="false"&&s!=="no"&&s!=="off"&&s!==""}return!1},Ht=t=>Gt(window.localStorage.getItem(t)),Ye=t=>{const e=decodeURIComponent(t).split("//"),n=e[1].indexOf("/");let o=e[1].substring(n);return o.includes("?")&&([o]=o.split("?")),o},qt=t=>new Promise((s,e)=>{const n=new Image;n.onload=()=>{s(n)},n.onerror=o=>{e(o)},n.crossOrigin="anonymous",n.src=t,n.complete&&s(n)}),Vt=async(t,s=3)=>{let e=!1;const n=(()=>t instanceof File?(e=!0,URL.createObjectURL(t)):t instanceof Blob?(e=!0,URL.createObjectURL(new File([t],"image.jpg"))):t)();let o=s;for(;o>0;){try{const i=await qt(n);return e&&URL.revokeObjectURL(n),i}catch{}o-=1}throw new Error("tried but no good")},et={en:"en-us",de:"de-de",fr:"fr-fr",it:"it-it",es:"es-es",zh:"zh-cn",ja:"ja-jp",jp:"ja-jp",ae:"ar-ae",ko:"ko-kr",ru:"ru-ru",nl:"nl-nl",pt:"pt-br",br:"pt-br",pl:"pl-pl",ro:"ro-ro",id:"id-id"},Qt=()=>Number("15046"),W=Qt(),z=()=>{if(typeof window.getProductIDByCookie!="function")return W;const t=window.getProductIDByCookie(window.location.host==="www.media.io"?void 0:"155");try{const s=Number(t);return s>0?s:W}catch{return W}},at=()=>{try{return z()===20034?{psource:"ppc"}:{}}catch{return{}}},Xt=t=>et[t]||et.en,R=Ut(),Zt=()=>{const t={redirect:window.location.href};return`${N}/v3/user/oauth/logout${F.stringify(t,{addQueryPrefix:!0})}`},ct=(t,s)=>({register_mode:4,product_id:z(),app_key:R.AppKey,source:R.AppSource,scope:"user normal",lang:Xt(t),response_type:"code",mode:"1",goto:s}),te="122557528937-hk3vjkcjih2rpcc8j793klpl478ro9om.apps.googleusercontent.com",Je=t=>{const s={...ct(t,void 0),redirect_uri:`${window.location.origin}/app_static/wsid3.0.html?chrome_login=1`},e=`${N}/v3/user/oauth-client/authorize${F.stringify(s,{addQueryPrefix:!0})}`;return{url:e,urlAll:e,clientId:te}},Fe=(t,s)=>{const e={env:R.AppEnv,goto:window.location.href,pbrand:R.AppName,pid:z(),...at()},n={...ct(t,s),redirect_uri:"https://www.media.io/lab/plugins/callback.html",state:btoa(JSON.stringify(e))},o=`${N}/v3/user/oauth-client/authorize${F.stringify(n,{addQueryPrefix:!0})}`;window.location.href=o},ze=()=>{window.location.href=Zt()},Ge=()=>{window.open(`${N}/web/overview`,"_blank")},He=()=>{const t="https://www.media.io/studio/#/";window.location.href=t},A="sensorsDataAnalytic201505",ee=Ht("sa-show-log"),_={get sensors(){return window[A]},list:[],push(t,s={}){this.list.length>=32||this.list.push({eventName:t,properties:s})},flush(){!this.sensors||(this.list.forEach(({eventName:t,properties:s})=>{this.sensors.track(t,s)}),this.list=[])}},$={profile:{},pageProps:{},wsid:0},y="MS_",D={pid:5903,pName:"Media.io Studio",server:"https://analytics.300624.com:8106/sa?project="},Y="mediaio",M={portrait:{test:"UA_AiPortraitGenerator_Web_test",prod:"UA_AiPortraitGenerator_Web"},anieraser:{test:"UA_AniEraser_Web_test",prod:"UA_AniEraser_Web"},[Y]:{test:"UA_MediaIo_Web_test",prod:"UA_MediaIo_Web"}},ut=t=>{const s="prod";let e=M["tiktok-downloader"]||M[Y];return t==="studio"&&(e=M[Y]),e[s]},J=ut(""),se=ut("studio"),ne=()=>({pid:It?Ct:Number(Pt?Et:"15046"),uid:0,tid:J,pver:C.version,pbrand:C.appname,penv:"production",oszone:new Date().getTimezoneOffset()/-60,plang:vt(),...at(),[`${y}session`]:zt(),[`${y}sign_status`]:!1,[`${y}pagetitle`]:decodeURIComponent(window.location.pathname),[`${y}technical_version`]:C.version,[`${y}app_version`]:C.appVersion,[`${y}Subfunction_id`]:"15046"}),oe=()=>{let t;return M["tiktok-downloader"]?t=[D.server+J,D.server+se]:t=D.server+J,t};let K=!1;const re=async()=>{if(A in window||K||(K=!0,typeof window.getProductIDByCookie!="function"&&await tt("https://dc-static.wondershare.cc/account_center/mk_channel_sdk.js",void 0,!0),await tt("https://www.media.io/staticV4/sensorsdata-1_26_6.min.js",void 0,!0),!(A in window)))return;sessionStorage.setItem("app-info",JSON.stringify(C));const t=window[A];t.init({server_url:oe(),is_track_single_page:!0,use_client_time:!0,send_type:"beacon",show_log:ee,heatmap:{clickmap:"default",scroll_notice_map:"default"}}),t.registerPage({...ne(),...$.pageProps}),$.wsid&&t.login(`${$.wsid}`),t.setProfile({[`${y}pid`]:D.pid,[`${y}p_name`]:D.pName,...$.profile}),t.quick("autoTrack"),window.sensors=t,_.flush(),K=!1},ie=t=>{if(!_.sensors){$.profile={...$.profile,...t};return}_.sensors.setProfile(t)},ae=t=>{if(!_.sensors){$.wsid=Number(t);return}t&&_.sensors.login(t)},ce=t=>{if(!_.sensors){$.pageProps={...$.pageProps,...t};return}_.sensors.registerPage({...$.pageProps,...t})},qe=t=>{ce({uid:t,[`${y}sign_status`]:t>0}),ie({[`${y}wsid`]:t}),ae(t)},ue=(t,s={})=>{if(!_.sensors){_.push(t,s),re();return}_.sensors.track(t,s)};setTimeout(()=>{ue("app_launch")},0);var dt={exports:{}};(function(t,s){(function(e,n){t.exports=n()})(kt,function(){var e,n,o=1e3,i=6e4,c=36e5,d=864e5,k=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p=31536e6,w=2592e6,S=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,E={years:p,months:w,days:d,hours:c,minutes:i,seconds:o,milliseconds:1,weeks:6048e5},T=function(l){return l instanceof Q},O=function(l,a,r){return new Q(l,r,a.$l)},L=function(l){return n.p(l)+"s"},V=function(l){return l<0},b=function(l){return V(l)?Math.ceil(l):Math.floor(l)},gt=function(l){return Math.abs(l)},I=function(l,a){return l?V(l)?{negative:!0,format:""+gt(l)+a}:{negative:!1,format:""+l+a}:{negative:!1,format:""}},Q=function(){function l(r,u,h){var f=this;if(this.$d={},this.$l=h,r===void 0&&(this.$ms=0,this.parseFromMilliseconds()),u)return O(r*E[L(u)],this);if(typeof r=="number")return this.$ms=r,this.parseFromMilliseconds(),this;if(typeof r=="object")return Object.keys(r).forEach(function(v){f.$d[L(v)]=r[v]}),this.calMilliseconds(),this;if(typeof r=="string"){var m=r.match(S);if(m){var g=m.slice(2).map(function(v){return v!=null?Number(v):0});return this.$d.years=g[0],this.$d.months=g[1],this.$d.weeks=g[2],this.$d.days=g[3],this.$d.hours=g[4],this.$d.minutes=g[5],this.$d.seconds=g[6],this.calMilliseconds(),this}}return this}var a=l.prototype;return a.calMilliseconds=function(){var r=this;this.$ms=Object.keys(this.$d).reduce(function(u,h){return u+(r.$d[h]||0)*E[h]},0)},a.parseFromMilliseconds=function(){var r=this.$ms;this.$d.years=b(r/p),r%=p,this.$d.months=b(r/w),r%=w,this.$d.days=b(r/d),r%=d,this.$d.hours=b(r/c),r%=c,this.$d.minutes=b(r/i),r%=i,this.$d.seconds=b(r/o),r%=o,this.$d.milliseconds=r},a.toISOString=function(){var r=I(this.$d.years,"Y"),u=I(this.$d.months,"M"),h=+this.$d.days||0;this.$d.weeks&&(h+=7*this.$d.weeks);var f=I(h,"D"),m=I(this.$d.hours,"H"),g=I(this.$d.minutes,"M"),v=this.$d.seconds||0;this.$d.milliseconds&&(v+=this.$d.milliseconds/1e3);var B=I(v,"S"),wt=r.negative||u.negative||f.negative||m.negative||g.negative||B.negative,yt=m.format||g.format||B.format?"T":"",j=(wt?"-":"")+"P"+r.format+u.format+f.format+yt+m.format+g.format+B.format;return j==="P"||j==="-P"?"P0D":j},a.toJSON=function(){return this.toISOString()},a.format=function(r){var u=r||"YYYY-MM-DDTHH:mm:ss",h={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return u.replace(k,function(f,m){return m||String(h[f])})},a.as=function(r){return this.$ms/E[L(r)]},a.get=function(r){var u=this.$ms,h=L(r);return h==="milliseconds"?u%=1e3:u=h==="weeks"?b(u/E[h]):this.$d[h],u===0?0:u},a.add=function(r,u,h){var f;return f=u?r*E[L(u)]:T(r)?r.$ms:O(r,this).$ms,O(this.$ms+f*(h?-1:1),this)},a.subtract=function(r,u){return this.add(r,u,!0)},a.locale=function(r){var u=this.clone();return u.$l=r,u},a.clone=function(){return O(this.$ms,this)},a.humanize=function(r){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!r)},a.milliseconds=function(){return this.get("milliseconds")},a.asMilliseconds=function(){return this.as("milliseconds")},a.seconds=function(){return this.get("seconds")},a.asSeconds=function(){return this.as("seconds")},a.minutes=function(){return this.get("minutes")},a.asMinutes=function(){return this.as("minutes")},a.hours=function(){return this.get("hours")},a.asHours=function(){return this.as("hours")},a.days=function(){return this.get("days")},a.asDays=function(){return this.as("days")},a.weeks=function(){return this.get("weeks")},a.asWeeks=function(){return this.as("weeks")},a.months=function(){return this.get("months")},a.asMonths=function(){return this.as("months")},a.years=function(){return this.get("years")},a.asYears=function(){return this.as("years")},l}();return function(l,a,r){e=r,n=r().$utils(),r.duration=function(f,m){var g=r.locale();return O(f,{$l:g},m)},r.isDuration=T;var u=a.prototype.add,h=a.prototype.subtract;a.prototype.add=function(f,m){return T(f)&&(f=f.asMilliseconds()),u.bind(this)(f,m)},a.prototype.subtract=function(f,m){return T(f)&&(f=f.asMilliseconds()),h.bind(this)(f,m)}}})})(dt);const de=dt.exports;bt.extend(de);const Ve=t=>{const s=parseInt(t,10),e=new Date(s*1e3),n=e.getFullYear(),o=e.getMonth()+1,i=e.getDate(),c=o<10?`0${o}`:o,d=i<10?`0${i}`:i;return`${n}-${c}-${d}`},Qe=t=>{const s=parseInt(t,10),e=new Date(s*1e3),n=e.getFullYear(),o=e.getMonth()+1,i=e.getDate(),c=o<10?`0${o}`:o;return`${i<10?`0${i}`:i}/${c}/${n}`},st="ASYNC_ONCE_SUCCESS",Xe=t=>{let s=!1;const e=new EventTarget;return(...o)=>new Promise((i,c)=>{if(s){e.addEventListener(st,d=>{i(d.detail)},{once:!0});return}s=!0,t(...o).then(d=>{i(d),e.dispatchEvent(new CustomEvent(st,{detail:d}))}).catch(c).finally(()=>{s=!1})})},le=t=>{const s=document.createElement("input");return s.value=t,s.style.top="0",s.style.left="0",s.style.position="fixed",document.body.appendChild(s),s.focus(),s.select(),new Promise((e,n)=>{try{const i=document.execCommand("copy")?"successful":"unsuccessful";e()}catch{n()}document.body.removeChild(s)})},Ze=t=>navigator.clipboard?navigator.clipboard.writeText(t):le(t);class fe extends Map{constructor(e){var n,o;super();U(this,"keyList",[]);U(this,"maxSize");U(this,"cleanUp");U(this,"keyEquals");this.maxSize=(n=e==null?void 0:e.maxSize)!=null?n:1/0,this.cleanUp=e==null?void 0:e.cleanUp,this.keyEquals=(o=e==null?void 0:e.keyEquals)!=null?o:(i,c)=>i===c}shouldCleanKey(e){var o;const n=(()=>{if(this.keyList.some(i=>this.keyEquals(i,e)))return this.keyList=this.keyList.filter(i=>!this.keyEquals(i,e)),this.keyList.push(e),e;if(this.keyList.push(e),this.keyList.length>this.maxSize)return this.keyList.shift()})();if(n){const i=this.get(n);this.delete(n),(o=this.cleanUp)==null||o.call(this,n,i)}}set(e,n){return this.shouldCleanKey(e),super.set(e,n),this}clear(){this.forEach((e,n)=>{var o;(o=this.cleanUp)==null||o.call(this,n,e)}),super.clear()}}const ts=async(t,s)=>{const e=await ot({method:"get",url:t,responseType:"blob"}),n=window.URL.createObjectURL(e.data),o=document.createElement("a");document.body.appendChild(o),o.style.display="none",o.href=n,o.download=s,o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(n)},he=(t,s)=>{const e=window.URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=e,n.download=s,n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(e)};(()=>{const t=new fe({maxSize:3,cleanUp:(e,n)=>{URL.revokeObjectURL(n.blobUrl)}}),s=async e=>{if(t.has(e))return t.get(e);const o=(await ot({method:"get",url:e,responseType:"blob"})).data,i=URL.createObjectURL(o),c=await Vt(i),d={blob:o,blobUrl:i,image:c};return t.set(e,d),d};return async e=>{const n=`${St}/v1/file/download?file=${e.file}&name=${encodeURIComponent(e.name)}`,{image:o,blob:i}=await s(n),c=document.createElement("canvas");c.width=e.resolution.width,c.height=e.resolution.height;const d=c.getContext("2d");d==null||d.drawImage(o,0,0,c.width,c.height);const k=await new Promise((p,w)=>{c.toBlob(S=>{S?p(S):w()},i.type)});he(k,e.name)}})();const nt={Encrypt:t=>t,Decrypt:t=>t};class lt{constructor(s){U(this,"store");U(this,"baseKey");this.store=s,this.baseKey="tiktok-downloader."}_toKey(s){return this.baseKey+s}set(s,e){if(!!s){if(typeof e>"u"||e===null){this.store.removeItem(this._toKey(s));return}typeof e!="string"&&(e=nt.Encrypt(JSON.stringify(e))),this.store.setItem(this._toKey(s),e)}}get(s){if(!s)return null;const e=this.store.getItem(this._toKey(s));if(!e)return null;try{return JSON.parse(nt.Decrypt(e))}catch{try{return JSON.parse(e)}catch{return e}}}tget(s,e){const n=this.get(s);return!e||e<0||(n==null?void 0:n.time)+e>Date.now()?n==null?void 0:n.data:null}tset(s,e){this.set(s,{data:e,time:Date.now()})}}class me extends lt{constructor(){super(sessionStorage)}}new me;class pe extends lt{constructor(){super(localStorage)}}new pe;const es=t=>t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(2)}KB`:t<1024*1024*1024?`${(t/1024/1024).toFixed(2)}MB`:`${(t/1024/1024/1024).toFixed(2)}GB`;function ge(){return`.${window.location.hostname.split(".").slice(-2).join(".")}`}function we(){return`__${window.location.hostname.split(".").slice(-2).join("")}_token`}function ye(){return`__${window.location.hostname.split(".").slice(-2).join("")}_uuid`}const $e=2,G=ge(),H=we(),_e=14,ft=ye();function ke(){["ou","email","wsid","uid"].forEach(s=>{P.remove(s,{domain:".ailab.wondershare.com"})})}function Se(){P.remove(H,{domain:G})}function ve(){return P.get(ft)||""}function be(t){P.set(ft,t,{domain:G,expires:_e})}function Ue(){return P.get(H)||""}function Ie(t){P.set(H,t,{domain:G,expires:$e})}const ht="token";function mt(t){window.localStorage.setItem(ht,t)}function pt(){window.localStorage.removeItem(ht)}const ss=()=>{const t=Ue();return t?(mt(t),t):(pt(),t)},ns=()=>{pt(),Se(),ke()},os=t=>{mt(t),Ie(t)},q="wsid-token";function rs(t){window.sessionStorage.setItem(q,t)}function is(){window.sessionStorage.removeItem(q)}function Ce(){return window.sessionStorage.getItem(q)||""}function as(){return Ce()}const cs=()=>{const t=ve();if(!t){const s=it();return be(s),s}return t};export{Ve as A,He as B,Be as C,Ze as D,ts as E,Ne as _,ue as a,cs as b,Je as c,ie as d,it as e,ss as f,as as g,ns as h,is as i,ze as j,rs as k,tt as l,qe as m,Xe as n,os as o,y as p,es as q,Ye as r,Ke as s,We as t,je as u,Qe as v,Ge as w,Fe as x,z as y,at as z};
