1import{a as k}from"./chunk-RIRGXRXY.js";import{a as U,b as y,c as S}from"./chunk-SKH2MXBC.js";import{B as c,D as m,y as H,z as h}from"./chunk-BQLJE42W.js";import{B as l,O as v,R as u,V as $,_ as d,k as b,p as w}from"./chunk-YE3BF7DR.js";var T=class f{constructor(t,r,i,s,o){this.http=t;this.settingService=r;this.helperService=i;this.httpClient=s;this.httpClient=new m(o)}progressFile=[];apiUrl="/api/v1/uploadfiles/";m2mToken=null;tokenExpiration=0;getM2MToken(){let t=Date.now();if(this.m2mToken&&this.tokenExpiration>t)return b(this.m2mToken);let{tokenEndpoint:r,client_id:i,client_secret:s,grant_type:o,scope:e}=y.m2mAuth,n=btoa(`${i}:${s}`),g=new h({"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${n}`}),a=new URLSearchParams;return a.set("grant_type",o),a.set("scope",e),this.httpClient.post(r,a.toString(),{headers:g}).pipe(u(p=>{this.m2mToken=p.access_token,this.tokenExpiration=t+(p.expires_in-60)*1e3}),v(p=>b(p.access_token)),l(p=>{throw p}))}getHeaders(t){return new h({"X-External-Authorization":`Bearer ${t}`})}buildPqrsUrl(t){let r=y.PqrsMCD;return r&&r.length?`${r}${t}`:t}crop(t,r){r.width=Math.round(r.width),r.height=Math.round(r.height);let i=`/api/v1/uploadfiles/${t}/crop`;return this.http.post(i,r)}getCodeYoutube(t){if(!t)return!1;try{let r=/^(?:https?:)?\/\//i.test(t.trim())?t.trim().replace(/^\/\//,"https://"):`https://${t.trim()}`,i=new URL(r),s=i.hostname.toLowerCase(),o=i.pathname.split("/").filter(Boolean),e=null;if(s==="youtu.be"||s==="www.youtu.be")e=o[0]??null;else if(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"].includes(s)){let n=o[0]?.toLowerCase();n==="watch"?e=i.searchParams.get("v"):["embed","shorts","live","v"].includes(n)?e=o[1]??null:n==="u"&&(e=o[2]??null)}return e&&/^[A-Za-z0-9_-]{11}$/.test(e)?e:!1}catch{return!1}}getPreviewYoutube(t){return`//i.ytimg.com/vi/${t}/hqdefault.jpg`}upload(t,r,i){let s=new FormData;s.append("file",t);let o=`${this.apiUrl}${r||""}`;return this.http.post(o,s,{headers:new h().set("Content-Type","undefined"),observe:"events",reportProgress:!0,responseType:"json"}).pipe(u(e=>{if(e.type===c.UploadProgress&&e.total){let n=Math.ceil(e.loaded/e.total*100);i&&i(n)}}),l(e=>{throw console.error("Upload failed",e),e}))}uploadFilePqr(t,r,i,s){return this.getM2MToken().pipe(v(o=>{let e=this.getHeaders(o),n=new FormData;n.append("file",t);let g=`${this.apiUrl}${r||""}`;return this.http.post(s?this.buildPqrsUrl(g):g,n,{headers:e,observe:"events",reportProgress:!0,responseType:"json"}).pipe(u(a=>{if(a.type===c.UploadProgress&&a.total){let p=Math.ceil(a.loaded/a.total*100);i&&i(p)}}),l(a=>{throw console.error("Upload failed",a),a}))}))}getSuper(t){let r=`${this.apiUrl}${t}`;return this.http.get(r,{headers:{include:"0"}})}deleteSuper(t){let r=`${this.apiUrl}${t}`;return this.http.del(r,{headers:{include:"0"}})}uploadSuper(t,r,i){let s=new FormData;s.append("file",t);let o=`${this.settingService.globalApiUrl}/api/v1/uploadfiles/`;return this.http.post(o,s,{headers:new h().set("Content-Type","undefined"),observe:"events",reportProgress:!0,responseType:"json",timeout:108e5}).pipe(u(e=>{if(e.type===c.UploadProgress&&e.total){let n=Math.ceil(e.loaded/e.total*100);i&&i(n)}}),l(e=>{throw console.error("Upload failed",e),e}))}uploadFileMessage(t,r,i){let s=new FormData;s.append("file",t);let o=`${this.settingService.globalApiUrl}/api/v1/uploadfiles/${r||""}`;return this.http.post(o,s,{headers:new h().set("Content-Type","undefined"),observe:"events",reportProgress:!0,responseType:"json"}).pipe(u(e=>{if(e.type===c.UploadProgress&&e.total){let n=Math.ceil(e.loaded/e.total*100);i&&i(n)}}),l(e=>{throw console.error("Upload failed",e),e}))}downloadFile(t,r={},i){return this.http.getTextResponse("/api/v1/downloadtoken").pipe(w(s=>{let o=Object.keys(r).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(r[e])}`).join("&");return o=o?`?${o}&token=${s}`:`?token=${s}`,i?t+o:this.settingService.settings.authorityDomain+t+o}))}getUrlPreview(t){return this.http.get("/api/v1/pagepreviews/",{params:{url:t}})}getImgFile(t){let r=`${this.apiUrl}/gallery-images/${t}`;return this.http.get(r)}static \u0275fac=function(r){return new(r||f)(d(U),d(S),d(k),d(m),d(H))};static \u0275prov=$({token:f,factory:f.\u0275fac,providedIn:"root"})};export{T as a};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.