@tinycloud/web-sdk 3.7.0-beta.2 → 3.7.0-beta.4
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/README.md +40 -0
- package/dist/adapters/BrowserNotificationHandler.d.ts +22 -6
- package/dist/authorization/WebSpaceCreationHandler.d.ts +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/modals.cjs +1 -0
- package/dist/modals.mjs +1 -0
- package/dist/modules/tcw.d.ts +16 -2
- package/dist/notifications/ModalManager.d.ts +21 -7
- package/dist/notifications/PermissionRequestModal.d.ts +8 -1
- package/dist/notifications/SpaceCreationModal.d.ts +8 -1
- package/dist/notifications/dialogFocus.d.ts +39 -0
- package/dist/notifications/index.d.ts +1 -6
- package/dist/notifications/lazy-prompts.d.ts +16 -0
- package/dist/notifications/legacy-config.d.ts +11 -0
- package/dist/notifications/modals-entry.d.ts +7 -0
- package/dist/notifications/modals-registry.d.ts +15 -0
- package/dist/notifications/scrollLock.d.ts +2 -0
- package/dist/notifications/types.d.ts +6 -33
- package/dist/notifications/types.schema.d.ts +7 -148
- package/dist/panel-data.cjs +1 -0
- package/dist/panel-data.mjs +1 -0
- package/dist/panel.cjs +1 -0
- package/dist/panel.mjs +1 -0
- package/dist/ui/api.d.ts +30 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/client.d.ts +27 -0
- package/dist/ui/config.d.ts +35 -0
- package/dist/ui/data/map.d.ts +23 -0
- package/dist/ui/data/prefetch.d.ts +18 -0
- package/dist/ui/data/real.d.ts +12 -0
- package/dist/ui/data.d.ts +241 -0
- package/dist/ui/frame-guard.d.ts +7 -0
- package/dist/ui/host.d.ts +29 -0
- package/dist/ui/ids.d.ts +7 -0
- package/dist/ui/index.d.ts +38 -0
- package/dist/ui/manage-url.d.ts +8 -0
- package/dist/ui/panel-data-entry.d.ts +28 -0
- package/dist/ui/panel-entry.d.ts +23 -0
- package/dist/ui/panel-modal.d.ts +13 -0
- package/dist/ui/panel-styles.d.ts +10 -0
- package/dist/ui/panel-toasts.d.ts +30 -0
- package/dist/ui/panel.d.ts +42 -0
- package/dist/ui/parts/index.d.ts +4 -0
- package/dist/ui/parts/prompts.d.ts +39 -0
- package/dist/ui/parts/storage-watch.d.ts +11 -0
- package/dist/ui/parts/sync-status.d.ts +7 -0
- package/dist/ui/parts/toasts.d.ts +8 -0
- package/dist/ui/pending.d.ts +13 -0
- package/dist/ui/persistence.d.ts +28 -0
- package/dist/ui/phone.d.ts +14 -0
- package/dist/ui/section-data.d.ts +20 -0
- package/dist/ui/section-dialogs.d.ts +10 -0
- package/dist/ui/sections/account.d.ts +3 -0
- package/dist/ui/sections/account.strings.d.ts +29 -0
- package/dist/ui/sections/activity.d.ts +7 -0
- package/dist/ui/sections/activity.strings.d.ts +46 -0
- package/dist/ui/sections/delegations.d.ts +25 -0
- package/dist/ui/sections/delegations.strings.d.ts +143 -0
- package/dist/ui/sections/freshness-copy.d.ts +17 -0
- package/dist/ui/sections/index.d.ts +4 -0
- package/dist/ui/sections/local-copy.d.ts +3 -0
- package/dist/ui/sections/local-copy.strings.d.ts +70 -0
- package/dist/ui/sections/local-tinycloud.d.ts +9 -0
- package/dist/ui/sections/local-tinycloud.strings.d.ts +48 -0
- package/dist/ui/sections/nodes.d.ts +7 -0
- package/dist/ui/sections/nodes.strings.d.ts +27 -0
- package/dist/ui/sections/placeholder.d.ts +8 -0
- package/dist/ui/sections/status.d.ts +10 -0
- package/dist/ui/sections/storage.d.ts +37 -0
- package/dist/ui/sections/storage.strings.d.ts +37 -0
- package/dist/ui/sections/ui.d.ts +77 -0
- package/dist/ui/sections/view-body.d.ts +23 -0
- package/dist/ui/sign-out-purge.d.ts +39 -0
- package/dist/ui/slots.d.ts +218 -0
- package/dist/ui/status.d.ts +16 -0
- package/dist/ui/storage-state.d.ts +12 -0
- package/dist/ui/strings-panel.d.ts +29 -0
- package/dist/ui/strings.d.ts +76 -0
- package/dist/ui/stub/index.d.ts +48 -0
- package/dist/ui/styles.d.ts +9 -0
- package/dist/ui/toast-store.d.ts +46 -0
- package/dist/ui/view-result.d.ts +6 -0
- package/package.json +13 -4
- package/dist/notifications/ErrorHandler.d.ts +0 -32
- package/dist/notifications/NodeSelectionModal.d.ts +0 -29
- package/dist/notifications/ToastContainer.d.ts +0 -16
- package/dist/notifications/ToastElement.d.ts +0 -22
- package/dist/notifications/ToastManager.d.ts +0 -36
package/dist/panel.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{livePanelData as e,onLivePanelDataChange as t}from"./panel-data.mjs";const n=["overview","local","copy","delegations","nodes","storage","activity"],o="tinycloud-ui-panel",a='\n.glance{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}\n.glance-row{display:flex;align-items:center;gap:14px;width:100%;min-height:56px;padding:6px 6px 6px 0;border:0;border-bottom:1px solid #e4e4e7;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}\n.glance-row:last-child{border-bottom:0}\n.glance-row .gl{flex:1;min-width:0}\n.glance-row .gl b{display:block;font-size:14.5px;font-weight:600}\n.glance-row .gl span{display:block;font-size:13px;color:#71717a}\n.glance-row .gr{display:flex;align-items:center;gap:10px;color:#71717a}\n.glance-row .gr .ui-ic{width:16px;height:16px}\n.glance-row .gi{display:inline-flex;flex:none;color:#71717a}\n.glance-row .gi .ui-ic{width:20px;height:20px}\n.ui-ic{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}\n.st{display:inline-flex;align-items:center;gap:8px;font-size:13.5px;font-weight:600;white-space:nowrap}\n.st .dot{top:auto;right:auto;width:9px;height:9px;border:0;border-radius:50%;background:transparent;flex:none;position:relative}\n.st-ok{color:#18181b}\n.st-ok .dot{background:currentColor}\n.st-warn{color:#92400e}\n/* Warning colour from the mockup (panel-mock index.html: --tc-color-warning #b35309 light line 34, #fbbd23 dark line 57; .st-warn .dot line 259). */\n.st-warn .dot{background:#b35309;box-shadow:0 0 0 1.5px #fff,0 0 0 2.5px #b35309}\n.st-off,.st-info{color:#71717a}\n.st-off .dot,.st-info .dot{box-shadow:inset 0 0 0 2px currentColor}\n.st-info .dot::after{content:"";position:absolute;left:-1px;right:-1px;top:3.5px;height:2px;background:currentColor;transform:rotate(-45deg)}\n.drawer{margin-top:12px;padding:14px 16px;border:1px solid #d4d4d8;border-radius:12px;background:#fafafa}\n.drawer>h3{margin:0 0 8px;font-size:15px;font-weight:600;overflow-wrap:anywhere}\n@media (prefers-color-scheme: dark){\n.glance-row{border-bottom-color:#3f3f46}\n.glance-row .gl span,.glance-row .gr{color:#a1a1aa}\n.drawer{border-color:#3f3f46;background:#151517}\n.st-ok{color:#fafafa}\n.st-warn{color:#fcd34d}\n.st-warn .dot{background:#fbbd23;box-shadow:0 0 0 1.5px #151517,0 0 0 2.5px #fbbd23}\n.st-off,.st-info{color:#a1a1aa}\n}\n';function i(e){const t=document.createElement("button");return t.type="button",t.className="action",t.textContent=e,t}let s=0;function r(e){const t=document.createElement("div");t.className="confirm",t.setAttribute("role","alertdialog");const n="tc-confirm-q-"+ ++s;t.setAttribute("aria-describedby",n),t.addEventListener("keydown",t=>{"Escape"===t.key&&(t.stopPropagation(),r.disabled||c.disabled||e.onCancel())});const o=document.createElement("p");o.className="busy",o.id=n,o.textContent=e.question;const a=document.createElement("div");a.className="actions";const r=i(e.cancelLabel);r.addEventListener("click",e.onCancel);const c=i(e.confirmLabel);return c.addEventListener("click",e.onConfirm),a.append(r,c),t.append(o,a),{el:t,cancel:r,confirm:c}}const c={monitor:'<rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/>',sync:'<path d="M4 12a8 8 0 0 1 14-5l2 2M20 4v5h-5M20 12a8 8 0 0 1-14 5l-2-2M4 20v-5h5"/>',key:'<circle cx="8" cy="15" r="4"/><path d="M11 12l9-9M17 6l3 3M14 9l2 2"/>',nodes:'<circle cx="6" cy="6" r="2.5"/><circle cx="18" cy="6" r="2.5"/><circle cx="12" cy="18" r="2.5"/><path d="M8.5 6h7M7.2 8.2l3.6 7.6M16.8 8.2l-3.6 7.6"/>',drive:'<rect x="3" y="13" width="18" height="7" rx="2"/><path d="M3 13l3-8h12l3 8M7 16.5h.01"/>',term:'<rect x="3" y="4" width="18" height="16" rx="3"/><path d="M7 10l3 2-3 2M13 15h4"/>',chev:'<path d="M9 5l7 7-7 7"/>',ext:'<path d="M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/>',sidebar:'<rect x="3" y="4" width="18" height="16" rx="3"/><path d="M15 4v16"/>',out:'<path d="M10 4H5a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h5M16 8l4 4-4 4M20 12H9"/>',copy:'<rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a1 1 0 0 1 1-1h10"/>',check:'<path d="M5 12l5 5 9-10"/>',warn:'<path d="M12 3l10 18H2zM12 10v5M12 18h.01"/>',info:'<circle cx="12" cy="12" r="9"/><path d="M12 11v5M12 8h.01"/>',close:'<path d="M6 6l12 12M18 6L6 18"/>',person:'<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-6 8-6s8 2 8 6"/>',eyeoff:'<path d="M3 12s3.5-6 9-6 9 6 9 6-3.5 6-9 6-9-6-9-6zM4 4l16 16"/>'};function l(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("class","ui-ic"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false"),t.innerHTML=c[e],t}function d(e){const t=document.createElement("span");t.className=`st st-${e.tone}`;const n=document.createElement("span");n.className="dot",n.setAttribute("aria-hidden","true");const o=document.createElement("span");return o.textContent=e.text,t.append(n,o),t}function p(e){const t=document.createElement("button");t.type="button",t.className="glance-row",t.addEventListener("click",e.onOpen);const n=document.createElement("span");n.className="gi",n.append(l(e.icon));const o=document.createElement("span");o.className="gl";const a=document.createElement("b");a.textContent=e.label;const i=document.createElement("span");i.textContent=e.sublabel,o.append(a,i);const s=document.createElement("span");return s.className="gr",void 0!==e.status&&s.append(d(e.status)),s.append(l("chev")),t.append(n,o,s),t}function u(e,t){const n=e.querySelector(".gr");null!==n&&(n.querySelector(".st")?.remove(),void 0!==t&&n.prepend(d(t)))}const g={"panel.title":"TinyCloud","panel.close":"Close","panel.hide":"Hide button","panel.sections":"Sections","panel.in":"in","panel.back":"Back to","section.placeholder":"Not available yet.","view.loading":"Loading…","view.error":"This didn't load.","view.retry":"Try again","view.permission":"This session can't show this yet.","nodes.kind.hosted":"Hosted","nodes.status.down":"Down","nodes.version":"Version","nodes.latency":"Latency","activity.empty":"No requests yet.","nav.account":"Overview","nav.local-tinycloud":"Local TinyCloud","nav.local-copy":"Local copy","nav.delegations":"Delegations","nav.nodes":"Nodes","nav.storage":"Storage","nav.activity":"Activity","button.aria":"TinyCloud settings","status.storage_full":"Storage is full","status.sync_pending":"Erase not confirmed","status.sync_attention":"Local copy needs attention","storage.state.full":"Storage is full","storage.declined":"You declined. Storage usage stays hidden.","storage.try_again":"Try again","storage.unavailable":"Storage usage isn't available here.","storage.manage":"Manage storage","storage.full":"Storage is full. Free up space or upgrade to keep saving.","sync.wipe.note":"Erases TinyCloud's copy on this device. Your data stays on your TinyCloud; the app's own files are not touched.","sync.error.declined":"You declined. The local copy stays off.","sync.error.unsupported":"This browser can't keep a local copy.","sync.error.failed":"That didn't work. Try again.","sync.reason.unsupported-browser":"This browser can't keep a local copy.","sync.reason.no-eligible-scope":"No space on this TinyCloud account can keep a local copy.","sync.reason.consent-declined":"You declined. The local copy stays off.","sync.reason.storage-blocked":"This browser blocks the storage the local copy needs.","sync.reason.erase-pending":"The last erase is not confirmed yet.","sync.reason.budget-reached":"This device's local copy has reached its size limit.","sync.reason.signed-out":"Sign in to use the local copy.","sync.reason.stale-tab":"Another tab changed this. Reload to continue.","sync.reason.wipe-failed":"Erase didn't finish. The local copy may still be on this device.","sync.reason.session-expired":"Your session expired. Sign in again.","sync.reason.unknown":"Something went wrong with the local copy.","toast.done":"Done","toast.signed_in":"Successfully signed in","toast.attention":"Something needs your attention. Details are in the console.","toast.error_generic":"Something went wrong.","toast.unexpected_error":"An unexpected error occurred. Try refreshing the page.","toast.space_created":"TinyCloud Space created successfully","toast.space_creation_timeout":"Setting up your TinyCloud Space timed out","toast.space_creation_failed":"Failed to create your TinyCloud Space","toast.error.auth.wallet_not_connected":"Please connect your wallet to continue","toast.error.auth.signature_rejected":"Signature was rejected. Please try again","toast.error.auth.chain_mismatch":"Please switch to the correct network","toast.error.storage.upload_failed":"Failed to upload file. Please check your connection","toast.error.storage.insufficient_space":"Insufficient storage space available","toast.error.storage.permission_denied":"Permission denied. Please check your access rights","toast.error.network.connection_failed":"Network connection failed. Please try again","toast.error.network.timeout":"Request timed out. Please try again","toast.error.wasm.initialization_failed":"Failed to initialize security module"};function f(e){return t=e,Object.prototype.hasOwnProperty.call(g,t)?g[e]:g["sync.reason.unknown"];var t}const m={"panel.full_page":"Open full page","panel.sidebar":"Show as sidebar","toast.dismiss":"Dismiss","toast.copy_receipt":"Copy receipt","toast.copied":"Copied","toast.copy_failed":"Couldn't copy. Select the text and copy it by hand.","section.status.checking":"Checking","section.status.needs_permission":"Needs permission","section.status.unavailable":"Unavailable"},h=new Map;function y(e){for(const[t,n]of Object.entries(e))h.set(t,n)}function x(e,t={}){return(Object.prototype.hasOwnProperty.call(m,e)?m[e]:h.get(e)??f(e)).replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}const b="http://www.w3.org/2000/svg",v={page:"M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7",drawer:"M6 4h12a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3zM15 4v16"},w={page:"panel.full_page",drawer:"panel.sidebar"};function k(e){const t=document.createElement("div");t.id=o,t.className="panel",t.dataset.layout="drawer",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.setAttribute("aria-label",x("button.aria")),t.hidden=!0;let n,a="drawer",i=!1,s="page",r=!1;const c=document.createElement("h2");c.className="title",c.textContent=x("panel.title");const d=document.createElement("span");d.className="ctx",d.hidden=!0;const p=document.createElement("div");p.className="brand",p.append(c,d);const u=document.createElement("span");u.className="status",u.hidden=!0;const g=document.createElementNS(b,"svg");g.setAttribute("viewBox","0 0 24 24"),g.setAttribute("aria-hidden","true");const f=document.createElementNS(b,"path");g.append(f);const m=document.createElement("span"),h=document.createElement("button");h.type="button",h.className="action layout-switch",h.append(g,m),h.addEventListener("click",()=>e.onLayout(s)),h.hidden=!0;const y=document.createElement("button");y.type="button",y.addEventListener("click",()=>e.onClose());const k=document.createElement("span"),C=document.createElementNS(b,"svg");C.setAttribute("viewBox","0 0 24 24"),C.setAttribute("aria-hidden","true");const E=document.createElementNS(b,"path");function N(){if("drawer"===a||i)return y.className="icon-btn ring",y.setAttribute("aria-label",x("panel.close")),void y.replaceChildren(C);y.className="action",k.textContent=void 0===n?x("panel.close"):`${x("panel.back")} ${n}`,y.setAttribute("aria-label",k.textContent),y.replaceChildren(k)}E.setAttribute("d","M6 6l12 12M18 6L6 18"),C.append(E),N();const _=`${o}-menu`,A=document.createElement("button");A.type="button",A.className="icon-btn ring menu-btn",A.setAttribute("aria-label",x("panel.sections")),A.setAttribute("aria-controls",_),A.setAttribute("aria-expanded","false");const S=document.createElementNS(b,"svg");S.setAttribute("viewBox","0 0 24 24"),S.setAttribute("aria-hidden","true");const T=document.createElementNS(b,"path");T.setAttribute("d","M4 7h16M4 12h16M4 17h16"),S.append(T),A.append(S);const L=document.createElement("div");L.id=_,L.className="menu",L.hidden=!0;const z=document.createElement("div");z.className="menu-wrap",z.append(A,L);const M=document.createElement("div");M.className="head-actions",M.append(z,h,y);const $=document.createElement("header");$.className="head",$.append(p,u,M);const D=document.createElement("nav");D.className="nav",D.setAttribute("aria-label",x("panel.sections"));const O=new Map,q=document.createElement("div");function B(e){r=e,L.hidden=!e,A.setAttribute("aria-expanded",String(e))}return q.className="main",t.append($,D,q),A.addEventListener("click",()=>{if(r)return void B(!1);B(!0);const e=L.querySelector('[aria-current="page"]')??L.querySelector("button");e?.focus()}),z.addEventListener("focusout",e=>{r&&(z.contains(e.relatedTarget)||B(!1))}),t.addEventListener("keydown",t=>{if("Escape"===t.key){if(t.stopPropagation(),r)return A.focus(),void B(!1);e.onEscape()}}),{el:t,main:q,setOpen(e){t.hidden=!e,t.setAttribute("aria-modal",String(e&&"drawer"===a&&!i)),e||B(!1)},setLayout(e,n){var o;a=e,i=n.phone,t.dataset.layout=e,t.setAttribute("aria-modal",String(!t.hidden&&"drawer"===e&&!i)),s="drawer"===e?"page":"drawer",o=s,f.setAttribute("d",v[o]),m.textContent=x(w[o]),h.hidden=!n.showLayoutToggle,i||B(!1),N()},setAppLabel(e){n=e,d.hidden=void 0===e,d.textContent=void 0===e?"":`${x("panel.in")} ${e}`,N()},setNav(t,n){const o=new Set(t.map(e=>e.id));for(const[e,t]of O)o.has(e)||(t.btn.remove(),t.pick.remove(),O.delete(e));t.forEach((t,o)=>{let a=O.get(t.id);a||(a=function(t){const n=document.createElement("button");n.type="button",n.className="nav-i",n.dataset.section=t.id;const o=document.createElement("span");o.className="nav-n",o.setAttribute("aria-hidden","true");const a=l(t.icon);a.classList.add("nav-ic");const i=document.createElement("span");i.className="nav-l",i.textContent=x(t.labelCode);const s=document.createElement("span");s.className="nav-m",s.setAttribute("aria-hidden","true"),n.append(a,o,i,s),n.addEventListener("click",()=>e.onNavigate(t.id));const r=document.createElement("button");return r.type="button",r.className="menu-i",r.dataset.section=t.id,r.textContent=x(t.labelCode),r.addEventListener("click",()=>{return n=t.id,B(!1),e.onNavigate(n),void function(){const e=q.querySelector(".sec-title")??q.firstElementChild;e instanceof HTMLElement&&(e.tabIndex=-1,e.focus())}();var n}),{btn:n,index:o,meta:s,pick:r}}(t),O.set(t.id,a)),a.index.textContent=String(o+1).padStart(2,"0"),a.meta.textContent=t.meta??"",void 0===t.meta?a.btn.removeAttribute("aria-description"):a.btn.setAttribute("aria-description",t.meta),D.children[o]!==a.btn&&D.insertBefore(a.btn,D.children[o]??null),L.children[o]!==a.pick&&L.insertBefore(a.pick,L.children[o]??null);const i=t.id===n;for(const e of[a.btn,a.pick])i?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current")})},setStatus(e){u.hidden=null===e,u.textContent=null===e?"":x(`status.${e}`)},focusFirst(){i?A.focus():(D.querySelector('[aria-current="page"]')??y).focus()}}}function C(e,t,n){return 0===e?-1:n?t<=0?e-1:t-1:t<0||t>=e-1?0:t+1}var E;const N=Symbol.for("tinycloud.web-sdk.prompt-state"),_=(E=globalThis)[N]??(E[N]={open:new Set,layer:void 0}),A="tinycloud-prompt-settled";function S(){for(const e of _.open)if(e.element?.isConnected&&!e.element.hidden)return!0;return!1}const T='button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],[tabindex]:not([tabindex="-1"])';function L(e){return"function"==typeof e.checkVisibility?e.checkVisibility({visibilityProperty:!0}):null===e.closest("[hidden]")}const z={info:"info",success:"check",warning:"warn",error:"warn"};function M(e){const t=document.createElement("button");return t.type="button",t.className="toast__close",t.setAttribute("aria-label",x("toast.dismiss")),t.append(l("close")),t.addEventListener("click",e),t}function $(e){const t=document.createElement("div");t.className=`toast toast--${e}`,t.setAttribute("role","error"===e?"alert":"status");const n=document.createElement("span");n.className="toast__icon",n.append(l(z[e]));const o=document.createElement("div");o.className="toast__body";const a=document.createElement("div");return a.className="toast__message",o.append(a),t.append(n,o),{el:t,body:o,message:a}}const D=()=>!0;function O(e){const t=document.createElement("h3");t.className="sec-title",t.textContent=f(`nav.${e.dataset.section??""}`);const n=document.createElement("p");return n.className="note",n.textContent=f("section.placeholder"),e.append(t,n),()=>{}}y({"account.copied":"DID copied","account.copy_failed":"Could not copy the DID","account.signed_out":"TinyCloud is signed out in this app. Sign in to see your account.","account.signed_in_as":"Signed in as","account.copy_did":"Copy your DID","account.hint":"Need more room? Choose Open full page, at the top, for these same sections on a full screen.","account.button.title":"This button","account.button.body":"TinyCloud shows a round button at the bottom right of {app}. If you'd rather open TinyCloud from the app's own settings, hide it.","account.button.app":"this app","account.button.dev.lead":"For developers.","account.button.dev.body":"Once the button is hidden, your app needs its own way back in: add a place in your settings that calls","account.button.dev.tail":"TinyCloud doesn't bring the button back on its own.","account.loading":"Loading account…","account.unavailable":"Account details are unavailable.","account.session.label":"Session","account.session.expires":"Expires in {hours}h {minutes}m","account.app.label":"You're in","account.glance.title":"At a glance","account.signout.button":"Sign out","account.signout.question":"Sign out of TinyCloud on this device?","account.signout.cancel":"Stay signed in","account.signout.confirm":"Sign out","account.signout.busy":"Signing out…","account.signout.failed":"Sign-out failed. Try again.","account.status.signed_out":"Signed out"});const q='"Literata Variable","Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif',B='ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace',I=`\n.account-hint{margin:-14px 0 28px;font-size:12.5px;line-height:1.4}\n.account-cols{display:grid;gap:28px 36px;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));align-items:start}\n.account-ident{display:flex;gap:16px;align-items:center;min-width:0}\n.account-avatar{flex:none;width:64px;height:64px;border-radius:50%;display:grid;place-items:center;font:500 30px/1 ${q};background:#09090b;color:#fff}\n.account-who{min-width:0}\n.account-ident .eyebrow{margin:0;font-size:13px;font-weight:600;line-height:1.3;color:#71717a}\n.account-ident .name{margin:0;font:500 1.375rem/1.2 ${q};overflow-wrap:anywhere}\n.account-idline{display:flex;flex-wrap:wrap;align-items:center;margin-top:2px;min-width:0}\n.account-did{min-width:0;font:.8125rem/1.5 ${B};color:#71717a;overflow-wrap:anywhere}\n.account-copy{flex:none}\n.account-copy .ui-ic{width:16px;height:16px;stroke-width:2}\n.account-kv{display:flex;flex-direction:column;margin:18px 0 0;padding:0}\n.account-kv>div{display:flex;align-items:center;gap:10px;box-sizing:border-box;min-height:44px;padding:9px 0;border-bottom:1px solid #e4e4e7}\n.account-kv>div:last-child{border-bottom:0}\n.account-kv dt{display:flex;flex:1 1 auto;align-items:baseline;gap:10px;min-width:0;font-size:14px;white-space:nowrap}\n.account-kv dt::after{content:"";flex:1 1 12px;min-width:12px;border-bottom:2px dotted #a1a1aa;transform:translateY(-3px)}\n.account-kv dd{display:flex;flex:0 1 auto;align-items:center;justify-content:flex-end;gap:2px;max-width:78%;margin:0;font-size:14px;font-weight:600;text-align:right;overflow-wrap:anywhere}\n.account-kv .account-host{margin-left:8px;font:400 .8125rem ${B};color:#71717a}\n.account-signout{margin-top:14px}\n.account-glance{display:flex;flex-direction:column;gap:0}\n.account-rule{display:flex;align-items:center;gap:10px;margin:0 0 12px;font-size:13px;font-weight:600;line-height:1.3;letter-spacing:.02em}\n.account-rule::after{content:"";flex:1;height:1px;background:#e4e4e7}\n.account-button{display:flex;flex-direction:column;align-items:flex-start;gap:12px;margin-top:28px}\n.account-button>*{margin:0}\n.account-button .account-rule{align-self:stretch;margin:0}\n.account-small{max-width:60ch;font-size:14px;line-height:1.45}\n.account-devnote{display:flex;gap:12px;align-items:flex-start;box-sizing:border-box;width:100%;padding:14px 16px;border-radius:12px;box-shadow:inset 0 0 0 1px #e4e4e7;font-size:13.5px;line-height:1.5}\n.account-devnote .ui-ic{margin-top:2px;flex:none}\n.account-devnote code{padding:1px 6px;border-radius:6px;background:#f4f4f5;font:600 .8125rem ${B}}\n@media (prefers-color-scheme: dark){\n.account-avatar{background:#fafafa;color:#09090b}\n.account-ident .eyebrow,.account-did,.account-kv .account-host{color:#a1a1aa}\n.account-kv>div{border-bottom-color:#69696b}\n.account-kv dt::after{border-bottom-color:#71717a}\n.account-rule::after{background:#69696b}\n.account-devnote{box-shadow:inset 0 0 0 1px #69696b}\n.account-devnote code{background:#27272a}\n}\n`,R={id:"account",labelCode:"nav.account",icon:"person",isAvailable:D,status:e=>!0===e.client()?.signedIn()?void 0:{text:e.text("account.status.signed_out"),tone:"off"},mount:function(e,t){const n=t.client(),o=document.createElement("style");o.textContent=I+a;const s=document.createElement("h3");s.className="sec-title",s.tabIndex=-1,s.textContent=t.text("nav.account"),e.append(o,s);let c,g,f=!1,m=0,h={state:"loading"},y=!1,x=!1;const b=document.createElement("p");b.className="note",b.textContent=t.text("account.signed_out");const v=document.createElement("p");v.className="account-hint",v.textContent=t.text("account.hint");const w=document.createElement("div");w.className="account-cols";const k=document.createElement("div"),C=document.createElement("div");C.className="account-ident";const E=document.createElement("div");E.className="account-avatar",E.setAttribute("aria-hidden","true");const N=document.createElement("div");N.className="account-who";const _=document.createElement("p");_.className="eyebrow",_.textContent=t.text("account.signed_in_as");const A=document.createElement("p");A.className="name";const S=document.createElement("div");S.className="account-idline";const T=document.createElement("span");T.className="account-did";const L=document.createElement("button");L.type="button",L.className="icon-btn account-copy",L.setAttribute("aria-label",t.text("account.copy_did")),L.append(l("copy")),S.append(T,L),N.append(_,A,S),C.append(E,N);const z=document.createElement("p");z.className="note";const M=document.createElement("dl");M.className="account-kv";const $=document.createElement("div"),D=document.createElement("dt");D.textContent=t.text("account.session.label");const O=document.createElement("dd");$.append(D,O);const q=document.createElement("div"),B=document.createElement("dt");B.textContent=t.text("account.app.label");const R=document.createElement("dd"),j=document.createTextNode(""),P=document.createElement("span");P.className="account-host",R.append(j,P),q.append(B,R),M.append($,q);const F=i(t.text("account.signout.button"));F.classList.add("account-signout"),F.prepend(l("out"));const Y=document.createElement("p");Y.className="note",Y.textContent=t.text("account.signout.failed");const W=document.createElement("div");W.hidden=!0,k.append(C,z,M,F,Y,W);const U=document.createElement("div"),H=document.createElement("h4");H.className="account-rule",H.textContent=t.text("account.glance.title");const V=document.createElement("div");V.className="glance account-glance";const G=[];for(const e of t.sections()){if("account"===e.id||void 0===e.summaryCode)continue;const n=p({icon:e.icon,label:t.text(e.labelCode),sublabel:t.text(e.summaryCode),onOpen:()=>t.openSection(e.id)});G.push({section:e,row:n}),V.append(n)}if(U.append(H,V),w.append(k,U),e.append(b,v,w),t.canHideButton()){const n=document.createElement("div");n.className="account-button";const o=document.createElement("h4");o.className="account-rule",o.textContent=t.text("account.button.title");const a=document.createElement("p");a.className="account-small",a.textContent=t.text("account.button.body").replace("{app}",t.appLabel()??t.text("account.button.app"));const s=i(t.text("panel.hide"));s.prepend(l("eyeoff")),s.addEventListener("click",()=>t.hideButton());const r=document.createElement("div");r.className="account-devnote";const c=document.createElement("b");c.textContent=t.text("account.button.dev.lead");const d=document.createElement("code");d.textContent="tc.ui.open()";const p=document.createElement("div");p.append(c,` ${t.text("account.button.dev.body")} `,d,`. ${t.text("account.button.dev.tail")}`),r.append(l("info"),p),n.append(o,a,s,r),e.append(n)}function K(){if(f)return;const e=!0===n?.signedIn();if(b.hidden=e,v.hidden=!e||"drawer"!==t.layout(),w.hidden=!e,!e)return;const o="ready"===h.state?h.data:void 0,a=void 0===o?n?.data?.knownDid?.():void 0,i=void 0===o?t.appLabel():void 0;if(z.hidden=void 0!==o,z.textContent="loading"===h.state?t.text("account.loading"):void 0===o?t.text("account.unavailable"):"",g=o?.did??a,C.hidden=void 0===g,M.hidden=void 0===o&&void 0===i,void 0!==g){const e=(s=g).length>26?`${s.slice(0,20)}…${s.slice(-4)}`:s,t=o?.displayName??e;A.textContent=t,A.title=void 0===o?.displayName?g:"",E.textContent=t.charAt(0).toUpperCase(),T.textContent=e,T.title=g,T.hidden=void 0===o?.displayName}var s;if($.hidden=void 0===o?.sessionExpiresAt,void 0!==o?.sessionExpiresAt){const{hours:e,minutes:n}=function(e,t){const n=Math.max(0,Math.ceil((e.getTime()-t)/6e4));return{hours:Math.floor(n/60),minutes:n%60}}(o.sessionExpiresAt,Date.now()),a=t.text("account.session.expires").replace("{hours}",String(e)).replace("{minutes}",String(n).padStart(2,"0"));O.replaceChildren(d({text:a,tone:"ok"}))}const r=o?.appName??i;q.hidden=void 0===r,void 0!==r&&(j.textContent=r),P.textContent=o?.appHost??"",P.hidden=void 0===o?.appHost,F.hidden=void 0===n?.signOut,F.disabled=y,Y.hidden=!x}function X(){if(!f&&!0===n?.signedIn())for(const{section:e,row:n}of G)u(n,e.status(t))}function Z(){c=void 0,W.replaceChildren(),W.hidden=!0}async function J(){const e=++m,t=n?.data;if(!t)return h={state:"error",code:"unavailable"},void K();let o;h="ready"===h.state||"error"===h.state?h:{state:"loading"},K();try{o=await t.account()}catch{o={state:"error",code:"unknown"}}f||e!==m||(h=o,K())}F.addEventListener("click",()=>function(){if(c)return;const e=r({question:t.text("account.signout.question"),cancelLabel:t.text("account.signout.cancel"),confirmLabel:t.text("account.signout.confirm"),onCancel:()=>{Z(),F.focus()},onConfirm:()=>{!async function(){if(!n?.signOut||y)return;y=!0,x=!1,c&&(c.confirm.disabled=!0,c.cancel.disabled=!0,c.confirm.textContent=t.text("account.signout.busy")),K();let e=!0;try{await n.signOut()}catch{e=!1}if(y=!1,!f){if(Z(),e)return await J(),void s.focus();x=!0,K(),F.focus()}}()}});c=e,W.replaceChildren(e.el),W.hidden=!1,e.cancel.focus()}()),L.addEventListener("click",()=>{!async function(){if(void 0===g)return;const e=g,n=t.data.generation();let o=!0;try{await navigator.clipboard.writeText(e)}catch{o=!1}f||n!==t.data.generation()||t.toast(o?{kind:"success",textCode:"account.copied"}:{kind:"error",textCode:"account.copy_failed"})}()});const Q=n?.onReset(()=>{h={state:"loading"},J()}),ee=t.data.subscribe(X),te=n?.data?.subscribe(e=>{"overview"===e&&"error"===h.state&&J()}),ne=setInterval(K,6e4);return J(),X(),()=>{f=!0,clearInterval(ne),Q?.(),ee(),te?.(),e.replaceChildren()}}};y({"activity.summary":"Recent requests this session","activity.glance.no_errors":"No errors","activity.glance.errors":"{count} errors","activity.glance.clear":"Clear","activity.chip":"Developer mode","activity.lede":"Every request this app makes to TinyCloud, newest first. Only the first path segment is shown.","activity.devnote_title":"Developer mode is set by {app} in code,","activity.devnote":"in the SDK config. It isn't a user setting, and people using {app} never see this section.","activity.app_fallback":"this app","activity.count_of":" of {total} requests · ","activity.count_error_one":" error","activity.count_error_many":" errors","activity.cap":"Showing the newest {shown} requests.","activity.errors_only":"Errors only","activity.pause":"Pause live","activity.resume":"Resume live","activity.copy_all":"Copy all","activity.copy_one":"Copy request: {target} at {time}","activity.copied_one":"Request copied.","activity.copied_many":"Requests copied as text.","activity.copy_failed":"Could not copy. Select the text and copy it by hand.","activity.no_errors_table":"No errors. Everything this app asked for went through.","activity.table_label":"Request log","activity.col.time":"Time","activity.col.op":"Operation","activity.col.path":"Path","activity.col.space":"Space","activity.col.host":"Host","activity.col.bytes":"Bytes","activity.col.took":"Took","activity.col.result":"Result","activity.col.source":"Source","activity.col.copy":"Copy","activity.res_ok":"ok","activity.res_unknown":"unknown","activity.unavailable":"The request log can't be read right now.","activity.no_errors_unsure":"No failed requests in the log. Some requests have no recorded result.","activity.host_local":"this device","activity.node":"Node","activity.local_copy":"Local copy","activity.on":"On","activity.off":"Off"});const j="—",P='ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace',F=`\n.act-root{container:act/inline-size;min-width:0}\n.act-head{display:flex;flex-direction:column;gap:8px;margin:0 0 36px}\n.act-head-row{display:flex;flex-wrap:wrap;align-items:baseline;gap:8px 12px}\n.act-head .sec-title{margin:0}\n.act-chip{display:inline-flex;align-items:center;height:28px;padding:0 11px;border-radius:999px;box-shadow:inset 0 0 0 1px #e4e4e7;font-size:12.5px;font-weight:600;white-space:nowrap}\n.act-lede{margin:0;max-width:56ch;font-size:15px;line-height:1.5}\n.act-devnote{display:flex;gap:12px;align-items:flex-start;box-sizing:border-box;margin:0 0 36px;padding:14px 16px;border-radius:12px;box-shadow:inset 0 0 0 1px #e4e4e7;font-size:13.5px;line-height:1.5}\n.act-devnote .ui-ic{margin-top:2px}\n.act-devnote p{margin:0}\n.act-tools{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin:0 0 36px}\n.act-count{margin:0;font-size:14px;line-height:1.45}\n.act-count b{font-weight:700}\n.act-chk{display:inline-flex;align-items:center;gap:10px;min-height:44px;font-size:14px;font-weight:600}\n.act-btns{display:flex;flex-wrap:wrap;align-items:center;gap:10px}\n.act-cap{margin:0 0 10px;font-size:12.5px;color:#71717a}\n.act-table{display:flex;flex-direction:column;border-radius:16px;box-shadow:inset 0 0 0 1px #e4e4e7;overflow:hidden;background:#ffffff}\n.act-ar{position:relative;display:flex;flex-wrap:wrap;align-items:center;gap:0 8px;padding:10px 4px 10px 12px;border-bottom:1px solid #e4e4e7;font-size:13px;font-variant-numeric:tabular-nums}\n.act-ar:last-child{border-bottom:0}\n.act-ar>*{min-width:0}\n.act-err{background:linear-gradient(90deg,#09090b 0 3px,transparent 3px)}\n.act-hd{display:none;background:#fafafa}\n.act-c-time{order:1;font-family:${P};font-size:12.5px;color:#71717a}\n.act-c-op{order:2;font-family:${P};font-weight:700;font-size:13px;overflow-wrap:anywhere}\n.act-c-path{order:3;font-family:${P};font-size:13px;overflow-wrap:anywhere}\n.act-c-res{order:4;display:inline-flex;align-items:center;gap:6px;font-weight:500;overflow-wrap:anywhere}\n.act-err .act-c-res{font-weight:700}\n.act-c-res .ui-ic{width:14px;height:14px}\n.act-err .act-c-res .ui-ic{color:#8a3f05}\n.act-c-source{order:4;font-size:12.5px;color:#71717a}\n.act-c-copy{order:5;display:flex;align-items:center;justify-content:center;width:44px;height:44px;margin:-9px -2px -9px auto}\n.act-br{order:6;flex-basis:100%;height:0}\n.act-c-space,.act-c-host,.act-c-bytes,.act-c-took{order:7;font-size:12.5px;color:#71717a;overflow-wrap:anywhere}\n.act-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.act-empty{padding:14px 16px;font-size:13.5px;color:#71717a}\n.act-facts{display:grid;gap:0 32px;grid-template-columns:minmax(0,1fr);margin:28px 0 0;padding:0}\n.act-facts>div{display:flex;align-items:center;gap:10px;box-sizing:border-box;min-height:44px;padding:9px 0;border-bottom:1px solid #e4e4e7}\n.act-facts dt{display:flex;flex:1 1 auto;align-items:baseline;gap:10px;min-width:0;font-size:14px;white-space:nowrap}\n.act-facts dt::after{content:"";flex:1 1 12px;min-width:12px;border-bottom:2px dotted #a1a1aa;transform:translateY(-3px)}\n.act-facts dd{margin:0;max-width:78%;font-size:14px;font-weight:600;text-align:right;overflow-wrap:anywhere}\n.act-facts .act-mono{font:600 .8125rem ${P}}\n@container act (min-width:720px){\n.act-tools{flex-direction:row;align-items:center;gap:20px}\n.act-count{margin-right:auto}\n.act-table{--act-cols:minmax(62px,70fr) minmax(64px,110fr) minmax(64px,100fr) minmax(64px,80fr) minmax(70px,150fr) minmax(58px,62fr) minmax(58px,64fr) minmax(84px,110fr) minmax(56px,56fr) 44px}\n.act-ar{display:grid;grid-template-columns:var(--act-cols);gap:0 8px;padding:0 6px 0 14px;min-height:48px}\n.act-ar>*{order:0!important}\n.act-c-copy{margin:0}\n.act-br{display:none}\n.act-c-bytes,.act-c-took{text-align:right}\n.act-hd{display:grid;min-height:40px}\n.act-hd>*{font:600 11px ${P}!important;letter-spacing:.08em;text-transform:uppercase;color:#71717a}\n.act-facts{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}\n}\n@media (prefers-reduced-motion:no-preference){\n.act-new{animation:act-in .5s cubic-bezier(.22,1,.36,1)}\n@keyframes act-in{from{opacity:0;transform:translateY(-8px);background-color:#f4f4f5}}\n}\n@media (prefers-color-scheme: dark){\n.act-chip,.act-devnote{box-shadow:inset 0 0 0 1px #69696b}\n.act-cap,.act-empty,.act-c-time,.act-c-source,.act-c-space,.act-c-host,.act-c-bytes,.act-c-took{color:#a1a1aa}\n.act-table{background:#151517;box-shadow:inset 0 0 0 1px #69696b}\n.act-ar,.act-facts>div{border-bottom-color:#69696b}\n.act-err{background:linear-gradient(90deg,#fafafa 0 3px,transparent 3px)}\n.act-err .act-c-res .ui-ic{color:#fbbd23}\n.act-hd{background:#151517}\n.act-hd>*{color:#a1a1aa}\n.act-facts dt::after{border-bottom-color:#71717a}\n@media (prefers-reduced-motion:no-preference){\n@keyframes act-in{from{opacity:0;transform:translateY(-8px);background-color:#27272a}}\n}\n}\n`,Y=/[\p{Cc}\p{Cf}\u2028\u2029]/gu,W=/^[A-Za-z0-9_.:-]{1,64}$/;function U(e,t){if("string"!=typeof e)return;const n=e.replace(Y," ").trim();return""===n?void 0:n.slice(0,t)}function H(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function V(e){if("object"!=typeof e||null===e)return;const t=e,n="number"==typeof t.id&&Number.isFinite(t.id)?String(t.id):U(t.id,64),o=U(t.code,64),a={key:"",at:"number"==typeof t.at&&Number.isFinite(t.at)?t.at:void 0,op:U(t.op,64)??j,path:U(t.path,256),space:U(t.space,64),host:U(t.host,128),bytes:H(t.bytes),durationMs:H(t.durationMs),ok:"boolean"==typeof t.ok?t.ok:void 0,code:void 0!==o&&W.test(o)?o:void 0,source:"replica"===t.source||"network"===t.source?t.source:void 0},i=[a.at,a.op,a.path,a.space,a.host,a.bytes,a.durationMs,a.ok,a.code,a.source];return{...a,key:n??`~${i.join("|")}`}}function G(e){if(void 0===e)return;let t;try{t=e.snapshot()}catch{return}if(!Array.isArray(t))return;const n=[],o=new Map;for(const e of t){const t=V(e);if(void 0===t)continue;const a=o.get(t.key)??0;o.set(t.key,a+1),n.push(0!==a&&t.key.startsWith("~")?{...t,key:`${t.key}#${a}`}:t)}return n}function K(e){const t=new Date(e),n=e=>String(e).padStart(2,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function X(e,t){let n=e("activity.res_unknown");!0===t.ok?n=e("activity.res_ok"):!1===t.ok&&(n=t.code??e("activity.res_unknown"));let o=j;return"replica"!==t.source&&"network"!==t.source||(o=t.source),[void 0===t.at?j:K(t.at),t.op,t.path??j,t.space??j,t.host??("replica"===t.source?e("activity.host_local"):j),void 0===t.bytes?j:(a=t.bytes,a>=1048576?`${(a/1048576).toFixed(1)} MiB`:a>=1024?`${(a/1024).toFixed(1)} KiB`:`${a} B`),void 0===t.durationMs?j:`${t.durationMs} ms`,n,o];var a}let Z=0;const J={id:"activity",labelCode:"nav.activity",icon:"term",summaryCode:"activity.summary",isAvailable:e=>e.developerMode(),status(e){const t=e.client()?.requests;if(void 0===t)return;const n=G(t);if(void 0===n)return;const o=n.filter(e=>!1===e.ok).length;return o>0?{text:e.text("activity.glance.errors",{count:o}),tone:"warn"}:n.some(e=>void 0===e.ok)?void 0:{text:e.text("activity.glance.no_errors"),tone:"ok",count:e.text("activity.glance.clear")}},mount(e,t){const n=t.client()?.requests;return n?function(e,t,n){const o=t.text,s=document.createElement("div");s.className="act-root";const r=document.createElement("style");r.textContent=F+a;const c=document.createElement("div");c.className="act-head";const d=document.createElement("div");d.className="act-head-row";const p=document.createElement("h3");p.className="sec-title",p.tabIndex=-1,p.textContent=o("nav.activity");const u=document.createElement("span");u.className="act-chip",u.textContent=o("activity.chip"),d.append(p,u);const g=document.createElement("p");g.className="act-lede",g.textContent=o("activity.lede"),c.append(d,g);const f=t.appLabel()??o("activity.app_fallback"),m=document.createElement("div");m.className="act-devnote";const h=document.createElement("p"),y=document.createElement("b");y.textContent=o("activity.devnote_title",{app:f}),h.append(y,` ${o("activity.devnote",{app:f})}`),m.append(l("info"),h);const x=document.createElement("p");x.className="act-count";const b=document.createElement("b"),v=document.createTextNode(""),w=document.createElement("b"),k=document.createTextNode("");x.append(b,v,w,k);const C=document.createElement("span");C.id="act-eo-"+ ++Z,C.textContent=o("activity.errors_only");const E=document.createElement("button");E.type="button",E.className="switch",E.setAttribute("role","switch"),E.setAttribute("aria-labelledby",C.id);const N=document.createElement("span");N.className="knob",E.append(N);const _=document.createElement("label");_.className="act-chk",_.append(C,E);const A=i(o("activity.pause")),S=i(o("activity.copy_all"));S.prepend(l("copy"));const T=document.createElement("div");T.className="act-btns",T.append(A,S);const L=document.createElement("div");L.className="act-tools",L.append(x,_,T);const z=document.createElement("p");z.className="act-cap",z.hidden=!0;const M=document.createElement("div");M.className="act-table",M.setAttribute("role","table"),M.setAttribute("aria-label",o("activity.table_label"));const $=function(e){const t=document.createElement("div");t.className="act-ar act-hd",t.setAttribute("role","row");for(const[n,o]of ee)t.append(Q(n,"columnheader",e(o)));return t.append(Q("act-sr","columnheader",e("activity.col.copy"))),t}(o),D=document.createElement("div");D.className="act-empty",D.setAttribute("role","row");const O=document.createElement("span");O.setAttribute("role","cell"),D.append(O);const q=document.createElement("dl");q.className="act-facts";const B=document.createElement("div"),I=document.createElement("dt");I.textContent=o("activity.node");const R=document.createElement("dd");R.className="act-mono",B.append(I,R);const P=document.createElement("div"),Y=document.createElement("dt");Y.textContent=o("activity.local_copy");const W=document.createElement("dd");P.append(Y,W),q.append(B,P),s.append(r,c,m,L,z,M,q),e.append(s);let U,H,V=!1,J=n,te=!1,ne=!1,oe=new Set;const ae=new Map;let ie=[];function se(e){const t=X(o,e),n=document.createElement("div");n.className=!1===e.ok?"act-ar act-err":"act-ar",n.setAttribute("role","row"),ee.forEach(([o],a)=>{const i=t[a]??j;if("act-c-res"!==o)return void n.append(Q(o,"cell",i));const s=Q(o,"cell","");!1===e.ok&&s.append(l("warn")),s.append(i),n.append(s)});const a=document.createElement("span");a.className="act-c-copy",a.setAttribute("role","cell");const i=document.createElement("button");i.type="button",i.className="icon-btn";const s=void 0===e.path?e.op:`${e.op} ${e.path}`,r=void 0===e.at?j:K(e.at);i.setAttribute("aria-label",o("activity.copy_one",{target:s,time:r})),i.append(l("copy")),i.addEventListener("click",()=>{le([e],"activity.copied_one")}),a.append(i);const c=document.createElement("span");return c.className="act-br",c.setAttribute("aria-hidden","true"),n.append(a,c),n}function re(){const e=function(){const e=t.data.latest("nodes");if("ready"!==e?.state)return;const n=e.data,o=n.find(e=>e.active)??n[0];if(void 0===o)return;const a=function(e){try{return new URL(e).host}catch{return e}}(o.origin);return void 0===o.version?a:`${a} · ${/^v/i.test(o.version)?o.version:`v${o.version}`}`}();B.hidden=void 0===e,void 0!==e&&(R.textContent=e);const n=t.client()?.sync;if(P.hidden=void 0===n,void 0!==n){const e="on"===n.state.effective||"pending"===n.state.effective;W.textContent=o(e?"activity.on":"activity.off")}q.hidden=B.hidden&&P.hidden}function ce(){const e=U??G(J),t=e??[],n=[...t].reverse(),a=t.filter(e=>!1===e.ok).length,i=V?n.filter(e=>!1===e.ok):n,s=new Set;ie=[];for(const e of i){if(100===ie.length)break;s.has(e.key)||(s.add(e.key),ie.push(e))}x.hidden=void 0===e,b.textContent=String(ie.length),v.data=o("activity.count_of",{total:t.length});const r=0===a&&t.some(e=>void 0===e.ok);w.textContent=r?j:String(a),k.data=o(1===a?"activity.count_error_one":"activity.count_error_many"),z.hidden=i.length<=ie.length,z.textContent=o("activity.cap",{shown:ie.length});const c=[$];for(const e of ie){let t=ae.get(e.key);void 0===t&&(t=se(e),ne&&!oe.has(e.key)&&t.classList.add("act-new"),ae.set(e.key,t)),c.push(t)}0===ie.length&&(void 0===e?O.textContent=o("activity.unavailable"):0===t.length?O.textContent=o("activity.empty"):O.textContent=o(r?"activity.no_errors_unsure":"activity.no_errors_table"),c.push(D));const l=new Set(c);for(const[e,t]of ae)l.has(t)||ae.delete(e);for(c.forEach((e,t)=>{const n=M.children[t];n!==e&&M.insertBefore(e,n??null)});M.children.length>c.length;)M.lastElementChild?.remove();void 0!==e&&(oe=new Set(t.map(e=>e.key))),ne=!0,E.setAttribute("aria-checked",String(V)),A.textContent=o(void 0===U?"activity.pause":"activity.resume"),S.disabled=0===ie.length,re()}async function le(n,a){if(0===n.length)return;const i=await async function(e,t){try{return await navigator.clipboard.writeText(t),!0}catch{}const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly",""),n.style.cssText="position:fixed;opacity:0;top:0;left:0",e.append(n);try{return n.select(),document.execCommand("copy")}catch{return!1}finally{n.remove()}}(e,n.map(e=>X(o,e).join(" ")).join("\n"));te||t.toast(i?{kind:"success",textCode:a}:{kind:"error",textCode:"activity.copy_failed"})}E.addEventListener("click",()=>{V=!V,ce()}),A.addEventListener("click",()=>{U=void 0===U?G(J):void 0,ce()}),S.addEventListener("click",()=>{le(ie,"activity.copied_many")});let de=0,pe=[];function ue(){for(const e of pe)e();de+=1;const e=de,n=t.client();J=n?.requests,U=void 0,void 0!==H&&cancelAnimationFrame(H),H=void 0,ae.clear(),oe=new Set,ne=!1,pe=[],void 0!==J&&pe.push(J.subscribe(()=>{e===de&&(te||void 0!==H||(H=requestAnimationFrame(()=>{H=void 0,te||(void 0===U&&ce(),t.requestRender())})))}),J.onClear(()=>{e!==de||te||(U=void 0,void 0!==H&&cancelAnimationFrame(H),H=void 0,ce(),t.requestRender())}));const o=n?.onReset(ge);void 0!==o&&pe.push(o);const a=n?.sync?.subscribe(()=>{e!==de||te||re()});void 0!==a&&pe.push(a)}function ge(){te||(ue(),ce(),t.requestRender())}ue();const fe=t.onClientChange(ge),me=t.data.subscribe(()=>{te||re()});return ce(),()=>{te=!0,de+=1;for(const e of pe)e();fe(),me(),void 0!==H&&cancelAnimationFrame(H),ae.clear(),e.replaceChildren()}}(e,t,n):O(e)}};function Q(e,t,n){const o=document.createElement("span");return o.className=e,o.setAttribute("role",t),o.textContent=n,o}const ee=[["act-c-time","activity.col.time"],["act-c-op","activity.col.op"],["act-c-path","activity.col.path"],["act-c-space","activity.col.space"],["act-c-host","activity.col.host"],["act-c-bytes","activity.col.bytes"],["act-c-took","activity.col.took"],["act-c-res","activity.col.result"],["act-c-source","activity.col.source"]];function te(e,t,n){if(void 0===e.data.source)return{text:e.text("section.status.unavailable"),tone:"info"};if(void 0!==t)switch(t.state){case"loading":return{text:e.text("section.status.checking"),tone:"info"};case"needs-permission":return{text:e.text("section.status.needs_permission"),tone:"info"};case"error":return{text:e.text("section.status.unavailable"),tone:"info"};case"ready":return n(t.data)}}const ne={"freshness.updating":"Updating…","freshness.updated":"Updated {age}","freshness.failed":"Couldn't refresh. Showing data from {age}.","freshness.age.now":"just now","freshness.age.minutes":"{n} min ago","freshness.age.hours":"{n} h ago","freshness.age.days":"{n} d ago"};function oe(e){return ne[e]}const ae={loading:"view.loading","needs-permission":"view.permission",error:"view.error"};function ie(e,t){const n=document.createElement("p");return n.className=e,n.textContent=t,n}function se(e,t){const n=ie("busy","");n.setAttribute("role","status"),n.hidden=!0;const o=document.createElement("button");return o.type="button",o.className="action",o.textContent=e.text("view.retry"),o.hidden=!0,o.addEventListener("click",()=>t()),{status:n,retry:o}}function re(e,t,n){if("ready"===n.state){e.retry.hidden=!0;const t=n.freshness?function(e){if(e.refreshing)return oe("freshness.updating");const t=function(e){const t=Math.floor(e/6e4);if(t<1)return oe("freshness.age.now");if(t<60)return oe("freshness.age.minutes").replace("{n}",String(t));const n=Math.floor(t/60);return n<24?oe("freshness.age.hours").replace("{n}",String(n)):oe("freshness.age.days").replace("{n}",String(Math.floor(n/24)))}(Date.now()-e.updatedAt);return oe(e.lastError?"freshness.failed":"freshness.updated").replace("{age}",t)}(n.freshness):void 0;return e.status.hidden=void 0===t,e.status.textContent=t??"",n.data}e.status.hidden=!1,e.status.textContent=t.text(ae[n.state]),e.retry.hidden="error"!==n.state}function ce(e,t){re(e,t,{state:"loading"})}function le(e){return Promise.resolve().then(e).catch(()=>({state:"error",code:"unknown"}))}y({"delegations.summary":"Who can act on your data","delegations.glance.visible":"Visible","delegations.lede":"Who can use your TinyCloud, and what they can do.","delegations.unavailable":"Delegations aren't available here.","delegations.denied":"This session doesn't have access to this list.","delegations.app.fallback":"this app","delegations.app.subject":"This app","delegations.g.app":"Granted to {app}","delegations.g.app.sub":"Access {app} holds on this device.","delegations.g.others":"Granted to others","delegations.g.others.sub":"Other apps and agents you gave access to.","delegations.g.received":"Received","delegations.g.received.sub":"Access that other people or apps gave you.","delegations.g.none":"Nothing here.","delegations.g.none.more":"None in what's loaded so far.","delegations.party.unknown":"Unknown","delegations.firstpage":"Showing {count}. There are more.","delegations.more.btn":"Show more","delegations.more.busy":"Loading…","delegations.more.err":"Couldn't load more.","delegations.reload":"Reload list","delegations.more.loaded":"{count} more loaded.","delegations.empty.title":"No one has access yet","delegations.empty.body":"When you give an app or an agent access to your TinyCloud, it shows up here, with what it can do and when it ends. You can take access back at any time.","delegations.loading":"Loading delegations","delegations.error":"The list of delegations didn't load.","delegations.ask.title":"{app} can't list delegations yet","delegations.ask.body":"To show who has access, TinyCloud needs your permission to read your list of delegations. It can't change them.","delegations.ask.openkey":" You'll approve it in OpenKey.","delegations.ask.button":"Allow delegation list","delegations.ask.declined":"That wasn't allowed, so nothing changed.","delegations.kind.app":"This app","delegations.kind.others":"Granted by you","delegations.kind.received":"Shared with you by {who}","delegations.st.active":"Active","delegations.st.soon":"Expiring soon","delegations.st.expired":"Expired","delegations.st.revoked":"Revoked","delegations.st.pending":"Not active yet","delegations.st.unknown":"Unknown","delegations.meta.space":"{space} space","delegations.meta.spaces":"{count} spaces","delegations.meta.created":"Created {when}","delegations.meta.expires":"Expires {when}","delegations.meta.expired":"Expired {when}","delegations.meta.space.unknown":"Space unknown","delegations.meta.created.unknown":"Creation time unknown","delegations.meta.expires.unknown":"Expiry unknown","delegations.meta.sep":" · ","delegations.time.now":"just now","delegations.time.min":"{n} min ago","delegations.time.hour":"{n} h ago","delegations.time.day":"{n} d ago","delegations.time.in":"in {t}","delegations.time.ago":"{t} ago","delegations.ability.can":"Can {what}","delegations.ability.none":"No actions listed","delegations.ability.unknown":"Abilities unknown","delegations.ability.more":" and more that couldn't be read","delegations.ability.all":"everything","delegations.ability.and":" and ","delegations.ability.sep":"; ","delegations.verb.read":"read","delegations.verb.write":"write","delegations.verb.list":"list","delegations.verb.delete":"delete","delegations.chip.read":"Read","delegations.chip.write":"Write","delegations.chip.list":"List","delegations.chip.delete":"Delete","delegations.chip.terminal":"Terminal","delegations.chip.terminal.tip":"Terminal: it can't pass this access on to anyone else.","delegations.see":"See details","delegations.see.for":"See details for {name}","delegations.revoke.btn":"Revoke","delegations.revoke.for":"Revoke access for {name}","delegations.ended.expired":"Expired grants can't be used. Nothing to revoke.","delegations.ended.revoked":"Already revoked. Nothing to revoke.","delegations.ended.pending":"Not active yet. Nothing to revoke.","delegations.ended.unknown":"Status unknown. Nothing to revoke here.","delegations.ended.received":"Shared with you. Only the one who shared it can end it.","delegations.confirm.title":"Revoke access for {name}?","delegations.confirm.title.app":"Revoke access for {name} on this device?","delegations.confirm.after.app":"{name} will stop working here until you sign in again.","delegations.confirm.what":"{name} will stop being able to {what}{where}.","delegations.confirm.generic":"{name} will stop being able to use this access{where}.","delegations.confirm.where":" in your {space} space","delegations.confirm.openkey":"You'll confirm with your wallet in OpenKey. You can give access again later; this can't be undone from here.","delegations.confirm.keep":"Keep access","delegations.confirm.go":"Revoke access","delegations.busy":"Revoking…","delegations.err.failed":"Couldn't revoke this access.","delegations.err.unconfirmed":"We couldn't confirm whether this worked. The list was re-read; try again if this still shows Active.","delegations.err.unconfirmed.later":"We couldn't confirm whether this worked. Reload the list and check.","delegations.prev.ok":"A revoke for your previous account finished.","delegations.prev.failed":"A revoke for your previous account did not finish.","delegations.err.denied":"This session can't change this access. Nothing was changed.","delegations.err.stale":"This access had already ended, so nothing was changed.","delegations.err.ended":"This access has ended.","delegations.live.revoked":"Access revoked for {name}.","delegations.receipt.title":"Access revoked","delegations.receipt.body":"That access has ended.","delegations.receipt.for":"For","delegations.receipt.cid":"Delegation","delegations.receipt.time":"Time","delegations.d.close":"Close","delegations.d.status":"Status","delegations.d.by":"Granted by","delegations.d.to":"Granted to","delegations.d.id":"Delegation ID","delegations.d.resources":"What it covers","delegations.d.issued":"Issued","delegations.d.notbefore":"Not valid before","delegations.d.expires":"Expires","delegations.d.expired":"Expired","delegations.d.parents":"Passed down from","delegations.d.parents.none":"Nothing, it was granted directly","delegations.d.parents.n":"{count} earlier delegations","delegations.d.revokedat":"Revoked","delegations.d.revokedby":"Revoked by","delegations.d.revokedvia":"Revoked through","delegations.d.none":"Unknown","delegations.d.resources.unreadable":"Some of what it covers couldn't be read.","delegations.d.space":"Space","delegations.d.terminal":"Terminal","delegations.d.terminal.yes":"Yes · can't pass access on","delegations.d.terminal.no":"No · can pass access on","delegations.d.noforward":"It can't pass this access on to anyone else.","delegations.receipt.what":"{name} can no longer {what}.","delegations.receipt.generic":"{name} can no longer use this access.","delegations.receipt.what.app":"{name} can no longer {what} on this device.","delegations.receipt.generic.app":"{name} can no longer use this access on this device.","delegations.d.copy.by":"Copy the identity that granted this","delegations.d.copy.to":"Copy the identity that received this","delegations.d.copy.id":"Copy the delegation ID"});const de='"Literata Variable","Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif',pe='ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace',ue=`\n.dl{container-type:inline-size}\n.dl-lede{margin:-22px 0 28px;max-width:56ch;font-size:15px;line-height:1.5}\n.dl-lede:has(+.dl-fresh:not([hidden])){margin-bottom:10px}\n.dl .dl-fresh{margin:0 0 24px;font-size:12.5px}\n.dl-live{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.dl-body{display:flex;flex-direction:column;gap:28px}\n.dl-h{display:flex;align-items:center;gap:10px;margin:0 0 12px;font:600 13px/1.3 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;letter-spacing:.02em}\n.dl-h::after{content:"";flex:1;height:1px;background:#e4e4e7}\n.dl-cnt{font-weight:500;color:#71717a}\n.dl-sub{margin:-4px 0 12px;font-size:12.5px;line-height:1.4;color:#71717a}\n.dl-none{margin:0;font-size:14px;line-height:1.45;color:#71717a}\n.dl-list{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}\n@container (min-width:720px){.dl-list{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:16px;align-items:start}}\n.dl-wrap{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:1fr;transition:grid-template-rows .4s cubic-bezier(.22,1,.36,1),opacity .3s}\n.dl-in{min-height:0;padding:3px 3px 12px;margin:-3px -3px 0}\n.dl-wrap.dl-leaving{grid-template-rows:0fr;opacity:0}\n.dl-wrap.dl-leaving>.dl-in{overflow:hidden;padding-bottom:0}\n.dl-card{display:flex;flex-direction:column;gap:10px;padding:16px 16px 16px 18px;border-radius:20px;background:#fff;box-shadow:inset 0 0 0 1px #e4e4e7}\n.dl-card:focus{outline:none}\n.dl-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;min-width:0}\n.dl-top .st{flex:none}\n.dl-name{margin:0;font-size:15px;font-weight:600;line-height:1.3;overflow-wrap:anywhere}\n.dl-kind{display:block;margin-top:2px;font-size:12.5px;font-weight:500;color:#71717a;overflow-wrap:anywhere}\n.dl-what{margin:0;font-size:14px;line-height:1.45;overflow-wrap:anywhere}\n.dl-meta{margin:0;font-size:13px;color:#71717a}\n.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:0;padding:0;list-style:none}\n.dl-chip{display:inline-flex;align-items:center;box-sizing:border-box;max-width:100%;min-height:28px;padding:4px 11px;border-radius:999px;background:#f4f4f5;color:#09090b;font-size:12.5px;font-weight:600;overflow-wrap:anywhere}\n.dl-chip-line{background:transparent;box-shadow:inset 0 0 0 1px #71717a}\n.dl-acts{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:2px}\n.dl-fine{margin:0;font-size:12.5px;line-height:1.4;color:#71717a}\n.dl-msg{margin:0;font-size:13px;line-height:1.4;color:#09090b}\n.dl-err{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.dl-foot{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:16px 0 0}\n.dl-foot[hidden]{display:none}\n.dl-notice{display:flex;flex-direction:column;align-items:flex-start;gap:12px;padding:28px 22px;border-radius:20px;box-shadow:inset 0 0 0 1px #e4e4e7}\n.dl-notice-ask{padding:16px 16px 16px 18px}\n.dl-ic{display:grid;place-items:center;width:52px;height:52px;border-radius:50%;box-shadow:inset 0 0 0 1px #71717a}\n.dl-notice-ask .dl-ic{width:44px;height:44px}\n.dl-ic .ui-ic{width:24px;height:24px}\n.dl-notice h4{margin:0;font:400 1.375rem/1.2 ${de}}\n.dl-notice p{margin:0;max-width:52ch;font-size:14px;line-height:1.45}\n.dl-skel{display:flex;flex-direction:column;gap:12px}\n.dl-skel-card{height:132px;border-radius:20px;background:#f4f4f5;animation:dl-pulse 1.4s ease-in-out infinite}\n.dl-skel-line{height:14px;width:40%;border-radius:7px;background:#f4f4f5;animation:dl-pulse 1.4s ease-in-out infinite}\n@keyframes dl-pulse{50%{opacity:.55}}\n.dl-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.dl-kv{display:flex;flex-direction:column;margin:0 0 12px;padding:0}\n.dl-kv>div{display:flex;align-items:center;justify-content:space-between;gap:10px;box-sizing:border-box;min-height:44px;padding:0;border-bottom:1px solid #e4e4e7}\n.dl-kv>div:last-child{border-bottom:0}\n.dl-kv dt{flex:none;font-size:14px}\n.dl-kv dd{display:flex;flex:1 1 auto;align-items:center;justify-content:flex-end;gap:2px;min-width:0;margin:0;font-size:14px;font-weight:600;text-align:right;overflow-wrap:anywhere}\n.dl-kv dd.dl-plain{font-weight:400}\n.dl-kv dd.dl-mono{font:500 12.5px ${pe}}\n.dl-sub-h{margin:12px 0 8px;font-size:13px;font-weight:600}\n.dl-res{display:flex;flex-direction:column;gap:8px;margin:0 0 12px;padding:0;list-style:none}\n.dl-res>li{display:flex;flex-direction:column;gap:6px;padding:10px 14px;border-radius:12px;background:#f4f4f5}\n.dl-res code{font:600 12px ${pe};overflow-wrap:anywhere}\n.dl-res .dl-chips{gap:4px}\n.dl-res .dl-chip{min-height:24px;padding:4px 9px;background:#fff;font-size:12px;line-height:1}\n.section[data-section="delegations"] .confirm{margin-top:10px;padding:14px 16px;border-radius:16px;box-shadow:inset 0 0 0 1px #71717a}\n.section[data-section="delegations"] .confirm p{margin:0;font-size:14px;line-height:1.45;color:inherit}\n.section[data-section="delegations"] .confirm .actions .action:last-child,.section[data-section="delegations"] .confirm .actions .action:last-child:hover{border-color:#09090b;background:#09090b;color:#fff}\n.dl-q-title{display:block;margin-bottom:6px;font:400 1.25rem/1.25 ${de}}\n.dl-q-dim{display:block;margin-top:8px;color:#52525b}\n.drawer .dl-what{margin:0 0 8px}\n@media (prefers-reduced-motion:reduce){\n.dl-wrap{transition:none}\n.dl-skel-card,.dl-skel-line{animation:none}\n}\n@media (prefers-color-scheme: dark){\n.dl-h::after{background:#69696b}\n.dl-cnt,.dl-sub,.dl-none,.dl-kind,.dl-meta,.dl-fine{color:#a1a1aa}\n.dl-card{background:#151517;box-shadow:inset 0 0 0 1px #69696b}\n.dl-msg{color:#fafafa}\n.dl-chip{background:#27272a;color:#fafafa}\n.dl-chip-line{background:transparent;box-shadow:inset 0 0 0 1px #a1a1aa}\n.dl-notice{box-shadow:inset 0 0 0 1px #69696b}\n.dl-ic{box-shadow:inset 0 0 0 1px #a1a1aa}\n.dl-skel-card,.dl-skel-line{background:#27272a}\n.dl-kv>div{border-bottom-color:#69696b}\n.dl-res>li{background:#27272a}\n.dl-res .dl-chip{height:24px;padding:0 9px;background:#151517}\n.section[data-section="delegations"] .confirm{box-shadow:inset 0 0 0 1px #a1a1aa}\n.section[data-section="delegations"] .confirm .actions .action:last-child,.section[data-section="delegations"] .confirm .actions .action:last-child:hover{border-color:#fafafa;background:#fafafa;color:#09090b}\n.dl-q-dim{color:#d4d4d8}\n}\n`,ge=["read","write","list","delete"],fe={"tinycloud.kv/get":"read","tinycloud.kv/put":"write","tinycloud.kv/list":"list","tinycloud.kv/del":"delete",get:"read",put:"write",list:"list",del:"delete"};function me(e,t=64){return e.replace(/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g," ").trim().slice(0,t)}const he=/^(.*?)\/(?:kv|sql|duckdb|hooks|vault)(?:\/(.*))?$/,ye=/^tinycloud\.[a-z]+\/(.*)$/i;function xe(e){const t=ye.exec(e);if(t)return{path:"/"===(t[1]??"")?"":t[1]??""};const n=he.exec(e);if(n){const e=(n[1]??"").split(/[:/]/).pop()??"",t=""===e||/^0x[0-9a-f]{16,}$/i.test(e)?void 0:e,o=n[2]??"";return{...void 0===t?{}:{space:t},path:"/"===o?"":o}}return{path:"/"===e?"":e}}function be(e){const t=[];if(!Array.isArray(e))return t;for(const n of e){if("object"!=typeof n||null===n)continue;const e="resource"in n?n.resource:void 0,o="actions"in n?n.actions:void 0;if("string"!=typeof e||!Array.isArray(o))continue;const a=new Set,i=[];for(const e of o){if("string"!=typeof e)continue;const t=e.trim().toLowerCase(),n=Object.prototype.hasOwnProperty.call(fe,t)?fe[t]:void 0;if(void 0!==n)a.add(n);else{const t=me(e);""===t||i.includes(t)||i.push(t)}}const s=xe(me(e,200));t.push({...void 0===s.space?{}:{space:s.space},path:s.path,verbs:ge.filter(e=>a.has(e)),raws:i})}return t}function ve(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")}${x("delegations.ability.and")}${e[e.length-1]??""}`}function we(e){return e.filter((t,n)=>e.indexOf(t)===n)}function ke(e){if(!Array.isArray(e))return 1;let t=0;for(const n of e)"object"==typeof n&&null!==n&&"resource"in n&&"string"==typeof n.resource&&"actions"in n&&Array.isArray(n.actions)&&n.actions.every(e=>"string"==typeof e)||(t+=1);return t}function Ce(e){const t=function(e){const t=new Map;for(const n of e){const e=[...n.verbs.map(e=>x(`delegations.verb.${e}`)),...n.raws];if(0===e.length)continue;const o=e.join("\0"),a=t.get(o)??{words:e,paths:[]};a.paths.push(""===n.path?x("delegations.ability.all"):n.path),t.set(o,a)}return[...t.values()].map(e=>`${ve(e.words)} ${ve(we(e.paths))}`).join(x("delegations.ability.sep"))}(be(e));return""!==t&&ke(e)>0?`${t}${x("delegations.ability.more")}`:t}function Ee(e){try{const t=be(e),n=Ce(e),o=[...ge.filter(e=>t.some(t=>t.verbs.includes(e))).map(e=>x(`delegations.chip.${e}`)),...we(t.flatMap(e=>e.raws))],a=ke(e)>0?"delegations.ability.unknown":"delegations.ability.none";return{plain:""===n?x(a):x("delegations.ability.can",{what:n}),chips:o}}catch{return{plain:x("delegations.ability.unknown"),chips:[]}}}const Ne={active:"ok",soon:"warn",expired:"info",revoked:"info",pending:"off",unknown:"info"};function _e(e,t){switch(e.status){case"active":{const n=e.expiresAt?.getTime();return void 0!==n&&!Number.isNaN(n)&&n<=t?"expired":e.expiringSoon?"soon":"active"}case"expired":return"expired";case"revoked":case"ancestor_revoked":return"revoked";case"pending":return"pending";default:return"unknown"}}const Ae=e=>"active"===e||"soon"===e,Se=e=>"received"===e.group||"received"===e.direction,Te=(e,t)=>Ae(_e(e,t))&&!Se(e),Le=["this-app","to-others","received"];function ze(e){const t=me(e,200);return t.length<=22?t:`${t.slice(0,14)}…${t.slice(-6)}`}function Me(e){const t=me(e,200);return t.length<=16?t:`${t.slice(0,10)}…${t.slice(-4)}`}function $e(e){return Se(e)?e.delegatorDid:e.delegateDid}function De(e){const t=me(e.label?.text??"",120),n=!Se(e)||""!==t&&t!==ze(e.delegateDid)?""===t?ze($e(e)):t:ze(e.delegatorDid);return""===n?x("delegations.party.unknown"):n}function Oe(e){return we(e.flatMap(e=>void 0===e.space?[]:[e.space]))}function qe(e){const t=Math.round(Math.abs(e)/6e4),n=Math.floor(t/1440),o=Math.floor(t%1440/60),a=t%60;return n>0?o>0?`${n}d ${o}h`:`${n}d`:o>0?a>0?`${o}h ${a}m`:`${o}h`:`${a}m`}function Be(e,t){const n=Math.max(0,Math.round((t-e.getTime())/6e4));return n<1?x("delegations.time.now"):n<60?x("delegations.time.min",{n}):n<1440?x("delegations.time.hour",{n:Math.floor(n/60)}):x("delegations.time.day",{n:Math.floor(n/1440)})}function Ie(e){return e instanceof Date&&!Number.isNaN(e.getTime())}const Re={"not-revocable":!0,NOT_FOUND:!0,not_found:!0,"not-found":!0,"not-active":!0},je={PERMISSION_DENIED:!0,"permission-denied":!0,denied:!0},Pe={NETWORK_ERROR:!0,ABORTED:!0,thrown:!0};function Fe(e,t,n){const o=document.createElement(e);return void 0!==t&&(o.className=t),void 0!==n&&(o.textContent=n),o}let Ye=0;const We=new Set,Ue=new WeakMap;function He(e){const t=Ue.get(e);if(void 0!==t)return t;const n=new Set;return Ue.set(e,n),n}const Ve={id:"delegations",labelCode:"nav.delegations",icon:"key",summaryCode:"delegations.summary",isAvailable:e=>!0===e.client()?.signedIn(),status:e=>te(e,e.data.latest("delegations"),t=>{const n=He(e.data),o=t.rows.filter(e=>!n.has(e.cid)).length,a=void 0!==t.nextCursor;return{text:e.text("delegations.glance.visible"),tone:"ok",...a&&0===o?{}:{count:`${o}${a?"+":""}`}}}),mount:function(e,t){const n=(e,n)=>t.text(e,n),o=()=>t.appLabel()??n("delegations.app.fallback"),s=e=>"this-app"===e.group?t.appLabel()??n("delegations.app.subject"):De(e),r=Fe("style");r.textContent=a+ue;const c=Fe("div","dl"),p=Fe("h3","sec-title",n("nav.delegations"));p.tabIndex=-1;const u=Fe("p","dl-lede",n("delegations.lede")),g=Fe("div","dl-live");g.setAttribute("role","status"),g.setAttribute("aria-live","polite");const f=Fe("div","dl-skel");f.setAttribute("role","status"),f.setAttribute("aria-busy","true"),f.append(Fe("span","dl-sr",n("delegations.loading")),Fe("div","dl-skel-line"),Fe("div","dl-skel-card"));const m=Fe("div"),h=Fe("div","dl-body"),b=Fe("div","dl-foot"),v=Fe("p","dl-fine"),w=i(n("delegations.more.btn")),k=Fe("p","dl-msg");k.setAttribute("role","alert"),k.hidden=!0,b.append(v,w,k),w.addEventListener("click",()=>{!async function(){const e=_,o=t.data.source;if("loading"===O||void 0===e||void 0===o)return;const a=ee(e);if(void 0===a)return;const i=L;let s;O="loading",te();try{s=await o.delegations(a)}catch{s={state:"error",code:"thrown"}}if(S||i!==L)return;if("ready"!==s.state)return O="error",te(),void w.focus({preventScroll:!0});const r=new Set([...e.rows,...D].map(e=>e.cid)),c=s.data.rows.filter(e=>!r.has(e.cid)&&(r.add(e.cid),!0));D=[...D,...c],A={next:s.data.nextCursor},O="idle",g.textContent=n("delegations.more.loaded",{count:c.length}),te(),void 0!==s.data.nextCursor?w.focus({preventScroll:!0}):(q.get(c[0]?.cid??"")?.article??p).focus({preventScroll:!0})}()});const C=se(t,()=>{});C.status.classList.add("dl-fresh"),c.append(p,u,C.status,g,f,m,h),e.append(r,c);let E,N,_,A,S=!1,T=!1,L=0,z=0,M=!1,$=!1,D=[],O="idle";const q=new Map,B=He(t.data),I=new Set,R=new Map;function j(e){const t=R.get(e);if(void 0!==t)return t;const a="this-app"===e?"app":"to-others"===e?"others":"received",i=Fe("section"),s=Fe("h3","dl-h"),r=Fe("span",void 0,n(`delegations.g.${a}`,{app:o()})),c=Fe("span","dl-cnt");s.append(r,c);const l=Fe("p","dl-sub",n(`delegations.g.${a}.sub`,{app:o()})),d=Fe("ul","dl-list"),p=Fe("p","dl-none",n("delegations.g.none"));i.append(s,l,d,p);const u={section:i,count:c,list:d,none:p};return R.set(e,u),u}function P(e){const o="dl-"+ ++Ye,a=Fe("li","dl-wrap"),s=Fe("div","dl-in"),r=Fe("article","dl-card");r.tabIndex=-1;const c=Fe("div","dl-top"),l=Fe("div","dl-name");l.id=`${o}-n`;const d=Fe("small","dl-kind"),u=Fe("span");l.append(u,d);const g=Fe("span");c.append(l,g);const f=Fe("p","dl-what"),m=Fe("p","dl-meta"),h=Fe("ul","dl-chips"),y=Fe("div","dl-acts"),x=i(n("delegations.see")),b=i(n("delegations.revoke.btn")),v=Fe("span","dl-fine");y.append(x,b,v);const w=Fe("p","dl-msg",n("delegations.busy"));w.setAttribute("role","status");const k=Fe("div","dl-err");k.setAttribute("role","alert");const C=Fe("p","dl-msg"),E=i(n("view.retry")),N=i(n("delegations.reload"));N.hidden=!0,k.append(C,E,N),r.setAttribute("aria-labelledby",l.id),r.append(c,f,m,h,y,w,k),s.append(r),a.append(s);const _={cid:e.cid,row:e,phase:"idle",confirm:void 0,drawer:void 0,detail:void 0,li:a,article:r,name:u,kind:d,statusSlot:g,what:f,meta:m,chips:h,see:x,revoke:b,ended:v,busy:w,err:k,errText:C,retry:E,reload:N};return x.addEventListener("click",()=>function(e){for(const t of q.values())t!==e&&(t.drawer?.close(),t.drawer=void 0,t.detail=void 0);e.drawer?.close();const o=Fe("div");e.detail=o,o.replaceChildren(...X(e.row,_e(e.row,Date.now()),Date.now()));const a=t.openDrawer({title:De(e.row),body:[o],closeLabel:n("delegations.d.close"),anchor:e.article,onClose:()=>{e.drawer=void 0,e.detail=void 0,S||e.see.focus()}});a.el.addEventListener("keydown",t=>{"Escape"===t.key&&(t.stopPropagation(),a.close(),e.drawer=void 0,e.detail=void 0,e.see.focus())}),e.drawer=a}(_)),b.addEventListener("click",()=>U(_)),E.addEventListener("click",()=>U(_)),N.addEventListener("click",()=>{!async function(){const e=++L;D=[],A=void 0,O="idle",te(),await H(),S||e!==L||p.focus({preventScroll:!0})}()}),_}function F(e){const t=Date.now(),{row:o}=e,a=_e(o,t),i=be(o.resources),s=De(o);e.name.textContent=s,e.kind.textContent=function(e,t){if(Se(e))return x("delegations.kind.received",{who:t});const n=x("this-app"===e.group?"delegations.kind.app":"delegations.kind.others"),o=ze($e(e));return o===t?n:`${n}${x("delegations.meta.sep")}${o}`}(o,s),e.statusSlot.replaceChildren(d({text:n(`delegations.st.${a}`),tone:Ne[a]})),e.what.textContent=Ee(o.resources).plain,e.meta.textContent=function(e,t,n,o){const a=[],i=Oe(n);if(1===i.length?a.push(x("delegations.meta.space",{space:i[0]??""})):i.length>1?a.push(x("delegations.meta.spaces",{count:i.length})):a.push(x("delegations.meta.space.unknown")),Ie(e.issuedAt)&&e.issuedAt.getTime()<=o+3e5?a.push(x("delegations.meta.created",{when:Be(e.issuedAt,o)})):a.push(x("delegations.meta.created.unknown")),Ie(e.expiresAt)){const n=e.expiresAt.getTime()<=o,i=x(n?"delegations.time.ago":"delegations.time.in",{t:qe(e.expiresAt.getTime()-o)});a.push(x(n||"expired"===t?"delegations.meta.expired":"delegations.meta.expires",{when:i}))}else a.push(x("delegations.meta.expires.unknown"));return a.join(x("delegations.meta.sep"))}(o,a,i,t);const r=Ee(o.resources).chips.map(e=>Fe("li","dl-chip",e));if(!0===o.terminal){const e=Fe("li","dl-chip dl-chip-line",n("delegations.chip.terminal"));e.title=n("delegations.chip.terminal.tip"),r.push(e)}e.chips.replaceChildren(...r),e.chips.hidden=0===r.length,e.see.setAttribute("aria-label",n("delegations.see.for",{name:s}));const c=Te(o,t);e.revoke.hidden=!c,e.revoke.disabled=We.has(e.cid),e.revoke.setAttribute("aria-label",n("delegations.revoke.for",{name:s})),e.ended.hidden=c,c||(e.ended.textContent=n(Ae(a)?"delegations.ended.received":"expired"===a?"delegations.ended.expired":"revoked"===a?"delegations.ended.revoked":"unknown"===a?"delegations.ended.unknown":"delegations.ended.pending"));const l=We.has(e.cid),p="busy"===e.phase||l;e.busy.hidden=!p;const u="failed"===e.phase||"denied"===e.phase||"stale"===e.phase||"unconfirmed"===e.phase;e.err.hidden=!u;const g=void 0!==_&&!_.rows.some(t=>t.cid===e.cid);if(u){const t=!(c||g||"failed"!==e.phase&&"unconfirmed"!==e.phase);e.errText.textContent=n(`delegations.err.${t?"ended":"unconfirmed"===e.phase&&g?"unconfirmed.later":e.phase}`)}e.reload.hidden=!(u&&"unconfirmed"===e.phase&&g),e.retry.hidden="failed"!==e.phase&&"unconfirmed"!==e.phase||!c,e.retry.disabled=l,void 0!==e.detail&&e.detail.replaceChildren(...X(o,a,t))}function Y(){for(const e of q.values())F(e)}function W(e){e.confirm?.close(),e.confirm=void 0}function U(o){if(We.has(o.cid)||"busy"===o.phase)return;if(!Te(o.row,Date.now()))return;!function(){for(const e of q.values())void 0!==e&&W(e)}(),W(o),o.phase="idle",F(o);const a="this-app"===o.row.group,i=s(o.row),r=Oe(be(o.row.resources)),c=1===r.length?n("delegations.confirm.where",{space:r[0]??""}):"",l=Ce(o.row.resources),d=n(a?"delegations.confirm.title.app":"delegations.confirm.title",{name:i}),u=""===l?n("delegations.confirm.generic",{name:i,where:c}):n("delegations.confirm.what",{name:i,what:l,where:c}),f=a?`${u} ${n("delegations.confirm.after.app",{name:i})}`:u,m=n("delegations.confirm.openkey"),h=t.confirm({question:`${d} ${f} ${m}`,cancelLabel:n("delegations.confirm.keep"),confirmLabel:n("delegations.confirm.go"),anchor:o.article,onCancel:()=>{o.confirm=void 0,S||!o.revoke.isConnected||o.revoke.hidden||o.revoke.focus()},onConfirm:()=>{!async function(o){if(We.has(o.cid)||"busy"===o.phase)return;const a=o.confirm;void 0!==a&&(a.confirm.disabled=!0);const i=t.data.source;if(void 0===i||!Te(o.row,Date.now()))return W(o),o.phase="stale",F(o),H(),void p.focus({preventScroll:!0});W(o);const r=L,c=function(){const e=t.data.source;let n=t.data.latest("delegations"),o=!1;return{moved:()=>o||t.data.source!==e,stop:t.data.subscribe(()=>{const e=t.data.latest("delegations");void 0===e&&void 0!==n&&(o=!0),n=e})}}();let l;We.add(o.cid),o.phase="busy",Y(),o.article.focus();try{l=await i.revoke(o.cid)}catch{l={ok:!1,code:"thrown"}}finally{We.delete(o.cid),c.stop()}const d=void 0!==l&&!0===l.ok;if(c.moved())return t.toastsEnabled()&&t.toast({kind:"info",textCode:d?"delegations.prev.ok":"delegations.prev.failed"}),S||Z(o),void t.requestRender();const u=!S&&r===L;if(d){if(B.add(o.cid),t.requestRender(),function(e){const o=(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),a=s(e.row),i="this-app"===e.row.group?".app":"",r=Ce(e.row.resources),c=""===r?n(`delegations.receipt.generic${i}`,{name:a}):n(`delegations.receipt.what${i}`,{name:a,what:r}),l=c.includes("{");l||y({"delegations.receipt.sentence":c});!t.receipt({titleCode:"delegations.receipt.title",bodyCode:l?"delegations.receipt.body":"delegations.receipt.sentence",rows:[...l?[{labelCode:"delegations.receipt.for",value:a}]:[],{labelCode:"delegations.receipt.cid",value:me(e.cid,200)},{labelCode:"delegations.receipt.time",value:o}]})&&t.toastsEnabled()&&t.toast({kind:"success",textCode:"delegations.receipt.title"})}(o),H(),S)return;return u?(g.textContent=n("delegations.live.revoked",{name:s(o.row)}),void function(t){q.delete(t.cid),W(t),t.drawer?.close(),t.drawer=void 0;const n=e.getRootNode().activeElement;null!==n&&t.li.contains(n)&&p.focus({preventScroll:!0});const o=()=>t.li.remove();if("function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)o();else{t.li.classList.add("dl-leaving");const e=window.setTimeout(()=>{I.delete(e),o()},420);I.add(e)}te()}(o)):void Z(o)}const f=void 0!==l&&!1===l.ok?l.code:"thrown";if(o.phase=function(e){return Object.prototype.hasOwnProperty.call(Re,e)?"stale":Object.prototype.hasOwnProperty.call(je,e)?"denied":Object.prototype.hasOwnProperty.call(Pe,e)?"unconfirmed":"failed"}(f),H(),!u)return t.toastsEnabled()&&t.toast({kind:"error",textCode:`delegations.err.${o.phase}`}),void(S||Z(o));Y(),o.retry.hidden?o.article.focus():o.retry.focus()}(o)}});o.confirm=h;const x=h.cancel.closest('[role="alertdialog"]'),b=x?.querySelector("p");if(null!=x&&null!=b){const e="dl-"+ ++Ye,t=Fe("span","dl-q-title",d);t.id=`${e}-t`;const n=Fe("span",void 0,f);n.id=`${e}-b`;const o=Fe("span","dl-q-dim",m);o.id=`${e}-w`,b.replaceChildren(t,n,o),x.setAttribute("aria-labelledby",t.id),x.setAttribute("aria-describedby",`${n.id} ${o.id}`)}}async function H(){try{await t.data.refresh("delegations")}catch{}}function V(e,t){const o=Fe("div");return o.append(Fe("dt",void 0,n(e)),Fe("dd","dl-plain",t)),o}function G(e,o,a,i){if(""===o)return V(e,n("delegations.d.none"));const s=Fe("div"),r=Fe("dd","dl-mono");return r.append(Fe("span",void 0,a),function(e,o){const a=Fe("button","icon-btn");return a.type="button",a.setAttribute("aria-label",n(o)),a.append(l("copy")),a.addEventListener("click",()=>{(async()=>{try{await navigator.clipboard.writeText(e),t.toast({kind:"success",textCode:"toast.copied"})}catch{t.toast({kind:"error",textCode:"toast.copy_failed"})}})()}),a}(o,i)),s.append(Fe("dt",void 0,n(e)),r),s}function K(e){return Ie(e)?e.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):n("delegations.d.none")}function X(e,t,o){const a=be(e.resources),i=Fe("p","dl-what",`${Ee(e.resources).plain}${!0===e.terminal?`. ${n("delegations.d.noforward")}`:"."}`),s=Fe("dl","dl-kv"),r=Fe("dd");r.append(d({text:n(`delegations.st.${t}`),tone:Ne[t]}));const c=Fe("div");c.append(Fe("dt",void 0,n("delegations.d.status")),r),s.append(c,G("delegations.d.by",e.delegatorDid,ze(e.delegatorDid),"delegations.d.copy.by"),G("delegations.d.to",e.delegateDid,ze(e.delegateDid),"delegations.d.copy.to"),G("delegations.d.id",e.cid,Me(e.cid),"delegations.d.copy.id"),V("delegations.d.issued",K(e.issuedAt)),V("delegations.d.notbefore",K(e.notBefore)),V(Ie(e.expiresAt)&&e.expiresAt.getTime()<=o?"delegations.d.expired":"delegations.d.expires",K(e.expiresAt)),V("delegations.d.parents",Array.isArray(e.parents)?0===e.parents.length?n("delegations.d.parents.none"):n("delegations.d.parents.n",{count:e.parents.length}):n("delegations.d.none")));const l=Oe(a);s.insertBefore(V("delegations.d.space",0===l.length?n("delegations.d.none"):l.join(", ")),s.children[1]??null),void 0!==e.terminal&&s.append(V("delegations.d.terminal",n(e.terminal?"delegations.d.terminal.yes":"delegations.d.terminal.no"))),("revoked"===t||void 0!==e.revokedAt&&null!==e.revokedAt)&&s.append(V("delegations.d.revokedat",K(e.revokedAt))),void 0!==e.revokedBy&&s.append(V("delegations.d.revokedby",ze(e.revokedBy))),void 0!==e.revokedAncestorCid&&s.append(V("delegations.d.revokedvia",Me(e.revokedAncestorCid)));const p=Fe("h4","dl-sub-h",n("delegations.d.resources")),u=Fe("ul","dl-res");for(const t of be(e.resources)){const e=Fe("li");e.append(Fe("code",void 0,""===t.path?n("delegations.ability.all"):t.path));const o=Fe("ul","dl-chips");for(const e of t.verbs)o.append(Fe("li","dl-chip",n(`delegations.chip.${e}`)));for(const e of t.raws)o.append(Fe("li","dl-chip",e));o.childElementCount>0&&e.append(o),u.append(e)}return[i,s,p,u,...ke(e.resources)>0?[Fe("p","dl-fine",n("delegations.d.resources.unreadable"))]:[]]}function Z(e){q.get(e.cid)===e&&q.delete(e.cid),W(e),e.drawer?.close(),e.li.remove()}function J(e,t,...n){const o=Fe("div",e),a=Fe("span","dl-ic");return a.setAttribute("aria-hidden","true"),a.append(l("key")),o.append(a,Fe("h4",void 0,t),...n),o}function Q(e){m.replaceChildren(...void 0===e?[]:[e]),m.hidden=void 0===e}function ee(e){return void 0===A?e.nextCursor:A.next}function te(){if(S)return;const a=t.data.source,s=t.data.latest("delegations"),r=M&&(a!==E||void 0===s&&void 0!==N||"ready"===N?.state&&"ready"!==s?.state);if(M=!0,E=a,N=s,r){L+=1,z+=1,T=!1,$=!1;for(const e of[...q.values()])Z(e)}if(void 0!==s&&"ready"===s.state||(D=[],A=void 0,O="idle"),void 0===a||"ready"!==s?.state&&"needs-permission"!==s?.state?(C.status.hidden=!0,C.status.textContent=""):(re(C,t,s),"needs-permission"===s.state&&(C.status.textContent=n("delegations.denied"))),f.hidden=!0,h.hidden=!0,void 0!==a){if(T||void 0===s||"loading"===s.state)return Q(void 0),void(f.hidden=!1);switch(s.state){case"needs-permission":return void Q(function(e){const a=t.client(),s=a?.requestAuthority,r="delegation/list"===e&&"function"==typeof s,c=[Fe("p",void 0,n("delegations.ask.body")+(r?n("delegations.ask.openkey"):""))];if($&&c.push(Fe("p","dl-fine",n("delegations.ask.declined"))),r&&void 0!==s){const t=i(n("delegations.ask.button"));t.addEventListener("click",()=>{t.disabled=!0;const n=L;(async()=>{let t=!1;try{t=!0===(await s(e)).approved}catch{t=!1}S||n!==L||($=!t,t&&await H(),S||n!==L||(t&&p.focus({preventScroll:!0}),te()))})()}),c.push(t)}return J("dl-notice dl-notice-ask",n("delegations.ask.title",{app:o()}),...c)}(s.ability));case"error":return void Q(function(){const e=Fe("div","dl-notice"),t=Fe("p",void 0,n("delegations.error"));t.setAttribute("role","status");const o=i(n("view.retry"));return o.addEventListener("click",()=>{const e=++z;T=!0,te(),H().then(()=>{e===z&&(T=!1,te())})}),e.append(t,o),e}());case"ready":!function(t){_=t;const o=new Set(t.rows.map(e=>e.cid)),a=[...t.rows,...D.filter(e=>!o.has(e.cid))].filter(e=>!B.has(e.cid)),i=void 0!==ee(t);if(0===a.length&&!i){for(const e of[...q.values()])"busy"!==e.phase&&Z(e);return Q(J("dl-notice",n("delegations.empty.title"),Fe("p",void 0,n("delegations.empty.body")))),void(h.hidden=!0)}Q(void 0),h.hidden=!1;const s=function(e){const t={"this-app":[],"to-others":[],received:[]};for(const n of e)t[Se(n)?"received":Le.includes(n.group)?n.group:"to-others"].push(n);return t}(a),r=new Set,c=[];for(const t of Le){const o=s[t];if("received"===t&&0===o.length)continue;const a=j(t);a.count.textContent=i?0===o.length?"":`${o.length}+`:String(o.length),a.none.hidden=o.length>0,a.none.textContent=n(i?"delegations.g.none.more":"delegations.g.none");const l=[];for(const t of o){let n=q.get(t.cid);if(void 0===n&&(n=P(t),q.set(t.cid,n)),n.row=t,r.add(t.cid),void 0!==n.confirm&&!Te(t,Date.now())){const t=n.confirm.cancel.closest("[role=alertdialog]"),o=e.getRootNode().activeElement,a=null!==t&&null!==o&&t.contains(o);W(n),n.phase="stale",a&&n.article.focus({preventScroll:!0})}F(n),l.push(n.li)}l.forEach((e,t)=>{a.list.children[t]!==e&&a.list.insertBefore(e,a.list.children[t]??null)}),c.push(a.section)}for(const e of[...q.values()])r.has(e.cid)||"busy"===e.phase||Z(e);b.hidden=!i,v.textContent=n("delegations.firstpage",{count:`${a.length}+`}),w.textContent=n("loading"===O?"delegations.more.busy":"error"===O?"view.retry":"delegations.more.btn"),w.setAttribute("aria-disabled",String("loading"===O)),k.hidden="error"!==O,k.textContent=n("delegations.more.err");const l=[...c,b];for(l.forEach((e,t)=>{h.children[t]!==e&&h.insertBefore(e,h.children[t]??null)});h.children.length>l.length;)h.lastElementChild?.remove()}(s.data)}}else Q(Fe("p","note",n("delegations.unavailable")))}const ne=t.data.subscribe(te);te();const oe=t.data.age("delegations");return void 0!==oe&&oe>1e4&&H(),()=>{S=!0,ne();for(const e of I)window.clearTimeout(e);I.clear();for(const e of q.values())W(e),e.drawer?.close();e.replaceChildren()}}},Ge={off:!0,enabling:!0,on:!0,wiping:!0,pending:!0,unavailable:!0};function Ke(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(Ge,e)?e:"unavailable"}const Xe=new WeakMap,Ze=new WeakMap,Je=Object.freeze({ok:!1,retryNow:!1});function Qe(e){return new Promise(t=>{let n=!1;const o=e=>{n||(n=!0,clearTimeout(a),t(e))},a=setTimeout(()=>o(Je),1e4);Promise.resolve().then(e).then(e=>o(!0===e?.ok?{ok:!0}:{ok:!1,retryNow:!0===e?.retryNow}),()=>o({ok:!1,retryNow:!1}))})}function et(e){return t=>{const n=t?.signOut;if(void 0===t||void 0===n)return t;const o=Ze.get(t);if(void 0!==o)return o;const a=t.purgeLocalCopy,i=void 0===a?void 0:function(e,t,n){let o,a,i=0;const s=new Set,r=e=>{if(o!==e){o=e;for(const e of[...s])e()}},c=()=>{const e=++i;return()=>i===e};return{begin:c,failure:()=>e.signedIn()?void 0:o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),settle(t,a){const i="readable"===o&&t===Je,s=a||!1===t.ok&&t.retryNow||i?"readable":"pending";e.signedIn()?!1===t.ok&&r(s):!0!==t.ok?(r(s),n({kind:"warning",textCode:"readable"===s?"local-copy.purge.toast.readable":"local-copy.purge.toast.pending"})):r(void 0)},markPending(){r("readable"===o?"readable":"pending")},retry(){if(e.signedIn())return Promise.resolve(!1);if(void 0===o)return Promise.resolve(!0);if(void 0!==a&&a.latest())return a.promise;const n=c(),i=Qe(t).then(t=>!(!n()||(!0===t.ok?e.signedIn()||(r(void 0),0):(t.retryNow&&r("readable"),1)))).finally(()=>{a?.promise===i&&(a=void 0)});return a={promise:i,latest:n},i}}}(t,a,e);let s;const r=Object.create(t,{signOut:{value:()=>{const e=s;if(!(void 0===e||e.purging&&t.signedIn()))return e.promise;const o={purging:!1,promise:Promise.resolve()};return o.promise=(async()=>{let e,s=!1;try{await n()}catch(t){s=!0,e=t}if(o.purging=!0,void 0!==a&&void 0!==i)if(t.signedIn())i.markPending();else{const e=i.begin();let n=await Qe(a);if(e()){const o=!1===n.ok&&n.retryNow;o&&!t.signedIn()&&(n=await Qe(a)),e()&&i.settle(n,o)}}if(s)throw e})().finally(()=>{s===o&&(s=void 0)}),s=o,o.promise}}});return Ze.set(t,r),void 0!==i&&(Xe.set(t,i),Xe.set(r,i)),r}}function tt(e){return"object"==typeof e&&null!==e&&"code"in e&&"string"==typeof e.code?e.code:"unknown"}y({"local-copy.summary":"Keep a copy of your data on this device","local-copy.glance.on":"On","local-copy.glance.off":"Off","local-copy.glance.pending":"Pending","local-copy.lede":"Keep a copy of your data in this browser, so it opens fast and works offline.","local-copy.switch":"Keep a local copy on this device","local-copy.switch.on":"Changes sync both ways","local-copy.switch.off":"Reads and writes go straight to your TinyCloud","local-copy.switch.state.on":"On","local-copy.switch.state.off":"Off","local-copy.state.enabling":"Turning on the local copy","local-copy.state.wiping":"Wiping local data","local-copy.state.pending":"The last wipe is not confirmed yet","local-copy.state.unavailable":"The local copy is not available here","local-copy.unavailable.note":"Your data in TinyCloud is not affected.","local-copy.pending.note":"Some local data may still be on this device. You can wipe it again below.","local-copy.off.title":"The local copy is off.","local-copy.off.empty":"Nothing is kept on this device.","local-copy.off.unknown":"What is kept on this device is unknown.","local-copy.off.body":"{app} reads and writes your TinyCloud directly, so it needs a connection.","local-copy.off.app":"This app","local-copy.synced":"Synced {ago}","local-copy.synced.unknown":"Last synced: unknown","local-copy.ago.now":"just now","local-copy.ago.minutes":"{count} min ago","local-copy.ago.hours":"{count} h ago","local-copy.ago.days":"{count} d ago","local-copy.unknown":"unknown","local-copy.row.waiting":"Waiting to sync","local-copy.row.waiting.none":"Nothing","local-copy.row.waiting.one":"1 change","local-copy.row.waiting.many":"{count} changes","local-copy.row.size":"Size on this device","local-copy.folders.title":"Folders covered","local-copy.folder.items":"{count} items","local-copy.folder.items.unknown":"items unknown","local-copy.folder.size.unknown":"size unknown","local-copy.folder.waiting":"{count} waiting","local-copy.folder.waiting.unknown":"waiting unknown","local-copy.folder.unknown":"details unknown","local-copy.folder.syncing":"Syncing","local-copy.folder.paused":"Paused","local-copy.bytes.b":"{value} B","local-copy.bytes.kib":"{value} KiB","local-copy.bytes.mib":"{value} MiB","local-copy.bytes.gib":"{value} GiB","local-copy.wipe.title":"Wipe local data","local-copy.wipe.body":"Erases TinyCloud's copy on this device. Your data stays on your TinyCloud; the app's own files are not touched.","local-copy.wipe.button":"Wipe local data","local-copy.wipe.question":"Wipe local data? Erases TinyCloud's copy on this device. Your data stays on your TinyCloud; the app's own files are not touched.","local-copy.wipe.question.off":"Turn off local copy and wipe local data? Erases TinyCloud's copy on this device. Your data stays on your TinyCloud; the app's own files are not touched.","local-copy.wipe.unsynced.one":"1 change hasn't synced yet. Wiping now loses it.","local-copy.wipe.unsynced.many":"{count} changes haven't synced yet. Wiping now loses them.","local-copy.wipe.unsynced.unknown":"It isn't known whether all changes have synced. Wiping now may lose changes that haven't.","local-copy.wipe.refill":"The copy downloads again the next time it syncs.","local-copy.wipe.keep":"Keep local data","local-copy.wipe.confirm":"Wipe local data","local-copy.wipe.busy":"Wiping…","local-copy.wipe.done":"Local data wiped. Your TinyCloud still has everything.","local-copy.wipe.failed":"The wipe didn't finish. The copy may still be on this device.","local-copy.wipe.retry":"Try again","local-copy.purge.pending":"The local copy on this browser was not removed yet.","local-copy.purge.readable":"The local copy on this browser was not removed yet. It may still be readable here.","local-copy.purge.toast.pending":"The local copy on this browser was not removed yet. Try again from Local copy.","local-copy.purge.toast.readable":"The local copy on this browser was not removed yet. It may still be readable here. Try again from Local copy.","local-copy.purge.done":"The local copy was removed from this browser."});const nt={off:!0,on:!0,pending:!0,enabling:!1,wiping:!1,unavailable:!1},ot={enabling:"local-copy.state.enabling",wiping:"local-copy.state.wiping",pending:"local-copy.state.pending",unavailable:"local-copy.state.unavailable"};function at(e,t){const n=[["local-copy.bytes.b",1],["local-copy.bytes.kib",1024],["local-copy.bytes.mib",1048576],["local-copy.bytes.gib",1024**3]];let o=n[0];for(const e of n)t>=e[1]&&(o=e);const a=t/o[1],i=1===o[1]||Number.isInteger(a)?String(Math.round(a)):a.toFixed(1);return e.text(o[0],{value:i})}function it(e,t,n){const o=Math.max(0,Math.floor((n-t.getTime())/6e4));return o<1?e.text("local-copy.ago.now"):o<60?e.text("local-copy.ago.minutes",{count:o}):o<1440?e.text("local-copy.ago.hours",{count:Math.floor(o/60)}):e.text("local-copy.ago.days",{count:Math.floor(o/1440)})}function st(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0}function rt(e,t,n=!1,o=!1){const a=document.createElement("div"),i=document.createElement("dt");if(o){const t=document.createElement("span");t.className="lc-prefix",t.textContent=e,i.append(t)}else i.textContent=e;const s=document.createElement("dd");return n&&(s.className="lc-plain"),s.append(t),a.append(i,s),a}function ct(e,t){switch(Ke(t.effective)){case"on":return{text:e.text("local-copy.glance.on"),tone:"ok"};case"off":return{text:e.text("local-copy.glance.off"),tone:"off"};case"pending":return{text:e.text("local-copy.glance.pending"),tone:"warn"};case"unavailable":return{text:e.text("section.status.unavailable"),tone:"info"};default:return{text:e.text("section.status.checking"),tone:"info"}}}let lt=0;const dt={id:"local-copy",labelCode:"nav.local-copy",icon:"sync",summaryCode:"local-copy.summary",isAvailable:e=>void 0!==e.client()?.sync,status:function(e){const t=e.client()?.sync?.state;return void 0!==t?ct(e,t):te(e,e.data.latest("localCopy"),t=>ct(e,t))},mount:function(e,t){const n=t.client()?.sync;if(!n)return()=>{};const o=n;let i,s,r,c=!1,l=0,p=!1,u=!1,g=!1,f=!1,m=!1,h=!1;const y=void 0===(x=t.client())?void 0:Xe.get(x);var x;let b=0;const v=document.createElement("style");v.textContent='\n.lc-lede{max-width:56ch;margin:-20px 0 20px;font-size:15px;line-height:1.5}\n.lc-sw{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:4px 0}\n.lc-sw strong{display:block;font:500 16px/1.3 "Literata Variable","Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;letter-spacing:-.005em}\n.lc-sub{display:block;margin-top:2px;font-size:13.5px;color:#71717a}\n.lc-swctl{display:flex;flex:none;align-items:center;gap:10px}\n.lc-swlbl{min-width:22px;font-size:13px;font-weight:700;text-align:right}\n.lc-card{display:flex;flex-direction:column;gap:10px;margin-top:16px;padding:16px 18px;border-radius:16px;background:#fafafa;box-shadow:inset 0 0 0 1px #e4e4e7}\n.lc-card p{margin:0}\n.lc-small{font-size:14px;line-height:1.45}\n.lc-state{margin:6px 0 0}\n.lc-kv{display:flex;flex-direction:column;margin:0;padding:0}\n.lc-kv>div{display:flex;align-items:center;gap:10px;box-sizing:border-box;min-height:44px;padding:9px 0;border-bottom:1px solid #e4e4e7}\n.lc-kv>div:last-child{border-bottom:0}\n.lc-kv.lc-cozy>div{min-height:36px;padding:5px 0;border-bottom:0}\n.lc-kv dt{display:flex;flex:1 1 auto;align-items:baseline;gap:10px;min-width:0;font-size:14px;white-space:nowrap}\n.lc-kv dt::after{content:"";flex:1 1 12px;min-width:12px;border-bottom:2px dotted #a1a1aa;transform:translateY(-3px)}\n.lc-kv dd{display:flex;flex:0 1 auto;align-items:center;justify-content:flex-end;max-width:78%;margin:0;font-size:14px;font-weight:600;text-align:right;overflow-wrap:anywhere}\n.lc-kv dd.lc-plain{font-weight:400}\n.lc-kv .lc-prefix{font:600 .875rem ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace}\n.lc-sec{margin-top:24px}\n.lc-h3{display:flex;align-items:center;gap:10px;margin:0 0 12px;font-size:13px;font-weight:600;line-height:1.3;letter-spacing:.02em}\n.lc-h3::after{content:"";flex:1;height:1px;background:#e4e4e7}\n.lc-cnt{font-weight:500;color:#71717a}\n.lc-wipe p{max-width:56ch;margin:0 0 12px;font-size:14px;line-height:1.45}\n.lc-fail{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:12px}\n.lc-fail p{margin:0;font-size:14px}\n.lc-sec .confirm,.lc-sw+.confirm{margin-top:12px}\n.lc-confirm.confirm .busy{margin:0;font-size:14.5px;line-height:1.5;color:inherit}\n.lc-confirm.confirm .actions{margin:16px 0 0}\n.lc-confirm .action:last-child{background:#09090b;border-color:#09090b;color:#fff}\n.lc-confirm .action:last-child:hover{background:#27272a}\n.lc-confirm .action:disabled{opacity:.6;cursor:default}\n@media (max-width:600px){\n.lc-confirm.confirm .actions{flex-direction:column}\n.lc-confirm .action{width:100%;white-space:normal}\n}\n.panel[data-layout="page"] .lc-card{background:#fff}\n@media (prefers-color-scheme: dark){\n.lc-sub,.lc-cnt{color:#a1a1aa}\n.lc-card{background:#151517;box-shadow:inset 0 0 0 1px #69696b}\n.lc-kv>div{border-bottom-color:#69696b}\n.lc-kv dt::after{border-bottom-color:#71717a}\n.lc-h3::after{background:#69696b}\n.lc-confirm .action:last-child{background:#fafafa;border-color:#fafafa;color:#09090b}\n.lc-confirm .action:last-child:hover{background:#e4e4e7}\n.panel[data-layout="page"] .lc-card{background:#151517}\n}\n'+a;const w=document.createElement("h3");w.className="sec-title",w.tabIndex=-1,w.textContent=t.text("nav.local-copy");const k=ie("lc-lede",t.text("local-copy.lede")),C=document.createElement("div");C.className="lc-fail lc-purge";const E=ie("","");E.setAttribute("role","alert");const N=document.createElement("button");N.type="button",N.className="action",N.textContent=t.text("local-copy.wipe.retry"),C.append(E,N);const _=document.createElement("div");_.className="row lc-sw";const A=document.createElement("div"),S=document.createElement("strong");S.id="lc-switch-label",S.className="label",S.textContent=t.text("local-copy.switch");const T=document.createElement("span");T.className="lc-sub",A.append(S,T);const L=document.createElement("div");L.className="lc-swctl";const z=document.createElement("span");z.className="lc-swlbl",z.setAttribute("aria-hidden","true");const M=document.createElement("button");M.type="button",M.className="switch",M.setAttribute("role","switch"),M.setAttribute("aria-labelledby",S.id);const $=document.createElement("span");$.className="knob",M.append($),L.append(z,M),_.append(A,L);const D=ie("note lc-state","");D.setAttribute("role","status");const O=ie("note",""),q=se(t,()=>{de()}),B=ie("error","");B.setAttribute("role","alert");const I=document.createElement("div");I.className="lc-card";const R=document.createElement("div"),j=document.createElement("dl");j.className="lc-kv lc-cozy";const P=ie("lc-small","");I.append(R,j,P);const F=document.createElement("section");F.className="lc-sec";const Y=document.createElement("h3");Y.className="lc-h3",Y.id="lc-folders",F.setAttribute("aria-labelledby",Y.id);const W=document.createElement("span");W.className="lc-cnt";const U=document.createTextNode(t.text("local-copy.folders.title"));Y.append(U,W);const H=document.createElement("dl");H.className="lc-kv",F.append(Y,H);const V=document.createElement("section");V.className="lc-sec lc-wipe";const G=document.createElement("h3");G.className="lc-h3",G.id="lc-wipe",G.textContent=t.text("local-copy.wipe.title"),V.setAttribute("aria-labelledby",G.id);const K=ie("",t.text("local-copy.wipe.body"));K.id="lc-wipe-text-"+ ++lt;const X=document.createElement("button");X.type="button",X.className="action",X.textContent=t.text("local-copy.wipe.button"),X.setAttribute("aria-describedby",K.id);const Z=document.createElement("div");Z.className="lc-fail";const J=ie("",t.text("local-copy.wipe.failed"));J.setAttribute("role","alert");const Q=document.createElement("button");function ee(){return Ke(o.state.effective)}function te(){const e=ee();return"unavailable"!==e&&"enabling"!==e&&("off"!==e||0!==s?.bytesOnDevice)}function ne(){return!c&&!u&&!p&&nt[ee()]&&te()}function oe(){const e=i;i=void 0,e?.close()}function ae(){if(c)return;const e=o.state,n=ee(),a=n===e.effective,l=e.requested,f="enabling"===n||"wiping"===n||"pending"===n||"unavailable"===n;M.setAttribute("aria-checked",String(l));const x=f||p||u,b=M.getRootNode();x&&!M.disabled&&b.activeElement===M&&(h=!0),M.disabled=x,!x&&h&&(h=!1,null!==b.activeElement&&b.activeElement!==document.body||M.focus()),z.textContent=t.text(l?"local-copy.switch.state.on":"local-copy.switch.state.off"),T.textContent=t.text(l?"local-copy.switch.on":"local-copy.switch.off");const v="pending"===n&&"sync_pending"===t.topStatus()&&!u,w=u?"local-copy.state.wiping":ot[n];D.hidden=void 0===w||v,D.textContent=void 0===w?"":t.text(w);const k=a?e.reason??("pending"===n?"erase-pending":"unknown"):"unknown";"unavailable"===n?(O.hidden=!1,O.textContent=`${t.text(`sync.reason.${k}`)} ${t.text("local-copy.unavailable.note")}`):"pending"===n?(O.hidden=!1,O.textContent=`${t.text(`sync.reason.${k}`)} ${t.text("local-copy.pending.note")}`):(O.hidden=!0,O.textContent=""),B.hidden=void 0===r,B.textContent=void 0===r?"":t.text(`sync.error.${r}`);const _=y?.failure();C.hidden=void 0===_,E.textContent=void 0===_?"":t.text(`local-copy.purge.${_}`),N.disabled=m;const A="on"===n||"pending"===n||"enabling"===n||"wiping"===n,S=void 0!==s&&(A||"off"===n);if(I.hidden=!S,F.hidden=!(void 0!==s&&A&&s.folders.length>0),void 0!==s&&S)if(j.hidden=!A,R.hidden=!A,P.hidden=A,A){const e="enabling"===n?{text:t.text("local-copy.state.enabling"),tone:"info"}:(L=s.lastSyncedAt)instanceof Date&&Number.isFinite(L.getTime())?{text:t.text("local-copy.synced",{ago:it(t,s.lastSyncedAt,Date.now())}),tone:"ok"}:{text:t.text("local-copy.synced.unknown"),tone:"info"};R.replaceChildren(d(e));const o=st(s.pending)?0===s.pending?t.text("local-copy.row.waiting.none"):1===s.pending?t.text("local-copy.row.waiting.one"):t.text("local-copy.row.waiting.many",{count:s.pending}):t.text("local-copy.unknown"),a=st(s.bytesOnDevice)?at(t,s.bytesOnDevice):t.text("local-copy.unknown"),i=[rt(t.text("local-copy.row.waiting"),o),rt(t.text("local-copy.row.size"),a)];j.replaceChildren(...i),W.textContent=String(s.folders.length),H.replaceChildren(...s.folders.map(e=>rt(e.prefix,function(e,t){const n=[];return"syncing"!==t.state&&"paused"!==t.state||n.push(e.text(`local-copy.folder.${t.state}`)),st(t.items)||st(t.bytes)||st(t.waiting)?(n.push(st(t.items)?e.text("local-copy.folder.items",{count:t.items}):e.text("local-copy.folder.items.unknown")),n.push(st(t.bytes)?at(e,t.bytes):e.text("local-copy.folder.size.unknown")),st(t.waiting)?t.waiting>0&&n.push(e.text("local-copy.folder.waiting",{count:t.waiting})):n.push(e.text("local-copy.folder.waiting.unknown"))):n.push(e.text("local-copy.folder.unknown")),n.join(" · ")}(t,e),!0,!0)))}else{const e=document.createElement("strong");e.textContent=t.text("local-copy.off.title");const n=0===s.bytesOnDevice?` ${t.text("local-copy.off.empty")}`:st(s.bytesOnDevice)?"":` ${t.text("local-copy.off.unknown")}`;P.replaceChildren(e,`${n} ${t.text("local-copy.off.body",{app:t.appLabel()??t.text("local-copy.off.app")})}`)}var L;const $=te();V.hidden=!$,X.disabled=p||u||"wiping"===n||"enabling"===n,Z.hidden=!g,Q.disabled=X.disabled,void 0===i||u||ne()||oe()}async function de(){const e=t.data.source;if(!e)return s=void 0,q.status.hidden=!0,q.retry.hidden=!0,void ae();const n=++l,o=b,a=await le(()=>e.localCopy());if(c||n!==l||o!==b)return;const i=re(q,t,a);void 0!==i&&(s=i),ae()}async function pe(e){const t=b;p=!0,r=void 0,ae();try{await o.setEnabled(e)}catch(e){c||t!==b||(r=tt(e))}finally{t===b&&(p=!1,ae())}}function ue(e,n,a){if(void 0!==i||!ne())return;f=e;const l=s?.pending,d=[t.text(e?"local-copy.wipe.question.off":"local-copy.wipe.question")];st(l)?l>0&&d.push(t.text(1===l?"local-copy.wipe.unsynced.one":"local-copy.wipe.unsynced.many",{count:l})):d.push(t.text("local-copy.wipe.unsynced.unknown")),e||d.push(t.text("local-copy.wipe.refill"));const p=t.confirm({question:d.join(" "),cancelLabel:t.text("local-copy.wipe.keep"),confirmLabel:t.text("local-copy.wipe.confirm"),anchor:n,onCancel:()=>{i===p&&(i=void 0),c||a.focus()},onConfirm:()=>{!async function(e,n){if(u||i!==e||!ne())return;u=!0;const a=b;g=!1,r=void 0,e.confirm.disabled=!0,e.cancel.disabled=!0,e.confirm.textContent=t.text("local-copy.wipe.busy"),ae();let s=!0;try{await o.wipeLocalData()}catch{s=!1}if(a===b){if(s&&n&&o.state.requested){try{await o.setEnabled(!1)}catch(e){c||a!==b||(r=tt(e))}if(a!==b)return}u=!1,s&&t.toast({kind:"success",textCode:"local-copy.wipe.done"}),c||(oe(),g=!s,ae(),s?(M.focus(),de()):V.hidden||Z.hidden||Q.disabled?w.focus():Q.focus())}}(p,e)}});i=p,p.confirm.closest(".confirm")?.classList.add("lc-confirm")}Q.type="button",Q.className="action",Q.textContent=t.text("local-copy.wipe.retry"),Z.append(J,Q),V.append(G,K,X,Z),e.append(v,w,k,C,_,D,O,q.status,q.retry,B,I,F,V),M.addEventListener("click",()=>{M.disabled||p||u||(o.state.requested?te()?ue(!0,_,M):pe(!1):pe(!0))}),X.addEventListener("click",()=>{X.disabled||(g=!1,ae(),ue(!1,X,X))}),Q.addEventListener("click",()=>{Q.disabled||(g=!1,ae(),ue(f,f?_:X,f?M:X))}),N.addEventListener("click",()=>{if(void 0===y||N.disabled||m)return;const e=b;m=!0,ae(),y.retry().then(n=>{e===b&&(m=!1,n&&t.toast({kind:"success",textCode:"local-copy.purge.done"}),c||(ae(),n?w.focus():N.focus()))})});const ge=o.subscribe(()=>{ae(),t.requestRender(),de()});let fe;const me=()=>{fe?.(),fe=t.data.source?.subscribe(e=>{"copy"===e&&de()})};me();const he=t.client()?.onReset(()=>{b+=1,p=!1,u=!1,m=!1,r=void 0,g=!1,s=void 0,oe(),ce(q,t),ae(),me(),de()}),ye=t.onStatusChange(ae),xe=y?.subscribe(ae),be=setInterval(()=>{ae(),de()},6e4),ve=t.data.latest("localCopy");return"ready"===ve?.state?s=ve.data:ce(q,t),ae(),de(),()=>{c=!0,clearInterval(be),ge(),fe?.(),he?.(),ye(),xe?.(),e.replaceChildren()}}},pt="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",ut=`\n.ll-intro{margin:-20px 0 20px;font-size:15px;line-height:1.5;max-width:56ch;color:#52525b}\n.ll-sub{margin:2px 0 0;font-size:12.5px;color:#52525b}\n.ll-ctl{display:flex;align-items:center;gap:10px;flex:none}\n.ll-word{min-width:22px;text-align:right;font-size:13px;font-weight:700}\n.ll-label{margin:0;font-family:"Literata Variable","Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;font-size:16px;font-weight:500;letter-spacing:-.005em}\n.ll-eyebrow{margin:0;font-size:13px;font-weight:600;line-height:1.3;color:#71717a}\n.ll-card{display:flex;flex-direction:column;gap:14px;margin-top:14px;padding:16px 18px;border-radius:16px;background:#fafafa;box-shadow:inset 0 0 0 1px #e4e4e7}\n.layer .panel[data-layout="page"] .ll-card{background:#fff}\n.ll-card-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}\n.ll-strong{margin:0;font-size:14px;font-weight:600}\n.ll-body{margin:0;font-size:14px;line-height:1.45;color:#52525b}\n.ll-looking{display:flex;align-items:center;gap:14px}\n.ll-spin{flex:none;width:26px;height:26px;border:3px solid #f4f4f5;border-top-color:#09090b;border-radius:50%;animation:ll-spin .9s linear infinite}\n@keyframes ll-spin{to{transform:rotate(360deg)}}\n@media (prefers-reduced-motion: reduce){.ll-spin{animation:none}}\n.ll-cancel{align-self:flex-start;width:auto}\n.ll-kv{display:flex;flex-direction:column;margin:0;padding:0}\n.ll-kv>div{display:flex;align-items:center;gap:10px;box-sizing:border-box;min-height:44px;padding:9px 0;border-bottom:1px solid #e4e4e7}\n.ll-kv>div:last-child{border-bottom:0}\n.ll-kv dt{display:flex;flex:1 1 auto;align-items:baseline;gap:10px;min-width:0;font-size:14px;color:#52525b;white-space:nowrap}\n.ll-kv dt::after{content:"";flex:1 1 12px;min-width:12px;border-bottom:2px dotted #a1a1aa;transform:translateY(-3px)}\n.ll-kv dd{display:flex;flex:0 1 auto;align-items:center;justify-content:flex-end;gap:2px;max-width:100%;min-width:0;margin:0;font-size:14px;font-weight:600;text-align:right;overflow-wrap:anywhere}\n.ll-mono,.ll-did{min-width:0;font-family:${pt};font-size:12.5px;overflow-wrap:anywhere}\n.ll-host{overflow-wrap:anywhere}\n.ll-cell{display:flex;align-items:center;gap:8px;min-width:0}\n.ll-codeline{display:flex;align-items:center;justify-content:space-between;gap:4px;box-sizing:border-box;margin-top:8px;padding:2px 4px 2px 14px;border-radius:12px;background:#f4f4f5;min-height:44px;font-family:${pt};font-size:13px}\n.ll-codeline code{min-width:0;overflow-wrap:anywhere}\n.ll-steps{display:flex;flex-direction:column;gap:12px;margin:0;padding:0;list-style:none;counter-reset:ll-step;font-size:14px;line-height:1.45;color:#09090b}\n.ll-steps li{position:relative;padding-left:34px;counter-increment:ll-step}\n.ll-steps li::before{content:counter(ll-step);position:absolute;left:0;top:-1px;width:24px;height:24px;border-radius:50%;box-shadow:inset 0 0 0 1px #71717a;font:600 12px/24px ${pt};text-align:center}\n.ll-unknown{color:#52525b}\n@media (prefers-color-scheme: dark){\n.ll-intro,.ll-sub,.ll-body,.ll-kv dt,.ll-unknown{color:#a1a1aa}\n.ll-card{background:#151517;box-shadow:inset 0 0 0 1px #69696b}\n.layer .panel[data-layout="page"] .ll-card{background:#151517}\n.ll-eyebrow{color:#a1a1aa}\n.ll-spin{border-color:#27272a;border-top-color:#fafafa}\n.ll-kv>div{border-bottom-color:#69696b}\n.ll-kv dt::after{border-bottom-color:#71717a}\n.ll-codeline{background:#27272a}\n.ll-steps{color:#fafafa}\n}\n`,gt={found:{code:"local-tinycloud.glance.found",tone:"ok"},looking:{code:"local-tinycloud.glance.looking",tone:"info"},"not-found":{code:"local-tinycloud.glance.not_found",tone:"off"},off:{code:"local-tinycloud.glance.off",tone:"off"},unavailable:{code:"section.status.unavailable",tone:"off"}},ft={off:"local-tinycloud.sub.off",looking:"local-tinycloud.sub.looking",found:"local-tinycloud.sub.found","not-found":"local-tinycloud.sub.not_found",unavailable:"local-tinycloud.sub.unavailable"};y({"local-tinycloud.summary":"Use a TinyCloud node on this computer","local-tinycloud.intro":"Use a TinyCloud that runs on this computer, next to your browser, instead of only your hosted one.","local-tinycloud.switch":"Use TinyCloud on this computer","local-tinycloud.switch.on":"On","local-tinycloud.switch.off":"Off","local-tinycloud.sub.off":"Off for this app","local-tinycloud.sub.looking":"Checking this computer…","local-tinycloud.sub.found":"Connected to a TinyCloud on this computer","local-tinycloud.sub.not_found":"Switched on, but nothing answered","local-tinycloud.sub.unavailable":"Not available in this app yet","local-tinycloud.app_fallback":"This app","local-tinycloud.glance.found":"Found","local-tinycloud.glance.looking":"Looking","local-tinycloud.glance.not_found":"Not found","local-tinycloud.glance.off":"Off","local-tinycloud.off.body":"{app} talks to your hosted TinyCloud only. Turn this on and it looks for a TinyCloud running on this computer.","local-tinycloud.looking.title":"Looking for TinyCloud on this computer…","local-tinycloud.looking.permission":"Your browser may ask to let {app} reach devices on your network. Allow it so the check can finish.","local-tinycloud.looking.cancel":"Cancel","local-tinycloud.found.recheck":"Check again","local-tinycloud.found.node_id":"Node ID","local-tinycloud.found.version":"Version","local-tinycloud.found.host":"Host","local-tinycloud.unknown":"Unknown","local-tinycloud.copy.node_id_label":"Copy node ID","local-tinycloud.copy.host_label":"Copy host","local-tinycloud.copy.command_label":"Copy command","local-tinycloud.copied":"Copied","local-tinycloud.copy_failed":"Couldn't copy. Select the text and copy it by hand.","local-tinycloud.not_found.title":"We couldn't find TinyCloud on this computer.","local-tinycloud.not_found.unchanged":"Nothing has changed: {app} still uses your hosted TinyCloud.","local-tinycloud.not_found.steps_title":"To start it","local-tinycloud.not_found.step_open":"Open TinyCloud on this computer, or start it from a terminal.","local-tinycloud.not_found.step_command":"tinycloud start","local-tinycloud.not_found.step_listen":"Check that it's listening on 127.0.0.1:8787.","local-tinycloud.not_found.step_retry":"Come back here and choose Try again.","local-tinycloud.not_found.retry":"Try again","local-tinycloud.unavailable.line":"Local TinyCloud can't be checked from this app.","local-tinycloud.unavailable.explain":"This app can't turn TinyCloud on this computer on or off yet, so the switch is off.","local-tinycloud.error":"Couldn't change TinyCloud on this computer. Try again."});const mt={id:"local-tinycloud",labelCode:"nav.local-tinycloud",icon:"monitor",summaryCode:"local-tinycloud.summary",isAvailable:D,status:e=>te(e,e.data.latest("localNode"),t=>{const n=gt[t.connection];return{text:e.text(n.code),tone:n.tone}}),mount(e,t){const n=t.client()?.data;if(!n)return O(e);let o,s,r,c=n,p=0,u=!1,g=!1,f=0;const m=()=>t.appLabel()??t.text("local-tinycloud.app_fallback"),h=se(t,()=>{B()}),y=document.createElement("div");y.hidden=!0;const x=ie("ll-intro",t.text("local-tinycloud.intro")),b=document.createElement("h3");b.className="sec-title",b.tabIndex=-1,b.textContent=t.text("nav.local-tinycloud");const v=document.createElement("div");v.className="row";const w=document.createElement("div"),k=ie("label ll-label",t.text("local-tinycloud.switch")),C=ie("ll-sub","");w.append(k,C);const E=document.createElement("div");E.className="ll-ctl";const N=document.createElement("span");N.className="ll-word";const _=document.createElement("button");_.type="button",_.className="switch",_.setAttribute("role","switch"),_.setAttribute("aria-label",t.text("local-tinycloud.switch"));const A=document.createElement("span");A.className="knob",_.append(A),E.append(N,_),v.append(w,E);const S=document.createElement("div");S.className="ll-card";const T=ie("error",t.text("local-tinycloud.error"));T.setAttribute("role","alert"),T.hidden=!0;const L=i(t.text("view.retry"));function z(e,n){const o=document.createElement("button");return o.className="icon-btn",o.setAttribute("aria-label",t.text(n)),o.append(l("copy")),o.addEventListener("click",()=>{!async function(e){const n=p;try{await navigator.clipboard.writeText(e),u||n!==p||t.toast({kind:"success",textCode:"local-tinycloud.copied"})}catch{u||n!==p||t.toast({kind:"error",textCode:"local-tinycloud.copy_failed"})}}(e)}),o}function M(){const e=document.createElement("span");return e.className="ll-unknown",e.textContent=t.text("local-tinycloud.unknown"),e}function $(e){const n=gt[e];return d({text:t.text(n.code),tone:n.tone})}function D(e,t){const n=document.createElement("div");return n.className="ll-card-head",n.append(e,...t?[t]:[]),n}function q(){if(u)return;if(y.hidden=void 0===s,void 0===s)return;const e=s.connection,n="off"!==e&&"unavailable"!==e;_.setAttribute("aria-checked",String(n)),_.disabled="unavailable"===e,_.setAttribute("aria-disabled",String(g)),N.textContent=t.text(n?"local-tinycloud.switch.on":"local-tinycloud.switch.off"),C.textContent=t.text(ft[e]),S.replaceChildren(...function(e){switch(e.connection){case"off":return[D($("off")),ie("ll-body",t.text("local-tinycloud.off.body",{app:m()}))];case"looking":{const e=document.createElement("span");e.className="ll-spin",e.setAttribute("aria-hidden","true");const n=document.createElement("div");n.append(ie("ll-strong",t.text("local-tinycloud.looking.title")),ie("ll-body",t.text("local-tinycloud.looking.permission",{app:m()})));const o=document.createElement("div");o.className="ll-looking",o.append(e,n);const a=i(t.text("local-tinycloud.looking.cancel"));return a.classList.add("ll-cancel"),a.addEventListener("click",()=>{g||I(!1)}),[o,a]}case"found":{const n=i(t.text("local-tinycloud.found.recheck"));n.addEventListener("click",()=>{B()});const o=document.createElement("dl");o.className="ll-kv";const a=(e,n)=>{const a=document.createElement("div"),i=document.createElement("dt");i.textContent=t.text(e);const s=document.createElement("dd");s.append(n),a.append(i,s),o.append(a)},s=e.identity?.nodeDid,r=document.createElement("span");if(r.className="ll-cell",s){const e=document.createElement("span");e.className="ll-did",e.textContent=s.length>18?`${s.slice(0,12)}…${s.slice(-6)}`:s,e.title=s,r.append(e,z(s,"local-tinycloud.copy.node_id_label"))}else r.append(M());a("local-tinycloud.found.node_id",r);const c=document.createElement("span");e.version?c.textContent=e.version:c.append(M()),a("local-tinycloud.found.version",c);const l=document.createElement("span");if(l.className="ll-cell",e.url){const t=document.createElement("span");t.className="ll-mono ll-host",t.textContent=e.url,t.title=e.url,l.append(t,z(e.url,"local-tinycloud.copy.host_label"))}else l.append(M());return a("local-tinycloud.found.host",l),[D($("found"),n),o]}case"not-found":{const e=i(t.text("local-tinycloud.not_found.retry"));e.addEventListener("click",()=>{B()});const n=t.text("local-tinycloud.not_found.step_command"),o=document.createElement("code");o.textContent=n;const a=document.createElement("div");a.className="ll-codeline",a.append(o,z(n,"local-tinycloud.copy.command_label"));const s=document.createElement("ol");s.className="ll-steps";const r=document.createElement("li");r.append(t.text("local-tinycloud.not_found.step_open"),a);const c=document.createElement("li");c.textContent=t.text("local-tinycloud.not_found.step_listen");const l=document.createElement("li");l.textContent=t.text("local-tinycloud.not_found.step_retry"),s.append(r,c,l);const d=document.createElement("p");d.className="ll-body";const p=document.createElement("strong");return p.textContent=t.text("local-tinycloud.not_found.title"),d.append(p,` ${t.text("local-tinycloud.not_found.unchanged",{app:m()})}`),[D($("not-found"),e),d,ie("ll-eyebrow",t.text("local-tinycloud.not_found.steps_title")),s]}case"unavailable":return[D($("unavailable")),ie("ll-strong",t.text("local-tinycloud.unavailable.line")),ie("ll-body",t.text("local-tinycloud.unavailable.explain"))]}}(s))}async function B(){const e=++f,n=c,o=p;if(void 0===n)return;const a=await le(()=>n.localNode());u||e!==f||o!==p||(s=re(h,t,a),q())}async function I(e){const t=c;if(void 0===t)return;const n=p;let o;g=!0,r=e,T.hidden=!0,L.hidden=!0,q();try{o=await t.setLocalNodeEnabled(e)}catch{o={ok:!1,code:"unknown"}}u||n!==p||(g=!1,T.hidden=o.ok,L.hidden=o.ok,o.ok&&(r=void 0),await B())}function R(){o?.(),o=c?.subscribe(e=>{"local"===e&&B()})}L.hidden=!0,L.addEventListener("click",()=>{void 0!==r&&I(r)}),y.append(v,S,T,L),_.addEventListener("click",()=>{g||void 0===s||"unavailable"===s.connection||I("off"===s.connection)});const j=t.onClientChange(()=>{if(p+=1,g=!1,r=void 0,T.hidden=!0,L.hidden=!0,s=void 0,c=t.client()?.data,R(),q(),void 0===c)return h.status.hidden=!0,void(h.retry.hidden=!0);ce(h,t),B()});R();const P=document.createElement("style");return P.textContent=ut+a,e.append(P,b,x,h.status,h.retry,y),ce(h,t),B(),()=>{u=!0,j(),o?.(),e.replaceChildren()}}};y({"nodes.summary":"Nodes your data syncs with","nodes.title":"Connected nodes","nodes.lede":"The nodes this session is talking to right now. TinyCloud picks the node for each space; there is nothing to switch here.","nodes.empty":"No node is in use right now.","nodes.unavailable":"Not available right now.","nodes.glance.none":"None","nodes.glance.healthy":"Healthy","nodes.glance.slow":"{count} slow","nodes.glance.down":"{count} down","nodes.card.ok":"Connected","nodes.card.slow":"Slow to respond","nodes.role.local":"On this computer","nodes.role.ownHosted":"Your hosted TinyCloud","nodes.nodeid":"Node ID","nodes.copy":"Copy the node ID of {host}","nodes.spaces":"Spaces here","nodes.latency.value":"{ms} ms · seen {seen}","nodes.latency.only":"{ms} ms","nodes.seen.seconds":"{count} s ago","nodes.seen.minutes":"{count} min ago"});const ht={ok:"nodes.card.ok",slow:"nodes.card.slow",down:"nodes.status.down"},yt={ok:"ok",slow:"warn",down:"warn"},xt={id:"nodes",labelCode:"nav.nodes",icon:"nodes",summaryCode:"nodes.summary",isAvailable:D,status:e=>te(e,e.data.latest("nodes"),t=>{const n=String(t.length);if(0===t.length)return{text:e.text("nodes.glance.none"),tone:"off",count:n};const o=t.filter(e=>"down"===e.status).length;if(o>0)return{text:e.text("nodes.glance.down",{count:o}),tone:"warn",count:n};const a=t.filter(e=>"slow"===e.status).length;return a>0?{text:e.text("nodes.glance.slow",{count:a}),tone:"warn",count:n}:{text:e.text("nodes.glance.healthy"),tone:"ok",count:n}}),mount(e,t){let n=t.client()?.data,o=!1,i=0;const s=document.createElement("style");s.textContent='\n.nd-wrap{container-type:inline-size;min-width:0}\n.nd-wrap>.nd-lede{margin:0 0 20px;font-size:15px;line-height:1.5;max-width:56ch;color:#09090b}\n.nd-cards{display:grid;gap:14px;grid-template-columns:minmax(0,1fr);margin:0;padding:0;list-style:none}\n@container (min-width:720px){.nd-cards{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}}\n.nd-card{min-width:0;padding:14px 16px;border:1px solid #e4e4e7;border-radius:12px;--nd-leader:#a1a1aa}\n.nd-card .row{align-items:baseline}\n.nd-card .row>div{min-width:0;flex:1}\n.nd-host{font:600 15px/1.3 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow-wrap:anywhere}\n.nd-kv{display:flex;flex-direction:column;margin:8px 0 0;padding:0}\n.nd-kv>div{display:flex;align-items:center;gap:10px;min-height:40px;padding:0;border-top:1px solid #f4f4f5}\n.nd-kv dt{display:flex;align-items:baseline;gap:10px;flex:1 1 auto;min-width:0;margin:0;font-size:14px;color:#52525b;white-space:nowrap}\n.nd-kv dt::after{content:"";flex:1 1 12px;min-width:12px;border-bottom:2px dotted var(--nd-leader);transform:translateY(-3px)}\n.nd-kv dd{display:flex;align-items:center;justify-content:flex-end;gap:2px;flex:0 1 auto;max-width:78%;min-width:0;margin:0;font-size:14px;font-weight:600;text-align:right;overflow-wrap:anywhere}\n.nd-kv dd.nd-mono{font-size:12px;font-weight:500}\n.nd-did-row{display:flex;align-items:center;gap:6px;min-width:0;max-width:100%}\n.nd-did{min-width:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow-wrap:anywhere}\n.nd-did-head,.nd-did-tail{overflow-wrap:anywhere}\n.nd-chips{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px;margin:0;padding:0;list-style:none}\n.nd-chip{display:inline-flex;align-items:center;min-height:28px;padding:0 11px;border-radius:999px;background:#f4f4f5;font-size:12.5px;font-weight:600;overflow-wrap:anywhere}\n.nd-card .icon-btn{margin:-10px -10px -10px 0}\n.nd-did-row .icon-btn{margin:-10px 0}\n@media (prefers-color-scheme: dark){\n.nd-wrap>.nd-lede{color:#fafafa}\n.nd-card{border-color:#3f3f46;--nd-leader:#71717a}\n.nd-kv>div{border-top-color:#27272a}\n.nd-kv dt{color:#a1a1aa}\n.nd-chip{background:#27272a}\n}\n'+a;const r=document.createElement("h3");r.className="sec-title",r.tabIndex=-1,r.textContent=t.text("nodes.title");const c=se(t,()=>{m()}),p=document.createElement("div");p.hidden=!0;const u=ie("note",t.text("nodes.lede"));u.classList.add("nd-lede");const g=ie("note",t.text("nodes.empty"));g.hidden=!0;const f=document.createElement("ul");async function m(){const e=++i,a=n;if(void 0===a)return y(),c.status.hidden=!1,c.status.textContent=t.text("nodes.unavailable"),void(c.retry.hidden=!0);const s=await le(()=>a.nodes());if(o||e!==i)return;const r=re(c,t,s);p.hidden=void 0===r,void 0!==r&&(g.hidden=r.length>0,f.replaceChildren(...r.map(e=>function(e){const n=function(e){try{return new URL(e).host}catch{return e}}(e.origin),o=document.createElement("li");o.className="nd-card",o.setAttribute("aria-label",n);const a=document.createElement("div");a.className="row";const i=document.createElement("div"),s=ie("label",n);s.classList.add("nd-host"),i.append(s,ie("note",function(e,t){return"local"===e.kind?t.text("nodes.role.local"):e.active?t.text("nodes.role.ownHosted"):t.text("nodes.kind.hosted")}(e,t)));const r={text:t.text(ht[e.status]),tone:yt[e.status]};a.append(i,d(r)),o.append(a);const c=[],p=(e,t,n=!1)=>{const o=document.createElement("div"),a=document.createElement("dt");a.textContent=e;const i=document.createElement("dd");n&&(i.className="nd-mono"),i.append(t),o.append(a,i),c.push(o)},u=e=>{const t=document.createElement("span");return t.textContent=e,t};if(void 0!==e.nodeDid){const o=document.createElement("span");o.className="nd-did";const a=Math.max(0,e.nodeDid.length-4),i=document.createElement("span");i.className="nd-did-head",i.textContent=e.nodeDid.slice(0,a);const s=document.createElement("span");s.className="nd-did-tail",s.textContent=e.nodeDid.slice(a),o.append(i,s);const r=document.createElement("button");r.type="button",r.className="icon-btn",r.setAttribute("aria-label",t.text("nodes.copy",{host:n})),r.append(l("copy")),r.addEventListener("click",()=>{navigator.clipboard?.writeText(o.textContent??"").catch(()=>{})});const c=document.createElement("span");c.className="nd-did-row",c.append(o,r),p(t.text("nodes.nodeid"),c,!0)}"string"==typeof e.version&&""!==e.version.trim()&&p(t.text("nodes.version"),u(`v${e.version}`));const g="number"==typeof e.latencyMs&&Number.isFinite(e.latencyMs)?e.latencyMs:void 0;if(void 0!==g){const n=String(g),o=function(e,t,n){if(!(e instanceof Date))return;const o=t-e.getTime();if(!Number.isFinite(o)||o<0)return;const a=Math.floor(o/1e3);return a<60?n.text("nodes.seen.seconds",{count:a}):n.text("nodes.seen.minutes",{count:Math.floor(a/60)})}(e.lastSeenAt,Date.now(),t),a=void 0!==o?t.text("nodes.latency.value",{ms:n,seen:o}):t.text("nodes.latency.only",{ms:n});p(t.text("nodes.latency"),u(a))}const f=Array.isArray(e.spaces)?e.spaces.filter(e=>"string"==typeof e&&""!==e.trim()):[];if(f.length>0){const e=document.createElement("ul");e.className="nd-chips",e.append(...f.map(e=>{const t=document.createElement("li");return t.className="nd-chip",t.textContent=e,t})),p(t.text("nodes.spaces"),e)}if(c.length>0){const e=document.createElement("dl");e.className="nd-kv",e.append(...c),o.append(e)}return o}(e))))}function h(e){return e.subscribe(e=>{"nodes"===e&&m()})}function y(){p.hidden=!0,g.hidden=!0,f.replaceChildren()}function x(){i++,b(),v?.(),y();const o=t.client()?.data;n=o,void 0===o?s.remove():e.prepend(s),b=o?h(o):()=>{},v=t.client()?.onReset(x),void 0!==o&&ce(c,t),m()}f.className="nd-cards",p.className="nd-wrap",p.append(u,g,f);let b=n?h(n):()=>{},v=t.client()?.onReset(x);const w=t.onClientChange(x);return e.append(r,c.status,c.retry,p),void 0!==n&&(e.prepend(s),ce(c,t)),m(),()=>{o=!0,w(),v?.(),b(),e.replaceChildren()}}},bt="https://account.tinycloud.xyz/storage";function vt(e){if("object"!=typeof e||null===e||!("manageUrl"in e))return bt;const t=e.manageUrl;if("string"!=typeof t)return bt;try{return"https:"===new URL(t).protocol?t:bt}catch{return bt}}const wt={unsupported:!0,STORAGE_STATUS_UNAVAILABLE:!0};function kt(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function Ct(e){return"object"==typeof e&&null!==e&&"usedBytes"in e&&"limitBytes"in e&&kt(e.usedBytes)&&(null===e.limitBytes||kt(e.limitBytes))}y({"storage.summary":"How much space is used","storage.glance.normal":"Normal","storage.glance.nearly_full":"Nearly full","storage.glance.full":"Full","storage.page.lede":"Your storage is shared by every TinyCloud app you use.","storage.page.lede_short":"How much of your TinyCloud you use.","storage.page.used":"Used","storage.page.by_space":"By space","storage.page.meter":"Storage used","storage.page.of_limit":"of {limit}","storage.page.meter_text":"{used} of {limit} used. {state}.","storage.page.meter_text_open":"{used} used. {state}.","storage.page.space_meter":"{space} storage used","storage.page.space_meter_text":"{used} of {limit}","storage.page.plan":"Plan","storage.page.left":"Left","storage.page.none":"None","storage.page.no_limit":"No limit","storage.page.manage_hint":"(opens in a new tab)","storage.page.nearly_note":"You're close to your limit. Saving large recordings may fail soon.","storage.page.full_title":"Storage full: you can't add more data right now.","storage.page.full_body":"Your existing data stays as it is.","storage.page.unavailable_node":"Storage usage isn't available on this node.","storage.page.permission_title":"{app} can't see your storage yet","storage.page.permission_app":"This app","storage.page.permission_body":"To show how much you use and your plan, TinyCloud needs your permission to read storage details. It can't read, change or delete your files.","storage.page.permission_approve":"You'll approve it in OpenKey.","storage.page.permission_blocked":"This session has no way to ask for it here.","storage.page.allow":"Allow storage details","storage.page.waiting":"Waiting for OpenKey…","storage.page.age_now":"Updated just now","storage.page.age_minutes":"Updated {count} min ago","storage.page.age_hours":"Updated {count} h ago"});const Et="\n.storage-banner{display:flex;gap:12px;align-items:flex-start;box-sizing:border-box;margin:0 0 28px;padding:14px 16px;border-radius:12px;box-shadow:inset 0 0 0 1px #e4e4e7;font-size:14px;line-height:1.45}\n.storage-banner .ui-ic{width:22px;height:22px;margin-top:1px;color:#b35309}\n.storage-banner strong{display:block}\n.storage-banner a.storage-manage{padding-left:0}\n@media (prefers-color-scheme: dark){\n.storage-banner{box-shadow:inset 0 0 0 1px #69696b}\n.storage-banner .ui-ic{color:#f59e0b}\n}\n",Nt={ok:"normal",nearly_full:"nearly",full:"full"},_t=["B","KiB","MiB","GiB","TiB"];function At(e,t){return Number(e.toFixed(t>=3?2:1))}function St(e){let t=0,n=e;for(;t<_t.length-1&&n>=1024;)n/=1024,t+=1;if(0===t)return{amount:String(n),unit:"B"};let o=At(n,t);return o>=1024&&t<_t.length-1&&(t+=1,o=At(n/1024,t)),{amount:String(o),unit:_t[t]??"B"}}function Tt(e){const{amount:t,unit:n}=St(e);return`${t} ${n}`}function Lt(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function zt(e){const t="perSpace"in e?e.perSpace:void 0;if(!Array.isArray(t))return[];const n=[];for(const e of t){if("object"!=typeof e||null===e)continue;const{space:t,usage:o,source:a}=e;if("string"!=typeof t||"object"!=typeof o||null===o)continue;const{usedBytes:i,limitBytes:s}=o;Lt(i)&&(null===s||Lt(s))&&n.push({space:t,usedBytes:i,limitBytes:null===s?null:s,source:"string"==typeof a?a:"real"})}return n}function Mt(e){if(!(Ct(t=e)&&"state"in t&&function(e){return"ok"===e||"nearly_full"===e||"full"===e}(t.state))||"account"in t&&void 0!==t.account&&!Ct(t.account))return;var t;const n=e.account??e,o=n.limitBytes,a=e.account?.plan??e.plan;return{level:null===o?"normal":Nt[e.state],usedBytes:n.usedBytes,limitBytes:o,percent:null!==o&&o>0?Math.min(100,Math.round(n.usedBytes/o*1e3)/10):void 0,plan:"string"==typeof a&&""!==a?a:void 0,leftBytes:null===o?void 0:Math.max(0,o-n.usedBytes),spaces:zt(e),manageHref:vt(e)}}const $t={normal:{key:"storage.glance.normal",tone:"ok"},nearly:{key:"storage.glance.nearly_full",tone:"warn"},full:{key:"storage.glance.full",tone:"warn"}};function Dt(e,t,n=""){const o=document.createElement(e);return o.className=t,""!==n&&(o.textContent=n),o}function Ot(e,t,n,o){const a=Dt("div","storage-meter");a.setAttribute("role","meter"),a.setAttribute("aria-label",e),a.setAttribute("aria-valuemin","0"),a.setAttribute("aria-valuemax",String(t)),a.setAttribute("aria-valuenow",String(Math.min(n,t))),a.setAttribute("aria-valuetext",o);const i=Dt("i","storage-fill");return i.style.width=`${Math.min(100,n/t*100)}%`,a.append(i),a}function qt(e,t){const n=Dt("div","storage-link"),o=Dt("a","storage-manage");return o.href=t,o.target="_blank",o.rel="noopener noreferrer",o.append(e.text("storage.manage"),Dt("span","storage-sr",` ${e.text("storage.page.manage_hint")}`),l("ext")),n.append(o),n}function Bt(e,t){const n=Dt("span","storage-st");n.dataset.tone=t;const o=Dt("span","storage-dot");return o.setAttribute("aria-hidden","true"),n.append(o,Dt("span","",e)),n}function It(e,t){const n=Dt("div","storage-banner");n.setAttribute("role","status");const o=document.createElement("div"),a=Dt("strong","",e.text("storage.page.full_title"));return o.append(a,e.text("storage.page.full_body"),qt(e,t)),n.append(l("warn"),o),n}const Rt={id:"storage",labelCode:"nav.storage",icon:"drive",summaryCode:"storage.summary",status:e=>void 0!==e.client()?.storageEpisode?.current()?{text:e.text("storage.glance.full"),tone:"warn"}:te(e,e.data.latest("storage"),t=>{const n=null===Mt(t)?.limitBytes;return n||"full"!==t.state?n||"nearly_full"!==t.state?{text:e.text("storage.glance.normal"),tone:"ok"}:{text:e.text("storage.glance.nearly_full"),tone:"warn"}:{text:e.text("storage.glance.full"),tone:"warn"}}),isAvailable:e=>!0===e.client()?.signedIn(),mount:function(e,t){const n=document.createElement("style");n.textContent='\n.ui-ic{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}\n.storage-lede{margin:-14px 0 28px;max-width:56ch;font-size:15px;line-height:1.5}\n.storage-cols{display:grid;gap:28px 36px;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));align-items:start}\n.storage-h{display:flex;align-items:center;gap:10px;margin:0 0 12px;font-size:13px;font-weight:600;line-height:1.3;letter-spacing:.02em}\n.storage-h::after{content:"";flex:1;height:1px;background:#e4e4e7}\n.storage-hd{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:12px}\n.storage-fig{font-size:2.75rem;font-weight:600;line-height:1;font-variant-numeric:tabular-nums;letter-spacing:-.03em}\n.storage-fig small{margin-left:2px;white-space:pre-wrap;font-size:1rem;font-weight:500;letter-spacing:0;color:#71717a}\n.storage-st{display:inline-flex;align-items:center;gap:8px;font-size:13.5px;font-weight:600;white-space:nowrap;color:#18181b}\n.storage-dot{position:relative;flex:none;width:9px;height:9px;border-radius:50%;background:currentColor}\n.storage-st[data-tone="warn"]{color:#92400e}\n.storage-st[data-tone="warn"] .storage-dot{background:#b45309;box-shadow:0 0 0 1.5px #fff,0 0 0 2.5px #b45309}\n.storage-meter{height:6px;border-radius:999px;background:#f4f4f5;box-shadow:inset 0 0 0 1px #71717a;overflow:hidden}\n.storage-fill{display:block;height:100%;border-radius:999px;background:#09090b;transition:width .6s ease}\n.storage-kv{display:flex;flex-direction:column;margin:14px 0 0;padding:0}\n.storage-kv>div{display:flex;align-items:center;gap:10px;box-sizing:border-box;min-height:44px;padding:9px 0;border-bottom:1px solid #e4e4e7}\n.storage-kv>div:last-child{border-bottom:0}\n.storage-kv dt{display:flex;flex:1 1 auto;align-items:baseline;gap:10px;min-width:0;margin:0;font-size:14px;white-space:nowrap}\n.storage-kv dt::after{content:"";flex:1 1 12px;min-width:12px;border-bottom:2px dotted #a1a1aa;transform:translateY(-3px)}\n.storage-kv dd{flex:0 1 auto;max-width:78%;margin:0;font-size:14px;font-weight:600;text-align:right;overflow-wrap:anywhere}\n.storage-link{margin-top:6px}\na.storage-manage{display:inline-flex;align-items:center;gap:6px;box-sizing:border-box;min-height:44px;padding:0 4px;color:inherit;font-size:13px;font-weight:600;text-decoration:underline;text-underline-offset:3px}\na.storage-manage:focus-visible{outline:2px solid #111827;outline-offset:2px}\na.storage-manage .ui-ic{width:14px;height:14px}\n.storage-sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.storage-updated{margin:18px 0 0;font-size:12.5px;line-height:1.4;color:#71717a}\n@media (prefers-reduced-motion:reduce){.storage-fill{transition:none}}\n@media (prefers-color-scheme: dark){\n.storage-kv>div{border-bottom-color:#3f3f46}\n.storage-h::after{background:#3f3f46}\n.storage-fig small,.storage-updated{color:#a1a1aa}\n.storage-st{color:#fafafa}\n.storage-st[data-tone="warn"]{color:#fcd34d}\n.storage-st[data-tone="warn"] .storage-dot{background:#f59e0b;box-shadow:0 0 0 1.5px #151517,0 0 0 2.5px #f59e0b}\n.storage-meter{background:#27272a}\n.storage-fill{background:#fafafa}\n.storage-kv dt::after{border-bottom-color:#71717a}\na.storage-manage:focus-visible{outline-color:#fafafa}\n}\n';const o=new Set,a=e=>{o.has(e)||(o.add(e),n.append(e))},i=Dt("h3","sec-title",t.text("nav.storage"));i.tabIndex=-1;const s=Dt("p","storage-lede");let r,c=!1,d=!1,p=0,u=!1;const g=()=>void 0!==t.client()?.storageEpisode?.current();let f=g();const m=se(t,()=>{N()}),h=document.createElement("div"),y=Dt("p","storage-updated"),x=Dt("div","storage-ask"),b=Dt("span","ic");b.setAttribute("aria-hidden","true"),b.append(l("drive"));const v=Dt("h4",""),w=document.createElement("p"),k=Dt("p","note"),C=Dt("button","action storage-primary");C.type="button";const E=document.createElement("div");async function N(){if(d)return;const e=p;d=!0,A();try{await t.data.refresh("storage")}catch{}e===p&&(d=!1,A())}function _(){p+=1,d=!1,u=!1,r=void 0,A()}function A(){if(c)return;if(void 0===t.data.source)return m.status.hidden=!1,m.status.textContent=t.text("storage.unavailable"),m.retry.hidden=!0,x.hidden=!0,h.replaceChildren(),void(y.hidden=!0);const e=d?{state:"loading"}:t.data.latest("storage")??{state:"loading"},n=g(),o="needs-permission"===e.state&&!n;let i;if(s.textContent=t.text(o?"storage.page.lede_short":"storage.page.lede"),o)m.status.hidden=!0,m.retry.hidden=!0;else if(d||"error"!==e.state||(p=e.code,!0!==wt[p])){const n=re(m,t,e);i=void 0===n?void 0:Mt(n),void 0!==n&&void 0===i&&(m.status.hidden=!1,m.status.textContent=t.text("storage.unavailable"))}else m.status.hidden=!1,m.status.textContent=t.text("storage.page.unavailable_node"),m.retry.hidden=!0;var p;if(n&&(m.status.hidden=!0,m.retry.hidden=!0,i=void 0),o&&a('\n.storage-ask{display:flex;flex-direction:column;align-items:flex-start;gap:14px;box-sizing:border-box;padding:20px;border-radius:20px;box-shadow:inset 0 0 0 1px #e4e4e7}\n.storage-ask .ic{display:grid;place-items:center;width:44px;height:44px;border-radius:50%;box-shadow:inset 0 0 0 1px #71717a}\n.storage-ask h4{margin:0 0 6px;font:400 1.375rem/1.2 "Literata Variable","Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;overflow-wrap:anywhere}\n.storage-ask p{max-width:52ch;margin:0;font-size:14px;line-height:1.45}\n.storage-ask .note{margin-top:8px;font-size:13px}\n.action.storage-primary{border-color:#09090b;background:#09090b;color:#fff}\n.action.storage-primary:hover{background:#27272a}\n@media (prefers-color-scheme: dark){\n.storage-ask{box-shadow:inset 0 0 0 1px #69696b}\n.action.storage-primary{border-color:#fafafa;background:#fafafa;color:#09090b}\n.action.storage-primary:hover{background:#e4e4e7}\n}\n'),x.hidden=!o,"needs-permission"===e.state){const n=void 0!==t.client()?.requestAuthority&&"space/info"===e.ability;v.textContent=t.text("storage.page.permission_title",{app:t.appLabel()??t.text("storage.page.permission_app")}),w.textContent=n?`${t.text("storage.page.permission_body")} ${t.text("storage.page.permission_approve")}`:t.text("storage.page.permission_body"),C.hidden=!n,C.disabled=u,C.textContent=t.text(u?"storage.page.waiting":"declined"===r?"storage.try_again":"storage.page.allow");const o=n&&"blocked"!==r?"declined"===r?"storage.declined":"":"storage.page.permission_blocked";k.hidden=""===o,k.textContent=""===o?"":t.text(o)}if(n){a(Et);const n=Dt("div","storage-hd");n.append(Bt(t.text($t.full.key),$t.full.tone));const o="ready"===e.state?vt(e.data):bt;h.replaceChildren(It(t,o),n)}else if(void 0===i)h.replaceChildren();else{"full"===i.level&&a(Et),"nearly"===i.level&&a("\n.storage-near{display:flex;gap:6px;align-items:flex-start;margin:6px 0 0;font-size:12.5px;line-height:1.4}\n.storage-near .ui-ic{width:16px;height:16px;margin-top:1px;color:#b35309}\n@media (prefers-color-scheme: dark){.storage-near .ui-ic{color:#f59e0b}}\n"),i.spaces.length>0&&a("\n.storage-h .cnt{font-weight:500;color:#71717a}\n.storage-spaces{margin:0;padding:0;list-style:none}\n.storage-space{display:flex;flex-direction:column;gap:8px;padding:12px 0;border-bottom:1px solid #e4e4e7}\n.storage-space:last-child{border-bottom:0}\n.storage-space .l{display:flex;justify-content:space-between;align-items:baseline;gap:12px;font-size:14px}\n.storage-space .l b{font-weight:600;overflow-wrap:anywhere}\n.storage-space .l span{font-variant-numeric:tabular-nums}\n@media (prefers-color-scheme: dark){\n.storage-h .cnt{color:#a1a1aa}\n.storage-space{border-bottom-color:#3f3f46}\n}\n");const e=Dt("div","storage-cols");e.append(function(e,t){const n=$t[t.level],o=Dt("section","storage-used");o.setAttribute("aria-labelledby","storage-used-h");const a=Dt("h4","storage-h",e.text("storage.page.used"));a.id="storage-used-h";const i=St(t.usedBytes),s=Dt("div","storage-fig");s.append(i.amount,Dt("small","",` ${i.unit}`));const r=Tt(t.usedBytes),c=e.text(n.key);let d;if(null===t.limitBytes)s.append(Dt("small","",` ${e.text("storage.page.no_limit")}`)),d=e.text("storage.page.meter_text_open",{used:r,state:c});else{const n=Tt(t.limitBytes);s.append(Dt("small","",` ${e.text("storage.page.of_limit",{limit:n})}`)),d=e.text("storage.page.meter_text",{used:r,limit:n,state:c})}const p=Dt("div","storage-hd");p.append(s,Bt(c,n.tone)),o.append(a,p),null!==t.limitBytes&&t.limitBytes>0&&o.append(Ot(e.text("storage.page.meter"),t.limitBytes,t.usedBytes,d));const u=Dt("dl","storage-kv"),g=(e,t)=>{const n=document.createElement("div");n.append(Dt("dt","",e),Dt("dd","",t)),u.append(n)};if(void 0!==t.plan){const n=t.plan.charAt(0).toUpperCase()+t.plan.slice(1);g(e.text("storage.page.plan"),null===t.limitBytes?n:`${n} — ${Tt(t.limitBytes)}`)}if(null===t.limitBytes?g(e.text("storage.page.left"),e.text("storage.page.no_limit")):g(e.text("storage.page.left"),0===t.leftBytes?e.text("storage.page.none"):Tt(t.leftBytes??0)),o.append(u,qt(e,t.manageHref)),"nearly"===t.level){const t=Dt("p","storage-near");t.append(l("warn"),e.text("storage.page.nearly_note")),o.append(t)}return o}(t,i)),i.spaces.length>0&&e.append(function(e,t){const n=Dt("section","storage-by-space");n.setAttribute("aria-labelledby","storage-space-h");const o=Dt("h4","storage-h",e.text("storage.page.by_space"));o.id="storage-space-h",o.append(" ",Dt("span","cnt",String(t.spaces.length)));const a=Dt("ul","storage-spaces");for(const n of t.spaces){const o=Dt("li","storage-space");o.dataset.source=n.source;const i=n.limitBytes??t.limitBytes,s=Tt(n.usedBytes),r=Dt("div","l");if(r.append(Dt("b","",n.space),Dt("span","",s)),o.append(r),null!==i&&i>0){const t=e.text("storage.page.space_meter_text",{used:s,limit:Tt(i)});o.append(Ot(e.text("storage.page.space_meter",{space:n.space}),i,n.usedBytes,t))}a.append(o)}return n.append(o,a),n}(t,i)),h.replaceChildren(..."full"===i.level?[It(t,i.manageHref)]:[],e)}const f=t.data.age("storage");y.hidden=void 0===i||void 0===f||n,y.textContent=void 0===f?"":function(e,t){const n=Math.floor(t/6e4);return n<1?e.text("storage.page.age_now"):n<60?e.text("storage.page.age_minutes",{count:n}):e.text("storage.page.age_hours",{count:Math.floor(n/60)})}(t,f)}E.append(v,w,k),x.append(b,E,C),C.addEventListener("click",e=>{const n=t.client()?.requestAuthority;if(!e.isTrusted||u||void 0===n)return;u=!0,r=void 0;const o=p;A(),(async()=>{let e;try{e=await n("space/info")}catch{e={approved:!1,code:"failed"}}c||o!==p||(u=!1,e.approved?await N():(r="unsupported"===e.code?"blocked":"declined",A()))})()});const S=t.data.subscribe(()=>A()),T=t.client()?.storageEpisode?.subscribe(()=>{const e=f;f=g(),A(),t.requestRender(),e&&!f&&N()}),L=t.client()?.onReset(_),z=t.onClientChange(_);return e.append(n,i,s,m.status,m.retry,x,h,y),A(),()=>{c=!0,S(),T?.(),L?.(),z(),e.replaceChildren()}}},jt=[R,mt,dt,Ve,xt,Rt,J],Pt=["localNode","localCopy","delegations","nodes","storage"];function Ft(e,t,n){void 0!==t?t.after(n):e?.append(n)}const Yt={ok:!1,code:"stale"},Wt=new WeakMap;function Ut(o,a,s,c){const l=document.createElement("style");l.textContent='\n.glance-row:focus-visible,.nav-i:focus-visible,.action:focus-visible,.switch:focus-visible,.icon-btn:focus-visible,.menu-i:focus-visible{outline:2px solid #111827;outline-offset:2px;box-shadow:0 0 0 6px #fafafa}\n.panel{position:fixed;top:0;bottom:0;right:0;box-sizing:border-box;width:min(420px,100%);display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr);grid-template-areas:"head" "nav" "main";overflow:hidden;border-left:1px solid #e4e4e7;background:#fff;color:#111827;box-shadow:-18px 0 48px -18px rgba(0,0,0,.35);pointer-events:auto;animation:tc-in .42s cubic-bezier(.22,1,.36,1)}\n.layer[data-position="bottom-left"] .panel{left:0;right:auto;border-left:0;border-right:1px solid #e4e4e7;box-shadow:18px 0 48px -18px rgba(0,0,0,.35);animation-name:tc-in-l}\n.layer .panel[data-layout="page"]{top:0;bottom:0;left:0;right:0;width:auto;border:0;box-shadow:none;grid-template-rows:auto minmax(0,1fr);grid-template-columns:288px minmax(0,1fr);grid-template-areas:"head head" "nav main"}\n.head{grid-area:head;display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:8px;box-sizing:border-box;min-height:68px;padding:14px 12px 10px 20px}\n.brand{display:flex;flex-direction:column;min-width:0;flex:1 0 92px}\n.title{margin:0;font-size:15px;font-weight:600}\n.ctx{overflow:hidden;font-size:12.5px;color:#71717a;text-overflow:ellipsis;white-space:nowrap}\n.head-actions{display:flex;flex-wrap:nowrap;align-items:center;min-width:0;flex-shrink:1;gap:6px}\n.head-actions .layout-switch{flex-shrink:0}\n.head-actions > .action{min-width:44px;overflow:hidden}\n.head-actions > .action span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.icon-btn{display:inline-flex;flex:none;align-items:center;justify-content:center;box-sizing:border-box;width:44px;height:44px;min-width:44px;min-height:44px;padding:0;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer}\n.icon-btn.ring{box-shadow:inset 0 0 0 1px #71717a}\n.icon-btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}\n.status{font-size:12px;color:#4b5563}\n.nav{grid-area:nav;display:flex;flex-wrap:wrap;gap:6px;padding:6px 20px 14px}\n.nav-i{display:inline-flex;align-items:center;min-height:44px;padding:0 13px;border:0;border-radius:999px;background:#f4f4f5;color:#09090b;font:inherit;font-size:13.5px;font-weight:500;white-space:nowrap;cursor:pointer}\n.nav-i[aria-current="page"]{background:#fff;font-weight:700;box-shadow:inset 0 0 0 2px #09090b}\n.nav-n,.nav-ic,.nav-m{display:none}\n.main{grid-area:main;min-width:0;min-height:0;overflow:auto;overflow-wrap:anywhere;box-sizing:border-box;padding:24px 20px 56px;border-top:2px solid #09090b}\n.sec-title{margin:0 0 28px;font-family:"Literata Variable","Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;font-size:1.5rem;font-weight:400;line-height:1.2;letter-spacing:-.005em}\n.section+.section{margin-top:12px;padding-top:12px;border-top:1px solid #e4e4e7}\n.action{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:44px;min-height:44px;padding:0 20px;border:1px solid;border-color:#71717a;border-radius:999px;background:#fff;color:#09090b;font:inherit;font-size:13.5px;font-weight:700;white-space:nowrap;cursor:pointer}\n.action:hover{background:#f4f4f5}\n.layout-switch{display:inline-flex;align-items:center;gap:8px;white-space:nowrap}\n.layout-switch[hidden]{display:none}\n.layout-switch svg{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}\n.row{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px}\n.label{font-weight:500}\n.switch{display:inline-flex;align-items:center;width:56px;min-width:44px;height:44px;padding:0;border:0;background:none;cursor:pointer}\n.switch:disabled{cursor:default;opacity:.6}\n/* The mockup switch: a 56x30 track with a 1px #71717a edge (the .knob background, so it clears 3:1 on the panel) around a muted fill (::before), and a 22px thumb that is black when off and white on a black track when on. */\n.knob{position:relative;display:block;width:56px;height:30px;border-radius:999px;background:#71717a}\n.knob::before{content:"";position:absolute;inset:1px;border-radius:999px;background:#f4f4f5}\n.knob::after{content:"";position:absolute;top:4px;left:4px;width:22px;height:22px;border-radius:50%;background:#09090b;transition:transform .3s cubic-bezier(.22,1,.36,1)}\n.switch[aria-checked="true"] .knob{background:#09090b}\n.switch[aria-checked="true"] .knob::before{background:#09090b}\n.switch[aria-checked="true"] .knob::after{transform:translateX(26px);background:#fff}\n.busy,.note,.error{margin:6px 0 0;font-size:12px;color:#4b5563}\n.note{text-wrap:pretty}\n.action+.note,.note:not([hidden])+.action,.row~.action{margin-top:8px}\n.error{color:#111827}\n.confirm{margin-top:8px}\n.confirm .actions{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}\n.layer .panel[data-layout="page"] .head{padding:12px 24px;border-bottom:1px solid #e4e4e7;background:#fff}\n.layer .panel[data-layout="page"] .nav{flex-direction:column;flex-wrap:nowrap;width:288px;box-sizing:border-box;padding:24px 16px;border-right:1px solid #e4e4e7;background:#fafafa}\n.layer .panel[data-layout="page"] .nav-i{width:100%;min-height:48px;padding:0 12px;border-radius:14px;background:transparent;font-size:14.5px}\n.layer .panel[data-layout="page"] .nav-i[aria-current="page"]{background:#fff}\n.layer .panel[data-layout="page"] .nav-i{gap:8px}\n.layer .panel[data-layout="page"] .nav-ic{display:inline-block;width:16px;height:16px}\n.layer .panel[data-layout="page"] .nav-m{display:inline;max-width:90px;margin-left:auto;overflow:hidden;color:#71717a;font-size:12.5px;font-weight:400;text-overflow:ellipsis;white-space:nowrap}\n.layer .panel[data-layout="page"] .nav-i[aria-current="page"] .nav-m{color:#09090b}\n.layer .panel[data-layout="page"] .nav-n{display:inline-block;width:18px;font:500 11px/1 ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;color:#71717a}\n.layer .panel[data-layout="page"] .main{padding:40px 40px 80px;border-top:0;max-width:960px;width:100%;margin:0 auto}\n.layer .panel[data-layout="page"] .sec-title{font-size:1.75rem;line-height:2.125rem;font-weight:600}\n@keyframes tc-in{from{transform:translateX(104%)}to{transform:none}}\n@keyframes tc-in-l{from{transform:translateX(-104%)}to{transform:none}}\n.menu-wrap{display:none;position:relative}\n.menu{position:absolute;top:calc(100% + 6px);right:0;z-index:2;box-sizing:border-box;width:min(280px,calc(100vw - 24px));padding:6px;border-radius:16px;background:#fff;box-shadow:inset 0 0 0 1px #e4e4e7,0 12px 32px -8px rgba(0,0,0,.3)}\n.menu[hidden]{display:none}\n.menu-i{display:flex;align-items:center;width:100%;min-height:44px;padding:0 12px;border:0;border-radius:12px;background:transparent;color:inherit;font:inherit;text-align:left;white-space:nowrap;cursor:pointer}\n.menu-i[aria-current="page"]{font-weight:700;background:#f4f4f5}\n.layer[data-phone] .menu-wrap{display:block}\n.layer[data-phone] .nav{display:none}\n.layer[data-phone] .panel[data-layout="page"]{grid-template-columns:minmax(0,1fr);grid-template-areas:"head" "main"}\n.layer[data-phone] .panel[data-layout="page"] .head{padding:12px 12px 12px 16px}\n.layer[data-phone] .panel[data-layout="page"] .main{padding:24px 16px 56px}\n.layer{--tc-color-overlay:rgb(9 9 11 / .4)}\n.scrim{position:fixed;inset:0;background:var(--tc-color-overlay);opacity:0;visibility:hidden;pointer-events:none;transition:opacity .35s cubic-bezier(.22,1,.36,1),visibility 0s .35s}\n.layer[data-panel-open][data-layout="drawer"] .scrim{opacity:1;visibility:visible;pointer-events:auto;transition:opacity .35s cubic-bezier(.22,1,.36,1)}\n@media (prefers-reduced-motion:reduce){\n.panel,.knob::after,.scrim,.layer[data-panel-open][data-layout="drawer"] .scrim{animation:none;transition:none}\n}\n@media (prefers-color-scheme: dark){\n.layer{--tc-color-overlay:rgb(0 0 0 / .6)}\n.glance-row:focus-visible,.nav-i:focus-visible,.action:focus-visible,.switch:focus-visible,.icon-btn:focus-visible,.menu-i:focus-visible{outline-color:#fafafa;box-shadow:0 0 0 6px #111827}\n.panel{border-left-color:#69696b;background:#151517;color:#fafafa}\n.main{border-top-color:#fafafa}\n.ctx,.status,.busy,.note{color:#a1a1aa}\n.nav-i{background:#27272a;color:#fafafa}\n.nav-i[aria-current="page"]{background:#151517;box-shadow:inset 0 0 0 2px #fafafa}\n.icon-btn.ring{box-shadow:inset 0 0 0 1px #71717a}\n.section+.section{border-top-color:#69696b}\n.action{border-color:#71717a;background:#151517;color:#fafafa}\n.action:hover{background:#27272a}\n.error{color:#fafafa}\n.knob::before{background:#27272a}\n.knob::after{background:#fafafa}\n.switch[aria-checked="true"] .knob{background:#fafafa}\n.switch[aria-checked="true"] .knob::before{background:#fafafa}\n.switch[aria-checked="true"] .knob::after{background:#09090b}\n.layer .panel[data-layout="page"] .head{background:#151517;border-bottom-color:#69696b}\n.layer .panel[data-layout="page"] .nav{background:#151517;border-right-color:#69696b}\n.layer .panel[data-layout="page"] .nav-i{background:transparent}\n.layer .panel[data-layout="page"] .nav-i[aria-current="page"]{background:#27272a}\n.layer .panel[data-layout="page"] .nav-n,.layer .panel[data-layout="page"] .nav-m{color:#a1a1aa}\n.layer .panel[data-layout="page"] .nav-i[aria-current="page"] .nav-m{color:#fafafa}\n.menu{background:#151517;box-shadow:inset 0 0 0 1px #69696b,0 12px 32px -8px rgba(0,0,0,.6)}\n.menu-i[aria-current="page"]{background:#27272a}\n}\n\n.tstack{position:fixed;bottom:calc(var(--b) + 56px);display:flex;flex-direction:column;gap:10px;width:min(400px,calc(100vw - 24px));pointer-events:none}\n.layer[data-position="bottom-right"] .tstack{right:var(--tinycloud-ui-offset-inline,12px)}\n.layer[data-position="bottom-left"] .tstack{left:var(--tinycloud-ui-offset-inline,12px)}\n.layer[data-position="bottom-center"] .tstack{left:50%;transform:translateX(-50%)}\n.layer[data-panel-open][data-layout="drawer"] .tstack{bottom:12px;width:min(396px,calc(100vw - 24px))}\n.layer[data-panel-open][data-layout="drawer"][data-position="bottom-right"] .tstack{right:12px}\n.layer[data-panel-open][data-layout="drawer"][data-position="bottom-left"] .tstack{left:12px}\n.layer[data-panel-open][data-layout="page"] .tstack{bottom:24px;right:24px;left:auto;transform:none;width:min(420px,calc(100vw - 32px))}\n.layer[data-phone][data-panel-open] .tstack{bottom:calc(var(--b));left:12px;right:12px;transform:none;width:auto}\n.tstack>div{display:contents}\n.tstack .toast{display:flex;align-items:flex-start;gap:12px;box-sizing:border-box;padding:14px 8px 14px 16px;border:0;border-radius:16px;background:#fff;color:#111827;box-shadow:0 12px 32px -8px rgba(0,0,0,.3),0 0 0 1px #a1a1aa;pointer-events:auto;animation:tc-toast-in .45s cubic-bezier(.22,1,.36,1)}\n.tstack .toast__icon{display:inline-flex;flex:none;margin-top:12px}\n.tstack .toast__icon .ui-ic{width:20px;height:20px}\n.tstack .toast__body{flex:1;min-width:0;padding-top:12px;overflow-wrap:anywhere}\n.tstack .toast__title{display:block;font-weight:700}\n.tstack .toast a,.tstack .toast__copy{display:inline-flex;align-items:center;min-height:44px;margin-top:2px;padding:0;border:0;background:transparent;color:inherit;font:inherit;font-weight:700;text-decoration:underline;text-underline-offset:3px;white-space:nowrap;cursor:pointer}\n.tstack .toast__close{display:inline-flex;align-items:center;justify-content:center;flex:none;box-sizing:border-box;width:44px;height:44px;padding:0;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer}\n.tstack .toast__close .ui-ic{width:20px;height:20px}\n.tstack .slip{margin-top:8px;padding:8px 0;border-top:2px dashed #71717a;border-bottom:2px dashed #71717a;font:12px/1.7 ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;overflow-wrap:anywhere}\n.tstack .slip>div{display:block}\n.toast a:focus-visible,.toast__close:focus-visible,.toast__copy:focus-visible{outline:2px solid #111827;outline-offset:2px;box-shadow:0 0 0 6px #fafafa}\n@keyframes tc-toast-in{from{opacity:0;transform:translateY(14px)}}\n@media (prefers-reduced-motion:reduce){\n.tstack .toast{animation:none}\n}\n@media (prefers-color-scheme: dark){\n.tstack .toast{background:#151517;color:#fafafa;box-shadow:0 12px 32px -8px rgba(0,0,0,.6),0 0 0 1px #69696b}\n.toast a:focus-visible,.toast__close:focus-visible,.toast__copy:focus-visible{outline-color:#fafafa;box-shadow:0 0 0 6px #111827}\n}\n',o.append(l);let d,p,u={open:!1,layout:"drawer",phone:!1,showLayoutToggle:!1},g=[],f=!1;const m=k({...a,onNavigate(e){d=e,j()}}),h=o.querySelector(".layer"),y=h?function(e,t,n){const o=document.createElement("div");o.className="tstack";const a=document.createElement("div"),i=document.createElement("div");o.append(a,i),e.querySelector(":scope > .toasts")?.remove(),e.append(o);const s=new Map,r=new Set;function c(e){const{el:n,body:o,message:a}=$(e.kind);if(a.textContent=x(e.textCode),void 0!==e.href&&void 0!==e.hrefLabelCode){const t=document.createElement("a");t.href=e.href,t.target="_blank",t.rel="noopener noreferrer",t.textContent=x(e.hrefLabelCode),o.append(t)}return n.append(M(()=>t.dismiss(e.id))),n.addEventListener("mouseenter",()=>{r.has(e.id)||(r.add(e.id),t.pause())}),n.addEventListener("mouseleave",()=>{r.delete(e.id)&&t.resume()}),n}const l=t.subscribe(function(e){const n=new Set(e.map(e=>e.id));for(const[e,o]of s)n.has(e)||(r.delete(e)&&t.resume(),o.remove(),s.delete(e));for(const t of e){if(s.has(t.id))continue;const e=c(t);s.set(t.id,e),i.append(e)}}),d=[];let p=0;function u(e){void 0!==e.timer||p>0||(e.startedAt=Date.now(),e.timer=setTimeout(()=>f(e),e.remaining))}function g(e){void 0!==e.timer&&(clearTimeout(e.timer),e.timer=void 0,e.remaining=Math.max(0,e.remaining-(Date.now()-e.startedAt)))}function f(e){const t=d.indexOf(e);-1!==t&&(g(e),d.splice(t,1),e.el.remove())}return{receipt(e){const t=e.rows.map(e=>`${e.labelCode}=${e.value}|${e.copyValue??""}`).join("\n");if(d.some(e=>e.key===t))return!1;const{el:o,body:i,message:s}=$("success"),r=document.createElement("b");r.className="toast__title",r.textContent=x(e.titleCode),s.append(r),void 0!==e.bodyCode&&s.append(x(e.bodyCode));const c=document.createElement("div");c.className="slip";for(const t of e.rows){const e=document.createElement("div");e.textContent=`${x(t.labelCode)} ${t.value}`,c.append(e)}const l=document.createElement("button");l.type="button",l.className="toast__copy",l.textContent=x("toast.copy_receipt"),l.addEventListener("click",()=>{!async function(e){const t=e.map(e=>`${x(e.labelCode)} ${e.copyValue??e.value}`).join("\n");try{await navigator.clipboard.writeText(t),n({kind:"success",textCode:"toast.copied"})}catch{n({kind:"error",textCode:"toast.copy_failed"})}}(e.rows)}),i.append(c,l);const m={key:t,el:o,timer:void 0,remaining:7e3,startedAt:0};o.append(M(()=>f(m)));let h=!1;for(o.addEventListener("mouseenter",()=>{h||(h=!0,(()=>{p++;for(const e of d)g(e)})())}),o.addEventListener("mouseleave",()=>{h&&(h=!1,(()=>{p=Math.max(0,p-1);for(const e of d)u(e)})())}),d.push(m),a.append(o);d.length>3;)f(d[0]);return u(m),!0},clearReceipts(){for(const e of[...d])f(e)},dispose(){l();for(let e=0;e<r.size;e++)t.resume();r.clear();for(const e of[...d])f(e);s.clear(),o.remove()}}}(h,c,e=>s.toast(e)):void 0,b=h?function(e,t,n,o){const a=document.createElement("div");a.className="scrim",a.setAttribute("aria-hidden","true"),a.addEventListener("click",o);const i=t.querySelector(":scope > .pending");i?i.before(a):t.append(a);let s,r,c,l=!1,d=!1,p=!1;const u=()=>t.querySelector(":scope > .tstack");function g(){return[...Array.from(n.querySelectorAll(T)),...Array.from(u()?.querySelectorAll(T)??[])].filter(L)}const f=e=>null!==e&&(n.contains(e)||(u()?.contains(e)??!1));function m(t){if(!d||S())return;const a=e.activeElement;if(!f(a))return;if("Escape"===t.key)return void(n.contains(a)||o());if("Tab"!==t.key||null===a)return;const i=g(),s=i[0],r=i[i.length-1];if(!s||!r)return void t.preventDefault();const c=a===r||Boolean(r.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING),l=a===s||Boolean(s.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING);!t.shiftKey&&c?(t.preventDefault(),i[C(i.length,i.length-1,!1)]?.focus()):t.shiftKey&&l&&(t.preventDefault(),i[C(i.length,0,!0)]?.focus())}function h(){if(!p){p=!0;try{const e=c?.isConnected&&f(c)&&L(c)?c:g()[0];e?.focus()}finally{p=!1}}}function y(t){S()||t.target===e.host||h()}function x(e){if(p||S())return;const t=e.target;f(t)?c=t:t.matches(".button")&&h()}function b(){if(!d||S()||!c||c.isConnected||!function(){const t=document.activeElement;return null===t||t===document.body||t===e.host&&null===e.activeElement}())return;const t=n.querySelector('[role="alertdialog"],.drawer'),o=t&&L(t)?Array.from(t.querySelectorAll(T)).find(L):void 0,a=Array.from(u()?.querySelectorAll(T)??[]).find(L),i=n.querySelector(".main"),s=i?.querySelector(".sec-title")??i?.firstElementChild,r=o??a??(s instanceof HTMLElement?s:g()[0]);r&&r===s&&(r.tabIndex=-1),r?.focus()}const v=new(e.ownerDocument.defaultView?.MutationObserver??MutationObserver)(()=>b());function w(e){null===e.relatedTarget&&queueMicrotask(b)}function k(e){!d||S()||"Escape"!==e.key||e.composedPath().includes(t)||e.target!==document.body&&e.target!==document.documentElement||queueMicrotask(()=>{if(!d||S()||e.defaultPrevented)return;const t=n.querySelector('[role="alertdialog"],.drawer');t&&L(t)?Array.from(t.querySelectorAll(T)).find(L)?.focus():o()})}function E(){queueMicrotask(()=>{!d||S()||f(e.activeElement)||h()})}function N(e){e?(c=void 0,document.addEventListener("focusin",y,!0),t.addEventListener("focusin",x),t.addEventListener("focusout",w),document.addEventListener("keydown",k,!0),v.observe(t,{childList:!0,subtree:!0})):(document.removeEventListener("focusin",y,!0),t.removeEventListener("focusin",x),t.removeEventListener("focusout",w),document.removeEventListener("keydown",k,!0),v.disconnect())}return t.addEventListener(A,E),t.addEventListener("keydown",m),{sync(t,n){if(t&&!l){const t=document.activeElement;s=t instanceof HTMLElement&&t!==e.host&&t!==document.body?t:void 0,r=void 0}else!t&&l&&(r=d?s:void 0,s=void 0);l=t,n!==d&&(d=n,N(d))},restoreFocus(){const e=r;return r=void 0,!!e?.isConnected&&(e.focus(),!0)},dispose(){N(!1),t.removeEventListener("keydown",m),t.removeEventListener(A,E),a.remove()}}}(o,h,m.el,a.onClose):void 0,v=()=>{const o=s.client();return o&&function(o){let a=Wt.get(o);if(void 0===a){let i;a=Object.create(o,{data:{get:()=>o.data??(o.signedIn()?i??(i=function(o){const a=new Set,i=e=>{for(const t of[...a])t(e)};let s,r;const c=()=>{const t=e(o);if(t!==s){r?.(),s=t,r=t?.subscribe(i);for(const e of n)i(e)}};return t(o,c),c(),{subscribe:e=>(a.add(e),()=>{a.delete(e)}),account:()=>s?.account()??{state:"loading"},knownDid:()=>s?.knownDid?.(),localNode:()=>s?.localNode()??{state:"loading"},localCopy:()=>s?.localCopy()??{state:"loading"},nodes:()=>s?.nodes()??{state:"loading"},storage:e=>s?.storage(e)??{state:"loading"},delegations:e=>s?.delegations(e)??{state:"loading"},revoke:e=>s?.revoke(e)??Yt,setLocalNodeEnabled:e=>s?.setLocalNodeEnabled(e)??Yt}}(o)):void 0),enumerable:!0}}),Wt.set(o,a)}return a}(o)},w=function(e,t=Date.now){const n=new Map,o=new Set;let a,i,s=0,r=0,c=!1;function l(){for(const e of[...o])e()}async function d(o){const a=e();if(void 0===a)return;const i=r;let s;try{s=await a[o]()}catch{s={state:"error",code:"unknown"}}i===r&&(n.set(o,{result:s,at:t()}),l())}function p(e){return void 0===e?Promise.all(Pt.map(d)).then(()=>{}):d(e)}function u(){a?.(),a=e()?.subscribe(()=>{p()})}return{get source(){return e()},latest:e=>n.get(e)?.result,age(e){const o=n.get(e);return void 0===o?void 0:t()-o.at},refresh:p,generation:()=>s,subscribe:e=>(o.add(e),()=>{o.delete(e)}),start(){c||(c=!0,u(),p(),i=setInterval(()=>{p()},6e4))},stop(){c=!1,r++,a?.(),a=void 0,void 0!==i&&clearInterval(i),i=void 0},reset(){s++,r++,n.clear(),l(),c&&(u(),p())},notify:l}}(()=>v()?.data),E=function(e){const t=new Set;function n(e){return!!t.delete(e)&&(e.remove(),!0)}return{confirm(o){const a=r({question:o.question,cancelLabel:o.cancelLabel,confirmLabel:o.confirmLabel,onCancel:()=>{n(a.el)&&o.onCancel?.()},onConfirm:o.onConfirm});return t.add(a.el),Ft(e(),o.anchor,a.el),a.cancel.focus(),{cancel:a.cancel,confirm:a.confirm,close:()=>{n(a.el)}}},openDrawer(o){const a=function(e){const t=document.createElement("section");t.className="drawer",t.setAttribute("role","region");const n=document.createElement("h3");n.textContent=e.title;const o=i(e.closeLabel);return o.addEventListener("click",e.onClose),t.append(n,...e.body,o),t}({title:o.title,body:o.body,closeLabel:o.closeLabel,onClose:()=>{n(a)&&o.onClose?.()}});t.add(a),Ft(e(),o.anchor,a);const s=a.querySelector("h3");return s?.setAttribute("tabindex","-1"),s?.focus(),{el:a,close:()=>{n(a)}}},closeAll(){for(const e of[...t])n(e)}}}(()=>p),N=et(e=>s.toast(e)),_={...s,client:()=>N(v()),text:x,data:w,layout:()=>u.layout,sections:()=>jt.filter(e=>e.isAvailable(_)),requestRender:()=>w.notify(),confirm:e=>E.confirm(e),openDrawer:e=>E.openDrawer(e),receipt:e=>s.toastsEnabled()&&void 0!==y&&y.receipt(e),closePanel:a.onClose,openSection(e){d=e,j()}};function z(){E.closeAll(),p=void 0;for(const e of g)e();g=[]}function D(e){return e.map(e=>{const t=e.status(_);return{id:e.id,labelCode:e.labelCode,icon:e.icon,meta:void 0===t?void 0:t.count??t.text}})}const O=w.subscribe(function(){m.setNav(D(jt.filter(e=>e.isAvailable(_))),d)});function q(){w.reset(),E.closeAll(),y?.clearReceipts()}let B;function I(){B?.(),B=s.client()?.onReset(q)}const R=s.onClientChange(()=>{I(),q()});function j(){z();const e=jt.filter(e=>e.isAvailable(_)),t=e.find(e=>e.id===d)??e[0];if(d=t?.id,m.setLayout(u.layout,{showLayoutToggle:u.showLayoutToggle,phone:u.phone}),m.setAppLabel(_.appLabel()),m.setNav(D(e),d),!u.open||!t)return;const n=document.createElement("section");n.className="section",n.dataset.section=t.id,p=n,m.main.replaceChildren(n);const o=t.mount(n,_);g.push(()=>{o(),n.remove()})}return I(),Object.assign(m,{render(e){u=e,void 0!==e.section&&(d=e.section),b?.sync(e.open,e.open&&"drawer"===e.layout),e.open&&!f?w.start():!e.open&&f&&w.stop(),f=e.open,j()},restoreFocus:()=>b?.restoreFocus()??!1,dispose(){z(),w.stop(),O(),B?.(),R(),y?.dispose(),b?.dispose()}})}export{Ut as mountPanel};
|
package/dist/ui/api.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SectionId } from "./slots";
|
|
2
|
+
/** Public `tc.ui` surface. */
|
|
3
|
+
export interface TinyCloudUI {
|
|
4
|
+
/**
|
|
5
|
+
* Clears the hidden flag, shows the button (if `ui.button !== false`), and opens
|
|
6
|
+
* the sidebar. `section` picks the starting section; unknown or unavailable ids
|
|
7
|
+
* fall back to the first available section. `ui.mode: "page"` opens the full page.
|
|
8
|
+
*/
|
|
9
|
+
open(section?: SectionId): void;
|
|
10
|
+
/** Like `open()` but opens the full page. Under `ui.mode: "sidebar"` it opens the sidebar. */
|
|
11
|
+
openPage(section?: SectionId): void;
|
|
12
|
+
/** Closes the panel only. Never changes the hidden flag. */
|
|
13
|
+
close(): void;
|
|
14
|
+
toggle(): void;
|
|
15
|
+
readonly isOpen: boolean;
|
|
16
|
+
/** False in iframes, opaque origins, SSR, no document, or when `ui: false`. */
|
|
17
|
+
readonly available: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface UiTarget {
|
|
20
|
+
open(section?: SectionId): void;
|
|
21
|
+
openPage(section?: SectionId): void;
|
|
22
|
+
close(): void;
|
|
23
|
+
isOpen(): boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `getTarget` returns undefined when this client is not registered (ui:false,
|
|
27
|
+
* version mismatch, or unregistered). Every method is then a silent no-op.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createUiApi(getTarget: () => UiTarget | undefined): TinyCloudUI;
|
|
30
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StatusCode } from "./slots";
|
|
2
|
+
export interface ButtonView {
|
|
3
|
+
readonly el: HTMLButtonElement;
|
|
4
|
+
setExpanded(expanded: boolean): void;
|
|
5
|
+
setHidden(hidden: boolean): void;
|
|
6
|
+
setStatus(status: StatusCode | null): void;
|
|
7
|
+
focus(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function createButton(onActivate: () => void, onPreload: () => void): ButtonView;
|
|
10
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IStorageService } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { PanelDataFactory } from "./data";
|
|
3
|
+
import type { PanelClient, PurgeLocalCopyResult, RequestLogReader, SyncFacade } from "./slots";
|
|
4
|
+
/**
|
|
5
|
+
* What the UI reads from a TinyCloudWeb instance. The panel never sees
|
|
6
|
+
* TinyCloudWeb itself.
|
|
7
|
+
*/
|
|
8
|
+
export interface ClientSource {
|
|
9
|
+
signedIn(): boolean;
|
|
10
|
+
/** Resolves when the account registry sync has settled. Absent means already settled. */
|
|
11
|
+
waitForAccountRegistrySync?(): Promise<void>;
|
|
12
|
+
readonly sync?: SyncFacade | undefined;
|
|
13
|
+
readonly storage: Pick<IStorageService, "status">;
|
|
14
|
+
readonly storageEpisode?: PanelClient["storageEpisode"];
|
|
15
|
+
readonly requests?: RequestLogReader | undefined;
|
|
16
|
+
/** Signs out of the TinyCloud session. Undefined when the host cannot sign out. */
|
|
17
|
+
signOut?: (() => Promise<void>) | undefined;
|
|
18
|
+
/** Removes the local copy from this browser; the panel calls it after sign-out settles. Undefined: nothing to purge. */
|
|
19
|
+
purgeLocalCopy?: (() => Promise<PurgeLocalCopyResult>) | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface PanelClientHandle {
|
|
22
|
+
readonly client: PanelClient;
|
|
23
|
+
/** Clears this client's per-account view state and fires onReset listeners. */
|
|
24
|
+
reset(): void;
|
|
25
|
+
}
|
|
26
|
+
export declare function createPanelClient(id: number, source: ClientSource, dataFactory?: PanelDataFactory): PanelClientHandle;
|
|
27
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Accepted `ui.position` values. Each `top-*` value places at the matching bottom position. */
|
|
2
|
+
export type UiPosition = "top-right" | "top-left" | "top-center" | "bottom-right" | "bottom-left" | "bottom-center";
|
|
3
|
+
type BottomPosition = "bottom-right" | "bottom-left" | "bottom-center";
|
|
4
|
+
/**
|
|
5
|
+
* Which layouts the settings panel offers. `"both"` (default) opens the sidebar
|
|
6
|
+
* with an "Open full page" switch. `"sidebar"` offers the sidebar only. `"page"`
|
|
7
|
+
* opens the full page directly.
|
|
8
|
+
*/
|
|
9
|
+
export type UiMode = "sidebar" | "page" | "both";
|
|
10
|
+
/** Config passed as `ui` on TinyCloudWeb. `ui: false` disables the UI entirely (see index.ts). */
|
|
11
|
+
export interface UiConfig {
|
|
12
|
+
/** Default true. false hides the button only; the panel, prompts, and open() still work. */
|
|
13
|
+
button?: boolean;
|
|
14
|
+
/** Default true. false shows no toasts and stops the unhandled-rejection listener. Prompts still render. */
|
|
15
|
+
toasts?: boolean;
|
|
16
|
+
/** Default false. Shows the developer section when true. */
|
|
17
|
+
developerMode?: boolean;
|
|
18
|
+
/** Default "bottom-right". */
|
|
19
|
+
position?: UiPosition;
|
|
20
|
+
/** Explicit identity for the hide flag when no manifest is set. */
|
|
21
|
+
appId?: string;
|
|
22
|
+
/** Default "both". Which layouts the panel offers. */
|
|
23
|
+
mode?: UiMode;
|
|
24
|
+
}
|
|
25
|
+
export interface ResolvedUiConfig {
|
|
26
|
+
readonly button: boolean;
|
|
27
|
+
readonly toasts: boolean;
|
|
28
|
+
readonly developerMode: boolean;
|
|
29
|
+
readonly position: BottomPosition;
|
|
30
|
+
readonly appId: string | undefined;
|
|
31
|
+
readonly mode: UiMode;
|
|
32
|
+
}
|
|
33
|
+
export declare function resolveUiConfig(ui: UiConfig | undefined): ResolvedUiConfig;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AccountDelegationRecord } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { DelegationGroup, DelegationRow } from "../data";
|
|
3
|
+
export declare const EXPIRING_SOON_MS: number;
|
|
4
|
+
/**
|
|
5
|
+
* The DID without its fragment. `tc.sessionDid` is a DID URL naming the session key
|
|
6
|
+
* (`did:key:z6Mk…#z6Mk…`); the node lists the same DID bare. Only a single trailing
|
|
7
|
+
* `#fragment` is dropped; a string with more than one `#` is left as it is.
|
|
8
|
+
*/
|
|
9
|
+
export declare function bareDid(did: string): string;
|
|
10
|
+
/** Same DID, ignoring a fragment on either side. A different key is never the same DID. */
|
|
11
|
+
export declare function sameDid(a: string, b: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* `this-app`: granted, delegate is the current session DID.
|
|
14
|
+
* `to-others`: granted, delegate is another DID.
|
|
15
|
+
* `received`: direction is received (checked first, so a received record whose
|
|
16
|
+
* delegate is this session still shows under received).
|
|
17
|
+
*/
|
|
18
|
+
export declare function delegationGroup(record: Pick<AccountDelegationRecord, "direction" | "delegateDid">, sessionDid: string): DelegationGroup;
|
|
19
|
+
/** True only for a future `expiresAt` within 24 h of `now`. Expired records are not "expiring". */
|
|
20
|
+
export declare function isExpiringSoon(expiresAt: Date | null, now: number): boolean;
|
|
21
|
+
export declare function shortDid(did: string): string;
|
|
22
|
+
export declare function toDelegationRow(record: AccountDelegationRecord, sessionDid: string, now: number): DelegationRow;
|
|
23
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PanelDataSource } from "../data";
|
|
2
|
+
export interface PanelPrefetch {
|
|
3
|
+
/** Panel open or launcher hover/focus: start now, skipping the idle gate. No-op after the first start. */
|
|
4
|
+
intent(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface PrefetchDeps {
|
|
7
|
+
readonly data: PanelDataSource;
|
|
8
|
+
/** Resolves when the account registry sync has settled. */
|
|
9
|
+
readonly registrySettled: () => Promise<void>;
|
|
10
|
+
/** Resolves on browser idle or after the cap. */
|
|
11
|
+
readonly idle: () => Promise<void>;
|
|
12
|
+
readonly onReset: (cb: () => void) => () => void;
|
|
13
|
+
}
|
|
14
|
+
/** Starts one pull per prefetch. A failed read does not stop the others and is not retried. */
|
|
15
|
+
export declare function createPanelPrefetch(deps: PrefetchDeps): PanelPrefetch;
|
|
16
|
+
/** Browser idle, capped at 3 s; setTimeout 2 s where requestIdleCallback is missing. Never rejects. */
|
|
17
|
+
export declare function browserIdle(): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=prefetch.d.ts.map
|