import{j as e}from"./jsx-runtime-hUI6LOBV.js";import{r as g}from"./index-CFdT0RIo.js";import{L as P,f as N}from"./chunk-EVOBXE3Y-Bmgys8-c.js";import{s as _}from"./progress-bar-8MSIg-hJ.js";import{c as x}from"./misc-BNcbB3dR.js";import{u as O}from"./pe-BRA_K7Pt.js";import{a as I,b as v}from"./root-loader-ByAKsmmv.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"66e9b849450b819e11683314a547a341cb57f7d0"};var t=new n.Error().stack;t&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[t]="7c3fa845-2e32-411c-9b01-6078ca9a42b4",n._sentryDebugIdIdentifier="sentry-dbid-7c3fa845-2e32-411c-9b01-6078ca9a42b4")}catch{}})();function j(n){const t=N();return g.useEffect(()=>{t.state==="idle"&&t.data!=null&&n?.("fetcher-done")},[t,n]),t}function D({className:n,file:t,appFile:r,appName:c,syncTo:a,line:l,column:d,children:u,onUpdate:o}){const i=j(o),b=O(),m=s=>{if(!a||!s.altKey||!s.metaKey)return;s.preventDefault();const h=s.currentTarget.form;if(!h)return;const y=new FormData(h);y.set("skipOpenAfterSync","true"),i.submit(y,{method:"POST",action:"/launch-editor"})};if(!t&&!r)return console.error('LaunchEditor: requires either "file" or "appFile" prop.'),null;const f=typeof r=="string"?[r]:r,E=t?"file":"appFile",p=a?.file?"file":a?.appFile?"appFile":"";return e.jsxs(i.Form,{action:"/launch-editor",method:"POST",className:"flex items-center",children:[b,_,e.jsx("input",{type:"hidden",name:"line",value:typeof l=="number"?l:void 0}),e.jsx("input",{type:"hidden",name:"column",value:d}),e.jsx("input",{type:"hidden",name:"type",value:E}),e.jsx("input",{type:"hidden",name:"file",value:t}),e.jsx("input",{type:"hidden",name:"appName",value:c}),f?.map(s=>e.jsx("input",{type:"hidden",name:"appFile",value:s},s)),a?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"hidden",name:"syncTo.type",value:p}),e.jsx("input",{type:"hidden",name:"syncTo.file",value:a.file}),e.jsx("input",{type:"hidden",name:"syncTo.appName",value:a.appName}),e.jsx("input",{type:"hidden",name:"syncTo.appFile",value:a.appFile})]}):null,e.jsx("button",{type:"submit",onClick:m,className:x("launch_button",i.state==="idle"?null:"cursor-progress",i.data?.status==="error"?"cursor-not-allowed":null,n),children:u})]})}function L({className:n,file:t,appFile:r,appName:c,line:a,children:l}){const d=I(),u=v();if(Array.isArray(r))return e.jsx("div",{children:"Cannot open more than one file"});if(t){const p=h=>h.replace(/\\/g,"/"),s=ENV.EPICSHOP_GITHUB_ROOT.replace("/tree/","/blob/");return e.jsx("a",{className:"launch_button no-underline!",href:p(t).replace(p(ENV.EPICSHOP_CONTEXT_CWD),s)+(a?`#L${a}`:""),rel:"noreferrer",target:"_blank",children:l})}const o=d.find(p=>p.name===c),i=ENV.EPICSHOP_GITHUB_ROOT.replace("/tree/","/blob/"),[b,m]=r?r.split(","):["",""],f=a||(m?Number(m):void 0),E=[...o?.relativePath.split(u.separator)??[],b].join("/");return e.jsx("a",{className:x("launch_button no-underline!",n),href:`${i}/${E}${f?`#L${f}`:""}`,rel:"noreferrer",target:"_blank",children:l})}function w({appFile:n="README.mdx",appName:t,file:r,relativePath:c}){const a=j(),l=u=>{if(!u.altKey||ENV.EPICSHOP_DEPLOYED)return;u.preventDefault();const o=new FormData,i=r?"file":"appFile";o.append(i,r??n),o.append("type",i),t&&o.append("appName",t),a.submit(o,{method:"POST",action:"/launch-editor"})},d=ENV.EPICSHOP_GITHUB_ROOT.replace(/\/tree\/|\/blob\//,"/edit/");return e.jsxs(P,{className:"self-center font-mono text-sm",onClick:l,target:"_blank",to:`${d}/${c}`.replace(/\\/g,"/"),children:[e.jsx("span",{className:"@min-[720px]:hidden",children:"Edit"}),e.jsx("span",{className:"hidden @min-[720px]:block @min-[900px]:hidden",children:"Edit on GitHub"}),e.jsx("span",{className:"hidden @min-[900px]:block",children:"Edit this page on GitHub"})]})}const G=ENV.EPICSHOP_DEPLOYED?L:D;export{w as E,G as L};
//# sourceMappingURL=launch-editor-DiQgdwg7.js.map
