phirepass-widgets 0.0.63 → 0.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{t as e,p as t,H as i,c as s,h as a,a as o}from"./index.js";import{_ as r,E as d,C as n,a as l,P as c}from"./p-C4LC8KfO.js";const h=t(class extends i{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.maximizeEvent=s(this,"maximize"),this.connectionStateChanged=s(this,"connectionStateChanged")}channel;domReady=!1;runtimeReady=!1;connected=!1;uploadInputEl;deleteLoadingTimeout;msgId=1;activeUploadToken=0;pendingUploadStarts=new Map;pendingUploadAcks=new Map;pendingDownloadStarts=new Map;activeDownloads=new Map;activeDownloadMsgId;pendingDelete;session_id;name="SFTP";description="Client";hideHeader=!1;serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(e,t){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),e&&(this.open_comms(),this.channel.connect(),this.status="Connecting...")}serverId;onServerIdChange(e,t){this.onNodeIdChange(this.nodeId,this.nodeId)}maximizeEvent;async maximize(){this.max=!this.max}async minimize(){this.max=!1}connectionStateChanged;max=!1;show_login_screen=!1;show_login_screen_username=!1;show_error=!1;error_message="";show_login_screen_password=!1;show_navigation=!1;breadcrumbs=[];current_dir=".";listing=[];show_content=!1;show_loader=!1;version="";status="Disconnected";selected_item=null;show_upload_modal=!1;upload_progress=0;upload_file_name="";upload_speed="--";upload_finished=!1;show_download_modal=!1;download_progress=0;download_file_name="";download_speed="--";download_finished=!1;show_delete_modal=!1;delete_file_name="";delete_loading=!1;toggle_max(){this.maximizeEvent?.emit(!this.max)}async connectedCallback(){await r(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.clear_delete_loading_timeout(),this.close_comms()}clear_delete_loading_timeout(){void 0!==this.deleteLoadingTimeout&&(window.clearTimeout(this.deleteLoadingTimeout),this.deleteLoadingTimeout=void 0)}next_msg_id(){const e=this.msgId;return this.msgId+=1,e}clear_pending_operations(){this.pendingUploadStarts.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Upload start aborted"))})),this.pendingUploadStarts.clear(),this.pendingUploadAcks.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Upload chunk aborted"))})),this.pendingUploadAcks.clear(),this.pendingDownloadStarts.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Download start aborted"))})),this.pendingDownloadStarts.clear(),this.stop_delete_polling(),this.activeDownloads.clear()}stop_delete_polling(){void 0!==this.pendingDelete?.interval&&window.clearInterval(this.pendingDelete.interval),this.pendingDelete=void 0}cancel_active_upload(){this.activeUploadToken+=1,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--"}cancel_active_download(){void 0!==this.activeDownloadMsgId&&this.activeDownloads.delete(this.activeDownloadMsgId),this.activeDownloadMsgId=void 0,this.download_progress=0,this.download_finished=!1,this.download_speed="--"}format_duration(e){if(!Number.isFinite(e)||e<0)return"--";if(e<60)return e.toFixed(0)+"s";const t=Math.floor(e/60);return t<60?`${t}m ${Math.floor(e%60)}s`:`${Math.floor(t/60)}h ${t%60}m`}format_percent(e){return(Number.isFinite(e)?e:0).toFixed(2)+"%"}format_transfer_rate(e){return!Number.isFinite(e)||e<=0?"--":this.format_size(e)+"/s"}update_upload_progress(e,t,i){if(this.upload_progress=Math.max(0,Math.min(100,t>0?e/t*100:0)),e>=t)return this.upload_finished=!0,void(this.upload_speed="--");const s=(performance.now()-i)/1e3,a=s>0?e/s:0;this.upload_speed=this.format_transfer_rate(a);const o=a>0?(t-e)/a:NaN;this.status=`Uploading ${this.format_size(e)} / ${this.format_size(t)} (ETA ${this.format_duration(o)})`}update_download_progress(e,t,i){if(this.download_progress=Math.max(0,Math.min(100,t>0?e/t*100:0)),e>=t)return this.download_finished=!0,void(this.download_speed="--");const s=(Date.now()-i)/1e3,a=s>0?e/s:0;this.download_speed=this.format_transfer_rate(a);const o=a>0?(t-e)/a:NaN;this.status=`Downloading ${this.format_size(e)} / ${this.format_size(t)} (ETA ${this.format_duration(o)})`}connect(){this.connected=!0,this.channel.connect(),this.status="Connecting..."}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.channel&&this.connect()}create_web_socket_endpoint(){const e=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${e}://${this.serverHost}`:`${e}://${this.serverHost}:${this.serverPort}`:`${e}://${this.serverHost}`}handle_error(e){if(void 0!==e.msg_id){const t=this.pendingUploadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.reject(Error(e.message||"Upload start failed")),this.pendingUploadStarts.delete(e.msg_id));const i=this.pendingDownloadStarts.get(e.msg_id);i&&(window.clearTimeout(i.timeout),i.reject(Error(e.message||"Download start failed")),this.pendingDownloadStarts.delete(e.msg_id)),this.activeDownloads.has(e.msg_id)&&(this.activeDownloads.delete(e.msg_id),this.activeDownloadMsgId===e.msg_id&&(this.activeDownloadMsgId=void 0),this.download_finished=!1),this.pendingDelete?.msgId===e.msg_id&&(this.stop_delete_polling(),this.delete_loading=!1,this.show_delete_modal=!1,this.status="Connected")}switch(e.kind){case d.Generic:case d.Authentication:this.error_message=e.message||"An unknown error occurred.",this.show_error=!0;break;case d.RequiresUsername:this.show_login_screen_username=!0,this.show_login_screen_password=!1,this.show_login_screen=!0;break;case d.RequiresPassword:this.show_login_screen_username=!1,this.show_login_screen_password=!0,this.show_login_screen=!0;break;case d.RequiresUsernamePassword:this.show_login_screen_username=!0,this.show_login_screen_password=!0,this.show_login_screen=!0}setTimeout((()=>{this.show_loader=!1}),1e3)}handle_auth_success(e){this.clear_creds_buffer(),this.version=e.version,this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_sftp_tunnel(this.nodeId),this.status="Connected"}handle_tunnel_opened(e){this.session_id=e.sid,this.channel.send_sftp_list_data(this.nodeId,this.session_id,this.current_dir)}handle_sftp_list_items(e){setTimeout((()=>{this.show_loader=!1}),500),this.listing=e.dir.items,this.current_dir=e.path,this.breadcrumbs=e.path.split("/").map(((e,t,i)=>""===e&&0===t?{label:"/",path:"/"}:{label:e,path:i.slice(0,t+1).join("/")})),this.show_content=!0,this.show_navigation=!0,this.pendingDelete&&e.path===this.current_dir&&(e.dir.items.some((e=>"File"===e.kind&&e.name===this.pendingDelete?.filename))||(this.stop_delete_polling(),this.delete_loading=!1,this.show_delete_modal=!1,this.delete_file_name="",this.status="Connected")),console.log("Received SFTP list items:",e)}handle_upload_start_response(e){if(void 0===e.msg_id)return;const t=this.pendingUploadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.resolve(e.response.upload_id),this.pendingUploadStarts.delete(e.msg_id))}handle_upload_chunk_ack(e){const t=`${e.upload_id}_${e.chunk_index}`,i=this.pendingUploadAcks.get(t);i&&(window.clearTimeout(i.timeout),i.resolve(),this.pendingUploadAcks.delete(t))}handle_download_start_response(e){if(void 0===e.msg_id)return;const t=this.pendingDownloadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.resolve({download_id:e.response.download_id,total_size:e.response.total_size,total_chunks:e.response.total_chunks}),this.pendingDownloadStarts.delete(e.msg_id))}request_next_download_chunk(e){const t=this.activeDownloads.get(e);t&&this.session_id&&(this.channel.send_sftp_download_chunk(this.nodeId,this.session_id,t.download_id,t.nextChunkToRequest,e),t.nextChunkToRequest+=1)}finalize_download(e){const t=this.activeDownloads.get(e);if(!t)return;const i=Array.from(t.chunks.entries()).sort(((e,t)=>e[0]-t[0])).map((([,e])=>e)).map((e=>new Uint8Array(e))),s=new Blob(i,{type:"application/octet-stream"}),a=URL.createObjectURL(s),o=document.createElement("a");o.href=a,o.download=t.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),this.activeDownloads.delete(e),this.activeDownloadMsgId===e&&(this.activeDownloadMsgId=void 0),this.download_finished=!0,this.status="Connected"}handle_download_chunk(e){if(void 0===e.msg_id)return;const t=this.activeDownloads.get(e.msg_id);if(!t)return;const i=new Uint8Array(e.chunk.data);t.chunks.set(e.chunk.chunk_index,i);const s=Array.from(t.chunks.values()).reduce(((e,t)=>e+t.length),0);this.update_download_progress(s,t.total_size,t.startTime),t.chunks.size>=t.total_chunks?this.finalize_download(e.msg_id):this.request_next_download_chunk(e.msg_id)}async start_download(e){if(!this.session_id)return;this.selected_item=e,this.download_file_name=e.name,this.download_progress=0,this.download_finished=!1,this.download_speed="--",this.show_download_modal=!0,this.show_error=!1;const t=this.next_msg_id();this.activeDownloadMsgId=t,this.activeDownloads.set(t,{filename:e.name,chunks:new Map,total_chunks:0,total_size:0,download_id:0,nextChunkToRequest:0,startTime:Date.now()});const i=new Promise(((e,i)=>{const s=window.setTimeout((()=>{this.pendingDownloadStarts.delete(t),i(Error("Download start timeout"))}),1e4);this.pendingDownloadStarts.set(t,{timeout:s,resolve:e,reject:i})}));try{this.channel.send_sftp_download_start(this.nodeId,this.session_id,e.path,e.name,t);const{download_id:s,total_chunks:a,total_size:o}=await i,r=this.activeDownloads.get(t);if(!r)return;r.download_id=s,r.total_chunks=a,r.total_size=o,r.nextChunkToRequest=0,this.request_next_download_chunk(t)}catch(e){this.activeDownloads.delete(t),this.activeDownloadMsgId===t&&(this.activeDownloadMsgId=void 0),this.show_error=!0,this.error_message=e instanceof Error?e.message:"Failed to start download",this.cancel_download()}}async upload_file(e){if(!this.session_id)return;const t=this.activeUploadToken+1;this.activeUploadToken=t,this.upload_file_name=e.name,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--",this.show_upload_modal=!0,this.show_error=!1,this.status="Uploading...";const i=65536,s=Math.max(1,Math.ceil(e.size/i)),a=this.next_msg_id(),o=new Promise(((e,t)=>{const i=window.setTimeout((()=>{this.pendingUploadStarts.delete(a),t(Error("Upload start timeout"))}),1e4);this.pendingUploadStarts.set(a,{timeout:i,resolve:e,reject:t})}));try{this.channel.send_sftp_upload_start(this.nodeId,this.session_id,e.name,this.current_dir,s,BigInt(e.size),a);const r=await o;let d=0;const n=performance.now();for(let a=0;a<s;a+=1){if(t!==this.activeUploadToken)throw Error("Upload cancelled");const s=a*i,o=Math.min(s+i,e.size),l=new Uint8Array(await e.slice(s,o).arrayBuffer());await new Promise(((e,t)=>{const i=`${r}_${a}`,s=window.setTimeout((()=>{this.pendingUploadAcks.delete(i),t(Error(`Upload chunk ${a+1} timed out`))}),3e4);this.pendingUploadAcks.set(i,{timeout:s,resolve:e,reject:t}),this.channel.send_sftp_upload_chunk(this.nodeId,this.session_id,r,a,l.length,l,null)})),d+=l.length,this.update_upload_progress(d,e.size,n)}this.upload_progress=100,this.upload_finished=!0,this.status="Connected",this.refresh_directory()}catch(e){"Upload cancelled"!==e.message&&(this.show_error=!0,this.error_message=e instanceof Error?e.message:"Upload failed"),this.upload_finished=!1,this.status="Connected"}}handle_tunnel_data(e){console.log("received tunnel data:",e)}handle_tunnel_closed(e){this.clear_creds_buffer(),this.close_comms()}open_comms(){this.channel=this.serverId?new n(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new n(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([l.Connected]),this.channel.authenticate(this.token,this.nodeId),this.status="Authenticating..."})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([l.Disconnected]),this.status="Disconnected"})),this.channel.on_connection_error((e=>{this.connectionStateChanged.emit([l.Error,e]),this.status="Error "+e.message})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((e=>{const{web:t}=e.data;switch(t.type){case c.Error:this.handle_error(t);break;case c.AuthSuccess:this.handle_auth_success(t);break;case c.TunnelOpened:this.handle_tunnel_opened(t);break;case c.TunnelClosed:this.handle_tunnel_closed(t);break;case c.TunnelData:this.handle_tunnel_data(t);break;case c.SFTPListItems:this.handle_sftp_list_items(t);break;case c.SFTPUploadStartResponse:this.handle_upload_start_response(t);break;case c.SFTPUploadChunkAck:this.handle_upload_chunk_ack(t);break;case c.SFTPDownloadStartResponse:this.handle_download_start_response(t);break;case c.SFTPDownloadChunk:this.handle_download_chunk(t);break;default:console.warn("Unhandled protocol message type:",t)}}))}close_comms(){this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}clear_creds_buffer(){}reset_session_state(){this.clear_creds_buffer()}list_breadcrumb(e){this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,e)}go_to_parent_directory(){this.session_id&&"/"!==this.current_dir&&this.list_breadcrumb(this.breadcrumbs[this.breadcrumbs.length-2]?.path||"/")}refresh_directory(){this.session_id&&this.list_breadcrumb(this.current_dir)}disconnect_session(){this.close_comms(),this.session_id=void 0,this.show_loader=!1,this.show_content=!1,this.breadcrumbs=[],this.current_dir=".",this.listing=[],this.show_navigation=!1,this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_upload_modal=!1,this.show_download_modal=!1,this.show_delete_modal=!1,this.upload_progress=0,this.download_progress=0,this.upload_finished=!1,this.download_finished=!1,this.delete_loading=!1,this.delete_file_name="",this.version="",this.status="Disconnected"}on_file_row_action(e,t){t.preventDefault(),t.stopPropagation(),"File"===e.kind&&this.start_download(e)}on_file_delete_action(e,t){t.preventDefault(),t.stopPropagation(),this.selected_item=e,this.delete_file_name=e.name,this.delete_loading=!1,this.show_delete_modal=!0}cancel_delete(){this.delete_loading||(this.show_delete_modal=!1,this.delete_file_name="",this.delete_loading=!1,this.refresh_directory())}confirm_delete(){if(this.delete_loading)return;if(!this.session_id||!this.selected_item)return void(this.show_delete_modal=!1);const e=this.selected_item.name;this.delete_loading=!0,this.status="Deleting...",this.show_error=!1,this.stop_delete_polling();const t=this.next_msg_id();this.pendingDelete={filename:e,msgId:t,startedAt:Date.now()};const i=()=>{if(this.pendingDelete)return Date.now()-this.pendingDelete.startedAt>=3e4?(this.stop_delete_polling(),this.delete_loading=!1,this.show_delete_modal=!1,this.show_error=!0,this.error_message=`Delete timed out for "${e}".`,void(this.status="Connected")):void(this.session_id&&this.channel.send_sftp_list_data(this.nodeId,this.session_id,this.current_dir))};i(),this.pendingDelete.interval=window.setInterval(i,2500),this.channel.send_sftp_delete(this.nodeId,this.session_id,this.current_dir,e,t)}open_upload_picker(){this.uploadInputEl?.click()}on_upload_selected(e){const t=e.target,i=t.files?.[0];i&&(this.upload_file(i),t.value="")}cancel_upload(){this.cancel_active_upload(),this.show_upload_modal=!1,this.upload_file_name="",this.upload_speed="--",this.status="Connected",this.refresh_directory()}cancel_download(){this.cancel_active_download(),this.show_download_modal=!1,this.download_file_name="",this.download_speed="--",this.status="Connected",this.refresh_directory()}is_selected(e){return!!this.selected_item&&this.selected_item.path===e.path&&this.selected_item.name===e.name}list_directory(e){if(!this.session_id)return void console.warn("No active session. Cannot list directory.");if("File"===e.kind)return console.warn("Cannot list directory of a file. Ignoring click."),void(this.selected_item=e);const t=[e.path,e.name].join("/");t!==this.current_dir?(this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,t)):console.warn("Already in this directory. Ignoring click.")}format_size(e){if(void 0===e||Number.isNaN(e))return"-";if(e<1024)return e+" B";let t=e,i=-1;for(;t>=1024&&i<4;)t/=1024,i+=1;return`${t.toFixed(t>=10?1:2)} ${["KB","MB","GB","TB","PB"][i]}`}mode_type_to_char(e,t){switch(61440&e){case 49152:return"s";case 40960:return"l";case 32768:return"-";case 24576:return"b";case 16384:return"d";case 8192:return"c";case 4096:return"p";default:return"Folder"===t?"d":"-"}}format_permissions(e,t){if(null==e)return"-";if("string"==typeof e){const i=e.trim();return/^[bcdlps-][rwxStTs-]{9}$/.test(i)?i:/^[0-7]{3,4}$/.test(i)?this.format_permissions(parseInt(i,8),t):/^\d+$/.test(i)?this.format_permissions(parseInt(i,10),t):i||"-"}const i=e,s=this.mode_type_to_char(i,t),a=[256&i?"r":"-",128&i?"w":"-",64&i?"x":"-",32&i?"r":"-",16&i?"w":"-",8&i?"x":"-",4&i?"r":"-",2&i?"w":"-",1&i?"x":"-"];return 2048&i&&(a[2]="x"===a[2]?"s":"S"),1024&i&&(a[5]="x"===a[5]?"s":"S"),512&i&&(a[8]="x"===a[8]?"t":"T"),`${s}${a.join("")}`}render(){return a(o,{key:"4a0c122426a92a92e3a7121d8adecbefe5eaf852",class:{default:!this.max,max:this.max}},a("section",{key:"f408645cf18f728c09e7af174f5eb30b5d37ca3b",class:"listing"},!this.hideHeader&&a("header",{key:"42fbffd05631ab758d4a9647b4bda41cb5b77b0a"},a("section",{key:"9b67a0e72219f287d8458bb8ce271789ec653dc7",class:"title"},a("img",{key:"0eb4b3588b0631d4e93827f74111650d3bed26c4",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==",alt:"SFTP Client"}),a("div",{key:"30945973ee86494b0b2c90ead1c178a1f48086fa",class:"text"},a("div",{key:"716418d9af825dfd974ef96f7c9687f8e08cc4e7",class:"name"},this.name),a("div",{key:"eec1114d46f86c0f777b75a98dc21af1fe473f96",class:"description"},this.description))),a("section",{key:"05aa545ba36f40adabe6d920514a00b50219744e",class:"actions"},a("div",{key:"036d227279849911bd353ba879600d46d4cd1ab2",class:"action",onClick:()=>this.toggle_max()},a("img",{key:"3087b9252229f3dc401ea984c7e4576dc0bb74cb",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K",alt:"Maximize"})))),a("main",{key:"5f2a69fb252b3df05742f8b74a15a0c9028f372f"},this.show_navigation&&a("nav",{key:"10612928faf505db3a3a2a00df51425540ea97ec",class:"navigation"},a("div",{key:"fdaa4662f45fad1b2fa31059f67df9344f7e7428",class:"breadcrumbs"},this.breadcrumbs.map(((e,t,i)=>a("span",{key:t,class:"breadcrumb-container"},a("span",{key:t,onClick:()=>this.list_breadcrumb(e.path),class:"breadcrumb"},e.label),t<i.length-1&&a("img",{class:"arrow",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogICAgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIKICAgIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQgdy0zIGgtMyB0ZXh0LW11dGVkLWZvcmVncm91bmQvNTAgc2hyaW5rLTAiPgogICAgPHBhdGggZD0ibTkgMTggNi02LTYtNiI+PC9wYXRoPgo8L3N2Zz4K"}))))),a("section",{key:"71356c63017f5c74eadeabec428a3b7b3809ade2",class:"actions","aria-label":"SFTP actions"},a("button",{key:"eaf88ec4362509efd594f29a38531a8b158ece9f",type:"button",class:"action",onClick:()=>this.go_to_parent_directory(),title:"Go to parent directory","aria-label":"Go to parent directory"},a("img",{key:"b1d5c6a632e22d64f829dbbd7139b859006dbd7a",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtYXJyb3ctdXAgdy0zLjUgaC0zLjUiPgogICAgPHBhdGggZD0ibTUgMTIgNy03IDcgNyI+PC9wYXRoPgogICAgPHBhdGggZD0iTTEyIDE5VjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Go up"})),a("button",{key:"94abac9e1a6984872c4c85e66aa448d11621e980",type:"button",class:"action",onClick:()=>this.refresh_directory(),title:"Refresh","aria-label":"Refresh"},a("img",{key:"d953e97de3411cd1a526c6e1fe042db0ddc673e5",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtcmVmcmVzaC1jdyB3LTMuNSBoLTMuNSI+CiAgICA8cGF0aCBkPSJNMyAxMmE5IDkgMCAwIDEgOS05IDkuNzUgOS43NSAwIDAgMSA2Ljc0IDIuNzRMMjEgOCI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDN2NWgtNSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDEyYTkgOSAwIDAgMS05IDkgOS43NSA5Ljc1IDAgMCAxLTYuNzQtMi43NEwzIDE2Ij48L3BhdGg+CiAgICA8cGF0aCBkPSJNOCAxNkgzdjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Refresh"})),a("button",{key:"03598d60ae17c54493b1572f53c267b765008766",type:"button",class:"action",onClick:()=>this.open_upload_picker(),title:"Upload","aria-label":"Upload"},a("img",{key:"c39ee38d8e584c35155035aeb37403d4a89372ba",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtdXBsb2FkIHctMy41IGgtMy41Ij4KICAgIDxwYXRoIGQ9Ik0yMSAxNXY0YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0ydi00Ij48L3BhdGg+CiAgICA8cG9seWxpbmUgcG9pbnRzPSIxNyA4IDEyIDMgNyA4Ij48L3BvbHlsaW5lPgogICAgPGxpbmUgeDE9IjEyIiB4Mj0iMTIiIHkxPSIzIiB5Mj0iMTUiPjwvbGluZT4KPC9zdmc+Cg==",alt:"Upload"})),a("button",{key:"7e017137f2588bb7a231ef76e874b85e3c1c112d",type:"button",class:"action disconnect",onClick:()=>this.disconnect_session(),title:"Disconnect","aria-label":"Disconnect"},"DISCONNECT"))),a("input",{key:"2956f9ad2124f813d848ace2206312ee81a4e145",type:"file",ref:e=>this.uploadInputEl=e,onChange:e=>this.on_upload_selected(e),style:{display:"none"}}),this.show_content&&a("div",{key:"451d0758c8b71ac9c720f4ad07c5fa3a7011b43e",class:"content"},a("table",{key:"27a87bfdc1e357a15ff578cae12f41fb768be576"},a("thead",{key:"c8161cd9ff7e2bdf0579b3aa9797bd2366b106e8"},a("tr",{key:"23dc88a5b43a77bb1ab031f72e01996c0e16d4de"},a("th",{key:"460827f1703d2c7165df2e07b2d873d71a842c6f"},"Name"),a("th",{key:"6960f731ba9b30012d1772911899714ad6ea5e10"},"Size"),a("th",{key:"71ae2e8bd6c7ba2110470b651aed9cda0ef2b88f"},"Permissions"),a("th",{key:"6e8e87a11812570c5bbfebadf4793eafe15e6237"},"Owner"),a("th",{key:"b0001ae77eb5c4958434558c715aa5b23e336da2"},"Modified"),a("th",{key:"3eb862c25e9734c1a2c99fe07ea804761d9578e9",class:"action-col","aria-label":"Actions"}))),a("tbody",{key:"b80916d2917e97c9e4058195c5d5d20e98702d60"},this.listing.map(((e,t)=>a("tr",{key:t,class:{selected:this.is_selected(e)},onClick:()=>this.list_directory(e)},a("td",null,a("img","Folder"===e.kind?{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1mb2xkZXIgdy0zLjUgaC0zLjUgdGV4dC1wcmltYXJ5IHNocmluay0wIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTIwIDIwYTIgMiAwIDAgMCAyLTJWOGEyIDIgMCAwIDAtMi0yaC03LjlhMiAyIDAgMCAxLTEuNjktLjlMOS42IDMuOUEyIDIgMCAwIDAgNy45MyAzSDRhMiAyIDAgMCAwLTIgMnYxM2EyIDIgMCAwIDAgMiAyWiI+PC9wYXRoPgo8L3N2Zz4K",alt:"Folder"}:{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtZmlsZSB3LTMuNSBoLTMuNSB0ZXh0LW11dGVkLWZvcmVncm91bmQgc2hyaW5rLTAiPgogICAgPHBhdGggZD0iTTE1IDJINmEyIDIgMCAwIDAtMiAydjE2YTIgMiAwIDAgMCAyIDJoMTJhMiAyIDAgMCAwIDItMlY3WiI+PC9wYXRoPgogICAgPHBhdGggZD0iTTE0IDJ2NGEyIDIgMCAwIDAgMiAyaDQiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"File"}),a("span",{class:"name "+e.kind.toLowerCase()},e.name)),a("td",null,this.format_size(e.attributes.size)),a("td",null,this.format_permissions(e.attributes.permissions,e.kind)),a("td",null,e.attributes.user??"-"),a("td",null,new Date(1e3*e.attributes.modified).toLocaleString()),a("td",{class:"action-col"},"File"===e.kind&&a("div",{class:"file-actions"},a("button",{type:"button",class:"file-action",onClick:t=>this.on_file_row_action(e,t),title:"Download","aria-label":"Download"},a("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},a("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),a("polyline",{points:"7 10 12 15 17 10"}),a("line",{x1:"12",x2:"12",y1:"15",y2:"3"}))),a("button",{type:"button",class:"file-action delete",onClick:t=>this.on_file_delete_action(e,t),title:"Delete","aria-label":"Delete"},a("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},a("polyline",{points:"3 6 5 6 21 6"}),a("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),a("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),a("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),a("line",{x1:"14",x2:"14",y1:"11",y2:"17"}))))))))))),this.show_loader&&a("div",{key:"6698d4f3a2f60efa264ac5d4a3e35da14c1b47d5",class:"loader"},"Loading..."),this.show_error&&a("div",{key:"411d74aa5574e444eb4f08d7ecec37fbe9c54a37",class:"error"},this.error_message)),a("footer",{key:"a58fb0f412a403f930cbdca15269678cf92037f9"},a("section",{key:"8a989e00a03d5d3290599131989ddef872444e9b",class:"version"},this.version?"Version: "+this.version:""))),this.show_login_screen&&a("section",{key:"8f070e03986f073de9ca90ea2f46cd0d485a0a8c",class:{creds:!0,blurred:this.show_login_screen}},a("form",{key:"f8d6b2455ecf15e6ef19f1058c86100d7fe36357",class:"auth",onSubmit:e=>{const t=new FormData(e.target);let i,s;this.show_login_screen_username&&(i=t.get("username")),this.show_login_screen_password&&(s=t.get("password")),this.channel.open_sftp_tunnel(this.nodeId,i,s),this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_loader=!0,e.stopPropagation(),e.preventDefault()}},a("div",{key:"870343a9f67b01ce620c88ab3af2d823e9c109da",class:"title"},"SFTP Connection"),this.show_login_screen_username&&a("div",{key:"d32b19a3d0e89196247358ca846fd6108fe15128"},a("label",{key:"c60053d805db2357780bb986c71f6b839390ca20",htmlFor:"username"},"Username"),a("input",{key:"73c368508cc63db7ff5d7c7ca1d3f12a6e409926",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"username",name:"username",type:"text",placeholder:""})),this.show_login_screen_password&&a("div",{key:"c5a91b121c0309e577ca63a5392dce7b982e6429"},a("label",{key:"b3adfc6963d418f9a7748092a661f87a77949f1d",htmlFor:"password"},"Password"),a("input",{key:"0e6855eb8e7ef22e6981e5c7df429d4bc81e8d67",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"password",name:"password",type:"password",placeholder:""})),a("div",{key:"05377a2061e222afada603838feaac68b913be1b"},a("button",{key:"4d28615b22f083ad8b7430a3babe2a5dbc9c4f90",type:"submit"},"Connect")))),this.show_upload_modal&&a("section",{key:"7979af0ec1f92bf78a94d5e1be2a7b7a79b780be",class:{"upload-modal":!0,visible:this.show_upload_modal}},a("div",{key:"55132c16758312e55fd7bb5bb32dfcd557500838",class:"upload-dialog",role:"dialog","aria-modal":"true","aria-label":"Upload progress"},a("div",{key:"7b808945f2123b5c1e8ed300cba85f3325be643e",class:"title"},"Uploading File"),a("div",{key:"0c7065ccff128f524eee7da248eee97f78819bc0",class:"file-name",title:this.upload_file_name},this.upload_file_name),a("div",{key:"848d3526b2cff55c6cc6eab0a4cb536264f14d80",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.upload_progress},a("div",{key:"a3f8d7c47971866243a5138ae1e5b84fe50fa008",class:"progress-fill",style:{width:this.upload_progress+"%"}})),a("div",{key:"6675b28ce14fa0f3d84cbfcc602409f6ba650a13",class:"progress-meta"},a("div",{key:"5205d72ab81c7bfc906fcfe827b05933440161b8",class:"progress-speed"},this.upload_speed),a("div",{key:"c3f59de705696ac1355629ac0397e1a9baf56a0a",class:"progress-value"},this.format_percent(this.upload_progress))),a("button",{key:"06d9bc2f61d7f83361ad97b7bb23f2f45b11ec27",type:"button",class:{cancel:!0,finished:this.upload_finished},onClick:()=>this.cancel_upload()},this.upload_finished?"Close":"Cancel"))),this.show_download_modal&&a("section",{key:"7217722972f463d2893bd44ac5a4899c8fe545a7",class:{"download-modal":!0,visible:this.show_download_modal}},a("div",{key:"493dddfad5d25411a3421641ef930eab561347b4",class:"download-dialog",role:"dialog","aria-modal":"true","aria-label":"Download progress"},a("div",{key:"2115492e8360a19edf260c7c603bc44e736cccec",class:"title"},"Downloading File"),a("div",{key:"5582b3ea56c9a184ff1b6de4ca89b93f07461847",class:"file-name",title:this.download_file_name},this.download_file_name),a("div",{key:"90df12daa47066e7a212edeec5760cef2abc52c6",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.download_progress},a("div",{key:"2c3c6ef5b7091ea010c4fc9037d05db5845f4e23",class:"progress-fill",style:{width:this.download_progress+"%"}})),a("div",{key:"9d963e08afe1e073f19fc9195cd66f67a874204f",class:"progress-meta"},a("div",{key:"96508c5a2a95ce9889d947bc4786403785b15c75",class:"progress-speed"},this.download_speed),a("div",{key:"3f0cab67e511efda1cf79111705525b9838eb410",class:"progress-value"},this.format_percent(this.download_progress))),a("button",{key:"cac13e01231ba4c1713b85e7b7ac661b1ec6f6e5",type:"button",class:{cancel:!0,finished:this.download_finished},onClick:()=>this.cancel_download()},this.download_finished?"Close":"Cancel"))),this.show_delete_modal&&a("section",{key:"e66cc06cb588d7842a4557041a5fa617b2672b0b",class:{"delete-modal":!0,visible:this.show_delete_modal}},a("div",{key:"ac2298da9dde4e4043f29a8b2b137fe7f2e0f5dc",class:"delete-dialog",role:"dialog","aria-modal":"true","aria-label":"Delete confirmation"},a("div",{key:"ac53826a41c03e3cb94296c30e622f453bca0f40",class:"title"},"Delete File"),a("div",{key:"9724627c77b3242f25e7d73b18bae820833cdb9f",class:"message"},this.delete_loading?"Deleting file...":"Are you sure you want to delete this file?"),a("div",{key:"408ece6999a858d60baf7bd34b3133d07aba8806",class:"file-name",title:this.delete_file_name},this.delete_file_name),this.delete_loading&&a("div",{key:"6f157f39e1097a355c139af9ea0e35ee76a04117",class:"delete-loader","aria-hidden":"true"},a("span",{key:"bd85fe1e6dfc09febebcd1c31fc99629d1f4429d",class:"spinner"})),a("div",{key:"ad4f19824730b61e82e8ad205d5ea0cc2e715a7f",class:"modal-actions"},a("button",{key:"9d95213a54aefc8064769796f235b4533fc5aa08",type:"button",class:"btn secondary",onClick:()=>this.cancel_delete(),disabled:this.delete_loading},"Cancel"),a("button",{key:"d423c0537eb372ed491387c45e6a5c5f5a975259",type:"button",class:"btn destructive",onClick:()=>this.confirm_delete(),disabled:this.delete_loading},this.delete_loading?"Deleting...":"Delete")))))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return":host{--radius:0.375rem;--card:220 18% 10%;--border:220 15% 18%;--primary:160 60% 45%;--radius:0.375rem;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:220 10% 50%;--primary-foreground:220 20% 7%;--scroll-track:220 16% 12%;--scroll-thumb:220 12% 34%;--scroll-thumb-hover:160 45% 44%;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;height:100%;width:100%;border:1px solid hsl(var(--border));background-color:hsl(var(--card));border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative;container-type:inline-size;.listing{height:100%;display:flex;flex-direction:column;justify-content:space-between;min-height:0;header{height:30px;background:rgba(28, 31, 38, 0.6);border-bottom:1px solid hsl(var(--border));display:flex;align-items:center;justify-content:space-between;.actions{display:flex;align-items:center;.action{cursor:pointer;padding:4px;display:flex;align-items:center;z-index:1;img{height:14px;padding:4px;border-radius:4px}&:hover{background-color:hsl(var(--border) / 0.6)}}}.title{color:hsl(var(--primary));height:14px;padding:0 12px;display:flex;align-items:center;font-size:0.75rem;line-height:1rem;img{height:14px;margin-right:5px}.text{display:flex;flex-direction:row;justify-content:center;margin-top:2px;.name{margin-right:10px}.description{color:hsl(var(--muted-foreground))}}}}main{flex:1;display:flex;flex-direction:column;position:relative;min-height:0;overflow:hidden;.loader{color:hsl(var(--muted-foreground));font-size:13px;animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;text-align:center;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;width:100%;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.error{font-size:13px;text-align:center;color:hsl(var(--destructive));height:100%;display:flex;align-items:center;justify-content:center}.navigation{height:25px;padding:10px;font-size:0.75rem;line-height:1rem;background-color:hsl(var(--card));display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid hsl(var(--border));position:sticky;top:0;z-index:3;.breadcrumbs{display:flex;align-items:center;margin-right:10px;.breadcrumb-container{white-space:nowrap;.breadcrumb{color:hsl(var(--primary));margin-right:4px;cursor:pointer;&:after{margin-left:4px}&:hover{color:rgb(189, 219, 209)}&:last-child{margin-right:0;color:rgb(189, 219, 209);cursor:default}}}.arrow{height:12px;width:12px;opacity:0.6;top:2px;margin-right:4px;position:relative}}.actions{display:flex;align-items:center;gap:8px}.action{border:none;background:transparent;color:rgb(189, 219, 209);font-size:1.1rem;line-height:1;padding:2px 4px;border-radius:4px;cursor:pointer;&:hover{background-color:hsl(var(--border) / 0.6)}img{height:14px;width:14px;display:block}}.action.disconnect{color:#ff4d5f;font-size:0.65rem;letter-spacing:0.08em;padding:4px 8px;&:hover{color:#ff6b7a;background-color:hsl(var(--destructive) / 0.12)}}}.content{flex:1;min-height:0;overflow:auto;font-size:0.75rem;line-height:1rem;scrollbar-width:thin;scrollbar-color:hsl(var(--scroll-thumb)) hsl(var(--scroll-track));&::-webkit-scrollbar{width:10px;height:10px}&::-webkit-scrollbar-track{background:hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb{background:hsl(var(--scroll-thumb));border-radius:999px;border:2px solid hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb:hover{background:hsl(var(--scroll-thumb-hover))}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:auto;thead{background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));th{padding:8px 10px;text-align:left;color:hsl(var(--muted-foreground));position:sticky;top:0;z-index:2;background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));line-height:0.95rem;&.action-col{width:58px;min-width:58px;padding:0 10px}&:first-child{width:30%;min-width:180px;max-width:195px}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap;width:1%}}}tbody{padding:10px 10px;tr{border-bottom:1px solid hsl(var(--border) / 0.4);td{padding:10px 10px 9px;color:hsl(var(--muted-foreground));&:first-child{min-width:180px;max-width:195px;white-space:nowrap;.name{display:inline-block;max-width:calc(100% - 26px);overflow:hidden;text-overflow:ellipsis;vertical-align:middle}}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap}&.action-col{width:58px;min-width:58px;text-align:center;padding-left:1px;padding-right:1px;.file-actions{display:flex;align-items:center;justify-content:center;gap:8px}.file-action{border:none;background:transparent;color:hsl(var(--muted-foreground));width:16px;height:16px;border-radius:3px;cursor:pointer;opacity:0;visibility:hidden;pointer-events:none;transition:opacity 120ms ease;padding:0;svg{width:12px;height:12px;display:block;margin:0 auto}&:hover{color:hsl(var(--primary))}&.delete:hover{color:hsl(var(--destructive))}}}.name{&.file{color:rgb(189, 219, 209)}&.folder{color:hsl(var(--primary))}}.kind{height:14px;width:14px;margin-right:5px;top:3px;position:relative}}&:hover{cursor:pointer;background-color:hsl(var(--muted) / 0.4);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;color:hsl(var(--primary))}}&.selected{background-color:hsl(var(--primary) / 0.3);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto}&:hover{background-color:hsl(var(--primary) / 0.4)}}}}}}}footer{height:25px;background:rgba(28, 31, 38, 0.6);border-top:1px solid hsl(var(--border));font-size:0.75rem;line-height:1rem;display:flex;align-items:center;justify-content:space-between;padding:0 10px;.status{font-size:0.65rem;color:hsl(var(--muted-foreground));.selected-item{margin-left:10px;color:hsl(var(--primary))}}.version{font-size:0.65rem;color:hsl(var(--muted-foreground))}}}.creds{position:absolute;top:0;left:0;height:100%;width:100%;display:flex;justify-content:center;align-items:center;;&.blurred{background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.auth{display:flex;flex-direction:column;background:hsl(var(--card));position:relative;background-color:rgba(21, 24, 30, 0.95);border:1px solid hsl(var(--border));padding:30px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;border-radius:var(--radius);.title{margin-bottom:12px;color:hsl(var(--primary))}label{font-size:0.75rem;line-height:1rem;margin-bottom:1rem;color:hsl(var(--muted-foreground))}input{font-size:0.875rem;line-height:1.25rem;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;background-color:rgb(28, 31, 38);border-color:rgb(39, 44, 53);border-width:1px;border-radius:calc(var(--radius) - 2px);width:100%;margin-bottom:12px;color:rgb(189, 219, 209);box-sizing:border-box;&:focus{outline:none;border-color:hsl(var(--primary));box-shadow:0 0 0 1px hsl(var(--primary))}}button[type='submit']{margin-top:12px;width:100%;background-color:hsl(var(--primary));color:hsl(var(--primary-foreground));letter-spacing:0.05em;font-size:13px;font-weight:500;padding:0.5rem 1rem;border-radius:calc(var(--radius) - 2px);height:2rem;cursor:pointer;border:none;&:hover{background-color:hsl(var(--primary) / 0.9)}}}}.upload-modal,.download-modal,.delete-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:6;&.visible{display:flex}.upload-dialog,.download-dialog,.delete-dialog{width:min(360px, calc(100% - 24px));background-color:rgba(21, 24, 30, 0.96);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px}.file-name{color:rgb(189, 219, 209);font-size:0.72rem;line-height:1rem;margin-bottom:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.progress-track{width:100%;height:10px;border-radius:999px;background-color:hsl(var(--muted));overflow:hidden;border:1px solid hsl(var(--border));.progress-fill{height:100%;width:0;background:linear-gradient(90deg, hsl(var(--primary) / 0.7), hsl(var(--primary)));transition:width 140ms ease}}.progress-meta{margin-top:8px;margin-bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:10px}.progress-speed{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:left}.progress-value{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:right}.cancel{margin-top:14px;width:100%;height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);background:hsl(var(--muted));color:rgb(189, 219, 209);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}&.finished{background-color:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover{background-color:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9);color:hsl(var(--primary-foreground))}}}.message{color:rgb(189, 219, 209);font-size:0.74rem;line-height:1rem;margin-bottom:8px}.modal-actions{margin-top:14px;display:grid;grid-template-columns:1fr 1fr;gap:8px;.btn{height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white;&:hover{background:hsl(var(--destructive) / 0.9);border-color:hsl(var(--destructive) / 0.9)}}}.delete-loader{margin-top:4px;display:flex;justify-content:center;.spinner{width:16px;height:16px;border:2px solid hsl(var(--muted-foreground) / 0.35);border-top-color:hsl(var(--primary));border-radius:50%;animation:spin 0.7s linear infinite}}}}}@keyframes spin{to{transform:rotate(360deg)}}:host(.max){height:100vh;width:100vw;position:fixed;top:0;left:0;z-index:9999}@container (max-width: 699px){:host .listing main .content table thead th:nth-child(4),:host .listing main .content table tbody td:nth-child(4){display:none}}@container (max-width: 635px){:host .listing main .content table thead th:nth-child(3),:host .listing main .content table tbody td:nth-child(3){display:none}}@container (max-width: 530px){:host .listing main .content table thead th:nth-child(5),:host .listing main .content table tbody td:nth-child(5){display:none}:host .listing footer .status{display:none}}@container (max-width: 370px){:host .listing main .content table thead th:nth-child(2),:host .listing main .content table tbody td:nth-child(2){display:none}:host .listing main .content table thead th:first-child,:host .listing main .content table tbody td:first-child{width:100%;min-width:0;max-width:none}:host .listing main .content table tbody td:first-child .name{max-width:100%}}@container (max-width: 295px){:host .listing main .content table tbody td:first-child .name{max-width:120px}}"}},[513,"phirepass-sftp-client",{name:[1],description:[1],hideHeader:[4,"hide-header"],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"],max:[32],show_login_screen:[32],show_login_screen_username:[32],show_error:[32],error_message:[32],show_login_screen_password:[32],show_navigation:[32],breadcrumbs:[32],current_dir:[32],listing:[32],show_content:[32],show_loader:[32],version:[32],status:[32],selected_item:[32],show_upload_modal:[32],upload_progress:[32],upload_file_name:[32],upload_speed:[32],upload_finished:[32],show_download_modal:[32],download_progress:[32],download_file_name:[32],download_speed:[32],download_finished:[32],show_delete_modal:[32],delete_file_name:[32],delete_loading:[32],maximize:[64],minimize:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function b(){"undefined"!=typeof customElements&&["phirepass-sftp-client"].forEach((t=>{"phirepass-sftp-client"===t&&(customElements.get(e(t))||customElements.define(e(t),h))}))}b();const g=h,p=b;export{g as PhirepassSftpClient,p as defineCustomElement}
1
+ import{t as e,p as t,H as i,c as s,h as a,a as o}from"./index.js";import{_ as r,E as d,C as n,a as c,P as l}from"./p-DdpMFZgO.js";const h=t(class extends i{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.maximizeEvent=s(this,"maximize"),this.connectionStateChanged=s(this,"connectionStateChanged")}channel;domReady=!1;runtimeReady=!1;connected=!1;uploadInputEl;deleteLoadingTimeout;msgId=1;activeUploadToken=0;pendingUploadStarts=new Map;pendingUploadAcks=new Map;pendingDownloadStarts=new Map;activeDownloads=new Map;activeDownloadMsgId;pendingDelete;session_id;name="SFTP";description="Client";hideHeader=!1;serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(e,t){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),e&&(this.open_comms(),this.channel.connect(),this.status="Connecting...")}serverId;onServerIdChange(e,t){this.onNodeIdChange(this.nodeId,this.nodeId)}maximizeEvent;async maximize(){this.max=!this.max}async minimize(){this.max=!1}connectionStateChanged;max=!1;show_login_screen=!1;show_login_screen_username=!1;show_error=!1;error_message="";show_login_screen_password=!1;show_navigation=!1;breadcrumbs=[];current_dir=".";listing=[];show_content=!1;show_loader=!1;version="";status="Disconnected";selected_item=null;show_upload_modal=!1;upload_progress=0;upload_file_name="";upload_speed="--";upload_finished=!1;show_download_modal=!1;download_progress=0;download_file_name="";download_speed="--";download_finished=!1;show_delete_modal=!1;delete_file_name="";delete_loading=!1;toggle_max(){this.maximizeEvent?.emit(!this.max)}async connectedCallback(){await r(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.clear_delete_loading_timeout(),this.close_comms()}clear_delete_loading_timeout(){void 0!==this.deleteLoadingTimeout&&(window.clearTimeout(this.deleteLoadingTimeout),this.deleteLoadingTimeout=void 0)}next_msg_id(){const e=this.msgId;return this.msgId+=1,e}clear_pending_operations(){this.pendingUploadStarts.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Upload start aborted"))})),this.pendingUploadStarts.clear(),this.pendingUploadAcks.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Upload chunk aborted"))})),this.pendingUploadAcks.clear(),this.pendingDownloadStarts.forEach((e=>{window.clearTimeout(e.timeout),e.reject(Error("Download start aborted"))})),this.pendingDownloadStarts.clear(),this.stop_delete_polling(),this.activeDownloads.clear()}stop_delete_polling(){void 0!==this.pendingDelete?.interval&&window.clearInterval(this.pendingDelete.interval),this.pendingDelete=void 0}cancel_active_upload(){this.activeUploadToken+=1,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--"}cancel_active_download(){void 0!==this.activeDownloadMsgId&&this.activeDownloads.delete(this.activeDownloadMsgId),this.activeDownloadMsgId=void 0,this.download_progress=0,this.download_finished=!1,this.download_speed="--"}format_duration(e){if(!Number.isFinite(e)||e<0)return"--";if(e<60)return e.toFixed(0)+"s";const t=Math.floor(e/60);return t<60?`${t}m ${Math.floor(e%60)}s`:`${Math.floor(t/60)}h ${t%60}m`}format_percent(e){return(Number.isFinite(e)?e:0).toFixed(2)+"%"}format_transfer_rate(e){return!Number.isFinite(e)||e<=0?"--":this.format_size(e)+"/s"}update_upload_progress(e,t,i){if(this.upload_progress=Math.max(0,Math.min(100,t>0?e/t*100:0)),e>=t)return this.upload_finished=!0,void(this.upload_speed="--");const s=(performance.now()-i)/1e3,a=s>0?e/s:0;this.upload_speed=this.format_transfer_rate(a);const o=a>0?(t-e)/a:NaN;this.status=`Uploading ${this.format_size(e)} / ${this.format_size(t)} (ETA ${this.format_duration(o)})`}update_download_progress(e,t,i){if(this.download_progress=Math.max(0,Math.min(100,t>0?e/t*100:0)),e>=t)return this.download_finished=!0,void(this.download_speed="--");const s=(Date.now()-i)/1e3,a=s>0?e/s:0;this.download_speed=this.format_transfer_rate(a);const o=a>0?(t-e)/a:NaN;this.status=`Downloading ${this.format_size(e)} / ${this.format_size(t)} (ETA ${this.format_duration(o)})`}connect(){this.connected=!0,this.channel.connect(),this.status="Connecting..."}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.channel&&this.connect()}create_web_socket_endpoint(){const e=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${e}://${this.serverHost}`:`${e}://${this.serverHost}:${this.serverPort}`:`${e}://${this.serverHost}`}handle_error(e){if(void 0!==e.msg_id){const t=this.pendingUploadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.reject(Error(e.message||"Upload start failed")),this.pendingUploadStarts.delete(e.msg_id));const i=this.pendingDownloadStarts.get(e.msg_id);i&&(window.clearTimeout(i.timeout),i.reject(Error(e.message||"Download start failed")),this.pendingDownloadStarts.delete(e.msg_id)),this.activeDownloads.has(e.msg_id)&&(this.activeDownloads.delete(e.msg_id),this.activeDownloadMsgId===e.msg_id&&(this.activeDownloadMsgId=void 0),this.download_finished=!1),this.pendingDelete?.msgId===e.msg_id&&(this.stop_delete_polling(),this.delete_loading=!1,this.show_delete_modal=!1,this.status="Connected")}switch(e.kind){case d.Generic:case d.Authentication:this.error_message=e.message||"An unknown error occurred.",this.show_error=!0;break;case d.RequiresUsername:this.show_login_screen_username=!0,this.show_login_screen_password=!1,this.show_login_screen=!0;break;case d.RequiresPassword:this.show_login_screen_username=!1,this.show_login_screen_password=!0,this.show_login_screen=!0;break;case d.RequiresUsernamePassword:this.show_login_screen_username=!0,this.show_login_screen_password=!0,this.show_login_screen=!0}setTimeout((()=>{this.show_loader=!1}),1e3)}handle_auth_success(e){this.clear_creds_buffer(),this.version=e.version,this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_sftp_tunnel(this.nodeId),this.status="Connected"}handle_tunnel_opened(e){this.session_id=e.sid,this.channel.send_sftp_list_data(this.nodeId,this.session_id,this.current_dir)}handle_sftp_list_items(e){setTimeout((()=>{this.show_loader=!1}),500),this.listing=e.dir.items,this.current_dir=e.path,this.breadcrumbs=e.path.split("/").map(((e,t,i)=>""===e&&0===t?{label:"/",path:"/"}:{label:e,path:i.slice(0,t+1).join("/")})),this.show_content=!0,this.show_navigation=!0,this.pendingDelete&&e.path===this.current_dir&&(e.dir.items.some((e=>"File"===e.kind&&e.name===this.pendingDelete?.filename))||(this.stop_delete_polling(),this.delete_loading=!1,this.show_delete_modal=!1,this.delete_file_name="",this.status="Connected")),console.log("Received SFTP list items:",e)}handle_upload_start_response(e){if(void 0===e.msg_id)return;const t=this.pendingUploadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.resolve(e.response.upload_id),this.pendingUploadStarts.delete(e.msg_id))}handle_upload_chunk_ack(e){const t=`${e.upload_id}_${e.chunk_index}`,i=this.pendingUploadAcks.get(t);i&&(window.clearTimeout(i.timeout),i.resolve(),this.pendingUploadAcks.delete(t))}handle_download_start_response(e){if(void 0===e.msg_id)return;const t=this.pendingDownloadStarts.get(e.msg_id);t&&(window.clearTimeout(t.timeout),t.resolve({download_id:e.response.download_id,total_size:e.response.total_size,total_chunks:e.response.total_chunks}),this.pendingDownloadStarts.delete(e.msg_id))}finalize_download(e){const t=this.activeDownloads.get(e);if(!t)return;const i=Array.from(t.chunks.entries()).sort(((e,t)=>e[0]-t[0])).map((([,e])=>e)).map((e=>new Uint8Array(e))),s=new Blob(i,{type:"application/octet-stream"}),a=URL.createObjectURL(s),o=document.createElement("a");o.href=a,o.download=t.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),this.activeDownloads.delete(e),this.activeDownloadMsgId===e&&(this.activeDownloadMsgId=void 0),this.download_finished=!0,this.status="Connected"}handle_download_chunk(e){if(void 0===e.msg_id)return;const t=this.activeDownloads.get(e.msg_id);if(!t||!this.session_id)return;const i=new Uint8Array(e.chunk.data);t.chunks.set(e.chunk.chunk_index,i);const s=Array.from(t.chunks.values()).reduce(((e,t)=>e+t.length),0);this.update_download_progress(s,t.total_size,t.startTime),this.channel.send_sftp_download_ack(this.nodeId,this.session_id,t.download_id,e.chunk.chunk_index),t.chunks.size>=t.total_chunks&&this.finalize_download(e.msg_id)}async start_download(e){if(!this.session_id)return;this.selected_item=e,this.download_file_name=e.name,this.download_progress=0,this.download_finished=!1,this.download_speed="--",this.show_download_modal=!0,this.show_error=!1;const t=this.next_msg_id();this.activeDownloadMsgId=t,this.activeDownloads.set(t,{filename:e.name,chunks:new Map,total_chunks:0,total_size:0,download_id:0,startTime:Date.now()});const i=new Promise(((e,i)=>{const s=window.setTimeout((()=>{this.pendingDownloadStarts.delete(t),i(Error("Download start timeout"))}),1e4);this.pendingDownloadStarts.set(t,{timeout:s,resolve:e,reject:i})}));try{this.channel.send_sftp_download_start(this.nodeId,this.session_id,e.path,e.name,t);const{download_id:s,total_chunks:a,total_size:o}=await i,r=this.activeDownloads.get(t);if(!r)return;r.download_id=s,r.total_chunks=a,r.total_size=o}catch(e){this.activeDownloads.delete(t),this.activeDownloadMsgId===t&&(this.activeDownloadMsgId=void 0),this.show_error=!0,this.error_message=e instanceof Error?e.message:"Failed to start download",this.cancel_download()}}async upload_file(e){if(!this.session_id)return;const t=this.activeUploadToken+1;this.activeUploadToken=t,this.upload_file_name=e.name,this.upload_progress=0,this.upload_finished=!1,this.upload_speed="--",this.show_upload_modal=!0,this.show_error=!1,this.status="Uploading...";const i=65536,s=Math.max(1,Math.ceil(e.size/i)),a=this.next_msg_id(),o=new Promise(((e,t)=>{const i=window.setTimeout((()=>{this.pendingUploadStarts.delete(a),t(Error("Upload start timeout"))}),1e4);this.pendingUploadStarts.set(a,{timeout:i,resolve:e,reject:t})}));try{this.channel.send_sftp_upload_start(this.nodeId,this.session_id,e.name,this.current_dir,s,BigInt(e.size),a);const r=await o;let d=0;const n=performance.now();for(let a=0;a<s;a+=1){if(t!==this.activeUploadToken)throw Error("Upload cancelled");const s=a*i,o=Math.min(s+i,e.size),c=new Uint8Array(await e.slice(s,o).arrayBuffer());await new Promise(((e,t)=>{const i=`${r}_${a}`,s=window.setTimeout((()=>{this.pendingUploadAcks.delete(i),t(Error(`Upload chunk ${a+1} timed out`))}),3e4);this.pendingUploadAcks.set(i,{timeout:s,resolve:e,reject:t}),this.channel.send_sftp_upload_chunk(this.nodeId,this.session_id,r,a,c.length,c,null)})),d+=c.length,this.update_upload_progress(d,e.size,n)}this.upload_progress=100,this.upload_finished=!0,this.status="Connected",this.refresh_directory()}catch(e){"Upload cancelled"!==e.message&&(this.show_error=!0,this.error_message=e instanceof Error?e.message:"Upload failed"),this.upload_finished=!1,this.status="Connected"}}handle_tunnel_data(e){console.log("received tunnel data:",e)}handle_tunnel_closed(e){this.clear_creds_buffer(),this.close_comms()}open_comms(){this.channel=this.serverId?new n(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new n(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([c.Connected]),this.channel.authenticate(this.token,this.nodeId),this.status="Authenticating..."})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([c.Disconnected]),this.status="Disconnected"})),this.channel.on_connection_error((e=>{this.connectionStateChanged.emit([c.Error,e]),this.status="Error "+e.message})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((e=>{const{web:t}=e.data;switch(t.type){case l.Error:this.handle_error(t);break;case l.AuthSuccess:this.handle_auth_success(t);break;case l.TunnelOpened:this.handle_tunnel_opened(t);break;case l.TunnelClosed:this.handle_tunnel_closed(t);break;case l.TunnelData:this.handle_tunnel_data(t);break;case l.SFTPListItems:this.handle_sftp_list_items(t);break;case l.SFTPUploadStartResponse:this.handle_upload_start_response(t);break;case l.SFTPUploadChunkAck:this.handle_upload_chunk_ack(t);break;case l.SFTPDownloadStartResponse:this.handle_download_start_response(t);break;case l.SFTPDownloadChunk:this.handle_download_chunk(t);break;default:console.warn("Unhandled protocol message type:",t)}}))}close_comms(){this.cancel_active_upload(),this.cancel_active_download(),this.clear_pending_operations(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}clear_creds_buffer(){}reset_session_state(){this.clear_creds_buffer()}list_breadcrumb(e){this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,e)}go_to_parent_directory(){this.session_id&&"/"!==this.current_dir&&this.list_breadcrumb(this.breadcrumbs[this.breadcrumbs.length-2]?.path||"/")}refresh_directory(){this.session_id&&this.list_breadcrumb(this.current_dir)}disconnect_session(){this.close_comms(),this.session_id=void 0,this.show_loader=!1,this.show_content=!1,this.breadcrumbs=[],this.current_dir=".",this.listing=[],this.show_navigation=!1,this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_upload_modal=!1,this.show_download_modal=!1,this.show_delete_modal=!1,this.upload_progress=0,this.download_progress=0,this.upload_finished=!1,this.download_finished=!1,this.delete_loading=!1,this.delete_file_name="",this.version="",this.status="Disconnected"}on_file_row_action(e,t){t.preventDefault(),t.stopPropagation(),"File"===e.kind&&this.start_download(e)}on_file_delete_action(e,t){t.preventDefault(),t.stopPropagation(),this.selected_item=e,this.delete_file_name=e.name,this.delete_loading=!1,this.show_delete_modal=!0}cancel_delete(){this.delete_loading||(this.show_delete_modal=!1,this.delete_file_name="",this.delete_loading=!1,this.refresh_directory())}confirm_delete(){if(this.delete_loading)return;if(!this.session_id||!this.selected_item)return void(this.show_delete_modal=!1);const e=this.selected_item.name;this.delete_loading=!0,this.status="Deleting...",this.show_error=!1,this.stop_delete_polling();const t=this.next_msg_id();this.pendingDelete={filename:e,msgId:t,startedAt:Date.now()};const i=()=>{if(this.pendingDelete)return Date.now()-this.pendingDelete.startedAt>=3e4?(this.stop_delete_polling(),this.delete_loading=!1,this.show_delete_modal=!1,this.show_error=!0,this.error_message=`Delete timed out for "${e}".`,void(this.status="Connected")):void(this.session_id&&this.channel.send_sftp_list_data(this.nodeId,this.session_id,this.current_dir))};i(),this.pendingDelete.interval=window.setInterval(i,2500),this.channel.send_sftp_delete(this.nodeId,this.session_id,this.current_dir,e,t)}open_upload_picker(){this.uploadInputEl?.click()}on_upload_selected(e){const t=e.target,i=t.files?.[0];i&&(this.upload_file(i),t.value="")}cancel_upload(){this.cancel_active_upload(),this.show_upload_modal=!1,this.upload_file_name="",this.upload_speed="--",this.status="Connected",this.refresh_directory()}cancel_download(){this.cancel_active_download(),this.show_download_modal=!1,this.download_file_name="",this.download_speed="--",this.status="Connected",this.refresh_directory()}is_selected(e){return!!this.selected_item&&this.selected_item.path===e.path&&this.selected_item.name===e.name}list_directory(e){if(!this.session_id)return void console.warn("No active session. Cannot list directory.");if("File"===e.kind)return console.warn("Cannot list directory of a file. Ignoring click."),void(this.selected_item=e);const t=[e.path,e.name].join("/");t!==this.current_dir?(this.show_loader=!0,this.selected_item=null,this.channel.send_sftp_list_data(this.nodeId,this.session_id,t)):console.warn("Already in this directory. Ignoring click.")}format_size(e){if(void 0===e||Number.isNaN(e))return"-";if(e<1024)return e+" B";let t=e,i=-1;for(;t>=1024&&i<4;)t/=1024,i+=1;return`${t.toFixed(t>=10?1:2)} ${["KB","MB","GB","TB","PB"][i]}`}mode_type_to_char(e,t){switch(61440&e){case 49152:return"s";case 40960:return"l";case 32768:return"-";case 24576:return"b";case 16384:return"d";case 8192:return"c";case 4096:return"p";default:return"Folder"===t?"d":"-"}}format_permissions(e,t){if(null==e)return"-";if("string"==typeof e){const i=e.trim();return/^[bcdlps-][rwxStTs-]{9}$/.test(i)?i:/^[0-7]{3,4}$/.test(i)?this.format_permissions(parseInt(i,8),t):/^\d+$/.test(i)?this.format_permissions(parseInt(i,10),t):i||"-"}const i=e,s=this.mode_type_to_char(i,t),a=[256&i?"r":"-",128&i?"w":"-",64&i?"x":"-",32&i?"r":"-",16&i?"w":"-",8&i?"x":"-",4&i?"r":"-",2&i?"w":"-",1&i?"x":"-"];return 2048&i&&(a[2]="x"===a[2]?"s":"S"),1024&i&&(a[5]="x"===a[5]?"s":"S"),512&i&&(a[8]="x"===a[8]?"t":"T"),`${s}${a.join("")}`}render(){return a(o,{key:"733fe85191c976aa3f1a1888aaf6b8ac66b78bce",class:{default:!this.max,max:this.max}},a("section",{key:"d2282996dfa3970f6e60713417872958b0273257",class:"listing"},!this.hideHeader&&a("header",{key:"c270d12cf1da32374f0bdcb650f3ad4f6e6701c1"},a("section",{key:"670335955f4f453d687c5315fe4e9b4b64c69ff7",class:"title"},a("img",{key:"9c4be4e7366ff1e3cd11d633b31beb625671be2b",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==",alt:"SFTP Client"}),a("div",{key:"bcb3764dc20d9d6b01fca4b3d9a7d4371a621403",class:"text"},a("div",{key:"bf036e8de51caf4fb468051edd0625e30ade4f62",class:"name"},this.name),a("div",{key:"9f042ed7412611dde5cacf7e66a7373049175da3",class:"description"},this.description))),a("section",{key:"46028c58138f41f8cfb0f355fd403cfbeada8559",class:"actions"},a("div",{key:"2613d4578a05d5b4ba5a27a6d7f0bb199692305c",class:"action",onClick:()=>this.toggle_max()},a("img",{key:"afbd51291e77e0a34bc429eacc3f92aafa72e65e",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K",alt:"Maximize"})))),a("main",{key:"200d355da53b9a777d870d472c279dc93cfae8ee"},this.show_navigation&&a("nav",{key:"a2a6d1f87818c9abfb8be2fbe7198ef3986efab5",class:"navigation"},a("div",{key:"b6d8104e7063e4011efd6510fc6f3fa33ad0c28d",class:"breadcrumbs"},this.breadcrumbs.map(((e,t,i)=>a("span",{key:t,class:"breadcrumb-container"},a("span",{key:t,onClick:()=>this.list_breadcrumb(e.path),class:"breadcrumb"},e.label),t<i.length-1&&a("img",{class:"arrow",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogICAgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIKICAgIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQgdy0zIGgtMyB0ZXh0LW11dGVkLWZvcmVncm91bmQvNTAgc2hyaW5rLTAiPgogICAgPHBhdGggZD0ibTkgMTggNi02LTYtNiI+PC9wYXRoPgo8L3N2Zz4K"}))))),a("section",{key:"86b69b8d759e1fc8a52c7f3f1cd90c318d1d413d",class:"actions","aria-label":"SFTP actions"},a("button",{key:"c69af8d208771d2788d055fa92fb396f567972e1",type:"button",class:"action",onClick:()=>this.go_to_parent_directory(),title:"Go to parent directory","aria-label":"Go to parent directory"},a("img",{key:"e7c0eaf4d8983369a68506084e77f20cc29184c8",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtYXJyb3ctdXAgdy0zLjUgaC0zLjUiPgogICAgPHBhdGggZD0ibTUgMTIgNy03IDcgNyI+PC9wYXRoPgogICAgPHBhdGggZD0iTTEyIDE5VjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Go up"})),a("button",{key:"0e8b47e93b2825bc0e60b0c75d961609c2b98158",type:"button",class:"action",onClick:()=>this.refresh_directory(),title:"Refresh","aria-label":"Refresh"},a("img",{key:"1a8d0178825ac27fb85584a36bd2d660fe09c135",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtcmVmcmVzaC1jdyB3LTMuNSBoLTMuNSI+CiAgICA8cGF0aCBkPSJNMyAxMmE5IDkgMCAwIDEgOS05IDkuNzUgOS43NSAwIDAgMSA2Ljc0IDIuNzRMMjEgOCI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDN2NWgtNSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDEyYTkgOSAwIDAgMS05IDkgOS43NSA5Ljc1IDAgMCAxLTYuNzQtMi43NEwzIDE2Ij48L3BhdGg+CiAgICA8cGF0aCBkPSJNOCAxNkgzdjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Refresh"})),a("button",{key:"fddbb65e05c0a9d800dc901bea49c9352099085d",type:"button",class:"action",onClick:()=>this.open_upload_picker(),title:"Upload","aria-label":"Upload"},a("img",{key:"cbb5517d854064846a05ee56ef959ed79308b9ad",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtdXBsb2FkIHctMy41IGgtMy41Ij4KICAgIDxwYXRoIGQ9Ik0yMSAxNXY0YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0ydi00Ij48L3BhdGg+CiAgICA8cG9seWxpbmUgcG9pbnRzPSIxNyA4IDEyIDMgNyA4Ij48L3BvbHlsaW5lPgogICAgPGxpbmUgeDE9IjEyIiB4Mj0iMTIiIHkxPSIzIiB5Mj0iMTUiPjwvbGluZT4KPC9zdmc+Cg==",alt:"Upload"})),a("button",{key:"15f521ad9359057a75fc13ab0336fd9803b9c432",type:"button",class:"action disconnect",onClick:()=>this.disconnect_session(),title:"Disconnect","aria-label":"Disconnect"},"DISCONNECT"))),a("input",{key:"48f7a635ea1e93a60e5b64042e730b3af5816ce9",type:"file",ref:e=>this.uploadInputEl=e,onChange:e=>this.on_upload_selected(e),style:{display:"none"}}),this.show_content&&a("div",{key:"7a977051ab3ccd46524a53c590e52c33904375e4",class:"content"},a("table",{key:"0ac3ae940c7ae094ca99a1c07b37980a9d5a06c4"},a("thead",{key:"f8141383e987cd435a4f89b9d85b5d373559ec1c"},a("tr",{key:"88479b89f19e1364afaf284b7947c754457c2aa5"},a("th",{key:"1ad5c30387a14041ff7f45e1caaffe39c4972b3f"},"Name"),a("th",{key:"b80c51a07e6e144b8d21698b1a4e6116eb36cb3a"},"Size"),a("th",{key:"9265bd2250aeb15ff19224f3247b0ec4c8678d7c"},"Permissions"),a("th",{key:"6c9488fced66224aee51e9193b7beb4d0ea05a04"},"Owner"),a("th",{key:"b741ca68c2ec44243160d5e9f64271c488381713"},"Modified"),a("th",{key:"a6717e7f50003dc7cb14c2c46b5141afaca3eef1",class:"action-col","aria-label":"Actions"}))),a("tbody",{key:"2406bf5112dff02abcb4952a19718398b43e6635"},this.listing.map(((e,t)=>a("tr",{key:t,class:{selected:this.is_selected(e)},onClick:()=>this.list_directory(e)},a("td",null,a("img","Folder"===e.kind?{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1mb2xkZXIgdy0zLjUgaC0zLjUgdGV4dC1wcmltYXJ5IHNocmluay0wIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTIwIDIwYTIgMiAwIDAgMCAyLTJWOGEyIDIgMCAwIDAtMi0yaC03LjlhMiAyIDAgMCAxLTEuNjktLjlMOS42IDMuOUEyIDIgMCAwIDAgNy45MyAzSDRhMiAyIDAgMCAwLTIgMnYxM2EyIDIgMCAwIDAgMiAyWiI+PC9wYXRoPgo8L3N2Zz4K",alt:"Folder"}:{class:"kind",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtZmlsZSB3LTMuNSBoLTMuNSB0ZXh0LW11dGVkLWZvcmVncm91bmQgc2hyaW5rLTAiPgogICAgPHBhdGggZD0iTTE1IDJINmEyIDIgMCAwIDAtMiAydjE2YTIgMiAwIDAgMCAyIDJoMTJhMiAyIDAgMCAwIDItMlY3WiI+PC9wYXRoPgogICAgPHBhdGggZD0iTTE0IDJ2NGEyIDIgMCAwIDAgMiAyaDQiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"File"}),a("span",{class:"name "+e.kind.toLowerCase()},e.name)),a("td",null,this.format_size(e.attributes.size)),a("td",null,this.format_permissions(e.attributes.permissions,e.kind)),a("td",null,e.attributes.user??"-"),a("td",null,new Date(1e3*e.attributes.modified).toLocaleString()),a("td",{class:"action-col"},"File"===e.kind&&a("div",{class:"file-actions"},a("button",{type:"button",class:"file-action",onClick:t=>this.on_file_row_action(e,t),title:"Download","aria-label":"Download"},a("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},a("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),a("polyline",{points:"7 10 12 15 17 10"}),a("line",{x1:"12",x2:"12",y1:"15",y2:"3"}))),a("button",{type:"button",class:"file-action delete",onClick:t=>this.on_file_delete_action(e,t),title:"Delete","aria-label":"Delete"},a("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},a("polyline",{points:"3 6 5 6 21 6"}),a("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),a("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),a("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),a("line",{x1:"14",x2:"14",y1:"11",y2:"17"}))))))))))),this.show_loader&&a("div",{key:"aa63f480151a0143183f8769413bbf1d8bad517a",class:"loader"},"Loading..."),this.show_error&&a("div",{key:"3ca7fe377368a520de804391d8939627e956e3d0",class:"error"},this.error_message)),a("footer",{key:"71a1233b255561b5e0cf4408c268ab399982cb7f"},a("section",{key:"5533f9b423be66da41ff7128b903e09bcd447c4c",class:"version"},this.version?"Version: "+this.version:""))),this.show_login_screen&&a("section",{key:"6dc948c828b479b6d706dbcca3b3075e58757cef",class:{creds:!0,blurred:this.show_login_screen}},a("form",{key:"a7f60c3dcc672cc18f1ec67a45495eb756ae9c92",class:"auth",onSubmit:e=>{const t=new FormData(e.target);let i,s;this.show_login_screen_username&&(i=t.get("username")),this.show_login_screen_password&&(s=t.get("password")),this.channel.open_sftp_tunnel(this.nodeId,i,s),this.show_login_screen_username=!1,this.show_login_screen_password=!1,this.show_login_screen=!1,this.show_loader=!0,e.stopPropagation(),e.preventDefault()}},a("div",{key:"b0f3c4b74c59590624d4944b8d6ccd5a45b6065c",class:"title"},"SFTP Connection"),this.show_login_screen_username&&a("div",{key:"2d6d9424cd170e087cc6f17d55c8cf1461a06988"},a("label",{key:"e420f513abc053a99c0e61c27716ff39f0527827",htmlFor:"username"},"Username"),a("input",{key:"c50aff8ff53e8ed3b3dbb5d0cc85055b247864cf",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"username",name:"username",type:"text",placeholder:""})),this.show_login_screen_password&&a("div",{key:"8f49b0425783375996484b536c58f07414215b44"},a("label",{key:"ed739b253b2bfa7dc6bab37dbf184b0c9eacf657",htmlFor:"password"},"Password"),a("input",{key:"d1be51c537fb0461678ede0e940fd312d96c1517",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"password",name:"password",type:"password",placeholder:""})),a("div",{key:"66da4c8d32459483a1b0329473287e89a82c5e4c"},a("button",{key:"cf5a2534f2a6abc344e999520bb4328c4dadd090",type:"submit"},"Connect")))),this.show_upload_modal&&a("section",{key:"b678714eff09b18b7932e936ae4dee366aa98b4e",class:{"upload-modal":!0,visible:this.show_upload_modal}},a("div",{key:"c4fa4e401c192e705207df634d2f93943ce77af5",class:"upload-dialog",role:"dialog","aria-modal":"true","aria-label":"Upload progress"},a("div",{key:"18ff3a246aa39f28474ced7cce76ace778922a2f",class:"title"},"Uploading File"),a("div",{key:"b08fa6b79f6080e9d60f361021b8bac6a5ed7424",class:"file-name",title:this.upload_file_name},this.upload_file_name),a("div",{key:"9efc45e387d8156a18afb90d5531df4ebfa64328",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.upload_progress},a("div",{key:"c988402fedde675d04bc7b2054da4e319c2af082",class:"progress-fill",style:{width:this.upload_progress+"%"}})),a("div",{key:"1d0d8f845d3bfa817aec865598cffa59f55505f4",class:"progress-meta"},a("div",{key:"5b983ed819d48105c3fb0a71b2d2d62f7f46003c",class:"progress-speed"},this.upload_speed),a("div",{key:"859bb76ff953d69ddaa710574bb1c72b92968f5a",class:"progress-value"},this.format_percent(this.upload_progress))),a("button",{key:"41d970d2112e63f931c5a5513bb580559f9e619b",type:"button",class:{cancel:!0,finished:this.upload_finished},onClick:()=>this.cancel_upload()},this.upload_finished?"Close":"Cancel"))),this.show_download_modal&&a("section",{key:"d9bfadbc2d3a164bc05811a7f2e9024a914ecbc8",class:{"download-modal":!0,visible:this.show_download_modal}},a("div",{key:"1f874ba0e526b99d2b41beaf8023cbada567ecc8",class:"download-dialog",role:"dialog","aria-modal":"true","aria-label":"Download progress"},a("div",{key:"ac2b5f65423e7e2b20ffecf864477e849b737259",class:"title"},"Downloading File"),a("div",{key:"639d6fe5a64db1aa53b077eb318fa21d72a551ed",class:"file-name",title:this.download_file_name},this.download_file_name),a("div",{key:"e90546d4dceab157f4599b2ffd31f1eb4eb9d18c",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.download_progress},a("div",{key:"eeb597904e31a6aa9717cc4e6fc534ae68924dee",class:"progress-fill",style:{width:this.download_progress+"%"}})),a("div",{key:"1bbf952144d17c374de6948ad94bc4deed7ae8a0",class:"progress-meta"},a("div",{key:"049f748019b11cea95f236202cd48c758e99411a",class:"progress-speed"},this.download_speed),a("div",{key:"01b8d063a3fdfe8cc9df21e75833df3a6c2eda49",class:"progress-value"},this.format_percent(this.download_progress))),a("button",{key:"a87560c1555bf8a6dea73a424792b3af25e06a68",type:"button",class:{cancel:!0,finished:this.download_finished},onClick:()=>this.cancel_download()},this.download_finished?"Close":"Cancel"))),this.show_delete_modal&&a("section",{key:"7e547c5f320acc9920020a4bcafc21ca57d6ad66",class:{"delete-modal":!0,visible:this.show_delete_modal}},a("div",{key:"b79c2be285b8e2af00189cd69143950f133f5722",class:"delete-dialog",role:"dialog","aria-modal":"true","aria-label":"Delete confirmation"},a("div",{key:"b25d1669edded42eae34ac15887428d85a3e8577",class:"title"},"Delete File"),a("div",{key:"da2a16b8f85ae7dc7d09aa2ffe4562124642233f",class:"message"},this.delete_loading?"Deleting file...":"Are you sure you want to delete this file?"),a("div",{key:"702dfa13f1e9b828c2d956cab0c1fcc557c80bb1",class:"file-name",title:this.delete_file_name},this.delete_file_name),this.delete_loading&&a("div",{key:"1e2b57c73dad6f463c3377c16ae407cc553232e3",class:"delete-loader","aria-hidden":"true"},a("span",{key:"40338e85202b89cb8b2fea8adddf10323fa91a25",class:"spinner"})),a("div",{key:"e0b264439056ab3e7f49f5dd221b5f58ea720d2e",class:"modal-actions"},a("button",{key:"ee6932fa56c02bca43c6ce914cec55ca9dbfd48a",type:"button",class:"btn secondary",onClick:()=>this.cancel_delete(),disabled:this.delete_loading},"Cancel"),a("button",{key:"2c26e30cc0942f532996a3b485ad77fb11c2d214",type:"button",class:"btn destructive",onClick:()=>this.confirm_delete(),disabled:this.delete_loading},this.delete_loading?"Deleting...":"Delete")))))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return":host{--radius:0.375rem;--card:220 18% 10%;--border:220 15% 18%;--primary:160 60% 45%;--radius:0.375rem;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:220 10% 50%;--primary-foreground:220 20% 7%;--scroll-track:220 16% 12%;--scroll-thumb:220 12% 34%;--scroll-thumb-hover:160 45% 44%;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;height:100%;width:100%;border:1px solid hsl(var(--border));background-color:hsl(var(--card));border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative;container-type:inline-size;.listing{height:100%;display:flex;flex-direction:column;justify-content:space-between;min-height:0;header{height:30px;background:rgba(28, 31, 38, 0.6);border-bottom:1px solid hsl(var(--border));display:flex;align-items:center;justify-content:space-between;.actions{display:flex;align-items:center;.action{cursor:pointer;padding:4px;display:flex;align-items:center;z-index:1;img{height:14px;padding:4px;border-radius:4px}&:hover{background-color:hsl(var(--border) / 0.6)}}}.title{color:hsl(var(--primary));height:14px;padding:0 12px;display:flex;align-items:center;font-size:0.75rem;line-height:1rem;img{height:14px;margin-right:5px}.text{display:flex;flex-direction:row;justify-content:center;margin-top:2px;.name{margin-right:10px}.description{color:hsl(var(--muted-foreground))}}}}main{flex:1;display:flex;flex-direction:column;position:relative;min-height:0;overflow:hidden;.loader{color:hsl(var(--muted-foreground));font-size:13px;animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;text-align:center;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;width:100%;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.error{font-size:13px;text-align:center;color:hsl(var(--destructive));height:100%;display:flex;align-items:center;justify-content:center}.navigation{height:25px;padding:10px;font-size:0.75rem;line-height:1rem;background-color:hsl(var(--card));display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid hsl(var(--border));position:sticky;top:0;z-index:3;.breadcrumbs{display:flex;align-items:center;margin-right:10px;.breadcrumb-container{white-space:nowrap;.breadcrumb{color:hsl(var(--primary));margin-right:4px;cursor:pointer;&:after{margin-left:4px}&:hover{color:rgb(189, 219, 209)}&:last-child{margin-right:0;color:rgb(189, 219, 209);cursor:default}}}.arrow{height:12px;width:12px;opacity:0.6;top:2px;margin-right:4px;position:relative}}.actions{display:flex;align-items:center;gap:8px}.action{border:none;background:transparent;color:rgb(189, 219, 209);font-size:1.1rem;line-height:1;padding:2px 4px;border-radius:4px;cursor:pointer;&:hover{background-color:hsl(var(--border) / 0.6)}img{height:14px;width:14px;display:block}}.action.disconnect{color:#ff4d5f;font-size:0.65rem;letter-spacing:0.08em;padding:4px 8px;&:hover{color:#ff6b7a;background-color:hsl(var(--destructive) / 0.12)}}}.content{flex:1;min-height:0;overflow:auto;font-size:0.75rem;line-height:1rem;scrollbar-width:thin;scrollbar-color:hsl(var(--scroll-thumb)) hsl(var(--scroll-track));&::-webkit-scrollbar{width:10px;height:10px}&::-webkit-scrollbar-track{background:hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb{background:hsl(var(--scroll-thumb));border-radius:999px;border:2px solid hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb:hover{background:hsl(var(--scroll-thumb-hover))}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:auto;thead{background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));th{padding:8px 10px;text-align:left;color:hsl(var(--muted-foreground));position:sticky;top:0;z-index:2;background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));line-height:0.95rem;&.action-col{width:58px;min-width:58px;padding:0 10px}&:first-child{width:30%;min-width:180px;max-width:195px}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap;width:1%}}}tbody{padding:10px 10px;tr{border-bottom:1px solid hsl(var(--border) / 0.4);td{padding:10px 10px 9px;color:hsl(var(--muted-foreground));&:first-child{min-width:180px;max-width:195px;white-space:nowrap;.name{display:inline-block;max-width:calc(100% - 26px);overflow:hidden;text-overflow:ellipsis;vertical-align:middle}}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap}&.action-col{width:58px;min-width:58px;text-align:center;padding-left:1px;padding-right:1px;.file-actions{display:flex;align-items:center;justify-content:center;gap:8px}.file-action{border:none;background:transparent;color:hsl(var(--muted-foreground));width:16px;height:16px;border-radius:3px;cursor:pointer;opacity:0;visibility:hidden;pointer-events:none;transition:opacity 120ms ease;padding:0;svg{width:12px;height:12px;display:block;margin:0 auto}&:hover{color:hsl(var(--primary))}&.delete:hover{color:hsl(var(--destructive))}}}.name{&.file{color:rgb(189, 219, 209)}&.folder{color:hsl(var(--primary))}}.kind{height:14px;width:14px;margin-right:5px;top:3px;position:relative}}&:hover{cursor:pointer;background-color:hsl(var(--muted) / 0.4);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;color:hsl(var(--primary))}}&.selected{background-color:hsl(var(--primary) / 0.3);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto}&:hover{background-color:hsl(var(--primary) / 0.4)}}}}}}}footer{height:25px;background:rgba(28, 31, 38, 0.6);border-top:1px solid hsl(var(--border));font-size:0.75rem;line-height:1rem;display:flex;align-items:center;justify-content:space-between;padding:0 10px;.status{font-size:0.65rem;color:hsl(var(--muted-foreground));.selected-item{margin-left:10px;color:hsl(var(--primary))}}.version{font-size:0.65rem;color:hsl(var(--muted-foreground))}}}.creds{position:absolute;top:0;left:0;height:100%;width:100%;display:flex;justify-content:center;align-items:center;;&.blurred{background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.auth{display:flex;flex-direction:column;background:hsl(var(--card));position:relative;background-color:rgba(21, 24, 30, 0.95);border:1px solid hsl(var(--border));padding:30px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;border-radius:var(--radius);.title{margin-bottom:12px;color:hsl(var(--primary))}label{font-size:0.75rem;line-height:1rem;margin-bottom:1rem;color:hsl(var(--muted-foreground))}input{font-size:0.875rem;line-height:1.25rem;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;background-color:rgb(28, 31, 38);border-color:rgb(39, 44, 53);border-width:1px;border-radius:calc(var(--radius) - 2px);width:100%;margin-bottom:12px;color:rgb(189, 219, 209);box-sizing:border-box;&:focus{outline:none;border-color:hsl(var(--primary));box-shadow:0 0 0 1px hsl(var(--primary))}}button[type='submit']{margin-top:12px;width:100%;background-color:hsl(var(--primary));color:hsl(var(--primary-foreground));letter-spacing:0.05em;font-size:13px;font-weight:500;padding:0.5rem 1rem;border-radius:calc(var(--radius) - 2px);height:2rem;cursor:pointer;border:none;&:hover{background-color:hsl(var(--primary) / 0.9)}}}}.upload-modal,.download-modal,.delete-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:6;&.visible{display:flex}.upload-dialog,.download-dialog,.delete-dialog{width:min(360px, calc(100% - 24px));background-color:rgba(21, 24, 30, 0.96);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px}.file-name{color:rgb(189, 219, 209);font-size:0.72rem;line-height:1rem;margin-bottom:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.progress-track{width:100%;height:10px;border-radius:999px;background-color:hsl(var(--muted));overflow:hidden;border:1px solid hsl(var(--border));.progress-fill{height:100%;width:0;background:linear-gradient(90deg, hsl(var(--primary) / 0.7), hsl(var(--primary)));transition:width 140ms ease}}.progress-meta{margin-top:8px;margin-bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:10px}.progress-speed{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:left}.progress-value{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:right}.cancel{margin-top:14px;width:100%;height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);background:hsl(var(--muted));color:rgb(189, 219, 209);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}&.finished{background-color:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover{background-color:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9);color:hsl(var(--primary-foreground))}}}.message{color:rgb(189, 219, 209);font-size:0.74rem;line-height:1rem;margin-bottom:8px}.modal-actions{margin-top:14px;display:grid;grid-template-columns:1fr 1fr;gap:8px;.btn{height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white;&:hover{background:hsl(var(--destructive) / 0.9);border-color:hsl(var(--destructive) / 0.9)}}}.delete-loader{margin-top:4px;display:flex;justify-content:center;.spinner{width:16px;height:16px;border:2px solid hsl(var(--muted-foreground) / 0.35);border-top-color:hsl(var(--primary));border-radius:50%;animation:spin 0.7s linear infinite}}}}}@keyframes spin{to{transform:rotate(360deg)}}:host(.max){height:100vh;width:100vw;position:fixed;top:0;left:0;z-index:9999}@container (max-width: 699px){:host .listing main .content table thead th:nth-child(4),:host .listing main .content table tbody td:nth-child(4){display:none}}@container (max-width: 635px){:host .listing main .content table thead th:nth-child(3),:host .listing main .content table tbody td:nth-child(3){display:none}}@container (max-width: 530px){:host .listing main .content table thead th:nth-child(5),:host .listing main .content table tbody td:nth-child(5){display:none}:host .listing footer .status{display:none}}@container (max-width: 370px){:host .listing main .content table thead th:nth-child(2),:host .listing main .content table tbody td:nth-child(2){display:none}:host .listing main .content table thead th:first-child,:host .listing main .content table tbody td:first-child{width:100%;min-width:0;max-width:none}:host .listing main .content table tbody td:first-child .name{max-width:100%}}@container (max-width: 295px){:host .listing main .content table tbody td:first-child .name{max-width:120px}}"}},[513,"phirepass-sftp-client",{name:[1],description:[1],hideHeader:[4,"hide-header"],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"],max:[32],show_login_screen:[32],show_login_screen_username:[32],show_error:[32],error_message:[32],show_login_screen_password:[32],show_navigation:[32],breadcrumbs:[32],current_dir:[32],listing:[32],show_content:[32],show_loader:[32],version:[32],status:[32],selected_item:[32],show_upload_modal:[32],upload_progress:[32],upload_file_name:[32],upload_speed:[32],upload_finished:[32],show_download_modal:[32],download_progress:[32],download_file_name:[32],download_speed:[32],download_finished:[32],show_delete_modal:[32],delete_file_name:[32],delete_loading:[32],maximize:[64],minimize:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function b(){"undefined"!=typeof customElements&&["phirepass-sftp-client"].forEach((t=>{"phirepass-sftp-client"===t&&(customElements.get(e(t))||customElements.define(e(t),h))}))}b();const g=h,p=b;export{g as PhirepassSftpClient,p as defineCustomElement}
@@ -1,4 +1,4 @@
1
- import{t,p as i,H as s,c as e,h,a as r}from"./index.js";import{I as n,_ as o,C as l,a,P as u,E as c}from"./p-C4LC8KfO.js";
1
+ import{t,p as i,H as s,c as e,h,a as r}from"./index.js";import{I as n,_ as o,C as l,a,P as u,E as c}from"./p-DdpMFZgO.js";
2
2
  /**
3
3
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
4
4
  * @license MIT
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-DovZQ7sb.js';
2
- import { _ as __wbg_init, E as ErrorType, C as Channel, a as ConnectionState, P as ProtocolMessageType } from './protocol-C4LC8KfO.js';
2
+ import { _ as __wbg_init, E as ErrorType, C as Channel, a as ConnectionState, P as ProtocolMessageType } from './protocol-DdpMFZgO.js';
3
3
 
4
4
  const phirepassSftpClientLogoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==';
5
5
 
@@ -422,14 +422,6 @@ const PhirepassSftpClient = class {
422
422
  });
423
423
  this.pendingDownloadStarts.delete(web.msg_id);
424
424
  }
425
- request_next_download_chunk(msgId) {
426
- const download = this.activeDownloads.get(msgId);
427
- if (!download || !this.session_id) {
428
- return;
429
- }
430
- this.channel.send_sftp_download_chunk(this.nodeId, this.session_id, download.download_id, download.nextChunkToRequest, msgId);
431
- download.nextChunkToRequest += 1;
432
- }
433
425
  finalize_download(msgId) {
434
426
  const download = this.activeDownloads.get(msgId);
435
427
  if (!download) {
@@ -461,18 +453,19 @@ const PhirepassSftpClient = class {
461
453
  return;
462
454
  }
463
455
  const download = this.activeDownloads.get(web.msg_id);
464
- if (!download) {
456
+ if (!download || !this.session_id) {
465
457
  return;
466
458
  }
467
459
  const chunkData = new Uint8Array(web.chunk.data);
468
460
  download.chunks.set(web.chunk.chunk_index, chunkData);
469
461
  const receivedBytes = Array.from(download.chunks.values()).reduce((sum, data) => sum + data.length, 0);
470
462
  this.update_download_progress(receivedBytes, download.total_size, download.startTime);
463
+ // Pipeline ACK: advance the agent's sliding window so it can push the next
464
+ // batch of chunks without waiting for an explicit per-chunk request.
465
+ this.channel.send_sftp_download_ack(this.nodeId, this.session_id, download.download_id, web.chunk.chunk_index);
471
466
  if (download.chunks.size >= download.total_chunks) {
472
467
  this.finalize_download(web.msg_id);
473
- return;
474
468
  }
475
- this.request_next_download_chunk(web.msg_id);
476
469
  }
477
470
  async start_download(item) {
478
471
  if (!this.session_id) {
@@ -493,7 +486,6 @@ const PhirepassSftpClient = class {
493
486
  total_chunks: 0,
494
487
  total_size: 0,
495
488
  download_id: 0,
496
- nextChunkToRequest: 0,
497
489
  startTime: Date.now(),
498
490
  });
499
491
  const downloadStart = new Promise((resolve, reject) => {
@@ -517,8 +509,8 @@ const PhirepassSftpClient = class {
517
509
  download.download_id = download_id;
518
510
  download.total_chunks = total_chunks;
519
511
  download.total_size = total_size;
520
- download.nextChunkToRequest = 0;
521
- this.request_next_download_chunk(msgId);
512
+ // Pipelined: agent pushes chunks immediately after SFTPDownloadStartResponse;
513
+ // no explicit per-chunk request is needed to start the flow.
522
514
  }
523
515
  catch (err) {
524
516
  this.activeDownloads.delete(msgId);
@@ -931,18 +923,18 @@ const PhirepassSftpClient = class {
931
923
  return `${typeChar}${chars.join('')}`;
932
924
  }
933
925
  render() {
934
- return (h(Host, { key: '4a0c122426a92a92e3a7121d8adecbefe5eaf852', class: {
926
+ return (h(Host, { key: '733fe85191c976aa3f1a1888aaf6b8ac66b78bce', class: {
935
927
  'default': !this.max,
936
928
  'max': this.max,
937
- } }, h("section", { key: 'f408645cf18f728c09e7af174f5eb30b5d37ca3b', class: "listing" }, !this.hideHeader &&
938
- h("header", { key: '42fbffd05631ab758d4a9647b4bda41cb5b77b0a' }, h("section", { key: '9b67a0e72219f287d8458bb8ce271789ec653dc7', class: "title" }, h("img", { key: '0eb4b3588b0631d4e93827f74111650d3bed26c4', src: phirepassSftpClientLogoSvg, alt: "SFTP Client" }), h("div", { key: '30945973ee86494b0b2c90ead1c178a1f48086fa', class: "text" }, h("div", { key: '716418d9af825dfd974ef96f7c9687f8e08cc4e7', class: "name" }, this.name), h("div", { key: 'eec1114d46f86c0f777b75a98dc21af1fe473f96', class: "description" }, this.description))), h("section", { key: '05aa545ba36f40adabe6d920514a00b50219744e', class: "actions" }, h("div", { key: '036d227279849911bd353ba879600d46d4cd1ab2', class: "action", onClick: () => this.toggle_max() }, h("img", { key: '3087b9252229f3dc401ea984c7e4576dc0bb74cb', src: phirepassSftpClientMaxSvg, alt: "Maximize" })))), h("main", { key: '5f2a69fb252b3df05742f8b74a15a0c9028f372f' }, this.show_navigation && h("nav", { key: '10612928faf505db3a3a2a00df51425540ea97ec', class: "navigation" }, h("div", { key: 'fdaa4662f45fad1b2fa31059f67df9344f7e7428', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index, breadcrumbs) => (h("span", { key: index, class: "breadcrumb-container" }, h("span", { key: index, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index < breadcrumbs.length - 1 && h("img", { class: "arrow", src: phirepassSftpClientChevronSvg }))))), h("section", { key: '71356c63017f5c74eadeabec428a3b7b3809ade2', class: "actions", "aria-label": "SFTP actions" }, h("button", { key: 'eaf88ec4362509efd594f29a38531a8b158ece9f', type: "button", class: "action", onClick: () => this.go_to_parent_directory(), title: "Go to parent directory", "aria-label": "Go to parent directory" }, h("img", { key: 'b1d5c6a632e22d64f829dbbd7139b859006dbd7a', src: phirepassSftpClientGoUpSvg, alt: "Go up" })), h("button", { key: '94abac9e1a6984872c4c85e66aa448d11621e980', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, h("img", { key: 'd953e97de3411cd1a526c6e1fe042db0ddc673e5', src: phirepassSftpClientRefreshSvg, alt: "Refresh" })), h("button", { key: '03598d60ae17c54493b1572f53c267b765008766', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, h("img", { key: 'c39ee38d8e584c35155035aeb37403d4a89372ba', src: phirepassSftpClientUploadSvg, alt: "Upload" })), h("button", { key: '7e017137f2588bb7a231ef76e874b85e3c1c112d', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), h("input", { key: '2956f9ad2124f813d848ace2206312ee81a4e145', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && h("div", { key: '451d0758c8b71ac9c720f4ad07c5fa3a7011b43e', class: "content" }, h("table", { key: '27a87bfdc1e357a15ff578cae12f41fb768be576' }, h("thead", { key: 'c8161cd9ff7e2bdf0579b3aa9797bd2366b106e8' }, h("tr", { key: '23dc88a5b43a77bb1ab031f72e01996c0e16d4de' }, h("th", { key: '460827f1703d2c7165df2e07b2d873d71a842c6f' }, "Name"), h("th", { key: '6960f731ba9b30012d1772911899714ad6ea5e10' }, "Size"), h("th", { key: '71ae2e8bd6c7ba2110470b651aed9cda0ef2b88f' }, "Permissions"), h("th", { key: '6e8e87a11812570c5bbfebadf4793eafe15e6237' }, "Owner"), h("th", { key: 'b0001ae77eb5c4958434558c715aa5b23e336da2' }, "Modified"), h("th", { key: '3eb862c25e9734c1a2c99fe07ea804761d9578e9', class: "action-col", "aria-label": "Actions" }))), h("tbody", { key: 'b80916d2917e97c9e4058195c5d5d20e98702d60' }, this.listing.map((item, index) => (h("tr", { key: index, class: {
929
+ } }, h("section", { key: 'd2282996dfa3970f6e60713417872958b0273257', class: "listing" }, !this.hideHeader &&
930
+ h("header", { key: 'c270d12cf1da32374f0bdcb650f3ad4f6e6701c1' }, h("section", { key: '670335955f4f453d687c5315fe4e9b4b64c69ff7', class: "title" }, h("img", { key: '9c4be4e7366ff1e3cd11d633b31beb625671be2b', src: phirepassSftpClientLogoSvg, alt: "SFTP Client" }), h("div", { key: 'bcb3764dc20d9d6b01fca4b3d9a7d4371a621403', class: "text" }, h("div", { key: 'bf036e8de51caf4fb468051edd0625e30ade4f62', class: "name" }, this.name), h("div", { key: '9f042ed7412611dde5cacf7e66a7373049175da3', class: "description" }, this.description))), h("section", { key: '46028c58138f41f8cfb0f355fd403cfbeada8559', class: "actions" }, h("div", { key: '2613d4578a05d5b4ba5a27a6d7f0bb199692305c', class: "action", onClick: () => this.toggle_max() }, h("img", { key: 'afbd51291e77e0a34bc429eacc3f92aafa72e65e', src: phirepassSftpClientMaxSvg, alt: "Maximize" })))), h("main", { key: '200d355da53b9a777d870d472c279dc93cfae8ee' }, this.show_navigation && h("nav", { key: 'a2a6d1f87818c9abfb8be2fbe7198ef3986efab5', class: "navigation" }, h("div", { key: 'b6d8104e7063e4011efd6510fc6f3fa33ad0c28d', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index, breadcrumbs) => (h("span", { key: index, class: "breadcrumb-container" }, h("span", { key: index, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index < breadcrumbs.length - 1 && h("img", { class: "arrow", src: phirepassSftpClientChevronSvg }))))), h("section", { key: '86b69b8d759e1fc8a52c7f3f1cd90c318d1d413d', class: "actions", "aria-label": "SFTP actions" }, h("button", { key: 'c69af8d208771d2788d055fa92fb396f567972e1', type: "button", class: "action", onClick: () => this.go_to_parent_directory(), title: "Go to parent directory", "aria-label": "Go to parent directory" }, h("img", { key: 'e7c0eaf4d8983369a68506084e77f20cc29184c8', src: phirepassSftpClientGoUpSvg, alt: "Go up" })), h("button", { key: '0e8b47e93b2825bc0e60b0c75d961609c2b98158', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, h("img", { key: '1a8d0178825ac27fb85584a36bd2d660fe09c135', src: phirepassSftpClientRefreshSvg, alt: "Refresh" })), h("button", { key: 'fddbb65e05c0a9d800dc901bea49c9352099085d', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, h("img", { key: 'cbb5517d854064846a05ee56ef959ed79308b9ad', src: phirepassSftpClientUploadSvg, alt: "Upload" })), h("button", { key: '15f521ad9359057a75fc13ab0336fd9803b9c432', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), h("input", { key: '48f7a635ea1e93a60e5b64042e730b3af5816ce9', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && h("div", { key: '7a977051ab3ccd46524a53c590e52c33904375e4', class: "content" }, h("table", { key: '0ac3ae940c7ae094ca99a1c07b37980a9d5a06c4' }, h("thead", { key: 'f8141383e987cd435a4f89b9d85b5d373559ec1c' }, h("tr", { key: '88479b89f19e1364afaf284b7947c754457c2aa5' }, h("th", { key: '1ad5c30387a14041ff7f45e1caaffe39c4972b3f' }, "Name"), h("th", { key: 'b80c51a07e6e144b8d21698b1a4e6116eb36cb3a' }, "Size"), h("th", { key: '9265bd2250aeb15ff19224f3247b0ec4c8678d7c' }, "Permissions"), h("th", { key: '6c9488fced66224aee51e9193b7beb4d0ea05a04' }, "Owner"), h("th", { key: 'b741ca68c2ec44243160d5e9f64271c488381713' }, "Modified"), h("th", { key: 'a6717e7f50003dc7cb14c2c46b5141afaca3eef1', class: "action-col", "aria-label": "Actions" }))), h("tbody", { key: '2406bf5112dff02abcb4952a19718398b43e6635' }, this.listing.map((item, index) => (h("tr", { key: index, class: {
939
931
  'selected': this.is_selected(item),
940
932
  }, onClick: () => this.list_directory(item) }, h("td", null, item.kind === 'Folder' ? h("img", { class: "kind", src: phirepassSftpClientFolderSvg, alt: "Folder" }) : h("img", { class: "kind", src: phirepassSftpClientFileSvg, alt: "File" }), h("span", { class: `name ${item.kind.toLowerCase()}` }, item.name)), h("td", null, this.format_size(item.attributes.size)), h("td", null, this.format_permissions(item.attributes.permissions, item.kind)), h("td", null, item.attributes.user ?? '-'), h("td", null, new Date(item.attributes.modified * 1000).toLocaleString()), h("td", { class: "action-col" }, item.kind === 'File' &&
941
- h("div", { class: "file-actions" }, h("button", { type: "button", class: "file-action", onClick: (event) => this.on_file_row_action(item, event), title: "Download", "aria-label": "Download" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), h("polyline", { points: "7 10 12 15 17 10" }), h("line", { x1: "12", x2: "12", y1: "15", y2: "3" }))), h("button", { type: "button", class: "file-action delete", onClick: (event) => this.on_file_delete_action(item, event), title: "Delete", "aria-label": "Delete" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("polyline", { points: "3 6 5 6 21 6" }), h("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), h("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }), h("line", { x1: "10", x2: "10", y1: "11", y2: "17" }), h("line", { x1: "14", x2: "14", y1: "11", y2: "17" }))))))))))), this.show_loader && h("div", { key: '6698d4f3a2f60efa264ac5d4a3e35da14c1b47d5', class: "loader" }, "Loading..."), this.show_error && h("div", { key: '411d74aa5574e444eb4f08d7ecec37fbe9c54a37', class: "error" }, this.error_message)), h("footer", { key: 'a58fb0f412a403f930cbdca15269678cf92037f9' }, h("section", { key: '8a989e00a03d5d3290599131989ddef872444e9b', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
942
- h("section", { key: '8f070e03986f073de9ca90ea2f46cd0d485a0a8c', class: {
933
+ h("div", { class: "file-actions" }, h("button", { type: "button", class: "file-action", onClick: (event) => this.on_file_row_action(item, event), title: "Download", "aria-label": "Download" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), h("polyline", { points: "7 10 12 15 17 10" }), h("line", { x1: "12", x2: "12", y1: "15", y2: "3" }))), h("button", { type: "button", class: "file-action delete", onClick: (event) => this.on_file_delete_action(item, event), title: "Delete", "aria-label": "Delete" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("polyline", { points: "3 6 5 6 21 6" }), h("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), h("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }), h("line", { x1: "10", x2: "10", y1: "11", y2: "17" }), h("line", { x1: "14", x2: "14", y1: "11", y2: "17" }))))))))))), this.show_loader && h("div", { key: 'aa63f480151a0143183f8769413bbf1d8bad517a', class: "loader" }, "Loading..."), this.show_error && h("div", { key: '3ca7fe377368a520de804391d8939627e956e3d0', class: "error" }, this.error_message)), h("footer", { key: '71a1233b255561b5e0cf4408c268ab399982cb7f' }, h("section", { key: '5533f9b423be66da41ff7128b903e09bcd447c4c', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
934
+ h("section", { key: '6dc948c828b479b6d706dbcca3b3075e58757cef', class: {
943
935
  'creds': true,
944
936
  'blurred': this.show_login_screen,
945
- } }, h("form", { key: 'f8d6b2455ecf15e6ef19f1058c86100d7fe36357', class: "auth", onSubmit: (event) => {
937
+ } }, h("form", { key: 'a7f60c3dcc672cc18f1ec67a45495eb756ae9c92', class: "auth", onSubmit: (event) => {
946
938
  const formData = new FormData(event.target);
947
939
  let username = undefined;
948
940
  if (this.show_login_screen_username) {
@@ -959,28 +951,28 @@ const PhirepassSftpClient = class {
959
951
  this.show_loader = true;
960
952
  event.stopPropagation();
961
953
  event.preventDefault();
962
- } }, h("div", { key: '870343a9f67b01ce620c88ab3af2d823e9c109da', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
963
- h("div", { key: 'd32b19a3d0e89196247358ca846fd6108fe15128' }, h("label", { key: 'c60053d805db2357780bb986c71f6b839390ca20', htmlFor: "username" }, "Username"), h("input", { key: '73c368508cc63db7ff5d7c7ca1d3f12a6e409926', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
964
- h("div", { key: 'c5a91b121c0309e577ca63a5392dce7b982e6429' }, h("label", { key: 'b3adfc6963d418f9a7748092a661f87a77949f1d', htmlFor: "password" }, "Password"), h("input", { key: '0e6855eb8e7ef22e6981e5c7df429d4bc81e8d67', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), h("div", { key: '05377a2061e222afada603838feaac68b913be1b' }, h("button", { key: '4d28615b22f083ad8b7430a3babe2a5dbc9c4f90', type: "submit" }, "Connect")))), this.show_upload_modal &&
965
- h("section", { key: '7979af0ec1f92bf78a94d5e1be2a7b7a79b780be', class: {
954
+ } }, h("div", { key: 'b0f3c4b74c59590624d4944b8d6ccd5a45b6065c', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
955
+ h("div", { key: '2d6d9424cd170e087cc6f17d55c8cf1461a06988' }, h("label", { key: 'e420f513abc053a99c0e61c27716ff39f0527827', htmlFor: "username" }, "Username"), h("input", { key: 'c50aff8ff53e8ed3b3dbb5d0cc85055b247864cf', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
956
+ h("div", { key: '8f49b0425783375996484b536c58f07414215b44' }, h("label", { key: 'ed739b253b2bfa7dc6bab37dbf184b0c9eacf657', htmlFor: "password" }, "Password"), h("input", { key: 'd1be51c537fb0461678ede0e940fd312d96c1517', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), h("div", { key: '66da4c8d32459483a1b0329473287e89a82c5e4c' }, h("button", { key: 'cf5a2534f2a6abc344e999520bb4328c4dadd090', type: "submit" }, "Connect")))), this.show_upload_modal &&
957
+ h("section", { key: 'b678714eff09b18b7932e936ae4dee366aa98b4e', class: {
966
958
  'upload-modal': true,
967
959
  'visible': this.show_upload_modal,
968
- } }, h("div", { key: '55132c16758312e55fd7bb5bb32dfcd557500838', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, h("div", { key: '7b808945f2123b5c1e8ed300cba85f3325be643e', class: "title" }, "Uploading File"), h("div", { key: '0c7065ccff128f524eee7da248eee97f78819bc0', class: "file-name", title: this.upload_file_name }, this.upload_file_name), h("div", { key: '848d3526b2cff55c6cc6eab0a4cb536264f14d80', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, h("div", { key: 'a3f8d7c47971866243a5138ae1e5b84fe50fa008', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), h("div", { key: '6675b28ce14fa0f3d84cbfcc602409f6ba650a13', class: "progress-meta" }, h("div", { key: '5205d72ab81c7bfc906fcfe827b05933440161b8', class: "progress-speed" }, this.upload_speed), h("div", { key: 'c3f59de705696ac1355629ac0397e1a9baf56a0a', class: "progress-value" }, this.format_percent(this.upload_progress))), h("button", { key: '06d9bc2f61d7f83361ad97b7bb23f2f45b11ec27', type: "button", class: {
960
+ } }, h("div", { key: 'c4fa4e401c192e705207df634d2f93943ce77af5', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, h("div", { key: '18ff3a246aa39f28474ced7cce76ace778922a2f', class: "title" }, "Uploading File"), h("div", { key: 'b08fa6b79f6080e9d60f361021b8bac6a5ed7424', class: "file-name", title: this.upload_file_name }, this.upload_file_name), h("div", { key: '9efc45e387d8156a18afb90d5531df4ebfa64328', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, h("div", { key: 'c988402fedde675d04bc7b2054da4e319c2af082', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), h("div", { key: '1d0d8f845d3bfa817aec865598cffa59f55505f4', class: "progress-meta" }, h("div", { key: '5b983ed819d48105c3fb0a71b2d2d62f7f46003c', class: "progress-speed" }, this.upload_speed), h("div", { key: '859bb76ff953d69ddaa710574bb1c72b92968f5a', class: "progress-value" }, this.format_percent(this.upload_progress))), h("button", { key: '41d970d2112e63f931c5a5513bb580559f9e619b', type: "button", class: {
969
961
  'cancel': true,
970
962
  'finished': this.upload_finished,
971
963
  }, onClick: () => this.cancel_upload() }, this.upload_finished ? 'Close' : 'Cancel'))), this.show_download_modal &&
972
- h("section", { key: '7217722972f463d2893bd44ac5a4899c8fe545a7', class: {
964
+ h("section", { key: 'd9bfadbc2d3a164bc05811a7f2e9024a914ecbc8', class: {
973
965
  'download-modal': true,
974
966
  'visible': this.show_download_modal,
975
- } }, h("div", { key: '493dddfad5d25411a3421641ef930eab561347b4', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, h("div", { key: '2115492e8360a19edf260c7c603bc44e736cccec', class: "title" }, "Downloading File"), h("div", { key: '5582b3ea56c9a184ff1b6de4ca89b93f07461847', class: "file-name", title: this.download_file_name }, this.download_file_name), h("div", { key: '90df12daa47066e7a212edeec5760cef2abc52c6', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, h("div", { key: '2c3c6ef5b7091ea010c4fc9037d05db5845f4e23', class: "progress-fill", style: { width: `${this.download_progress}%` } })), h("div", { key: '9d963e08afe1e073f19fc9195cd66f67a874204f', class: "progress-meta" }, h("div", { key: '96508c5a2a95ce9889d947bc4786403785b15c75', class: "progress-speed" }, this.download_speed), h("div", { key: '3f0cab67e511efda1cf79111705525b9838eb410', class: "progress-value" }, this.format_percent(this.download_progress))), h("button", { key: 'cac13e01231ba4c1713b85e7b7ac661b1ec6f6e5', type: "button", class: {
967
+ } }, h("div", { key: '1f874ba0e526b99d2b41beaf8023cbada567ecc8', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, h("div", { key: 'ac2b5f65423e7e2b20ffecf864477e849b737259', class: "title" }, "Downloading File"), h("div", { key: '639d6fe5a64db1aa53b077eb318fa21d72a551ed', class: "file-name", title: this.download_file_name }, this.download_file_name), h("div", { key: 'e90546d4dceab157f4599b2ffd31f1eb4eb9d18c', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, h("div", { key: 'eeb597904e31a6aa9717cc4e6fc534ae68924dee', class: "progress-fill", style: { width: `${this.download_progress}%` } })), h("div", { key: '1bbf952144d17c374de6948ad94bc4deed7ae8a0', class: "progress-meta" }, h("div", { key: '049f748019b11cea95f236202cd48c758e99411a', class: "progress-speed" }, this.download_speed), h("div", { key: '01b8d063a3fdfe8cc9df21e75833df3a6c2eda49', class: "progress-value" }, this.format_percent(this.download_progress))), h("button", { key: 'a87560c1555bf8a6dea73a424792b3af25e06a68', type: "button", class: {
976
968
  'cancel': true,
977
969
  'finished': this.download_finished,
978
970
  }, onClick: () => this.cancel_download() }, this.download_finished ? 'Close' : 'Cancel'))), this.show_delete_modal &&
979
- h("section", { key: 'e66cc06cb588d7842a4557041a5fa617b2672b0b', class: {
971
+ h("section", { key: '7e547c5f320acc9920020a4bcafc21ca57d6ad66', class: {
980
972
  'delete-modal': true,
981
973
  'visible': this.show_delete_modal,
982
- } }, h("div", { key: 'ac2298da9dde4e4043f29a8b2b137fe7f2e0f5dc', class: "delete-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Delete confirmation" }, h("div", { key: 'ac53826a41c03e3cb94296c30e622f453bca0f40', class: "title" }, "Delete File"), h("div", { key: '9724627c77b3242f25e7d73b18bae820833cdb9f', class: "message" }, this.delete_loading ? 'Deleting file...' : 'Are you sure you want to delete this file?'), h("div", { key: '408ece6999a858d60baf7bd34b3133d07aba8806', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_loading &&
983
- h("div", { key: '6f157f39e1097a355c139af9ea0e35ee76a04117', class: "delete-loader", "aria-hidden": "true" }, h("span", { key: 'bd85fe1e6dfc09febebcd1c31fc99629d1f4429d', class: "spinner" })), h("div", { key: 'ad4f19824730b61e82e8ad205d5ea0cc2e715a7f', class: "modal-actions" }, h("button", { key: '9d95213a54aefc8064769796f235b4533fc5aa08', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), h("button", { key: 'd423c0537eb372ed491387c45e6a5c5f5a975259', type: "button", class: "btn destructive", onClick: () => this.confirm_delete(), disabled: this.delete_loading }, this.delete_loading ? 'Deleting...' : 'Delete'))))));
974
+ } }, h("div", { key: 'b79c2be285b8e2af00189cd69143950f133f5722', class: "delete-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Delete confirmation" }, h("div", { key: 'b25d1669edded42eae34ac15887428d85a3e8577', class: "title" }, "Delete File"), h("div", { key: 'da2a16b8f85ae7dc7d09aa2ffe4562124642233f', class: "message" }, this.delete_loading ? 'Deleting file...' : 'Are you sure you want to delete this file?'), h("div", { key: '702dfa13f1e9b828c2d956cab0c1fcc557c80bb1', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_loading &&
975
+ h("div", { key: '1e2b57c73dad6f463c3377c16ae407cc553232e3', class: "delete-loader", "aria-hidden": "true" }, h("span", { key: '40338e85202b89cb8b2fea8adddf10323fa91a25', class: "spinner" })), h("div", { key: 'e0b264439056ab3e7f49f5dd221b5f58ea720d2e', class: "modal-actions" }, h("button", { key: 'ee6932fa56c02bca43c6ce914cec55ca9dbfd48a', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), h("button", { key: '2c26e30cc0942f532996a3b485ad77fb11c2d214', type: "button", class: "btn destructive", onClick: () => this.confirm_delete(), disabled: this.delete_loading }, this.delete_loading ? 'Deleting...' : 'Delete'))))));
984
976
  }
985
977
  static get watchers() { return {
986
978
  "nodeId": [{
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, g as getElement, h as h$1, H as Host } from './index-DovZQ7sb.js';
2
- import { I as InputMode, _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType, E as ErrorType } from './protocol-C4LC8KfO.js';
2
+ import { I as InputMode, _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType, E as ErrorType } from './protocol-DdpMFZgO.js';
3
3
 
4
4
  /**
5
5
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
@@ -189,6 +189,20 @@ class Channel {
189
189
  const len2 = WASM_VECTOR_LEN;
190
190
  wasm.channel_send_sftp_delete(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1, ptr2, len2, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
191
191
  }
192
+ /**
193
+ * Send a pipelining ACK to the agent: acknowledges all chunks with index ≤ ack_up_to
194
+ * so the agent's sliding window advances and it can push the next batch.
195
+ * Call this after processing each received SFTPDownloadChunk (or every N chunks).
196
+ * @param {string} node_id
197
+ * @param {number} sid
198
+ * @param {number} download_id
199
+ * @param {number} ack_up_to
200
+ */
201
+ send_sftp_download_ack(node_id, sid, download_id, ack_up_to) {
202
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
203
+ const len0 = WASM_VECTOR_LEN;
204
+ wasm.channel_send_sftp_download_ack(this.__wbg_ptr, ptr0, len0, sid, download_id, ack_up_to);
205
+ }
192
206
  /**
193
207
  * @param {string} node_id
194
208
  * @param {number} sid
@@ -377,7 +391,7 @@ function __wbg_get_imports() {
377
391
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
378
392
  return addHeapObject(ret);
379
393
  }, arguments); },
380
- __wbg_info_c397415406abbd0f: function(arg0, arg1) {
394
+ __wbg_info_7e60b0839637b648: function(arg0, arg1) {
381
395
  console.info(getStringFromWasm0(arg0, arg1));
382
396
  },
383
397
  __wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
@@ -449,7 +463,7 @@ function __wbg_get_imports() {
449
463
  __wbg_set_onopen_db452f4233e99d7d: function(arg0, arg1) {
450
464
  getObject(arg0).onopen = getObject(arg1);
451
465
  },
452
- __wbg_warn_1445997d33882ef8: function(arg0, arg1) {
466
+ __wbg_warn_175986b719b7c712: function(arg0, arg1) {
453
467
  console.warn(getStringFromWasm0(arg0, arg1));
454
468
  },
455
469
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
@@ -1,4 +1,4 @@
1
- import{r as t,c as i,g as s,h as e,H as h}from"./p-DovZQ7sb.js";import{I as r,_ as n,C as o,a as l,P as a,E as u}from"./p-C4LC8KfO.js";
1
+ import{r as t,c as i,g as s,h as e,H as h}from"./p-DovZQ7sb.js";import{I as r,_ as n,C as o,a as l,P as a,E as u}from"./p-DdpMFZgO.js";
2
2
  /**
3
3
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
4
4
  * @license MIT
@@ -0,0 +1 @@
1
+ class n{__destroy_into_raw(){const n=this.__wbg_ptr;return this.__wbg_ptr=0,_.unregister(this),n}free(){const n=this.__destroy_into_raw();O.__wbg_channel_free(n,0)}authenticate(n,t,e){const r=S(n,O.__wbindgen_export,O.__wbindgen_export2),o=P,c=S(t,O.__wbindgen_export,O.__wbindgen_export2);O.channel_authenticate(this.__wbg_ptr,r,o,c,P,A(e)?Number.MAX_SAFE_INTEGER:e>>>0)}connect(){O.channel_connect(this.__wbg_ptr)}disable_service(n,t,e,r,o,c,i){const s=S(n,O.__wbindgen_export,O.__wbindgen_export2),_=P,u=S(t,O.__wbindgen_export,O.__wbindgen_export2),a=P,f=S(e,O.__wbindgen_export,O.__wbindgen_export2),b=P;var l=A(o)?0:S(o,O.__wbindgen_export,O.__wbindgen_export2),d=P,w=A(c)?0:S(c,O.__wbindgen_export,O.__wbindgen_export2);O.channel_disable_service(this.__wbg_ptr,s,_,u,a,f,b,r,l,d,w,P,A(i)?Number.MAX_SAFE_INTEGER:i>>>0)}disconnect(){O.channel_disconnect(this.__wbg_ptr)}enable_service(n,t,e,r,o,c,i){const s=S(n,O.__wbindgen_export,O.__wbindgen_export2),_=P,u=S(t,O.__wbindgen_export,O.__wbindgen_export2),a=P,f=S(e,O.__wbindgen_export,O.__wbindgen_export2),b=P;var l=A(o)?0:S(o,O.__wbindgen_export,O.__wbindgen_export2),d=P,w=A(c)?0:S(c,O.__wbindgen_export,O.__wbindgen_export2);O.channel_enable_service(this.__wbg_ptr,s,_,u,a,f,b,r,l,d,w,P,A(i)?Number.MAX_SAFE_INTEGER:i>>>0)}is_connected(){return 0!==O.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==O.channel_is_disconnected(this.__wbg_ptr)}constructor(n,t,e){const r=S(n,O.__wbindgen_export,O.__wbindgen_export2),o=P,c=S(t,O.__wbindgen_export,O.__wbindgen_export2),i=P;var s=A(e)?0:S(e,O.__wbindgen_export,O.__wbindgen_export2);const u=O.channel_new(r,o,c,i,s,P);return this.__wbg_ptr=u,_.register(this,this.__wbg_ptr,this),this}on_connection_close(n){O.channel_on_connection_close(this.__wbg_ptr,A(n)?0:u(n))}on_connection_error(n){O.channel_on_connection_error(this.__wbg_ptr,A(n)?0:u(n))}on_connection_message(n){O.channel_on_connection_message(this.__wbg_ptr,A(n)?0:u(n))}on_connection_open(n){O.channel_on_connection_open(this.__wbg_ptr,A(n)?0:u(n))}on_protocol_message(n){O.channel_on_protocol_message(this.__wbg_ptr,A(n)?0:u(n))}on_protocol_message_type(n,t){const e=S(n,O.__wbindgen_export,O.__wbindgen_export2);O.channel_on_protocol_message_type(this.__wbg_ptr,e,P,A(t)?0:u(t))}open_sftp_tunnel(n,t,e,r){const o=S(n,O.__wbindgen_export,O.__wbindgen_export2),c=P;var i=A(t)?0:S(t,O.__wbindgen_export,O.__wbindgen_export2),s=P,_=A(e)?0:S(e,O.__wbindgen_export,O.__wbindgen_export2);O.channel_open_sftp_tunnel(this.__wbg_ptr,o,c,i,s,_,P,A(r)?Number.MAX_SAFE_INTEGER:r>>>0)}open_ssh_tunnel(n,t,e,r){const o=S(n,O.__wbindgen_export,O.__wbindgen_export2),c=P;var i=A(t)?0:S(t,O.__wbindgen_export,O.__wbindgen_export2),s=P,_=A(e)?0:S(e,O.__wbindgen_export,O.__wbindgen_export2);O.channel_open_ssh_tunnel(this.__wbg_ptr,o,c,i,s,_,P,A(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_delete(n,t,e,r,o){const c=S(n,O.__wbindgen_export,O.__wbindgen_export2),i=P,s=S(e,O.__wbindgen_export,O.__wbindgen_export2),_=P,u=S(r,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_sftp_delete(this.__wbg_ptr,c,i,t,s,_,u,P,A(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_ack(n,t,e,r){const o=S(n,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_sftp_download_ack(this.__wbg_ptr,o,P,t,e,r)}send_sftp_download_chunk(n,t,e,r,o){const c=S(n,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_sftp_download_chunk(this.__wbg_ptr,c,P,t,e,r,A(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_start(n,t,e,r,o){const c=S(n,O.__wbindgen_export,O.__wbindgen_export2),i=P,s=S(e,O.__wbindgen_export,O.__wbindgen_export2),_=P,u=S(r,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_sftp_download_start(this.__wbg_ptr,c,i,t,s,_,u,P,A(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_list_data(n,t,e,r){const o=S(n,O.__wbindgen_export,O.__wbindgen_export2),c=P,i=S(e,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_sftp_list_data(this.__wbg_ptr,o,c,t,i,P,A(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_upload_chunk(n,t,e,r,o,c,i){const s=S(n,O.__wbindgen_export,O.__wbindgen_export2),_=P,u=function(n){const t=(0,O.__wbindgen_export)(1*n.length,1)>>>0;return h().set(n,t/1),P=n.length,t}(c);O.channel_send_sftp_upload_chunk(this.__wbg_ptr,s,_,t,e,r,o,u,P,A(i)?Number.MAX_SAFE_INTEGER:i>>>0)}send_sftp_upload_start(n,t,e,r,o,c,i){const s=S(n,O.__wbindgen_export,O.__wbindgen_export2),_=P,u=S(e,O.__wbindgen_export,O.__wbindgen_export2),a=P,f=S(r,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_sftp_upload_start(this.__wbg_ptr,s,_,t,u,a,f,P,o,c,A(i)?Number.MAX_SAFE_INTEGER:i>>>0)}send_ssh_terminal_resize(n,t,e,r,o,c){const i=S(n,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_ssh_terminal_resize(this.__wbg_ptr,i,P,t,e,r,o,c)}send_ssh_tunnel_data(n,t,e){const r=S(n,O.__wbindgen_export,O.__wbindgen_export2),o=P,c=S(e,O.__wbindgen_export,O.__wbindgen_export2);O.channel_send_ssh_tunnel_data(this.__wbg_ptr,r,o,t,c,P)}start_heartbeat(n){O.channel_start_heartbeat(this.__wbg_ptr,n)}stop_heartbeat(){O.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);const t=Object.freeze({Generic:0,0:"Generic",Authentication:10,10:"Authentication",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword",RequiresUsernamePassword:120,120:"RequiresUsernamePassword"});function e(){const n={__proto__:null,__wbg_Error_ef53bc310eb298a0:function(n,t){return u(Error(w(n,t)))},__wbg_String_8564e559799eccda:function(n,t){const e=S(String(p(t)),O.__wbindgen_export,O.__wbindgen_export2),r=P;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_debug_string_0accd80f45e5faa2:function(n,t){const e=S(f(p(t)),O.__wbindgen_export,O.__wbindgen_export2),r=P;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_string_get_72bdf95d3ae505b1:function(n,t){const e=p(t),r="string"==typeof e?e:void 0;var o=A(r)?0:S(r,O.__wbindgen_export,O.__wbindgen_export2),c=P;d().setInt32(n+4,c,!0),d().setInt32(n+0,o,!0)},__wbg___wbindgen_throw_1506f2235d1bdba0:function(n,t){throw new Error(w(n,t))},__wbg__wbg_cb_unref_61db23ac97f16c31:function(n){p(n)._wbg_cb_unref()},__wbg_call_40e4174f169eaca7:function(){return y((function(n,t,e,r){return u(p(n).call(p(t),p(e),p(r)))}),arguments)},__wbg_call_8a89609d89f6608a:function(){return y((function(n,t){return u(p(n).call(p(t)))}),arguments)},__wbg_call_9c758de292015997:function(){return y((function(n,t,e){return u(p(n).call(p(t),p(e)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(n){return u(clearInterval(T(n)))},__wbg_close_9acc00cbca310439:function(){return y((function(n){p(n).close()}),arguments)},__wbg_data_bd354b70c783c66e:function(n){return u(p(n).data)},__wbg_from_d300fe49deab18f5:function(n){return u(Array.from(p(n)))},__wbg_get_de6a0f7d4d18a304:function(){return y((function(n,t){return u(Reflect.get(p(n),p(t)))}),arguments)},__wbg_info_7e60b0839637b648:function(n,t){console.info(w(n,t))},__wbg_instanceof_ArrayBuffer_8f49811467741499:function(n){let t;try{t=p(n)instanceof ArrayBuffer}catch(n){t=!1}return t},__wbg_length_4a591ecaa01354d9:function(n){return p(n).length},__wbg_new_578aeef4b6b94378:function(n){return u(new Uint8Array(p(n)))},__wbg_new_ce1ab61c1c2b300d:function(){return u(new Object)},__wbg_new_d90091b82fdf5b91:function(){return u(new Array)},__wbg_new_with_str_sequence_9ed2327430efed8d:function(){return y((function(n,t,e){return u(new WebSocket(w(n,t),p(e)))}),arguments)},__wbg_prototypesetcall_3249fc62a0fafa30:function(n,t,e){Uint8Array.prototype.set.call(b(n,t),p(e))},__wbg_push_a6822215aa43e71c:function(n,t){return p(n).push(p(t))},__wbg_readyState_490503c1fa8f8dd6:function(n){return p(n).readyState},__wbg_send_4a773f523104d75e:function(){return y((function(n,t,e){p(n).send(b(t,e))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return y((function(n,t){return u(setInterval(p(n),t))}),arguments)},__wbg_set_6be42768c690e380:function(n,t,e){p(n)[T(t)]=T(e)},__wbg_set_binaryType_41994c453b95bdd2:function(n,t){p(n).binaryType=s[t]},__wbg_set_dca99999bba88a9a:function(n,t,e){p(n)[t>>>0]=T(e)},__wbg_set_onclose_13787fb31ae8aefd:function(n,t){p(n).onclose=p(t)},__wbg_set_onerror_5a45265839edf1b1:function(n,t){p(n).onerror=p(t)},__wbg_set_onmessage_9c6b4cb14e244b7f:function(n,t){p(n).onmessage=p(t)},__wbg_set_onopen_db452f4233e99d7d:function(n,t){p(n).onopen=p(t)},__wbg_warn_175986b719b7c712:function(n,t){console.warn(w(n,t))},__wbindgen_cast_0000000000000001:function(n,t){return u(R(n,t,o))},__wbindgen_cast_0000000000000002:function(n,t){return u(R(n,t,c))},__wbindgen_cast_0000000000000003:function(n,t){return u(R(n,t,i))},__wbindgen_cast_0000000000000004:function(n,t){return u(R(n,t,r))},__wbindgen_cast_0000000000000005:function(n){return u(n)},__wbindgen_cast_0000000000000006:function(n,t){return u(b(n,t))},__wbindgen_cast_0000000000000007:function(n,t){return u(w(n,t))},__wbindgen_cast_0000000000000008:function(n){return u(BigInt.asUintN(64,n))},__wbindgen_object_clone_ref:function(n){return u(p(n))},__wbindgen_object_drop_ref:function(n){T(n)}};return{__proto__:null,"./phirepass-channel_bg.js":n}}function r(n,t){O.__wasm_bindgen_func_elem_44(n,t)}function o(n,t,e){O.__wasm_bindgen_func_elem_42(n,t,u(e))}function c(n,t,e){O.__wasm_bindgen_func_elem_42_1(n,t,u(e))}function i(n,t,e){O.__wasm_bindgen_func_elem_42_2(n,t,u(e))}const s=["blob","arraybuffer"],_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>O.__wbg_channel_free(n,1)));function u(n){v===m.length&&m.push(m.length+1);const t=v;return v=m[t],m[t]=n,t}const a="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>O.__wbindgen_export4(n.a,n.b)));function f(n){const t=typeof n;if("number"==t||"boolean"==t||null==n)return`${n}`;if("string"==t)return`"${n}"`;if("symbol"==t){const t=n.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=n.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(n)){const t=n.length;let e="[";t>0&&(e+=f(n[0]));for(let r=1;r<t;r++)e+=", "+f(n[r]);return e+="]",e}const e=/\[object ([^\]]+)\]/.exec(toString.call(n));let r;if(!(e&&e.length>1))return toString.call(n);if(r=e[1],"Object"==r)try{return"Object("+JSON.stringify(n)+")"}catch(n){return"Object"}return n instanceof Error?`${n.name}: ${n.message}\n${n.stack}`:r}function b(n,t){return n>>>=0,h().subarray(n/1,n/1+t)}let l=null;function d(){return(null===l||!0===l.buffer.detached||void 0===l.buffer.detached&&l.buffer!==O.memory.buffer)&&(l=new DataView(O.memory.buffer)),l}function w(n,t){return function(n,t){return F+=t,F>=j&&(U=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),U.decode(),F=t),U.decode(h().subarray(n,n+t))}(n>>>0,t)}let g=null;function h(){return null!==g&&0!==g.byteLength||(g=new Uint8Array(O.memory.buffer)),g}function p(n){return m[n]}function y(n,t){try{return n.apply(this,t)}catch(n){O.__wbindgen_export3(u(n))}}let m=new Array(1024).fill(void 0);m.push(void 0,null,!0,!1);let v=m.length;function A(n){return null==n}function R(n,t,e){const r={a:n,b:t,cnt:1},o=(...n)=>{r.cnt++;const t=r.a;r.a=0;try{return e(t,r.b,...n)}finally{r.a=t,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{0==--r.cnt&&(O.__wbindgen_export4(r.a,r.b),r.a=0,a.unregister(r))},a.register(o,r,r),o}function S(n,t,e){if(void 0===e){const e=N.encode(n),r=t(e.length,1)>>>0;return h().subarray(r,r+e.length).set(e),P=e.length,r}let r=n.length,o=t(r,1)>>>0;const c=h();let i=0;for(;i<r;i++){const t=n.charCodeAt(i);if(t>127)break;c[o+i]=t}if(i!==r){0!==i&&(n=n.slice(i)),o=e(o,r,r=i+3*n.length,1)>>>0;const t=h().subarray(o+i,o+r);i+=N.encodeInto(n,t).written,o=e(o,r,i,1)>>>0}return P=i,o}function T(n){const t=p(n);return function(n){n<1028||(m[n]=v,v=n)}(n),t}let U=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});U.decode();const j=2146435072;let F=0;const N=new TextEncoder;"encodeInto"in N||(N.encodeInto=function(n,t){const e=N.encode(n);return t.set(e),{read:n.length,written:e.length}});let O,P=0;async function k(n){if(void 0!==O)return O;void 0!==n&&(Object.getPrototypeOf(n)===Object.prototype?({module_or_path:n}=n):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===n&&(n=new URL("phirepass-channel_bg.wasm",import.meta.url));const t=e();("string"==typeof n||"function"==typeof Request&&n instanceof Request||"function"==typeof URL&&n instanceof URL)&&(n=fetch(n));const{instance:r}=await async function(n,t){if("function"==typeof Response&&n instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(n,t)}catch(t){if(!n.ok||!function(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}(n.type)||"application/wasm"===n.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const e=await n.arrayBuffer();return await WebAssembly.instantiate(e,t)}{const e=await WebAssembly.instantiate(n,t);return e instanceof WebAssembly.Instance?{instance:e,module:n}:e}}(await n,t);return function(n){return O=n.exports,l=null,g=null,O}(r)}var q,I,W;!function(n){n.Error="Error",n.AuthSuccess="AuthSuccess",n.TunnelOpened="TunnelOpened",n.TunnelClosed="TunnelClosed",n.TunnelData="TunnelData",n.SFTPListItems="SFTPListItems",n.SFTPDownloadStartResponse="SFTPDownloadStartResponse",n.SFTPDownloadChunk="SFTPDownloadChunk",n.SFTPUploadStartResponse="SFTPUploadStartResponse",n.SFTPUploadChunkAck="SFTPUploadChunkAck"}(q||(q={})),function(n){n[n.Username=0]="Username",n[n.Password=1]="Password",n[n.Default=2]="Default"}(I||(I={})),function(n){n.Disconnected="disconnected",n.Connected="connected",n.Error="error"}(W||(W={}));export{n as C,t as E,I,q as P,k as _,W as a}