import{c as i,a as y,i as g,b as d}from"./createLucideIcon-DH2lOosf.js";import{S as b,N as v}from"./Navbar-BWwFA23w.js";import{P as k,a as B,_ as M}from"./Checkbox-B4sFSlSx.js";import{a as c}from"./fetch_utils-DQISAahE.js";import{S as u}from"./sunshine_version-DVtzCFi7.js";import{T as F,S,C}from"./trash-2-LBRRU8Ct.js";import{S as _}from"./save-C7DQtVMP.js";import{R as $}from"./rotate-ccw-CpbmRvDV.js";import{F as x}from"./file-text-DAmcqA6b.js";import"./Notification-CS5WPe7L.js";/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const P=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],T=i("arrow-down",P);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const N=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],A=i("arrow-right",N);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const E=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],L=i("arrow-up-down",E);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const j=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],I=i("arrow-up",j);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const z=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],V=i("folder-open",z);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const O=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]],q=i("folder-up",O);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],H=i("folder",D);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const U=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],Q=i("hard-drive",U);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const J=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 .83.18 2 2 0 0 0 .83-.18l8.58-3.9a1 1 0 0 0 0-1.831z",key:"zzgyd3"}],["path",{d:"M16 17h6",key:"1ook5g"}],["path",{d:"M19 14v6",key:"1ckrd5"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 .825.178",key:"1ia9y3"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l2.116-.962",key:"jksky3"}]],R=i("layers-plus",J);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const G=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Z=i("square-pen",G);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const W=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],X=i("terminal",W);/**
 * @license @lucide/vue v1.17.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const K=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Y=i("x",K),ee=y({components:{Navbar:v,Checkbox:M,ArrowDown:T,ArrowRight:A,ArrowUp:I,ArrowUpDown:L,Check:C,Edit:Z,FileText:x,Folder:H,FolderOpen:V,FolderUp:q,HardDrive:Q,LayersPlus:R,Play:B,Plus:k,RotateCcw:$,Save:_,Search:S,Shield:b,Terminal:X,Trash2:F,X:Y},data(){return{apps:[],editForm:null,detachedCmd:"",coverSearching:!1,coverFinderBusy:!1,coverCandidates:[],coverSearchQuery:"",platform:"",fileBrowserType:"any",fileBrowserTitle:"",fileBrowserCallback:null,fileBrowserCurrentPath:"",fileBrowserParentPath:"",fileBrowserEntries:[],fileBrowserLoading:!1,fileBrowserError:"",fileBrowserSelectedPath:"",fileBrowserTypedPath:"",searchQuery:"",sortMode:"default",deleteTarget:null,version:null,githubVersion:null}},computed:{installedVersionNotStable(){return!this.githubVersion||!this.version?!1:this.version.isGreater(this.githubVersion)},documentationBaseUrl(){return`https://docs.lizardbyte.dev/projects/sunshine/${this.installedVersionNotStable?"master":"latest"}`},displayedApps(){let e=this.apps.map((t,s)=>({app:t,index:s}));const r=this.searchQuery.trim().toLowerCase();return r&&(e=e.filter(({app:t})=>(t.name||"").toLowerCase().includes(r))),this.sortMode!=="default"&&e.sort((t,s)=>{const a=(t.app.name||"").localeCompare(s.app.name||"",void 0,{sensitivity:"base"});return this.sortMode==="asc"?a:-a}),e},sortModeLabel(){switch(this.sortMode){case"asc":return this.$t("apps.sort_ascending");case"desc":return this.$t("apps.sort_descending");default:return this.$t("apps.sort_default")}},appCountLabel(){const e=this.apps.length,r=this.displayedApps.length;return r===e?`${e}`:`${r} / ${e}`},editModalTitle(){if(!this.editForm)return"";const e=this.editForm.index===-1?this.$t("apps.add_new"):this.$t("apps.edit");return this.editForm.name?`${e}: ${this.editForm.name}`:e}},created(){this.loadApps(),fetch("./api/config").then(e=>e.json()).then(e=>{this.platform=e.platform,this.version=new u(null,e.version)}),fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then(e=>e.json()).then(e=>this.githubVersion=new u(e,null)).catch(e=>console.error(e))},methods:{newApp(){this.editForm={name:"",output:"",cmd:"",index:-1,"exclude-global-prep-cmd":!1,elevated:!1,"auto-detach":!0,"wait-all":!0,"exit-timeout":5,"prep-cmd":[],detached:[],"image-path":""},this.openEditModal()},editApp(e){this.editForm=JSON.parse(JSON.stringify(this.apps[e])),this.editForm.index=e,this.editForm["prep-cmd"]===void 0&&(this.editForm["prep-cmd"]=[]),this.editForm.detached===void 0&&(this.editForm.detached=[]),this.editForm["exclude-global-prep-cmd"]===void 0&&(this.editForm["exclude-global-prep-cmd"]=!1),this.editForm.elevated===void 0&&this.platform==="windows"&&(this.editForm.elevated=!1),this.editForm["auto-detach"]===void 0&&(this.editForm["auto-detach"]=!0),this.editForm["wait-all"]===void 0&&(this.editForm["wait-all"]=!0),this.editForm["exit-timeout"]===void 0&&(this.editForm["exit-timeout"]=5),this.openEditModal()},showDeleteModal(e){this.deleteTarget={index:e,name:this.apps[e].name},this.$nextTick(()=>{d.Modal.getOrCreateInstance(this.$refs.deleteModal).show()})},closeDeleteModal(){const e=d.Modal.getInstance(this.$refs.deleteModal);e&&e.hide()},loadApps(){return fetch("./api/apps").then(e=>e.json()).then(e=>{this.apps=e.apps})},confirmDelete(){c("./api/apps/"+this.deleteTarget.index,{method:"DELETE",headers:{"Content-Type":"application/json"}}).then(e=>{e.status===200&&document.location.reload()})},addPrepCmd(){let e={do:"",undo:""};this.platform==="windows"&&(e={...e,elevated:!1}),this.editForm["prep-cmd"].push(e)},deletePrepCmd(e){this.editForm["prep-cmd"].splice(e,1)},addDetached(){this.editForm.detached.push("")},showCoverFinder(){this.coverCandidates=[],this.coverSearchQuery="",this.showStacked(this.$refs.coverFinderModal),this.performCoverSearch()},performCoverSearch(){this.coverSearching=!0,this.coverCandidates=[];const e=this.coverSearchQuery.trim()||this.editForm.name.toString();function r(s){let a=s.substring(0,Math.min(s.length,2)).toLowerCase().replaceAll(/[^a-z\d]/g,"");return a||"@"}function t(s){if(!s)return Promise.resolve([]);let a=s.replaceAll(/\s+/g,".").toLowerCase(),p="https://raw.githubusercontent.com/LizardByte/GameDB/gh-pages",w=r(s);return fetch(`${p}/buckets/${w}.json`).then(function(n){if(!n.ok)throw new Error("Failed to search covers");return n.json()}).then(n=>Promise.all(Object.keys(n).map(o=>n[o].name.replaceAll(/\s+/g,".").toLowerCase().startsWith(a)?fetch(`${p}/games/${o}.json`).then(function(h){return h.json()}).catch(()=>null):null).filter(o=>o))).then(n=>n.filter(o=>o&&o.cover&&o.cover.url).map(o=>{const l=o.cover.url,h=l.lastIndexOf("."),f=l.lastIndexOf("/");if(h<0||f<0)return null;const m=l.substring(f+1,h);return{name:o.name,key:`igdb_${o.id}`,url:`https://images.igdb.com/igdb/image/upload/t_cover_big/${m}.jpg`,saveUrl:`https://images.igdb.com/igdb/image/upload/t_cover_big_2x/${m}.png`}}).filter(o=>o))}t(e).then(s=>this.coverCandidates=s).finally(()=>this.coverSearching=!1)},useCover(e){this.coverFinderBusy=!0,c("./api/covers/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e.key,url:e.saveUrl})}).then(r=>{if(!r.ok)throw new Error("Failed to download covers");return r.json()}).then(r=>{this.editForm["image-path"]=r.path;const t=this.$refs.coverFinderModal;if(t){const s=d.Modal.getInstance(t);s&&s.hide()}}).finally(()=>this.coverFinderBusy=!1)},browseFor(e,r,t,s){this.fileBrowserType=e,this.fileBrowserTitle=this.$t(r),this.fileBrowserCallback=s,this.fileBrowserSelectedPath=t||"",this.fileBrowserTypedPath=t||"",this.fileBrowserError="",this.fileBrowserNavigate(t||""),this.showStacked(this.$refs.fileBrowserModal)},fileBrowserClose(){const e=d.Modal.getInstance(this.$refs.fileBrowserModal);e&&e.hide()},fileBrowserConfirm(){const e=this.fileBrowserSelectedPath||this.fileBrowserTypedPath;e&&(this.fileBrowserCallback&&(this.fileBrowserCallback(e),this.fileBrowserCallback=null),this.fileBrowserClose())},fileBrowserNavigate(e){this.fileBrowserLoading=!0,this.fileBrowserError="";const r=new URLSearchParams({type:this.fileBrowserType});e&&r.set("path",e),fetch(`./api/browse?${r.toString()}`).then(t=>t.ok?t.json():t.json().then(s=>{throw new Error(s.error||"Browse failed")})).then(t=>{this.fileBrowserCurrentPath=t.path??"",this.fileBrowserParentPath=t.parent??"",this.fileBrowserEntries=t.entries??[],this.fileBrowserTypedPath=t.path??"",this.fileBrowserSelectedPath=this.fileBrowserType==="directory"?t.path??"":""}).catch(t=>{this.fileBrowserError=t.message}).finally(()=>{this.fileBrowserLoading=!1})},fileBrowserNavigateUp(){this.fileBrowserNavigate(this.fileBrowserParentPath)},fileBrowserSelectEntry(e){e.type==="directory"?this.fileBrowserNavigate(e.path):(this.fileBrowserSelectedPath=e.path,this.fileBrowserTypedPath=e.path)},fileBrowserActivateEntry(e){e.type==="directory"?this.fileBrowserNavigate(e.path):(this.fileBrowserSelectedPath=e.path,this.fileBrowserTypedPath=e.path,this.fileBrowserConfirm())},fileBrowserOnTypedInput(){this.fileBrowserSelectedPath=this.fileBrowserTypedPath},browsePrep(e,r){const t=this.editForm["prep-cmd"][e][r]||"";this.browseFor("executable","file_browser.select_executable",t,s=>{this.editForm["prep-cmd"][e][r]=s})},browseDetached(e){const r=this.editForm.detached[e]||"";this.browseFor("executable","file_browser.select_executable",r,t=>{this.editForm.detached[e]=t})},save(){this.editForm["image-path"]=this.editForm["image-path"].toString().replace(/"/g,""),c("./api/apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.editForm)}).then(e=>{e.status===200&&document.location.reload()})},handleImageError(e){e.target.style.display="none";const r=e.target.nextElementSibling;r&&r.classList.contains("app-poster-placeholder")&&(r.style.display="flex")},resetSearchQuery(){this.searchQuery=""},toggleSort(){this.sortMode==="default"?this.sortMode="asc":this.sortMode==="asc"?this.sortMode="desc":this.sortMode="default"},openEditModal(){this.$nextTick(()=>{d.Modal.getOrCreateInstance(this.$refs.editModal).show()})},closeEditModal(){const e=d.Modal.getInstance(this.$refs.editModal);e&&e.hide()},showStacked(e){e.addEventListener("show.bs.modal",()=>{const t=1055+(document.querySelectorAll(".modal.show").length+1)*20;e.style.zIndex=t,requestAnimationFrame(()=>{const s=document.querySelectorAll(".modal-backdrop"),a=s[s.length-1];a&&(a.style.zIndex=t-10)})},{once:!0}),d.Modal.getOrCreateInstance(e).show()}}});g(ee);
