function createOfflineIssueBlocker({
  enqueueDurably,
  onQueued = () => {},
  createOperationId = () => globalThis.crypto?.randomUUID?.() || String(Date.now()) + '-' + Math.random().toString(16).slice(2),
}) {
  return async function queueOfflineIssueBlocker(item, blocker, present) {
    const admission = await enqueueDurably({
      kind: 'issue-blocker',
      repository: String(item.repository || ''),
      number: Number(item.number || 0),
      blockerRepository: String(blocker.repository || ''),
      blockerNumber: Number(blocker.number || 0),
      present: present === true,
      operationId: String(createOperationId()).slice(0, 128),
    });
    onQueued(item, blocker, present === true, admission);
    return { admission };
  };
}

if (typeof module !== 'undefined' && module.exports) module.exports = createOfflineIssueBlocker;
