{"version":3,"file":"chunk.620.9604655d47e56675a902.js","names":["_classPrivateFieldInitSpec","e","t","a","_checkPrivateRedeclaration","set","has","TypeError","_defineProperty","r","i","Symbol","toPrimitive","call","String","Object","defineProperty","value","enumerable","configurable","writable","_classPrivateFieldGet","s","get","_assertClassBrand","_classPrivateFieldSet","n","arguments","length","CONNECTION_STATES","connecting","open","reconnecting","stopped","MESSAGE_TYPES","batch","recorded","error","ping","RETRYABLE_ERRORS","POLICY_VIOLATION","FIRST_RECONNECT_MILLISECONDS","LONGEST_RECONNECT_MILLISECONDS","IDLE_PING_MILLISECONDS","BatchNotRecorded","Error","constructor","reason","super","_url","WeakMap","_checkRefusal","_WebSocket","_timers","_onChange","_socket","_hasOpened","_reconnectDelay","_reconnectTimer","_pingTimer","_sending","_openWaiters","_JournalConnection_brand","WeakSet","JournalConnection","url","checkRefusal","onChange","WebSocket","globalThis","timers","this","add","isStopped","state","_connect","close","_stop","whenOpen","Promise","resolve","reject","stopReason","push","send","file","firstLine","lines","answerTimer","setTimeout","_settle","_sendMessage","type","first_line","_setState","socket","onopen","_opened","onmessage","message","_answered","data","onclose","event","_closed","code","_scheduleIdlePing","waiter","splice","answer","JSON","parse","refused","includes","_isAboutSending","sending","clearTimeout","async","Math","min","stringify","CONSENT_PATH","CONSENT_SETTING","NEEDS_CONSENT","hasAgreedToCurrentText","consent","Boolean","agreed_version","version","JOURNAL_FILE_NAME","MOST_LINES_IN_A_BATCH","MOST_BATCH_BYTES","SEPARATE_FILE_EVENT","CODEX_EVENT","STATUS_FILE","SEPARATE_FILE_WAIT_MILLISECONDS","STATUS_WINDOW_MILLISECONDS","NEWLINE_BYTE","ALWAYS","writtenWith","isNeeded","writtenWithin","waitFor","SEPARATE_FILES","Map","SEPARATE_FILES_BY_NAME","values","map","separateFile","isJournalFileName","name","test","journalFileNames","names","filter","sort","decoder","TextDecoder","ignoreBOM","encoder","TextEncoder","byteLength","text","encode","completeLines","bytes","start","end","indexOf","decode","subarray","replace","parseLine","line","separateFileFor","separateFileLine","fileName","content","writtenAfterEvent","millisecondsBetween","timestamp","isWrittenAfter","separateFileWait","Date","NOWHERE","system","station","JUMP_EVENTS","LOCATION_EVENT","DOCKED_EVENT","UNDOCKED_EVENT","systemOf","StarSystem","Array","isArray","StarPos","x","y","z","Number","id64","SystemAddress","coords","stationOf","StationName","locationAfter","location","Docked","JOURNAL_PATH","SECURE_PAGE_PROTOCOL","SOCKET_PROTOCOL","SECURE_SOCKET_PROTOCOL","REFUSAL_STATUSES","MODE_PARAMETER","JOURNAL_MODES","live","upload","journalServerConnection","serverAddress","mode","address","self","origin","Ay","socketAddress","response","fetch","URL","o","credentials","json","catch","status","statusText","ok","searchParams","protocol","href","WORKER_NAME","startLiveJournalWorker","SharedWorker","p","u","b","LIVE_JOURNAL_STATES","needsFolder","needsPermission","reading","needsConsent","LIVE_JOURNAL_ACTIVE_STATES","LIVE_JOURNAL_MESSAGES","stop","events","READ_PERMISSION","PERMISSION_GRANTED","FOLDER_KEY","PROGRESS_KEY","LOCATION_KEY","loadFolder","Jt","saveFolder","folder","hZ","progressStore","load","save","progress","clear","yH","locationStore","STILL_WAITING","NOT_FOUND","_folder","_progress","_now","_position","_sentEnd","_nothingNew","_isStopped","_JournalReader_brand","JournalReader","now","nextBatch","isWaitingForSeparateFile","_fileNames","position","_startingPosition","newLines","_linesAfter","nextFile","find","_moveTo","_batch","markSent","sentEnd","journalLineCount","at","_file","_isUnchanged","unread","slice","arrayBuffer","Uint8Array","sentAlready","totalBytes","size","nothingNew","messageBytes","fileBytes","separateLine","_separateLineFor","linesAdded","bytesAdded","reduce","total","added","isFull","_readText","keys","fileHandle","getFileHandle","getFile","READ_AGAIN_MILLISECONDS","RESEND_AFTER_MILLISECONDS","B","NoJournalsInUpload","uploadJournals","files","connection","onProgress","signal","journalNames","journals","reader","uploadedFolder","sentSoFar","bytesTotal","linesSent","bytesSent","addEventListener","aborted","wait","fileNumber","fileCount","DOMException","milliseconds","window","_eai_r","require","_eai_d","define"],"sources":["webpack://__ember_auto_import__/app/journal/connection.js","webpack://__ember_auto_import__/app/journal/consent.js","webpack://__ember_auto_import__/app/journal/lines.js","webpack://__ember_auto_import__/app/journal/location.js","webpack://__ember_auto_import__/app/journal/server-connection.js","webpack://__ember_auto_import__/app/journal/start-worker.js","webpack://__ember_auto_import__/app/journal/states.js","webpack://__ember_auto_import__/app/journal/storage.js","webpack://__ember_auto_import__/app/journal/reader.js","webpack://__ember_auto_import__/app/journal/upload.js","webpack://__ember_auto_import__/tmp/broccoli-82hwiCqp50C7MY/cache-164-webpack_bundler_ember_auto_import_webpack/l.cjs"],"sourcesContent":["0; //eaimeta@70e063a35619d71feaimeta@70e063a35619d71f\nfunction _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }\nfunction _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }\nfunction _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError(\"Cannot initialize the same private elements twice on an object\"); }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }\nfunction _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }\nfunction _assertClassBrand(e, t, n) { if (\"function\" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError(\"Private element is not present on this object\"); }\n// The live journal's websocket to the server: batches are sent one at a\n// time, each waiting for its answer. A dropped connection is opened again,\n// waiting a little longer each time; a refusal stops it until the player\n// does something about it.\n\nexport const CONNECTION_STATES = {\n  connecting: 'connecting',\n  open: 'open',\n  reconnecting: 'reconnecting',\n  stopped: 'stopped'\n};\nconst MESSAGE_TYPES = {\n  batch: 'batch',\n  recorded: 'recorded',\n  error: 'error',\n  ping: 'ping'\n};\n// Server problems: the batch is sent again a little later.\nconst RETRYABLE_ERRORS = ['Could not save the batch, try again', 'Too many batches waiting, send it again later'];\n// The server closes the connection with this once it has refused a batch.\nconst POLICY_VIOLATION = 1008;\nconst FIRST_RECONNECT_MILLISECONDS = 1000;\nconst LONGEST_RECONNECT_MILLISECONDS = 60 * 1000;\n// The server closes a connection with nothing on it for 5 minutes.\nconst IDLE_PING_MILLISECONDS = 60 * 1000;\n// An answer this late is taken as lost, and the batch sent again.\nconst ANSWER_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;\n\n// Why a batch wasn't recorded; an empty message when nobody said.\nexport class BatchNotRecorded extends Error {\n  constructor(reason) {\n    super(reason ?? '');\n  }\n}\nvar _url = /*#__PURE__*/new WeakMap();\nvar _checkRefusal = /*#__PURE__*/new WeakMap();\nvar _WebSocket = /*#__PURE__*/new WeakMap();\nvar _timers = /*#__PURE__*/new WeakMap();\nvar _onChange = /*#__PURE__*/new WeakMap();\nvar _socket = /*#__PURE__*/new WeakMap();\nvar _hasOpened = /*#__PURE__*/new WeakMap();\nvar _reconnectDelay = /*#__PURE__*/new WeakMap();\nvar _reconnectTimer = /*#__PURE__*/new WeakMap();\nvar _pingTimer = /*#__PURE__*/new WeakMap();\nvar _sending = /*#__PURE__*/new WeakMap();\nvar _openWaiters = /*#__PURE__*/new WeakMap();\nvar _JournalConnection_brand = /*#__PURE__*/new WeakSet();\nexport default class JournalConnection {\n  // checkRefusal finds out why a connection was turned away before it\n  // opened: it resolves with the server's reason, or null for a connection\n  // that only failed and is worth trying again.\n  constructor({\n    url,\n    checkRefusal,\n    onChange = () => {},\n    WebSocket = globalThis.WebSocket,\n    timers = globalThis\n  }) {\n    _classPrivateMethodInitSpec(this, _JournalConnection_brand);\n    _defineProperty(this, \"state\", CONNECTION_STATES.connecting);\n    // Why the connection stopped: the server's reason, or null when it was\n    // closed here or the server gave none.\n    _defineProperty(this, \"stopReason\", null);\n    _classPrivateFieldInitSpec(this, _url, void 0);\n    _classPrivateFieldInitSpec(this, _checkRefusal, void 0);\n    _classPrivateFieldInitSpec(this, _WebSocket, void 0);\n    _classPrivateFieldInitSpec(this, _timers, void 0);\n    _classPrivateFieldInitSpec(this, _onChange, void 0);\n    _classPrivateFieldInitSpec(this, _socket, null);\n    _classPrivateFieldInitSpec(this, _hasOpened, false);\n    _classPrivateFieldInitSpec(this, _reconnectDelay, FIRST_RECONNECT_MILLISECONDS);\n    _classPrivateFieldInitSpec(this, _reconnectTimer, null);\n    _classPrivateFieldInitSpec(this, _pingTimer, null);\n    _classPrivateFieldInitSpec(this, _sending, null);\n    _classPrivateFieldInitSpec(this, _openWaiters, []);\n    _classPrivateFieldSet(_url, this, url);\n    _classPrivateFieldSet(_checkRefusal, this, checkRefusal);\n    _classPrivateFieldSet(_onChange, this, onChange);\n    _classPrivateFieldSet(_WebSocket, this, WebSocket);\n    _classPrivateFieldSet(_timers, this, timers);\n  }\n  get isStopped() {\n    return this.state === CONNECTION_STATES.stopped;\n  }\n  open() {\n    _assertClassBrand(_JournalConnection_brand, this, _connect).call(this, CONNECTION_STATES.connecting);\n  }\n  close() {\n    _assertClassBrand(_JournalConnection_brand, this, _stop).call(this, null);\n  }\n\n  // Resolves once the connection is open; rejects if it stops instead.\n  whenOpen() {\n    if (this.state === CONNECTION_STATES.open) {\n      return Promise.resolve();\n    }\n    if (this.isStopped) {\n      return Promise.reject(new BatchNotRecorded(this.stopReason));\n    }\n    return new Promise((resolve, reject) => _classPrivateFieldGet(_openWaiters, this).push({\n      resolve,\n      reject\n    }));\n  }\n\n  // Sends a batch, resolving with the server's answer once it is recorded,\n  // and rejecting with BatchNotRecorded when it isn't.\n  send({\n    file,\n    firstLine,\n    lines\n  }) {\n    if (this.state !== CONNECTION_STATES.open) {\n      return Promise.reject(new BatchNotRecorded('Not connected'));\n    }\n    return new Promise((resolve, reject) => {\n      const answerTimer = _classPrivateFieldGet(_timers, this).setTimeout(() => _assertClassBrand(_JournalConnection_brand, this, _settle).call(this, null, new BatchNotRecorded('No answer')), ANSWER_TIMEOUT_MILLISECONDS);\n      _classPrivateFieldSet(_sending, this, {\n        file,\n        firstLine,\n        resolve,\n        reject,\n        answerTimer\n      });\n      _assertClassBrand(_JournalConnection_brand, this, _sendMessage).call(this, {\n        type: MESSAGE_TYPES.batch,\n        file,\n        first_line: firstLine,\n        lines\n      });\n    });\n  }\n}\nfunction _connect(state) {\n  if (this.isStopped) {\n    return;\n  }\n  _assertClassBrand(_JournalConnection_brand, this, _setState).call(this, state);\n  _classPrivateFieldSet(_hasOpened, this, false);\n  const socket = new (_classPrivateFieldGet(_WebSocket, this))(_classPrivateFieldGet(_url, this));\n  _classPrivateFieldSet(_socket, this, socket);\n  socket.onopen = () => _assertClassBrand(_JournalConnection_brand, this, _opened).call(this);\n  socket.onmessage = message => _assertClassBrand(_JournalConnection_brand, this, _answered).call(this, message.data);\n  socket.onclose = event => {\n    if (socket === _classPrivateFieldGet(_socket, this)) {\n      _assertClassBrand(_JournalConnection_brand, this, _closed).call(this, event.code);\n    }\n  };\n}\nfunction _opened() {\n  _classPrivateFieldSet(_hasOpened, this, true);\n  _classPrivateFieldSet(_reconnectDelay, this, FIRST_RECONNECT_MILLISECONDS);\n  _assertClassBrand(_JournalConnection_brand, this, _setState).call(this, CONNECTION_STATES.open);\n  _assertClassBrand(_JournalConnection_brand, this, _scheduleIdlePing).call(this);\n  for (const waiter of _classPrivateFieldGet(_openWaiters, this).splice(0)) {\n    waiter.resolve();\n  }\n}\nfunction _answered(data) {\n  let answer;\n  try {\n    answer = JSON.parse(data);\n  } catch {\n    return;\n  }\n  if (answer === null || typeof answer !== 'object') {\n    return;\n  }\n  if (answer.refused) {\n    _assertClassBrand(_JournalConnection_brand, this, _stop).call(this, answer.error ?? null);\n    return;\n  }\n  const isAnswerToBatch = [MESSAGE_TYPES.recorded, MESSAGE_TYPES.error].includes(answer.type);\n  if (!isAnswerToBatch || !_assertClassBrand(_JournalConnection_brand, this, _isAboutSending).call(this, answer)) {\n    return;\n  }\n  if (answer.type === MESSAGE_TYPES.recorded) {\n    _assertClassBrand(_JournalConnection_brand, this, _settle).call(this, answer, null);\n    return;\n  }\n  _assertClassBrand(_JournalConnection_brand, this, _settle).call(this, null, new BatchNotRecorded(answer.error));\n  // Anything but a server problem would be refused again and again.\n  if (!RETRYABLE_ERRORS.includes(answer.error)) {\n    _assertClassBrand(_JournalConnection_brand, this, _stop).call(this, answer.error);\n  }\n}\n// An answer names the batch it is about by as much as it gives of its\n// file and first line.\nfunction _isAboutSending(answer) {\n  const sending = _classPrivateFieldGet(_sending, this);\n  return sending !== null && (answer.file == null || answer.file === sending.file) && (answer.first_line == null || answer.first_line === sending.firstLine);\n}\nfunction _settle(answer, error) {\n  const sending = _classPrivateFieldGet(_sending, this);\n  if (!sending) {\n    return;\n  }\n  _classPrivateFieldSet(_sending, this, null);\n  _classPrivateFieldGet(_timers, this).clearTimeout(sending.answerTimer);\n  if (error) {\n    sending.reject(error);\n  } else {\n    sending.resolve(answer);\n  }\n}\nasync function _closed(code) {\n  _classPrivateFieldGet(_timers, this).clearTimeout(_classPrivateFieldGet(_pingTimer, this));\n  _assertClassBrand(_JournalConnection_brand, this, _settle).call(this, null, new BatchNotRecorded('The connection closed'));\n  if (this.isStopped) {\n    return;\n  }\n  if (code === POLICY_VIOLATION) {\n    _assertClassBrand(_JournalConnection_brand, this, _stop).call(this, null);\n    return;\n  }\n  // A refused handshake looks like any failed one, so the server is asked.\n  if (!_classPrivateFieldGet(_hasOpened, this)) {\n    const reason = await _classPrivateFieldGet(_checkRefusal, this).call(this);\n    if (this.isStopped) {\n      return;\n    }\n    if (reason) {\n      _assertClassBrand(_JournalConnection_brand, this, _stop).call(this, reason);\n      return;\n    }\n  }\n  _assertClassBrand(_JournalConnection_brand, this, _setState).call(this, CONNECTION_STATES.reconnecting);\n  _classPrivateFieldSet(_reconnectTimer, this, _classPrivateFieldGet(_timers, this).setTimeout(() => _assertClassBrand(_JournalConnection_brand, this, _connect).call(this, CONNECTION_STATES.reconnecting), _classPrivateFieldGet(_reconnectDelay, this)));\n  _classPrivateFieldSet(_reconnectDelay, this, Math.min(_classPrivateFieldGet(_reconnectDelay, this) * 2, LONGEST_RECONNECT_MILLISECONDS));\n}\nfunction _stop(reason) {\n  if (this.isStopped) {\n    return;\n  }\n  this.stopReason = reason;\n  _assertClassBrand(_JournalConnection_brand, this, _setState).call(this, CONNECTION_STATES.stopped);\n  _classPrivateFieldGet(_timers, this).clearTimeout(_classPrivateFieldGet(_pingTimer, this));\n  _classPrivateFieldGet(_timers, this).clearTimeout(_classPrivateFieldGet(_reconnectTimer, this));\n  _assertClassBrand(_JournalConnection_brand, this, _settle).call(this, null, new BatchNotRecorded(reason));\n  for (const waiter of _classPrivateFieldGet(_openWaiters, this).splice(0)) {\n    waiter.reject(new BatchNotRecorded(reason));\n  }\n  _classPrivateFieldGet(_socket, this)?.close();\n}\nfunction _sendMessage(message) {\n  _classPrivateFieldGet(_socket, this).send(JSON.stringify(message));\n  _assertClassBrand(_JournalConnection_brand, this, _scheduleIdlePing).call(this);\n}\nfunction _scheduleIdlePing() {\n  _classPrivateFieldGet(_timers, this).clearTimeout(_classPrivateFieldGet(_pingTimer, this));\n  _classPrivateFieldSet(_pingTimer, this, _classPrivateFieldGet(_timers, this).setTimeout(() => {\n    if (this.state === CONNECTION_STATES.open && !_classPrivateFieldGet(_sending, this)) {\n      _assertClassBrand(_JournalConnection_brand, this, _sendMessage).call(this, {\n        type: MESSAGE_TYPES.ping\n      });\n    } else {\n      _assertClassBrand(_JournalConnection_brand, this, _scheduleIdlePing).call(this);\n    }\n  }, IDLE_PING_MILLISECONDS));\n}\nfunction _setState(state) {\n  this.state = state;\n  _classPrivateFieldGet(_onChange, this).call(this, this);\n}","0; //eaimeta@70e063a35619d71feaimeta@70e063a35619d71f\n// The live journal's consent text, which the player agrees to before their\n// journal is read: { version, text, agreed_version }.\nexport const CONSENT_PATH = '/api/user/journal/consent';\nexport const CONSENT_SETTING = 'live_journal_consent';\n// Why the worker stopped, when it is because the player hasn't agreed to the\n// current text.\nexport const NEEDS_CONSENT = 'needs_consent';\n\n// The text changes now and then; agreeing to an earlier one isn't agreeing\n// to it.\nexport function hasAgreedToCurrentText(consent) {\n  return Boolean(consent && consent.agreed_version === consent.version);\n}","0; //eaimeta@70e063a35619d71feaimeta@70e063a35619d71f\n// The game's journal files and lines, as the live journal reads them and\n// sends them on: which files are journals, which lines are complete, the\n// separate files the game writes beside some events, and how lines are put\n// into batches.\n\n// Journal.<date and time>.<part>.log; the name sorts by when it was started.\nconst JOURNAL_FILE_NAME = /^Journal\\.\\d{4}-\\d{2}-\\d{2}T\\d{6}\\.\\d{2}\\.log$/;\n\n// The server's limits: lines in a batch (separate files' lines included),\n// and the bytes of a message, less room for the rest of it.\nexport const MOST_LINES_IN_A_BATCH = 1000;\nexport const MOST_BATCH_BYTES = 4 * 1024 * 1024 - 64 * 1024;\nexport const SEPARATE_FILE_EVENT = '_File';\nexport const CODEX_EVENT = 'CodexEntry';\n// The game's status, rewritten as the player moves. Sent with a codex entry,\n// it names the body the player is near, which the entry doesn't.\nexport const STATUS_FILE = 'Status.json';\n// How long after an event its separate file is waited for: the game can\n// write the event a moment before the file.\nexport const SEPARATE_FILE_WAIT_MILLISECONDS = 15 * 1000;\n// How soon after a codex entry the status must be written to go with it.\nexport const STATUS_WINDOW_MILLISECONDS = 10 * 1000;\nconst NEWLINE_BYTE = 0x0a;\nconst ALWAYS = () => true;\n\n// A file the game writes with its event, at the same time.\nfunction writtenWith(file, isNeeded = ALWAYS) {\n  return {\n    file,\n    isNeeded,\n    writtenWithin: 0,\n    waitFor: SEPARATE_FILE_WAIT_MILLISECONDS\n  };\n}\n\n// The file the game writes with each of these events, when the event leaves\n// its details to the file: written within writtenWithin milliseconds after\n// it, and waited for until the event is waitFor milliseconds old.\nconst SEPARATE_FILES = new Map([['Market', writtenWith('Market.json')], ['Outfitting', writtenWith('Outfitting.json')], ['Shipyard', writtenWith('Shipyard.json')], ['NavRoute', writtenWith('NavRoute.json')], ['FCMaterials', writtenWith('FCMaterials.json')], ['ModuleInfo', writtenWith('ModulesInfo.json')], ['Cargo', writtenWith('Cargo.json', event => !('Inventory' in event))], ['Backpack', writtenWith('Backpack.json')], ['ShipLocker', writtenWith('ShipLocker.json', event => !('Items' in event))], [CODEX_EVENT, {\n  file: STATUS_FILE,\n  isNeeded: ALWAYS,\n  writtenWithin: STATUS_WINDOW_MILLISECONDS,\n  waitFor: STATUS_WINDOW_MILLISECONDS\n}]]);\nconst SEPARATE_FILES_BY_NAME = new Map([...SEPARATE_FILES.values()].map(separateFile => [separateFile.file, separateFile]));\nexport function isJournalFileName(name) {\n  return JOURNAL_FILE_NAME.test(name);\n}\n\n// The journal files' names, oldest first.\nexport function journalFileNames(names) {\n  return names.filter(isJournalFileName).sort();\n}\n\n// A byte order mark stays part of the first line, so lines keep their bytes.\nconst decoder = new TextDecoder('utf-8', {\n  ignoreBOM: true\n});\nconst encoder = new TextEncoder();\nexport function byteLength(text) {\n  return encoder.encode(text).length;\n}\n\n// The complete lines in the bytes, each with how many bytes it takes in the\n// file, newline included: a last line without its newline is still being\n// written, so it is left for later. Lines end where a newline byte is, so a\n// character is never cut in two.\nexport function completeLines(bytes) {\n  const lines = [];\n  let start = 0;\n  let end = bytes.indexOf(NEWLINE_BYTE, start);\n  while (end !== -1) {\n    const text = decoder.decode(bytes.subarray(start, end));\n    lines.push({\n      text: text.replace(/\\r$/, ''),\n      bytes: end + 1 - start\n    });\n    start = end + 1;\n    end = bytes.indexOf(NEWLINE_BYTE, start);\n  }\n  return lines;\n}\n\n// The line, parsed, or null when it isn't JSON.\nexport function parseLine(line) {\n  try {\n    return JSON.parse(line);\n  } catch {\n    return null;\n  }\n}\n\n// The name of the separate file the game wrote with the event, or null.\nexport function separateFileFor(event) {\n  const separateFile = SEPARATE_FILES.get(event?.event);\n  return separateFile?.isNeeded(event) ? separateFile.file : null;\n}\n\n// The separate file's line, sent straight after its event's, when the file\n// is the one written with the event.\nexport function separateFileLine(fileName, event, content) {\n  const writtenAfterEvent = millisecondsBetween(event, content);\n  const isWrittenWithEvent = writtenAfterEvent >= 0 && writtenAfterEvent <= SEPARATE_FILES_BY_NAME.get(fileName).writtenWithin;\n  if (!isWrittenWithEvent) {\n    return null;\n  }\n  return JSON.stringify({\n    event: SEPARATE_FILE_EVENT,\n    file: fileName,\n    timestamp: event.timestamp,\n    content\n  });\n}\n\n// Whether the separate file was written too long after the event to go\n// with it, so the event's own will never come.\nexport function isWrittenAfter(fileName, content, event) {\n  return millisecondsBetween(event, content) > SEPARATE_FILES_BY_NAME.get(fileName).writtenWithin;\n}\n\n// How long after the event its separate file is waited for.\nexport function separateFileWait(fileName) {\n  return SEPARATE_FILES_BY_NAME.get(fileName).waitFor;\n}\n\n// NaN when either has no timestamp, so it matches nothing.\nfunction millisecondsBetween(event, content) {\n  return Date.parse(content?.timestamp) - Date.parse(event.timestamp);\n}","0; //eaimeta@70e063a35619d71feaimeta@70e063a35619d71f\n// Where the player is, as the journal says: the system, and the station\n// when docked at one, as { system: { name, id64, coords }, station: { name,\n// system } }. Either may be null.\nexport const NOWHERE = {\n  system: null,\n  station: null\n};\nconst JUMP_EVENTS = ['FSDJump', 'CarrierJump'];\nconst LOCATION_EVENT = 'Location';\nconst DOCKED_EVENT = 'Docked';\nconst UNDOCKED_EVENT = 'Undocked';\nfunction systemOf(event) {\n  if (!event.StarSystem || !Array.isArray(event.StarPos)) {\n    return null;\n  }\n  const [x, y, z] = event.StarPos.map(Number);\n  return {\n    name: event.StarSystem,\n    id64: String(event.SystemAddress),\n    coords: {\n      x,\n      y,\n      z\n    }\n  };\n}\nfunction stationOf(event) {\n  if (!event.StationName || !event.StarSystem) {\n    return null;\n  }\n  return {\n    name: event.StationName,\n    system: event.StarSystem\n  };\n}\n\n// Where the player is after the event. An event that says nothing about it\n// gives back the same location.\nexport function locationAfter(location, event) {\n  const name = event?.event;\n  // A carrier jump or a location can find the player docked.\n  if (JUMP_EVENTS.includes(name) || name === LOCATION_EVENT) {\n    return {\n      system: systemOf(event) ?? location.system,\n      station: event.Docked ? stationOf(event) : null\n    };\n  }\n  if (name === DOCKED_EVENT) {\n    return {\n      ...location,\n      station: stationOf(event)\n    };\n  }\n  if (name === UNDOCKED_EVENT) {\n    return {\n      ...location,\n      station: null\n    };\n  }\n  return location;\n}","0; //eaimeta@70e063a35619d71f0,\"elite-dangerous-gui/journal/connection\",0,\"elite-dangerous-gui/journal/consent\"eaimeta@70e063a35619d71f\nimport JournalConnection from 'elite-dangerous-gui/journal/connection';\nimport { CONSENT_PATH, NEEDS_CONSENT, hasAgreedToCurrentText } from 'elite-dangerous-gui/journal/consent';\nconst JOURNAL_PATH = '/api/user/journal';\nconst SECURE_PAGE_PROTOCOL = 'https:';\nconst SOCKET_PROTOCOL = 'ws:';\nconst SECURE_SOCKET_PROTOCOL = 'wss:';\n// Answers to the consent check that mean the server won't take the journal.\nconst REFUSAL_STATUSES = [401, 403];\nconst MODE_PARAMETER = 'mode';\n\n// Which kind of sending a connection is, for the server's logs.\nexport const JOURNAL_MODES = {\n  live: 'live',\n  upload: 'upload'\n};\n\n// A connection to the server's journal websocket. serverAddress is the API's\n// address; an empty one is the site's own.\nexport default function journalServerConnection(serverAddress, mode, onChange) {\n  const address = serverAddress || self.location.origin;\n  return new JournalConnection({\n    url: socketAddress(address, mode),\n    checkRefusal: () => refusalReason(address),\n    onChange\n  });\n}\nexport function socketAddress(serverAddress, mode) {\n  const address = new URL(JOURNAL_PATH, serverAddress);\n  address.searchParams.set(MODE_PARAMETER, mode);\n  address.protocol = address.protocol === SECURE_PAGE_PROTOCOL ? SECURE_SOCKET_PROTOCOL : SOCKET_PROTOCOL;\n  return address.href;\n}\n\n// Why the server turned the connection away, or null for a connection that\n// is worth trying again.\nasync function refusalReason(serverAddress) {\n  let response;\n  try {\n    response = await fetch(new URL(CONSENT_PATH, serverAddress), {\n      credentials: 'include'\n    });\n  } catch {\n    return null;\n  }\n  const answer = await response.json().catch(() => null);\n  if (REFUSAL_STATUSES.includes(response.status)) {\n    return answer?.error || response.statusText || String(response.status);\n  }\n  if (!response.ok || !answer) {\n    return null;\n  }\n  return hasAgreedToCurrentText(answer) ? null : NEEDS_CONSENT;\n}","0; //eaimeta@70e063a35619d71feaimeta@70e063a35619d71f\n// The live journal's worker, shared by every open page of the site, which\n// find it by this name.\nconst WORKER_NAME = 'live-journal';\nexport default function startLiveJournalWorker() {\n  return new SharedWorker(new URL('./worker.js', import.meta.url), {\n    name: WORKER_NAME\n  });\n}","0; //eaimeta@70e063a35619d71feaimeta@70e063a35619d71f\n// What the live journal is doing, as the worker tells the site's pages.\nexport const LIVE_JOURNAL_STATES = {\n  needsFolder: 'needs_folder',\n  // The browser needs the player to let the site read the folder again.\n  needsPermission: 'needs_permission',\n  connecting: 'connecting',\n  reading: 'reading',\n  reconnecting: 'reconnecting',\n  // The consent text changed since the player agreed to it.\n  needsConsent: 'needs_consent',\n  // Refused by the server, or turned off for this visitor; the reason, if\n  // there is one, says why.\n  stopped: 'stopped'\n};\n\n// The states in which the journal is being read, or soon will be.\nexport const LIVE_JOURNAL_ACTIVE_STATES = [LIVE_JOURNAL_STATES.connecting, LIVE_JOURNAL_STATES.reading, LIVE_JOURNAL_STATES.reconnecting];\n\n// Messages between the pages and the worker.\nexport const LIVE_JOURNAL_MESSAGES = {\n  start: 'start',\n  stop: 'stop',\n  status: 'status',\n  events: 'events'\n};\n\n// What a page or the worker asks of the journal folder.\nexport const READ_PERMISSION = {\n  mode: 'read'\n};\nexport const PERMISSION_GRANTED = 'granted';","0; //eaimeta@70e063a35619d71f0,\"idb-keyval\"eaimeta@70e063a35619d71f\nimport { del, get, set } from 'idb-keyval';\n\n// What the live journal keeps in the browser: the journal folder the player\n// chose, how far through its journals the lines have been sent, and where\n// the player was in the last of them.\nconst FOLDER_KEY = 'live-journal-folder';\nconst PROGRESS_KEY = 'live-journal-progress';\nconst LOCATION_KEY = 'live-journal-location';\nexport function loadFolder() {\n  return get(FOLDER_KEY);\n}\nexport function saveFolder(folder) {\n  return set(FOLDER_KEY, folder);\n}\nexport const progressStore = {\n  load: () => get(PROGRESS_KEY),\n  save: progress => set(PROGRESS_KEY, progress),\n  clear: () => del(PROGRESS_KEY)\n};\nexport const locationStore = {\n  load: () => get(LOCATION_KEY),\n  save: location => set(LOCATION_KEY, location),\n  clear: () => del(LOCATION_KEY)\n};","0; //eaimeta@70e063a35619d71f0,\"elite-dangerous-gui/journal/lines\"eaimeta@70e063a35619d71f\nfunction _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }\nfunction _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }\nfunction _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError(\"Cannot initialize the same private elements twice on an object\"); }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }\nfunction _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }\nfunction _assertClassBrand(e, t, n) { if (\"function\" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError(\"Private element is not present on this object\"); }\nimport { MOST_BATCH_BYTES, MOST_LINES_IN_A_BATCH, byteLength, completeLines, isWrittenAfter, journalFileNames, parseLine, separateFileFor, separateFileLine, separateFileWait } from 'elite-dangerous-gui/journal/lines';\nconst STILL_WAITING = Symbol('still waiting');\nconst NOT_FOUND = 'NotFoundError';\n\n// Reads new lines from the journal folder in batches, carrying on from where\n// the progress store says the last batch sent ended. It starts at the newest\n// journal, finishes each journal before going on to the next, and holds back\n// a last line until it is complete. A batch's lines are only counted as sent\n// once markSent is told the server has them.\nvar _folder = /*#__PURE__*/new WeakMap();\nvar _progress = /*#__PURE__*/new WeakMap();\nvar _now = /*#__PURE__*/new WeakMap();\nvar _position = /*#__PURE__*/new WeakMap();\nvar _sentEnd = /*#__PURE__*/new WeakMap();\nvar _nothingNew = /*#__PURE__*/new WeakMap();\nvar _isStopped = /*#__PURE__*/new WeakMap();\nvar _JournalReader_brand = /*#__PURE__*/new WeakSet();\nexport default class JournalReader {\n  // folder is the journal folder's FileSystemDirectoryHandle; progress is\n  // where { file, lines } is loaded from and saved to: the journal, and how\n  // many of its lines are sent.\n  constructor({\n    folder,\n    progress,\n    now = Date.now\n  }) {\n    _classPrivateMethodInitSpec(this, _JournalReader_brand);\n    // Whether the last batch stopped at an event whose separate file isn't\n    // written yet, so the folder is worth reading again soon.\n    _defineProperty(this, \"isWaitingForSeparateFile\", false);\n    _classPrivateFieldInitSpec(this, _folder, void 0);\n    _classPrivateFieldInitSpec(this, _progress, void 0);\n    _classPrivateFieldInitSpec(this, _now, void 0);\n    _classPrivateFieldInitSpec(this, _position, null);\n    // Where the lines sent end in the journal being read, so only what comes\n    // after them is read again: { file, lines, bytes }.\n    _classPrivateFieldInitSpec(this, _sentEnd, null);\n    // A journal last read with nothing new in it: { file, lines, size }. Until\n    // it grows, it isn't read again.\n    _classPrivateFieldInitSpec(this, _nothingNew, null);\n    _classPrivateFieldInitSpec(this, _isStopped, false);\n    _classPrivateFieldSet(_folder, this, folder);\n    _classPrivateFieldSet(_progress, this, progress);\n    _classPrivateFieldSet(_now, this, now);\n  }\n\n  // The next lines to send, as { file, firstLine, lines, journalLineCount,\n  // bytes }, or null when there are none yet.\n  async nextBatch() {\n    this.isWaitingForSeparateFile = false;\n    const names = journalFileNames(await _assertClassBrand(_JournalReader_brand, this, _fileNames).call(this));\n    if (names.length === 0) {\n      return null;\n    }\n    let position = await _assertClassBrand(_JournalReader_brand, this, _startingPosition).call(this, names);\n    let newLines = await _assertClassBrand(_JournalReader_brand, this, _linesAfter).call(this, position);\n    while (newLines.length === 0) {\n      const nextFile = names.find(name => name > position.file);\n      if (!nextFile) {\n        return null;\n      }\n      position = await _assertClassBrand(_JournalReader_brand, this, _moveTo).call(this, {\n        file: nextFile,\n        lines: 0\n      });\n      newLines = await _assertClassBrand(_JournalReader_brand, this, _linesAfter).call(this, position);\n    }\n    return _assertClassBrand(_JournalReader_brand, this, _batch).call(this, position, newLines);\n  }\n\n  // Counts the batch's lines as sent.\n  async markSent(batch) {\n    const sentEnd = _classPrivateFieldGet(_sentEnd, this);\n    if (sentEnd?.file === batch.file && sentEnd.lines === batch.firstLine - 1) {\n      _classPrivateFieldSet(_sentEnd, this, {\n        file: batch.file,\n        lines: sentEnd.lines + batch.journalLineCount,\n        bytes: sentEnd.bytes + batch.bytes\n      });\n    }\n    await _assertClassBrand(_JournalReader_brand, this, _moveTo).call(this, {\n      file: batch.file,\n      lines: batch.firstLine - 1 + batch.journalLineCount\n    });\n  }\n\n  // A reader that has been replaced no longer saves its progress.\n  stop() {\n    _classPrivateFieldSet(_isStopped, this, true);\n  }\n}\nasync function _startingPosition(names) {\n  _classPrivateFieldGet(_position, this) ?? _classPrivateFieldSet(_position, this, (await _classPrivateFieldGet(_progress, this).load()) ?? null);\n  const position = _classPrivateFieldGet(_position, this);\n  if (position && names.includes(position.file)) {\n    return position;\n  }\n  // A journal that has gone is followed by the next one; with nothing\n  // sent yet, the newest is read from its start.\n  const nextFile = position && names.find(name => name > position.file);\n  return _assertClassBrand(_JournalReader_brand, this, _moveTo).call(this, {\n    file: nextFile ?? names.at(-1),\n    lines: 0\n  });\n}\nasync function _moveTo(position) {\n  _classPrivateFieldSet(_position, this, position);\n  if (!_classPrivateFieldGet(_isStopped, this)) {\n    await _classPrivateFieldGet(_progress, this).save(position);\n  }\n  return position;\n}\n// The complete lines after those sent.\nasync function _linesAfter(position) {\n  const startsAfterSent = _classPrivateFieldGet(_sentEnd, this)?.file === position.file && _classPrivateFieldGet(_sentEnd, this).lines <= position.lines;\n  if (!startsAfterSent) {\n    _classPrivateFieldSet(_sentEnd, this, {\n      file: position.file,\n      lines: 0,\n      bytes: 0\n    });\n  }\n  const file = await _assertClassBrand(_JournalReader_brand, this, _file).call(this, position.file);\n  if (!file || _assertClassBrand(_JournalReader_brand, this, _isUnchanged).call(this, position, file)) {\n    return [];\n  }\n  const sentEnd = _classPrivateFieldGet(_sentEnd, this);\n  const unread = await file.slice(sentEnd.bytes).arrayBuffer();\n  const lines = completeLines(new Uint8Array(unread));\n  const sentAlready = lines.splice(0, position.lines - sentEnd.lines);\n  _classPrivateFieldSet(_sentEnd, this, {\n    file: position.file,\n    lines: sentEnd.lines + sentAlready.length,\n    bytes: sentEnd.bytes + totalBytes(sentAlready)\n  });\n  // A journal shorter than the lines sent from it has nothing new.\n  const newLines = _classPrivateFieldGet(_sentEnd, this).lines === position.lines ? lines : [];\n  _classPrivateFieldSet(_nothingNew, this, newLines.length === 0 ? {\n    file: position.file,\n    lines: position.lines,\n    size: file.size\n  } : null);\n  return newLines;\n}\nfunction _isUnchanged(position, file) {\n  const nothingNew = _classPrivateFieldGet(_nothingNew, this);\n  return nothingNew?.file === position.file && nothingNew.lines === position.lines && nothingNew.size === file.size;\n}\nasync function _batch(position, newLines) {\n  const lines = [];\n  let journalLineCount = 0;\n  let messageBytes = 0;\n  let fileBytes = 0;\n  for (const line of newLines) {\n    const separateLine = await _assertClassBrand(_JournalReader_brand, this, _separateLineFor).call(this, line.text);\n    if (separateLine === STILL_WAITING) {\n      this.isWaitingForSeparateFile = true;\n      break;\n    }\n    const linesAdded = separateLine ? [line.text, separateLine] : [line.text];\n    const bytesAdded = linesAdded.reduce((total, added) => total + byteLength(JSON.stringify(added)), 0);\n    const isFull = lines.length + linesAdded.length > MOST_LINES_IN_A_BATCH || messageBytes + bytesAdded > MOST_BATCH_BYTES;\n    // A single line too large for a batch is still sent, on its own.\n    if (lines.length > 0 && isFull) {\n      break;\n    }\n    lines.push(...linesAdded);\n    journalLineCount += 1;\n    messageBytes += bytesAdded;\n    fileBytes += line.bytes;\n  }\n  if (journalLineCount === 0) {\n    return null;\n  }\n  return {\n    file: position.file,\n    firstLine: position.lines + 1,\n    lines,\n    journalLineCount,\n    bytes: fileBytes\n  };\n}\n// The separate file's line for the event on this line, null when it has\n// none (or its own will never come), or STILL_WAITING while the game may\n// still be writing it.\nasync function _separateLineFor(line) {\n  const event = parseLine(line);\n  const fileName = separateFileFor(event);\n  if (!fileName) {\n    return null;\n  }\n  const content = parseLine((await _assertClassBrand(_JournalReader_brand, this, _readText).call(this, fileName)) ?? '');\n  const separateLine = separateFileLine(fileName, event, content);\n  if (separateLine) {\n    return separateLine;\n  }\n  const eventAge = _classPrivateFieldGet(_now, this).call(this) - Date.parse(event.timestamp);\n  const mayStillCome = eventAge < separateFileWait(fileName) && !isWrittenAfter(fileName, content, event);\n  return mayStillCome ? STILL_WAITING : null;\n}\nasync function _fileNames() {\n  const names = [];\n  for await (const name of _classPrivateFieldGet(_folder, this).keys()) {\n    names.push(name);\n  }\n  return names;\n}\n// The file, or null when it isn't there.\nasync function _file(name) {\n  try {\n    const fileHandle = await _classPrivateFieldGet(_folder, this).getFileHandle(name);\n    return await fileHandle.getFile();\n  } catch (error) {\n    if (error.name === NOT_FOUND) {\n      return null;\n    }\n    throw error;\n  }\n}\nasync function _readText(name) {\n  return (await _assertClassBrand(_JournalReader_brand, this, _file).call(this, name))?.text() ?? null;\n}\nfunction totalBytes(lines) {\n  return lines.reduce((total, line) => total + line.bytes, 0);\n}","0; //eaimeta@70e063a35619d71f0,\"elite-dangerous-gui/journal/lines\",0,\"elite-dangerous-gui/journal/reader\"eaimeta@70e063a35619d71f\nimport { journalFileNames } from 'elite-dangerous-gui/journal/lines';\nimport JournalReader from 'elite-dangerous-gui/journal/reader';\n\n// While the newest journal's last event may still get its separate file, it\n// is looked at again after this long.\nconst READ_AGAIN_MILLISECONDS = 1000;\nconst RESEND_AFTER_MILLISECONDS = 10 * 1000;\nconst NOT_FOUND = 'NotFoundError';\nexport class NoJournalsInUpload extends Error {}\n\n// Sends every journal in the files, oldest first, through the connection in\n// the live journal's batches, for browsers that can't read the journal folder\n// as the game writes it. The game's separate files are left out, as they\n// can't be matched to their events afterwards. onProgress is told after each\n// batch: { file, fileNumber, fileCount, linesSent, bytesSent, bytesTotal }.\n// Resolves with the lines sent; rejects with BatchNotRecorded if the server\n// stops it, or the signal's reason if it is aborted.\nexport default async function uploadJournals({\n  files,\n  connection,\n  onProgress,\n  signal\n}) {\n  const journalNames = journalFileNames(files.map(file => file.name));\n  if (journalNames.length === 0) {\n    throw new NoJournalsInUpload();\n  }\n  const journals = new Map(journalNames.map(name => [name, files.find(file => file.name === name)]));\n  let progress = {\n    file: journalNames[0],\n    lines: 0\n  };\n  const reader = new JournalReader({\n    folder: uploadedFolder(journals),\n    progress: {\n      load: async () => progress,\n      save: async sentSoFar => progress = sentSoFar\n    }\n  });\n  const bytesTotal = [...journals.values()].reduce((total, file) => total + file.size, 0);\n  let linesSent = 0;\n  let bytesSent = 0;\n  signal.addEventListener('abort', () => connection.close());\n  connection.open();\n  try {\n    while (!signal.aborted) {\n      await connection.whenOpen();\n      const batch = await reader.nextBatch();\n      if (!batch && !reader.isWaitingForSeparateFile) {\n        return linesSent;\n      }\n      if (!batch) {\n        await wait(READ_AGAIN_MILLISECONDS);\n        continue;\n      }\n      try {\n        await connection.send(batch);\n      } catch (error) {\n        if (connection.isStopped) {\n          throw error;\n        }\n        await wait(RESEND_AFTER_MILLISECONDS);\n        continue;\n      }\n      await reader.markSent(batch);\n      linesSent += batch.journalLineCount;\n      bytesSent += batch.bytes;\n      onProgress({\n        file: batch.file,\n        fileNumber: journalNames.indexOf(batch.file) + 1,\n        fileCount: journalNames.length,\n        linesSent,\n        bytesSent,\n        bytesTotal\n      });\n    }\n    throw signal.reason;\n  } catch (error) {\n    throw signal.aborted ? signal.reason : error;\n  } finally {\n    connection.close();\n  }\n}\n\n// The uploaded journals, as the reader reads a folder.\nfunction uploadedFolder(journals) {\n  return {\n    async *keys() {\n      yield* journals.keys();\n    },\n    async getFileHandle(name) {\n      const file = journals.get(name);\n      if (!file) {\n        throw new DOMException(`${name} was not uploaded`, NOT_FOUND);\n      }\n      return {\n        getFile: async () => file\n      };\n    }\n  };\n}\nfunction wait(milliseconds) {\n  return new Promise(resolve => setTimeout(resolve, milliseconds));\n}","\nwindow._eai_r = require;\nwindow._eai_d = define;\n"],"mappings":";AAEA,SAASA,EAA2BC,EAAGC,EAAGC,GAAKC,EAA2BH,EAAGC,GAAIA,EAAEG,IAAIJ,EAAGE,EAAI,CAC9F,SAASC,EAA2BH,EAAGC,GAAK,GAAIA,EAAEI,IAAIL,GAAI,MAAM,IAAIM,UAAU,iEAAmE,CACjJ,SAASC,EAAgBP,EAAGQ,EAAGP,GAAK,OAAQO,EAC5C,SAAwBP,GAAK,IAAIQ,EACjC,SAAsBR,EAAGO,GAAK,GAAI,iBAAmBP,IAAMA,EAAG,OAAOA;AAAG,IAAID,EAAIC,EAAES,OAAOC;AAAc,YAAeX,EAAG,CAAE,IAAIS,EAAIT,EAAEY,KAAKX,EAAGO;AAAiB,GAAI,iBAAmBC,EAAG,OAAOA;AAAG,MAAM,IAAIH,UAAU,+CAAiD,CAAE,OAAyBO,OAAiBZ,EAAI,CAAvT,CADkDA;AAAc,MAAO,iBAAmBQ,EAAIA,EAAIA,EAAI,EAAI,CAA1G,C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