@bgforge/mls-server 3.13.2 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ var __imu=require("url").pathToFileURL(__filename).href;
2
+ "use strict";var hr=Object.create;var ot=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var Sr=Object.getPrototypeOf,Ar=Object.prototype.hasOwnProperty;var wr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of mr(e))!Ar.call(t,s)&&s!==r&&ot(t,s,{get:()=>e[s],enumerable:!(n=fr(e,s))||n.enumerable});return t};var Z=(t,e,r)=>(r=t!=null?hr(Sr(t)):{},wr(e||!t||!t.__esModule?ot(r,"default",{value:t,enumerable:!0}):r,t));var Tr=Z(require("fs")),nt=require("worker_threads");var Ut=Z(require("node:path"),1);function br(t){return t.type==="ERROR"||t.isError||t.isMissing}function it(t){let e=[];return at(t,e),e}function at(t,e){if(br(t)){e.push(t);return}if(t.hasError)for(let r of t.children)r&&at(r,e)}var Y=class extends Error{diagnostics;constructor(e){let r=e[0];super(r?`${r.line}:${r.column}: ${r.message}`:"compilation failed"),this.name="CompileError",this.diagnostics=e}};var yr=["NOOP","CONST","CRITICAL_START","CRITICAL_DONE","JMP","CALL","CALL_AT","CALL_CONDITION","CALLSTART","EXEC","SPAWN","FORK","A_TO_D","D_TO_A","EXIT","DETACH","EXIT_PROG","STOP_PROG","FETCH_GLOBAL","STORE_GLOBAL","FETCH_EXTERNAL","STORE_EXTERNAL","EXPORT_VAR","EXPORT_PROC","SWAP","SWAPA","POP","DUP","POP_RETURN","POP_EXIT","POP_ADDRESS","POP_FLAGS","POP_FLAGS_RETURN","POP_FLAGS_EXIT","POP_FLAGS_RETURN_EXTERN","POP_FLAGS_EXIT_EXTERN","POP_FLAGS_RETURN_VAL_EXTERN","POP_FLAGS_RETURN_VAL_EXIT","POP_FLAGS_RETURN_VAL_EXIT_EXTERN","CHECK_ARG_COUNT","LOOKUP_STRING_PROC","POP_BASE","POP_TO_BASE","PUSH_BASE","SET_GLOBAL","FETCH_PROC_ADDRESS","DUMP","IF","WHILE","STORE","FETCH","EQUAL","NOT_EQUAL","LESS_EQUAL","GREATER_EQUAL","LESS","GREATER","ADD","SUB","MUL","DIV","MOD","AND","OR","BWAND","BWOR","BWXOR","BWNOT","FLOOR","NOT","NEGATE","WAIT","CANCEL","CANCELALL","STARTCRITICAL","ENDCRITICAL"];function Rr(){let t={};return yr.forEach((e,r)=>{t[e]=32768+r}),t}var T=Rr(),_t=T.CONST|16384,lt=T.CONST|8192,ct=T.CONST|4096;var Or=76,dt=["SAYQUIT","SAYEND","SAYSTART","SAYSTARTPOS","SAYREPLYTITLE","SAYGOTOREPLY","SAYREPLY","SAYOPTION","SAYMESSAGE","SAYREPLYWINDOW","SAYOPTIONWINDOW","SAYBORDER","SAYSCROLLUP","SAYSCROLLDOWN","SAYSETSPACING","SAYOPTIONCOLOR","SAYREPLYCOLOR","SAYRESTART","SAYGETLASTPOS","SAYREPLYFLAGS","SAYOPTIONFLAGS","SAYMESSAGETIMEOUT","CREATEWIN","DELETEWIN","SELECTWIN","RESIZEWIN","SCALEWIN","SHOWWIN","FILLWIN","FILLRECT","FILLWIN3X3","DISPLAY","DISPLAYGFX","DISPLAYRAW","LOADPALETTETABLE","FADEIN","FADEOUT","GOTOXY","PRINT","FORMAT","PRINTRECT","SETFONT","SETTEXTFLAGS","SETTEXTCOLOR","SETHIGHLIGHTCOLOR","STOPMOVIE","PLAYMOVIE","MOVIEFLAGS","PLAYMOVIERECT","PLAYMOVIEALPHA","PLAYMOVIEALPHARECT","ADDREGION","ADDREGIONFLAG","ADDREGIONPROC","ADDREGIONRIGHTPROC","DELETEREGION","ACTIVATEREGION","CHECKREGION","ADDBUTTON","ADDBUTTONTEXT","ADDBUTTONFLAG","ADDBUTTONGFX","ADDBUTTONPROC","ADDBUTTONRIGHTPROC","DELETEBUTTON","HIDEMOUSE","SHOWMOUSE","MOUSESHAPE","REFRESHMOUSE","SETGLOBALMOUSEFUNC","ADDNAMEDEVENT","ADDNAMEDHANDLER","CLEARNAMED","SIGNALNAMED","ADDKEY","DELETEKEY","SOUNDPLAY","SOUNDPAUSE","SOUNDRESUME","SOUNDSTOP","SOUNDREWIND","SOUNDDELETE","SETONEOPTPAUSE","SELECTFILELIST","TOKENIZE"],ut=["GIVE_EXP_POINTS","SCR_RETURN","PLAY_SFX","OBJ_NAME","SFX_BUILD_OPEN_NAME","GET_PC_STAT","TILE_CONTAINS_PID_OBJ","SET_MAP_START","OVERRIDE_MAP_START","HAS_SKILL","USING_SKILL","ROLL_VS_SKILL","SKILL_CONTEST","DO_CHECK","IS_SUCCESS","IS_CRITICAL","HOW_MUCH","MARK_AREA_KNOWN","REACTION_INFLUENCE","RANDOM","ROLL_DICE","MOVE_TO","CREATE_OBJECT_SID","DISPLAY_MSG","SCRIPT_OVERRIDES","OBJ_IS_CARRYING_OBJ_PID","TILE_CONTAINS_OBJ_PID","SELF_OBJ","SOURCE_OBJ","TARGET_OBJ","DUDE_OBJ","OBJ_BEING_USED_WITH","LOCAL_VAR","SET_LOCAL_VAR","MAP_VAR","SET_MAP_VAR","GLOBAL_VAR","SET_GLOBAL_VAR","SCRIPT_ACTION","OBJ_TYPE","OBJ_ITEM_SUBTYPE","GET_CRITTER_STAT","SET_CRITTER_STAT","ANIMATE_STAND_OBJ","ANIMATE_STAND_REVERSE_OBJ","ANIMATE_MOVE_OBJ_TO_TILE","TILE_IN_TILE_RECT","ATTACK_COMPLEX","MAKE_DAYTIME","TILE_DISTANCE","TILE_DISTANCE_OBJS","TILE_NUM","TILE_NUM_IN_DIRECTION","PICKUP_OBJ","DROP_OBJ","ADD_OBJ_TO_INVEN","RM_OBJ_FROM_INVEN","WIELD_OBJ_CRITTER","USE_OBJ","OBJ_CAN_SEE_OBJ","ATTACK","START_GDIALOG","END_DIALOGUE","DIALOGUE_REACTION","METARULE3","SET_MAP_MUSIC","SET_OBJ_VISIBILITY","LOAD_MAP","WM_AREA_SET_POS","SET_EXIT_GRIDS","ANIM_BUSY","CRITTER_HEAL","SET_LIGHT_LEVEL","GAME_TIME","GAME_TIME_IN_SECONDS","ELEVATION","KILL_CRITTER","KILL_CRITTER_TYPE","CRITTER_DMG","ADD_TIMER_EVENT","RM_TIMER_EVENT","GAME_TICKS","HAS_TRAIT","DESTROY_OBJECT","OBJ_CAN_HEAR_OBJ","GAME_TIME_HOUR","FIXED_PARAM","TILE_IS_VISIBLE","DIALOGUE_SYSTEM_ENTER","ACTION_BEING_USED","CRITTER_STATE","GAME_TIME_ADVANCE","RADIATION_INC","RADIATION_DEC","CRITTER_ATTEMPT_PLACEMENT","OBJ_PID","CUR_MAP_INDEX","CRITTER_ADD_TRAIT","CRITTER_RM_TRAIT","PROTO_DATA","MESSAGE_STR","CRITTER_INVEN_OBJ","OBJ_SET_LIGHT_LEVEL","WORLD_MAP","INVEN_CMDS","FLOAT_MSG","METARULE","ANIM","OBJ_CARRYING_PID_OBJ","REG_ANIM_FUNC","REG_ANIM_ANIMATE","REG_ANIM_ANIMATE_REVERSE","REG_ANIM_OBJ_MOVE_TO_OBJ","REG_ANIM_OBJ_RUN_TO_OBJ","REG_ANIM_OBJ_MOVE_TO_TILE","REG_ANIM_OBJ_RUN_TO_TILE","PLAY_GMOVIE","ADD_MULT_OBJS_TO_INVEN","RM_MULT_OBJS_FROM_INVEN","GET_MONTH","GET_DAY","EXPLOSION","DAYS_SINCE_VISITED","GSAY_START","GSAY_END","GSAY_REPLY","GSAY_OPTION","GSAY_MESSAGE","GIQ_OPTION","POISON","GET_POISON","PARTY_ADD","PARTY_REMOVE","REG_ANIM_ANIMATE_FOREVER","CRITTER_INJURE","COMBAT_IS_INITIALIZED","GDIALOG_MOD_BARTER","DIFFICULTY_LEVEL","RUNNING_BURNING_GUY","INVEN_UNWIELD","OBJ_IS_LOCKED","OBJ_LOCK","OBJ_UNLOCK","OBJ_IS_OPEN","OBJ_OPEN","OBJ_CLOSE","GAME_UI_DISABLE","GAME_UI_ENABLE","GAME_UI_IS_DISABLED","GFADE_OUT","GFADE_IN","ITEM_CAPS_TOTAL","ITEM_CAPS_ADJUST","ANIM_ACTION_FRAME","REG_ANIM_PLAY_SFX","CRITTER_MOD_SKILL","SFX_BUILD_CHAR_NAME","SFX_BUILD_AMBIENT_NAME","SFX_BUILD_INTERFACE_NAME","SFX_BUILD_ITEM_NAME","SFX_BUILD_WEAPON_NAME","SFX_BUILD_SCENERY_NAME","ATTACK_SETUP","DESTROY_MULT_OBJS","USE_OBJ_ON_OBJ","ENDGAME_SLIDESHOW","MOVE_OBJ_INVEN_TO_OBJ","ENDGAME_MOVIE","OBJ_ART_FID","ART_ANIM","PARTY_MEMBER_OBJ","ROTATION_TO_TILE","JAM_LOCK","GDIALOG_SET_BARTER_MOD","COMBAT_DIFFICULTY","OBJ_ON_SCREEN","CRITTER_IS_FLEEING","CRITTER_SET_FLEE_STATE","TERMINATE_COMBAT","DEBUG_MSG","CRITTER_STOP_ATTACKING","TS_READ_BYTE","TS_READ_SHORT","TS_READ_INT","TS_READ_STRING","TS_SET_PC_BASE_STAT","TS_SET_PC_EXTRA_STAT","TS_GET_PC_BASE_STAT","TS_GET_PC_EXTRA_STAT","TS_SET_CRITTER_BASE_STAT","TS_SET_CRITTER_EXTRA_STAT","TS_GET_CRITTER_BASE_STAT","TS_GET_CRITTER_EXTRA_STAT","TS_TAP_KEY","TS_GET_YEAR","TS_GAME_LOADED","TS_GRAPHICS_FUNCS_AVAILABLE","TS_LOAD_SHADER","TS_FREE_SHADER","TS_ACTIVATE_SHADER","TS_DEACTIVATE_SHADER","TS_SET_GLOBAL_SCRIPT_REPEAT","TS_INPUT_FUNCS_AVAILABLE","TS_KEY_PRESSED","TS_SET_SHADER_INT","TS_SET_SHADER_FLOAT","TS_SET_SHADER_VECTOR","TS_IN_WORLD_MAP","TS_FORCE_ENCOUNTER","TS_SET_WORLD_MAP_POS","TS_GET_WORLD_MAP_X_POS","TS_GET_WORLD_MAP_Y_POS","TS_SET_DM_MODEL","TS_SET_DF_MODEL","TS_SET_MOVIE_PATH","TS_SET_PERK_IMAGE","TS_SET_PERK_RANKS","TS_SET_PERK_LEVEL","TS_SET_PERK_STAT","TS_SET_PERK_STAT_MAG","TS_SET_PERK_SKILL1","TS_SET_PERK_SKIL","TS_SET_PERK_TYPE","TS_SET_PERK_SKILL2","TS_SET_PERK_SKILL2_MAG","TS_SET_PERK_STR","TS_SET_PERK_PER","TS_SET_PERK_END","TS_SET_PERK_CHR","TS_SET_PERK_INT","TS_SET_PERK_AGL","TS_SET_PERK_LCK","TS_SET_PERK_NAME","TS_SET_PERK_DESC","TS_SET_PIPBOY_AVAILABLE","TS_GET_KILL_COUNTER","TS_MOD_KILL_COUNTER","TS_GET_PERK_OWED","TS_SET_PERK_OWED","TS_GET_PERK_AVAILABLE","TS_GET_CRITTER_AP","TS_SET_CRITTER_AP","TS_GET_ACTIVE_HAND","TS_TOGGLE_ACTIVE_HAND","TS_SET_WEAPON_KNOCKBACK","TS_SET_TARGET_KNOCKBACK","TS_SET_ATTACKER_KNOCKBACK","TS_REMOVE_WEAPON_KNOCKBACK","TS_REMOVE_TARGET_KNOCKBACK","TS_REMOVE_ATTACKER_KNOCKBACK","TS_SET_GLOBAL_SCRIPT_TYPE","TS_AVAILABLE_GLOBAL_SCRIPT_TYPES","TS_SET_SFALL_GLOBAL","TS_GET_SFALL_GLOBAL_INT","TS_GET_SFALL_GLOBAL_FLOAT","TS_SET_PICKPOCKET_MAX","TS_SET_HIT_CHANCE_MAX","TS_SET_SKILL_MAX","TS_EAX_AVAILABLE","TS_SET_EAX_ENVIRONMENT","TS_INC_NPC_LEVEL","TS_GET_VIEWPORT_X","TS_GET_VIEWPORT_Y","TS_SET_VIEWPORT_X","TS_SET_VIEWPORT_Y","TS_SET_XP_MOD","TS_SET_PERK_LEVEL_MOD","TS_GET_INI_SETTING","TS_GET_SHADER_VERSION","TS_SET_SHADER_MODE","TS_GET_GAME_MODE","TS_FORCE_GRAPHICS_REFRESH","TS_GET_SHADER_TEXTURE","TS_SET_SHADER_TEXTURE","TS_GET_UPTIME","TS_SET_STAT_MAX","TS_SET_STAT_MIN","TS_SET_CAR_CURRENT_TOWN","TS_SET_PC_STAT_MAX","TS_SET_PC_STAT_MIN","TS_SET_NPC_STAT_MAX","TS_SET_NPC_STAT_MIN","TS_SET_FAKE_PERK","TS_SET_FAKE_TRAIT","TS_SET_SELECTABLE_PERK","TS_SET_PERKBOX_TITLE","TS_HIDE_REAL_PERKS","TS_SHOW_REAL_PERKS","TS_HAS_FAKE_PERK","TS_HAS_FAKE_TRAIT","TS_PERK_ADD_MODE","TS_CLEAR_SELECTABLE_PERKS","TS_SET_CRITTER_HIT_CHANCE_MOD","TS_SET_BASE_HIT_CHANCE_MOD","TS_SET_CRITTER_SKILL_MOD","TS_SET_BASE_SKILL_MOD","TS_SET_CRITTER_PICKPOCKET_MOD","TS_SET_BASE_PICKPOCKET_MOD","TS_SET_PYROMANIAC_MOD","TS_APPLY_HEAVEHO_FIX","TS_SET_SWIFTLEARNER_MOD","TS_SET_HP_LEVEL_MOD","TS_WRITE_BYTE","TS_WRITE_SHORT","TS_WRITE_INT","TS_CALL_OFFSET_V0","TS_CALL_OFFSET_V1","TS_CALL_OFFSET_V2","TS_CALL_OFFSET_V3","TS_CALL_OFFSET_V4","TS_CALL_OFFSET_R0","TS_CALL_OFFSET_R1","TS_CALL_OFFSET_R2","TS_CALL_OFFSET_R3","TS_CALL_OFFSET_R4","TS_SHOW_IFACE_TAG","TS_HIDE_IFACE_TAG","TS_IS_IFACE_TAG_ACTIVE","TS_GET_BODYPART_HIT_MODIFIER","TS_SET_BODYPART_HIT_MODIFIER","TS_SET_CRITICAL_TABLE","TS_GET_CRITICAL_TABLE","TS_RESET_CRITICAL_TABLE","TS_GET_SFALL_ARG","TS_SET_SFALL_RETURN","TS_SET_UNSPENT_AP_BONUS","TS_GET_UNSPENT_AP_BONUS","TS_SET_UNSPENT_AP_EBONUS","TS_GET_UNSPENT_AP_EBONUS","TS_INIT_HOOK","TS_GET_INI_STRING","TS_SQRT","TS_ABS","TS_SIN","TS_COS","TS_TAN","TS_ATAN","TS_SET_PALETTE","TS_REMOVE_SCRIPT","TS_SET_SCRIPT","TS_GET_SCRIPT","TS_NB_CREATE_CHAR","TS_FS_CREATE","TS_FS_COPY","TS_FS_FIND","TS_FS_WRITE_BYTE","TS_FS_WRITE_SHORT","TS_FS_WRITE_INT","TS_FS_WRITE_FLOAT","TS_FS_WRITE_STRING","TS_FS_DELETE","TS_FS_SIZE","TS_FS_POS","TS_FS_SEEK","TS_FS_RESIZE","TS_GET_PROTO_DATA","TS_SET_PROTO_DATA","TS_SET_SELF","TS_REGISTER_HOOK","TS_FS_WRITE_BSTRING","TS_FS_READ_BYTE","TS_FS_READ_SHORT","TS_FS_READ_INT","TS_FS_READ_FLOAT","TS_LIST_BEGIN","TS_LIST_NEXT","TS_LIST_END","TS_SFALL_VER_MAJOR","TS_SFALL_VER_MINOR","TS_SFALL_VER_BUILD","TS_HERO_SELECT_WIN","TS_SET_HERO_RACE","TS_SET_HERO_STYLE","TS_SET_CRITTER_BURST_DISABLE","TS_GET_WEAPON_AMMO_PID","TS_SET_WEAPON_AMMO_PID","TS_GET_WEAPON_AMMO_COUNT","TS_SET_WEAPON_AMMO_COUNT","TS_WRITE_STRING","TS_GET_MOUSE_X","TS_GET_MOUSE_Y","TS_GET_MOUSE_BUTTONS","TS_GET_WINDOW_UNDER_MOUSE","TS_GET_SCREEN_WIDTH","TS_GET_SCREEN_HEIGHT","TS_STOP_GAME","TS_RESUME_GAME","TS_CREATE_MESSAGE_WINDOW","TS_REMOVE_TRAIT","TS_GET_LIGHT_LEVEL","TS_REFRESH_PC_ART","TS_GET_ATTACK_TYPE","TS_FORCE_ENCOUNTER_WITH_FLAGS","TS_SET_MAP_TIME_MULTI","TS_PLAY_SFALL_SOUND","TS_STOP_SFALL_SOUND","TS_CREATE_ARRAY","TS_SET_ARRAY","TS_GET_ARRAY","TS_FREE_ARRAY","TS_LEN_ARRAY","TS_RESIZE_ARRAY","TS_TEMP_ARRAY","TS_FIX_ARRAY","TS_STRING_SPLIT","TS_LIST_AS_ARRAY","TS_ATOI","TS_ATOF","TS_SCAN_ARRAY","TS_TILE_PID","TS_MODIFIED_INI","TS_GET_SFALL_ARGS","TS_SET_SFALL_ARG","TS_FORCE_AIMED_SHOTS","TS_DISABLE_AIMED_SHOTS","TS_MARK_MOVIE_PLAYED","TS_GET_NPC_LEVEL","TS_SET_CRITTER_SKILL_POINTS","TS_GET_CRITTER_SKILL_POINTS","TS_SET_AVAILABLE_SKILL_POINTS","TS_GET_AVAILABLE_SKILL_POINTS","TS_MOD_SKILL_POINTS_PER_LEVEL","TS_SET_PERK_FREQ","TS_GET_LAST_ATTACKER","TS_GET_LAST_TARGET","TS_BLOCK_COMBAT","TS_TILE_UNDER_CURSOR","TS_GET_BARTER_MOD","TS_SET_INVEN_AP_COST","TS_SUBSTR","TS_STRLEN","TS_SPRINTF","TS_ORD","TS_RESERVD2","TS_TYPEOF","TS_SAVE_ARRAY","TS_LOAD_ARRAY","TS_GET_ARRAY_KEY","TS_STACK_ARRAY","TS_RESERVD3","TS_RESERVD4","TS_REG_ANIM_DESTROY","TS_REG_ANIM_ANIMATE_AND_HIDE","TS_REG_ANIM_COMBAT_CHECK","TS_REG_ANIM_LIGHT","TS_REG_ANIM_CHANGE_FID","TS_REG_ANIM_TAKE_OUT","TS_REG_ANIM_TURN_TOWARDS","TS_EXPLOSIONS_METARULE","TS_REGISTER_HOOK_PROC","TS_POW","TS_LOG","TS_EXP","TS_CEIL","TS_ROUND","TS_RESERVD5","TS_RESERVD6","TS_RESERVD7","TS_MESSAGE_STR_GAME","TS_SNEAK_SUCCESS","TS_TILE_LIGHT","TS_MAKE_STRAIGHT_PATH","TS_OBJ_BLOCKING_AT","TS_TILE_GET_OBJECTS","TS_GET_PARTY_MEMBERS","TS_PATH_FIND","TS_CREATE_SPATIAL","TS_ART_EXISTS","TS_OBJ_IS_CARRYING_OBJ","TS_SFALL_METARULE0","TS_SFALL_METARULE1","TS_SFALL_METARULE2","TS_SFALL_METARULE3","TS_SFALL_METARULE4","TS_SFALL_METARULE5","TS_SFALL_METARULE6","TS_REGISTER_HOOK_PROC2","TS_REG_ANIM_CALLBACK","TS_DIV","TS_SFALL_METARULE7","TS_SFALL_METARULE8"],Pr={17:"REACTION",46:"ANIMATE_JUMP",64:"TURN_OFF_OBJS_IN_AREA",65:"TURN_ON_OBJS_IN_AREA",68:"BARTER_OFFER",69:"BARTER_ASKING",104:"TOWN_MAP"},pt=32768+Or,ve=pt+dt.length;function gt(t,e){let r={};return t.forEach((n,s)=>{r[n]=e+s}),r}var f=gt(dt,pt),a=gt(ut,ve),gs=ve+ut.length,Et=Object.fromEntries(Object.entries(Pr).map(([t,e])=>[e,ve+Number(t)]));function Lr(t){let e=t+1;return e%2===0?e:e+1}var de=class{offsets=new Map;records=[];cursor=4;intern(e){let r=this.offsets.get(e);if(r!==void 0)return r;let n=Buffer.from(e,"latin1"),s=Lr(n.length),o=new Uint8Array(2+s);o[0]=s>>8&255,o[1]=s&255,o.set(n,2);let _=this.cursor+2;return this.offsets.set(e,_),this.records.push(o),this.cursor+=o.length,_}offsetOf(e){let r=this.offsets.get(e);if(r===void 0)throw new Error(`name '${e}' was not interned before the table was written`);return r}markAllocated(){this.allocated=!0}allocated=!1;get isEmpty(){return this.records.length===0&&!this.allocated}get entriesLength(){return this.cursor-4}toBytes(){let e=Uint8Array.from([255,255,255,255]);if(this.isEmpty)return e;let r=this.entriesLength,n=new Uint8Array(4+r+4);n[0]=r>>>24&255,n[1]=r>>>16&255,n[2]=r>>>8&255,n[3]=r&255;let s=4;for(let o of this.records)n.set(o,s),s+=o.length;return n.set(e,s),n}};var Ae=class{buffer;length=0;constructor(e=4096){this.buffer=new Uint8Array(e)}tell(){return this.length}ensure(e){if(this.length+e<=this.buffer.length)return;let r=this.buffer.length*2;for(;r<this.length+e;)r*=2;let n=new Uint8Array(r);n.set(this.buffer.subarray(0,this.length)),this.buffer=n}byte(e){this.ensure(1),this.buffer[this.length++]=e&255}word(e){this.byte(e>>8),this.byte(e)}long(e){this.byte(e>>24),this.byte(e>>16),this.byte(e>>8),this.byte(e)}patchLong(e,r){this.buffer[e]=r>>24&255,this.buffer[e+1]=r>>16&255,this.buffer[e+2]=r>>8&255,this.buffer[e+3]=r&255}bytes(e){this.ensure(e.length),this.buffer.set(e,this.length),this.length+=e.length}op(e){this.word(e)}int(e){this.word(_t),this.long(e)}float(e){this.word(lt);let r=new DataView(new ArrayBuffer(4));r.setFloat32(0,e,!1),this.long(r.getUint32(0,!1))}string(e){this.word(ct),this.long(e)}toBytes(){return this.buffer.slice(0,this.length)}};function ue(t){switch(t.kind){case"return":return!0;case"block":return t.body.some(ue);case"if":return t.elseBranch!==void 0?ue(t.thenBranch)&&ue(t.elseBranch):!1;default:return!1}}function j(t){return t.declarations.flatMap(e=>e.kind==="procedure"?[e.procedure]:[])}function pe(t){return t.declarations.flatMap(e=>e.kind==="global"?[e.variable]:[])}function Tt(t){return t.declarations.flatMap(e=>e.kind==="external"?[e.variable]:[])}var Ce="..............",ht=18,Br={"+":T.ADD,"-":T.SUB,"*":T.MUL,"/":T.DIV,"%":T.MOD,"==":T.EQUAL,"!=":T.NOT_EQUAL,"<=":T.LESS_EQUAL,">=":T.GREATER_EQUAL,"<":T.LESS,">":T.GREATER,div:a.TS_DIV,"^":a.TS_POW,bwand:T.BWAND,bwor:T.BWOR,bwxor:T.BWXOR},Ur={not:T.NOT,bwnot:T.BWNOT,negate:T.NEGATE,floor:T.FLOOR},Gr={"+=":T.ADD,"-=":T.SUB,"*=":T.MUL,"/=":T.DIV},$=class extends Error{constructor(e){super(e),this.name="EmitError"}},Me=class{w=new Ae;names=new de;strings=new de;loops=[];shortCircuit;dropUnreachableEpilogue;procedures;globals;externals;procTableStart=0;currentProcedure=null;program;constructor(e,r){this.program=e,this.shortCircuit=r.shortCircuit??!1,this.dropUnreachableEpilogue=r.dropUnreachableEpilogue??!1;let n={name:Ce,args:[],locals:[],body:[]};this.procedures=[n,...j(e)],this.globals=pe(e),this.externals=Tt(e)}emit(){this.internNames(),this.internStrings();let e=this.writeStartupCode();this.procTableStart=this.w.tell(),this.writeProcedureTable(),this.w.bytes(this.names.toBytes()),this.w.bytes(this.strings.toBytes()),this.w.patchLong(e,this.w.tell());let r=this.writeGlobals(),n=this.writeProcedures();return n!==null&&this.w.patchLong(r,n),this.w.toBytes()}internNames(){this.names.intern(Ce);for(let e of this.program.declarations)e.kind==="procedure"?this.names.intern(e.procedure.name):this.names.intern(e.variable.name)}internStrings(){(this.program.stringTableAllocated??(this.program.stringLiterals?.length??0)>0)&&this.strings.markAllocated();for(let n of this.program.stringLiterals??[])this.strings.intern(n);let e=n=>{switch(n.kind){case"string":this.strings.intern(n.value);break;case"procRef":n.stringify&&this.strings.intern(this.procedures[n.index+1]?.name??"");break;case"unary":e(n.operand);break;case"binary":e(n.left),e(n.right);break;case"ternary":e(n.cond),e(n.whenTrue),e(n.whenFalse);break;case"call":e(n.target),n.args.forEach(e);break;case"libCall":n.args.forEach(e);break}},r=n=>{switch(n.kind){case"block":n.body.forEach(r);break;case"expr":e(n.expr);break;case"assign":e(n.target),e(n.value);break;case"if":e(n.cond),r(n.thenBranch),n.elseBranch&&r(n.elseBranch);break;case"while":e(n.cond),r(n.body);break;case"return":n.value&&e(n.value);break;case"callStmt":e(n.target),n.args.forEach(e);break;case"timedCallStmt":e(n.delay);break;case"libStmt":case"opStmt":n.args.forEach(e);break}};for(let n of this.program.declarations){if(n.kind!=="procedure"){e(n.variable.initial);continue}let s=n.procedure;s.conditional&&e(s.conditional);for(let o of s.locals)e(o.initial);s.body.forEach(r)}}writeStartupCode(){this.w.op(T.CRITICAL_START),this.w.int(ht),this.w.op(T.D_TO_A);let e=this.w.tell()+2;return this.w.int(0),this.w.op(T.JMP),this.w.op(T.EXIT_PROG),this.w.op(T.POP),this.w.op(T.POP_FLAGS_RETURN),this.w.op(T.POP),this.w.op(T.POP_FLAGS_EXIT),this.w.op(T.POP),this.w.op(T.POP_FLAGS_RETURN_EXTERN),this.w.op(T.POP),this.w.op(T.POP_FLAGS_EXIT_EXTERN),this.w.op(T.POP_FLAGS_RETURN_VAL_EXTERN),this.w.op(T.POP_FLAGS_RETURN_VAL_EXIT),this.w.op(T.POP_FLAGS_RETURN_VAL_EXIT_EXTERN),e}procedureType(e){let r=0;return e.timed!==void 0&&(r|=1),e.conditional&&(r|=2),e.imported&&(r|=4),e.exported&&(r|=8),e.critical&&(r|=16),e.pure&&(r|=32),e.inline&&(r|=64),r}writeProcedureTable(){this.w.long(this.procedures.length);for(let e of this.procedures)this.w.long(this.names.offsetOf(e.name)),this.w.long(this.procedureType(e)),this.w.long(e.timed??0),this.w.long(0),this.w.long(0),this.w.long(e.args.length)}patchProcTableEntry(e,r,n){this.w.patchLong(this.procTableStart+4+e*4*6+r*4,n)}writeGlobals(){this.w.op(T.SET_GLOBAL);for(let r of this.globals)this.writeInitialValue(r);for(let r of this.externals)r.exported&&(this.w.string(this.names.offsetOf(r.name)),this.w.op(T.EXPORT_VAR));for(let r of this.externals)r.exported&&(this.writeInitialValue(r),this.w.string(this.names.offsetOf(r.name)),this.w.op(T.STORE_EXTERNAL));this.procedures.forEach((r,n)=>{r.exported&&(this.w.int(r.args.length),this.w.int(n),this.w.op(T.EXPORT_PROC))}),this.w.int(0),this.w.op(T.CRITICAL_DONE);let e=this.w.tell()+2;return this.w.int(ht),this.w.op(T.JMP),e}writeInitialValue(e){let r=e.initial;switch(r.kind){case"int":this.w.int(r.value);break;case"float":this.w.float(r.value);break;case"string":this.w.string(this.strings.offsetOf(r.value));break}}writeProcedures(){let e=null;return this.procedures.forEach((r,n)=>{r.name.toLowerCase()==="start"&&(e=this.w.tell()),!r.imported&&(this.patchProcTableEntry(n,4,this.w.tell()),this.writeProcedure(r,n))}),e}writeProcedure(e,r){if(e.name===Ce&&e.body.length===0)return;if(e.conditional){let o=this.w.tell()+2;this.w.int(0),this.w.op(T.JMP);let _=this.w.tell();this.w.op(T.CRITICAL_START),this.writeExpression(e.conditional),this.w.op(T.CRITICAL_DONE),this.w.op(T.STOP_PROG),this.w.patchLong(o,this.w.tell()),this.patchProcTableEntry(r,3,_)}this.w.op(T.PUSH_BASE);let n=e.reclaimedArgSlots??0;for(let o of e.locals.slice(n))this.writeInitialValue(o);this.currentProcedure=e;for(let o of e.body)this.writeStatement(o);let s=e.body[e.body.length-1];this.dropUnreachableEpilogue&&s?.kind==="return"||this.writeReturn({kind:"int",value:0}),this.w.op(T.POP_TO_BASE),this.w.op(T.POP_BASE),e.critical&&this.w.op(T.CRITICAL_DONE),this.w.op(T.POP_RETURN),this.currentProcedure=null}writeReturn(e){e&&(this.writeExpression(e),this.w.op(T.D_TO_A),this.w.op(T.SWAPA)),this.w.op(T.POP_TO_BASE),this.w.op(T.POP_BASE),e&&this.w.op(T.A_TO_D),this.currentProcedure?.critical&&this.w.op(T.CRITICAL_DONE),this.w.op(T.POP_RETURN)}writeStatement(e){switch(e.kind){case"block":for(let r of e.body)this.writeStatement(r);break;case"expr":this.writeExpression(e.expr);break;case"assign":this.writeAssign(e);break;case"if":this.writeIf(e);break;case"while":this.writeWhile(e);break;case"return":this.writeReturn(e.value);break;case"break":this.w.op(T.JMP);break;case"continue":{let r=this.currentLoop("continue");r.pendingContinues.push(this.w.tell()+2),this.w.int(r.startPos),this.w.op(T.JMP);break}case"loopEnd":{let r=this.currentLoop("loopEnd"),n=this.w.tell();for(let s of r.pendingContinues)this.w.patchLong(s,n);r.pendingContinues=[];break}case"callStmt":this.writeCall(e.target,e.args,e.checkArgCount??!1),this.w.op(T.POP);break;case"timedCallStmt":this.writeExpression(e.delay),this.w.int(e.target.index+1),this.w.op(T.CALL_AT);break;case"libStmt":for(let r of e.args)this.writeExpression(r);this.w.op(e.opcode),e.popsResult&&this.w.op(T.POP);break;case"opStmt":for(let r of e.args)this.writeExpression(r);this.w.op(e.opcode),e.opcode===T.CANCELALL&&this.w.op(e.opcode);break}}currentLoop(e){let r=this.loops[this.loops.length-1];if(!r)throw new $(`'${e}' outside a loop`);return r}writeAssign(e){let r=e.target;if(e.op!=="="){let n=Gr[e.op];if(n===void 0)throw new $(`unsupported compound assignment '${e.op}'`);this.writeFetch(r),this.writeExpression(e.value),this.w.op(n)}else this.writeExpression(e.value);this.writeStore(r)}writeFetch(e){switch(e.scope){case"local":this.w.int(e.index),this.w.op(T.FETCH);break;case"global":this.w.int(e.index),this.w.op(T.FETCH_GLOBAL);break;case"external":this.w.string(this.names.offsetOf(e.name)),this.w.op(T.FETCH_EXTERNAL);break}}writeStore(e){switch(e.scope){case"local":this.w.int(e.index),this.w.op(T.STORE);break;case"global":this.w.int(e.index),this.w.op(T.STORE_GLOBAL);break;case"external":this.w.string(this.names.offsetOf(e.name)),this.w.op(T.STORE_EXTERNAL);break}}writeIf(e){let r=this.w.tell()+2;if(this.w.int(0),this.writeExpression(e.cond),this.w.op(T.IF),this.writeStatement(e.thenBranch),!e.elseBranch){this.w.patchLong(r,this.w.tell());return}let n=this.w.tell()+2;this.w.int(0),this.w.op(T.JMP),this.w.patchLong(r,this.w.tell()),this.writeStatement(e.elseBranch),this.w.patchLong(n,this.w.tell())}writeWhile(e){let r=this.w.tell()+2;this.w.int(0);let n=this.w.tell();this.loops.push({startPos:n,pendingContinues:[]}),this.writeExpression(e.cond),this.w.op(T.WHILE),this.writeStatement(e.body),this.w.int(n),this.w.op(T.JMP),this.w.patchLong(r,this.w.tell()),this.loops.pop()}writeExpression(e){switch(e.kind){case"int":this.w.int(e.value);break;case"float":this.w.float(e.value);break;case"string":this.w.string(this.strings.offsetOf(e.value));break;case"var":this.writeFetch(e);break;case"procRef":e.stringify?this.w.string(this.strings.offsetOf(this.procedures[e.index+1]?.name??"")):this.w.int(e.index+1);break;case"unary":this.writeExpression(e.operand),this.w.op(Ur[e.op]);break;case"binary":this.writeBinary(e);break;case"ternary":this.writeTernary(e);break;case"call":this.writeCall(e.target,e.args,e.checkArgCount??!1);break;case"libCall":for(let r of e.args)this.writeExpression(r);this.w.op(e.opcode);break}}writeBinary(e){if(e.op==="and"||e.op==="or"||e.op==="andalso"||e.op==="orelse"){this.writeLogical(e);return}let r=Br[e.op];if(r===void 0)throw new $(`operator '${e.op}' has no core opcode`);this.writeExpression(e.left),this.writeExpression(e.right),this.w.op(r)}writeLogical(e){let r=e.op==="andalso"||e.op==="orelse",n=e.op==="or"||e.op==="orelse";if(this.writeExpression(e.left),!this.shortCircuit&&!r){this.writeExpression(e.right),this.w.op(n?T.OR:T.AND);return}this.w.op(T.DUP);let s=this.w.tell()+2;this.w.int(0),this.w.op(T.SWAP),n&&this.w.op(T.NOT),this.w.op(T.IF),this.w.op(T.POP),this.writeExpression(e.right),this.w.patchLong(s,this.w.tell())}writeTernary(e){let r=this.w.tell()+2;this.w.int(0),this.writeExpression(e.cond),this.w.op(T.IF),this.writeExpression(e.whenTrue);let n=this.w.tell()+2;this.w.int(0),this.w.op(T.JMP),this.w.patchLong(r,this.w.tell()),this.writeExpression(e.whenFalse),this.w.patchLong(n,this.w.tell())}writeCall(e,r,n){let s=this.w.tell()+2;this.w.int(0),this.w.op(T.D_TO_A);for(let o of r)this.writeExpression(o);this.w.int(r.length),this.writeProcAddress(e),n&&(this.w.op(T.DUP),this.w.int(r.length),this.w.op(T.CHECK_ARG_COUNT)),this.w.op(T.CALL),this.w.patchLong(s,this.w.tell())}writeProcAddress(e){if(e.kind==="procRef"){this.w.int(e.index+1);return}if(e.kind==="string"){this.w.string(this.strings.offsetOf(e.value)),this.w.op(T.LOOKUP_STRING_PROC);return}if(e.kind==="var"){this.writeFetch(e),this.w.op(T.LOOKUP_STRING_PROC);return}throw new $(`cannot call a '${e.kind}' expression`)}};function ft(t,e={}){let r=t.undefinedProcedures?.[0];if(r)throw new $(`${r.line}:${r.column}: procedure '${r.name}' is declared but never defined`);return new Me(t,e).emit()}var X={kind:"int",value:0},Vr=32,Hr=64,we=class{arrayNesting=0;for(e,r){let n=r.init?.()??null,s=r.cond?r.cond():e.report("for loop has no condition",r.origin),o=r.update?.()??null,_=[];r.body&&_.push(r.body()),_.push({kind:"loopEnd"}),o&&_.push(o);let l={kind:"while",cond:s,body:{kind:"block",body:_}};return n?{kind:"block",body:[n,l]}:l}foreach(e,r){let n=[];if(r.declares){let{key:h,value:S}=r.declares;h&&e.declareLocal(h.text,{kind:"int",value:0},h.origin),e.declareLocal(S.text,{kind:"int",value:0},S.origin)}let s;if(r.subject.isVariable)s=r.subject.get();else{let h=e.newTemp();n.push({kind:"assign",target:h,op:"=",value:r.subject.get()}),s=h}let o=e.newTemp(),_=e.newTemp(),l=r.key?r.key():e.newTemp(),d=r.value();if(l.kind!=="var"||d.kind!=="var")return(l.kind==="var"?d:l)!==X&&e.report("foreach loop variable is not a variable",r.origin),{kind:"block",body:n};let u=(h,S)=>e.engineCall(h,S,r.origin);n.push({kind:"assign",target:_,op:"=",value:{kind:"int",value:0}},{kind:"assign",target:o,op:"=",value:u("len_array",[s])});let E={kind:"binary",op:"<",left:_,right:o};r.guard&&(E={kind:"binary",op:"and",left:E,right:r.guard()});let g=[{kind:"assign",target:l,op:"=",value:u("array_key",[s,_])},{kind:"assign",target:d,op:"=",value:u("get_array",[s,l])}];return r.body&&g.push(r.body()),g.push({kind:"loopEnd"},{kind:"assign",target:_,op:"+=",value:{kind:"int",value:1}}),n.push({kind:"while",cond:E,body:{kind:"block",body:g}}),{kind:"block",body:n}}switch(e,r){let n=[],s;if(r.subject.isVariable)s=r.subject.get();else{let _=e.newTemp();n.push({kind:"assign",target:_,op:"=",value:r.subject.get()}),s=_}r.cases.length===0&&e.report("switch statement with no cases",r.origin);let o=r.fallback?{kind:"block",body:r.fallback()}:void 0;for(let _=r.cases.length-1;_>=0;_--){let l=r.cases[_],d={kind:"if",cond:{kind:"binary",op:"==",left:s,right:l.value()},thenBranch:{kind:"block",body:l.body()}};o=o?{...d,elseBranch:o}:d}return o&&n.push(o),n.length===1?n[0]:{kind:"block",body:n}}arrayLiteral(e,r){this.arrayNesting++;try{let n=this.arrayNesting>1,s=(d,u)=>e.engineCall(d,u,r.origin),o=s("temp_array",[{kind:"int",value:r.isMap?-1:0},{kind:"int",value:n?Vr:0}]),_=d=>{o={kind:"binary",op:"+",left:o,right:d}},l=0;for(let d of r.entries){let u=d.key?d.key():{kind:"int",value:l++};_(s("arrayexpr",[u,d.value()]))}return n&&_(s("temp_array",[{kind:"int",value:0},{kind:"int",value:Hr}])),o}finally{this.arrayNesting--}}};var mt={reg_anim_func:{opcode:a.REG_ANIM_FUNC,args:2},abs:{opcode:a.TS_ABS,args:1,returns:!0},action_being_used:{opcode:a.ACTION_BEING_USED,args:0,returns:!0},activate_shader:{opcode:a.TS_ACTIVATE_SHADER,args:1},activateregion:{opcode:f.ACTIVATEREGION,args:2},active_hand:{opcode:a.TS_GET_ACTIVE_HAND,args:0,returns:!0},add_mult_objs_to_inven:{opcode:a.ADD_MULT_OBJS_TO_INVEN,args:3},add_obj_to_inven:{opcode:a.ADD_OBJ_TO_INVEN,args:2},add_timer_event:{opcode:a.ADD_TIMER_EVENT,args:3},addbutton:{opcode:f.ADDBUTTON,args:5},addbuttonflag:{opcode:f.ADDBUTTONFLAG,args:2},addbuttongfx:{opcode:f.ADDBUTTONGFX,args:4},addbuttonproc:{opcode:f.ADDBUTTONPROC,args:5,procArgs:30},addbuttonrightproc:{opcode:f.ADDBUTTONRIGHTPROC,args:3,procArgs:6},addbuttontext:{opcode:f.ADDBUTTONTEXT,args:2},addkey:{opcode:f.ADDKEY,args:2,procArgs:2},addnamedevent:{opcode:f.ADDNAMEDEVENT,args:2,procArgs:2},addnamedhandler:{opcode:f.ADDNAMEDHANDLER,args:2,procArgs:2},addregion:{opcode:f.ADDREGION,args:2},addregionflag:{opcode:f.ADDREGIONFLAG,args:2},addregionproc:{opcode:f.ADDREGIONPROC,args:5,procArgs:30},addregionrightproc:{opcode:f.ADDREGIONRIGHTPROC,args:3,procArgs:6},anim:{opcode:a.ANIM,args:3},anim_action_frame:{opcode:a.ANIM_ACTION_FRAME,args:2,returns:!0},anim_busy:{opcode:a.ANIM_BUSY,args:1,returns:!0},animate_move_obj_to_tile:{opcode:a.ANIMATE_MOVE_OBJ_TO_TILE,args:3},animate_stand_obj:{opcode:a.ANIMATE_STAND_OBJ,args:1},animate_stand_reverse_obj:{opcode:a.ANIMATE_STAND_REVERSE_OBJ,args:1},apply_heaveho_fix:{opcode:a.TS_APPLY_HEAVEHO_FIX,args:0},arctan:{opcode:a.TS_ATAN,args:2,returns:!0},array_key:{opcode:a.TS_GET_ARRAY_KEY,args:2,returns:!0},arrayexpr:{opcode:a.TS_STACK_ARRAY,args:2,returns:!0},art_anim:{opcode:a.ART_ANIM,args:1,returns:!0},art_exists:{opcode:a.TS_ART_EXISTS,args:1,returns:!0},atof:{opcode:a.TS_ATOF,args:1,returns:!0},atoi:{opcode:a.TS_ATOI,args:1,returns:!0},attack:{opcode:a.ATTACK,args:1},attack_complex:{opcode:a.ATTACK_COMPLEX,args:8},attack_setup:{opcode:a.ATTACK_SETUP,args:2},available_global_script_types:{opcode:a.TS_AVAILABLE_GLOBAL_SCRIPT_TYPES,args:0,returns:!0},block_combat:{opcode:a.TS_BLOCK_COMBAT,args:1},call_offset_r0:{opcode:a.TS_CALL_OFFSET_R0,args:1,returns:!0},call_offset_r1:{opcode:a.TS_CALL_OFFSET_R1,args:2,returns:!0},call_offset_r2:{opcode:a.TS_CALL_OFFSET_R2,args:3,returns:!0},call_offset_r3:{opcode:a.TS_CALL_OFFSET_R3,args:4,returns:!0},call_offset_r4:{opcode:a.TS_CALL_OFFSET_R4,args:5,returns:!0},call_offset_v0:{opcode:a.TS_CALL_OFFSET_V0,args:1},call_offset_v1:{opcode:a.TS_CALL_OFFSET_V1,args:2},call_offset_v2:{opcode:a.TS_CALL_OFFSET_V2,args:3},call_offset_v3:{opcode:a.TS_CALL_OFFSET_V3,args:4},call_offset_v4:{opcode:a.TS_CALL_OFFSET_V4,args:5},ceil:{opcode:a.TS_CEIL,args:1,returns:!0},charcode:{opcode:a.TS_ORD,args:1,returns:!0},checkregion:{opcode:f.CHECKREGION,args:1,returns:!0},clear_selectable_perks:{opcode:a.TS_CLEAR_SELECTABLE_PERKS,args:0},clearnamed:{opcode:f.CLEARNAMED,args:1},combat_difficulty:{opcode:a.COMBAT_DIFFICULTY,args:0,returns:!0},combat_is_initialized:{opcode:a.COMBAT_IS_INITIALIZED,args:0,returns:!0},cos:{opcode:a.TS_COS,args:1,returns:!0},create_array:{opcode:a.TS_CREATE_ARRAY,args:2,returns:!0},create_message_window:{opcode:a.TS_CREATE_MESSAGE_WINDOW,args:1},create_object_sid:{opcode:a.CREATE_OBJECT_SID,args:4,returns:!0,popsResult:!0},create_spatial:{opcode:a.TS_CREATE_SPATIAL,args:4,returns:!0,popsResult:!0},createwin:{opcode:f.CREATEWIN,args:5},critter_add_trait:{opcode:a.CRITTER_ADD_TRAIT,args:4,returns:!0,popsResult:!0},critter_attempt_placement:{opcode:a.CRITTER_ATTEMPT_PLACEMENT,args:3,returns:!0,popsResult:!0},critter_dmg:{opcode:a.CRITTER_DMG,args:3},critter_heal:{opcode:a.CRITTER_HEAL,args:2,returns:!0,popsResult:!0},critter_injure:{opcode:a.CRITTER_INJURE,args:2,returns:!0},critter_inven_obj:{opcode:a.CRITTER_INVEN_OBJ,args:2,returns:!0},critter_is_fleeing:{opcode:a.CRITTER_IS_FLEEING,args:1,returns:!0},critter_mod_skill:{opcode:a.CRITTER_MOD_SKILL,args:3,returns:!0},critter_rm_trait:{opcode:a.CRITTER_RM_TRAIT,args:4,returns:!0,popsResult:!0},critter_set_flee_state:{opcode:a.CRITTER_SET_FLEE_STATE,args:2,returns:!0},critter_state:{opcode:a.CRITTER_STATE,args:1,returns:!0},critter_stop_attacking:{opcode:a.CRITTER_STOP_ATTACKING,args:1,returns:!0},cur_map_index:{opcode:a.CUR_MAP_INDEX,args:0,returns:!0},days_since_visited:{opcode:a.DAYS_SINCE_VISITED,args:0,returns:!0},deactivate_shader:{opcode:a.TS_DEACTIVATE_SHADER,args:1},debug_msg:{opcode:a.DEBUG_MSG,args:1},deletebutton:{opcode:f.DELETEBUTTON,args:1},deletekey:{opcode:f.DELETEKEY,args:1},deleteregion:{opcode:f.DELETEREGION,args:1},deletewin:{opcode:f.DELETEWIN,args:1},destroy_mult_objs:{opcode:a.DESTROY_MULT_OBJS,args:2,returns:!0},destroy_object:{opcode:a.DESTROY_OBJECT,args:1,returns:!0},dialogue_reaction:{opcode:a.DIALOGUE_REACTION,args:1},dialogue_system_enter:{opcode:a.DIALOGUE_SYSTEM_ENTER,args:0},difficulty_level:{opcode:a.DIFFICULTY_LEVEL,args:0,returns:!0},disable_aimed_shots:{opcode:a.TS_DISABLE_AIMED_SHOTS,args:1},display:{opcode:f.DISPLAY,args:1},display_msg:{opcode:a.DISPLAY_MSG,args:1},displaygfx:{opcode:f.DISPLAYGFX,args:5},displayraw:{opcode:f.DISPLAYRAW,args:1},do_check:{opcode:a.DO_CHECK,args:3,returns:!0,popsResult:!0},drop_obj:{opcode:a.DROP_OBJ,args:1,returns:!0},dude_obj:{opcode:a.DUDE_OBJ,args:0,returns:!0},eax_available:{opcode:a.TS_EAX_AVAILABLE,args:0,returns:!0},elevation:{opcode:a.ELEVATION,args:1,returns:!0},end_dialogue:{opcode:a.END_DIALOGUE,args:0},endgame_movie:{opcode:a.ENDGAME_MOVIE,args:0},endgame_slideshow:{opcode:a.ENDGAME_SLIDESHOW,args:0},explosion:{opcode:a.EXPLOSION,args:3,returns:!0},exponent:{opcode:a.TS_EXP,args:1,returns:!0},fadein:{opcode:f.FADEIN,args:1},fadeout:{opcode:f.FADEOUT,args:1},fillrect:{opcode:f.FILLRECT,args:7},fillwin:{opcode:f.FILLWIN,args:3},fillwin3x3:{opcode:f.FILLWIN3X3,args:1},fix_array:{opcode:a.TS_FIX_ARRAY,args:1},fixed_param:{opcode:a.FIXED_PARAM,args:0,returns:!0},float_msg:{opcode:a.FLOAT_MSG,args:3},force_aimed_shots:{opcode:a.TS_FORCE_AIMED_SHOTS,args:1},force_encounter:{opcode:a.TS_FORCE_ENCOUNTER,args:1},force_encounter_with_flags:{opcode:a.TS_FORCE_ENCOUNTER_WITH_FLAGS,args:2},force_graphics_refresh:{opcode:a.TS_FORCE_GRAPHICS_REFRESH,args:1},format:{opcode:f.FORMAT,args:6},free_array:{opcode:a.TS_FREE_ARRAY,args:1},free_shader:{opcode:a.TS_FREE_SHADER,args:1},fs_copy:{opcode:a.TS_FS_COPY,args:2,returns:!0},fs_create:{opcode:a.TS_FS_CREATE,args:2,returns:!0},fs_delete:{opcode:a.TS_FS_DELETE,args:1},fs_find:{opcode:a.TS_FS_FIND,args:1,returns:!0},fs_pos:{opcode:a.TS_FS_POS,args:1,returns:!0},fs_read_byte:{opcode:a.TS_FS_READ_BYTE,args:1,returns:!0},fs_read_float:{opcode:a.TS_FS_READ_FLOAT,args:1,returns:!0},fs_read_int:{opcode:a.TS_FS_READ_INT,args:1,returns:!0},fs_read_short:{opcode:a.TS_FS_READ_SHORT,args:1,returns:!0},fs_resize:{opcode:a.TS_FS_RESIZE,args:2},fs_seek:{opcode:a.TS_FS_SEEK,args:2},fs_size:{opcode:a.TS_FS_SIZE,args:1,returns:!0},fs_write_bstring:{opcode:a.TS_FS_WRITE_BSTRING,args:2},fs_write_byte:{opcode:a.TS_FS_WRITE_BYTE,args:2},fs_write_float:{opcode:a.TS_FS_WRITE_FLOAT,args:2},fs_write_int:{opcode:a.TS_FS_WRITE_INT,args:2},fs_write_short:{opcode:a.TS_FS_WRITE_SHORT,args:2},fs_write_string:{opcode:a.TS_FS_WRITE_STRING,args:2},game_loaded:{opcode:a.TS_GAME_LOADED,args:0,returns:!0},game_ticks:{opcode:a.GAME_TICKS,args:1,returns:!0},game_time:{opcode:a.GAME_TIME,args:0,returns:!0},game_time_advance:{opcode:a.GAME_TIME_ADVANCE,args:1},game_time_hour:{opcode:a.GAME_TIME_HOUR,args:0,returns:!0},game_time_in_seconds:{opcode:a.GAME_TIME_IN_SECONDS,args:0,returns:!0},game_ui_disable:{opcode:a.GAME_UI_DISABLE,args:0},game_ui_enable:{opcode:a.GAME_UI_ENABLE,args:0},game_ui_is_disabled:{opcode:a.GAME_UI_IS_DISABLED,args:0,returns:!0},gdialog_get_barter_mod:{opcode:a.TS_GET_BARTER_MOD,args:0,returns:!0},gdialog_mod_barter:{opcode:a.GDIALOG_MOD_BARTER,args:1,returns:!0},gdialog_set_barter_mod:{opcode:a.GDIALOG_SET_BARTER_MOD,args:1},get_array:{opcode:a.TS_GET_ARRAY,args:2,returns:!0},get_attack_type:{opcode:a.TS_GET_ATTACK_TYPE,args:0,returns:!0},get_available_skill_points:{opcode:a.TS_GET_AVAILABLE_SKILL_POINTS,args:0,returns:!0},get_bodypart_hit_modifier:{opcode:a.TS_GET_BODYPART_HIT_MODIFIER,args:1,returns:!0},get_critical_table:{opcode:a.TS_GET_CRITICAL_TABLE,args:4,returns:!0},get_critter_base_stat:{opcode:a.TS_GET_CRITTER_BASE_STAT,args:2,returns:!0},get_critter_current_ap:{opcode:a.TS_GET_CRITTER_AP,args:1,returns:!0},get_critter_extra_stat:{opcode:a.TS_GET_CRITTER_EXTRA_STAT,args:2,returns:!0},get_critter_skill_points:{opcode:a.TS_GET_CRITTER_SKILL_POINTS,args:2,returns:!0},get_critter_stat:{opcode:a.GET_CRITTER_STAT,args:2,returns:!0},get_day:{opcode:a.GET_DAY,args:0,returns:!0},get_game_mode:{opcode:a.TS_GET_GAME_MODE,args:0,returns:!0},get_ini_setting:{opcode:a.TS_GET_INI_SETTING,args:1,returns:!0},get_ini_string:{opcode:a.TS_GET_INI_STRING,args:1,returns:!0},get_kill_counter:{opcode:a.TS_GET_KILL_COUNTER,args:1,returns:!0},get_last_attacker:{opcode:a.TS_GET_LAST_ATTACKER,args:1,returns:!0},get_last_target:{opcode:a.TS_GET_LAST_TARGET,args:1,returns:!0},get_light_level:{opcode:a.TS_GET_LIGHT_LEVEL,args:0,returns:!0},get_month:{opcode:a.GET_MONTH,args:0,returns:!0},get_mouse_buttons:{opcode:a.TS_GET_MOUSE_BUTTONS,args:0,returns:!0},get_mouse_x:{opcode:a.TS_GET_MOUSE_X,args:0,returns:!0},get_mouse_y:{opcode:a.TS_GET_MOUSE_Y,args:0,returns:!0},get_npc_level:{opcode:a.TS_GET_NPC_LEVEL,args:1,returns:!0},get_pc_base_stat:{opcode:a.TS_GET_PC_BASE_STAT,args:1,returns:!0},get_pc_extra_stat:{opcode:a.TS_GET_PC_EXTRA_STAT,args:1,returns:!0},get_pc_stat:{opcode:a.GET_PC_STAT,args:1,returns:!0},get_perk_available:{opcode:a.TS_GET_PERK_AVAILABLE,args:1,returns:!0},get_perk_owed:{opcode:a.TS_GET_PERK_OWED,args:0,returns:!0},get_poison:{opcode:a.GET_POISON,args:1,returns:!0},get_proto_data:{opcode:a.TS_GET_PROTO_DATA,args:2,returns:!0},get_screen_height:{opcode:a.TS_GET_SCREEN_HEIGHT,args:0,returns:!0},get_screen_width:{opcode:a.TS_GET_SCREEN_WIDTH,args:0,returns:!0},get_script:{opcode:a.TS_GET_SCRIPT,args:1,returns:!0},get_sfall_arg:{opcode:a.TS_GET_SFALL_ARG,args:0,returns:!0},get_sfall_args:{opcode:a.TS_GET_SFALL_ARGS,args:0,returns:!0},get_sfall_global_float:{opcode:a.TS_GET_SFALL_GLOBAL_FLOAT,args:1,returns:!0},get_sfall_global_int:{opcode:a.TS_GET_SFALL_GLOBAL_INT,args:1,returns:!0},get_shader_texture:{opcode:a.TS_GET_SHADER_TEXTURE,args:2,returns:!0},get_shader_version:{opcode:a.TS_GET_SHADER_VERSION,args:0,returns:!0},get_tile_fid:{opcode:a.TS_TILE_PID,args:1,returns:!0},get_unspent_ap_bonus:{opcode:a.TS_GET_UNSPENT_AP_BONUS,args:0,returns:!0},get_unspent_ap_perk_bonus:{opcode:a.TS_GET_UNSPENT_AP_EBONUS,args:0,returns:!0},get_uptime:{opcode:a.TS_GET_UPTIME,args:0,returns:!0},get_viewport_x:{opcode:a.TS_GET_VIEWPORT_X,args:0,returns:!0},get_viewport_y:{opcode:a.TS_GET_VIEWPORT_Y,args:0,returns:!0},get_weapon_ammo_count:{opcode:a.TS_GET_WEAPON_AMMO_COUNT,args:1,returns:!0},get_weapon_ammo_pid:{opcode:a.TS_GET_WEAPON_AMMO_PID,args:1,returns:!0},get_window_under_mouse:{opcode:a.TS_GET_WINDOW_UNDER_MOUSE,args:0,returns:!0},get_world_map_x_pos:{opcode:a.TS_GET_WORLD_MAP_X_POS,args:0,returns:!0},get_world_map_y_pos:{opcode:a.TS_GET_WORLD_MAP_Y_POS,args:0,returns:!0},get_year:{opcode:a.TS_GET_YEAR,args:0,returns:!0},gfade_in:{opcode:a.GFADE_IN,args:1},gfade_out:{opcode:a.GFADE_OUT,args:1},giq_option:{opcode:a.GIQ_OPTION,args:5,procArgs:8},give_exp_points:{opcode:a.GIVE_EXP_POINTS,args:1},global_var:{opcode:a.GLOBAL_VAR,args:1,returns:!0},gotoxy:{opcode:f.GOTOXY,args:2},graphics_funcs_available:{opcode:a.TS_GRAPHICS_FUNCS_AVAILABLE,args:0,returns:!0},gsay_end:{opcode:a.GSAY_END,args:0},gsay_message:{opcode:a.GSAY_MESSAGE,args:3},gsay_option:{opcode:a.GSAY_OPTION,args:4,returns:!0,procArgs:4},gsay_reply:{opcode:a.GSAY_REPLY,args:2,returns:!0},gsay_start:{opcode:a.GSAY_START,args:0},has_fake_perk:{opcode:a.TS_HAS_FAKE_PERK,args:1,returns:!0},has_fake_trait:{opcode:a.TS_HAS_FAKE_TRAIT,args:1,returns:!0},has_skill:{opcode:a.HAS_SKILL,args:2,returns:!0,popsResult:!0},has_trait:{opcode:a.HAS_TRAIT,args:3,returns:!0},hero_select_win:{opcode:a.TS_HERO_SELECT_WIN,args:1},hide_iface_tag:{opcode:a.TS_HIDE_IFACE_TAG,args:1},hide_real_perks:{opcode:a.TS_HIDE_REAL_PERKS,args:0},hidemouse:{opcode:f.HIDEMOUSE,args:0},how_much:{opcode:a.HOW_MUCH,args:1,returns:!0},in_world_map:{opcode:a.TS_IN_WORLD_MAP,args:0,returns:!0},inc_npc_level:{opcode:a.TS_INC_NPC_LEVEL,args:1},init_hook:{opcode:a.TS_INIT_HOOK,args:0,returns:!0},input_funcs_available:{opcode:a.TS_INPUT_FUNCS_AVAILABLE,args:0,returns:!0},inven_cmds:{opcode:a.INVEN_CMDS,args:3,returns:!0},inven_unwield:{opcode:a.INVEN_UNWIELD,args:0},is_critical:{opcode:a.IS_CRITICAL,args:1,returns:!0},is_iface_tag_active:{opcode:a.TS_IS_IFACE_TAG_ACTIVE,args:1,returns:!0},is_success:{opcode:a.IS_SUCCESS,args:1,returns:!0},item_caps_adjust:{opcode:a.ITEM_CAPS_ADJUST,args:2,returns:!0,popsResult:!0},item_caps_total:{opcode:a.ITEM_CAPS_TOTAL,args:1,returns:!0},jam_lock:{opcode:a.JAM_LOCK,args:1,returns:!0},key_pressed:{opcode:a.TS_KEY_PRESSED,args:1,returns:!0},kill_critter:{opcode:a.KILL_CRITTER,args:2},kill_critter_type:{opcode:a.KILL_CRITTER_TYPE,args:2},len_array:{opcode:a.TS_LEN_ARRAY,args:1,returns:!0},list_as_array:{opcode:a.TS_LIST_AS_ARRAY,args:1,returns:!0},list_begin:{opcode:a.TS_LIST_BEGIN,args:1,returns:!0},list_end:{opcode:a.TS_LIST_END,args:1},list_next:{opcode:a.TS_LIST_NEXT,args:1,returns:!0},load_array:{opcode:a.TS_LOAD_ARRAY,args:1,returns:!0},load_map:{opcode:a.LOAD_MAP,args:2},load_shader:{opcode:a.TS_LOAD_SHADER,args:1,returns:!0},loadpalettetable:{opcode:f.LOADPALETTETABLE,args:1},local_var:{opcode:a.LOCAL_VAR,args:1,returns:!0},log:{opcode:a.TS_LOG,args:1,returns:!0},make_daytime:{opcode:a.MAKE_DAYTIME},map_var:{opcode:a.MAP_VAR,args:1,returns:!0},mark_area_known:{opcode:a.MARK_AREA_KNOWN,args:3},mark_movie_played:{opcode:a.TS_MARK_MOVIE_PLAYED,args:1},message_str:{opcode:a.MESSAGE_STR,args:2,returns:!0},message_str_game:{opcode:a.TS_MESSAGE_STR_GAME,args:2,returns:!0},metarule:{opcode:a.METARULE,args:2,returns:!0,popsResult:!0},metarule2_explosions:{opcode:a.TS_EXPLOSIONS_METARULE,args:3,returns:!0,popsResult:!0},metarule3:{opcode:a.METARULE3,args:4,returns:!0,popsResult:!0},mod_kill_counter:{opcode:a.TS_MOD_KILL_COUNTER,args:2},mod_skill_points_per_level:{opcode:a.TS_MOD_SKILL_POINTS_PER_LEVEL,args:1},modified_ini:{opcode:a.TS_MODIFIED_INI,args:0,returns:!0},mouseshape:{opcode:f.MOUSESHAPE,args:3},move_obj_inven_to_obj:{opcode:a.MOVE_OBJ_INVEN_TO_OBJ,args:2,returns:!0},move_to:{opcode:a.MOVE_TO,args:3,returns:!0,popsResult:!0},movieflags:{opcode:f.MOVIEFLAGS,args:1},nb_create_char:{opcode:a.TS_NB_CREATE_CHAR,args:0,returns:!0},obj_art_fid:{opcode:a.OBJ_ART_FID,args:1,returns:!0},obj_being_used_with:{opcode:a.OBJ_BEING_USED_WITH,args:0,returns:!0},obj_blocking_line:{opcode:a.TS_MAKE_STRAIGHT_PATH,args:3,returns:!0},obj_blocking_tile:{opcode:a.TS_OBJ_BLOCKING_AT,args:3,returns:!0},obj_can_hear_obj:{opcode:a.OBJ_CAN_HEAR_OBJ,args:2,returns:!0},obj_can_see_obj:{opcode:a.OBJ_CAN_SEE_OBJ,args:2,returns:!0},obj_carrying_pid_obj:{opcode:a.OBJ_CARRYING_PID_OBJ,args:2,returns:!0},obj_close:{opcode:a.OBJ_CLOSE,args:1},obj_is_carrying_obj:{opcode:a.TS_OBJ_IS_CARRYING_OBJ,args:2,returns:!0},obj_is_carrying_obj_pid:{opcode:a.OBJ_IS_CARRYING_OBJ_PID,args:2,returns:!0},obj_is_locked:{opcode:a.OBJ_IS_LOCKED,args:1,returns:!0},obj_is_open:{opcode:a.OBJ_IS_OPEN,args:1,returns:!0},obj_item_subtype:{opcode:a.OBJ_ITEM_SUBTYPE,args:1,returns:!0},obj_lock:{opcode:a.OBJ_LOCK,args:1},obj_name:{opcode:a.OBJ_NAME,args:1,returns:!0},obj_on_screen:{opcode:a.OBJ_ON_SCREEN,args:1,returns:!0},obj_open:{opcode:a.OBJ_OPEN,args:1},obj_pid:{opcode:a.OBJ_PID,args:1,returns:!0},obj_set_light_level:{opcode:a.OBJ_SET_LIGHT_LEVEL,args:3},obj_type:{opcode:a.OBJ_TYPE,args:1,returns:!0},obj_unlock:{opcode:a.OBJ_UNLOCK,args:1},override_map_start:{opcode:a.OVERRIDE_MAP_START,args:4},party_add:{opcode:a.PARTY_ADD,args:1},party_member_list:{opcode:a.TS_GET_PARTY_MEMBERS,args:1,returns:!0},party_member_obj:{opcode:a.PARTY_MEMBER_OBJ,args:1,returns:!0},party_remove:{opcode:a.PARTY_REMOVE,args:1},path_find_to:{opcode:a.TS_PATH_FIND,args:3,returns:!0},perk_add_mode:{opcode:a.TS_PERK_ADD_MODE,args:1},pickup_obj:{opcode:a.PICKUP_OBJ,args:1},play_gmovie:{opcode:a.PLAY_GMOVIE,args:1},play_sfall_sound:{opcode:a.TS_PLAY_SFALL_SOUND,args:2,returns:!0},play_sfx:{opcode:a.PLAY_SFX,args:1,returns:!0},playmovie:{opcode:f.PLAYMOVIE,args:1},playmoviealpha:{opcode:f.PLAYMOVIEALPHA},playmoviealpharect:{opcode:f.PLAYMOVIEALPHARECT},playmovierect:{opcode:f.PLAYMOVIERECT,args:5},poison:{opcode:a.POISON,args:2},print:{opcode:f.PRINT,args:1},printrect:{opcode:f.PRINTRECT,args:3},proto_data:{opcode:a.PROTO_DATA,args:2,returns:!0},radiation_dec:{opcode:a.RADIATION_DEC,args:2},radiation_inc:{opcode:a.RADIATION_INC,args:2},random:{opcode:a.RANDOM,args:2,returns:!0},reaction_influence:{opcode:a.REACTION_INFLUENCE,args:3,returns:!0},read_byte:{opcode:a.TS_READ_BYTE,args:1,returns:!0},read_int:{opcode:a.TS_READ_INT,args:1,returns:!0},read_short:{opcode:a.TS_READ_SHORT,args:1,returns:!0},read_string:{opcode:a.TS_READ_STRING,args:1,returns:!0},refresh_pc_art:{opcode:a.TS_REFRESH_PC_ART,args:0},refreshmouse:{opcode:f.REFRESHMOUSE,args:1,procArgs:1},reg_anim_animate:{opcode:a.REG_ANIM_ANIMATE,args:3},reg_anim_animate_and_hide:{opcode:a.TS_REG_ANIM_ANIMATE_AND_HIDE,args:3},reg_anim_animate_forever:{opcode:a.REG_ANIM_ANIMATE_FOREVER,args:2},reg_anim_animate_reverse:{opcode:a.REG_ANIM_ANIMATE_REVERSE,args:3},reg_anim_callback:{opcode:a.TS_REG_ANIM_CALLBACK,args:1,procArgs:1},reg_anim_change_fid:{opcode:a.TS_REG_ANIM_CHANGE_FID,args:3},reg_anim_combat_check:{opcode:a.TS_REG_ANIM_COMBAT_CHECK,args:1},reg_anim_destroy:{opcode:a.TS_REG_ANIM_DESTROY,args:1},reg_anim_light:{opcode:a.TS_REG_ANIM_LIGHT,args:3},reg_anim_obj_move_to_obj:{opcode:a.REG_ANIM_OBJ_MOVE_TO_OBJ,args:3},reg_anim_obj_move_to_tile:{opcode:a.REG_ANIM_OBJ_MOVE_TO_TILE,args:3},reg_anim_obj_run_to_obj:{opcode:a.REG_ANIM_OBJ_RUN_TO_OBJ,args:3},reg_anim_obj_run_to_tile:{opcode:a.REG_ANIM_OBJ_RUN_TO_TILE,args:3},reg_anim_play_sfx:{opcode:a.REG_ANIM_PLAY_SFX,args:3},reg_anim_take_out:{opcode:a.TS_REG_ANIM_TAKE_OUT,args:3},reg_anim_turn_towards:{opcode:a.TS_REG_ANIM_TURN_TOWARDS,args:3},register_hook:{opcode:a.TS_REGISTER_HOOK,args:1},register_hook_proc:{opcode:a.TS_REGISTER_HOOK_PROC,args:2,procArgs:2},register_hook_proc_spec:{opcode:a.TS_REGISTER_HOOK_PROC2,args:2,procArgs:2},remove_attacker_knockback:{opcode:a.TS_REMOVE_ATTACKER_KNOCKBACK,args:1},remove_script:{opcode:a.TS_REMOVE_SCRIPT,args:1},remove_target_knockback:{opcode:a.TS_REMOVE_TARGET_KNOCKBACK,args:1},remove_trait:{opcode:a.TS_REMOVE_TRAIT,args:1},remove_weapon_knockback:{opcode:a.TS_REMOVE_WEAPON_KNOCKBACK,args:1},reset_critical_table:{opcode:a.TS_RESET_CRITICAL_TABLE,args:4},resize_array:{opcode:a.TS_RESIZE_ARRAY,args:2},resizewin:{opcode:f.RESIZEWIN,args:5},resume_game:{opcode:a.TS_RESUME_GAME,args:0},rm_mult_objs_from_inven:{opcode:a.RM_MULT_OBJS_FROM_INVEN,args:3,returns:!0},rm_obj_from_inven:{opcode:a.RM_OBJ_FROM_INVEN,args:2},rm_timer_event:{opcode:a.RM_TIMER_EVENT,args:1},roll_dice:{opcode:a.ROLL_DICE,args:2,returns:!0,popsResult:!0},roll_vs_skill:{opcode:a.ROLL_VS_SKILL,args:3,returns:!0,popsResult:!0},rotation_to_tile:{opcode:a.ROTATION_TO_TILE,args:2,returns:!0},round:{opcode:a.TS_ROUND,args:1,returns:!0},running_burning_guy:{opcode:a.RUNNING_BURNING_GUY,args:0,returns:!0},save_array:{opcode:a.TS_SAVE_ARRAY,args:2},sayborder:{opcode:f.SAYBORDER,args:2},sayend:{opcode:f.SAYEND,args:0},saygetlastpos:{opcode:f.SAYGETLASTPOS,args:0,returns:!0},saygotoreply:{opcode:f.SAYGOTOREPLY,args:1},saymessage:{opcode:f.SAYMESSAGE,args:2},saymessagetimeout:{opcode:f.SAYMESSAGETIMEOUT,args:1},sayoption:{opcode:f.SAYOPTION,args:2,procArgs:2},sayoptioncolor:{opcode:f.SAYOPTIONCOLOR,args:3},sayoptionflags:{opcode:f.SAYOPTIONFLAGS,args:1},sayoptionwindow:{opcode:f.SAYOPTIONWINDOW,args:5},sayquit:{opcode:f.SAYQUIT,args:0},sayreply:{opcode:f.SAYREPLY,args:2},sayreplycolor:{opcode:f.SAYREPLYCOLOR,args:3},sayreplyflags:{opcode:f.SAYREPLYFLAGS,args:1},sayreplytitle:{opcode:f.SAYREPLYTITLE,args:1},sayreplywindow:{opcode:f.SAYREPLYWINDOW,args:5},sayrestart:{opcode:f.SAYRESTART,args:0},sayscrolldown:{opcode:f.SAYSCROLLDOWN,args:6},sayscrollup:{opcode:f.SAYSCROLLUP,args:6},saysetspacing:{opcode:f.SAYSETSPACING,args:1},saystart:{opcode:f.SAYSTART,args:0},saystartpos:{opcode:f.SAYSTARTPOS,args:1},scalewin:{opcode:f.SCALEWIN,args:5},scan_array:{opcode:a.TS_SCAN_ARRAY,args:2,returns:!0},scr_return:{opcode:a.SCR_RETURN,args:1},script_action:{opcode:a.SCRIPT_ACTION,args:0,returns:!0},script_overrides:{opcode:a.SCRIPT_OVERRIDES,args:0},selectfilelist:{opcode:f.SELECTFILELIST,args:2},selectwin:{opcode:f.SELECTWIN,args:1},self_obj:{opcode:a.SELF_OBJ,args:0,returns:!0},set_array:{opcode:a.TS_SET_ARRAY,args:3},set_attacker_knockback:{opcode:a.TS_SET_ATTACKER_KNOCKBACK,args:3},set_available_skill_points:{opcode:a.TS_SET_AVAILABLE_SKILL_POINTS,args:1},set_base_hit_chance_mod:{opcode:a.TS_SET_BASE_HIT_CHANCE_MOD,args:2},set_base_pickpocket_mod:{opcode:a.TS_SET_BASE_PICKPOCKET_MOD,args:2},set_base_skill_mod:{opcode:a.TS_SET_BASE_SKILL_MOD,args:1},set_bodypart_hit_modifier:{opcode:a.TS_SET_BODYPART_HIT_MODIFIER,args:2},set_car_current_town:{opcode:a.TS_SET_CAR_CURRENT_TOWN,args:1},set_critical_table:{opcode:a.TS_SET_CRITICAL_TABLE,args:5},set_critter_base_stat:{opcode:a.TS_SET_CRITTER_BASE_STAT,args:3},set_critter_burst_disable:{opcode:a.TS_SET_CRITTER_BURST_DISABLE,args:2},set_critter_current_ap:{opcode:a.TS_SET_CRITTER_AP,args:2},set_critter_extra_stat:{opcode:a.TS_SET_CRITTER_EXTRA_STAT,args:3},set_critter_hit_chance_mod:{opcode:a.TS_SET_CRITTER_HIT_CHANCE_MOD,args:3},set_critter_pickpocket_mod:{opcode:a.TS_SET_CRITTER_PICKPOCKET_MOD,args:3},set_critter_skill_mod:{opcode:a.TS_SET_CRITTER_SKILL_MOD,args:2},set_critter_skill_points:{opcode:a.TS_SET_CRITTER_SKILL_POINTS,args:3},set_critter_stat:{opcode:a.SET_CRITTER_STAT,args:3,returns:!0,popsResult:!0},set_df_model:{opcode:a.TS_SET_DF_MODEL,args:1},set_dm_model:{opcode:a.TS_SET_DM_MODEL,args:1},set_eax_environment:{opcode:a.TS_SET_EAX_ENVIRONMENT,args:1},set_exit_grids:{opcode:a.SET_EXIT_GRIDS,args:5},set_fake_perk:{opcode:a.TS_SET_FAKE_PERK,args:4},set_fake_trait:{opcode:a.TS_SET_FAKE_TRAIT,args:4},set_global_script_repeat:{opcode:a.TS_SET_GLOBAL_SCRIPT_REPEAT,args:1},set_global_script_type:{opcode:a.TS_SET_GLOBAL_SCRIPT_TYPE,args:1},set_global_var:{opcode:a.SET_GLOBAL_VAR,args:2},set_hero_race:{opcode:a.TS_SET_HERO_RACE,args:1},set_hero_style:{opcode:a.TS_SET_HERO_STYLE,args:1},set_hit_chance_max:{opcode:a.TS_SET_HIT_CHANCE_MAX,args:1},set_hp_per_level_mod:{opcode:a.TS_SET_HP_LEVEL_MOD,args:1},set_inven_ap_cost:{opcode:a.TS_SET_INVEN_AP_COST,args:1},set_light_level:{opcode:a.SET_LIGHT_LEVEL,args:1},set_local_var:{opcode:a.SET_LOCAL_VAR,args:2},set_map_music:{opcode:a.SET_MAP_MUSIC,args:2},set_map_start:{opcode:a.SET_MAP_START,args:4},set_map_time_multi:{opcode:a.TS_SET_MAP_TIME_MULTI,args:1},set_map_var:{opcode:a.SET_MAP_VAR,args:2},set_movie_path:{opcode:a.TS_SET_MOVIE_PATH,args:2},set_npc_stat_max:{opcode:a.TS_SET_NPC_STAT_MAX,args:2},set_npc_stat_min:{opcode:a.TS_SET_NPC_STAT_MIN,args:2},set_obj_visibility:{opcode:a.SET_OBJ_VISIBILITY,args:2},set_palette:{opcode:a.TS_SET_PALETTE,args:1},set_pc_base_stat:{opcode:a.TS_SET_PC_BASE_STAT,args:2},set_pc_extra_stat:{opcode:a.TS_SET_PC_EXTRA_STAT,args:2},set_pc_stat_max:{opcode:a.TS_SET_PC_STAT_MAX,args:2},set_pc_stat_min:{opcode:a.TS_SET_PC_STAT_MIN,args:2},set_perk_agl:{opcode:a.TS_SET_PERK_AGL,args:2},set_perk_chr:{opcode:a.TS_SET_PERK_CHR,args:2},set_perk_desc:{opcode:a.TS_SET_PERK_DESC,args:2},set_perk_end:{opcode:a.TS_SET_PERK_END,args:2},set_perk_freq:{opcode:a.TS_SET_PERK_FREQ,args:1},set_perk_image:{opcode:a.TS_SET_PERK_IMAGE,args:2},set_perk_int:{opcode:a.TS_SET_PERK_INT,args:2},set_perk_lck:{opcode:a.TS_SET_PERK_LCK,args:2},set_perk_level:{opcode:a.TS_SET_PERK_LEVEL,args:2},set_perk_level_mod:{opcode:a.TS_SET_PERK_LEVEL_MOD,args:1},set_perk_name:{opcode:a.TS_SET_PERK_NAME,args:2},set_perk_owed:{opcode:a.TS_SET_PERK_OWED,args:1},set_perk_per:{opcode:a.TS_SET_PERK_PER,args:2},set_perk_ranks:{opcode:a.TS_SET_PERK_RANKS,args:2},set_perk_skill1:{opcode:a.TS_SET_PERK_SKILL1,args:2},set_perk_skill2:{opcode:a.TS_SET_PERK_SKILL2,args:2},set_perk_skill2_mag:{opcode:a.TS_SET_PERK_SKILL2_MAG,args:2},set_perk_stat:{opcode:a.TS_SET_PERK_STAT,args:2},set_perk_stat_mag:{opcode:a.TS_SET_PERK_STAT_MAG,args:2},set_perk_str:{opcode:a.TS_SET_PERK_STR,args:2},set_perk_type:{opcode:a.TS_SET_PERK_TYPE,args:2},set_perkbox_title:{opcode:a.TS_SET_PERKBOX_TITLE,args:1},set_pickpocket_max:{opcode:a.TS_SET_PICKPOCKET_MAX,args:1},set_pipboy_available:{opcode:a.TS_SET_PIPBOY_AVAILABLE,args:1},set_proto_data:{opcode:a.TS_SET_PROTO_DATA,args:3},set_pyromaniac_mod:{opcode:a.TS_SET_PYROMANIAC_MOD,args:1},set_script:{opcode:a.TS_SET_SCRIPT,args:2},set_selectable_perk:{opcode:a.TS_SET_SELECTABLE_PERK,args:4},set_self:{opcode:a.TS_SET_SELF,args:1},set_sfall_arg:{opcode:a.TS_SET_SFALL_ARG,args:2},set_sfall_global:{opcode:a.TS_SET_SFALL_GLOBAL,args:2},set_sfall_return:{opcode:a.TS_SET_SFALL_RETURN,args:1},set_shader_float:{opcode:a.TS_SET_SHADER_FLOAT,args:3},set_shader_int:{opcode:a.TS_SET_SHADER_INT,args:3},set_shader_mode:{opcode:a.TS_SET_SHADER_MODE,args:2},set_shader_texture:{opcode:a.TS_SET_SHADER_TEXTURE,args:3},set_shader_vector:{opcode:a.TS_SET_SHADER_VECTOR,args:6},set_skill_max:{opcode:a.TS_SET_SKILL_MAX,args:1},set_stat_max:{opcode:a.TS_SET_STAT_MAX,args:2},set_stat_min:{opcode:a.TS_SET_STAT_MIN,args:2},set_swiftlearner_mod:{opcode:a.TS_SET_SWIFTLEARNER_MOD,args:1},set_target_knockback:{opcode:a.TS_SET_TARGET_KNOCKBACK,args:3},set_unspent_ap_bonus:{opcode:a.TS_SET_UNSPENT_AP_BONUS,args:1},set_unspent_ap_perk_bonus:{opcode:a.TS_SET_UNSPENT_AP_EBONUS,args:1},set_viewport_x:{opcode:a.TS_SET_VIEWPORT_X,args:1},set_viewport_y:{opcode:a.TS_SET_VIEWPORT_Y,args:1},set_weapon_ammo_count:{opcode:a.TS_SET_WEAPON_AMMO_COUNT,args:2},set_weapon_ammo_pid:{opcode:a.TS_SET_WEAPON_AMMO_PID,args:2},set_weapon_knockback:{opcode:a.TS_SET_WEAPON_KNOCKBACK,args:3},set_world_map_pos:{opcode:a.TS_SET_WORLD_MAP_POS,args:2},set_xp_mod:{opcode:a.TS_SET_XP_MOD,args:1},setfont:{opcode:f.SETFONT,args:1},setglobalmousefunc:{opcode:f.SETGLOBALMOUSEFUNC,procArgs:15},sethighlightcolor:{opcode:f.SETHIGHLIGHTCOLOR,args:3},setoneoptpause:{opcode:f.SETONEOPTPAUSE,args:1},settextcolor:{opcode:f.SETTEXTCOLOR,args:3},settextflags:{opcode:f.SETTEXTFLAGS,args:1},sfall_func0:{opcode:a.TS_SFALL_METARULE0,args:1,returns:!0,popsResult:!0},sfall_func1:{opcode:a.TS_SFALL_METARULE1,args:2,returns:!0,popsResult:!0},sfall_func2:{opcode:a.TS_SFALL_METARULE2,args:3,returns:!0,popsResult:!0},sfall_func3:{opcode:a.TS_SFALL_METARULE3,args:4,returns:!0,popsResult:!0},sfall_func4:{opcode:a.TS_SFALL_METARULE4,args:5,returns:!0,popsResult:!0},sfall_func5:{opcode:a.TS_SFALL_METARULE5,args:6,returns:!0,popsResult:!0},sfall_func6:{opcode:a.TS_SFALL_METARULE6,args:7,returns:!0,popsResult:!0},sfall_func7:{opcode:a.TS_SFALL_METARULE7,args:8,returns:!0,popsResult:!0},sfall_func8:{opcode:a.TS_SFALL_METARULE8,args:9,returns:!0,popsResult:!0},sfall_ver_build:{opcode:a.TS_SFALL_VER_BUILD,args:0,returns:!0},sfall_ver_major:{opcode:a.TS_SFALL_VER_MAJOR,args:0,returns:!0},sfall_ver_minor:{opcode:a.TS_SFALL_VER_MINOR,args:0,returns:!0},sfx_build_ambient_name:{opcode:a.SFX_BUILD_AMBIENT_NAME,args:2,returns:!0},sfx_build_char_name:{opcode:a.SFX_BUILD_CHAR_NAME,args:3,returns:!0},sfx_build_interface_name:{opcode:a.SFX_BUILD_INTERFACE_NAME,args:2,returns:!0},sfx_build_item_name:{opcode:a.SFX_BUILD_ITEM_NAME,args:3,returns:!0},sfx_build_open_name:{opcode:a.SFX_BUILD_OPEN_NAME,args:2,returns:!0},sfx_build_scenery_name:{opcode:a.SFX_BUILD_SCENERY_NAME,args:3,returns:!0},sfx_build_weapon_name:{opcode:a.SFX_BUILD_WEAPON_NAME,args:4,returns:!0},show_iface_tag:{opcode:a.TS_SHOW_IFACE_TAG,args:1},show_real_perks:{opcode:a.TS_SHOW_REAL_PERKS,args:0},showmouse:{opcode:f.SHOWMOUSE,args:0},showwin:{opcode:f.SHOWWIN,args:0},signalnamed:{opcode:f.SIGNALNAMED,args:1},sin:{opcode:a.TS_SIN,args:1,returns:!0},skill_contest:{opcode:a.SKILL_CONTEST,args:1,returns:!0,popsResult:!0},sneak_success:{opcode:a.TS_SNEAK_SUCCESS,args:0,returns:!0},sounddelete:{opcode:f.SOUNDDELETE,args:1},soundpause:{opcode:f.SOUNDPAUSE,args:1},soundplay:{opcode:f.SOUNDPLAY,args:2,returns:!0},soundresume:{opcode:f.SOUNDRESUME,args:1},soundrewind:{opcode:f.SOUNDREWIND,args:1},soundstop:{opcode:f.SOUNDSTOP,args:1},source_obj:{opcode:a.SOURCE_OBJ,args:0,returns:!0},sprintf:{opcode:a.TS_SPRINTF,args:2,returns:!0},sqrt:{opcode:a.TS_SQRT,args:1,returns:!0},start_gdialog:{opcode:a.START_GDIALOG,args:5},stop_game:{opcode:a.TS_STOP_GAME,args:0},stop_sfall_sound:{opcode:a.TS_STOP_SFALL_SOUND,args:1},stopmovie:{opcode:f.STOPMOVIE,args:0},string_split:{opcode:a.TS_STRING_SPLIT,args:2,returns:!0},strlen:{opcode:a.TS_STRLEN,args:1,returns:!0},substr:{opcode:a.TS_SUBSTR,args:3,returns:!0},tan:{opcode:a.TS_TAN,args:1,returns:!0},tap_key:{opcode:a.TS_TAP_KEY,args:1},target_obj:{opcode:a.TARGET_OBJ,args:0,returns:!0},temp_array:{opcode:a.TS_TEMP_ARRAY,args:2,returns:!0},terminate_combat:{opcode:a.TERMINATE_COMBAT,args:0},tile_contains_obj_pid:{opcode:a.TILE_CONTAINS_OBJ_PID,args:3,returns:!0},tile_contains_pid_obj:{opcode:a.TILE_CONTAINS_PID_OBJ,args:3,returns:!0},tile_distance:{opcode:a.TILE_DISTANCE,args:2,returns:!0},tile_distance_objs:{opcode:a.TILE_DISTANCE_OBJS,args:2,returns:!0},tile_get_objs:{opcode:a.TS_TILE_GET_OBJECTS,args:2,returns:!0},tile_in_tile_rect:{opcode:a.TILE_IN_TILE_RECT,args:5,returns:!0},tile_is_visible:{opcode:a.TILE_IS_VISIBLE,args:1,returns:!0},tile_light:{opcode:a.TS_TILE_LIGHT,args:2,returns:!0},tile_num:{opcode:a.TILE_NUM,args:1,returns:!0},tile_num_in_direction:{opcode:a.TILE_NUM_IN_DIRECTION,args:3,returns:!0},tile_under_cursor:{opcode:a.TS_TILE_UNDER_CURSOR,args:0,returns:!0},toggle_active_hand:{opcode:a.TS_TOGGLE_ACTIVE_HAND,args:0},tokenize:{opcode:f.TOKENIZE,args:3,returns:!0},typeof:{opcode:a.TS_TYPEOF,args:1,returns:!0},use_obj:{opcode:a.USE_OBJ,args:1},use_obj_on_obj:{opcode:a.USE_OBJ_ON_OBJ,args:2,returns:!0},using_skill:{opcode:a.USING_SKILL,args:2,returns:!0,popsResult:!0},wield_obj_critter:{opcode:a.WIELD_OBJ_CRITTER,args:2},wm_area_set_pos:{opcode:a.WM_AREA_SET_POS,args:3},world_map:{opcode:a.WORLD_MAP,args:0},write_string:{opcode:a.TS_WRITE_STRING,args:2},write_byte:{opcode:a.TS_WRITE_BYTE,args:2},write_int:{opcode:a.TS_WRITE_INT,args:2},write_short:{opcode:a.TS_WRITE_SHORT,args:2}},Wr={animate_jump:"ANIMATE_JUMP",barter_asking:"BARTER_ASKING",barter_offer:"BARTER_OFFER",reaction:"REACTION",town_map:"TOWN_MAP",turn_off_objs_in_area:"TURN_OFF_OBJS_IN_AREA",turn_on_objs_in_area:"TURN_ON_OBJS_IN_AREA"};function q(t,e=2){if(e===1){let r=Wr[t],n=r===void 0?void 0:Et[r];if(n!==void 0)return{opcode:n}}return mt[t]}var Ls=new Map(Object.entries(mt).map(([t,e])=>[e.opcode,{name:t,...e}]));var R=class extends Error{line;column;detail;all;constructor(e,r,n=[]){let s="startPosition"in r?r.startPosition.row+1:r.line,o="startPosition"in r?r.startPosition.column+1:r.column;super(`${s}:${o}: ${e}`),this.name="LowerError",this.line=s,this.column=o,this.detail=e,this.all=n.length>0?n:[this]}},Kr=100;function oe(t){return{line:t.startPosition.row+1,column:t.startPosition.column+1}}var Yr={kind:"block",body:[]},St=new Set(["+","-","*","/","%","^","div","==","!=","<=",">=","<",">","and","or","andalso","orelse","bwand","bwor","bwxor"]),At=new Set(["=",":=","+=","-=","*=","/="]),Xr=new Set(["number","string","char","boolean"]),wt=new Set(["==","!=","<",">","<=",">="]);function Jr(t){return t?.type!=="param_default"?t:t.namedChildren.find(e=>e&&e.type!=="comment")??null}function bt(t){if(t.type==="paren_expr"){let n=t.namedChildren.find(s=>s&&s.type!=="comment");return n?bt(n):!1}if(t.type==="boolean")return t.text.toLowerCase()==="false";if(t.type!=="number")return!1;let e=t.text,r=e.startsWith("0x")||e.startsWith("0X")?16:10;return(e.includes(".")?Number.parseFloat(e):Number.parseInt(e,r))===0}var jr={spawn:T.SPAWN,callstart:T.CALLSTART,exec:T.EXEC,fork:T.FORK,wait:T.WAIT,cancel:T.CANCEL,cancelall:T.CANCELALL,exit:T.EXIT,detach:T.DETACH,startcritical:T.STARTCRITICAL,endcritical:T.ENDCRITICAL},$r=new Set(["len_array","atoi","atof","get_tile_fid","modified_ini"].map(t=>q(t)?.opcode).filter(t=>t!==void 0));function ke(t,e){return{kind:"libCall",opcode:t,args:e,...$r.has(t)?{pure:!0}:{}}}var xe=class{game;procedures=new Map;globals=new Map;externals=new Map;declarations=[];tempCounter=0;paramDefaults=new Map;declaredAt=new Map;inlineProcedures=new Set;pureProcedures=new Set;undefinedProcedures=[];loopDepth=0;currentTarget=null;onWarning;constructor(e){this.game=e.game??2,this.onWarning=e.onWarning}warn(e,r){if(!this.onWarning)return;let n="startPosition"in r?{line:r.startPosition.row+1,column:r.startPosition.column+1}:r;this.onWarning({...n,message:e})}diagnostics=[];reportedNames=new Set;report(e,r){let n=new R(e,r);return this.diagnostics.length<Kr&&!this.diagnostics.some(s=>s.message===n.message)&&this.diagnostics.push(n),X}lower(e){try{this.collect(e),this.lowerBodies(e)}catch(n){if(!(n instanceof R)||this.diagnostics.length===0)throw n;this.diagnostics.push(n)}let r=this.diagnostics[0];if(r)throw new R(r.detail,{line:r.line,column:r.column},this.diagnostics);return this.onWarning&&!this.procedures.has("start")&&this.warn("no 'start' procedure: the engine has no entry point into this script",{line:1,column:1}),{declarations:this.declarations,stringLiterals:Qr(e,this.onWarning?(n,s)=>this.warn(n,s):void 0),...qr(e)?{shortCircuit:!0}:{},...this.undefinedProcedures.length>0?{undefinedProcedures:this.undefinedProcedures}:{}}}collect(e){for(let r of e.namedChildren)if(r)switch(r.type){case"procedure_forward":case"procedure":{let n=this.nameOf(r);if(this.checkModifiers(r),this.procedures.has(n.toLowerCase())&&this.checkRedeclaration(r,n),this.recordParameters(r),this.procedures.has(n.toLowerCase()))break;this.declaredAt.set(this.procedures.size,r),this.procedures.set(n.toLowerCase(),this.procedures.size);let s=r.childForFieldName("modifier")?.text.toLowerCase();s==="inline"&&this.inlineProcedures.add(this.procedures.size-1),s==="pure"&&this.pureProcedures.add(this.procedures.size-1),this.declarations.push({kind:"procedure",procedure:{name:n,args:[],locals:[],body:[],...s==="pure"?{pure:!0}:{},...s==="inline"?{inline:!0}:{},...r.childForFieldName("critical")?{critical:!0}:{}}});break}case"variable_decl":this.collectVariables(r,r.text.trimStart().toLowerCase().startsWith("import"));break;case"export_decl":this.collectExport(r);break}}checkRedeclaration(e,r){let n=e.childForFieldName("params");if(!n)return;let s=n.namedChildren.filter(l=>!!l&&l.type==="param"),o=this.paramDefaults.get(this.procedures.get(r.toLowerCase())??-1);o&&s.length!==o.length&&this.report(`'${r}' was declared with ${o.length} parameters`,n);let _=s.find(l=>l.childForFieldName("default"));_&&this.report(`'${r}' is already declared; its defaults belong to that declaration`,_)}checkModifiers(e){let r=e.childForFieldName("modifier")?.text.toLowerCase(),n=e.childForFieldName("timed")??e.childForFieldName("condition");n&&(r==="pure"||r==="inline")&&this.report(`a timed or conditional procedure cannot be '${r}'`,n),r==="inline"&&e.type==="procedure_forward"&&this.report("an inline procedure cannot be forward-declared",e)}recordParameters(e){let r=e.childForFieldName("params");if(!r)return;let n=this.nameOf(e).toLowerCase(),s=this.procedures.get(n)??this.procedures.size,o=this.paramDefaults.get(s)??[],_=[],l=0,d=!1;for(let u of r.namedChildren){if(!u||u.type!=="param")continue;let E=u.childForFieldName("default");E?d=!0:d&&!o[l]&&this.report("a parameter with a default cannot precede one without",u),_.push(E?this.constantOf(E):o[l]??null),l++}this.paramDefaults.set(s,_)}collectVariables(e,r){for(let n of e.namedChildren){if(!n||n.type!=="var_init")continue;let s=this.nameOf(n);if(r)this.externals.set(s.toLowerCase(),s),this.declarations.push({kind:"external",variable:this.variableOf(n)});else{if(this.globals.has(s.toLowerCase())){this.warn(`'${s}' is already declared; this declaration is ignored`,n);continue}this.globals.set(s.toLowerCase(),this.globals.size),this.declarations.push({kind:"global",variable:this.variableOf(n)})}}}collectExport(e){let r=this.nameOf(e),n=e.childForFieldName("value");this.externals.set(r.toLowerCase(),r),this.declarations.push({kind:"external",variable:{name:r,initial:n?this.constantOf(n):{kind:"int",value:0},exported:!0}})}variableOf(e){let r=this.nameOf(e),n=e.childForFieldName("size");n&&this.report("array declarations are only allowed on a local variable",n);let s=e.childForFieldName("value");return{name:r,initial:s?this.constantOf(s):{kind:"int",value:0}}}constantOf(e){switch(e.type){case"param_default":case"paren_expr":case"param_default_group":{let r=e.namedChildren.find(n=>n&&n.type!=="comment");if(r)return this.constantOf(r);break}case"number":{let r=e.text;if(r.includes("."))return{kind:"float",value:Number.parseFloat(r)};let n=r.startsWith("0x")||r.startsWith("0X")?16:10;return{kind:"int",value:Number.parseInt(r,n)}}case"string":return{kind:"string",value:Rt(e.text)};case"char":{let r=tn(e);return r===null?(this.report(`unknown escape '${e.text.slice(1,-1)}' in a character constant`,e),{kind:"int",value:0}):{kind:"int",value:r}}case"boolean":return{kind:"int",value:e.text.toLowerCase()==="true"?1:0};case"param_default_unary":case"unary_expr":{let r=Jr(e.childForFieldName("expr")),n=e.childForFieldName("op")?.text.toLowerCase();if(r&&!Xr.has(r.type))break;if(r&&(n==="-"||n==="not"||n==="bwnot")){let s=this.constantOf(r);if(s.kind==="int"||s.kind==="float"){let o=Math.trunc(s.value);return n==="not"?{kind:"int",value:o===0?1:0}:n==="bwnot"?{kind:"int",value:~o}:s.kind==="int"?{kind:"int",value:-s.value}:{kind:"float",value:-s.value}}}break}}return this.report(`initial value must be a literal, got ${e.type}`,e),{kind:"int",value:0}}literalOf(e){switch(e.type){case"number":case"string":case"char":case"boolean":return this.constantOf(e);case"paren_expr":{let r=e.namedChildren.find(n=>n&&n.type!=="comment");return r?this.literalOf(r):null}}return null}nameOf(e){let r=e.childForFieldName("name");if(!r)throw new R(`${e.type} has no name`,e);return r.text}lowerBodies(e){let r=this.declarations.filter(s=>s.kind==="procedure"),n=new Set;for(let s of e.namedChildren){if(!s||s.type!=="procedure")continue;let o=this.procedures.get(this.nameOf(s).toLowerCase()),_=o===void 0?void 0:r[o];_?.kind==="procedure"&&(o!==void 0&&n.add(o),this.lowerProcedure(s,_.procedure))}for(let[s,o]of this.declaredAt){if(n.has(s))continue;let _=r[s];this.undefinedProcedures.push({index:s,name:_?.kind==="procedure"?_.procedure.name:"?",line:o.startPosition.row+1,column:o.startPosition.column+1})}}lowerProcedure(e,r){let n={slots:new Map},s=e.childForFieldName("params");if(s)for(let u of s.namedChildren){if(!u||u.type!=="param")continue;let E=this.nameOf(u);n.slots.set(E.toLowerCase(),n.slots.size),r.args.push(E)}let o=e.childrenForFieldName("body").filter(u=>u!==null);this.currentTarget=r,r.body=this.lowerEach(o,n),this.currentTarget=null;let _=e.childForFieldName("modifier")?.text.toLowerCase();_==="pure"&&(r.pure=!0),_==="inline"&&(r.inline=!0),e.childForFieldName("critical")&&(r.critical=!0);let l=e.childForFieldName("timed");if(l){let u=this.lowerExpression(l,n);u.kind==="int"?r.timed=u.value:this.report("a timed procedure's delay must be an integer",l)}let d=e.childForFieldName("condition");d&&(r.conditional=this.lowerExpression(d,n))}declareLocal(e,r,n,s){let o=this.currentTarget;if(!o)throw new Error("local declared outside a procedure");let _=r.toLowerCase(),l=e.slots.get(_);if(l!==void 0)return s&&this.warn(`'${r}' is already declared in this procedure; this declaration is ignored`,s),{kind:"var",scope:"local",index:l,name:r};let d=e.slots.size;return e.slots.set(_,d),o.locals.push({name:r,initial:n}),{kind:"var",scope:"local",index:d,name:r}}newTemp(e){return this.declareLocal(e,`tmp.${this.tempCounter++}`,{kind:"int",value:0})}expansions=new we;hostFor(e){return{declareLocal:(r,n,s)=>this.declareLocal(e,r,n,s),newTemp:()=>this.newTemp(e),engineCall:(r,n,s)=>this.engineCall(s,r,n),report:(r,n)=>this.report(r,n)}}lowerEach(e,r){let n=[];for(let s of e){let o=this.lowerStatement(s,r);o&&n.push(o)}return n}lowerStatements(e,r){return this.lowerEach(e.namedChildren.filter(n=>n!==null),r)}lowerStatement(e,r){switch(e.type){case"comment":case"line_comment":case"empty_statement":return null;case"variable_decl":return this.lowerLocalDeclaration(e,r);case"block":return{kind:"block",body:this.lowerStatements(e,r)};case"if_stmt":{let n=this.required(e,"cond",r),s=this.branch(e,"then",r),o=e.childForFieldName("else"),_={kind:"if",cond:n,thenBranch:s};return o?{..._,elseBranch:this.lowerBranchNode(o,r)}:_}case"while_stmt":return{kind:"while",cond:this.required(e,"cond",r),body:this.inLoop(()=>this.branch(e,"body",r))};case"for_stmt":return this.inLoop(()=>this.lowerFor(e,r));case"foreach_stmt":return this.inLoop(()=>this.lowerForeach(e,r));case"switch_stmt":return this.lowerSwitch(e,r);case"return_stmt":{if(this.currentTarget?.inline)return this.report("an inline procedure cannot return",e),null;let n=e.namedChildren.find(s=>s&&s.type!=="comment"&&s.type!=="line_comment");return{kind:"return",value:n?this.lowerExpression(n,r):{kind:"int",value:0}}}case"process_stmt":return this.lowerProcessStatement(e,r);case"break_stmt":return this.requireLoop(e,"break"),{kind:"break"};case"continue_stmt":return this.requireLoop(e,"continue"),{kind:"continue"};case"assignment":return this.lowerAssignment(e,r);case"call_stmt":return this.lowerCallStatement(e,r);case"expression_stmt":{let n=e.namedChildren.find(s=>s&&s.type!=="comment"&&s.type!=="line_comment");return n?this.lowerExpressionStatement(n,r):null}case"preprocessor":return null}throw new R(`unsupported statement '${e.type}'`,e)}lowerFor(e,r){let n=e.childForFieldName("init"),s=e.childForFieldName("cond"),o=e.childForFieldName("update"),_=e.childForFieldName("body"),l={origin:oe(e),init:n?()=>this.lowerForClause(n,r):null,cond:s?()=>this.lowerExpression(s,r):null,update:o?()=>this.lowerForClause(o,r):null,body:_?()=>this.lowerBranchNode(_,r):null};return this.expansions.for(this.hostFor(r),l)}lowerForeach(e,r){let n=e.childForFieldName("iter");if(!n)throw new R("foreach has no iterable",e);let s=e.childForFieldName("key"),o=e.childForFieldName("value"),_=e.childForFieldName("var"),l=o??_??s,d=o?s:null;if(!l)throw new R("foreach has no loop variable",e);let u=e.children.some(O=>O?.type==="variable"),E=e.childForFieldName("while_cond"),g=e.childForFieldName("body"),h=n.type==="identifier",S={origin:oe(e),declares:u?{key:d?{text:d.text,origin:oe(d)}:null,value:{text:l.text,origin:oe(l)}}:null,subject:{isVariable:h,get:()=>h?this.reference(n,r):this.lowerExpression(n,r)},key:d?()=>this.reference(d,r):null,value:()=>this.reference(l,r),guard:E?()=>this.lowerExpression(E,r):null,body:g?()=>this.lowerBranchNode(g,r):null};return this.expansions.foreach(this.hostFor(r),S)}lowerSwitch(e,r){let n=e.childForFieldName("value");if(!n)throw new R("switch has no subject",e);let s=e.namedChildren.filter(d=>d?.type==="case_clause"),o=e.namedChildren.find(d=>d?.type==="default_clause"),_=n.type==="identifier",l={origin:oe(e),subject:{isVariable:_,get:()=>_?this.reference(n,r):this.lowerExpression(n,r)},cases:s.map(d=>{let u=d.childForFieldName("value");if(!u)throw new R("case has no value",d);return{value:()=>this.lowerExpression(u,r),body:()=>this.lowerClauseBody(d,r)}}),fallback:o?()=>this.lowerClauseBody(o,r):null};return this.expansions.switch(this.hostFor(r),l)}lowerClauseBody(e,r){let n=e.childForFieldName("value")?.id,s=e.namedChildren.filter(o=>o!==null&&o.id!==n);return this.lowerEach(s,r)}lowerForClause(e,r){switch(e.type){case"for_var_decl":case"for_init_assign":{let n=e.childForFieldName("name"),s=e.childForFieldName("value");if(!n||!s)throw new R("malformed for clause",e);let o=e.type==="for_var_decl"?this.literalOf(s):null;if(e.type==="for_var_decl"&&this.declareLocal(r,n.text,o??{kind:"int",value:0},n),o!==null)return null;let _=this.reference(n,r);return _.kind!=="var"?(_!==X&&this.report("for target must be a variable",n),null):{kind:"assign",target:_,op:"=",value:this.lowerExpression(s,r)}}case"for_update_assign":{let n=e.childForFieldName("left"),s=e.childForFieldName("right");if(!n||!s)throw new R("malformed for update",e);let o=this.lowerExpression(n,r);if(o.kind!=="var")return o!==X&&this.report("for update target must be a variable",n),null;let _=e.children.find(l=>l&&At.has(l.text))?.text??"=";return{kind:"assign",target:o,op:_===":="?"=":_,value:this.lowerExpression(s,r)}}}return this.incrementOf(e,r)??{kind:"expr",expr:this.lowerExpression(e,r)}}lowerLocalDeclaration(e,r){let n=[];for(let s of e.namedChildren){if(!s||s.type!=="var_init")continue;let o=s.childForFieldName("name");if(!o)throw new R("var_init has no name",s);let _=s.childForFieldName("value"),l=s.childForFieldName("size"),d=_?this.literalOf(_):{kind:"int",value:0},u=this.declareLocal(r,o.text,d??{kind:"int",value:0},o);if(l){if(u.kind!=="var")throw new R(`'${o.text}' is not a variable`,o);let E=s.childForFieldName("flags");n.push({kind:"assign",target:u,op:"=",value:this.engineCall(s,"temp_array",[this.lowerExpression(l,r),E?this.lowerExpression(E,r):{kind:"int",value:4}])});continue}if(!(!_||d!==null)){if(u.kind!=="var")throw new R(`'${o.text}' is not a variable`,o);n.push({kind:"assign",target:u,op:"=",value:this.lowerExpression(_,r)})}}return n.length===0?null:n.length===1?n[0]:{kind:"block",body:n}}branch(e,r,n){let s=e.childForFieldName(r);if(!s)throw new R(`${e.type} has no '${r}'`,e);return this.lowerBranchNode(s,n)}lowerBranchNode(e,r){return this.lowerStatement(e,r)??{kind:"block",body:[]}}required(e,r,n){let s=e.childForFieldName(r);if(!s)throw new R(`${e.type} has no '${r}'`,e);return this.lowerExpression(s,n)}lowerAssignment(e,r){let n=e.childForFieldName("left"),s=e.childForFieldName("right");if(!n||!s)throw new R("malformed assignment",e);let o=e.children.find(d=>d&&At.has(d.text))?.text??"=",_=o===":="?"=":o;if(n.type==="subscript_expr"||n.type==="member_expr")return this.elementAssignment(n,_,()=>this.lowerExpression(s,r),r);let l=this.lowerExpression(n,r);return l===X?null:l.kind!=="var"?(this.report("assignment target must be a variable",n),null):{kind:"assign",target:l,op:_,value:this.lowerExpression(s,r)}}elementAssignment(e,r,n,s){{let o=e,_=e.childForFieldName("object"),l=e.type==="subscript_expr"?e.childForFieldName("index"):e.childForFieldName("member");if(!_||!l)throw new R("malformed element assignment",e);let d=e.type==="subscript_expr"?this.lowerExpression(l,s):{kind:"string",value:l.text},u=this.lowerExpression(_,s),E=q("set_array",this.game);if(!E)throw new R("engine function 'set_array' is unavailable",o);let g=E.popsResult?{popsResult:!0}:{};if(r==="=")return{kind:"libStmt",opcode:E.opcode,args:[u,d,n()],...g};let h=[],S=y=>{if(y.kind==="int"||y.kind==="float"||y.kind==="string"||y.kind==="var")return y;let C=this.newTemp(s);if(C.kind!=="var")throw new R("temporary is not a variable",o);return h.push({kind:"assign",target:C,op:"=",value:y}),C};u=S(u),d=S(d);let O=q("get_array",this.game);if(!O)throw new R("engine function 'get_array' is unavailable",o);let L=r.slice(0,-1);if(!St.has(L))throw new R(`unsupported compound assignment '${r}'`,o);let m={kind:"binary",op:L,left:{kind:"libCall",opcode:O.opcode,args:[u,d]},right:n()},w={kind:"libStmt",opcode:E.opcode,args:[u,d,m],...g};return h.length>0?{kind:"block",body:[...h,w]}:w}}lowerCallStatement(e,r){let n=e.childForFieldName("target");if(!n)throw new R("call has no target",e);let s=e.childForFieldName("delay");if(s){if(n.type==="call_expr")return this.report("a timed call cannot pass arguments",e),null;let _=this.procedureRef(n,r);return _.kind!=="procRef"?(_!==X&&this.report(`unknown procedure '${n.text}'`,n),null):this.refusePureCallStatement(_,n)?null:{kind:"timedCallStmt",target:_,delay:this.lowerExpression(s,r)}}if(n.type==="call_expr"){let{callee:_,args:l,checkArgCount:d}=this.callParts(n,r);return this.refusePureCallStatement(_,n)?null:{kind:"callStmt",target:_,args:l,...d?{checkArgCount:d}:{}}}let o=this.procedureRef(n,r);return o.kind!=="procRef"?{kind:"callStmt",target:o,args:[],checkArgCount:!0}:this.refusePureCallStatement(o,n)?null:{kind:"callStmt",target:o,args:this.padWithDefaults(o.index,[])}}lowerExpressionStatement(e,r){let n=this.incrementOf(e,r);if(n)return n;if(this.literalOf(e)!==null)return null;if(e.type==="call_expr"){let s=e.childForFieldName("func");if(s?.type==="identifier"){let _=q(s.text.toLowerCase(),this.game);if(_){let l=this.argumentsOf(e,r,_.procArgs);this.checkEngineArity(s.text,_,l,e);let d={kind:"libStmt",opcode:_.opcode,args:l};return _.popsResult?{...d,popsResult:!0}:d}}let o=s?.text??"it";return this.report(`'${o}' is not an engine function; write 'call ${o}(...)'`,e),null}if(e.type==="identifier"){let s=q(e.text.toLowerCase(),this.game);if(s&&(s.args??0)===0){let o={kind:"libStmt",opcode:s.opcode,args:[]};return s.popsResult?{...o,popsResult:!0}:o}}return this.report("assignment operator expected",e),null}incrementOf(e,r){if(e.type!=="unary_expr")return null;let n=e.childForFieldName("op")?.text;if(n!=="++"&&n!=="--")return null;let s=e.childForFieldName("expr");if(!s)throw new R("malformed increment",e);let o=n==="++"?"+=":"-=";if(s.type==="subscript_expr"||s.type==="member_expr")return this.elementAssignment(s,o,()=>({kind:"int",value:1}),r);let _=this.lowerExpression(s,r);return _.kind!=="var"?(_!==X&&this.report("increment target must be a variable",s),Yr):{kind:"assign",target:_,op:o,value:{kind:"int",value:1}}}callParts(e,r){let n=e.childForFieldName("func");if(!n)throw new R("call has no callee",e);let s=this.procedureRef(n,r),o=this.argumentsOf(e,r);return s.kind!=="procRef"?{callee:s,args:o,checkArgCount:!0}:{callee:s,args:this.padWithDefaults(s.index,o),checkArgCount:!1}}padWithDefaults(e,r){let n=this.paramDefaults.get(e)??[],s=[...r];for(let o=s.length;o<n.length;o++){let _=n[o];if(!_)break;s.push(_)}return s}argumentsOf(e,r,n=0){return e.namedChildren.slice(1).filter(o=>!!o&&o.type!=="comment"&&o.type!=="line_comment").map((o,_)=>{if((n&1<<_)!==0&&o.type==="identifier"){let l=this.procedures.get(o.text.toLowerCase());if(l!==void 0)return{kind:"procRef",index:l}}return this.lowerExpression(o,r)})}procedureRef(e,r){if(e.type==="string")return this.constantOf(e);if(e.type!=="identifier")throw new R(`cannot call a '${e.type}'`,e);let n=e.text.toLowerCase(),s=this.procedures.get(n);if(s!==void 0)return{kind:"procRef",index:s};let o=r.slots.get(n);if(o!==void 0)return{kind:"var",scope:"local",index:o,name:e.text};let _=this.globals.get(n);if(_!==void 0)return{kind:"var",scope:"global",index:_,name:e.text};let l=this.externals.get(n);return l!==void 0?{kind:"var",scope:"external",index:0,name:l}:this.reportedNames.has(n)?X:(this.reportedNames.add(n),this.report(`unknown procedure '${e.text}'`,e))}lowerProcessStatement(e,r){let n=e.childForFieldName("op")?.text.toLowerCase();if(!n)throw new R("malformed process statement",e);if(n==="noop")return null;let s=jr[n];if(s===void 0)throw new R(`unsupported process statement '${n}'`,e);let o=e.childForFieldName("arg");if(!o)return{kind:"opStmt",opcode:s,args:[]};if(n==="cancel"){let _=this.procedures.get(o.text.toLowerCase());return _===void 0?(this.report(`unknown procedure '${o.text}'`,o),null):{kind:"opStmt",opcode:s,args:[{kind:"procRef",index:_}]}}return{kind:"opStmt",opcode:s,args:[this.lowerExpression(o,r)]}}inLoop(e){this.loopDepth++;try{return e()}finally{this.loopDepth--}}requireLoop(e,r){this.loopDepth===0&&this.report(`'${r}' outside a loop`,e)}lowerExpression(e,r){switch(e.type){case"number":case"string":case"char":case"boolean":return this.constantOf(e);case"paren_expr":{let n=e.namedChildren.find(s=>s&&s.type!=="comment");if(!n)throw new R("empty parentheses",e);return this.lowerExpression(n,r)}case"identifier":return this.reference(e,r);case"proc_ref":{let n=e.namedChildren[0];if(!n)throw new R("malformed procedure reference",e);let s=this.procedures.get(n.text.toLowerCase());return s===void 0?this.report(`unknown procedure '${n.text}'`,n):{kind:"procRef",index:s,stringify:!0}}case"unary_expr":{let n=e.childForFieldName("expr"),s=e.childForFieldName("op")?.text?.toLowerCase();if(!n||!s)throw new R("malformed unary expression",e);return s==="-"?{kind:"unary",op:"negate",operand:this.lowerExpression(n,r)}:s==="not"||s==="bwnot"||s==="floor"?{kind:"unary",op:s,operand:this.lowerExpression(n,r)}:this.report(`unsupported unary operator '${s}'`,e)}case"binary_expr":{let n=e.childForFieldName("left"),s=e.childForFieldName("right"),o=e.childForFieldName("op")?.text?.toLowerCase();if(!n||!s||!o)throw new R("malformed binary expression",e);if(!St.has(o))return this.report(`unsupported operator '${o}'`,e);if(wt.has(o))for(let _ of[n,s]){let l=_.childForFieldName("op")?.text?.toLowerCase();if(_.type==="binary_expr"&&l&&wt.has(l))return this.report("comparisons do not chain; parenthesise one of them",e)}return(o==="/"||o==="%"||o==="div")&&bt(s)?this.report("division by zero",s):{kind:"binary",op:o,left:this.lowerExpression(n,r),right:this.lowerExpression(s,r)}}case"ternary_expr":{let n=e.childForFieldName("true_value"),s=e.childForFieldName("cond"),o=e.childForFieldName("false_value");if(!n||!s||!o)throw new R("malformed conditional",e);return{kind:"ternary",cond:this.lowerExpression(s,r),whenTrue:this.lowerExpression(n,r),whenFalse:this.lowerExpression(o,r)}}case"subscript_expr":{let n=e.childForFieldName("object"),s=e.childForFieldName("index");if(!n||!s)throw new R("malformed subscript",e);return this.engineCall(e,"get_array",[this.lowerExpression(n,r),this.lowerExpression(s,r)])}case"member_expr":{let n=e.childForFieldName("object"),s=e.childForFieldName("member");if(!n||!s)throw new R("malformed member access",e);return this.engineCall(e,"get_array",[this.lowerExpression(n,r),{kind:"string",value:s.text}])}case"array_expr":return this.lowerArrayLiteral(e,r,!1);case"map_expr":return this.lowerArrayLiteral(e,r,!0);case"call_expr":{let n=e.childForFieldName("func");if(n?.type==="identifier"){let l=q(n.text.toLowerCase(),this.game);if(l){let d=this.argumentsOf(e,r,l.procArgs);return this.checkEngineArity(n.text,l,d,e),ke(l.opcode,d)}}let{callee:s,args:o,checkArgCount:_}=this.callParts(e,r);return{kind:"call",target:s,args:o,..._?{checkArgCount:_}:{},...this.callsPureProcedure(s)?{pure:!0}:{}}}}throw new R(`unsupported expression '${e.type}'`,e)}lowerArrayLiteral(e,r,n){let s=[];for(let _ of e.namedChildren)if(_)if(n){if(_.type!=="map_entry")continue;let l=_.childForFieldName("key"),d=_.childForFieldName("value");if(!l||!d)throw new R("malformed map entry",_);s.push({key:()=>this.lowerExpression(l,r),value:()=>this.lowerExpression(d,r)})}else{if(_.type==="comment"||_.type==="line_comment")continue;s.push({key:null,value:()=>this.lowerExpression(_,r)})}let o={origin:oe(e),isMap:n,entries:s};return this.expansions.arrayLiteral(this.hostFor(r),o)}checkEngineArity(e,r,n,s){if(r.args===void 0||n.length===r.args)return;let o=`${r.args} argument${r.args===1?"":"s"}`;this.report(`'${e}' takes ${o}, not ${n.length}`,s)}engineCall(e,r,n){let s=q(r,this.game);if(!s)throw new R(`engine function '${r}' is unavailable`,e);return ke(s.opcode,n)}callsPureProcedure(e){return e.kind==="procRef"&&this.pureProcedures.has(e.index)}refusePureCallStatement(e,r){return this.callsPureProcedure(e)?(this.report(`'${r.text}' is a pure procedure; use its value instead of 'call'`,r),!0):!1}refuseInlineInExpression(e,r){return this.inlineProcedures.has(e)?this.report(`'${r.text}' is an inline procedure and has no value`,r):null}reference(e,r){let n=e.text.toLowerCase(),s=r.slots.get(n);if(s!==void 0)return{kind:"var",scope:"local",index:s,name:e.text};let o=this.globals.get(n);if(o!==void 0)return{kind:"var",scope:"global",index:o,name:e.text};let _=this.externals.get(n);if(_!==void 0)return{kind:"var",scope:"external",index:0,name:_};let l=q(n,this.game);if(l)return ke(l.opcode,[]);let d=this.procedures.get(n);return d!==void 0?this.refuseInlineInExpression(d,e)??{kind:"call",target:{kind:"procRef",index:d},args:[],...this.pureProcedures.has(d)?{pure:!0}:{}}:this.reportedNames.has(n)?X:(this.reportedNames.add(n),this.report(`unknown identifier '${e.text}'`,e))}};function qr(t){if(!zr.test(t.text))return!1;let e=r=>r.type==="other_preprocessor"&&/^#\s*pragma\s+sce\b/i.test(r.text)?!0:r.namedChildren.some(n=>!!n&&e(n));return e(t)}var zr=/#\s*pragma\s+sce\b/i;function Qr(t,e){let r=[],n=s=>{if(s.type==="string"){if(e)for(let l of en(s.text))e(`unknown escape '\\${l}' in a string; it stands for '${l}'`,s);r.push(Rt(s.text))}let o=s.namedChildren;s.type==="proc_ref"&&o[0]&&r.push(o[0].text);let _=s.type==="member_expr"?s.childForFieldName("member")?.id:void 0;for(let l of o)if(l){if(_!==void 0&&l.id===_){r.push(l.text);continue}n(l)}};return n(t),r}var De={a:"\x07",b:"\b",f:"\f",n:`
3
+ `,r:"\r",t:" ",v:" "};function*yt(t){for(let e=0;e<t.length;e++){if(t[e]!=='"')continue;let r=e+1,n=r;for(;n<t.length&&t[n]!=='"';)n+=t[n]==="\\"?2:1;if(n>=t.length)return;yield t.slice(r,n),e=n}}var Zr=new Set(["\\",'"']);function Rt(t){let e="";for(let r of yt(t))e+=r.replaceAll(/\\(.)/g,(n,s)=>De[s]??s);return e}function en(t){let e=[];for(let r of yt(t))for(let[,n]of r.matchAll(/\\(.)/g))n!==void 0&&De[n]===void 0&&!Zr.has(n)&&e.push(n);return e}function tn(t){let e=t.text.slice(1,-1);if(!e.startsWith("\\"))return e.codePointAt(0)??0;if(/^\\0[0-7]{2,3}$/.exec(e))return Number.parseInt(e.slice(1),8);let n=De[e.slice(1)];return n===void 0?null:n.codePointAt(0)??0}function It(t,e={}){return new xe(e).lower(t.rootNode)}function z(t){switch(t.kind){case"call":case"libCall":return t.pure===!0&&t.args.every(z);case"unary":return z(t.operand);case"binary":return z(t.left)&&z(t.right);case"ternary":return z(t.cond)&&z(t.whenTrue)&&z(t.whenFalse);default:return!0}}function rn(t){if(t.kind==="unary"){let u=t.operand;if(u.kind!=="int"&&u.kind!=="float")return t;switch(t.op){case"not":return{kind:"int",value:u.value===0?1:0};case"bwnot":return{kind:"int",value:~u.value};case"negate":return{...u,value:-u.value};default:return t}}if(t.kind!=="binary")return t;let e=t.left,r=t.right;if(e.kind!=="int"&&e.kind!=="float"||r.kind!=="int"&&r.kind!=="float")return t;let n=u=>({kind:"int",value:u}),s=u=>n(u?1:0),o=e.kind==="float"||r.kind==="float",_=e.value,l=r.value,d=u=>o?{kind:"float",value:Math.fround(u)}:n(u);switch(t.op){case"+":return d(_+l);case"-":return d(_-l);case"*":return d(_*l);case"/":case"div":return l===0?t:o?d(_/l):n(Math.trunc(_/l));case"bwand":return n(_&l);case"bwor":return n(_|l);case"bwxor":return n(_^l);case"==":return s(_===l);case"!=":return s(_!==l);case"<":return s(_<l);case">":return s(_>l);case"<=":return s(_<=l);case">=":return s(_>=l);default:return t}}function Ot(t){return t.kind==="int"||t.kind==="float"?t.value!==0:null}var nn=new Set(["no_p_proc","start","spatial_p_proc","description_p_proc","desc_p_proc","pickup_p_proc","drop_p_proc","use_p_proc","use_obj_on_p_proc","use_skill_on_p_proc","none_x_bad","talk_p_proc","critter_p_proc","combat_p_proc","damage_p_proc","map_enter_p_proc","map_exit_p_proc","create_p_proc","destroy_p_proc","look_at_p_proc","timed_event_p_proc","map_update_p_proc","push_p_proc","is_dropping_p_proc","combat_is_starting_p_proc","combat_is_over_p_proc"]);function ae(t,e){let r=s=>{switch(e(s),s.kind){case"unary":r(s.operand);break;case"binary":r(s.left),r(s.right);break;case"ternary":r(s.cond),r(s.whenTrue),r(s.whenFalse);break;case"call":r(s.target),s.args.forEach(r);break;case"libCall":s.args.forEach(r);break;default:break}},n=s=>{switch(s.kind){case"block":s.body.forEach(n);break;case"expr":r(s.expr);break;case"assign":r(s.target),r(s.value);break;case"if":r(s.cond),n(s.thenBranch),s.elseBranch&&n(s.elseBranch);break;case"while":r(s.cond),n(s.body);break;case"return":s.value&&r(s.value);break;case"callStmt":r(s.target),s.args.forEach(r);break;case"timedCallStmt":r(s.target),r(s.delay);break;case"libStmt":case"opStmt":s.args.forEach(r);break;default:break}};n(t)}function ge(t,e){t.body.forEach(r=>ae(r,e)),t.conditional&&ae({kind:"expr",expr:t.conditional},e)}function sn(t){let e=!1,r=n=>{n.kind!=="procRef"&&n.kind!=="string"&&n.kind!=="var"&&(e=!0)};for(let n of j(t)){ge(n,o=>{o.kind==="call"&&r(o.target)});let s=o=>{switch(o.kind){case"callStmt":r(o.target);break;case"block":o.body.forEach(s);break;case"if":s(o.thenBranch),o.elseBranch&&s(o.elseBranch);break;case"while":s(o.body);break;default:break}};n.body.forEach(s)}return e}function on(t){let e=j(t),r=new Map;e.forEach((_,l)=>r.set(_.name.toLowerCase(),l));let n=new Set,s=[],o=_=>{_<0||_>=e.length||n.has(_)||(n.add(_),s.push(_))};for(e.forEach((_,l)=>{(nn.has(_.name.toLowerCase())||_.exported||_.imported||_.timed!==void 0||_.conditional)&&o(l)});s.length>0;){let _=e[s.pop()];_&&ge(_,l=>{if(l.kind==="procRef"&&o(l.index),l.kind==="string"){let d=r.get(l.value.toLowerCase());d!==void 0&&o(d)}})}return n}function Pt(t,e,r){return ye(t,n=>n.kind==="procRef"?{...n,index:e.get(n.index)??n.index}:n.kind==="var"&&n.scope==="global"?{...n,index:r.get(n.index)??n.index}:n)}function ye(t,e){let r=s=>{switch(s.kind){case"unary":return e({...s,operand:r(s.operand)});case"binary":return e({...s,left:r(s.left),right:r(s.right)});case"ternary":return e({...s,cond:r(s.cond),whenTrue:r(s.whenTrue),whenFalse:r(s.whenFalse)});case"call":return e({...s,target:r(s.target),args:s.args.map(r)});case"libCall":return e({...s,args:s.args.map(r)});default:return e(s)}},n=s=>{switch(s.kind){case"block":return{...s,body:s.body.map(n)};case"expr":return{...s,expr:r(s.expr)};case"assign":return{...s,target:r(s.target),value:r(s.value)};case"if":return{...s,cond:r(s.cond),thenBranch:n(s.thenBranch),...s.elseBranch?{elseBranch:n(s.elseBranch)}:{}};case"while":return{...s,cond:r(s.cond),body:n(s.body)};case"return":return s.value?{...s,value:r(s.value)}:s;case"callStmt":return{...s,target:r(s.target),args:s.args.map(r)};case"timedCallStmt":return{...s,target:r(s.target),delay:r(s.delay)};case"libStmt":case"opStmt":return{...s,args:s.args.map(r)};default:return s}};return n(t)}function an(t,e,r){let n={...t,body:t.body.map(s=>Pt(s,e,r))};if(t.conditional){let s=Pt({kind:"expr",expr:t.conditional},e,r);s.kind==="expr"&&(n.conditional=s.expr)}return n}function Fe(t){let e=[];for(let r of t){let n=ie(r);if(n!==null&&(e.push(n),ue(n)))break}return e}function Be(t){switch(t.kind){case"block":return t.body.every(Be);case"loopEnd":return!0;default:return!1}}function ie(t){switch(t.kind){case"block":{let e=Fe(t.body);return e.length>0?{...t,body:e}:null}case"if":{let e=Ot(t.cond);if(e===!0)return ie(t.thenBranch);if(e===!1)return t.elseBranch?ie(t.elseBranch):null;let r=ie(t.thenBranch)??{kind:"block",body:[]},n=t.elseBranch?ie(t.elseBranch):void 0,s=n&&!Be(n)?n:void 0;return Be(r)&&!s?z(t.cond)?null:{...t,thenBranch:r,elseBranch:void 0}:{...t,thenBranch:r,elseBranch:s??void 0}}case"while":{if(Ot(t.cond)===!1)return null;let e=ie(t.body)??{kind:"block",body:[]};return{...t,body:e}}default:return t}}function _n(){return{firstAssign:null,lastAssign:null,firstAssignAt:0,lastAssignAt:0,firstUseAt:0,lastUseAt:0,firstAssignPure:!1,firstAssignDead:!1,transferable:null,lastAssignPure:!1,lastAssignInWhile:!1,lastAssignIsBranchBody:!1}}function ln(t){let e=new Map,r=d=>{let u=e.get(d);return u||(u=_n(),e.set(d,u)),u},n=0,s=new Set,o=(d,u)=>{let E=r(d);E.lastUseAt=u,E.firstUseAt===0&&(E.firstUseAt=u)},_=(d,u)=>{ae({kind:"expr",expr:d},E=>{E.kind==="var"&&E.scope==="local"&&o(E.index,u)})},l=(d,u,E,g)=>{n++;let h=E===0?0:E+1,S=u,O=g;u===0?(O={at:n,stmt:d},d.kind==="while"?S=1:d.kind==="if"&&E===0&&(h=1)):S=u+1;let L=O.at;switch(d.kind){case"assign":{if(d.target.scope!=="local"){_(d.value,L);return}let m=d.target.index,w=r(m),y=z(d.value);if(w.lastAssign=O.stmt,w.lastAssignAt=L,w.lastAssignPure||=y,w.lastAssignInWhile=S>0,w.lastAssignIsBranchBody=s.has(O.stmt),w.firstUseAt===0)if(w.firstAssign===null){if(w.firstAssign=O.stmt,w.firstAssignAt=L,y){w.firstAssignPure=!0;let C=d.value,P=C.kind==="int"||C.kind==="float";S===0&&h===0&&P&&d.op==="="&&(w.transferable=C,w.firstAssignDead=!0)}}else S===0&&h===0?w.firstAssignPure&&d.op==="="&&(w.firstAssignDead=!0):!y&&L===w.firstAssignAt&&(w.firstAssignPure=!1);d.op!=="="&&o(m,L),_(d.value,L);return}case"block":for(let m of d.body)l(m,S,h,O);return;case"if":_(d.cond,L),s.add(d.thenBranch),l(d.thenBranch,S,h,O),d.elseBranch&&(s.add(d.elseBranch),l(d.elseBranch,S,h,O));return;case"while":_(d.cond,L),s.add(d.body),l(d.body,S,h,O);return;default:ae(d,m=>{m.kind==="var"&&m.scope==="local"&&o(m.index,L)})}};for(let d of t.body)l(d,0,0,{at:0,stmt:d});return e}function Ue(t,e){let r=n=>{if(n===e)return null;switch(n.kind){case"block":{let s=Ue(n.body,e);return s.length>0?{...n,body:s}:null}case"if":{let s=r(n.thenBranch)??{kind:"block",body:[]},o=n.elseBranch?r(n.elseBranch):void 0;return{...n,thenBranch:s,elseBranch:o??void 0}}case"while":return{...n,body:r(n.body)??{kind:"block",body:[]}};default:return n}};return t.flatMap(n=>{let s=r(n);return s===null?[]:[s]})}function Lt(t,e){let r=n=>{switch(n.kind){case"assign":return n.target.scope==="local"&&n.target.index===e?null:n;case"block":{let s=Lt(n.body,e);return s.length>0?{...n,body:s}:null}case"if":{let s=r(n.thenBranch)??{kind:"block",body:[]},o=n.elseBranch?r(n.elseBranch):void 0;return{...n,thenBranch:s,elseBranch:o??void 0}}case"while":return{...n,body:r(n.body)??{kind:"block",body:[]}};default:return n}};return t.flatMap(n=>{let s=r(n);return s===null?[]:[s]})}function cn(t){let e=t.body,r=t.locals,n=!1;for(;;){let s=ln({...t,body:e,locals:r}),o=!1;for(let[_,l]of[...s.entries()].sort((d,u)=>d[0]-u[0])){if(l.firstAssignDead&&l.firstAssign){let d=_-t.args.length,u=l.transferable;if(u&&r[d]&&(u.kind==="int"||u.kind==="float")){let E=[...r];E[d]={...r[d],initial:u},r=E}e=Ue(e,l.firstAssign),o=!0;break}if(l.lastAssign&&l.lastAssignAt>=l.lastUseAt&&l.lastAssignPure&&!l.lastAssignIsBranchBody&&(!l.lastAssignInWhile||l.lastAssignAt>l.lastUseAt)){e=l.lastAssignInWhile?Lt(e,_):Ue(e,l.lastAssign),o=!0;break}}if(!o)break;n=!0}return{procedure:{...t,body:e,locals:r},changed:n}}function dn(t){let e=!1,r=s=>{let o=[];for(let _ of s){let l=o[o.length-1];if(l?.kind==="assign"&&l.op==="="&&_.kind==="assign"&&_.op!=="="&&_.target.scope===l.target.scope&&_.target.index===l.target.index&&_.target.name===l.target.name){let d=_.op.slice(0,-1);if(un.has(d)){o[o.length-1]={...l,value:{kind:"binary",op:d,left:l.value,right:_.value}},e=!0;continue}}o.push(n(_))}return o},n=s=>{switch(s.kind){case"block":return{...s,body:r(s.body)};case"if":return{...s,thenBranch:n(s.thenBranch),...s.elseBranch?{elseBranch:n(s.elseBranch)}:{}};case"while":return{...s,body:n(s.body)};default:return s}};return{body:r(t),changed:e}}var un=new Set(["+","-","*","/"]);function pn(t){let e=t.args.length,r=new Set;for(let g of t.body)ae(g,h=>{h.kind==="var"&&h.scope==="local"&&r.add(h.index)});t.conditional&&ae({kind:"expr",expr:t.conditional},g=>{g.kind==="var"&&g.scope==="local"&&r.add(g.index)});let n=t.reclaimedArgSlots??0,s=e-n,o=t.locals.map((g,h)=>r.has(s+h)),_=0;for(let g=s-1;g>=0&&!r.has(g);g--)_++;let l=n+_;if(o.every(Boolean)&&_===0)return t;let d=new Map;for(let g=0;g<s-_;g++)d.set(g,g);let u=s-_;t.locals.forEach((g,h)=>{o[h]&&d.set(s+h,u++)});let E=g=>g.kind==="var"&&g.scope==="local"?{...g,index:d.get(g.index)??g.index}:g;return{...t,locals:t.locals.filter((g,h)=>o[h]),body:t.body.map(g=>ye(g,E)),...l>0?{reclaimedArgSlots:l}:{}}}function Ee(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let _=0;_<t.length;_++)if(!Ee(t[_],e[_]))return!1;return!0}if(Array.isArray(e))return!1;let r=t,n=e,s=0;for(let _ in r){if(!Object.hasOwn(r,_))continue;let l=r[_];if(l!==void 0&&(s++,!Ee(l,n[_])))return!1}let o=0;for(let _ in n)Object.hasOwn(n,_)&&n[_]!==void 0&&o++;return s===o}function gn(t){let e=t.body,r=t.locals;for(let n=0;n<32;n++){let s=!1,o=e.map(u=>ye(u,rn));Ee(o,e)||(s=!0),e=o;let _=cn({...t,body:e,locals:r});e=_.procedure.body,r=_.procedure.locals,s||=_.changed;let l=Fe(e);Ee(l,e)||(s=!0),e=l;let d=dn(e);if(e=d.body,s||=d.changed,!s)break}return pn({...t,body:Fe(e),locals:r})}function En(t){let e=new Set;for(let o of j(t)){let _=l=>{l.kind==="assign"&&l.target.scope==="global"&&e.add(l.target.index),l.kind==="block"&&l.body.forEach(_),l.kind==="if"&&(_(l.thenBranch),l.elseBranch&&_(l.elseBranch)),l.kind==="while"&&_(l.body)};o.body.forEach(_)}let r=new Set;for(let o of j(t)){let _=d=>{d.kind==="var"&&d.scope==="global"&&r.add(d.index)};ge(o,d=>{d.kind==="call"&&_(d.target)});let l=d=>{d.kind==="callStmt"&&_(d.target),d.kind==="timedCallStmt"&&_(d.target),d.kind==="block"&&d.body.forEach(l),d.kind==="if"&&(l(d.thenBranch),d.elseBranch&&l(d.elseBranch)),d.kind==="while"&&l(d.body)};o.body.forEach(l)}let n=new Map;if(pe(t).forEach((o,_)=>{!e.has(_)&&!o.exported&&!r.has(_)&&n.set(_,o.initial)}),n.size===0)return t;let s=o=>o.kind==="var"&&o.scope==="global"?n.get(o.index)??o:o;return{...t,declarations:t.declarations.map(o=>o.kind==="procedure"?{kind:"procedure",procedure:{...o.procedure,body:o.procedure.body.map(_=>ye(_,s))}}:o)}}function Nt(t,e={}){let r=e.level??0;if(r<1)return t;if(r<2)return be(t);let n=s=>({...s,declarations:s.declarations.map(o=>o.kind==="procedure"?{kind:"procedure",procedure:gn(o.procedure)}:o)});for(let s=0;s<16;s++){let o=t;if(t=En(be(n(be(t)))),Ee(t,o))break}return be(t)}function be(t){let r=sn(t)?null:on(t),n=new Map,s=0;j(t).forEach((m,w)=>{(r===null||r.has(w))&&n.set(w,s++)});let o=new Set,_=new Set;j(t).forEach((m,w)=>{n.has(w)&&ge(m,y=>{y.kind==="var"&&(y.scope==="global"&&o.add(y.index),y.scope==="external"&&_.add(y.name))})});let l=new Map,d=0;pe(t).forEach((m,w)=>{(o.has(w)||m.exported)&&l.set(w,d++)});let u=-1,E=-1,g=[],h=new Set;for(let m of t.declarations){if(m.kind==="procedure"){if(u++,!n.has(u))continue;g.push({kind:"procedure",procedure:an(m.procedure,n,l)});continue}m.kind==="global"&&(E++,!l.has(E))||m.kind==="external"&&!m.variable.exported&&!_.has(m.variable.name)||g.push(m)}let S=g.flatMap(m=>m.kind==="procedure"?[m.procedure]:[]);for(let m of S){for(let w of m.locals)w.initial.kind==="string"&&h.add(w.initial.value);ge(m,w=>{if(w.kind==="string"&&h.add(w.value),w.kind==="procRef"&&w.stringify){let y=S[w.index];y&&h.add(y.name)}})}for(let m of g)m.kind!=="procedure"&&m.variable.initial.kind==="string"&&h.add(m.variable.initial.value);let O=t.stringLiterals?.filter(m=>h.has(m)),L=t.undefinedProcedures?.filter(m=>n.has(m.index)).map(m=>({...m,index:n.get(m.index)}));return{...t,declarations:g,...O?{stringLiterals:O}:{},...(t.stringLiterals?.length??0)>0?{stringTableAllocated:!0}:{},...L&&L.length>0?{undefinedProcedures:L}:{undefinedProcedures:void 0}}}var U=Z(require("node:fs"),1),_e=Z(require("node:path"),1),M=class extends Error{file;line;detail;all;constructor(e,r,n,s=[]){super(`${r}:${n}: ${e}`),this.name="PreprocessError",this.file=r,this.line=n,this.detail=e,this.all=s.length>0?s:[this]}},Tn=100,Pe=new Set,vt=/(\s+)|("(?:[^"\\]|\\.)*"?)|('(?:[^'\\]|\\.)*'?)|(0[xX][0-9a-fA-F]+|\d+\.?\d*)|([A-Za-z_]\w*)|(##|[^\s])/g;function Re(t,e=Pe){let r=[];vt.lastIndex=0;let n;for(;(n=vt.exec(t))!==null;)r.push(n[1]===void 0?{t:n[0],ws:!1,hide:e}:{t:" ",ws:!0,hide:e});return r}function Ie(t){return t!==void 0&&!t.ws&&/^[A-Za-z_]\w*$/.test(t.t)}function Ve(t){return t.map(e=>e.t).join("")}function Le(t){let e=0,r=t.length;for(;e<r&&t[e]?.ws===!0;)e++;for(;r>e&&t[r-1]?.ws===!0;)r--;return t.slice(e,r)}function Oe(t,e){let r=e;for(;r<t.length&&t[r]?.ws===!0;)r++;return r}function hn(t,e){let r=new Set;for(let n of t)e.has(n)&&r.add(n);return r}function Ct(t,e){return t.map(r=>({t:r.t,ws:r.ws,hide:new Set([...r.hide,...e])}))}function fn(t){return`"${Ve(Le(t)).replaceAll(/\s+/g," ").replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}var He=class{macros;unclosedCall=!1;constructor(e){this.macros=e}readArgs(e,r){let n=0,s=[],o=[];for(let _=r;_<e.length;_++){let l=e[_];if(l===void 0)break;if(l.t==="("){if(n++,n===1)continue}else if(l.t===")"){if(n--,n===0)return s.push(o),{args:s,end:_+1,rparenHide:l.hide}}else if(l.t===","&&n===1){s.push(o),o=[];continue}o.push(l)}return null}subst(e,r,n){let s=e.params??[],o=new Map;if(s.forEach((d,u)=>o.set(d,r[u]??[])),e.variadic){let d=[];r.slice(s.length).forEach((u,E)=>{E>0&&d.push({t:",",ws:!1,hide:Pe}),d.push(...u)}),o.set("__VA_ARGS__",d)}let _=Re(e.body),l=[];for(let d=0;d<_.length;d++){let u=_[d];if(u!==void 0){if(u.t==="#"){let E=Oe(_,d+1),g=_[E];if(Ie(g)&&o.has(g.t)){l.push({t:fn(o.get(g.t)??[]),ws:!1,hide:Pe}),d=E;continue}}if(u.t==="##"){for(;l.length>0&&l[l.length-1]?.ws===!0;)l.pop();let E=Oe(_,d+1),g=_[E];if(g===void 0){d=E;continue}let h=Ie(g)&&o.has(g.t)?Le(o.get(g.t)??[]):[g],S=l.pop();l.push(...Re((S?.t??"")+Ve(h),S?.hide??Pe)),d=E;continue}if(Ie(u)&&o.has(u.t)){let E=o.get(u.t)??[],g=_[Oe(_,d+1)]?.t==="##";l.push(...g?Le(E):this.expand([...E]));continue}l.push(u)}}return Ct(l,n)}expand(e){let r=[],n=0,s=5e5;for(;n<e.length;){if(--s<0)throw new Error("macro expansion did not terminate");let o=e[n];if(o===void 0)break;if(!Ie(o)||o.hide.has(o.t)){r.push(o),n++;continue}let _=this.macros.get(o.t);if(_===void 0){r.push(o),n++;continue}if(_.params===null){let g=new Set([...o.hide,o.t]);e.splice(n,1,...Ct(Re(_.body),g));continue}let l=Oe(e,n+1);if(e[l]?.t!=="("){r.push(o),n++;continue}let d=this.readArgs(e,l);if(d===null){this.unclosedCall=!0,r.push(o),n++;continue}let u=_.params.length===0&&!_.variadic&&d.args.length===1&&Le(d.args[0]??[]).length===0,E=new Set([...hn(o.hide,d.rparenHide),o.t]);e.splice(n,d.end-n,...this.subst(_,u?[]:d.args,E))}return r}expandText(e){return this.expandChunk(e).text}expandChunk(e){return this.unclosedCall=!1,{text:Ve(this.expand(Re(e))),unclosedCall:this.unclosedCall}}};function mn(t){return t.replaceAll(/\\\r?\n/g,"")}function Sn(t){let e=t.length,r="",n=0,s=0;for(;s<e;){let o=t.codePointAt(s);if(o===34||o===39){for(s++;s<e;){let _=t.codePointAt(s);if(_===92){s+=2;continue}if(s++,_===o||_===10)break}continue}if(o===47){let _=t.codePointAt(s+1);if(_===42){r+=t.slice(n,s);let l=s+2,d=0;for(;l<e&&!(t.codePointAt(l)===42&&t.codePointAt(l+1)===47);)t.codePointAt(l)===10&&d++,l++;r+=d===0?" ":` ${`
4
+ `.repeat(d)}`,s=l+2,n=s;continue}if(_===47){r+=t.slice(n,s);let l=s+2;for(;l<e&&t.codePointAt(l)!==10;)l++;s=l,n=s;continue}}s++}return n===0?t:r+t.slice(n)}var An={"*":10,"/":10,"%":10,"+":9,"-":9,"<<":8,">>":8,"<":7,">":7,"<=":7,">=":7,"==":6,"!=":6,"&":5,"^":4,"|":3,"&&":2,"||":1};function wn(t,e,r){switch(t){case"*":return e*r;case"/":return r===0?0:Math.trunc(e/r);case"%":return r===0?0:e%r;case"+":return e+r;case"-":return e-r;case"<<":return e<<r;case">>":return e>>r;case"<":return e<r?1:0;case">":return e>r?1:0;case"<=":return e<=r?1:0;case">=":return e>=r?1:0;case"==":return e===r?1:0;case"!=":return e!==r?1:0;case"&":return e&r;case"^":return e^r;case"|":return e|r;case"&&":return e&&r?1:0;default:return e||r?1:0}}function Mt(t,e,r,n,s){let o=t.replaceAll(/\bdefined\s*\(\s*([A-Za-z_]\w*)\s*\)|\bdefined\s+([A-Za-z_]\w*)/g,(g,h,S)=>r.has(h??S)?"1":"0");o=e.expandText(o),o=o.replaceAll(/\b[A-Za-z_]\w*\b/g,"0");let _=o.match(/0[xX][0-9a-fA-F]+|\d+|<<|>>|<=|>=|==|!=|&&|\|\||[-+*/%()<>!~&^|]/g)??[],l=0,d=()=>{let g=_[l++];if(g===void 0)throw new M("malformed #if expression",n,s);if(g==="("){let h=u(1);if(_[l++]!==")")throw new M("unbalanced ( in #if",n,s);return h}if(g==="!")return d()?0:1;if(g==="~")return~d();if(g==="-")return-d();if(g==="+")return d();if(/^0[xX]/.test(g))return parseInt(g,16);if(/^\d+$/.test(g))return parseInt(g,10);throw new M(`unexpected token '${g}' in #if`,n,s)};function u(g){let h=d();for(;;){let S=_[l],O=S===void 0?void 0:An[S];if(O===void 0||O<g)return h;l++,h=wn(S,h,u(O+1))}}let E=u(1);if(l!==_.length)throw new M("trailing tokens in #if",n,s);return E!==0}var bn=/^[ \t]*#[ \t]*([A-Za-z_]\w*)?[ \t]*([\s\S]*)$/,yn=/^[ \t]*#/,kt=/^\s*"([^"]+)"|^\s*<([^>]+)>/,Rn=new Set(["warning","assert","unassert","ident","sccs"]);function H(t,e){return t.errors.some(n=>n.file===e.file&&n.line===e.line&&n.detail===e.detail)||t.errors.push(e),t.errors.length<Tn}function xt(t,e){try{return e()}catch(r){if(!(r instanceof M))throw r;return H(t,r),null}}function In(t){let e=/^([A-Za-z_]\w*)(\(([^)]*)\))?([\s\S]*)$/.exec(t);if(e===null)return{error:"malformed #define"};let[,r,n,s,o]=e;if(r===void 0)return{error:"malformed #define"};let _=(o??"").trim();if(n===void 0)return{name:r,params:null,body:_,variadic:!1};let l=(s??"").split(",").map(E=>E.trim()).filter(E=>E.length>0),d=l[l.length-1]==="...",u=d?l.slice(0,-1):l;return u.some(E=>E.endsWith("..."))?{error:"named variadic parameters are not supported"}:{name:r,params:u,body:_,variadic:d}}function On(t,e,r){let n=t.replaceAll("\\","/");return[_e.resolve(e,n),...(r.includeDirs??[]).map(o=>_e.resolve(o,n))].find(o=>U.existsSync(o)&&U.statSync(o).isFile())??null}function Pn(t,e){if(e.depth>(e.options.maxIncludeDepth??64)){H(e,new M("include nesting too deep",t,0));return}Ft(vn(t),t,e)}var Ln=32;function Nn(t,e,r,n){let s=e[r]?.text??"",o=r,_=t.expander.expandChunk(s);for(;_.unclosedCall&&o+1<e.length&&o-r<Ln;)o++,s+=`
5
+ ${e[o]?.text??""}`,_=t.expander.expandChunk(s);t.out.push(_.text);let l=_.text.split(`
6
+ `).length-1;for(let d=l;d<o-r;d++)t.out.push("");for(let d=r;d<=o;d++)t.origins.push({file:n,line:d+1});return o}var Ge=new Map;function vn(t){let e;try{e=U.openSync(t,"r")}catch(r){throw Ge.delete(t),r}try{let r=U.fstatSync(e),n=`${r.mtimeMs}:${r.size}`,s=Ge.get(t);if(s!==void 0&&s.stamp===n)return s.lines;let o=Dt(U.readFileSync(e,"latin1"));return Ge.set(t,{stamp:n,lines:o}),o}finally{U.closeSync(e)}}function Dt(t){return Sn(mn(t)).split(/\r?\n/).map(e=>Cn(e))}function Cn(t){if(!yn.test(t))return{text:t};let e=bn.exec(t);if(e===null)return{text:t};let r=e[1]??"",n=e[2]??"";return r!=="define"?{text:t,directive:r,rest:n}:{text:t,directive:r,rest:n,define:In(n)}}function Ft(t,e,r){let n=typeof t=="string"?Dt(t):t,s=_e.dirname(e),o=[],_=()=>o.every(l=>l.active);for(let l=0;l<n.length;l++){let d=n[l];if(d===void 0||d.directive===void 0){_()&&(l=Nn(r,n,l,e));continue}let u=d.directive,E=d.rest??"";switch(u){case"ifdef":case"ifndef":{let g=E.trim().split(/\s+/)[0]??"",h=r.macros.has(g)===(u==="ifdef"),S=_();o.push({active:S&&h,taken:h,parentActive:S});break}case"if":{let g=_(),h=g&&(xt(r,()=>Mt(E,r.expander,r.macros,e,l+1))??!1);o.push({active:h,taken:h,parentActive:g});break}case"else":{let g=o[o.length-1];if(g===void 0){if(!H(r,new M("#else without #if",e,l+1)))return;break}g.active=g.parentActive&&!g.taken,g.taken=!0;break}case"endif":{if(o.pop()===void 0&&!H(r,new M("#endif without #if",e,l+1)))return;break}case"elif":{let g=o[o.length-1];if(g===void 0){if(!H(r,new M("#elif without #if",e,l+1)))return;break}if(g.taken){g.active=!1;break}let h=g.parentActive&&(xt(r,()=>Mt(E,r.expander,r.macros,e,l+1))??!1);g.active=h,g.taken=h;break}case"define":{if(!_())break;let g=d.define;if(g===void 0)break;if("error"in g){if(!H(r,new M(g.error,e,l+1)))return;break}r.macros.set(g.name,g);break}case"undef":{if(!_())break;r.macros.delete(E.trim().split(/\s+/)[0]??"");break}case"include":{if(!_())break;let g=kt.exec(E);if(g===null&&(g=kt.exec(r.expander.expandText(E))),g===null){if(!H(r,new M(`malformed #include: ${E.trim()}`,e,l+1)))return;break}let h=g[1]??g[2]??"",S=On(h,s,r.options);if(S===null){if(!H(r,new M(`cannot find include "${h}"`,e,l+1)))return;break}r.depth++,Pn(S,r),r.depth--;break}case"pragma":_()&&(r.out.push(d.text),r.origins.push({file:e,line:l+1}));break;case"error":if(_()&&!H(r,new M(`#error ${E.trim()}`,e,l+1)))return;break;case"line":break;case"":break;default:if(!H(r,new M(Rn.has(u)?`#${u} is not supported`:`unknown directive #${u}`,e,l+1)))return}}o.length>0&&H(r,new M("unterminated #if",e,n.length))}function Bt(t,e,r={}){return Mn(r,n=>Ft(t,_e.resolve(e),n))}function Mn(t,e){let r=new Map;for(let[o,_]of Object.entries(t.defines??{}))r.set(o,{name:o,params:null,body:_,variadic:!1});let n={macros:r,expander:new He(r),out:[],origins:[],options:t,depth:0,errors:[]};e(n);let s=n.errors[0];if(s)throw new M(s.detail,s.file,s.line,n.errors);return{text:n.out.join(`
7
+ `),origins:n.origins}}function We(t){if(t instanceof M)return t.all.map(n=>({file:n.file,line:n.line,column:0,message:n.message}));if(t instanceof Y&&t.diagnostics.length>0)return t.diagnostics.map(n=>({...n.file===void 0?{}:{file:n.file},line:n.line,column:n.column,message:n.message}));if(t instanceof R)return t.all.map(n=>({line:n.line,column:n.column,message:n.detail}));let e=t instanceof Error?t.message:String(t),r=/^(\d+):(\d+): (.*)$/s.exec(e);return r?[{line:Number(r[1]),column:Number(r[2]),message:r[3]}]:[{line:1,column:0,message:e}]}function kn(t,e,r={}){let n=t.parse(e);if(n===null)throw new Y([{line:1,column:1,message:"parser returned no tree"}]);try{let s=it(n.rootNode);if(s.length>0)throw new Y(s.map(o=>({line:o.startPosition.row+1,column:o.startPosition.column+1,message:o.isMissing?`missing ${o.type}`:"syntax error"})));return Nt(It(n,r),r)}finally{n.delete()}}function xn(t,e={}){return ft(t,{...e,shortCircuit:e.shortCircuit===!0||t.shortCircuit===!0,dropUnreachableEpilogue:(e.level??0)>=2})}function Dn(t,e,r={}){return xn(kn(t,e,r),r)}function Gt(t,e,r,n={}){let s=[],o=n.onWarning,_={...n,onWarning:n.noWarnings?void 0:l=>{s.push(l),o?.(l)}};try{let l=Bt(e,r,n.preprocess);return{bytes:Fn(t,l,r,_),problems:[],warnings:s}}catch(l){return{problems:We(l),warnings:s}}}function Fn(t,e,r,n={}){try{return Dn(t,e.text,Bn(n,e,r))}catch(s){throw Un(s,e,r)}}function Vt(t,e,r){let n=t.origins[r-1];return n?n.file===Ut.resolve(e)?{line:n.line}:{file:n.file,line:n.line}:{line:r}}function Bn(t,e,r){let n=t.onWarning;return n?{...t,onWarning:s=>n({...s,...Vt(e,r,s.line)})}:t}function Un(t,e,r){return t instanceof Y||t instanceof R||t instanceof $?new Y(We(t).map(n=>({column:n.column,message:n.message,...Vt(e,r,n.line)}))):t}var Gn=Object.defineProperty,p=(t,e)=>Gn(t,"name",{value:e,configurable:!0}),Qs=class{static{p(this,"Edit")}startPosition;oldEndPosition;newEndPosition;startIndex;oldEndIndex;newEndIndex;constructor({startIndex:t,oldEndIndex:e,newEndIndex:r,startPosition:n,oldEndPosition:s,newEndPosition:o}){this.startIndex=t>>>0,this.oldEndIndex=e>>>0,this.newEndIndex=r>>>0,this.startPosition=n,this.oldEndPosition=s,this.newEndPosition=o}editPoint(t,e){let r=e,n={...t};if(e>=this.oldEndIndex){r=this.newEndIndex+(e-this.oldEndIndex);let s=t.row;n.row=this.newEndPosition.row+(t.row-this.oldEndPosition.row),n.column=s===this.oldEndPosition.row?this.newEndPosition.column+(t.column-this.oldEndPosition.column):t.column}else e>this.startIndex&&(r=this.newEndIndex,n.row=this.newEndPosition.row,n.column=this.newEndPosition.column);return{point:n,index:r}}editRange(t){let e={startIndex:t.startIndex,startPosition:{...t.startPosition},endIndex:t.endIndex,endPosition:{...t.endPosition}};return t.endIndex>=this.oldEndIndex?t.endIndex!==Number.MAX_SAFE_INTEGER&&(e.endIndex=this.newEndIndex+(t.endIndex-this.oldEndIndex),e.endPosition={row:this.newEndPosition.row+(t.endPosition.row-this.oldEndPosition.row),column:t.endPosition.row===this.oldEndPosition.row?this.newEndPosition.column+(t.endPosition.column-this.oldEndPosition.column):t.endPosition.column},e.endIndex<this.newEndIndex&&(e.endIndex=Number.MAX_SAFE_INTEGER,e.endPosition={row:Number.MAX_SAFE_INTEGER,column:Number.MAX_SAFE_INTEGER})):t.endIndex>this.startIndex&&(e.endIndex=this.startIndex,e.endPosition={...this.startPosition}),t.startIndex>=this.oldEndIndex?(e.startIndex=this.newEndIndex+(t.startIndex-this.oldEndIndex),e.startPosition={row:this.newEndPosition.row+(t.startPosition.row-this.oldEndPosition.row),column:t.startPosition.row===this.oldEndPosition.row?this.newEndPosition.column+(t.startPosition.column-this.oldEndPosition.column):t.startPosition.column},e.startIndex<this.newEndIndex&&(e.startIndex=Number.MAX_SAFE_INTEGER,e.startPosition={row:Number.MAX_SAFE_INTEGER,column:Number.MAX_SAFE_INTEGER})):t.startIndex>this.startIndex&&(e.startIndex=this.startIndex,e.startPosition={...this.startPosition}),e}},Ht=2,b=4,Ke=4*b,D=5*b,J=2*b,fe=2*b+2*J,x={row:0,column:0},ee=Symbol("INTERNAL");function le(t){if(t!==ee)throw new Error("Illegal constructor")}p(le,"assertInternal");function he(t){return!!t&&typeof t.row=="number"&&typeof t.column=="number"}p(he,"isPoint");function Kt(t){c=t}p(Kt,"setModule");var c,Vn=class{static{p(this,"LookaheadIterator")}0=0;language;constructor(t,e,r){le(t),this[0]=e,this.language=r}get currentTypeId(){return c._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){c._ts_lookahead_iterator_delete(this[0]),this[0]=0}reset(t,e){return c._ts_lookahead_iterator_reset(this[0],t[0],e)?(this.language=t,!0):!1}resetState(t){return!!c._ts_lookahead_iterator_reset_state(this[0],t)}[Symbol.iterator](){return{next:p(()=>c._ts_lookahead_iterator_next(this[0])?{done:!1,value:this.currentType}:{done:!0,value:""},"next")}}};function $e(t,e,r,n){let s=r-e,o=t.textCallback(e,n);if(o){for(e+=o.length;e<r;){let _=t.textCallback(e,n);if(_&&_.length>0)e+=_.length,o+=_;else break}e>r&&(o=o.slice(0,s))}return o??""}p($e,"getText");var Hn=class Je{static{p(this,"Tree")}0=0;textCallback;language;constructor(e,r,n,s){le(e),this[0]=r,this.language=n,this.textCallback=s}copy(){let e=c._ts_tree_copy(this[0]);return new Je(ee,e,this.language,this.textCallback)}delete(){c._ts_tree_delete(this[0]),this[0]=0}get rootNode(){return c._ts_tree_root_node_wasm(this[0]),v(this)}rootNodeWithOffset(e,r){let n=A+D;return c.setValue(n,e,"i32"),G(n+b,r),c._ts_tree_root_node_with_offset_wasm(this[0]),v(this)}edit(e){Jt(e),c._ts_tree_edit_wasm(this[0])}walk(){return this.rootNode.walk()}getChangedRanges(e){if(!(e instanceof Je))throw new TypeError("Argument must be a Tree");c._ts_tree_get_changed_ranges_wasm(this[0],e[0]);let r=c.getValue(A,"i32"),n=c.getValue(A+b,"i32"),s=new Array(r);if(r>0){let o=n;for(let _=0;_<r;_++)s[_]=Ne(o),o+=fe;c._free(n)}return s}getIncludedRanges(){c._ts_tree_included_ranges_wasm(this[0]);let e=c.getValue(A,"i32"),r=c.getValue(A+b,"i32"),n=new Array(e);if(e>0){let s=r;for(let o=0;o<e;o++)n[o]=Ne(s),s+=fe;c._free(r)}return n}},Wn=class Yt{static{p(this,"TreeCursor")}0=0;1=0;2=0;3=0;tree;constructor(e,r){le(e),this.tree=r,B(this)}copy(){let e=new Yt(ee,this.tree);return c._ts_tree_cursor_copy_wasm(this.tree[0]),B(e),e}delete(){N(this),c._ts_tree_cursor_delete_wasm(this.tree[0]),this[0]=this[1]=this[2]=0}get currentNode(){return N(this),c._ts_tree_cursor_current_node_wasm(this.tree[0]),v(this.tree)}get currentFieldId(){return N(this),c._ts_tree_cursor_current_field_id_wasm(this.tree[0])}get currentFieldName(){return this.tree.language.fields[this.currentFieldId]}get currentDepth(){return N(this),c._ts_tree_cursor_current_depth_wasm(this.tree[0])}get currentDescendantIndex(){return N(this),c._ts_tree_cursor_current_descendant_index_wasm(this.tree[0])}get nodeType(){return this.tree.language.types[this.nodeTypeId]||"ERROR"}get nodeTypeId(){return N(this),c._ts_tree_cursor_current_node_type_id_wasm(this.tree[0])}get nodeStateId(){return N(this),c._ts_tree_cursor_current_node_state_id_wasm(this.tree[0])}get nodeId(){return N(this),c._ts_tree_cursor_current_node_id_wasm(this.tree[0])}get nodeIsNamed(){return N(this),c._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])===1}get nodeIsMissing(){return N(this),c._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])===1}get nodeText(){N(this);let e=c._ts_tree_cursor_start_index_wasm(this.tree[0]),r=c._ts_tree_cursor_end_index_wasm(this.tree[0]);c._ts_tree_cursor_start_position_wasm(this.tree[0]);let n=se(A);return $e(this.tree,e,r,n)}get startPosition(){return N(this),c._ts_tree_cursor_start_position_wasm(this.tree[0]),se(A)}get endPosition(){return N(this),c._ts_tree_cursor_end_position_wasm(this.tree[0]),se(A)}get startIndex(){return N(this),c._ts_tree_cursor_start_index_wasm(this.tree[0])}get endIndex(){return N(this),c._ts_tree_cursor_end_index_wasm(this.tree[0])}gotoFirstChild(){N(this);let e=c._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return B(this),e===1}gotoLastChild(){N(this);let e=c._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);return B(this),e===1}gotoParent(){N(this);let e=c._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return B(this),e===1}gotoNextSibling(){N(this);let e=c._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return B(this),e===1}gotoPreviousSibling(){N(this);let e=c._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);return B(this),e===1}gotoDescendant(e){N(this),c._ts_tree_cursor_goto_descendant_wasm(this.tree[0],e),B(this)}gotoFirstChildForIndex(e){N(this),c.setValue(A+Ke,e,"i32");let r=c._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);return B(this),r===1}gotoFirstChildForPosition(e){N(this),G(A+Ke,e);let r=c._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);return B(this),r===1}reset(e){I(e),N(this,A+D),c._ts_tree_cursor_reset_wasm(this.tree[0]),B(this)}resetTo(e){N(this,A),N(e,A+Ke),c._ts_tree_cursor_reset_to_wasm(this.tree[0],e.tree[0]),B(this)}},Kn=class{static{p(this,"Node")}0=0;_children;_namedChildren;constructor(t,{id:e,tree:r,startIndex:n,startPosition:s,other:o}){le(t),this[0]=o,this.id=e,this.tree=r,this.startIndex=n,this.startPosition=s}id;startIndex;startPosition;tree;get typeId(){return I(this),c._ts_node_symbol_wasm(this.tree[0])}get grammarId(){return I(this),c._ts_node_grammar_symbol_wasm(this.tree[0])}get type(){return this.tree.language.types[this.typeId]||"ERROR"}get grammarType(){return this.tree.language.types[this.grammarId]||"ERROR"}get isNamed(){return I(this),c._ts_node_is_named_wasm(this.tree[0])===1}get isExtra(){return I(this),c._ts_node_is_extra_wasm(this.tree[0])===1}get isError(){return I(this),c._ts_node_is_error_wasm(this.tree[0])===1}get isMissing(){return I(this),c._ts_node_is_missing_wasm(this.tree[0])===1}get hasChanges(){return I(this),c._ts_node_has_changes_wasm(this.tree[0])===1}get hasError(){return I(this),c._ts_node_has_error_wasm(this.tree[0])===1}get endIndex(){return I(this),c._ts_node_end_index_wasm(this.tree[0])}get endPosition(){return I(this),c._ts_node_end_point_wasm(this.tree[0]),se(A)}get text(){return $e(this.tree,this.startIndex,this.endIndex,this.startPosition)}get parseState(){return I(this),c._ts_node_parse_state_wasm(this.tree[0])}get nextParseState(){return I(this),c._ts_node_next_parse_state_wasm(this.tree[0])}equals(t){return this.tree===t.tree&&this.id===t.id}child(t){return I(this),c._ts_node_child_wasm(this.tree[0],t),v(this.tree)}namedChild(t){return I(this),c._ts_node_named_child_wasm(this.tree[0],t),v(this.tree)}childForFieldId(t){return I(this),c._ts_node_child_by_field_id_wasm(this.tree[0],t),v(this.tree)}childForFieldName(t){let e=this.tree.language.fields.indexOf(t);return e!==-1?this.childForFieldId(e):null}fieldNameForChild(t){I(this);let e=c._ts_node_field_name_for_child_wasm(this.tree[0],t);return e?c.AsciiToString(e):null}fieldNameForNamedChild(t){I(this);let e=c._ts_node_field_name_for_named_child_wasm(this.tree[0],t);return e?c.AsciiToString(e):null}childrenForFieldName(t){let e=this.tree.language.fields.indexOf(t);return e!==-1&&e!==0?this.childrenForFieldId(e):[]}childrenForFieldId(t){I(this),c._ts_node_children_by_field_id_wasm(this.tree[0],t);let e=c.getValue(A,"i32"),r=c.getValue(A+b,"i32"),n=new Array(e);if(e>0){let s=r;for(let o=0;o<e;o++)n[o]=v(this.tree,s),s+=D;c._free(r)}return n}firstChildForIndex(t){I(this);let e=A+D;return c.setValue(e,t,"i32"),c._ts_node_first_child_for_byte_wasm(this.tree[0]),v(this.tree)}firstNamedChildForIndex(t){I(this);let e=A+D;return c.setValue(e,t,"i32"),c._ts_node_first_named_child_for_byte_wasm(this.tree[0]),v(this.tree)}get childCount(){return I(this),c._ts_node_child_count_wasm(this.tree[0])}get namedChildCount(){return I(this),c._ts_node_named_child_count_wasm(this.tree[0])}get firstChild(){return this.child(0)}get firstNamedChild(){return this.namedChild(0)}get lastChild(){return this.child(this.childCount-1)}get lastNamedChild(){return this.namedChild(this.namedChildCount-1)}get children(){if(!this._children){I(this),c._ts_node_children_wasm(this.tree[0]);let t=c.getValue(A,"i32"),e=c.getValue(A+b,"i32");if(this._children=new Array(t),t>0){let r=e;for(let n=0;n<t;n++)this._children[n]=v(this.tree,r),r+=D;c._free(e)}}return this._children}get namedChildren(){if(!this._namedChildren){I(this),c._ts_node_named_children_wasm(this.tree[0]);let t=c.getValue(A,"i32"),e=c.getValue(A+b,"i32");if(this._namedChildren=new Array(t),t>0){let r=e;for(let n=0;n<t;n++)this._namedChildren[n]=v(this.tree,r),r+=D;c._free(e)}}return this._namedChildren}descendantsOfType(t,e=x,r=x){Array.isArray(t)||(t=[t]);let n=[],s=this.tree.language.types;for(let u of t)u=="ERROR"&&n.push(65535);for(let u=0,E=s.length;u<E;u++)t.includes(s[u])&&n.push(u);let o=c._malloc(b*n.length);for(let u=0,E=n.length;u<E;u++)c.setValue(o+u*b,n[u],"i32");I(this),c._ts_node_descendants_of_type_wasm(this.tree[0],o,n.length,e.row,e.column,r.row,r.column);let _=c.getValue(A,"i32"),l=c.getValue(A+b,"i32"),d=new Array(_);if(_>0){let u=l;for(let E=0;E<_;E++)d[E]=v(this.tree,u),u+=D}return c._free(l),c._free(o),d}get nextSibling(){return I(this),c._ts_node_next_sibling_wasm(this.tree[0]),v(this.tree)}get previousSibling(){return I(this),c._ts_node_prev_sibling_wasm(this.tree[0]),v(this.tree)}get nextNamedSibling(){return I(this),c._ts_node_next_named_sibling_wasm(this.tree[0]),v(this.tree)}get previousNamedSibling(){return I(this),c._ts_node_prev_named_sibling_wasm(this.tree[0]),v(this.tree)}get descendantCount(){return I(this),c._ts_node_descendant_count_wasm(this.tree[0])}get parent(){return I(this),c._ts_node_parent_wasm(this.tree[0]),v(this.tree)}childWithDescendant(t){return I(this),I(t,1),c._ts_node_child_with_descendant_wasm(this.tree[0]),v(this.tree)}descendantForIndex(t,e=t){if(typeof t!="number"||typeof e!="number")throw new Error("Arguments must be numbers");I(this);let r=A+D;return c.setValue(r,t,"i32"),c.setValue(r+b,e,"i32"),c._ts_node_descendant_for_index_wasm(this.tree[0]),v(this.tree)}namedDescendantForIndex(t,e=t){if(typeof t!="number"||typeof e!="number")throw new Error("Arguments must be numbers");I(this);let r=A+D;return c.setValue(r,t,"i32"),c.setValue(r+b,e,"i32"),c._ts_node_named_descendant_for_index_wasm(this.tree[0]),v(this.tree)}descendantForPosition(t,e=t){if(!he(t)||!he(e))throw new Error("Arguments must be {row, column} objects");I(this);let r=A+D;return G(r,t),G(r+J,e),c._ts_node_descendant_for_position_wasm(this.tree[0]),v(this.tree)}namedDescendantForPosition(t,e=t){if(!he(t)||!he(e))throw new Error("Arguments must be {row, column} objects");I(this);let r=A+D;return G(r,t),G(r+J,e),c._ts_node_named_descendant_for_position_wasm(this.tree[0]),v(this.tree)}walk(){return I(this),c._ts_tree_cursor_new_wasm(this.tree[0]),new Wn(ee,this.tree)}edit(t){if(this.startIndex>=t.oldEndIndex){this.startIndex=t.newEndIndex+(this.startIndex-t.oldEndIndex);let e,r;this.startPosition.row>t.oldEndPosition.row?(e=this.startPosition.row-t.oldEndPosition.row,r=this.startPosition.column):(e=0,r=this.startPosition.column,this.startPosition.column>=t.oldEndPosition.column&&(r=this.startPosition.column-t.oldEndPosition.column)),e>0?(this.startPosition.row+=e,this.startPosition.column=r):this.startPosition.column+=r}else this.startIndex>t.startIndex&&(this.startIndex=t.newEndIndex,this.startPosition.row=t.newEndPosition.row,this.startPosition.column=t.newEndPosition.column)}toString(){I(this);let t=c._ts_node_to_string_wasm(this.tree[0]),e=c.AsciiToString(t);return c._free(t),e}};function je(t,e,r,n,s){for(let o=0,_=s.length;o<_;o++){let l=c.getValue(r,"i32");r+=b;let d=v(e,r);r+=D,s[o]={patternIndex:n,name:t.captureNames[l],node:d}}return r}p(je,"unmarshalCaptures");function I(t,e=0){let r=A+e*D;c.setValue(r,t.id,"i32"),r+=b,c.setValue(r,t.startIndex,"i32"),r+=b,c.setValue(r,t.startPosition.row,"i32"),r+=b,c.setValue(r,t.startPosition.column,"i32"),r+=b,c.setValue(r,t[0],"i32")}p(I,"marshalNode");function v(t,e=A){let r=c.getValue(e,"i32");if(e+=b,r===0)return null;let n=c.getValue(e,"i32");e+=b;let s=c.getValue(e,"i32");e+=b;let o=c.getValue(e,"i32");e+=b;let _=c.getValue(e,"i32");return new Kn(ee,{id:r,tree:t,startIndex:n,startPosition:{row:s,column:o},other:_})}p(v,"unmarshalNode");function N(t,e=A){c.setValue(e+0*b,t[0],"i32"),c.setValue(e+1*b,t[1],"i32"),c.setValue(e+2*b,t[2],"i32"),c.setValue(e+3*b,t[3],"i32")}p(N,"marshalTreeCursor");function B(t){t[0]=c.getValue(A+0*b,"i32"),t[1]=c.getValue(A+1*b,"i32"),t[2]=c.getValue(A+2*b,"i32"),t[3]=c.getValue(A+3*b,"i32")}p(B,"unmarshalTreeCursor");function G(t,e){c.setValue(t,e.row,"i32"),c.setValue(t+b,e.column,"i32")}p(G,"marshalPoint");function se(t){return{row:c.getValue(t,"i32")>>>0,column:c.getValue(t+b,"i32")>>>0}}p(se,"unmarshalPoint");function Xt(t,e){G(t,e.startPosition),t+=J,G(t,e.endPosition),t+=J,c.setValue(t,e.startIndex,"i32"),t+=b,c.setValue(t,e.endIndex,"i32"),t+=b}p(Xt,"marshalRange");function Ne(t){let e={};return e.startPosition=se(t),t+=J,e.endPosition=se(t),t+=J,e.startIndex=c.getValue(t,"i32")>>>0,t+=b,e.endIndex=c.getValue(t,"i32")>>>0,e}p(Ne,"unmarshalRange");function Jt(t,e=A){G(e,t.startPosition),e+=J,G(e,t.oldEndPosition),e+=J,G(e,t.newEndPosition),e+=J,c.setValue(e,t.startIndex,"i32"),e+=b,c.setValue(e,t.oldEndIndex,"i32"),e+=b,c.setValue(e,t.newEndIndex,"i32"),e+=b}p(Jt,"marshalEdit");function jt(t){let e=c.getValue(t,"i32"),r=c.getValue(t+=b,"i32"),n=c.getValue(t+=b,"i32");return{major_version:e,minor_version:r,patch_version:n}}p(jt,"unmarshalLanguageMetadata");var Yn=/^tree_sitter_\w+$/,qe=class $t{static{p(this,"Language")}0=0;types;fields;constructor(e,r){le(e),this[0]=r,this.types=new Array(c._ts_language_symbol_count(this[0]));for(let n=0,s=this.types.length;n<s;n++)c._ts_language_symbol_type(this[0],n)<2&&(this.types[n]=c.UTF8ToString(c._ts_language_symbol_name(this[0],n)));this.fields=new Array(c._ts_language_field_count(this[0])+1);for(let n=0,s=this.fields.length;n<s;n++){let o=c._ts_language_field_name_for_id(this[0],n);o!==0?this.fields[n]=c.UTF8ToString(o):this.fields[n]=null}}get name(){let e=c._ts_language_name(this[0]);return e===0?null:c.UTF8ToString(e)}get abiVersion(){return c._ts_language_abi_version(this[0])}get metadata(){return c._ts_language_metadata_wasm(this[0]),c.getValue(A,"i32")===0?null:jt(A+b)}get fieldCount(){return this.fields.length-1}get stateCount(){return c._ts_language_state_count(this[0])}fieldIdForName(e){let r=this.fields.indexOf(e);return r!==-1?r:null}fieldNameForId(e){return this.fields[e]??null}idForNodeType(e,r){let n=c.lengthBytesUTF8(e),s=c._malloc(n+1);c.stringToUTF8(e,s,n+1);let o=c._ts_language_symbol_for_name(this[0],s,n,r?1:0);return c._free(s),o||null}get nodeTypeCount(){return c._ts_language_symbol_count(this[0])}nodeTypeForId(e){let r=c._ts_language_symbol_name(this[0],e);return r?c.UTF8ToString(r):null}nodeTypeIsNamed(e){return!!c._ts_language_type_is_named_wasm(this[0],e)}nodeTypeIsVisible(e){return!!c._ts_language_type_is_visible_wasm(this[0],e)}get supertypes(){c._ts_language_supertypes_wasm(this[0]);let e=c.getValue(A,"i32"),r=c.getValue(A+b,"i32"),n=new Array(e);if(e>0){let s=r;for(let o=0;o<e;o++)n[o]=c.getValue(s,"i16"),s+=Ht}return n}subtypes(e){c._ts_language_subtypes_wasm(this[0],e);let r=c.getValue(A,"i32"),n=c.getValue(A+b,"i32"),s=new Array(r);if(r>0){let o=n;for(let _=0;_<r;_++)s[_]=c.getValue(o,"i16"),o+=Ht}return s}nextState(e,r){return c._ts_language_next_state(this[0],e,r)}lookaheadIterator(e){let r=c._ts_lookahead_iterator_new(this[0],e);return r?new Vn(ee,r,this):null}static async load(e){let r;if(e instanceof Uint8Array)r=e;else if(globalThis.process?.versions.node)r=await(await import("fs/promises")).readFile(e);else{let l=await fetch(e);if(!l.ok){let u=await l.text();throw new Error(`Language.load failed with status ${l.status}.
8
+
9
+ ${u}`)}let d=l.clone();try{r=await WebAssembly.compileStreaming(l)}catch(u){console.error("wasm streaming compile failed:",u),console.error("falling back to ArrayBuffer instantiation"),r=new Uint8Array(await d.arrayBuffer())}}let n=await c.loadWebAssemblyModule(r,{loadAsync:!0}),s=Object.keys(n),o=s.find(l=>Yn.test(l)&&!l.includes("external_scanner_"));if(!o)throw console.log(`Couldn't find language function in Wasm file. Symbols:
10
+ ${JSON.stringify(s,null,2)}`),new Error("Language.load failed: no language function found in Wasm file");let _=n[o]();return new $t(ee,_)}};async function qt(moduleArg={}){var moduleRtn,Module=moduleArg,ENVIRONMENT_IS_WEB=typeof window=="object",ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope<"u",ENVIRONMENT_IS_NODE=typeof process=="object"&&process.versions?.node&&process.type!="renderer";if(ENVIRONMENT_IS_NODE){let{createRequire:t}=await import("module");var require=t(__imu)}Module.currentQueryProgressCallback=null,Module.currentProgressCallback=null,Module.currentLogCallback=null,Module.currentParseCallback=null;var arguments_=[],thisProgram="./this.program",quit_=p((t,e)=>{throw e},"quit_"),_scriptName=__imu,scriptDirectory="";function locateFile(t){return Module.locateFile?Module.locateFile(t,scriptDirectory):scriptDirectory+t}p(locateFile,"locateFile");var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");_scriptName.startsWith("file:")&&(scriptDirectory=require("path").dirname(require("url").fileURLToPath(_scriptName))+"/"),readBinary=p(t=>{t=isFileURI(t)?new URL(t):t;var e=fs.readFileSync(t);return e},"readBinary"),readAsync=p(async(t,e=!0)=>{t=isFileURI(t)?new URL(t):t;var r=fs.readFileSync(t,e?void 0:"utf8");return r},"readAsync"),process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),quit_=p((t,e)=>{throw process.exitCode=t,e},"quit_")}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}ENVIRONMENT_IS_WORKER&&(readBinary=p(t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)},"readBinary")),readAsync=p(async t=>{if(isFileURI(t))return new Promise((r,n)=>{var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="arraybuffer",s.onload=()=>{if(s.status==200||s.status==0&&s.response){r(s.response);return}n(s.status)},s.onerror=n,s.send(null)});var e=await fetch(t,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)},"readAsync")}var out=console.log.bind(console),err=console.error.bind(console),dynamicLibraries=[],wasmBinary,ABORT=!1,EXITSTATUS,isFileURI=p(t=>t.startsWith("file://"),"isFileURI"),readyPromiseResolve,readyPromiseReject,wasmMemory,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64,HEAP64,HEAPU64,HEAP_DATA_VIEW,runtimeInitialized=!1;function updateMemoryViews(){var t=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(t),Module.HEAP16=HEAP16=new Int16Array(t),Module.HEAPU8=HEAPU8=new Uint8Array(t),Module.HEAPU16=HEAPU16=new Uint16Array(t),Module.HEAP32=HEAP32=new Int32Array(t),Module.HEAPU32=HEAPU32=new Uint32Array(t),Module.HEAPF32=HEAPF32=new Float32Array(t),Module.HEAPF64=HEAPF64=new Float64Array(t),Module.HEAP64=HEAP64=new BigInt64Array(t),Module.HEAPU64=HEAPU64=new BigUint64Array(t),Module.HEAP_DATA_VIEW=HEAP_DATA_VIEW=new DataView(t),LE_HEAP_UPDATE()}p(updateMemoryViews,"updateMemoryViews");function initMemory(){if(Module.wasmMemory)wasmMemory=Module.wasmMemory;else{var t=Module.INITIAL_MEMORY||33554432;wasmMemory=new WebAssembly.Memory({initial:t/65536,maximum:32768})}updateMemoryViews()}p(initMemory,"initMemory");var __RELOC_FUNCS__=[];function preRun(){if(Module.preRun)for(typeof Module.preRun=="function"&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(onPreRuns)}p(preRun,"preRun");function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),wasmExports.__wasm_call_ctors(),callRuntimeCallbacks(onPostCtors)}p(initRuntime,"initRuntime");function preMain(){}p(preMain,"preMain");function postRun(){if(Module.postRun)for(typeof Module.postRun=="function"&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(onPostRuns)}p(postRun,"postRun");function abort(t){Module.onAbort?.(t),t="Aborted("+t+")",err(t),ABORT=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw readyPromiseReject?.(e),e}p(abort,"abort");var wasmBinaryFile;function findWasmBinary(){return Module.locateFile?locateFile("web-tree-sitter.wasm"):new URL("web-tree-sitter.wasm",__imu).href}p(findWasmBinary,"findWasmBinary");function getBinarySync(t){if(t==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(t);throw"both async and sync fetching of the wasm failed"}p(getBinarySync,"getBinarySync");async function getWasmBinary(t){if(!wasmBinary)try{var e=await readAsync(t);return new Uint8Array(e)}catch{}return getBinarySync(t)}p(getWasmBinary,"getWasmBinary");async function instantiateArrayBuffer(t,e){try{var r=await getWasmBinary(t),n=await WebAssembly.instantiate(r,e);return n}catch(s){err(`failed to asynchronously prepare wasm: ${s}`),abort(s)}}p(instantiateArrayBuffer,"instantiateArrayBuffer");async function instantiateAsync(t,e,r){if(!t&&!isFileURI(e)&&!ENVIRONMENT_IS_NODE)try{var n=fetch(e,{credentials:"same-origin"}),s=await WebAssembly.instantiateStreaming(n,r);return s}catch(o){err(`wasm streaming compile failed: ${o}`),err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(e,r)}p(instantiateAsync,"instantiateAsync");function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)}}p(getWasmImports,"getWasmImports");async function createWasm(){function t(o,_){wasmExports=o.exports,wasmExports=relocateExports(wasmExports,1024);var l=getDylinkMetadata(_);return l.neededDynlibs&&(dynamicLibraries=l.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports,"main"),LDSO.init(),loadDylibs(),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),assignWasmExports(wasmExports),wasmExports}p(t,"receiveInstance");function e(o){return t(o.instance,o.module)}p(e,"receiveInstantiationResult");var r=getWasmImports();if(Module.instantiateWasm)return new Promise((o,_)=>{Module.instantiateWasm(r,(l,d)=>{o(t(l,d))})});wasmBinaryFile??=findWasmBinary();var n=await instantiateAsync(wasmBinary,wasmBinaryFile,r),s=e(n);return s}p(createWasm,"createWasm");class ExitStatus{static{p(this,"ExitStatus")}name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(t,e){var r=GOT[e];return r||(r=GOT[e]=new WebAssembly.Global({value:"i32",mutable:!0})),currentModuleWeakSymbols.has(e)||(r.required=!0),r}},LE_ATOMICS_NATIVE_BYTE_ORDER=[],LE_HEAP_LOAD_F32=p(t=>HEAP_DATA_VIEW.getFloat32(t,!0),"LE_HEAP_LOAD_F32"),LE_HEAP_LOAD_F64=p(t=>HEAP_DATA_VIEW.getFloat64(t,!0),"LE_HEAP_LOAD_F64"),LE_HEAP_LOAD_I16=p(t=>HEAP_DATA_VIEW.getInt16(t,!0),"LE_HEAP_LOAD_I16"),LE_HEAP_LOAD_I32=p(t=>HEAP_DATA_VIEW.getInt32(t,!0),"LE_HEAP_LOAD_I32"),LE_HEAP_LOAD_I64=p(t=>HEAP_DATA_VIEW.getBigInt64(t,!0),"LE_HEAP_LOAD_I64"),LE_HEAP_LOAD_U32=p(t=>HEAP_DATA_VIEW.getUint32(t,!0),"LE_HEAP_LOAD_U32"),LE_HEAP_STORE_F32=p((t,e)=>HEAP_DATA_VIEW.setFloat32(t,e,!0),"LE_HEAP_STORE_F32"),LE_HEAP_STORE_F64=p((t,e)=>HEAP_DATA_VIEW.setFloat64(t,e,!0),"LE_HEAP_STORE_F64"),LE_HEAP_STORE_I16=p((t,e)=>HEAP_DATA_VIEW.setInt16(t,e,!0),"LE_HEAP_STORE_I16"),LE_HEAP_STORE_I32=p((t,e)=>HEAP_DATA_VIEW.setInt32(t,e,!0),"LE_HEAP_STORE_I32"),LE_HEAP_STORE_I64=p((t,e)=>HEAP_DATA_VIEW.setBigInt64(t,e,!0),"LE_HEAP_STORE_I64"),LE_HEAP_STORE_U32=p((t,e)=>HEAP_DATA_VIEW.setUint32(t,e,!0),"LE_HEAP_STORE_U32"),callRuntimeCallbacks=p(t=>{for(;t.length>0;)t.shift()(Module)},"callRuntimeCallbacks"),onPostRuns=[],addOnPostRun=p(t=>onPostRuns.push(t),"addOnPostRun"),onPreRuns=[],addOnPreRun=p(t=>onPreRuns.push(t),"addOnPreRun"),UTF8Decoder=typeof TextDecoder<"u"?new TextDecoder:void 0,findStringEnd=p((t,e,r,n)=>{var s=e+r;if(n)return s;for(;t[e]&&!(e>=s);)++e;return e},"findStringEnd"),UTF8ArrayToString=p((t,e=0,r,n)=>{var s=findStringEnd(t,e,r,n);if(s-e>16&&t.buffer&&UTF8Decoder)return UTF8Decoder.decode(t.subarray(e,s));for(var o="";e<s;){var _=t[e++];if(!(_&128)){o+=String.fromCharCode(_);continue}var l=t[e++]&63;if((_&224)==192){o+=String.fromCharCode((_&31)<<6|l);continue}var d=t[e++]&63;if((_&240)==224?_=(_&15)<<12|l<<6|d:_=(_&7)<<18|l<<12|d<<6|t[e++]&63,_<65536)o+=String.fromCharCode(_);else{var u=_-65536;o+=String.fromCharCode(55296|u>>10,56320|u&1023)}}return o},"UTF8ArrayToString"),getDylinkMetadata=p(t=>{var e=0,r=0;function n(){return t[e++]}p(n,"getU8");function s(){for(var K=0,ne=1;;){var st=t[e++];if(K+=(st&127)*ne,ne*=128,!(st&128))break}return K}p(s,"getLEB");function o(){var K=s();return e+=K,UTF8ArrayToString(t,e-K,K)}p(o,"getString");function _(){for(var K=s(),ne=[];K--;)ne.push(o());return ne}p(_,"getStringList");function l(K,ne){if(K)throw new Error(ne)}if(p(l,"failIf"),t instanceof WebAssembly.Module){var d=WebAssembly.Module.customSections(t,"dylink.0");l(d.length===0,"need dylink section"),t=new Uint8Array(d[0]),r=t.length}else{var u=new Uint32Array(new Uint8Array(t.subarray(0,24)).buffer),E=u[0]==1836278016||u[0]==6386541;l(!E,"need to see wasm magic number"),l(t[8]!==0,"need the dylink section to be first"),e=9;var g=s();r=e+g;var h=o();l(h!=="dylink.0")}for(var S={neededDynlibs:[],tlsExports:new Set,weakImports:new Set,runtimePaths:[]},O=1,L=2,m=3,w=4,y=5,C=256,P=3,Q=1;e<r;){var F=n(),k=s();if(F===O)S.memorySize=s(),S.memoryAlign=s(),S.tableSize=s(),S.tableAlign=s();else if(F===L)S.neededDynlibs=_();else if(F===m)for(var te=s();te--;){var re=o(),ce=s();ce&C&&S.tlsExports.add(re)}else if(F===w)for(var te=s();te--;){var _s=o(),re=o(),ce=s();(ce&P)==Q&&S.weakImports.add(re)}else F===y?S.runtimePaths=_():e+=k}return S},"getDylinkMetadata");function getValue(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":return HEAP8[t];case"i8":return HEAP8[t];case"i16":return LE_HEAP_LOAD_I16((t>>1)*2);case"i32":return LE_HEAP_LOAD_I32((t>>2)*4);case"i64":return LE_HEAP_LOAD_I64((t>>3)*8);case"float":return LE_HEAP_LOAD_F32((t>>2)*4);case"double":return LE_HEAP_LOAD_F64((t>>3)*8);case"*":return LE_HEAP_LOAD_U32((t>>2)*4);default:abort(`invalid type for getValue: ${e}`)}}p(getValue,"getValue");var newDSO=p((t,e,r)=>{var n={refcount:1/0,name:t,exports:r,global:!0};return LDSO.loadedLibsByName[t]=n,e!=null&&(LDSO.loadedLibsByHandle[e]=n),n},"newDSO"),LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=78240,alignMemory=p((t,e)=>Math.ceil(t/e)*e,"alignMemory"),getMemory=p(t=>{if(runtimeInitialized)return _calloc(t,1);var e=___heap_base,r=e+alignMemory(t,16);return ___heap_base=r,GOT.__heap_base.value=r,e},"getMemory"),isInternalSym=p(t=>["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm","__start_em_js","__stop_em_js"].includes(t)||t.startsWith("__em_js__"),"isInternalSym"),uleb128EncodeWithLen=p(t=>{let e=t.length;return[e%128|128,e>>7,...t]},"uleb128EncodeWithLen"),wasmTypeCodes={i:127,p:127,j:126,f:125,d:124,e:111},generateTypePack=p(t=>uleb128EncodeWithLen(Array.from(t,e=>{var r=wasmTypeCodes[e];return r})),"generateTypePack"),convertJsFunctionToWasm=p((t,e)=>{var r=Uint8Array.of(0,97,115,109,1,0,0,0,1,...uleb128EncodeWithLen([1,96,...generateTypePack(e.slice(1)),...generateTypePack(e[0]==="v"?"":e[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),n=new WebAssembly.Module(r),s=new WebAssembly.Instance(n,{e:{f:t}}),o=s.exports.f;return o},"convertJsFunctionToWasm"),wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:31,element:"anyfunc"}),getWasmTableEntry=p(t=>{var e=wasmTableMirror[t];return e||(wasmTableMirror[t]=e=wasmTable.get(t)),e},"getWasmTableEntry"),updateTableMap=p((t,e)=>{if(functionsInTableMap)for(var r=t;r<t+e;r++){var n=getWasmTableEntry(r);n&&functionsInTableMap.set(n,r)}},"updateTableMap"),functionsInTableMap,getFunctionAddress=p(t=>(functionsInTableMap||(functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length)),functionsInTableMap.get(t)||0),"getFunctionAddress"),freeTableIndexes=[],getEmptyTableSlot=p(()=>freeTableIndexes.length?freeTableIndexes.pop():wasmTable.grow(1),"getEmptyTableSlot"),setWasmTableEntry=p((t,e)=>{wasmTable.set(t,e),wasmTableMirror[t]=wasmTable.get(t)},"setWasmTableEntry"),addFunction=p((t,e)=>{var r=getFunctionAddress(t);if(r)return r;var n=getEmptyTableSlot();try{setWasmTableEntry(n,t)}catch(o){if(!(o instanceof TypeError))throw o;var s=convertJsFunctionToWasm(t,e);setWasmTableEntry(n,s)}return functionsInTableMap.set(t,n),n},"addFunction"),updateGOT=p((t,e)=>{for(var r in t)if(!isInternalSym(r)){var n=t[r];GOT[r]||=new WebAssembly.Global({value:"i32",mutable:!0}),(e||GOT[r].value==0)&&(typeof n=="function"?GOT[r].value=addFunction(n):typeof n=="number"?GOT[r].value=n:err(`unhandled export type for '${r}': ${typeof n}`))}},"updateGOT"),relocateExports=p((t,e,r)=>{var n={};for(var s in t){var o=t[s];typeof o=="object"&&(o=o.value),typeof o=="number"&&(o+=e),n[s]=o}return updateGOT(n,r),n},"relocateExports"),isSymbolDefined=p(t=>{var e=wasmImports[t];return!(!e||e.stub)},"isSymbolDefined"),dynCall=p((t,e,r=[],n=!1)=>{var s=getWasmTableEntry(e),o=s(...r);function _(l){return l}return p(_,"convert"),o},"dynCall"),stackSave=p(()=>_emscripten_stack_get_current(),"stackSave"),stackRestore=p(t=>__emscripten_stack_restore(t),"stackRestore"),createInvokeFunction=p(t=>(e,...r)=>{var n=stackSave();try{return dynCall(t,e,r)}catch(s){if(stackRestore(n),s!==s+0)throw s;if(_setThrew(1,0),t[0]=="j")return 0n}},"createInvokeFunction"),resolveGlobalSymbol=p((t,e=!1)=>{var r;return isSymbolDefined(t)?r=wasmImports[t]:t.startsWith("invoke_")&&(r=wasmImports[t]=createInvokeFunction(t.split("_")[1])),{sym:r,name:t}},"resolveGlobalSymbol"),onPostCtors=[],addOnPostCtor=p(t=>onPostCtors.push(t),"addOnPostCtor"),UTF8ToString=p((t,e,r)=>t?UTF8ArrayToString(HEAPU8,t,e,r):"","UTF8ToString"),loadWebAssemblyModule=p((binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);function loadModule(){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;handle&&(HEAP8[handle+8]=1,LE_HEAP_STORE_U32((handle+12>>2)*4,memoryBase),LE_HEAP_STORE_I32((handle+16>>2)*4,metadata.memorySize),LE_HEAP_STORE_U32((handle+20>>2)*4,tableBase),LE_HEAP_STORE_I32((handle+24>>2)*4,metadata.tableSize)),metadata.tableSize&&wasmTable.grow(metadata.tableSize);var moduleExports;function resolveSymbol(t){var e=resolveGlobalSymbol(t).sym;return!e&&localScope&&(e=localScope[t]),e||(e=moduleExports[t]),e}p(resolveSymbol,"resolveSymbol");var proxyHandler={get(t,e){switch(e){case"__memory_base":return memoryBase;case"__table_base":return tableBase}if(e in wasmImports&&!wasmImports[e].stub){var r=wasmImports[e];return r}if(!(e in t)){var n;t[e]=(...s)=>(n||=resolveSymbol(e),n(...s))}return t[e]}},proxy=new Proxy({},proxyHandler);currentModuleWeakSymbols=metadata.weakImports;var info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(module,instance){updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols();function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&body.indexOf("$"+arity)!=-1;arity++)args.push("$"+arity);args=args.join(",");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if(p(addEmAsm,"addEmAsm"),"__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;start<stop;){var jsString=UTF8ToString(start);addEmAsm(start,jsString),start=HEAPU8.indexOf(0,start)+1}function addEmJs(name,cSig,body){var jsArgs=[];if(cSig=cSig.slice(1,-1),cSig!="void"){cSig=cSig.split(",");for(var i in cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replace("*",""))}}var func=`(${jsArgs}) => ${body};`;moduleExports[name]=eval(func)}p(addEmJs,"addEmJs");for(var name in moduleExports)if(name.startsWith("__em_js__")){var start=moduleExports[name],jsString=UTF8ToString(start),parts=jsString.split("<::>");addEmJs(name.replace("__em_js__",""),parts[0],parts[1]),delete moduleExports[name]}var applyRelocs=moduleExports.__wasm_apply_data_relocs;applyRelocs&&(runtimeInitialized?applyRelocs():__RELOC_FUNCS__.push(applyRelocs));var init=moduleExports.__wasm_call_ctors;return init&&(runtimeInitialized?init():addOnPostCtor(init)),moduleExports}if(p(postInstantiation,"postInstantiation"),flags.loadAsync)return(async()=>{var t;return binary instanceof WebAssembly.Module?t=new WebAssembly.Instance(binary,info):{module:binary,instance:t}=await WebAssembly.instantiate(binary,info),postInstantiation(binary,t)})();var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}return p(loadModule,"loadModule"),flags={...flags,rpath:{parentLibPath:libName,paths:metadata.runtimePaths}},flags.loadAsync?metadata.neededDynlibs.reduce((t,e)=>t.then(()=>loadDynamicLibrary(e,flags,localScope)),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach(t=>loadDynamicLibrary(t,flags,localScope)),loadModule())},"loadWebAssemblyModule"),mergeLibSymbols=p((t,e)=>{for(var[r,n]of Object.entries(t)){let s=p(_=>{isSymbolDefined(_)||(wasmImports[_]=n)},"setImport");s(r);let o="__main_argc_argv";r=="main"&&s(o),r==o&&s("main")}},"mergeLibSymbols"),asyncLoad=p(async t=>{var e=await readAsync(t);return new Uint8Array(e)},"asyncLoad");function loadDynamicLibrary(t,e={global:!0,nodelete:!0},r,n){var s=LDSO.loadedLibsByName[t];if(s)return e.global?s.global||(s.global=!0,mergeLibSymbols(s.exports,t)):r&&Object.assign(r,s.exports),e.nodelete&&s.refcount!==1/0&&(s.refcount=1/0),s.refcount++,n&&(LDSO.loadedLibsByHandle[n]=s),e.loadAsync?Promise.resolve(!0):!0;s=newDSO(t,n,"loading"),s.refcount=e.nodelete?1/0:1,s.global=e.global;function o(){if(n){var d=LE_HEAP_LOAD_U32((n+28>>2)*4),u=LE_HEAP_LOAD_U32((n+32>>2)*4);if(d&&u){var E=HEAP8.slice(d,d+u);return e.loadAsync?Promise.resolve(E):E}}var g=locateFile(t);if(e.loadAsync)return asyncLoad(g);if(!readBinary)throw new Error(`${g}: file not found, and synchronous loading of external files is not available`);return readBinary(g)}p(o,"loadLibData");function _(){return e.loadAsync?o().then(d=>loadWebAssemblyModule(d,e,t,r,n)):loadWebAssemblyModule(o(),e,t,r,n)}p(_,"getExports");function l(d){s.global?mergeLibSymbols(d,t):r&&Object.assign(r,d),s.exports=d}return p(l,"moduleLoaded"),e.loadAsync?_().then(d=>(l(d),!0)):(l(_()),!0)}p(loadDynamicLibrary,"loadDynamicLibrary");var reportUndefinedSymbols=p(()=>{for(var[t,e]of Object.entries(GOT))if(e.value==0){var r=resolveGlobalSymbol(t,!0).sym;if(!r&&!e.required)continue;if(typeof r=="function")e.value=addFunction(r,r.sig);else if(typeof r=="number")e.value=r;else throw new Error(`bad export type for '${t}': ${typeof r}`)}},"reportUndefinedSymbols"),runDependencies=0,dependenciesFulfilled=null,removeRunDependency=p(t=>{if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),runDependencies==0&&dependenciesFulfilled){var e=dependenciesFulfilled;dependenciesFulfilled=null,e()}},"removeRunDependency"),addRunDependency=p(t=>{runDependencies++,Module.monitorRunDependencies?.(runDependencies)},"addRunDependency"),loadDylibs=p(async()=>{if(!dynamicLibraries.length){reportUndefinedSymbols();return}addRunDependency("loadDylibs");for(var t of dynamicLibraries)await loadDynamicLibrary(t,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0});reportUndefinedSymbols(),removeRunDependency("loadDylibs")},"loadDylibs"),noExitRuntime=!0;function setValue(t,e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":HEAP8[t]=e;break;case"i8":HEAP8[t]=e;break;case"i16":LE_HEAP_STORE_I16((t>>1)*2,e);break;case"i32":LE_HEAP_STORE_I32((t>>2)*4,e);break;case"i64":LE_HEAP_STORE_I64((t>>3)*8,BigInt(e));break;case"float":LE_HEAP_STORE_F32((t>>2)*4,e);break;case"double":LE_HEAP_STORE_F64((t>>3)*8,e);break;case"*":LE_HEAP_STORE_U32((t>>2)*4,e);break;default:abort(`invalid type for setValue: ${r}`)}}p(setValue,"setValue");var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_high=78240,___stack_low=12704,___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},78240),___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),__abort_js=p(()=>abort(""),"__abort_js");__abort_js.sig="v";var getHeapMax=p(()=>2147483648,"getHeapMax"),growMemory=p(t=>{var e=wasmMemory.buffer.byteLength,r=(t-e+65535)/65536|0;try{return wasmMemory.grow(r),updateMemoryViews(),1}catch{}},"growMemory"),_emscripten_resize_heap=p(t=>{var e=HEAPU8.length;t>>>=0;var r=getHeapMax();if(t>r)return!1;for(var n=1;n<=4;n*=2){var s=e*(1+.2/n);s=Math.min(s,t+100663296);var o=Math.min(r,alignMemory(Math.max(t,s),65536)),_=growMemory(o);if(_)return!0}return!1},"_emscripten_resize_heap");_emscripten_resize_heap.sig="ip";var _fd_close=p(t=>52,"_fd_close");_fd_close.sig="ii";var INT53_MAX=9007199254740992,INT53_MIN=-9007199254740992,bigintToI53Checked=p(t=>t<INT53_MIN||t>INT53_MAX?NaN:Number(t),"bigintToI53Checked");function _fd_seek(t,e,r,n){return e=bigintToI53Checked(e),70}p(_fd_seek,"_fd_seek"),_fd_seek.sig="iijip";var printCharBuffers=[null,[],[]],printChar=p((t,e)=>{var r=printCharBuffers[t];e===0||e===10?((t===1?out:err)(UTF8ArrayToString(r)),r.length=0):r.push(e)},"printChar"),_fd_write=p((t,e,r,n)=>{for(var s=0,o=0;o<r;o++){var _=LE_HEAP_LOAD_U32((e>>2)*4),l=LE_HEAP_LOAD_U32((e+4>>2)*4);e+=8;for(var d=0;d<l;d++)printChar(t,HEAPU8[_+d]);s+=l}return LE_HEAP_STORE_U32((n>>2)*4,s),0},"_fd_write");_fd_write.sig="iippp";function _tree_sitter_log_callback(t,e){if(Module.currentLogCallback){let r=UTF8ToString(e);Module.currentLogCallback(r,t!==0)}}p(_tree_sitter_log_callback,"_tree_sitter_log_callback");function _tree_sitter_parse_callback(t,e,r,n,s){let _=Module.currentParseCallback(e,{row:r,column:n});typeof _=="string"?(setValue(s,_.length,"i32"),stringToUTF16(_,t,10240)):setValue(s,0,"i32")}p(_tree_sitter_parse_callback,"_tree_sitter_parse_callback");function _tree_sitter_progress_callback(t,e){return Module.currentProgressCallback?Module.currentProgressCallback({currentOffset:t,hasError:e}):!1}p(_tree_sitter_progress_callback,"_tree_sitter_progress_callback");function _tree_sitter_query_progress_callback(t){return Module.currentQueryProgressCallback?Module.currentQueryProgressCallback({currentOffset:t}):!1}p(_tree_sitter_query_progress_callback,"_tree_sitter_query_progress_callback");var runtimeKeepaliveCounter=0,keepRuntimeAlive=p(()=>noExitRuntime||runtimeKeepaliveCounter>0,"keepRuntimeAlive"),_proc_exit=p(t=>{EXITSTATUS=t,keepRuntimeAlive()||(Module.onExit?.(t),ABORT=!0),quit_(t,new ExitStatus(t))},"_proc_exit");_proc_exit.sig="vi";var exitJS=p((t,e)=>{EXITSTATUS=t,_proc_exit(t)},"exitJS"),handleException=p(t=>{if(t instanceof ExitStatus||t=="unwind")return EXITSTATUS;quit_(1,t)},"handleException"),lengthBytesUTF8=p(t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++r):e+=3}return e},"lengthBytesUTF8"),stringToUTF8Array=p((t,e,r,n)=>{if(!(n>0))return 0;for(var s=r,o=r+n-1,_=0;_<t.length;++_){var l=t.codePointAt(_);if(l<=127){if(r>=o)break;e[r++]=l}else if(l<=2047){if(r+1>=o)break;e[r++]=192|l>>6,e[r++]=128|l&63}else if(l<=65535){if(r+2>=o)break;e[r++]=224|l>>12,e[r++]=128|l>>6&63,e[r++]=128|l&63}else{if(r+3>=o)break;e[r++]=240|l>>18,e[r++]=128|l>>12&63,e[r++]=128|l>>6&63,e[r++]=128|l&63,_++}}return e[r]=0,r-s},"stringToUTF8Array"),stringToUTF8=p((t,e,r)=>stringToUTF8Array(t,HEAPU8,e,r),"stringToUTF8"),stackAlloc=p(t=>__emscripten_stack_alloc(t),"stackAlloc"),stringToUTF8OnStack=p(t=>{var e=lengthBytesUTF8(t)+1,r=stackAlloc(e);return stringToUTF8(t,r,e),r},"stringToUTF8OnStack"),AsciiToString=p(t=>{for(var e="";;){var r=HEAPU8[t++];if(!r)return e;e+=String.fromCharCode(r)}},"AsciiToString"),stringToUTF16=p((t,e,r)=>{if(r??=2147483647,r<2)return 0;r-=2;for(var n=e,s=r<t.length*2?r/2:t.length,o=0;o<s;++o){var _=t.charCodeAt(o);LE_HEAP_STORE_I16((e>>1)*2,_),e+=2}return LE_HEAP_STORE_I16((e>>1)*2,0),e-n},"stringToUTF16");LE_ATOMICS_NATIVE_BYTE_ORDER=new Int8Array(new Int16Array([1]).buffer)[0]===1?[(t=>t),(t=>t),void 0,(t=>t)]:[(t=>t),(t=>((t&65280)<<8|(t&255)<<24)>>16),void 0,(t=>t>>24&255|t>>8&65280|(t&65280)<<8|(t&255)<<24)];function LE_HEAP_UPDATE(){HEAPU16.unsigned=(t=>t&65535),HEAPU32.unsigned=(t=>t>>>0)}if(p(LE_HEAP_UPDATE,"LE_HEAP_UPDATE"),initMemory(),Module.noExitRuntime&&(noExitRuntime=Module.noExitRuntime),Module.print&&(out=Module.print),Module.printErr&&(err=Module.printErr),Module.dynamicLibraries&&(dynamicLibraries=Module.dynamicLibraries),Module.wasmBinary&&(wasmBinary=Module.wasmBinary),Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.preInit)for(typeof Module.preInit=="function"&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.shift()();Module.setValue=setValue,Module.getValue=getValue,Module.UTF8ToString=UTF8ToString,Module.stringToUTF8=stringToUTF8,Module.lengthBytesUTF8=lengthBytesUTF8,Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,Module.loadWebAssemblyModule=loadWebAssemblyModule,Module.LE_HEAP_STORE_I64=LE_HEAP_STORE_I64;var ASM_CONSTS={},_malloc,_calloc,_realloc,_free,_ts_range_edit,_memcmp,_ts_language_symbol_count,_ts_language_state_count,_ts_language_abi_version,_ts_language_name,_ts_language_field_count,_ts_language_next_state,_ts_language_symbol_name,_ts_language_symbol_for_name,_strncmp,_ts_language_symbol_type,_ts_language_field_name_for_id,_ts_lookahead_iterator_new,_ts_lookahead_iterator_delete,_ts_lookahead_iterator_reset_state,_ts_lookahead_iterator_reset,_ts_lookahead_iterator_next,_ts_lookahead_iterator_current_symbol,_ts_point_edit,_ts_parser_delete,_ts_parser_reset,_ts_parser_set_language,_ts_parser_set_included_ranges,_ts_query_new,_ts_query_delete,_iswspace,_iswalnum,_ts_query_pattern_count,_ts_query_capture_count,_ts_query_string_count,_ts_query_capture_name_for_id,_ts_query_capture_quantifier_for_id,_ts_query_string_value_for_id,_ts_query_predicates_for_pattern,_ts_query_start_byte_for_pattern,_ts_query_end_byte_for_pattern,_ts_query_is_pattern_rooted,_ts_query_is_pattern_non_local,_ts_query_is_pattern_guaranteed_at_step,_ts_query_disable_capture,_ts_query_disable_pattern,_ts_tree_copy,_ts_tree_delete,_ts_init,_ts_parser_new_wasm,_ts_parser_enable_logger_wasm,_ts_parser_parse_wasm,_ts_parser_included_ranges_wasm,_ts_language_type_is_named_wasm,_ts_language_type_is_visible_wasm,_ts_language_metadata_wasm,_ts_language_supertypes_wasm,_ts_language_subtypes_wasm,_ts_tree_root_node_wasm,_ts_tree_root_node_with_offset_wasm,_ts_tree_edit_wasm,_ts_tree_included_ranges_wasm,_ts_tree_get_changed_ranges_wasm,_ts_tree_cursor_new_wasm,_ts_tree_cursor_copy_wasm,_ts_tree_cursor_delete_wasm,_ts_tree_cursor_reset_wasm,_ts_tree_cursor_reset_to_wasm,_ts_tree_cursor_goto_first_child_wasm,_ts_tree_cursor_goto_last_child_wasm,_ts_tree_cursor_goto_first_child_for_index_wasm,_ts_tree_cursor_goto_first_child_for_position_wasm,_ts_tree_cursor_goto_next_sibling_wasm,_ts_tree_cursor_goto_previous_sibling_wasm,_ts_tree_cursor_goto_descendant_wasm,_ts_tree_cursor_goto_parent_wasm,_ts_tree_cursor_current_node_type_id_wasm,_ts_tree_cursor_current_node_state_id_wasm,_ts_tree_cursor_current_node_is_named_wasm,_ts_tree_cursor_current_node_is_missing_wasm,_ts_tree_cursor_current_node_id_wasm,_ts_tree_cursor_start_position_wasm,_ts_tree_cursor_end_position_wasm,_ts_tree_cursor_start_index_wasm,_ts_tree_cursor_end_index_wasm,_ts_tree_cursor_current_field_id_wasm,_ts_tree_cursor_current_depth_wasm,_ts_tree_cursor_current_descendant_index_wasm,_ts_tree_cursor_current_node_wasm,_ts_node_symbol_wasm,_ts_node_field_name_for_child_wasm,_ts_node_field_name_for_named_child_wasm,_ts_node_children_by_field_id_wasm,_ts_node_first_child_for_byte_wasm,_ts_node_first_named_child_for_byte_wasm,_ts_node_grammar_symbol_wasm,_ts_node_child_count_wasm,_ts_node_named_child_count_wasm,_ts_node_child_wasm,_ts_node_named_child_wasm,_ts_node_child_by_field_id_wasm,_ts_node_next_sibling_wasm,_ts_node_prev_sibling_wasm,_ts_node_next_named_sibling_wasm,_ts_node_prev_named_sibling_wasm,_ts_node_descendant_count_wasm,_ts_node_parent_wasm,_ts_node_child_with_descendant_wasm,_ts_node_descendant_for_index_wasm,_ts_node_named_descendant_for_index_wasm,_ts_node_descendant_for_position_wasm,_ts_node_named_descendant_for_position_wasm,_ts_node_start_point_wasm,_ts_node_end_point_wasm,_ts_node_start_index_wasm,_ts_node_end_index_wasm,_ts_node_to_string_wasm,_ts_node_children_wasm,_ts_node_named_children_wasm,_ts_node_descendants_of_type_wasm,_ts_node_is_named_wasm,_ts_node_has_changes_wasm,_ts_node_has_error_wasm,_ts_node_is_error_wasm,_ts_node_is_missing_wasm,_ts_node_is_extra_wasm,_ts_node_parse_state_wasm,_ts_node_next_parse_state_wasm,_ts_query_matches_wasm,_ts_query_captures_wasm,_memset,_memcpy,_memmove,_iswalpha,_iswblank,_iswdigit,_iswlower,_iswupper,_iswxdigit,_memchr,_strlen,_strcmp,_strncat,_strncpy,_towlower,_towupper,_setThrew,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___wasm_apply_data_relocs;function assignWasmExports(t){Module._malloc=_malloc=t.malloc,Module._calloc=_calloc=t.calloc,Module._realloc=_realloc=t.realloc,Module._free=_free=t.free,Module._ts_range_edit=_ts_range_edit=t.ts_range_edit,Module._memcmp=_memcmp=t.memcmp,Module._ts_language_symbol_count=_ts_language_symbol_count=t.ts_language_symbol_count,Module._ts_language_state_count=_ts_language_state_count=t.ts_language_state_count,Module._ts_language_abi_version=_ts_language_abi_version=t.ts_language_abi_version,Module._ts_language_name=_ts_language_name=t.ts_language_name,Module._ts_language_field_count=_ts_language_field_count=t.ts_language_field_count,Module._ts_language_next_state=_ts_language_next_state=t.ts_language_next_state,Module._ts_language_symbol_name=_ts_language_symbol_name=t.ts_language_symbol_name,Module._ts_language_symbol_for_name=_ts_language_symbol_for_name=t.ts_language_symbol_for_name,Module._strncmp=_strncmp=t.strncmp,Module._ts_language_symbol_type=_ts_language_symbol_type=t.ts_language_symbol_type,Module._ts_language_field_name_for_id=_ts_language_field_name_for_id=t.ts_language_field_name_for_id,Module._ts_lookahead_iterator_new=_ts_lookahead_iterator_new=t.ts_lookahead_iterator_new,Module._ts_lookahead_iterator_delete=_ts_lookahead_iterator_delete=t.ts_lookahead_iterator_delete,Module._ts_lookahead_iterator_reset_state=_ts_lookahead_iterator_reset_state=t.ts_lookahead_iterator_reset_state,Module._ts_lookahead_iterator_reset=_ts_lookahead_iterator_reset=t.ts_lookahead_iterator_reset,Module._ts_lookahead_iterator_next=_ts_lookahead_iterator_next=t.ts_lookahead_iterator_next,Module._ts_lookahead_iterator_current_symbol=_ts_lookahead_iterator_current_symbol=t.ts_lookahead_iterator_current_symbol,Module._ts_point_edit=_ts_point_edit=t.ts_point_edit,Module._ts_parser_delete=_ts_parser_delete=t.ts_parser_delete,Module._ts_parser_reset=_ts_parser_reset=t.ts_parser_reset,Module._ts_parser_set_language=_ts_parser_set_language=t.ts_parser_set_language,Module._ts_parser_set_included_ranges=_ts_parser_set_included_ranges=t.ts_parser_set_included_ranges,Module._ts_query_new=_ts_query_new=t.ts_query_new,Module._ts_query_delete=_ts_query_delete=t.ts_query_delete,Module._iswspace=_iswspace=t.iswspace,Module._iswalnum=_iswalnum=t.iswalnum,Module._ts_query_pattern_count=_ts_query_pattern_count=t.ts_query_pattern_count,Module._ts_query_capture_count=_ts_query_capture_count=t.ts_query_capture_count,Module._ts_query_string_count=_ts_query_string_count=t.ts_query_string_count,Module._ts_query_capture_name_for_id=_ts_query_capture_name_for_id=t.ts_query_capture_name_for_id,Module._ts_query_capture_quantifier_for_id=_ts_query_capture_quantifier_for_id=t.ts_query_capture_quantifier_for_id,Module._ts_query_string_value_for_id=_ts_query_string_value_for_id=t.ts_query_string_value_for_id,Module._ts_query_predicates_for_pattern=_ts_query_predicates_for_pattern=t.ts_query_predicates_for_pattern,Module._ts_query_start_byte_for_pattern=_ts_query_start_byte_for_pattern=t.ts_query_start_byte_for_pattern,Module._ts_query_end_byte_for_pattern=_ts_query_end_byte_for_pattern=t.ts_query_end_byte_for_pattern,Module._ts_query_is_pattern_rooted=_ts_query_is_pattern_rooted=t.ts_query_is_pattern_rooted,Module._ts_query_is_pattern_non_local=_ts_query_is_pattern_non_local=t.ts_query_is_pattern_non_local,Module._ts_query_is_pattern_guaranteed_at_step=_ts_query_is_pattern_guaranteed_at_step=t.ts_query_is_pattern_guaranteed_at_step,Module._ts_query_disable_capture=_ts_query_disable_capture=t.ts_query_disable_capture,Module._ts_query_disable_pattern=_ts_query_disable_pattern=t.ts_query_disable_pattern,Module._ts_tree_copy=_ts_tree_copy=t.ts_tree_copy,Module._ts_tree_delete=_ts_tree_delete=t.ts_tree_delete,Module._ts_init=_ts_init=t.ts_init,Module._ts_parser_new_wasm=_ts_parser_new_wasm=t.ts_parser_new_wasm,Module._ts_parser_enable_logger_wasm=_ts_parser_enable_logger_wasm=t.ts_parser_enable_logger_wasm,Module._ts_parser_parse_wasm=_ts_parser_parse_wasm=t.ts_parser_parse_wasm,Module._ts_parser_included_ranges_wasm=_ts_parser_included_ranges_wasm=t.ts_parser_included_ranges_wasm,Module._ts_language_type_is_named_wasm=_ts_language_type_is_named_wasm=t.ts_language_type_is_named_wasm,Module._ts_language_type_is_visible_wasm=_ts_language_type_is_visible_wasm=t.ts_language_type_is_visible_wasm,Module._ts_language_metadata_wasm=_ts_language_metadata_wasm=t.ts_language_metadata_wasm,Module._ts_language_supertypes_wasm=_ts_language_supertypes_wasm=t.ts_language_supertypes_wasm,Module._ts_language_subtypes_wasm=_ts_language_subtypes_wasm=t.ts_language_subtypes_wasm,Module._ts_tree_root_node_wasm=_ts_tree_root_node_wasm=t.ts_tree_root_node_wasm,Module._ts_tree_root_node_with_offset_wasm=_ts_tree_root_node_with_offset_wasm=t.ts_tree_root_node_with_offset_wasm,Module._ts_tree_edit_wasm=_ts_tree_edit_wasm=t.ts_tree_edit_wasm,Module._ts_tree_included_ranges_wasm=_ts_tree_included_ranges_wasm=t.ts_tree_included_ranges_wasm,Module._ts_tree_get_changed_ranges_wasm=_ts_tree_get_changed_ranges_wasm=t.ts_tree_get_changed_ranges_wasm,Module._ts_tree_cursor_new_wasm=_ts_tree_cursor_new_wasm=t.ts_tree_cursor_new_wasm,Module._ts_tree_cursor_copy_wasm=_ts_tree_cursor_copy_wasm=t.ts_tree_cursor_copy_wasm,Module._ts_tree_cursor_delete_wasm=_ts_tree_cursor_delete_wasm=t.ts_tree_cursor_delete_wasm,Module._ts_tree_cursor_reset_wasm=_ts_tree_cursor_reset_wasm=t.ts_tree_cursor_reset_wasm,Module._ts_tree_cursor_reset_to_wasm=_ts_tree_cursor_reset_to_wasm=t.ts_tree_cursor_reset_to_wasm,Module._ts_tree_cursor_goto_first_child_wasm=_ts_tree_cursor_goto_first_child_wasm=t.ts_tree_cursor_goto_first_child_wasm,Module._ts_tree_cursor_goto_last_child_wasm=_ts_tree_cursor_goto_last_child_wasm=t.ts_tree_cursor_goto_last_child_wasm,Module._ts_tree_cursor_goto_first_child_for_index_wasm=_ts_tree_cursor_goto_first_child_for_index_wasm=t.ts_tree_cursor_goto_first_child_for_index_wasm,Module._ts_tree_cursor_goto_first_child_for_position_wasm=_ts_tree_cursor_goto_first_child_for_position_wasm=t.ts_tree_cursor_goto_first_child_for_position_wasm,Module._ts_tree_cursor_goto_next_sibling_wasm=_ts_tree_cursor_goto_next_sibling_wasm=t.ts_tree_cursor_goto_next_sibling_wasm,Module._ts_tree_cursor_goto_previous_sibling_wasm=_ts_tree_cursor_goto_previous_sibling_wasm=t.ts_tree_cursor_goto_previous_sibling_wasm,Module._ts_tree_cursor_goto_descendant_wasm=_ts_tree_cursor_goto_descendant_wasm=t.ts_tree_cursor_goto_descendant_wasm,Module._ts_tree_cursor_goto_parent_wasm=_ts_tree_cursor_goto_parent_wasm=t.ts_tree_cursor_goto_parent_wasm,Module._ts_tree_cursor_current_node_type_id_wasm=_ts_tree_cursor_current_node_type_id_wasm=t.ts_tree_cursor_current_node_type_id_wasm,Module._ts_tree_cursor_current_node_state_id_wasm=_ts_tree_cursor_current_node_state_id_wasm=t.ts_tree_cursor_current_node_state_id_wasm,Module._ts_tree_cursor_current_node_is_named_wasm=_ts_tree_cursor_current_node_is_named_wasm=t.ts_tree_cursor_current_node_is_named_wasm,Module._ts_tree_cursor_current_node_is_missing_wasm=_ts_tree_cursor_current_node_is_missing_wasm=t.ts_tree_cursor_current_node_is_missing_wasm,Module._ts_tree_cursor_current_node_id_wasm=_ts_tree_cursor_current_node_id_wasm=t.ts_tree_cursor_current_node_id_wasm,Module._ts_tree_cursor_start_position_wasm=_ts_tree_cursor_start_position_wasm=t.ts_tree_cursor_start_position_wasm,Module._ts_tree_cursor_end_position_wasm=_ts_tree_cursor_end_position_wasm=t.ts_tree_cursor_end_position_wasm,Module._ts_tree_cursor_start_index_wasm=_ts_tree_cursor_start_index_wasm=t.ts_tree_cursor_start_index_wasm,Module._ts_tree_cursor_end_index_wasm=_ts_tree_cursor_end_index_wasm=t.ts_tree_cursor_end_index_wasm,Module._ts_tree_cursor_current_field_id_wasm=_ts_tree_cursor_current_field_id_wasm=t.ts_tree_cursor_current_field_id_wasm,Module._ts_tree_cursor_current_depth_wasm=_ts_tree_cursor_current_depth_wasm=t.ts_tree_cursor_current_depth_wasm,Module._ts_tree_cursor_current_descendant_index_wasm=_ts_tree_cursor_current_descendant_index_wasm=t.ts_tree_cursor_current_descendant_index_wasm,Module._ts_tree_cursor_current_node_wasm=_ts_tree_cursor_current_node_wasm=t.ts_tree_cursor_current_node_wasm,Module._ts_node_symbol_wasm=_ts_node_symbol_wasm=t.ts_node_symbol_wasm,Module._ts_node_field_name_for_child_wasm=_ts_node_field_name_for_child_wasm=t.ts_node_field_name_for_child_wasm,Module._ts_node_field_name_for_named_child_wasm=_ts_node_field_name_for_named_child_wasm=t.ts_node_field_name_for_named_child_wasm,Module._ts_node_children_by_field_id_wasm=_ts_node_children_by_field_id_wasm=t.ts_node_children_by_field_id_wasm,Module._ts_node_first_child_for_byte_wasm=_ts_node_first_child_for_byte_wasm=t.ts_node_first_child_for_byte_wasm,Module._ts_node_first_named_child_for_byte_wasm=_ts_node_first_named_child_for_byte_wasm=t.ts_node_first_named_child_for_byte_wasm,Module._ts_node_grammar_symbol_wasm=_ts_node_grammar_symbol_wasm=t.ts_node_grammar_symbol_wasm,Module._ts_node_child_count_wasm=_ts_node_child_count_wasm=t.ts_node_child_count_wasm,Module._ts_node_named_child_count_wasm=_ts_node_named_child_count_wasm=t.ts_node_named_child_count_wasm,Module._ts_node_child_wasm=_ts_node_child_wasm=t.ts_node_child_wasm,Module._ts_node_named_child_wasm=_ts_node_named_child_wasm=t.ts_node_named_child_wasm,Module._ts_node_child_by_field_id_wasm=_ts_node_child_by_field_id_wasm=t.ts_node_child_by_field_id_wasm,Module._ts_node_next_sibling_wasm=_ts_node_next_sibling_wasm=t.ts_node_next_sibling_wasm,Module._ts_node_prev_sibling_wasm=_ts_node_prev_sibling_wasm=t.ts_node_prev_sibling_wasm,Module._ts_node_next_named_sibling_wasm=_ts_node_next_named_sibling_wasm=t.ts_node_next_named_sibling_wasm,Module._ts_node_prev_named_sibling_wasm=_ts_node_prev_named_sibling_wasm=t.ts_node_prev_named_sibling_wasm,Module._ts_node_descendant_count_wasm=_ts_node_descendant_count_wasm=t.ts_node_descendant_count_wasm,Module._ts_node_parent_wasm=_ts_node_parent_wasm=t.ts_node_parent_wasm,Module._ts_node_child_with_descendant_wasm=_ts_node_child_with_descendant_wasm=t.ts_node_child_with_descendant_wasm,Module._ts_node_descendant_for_index_wasm=_ts_node_descendant_for_index_wasm=t.ts_node_descendant_for_index_wasm,Module._ts_node_named_descendant_for_index_wasm=_ts_node_named_descendant_for_index_wasm=t.ts_node_named_descendant_for_index_wasm,Module._ts_node_descendant_for_position_wasm=_ts_node_descendant_for_position_wasm=t.ts_node_descendant_for_position_wasm,Module._ts_node_named_descendant_for_position_wasm=_ts_node_named_descendant_for_position_wasm=t.ts_node_named_descendant_for_position_wasm,Module._ts_node_start_point_wasm=_ts_node_start_point_wasm=t.ts_node_start_point_wasm,Module._ts_node_end_point_wasm=_ts_node_end_point_wasm=t.ts_node_end_point_wasm,Module._ts_node_start_index_wasm=_ts_node_start_index_wasm=t.ts_node_start_index_wasm,Module._ts_node_end_index_wasm=_ts_node_end_index_wasm=t.ts_node_end_index_wasm,Module._ts_node_to_string_wasm=_ts_node_to_string_wasm=t.ts_node_to_string_wasm,Module._ts_node_children_wasm=_ts_node_children_wasm=t.ts_node_children_wasm,Module._ts_node_named_children_wasm=_ts_node_named_children_wasm=t.ts_node_named_children_wasm,Module._ts_node_descendants_of_type_wasm=_ts_node_descendants_of_type_wasm=t.ts_node_descendants_of_type_wasm,Module._ts_node_is_named_wasm=_ts_node_is_named_wasm=t.ts_node_is_named_wasm,Module._ts_node_has_changes_wasm=_ts_node_has_changes_wasm=t.ts_node_has_changes_wasm,Module._ts_node_has_error_wasm=_ts_node_has_error_wasm=t.ts_node_has_error_wasm,Module._ts_node_is_error_wasm=_ts_node_is_error_wasm=t.ts_node_is_error_wasm,Module._ts_node_is_missing_wasm=_ts_node_is_missing_wasm=t.ts_node_is_missing_wasm,Module._ts_node_is_extra_wasm=_ts_node_is_extra_wasm=t.ts_node_is_extra_wasm,Module._ts_node_parse_state_wasm=_ts_node_parse_state_wasm=t.ts_node_parse_state_wasm,Module._ts_node_next_parse_state_wasm=_ts_node_next_parse_state_wasm=t.ts_node_next_parse_state_wasm,Module._ts_query_matches_wasm=_ts_query_matches_wasm=t.ts_query_matches_wasm,Module._ts_query_captures_wasm=_ts_query_captures_wasm=t.ts_query_captures_wasm,Module._memset=_memset=t.memset,Module._memcpy=_memcpy=t.memcpy,Module._memmove=_memmove=t.memmove,Module._iswalpha=_iswalpha=t.iswalpha,Module._iswblank=_iswblank=t.iswblank,Module._iswdigit=_iswdigit=t.iswdigit,Module._iswlower=_iswlower=t.iswlower,Module._iswupper=_iswupper=t.iswupper,Module._iswxdigit=_iswxdigit=t.iswxdigit,Module._memchr=_memchr=t.memchr,Module._strlen=_strlen=t.strlen,Module._strcmp=_strcmp=t.strcmp,Module._strncat=_strncat=t.strncat,Module._strncpy=_strncpy=t.strncpy,Module._towlower=_towlower=t.towlower,Module._towupper=_towupper=t.towupper,_setThrew=t.setThrew,__emscripten_stack_restore=t._emscripten_stack_restore,__emscripten_stack_alloc=t._emscripten_stack_alloc,_emscripten_stack_get_current=t.emscripten_stack_get_current,___wasm_apply_data_relocs=t.__wasm_apply_data_relocs}p(assignWasmExports,"assignWasmExports");var wasmImports={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_high:___stack_high,__stack_low:___stack_low,__stack_pointer:___stack_pointer,__table_base:___table_base,_abort_js:__abort_js,emscripten_resize_heap:_emscripten_resize_heap,fd_close:_fd_close,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,tree_sitter_log_callback:_tree_sitter_log_callback,tree_sitter_parse_callback:_tree_sitter_parse_callback,tree_sitter_progress_callback:_tree_sitter_progress_callback,tree_sitter_query_progress_callback:_tree_sitter_query_progress_callback};function callMain(t=[]){var e=resolveGlobalSymbol("main").sym;if(e){t.unshift(thisProgram);var r=t.length,n=stackAlloc((r+1)*4),s=n;t.forEach(_=>{LE_HEAP_STORE_U32((s>>2)*4,stringToUTF8OnStack(_)),s+=4}),LE_HEAP_STORE_U32((s>>2)*4,0);try{var o=e(r,n);return exitJS(o,!0),o}catch(_){return handleException(_)}}}p(callMain,"callMain");function run(t=arguments_){if(runDependencies>0){dependenciesFulfilled=run;return}if(preRun(),runDependencies>0){dependenciesFulfilled=run;return}function e(){if(Module.calledRun=!0,!ABORT){initRuntime(),readyPromiseResolve?.(Module),Module.onRuntimeInitialized?.();var r=Module.noInitialRun||!1;r||callMain(t),postRun()}}p(e,"doRun"),Module.setStatus?(Module.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>Module.setStatus(""),1),e()},1)):e()}p(run,"run");var wasmExports;return wasmExports=await createWasm(),run(),runtimeInitialized?moduleRtn=Module:moduleRtn=new Promise((t,e)=>{readyPromiseResolve=t,readyPromiseReject=e}),moduleRtn}p(qt,"Module");var Xn=qt,zt=null;async function Qt(t){return zt??=await Xn(t)}p(Qt,"initializeBinding");function Zt(){return!!zt}p(Zt,"checkModule");var A,Ye,Xe,ze=class{static{p(this,"Parser")}0=0;1=0;logCallback=null;language=null;static async init(t){Kt(await Qt(t)),A=c._ts_init(),Ye=c.getValue(A,"i32"),Xe=c.getValue(A+b,"i32")}constructor(){this.initialize()}initialize(){if(!Zt())throw new Error("cannot construct a Parser before calling `init()`");c._ts_parser_new_wasm(),this[0]=c.getValue(A,"i32"),this[1]=c.getValue(A+b,"i32")}delete(){c._ts_parser_delete(this[0]),c._free(this[1]),this[0]=0,this[1]=0}setLanguage(t){let e;if(!t)e=0,this.language=null;else if(t.constructor===qe){e=t[0];let r=c._ts_language_abi_version(e);if(r<Xe||Ye<r)throw new Error(`Incompatible language version ${r}. Compatibility range ${Xe} through ${Ye}.`);this.language=t}else throw new Error("Argument must be a Language");return c._ts_parser_set_language(this[0],e),this}parse(t,e,r){if(typeof t=="string")c.currentParseCallback=l=>t.slice(l);else if(typeof t=="function")c.currentParseCallback=t;else throw new Error("Argument must be a string or a function");r?.progressCallback?c.currentProgressCallback=r.progressCallback:c.currentProgressCallback=null,this.logCallback?(c.currentLogCallback=this.logCallback,c._ts_parser_enable_logger_wasm(this[0],1)):(c.currentLogCallback=null,c._ts_parser_enable_logger_wasm(this[0],0));let n=0,s=0;if(r?.includedRanges){n=r.includedRanges.length,s=c._calloc(n,fe);let l=s;for(let d=0;d<n;d++)Xt(l,r.includedRanges[d]),l+=fe}let o=c._ts_parser_parse_wasm(this[0],this[1],e?e[0]:0,s,n);if(!o)return c.currentParseCallback=null,c.currentLogCallback=null,c.currentProgressCallback=null,null;if(!this.language)throw new Error("Parser must have a language to parse");let _=new Hn(ee,o,this.language,c.currentParseCallback);return c.currentParseCallback=null,c.currentLogCallback=null,c.currentProgressCallback=null,_}reset(){c._ts_parser_reset(this[0])}getIncludedRanges(){c._ts_parser_included_ranges_wasm(this[0]);let t=c.getValue(A,"i32"),e=c.getValue(A+b,"i32"),r=new Array(t);if(t>0){let n=e;for(let s=0;s<t;s++)r[s]=Ne(n),n+=fe;c._free(e)}return r}setLogger(t){if(!t)this.logCallback=null;else{if(typeof t!="function")throw new Error("Logger callback must be a function");this.logCallback=t}return this}getLogger(){return this.logCallback}},Jn=1,jn=2,$n=/[\w-]+/g,Zs={Zero:0,ZeroOrOne:1,ZeroOrMore:2,One:3,OneOrMore:4},Wt=p(t=>t.type==="capture","isCaptureStep"),Qe=p(t=>t.type==="string","isStringStep"),W={Syntax:1,NodeName:2,FieldName:3,CaptureName:4,PatternStructure:5},Te=class er extends Error{constructor(e,r,n,s){super(er.formatMessage(e,r)),this.kind=e,this.info=r,this.index=n,this.length=s,this.name="QueryError"}static{p(this,"QueryError")}static formatMessage(e,r){switch(e){case W.NodeName:return`Bad node name '${r.word}'`;case W.FieldName:return`Bad field name '${r.word}'`;case W.CaptureName:return`Bad capture name @${r.word}`;case W.PatternStructure:return`Bad pattern structure at offset ${r.suffix}`;case W.Syntax:return`Bad syntax at offset ${r.suffix}`}}};function tr(t,e,r,n){if(t.length!==3)throw new Error(`Wrong number of arguments to \`#${r}\` predicate. Expected 2, got ${t.length-1}`);if(!Wt(t[1]))throw new Error(`First argument of \`#${r}\` predicate must be a capture. Got "${t[1].value}"`);let s=r==="eq?"||r==="any-eq?",o=!r.startsWith("any-");if(Wt(t[2])){let _=t[1].name,l=t[2].name;n[e].push(d=>{let u=[],E=[];for(let h of d)h.name===_&&u.push(h.node),h.name===l&&E.push(h.node);let g=p((h,S,O)=>O?h.text===S.text:h.text!==S.text,"compare");return o?u.every(h=>E.some(S=>g(h,S,s))):u.some(h=>E.some(S=>g(h,S,s)))})}else{let _=t[1].name,l=t[2].value,d=p(E=>E.text===l,"matches"),u=p(E=>E.text!==l,"doesNotMatch");n[e].push(E=>{let g=[];for(let S of E)S.name===_&&g.push(S.node);let h=s?d:u;return o?g.every(h):g.some(h)})}}p(tr,"parseAnyPredicate");function rr(t,e,r,n){if(t.length!==3)throw new Error(`Wrong number of arguments to \`#${r}\` predicate. Expected 2, got ${t.length-1}.`);if(t[1].type!=="capture")throw new Error(`First argument of \`#${r}\` predicate must be a capture. Got "${t[1].value}".`);if(t[2].type!=="string")throw new Error(`Second argument of \`#${r}\` predicate must be a string. Got @${t[2].name}.`);let s=r==="match?"||r==="any-match?",o=!r.startsWith("any-"),_=t[1].name,l=new RegExp(t[2].value);n[e].push(d=>{let u=[];for(let g of d)g.name===_&&u.push(g.node.text);let E=p((g,h)=>h?l.test(g):!l.test(g),"test");return u.length===0?!s:o?u.every(g=>E(g,s)):u.some(g=>E(g,s))})}p(rr,"parseMatchPredicate");function nr(t,e,r,n){if(t.length<2)throw new Error(`Wrong number of arguments to \`#${r}\` predicate. Expected at least 1. Got ${t.length-1}.`);if(t[1].type!=="capture")throw new Error(`First argument of \`#${r}\` predicate must be a capture. Got "${t[1].value}".`);let s=r==="any-of?",o=t[1].name,_=t.slice(2);if(!_.every(Qe))throw new Error(`Arguments to \`#${r}\` predicate must be strings.".`);let l=_.map(d=>d.value);n[e].push(d=>{let u=[];for(let E of d)E.name===o&&u.push(E.node.text);return u.length===0?!s:u.every(E=>l.includes(E))===s})}p(nr,"parseAnyOfPredicate");function sr(t,e,r,n,s){if(t.length<2||t.length>3)throw new Error(`Wrong number of arguments to \`#${r}\` predicate. Expected 1 or 2. Got ${t.length-1}.`);if(!t.every(Qe))throw new Error(`Arguments to \`#${r}\` predicate must be strings.".`);let o=r==="is?"?n:s;o[e]||(o[e]={}),o[e][t[1].value]=t[2]?.value??null}p(sr,"parseIsPredicate");function or(t,e,r){if(t.length<2||t.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${t.length-1}.`);if(!t.every(Qe))throw new Error('Arguments to `#set!` predicate must be strings.".');r[e]||(r[e]={}),r[e][t[1].value]=t[2]?.value??null}p(or,"parseSetDirective");function ir(t,e,r,n,s,o,_,l,d,u,E){if(e===Jn){let g=n[r];o.push({type:"capture",name:g})}else if(e===jn)o.push({type:"string",value:s[r]});else if(o.length>0){if(o[0].type!=="string")throw new Error("Predicates must begin with a literal value");let g=o[0].value;switch(g){case"any-not-eq?":case"not-eq?":case"any-eq?":case"eq?":tr(o,t,g,_);break;case"any-not-match?":case"not-match?":case"any-match?":case"match?":rr(o,t,g,_);break;case"not-any-of?":case"any-of?":nr(o,t,g,_);break;case"is?":case"is-not?":sr(o,t,g,u,E);break;case"set!":or(o,t,d);break;default:l[t].push({operator:g,operands:o.slice(1)})}o.length=0}}p(ir,"parsePattern");var eo=class{static{p(this,"Query")}0=0;exceededMatchLimit;textPredicates;captureNames;captureQuantifiers;predicates;setProperties;assertedProperties;refutedProperties;matchLimit;constructor(t,e){let r=c.lengthBytesUTF8(e),n=c._malloc(r+1);c.stringToUTF8(e,n,r+1);let s=c._ts_query_new(t[0],n,r,A,A+b);if(!s){let m=c.getValue(A+b,"i32"),w=c.getValue(A,"i32"),y=c.UTF8ToString(n,w).length,C=e.slice(y,y+100).split(`
11
+ `)[0],P=C.match($n)?.[0]??"";switch(c._free(n),m){case W.Syntax:throw new Te(W.Syntax,{suffix:`${y}: '${C}'...`},y,0);case W.NodeName:throw new Te(m,{word:P},y,P.length);case W.FieldName:throw new Te(m,{word:P},y,P.length);case W.CaptureName:throw new Te(m,{word:P},y,P.length);case W.PatternStructure:throw new Te(m,{suffix:`${y}: '${C}'...`},y,0)}}let o=c._ts_query_string_count(s),_=c._ts_query_capture_count(s),l=c._ts_query_pattern_count(s),d=new Array(_),u=new Array(l),E=new Array(o);for(let m=0;m<_;m++){let w=c._ts_query_capture_name_for_id(s,m,A),y=c.getValue(A,"i32");d[m]=c.UTF8ToString(w,y)}for(let m=0;m<l;m++){let w=new Array(_);for(let y=0;y<_;y++){let C=c._ts_query_capture_quantifier_for_id(s,m,y);w[y]=C}u[m]=w}for(let m=0;m<o;m++){let w=c._ts_query_string_value_for_id(s,m,A),y=c.getValue(A,"i32");E[m]=c.UTF8ToString(w,y)}let g=new Array(l),h=new Array(l),S=new Array(l),O=new Array(l),L=new Array(l);for(let m=0;m<l;m++){let w=c._ts_query_predicates_for_pattern(s,m,A),y=c.getValue(A,"i32");O[m]=[],L[m]=[];let C=new Array,P=w;for(let Q=0;Q<y;Q++){let F=c.getValue(P,"i32");P+=b;let k=c.getValue(P,"i32");P+=b,ir(m,F,k,d,E,C,L,O,g,h,S)}Object.freeze(L[m]),Object.freeze(O[m]),Object.freeze(g[m]),Object.freeze(h[m]),Object.freeze(S[m])}c._free(n),this[0]=s,this.captureNames=d,this.captureQuantifiers=u,this.textPredicates=L,this.predicates=O,this.setProperties=g,this.assertedProperties=h,this.refutedProperties=S,this.exceededMatchLimit=!1}delete(){c._ts_query_delete(this[0]),this[0]=0}matches(t,e={}){let r=e.startPosition??x,n=e.endPosition??x,s=e.startIndex??0,o=e.endIndex??0,_=e.startContainingPosition??x,l=e.endContainingPosition??x,d=e.startContainingIndex??0,u=e.endContainingIndex??0,E=e.matchLimit??4294967295,g=e.maxStartDepth??4294967295,h=e.progressCallback;if(typeof E!="number")throw new Error("Arguments must be numbers");if(this.matchLimit=E,o!==0&&s>o)throw new Error("`startIndex` cannot be greater than `endIndex`");if(n!==x&&(r.row>n.row||r.row===n.row&&r.column>n.column))throw new Error("`startPosition` cannot be greater than `endPosition`");if(u!==0&&d>u)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(l!==x&&(_.row>l.row||_.row===l.row&&_.column>l.column))throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");h&&(c.currentQueryProgressCallback=h),I(t),c._ts_query_matches_wasm(this[0],t.tree[0],r.row,r.column,n.row,n.column,s,o,_.row,_.column,l.row,l.column,d,u,E,g);let S=c.getValue(A,"i32"),O=c.getValue(A+b,"i32"),L=c.getValue(A+2*b,"i32"),m=new Array(S);this.exceededMatchLimit=!!L;let w=0,y=O;for(let C=0;C<S;C++){let P=c.getValue(y,"i32");y+=b;let Q=c.getValue(y,"i32");y+=b;let F=new Array(Q);if(y=je(this,t.tree,y,P,F),this.textPredicates[P].every(k=>k(F))){m[w]={patternIndex:P,captures:F};let k=this.setProperties[P];m[w].setProperties=k;let te=this.assertedProperties[P];m[w].assertedProperties=te;let re=this.refutedProperties[P];m[w].refutedProperties=re,w++}}return m.length=w,c._free(O),c.currentQueryProgressCallback=null,m}captures(t,e={}){let r=e.startPosition??x,n=e.endPosition??x,s=e.startIndex??0,o=e.endIndex??0,_=e.startContainingPosition??x,l=e.endContainingPosition??x,d=e.startContainingIndex??0,u=e.endContainingIndex??0,E=e.matchLimit??4294967295,g=e.maxStartDepth??4294967295,h=e.progressCallback;if(typeof E!="number")throw new Error("Arguments must be numbers");if(this.matchLimit=E,o!==0&&s>o)throw new Error("`startIndex` cannot be greater than `endIndex`");if(n!==x&&(r.row>n.row||r.row===n.row&&r.column>n.column))throw new Error("`startPosition` cannot be greater than `endPosition`");if(u!==0&&d>u)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(l!==x&&(_.row>l.row||_.row===l.row&&_.column>l.column))throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");h&&(c.currentQueryProgressCallback=h),I(t),c._ts_query_captures_wasm(this[0],t.tree[0],r.row,r.column,n.row,n.column,s,o,_.row,_.column,l.row,l.column,d,u,E,g);let S=c.getValue(A,"i32"),O=c.getValue(A+b,"i32"),L=c.getValue(A+2*b,"i32"),m=new Array;this.exceededMatchLimit=!!L;let w=new Array,y=O;for(let C=0;C<S;C++){let P=c.getValue(y,"i32");y+=b;let Q=c.getValue(y,"i32");y+=b;let F=c.getValue(y,"i32");if(y+=b,w.length=Q,y=je(this,t.tree,y,P,w),this.textPredicates[P].every(k=>k(w))){let k=w[F],te=this.setProperties[P];k.setProperties=te;let re=this.assertedProperties[P];k.assertedProperties=re;let ce=this.refutedProperties[P];k.refutedProperties=ce,m.push(k)}}return c._free(O),c.currentQueryProgressCallback=null,m}predicatesForPattern(t){return this.predicates[t]}disableCapture(t){let e=c.lengthBytesUTF8(t),r=c._malloc(e+1);c.stringToUTF8(t,r,e+1),c._ts_query_disable_capture(this[0],r,e),c._free(r)}disablePattern(t){if(t>=this.predicates.length)throw new Error(`Pattern index is ${t} but the pattern count is ${this.predicates.length}`);c._ts_query_disable_pattern(this[0],t)}didExceedMatchLimit(){return this.exceededMatchLimit}startIndexForPattern(t){if(t>=this.predicates.length)throw new Error(`Pattern index is ${t} but the pattern count is ${this.predicates.length}`);return c._ts_query_start_byte_for_pattern(this[0],t)}endIndexForPattern(t){if(t>=this.predicates.length)throw new Error(`Pattern index is ${t} but the pattern count is ${this.predicates.length}`);return c._ts_query_end_byte_for_pattern(this[0],t)}patternCount(){return c._ts_query_pattern_count(this[0])}captureIndexForName(t){return this.captureNames.indexOf(t)}isPatternRooted(t){return c._ts_query_is_pattern_rooted(this[0],t)===1}isPatternNonLocal(t){return c._ts_query_is_pattern_non_local(this[0],t)===1}isPatternGuaranteedAtStep(t){return c._ts_query_is_pattern_guaranteed_at_step(this[0],t)===1}};var Ze=Z(require("path"),1),_r=Z(require("fs"),1);var me=class extends Map{#r=0;#e=new Map;#t=new Map;#s;#i;#o;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge=="number"&&e.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.#s=e.maxSize,this.#i=e.maxAge||Number.POSITIVE_INFINITY,this.#o=e.onEviction}get __oldCache(){return this.#t}#a(e){if(typeof this.#o=="function")for(let[r,n]of e)this.#o(r,n.value)}#n(e,r){return typeof r.expiry=="number"&&r.expiry<=Date.now()?(typeof this.#o=="function"&&this.#o(e,r.value),this.delete(e)):!1}#u(e,r){if(this.#n(e,r)===!1)return r.value}#l(e,r){return r.expiry?this.#u(e,r):r.value}#c(e,r){let n=r.get(e);return this.#l(e,n)}#d(e,r){this.#e.set(e,r),this.#r++,this.#r>=this.#s&&(this.#r=0,this.#a(this.#t),this.#t=this.#e,this.#e=new Map)}#p(e,r){this.#t.delete(e),this.#d(e,r)}*#_(){for(let e of this.#t){let[r,n]=e;this.#e.has(r)||this.#n(r,n)===!1&&(yield e)}for(let e of this.#e){let[r,n]=e;this.#n(r,n)===!1&&(yield e)}}get(e){if(this.#e.has(e)){let r=this.#e.get(e);return this.#l(e,r)}if(this.#t.has(e)){let r=this.#t.get(e);if(this.#n(e,r)===!1)return this.#p(e,r),r.value}}set(e,r,{maxAge:n=this.#i}={}){let s=typeof n=="number"&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;return this.#e.has(e)?this.#e.set(e,{value:r,expiry:s}):this.#d(e,{value:r,expiry:s}),this}has(e){return this.#e.has(e)?!this.#n(e,this.#e.get(e)):this.#t.has(e)?!this.#n(e,this.#t.get(e)):!1}peek(e){if(this.#e.has(e))return this.#c(e,this.#e);if(this.#t.has(e))return this.#c(e,this.#t)}expiresIn(e){let r=this.#e.get(e)??this.#t.get(e);if(r)return r.expiry?r.expiry-Date.now():Number.POSITIVE_INFINITY}delete(e){let r=this.#e.delete(e);return r&&this.#r--,this.#t.delete(e)||r}clear(){this.#e.clear(),this.#t.clear(),this.#r=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");let r=[...this.#_()],n=r.length-e;n<0?(this.#e=new Map(r),this.#t=new Map,this.#r=r.length):(n>0&&this.#a(r.slice(0,n)),this.#t=new Map(r.slice(n)),this.#e=new Map,this.#r=0),this.#s=e}evict(e=1){let r=Number(e);if(!r||r<=0)return;let n=[...this.#_()],s=Math.trunc(Math.min(r,Math.max(n.length-1,0)));s<=0||(this.#a(n.slice(0,s)),this.#t=new Map(n.slice(s)),this.#e=new Map,this.#r=0)}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.#e){let[r,n]=e;this.#n(r,n)===!1&&(yield[r,n.value])}for(let e of this.#t){let[r,n]=e;this.#e.has(r)||this.#n(r,n)===!1&&(yield[r,n.value])}}*entriesDescending(){let e=[...this.#e];for(let r=e.length-1;r>=0;--r){let n=e[r],[s,o]=n;this.#n(s,o)===!1&&(yield[s,o.value])}e=[...this.#t];for(let r=e.length-1;r>=0;--r){let n=e[r],[s,o]=n;this.#e.has(s)||this.#n(s,o)===!1&&(yield[s,o.value])}}*entriesAscending(){for(let[e,r]of this.#_())yield[e,r.value]}get size(){if(!this.#r)return this.#t.size;let e=0;for(let r of this.#t.keys())this.#e.has(r)||e++;return Math.min(this.#r+e,this.#s)}get maxSize(){return this.#s}get maxAge(){return this.#i}entries(){return this.entriesAscending()}forEach(e,r=this){for(let[n,s]of this.entriesAscending())e.call(r,s,n,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};var ar=!1;async function qn(){if(ar)return;let t=_r.readFileSync(Ze.join(__dirname,"web-tree-sitter.wasm"));await ze.init({wasmBinary:t}),ar=!0}function zn(t,e){let r=null,n=!1;return{async init(){if(n)return;await qn(),r=new ze;let s=Ze.join(__dirname,t),o=await qe.load(s);r.setLanguage(o),n=!0},getParser(){if(!r)throw new Error(`${e} parser not initialized. Call init() first.`);return r},isInitialized(){return n}}}var Qn=64;function lr(t,e,r=Qn){let n=zn(t,e),s=new me({maxSize:r,onEviction:(o,_)=>_.delete()});return{...n,parseWithCache(o){if(!n.isInitialized())return null;let _=s.get(o);if(_)return _;let l=n.getParser().parse(o);return l&&s.set(o,l),l},invalidateCache(o){if(o===void 0){for(let[,_]of s)_.delete();s.clear()}else s.get(o)?.delete(),s.delete(o)}}}var cr={info:t=>console.log(t),error:t=>console.error(t)};var et=class{parsers=new Map;register(e,r,n){if(this.parsers.has(e))return;let s=lr(r,n);this.parsers.set(e,{langId:e,name:n,module:s})}async initOne(e,r,n){this.register(e,r,n);let s=this.parsers.get(e);s.module.isInitialized()||await s.module.init()}async initAll(){for(let e of this.parsers.values())try{await e.module.init()}catch(r){cr.error(`Failed to initialize ${e.name} parser: ${r instanceof Error?r.message:String(r)}`)}cr.info(`ParserManager: initialized ${this.parsers.size} parsers`)}isInitialized(e){return this.parsers.get(e)?.module.isInitialized()??!1}parseWithCache(e,r){let n=this.parsers.get(e);if(!n)throw new Error(`No parser registered for language: ${e}`);return n.module.parseWithCache(r)}getParser(e){let r=this.parsers.get(e);if(!r)throw new Error(`No parser registered for language: ${e}`);return r.module.getParser()}},tt=new et;var rt="fallout-ssl";var dr=".ssl";var Zn=[".h"],go=[...Zn,dr],es=".tssl",ts=".tbaf",rs=".td",ns=[".tph",".tpa",".tpp",".tp2"],ss=".baf",os=".d";var Eo=[...ns.map(t=>t.slice(1)),os.slice(1),ss.slice(1),ts.slice(1),rs.slice(1)],To=[dr.slice(1),"h",es.slice(1)];var ur=()=>tt.initOne(rt,"tree-sitter-ssl.wasm","SSL"),pr=()=>tt.getParser(rt);var gr=require("node:url");function Se(t){return(0,gr.pathToFileURL)(t).toString()}function Er(t,e){return t.map(r=>({uri:Se(r.file??e),line:r.line,columnStart:0,columnEnd:r.column,message:r.message}))}function is(t){let e=pr();if(!e)return{errors:[{uri:Se(t.filepath),line:1,columnStart:0,columnEnd:0,message:"The SSL grammar could not be loaded."}],warnings:[]};let r=Gt(e,t.text,t.filepath,{preprocess:{includeDirs:t.includeDirs,defines:t.defines},level:t.level,shortCircuit:t.shortCircuit,noWarnings:t.noWarnings}),n=[...r.problems];if(r.bytes)try{Tr.writeFileSync(t.dstPath,r.bytes)}catch(s){let o=s instanceof Error?s.message:String(s);n.push({line:1,column:0,message:o})}return{errors:Er(n,t.filepath),warnings:r.warnings.map(s=>({uri:Se(s.file??t.filepath),line:s.line,columnStart:Math.max(0,s.column-1),columnEnd:Math.max(0,s.column-1),message:s.message}))}}var as=ur();nt.parentPort?.on("message",t=>{as.then(()=>{let e={id:t.id,...is(t)};nt.parentPort?.postMessage(e)})});
@@ -196,7 +196,7 @@
196
196
  "category": "base_functions",
197
197
  "documentation": {
198
198
  "kind": "markdown",
199
- "value": "```fallout-ssl-tooltip\nvoid art_anim(int fid)\n```\nReturns the animation that this fid represents (ANIM_stand, ANIM_pickup, etc.)"
199
+ "value": "```fallout-ssl-tooltip\nint art_anim(int fid)\n```\nReturns the animation that this fid represents (ANIM_stand, ANIM_pickup, etc.)"
200
200
  }
201
201
  },
202
202
  {
@@ -216,7 +216,7 @@
216
216
  "category": "base_functions",
217
217
  "documentation": {
218
218
  "kind": "markdown",
219
- "value": "```fallout-ssl-tooltip\nvoid attack_complex(ObjectPtr who, int called_shot, int num_attacks, int bonus, int min_damage, int max_damage, int attacker_results, int target_results\n```\nCauses the current object (self - must be a critter) to attempt to attack a critter (who) with various parameters modifying the combat: called_shot - 0/1/specific means none/random/specific (head, torso, etc.) num_attacks - the # of extra attacks the self object gets before the target bonus - the bonus to hit the target on the first turn only min_damage - the minimum damage that will be done the first attack max_damage - the maximum damage that will be done the first attack attacker_results - what state the attacker ends in after the first attack target_results - what state the target ends in after the first attack"
219
+ "value": "```fallout-ssl-tooltip\nvoid attack_complex(ObjectPtr who, int called_shot, int num_attacks, int bonus, int min_damage, int max_damage, int attacker_results, int target_results)\n```\nCauses the current object (self - must be a critter) to attempt to attack a critter (who) with various parameters modifying the combat: called_shot - 0/1/specific means none/random/specific (head, torso, etc.) num_attacks - the # of extra attacks the self object gets before the target bonus - the bonus to hit the target on the first turn only min_damage - the minimum damage that will be done the first attack max_damage - the maximum damage that will be done the first attack attacker_results - what state the attacker ends in after the first attack target_results - what state the target ends in after the first attack"
220
220
  }
221
221
  },
222
222
  {
@@ -346,7 +346,7 @@
346
346
  "category": "base_functions",
347
347
  "documentation": {
348
348
  "kind": "markdown",
349
- "value": "```fallout-ssl-tooltip\nvoid critter_heal(ObjectPtr who, int amount)\n```\nHeals a critter for a given amount (if given a value above their MaxHP will go up to their maximum HP). [Note: can also input negative amounts, causing the critter to be hurt for that amount. This is useful because it bypasses all resistances and thresholds"
349
+ "value": "```fallout-ssl-tooltip\nint critter_heal(ObjectPtr who, int amount)\n```\nHeals a critter for a given amount (if given a value above their MaxHP will go up to their maximum HP). [Note: can also input negative amounts, causing the critter to be hurt for that amount. This is useful because it bypasses all resistances and thresholds"
350
350
  }
351
351
  },
352
352
  {
@@ -409,7 +409,7 @@
409
409
  "category": "base_functions",
410
410
  "documentation": {
411
411
  "kind": "markdown",
412
- "value": "```fallout-ssl-tooltip\nint critter_set_flee_state(ObjectPtr who, bool flee_on\n```\nSets the FLEE flag on or off. This controls whether the critter flees during combat."
412
+ "value": "```fallout-ssl-tooltip\nint critter_set_flee_state(ObjectPtr who, bool flee_on)\n```\nSets the FLEE flag on or off. This controls whether the critter flees during combat."
413
413
  }
414
414
  },
415
415
  {
@@ -952,7 +952,7 @@
952
952
  "category": "base_functions",
953
953
  "documentation": {
954
954
  "kind": "markdown",
955
- "value": "```fallout-ssl-tooltip\nint has_trait(int trait_type, ObjectPtr who, int trait\n```\nReturns the value of a given critter object's (who) trait of a given trait_type (see define.h). This can be used to determine if the player has a particular Perk, AI Packet, team num, current rotation, or Trait (finesse, bruiser, etc.)."
955
+ "value": "```fallout-ssl-tooltip\nint has_trait(int trait_type, ObjectPtr who, int trait)\n```\nReturns the value of a given critter object's (who) trait of a given trait_type (see define.h). This can be used to determine if the player has a particular Perk, AI Packet, team num, current rotation, or Trait (finesse, bruiser, etc.)."
956
956
  }
957
957
  },
958
958
  {
@@ -6706,7 +6706,7 @@
6706
6706
  "category": "sfall_functions",
6707
6707
  "documentation": {
6708
6708
  "kind": "markdown",
6709
- "value": "```fallout-ssl-tooltip\nvoid set_shader_mode(int mode)\n```\nTells sfall when to use a shader. The parameter is a set of 32 flags which specify the screens on which the shader will be disabled, unless bit 32 is set, in which case the shader will only be active on those screens. Remember that screens are displayed on top of each other; if the player opens the character menu which in combat, the game still considers the player to be in combat. See **sfall.h** for a list of defines.\nThe graphics functions are only available if the user is using graphics mode 4 or 5. Use `graphics_funcs_available` to check; it returns 1 if you can use them or 0 if you can't. Calling graphics functions when `graphics_funcs_available` returns 0 will do nothing."
6709
+ "value": "```fallout-ssl-tooltip\nvoid set_shader_mode(int ID, int mode)\n```\nTells sfall when to use a shader. `mode` is a set of 32 flags which specify the screens on which the shader will be disabled, unless bit 32 is set, in which case the shader will only be active on those screens. Remember that screens are displayed on top of each other; if the player opens the character menu which in combat, the game still considers the player to be in combat. See **sfall.h** for a list of defines.\nThe graphics functions are only available if the user is using graphics mode 4 or 5. Use `graphics_funcs_available` to check; it returns 1 if you can use them or 0 if you can't. Calling graphics functions when `graphics_funcs_available` returns 0 will do nothing."
6710
6710
  }
6711
6711
  },
6712
6712
  {
@@ -2707,7 +2707,7 @@
2707
2707
  "category": "actions",
2708
2708
  "documentation": {
2709
2709
  "kind": "markdown",
2710
- "value": "```weidu-baf-tooltip\nRestParty()\n```\nThis action duplicates the effects of resting. Such resting is not interruptible, and functions even if enemies are nearby."
2710
+ "value": "```weidu-baf-tooltip\nRestParty()\n```\nThis action duplicates the effects of resting. Such resting is not interruptible, and functions even if enemies are nearby. The second variant allows to specify the amount of gold to spend on the rest, a HP bonus in addition to natural healing, as well as an option to suppress the rest movie. A non-zero amount of gold forces the \"Rest at Inn\" movie to play, regardless of the current area type."
2711
2711
  }
2712
2712
  },
2713
2713
  {
@@ -2717,7 +2717,7 @@
2717
2717
  "category": "actions",
2718
2718
  "documentation": {
2719
2719
  "kind": "markdown",
2720
- "value": "```weidu-baf-tooltip\nRestPartyEx(I:Gold, I:HpBonus, I:DisableMovie*Boolean)\n```\nThis action duplicates the effects of resting. Such resting is not interruptible, and functions even if enemies are nearby."
2720
+ "value": "```weidu-baf-tooltip\nRestPartyEx(I:Gold, I:HpBonus, I:DisableMovie*Boolean)\n```\nThis action duplicates the effects of resting. Such resting is not interruptible, and functions even if enemies are nearby. The second variant allows to specify the amount of gold to spend on the rest, a HP bonus in addition to natural healing, as well as an option to suppress the rest movie. A non-zero amount of gold forces the \"Rest at Inn\" movie to play, regardless of the current area type."
2721
2721
  }
2722
2722
  },
2723
2723
  {