{"version":3,"file":"utils.esm-xdfcimIj.js","sources":["../../../node_modules/.pnpm/@chatwoot+utils@0.0.25/node_modules/@chatwoot/utils/dist/utils.esm.js"],"sourcesContent":["import isToday from 'date-fns/isToday';\nimport isYesterday from 'date-fns/isYesterday';\n\n// Returns a function, that, as long as it continues to be invoked, will not\n// be triggered. The function will be called after it stops being called for\n// N milliseconds. If `immediate` is passed, trigger the function on the\n// leading edge, instead of the trailing.\n\n/**\r\n * @func Callback function to be called after delay\r\n * @delay Delay for debounce in ms\r\n * @immediate should execute immediately\r\n * @returns debounced callback function\r\n */\nvar debounce = function debounce(func, wait, immediate) {\n  var timeout;\n  return function () {\n    var context = null;\n    var args = arguments;\n\n    var later = function later() {\n      timeout = null;\n      if (!immediate) func.apply(context, args);\n    };\n\n    var callNow = immediate && !timeout;\n    clearTimeout(timeout);\n    timeout = window.setTimeout(later, wait);\n    if (callNow) func.apply(context, args);\n  };\n};\n\n/**\r\n * @name Get contrasting text color\r\n * @description Get contrasting text color from a text color\r\n * @param bgColor  Background color of text.\r\n * @returns contrasting text color\r\n */\n\nvar getContrastingTextColor = function getContrastingTextColor(bgColor) {\n  var color = bgColor.replace('#', '');\n  var r = parseInt(color.slice(0, 2), 16);\n  var g = parseInt(color.slice(2, 4), 16);\n  var b = parseInt(color.slice(4, 6), 16); // http://stackoverflow.com/a/3943023/112731\n\n  return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#FFFFFF';\n};\n/**\r\n * @name Get formatted date\r\n * @description Get date in today, yesterday or any other date format\r\n * @param date  date\r\n * @param todayText  Today text\r\n * @param yesterdayText  Yesterday text\r\n * @returns formatted date\r\n */\n\nvar formatDate = function formatDate(_ref) {\n  var date = _ref.date,\n      todayText = _ref.todayText,\n      yesterdayText = _ref.yesterdayText;\n  var dateValue = new Date(date);\n  if (isToday(dateValue)) return todayText;\n  if (isYesterday(dateValue)) return yesterdayText;\n  return date;\n};\n/**\r\n * @name formatTime\r\n * @description Format time to Hour, Minute and Second\r\n * @param timeInSeconds  number\r\n * @returns formatted time\r\n */\n\nvar formatTime = function formatTime(timeInSeconds) {\n  var formattedTime = '';\n\n  if (timeInSeconds >= 60 && timeInSeconds < 3600) {\n    var minutes = Math.floor(timeInSeconds / 60);\n    formattedTime = minutes + \" Min\";\n    var seconds = minutes === 60 ? 0 : Math.floor(timeInSeconds % 60);\n    return formattedTime + (\"\" + (seconds > 0 ? ' ' + seconds + ' Sec' : ''));\n  }\n\n  if (timeInSeconds >= 3600 && timeInSeconds < 86400) {\n    var hours = Math.floor(timeInSeconds / 3600);\n    formattedTime = hours + \" Hr\";\n\n    var _minutes = timeInSeconds % 3600 < 60 || hours === 24 ? 0 : Math.floor(timeInSeconds % 3600 / 60);\n\n    return formattedTime + (\"\" + (_minutes > 0 ? ' ' + _minutes + ' Min' : ''));\n  }\n\n  if (timeInSeconds >= 86400) {\n    var days = Math.floor(timeInSeconds / 86400);\n    formattedTime = days + \" Day\";\n\n    var _hours = timeInSeconds % 86400 < 3600 || days >= 364 ? 0 : Math.floor(timeInSeconds % 86400 / 3600);\n\n    return formattedTime + (\"\" + (_hours > 0 ? ' ' + _hours + ' Hr' : ''));\n  }\n\n  return Math.floor(timeInSeconds) + \" Sec\";\n};\n/**\r\n * @name trimContent\r\n * @description Trim a string to max length\r\n * @param content String to trim\r\n * @param maxLength Length of the string to trim, default 1024\r\n * @param ellipsis Boolean to add dots at the end of the string, default false\r\n * @returns trimmed string\r\n */\n\nvar trimContent = function trimContent(content, maxLength, ellipsis) {\n  if (content === void 0) {\n    content = '';\n  }\n\n  if (maxLength === void 0) {\n    maxLength = 1024;\n  }\n\n  if (ellipsis === void 0) {\n    ellipsis = false;\n  }\n\n  var trimmedContent = content;\n\n  if (content.length > maxLength) {\n    trimmedContent = content.substring(0, maxLength);\n  }\n\n  if (ellipsis) {\n    trimmedContent = trimmedContent + '...';\n  }\n\n  return trimmedContent;\n};\n/**\r\n * @name convertSecondsToTimeUnit\r\n * @description Convert seconds to time unit\r\n * @param seconds  number\r\n * @param unitNames  object\r\n * @returns time and unit\r\n * @example\r\n * convertToUnit(60, { minute: 'm', hour: 'h', day: 'd' }); // { time: 1, unit: 'm' }\r\n * convertToUnit(60, { minute: 'Minutes', hour: 'Hours', day: 'Days' }); // { time: 1, unit: 'Minutes' }\r\n */\n\nvar convertSecondsToTimeUnit = function convertSecondsToTimeUnit(seconds, unitNames) {\n  if (seconds === null || seconds === 0) return {\n    time: '',\n    unit: ''\n  };\n  if (seconds < 3600) return {\n    time: Number((seconds / 60).toFixed(1)),\n    unit: unitNames.minute\n  };\n  if (seconds < 86400) return {\n    time: Number((seconds / 3600).toFixed(1)),\n    unit: unitNames.hour\n  };\n  return {\n    time: Number((seconds / 86400).toFixed(1)),\n    unit: unitNames.day\n  };\n};\n\n/**\r\n * Function that parses a string boolean value and returns the corresponding boolean value\r\n * @param {string | number} candidate - The string boolean value to be parsed\r\n * @return {boolean} - The parsed boolean value\r\n */\nfunction parseBoolean(candidate) {\n  try {\n    // lowercase the string, so TRUE becomes true\n    var candidateString = String(candidate).toLowerCase(); // wrap in boolean to ensure that the return value\n    // is a boolean even if values like 0 or 1 are passed\n\n    return Boolean(JSON.parse(candidateString));\n  } catch (error) {\n    return false;\n  }\n}\n\n/**\r\n * Sorts an array of numbers in ascending order.\r\n * @param {number[]} arr - The array of numbers to be sorted.\r\n * @returns {number[]} - The sorted array.\r\n */\nfunction sortAsc(arr) {\n  // .slice() is used to create a copy of the array so that the original array is not mutated\n  return arr.slice().sort(function (a, b) {\n    return a - b;\n  });\n}\n/**\r\n * Calculates the quantile value of an array at a specified percentile.\r\n * @param {number[]} arr - The array of numbers to calculate the quantile value from.\r\n * @param {number} q - The percentile to calculate the quantile value for.\r\n * @returns {number} - The quantile value.\r\n */\n\nfunction quantile(arr, q) {\n  var sorted = sortAsc(arr); // Sort the array in ascending order\n\n  return _quantileForSorted(sorted, q); // Calculate the quantile value\n}\n/**\r\n * Clamps a value between a minimum and maximum range.\r\n * @param {number} min - The minimum range.\r\n * @param {number} max - The maximum range.\r\n * @param {number} value - The value to be clamped.\r\n * @returns {number} - The clamped value.\r\n */\n\nfunction clamp(min, max, value) {\n  if (value < min) {\n    return min;\n  }\n\n  if (value > max) {\n    return max;\n  }\n\n  return value;\n}\n/**\r\n * This method assumes the the array provided is already sorted in ascending order.\r\n * It's a helper method for the quantile method and should not be exported as is.\r\n *\r\n * @param {number[]} arr - The array of numbers to calculate the quantile value from.\r\n * @param {number} q - The percentile to calculate the quantile value for.\r\n * @returns {number} - The quantile value.\r\n */\n\nfunction _quantileForSorted(sorted, q) {\n  var clamped = clamp(0, 1, q); // Clamp the percentile between 0 and 1\n\n  var pos = (sorted.length - 1) * clamped; // Calculate the index of the element at the specified percentile\n\n  var base = Math.floor(pos); // Find the index of the closest element to the specified percentile\n\n  var rest = pos - base; // Calculate the decimal value between the closest elements\n  // Interpolate the quantile value between the closest elements\n  // Most libraries don't to the interpolation, but I'm just having fun here\n  // also see https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample\n\n  if (sorted[base + 1] !== undefined) {\n    // in case the position was a integer, the rest will be 0 and the interpolation will be skipped\n    return sorted[base] + rest * (sorted[base + 1] - sorted[base]);\n  } // Return the closest element if there is no interpolation possible\n\n\n  return sorted[base];\n}\n/**\r\n * Calculates the quantile values for an array of intervals.\r\n * @param {number[]} data - The array of numbers to calculate the quantile values from.\r\n * @param {number[]} intervals - The array of intervals to calculate the quantile values for.\r\n * @returns {number[]} - The array of quantile values for the intervals.\r\n */\n\n\nvar getQuantileIntervals = function getQuantileIntervals(data, intervals) {\n  // Sort the array in ascending order before looping through the intervals.\n  // depending on the size of the array and the number of intervals, this can speed up the process by at least twice\n  // for a random array of 100 numbers and 5 intervals, the speedup is 3x\n  var sorted = sortAsc(data);\n  return intervals.map(function (interval) {\n    return _quantileForSorted(sorted, interval);\n  });\n};\n\nfunction _extends() {\n  _extends = Object.assign || function (target) {\n    for (var i = 1; i < arguments.length; i++) {\n      var source = arguments[i];\n\n      for (var key in source) {\n        if (Object.prototype.hasOwnProperty.call(source, key)) {\n          target[key] = source[key];\n        }\n      }\n    }\n\n    return target;\n  };\n\n  return _extends.apply(this, arguments);\n}\n\nvar MESSAGE_VARIABLES_REGEX = /{{(.*?)}}/g;\n\nvar skipCodeBlocks = function skipCodeBlocks(str) {\n  return str.replace(/```(?:.|\\n)+?```/g, '');\n};\n\nvar capitalizeName = function capitalizeName(name) {\n  return (name || '').replace(/\\b(\\w)/g, function (s) {\n    return s.toUpperCase();\n  });\n};\nvar getFirstName = function getFirstName(_ref) {\n  var user = _ref.user;\n  var firstName = user != null && user.name ? user.name.split(' ').shift() : '';\n  return capitalizeName(firstName);\n};\nvar getLastName = function getLastName(_ref2) {\n  var user = _ref2.user;\n\n  if (user && user.name) {\n    var lastName = user.name.split(' ').length > 1 ? user.name.split(' ').pop() : '';\n    return capitalizeName(lastName);\n  }\n\n  return '';\n};\nvar getMessageVariables = function getMessageVariables(_ref3) {\n  var _assignee$email;\n\n  var conversation = _ref3.conversation,\n      contact = _ref3.contact;\n  var _conversation$meta = conversation.meta,\n      assignee = _conversation$meta.assignee,\n      sender = _conversation$meta.sender,\n      id = conversation.id,\n      _conversation$custom_ = conversation.custom_attributes,\n      conversationCustomAttributes = _conversation$custom_ === void 0 ? {} : _conversation$custom_;\n\n  var _ref4 = contact || {},\n      contactCustomAttributes = _ref4.custom_attributes;\n\n  var standardVariables = {\n    'contact.name': capitalizeName((sender == null ? void 0 : sender.name) || ''),\n    'contact.first_name': getFirstName({\n      user: sender\n    }),\n    'contact.last_name': getLastName({\n      user: sender\n    }),\n    'contact.email': sender == null ? void 0 : sender.email,\n    'contact.phone': sender == null ? void 0 : sender.phone_number,\n    'contact.id': sender == null ? void 0 : sender.id,\n    'conversation.id': id,\n    'agent.name': capitalizeName((assignee == null ? void 0 : assignee.name) || ''),\n    'agent.first_name': getFirstName({\n      user: assignee\n    }),\n    'agent.last_name': getLastName({\n      user: assignee\n    }),\n    'agent.email': (_assignee$email = assignee == null ? void 0 : assignee.email) != null ? _assignee$email : ''\n  };\n  var conversationCustomAttributeVariables = Object.entries(conversationCustomAttributes != null ? conversationCustomAttributes : {}).reduce(function (acc, _ref5) {\n    var key = _ref5[0],\n        value = _ref5[1];\n    acc[\"conversation.custom_attribute.\" + key] = value;\n    return acc;\n  }, {});\n  var contactCustomAttributeVariables = Object.entries(contactCustomAttributes != null ? contactCustomAttributes : {}).reduce(function (acc, _ref6) {\n    var key = _ref6[0],\n        value = _ref6[1];\n    acc[\"contact.custom_attribute.\" + key] = value;\n    return acc;\n  }, {});\n\n  var variables = _extends({}, standardVariables, conversationCustomAttributeVariables, contactCustomAttributeVariables);\n\n  return variables;\n};\nvar replaceVariablesInMessage = function replaceVariablesInMessage(_ref7) {\n  var message = _ref7.message,\n      variables = _ref7.variables;\n  // @ts-ignore\n  return message == null ? void 0 : message.replace(MESSAGE_VARIABLES_REGEX, function (_, replace) {\n    return variables[replace.trim()] ? variables[replace.trim().toLowerCase()] : '';\n  });\n};\nvar getUndefinedVariablesInMessage = function getUndefinedVariablesInMessage(_ref8) {\n  var message = _ref8.message,\n      variables = _ref8.variables;\n  var messageWithOutCodeBlocks = skipCodeBlocks(message);\n  var matches = messageWithOutCodeBlocks.match(MESSAGE_VARIABLES_REGEX);\n  if (!matches) return [];\n  return matches.map(function (match) {\n    return match.replace('{{', '').replace('}}', '').trim();\n  }).filter(function (variable) {\n    return variables[variable] === undefined;\n  });\n};\n\n/**\r\n * Creates a typing indicator utility.\r\n * @param onStartTyping Callback function to be called when typing starts\r\n * @param onStopTyping Callback function to be called when typing stops after delay\r\n * @param idleTime Delay for idle time in ms before considering typing stopped\r\n * @returns An object with start and stop methods for typing indicator\r\n */\nvar createTypingIndicator = function createTypingIndicator(onStartTyping, onStopTyping, idleTime) {\n  var timer = null;\n\n  var start = function start() {\n    if (!timer) {\n      onStartTyping();\n    }\n\n    reset();\n  };\n\n  var stop = function stop() {\n    if (timer) {\n      clearTimeout(timer);\n      timer = null;\n      onStopTyping();\n    }\n  };\n\n  var reset = function reset() {\n    if (timer) {\n      clearTimeout(timer);\n    }\n\n    timer = setTimeout(function () {\n      stop();\n    }, idleTime);\n  };\n\n  return {\n    start: start,\n    stop: stop\n  };\n};\n\n/**\r\n * Calculates the threshold for an SLA based on the current time and the provided threshold.\r\n * @param timeOffset - The time offset in seconds.\r\n * @param threshold - The threshold in seconds or null if not applicable.\r\n * @returns The calculated threshold in seconds or null if the threshold is null.\r\n */\nvar calculateThreshold = function calculateThreshold(timeOffset, threshold) {\n  // Calculate the time left for the SLA to breach or the time since the SLA has missed\n  if (threshold === null) return null;\n  var currentTime = Math.floor(Date.now() / 1000);\n  return timeOffset + threshold - currentTime;\n};\n/**\r\n * Finds the most urgent SLA status based on the threshold.\r\n * @param SLAStatuses - An array of SLAStatus objects.\r\n * @returns The most urgent SLAStatus object.\r\n */\n\n\nvar findMostUrgentSLAStatus = function findMostUrgentSLAStatus(SLAStatuses) {\n  // Sort the SLAs based on the threshold and return the most urgent SLA\n  SLAStatuses.sort(function (sla1, sla2) {\n    return Math.abs(sla1.threshold) - Math.abs(sla2.threshold);\n  });\n  return SLAStatuses[0];\n};\n/**\r\n * Formats the SLA time in a human-readable format.\r\n * @param seconds - The time in seconds.\r\n * @returns A formatted string representing the time.\r\n */\n\n\nvar formatSLATime = function formatSLATime(seconds) {\n  var units = {\n    y: 31536000,\n    mo: 2592000,\n    d: 86400,\n    h: 3600,\n    m: 60\n  };\n\n  if (seconds < 60) {\n    return '1m';\n  } // we will only show two parts, two max granularity's, h-m, y-d, d-h, m, but no seconds\n\n\n  var parts = [];\n  Object.keys(units).forEach(function (unit) {\n    var value = Math.floor(seconds / units[unit]);\n    if (seconds < 60 && parts.length > 0) return;\n    if (parts.length === 2) return;\n\n    if (value > 0) {\n      parts.push(value + unit);\n      seconds -= value * units[unit];\n    }\n  });\n  return parts.join(' ');\n};\n/**\r\n * Creates an SLA object based on the type, applied SLA, and chat details.\r\n * @param type - The type of SLA (FRT, NRT, RT).\r\n * @param appliedSla - The applied SLA details.\r\n * @param chat - The chat details.\r\n * @returns An object containing the SLA status or null if conditions are not met.\r\n */\n\n\nvar createSLAObject = function createSLAObject(type, appliedSla, chat) {\n  var frtThreshold = appliedSla.sla_first_response_time_threshold,\n      nrtThreshold = appliedSla.sla_next_response_time_threshold,\n      rtThreshold = appliedSla.sla_resolution_time_threshold,\n      createdAt = appliedSla.created_at;\n  var firstReplyCreatedAt = chat.first_reply_created_at,\n      waitingSince = chat.waiting_since,\n      status = chat.status;\n  var SLATypes = {\n    FRT: {\n      threshold: calculateThreshold(createdAt, frtThreshold),\n      //   Check FRT only if threshold is not null and first reply hasn't been made\n      condition: frtThreshold !== null && (!firstReplyCreatedAt || firstReplyCreatedAt === 0)\n    },\n    NRT: {\n      threshold: calculateThreshold(waitingSince, nrtThreshold),\n      // Check NRT only if threshold is not null, first reply has been made and we are waiting since\n      condition: nrtThreshold !== null && !!firstReplyCreatedAt && !!waitingSince\n    },\n    RT: {\n      threshold: calculateThreshold(createdAt, rtThreshold),\n      // Check RT only if the conversation is open and threshold is not null\n      condition: status === 'open' && rtThreshold !== null\n    }\n  };\n  var SLAStatus = SLATypes[type];\n  return SLAStatus ? _extends({}, SLAStatus, {\n    type: type\n  }) : null;\n};\n/**\r\n * Evaluates SLA conditions and returns an array of SLAStatus objects.\r\n * @param appliedSla - The applied SLA details.\r\n * @param chat - The chat details.\r\n * @returns An array of SLAStatus objects.\r\n */\n\n\nvar evaluateSLAConditions = function evaluateSLAConditions(appliedSla, chat) {\n  // Filter out the SLA based on conditions and update the object with the breach status(icon, isSlaMissed)\n  var SLATypes = ['FRT', 'NRT', 'RT'];\n  return SLATypes.map(function (type) {\n    return createSLAObject(type, appliedSla, chat);\n  }).filter(function (SLAStatus) {\n    return !!SLAStatus && SLAStatus.condition;\n  }).map(function (SLAStatus) {\n    return _extends({}, SLAStatus, {\n      icon: SLAStatus.threshold <= 0 ? 'flame' : 'alarm',\n      isSlaMissed: SLAStatus.threshold <= 0\n    });\n  });\n};\n/**\r\n * Evaluates the SLA status for a given chat and applied SLA.\r\n * @param {Object} params - The parameters object.\r\n * @param params.appliedSla - The applied SLA details.\r\n * @param params.chat - The chat details.\r\n * @returns An object containing the most urgent SLA status.\r\n */\n\n\nvar evaluateSLAStatus = function evaluateSLAStatus(_ref) {\n  var appliedSla = _ref.appliedSla,\n      chat = _ref.chat;\n  if (!appliedSla || !chat) return {\n    type: '',\n    threshold: '',\n    icon: '',\n    isSlaMissed: false\n  }; // Filter out the SLA and create the object for each breach\n\n  var SLAStatuses = evaluateSLAConditions(appliedSla, chat); // Return the most urgent SLA which is latest to breach or has missed\n\n  var mostUrgent = findMostUrgentSLAStatus(SLAStatuses);\n  return mostUrgent ? {\n    type: mostUrgent == null ? void 0 : mostUrgent.type,\n    threshold: formatSLATime(mostUrgent.threshold <= 0 ? -mostUrgent.threshold : mostUrgent.threshold),\n    icon: mostUrgent.icon,\n    isSlaMissed: mostUrgent.isSlaMissed\n  } : {\n    type: '',\n    threshold: '',\n    icon: '',\n    isSlaMissed: false\n  };\n};\n\nexport { clamp, convertSecondsToTimeUnit, createTypingIndicator, debounce, evaluateSLAStatus, formatDate, formatTime, getContrastingTextColor, getMessageVariables, getQuantileIntervals, getUndefinedVariablesInMessage, parseBoolean, quantile, replaceVariablesInMessage, sortAsc, trimContent };\n//# sourceMappingURL=utils.esm.js.map\n"],"names":["debounce","func","wait","immediate","timeout","context","args","later","callNow","getContrastingTextColor","bgColor","color","r","g","b","formatTime","timeInSeconds","formattedTime","minutes","seconds","hours","_minutes","days","_hours","trimContent","content","maxLength","ellipsis","trimmedContent","convertSecondsToTimeUnit","unitNames","parseBoolean","candidate","candidateString","sortAsc","arr","a","clamp","min","max","value","_quantileForSorted","sorted","q","clamped","pos","base","rest","getQuantileIntervals","data","intervals","interval","_extends","target","i","source","key","MESSAGE_VARIABLES_REGEX","skipCodeBlocks","str","capitalizeName","name","s","getFirstName","_ref","user","firstName","getLastName","_ref2","lastName","getMessageVariables","_ref3","_assignee$email","conversation","contact","_conversation$meta","assignee","sender","id","_conversation$custom_","conversationCustomAttributes","_ref4","contactCustomAttributes","standardVariables","conversationCustomAttributeVariables","acc","_ref5","contactCustomAttributeVariables","_ref6","variables","replaceVariablesInMessage","_ref7","message","_","replace","getUndefinedVariablesInMessage","_ref8","messageWithOutCodeBlocks","matches","match","variable","createTypingIndicator","onStartTyping","onStopTyping","idleTime","timer","start","reset","stop","calculateThreshold","timeOffset","threshold","currentTime","findMostUrgentSLAStatus","SLAStatuses","sla1","sla2","formatSLATime","units","parts","unit","createSLAObject","type","appliedSla","chat","frtThreshold","nrtThreshold","rtThreshold","createdAt","firstReplyCreatedAt","waitingSince","status","SLATypes","SLAStatus","evaluateSLAConditions","evaluateSLAStatus","mostUrgent"],"mappings":"AAcG,IAACA,EAAW,SAAkBC,EAAMC,EAAMC,EAAW,CACtD,IAAIC,EACJ,OAAO,UAAY,CACjB,IAAIC,EAAU,KACVC,EAAO,UAEPC,EAAQ,UAAiB,CAC3BH,EAAU,KACLD,GAAWF,EAAK,MAAMI,EAASC,CAAI,CAC9C,EAEQE,EAAUL,GAAa,CAACC,EAC5B,aAAaA,CAAO,EACpBA,EAAU,OAAO,WAAWG,EAAOL,CAAI,EACnCM,GAASP,EAAK,MAAMI,EAASC,CAAI,CACzC,CACA,EASIG,EAA0B,SAAiCC,EAAS,CACtE,IAAIC,EAAQD,EAAQ,QAAQ,IAAK,EAAE,EAC/BE,EAAI,SAASD,EAAM,MAAM,EAAG,CAAC,EAAG,EAAE,EAClCE,EAAI,SAASF,EAAM,MAAM,EAAG,CAAC,EAAG,EAAE,EAClCG,EAAI,SAASH,EAAM,MAAM,EAAG,CAAC,EAAG,EAAE,EAEtC,OAAOC,EAAI,KAAQC,EAAI,KAAQC,EAAI,KAAQ,IAAM,UAAY,SAC/D,EA0BIC,EAAa,SAAoBC,EAAe,CAClD,IAAIC,EAAgB,GAEpB,GAAID,GAAiB,IAAMA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