import{r as e,j as t}from"./vendor-react-AXa6hZO5.js";import{l as s,L as r,a8 as o,B as a}from"./cec18ad9a-DiLjrOUd.js";import{eu as n,cn as i,gR as l}from"./index-C_tZnXTW.js";import{bi as c,p as d,aK as p}from"./vendor-icons-Dy3Nea9p.js";import{u as m,M as u}from"./vendor-intl-BdADXLLt.js";
/*!-----------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
 * Released under the MIT license
 * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
 *-----------------------------------------------------------------------------*/var g={wordPattern:/(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,comments:{lineComment:"//",blockComment:["{","}"]},brackets:[["{","}"],["[","]"],["(",")"],["<",">"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:"<",close:">"},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:"<",close:">"},{open:"'",close:"'"}],folding:{markers:{start:new RegExp("^\\s*\\{\\$REGION(\\s\\'.*\\')?\\}"),end:new RegExp("^\\s*\\{\\$ENDREGION\\}")}}};const f=Object.freeze(Object.defineProperty({__proto__:null,conf:g,language:{defaultToken:"",tokenPostfix:".pascal",ignoreCase:!0,brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"},{open:"<",close:">",token:"delimiter.angle"}],keywords:["absolute","abstract","all","and_then","array","as","asm","attribute","begin","bindable","case","class","const","contains","default","div","else","end","except","exports","external","far","file","finalization","finally","forward","generic","goto","if","implements","import","in","index","inherited","initialization","interrupt","is","label","library","mod","module","name","near","not","object","of","on","only","operator","or_else","otherwise","override","package","packed","pow","private","program","protected","public","published","interface","implementation","qualified","read","record","resident","requires","resourcestring","restricted","segment","set","shl","shr","specialize","stored","strict","then","threadvar","to","try","type","unit","uses","var","view","virtual","dynamic","overload","reintroduce","with","write","xor","true","false","procedure","function","constructor","destructor","property","break","continue","exit","abort","while","do","for","raise","repeat","until"],typeKeywords:["boolean","double","byte","integer","shortint","char","longint","float","string"],operators:["=",">","<","<=",">=","<>",":",":=","and","or","+","-","*","/","@","&","^","%"],symbols:/[=><:@\^&|+\-*\/\^%]+/,tokenizer:{root:[[/[a-zA-Z_][\w]*/,{cases:{"@keywords":{token:"keyword.$0"},"@default":"identifier"}}],{include:"@whitespace"},[/[{}()\[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":"delimiter","@default":""}}],[/\d*\.\d+([eE][\-+]?\d+)?/,"number.float"],[/\$[0-9a-fA-F]{1,16}/,"number.hex"],[/\d+/,"number"],[/[;,.]/,"delimiter"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/'/,"string","@string"],[/'[^\\']'/,"string"],[/'/,"string.invalid"],[/\#\d+/,"string"]],comment:[[/[^\*\}]+/,"comment"],[/\}/,"comment","@pop"],[/[\{]/,"comment"]],string:[[/[^\\']+/,"string"],[/\\./,"string.escape.invalid"],[/'/,{token:"string.quote",bracket:"@close",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,"white"],[/\{/,"comment","@comment"],[/\/\/.*$/,"comment"]]}}},Symbol.toStringTag,{value:"Module"}));
/*!-----------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
 * Released under the MIT license
 * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
 *-----------------------------------------------------------------------------*/const x=Object.freeze(Object.defineProperty({__proto__:null,conf:{comments:{lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'}]},language:{defaultToken:"",tokenPostfix:".r",roxygen:["@alias","@aliases","@assignee","@author","@backref","@callGraph","@callGraphDepth","@callGraphPrimitives","@concept","@describeIn","@description","@details","@docType","@encoding","@evalNamespace","@evalRd","@example","@examples","@export","@exportClass","@exportMethod","@exportPattern","@family","@field","@formals","@format","@import","@importClassesFrom","@importFrom","@importMethodsFrom","@include","@inherit","@inheritDotParams","@inheritParams","@inheritSection","@keywords","@md","@method","@name","@noMd","@noRd","@note","@param","@rawNamespace","@rawRd","@rdname","@references","@return","@S3method","@section","@seealso","@setClass","@slot","@source","@template","@templateVar","@title","@TODO","@usage","@useDynLib"],constants:["NULL","FALSE","TRUE","NA","Inf","NaN","NA_integer_","NA_real_","NA_complex_","NA_character_","T","F","LETTERS","letters","month.abb","month.name","pi","R.version.string"],keywords:["break","next","return","if","else","for","in","repeat","while","array","category","character","complex","double","function","integer","list","logical","matrix","numeric","vector","data.frame","factor","library","require","attach","detach","source"],special:["\\n","\\r","\\t","\\b","\\a","\\f","\\v","\\'",'\\"',"\\\\"],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.bracket"},{open:"(",close:")",token:"delimiter.parenthesis"}],tokenizer:{root:[{include:"@numbers"},{include:"@strings"},[/[{}\[\]()]/,"@brackets"],{include:"@operators"},[/#'$/,"comment.doc"],[/#'/,"comment.doc","@roxygen"],[/(^#.*$)/,"comment"],[/\s+/,"white"],[/[,:;]/,"delimiter"],[/@[a-zA-Z]\w*/,"tag"],[/[a-zA-Z]\w*/,{cases:{"@keywords":"keyword","@constants":"constant","@default":"identifier"}}]],roxygen:[[/@\w+/,{cases:{"@roxygen":"tag","@eos":{token:"comment.doc",next:"@pop"},"@default":"comment.doc"}}],[/\s+/,{cases:{"@eos":{token:"comment.doc",next:"@pop"},"@default":"comment.doc"}}],[/.*/,{token:"comment.doc",next:"@pop"}]],numbers:[[/0[xX][0-9a-fA-F]+/,"number.hex"],[/-?(\d*\.)?\d+([eE][+\-]?\d+)?/,"number"]],operators:[[/<{1,2}-/,"operator"],[/->{1,2}/,"operator"],[/%[^%\s]+%/,"operator"],[/\*\*/,"operator"],[/%%/,"operator"],[/&&/,"operator"],[/\|\|/,"operator"],[/<</,"operator"],[/>>/,"operator"],[/[-+=&|!<>^~*/:$]/,"operator"]],strings:[[/'/,"string.escape","@stringBody"],[/"/,"string.escape","@dblStringBody"]],stringBody:[[/\\./,{cases:{"@special":"string","@default":"error-token"}}],[/'/,"string.escape","@popall"],[/./,"string"]],dblStringBody:[[/\\./,{cases:{"@special":"string","@default":"error-token"}}],[/"/,"string.escape","@popall"],[/./,"string"]]}}},Symbol.toStringTag,{value:"Module"}));const b=Object.freeze(Object.defineProperty({__proto__:null,FolderBrowserModal:function({isOpen:g,onClose:f,onSelect:x,sshConfig:b,initialPath:h}){const y=m(),[k,j]=e.useState(h||"~"),[v,w]=e.useState([]),[S,N]=e.useState(!1),[C,_]=e.useState(null),[M,z]=e.useState(""),O=e.useCallback(async e=>{if(n?.listSSHDirectory){N(!0),_(null);try{const t=await n.listSSHDirectory(b,e);t.error?(_(t.error),w([])):(w(t.entries.filter(e=>e.isDirectory)),j(e),z(e))}catch(t){s.error(r.LOCAL_SESSION,"FolderBrowserModal: listSSHDirectory threw",t),_(y.formatMessage({defaultMessage:"Failed to connect to SSH server. Check your connection and try again.",id:"uE+N+pZ+Ca"})),w([])}finally{N(!1)}}else _(y.formatMessage({defaultMessage:"SSH browsing requires the desktop app.",id:"KztcpqBs9Q"}))},[b,y]);e.useEffect(()=>{g&&O(h||"~")},[g,h,O]);const P=e.useCallback(e=>{O(e)},[O]),E=e.useCallback(()=>{if("/"===k||"~"===k)return;const e=k.split("/").slice(0,-1).join("/")||"/";O(e)},[k,O]),F=e.useCallback(()=>{O("~")},[O]),A=e.useCallback(()=>{M.trim()&&O(M.trim())},[M,O]),B=e.useCallback(()=>{x(k),f()},[k,x,f]),R=e.useMemo(()=>"~"===k?["~"]:k.startsWith("~")?["~",...k.slice(2).split("/").filter(Boolean)]:k.split("/").filter(Boolean),[k]);return t.jsx(o,{isOpen:g,onClose:f,modalSize:"lg",hasCloseButton:!0,title:y.formatMessage({defaultMessage:"Select Remote Folder",id:"1+B6FLaGe2"}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(i,{type:"text",value:M,onChange:e=>z(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"/path/to/folder",className:"flex-1",disabled:S}),t.jsx(a,{variant:"secondary",onClick:A,disabled:S||!M.trim(),children:t.jsx(u,{defaultMessage:"Go",id:"nSwpYgWqUX"})})]}),t.jsxs("div",{className:"flex items-center gap-1 text-sm text-text-300 overflow-x-auto",children:[t.jsx("button",{type:"button",onClick:F,className:"p-1 hover:bg-bg-200 rounded",disabled:S,"aria-label":y.formatMessage({defaultMessage:"Go to home directory",id:"g1Dy492V3e"}),children:t.jsx(c,{size:16})}),R.map((e,s)=>t.jsxs("div",{className:"flex items-center",children:[s>0&&t.jsx(d,{size:12,className:"mx-1"}),t.jsx("button",{type:"button",onClick:()=>{if("~"===e)P("~");else{const e=R.slice(0,s+1).join("/"),t=k.startsWith("/")?`/${e}`:e;P(t)}},className:"px-1 py-0.5 hover:bg-bg-200 rounded truncate max-w-32",disabled:S,children:e})]},s))]}),t.jsx("div",{className:"border border-border-300 rounded-lg h-64 overflow-y-auto",children:S?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(p,{size:24,className:"animate-spin"})}):C?t.jsx("div",{className:"flex items-center justify-center h-full text-danger-100 text-sm p-4 text-center",children:C}):0===v.length?t.jsx("div",{className:"flex items-center justify-center h-full text-text-400 text-sm",children:t.jsx(u,{defaultMessage:"No subdirectories",id:"tVqP+rhco5"})}):t.jsxs("div",{className:"p-1",children:["/"!==k&&"~"!==k&&t.jsxs("button",{type:"button",onClick:E,className:"w-full flex items-center gap-2 px-2 py-1.5 text-sm text-text-300 hover:bg-bg-200 rounded",children:[t.jsx(l,{size:16}),t.jsx("span",{children:".."})]}),v.map(e=>t.jsxs("button",{type:"button",onClick:()=>P(e.path),className:"w-full flex items-center gap-2 px-2 py-1.5 text-sm text-text-200 hover:bg-bg-200 rounded",children:[t.jsx(l,{size:16,className:"text-text-400"}),t.jsx("span",{className:"truncate",children:e.name})]},e.path))]})}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(a,{variant:"secondary",onClick:f,children:t.jsx(u,{defaultMessage:"Cancel",id:"47FYwba+bI"})}),t.jsx(a,{variant:"primary",onClick:B,disabled:S,children:t.jsx(u,{defaultMessage:"Select Folder",id:"JUdxvKt2OO"})})]})]})})}},Symbol.toStringTag,{value:"Module"}));export{b as S,f as p,x as r};
