phirepass-widgets 0.0.113 → 0.0.115

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.
Files changed (52) hide show
  1. package/dist/cjs/{index-CurErEK7.js → index-BCgmMoIq.js} +3 -3
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +157 -41
  4. package/dist/cjs/phirepass-rdp.cjs.entry.js +3 -3
  5. package/dist/cjs/phirepass-terminal.cjs.entry.js +4 -4
  6. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  7. package/dist/cjs/{protocol-DCBMfc2u.js → protocol-CYh109n2.js} +252 -21
  8. package/dist/collection/collection-manifest.json +1 -1
  9. package/dist/collection/common/fetch.js +4 -0
  10. package/dist/collection/components/phirepass-downloader/jobs.js +26 -3
  11. package/dist/collection/components/phirepass-downloader/source.js +14 -0
  12. package/dist/collection/components/phirepass-downloader/views/icons.js +1 -0
  13. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +9 -0
  14. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +79 -3
  15. package/dist/collection/components/phirepass-media-player/player.js +24 -0
  16. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +1 -1
  17. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +33 -33
  18. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  19. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  20. package/dist/components/p-BtMWUitf.js +1 -0
  21. package/dist/components/p-DIf-Ru26.js +1 -0
  22. package/dist/components/p-DqT-qhTU.js +1 -0
  23. package/dist/components/phirepass-downloader.js +1 -1
  24. package/dist/components/phirepass-media-player.js +1 -1
  25. package/dist/components/phirepass-rdp.js +1 -1
  26. package/dist/components/phirepass-sftp-client.js +1 -1
  27. package/dist/components/phirepass-terminal.js +2 -2
  28. package/dist/esm/{index-B9qUl6FW.js → index-Dd9o0CbU.js} +3 -3
  29. package/dist/esm/loader.js +3 -3
  30. package/dist/esm/phirepass-downloader_3.entry.js +157 -41
  31. package/dist/esm/phirepass-rdp.entry.js +3 -3
  32. package/dist/esm/phirepass-terminal.entry.js +4 -4
  33. package/dist/esm/phirepass-widgets.js +4 -4
  34. package/dist/esm/{protocol-CsYQJXY2.js → protocol-BtMWUitf.js} +251 -20
  35. package/dist/phirepass-widgets/{p-1b84c526.entry.js → p-2fd32ec5.entry.js} +1 -1
  36. package/dist/phirepass-widgets/{p-41dd1ac9.entry.js → p-705501d4.entry.js} +2 -2
  37. package/dist/phirepass-widgets/p-BtMWUitf.js +1 -0
  38. package/dist/phirepass-widgets/{p-B9qUl6FW.js → p-Dd9o0CbU.js} +2 -2
  39. package/dist/phirepass-widgets/p-b8caf9e1.entry.js +1 -0
  40. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  41. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  42. package/dist/types/common/fetch.d.ts +6 -0
  43. package/dist/types/components/phirepass-downloader/jobs.d.ts +10 -2
  44. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +16 -1
  45. package/dist/types/components/phirepass-media-player/player.d.ts +10 -0
  46. package/dist/types/components.d.ts +10 -2
  47. package/package.json +6 -6
  48. package/dist/components/p-C4cmk3bS.js +0 -1
  49. package/dist/components/p-CsYQJXY2.js +0 -1
  50. package/dist/components/p-D6Geq8Rn.js +0 -1
  51. package/dist/phirepass-widgets/p-614ab3de.entry.js +0 -1
  52. package/dist/phirepass-widgets/p-CsYQJXY2.js +0 -1
@@ -0,0 +1 @@
1
+ import{h as e,r as t,c as i,g as s,H as a}from"./p-Dd9o0CbU.js";import{_ as o,C as n,P as r,E as l,a as d}from"./p-BtMWUitf.js";const c=["send_download_start","send_download_stop","send_download_resume","send_download_set_order","send_download_delete","send_download_subscribe","send_download_where"];function h(e){return!(!e||"object"!=typeof e)&&c.every((t=>"function"==typeof e[t]))}const p=1073741824,u=new Set(["DownloadProgress","DownloadAccepted","DownloadWhereAnswer","DownloadCaps","DownloadFoldersAnswer"]);function b(e){return u.has(e.type)}const g=new Set(["host","content-length","range","if-range","transfer-encoding","connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","upgrade"]),f=["B","KB","MB","GB","TB"];function m(e){if(null==e||!Number.isFinite(e)||e<0)return"—";let t=e,i=0;for(;t>=1e3&&i<f.length-1;)t/=1e3,i++;if(0===i)return`${Math.round(t)} B`;const s=t>=100?0:t>=10?1:i>=3?2:1,a=t.toFixed(s);return`${s?a.replace(/\.?0+$/,""):a} ${f[i]}`}function y(e,t="↓"){return!e||e<=0?"":`${t} ${m(e)}/s`}function v(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const i=Math.floor(t/60);if(i<10){const e=t%60;return e?`${i}m ${e}s`:`${i}m`}if(i<60)return`${i}m`;const s=Math.floor(i/60),a=i%60;return s<24?a?`${s}h ${a}m`:`${s}h`:`${Math.floor(s/24)}d ${s%24}h`}function x(e){if(!Number.isFinite(e)||e<0)return"0:00";const t=Math.floor(e),i=Math.floor(t/3600),s=Math.floor(t%3600/60),a=String(t%60).padStart(2,"0");return i?`${i}:${String(s).padStart(2,"0")}:${a}`:`${s}:${a}`}function w(e){const t=e.trim();if(!t)return{kind:"empty"};if(/^magnet:\?/i.test(t)){const e=t.slice(t.indexOf("?")+1),i=new URLSearchParams(e),s=i.getAll("xt").find((e=>/^urn:btih:/i.test(e)));if(!s)return{kind:"invalid"};const a=s.slice(9),o=i.get("dn")?.trim();return{kind:"magnet",uri:t,infoHash:a,...o?{name:o}:{}}}let i;try{i=new URL(t)}catch{return{kind:"invalid"}}if("http:"!==i.protocol&&"https:"!==i.protocol)return{kind:"invalid"};if(!i.hostname)return{kind:"invalid"};if(i.username||i.password)return{kind:"invalid"};const s="https:"===i.protocol?"HTTPS":"HTTP",a=function(e){const t=e.split("/").filter(Boolean),i=t[t.length-1]??"";try{return decodeURIComponent(i)}catch{return i}}(i.pathname)||"download";return{kind:/\.torrent$/i.test(i.pathname)?"torrent-url":"http",url:t,host:i.hostname,name:a,scheme:s}}function k(e){const t=(...e)=>e.some((e=>/[\r\n\0]/.test(e)));switch(e.mode){case"none":return{auth:null};case"basic":return e.username?e.username.includes(":")?{auth:null,error:"A username cannot contain a colon."}:t(e.username,e.password)?{auth:null,error:"A login cannot contain line breaks."}:{auth:{Basic:{username:e.username,password:e.password}}}:{auth:null,error:"Enter a username."};case"bearer":return e.token.trim()?t(e.token)?{auth:null,error:"A login cannot contain line breaks."}:{auth:{Bearer:{token:e.token.trim()}}}:{auth:null,error:"Enter a token."};case"header":{const i=e.headerName.trim();return/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(i)?g.has(i.toLowerCase())?{auth:null,error:`${i} cannot be set here.`}:t(e.headerValue)?{auth:null,error:"A login cannot contain line breaks."}:{auth:{Header:{name:i,value:e.headerValue}}}:{auth:null,error:"Enter a valid header name."}}}}const C={text:"",saveAs:"",torrent:null,order:null,auth:{mode:"none",username:"",password:"",token:"",headerName:"",headerValue:""},authOpen:!1};function I(e,t,i){const s=e.torrent?{kind:"empty"}:w(e.text),a=!!e.torrent||"magnet"===s.kind,o=a&&!!t&&!t.torrents,n="http"===s.kind||"torrent-url"===s.kind;let r=null;"too-large"===e.torrent?.error?r={tone:"err",title:"Too large",body:"A .torrent file can be up to 2 MB. Use its magnet link instead."}:"not-torrent"===e.torrent?.error?r={tone:"err",title:"Not a .torrent",body:"Choose a file that ends in .torrent."}:"invalid"===s.kind?r={tone:"err",title:"Not a link",body:"Use http://, https:// or magnet:"}:o&&(r={tone:"warn",title:"Torrents are off",body:"This node only allows ordinary links. Its owner can allow torrents in the node's settings."});const l=k(e.auth),d=a&&!o,c=i&&!!t&&(n||"magnet"===s.kind||!!e.torrent&&!e.torrent.error&&!!e.torrent.contents)&&!r&&(!d||null!==e.order)&&(!n||!e.authOpen||!l.error);let h;return n?h=e.saveAs.trim()||s.name:"magnet"===s.kind&&(h=s.name),{detected:s,isTorrent:a,needsOrder:d,showSaveAs:"http"===s.kind,showAuth:n,note:r,canStart:c,askedName:h,authError:n&&e.authOpen&&(e.auth.username||e.auth.token||e.auth.headerName||e.auth.headerValue)?l.error:void 0}}const M=new Set(["Completed","Seeding"]);function _(e){return M.has(e)}const D=new Set(["Queued","Scheduled","Resolving","FetchingMetadata","Downloading","Verifying","Paused","Stopped","Unknown"]);function S(e){return"Stopped"===e.state&&"Torrent"===e.kind&&!!e.seeding_since}function z(e){return["Queued","Scheduled","Resolving","FetchingMetadata","Downloading","Verifying","Paused"].includes(e.state)}function A(e){return("Completed"===e.state||"Cancelled"===e.state)&&!e.deleting}const $={Downloading:0,Verifying:1,FetchingMetadata:2,Resolving:3,Paused:4,Queued:5,Scheduled:6,Retrying:7,Stopped:8,Seeding:9,Completed:10,Cancelled:11,Deleted:12,Unknown:13};function P(e){const t=e.filter(z),i=t.reduce(((e,t)=>e+(t.down_bps||0)),0),s=t.filter((e=>e.total_bytes)),a=s.reduce(((e,t)=>e+t.done_bytes),0),o=s.reduce(((e,t)=>e+(t.total_bytes??0)),0);return{active:t.length,downBps:i,done:a,total:o,percent:o?a/o*100:null}}const N=/\.(mp4|m4v|webm|mkv|mov|mp3|m4a|flac|ogg|oga|opus|wav)$/i;function T(e){return N.test(e)}function R(e){const t=function(e){const t=e.files.filter((e=>e.media||T(e.name)));return t.length?t.reduce(((e,t)=>t.size>e.size?t:e)):!e.files.length&&T(e.name)?{index:0,name:e.name,size:e.total_bytes??0,done_bytes:e.done_bytes,media:!0,ready_from_start:e.in_order?e.done_bytes:0}:null}(e);return!t||e.deleting?{play:!1,file:null,switchToInOrder:!1}:_(e.state)?{play:!0,file:t,switchToInOrder:!1}:["Downloading","Verifying","Paused","Stopped","Retrying"].includes(e.state)&&t.size?e.in_order?{play:!0,file:t,switchToInOrder:!1}:{play:!1,file:null,switchToInOrder:"Torrent"===e.kind&&!S(e)}:{play:!1,file:null,switchToInOrder:!1}}function j(...e){const t=e.filter((e=>!!e)).join("/").replace(/\/{2,}/g,"/");return t.length>1?t.replace(/\/+$/,""):t}function F(e){return j(e.dest_root,e.sub_dir)}function W(e,t,i){return e.agent_supported?"Organisation"===e.lock?{id:"blocked",title:"Blocked",body:`Your organisation does not allow downloads on ${t}.`,secondary:"An owner or admin of the organisation can change this under Organisation → Downloads."}:e.http?"NoFolder"===e.lock?{id:"no-folder",title:"No download folder",body:"The download folder on this node is missing or can't be written.",secondary:"Someone who can configure the node can pick another one.",action:i?"Open node settings":void 0}:null:{id:"off",title:"Downloads are off",body:`Downloads are turned off for ${t}.`,secondary:i?"You can turn them on in the node's settings.":"Ask the node's owner to turn them on.",action:i?"Open node settings":void 0}:{id:"too-old",title:"Too old",body:`${t} runs an agent that cannot download. Update the agent on that machine, then try again.`}}const B={fetch:()=>[e("path",{d:"M17.5 19a4.5 4.5 0 1 0-1.4-8.8A6 6 0 0 0 4.3 12.7 4 4 0 0 0 6 19.9"}),e("path",{d:"M12 12v8"}),e("path",{d:"m8.5 16.5 3.5 3.5 3.5-3.5"})],magnet:()=>[e("path",{d:"M6 3v8a6 6 0 0 0 12 0V3"}),e("path",{d:"M6 7h4M14 7h4"}),e("path",{d:"M10 3v8a2 2 0 0 0 4 0V3"})],globe:()=>[e("circle",{cx:"12",cy:"12",r:"9"}),e("path",{d:"M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"})],torrent:()=>[e("path",{d:"M6 3h8l4 4v14H6z"}),e("path",{d:"M14 3v4h4"}),e("path",{d:"M9.5 11.5 12 14l2.5-2.5M12 14v3"})],node:()=>[e("rect",{x:"3",y:"4",width:"18",height:"7",rx:"1.5"}),e("rect",{x:"3",y:"13",width:"18",height:"7",rx:"1.5"}),e("path",{d:"M7 7.5h.01M7 16.5h.01"})],x:()=>[e("path",{d:"M6 6l12 12M18 6 6 18"})],retry:()=>[e("path",{d:"M3 12a9 9 0 0 0 15.4 6.4L21 16"}),e("path",{d:"M21 21v-5h-5"}),e("path",{d:"M21 12A9 9 0 0 0 5.6 5.6L3 8"}),e("path",{d:"M3 3v5h5"})],check:()=>[e("circle",{cx:"12",cy:"12",r:"9.5"}),e("path",{d:"m8 12.5 2.7 2.7L16.5 9.5"})],locate:()=>[e("path",{d:"M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2 2h8.4A1.5 1.5 0 0 1 21 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5z"}),e("path",{d:"m11 13 2 2 3-3"})],file:()=>[e("path",{d:"M6 3h8l4 4v14H6z"}),e("path",{d:"M14 3v4h4"})],folder:()=>[e("path",{d:"M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2 2h8.4A1.5 1.5 0 0 1 21 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5z"})],warn:()=>[e("path",{d:"M12 3 2.5 20h19z"}),e("path",{d:"M12 10v4.5"}),e("path",{d:"M12 17.5v.01"})],trash:()=>[e("path",{d:"M3 6h18"}),e("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})],chevron:()=>[e("path",{d:"m6 9 6 6 6-6"})],up:()=>[e("path",{d:"m6 15 6-6 6 6"})],cast:()=>[e("path",{d:"M3 8V6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-5"}),e("path",{d:"M3 12a8 8 0 0 1 8 8"}),e("path",{d:"M3 16a4 4 0 0 1 4 4"}),e("path",{d:"M3 20h.01"})],lock:()=>[e("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})],signal:()=>[e("path",{d:"M2 20h.01M7 20v-4M12 20v-8M17 20V8M22 4v16"})],plus:()=>[e("path",{d:"M12 5v14M5 12h14"})],link:()=>[e("path",{d:"M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7"}),e("path",{d:"M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7"})]},Z={pause:()=>[e("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),e("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})],play:()=>[e("path",{d:"M7 5v14l12-7z"})]},H=({name:t,size:i=16,label:s})=>{const a=Z[t];return e("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:a?"currentColor":"none",stroke:a?"none":"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s},(a??B[t])?.()??null)},L=({label:t,onClose:i,wide:s},a)=>e("div",{class:"overlay",onClick:e=>{e.target===e.currentTarget&&i()}},e("div",{class:{modal:!0,wide:!!s},role:"dialog","aria-modal":"true","aria-label":t,tabindex:-1,onKeyDown:e=>{"Escape"===e.key&&(e.stopPropagation(),i())}},a)),E=({cancel:t,confirm:i,danger:s,onCancel:a,onConfirm:o})=>e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn",onClick:a},t),e("button",{type:"button",class:{btn:!0,pri:!s,dng:!!s},onClick:o},i)),U=({row:t,discard:i,onDiscard:s,...a})=>e(L,{label:"Stop this download?",onClose:a.onCancel},e("div",{class:"dlg"},e("h4",null,"Stop this download?"),e("div",{class:"filechip"},e(H,{name:"file",size:20}),e("div",null,e("b",null,t.name),e("span",null,t.total_bytes?`${m(t.done_bytes)} of ${m(t.total_bytes)} downloaded`:`${m(t.done_bytes)} downloaded`))),e("label",{class:"checkline"},e("input",{type:"checkbox",checked:i,onChange:e=>s(e.target.checked)}),e("span",null,"Also delete the part already downloaded",e("span",{class:"hint block"},"Leave this off and Resume continues from here."))),e(E,{cancel:"Keep downloading",confirm:"Stop download",danger:!0,...a}))),G=({row:t,deleteFile:i,onDeleteFile:s,nodeName:a,...o})=>{const n=_(t.state),r=t.files.length>1?`${t.files.length} files · ${m(t.total_bytes??t.done_bytes)}`:m(t.total_bytes??t.done_bytes);return e(L,{label:"Delete this download?",onClose:o.onCancel},e("div",{class:"dlg"},e("h4",null,"Delete this download?"),e("div",{class:"filechip"},e(H,{name:"file",size:20}),e("div",null,e("b",null,t.name),e("span",null,"Seeding"===t.state?"Seeding · ":"",r," in ",F(t)))),"Seeding"===t.state&&e("p",{class:"dtx"},a," stops sharing it with peers."),n?e("label",{class:"checkline"},e("input",{type:"checkbox",checked:i,onChange:e=>s(e.target.checked)}),e("span",null,"Also delete the files",e("span",{class:"hint block"},"Off: the files stay in ",F(t)," and only the download is removed."))):e("p",{class:"dtx"},"The part already downloaded is deleted."),e(E,{cancel:"Cancel",confirm:"Delete",danger:!0,...o})))},O=({row:t,...i})=>e(L,{label:"Switch to fastest?",onClose:i.onCancel},e("div",{class:"dlg"},e("h4",null,"Switch to fastest?"),e("p",{class:"dtx"},e("b",null,t.name)," is playing. Fastest downloads pieces in any order, so playback stops until it finishes or you switch back."),e(E,{cancel:"Keep in order",confirm:"Switch and stop playback",danger:!0,...i}))),V=({nodeName:t,dontAsk:i,onDontAsk:s,...a})=>e(L,{label:`Start a torrent on ${t}?`,onClose:a.onCancel},e("div",{class:"dlg"},e("h4",null,"Start a torrent on ",t,"?"),e("div",{class:"note warn"},e(H,{name:"warn",size:14}),e("div",null,"The node will connect to public peers. They can see its internet address, and it uploads to them while it downloads.")),e("p",{class:"dtx"},"When it finishes, ",t," keeps sharing it with other peers until you delete it."),e("label",{class:"checkline"},e("input",{type:"checkbox",checked:i,onChange:e=>s(e.target.checked)}),e("span",null,"Do not ask again on this browser")),e(E,{cancel:"Cancel",confirm:"Start torrent",...a}))),J=({reason:t,onClose:i})=>e(L,{label:"Not enough space",onClose:i},e("div",{class:"dlg"},e("h4",null,"Not enough space"),e("p",{class:"dtx"},t),e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn pri",onClick:i},"OK")))),Y=t=>e(L,{label:"Save downloads to",onClose:t.onCancel,wide:!0},e("div",{class:"dlg"},e("h4",null,"Save downloads to"),e("nav",{class:"crumbs","aria-label":"Folder"},e("button",{type:"button",class:"lnk",onClick:()=>t.onUp(0)},t.root),t.path.map(((i,s)=>[e("span",{class:"sep"},"/"),e("button",{type:"button",class:"lnk",onClick:()=>t.onUp(s+1)},i)]))),e("div",{class:"folders",role:"list"},null===t.folders&&e("div",{class:"muted"},"Loading…"),0===t.folders?.length&&e("div",{class:"muted"},"No folders here."),t.folders?.map((i=>e("button",{type:"button",class:"folder-row",role:"listitem",onClick:()=>t.onOpen(i)},e(H,{name:"folder",size:14}),e("span",null,i))))),t.error&&e("div",{class:"note err"},t.error),null!==t.newName&&e("input",{class:"inp",type:"text","aria-label":"New folder name",placeholder:"New folder name",value:t.newName,onInput:e=>t.onNewName(e.target.value)}),e("p",{class:"hint"},"Folders only, and only inside the node's download folder. A new folder is created by the node when the first download lands in it."),e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn left",onClick:()=>t.onNewName(null===t.newName?"":null)},e(H,{name:"plus",size:12})," New folder"),e("button",{type:"button",class:"btn",onClick:t.onCancel},"Cancel"),e("button",{type:"button",class:"btn pri",disabled:null!==t.newName&&!/^[^/\\\0]+$/.test(t.newName.trim()),onClick:t.onSave},"Save here")))),K=({note:t})=>e("div",{class:`note ${t.tone}`,role:"err"===t.tone?"alert":"status"},e(H,{name:"warn",size:14}),e("div",null,e("b",null,t.title)," ",t.body));function X({model:t}){const i=t.detected;return"http"===i.kind||"torrent-url"===i.kind?e("div",{class:"detect","data-kind":i.kind},e("span",{class:"pill meta"},"torrent-url"===i.kind?".torrent link":i.scheme),e("span",{class:"host"},i.host)):"magnet"===i.kind?e("div",{class:"detect","data-kind":"magnet"},e("span",{class:"pill meta"},"Magnet"),e("span",{class:"host"},i.name??"name arrives with the metadata")):e("div",{class:"detect"})}const Q=({auth:t,onChange:i})=>{const s=i,a=(i,a,o="text")=>e("label",{class:"fld"},e("span",null,i),e("input",{class:"inp",type:o,autocomplete:"off",spellcheck:!1,value:t[a],onInput:e=>s({[a]:e.target.value})}));return e("div",{class:"auth"},e("div",{class:"seg",role:"radiogroup","aria-label":"Login for the link"},[["none","No login"],["basic","Username and password"],["bearer","Bearer token"],["header","Custom header"]].map((([i,a])=>e("label",{class:{on:t.mode===i}},e("input",{type:"radio",name:"auth-mode",checked:t.mode===i,onChange:()=>s({mode:i})}),a)))),"basic"===t.mode&&[a("Username","username"),a("Password","password","password")],"bearer"===t.mode&&a("Token","token","password"),"header"===t.mode&&[a("Header name","headerName"),a("Value","headerValue","password")],"none"!==t.mode&&e("p",{class:"hint"},"Sent only to this link's own site, and dropped if it redirects elsewhere. The node seals it and deletes it when the download finishes."))},q=({order:t,onChange:i})=>e("fieldset",{class:"order"},e("legend",null,"How should it download? (required for torrents)"),e("label",{class:{opt:!0,on:"in"===t}},e("input",{type:"radio",name:"order",value:"in",checked:"in"===t,onChange:()=>i("in")}),e("span",null,e("b",null,"In order")," · watch while it downloads, a little slower")),e("label",{class:{opt:!0,on:"fast"===t}},e("input",{type:"radio",name:"order",value:"fast",checked:"fast"===t,onChange:()=>i("fast")}),e("span",null,e("b",null,"Fastest")," · any order; switch to in order later if you want to watch"))),ee=t=>{const{form:i,model:s,caps:a}=t;let o;const n=!!a?.torrents,r="dialog"===t.layout,l=e("input",{type:"file",accept:".torrent,application/x-bittorrent",class:"hidden-input",ref:e=>o=e,onChange:e=>{const i=e.target,s=i.files?.[0];s&&t.onPickTorrent(s),i.value=""}}),d=i.torrent?e("div",{class:{filechip:!0,bad:!!i.torrent.error}},e(H,{name:"torrent",size:20}),e("div",null,e("b",null,i.torrent.name),e("span",null,m(i.torrent.size)," · from this computer")),e("button",{type:"button",class:"ib","aria-label":"Remove the .torrent file",title:"Remove",onClick:()=>t.onChange({torrent:null,order:null})},e(H,{name:"x",size:14}))):e("div",{class:"fld"},e("label",{htmlFor:"fetch-link"},"Link or magnet"),e("div",{class:"inline-row"},e("input",{id:"fetch-link",class:"inp",type:"text",inputMode:"url",autocomplete:"off",autocapitalize:"none",spellcheck:!1,placeholder:"https://… or magnet:?xt=…",value:i.text,disabled:t.starting,onInput:e=>t.onChange({text:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&s.canStart&&(e.preventDefault(),t.onStart())}}),!r&&n&&e("button",{type:"button",class:"btn",onClick:()=>o?.click()},".torrent…"),!r&&e("button",{type:"button",class:"btn pri",disabled:!s.canStart||t.starting,onClick:()=>t.onStart()},t.starting?"Starting…":"Download")),e(X,{model:s}));return e("form",{class:{"fetch-form":!0,[t.layout]:!0},onSubmit:e=>{e.preventDefault(),s.canStart&&t.onStart()},onDragOver:e=>n&&e.preventDefault(),onDrop:e=>n&&(e=>{e.preventDefault();const i=e.dataTransfer?.files?.[0];i&&t.onPickTorrent(i)})(e)},r&&e("div",{class:"dlg-h"},e(H,{name:"fetch"}),e("h4",null,t.title)),l,d,s.note&&e(K,{note:s.note}),t.refusal&&e(K,{note:t.refusal}),s.showSaveAs&&e("div",{class:"fld"},e("label",{htmlFor:"fetch-save-as"},"Save as"),e("input",{id:"fetch-save-as",class:"inp",type:"text",autocomplete:"off",spellcheck:!1,placeholder:s.askedName,value:i.saveAs,disabled:t.starting,onInput:e=>t.onChange({saveAs:e.target.value})}),e("span",{class:"hint"},"Taken from the server's filename when it sends one. An existing file is never overwritten; the new one gets “(1)” added.")),s.showAuth&&e("div",{class:"login"},e("button",{type:"button",class:"lnk","aria-expanded":i.authOpen?"true":"false",onClick:()=>t.onChange({authOpen:!i.authOpen})},e(H,{name:i.authOpen?"up":"chevron",size:12})," This link needs a login"),i.authOpen&&e(Q,{auth:i.auth,onChange:t.onAuth}),s.authError&&e("span",{class:"hint err",role:"alert"},s.authError)),s.needsOrder&&e(q,{order:i.order,onChange:e=>t.onChange({order:e})}),("http"===s.detected.kind||"torrent-url"===s.detected.kind)&&e("p",{class:"hint"},"A link always downloads in order, so you can watch while it arrives."),r&&n&&!i.torrent&&[e("div",{class:"or"},"or"),e("button",{type:"button",class:"drop",onClick:()=>o?.click()},e(H,{name:"torrent",size:22}),e("span",null,e("b",null,"Choose a .torrent file")," or drop it here",e("br",null),e("span",{class:"hint"},"Up to 2 MB, read in the browser and sent to the node")))],t.destination&&e("div",{class:"fld"},r&&e("label",null,"Destination"),e("div",{class:"dest-row"},e("div",{class:"dest",title:t.destination.path},e(H,{name:"folder",size:14}),e("span",null,t.destination.path)),t.onChooseFolder&&e("button",{type:"button",class:"btn",onClick:()=>t.onChooseFolder?.()},"Choose folder…")),t.destination.hint&&e("span",{class:"hint where"},t.destination.hint)),r&&e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn",onClick:()=>t.onCancel?.()},"Cancel"),e("button",{type:"submit",class:"btn pri",disabled:!s.canStart||t.starting},t.starting?"Starting…":"Start download")))};function te(e){return"FetchingMetadata"===e.state||"Resolving"===e.state?"bar indet":"Retrying"===e.state||"Paused"===e.state?"bar moving":"Stopped"===e.state||"Queued"===e.state||"Scheduled"===e.state||e.deleting?"bar paused":"Cancelled"===e.state?"bar fail":"Seeding"===e.state?"bar seed":"bar"}const ie=({icon:t,label:i,onClick:s,primary:a})=>e("button",{type:"button",class:{ib:!0,new:!!a},title:i,"aria-label":i,onClick:s},e(H,{name:t,size:14})),se=({row:t,actions:i,running:s,source:a,compact:o})=>{const{icon:n,tone:r}=function(e){return"Torrent"===e.kind?{icon:e.name.startsWith("magnet:")?"magnet":"torrent",tone:"t"}:"Node"===e.kind?{icon:"node",tone:"n"}:{icon:"globe",tone:"h"}}(t),l=function(e){if(e.deleting)return{text:"Deleting…",tone:"ps"};if(e.waitingForNode)return{text:"Waiting for the node",tone:"q"};switch(e.state){case"Queued":return{text:"Queued",tone:"q"};case"Scheduled":return{text:"Scheduled",tone:"q"};case"Resolving":return{text:"Connecting",tone:"meta"};case"FetchingMetadata":return{text:"Fetching metadata",tone:"meta"};case"Downloading":return{text:"Downloading",tone:"dl"};case"Verifying":return{text:"Checking pieces",tone:"meta"};case"Paused":return{text:"DiskFull"===e.pause_reason?"Paused · disk almost full":"Paused",tone:"mv"};case"Retrying":return{text:"Retrying",tone:"mv"};case"Seeding":return{text:"Seeding",tone:"sd"};case"Completed":return{text:"Completed",tone:"ok"};case"Stopped":return{text:S(e)?"Seeding paused":"Stopped",tone:"ps"};case"Cancelled":return{text:"Cancelled",tone:"err"};default:return{text:e.state,tone:"ps"}}}(t),d=function(e){return"Torrent"===e.kind&&["Downloading","Verifying","Paused"].includes(e.state)?e.in_order?"In order":"Fastest":null}(t),c=R(t),h=function(e,t={}){const i=t.now??Date.now(),s=function(e,t){if(!t||t<=0)return"";const i=Math.min(100,e/t*100);return i>=100?"100%":`${i.toFixed(1)}%`}(e.done_bytes,e.total_bytes),a=e.total_bytes?`${m(e.done_bytes)} of ${m(e.total_bytes)}`:e.done_bytes?m(e.done_bytes):"",o=[],n=(e,t={})=>e&&o.push({text:e,...t});if(e.deleting)return n("Waiting for the node to confirm"),o;if(e.waitingForNode)return n("Starts when the node reports in"),n("It keeps going after you close this tab"),o;switch(e.state){case"Queued":n("Waiting for a free slot"),t.running&&n(`${t.running} ${1===t.running?"is":"are"} running`);break;case"Scheduled":n("Waits for the download window"),e.next_attempt_at&&e.next_attempt_at>i&&n(`starts in ${v((e.next_attempt_at-i)/1e3)}`);break;case"Resolving":n(t.source?`Contacting ${t.source}`:"Contacting the server");break;case"FetchingMetadata":n("Asking peers for the torrent info"),n(`${e.peers} ${1===e.peers?"peer":"peers"}`),n(x((i-e.started_at)/1e3));break;case"Downloading":n(s,{strong:!0}),n(a),n(y(e.down_bps)),"Torrent"===e.kind&&(n(y(e.up_bps,"↑")),n(`${e.peers} ${1===e.peers?"peer":"peers"}`)),n((r=e.done_bytes,d=e.down_bps,!(l=e.total_bytes)||!d||d<=0||r>=l?"":`${v((l-r)/d)} left`)),e.restarted_from_zero&&n("The file changed on the server, so it started over"),t.source&&n(t.source);break;case"Verifying":n(s,{strong:!0}),n("Checking downloaded pieces after a restart"),n(`${m(e.done_bytes)} already on disk`);break;case"Paused":"DiskFull"===e.pause_reason?(n(e.reason??"Free space is below the floor"),n("Resumes by itself when there is room")):(n(s,{strong:!0}),n("Outside the download window"),n("Resumes by itself"));break;case"Retrying":n(e.retry_reason??e.reason??"Something went wrong",{error:!0}),n(`attempt ${e.attempt}`),e.next_attempt_at&&n(e.next_attempt_at>i?`Next try in ${v((e.next_attempt_at-i)/1e3)}`:"Trying again now"),e.done_bytes&&n(`${m(e.done_bytes)} kept`);break;case"Seeding":n(y(e.up_bps,"↑")),n(`${m(e.up_total)} uploaded`),n(`${e.peers} ${1===e.peers?"peer":"peers"}`),e.seeding_since&&n(`seeding for ${v((i-e.seeding_since)/1e3).replace(/ \d+[hm]$/,"")}, until you delete it`);break;case"Completed":if(n("100%",{strong:!0}),n(e.files.length>1?`${e.files.length} files · ${m(e.total_bytes??e.done_bytes)}`:m(e.total_bytes??e.done_bytes)),e.finished_at&&e.started_at){const t=(e.finished_at-e.started_at)/1e3;n(`took ${v(t)}`),t>0&&(e.total_bytes??e.done_bytes)&&n(`avg ${m((e.total_bytes??e.done_bytes)/t)}/s`)}break;case"Stopped":if(S(e)){n(`${m(e.up_total)} uploaded`),n(e.reason??"Seeding paused by you"),n("Resume shares it again");break}n(s,{strong:!0}),n(e.reason??"Stopped by you"),n("Resume continues from here");break;case"Cancelled":n(e.reason??"Stopped and its part deleted",{error:!!e.reason}),n("Resume starts from zero")}var r,l,d;return o}(t,{running:s,source:a}),p="Completed"===t.state||"Seeding"===t.state?100:!(u=t.total_bytes)||u<=0?0:Math.max(0,Math.min(100,t.done_bytes/u*100));var u;const b=[];if(!t.deleting)switch(c.play&&b.push(e(ie,{icon:"play",label:_(t.state)?"Play":"Play while downloading",primary:!0,onClick:()=>i.play(t)})),t.state){case"Downloading":case"Verifying":case"Resolving":case"FetchingMetadata":case"Queued":"Downloading"!==t.state&&"Verifying"!==t.state||b.push(e(ie,{icon:"pause",label:"Pause",onClick:()=>i.pause(t)})),b.push(e(ie,{icon:"x",label:"Stop",onClick:()=>i.stop(t)}));break;case"Scheduled":case"Paused":"Scheduled"!==t.state&&"Window"!==t.pause_reason||b.push(e(ie,{icon:"play",label:"Start now",onClick:()=>i.resume(t,!0)})),b.push(e(ie,{icon:"x",label:"Stop",onClick:()=>i.stop(t)}));break;case"Retrying":b.push(e(ie,{icon:"retry",label:"Try now",onClick:()=>i.resume(t)})),b.push(e(ie,{icon:"x",label:"Stop",onClick:()=>i.stop(t)}));break;case"Stopped":b.push(e(ie,{icon:"play",label:"Resume",onClick:()=>i.resume(t)})),b.push(e(ie,{icon:"trash",label:"Delete",onClick:()=>i.remove(t)}));break;case"Seeding":b.push(e(ie,{icon:"pause",label:"Pause seeding",onClick:()=>i.pause(t)})),b.push(e(ie,{icon:"locate",label:"Show in folder",onClick:()=>i.showInFolder(t)})),b.push(e(ie,{icon:"trash",label:"Delete",onClick:()=>i.remove(t)}));break;case"Completed":b.push(e(ie,{icon:"locate",label:"Show in folder",onClick:()=>i.showInFolder(t)})),b.push(e(ie,{icon:"x",label:"Remove from list",onClick:()=>i.remove(t)}));break;case"Cancelled":b.push(e(ie,{icon:"retry",label:"Start again",onClick:()=>i.resume(t)})),b.push(e(ie,{icon:"x",label:"Remove from list",onClick:()=>i.remove(t)}))}return e("div",{key:t.download_id,class:{job:!0,compact:!!o},"data-state":t.deleting?"Deleting":t.state,"data-id":t.download_id,role:"listitem","aria-label":`${t.name}, ${l.text}`},e("span",{class:`kind ${r}`},e(H,{name:n,size:15})),e("div",{class:"title"},e("span",{class:"nm",title:t.name},t.name),e("span",{class:`pill ${l.tone}`},l.text),d&&e("span",{class:"pill meta"},d)),e("div",{class:"acts"},b),e("div",{class:te(t),role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(p),"aria-label":`${t.name} progress`},e("i",{style:{width:`${p}%`}})),e("div",{class:"stats"},h.map((t=>t.strong?e("b",null,t.text):e("span",{class:{err:!!t.error}},t.text))),!c.play&&c.switchToInOrder&&e("button",{type:"button",class:"lnk inline",onClick:()=>i.setOrder(t,!0)},"Switch to in order to watch"),c.play&&"Torrent"===t.kind&&t.in_order&&!_(t.state)&&e("button",{type:"button",class:"lnk inline",onClick:()=>i.setOrder(t,!1)},"Switch to fastest")))},ae={started:"fetch",queued:"fetch",stuck:"warn",renamed:"file",completed:"check",error:"warn"},oe=({notices:t,onDismiss:i})=>t.length?e("div",{class:"toasts","aria-live":"polite"},t.map((t=>e("div",{class:{toast:!0,bad:"stuck"===t.kind||"error"===t.kind},"data-notice":t.kind,key:t.id},e(H,{name:ae[t.kind],size:18}),e("div",{class:"t"},e("b",null,t.title),e("span",{title:t.detail},t.detail)),t.action&&e("button",{type:"button",class:"btn",onClick:()=>{t.action.run(),i(t.id)}},t.action.label),e("button",{type:"button",class:"ib","aria-label":"Dismiss",onClick:()=>i(t.id)},e(H,{name:"x",size:12})))))):null,ne=({icon:t,title:i,body:s,action:a})=>e("div",{class:"empty",role:"status"},e(H,{name:t,size:28}),e("b",null,i),e("span",null,s),a&&e("button",{type:"button",class:"btn pri",onClick:a.onClick},a.label)),re=()=>e(ne,{icon:"fetch",title:"No downloads yet",body:"Press Fetch and paste a link. Downloads keep running after you close this tab, and they show here when you come back."}),le=({nodeName:t,folder:i})=>e(ne,{icon:"fetch",title:"Nothing downloading",body:`Paste a link above. It downloads onto ${t}${i?`, into ${i}`:""}.`}),de=({onSignIn:t})=>e(ne,{icon:"lock",title:"Sign in to PhirePass",body:"Your downloads are tied to your account and the nodes you can reach.",action:{label:"Sign in",onClick:t}}),ce=({nodeName:t,onRetry:i})=>e(ne,{icon:"signal",title:`Can't reach ${t}`,body:"If the machine is still running, its downloads carry on. They will show here when it reconnects.",action:i?{label:"Try again",onClick:i}:void 0}),he=()=>e(ne,{icon:"warn",title:"Downloads are not available here",body:"This page's connection library is too old to start downloads. Reload after the site updates."}),pe=()=>e("div",{class:"empty",role:"status"},e("span",{class:"spin","aria-hidden":"true"}),e("span",null,"Loading downloads…")),ue=({blocker:t,onAction:i,onClose:s})=>e("div",{class:"blocker","data-blocker":t.id},e("div",{class:"note "+("off"===t.id?"info":"warn"),role:"status"},e(H,{name:"off"===t.id?"fetch":"warn",size:14}),e("div",null,e("b",null,t.title)," ",t.body)),t.secondary&&e("p",{class:"hint"},t.secondary),(s||t.action&&i)&&e("div",{class:"dlg-f"},s&&e("button",{type:"button",class:"btn",onClick:s},"Close"),t.action&&i&&e("button",{type:"button",class:"btn pri",onClick:i},t.action))),be="phirepass.downloader.torrent-ack",ge=class{constructor(e){new.target===ge&&t(this,e),this.fetchCompleted=i(this,"phirepassFetchCompleted"),this.play=i(this,"phirepassPlay"),this.activeCount=i(this,"phirepassActiveCount"),this.showInFolder=i(this,"phirepassShowInFolder"),this.openNodeSettings=i(this,"phirepassOpenNodeSettings"),this.signIn=i(this,"phirepassSignIn")}get el(){return s(this)}ownChannel=!1;msgId=p;noticeId=1;seenNotices=new Set;torrentAcked=function(){try{return"1"===window.localStorage.getItem(be)}catch{return!1}}();noticeTimers=new Map;whereMsgId;nodeId;nodeLabel;token;channel;connected=!1;channelFactory;browsingService;browsingPath;compact=!1;streamBase;canConfigure=!1;inlinePlayer=!0;serverHost="phirepass.com";serverPort=443;serverId;allowInsecure=!1;heartbeatInterval=3e4;fetchCompleted;play;activeCount;showInFolder;openNodeSettings;signIn;connection="connecting";caps=null;jobs={};tab="active";drawerOpen=!1;dialogOpen=!1;unread=0;form=C;where=null;starting=null;refusal=null;confirm=null;notices=[];subDir=null;picker=null;player=null;get name(){return this.nodeLabel||this.nodeId}get ch(){return this.channel??this.ownedChannel}ownedChannel;async componentWillLoad(){this.channel?this.adoptChannel():await this.openOwnChannel()}disconnectedCallback(){this.noticeTimers.forEach((e=>window.clearTimeout(e))),this.noticeTimers.clear(),this.starting?.silence&&window.clearTimeout(this.starting.silence),this.ownChannel&&this.ownedChannel&&(this.ownedChannel.stop_heartbeat(),this.ownedChannel.disconnect())}onChannel(){this.channel&&this.adoptChannel()}onConnected(e,t){this.channel&&(e&&!t?this.subscribe():!e&&t&&(this.connection="unreachable"))}onBrowsing(){this.where=null,this.dialogOpen&&this.askWhere()}onNode(e,t){e!==t&&(this.jobs={},this.caps=null,this.where=null,this.channel?this.connected&&this.subscribe():this.ownedChannel&&(this.ownedChannel.disconnect(),this.openOwnChannel()))}adoptChannel(){this.ownChannel=!1,h(this.channel)?(this.connection="connecting",this.connected&&this.subscribe()):this.connection="unsupported"}endpoint(){return`${this.allowInsecure?"ws":"wss"}://${this.serverHost}${!this.allowInsecure&&443===this.serverPort||this.allowInsecure&&80===this.serverPort?"":`:${this.serverPort}`}/api/web/ws`}defaultStreamBase(){return`${this.allowInsecure?"http":"https"}://${this.serverHost}${!this.allowInsecure&&443===this.serverPort||this.allowInsecure&&80===this.serverPort?"":`:${this.serverPort}`}`}async openOwnChannel(){if(this.ownChannel=!0,!this.token)return void(this.connection="signed-out");if(!this.nodeId)return;this.channelFactory||await o();const e=this.channelFactory?this.channelFactory(this.endpoint(),this.nodeId,this.serverId):this.serverId?new n(this.endpoint(),this.nodeId,this.serverId):new n(this.endpoint(),this.nodeId);this.ownedChannel=e,h(e)?(e.on_connection_open((()=>e.authenticate(this.token,this.nodeId))),e.on_connection_close((()=>{"signed-out"!==this.connection&&(this.connection="unreachable")})),e.on_connection_error((()=>{"signed-out"!==this.connection&&(this.connection="unreachable")})),e.on_connection_message((()=>{})),e.on_protocol_message((e=>this.dispatch(e.data.web))),this.connection="connecting",e.connect()):this.connection="unsupported"}reconnect(){this.ownChannel?(this.ownedChannel?.disconnect(),this.openOwnChannel()):this.connected&&this.subscribe()}async receive(e){this.dispatch(e.data.web)}dispatch(e){if(e.type===r.AuthSuccess)return this.ownedChannel?.start_heartbeat(Math.max(3e4,this.heartbeatInterval)),void this.subscribe();if(e.type!==r.Error){if(b(e))switch(e.type){case"DownloadCaps":e.node_id===this.nodeId&&(this.caps=e.caps,this.connection="ready");break;case"DownloadProgress":e.node_id===this.nodeId&&this.onProgress(e.job);break;case"DownloadAccepted":this.onAccepted(e.msg_id,e.download_id);break;case"DownloadWhereAnswer":e.msg_id===this.whereMsgId&&(this.where={saves_to:e.saves_to,mapped:e.mapped});break;case"DownloadFoldersAnswer":this.picker&&e.msg_id===this.picker.msgId&&(this.picker={...this.picker,folders:[...e.folders].sort(((e,t)=>e.localeCompare(t)))})}}else this.handleError(e)}handleError(e){if(void 0!==e.msg_id&&e.msg_id===this.starting?.msgId)return this.clearStarting(),void(this.refusal={tone:"err",title:"Refused",body:e.message||"The server refused this download."});this.picker&&e.msg_id===this.picker.msgId?this.picker={...this.picker,folders:[],error:e.message}:void 0!==e.msg_id&&e.msg_id>=p?this.notify("error","That did not work",e.message||"The server refused it."):this.ownChannel&&e.kind===l.Authentication&&(this.connection="signed-out")}subscribe(){const e=this.ch;h(e)?(this.jobs={},e.send_download_subscribe({Node:this.nodeId}),this.dialogOpen&&this.askWhere()):this.connection="unsupported"}onProgress(e){const t=this.jobs[e.download_id],{jobs:i,completed:s}=function(e,t){const i=e[t.download_id];if("Deleted"===t.state){if(!i)return{jobs:e,first:!1};const{[t.download_id]:s,...a}=e;return{jobs:a,first:!1}}const s=t.deleting||i?.deleting||void 0;return{jobs:{...e,[t.download_id]:{...t,deleting:s}},completed:i&&!_(i.state)&&_(t.state)?t:void 0,first:!i}}(this.jobs,e);this.jobs=i,this.emitCount(),this.starting?.downloadId!==e.download_id||t||this.onFirstProgress(e),s&&(this.fetchCompleted.emit({download_id:e.download_id,dest_root:e.dest_root,sub_dir:e.sub_dir,name:e.name}),!this.drawerOpen&&this.compact&&this.unread++,this.notify("completed","Download complete",`${e.name} → ${F(e)}`,{label:"Show",run:()=>this.showInFolder.emit({path:F(e),name:e.name})}));const a=this.jobs[e.download_id];a&&function(e,t=3600){return"Retrying"===e.state&&function(e,t=3600){let i=0;for(let s=0;s<e;s++)i+=Math.min(10*2**s,t);return i}(e.attempt,t)>=86400}(a)&&!this.seenNotices.has(`stuck:${e.download_id}`)&&(this.seenNotices.add(`stuck:${e.download_id}`),this.notify("stuck","Still retrying after a day",`${e.name} · ${e.retry_reason??"no answer"}`,{label:"Show",run:()=>this.showRetrying()},!0))}onAccepted(e,t){if(!this.starting||this.starting.msgId!==e)return;if(this.jobs[t])return void this.onFirstProgress(this.jobs[t]);const i=window.setTimeout((()=>this.nodeSilent(t)),8e3);this.starting={...this.starting,downloadId:t,silence:i}}nodeSilent(e){if(this.starting?.downloadId!==e||this.jobs[e])return;const t=this.starting.askedName??"Download",i=Date.now(),s={download_id:e,kind:"Unknown",name:t,dest_root:this.where?.saves_to??this.caps?.folder??"",sub_dir:null,state:"Queued",done_bytes:0,total_bytes:null,down_bps:0,up_bps:0,peers:0,in_order:!0,started_at:i,finished_at:null,reason:null,requested_by:null,files:[],up_total:0,pause_reason:null,seeding_since:null,info_hash:null,retry_reason:null,attempt:0,next_attempt_at:null,restarted_from_zero:!1,waitingForNode:!0};this.jobs={...this.jobs,[e]:s},this.clearStarting(),this.closeDialog(!0),this.notify("queued",`Waiting for ${this.name}`,`${t} starts when the node reports in.`)}onFirstProgress(e){const t=this.starting?.askedName;if(this.clearStarting(),"Cancelled"!==e.state){if(this.closeDialog(!0),"Queued"===e.state){const e=Object.values(this.jobs).filter((e=>"Downloading"===e.state)).length;this.notify("queued","Added to the queue",`${e} ${1===e?"download is":"downloads are"} already running on this node`)}else this.notify("started","Download started",`${e.name} → ${F(e)}`);(function(e,t){return!!e&&e!==t&&/ \(\d+\)(\.[^.]*)?$/.test(t)})(t,e.name)&&this.notify("renamed",`Saved as ${e.name}`,`A file named ${t} was already in ${F(e)}`)}else{const t=e.reason??"The node refused this download.";!function(e){return!!e&&/not enough (disk )?space|disk (is )?full|needs [\d.]+ ?[kmgt]?b\b.*\bfree\b/i.test(e)}(t)?!this.dialogOpen&&this.compact||(this.refusal={tone:"err",title:"Refused",body:t}):this.confirm={kind:"space",reason:t}}}clearStarting(){this.starting?.silence&&window.clearTimeout(this.starting.silence),this.starting=null}emitCount(){this.activeCount.emit({n:Object.values(this.jobs).filter(z).length})}notify(e,t,i,s,a=!1){const o=this.noticeId++;this.notices=[...this.notices.slice(-2),{id:o,kind:e,title:t,detail:i,action:s,sticky:a}],a||this.noticeTimers.set(o,window.setTimeout((()=>this.dismiss(o)),6e3))}dismiss(e){const t=this.noticeTimers.get(e);t&&(window.clearTimeout(t),this.noticeTimers.delete(e)),this.notices=this.notices.filter((t=>t.id!==e))}showRetrying(){this.tab="retrying",this.drawerOpen=!0}async openFetch(e){void 0!==e&&e!==this.browsingPath&&(this.browsingPath=e),this.drawerOpen=!0,this.unread=0,this.dialogOpen=!0,this.refusal=null,this.askWhere()}async toggleDrawer(e){this.drawerOpen=e??!this.drawerOpen,this.drawerOpen&&(this.unread=0)}async jobForPath(e){const t=Object.values(this.jobs).find((t=>!_(t.state)&&"Cancelled"!==t.state&&function(e){return`${j(F(e),e.name)}.phirepass-part`}(t)===e));return t?{download_id:t.download_id,name:t.name}:null}async deleteDownload(e,t=!1){const i=this.jobs[e];i&&this.sendDelete(i,t)}async torrentPathFor(e){const t=this.caps?.folder;if(!t||!this.caps?.torrents||!/\.torrent$/i.test(e)||W(this.caps,this.name,this.canConfigure))return null;const i=t.endsWith("/")?t:`${t}/`;return e.startsWith(i)?e.slice(i.length):null}async startTorrentPath(e,t=!1){const i=await this.torrentPathFor(e),s=this.ch;if(null===i||!h(s))return!1;const a=this.nextMsgId();this.starting={msgId:a,askedName:i.split("/").pop()?.replace(/\.torrent$/i,"")};const o=i.includes("/")?i.slice(0,i.lastIndexOf("/")):null;return s.send_download_start(this.nodeId,{TorrentPath:{path:i}},o,null,t,{source_auth:null,ignore_window:!1},a),this.drawerOpen=!0,!0}nextMsgId(){return this.msgId=this.msgId>=4294967280?p:this.msgId+1,this.msgId}browsing(){return this.compact&&this.browsingService&&this.browsingPath?{service_id:this.browsingService,path:this.browsingPath}:null}askWhere(){const e=this.browsing(),t=this.ch;e&&h(t)&&"ready"===this.connection&&(this.whereMsgId=this.nextMsgId(),t.send_download_where(this.nodeId,e,this.whereMsgId))}destination(){if(this.browsing())return this.where?this.where.mapped?{path:this.where.saves_to}:{path:this.where.saves_to,hint:`This folder is outside ${this.name}'s download folder. The file will be saved to ${this.where.saves_to}.`}:{path:this.browsingPath,hint:"Asking the node where this lands…"};const e=this.caps?.folder;return e?{path:j(e,this.subDir)}:null}formReady(){return!(this.starting||"ready"!==this.connection||this.browsing()&&!this.where)}async pickTorrent(e){const t=function(e){const t=function(e){return/\.torrent$/i.test(e.name)?e.size>2097152?{ok:!1,reason:"too-large"}:{ok:!0}:{ok:!1,reason:"not-torrent"}}(e);return t.ok?{name:e.name,size:e.size}:{name:e.name,size:e.size,error:t.reason}}(e);t.error||(t.contents=new Uint8Array(await e.arrayBuffer())),this.form={...this.form,torrent:t,text:"",order:null},this.refusal=null}start(e=!1){const t=I(this.form,this.caps,this.formReady()),i=function(e){const t={source_auth:null,ignore_window:!1};if(e.torrent)return!e.torrent.contents||e.torrent.error?null:{source:{TorrentFile:{name:e.torrent.name,contents:e.torrent.contents}},inOrder:"in"===e.order,options:t};const i=w(e.text);if("magnet"===i.kind)return{source:{Magnet:{uri:i.uri}},inOrder:"in"===e.order,options:t};if("http"===i.kind||"torrent-url"===i.kind){const s=e.authOpen?k(e.auth):{auth:null};if("error"in s&&s.error)return null;const a=e.saveAs.trim();return{source:{Http:{url:i.url,save_as:a||null}},inOrder:!0,options:{...t,source_auth:s.auth}}}return null}(this.form),s=this.ch;if(!t.canStart||!i||!h(s))return;if(t.isTorrent&&!this.torrentAcked&&!e)return void(this.confirm={kind:"torrent",dontAsk:!1});const a=this.nextMsgId(),o=t.askedName??(this.form.torrent?this.form.torrent.name.replace(/\.torrent$/i,""):"magnet"===t.detected.kind?function(e){const t=/urn:btih:([a-z0-9]+)/i.exec(e);if(!t)return e.length>40?`${e.slice(0,37)}…`:e;const i=t[1];return`magnet:?xt=urn:btih:${i.slice(0,4)}…${i.slice(-4)}`}(t.detected.uri):void 0);this.starting={msgId:a,askedName:o},this.refusal=null;const n=this.browsing();s.send_download_start(this.nodeId,i.source,n?null:this.subDir,n,i.inOrder,i.options,a)}closeDialog(e=!1){this.dialogOpen=!1,this.refusal=null,e&&(this.form=C,this.drawerOpen=!0)}sendStop(e,t){const i=this.ch;h(i)&&i.send_download_stop(e.download_id,t,this.nextMsgId())}sendDelete(e,t){const i=this.ch;h(i)&&(i.send_download_delete(e.download_id,t,this.nextMsgId()),this.jobs={...this.jobs,[e.download_id]:{...e,deleting:!0}})}actions={play:e=>this.playRow(e),pause:e=>this.sendStop(e,!1),resume:(e,t=!1)=>{const i=this.ch;h(i)&&i.send_download_resume(e.download_id,t,this.nextMsgId())},stop:e=>this.confirm={kind:"stop",row:e,discard:!1},remove:e=>{"Completed"===e.state||"Seeding"===e.state||"Stopped"===e.state?this.confirm={kind:"delete",row:e,deleteFile:!1}:this.sendDelete(e,!1)},setOrder:(e,t)=>{t||this.player?.downloadId!==e.download_id?this.sendOrder(e,t):this.confirm={kind:"fastest",row:e}},showInFolder:e=>this.showInFolder.emit({path:F(e),name:e.name})};sendOrder(e,t){const i=this.ch;h(i)&&i.send_download_set_order(e.download_id,t,this.nextMsgId())}playRow(e){const t=R(e);if(!t.play||!t.file)return;const i=(s=this.streamBase||this.defaultStreamBase(),a=this.nodeId,o=e.download_id,n=t.file.index,`${s.replace(/\/+$/,"")}/api/web/stream/${encodeURIComponent(a)}/${encodeURIComponent(o)}/${n}`);var s,a,o,n;!this.play.emit({src:i,name:t.file.name,downloadId:e.download_id}).defaultPrevented&&this.inlinePlayer&&(this.player={src:i,name:t.file.name,downloadId:e.download_id})}clearFinished(){Object.values(this.jobs).filter(A).forEach((e=>this.sendDelete(e,!1)))}canPickFolder(){return!!this.caps?.folder&&"function"==typeof this.ch?.send_download_folders}listFolders(e){const t=this.nextMsgId();this.picker={path:e,folders:null,msgId:t,newName:null},this.ch?.send_download_folders?.(this.nodeId,e.length?e.join("/"):null,t)}savePicker(){if(!this.picker)return;const e=[...this.picker.path],t=this.picker.newName?.trim();t&&e.push(t),this.subDir=e.length?e.join("/"):null,this.picker=null}renderConfirm(){const t=this.confirm;if(!t)return null;const i=()=>this.confirm=null;switch(t.kind){case"stop":return e(U,{row:t.row,discard:t.discard,onDiscard:e=>this.confirm={...t,discard:e},onCancel:i,onConfirm:()=>{this.sendStop(t.row,t.discard),this.confirm=null}});case"delete":return e(G,{row:t.row,nodeName:this.name,deleteFile:t.deleteFile,onDeleteFile:e=>this.confirm={...t,deleteFile:e},onCancel:i,onConfirm:()=>{this.sendDelete(t.row,t.deleteFile),this.confirm=null}});case"fastest":return e(O,{row:t.row,onCancel:i,onConfirm:()=>{this.player=null,this.sendOrder(t.row,!1),this.confirm=null}});case"torrent":return e(V,{nodeName:this.name,dontAsk:t.dontAsk,onDontAsk:e=>this.confirm={...t,dontAsk:e},onCancel:i,onConfirm:()=>{t.dontAsk&&(function(){try{window.localStorage.setItem(be,"1")}catch{}}(),this.torrentAcked=!0),this.confirm=null,this.start(!0)}});case"space":return e(J,{reason:t.reason,onClose:i})}}renderForm(t){const i=this.caps?W(this.caps,this.name,this.canConfigure):null,s=()=>this.openNodeSettings.emit({nodeId:this.nodeId});if(i)return"dialog"===t?e("div",{class:"dlg"},e("div",{class:"dlg-h"},e(H,{name:"fetch"}),e("h4",null,"Fetch into this folder")),e(ue,{blocker:i,onAction:s,onClose:()=>this.closeDialog()})):e(ue,{blocker:i,onAction:s});const a=I(this.form,this.caps,this.formReady());return e(ee,{form:this.form,model:a,caps:this.caps,layout:t,title:this.browsing()?"Fetch into this folder":"Add download",destination:"dialog"===t||this.browsing()?this.destination():null,starting:!!this.starting,refusal:this.refusal,onChange:e=>{this.form={...this.form,...e},("text"in e||"torrent"in e)&&(this.refusal=null)},onAuth:e=>this.form={...this.form,auth:{...this.form.auth,...e}},onPickTorrent:e=>{this.pickTorrent(e)},onStart:()=>this.start(),onCancel:()=>this.closeDialog()})}renderRows(t){const i=t.filter((e=>"Downloading"===e.state)).length;return e("div",{class:"jobs",role:"list"},function(e){return[...e].sort(((e,t)=>$[e.state]-$[t.state]||(t.finished_at??t.started_at)-(e.finished_at??e.started_at)))}(t).map((t=>e(se,{row:t,actions:this.actions,running:i,compact:this.compact}))))}renderStatus(){switch(this.connection){case"unsupported":return e(he,null);case"signed-out":return e(de,{onSignIn:()=>this.signIn.emit()});case"unreachable":return e(ce,{nodeName:this.name,onRetry:()=>this.reconnect()});case"connecting":return e(pe,null);default:return null}}renderCompact(){const t=Object.values(this.jobs),i=P(t),s=this.renderStatus();if("unsupported"===this.connection)return null;const a=t.some(A),o=!this.drawerOpen&&(i.active>0||this.unread>0),n=[`${i.active} active`,null===i.percent||this.drawerOpen?"":`${Math.round(i.percent)}%`,y(i.downBps)].filter(Boolean).join(" · ");return[this.drawerOpen&&e("section",{class:"drawer","aria-label":"Transfers"},e("div",{class:"drawer-h"},e("h4",null,"Transfers"),e("span",{class:"sum"},n),e("span",{class:"sp"}),a&&e("button",{type:"button",class:"lnk",onClick:()=>this.clearFinished()},"Clear finished"),e("button",{type:"button",class:"ib","aria-label":"Collapse transfers",title:"Collapse",onClick:()=>this.drawerOpen=!1},e(H,{name:"chevron",size:12}))),e("div",{class:"drawer-b"},s??(t.length?this.renderRows(t):e(re,null)))),o&&e("button",{type:"button",class:"strip","aria-label":"Show transfers",onClick:()=>this.toggleDrawer(!0)},e("h4",null,"Transfers"),e("span",{class:"bar"},e("i",{style:{width:`${i.percent??0}%`}})),e("span",{class:"sum"},this.unread&&!i.active?`${this.unread} finished`:n),e(H,{name:"up",size:12})),this.dialogOpen&&e(L,{label:"Fetch into this folder",onClose:()=>this.closeDialog()},s&&"ready"!==this.connection?e("div",{class:"dlg"},s,e("div",{class:"dlg-f"},e("button",{type:"button",class:"btn",onClick:()=>this.closeDialog()},"Close"))):this.renderForm("dialog"))]}renderStandalone(){const t=this.renderStatus(),i=Object.values(this.jobs),s={active:[],finished:[],retrying:[]};i.forEach((e=>{return s[(t=e,"Retrying"===t.state?"retrying":S(t)?"finished":D.has(t.state)?"active":"finished")].push(e);var t}));const a=P(i),o=s[this.tab],n=this.caps?.folder?j(this.caps.folder,this.subDir):null;return e("section",{class:"standalone"},e("header",{class:"sa-head"},e("div",{class:"sa-title"},e("h3",null,"Downloads"),e("span",{class:"node"},this.name),a.downBps>0&&e("span",{class:"sum"},y(a.downBps))),n&&e("span",{class:"saving"},"saving to ",e("code",null,n),this.caps&&this.caps.folder_free_bytes>0&&e("span",{class:"free"}," · ",m(this.caps.folder_free_bytes)," free"))),t??[e("div",{class:"sa-add"},this.renderForm("inline"),n&&!W(this.caps,this.name,this.canConfigure)&&e("div",{class:"sa-dest"},e("span",{class:"dest"},e(H,{name:"folder",size:14}),e("span",null,n)),this.canPickFolder()&&e("button",{type:"button",class:"btn",onClick:()=>this.listFolders(this.subDir?this.subDir.split("/"):[])},"Choose folder…"))),e("div",{class:"tabs",role:"tablist","aria-label":"Downloads"},[["active","Active"],["finished","Finished"],["retrying","Retrying"]].map((([t,i])=>e("button",{type:"button",role:"tab","aria-selected":this.tab===t?"true":"false",class:{on:this.tab===t},onClick:()=>this.tab=t},i,e("b",null,s[t].length))))),"finished"===this.tab&&s.finished.length>0&&e("div",{class:"tab-h"},e("span",null,s.finished.length," finished"),s.finished.some(A)&&e("button",{type:"button",class:"lnk",onClick:()=>this.clearFinished()},"Clear finished")),o.length?this.renderRows(o):0===i.length?e(le,{nodeName:this.name,folder:n}):e("div",{class:"muted pad"},"retrying"===this.tab?"Nothing is retrying.":"finished"===this.tab?"Nothing has finished yet.":"Nothing is running.")])}render(){return e(a,{key:"6a7316df730c5bc4bc588f7d05e19033d98a9d0a",class:{compact:this.compact,standalone:!this.compact}},this.compact?this.renderCompact():this.renderStandalone(),this.renderConfirm(),this.picker&&e(Y,{key:"412dc8107ea30420f022a49f188ea020eabd46f5",root:this.caps?.folder??"",path:this.picker.path,folders:this.picker.folders,error:this.picker.error,newName:this.picker.newName,onOpen:e=>this.listFolders([...this.picker.path,e]),onUp:e=>this.listFolders(this.picker.path.slice(0,e)),onNewName:e=>this.picker={...this.picker,newName:e},onCancel:()=>this.picker=null,onSave:()=>this.savePicker()}),this.player&&e("div",{key:"61bc6c3ab32346d87c0ed02280182fdae234eb71",class:"overlay player"},e("phirepass-media-player",{key:"59d99ac6289a146ba106e9cb8682d5f7b4383e26",src:this.player.src,name:this.player.name,status:this.playerStatus(),ready:this.playerReady(),positionKey:`dl:${this.player.downloadId}`,onPhirepassPlayerClose:()=>this.player=null})),e(oe,{key:"fa27f16c8f72435939e51b48d92b6f10b0535d80",notices:this.notices,onDismiss:e=>this.dismiss(e)}))}playerRow(){return this.player?this.jobs[this.player.downloadId]:void 0}playerStatus(){const e=this.playerRow();if(!e)return this.player?"On the node":void 0;if(_(e.state))return"On the node";const t=e.total_bytes?` · ${(e.done_bytes/e.total_bytes*100).toFixed(1)}%`:"";return`${"Downloading"===e.state?"Downloading":e.state}${t}`}playerReady(){const e=this.playerRow();if(!e||_(e.state))return;const t=R(e);return t.file?.ready_from_start}static get watchers(){return{channel:[{onChannel:0}],connected:[{onConnected:0}],browsingPath:[{onBrowsing:0}],browsingService:[{onBrowsing:0}],nodeId:[{onNode:0}]}}};ge.style=":host{--card:220 18% 10%;--bg:216 18% 7%;--border:220 15% 18%;--primary:160 60% 45%;--primary-foreground:220 20% 7%;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:215 10% 52%;--foreground:210 20% 90%;--amber:38 75% 55%;--blue:206 72% 63%;--radius:0.375rem;display:block;color:hsl(var(--foreground));font-family:ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;font-size:13px;line-height:1.45;container-type:inline-size}:host(.standalone){position:relative;height:100%;background:hsl(var(--card));border:1px solid hsl(var(--border));border-radius:var(--radius);overflow:auto}:host(.compact){flex:none}*{box-sizing:border-box}button{font:inherit;color:inherit;cursor:pointer}button:disabled{cursor:not-allowed}:focus-visible{outline:2px solid hsl(var(--primary));outline-offset:2px}.hidden-input{display:none}.mono,code,.stats,.sum,.inp,.dest,.detect .host{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace}code{font-size:12px}.muted{color:hsl(var(--muted-foreground))}.pad{padding:18px 14px}.ib{width:28px;height:28px;display:inline-grid;place-items:center;border-radius:4px;border:1px solid transparent;background:transparent;color:hsl(var(--muted-foreground));flex:none;padding:0}.ib:hover:not(:disabled){background:hsl(var(--muted));color:hsl(var(--foreground))}.ib:disabled{opacity:0.4}.ib.new{color:hsl(var(--primary));border-color:hsl(var(--primary) / 0.55);background:hsl(var(--primary) / 0.12)}.btn{border-radius:4px;padding:7px 14px;font-size:12px;font-weight:600;border:1px solid hsl(var(--border));background:hsl(var(--muted));white-space:nowrap;display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:hsl(var(--foreground))}.btn:hover:not(:disabled){border-color:hsl(var(--muted-foreground))}.btn.pri{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground))}.btn.dng{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:#fff}.btn:disabled{opacity:0.45}.lnk{background:none;border:0;color:hsl(var(--muted-foreground));font-size:11px;padding:2px 4px;display:inline-flex;align-items:center;gap:4px}.lnk:hover{color:hsl(var(--foreground))}.lnk.inline{color:hsl(var(--primary));padding:0}.pill{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:2px 7px;border-radius:3px;white-space:nowrap;flex:none}.pill.dl{background:hsl(var(--primary) / 0.18);color:hsl(var(--primary))}.pill.meta,.pill.sd{background:hsl(var(--blue) / 0.18);color:hsl(var(--blue))}.pill.mv{background:hsl(var(--amber) / 0.18);color:hsl(var(--amber))}.pill.ok{background:hsl(var(--primary));color:hsl(var(--primary-foreground))}.pill.err{background:hsl(var(--destructive) / 0.2);color:hsl(var(--destructive))}.pill.ps,.pill.q{background:hsl(var(--muted));color:hsl(var(--muted-foreground))}.bar{display:block;height:5px;border-radius:3px;background:hsl(var(--muted));overflow:hidden;position:relative}.bar i{display:block;height:100%;background:hsl(var(--primary));border-radius:3px;transition:width 0.6s linear}.bar.indet i{width:30% !important;animation:slide 1.3s ease-in-out infinite;background:hsl(var(--blue))}.bar.paused i{background:hsl(var(--muted-foreground))}.bar.fail i{background:hsl(var(--destructive))}.bar.moving i{background:hsl(var(--amber))}.bar.seed i{background:hsl(var(--blue))}@keyframes slide{0%{transform:translateX(-100%)}100%{transform:translateX(340%)}}.jobs{display:flex;flex-direction:column}.job{display:grid;grid-template-columns:28px minmax(0, 1fr) auto;gap:4px 10px;padding:10px 12px;border-bottom:1px solid hsl(var(--border) / 0.6);align-items:center}.job:last-child{border-bottom:0}.job .kind{grid-row:span 3;align-self:start;width:28px;height:28px;border-radius:6px;display:grid;place-items:center;background:hsl(var(--muted));color:hsl(var(--muted-foreground))}.job .kind.t{color:hsl(var(--blue))}.job .kind.h{color:hsl(var(--primary))}.job .kind.n{color:hsl(var(--amber))}.job .title{display:flex;gap:8px;align-items:center;min-width:0}.job .title .nm{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.job .acts{display:flex;gap:2px;grid-row:1;grid-column:3}.job .bar,.job .stats{grid-column:2 / 4}.stats{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:11px;color:hsl(var(--muted-foreground));font-variant-numeric:tabular-nums}.stats b{color:hsl(var(--foreground));font-weight:500}.stats .err{color:hsl(var(--destructive))}.job[data-state='Deleting']{opacity:0.6}.drawer{border-top:1px solid hsl(var(--border));background:hsl(var(--bg));display:flex;flex-direction:column;max-height:min(46vh, 380px)}.drawer-h{display:flex;align-items:center;gap:10px;padding:6px 12px;border-bottom:1px solid hsl(var(--border));flex:none}.drawer-h h4,.strip h4{margin:0;font-size:12px;font-weight:600;letter-spacing:0.04em;text-transform:uppercase}.sum{color:hsl(var(--muted-foreground));font-size:11px;font-variant-numeric:tabular-nums}.sp{flex:1}.drawer-b{overflow:auto;min-height:0}.strip{display:flex;align-items:center;gap:10px;padding:7px 12px;border:0;border-top:1px solid hsl(var(--border));background:hsl(var(--bg));width:100%;text-align:left}.strip .bar{flex:1 1 120px}.overlay{position:absolute;inset:0;background:rgba(5, 7, 9, 0.6);display:grid;place-items:center;padding:14px;z-index:20}:host(.standalone) .overlay{position:fixed}.modal{width:min(100%, 420px);max-height:100%;overflow:auto;background:hsl(var(--card));border:1px solid hsl(var(--border));border-radius:8px;box-shadow:0 20px 50px -10px rgba(0, 0, 0, 0.7)}.modal.wide{width:min(100%, 480px)}.dlg,.fetch-form.dialog{padding:16px;display:flex;flex-direction:column;gap:14px}.dlg h4,.dlg-h h4{margin:0;font-size:14px;font-weight:600}.dlg-h{display:flex;align-items:center;gap:10px;color:hsl(var(--primary))}.dlg-h h4{color:hsl(var(--foreground))}.dlg-f{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}.dlg-f .left{margin-right:auto}.dtx{margin:0;font-size:13px}.hint{font-size:11px;color:hsl(var(--muted-foreground));margin:0}.hint.block{display:block;margin-top:2px}.hint.err{color:hsl(var(--destructive))}.hint.where{color:hsl(var(--amber))}.fld{display:flex;flex-direction:column;gap:6px;min-width:0}.fld>label,.fld>span:first-child,legend{font-size:11px;text-transform:uppercase;letter-spacing:0.05em;color:hsl(var(--muted-foreground))}.inp{width:100%;min-width:0;background:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:4px;color:hsl(var(--foreground));padding:8px 10px;font-size:12px}.inp:focus{outline:none;border-color:hsl(var(--primary))}.inline-row{display:flex;gap:8px;align-items:stretch}.detect{display:flex;align-items:center;gap:8px;font-size:12px;color:hsl(var(--muted-foreground));min-height:20px;min-width:0}.detect .host{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.note{display:flex;gap:8px;align-items:flex-start;font-size:12px;line-height:1.45;padding:8px 10px;border-radius:4px;border:1px solid hsl(var(--border));background:hsl(var(--muted))}.note svg{flex:none;margin-top:2px}.note.err{border-color:hsl(var(--destructive) / 0.5)}.note.err svg{color:hsl(var(--destructive))}.note.warn{border-color:hsl(var(--amber) / 0.5)}.note.warn svg{color:hsl(var(--amber))}.note.info svg{color:hsl(var(--primary))}.or{display:flex;align-items:center;gap:10px;color:hsl(var(--muted-foreground));font-size:11px;text-transform:uppercase;letter-spacing:0.06em}.or::before,.or::after{content:'';flex:1;height:1px;background:hsl(var(--border))}.drop{border:1px dashed hsl(var(--border));border-radius:6px;padding:14px;display:flex;align-items:center;gap:12px;color:hsl(var(--muted-foreground));font-size:12px;background:transparent;text-align:left}.drop svg{color:hsl(var(--blue));flex:none}.drop b{color:hsl(var(--foreground));font-weight:500}.filechip{display:flex;gap:10px;align-items:center;padding:10px;border:1px solid hsl(var(--border));border-radius:4px;background:hsl(var(--muted))}.filechip>svg{color:hsl(var(--blue));flex:none}.filechip>div{flex:1;min-width:0}.filechip b{display:block;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.filechip span{color:hsl(var(--muted-foreground));font-size:11px}.filechip.bad{border-color:hsl(var(--destructive) / 0.55)}.filechip.bad>svg{color:hsl(var(--destructive))}.dest-row,.sa-dest{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.dest{display:flex;align-items:center;gap:8px;background:hsl(var(--bg));border:1px solid hsl(var(--border));border-radius:4px;padding:7px 10px;font-size:12px;min-width:0;flex:1 1 200px}.dest span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dest svg{color:hsl(var(--primary));flex:none}fieldset.order{border:0;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}fieldset.order legend{margin-bottom:6px}.opt{display:flex;gap:8px;align-items:flex-start;padding:8px 10px;border:1px solid hsl(var(--border));border-radius:4px;font-size:12px;cursor:pointer}.opt.on{border-color:hsl(var(--primary));background:hsl(var(--primary) / 0.08)}.opt input,.checkline input,.seg input{accent-color:hsl(var(--primary));margin:2px 0 0}.checkline{display:flex;gap:8px;align-items:flex-start;font-size:12px;cursor:pointer}.login{display:flex;flex-direction:column;gap:8px}.login>.lnk{align-self:flex-start;padding-left:0}.auth{display:flex;flex-direction:column;gap:10px;padding:10px;border:1px solid hsl(var(--border));border-radius:4px}.seg{display:flex;flex-wrap:wrap;gap:6px}.seg label{display:flex;gap:6px;align-items:center;font-size:11px;padding:4px 8px;border:1px solid hsl(var(--border));border-radius:999px;cursor:pointer}.seg label.on{border-color:hsl(var(--primary));color:hsl(var(--primary))}.seg input{margin:0}.crumbs{display:flex;flex-wrap:wrap;align-items:center;gap:2px;font-family:ui-monospace, SFMono-Regular, Menlo, monospace}.crumbs .lnk{font-size:12px}.crumbs .sep{color:hsl(var(--muted-foreground))}.folders{display:flex;flex-direction:column;border:1px solid hsl(var(--border));border-radius:4px;max-height:220px;overflow:auto}.folders .muted{padding:10px}.folder-row{display:flex;align-items:center;gap:8px;padding:7px 10px;border:0;border-bottom:1px solid hsl(var(--border) / 0.6);background:transparent;text-align:left;font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:12px}.folder-row:hover{background:hsl(var(--muted))}.folder-row svg{color:hsl(var(--primary))}.blocker{display:flex;flex-direction:column;gap:10px}.empty{display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px;padding:30px 20px}.empty>svg{color:hsl(var(--muted-foreground))}.empty b{font-size:14px;font-weight:600}.empty span{color:hsl(var(--muted-foreground));font-size:12px;max-width:44ch}.spin{width:22px;height:22px;border-radius:50%;border:3px solid hsl(var(--border));border-top-color:hsl(var(--primary));animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.standalone{display:flex;flex-direction:column;min-height:100%}.sa-head{padding:14px 16px 10px;display:flex;flex-direction:column;gap:4px}.sa-title{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.sa-title h3{margin:0;font-size:16px;font-weight:600}.sa-title .node{color:hsl(var(--muted-foreground))}.saving{font-size:12px;color:hsl(var(--muted-foreground))}.sa-add{padding:0 16px 14px;display:flex;flex-direction:column;gap:10px;border-bottom:1px solid hsl(var(--border))}.fetch-form.inline{display:flex;flex-direction:column;gap:10px}.tabs{display:flex;gap:4px;padding:0 10px;border-bottom:1px solid hsl(var(--border));overflow-x:auto}.tabs button{padding:9px 10px;font-size:12px;color:hsl(var(--muted-foreground));border:0;border-bottom:2px solid transparent;background:none;white-space:nowrap}.tabs button.on{color:hsl(var(--foreground));border-bottom-color:hsl(var(--primary))}.tabs b{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-weight:500;color:hsl(var(--muted-foreground));margin-left:6px}.tab-h{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;font-size:12px;color:hsl(var(--muted-foreground));border-bottom:1px solid hsl(var(--border) / 0.6)}.toasts{position:absolute;left:12px;right:12px;bottom:12px;display:flex;flex-direction:column;gap:8px;z-index:30;pointer-events:none;align-items:flex-end}:host(.standalone) .toasts{position:sticky;margin:12px}.toast{pointer-events:auto;display:flex;gap:10px;align-items:center;padding:10px 12px;background:hsl(var(--bg));border:1px solid hsl(var(--primary) / 0.5);border-radius:6px;width:min(100%, 420px);box-shadow:0 12px 30px -12px rgba(0, 0, 0, 0.7)}.toast>svg{color:hsl(var(--primary));flex:none}.toast.bad{border-color:hsl(var(--destructive) / 0.55)}.toast.bad>svg{color:hsl(var(--destructive))}.toast .t{flex:1;min-width:0}.toast .t b{display:block;font-weight:600}.toast .t span{color:hsl(var(--muted-foreground));font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block}.overlay.player{padding:10px}.overlay.player phirepass-media-player{width:min(100%, 880px)}@container (max-width: 480px){.job{padding:9px 10px}.job .title .pill.meta{display:none}.inline-row{flex-wrap:wrap}.inline-row .inp{flex-basis:100%}.inline-row .btn.pri{flex:1;justify-content:center}.stats{gap:2px 10px}}@media (prefers-reduced-motion: reduce){.bar i{transition:none}.bar.indet i{animation:none;width:100% !important;opacity:0.5}.spin{animation:none}}";const fe={mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",mkv:"video/x-matroska",mov:"video/quicktime",mp3:"audio/mpeg",m4a:"audio/mp4",flac:"audio/flac",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",wav:"audio/wav"};function me(e){return fe[function(e){const t=/\.([a-z0-9]+)$/i.exec(e);return t?t[1].toLowerCase():""}(e)]??"application/octet-stream"}function ye(e,t){return function(e,t){return!(!Number.isFinite(t)||t<=0)&&(e>=.95*t||t-e<=120)}(e,t)?"clear":e<30?"skip":"save"}const ve="phirepass.player.position.",xe={async get(e){try{const t=window.localStorage.getItem(ve+e);if(!t)return null;const i=JSON.parse(t);return"number"==typeof i?.secs?i:null}catch{return null}},async set(e,t,i){try{window.localStorage.setItem(ve+e,JSON.stringify({secs:t,duration:i,at:Date.now()}))}catch{}},async clear(e){try{window.localStorage.removeItem(ve+e)}catch{}}},we=class{constructor(e){new.target===we&&t(this,e),this.playerClose=i(this,"phirepassPlayerClose")}get el(){return s(this)}media;lastSave=0;resumeAt=0;everPlayed=!1;positionPrompted=!1;availabilityId;onRemoteConnect=()=>this.phase="casting";onRemoteDisconnect=()=>{"casting"===this.phase&&(this.phase=this.everPlayed?"playing":"buffering")};src;name;mime;status;ready;positionStore;positionKey;remotePlayback;linkMinter;castDevice;playerClose;phase="buffering";stored=null;castAvailable=!1;castSrc=null;linkNote=null;currentTime=0;duration=0;get store(){return this.positionStore??xe}get audio(){return(this.mime??me(this.name)).startsWith("audio/")}async componentWillLoad(){if(this.positionKey){const e=await this.store.get(this.positionKey).catch((()=>null));e&&"save"===ye(e.secs,e.duration)&&(this.stored=e,this.positionPrompted=!0,this.phase="prompt")}}componentDidLoad(){this.watchRemote()}disconnectedCallback(){this.savePosition(!0);const e=this.remote();e&&(e.removeEventListener("connect",this.onRemoteConnect),e.removeEventListener("disconnect",this.onRemoteDisconnect),void 0!==this.availabilityId&&e.cancelWatchAvailability(this.availabilityId).catch((()=>{})))}onSrc(){this.castSrc=null,this.everPlayed=!1,this.phase="buffering"}async close(){await this.savePosition(!0),this.media?.pause?.(),this.playerClose.emit()}get minter(){return this.linkMinter??function(e=(e,t)=>fetch(e,t)){return async t=>{try{const i=await e(t,{method:"POST",credentials:"include"});if(!i.ok)return null;const s=await i.json();return"string"==typeof s.ticket&&s.ticket?function(e,t,i=globalThis.location?.href){const s=/^[a-z][a-z0-9+.-]*:/i.test(e)?new URL(e):new URL(e,i);return s.searchParams.set("ticket",t),s.href}(t,s.ticket):null}catch{return null}}}()}async cast(){if(!this.castSrc){const e=await this.minter(this.src),t=this.media;if(e&&t){const i=t.currentTime,s=!t.paused;this.castSrc=e,t.src=e,this.resumeAt=i,i>0&&(t.currentTime=i),s&&t.play?.()?.catch?.((()=>{}))}}await(this.remote()?.prompt().catch((()=>{})))}async copyLink(){const e=this.castSrc??await this.minter(this.src);if(e)try{await navigator.clipboard.writeText(e),this.linkNote="Link copied. It works in VLC until it expires."}catch{this.linkNote=e}else this.linkNote="Could not make a link."}remote(){return this.remotePlayback??this.media?.remote}async watchRemote(){const e=this.remote();if(e&&!this.audio){e.addEventListener("connect",this.onRemoteConnect),e.addEventListener("disconnect",this.onRemoteDisconnect),"connected"===e.state&&(this.phase="casting");try{this.availabilityId=await e.watchAvailability((e=>this.castAvailable=e))}catch{this.castAvailable=!0}}}async savePosition(e=!1){const t=this.media;if(!t||!this.positionKey||!this.everPlayed)return;const i=Date.now();if(!e&&i-this.lastSave<1e4)return;this.lastSave=i;const s=ye(t.currentTime,t.duration);"save"===s?await this.store.set(this.positionKey,t.currentTime,t.duration).catch((()=>{})):"clear"===s&&await(this.store.clear?.(this.positionKey).catch((()=>{})))}startAt(e){this.stored=null,this.phase="buffering",this.resumeAt=e;const t=this.media;t&&(e>0&&(t.currentTime=e),t.play?.()?.catch?.((()=>{})))}retry(){const e=this.media,t=e?.currentTime||this.resumeAt;this.phase="buffering",e&&(e.load?.(),this.startAt(t))}onError(){const e=this.media?.error?.code;this.phase=2===e?"stopped":"unsupported"}bindMedia(e){e&&e!==this.media&&(this.media=e)}renderStage(){switch(this.phase){case"prompt":return e("div",{class:"stage-msg","data-phase":"prompt"},e("b",null,"Resume from ",x(this.stored.secs),"?"),e("span",null,"You stopped here on ",function(e){const t=new Date(e);return`${t.getDate()} ${t.toLocaleString("en-GB",{month:"short"})}`}(this.stored.at),". ",x(this.stored.duration)," in total."),e("div",{class:"row"},e("button",{type:"button",class:"btn",onClick:()=>this.startAt(0)},"Start over"),e("button",{type:"button",class:"btn pri",onClick:()=>this.startAt(this.stored.secs)},"Resume")));case"buffering":return e("div",{class:"stage-msg overlay-msg","data-phase":"buffering"},e("span",{class:"spin","aria-hidden":"true"}),e("b",null,"Buffering"),void 0!==this.ready&&e("span",null,m(this.ready)," ready from the start"));case"waiting":return e("div",{class:"stage-msg overlay-msg","data-phase":"waiting"},e("span",{class:"spin","aria-hidden":"true"}),e("b",null,"Waiting for this part to download"),e("span",null,"You skipped ahead of what the node has. Playback resumes by itself."));case"unsupported":return e("div",{class:"stage-msg","data-phase":"unsupported"},e(H,{name:"warn",size:28}),e("b",null,"This browser cannot play this format"),e("span",null,"The download is not affected. Download the file to play it in another app."),e("a",{class:"btn pri",href:this.src,download:this.name},"Download file"));case"stopped":return e("div",{class:"stage-msg","data-phase":"stopped"},e(H,{name:"signal",size:28}),e("b",null,"Playback stopped"),e("span",null,"The connection to the node was lost."),e("button",{type:"button",class:"btn pri",onClick:()=>this.retry()},"Try again"));case"casting":return e("div",{class:"stage-msg","data-phase":"casting"},e(H,{name:"cast",size:28}),e("b",null,"Playing on ",this.castDevice??"your TV"),e("span",null,"The TV reads the file from the node. You can close this tab."),e("span",{class:"clock"},x(this.currentTime)," / ",x(this.duration)),e("button",{type:"button",class:"btn",onClick:()=>{this.remote()?.prompt().catch((()=>{}))}},"Stop casting"));default:return null}}render(){const t=this.audio,i=function(e,t){const i=t??me(e);return"video/x-matroska"===i?"TVs cannot play MKV files. Download it and play it with VLC.":"video/quicktime"===i?"TVs cannot play MOV files.":null}(this.name,this.mime),s="function"==typeof this.media?.webkitShowPlaybackTargetPicker,o={ref:e=>this.bindMedia(e),src:this.castSrc??this.src,controls:!0,preload:"prompt"===this.phase?"metadata":"auto",autoplay:!this.positionPrompted,playsInline:!0,class:{hidden:"prompt"===this.phase||"unsupported"===this.phase||"stopped"===this.phase||"casting"===this.phase},onCanPlay:()=>{"buffering"!==this.phase&&"waiting"!==this.phase||(this.phase="playing")},onPlaying:()=>{this.everPlayed=!0,"casting"!==this.phase&&(this.phase="playing")},onWaiting:()=>{"playing"===this.phase&&(this.phase=this.everPlayed?"waiting":"buffering")},onTimeUpdate:e=>{this.currentTime=e.target.currentTime,this.savePosition()},onDurationChange:e=>this.duration=e.target.duration||0,onPause:()=>{this.savePosition(!0)},onError:()=>this.onError()};return e(a,{key:"2a0961d6bb91d0d28c516e42b11c8988a7721c99",class:{audio:t}},e("header",{key:"c2339f0ca216eb347a09c9be77df877a54cf8b47",class:"bar"},e("span",{key:"ae5b874219ff03c803febb079027549ee68751b6",class:"nm",title:this.name},this.name),this.status&&e("span",{key:"09ccaae203ecb0c205bd2e4b1ac9fc2f5d9b22a1",class:"pill"},this.status),e("span",{key:"7304adbb0b50a3bcf8c4783f3444029f97e84fa9",class:"sp"}),!t&&(this.castAvailable||i)&&e("button",{key:"5c2b9d5d36ae0fd723d81da54e8e4acbf79a39d0",type:"button",class:"ib",disabled:!!i,title:i??"Cast","aria-label":i?`Cast unavailable: ${i}`:"Cast",onClick:()=>{this.cast()}},e(H,{key:"f45d71a1a5b1144376b6360812185dcbc7e5e57f",name:"cast",size:15})),e("button",{key:"71964d197aee9de089f895fd0c017e1e4e04297a",type:"button",class:"ib",title:"Copy link for VLC","aria-label":"Copy link for VLC",onClick:()=>{this.copyLink()}},e(H,{key:"643d026d4dd85cad24e1e6b01dcba1bfda956825",name:"link",size:15})),!t&&s&&e("button",{key:"a42d75246d807366e427b660062b47cc03890fac",type:"button",class:"ib",title:"AirPlay","aria-label":"AirPlay",onClick:()=>this.media.webkitShowPlaybackTargetPicker()},e(H,{key:"21c9dc4e3ea560f72d230b017f2f73314ae17ef4",name:"cast",size:15})),e("button",{key:"f1413cec5dceb9f1dfe9b0470d3784ccaf20d08a",type:"button",class:"ib","aria-label":"Close player",title:"Close",onClick:()=>{this.close()}},e(H,{key:"707e719e7608edbad68185c8071ab90e2da614d4",name:"x",size:14}))),e("div",{key:"51673733f9cd732cfe5f1b9406ddec3787ba0e6c",class:{stage:!0,audio:t},"data-phase":this.phase},e(t?"audio":"video",{...o}),this.renderStage()),this.linkNote&&e("p",{key:"bd2db764da4183f67d1589a8be5aa4e8e7df76f3",class:"link-note",role:"status"},this.linkNote))}static get watchers(){return{src:[{onSrc:0}]}}};function ke(e){return e.endsWith(".phirepass-part")}we.style=":host{--card:220 18% 10%;--bg:216 18% 7%;--border:220 15% 18%;--primary:160 60% 45%;--primary-foreground:220 20% 7%;--muted:220 15% 13%;--muted-foreground:215 10% 52%;--foreground:210 20% 90%;--amber:38 75% 55%;display:flex;flex-direction:column;background:hsl(var(--card));color:hsl(var(--foreground));border:1px solid hsl(var(--border));border-radius:8px;overflow:hidden;font-family:ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;font-size:13px;line-height:1.45;box-shadow:0 20px 50px -10px rgba(0, 0, 0, 0.7)}*{box-sizing:border-box}button,a.btn{font:inherit;color:inherit;cursor:pointer}:focus-visible{outline:2px solid hsl(var(--primary));outline-offset:2px}.bar{display:flex;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid hsl(var(--border));min-width:0}.nm{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.pill{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:2px 7px;border-radius:3px;white-space:nowrap;background:hsl(var(--primary) / 0.18);color:hsl(var(--primary));flex:none}.sp{flex:1}.ib{width:28px;height:28px;display:inline-grid;place-items:center;border-radius:4px;border:1px solid transparent;background:transparent;color:hsl(var(--muted-foreground));padding:0;flex:none}.ib:hover:not(:disabled){background:hsl(var(--muted));color:hsl(var(--foreground))}.ib:disabled{opacity:0.4;cursor:not-allowed}.btn{border-radius:4px;padding:7px 14px;font-size:12px;font-weight:600;border:1px solid hsl(var(--border));background:hsl(var(--muted));text-decoration:none;display:inline-flex;align-items:center}.btn.pri{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground))}.stage{position:relative;background:#000;min-height:220px;display:grid}.stage.audio{min-height:0;background:hsl(var(--bg));padding:14px}.stage>video,.stage>audio{grid-area:1 / 1;width:100%;max-height:70vh;display:block}.stage>audio{align-self:center}.stage>.hidden{visibility:hidden}.stage-msg{grid-area:1 / 1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:8px;padding:22px;z-index:1}.stage.audio .stage-msg{padding:8px}.overlay-msg{background:rgba(0, 0, 0, 0.55);pointer-events:none}.stage-msg>svg{color:hsl(var(--amber))}.stage-msg[data-phase='casting']>svg{color:hsl(var(--primary))}.stage-msg b{font-size:14px;font-weight:600}.stage-msg span{color:hsl(var(--muted-foreground));font-size:12px;max-width:44ch}.stage-msg .clock{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-variant-numeric:tabular-nums}.stage-msg .row{display:flex;gap:8px;margin-top:4px}.spin{width:26px;height:26px;border-radius:50%;border:3px solid hsl(var(--border));border-top-color:hsl(var(--primary));animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.spin{animation:none}}.link-note{margin:0;padding:6px 10px;font-size:12px;color:var(--w-dim, #737f8c);overflow-wrap:anywhere;border-top:1px solid var(--w-border, #262c35)}";const Ce=/\.(mp4|m4v|webm|mkv|mov|mp3|m4a|flac|ogg|oga|opus|wav)$/i;function Ie(e){const t=e.replace(/\/{2,}/g,"/");return t.length>1?t.replace(/\/+$/,""):t}function Me(e,t){return Ie(e)===Ie(t)}const _e=({count:t,onClick:i})=>e("button",{type:"button",class:"action fetch",onClick:i,title:"Fetch from a link, magnet or torrent","aria-label":"Fetch from a link, magnet or torrent"},e(H,{name:"fetch",size:14}),t>0&&e("span",{class:"badge","aria-label":`${t} active`},t)),De=({name:t,busy:i,onCancel:s,onConfirm:a})=>e("section",{class:"delete-modal visible"},e("div",{class:"delete-dialog",role:"dialog","aria-modal":"true","aria-label":"This file is still downloading",tabindex:-1,onKeyDown:e=>{"Escape"===e.key&&s()}},e("div",{class:"title"},"This file is still downloading"),e("div",{class:"message"},"Deleting ",e("span",{class:"file-name inline"},t)," deletes its download."),e("div",{class:"modal-actions"},e("button",{type:"button",class:"btn secondary",onClick:s,disabled:i},"Keep it"),e("button",{type:"button",class:"btn destructive",onClick:a,disabled:i},"Delete download")))),Se=({menu:t,onFetch:i,onDownload:s,onRename:a,onDelete:o,onClose:n})=>e("div",{class:"context-backdrop",onClick:n,onContextMenu:e=>(e.preventDefault(),n())},e("div",{class:"context-menu",role:"menu","aria-label":`Actions for ${t.name}`,style:{left:`${t.x}px`,top:`${t.y}px`},onClick:e=>e.stopPropagation()},e("button",{type:"button",role:"menuitem",class:"primary",onClick:i},e(H,{name:"fetch",size:13})," Download torrent contents here"),e("hr",null),e("button",{type:"button",role:"menuitem",onClick:s},"Download"),e("button",{type:"button",role:"menuitem",onClick:a},"Rename"),e("button",{type:"button",role:"menuitem",class:"danger",onClick:o},"Delete"))),ze=class{constructor(e){new.target===ze&&t(this,e),this.maximizeEvent=i(this,"maximize"),this.connectionStateChanged=i(this,"connectionStateChanged")}get el_host(){return s(this)}channel;domReady=!1;runtimeReady=!1;connected=!1;uploadInputEl;msgId=1;activeUploadToken=0;pendingUploadStarts=new Map;pendingUploadAcks=new Map;pendingDownloadStarts=new Map;activeDownloads=new Map;activeDownloadMsgId;pendingOps=new Map;promptInputEl;editorPath="";editorTextEl;session_id;name="SFTP";description="Client";hideHeader=!1;serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;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;channelFactory;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;delete_is_dir=!1;delete_recursive=!1;delete_error="";prompt_kind=null;prompt_value="";prompt_error="";prompt_busy=!1;chmod_target=null;chmod_mode=0;chmod_error="";chmod_busy=!1;show_editor=!1;editor_name="";editor_text="";editor_saved_text="";editor_busy="";editor_error="";editor_confirm_discard=!1;editor_loaded=!1;filter="";sort_key="name";sort_asc=!0;channel_ready=!1;fetch_count=0;fresh_names=[];part_delete=null;torrent_menu=null;listing_player=null;downloaderEl;fetch_enabled(){return h(this.channel)}stream_base(){return`${this.allowInsecure?"http":"https"}://${this.serverHost}${!this.allowInsecure&&443===this.serverPort||this.allowInsecure&&80===this.serverPort?"":`:${this.serverPort}`}`}on_fetch_completed(e){Me(function(e){return Ie(e.sub_dir?`${e.dest_root}/${e.sub_dir}`:e.dest_root)}(e),this.current_dir)&&(this.fresh_names=[...this.fresh_names.filter((t=>t!==e.name)),e.name],this.refresh_directory())}on_show_in_folder(e){this.fresh_names=[e.name],Me(e.path,this.current_dir)||this.list_breadcrumb(e.path)}async on_row_context_menu(e,t){if("File"!==e.kind||!/\.torrent$/i.test(e.name)||!this.downloaderEl)return;const i=this.item_path(e);if(t.preventDefault(),null===await this.downloaderEl.torrentPathFor(i))return;const s=this.el_host.getBoundingClientRect();this.selected_item=e,this.torrent_menu={x:t.clientX-s.left,y:t.clientY-s.top,path:i,name:e.name}}async play_listing_file(e,t){t.preventDefault(),t.stopPropagation();const i=this.channel;if("function"!=typeof i.send_sftp_open_stream)return;const s=this.item_path(e);try{const t=await this.run_op("play",(e=>i.send_sftp_open_stream(this.nodeId,this.session_id,s,e)));if("Stream"!==t.result||!t.token)throw new Error("The node did not open a stream.");this.listing_player={src:`${this.stream_base()}/api/web/stream/${encodeURIComponent(this.nodeId)}/t/${encodeURIComponent(t.token)}`,name:e.name,key:`node:${this.nodeId}:${s}`}}catch(e){this.error_message=this.error_text(e),this.show_error=!0}}listing_can_play(){return"function"==typeof this.channel?.send_sftp_open_stream}toggle_max(){this.maximizeEvent?.emit(!this.max)}async connectedCallback(){this.channelFactory||await o(),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.close_comms()}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(new Error("Upload start aborted"))})),this.pendingUploadStarts.clear(),this.pendingUploadAcks.forEach((e=>{window.clearTimeout(e.timeout),e.reject(new Error("Upload chunk aborted"))})),this.pendingUploadAcks.clear(),this.pendingDownloadStarts.forEach((e=>{window.clearTimeout(e.timeout),e.reject(new Error("Download start aborted"))})),this.pendingDownloadStarts.clear(),this.pendingOps.forEach((e=>{window.clearTimeout(e.timeout),e.reject(new Error(`Could not ${e.verb}: the session ended.`))})),this.pendingOps.clear(),this.activeDownloads.clear()}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),i=Math.floor(e%60);return t<60?`${t}m ${i}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(new 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(new 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);const s=this.pendingOps.get(e.msg_id);if(s)return window.clearTimeout(s.timeout),this.pendingOps.delete(e.msg_id),s.reject(new Error(e.message||`Could not ${s.verb}.`)),void(this.show_loader=!1)}switch(e.kind){case l.Generic:case l.Authentication:this.error_message=e.message||"An unknown error occurred.",this.show_error=!0;break;case l.RequiresUsername:this.show_login_screen_username=!0,this.show_login_screen_password=!1,this.show_login_screen=!0;break;case l.RequiresPassword:this.show_login_screen_username=!1,this.show_login_screen_password=!0,this.show_login_screen=!0;break;case l.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.serviceId),this.status="Connected",this.channel_ready=!0}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),e.path!==this.current_dir&&(this.filter=""),e.path!==this.current_dir&&(this.fresh_names=[]),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,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(new 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,n=this.activeDownloads.get(t);if(!n)return;n.download_id=s,n.total_chunks=a,n.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(new 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 n=await o;let r=0;const l=performance.now();for(let a=0;a<s;a+=1){if(t!==this.activeUploadToken)throw new Error("Upload cancelled");const s=a*i,o=Math.min(s+i,e.size),d=new Uint8Array(await e.slice(s,o).arrayBuffer());await new Promise(((e,t)=>{const i=`${n}_${a}`,s=window.setTimeout((()=>{this.pendingUploadAcks.delete(i),t(new 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,n,a,d.length,d,null)})),r+=d.length,this.update_upload_progress(r,e.size,l)}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_op_result(e){if(void 0===e.msg_id)return;const t=this.pendingOps.get(e.msg_id);t&&(window.clearTimeout(t.timeout),this.pendingOps.delete(e.msg_id),t.resolve(e.result))}run_op(e,t,i=3e4){if(!this.session_id)return Promise.reject(new Error("No active SFTP session."));const s=this.next_msg_id();return new Promise(((a,o)=>{const n=window.setTimeout((()=>{this.pendingOps.delete(s),o(new Error(`Timed out trying to ${e}. This node's agent may be too old to support it.`))}),i);this.pendingOps.set(s,{verb:e,timeout:n,resolve:a,reject:o});try{t(s)}catch(e){window.clearTimeout(n),this.pendingOps.delete(s),o(e instanceof Error?e:new Error(String(e)))}}))}error_text(e){return e instanceof Error?e.message:String(e)}item_path(e){return this.join_path(e.path,e.name)}join_path(e,t){return e&&"/"!==e?e.endsWith("/")?`${e}${t}`:`${e}/${t}`:`/${t}`}invalid_name(e){return e?"."===e||".."===e?"That name is reserved.":e.includes("/")?'A name cannot contain "/".':e.includes("\0")?"A name cannot contain a null byte.":"":"Enter a name."}handle_tunnel_data(e){console.log("received tunnel data:",e)}handle_tunnel_closed(e){this.clear_creds_buffer(),this.close_comms()}open_comms(){const e=`${this.create_web_socket_endpoint()}/api/web/ws`;this.channel=this.channelFactory?this.channelFactory(e,this.nodeId,this.serverId||void 0):this.serverId?new n(e,this.nodeId,this.serverId):new n(e,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([d.Connected]),this.channel.authenticate(this.token,this.nodeId),this.status="Authenticating..."})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([d.Disconnected]),this.status="Disconnected",this.channel_ready=!1})),this.channel.on_connection_error((e=>{this.connectionStateChanged.emit([d.Error,e]),this.status="Error "+e.message})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((e=>{const{web:t}=e.data;if(b(t)||t.type===r.Error&&(t.msg_id??0)>=p)this.downloaderEl?.receive(e);else switch(t.type){case r.Error:this.handle_error(t);break;case r.AuthSuccess:this.handle_auth_success(t);break;case r.TunnelOpened:this.handle_tunnel_opened(t);break;case r.TunnelClosed:this.handle_tunnel_closed(t);break;case r.TunnelData:this.handle_tunnel_data(t);break;case r.SFTPListItems:this.handle_sftp_list_items(t);break;case r.SFTPUploadStartResponse:this.handle_upload_start_response(t);break;case r.SFTPUploadChunkAck:this.handle_upload_chunk_ack(t);break;case r.SFTPDownloadStartResponse:this.handle_download_start_response(t);break;case r.SFTPDownloadChunk:this.handle_download_chunk(t);break;case r.SFTPOpResult:this.handle_op_result(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.delete_error="",this.delete_is_dir=!1,this.delete_recursive=!1,this.prompt_kind=null,this.prompt_value="",this.prompt_error="",this.prompt_busy=!1,this.chmod_target=null,this.chmod_error="",this.chmod_busy=!1,this.show_editor=!1,this.editor_busy="",this.editor_error="",this.editor_confirm_discard=!1,this.editor_loaded=!1,this.filter="",this.version="",this.status="Disconnected",this.channel_ready=!1,this.part_delete=null,this.torrent_menu=null,this.listing_player=null}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,"File"===e.kind&&ke(e.name)&&this.downloaderEl?this.downloaderEl.jobForPath(this.item_path(e)).then((t=>{t?this.part_delete={download_id:t.download_id,name:e.name,busy:!1}:this.open_delete_prompt(e)})):this.open_delete_prompt(e)}open_delete_prompt(e){this.delete_file_name=e.name,this.delete_is_dir="Folder"===e.kind,this.delete_recursive=!1,this.delete_error="",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_error="",this.delete_is_dir=!1,this.delete_recursive=!1)}async confirm_delete(){if(this.delete_loading)return;const e=this.selected_item;if(!this.session_id||!e)return void(this.show_delete_modal=!1);const t=this.item_path(e),i=this.delete_is_dir&&this.delete_recursive;this.delete_loading=!0,this.delete_error="",this.show_error=!1,this.status=`Deleting ${e.name}...`;try{await this.run_op("delete",(e=>this.channel.send_sftp_remove(this.nodeId,this.session_id,t,i,e)),i?3e5:3e4),this.delete_loading=!1,this.show_delete_modal=!1,this.delete_file_name="",this.delete_is_dir=!1,this.delete_recursive=!1,this.status="Connected",this.refresh_directory()}catch(e){this.delete_loading=!1,this.delete_error=this.error_text(e),this.status="Connected"}}open_mkdir(){this.session_id&&(this.prompt_kind="mkdir",this.prompt_value="",this.prompt_error="",this.prompt_busy=!1)}on_rename_action(e,t){t.preventDefault(),t.stopPropagation(),this.session_id&&(this.selected_item=e,this.prompt_kind="rename",this.prompt_value=e.name,this.prompt_error="",this.prompt_busy=!1)}close_prompt(){this.prompt_busy||(this.prompt_kind=null,this.prompt_value="",this.prompt_error="",this.promptInputEl=void 0)}async submit_prompt(){if(this.prompt_busy||!this.session_id)return;const e=this.prompt_kind,t=this.prompt_value.trim(),i=this.invalid_name(t);if(i)return void(this.prompt_error=i);const s=this.selected_item;if("rename"===e&&s&&t===s.name)this.close_prompt();else{this.prompt_busy=!0,this.prompt_error="",this.show_error=!1;try{if("mkdir"===e){const e=this.join_path(this.current_dir,t);this.status=`Creating ${t}...`,await this.run_op("create the folder",(t=>this.channel.send_sftp_mkdir(this.nodeId,this.session_id,e,t)))}else{if("rename"!==e||!s)return this.prompt_busy=!1,void this.close_prompt();{const e=this.item_path(s),i=this.join_path(s.path,t);this.status=`Renaming ${s.name}...`,await this.run_op("rename",(t=>this.channel.send_sftp_rename(this.nodeId,this.session_id,e,i,t)))}}this.prompt_busy=!1,this.prompt_kind=null,this.prompt_value="",this.promptInputEl=void 0,this.status="Connected",this.refresh_directory()}catch(e){this.prompt_busy=!1,this.prompt_error=this.error_text(e),this.status="Connected"}}}on_chmod_action(e,t){t.preventDefault(),t.stopPropagation(),this.session_id&&(this.selected_item=e,this.chmod_target=e,this.chmod_mode=4095&(e.attributes.permissions??0),this.chmod_error="",this.chmod_busy=!1)}close_chmod(){this.chmod_busy||(this.chmod_target=null,this.chmod_error="")}toggle_chmod_bit(e){this.chmod_busy||(this.chmod_mode=4095&(this.chmod_mode^e))}on_chmod_octal_input(e){const t=e.trim();/^[0-7]{1,4}$/.test(t)?(this.chmod_error="",this.chmod_mode=4095&parseInt(t,8)):this.chmod_error="Enter up to four octal digits, 0-7."}async submit_chmod(){const e=this.chmod_target;if(this.chmod_busy||!this.session_id||!e)return;const t=this.item_path(e),i=4095&this.chmod_mode;this.chmod_busy=!0,this.chmod_error="",this.show_error=!1,this.status=`Setting permissions on ${e.name}...`;try{await this.run_op("change permissions",(e=>this.channel.send_sftp_chmod(this.nodeId,this.session_id,t,i,e))),this.chmod_busy=!1,this.chmod_target=null,this.status="Connected",this.refresh_directory()}catch(e){this.chmod_busy=!1,this.chmod_error=this.error_text(e),this.status="Connected"}}async on_edit_action(e,t){if(t.preventDefault(),t.stopPropagation(),!this.session_id||"File"!==e.kind)return;const i=this.item_path(e);this.selected_item=e,this.show_editor=!0,this.editorPath=i,this.editor_name=e.name,this.editor_text="",this.editor_saved_text="",this.editor_error="",this.editor_confirm_discard=!1,this.editor_loaded=!1,this.editor_busy="loading",this.status=`Opening ${e.name}...`;try{const e=await this.run_op("open the file",(e=>this.channel.send_sftp_read_file(this.nodeId,this.session_id,i,e)),6e4);if("FileContents"!==e.result)throw new Error("The agent answered without any file contents.");const t=this.decode_text(e.contents instanceof Uint8Array?e.contents:new Uint8Array(e.contents));this.editor_text=t,this.editor_saved_text=t,this.editor_loaded=!0,this.editor_busy="",this.status="Connected"}catch(e){this.editor_busy="",this.editor_error=this.error_text(e),this.status="Connected"}}decode_text(e){if(e.includes(0))throw new Error("This looks like a binary file. Download it instead of editing it here.");try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{throw new Error("This file is not valid UTF-8. Download it instead of editing it here.")}}editor_is_dirty(){return this.editor_loaded&&this.editor_text!==this.editor_saved_text}close_editor(e=!1){"saving"!==this.editor_busy&&(e||!this.editor_is_dirty()?(this.show_editor=!1,this.editor_confirm_discard=!1,this.editor_loaded=!1,this.editorPath="",this.editor_name="",this.editor_text="",this.editor_saved_text="",this.editor_error="",this.editor_busy="",this.editorTextEl=void 0):this.editor_confirm_discard=!0)}async save_editor(){if(this.editor_busy||!this.session_id||!this.editorPath)return;const e=this.editorPath,t=this.editor_text;this.editor_busy="saving",this.editor_error="",this.show_error=!1,this.status=`Saving ${this.editor_name}...`;try{await this.run_op("save the file",(i=>this.channel.send_sftp_write_file(this.nodeId,this.session_id,e,(new TextEncoder).encode(t),i)),6e4),this.editor_saved_text=t,this.editor_busy="",this.status="Connected",this.refresh_directory()}catch(e){this.editor_busy="",this.editor_error=this.error_text(e),this.status="Connected"}}toggle_sort(e){this.sort_key!==e?(this.sort_key=e,this.sort_asc=!0):this.sort_asc=!this.sort_asc}visible_listing(){const e=this.filter.trim().toLowerCase(),t=e?this.listing.filter((t=>t.name.toLowerCase().includes(e))):[...this.listing],i=this.sort_asc?1:-1;return t.sort(((e,t)=>{if(e.kind!==t.kind)return"Folder"===e.kind?-1:1;switch(this.sort_key){case"size":return i*((e.attributes.size??0)-(t.attributes.size??0));case"modified":return i*((e.attributes.modified??0)-(t.attributes.modified??0));default:return i*e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:"base"})}}))}sort_indicator(e){return this.sort_key!==e?"":this.sort_asc?" ▲":" ▼"}on_listing_keydown(e){if(this.prompt_kind||this.chmod_target||this.show_editor||this.show_delete_modal)return;const t=this.selected_item;switch(e.key){case"Backspace":e.preventDefault(),this.go_to_parent_directory();break;case"F5":e.preventDefault(),this.refresh_directory();break;case"F2":t&&(e.preventDefault(),this.on_rename_action(t,e));break;case"Delete":t&&(e.preventDefault(),this.on_file_delete_action(t,e));break;case"Enter":t&&(e.preventDefault(),this.list_directory(t))}}on_modal_keydown(e,t){"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),t())}focus_once(e,t,i){e&&e!==t&&(i(e),requestAnimationFrame((()=>e.focus())))}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=this.item_path(e);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`;const t=["KB","MB","GB","TB","PB"];let i=e,s=-1;for(;i>=1024&&s<t.length-1;)i/=1024,s+=1;return`${i.toFixed(i>=10?1:2)} ${t[s]}`}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();if(/^[bcdlps-][rwxStTs-]{9}$/.test(i))return i;if(/^[0-7]{3,4}$/.test(i)){const e=parseInt(i,8);return this.format_permissions(e,t)}if(/^\d+$/.test(i)){const e=parseInt(i,10);return this.format_permissions(e,t)}return 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 e(a,{key:"c8a576625404b5653c066c2844160c40cff71603",class:{default:!this.max,max:this.max}},e("section",{key:"87cc1357c8cba09dc857ac0035d701ee46f72ad3",class:"listing"},!this.hideHeader&&e("header",{key:"f034a4a4d6498c8f813174566ce7ff258f6d98fb"},e("section",{key:"ce24941dbd0beffe42d5fa6bad89542d25e57ff8",class:"title"},e("img",{key:"808e0b3f448e15ceb5a7daccce98f9314eb5b758",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==",alt:"SFTP Client"}),e("div",{key:"4b4e8244a97167010abc5ba2a518f9c7fd465b39",class:"text"},e("div",{key:"dc32511596fb480ef7fb280941b9de8099b5ff05",class:"name"},this.name),e("div",{key:"fc477ea5670b74c40f4af20022dac4f02bc8b96c",class:"description"},this.description))),e("section",{key:"35beb6cd84dea257e428cca3338db239eed37cdb",class:"actions"},e("div",{key:"7adecc9ecb0a24721fcf6e82f73b58d38946801e",class:"action",onClick:()=>this.toggle_max()},e("img",{key:"e63674064553d3809a1d563bbe6fc83ad0aceb80",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K",alt:"Maximize"})))),e("main",{key:"4bef9055a683d18e391c2620ba2351282a1165ca"},this.show_navigation&&e("nav",{key:"e08ac22ec258e081195785661907d170b86bd83d",class:"navigation"},e("div",{key:"026e32148d4062a7e6be2b58192676dc0102e2dd",class:"breadcrumbs"},this.breadcrumbs.map(((t,i,s)=>e("span",{key:i,class:"breadcrumb-container"},e("span",{key:i,onClick:()=>this.list_breadcrumb(t.path),class:"breadcrumb"},t.label),i<s.length-1&&e("img",{class:"arrow",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogICAgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIKICAgIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQgdy0zIGgtMyB0ZXh0LW11dGVkLWZvcmVncm91bmQvNTAgc2hyaW5rLTAiPgogICAgPHBhdGggZD0ibTkgMTggNi02LTYtNiI+PC9wYXRoPgo8L3N2Zz4K"}))))),e("section",{key:"04f0111d530f2cb9a64bb0557b72820bd13832bf",class:"actions","aria-label":"SFTP actions"},e("input",{key:"fb28f1861a4dd9c83aaa4a20a5d25dde3e6337c7",class:"filter",type:"search",autocorrect:"off",autocapitalize:"none",autoComplete:"off",placeholder:"Filter","aria-label":"Filter this directory",value:this.filter,onInput:e=>this.filter=e.target.value}),e("button",{key:"5e173f8426eee17b08b05547e9ba033746a5a84a",type:"button",class:"action",onClick:()=>this.go_to_parent_directory(),title:"Go to parent directory","aria-label":"Go to parent directory"},e("img",{key:"64ed13f7093abc57f9b73638b902b160d11c1fd3",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtYXJyb3ctdXAgdy0zLjUgaC0zLjUiPgogICAgPHBhdGggZD0ibTUgMTIgNy03IDcgNyI+PC9wYXRoPgogICAgPHBhdGggZD0iTTEyIDE5VjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Go up"})),e("button",{key:"e6a7d97bc089f3b023d06213852aec8e5cd83d18",type:"button",class:"action",onClick:()=>this.refresh_directory(),title:"Refresh","aria-label":"Refresh"},e("img",{key:"66590858743453d7fc0fbb578e98da2a8bc762d5",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtcmVmcmVzaC1jdyB3LTMuNSBoLTMuNSI+CiAgICA8cGF0aCBkPSJNMyAxMmE5IDkgMCAwIDEgOS05IDkuNzUgOS43NSAwIDAgMSA2Ljc0IDIuNzRMMjEgOCI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDN2NWgtNSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDEyYTkgOSAwIDAgMS05IDkgOS43NSA5Ljc1IDAgMCAxLTYuNzQtMi43NEwzIDE2Ij48L3BhdGg+CiAgICA8cGF0aCBkPSJNOCAxNkgzdjUiPjwvcGF0aD4KPC9zdmc+Cg==",alt:"Refresh"})),e("button",{key:"8eca55beb0377394da8fae85546b25ee74c0f6f9",type:"button",class:"action",onClick:()=>this.open_mkdir(),title:"New folder","aria-label":"New folder"},e("svg",{key:"12d1fc50a9e325a1214462f2a06d734ab38ff1c1",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},e("path",{key:"7148c12cc461d1778ccfb3e3129786655f780dc2",d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}),e("line",{key:"a5701765411cff983baa1c4248a383c3a3a9dca6",x1:"12",x2:"12",y1:"10",y2:"16"}),e("line",{key:"9c22835c4279619e8c8cd130007d07ed19795366",x1:"9",x2:"15",y1:"13",y2:"13"}))),this.fetch_enabled()&&e(_e,{key:"259d3c2e7bdadac5d1ed77724628459e6c440e09",count:this.fetch_count,onClick:()=>{this.downloaderEl?.openFetch(this.current_dir)}}),e("button",{key:"f744681697e23f2f2892a01b625490fc66999592",type:"button",class:"action",onClick:()=>this.open_upload_picker(),title:"Upload","aria-label":"Upload"},e("img",{key:"bcb2e3f7c283f4213b0a27cb97afd3e61f8d954e",src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtdXBsb2FkIHctMy41IGgtMy41Ij4KICAgIDxwYXRoIGQ9Ik0yMSAxNXY0YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0ydi00Ij48L3BhdGg+CiAgICA8cG9seWxpbmUgcG9pbnRzPSIxNyA4IDEyIDMgNyA4Ij48L3BvbHlsaW5lPgogICAgPGxpbmUgeDE9IjEyIiB4Mj0iMTIiIHkxPSIzIiB5Mj0iMTUiPjwvbGluZT4KPC9zdmc+Cg==",alt:"Upload"})),e("button",{key:"5348bc25576e559e7b2f05ec6378fe72fc8483f5",type:"button",class:"action disconnect",onClick:()=>this.disconnect_session(),title:"Disconnect","aria-label":"Disconnect"},"DISCONNECT"))),e("input",{key:"7daf75741416f3aeb759ddc6c94106167291d641",type:"file",ref:e=>this.uploadInputEl=e,onChange:e=>this.on_upload_selected(e),style:{display:"none"}}),this.show_content&&e("div",{key:"e384c122d7454b16d13066a7cc6f7f3aa1414feb",class:"content",tabindex:0,onKeyDown:e=>this.on_listing_keydown(e)},e("table",{key:"bd1b14b317290eb59cb867a2bfbf23fb63b2fa94"},e("thead",{key:"c414438b0e8f2a776643bdaaf6441b01ed7c3be3"},e("tr",{key:"fd7d0947644aa0e0eb93d56dfacb8fe545c805f3"},e("th",{key:"8e62f0daaaad938db61b85586aeb138844877ebe",class:"sortable",onClick:()=>this.toggle_sort("name"),title:"Sort by name"},"Name",this.sort_indicator("name")),e("th",{key:"f2d3e287c8f0f97e23c173c10393d0eec4e4a752",class:"sortable",onClick:()=>this.toggle_sort("size"),title:"Sort by size"},"Size",this.sort_indicator("size")),e("th",{key:"d62906a8dd76c22cfcf2c7a82d37ffe8ac3582ba"},"Permissions"),e("th",{key:"d5ce78f188629f956704a70a8d2280a1db945666"},"Owner"),e("th",{key:"42d52536f0c5daa29af06c892c5ca3f79b888216",class:"sortable",onClick:()=>this.toggle_sort("modified"),title:"Sort by modified date"},"Modified",this.sort_indicator("modified")),e("th",{key:"4b80527286d771950be9219387fb938e92f07b63",class:"action-col","aria-label":"Actions"}))),e("tbody",{key:"1959c3f04257c8c1a2e93b4717a6eef9a7999437"},this.visible_listing().map(((t,i)=>{return e("tr",{key:i,class:{selected:this.is_selected(t),part:"File"===t.kind&&ke(t.name),fresh:"File"===t.kind&&this.fresh_names.includes(t.name)},onClick:()=>this.list_directory(t),onContextMenu:e=>{this.on_row_context_menu(t,e)}},e("td",null,e("img","Folder"===t.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"}),e("span",{class:`name ${t.kind.toLowerCase()}`},t.name)),e("td",null,"Folder"===t.kind?"-":this.format_size(t.attributes.size)),e("td",null,this.format_permissions(t.attributes.permissions,t.kind)),e("td",null,t.attributes.user??"-"),e("td",null,new Date(1e3*t.attributes.modified).toLocaleString()),e("td",{class:"action-col"},e("div",{class:"file-actions"},"File"===t.kind&&Ce.test(s=t.name)&&!ke(s)&&this.listing_can_play()&&e("button",{type:"button",class:"file-action",onClick:e=>{this.play_listing_file(t,e)},title:"Play","aria-label":`Play ${t.name}`},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},e("path",{d:"M7 5v14l12-7z"}))),"File"===t.kind&&e("button",{type:"button",class:"file-action",onClick:e=>this.on_edit_action(t,e),title:"Edit","aria-label":`Edit ${t.name}`},e("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"},e("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z"}))),"File"===t.kind&&e("button",{type:"button",class:"file-action",onClick:e=>this.on_file_row_action(t,e),title:"Download","aria-label":`Download ${t.name}`},e("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"},e("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e("polyline",{points:"7 10 12 15 17 10"}),e("line",{x1:"12",x2:"12",y1:"15",y2:"3"}))),e("button",{type:"button",class:"file-action",onClick:e=>this.on_rename_action(t,e),title:"Rename","aria-label":`Rename ${t.name}`},e("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"},e("path",{d:"M12 20h9"}),e("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"}))),e("button",{type:"button",class:"file-action",onClick:e=>this.on_chmod_action(t,e),title:"Permissions","aria-label":`Change permissions on ${t.name}`},e("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"},e("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}))),e("button",{type:"button",class:"file-action delete",onClick:e=>this.on_file_delete_action(t,e),title:"Delete","aria-label":`Delete ${t.name}`},e("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"},e("polyline",{points:"3 6 5 6 21 6"}),e("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),e("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),e("line",{x1:"14",x2:"14",y1:"11",y2:"17"}))))));var s})),0===this.visible_listing().length&&e("tr",{key:"94619eb9cf5506a57c6d085ac6b91d41b7770553",class:"empty"},e("td",{key:"87161e6091cf501364eda0d0b1072a937f8c9946",colSpan:6},this.filter?`Nothing here matches "${this.filter}".`:"This directory is empty."))))),this.show_loader&&e("div",{key:"db0f871976de1f36a72fa947441e0fb1f6051438",class:"loader"},"Loading..."),this.show_error&&e("div",{key:"8870f437cfe246be74479d98f0a0d5a2bc72f781",class:"error"},this.error_message)),this.fetch_enabled()&&e("phirepass-downloader",{key:"917af582cad03523807ef641710f85bd74bb317e",ref:e=>this.downloaderEl=e,compact:!0,channel:this.channel,connected:this.channel_ready,nodeId:this.nodeId,browsingService:this.serviceId,browsingPath:this.current_dir,streamBase:this.stream_base(),onPhirepassActiveCount:e=>this.fetch_count=e.detail.n,onPhirepassFetchCompleted:e=>this.on_fetch_completed(e.detail),onPhirepassShowInFolder:e=>this.on_show_in_folder(e.detail)}),e("footer",{key:"ff3c726b1762ca1789b1f3cd795613d9e64ec445"},e("section",{key:"47e1cbc5a79ee62355136341add2b67456d1a462",class:"status"},this.status,this.selected_item&&e("span",{key:"c828889045b7d0cca91ce0703a577f9a35a708e0",class:"selected-item"},this.selected_item.name)),e("section",{key:"9e16fe486979999adadd80483542709570a5992d",class:"version"},this.version?`Version: ${this.version}`:""))),this.show_login_screen&&e("section",{key:"4da9c7934d550538c3bd488c7ad455af30ff4e00",class:{creds:!0,blurred:this.show_login_screen}},e("form",{key:"576cc82e5cd90978039e1e644af04194485b86d6",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,this.serviceId,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()}},e("div",{key:"27098f0a63b4ceddd4e0bf0d84b3b3f321a3f512",class:"title"},"SFTP Connection"),this.show_login_screen_username&&e("div",{key:"2714b5b014572d4f58523ddb79bde232bf9b65f1"},e("label",{key:"8f0c73f148cc08fc8db445cd99fbab060807fe12",htmlFor:"username"},"Username"),e("input",{key:"c64fd60eb284e8a77d0943380cb3fcbacbc333fa",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"username",name:"username",type:"text",placeholder:""})),this.show_login_screen_password&&e("div",{key:"2d84bbacefcb3b4ba84a9b8ce74bd662fa62c8b3"},e("label",{key:"0ce1b8309229d45ab0f54d5e2de1e40b3fab57f0",htmlFor:"password"},"Password"),e("input",{key:"5752cbe6e72c332be94c0b9a813a66526ab06f3c",autocorrect:"off",autocapitalize:"none",autoComplete:"off",id:"password",name:"password",type:"password",placeholder:""})),e("div",{key:"e272596a07a758d008a90a2c2290e589feeb8b3f"},e("button",{key:"5ddb365a8b700a8d5051539bed3c9aafef20a099",type:"submit"},"Connect")))),this.show_upload_modal&&e("section",{key:"b4314fc5bb3ace26757d690ff4113954144362f6",class:{"upload-modal":!0,visible:this.show_upload_modal}},e("div",{key:"8d152c11c9c27528b667199e6cd66e7129506be6",class:"upload-dialog",role:"dialog","aria-modal":"true","aria-label":"Upload progress"},e("div",{key:"703aa9f78b0248f026ae168d95db2aaaea65a6ce",class:"title"},"Uploading File"),e("div",{key:"8e9bceaea052b871b2b6700684384515260c864c",class:"file-name",title:this.upload_file_name},this.upload_file_name),e("div",{key:"0c3f7be58a562e339dea87904297d0407bddb289",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.upload_progress},e("div",{key:"e003866966bdae3af7e9321b288dd23424491a16",class:"progress-fill",style:{width:`${this.upload_progress}%`}})),e("div",{key:"ac5e45111e0d694b09c4af709378e827288ad418",class:"progress-meta"},e("div",{key:"63e5c77d6af531e49fe9817167d945fc6e80e1be",class:"progress-speed"},this.upload_speed),e("div",{key:"369628aa1ba577c4a4a9fa13930985716830b993",class:"progress-value"},this.format_percent(this.upload_progress))),e("button",{key:"da4984bb0fc81d65a8f2876aa1aaba5dc8ea9da8",type:"button",class:{cancel:!0,finished:this.upload_finished},onClick:()=>this.cancel_upload()},this.upload_finished?"Close":"Cancel"))),this.show_download_modal&&e("section",{key:"88a14959b710af2dcced2fc37b7c404272571084",class:{"download-modal":!0,visible:this.show_download_modal}},e("div",{key:"86bbc1dd32612e7b63c4af35b366fe0a74597ed9",class:"download-dialog",role:"dialog","aria-modal":"true","aria-label":"Download progress"},e("div",{key:"8c3edb4fc04ffaecb3fbd5b6d1aeab4211d7876c",class:"title"},"Downloading File"),e("div",{key:"4815f43687f525c0b6f598e98f9df237a4253dd9",class:"file-name",title:this.download_file_name},this.download_file_name),e("div",{key:"095ac5ffbcb3f4a1bfe5742232752baffb93308e",class:"progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":this.download_progress},e("div",{key:"6a1f3d4ddbbda2c8a4069b59c7882ddcddee5b4d",class:"progress-fill",style:{width:`${this.download_progress}%`}})),e("div",{key:"db52703f7105f26aa4234eb6b623524362ced064",class:"progress-meta"},e("div",{key:"a12b2578badf08fc272f3533db2fd93fa946a4b2",class:"progress-speed"},this.download_speed),e("div",{key:"3b2b1d92c4534d6f7adf01d64a1593af504f98d0",class:"progress-value"},this.format_percent(this.download_progress))),e("button",{key:"f9a668ef58d9566ebaf66ad9219d619005294a6f",type:"button",class:{cancel:!0,finished:this.download_finished},onClick:()=>this.cancel_download()},this.download_finished?"Close":"Cancel"))),this.show_delete_modal&&e("section",{key:"cbcf699a17d748a8a7fa3daf1d96f42e47847bd6",class:{"delete-modal":!0,visible:this.show_delete_modal}},e("div",{key:"3ac99ddba7dc86a7712a4cbb1516254a62f88ef4",class:"delete-dialog",role:"dialog","aria-modal":"true","aria-label":"Delete confirmation",tabindex:-1,onKeyDown:e=>this.on_modal_keydown(e,(()=>this.cancel_delete()))},e("div",{key:"5075e7e7fda69e6941980d3bb257b30bd61d1b03",class:"title"},this.delete_is_dir?"Delete Folder":"Delete File"),e("div",{key:"a9bc63a90afc0f56caccdda8c782abf761b06fa9",class:"message"},this.delete_loading?this.delete_recursive?"Deleting the folder and everything in it...":"Deleting...":`Are you sure you want to delete this ${this.delete_is_dir?"folder":"file"}?`),e("div",{key:"50a72830064fc1352787d6ac761a13e8c6d2d5ce",class:"file-name",title:this.delete_file_name},this.delete_file_name),this.delete_is_dir&&e("label",{key:"528ba9b17f186d54e98fa5abe26d649721880eab",class:"checkline"},e("input",{key:"33dc78531ac4833e95460b93de7d211979a7973b",type:"checkbox",checked:this.delete_recursive,disabled:this.delete_loading,onChange:e=>this.delete_recursive=e.target.checked}),e("span",{key:"68517a96007ba248bbcac1fffaae2b048c4aafaf"},"Delete everything inside it too")),!this.delete_is_dir||this.delete_recursive?null:e("div",{class:"hint"},"Without this, the remote refuses a folder that is not empty."),this.delete_error&&e("div",{key:"fb0df28a4daa756166deec9dd18c0acae8874202",class:"dialog-error"},this.delete_error),this.delete_loading&&e("div",{key:"114fcfea0367efd1f2df2d06beeba2013058ff73",class:"delete-loader","aria-hidden":"true"},e("span",{key:"2b07a71d733ba7606fa45f0d24548b2b63dcc798",class:"spinner"})),e("div",{key:"44cfc262272484fdbd41257c39457d42de6e1f29",class:"modal-actions"},e("button",{key:"5035eb462279fb4e89036a34b5b5b64eee052706",type:"button",class:"btn secondary",onClick:()=>this.cancel_delete(),disabled:this.delete_loading},"Cancel"),e("button",{key:"f16d9f97ce99691c0cfbbad16679bb1dc3affbc9",type:"button",class:"btn destructive",onClick:()=>this.confirm_delete(),disabled:this.delete_loading},this.delete_loading?"Deleting...":"Delete")))),this.prompt_kind&&e("section",{key:"8ee05b491fbc60b2fa9115fa7a88b60960e3326a",class:"prompt-modal visible"},e("div",{key:"46622ceafa285047e2df9082251d7a02e38cb49f",class:"prompt-dialog",role:"dialog","aria-modal":"true","aria-label":"mkdir"===this.prompt_kind?"New folder":"Rename",tabindex:-1,onKeyDown:e=>this.on_modal_keydown(e,(()=>this.close_prompt()))},e("div",{key:"1dce2a864f58590017238fc76810297190dc223f",class:"title"},"mkdir"===this.prompt_kind?"New Folder":"Rename"),e("div",{key:"556e931df541d9ca07a58882cf658572c23276fe",class:"message"},"mkdir"===this.prompt_kind?`Create a folder in ${this.current_dir}`:"Give it a new name. Existing names are not overwritten."),e("form",{key:"b6a5807b0208576e15468912c48bcdc314cf2d41",onSubmit:e=>{e.preventDefault(),e.stopPropagation(),this.submit_prompt()}},e("input",{key:"d7ad180a2b431046905f37ee8ba21e6933f8eb09",class:"dialog-input",type:"text",autocorrect:"off",autocapitalize:"none",autoComplete:"off",spellcheck:!1,"aria-label":"Name",disabled:this.prompt_busy,value:this.prompt_value,onInput:e=>this.prompt_value=e.target.value,ref:e=>this.focus_once(e,this.promptInputEl,(e=>this.promptInputEl=e))}),this.prompt_error&&e("div",{key:"c0afc0bc34860b1c8bcfea5087d8afca425edf6a",class:"dialog-error"},this.prompt_error),e("div",{key:"91899e1d57a82434cc859e7d90636bd9f1df2545",class:"modal-actions"},e("button",{key:"24f1d359789dbd40e8d98ddf220acf2e5cdbb1e1",type:"button",class:"btn secondary",onClick:()=>this.close_prompt(),disabled:this.prompt_busy},"Cancel"),e("button",{key:"3a5ae8f5edbbe70c226d9ec01d204b0f276607cd",type:"submit",class:"btn primary",disabled:this.prompt_busy},this.prompt_busy?"Working...":"mkdir"===this.prompt_kind?"Create":"Rename"))))),this.chmod_target&&e("section",{key:"3f5daa368a81ae49fd074c33979fad6d9dc1e79f",class:"prompt-modal visible"},e("div",{key:"a2cfc7cbecbead9ccd977e74213c48ba47d5e0f7",class:"prompt-dialog",role:"dialog","aria-modal":"true","aria-label":"Change permissions",tabindex:-1,onKeyDown:e=>this.on_modal_keydown(e,(()=>this.close_chmod()))},e("div",{key:"6db7c2771db3bf9dc4c16c506c95fbadc01b24d5",class:"title"},"Permissions"),e("div",{key:"c6fba2cffb84fd01ac51171ddedc140978652756",class:"file-name",title:this.chmod_target.name},this.chmod_target.name),e("table",{key:"fc871c448ad4ad75754256f0b4d9ce9e5188ea90",class:"perm-grid"},e("thead",{key:"b2de44bba7219257af5e16687f1f9e44b64429b8"},e("tr",{key:"b4e964c7281f8088385d1707df0c638b99c0e1e7"},e("th",{key:"a0bebfa92a96c6276a8c57bbd56555c1c8cacbd2","aria-label":"Class"}),e("th",{key:"c7618c92048861c4ee94d0fb8078c6dd719d9603"},"Read"),e("th",{key:"23d0d6cbf7de82f337d4230e0286174a5fc6bd97"},"Write"),e("th",{key:"fbbe7fafe3aa03ed29db6038157167362c736f9c"},"Execute"))),e("tbody",{key:"5468214c98eb5e6278cade8d46bcae62394d0205"},[{label:"Owner",read:256,write:128,exec:64},{label:"Group",read:32,write:16,exec:8},{label:"Other",read:4,write:2,exec:1}].map((t=>e("tr",{key:t.label},e("th",{scope:"row"},t.label),[t.read,t.write,t.exec].map((i=>e("td",{key:i},e("input",{type:"checkbox","aria-label":`${t.label} ${i}`,disabled:this.chmod_busy,checked:!!(this.chmod_mode&i),onChange:()=>this.toggle_chmod_bit(i)}))))))))),e("div",{key:"61a09c4521472a61f3f7e71fe651cb42f125ed81",class:"perm-special"},[{label:"setuid",bit:2048},{label:"setgid",bit:1024},{label:"sticky",bit:512}].map((t=>e("label",{key:t.label,class:"checkline"},e("input",{type:"checkbox",disabled:this.chmod_busy,checked:!!(this.chmod_mode&t.bit),onChange:()=>this.toggle_chmod_bit(t.bit)}),e("span",null,t.label))))),e("div",{key:"49370f167cbe30ee221f6373d4261571b25be38b",class:"perm-octal"},e("label",{key:"f0b17a2ed4c59cbbaf02cd34cc847c773118faef",htmlFor:"chmod-octal"},"Octal"),e("input",{key:"020ec6003d98553c663cceb92502f6391c60691b",id:"chmod-octal",class:"dialog-input",type:"text",autocorrect:"off",autocapitalize:"none",autoComplete:"off",spellcheck:!1,maxlength:4,disabled:this.chmod_busy,value:this.chmod_mode.toString(8).padStart(4,"0"),onInput:e=>this.on_chmod_octal_input(e.target.value)}),e("span",{key:"4cc7a1cbe4ddfb565f44b5ef3fd116feb879b6c0",class:"perm-preview"},this.format_permissions(this.chmod_mode,this.chmod_target.kind))),this.chmod_error&&e("div",{key:"99cc2d982aef130ea75fa61765d17921186cc2fb",class:"dialog-error"},this.chmod_error),e("div",{key:"d5796750cfa9eb9304340bb9fd091eea7781f3cc",class:"modal-actions"},e("button",{key:"dffe3756b1b4e593ff71663e931df57d53c4a842",type:"button",class:"btn secondary",onClick:()=>this.close_chmod(),disabled:this.chmod_busy},"Cancel"),e("button",{key:"cb30401112b8f500b49e6974dc67ae9065319539",type:"button",class:"btn primary",onClick:()=>{this.submit_chmod()},disabled:this.chmod_busy},this.chmod_busy?"Applying...":"Apply")))),this.show_editor&&e("section",{key:"c9be5edfe1feea95ca51495503dc0c1c3b213d70",class:"editor-modal visible"},e("div",{key:"bf7c2aec8559b42017dc7142bc8a12f0fb4f1c39",class:"editor-dialog",role:"dialog","aria-modal":"true","aria-label":`Editing ${this.editor_name}`,tabindex:-1,onKeyDown:e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key)return e.preventDefault(),void this.save_editor();this.on_modal_keydown(e,(()=>this.close_editor()))}},e("div",{key:"fb6c305fc54a7c5f419a133c9477a69b489b77f0",class:"editor-head"},e("div",{key:"9b22c14a92be28cc42ea900b4907d4411f5e3c7d",class:"title"},this.editor_name,this.editor_is_dirty()?" *":""),e("button",{key:"2c800c08e12448ddf3c0f92f34257960ea0ea713",type:"button",class:"editor-close",onClick:()=>this.close_editor(),"aria-label":"Close editor",disabled:"saving"===this.editor_busy},"x")),"loading"===this.editor_busy?e("div",{class:"editor-loading"},"Loading..."):e("textarea",{class:"editor-text",spellcheck:!1,autocorrect:"off",autocapitalize:"none",autoComplete:"off","aria-label":"File contents",disabled:"saving"===this.editor_busy||!this.editor_loaded,value:this.editor_text,onInput:e=>this.editor_text=e.target.value,ref:e=>this.focus_once(e,this.editorTextEl,(e=>this.editorTextEl=e))}),this.editor_error&&e("div",{key:"7918d367cbe8c9a3c179a20f8083b9c4e067ad79",class:"dialog-error"},this.editor_error),this.editor_confirm_discard&&e("div",{key:"6b2ba93692a575bd2c6253dcd7c9abb65807a900",class:"dialog-error"},"Unsaved changes. Close anyway?"),e("div",{key:"879a150fdb6501ad95847a09f984f5acd9301830",class:"modal-actions"},this.editor_confirm_discard?e("button",{type:"button",class:"btn destructive",onClick:()=>this.close_editor(!0)},"Discard"):e("button",{type:"button",class:"btn secondary",onClick:()=>this.close_editor(),disabled:"saving"===this.editor_busy},"Close"),e("button",{key:"e034f852259bcf75f6ba28159706862cfefbe5fa",type:"button",class:"btn primary",onClick:()=>{this.save_editor()},disabled:!!this.editor_busy||!this.editor_is_dirty()},"saving"===this.editor_busy?"Saving...":"Save")))),this.part_delete&&e(De,{key:"e7789b9ddf6e9d7f9e479aa390e7391e61c208f7",name:this.part_delete.name,busy:this.part_delete.busy,onCancel:()=>this.part_delete=null,onConfirm:()=>{const e=this.part_delete;this.part_delete={...e,busy:!0},this.downloaderEl?.deleteDownload(e.download_id).finally((()=>{this.part_delete=null,this.refresh_directory()}))}}),this.torrent_menu&&e(Se,{key:"094cd2ab17cf975825db6afefcf205855221a03b",menu:this.torrent_menu,onClose:()=>this.torrent_menu=null,onFetch:()=>{const e=this.torrent_menu.path;this.torrent_menu=null,this.downloaderEl?.startTorrentPath(e)},onDownload:()=>{const e=this.selected_item;this.torrent_menu=null,e&&this.start_download(e)},onRename:()=>{const e=this.selected_item;this.torrent_menu=null,e&&this.on_rename_action(e,new window.Event("click"))},onDelete:()=>{const e=this.selected_item;this.torrent_menu=null,e&&this.on_file_delete_action(e,new window.Event("click"))}}),this.listing_player&&e("section",{key:"f5b06ff083b4af19a7c4cc336d8be172c0e646e1",class:"player-modal visible"},e("phirepass-media-player",{key:"b2770268f3fb6af053a6a52da1e346d8ae3cdda9",src:this.listing_player.src,name:this.listing_player.name,status:"On the node",positionKey:this.listing_player.key,onPhirepassPlayerClose:()=>this.listing_player=null})))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};ze.style=":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}.filter{height:1.5rem;width:110px;padding:0 6px;font:inherit;font-size:0.68rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&::placeholder{color:hsl(var(--muted-foreground))}&:focus{border-color:hsl(var(--primary))}}.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;outline:none;overflow:auto;font-size:0.75rem;line-height:1rem;scrollbar-width:thin;scrollbar-color:hsl(var(--scroll-thumb)) hsl(var(--scroll-track));&:focus-visible{box-shadow:inset 0 0 0 1px hsl(var(--primary) / 0.5)}&::-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.sortable{cursor:pointer;user-select:none;&:hover{color:hsl(var(--primary))}}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.empty{cursor:default;td{color:hsl(var(--muted-foreground));text-align:center;padding:18px 8px}&:hover{background:transparent}}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,.prompt-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,.prompt-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)}}}.dialog-input{width:100%;box-sizing:border-box;height:2rem;padding:0 8px;font:inherit;font-size:0.75rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary))}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.hint{margin-top:4px;font-size:0.66rem;line-height:0.9rem;color:hsl(var(--muted-foreground))}.checkline{margin-top:8px;display:flex;align-items:center;gap:6px;font-size:0.72rem;color:rgb(189, 219, 209);cursor:pointer;input{accent-color:hsl(var(--primary));margin:0}}.perm-grid{margin-top:10px;width:100%;border-collapse:collapse;font-size:0.68rem;th{color:hsl(var(--muted-foreground));font-weight:normal;text-align:center;padding:2px 0}th[scope='row']{text-align:left;color:rgb(189, 219, 209)}td{text-align:center;padding:2px 0}input{accent-color:hsl(var(--primary));margin:0}}.perm-special{margin-top:4px;display:flex;gap:12px;.checkline{margin-top:4px;font-size:0.66rem}}.perm-octal{margin-top:10px;display:flex;align-items:center;gap:8px;label{font-size:0.68rem;color:hsl(var(--muted-foreground))}.dialog-input{width:4.5rem;text-align:center;letter-spacing:0.1em}.perm-preview{font-size:0.7rem;color:hsl(var(--primary))}}.modal-actions .btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 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}}}}.editor-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:7;&.visible{display:flex}.editor-dialog{width:min(860px, calc(100% - 24px));height:min(620px, calc(100% - 24px));display:flex;flex-direction:column;background-color:rgba(21, 24, 30, 0.98);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;outline:none;.editor-head{display:flex;align-items:center;justify-content:space-between;gap:8px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.editor-close{border:none;background:transparent;color:hsl(var(--muted-foreground));font-size:0.85rem;line-height:1;padding:2px 6px;border-radius:4px;cursor:pointer;&:hover:not(:disabled){color:hsl(var(--primary));background-color:hsl(var(--border) / 0.6)}&:disabled{opacity:0.5;cursor:not-allowed}}}.editor-loading{flex:1;display:flex;align-items:center;justify-content:center;font-size:0.75rem;color:hsl(var(--muted-foreground))}.editor-text{flex:1;min-height:0;width:100%;box-sizing:border-box;resize:none;padding:10px;font:inherit;font-size:0.75rem;line-height:1.15rem;tab-size:4;white-space:pre;overflow:auto;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary) / 0.6)}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.modal-actions{margin-top:14px;display:flex;justify-content:flex-end;gap:8px;.btn{height:2rem;min-width:6rem;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:not(:disabled){border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white}.btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}}}}}@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}}@container (max-width: 635px){:host .listing main .content table tbody tr td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;width:36px;height:36px;border-radius:8px}:host .listing main .content table tbody tr td.action-col .file-action svg{width:17px;height:17px}:host .listing main .content table thead th.action-col,:host .listing main .content table tbody td.action-col{width:92px;min-width:92px}:host .listing main .content table tbody td.action-col .file-actions{gap:4px}:host .listing main .content table tbody tr:hover{background-color:transparent}:host .listing main .content table tbody tr.selected:hover{background-color:hsl(var(--primary) / 0.3)}:host .listing main .content table tbody td{padding:13px 10px 12px}:host .listing main .content table thead th{padding:12px 10px}:host .listing main .navigation{height:auto;min-height:44px;padding:6px 8px}:host .listing main .navigation .action{padding:10px;border-radius:8px}:host .listing main .navigation .action img{height:17px;width:17px}:host .listing main .navigation .action.disconnect{padding:10px 12px}:host .listing main .navigation .filter{height:2.25rem;font-size:16px;width:8rem}:host .listing header .actions .action{padding:8px}:host .listing header .actions .action img{height:17px}:host .modal .upload-dialog .cancel,:host .modal .download-dialog .cancel,:host .modal .delete-dialog .cancel,:host .modal .prompt-dialog .cancel,:host .modal .upload-dialog .modal-actions .btn,:host .modal .download-dialog .modal-actions .btn,:host .modal .delete-dialog .modal-actions .btn,:host .modal .prompt-dialog .modal-actions .btn{height:2.75rem}:host .modal .prompt-dialog .dialog-input,:host .auth input{height:2.5rem;font-size:16px}:host .modal .prompt-dialog .perm-grid input,:host .modal .prompt-dialog .perm-special input{width:20px;height:20px}:host .modal .prompt-dialog .perm-grid td,:host .modal .prompt-dialog .perm-grid th{padding:7px 0}}:host .listing main .navigation .action.fetch{position:relative;display:inline-grid;place-items:center;color:hsl(var(--primary))}:host .listing main .navigation .action.fetch .badge{position:absolute;top:-5px;right:-6px;min-width:15px;height:15px;padding:0 4px;border-radius:8px;background:hsl(var(--primary));color:hsl(var(--primary-foreground));font-size:9px;font-weight:700;line-height:15px;text-align:center}:host .listing main .content table tbody tr.part td{color:hsl(var(--muted-foreground));font-style:italic}:host .listing main .content table tbody tr.fresh{background-color:hsl(var(--primary) / 0.1)}:host .listing main .content table tbody tr.fresh .name::after{content:'new';margin-left:8px;font-size:10px;padding:1px 6px;border-radius:3px;background:hsl(var(--primary));color:hsl(var(--primary-foreground));font-weight:600;font-style:normal}:host .delete-dialog .file-name.inline{display:inline;padding:0;border:0;background:none}:host .context-backdrop{position:absolute;inset:0;z-index:8}:host .context-menu{position:absolute;min-width:220px;max-width:calc(100% - 16px);padding:4px;background:hsl(var(--card));border:1px solid hsl(var(--border));border-radius:6px;box-shadow:0 12px 30px -10px rgba(0, 0, 0, 0.7);display:flex;flex-direction:column;font-size:12px;button{display:flex;align-items:center;gap:8px;text-align:left;padding:6px 10px;border:0;border-radius:4px;background:transparent;color:rgb(189, 219, 209);font:inherit;cursor:pointer;&:hover,&:focus-visible{background:hsl(var(--muted));outline:none}&.primary{color:hsl(var(--primary))}&.danger{color:hsl(var(--destructive))}}hr{border:0;border-top:1px solid hsl(var(--border));margin:4px 0}}:host .player-modal{position:absolute;inset:0;z-index:7;display:grid;place-items:center;padding:10px;background:rgba(5, 7, 9, 0.6);phirepass-media-player{width:min(100%, 880px)}}";export{ge as phirepass_downloader,we as phirepass_media_player,ze as phirepass_sftp_client}
@@ -1 +1 @@
1
- import{p as e,b as r}from"./p-B9qUl6FW.js";export{s as setNonce}from"./p-B9qUl6FW.js";import{g as o}from"./p-DQuL1Twl.js";(()=>{const r=import.meta.url,o={};return""!==r&&(o.resourcesUrl=new URL(".",r).href),e(o)})().then((async e=>(await o(),r([["p-1b84c526",[[769,"phirepass-rdp",{serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],channelFactory:[16],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]]],["p-41dd1ac9",[[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],keyBar:[1,"key-bar"],serverId:[1,"server-id"],channelFactory:[16],ctrlArmed:[32],altArmed:[32]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]]],["p-614ab3de",[[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"],serviceId:[1,"service-id"],token:[1],serverId:[1,"server-id"],channelFactory:[16],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],delete_is_dir:[32],delete_recursive:[32],delete_error:[32],prompt_kind:[32],prompt_value:[32],prompt_error:[32],prompt_busy:[32],chmod_target:[32],chmod_mode:[32],chmod_error:[32],chmod_busy:[32],show_editor:[32],editor_name:[32],editor_text:[32],editor_saved_text:[32],editor_busy:[32],editor_error:[32],editor_confirm_discard:[32],editor_loaded:[32],filter:[32],sort_key:[32],sort_asc:[32],channel_ready:[32],fetch_count:[32],fresh_names:[32],part_delete:[32],torrent_menu:[32],listing_player:[32],maximize:[64],minimize:[64]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}],[513,"phirepass-downloader",{nodeId:[1,"node-id"],nodeLabel:[1,"node-label"],token:[1],channel:[16],connected:[4],channelFactory:[16],browsingService:[1,"browsing-service"],browsingPath:[1025,"browsing-path"],compact:[516],streamBase:[1,"stream-base"],canConfigure:[4,"can-configure"],inlinePlayer:[4,"inline-player"],serverHost:[1,"server-host"],serverPort:[2,"server-port"],serverId:[1,"server-id"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],connection:[32],caps:[32],jobs:[32],tab:[32],drawerOpen:[32],dialogOpen:[32],unread:[32],form:[32],where:[32],starting:[32],refusal:[32],confirm:[32],notices:[32],subDir:[32],picker:[32],player:[32],receive:[64],openFetch:[64],toggleDrawer:[64],jobForPath:[64],deleteDownload:[64],torrentPathFor:[64],startTorrentPath:[64]},null,{channel:[{onChannel:0}],connected:[{onConnected:0}],browsingPath:[{onBrowsing:0}],browsingService:[{onBrowsing:0}],nodeId:[{onNode:0}]}],[513,"phirepass-media-player",{src:[1],name:[1],mime:[1],status:[1],ready:[2],positionStore:[16],positionKey:[1,"position-key"],remotePlayback:[16],castDevice:[1,"cast-device"],phase:[32],stored:[32],castAvailable:[32],currentTime:[32],duration:[32],close:[64]},null,{src:[{onSrc:0}]}]]]],e))));
1
+ import{p as e,b as r}from"./p-Dd9o0CbU.js";export{s as setNonce}from"./p-Dd9o0CbU.js";import{g as o}from"./p-DQuL1Twl.js";(()=>{const r=import.meta.url,o={};return""!==r&&(o.resourcesUrl=new URL(".",r).href),e(o)})().then((async e=>(await o(),r([["p-2fd32ec5",[[769,"phirepass-rdp",{serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],channelFactory:[16],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]]],["p-705501d4",[[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],keyBar:[1,"key-bar"],serverId:[1,"server-id"],channelFactory:[16],ctrlArmed:[32],altArmed:[32]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]]],["p-b8caf9e1",[[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"],serviceId:[1,"service-id"],token:[1],serverId:[1,"server-id"],channelFactory:[16],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],delete_is_dir:[32],delete_recursive:[32],delete_error:[32],prompt_kind:[32],prompt_value:[32],prompt_error:[32],prompt_busy:[32],chmod_target:[32],chmod_mode:[32],chmod_error:[32],chmod_busy:[32],show_editor:[32],editor_name:[32],editor_text:[32],editor_saved_text:[32],editor_busy:[32],editor_error:[32],editor_confirm_discard:[32],editor_loaded:[32],filter:[32],sort_key:[32],sort_asc:[32],channel_ready:[32],fetch_count:[32],fresh_names:[32],part_delete:[32],torrent_menu:[32],listing_player:[32],maximize:[64],minimize:[64]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}],[513,"phirepass-downloader",{nodeId:[1,"node-id"],nodeLabel:[1,"node-label"],token:[1],channel:[16],connected:[4],channelFactory:[16],browsingService:[1,"browsing-service"],browsingPath:[1025,"browsing-path"],compact:[516],streamBase:[1,"stream-base"],canConfigure:[4,"can-configure"],inlinePlayer:[4,"inline-player"],serverHost:[1,"server-host"],serverPort:[2,"server-port"],serverId:[1,"server-id"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],connection:[32],caps:[32],jobs:[32],tab:[32],drawerOpen:[32],dialogOpen:[32],unread:[32],form:[32],where:[32],starting:[32],refusal:[32],confirm:[32],notices:[32],subDir:[32],picker:[32],player:[32],receive:[64],openFetch:[64],toggleDrawer:[64],jobForPath:[64],deleteDownload:[64],torrentPathFor:[64],startTorrentPath:[64]},null,{channel:[{onChannel:0}],connected:[{onConnected:0}],browsingPath:[{onBrowsing:0}],browsingService:[{onBrowsing:0}],nodeId:[{onNode:0}]}],[513,"phirepass-media-player",{src:[1],name:[1],mime:[1],status:[1],ready:[2],positionStore:[16],positionKey:[1,"position-key"],remotePlayback:[16],linkMinter:[16],castDevice:[1,"cast-device"],phase:[32],stored:[32],castAvailable:[32],castSrc:[32],linkNote:[32],currentTime:[32],duration:[32],close:[64]},null,{src:[{onSrc:0}]}]]]],e))));
@@ -6,6 +6,10 @@
6
6
  * enums by name, data-carrying enums externally tagged (`{ Http: { … } }`).
7
7
  * Unit enums that may grow end in `Unknown`, as on the Rust side, so a newer
8
8
  * server never breaks an older widget.
9
+ *
10
+ * A Rust `None` reaches JS as `undefined` (the field is absent), not `null`,
11
+ * even where a type below says `| null`. Read optional fields with `??` or a
12
+ * truthiness check, never `=== null`. Checked against the real channel build.
9
13
  */
10
14
  /**
11
15
  * `msg_id`s `<phirepass-downloader>` mints start here, so a host sharing its
@@ -109,6 +113,8 @@ export type FetchJob = {
109
113
  attempt: number;
110
114
  next_attempt_at: number | null;
111
115
  restarted_from_zero: boolean;
116
+ /** Set by the server: a Delete was asked and the node has not answered yet. */
117
+ deleting?: boolean;
112
118
  };
113
119
  export type FetchCaps = {
114
120
  http: boolean;
@@ -1,10 +1,11 @@
1
1
  import type { FetchCaps, FetchFile, FetchJob, FetchState } from '../../common/fetch';
2
2
  /**
3
3
  * A row as the widget holds it: the node's latest `FetchJob`, plus what the
4
- * widget itself is waiting on (a Delete sent but not yet confirmed).
4
+ * widget itself is waiting on. `deleting` is set when this widget sent a
5
+ * Delete, or when the server says one is pending (a Delete sent from
6
+ * elsewhere, or while the node was offline).
5
7
  */
6
8
  export type Row = FetchJob & {
7
- deleting?: boolean;
8
9
  /** Accepted by the server, but the node has not reported it yet (it may be offline). */
9
10
  waitingForNode?: boolean;
10
11
  };
@@ -24,6 +25,13 @@ export declare function applyProgress(prev: JobMap, job: FetchJob): {
24
25
  first: boolean;
25
26
  };
26
27
  export type Tab = 'active' | 'finished' | 'retrying';
28
+ /**
29
+ * A finished torrent whose seeding was stopped. Its files are whole and
30
+ * Resume seeds again, so it stays with the finished rows. The agent keeps
31
+ * `seeding_since` through a Stop, which is what tells it apart from a
32
+ * download stopped half-way.
33
+ */
34
+ export declare function isPausedSeeding(row: Row): boolean;
27
35
  export declare function tabOf(row: Row): Tab;
28
36
  /**
29
37
  * Jobs working towards their bytes: what the badge and “N active” count.
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from '../../stencil-public-runtime';
2
- import { PositionStore, RemotePlaybackLike, StoredPosition } from './player';
2
+ import { LinkMinter, PositionStore, RemotePlaybackLike, StoredPosition } from './player';
3
3
  /**
4
4
  * What the player is showing. `buffering` is before the first frame;
5
5
  * `waiting` is a stall after it (a seek past what the node has, G2).
@@ -39,12 +39,17 @@ export declare class PhirepassMediaPlayer {
39
39
  positionKey?: string;
40
40
  /** Stands in for `video.remote`, for demos and tests (like `channelFactory`). */
41
41
  remotePlayback?: RemotePlaybackLike;
42
+ /** Makes the link a TV or VLC opens (T2.9). Defaults to POSTing `src`. */
43
+ linkMinter?: LinkMinter;
42
44
  /** Shown while casting, when the host knows the device's name. */
43
45
  castDevice?: string;
44
46
  playerClose: EventEmitter<void>;
45
47
  phase: PlayerPhase;
46
48
  stored: StoredPosition | null;
47
49
  castAvailable: boolean;
50
+ /** The ticket URL the element plays from once casting was asked for. */
51
+ castSrc: string | null;
52
+ linkNote: string | null;
48
53
  currentTime: number;
49
54
  duration: number;
50
55
  private get store();
@@ -55,6 +60,16 @@ export declare class PhirepassMediaPlayer {
55
60
  onSrc(): void;
56
61
  /** Closes the player, saving where it stopped. The download is not affected. */
57
62
  close(): Promise<void>;
63
+ private get minter();
64
+ /**
65
+ * The TV fetches the file itself and has no cookie, so the element first
66
+ * moves to a ticket URL (same bytes, same position), then the device picker
67
+ * opens. A ticket that cannot be had still opens the picker: on a
68
+ * development stack the plain URL plays.
69
+ */
70
+ private cast;
71
+ /** “Copy link for VLC”: the same ticket, on the clipboard. */
72
+ private copyLink;
58
73
  private remote;
59
74
  private watchRemote;
60
75
  private savePosition;
@@ -23,6 +23,16 @@ export declare function isPlayableName(name: string): boolean;
23
23
  * (H.264/AAC), WebM and common audio, mostly not MKV or MOV.
24
24
  */
25
25
  export declare function castBlocker(name: string, mime?: string): string | null;
26
+ /**
27
+ * Turns a stream URL into one a TV or VLC can open without the dashboard's
28
+ * cookie: a stream ticket (T2.9) that lasts the organisation's “Cast and player
29
+ * links last”. `null` when the server would not make one.
30
+ */
31
+ export type LinkMinter = (src: string) => Promise<string | null>;
32
+ /** `src` with its ticket, absolute, since it leaves this page. */
33
+ export declare function ticketUrl(src: string, ticket: string, base?: string): string;
34
+ /** POSTs the stream URL with the session cookie; the server answers `{ ticket }`. */
35
+ export declare function fetchLinkMinter(fetcher?: typeof fetch): LinkMinter;
26
36
  /** Nothing is saved in the first 30 seconds. */
27
37
  export declare const SAVE_AFTER_SECS = 30;
28
38
  export declare const SAVE_EVERY_MS = 10000;
@@ -7,10 +7,10 @@
7
7
  import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
8
  import { ChannelFactory, DownloadChannelFactory, DownloadChannelLike } from "./common/channel";
9
9
  import { ConnectionState, ProtocolMessage } from "./common/protocol";
10
- import { PositionStore, RemotePlaybackLike } from "./components/phirepass-media-player/player";
10
+ import { LinkMinter, PositionStore, RemotePlaybackLike } from "./components/phirepass-media-player/player";
11
11
  export { ChannelFactory, DownloadChannelFactory, DownloadChannelLike } from "./common/channel";
12
12
  export { ConnectionState, ProtocolMessage } from "./common/protocol";
13
- export { PositionStore, RemotePlaybackLike } from "./components/phirepass-media-player/player";
13
+ export { LinkMinter, PositionStore, RemotePlaybackLike } from "./components/phirepass-media-player/player";
14
14
  export namespace Components {
15
15
  /**
16
16
  * Remote Fetch: paste a link or a magnet, or drop a `.torrent`, and the node
@@ -136,6 +136,10 @@ export namespace Components {
136
136
  * Closes the player, saving where it stopped. The download is not affected.
137
137
  */
138
138
  "close": () => Promise<void>;
139
+ /**
140
+ * Makes the link a TV or VLC opens (T2.9). Defaults to POSTing `src`.
141
+ */
142
+ "linkMinter"?: LinkMinter;
139
143
  /**
140
144
  * Overrides the mime the extension implies.
141
145
  */
@@ -575,6 +579,10 @@ declare namespace LocalJSX {
575
579
  * Shown while casting, when the host knows the device's name.
576
580
  */
577
581
  "castDevice"?: string;
582
+ /**
583
+ * Makes the link a TV or VLC opens (T2.9). Defaults to POSTing `src`.
584
+ */
585
+ "linkMinter"?: LinkMinter;
578
586
  /**
579
587
  * Overrides the mime the extension implies.
580
588
  */