@inkandswitch/patchwork-pkg-base 0.0.58 → 0.0.60
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/account/dist/{AccountPicker-HB6MDLKN.js → AccountPicker-KAKD2EZJ.js} +17 -61
- package/packages/account/dist/{AccountPicker-HB6MDLKN.js.map → AccountPicker-KAKD2EZJ.js.map} +2 -2
- package/packages/account/dist/index.js +1 -1
- package/packages/folder/dist/index.js +1 -1
- package/packages/folder/dist/{tool-WZGXLTTD.js → tool-EOCAL24F.js} +3 -4
- package/packages/folder/dist/tool-EOCAL24F.js.map +7 -0
- package/packages/sideboard/dist/chunk-7V2BKMG7.js +26 -0
- package/packages/sideboard/dist/chunk-7V2BKMG7.js.map +7 -0
- package/packages/sideboard/dist/document-list-panel-UUH6HOJ3.js +2 -0
- package/packages/sideboard/dist/index.css +1 -1
- package/packages/sideboard/dist/index.css.map +2 -2
- package/packages/sideboard/dist/index.js +1 -1
- package/packages/sideboard/dist/sideboard/sideboard.js +1 -1
- package/packages/sideboard/package.json +0 -1
- package/packages/threepane/dist/PatchworkFrame-RLYJ4GEF.js +2 -0
- package/packages/threepane/dist/{PatchworkFrame-II6JKG65.js.map → PatchworkFrame-RLYJ4GEF.js.map} +4 -4
- package/packages/threepane/dist/index.js +1 -1
- package/packages/folder/dist/tool-WZGXLTTD.js.map +0 -7
- package/packages/sideboard/dist/chunk-YCECYDWC.js +0 -26
- package/packages/sideboard/dist/chunk-YCECYDWC.js.map +0 -7
- package/packages/sideboard/dist/document-list-panel-DZYK3JHP.js +0 -2
- package/packages/threepane/dist/PatchworkFrame-II6JKG65.js +0 -2
- /package/packages/sideboard/dist/{document-list-panel-DZYK3JHP.js.map → document-list-panel-UUH6HOJ3.js.map} +0 -0
package/packages/threepane/dist/{PatchworkFrame-II6JKG65.js.map → PatchworkFrame-RLYJ4GEF.js.map}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/PatchworkFrame.tsx", "../node_modules/.pnpm/@inkandswitch+patchwork-providers@0.3.0_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2.0_/node_modules/@inkandswitch/patchwork-providers/dist/overlay-handle.js", "../node_modules/.pnpm/@inkandswitch+patchwork-providers@0.3.0_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2.0_/node_modules/@inkandswitch/patchwork-providers/dist/overlay-repo.js", "../node_modules/.pnpm/@inkandswitch+patchwork-providers@0.3.0_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2.0_/node_modules/@inkandswitch/patchwork-providers/dist/index.js", "../src/components/SidebarWidgets.tsx", "../src/components/Tray.tsx", "../src/account/ensureThreepaneConfig.ts", "../src/account/loadDatatypeWhenReady.ts", "../src/account/seedExampleDocuments.ts"],
|
|
4
|
-
"sourcesContent": ["import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { setStyleProperty as _$setStyleProperty } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { use as _$use } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=frame-shell><aside class=frame-warning-banner>research grade software. do not share links. sharing a doc is sharing your account.</aside><div class=frame><patchwork-view component=patchwork-selected-doc-provider><patchwork-view component=patchwork-account-provider><patchwork-view component=patchwork-tool-storage-provider>`, true, false, false),\n _tmpl$2 = /*#__PURE__*/_$template(`<div style=display:contents>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=main-area>`),\n _tmpl$4 = /*#__PURE__*/_$template(`<div class=frame__popover-backdrop><div class=frame__popover role=dialog aria-modal=true><div class=frame__popover-toolbar><patchwork-view tool-id=doc-openwith></patchwork-view></div><div class=frame__popover-body><patchwork-view>`, true, false, false),\n _tmpl$5 = /*#__PURE__*/_$template(`<button type=button class=\"frame__sidebar-toggle frame__left-toggle\">`),\n _tmpl$6 = /*#__PURE__*/_$template(`<div class=threepane-sidebar><div class=threepane-sidebar__footer><footer class=threepane-account-bar><button type=button class=threepane-account-bar__button>Settings`),\n _tmpl$7 = /*#__PURE__*/_$template(`<div class=frame__tray-dock>`),\n _tmpl$8 = /*#__PURE__*/_$template(`<button type=button class=\"threepane-account-bar__button threepane-account-bar__avatar\"title=Account aria-label=Account><patchwork-view tool-id=contact-avatar>`, true, false, false),\n _tmpl$9 = /*#__PURE__*/_$template(`<button type=button class=threepane-account-bar__button>Packages`),\n _tmpl$0 = /*#__PURE__*/_$template(`<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox=\"0 0 24 24\"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d=\"M9 3v18\">`);\nimport \"@inkandswitch/patchwork-elements\";\nimport { useDocHandle } from \"solid-automerge\";\nimport { subscribe } from \"@inkandswitch/patchwork-providers\";\nimport { useSidebarState, useSidebarResize, useMainDocMounted, useDebugRegistryToast, DebugRegistryToast, SIDEBAR_KEYS, COLLAPSE_CONTEXT_SIDEBAR_EVENT, getStoredNumber, getStoredBoolean, DEFAULT_SIDEBAR_WIDTH } from \"./hooks\";\nimport { Sidebar } from \"./components/Sidebar\";\nimport { SidebarWidgets } from \"./components/SidebarWidgets\";\nimport { DocumentAreaRoot } from \"./components/DocumentAreaRoot\";\nimport { IsolatedDocumentArea } from \"./components/IsolatedDocumentArea\";\nimport { MainDocumentView } from \"./components/MainDocumentView\";\nimport { Tray } from \"./components/Tray\";\nimport { createEffect, createMemo, createSignal, onCleanup, onMount, Show } from \"solid-js\";\nimport { render } from \"solid-js/web\";\nimport { ensureThreepaneConfig } from \"./account/ensureThreepaneConfig\";\nimport { seedExampleDocuments } from \"./account/seedExampleDocuments\";\nimport { ensureFrameStyles } from \"./ensureFrameStyles\";\nconst MIN_SIDEBAR_WIDTH = 180;\nconst MAX_SIDEBAR_WIDTH = 720;\nconst AUTO_CLOSE_WIDTH = 120;\nconst DRAG_THRESHOLD = 3;\nconst useFrameProviderReady = (componentId, element) => {\n const [isReady, setReady] = createSignal(false);\n createEffect(() => {\n const el = element();\n if (!el) return;\n setReady(false);\n const onMounted = event => {\n const detail = event.detail;\n if (detail?.componentId !== componentId) return;\n setReady(true);\n };\n el.addEventListener(\"patchwork:mounted\", onMounted);\n onCleanup(() => el.removeEventListener(\"patchwork:mounted\", onMounted));\n });\n return isReady;\n};\nfunction dispatchOpen(el, detail) {\n el.dispatchEvent(new CustomEvent(\"patchwork:open-document\", {\n detail,\n bubbles: true,\n composed: true\n }));\n}\nexport function PatchworkFrame({\n handle,\n repo,\n ...props\n}) {\n ensureFrameStyles();\n const accountDocUrl = handle.url;\n const [accountProviderElement, setAccountProviderElement] = createSignal();\n const isAccountProviderReady = useFrameProviderReady(\"patchwork-account-provider\", accountProviderElement);\n const [toolStorageProviderElement, setToolStorageProviderElement] = createSignal();\n const isToolStorageProviderReady = useFrameProviderReady(\"patchwork-tool-storage-provider\", toolStorageProviderElement);\n const [selectedDocProviderElement, setSelectedDocProviderElement] = createSignal();\n const isSelectedDocProviderReady = useFrameProviderReady(\"patchwork-selected-doc-provider\", selectedDocProviderElement);\n const areProvidersReady = createMemo(() => isSelectedDocProviderReady() && isAccountProviderReady() && isToolStorageProviderReady());\n return (() => {\n var _el$ = _tmpl$(),\n _el$2 = _el$.firstChild,\n _el$3 = _el$2.firstChild,\n _el$4 = _el$2.nextSibling,\n _el$5 = _el$4.firstChild,\n _el$6 = _el$5.firstChild,\n _el$7 = _el$6.firstChild;\n _$insert(_el$2, _$createComponent(Show, {\n get when() {\n return props.isolation;\n },\n get children() {\n return [\" \", \"isolation is highly experimental. if things are broken, switch back to wild west.\"];\n }\n }), null);\n _$use(setSelectedDocProviderElement, _el$5);\n _el$5._$owner = _$getOwner();\n _$use(setAccountProviderElement, _el$6);\n _el$6.docUrl = accountDocUrl;\n _el$6._$owner = _$getOwner();\n _$use(setToolStorageProviderElement, _el$7);\n _el$7.docUrl = accountDocUrl;\n _el$7._$owner = _$getOwner();\n _$insert(_el$7, _$createComponent(Show, {\n get when() {\n return areProvidersReady();\n },\n get children() {\n return _$createComponent(PatchworkFrameInner, {\n handle: handle,\n repo: repo,\n get isolation() {\n return props.isolation;\n }\n });\n }\n }));\n return _el$;\n })();\n}\nfunction PatchworkFrameInner(props) {\n const accountDocHandle = useDocHandle(() => props.handle.url, {\n repo: props.repo\n });\n void (async () => {\n await ensureThreepaneConfig(props.handle, props.repo);\n await seedExampleDocuments(props.handle, props.repo);\n })().catch(err => {\n console.error(\"frame: account bootstrap failed\", err);\n });\n const [docVersion, setDocVersion] = createSignal(0);\n createEffect(() => {\n const h = accountDocHandle();\n if (!h) return;\n const onChange = () => setDocVersion(v => v + 1);\n h.on(\"change\", onChange);\n onCleanup(() => h.off(\"change\", onChange));\n });\n const accountDoc = createMemo(() => {\n docVersion();\n return accountDocHandle()?.doc();\n });\n const accountDocUrl = props.handle.url;\n const threepaneUrl = () => accountDoc()?.tools?.[\"threepane\"];\n const threepaneConfigHandle = useDocHandle(() => threepaneUrl(), {\n repo: props.repo\n });\n const [threepaneVersion, setThreepaneVersion] = createSignal(0);\n createEffect(() => {\n const h = threepaneConfigHandle();\n if (!h) return;\n const onChange = () => setThreepaneVersion(v => v + 1);\n h.on(\"change\", onChange);\n onCleanup(() => h.off(\"change\", onChange));\n });\n const threepaneConfig = createMemo(() => {\n threepaneVersion();\n return threepaneConfigHandle()?.doc();\n });\n const doctitleSlots = () => threepaneConfig()?.doctitle?.tools;\n const sidebarWidgets = () => threepaneConfig()?.sidebar?.widgets ?? [];\n const traySlots = () => threepaneConfig()?.tray ?? [];\n const rootFolderUrl = () => accountDoc()?.rootFolderUrl;\n const sidebarState = useSidebarState();\n const sidebarResize = useSidebarResize({\n setLeftSidebarWidth: sidebarState.setLeftSidebarWidth,\n setRightSidebarWidth: sidebarState.setRightSidebarWidth,\n setIsSidebarCollapsed: sidebarState.setIsSidebarCollapsed,\n setIsRightSidebarCollapsed: sidebarState.setIsRightSidebarCollapsed,\n isLeftCollapsed: sidebarState.isSidebarCollapsed,\n isRightCollapsed: sidebarState.isRightSidebarCollapsed,\n minWidth: MIN_SIDEBAR_WIDTH,\n maxWidth: MAX_SIDEBAR_WIDTH,\n autoCloseWidth: AUTO_CLOSE_WIDTH,\n dragThreshold: DRAG_THRESHOLD\n });\n const {\n events: debugEvents,\n dismissEvent,\n clearAll\n } = useDebugRegistryToast();\n let element;\n const [selectedView, setSelectedView] = createSignal(null);\n const [popoverView, setPopoverView] = createSignal(null);\n onMount(() => {\n const unsubscribeSelectedView = subscribe(element, {\n type: \"patchwork:selected-view\"\n }, view => setSelectedView(view));\n onCleanup(unsubscribeSelectedView);\n });\n const selectedDocUrl = () => selectedView()?.url;\n const selectedToolId = () => selectedView()?.toolId ?? void 0;\n const initialRightWidth = () => getStoredNumber(SIDEBAR_KEYS.rightWidth, DEFAULT_SIDEBAR_WIDTH);\n const initialRightCollapsed = () => getStoredBoolean(SIDEBAR_KEYS.rightCollapsed);\n const [mainDocElement, setMainDocElement] = createSignal();\n const isMainDocMounted = useMainDocMounted(mainDocElement, selectedDocUrl);\n const [widgetsReady, setWidgetsReady] = createSignal(false);\n createEffect(() => {\n if (widgetsReady()) return;\n if (props.isolation || !selectedDocUrl() || isMainDocMounted()) setWidgetsReady(true);\n });\n return (() => {\n var _el$8 = _tmpl$2();\n var _ref$ = element;\n typeof _ref$ === \"function\" ? _$use(_ref$, _el$8) : element = _el$8;\n _$insert(_el$8, _$createComponent(DebugRegistryToast, {\n get events() {\n return debugEvents();\n },\n onDismiss: dismissEvent,\n onClearAll: clearAll\n }), null);\n _$insert(_el$8, _$createComponent(FrameLayout, {\n accountDocUrl: accountDocUrl,\n sidebarState: sidebarState,\n sidebarResize: sidebarResize,\n sidebarWidgets: sidebarWidgets,\n traySlots: traySlots,\n configHandle: threepaneConfigHandle,\n rootFolderUrl: rootFolderUrl,\n widgetsReady: widgetsReady,\n contactUrl: () => accountDoc()?.contactUrl,\n moduleSettingsUrl: () => accountDoc()?.moduleSettingsUrl,\n get isolation() {\n return props.isolation;\n },\n onInterceptOpen: setPopoverView,\n get children() {\n return _$createComponent(Show, {\n get when() {\n return selectedDocUrl();\n },\n get fallback() {\n return (() => {\n var _el$9 = _tmpl$3();\n _$insert(_el$9, _$createComponent(MainDocumentView, {\n viewKey: selectedDocUrl,\n selectedDocUrl: selectedDocUrl,\n toolId: selectedToolId,\n ref: setMainDocElement\n }));\n return _el$9;\n })();\n },\n get children() {\n return _$createComponent(Show, {\n get when() {\n return props.isolation;\n },\n get fallback() {\n return _$createComponent(DocumentAreaRoot, {\n setMainDocElement: setMainDocElement,\n selectedDocUrl: selectedDocUrl,\n selectedToolId: selectedToolId,\n doctitleSlots: doctitleSlots,\n get isLeftCollapsed() {\n return sidebarState.isSidebarCollapsed;\n },\n initialRightWidth: initialRightWidth,\n initialRightCollapsed: initialRightCollapsed\n });\n },\n get children() {\n return _$createComponent(IsolatedDocumentArea, {\n get contactUrl() {\n return accountDoc()?.contactUrl;\n },\n selectedDocUrl: selectedDocUrl,\n selectedToolId: selectedToolId,\n doctitleSlots: doctitleSlots,\n get isLeftCollapsed() {\n return sidebarState.isSidebarCollapsed;\n },\n initialRightWidth: initialRightWidth,\n initialRightCollapsed: initialRightCollapsed\n });\n }\n });\n }\n });\n }\n }), null);\n _$insert(_el$8, _$createComponent(Show, {\n get when() {\n return popoverView();\n },\n children: view => _$createComponent(FramePopover, {\n get view() {\n return view();\n },\n onClose: () => setPopoverView(null)\n })\n }), null);\n return _el$8;\n })();\n}\nfunction FramePopover(props) {\n const [toolId, setToolId] = createSignal(props.view.toolId ?? void 0);\n createEffect(() => setToolId(props.view.toolId ?? void 0));\n let popoverEl;\n onMount(() => {\n const onKey = e => {\n if (e.key === \"Escape\") props.onClose();\n };\n window.addEventListener(\"keydown\", onKey);\n onCleanup(() => window.removeEventListener(\"keydown\", onKey));\n const el = popoverEl;\n if (!el) return;\n const onOpen = event => {\n const {\n url,\n toolId: nextToolId\n } = event.detail;\n if (!url) return;\n event.stopPropagation();\n setToolId(nextToolId ?? void 0);\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n return (() => {\n var _el$0 = _tmpl$4(),\n _el$1 = _el$0.firstChild,\n _el$10 = _el$1.firstChild,\n _el$11 = _el$10.firstChild,\n _el$12 = _el$10.nextSibling,\n _el$13 = _el$12.firstChild;\n _el$0.$$click = () => props.onClose();\n _el$1.$$click = e => e.stopPropagation();\n var _ref$2 = popoverEl;\n typeof _ref$2 === \"function\" ? _$use(_ref$2, _el$1) : popoverEl = _el$1;\n _el$11._$owner = _$getOwner();\n _el$13._$owner = _$getOwner();\n _$effect(_p$ => {\n var _v$ = props.view.url,\n _v$2 = props.view.url,\n _v$3 = toolId();\n _v$ !== _p$.e && (_el$11.docUrl = _p$.e = _v$);\n _v$2 !== _p$.t && (_el$13.docUrl = _p$.t = _v$2);\n _v$3 !== _p$.a && (_el$13.toolId = _p$.a = _v$3);\n return _p$;\n }, {\n e: undefined,\n t: undefined,\n a: undefined\n });\n return _el$0;\n })();\n}\nfunction FrameLayout(props) {\n const isCollapsed = props.sidebarState.isSidebarCollapsed;\n const hasTray = () => props.traySlots().length > 0;\n let footerEl;\n onMount(() => {\n if (!props.isolation || !footerEl) return;\n const el = footerEl;\n const onOpen = event => {\n const {\n url,\n toolId\n } = event.detail;\n if (!url) return;\n event.stopPropagation();\n props.onInterceptOpen?.({\n url,\n toolId: toolId ?? null\n });\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n let sidebarContentEl;\n createEffect(() => {\n if (props.sidebarState.isSidebarCollapsed()) return;\n const el = sidebarContentEl;\n if (!el) return;\n const onOpen = () => {\n if (el.getBoundingClientRect().width <= window.innerWidth * 0.75) return;\n props.sidebarState.setIsSidebarCollapsed(true);\n window.dispatchEvent(new CustomEvent(COLLAPSE_CONTEXT_SIDEBAR_EVENT));\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n return [(() => {\n var _el$14 = _tmpl$5();\n _el$14.$$click = () => props.sidebarState.setIsSidebarCollapsed(v => !v);\n _$insert(_el$14, _$createComponent(PanelLeftIcon, {}));\n _$effect(_p$ => {\n var _v$4 = isCollapsed() ? \"Show sidebar\" : \"Hide sidebar\",\n _v$5 = isCollapsed() ? \"Show sidebar\" : \"Hide sidebar\",\n _v$6 = !isCollapsed();\n _v$4 !== _p$.e && _$setAttribute(_el$14, \"title\", _p$.e = _v$4);\n _v$5 !== _p$.t && _$setAttribute(_el$14, \"aria-label\", _p$.t = _v$5);\n _v$6 !== _p$.a && _$setAttribute(_el$14, \"aria-pressed\", _p$.a = _v$6);\n return _p$;\n }, {\n e: undefined,\n t: undefined,\n a: undefined\n });\n return _el$14;\n })(), _$createComponent(Sidebar, {\n side: \"left\",\n isCollapsed: isCollapsed,\n get width() {\n return props.sidebarState.leftSidebarWidth;\n },\n get onMouseDown() {\n return props.sidebarResize.handleMouseDown;\n },\n get onToggleClick() {\n return props.sidebarResize.handleToggleClick;\n },\n get children() {\n var _el$15 = _tmpl$6(),\n _el$16 = _el$15.firstChild,\n _el$17 = _el$16.firstChild,\n _el$18 = _el$17.firstChild;\n var _ref$3 = sidebarContentEl;\n typeof _ref$3 === \"function\" ? _$use(_ref$3, _el$15) : sidebarContentEl = _el$15;\n _$insert(_el$15, _$createComponent(SidebarWidgets, {\n get widgets() {\n return props.sidebarWidgets;\n },\n get configHandle() {\n return props.configHandle;\n },\n get rootFolderUrl() {\n return props.rootFolderUrl;\n },\n get ready() {\n return props.widgetsReady;\n }\n }), _el$16);\n var _ref$4 = footerEl;\n typeof _ref$4 === \"function\" ? _$use(_ref$4, _el$16) : footerEl = _el$16;\n _$insert(_el$17, _$createComponent(Show, {\n get when() {\n return props.contactUrl();\n },\n children: contactUrl => (() => {\n var _el$20 = _tmpl$8(),\n _el$21 = _el$20.firstChild;\n _el$20.$$click = e => dispatchOpen(e.currentTarget, {\n url: props.accountDocUrl,\n toolId: \"account-picker\"\n });\n _el$21._$owner = _$getOwner();\n _$effect(() => _el$21.docUrl = contactUrl());\n return _el$20;\n })()\n }), _el$18);\n _$insert(_el$17, _$createComponent(Show, {\n get when() {\n return props.moduleSettingsUrl();\n },\n children: moduleSettingsUrl => (() => {\n var _el$22 = _tmpl$9();\n _el$22.$$click = e => dispatchOpen(e.currentTarget, {\n url: moduleSettingsUrl(),\n toolId: \"packages\"\n });\n return _el$22;\n })()\n }), _el$18);\n _el$18.$$click = e => dispatchOpen(e.currentTarget, {\n url: props.accountDocUrl,\n toolId: \"frame-configurator\"\n });\n _$effect(() => _el$15.classList.toggle(\"threepane-sidebar--has-tray\", !!hasTray()));\n return _el$15;\n }\n }), _$createComponent(Show, {\n get when() {\n return hasTray();\n },\n get children() {\n var _el$19 = _tmpl$7();\n _$insert(_el$19, _$createComponent(Tray, {\n get slots() {\n return props.traySlots;\n }\n }));\n _$effect(_p$ => {\n var _v$7 = !!isCollapsed(),\n _v$8 = `${props.sidebarState.leftSidebarWidth()}px`;\n _v$7 !== _p$.e && _el$19.classList.toggle(\"frame__tray-dock--collapsed\", _p$.e = _v$7);\n _v$8 !== _p$.t && _$setStyleProperty(_el$19, \"width\", _p$.t = _v$8);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$19;\n }\n }), _$memo(() => props.children)];\n}\nfunction PanelLeftIcon() {\n return _tmpl$0();\n}\nexport function renderPatchworkFrame(isolation) {\n return (handle, element) => {\n return render(() => _$createComponent(PatchworkFrame, {\n handle: handle,\n get repo() {\n return element.repo;\n },\n isolation: isolation\n }), element);\n };\n}\n_$delegateEvents([\"click\"]);", "import { parseAutomergeUrl, stringifyAutomergeUrl, } from \"@automerge/automerge-repo\";\nimport { forwardingProxy } from \"./forwarding-proxy.js\";\n// The only members whose behavior an overlay handle changes: the presented\n// identity, the identity-preserving `sub` (so sub-handle urls stay in the\n// presented space), the argument-unwrapping handle comparisons\n// (`merge`/`overlaps`/`contains`/`isChildOf`/`equals`), and the re-stamping\n// EventEmitter surface. Everything else (doc/change/heads/ref/view/diff/...)\n// forwards to the backing handle.\nconst OVERLAY_HANDLE_OWNED = new Set([\n \"url\",\n \"documentId\",\n \"backingHandle\",\n \"sub\",\n \"merge\",\n \"overlaps\",\n \"contains\",\n \"isChildOf\",\n \"equals\",\n \"on\",\n \"off\",\n \"once\",\n \"addListener\",\n \"removeListener\",\n \"removeAllListeners\",\n \"emit\",\n]);\n/**\n * A url-hiding proxy around a fixed backing `DocHandle`. `url`/`documentId`\n * always report the *presented* url; every other operation forwards to the\n * backing handle. Event subscriptions are tracked locally and the backing\n * handle's events are lazily forwarded with `payload.handle` re-stamped to this\n * wrapper, so consumers never observe the backing (clone) handle or its url.\n *\n * Unlike the copy-on-write handle it is modelled on, the backing never swaps:\n * remappers clone eagerly and hand back the clone up front, so there is no\n * COW, no re-wiring, and no synthetic change nudge.\n */\nexport class OverlayHandle {\n #originalUrl;\n #handle;\n #listeners = new Map();\n #forwarded = new Set();\n // Sub-handle wrappers keyed by their backing (canonicalised) url, so repeated\n // `sub(...)` of the same path return the same wrapper instance.\n #subCache = new Map();\n // The Proxy returned from the constructor \u2014 the object consumers actually\n // hold. Re-stamped onto forwarded events so identity stays consistent.\n #self;\n constructor(opts) {\n this.#originalUrl = opts.presentedUrl;\n this.#handle = opts.backing;\n this.#self = forwardingProxy(this, opts.backing, OVERLAY_HANDLE_OWNED);\n return this.#self;\n }\n get url() {\n return this.#originalUrl;\n }\n get documentId() {\n return parseAutomergeUrl(this.#originalUrl).documentId;\n }\n /** @internal The live handle this wrapper forwards to. */\n get backingHandle() {\n return this.#handle;\n }\n // Handle comparisons read the *other* handle's internals (Automerge rejects\n // a foreign wrapper, and `overlaps`/`contains` touch its private `#path`), so\n // unwrap an overlay argument down to its backing before delegating.\n merge(other) {\n this.#handle.merge(unwrapHandle(other));\n }\n overlaps(other) {\n return this.#handle.overlaps(unwrapHandle(other));\n }\n contains(other) {\n return this.#handle.contains(unwrapHandle(other));\n }\n isChildOf(other) {\n return this.#handle.isChildOf(unwrapHandle(other));\n }\n equals(other) {\n return this.#handle.equals(unwrapHandle(other));\n }\n // Sub-handles must keep reporting urls in the *presented* space; otherwise a\n // ref or cursor produced here (a comment target, a selection cursor, ...)\n // would leak the backing (clone) documentId and break identity for consumers\n // that resolve it back through the overlay. We scope `sub` to the backing\n // handle (reads/writes still hit the clone) but wrap the result in another\n // OverlayHandle whose presented url swaps the documentId back to ours. The\n // backing sub-handle is canonicalised by the repo, so caching by its url\n // keeps our wrappers referentially stable too.\n sub(...segments) {\n const backingSub = this.#handle.sub(...segments);\n const cached = this.#subCache.get(backingSub.url);\n if (cached)\n return cached;\n const wrapped = new OverlayHandle({\n presentedUrl: restampUrl(this.#originalUrl, backingSub.url),\n backing: backingSub,\n });\n this.#subCache.set(backingSub.url, wrapped);\n return wrapped;\n }\n on(ev, fn) {\n this.#forward(ev);\n let set = this.#listeners.get(ev);\n if (!set) {\n set = new Set();\n this.#listeners.set(ev, set);\n }\n set.add(fn);\n return this.#self;\n }\n off(ev, fn) {\n this.#listeners.get(ev)?.delete(fn);\n return this.#self;\n }\n once(ev, fn) {\n const wrapper = (...args) => {\n this.off(ev, wrapper);\n fn(...args);\n };\n return this.on(ev, wrapper);\n }\n addListener(ev, fn) {\n return this.on(ev, fn);\n }\n removeListener(ev, fn) {\n return this.off(ev, fn);\n }\n removeAllListeners(ev) {\n if (ev)\n this.#listeners.get(ev)?.clear();\n else\n this.#listeners.clear();\n return this.#self;\n }\n emit(ev, ...args) {\n const set = this.#listeners.get(ev);\n if (!set || set.size === 0)\n return false;\n for (const fn of [...set])\n fn(...args);\n return true;\n }\n // Lazily forward a backing event the first time someone subscribes to it,\n // re-stamping `payload.handle = this wrapper` so consumers see the wrapper\n // rather than the backing handle as the event source.\n #forward(ev) {\n if (this.#forwarded.has(ev))\n return;\n this.#forwarded.add(ev);\n this.#handle.on(ev, (payload) => {\n if (payload &&\n typeof payload === \"object\" &&\n \"handle\" in payload) {\n this.emit(ev, { ...payload, handle: this.#self });\n }\n else {\n this.emit(ev, payload);\n }\n });\n }\n}\n// Unwrap an overlay wrapper down to its backing handle (Automerge rejects a\n// foreign wrapper, and comparisons touch the backing's private fields). Plain\n// handles pass through untouched.\nfunction unwrapHandle(handle) {\n return handle instanceof OverlayHandle\n ? handle.backingHandle\n : handle;\n}\n// Re-stamp a backing (clone) handle url into the presented space: keep the\n// path segments and any pinned heads, but swap the documentId back to the\n// presented root's. Mirrors the original->clone mapping in OverlayRepo#resolve.\nfunction restampUrl(presentedRoot, backingUrl) {\n const { documentId } = parseAutomergeUrl(presentedRoot);\n const { segments, heads } = parseAutomergeUrl(backingUrl);\n return stringifyAutomergeUrl({ documentId, segments, heads });\n}\n", "import { interpretAsDocumentId, isValidAutomergeUrl, parseAutomergeUrl, stringifyAutomergeUrl, } from \"@automerge/automerge-repo\";\nimport { request } from \"./index.js\";\nimport { forwardingProxy } from \"./forwarding-proxy.js\";\nimport { OverlayHandle } from \"./overlay-handle.js\";\n// The only members whose behavior an overlay repo changes; everything else\n// (create/create2/clone/delete, the EventEmitter surface, ...) forwards to the\n// realm-local base repo.\nconst OVERLAY_REPO_OWNED = new Set([\n \"baseRepo\",\n \"handles\",\n \"find\",\n \"findWithProgress\",\n \"create\",\n \"create2\",\n]);\n/**\n * A realm-local {@link RepoLike} shim that makes document resolution\n * remappable across provider scopes (including iframes) without sending a live\n * `Repo`/`DocHandle` over the wire.\n *\n * `find`/`findWithProgress` dispatch a `repo:handle-descriptor` subscription for\n * the requested url and resolve the returned `cloneUrl ?? url` against the\n * realm-local `baseRepo`, then hand back an {@link OverlayHandle} that keeps\n * reporting the *original* url. Every other method (`create`, `create2`,\n * `clone`, `delete`, the EventEmitter surface, ...) forwards to `baseRepo`\n * unchanged \u2014 created docs need no remapping.\n */\nexport class OverlayRepo {\n /** The realm-local repo all resolution ultimately bottoms out in. */\n baseRepo;\n #element;\n // Keyed by the *presented* url (documentId + path + heads), not just the\n // documentId, so distinct sub-document paths under the same root document\n // don't collide.\n #wrapped = new Map();\n #inner = new Map();\n #resolving = new Map();\n constructor(baseRepo, element) {\n this.baseRepo = baseRepo;\n this.#element = element;\n // Forward everything but resolution to the realm-local repo.\n return forwardingProxy(this, baseRepo, OVERLAY_REPO_OWNED);\n }\n // Only already-wrapped handles are exposed; unknown ids fall through to\n // `find`/`findWithProgress` so consumers never see an un-wrapped handle.\n // `#wrapped` is keyed by presented url, so derive the documentId from each\n // handle; sub-handles of the same root collapse onto a single entry (the\n // `Record<DocumentId, ...>` shape can't represent paths).\n get handles() {\n const out = {};\n for (const wrapped of this.#wrapped.values()) {\n out[wrapped.documentId] = wrapped;\n }\n return out;\n }\n async find(id) {\n const presented = presentedUrlOf(id);\n const cached = this.#wrapped.get(presented);\n if (cached)\n return cached;\n const wrapped = await this.#resolve(presented);\n return wrapped;\n }\n // Mirrors the realm-local repo's progress but reports `loading` until the\n // descriptor has arrived and the backing handle is wrapped \u2014 otherwise\n // consumers would briefly observe the un-wrapped (un-remapped) handle.\n findWithProgress(id) {\n const self = this;\n const presented = presentedUrlOf(id);\n // The reported `documentId` is the root id \u2014 `DocumentId` can't encode a\n // path \u2014 but caches are keyed by the full presented url.\n const documentId = parseAutomergeUrl(presented).documentId;\n const wrappedPromise = this.#resolve(presented);\n wrappedPromise.catch(() => { });\n const peek = () => {\n const inner = self.#inner.get(presented);\n if (!inner)\n return { state: \"loading\", sources: {} };\n const innerState = inner.peek();\n if (innerState.state !== \"ready\")\n return innerState;\n const wrapped = self.#wrapped.get(presented);\n if (!wrapped) {\n return { state: \"loading\", sources: innerState.sources };\n }\n return {\n state: \"ready\",\n handle: wrapped,\n sources: innerState.sources,\n };\n };\n return {\n documentId,\n peek,\n subscribe: (callback) => {\n let last = null;\n let unsubscribeInner = () => { };\n const dispatch = () => {\n const state = peek();\n const sig = state.state === \"failed\"\n ? `failed:${state.error.message}`\n : state.state;\n if (sig === last)\n return;\n last = sig;\n callback(state);\n };\n wrappedPromise.then(() => {\n const inner = self.#inner.get(presented);\n if (inner)\n unsubscribeInner = inner.subscribe(dispatch);\n dispatch();\n }, dispatch);\n return () => unsubscribeInner();\n },\n whenReady: ({ signal } = {}) => {\n const handlePromise = wrappedPromise;\n if (signal?.aborted)\n return Promise.reject(signal.reason);\n if (!signal)\n return handlePromise;\n return new Promise((resolve, reject) => {\n const onAbort = () => reject(signal.reason);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n handlePromise.then((handle) => {\n signal.removeEventListener(\"abort\", onAbort);\n resolve(handle);\n }, (err) => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(err);\n });\n });\n },\n // Deprecated; kept for pre-`peek()` consumers.\n get state() {\n return peek().state;\n },\n get progress() {\n return self.#inner.get(presented)?.progress;\n },\n get error() {\n const s = peek();\n return s.state === \"failed\" ? s.error : undefined;\n },\n };\n }\n // Plain local creates need no remapping; declared (rather than forwarded) so\n // the class still satisfies `RepoLike`.\n create(initialValue) {\n return this.baseRepo.create(initialValue);\n }\n create2(initialValue) {\n return this.baseRepo.create2(initialValue);\n }\n // De-dupes concurrent resolutions of the same presented url: the first\n // caller dispatches the subscription, everyone else awaits the same promise.\n #resolve(presented) {\n const existing = this.#resolving.get(presented);\n if (existing)\n return existing;\n const promise = (async () => {\n // The descriptor channel remaps whole documents, so ask about the root\n // and reapply the original path/heads onto whatever clone comes back.\n // The clone is a fork of the root, so the same sub-tree exists in it.\n const { documentId, segments, heads } = parseAutomergeUrl(presented);\n const rootUrl = stringifyAutomergeUrl({ documentId });\n const descriptor = await request(this.#element, {\n type: \"repo:handle-descriptor\",\n url: rootUrl,\n });\n const backingRoot = descriptor.cloneUrl ?? descriptor.url;\n const backingUrl = stringifyAutomergeUrl({\n documentId: parseAutomergeUrl(backingRoot).documentId,\n segments,\n heads,\n });\n const inner = this.baseRepo.findWithProgress(backingUrl);\n this.#inner.set(presented, inner);\n const backing = await this.baseRepo.find(backingUrl);\n const wrapped = new OverlayHandle({\n presentedUrl: presented,\n backing,\n });\n this.#wrapped.set(presented, wrapped);\n return wrapped;\n })();\n this.#resolving.set(presented, promise);\n return promise;\n }\n}\n// Canonicalize any id to its *presented* url, preserving the path suffix\n// (`/a/@0/b`) and any pinned heads so sub-document and view-scoped urls keep\n// their identity through the overlay. Plain document ids carry no path.\nfunction presentedUrlOf(id) {\n if (isValidAutomergeUrl(id)) {\n const { documentId, segments, heads } = parseAutomergeUrl(id);\n return stringifyAutomergeUrl({ documentId, segments, heads });\n }\n return stringifyAutomergeUrl({ documentId: interpretAsDocumentId(id) });\n}\n", "/**\n * Open a streaming subscription. Dispatches a `patchwork:subscribe` for the\n * given `selector` carrying a fresh `MessageChannel` port; the answering\n * provider pushes values back over that channel for as long as the\n * subscription is live. `listener` is invoked once per emission (the first\n * delivery is always async because `MessagePort.postMessage` queues a task).\n *\n * The event is dispatched from the nearest enclosing `<patchwork-view>` so\n * callers can pass any node inside a provider subtree. An unclaimed\n * subscription is never settled: if no provider answers, `listener` simply\n * never fires.\n *\n * Returns an unsubscribe function. Calling it tells the provider to tear down\n * (via an `unsubscribe` message) and closes the consumer's port; any values\n * the provider emits after that are dropped.\n */\nexport function subscribe(element, selector, listener) {\n const view = element.closest(\"patchwork-view\");\n const dispatchEl = view ?? element;\n const channel = new MessageChannel();\n const port = channel.port2;\n const controller = new AbortController();\n const { signal } = controller;\n port.addEventListener(\"message\", (event) => {\n if (event.data?.type === \"change\")\n listener(event.data.value);\n }, { signal });\n // addEventListener (unlike assigning onmessage) does not implicitly start\n // the port, so message delivery has to be kicked off explicitly.\n port.start();\n const detail = {\n selector,\n port: channel.port1,\n };\n dispatchEl.dispatchEvent(new CustomEvent(\"patchwork:subscribe\", {\n detail,\n bubbles: true,\n composed: true,\n }));\n return () => {\n if (signal.aborted)\n return;\n controller.abort();\n port.postMessage({ type: \"unsubscribe\" });\n port.close();\n };\n}\n/**\n * Answer a `patchwork:subscribe`. The `producer` receives a `respond`\n * callback it can call any number of times to push values to the consumer,\n * and may return a teardown that runs when the consumer unsubscribes. Stops\n * propagation so ancestor providers don't double-answer. Values emitted after\n * the consumer unsubscribes are dropped.\n */\nexport function accept(event, producer) {\n event.stopPropagation();\n const port = event.detail.port;\n let alive = true;\n const respond = (value) => {\n if (!alive)\n return;\n port.postMessage({ type: \"change\", value });\n };\n let teardown;\n try {\n teardown = producer(respond);\n }\n catch (err) {\n console.error(\"[patchwork-providers] subscribe producer threw:\", err);\n }\n const stop = () => {\n if (!alive)\n return;\n alive = false;\n try {\n teardown?.();\n }\n catch (err) {\n console.error(\"[patchwork-providers] subscribe teardown threw:\", err);\n }\n port.close();\n };\n port.onmessage = (event) => {\n if (event.data?.type === \"unsubscribe\")\n stop();\n };\n}\n/**\n * One-shot convenience wrapper over {@link subscribe}: opens a subscription\n * for `selector`, resolves with the first value a provider emits, then\n * immediately unsubscribes. Because there is no fallback provider, an\n * unclaimed selector never resolves \u2014 use `subscribe` directly if you need to\n * handle the \"no provider\" case.\n */\nexport function request(element, selector) {\n return new Promise((resolve) => {\n const unsubscribe = subscribe(element, selector, (value) => {\n // The first emission is always async (postMessage queues a task), so\n // `unsubscribe` is assigned by the time this fires.\n unsubscribe();\n resolve(value);\n });\n });\n}\nexport { registerRepoProviderElement, } from \"./repo-provider.js\";\nexport { OverlayHandle } from \"./overlay-handle.js\";\nexport { OverlayRepo } from \"./overlay-repo.js\";\n", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=threepane-widgets>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=threepane-widgets__empty><button type=button class=threepane-widgets__add>\uFF0B Add document list`),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=threepane-widget>`);\nimport { For, Show } from \"solid-js\";\nimport { SlotView } from \"./SlotView\";\nconst DOCUMENT_LIST_TOOL = \"chee/document-list\";\nexport function SidebarWidgets(props) {\n const addDocumentList = () => {\n const root = props.rootFolderUrl();\n const handle = props.configHandle();\n if (!root || !handle) return;\n handle.change(doc => {\n doc.sidebar.widgets.push([DOCUMENT_LIST_TOOL, root]);\n });\n };\n return (() => {\n var _el$ = _tmpl$();\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return props.ready();\n },\n get children() {\n return _$createComponent(Show, {\n get when() {\n return props.widgets().length;\n },\n get fallback() {\n return (// While the config/root folder are still loading we can't add a\n // widget yet \u2014 show nothing rather than a disabled button.\n _$createComponent(Show, {\n get when() {\n return _$memo(() => !!props.rootFolderUrl())() && props.configHandle();\n },\n get children() {\n var _el$2 = _tmpl$2(),\n _el$3 = _el$2.firstChild;\n _el$3.$$click = addDocumentList;\n return _el$2;\n }\n })\n );\n },\n get children() {\n return _$createComponent(For, {\n get each() {\n return props.widgets();\n },\n children: widget => (() => {\n var _el$4 = _tmpl$3();\n _$insert(_el$4, _$createComponent(SlotView, {\n slot: widget\n }));\n return _el$4;\n })()\n });\n }\n });\n }\n }));\n return _el$;\n })();\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=frame-tray>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=frame-tray__item>`);\nimport { For, Show } from \"solid-js\";\nimport { SlotView, slotId } from \"./SlotView\";\nexport function Tray(props) {\n return _$createComponent(Show, {\n get when() {\n return props.slots().length;\n },\n get children() {\n var _el$ = _tmpl$();\n _$insert(_el$, _$createComponent(For, {\n get each() {\n return props.slots();\n },\n children: slot => (() => {\n var _el$2 = _tmpl$2();\n _$insert(_el$2, _$createComponent(SlotView, {\n slot: slot\n }));\n _$effect(() => _$setAttribute(_el$2, \"data-tray-id\", slotId(slot)));\n return _el$2;\n })()\n }));\n return _el$;\n }\n });\n}", "import type { AutomergeUrl, DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\nimport { createDocOfDatatype2 } from \"@inkandswitch/patchwork-plugins\";\nimport type { AccountDoc, ThreepaneConfigDoc, ToolRef, ToolSlot } from \"../types\";\nimport { DEFAULT_DOCTITLE_TOOLS, DEFAULT_TRAY_TOOLS } from \"../datatypes\";\nimport { loadDatatypeWhenReady } from \"./loadDatatypeWhenReady\";\n\n// Title + spacer are intrinsic to the frame's top bar, never configured tools.\nconst INTRINSIC_DOCTITLE_TOOLS = new Set([\"document-title\", \"spacer\"]);\n\n// The sidebar's default widget: a document list pinned to the account's root\n// folder. Every account gets one so the left pane is never empty.\nconst DOCUMENT_LIST_TOOL = \"chee/document-list\";\n\n/** The default sidebar widgets for a fresh (or empty) account. */\nfunction defaultSidebarWidgets(rootFolderUrl?: AutomergeUrl): ToolRef[] {\n return rootFolderUrl ? [[DOCUMENT_LIST_TOOL, rootFolderUrl]] : [];\n}\n\n/**\n * Lazily create the threepane layout config doc and point `account.tools.threepane`\n * at it, migrating the legacy `account.documentToolbarToolIds` into its\n * `doctitle` lane. The context sidebar is host chrome and still registry-driven\n * (every `patchwork:component` tagged `\"context-tool\"`); the system tray is now\n * an explicit `tray` list here, seeded with `DEFAULT_TRAY_TOOLS` (and backfilled\n * for configs created before the field existed).\n *\n * Seeds the sidebar with a default document-list widget (pinned to the account's\n * root folder), so the left pane is never empty.\n *\n * Non-destructive: the old `documentToolbarToolIds` / `accountSidebarToolId`\n * fields are left untouched so older builds keep working and you can switch\n * branches freely during the PR. Run the (separate, opt-in)\n * cleanupLegacyAccountFields script to remove them later.\n */\nexport async function ensureThreepaneConfig(\n accountHandle: DocHandle<AccountDoc>,\n repo: Repo\n) {\n const rootFolderUrl = accountHandle.doc()?.rootFolderUrl;\n const existingConfigUrl = accountHandle.doc()?.tools?.[\"threepane\"];\n\n // Already migrated. Backfill the default document-list widget for early\n // builds of this branch that seeded an empty sidebar.\n if (existingConfigUrl) {\n const configHandle = await repo.find<ThreepaneConfigDoc>(existingConfigUrl);\n configHandle.change((doc) => {\n if (rootFolderUrl && !doc.sidebar?.widgets?.length) {\n doc.sidebar.widgets = defaultSidebarWidgets(rootFolderUrl);\n }\n // Backfill the tray for configs created before it moved out of the\n // registry onto this doc, so existing accounts keep their system tray.\n if (!doc.tray) {\n doc.tray = DEFAULT_TRAY_TOOLS.slice();\n }\n // An account whose doctitle lane ended up empty (nothing to migrate from\n // the legacy field) gets the defaults rather than a bare top bar.\n if (!doc.doctitle?.tools?.length) {\n doc.doctitle = { ...doc.doctitle, tools: DEFAULT_DOCTITLE_TOOLS.slice() };\n }\n });\n return;\n }\n\n const datatype = await loadDatatypeWhenReady<ThreepaneConfigDoc>(\n \"threepane:config\"\n );\n if (!datatype) {\n console.warn(\"frame: threepane:config datatype never registered\");\n return;\n }\n\n // Re-check after the await in case another tab migrated concurrently.\n if (accountHandle.doc()?.tools?.[\"threepane\"]) return;\n\n const account = accountHandle.doc();\n\n // doctitle tools migrate as bare ids: the frame always points them at the\n // selected main-view doc, so a slot tuple's docid would be ignored \u2014 keep\n // them as plain strings.\n const doctitleTools: ToolSlot[] = (account?.documentToolbarToolIds ?? [])\n .filter((id) => !INTRINSIC_DOCTITLE_TOOLS.has(id));\n\n const configHandle = await createDocOfDatatype2<ThreepaneConfigDoc>(\n datatype,\n repo\n );\n configHandle.change((doc) => {\n if (doctitleTools.length) doc.doctitle.tools = doctitleTools;\n doc.sidebar.widgets = defaultSidebarWidgets(account?.rootFolderUrl);\n if (!doc.tray) doc.tray = DEFAULT_TRAY_TOOLS.slice();\n });\n\n accountHandle.change((acc) => {\n if (!acc.tools) acc.tools = {};\n if (!acc.tools[\"threepane\"]) acc.tools[\"threepane\"] = configHandle.url;\n });\n}\n", "import {\n getRegistry,\n type DatatypeDescription,\n type LoadedDatatype,\n} from \"@inkandswitch/patchwork-plugins\";\n\nexport function loadDatatypeWhenReady<D>(\n id: string\n): Promise<LoadedDatatype<D>> {\n return getRegistry<DatatypeDescription>(\n \"patchwork:datatype\"\n ).loadWhenReady(id) as Promise<LoadedDatatype<D>>;\n}\n", "import debug from \"debug\";\nimport type { DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\nimport { createDocOfDatatype2 } from \"@inkandswitch/patchwork-plugins\";\nimport type { FolderDoc } from \"@inkandswitch/patchwork-filesystem\";\nimport type { AccountDoc } from \"../types\";\nimport { loadDatatypeWhenReady } from \"./loadDatatypeWhenReady\";\n\nconst log = debug(\"patchwork:threepane:examples\");\n\n/**\n * Seed a fresh account with example documents by running each static module\n * bundle's generated `init.js` (emitted by that repo's scripts/bundle.mjs next\n * to its modules.json). Every init script receives the same Examples folder\n * handle, so multiple bundles merge their examples into one folder.\n *\n * Runs at most once per account: the account doc's `exampleDocsSeededAt`\n * marker is claimed *before* seeding (a race between two tabs can at worst\n * skip the examples, never duplicate them), and a deleted Examples folder is\n * never recreated. Accounts that already have documents get the marker but no\n * examples \u2014 only truly fresh accounts are seeded.\n */\nexport async function seedExampleDocuments(\n accountHandle: DocHandle<AccountDoc>,\n repo: Repo\n) {\n const account = accountHandle.doc();\n if (!account?.rootFolderUrl) {\n log(\"skipped \u2014 account has no rootFolderUrl\");\n return;\n }\n if (account.exampleDocsSeededAt) {\n log(\n \"skipped \u2014 already ran for this account at\",\n new Date(account.exampleDocsSeededAt).toISOString()\n );\n return;\n }\n\n log(\"claiming marker on account\", accountHandle.url);\n accountHandle.change((doc) => {\n if (!doc.exampleDocsSeededAt) doc.exampleDocsSeededAt = Date.now();\n });\n\n const rootFolder = await repo.find<FolderDoc>(account.rootFolderUrl);\n const existingDocs = rootFolder.doc()?.docs?.length ?? 0;\n if (existingDocs) {\n log(\n `skipped \u2014 root folder already has ${existingDocs} doc(s); only fresh accounts are seeded`\n );\n return;\n }\n\n const initUrls = await bundleInitScriptUrls();\n log(\"bundle init scripts:\", initUrls);\n if (!initUrls.length) {\n log(\"skipped \u2014 no static module bundles to ask\");\n return;\n }\n\n const folderDatatype = await loadDatatypeWhenReady<FolderDoc>(\"folder\");\n if (!folderDatatype) {\n log(\"folder datatype never registered; giving up\");\n return;\n }\n const folder = await createDocOfDatatype2<FolderDoc>(\n folderDatatype,\n repo,\n (doc) => {\n doc.title = \"Examples\";\n }\n );\n\n for (const url of initUrls) {\n try {\n const mod = await import(/* @vite-ignore */ url);\n await mod.default?.(repo, folder);\n log(\"ran init script\", url);\n } catch (err) {\n // A bundle that ships no init script 404s here \u2014 normal, not an error.\n log(\"init script unavailable or failed\", url, err);\n }\n }\n\n const seeded = folder.doc()?.docs?.length ?? 0;\n if (!seeded) {\n // Don't leave an empty Examples folder if no bundle contributed anything.\n log(\"no bundle contributed any documents\");\n return;\n }\n\n rootFolder.change((doc) => {\n doc.docs.unshift({ name: \"Examples\", type: \"folder\", url: folder.url });\n });\n log(`seeded ${seeded} document(s) into Examples folder`, folder.url);\n}\n\ntype ModuleWatcherLike = {\n urls?: Record<string, string>;\n doneLoading?: Promise<void>;\n};\n\n/**\n * The patchwork-tools bundle isn't in every site's default module sources\n * (some boot from an automerge module-settings doc, which has no init.js),\n * but its examples should seed everywhere \u2014 so it's always consulted.\n */\nconst TOOLS_BUNDLE_INIT_URL = \"https://patchwork-tools.netlify.app/init.js\";\n\n/**\n * Fallback for shells with no static manifest at all (automerge-doc module\n * sources only): the deployed patchwork-base bundle. Not consulted when any\n * static manifest is configured, because that manifest is usually a copy of\n * this very bundle (e.g. a localhost dev serve) and URL-dedupe can't tell \u2014\n * always adding it would seed base's examples twice.\n */\nconst BASE_BUNDLE_INIT_URL = \"https://patchwork-base.netlify.app/init.js\";\n\n/**\n * The `init.js` URL next to every static (http) module manifest the host is\n * watching, plus the hardcoded bundles above. Automerge module-settings docs\n * have no init script. Waits for the watcher's initial load so the bundles'\n * plugins are registered before any example runs.\n */\nasync function bundleInitScriptUrls(): Promise<string[]> {\n const watcher = (\n window as { patchwork?: { packages?: ModuleWatcherLike } }\n ).patchwork?.packages;\n if (!watcher?.urls) return [BASE_BUNDLE_INIT_URL, TOOLS_BUNDLE_INIT_URL];\n await watcher.doneLoading;\n const fromManifests = Object.values(watcher.urls)\n .filter((url) => typeof url === \"string\" && !url.startsWith(\"automerge:\"))\n .map((url) => new URL(\"init.js\", new URL(url, document.baseURI)).href);\n const base = fromManifests.length ? [] : [BASE_BUNDLE_INIT_URL];\n return [...new Set([...fromManifests, ...base, TOOLS_BUNDLE_INIT_URL])];\n}\n"],
|
|
5
|
-
"mappings": "+QAAA,OAAS,YAAYA,MAAkB,eACvC,OAAS,kBAAkBC,OAAwB,eACnD,OAAS,QAAQC,OAAc,eAC/B,OAAS,oBAAoBC,OAA0B,eACvD,OAAS,gBAAgBC,MAAsB,eAC/C,OAAS,UAAUC,MAAgB,eACnC,OAAS,YAAYC,MAAkB,eACvC,OAAS,OAAOC,MAAa,eAC7B,OAAS,UAAUC,MAAgB,eACnC,OAAS,mBAAmBC,MAAyB,eAWrD,MAAO,mCCpBP,OAAS,qBAAAC,GAAmB,yBAAAC,OAA8B,4BCA1D,OAAS,yBAAAC,GAAuB,uBAAAC,GAAqB,qBAAAC,GAAmB,yBAAAC,OAA8B,4BCgB/F,SAASC,GAAUC,EAASC,EAAUC,EAAU,CAEnD,IAAMC,EADOH,EAAQ,QAAQ,gBAAgB,GAClBA,EACrBI,EAAU,IAAI,eACdC,EAAOD,EAAQ,MACfE,EAAa,IAAI,gBACjB,CAAE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ACpD,OAAQC,EACR,IAAI,MAAO,CACT,OAAOZ,EAAQ,IACjB,EACA,UAAWuJ,CACb,CAAC,EAAGvJ,CAAO,CAEf,CACAyJ,GAAiB,CAAC,OAAO,CAAC",
|
|
6
|
-
"names": ["_$template", "_$delegateEvents", "_$memo", "_$setStyleProperty", "_$setAttribute", "_$effect", "_$getOwner", "_$use", "_$insert", "_$createComponent", "parseAutomergeUrl", "stringifyAutomergeUrl", "interpretAsDocumentId", "isValidAutomergeUrl", "parseAutomergeUrl", "stringifyAutomergeUrl", "subscribe", "element", "selector", "listener", "dispatchEl", "channel", "port", "controller", "signal", "event", "detail", "_$template", "_$delegateEvents", "_$memo", "_$insert", "_$createComponent", "For", "Show", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "DOCUMENT_LIST_TOOL", "SidebarWidgets", "props", "addDocumentList", "root", "handle", "doc", "_el$", "_$insert", "_$createComponent", "Show", "_$memo", "_el$2", "_el$3", "For", "widget", "_el$4", "SlotView", "_$delegateEvents", "_$template", "_$setAttribute", "_$effect", "_$insert", "_$createComponent", "For", "Show", "_tmpl$", "_$template", "_tmpl$2", "Tray", "props", "_$createComponent", "Show", "_el$", "_$insert", "For", "slot", "_el$2", "SlotView", "_$effect", "_$setAttribute", "slotId", "createEffect", "createMemo", "createSignal", "onCleanup", "onMount", "Show", "render", "createDocOfDatatype2", "getRegistry", "loadDatatypeWhenReady", "id", "INTRINSIC_DOCTITLE_TOOLS", "DOCUMENT_LIST_TOOL", "defaultSidebarWidgets", "rootFolderUrl", "ensureThreepaneConfig", "accountHandle", "repo", "existingConfigUrl", "doc", "DEFAULT_TRAY_TOOLS", "DEFAULT_DOCTITLE_TOOLS", "datatype", "loadDatatypeWhenReady", "account", "doctitleTools", "id", "configHandle", "createDocOfDatatype2", "acc", "import_debug", "createDocOfDatatype2", "log", "debug", "seedExampleDocuments", "accountHandle", "repo", "account", "doc", "rootFolder", "existingDocs", "initUrls", "bundleInitScriptUrls", "folderDatatype", "loadDatatypeWhenReady", "folder", "createDocOfDatatype2", "url", "err", "seeded", "TOOLS_BUNDLE_INIT_URL", "BASE_BUNDLE_INIT_URL", "watcher", "fromManifests", "base", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "_tmpl$4", "_tmpl$5", "_tmpl$6", "_tmpl$7", "_tmpl$8", "_tmpl$9", "_tmpl$0", "MIN_SIDEBAR_WIDTH", "MAX_SIDEBAR_WIDTH", "AUTO_CLOSE_WIDTH", "DRAG_THRESHOLD", "useFrameProviderReady", "componentId", "element", "isReady", "setReady", "createSignal", "createEffect", "el", "onMounted", "event", "onCleanup", "dispatchOpen", "detail", "PatchworkFrame", "handle", "repo", "props", "ensureFrameStyles", "accountDocUrl", "accountProviderElement", "setAccountProviderElement", "isAccountProviderReady", "toolStorageProviderElement", "setToolStorageProviderElement", "isToolStorageProviderReady", "selectedDocProviderElement", "setSelectedDocProviderElement", "isSelectedDocProviderReady", "areProvidersReady", "createMemo", "_el$", "_el$2", "_el$3", "_el$4", "_el$5", "_el$6", "_el$7", "_$insert", "_$createComponent", "Show", "_$use", "_$getOwner", "PatchworkFrameInner", "accountDocHandle", "useDocHandle", "ensureThreepaneConfig", "seedExampleDocuments", "err", "docVersion", "setDocVersion", "h", "onChange", "v", "accountDoc", "threepaneUrl", "threepaneConfigHandle", "threepaneVersion", "setThreepaneVersion", "threepaneConfig", "doctitleSlots", "sidebarWidgets", "traySlots", "rootFolderUrl", "sidebarState", "useSidebarState", "sidebarResize", "useSidebarResize", "debugEvents", "dismissEvent", "clearAll", "useDebugRegistryToast", "selectedView", "setSelectedView", "popoverView", "setPopoverView", "onMount", "unsubscribeSelectedView", "subscribe", "view", "selectedDocUrl", "selectedToolId", "initialRightWidth", "getStoredNumber", "SIDEBAR_KEYS", "DEFAULT_SIDEBAR_WIDTH", "initialRightCollapsed", "getStoredBoolean", "mainDocElement", "setMainDocElement", "isMainDocMounted", "useMainDocMounted", "widgetsReady", "setWidgetsReady", "_el$8", "_ref$", "DebugRegistryToast", "FrameLayout", "_el$9", "MainDocumentView", "DocumentAreaRoot", "IsolatedDocumentArea", "FramePopover", "toolId", "setToolId", "popoverEl", "onKey", "e", "onOpen", "url", "nextToolId", "_el$0", "_el$1", "_el$10", "_el$11", "_el$12", "_el$13", "_ref$2", "_$effect", "_p$", "_v$", "_v$2", "_v$3", "isCollapsed", "hasTray", "footerEl", "sidebarContentEl", "COLLAPSE_CONTEXT_SIDEBAR_EVENT", "_el$14", "PanelLeftIcon", "_v$4", "_v$5", "_v$6", "_$setAttribute", "Sidebar", "_el$15", "_el$16", "_el$17", "_el$18", "_ref$3", "SidebarWidgets", "_ref$4", "contactUrl", "_el$20", "_el$21", "moduleSettingsUrl", "_el$22", "_el$19", "Tray", "_v$7", "_v$8", "_$setStyleProperty", "_$memo", "renderPatchworkFrame", "isolation", "render", "_$delegateEvents"]
|
|
3
|
+
"sources": ["../src/PatchworkFrame.tsx", "../node_modules/.pnpm/@inkandswitch+patchwork-providers@0.3.0_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2.0_/node_modules/@inkandswitch/patchwork-providers/dist/overlay-handle.js", "../node_modules/.pnpm/@inkandswitch+patchwork-providers@0.3.0_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2.0_/node_modules/@inkandswitch/patchwork-providers/dist/overlay-repo.js", "../node_modules/.pnpm/@inkandswitch+patchwork-providers@0.3.0_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2.0_/node_modules/@inkandswitch/patchwork-providers/dist/index.js", "../src/components/SidebarWidgets.tsx", "../src/components/Tray.tsx", "../src/account/ensureThreepaneConfig.ts", "../src/account/loadDatatypeWhenReady.ts", "../src/account/seedExampleDocuments.ts", "../src/account/gaiosExamples.ts"],
|
|
4
|
+
"sourcesContent": ["import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { setStyleProperty as _$setStyleProperty } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { use as _$use } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=frame-shell><aside class=frame-warning-banner>research grade software. do not share links. sharing a doc is sharing your account.</aside><div class=frame><patchwork-view component=patchwork-selected-doc-provider><patchwork-view component=patchwork-account-provider><patchwork-view component=patchwork-tool-storage-provider>`, true, false, false),\n _tmpl$2 = /*#__PURE__*/_$template(`<div style=display:contents>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=main-area>`),\n _tmpl$4 = /*#__PURE__*/_$template(`<div class=frame__popover-backdrop><div class=frame__popover role=dialog aria-modal=true><div class=frame__popover-toolbar><patchwork-view tool-id=doc-openwith></patchwork-view></div><div class=frame__popover-body><patchwork-view>`, true, false, false),\n _tmpl$5 = /*#__PURE__*/_$template(`<button type=button class=\"frame__sidebar-toggle frame__left-toggle\">`),\n _tmpl$6 = /*#__PURE__*/_$template(`<div class=threepane-sidebar><div class=threepane-sidebar__footer><footer class=threepane-account-bar><button type=button class=threepane-account-bar__button>Settings`),\n _tmpl$7 = /*#__PURE__*/_$template(`<div class=frame__tray-dock>`),\n _tmpl$8 = /*#__PURE__*/_$template(`<button type=button class=\"threepane-account-bar__button threepane-account-bar__avatar\"title=Account aria-label=Account><patchwork-view tool-id=contact-avatar>`, true, false, false),\n _tmpl$9 = /*#__PURE__*/_$template(`<button type=button class=threepane-account-bar__button>Packages`),\n _tmpl$0 = /*#__PURE__*/_$template(`<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox=\"0 0 24 24\"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d=\"M9 3v18\">`);\nimport \"@inkandswitch/patchwork-elements\";\nimport { useDocHandle } from \"solid-automerge\";\nimport { subscribe } from \"@inkandswitch/patchwork-providers\";\nimport { useSidebarState, useSidebarResize, useMainDocMounted, useDebugRegistryToast, DebugRegistryToast, SIDEBAR_KEYS, COLLAPSE_CONTEXT_SIDEBAR_EVENT, getStoredNumber, getStoredBoolean, DEFAULT_SIDEBAR_WIDTH } from \"./hooks\";\nimport { Sidebar } from \"./components/Sidebar\";\nimport { SidebarWidgets } from \"./components/SidebarWidgets\";\nimport { DocumentAreaRoot } from \"./components/DocumentAreaRoot\";\nimport { IsolatedDocumentArea } from \"./components/IsolatedDocumentArea\";\nimport { MainDocumentView } from \"./components/MainDocumentView\";\nimport { Tray } from \"./components/Tray\";\nimport { createEffect, createMemo, createSignal, onCleanup, onMount, Show } from \"solid-js\";\nimport { render } from \"solid-js/web\";\nimport { ensureThreepaneConfig } from \"./account/ensureThreepaneConfig\";\nimport { seedExampleDocuments } from \"./account/seedExampleDocuments\";\nimport { ensureFrameStyles } from \"./ensureFrameStyles\";\nconst MIN_SIDEBAR_WIDTH = 180;\nconst MAX_SIDEBAR_WIDTH = 720;\nconst AUTO_CLOSE_WIDTH = 120;\nconst DRAG_THRESHOLD = 3;\nconst useFrameProviderReady = (componentId, element) => {\n const [isReady, setReady] = createSignal(false);\n createEffect(() => {\n const el = element();\n if (!el) return;\n setReady(false);\n const onMounted = event => {\n const detail = event.detail;\n if (detail?.componentId !== componentId) return;\n setReady(true);\n };\n el.addEventListener(\"patchwork:mounted\", onMounted);\n onCleanup(() => el.removeEventListener(\"patchwork:mounted\", onMounted));\n });\n return isReady;\n};\nfunction dispatchOpen(el, detail) {\n el.dispatchEvent(new CustomEvent(\"patchwork:open-document\", {\n detail,\n bubbles: true,\n composed: true\n }));\n}\nexport function PatchworkFrame({\n handle,\n repo,\n ...props\n}) {\n ensureFrameStyles();\n const accountDocUrl = handle.url;\n const [accountProviderElement, setAccountProviderElement] = createSignal();\n const isAccountProviderReady = useFrameProviderReady(\"patchwork-account-provider\", accountProviderElement);\n const [toolStorageProviderElement, setToolStorageProviderElement] = createSignal();\n const isToolStorageProviderReady = useFrameProviderReady(\"patchwork-tool-storage-provider\", toolStorageProviderElement);\n const [selectedDocProviderElement, setSelectedDocProviderElement] = createSignal();\n const isSelectedDocProviderReady = useFrameProviderReady(\"patchwork-selected-doc-provider\", selectedDocProviderElement);\n const areProvidersReady = createMemo(() => isSelectedDocProviderReady() && isAccountProviderReady() && isToolStorageProviderReady());\n return (() => {\n var _el$ = _tmpl$(),\n _el$2 = _el$.firstChild,\n _el$3 = _el$2.firstChild,\n _el$4 = _el$2.nextSibling,\n _el$5 = _el$4.firstChild,\n _el$6 = _el$5.firstChild,\n _el$7 = _el$6.firstChild;\n _$insert(_el$2, _$createComponent(Show, {\n get when() {\n return props.isolation;\n },\n get children() {\n return [\" \", \"isolation is highly experimental. if things are broken, switch back to wild west.\"];\n }\n }), null);\n _$use(setSelectedDocProviderElement, _el$5);\n _el$5._$owner = _$getOwner();\n _$use(setAccountProviderElement, _el$6);\n _el$6.docUrl = accountDocUrl;\n _el$6._$owner = _$getOwner();\n _$use(setToolStorageProviderElement, _el$7);\n _el$7.docUrl = accountDocUrl;\n _el$7._$owner = _$getOwner();\n _$insert(_el$7, _$createComponent(Show, {\n get when() {\n return areProvidersReady();\n },\n get children() {\n return _$createComponent(PatchworkFrameInner, {\n handle: handle,\n repo: repo,\n get isolation() {\n return props.isolation;\n }\n });\n }\n }));\n return _el$;\n })();\n}\nfunction PatchworkFrameInner(props) {\n const accountDocHandle = useDocHandle(() => props.handle.url, {\n repo: props.repo\n });\n void (async () => {\n await ensureThreepaneConfig(props.handle, props.repo);\n await seedExampleDocuments(props.handle, props.repo);\n })().catch(err => {\n console.error(\"frame: account bootstrap failed\", err);\n });\n const [docVersion, setDocVersion] = createSignal(0);\n createEffect(() => {\n const h = accountDocHandle();\n if (!h) return;\n const onChange = () => setDocVersion(v => v + 1);\n h.on(\"change\", onChange);\n onCleanup(() => h.off(\"change\", onChange));\n });\n const accountDoc = createMemo(() => {\n docVersion();\n return accountDocHandle()?.doc();\n });\n const accountDocUrl = props.handle.url;\n const threepaneUrl = () => accountDoc()?.tools?.[\"threepane\"];\n const threepaneConfigHandle = useDocHandle(() => threepaneUrl(), {\n repo: props.repo\n });\n const [threepaneVersion, setThreepaneVersion] = createSignal(0);\n createEffect(() => {\n const h = threepaneConfigHandle();\n if (!h) return;\n const onChange = () => setThreepaneVersion(v => v + 1);\n h.on(\"change\", onChange);\n onCleanup(() => h.off(\"change\", onChange));\n });\n const threepaneConfig = createMemo(() => {\n threepaneVersion();\n return threepaneConfigHandle()?.doc();\n });\n const doctitleSlots = () => threepaneConfig()?.doctitle?.tools;\n const sidebarWidgets = () => threepaneConfig()?.sidebar?.widgets ?? [];\n const traySlots = () => threepaneConfig()?.tray ?? [];\n const rootFolderUrl = () => accountDoc()?.rootFolderUrl;\n const sidebarState = useSidebarState();\n const sidebarResize = useSidebarResize({\n setLeftSidebarWidth: sidebarState.setLeftSidebarWidth,\n setRightSidebarWidth: sidebarState.setRightSidebarWidth,\n setIsSidebarCollapsed: sidebarState.setIsSidebarCollapsed,\n setIsRightSidebarCollapsed: sidebarState.setIsRightSidebarCollapsed,\n isLeftCollapsed: sidebarState.isSidebarCollapsed,\n isRightCollapsed: sidebarState.isRightSidebarCollapsed,\n minWidth: MIN_SIDEBAR_WIDTH,\n maxWidth: MAX_SIDEBAR_WIDTH,\n autoCloseWidth: AUTO_CLOSE_WIDTH,\n dragThreshold: DRAG_THRESHOLD\n });\n const {\n events: debugEvents,\n dismissEvent,\n clearAll\n } = useDebugRegistryToast();\n let element;\n const [selectedView, setSelectedView] = createSignal(null);\n const [popoverView, setPopoverView] = createSignal(null);\n onMount(() => {\n const unsubscribeSelectedView = subscribe(element, {\n type: \"patchwork:selected-view\"\n }, view => setSelectedView(view));\n onCleanup(unsubscribeSelectedView);\n });\n const selectedDocUrl = () => selectedView()?.url;\n const selectedToolId = () => selectedView()?.toolId ?? void 0;\n const initialRightWidth = () => getStoredNumber(SIDEBAR_KEYS.rightWidth, DEFAULT_SIDEBAR_WIDTH);\n const initialRightCollapsed = () => getStoredBoolean(SIDEBAR_KEYS.rightCollapsed);\n const [mainDocElement, setMainDocElement] = createSignal();\n const isMainDocMounted = useMainDocMounted(mainDocElement, selectedDocUrl);\n const [widgetsReady, setWidgetsReady] = createSignal(false);\n createEffect(() => {\n if (widgetsReady()) return;\n if (props.isolation || !selectedDocUrl() || isMainDocMounted()) setWidgetsReady(true);\n });\n return (() => {\n var _el$8 = _tmpl$2();\n var _ref$ = element;\n typeof _ref$ === \"function\" ? _$use(_ref$, _el$8) : element = _el$8;\n _$insert(_el$8, _$createComponent(DebugRegistryToast, {\n get events() {\n return debugEvents();\n },\n onDismiss: dismissEvent,\n onClearAll: clearAll\n }), null);\n _$insert(_el$8, _$createComponent(FrameLayout, {\n accountDocUrl: accountDocUrl,\n sidebarState: sidebarState,\n sidebarResize: sidebarResize,\n sidebarWidgets: sidebarWidgets,\n traySlots: traySlots,\n configHandle: threepaneConfigHandle,\n rootFolderUrl: rootFolderUrl,\n widgetsReady: widgetsReady,\n contactUrl: () => accountDoc()?.contactUrl,\n moduleSettingsUrl: () => accountDoc()?.moduleSettingsUrl,\n get isolation() {\n return props.isolation;\n },\n onInterceptOpen: setPopoverView,\n get children() {\n return _$createComponent(Show, {\n get when() {\n return selectedDocUrl();\n },\n get fallback() {\n return (() => {\n var _el$9 = _tmpl$3();\n _$insert(_el$9, _$createComponent(MainDocumentView, {\n viewKey: selectedDocUrl,\n selectedDocUrl: selectedDocUrl,\n toolId: selectedToolId,\n ref: setMainDocElement\n }));\n return _el$9;\n })();\n },\n get children() {\n return _$createComponent(Show, {\n get when() {\n return props.isolation;\n },\n get fallback() {\n return _$createComponent(DocumentAreaRoot, {\n setMainDocElement: setMainDocElement,\n selectedDocUrl: selectedDocUrl,\n selectedToolId: selectedToolId,\n doctitleSlots: doctitleSlots,\n get isLeftCollapsed() {\n return sidebarState.isSidebarCollapsed;\n },\n initialRightWidth: initialRightWidth,\n initialRightCollapsed: initialRightCollapsed\n });\n },\n get children() {\n return _$createComponent(IsolatedDocumentArea, {\n get contactUrl() {\n return accountDoc()?.contactUrl;\n },\n selectedDocUrl: selectedDocUrl,\n selectedToolId: selectedToolId,\n doctitleSlots: doctitleSlots,\n get isLeftCollapsed() {\n return sidebarState.isSidebarCollapsed;\n },\n initialRightWidth: initialRightWidth,\n initialRightCollapsed: initialRightCollapsed\n });\n }\n });\n }\n });\n }\n }), null);\n _$insert(_el$8, _$createComponent(Show, {\n get when() {\n return popoverView();\n },\n children: view => _$createComponent(FramePopover, {\n get view() {\n return view();\n },\n onClose: () => setPopoverView(null)\n })\n }), null);\n return _el$8;\n })();\n}\nfunction FramePopover(props) {\n const [toolId, setToolId] = createSignal(props.view.toolId ?? void 0);\n createEffect(() => setToolId(props.view.toolId ?? void 0));\n let popoverEl;\n onMount(() => {\n const onKey = e => {\n if (e.key === \"Escape\") props.onClose();\n };\n window.addEventListener(\"keydown\", onKey);\n onCleanup(() => window.removeEventListener(\"keydown\", onKey));\n const el = popoverEl;\n if (!el) return;\n const onOpen = event => {\n const {\n url,\n toolId: nextToolId\n } = event.detail;\n if (!url) return;\n event.stopPropagation();\n setToolId(nextToolId ?? void 0);\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n return (() => {\n var _el$0 = _tmpl$4(),\n _el$1 = _el$0.firstChild,\n _el$10 = _el$1.firstChild,\n _el$11 = _el$10.firstChild,\n _el$12 = _el$10.nextSibling,\n _el$13 = _el$12.firstChild;\n _el$0.$$click = () => props.onClose();\n _el$1.$$click = e => e.stopPropagation();\n var _ref$2 = popoverEl;\n typeof _ref$2 === \"function\" ? _$use(_ref$2, _el$1) : popoverEl = _el$1;\n _el$11._$owner = _$getOwner();\n _el$13._$owner = _$getOwner();\n _$effect(_p$ => {\n var _v$ = props.view.url,\n _v$2 = props.view.url,\n _v$3 = toolId();\n _v$ !== _p$.e && (_el$11.docUrl = _p$.e = _v$);\n _v$2 !== _p$.t && (_el$13.docUrl = _p$.t = _v$2);\n _v$3 !== _p$.a && (_el$13.toolId = _p$.a = _v$3);\n return _p$;\n }, {\n e: undefined,\n t: undefined,\n a: undefined\n });\n return _el$0;\n })();\n}\nfunction FrameLayout(props) {\n const isCollapsed = props.sidebarState.isSidebarCollapsed;\n const hasTray = () => props.traySlots().length > 0;\n let footerEl;\n onMount(() => {\n if (!props.isolation || !footerEl) return;\n const el = footerEl;\n const onOpen = event => {\n const {\n url,\n toolId\n } = event.detail;\n if (!url) return;\n event.stopPropagation();\n props.onInterceptOpen?.({\n url,\n toolId: toolId ?? null\n });\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n let sidebarContentEl;\n createEffect(() => {\n if (props.sidebarState.isSidebarCollapsed()) return;\n const el = sidebarContentEl;\n if (!el) return;\n const onOpen = () => {\n if (el.getBoundingClientRect().width <= window.innerWidth * 0.75) return;\n props.sidebarState.setIsSidebarCollapsed(true);\n window.dispatchEvent(new CustomEvent(COLLAPSE_CONTEXT_SIDEBAR_EVENT));\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n return [(() => {\n var _el$14 = _tmpl$5();\n _el$14.$$click = () => props.sidebarState.setIsSidebarCollapsed(v => !v);\n _$insert(_el$14, _$createComponent(PanelLeftIcon, {}));\n _$effect(_p$ => {\n var _v$4 = isCollapsed() ? \"Show sidebar\" : \"Hide sidebar\",\n _v$5 = isCollapsed() ? \"Show sidebar\" : \"Hide sidebar\",\n _v$6 = !isCollapsed();\n _v$4 !== _p$.e && _$setAttribute(_el$14, \"title\", _p$.e = _v$4);\n _v$5 !== _p$.t && _$setAttribute(_el$14, \"aria-label\", _p$.t = _v$5);\n _v$6 !== _p$.a && _$setAttribute(_el$14, \"aria-pressed\", _p$.a = _v$6);\n return _p$;\n }, {\n e: undefined,\n t: undefined,\n a: undefined\n });\n return _el$14;\n })(), _$createComponent(Sidebar, {\n side: \"left\",\n isCollapsed: isCollapsed,\n get width() {\n return props.sidebarState.leftSidebarWidth;\n },\n get onMouseDown() {\n return props.sidebarResize.handleMouseDown;\n },\n get onToggleClick() {\n return props.sidebarResize.handleToggleClick;\n },\n get children() {\n var _el$15 = _tmpl$6(),\n _el$16 = _el$15.firstChild,\n _el$17 = _el$16.firstChild,\n _el$18 = _el$17.firstChild;\n var _ref$3 = sidebarContentEl;\n typeof _ref$3 === \"function\" ? _$use(_ref$3, _el$15) : sidebarContentEl = _el$15;\n _$insert(_el$15, _$createComponent(SidebarWidgets, {\n get widgets() {\n return props.sidebarWidgets;\n },\n get configHandle() {\n return props.configHandle;\n },\n get rootFolderUrl() {\n return props.rootFolderUrl;\n },\n get ready() {\n return props.widgetsReady;\n }\n }), _el$16);\n var _ref$4 = footerEl;\n typeof _ref$4 === \"function\" ? _$use(_ref$4, _el$16) : footerEl = _el$16;\n _$insert(_el$17, _$createComponent(Show, {\n get when() {\n return props.contactUrl();\n },\n children: contactUrl => (() => {\n var _el$20 = _tmpl$8(),\n _el$21 = _el$20.firstChild;\n _el$20.$$click = e => dispatchOpen(e.currentTarget, {\n url: props.accountDocUrl,\n toolId: \"account-picker\"\n });\n _el$21._$owner = _$getOwner();\n _$effect(() => _el$21.docUrl = contactUrl());\n return _el$20;\n })()\n }), _el$18);\n _$insert(_el$17, _$createComponent(Show, {\n get when() {\n return props.moduleSettingsUrl();\n },\n children: moduleSettingsUrl => (() => {\n var _el$22 = _tmpl$9();\n _el$22.$$click = e => dispatchOpen(e.currentTarget, {\n url: moduleSettingsUrl(),\n toolId: \"packages\"\n });\n return _el$22;\n })()\n }), _el$18);\n _el$18.$$click = e => dispatchOpen(e.currentTarget, {\n url: props.accountDocUrl,\n toolId: \"frame-configurator\"\n });\n _$effect(() => _el$15.classList.toggle(\"threepane-sidebar--has-tray\", !!hasTray()));\n return _el$15;\n }\n }), _$createComponent(Show, {\n get when() {\n return hasTray();\n },\n get children() {\n var _el$19 = _tmpl$7();\n _$insert(_el$19, _$createComponent(Tray, {\n get slots() {\n return props.traySlots;\n }\n }));\n _$effect(_p$ => {\n var _v$7 = !!isCollapsed(),\n _v$8 = `${props.sidebarState.leftSidebarWidth()}px`;\n _v$7 !== _p$.e && _el$19.classList.toggle(\"frame__tray-dock--collapsed\", _p$.e = _v$7);\n _v$8 !== _p$.t && _$setStyleProperty(_el$19, \"width\", _p$.t = _v$8);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$19;\n }\n }), _$memo(() => props.children)];\n}\nfunction PanelLeftIcon() {\n return _tmpl$0();\n}\nexport function renderPatchworkFrame(isolation) {\n return (handle, element) => {\n return render(() => _$createComponent(PatchworkFrame, {\n handle: handle,\n get repo() {\n return element.repo;\n },\n isolation: isolation\n }), element);\n };\n}\n_$delegateEvents([\"click\"]);", "import { parseAutomergeUrl, stringifyAutomergeUrl, } from \"@automerge/automerge-repo\";\nimport { forwardingProxy } from \"./forwarding-proxy.js\";\n// The only members whose behavior an overlay handle changes: the presented\n// identity, the identity-preserving `sub` (so sub-handle urls stay in the\n// presented space), the argument-unwrapping handle comparisons\n// (`merge`/`overlaps`/`contains`/`isChildOf`/`equals`), and the re-stamping\n// EventEmitter surface. Everything else (doc/change/heads/ref/view/diff/...)\n// forwards to the backing handle.\nconst OVERLAY_HANDLE_OWNED = new Set([\n \"url\",\n \"documentId\",\n \"backingHandle\",\n \"sub\",\n \"merge\",\n \"overlaps\",\n \"contains\",\n \"isChildOf\",\n \"equals\",\n \"on\",\n \"off\",\n \"once\",\n \"addListener\",\n \"removeListener\",\n \"removeAllListeners\",\n \"emit\",\n]);\n/**\n * A url-hiding proxy around a fixed backing `DocHandle`. `url`/`documentId`\n * always report the *presented* url; every other operation forwards to the\n * backing handle. Event subscriptions are tracked locally and the backing\n * handle's events are lazily forwarded with `payload.handle` re-stamped to this\n * wrapper, so consumers never observe the backing (clone) handle or its url.\n *\n * Unlike the copy-on-write handle it is modelled on, the backing never swaps:\n * remappers clone eagerly and hand back the clone up front, so there is no\n * COW, no re-wiring, and no synthetic change nudge.\n */\nexport class OverlayHandle {\n #originalUrl;\n #handle;\n #listeners = new Map();\n #forwarded = new Set();\n // Sub-handle wrappers keyed by their backing (canonicalised) url, so repeated\n // `sub(...)` of the same path return the same wrapper instance.\n #subCache = new Map();\n // The Proxy returned from the constructor \u2014 the object consumers actually\n // hold. Re-stamped onto forwarded events so identity stays consistent.\n #self;\n constructor(opts) {\n this.#originalUrl = opts.presentedUrl;\n this.#handle = opts.backing;\n this.#self = forwardingProxy(this, opts.backing, OVERLAY_HANDLE_OWNED);\n return this.#self;\n }\n get url() {\n return this.#originalUrl;\n }\n get documentId() {\n return parseAutomergeUrl(this.#originalUrl).documentId;\n }\n /** @internal The live handle this wrapper forwards to. */\n get backingHandle() {\n return this.#handle;\n }\n // Handle comparisons read the *other* handle's internals (Automerge rejects\n // a foreign wrapper, and `overlaps`/`contains` touch its private `#path`), so\n // unwrap an overlay argument down to its backing before delegating.\n merge(other) {\n this.#handle.merge(unwrapHandle(other));\n }\n overlaps(other) {\n return this.#handle.overlaps(unwrapHandle(other));\n }\n contains(other) {\n return this.#handle.contains(unwrapHandle(other));\n }\n isChildOf(other) {\n return this.#handle.isChildOf(unwrapHandle(other));\n }\n equals(other) {\n return this.#handle.equals(unwrapHandle(other));\n }\n // Sub-handles must keep reporting urls in the *presented* space; otherwise a\n // ref or cursor produced here (a comment target, a selection cursor, ...)\n // would leak the backing (clone) documentId and break identity for consumers\n // that resolve it back through the overlay. We scope `sub` to the backing\n // handle (reads/writes still hit the clone) but wrap the result in another\n // OverlayHandle whose presented url swaps the documentId back to ours. The\n // backing sub-handle is canonicalised by the repo, so caching by its url\n // keeps our wrappers referentially stable too.\n sub(...segments) {\n const backingSub = this.#handle.sub(...segments);\n const cached = this.#subCache.get(backingSub.url);\n if (cached)\n return cached;\n const wrapped = new OverlayHandle({\n presentedUrl: restampUrl(this.#originalUrl, backingSub.url),\n backing: backingSub,\n });\n this.#subCache.set(backingSub.url, wrapped);\n return wrapped;\n }\n on(ev, fn) {\n this.#forward(ev);\n let set = this.#listeners.get(ev);\n if (!set) {\n set = new Set();\n this.#listeners.set(ev, set);\n }\n set.add(fn);\n return this.#self;\n }\n off(ev, fn) {\n this.#listeners.get(ev)?.delete(fn);\n return this.#self;\n }\n once(ev, fn) {\n const wrapper = (...args) => {\n this.off(ev, wrapper);\n fn(...args);\n };\n return this.on(ev, wrapper);\n }\n addListener(ev, fn) {\n return this.on(ev, fn);\n }\n removeListener(ev, fn) {\n return this.off(ev, fn);\n }\n removeAllListeners(ev) {\n if (ev)\n this.#listeners.get(ev)?.clear();\n else\n this.#listeners.clear();\n return this.#self;\n }\n emit(ev, ...args) {\n const set = this.#listeners.get(ev);\n if (!set || set.size === 0)\n return false;\n for (const fn of [...set])\n fn(...args);\n return true;\n }\n // Lazily forward a backing event the first time someone subscribes to it,\n // re-stamping `payload.handle = this wrapper` so consumers see the wrapper\n // rather than the backing handle as the event source.\n #forward(ev) {\n if (this.#forwarded.has(ev))\n return;\n this.#forwarded.add(ev);\n this.#handle.on(ev, (payload) => {\n if (payload &&\n typeof payload === \"object\" &&\n \"handle\" in payload) {\n this.emit(ev, { ...payload, handle: this.#self });\n }\n else {\n this.emit(ev, payload);\n }\n });\n }\n}\n// Unwrap an overlay wrapper down to its backing handle (Automerge rejects a\n// foreign wrapper, and comparisons touch the backing's private fields). Plain\n// handles pass through untouched.\nfunction unwrapHandle(handle) {\n return handle instanceof OverlayHandle\n ? handle.backingHandle\n : handle;\n}\n// Re-stamp a backing (clone) handle url into the presented space: keep the\n// path segments and any pinned heads, but swap the documentId back to the\n// presented root's. Mirrors the original->clone mapping in OverlayRepo#resolve.\nfunction restampUrl(presentedRoot, backingUrl) {\n const { documentId } = parseAutomergeUrl(presentedRoot);\n const { segments, heads } = parseAutomergeUrl(backingUrl);\n return stringifyAutomergeUrl({ documentId, segments, heads });\n}\n", "import { interpretAsDocumentId, isValidAutomergeUrl, parseAutomergeUrl, stringifyAutomergeUrl, } from \"@automerge/automerge-repo\";\nimport { request } from \"./index.js\";\nimport { forwardingProxy } from \"./forwarding-proxy.js\";\nimport { OverlayHandle } from \"./overlay-handle.js\";\n// The only members whose behavior an overlay repo changes; everything else\n// (create/create2/clone/delete, the EventEmitter surface, ...) forwards to the\n// realm-local base repo.\nconst OVERLAY_REPO_OWNED = new Set([\n \"baseRepo\",\n \"handles\",\n \"find\",\n \"findWithProgress\",\n \"create\",\n \"create2\",\n]);\n/**\n * A realm-local {@link RepoLike} shim that makes document resolution\n * remappable across provider scopes (including iframes) without sending a live\n * `Repo`/`DocHandle` over the wire.\n *\n * `find`/`findWithProgress` dispatch a `repo:handle-descriptor` subscription for\n * the requested url and resolve the returned `cloneUrl ?? url` against the\n * realm-local `baseRepo`, then hand back an {@link OverlayHandle} that keeps\n * reporting the *original* url. Every other method (`create`, `create2`,\n * `clone`, `delete`, the EventEmitter surface, ...) forwards to `baseRepo`\n * unchanged \u2014 created docs need no remapping.\n */\nexport class OverlayRepo {\n /** The realm-local repo all resolution ultimately bottoms out in. */\n baseRepo;\n #element;\n // Keyed by the *presented* url (documentId + path + heads), not just the\n // documentId, so distinct sub-document paths under the same root document\n // don't collide.\n #wrapped = new Map();\n #inner = new Map();\n #resolving = new Map();\n constructor(baseRepo, element) {\n this.baseRepo = baseRepo;\n this.#element = element;\n // Forward everything but resolution to the realm-local repo.\n return forwardingProxy(this, baseRepo, OVERLAY_REPO_OWNED);\n }\n // Only already-wrapped handles are exposed; unknown ids fall through to\n // `find`/`findWithProgress` so consumers never see an un-wrapped handle.\n // `#wrapped` is keyed by presented url, so derive the documentId from each\n // handle; sub-handles of the same root collapse onto a single entry (the\n // `Record<DocumentId, ...>` shape can't represent paths).\n get handles() {\n const out = {};\n for (const wrapped of this.#wrapped.values()) {\n out[wrapped.documentId] = wrapped;\n }\n return out;\n }\n async find(id) {\n const presented = presentedUrlOf(id);\n const cached = this.#wrapped.get(presented);\n if (cached)\n return cached;\n const wrapped = await this.#resolve(presented);\n return wrapped;\n }\n // Mirrors the realm-local repo's progress but reports `loading` until the\n // descriptor has arrived and the backing handle is wrapped \u2014 otherwise\n // consumers would briefly observe the un-wrapped (un-remapped) handle.\n findWithProgress(id) {\n const self = this;\n const presented = presentedUrlOf(id);\n // The reported `documentId` is the root id \u2014 `DocumentId` can't encode a\n // path \u2014 but caches are keyed by the full presented url.\n const documentId = parseAutomergeUrl(presented).documentId;\n const wrappedPromise = this.#resolve(presented);\n wrappedPromise.catch(() => { });\n const peek = () => {\n const inner = self.#inner.get(presented);\n if (!inner)\n return { state: \"loading\", sources: {} };\n const innerState = inner.peek();\n if (innerState.state !== \"ready\")\n return innerState;\n const wrapped = self.#wrapped.get(presented);\n if (!wrapped) {\n return { state: \"loading\", sources: innerState.sources };\n }\n return {\n state: \"ready\",\n handle: wrapped,\n sources: innerState.sources,\n };\n };\n return {\n documentId,\n peek,\n subscribe: (callback) => {\n let last = null;\n let unsubscribeInner = () => { };\n const dispatch = () => {\n const state = peek();\n const sig = state.state === \"failed\"\n ? `failed:${state.error.message}`\n : state.state;\n if (sig === last)\n return;\n last = sig;\n callback(state);\n };\n wrappedPromise.then(() => {\n const inner = self.#inner.get(presented);\n if (inner)\n unsubscribeInner = inner.subscribe(dispatch);\n dispatch();\n }, dispatch);\n return () => unsubscribeInner();\n },\n whenReady: ({ signal } = {}) => {\n const handlePromise = wrappedPromise;\n if (signal?.aborted)\n return Promise.reject(signal.reason);\n if (!signal)\n return handlePromise;\n return new Promise((resolve, reject) => {\n const onAbort = () => reject(signal.reason);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n handlePromise.then((handle) => {\n signal.removeEventListener(\"abort\", onAbort);\n resolve(handle);\n }, (err) => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(err);\n });\n });\n },\n // Deprecated; kept for pre-`peek()` consumers.\n get state() {\n return peek().state;\n },\n get progress() {\n return self.#inner.get(presented)?.progress;\n },\n get error() {\n const s = peek();\n return s.state === \"failed\" ? s.error : undefined;\n },\n };\n }\n // Plain local creates need no remapping; declared (rather than forwarded) so\n // the class still satisfies `RepoLike`.\n create(initialValue) {\n return this.baseRepo.create(initialValue);\n }\n create2(initialValue) {\n return this.baseRepo.create2(initialValue);\n }\n // De-dupes concurrent resolutions of the same presented url: the first\n // caller dispatches the subscription, everyone else awaits the same promise.\n #resolve(presented) {\n const existing = this.#resolving.get(presented);\n if (existing)\n return existing;\n const promise = (async () => {\n // The descriptor channel remaps whole documents, so ask about the root\n // and reapply the original path/heads onto whatever clone comes back.\n // The clone is a fork of the root, so the same sub-tree exists in it.\n const { documentId, segments, heads } = parseAutomergeUrl(presented);\n const rootUrl = stringifyAutomergeUrl({ documentId });\n const descriptor = await request(this.#element, {\n type: \"repo:handle-descriptor\",\n url: rootUrl,\n });\n const backingRoot = descriptor.cloneUrl ?? descriptor.url;\n const backingUrl = stringifyAutomergeUrl({\n documentId: parseAutomergeUrl(backingRoot).documentId,\n segments,\n heads,\n });\n const inner = this.baseRepo.findWithProgress(backingUrl);\n this.#inner.set(presented, inner);\n const backing = await this.baseRepo.find(backingUrl);\n const wrapped = new OverlayHandle({\n presentedUrl: presented,\n backing,\n });\n this.#wrapped.set(presented, wrapped);\n return wrapped;\n })();\n this.#resolving.set(presented, promise);\n return promise;\n }\n}\n// Canonicalize any id to its *presented* url, preserving the path suffix\n// (`/a/@0/b`) and any pinned heads so sub-document and view-scoped urls keep\n// their identity through the overlay. Plain document ids carry no path.\nfunction presentedUrlOf(id) {\n if (isValidAutomergeUrl(id)) {\n const { documentId, segments, heads } = parseAutomergeUrl(id);\n return stringifyAutomergeUrl({ documentId, segments, heads });\n }\n return stringifyAutomergeUrl({ documentId: interpretAsDocumentId(id) });\n}\n", "/**\n * Open a streaming subscription. Dispatches a `patchwork:subscribe` for the\n * given `selector` carrying a fresh `MessageChannel` port; the answering\n * provider pushes values back over that channel for as long as the\n * subscription is live. `listener` is invoked once per emission (the first\n * delivery is always async because `MessagePort.postMessage` queues a task).\n *\n * The event is dispatched from the nearest enclosing `<patchwork-view>` so\n * callers can pass any node inside a provider subtree. An unclaimed\n * subscription is never settled: if no provider answers, `listener` simply\n * never fires.\n *\n * Returns an unsubscribe function. Calling it tells the provider to tear down\n * (via an `unsubscribe` message) and closes the consumer's port; any values\n * the provider emits after that are dropped.\n */\nexport function subscribe(element, selector, listener) {\n const view = element.closest(\"patchwork-view\");\n const dispatchEl = view ?? element;\n const channel = new MessageChannel();\n const port = channel.port2;\n const controller = new AbortController();\n const { signal } = controller;\n port.addEventListener(\"message\", (event) => {\n if (event.data?.type === \"change\")\n listener(event.data.value);\n }, { signal });\n // addEventListener (unlike assigning onmessage) does not implicitly start\n // the port, so message delivery has to be kicked off explicitly.\n port.start();\n const detail = {\n selector,\n port: channel.port1,\n };\n dispatchEl.dispatchEvent(new CustomEvent(\"patchwork:subscribe\", {\n detail,\n bubbles: true,\n composed: true,\n }));\n return () => {\n if (signal.aborted)\n return;\n controller.abort();\n port.postMessage({ type: \"unsubscribe\" });\n port.close();\n };\n}\n/**\n * Answer a `patchwork:subscribe`. The `producer` receives a `respond`\n * callback it can call any number of times to push values to the consumer,\n * and may return a teardown that runs when the consumer unsubscribes. Stops\n * propagation so ancestor providers don't double-answer. Values emitted after\n * the consumer unsubscribes are dropped.\n */\nexport function accept(event, producer) {\n event.stopPropagation();\n const port = event.detail.port;\n let alive = true;\n const respond = (value) => {\n if (!alive)\n return;\n port.postMessage({ type: \"change\", value });\n };\n let teardown;\n try {\n teardown = producer(respond);\n }\n catch (err) {\n console.error(\"[patchwork-providers] subscribe producer threw:\", err);\n }\n const stop = () => {\n if (!alive)\n return;\n alive = false;\n try {\n teardown?.();\n }\n catch (err) {\n console.error(\"[patchwork-providers] subscribe teardown threw:\", err);\n }\n port.close();\n };\n port.onmessage = (event) => {\n if (event.data?.type === \"unsubscribe\")\n stop();\n };\n}\n/**\n * One-shot convenience wrapper over {@link subscribe}: opens a subscription\n * for `selector`, resolves with the first value a provider emits, then\n * immediately unsubscribes. Because there is no fallback provider, an\n * unclaimed selector never resolves \u2014 use `subscribe` directly if you need to\n * handle the \"no provider\" case.\n */\nexport function request(element, selector) {\n return new Promise((resolve) => {\n const unsubscribe = subscribe(element, selector, (value) => {\n // The first emission is always async (postMessage queues a task), so\n // `unsubscribe` is assigned by the time this fires.\n unsubscribe();\n resolve(value);\n });\n });\n}\nexport { registerRepoProviderElement, } from \"./repo-provider.js\";\nexport { OverlayHandle } from \"./overlay-handle.js\";\nexport { OverlayRepo } from \"./overlay-repo.js\";\n", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=threepane-widgets>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=threepane-widgets__empty><button type=button class=threepane-widgets__add>\uFF0B Add document list`),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=threepane-widget>`);\nimport { For, Show } from \"solid-js\";\nimport { SlotView } from \"./SlotView\";\nconst DOCUMENT_LIST_TOOL = \"chee/document-list\";\nexport function SidebarWidgets(props) {\n const addDocumentList = () => {\n const root = props.rootFolderUrl();\n const handle = props.configHandle();\n if (!root || !handle) return;\n handle.change(doc => {\n doc.sidebar.widgets.push([DOCUMENT_LIST_TOOL, root]);\n });\n };\n return (() => {\n var _el$ = _tmpl$();\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return props.ready();\n },\n get children() {\n return _$createComponent(Show, {\n get when() {\n return props.widgets().length;\n },\n get fallback() {\n return (// While the config/root folder are still loading we can't add a\n // widget yet \u2014 show nothing rather than a disabled button.\n _$createComponent(Show, {\n get when() {\n return _$memo(() => !!props.rootFolderUrl())() && props.configHandle();\n },\n get children() {\n var _el$2 = _tmpl$2(),\n _el$3 = _el$2.firstChild;\n _el$3.$$click = addDocumentList;\n return _el$2;\n }\n })\n );\n },\n get children() {\n return _$createComponent(For, {\n get each() {\n return props.widgets();\n },\n children: widget => (() => {\n var _el$4 = _tmpl$3();\n _$insert(_el$4, _$createComponent(SlotView, {\n slot: widget\n }));\n return _el$4;\n })()\n });\n }\n });\n }\n }));\n return _el$;\n })();\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=frame-tray>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=frame-tray__item>`);\nimport { For, Show } from \"solid-js\";\nimport { SlotView, slotId } from \"./SlotView\";\nexport function Tray(props) {\n return _$createComponent(Show, {\n get when() {\n return props.slots().length;\n },\n get children() {\n var _el$ = _tmpl$();\n _$insert(_el$, _$createComponent(For, {\n get each() {\n return props.slots();\n },\n children: slot => (() => {\n var _el$2 = _tmpl$2();\n _$insert(_el$2, _$createComponent(SlotView, {\n slot: slot\n }));\n _$effect(() => _$setAttribute(_el$2, \"data-tray-id\", slotId(slot)));\n return _el$2;\n })()\n }));\n return _el$;\n }\n });\n}", "import type { AutomergeUrl, DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\nimport { createDocOfDatatype2 } from \"@inkandswitch/patchwork-plugins\";\nimport type { AccountDoc, ThreepaneConfigDoc, ToolRef, ToolSlot } from \"../types\";\nimport { DEFAULT_DOCTITLE_TOOLS, DEFAULT_TRAY_TOOLS } from \"../datatypes\";\nimport { loadDatatypeWhenReady } from \"./loadDatatypeWhenReady\";\n\n// Title + spacer are intrinsic to the frame's top bar, never configured tools.\nconst INTRINSIC_DOCTITLE_TOOLS = new Set([\"document-title\", \"spacer\"]);\n\n// The sidebar's default widget: a document list pinned to the account's root\n// folder. Every account gets one so the left pane is never empty.\nconst DOCUMENT_LIST_TOOL = \"chee/document-list\";\n\n/** The default sidebar widgets for a fresh (or empty) account. */\nfunction defaultSidebarWidgets(rootFolderUrl?: AutomergeUrl): ToolRef[] {\n return rootFolderUrl ? [[DOCUMENT_LIST_TOOL, rootFolderUrl]] : [];\n}\n\n/**\n * Lazily create the threepane layout config doc and point `account.tools.threepane`\n * at it, migrating the legacy `account.documentToolbarToolIds` into its\n * `doctitle` lane. The context sidebar is host chrome and still registry-driven\n * (every `patchwork:component` tagged `\"context-tool\"`); the system tray is now\n * an explicit `tray` list here, seeded with `DEFAULT_TRAY_TOOLS` (and backfilled\n * for configs created before the field existed).\n *\n * Seeds the sidebar with a default document-list widget (pinned to the account's\n * root folder), so the left pane is never empty.\n *\n * Non-destructive: the old `documentToolbarToolIds` / `accountSidebarToolId`\n * fields are left untouched so older builds keep working and you can switch\n * branches freely during the PR. Run the (separate, opt-in)\n * cleanupLegacyAccountFields script to remove them later.\n */\nexport async function ensureThreepaneConfig(\n accountHandle: DocHandle<AccountDoc>,\n repo: Repo\n) {\n const rootFolderUrl = accountHandle.doc()?.rootFolderUrl;\n const existingConfigUrl = accountHandle.doc()?.tools?.[\"threepane\"];\n\n // Already migrated. Backfill the default document-list widget for early\n // builds of this branch that seeded an empty sidebar.\n if (existingConfigUrl) {\n const configHandle = await repo.find<ThreepaneConfigDoc>(existingConfigUrl);\n configHandle.change((doc) => {\n if (rootFolderUrl && !doc.sidebar?.widgets?.length) {\n doc.sidebar.widgets = defaultSidebarWidgets(rootFolderUrl);\n }\n // Backfill the tray for configs created before it moved out of the\n // registry onto this doc, so existing accounts keep their system tray.\n if (!doc.tray) {\n doc.tray = DEFAULT_TRAY_TOOLS.slice();\n }\n // An account whose doctitle lane ended up empty (nothing to migrate from\n // the legacy field) gets the defaults rather than a bare top bar.\n if (!doc.doctitle?.tools?.length) {\n doc.doctitle = { ...doc.doctitle, tools: DEFAULT_DOCTITLE_TOOLS.slice() };\n }\n });\n return;\n }\n\n const datatype = await loadDatatypeWhenReady<ThreepaneConfigDoc>(\n \"threepane:config\"\n );\n if (!datatype) {\n console.warn(\"frame: threepane:config datatype never registered\");\n return;\n }\n\n // Re-check after the await in case another tab migrated concurrently.\n if (accountHandle.doc()?.tools?.[\"threepane\"]) return;\n\n const account = accountHandle.doc();\n\n // doctitle tools migrate as bare ids: the frame always points them at the\n // selected main-view doc, so a slot tuple's docid would be ignored \u2014 keep\n // them as plain strings.\n const doctitleTools: ToolSlot[] = (account?.documentToolbarToolIds ?? [])\n .filter((id) => !INTRINSIC_DOCTITLE_TOOLS.has(id));\n\n const configHandle = await createDocOfDatatype2<ThreepaneConfigDoc>(\n datatype,\n repo\n );\n configHandle.change((doc) => {\n if (doctitleTools.length) doc.doctitle.tools = doctitleTools;\n doc.sidebar.widgets = defaultSidebarWidgets(account?.rootFolderUrl);\n if (!doc.tray) doc.tray = DEFAULT_TRAY_TOOLS.slice();\n });\n\n accountHandle.change((acc) => {\n if (!acc.tools) acc.tools = {};\n if (!acc.tools[\"threepane\"]) acc.tools[\"threepane\"] = configHandle.url;\n });\n}\n", "import {\n getRegistry,\n type DatatypeDescription,\n type LoadedDatatype,\n} from \"@inkandswitch/patchwork-plugins\";\n\nexport function loadDatatypeWhenReady<D>(\n id: string\n): Promise<LoadedDatatype<D>> {\n return getRegistry<DatatypeDescription>(\n \"patchwork:datatype\"\n ).loadWhenReady(id) as Promise<LoadedDatatype<D>>;\n}\n", "import debug from \"debug\";\nimport type { DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\nimport { createDocOfDatatype2 } from \"@inkandswitch/patchwork-plugins\";\nimport type { FolderDoc } from \"@inkandswitch/patchwork-filesystem\";\nimport type { AccountDoc } from \"../types\";\nimport { loadDatatypeWhenReady } from \"./loadDatatypeWhenReady\";\nimport { seedGaiosExamples } from \"./gaiosExamples\";\n\nconst log = debug(\"patchwork:threepane:examples\");\n\n/**\n * Seed a fresh account with example documents by running each static module\n * bundle's generated `init.js` (emitted by that repo's scripts/bundle.mjs next\n * to its modules.json). Every init script receives the same Examples folder\n * handle, so multiple bundles merge their examples into one folder.\n *\n * Runs at most once per account: the account doc's `exampleDocsSeededAt`\n * marker is claimed *before* seeding (a race between two tabs can at worst\n * skip the examples, never duplicate them), and a deleted Examples folder is\n * never recreated. Accounts that already have documents get the marker but no\n * examples \u2014 only truly fresh accounts are seeded.\n */\nexport async function seedExampleDocuments(\n accountHandle: DocHandle<AccountDoc>,\n repo: Repo\n) {\n const account = accountHandle.doc();\n if (!account?.rootFolderUrl) {\n log(\"skipped \u2014 account has no rootFolderUrl\");\n return;\n }\n if (account.exampleDocsSeededAt) {\n log(\n \"skipped \u2014 already ran for this account at\",\n new Date(account.exampleDocsSeededAt).toISOString()\n );\n return;\n }\n\n log(\"claiming marker on account\", accountHandle.url);\n accountHandle.change((doc) => {\n if (!doc.exampleDocsSeededAt) doc.exampleDocsSeededAt = Date.now();\n });\n\n const rootFolder = await repo.find<FolderDoc>(account.rootFolderUrl);\n const existingDocs = rootFolder.doc()?.docs?.length ?? 0;\n if (existingDocs) {\n log(\n `skipped \u2014 root folder already has ${existingDocs} doc(s); only fresh accounts are seeded`\n );\n return;\n }\n\n const gaios = window.location.hostname.includes(\"gaios\");\n const initUrls = gaios ? [] : await bundleInitScriptUrls();\n log(gaios ? \"gaios examples\" : \"bundle init scripts:\", initUrls);\n if (!gaios && !initUrls.length) {\n log(\"skipped \u2014 no static module bundles to ask\");\n return;\n }\n\n const folderDatatype = await loadDatatypeWhenReady<FolderDoc>(\"folder\");\n if (!folderDatatype) {\n log(\"folder datatype never registered; giving up\");\n return;\n }\n const folder = await createDocOfDatatype2<FolderDoc>(\n folderDatatype,\n repo,\n (doc) => {\n doc.title = \"Examples\";\n }\n );\n\n if (gaios) await seedGaiosExamples(repo, folder);\n\n for (const url of initUrls) {\n try {\n const mod = await import(/* @vite-ignore */ url);\n await mod.default?.(repo, folder);\n log(\"ran init script\", url);\n } catch (err) {\n // A bundle that ships no init script 404s here \u2014 normal, not an error.\n log(\"init script unavailable or failed\", url, err);\n }\n }\n\n const seeded = folder.doc()?.docs?.length ?? 0;\n if (!seeded) {\n // Don't leave an empty Examples folder if no bundle contributed anything.\n log(\"no bundle contributed any documents\");\n return;\n }\n\n rootFolder.change((doc) => {\n doc.docs.unshift({ name: \"Examples\", type: \"folder\", url: folder.url });\n });\n log(`seeded ${seeded} document(s) into Examples folder`, folder.url);\n}\n\ntype ModuleWatcherLike = {\n urls?: Record<string, string>;\n doneLoading?: Promise<void>;\n};\n\n/**\n * The patchwork-tools bundle isn't in every site's default module sources\n * (some boot from an automerge module-settings doc, which has no init.js),\n * but its examples should seed everywhere \u2014 so it's always consulted.\n */\nconst TOOLS_BUNDLE_INIT_URL = \"https://patchwork-tools.netlify.app/init.js\";\n\n/**\n * Fallback for shells with no static manifest at all (automerge-doc module\n * sources only): the deployed patchwork-base bundle. Not consulted when any\n * static manifest is configured, because that manifest is usually a copy of\n * this very bundle (e.g. a localhost dev serve) and URL-dedupe can't tell \u2014\n * always adding it would seed base's examples twice.\n */\nconst BASE_BUNDLE_INIT_URL = \"https://patchwork-base.netlify.app/init.js\";\n\n/**\n * The `init.js` URL next to every static (http) module manifest the host is\n * watching, plus the hardcoded bundles above. Automerge module-settings docs\n * have no init script. Waits for the watcher's initial load so the bundles'\n * plugins are registered before any example runs.\n */\nasync function bundleInitScriptUrls(): Promise<string[]> {\n const watcher = (\n window as { patchwork?: { packages?: ModuleWatcherLike } }\n ).patchwork?.packages;\n if (!watcher?.urls) return [BASE_BUNDLE_INIT_URL, TOOLS_BUNDLE_INIT_URL];\n await watcher.doneLoading;\n const fromManifests = Object.values(watcher.urls)\n .filter((url) => typeof url === \"string\" && !url.startsWith(\"automerge:\"))\n .map((url) => new URL(\"init.js\", new URL(url, document.baseURI)).href);\n const base = fromManifests.length ? [] : [BASE_BUNDLE_INIT_URL];\n return [...new Set([...fromManifests, ...base, TOOLS_BUNDLE_INIT_URL])];\n}\n", "import type { DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\nimport type { FolderDoc } from \"@inkandswitch/patchwork-filesystem\";\n\n/**\n * Examples for gaios deployments, seeded in place of the module bundles'\n * generated init scripts. Each entry is built inline (no plugin registry), so\n * a datatype that isn't installed here still gets a well-formed document.\n */\nexport async function seedGaiosExamples(\n repo: Repo,\n folder: DocHandle<FolderDoc>\n) {\n for (const example of EXAMPLES) {\n const handle = await repo.create2(example.doc);\n folder.change((doc) => {\n doc.docs.push({\n name: example.name,\n type: example.doc[\"@patchwork\"].type,\n url: handle.url,\n });\n });\n }\n}\n\nconst SEIRV = {\n \"@patchwork\": {\n title: \"SEIRV\",\n type: \"catcolab-model\",\n },\n analysisDocUrl: \"automerge:qJJEiMQo21VwaLToRtYENuYSuTC\",\n name: \"SEIRV\",\n notebook: {\n cellContents: {\n \"0194d7a9-bc26-73ac-b2b8-73470cb412ae\": {\n content: {\n id: \"0194d7a9-bc26-73ac-b2b8-6eb9a514827b\",\n name: \"Susceptible\",\n obType: { content: \"Object\", tag: \"Basic\" },\n tag: \"object\",\n },\n id: \"0194d7a9-bc26-73ac-b2b8-73470cb412ae\",\n tag: \"formal\",\n },\n \"0194d7a9-bf28-709f-b34d-545928dd7c16\": {\n content: {\n id: \"0194d7a9-bf28-709f-b34d-513c3da75e9c\",\n name: \"Infectious\",\n obType: { content: \"Object\", tag: \"Basic\" },\n tag: \"object\",\n },\n id: \"0194d7a9-bf28-709f-b34d-545928dd7c16\",\n tag: \"formal\",\n },\n \"0194d7a9-c036-745b-99e2-b3ef2d3b87d0\": {\n content: {\n id: \"0194d7a9-c036-745b-99e2-aedb526915c7\",\n name: \"Recovered\",\n obType: { content: \"Object\", tag: \"Basic\" },\n tag: \"object\",\n },\n id: \"0194d7a9-c036-745b-99e2-b3ef2d3b87d0\",\n tag: \"formal\",\n },\n \"0194d7a9-d72e-700a-9c8b-7686fad4193b\": {\n content: {\n cod: { content: \"0194fc13-3da9-77cb-b36a-9b8a6a83f0e6\", tag: \"Basic\" },\n dom: { content: \"0194d7a9-bc26-73ac-b2b8-6eb9a514827b\", tag: \"Basic\" },\n id: \"0194d7a9-d72e-700a-9c8b-703b753da038\",\n morType: {\n content: { content: \"Object\", tag: \"Basic\" },\n tag: \"Hom\",\n },\n name: \"exposure\",\n tag: \"morphism\",\n },\n id: \"0194d7a9-d72e-700a-9c8b-7686fad4193b\",\n tag: \"formal\",\n },\n \"0194d7a9-d8b5-741f-916f-d559d3ff2f8d\": {\n content: {\n cod: { content: \"0194d7a9-c036-745b-99e2-aedb526915c7\", tag: \"Basic\" },\n dom: { content: \"0194d7a9-bf28-709f-b34d-513c3da75e9c\", tag: \"Basic\" },\n id: \"0194d7a9-d8b5-741f-916f-d3dd802450ec\",\n morType: {\n content: { content: \"Object\", tag: \"Basic\" },\n tag: \"Hom\",\n },\n name: \"recovery\",\n tag: \"morphism\",\n },\n id: \"0194d7a9-d8b5-741f-916f-d559d3ff2f8d\",\n tag: \"formal\",\n },\n \"0194d7a9-f4ff-77df-80a5-75410f4b9680\": {\n content: {\n cod: {\n content: {\n content: \"0194d7a9-d72e-700a-9c8b-703b753da038\",\n tag: \"Basic\",\n },\n tag: \"Tabulated\",\n },\n dom: { content: \"0194d7a9-bf28-709f-b34d-513c3da75e9c\", tag: \"Basic\" },\n id: \"0194d7a9-f4ff-77df-80a5-70d50473ed6d\",\n morType: { content: \"Link\", tag: \"Basic\" },\n name: \"\",\n tag: \"morphism\",\n },\n id: \"0194d7a9-f4ff-77df-80a5-75410f4b9680\",\n tag: \"formal\",\n },\n \"0194d7c1-3b04-77cf-b2c1-e4e8a10712e2\": {\n content:\n \"This stock-flow diagram exhibits the standard SIR model from epidemiology augmented with Exposed and Vaccinated populations: there are populations of susceptible, exposed, infectious, vaccinated, and recovered subjects, and processes flow among these stocks. A link from the infectious population to the infection process reflects that the infection rate increases as the density of infectious subjects does.\",\n id: \"0194d7c1-3b04-77cf-b2c1-e4e8a10712e2\",\n tag: \"rich-text\",\n },\n \"0194fc13-2920-724c-a6c3-fc1d17699223\": {\n content: {\n id: \"0194fc13-2920-724c-a6c3-f85ca780f6cf\",\n name: \"Vaccinated\",\n obType: { content: \"Object\", tag: \"Basic\" },\n tag: \"object\",\n },\n id: \"0194fc13-2920-724c-a6c3-fc1d17699223\",\n tag: \"formal\",\n },\n \"0194fc13-3da9-77cb-b36a-9c5b8a74d941\": {\n content: {\n id: \"0194fc13-3da9-77cb-b36a-9b8a6a83f0e6\",\n name: \"Exposed\",\n obType: { content: \"Object\", tag: \"Basic\" },\n tag: \"object\",\n },\n id: \"0194fc13-3da9-77cb-b36a-9c5b8a74d941\",\n tag: \"formal\",\n },\n \"0194fc13-d6aa-741c-a30c-54cd59aaee10\": {\n content: {\n cod: { content: \"0194d7a9-bf28-709f-b34d-513c3da75e9c\", tag: \"Basic\" },\n dom: { content: \"0194fc13-3da9-77cb-b36a-9b8a6a83f0e6\", tag: \"Basic\" },\n id: \"0194fc13-d6aa-741c-a30c-536d48c10c1e\",\n morType: {\n content: { content: \"Object\", tag: \"Basic\" },\n tag: \"Hom\",\n },\n name: \"infection\",\n tag: \"morphism\",\n },\n id: \"0194fc13-d6aa-741c-a30c-54cd59aaee10\",\n tag: \"formal\",\n },\n \"0194fc14-204c-72a4-92fa-df5491673bab\": {\n content: {\n cod: { content: \"0194fc13-2920-724c-a6c3-f85ca780f6cf\", tag: \"Basic\" },\n dom: { content: \"0194d7a9-bc26-73ac-b2b8-6eb9a514827b\", tag: \"Basic\" },\n id: \"0194fc14-204c-72a4-92fa-da1399afa430\",\n morType: {\n content: { content: \"Object\", tag: \"Basic\" },\n tag: \"Hom\",\n },\n name: \"vaccination\",\n tag: \"morphism\",\n },\n id: \"0194fc14-204c-72a4-92fa-df5491673bab\",\n tag: \"formal\",\n },\n \"01981982-b589-702c-99a8-57983e3bd08e\": {\n content: {\n cod: { content: \"0194d7a9-bc26-73ac-b2b8-6eb9a514827b\", tag: \"Basic\" },\n dom: { content: \"0194fc13-2920-724c-a6c3-f85ca780f6cf\", tag: \"Basic\" },\n id: \"01981982-b589-702c-99a8-539c45521dc9\",\n morType: {\n content: { content: \"Object\", tag: \"Basic\" },\n tag: \"Hom\",\n },\n name: \"waning\",\n tag: \"morphism\",\n },\n id: \"01981982-b589-702c-99a8-57983e3bd08e\",\n tag: \"formal\",\n },\n \"019ffc10-1a2b-73c1-9f01-4d5e6a7b8c01\": {\n content: {\n cod: { content: \"0194fc13-3da9-77cb-b36a-9b8a6a83f0e6\", tag: \"Basic\" },\n dom: { content: \"0194d7a9-c036-745b-99e2-aedb526915c7\", tag: \"Basic\" },\n id: \"019ffc10-1a2b-73c1-9f01-4d5e6a7b8c02\",\n morType: {\n content: { content: \"Object\", tag: \"Basic\" },\n tag: \"Hom\",\n },\n name: \"reinfection\",\n tag: \"morphism\",\n },\n id: \"019ffc10-1a2b-73c1-9f01-4d5e6a7b8c01\",\n tag: \"formal\",\n },\n \"019ffc10-3c4d-74e2-8a12-5e6f7a8b9c11\": {\n content: {\n cod: {\n content: {\n content: \"019ffc10-1a2b-73c1-9f01-4d5e6a7b8c02\",\n tag: \"Basic\",\n },\n tag: \"Tabulated\",\n },\n dom: { content: \"0194d7a9-bf28-709f-b34d-513c3da75e9c\", tag: \"Basic\" },\n id: \"019ffc10-3c4d-74e2-8a12-5e6f7a8b9c12\",\n morType: { content: \"Link\", tag: \"Basic\" },\n name: \"\",\n tag: \"morphism\",\n },\n id: \"019ffc10-3c4d-74e2-8a12-5e6f7a8b9c11\",\n tag: \"formal\",\n },\n },\n cellOrder: [\n \"0194d7c1-3b04-77cf-b2c1-e4e8a10712e2\",\n \"0194d7a9-bc26-73ac-b2b8-73470cb412ae\",\n \"0194fc13-3da9-77cb-b36a-9c5b8a74d941\",\n \"0194d7a9-bf28-709f-b34d-545928dd7c16\",\n \"0194d7a9-c036-745b-99e2-b3ef2d3b87d0\",\n \"0194fc13-2920-724c-a6c3-fc1d17699223\",\n \"0194d7a9-d72e-700a-9c8b-7686fad4193b\",\n \"0194fc14-204c-72a4-92fa-df5491673bab\",\n \"0194fc13-d6aa-741c-a30c-54cd59aaee10\",\n \"0194d7a9-d8b5-741f-916f-d559d3ff2f8d\",\n \"0194d7a9-f4ff-77df-80a5-75410f4b9680\",\n \"01981982-b589-702c-99a8-57983e3bd08e\",\n \"019ffc10-1a2b-73c1-9f01-4d5e6a7b8c01\",\n ],\n },\n theory: \"primitive-stock-flow\",\n type: \"model\",\n version: \"2\",\n};\n\nconst EXAMPLES = [{ name: \"CatColab: Stock & Flow\", doc: SEIRV }];\n"],
|
|
5
|
+
"mappings": "+QAAA,OAAS,YAAYA,MAAkB,eACvC,OAAS,kBAAkBC,OAAwB,eACnD,OAAS,QAAQC,OAAc,eAC/B,OAAS,oBAAoBC,OAA0B,eACvD,OAAS,gBAAgBC,MAAsB,eAC/C,OAAS,UAAUC,MAAgB,eACnC,OAAS,YAAYC,MAAkB,eACvC,OAAS,OAAOC,MAAa,eAC7B,OAAS,UAAUC,MAAgB,eACnC,OAAS,mBAAmBC,MAAyB,eAWrD,MAAO,mCCpBP,OAAS,qBAAAC,GAAmB,yBAAAC,OAA8B,4BCA1D,OAAS,yBAAAC,GAAuB,uBAAAC,GAAqB,qBAAAC,GAAmB,yBAAAC,OAA8B,4BCgB/F,SAASC,GAAUC,EAASC,EAAUC,EAAU,CAEnD,IAAMC,EADOH,EAAQ,QAAQ,gBAAgB,GAClBA,EACrBI,EAAU,IAAI,eACdC,EAAOD,EAAQ,MACfE,EAAa,IAAI,gBACjB,CAAE,OAAAC,CAAO,EAAID,EACnBD,EAAK,iBAAiB,UAAYG,GAAU,CACpCA,EAAM,MAAM,OAAS,UACrBN,EAASM,EAAM,KAAK,KAAK,CACjC,EAAG,CAAE,OAAAD,CAAO,CAAC,EAGbF,EAAK,MAAM,EACX,IAAMI,EAAS,CACX,SAAAR,EACA,KAAMG,EAAQ,KAClB,EACA,OAAAD,EAAW,cAA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CAACX,EAAQ,CAAC,CAAC,EAC3EW,CACT,CACF,CAAC,EAAGhG,EAAkBC,EAAM,CAC1B,IAAI,MAAO,CACT,OAAOoF,EAAQ,CACjB,EACA,IAAI,UAAW,CACb,IAAIuB,EAAS1J,GAAQ,EACrB,OAAA6C,EAAS6G,EAAQ5G,EAAkB6G,GAAM,CACvC,IAAI,OAAQ,CACV,OAAOnI,EAAM,SACf,CACF,CAAC,CAAC,EACFqG,EAASC,GAAO,CACd,IAAI8B,EAAO,CAAC,CAAC1B,EAAY,EACvB2B,EAAO,GAAGrI,EAAM,aAAa,iBAAiB,CAAC,KACjD,OAAAoI,IAAS9B,EAAI,GAAK4B,EAAO,UAAU,OAAO,8BAA+B5B,EAAI,EAAI8B,CAAI,EACrFC,IAAS/B,EAAI,GAAKgC,GAAmBJ,EAAQ,QAAS5B,EAAI,EAAI+B,CAAI,EAC3D/B,CACT,EAAG,CACD,EAAG,OACH,EAAG,MACL,CAAC,EACM4B,CACT,CACF,CAAC,EAAGK,GAAO,IAAMvI,EAAM,QAAQ,CAAC,CAClC,CACA,SAASgH,IAAgB,CACvB,OAAOrI,GAAQ,CACjB,CACO,SAAS6J,GAAqBC,EAAW,CAC9C,MAAO,CAAC3I,EAAQZ,IACPwJ,GAAO,IAAMpH,EAAkBzB,GAAgB,CACpD,OAAQC,EACR,IAAI,MAAO,CACT,OAAOZ,EAAQ,IACjB,EACA,UAAWuJ,CACb,CAAC,EAAGvJ,CAAO,CAEf,CACAyJ,GAAiB,CAAC,OAAO,CAAC",
|
|
6
|
+
"names": ["_$template", "_$delegateEvents", "_$memo", "_$setStyleProperty", "_$setAttribute", "_$effect", "_$getOwner", "_$use", "_$insert", "_$createComponent", "parseAutomergeUrl", "stringifyAutomergeUrl", "interpretAsDocumentId", "isValidAutomergeUrl", "parseAutomergeUrl", "stringifyAutomergeUrl", "subscribe", "element", "selector", "listener", "dispatchEl", "channel", "port", "controller", "signal", "event", "detail", "_$template", "_$delegateEvents", "_$memo", "_$insert", "_$createComponent", "For", "Show", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "DOCUMENT_LIST_TOOL", "SidebarWidgets", "props", "addDocumentList", "root", "handle", "doc", "_el$", "_$insert", "_$createComponent", "Show", "_$memo", "_el$2", "_el$3", "For", "widget", "_el$4", "SlotView", "_$delegateEvents", "_$template", "_$setAttribute", "_$effect", "_$insert", "_$createComponent", "For", "Show", "_tmpl$", "_$template", "_tmpl$2", "Tray", "props", "_$createComponent", "Show", "_el$", "_$insert", "For", "slot", "_el$2", "SlotView", "_$effect", "_$setAttribute", "slotId", "createEffect", "createMemo", "createSignal", "onCleanup", "onMount", "Show", "render", "createDocOfDatatype2", "getRegistry", "loadDatatypeWhenReady", "id", "INTRINSIC_DOCTITLE_TOOLS", "DOCUMENT_LIST_TOOL", "defaultSidebarWidgets", "rootFolderUrl", "ensureThreepaneConfig", "accountHandle", "repo", "existingConfigUrl", "doc", "DEFAULT_TRAY_TOOLS", "DEFAULT_DOCTITLE_TOOLS", "datatype", "loadDatatypeWhenReady", "account", "doctitleTools", "id", "configHandle", "createDocOfDatatype2", "acc", "import_debug", "createDocOfDatatype2", "seedGaiosExamples", "repo", "folder", "example", "EXAMPLES", "handle", "doc", "SEIRV", "log", "debug", "seedExampleDocuments", "accountHandle", "repo", "account", "doc", "rootFolder", "existingDocs", "gaios", "initUrls", "bundleInitScriptUrls", "folderDatatype", "loadDatatypeWhenReady", "folder", "createDocOfDatatype2", "seedGaiosExamples", "url", "err", "seeded", "TOOLS_BUNDLE_INIT_URL", "BASE_BUNDLE_INIT_URL", "watcher", "fromManifests", "base", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "_tmpl$4", "_tmpl$5", "_tmpl$6", "_tmpl$7", "_tmpl$8", "_tmpl$9", "_tmpl$0", "MIN_SIDEBAR_WIDTH", "MAX_SIDEBAR_WIDTH", "AUTO_CLOSE_WIDTH", "DRAG_THRESHOLD", "useFrameProviderReady", "componentId", "element", "isReady", "setReady", "createSignal", "createEffect", "el", "onMounted", "event", "onCleanup", "dispatchOpen", "detail", "PatchworkFrame", "handle", "repo", "props", "ensureFrameStyles", "accountDocUrl", "accountProviderElement", "setAccountProviderElement", "isAccountProviderReady", "toolStorageProviderElement", "setToolStorageProviderElement", "isToolStorageProviderReady", "selectedDocProviderElement", "setSelectedDocProviderElement", "isSelectedDocProviderReady", "areProvidersReady", "createMemo", "_el$", "_el$2", "_el$3", "_el$4", "_el$5", "_el$6", "_el$7", "_$insert", "_$createComponent", "Show", "_$use", "_$getOwner", "PatchworkFrameInner", "accountDocHandle", "useDocHandle", "ensureThreepaneConfig", "seedExampleDocuments", "err", "docVersion", "setDocVersion", "h", "onChange", "v", "accountDoc", "threepaneUrl", "threepaneConfigHandle", "threepaneVersion", "setThreepaneVersion", "threepaneConfig", "doctitleSlots", "sidebarWidgets", "traySlots", "rootFolderUrl", "sidebarState", "useSidebarState", "sidebarResize", "useSidebarResize", "debugEvents", "dismissEvent", "clearAll", "useDebugRegistryToast", "selectedView", "setSelectedView", "popoverView", "setPopoverView", "onMount", "unsubscribeSelectedView", "subscribe", "view", "selectedDocUrl", "selectedToolId", "initialRightWidth", "getStoredNumber", "SIDEBAR_KEYS", "DEFAULT_SIDEBAR_WIDTH", "initialRightCollapsed", "getStoredBoolean", "mainDocElement", "setMainDocElement", "isMainDocMounted", "useMainDocMounted", "widgetsReady", "setWidgetsReady", "_el$8", "_ref$", "DebugRegistryToast", "FrameLayout", "_el$9", "MainDocumentView", "DocumentAreaRoot", "IsolatedDocumentArea", "FramePopover", "toolId", "setToolId", "popoverEl", "onKey", "e", "onOpen", "url", "nextToolId", "_el$0", "_el$1", "_el$10", "_el$11", "_el$12", "_el$13", "_ref$2", "_$effect", "_p$", "_v$", "_v$2", "_v$3", "isCollapsed", "hasTray", "footerEl", "sidebarContentEl", "COLLAPSE_CONTEXT_SIDEBAR_EVENT", "_el$14", "PanelLeftIcon", "_v$4", "_v$5", "_v$6", "_$setAttribute", "Sidebar", "_el$15", "_el$16", "_el$17", "_el$18", "_ref$3", "SidebarWidgets", "_ref$4", "contactUrl", "_el$20", "_el$21", "moduleSettingsUrl", "_el$22", "_el$19", "Tray", "_v$7", "_v$8", "_$setStyleProperty", "_$memo", "renderPatchworkFrame", "isolation", "render", "_$delegateEvents"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-FW4363Y4.js";function a(){return new Promise(t=>setTimeout(t))}async function e(t){let{renderPatchworkFrame:o}=await import("./PatchworkFrame-
|
|
1
|
+
import"./chunk-FW4363Y4.js";function a(){return new Promise(t=>setTimeout(t))}async function e(t){let{renderPatchworkFrame:o}=await import("./PatchworkFrame-RLYJ4GEF.js");return await a(),o(t)}var n=[{type:"patchwork:datatype",id:"account",name:"Patchwork Account",icon:"UserCircle",unlisted:!0,async load(){let{AccountDatatype:t}=await import("./datatypes-CZ3FLN4K.js");return t}},{type:"patchwork:datatype",id:"threepane:config",name:"Threepane Config",icon:"Settings",unlisted:!0,async load(){let{ThreepaneConfigDatatype:t}=await import("./datatypes-CZ3FLN4K.js");return t}},{type:"patchwork:tool",id:"threepane",tags:["frame-tool"],name:"Threepane (\u{1F920} wild west)",icon:"Window",supportedDatatypes:["account"],load:e},{type:"patchwork:tool",id:"threepane-wild-west",tags:["frame-tool"],name:"Threepane (\u{1F920} wild west)",icon:"Window",supportedDatatypes:["account"],load:e,unlisted:!0},{type:"patchwork:tool",id:"threepane-isolation",tags:["frame-tool"],name:"Threepane (isolate)",icon:"Window",supportedDatatypes:["account"],load:()=>e(!0)},{type:"patchwork:component",id:"threepane-isolation-root",name:"Threepane Isolation Root",async load(){let{mountIsolationRoot:t}=await import("./IsolatedDocumentArea-2JIBFDOX.js");return await a(),t}},{type:"patchwork:tool",id:"patchwork-frame",name:"Patchwork Frame",icon:"Window",supportedDatatypes:["account"],unlisted:!0,load:e}];export{n as plugins};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/tool.js", "../src/styles.css"],
|
|
4
|
-
"sourcesContent": ["import {\n parseAutomergeUrl,\n isValidAutomergeUrl,\n} from \"@automerge/automerge-repo/slim\";\nimport { openDocument } from \"@inkandswitch/patchwork-elements\";\nimport {\n getRegistry,\n createDocOfDatatype2,\n} from \"@inkandswitch/patchwork-plugins\";\nimport styles from \"./styles.css\";\n\n// MIME types we can extract document drags from, in order of preference.\n// These mirror what the sideboard sets on dragstart so dropping a sidebar\n// item into the folder view adds it to the folder.\nconst DND_DATA_TYPES = [\n \"text/x-patchwork-dnd\",\n \"text/x-patchwork-urls\",\n \"text/uri-list\",\n \"text/plain\",\n];\n\nfunction hasDocumentDrag(dataTransfer) {\n return Boolean(\n dataTransfer &&\n DND_DATA_TYPES.some((type) => dataTransfer.types.includes(type))\n );\n}\n\nfunction urlFromText(text) {\n const trimmed = text.trim();\n if (isValidAutomergeUrl(trimmed)) return trimmed;\n // patchwork web links carry the document id in the fragment: #doc=<documentId>\n const docId = trimmed.match(/#doc=([^&\\s]+)/)?.[1];\n if (docId && isValidAutomergeUrl(`automerge:${docId}`)) {\n return `automerge:${docId}`;\n }\n return null;\n}\n\n// Extract the dragged documents from a drop event. Returns an array of\n// { url, name?, type? } items, or an empty array if there's nothing droppable.\nfunction getDndItems(event) {\n const data = event.dataTransfer;\n if (!data) return [];\n\n const dndData = data.getData(\"text/x-patchwork-dnd\");\n if (dndData) {\n try {\n const parsed = JSON.parse(dndData);\n if (Array.isArray(parsed?.items) && parsed.items.length > 0) {\n return parsed.items.filter((item) => isValidAutomergeUrl(item?.url));\n }\n } catch {\n // fall through to the other types\n }\n }\n\n const urlData = data.getData(\"text/x-patchwork-urls\");\n if (urlData) {\n try {\n const urls = JSON.parse(urlData);\n const items = (Array.isArray(urls) ? urls : [])\n .filter((url) => isValidAutomergeUrl(url))\n .map((url) => ({ url }));\n if (items.length > 0) return items;\n } catch {\n // fall through to the other types\n }\n }\n\n const text = data.getData(\"text/uri-list\") || data.getData(\"text/plain\");\n return text\n .split(/\\r?\\n/)\n .map(urlFromText)\n .filter((url) => url !== null)\n .map((url) => ({ url }));\n}\n\nfunction el(tag, attrs, ...children) {\n const node = document.createElement(tag);\n if (attrs) {\n for (const [key, value] of Object.entries(attrs)) {\n if (value == null || value === false) continue;\n if (key === \"className\") {\n node.className = value;\n } else if (key.startsWith(\"on\") && typeof value === \"function\") {\n node.addEventListener(key.slice(2).toLowerCase(), value);\n } else {\n node.setAttribute(key, value);\n }\n }\n }\n for (const child of children.flat()) {\n if (child == null || child === false) continue;\n node.appendChild(\n typeof child === \"string\" ? document.createTextNode(child) : child\n );\n }\n return node;\n}\n\nfunction entryHref(docLink) {\n return `#doc=${parseAutomergeUrl(docLink.url).documentId}&type=${docLink.type}`;\n}\n\nfunction renderLoading() {\n return el(\"div\", { className: \"folder-view-loading\" }, \"Loading\u2026\");\n}\n\nfunction buildEntry(docLink) {\n const isFolder = docLink.type === \"folder\";\n const nameEl = el(\"span\", { className: \"folder-entry-name\" }, docLink.name);\n const typeEl = el(\"span\", { className: \"folder-entry-type\" }, docLink.type);\n const openEl = el(\n \"a\",\n { className: \"folder-entry-open\", href: entryHref(docLink) },\n \"Open\"\n );\n\n // The nested view names the doc without heads; resolution (the drafts\n // `repo:handle-descriptor` answer) pins it to the active checkpoint when one\n // is checked out, so the entry freezes with the folder it lives in.\n const node = el(\n \"div\",\n { className: \"folder-entry\", \"data-type\": docLink.type },\n el(\n \"div\",\n { className: \"folder-entry-head\" },\n el(\"div\", { className: \"folder-entry-title\" }, nameEl, typeEl),\n openEl\n ),\n isFolder\n ? el(\n \"p\",\n { className: \"folder-entry-hint\" },\n 'Click \"Open\" to view folder contents'\n )\n : el(\n \"div\",\n { className: \"folder-entry-body\" },\n el(\n \"div\",\n { className: \"folder-entry-scroll\" },\n el(\"patchwork-view\", { \"doc-url\": docLink.url })\n )\n )\n );\n\n return {\n node,\n nameEl,\n typeEl,\n openEl,\n isFolder,\n url: docLink.url,\n };\n}\n\nfunction updateEntry(entry, docLink) {\n if (entry.nameEl.textContent !== docLink.name) {\n entry.nameEl.textContent = docLink.name;\n }\n if (entry.typeEl.textContent !== docLink.type) {\n entry.typeEl.textContent = docLink.type;\n }\n if (entry.node.getAttribute(\"data-type\") !== docLink.type) {\n entry.node.setAttribute(\"data-type\", docLink.type);\n }\n const href = entryHref(docLink);\n if (entry.openEl.getAttribute(\"href\") !== href) {\n entry.openEl.setAttribute(\"href\", href);\n }\n}\n\n// The listable document types, sorted by name. `file` and other unlisted\n// datatypes are hidden \u2014 you can't create an empty File, for instance.\nfunction listableDatatypes() {\n return getRegistry(\"patchwork:datatype\")\n .all()\n .filter((datatype) => !datatype.unlisted)\n .sort((a, b) => a.name.localeCompare(b.name));\n}\n\n// Create a fresh document of the given datatype and return a DocLink for it.\n// Mirrors the sideboard's createNew: load the plugin on demand, create the doc,\n// register it with the sync server (if a hive is present), then read its title.\nasync function createDocLink(repo, hive, datatype) {\n const loaded = await getRegistry(\"patchwork:datatype\").load(datatype.id);\n if (!loaded) throw new Error(`couldn't load datatype \"${datatype.id}\"`);\n const docHandle = await createDocOfDatatype2(loaded, repo);\n if (hive) await hive.addSyncServerPullToDoc(docHandle.url);\n return {\n url: docHandle.url,\n name: loaded.module.getTitle(docHandle.doc()),\n type: datatype.id,\n };\n}\n\n// The \"New\" button plus its type-picker popover. Creating a doc appends a\n// DocLink to the folder and opens it. Returns { node, dispose }.\nfunction buildCreateNew(handle, element) {\n const menu = el(\"div\", { className: \"folder-create-menu\", hidden: \"\" });\n const button = el(\n \"button\",\n {\n className: \"folder-create-button\",\n type: \"button\",\n \"aria-label\": \"Create new document\",\n },\n el(\"span\", { className: \"folder-create-icon\" }, \"+\"),\n \"New\"\n );\n const node = el(\"div\", { className: \"folder-create\" }, button, menu);\n\n let open = false;\n\n function setOpen(next) {\n open = next;\n if (open) {\n renderMenu();\n menu.removeAttribute(\"hidden\");\n node.setAttribute(\"data-open\", \"\");\n } else {\n menu.setAttribute(\"hidden\", \"\");\n node.removeAttribute(\"data-open\");\n }\n }\n\n function renderMenu() {\n const datatypes = listableDatatypes();\n if (datatypes.length === 0) {\n menu.replaceChildren(\n el(\n \"div\",\n { className: \"folder-create-empty\" },\n \"No document types available\"\n )\n );\n return;\n }\n menu.replaceChildren(\n ...datatypes.map((datatype) =>\n el(\n \"button\",\n {\n className: \"folder-create-item\",\n type: \"button\",\n onClick: () => pick(datatype),\n },\n datatype.name\n )\n )\n );\n }\n\n async function pick(datatype) {\n setOpen(false);\n const repo = element.repo;\n if (!repo) return;\n try {\n const link = await createDocLink(repo, element.hive, datatype);\n handle.change((doc) => {\n doc.docs.push(link);\n });\n openDocument(element, link.url);\n } catch (error) {\n console.error(\"folder: couldn't create document\", error);\n }\n }\n\n button.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n setOpen(!open);\n });\n\n // Dismiss the menu on an outside click or Escape.\n const onPointerDown = (event) => {\n if (open && !node.contains(event.target)) setOpen(false);\n };\n const onKeyDown = (event) => {\n if (open && event.key === \"Escape\") setOpen(false);\n };\n document.addEventListener(\"pointerdown\", onPointerDown);\n document.addEventListener(\"keydown\", onKeyDown);\n\n const dispose = () => {\n document.removeEventListener(\"pointerdown\", onPointerDown);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n\n return { node, dispose };\n}\n\nexport const FolderTool = (handle, element) => {\n const entries = new Map();\n\n const styleEl = el(\"style\");\n styleEl.textContent = styles;\n\n const countEl = el(\"span\", { className: \"folder-view-count\" });\n const listEl = el(\"div\", { className: \"folder-view-list\" });\n const createNew = buildCreateNew(handle, element);\n const shell = el(\n \"div\",\n { className: \"folder-view\" },\n el(\n \"div\",\n { className: \"folder-view-header\" },\n createNew.node,\n countEl\n ),\n listEl\n );\n\n element.append(styleEl);\n\n // --- drag-and-drop: accept documents dragged in from the sidebar ---\n\n // dragenter/dragleave fire for every descendant, so track nesting depth to\n // know when the pointer has actually left the folder view.\n let dragDepth = 0;\n\n function endDrag() {\n dragDepth = 0;\n shell.removeAttribute(\"data-drop-active\");\n }\n\n function addDroppedDocs(event) {\n const folder = handle.doc();\n if (!folder) return;\n\n const existing = new Set(folder.docs.map((docLink) => docLink.url));\n const selfUrl = handle.url;\n\n const links = [];\n for (const item of getDndItems(event)) {\n if (item.url === selfUrl) continue; // don't nest a folder inside itself\n if (existing.has(item.url)) continue; // already here\n existing.add(item.url); // de-dupe within a single drop too\n links.push({\n url: item.url,\n name: item.name || \"Untitled\",\n type: item.type || \"\",\n });\n }\n\n if (links.length === 0) return;\n\n handle.change((doc) => {\n doc.docs.push(...links);\n });\n }\n\n shell.addEventListener(\"dragenter\", (event) => {\n if (!hasDocumentDrag(event.dataTransfer)) return;\n event.preventDefault();\n dragDepth++;\n shell.setAttribute(\"data-drop-active\", \"\");\n });\n\n shell.addEventListener(\"dragover\", (event) => {\n if (!hasDocumentDrag(event.dataTransfer)) return;\n event.preventDefault();\n // \"link\": dropping here adds a new DocLink to the same automerge url \u2014 the\n // doc isn't moved or cloned. Requires the source's effectAllowed to permit\n // link (the sideboard sets \"all\").\n event.dataTransfer.dropEffect = \"link\";\n });\n\n shell.addEventListener(\"dragleave\", (event) => {\n if (!hasDocumentDrag(event.dataTransfer)) return;\n dragDepth--;\n if (dragDepth <= 0) endDrag();\n });\n\n shell.addEventListener(\"drop\", (event) => {\n if (!hasDocumentDrag(event.dataTransfer)) return;\n event.preventDefault();\n endDrag();\n addDroppedDocs(event);\n });\n\n let mounted = null;\n\n function show(node) {\n if (mounted !== node) {\n // keep the injected <style>, swap the rendered tree\n if (mounted) mounted.remove();\n element.append(node);\n mounted = node;\n }\n }\n\n function render() {\n const folder = handle.doc();\n if (!folder) {\n show(renderLoading());\n return;\n }\n\n show(shell);\n countEl.textContent = `${folder.docs.length} ${\n folder.docs.length === 1 ? \"document\" : \"documents\"\n }`;\n\n if (folder.docs.length === 0) {\n entries.clear();\n listEl.replaceChildren(\n el(\"div\", { className: \"folder-view-empty\" }, \"This folder is empty\")\n );\n return;\n }\n\n const seen = new Set();\n const ordered = [];\n for (const docLink of folder.docs) {\n seen.add(docLink.url);\n const isFolder = docLink.type === \"folder\";\n let entry = entries.get(docLink.url);\n // Rebuild only if folder/non-folder shape flipped \u2014 that's the one\n // case where the body structure differs.\n if (!entry || entry.isFolder !== isFolder) {\n entry = buildEntry(docLink);\n entries.set(docLink.url, entry);\n } else {\n updateEntry(entry, docLink);\n }\n ordered.push(entry.node);\n }\n\n for (const url of [...entries.keys()]) {\n if (seen.has(url)) continue;\n entries.delete(url);\n }\n\n listEl.replaceChildren(...ordered);\n }\n\n const onChange = () => render();\n handle.on(\"change\", onChange);\n render();\n\n return () => {\n handle.off(\"change\", onChange);\n createNew.dispose();\n element.replaceChildren();\n entries.clear();\n mounted = null;\n };\n};\n", "@layer package {\n:root,\n:host,\n[theme] {\n /* The well the cards sit in \u2014 slightly recessed surface. */\n --folder-view-well: var(--editor-fill-offset-10, #f2f2f2);\n --folder-view-well-edge: var(--editor-fill-offset-30, #d6d6d6);\n --folder-view-fg: var(--editor-line, black);\n --folder-view-muted: var(--editor-line-offset-50, #999);\n --folder-view-border: var(--editor-fill-offset-20, #e5e5e5);\n\n /* A card = a raised surface sitting on the well. */\n --folder-view-card: var(--editor-fill, white);\n --folder-view-card-border: var(--editor-fill-offset-20, #e5e5e5);\n\n --folder-view-accent: var(--studio-primary-fill, var(--studio-primary, #35f7ca));\n --folder-view-accent-line: var(--studio-primary-line, var(--editor-fill, white));\n --folder-view-accent-text: var(--editor-primary-text, var(--studio-primary-text, var(--studio-primary, #35f7ca)));\n --folder-view-hover: var(--editor-fill-offset-10, #f2f2f2);\n\n /* Layered drop shadow so a card reads as a solid object resting on the\n well \u2014 a tight contact shadow plus a softer cast one. Derived from the\n theme line colour so it inverts in dark themes. */\n --folder-view-card-shadow: 0 1px 2px\n color-mix(in oklch, var(--editor-line, black), transparent 94%),\n 0 2px 8px color-mix(in oklch, var(--editor-line, black), transparent 96%);\n --folder-view-card-shadow-hover: 0 2px 4px\n color-mix(in oklch, var(--editor-line, black), transparent 90%),\n 0 8px 20px color-mix(in oklch, var(--editor-line, black), transparent 93%);\n\n --folder-view-family: var(--editor-family-sans, system-ui, sans-serif);\n}\n}\n\n/* Block: the whole tool. A sunken well with an inset edge. */\n.folder-view {\n height: 100%;\n overflow: auto;\n padding: var(--studio-space-md, 1rem);\n display: flex;\n flex-direction: column;\n gap: var(--studio-space-md, 1rem);\n font-family: var(--folder-view-family);\n color: var(--folder-view-fg);\n background: var(--folder-view-well);\n /* No outer border: the host frame already draws the lines around the pane, so\n the well reads as flush rather than double-edged. */\n}\n\n/* State: a document is being dragged in from the sidebar. Outline the well\n with the accent colour so it reads as an active drop target. */\n.folder-view[data-drop-active] {\n border-color: var(--folder-view-accent);\n box-shadow: inset 0 0 0 2px var(--folder-view-accent);\n}\n\n/* Composition: header row. New-doc button on the left, count on the right. */\n.folder-view .folder-view-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--studio-space-sm, 0.5rem);\n padding-bottom: var(--studio-space-sm, 0.5rem);\n border-bottom: 1px solid var(--folder-view-border);\n}\n\n/* Composition: the create-new control \u2014 a button anchoring a type-picker. */\n.folder-view .folder-create {\n position: relative;\n}\n\n.folder-view .folder-create-button {\n display: inline-flex;\n align-items: center;\n gap: var(--studio-space-2xs, 0.25rem);\n font: inherit;\n font-size: 0.8rem;\n color: var(--folder-view-accent-line);\n background: var(--folder-view-accent);\n border: 1px solid transparent;\n border-radius: var(--studio-radius-sm, 4px);\n padding: var(--studio-space-2xs, 0.25rem) var(--studio-space-sm, 0.5rem);\n cursor: pointer;\n transition: filter var(--studio-transition-fast, 0.1s ease);\n}\n\n.folder-view .folder-create-button:hover {\n filter: brightness(0.96);\n}\n\n.folder-view .folder-create-icon {\n font-size: 1rem;\n line-height: 1;\n}\n\n/* The type-picker popover, anchored under the button. */\n.folder-view .folder-create-menu {\n position: absolute;\n top: calc(100% + var(--studio-space-2xs, 0.25rem));\n left: 0;\n z-index: 10;\n min-width: 12rem;\n max-height: 16rem;\n overflow: auto;\n display: flex;\n flex-direction: column;\n padding: var(--studio-space-3xs, 0.125rem);\n background: var(--folder-view-card);\n border: 1px solid var(--folder-view-card-border);\n border-radius: var(--studio-radius-md, 8px);\n box-shadow: var(--folder-view-card-shadow-hover);\n}\n\n.folder-view .folder-create-menu[hidden] {\n display: none;\n}\n\n.folder-view .folder-create-item {\n text-align: left;\n font: inherit;\n font-size: 0.85rem;\n color: var(--folder-view-fg);\n background: transparent;\n border: 0;\n border-radius: var(--studio-radius-sm, 4px);\n padding: var(--studio-space-2xs, 0.25rem) var(--studio-space-sm, 0.5rem);\n cursor: pointer;\n}\n\n.folder-view .folder-create-item:hover {\n background: var(--folder-view-hover);\n}\n\n.folder-view .folder-create-empty {\n padding: var(--studio-space-sm, 0.5rem);\n font-size: 0.8rem;\n color: var(--folder-view-muted);\n}\n\n.folder-view .folder-view-count {\n font-size: 0.8rem;\n color: var(--folder-view-muted);\n padding: var(--studio-space-2xs, 0.25rem) var(--studio-space-sm, 0.5rem);\n border-radius: var(--studio-radius-round, 9999px);\n background: var(--folder-view-card);\n border: 1px solid var(--folder-view-border);\n}\n\n/* Composition: the list of cards. */\n.folder-view .folder-view-list {\n display: flex;\n flex-direction: column;\n gap: var(--studio-space-md, 1rem);\n padding-bottom: var(--studio-space-md, 1rem);\n}\n\n.folder-view .folder-view-empty {\n text-align: center;\n color: var(--folder-view-muted);\n padding: var(--studio-space-xl, 2rem) 0;\n}\n\n.folder-view-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding: var(--studio-space-md, 1rem);\n font-family: var(--folder-view-family);\n color: var(--folder-view-muted);\n background: var(--folder-view-card);\n}\n\n/* Block: one rendered file/folder card \u2014 sitting on the well. */\n.folder-view .folder-entry {\n background: var(--folder-view-card);\n border: 1px solid var(--folder-view-card-border);\n border-radius: var(--studio-radius-lg, 12px);\n box-shadow: var(--folder-view-card-shadow);\n overflow: hidden;\n transition: box-shadow var(--studio-transition, 0.15s ease),\n transform var(--studio-transition, 0.15s ease);\n}\n\n.folder-view .folder-entry:hover {\n box-shadow: var(--folder-view-card-shadow-hover);\n /* Lift slightly so the card feels like it peels up off the well. */\n transform: translateY(-1px);\n}\n\n.folder-view .folder-entry-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--studio-space-sm, 0.5rem);\n padding: var(--studio-space-sm, 0.5rem) var(--studio-space-md, 1rem);\n}\n\n.folder-view .folder-entry-title {\n display: flex;\n align-items: baseline;\n gap: var(--studio-space-sm, 0.5rem);\n min-width: 0;\n}\n\n.folder-view .folder-entry-name {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.folder-view .folder-entry-type {\n font-size: 0.7rem;\n color: var(--folder-view-muted);\n padding: var(--studio-space-3xs, 0.125rem) var(--studio-space-2xs, 0.25rem);\n border: 1px solid var(--folder-view-border);\n border-radius: var(--studio-radius-sm, 4px);\n flex-shrink: 0;\n}\n\n.folder-view .folder-entry-open {\n font-size: 0.8rem;\n color: var(--folder-view-accent-text);\n text-decoration: none;\n padding: var(--studio-space-2xs, 0.25rem) var(--studio-space-sm, 0.5rem);\n border-radius: var(--studio-radius-sm, 4px);\n flex-shrink: 0;\n transition: background var(--studio-transition-fast, 0.1s ease);\n}\n\n.folder-view .folder-entry-open:hover {\n background: var(--folder-view-hover);\n}\n\n.folder-view .folder-entry-hint {\n margin: 0;\n padding: 0 var(--studio-space-md, 1rem) var(--studio-space-md, 1rem);\n font-size: 0.85rem;\n color: var(--folder-view-muted);\n}\n\n/* Block: embedded preview body. */\n.folder-view .folder-entry-body {\n flex: 1 1 auto;\n min-height: 0;\n max-height: 300px;\n display: flex;\n flex-direction: column;\n border-top: 1px solid var(--folder-view-border);\n}\n\n.folder-view .folder-entry-scroll {\n height: 100%;\n overflow: auto;\n}\n\n.folder-view .folder-entry-scroll patchwork-view {\n display: block;\n height: 100%;\n}\n"],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