import{parse as o}from"path";function p(t){const e=t.split("/");let a=-1;for(let i=0;i<e.length;i++)if(e[i]==="@api"){a=i;break}if(a===-1)return{prefixPath:"",apiPath:t};const n=e.slice(0,a).join("/"),r=e.slice(a+1).join("/");return{prefixPath:n?`/${n}/api`:"/api",apiPath:r}}function c(t){const{dir:e,name:a}=o(t),n=a.match(/\.(get|post|put|delete|patch)$/i);return{dir:e,method:n?n[1]:"all",routeName:a.replace(/\.(get|post|put|delete|patch)$/,"")}}function s(t){return t.startsWith("[...")&&t.endsWith("]")?`:${t.slice(4,-1)}{.+}`:t.startsWith("[")&&t.endsWith("]")?`:${t.slice(1,-1)}`:t}function h(t,e){const a=t.split("/");return e!=="index"&&a.push(e),a}function u(t,e){return`${t}/${e.join("/")}`.replace(/\/+/g,"/").replace(/\/$/,"")}function f(t){const{prefixPath:e,apiPath:a}=p(t),{dir:n,routeName:r,method:i}=c(a);return{path:u(e,h(n,r).map(s)),method:i,handler:t}}export{f as parseRouteFsPathForHono};
