/* Socket Lib - Built with esbuild */
var J=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var L=(n,e)=>{for(var a in e)J(n,a,{get:e[a],enumerable:!0})},G=(n,e,a,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!I.call(n,r)&&r!==a&&J(n,r,{get:()=>e[r],enumerable:!(t=C(e,r))||t.enumerable});return n};var M=n=>G(J({},"__esModule",{value:!0}),n);var ce={};L(ce,{extractPackage:()=>ee,findPackageExtensions:()=>ne,getReleaseTag:()=>te,packPackage:()=>ae,readPackageJson:()=>$,readPackageJsonSync:()=>oe,resolveGitHubTgzUrl:()=>re,resolvePackageName:()=>ie,resolveRegistryPackageName:()=>se});module.exports=M(ce);var k=require("#constants/packages"),H=require("#constants/process"),T=require("#constants/socket"),d=require("../fs"),m=require("../objects"),U=require("./normalize"),j=require("./paths"),s=require("./specs");const N=(0,H.getAbortSignal)(),D=(0,k.getPackageExtensions)(),F=(0,k.getPackumentCache)(),q=(0,k.getPacoteCachePath)();let b;function W(){return b===void 0&&(b=require("../external/cacache")),b}let y;function z(){return y===void 0&&(y=require("../external/make-fetch-happen").defaults({cachePath:q,cache:"force-cache"})),y}let x;function Y(){return x===void 0&&(x=require("../external/npm-package-arg")),x}let _;function B(){return _===void 0&&(_=require("../external/libnpmpack")),_}let w;function K(){return w===void 0&&(w=require("../external/@socketregistry/packageurl-js").PackageURL),w}let O;function Q(){return O===void 0&&(O=require("../external/pacote")),O}let E;function V(){return E===void 0&&(E=require("../external/semver")),E}let S;function X(){return S===void 0&&(S=require("#packages/editable").toEditablePackageJson),S}let R;function Z(){return R===void 0&&(R=require("#packages/editable").toEditablePackageJsonSync),R}async function ee(n,e,a){let t=a,r=e;arguments.length===2&&typeof e=="function"&&(t=e,r=void 0);const{dest:i,tmpPrefix:o,...f}={__proto__:null,...r},g={packumentCache:F,preferOffline:!0,...f},u=Q();typeof i=="string"?(await u.extract(n,i,g),typeof t=="function"&&await t(i)):await W().tmp.withTmp(q,{tmpPrefix:o},async c=>{await u.extract(n,c,g),typeof t=="function"&&await t(c)})}function ne(n,e){let a;for(const t of D){const r=String(t[0]),i=t[1],o=r.lastIndexOf("@"),f=r.slice(0,o);if(n===f){const g=V(),u=r.slice(o+1);g.satisfies(e,u)&&(a===void 0&&(a={}),typeof i=="object"&&i!==null&&(0,m.merge)(a,i))}}return a}function te(n){if(!n)return"";let e=-1;return n.startsWith("@")?e=n.indexOf("@",1):e=n.indexOf("@"),e!==-1?n.slice(e+1):""}async function ae(n,e){return await B()(n,{__proto__:null,signal:N,...e,packumentCache:F,preferOffline:!0})}async function $(n,e){const{editable:a,normalize:t,throws:r,...i}={__proto__:null,...e},o=await(0,d.readJson)((0,j.resolvePackageJsonPath)(n),{throws:r});if(o)return a?await X()(o,{path:n,normalize:t,...i}):t?(0,U.normalizePackageJson)(o,i):o}function oe(n,e){const{editable:a,normalize:t,throws:r,...i}={__proto__:null,...e},o=(0,d.readJsonSync)((0,j.resolvePackageJsonPath)(n),{throws:r});if(o)return a?Z()(o,{path:n,normalize:t,...i}):t?(0,U.normalizePackageJson)(o,i):o}async function re(n,e){const a=(0,m.isObjectObject)(e),t=a?e:await $(e,{normalize:!0});if(!t)return"";const{version:r}=t,o=Y()(n,a?void 0:e);if((0,s.isGitHubTgzSpec)(o))return o.saveSpec||"";const g=(0,s.isGitHubUrlSpec)(o),u=t.repository,{project:l,user:c}=(g?o.hosted:(0,s.getRepoUrlDetails)(u?.url))||{project:"",user:""};if(c&&l){let p="";if(g)p=(0,s.gitHubTagRefUrl)(c,l,o.gitCommittish||"");else{const P=z(),h=r;p=(0,s.gitHubTagRefUrl)(c,l,`v${h}`),(await P(p,{method:"head"})).ok||(p=(0,s.gitHubTagRefUrl)(c,l,h),(await P(p,{method:"head"})).ok||(p=""))}if(p){const v=(await(await z()(p)).json())?.object?.sha;if(v)return(0,s.gitHubTgzUrl)(c,l,v)}}return""}function ie(n,e="/"){const{name:a,namespace:t}=n;return`${t?`${t}${e}`:""}${a}`}function se(n){const e=K().fromString(`pkg:npm/${n}`);return e.namespace?`${e.namespace.slice(1)}${T.REGISTRY_SCOPE_DELIMITER}${e.name}`:n}0&&(module.exports={extractPackage,findPackageExtensions,getReleaseTag,packPackage,readPackageJson,readPackageJsonSync,resolveGitHubTgzUrl,resolvePackageName,resolveRegistryPackageName});
//# sourceMappingURL=operations.js.map
