@inkandswitch/patchwork-pkg-base 0.0.49 → 0.0.50
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.
- package/package.json +1 -1
- package/packages/drafts/dist/assets/{main-BR_tW0sp.js → main-CCEftK7X.js} +12 -7
- package/packages/drafts/dist/assets/main-CCEftK7X.js.map +1 -0
- package/packages/drafts/dist/index.js +3 -3
- package/packages/tldraw5/dist/tool.js +62 -11
- package/packages/tldraw5/dist/tool.js.map +2 -2
- package/packages/drafts/dist/assets/main-BR_tW0sp.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-CCEftK7X.js","sources":["../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js","../../node_modules/.pnpm/debug@4.4.3_supports-color@7.2.0/node_modules/debug/src/common.js","../../node_modules/.pnpm/debug@4.4.3_supports-color@7.2.0/node_modules/debug/src/browser.js","../../node_modules/.pnpm/cabbages@0.2.10_supports-color@7.2.0/node_modules/cabbages/output/cabbages.js","../../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.47_supports-color@7.2._7da048330ce229efe623709826d179e7/node_modules/solid-automerge/out/context.js","../../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.47_supports-color@7.2._7da048330ce229efe623709826d179e7/node_modules/solid-automerge/out/createDocSignal.js","../../node_modules/.pnpm/@inkandswitch+patchwork-providers-solid@0.2.7_@automerge+automerge-repo@2.6.0-subductio_da34c10f1bc63895d710f582f3ec3c59/node_modules/@inkandswitch/patchwork-providers-solid/dist/index.js","../../src/DraftsSidebar.tsx","../../src/main.tsx"],"sourcesContent":["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\t\tlet namespacesCache;\n\t\tlet enabledCache;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => {\n\t\t\t\tif (enableOverride !== null) {\n\t\t\t\t\treturn enableOverride;\n\t\t\t\t}\n\t\t\t\tif (namespacesCache !== createDebug.namespaces) {\n\t\t\t\t\tnamespacesCache = createDebug.namespaces;\n\t\t\t\t\tenabledCache = createDebug.enabled(namespace);\n\t\t\t\t}\n\n\t\t\t\treturn enabledCache;\n\t\t\t},\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\t\tcreateDebug.namespaces = namespaces;\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '')\n\t\t\t.trim()\n\t\t\t.replace(/\\s+/g, ',')\n\t\t\t.split(',')\n\t\t\t.filter(Boolean);\n\n\t\tfor (const ns of split) {\n\t\t\tif (ns[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(ns.slice(1));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(ns);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the given string matches a namespace template, honoring\n\t * asterisks as wildcards.\n\t *\n\t * @param {String} search\n\t * @param {String} template\n\t * @return {Boolean}\n\t */\n\tfunction matchesTemplate(search, template) {\n\t\tlet searchIndex = 0;\n\t\tlet templateIndex = 0;\n\t\tlet starIndex = -1;\n\t\tlet matchIndex = 0;\n\n\t\twhile (searchIndex < search.length) {\n\t\t\tif (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {\n\t\t\t\t// Match character or proceed with wildcard\n\t\t\t\tif (template[templateIndex] === '*') {\n\t\t\t\t\tstarIndex = templateIndex;\n\t\t\t\t\tmatchIndex = searchIndex;\n\t\t\t\t\ttemplateIndex++; // Skip the '*'\n\t\t\t\t} else {\n\t\t\t\t\tsearchIndex++;\n\t\t\t\t\ttemplateIndex++;\n\t\t\t\t}\n\t\t\t} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition\n\t\t\t\t// Backtrack to the last '*' and try to match more characters\n\t\t\t\ttemplateIndex = starIndex + 1;\n\t\t\t\tmatchIndex++;\n\t\t\t\tsearchIndex = matchIndex;\n\t\t\t} else {\n\t\t\t\treturn false; // No match\n\t\t\t}\n\t\t}\n\n\t\t// Handle trailing '*' in template\n\t\twhile (templateIndex < template.length && template[templateIndex] === '*') {\n\t\t\ttemplateIndex++;\n\t\t}\n\n\t\treturn templateIndex === template.length;\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names,\n\t\t\t...createDebug.skips.map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tfor (const skip of createDebug.skips) {\n\t\t\tif (matchesTemplate(name, skip)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (const ns of createDebug.names) {\n\t\t\tif (matchesTemplate(name, ns)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\t// eslint-disable-next-line no-return-assign\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","// cabbages.ts\nimport debug from \"debug\";\nvar log = debug(\"cabbages\");\nfunction pojo(target) {\n return typeof target == \"object\" && typeof target != null && Object.getPrototypeOf(target) == Object.prototype;\n}\nvar BLOCK_MARKER = \"\\uFFFC\";\nfunction apply(target, ...rest) {\n if (rest.length == 0) {\n log(\"empty patch\");\n return;\n }\n const [path, range, val] = rest;\n let p = [...path];\n while (true) {\n let key = p.shift();\n if (!p.length) {\n const RANGE_ARRAY = Array.isArray(range);\n if (pojo(target) && RANGE_ARRAY && typeof key == \"undefined\" && typeof range[0] == \"string\") {\n delete target[range[0]];\n return;\n }\n if (RANGE_ARRAY || typeof range == \"number\") {\n if (typeof key == \"undefined\") {\n throw new Error(\"cant treat top level as a seq\");\n }\n key = key;\n let [start, end] = Array.isArray(range) ? range : [range, range + 1];\n const ZERO_LENGTH = Array.isArray(range) && range.length == 0;\n if (!ZERO_LENGTH && (start == null || end == null)) {\n throw new RangeError(\"it's all or nothing, no half measures\");\n }\n const DELETE = typeof val == \"undefined\";\n const INSERT = start === end && !DELETE;\n const APPEND = ZERO_LENGTH && !DELETE;\n const REPLACE = !INSERT && !DELETE && !APPEND;\n if (typeof target[key] == \"undefined\") {\n if (typeof target == \"string\") {\n return;\n } else if (typeof val == \"string\") {\n target[key] = \"\";\n } else {\n target[key] = [];\n }\n }\n let seq = target[key];\n if (Array.isArray(seq)) {\n if (APPEND) {\n Array.isArray(val) ? seq.push(...val) : seq.push(val);\n return;\n }\n if (INSERT || REPLACE) {\n Array.isArray(val) ? seq.splice(start, end - start, ...val) : seq.splice(start, end - start, val);\n return;\n }\n if (DELETE) {\n seq.splice(start, end - start);\n return;\n }\n throw new Error(\"i don't know what happened\");\n }\n if (typeof seq == \"string\") {\n if (APPEND) {\n target[key] = seq + val;\n return;\n }\n if (REPLACE || INSERT) {\n target[key] = seq.slice(0, start) + (typeof val == \"string\" ? val : val.map(\n (n) => typeof n == \"string\" ? n : BLOCK_MARKER\n ).join(\"\")) + seq.slice(end);\n return;\n }\n if (DELETE) {\n target[key] = seq.slice(0, start) + seq.slice(end);\n return;\n }\n throw new Error(\"i don't know what happened\");\n }\n if (pojo(seq) && RANGE_ARRAY && typeof range[0] == \"string\") {\n delete seq[range[0]];\n return;\n }\n throw new Error(\"not implemented\");\n }\n if (typeof key == \"undefined\") {\n if (typeof range != \"string\") {\n throw new Error(`can't index top-level map with ${range}`);\n }\n if (typeof val == \"undefined\") {\n delete target[range];\n } else {\n target[range] = val;\n }\n return;\n }\n if (typeof target[key] == \"undefined\") {\n target[key] = {};\n }\n if (RANGE_ARRAY) {\n let [a, b] = range;\n if (a != null && b != null) {\n if (typeof val == \"undefined\" && a != null && b != null) {\n delete target[key][a || b];\n } else {\n target[key][a || b] = val;\n }\n }\n } else {\n if (typeof val == \"undefined\") {\n delete target[key][range];\n } else if (typeof target[key] == \"string\") {\n return;\n } else {\n target[key][range] = val;\n }\n }\n return;\n }\n if (typeof key == \"undefined\") {\n throw new Error(\"cant treat top level as a seq\");\n }\n key = key;\n let nextkey = p[0];\n if (typeof target[key] == \"undefined\") {\n if (typeof nextkey == \"string\") {\n target[key] = {};\n } else if (typeof nextkey == \"number\") {\n target[key] = [];\n } else {\n throw new Error(`can't go down this road ${target}.${key}.${nextkey}`);\n }\n }\n target = target[key];\n }\n}\nvar patch = apply;\nfunction get(obj, key) {\n for (let p = 0; p < key.length; p++) {\n obj = obj ? obj[key[p]] : void 0;\n }\n return obj;\n}\nfunction fromAutomerge(autopatch, payload) {\n const path = autopatch.path.slice(0, -1);\n const key = autopatch.path[autopatch.path.length - 1];\n switch (autopatch.action) {\n case \"mark\":\n case \"unmark\":\n log(\n `skipping ${autopatch.action} because it doesn't affect material reality`\n );\n return [];\n case \"inc\":\n if (payload) {\n return [path, key, get(payload.patchInfo.after, autopatch.path)];\n } else {\n throw new Error(\n `can't apply ${autopatch.action} without payload argument`\n );\n }\n case \"conflict\":\n if (payload) {\n return [path, key, get(payload.patchInfo.after, autopatch.path)];\n } else {\n throw new Error(\n `can't apply ${autopatch.action} without payload argument`\n );\n }\n case \"del\": {\n return typeof key == \"string\" ? [path, key] : [path, [key, key + (autopatch.length || 1)]];\n }\n case \"insert\": {\n return [\n path,\n [key, key],\n structuredClone(autopatch.values)\n ];\n }\n case \"splice\": {\n return [path, [key, key], [autopatch.value]];\n }\n case \"put\": {\n return [path, key, structuredClone(autopatch.value)];\n }\n }\n}\nexport {\n apply,\n fromAutomerge,\n patch,\n pojo\n};\n","\"use strict\";\nimport { createContext } from \"solid-js\";\nexport const RepoContext = createContext(\n null\n);\n//# sourceMappingURL=context.js.map\n","\"use strict\";\nimport { createEffect, onCleanup } from \"solid-js\";\nimport { createSignal } from \"solid-js\";\nexport default function createDocSignal(handle) {\n const [signal, setSignal] = createSignal(handle()?.doc());\n createEffect(() => {\n const h = handle();\n function update() {\n setSignal(() => h?.doc());\n }\n update();\n if (h) {\n h.on(\"change\", update);\n onCleanup(() => h.off(\"change\", update));\n }\n });\n return signal;\n}\n//# sourceMappingURL=createDocSignal.js.map\n","import { createEffect, createSignal, onCleanup, onMount, } from \"solid-js\";\nimport { createStore, reconcile } from \"solid-js/store\";\nimport * as Providers from \"@inkandswitch/patchwork-providers\";\nfunction resolveElement(source) {\n return typeof source === \"function\" ? source() : source;\n}\n/**\n * Generic reactive request. Resolves the first value a provider emits for\n * `selector` (via the one-shot `request` helper) and returns an accessor that\n * reads `undefined` until then. `T` is the response type.\n */\nexport function request(element, selector) {\n const [value, setValue] = createSignal(undefined);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n Providers.request(target, selector).then((v) => {\n if (v == null)\n return;\n setValue(() => v);\n });\n });\n return value;\n}\nexport function subscribe(element, selector, initialValue) {\n const [value, setValue] = createSignal(initialValue);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n const unsubscribe = Providers.subscribe(target, selector, setValue);\n onCleanup(unsubscribe);\n });\n return value;\n}\n/**\n * Store-backed subscription. Use this when a consumer wants Solid's\n * fine-grained nested reactivity for incoming JSON object or array snapshots.\n * Requires an initial object/array so the store has a stable root.\n *\n * `reconcile` preserves stable object/array identity where possible, so this\n * helper is not a good fit when the top-level value is used as an identity key\n * for resources or memos.\n */\nexport function subscribeReconciled(element, selector, initialValue) {\n const [store, setStore] = createStore(initialValue);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n const unsubscribe = Providers.subscribe(target, selector, (v) => {\n setStore(reconcile(v));\n });\n onCleanup(unsubscribe);\n });\n return store;\n}\n/**\n * Handle-specialized subscription. Use when the answering provider emits an\n * `AutomergeUrl`. The handle is recovered locally from the global repo\n * (`window.repo`), so it stays fully live — reads project reactively and writes go\n * straight back to the same repo. Returns `[doc, handle]` matching the shape\n * of `solid-automerge`'s `useDocument`; both read `undefined` until the first\n * url arrives. `T` is the doc shape inside the handle.\n */\nexport function subscribeDoc(element, selector) {\n const [handle, setHandle] = createSignal(undefined);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n let canceled = false;\n const unsubscribe = Providers.subscribe(target, selector, (url) => {\n if (!url)\n return;\n const repo = \"repo\" in window ? window.repo : undefined;\n if (!repo)\n return;\n void Promise.resolve(repo.find(url)).then((h) => {\n if (canceled)\n return;\n setHandle(() => h);\n });\n });\n onCleanup(() => {\n canceled = true;\n unsubscribe();\n });\n });\n // Mirror the doc into a store by `reconcile`-ing against the *materialized*\n // snapshot (`handle.doc()`) on every change, rather than replaying the\n // change's incremental patches (as `solid-automerge`'s `createDocumentProjection`\n // / `autoproduce` does).\n //\n // A whole-value write such as `doc.list = [...]` is lowered by Automerge to\n // `putObjectFromHydrate`, whose patch stream is a `put` that materializes the\n // new container *plus* per-element `insert` patches. Replaying that delta with\n // `applyPatches` double-applies the contents — the `put` seeds `[a, b]`, then\n // the inserts splice `a, b` in again, yielding `[a, b, a, b]` — even though the\n // document itself is correct. The materialized snapshot is always\n // authoritative, so reconciling against it is robust to any valid change,\n // whole-array reassignment included.\n const [store, setStore] = createStore({});\n const [ready, setReady] = createSignal(false);\n createEffect(() => {\n const h = handle();\n if (!h) {\n setReady(false);\n return;\n }\n const sync = () => {\n setStore(reconcile((h.doc() ?? {})));\n setReady(true);\n };\n sync();\n h.on(\"change\", sync);\n onCleanup(() => h.off(\"change\", sync));\n });\n const doc = () => (ready() ? store : undefined);\n return [doc, handle];\n}\n","import \"./styles.css\";\nimport {\n createEffect,\n createMemo,\n createSignal,\n For,\n onCleanup,\n Show,\n type Accessor,\n} from \"solid-js\";\nimport { createDocSignal } from \"solid-automerge\";\nimport type {\n AutomergeUrl,\n DocHandle,\n Repo,\n UrlHeads,\n} from \"@automerge/automerge-repo/slim\";\nimport {\n decodeHeads,\n encodeHeads,\n isValidAutomergeUrl,\n} from \"@automerge/automerge-repo/slim\";\nimport * as Automerge from \"@automerge/automerge/slim\";\nimport {\n subscribe,\n subscribeDoc,\n} from \"@inkandswitch/patchwork-providers-solid\";\nimport type {\n ActorAttributionDoc,\n ChangeGroup,\n ChangeGroupDoc,\n CheckedOutDraft,\n CloneEntry,\n DraftCheckpoint,\n DraftDoc,\n DraftList,\n DraftMemberDoc,\n DraftSummary,\n HasDrafts,\n} from \"./draft-types\";\nimport {\n computeEditCounts,\n computeRangeEditCounts,\n getDocCreationTime,\n sameHeads,\n} from \"./change-group-cache\";\nimport { ensureMainDraft } from \"./draft-docs\";\n\n// Seed for the read-only `draft:list` subscription until the provider answers.\n// `main.url` is a placeholder; the Main card displays the host doc url instead.\nconst EMPTY_DRAFT_LIST: DraftList = {\n main: {\n url: \"\" as AutomergeUrl,\n parent: null,\n members: [],\n childCount: 0,\n name: null,\n changeGroupDocUrl: null,\n },\n drafts: [],\n actorAttributionUrl: null,\n};\n\n// Shown in the panel footer, logged on load, and stamped into fork\n// diagnostics; bump on deploy to tell builds apart.\nconst DRAFTS_VERSION = \"0.0.45\";\n\n// Logged at module load so the console shows which build is running even\n// before the panel renders.\nconsole.log(`[drafts] DraftsSidebar v${DRAFTS_VERSION} loaded`);\n\nexport function DraftsSidebar(props: { element: HTMLElement }) {\n const [hostDoc, hostDocHandle] = subscribeDoc<HasDrafts>(props.element, {\n type: \"draft:root-doc\",\n });\n\n // Selection only: which draft is checked out (writeable).\n const [, checkedOutHandle] = subscribeDoc<CheckedOutDraft>(props.element, {\n type: \"draft:checked-out\",\n });\n\n // Read the checkout doc coarsely from the live handle (handle.doc()) rather\n // than a fine-grained patch-replay projection: the projection can render a\n // whole-value write doubled, whereas handle.doc() is always the correct\n // materialized document.\n const checkedOut = createDocSignal(checkedOutHandle);\n const selected = createMemo<AutomergeUrl | null>(\n () => checkedOut()?.checkedOut ?? null\n );\n\n // The eye toggle's state, derived from the checkpoint itself (no separate\n // flag): the eye is open — diffs showing — iff the current checkpoint\n // carries any diff baseline (`from`).\n const eyeOpen = createMemo<boolean>(() => {\n const at = checkedOut()?.at;\n return !!at && Object.values(at).some((e) => e.from !== undefined);\n });\n\n // Whether the view is actually pinned to history (any member has a `to`),\n // as opposed to live-with-baseline (eye open, nothing pinned).\n const isPinned = createMemo<boolean>(() => {\n const at = checkedOut()?.at;\n return !!at && Object.values(at).some((e) => e.to !== undefined);\n });\n\n // Where the scrubber sits: the change whose heads are displayed. Ephemeral,\n // client-only state: the stored checkpoint (`checkedOut.at`) is what\n // actually pins the view; this mirrors it to render the token and the\n // group highlight. Not persisted, so it resets on reload (the pinned view\n // survives).\n const [scrubber, setScrubber] = createSignal<ScrubberState | null>(null);\n\n // Where the diff baseline handle sits: an absolute point in history the\n // diff is measured from, independent of the head (`scrubber`). Ephemeral\n // like the head — resets on reload, while the persisted `from` keeps\n // driving the editor diff. Non-null only while the eye is open and a\n // version is pinned; that is also exactly when the handle renders.\n const [baseliner, setBaseliner] = createSignal<BaselineState | null>(null);\n\n // The derived drafts list (read-only): main plus each draft with its member\n // docs, recomputed and pushed by the provider.\n const list = subscribe<DraftList>(\n props.element,\n { type: \"draft:list\" },\n EMPTY_DRAFT_LIST\n );\n\n // Feed the module-level attribution store from this host doc's attribution\n // doc, so `AuthorAvatars` can render contacts instead of raw actor ids.\n createEffect(() => {\n const url = list().actorAttributionUrl;\n const repo = getRepo();\n if (!url || !repo) return;\n let disposed = false;\n let off: (() => void) | null = null;\n void repo.find<ActorAttributionDoc>(url).then(\n (handle) => {\n if (disposed) return;\n const update = () => {\n const actors = handle.doc()?.actors;\n if (actors && Object.keys(actors).length > 0) {\n setActorContacts((prev) => ({ ...prev, ...actors }));\n }\n };\n handle.on(\"change\", update);\n off = () => handle.off(\"change\", update);\n update();\n },\n (err) => {\n console.warn(\"[drafts] failed to load actor attribution:\", url, err);\n }\n );\n onCleanup(() => {\n disposed = true;\n off?.();\n });\n });\n\n const isMainSelected = createMemo(() => selected() === null);\n // Drafting off a folder isn't supported yet, so creating a draft is disabled\n // while viewing a folder on Main.\n const isFolder = createMemo(\n () => hostDoc()?.[\"@patchwork\"]?.type === \"folder\"\n );\n\n const selectDraft = (url: AutomergeUrl | null) => {\n const handle = checkedOutHandle();\n if (!handle) return;\n setScrubber(null);\n setBaseliner(null);\n handle.change((d) => {\n d.checkedOut = url;\n // Switching drafts (or to main) returns to the live latest heads.\n d.at = null;\n });\n };\n\n const getRepo = (): Repo | undefined =>\n \"repo\" in window ? window.repo : undefined;\n\n // Monotonic counter so a slow checkpoint computation can't overwrite a newer\n // scrub position (a drag fires one recompute per snapped change).\n let scrubSeq = 0;\n\n // Recompute and persist the checkpoint from the current head (`scrubber`)\n // and baseline (`baseliner`) signals: `to`s follow the head, `from`s follow\n // the baseline (absolute, independent of the head). With the eye closed the\n // baseline is null and no `from` is written. The token and row highlight\n // update immediately from the signals; the checkpoint follows async.\n // `draftUrl` is `null` for main. Guarded by `scrubSeq` so a slower\n // computation can't clobber a newer drag.\n const applyPins = (\n draftUrl: AutomergeUrl | null,\n members: DraftMemberDoc[]\n ) => {\n const handle = checkedOutHandle();\n const repo = getRepo();\n if (!handle || !repo) return;\n const head = scrubber();\n if (!head) return;\n const bl = baseliner();\n const base: CheckpointBase = bl ? { beforeTime: bl.time } : \"none\";\n const seq = ++scrubSeq;\n void (async () => {\n const checkpoint = await computeCheckpoint(repo, members, head.head, base);\n // A newer scrub landed while this one was computing; drop it.\n if (seq !== scrubSeq) return;\n handle.change((d) => {\n d.checkedOut = draftUrl;\n d.at = checkpoint;\n });\n })();\n };\n\n // Move the head (the version being viewed); the baseline stays where it is.\n const onScrub = (\n draftUrl: AutomergeUrl | null,\n members: DraftMemberDoc[],\n scrub: ScrubberState\n ) => {\n setScrubber(scrub);\n applyPins(draftUrl, members);\n };\n\n // Move the diff baseline; the head stays where it is. Only reachable while\n // the eye is open and pinned (that is when the handle renders).\n const onBaselineScrub = (\n draftUrl: AutomergeUrl | null,\n members: DraftMemberDoc[],\n base: BaselineState\n ) => {\n setBaseliner(base);\n applyPins(draftUrl, members);\n };\n\n // The member docs of the current selection (`null` = main), for the eye\n // and checkpoint handlers below.\n const membersFor = (draftUrl: AutomergeUrl | null): DraftMemberDoc[] =>\n draftUrl\n ? (list().drafts.find((s) => s.url === draftUrl)?.members ?? [])\n : list().main.members;\n\n // The eye-open checkpoint for a live (unpinned) draft: every cloned member\n // diffs against its fork point, nothing pinned.\n const forkBaselines = (draftUrl: AutomergeUrl): DraftCheckpoint => {\n const at: DraftCheckpoint = {};\n for (const member of membersFor(draftUrl)) {\n if (member.clonedAt) at[member.url] = { from: member.clonedAt };\n }\n return at;\n };\n\n // Drop the time pin but stay on the same draft: back to live latest heads.\n // With the eye open on a draft the diff baselines survive — the view goes\n // live but keeps showing what changed since the fork point. (A live main\n // has nothing to diff against, so there the eye closes with the pin.)\n const clearCheckpoint = () => {\n const handle = checkedOutHandle();\n if (!handle) return;\n setScrubber(null);\n // Unpinned: the baseline handle only shows while pinned, so drop it.\n setBaseliner(null);\n const draftUrl = selected();\n const baselines = eyeOpen() && draftUrl ? forkBaselines(draftUrl) : null;\n handle.change((d) => {\n d.at =\n baselines && Object.keys(baselines).length > 0 ? baselines : null;\n });\n };\n\n // The eye toggle: show or hide diff highlighting. The eye holds no state of\n // its own — it rewrites the checkpoint's per-member `from`s (which the\n // provider serves as `draft:baseline`), and its open/closed state is read\n // back off the checkpoint (`eyeOpen`).\n const toggleEye = () => {\n const handle = checkedOutHandle();\n const repo = getRepo();\n if (!handle || !repo) return;\n\n if (eyeOpen()) {\n // Close: strip the baselines; a pin (`to`) stays untouched. Baseline-\n // only entries disappear entirely, so a live view's `at` goes to null.\n setBaseliner(null);\n handle.change((d) => {\n if (!d.at) return;\n const urls = Object.keys(d.at) as AutomergeUrl[];\n if (!urls.some((u) => d.at?.[u]?.to !== undefined)) {\n d.at = null;\n return;\n }\n for (const url of urls) {\n const entry = d.at[url];\n if (!entry) continue;\n if (entry.to === undefined) delete d.at[url];\n else delete entry.from;\n }\n });\n return;\n }\n\n const draftUrl = selected();\n const s = scrubber();\n if (isPinned() && s) {\n // Pinned with a known scrub position: seed the baseline handle at the\n // scrubbed group's start and recompute the checkpoint against it. The\n // handle's exact offset is resolved by the changes list, which knows\n // the group's size (BASELINE_GROUP_START).\n setBaseliner({\n groupId: s.groupId,\n offset: BASELINE_GROUP_START,\n time: s.groupStartTime,\n });\n const members = membersFor(draftUrl);\n const seq = ++scrubSeq;\n void (async () => {\n const checkpoint = await computeCheckpoint(repo, members, s.head, {\n beforeTime: s.groupStartTime,\n });\n if (seq !== scrubSeq) return;\n handle.change((d) => {\n d.at = checkpoint;\n });\n })();\n return;\n }\n\n if (isPinned()) {\n // Pinned but the scrub position is unknown (the sidebar remounted\n // while the pin survived): fall back to diffing the pinned view\n // against the fork point.\n const clonedAt = new Map(\n membersFor(draftUrl).map((m) => [m.url, m.clonedAt])\n );\n handle.change((d) => {\n if (!d.at) return;\n for (const url of Object.keys(d.at) as AutomergeUrl[]) {\n const entry = d.at[url];\n if (!entry) continue;\n entry.from = clonedAt.get(url) ?? encodeHeads([]);\n }\n });\n return;\n }\n\n // Live on a draft: show what changed since the fork point. (Live on\n // main the button is disabled — there is no baseline to diff against.)\n if (!draftUrl) return;\n const baselines = forkBaselines(draftUrl);\n if (Object.keys(baselines).length === 0) return;\n handle.change((d) => {\n d.at = baselines;\n });\n };\n\n // While the eye is open on a live (unpinned) draft, keep the baseline map\n // in step with the member list: a doc forked after the eye was opened gets\n // its fork-point baseline added here. (The provider serves baselines only\n // from the checkpoint — there is no implicit fallback to cover it.)\n createEffect(() => {\n const at = checkedOut()?.at;\n const draftUrl = selected();\n const handle = checkedOutHandle();\n if (!at || !draftUrl || !handle) return;\n const entries = Object.values(at);\n if (entries.length === 0) return;\n if (entries.some((e) => e.to !== undefined)) return; // pinned: onScrub owns it\n if (!entries.some((e) => e.from !== undefined)) return; // eye closed\n const missing = membersFor(draftUrl).filter(\n (m) => m.clonedAt !== null && !at[m.url]\n );\n if (missing.length === 0) return;\n handle.change((d) => {\n if (!d.at) return;\n for (const m of missing) {\n if (m.clonedAt) d.at[m.url] = { from: m.clonedAt };\n }\n });\n });\n\n // Fork the current selection as a new child draft. `atVersion` picks the\n // fork point (the two menu items): true clones every member doc at the\n // heads it had as of the scrubbed version, false forks at the latest\n // heads. The new draft is parented to the selection — merging it later\n // lands back here, not on main. Pre-populating `DraftDoc.clones` means the\n // overlay's lazy `resolveClone` reuses these entries instead of forking\n // the originals at current heads (which matters when forking off a draft:\n // the clones must branch off the draft's clones). Forking main live needs\n // no eager clones — main's members are the originals, so the lazy path is\n // exactly right. Members with no changes at or before a pinned version\n // (created later) are left out; the version's docs don't reference them\n // yet, so they are normally never resolved beneath the draft.\n const onForkSelection = async (atVersion: boolean) => {\n if (isFolder()) return;\n const docHandle = hostDocHandle();\n if (!docHandle) return;\n const repo = getRepo();\n if (!repo) {\n console.warn(\"[drafts] window.repo is not set\");\n return;\n }\n\n const parentUrl = selected(); // null = main\n const members = membersFor(parentUrl);\n const head = atVersion ? (scrubber()?.head ?? null) : null;\n\n const clones: Record<AutomergeUrl, CloneEntry> = {};\n if (head) {\n // Reuse the scrub machinery to resolve per-doc heads at this version\n // (only the `to`s are read, so no diff baseline).\n const checkpoint = await computeCheckpoint(repo, members, head, \"none\");\n for (const member of members) {\n const to = checkpoint[member.url]?.to;\n if (!to) continue;\n let handle: DocHandle<unknown> | null = null;\n try {\n // Clone the doc the timeline read its changes from (the draft's\n // clone when forking off a draft), pinned to the version's heads.\n // Keyed by the original url so baselines and merge-back resolve.\n handle = await repo.find<unknown>(member.cloneUrl ?? member.url);\n const clone = cloneAtVersion(repo, handle, to);\n clones[member.url] = { cloneUrl: clone.url, clonedAt: to };\n } catch (err) {\n reportForkFailure(\n handle ? collectForkDiagnostic(handle, member, to) : null,\n err\n );\n }\n }\n } else if (parentUrl) {\n // Forking a draft at its latest heads: branch each member off the\n // draft's clone (not the original, which lacks the draft's changes).\n for (const member of members) {\n try {\n const source = await repo.find<unknown>(\n member.cloneUrl ?? member.url\n );\n const clonedAt = source.heads();\n const clone = repo.clone(source);\n clones[member.url] = { cloneUrl: clone.url, clonedAt };\n } catch (err) {\n console.warn(\"[drafts] failed to fork member:\", member, err);\n }\n }\n }\n\n const mainDraft = await ensureMainDraft(repo, docHandle);\n const parentHandle = parentUrl\n ? await repo.find<DraftDoc>(parentUrl)\n : mainDraft;\n // Default name from a monotonic counter on the main draft, stamped at\n // creation so numbering stays stable as drafts are merged or deleted.\n let draftNumber = 1;\n mainDraft.change((d) => {\n d.draftCounter = (d.draftCounter ?? 0) + 1;\n draftNumber = d.draftCounter;\n });\n const draft = repo.create<DraftDoc>({\n \"@patchwork\": { type: \"draft\" },\n name: `Draft ${draftNumber}`,\n parent: parentHandle.url,\n drafts: [],\n clones,\n });\n parentHandle.change((d) => {\n d.drafts.push(draft.url);\n });\n selectDraft(draft.url);\n };\n\n // Rename a draft, or main (`url === null`). Names live on the `DraftDoc`;\n // renaming main creates the main draft doc if this is the first draft-ish\n // action on the host doc. `null` clears back to the default label.\n const onRename = async (url: AutomergeUrl | null, name: string | null) => {\n const repo = getRepo();\n if (!repo) return;\n let handle: DocHandle<DraftDoc>;\n if (url === null) {\n const docHandle = hostDocHandle();\n if (!docHandle) return;\n handle = await ensureMainDraft(repo, docHandle);\n } else {\n handle = await repo.find<DraftDoc>(url);\n }\n handle.change((d) => {\n if (name) d.name = name;\n else delete d.name;\n });\n };\n\n // The selected draft's summary and parent, driving the merge button on the\n // selected draft's header (it merges up into the parent).\n const selectedSummary = createMemo<DraftSummary | null>(\n () => list().drafts.find((s) => s.url === selected()) ?? null\n );\n const mergeParentUrl = createMemo<AutomergeUrl | null>(\n () => selectedSummary()?.parent ?? null\n );\n // Display name of the merge target (the parent): the tooltip and the\n // confirm dialog both name it.\n const mergeTargetName = createMemo<string>(() => {\n const parentUrl = mergeParentUrl();\n if (parentUrl === null || parentUrl === list().main.url) {\n return list().main.name ?? \"Main\";\n }\n return list().drafts.find((s) => s.url === parentUrl)?.name ?? \"Draft\";\n });\n\n // Label of the menu's fork-from-version item, e.g. \"Fork from Jul 24,\n // 3:12 PM\" — the change the scrubber sits on. Null (item hidden) while\n // the timeline isn't pinned.\n const forkAtLabel = createMemo<string | null>(() => {\n if (!isPinned()) return null;\n const time = scrubber()?.head.time;\n if (!time) return null;\n return `Fork from ${formatVersionTime(time)}`;\n });\n\n // True while the menu's merge item is hovered: the target card (the\n // selected draft's parent) lights up via `data-merge-target`.\n const [mergeHighlight, setMergeHighlight] = createSignal(false);\n\n // Nesting depth for a card's indentation: hops up the parent chain until\n // main (a top-level draft's parent is the main draft, which isn't in the\n // drafts list, so it counts 0). Cycle-guarded — parents are plain urls.\n const draftDepth = (summary: DraftSummary): number => {\n const byUrl = new Map(list().drafts.map((s) => [s.url, s]));\n const seen = new Set<AutomergeUrl>();\n let depth = 0;\n let parent = summary.parent;\n while (parent && byUrl.has(parent) && !seen.has(parent)) {\n seen.add(parent);\n depth++;\n parent = byUrl.get(parent)!.parent;\n }\n return depth;\n };\n\n // Merge the selected draft into its parent — the draft it was forked off,\n // or main for a top-level draft — then check the parent out. The merged\n // draft's `mergedAt` stamp hides it from the list.\n const onMergeDraft = async () => {\n const draftUrl = selected();\n if (!draftUrl) return;\n const parentUrl = mergeParentUrl();\n if (!window.confirm(`Merge this draft into \"${mergeTargetName()}\"?`))\n return;\n const repo = getRepo();\n if (!repo) {\n console.warn(\"[drafts] window.repo is not set\");\n return;\n }\n const draftHandle = await repo.find<DraftDoc>(draftUrl);\n await mergeDraft(repo, draftHandle);\n selectDraft(parentUrl && parentUrl !== list().main.url ? parentUrl : null);\n };\n\n // Delete the selected draft: unlink it from its parent's `drafts` list,\n // which drops it — along with any drafts forked from it — from every\n // peer's tree walk. Nothing is merged and the docs themselves are left in\n // place; the draft just becomes unreachable.\n const onDeleteDraft = async () => {\n const draftUrl = selected();\n if (!draftUrl) return;\n const childCount = selectedSummary()?.childCount ?? 0;\n const warning =\n childCount > 0\n ? \"Delete this draft? Drafts forked from it will be deleted too. This can't be undone.\"\n : \"Delete this draft? This can't be undone.\";\n if (!window.confirm(warning)) return;\n const repo = getRepo();\n if (!repo) {\n console.warn(\"[drafts] window.repo is not set\");\n return;\n }\n const parentUrl = mergeParentUrl();\n let parentHandle: DocHandle<DraftDoc>;\n if (parentUrl) {\n parentHandle = await repo.find<DraftDoc>(parentUrl);\n } else {\n // Legacy drafts without a `parent` field hang off the main draft.\n const docHandle = hostDocHandle();\n if (!docHandle) return;\n parentHandle = await ensureMainDraft(repo, docHandle);\n }\n parentHandle.change((d) => {\n const i = d.drafts.indexOf(draftUrl);\n if (i >= 0) d.drafts.splice(i, 1);\n });\n selectDraft(parentUrl && parentUrl !== list().main.url ? parentUrl : null);\n };\n\n return (\n <div class=\"drafts-panel\">\n <Show\n when={hostDoc()}\n fallback={<div class=\"drafts-empty\">No document selected.</div>}\n >\n <div class=\"drafts-list\">\n <MainCard\n hostDocUrl={hostDocHandle()?.url}\n isSelected={isMainSelected()}\n members={() => list().main.members}\n changeGroupDocUrl={list().main.changeGroupDocUrl}\n name={list().main.name}\n onRename={(name) => void onRename(null, name)}\n onSelect={() => selectDraft(null)}\n onScrub={(scrub) => onScrub(null, list().main.members, scrub)}\n scrubber={() => (isMainSelected() ? scrubber() : null)}\n onBaselineScrub={(base) =>\n onBaselineScrub(null, list().main.members, base)\n }\n baseliner={() => (isMainSelected() ? baseliner() : null)}\n checkpoint={() => (isMainSelected() ? (checkedOut()?.at ?? null) : null)}\n hasCheckpoint={isMainSelected() && isPinned()}\n onReturnToLatest={clearCheckpoint}\n eyeOpen={isMainSelected() && eyeOpen()}\n eyeDisabled={!isPinned()}\n onToggleEye={toggleEye}\n forkDisabled={isFolder()}\n onFork={() => void onForkSelection(false)}\n forkAtLabel={forkAtLabel()}\n onForkAt={() => void onForkSelection(true)}\n isMergeTarget={\n mergeHighlight() && mergeParentUrl() === list().main.url\n }\n />\n <For each={list().drafts}>\n {(summary) => (\n <DraftCard\n url={summary.url}\n members={summary.members}\n changeGroupDocUrl={summary.changeGroupDocUrl}\n mainDocUrl={hostDocHandle()?.url}\n isSelected={selected() === summary.url}\n name={summary.name}\n depth={draftDepth(summary)}\n onRename={(name) => void onRename(summary.url, name)}\n onSelect={selectDraft}\n onScrub={(scrub) =>\n onScrub(summary.url, summary.members, scrub)\n }\n scrubber={() =>\n selected() === summary.url ? scrubber() : null\n }\n onBaselineScrub={(base) =>\n onBaselineScrub(summary.url, summary.members, base)\n }\n baseliner={() =>\n selected() === summary.url ? baseliner() : null\n }\n checkpoint={() =>\n selected() === summary.url ? (checkedOut()?.at ?? null) : null\n }\n hasCheckpoint={selected() === summary.url && isPinned()}\n onReturnToLatest={clearCheckpoint}\n eyeOpen={selected() === summary.url && eyeOpen()}\n eyeDisabled={false}\n onToggleEye={toggleEye}\n onFork={() => void onForkSelection(false)}\n forkAtLabel={forkAtLabel()}\n onForkAt={() => void onForkSelection(true)}\n mergeLabel={`Merge into \"${mergeTargetName()}\"`}\n onMerge={() => void onMergeDraft()}\n onMergeHover={setMergeHighlight}\n onDelete={() => void onDeleteDraft()}\n isMergeTarget={\n mergeHighlight() && mergeParentUrl() === summary.url\n }\n />\n )}\n </For>\n </div>\n </Show>\n <div class=\"drafts-version\">v{DRAFTS_VERSION}</div>\n </div>\n );\n}\n\n// Merges every cloned doc back into the parent draft's copy of it — the\n// parent's clone when it has one, the original otherwise (the main draft's\n// identity clones make those the same thing, so a top-level draft merges\n// into the originals) — recording per-clone merge heads for auditing, and\n// marks the draft as merged (which hides it from the list). The merged\n// draft's children are handed up to the merge target, so they never dangle\n// under a hidden draft.\nasync function mergeDraft(\n repo: Repo,\n draftHandle: DocHandle<DraftDoc>\n): Promise<void> {\n const doc = draftHandle.doc();\n const parentHandle = await findMergeTarget(repo, doc?.parent);\n const parentClones = parentHandle?.doc()?.clones ?? {};\n const entries = Object.entries(doc?.clones ?? {}) as [\n AutomergeUrl,\n CloneEntry,\n ][];\n for (const [originalUrl, entry] of entries) {\n const targetUrl = parentClones[originalUrl]?.cloneUrl ?? originalUrl;\n if (entry.cloneUrl === targetUrl) continue;\n const [target, clone] = await Promise.all([\n repo.find<unknown>(targetUrl),\n repo.find<unknown>(entry.cloneUrl),\n ]);\n target.merge(clone);\n const mergedAt = target.heads();\n draftHandle.change((d) => {\n const e = d.clones[originalUrl];\n if (e) e.mergedAt = mergedAt;\n });\n }\n draftHandle.change((d) => {\n d.mergedAt = Date.now();\n });\n\n // Re-parent the merged draft's children onto the merge target: they list\n // under it and their own merges land there (where this draft's changes\n // now live). Their clones branched off this draft's clones, whose history\n // was just merged into the target, so they still merge back cleanly.\n if (parentHandle) {\n const children = (draftHandle.doc()?.drafts ?? []).filter(\n isValidAutomergeUrl\n );\n for (const childUrl of children) {\n try {\n const child = await repo.find<DraftDoc>(childUrl);\n child.change((d) => {\n d.parent = parentHandle.url;\n });\n parentHandle.change((d) => {\n if (!d.drafts.includes(childUrl)) d.drafts.push(childUrl);\n });\n draftHandle.change((d) => {\n const i = d.drafts.indexOf(childUrl);\n if (i >= 0) d.drafts.splice(i, 1);\n });\n } catch (err) {\n console.warn(\n \"[drafts] failed to re-parent child draft after merge:\",\n childUrl,\n err\n );\n }\n }\n }\n}\n\n// Resolve the draft the merge should land in: the nearest non-merged\n// ancestor. A parent that was itself merged away hands its role up the\n// chain (its changes live in *its* merge target), ending at the main draft,\n// which is never merged. Null when the chain can't be resolved — the caller\n// then falls back to merging into the originals.\nasync function findMergeTarget(\n repo: Repo,\n parentUrl: AutomergeUrl | undefined\n): Promise<DocHandle<DraftDoc> | null> {\n const seen = new Set<AutomergeUrl>();\n let cursor = parentUrl;\n while (cursor && isValidAutomergeUrl(cursor) && !seen.has(cursor)) {\n seen.add(cursor);\n try {\n const candidate = await repo.find<DraftDoc>(cursor);\n if (candidate.doc()?.mergedAt === undefined) return candidate;\n cursor = candidate.doc()?.parent;\n } catch (err) {\n console.warn(\n \"[drafts] failed to load ancestor draft for merge; \" +\n \"falling back to merging into the originals:\",\n cursor,\n err\n );\n return null;\n }\n }\n return null;\n}\n\n// --- Cloning a member at a version -------------------------------------------\n// The obvious way — `repo.clone(handle.view(to))`, i.e. wasm `fork_at` — is\n// broken upstream: on documents whose history contains certain concurrent\n// merge changes (as anything synced through subduction ends up with),\n// `fork_at` panics with `MissingOps` in `ChangeCollector::from_build_meta`\n// at *any* heads, and the panic poisons the doc object for the rest of the\n// session (every later call throws \"recursive use of an object detected\").\n// Confirmed offline against automerge 3.3.0-fragments.1 and .2 with a\n// 26-change minimal repro.\n//\n// So the version clone is built without `fork_at`: collect the ancestor\n// closure of the pin heads from the change metadata, bundle exactly those\n// changes (`saveBundle`), hydrate a fresh doc from the bundle\n// (`loadIncremental`), and install it into a new repo handle — the same move\n// `repo.clone` performs internally, minus the panicking wasm path. The\n// resulting doc's heads are exactly `to`, it shares history with the\n// original, and merges back cleanly.\n\n// Build a clone of `handle`'s doc pinned to the `to` heads and register it\n// with the repo. Throws (a plain JS error, no wasm panic) when the pin's\n// ancestry can't be resolved from the doc's change metadata.\nfunction cloneAtVersion(\n repo: Repo,\n handle: DocHandle<unknown>,\n to: UrlHeads\n): DocHandle<unknown> {\n const doc = handle.doc() as Automerge.Doc<unknown>;\n const pinHeads = decodeHeads(to);\n\n // Ancestor closure of the pin heads, walked over the full change metadata.\n const metas = Automerge.getChangesMetaSince(doc, []);\n const byHash = new Map(metas.map((m) => [m.hash, m]));\n const closure = new Set<string>();\n const stack = [...pinHeads];\n while (stack.length > 0) {\n const hash = stack.pop()!;\n if (closure.has(hash)) continue;\n const meta = byHash.get(hash);\n if (!meta) {\n throw new Error(\n `[drafts] change ${hash} is not in the doc's history metadata`\n );\n }\n closure.add(hash);\n stack.push(...meta.deps);\n }\n\n const bundle = Automerge.saveBundle(doc, [...closure]);\n const pinned = Automerge.loadIncremental(Automerge.init<unknown>(), bundle);\n\n const gotHeads = [...Automerge.getHeads(pinned)].sort();\n const wantHeads = [...pinHeads].sort();\n if (JSON.stringify(gotHeads) !== JSON.stringify(wantHeads)) {\n throw new Error(\n `[drafts] version clone heads mismatch: wanted ${wantHeads}, got ${gotHeads}`\n );\n }\n\n const clone = repo.create<unknown>();\n clone.update(() => pinned);\n return clone;\n}\n\n// --- Fork-at-version diagnostics --------------------------------------------\n// When `cloneAtVersion` fails, everything we can learn about the member and\n// the pinned heads is dumped as one JSON block tagged\n// [drafts][fork-diagnostic]; paste that back when reporting.\n\n// Everything we could learn about the member and the pinned heads, plus the\n// final error.\ntype ForkDiagnostic = {\n draftsVersion: string;\n memberUrl: AutomergeUrl;\n sourceUrl: AutomergeUrl;\n memberClonedAt: UrlHeads | null;\n // The version being forked at, as url-encoded heads and as hex hashes.\n to: UrlHeads;\n toHex: string[];\n // The doc's live frontier (hex), for comparison with `toHex`.\n currentHeads: string[] | null;\n // Does the doc itself consider `toHex` a valid point in its history?\n hasHeads: boolean | null;\n // Change hashes the doc knows it is missing ops for, as of `toHex`.\n missingDeps: string[] | null;\n stats: { numChanges: number; numOps: number } | null;\n automerge: {\n jsGitHead: string;\n wasmGitHead: string | null;\n wasmVersion: string | null;\n } | null;\n // Where each pinned hash sits in the doc's history: its topological index,\n // metadata, and whether it is a live head. `known: false` means the doc has\n // no change with that hash at all.\n pinnedChanges: {\n hash: string;\n known: boolean;\n topoIndex: number | null;\n time: number | null;\n actor: string | null;\n seq: number | null;\n deps: string[] | null;\n isCurrentHead: boolean;\n }[];\n // Sedimentree fragment coverage: how the doc's history is bundled.\n // `topoRange` is the [min, max] topological index of the fragment's member\n // changes and `containsPin` whether a pinned hash is one of them — so a\n // fork-depth failure boundary can be read directly against bundle\n // boundaries. A pinned hash buried inside a higher-level bundle is the\n // prime MissingOps suspect.\n fragments:\n | {\n level: number;\n head: string;\n memberCount: number;\n topoRange: [number, number] | null;\n containsPin: boolean;\n }[]\n | null;\n probeErrors: string[];\n failure?: { message: string; stack?: string };\n};\n\n// The saved doc bytes captured before the failing fork, kept out of the JSON\n// report (too big) and exposed on `window.__draftsForkRepro` instead, so the\n// exact failing document can be reproduced offline.\ntype ForkRepro = {\n url: AutomergeUrl;\n toHex: string[];\n docBase64: string;\n};\n\n// Snapshot everything we can read about `handle`'s doc and the pinned heads.\n// Every probe is individually guarded so one bad call doesn't lose the rest.\nfunction collectForkDiagnostic(\n handle: DocHandle<unknown>,\n member: DraftMemberDoc,\n to: UrlHeads\n): ForkDiagnostic {\n const diagnostic: ForkDiagnostic = {\n draftsVersion: DRAFTS_VERSION,\n memberUrl: member.url,\n sourceUrl: member.cloneUrl ?? member.url,\n memberClonedAt: member.clonedAt,\n to,\n toHex: [],\n currentHeads: null,\n hasHeads: null,\n missingDeps: null,\n stats: null,\n automerge: null,\n pinnedChanges: [],\n fragments: null,\n probeErrors: [],\n };\n const probe = (name: string, run: () => void) => {\n try {\n run();\n } catch (err) {\n diagnostic.probeErrors.push(`${name}: ${String(err)}`);\n }\n };\n\n probe(\"decodeHeads\", () => {\n diagnostic.toHex = decodeHeads(to);\n });\n\n const doc = handle.doc() as Automerge.Doc<unknown>;\n\n probe(\"getHeads\", () => {\n diagnostic.currentHeads = Automerge.getHeads(doc);\n });\n probe(\"hasHeads\", () => {\n diagnostic.hasHeads = Automerge.hasHeads(doc, diagnostic.toHex);\n });\n probe(\"getMissingDeps\", () => {\n diagnostic.missingDeps = Automerge.getMissingDeps(doc, diagnostic.toHex);\n });\n probe(\"stats\", () => {\n const s = Automerge.stats(doc);\n diagnostic.stats = { numChanges: s.numChanges, numOps: s.numOps };\n });\n probe(\"releaseInfo\", () => {\n const info = Automerge.releaseInfo();\n diagnostic.automerge = {\n jsGitHead: info.js.gitHead,\n wasmGitHead: info.wasm?.gitHead ?? null,\n wasmVersion: info.wasm?.cargoPackageVersion ?? null,\n };\n });\n probe(\"pinnedChanges\", () => {\n const topo = Automerge.topoHistoryTraversal(doc);\n const metas = Automerge.getChangesMetaSince(doc, []);\n const metaByHash = new Map(metas.map((m) => [m.hash, m]));\n diagnostic.pinnedChanges = diagnostic.toHex.map((hash) => {\n const meta = metaByHash.get(hash);\n const topoIndex = topo.indexOf(hash);\n return {\n hash,\n known: !!meta || topoIndex >= 0,\n topoIndex: topoIndex >= 0 ? topoIndex : null,\n time: meta?.time ?? null,\n actor: meta?.actor ?? null,\n seq: meta?.seq ?? null,\n deps: meta?.deps ?? null,\n isCurrentHead: diagnostic.currentHeads?.includes(hash) ?? false,\n };\n });\n });\n probe(\"fragments\", () => {\n const topo = Automerge.topoHistoryTraversal(doc);\n const topoIndex = new Map(topo.map((h, i) => [h, i]));\n const pinned = new Set(diagnostic.toHex);\n diagnostic.fragments = Automerge.getFragmentMetadata(doc).map((f) => {\n let min = Infinity;\n let max = -Infinity;\n let containsPin = false;\n for (const h of f.members) {\n const i = topoIndex.get(h);\n if (i !== undefined) {\n if (i < min) min = i;\n if (i > max) max = i;\n }\n if (pinned.has(h)) containsPin = true;\n }\n return {\n level: f.level,\n head: f.head,\n memberCount: f.members.length,\n topoRange: min <= max ? ([min, max] as [number, number]) : null,\n containsPin,\n };\n });\n });\n probe(\"saveDoc\", () => {\n // Capture the full doc bytes for an offline repro; published to\n // `window.__draftsForkRepro` by `reportForkFailure`.\n const bytes = Automerge.save(doc);\n let binary = \"\";\n const CHUNK = 0x8000;\n for (let i = 0; i < bytes.length; i += CHUNK) {\n binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK));\n }\n lastForkRepro = {\n url: member.url,\n toHex: diagnostic.toHex,\n docBase64: btoa(binary),\n };\n });\n\n return diagnostic;\n}\n\n// The most recent member's saved bytes, captured by `collectForkDiagnostic`\n// and published by `reportForkFailure` when its member's fork fails.\nlet lastForkRepro: ForkRepro | null = null;\n\n// Dump the diagnostic and the error as one copy-pasteable JSON block.\nfunction reportForkFailure(\n diagnostic: ForkDiagnostic | null,\n err: unknown\n): void {\n const failure = {\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : undefined,\n };\n if (!diagnostic) {\n console.error(\n \"[drafts][fork-diagnostic] failed before diagnostics could be gathered:\",\n failure\n );\n return;\n }\n diagnostic.failure = failure;\n if (lastForkRepro && lastForkRepro.url === diagnostic.memberUrl) {\n (window as unknown as Record<string, unknown>).__draftsForkRepro =\n lastForkRepro;\n }\n console.error(\n \"[drafts][fork-diagnostic] failed to fork member at version — paste this block back:\\n\" +\n JSON.stringify(diagnostic, null, 2) +\n \"\\n[drafts][fork-diagnostic] the failing doc's bytes are on \" +\n \"window.__draftsForkRepro — to save them for an offline repro, run:\\n\" +\n \" const r = window.__draftsForkRepro;\\n\" +\n \" const bytes = Uint8Array.from(atob(r.docBase64), c => c.charCodeAt(0));\\n\" +\n \" const a = document.createElement('a');\\n\" +\n \" a.href = URL.createObjectURL(new Blob([bytes]));\\n\" +\n \" a.download = 'fork-repro.automerge'; a.click();\\n\" +\n \" console.log('pin heads:', r.toHex);\"\n );\n}\n\nfunction MainCard(props: {\n hostDocUrl: AutomergeUrl | undefined;\n isSelected: boolean;\n members: Accessor<DraftMemberDoc[]>;\n changeGroupDocUrl: AutomergeUrl | null;\n name: string | null;\n onRename: (name: string | null) => void;\n onSelect: () => void;\n onScrub: (scrub: ScrubberState) => void;\n scrubber: Accessor<ScrubberState | null>;\n onBaselineScrub: (base: BaselineState) => void;\n baseliner: Accessor<BaselineState | null>;\n checkpoint: Accessor<DraftCheckpoint | null>;\n hasCheckpoint: boolean;\n onReturnToLatest: () => void;\n eyeOpen: boolean;\n eyeDisabled: boolean;\n onToggleEye: () => void;\n forkDisabled: boolean;\n onFork: () => void;\n forkAtLabel: string | null;\n onForkAt: () => void;\n // True while the merge menu item is hovered and this card is the target.\n isMergeTarget: boolean;\n}) {\n const [menuOpen, setMenuOpen] = createSignal(false);\n return (\n <div\n class=\"draft-card\"\n data-selected={props.isSelected ? \"\" : undefined}\n data-menu-open={menuOpen() ? \"\" : undefined}\n data-merge-target={props.isMergeTarget ? \"\" : undefined}\n >\n {/* A div, not a <button>: the rename input rendered inside would be\n invalid (and misbehave) nested in a button. */}\n <div\n class=\"draft-card-header\"\n onClick={props.onSelect}\n title=\"Main version (host document)\"\n >\n <div class=\"draft-card-title\">\n <DraftName\n name={props.name}\n fallback=\"Main\"\n onRename={props.onRename}\n />\n {/* Shown left of the tools while the timeline is pinned: drops the\n pin and returns to the live latest heads. It lives inside the\n clickable header, so the click is stopped from also\n re-selecting the card. */}\n <Show when={props.hasCheckpoint}>\n <button\n type=\"button\"\n class=\"draft-card-return\"\n onClick={(e) => {\n e.stopPropagation();\n props.onReturnToLatest();\n }}\n title=\"Return to the latest version\"\n >\n Return to latest\n </button>\n </Show>\n <Show when={props.isSelected}>\n <span class=\"draft-card-tools\">\n <EyeToggle\n open={props.eyeOpen}\n disabled={props.eyeDisabled}\n onToggle={props.onToggleEye}\n />\n <CardMenu\n forkDisabled={props.forkDisabled}\n onFork={props.onFork}\n forkAtLabel={props.forkAtLabel}\n onForkAt={props.onForkAt}\n onOpenChange={setMenuOpen}\n />\n </span>\n </Show>\n </div>\n </div>\n <Show when={props.isSelected}>\n <DraftChangesList\n members={props.members}\n changeGroupDocUrl={props.changeGroupDocUrl}\n mainDocUrl={props.hostDocUrl}\n onScrub={props.onScrub}\n scrubber={props.scrubber}\n onBaselineScrub={props.onBaselineScrub}\n baseliner={props.baseliner}\n eyeOpen={() => props.eyeOpen}\n checkpoint={props.checkpoint}\n onReturnToLatest={props.onReturnToLatest}\n />\n </Show>\n </div>\n );\n}\n\nfunction DraftCard(props: {\n url: AutomergeUrl;\n members: DraftMemberDoc[];\n changeGroupDocUrl: AutomergeUrl | null;\n mainDocUrl: AutomergeUrl | undefined;\n isSelected: boolean;\n name: string | null;\n // Nesting depth below main (0 = top-level draft); indents the card so a\n // fork reads as a child of the card above it. Rendering adds one level so\n // every draft — main's children included — sits indented under the Main\n // card.\n depth: number;\n onRename: (name: string | null) => void;\n onSelect: (url: AutomergeUrl) => void;\n onScrub: (scrub: ScrubberState) => void;\n scrubber: Accessor<ScrubberState | null>;\n onBaselineScrub: (base: BaselineState) => void;\n baseliner: Accessor<BaselineState | null>;\n checkpoint: Accessor<DraftCheckpoint | null>;\n hasCheckpoint: boolean;\n onReturnToLatest: () => void;\n eyeOpen: boolean;\n eyeDisabled: boolean;\n onToggleEye: () => void;\n onFork: () => void;\n forkAtLabel: string | null;\n onForkAt: () => void;\n // Menu item text naming the merge target (this draft's parent, e.g.\n // `Merge into \"Main\"`); merging goes up.\n mergeLabel: string;\n onMerge: () => void;\n // Fires with true/false as the merge item is hovered/left, so the parent\n // card can light up as the target.\n onMergeHover: (over: boolean) => void;\n // True while the merge menu item is hovered and this card is the target.\n isMergeTarget: boolean;\n // Unlinks the draft (and its forks) from the tree, after a confirm dialog.\n onDelete: () => void;\n}) {\n const [menuOpen, setMenuOpen] = createSignal(false);\n return (\n <div\n class=\"draft-card\"\n data-selected={props.isSelected ? \"\" : undefined}\n data-menu-open={menuOpen() ? \"\" : undefined}\n data-merge-target={props.isMergeTarget ? \"\" : undefined}\n style={{ \"margin-left\": `${Math.min(props.depth + 1, 5)}rem` }}\n >\n {/* A div, not a <button>: see MainCard. */}\n <div\n class=\"draft-card-header\"\n onClick={() => props.onSelect(props.url)}\n title=\"Open draft\"\n >\n <div class=\"draft-card-title\">\n <DraftName\n name={props.name}\n fallback=\"Draft\"\n onRename={props.onRename}\n />\n {/* See MainCard: pinned-only \"return to latest\" control in the title. */}\n <Show when={props.hasCheckpoint}>\n <button\n type=\"button\"\n class=\"draft-card-return\"\n onClick={(e) => {\n e.stopPropagation();\n props.onReturnToLatest();\n }}\n title=\"Return to the latest version\"\n >\n Return to latest\n </button>\n </Show>\n <Show when={props.isSelected}>\n <span class=\"draft-card-tools\">\n <EyeToggle\n open={props.eyeOpen}\n disabled={props.eyeDisabled}\n onToggle={props.onToggleEye}\n />\n <CardMenu\n onFork={props.onFork}\n forkAtLabel={props.forkAtLabel}\n onForkAt={props.onForkAt}\n merge={{\n label: props.mergeLabel,\n onMerge: props.onMerge,\n onHoverTarget: props.onMergeHover,\n }}\n onDelete={props.onDelete}\n onOpenChange={setMenuOpen}\n />\n </span>\n </Show>\n </div>\n </div>\n <Show when={props.isSelected}>\n <DraftChangesList\n members={() => props.members}\n changeGroupDocUrl={props.changeGroupDocUrl}\n mainDocUrl={props.mainDocUrl}\n onScrub={props.onScrub}\n scrubber={props.scrubber}\n onBaselineScrub={props.onBaselineScrub}\n baseliner={props.baseliner}\n eyeOpen={() => props.eyeOpen}\n checkpoint={props.checkpoint}\n onReturnToLatest={props.onReturnToLatest}\n />\n </Show>\n </div>\n );\n}\n\n// The \"⋯\" context menu in a selected card's title. Items: fork at the\n// latest heads, fork from the scrubbed version (only while the timeline is\n// pinned), and — on draft cards — merge up into the parent. Hovering the\n// merge item highlights the target card via `onHoverTarget`. The dropdown\n// is anchored to the trigger; `onOpenChange` mirrors the open state up so\n// the card can lift its overflow clipping while the list is showing.\nfunction CardMenu(props: {\n forkDisabled?: boolean;\n onFork: () => void;\n // \"Fork from Jul 24, 3:12 PM\" while pinned; null hides the item.\n forkAtLabel: string | null;\n onForkAt: () => void;\n // Draft cards only: the merge-up item.\n merge?: {\n label: string;\n onMerge: () => void;\n onHoverTarget: (over: boolean) => void;\n };\n // Draft cards only: the delete item (confirmed via a dialog in the\n // handler).\n onDelete?: () => void;\n onOpenChange: (open: boolean) => void;\n}) {\n const [open, setOpenSignal] = createSignal(false);\n const setOpen = (v: boolean) => {\n setOpenSignal(v);\n props.onOpenChange(v);\n if (!v) props.merge?.onHoverTarget(false);\n };\n // The menu unmounts with its card's selection; reset what was mirrored up.\n onCleanup(() => setOpen(false));\n\n createEffect(() => {\n if (!open()) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false);\n };\n document.addEventListener(\"keydown\", onKey);\n onCleanup(() => document.removeEventListener(\"keydown\", onKey));\n });\n\n // Every item click: don't bubble into the header's select, close, run.\n const pick = (e: MouseEvent, action: () => void) => {\n e.stopPropagation();\n setOpen(false);\n action();\n };\n\n return (\n <span class=\"draft-menu\">\n <button\n type=\"button\"\n class=\"draft-card-action\"\n data-active={open() ? \"\" : undefined}\n onClick={(e) => {\n e.stopPropagation();\n setOpen(!open());\n }}\n title=\"Draft actions\"\n >\n <EllipsisIcon />\n </button>\n <Show when={open()}>\n {/* Invisible click-catcher behind the list: any click outside the\n items closes the menu without doing anything else. */}\n <div\n class=\"draft-menu-backdrop\"\n onClick={(e) => {\n e.stopPropagation();\n setOpen(false);\n }}\n />\n <div class=\"draft-menu-list\">\n <button\n type=\"button\"\n class=\"draft-menu-item\"\n disabled={props.forkDisabled}\n title={\n props.forkDisabled\n ? \"Drafts aren't supported for folders yet\"\n : \"Fork a new draft from the latest version\"\n }\n onClick={(e) => pick(e, props.onFork)}\n >\n <GitBranchIcon />\n Fork\n </button>\n <Show when={props.forkAtLabel}>\n {(label) => (\n <button\n type=\"button\"\n class=\"draft-menu-item\"\n title=\"Fork a new draft from the version you're viewing\"\n onClick={(e) => pick(e, props.onForkAt)}\n >\n <HistoryIcon />\n {label()}\n </button>\n )}\n </Show>\n <Show when={props.merge}>\n {(merge) => (\n <>\n <div class=\"draft-menu-separator\" />\n <button\n type=\"button\"\n class=\"draft-menu-item\"\n title=\"Merge this draft into the highlighted card and hide it\"\n onClick={(e) => pick(e, merge().onMerge)}\n onMouseEnter={() => merge().onHoverTarget(true)}\n onMouseLeave={() => merge().onHoverTarget(false)}\n >\n <GitMergeIcon />\n {merge().label}\n </button>\n </>\n )}\n </Show>\n <Show when={props.onDelete}>\n {(onDelete) => (\n <>\n <div class=\"draft-menu-separator\" />\n <button\n type=\"button\"\n class=\"draft-menu-item draft-menu-item--danger\"\n title=\"Deletes this draft and any drafts forked from it\"\n onClick={(e) => pick(e, onDelete())}\n >\n <TrashIcon />\n Delete draft\n </button>\n </>\n )}\n </Show>\n </div>\n </Show>\n </span>\n );\n}\n\n// \"Jul 24, 3:12 PM\" (with the year when it isn't the current one), for the\n// fork-from-version menu item. Takes an Automerge change time (Unix SECONDS).\nfunction formatVersionTime(timeSeconds: number): string {\n const date = new Date(timeSeconds * 1000);\n const sameYear = date.getFullYear() === new Date().getFullYear();\n return date.toLocaleString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: sameYear ? undefined : \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n });\n}\n\nfunction GitBranchIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <line x1=\"6\" x2=\"6\" y1=\"3\" y2=\"15\" />\n <circle cx=\"18\" cy=\"6\" r=\"3\" />\n <circle cx=\"6\" cy=\"18\" r=\"3\" />\n <path d=\"M18 9a9 9 0 0 1-9 9\" />\n </svg>\n );\n}\n\nfunction GitMergeIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <circle cx=\"18\" cy=\"18\" r=\"3\" />\n <circle cx=\"6\" cy=\"6\" r=\"3\" />\n <path d=\"M6 21V9a9 9 0 0 0 9 9\" />\n </svg>\n );\n}\n\nfunction EllipsisIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"1\" />\n <circle cx=\"19\" cy=\"12\" r=\"1\" />\n <circle cx=\"5\" cy=\"12\" r=\"1\" />\n </svg>\n );\n}\n\nfunction TrashIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"M3 6h18\" />\n <path d=\"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6\" />\n <path d=\"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2\" />\n <line x1=\"10\" x2=\"10\" y1=\"11\" y2=\"17\" />\n <line x1=\"14\" x2=\"14\" y1=\"11\" y2=\"17\" />\n </svg>\n );\n}\n\n// A clock rewinding: the fork-from-a-past-version item.\nfunction HistoryIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\" />\n <path d=\"M3 3v5h5\" />\n <path d=\"M12 7v5l4 2\" />\n </svg>\n );\n}\n\n// A card's display name. Double-click to rename inline: Enter or clicking\n// away commits, Escape cancels, and committing an empty value clears the\n// name back to the default label.\nfunction DraftName(props: {\n name: string | null;\n fallback: string;\n onRename: (name: string | null) => void;\n}) {\n const [editing, setEditing] = createSignal(false);\n return (\n <Show\n when={editing()}\n fallback={\n <span\n class=\"draft-name\"\n title=\"Double-click to rename\"\n onDblClick={() => setEditing(true)}\n >\n {props.name ?? props.fallback}\n </span>\n }\n >\n <input\n class=\"draft-name-input\"\n value={props.name ?? \"\"}\n placeholder={props.fallback}\n // Focus once mounted; the ref fires before insertion, hence the tick.\n ref={(el) => setTimeout(() => el.select())}\n onClick={(e) => e.stopPropagation()}\n onDblClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") e.currentTarget.blur();\n if (e.key === \"Escape\") setEditing(false);\n }}\n onBlur={(e) => {\n if (!editing()) return; // already cancelled via Escape\n setEditing(false);\n const value = e.currentTarget.value.trim();\n if (value !== (props.name ?? \"\")) props.onRename(value || null);\n }}\n />\n </Show>\n );\n}\n\n// The diff toggle in a card title, right-aligned. Open = diff highlighting\n// showing. It holds no state: open/closed is derived from the checkpoint's\n// baselines and toggling rewrites them (see `toggleEye`). Disabled on a live\n// main view, where there is nothing to diff against — via aria-disabled\n// rather than the disabled attribute, so the explanatory tooltip still shows\n// on hover (browsers don't reliably show titles on disabled buttons).\nfunction EyeToggle(props: {\n open: boolean;\n disabled: boolean;\n onToggle: () => void;\n}) {\n return (\n <button\n type=\"button\"\n class=\"draft-card-eye\"\n data-active={props.open ? \"\" : undefined}\n data-disabled={props.disabled ? \"\" : undefined}\n aria-disabled={props.disabled}\n onClick={(e) => {\n e.stopPropagation();\n if (props.disabled) return;\n props.onToggle();\n }}\n title={\n props.disabled\n ? \"Nothing to compare yet — select a version in the timeline first\"\n : props.open\n ? \"Hide changes\"\n : \"Show what changed\"\n }\n >\n <Show when={props.open} fallback={<EyeOffIcon />}>\n <EyeIcon />\n </Show>\n </button>\n );\n}\n\nfunction EyeIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n );\n}\n\nfunction EyeOffIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24\" />\n <line x1=\"1\" y1=\"1\" x2=\"23\" y2=\"23\" />\n </svg>\n );\n}\n\n// A reference to one change in the interleaved timeline, by document and\n// hash. `time` steers how the *other* member docs' heads are resolved around\n// it (see `computeCheckpoint`).\ntype ChangeRef = {\n docUrl: AutomergeUrl;\n hash: string;\n time: number;\n};\n\n// Where the scrubber sits: the change whose heads the view displays,\n// anchored to its persisted group. `offset` is the change's position within the\n// group, 0 = the group's newest change (what the scrubber geometry snaps\n// to); `head` identifies the exact change for the checkpoint machinery.\n// `groupStartTime` is the group's span start, carried so the checkpoint's\n// diff baseline can anchor at the group's beginning while the eye is on.\ntype ScrubberState = {\n groupId: string;\n offset: number;\n head: ChangeRef;\n groupStartTime: number;\n};\n\n// Where the diff baseline handle sits: an absolute point in history the diff\n// is measured from, independent of the head. `time` resolves each member's\n// `from` (see `computeCheckpoint`); `groupId`/`offset` place the handle in the\n// track (same geometry as the head). `offset` of `BASELINE_GROUP_START` means\n// \"the start of the group\" — the changes list resolves it to the group's\n// oldest change once it knows the group's size. Ephemeral like `ScrubberState`.\ntype BaselineState = {\n groupId: string;\n offset: number;\n time: number;\n};\n\n// Sentinel `BaselineState.offset` meaning \"the group's start\" (its oldest\n// change / the bottom of its band), used when the eye seeds the handle before\n// the group's change count is known.\nconst BASELINE_GROUP_START = -1;\n\n// One change recovered by the on-demand scrub-resolution scan. `doc` is the\n// member doc it was read from (kept so the sticker can diff it on demand);\n// `seq` is the change's per-document causal index, used only to break\n// same-second timestamp ties — matching the ChangeGrouper's interleave order.\ntype ScanChange = {\n docUrl: AutomergeUrl;\n doc: Automerge.Doc<unknown>;\n hash: string;\n time: number;\n deps: string[];\n seq: number;\n};\n\n// Renders a draft's (or main's) timeline straight from its ChangeGroupDoc.\n// The ChangeGrouper computes and persists activity groups (newest first, older\n// history backfilling), and this component is a pure reader: it paints before\n// the member docs even load, and live edits arrive through the group doc's\n// change signal. A gutter on\n// the left spans the whole history (top = latest version, bottom = first);\n// the indicator — a calendar-style dot + line — marks the version being\n// looked at and paints *on top* of everything in the changes area.\n// Dragging starts only from its handles in the gutter; dragging it all the\n// way to the top returns to the latest version (`onReturnToLatest`). While\n// pinned, a sticker overlays the row at the head with the exact change the\n// line sits on. Individual changes are NOT cached: scrub positions resolve\n// on demand by scanning the member docs' change metadata inside the group's\n// time span (no diffs), memoized per group so dragging stays snappy.\nfunction DraftChangesList(props: {\n members: Accessor<DraftMemberDoc[]>;\n changeGroupDocUrl: AutomergeUrl | null;\n mainDocUrl: AutomergeUrl | undefined;\n onScrub: (scrub: ScrubberState) => void;\n scrubber: Accessor<ScrubberState | null>;\n onBaselineScrub: (base: BaselineState) => void;\n baseliner: Accessor<BaselineState | null>;\n eyeOpen: Accessor<boolean>;\n // The live checkpoint (`CheckedOutDraft.at`): per-member `to`/`from`\n // heads, read for the sticker's whole-range diff counts.\n checkpoint: Accessor<DraftCheckpoint | null>;\n onReturnToLatest: () => void;\n}) {\n const repo = \"repo\" in window ? window.repo : undefined;\n\n // The group doc is read live, so ChangeGrouper writes stream in as rows.\n const [changeGroupHandle, setChangeGroupHandle] =\n createSignal<DocHandle<ChangeGroupDoc>>();\n createEffect(() => {\n const url = props.changeGroupDocUrl;\n setChangeGroupHandle(undefined);\n if (!url || !repo) return;\n let disposed = false;\n void repo.find<ChangeGroupDoc>(url).then(\n (handle) => {\n if (!disposed) setChangeGroupHandle(handle);\n },\n (err) => {\n console.warn(\"[drafts] failed to load change-group doc:\", url, err);\n }\n );\n onCleanup(() => {\n disposed = true;\n });\n });\n const changeGroupDoc = createDocSignal(changeGroupHandle);\n\n // The rendered groups, newest-first. Metadata-only groups are retained so\n // the ChangeGrouper can extend the newest one, but filtered from the UI.\n const timeGroups = createMemo<ChangeGroup[]>(() =>\n Object.values(changeGroupDoc()?.groups ?? {})\n .filter((g) => g.additions > 0 || g.deletions > 0)\n .sort((a, b) => b.endTime - a.endTime || (a.id < b.id ? -1 : 1))\n );\n\n // Member doc handles (plus the creation-time cutoff), resolved once per\n // member set — only needed to *scrub*, never to render the rows.\n type MemberSource = { member: DraftMemberDoc; handle: DocHandle<unknown> };\n const [sources, setSources] = createSignal<MemberSource[] | null>(null);\n const [createdAt, setCreatedAt] = createSignal<number | undefined>(\n undefined\n );\n createEffect(() => {\n const list = props.members();\n const mainDocUrl = props.mainDocUrl;\n if (!repo) return;\n let disposed = false;\n setSources(null);\n void (async () => {\n const next: MemberSource[] = [];\n for (const member of list) {\n try {\n const handle = await repo.find<unknown>(\n member.cloneUrl ?? member.url\n );\n next.push({ member, handle });\n } catch (err) {\n console.warn(\n \"[drafts] failed to resolve member for scrubbing:\",\n member,\n err\n );\n }\n }\n const created = await getDocCreationTime(repo, mainDocUrl);\n if (disposed) return;\n setCreatedAt(created);\n setSources(next);\n })();\n onCleanup(() => {\n disposed = true;\n });\n });\n\n // Grouping is caught up when every member's live heads match the group\n // doc's consumed marker (`computedThrough` — written only when a pass\n // completes, while groups flush incrementally during it). A running build\n // keeps writing to the group doc, so this re-evaluates live; it also reads\n // true while another peer does the building, since the group doc syncs.\n // Checkpoint pins don't interfere: they bake heads onto overlay urls, the\n // handles here always sit at the live frontier.\n const isBuilding = createMemo<boolean>(() => {\n const consumed = changeGroupDoc()?.computedThrough ?? {};\n const srcs = sources();\n if (!srcs || srcs.length === 0) return false;\n return srcs.some(({ member, handle }) => {\n const heads = handle.heads();\n return heads ? !sameHeads(heads, consumed[member.url]) : false;\n });\n });\n\n // Recover a group's member changes on demand: scan each member's post-fork\n // change metadata filtered to the group's span (spans are disjoint — groups\n // are separated by >gap lulls, so time containment recovers exactly the\n // group's changes) and interleave with the ChangeGrouper's ordering.\n // Metadata only, no diffs. Memoized per group identity so dragging\n // stays snappy; returns null until the member handles resolve. It must apply\n // the same filters as grouping (notably the pre-creation cutoff), or the\n // scrubber's index math drifts from the persisted changeCount.\n const scanCache = new Map<string, ScanChange[]>();\n const resolveGroupChanges = (group: ChangeGroup): ScanChange[] | null => {\n const key = `${group.id}:${group.changeCount}`;\n const hit = scanCache.get(key);\n if (hit) return hit;\n const srcs = sources();\n if (!srcs) return null;\n const cutoff = createdAt();\n const rows: ScanChange[] = [];\n for (const { member, handle } of srcs) {\n const doc = handle.doc() as Automerge.Doc<unknown> | undefined;\n if (!doc) continue;\n try {\n const since = member.clonedAt ? decodeHeads(member.clonedAt) : [];\n const metas = Automerge.getChangesMetaSince(doc, since);\n metas.forEach((meta, seq) => {\n if (cutoff !== undefined && meta.time && meta.time < cutoff) return;\n if (meta.time < group.startTime || meta.time > group.endTime) return;\n rows.push({\n docUrl: member.url,\n doc,\n hash: meta.hash,\n time: meta.time,\n deps: meta.deps,\n seq,\n });\n });\n } catch (err) {\n console.warn(\n \"[drafts] failed to scan changes for member:\",\n member,\n err\n );\n }\n }\n rows.sort((a, b) => b.time - a.time || b.seq - a.seq);\n scanCache.set(key, rows);\n return rows;\n };\n\n // Build the head scrub state for `offset` within `group` (0 = the group's\n // newest change, which the group doc anchors directly; deeper offsets resolve\n // through the on-demand scan). Null while the scan is still resolving.\n const buildHead = (\n group: ChangeGroup,\n offset: number\n ): ScrubberState | null => {\n if (offset <= 0) {\n return {\n groupId: group.id,\n offset: 0,\n head: {\n docUrl: group.newestMemberUrl,\n hash: group.newestHash,\n time: group.endTime,\n },\n groupStartTime: group.startTime,\n };\n }\n const rows = resolveGroupChanges(group);\n if (!rows || rows.length === 0) return null;\n const row = rows[Math.min(offset, rows.length - 1)];\n return {\n groupId: group.id,\n offset,\n head: { docUrl: row.docUrl, hash: row.hash, time: row.time },\n groupStartTime: group.startTime,\n };\n };\n\n // Expand the BASELINE_GROUP_START sentinel to the group's oldest change.\n const resolveOffset = (group: ChangeGroup, offset: number): number =>\n offset === BASELINE_GROUP_START\n ? Math.max(0, group.changeCount - 1)\n : offset;\n\n // The change time at `offset` within `group` (0 = the group's newest\n // change). Used to resolve the baseline handle's `from` time.\n const timeAt = (group: ChangeGroup, offset: number): number => {\n const resolved = resolveOffset(group, offset);\n if (resolved <= 0) return group.endTime;\n const rows = resolveGroupChanges(group);\n if (!rows || rows.length === 0) return group.startTime;\n return rows[Math.min(resolved, rows.length - 1)].time;\n };\n\n // A position's rank in the flat change order (higher = older), so the head\n // and baseline can be compared for clamping. Offsets are resolved (sentinel\n // -> group start) and clamped within their group.\n const linearIndex = (groupId: string, offset: number): number => {\n let acc = 0;\n for (const b of bands()) {\n const count = Math.max(1, b.group.changeCount);\n if (b.group.id === groupId) {\n return acc + Math.min(Math.max(0, resolveOffset(b.group, offset)), count - 1);\n }\n acc += count;\n }\n return acc + Math.max(0, offset);\n };\n\n // Move the head to `offset` within `group`. With the eye open the baseline\n // stays put (absolute), except that dragging the head older than the\n // baseline pushes the baseline down with it — they can meet but not cross.\n // The baseline is pushed first so the diff never momentarily inverts.\n const scrubTo = (group: ChangeGroup, offset: number) => {\n const head = buildHead(group, offset);\n if (!head) return;\n if (props.eyeOpen()) {\n const bl = props.baseliner();\n if (\n bl &&\n linearIndex(head.groupId, head.offset) >\n linearIndex(bl.groupId, bl.offset)\n ) {\n props.onBaselineScrub({\n groupId: group.id,\n offset: head.offset,\n time: head.head.time,\n });\n }\n }\n props.onScrub(head);\n };\n\n // Select a group (click on its row): the head pins to the group's newest\n // change, and — with the eye open — the baseline re-anchors to the group's\n // start, so the diff reads \"everything this group changed\". Dragging the\n // head, by contrast, leaves the baseline where it is (see `scrubTo`).\n const selectGroup = (group: ChangeGroup) => {\n if (props.eyeOpen()) {\n props.onBaselineScrub({\n groupId: group.id,\n offset: BASELINE_GROUP_START,\n time: group.startTime,\n });\n }\n scrubTo(group, 0);\n };\n\n // Move the baseline to `offset` within `group`, clamped so it never crosses\n // above (newer than) the head — the diff always reads old -> new. When the\n // clamp bites, the baseline snaps to the head (an empty diff).\n const baselineScrubTo = (group: ChangeGroup, offset: number) => {\n const head = props.scrubber();\n if (!head) return;\n if (linearIndex(group.id, offset) < linearIndex(head.groupId, head.offset)) {\n props.onBaselineScrub({\n groupId: head.groupId,\n offset: head.offset,\n time: head.head.time,\n });\n return;\n }\n props.onBaselineScrub({\n groupId: group.id,\n offset,\n time: timeAt(group, offset),\n });\n };\n\n // The group the scrubber head sits in: by group identity when it still\n // exists, falling back to span containment (an extended group gets a new\n // id, but its span still covers the pinned change).\n const groupForScrub = (s: ScrubberState): ChangeGroup | null =>\n timeGroups().find((g) => g.id === s.groupId) ??\n timeGroups().find(\n (g) => s.head.time >= g.startTime && s.head.time <= g.endTime\n ) ??\n null;\n\n // --- Scrubber geometry ---------------------------------------------------\n // The track mirrors the rows column: each group row is one vertical band,\n // and the group's changes distribute evenly across the band's height, so\n // every individual change — including ones in the middle of a group — is a\n // valid stop for the token, not just group boundaries.\n const rowEls = new Map<string, HTMLElement>();\n const [rowsEl, setRowsEl] = createSignal<HTMLDivElement>();\n // Bumped after layout changes so `bands` re-measures the rendered rows.\n const [measureTick, setMeasureTick] = createSignal(0);\n\n createEffect(() => {\n const el = rowsEl();\n if (!el) return;\n const observer = new ResizeObserver(() => setMeasureTick((t) => t + 1));\n observer.observe(el);\n onCleanup(() => observer.disconnect());\n });\n\n // Rows render after the groups memo recomputes, so measure again on the\n // next frame once the DOM has settled.\n createEffect(() => {\n timeGroups();\n requestAnimationFrame(() => setMeasureTick((t) => t + 1));\n });\n\n type Band = {\n group: ChangeGroup;\n top: number;\n height: number;\n };\n const bands = createMemo<Band[]>(() => {\n measureTick();\n const out: Band[] = [];\n for (const group of timeGroups()) {\n const el = rowEls.get(group.id);\n if (el) {\n out.push({ group, top: el.offsetTop, height: el.offsetHeight });\n }\n }\n return out;\n });\n\n // A scrub position's y in the track: offsets interpolate across their\n // group's band, sized by the persisted changeCount (the flat change list is\n // never materialized).\n const yForPosition = (band: Band, offset: number): number => {\n const count = Math.max(1, band.group.changeCount);\n return band.top + (Math.min(offset, count - 1) / count) * band.height;\n };\n\n // Inverse: the (group, offset) position nearest a pointer y (in track\n // coordinates).\n const positionForY = (\n y: number\n ): { group: ChangeGroup; offset: number } | null => {\n const bs = bands();\n if (bs.length === 0) return null;\n for (const b of bs) {\n if (y < b.top) return { group: b.group, offset: 0 };\n if (y < b.top + b.height) {\n const count = Math.max(1, b.group.changeCount);\n const offset = Math.min(\n Math.round(((y - b.top) / b.height) * count),\n count - 1\n );\n return { group: b.group, offset };\n }\n }\n const last = bs[bs.length - 1];\n return {\n group: last.group,\n offset: Math.max(0, last.group.changeCount - 1),\n };\n };\n\n // The indicator's pixel position: the head line's y in the track. The\n // zero-height box is fine — the dot and line overflow it and stay\n // grabbable. With nothing pinned it idles at the very top — you're looking\n // at the live latest.\n const tokenGeometry = createMemo(() => {\n const bs = bands();\n if (bs.length === 0) return null;\n const s = props.scrubber();\n if (!s) return { top: bs[0].top };\n const group = groupForScrub(s);\n const band = group ? bs.find((b) => b.group.id === group.id) : undefined;\n if (!band) return { top: bs[0].top };\n return { top: yForPosition(band, s.offset) };\n });\n\n // The baseline handle's y in the track, or null when it should not show:\n // only while the eye is open and a version is pinned (a head is set). Idle\n // on the latest version there is no baseline to drag.\n const baselineGeometry = createMemo(() => {\n if (!props.eyeOpen() || !props.scrubber()) return null;\n const b = props.baseliner();\n if (!b) return null;\n const bs = bands();\n const band =\n bs.find((x) => x.group.id === b.groupId) ??\n bs.find((x) => b.time >= x.group.startTime && b.time <= x.group.endTime);\n if (!band) return null;\n return { top: yForPosition(band, resolveOffset(band.group, b.offset)) };\n });\n\n let trackEl: HTMLDivElement | undefined;\n\n // Pointer y relative to the track's top edge. The rect is re-read per event\n // so scrolling the card mid-drag stays accurate.\n const yInTrack = (ev: PointerEvent): number => {\n const rect = trackEl!.getBoundingClientRect();\n return ev.clientY - rect.top;\n };\n\n // Begin an indicator drag: the head follows the pointer. Grabbing one of\n // the indicator's own handles (dot, line) keeps the grab point under the\n // pointer; pressing the bare gutter (`jumpToPointer`) lands the head where\n // you pressed and scrubs from there. The rows themselves don't scrub.\n // Every position snaps to an individual change, so the indicator can rest\n // anywhere in history — between groups or in the middle of one. Dragging\n // all the way to the top (the newest change) means \"return to the latest\n // version\": it drops the pin rather than freezing at the newest change.\n const beginDrag = (ev: PointerEvent, jumpToPointer = false) => {\n if (!trackEl || bands().length === 0) return;\n ev.preventDefault();\n ev.stopPropagation();\n const grabOffset = jumpToPointer\n ? 0\n : yInTrack(ev) - (tokenGeometry()?.top ?? 0);\n\n const s = props.scrubber();\n let last = s ? `${s.groupId}:${s.offset}` : null;\n const onMove = (e: PointerEvent) => {\n const pos = positionForY(yInTrack(e) - grabOffset);\n if (!pos) return;\n const key = `${pos.group.id}:${pos.offset}`;\n if (key === last) return;\n last = key;\n const first = bands()[0];\n if (first && pos.group.id === first.group.id && pos.offset === 0) {\n props.onReturnToLatest();\n } else {\n scrubTo(pos.group, pos.offset);\n }\n };\n // A gutter press must land before any movement, so a plain click jumps.\n if (jumpToPointer) onMove(ev);\n\n const target = ev.currentTarget as HTMLElement;\n target.setPointerCapture(ev.pointerId);\n const onUp = () => {\n target.removeEventListener(\"pointermove\", onMove);\n target.removeEventListener(\"pointerup\", onUp);\n target.removeEventListener(\"pointercancel\", onUp);\n };\n target.addEventListener(\"pointermove\", onMove);\n target.addEventListener(\"pointerup\", onUp);\n target.addEventListener(\"pointercancel\", onUp);\n };\n\n // Begin a baseline-handle drag: the baseline follows the pointer, clamped so\n // it never crosses above the head (see `baselineScrubTo`). Unlike the head,\n // it has no return-to-latest gesture — the baseline is only meaningful while\n // pinned, so there is nowhere at the top to drop it.\n const beginBaselineDrag = (ev: PointerEvent) => {\n if (!trackEl || bands().length === 0) return;\n ev.preventDefault();\n ev.stopPropagation();\n const grabOffset = yInTrack(ev) - (baselineGeometry()?.top ?? 0);\n\n let last: string | null = null;\n const onMove = (e: PointerEvent) => {\n const pos = positionForY(yInTrack(e) - grabOffset);\n if (!pos) return;\n const key = `${pos.group.id}:${pos.offset}`;\n if (key === last) return;\n last = key;\n baselineScrubTo(pos.group, pos.offset);\n };\n\n const target = ev.currentTarget as HTMLElement;\n target.setPointerCapture(ev.pointerId);\n const onUp = () => {\n target.removeEventListener(\"pointermove\", onMove);\n target.removeEventListener(\"pointerup\", onUp);\n target.removeEventListener(\"pointercancel\", onUp);\n };\n target.addEventListener(\"pointermove\", onMove);\n target.addEventListener(\"pointerup\", onUp);\n target.addEventListener(\"pointercancel\", onUp);\n };\n\n // The exact change the scrubber head sits on, recovered through the\n // on-demand scan; feeds the sticker that overlays the group row with the\n // version being looked at. It is suppressed when the head sits exactly on\n // a group's newest change (the row already shows that version).\n const headChange = createMemo<ScanChange | null>(() => {\n const s = props.scrubber();\n if (!s || s.offset === 0) return null;\n const group = groupForScrub(s);\n if (!group || s.head.hash === group.newestHash) return null;\n const rows = resolveGroupChanges(group);\n if (!rows || rows.length === 0) return null;\n return (\n rows.find(\n (r) => r.hash === s.head.hash && r.docUrl === s.head.docUrl\n ) ??\n rows[Math.min(s.offset, rows.length - 1)] ??\n null\n );\n });\n\n // The sticker's +/- counts. With the eye open they cover the whole diff\n // range — each member diffed from the checkpoint's `from` (the baseline)\n // to its `to` (the head), summed — so extending the baseline grows them.\n // With the eye closed there is no range, so they fall back to the single\n // change under the head.\n const headCounts = createMemo(() => {\n const change = headChange();\n if (!change) return null;\n if (props.eyeOpen()) {\n const at = props.checkpoint();\n const srcs = sources();\n if (at && srcs) {\n let additions = 0;\n let deletions = 0;\n let spans = 0;\n for (const { member, handle } of srcs) {\n const entry = at[member.url];\n if (!entry?.from || !entry.to) continue;\n const doc = handle.doc() as Automerge.Doc<unknown> | undefined;\n if (!doc) continue;\n spans++;\n const counts = computeRangeEditCounts(\n doc,\n decodeHeads(entry.from),\n decodeHeads(entry.to)\n );\n additions += counts.additions;\n deletions += counts.deletions;\n }\n if (spans > 0) return { additions, deletions };\n }\n }\n return computeEditCounts(change.doc, change.hash, change.deps);\n });\n\n return (\n <div class=\"draft-card-changes\">\n <Show\n when={timeGroups().length > 0}\n fallback={\n <Show\n when={isBuilding()}\n fallback={<div class=\"draft-changes-empty\">No changes yet.</div>}\n >\n <div class=\"draft-changes-building\">\n <span class=\"draft-building-spinner\" />\n Building history…\n </div>\n </Show>\n }\n >\n <div class=\"draft-changes-body\">\n <div\n class=\"draft-scrubber\"\n ref={trackEl}\n title=\"Click or drag anywhere in the gutter to scrub through history\"\n onPointerDown={(ev) => beginDrag(ev, true)}\n />\n <div class=\"draft-changes-rows\" ref={setRowsEl}>\n <For each={timeGroups()}>\n {(group) => (\n <TimeGroupRow\n group={group}\n rowRef={(el) => rowEls.set(group.id, el)}\n onSelect={() => selectGroup(group)}\n />\n )}\n </For>\n {/* Rebuilds backfill oldest history last, so the gap sits below\n the rows that have already painted. */}\n <Show when={isBuilding()}>\n <div class=\"draft-changes-building\">\n <span class=\"draft-building-spinner\" />\n Building history…\n </div>\n </Show>\n </div>\n <Show when={tokenGeometry()}>\n <div\n class=\"draft-scrubber-token\"\n style={{ top: `${tokenGeometry()!.top}px` }}\n >\n {/* The head line, painted on top of the group rows. */}\n <div class=\"draft-scrubber-line\" />\n {/* Grab handle, confined to the gutter. */}\n <div\n class=\"draft-scrubber-edge\"\n title=\"Drag to scrub through history — drop at the top to return to the latest version\"\n onPointerDown={beginDrag}\n />\n <div\n class=\"draft-scrubber-dot\"\n title=\"Drag to scrub through history — drop at the top to return to the latest version\"\n onPointerDown={beginDrag}\n />\n {/* Pinned inside a group: overlay the row with the exact\n version the head sits on (the card's Fork button forks\n from it). */}\n <Show when={headChange()}>\n {(change) => (\n <div\n class=\"draft-scrubber-sticker\"\n title=\"The version being viewed — Fork below to branch from here\"\n >\n <span class=\"draft-sticker-time\">\n {formatTime(change().time)}\n </span>\n <span class=\"draft-sticker-spacer\" />\n <EditCounts\n additions={headCounts()?.additions ?? 0}\n deletions={headCounts()?.deletions ?? 0}\n />\n </div>\n )}\n </Show>\n </div>\n </Show>\n {/* The diff baseline: a second handle (line + hollow circle) shown\n only with the eye open and a version pinned. Independent of the\n head — dragging it re-anchors the diff's older bound — and joined\n to the head by a connector so the two read as one range. */}\n <Show when={baselineGeometry()}>\n <div\n class=\"draft-scrubber-connector\"\n style={{\n top: `${Math.min(tokenGeometry()?.top ?? 0, baselineGeometry()!.top)}px`,\n height: `${Math.abs((tokenGeometry()?.top ?? 0) - baselineGeometry()!.top)}px`,\n }}\n />\n <div\n class=\"draft-scrubber-token draft-scrubber-token--baseline\"\n style={{ top: `${baselineGeometry()!.top}px` }}\n >\n <div class=\"draft-scrubber-line\" />\n <div\n class=\"draft-scrubber-edge\"\n title=\"Drag to move the diff baseline\"\n onPointerDown={beginBaselineDrag}\n />\n <div\n class=\"draft-scrubber-baseline\"\n title=\"Drag to move the diff baseline\"\n onPointerDown={beginBaselineDrag}\n />\n </div>\n </Show>\n </div>\n </Show>\n </div>\n );\n}\n\n// One time group, rendered as a single non-expandable row: author avatars,\n// the group's newest timestamp, and the aggregated +/- counts. Clicking the\n// row parks the scrubber at the top of the group (the scrubber token is the\n// selection indicator — the row itself doesn't highlight).\nfunction TimeGroupRow(props: {\n group: ChangeGroup;\n rowRef: (el: HTMLElement) => void;\n onSelect: () => void;\n}) {\n return (\n <button\n type=\"button\"\n class=\"draft-group-row\"\n ref={props.rowRef}\n title=\"View the draft as of this group\"\n onClick={props.onSelect}\n >\n <AuthorAvatars actors={props.group.actors} />\n <span class=\"draft-group-time\">{formatTime(props.group.endTime)}</span>\n <span class=\"draft-group-spacer\" />\n <EditCounts\n additions={props.group.additions}\n deletions={props.group.deletions}\n />\n </button>\n );\n}\n\n// A stack of author avatars, newest-contributor first. Actors with a known\n// contact embed the contact tool's own avatar view (image or name initials —\n// see contact/src/components/InlineContactAvatar.ts) and are deduped by\n// contact — one person editing across several sessions reads as one avatar;\n// unattributed actors fall back to actor-id rendering.\nfunction AuthorAvatars(props: { actors: string[] }) {\n const authors = createMemo(() => resolveAuthors(props.actors));\n const visible = () => authors().slice(0, 3);\n const extra = () => Math.max(0, authors().length - 3);\n return (\n <div class=\"draft-avatars\">\n <For each={visible()}>\n {(author, i) => (\n <div\n class=\"draft-avatar\"\n // Attributed avatars carry their own name tooltip (set by the\n // embedded contact view); only the fallback labels the actor id.\n title={author.contactUrl ? undefined : author.key}\n style={{\n background: author.contactUrl\n ? undefined\n : authorColor(author.key),\n \"margin-left\": i() === 0 ? \"0\" : \"-4px\",\n \"z-index\": String(visible().length - i()),\n }}\n >\n <Show\n when={author.contactUrl}\n fallback={getInitials(author.key)}\n >\n <patchwork-view\n doc-url={author.contactUrl!}\n tool-id=\"contact-inline\"\n />\n </Show>\n </div>\n )}\n </For>\n <Show when={extra() > 0}>\n <div class=\"draft-avatar draft-avatar--extra\">+{extra()}</div>\n </Show>\n </div>\n );\n}\n\n// The +N / -N edit-size counts shown at the end of a group row.\nfunction EditCounts(props: { additions: number; deletions: number }) {\n return (\n <span class=\"draft-counts\">\n <Show when={props.additions > 0}>\n <span class=\"draft-count draft-count--add\">+{props.additions}</span>\n </Show>\n <Show when={props.deletions > 0}>\n <span class=\"draft-count draft-count--del\">-{props.deletions}</span>\n </Show>\n </span>\n );\n}\n\n// Diff baseline mode for a checkpoint. `\"none\"` writes no `from` (no diff);\n// `{ beforeTime }` anchors each member's `from` at its state just before that\n// absolute time — the draggable baseline handle's position — so everything\n// from there up to the head reads as the diff. The baseline is independent of\n// the head (see `onScrub`/`onBaselineScrub`): the two are resolved separately\n// and only clamped so the baseline stays at or older than the head.\ntype CheckpointBase = \"none\" | { beforeTime: number };\n\n// Build the checkpoint map for a scrub position. Each member's displayed\n// version (`to`) is its heads as of `head`: the doc that owns that change is\n// pinned exactly to it, every other member to its latest change at or before\n// it (approximate but good enough). The diff baseline (`from`) follows\n// `base`: omitted for `\"none\"`, or the member's heads just before\n// `beforeTime` (falling back to the fork point — empty heads on main — when\n// no post-fork change precedes it). Members with no change at or before\n// `head` are omitted entirely: they didn't exist yet, so they fall through to\n// live.\nasync function computeCheckpoint(\n repo: Repo,\n members: DraftMemberDoc[],\n head: ChangeRef,\n base: CheckpointBase\n): Promise<DraftCheckpoint> {\n const checkpoint: DraftCheckpoint = {};\n for (const member of members) {\n try {\n const handle = await repo.find<unknown>(member.cloneUrl ?? member.url);\n const doc = handle.doc();\n if (!doc) continue;\n const since = member.clonedAt ? decodeHeads(member.clonedAt) : [];\n const metas = Automerge.getChangesMetaSince(doc, since);\n\n // Displayed version: exactly the head change for the doc that owns it,\n // otherwise the member's latest change at or before it.\n let to: UrlHeads;\n if (member.url === head.docUrl) {\n // Pin the head's doc exactly even if it falls outside the metas\n // window (robust against a mismatched fork point).\n to = encodeHeads([head.hash]);\n } else {\n let pinnedIndex = -1;\n let bestTime = -Infinity;\n metas.forEach((m, i) => {\n if (m.time <= head.time && m.time >= bestTime) {\n bestTime = m.time;\n pinnedIndex = i;\n }\n });\n if (pinnedIndex < 0) continue;\n to = encodeHeads([metas[pinnedIndex].hash]);\n }\n\n if (base === \"none\") {\n checkpoint[member.url] = { to };\n continue;\n }\n\n // Diff baseline: the member's newest change strictly before the\n // baseline's time. None post-fork means the baseline sits at or before\n // the start of the member's history in this timeline, so diff against\n // the fork point (empty heads on main — the whole doc reads as added).\n let fromIndex = -1;\n let fromTime = -Infinity;\n metas.forEach((m, i) => {\n if (m.time < base.beforeTime && m.time >= fromTime) {\n fromTime = m.time;\n fromIndex = i;\n }\n });\n const from =\n fromIndex >= 0\n ? encodeHeads([metas[fromIndex].hash])\n : (member.clonedAt ?? encodeHeads([]));\n checkpoint[member.url] = { from, to };\n } catch (err) {\n console.warn(\n \"[drafts] failed to compute checkpoint for member:\",\n member,\n err\n );\n }\n }\n return checkpoint;\n}\n\n// ---- Author attribution ----------------------------------------------------\n// Module-level, like the `nowMs` ticker below: attribution (actor id ->\n// contact url) is globally true, not per host doc, so one merged store can\n// serve every card and survive doc switches. Fed by the sidebar's\n// attribution-doc subscription. Rendering (including the name tooltip) is\n// delegated to the contact tool (`tool-id=\"contact-inline\"`).\n\nconst [actorContacts, setActorContacts] = createSignal<\n Record<string, AutomergeUrl>\n>({});\n\n// What an avatar renders for one author. `key` dedupes (and seeds the\n// fallback rendering): the contact url when attributed, the actor id\n// otherwise.\ntype AuthorDisplay = {\n key: string;\n contactUrl: AutomergeUrl | null;\n};\n\nfunction resolveAuthors(actors: string[]): AuthorDisplay[] {\n const attribution = actorContacts();\n const out: AuthorDisplay[] = [];\n const seen = new Set<string>();\n for (const actor of actors) {\n const contactUrl = attribution[actor] ?? null;\n const key = contactUrl ?? actor;\n if (seen.has(key)) continue;\n seen.add(key);\n out.push({ key, contactUrl });\n }\n return out;\n}\n\n// A stable-ish color for an author, so the same person reads the same across\n// rows. Actors are Automerge actor ids (per device/session), the best \"who\"\n// signal available in a draft's raw change history.\nfunction authorColor(authorId: string): string {\n let hash = 0;\n for (let i = 0; i < authorId.length; i++) {\n hash = authorId.charCodeAt(i) + ((hash << 5) - hash);\n }\n const h = Math.abs(hash) % 360;\n return `hsl(${h}, 45%, 63%)`;\n}\n\n// Two short characters to stand in for an author on their avatar.\nfunction getInitials(authorId: string): string {\n return authorId.slice(0, 2).toUpperCase();\n}\n\n// Ticks so relative timestamps (\"5 minutes ago\") stay fresh while the panel\n// is open. Module-level: one timer serves every row of every card, and it\n// lives as long as the module does.\nconst [nowMs, setNowMs] = createSignal(Date.now());\nsetInterval(() => setNowMs(Date.now()), 30_000);\n\n// `numeric: \"auto\"` gives GitHub's phrasing: \"yesterday\" and \"last week\"\n// instead of \"1 day ago\" and \"1 week ago\".\nconst RELATIVE_TIME = new Intl.RelativeTimeFormat(undefined, {\n numeric: \"auto\",\n});\n\n// Format an Automerge change time (Unix SECONDS): relative while recent\n// (\"now\", \"5 minutes ago\", \"5 hours ago\", \"yesterday\"), and from a week on\n// an absolute date with time (\"Jun 12 12:20\"), with the year appended only\n// once it differs from the current one (\"Jun 12, 2025 12:20\").\nfunction formatTime(timeSeconds: number): string {\n if (!timeSeconds) return \"\";\n const date = new Date(timeSeconds * 1000);\n const seconds = Math.max(0, Math.floor((nowMs() - date.getTime()) / 1000));\n const minutes = Math.floor(seconds / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n if (minutes < 1) return \"now\";\n if (hours < 1) return RELATIVE_TIME.format(-minutes, \"minute\");\n if (days < 1) return RELATIVE_TIME.format(-hours, \"hour\");\n if (days < 7) return RELATIVE_TIME.format(-days, \"day\");\n const day = date.toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year:\n date.getFullYear() === new Date(nowMs()).getFullYear()\n ? undefined\n : \"numeric\",\n });\n const time = date.toLocaleTimeString(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n hourCycle: \"h23\",\n });\n return `${day} ${time}`;\n}\n","import { render } from \"solid-js/web\";\nimport { RepoContext } from \"solid-automerge\";\nimport type { ToolImplementation } from \"@inkandswitch/patchwork-plugins\";\nimport { DraftsSidebar } from \"./DraftsSidebar\";\n\nexport const renderDraftsSidebar: ToolImplementation = (_handle, element) => {\n return render(\n () => (\n <RepoContext.Provider value={element.repo}>\n <DraftsSidebar element={element} />\n </RepoContext.Provider>\n ),\n element\n );\n};\n"],"names":["ms","require$$0","debug","template","Providers.subscribe","EMPTY_DRAFT_LIST","main","url","parent","members","childCount","name","changeGroupDocUrl","drafts","actorAttributionUrl","DRAFTS_VERSION","console","log","DraftsSidebar","props","hostDoc","hostDocHandle","subscribeDoc","element","type","checkedOutHandle","checkedOut","createDocSignal","selected","createMemo","eyeOpen","at","Object","values","some","e","from","undefined","isPinned","to","scrubber","setScrubber","createSignal","baseliner","setBaseliner","list","subscribe","createEffect","repo","getRepo","disposed","off","find","then","handle","update","actors","doc","keys","length","setActorContacts","prev","on","err","warn","onCleanup","isMainSelected","isFolder","selectDraft","change","d","window","scrubSeq","applyPins","draftUrl","head","bl","base","beforeTime","time","seq","checkpoint","computeCheckpoint","onScrub","scrub","onBaselineScrub","membersFor","s","forkBaselines","member","clonedAt","clearCheckpoint","baselines","toggleEye","urls","u","entry","groupId","offset","BASELINE_GROUP_START","groupStartTime","Map","map","m","get","encodeHeads","entries","missing","filter","onForkSelection","atVersion","docHandle","parentUrl","clones","cloneUrl","clone","cloneAtVersion","reportForkFailure","collectForkDiagnostic","source","heads","mainDraft","ensureMainDraft","parentHandle","draftNumber","draftCounter","draft","create","push","onRename","selectedSummary","mergeParentUrl","mergeTargetName","forkAtLabel","formatVersionTime","mergeHighlight","setMergeHighlight","draftDepth","summary","byUrl","seen","Set","depth","has","add","onMergeDraft","confirm","draftHandle","mergeDraft","onDeleteDraft","warning","i","indexOf","splice","_el$","_tmpl$2","_el$3","firstChild","_$insert","_$createComponent","Show","when","fallback","_tmpl$3","children","_el$2","_tmpl$","MainCard","hostDocUrl","isSelected","onSelect","hasCheckpoint","_$memo","onReturnToLatest","eyeDisabled","onToggleEye","forkDisabled","onFork","onForkAt","isMergeTarget","For","each","DraftCard","mainDocUrl","mergeLabel","onMerge","onMergeHover","onDelete","findMergeTarget","parentClones","originalUrl","targetUrl","target","Promise","all","merge","mergedAt","Date","now","isValidAutomergeUrl","childUrl","child","includes","cursor","candidate","pinHeads","decodeHeads","metas","Automerge","getChangesMetaSince","byHash","hash","closure","stack","pop","meta","Error","deps","bundle","saveBundle","pinned","loadIncremental","init","gotHeads","getHeads","sort","wantHeads","JSON","stringify","diagnostic","draftsVersion","memberUrl","sourceUrl","memberClonedAt","toHex","currentHeads","hasHeads","missingDeps","stats","automerge","pinnedChanges","fragments","probeErrors","probe","run","String","getMissingDeps","numChanges","numOps","info","releaseInfo","jsGitHead","js","gitHead","wasmGitHead","wasm","wasmVersion","cargoPackageVersion","topo","topoHistoryTraversal","metaByHash","topoIndex","known","actor","isCurrentHead","h","getFragmentMetadata","f","min","Infinity","max","containsPin","level","memberCount","topoRange","bytes","save","binary","CHUNK","fromCharCode","subarray","lastForkRepro","docBase64","btoa","failure","message","error","__draftsForkRepro","menuOpen","setMenuOpen","_el$5","_tmpl$6","_el$6","_el$7","_$addEventListener","DraftName","_el$8","_tmpl$4","$$click","stopPropagation","_el$9","_tmpl$5","EyeToggle","open","disabled","onToggle","CardMenu","onOpenChange","DraftChangesList","_$effect","_p$","_v$","_v$2","_v$3","_$setAttribute","t","a","_el$0","_tmpl$7","_el$1","_el$10","_el$11","_el$12","label","onHoverTarget","_v$4","_v$5","_v$6","_v$7","Math","o","_$setStyleProperty","setOpenSignal","setOpen","v","onKey","key","document","addEventListener","removeEventListener","pick","action","_el$13","_tmpl$0","_el$14","EllipsisIcon","_el$15","_tmpl$8","_el$16","_tmpl$9","_el$17","_el$18","GitBranchIcon","_el$19","_tmpl$1","HistoryIcon","_tmpl$10","_el$21","_tmpl$11","GitMergeIcon","_el$23","_tmpl$12","_el$24","TrashIcon","_v$8","_v$9","timeSeconds","date","sameYear","getFullYear","toLocaleString","month","day","year","hour","minute","_tmpl$13","_tmpl$14","_tmpl$15","_tmpl$16","_tmpl$17","editing","setEditing","_el$31","_tmpl$19","$$dblclick","_el$30","_tmpl$18","value","currentTarget","trim","$$keydown","blur","_$use","el","setTimeout","select","_el$32","_tmpl$20","EyeOffIcon","EyeIcon","_v$0","_v$1","_v$10","_v$11","_tmpl$21","_tmpl$22","changeGroupHandle","setChangeGroupHandle","changeGroupDoc","timeGroups","groups","g","additions","deletions","b","endTime","id","sources","setSources","createdAt","setCreatedAt","next","created","getDocCreationTime","isBuilding","consumed","computedThrough","srcs","sameHeads","scanCache","resolveGroupChanges","group","changeCount","hit","cutoff","rows","since","forEach","startTime","docUrl","set","buildHead","newestMemberUrl","newestHash","row","resolveOffset","timeAt","resolved","linearIndex","acc","bands","count","scrubTo","selectGroup","baselineScrubTo","groupForScrub","rowEls","rowsEl","setRowsEl","measureTick","setMeasureTick","observer","ResizeObserver","observe","disconnect","requestAnimationFrame","out","top","offsetTop","height","offsetHeight","yForPosition","band","positionForY","y","bs","round","last","tokenGeometry","baselineGeometry","x","trackEl","yInTrack","ev","rect","getBoundingClientRect","clientY","beginDrag","jumpToPointer","preventDefault","grabOffset","onMove","pos","first","setPointerCapture","pointerId","onUp","beginBaselineDrag","headChange","r","headCounts","spans","counts","computeRangeEditCounts","computeEditCounts","_el$35","_tmpl$28","_tmpl$29","_tmpl$23","_el$36","_tmpl$27","_el$37","_el$38","nextSibling","$$pointerdown","_ref$","TimeGroupRow","rowRef","_el$40","_tmpl$24","_el$41","_el$42","_el$43","_el$51","_tmpl$30","_el$52","formatTime","EditCounts","_$p","_el$44","_tmpl$25","_v$12","_v$13","abs","_el$45","_tmpl$26","_el$46","_el$47","_el$48","_el$54","_tmpl$31","_el$55","_ref$2","AuthorAvatars","authors","resolveAuthors","visible","slice","extra","_el$57","_tmpl$33","author","_el$60","_tmpl$35","contactUrl","getInitials","_el$61","_tmpl$34","_$owner","_$getOwner","_v$14","_v$15","authorColor","_v$16","_v$17","_el$58","_tmpl$32","_el$62","_tmpl$38","_el$63","_tmpl$36","_el$65","_tmpl$37","pinnedIndex","bestTime","fromIndex","fromTime","actorContacts","attribution","authorId","charCodeAt","toUpperCase","nowMs","setNowMs","setInterval","RELATIVE_TIME","Intl","RelativeTimeFormat","numeric","seconds","floor","getTime","minutes","hours","days","format","toLocaleDateString","toLocaleTimeString","hourCycle","_$delegateEvents","renderDraftsSidebar","_handle","render","RepoContext","Provider"],"mappings":";;;;;;;;;;;;;;;;;AAIA,MAAI,IAAI;AACR,MAAI,IAAI,IAAI;AACZ,MAAI,IAAI,IAAI;AACZ,MAAI,IAAI,IAAI;AACZ,MAAI,IAAI,IAAI;AACZ,MAAI,IAAI,IAAI;AAgBZ,OAAiB,SAAU,KAAK,SAAS;AACvC,cAAU,WAAW,CAAA;AACrB,QAAI,OAAO,OAAO;AAClB,QAAI,SAAS,YAAY,IAAI,SAAS,GAAG;AACvC,aAAO,MAAM,GAAG;AAAA,IACpB,WAAa,SAAS,YAAY,SAAS,GAAG,GAAG;AAC7C,aAAO,QAAQ,OAAO,QAAQ,GAAG,IAAI,SAAS,GAAG;AAAA,IACrD;AACE,UAAM,IAAI;AAAA,MACR,0DACE,KAAK,UAAU,GAAG;AAAA;EAExB;AAUA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G,QAAOT,cAAcU,OAAO,CAACD,MAAM,KAAK;AACtD,QAAM/N,MAAML,KAAKsO,mBAAmBhjB,QAAW;AAAA,IAC7C8U,OAAO;AAAA,IACPC,KAAK;AAAA,IACLC,MACEN,KAAKE,YAAAA,MAAkB,IAAI5K,KAAKkY,OAAO,EAAEtN,YAAAA,IACrC5U,SACA;AAAA,EAAA,CACP;AACD,QAAM0C,OAAOgS,KAAKuO,mBAAmBjjB,QAAW;AAAA,IAC9CiV,MAAM;AAAA,IACNC,QAAQ;AAAA,IACRgO,WAAW;AAAA,EAAA,CACZ;AACD,SAAO,GAAGnO,GAAG,IAAIrS,IAAI;AACvB;AAACygB,eAAA,CAAA,SAAA,YAAA,WAAA,aAAA,CAAA;AC9jFM,MAAMC,sBAA0CA,CAACC,SAASnkB,YAAY;AAC3E,SAAOokB,OACL,MAAA5b,gBACG6b,YAAYC,UAAQ;AAAA,IAAA,IAACzN,QAAK;AAAA,aAAE7W,QAAQyB;AAAAA,IAAI;AAAA,IAAA,IAAAoH,WAAA;AAAA,aAAAL,gBACtC7I,eAAa;AAAA,QAACK;AAAAA,MAAAA,CAAgB;AAAA,IAAA;AAAA,EAAA,CAAA,GAGnCA,OACF;AACF;","x_google_ignoreList":[0,1,2,3,4,5,6]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/DraftStateProvider-DX8b_RgQ.js","./assets/index-FKZtof6Z.js","./assets/clone-policy-CIdEhg7W.js","./assets/draft-docs-Bi8K1y3a.js","./assets/DraftOverlayProvider-VYKlzOy1.js","./assets/main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/DraftStateProvider-DX8b_RgQ.js","./assets/index-FKZtof6Z.js","./assets/clone-policy-CIdEhg7W.js","./assets/draft-docs-Bi8K1y3a.js","./assets/DraftOverlayProvider-VYKlzOy1.js","./assets/main-CCEftK7X.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
const scriptRel = "modulepreload";
|
|
3
3
|
const assetsURL = function(dep, importerUrl) {
|
|
4
4
|
return new URL(dep, importerUrl).href;
|
|
@@ -110,7 +110,7 @@ const plugins = [
|
|
|
110
110
|
supportedDatatypes: ["account"],
|
|
111
111
|
async load() {
|
|
112
112
|
const { renderDraftsSidebar } = await __vitePreload(async () => {
|
|
113
|
-
const { renderDraftsSidebar: renderDraftsSidebar2 } = await import("./assets/main-
|
|
113
|
+
const { renderDraftsSidebar: renderDraftsSidebar2 } = await import("./assets/main-CCEftK7X.js");
|
|
114
114
|
return { renderDraftsSidebar: renderDraftsSidebar2 };
|
|
115
115
|
}, true ? __vite__mapDeps([5,1,3]) : void 0, import.meta.url);
|
|
116
116
|
return renderDraftsSidebar;
|
|
@@ -126,7 +126,7 @@ const plugins = [
|
|
|
126
126
|
tags: ["context-tool"],
|
|
127
127
|
async load() {
|
|
128
128
|
const { renderDraftsSidebar } = await __vitePreload(async () => {
|
|
129
|
-
const { renderDraftsSidebar: renderDraftsSidebar2 } = await import("./assets/main-
|
|
129
|
+
const { renderDraftsSidebar: renderDraftsSidebar2 } = await import("./assets/main-CCEftK7X.js");
|
|
130
130
|
return { renderDraftsSidebar: renderDraftsSidebar2 };
|
|
131
131
|
}, true ? __vite__mapDeps([5,1,3]) : void 0, import.meta.url);
|
|
132
132
|
return (element) => renderDraftsSidebar(null, element);
|