import{c as e,o as t,s as n}from"./home-dir-C44RaPME-B5iLWwCq.mjs";function r(t){let r=n(t);if(!r)return null;let i=r.split(`:`).filter(Boolean);if(i.length<3||i[0]!==`agent`)return null;let a=e(i[1]),o=i.slice(2).join(`:`);return!a||!o?null:{agentId:a,rest:o}}function i(e){let t=r(e);return t?n(t.rest)?.startsWith(`cron:`)===!0:!1}function a(e){let t=n(e);return t?t.split(`:subagent:`).length-1:0}function o(n){let r=e(n);if(!r)return{baseSessionKey:void 0,threadId:void 0};let i=t(r).lastIndexOf(`:thread:`);return{baseSessionKey:i===-1?r:r.slice(0,i),threadId:e(i===-1?void 0:r.slice(i+8))}}function s(t){let r=e(t);if(!r)return null;let i=r.split(`:`).filter(Boolean),a=i.length>=3&&n(i[0])===`agent`?2:0,o=i.slice(a);if(o.length<3)return null;let s=n(o[0]),c=n(o[1]);if(!s||c!==`group`&&c!==`channel`)return null;let l=e(o.slice(2).join(`:`)),u=e(i.slice(0,a+2).join(`:`));return!l||!u?null:{channel:s,kind:c,rawId:l,prefix:u}}const c=`main`,l=/^[a-z0-9][a-z0-9_-]{0,63}$/i,u=/[^a-z0-9_-]+/g,d=/^-+/,f=/-+$/;function p(e){return t(e)||`main`}function m(e){return h(r(e)?.agentId??`main`)}function h(e){let n=(e??``).trim();if(!n)return c;let r=t(n);return l.test(n)?r:r.replace(u,`-`).replace(d,``).replace(f,``).slice(0,64)||`main`}export{p as a,o as c,h as i,m as l,a as n,r as o,i as r,s,c as t};