@vite-hub/comments 0.5.1 → 0.6.0
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 +3 -1
- package/dist/client.d.ts +29 -3
- package/dist/client.js +50 -22
- package/dist/{console-CK2F53QP.d.ts → console-CCLX_eIk.d.ts} +1 -1
- package/dist/{define-9uMM3Ewc.js → define-BCxNaSZv.js} +1 -1
- package/dist/hosted/hosted-comments/overlay-CFuq5QAH.js +182 -0
- package/dist/hosted/hosted-comments/{tools-CdwnUCOr.js → tools-Bz--joZw.js} +3 -3
- package/dist/hosted/hosted-comments.js +2 -2
- package/dist/{index-BEnHTj2Z.d.ts → index-D1T7RJ4R.d.ts} +5 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{install-B-FQpi47.d.ts → install-NehuMNhG.d.ts} +1 -1
- package/dist/{install-BUXxryut.js → install-w6CCgGFV.js} +39 -15
- package/dist/{operations-CKC_lMG_.js → operations-B8IMhRmY.js} +1 -1
- package/dist/operations.js +2 -2
- package/dist/overlay/overlay.js +27 -15
- package/dist/page/loader.js +1 -1
- package/dist/{plugin-B2hETRii.js → plugin-DbCYT7Ac.js} +8 -3
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js +1 -1
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +1 -1
- package/dist/runtime/index.d.ts +40 -10
- package/dist/runtime/index.js +11 -5
- package/dist/server.d.ts +1 -1
- package/dist/server.js +4 -4
- package/dist/{service-DDD4Ubxd.js → service-DUh2uGd2.js} +1 -1
- package/dist/{session-CTh9nisq.d.ts → session-CN4irEqf.d.ts} +1 -1
- package/dist/{session-BGN6Vlm6.js → session-_1GY5gaG.js} +23 -8
- package/dist/vite.d.ts +18 -2
- package/dist/vite.js +16 -3
- package/package.json +7 -7
- package/dist/hosted/hosted-comments/overlay-4-mWX4Uz.js +0 -170
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./overlay-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./overlay-CFuq5QAH.js","../hosted-comments.js","./protocol-BHvtQKte.js","./rest-transport-D-9_pNqZ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"../hosted-comments.js";import{c,l,s as u}from"./protocol-BHvtQKte.js";import{i as d,n as f,o as p,t as m}from"./rest-transport-D-9_pNqZ.js";var h=Object.defineProperty,g=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t||h(n,Symbol.toStringTag,{value:`Module`}),n},_=new Set,v,y=!1;function b(){return v?.matches??!1}function x(){let e=b();if(e!==y){y=e;for(let t of _)t(e)}}function S(){v||typeof matchMedia!=`function`||(v=matchMedia(`(prefers-reduced-motion: reduce)`),v.addEventListener?.(`change`,x),y=b())}function C(){return S(),b()}function w(e){return S(),_.add(e),()=>_.delete(e)}var T={snappy:{stiffness:520,damping:34},soft:{stiffness:380,damping:20}},E=new Map,D=new Set,ee=0,te=!1,O=0,k=0,ne=1;function re(){return ne}function ie(e){let t=Math.min(.032,k?(e-k)/1e3:.016)/ne;k=e;let n=Array.from(E),r=Array.from(D);for(let[e,r]of n)if(E.get(e)===r){if(e.tween){let n=e.tween;n.elapsed+=t;let r=Math.min(1,n.elapsed/n.duration),i=1-(1-r)**3,a=n.from+(e.target-n.from)*i;e.velocity=(a-e.value)/(t||1),e.value=a,r>=1&&ae(e)}else{let{stiffness:n,damping:r}=e.preset,i=t/6;for(let t=0;t<6;t++){let t=-n*(e.value-e.target)-r*e.velocity;e.velocity+=t*i,e.value+=e.velocity*i}Math.abs(e.velocity)<.002&&Math.abs(e.value-e.target)<5e-4&&ae(e)}e.frame(e.value,e.velocity)}for(let e of r)D.has(e)&&e(t)===!1&&D.delete(e);E.size||D.size?O=requestAnimationFrame(ie):(O=0,k=0)}function ae(e){e.value=e.target,e.velocity=0,e.tween=void 0,E.delete(e)}function oe(e){E.set(e,++ee),O||=requestAnimationFrame(ie)}function se(e){let t=t=>e(t);return D.add(t),O||=requestAnimationFrame(ie),()=>{D.delete(t)}}function ce(e){if(!e)return;let t=Array.from(E);for(let[e,n]of t)E.get(e)!==n||e.tween||(ae(e),e.frame(e.value,0))}function A(e,t,n=T.snappy){let r={value:e,velocity:0,target:e,preset:n,tween:void 0,frame:t},i={get value(){return r.value},get velocity(){return r.velocity},get target(){return r.target},get active(){return E.has(r)},to(e,t={}){if(t.preset&&(r.preset=t.preset),t.tween===void 0&&C())return i.set(e);t.tween===void 0&&!te&&(te=!0,w(ce)),r.target=e,t.velocity!==void 0&&(r.velocity+=t.velocity),r.tween=t.tween===void 0?void 0:{from:r.value,elapsed:0,duration:t.tween},oe(r)},set(e){r.value=r.target=e,r.velocity=0,r.tween=void 0,E.delete(r),t(e,0)},stop(){r.velocity=0,r.tween=void 0,E.delete(r)}};return i}var le=`data-resize-handle-active`;function j(e){let t=e;for(;t;){if(t.closest(`[data-motion="none"]`))return!0;let e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}return!1}var ue=[`aria-checked`,`aria-selected`,`aria-pressed`,`aria-expanded`,`aria-valuenow`,`aria-valuetext`,`data-state`,`data-checked`,`data-open`,`open`,`data-leaving`],M=new Map,de=new Set,fe=Symbol.for(`vite-hub.motion.layer`),pe;function me(){let e=Reflect.get(globalThis,fe);if(e&&e!==pe&&typeof e==`object`&&`define`in e&&`install`in e)return e}function he(e){pe=e,Reflect.get(globalThis,fe)||Reflect.set(globalThis,fe,e)}function ge(e){let t=[...M.values()];M.clear();for(let n of t)n.removeFromShared=e.define(n.effect,n.isReduced)}function _e(e,t=C){let n={effect:e,isReduced:t};M.set(e.name,n);for(let e of de)e();return()=>{if(n.removeFromShared)return n.removeFromShared();if(M.get(e.name)===n){M.delete(e.name);for(let e of de)e()}}}function N(){return[...M.values()].map(e=>e.effect)}function ve(){return[...M.values()]}function ye(e){return de.add(e),()=>de.delete(e)}function P(e,t){for(let[n,r]of Object.entries(t))r?e.style.setProperty(n,r):e.style.removeProperty(n)}var F=new Map,I,L=new Map,R,be=[],xe=Symbol.for(`vite-hub.motion.effect-presses`),Se=e=>{let t=Reflect.get(e,xe);if(t)return t;let n=new Map;return Reflect.set(e,xe,n),n},Ce=new Set;function we(e,t){if(Ce.has(t))return!1;try{return e.matches(t)}catch{return Ce.add(t),!1}}function Te(e){let t=e;for(;;){for(let e of F.keys())if(e instanceof Element&&e.contains(t))return!0;let e=t.getRootNode();if((e instanceof Document||e instanceof ShadowRoot)&&F.has(e))return!0;if(!(e instanceof ShadowRoot))return!1;t=e.host}}function Ee(e,t){let n=-1;e.forEach((e,t)=>{e instanceof Element&&e.matches(`[data-motion="none"]`)&&(n=t)});let r=e.findIndex(e=>e instanceof HTMLElement&&we(e,t));return r===-1||r<=n||!Te(e[r])?void 0:e[r]}function De(e,t,n){z(e,!0);let r=Se(t),i=[];for(let{effect:a,isReduced:o}of ve()){if(!a.press||o())continue;let s=Ee(n,a.selector);if(!s||e===`key`&&s!==n[0])continue;let c=r.get(s);if(c?.has(a.name))continue;let l=a.press(s,t);if(!l)continue;c?c.add(a.name):r.set(s,new Set([a.name]));let u={element:s,press:l};e!==`key`&&!l.move&&(u.leave=()=>Oe(e,u,!0),s.addEventListener(`pointerleave`,u.leave,{once:!0})),i.push(u)}i.length&&(L.set(e,i),i.some(e=>e.press.move)&&document.addEventListener(`pointermove`,Me,{capture:!0,passive:!0}))}function z(e,t=!1){let n=L.get(e);if(n){L.delete(e);for(let{element:e,press:r,leave:i}of n)i&&e.removeEventListener(`pointerleave`,i),t&&r.cancel?r.cancel():r.release();ke()}}function Oe(e,t,n=!1){let r=L.get(e),i=r?.indexOf(t)??-1;r&&i!==-1&&(t.leave&&t.element.removeEventListener(`pointerleave`,t.leave),r.splice(i,1),r.length||L.delete(e),n&&t.press.cancel?t.press.cancel():t.press.release(),ke())}function ke(){[...L.values()].some(e=>e.some(e=>e.press.move))||document.removeEventListener(`pointermove`,Me,{capture:!0})}function Ae(e){if(e.button!==0)return;let t=e.composedPath();e.isPrimary&&(R={event:e,path:t}),De(e.pointerId,e,t)}function je(e){R?.event.pointerId===e.pointerId&&(R=void 0),z(e.pointerId,e.type===`pointercancel`)}function Me(e){for(let{press:t}of L.get(e.pointerId)??[])t.move?.(e)}function Ne(e){if(e.repeat||e.key!==` `&&e.key!==`Enter`)return;let t=e.composedPath();e.key===` `&&t[0]instanceof Element&&t[0].matches(`a[href], [role=link]`)||De(`key`,e,t)}function Pe(e){(e.key===` `||e.key===`Enter`)&&z(`key`)}function Fe(e,t){let n=t.filter(e=>e.content);if(!n.length)return;let r=new Map;for(let t of e){if(t.type===`attributes`)continue;let e=t.type===`characterData`?t.target.parentElement:t.target;if(!(e instanceof HTMLElement||e instanceof SVGElement))continue;let n=r.get(e);n||(n={added:[],removed:[],oldText:void 0,texts:new Map},r.set(e,n)),t.type===`characterData`?n.texts.has(t.target)||n.texts.set(t.target,t.oldValue):(n.added.push(...t.addedNodes),n.removed.push(...t.removedNodes))}for(let[e,t]of r){if(!e.isConnected)continue;let r=t.added.filter(e=>!t.removed.includes(e)),i=t.removed.filter(e=>!t.added.includes(e)),a=t.texts,o,s=[...e.childNodes];i.length&&s.every(e=>r.includes(e))?o=i.map(e=>e.textContent??``).join(``):a.size===1&&s.length===1&&a.has(s[0])&&(o=a.get(s[0])??``);for(let t of n)we(e,t.selector)&&!j(e)&&t.content(e,{added:r,removed:i,oldText:o})}}function Ie(e){if(!R||!e.matches(`[role=separator][data-panel-resize-handle-id]`))return;let t=ve().find(({effect:e})=>e.name===`divider`);if(!t||t.isReduced())return;let{event:n,path:r}=R,i=L.get(n.pointerId)??[],a=i.find(t=>t.splitter&&t.element===e);if(e.getAttribute(`data-resize-handle-active`)!==`pointer`){a&&Oe(n.pointerId,a);return}if(a||!r.includes(e.getRootNode())||!Te(e)||j(e))return;let o=t.effect.press?.(e,n);o&&(i.push({element:e,press:o,splitter:!0}),L.set(n.pointerId,i),document.addEventListener(`pointermove`,Me,{capture:!0,passive:!0}))}function Le(e){let t=[...new Set(e)],n=N(),r=new Map;Fe(t,n);for(let e of t)if(e.type!==`characterData`){if(e.type===`attributes`){let t=e.target;if(!(t instanceof HTMLElement))continue;if(e.attributeName===`data-resize-handle-active`){Ie(t);continue}let i=e.attributeName,a=t.getAttribute(i);if(a===e.oldValue)continue;let o=r.get(t);o||r.set(t,o=new Map);let s=o.get(i);if(s||o.set(i,s=new Set),s.has(e.oldValue))continue;s.add(e.oldValue);for(let r of n)r.state&&we(t,r.selector)&&!j(t)&&r.state(t,{attribute:i,oldValue:e.oldValue,value:a})}else for(let t of e.addedNodes)if(t instanceof HTMLElement&&t.isConnected)for(let e of n){if(!e.enter)continue;let n=we(t,e.selector);if(Ce.has(e.selector))continue;let r=[...n?[t]:[],...t.querySelectorAll(e.selector)];for(let t of r)j(t)||e.enter(t)}}}function Re(e,t){let n=N().some(e=>e.content);t.observe(e,{attributes:!0,attributeFilter:[...ue,...N().some(e=>e.name===`divider`)?[le]:[]],attributeOldValue:!0,childList:n||N().some(e=>e.enter),characterData:n,characterDataOldValue:n,subtree:!0})}function ze(e,t){let n=N();for(let[e,r]of t)n.includes(e)||(r(),t.delete(e));for(let r of n)r.watch&&!t.has(r)&&t.set(r,r.watch(e))}function Be(){let e={capture:!0,passive:!0};document.addEventListener(`pointerdown`,Ae,e),document.addEventListener(`pointerup`,je,e),document.addEventListener(`pointercancel`,je,e),document.addEventListener(`keydown`,Ne,e),document.addEventListener(`keyup`,Pe,e),be=[()=>{document.removeEventListener(`pointerdown`,Ae,e),document.removeEventListener(`pointerup`,je,e),document.removeEventListener(`pointercancel`,je,e),document.removeEventListener(`keydown`,Ne,e),document.removeEventListener(`keyup`,Pe,e),R=void 0;for(let e of L.keys())z(e,!0)},w(e=>{if(e){R=void 0;for(let e of L.keys())z(e,!0)}})]}function B(e,t){if(typeof document>`u`)return()=>{};let n=me();return n?(ge(n),n.install(e,t.effects,C)):(he(Ve),He(e,t.effects))}var Ve={define:_e,install:He};function He(e,t,n=C){let r=new Set(N().map(e=>e.name));for(let e of t)r.has(e.name)||_e(e,n);if(!I){Be();let e=new MutationObserver((e,t)=>Le(e.concat(t.takeRecords())));I=e,be.push(ye(()=>{for(let[t,{watchers:n}]of F)Re(t,e),ze(t,n)}))}let i=F.get(e);if(i)i.installs++;else{let t=new Map;Re(e,I),F.set(e,{installs:1,watchers:t}),ze(e,t)}let a=!1;return()=>{if(a)return;a=!0;let t=F.get(e);if(!t||--t.installs>0)return;F.delete(e);let n=I,r=n.takeRecords();n.disconnect();for(let e of t.watchers.values())e();if(F.size){for(let e of F.keys())Re(e,n);r.length&&queueMicrotask(()=>{if(I!==n)return;let e=[...F.keys()];Le(r.filter(t=>e.some(e=>e.contains(t.target))))})}else{I=void 0;for(let e of be)e();be=[]}}}function Ue(e,t,n,r){let i=(e,t,n)=>3*t*e*(1-e)**2+3*n*e**2*(1-e)+e**3;return a=>{if(a<=0||a>=1)return a<=0?0:1;let o=0,s=1,c=a;for(let t=0;t<24;t++)i(c,e,n)<a?o=c:s=c,c=(o+s)/2;return i(c,t,r)}}var We=e=>e;function Ge(e,t,n,r,i){let a=(n.delay??0)/1e3,o=n.duration/1e3,s=n.ease??We,c=C(),l=0;return{stop:se(n=>{l+=n;let u=!c&&C()||l>=a+o?1:o>0?Math.max(0,(l-a)/o):0;return r(e+(t-e)*s(u)),u<1||(i?.(),!1)})}}function Ke(e,t,n=We,r=0){let i=()=>{},a=new Promise(e=>i=e),o=Ge(0,1,{duration:e*1e3,delay:r*1e3,ease:n},t,()=>i(!0));return{done:a,stop:()=>{o.stop(),i(!1)}}}var qe={stiffness:900,damping:40},Je={stiffness:380,damping:14},Ye=`:is(button, a[href], summary, input:is([type=button], [type=submit], [type=reset], [type=checkbox], [type=radio]), ${[`button`,`link`,`tab`,`radio`,`menuitem`,`menuitemradio`,`menuitemcheckbox`,`option`,`checkbox`].map(e=>`[role=${e}]`).join(`, `)}):not(:disabled, [aria-disabled="true"], [role=switch])`,Xe=`svg, img, .iconify, [data-slot=icon], [data-slot$=Icon], [data-slot=swap-icon]`,Ze=new WeakMap,Qe=e=>e>=40?.03:e>=32?.04:.05;function $e(e){let t=e.dataset.motionPressTarget?e.closest(e.dataset.motionPressTarget):null;if(t instanceof HTMLElement)return{target:t,amount:Qe(t.offsetHeight)};let n=e.firstElementChild;return e.childElementCount===1&&!e.textContent?.trim()&&(n instanceof HTMLElement||n instanceof SVGElement)&&n.matches(Xe)?{target:n,amount:.15}:{target:e,amount:Qe(e.offsetHeight)}}function et(e){let t=e.transitionDuration.split(`,`);return e.transitionProperty.split(`,`).some((e,n)=>/^\s*(?:scale|all)\s*$/.test(e)&&Number.parseFloat(t[n%t.length])>0)}function tt(e,t,n){let{left:r,right:i,top:a,bottom:o,width:s,height:c}=e;return Math.min(t.clientX-r,i-t.clientX)<=s*n||Math.min(t.clientY-a,o-t.clientY)<=c*n}var nt={name:`press`,selector:Ye,press(e,t){let{target:n,amount:r}=$e(e),i=getComputedStyle(n);if(et(i)||i.display===`contents`||i.display===`inline`&&n===e&&!(e instanceof HTMLInputElement))return;let a;if(n===e&&`pointerId`in t&&(a=e.getBoundingClientRect(),tt(a,t,r)))return;let o=Ze.get(n);if(!o){let e={amount:r,spring:A(0,t=>{P(n,{scale:t?String(1-e.amount*t):null})},qe)};o=e,Ze.set(n,o)}o.amount=r;let{spring:s}=o;s.to(1,{preset:qe});let c=!1,l=()=>{c||(c=!0,s.set(0))};return{move:a?e=>{tt(a,e,r)&&l()}:void 0,release:()=>{c||s.to(0,{preset:Je})},cancel:l}}};function rt(e){let t=e.cloneNode(!0);t.inert=!0,t.setAttribute(`aria-hidden`,`true`);for(let e of[t,...t.querySelectorAll(`[id], [name], [form], input, button, select, textarea, fieldset`)])e.removeAttribute(`id`),e.removeAttribute(`name`),e.removeAttribute(`form`),e.matches(`input, button, select, textarea, fieldset`)&&e.setAttribute(`disabled`,``);return t}var it={stiffness:380,damping:26},at={stiffness:260,damping:28},ot=.9,st=.32,ct=Ue(.5,0,.75,0),lt=`data-motion-ghost`,V=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function ut(e){return e.bottom>0&&e.right>0&&e.top<innerHeight&&e.left<innerWidth&&e.width+e.height>0}function dt(e){return[...e.children].filter(e=>e instanceof HTMLElement&&!e.hasAttribute(lt))}function ft(e,t={}){let n=t.items??dt,r=new Map,i=new Set,a=new Map,o=!1;function s(e){if(!e)return{x:0,y:0};let t=1-e.grow.value;return{x:e.x.value+e.from.x*t,y:e.y.value+e.from.y*t}}function c(e,t){let{x:n,y:i,grow:a,from:c}=t;if(!n.active&&!i.active&&!a.active&&n.value===0&&i.value===0&&a.value===1){P(e,{translate:null,scale:null,opacity:null}),o||r.delete(e);return}let{x:l,y:u}=s(t),d=c.scale+(1-c.scale)*a.value;P(e,{translate:l||u?`${l.toFixed(2)}px ${u.toFixed(2)}px`:null,scale:d===1?null:d.toFixed(4),opacity:a.value>=1?null:Math.max(0,Math.min(1,a.value)).toFixed(3)})}function l(e){let t=r.get(e);if(t)return t;let n=()=>t&&c(e,t);return t={x:A(0,n,T.snappy),y:A(0,n,T.snappy),grow:A(1,n,it),from:{x:0,y:0,scale:1}},r.set(e,t),t}function u(e){let t=r.get(e);t&&(r.delete(e),t.x.stop(),t.y.stop(),t.grow.stop(),P(e,{translate:null,scale:null,opacity:null}))}function d(e,t){let n=e.velocity;e.set(t),e.to(0,{preset:T.snappy,velocity:n})}function f(t,n,r){if(!ut(n))return;let a=e.getBoundingClientRect();getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let o=rt(t);o.setAttribute(lt,``),Object.assign(o.style,{boxSizing:`border-box`,height:`${n.height}px`,left:`${n.left-a.left-e.clientLeft+e.scrollLeft}px`,margin:`0`,pointerEvents:`none`,position:`absolute`,top:`${n.top-a.top-e.clientTop+e.scrollTop}px`,width:`${n.width}px`}),P(o,{translate:null,scale:null,opacity:null,filter:null}),e.append(o);let s={element:o,stop:()=>{}},c=()=>{s.stop(),o.remove(),i.delete(s)};if(i.add(s),C()){let e=Ke(.15,e=>P(o,{opacity:(1-e).toFixed(3)}));s.stop=e.stop,e.done.then(c);return}if(r){let e=V(r.getBoundingClientRect()),t=V(n),i=Ke(st,n=>{P(o,{translate:`${((e.x-t.x)*n).toFixed(2)}px ${((e.y-t.y)*n).toFixed(2)}px`,scale:(1-.8*n).toFixed(4),opacity:(1-n).toFixed(3),filter:n>0?`blur(${(3*n).toFixed(2)}px)`:null})},ct);s.stop=i.stop,i.done.then(c);return}let l=A(1,e=>{P(o,{scale:(ot+.09999999999999998*e).toFixed(4),opacity:Math.max(0,e).toFixed(3)}),e<.02&&c()},at);s.stop=()=>l.stop(),l.to(0)}return{measure(){a=new Map;for(let t of n(e)){let e=t.getBoundingClientRect();if(!e.width&&!e.height)continue;let n=V(e),i=s(r.get(t));a.set(t,{x:n.x-i.x,y:n.y-i.y,rect:e})}},play(i={}){let c=a;a=new Map;let p=j(e),m=n(e),h=new Set(m),g=m.map(e=>{let t=e.getBoundingClientRect(),n=s(r.get(e)),i=V(t);return{element:e,rect:t,layout:{x:i.x-n.x,y:i.y-n.y}}}),_=g.map(({element:e})=>{if(!c.has(e)&&i.origin)return(typeof i.origin==`function`?i.origin(e):i.origin)?.getBoundingClientRect()});for(let[e,{rect:n}]of c)h.has(e)||(u(e),p||t.movesOnly||e.hasAttribute(`data-motion-leaving`)||f(e,n,i.target));o=!0,g.forEach(({element:e,rect:n,layout:r},i)=>{if(p)return u(e);let a=c.get(e);if(a){let t=a.x-r.x,i=a.y-r.y;if(Math.abs(t)<.5&&Math.abs(i)<.5)return;if(!ut(a.rect)&&!ut(n))return u(e);let o=l(e);d(o.x,o.x.value+t),d(o.y,o.y.value+i);return}if(!ut(n)||t.movesOnly)return;let o=l(e),s=_[i];if(C())o.from={x:0,y:0,scale:1};else if(s){let e=V(s),t=Math.min(1,Math.max(.2,Math.min(s.width/(n.width||1),s.height/(n.height||1))));o.from={x:e.x-r.x,y:e.y-r.y,scale:t}}else o.from={x:0,y:0,scale:ot};o.grow.set(0),o.grow.to(1,C()?{tween:.15}:{preset:it})}),o=!1},destroy(){for(let e of r.keys())u(e);for(let e of i)e.stop(),e.element.remove();i.clear(),a=new Map}}}var H={effects:[nt]},pt=[[`0px`,`6px`],[`6px`,`0px`],[`calc(100% - 6px)`,`0px`],[`100%`,`6px`],[`100%`,`50%`],[`100%`,`50%`],[`100%`,`calc(100% - 6px)`],[`calc(100% - 6px)`,`100%`],[`6px`,`100%`],[`0px`,`calc(100% - 6px)`],[`0px`,`50%`],[`0px`,`50%`]],mt=e=>e.map(([e,t])=>[`calc(50% + var(--vitehub-hex-w) * ${e})`,`calc(50% + var(--vitehub-hex-h) * ${t})`]),ht=mt([[-.28,-.453],[-.208,-.5],[.208,-.5],[.28,-.453],[.488,-.047],[.488,.047],[.28,.453],[.208,.5],[-.208,.5],[-.28,.453],[-.488,.047],[-.488,-.047]]),gt=mt([[-.5,-.5],[-.5,-.5],[.5,-.5],[.5,-.5],[.5,0],[.5,0],[.5,.5],[.5,.5],[-.5,.5],[-.5,.5],[-.5,0],[-.5,0]]),_t=e=>`polygon(${e.map(([e,t])=>`${e} ${t}`).join(`,`)})`;function vt(e,t,n){let r=(1-n).toFixed(4),i=n.toFixed(4);return _t(e.map(([e,n],a)=>[`calc(${e} * ${r} + ${t[a][0]} * ${i})`,`calc(${n} * ${r} + ${t[a][1]} * ${i})`]))}var yt=_t(pt),bt=_t(ht),xt=_t(gt),St=e=>`calc(var(--start) + ${e} / 2 + (100% - var(--start) - var(--end) - ${e}) * var(--at) / 100)`,Ct=`:host{all:initial;position:fixed;z-index:2147483001;pointer-events:none;filter:drop-shadow(0 8px 24px rgb(0 0 0/25%));color-scheme:dark;font:500 12px/1 ui-sans-serif,system-ui,sans-serif;color:#d4d4d4;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--vitehub-pill-text:#d4d4d4;--vitehub-pill-strong:#fafafa;--vitehub-pill-muted:#a3a3a3;--vitehub-pill-hover:rgb(255 255 255/8%);--vitehub-pill-on:#fafafa;--vitehub-pill-on-text:#0a0a0a;--vitehub-pill-line:rgb(255 255 255/12%);--vitehub-pill-surface:#111;--vitehub-pill-flow:row;--vitehub-hex-h:24px;--vitehub-hex-w:calc(var(--vitehub-hex-h) * 10 / 9);--vitehub-pill-fade:opacity 160ms ease-out 80ms,visibility 0s;--vitehub-pill-fade-end:opacity 160ms ease-out 120ms,visibility 0s;--at:50;--margin:16px;--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px)}
|
|
3
3
|
:host([collapsed]){--margin:2px;--vitehub-pill-fade:opacity 80ms ease-out,visibility 0s 80ms;--vitehub-pill-fade-end:opacity 40ms ease-out,visibility 0s 40ms}
|
|
4
4
|
:host(:is([edge=top],[edge=bottom])){left:${St(`0px`)};--start:max(var(--margin),var(--safe-left));--end:max(var(--margin),var(--safe-right));--x:calc(var(--at) * -1%)}
|
|
@@ -77,7 +77,7 @@ ${Rt}
|
|
|
77
77
|
.me small{margin-top:2px;color:var(--vitehub-pill-muted);font-size:12px}
|
|
78
78
|
.via{display:flex;align-items:center;gap:6px;padding:6px 8px;color:var(--vitehub-pill-muted);font-size:12px}
|
|
79
79
|
.via svg{width:11px;height:10px;flex:none;fill:var(--vitehub-pill-text)}
|
|
80
|
-
`,Bt=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 7h10v10M7 17 17 7"/></svg>`,Vt=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49M14.084 14.158a3 3 0 0 1-4.242-4.242M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143M2 2l20 20"/></svg>`,Ht=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 17 5-5-5-5M21 12H9M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/></svg>`;function Ut(e){return e.trim().split(/\s+/).slice(0,2).map(e=>[...e][0]??``).join(``).toLocaleUpperCase()}function Wt(e){let t=document.createElement(`span`);if(t.className=`avatar`,t.setAttribute(`aria-hidden`,`true`),t.textContent=Ut(e.name),e.image){let n=document.createElement(`img`);n.alt=``,n.referrerPolicy=`no-referrer`,n.src=e.image,n.addEventListener(`load`,()=>t.replaceChildren(n),{once:!0})}return t}function Gt(e,t){let n=document.createElement(`button`);n.type=`button`,n.setAttribute(`role`,`menuitem`),n.tabIndex=-1,n.insertAdjacentHTML(`beforeend`,e);let r=document.createElement(`span`);return r.textContent=t,n.append(r),{item:n,label:r}}function Kt(){let t=new URL(location.href);for(let r of[e,...n])t.searchParams.delete(r);return t}function qt(e){let{account:t,bar:n,signal:r}=e,i=n.parentElement,a=n.attachShadow({mode:`open`});r.addEventListener(`abort`,B(a,H),{once:!0});let o=document.createElement(`style`);o.textContent=zt;let s=document.createElement(`div`);s.id=`account-menu`,s.setAttribute(`popover`,`auto`),s.setAttribute(`role`,`menu`),s.setAttribute(`aria-label`,t.name);let c=document.createElement(`button`);c.type=`button`,c.className=`who`,c.title=t.email?`${t.name} (${t.email})`:t.name,c.setAttribute(`aria-label`,`Account: ${t.name}`),c.setAttribute(`aria-haspopup`,`menu`),c.setAttribute(`aria-expanded`,`false`),c.setAttribute(`aria-controls`,s.id),c.setAttribute(`popovertarget`,s.id),c.append(Wt(t));let l=document.createElement(`div`);l.className=`me`,l.setAttribute(`role`,`none`);let u=document.createElement(`div`),d=document.createElement(`b`);if(d.textContent=t.name,u.append(d),t.email){let e=document.createElement(`small`);e.textContent=t.email,u.append(e)}if(l.append(Wt(t),u),s.append(l),t.via===`console`){let t=document.createElement(`div`);t.className=`via`,t.setAttribute(`role`,`none`),t.append(wt(`0 0 20 18`,e.mark,{}),`Signed in with ViteHub Console`),s.append(t)}let f=Gt(Bt,`Open in the Console`),p=Gt(Ht,`Sign out of ${location.host}`);s.append(f.item,p.item),a.append(o,c,s);let m;Yt({menu:s,button:c,pill:i,beforeOpen:()=>{m=e.openConsole?.(),f.item.hidden=!m},signal:r}),f.item.addEventListener(`click`,()=>{s.hidePopover(),m?.()},{signal:r}),Xt(t,p,r)}function Jt(e){let{account:t,button:n,turnOff:r,canExit:i,signal:a}=e,o=document.createElement(`style`);o.textContent=Rt;let s=document.createElement(`vitehub-menu`);s.id=`exit-menu`,s.setAttribute(`popover`,`auto`),s.setAttribute(`role`,`menu`),s.setAttribute(`aria-label`,`Turn off tools or sign out`);let c=Gt(Vt,r.label),l=Gt(Ht,`Sign out of ${location.host}`);s.append(c.item,l.item);let u=`Turn off tools or sign out`;n.setAttribute(`aria-label`,u),n.title=u,n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,s.id),n.setAttribute(`popovertarget`,s.id);let d=n.getRootNode();return Yt({menu:s,button:n,pill:d instanceof ShadowRoot&&d.host instanceof HTMLElement?d.host:null,signal:a}),c.item.addEventListener(`click`,e=>{s.hidePopover(),r.press(e.detail===0)},{signal:a}),Xt(t,l,a,i),[o,s]}function Yt(e){let{menu:t,button:n,pill:r,signal:i}=e,a=()=>{let e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement:null},o=()=>[...t.querySelectorAll(`[role=menuitem]`)].filter(e=>!e.hidden),s=e=>{let i=document.documentElement.clientWidth,a=document.documentElement.clientHeight,o=(r??n).getBoundingClientRect(),s=n.getBoundingClientRect(),c={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};e===`bottom`||e===`top`?(c.right=`${Math.max(8,i-s.right)}px`,e===`bottom`?c.bottom=`${a-o.top+8}px`:c.top=`${o.bottom+8}px`):(s.top<a/2?c.top=`${Math.max(8,s.top)}px`:c.bottom=`${Math.max(8,a-s.bottom)}px`,e===`left`?c.left=`${o.right+8}px`:c.right=`${i-o.left+8}px`),Object.assign(t.style,c)},c=e=>{if(e!==`bottom`&&e!==`top`)return;let r=document.documentElement.clientWidth,i=n.getBoundingClientRect(),a=t.getBoundingClientRect().width;t.style.right=`auto`,t.style.left=`${Math.max(8,Math.min(i.right-a,r-a-8))}px`};if(t.addEventListener(`beforetoggle`,i=>{if(i.newState===`closed`){t.contains(a())&&n.focus({preventScroll:!0});return}e.beforeOpen?.();let o=r?.getAttribute(`edge`)??`bottom`;s(o),requestAnimationFrame(()=>c(o))},{signal:i}),t.addEventListener(`toggle`,e=>{let t=e.newState===`open`;n.setAttribute(`aria-expanded`,String(t)),t&&o()[0]?.focus({preventScroll:!0})},{signal:i}),t.addEventListener(`keydown`,e=>{let n=o(),r=n.findIndex(e=>e===a()),i=e.key===`ArrowDown`?r+1:e.key===`ArrowUp`?r-1:e.key===`Home`?0:e.key===`End`?n.length-1:void 0;i===void 0?e.key===`Escape`?e.stopPropagation():e.key===`Tab`&&t.hidePopover():(e.preventDefault(),n[(i+n.length)%n.length]?.focus())},{signal:i}),r){let e=new MutationObserver(e=>{e.some(e=>e.oldValue!==r.getAttribute(e.attributeName??``))&&t.hidePopover()});e.observe(r,{attributes:!0,attributeOldValue:!0,attributeFilter:[`collapsed`,`dragging`,`edge`]}),i.addEventListener(`abort`,()=>e.disconnect(),{once:!0})}i.addEventListener(`abort`,()=>t.hidePopover(),{once:!0})}function Xt(e,t,n,r){t.item.addEventListener(`click`,async()=>{if(t.item.getAttribute(`aria-disabled`)===`true`||r?.()===!1)return;t.item.setAttribute(`aria-disabled`,`true`),t.label.textContent=`Signing out…`;let n=await fetch(e.signOut,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:`{}`}).catch(e=>e);if(!(n instanceof Response)||!n.ok){console.error(`[vitehub] The sign-out failed. The session stays.`,n instanceof Response?`The sign-out answered ${n.status}.`:n),t.item.removeAttribute(`aria-disabled`),t.label.textContent=`Could not sign out. Try again`;return}let i=Kt();i.href===location.href?location.reload():location.replace(i)},{signal:n})}var Zt=l({docsBase:`https://vitehub.dev/docs/development/diagnostics`,codes:{INTERNAL_INVARIANT_FAILED:{why:({what:e})=>`ViteHub reached a state that it does not expect: ${e}`,fix:`This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace.`}}});function Qt(e){return Zt.INTERNAL_INVARIANT_FAILED({what:e})}function $t(e,t){if(!e)throw Qt(t)}function en(e,t,n){let r=e.cloneNode(!0);for(let e of[r,...r.querySelectorAll(`*`)])for(let t of[`id`,`role`,`tabindex`,`hidden`,`inert`,`popover`,`data-ending-style`,`data-starting-style`,`aria-live`])e.removeAttribute(t);return r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`data-motion`,`none`),r instanceof HTMLElement&&(r.inert=!0),r.style.pointerEvents=`none`,t.insertBefore(r,n?.parentNode===t?n:null),r}function tn(e,t){Object.assign(e.style,{position:`fixed`,inset:`auto`,left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,margin:`0`,boxSizing:`border-box`,transform:`none`,translate:`none`,zIndex:`2147483647`});let n=e.getBoundingClientRect();Math.abs(n.left-t.left)>.5&&(e.style.left=`${2*t.left-n.left}px`),Math.abs(n.top-t.top)>.5&&(e.style.top=`${2*t.top-n.top}px`)}function nn(e,t){return window.setTimeout(t,e*re())}var W={stiffness:480,damping:36},rn={stiffness:380,damping:26},G={stiffness:440,damping:32},an=30,on=120,sn=70,cn=40,ln=90,un=520,dn=.24,fn=.15,pn=.14,mn=.15,K=new WeakMap,q=new Set,hn=new Set,J;function gn(e){let t=getComputedStyle(e);return t.clipPath===`inset(50%)`||t.clip===`rect(0px, 0px, 0px, 0px)`}function _n(e){return e.matches(`[role=tooltip]`)?e:e.querySelector(`:scope > [role=tooltip]`)}var vn=`[data-motion-appear]`;function yn(e){if(e.matches(vn))return e;if(e.matches(`[role=tooltip]`))return gn(e)?e.parentElement:e;let t=e.querySelector(`:scope > [role=tooltip]`);return t&&gn(t)?e:null}function bn(e){let t=e.getAttribute(`data-state`);return t===null?!e.hidden&&!e.hasAttribute(`data-closed`):t!==`closed`}function xn(e){let t=e.getAttribute(`data-motion-appear`);if(t!==null){let n=e.parentElement;return!t||!n?null:n.closest(t)??[...n.children].find(n=>n!==e&&n.matches(t))??null}let n=_n(e)?.id;return n?e.getRootNode().querySelector(`[aria-describedby~="${CSS.escape(n)}"]`)??document.querySelector(`[aria-describedby~="${CSS.escape(n)}"]`):null}function Sn(e){let t=[`translate`,`scale`,`clip-path`,`opacity`].map(t=>[t,e.style.getPropertyValue(t)]);P(e,{translate:null,scale:null,"clip-path":null});let n=e.getBoundingClientRect();for(let[n,r]of t)r&&e.style.setProperty(n,r);return n}function Cn(e,t,n){let r=e.getAttribute(`data-side`);if(r===`top`||r===`bottom`||r===`left`||r===`right`)return r;if(!n)return`top`;let i=n.left+n.width/2-(t.left+t.width/2),a=n.top+n.height/2-(t.top+t.height/2);return Math.abs(a)>=Math.abs(i)?a>0?`top`:`bottom`:i>0?`left`:`right`}function wn(e,t,n){return e===`top`?n?.top??t.bottom+8:e===`bottom`?n?.bottom??t.top-8:e===`left`?n?.left??t.right+8:n?.right??t.left-8}var Tn=e=>e===`top`||e===`bottom`;function En(e){let{rest:t,side:n,edge:r}=e;return n===`top`?r+t.height/2:n===`bottom`?r-t.height/2:n===`left`?r+t.width/2:r-t.width/2}function Dn(e){return[...e.element.children].filter(t=>t instanceof HTMLElement&&t!==e.old?.element&&!t.matches(`[role=tooltip]`)&&!gn(t))}function On(e){return[...e.element.childNodes].filter(t=>t.nodeType===Node.TEXT_NODE||t instanceof Element&&t!==e.old?.element&&!t.matches(`[role=tooltip]`)&&!gn(t)).map(e=>e.textContent??``).join(``)}function kn(e){return[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())}var Y=e=>`${Math.round(e*100)/100}px`;function X(e){let{element:t,rest:n,side:r,edge:i,origin:a}=e,o=Math.max(1,e.width.value),s=e.mode===`clip`&&o<n.width,c=s?1:o/n.width,l=e.x.value-o/2,u=s?e.x.value-(n.left+n.width/2):l-n.left-a*(1-c),d=e.y.value-(n.top+n.height/2),f=[-40,-40,-40,-40];r===`top`&&(f[2]=e.y.value+n.height/2-i),r===`bottom`&&(f[0]=i-(e.y.value-n.height/2)),r===`left`&&(f[1]=(e.x.value+o/2-i)/c),r===`right`&&(f[3]=(i-(e.x.value-o/2))/c);let p=f.some(e=>e>0),m=null;if(s){let t=(n.width-o)/2;m=`inset(${[Math.max(0,f[0]),t+Math.max(0,f[1]),Math.max(0,f[2]),t+Math.max(0,f[3])].map(Y).join(` `)} round ${e.radius})`}else p&&(m=`inset(${f.map(Y).join(` `)})`);P(t,{translate:Math.abs(u)>.01||Math.abs(d)>.01||e.old?`${Y(u)} ${Y(d)}`:null,scale:Math.abs(c-1)>.001?`${c} 1`:null,"clip-path":m,opacity:e.fade.active||e.fade.value<1?String(e.fade.value):null});let h=Math.abs(c-1)>.001?`${1/c} 1`:null,g=e.label.value;for(let t of Dn(e))P(t,{scale:h,opacity:g<1?String(g):null,filter:g<1?`blur(${Y((1-g)*6)})`:null});if(e.old){let t=e.old.spring.value;P(e.old.element,{scale:h,opacity:String(t),filter:`blur(${Y((1-t)*5)})`})}}function An(e){if(!(e.holding||e.timers.size||[e.x,e.y,e.width,e.label,e.fade,e.old?.spring].some(e=>e?.active))){e.old?.element.remove(),e.old=void 0,P(e.element,{translate:null,scale:null,"clip-path":null,opacity:null});for(let t of Dn(e))P(t,{scale:null,opacity:null,filter:null});e.done?.()}}function jn(e,t,n){let r=getComputedStyle(e),i=Cn(e,t,n),a={element:e,rest:t,origin:Number.parseFloat(r.transformOrigin)||t.width/2,side:i,edge:wn(i,t,n),trigger:n,mode:kn(e)||e.matches(vn)?`clip`:`scale`,handoff:!e.matches(vn),radius:r.borderRadius||`0px`,timers:new Set,holding:!0},o=()=>{X(a),An(a)};return a.x=A(t.left+t.width/2,o,W),a.y=A(t.top+t.height/2,o,W),a.width=A(t.width,o,G),a.label=A(1,o),a.fade=A(1,o),a}function Z(e,t,n){let r=nn(t,()=>{e.timers.delete(r),n(),An(e)});e.timers.add(r)}function Mn(e){for(let t of e.timers)clearTimeout(t);e.timers.clear();for(let t of[e.x,e.y,e.width,e.label,e.fade,e.old?.spring])t?.stop()}function Nn(e){Mn(e),hn.delete(e),J===e&&(J=void 0),e.element.closest(`[data-motion=none]`)?.remove()}function Pn(e){if(e){for(let e of hn)Nn(e);for(let e of q){let t=K.get(e)?.box;t&&(Mn(t),t.holding=!0,t.x.set(t.rest.left+t.rest.width/2),t.y.set(t.rest.top+t.rest.height/2),t.width.set(t.rest.width),t.label.set(1),t.fade.set(1),t.holding=!1,An(t))}}}function Fn(e,t){let n=e.trigger,r=t.trigger;return!n||!r||e.side!==t.side?!1:Tn(t.side)?n.top<r.bottom&&r.top<n.bottom:n.left<r.right&&r.left<n.right}function In(e){return Tn(e.side)?e.y:e.x}function Ln(e,t,n){if(!t.length)return;let r=document.createElement(`span`);r.setAttribute(`aria-hidden`,`true`),Object.assign(r.style,{position:`absolute`,inset:`0`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`inherit`,pointerEvents:`none`,whiteSpace:`nowrap`}),r.append(...t),e.element.append(r);let i=A(n,()=>{X(e),An(e)});e.old={element:r,spring:i},i.to(0,{tween:fn})}function Rn(e){return e.mode===`clip`?[...e.element.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.cloneNode()):Dn(e).map(e=>{let t=e.cloneNode(!0);return t.style.removeProperty(`scale`),t.style.removeProperty(`opacity`),t.style.removeProperty(`filter`),t})}function zn(e,t){let n=t.trigger?.getBoundingClientRect(),r=Sn(e),i=jn(e,r,n);t.box=i,t.text=On(i),t.label=Rn(i),P(e,{opacity:null});let a=i.handoff&&J&&Fn(J,i)?J:void 0;if(a&&(J=void 0),C())a&&Bn(a,!0),i.fade.set(0),i.holding=!1,i.fade.to(1,{tween:mn});else if(a){let e=Rn(a),t={x:[a.x.value,a.x.velocity],y:[a.y.value,a.y.velocity],width:[a.width.value,a.width.velocity]},n=a.old?0:a.label.value;Nn(a),i.x.set(t.x[0]),i.y.set(t.y[0]),i.width.set(t.width[0]),i.label.set(0),Ln(i,e,n),i.x.to(r.left+r.width/2,{preset:W,velocity:t.x[1]}),i.y.to(r.top+r.height/2,{preset:W,velocity:t.y[1]}),i.width.to(r.width,{preset:G,velocity:t.width[1]}),Z(i,cn,()=>i.label.to(1,{tween:dn})),i.holding=!1,X(i)}else In(i).set(En(i)),i.width.set(Math.min(an,r.width)),i.label.set(0),X(i),In(i).to(Tn(i.side)?r.top+r.height/2:r.left+r.width/2,{preset:rn}),Z(i,on,()=>{i.width.to(r.width,{preset:G}),Z(i,sn,()=>i.label.to(1,{tween:dn}))}),i.holding=!1}function Bn(e,t){hn.add(e),e.holding=!1,t?(e.done=()=>Nn(e),e.fade.to(0,{tween:mn})):(e.handoff&&(J=e),e.old&&e.old.spring.to(0,{tween:pn}),e.label.to(0,{tween:pn}),e.width.to(Math.min(an,e.rest.width),{preset:G}),Z(e,ln,()=>{J===e&&(J=void 0),In(e).to(En(e),{preset:rn})}),Z(e,un,()=>Nn(e)))}function Vn(e,t){if(!t.open)return;t.open=!1,q.delete(e),t.stopWatch?.(),t.stopWatch=void 0,q.size||Qn();let n=t.box;if(t.box=void 0,P(e,{opacity:null}),!n)return;let r=t.root.parentNode??t.parent,i=r?.isConnected?en(t.root,r,t.root.isConnected?t.root.nextSibling:t.next):void 0,a={x:n.x,y:n.y,width:n.width,label:n.label,fade:n.fade},o=Object.fromEntries(Object.entries(a).map(([e,t])=>[e,[t.value,t.velocity]])),s=n.old?.spring.value;Mn(n),n.old?.element.remove(),P(e,{translate:null,scale:null,"clip-path":null,opacity:null});for(let e of Dn(n))P(e,{scale:null,opacity:null,filter:null});if(!i)return;let c=Hn(t.root,e).reduce((e,t)=>e?.children[t],i);if(!(c instanceof HTMLElement)){i.remove();return}e.hasAttribute(`popover`)&&(P(c,{scale:null}),tn(c,n.rest));let l=jn(c,n.rest,void 0);Object.assign(l,{side:n.side,edge:n.edge,trigger:n.trigger,mode:n.mode,origin:n.origin,radius:n.radius,handoff:n.handoff});let u=c.querySelector(`:scope > [aria-hidden=true][style*=absolute]`);s!==void 0&&u&&(l.old={element:u,spring:A(s,()=>X(l))});for(let e of[`x`,`y`,`width`,`label`,`fade`])l[e].set(o[e][0]);X(l);for(let e of[`x`,`y`,`width`])o[e][1]&&l[e].to(o[e][0],{velocity:o[e][1]});Bn(l,C())}function Hn(e,t){let n=[];for(let r=t;r!==e&&r.parentElement;r=r.parentElement)n.unshift([...r.parentElement.children].indexOf(r));return n}function Un(e,t,n,r=20){requestAnimationFrame(()=>{if(!t.open||!e.isConnected)return;let i=e.closest(`[data-reka-popper-content-wrapper]`);if(r>0&&i?.style.transform.includes(`-200%`))return Un(e,t,n,r-1);n()})}function Wn(e,t){let n=()=>{r.disconnect();let t=e;for(;t;){let e=t.parentNode;e&&r.observe(e,{childList:!0}),t=e??(t instanceof ShadowRoot?t.host:null)}},r=new MutationObserver(()=>{e.isConnected?(t.parent=t.root.parentNode,t.next=t.root.nextSibling,n()):Vn(e,t)});return n(),()=>r.disconnect()}function Gn(e){let t=K.get(e);if(t?.open)return;let n=xn(e);if(n&&j(n))return;let r=e.closest(`[data-reka-popper-content-wrapper]`)??e;t={open:!0,root:r,parent:r.parentNode,next:r.nextSibling,text:``,label:[],trigger:n},K.set(e,t),q.add(e),Zn(),P(e,{opacity:`0`}),t.stopWatch=Wn(e,t);let i=t;Un(e,t,()=>zn(e,i))}var Kn=0;function qn(){Kn=0;for(let e of q){let t=K.get(e),n=t?.box;if(!t||!n)continue;let r=Sn(e),i=On(n);if(!(Math.abs(r.left-n.rest.left)>1||Math.abs(r.top-n.rest.top)>1||Math.abs(r.width-n.rest.width)>1)&&i===t.text)continue;let a=i===t.text?[]:t.label;t.trigger=xn(e)??t.trigger;let o=t.trigger?.getBoundingClientRect();t.text=i,t.label=Rn(n),n.rest=r,n.side=Cn(e,r,o),n.edge=wn(n.side,r,o),C()?(n.x.set(r.left+r.width/2),n.y.set(r.top+r.height/2),n.width.set(r.width)):(n.x.to(r.left+r.width/2,{preset:W}),n.y.to(r.top+r.height/2,{preset:W}),n.width.to(r.width,{preset:G}),a.length&&(n.old?.spring.stop(),n.old?.element.remove(),Ln(n,a,n.label.value),n.label.set(0),Z(n,cn,()=>n.label.to(1,{tween:dn}))))}}function Jn(){Kn||=requestAnimationFrame(qn)}var Yn=!1,Xn;function Zn(){Xn??=w(Pn),Yn||(Yn=!0,document.addEventListener(`pointerover`,Jn,{capture:!0,passive:!0}),document.addEventListener(`focusin`,Jn,{capture:!0,passive:!0}))}function Qn(){Yn=!1,cancelAnimationFrame(Kn),Kn=0,document.removeEventListener(`pointerover`,Jn,{capture:!0}),document.removeEventListener(`focusin`,Jn,{capture:!0})}var $n={enter(e){yn(e)===e&&bn(e)&&Gn(e)},state(e){if(yn(e)!==e)return;let t=K.get(e);bn(e)?Gn(e):t&&Vn(e,t)}};({...$n});var er={name:`appear`,selector:vn,...$n},tr=`
|
|
80
|
+
`,Bt=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 7h10v10M7 17 17 7"/></svg>`,Vt=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49M14.084 14.158a3 3 0 0 1-4.242-4.242M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143M2 2l20 20"/></svg>`,Ht=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 17 5-5-5-5M21 12H9M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/></svg>`;function Ut(e){return e.trim().split(/\s+/).slice(0,2).map(e=>[...e][0]??``).join(``).toLocaleUpperCase()}function Wt(e){let t=document.createElement(`span`);if(t.className=`avatar`,t.setAttribute(`aria-hidden`,`true`),t.textContent=Ut(e.name),e.image){let n=document.createElement(`img`);n.alt=``,n.referrerPolicy=`no-referrer`,n.src=e.image,n.addEventListener(`load`,()=>t.replaceChildren(n),{once:!0})}return t}function Gt(e,t){let n=document.createElement(`button`);n.type=`button`,n.setAttribute(`role`,`menuitem`),n.tabIndex=-1,n.insertAdjacentHTML(`beforeend`,e);let r=document.createElement(`span`);return r.textContent=t,n.append(r),{item:n,label:r}}function Kt(){let t=new URL(location.href);for(let r of[e,...n])t.searchParams.delete(r);return t}function qt(e){let{account:t,bar:n,signal:r}=e,i=n.parentElement,a=n.attachShadow({mode:`open`});r.addEventListener(`abort`,B(a,H),{once:!0});let o=document.createElement(`style`);o.textContent=zt;let s=document.createElement(`div`);s.id=`account-menu`,s.setAttribute(`popover`,`auto`),s.setAttribute(`role`,`menu`),s.setAttribute(`aria-label`,t.name);let c=document.createElement(`button`);c.type=`button`,c.className=`who`,c.title=t.email?`${t.name} (${t.email})`:t.name,c.setAttribute(`aria-label`,`Account: ${t.name}`),c.setAttribute(`aria-haspopup`,`menu`),c.setAttribute(`aria-expanded`,`false`),c.setAttribute(`aria-controls`,s.id),c.setAttribute(`popovertarget`,s.id),c.append(Wt(t));let l=document.createElement(`div`);l.className=`me`,l.setAttribute(`role`,`none`);let u=document.createElement(`div`),d=document.createElement(`b`);if(d.textContent=t.name,u.append(d),t.email){let e=document.createElement(`small`);e.textContent=t.email,u.append(e)}if(l.append(Wt(t),u),s.append(l),t.via===`console`){let t=document.createElement(`div`);t.className=`via`,t.setAttribute(`role`,`none`),t.append(wt(`0 0 20 18`,e.mark,{}),`Signed in with ViteHub Console`),s.append(t)}let f=Gt(Bt,`Open in the Console`),p=Gt(Ht,`Sign out of ${location.host}`);s.append(f.item,p.item),a.append(o,c,s);let m;Yt({menu:s,button:c,pill:i,beforeOpen:()=>{m=e.openConsole?.(),f.item.hidden=!m},signal:r}),f.item.addEventListener(`click`,()=>{s.hidePopover(),m?.()},{signal:r}),Xt(t,p,r)}function Jt(e){let{account:t,button:n,turnOff:r,canExit:i,signal:a}=e,o=document.createElement(`style`);o.textContent=Rt;let s=document.createElement(`vitehub-menu`);s.id=`exit-menu`,s.setAttribute(`popover`,`auto`),s.setAttribute(`role`,`menu`),s.setAttribute(`aria-label`,`Turn off tools or sign out`);let c=Gt(Vt,r.label),l=Gt(Ht,`Sign out of ${location.host}`);s.append(c.item,l.item);let u=`Turn off tools or sign out`;n.setAttribute(`aria-label`,u),n.title=u,n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,s.id),n.setAttribute(`popovertarget`,s.id);let d=n.getRootNode();return Yt({menu:s,button:n,pill:d instanceof ShadowRoot&&d.host instanceof HTMLElement?d.host:null,signal:a}),c.item.addEventListener(`click`,e=>{s.hidePopover(),r.press(e.detail===0)},{signal:a}),Xt(t,l,a,i),[o,s]}function Yt(e){let{menu:t,button:n,pill:r,signal:i}=e,a=()=>{let e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement:null},o=()=>[...t.querySelectorAll(`[role=menuitem]`)].filter(e=>!e.hidden),s=e=>{let i=document.documentElement.clientWidth,a=document.documentElement.clientHeight,o=(r??n).getBoundingClientRect(),s=n.getBoundingClientRect(),c={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};e===`bottom`||e===`top`?(c.right=`${Math.max(8,i-s.right)}px`,e===`bottom`?c.bottom=`${a-o.top+8}px`:c.top=`${o.bottom+8}px`):(s.top<a/2?c.top=`${Math.max(8,s.top)}px`:c.bottom=`${Math.max(8,a-s.bottom)}px`,e===`left`?c.left=`${o.right+8}px`:c.right=`${i-o.left+8}px`),Object.assign(t.style,c)},c=e=>{if(e!==`bottom`&&e!==`top`)return;let r=document.documentElement.clientWidth,i=n.getBoundingClientRect(),a=t.getBoundingClientRect().width;t.style.right=`auto`,t.style.left=`${Math.max(8,Math.min(i.right-a,r-a-8))}px`};if(t.addEventListener(`beforetoggle`,i=>{if(i.newState===`closed`){t.contains(a())&&n.focus({preventScroll:!0});return}e.beforeOpen?.();let o=r?.getAttribute(`edge`)??`bottom`;s(o),requestAnimationFrame(()=>c(o))},{signal:i}),t.addEventListener(`toggle`,e=>{let t=e.newState===`open`;n.setAttribute(`aria-expanded`,String(t)),t&&o()[0]?.focus({preventScroll:!0})},{signal:i}),t.addEventListener(`keydown`,e=>{let n=o(),r=n.findIndex(e=>e===a()),i=e.key===`ArrowDown`?r+1:e.key===`ArrowUp`?r-1:e.key===`Home`?0:e.key===`End`?n.length-1:void 0;i===void 0?e.key===`Escape`?e.stopPropagation():e.key===`Tab`&&t.hidePopover():(e.preventDefault(),n[(i+n.length)%n.length]?.focus())},{signal:i}),r){let e=new MutationObserver(e=>{e.some(e=>e.oldValue!==r.getAttribute(e.attributeName??``))&&t.hidePopover()});e.observe(r,{attributes:!0,attributeOldValue:!0,attributeFilter:[`collapsed`,`dragging`,`edge`]}),i.addEventListener(`abort`,()=>e.disconnect(),{once:!0})}i.addEventListener(`abort`,()=>t.hidePopover(),{once:!0})}function Xt(e,t,n,r){t.item.addEventListener(`click`,async()=>{if(t.item.getAttribute(`aria-disabled`)===`true`||r?.()===!1)return;t.item.setAttribute(`aria-disabled`,`true`),t.label.textContent=`Signing out…`;let n=await fetch(e.signOut,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:`{}`}).catch(e=>e);if(!(n instanceof Response)||!n.ok){console.error(`[vitehub] The sign-out failed. The session stays.`,n instanceof Response?`The sign-out answered ${n.status}.`:n),t.item.removeAttribute(`aria-disabled`),t.label.textContent=`Could not sign out. Try again`;return}let i=Kt();i.href===location.href?location.reload():location.replace(i)},{signal:n})}var Zt=l({docsBase:`https://vitehub.dev/docs/development/diagnostics`,codes:{INTERNAL_INVARIANT_FAILED:{why:({what:e})=>`ViteHub reached a state that it does not expect: ${e}`,fix:`This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace.`}}});function Qt(e){return Zt.INTERNAL_INVARIANT_FAILED({what:e})}function $t(e,t){if(!e)throw Qt(t)}function en(e,t,n){let r=e.cloneNode(!0);for(let e of[r,...r.querySelectorAll(`*`)])for(let t of[`id`,`role`,`tabindex`,`hidden`,`inert`,`popover`,`data-ending-style`,`data-starting-style`,`aria-live`])e.removeAttribute(t);return r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`data-motion`,`none`),r instanceof HTMLElement&&(r.inert=!0),r.style.pointerEvents=`none`,t.insertBefore(r,n?.parentNode===t?n:null),r}function tn(e,t){Object.assign(e.style,{position:`fixed`,inset:`auto`,left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,margin:`0`,boxSizing:`border-box`,transform:`none`,translate:`none`,zIndex:`2147483647`});let n=e.getBoundingClientRect();Math.abs(n.left-t.left)>.5&&(e.style.left=`${2*t.left-n.left}px`),Math.abs(n.top-t.top)>.5&&(e.style.top=`${2*t.top-n.top}px`)}function nn(e,t){return window.setTimeout(t,e*re())}var W={stiffness:480,damping:36},rn={stiffness:380,damping:26},G={stiffness:440,damping:32},an=30,on=120,sn=70,cn=40,ln=90,un=520,dn=.24,fn=.15,pn=.14,mn=.15,K=new WeakMap,q=new Set,hn=new Set,J;function gn(e){let t=getComputedStyle(e);return t.clipPath===`inset(50%)`||t.clip===`rect(0px, 0px, 0px, 0px)`}function _n(e){return e.matches(`[role=tooltip]`)?e:e.querySelector(`:scope > [role=tooltip]`)}var vn=`[data-motion-appear]`;function yn(e){if(e.matches(vn))return e;if(e.matches(`[role=tooltip]`))return gn(e)?e.parentElement:e;let t=e.querySelector(`:scope > [role=tooltip]`);return t&&gn(t)?e:null}function bn(e){let t=e.getAttribute(`data-state`);return t===null?!e.hidden&&!e.hasAttribute(`data-closed`):t!==`closed`}function xn(e){let t=e.getAttribute(`data-motion-appear`);if(t!==null){let n=e.parentElement;return!t||!n?null:n.closest(t)??[...n.children].find(n=>n!==e&&n.matches(t))??null}let n=_n(e)?.id;return n?e.getRootNode().querySelector(`[aria-describedby~="${CSS.escape(n)}"]`)??document.querySelector(`[aria-describedby~="${CSS.escape(n)}"]`):null}function Sn(e){let t=[`translate`,`scale`,`clip-path`,`opacity`].map(t=>[t,e.style.getPropertyValue(t)]);P(e,{translate:null,scale:null,"clip-path":null});let n=e.getBoundingClientRect();for(let[n,r]of t)r&&e.style.setProperty(n,r);return n}function Cn(e,t,n){let r=e.getAttribute(`data-side`);if(r===`top`||r===`bottom`||r===`left`||r===`right`)return r;if(!n)return`top`;let[i,a]=[[`top`,n.top-t.bottom],[`bottom`,t.top-n.bottom],[`left`,n.left-t.right],[`right`,t.left-n.right]].reduce((e,t)=>t[1]>e[1]?t:e);if(a>=0)return i;let o=n.left+n.width/2-(t.left+t.width/2),s=n.top+n.height/2-(t.top+t.height/2);return Math.abs(s)>=Math.abs(o)?s>0?`top`:`bottom`:o>0?`left`:`right`}function wn(e,t,n){return e===`top`?n?.top??t.bottom+8:e===`bottom`?n?.bottom??t.top-8:e===`left`?n?.left??t.right+8:n?.right??t.left-8}var Tn=e=>e===`top`||e===`bottom`;function En(e){let{rest:t,side:n,edge:r}=e;return n===`top`?r+t.height/2:n===`bottom`?r-t.height/2:n===`left`?r+t.width/2:r-t.width/2}function Dn(e){return[...e.element.children].filter(t=>t instanceof HTMLElement&&t!==e.old?.element&&!t.matches(`[role=tooltip]`)&&!gn(t))}function On(e){return[...e.element.childNodes].filter(t=>t.nodeType===Node.TEXT_NODE||t instanceof Element&&t!==e.old?.element&&!t.matches(`[role=tooltip]`)&&!gn(t)).map(e=>e.textContent??``).join(``)}function kn(e){return[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())}var Y=e=>`${Math.round(e*100)/100}px`;function X(e){let{element:t,rest:n,side:r,edge:i,origin:a}=e,o=Math.max(1,e.width.value),s=e.mode===`clip`&&o<n.width,c=s?1:o/n.width,l=e.x.value-o/2,u=s?e.x.value-(n.left+n.width/2):l-n.left-a*(1-c),d=e.y.value-(n.top+n.height/2),f=[-40,-40,-40,-40];r===`top`&&(f[2]=e.y.value+n.height/2-i),r===`bottom`&&(f[0]=i-(e.y.value-n.height/2)),r===`left`&&(f[1]=(e.x.value+o/2-i)/c),r===`right`&&(f[3]=(i-(e.x.value-o/2))/c);let p=f.some(e=>e>0),m=null;if(s){let t=(n.width-o)/2;m=`inset(${[Math.max(0,f[0]),t+Math.max(0,f[1]),Math.max(0,f[2]),t+Math.max(0,f[3])].map(Y).join(` `)} round ${e.radius})`}else p&&(m=`inset(${f.map(Y).join(` `)})`);P(t,{translate:Math.abs(u)>.01||Math.abs(d)>.01||e.old?`${Y(u)} ${Y(d)}`:null,scale:Math.abs(c-1)>.001?`${c} 1`:null,"clip-path":m,opacity:e.fade.active||e.fade.value<1?String(e.fade.value):null});let h=Math.abs(c-1)>.001?`${1/c} 1`:null,g=e.label.value;for(let t of Dn(e))P(t,{scale:h,opacity:g<1?String(g):null,filter:g<1?`blur(${Y((1-g)*6)})`:null});if(e.old){let t=e.old.spring.value;P(e.old.element,{scale:h,opacity:String(t),filter:`blur(${Y((1-t)*5)})`})}}function An(e){if(!(e.holding||e.timers.size||[e.x,e.y,e.width,e.label,e.fade,e.old?.spring].some(e=>e?.active))){e.old?.element.remove(),e.old=void 0,P(e.element,{translate:null,scale:null,"clip-path":null,opacity:null});for(let t of Dn(e))P(t,{scale:null,opacity:null,filter:null});e.done?.()}}function jn(e,t,n){let r=getComputedStyle(e),i=Cn(e,t,n),a={element:e,rest:t,origin:Number.parseFloat(r.transformOrigin)||t.width/2,side:i,edge:wn(i,t,n),trigger:n,mode:kn(e)||e.matches(vn)?`clip`:`scale`,handoff:!e.matches(vn),radius:r.borderRadius||`0px`,timers:new Set,holding:!0},o=()=>{X(a),An(a)};return a.x=A(t.left+t.width/2,o,W),a.y=A(t.top+t.height/2,o,W),a.width=A(t.width,o,G),a.label=A(1,o),a.fade=A(1,o),a}function Z(e,t,n){let r=nn(t,()=>{e.timers.delete(r),n(),An(e)});e.timers.add(r)}function Mn(e){for(let t of e.timers)clearTimeout(t);e.timers.clear();for(let t of[e.x,e.y,e.width,e.label,e.fade,e.old?.spring])t?.stop()}function Nn(e){Mn(e),hn.delete(e),J===e&&(J=void 0),e.element.closest(`[data-motion=none]`)?.remove()}function Pn(e){if(e){for(let e of hn)Nn(e);for(let e of q){let t=K.get(e)?.box;t&&(Mn(t),t.holding=!0,t.x.set(t.rest.left+t.rest.width/2),t.y.set(t.rest.top+t.rest.height/2),t.width.set(t.rest.width),t.label.set(1),t.fade.set(1),t.holding=!1,An(t))}}}function Fn(e,t){let n=e.trigger,r=t.trigger;return!n||!r||e.side!==t.side?!1:Tn(t.side)?n.top<r.bottom&&r.top<n.bottom:n.left<r.right&&r.left<n.right}function In(e){return Tn(e.side)?e.y:e.x}function Ln(e,t,n){if(!t.length)return;let r=document.createElement(`span`);r.setAttribute(`aria-hidden`,`true`),Object.assign(r.style,{position:`absolute`,inset:`0`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`inherit`,pointerEvents:`none`,whiteSpace:`nowrap`}),r.append(...t),e.element.append(r);let i=A(n,()=>{X(e),An(e)});e.old={element:r,spring:i},i.to(0,{tween:fn})}function Rn(e){return e.mode===`clip`?[...e.element.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.cloneNode()):Dn(e).map(e=>{let t=e.cloneNode(!0);return t.style.removeProperty(`scale`),t.style.removeProperty(`opacity`),t.style.removeProperty(`filter`),t})}function zn(e,t){let n=t.trigger?.getBoundingClientRect(),r=Sn(e),i=jn(e,r,n);t.box=i,t.text=On(i),t.label=Rn(i),P(e,{opacity:null});let a=i.handoff&&J&&Fn(J,i)?J:void 0;if(a&&(J=void 0),C())a&&Bn(a,!0),i.fade.set(0),i.holding=!1,i.fade.to(1,{tween:mn});else if(a){let e=Rn(a),t={x:[a.x.value,a.x.velocity],y:[a.y.value,a.y.velocity],width:[a.width.value,a.width.velocity]},n=a.old?0:a.label.value;Nn(a),i.x.set(t.x[0]),i.y.set(t.y[0]),i.width.set(t.width[0]),i.label.set(0),Ln(i,e,n),i.x.to(r.left+r.width/2,{preset:W,velocity:t.x[1]}),i.y.to(r.top+r.height/2,{preset:W,velocity:t.y[1]}),i.width.to(r.width,{preset:G,velocity:t.width[1]}),Z(i,cn,()=>i.label.to(1,{tween:dn})),i.holding=!1,X(i)}else In(i).set(En(i)),i.width.set(Math.min(an,r.width)),i.label.set(0),X(i),In(i).to(Tn(i.side)?r.top+r.height/2:r.left+r.width/2,{preset:rn}),Z(i,on,()=>{i.width.to(r.width,{preset:G}),Z(i,sn,()=>i.label.to(1,{tween:dn}))}),i.holding=!1}function Bn(e,t){hn.add(e),e.holding=!1,t?(e.done=()=>Nn(e),e.fade.to(0,{tween:mn})):(e.handoff&&(J=e),e.old&&e.old.spring.to(0,{tween:pn}),e.label.to(0,{tween:pn}),e.width.to(Math.min(an,e.rest.width),{preset:G}),Z(e,ln,()=>{J===e&&(J=void 0),In(e).to(En(e),{preset:rn})}),Z(e,un,()=>Nn(e)))}function Vn(e,t){if(!t.open)return;t.open=!1,q.delete(e),t.stopWatch?.(),t.stopWatch=void 0,q.size||Qn();let n=t.box;if(t.box=void 0,P(e,{opacity:null}),!n)return;let r=t.root.parentNode??t.parent,i=r?.isConnected?en(t.root,r,t.root.isConnected?t.root.nextSibling:t.next):void 0,a={x:n.x,y:n.y,width:n.width,label:n.label,fade:n.fade},o=Object.fromEntries(Object.entries(a).map(([e,t])=>[e,[t.value,t.velocity]])),s=n.old?.spring.value;Mn(n),n.old?.element.remove(),P(e,{translate:null,scale:null,"clip-path":null,opacity:null});for(let e of Dn(n))P(e,{scale:null,opacity:null,filter:null});if(!i)return;let c=Hn(t.root,e).reduce((e,t)=>e?.children[t],i);if(!(c instanceof HTMLElement)){i.remove();return}e.hasAttribute(`popover`)&&(P(c,{scale:null}),tn(c,n.rest));let l=jn(c,n.rest,void 0);Object.assign(l,{side:n.side,edge:n.edge,trigger:n.trigger,mode:n.mode,origin:n.origin,radius:n.radius,handoff:n.handoff});let u=c.querySelector(`:scope > [aria-hidden=true][style*=absolute]`);s!==void 0&&u&&(l.old={element:u,spring:A(s,()=>X(l))});for(let e of[`x`,`y`,`width`,`label`,`fade`])l[e].set(o[e][0]);X(l);for(let e of[`x`,`y`,`width`])o[e][1]&&l[e].to(o[e][0],{velocity:o[e][1]});Bn(l,C())}function Hn(e,t){let n=[];for(let r=t;r!==e&&r.parentElement;r=r.parentElement)n.unshift([...r.parentElement.children].indexOf(r));return n}function Un(e,t,n,r=20){requestAnimationFrame(()=>{if(!t.open||!e.isConnected)return;let i=e.closest(`[data-reka-popper-content-wrapper]`);if(r>0&&i?.style.transform.includes(`-200%`))return Un(e,t,n,r-1);n()})}function Wn(e,t){let n=()=>{r.disconnect();let t=e;for(;t;){let e=t.parentNode;e&&r.observe(e,{childList:!0}),t=e??(t instanceof ShadowRoot?t.host:null)}},r=new MutationObserver(()=>{e.isConnected?(t.parent=t.root.parentNode,t.next=t.root.nextSibling,n()):Vn(e,t)});return n(),()=>r.disconnect()}function Gn(e){let t=K.get(e);if(t?.open)return;let n=xn(e);if(n&&j(n))return;let r=e.closest(`[data-reka-popper-content-wrapper]`)??e;t={open:!0,root:r,parent:r.parentNode,next:r.nextSibling,text:``,label:[],trigger:n},K.set(e,t),q.add(e),Zn(),P(e,{opacity:`0`}),t.stopWatch=Wn(e,t);let i=t;Un(e,t,()=>zn(e,i))}var Kn=0;function qn(){Kn=0;for(let e of q){let t=K.get(e),n=t?.box;if(!t||!n)continue;let r=Sn(e),i=On(n);if(!(Math.abs(r.left-n.rest.left)>1||Math.abs(r.top-n.rest.top)>1||Math.abs(r.width-n.rest.width)>1)&&i===t.text)continue;let a=i===t.text?[]:t.label;t.trigger=xn(e)??t.trigger;let o=t.trigger?.getBoundingClientRect();t.text=i,t.label=Rn(n),n.rest=r,n.side=Cn(e,r,o),n.edge=wn(n.side,r,o),C()?(n.x.set(r.left+r.width/2),n.y.set(r.top+r.height/2),n.width.set(r.width)):(n.x.to(r.left+r.width/2,{preset:W}),n.y.to(r.top+r.height/2,{preset:W}),n.width.to(r.width,{preset:G}),a.length&&(n.old?.spring.stop(),n.old?.element.remove(),Ln(n,a,n.label.value),n.label.set(0),Z(n,cn,()=>n.label.to(1,{tween:dn}))))}}function Jn(){Kn||=requestAnimationFrame(qn)}var Yn=!1,Xn;function Zn(){Xn??=w(Pn),Yn||(Yn=!0,document.addEventListener(`pointerover`,Jn,{capture:!0,passive:!0}),document.addEventListener(`focusin`,Jn,{capture:!0,passive:!0}))}function Qn(){Yn=!1,cancelAnimationFrame(Kn),Kn=0,document.removeEventListener(`pointerover`,Jn,{capture:!0}),document.removeEventListener(`focusin`,Jn,{capture:!0})}var $n={enter(e){yn(e)===e&&bn(e)&&Gn(e)},state(e){if(yn(e)!==e)return;let t=K.get(e);bn(e)?Gn(e):t&&Vn(e,t)}};({...$n});var er={name:`appear`,selector:vn,...$n},tr=`
|
|
81
81
|
:host{all:initial;--surface:light-dark(#fff,#0a0a0a);--text:light-dark(#18181b,#fafafa);--muted:light-dark(#71717a,#a1a1aa);--line:light-dark(rgb(0 0 0/8%),rgb(255 255 255/9%));--hover:light-dark(rgb(0 0 0/5%),rgb(255 255 255/7%));--focus:light-dark(#18181b,#fafafa);--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--at:50;--margin:16px;--start:max(var(--margin),var(--safe-left));--end:max(var(--margin),var(--safe-right));--far:max(16px,var(--safe-top));--along:calc(var(--start) + (100% - var(--start) - var(--end)) * var(--at) / 100);--shift:calc(var(--at) * -1%);--dock:calc(max(var(--margin),var(--safe-bottom)) + var(--thickness,38px) + 8px);--width:calc(100vw - var(--start) - var(--end));--height:calc(100dvh - var(--dock) - var(--far));position:fixed;inset:0;z-index:2147483000;pointer-events:none;color:var(--text);font:400 .875rem/1.5 system-ui,sans-serif;color-scheme:light dark}
|
|
82
82
|
:host([collapsed]){--margin:2px}
|
|
83
83
|
:host([edge=top]){--dock:calc(max(var(--margin),var(--safe-top)) + var(--thickness,38px) + 8px);--far:max(16px,var(--safe-bottom))}
|
|
@@ -123,4 +123,4 @@ svg{display:block;width:100%;height:100%;overflow:visible;fill:rgb(17 17 17/92%)
|
|
|
123
123
|
:host([off][dragging]) svg{scale:none}
|
|
124
124
|
@media(hover:hover){:host([off]) button:hover{opacity:1;background:none}button:hover svg{fill:rgb(38 38 38/94%)}}
|
|
125
125
|
@media(any-pointer:coarse){:host([off]){--vitehub-hex-h:20px}:host([off]) button{min-width:0;height:var(--vitehub-hex-h)}:host([off]) button::before{inset:-10px}}
|
|
126
|
-
@media(prefers-reduced-motion:reduce){:host([off]) button,svg{transition:none}}`,dr=`vitehub-tools-off`,fr=`vitehub-tools-collapsed`,pr=`vitehub-tools-dock`,mr=`vitehub-account`,hr=`M19.734 8.156 15.576.844A1.66 1.66 0 0 0 14.135 0H5.819C5.226 0 4.677.32 4.38.844L.222 8.156a1.71 1.71 0 0 0 0 1.688l4.158 7.312c.297.523.846.844 1.439.844h8.316c.593 0 1.142-.32 1.438-.844l4.158-7.312c.3-.523.3-1.165.003-1.688Z`;function gr(e){try{return localStorage.getItem(e)===`1`}catch{return!1}}function _r(e,t){try{t?localStorage.setItem(e,`1`):localStorage.removeItem(e)}catch{}}function vr(){return document.documentElement.getAttribute(`data-vitehub-pill`)===`mark`||yr}var yr=!1,br=!1;function xr(){try{return localStorage.getItem(pr)}catch{return null}}function Sr(){if(br||typeof document.elementsFromPoint!=`function`)return!1;let e=e=>{let t=e.getBoundingClientRect();return t.width*t.height<innerWidth*innerHeight/2},t=Array.from({length:36},(e,t)=>[Math.min(innerWidth-1,Math.max(0,innerWidth/2-140+t%18*16+8)),innerHeight-(t<18?24:44)]),n=new Set;for(let[r,i]of t)for(let t of document.elementsFromPoint(r,i))if(!n.has(t)){n.add(t);for(let n=t;n&&n!==document.body&&n!==document.documentElement&&!n.localName.startsWith(`vitehub-`);n=n.parentElement){let r=getComputedStyle(n);if(r.position===`fixed`||r.position===`sticky`&&r.bottom!==`auto`){if(e(n)||n!==t&&e(t))return!0;break}if(/auto|scroll/.test(r.overflowY)&&n.scrollHeight>n.clientHeight)break}}return!1}function Cr(e){return e.edge===`bottom`?{edge:`bottom`,at:e.at<50?0:100}:e}function wr(e,t){let n=vr(),r=xr(),i=()=>{br||=xr()!==r;let t=yr;if(yr=Sr(),t&&!yr&&br&&document.querySelector(`vitehub-pill`)?.hasAttribute(`collapsed`))try{localStorage.setItem(fr,`1`)}catch{}vr()!==n&&(n=!n,e())},a=new MutationObserver(i);a.observe(document.documentElement,{attributes:!0,attributeFilter:[o]});let s,c=()=>{s??=setTimeout(()=>{s=void 0,i()},200)},l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.localName.startsWith(`vitehub-`)))&&c()});l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`class`,`style`]}),addEventListener(`scroll`,c,{capture:!0,passive:!0,signal:t}),addEventListener(`resize`,c,{signal:t}),addEventListener(`storage`,e=>{(e.key===null||e.key===pr)&&(r=xr()),c()},{signal:t}),document.addEventListener(`pointerup`,c,{signal:t}),t.addEventListener(`abort`,()=>{a.disconnect(),l.disconnect(),clearTimeout(s)},{once:!0})}var $={name:`vitehub-pill`,label:`ViteHub tools`,off:dr,collapsed:fr,dock:pr};function Tr(e,t,n,r,i){if(t.aborted)return;let a=document.createElement(e.off);a.setAttribute(`off`,``),a.setAttribute(`collapsed`,``),i&&a.setAttribute(`closing`,``),a.style.viewTransitionName=e.name;let o=Ot(e.dock)??e.initialDock??{edge:`bottom`,at:50},s=()=>{let t=e===$&&vr()&&!a.hasAttribute(`dragging`)?Cr(o):o;a.setAttribute(`edge`,t.edge),a.style.setProperty(`--at`,String(t.at))};s();let c=new AbortController;t.addEventListener(`abort`,()=>{c.abort(),a.remove()},{once:!0,signal:c.signal}),e===$&&wr(s,c.signal);let l=a.attachShadow({mode:`open`}),u=B(l,H);c.signal.addEventListener(`abort`,u,{once:!0});let d=document.createElement(`style`);d.textContent=`${Ct}\n${ur}`;let f=document.createElement(`button`);if(f.type=`button`,f.title=`Turn on ${e.label}`,f.setAttribute(`aria-label`,f.title),f.append(wt(`0 0 20 18`,hr,{})),l.append(d,f),document.documentElement.append(a),i){let e=i/U(a).height,t=A(e,(e,t)=>{let n=t===0&&e===1;P(f,{scale:n?null:e.toFixed(4)}),n&&a.removeAttribute(`closing`)},T.snappy);t.set(e),t.to(1,{preset:T.snappy})}let p=It({host:a,handle:f,dock:()=>o,shape:e=>{let t=e?a.offsetHeight:a.offsetWidth,n=U(a);return{size:t,lead:t/2,part:e?n.height:n.width,margin:2}},place:e=>{o=e,s()},drop:()=>{s();try{localStorage.setItem(e.dock,JSON.stringify(o))}catch{}},signal:c.signal});f.addEventListener(`click`,()=>{p()||(c.abort(),a.remove(),n())}),r&&f.focus({preventScroll:!0})}async function Er(e={}){return await kr(e,!1)}var Dr=new AbortController;function Or(){Dr.abort(),Dr=new AbortController}async function kr(n,o){let s=new URLSearchParams(location.search),c=typeof n.session==`function`?n.session:void 0,l=typeof n.session==`string`?n.session:a(import.meta.url);if(!c&&!i(location.search,document.cookie))return[];let{signal:u}=Dr,d=n.pill??$;d===$&&(br=Ot(pr)!==void 0,yr=Sr());let f=n.load??(e=>import(e)),p;try{if(c)p=await c();else{let e=new URL(l,location.href);e.searchParams.set(`page`,location.pathname);let t=await fetch(e.origin===location.origin?`${e.pathname}${e.search}`:e.href,{credentials:`same-origin`,headers:{accept:`application/json`}});if(!t.ok)return[];p=r(await t.json())}}catch{return[]}if(u.aborted||p.tools.length===0||document.querySelector(`${d.name}, ${d.off}`))return[];let m=p.tools.find(e=>e.param&&s.has(e.param));if(s.has(`vitehub`)||m||n.open)_r(d.off,!1);else if(gr(d.off))return Tr(d,u,()=>{_r(d.off,!1),kr(n,!0)},!1),[];let h=n.open||s.get(`vitehub`)||m?.id,g=p.tools.some(e=>e.id===h),_=new AbortController,v=p.tools.map(()=>new AbortController);u.addEventListener(`abort`,()=>{for(let e of v)e.abort();_.abort()},{once:!0,signal:_.signal});let y=new Set,b=!1,x=()=>!b&&[...y].every(e=>e()),S=(t=!1)=>{if(!x())return;b=!0;let r=p.tools.filter(e=>ee(e.id));for(let e of p.tools)D(e.id,!1);_r(d.off,!0);let i=new URL(location.href);(d===$||p.tools.some(e=>e.id===i.searchParams.get(`vitehub`)))&&i.searchParams.delete(e);for(let e of p.tools)e.param&&i.searchParams.delete(e.param);i.href!==location.href&&history.replaceState(history.state,``,i);let a=U(w).height,o=Ft(w);for(let e of v)e.abort();o.then(()=>{_.abort(),Tr(d,u,()=>{_r(d.off,!1);for(let e of r)D(e.id,!0);kr(n,!0)},t,a&&!matchMedia(`(prefers-reduced-motion: reduce)`).matches?a:void 0)})},C=p.account,w=Pt({name:d.name,label:d.label,mark:wt(`0 0 20 18`,hr,{fill:`currentColor`}),slots:[...p.tools.map(e=>e.id),...p.account?[mr]:[]],storage:{collapsed:d.collapsed,dock:d.dock},...d.initialDock?{initial:{dock:d.initialDock}}:{},exit:{label:`Turn off ${d.label}`,press:S,...C&&!C.guest?{menu:e=>Jt({account:C,button:e,turnOff:{label:`Turn off ${d.label}`,press:S},canExit:x,signal:_.signal})}:{}},onPlace:or,...d===$?{markOnly:{active:vr,watch:wr,opened:o}}:{},signal:_.signal});if(_.signal.addEventListener(`abort`,B(w,{effects:[nt,er]}),{once:!0}),p.account){let e=document.createElement(`vitehub-account`);e.slot=mr,w.append(e),qt({account:p.account,bar:e,mark:hr,openConsole:()=>{let e=w.querySelector(`vitehub-tool[slot="console"]`);return e&&!e.hidden?()=>void O(`console`):void 0},signal:_.signal})}let T=new Map,E=e=>`vitehub-open:${n.pill?.name??l}:${e}`,D=(e,t)=>{try{sessionStorage.setItem(E(e),String(t))}catch{}},ee=e=>{try{return sessionStorage.getItem(E(e))===`true`}catch{return!1}},te=new Map,O=async(e,t)=>await te.get(e)?.(t)??!1,k=(await Promise.all(p.tools.map(async(e,n)=>{let{signal:r}=v[n],i=document.createElement(`vitehub-tool`);i.slot=e.id,w.append(i);let a,o,s,c=()=>(s||(s=f(e.script),s.catch(()=>{s=void 0})),s),l=!1,u=()=>{let t=document.createElement(`vitehub-tool`);t.slot=e.id,i.replaceWith(t),i=t},d=()=>{let e=i.attachShadow({mode:`open`}),n=B(e,H);r.addEventListener(`abort`,n,{once:!0});let a=document.createElement(`style`);a.textContent=t,e.append(a,m)},p=(t,n=!0)=>r.aborted?Promise.resolve(!1):l?(a?.(t),Promise.resolve(!0)):o?o.then(e=>(e&&a?.(t),e)):(o=(async()=>{let s=new AbortController,f=()=>s.abort();r.addEventListener(`abort`,f,{once:!0});try{i.setAttribute(`aria-busy`,`true`);let o=lr(await c());if($t(o,`the script of a page tool default-exports a function (${e.script})`),r.aborted)return!1;m.remove(),i.shadowRoot?u():i.replaceChildren();let d=o({beforeExit:e=>{let t=()=>e();y.add(t),s.signal.addEventListener(`abort`,()=>y.delete(t),{once:!0})},tool:e,bar:i,signal:s.signal,open:n&&(e.lazy===!0||e.id===h||ee(e.id)),exit:()=>S(),createWindow:t=>{let n=cr({...t,signal:s.signal,onHide:()=>{D(e.id,!1),w.hasAttribute(`collapsed`)&&w.shadowRoot.querySelector(`button.mark`).focus({preventScroll:!0}),t.onHide?.()}}),r={...n,show(){if(!s.signal.aborted){for(let[t,n]of T)t!==e.id&&n.hide();D(e.id,!0),n.show()}},destroy(){T.get(e.id)===r&&(T.delete(e.id),D(e.id,!1)),n.destroy()}};return T.set(e.id,r),r},openTool:O,createTab:()=>{let e=document.createElement(`vitehub-tab`);return e.slot=`tab`,e.setAttribute(`data-motion-appear`,`vitehub-pill`),w.append(e),s.signal.addEventListener(`abort`,()=>e.remove(),{once:!0}),e},onOpen:e=>{a=e}});return l=!0,t&&a?.(t),!i.shadowRoot&&!i.hasChildNodes()&&(i.hidden=!0),d instanceof Function&&(r.aborted?d():s.signal.addEventListener(`abort`,()=>d(),{once:!0})),!r.aborted}catch(t){return s.abort(),r.removeEventListener(`abort`,f),T.delete(e.id)&&D(e.id,!1),a=void 0,l=!1,console.error(`[vitehub] The page tool "${e.id}" did not start.`,t),u(),m.textContent=`Retry ${e.label}`,m.title=`The tool could not load. Try again.`,i.hidden=!1,d(),!1}finally{i.removeAttribute(`aria-busy`),o=void 0}})(),o),m=document.createElement(`button`);m.type=`button`,m.textContent=e.label,m.addEventListener(`click`,()=>void p());for(let e of[`pointerenter`,`pointerdown`,`focus`])m.addEventListener(e,()=>void c());return te.set(e.id,p),e.lazy&&e.id!==h&&!ee(e.id)?(d(),e):(await p(void 0,!g||e.id===h),r.aborted?void 0:e)}))).filter(e=>!!e);return k.length===0&&_.abort(),k}function Ar(e={}){let t=m(e),n=()=>encodeURIComponent(typeof e.page==`function`?e.page():e.page??location.pathname),r=e=>({method:`POST`,...e===void 0?{}:{body:JSON.stringify(e)}}),i=e=>encodeURIComponent(e),a=new Map;return{status:async()=>(await t(`/send/status?page=${n()}`)).data,startPairing:async()=>{let e=n(),i=(await t(`/send/start?page=${e}`,r())).data;return a.set(i.code,e),i},pollPairing:async e=>(await t(`/send/pair/${i(e)}`)).data,allow:async(e,i)=>{let o=a.get(e)??n(),s=(await t(`/send/allow?page=${o}`,r({code:e,selection:i}))).data;return s.status!==`changed`&&a.delete(e),s},cancel:async e=>{a.delete(e),await t(`/send/pair/${i(e)}`,{method:`DELETE`})},send:async()=>(await t(`/send?page=${n()}`,r())).data}}var jr=`vitehub-comments-guest`,Mr=d(import.meta.url);function Nr(){try{let e=JSON.parse(localStorage.getItem(jr)??`null`);if(e&&typeof e==`object`&&`id`in e&&`name`in e&&typeof e.id==`string`&&typeof e.name==`string`)return{id:e.id,name:e.name}}catch{}}function Pr(e){let t={id:Nr()?.id??crypto.randomUUID(),name:e};return localStorage.setItem(jr,JSON.stringify(t)),t}var Fr=m({route:Mr,guest:Nr});function Ir(e){if(e instanceof c)return{code:e.code,why:e.message,...e.fix?{fix:e.fix}:{}};throw e}async function Lr(e,t={}){try{return[void 0,(await Fr(e,t)).data]}catch(e){return[Ir(e),void 0]}}var Rr;function zr(e){Rr=e}var Br=e=>({method:`POST`,body:JSON.stringify(e)}),Vr={session:e=>Rr?Rr.session(e):Lr(`/session?page=${encodeURIComponent(e)}`),field:(e,t)=>Lr(`/fields?page=${encodeURIComponent(t)}&field=${encodeURIComponent(e)}`),saveField:(e,t)=>Lr(`/fields?page=${encodeURIComponent(t)}`,Br(e))};function Hr(e){let t=t=>t.people.length&&e.onPeople(t.people),n=Rr?Rr.transport(t):f({base:Mr.slice(0,-p.length),guest:Nr,onAnswer:t}),r=t=>async(...n)=>{let r=await t(...n);return e.onChange(),r};return{...n,create:r(t=>{let r=e.contextOf(t),i=t.revision??e.revisionOf?.();return n.create({...t,...r?{context:r}:{},...i===void 0?{}:{revision:i}})}),reply:r(n.reply),edit:r(n.edit),delete:r(n.delete),resolve:r(n.resolve),reopen:r(n.reopen)}}function Ur(e){return Ar({base:Mr.slice(0,-p.length),page:e})}var Wr=g({mountHostedComments:()=>Jr}),Gr={tools:[{id:`comments`,label:`Comments`,icon:`i-lucide-message-square-text`,script:`comments`,param:`comment`}]};function Kr(){return Promise.reject(u(405))}function qr(e){return{async session(t){try{return[void 0,(await(await e).call(`session`,t)).value]}catch(e){return[Ir(e),void 0]}},transport(t){let n=async(n,r)=>{let i=await(await e).call(n,r);return t({data:i.value,people:i.people}),i.value};return{list:e=>n(`list`,e),get:e=>n(`get`,e),create:({files:e,outbox:t,...r})=>n(`create`,r),reply:({files:e,outbox:t,...r})=>n(`reply`,r),resolve:e=>n(`resolve`,{threadId:e.threadId}),reopen:e=>n(`reopen`,{threadId:e.threadId}),edit:Kr,delete:Kr,users:async()=>[],upload:Kr,attachmentUrl:()=>``}}}}async function Jr(e,t=!1){t&&Or(),zr(qr(e)),await Er({pill:{name:`vitehub-hosted-comments-pill`,label:`ViteHub Comments`,off:`vitehub-hosted-comments-off`,collapsed:`vitehub-hosted-comments-collapsed`,dock:`vitehub-hosted-comments-dock`,initialDock:{edge:`right`,at:85}},...t?{open:`comments`}:{},session:async()=>Gr,load:()=>s(()=>import(`./overlay-4-mWX4Uz.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)})}export{Nr as a,Hr as i,Jr as mountHostedComments,Vr as n,Pr as o,Ur as r,g as s,Wr as t};
|
|
126
|
+
@media(prefers-reduced-motion:reduce){:host([off]) button,svg{transition:none}}`,dr=`vitehub-tools-off`,fr=`vitehub-tools-collapsed`,pr=`vitehub-tools-dock`,mr=`vitehub-account`,hr=`M19.734 8.156 15.576.844A1.66 1.66 0 0 0 14.135 0H5.819C5.226 0 4.677.32 4.38.844L.222 8.156a1.71 1.71 0 0 0 0 1.688l4.158 7.312c.297.523.846.844 1.439.844h8.316c.593 0 1.142-.32 1.438-.844l4.158-7.312c.3-.523.3-1.165.003-1.688Z`;function gr(e){try{return localStorage.getItem(e)===`1`}catch{return!1}}function _r(e,t){try{t?localStorage.setItem(e,`1`):localStorage.removeItem(e)}catch{}}function vr(){return document.documentElement.getAttribute(`data-vitehub-pill`)===`mark`||yr}var yr=!1,br=!1;function xr(){try{return localStorage.getItem(pr)}catch{return null}}function Sr(){if(br||typeof document.elementsFromPoint!=`function`)return!1;let e=e=>{let t=e.getBoundingClientRect();return t.width*t.height<innerWidth*innerHeight/2},t=Array.from({length:36},(e,t)=>[Math.min(innerWidth-1,Math.max(0,innerWidth/2-140+t%18*16+8)),innerHeight-(t<18?24:44)]),n=new Set;for(let[r,i]of t)for(let t of document.elementsFromPoint(r,i))if(!n.has(t)){n.add(t);for(let n=t;n&&n!==document.body&&n!==document.documentElement&&!n.localName.startsWith(`vitehub-`);n=n.parentElement){let r=getComputedStyle(n);if(r.position===`fixed`||r.position===`sticky`&&r.bottom!==`auto`){if(e(n)||n!==t&&e(t))return!0;break}if(/auto|scroll/.test(r.overflowY)&&n.scrollHeight>n.clientHeight)break}}return!1}function Cr(e){return e.edge===`bottom`?{edge:`bottom`,at:e.at<50?0:100}:e}function wr(e,t){let n=vr(),r=xr(),i=()=>{br||=xr()!==r;let t=yr;if(yr=Sr(),t&&!yr&&br&&document.querySelector(`vitehub-pill`)?.hasAttribute(`collapsed`))try{localStorage.setItem(fr,`1`)}catch{}vr()!==n&&(n=!n,e())},a=new MutationObserver(i);a.observe(document.documentElement,{attributes:!0,attributeFilter:[o]});let s,c=()=>{s??=setTimeout(()=>{s=void 0,i()},200)},l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.localName.startsWith(`vitehub-`)))&&c()});l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`class`,`style`]}),addEventListener(`scroll`,c,{capture:!0,passive:!0,signal:t}),addEventListener(`resize`,c,{signal:t}),addEventListener(`storage`,e=>{(e.key===null||e.key===pr)&&(r=xr()),c()},{signal:t}),document.addEventListener(`pointerup`,c,{signal:t}),t.addEventListener(`abort`,()=>{a.disconnect(),l.disconnect(),clearTimeout(s)},{once:!0})}var $={name:`vitehub-pill`,label:`ViteHub tools`,off:dr,collapsed:fr,dock:pr};function Tr(e,t,n,r,i){if(t.aborted)return;let a=document.createElement(e.off);a.setAttribute(`off`,``),a.setAttribute(`collapsed`,``),i&&a.setAttribute(`closing`,``),a.style.viewTransitionName=e.name;let o=Ot(e.dock)??e.initialDock??{edge:`bottom`,at:50},s=()=>{let t=e===$&&vr()&&!a.hasAttribute(`dragging`)?Cr(o):o;a.setAttribute(`edge`,t.edge),a.style.setProperty(`--at`,String(t.at))};s();let c=new AbortController;t.addEventListener(`abort`,()=>{c.abort(),a.remove()},{once:!0,signal:c.signal}),e===$&&wr(s,c.signal);let l=a.attachShadow({mode:`open`}),u=B(l,H);c.signal.addEventListener(`abort`,u,{once:!0});let d=document.createElement(`style`);d.textContent=`${Ct}\n${ur}`;let f=document.createElement(`button`);if(f.type=`button`,f.title=`Turn on ${e.label}`,f.setAttribute(`aria-label`,f.title),f.append(wt(`0 0 20 18`,hr,{})),l.append(d,f),document.documentElement.append(a),i){let e=i/U(a).height,t=A(e,(e,t)=>{let n=t===0&&e===1;P(f,{scale:n?null:e.toFixed(4)}),n&&a.removeAttribute(`closing`)},T.snappy);t.set(e),t.to(1,{preset:T.snappy})}let p=It({host:a,handle:f,dock:()=>o,shape:e=>{let t=e?a.offsetHeight:a.offsetWidth,n=U(a);return{size:t,lead:t/2,part:e?n.height:n.width,margin:2}},place:e=>{o=e,s()},drop:()=>{s();try{localStorage.setItem(e.dock,JSON.stringify(o))}catch{}},signal:c.signal});f.addEventListener(`click`,()=>{p()||(c.abort(),a.remove(),n())}),r&&f.focus({preventScroll:!0})}async function Er(e={}){return await kr(e,!1)}var Dr=new AbortController;function Or(){Dr.abort(),Dr=new AbortController}async function kr(n,o){let s=new URLSearchParams(location.search),c=typeof n.session==`function`?n.session:void 0,l=typeof n.session==`string`?n.session:a(import.meta.url);if(!c&&!i(location.search,document.cookie))return[];let{signal:u}=Dr,d=n.pill??$;d===$&&(br=Ot(pr)!==void 0,yr=Sr());let f=n.load??(e=>import(e)),p;try{if(c)p=await c();else{let e=new URL(l,location.href);e.searchParams.set(`page`,location.pathname);let t=await fetch(e.origin===location.origin?`${e.pathname}${e.search}`:e.href,{credentials:`same-origin`,headers:{accept:`application/json`}});if(!t.ok)return[];p=r(await t.json())}}catch{return[]}if(u.aborted||p.tools.length===0||document.querySelector(`${d.name}, ${d.off}`))return[];let m=p.tools.find(e=>e.param&&s.has(e.param));if(s.has(`vitehub`)||m||n.open)_r(d.off,!1);else if(gr(d.off))return Tr(d,u,()=>{_r(d.off,!1),kr(n,!0)},!1),[];let h=n.open||s.get(`vitehub`)||m?.id,g=p.tools.some(e=>e.id===h),_=new AbortController,v=p.tools.map(()=>new AbortController);u.addEventListener(`abort`,()=>{for(let e of v)e.abort();_.abort()},{once:!0,signal:_.signal});let y=new Set,b=!1,x=()=>!b&&[...y].every(e=>e()),S=(t=!1)=>{if(!x())return;b=!0;let r=p.tools.filter(e=>ee(e.id));for(let e of p.tools)D(e.id,!1);_r(d.off,!0);let i=new URL(location.href);(d===$||p.tools.some(e=>e.id===i.searchParams.get(`vitehub`)))&&i.searchParams.delete(e);for(let e of p.tools)e.param&&i.searchParams.delete(e.param);i.href!==location.href&&history.replaceState(history.state,``,i);let a=U(w).height,o=Ft(w);for(let e of v)e.abort();o.then(()=>{_.abort(),Tr(d,u,()=>{_r(d.off,!1);for(let e of r)D(e.id,!0);kr(n,!0)},t,a&&!matchMedia(`(prefers-reduced-motion: reduce)`).matches?a:void 0)})},C=p.account,w=Pt({name:d.name,label:d.label,mark:wt(`0 0 20 18`,hr,{fill:`currentColor`}),slots:[...p.tools.map(e=>e.id),...p.account?[mr]:[]],storage:{collapsed:d.collapsed,dock:d.dock},...d.initialDock?{initial:{dock:d.initialDock}}:{},exit:{label:`Turn off ${d.label}`,press:S,...C&&!C.guest?{menu:e=>Jt({account:C,button:e,turnOff:{label:`Turn off ${d.label}`,press:S},canExit:x,signal:_.signal})}:{}},onPlace:or,...d===$?{markOnly:{active:vr,watch:wr,opened:o}}:{},signal:_.signal});if(_.signal.addEventListener(`abort`,B(w,{effects:[nt,er]}),{once:!0}),p.account){let e=document.createElement(`vitehub-account`);e.slot=mr,w.append(e),qt({account:p.account,bar:e,mark:hr,openConsole:()=>{let e=w.querySelector(`vitehub-tool[slot="console"]`);return e&&!e.hidden?()=>void O(`console`):void 0},signal:_.signal})}let T=new Map,E=e=>`vitehub-open:${n.pill?.name??l}:${e}`,D=(e,t)=>{try{sessionStorage.setItem(E(e),String(t))}catch{}},ee=e=>{try{return sessionStorage.getItem(E(e))===`true`}catch{return!1}},te=new Map,O=async(e,t)=>await te.get(e)?.(t)??!1,k=(await Promise.all(p.tools.map(async(e,n)=>{let{signal:r}=v[n],i=document.createElement(`vitehub-tool`);i.slot=e.id,w.append(i);let a,o,s,c=()=>(s||(s=f(e.script),s.catch(()=>{s=void 0})),s),l=!1,u=()=>{let t=document.createElement(`vitehub-tool`);t.slot=e.id,i.replaceWith(t),i=t},d=()=>{let e=i.attachShadow({mode:`open`}),n=B(e,H);r.addEventListener(`abort`,n,{once:!0});let a=document.createElement(`style`);a.textContent=t,e.append(a,m)},p=(t,n=!0)=>r.aborted?Promise.resolve(!1):l?(a?.(t),Promise.resolve(!0)):o?o.then(e=>(e&&a?.(t),e)):(o=(async()=>{let s=new AbortController,f=()=>s.abort();r.addEventListener(`abort`,f,{once:!0});try{i.setAttribute(`aria-busy`,`true`);let o=lr(await c());if($t(o,`the script of a page tool default-exports a function (${e.script})`),r.aborted)return!1;m.remove(),i.shadowRoot?u():i.replaceChildren();let d=o({beforeExit:e=>{let t=()=>e();y.add(t),s.signal.addEventListener(`abort`,()=>y.delete(t),{once:!0})},tool:e,bar:i,signal:s.signal,open:n&&(e.lazy===!0||e.id===h||ee(e.id)),exit:()=>S(),createWindow:t=>{let n=cr({...t,signal:s.signal,onHide:()=>{D(e.id,!1),w.hasAttribute(`collapsed`)&&w.shadowRoot.querySelector(`button.mark`).focus({preventScroll:!0}),t.onHide?.()}}),r={...n,show(){if(!s.signal.aborted){for(let[t,n]of T)t!==e.id&&n.hide();D(e.id,!0),n.show()}},destroy(){T.get(e.id)===r&&(T.delete(e.id),D(e.id,!1)),n.destroy()}};return T.set(e.id,r),r},openTool:O,createTab:()=>{let e=document.createElement(`vitehub-tab`);return e.slot=`tab`,e.setAttribute(`data-motion-appear`,`vitehub-pill`),w.append(e),s.signal.addEventListener(`abort`,()=>e.remove(),{once:!0}),e},onOpen:e=>{a=e}});return l=!0,t&&a?.(t),!i.shadowRoot&&!i.hasChildNodes()&&(i.hidden=!0),d instanceof Function&&(r.aborted?d():s.signal.addEventListener(`abort`,()=>d(),{once:!0})),!r.aborted}catch(t){return s.abort(),r.removeEventListener(`abort`,f),T.delete(e.id)&&D(e.id,!1),a=void 0,l=!1,console.error(`[vitehub] The page tool "${e.id}" did not start.`,t),u(),m.textContent=`Retry ${e.label}`,m.title=`The tool could not load. Try again.`,i.hidden=!1,d(),!1}finally{i.removeAttribute(`aria-busy`),o=void 0}})(),o),m=document.createElement(`button`);m.type=`button`,m.textContent=e.label,m.addEventListener(`click`,()=>void p());for(let e of[`pointerenter`,`pointerdown`,`focus`])m.addEventListener(e,()=>void c());return te.set(e.id,p),e.lazy&&e.id!==h&&!ee(e.id)?(d(),e):(await p(void 0,!g||e.id===h),r.aborted?void 0:e)}))).filter(e=>!!e);return k.length===0&&_.abort(),k}function Ar(e={}){let t=m(e),n=()=>encodeURIComponent(typeof e.page==`function`?e.page():e.page??location.pathname),r=e=>({method:`POST`,...e===void 0?{}:{body:JSON.stringify(e)}}),i=e=>encodeURIComponent(e),a=new Map;return{status:async()=>(await t(`/send/status?page=${n()}`)).data,startPairing:async()=>{let e=n(),i=(await t(`/send/start?page=${e}`,r())).data;return a.set(i.code,e),i},pollPairing:async e=>(await t(`/send/pair/${i(e)}`)).data,allow:async(e,i)=>{let o=a.get(e)??n(),s=(await t(`/send/allow?page=${o}`,r({code:e,selection:i}))).data;return s.status!==`changed`&&a.delete(e),s},cancel:async e=>{a.delete(e),await t(`/send/pair/${i(e)}`,{method:`DELETE`})},send:async()=>(await t(`/send?page=${n()}`,r())).data}}var jr=`vitehub-comments-guest`,Mr=d(import.meta.url);function Nr(){try{let e=JSON.parse(localStorage.getItem(jr)??`null`);if(e&&typeof e==`object`&&`id`in e&&`name`in e&&typeof e.id==`string`&&typeof e.name==`string`)return{id:e.id,name:e.name}}catch{}}function Pr(e){let t={id:Nr()?.id??crypto.randomUUID(),name:e};return localStorage.setItem(jr,JSON.stringify(t)),t}var Fr=m({route:Mr,guest:Nr});function Ir(e){if(e instanceof c)return{code:e.code,why:e.message,...e.fix?{fix:e.fix}:{}};throw e}async function Lr(e,t={}){try{return[void 0,(await Fr(e,t)).data]}catch(e){return[Ir(e),void 0]}}var Rr;function zr(e){Rr=e}var Br=e=>({method:`POST`,body:JSON.stringify(e)}),Vr={session:e=>Rr?Rr.session(e):Lr(`/session?page=${encodeURIComponent(e)}`),field:(e,t)=>Lr(`/fields?page=${encodeURIComponent(t)}&field=${encodeURIComponent(e)}`),saveField:(e,t)=>Lr(`/fields?page=${encodeURIComponent(t)}`,Br(e))};function Hr(e){let t=t=>t.people.length&&e.onPeople(t.people),n=Rr?Rr.transport(t):f({base:Mr.slice(0,-p.length),guest:Nr,onAnswer:t}),r=t=>async(...n)=>{let r=await t(...n);return e.onChange(),r};return{...n,create:r(t=>{let r=e.contextOf(t),i=t.revision??e.revisionOf?.();return n.create({...t,...r?{context:r}:{},...i===void 0?{}:{revision:i}})}),reply:r(n.reply),edit:r(n.edit),delete:r(n.delete),resolve:r(n.resolve),reopen:r(n.reopen)}}function Ur(e){return Ar({base:Mr.slice(0,-p.length),page:e})}var Wr=g({mountHostedComments:()=>Jr}),Gr={tools:[{id:`comments`,label:`Comments`,icon:`i-lucide-message-square-text`,script:`comments`,param:`comment`}]};function Kr(){return Promise.reject(u(405))}function qr(e){return{async session(t){try{return[void 0,(await(await e).call(`session`,t)).value]}catch(e){return[Ir(e),void 0]}},transport(t){let n=async(n,r)=>{let i=await(await e).call(n,r);return t({data:i.value,people:i.people}),i.value};return{list:e=>n(`list`,e),get:e=>n(`get`,e),create:({files:e,outbox:t,...r})=>n(`create`,r),reply:({files:e,outbox:t,...r})=>n(`reply`,r),resolve:e=>n(`resolve`,{threadId:e.threadId}),reopen:e=>n(`reopen`,{threadId:e.threadId}),edit:Kr,delete:Kr,users:async()=>[],upload:Kr,attachmentUrl:()=>``}}}}async function Jr(e){Or(),zr(qr(e)),await Er({pill:{name:`vitehub-hosted-comments-pill`,label:`ViteHub Comments`,off:`vitehub-hosted-comments-off`,collapsed:`vitehub-hosted-comments-collapsed`,dock:`vitehub-hosted-comments-dock`,initialDock:{edge:`right`,at:85}},session:async()=>Gr,load:()=>s(()=>import(`./overlay-CFuq5QAH.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)})}export{Nr as a,Hr as i,Jr as mountHostedComments,Vr as n,Pr as o,Ur as r,g as s,Wr as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./hosted-comments/tools-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./hosted-comments/tools-Bz--joZw.js","./hosted-comments/protocol-BHvtQKte.js","./hosted-comments/rest-transport-D-9_pNqZ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,n as t,r as n,s as r,t as i}from"./hosted-comments/protocol-BHvtQKte.js";var a=`vitehub`,o=[`comment`];function s(e,t){let n=new URLSearchParams(e);if(n.has(`vitehub`)||o.some(e=>n.has(e)))return!0;let r=t.split(`;`).map(e=>e.trim());return r.includes(`vitehub-tools=1`)?!0:r.includes(`vitehub_session=1`)&&!r.some(e=>e.startsWith(`vitehub-tools=`))}var c=`/_vitehub/page/assets`,l=`/_vitehub/page/tools`,u=`button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:var(--vitehub-pill-justify,center);gap:4px;min-width:28px;height:28px;padding:0 8px;border-radius:8px;font:inherit;white-space:nowrap;color:var(--vitehub-pill-text);cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition-property:background-color,color;transition-duration:150ms;transition-timing-function:cubic-bezier(.23,1,.32,1)}
|
|
3
3
|
@media(hover:hover){button:where(:not(:disabled):hover){background:var(--vitehub-pill-hover);color:var(--vitehub-pill-strong)}}
|
|
4
4
|
button[aria-pressed=true],button[aria-expanded=true]{background:var(--vitehub-pill-on);color:var(--vitehub-pill-on-text)}
|
|
@@ -6,4 +6,4 @@ button[aria-pressed=true],button[aria-expanded=true]{background:var(--vitehub-pi
|
|
|
6
6
|
button:focus-visible{outline:2px solid var(--vitehub-pill-on);outline-offset:1px}
|
|
7
7
|
button svg{width:14px;height:14px;flex:none}
|
|
8
8
|
@media(any-pointer:coarse){button{min-width:44px;height:44px}}
|
|
9
|
-
@media(prefers-reduced-motion:reduce){button{transition:none}}`,d=`data-vitehub-pill`;function f(e){let t=new URL(e,`http://localhost`).pathname,n=t.lastIndexOf(`${c}/`);return n===-1?l:`${t.slice(0,n)}${l}`}function p(e){return typeof e==`string`&&e?e:void 0}function m(e){if(typeof e!=`object`||!e)return;let t=p(Reflect.get(e,`id`)),n=p(Reflect.get(e,`script`));if(!t||!n)return;let r={id:t,label:p(Reflect.get(e,`label`))??t,icon:p(Reflect.get(e,`icon`))??``,script:n};Reflect.get(e,`lazy`)===!0&&(r.lazy=!0);let i=p(Reflect.get(e,`hotkey`));i&&(r.hotkey=i);let a=p(Reflect.get(e,`param`));return a&&(r.param=a),r}function h(e){if(typeof e!=`object`||!e)return;let t=p(Reflect.get(e,`name`)),n=p(Reflect.get(e,`signOut`));if(!t||!n?.startsWith(`/`)||n.startsWith(`//`)||n.includes(`\\`))return;let r={name:t,signOut:n},i=p(Reflect.get(e,`email`));i&&(r.email=i);let a=p(Reflect.get(e,`image`));return a&&/^https?:\/\//i.test(a)&&(r.image=a),Reflect.get(e,`via`)===`console`&&(r.via=`console`),Reflect.get(e,`guest`)===!0&&(r.guest=!0),r}function g(e){let t=typeof e==`object`&&e?Reflect.get(e,`tools`):void 0,n={tools:Array.isArray(t)?t.map(m).filter(e=>!!e):[]},r=typeof e==`object`&&e?h(Reflect.get(e,`account`)):void 0;return r&&(n.account=r),n}var _=`modulepreload`,v=function(e,t){return new URL(e,t).href},y={},b=function(e){return e.pathname.endsWith(`.css`)},x=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},S=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=v(t,n);let r=s(t),i=b(r);return x(y,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:_,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},C=15e3,w=3e4,T=5e3;function
|
|
9
|
+
@media(prefers-reduced-motion:reduce){button{transition:none}}`,d=`data-vitehub-pill`;function f(e){let t=new URL(e,`http://localhost`).pathname,n=t.lastIndexOf(`${c}/`);return n===-1?l:`${t.slice(0,n)}${l}`}function p(e){return typeof e==`string`&&e?e:void 0}function m(e){if(typeof e!=`object`||!e)return;let t=p(Reflect.get(e,`id`)),n=p(Reflect.get(e,`script`));if(!t||!n)return;let r={id:t,label:p(Reflect.get(e,`label`))??t,icon:p(Reflect.get(e,`icon`))??``,script:n};Reflect.get(e,`lazy`)===!0&&(r.lazy=!0);let i=p(Reflect.get(e,`hotkey`));i&&(r.hotkey=i);let a=p(Reflect.get(e,`param`));return a&&(r.param=a),r}function h(e){if(typeof e!=`object`||!e)return;let t=p(Reflect.get(e,`name`)),n=p(Reflect.get(e,`signOut`));if(!t||!n?.startsWith(`/`)||n.startsWith(`//`)||n.includes(`\\`))return;let r={name:t,signOut:n},i=p(Reflect.get(e,`email`));i&&(r.email=i);let a=p(Reflect.get(e,`image`));return a&&/^https?:\/\//i.test(a)&&(r.image=a),Reflect.get(e,`via`)===`console`&&(r.via=`console`),Reflect.get(e,`guest`)===!0&&(r.guest=!0),r}function g(e){let t=typeof e==`object`&&e?Reflect.get(e,`tools`):void 0,n={tools:Array.isArray(t)?t.map(m).filter(e=>!!e):[]},r=typeof e==`object`&&e?h(Reflect.get(e,`account`)):void 0;return r&&(n.account=r),n}var _=`modulepreload`,v=function(e,t){return new URL(e,t).href},y={},b=function(e){return e.pathname.endsWith(`.css`)},x=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},S=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=v(t,n);let r=s(t),i=b(r);return x(y,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:_,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},C=15e3,w=3e4,T=5e3,E=RegExp(`^#(/?)vhc=([\\w-]+)$`);function D(){let e=E.exec(location.hash);if(!e)return;let[,t,n]=e;return history.replaceState(history.state,``,`${location.pathname}${location.search}${t?`#/`:``}`),n}function O(e){try{return sessionStorage.getItem(e)===`1`}catch{return!1}}function k(e){try{sessionStorage.setItem(e,`1`)}catch{}}function A(i,a){let o=document.createElement(`iframe`);o.src=`${i}${n(a)}`,o.hidden=!0,o.tabIndex=-1,o.title=`ViteHub Comments`,o.setAttribute(`aria-hidden`,`true`),o.setAttribute(`data-comments-ui`,``);let s=new MessageChannel,c=new Map,l=0,u={call:(t,n)=>new Promise((i,a)=>{let o=++l,u=setTimeout(()=>{c.delete(o),a(r(0))},w);c.set(o,t=>{clearTimeout(u),t.ok?i(t):a(e(t.error))}),s.port1.postMessage({id:o,method:t,input:n})})};return new Promise((e,n)=>{let a=setTimeout(()=>n(r(0)),C);s.port1.addEventListener(`message`,({data:t})=>{if(typeof t==`object`&&t){if(Reflect.get(t,`event`)===`ready`)clearTimeout(a),e(u);else{let e=Reflect.get(t,`id`),n=typeof e==`number`?c.get(e):void 0;if(!n||typeof e!=`number`)return;c.delete(e),n(t)}}}),s.port1.start(),o.addEventListener(`load`,()=>o.contentWindow?.postMessage({type:t},i,[s.port2]),{once:!0}),o.addEventListener(`error`,()=>n(r(0)),{once:!0}),document.documentElement.append(o)})}async function j(e,t){return await new Promise(n=>{let r=setTimeout(()=>i(!1),T);function i(t){clearTimeout(r),e.removeEventListener(`message`,a),n(t)}function a({data:e}){e.type===`redeemed`&&e.code===t&&i(!0)}e.addEventListener(`message`,a),e.postMessage({type:`code`,code:t})})}async function M(e,t){let n=D(),r=`vitehub-comments:${e}`;if(!n&&!O(r)&&!s(location.search,document.cookie))return;k(r);let a=new BroadcastChannel(i(e)),o=A(t,e),c=async e=>(await(await o).call(`redeem`,e)).value===!0,l=S(()=>import(`./hosted-comments/tools-Bz--joZw.js`).then(e=>e.t),__vite__mapDeps([0,1,2]),import.meta.url);a.addEventListener(`message`,({data:e})=>{e.type===`code`&&c(e.code).then(t=>{t&&(a.postMessage({type:`redeemed`,code:e.code}),l.then(({mountHostedComments:e})=>e(o)))},()=>void 0)});let u=n?await c(n).catch(()=>!1):!1;if(n&&!u&&await j(a,n)){window.close();return}let{mountHostedComments:d}=await l;await d(o)}var N=document.querySelector(`script[data-vitehub-comments]`)?.dataset.vitehubComments;N&&M(N,new URL(import.meta.url).origin);export{a,u as c,o as i,g as n,s as o,f as r,d as s,S as t};
|
|
@@ -58,7 +58,10 @@ interface CommentSendWebhooks {
|
|
|
58
58
|
address?: string;
|
|
59
59
|
endpointId?: string;
|
|
60
60
|
}) => Promise<Result<EndpointLike | null, string>>;
|
|
61
|
-
|
|
61
|
+
getMemberDelivery: (id: string) => Promise<{
|
|
62
|
+
state: "pending" | "sending" | "sent" | "dead" | "cancelled";
|
|
63
|
+
inbox: boolean;
|
|
64
|
+
} | undefined>;
|
|
62
65
|
sendToMemberEndpoint: (owner: string, body: unknown, options: {
|
|
63
66
|
event: string;
|
|
64
67
|
key: string;
|
|
@@ -170,7 +173,7 @@ interface Comments {
|
|
|
170
173
|
listSends(user: CommentsUser, options?: CommentSendListOptions): Promise<Result<CommentSendView[], Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_SEND_OFF">>>;
|
|
171
174
|
/**
|
|
172
175
|
* With `send`: a send of `user` with the threads that `user` may still read, as `comments_get_send` opens it. A send
|
|
173
|
-
* that reached the agent becomes `working
|
|
176
|
+
* that reached the agent becomes `working`, also while its delivery waits for the receiver's answer.
|
|
174
177
|
*/
|
|
175
178
|
readSend(user: CommentsUser, id: string, policy?: CommentSendPolicy): Promise<Result<CommentSendView, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND" | "COMMENTS_SEND_OFF">>>;
|
|
176
179
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as ElementAnchor, C as CommentStatusInput, D as CommentUser, E as CommentUploadInput, M as PageAnchor, N as TextAnchor, O as CommentUsersInput, S as CommentStatus, T as CommentThread, _ as CommentListCursor, a as CommentBuild, b as CommentMetadata, c as CommentCreateInput, d as CommentDeliveryError, f as CommentEditInput, g as CommentGetInput, h as CommentForgeLink, i as CommentAttachment, j as ImageAnchor, k as CommentsTransport, l as CommentDeleteInput, m as CommentFiles, n as CommentActor, o as CommentComponent, p as CommentEvent, r as CommentAnchor, s as CommentContext, t as AreaAnchor, u as CommentDelivery, v as CommentListQuery, w as CommentSubject, x as CommentReplyInput, y as CommentMessage } from "./types-BX3vH18p.js";
|
|
2
2
|
import { _ as commentsRoleAllows, a as CommentsAttachmentFile, c as CommentsCanMentionContext, d as CommentsPeople, f as CommentsPolicyGate, g as CommentsUser, h as CommentsStoreAttachmentContext, i as CommentSubjectDefinition, l as CommentsDefinition, m as CommentsReadAttachmentContext, n as CommentMentionEvent, o as CommentsAuthorize, p as CommentsRateLimit, r as CommentMessageEvent, s as CommentsAuthorizeContext, t as CommentAction, u as CommentsGitHubAccess, v as defaultPolicy, y as defineCommentSubject } from "./define-B1jLSPe9.js";
|
|
3
3
|
import { _ as ListCommentThreadsOptions, a as CommentSendPromptContext, c as CommentsForgeTarget, d as CommentsPageSubject, f as CommentsRequestEvent, g as FindCommentThreadInput, h as EditCommentInput, i as CommentSendPayloadContext, l as CommentsIdentifyContext, m as DefineCommentsOptions, n as CommentSendData, o as CommentsErrorCode, p as CreateCommentThreadInput, r as CommentSendOptions, s as CommentsForgeOptions, t as CommentSendAddressContext, u as CommentsPageContext, v as ReplyInput, y as ReplyOptions } from "./types-l6GOb_yc.js";
|
|
4
|
-
import { a as CommentSendPolicy, i as CommentSendListOptions, n as defineComments, o as CommentSendThread, r as describeCommentContext, s as CommentSendView, t as Comments } from "./index-
|
|
4
|
+
import { a as CommentSendPolicy, i as CommentSendListOptions, n as defineComments, o as CommentSendThread, r as describeCommentContext, s as CommentSendView, t as Comments } from "./index-D1T7RJ4R.js";
|
|
5
5
|
import { r as normalizeCommentPage, t as commentRoom } from "./page-DE71P_gQ.js";
|
|
6
6
|
export { type AreaAnchor, type CommentAction, type CommentActor, type CommentAnchor, type CommentAttachment, type CommentBuild, type CommentComponent, type CommentContext, type CommentCreateInput, type CommentDeleteInput, type CommentDelivery, type CommentDeliveryError, type CommentEditInput, type CommentEvent, type CommentFiles, type CommentForgeLink, type CommentGetInput, type CommentListCursor, type CommentListQuery, type CommentMentionEvent, type CommentMessage, type CommentMessageEvent, type CommentMetadata, type CommentReplyInput, type CommentSendAddressContext, type CommentSendData, type CommentSendListOptions, type CommentSendOptions, type CommentSendPayloadContext, type CommentSendPolicy, type CommentSendPromptContext, type CommentSendThread, type CommentSendView, type CommentStatus, type CommentStatusInput, type CommentSubject, type CommentSubjectDefinition, type CommentThread, type CommentUploadInput, type CommentUser, type CommentUsersInput, Comments, type CommentsAttachmentFile, type CommentsAuthorize, type CommentsAuthorizeContext, type CommentsCanMentionContext, type CommentsDefinition, type CommentsErrorCode, type CommentsForgeOptions, type CommentsForgeTarget, type CommentsGitHubAccess, type CommentsIdentifyContext, type CommentsPageContext, type CommentsPageSubject, type CommentsPeople, type CommentsPolicyGate, type CommentsRateLimit, type CommentsReadAttachmentContext, type CommentsRequestEvent, type CommentsStoreAttachmentContext, type CommentsTransport, type CommentsUser, type CreateCommentThreadInput, type DefineCommentsOptions, type EditCommentInput, type ElementAnchor, type FindCommentThreadInput, type ImageAnchor, type ListCommentThreadsOptions, type PageAnchor, type ReplyInput, type ReplyOptions, type TextAnchor, commentRoom, commentsRoleAllows, defaultPolicy, defineCommentSubject, defineComments, describeCommentContext, normalizeCommentPage };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as suggest, a as createThread, b as scopeOf, c as earlierThread, g as replyToThread, l as editMessage, r as can, s as earlierReply, w as clientRateLimitIssue } from "./service-
|
|
2
|
-
import { a as defineCommentSubject, i as defaultPolicy, n as commentsRoleAllows, s as markCommentsDefinition } from "./define-
|
|
1
|
+
import { S as suggest, a as createThread, b as scopeOf, c as earlierThread, g as replyToThread, l as editMessage, r as can, s as earlierReply, w as clientRateLimitIssue } from "./service-DUh2uGd2.js";
|
|
2
|
+
import { a as defineCommentSubject, i as defaultPolicy, n as commentsRoleAllows, s as markCommentsDefinition } from "./define-BCxNaSZv.js";
|
|
3
3
|
import { t as commentsErrorDiagnostics } from "./errors-DFNiJg67.js";
|
|
4
4
|
import { t as commentsErrors } from "./errors-C0VwRHiy.js";
|
|
5
5
|
import { a as runtimeOf, n as pendingKey, o as runtimes, t as commentSendOf } from "./installed-C9SkldMi.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as commentsSchema } from "./database-DUs3c2al.js";
|
|
2
2
|
import { i as CommentsRuntime, n as CommentsAttachmentStore, o as SharedRateLimit } from "./service-CPiWPoiY.js";
|
|
3
|
-
import { c as CommentSendWebhooks, t as Comments } from "./index-
|
|
3
|
+
import { c as CommentSendWebhooks, t as Comments } from "./index-D1T7RJ4R.js";
|
|
4
4
|
import { d as CommentsPeople } from "./define-B1jLSPe9.js";
|
|
5
5
|
import { r as CommentsTables, t as CommentsDatabase } from "./store-DvNTDNgn.js";
|
|
6
6
|
import { r as CommentsSchemaOwner } from "./migrate-XjFeQppf.js";
|
|
@@ -1464,9 +1464,12 @@ function createCommentSendService(options) {
|
|
|
1464
1464
|
const forbidden = () => [commentsErrors.COMMENTS_FORBIDDEN({ action: "send" }), void 0];
|
|
1465
1465
|
const insecure = (origin) => isSecureOrigin(origin) ? void 0 : [commentsErrors.COMMENTS_SEND_INSECURE({ origin }), void 0];
|
|
1466
1466
|
const deliveryFailed = "The agent's receiver did not take the send.";
|
|
1467
|
+
async function deliveryOf(row) {
|
|
1468
|
+
return row.delivery ? await (await webhooks()).getMemberDelivery(row.delivery) : void 0;
|
|
1469
|
+
}
|
|
1467
1470
|
async function reconcile(row) {
|
|
1468
1471
|
if (row.state !== "pending") return row;
|
|
1469
|
-
const delivery =
|
|
1472
|
+
const delivery = (await deliveryOf(row))?.state;
|
|
1470
1473
|
const state = delivery === "sent" ? "sent" : delivery === "dead" || delivery === "cancelled" || !delivery && Date.now() - row.updatedAt > 6e4 ? "failed" : "pending";
|
|
1471
1474
|
if (state === "pending") return row;
|
|
1472
1475
|
const error = state === "failed" ? deliveryFailed : null;
|
|
@@ -1606,12 +1609,13 @@ function createCommentSendService(options) {
|
|
|
1606
1609
|
}
|
|
1607
1610
|
async function view(row, user, policy) {
|
|
1608
1611
|
const opened = await viewOf(row, user, policy);
|
|
1609
|
-
|
|
1612
|
+
if (row.state !== "sent" && row.state !== "pending") return opened;
|
|
1613
|
+
const state = await store.setSendState(row.id, ["pending", "sent"], "working", Date.now()) ? "working" : (await store.send(row.id))?.state ?? row.state;
|
|
1610
1614
|
return {
|
|
1611
1615
|
...opened,
|
|
1612
1616
|
send: {
|
|
1613
1617
|
...opened.send,
|
|
1614
|
-
state
|
|
1618
|
+
state
|
|
1615
1619
|
}
|
|
1616
1620
|
};
|
|
1617
1621
|
}
|
|
@@ -1622,13 +1626,15 @@ function createCommentSendService(options) {
|
|
|
1622
1626
|
status: "failed",
|
|
1623
1627
|
reason: "No agent is paired. Press Send to pair one."
|
|
1624
1628
|
};
|
|
1629
|
+
const inbox = endpoint.kind === "inbox";
|
|
1625
1630
|
const resultOf = (row) => row.state === "failed" ? {
|
|
1626
1631
|
status: "failed",
|
|
1627
1632
|
reason: row.error ?? deliveryFailed
|
|
1628
1633
|
} : {
|
|
1629
1634
|
status: row.state === "pending" ? "pending" : "sent",
|
|
1630
1635
|
id: row.id,
|
|
1631
|
-
...row.thread ? { thread: row.thread } : {}
|
|
1636
|
+
...row.thread ? { thread: row.thread } : {},
|
|
1637
|
+
inbox
|
|
1632
1638
|
};
|
|
1633
1639
|
const live = [
|
|
1634
1640
|
"pending",
|
|
@@ -1705,7 +1711,10 @@ function createCommentSendService(options) {
|
|
|
1705
1711
|
};
|
|
1706
1712
|
}
|
|
1707
1713
|
const fail = async (reason) => {
|
|
1708
|
-
await store.setSendState(id, ["pending"], "failed", Date.now(), { error: reason })
|
|
1714
|
+
if (!await store.setSendState(id, ["pending"], "failed", Date.now(), { error: reason })) {
|
|
1715
|
+
const current = await store.send(id);
|
|
1716
|
+
if (current) return resultOf(current);
|
|
1717
|
+
}
|
|
1709
1718
|
return {
|
|
1710
1719
|
status: "failed",
|
|
1711
1720
|
reason
|
|
@@ -1753,11 +1762,15 @@ function createCommentSendService(options) {
|
|
|
1753
1762
|
});
|
|
1754
1763
|
if (error || delivered.status === "failed") return fail(error?.why ?? deliveryFailed);
|
|
1755
1764
|
const status = delivered.status === "pending" ? "pending" : "sent";
|
|
1756
|
-
await store.setSendState(id, ["pending"], status, Date.now(), { delivery: delivered.id })
|
|
1765
|
+
if (!await store.setSendState(id, ["pending"], status, Date.now(), { delivery: delivered.id })) {
|
|
1766
|
+
const current = await store.send(id);
|
|
1767
|
+
if (current) return resultOf(current);
|
|
1768
|
+
}
|
|
1757
1769
|
return {
|
|
1758
1770
|
status,
|
|
1759
1771
|
id,
|
|
1760
|
-
...thread ? { thread } : {}
|
|
1772
|
+
...thread ? { thread } : {},
|
|
1773
|
+
inbox
|
|
1761
1774
|
};
|
|
1762
1775
|
}
|
|
1763
1776
|
return {
|
|
@@ -1777,20 +1790,25 @@ function createCommentSendService(options) {
|
|
|
1777
1790
|
]);
|
|
1778
1791
|
const latest = candidate && await reconcile(candidate);
|
|
1779
1792
|
const agent = agentOf(endpoint);
|
|
1780
|
-
let
|
|
1793
|
+
let last = {};
|
|
1781
1794
|
if (latest?.state === "sent" || latest?.state === "working") {
|
|
1782
1795
|
const byId = new Map(open.map((thread) => [thread.id, thread]));
|
|
1783
|
-
if (!finished(latest, (id) => byId.get(id)))
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1796
|
+
if (!finished(latest, (id) => byId.get(id))) {
|
|
1797
|
+
const send = {
|
|
1798
|
+
id: latest.id,
|
|
1799
|
+
...latest.thread ? { thread: latest.thread } : {}
|
|
1800
|
+
};
|
|
1801
|
+
last = latest.state === "sent" ? { sent: {
|
|
1802
|
+
...send,
|
|
1803
|
+
inbox: (await deliveryOf(latest))?.inbox ?? false
|
|
1804
|
+
} } : { working: send };
|
|
1805
|
+
} else await store.setSendState(latest.id, ["sent", "working"], "done", now);
|
|
1788
1806
|
}
|
|
1789
1807
|
return {
|
|
1790
1808
|
count: ready.length,
|
|
1791
1809
|
selection: await selectionOf(caller.subject, ready),
|
|
1792
1810
|
...agent ? { agent } : {},
|
|
1793
|
-
...
|
|
1811
|
+
...last,
|
|
1794
1812
|
...latest?.state === "pending" ? { pending: true } : {},
|
|
1795
1813
|
...limitedUntil === void 0 ? {} : { retryAt: limitedUntil }
|
|
1796
1814
|
};
|
|
@@ -1904,6 +1922,7 @@ function createCommentSendService(options) {
|
|
|
1904
1922
|
if (allowed.status !== "allowed") return allowed.status === "not-owner" ? forbidden() : [commentsErrors.COMMENTS_SEND_CODE_EXPIRED(), void 0];
|
|
1905
1923
|
return [void 0, await deliver(caller, user, {
|
|
1906
1924
|
id: allowed.endpoint.id,
|
|
1925
|
+
kind: allowed.endpoint.kind,
|
|
1907
1926
|
thread: allowed.pairing.address
|
|
1908
1927
|
}, confirmed)];
|
|
1909
1928
|
},
|
|
@@ -1930,7 +1949,12 @@ function createCommentSendService(options) {
|
|
|
1930
1949
|
const found = id ? await store.send(id) : await store.latestSend(user.id, void 0, ["pending", "sent"]);
|
|
1931
1950
|
if (found?.member !== user.id) return void 0;
|
|
1932
1951
|
const row = await reconcile(found);
|
|
1933
|
-
if (row.state === "failed"
|
|
1952
|
+
if (row.state === "failed") return void 0;
|
|
1953
|
+
if (row.state === "pending") {
|
|
1954
|
+
if (!id) return void 0;
|
|
1955
|
+
const delivery = (await deliveryOf(row))?.state;
|
|
1956
|
+
if (delivery !== "sending" && delivery !== "sent") return void 0;
|
|
1957
|
+
}
|
|
1934
1958
|
return view(row, user, policy);
|
|
1935
1959
|
},
|
|
1936
1960
|
async listOwn(user, options = {}) {
|
|
@@ -2,7 +2,7 @@ import { n as outboxAccountHeader } from "./client-files-lC6X7XyS.js";
|
|
|
2
2
|
import { t as commentsErrorDiagnostics } from "./errors-DFNiJg67.js";
|
|
3
3
|
import { n as pagePathOf, t as isPagePath } from "./path-8yqMd8zR.js";
|
|
4
4
|
import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
|
|
5
|
-
import { C as clientAddressKey, S as suggest, T as createClientRateLimit, _ as requestIdSchema, a as createThread, c as earlierThread, d as maximumAttachmentBytes, f as maximumCommentBodyLength, g as replyToThread, h as readAttachment, l as editMessage, m as personOf, n as base64, o as deniedError, r as can, s as earlierReply, t as attachmentThread, u as fail, v as retried, x as storeAttachment, y as retriedReply } from "./service-
|
|
5
|
+
import { C as clientAddressKey, S as suggest, T as createClientRateLimit, _ as requestIdSchema, a as createThread, c as earlierThread, d as maximumAttachmentBytes, f as maximumCommentBodyLength, g as replyToThread, h as readAttachment, l as editMessage, m as personOf, n as base64, o as deniedError, r as can, s as earlierReply, t as attachmentThread, u as fail, v as retried, x as storeAttachment, y as retriedReply } from "./service-DUh2uGd2.js";
|
|
6
6
|
import { n as guestFromHeaders, t as authorOf } from "./identity-CT7-UGmS.js";
|
|
7
7
|
import { t as describeCommentContext } from "./context-DbkBjITZ.js";
|
|
8
8
|
import { t as commentsRuntime } from "./server-BGbD7H5s.js";
|
package/dist/operations.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-
|
|
2
|
-
import { f as maximumCommentBodyLength } from "./service-
|
|
1
|
+
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-B8IMhRmY.js";
|
|
2
|
+
import { f as maximumCommentBodyLength } from "./service-DUh2uGd2.js";
|
|
3
3
|
export { commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, maximumCommentBodyLength };
|