@popmelt.com/core 0.41.1 → 0.42.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/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/codex-plugin/assets/popmelt-logo.svg +1 -1
- package/dist/{ExploreAttachment-PTK4YHVE.mjs → ExploreAttachment-TRA62BMX.mjs} +1 -1
- package/dist/PagePreviewLayer-TX74TJBY.mjs +1 -0
- package/dist/ParticipantRuntime-Y7MKLWBC.mjs +1 -0
- package/dist/PhoneHostGate-XRYFSUJA.mjs +1 -0
- package/dist/{PopmeltProvider-5g-1VH5a.d.mts → PopmeltProvider-NwqjKtGG.d.mts} +1 -1
- package/dist/PopmeltTasteConnectedPane-NMKIRMDM.mjs +1 -0
- package/dist/{PreviewRuntime-7EQNIOF5.mjs → PreviewRuntime-VJXFECBF.mjs} +1 -1
- package/dist/{QueuedReplies-ESF5UL3J.mjs → QueuedReplies-X2N4JRS6.mjs} +1 -1
- package/dist/SamplePlacementOverlay-VWCULP2R.mjs +1 -0
- package/dist/ShareProjectPane-L6AO57IN.mjs +1 -0
- package/dist/SuppliedContext-UGQSL4IG.mjs +1 -0
- package/dist/{ThreadErrorCard-QGTWIV7B.mjs → ThreadErrorCard-WSNEGY7J.mjs} +1 -1
- package/dist/ThreadPanel-QNDCQOA4.mjs +1 -0
- package/dist/adapter-react-three-fiber.d.mts +1 -1
- package/dist/adapter-three.d.mts +1 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/{bridgeSSEStream-2KKFO64A.mjs → bridgeSSEStream-BHUFYHTT.mjs} +1 -1
- package/dist/{bridgeWebSocketStream-XTHQPBPI.mjs → bridgeWebSocketStream-L277I5ZX.mjs} +1 -1
- package/dist/browser-runtime-3PAM2ZUE.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/{canvas-chat-note-XMVKWL2J.mjs → canvas-chat-note-HTK23RYE.mjs} +1 -1
- package/dist/canvas-text.d.mts +1 -1
- package/dist/{checkFixture-VWHN4ZNH.mjs → checkFixture-C26VSTGP.mjs} +1 -1
- package/dist/chunk-23YWKAQM.mjs +1 -0
- package/dist/chunk-2OWGUAUI.mjs +1 -0
- package/dist/{chunk-YTIDSDPP.mjs → chunk-2PARHFWP.mjs} +1 -1
- package/dist/chunk-2YT4X5VC.mjs +1 -0
- package/dist/{chunk-DMKBAI2Z.mjs → chunk-47SWWW5Y.mjs} +1 -1
- package/dist/chunk-56AALMHI.mjs +1 -0
- package/dist/chunk-5JAZXI47.mjs +1 -0
- package/dist/chunk-5SXPTNUM.mjs +1 -0
- package/dist/chunk-5YNIYMKX.mjs +1 -0
- package/dist/{chunk-EWNSX5BF.mjs → chunk-7PZN2RNE.mjs} +1 -1
- package/dist/chunk-ALW6WNDJ.mjs +1 -0
- package/dist/{chunk-ADRWR5GI.mjs → chunk-BH5BNULT.mjs} +1 -1
- package/dist/chunk-BZPWT44Z.mjs +1 -0
- package/dist/chunk-DAMF6ZWZ.mjs +1 -0
- package/dist/chunk-E7VH7WB5.mjs +1 -0
- package/dist/chunk-EBESPLST.mjs +1 -0
- package/dist/{chunk-7D4BUDKG.mjs → chunk-ECGXE2Z6.mjs} +1 -1
- package/dist/chunk-EEU5J3CD.mjs +1 -0
- package/dist/chunk-FGJX74DI.mjs +1 -0
- package/dist/chunk-I3LFTKJP.mjs +1 -0
- package/dist/chunk-K4CIGHJI.mjs +1 -0
- package/dist/chunk-KYS76O3N.mjs +1 -0
- package/dist/{chunk-77DD4HQE.mjs → chunk-LB66O2BP.mjs} +1 -1
- package/dist/chunk-LEMLTB2X.mjs +1 -0
- package/dist/chunk-M2BCEQDP.mjs +1 -0
- package/dist/{chunk-44NLL6X3.mjs → chunk-MYEG7OXO.mjs} +1 -1
- package/dist/chunk-NMMTIZ6K.mjs +1 -0
- package/dist/chunk-NWQGXYER.mjs +1 -0
- package/dist/{chunk-3UE2DLFY.mjs → chunk-OBYCW4I3.mjs} +1 -1
- package/dist/chunk-ODZOYCTC.mjs +1 -0
- package/dist/{chunk-HFKGW34E.mjs → chunk-OOFTFGZL.mjs} +1 -1
- package/dist/chunk-OSUJWNS2.mjs +1 -0
- package/dist/chunk-PACB6IBR.mjs +1 -0
- package/dist/{chunk-ENXCO63D.mjs → chunk-PGIWJ37M.mjs} +1 -1
- package/dist/{chunk-VSWRWS2H.mjs → chunk-PLRJ4GAR.mjs} +1 -1
- package/dist/{chunk-KF35YUNZ.mjs → chunk-QF5B6AYF.mjs} +1 -1
- package/dist/chunk-QKJPWA2I.mjs +1 -0
- package/dist/{chunk-4O6YFMWF.mjs → chunk-RBX7ANQX.mjs} +1 -1
- package/dist/chunk-RQHZNEA2.mjs +1 -0
- package/dist/{chunk-SZQTGYPS.mjs → chunk-SDXFJ7JW.mjs} +1 -1
- package/dist/{chunk-EHM2ZBQU.mjs → chunk-SKQA53J2.mjs} +1 -1
- package/dist/chunk-TJ25JLBL.mjs +1 -0
- package/dist/chunk-U522GPBG.mjs +1 -0
- package/dist/{chunk-5J4BZL6N.mjs → chunk-V5K4F2XQ.mjs} +1 -1
- package/dist/chunk-VGX6J2OP.mjs +1 -0
- package/dist/{chunk-EO3SHOXX.mjs → chunk-VPF4NHAP.mjs} +1 -1
- package/dist/{chunk-VJKC2RJB.mjs → chunk-WNCZCPTX.mjs} +1 -1
- package/dist/chunk-XMCHOGMG.mjs +1 -0
- package/dist/chunk-XNCN6DGG.mjs +30 -0
- package/dist/{chunk-P6XIVHP5.mjs → chunk-XRM2KI4C.mjs} +1 -1
- package/dist/{chunk-YU5PF45T.mjs → chunk-YFXYRNER.mjs} +1 -1
- package/dist/{chunk-YHCZYT4T.mjs → chunk-YZIDCW7A.mjs} +1 -1
- package/dist/chunk-Z32CLWW2.mjs +1 -0
- package/dist/{chunk-KCDHP4N3.mjs → chunk-ZCJCM3DT.mjs} +1 -1
- package/dist/{chunk-WIJSWSNF.mjs → chunk-ZE3LG7MR.mjs} +1 -1
- package/dist/chunk-ZEIVO4X7.mjs +1 -0
- package/dist/{chunk-SIGOY5GG.mjs → chunk-ZQLNGMVV.mjs} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-327LH622.mjs +1 -0
- package/dist/codex-project-25QJDNJN.mjs +1 -0
- package/dist/{codex-store-mount-VHUHC2ZA.mjs → codex-store-mount-BRHVGYZU.mjs} +1 -1
- package/dist/{dev-server-D8Qxrp1A.d.mts → dev-server-C-mvGeOM.d.mts} +2 -2
- package/dist/dev-server-ZLIPCFFT.mjs +1 -0
- package/dist/{focus-inspection-FVQ6TVGA.mjs → focus-inspection-TPTEFBH3.mjs} +1 -1
- package/dist/guest-admission.mjs +1 -1
- package/dist/guest-live-canvas.mjs +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +1 -1
- package/dist/{invitationLink-LUIIOAEZ.mjs → invitationLink-RX53O6RI.mjs} +1 -1
- package/dist/media.d.mts +3 -3
- package/dist/memory-store.d.mts +6 -6
- package/dist/{page-interaction-74JGNCZ5.mjs → page-interaction-6SR32FFS.mjs} +1 -1
- package/dist/{page-planes-BeFZ3Wso.d.mts → page-planes-C5J6qgMj.d.mts} +99 -50
- package/dist/{participantBootstrap-BcfNTEe9.d.mts → participantBootstrap-BjHfrdwL.d.mts} +3 -2
- package/dist/peer-client-2LEZ7SW4.mjs +1 -0
- package/dist/phone-recovery.mjs +1 -0
- package/dist/plugin-astro.d.mts +7 -7
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-next.mjs +1 -1
- package/dist/plugin-nuxt.d.mts +5 -5
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.d.mts +8 -7
- package/dist/plugin-vite.mjs +1 -1
- package/dist/project-id.mjs +1 -0
- package/dist/{protocol-BIUE4rB6.d.mts → protocol-aJ3S127Q.d.mts} +5 -1
- package/dist/server.d.mts +15 -7
- package/dist/server.mjs +1 -1
- package/dist/shared-page-KQSG3DM3.mjs +1 -0
- package/dist/{subjects-qHIrZrlt.d.mts → subjects-CGN4QTSS.d.mts} +1 -1
- package/dist/{video-adapter-B5eap10v.d.mts → video-adapter-DtIw_QVy.d.mts} +1 -1
- package/dist/{workspace-snapshot-RUGPDEYJ.mjs → workspace-snapshot-DX62ZFVF.mjs} +1 -1
- package/infra/phone-pairing/machine-config.mjs +15 -2
- package/infra/phone-pairing/machine-service.mjs +39 -13
- package/infra/phone-pairing/managed-install.mjs +8 -2
- package/package.json +1 -1
- package/dist/PagePreviewLayer-HMKZL5VB.mjs +0 -1
- package/dist/ParticipantRuntime-ELXK42P7.mjs +0 -1
- package/dist/PhoneHostGate-5S2WCM3W.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-BILMI6L2.mjs +0 -1
- package/dist/SamplePlacementOverlay-K3Z5C67A.mjs +0 -1
- package/dist/ShareProjectPane-P5HAKBKX.mjs +0 -1
- package/dist/SuppliedContext-ADMN2D2I.mjs +0 -1
- package/dist/ThreadPanel-Z76WNKPP.mjs +0 -1
- package/dist/browser-runtime-OWU4CMJB.mjs +0 -1
- package/dist/chunk-2F2BVGFH.mjs +0 -1
- package/dist/chunk-5TCWBNV4.mjs +0 -1
- package/dist/chunk-72CUIZA2.mjs +0 -1
- package/dist/chunk-C2ZSNUXQ.mjs +0 -1
- package/dist/chunk-EILBHZDX.mjs +0 -1
- package/dist/chunk-FAEFYWCY.mjs +0 -1
- package/dist/chunk-FQH24XFS.mjs +0 -1
- package/dist/chunk-G7UU6M76.mjs +0 -1
- package/dist/chunk-GYKRKAEF.mjs +0 -1
- package/dist/chunk-HAZXZ5TU.mjs +0 -1
- package/dist/chunk-HM6EBJVO.mjs +0 -1
- package/dist/chunk-IC4G3NXR.mjs +0 -1
- package/dist/chunk-ITLRSHNZ.mjs +0 -1
- package/dist/chunk-J3IPAD7E.mjs +0 -1
- package/dist/chunk-LZV3IYTM.mjs +0 -1
- package/dist/chunk-OEJXPUAR.mjs +0 -1
- package/dist/chunk-PRZ6C5X3.mjs +0 -1
- package/dist/chunk-RWZ7SVMO.mjs +0 -1
- package/dist/chunk-SHIN4R4V.mjs +0 -1
- package/dist/chunk-SMIEQSM5.mjs +0 -1
- package/dist/chunk-SOGN7S54.mjs +0 -1
- package/dist/chunk-SUAHDXJZ.mjs +0 -1
- package/dist/chunk-TMW3SI7F.mjs +0 -1
- package/dist/chunk-TRRNHBEH.mjs +0 -1
- package/dist/chunk-UFU5IA3G.mjs +0 -1
- package/dist/chunk-UNUYNWTJ.mjs +0 -1
- package/dist/chunk-VI3DNZM4.mjs +0 -1
- package/dist/chunk-VLTK7KWK.mjs +0 -1
- package/dist/chunk-WP44H6DL.mjs +0 -30
- package/dist/chunk-YG3RSK5J.mjs +0 -1
- package/dist/chunk-YTMUAK4P.mjs +0 -1
- package/dist/codex-note-context-PM4TA6WR.mjs +0 -1
- package/dist/codex-project-YSALZU44.mjs +0 -1
- package/dist/dev-server-KE4NM4WM.mjs +0 -1
- package/dist/peer-client-TSTD27DV.mjs +0 -1
- package/dist/shared-page-6AUYAPJ3.mjs +0 -1
- /package/dist/{chunk-CIKFUS7J.mjs → chunk-R565ZNSP.mjs} +0 -0
- /package/dist/{chunk-DPLSL33X.mjs → chunk-XBA5ROC5.mjs} +0 -0
- /package/dist/{toolbarFonts-33BI56VQ.mjs → toolbarFonts-RR24L4CJ.mjs} +0 -0
- /package/dist/{webpEncoder-JVMGDKHV.mjs → webpEncoder-XTISHUBA.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{c as e}from"./chunk-RK6UROPO.mjs";import{o as t,n as o,h as n}from"./chunk-AOTDTBQO.mjs";import{i,j as r}from"./chunk-M2BCEQDP.mjs";import{a}from"./chunk-5YNIYMKX.mjs";import{h as l,e as s,o as d,X as p,v as c,A as u,b as h}from"./chunk-QF5B6AYF.mjs";import{b as f}from"./chunk-VBH2YQLG.mjs";import{a as m,h as g,d as v,i as b,c as w,m as y,b as x}from"./chunk-LH7HKUCK.mjs";import{L as k}from"./chunk-KE4MQBRY.mjs";import{b as A}from"./chunk-BH5BNULT.mjs";import{createContext as R,useState as L,useLayoutEffect as $,useContext as j,useId as C,useRef as S}from"react";import{jsxs as D,jsx as E,Fragment as O}from"react/jsx-runtime";var N=R(!0);function M(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);if(o)return`oklch(${o[1]} / ${t})`;let n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n){return`rgba(${parseInt(n[1],16)}, ${parseInt(n[2],16)}, ${parseInt(n[3],16)}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(100*t)}%, transparent)`}var T=new WeakMap,F=0,P="popmelt-scroll-anchor",z="popmelt-page-paint",B=`\n[data-popmelt-top-layer-host]::part(${P}) {\n position-anchor: var(--popmelt-anchor) !important;\n}\n[data-popmelt-top-layer-host]::part(${z}) {\n position-anchor: --popmelt-page-origin;\n left: calc(anchor(left, calc(0px - var(--popmelt-painted-x, 0px))) + var(--popmelt-painted-x, 0px));\n top: calc(anchor(top, calc(0px - var(--popmelt-painted-y, 0px))) + var(--popmelt-painted-y, 0px));\n}\n`;function H(e){if(!(e instanceof HTMLElement&&e.getRootNode()===document&&globalThis.CSS?.supports?.("top","anchor(top)")))return;let t=T.get(e);if(!t){let o=getComputedStyle(e).getPropertyValue("anchor-name");if(o&&"none"!==o)return;let n="--popmelt-target-"+ ++F;t={name:n,users:0,previous:e.style.getPropertyValue("anchor-name"),priority:e.style.getPropertyPriority("anchor-name"),hadStyle:e.hasAttribute("style")},T.set(e,t),e.style.setProperty("anchor-name",n)}let o=t;return o.users++,{name:o.name,element:e,release(){--o.users||(T.delete(e),I(e,o))}}}function I(e,t){e.style.getPropertyValue("anchor-name")===t.name&&(e.style.setProperty("anchor-name",t.previous,t.priority),!t.hadStyle&&!e.style.length&&e.removeAttribute("style"))}function W(e,t){if(!(e instanceof HTMLElement&&t instanceof HTMLElement))return;let o=T.get(e);o&&I(t,o)}function q(e){let[t,o]=L();return $(()=>{let t=H(e);return o(t),t?.release},[e]),t&&t.element===e?t.name:void 0}function V(e,t,o,n){return e?{"--popmelt-anchor":e,positionAnchor:e,left:`calc(anchor(left, ${t.left}px) + ${o-t.left}px)`,top:`calc(anchor(top, ${t.top}px) + ${n-t.top}px)`}:{left:o,top:n}}function K(e){let[t,o]=L(null),n=S(null);return $(()=>{if(o(null),!e)return;let t=p(e,"transparent",0,"solid",o);return()=>t?.abort()},[e]),$(()=>{let e=n.current;if(!t||!e)return;let o=()=>{let o=t.matches("path")?[t]:t.querySelectorAll("path"),n=0;for(let t of o){let o=t.getAttribute("d"),i=t.getScreenCTM();if(!o||!i||!t.getClientRects().length)continue;let r=e.children[n++];r||(r=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("vector-effect","non-scaling-stroke"),e.append(r));let a=m(t.ownerDocument)?w({left:0,top:0,width:1,height:1},t.ownerDocument):null,l=a?.width??1,s=a?.height??1,d=`matrix(${i.a*l} ${i.b*s} ${i.c*l} ${i.d*s} ${i.e*l+(a?.x??0)} ${i.f*s+(a?.y??0)})`;r.getAttribute("d")!==o&&r.setAttribute("d",o),r.getAttribute("transform")!==d&&r.setAttribute("transform",d);let p=t.getAttribute("fill-rule")||"nonzero";r.getAttribute("fill-rule")!==p&&r.setAttribute("fill-rule",p)}for(;e.children.length>n;)e.lastElementChild.remove()},i=new MutationObserver(o);i.observe(t,{subtree:!0,attributes:!0,childList:!0});let r,a=()=>{o(),r=requestAnimationFrame(a)};return a(),()=>{i.disconnect(),cancelAnimationFrame(r),e.replaceChildren()}},[t]),{active:!!t,group:n}}function U({painterTarget:e,path:t,polygon:o,bounds:n,clip:i,color:r,selected:a,zIndex:l}){let s=C(),d=s+"-contour",p=K(e),{left:c,top:u,width:f,height:m}=n;return D("svg",{"data-devtools":"sample-spotlight","aria-hidden":"true",width:"100%",height:"100%",style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:l},children:[D("defs",{children:[i&&E("clipPath",{id:s+"-clip",children:E("rect",{x:i.left,y:i.top,width:i.width,height:i.height})}),E("g",{id:d,clipPath:i?`url(#${s}-clip)`:void 0,children:p.active?E("g",{ref:p.group}):o?E("polygon",{points:o,transform:`translate(${c} ${u}) scale(${f} ${m})`,vectorEffect:"non-scaling-stroke"}):t?E("path",{d:t}):E("rect",{x:c,y:u,width:f,height:m})}),D("mask",{id:s+"-mask",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"100%",height:"100%",children:[E("rect",{width:"100%",height:"100%",fill:"white"}),E("use",{href:"#"+d,fill:"black"})]})]}),E("rect",{width:"100%",height:"100%",fill:"black",fillOpacity:.5,mask:`url(#${s}-mask)`}),r&&E("use",{href:"#"+d,fill:"none",stroke:r,strokeWidth:1,strokeDasharray:a?void 0:h})]})}var Y,Q=new Set;function _(e){if(Q.add(e),!Y){let e=new Map,t=new Map,o="",n=!0,i=!0,r=!1,a=!0,l=0,s=()=>{let o=new Set,r=new Map,a=t=>{if(o.add(t),!e.has(t)){let o=new MutationObserver(e=>{let t=e.filter(e=>!(1===e.target.nodeType?e.target:e.target.parentElement)?.closest("[data-devtools]"));t.length&&(n=!0),t.some(e=>"childList"===e.type)&&(i=!0)});o.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let r=()=>{n=!0};t.addEventListener("scroll",r,!0),t.addEventListener("load",r,!0),e.set(t,()=>{o.disconnect(),t.removeEventListener("scroll",r,!0),t.removeEventListener("load",r,!0)})}for(let e of t.querySelectorAll("*")){if(e.shadowRoot&&!e.closest("[data-devtools]")&&a(e.shadowRoot),"iframe"!==e.localName||e.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let t=x(e);r.set(e,t),t&&a(t)}};a(document);for(let[t,n]of e)o.has(t)||(n(),e.delete(t));t=r,i=!1,n=!0},d=()=>{if(!a)return;(i||[...t].some(([e,t])=>x(e)!==t))&&s();let e=[];for(let[o,n]of t){let t=o.getBoundingClientRect();e.push(n?.URL,t.x,t.y,t.width,t.height,n?.defaultView?.scrollX,n?.defaultView?.scrollY)}let p=JSON.stringify(e);if((n||p!==o)&&(n=!1,o=p,r))for(let e of Q)e();r=!0,a&&(l=requestAnimationFrame(d))};d(),Y=()=>{a=!1,cancelAnimationFrame(l);for(let t of e.values())t()}}return()=>{Q.delete(e),Q.size||(Y?.(),Y=void 0)}}function G(e,t,o){let n=e.ownerDocument.defaultView,i=new Set,r=new Set,a=null;function l(){a=null,o();for(let e of r)!e.pending&&"running"!==e.playState&&r.delete(e);r.size&&(a=n.requestAnimationFrame(l))}function s(e){for(let t of e.getAnimations?.()??[])(t.pending||"running"===t.playState)&&r.add(t);r.size&&null===a&&(a=n.requestAnimationFrame(l))}function d(e){e.target===e.currentTarget&&s(e.currentTarget)}let p=typeof ResizeObserver>"u"?null:new ResizeObserver(t),c=new MutationObserver(e=>{e.some(e=>Array.from(e.removedNodes).some(e=>i.has(e)))&&h(),e.some(e=>"style"===e.attributeName)?o():t()});function u(){c.disconnect(),p?.disconnect();for(let e of i)e.removeEventListener("animationstart",d),e.removeEventListener("transitionrun",d);i.clear(),r.clear(),null!==a&&n.cancelAnimationFrame(a),a=null}function h(){u();for(let t=e;t;t=t.assignedSlot??y(t))i.add(t),p?.observe(t),c.observe(t,{attributes:!0,attributeFilter:["style","class","hidden","open","data-popmelt-hover-painter"],childList:!0}),t.addEventListener("animationstart",d),t.addEventListener("transitionrun",d),s(t)}return h(),u}function X(n,i,r){let a=n.ownerDocument.defaultView??window,l=t(n)??n,s=()=>i(l),d=null,p=()=>{null===d&&(d=a.requestAnimationFrame(()=>{d=null,s()}))},c="true"===n.getAttribute("data-popmelt-subject-projection")&&r,u=()=>c?c.subscribeFrame(s):G(l,p,s),h=u(),f=o(()=>{let e=t(n)??n;e!==l&&(h(),l=e,h=u(),s())}),g=e(s,a),v=m(n.ownerDocument)?_(s):void 0;return s(),()=>{f(),v?.(),g(),h(),null!==d&&a.cancelAnimationFrame(d)}}function J(e){return"string"==typeof e?e:e.component+e.styles}function Z(e,t){let o="string"==typeof e?0:16;return t(J(e))+o}function ee(e,t=!1){if(e.subjectLabel)return`<${e.subjectLabel}>`;let o=e.dataAttributes?.["data-popmelt-label"]?.trim();if(o)return o;if(t&&e.reactComponent)return{component:e.reactComponent,styles:""};let n=e.id?`#${e.id}`:"";if(t)return e.tagName+n;let i=(e.className?.match(/\S+/g)??[]).map(e=>e.replace(/^[\w.-]+[.-]module__[\w-]+?__([\w-]+)$/,"$1"));return e.reactComponent?{component:e.reactComponent,styles:i.length?` (${i.join(", ")})`:""}:[e.tagName+n,...i.slice(0,2)].join(".")}var te=400,oe=12,ne=.24,ie=8,re=4;function ae(e){return"string"==typeof e?8:4}function le(e){return{...d(),display:"flex",alignItems:"center",gap:4,backgroundColor:e,color:"#fff",fontSize:12,lineHeight:12*s+"px",fontFamily:l,letterSpacing:"0.24px",padding:"0 8px",borderRadius:8,whiteSpace:"nowrap",maxWidth:400}}var se={overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0};function de({label:e,prefix:t="",hoverName:o,preview:n="expanded"}){let i="expanded"!==n,r="string"!=typeof e,a=r?e.component:o??e,l=r?e.styles:e.slice(a.length),s=void 0!==o&&!!l;return r||s?D("span",{"data-popmelt-snap-collapse":s&&"waiting"===n||void 0,"data-popmelt-collapsed":s?i:void 0,style:{display:s?"flex":"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r?"rgb(255 255 255 / 60%)":void 0},children:[D("span",{"data-popmelt-component-name":r||void 0,style:{color:"#fff",...s&&{flex:"none",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"}},children:[t,r&&E(k,{"aria-hidden":"true",size:12,fill:"currentColor",stroke:"none",style:{display:"inline-block",verticalAlign:"-0.12em",marginRight:4}}),a]}),s?E("span",{className:"popmelt-collapsible-badge-detail","aria-hidden":i,children:E("span",{className:"popmelt-collapsible-badge-detail-inner",style:{paddingLeft:0,whiteSpace:"pre",maxWidth:400},children:l})}):l]}):t+e}var pe={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function ce(e,t){return e.radii.topLeft===t.radii.topLeft&&e.radii.topRight===t.radii.topRight&&e.radii.bottomRight===t.radii.bottomRight&&e.radii.bottomLeft===t.radii.bottomLeft&&e.outline===t.outline&&e.path===t.path&&!["left","top","width","height"].some(o=>e.frameClip?.[o]!==t.frameClip?.[o]||e.subjectBounds?.[o]!==t.subjectBounds?.[o])&&e.fragments.length===t.fragments.length&&e.fragments.every((e,o)=>{let n=t.fragments[o];return!!n&&e.left===n.left&&e.top===n.top&&e.width===n.width&&e.height===n.height})}function ue(e,t){if(!e.isConnected||!g(e.ownerDocument))return{fragments:[],radii:pe};let o=v(e),i=b(o,e.ownerDocument);if(m(e.ownerDocument)&&(!i.width||!i.height))return{fragments:[],radii:pe};let a=t&&m(e.ownerDocument)?b(new DOMRect(0,0,window.innerWidth,window.innerHeight),e.ownerDocument):void 0;if("true"===e.getAttribute("data-popmelt-subject-projection"))return{fragments:[{left:i.left,top:i.top,width:i.width,height:i.height}],radii:pe,frameClip:a,subjectBounds:t?o:void 0,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let l=Array.from(e.getClientRects()).map(t=>b(w(t,e.ownerDocument),e.ownerDocument)).filter(e=>e.width>0&&e.height>0).map(e=>({left:e.left,top:e.top,width:e.width,height:e.height}));return{fragments:r(l.length>0?l:[{left:i.left,top:i.top,width:i.width,height:i.height}]),radii:n(e),path:t?u(e):void 0,frameClip:a}}function he({element:e,projectedRect:o,isSelected:n=!1,elementInfo:r,color:l="#3b82f6",annotationNumber:s,changeCount:d,hideTooltip:u=!1,hideOutline:h=!1,hideFill:m=!1,tintHoveredSubject:g=!1,spotlight:v=!1,fillOpacity:b=.05,subjectRegistry:w,railGap:y=2,railHeight:x=22,railWidth:k=0,renderRail:R,refreshKey:C,outlineZIndex:S=9996,threadTarget:T,onActivate:F,onRemove:z}){let B=j(N);$(()=>{if(!(B&&g&&e&&w))return;let t=f(e);if(!t)return;let o=w.resolve(t);return o?.element===e?o.adapter.highlightHover?.(t.key,l):void 0},[e,l,w,g,B]);let[H,I]=L({fragments:[],radii:pe});$(()=>{if(B)return e?X(e,e=>{let t=ue(e,v);I(e=>ce(e,t)?e:t)},w):void I({fragments:[],radii:pe})},[B,e,w,v]),$(()=>{if(!B||!e||void 0===C)return;let o=ue(t(e)??e,v);I(e=>ce(e,o)?e:o)},[B,e,C,v]);let{fragments:W,radii:K}=o?{fragments:[o],radii:pe}:H,Y=e&&(t(e)??e),Q=Y?.closest("[data-popmelt-hover-painter]"),[_,G]=L(null);$(()=>{if(!B||o||h||v||!Y||!Q)return void G(null);let e=p(Y,l,m?0:b,n?"solid":"dashed");return G(e?Y:null),()=>e?.abort()},[B,o,h,Y,Q,l,m,v,b,n]);let J=!!Y&&_===Y,Z=q(!B||o||1!==W.length||H.outline?null:Y),te=Z?P:void 0;if(0===W.length||!e&&!o)return null;let oe=i(W,W[0]),ne=ee({tagName:e?.localName??"",id:e?.id,className:e?.getAttribute("class")??void 0,reactComponent:r?.reactComponent,subjectLabel:e?.hasAttribute("data-popmelt-subject-adapter")?e.getAttribute("data-popmelt-subject-label")??void 0:void 0,dataAttributes:{"data-popmelt-label":e?.getAttribute("data-popmelt-label")??""}}),ie=c({left:oe.left,right:oe.left+oe.width,top:oe.top,bottom:oe.top+oe.height,height:oe.height},x,y,window.innerHeight,k,window.innerWidth),re={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:l,color:"#fff",fontSize:12,fontFamily:A,lineHeight:"14px",padding:"4px 8px",paddingLeft:void 0===s?ae(ne):8,borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",...V(Z,oe,ie.left,ie.top)},le=!u&&D("div",{ref:t=>{e&&a(e,t,ie.anchor)},part:te,"data-devtools":"tooltip",style:re,children:[void 0!==s&&D("span",{children:[s,"."]}),E("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:E(de,{label:ne})}),void 0!==d&&d>0&&D("span",{style:{opacity:.8},children:["(",d," ",1===d?"change":"changes",")"]})]}),se={borderTopLeftRadius:K.topLeft,borderTopRightRadius:K.topRight,borderBottomRightRadius:K.bottomRight,borderBottomLeftRadius:K.bottomLeft};return D(O,{children:[v&&E(U,{painterTarget:B&&!o&&Q?Y:null,path:o?void 0:H.path,polygon:o?void 0:H.outline,bounds:!o&&H.subjectBounds||oe,clip:o?void 0:H.frameClip,color:h?void 0:l,selected:n,zIndex:S-1}),!h&&W.map((e,t)=>E("div",{part:te,"data-devtools":"highlight",onContextMenu:z?e=>{e.preventDefault(),e.stopPropagation(),z()}:void 0,role:F?"button":void 0,tabIndex:F?0:void 0,"data-popmelt-thread-target":F&&T,"aria-label":F?"Open annotation thread":void 0,onPointerDown:F?e=>{e.preventDefault(),e.stopPropagation()}:void 0,onClick:F?e=>{e.preventDefault(),e.stopPropagation(),F()}:void 0,onKeyDown:F?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),F())}:void 0,style:{position:"fixed",...V(Z,oe,e.left,e.top),width:e.width,height:e.height,pointerEvents:F||z?"auto":"none",cursor:F?"pointer":void 0,zIndex:S,overflow:"visible",opacity:J||v?0:void 0},children:E("div",{style:H.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:m||v?"transparent":M(l,b),borderColor:l,borderStyle:n?"solid":"dashed",borderWidth:1,...se,pointerEvents:"none"},children:H.outline?E("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",style:{display:"block",overflow:"visible"},"aria-hidden":"true",children:E("polygon",{points:H.outline,fill:m||v?"transparent":M(l,b),stroke:l,strokeWidth:1,strokeDasharray:n?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},t)),R?R(ie,oe,Z):le]})}export{N as a,M as b,P as c,z as d,B as e,H as f,W as g,q as h,V as i,_ as j,X as k,J as l,Z as m,ee as n,te as o,oe as p,ne as q,ie as r,re as s,ae as t,le as u,se as v,de as w,he as x};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{d as e}from"./chunk-5TCWBNV4.mjs";import{E as t,D as n,F as i,H as a,G as r}from"./chunk-ENXCO63D.mjs";import{a as o}from"./chunk-YG3RSK5J.mjs";import{n as s,o as d}from"./chunk-EILBHZDX.mjs";import{j as l,a as m,i as c,k as p}from"./chunk-HFKGW34E.mjs";import{a as u}from"./chunk-7D4BUDKG.mjs";import{x as h,J as y,Qa as f,R as g,ya as b}from"./chunk-KE4MQBRY.mjs";import{a as v}from"./chunk-B4DYUYX4.mjs";import{c as w,a as k}from"./chunk-ADRWR5GI.mjs";import{useRef as j,useState as x,useLayoutEffect as S,useId as C,useEffect as I}from"react";import{jsxs as T,jsx as z,Fragment as A}from"react/jsx-runtime";function R(){let e=crypto.getRandomValues(new Uint8Array(32));return{id:crypto.randomUUID(),token:Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}}var E=360,N=120;function J({client:J,storage:O,storageKey:W,onAdmitted:q,theme:F="light",themePreference:B=F,onThemePreferenceChange:D,onJoin:L,guestInvite:H,showHostLinkHelp:K=!1}){let P=j(null),$=j(!1);if(!$.current){$.current=!0;try{W&&(P.current=JSON.parse(O.getItem(W)??"null"))}catch{}}let[U,X]=x(P.current?.name??""),M=j(!1),Y=!!H;S(()=>{if(Y&&W&&!M.current)try{let e=JSON.parse(O.getItem(W)??"null");"string"==typeof e?.name&&X(e.name)}catch{}},[Y,O,W]);let G=!(!L&&!H),[V,Q]=x(G?void 0:P.current?.receipt),[Z,_]=x(null),[ee,te]=x(),ne=H?.color??ee,[ie,ae]=x(),re=H?.shape??ie,oe=j(null),[se,de]=x(G),[le,me]=x(!1),[ce,pe]=x(0),[ue,he]=x(),[ye,fe]=x("idle"),[ge,be]=x(),ve=j(!1),[we,ke]=x(""),je=j(null),xe=j(null),Se=j(!1),Ce=j(0),Ie=j(!1),Te=C(),ze=j(!1),Ae=j(0),Re=j(q);Re.current=q;let Ee=j(!1),Ne=j(null),Je=j(()=>{});Ne.current||(Ne.current=new Promise(e=>{Je.current=e}));let Oe=u[F],We=!Y&&se&&!ne;I(()=>{let e,t,n=!1,i=()=>{n||(n=!0,Ee.current=!0,Je.current())};"function"==typeof requestAnimationFrame&&(e=requestAnimationFrame(()=>{t=requestAnimationFrame(i)}));let a=window.setTimeout(i,64);return()=>{void 0!==e&&cancelAnimationFrame(e),void 0!==t&&cancelAnimationFrame(t),window.clearTimeout(a),i()}},[]),I(()=>w(document),[]),S(()=>{let e=!0,t=()=>{if(!e||!xe.current)return;let t=getComputedStyle(xe.current),n=document.createElement("span");Object.assign(n.style,{position:"fixed",visibility:"hidden",pointerEvents:"none",whiteSpace:"nowrap",fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight,lineHeight:t.lineHeight}),document.body.append(n);let i=Number.parseFloat(t.paddingLeft)+Number.parseFloat(t.paddingRight);n.textContent="Ask for access";let a=i+12+3+n.getBoundingClientRect().width;n.textContent="Request pending";let r=i+12+3+n.getBoundingClientRect().width;n.textContent="Request declined";let o=i+12+3+n.getBoundingClientRect().width;n.remove(),a>15&&r>15&&o>15&&be({ask:Math.ceil(a),pending:Math.ceil(r),declined:Math.ceil(o)})};return t(),document.fonts?.ready.then(t),()=>{e=!1}},[F,se]),I(()=>{if(!ce)return;let e=setTimeout(()=>pe(0),E);return()=>clearTimeout(e)},[ce]),I(()=>{if(!ue)return;let e=setTimeout(()=>he(void 0),E);return()=>clearTimeout(e)},[ue]),I(()=>{if("in"!==ye)return;let e=setTimeout(()=>fe("idle"),180);return()=>clearTimeout(e)},[ye]),I(()=>{if(W){P.current&&delete P.current.color;try{let e=JSON.parse(O.getItem(W)??"null");e&&"object"==typeof e&&"color"in e&&(delete e.color,O.setItem(W,JSON.stringify(e)))}catch{}}},[O,W]);let qe=!(!V||Z&&"pending"!==Z.status&&"granted"!==Z.status),Fe=(e,t)=>{P.current={...P.current,name:e,receipt:t},W&&O.setItem(W,JSON.stringify(P.current))};I(()=>{if("cancelled"===Z?.status){P.current={...P.current,name:U,receipt:void 0};try{O.setItem(W,JSON.stringify(P.current))}catch{}Q(void 0),_(null)}},[Z,U,O,W]);let Be=()=>{if(oe.current)return oe.current;return oe.current=(async()=>{if(!J)throw new Error("Local admission client unavailable");let e,t=JSON.parse(O.getItem(W)??"null"),n=t?.colorIdentity??t?.receipt??R();P.current={name:U,receipt:t?.receipt,colorIdentity:n},O.setItem(W,JSON.stringify(P.current));try{e=await J.reserveAdmissionColor(n)}catch(t){let i=t.status;if(400!==i&&401!==i)throw t;n=R(),P.current={...P.current,colorIdentity:n},O.setItem(W,JSON.stringify(P.current)),e=await J.reserveAdmissionColor(n)}return te(e.color),ae(d(e)),n})().finally(()=>{oe.current=null}),oe.current},De=j(Be);De.current=Be,I(()=>{if(!J||!se||ne)return;let t,n=!1,i=0,a=async()=>{try{await De.current()}catch{if(n)return;t=setTimeout(()=>{a()},e(++i))}};return a(),()=>{n=!0,clearTimeout(t)}},[J,se,ne,O,W]),I(()=>{if(!se)return;let e=e=>{e.composedPath().includes(je.current)||de(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[se]),I(()=>{if(!J||!V)return;let t,n,i=!0,a=!1,r=!1,o=()=>{Ae.current+=1,P.current={...P.current,name:U,receipt:void 0};try{O.setItem(W,JSON.stringify(P.current))}catch{}Q(void 0),_(null),de(!1),ke("")},s=()=>{r=!0;let t=R(),a=0,o=async()=>{if(i)try{let e=await De.current();P.current={...P.current,name:U,receipt:t,colorIdentity:e},O.setItem(W,JSON.stringify(P.current));let n=await J.requestAdmission(t,U,e);if(!i)return;Ae.current+=1,Q(t),_(n),ke("")}catch{if(!i)return;n=setTimeout(()=>{o()},e(++a))}};o()},d=async()=>{if(a||r||Ie.current||ze.current)return;a=!0;let e=Ae.current;try{let n=await J.admissionStatus(V);if(!i||e!==Ae.current)return;if("declined"===n.status){if(Ee.current||await Ne.current,!i||e!==Ae.current)return;r=!0;let n=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,a=()=>{i&&(fe("rejected"),pe(e=>e+1),t=setTimeout(()=>{if(i){if(n)return o(),void fe("idle");fe("rejected-out"),t=setTimeout(()=>{i&&(o(),fe("in"))},N)}},E))};return void(n?a():(fe("pending-out"),t=setTimeout(a,N)))}if("expired"===n.status)return void s();if(_(n),r="cancelled"===n.status,ke(""),n.credential){Ie.current=!0;try{await(Re.current?.(n.credential)),r=!0}finally{Ie.current=!1}}}catch(t){if(!i||e!==Ae.current)return;401===t.status&&s()}finally{a=!1}};d();let l=setInterval(d,1500);return()=>{i=!1,clearInterval(l),clearTimeout(t),clearTimeout(n)}},[J,V,U,O,W]);return T("div",{ref:je,"data-devtools":"participant-admission","data-popmelt-font":"sans","data-popmelt-theme":F,style:{display:"contents"},onKeyDown:e=>{"Escape"===e.key&&(de(!1),e.stopPropagation())},children:[z("style",{children:`\n ${t}\n [data-popmelt-entry-dock$="-left"] [data-popmelt-admission-ask] {\n margin-right: 6px;\n }\n [data-popmelt-admission-ask] {\n transition: box-shadow 120ms ease, width 180ms ease;\n }\n [data-popmelt-admission-ask][data-popmelt-admission-rejection="odd"] {\n animation: popmelt-admission-rejection-odd 360ms ease-out;\n }\n [data-popmelt-admission-ask][data-popmelt-admission-rejection="even"] {\n animation: popmelt-admission-rejection-even 360ms ease-out;\n }\n [data-popmelt-admission-submit-rejection="odd"] {\n animation: popmelt-admission-rejection-odd 360ms ease-out;\n }\n [data-popmelt-admission-submit-rejection="even"] {\n animation: popmelt-admission-rejection-even 360ms ease-out;\n }\n @keyframes popmelt-admission-rejection-odd {\n 0%, 100% { transform: translateX(0); }\n 38% { transform: translateX(-3px); }\n }\n @keyframes popmelt-admission-rejection-even {\n 0%, 100% { transform: translateX(0); }\n 38% { transform: translateX(-3px); }\n }\n [data-popmelt-admission-sending-dot] {\n animation-duration: 1.2s;\n animation-iteration-count: infinite;\n animation-timing-function: step-end;\n }\n [data-popmelt-admission-sending-dot="1"] {\n animation-name: popmelt-admission-sending-dot-1;\n }\n [data-popmelt-admission-sending-dot="2"] {\n animation-name: popmelt-admission-sending-dot-2;\n }\n [data-popmelt-admission-sending-dot="3"] {\n animation-name: popmelt-admission-sending-dot-3;\n }\n @keyframes popmelt-admission-sending-dot-1 {\n 0%, 24.99% { opacity: 0; }\n 25%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-sending-dot-2 {\n 0%, 49.99% { opacity: 0; }\n 50%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-sending-dot-3 {\n 0%, 74.99% { opacity: 0; }\n 75%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-send-icon-out {\n 0%, 30% {\n opacity: 1;\n transform: translate(0, -50%);\n }\n 100% {\n opacity: 0;\n transform: translate(10px, -50%);\n }\n }\n [data-devtools="participant-admission"][data-popmelt-theme="${F}"] [data-popmelt-admission-ask]:is([aria-expanded="false"], [data-popmelt-admission-pending]):is(:hover, :focus-visible) {\n box-shadow: inset 0 0 0 100px ${Oe.softHairline};\n }\n [data-popmelt-admission-pending-label],\n [data-popmelt-admission-cancel-label],\n [data-popmelt-admission-declined-label] {\n grid-area: 1 / 1;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 3px;\n }\n [data-popmelt-admission-cancel-label] { visibility: hidden; }\n [data-popmelt-admission-ask]:is(:hover, :focus-visible, [aria-busy="true"]) [data-popmelt-admission-pending-label] { visibility: hidden; }\n [data-popmelt-admission-ask]:is(:hover, :focus-visible, [aria-busy="true"]) [data-popmelt-admission-cancel-label] { visibility: visible; }\n [data-devtools="participant-admission"][data-popmelt-theme="${F}"] input::placeholder {\n color: ${Oe.secondary};\n opacity: 1;\n }\n [data-devtools="participant-admission"] button[type="submit"] {\n -webkit-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n }\n [data-devtools="participant-admission"] button[type="submit"] > * { pointer-events: none; }\n @media (pointer: coarse) {\n [data-devtools="participant-admission"] button[type="submit"] { min-width: 44px; min-height: 44px; touch-action: manipulation; }\n [data-popmelt-admission-name-field] { font-size: 16px; }\n }\n @media (prefers-reduced-motion: reduce) {\n [data-popmelt-admission-ask] { transition: none; animation: none; }\n [data-popmelt-admission-submit-rejection] { animation: none; }\n [data-popmelt-admission-sending-dot] { animation: none; opacity: 1; }\n [data-popmelt-admission-send-icon],\n [data-popmelt-admission-sending-label] { animation: none !important; }\n }\n `}),z(n,{theme:F,themePreference:B,onThemePreferenceChange:D,deemphasizeControls:se,onCollapse:()=>de(!1),panel:se||we?T(A,{children:[se&&!qe&&T("form",{"aria-label":G?"Join session":"Ask for access","data-popmelt-font":"sans","aria-busy":le||void 0,style:{...r(F),flexWrap:"wrap",...Y&&{maxWidth:"min(320px, calc(100vw - 24px))",boxSizing:"border-box",padding:12,gap:8,borderRadius:16}},onSubmit:e=>{e.preventDefault();let t=Se.current?"enter":"send";Se.current=!1,(async e=>{if(!U.trim()||We||le||qe||ve.current)return;if(ve.current=!0,me(!0),ke(""),he(void 0),H||L){try{if(Fe(U.trim()),H)return void await H.join(U.trim());L&&await L(U.trim(),await Be())}catch(e){ke(e instanceof Error?e.message:"Could not join. Please try again.")}return ve.current=!1,void me(!1)}try{P.current=JSON.parse(O.getItem(W)??"null")}catch{}let t=!Z&&P.current?.receipt?P.current.receipt:R();try{let e=await Be();Fe(U,t),P.current={...P.current,name:U,receipt:t};let n=await J.requestAdmission(t,U.trim(),e);Q(t),X(n.name),_(n),de(!1)}catch{P.current={...P.current,name:U,receipt:t},he({target:e,pulse:++Ce.current})}finally{ve.current=!1,me(!1)}})(t)},children:[H?.projectName&&T("span",{style:{flexBasis:"100%",minWidth:0,overflowWrap:"anywhere"},children:["Join ",H.projectName]}),T("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[z(o,{"data-popmelt-entry-avatar":!0,shape:re&&"circle"!==re?re:s(0),color:ne??(We?Oe.muted:"transparent"),size:m.identitySize}),T("span",{"data-popmelt-admission-name-field":!0,style:{...Y&&{fontSize:16},display:"inline-grid",flex:"0 1 auto",minWidth:0},children:[z("span",{"aria-hidden":"true","data-popmelt-admission-name-measure":!0,style:{gridArea:"1 / 1",visibility:"hidden",whiteSpace:"pre",overflow:"hidden",paddingRight:1},children:U||"what’s your name?"}),z("input",{autoFocus:!0,"aria-label":"Your name",placeholder:"what’s your name?",autoComplete:"nickname",enterKeyHint:G?"go":"send",maxLength:48,value:U,disabled:le,onKeyDown:e=>{"Enter"===e.key&&(Se.current=!0)},onKeyUp:e=>{"Enter"===e.key&&(Se.current=!1)},onBlur:()=>{Se.current=!1},onChange:e=>{M.current=!0,X(e.target.value);try{Fe(e.target.value,P.current?.receipt)}catch{}},style:{gridArea:"1 / 1",minWidth:"100%",width:0,padding:0,border:0,borderRadius:0,background:"transparent",color:le?Oe.mutedStrong:Oe.primary,WebkitTextFillColor:le?Oe.mutedStrong:Oe.primary,caretColor:le?"transparent":Oe.primary,opacity:1,transition:"color 120ms ease",font:"inherit",fontFamily:k,outline:"none",boxShadow:"none",appearance:"none"}})]}),U.trim().length>0&&z("kbd",{"aria-hidden":"true","data-popmelt-admission-enter-hint":!0,"data-popmelt-admission-submit-rejection":"enter"===ue?.target?ue.pulse%2?"odd":"even":void 0,style:{...i(F),...c,flexShrink:0,color:Oe.primary,opacity:le?0:1,pointerEvents:le?"none":void 0,transition:"opacity 120ms ease"},children:"enter"})]}),T(p,{variant:"custom",type:"submit",disabled:le||We||!U.trim(),"aria-label":le?"Sending…":G?"Join session":"Send request",onPointerDown:e=>{"mouse"===e.pointerType&&0===e.button&&e.preventDefault()},"aria-keyshortcuts":"Enter","aria-busy":le||void 0,"data-popmelt-admission-submit-rejection":"send"===ue?.target?ue.pulse%2?"odd":"even":void 0,style:{...a(F),...Y&&{minWidth:44,minHeight:44,borderRadius:10},position:"relative",boxSizing:"border-box",overflow:"hidden",fontSize:12,color:le||!U.trim()?Oe.muted:Oe.primary,transition:"color 120ms ease"},children:[z("span",{"aria-hidden":"true","data-popmelt-admission-submit-sizer":!0,style:{display:le?"none":"block",width:14,height:14}}),T("span",{"aria-hidden":"true","data-popmelt-admission-submit-content":!0,style:{position:le?"static":"absolute",inset:0,pointerEvents:"none"},children:[z(b,{size:14,"data-popmelt-admission-send-icon":!0,style:{position:"absolute",top:"50%",left:"50%",marginLeft:-7,opacity:le?0:1,transform:le?"translate(10px, -50%)":"translate(0, -50%)",animation:le?"popmelt-admission-send-icon-out 260ms ease both":void 0}}),T("span",{"data-popmelt-admission-sending-label":!0,style:{display:le?"inline-block":"none",opacity:le?1:0},children:["Sending",T("span",{"data-popmelt-admission-sending-dots":!0,"aria-hidden":"true",style:{display:"inline-block"},children:[z("span",{"data-popmelt-admission-sending-dot":"1",children:"."}),z("span",{"data-popmelt-admission-sending-dot":"2",children:"."}),z("span",{"data-popmelt-admission-sending-dot":"3",children:"."})]})]})]})]}),K&&!G&&T("details",{style:{flexBasis:"100%",fontSize:12,color:Oe.secondary},children:[z("summary",{style:{cursor:"pointer"},children:"Using your own project?"}),T("p",{style:{margin:"6px 0 0",overflowWrap:"anywhere"},children:["Open the URL from your project’s"," ",z("code",{children:".popmelt/participant-host-link.json"})," in this browser to link it as a host."]})]}),we&&z("span",{role:"alert",style:{flexBasis:"100%",fontSize:12},children:we})]}),!se&&we&&z("div",{role:"status",style:{...r(F),fontSize:12},children:we})]}):null,action:T(A,{children:[z("span",{"aria-hidden":"true","data-popmelt-admission-host":!0,style:{width:22,height:22,marginLeft:5,flexShrink:0,boxSizing:"border-box",border:`1px solid ${Oe.surface}`,borderRadius:"50%",background:v.activeColor,opacity:se||qe?.2:1,transition:Ee.current?"opacity 120ms ease":"none"}}),z("button",{ref:xe,type:"button","data-popmelt-font":"sans","data-popmelt-admission-ask":!0,"data-popmelt-admission-pending":qe?"":void 0,"data-popmelt-admission-declined":"rejected"===ye||"rejected-out"===ye?"":void 0,"data-popmelt-admission-rejection":ce?ce%2?"odd":"even":void 0,"data-popmelt-admission-transition":"idle"===ye?void 0:ye,"data-popmelt-entry-control":!0,"aria-expanded":qe?void 0:se,"aria-label":"rejected"===ye||"rejected-out"===ye?"Request declined":qe?"Cancel request":void 0,"aria-describedby":qe?Te:void 0,"aria-busy":!(!qe||!le)||void 0,disabled:qe&&(le||"idle"!==ye),onClick:()=>"idle"===ye&&(qe?void(async()=>{if(J&&V&&!le&&!ze.current){ze.current=!0,Ae.current+=1,me(!0),ke("");try{let e=await J.cancelAdmission(V);_(e),de(!1)}catch{pe(e=>e+1)}finally{ze.current=!1,me(!1)}}})():(de(!se),void(se||ke("")))),"aria-description":qe?void 0:G?"Enter your name to join the session.":"Ask the host to join in Suggest mode.",style:{...l(F),width:ge?ge["rejected"===ye||"rejected-out"===ye?"declined":qe?"pending":"ask"]:void 0,paddingLeft:3,overflow:"hidden",transition:"box-shadow 120ms ease, width 180ms ease",background:qe&&Z?.color?`color-mix(in srgb, ${Z.color} 10%, ${Oe.control})`:Oe.control},children:T("span",{"data-popmelt-entry-content":!0,style:{display:qe?"inline-grid":"inline-flex",alignItems:"center",gap:"inherit",opacity:"pending-out"===ye||"rejected-out"===ye?0:1,transition:Ee.current?"opacity 120ms ease":"none"},children:["rejected"===ye||"rejected-out"===ye?T("span",{id:Te,"data-popmelt-admission-declined-label":!0,"aria-hidden":"true",children:[z(h,{size:12}),"Request declined"]}):qe?T(A,{children:[T("span",{id:Te,"data-popmelt-admission-pending-label":!0,"aria-hidden":"true",children:[z(y,{size:12,style:{color:Z?.color}}),"Request pending"]}),T("span",{"data-popmelt-admission-cancel-label":!0,"aria-hidden":"true",children:[z(f,{size:12}),"Cancel request"]})]}):z(g,{size:12,"aria-hidden":"true","data-popmelt-admission-wave":!0}),!qe&&"Ask for access"]})})]})})]})}export{J as a};
|
|
1
|
+
"use client";import{d as e}from"./chunk-EBESPLST.mjs";import{E as t,D as n,F as i,H as a,G as r}from"./chunk-PGIWJ37M.mjs";import{d as o}from"./chunk-VGX6J2OP.mjs";import{j as s,k as d}from"./chunk-5JAZXI47.mjs";import{j as l,a as m,i as c,k as p}from"./chunk-OOFTFGZL.mjs";import{a as u}from"./chunk-ECGXE2Z6.mjs";import{x as h,J as y,Qa as f,R as g,ya as b}from"./chunk-KE4MQBRY.mjs";import{a as v}from"./chunk-B4DYUYX4.mjs";import{c as w,a as k}from"./chunk-BH5BNULT.mjs";import{useRef as j,useState as x,useLayoutEffect as S,useId as I,useEffect as C}from"react";import{jsxs as T,jsx as z,Fragment as A}from"react/jsx-runtime";function E(){let e=crypto.getRandomValues(new Uint8Array(32));return{id:crypto.randomUUID(),token:Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}}var J=360,N=120;function O({client:O,storage:R,storageKey:F,onAdmitted:q,theme:L="light",themePreference:W=L,onThemePreferenceChange:B,onJoin:P,guestInvite:H,showHostLinkHelp:$=!1}){let U=j(null),X=j(!1);if(!X.current){X.current=!0;try{F&&(U.current=JSON.parse(R.getItem(F)??"null"))}catch{}}let[D,K]=x(U.current?.name??""),M=j(!1),G=!!H;S(()=>{if(G&&F&&!M.current)try{let e=JSON.parse(R.getItem(F)??"null");"string"==typeof e?.name&&K(e.name)}catch{}},[G,R,F]);let Y=!(!P&&!H),[Z,V]=x(Y?void 0:U.current?.receipt),[Q,_]=x(null),[ee,te]=x(),ne=H?.color??ee,[ie,ae]=x(),re=H?.shape??ie,oe=j(null),[se,de]=x(Y),[le,me]=x(!1),[ce,pe]=x(0),[ue,he]=x(),[ye,fe]=x("idle"),[ge,be]=x(),ve=j(!1),[we,ke]=x(""),je=j(null),xe=j(null),Se=j(!1),Ie=j(0),Ce=j(!1),Te=I(),ze=j(!1),Ae=j(0),Ee=j(q);Ee.current=q;let Je=j(!1),Ne=j(null),Oe=j(()=>{});Ne.current||(Ne.current=new Promise(e=>{Oe.current=e}));let Re=u[L],Fe=!G&&se&&!ne;C(()=>{let e,t,n=!1,i=()=>{n||(n=!0,Je.current=!0,Oe.current())};"function"==typeof requestAnimationFrame&&(e=requestAnimationFrame(()=>{t=requestAnimationFrame(i)}));let a=window.setTimeout(i,64);return()=>{void 0!==e&&cancelAnimationFrame(e),void 0!==t&&cancelAnimationFrame(t),window.clearTimeout(a),i()}},[]),C(()=>w(document),[]),S(()=>{let e=!0,t=()=>{if(!e||!xe.current)return;let t=getComputedStyle(xe.current),n=document.createElement("span");Object.assign(n.style,{position:"fixed",visibility:"hidden",pointerEvents:"none",whiteSpace:"nowrap",fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight,lineHeight:t.lineHeight}),document.body.append(n);let i=Number.parseFloat(t.paddingLeft)+Number.parseFloat(t.paddingRight);n.textContent="Ask for access";let a=i+12+3+n.getBoundingClientRect().width;n.textContent="Request pending";let r=i+12+3+n.getBoundingClientRect().width;n.textContent="Request declined";let o=i+12+3+n.getBoundingClientRect().width;n.remove(),a>15&&r>15&&o>15&&be({ask:Math.ceil(a),pending:Math.ceil(r),declined:Math.ceil(o)})};return t(),document.fonts?.ready.then(t),()=>{e=!1}},[L,se]),C(()=>{if(!ce)return;let e=setTimeout(()=>pe(0),J);return()=>clearTimeout(e)},[ce]),C(()=>{if(!ue)return;let e=setTimeout(()=>he(void 0),J);return()=>clearTimeout(e)},[ue]),C(()=>{if("in"!==ye)return;let e=setTimeout(()=>fe("idle"),180);return()=>clearTimeout(e)},[ye]),C(()=>{if(F){U.current&&delete U.current.color;try{let e=JSON.parse(R.getItem(F)??"null");e&&"object"==typeof e&&"color"in e&&(delete e.color,R.setItem(F,JSON.stringify(e)))}catch{}}},[R,F]);let qe=!(!Z||Q&&"pending"!==Q.status&&"granted"!==Q.status),Le=(e,t)=>{U.current={...U.current,name:e,receipt:t},F&&R.setItem(F,JSON.stringify(U.current))};C(()=>{if("cancelled"===Q?.status){U.current={...U.current,name:D,receipt:void 0};try{R.setItem(F,JSON.stringify(U.current))}catch{}V(void 0),_(null)}},[Q,D,R,F]);let We=()=>{if(oe.current)return oe.current;return oe.current=(async()=>{if(!O)throw new Error("Local admission client unavailable");let e,t=JSON.parse(R.getItem(F)??"null"),n=t?.colorIdentity??t?.receipt??E();U.current={name:D,receipt:t?.receipt,colorIdentity:n},R.setItem(F,JSON.stringify(U.current));try{e=await O.reserveAdmissionColor(n)}catch(t){let i=t.status;if(400!==i&&401!==i)throw t;n=E(),U.current={...U.current,colorIdentity:n},R.setItem(F,JSON.stringify(U.current)),e=await O.reserveAdmissionColor(n)}return te(e.color),ae(d(e)),n})().finally(()=>{oe.current=null}),oe.current},Be=j(We);Be.current=We,C(()=>{if(!O||!se||ne)return;let t,n=!1,i=0,a=async()=>{try{await Be.current()}catch{if(n)return;t=setTimeout(()=>{a()},e(++i))}};return a(),()=>{n=!0,clearTimeout(t)}},[O,se,ne,R,F]),C(()=>{if(!se)return;let e=e=>{e.composedPath().includes(je.current)||de(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[se]),C(()=>{if(!O||!Z)return;let t,n,i=!0,a=!1,r=!1,o=()=>{Ae.current+=1,U.current={...U.current,name:D,receipt:void 0};try{R.setItem(F,JSON.stringify(U.current))}catch{}V(void 0),_(null),de(!1),ke("")},s=()=>{r=!0;let t=E(),a=0,o=async()=>{if(i)try{let e=await Be.current();U.current={...U.current,name:D,receipt:t,colorIdentity:e},R.setItem(F,JSON.stringify(U.current));let n=await O.requestAdmission(t,D,e);if(!i)return;Ae.current+=1,V(t),_(n),ke("")}catch{if(!i)return;n=setTimeout(()=>{o()},e(++a))}};o()},d=async()=>{if(a||r||Ce.current||ze.current)return;a=!0;let e=Ae.current;try{let n=await O.admissionStatus(Z);if(!i||e!==Ae.current)return;if("declined"===n.status){if(Je.current||await Ne.current,!i||e!==Ae.current)return;r=!0;let n=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,a=()=>{i&&(fe("rejected"),pe(e=>e+1),t=setTimeout(()=>{if(i){if(n)return o(),void fe("idle");fe("rejected-out"),t=setTimeout(()=>{i&&(o(),fe("in"))},N)}},J))};return void(n?a():(fe("pending-out"),t=setTimeout(a,N)))}if("expired"===n.status)return void s();if(_(n),r="cancelled"===n.status,ke(""),n.credential){Ce.current=!0;try{await(Ee.current?.(n.credential)),r=!0}finally{Ce.current=!1}}}catch(t){if(!i||e!==Ae.current)return;401===t.status&&s()}finally{a=!1}};d();let l=setInterval(d,1500);return()=>{i=!1,clearInterval(l),clearTimeout(t),clearTimeout(n)}},[O,Z,D,R,F]);return T("div",{ref:je,"data-devtools":"participant-admission","data-popmelt-font":"sans","data-popmelt-theme":L,style:{display:"contents"},onKeyDown:e=>{"Escape"===e.key&&(de(!1),e.stopPropagation())},children:[z("style",{children:`\n ${t}\n [data-popmelt-entry-dock$="-left"] [data-popmelt-admission-ask] {\n margin-right: 6px;\n }\n [data-popmelt-admission-ask] {\n transition: box-shadow 120ms ease, width 180ms ease;\n }\n [data-popmelt-admission-ask][data-popmelt-admission-rejection="odd"] {\n animation: popmelt-admission-rejection-odd 360ms ease-out;\n }\n [data-popmelt-admission-ask][data-popmelt-admission-rejection="even"] {\n animation: popmelt-admission-rejection-even 360ms ease-out;\n }\n [data-popmelt-admission-submit-rejection="odd"] {\n animation: popmelt-admission-rejection-odd 360ms ease-out;\n }\n [data-popmelt-admission-submit-rejection="even"] {\n animation: popmelt-admission-rejection-even 360ms ease-out;\n }\n @keyframes popmelt-admission-rejection-odd {\n 0%, 100% { transform: translateX(0); }\n 38% { transform: translateX(-3px); }\n }\n @keyframes popmelt-admission-rejection-even {\n 0%, 100% { transform: translateX(0); }\n 38% { transform: translateX(-3px); }\n }\n [data-popmelt-admission-sending-dot] {\n animation-duration: 1.2s;\n animation-iteration-count: infinite;\n animation-timing-function: step-end;\n }\n [data-popmelt-admission-sending-dot="1"] {\n animation-name: popmelt-admission-sending-dot-1;\n }\n [data-popmelt-admission-sending-dot="2"] {\n animation-name: popmelt-admission-sending-dot-2;\n }\n [data-popmelt-admission-sending-dot="3"] {\n animation-name: popmelt-admission-sending-dot-3;\n }\n @keyframes popmelt-admission-sending-dot-1 {\n 0%, 24.99% { opacity: 0; }\n 25%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-sending-dot-2 {\n 0%, 49.99% { opacity: 0; }\n 50%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-sending-dot-3 {\n 0%, 74.99% { opacity: 0; }\n 75%, 100% { opacity: 1; }\n }\n @keyframes popmelt-admission-send-icon-out {\n 0%, 30% {\n opacity: 1;\n transform: translate(0, -50%);\n }\n 100% {\n opacity: 0;\n transform: translate(10px, -50%);\n }\n }\n [data-devtools="participant-admission"][data-popmelt-theme="${L}"] [data-popmelt-admission-ask]:is([aria-expanded="false"], [data-popmelt-admission-pending]):is(:hover, :focus-visible) {\n box-shadow: inset 0 0 0 100px ${Re.softHairline};\n }\n [data-popmelt-admission-pending-label],\n [data-popmelt-admission-cancel-label],\n [data-popmelt-admission-declined-label] {\n grid-area: 1 / 1;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 3px;\n }\n [data-popmelt-admission-cancel-label] { visibility: hidden; }\n [data-popmelt-admission-ask]:is(:hover, :focus-visible, [aria-busy="true"]) [data-popmelt-admission-pending-label] { visibility: hidden; }\n [data-popmelt-admission-ask]:is(:hover, :focus-visible, [aria-busy="true"]) [data-popmelt-admission-cancel-label] { visibility: visible; }\n [data-devtools="participant-admission"][data-popmelt-theme="${L}"] input::placeholder {\n color: ${Re.secondary};\n opacity: 1;\n }\n [data-devtools="participant-admission"] button[type="submit"] {\n -webkit-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n }\n [data-devtools="participant-admission"] button[type="submit"] > * { pointer-events: none; }\n @media (pointer: coarse) {\n [data-devtools="participant-admission"] button[type="submit"] { min-width: 44px; min-height: 44px; touch-action: manipulation; }\n [data-popmelt-admission-name-field] { font-size: 16px; }\n }\n @media (prefers-reduced-motion: reduce) {\n [data-popmelt-admission-ask] { transition: none; animation: none; }\n [data-popmelt-admission-submit-rejection] { animation: none; }\n [data-popmelt-admission-sending-dot] { animation: none; opacity: 1; }\n [data-popmelt-admission-send-icon],\n [data-popmelt-admission-sending-label] { animation: none !important; }\n }\n `}),z(n,{theme:L,themePreference:W,onThemePreferenceChange:B,deemphasizeControls:se,onCollapse:()=>de(!1),panel:se||we?T(A,{children:[se&&!qe&&T("form",{"aria-label":Y?"Join session":"Ask for access","data-popmelt-font":"sans","aria-busy":le||void 0,style:{...r(L),flexWrap:"wrap",...G&&{maxWidth:"min(320px, calc(100vw - 24px))",boxSizing:"border-box",padding:12,gap:8,borderRadius:16}},onSubmit:e=>{e.preventDefault();let t=Se.current?"enter":"send";Se.current=!1,(async e=>{if(!D.trim()||Fe||le||qe||ve.current)return;if(ve.current=!0,me(!0),ke(""),he(void 0),H||P){try{if(Le(D.trim()),H)return void await H.join(D.trim());P&&await P(D.trim(),await We())}catch(e){ke(e instanceof Error?e.message:"Could not join. Please try again.")}return ve.current=!1,void me(!1)}try{U.current=JSON.parse(R.getItem(F)??"null")}catch{}let t=!Q&&U.current?.receipt?U.current.receipt:E();try{let e=await We();Le(D,t),U.current={...U.current,name:D,receipt:t};let n=await O.requestAdmission(t,D.trim(),e);V(t),K(n.name),_(n),de(!1)}catch{U.current={...U.current,name:D,receipt:t},he({target:e,pulse:++Ie.current})}finally{ve.current=!1,me(!1)}})(t)},children:[H?.projectName&&T("span",{style:{flexBasis:"100%",minWidth:0,overflowWrap:"anywhere"},children:["Join ",H.projectName]}),T("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[z(o,{"data-popmelt-entry-avatar":!0,shape:re&&"circle"!==re?re:s(0),color:ne??(Fe?Re.muted:"transparent"),size:m.identitySize}),T("span",{"data-popmelt-admission-name-field":!0,style:{...G&&{fontSize:16},display:"inline-grid",flex:"0 1 auto",minWidth:0},children:[z("span",{"aria-hidden":"true","data-popmelt-admission-name-measure":!0,style:{gridArea:"1 / 1",visibility:"hidden",whiteSpace:"pre",overflow:"hidden",paddingRight:1},children:D||"what’s your name?"}),z("input",{autoFocus:!0,"aria-label":"Your name",placeholder:"what’s your name?",autoComplete:"nickname",enterKeyHint:Y?"go":"send",maxLength:48,value:D,disabled:le,onKeyDown:e=>{"Enter"===e.key&&(Se.current=!0)},onKeyUp:e=>{"Enter"===e.key&&(Se.current=!1)},onBlur:()=>{Se.current=!1},onChange:e=>{M.current=!0,K(e.target.value);try{Le(e.target.value,U.current?.receipt)}catch{}},style:{gridArea:"1 / 1",minWidth:"100%",width:0,padding:0,border:0,borderRadius:0,background:"transparent",color:le?Re.mutedStrong:Re.primary,WebkitTextFillColor:le?Re.mutedStrong:Re.primary,caretColor:le?"transparent":Re.primary,opacity:1,transition:"color 120ms ease",font:"inherit",fontFamily:k,outline:"none",boxShadow:"none",appearance:"none"}})]}),D.trim().length>0&&z("kbd",{"aria-hidden":"true","data-popmelt-admission-enter-hint":!0,"data-popmelt-admission-submit-rejection":"enter"===ue?.target?ue.pulse%2?"odd":"even":void 0,style:{...i(L),...c,flexShrink:0,color:Re.primary,opacity:le?0:1,pointerEvents:le?"none":void 0,transition:"opacity 120ms ease"},children:"enter"})]}),T(p,{variant:"custom",type:"submit",disabled:le||Fe||!D.trim(),"aria-label":le?"Sending…":Y?"Join session":"Send request",onPointerDown:e=>{"mouse"===e.pointerType&&0===e.button&&e.preventDefault()},"aria-keyshortcuts":"Enter","aria-busy":le||void 0,"data-popmelt-admission-submit-rejection":"send"===ue?.target?ue.pulse%2?"odd":"even":void 0,style:{...a(L),...G&&{minWidth:44,minHeight:44,borderRadius:10},position:"relative",boxSizing:"border-box",overflow:"hidden",fontSize:12,color:le||!D.trim()?Re.muted:Re.primary,transition:"color 120ms ease"},children:[z("span",{"aria-hidden":"true","data-popmelt-admission-submit-sizer":!0,style:{display:le?"none":"block",width:14,height:14}}),T("span",{"aria-hidden":"true","data-popmelt-admission-submit-content":!0,style:{position:le?"static":"absolute",inset:0,pointerEvents:"none"},children:[z(b,{size:14,"data-popmelt-admission-send-icon":!0,style:{position:"absolute",top:"50%",left:"50%",marginLeft:-7,opacity:le?0:1,transform:le?"translate(10px, -50%)":"translate(0, -50%)",animation:le?"popmelt-admission-send-icon-out 260ms ease both":void 0}}),T("span",{"data-popmelt-admission-sending-label":!0,style:{display:le?"inline-block":"none",opacity:le?1:0},children:["Sending",T("span",{"data-popmelt-admission-sending-dots":!0,"aria-hidden":"true",style:{display:"inline-block"},children:[z("span",{"data-popmelt-admission-sending-dot":"1",children:"."}),z("span",{"data-popmelt-admission-sending-dot":"2",children:"."}),z("span",{"data-popmelt-admission-sending-dot":"3",children:"."})]})]})]})]}),$&&!Y&&T("details",{style:{flexBasis:"100%",fontSize:12,color:Re.secondary},children:[z("summary",{style:{cursor:"pointer"},children:"Using your own project?"}),T("p",{style:{margin:"6px 0 0",overflowWrap:"anywhere"},children:["Open the URL from your project’s"," ",z("code",{children:".popmelt/participant-host-link.json"})," in this browser to link it as a host."]})]}),we&&z("span",{role:"alert",style:{flexBasis:"100%",fontSize:12},children:we})]}),!se&&we&&z("div",{role:"status",style:{...r(L),fontSize:12},children:we})]}):null,action:T(A,{children:[z("span",{"aria-hidden":"true","data-popmelt-admission-host":!0,style:{width:22,height:22,marginLeft:5,flexShrink:0,boxSizing:"border-box",border:`1px solid ${Re.surface}`,borderRadius:"50%",background:v.activeColor,opacity:se||qe?.2:1,transition:Je.current?"opacity 120ms ease":"none"}}),z("button",{ref:xe,type:"button","data-popmelt-font":"sans","data-popmelt-admission-ask":!0,"data-popmelt-admission-pending":qe?"":void 0,"data-popmelt-admission-declined":"rejected"===ye||"rejected-out"===ye?"":void 0,"data-popmelt-admission-rejection":ce?ce%2?"odd":"even":void 0,"data-popmelt-admission-transition":"idle"===ye?void 0:ye,"data-popmelt-entry-control":!0,"aria-expanded":qe?void 0:se,"aria-label":"rejected"===ye||"rejected-out"===ye?"Request declined":qe?"Cancel request":void 0,"aria-describedby":qe?Te:void 0,"aria-busy":!(!qe||!le)||void 0,disabled:qe&&(le||"idle"!==ye),onClick:()=>"idle"===ye&&(qe?void(async()=>{if(O&&Z&&!le&&!ze.current){ze.current=!0,Ae.current+=1,me(!0),ke("");try{let e=await O.cancelAdmission(Z);_(e),de(!1)}catch{pe(e=>e+1)}finally{ze.current=!1,me(!1)}}})():(de(!se),void(se||ke("")))),"aria-description":qe?void 0:Y?"Enter your name to join the session.":"Ask the host to join in Suggest mode.",style:{...l(L),width:ge?ge["rejected"===ye||"rejected-out"===ye?"declined":qe?"pending":"ask"]:void 0,paddingLeft:3,overflow:"hidden",transition:"box-shadow 120ms ease, width 180ms ease",background:qe&&Q?.color?`color-mix(in srgb, ${Q.color} 10%, ${Re.control})`:Re.control},children:T("span",{"data-popmelt-entry-content":!0,style:{display:qe?"inline-grid":"inline-flex",alignItems:"center",gap:"inherit",opacity:"pending-out"===ye||"rejected-out"===ye?0:1,transition:Je.current?"opacity 120ms ease":"none"},children:["rejected"===ye||"rejected-out"===ye?T("span",{id:Te,"data-popmelt-admission-declined-label":!0,"aria-hidden":"true",children:[z(h,{size:12}),"Request declined"]}):qe?T(A,{children:[T("span",{id:Te,"data-popmelt-admission-pending-label":!0,"aria-hidden":"true",children:[z(y,{size:12,style:{color:Q?.color}}),"Request pending"]}),T("span",{"data-popmelt-admission-cancel-label":!0,"aria-hidden":"true",children:[z(f,{size:12}),"Cancel request"]})]}):z(g,{size:12,"aria-hidden":"true","data-popmelt-admission-wave":!0}),!qe&&"Ask for access"]})})]})})]})}export{O as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";var t="/__popmelt/guest";function o(o){return typeof location<"u"&&"https:"===location.protocol&&o===location.origin+t}function a(t){return/^https:\/\/g-([a-f0-9]{32})\.popmelt\.com$/.exec(t)?.[1]}function n(t){return/^https:\/\/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.trycloudflare\.com$/.test(t)}export{t as a,o as b,a as c,n as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{d as e,h as t}from"./chunk-VXRRHXUP.mjs";import{c as r}from"./chunk-WP2SHSCG.mjs";import{f as o,e as n}from"./chunk-AAMUU2QA.mjs";import{u as i,l as a,f as l,d as s,c,e as d,g as f}from"./chunk-LH7HKUCK.mjs";import{sha256Hex as p}from"./project-id.mjs";var u=("display color background-color font-family font-size font-style font-weight line-height letter-spacing text-align text-decoration-line white-space flex-direction flex-wrap flex-grow align-items justify-content row-gap column-gap "+["top","right","bottom","left"].flatMap(e=>["padding-"+e,"margin-"+e,"border-"+e+"-style","border-"+e+"-color","border-"+e+"-width"]).join(" ")+" border-top-left-radius border-top-right-radius border-bottom-left-radius border-bottom-right-radius").split(" "),h={"aspect-ratio":"auto","box-sizing":"content-box",width:"auto",height:"auto","max-width":"none","max-height":"none",transform:"none","transform-origin":"50% 50%",translate:"none",rotate:"none",scale:"none","z-index":"auto",visibility:"visible","min-height":"auto","min-width":"auto","box-shadow":"none","text-shadow":"none","text-transform":"none","word-spacing":"0px","overflow-wrap":"normal","word-break":"normal",direction:"ltr","writing-mode":"horizontal-tb","vertical-align":"baseline",opacity:"1","align-self":"auto","justify-self":"auto","align-content":"normal","justify-items":"normal","flex-shrink":"1","flex-basis":"auto",order:"0","grid-template-columns":"none","grid-template-rows":"none","grid-auto-flow":"row","grid-column-start":"auto","grid-column-end":"auto","grid-row-start":"auto","grid-row-end":"auto","overflow-x":"visible","overflow-y":"visible"},m=["top","right","bottom","left"],g=[...m,"height","width","clip"],y=["width","height","max-width","max-height","object-fit","object-position"],b=["background-size","background-position","background-repeat","background-origin","background-clip"],w=new Set([...[...u,...Object.keys(h),...m,...b,...y].map(e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())),"borderColor","borderRadius","fill","stroke","strokeWidth","strokeDasharray","strokeDashoffset"]),v=/^[a-f0-9]{64}$/,x=/^[a-zA-Z0-9 _-]{0,64}$/,N=3145728,S=new Map,E=new Map,T=new Map;function k(e){return e&&"string"==typeof e.version&&v.test(e.version)&&"string"==typeof e.variant&&x.test(e.variant)&&function(e){if(void 0===e)return!0;if("string"!=typeof e||e.length>8192)return!1;try{let t=JSON.parse(e);return null!==t&&"object"==typeof t&&!Array.isArray(t)}catch{return!1}}(e.props)&&(void 0===e.label||"string"==typeof e.label&&e.label.length<=256)&&"boolean"==typeof e.dark}function P(e,t){return new URL(n(e.location.pathname)+"_popmelt/samples/"+t+".json",e.location.origin).href}async function M(e,t){let r=S.get(t);if(r)return r;let o=P(e,t),n=E.get(o);if(n)return n;let i=(async()=>{let r=new URL("/_popmelt/samples/"+t+".json",e.location.origin).href,n=await(globalThis.caches?.open("popmelt-component-samples-v1").catch(()=>{})),i=await(n?.match(r)),a=i??await fetch(o,{redirect:"error"});if(!a.ok||Number(a.headers.get("content-length"))>N)throw Error();let l=a.body?.getReader();if(!l)throw Error();let s=0,c="",d=new TextDecoder("utf-8",{fatal:!0});for(;;){let{done:e,value:t}=await l.read();if(e)break;if(s+=t.length,s>N)throw await l.cancel(),Error();c+=d.decode(t,{stream:!0})}if(c+=d.decode(),(globalThis.crypto?.subtle?Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(c))),e=>e.toString(16).padStart(2,"0")).join(""):p(c))!==t)throw Error();let f=JSON.parse(c);if("string"!=typeof f.script||"string"!=typeof f.css)throw Error();return i||await(n?.put(r,new Response(c)).catch(()=>{})),S.size>=8&&S.delete(S.keys().next().value),S.set(t,f),T.delete(o),f})().finally(()=>E.delete(o));return E.set(o,i),i}function A(e){return"string"==typeof e&&e.length<=384&&!/[;{}\\]|(?:url|var|attr|env)\s*\(/i.test(e)}function R(e){return Array.isArray(e)&&e.length<=8&&e.every(e=>{let t=e?.timing;return!!(!(!t||"boolean"!=typeof e.paused||void 0!==e.currentTime&&!Number.isFinite(e.currentTime)||!Array.isArray(e.frames)||!e.frames.length||e.frames.length>64||!Number.isFinite(t.duration)||t.duration<0)&&Number.isFinite(t.delay)&&Number.isFinite(t.endDelay)&&("infinite"===t.iterations||Number.isFinite(t.iterations)&&t.iterations>=0)&&["normal","reverse","alternate","alternate-reverse"].includes(t.direction)&&["auto","none","forwards","backwards","both"].includes(t.fill)&&A(t.easing))&&e.frames.every((t,r)=>t&&Number.isFinite(t.offset)&&t.offset>=(e.frames[r-1]?.offset??0)&&t.offset<=1&&A(t.easing)&&Object.entries(t).every(([e,t])=>"offset"===e||"easing"===e||w.has(e)&&A(t)))})}var C=new WeakMap,D=new WeakMap;function j(e,t){for(let{frames:r,timing:o,paused:n,currentTime:i}of t){let t=e.animate(r,{id:"popmelt-sampled-motion",duration:o.duration,delay:o.delay,endDelay:o.endDelay,direction:o.direction,fill:o.fill,easing:o.easing,iterations:"infinite"===o.iterations?1/0:o.iterations});void 0!==i&&(t.currentTime=i),n&&t.pause()}}var O=new WeakMap;function V(e){let t=e.currentSrc||e.src;if(!e.complete||!e.naturalWidth||!e.naturalHeight)throw new Error("The image has not loaded.");let r=O.get(e);if(r?.src===t)return r.pixels;let o=e.ownerDocument.createElement("canvas"),n=Math.min(1,1024/Math.max(e.naturalWidth,e.naturalHeight));for(;;){o.width=Math.max(1,Math.round(e.naturalWidth*n)),o.height=Math.max(1,Math.round(e.naturalHeight*n));let r,i=o.getContext("2d");if(!i)throw new Error("The browser cannot capture this image.");i.drawImage(e,0,0,o.width,o.height);try{r=o.width*o.height<=65536?o.toDataURL("image/png"):"",(!r||r.length>24576)&&(r=o.toDataURL("image/webp",.9))}catch{throw new Error("The image host does not allow its pixels to be copied.")}if(F(r))return O.set(e,{src:t,pixels:r}),e.addEventListener("load",()=>O.delete(e),{once:!0}),r;if(1===o.width&&1===o.height)throw new Error("The browser cannot capture this image.");n/=2}}function F(e){return"string"==typeof e&&e.length<=24576&&/^data:image\/(?:png|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(e)}var L=new WeakMap;var W="http://www.w3.org/2000/svg",z=new Set("svg g path rect circle ellipse line polygon polyline defs linearGradient radialGradient stop clipPath title desc".split(" ")),I=new Set("viewBox preserveAspectRatio x y width height cx cy r rx ry x1 x2 y1 y2 d points transform pathLength gradientUnits gradientTransform spreadMethod offset fx fy fr clipPathUnits".split(" ")),H=new Set("fill stroke stop-color".split(" ")),U="fill fill-opacity fill-rule stroke stroke-width stroke-opacity stroke-linecap stroke-linejoin stroke-miterlimit stroke-dasharray stroke-dashoffset clip-rule clip-path vector-effect opacity stop-color stop-opacity display visibility".split(" "),$=/^url\(["']?#([\w.:-]+)["']?\)$/,_=/^[\w.:-]{1,128}$/;function q(e,t){return"id"===e?_.test(t):"aria-label"===e?t.length<=512:"aria-hidden"===e?"true"===t||"false"===t:I.has(e)?/^[\w\s.%+,()-]*$/.test(t):$.test(t)?H.has(e)||"clip-path"===e:"clip-path"===e?"none"===t:H.has(e)?/^(?:[a-z]+|#[a-f\d]{3,8}|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([a-z\d.\s,%/+-]+\))$/i.test(t):U.includes(e)&&/^[a-z\d.\s,%+-]+$/i.test(t)}var B=class{constructor(){this.ids=new Set,this.references=new Set,this.prefix="pm-svg-"+crypto.randomUUID()+"-"}value(e,t){if("id"===e)return this.ids.has(t)?null:(this.ids.add(t),this.prefix+t);let r=$.exec(t)?.[1];return r?(this.references.add(r),"url(#"+this.prefix+r+")"):t}complete(){return[...this.references].every(e=>this.ids.has(e))}};var J=new Set("article section aside header footer div span h1 h2 h3 h4 h5 h6 p strong em b i small blockquote ul ol li button br picture img figure figcaption code pre".split(" ")),G={color:"color",fontFamily:"font-family",fontSize:"font-size",fontWeight:"font-weight",fontStyle:"font-style",lineHeight:"line-height",letterSpacing:"letter-spacing",visibility:"visibility",fill:"fill",stroke:"stroke",strokeWidth:"stroke-width",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset"},X=new Set(["div","article","section","aside","figure"]),K=65536,Z=new Set(["width","height","max-width","max-height","min-width","min-height","transform","transform-origin","grid-template-columns","grid-template-rows",...m]);function Q(e,t){let r=e.getBoundingClientRect(),o=(e,o)=>{let n=t.getPropertyValue(e);return n.endsWith("px")?parseFloat(n)+("border-box"===t.boxSizing?0:o.reduce((e,r)=>e+(parseFloat(t.getPropertyValue("padding-"+r))||0)+(parseFloat(t.getPropertyValue("border-"+r+"-width"))||0),0)):r[e]};return{previewWidth:o("width",["left","right"]),previewHeight:o("height",["top","bottom"])}}function Y(e){return e.hasAttribute("data-popmelt-sample-version")||("http://www.w3.org/1999/xhtml"===e.namespaceURI&&J.has(e.localName)||e.namespaceURI===W&&"svg"===e.localName)&&!e.shadowRoot}function ee(e){let t=e.ownerDocument.defaultView,r=0;let o=function e(o,n,i,a){if(!t)throw new Error("The source page is no longer available.");if(n>16||++r>256)throw new Error("This subtree is too large to place in one draft.");let l=i?void 0:function(e){let t=e.getAttribute("data-popmelt-sample-version");if(null===t)return;let r={version:t,variant:e.getAttribute("data-popmelt-sample-variant")??"",props:e.getAttribute("data-popmelt-sample-props")??void 0,dark:!!e.closest(".dark")||"dark"===e.ownerDocument.defaultView?.getComputedStyle(e).colorScheme,label:(e.getAttribute("aria-label")??"").slice(0,256)};if(!k(r))throw Error("This component has no valid sample revision.");if(!S.has(t)){let r=P(e.ownerDocument,t);throw(T.get(r)??0)>Date.now()?Error("The sampled revision is unavailable."):(E.has(r)||M(e.ownerDocument,t).catch(()=>T.set(r,Date.now()+5e3)).finally(()=>{e.ownerDocument.dispatchEvent(new Event("popmelt-sample-ready"))}),Error("Loading this component for sampling."))}return r}(o),s=i??(l||o.namespaceURI!==W||"svg"!==o.localName?void 0:new B);if(s?o.namespaceURI!==W||!z.has(o.localName):!Y(o))throw new Error(`<${o.localName}> content cannot be placed as an HTML draft.`);let c=t.getComputedStyle(o),d=o.computedStyleMap?.(),f=e=>d?.get(e)?.toString()||c.getPropertyValue(e),p=i?{}:Object.fromEntries(u.map(e=>[e,c.getPropertyValue(e)]).filter(([,e])=>!!e));for(let[e,t]of Object.entries(i?{}:h)){let r=Z.has(e)?f(e):c.getPropertyValue(e);r&&r!==t&&(p[e]=r)}let g,v=i?void 0:function(e,t){let r=/^url\("(data:image\/[^"]+)"\)$/.exec(t)?.[1];if(!r)return;if(F(r))return r;let o=L.get(e);if(o?.src===r){if(o.pixels)return o.pixels;if(o.failed)throw Error("This background image could not be sampled.")}else{let t={src:r};L.set(e,t);let o=e.ownerDocument.createElement("img");o.src=r,o.decode().then(()=>{t.pixels=V(o)}).catch(()=>{t.failed=!0}).finally(()=>e.ownerDocument.dispatchEvent(new Event("popmelt-sample-ready")))}throw Error("Loading this image for sampling.")}(o,c.backgroundImage);if(v)for(let e of b)p[e]=c.getPropertyValue(e);if(s&&(g=function(e,t,r){let o={};for(let t of e.attributes){let{name:e,value:r}=t;if("href"===e||"href"===t.localName)throw new Error("This SVG references other artwork.");(I.has(e)||"id"===e||"aria-label"===e||"aria-hidden"===e)&&(o[e]=r)}for(let r of["filter","mask-image","marker-start","marker-mid","marker-end"]){let o=t.getPropertyValue(r)||e.getAttribute(r);if(o&&"none"!==o)throw new Error("This SVG uses an unsupported effect.")}if("rect"===e.localName||"svg"===e.localName)for(let r of["width","height"]){let n=e.computedStyleMap?.().get(r)?.toString()||t.getPropertyValue(r);n&&"auto"!==n&&(o[r]=n)}for(let r of U){let n=t.getPropertyValue(r)||e.getAttribute(r);n&&(o[r]=n)}for(let[e,t]of Object.entries(o))if(!q(e,t)||null===r.value(e,t))throw new Error("This SVG uses an unsupported paint or shape.");return o}(o,c,s)),!l&&"img"===o.localName){let e=o;g={src:V(e),alt:e.alt}}if(!l&&!i&&("img"===o.localName||s))for(let e of y){let t=c.getPropertyValue(e);t&&(!Z.has(e)||"img"===o.localName&&"auto"===f(e))&&(p[e]=t)}if(!i&&("relative"===c.position||n>0&&"absolute"===c.position)){p.position=c.position;for(let e of m){let t=f(e);t&&"auto"!==t&&(p[e]=t)}"absolute"===p.position&&c.clip&&"auto"!==c.clip&&(p.clip=c.clip)}if(l)return{tag:X.has(o.localName)?o.localName:"div",style:p,children:[],component:l,backgroundStill:v,...Q(o,c)};let x=function(e){let t=[];for(let r of e.getAnimations?.()??[]){if(!("animationName"in r)&&"popmelt-sampled-motion"!==r.id)continue;let o=r.effect;if(o?.target!==e||o.pseudoElement||"finished"===r.playState)continue;let n=o.getTiming(),i=o.getKeyframes().map(e=>{let t={offset:e.computedOffset,easing:e.easing??"linear"};for(let[r,o]of Object.entries(e))w.has(r)&&A(o)&&(t[r]=o);return t});i.some(e=>Object.keys(e).length>2)&&t.push({frames:i,currentTime:"number"==typeof r.currentTime?r.currentTime:void 0,paused:"paused"===r.playState,timing:{duration:Number(n.duration),delay:n.delay??0,endDelay:n.endDelay??0,iterations:n.iterations===1/0?"infinite":n.iterations??1,direction:n.direction??"normal",fill:n.fill??"none",easing:n.easing??"linear"}})}if(t.length){if(!R(t))throw Error("This animation is too complex to sample.");return t}}(o),N=new Set;if(a)for(let e of a.properties){let t=c.getPropertyValue(e),r=o.style.getPropertyValue(e)||(s?o.getAttribute(e):null);t!==a.css.getPropertyValue(e)||r&&"inherit"!==r?t&&Object.hasOwn(h,e)&&(p[e]=t):(N.add(e),e in p&&(p[e]="inherit"),g&&e in g&&(g[e]="inherit"))}for(let e of x??[])for(let t of e.frames)for(let e of Object.keys(t)){let t=G[e];t&&N.add(t)}let C=N.size?{css:c,properties:N}:void 0,D=[];for(let t of o.childNodes){if(3===t.nodeType&&t.textContent&&D.push(t.textContent),1!==t.nodeType)continue;let r=t;r.matches("[data-devtools],[data-popmelt-root],[data-popmelt-shadow-host]")||"picture"===o.localName&&"source"===r.localName||D.push(e(r,n+1,s,C))}if(s&&!i&&!s.complete())throw new Error("This SVG references artwork outside the sample.");return i?{tag:o.localName,style:p,children:D,attributes:g,motion:x}:{tag:o.localName,motion:x,backgroundStill:v,attributes:g,style:p,children:D,..."img"===o.localName&&{imageSourceHash:ie(o)},...0===n?Q(o,c):{}}}(e,0);if(JSON.stringify(o).length>K)throw new Error("This subtree is too large to place in one draft.");return o}function te(e,t,r="draft"){let o=0,n=0,i=!1;let a=function e(a,l,s){if(!a||++o>256||l>16||!(s?z.has(a.tag):J.has(a.tag)||"svg"===a.tag)||!Array.isArray(a.children)||!a.style||"object"!=typeof a.style)return null;let c=s??("svg"===a.tag?new B:void 0),d=c?t.createElementNS(W,a.tag):t.createElement(a.tag),f=a.attributes;if(void 0!==f){if(!f||"object"!=typeof f||Array.isArray(f))return null;for(let[e,t]of Object.entries(f))if("string"!=typeof t||(n+=e.length+t.length)>K)return null}if(c){if(!f||!function(e,t,r){for(let[o,n]of Object.entries(t)){if("string"!=typeof n||!q(o,n))return!1;let t=r.value(o,n);if(null===t)return!1;e.setAttribute(o,t),U.includes(o)&&e.style.setProperty(o,t)}return!0}(d,f,c))return null}else if("img"===a.tag){if(!f||!F(f.src)||"string"!=typeof f.alt||2!==Object.keys(f).length||a.children.length)return null;d.setAttribute("alt",f.alt),d.setAttribute("src",f.src)}else if(f)return null;if(void 0!==a.backgroundStill){if(!F(a.backgroundStill)||(n+=a.backgroundStill.length)>K)return null;d.style.backgroundImage='url("'+a.backgroundStill+'")'}"button"===d.localName&&d.setAttribute("type","button");let p=a.style.position;if(p&&"relative"!==p&&!(l>0&&"absolute"===p))return null;"absolute"===p&&(i=!0);for(let[e,t]of Object.entries(a.style)){if(!u.includes(e)&&!Object.hasOwn(h,e)&&(!a.backgroundStill||!b.includes(e))&&(!p||"position"!==e&&!g.includes(e))&&("img"!==a.tag&&"svg"!==a.tag||!y.includes(e))||"string"!=typeof t||t.length>1024||(n+=t.length+e.length)>K)return null;d.style.setProperty(e,t)}if("preview"===r&&!s)for(let[e,t]of[["width",a.previewWidth],["height",a.previewHeight]])"number"!=typeof t||!Number.isFinite(t)||t<0||(d.style.boxSizing="border-box",d.style[e]=t+"px",d.style.setProperty("min-"+e,"0"),d.style.setProperty("max-"+e,"none"));if(void 0!==a.component){if(c||!X.has(a.tag)||a.children.length||!k(a.component)||(n+=a.component.props?.length??0)>K)return null;(0===l||!d.style.position)&&(d.style.width=Number.isFinite(a.previewWidth)?a.previewWidth+"px":"100%",d.style.height=Number.isFinite(a.previewHeight)?a.previewHeight+"px":"100%"),d.dataset.popmeltSampleVersion=a.component.version,d.dataset.popmeltSampleVariant=a.component.variant,void 0!==a.component.props&&(d.dataset.popmeltSampleProps=a.component.props),a.component.label&&d.setAttribute("aria-label",a.component.label),function(e,t){let r=e.ownerDocument,o=r.createElement("iframe");o.title=t.label||"Sampled component",o.setAttribute("sandbox","allow-scripts"),o.referrerPolicy="no-referrer",o.style.cssText="display:block;width:100%;height:100%;border:0";let n=t.dark?"dark":"light";o.style.colorScheme=n,e.append(o),M(r,t.version).then(({script:e,css:i})=>{let a=r.createElement("div");a.id="root",a.dataset.variant=t.variant,void 0!==t.props&&(a.dataset.props=t.props),o.addEventListener("load",()=>{!1===r.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&o.animate?.([{opacity:0},{opacity:1}],{duration:160,easing:"ease-out"})},{once:!0}),o.srcdoc='<!doctype html><html class="'+(t.dark?"dark":"")+'" style="color-scheme:'+n+'"><head><meta name="color-scheme" content="'+n+"\"><meta charset=\"utf-8\"><meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'\"><style>html,body,#root{margin:0;width:100%;height:100%;overflow:hidden}*,*::before,*::after{box-sizing:border-box}"+i.replace(/<\/style/gi,"<\\/style")+"</style></head><body>"+a.outerHTML+"<script>"+e.replace(/<\/script/gi,"<\\/script")+"<\/script></body></html>"}).catch(()=>o.replaceWith(r.createTextNode("Sampled revision unavailable")))}(d,a.component)}for(let r of a.children)if("string"==typeof r){if((n+=r.length)>K)return null;d.appendChild(t.createTextNode(r))}else{let t=e(r,l+1,c);if(!t)return null;d.appendChild(t)}if(c&&!s&&!c.complete())return null;if(void 0!==a.motion){if(!R(a.motion)||(n+=JSON.stringify(a.motion).length)>K)return null;try{!function(e,t){if(!e.animate)return;let r=e.ownerDocument,o=D.get(r);if(!o&&r.defaultView?.matchMedia){let e=r.defaultView.matchMedia("(prefers-reduced-motion: reduce)"),t=new Set;e.addEventListener("change",()=>{for(let r of t){let o=r.deref();if(o?.isConnected){for(let e of o.getAnimations())"popmelt-sampled-motion"===e.id&&e.cancel();e.matches||j(o,C.get(o))}else t.delete(r)}}),o={query:e,elements:t},D.set(r,o)}if(o){if(o.elements.size%32==0)for(let e of o.elements)e.deref()||o.elements.delete(e);if(C.set(e,t),o.elements.add(new WeakRef(e)),o.query.matches)return}j(e,t)}(d,a.motion)}catch{return null}}return d}(e,0);return a&&i&&!a.style.position&&(a.style.position="relative"),a}function re(e){return`[data-pm="placed-${e}"]`}var oe=new Set("main article section aside div ul ol body header footer nav".split(" "));function ne(e,t){return oe.has(e.localName)&&!e.closest("[data-devtools],[data-popmelt-shadow-host]")&&("li"!==t||["ul","ol"].includes(e.localName))}function ie(e){let t=e.getAttribute("src")||e.getAttribute("srcset");return t?p(t):void 0}function ae(e,t){if(!e.sampledTree||!function(e,t){return"copy"===e.operation&&/^[0-9a-f-]{36}$/.test(e.id)&&e.selector===re(e.id)&&e.pathname===o(t.location?.pathname??"")}(e,t))return;let r=i([e.targetParentSelector],void 0,t);if("matched"!==r.status||r.element.querySelector(e.selector)||!ne(r.element,e.sampledTree.tag))return;let n=null;if(e.referenceSelector){let o=i([e.referenceSelector],void 0,t);if("matched"!==o.status||o.element.parentElement!==r.element)return;n="before"===e.placement?o.element:o.element.nextSibling}let a=te(e.sampledTree,t);if(a)if(a.dataset.pm="placed-"+e.id,a.dataset.popmeltPlacement=e.id,["ul","ol"].includes(r.element.localName)&&"li"!==a.localName){let o=t.createElement("li");o.dataset.popmeltPlacementItem=e.id,o.append(a),r.element.insertBefore(o,n)}else r.element.insertBefore(a,n)}function le(e,t){if(!/^[0-9a-f-]{36}$/.test(e.id)||e.selector!==re(e.id))return;let r=e.selector+`[data-popmelt-placement="${e.id}"]`,o=e.targetParentSelector.includes(" >>> ")||e.targetParentSelector.startsWith("@frame(")?a(e.targetParentSelector,t)?.querySelector(r):a(r,t);o?.parentElement?.getAttribute("data-popmelt-placement-item")===e.id?o.parentElement.remove():o?.remove()}function se(e){return e.left+e.width}function ce(e){return e.top+e.height}function de(e,t){if(0===e.length)return t;let r=Math.min(...e.map(e=>e.left)),o=Math.min(...e.map(e=>e.top));return{left:r,top:o,width:Math.max(...e.map(se))-r,height:Math.max(...e.map(ce))-o}}function fe(e){let t=[...e].sort((e,t)=>e.top-t.top||e.left-t.left),r=[];for(let e of t){let t=e.top+e.height/2,o=r.find(r=>{let o=r.top+r.height/2;return Math.abs(t-o)<=.4*Math.max(r.height,e.height)});if(!o){r.push({...e});continue}let n=Math.min(o.left,e.left),i=Math.min(o.top,e.top),a=Math.max(se(o),se(e)),l=Math.max(ce(o),ce(e));o.left=n,o.top=i,o.width=a-n,o.height=l-i}return r.sort((e,t)=>e.top-t.top||e.left-t.left)}function pe(e){return!!e&&!!e.closest("#devtools-toolbar, #devtools-scrim, #devtools-text-input, [data-devtools], [data-popmelt-panel], [data-popmelt-shadow-host]")}function ue(e,t,r){let o=e.caretPositionFromPoint?.(t,r);if(o?.offsetNode.nodeType===Node.TEXT_NODE)return{node:o.offsetNode,offset:o.offset};let n=e.caretRangeFromPoint?.(t,r);return n?.startContainer.nodeType===Node.TEXT_NODE?{node:n.startContainer,offset:n.startOffset}:null}function he(e,r,o,n=!1){return function(e,t){if(!e)return t();let r=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=r}}(o,()=>{let o=t(e,r);if(!o||pe(o))return null;let i=o?.ownerDocument??document,a=d(e,r,i),s=ue(i,a.x,a.y)?.node??null;if(s&&!o.contains(s)&&(s=null),!s){let e=o;e&&!pe(e)&&(s=function(e,t,r){let o=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}),n=o.nextNode();for(;n;){let i=n,a=e.ownerDocument.createRange();a.selectNodeContents(i);let l=Array.from(a.getClientRects());if(a.detach?.(),l.some(e=>t>=e.left&&t<=e.right&&r>=e.top&&r<=e.bottom))return i;n=o.nextNode()}return null}(e,a.x,a.y))}if(!s&&o?.closest("p")?.querySelector("[data-popmelt-empty-paragraph]"))return me(o.closest("p"));if(!s||!f(s.parentElement))return null;let c=s.parentElement;if(pe(c))return null;for(;!n&&c.parentElement&&c!==i.body;){let e=l(c).getComputedStyle(c).display,t="inline-block"===e&&1===c.childNodes.length&&c.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==e&&"contents"!==e&&!t)break;let r=c.parentElement;if(pe(r))break;if(Array.from(r.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&!!e.nodeValue?.trim())){c=r;continue}let o=l(r).getComputedStyle(r).display,n="inline-block"===o&&1===r.childNodes.length&&r.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==o&&"contents"!==o&&!n)break;c=r}let p=s.parentElement?.closest("p"),u=s.parentElement?.closest('button, input, textarea, select, [role="button"]');if(p&&(!u||!p.contains(u)))return me(p,s);let h=c.tagName.toLowerCase();if("script"===h||"style"===h||"textarea"===h||"input"===h)return null;let m=ye(c).filter(e=>!n||e.textNode===s),g=m.map(e=>e.originalText).join("");if(!g.trim())return null;let y=ge(c,s);if(!y)return null;let b=l(c).getComputedStyle(c),w=ve(m,c,b,n),{textRect:v,boundaryRect:x,boundaryRects:N,flowRect:S,firstLineIndent:E}=w;if(v.width<=0||v.height<=0)return null;let T=parseFloat(b.fontSize)||12,k="nowrap"!==b.whiteSpace&&"pre"!==b.whiteSpace&&(n?N.length>1:function(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let r=Array.from(t.getClientRects()).filter(e=>e.width>0&&e.height>0).length;return t.detach?.(),r>1}(s)||"inline"!==b.display);return{textNode:s,targetElement:c,textNodePath:y,segments:m,originalText:g,rect:v,boundaryRect:x,boundaryRects:N,flowRect:S,firstLineIndent:E,styles:b,fontSize:T,wrapsText:k,singleTextNode:n}})}function me(e,t){let r=ye(e),o=r.find(e=>e.textNode===t)??r[0];if(!o)return null;let n=l(e).getComputedStyle(e),{textRect:i,...a}=ve(r,e,n);return{...o,targetElement:e,segments:r,originalText:r.map(e=>e.originalText).join(""),styles:n,rect:i,...a,fontSize:parseFloat(n.fontSize)||12,wrapsText:"nowrap"!==n.whiteSpace&&"pre"!==n.whiteSpace}}function ge(e,t){let r=[],o=t;for(;o&&o!==e;){let e=o.parentNode;if(!e)return null;r.unshift(Array.prototype.indexOf.call(e.childNodes,o)),o=e}return o===e?r:null}function ye(e){let t=[],r=o=>{if(o.nodeType===Node.TEXT_NODE){let r=o,n=ge(e,r);return void(n&&t.push({textNode:r,textNodePath:n,originalText:r.nodeValue??""}))}if(o.nodeType!==Node.ELEMENT_NODE&&o!==e)return;let n=o.tagName?.toLowerCase();"script"===n||"style"===n||o.childNodes.forEach(r)};return e.childNodes.forEach(r),t}function be(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function we(e){let t=e.getBoundingClientRect(),r=l(e).getComputedStyle(e),o=(parseFloat(r.borderLeftWidth)||0)+(parseFloat(r.paddingLeft)||0),n=(parseFloat(r.borderRightWidth)||0)+(parseFloat(r.paddingRight)||0),i=(parseFloat(r.borderTopWidth)||0)+(parseFloat(r.paddingTop)||0),a=(parseFloat(r.borderBottomWidth)||0)+(parseFloat(r.paddingBottom)||0);return c({left:t.left+o,top:t.top+i,width:Math.max(0,t.width-o-n),height:Math.max(0,t.height-i-a)},e.ownerDocument)}function ve(e,t,r,o=!1){let n=be(s(t)),i=function(e){let t=[];for(let r of e){if(!r.textNode.isConnected||!r.originalText.trim())continue;let e=r.textNode.ownerDocument.createRange();e.selectNodeContents(r.textNode),t.push(...Array.from(e.getClientRects()).filter(e=>e.width>0&&e.height>0).map(e=>be(c(e,r.textNode.ownerDocument)))),e.detach?.()}return fe(t)}(e),a=e[0]?.textNode?function(e,t){let r=e.ownerDocument.createRange();r.selectNodeContents(e);let o=c(r.getBoundingClientRect(),e.ownerDocument);if(r.detach?.(),o.width>0&&o.height>0)return{left:o.left,top:o.top,width:o.width,height:o.height};let n=s(t);return{left:n.left,top:n.top,width:n.width,height:n.height}}(e[0].textNode,t):n,l=i.length>0?i:[a];return function({display:e,singleTextNode:t=!1,fragmentRects:r,elementRect:o,parentContentRect:n}){let i=fe(r),a=de(i,o);if(!("inline"===e&&i.length>1&&n&&n.width>0))return{textRect:a,boundaryRect:t?a:o,boundaryRects:t?i:[o],firstLineIndent:0};let l=i[0],s={left:n.left,top:l.top,width:n.width,height:Math.max(a.height,ce(a)-l.top)},c=Math.max(0,Math.min(s.width,l.left-s.left));return{textRect:a,boundaryRect:de(i,o),boundaryRects:i,flowRect:s,firstLineIndent:c}}({display:r.display,singleTextNode:o,fragmentRects:l,elementRect:n,parentContentRect:t.parentElement?we(t.parentElement):void 0})}function xe(e,t,r){if(t===r||0===e.length)return[];let o=0;for(;o<t.length&&o<r.length&&t[o]===r[o];)o+=1;let n=0;for(;n<t.length-o&&n<r.length-o&&t[t.length-1-n]===r[r.length-1-n];)n+=1;let i=o,a=t.length-n,l=r.slice(o,r.length-n),s=0,c=!1;return e.flatMap((t,r)=>{let o=s,n=o+t.originalText.length;s=n;let d=i===a;if(!(d&&(i>=o&&i<n||r===e.length-1&&i===n))&&!(!d&&n>i&&o<a))return[];let f=Math.max(0,Math.min(t.originalText.length,i-o)),p=Math.max(0,Math.min(t.originalText.length,a-o)),u=t.originalText.slice(0,f);return c||(u+=l,c=!0),u+=t.originalText.slice(p),u===t.originalText?[]:[{segment:t,modifiedText:u}]})}function Ne(e,t){return Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function Se(e,t){return e&&t?Ne(e,t):e===t}function Ee(e,t){return e.length===t.length&&e.every((e,r)=>Ne(e,t[r]))}var Te=new WeakMap;function ke(e){let t=e.closest("p");return t?Te.get(t):void 0}function Pe(e){let t=ye(e);return{root:e,rows:[e],runs:t.map(e=>[e.textNode]),paths:t.map(e=>e.textNodePath),undo:[]}}function Me(e){let t=Te.get(e)??Pe(e),r=t.runs.map((e,r)=>({path:t.paths[r],parts:e.map(e=>e.data)}));return{group:t,layout:r}}function Ae(e,t,r){let o=t.splitText(r),n=o,i=t.parentElement;for(;;){let r=i,o=i.cloneNode(!1);for(o.removeAttribute("id"),o.removeAttribute("data-pm");n.nextSibling;)o.appendChild(n.nextSibling);if(o.insertBefore(n,o.firstChild),r.after(o),e.undo.push(e=>{if(!e?.has(r)||r.contains(t))for(;o.firstChild;)r.appendChild(o.firstChild);o.remove()}),"P"===i.tagName){o.dataset.popmeltParagraphContinuation="",e.rows.splice(e.rows.indexOf(r)+1,0,o),Te.set(o,e);break}n=o,i=r.parentElement}return o}function Re(e,t){let r=Te.get(e);if(r&&r.root===e){for(let e of r.rows)e.querySelector("br[data-popmelt-empty-paragraph]")?.remove(),Te.delete(e);for(let e of r.undo.reverse())e(t)}}function Ce(e,t){if("P"!==e.tagName)return;let r=Te.get(e);if((!r||r.root===e)&&(r&&!r.runs.every((e,r)=>e.length===t[r]?.parts.length)&&(Re(e),r=void 0),r??(r=Pe(e)),r.paths.length===t.length&&t.every((e,t)=>e.parts.length&&e.path.join(".")===r.paths[t].join(".")))){if(!Te.has(e)){Te.set(e,r);for(let e=0;e<t.length;e++){let o=r.runs[e],n=o[0],i=n.data;r.undo.push(e=>{e?.has(n)||(n.data=i);for(let e of o.slice(1))e.remove()});let a=t[e].parts;for(let e=1;e<a.length;e++){let t=o[e-1];o.push(Ae(r,t,t.length))}}}r.runs.forEach((e,r)=>e.forEach((e,o)=>{let n=t[r].parts[o];e.data!==n&&(e.data=n)}));for(let e of r.rows){let t=e.querySelector("br[data-popmelt-empty-paragraph]");if(e.textContent||t||e.querySelector("br,img,svg,input"))e.textContent&&t&&t.remove();else{let t=e.ownerDocument.createElement("br");t.dataset.popmeltEmptyParagraph="",e.appendChild(t)}}return r.lastLayout=t,r}}var De=new WeakMap,je=new WeakMap;function Oe(e,t){if(r(t))for(let[r,o]of je.get(e)??[])o.value?t.style.setProperty(r,o.value,o.priority):t.style.removeProperty(r)}function Ve(e,t){De.set(e,new Set(t))}function Fe(e){De.delete(e)}function Le(e,t){return r(e)&&(De.get(e)?.has(t)??!1)}function We(e){let t=e.sticker;return t?"padding"===t.family||"margin"===t.family?"all"===t.subproperty?10:"x"===t.subproperty||"y"===t.subproperty?20:30:"radius"===t.family||"border"===t.family?"all"===t.subproperty?10:20:10:0}function ze(e){return e.changes.map((e,t)=>({change:e,index:t})).sort((e,t)=>We(e.change)-We(t.change)||e.index-t.index).map(({change:e})=>e)}function Ie(e,t,o){if(r(e)){let r=je.get(e);r||(r=new Map,je.set(e,r)),r.has(t)||r.set(t,{value:e.style.getPropertyValue(t),priority:e.style.getPropertyPriority(t)}),e.style.setProperty(t,o,"important")}}function He(e,t,o,n=!1){if(r(e)){let r=n?je.get(e)?.get(t):void 0;r?.value?e.style.setProperty(t,r.value,r.priority):e.style.removeProperty(t),je.get(e)?.delete(t)}}function Ue(t){let r=e(t.selector);if(!r&&t.durableSelector&&(r=e(t.durableSelector),r)){let e=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];e&&r.setAttribute("data-pm",e)}return r}function $e(e){for(let t of e){let e=Ue(t);if(e)for(let r of ze(t))Le(e,r.property)||Ie(e,r.property,r.modified)}}function _e(t,r=!1){for(let o of t){let t=e(o.selector);if(t)for(let e of o.changes)Le(t,e.property)||He(t,e.property,e.original,r)}}function qe(t){let r=e(t.selector);if(!r&&t.durableSelector&&(r=e(t.durableSelector),r)){let e=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];e&&r.setAttribute("data-pm",e)}return r}function Be(e,t){let r=e;for(let e of t)r=r?.childNodes[e]??null;return r?.nodeType===Node.TEXT_NODE?r:null}function Je(e){for(let t of e){if(t.captured)continue;let e=qe(t);if(!e)continue;if(t.paragraphs&&"P"===e.tagName){let r=e;if(!ke(r)&&JSON.stringify(Me(r).layout)!==JSON.stringify(t.paragraphs.before))continue;Ce(r,t.paragraphs.after);continue}let r=Be(e,t.textNodePath);r&&r.nodeValue===t.original&&r.nodeValue!==t.modified&&(r.nodeValue=t.modified)}}function Ge(e){for(let t of[...e].reverse()){if(t.captured)continue;let e=qe(t);if(!e)continue;if(t.paragraphs&&"P"===e.tagName){Re(e),t.paragraphs.before.some(e=>e.parts.length>1)&&Ce(e,t.paragraphs.before);continue}let r=Be(e,t.textNodePath);r&&r.nodeValue===t.modified&&r.nodeValue!==t.original&&(r.nodeValue=t.original)}}function Xe(e,t){let r=new Set(t);Ge(e.filter(e=>!(r.has(e)||e.paragraphs&&t.some(t=>t.paragraphs&&t.selector===e.selector&&!t.captured)))),Je(t)}function Ke(t,r){if(!t)return null;let o=e(t);if(!o&&r&&(o=e(r),o)){let e=t.match(/\[data-pm="([^"]+)"\]/)?.[1];e&&o.setAttribute("data-pm",e)}return o}function Ze(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(e=>e.removeAttribute("data-pm"))}function Qe(e,t){let r=t.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&e.setAttribute("data-pm",r)}function Ye(e,t,r){let o=Array.from(e.children).filter(e=>e!==t),n=Math.max(0,Math.min(r,o.length));e.insertBefore(t,o[n]??null)}function et(e){for(let t of e){if(t.sampledTree){ae(t,document);continue}let e=Ke(t.targetParentSelector,t.targetParentDurableSelector);if(!e)continue;if("move"===t.operation){let r=Ke(t.selector,t.durableSelector);if(!r||r===e||r.contains(e))continue;Ye(e,r,t.targetIndex);continue}if(Ke(t.selector,t.durableSelector))continue;let r=Ke(t.sourceSelector,t.sourceDurableSelector);if(!r)continue;let o=r.cloneNode(!0);o instanceof Element&&(Ze(o),Qe(o,t.selector),Ye(e,o,t.targetIndex))}}function tt(e,t){let r=0;for(;r<e.length&&r<t.length;){let o=e[r],n=t[r];if(o!==n&&(o.id!==n.id||JSON.stringify(o)!==JSON.stringify(n)))break;r++}return rt(e.slice(r)),t.filter((e,t)=>t>=r||!!e.sampledTree)}function rt(e){for(let t of[...e].reverse()){if(t.sampledTree){le(t,document);continue}if("copy"===t.operation){Ke(t.selector,t.durableSelector)?.remove();continue}let e=Ke(t.selector,t.durableSelector),r=Ke(t.originalParentSelector,t.originalParentDurableSelector);!e||!r||e===r||e.contains(r)||Ye(r,e,t.originalIndex??r.children.length)}}export{Ie as A,Ue as B,$e as C,_e as D,qe as E,Be as F,Je as G,Ge as H,Xe as I,et as J,tt as K,rt as L,Y as a,ee as b,te as c,re as d,ne as e,ie as f,ae as g,le as h,de as i,fe as j,pe as k,ue as l,he as m,me as n,ve as o,xe as p,Ne as q,Se as r,Ee as s,ke as t,Me as u,Re as v,Ce as w,Oe as x,Ve as y,Fe as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{p as t,r as e,f as n}from"./chunk-YTIDSDPP.mjs";import{X as o,A as i,a as r}from"./chunk-KF35YUNZ.mjs";import{a}from"./chunk-VBH2YQLG.mjs";import{f as l}from"./chunk-AAMUU2QA.mjs";import{l as s,v as c,d,i as m,m as u}from"./chunk-LH7HKUCK.mjs";import{destroyContext as h,createContext as f,domToCanvas as g}from"modern-screenshot";function p(){return performance.now()+5e3}async function w(t,e){let n,o=t-performance.now(),i=()=>new Error("Visual capture timed out");if(o<=0)throw i();try{return await Promise.race([new Promise((t,e)=>{n=setTimeout(()=>e(i()),o)}),e()])}finally{clearTimeout(n)}}function b(t,e){return`[${t}="${typeof CSS<"u"&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}"]`}function y(t){let e=t.elements?.[0],n=e?.sourceElement?.dataAttributes,o=n?.["data-popmelt-media-id"]??n?.["data-popmelt-see-id"]??e?.dataAttributes?.["data-popmelt-media-id"]??e?.dataAttributes?.["data-popmelt-see-id"];if(o&&!t.linkedSelector?.startsWith("@frame(")&&!e?.selector.startsWith("@frame(")){let t=s(b("data-popmelt-media-id",o));if(t)return t;let e=s(b("data-popmelt-see-id",o));if(e)return e}return c(t.linkedSelector,e)}var x="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",M=["position","inset","top","right","bottom","left","z-index","display","visibility","opacity","overflow","overflow-x","overflow-y","box-sizing","box-decoration-break","float","clear","width","min-width","max-width","height","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-width","border-style","border-color","border-top","border-right","border-bottom","border-left","border-radius","outline","outline-offset","box-shadow","background","background-color","background-image","background-size","background-position","background-repeat","background-clip","background-origin","color","font","font-family","font-size","font-style","font-weight","font-stretch","font-variant","line-height","letter-spacing","text-align","text-decoration","text-indent","text-overflow","text-shadow","text-transform","white-space","word-break","overflow-wrap","vertical-align","direction","writing-mode","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","align-content","align-items","align-self","justify-content","justify-items","justify-self","gap","row-gap","column-gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-row","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","order","columns","column-count","column-fill","column-rule","column-span","column-width","list-style","list-style-image","list-style-position","list-style-type","object-fit","object-position","aspect-ratio","transform","transform-box","transform-origin","transform-style","perspective","perspective-origin","backface-visibility","clip","clip-path","filter","backdrop-filter","mix-blend-mode","isolation","mask","mask-image","mask-position","mask-repeat","mask-size","content","quotes","counter-increment","counter-reset","appearance","accent-color","caret-color","cursor","pointer-events","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity"];async function v(t,e){try{let e=await t();if(e)return e}catch{}return e()}var A=new Map,k=new WeakMap,S=1;function C(){return typeof performance<"u"?performance.now():Date.now()}function P(t){if(void 0!==t?.debug)return t.debug;if(typeof window>"u")return!1;try{return"true"===window.localStorage.getItem("popmelt:screenshot-debug")}catch{return!1}}function I(t,e){let n=null;return async o=>{if(!E(o))return!1;n??(n=Date.now()+t);let i=n-Date.now();if(i<=0)return e(),x;let r=new AbortController,a=setTimeout(()=>r.abort(),i);try{let t=await fetch(o,{cache:"force-cache",mode:"cors",signal:r.signal});if(!t.ok)throw new Error(`Asset returned ${t.status}`);return await function(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result)),o.onerror=()=>n(o.error??new Error("Asset could not be read")),o.readAsDataURL(t)})}(await t.blob())}catch{return e(),x}finally{clearTimeout(a)}}}function R(t,e,n){let o=Math.min(e,n);return{top:Math.max(0,Math.min(t,n-o)),height:o,annotations:[]}}function E(t){if(typeof window>"u")return!1;try{let e=new URL(t,window.location.href);return("http:"===e.protocol||"https:"===e.protocol)&&e.origin!==window.location.origin}catch{return!1}}function j(t){let e=document.createElement("canvas").getContext("2d");return e?(e.fillStyle=t,e.fillStyle):"#888888"}function D(t,e=[],n,o,i=[],r=[],a){let l=new Map,s=[];for(let e of t)if(e.groupId){let t=l.get(e.groupId)||[];t.push(e),l.set(e.groupId,t)}else s.push(e);let c=[];for(let[t,e]of l){let t=e.find(t=>"text"!==t.type),n=e.find(t=>"text"===t.type);if(t){let e=t.linkedSelector||n?.linkedSelector,o=n?.imageCount||t.imageCount,i=n?.attachments||t.attachments,r=n?.interactionEpisode||t.interactionEpisode,a=t.pathname||n?.pathname;c.push({id:t.id,type:t.type,instruction:n?.text,...e?{linkedSelector:e}:{},...t.target||n?.target?{target:t.target??n?.target}:{},...a?{pathname:a}:{},elements:t.elements||[],...o?{imageCount:o}:{},...i?.length?{attachments:i}:{},...r?{interactionEpisode:r}:{}})}}for(let t of s)c.push({id:t.id,type:t.type,instruction:"text"===t.type?t.text:void 0,...t.linkedSelector?{linkedSelector:t.linkedSelector}:{},...t.target?{target:t.target}:{},...t.pathname?{pathname:t.pathname}:{},elements:t.elements||[],...t.region?{region:t.region}:{},...t.imageCount?{imageCount:t.imageCount}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}});return{timestamp:(new Date).toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:c,styleModifications:e,...i.length>0?{textModifications:i}:{},...r.length>0?{domModifications:r}:{},...n?{inspectedElement:n}:{},...o&&o.length>0?{spacingTokenChanges:o}:{},...a?{meta:a}:{}}}function L(t,e){if(!e&&"text"===t.type&&t.linkedSelector&&!t.target&&!t.region)return null;if(e&&"text"===t.type&&!t.region){let n=Math.min(e.height,.75*window.innerHeight),o="bottom-left"===t.linkedAnchor?e.y+e.height-n:e.y;return{minX:e.x,minY:o,maxX:e.x+e.width,maxY:o+n}}if(!t.points||0===t.points.length)return null;let n=[...t.points,...t.region?.points??[]],o=n.map(t=>t.x),i=n.map(t=>t.y);return{minX:Math.min(...o),minY:Math.min(...i),maxX:Math.max(...o),maxY:Math.max(...i)}}function U(t){let e=d(t),n=function(t,e){let n=m(e,t.ownerDocument),{left:o,right:i,top:r,bottom:a}=n;for(let e=u(t);e&&e!==t.ownerDocument.documentElement&&e!==t.ownerDocument.body;e=u(e)){let t=getComputedStyle(e);if("visible"===t.overflowX&&"visible"===t.overflowY)continue;let n=d(e);"visible"!==t.overflowX&&(o=Math.max(o,n.left),i=Math.min(i,n.right)),"visible"!==t.overflowY&&(r=Math.max(r,n.top),a=Math.min(a,n.bottom))}return new DOMRect(o,r,Math.max(0,i-o),Math.max(0,a-r))}(t,e),r=(new DOMMatrix).translate(window.scrollX,window.scrollY),a=new Path2D,l=t.getAttribute("data-popmelt-subject-outline");if(l&&t.hasAttribute("data-popmelt-subject-projection")){let t=new Path2D("M"+l.trim().split(/\s+/).join("L")+"Z");a.addPath(t,r.translate(e.left,e.top).scale(e.width,e.height))}else{let e=!1;o(t,"#000",0,"solid",t=>{let n=t.getScreenCTM();if(n)for(let o of t.querySelectorAll("path")){let t=o.getAttribute("d");t&&(a.addPath(new Path2D(t),r.multiply(n)),e=!0)}})?.abort(),e||a.addPath(new Path2D(i(t)),r)}return{x:n.left+r.e,y:n.top+r.f,width:n.width,height:n.height,contour:a,clipped:n.left!==e.left||n.top!==e.top||n.width!==e.width||n.height!==e.height}}function Y(e,o,i,a,l,s,c=window.scrollX){let d=e.canvas.width/a,m=e.canvas.height/a;e.save(),e.scale(a,a),e.save(),e.translate(-c,-i),e.lineWidth=1,e.setLineDash([...r]);for(let t of o){let n=l.get(t.id);n&&(e.save(),n.clipped&&(e.beginPath(),e.rect(n.x,n.y,n.width,n.height),e.clip()),e.fillStyle=e.strokeStyle=t.color,e.globalAlpha=.05,e.fill(n.contour),e.globalAlpha=1,e.stroke(n.contour),e.restore())}e.restore();let u=t=>({x:t.x-c,y:t.y-i});for(let r of o){let o=r.points.map(u),a=r.linkedAnchor;if("text"===r.type){let t=l.get(r.id),e=L(r,t);if(!e||e.maxX<c||e.minX>=c+d||e.maxY<i||e.minY>=i+m)continue;if(t&&!r.region){let e=t.y-i,r=e+t.height,l="bottom-left"===a||!a&&e<22+n,s=l?r+n:e-22-n;a=l?"bottom-left":"top-left",o=[{x:Math.max(0,t.x-c)+8,y:s+4}]}}t(e,{...r,points:o,linkedAnchor:a,...r.region?{region:{...r.region,points:r.region.points.map(u)}}:{}},s?.get(r.id),{avoidBottom:m})}e.restore()}async function O(t,e,n=[],o){let i=function(t,e,n){let o=k.get(t);o||(o=S++,k.set(t,o));let i=e.filter(t=>"pending"===(t.status??"pending")).map(t=>JSON.stringify([t.id,t.type,t.text,t.color,t.fontSize,t.strokeWidth,t.points,t.region,t.linkedSelector,t.linkedAnchor,t.pathname,t.groupId,n?.annotationNumbers?.get(t.id)])).join("|");return[o,window.location.href,window.innerWidth,window.innerHeight,n?.dpr??window.devicePixelRatio??1,window.scrollX,window.scrollY,!!n?.viewportOnly,i].join("::")}(t,n,o),r=A.get(i);if(r)return P(o)&&console.debug("[Screenshot] Reusing in-flight capture",i),r;let a=z(t,n,o).finally(()=>A.delete(i));return A.set(i,a),a}function X(){let t=getComputedStyle(document.documentElement).backgroundColor;return t&&"rgba(0, 0, 0, 0)"!==t&&"transparent"!==t?t:"#ffffff"}function B(t){return!(t instanceof Element)||"devtools-canvas"!==t.id&&"devtools-toolbar"!==t.id&&"devtools-scrim"!==t.id&&(!t.hasAttribute("data-devtools")&&!t.hasAttribute("data-popmelt-top-layer-host"))}function H(t,e,n,o,i){let r=new Map,a=Math.max(0,document.documentElement.scrollWidth-n,document.body.scrollWidth-n);for(let o of t){let t=L(o,e.get(o.id));if(!t)continue;let i=window.scrollX;(t.minX>=i+n||t.maxX<i)&&(i=Math.max(0,Math.min(a,Math.floor(t.minX/n)*n)));let l=r.get(i);l?l.push(o):r.set(i,[o])}return r.size||r.set(window.scrollX,[]),[...r].flatMap(([t,n])=>function(t,e,n,o){return 0===t.length?[{top:Math.max(0,Math.min(o,Math.max(0,n-e))),height:Math.min(e,n||e),annotations:[]}]:t.map(t=>{let o=Math.min(e,n||e);return{top:Math.max(0,Math.min(t.top,Math.max(0,n-o))),height:o,annotations:t.annotations}})}(function(t,e,n){if(0===t.length)return[];let o=t.map(t=>({annotation:t,bounds:L(t,n.get(t.id))})).filter(t=>null!==t.bounds);if(0===o.length)return[];o.sort((t,e)=>t.bounds.minY-e.bounds.minY);let i=Math.min(...o.map(t=>t.bounds.minY)),r=Math.max(...o.map(t=>t.bounds.maxY));if(r-i<=e){let t=(i+r)/2,n=Math.max(0,t-e/2);return[{top:n,bottom:n+e,annotations:o.map(({annotation:t})=>t)}]}let a=[],l=Math.max(0,i-50),s=[],c=l;for(let{annotation:t,bounds:n}of o){let o=n.maxY+50;if(o-l<=e)s.push(t),c=Math.max(c,o);else{if(s.length>0){let t=(l+c)/2,n=Math.max(0,t-e/2);a.push({top:n,bottom:n+e,annotations:s})}l=Math.max(0,n.minY-50),s=[t],c=n.maxY+50}}if(s.length>0){let t=(l+c)/2,n=Math.max(0,t-e/2);a.push({top:n,bottom:n+e,annotations:s})}return a}(n,o,e),o,i,window.scrollY).map(e=>({...e,left:t})))}var N=Promise.resolve();async function T(t,e){if(!t.length)return e();let n,o=N;N=new Promise(t=>{n=t}),await o;let i=[];for(let e of t){let t=Object.getOwnPropertyDescriptor(e.element,"toDataURL");try{Object.defineProperty(e.element,"toDataURL",{configurable:!0,value:()=>e.dataUrl}),i.push(()=>{t?Object.defineProperty(e.element,"toDataURL",t):Reflect.deleteProperty(e.element,"toDataURL")})}catch{}}try{return await e()}finally{try{for(let t of i.reverse())t()}finally{n()}}}async function W(t,e,n,o,i,r){if(o?.nativeCapture){let i=C();try{let a=await o.nativeCapture({url:window.location.href,clip:{x:t.left??window.scrollX,y:t.top,width:e,height:t.height},scale:n});if(r.nativeMs+=C()-i,a)return r.mode=r.renderMs>0||r.contextMs>0?"mixed":"native",async function(t,e,n){let o=document.createElement("canvas");o.width=e,o.height=n;let i=o.getContext("2d");if(!i)throw new Error("Canvas context unavailable");if("function"==typeof createImageBitmap){let r=await createImageBitmap(t);return i.drawImage(r,0,0,e,n),r.close(),o}let r=new Image,a=URL.createObjectURL(t);try{return await new Promise((t,e)=>{r.onload=()=>t(),r.onerror=()=>e(new Error("Native screenshot could not be decoded")),r.src=a}),i.drawImage(r,0,0,e,n),o}finally{URL.revokeObjectURL(a)}}(a,Math.round(e*n),Math.round(t.height*n))}catch(t){r.nativeMs+=C()-i,P(o)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",t)}}let a=await i(),l=C(),s=await(o?.captureSurfaces?.())??[],c=await T(s,()=>async function(t,e,n){return t.width=n,t.height=e.height,t.style={transform:`translate(${-(e.left??window.scrollX)}px, ${-e.top}px)`,transformOrigin:"top left"},g(t)}(a,t,e));return r.renderMs+=C()-l,r.mode="native"===r.mode?"mixed":"dom",c}function $(t,e,n,o,i,r,a,l){let s=document.createElement("canvas");s.width=Math.round(o*i),s.height=Math.round(n.height*i);let c=s.getContext("2d");if(!c)throw new Error("Canvas context unavailable");let d=Math.round((n.top-e)*i);return c.drawImage(t,0,d,s.width,s.height,0,0,s.width,s.height),Y(c,n.annotations,n.top,i,r,a,l),s}async function z(t,n,o){let i=p(),r=C(),s=o?.dpr??(window.devicePixelRatio||1),c=window.innerWidth,d=window.innerHeight,m=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),u=Math.max(250,o?.mediaTimeoutMs??1500),g=P(o),b=window.scrollX,v=l(location.pathname),A=n.filter(t=>"pending"===(t.status??"pending")&&(!t.pathname||t.pathname===v)),k=function(t){let e=new Map,n=new Map;for(let o of t){if(!o.linkedSelector&&!o.target)continue;let t=o.target?document.querySelector(a(o.target)):y(o);if(!t||!t.getClientRects().length||"visible"!==getComputedStyle(t).visibility)continue;let i=n.get(t)??U(t);n.set(t,i),i.width&&i.height&&e.set(o.id,i)}return e}(A),S=o?.annotationNumbers??e({annotations:A,styleModifications:[],textModifications:[]}).annotationNumberById,j=o?.viewportOnly?[{...R(window.scrollY,d,m),left:b,annotations:A}]:H(A,k,c,d,m),D=function(t){let e=0,n=0;for(let o of t.querySelectorAll("img[src]"))E(o.currentSrc||o.src)&&(e++,(!o.complete||0===o.naturalWidth)&&n++);return{remoteImages:e,unresolvedRemoteImages:n}}(t),L={startedAt:r,mode:"dom",mediaTimeoutMs:u,ranges:j.length,...D,remoteAssetFallbacks:0,nativeMs:0,contextMs:0,renderMs:0,compositeMs:0,encodeMs:0};console.log("[Screenshot] Starting capture with",A.length,"active annotations (filtered",n.length-A.length,"captured);",`${j.length} range(s), ${D.remoteImages} remote image(s), ${D.unresolvedRemoteImages} unresolved`);let Y=null,O=null,N=j.every(t=>t.left===j[0]?.left)&&function(t,e,n){if(0===t.length)return null;let o=Math.min(...t.map(t=>t.top)),i=Math.max(...t.map(t=>t.top+t.height))-o;return i>16e3||e*i*n*n>24e6?null:{top:o,height:i}}(j,c,s),T=N?{...N,left:j[0]?.left}:null,z=T??j[0],F=async()=>{if(!Y){let e=C();Y=w(i,()=>async function(t,e,n,o,i,r,a){let l=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)>4*window.innerHeight||t.querySelectorAll("*").length>2500,s=await f(t,{autoDestruct:!1,filter:B,features:{restoreScrollPosition:!0},onCloneNode:e=>{t===document.body&&(e.style.margin=getComputedStyle(t).margin)},onCloneEachNode:t=>{if(1===t.nodeType&&"html"===t.localName&&t.ownerDocument!==document){let e=t.style;e.overflow="hidden",e.display="inline-block",e.clipPath=`inset(0 round ${e.borderRadius||"0px"})`}},scale:o,backgroundColor:X(),width:n,height:e.height,style:{transform:`translate(${-(e.left??window.scrollX)}px, ${-e.top}px)`,transformOrigin:"top left"},timeout:i,debug:r,includeStyleProperties:l?[...M]:null,fetchFn:I(i,()=>{a.remoteAssetFallbacks++}),fetch:{requestInit:{cache:"force-cache"},placeholderImage:x}});return"null"===window.origin&&(s.sandbox=document.createElement("iframe")),s}(t,z,c,s,u,g,L)).then(t=>(O=t,L.contextMs+=C()-e,t))}return Y};try{let t,e=C();if(T){let e=await w(i,()=>W(T,c,s,o,F,L));t=j.map(t=>$(e,T.top,t,c,s,k,S,t.left??b))}else{t=[];for(let e of j){let n=await w(i,()=>W(e,c,s,o,F,L));t.push($(n,e.top,e,c,s,k,S,e.left??b))}}let n=function(t){if(1===t.length)return t[0];let e=document.createElement("canvas");e.width=t[0]?.width??0,e.height=t.reduce((t,e)=>t+e.height,0);let n=e.getContext("2d");if(!n)throw new Error("Canvas context unavailable");let o=0;for(let e of t)n.drawImage(e,0,o),o+=e.height;return e}(t);L.compositeMs+=C()-e-L.renderMs-L.nativeMs-L.contextMs;let r=C(),a=await w(i,()=>function(t,e="image/webp",n=.8){return new Promise(o=>t.toBlob(o,e,n))}(n));L.encodeMs=C()-r;let l=C()-L.startedAt,d={mode:L.mode,totalMs:Math.round(l),mediaTimeoutMs:L.mediaTimeoutMs,ranges:L.ranges,remoteImages:L.remoteImages,unresolvedRemoteImages:L.unresolvedRemoteImages,remoteAssetFallbacks:L.remoteAssetFallbacks,nativeMs:Math.round(L.nativeMs),contextMs:Math.round(L.contextMs),renderMs:Math.round(L.renderMs),compositeMs:Math.max(0,Math.round(L.compositeMs)),encodeMs:Math.round(L.encodeMs),overBudget:performance.now()>i};return console.log("[Screenshot] Capture complete",JSON.stringify(d)),a?[a]:[]}catch(t){return console.error("[Screenshot] Capture failed:",t),[]}finally{O&&h(O)}}async function F(t){if(0===t.length)return null;if(1===t.length)return t[0];let e=await Promise.all(t.map(t=>new Promise((e,n)=>{let o=new Image;o.onload=()=>e(o),o.onerror=n,o.src=URL.createObjectURL(t)}))),n=e[0].width,o=e.reduce((t,e)=>t+e.height,0),i=document.createElement("canvas");i.width=n,i.height=o;let r=i.getContext("2d");if(!r)return null;let a=0;for(let t of e)r.drawImage(t,0,a),a+=t.height,URL.revokeObjectURL(t.src);return new Promise(t=>{i.toBlob(e=>t(e),"image/webp",.8)})}async function q(t,e,n,o,i){try{let r=Array.isArray(t)?t:[t];if(0===r.length)return!1;let a=await F(r);if(!a)return!1;let l=a;if("image/png"!==a.type){let t=new Image,e=URL.createObjectURL(a);await new Promise(n=>{t.onload=()=>n(),t.src=e}),URL.revokeObjectURL(e);let n=document.createElement("canvas");n.width=t.naturalWidth,n.height=t.naturalHeight,n.getContext("2d").drawImage(t,0,0),l=await new Promise(t=>n.toBlob(e=>t(e),"image/png"))}let s={"image/png":l},c=e&&e.length>0,d=n&&n.length>0,m=o&&o.length>0,u=i&&i.length>0;if(c||d||m||u){let t=e?e.filter(t=>"pending"===(t.status??"pending")):[];if(t.length>0||d||m||u){let e=D(t,n||[],void 0,void 0,o||[],i||[]),r=new Blob([JSON.stringify(e,null,2)],{type:"text/plain"});s["text/plain"]=r}}return await navigator.clipboard.write([new ClipboardItem(s)]),!0}catch(t){return console.warn("Clipboard write failed:",t),!1}}export{p as a,w as b,y as c,v as d,j as e,D as f,U as g,Y as h,O as i,T as j,F as k,q as l};
|
|
1
|
+
"use client";import{p as t,r as e,f as n}from"./chunk-2PARHFWP.mjs";import{X as o,A as i,a as r}from"./chunk-QF5B6AYF.mjs";import{a}from"./chunk-VBH2YQLG.mjs";import{f as l}from"./chunk-AAMUU2QA.mjs";import{l as s,v as c,d,i as m,m as u}from"./chunk-LH7HKUCK.mjs";import{destroyContext as h,createContext as f,domToCanvas as g}from"modern-screenshot";function p(){return performance.now()+5e3}async function w(t,e){let n,o=t-performance.now(),i=()=>new Error("Visual capture timed out");if(o<=0)throw i();try{return await Promise.race([new Promise((t,e)=>{n=setTimeout(()=>e(i()),o)}),e()])}finally{clearTimeout(n)}}function b(t,e){return`[${t}="${typeof CSS<"u"&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}"]`}function y(t){let e=t.elements?.[0],n=e?.sourceElement?.dataAttributes,o=n?.["data-popmelt-media-id"]??n?.["data-popmelt-see-id"]??e?.dataAttributes?.["data-popmelt-media-id"]??e?.dataAttributes?.["data-popmelt-see-id"];if(o&&!t.linkedSelector?.startsWith("@frame(")&&!e?.selector.startsWith("@frame(")){let t=s(b("data-popmelt-media-id",o));if(t)return t;let e=s(b("data-popmelt-see-id",o));if(e)return e}return c(t.linkedSelector,e)}var x="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",M=["position","inset","top","right","bottom","left","z-index","display","visibility","opacity","overflow","overflow-x","overflow-y","box-sizing","box-decoration-break","float","clear","width","min-width","max-width","height","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-width","border-style","border-color","border-top","border-right","border-bottom","border-left","border-radius","outline","outline-offset","box-shadow","background","background-color","background-image","background-size","background-position","background-repeat","background-clip","background-origin","color","font","font-family","font-size","font-style","font-weight","font-stretch","font-variant","line-height","letter-spacing","text-align","text-decoration","text-indent","text-overflow","text-shadow","text-transform","white-space","word-break","overflow-wrap","vertical-align","direction","writing-mode","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","align-content","align-items","align-self","justify-content","justify-items","justify-self","gap","row-gap","column-gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-row","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","order","columns","column-count","column-fill","column-rule","column-span","column-width","list-style","list-style-image","list-style-position","list-style-type","object-fit","object-position","aspect-ratio","transform","transform-box","transform-origin","transform-style","perspective","perspective-origin","backface-visibility","clip","clip-path","filter","backdrop-filter","mix-blend-mode","isolation","mask","mask-image","mask-position","mask-repeat","mask-size","content","quotes","counter-increment","counter-reset","appearance","accent-color","caret-color","cursor","pointer-events","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity"];async function v(t,e){try{let e=await t();if(e)return e}catch{}return e()}var A=new Map,k=new WeakMap,S=1;function C(){return typeof performance<"u"?performance.now():Date.now()}function P(t){if(void 0!==t?.debug)return t.debug;if(typeof window>"u")return!1;try{return"true"===window.localStorage.getItem("popmelt:screenshot-debug")}catch{return!1}}function R(t,e){let n=null;return async o=>{if(!I(o))return!1;n??(n=Date.now()+t);let i=n-Date.now();if(i<=0)return e(),x;let r=new AbortController,a=setTimeout(()=>r.abort(),i);try{let t=await fetch(o,{cache:"force-cache",mode:"cors",signal:r.signal});if(!t.ok)throw new Error(`Asset returned ${t.status}`);return await function(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result)),o.onerror=()=>n(o.error??new Error("Asset could not be read")),o.readAsDataURL(t)})}(await t.blob())}catch{return e(),x}finally{clearTimeout(a)}}}function E(t,e,n){let o=Math.min(e,n);return{top:Math.max(0,Math.min(t,n-o)),height:o,annotations:[]}}function I(t){if(typeof window>"u")return!1;try{let e=new URL(t,window.location.href);return("http:"===e.protocol||"https:"===e.protocol)&&e.origin!==window.location.origin}catch{return!1}}function j(t){let e=document.createElement("canvas").getContext("2d");return e?(e.fillStyle=t,e.fillStyle):"#888888"}function D(t,e=[],n,o,i=[],r=[],a){let l=new Map,s=[];for(let e of t)if(e.groupId){let t=l.get(e.groupId)||[];t.push(e),l.set(e.groupId,t)}else s.push(e);let c=[];for(let[t,e]of l){let t=e.find(t=>"text"!==t.type),n=e.find(t=>"text"===t.type);if(t){let e=t.linkedSelector||n?.linkedSelector,o=n?.imageCount||t.imageCount,i=n?.attachments||t.attachments,r=n?.interactionEpisode||t.interactionEpisode,a=t.pathname||n?.pathname;c.push({id:t.id,type:t.type,instruction:n?.text,...e?{linkedSelector:e}:{},...t.target||n?.target?{target:t.target??n?.target}:{},...a?{pathname:a}:{},elements:t.elements||[],...o?{imageCount:o}:{},...i?.length?{attachments:i}:{},...r?{interactionEpisode:r}:{}})}}for(let t of s)c.push({id:t.id,type:t.type,instruction:"text"===t.type?t.text:void 0,...t.linkedSelector?{linkedSelector:t.linkedSelector}:{},...t.target?{target:t.target}:{},...t.pathname?{pathname:t.pathname}:{},elements:t.elements||[],...t.region?{region:t.region}:{},...t.imageCount?{imageCount:t.imageCount}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}});return{timestamp:(new Date).toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:c,styleModifications:e,...i.length>0?{textModifications:i}:{},...r.length>0?{domModifications:r}:{},...n?{inspectedElement:n}:{},...o&&o.length>0?{spacingTokenChanges:o}:{},...a?{meta:a}:{}}}function L(t,e){if(!e&&"text"===t.type&&t.linkedSelector&&!t.target&&!t.region)return null;if(e&&"text"===t.type&&!t.region){let n=Math.min(e.height,.75*window.innerHeight),o="bottom-left"===t.linkedAnchor?e.y+e.height-n:e.y;return{minX:e.x,minY:o,maxX:e.x+e.width,maxY:o+n}}if(!t.points||0===t.points.length)return null;let n=[...t.points,...t.region?.points??[]],o=n.map(t=>t.x),i=n.map(t=>t.y);return{minX:Math.min(...o),minY:Math.min(...i),maxX:Math.max(...o),maxY:Math.max(...i)}}function O(t){let e=d(t),n=function(t,e){let n=m(e,t.ownerDocument),{left:o,right:i,top:r,bottom:a}=n;for(let e=u(t);e&&e!==t.ownerDocument.documentElement&&e!==t.ownerDocument.body;e=u(e)){let t=getComputedStyle(e);if("visible"===t.overflowX&&"visible"===t.overflowY)continue;let n=d(e);"visible"!==t.overflowX&&(o=Math.max(o,n.left),i=Math.min(i,n.right)),"visible"!==t.overflowY&&(r=Math.max(r,n.top),a=Math.min(a,n.bottom))}return new DOMRect(o,r,Math.max(0,i-o),Math.max(0,a-r))}(t,e),r=(new DOMMatrix).translate(window.scrollX,window.scrollY),a=new Path2D,l=t.getAttribute("data-popmelt-subject-outline");if(l&&t.hasAttribute("data-popmelt-subject-projection")){let t=new Path2D("M"+l.trim().split(/\s+/).join("L")+"Z");a.addPath(t,r.translate(e.left,e.top).scale(e.width,e.height))}else{let e=!1;o(t,"#000",0,"solid",t=>{let n=t.getScreenCTM();if(n)for(let o of t.querySelectorAll("path")){let t=o.getAttribute("d");t&&(a.addPath(new Path2D(t),r.multiply(n)),e=!0)}})?.abort(),e||a.addPath(new Path2D(i(t)),r)}return{x:n.left+r.e,y:n.top+r.f,width:n.width,height:n.height,contour:a,clipped:n.left!==e.left||n.top!==e.top||n.width!==e.width||n.height!==e.height}}function U(e,o,i,a,l,s,c=window.scrollX){let d=e.canvas.width/a,m=e.canvas.height/a;e.save(),e.scale(a,a),e.save(),e.translate(-c,-i),e.lineWidth=1,e.setLineDash([...r]);for(let t of o){let n=l.get(t.id);n&&(e.save(),n.clipped&&(e.beginPath(),e.rect(n.x,n.y,n.width,n.height),e.clip()),e.fillStyle=e.strokeStyle=t.color,e.globalAlpha=.05,e.fill(n.contour),e.globalAlpha=1,e.stroke(n.contour),e.restore())}e.restore();let u=t=>({x:t.x-c,y:t.y-i});for(let r of o){let o=r.points.map(u),a=r.linkedAnchor;if("text"===r.type){let t=l.get(r.id),e=L(r,t);if(!e||e.maxX<c||e.minX>=c+d||e.maxY<i||e.minY>=i+m)continue;if(t&&!r.region){let e=t.y-i,r=e+t.height,l="bottom-left"===a||!a&&e<22+n,s=l?r+n:e-22-n;a=l?"bottom-left":"top-left",o=[{x:Math.max(0,t.x-c)+8,y:s+4}]}}t(e,{...r,points:o,linkedAnchor:a,...r.region?{region:{...r.region,points:r.region.points.map(u)}}:{}},s?.get(r.id),{avoidBottom:m})}e.restore()}async function Y(t,e,n=[],o){let i=function(t,e,n){let o=k.get(t);o||(o=S++,k.set(t,o));let i=e.filter(t=>"pending"===(t.status??"pending")).map(t=>JSON.stringify([t.id,t.type,t.text,t.color,t.fontSize,t.strokeWidth,t.points,t.region,t.linkedSelector,t.linkedAnchor,t.pathname,t.groupId,n?.annotationNumbers?.get(t.id)])).join("|");return[o,window.location.href,window.innerWidth,window.innerHeight,n?.dpr??window.devicePixelRatio??1,window.scrollX,window.scrollY,!!n?.viewportOnly,i].join("::")}(t,n,o),r=A.get(i);if(r)return P(o)&&console.debug("[Screenshot] Reusing in-flight capture",i),r;let a=F(t,n,o).finally(()=>A.delete(i));return A.set(i,a),a}function X(){let t=getComputedStyle(document.documentElement).backgroundColor;return t&&"rgba(0, 0, 0, 0)"!==t&&"transparent"!==t?t:"#ffffff"}function B(t){return!(t instanceof Element)||"devtools-canvas"!==t.id&&"devtools-toolbar"!==t.id&&"devtools-scrim"!==t.id&&(!t.hasAttribute("data-devtools")&&!t.hasAttribute("data-popmelt-top-layer-host"))}function H(t,e,n,o,i){let r=new Map,a=Math.max(0,document.documentElement.scrollWidth-n,document.body.scrollWidth-n);for(let o of t){let t=L(o,e.get(o.id));if(!t)continue;let i=window.scrollX;(t.minX>=i+n||t.maxX<i)&&(i=Math.max(0,Math.min(a,Math.floor(t.minX/n)*n)));let l=r.get(i);l?l.push(o):r.set(i,[o])}return r.size||r.set(window.scrollX,[]),[...r].flatMap(([t,n])=>function(t,e,n,o){return 0===t.length?[{top:Math.max(0,Math.min(o,Math.max(0,n-e))),height:Math.min(e,n||e),annotations:[]}]:t.map(t=>{let o=Math.min(e,n||e);return{top:Math.max(0,Math.min(t.top,Math.max(0,n-o))),height:o,annotations:t.annotations}})}(function(t,e,n){if(0===t.length)return[];let o=t.map(t=>({annotation:t,bounds:L(t,n.get(t.id))})).filter(t=>null!==t.bounds);if(0===o.length)return[];o.sort((t,e)=>t.bounds.minY-e.bounds.minY);let i=Math.min(...o.map(t=>t.bounds.minY)),r=Math.max(...o.map(t=>t.bounds.maxY));if(r-i<=e){let t=(i+r)/2,n=Math.max(0,t-e/2);return[{top:n,bottom:n+e,annotations:o.map(({annotation:t})=>t)}]}let a=[],l=Math.max(0,i-50),s=[],c=l;for(let{annotation:t,bounds:n}of o){let o=n.maxY+50;if(o-l<=e)s.push(t),c=Math.max(c,o);else{if(s.length>0){let t=(l+c)/2,n=Math.max(0,t-e/2);a.push({top:n,bottom:n+e,annotations:s})}l=Math.max(0,n.minY-50),s=[t],c=n.maxY+50}}if(s.length>0){let t=(l+c)/2,n=Math.max(0,t-e/2);a.push({top:n,bottom:n+e,annotations:s})}return a}(n,o,e),o,i,window.scrollY).map(e=>({...e,left:t})))}var W=Promise.resolve();async function $(t,e){if(!t.length)return e();let n,o=W;W=new Promise(t=>{n=t}),await o;let i=[];for(let e of t){let t=Object.getOwnPropertyDescriptor(e.element,"toDataURL");try{Object.defineProperty(e.element,"toDataURL",{configurable:!0,value:()=>e.dataUrl}),i.push(()=>{t?Object.defineProperty(e.element,"toDataURL",t):Reflect.deleteProperty(e.element,"toDataURL")})}catch{}}try{return await e()}finally{try{for(let t of i.reverse())t()}finally{n()}}}async function N(t,e,n,o,i,r){if(o?.nativeCapture){let i=C();try{let a=await o.nativeCapture({url:window.location.href,clip:{x:t.left??window.scrollX,y:t.top,width:e,height:t.height},scale:n});if(r.nativeMs+=C()-i,a)return r.mode=r.renderMs>0||r.contextMs>0?"mixed":"native",async function(t,e,n){let o=document.createElement("canvas");o.width=e,o.height=n;let i=o.getContext("2d");if(!i)throw new Error("Canvas context unavailable");if("function"==typeof createImageBitmap){let r=await createImageBitmap(t);return i.drawImage(r,0,0,e,n),r.close(),o}let r=new Image,a=URL.createObjectURL(t);try{return await new Promise((t,e)=>{r.onload=()=>t(),r.onerror=()=>e(new Error("Native screenshot could not be decoded")),r.src=a}),i.drawImage(r,0,0,e,n),o}finally{URL.revokeObjectURL(a)}}(a,Math.round(e*n),Math.round(t.height*n))}catch(t){r.nativeMs+=C()-i,P(o)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",t)}}let a=await i(),l=C(),s=await(o?.captureSurfaces?.())??[],c=await $(s,()=>async function(t,e,n){return t.width=n,t.height=e.height,t.style={transform:`translate(${-(e.left??window.scrollX)}px, ${-e.top}px)`,transformOrigin:"top left"},g(t)}(a,t,e));return r.renderMs+=C()-l,r.mode="native"===r.mode?"mixed":"dom",c}function T(t,e,n,o,i,r,a,l){let s=document.createElement("canvas");s.width=Math.round(o*i),s.height=Math.round(n.height*i);let c=s.getContext("2d");if(!c)throw new Error("Canvas context unavailable");let d=Math.round((n.top-e)*i);return c.drawImage(t,0,d,s.width,s.height,0,0,s.width,s.height),U(c,n.annotations,n.top,i,r,a,l),s}async function F(t,n,o){let i=p(),r=C(),s=o?.dpr??(window.devicePixelRatio||1),c=window.innerWidth,d=window.innerHeight,m=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),u=Math.max(250,o?.mediaTimeoutMs??1500),g=P(o),b=window.scrollX,v=l(location.pathname),A=n.filter(t=>"pending"===(t.status??"pending")&&(!t.pathname||t.pathname===v)),k=function(t){let e=new Map,n=new Map;for(let o of t){if(!o.linkedSelector&&!o.target)continue;let t=o.target?document.querySelector(a(o.target)):y(o);if(!t||!t.getClientRects().length||"visible"!==getComputedStyle(t).visibility)continue;let i=n.get(t)??O(t);n.set(t,i),i.width&&i.height&&e.set(o.id,i)}return e}(A),S=o?.annotationNumbers??e({annotations:A,styleModifications:[],textModifications:[]}).annotationNumberById,j=o?.viewportOnly?[{...E(window.scrollY,d,m),left:b,annotations:A}]:H(A,k,c,d,m),D=function(t){let e=0,n=0;for(let o of t.querySelectorAll("img[src]"))I(o.currentSrc||o.src)&&(e++,(!o.complete||0===o.naturalWidth)&&n++);return{remoteImages:e,unresolvedRemoteImages:n}}(t),L={startedAt:r,mode:"dom",mediaTimeoutMs:u,ranges:j.length,...D,remoteAssetFallbacks:0,nativeMs:0,contextMs:0,renderMs:0,compositeMs:0,encodeMs:0};console.log("[Screenshot] Starting capture with",A.length,"active annotations (filtered",n.length-A.length,"captured);",`${j.length} range(s), ${D.remoteImages} remote image(s), ${D.unresolvedRemoteImages} unresolved`);let U=null,Y=null,W=j.every(t=>t.left===j[0]?.left)&&function(t,e,n){if(0===t.length)return null;let o=Math.min(...t.map(t=>t.top)),i=Math.max(...t.map(t=>t.top+t.height))-o;return i>16e3||e*i*n*n>24e6?null:{top:o,height:i}}(j,c,s),$=W?{...W,left:j[0]?.left}:null,F=$??j[0],z=async()=>{if(!U){let e=C();U=w(i,()=>async function(t,e,n,o,i,r,a){let l=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)>4*window.innerHeight||t.querySelectorAll("*").length>2500,s=await f(t,{autoDestruct:!1,filter:B,features:{restoreScrollPosition:!0},onCloneNode:e=>{t===document.body&&(e.style.margin=getComputedStyle(t).margin)},onCloneEachNode:t=>{if(1===t.nodeType&&"html"===t.localName&&t.ownerDocument!==document){let e=t.style;e.overflow="hidden",e.display="inline-block",e.clipPath=`inset(0 round ${e.borderRadius||"0px"})`}},scale:o,backgroundColor:X(),width:n,height:e.height,style:{transform:`translate(${-(e.left??window.scrollX)}px, ${-e.top}px)`,transformOrigin:"top left"},timeout:i,debug:r,includeStyleProperties:l?[...M]:null,fetchFn:R(i,()=>{a.remoteAssetFallbacks++}),fetch:{requestInit:{cache:"force-cache"},placeholderImage:x}});return"null"===window.origin&&(s.sandbox=document.createElement("iframe")),s}(t,F,c,s,u,g,L)).then(t=>(Y=t,L.contextMs+=C()-e,t))}return U};try{let t,e=C();if($){let e=await w(i,()=>N($,c,s,o,z,L));t=j.map(t=>T(e,$.top,t,c,s,k,S,t.left??b))}else{t=[];for(let e of j){let n=await w(i,()=>N(e,c,s,o,z,L));t.push(T(n,e.top,e,c,s,k,S,e.left??b))}}let n=function(t){if(1===t.length)return t[0];let e=document.createElement("canvas");e.width=t[0]?.width??0,e.height=t.reduce((t,e)=>t+e.height,0);let n=e.getContext("2d");if(!n)throw new Error("Canvas context unavailable");let o=0;for(let e of t)n.drawImage(e,0,o),o+=e.height;return e}(t);L.compositeMs+=C()-e-L.renderMs-L.nativeMs-L.contextMs;let r=C(),a=await w(i,()=>function(t,e="image/webp",n=.8){return new Promise(o=>t.toBlob(o,e,n))}(n));L.encodeMs=C()-r;let l=C()-L.startedAt,d={mode:L.mode,totalMs:Math.round(l),mediaTimeoutMs:L.mediaTimeoutMs,ranges:L.ranges,remoteImages:L.remoteImages,unresolvedRemoteImages:L.unresolvedRemoteImages,remoteAssetFallbacks:L.remoteAssetFallbacks,nativeMs:Math.round(L.nativeMs),contextMs:Math.round(L.contextMs),renderMs:Math.round(L.renderMs),compositeMs:Math.max(0,Math.round(L.compositeMs)),encodeMs:Math.round(L.encodeMs),overBudget:performance.now()>i};return console.log("[Screenshot] Capture complete",JSON.stringify(d)),a?[a]:[]}catch(t){return console.error("[Screenshot] Capture failed:",t),[]}finally{Y&&h(Y)}}async function z(t){if(0===t.length)return null;if(1===t.length)return t[0];let e=await Promise.all(t.map(t=>new Promise((e,n)=>{let o=new Image;o.onload=()=>e(o),o.onerror=n,o.src=URL.createObjectURL(t)}))),n=e[0].width,o=e.reduce((t,e)=>t+e.height,0),i=document.createElement("canvas");i.width=n,i.height=o;let r=i.getContext("2d");if(!r)return null;let a=0;for(let t of e)r.drawImage(t,0,a),a+=t.height,URL.revokeObjectURL(t.src);return new Promise(t=>{i.toBlob(e=>t(e),"image/webp",.8)})}async function q(t,e,n,o,i){try{let r=Array.isArray(t)?t:[t];if(0===r.length)return!1;let a=await z(r);if(!a)return!1;let l=a;if("image/png"!==a.type){let t=new Image,e=URL.createObjectURL(a);await new Promise(n=>{t.onload=()=>n(),t.src=e}),URL.revokeObjectURL(e);let n=document.createElement("canvas");n.width=t.naturalWidth,n.height=t.naturalHeight,n.getContext("2d").drawImage(t,0,0),l=await new Promise(t=>n.toBlob(e=>t(e),"image/png"))}let s={"image/png":l},c=e&&e.length>0,d=n&&n.length>0,m=o&&o.length>0,u=i&&i.length>0;if(c||d||m||u){let t=e?e.filter(t=>"pending"===(t.status??"pending")):[];if(t.length>0||d||m||u){let e=D(t,n||[],void 0,void 0,o||[],i||[]),r=new Blob([JSON.stringify(e,null,2)],{type:"text/plain"});s["text/plain"]=r}}return await navigator.clipboard.write([new ClipboardItem(s)]),!0}catch(t){return console.warn("Clipboard write failed:",t),!1}}export{p as a,w as b,y as c,v as d,j as e,D as f,O as g,U as h,Y as i,$ as j,z as k,q as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as t}from"./chunk-R565ZNSP.mjs";import{a as r,e as a,f as i,g as s}from"./chunk-GLF7Z5IR.mjs";import{a as n}from"./chunk-KD2AOPYP.mjs";import{c as o}from"./chunk-KF73S7MG.mjs";import{execFile as p}from"child_process";import{createHash as c}from"crypto";import{mkdir as l,mkdtemp as d,realpath as u,rm as h,stat as m}from"fs/promises";import{join as f,relative as w,resolve as g}from"path";import{promisify as y}from"util";var v=y(p),b=/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;async function k(e,t,r){let a={...process.env};for(let e of Object.keys(a))e.startsWith("GIT_")&&delete a[e];async function i(e,t,r){return(await v("git",["-c","core.hooksPath=/dev/null","-c","user.name=Popmelt","-c","user.email=planes@localhost",...t],{cwd:e,env:r?{...a,GIT_INDEX_FILE:r}:a})).stdout.trim()}let s=await u(await i(e,["rev-parse","--show-toplevel"])),o=w(s,await u(e));await l(t,{recursive:!0,mode:448});let p=await u(t),y=w(s,p);if(!y.startsWith(".."+("win32"===process.platform?"\\":"/"))&&".."!==y&&!y.split(/[\\/]/).includes(".popmelt"))throw new Error("Store plane worktrees outside the checkout or under .popmelt.");let k="refs/popmelt/planes/"+c("sha256").update(s).digest("hex")+"/",P=await u(await i(s,["rev-parse","--path-format=absolute","--git-common-dir"])),I=new Map,j=new Map,E=new Map,R=new Map,S=e=>"edit-"+c("sha256").update(e).digest("hex");async function x(e){try{await m(f(e,".git"))}catch(e){if("ENOENT"===e.code)return null;throw e}let t=await u(e);if(t!==await u(await i(e,["rev-parse","--show-toplevel"]))||await u(await i(e,["rev-parse","--path-format=absolute","--git-common-dir"]))!==P)throw new Error("Plane checkout does not belong to this repository.");return g(t,o)}async function A(e){let t=E.get(e);if(t)return t;let a=await x(f(p,e))??(r&&e.startsWith("edit-")?await x(f(r,e)):null);return a&&E.set(e,a),a}async function H(e,t){if(!b.test(t))throw new Error("Unknown plane source snapshot.");let r=I.get(e);return r||(r=n(f(p,e+".lock"),async()=>{let r=await A(e);if(r)return r;let a=await i(s,["rev-parse","--verify",k+t+"^{commit}"]),n=f(p,e);return await i(s,["update-ref",k+"bases/"+e,a]),await i(s,["worktree","add","--quiet","--detach",n,a]),g(n,o)}).finally(()=>I.delete(e)),I.set(e,r)),r}return{capture:function(e=s){let t=j.get(e);return t||(t=async function(e){let t=e===s?s:await i(e,["rev-parse","--show-toplevel"]),r=await d(f(p,"index-"));try{let e=f(r,"index"),a=await i(t,["rev-parse","--verify","--quiet","HEAD"]).catch(e=>{if(1===e.code)return"";throw e});await i(t,["read-tree",a||"--empty"],e);let s=[":(glob)**/.popmelt/**",":(glob)**/.env",":(glob)**/.env.*",":(glob)**/node_modules/**"];await i(t,["rm","-rq","--cached","--ignore-unmatch","--",...s],e),await i(t,["add","-A","--",".",...s.map(e=>e.replace("(glob)","(exclude,glob)"))],e);let n=await i(t,["write-tree"],e),o=k+n;if(!await i(t,["rev-parse","--verify","--quiet",o]).catch(e=>{if(1===e.code)return"";throw e})){let e=await i(t,["commit-tree",n,...a?["-p",a]:[],"-m","Popmelt plane source"]);await i(t,["update-ref",o,e])}return n}finally{await h(r,{recursive:!0,force:!0})}}(e).finally(()=>j.delete(e)),j.set(e,t)),t},checkoutRoot:e=>g(e,w(g(s,o),s)),editable:(e,t)=>H(S(e),t),findEditable:e=>I.get(S(e))??A(S(e)),retained:e=>H("base-"+e,e),async basis(e){let t=R.get(e)??await i(s,["rev-parse",k+"bases/"+S(e)+"^{tree}"]);return R.set(e,t),t}}}import{createHash as P,createHmac as I,randomBytes as j}from"crypto";import{request as E}from"http";import{pipeline as R}from"stream/promises";var S="/popmelt/phone";var x=new Map;function A(t,r){let a=function(t,r){let a=_(t);if(!a)return r;let i=new Headers(r.headers);for(let[e,t]of Object.entries(a.headers))i.set(e,t);return{...r,headers:i,redirect:"error",credentials:a.phone?function(e=location.origin){let t=/^https:\/\/p-([0-9a-f]{32})\.popmelt\.com$/.exec(e)?.[1];return t?"https://pair.popmelt.com/p/"+t:null}()?"same-origin":"omit":a.pathPrefix===e+"/"?"same-origin":"omit"}}(t,r);if(_(t)?.phone){let e=new URL(t),r=new Headers(a.headers);return r.set("X-Popmelt-Phone-Route",e.pathname.slice(14)+e.search),fetch(e.origin+S,{...a,headers:r,cache:"no-store"})}return fetch(t,a)}function H(e,t){return typeof location<"u"&&e===location.origin+S&&!0===x.get(location.origin)?.phone&&x.get(location.origin)?.headers["X-Popmelt-Project-Id"]===t}function _(e){try{let t=new URL(e),r=x.get(t.origin);return r?.pathPrefix?("string"==typeof r.pathPrefix?[r.pathPrefix]:r.pathPrefix).some(e=>e.endsWith("/")?t.pathname.startsWith(e):t.pathname===e)?r:void 0:r}catch{return}}var q=class extends Error{constructor(e,t,r){super(t),this.status=e,this.code=r}},O=class{constructor(e,r,a,i=(...e)=>fetch(...e)){this.projectId=r,this.transport=i;let s=new URL(e);if(this.guestGateway=t(e),this.phone=H(e,r),!this.phone&&!this.guestGateway&&("http:"!==s.protocol||!["localhost","127.0.0.1","[::1]"].includes(s.hostname)||s.username||s.password||s.search||s.hash||"/"!==s.pathname))throw new Error("Participant transport requires a local bridge origin");if(!r)throw new Error("Project identity required");this.base=this.phone||t(e)?e:s.origin,this.credential=a?{...a}:void 0}moderateStyles(e,t,r=!1){return this.rpc("moderate-styles",{participantId:e,styleModifications:t,restore:r})}moderateAnnotations(e,t,r=!1,a){return this.rpc("moderate-annotations",{participantId:e,annotationIds:t,restore:r,threadId:a})}async request(e,r,a={},i){let s=r instanceof FormData;if(this.phone&&!H(this.base,this.projectId))throw new Error("Phone pairing is no longer active");let n=await(this.phone?A:this.transport)(this.base+e,{method:"POST",redirect:"error",credentials:t(this.base)?"same-origin":"omit",signal:i??AbortSignal.timeout(3e4),headers:{...s?{}:{"Content-Type":"application/json"},"X-Popmelt-Project-Id":this.projectId,...this.credential&&!this.phone?{"X-Popmelt-Participant-Id":this.credential.participantId,"X-Popmelt-Participant-Token":this.credential.token}:{},...a},body:s?r:JSON.stringify(r)}),o=await n.json().catch(()=>null);if(!n.ok)throw new q(n.status,"string"==typeof o?.error?o.error:"Participant request failed","string"==typeof o?.code?o.code:void 0);if(null===o)throw new Error("Invalid participant response");return{data:o,status:n.status}}async rpc(e,t={},r){return(await this.request("/participants/"+e,t,{},r)).data}mountRequestScope(r){if(!this.credential)throw new Error("Join before mounting a canvas");return this.phone?()=>{}:function(r,a){let i=new URL(r);if(!t(r)&&("http:"!==i.protocol||!["localhost","127.0.0.1","[::1]"].includes(i.hostname)||"/"!==i.pathname||i.search||i.hash||i.username||i.password))throw new Error("Bridge scope requires a local origin");if(x.has(i.origin))throw new Error("This bridge already has an active participant in this page");let s={headers:{...a},pathPrefix:t(r)?e+"/":void 0};return x.set(i.origin,s),()=>{x.get(i.origin)===s&&x.delete(i.origin)}}(this.base,{"X-Popmelt-Project-Id":this.projectId,"X-Popmelt-Participant-Id":this.credential.participantId,"X-Popmelt-Participant-Token":this.credential.token,...r?{"X-Popmelt-Source-Revision":r.revision}:{}})}source(){return this.rpc("source")}snapshot(){return this.rpc("snapshot")}setHostModelSelection(e){return this.rpc("model-selection",{selection:e})}reserveAdmissionColor(e){return this.rpc("access-color",{receipt:e})}requestAdmission(e,t,r){return this.rpc("access-request",{receipt:e,name:t,colorIdentity:r})}admissionStatus(e){return this.rpc("access-status",{receipt:e})}cancelAdmission(e){return this.rpc("access-cancel",{receipt:e})}admissions(){return this.rpc("access-list")}decideAdmission(e,t){return this.rpc("access-decide",{id:e,decision:t})}attention(){return this.rpc("attention-read")}async reportAttention(e,t,r,a,i){return(await this.request("/participants/attention",{runtime:e,phase:t,operationId:r,location:a},{},i??AbortSignal.timeout(1500))).data}invite(){return this.rpc("invite")}guestInvite(e,t=(typeof location>"u"?"/":location.pathname)){return this.rpc("guest-invite",{mode:e,pathname:t},AbortSignal.timeout("tunnel"===e?18e4:6e4))}revokeInvite(e){return this.rpc("revoke-invite",{invitation:e})}join(e,t,r){return this.rpc("join",{invitation:e,name:t,...r?{colorIdentity:r}:{}})}joinOrRequestAdmission(e,t,r){return this.rpc("join-or-request",{invitation:e,name:t,colorIdentity:r})}read(e,t,r=!1){return this.rpc("read",{participantId:e,historyVersion:2,...r&&{ownSource:!0}},t)}connect(e,t){return this.rpc("connect",{runtimeId:e,previousToken:t})}renew(e,t){return this.rpc("renew",{runtime:e,activeColor:t})}disconnect(e){return this.rpc("disconnect",{runtime:e})}publish(e,t,r,a){return r.sourceId!==this.projectId?Promise.reject(new Error("Source world mismatch")):this.rpc("publish",{runtime:e,expectedRevision:t,sourceRevision:r.revision,state:a})}merge(e,t,r,a){return r.sourceId!==this.projectId?Promise.reject(new Error("Source world mismatch")):this.rpc("merge",{runtime:e,expectedRevision:t,sourceRevision:r.revision,events:a,historyVersion:2})}rename(e){return this.rpc("rename",{name:e})}setProjectVisibility(e){return this.rpc("project-visibility",{visibility:e})}setPermission(e,t){return this.rpc("permission",{participantId:e,permission:t})}revokeAccess(e){return this.rpc("revoke-access",{participantId:e})}pending(){return this.rpc("pending")}preview(e){return this.rpc("preview-read",{participantId:e})}previewWanted(e){return this.rpc("preview-demand",{runtime:e})}publishPreview(e,t,r){return this.rpc("preview-publish",{runtime:e,image:t,geometry:r})}review(e){return this.rpc("review",{id:e})}discard(e){return this.rpc("discard",{id:e})}submission(e,t){if(202===t&&!0===e.pendingApproval&&"string"==typeof e.submissionId)return{status:"pending-approval",submissionId:e.submissionId,threadId:"string"==typeof e.threadId?e.threadId:void 0};if(200===t&&"string"==typeof e.jobId&&"string"==typeof e.threadId&&"number"==typeof e.position)return{...e,status:"queued",jobId:e.jobId,threadId:e.threadId,position:e.position};throw new Error("Unexpected participant submission response")}async send(e,t,r){if(r.sourceId!==this.projectId)throw new Error("Source world mismatch");let a=await this.request("/send",e,{"X-Popmelt-Draft-Revision":String(t),"X-Popmelt-Source-Revision":r.revision});return this.submission(a.data,a.status)}contribute(e,t){return this.rpc("contribute",{threadId:e,text:t})}async approve(e,t){let r=await this.request("/participants/approve",{id:e,revision:t});return this.submission(r.data,r.status)}};async function C(e){let t,n=await k(e.projectRoot,e.directory,e.previousDirectory),p=new Map,c=new Map,l=new Map,d=new Map,u=j(32),h="",m=!1,f=!0,w=0,g=async()=>{let e=w,t=await n.capture();return h=t,e===w&&(f=!1),t};async function y(r){let i=l.get(r.id)||"/";if(r.id===await t){let e=await b();return{basePath:"/",path:i,version:e,basis:e}}let s=await n.findEditable(r.id),o="unversioned"===r.revision?void 0:r.revision;if(!s){let e=await b();if(!o||o===e)return{basePath:"/",path:i,version:e,basis:e}}let d=s||await n.retained(o),u=s?await n.basis(r.id):o,{basePath:h,app:f}=await async function(t,r){if(m)throw new Error("Plane session closed");let i=[...c.entries()].find(([,e])=>e.directory===t)?.[0];i||(i=a+"app/"+j(16).toString("hex")+"/",c.set(i,{directory:t,revision:r}));let s=p.get(t);if(!s){let a=i;s=e.startApp({directory:t,basePath:a,checkoutRoot:n.checkoutRoot(t),sourceRevision:r}).then(async e=>{let t;try{t=new URL(e.origin)}catch(t){throw await e.close(),t}if("http:"!==t.protocol||"127.0.0.1"!==t.hostname||t.origin!==e.origin)throw await e.close(),new Error("Plane app must serve a dedicated loopback origin");return c.get(a).app=e,e}).catch(e=>{throw p.delete(t),c.delete(a),e}),p.set(t,s)}let o=await s;return await(o.ready?.()),{basePath:i,app:o}}(d,u);return{basePath:h,path:i,version:f.version?.()||u,basis:u}}async function v(t,a,i,n,o){let p=t.planeAppBasis;if(!p)throw new Error("Participant plane authorization unavailable");let c,d=a.participantId,u=new O("http://127.0.0.1:"+t.port,t.projectId,a),h=await p(a,i);if(void 0!==n){if(d!==i||"string"!=typeof n||!/^\/(?!\/)/.test(n)||/[?#\\]/.test(n))throw new r(400,"Invalid plane route");let e=s(new URL(n,"http://localhost").pathname);if(e.startsWith("//")||e.startsWith("/__popmelt/"))throw new r(400,"Invalid plane route");c=e,!1!==o&&l.set(d,e)}let m={...await y(h),...e.interactivePage&&{interactivePage:!0}};c&&(m.path=c);let f=void 0===n?await u.read(i):{author:{id:d}};if((await p(a,i)).revision!==h.revision)throw new r(503,"Plane changed during selection");return{...f,application:m}}async function b(){return f||!h?g():h}return{capture:g,hostWorkspace:async()=>({revision:await b(),basePath:"/"}),hostBasis:b,open:v,checkout(t){if("/"===t)return e.projectRoot;let a=c.get(t);if(!a)throw new r(404,"Plane unavailable");return a.directory},async pageReader(e){let t=c.get(e);if(!t)throw new r(404,"Plane unavailable");let a=await p.get(t.directory);return await(a?.ready?.()),a?.pageReader},sourceChanged(){w++,f=!0},async servedAt(e){let t=c.get(i(e));if(!t){let e=await b();return{revision:e,appVersion:e}}let r=(await p.get(t.directory))?.version?.();return{revision:t.revision,appVersion:r??t.revision}},localPreview(e){for(let[t,r]of c)if(r.directory===e&&r.app)return{origin:r.app.origin,basePath:r.app.pageReader?"/":t}},findEditable:n.findEditable,forEdit:async(r,a,i=!1)=>i||r===await t?e.projectRoot:await n.findEditable(r)||n.editable(r,"unversioned"===a?await b():a),middleware(e,n,l){let h=new URL(n);if(!["127.0.0.1","localhost","[::1]"].includes(h.hostname)||h.origin!==n)throw new Error("Participant plane apps require a local app origin");t=e.participantHost?.().then(e=>e.participantId);let f=e.planeAppBasis;if(!f)throw new Error("Plane apps require a local participant bridge.");let w="popmelt-plane-"+P("sha256").update(e.projectId).digest("hex").slice(0,12);return async(t,g,y)=>{let b=t.url??"";if(!b.startsWith(a)){if(!b.startsWith("/")||b.startsWith("//")||b.startsWith("/__popmelt/")||!t.headers.referer||t.headers.host!==h.host||["document","iframe"].includes(String(t.headers["sec-fetch-dest"])))return y();let e;try{e=new URL(t.headers.referer)}catch{return y()}let r=e.origin===n&&i(e.pathname);return r&&c.has(r)?(g.setHeader("Cache-Control","private, no-store"),g.setHeader("Vary","Referer"),"GET"!==t.method&&"HEAD"!==t.method?(g.statusCode=405,void g.end()):(g.writeHead(307,{Location:r.slice(0,-1)+b}),void g.end())):y()}g.setHeader("Cache-Control","private, no-store"),g.setHeader("Referrer-Policy","same-origin"),g.setHeader("Cross-Origin-Resource-Policy","same-origin");let k=e=>{g.destroyed||g.writableEnded||(g.headersSent||(g.statusCode=e),g.end())};if(m||t.headers.host!==h.host||"cross-site"===t.headers["sec-fetch-site"])return k(403);try{if(b===a+"open"){if("POST"!==t.method||t.headers.origin!==n||"application/json"!==t.headers["content-type"])return k(403);let r=t.headers["x-popmelt-participant-id"],i=t.headers["x-popmelt-participant-token"];if("string"!=typeof r||"string"!=typeof i)return k(403);let s,o="";for await(let e of t)if(o+=e,o.length>8192)return k(413);try{s=JSON.parse(o)}catch{return k(400)}let{target:p,pathname:c,active:h}=s??{};if("string"!=typeof p)return k(400);let m={participantId:r,token:i},f=await v(e,m,p,c,h),{application:y}=f,b=I("sha256",u).update(i).digest("hex"),P=Date.now();for(let[e,t]of d)t.expires<=P&&d.delete(e);let j=d.get(b)??{proof:m,mounts:new Map,pages:new Map,expires:0};j.expires=P+36e5;let E=j.mounts.get(y.basePath)??new Set;if(E.add(p),l){let e=j.pages.get(y.basePath)??{routes:new Set,assets:new Set};e.routes.add(y.path),j.pages.set(y.basePath,e)}return j.mounts.set(y.basePath,E),d.set(b,j),g.setHeader("Set-Cookie",w+"="+b+"; Path="+a+"app/; HttpOnly; SameSite=Strict; Max-Age=3600"),g.setHeader("Content-Type","application/json"),void g.end(JSON.stringify(f))}if("GET"!==t.method&&"HEAD"!==t.method)return k(405);let h=new URL(b,n).pathname,m=i(h),y=m&&c.get(m);if("/"===m)return k(404);let P=t.headers.cookie?.split(";").map(e=>e.trim()).find(e=>e.startsWith(w+"="))?.slice(w.length+1),j=P&&d.get(P);if(!y||!j||j.expires<=Date.now()||!j.mounts.has(m)){if("document"===t.headers["sec-fetch-dest"]&&"navigate"===t.headers["sec-fetch-mode"]){let e=s(h);if(!e.startsWith("//")&&!e.startsWith("/__popmelt/"))return g.writeHead(302,{Location:e+new URL(b,n).search}),void g.end()}return k(y?403:404)}let S=j.mounts.get(m);for(let e of S)try{await f(j.proof,e);break}catch(t){if(!(t instanceof r)||404!==t.statusCode)throw t;S.delete(e)}if(!S.size)return k(404);let x=s(h),A=j.pages.get(m)?.routes,H=A?.has(x)?x:o(x),_=A?.has(H),q=["document","iframe"].includes(String(t.headers["sec-fetch-dest"]))||!!t.headers.accept?.includes("text/html")||"HEAD"===t.method&&!0===_,O=await p.get(y.directory);if(!O)return k(503);if(await(O.ready?.()),O.pageReader&&l){let r=new URL(b,n),a=j.pages.get(m);if(!a)return k(403);if(q&&!a.routes.has(H))return k(404);let i=await O.pageReader({url:r,document:q,sharedPath:H,basePath:m,assets:a.assets,projectId:e.projectId,bootstrap:await l(h)});return i?(g.statusCode=i.status,i.headers.forEach((e,t)=>g.setHeader(t,e)),void g.end("HEAD"===t.method?void 0:Buffer.from(await i.arrayBuffer()))):k(404)}let C=E(new URL(b,O.origin),{method:t.method,headers:{accept:t.headers.accept||"*/*"}});C.setTimeout(3e4,()=>C.destroy(new Error("Plane app timed out"))),g.on("close",()=>C.destroy()),C.on("error",()=>k(502)),C.on("response",e=>{g.statusCode=e.statusCode??502;let t=e.headers["content-type"];if(t&&g.setHeader("Content-Type",t),e.headers.location){let t;try{t=new URL(e.headers.location,new URL(b,O.origin))}catch{return e.resume(),k(502)}if(t.origin!==O.origin||!t.pathname.startsWith(m))return e.resume(),k(502);g.setHeader("Location",t.pathname+t.search)}R(e,g).catch(()=>g.destroy())}),C.end()}catch(e){let t=e instanceof r?e.statusCode:e instanceof q?e.status:void 0;k(t&&t>=400&&t<500?t:503)}}},async close(){m=!0,d.clear();let e=(await Promise.allSettled([...p.values()].map(async e=>(await e).close()))).find(e=>"rejected"===e.status);if("rejected"===e?.status)throw e.reason}}}import{execFile as L}from"child_process";import{createHash as M}from"crypto";import{lstat as W,mkdir as D,readFile as U,realpath as T,writeFile as N}from"fs/promises";import{basename as X,dirname as B,join as F,relative as G}from"path";import{promisify as J}from"util";var V=J(L),z={"npm-shrinkwrap.json":"npm","package-lock.json":"npm","pnpm-lock.yaml":"pnpm","yarn.lock":"yarn","bun.lock":"bun","bun.lockb":"bun"},K=[...Object.keys(z),"pnpm-workspace.yaml",".npmrc",".yarnrc.yml",".pnpmfile.cjs","bunfig.toml"],Z=["dependencies","devDependencies","optionalDependencies","peerDependencies","peerDependenciesMeta","overrides","resolutions","pnpm","workspaces","packageManager","dependenciesMeta","bundledDependencies","bundleDependencies","engines","os","cpu"];function $(e){let t=X(e);return"package.json"===t||K.includes(t)}async function Y(e){try{return await e}catch(e){if("ENOENT"!==e.code)throw e}}function Q(e,t){return!t||"object"!=typeof t||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:e>t?1:0))}async function ee(e,t,r){let a,i;for(let r=e;;r=B(r)){let e=await Y(U(F(r,"package.json"),"utf8")),s=await Promise.all([...Object.keys(z),"pnpm-workspace.yaml"].map(e=>Y(W(F(r,e)))));if(e&&(a??=r),s.some(Boolean)||e&&JSON.parse(e).workspaces){i=r;break}if(r===t)break}if(i??=a,!i)return;let s=JSON.parse(await Y(U(F(i,"package.json"),"utf8"))??"{}"),n=M("sha256"),o=M("sha256"),p=await Promise.all(K.map(async e=>[e,await Y(U(F(i,e)))])),c=new Set;for(let[e,t]of p){if(!t)continue;c.add(e);let r=M("sha256").update(t).digest();n.update(e+"\0").update(r),e in z||o.update(e+"\0").update(r)}let l=!!s.workspaces||c.has("pnpm-workspace.yaml"),d=new Set(["package.json",G(i,F(e,"package.json"))]);if(l){let{stdout:e}=await V("git",["ls-files","--cached","--others","--exclude-standard","-z","--",":(glob)**/package.json",":(exclude,glob)**/node_modules/**",":(exclude,glob)**/.popmelt/**"],{cwd:i,maxBuffer:16777216});for(let t of e.split("\0").filter(Boolean))d.add(t)}for(let e of[...d].sort()){let t=await Y(U(F(i,e),"utf8"));if(!t)continue;let r=JSON.parse(t),a=l?[...Z,"name","version"]:Z,s=Object.fromEntries(a.filter(e=>e in r).map(e=>[e,r[e]]));o.update(e+"\0").update(JSON.stringify(s,Q)+"\0")}let u=new Set(Object.entries(z).filter(([e])=>c.has(e)).map(([,e])=>e));c.has("pnpm-workspace.yaml")&&u.add("pnpm");let h=s.packageManager?.split("@")[0]??(u.size>1?"ambiguous":[...u][0])??"npm",m=o.update(h).digest("hex");return n.update(m),r&&i!==e&&r([...d,...K].map(e=>F(i,e))),{root:i,key:n.digest("hex"),manifestKey:m,manager:h,pnpmWorkspace:c.has("pnpm-workspace.yaml"),manifests:d,present:c}}async function te(e,t,r,a){let i=F(r,G(e,t)),[s,o]=await Promise.all([ee(e,t),ee(r,i,a)]);if(!s)return{installed:!1,graph:"shared"};let p=F(s.root,"node_modules"),c=F(p,".popmelt-install"),l=await Y(U(c,"utf8"));return l===s.key?{installed:!1,graph:"private:"+s.key}:s.key===o?.key&&void 0===l?{installed:!1,graph:"shared:"+s.key}:n(F(t,".popmelt","dependencies.lock"),async()=>{let r=await ee(e,t);if(!r)return{installed:!1,graph:"shared"};let a=F(r.root,"node_modules",".popmelt-install");if(await Y(U(a,"utf8"))===r.key)return{installed:!1,graph:"private:"+r.key};for(let e of[...r.manifests,...r.present]){let t=F(r.root,e),a=await Y(T(t));if(a&&a!==t)throw new Error("Automatic plane installation requires local dependency files: "+e)}await async function(e){for(let t of e.manifests){let r=F(e.root,B(t),"node_modules"),a=await Y(W(r));if(a&&(a.isSymbolicLink()||await T(r)!==r))throw new Error("Plane node_modules points outside its install directory. Use a custom prepare hook.")}let t,r=e.root,a={...process.env,CI:"true",npm_config_global:"false"};switch(e.manager){case"npm":t=["install","--prefix",".","--ignore-scripts","--no-audit","--no-fund","--include=dev"];break;case"pnpm":t=["install","--ignore-scripts","--no-frozen-lockfile","--config.modules-dir=node_modules","--config.virtual-store-dir=node_modules/.pnpm",...e.pnpmWorkspace?[]:["--ignore-workspace"]];break;default:throw new Error("Automatic plane installs require npm or pnpm. Configure participantPlanes.prepare for "+e.manager+".")}await D(F(r,"node_modules"),{recursive:!0}),await N(F(r,"node_modules",".popmelt-install"),"pending"),await V(e.manager,t,{cwd:r,env:a,shell:"win32"===process.platform,timeout:18e4,maxBuffer:4194304})}(r);let i=await ee(e,t);if(!i||r.root!==i.root||r.manifestKey!==i.manifestKey)throw new Error("Plane dependencies changed during installation. Retry with the current manifest.");return await D(F(i.root,"node_modules"),{recursive:!0}),await N(F(i.root,"node_modules",".popmelt-install"),i.key),{installed:!0,graph:"private:"+i.key}},185e3)}export{k as a,C as b,$ as c,te as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{O as r}from"./chunk-KE4MQBRY.mjs";import{useState as e,useEffect as n}from"react";import{jsx as t}from"react/jsx-runtime";var o="@keyframes popmelt-looking-blink { 0%, 40%, 72.5%, 100% { transform: scaleY(1); } 50%, 62.5% { transform: scaleY(0.1); } }";function a(r){return{windowIndex:r,delay:4e3*Math.random()}}function i(){let[o,i]=e(()=>a(0));return n(()=>{let r=0,e=window.setInterval(()=>i(a(++r)),5e3);return()=>window.clearInterval(e)},[]),t(r,{x:5.5,y:5.5,size:13,strokeWidth:2.4,color:"#fff",style:{animationDelay:o.delay+"ms",animationDuration:"1000ms"}},o.windowIndex)}export{o as a,i as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./chunk-
|
|
1
|
+
import{c as t}from"./chunk-OSUJWNS2.mjs";import{f as r}from"./chunk-QKJPWA2I.mjs";import{q as e}from"./chunk-XNCN6DGG.mjs";import{f as a}from"./chunk-BSVZXOOS.mjs";async function o(o,s){let i=await a(o);if(!i||!s)return[];let n=await e(o,s);return n.length?(await Promise.all([i,...i.mountedStores].map(async e=>{try{let a=await t(e,o);if(!a)return[];let{endpoint:s,request:i}=a,m=[];for(let t of n){let a=await r(s,"/participants/read-canvas-receipt",{...i,method:"POST",body:JSON.stringify({receiptId:t})});a.response.ok&&m.push({storeId:e.storeId,receipt:a.body})}return m}catch{return[]}}))).flat():[]}export{o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{l as e,a as t,i as r,j as n}from"./chunk-EEU5J3CD.mjs";import{b as o}from"./chunk-LEMLTB2X.mjs";var a=new Set;function i(e,r){let n=new URL(e).origin;"websocket"===r&&new URL(e).pathname!==t?a.add(n):a.delete(n)}function s(t){return a.has(new URL(t).origin)?new l(t,!0):e(t)?new l(t):new EventSource(t)}var l=class{constructor(e,r=!1){if(this.readyState=0,this.onerror=null,this.controller=new AbortController,this.listeners=new Map,this.fail=()=>{this.controller.signal.aborted||(this.readyState=2,this.controller.abort(),this.emit("error",""),this.onerror?.call(this,new Event("error")))},new URL(e).pathname===t+"/events"){let e=setTimeout(this.fail,15e3),t=()=>clearTimeout(e);this.addEventListener("connected",t),this.controller.signal.addEventListener("abort",t,{once:!0})}typeof document<"u"&&document.addEventListener("resume",this.fail,{signal:this.controller.signal}),this.read(e,r)}addEventListener(e,t){let r=this.listeners.get(e)??new Set;r.add(t),this.listeners.set(e,r)}close(){this.readyState=2,this.controller.abort(),this.listeners.clear()}emit(e,t){let r=new MessageEvent(e,{data:t});for(let t of this.listeners.get(e)??[])t(r)}async read(e,t){try{if(t){let{readBridgeWebSocket:t}=await(import("./bridgeWebSocketStream-L277I5ZX.mjs"));return void await t(e,this.controller.signal,(e,t)=>{"connected"===e&&(this.readyState=1),this.emit(e,t)})}let{readBridgeSSE:r}=await(import("./bridgeSSEStream-BHUFYHTT.mjs"));await r(e,this.controller.signal,()=>{this.readyState=1},(e,t)=>this.emit(e,t))}catch{this.fail()}}},c="http://localhost:1111",d=new Map;function u(){return typeof window<"u"?window.__POPMELT_PROJECT_ID__??null:null}function p(e,t={}){return r(e,function(e={}){let t=u();if(!t)return e;let r=new Headers(e.headers);return r.set("X-Popmelt-Project-Id",t),{...e,headers:r}}(t))}async function h(e,t,r){let n=new URLSearchParams({annotationId:t,kind:r.kind,name:r.name}),o=await m(`${e}/draft-attachments?${n}`,{method:"POST",headers:{"Content-Type":r.blob.type},body:r.blob},15e3);if(!o.ok)throw new Error((await o.json().catch(()=>null))?.error||`Bridge returned ${o.status}`);return(await o.json()).attachment}async function f(e,t){0!==t.length&&await m(`${e}/draft-attachments/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:t})},5e3)}async function w(e,t){await m(`${e}/draft-attachments/${encodeURIComponent(t)}`,{method:"DELETE"},5e3)}async function g(e,t){if((d.get(e)??0)>Date.now())return null;try{let r=await m(`${e}/capture/native`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageUrl:t.url,clip:t.clip,scale:t.scale})},2500);if(!r.ok)return d.set(e,Date.now()+(404===r.status||501===r.status?6e4:1e4)),null;let n=await r.blob();return n.size>0?n:null}catch{return d.set(e,Date.now()+1e4),null}}function m(e,t={},r=15e3){let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let o=setTimeout(()=>n.abort(),r);return p(e,{...t,signal:n.signal}).finally(()=>clearTimeout(o))}async function y(e=c){try{let t=await m(`${e}/ui-preferences`,{},5e3);return t.ok?await t.json():null}catch{return null}}async function b(e,t){try{let r=await m(`${e}/ui-preferences`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:t})},5e3);return r.ok?await r.json():null}catch{return null}}async function $(e=c,t){try{let r=t?`?refresh=${encodeURIComponent(t)}`:"",n=await m(`${e}/capabilities${r}`,{},t?35e3:5e3);return n.ok?await n.json():null}catch{return null}}async function I(e,t,r="/status"){let o=n(e),a=new AbortController,s=setTimeout(()=>a.abort(),t);try{let t=await p(`${e}${r}`,{signal:a.signal});if(!t.ok)return o?.(t.status,void 0,t.headers.get("X-Popmelt-Pair-State")),null;let n=await t.json();return!0===n?.ok&&o?.(t.status,n.projectId),i(e,n.eventTransport),n}catch{return o?.(0),null}finally{a.abort(),clearTimeout(s)}}async function j(e=c){return I(e,typeof location<"u"&&e===location.origin+t?8e3:2e3)}async function v(e){return I(`http://localhost:${e}`,500,"/status?discovery=1")}async function S(e){return j(e)}async function k(e,r){if(typeof location<"u"&&e&&(e===location.origin+t||o(e??""))){let t=await S(e);return r&&t?.projectId===r?{url:e,port:Number(location.port)||443,projectId:r}:null}if(e&&e!==c)try{let t=new URL(e),n=await S(e);if(!n&&!r)return null;if((n||!r)&&(!n||!r||n.projectId===r)){if(n?.projectId&&!r)return null;if(n)return{url:e,port:parseInt(t.port,10)||1111,projectId:n.projectId}}}catch{if(!r)return null}let n=typeof window<"u"?window.location.origin:null,a=await v(1111);if(a){if(r&&a.projectId===r)return{url:"http://localhost:1111",port:1111,projectId:a.projectId};if(a.devOrigin&&n&&a.devOrigin===n&&!r&&!a.projectId)return{url:"http://localhost:1111",port:1111,projectId:a.projectId}}let i=function(e=1111){return Array.from({length:Math.min(32,65536-e)},(t,r)=>e+r)}().slice(1).map(e=>v(e).then(t=>t?{status:t,port:e}:null)),s=(await Promise.all(i)).filter(e=>null!==e),l=[];a&&l.push({port:1111,devOrigin:a.devOrigin,projectId:a.projectId});for(let e of s)l.push({port:e.port,devOrigin:e.status.devOrigin,projectId:e.status.projectId});if(r){let e=l.find(e=>e.projectId===r);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}if(n){let e=l.find(e=>e.devOrigin===n&&!e.projectId);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}return 1!==l.length||l[0].projectId?null:{url:`http://localhost:${l[0].port}`,port:l[0].port,projectId:l[0].projectId}}async function T(e=c,t,r=-1,n={}){try{let o=await m(`${e}/jobs/${t}/events?afterSeq=${r}`,{},5e3);if(404===o.status||410===o.status)return null;if(!o.ok){if(n.retryUnavailable&&(429===o.status||o.status>=500))throw new Error("Bridge history is temporarily unavailable");return null}return await o.json()}catch(e){if(n.retryUnavailable)throw e;return null}}async function E(e,t,r=c,n,o,a,i,s,l,d,u,p,h){let f=O({screenshots:e,feedbackJson:t,color:n,provider:o,model:a,pastedImages:i,sourceId:s,agentSettings:l,continuationThreadId:d,continuationSelectorAliases:u,continuationTargetBindingId:p}),w=await m(`${r}/send`,{method:"POST",body:f,...h?{headers:{"X-Popmelt-Peer-Grant":h}}:{}},3e4);if(!w.ok){let e=await w.text();throw new Error(`Bridge returned ${w.status}: ${e}`)}return w.json()}function O({screenshots:e,feedbackJson:t,color:r,provider:n,model:o,pastedImages:a,sourceId:i,agentSettings:s,continuationThreadId:l,continuationSelectorAliases:c,continuationTargetBindingId:d}){let u=new FormData;if(e instanceof Map){let t=!0;for(let[r,n]of e){let e=encodeURIComponent(r);u.append(`screenshot-${e}`,n,`screenshot-${e}.webp`),t&&(u.append("screenshot",n,"screenshot.webp"),t=!1)}t&&u.append("screenshot",new Blob([],{type:"image/webp"}),"screenshot.webp")}else u.append("screenshot",e,"screenshot.webp");if(u.append("feedback",t),r&&u.append("color",r),n&&u.append("provider",n),o&&u.append("model",o),function(e,t){t?.reasoningEffort&&e.append("reasoningEffort",t.reasoningEffort),t?.serviceTier&&e.append("serviceTier",t.serviceTier)}(u,s),i&&u.append("sourceId",i),l&&u.append("continuationThreadId",l),d&&u.append("continuationTargetBindingId",d),c?.length&&u.append("continuationSelectorAliases",JSON.stringify(c)),a)for(let[e,t]of a)for(let r=0;r<t.length;r++)u.append(`image-${e}-${r}`,t[r],`image-${e}-${r}.webp`);return u}async function P(e=c){let t=()=>({head:{sequence:0,updatedAt:new Date(0).toISOString()},counts:{total:0,emerging:0,testing:0,grounded:0,challenged:0,retired:0,needsGrounding:0},explanations:[]});try{let r=await m(`${e}/memory/imprint-view`,{},5e3);return r.ok?r.json():t()}catch{return t()}}function B(e){return new Promise(t=>setTimeout(t,e))}async function U(e=c,t,r=15e3){let n=Date.now();try{let t=await m(`${e}/restart`,{method:"POST"},5e3);if(!t.ok){let e=await t.text().catch(()=>"");return{ok:!1,error:e?`Bridge restart returned ${t.status}: ${e}`:`Bridge restart returned ${t.status}`,elapsedMs:Date.now()-n}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"Bridge restart request failed",elapsedMs:Date.now()-n}}let o=null,a=e,i=u();for(;Date.now()-n<r;){if(await B(350),o=await j(a),!o?.ok&&i){let t=await k(e,i);t?.url&&(a=t.url,o=await j(a))}if(o?.ok&&(!i||o.projectId===i)&&(!t||o.version===t))return{ok:!0,status:o,elapsedMs:Date.now()-n,bridgeUrl:a}}let s=t?` with version ${t}`:"";return o?.ok&&t&&o.version!==t?{ok:!1,error:`Bridge is running version ${o.version??"unknown"}, but this page expects ${t}. Refresh the page to load the current package. If the mismatch remains, rebuild or update the package used by the bridge, then restart it.`,status:o,elapsedMs:Date.now()-n}:{ok:!1,error:`Bridge did not come back${s} within ${Math.round(r/1e3)}s`,status:o,elapsedMs:Date.now()-n}}async function C(e=c){return(await U(e)).ok}async function D(e,t,r=c,n,o,a,i,s,l,d){let u,p=`${r}/reply`;if(i&&i.length>0){let r=new FormData,c=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});r.append("screenshot",c,"screenshot.png"),r.append("feedback",JSON.stringify({threadId:e,reply:t,color:n,provider:o,model:a,sourceId:s,...l,...d}));for(let e=0;e<i.length;e++)r.append(`image-reply-${e}`,i[e],`reply-image-${e}.webp`);u={method:"POST",body:r}}else u={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:n,provider:o,model:a,sourceId:s,...l,...d})};let h=await m(p,u,3e4);if(!h.ok){let e=await h.json().catch(()=>null);throw new Error("string"==typeof e?.error?e.error:`Bridge returned ${h.status}`)}return h.json()}async function L(e,t=c,r=!1){let n=await m(`${t}/thread/${encodeURIComponent(e)}/archive${r?"?cancelQueued=true":""}`,{method:"POST"},15e3);if(!n.ok&&404!==n.status){let e=await n.text();throw new Error(`Bridge returned ${n.status}: ${e}`)}return n.json()}async function M(e,t=c){let r=await m(`${t}/thread/${encodeURIComponent(e)}/restore`,{method:"POST"},15e3);if(!r.ok)throw new Error(`Thread restore failed: ${r.status}`)}async function R(e=c){let t=await m(`${e}/workspace/clear`,{method:"POST"},5e3);if(!t.ok){let e=await t.text();throw new Error(`Bridge returned ${t.status}: ${e}`)}return t.json()}export{s as a,p as b,h as c,f as d,w as e,g as f,y as g,b as h,$ as i,j,k,T as l,E as m,O as n,P as o,U as p,C as q,D as r,L as s,M as t,R as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{c as i}from"./chunk-CK3CDA3L.mjs";import{a}from"./chunk-
|
|
1
|
+
"use client";import{c as i}from"./chunk-CK3CDA3L.mjs";import{a}from"./chunk-ECGXE2Z6.mjs";import{a as e}from"./chunk-BH5BNULT.mjs";import{forwardRef as r}from"react";import{jsx as n,jsxs as t}from"react/jsx-runtime";var o={gap:16,padding:12,radius:20,width:360,viewportGutter:32,identitySize:24},d=`calc(100vw - ${o.viewportGutter}px)`,p={gap:6,padding:"4px 8px",radius:8,iconSize:12},s={gap:3,padding:"2px 6px",radius:8,iconSize:12},c={gap:3,padding:"3px 9px 3px 6px",radius:8,iconSize:10},h=c,l={size:21,padding:3,radius:8,iconSize:15},g={padding:"0 4px",height:18,radius:6},u={fontFamily:e,fontSize:12,fontWeight:500,lineHeight:1.3};function m(i){return{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:s.gap,padding:s.padding,borderRadius:s.radius,border:0,flexShrink:0,background:a[i].control,color:a[i].primary,...u,whiteSpace:"nowrap",cursor:"pointer",transition:"box-shadow 120ms ease"}}var f={compact:{height:24,icon:12},regular:{height:28,icon:14},large:{height:40,icon:16}},b=r(function({theme:a,variant:e="filled",size:r="compact",icon:o,hint:d,above:p,anchorRef:s,hoverDelayMs:c,onReveal:h,style:l,disabled:g,children:u,...b},x){let y,{height:v,icon:z}=f[r],S=o&&null==u;function w(i){return t("button",{type:"button",...b,"aria-describedby":i?[b["aria-describedby"],i].filter(Boolean).join(" "):b["aria-describedby"],ref:x,disabled:g,style:y?{...y,...l}:l,children:[o&&n(o,{size:S?16:z,"aria-hidden":!0}),u]})}return a&&"custom"!==e&&(y={...m(a),minHeight:v,..."compact"!==r&&{padding:"4px 10px",gap:4,fontSize:14},..."ghost"===e&&{background:"transparent"},...S&&{width:v,padding:0},...g&&{opacity:.6,cursor:"default"}}),void 0===d?w():n(i,{hint:!0===d?b["aria-label"]:d,above:p,anchorRef:s,hoverDelayMs:c,onReveal:h,children:w})});export{o as a,d as b,p as c,s as d,c as e,h as f,l as g,g as h,u as i,m as j,b as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t,f as e}from"./chunk-QKJPWA2I.mjs";import{p as r,z as a}from"./chunk-XNCN6DGG.mjs";import{readFile as i,realpath as o,mkdir as n,writeFile as s}from"fs/promises";import{createHash as c}from"crypto";import{join as p,resolve as d}from"path";import{getPopmeltProjectId as l}from"./project-id.mjs";function u(t,e){let r=c("sha256").update(e).digest("hex");return p(t,".popmelt","participant-agents",r+".json")}async function f(t,r){if(r.storeId!==t.storeId)return{ok:!1,body:{status:"writable_store_required"}};if("string"!=typeof r.threadId||!r.threadId||"string"!=typeof r.text||!r.text.trim()||r.text.length>8e3)return{ok:!1,body:{status:"invalid_note"}};let a;try{a=await m(t,t.sessionId,!0)}catch(t){if("ENOENT"!==t.code)throw t;return{ok:!1,body:{status:"participant_invitation_required"}}}if(!a)return{ok:!1,body:{status:"enrolled_bridge_required"}};let i=await e(a.endpoint,"/participants/thread-note",{...a.request,method:"POST",signal:AbortSignal.timeout(3e4),body:JSON.stringify({storeId:t.storeId,threadId:r.threadId,reply:r.text,sessionId:t.sessionId,requestId:r.requestId})});return{ok:i.response.ok,body:i.body}}async function m(t,a,n=!1){let s=await i(p(t.projectRoot,".popmelt","participant-bridge.json"),"utf8").then(JSON.parse).catch(e=>{if("ENOENT"!==e.code||!t.bridgePort)throw e;return{projectId:t.projectId,port:t.bridgePort}});if(s.projectId!==t.projectId||!Number.isInteger(s.port)||s.port<1||s.port>65535)return null;let c={redirect:"error",signal:AbortSignal.timeout(3e3)},d=await e(s,"/status",c);if(!d.response.ok||d.body?.projectId!==t.projectId)return null;let f,m=u(t.projectRoot,a);try{f=JSON.parse(await i(m,"utf8"))}catch(d){if("ENOENT"!==d.code||!n)throw d;let u=await o(t.projectRoot),h=r(a);if(l(u)!==t.projectId||!h)return null;let g=JSON.parse(await i(p(u,".popmelt","participant-host.json"),"utf8"));if(!(await e(s,"/participants/agent-join",{...c,method:"POST",headers:{"X-Popmelt-Participant-Id":g.participantId,"X-Popmelt-Participant-Token":g.token},body:JSON.stringify({sessionId:a,name:h,headless:!0})})).response.ok)return null;f=JSON.parse(await i(m,"utf8"))}return{endpoint:s,request:{...c,headers:{"X-Popmelt-Participant-Id":f.participantId,"X-Popmelt-Participant-Token":f.token}}}}async function h(t,r,a){let i=[t,...t.mountedStores].find(t=>t.storeId===r.storeId);if(!i||a&&i!==t)return{ok:!1,body:{status:"store_unavailable"}};if(a&&("string"!=typeof r.threadId||!r.threadId))return{ok:!1,body:{status:"thread_required"}};let o=await m(i,t.sessionId,a).catch(t=>{if("ENOENT"===t.code)return null;throw t});if(!o)return{ok:!1,body:{status:"enrolled_bridge_required",message:"Join this project as a Popmelt peer and check that its bridge is running."}};let{endpoint:n,request:s}=o,c=await e(n,a?t.sessionId.startsWith("claude:")?"/participants/link-claude-chat":"/participants/link-codex-chat":"/participants/check-claude-notes",{...s,method:"POST",body:JSON.stringify({sessionId:t.sessionId,...a?{threadId:r.threadId}:{}})});return{ok:c.response.ok,body:c.body}}async function g(r,d,f={}){if(t())return{status:"already_managed_by_bridge"};if((await e(r,"/status",{redirect:"error",signal:AbortSignal.timeout(3e3)})).body?.participantSessions)return async function(t,r,d){if(!d.projectRoot)throw new Error("Participant connections require the active project root");let f=await o(d.projectRoot);if(l(f)!==t.projectId)throw new Error("Participant project does not match");let m,h,g=p(f,".popmelt"),w=c("sha256").update(r).digest("hex"),I=async(r,a,i)=>{let o=await e(t,"/participants/"+r,{method:"POST",redirect:"error",headers:{"X-Popmelt-Participant-Id":a.participantId,"X-Popmelt-Participant-Token":a.token},body:JSON.stringify(i),signal:AbortSignal.timeout(9e4)}),n=o.body;if(!o.response.ok||n.error)throw new Error(n.error??"Participant connection unavailable");return n};try{m=JSON.parse(await i(u(f,r),"utf8"))}catch(t){if("ENOENT"!==t.code)throw t;if(!d.name)return{status:"participant_invitation_required"};let e=JSON.parse(await i(p(g,"participant-host.json"),"utf8")),a=await I("agent-join",e,{sessionId:r,name:d.name});m=a.credential,h=a.participant}if(!d.action){let t=await I("agent-connect",m,{});return{status:"participant_connected",participantId:m.participantId,participant:t.participant??h}}let y=await I("agent-act",m,{action:a(d.action)}),b=y.evidence;if(b?.frame?.image){let t=b.frame.image;if(!/^data:image\/jpeg;base64,[A-Za-z0-9+/=]+$/.test(t)||t.length>7e5)throw new Error("Invalid participant preview");let e=p(g,"artifacts","participant-previews");await n(e,{recursive:!0,mode:448});let r=p(e,w+".jpg");return await s(r,Buffer.from(t.slice(t.indexOf(",")+1),"base64"),{mode:384}),{status:"participant_connected",participant:y.participant,evidence:{...b,frame:{imagePath:r,targets:b.frame.targets}}}}return{status:"participant_connected",participant:y.participant,evidence:y.evidence}}(r,d,f);let m=async(t,a)=>{let i=await e(r,`/peers/${t}`,{method:"POST",body:JSON.stringify(a),signal:AbortSignal.timeout(5e4)}),o=i.body;if(!i.response.ok||o?.error)throw new Error(o?.error??"Peer connection unavailable");return o},h=await m("join",{sessionId:d,name:f.name}),g=f.action?await m("act",{token:h.token,clientId:f.clientId,action:a(f.action)}):h,w=g.peer;return{...g.status?{status:g.status}:{},...w?{peer:{...w,state:w.state?{annotations:w.state.annotations,styleModifications:w.state.styleModifications,textModifications:w.state.textModifications,undoDepth:w.state.undoStack.length,redoDepth:w.state.redoStack.length}:null}}:{},...g.evidence?{evidence:g.evidence}:{},clients:h.clients}}async function w(t){let r=e=>{let r=t.indexOf(e);return r>=0?t[r+1]:void 0},a=r("--session");if(!a)throw new Error("Usage: popmelt peer --session <stable-agent-session> [--project-root <active-project>] [--name <your-name>] [--client <canvas-id>] [--action <JSON>]");let n=await o(d(r("--project-root")??process.cwd())),s=JSON.parse(await i(p(n,".popmelt","bridge.lock"),"utf8")),c=l(n),u=await e({port:s.port,projectId:c},"/status",{signal:AbortSignal.timeout(3e3)});if(!u.response.ok||u.body.projectRoot!==n&&(!u.body.participantSessions||u.body.projectId!==c))throw new Error("No matching running project bridge");let f=r("--action");console.log(JSON.stringify(await g({port:s.port,projectId:c},a,{name:r("--name"),projectRoot:n,clientId:r("--client"),action:f?JSON.parse(f):void 0}),null,2))}export{u as a,f as b,m as c,h as d,g as e,w as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";function t(t,e){return JSON.stringify([t,e??null])}function e(e){return(e.annotations?.length?e.annotations:[{id:void 0,label:"Submitted changes"}]).map(n=>({submission:e,annotation:n,key:t(e.id,n.id)}))}function n(t,n){return t.filter(t=>t.threadId===n).flatMap(t=>e(t).map(t=>t.key))}function r(t,e){let n=[],r=()=>{try{let r=JSON.parse(t.getItem(e)??"[]");Array.isArray(r)&&(n=[...new Set([...r.filter(t=>"string"==typeof t),...n])].slice(-1e3))}catch{}return n},a=a=>{let i=r(),s=a.filter(t=>!i.includes(t));if(!s.length)return i;let l=[...new Set([...i,...s])].slice(-1e3);n=l;try{t.setItem(e,JSON.stringify(l))}catch{}return l};return{read:r,markMany:a,mark:t=>a([t])}}export{t as a,e as b,n as c,r as d};
|