/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/csgo-sharecode@4.0.0/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const DICTIONARY="ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789",DICTIONARY_LENGTH=BigInt(57),SHARECODE_PATTERN=/^CSGO(-?[\w]{5}){5}$/;export class InvalidShareCode extends Error{constructor(){super("Invalid share code"),Object.setPrototypeOf(this,InvalidShareCode.prototype)}}export class InvalidCrosshairShareCode extends Error{constructor(){super("Invalid crosshair share code"),Object.setPrototypeOf(this,InvalidCrosshairShareCode.prototype)}}function bytesToHex(e){return Array.from(e,(e=>("0"+(255&e).toString(16)).slice(-2))).join("")}function bytesToBigInt(e){const r=bytesToHex(e);return BigInt(`0x${r}`)}function stringToBytes(e){const r=[];for(let t=0;t<e.length;t+=2)r.push(parseInt(e.slice(t,t+2),16));return r}function int16ToBytes(e){return[(65280&e)>>8,255&e]}function uint8ToInt8(e){return e<<24>>24}function sumArray(e){return e.reduce(((e,r)=>e+r),0)}function shareCodeToBytes(e){if(!e.match(SHARECODE_PATTERN))throw new InvalidShareCode;e=e.replace(/CSGO|-/g,"");const r=Array.from(e).reverse();let t=BigInt(0);for(let e=0;e<r.length;e++)t=t*DICTIONARY_LENGTH+BigInt(DICTIONARY.indexOf(r[e]));return stringToBytes(t.toString(16).padStart(36,"0"))}function bytesToShareCode(e){const r=bytesToHex(e);let t=BigInt(`0x${r}`),o="",n=BigInt(0);for(let e=0;e<25;e++)n=t%DICTIONARY_LENGTH,o+=DICTIONARY[Number(n)],t/=DICTIONARY_LENGTH;return`CSGO-${o.slice(0,5)}-${o.slice(5,10)}-${o.slice(10,15)}-${o.slice(15,20)}-${o.slice(20,25)}`}export function encodeMatch({matchId:e,reservationId:r,tvPort:t}){return bytesToShareCode([...stringToBytes(e.toString(16)).reverse(),...stringToBytes(r.toString(16)).reverse(),...int16ToBytes(t).reverse()])}export function decodeMatchShareCode(e){const r=shareCodeToBytes(e);return{matchId:bytesToBigInt(r.slice(0,8).reverse()),reservationId:bytesToBigInt(r.slice(8,16).reverse()),tvPort:Number(bytesToBigInt(r.slice(16,18).reverse()))}}export function decodeCrosshairShareCode(e){const r=shareCodeToBytes(e),t=sumArray(r.slice(1))%256;if(r[0]!==t)throw new InvalidCrosshairShareCode;return{gap:uint8ToInt8(r[2])/10,outline:r[3]/2,red:r[4],green:r[5],blue:r[6],alpha:r[7],splitDistance:7&r[8],followRecoil:8==(r[8]>>4&8),fixedCrosshairGap:uint8ToInt8(r[9])/10,color:7&r[10],outlineEnabled:!(8&~r[10]),innerSplitAlpha:(r[10]>>4)/10,outerSplitAlpha:(15&r[11])/10,splitSizeRatio:(r[11]>>4)/10,thickness:r[12]/10,centerDotEnabled:1==(r[13]>>4&1),deployedWeaponGapEnabled:2==(r[13]>>4&2),alphaEnabled:4==(r[13]>>4&4),tStyleEnabled:8==(r[13]>>4&8),style:(15&r[13])>>1,length:r[14]/10}}export function encodeCrosshair(e){const r=[0,1,10*e.gap&255,2*e.outline,e.red,e.green,e.blue,e.alpha,7&e.splitDistance|Number(e.followRecoil)<<7,10*e.fixedCrosshairGap&255,7&e.color|Number(e.outlineEnabled)<<3|10*e.innerSplitAlpha<<4,10*e.outerSplitAlpha|10*e.splitSizeRatio<<4,10*e.thickness,e.style<<1|Number(e.centerDotEnabled)<<4|Number(e.deployedWeaponGapEnabled)<<5|Number(e.alphaEnabled)<<6|Number(e.tStyleEnabled)<<7,10*e.length,0,0,0];r[0]=255&sumArray(r);return bytesToShareCode(r)}export function crosshairToConVars(e){return`\ncl_crosshair_drawoutline "${Number(e.outlineEnabled)}"\ncl_crosshair_dynamic_maxdist_splitratio "${e.splitSizeRatio}"\ncl_crosshair_dynamic_splitalpha_innermod "${e.innerSplitAlpha}"\ncl_crosshair_dynamic_splitalpha_outermod "${e.outerSplitAlpha}"\ncl_crosshair_dynamic_splitdist "${e.splitDistance}"\ncl_crosshair_outlinethickness "${e.outline}"\ncl_crosshair_t "${Number(e.tStyleEnabled)}"\ncl_crosshairalpha "${e.alpha}"\ncl_crosshaircolor "${e.color}"\ncl_crosshaircolor_b "${e.blue}"\ncl_crosshaircolor_g "${e.green}"\ncl_crosshaircolor_r "${e.red}"\ncl_crosshairdot "${Number(e.centerDotEnabled)}"\ncl_crosshairgap "${e.gap}"\ncl_crosshairgap_useweaponvalue "${Number(e.deployedWeaponGapEnabled)}"\ncl_crosshairsize "${e.length}"\ncl_crosshairstyle "${e.style}"\ncl_crosshairthickness "${e.thickness}"\ncl_crosshairusealpha "${Number(e.alphaEnabled)}"\ncl_fixedcrosshairgap "${e.fixedCrosshairGap}"\ncl_crosshair_recoil "${Number(e.followRecoil)}"\n`}
//# sourceMappingURL=/sm/a5a1872a786095c3375b8c5b0e93bd7882fda01123a84a06c521c9fc73a65ee4.map