import{Nt as e}from"./profile-DkxWhVLn.js";var t=null;function n(e){t=e}function r(e){if(!e)return`local:`;let t=e.remoteKind===`ssh`?e.remoteIdentity||e.remoteHost||``:e.baseUrl||``;return`${e.mode||`local`}:${e.remoteKind||``}:${e.profile||``}:${t}`}function i(t=e.get()){return r(t)}function a(){return e.get()?.mode===`remote`}function o(){return e.get()?.profile||void 0}function s(e,t){return`/api/fs/${e}?path=${encodeURIComponent(t)}`}function c(){let e=window.hermesDesktop;if(!e)throw Error(`Hermes Desktop bridge is unavailable`);return e}function l(e,t){return c().api(t?{body:t,method:`POST`,path:e,profile:o()}:{path:e,profile:o()})}async function u(e){return a()?l(s(`list`,e)):c().readDir(e)}async function d(e){return a()?l(s(`read-text`,e)):c().readFileText(e)}async function f(e,t){let n=c();if(!a()){if(!n.writeTextFile)throw Error(`Saving is not available`);return n.writeTextFile(e,t)}return{path:(await l(`/api/fs/write-text`,{content:t,path:e})).path||e}}async function p(e){if(!a())return c().readFileDataUrl(e);let t=await l(s(`read-data-url`,e));return typeof t==`string`?t:t.dataUrl||``}async function m(e){try{let t=await window.hermesDesktop?.readFileDataUrl?.(e);if(t)return t}catch(e){if(!a())throw e}return p(e)}async function h(e){let t=c();return a()?(await l(s(`git-root`,e))).root:t.gitRoot?t.gitRoot(e):null}async function g(){return a()?l(`/api/fs/default-cwd`):null}async function _(e){await c().revealPath?.(e)}async function v(e,t){let n=c();if(!n.renamePath)throw Error(`Rename is not available`);return(await n.renamePath(e,t)).path}async function y(e){let t=c();if(!t.trashPath)throw Error(`Delete is not available`);await t.trashPath(e)}async function b(e){await c().writeClipboard(e)}async function x(e,t){if(a())return(await l(`/api/git/file-diff?path=${encodeURIComponent(e)}&file=${encodeURIComponent(t)}`)).diff||``;let n=c().git;return n?.fileDiff?n.fileDiff(e,t):``}async function S(e){let n=c(),r=o(),i=r?{...e,profile:r}:e;return!a()||!e?.directories?n.selectPaths(i):t?t.selectPaths({...e,multiple:!1}):[]}export{f as _,o as a,u as c,d,v as f,y as g,n as h,i,p as l,S as m,g as n,h as o,_ as p,x as r,a as s,b as t,m as u};