@popmelt.com/core 0.24.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -2
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ParticipantRuntime-5WM2XJT7.mjs +139 -0
- package/dist/PopmeltTasteConnectedPane-IXJ2KAPX.mjs +81 -0
- package/dist/PreviewRuntime-ATSECGMB.mjs +2 -0
- package/dist/bridge-entry.mjs +84 -71
- package/dist/browser-runtime-O5GITMZB.mjs +2 -0
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-NV55QGKG.mjs → chunk-7IVK4FEU.mjs} +1 -1
- package/dist/chunk-CWVRJOGB.mjs +370 -0
- package/dist/chunk-EH5Y2F4E.mjs +77 -0
- package/dist/chunk-FRHGK5ZV.mjs +2 -0
- package/dist/chunk-J2OX47QB.mjs +345 -0
- package/dist/{chunk-TJVWZRAF.mjs → chunk-MGIH5NQE.mjs} +1 -1
- package/dist/chunk-NXMPY7RX.mjs +2 -0
- package/dist/chunk-ZJPPZLXU.mjs +2 -0
- package/dist/cli.mjs +109 -96
- package/dist/index.mjs +1 -1
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-next.d.mts +6 -2
- package/dist/plugin-next.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server-QHSVIUQW.mjs +241 -0
- package/dist/server.d.mts +7 -0
- package/dist/server.mjs +87 -74
- package/package.json +4 -1
- package/dist/ParticipantRuntime-6QPULJPO.mjs +0 -139
- package/dist/PreviewRuntime-NGTLOEX3.mjs +0 -2
- package/dist/browser-runtime-3UZPA2SA.mjs +0 -2
- package/dist/chunk-3XSTOVWX.mjs +0 -2
- package/dist/chunk-D4ZJC7OV.mjs +0 -301
- package/dist/chunk-ENERPQJN.mjs +0 -2
- package/dist/chunk-ZL4X7KBW.mjs +0 -413
- package/dist/server-M6OXW7FE.mjs +0 -228
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"./chunk-NOHXTT24.mjs";import{request as c}from"http";function u(){let e=process.env.POPMELT_BRIDGE_URL;if(!e)return null;try{let t=new URL(e);return{port:t.port?Number.parseInt(t.port,10):null,projectId:process.env.POPMELT_PROJECT_ID||null,leaseEligible:!1}}catch{return null}}async function h(e,t,i){let r=u();if(e?.bridge===!1||r)return r??{port:null,projectId:null,leaseEligible:!1};try{let{startPopmelt:o}=await import("./server-
|
|
1
|
+
import{a as p}from"./chunk-NOHXTT24.mjs";import{request as c}from"http";function u(){let e=process.env.POPMELT_BRIDGE_URL;if(!e)return null;try{let t=new URL(e);return{port:t.port?Number.parseInt(t.port,10):null,projectId:process.env.POPMELT_PROJECT_ID||null,leaseEligible:!1}}catch{return null}}async function h(e,t,i){let r=u();if(e?.bridge===!1||r)return r??{port:null,projectId:null,leaseEligible:!1};try{let{startPopmelt:o}=await import("./server-QHSVIUQW.mjs"),n=t.config?.server?.host,l=n===!0?"0.0.0.0":n||"localhost",s=t.config?.server?.port??i,d=`http://${l==="0.0.0.0"?"localhost":l}:${s}`,a=await o({port:e?.port,projectRoot:e?.projectRoot,devOrigin:d,force:!0,detached:!0,manageLease:!1});return console.log(`[popmelt] bridge ready at http://localhost:${a.port}`),{port:a.port,projectId:a.projectId,leaseEligible:!0}}catch(o){let n=o instanceof Error?o.message:String(o);return console.warn("[popmelt] bridge failed to start:",n),{port:null,projectId:null,leaseEligible:!1}}}async function v(e,t,i=fetch){if(!e.leaseEligible||e.port===null)return null;let r=await p({port:e.port,projectId:e.projectId},i);if(!r)return null;let o=()=>{n()},n=async()=>{process.removeListener("beforeExit",o),await r.release()};return process.once("beforeExit",o),t.httpServer?.once("close",()=>{n()}),{id:r.id,release:n}}function g(e,t,i){if(i.port===null)return null;let r=new URL(t,"http://popmelt.local");if(r.pathname!==`${e}/status`)return null;let o=new URL("/status",`http://localhost:${i.port}`);return r.searchParams.forEach((n,l)=>o.searchParams.append(l,n)),i.projectId&&o.searchParams.set("projectId",i.projectId),o}function b(e,t){return(i,r,o)=>{let n=g(e,i.url||"",t());if(!n)return o();let l=c(n,{method:i.method,headers:{...i.headers,host:n.host}},s=>{r.writeHead(s.statusCode||502,s.headers),s.pipe(r)});l.on("error",()=>{r.writeHead(502,{"Content-Type":"text/plain"}),r.end(`Popmelt bridge not running on port ${t().port}`)}),i.pipe(l)}}function P(e){let t=e.port===null?null:`http://localhost:${e.port}`;return`window.__POPMELT_BRIDGE_URL__=${JSON.stringify(t)};window.__POPMELT_PROJECT_ID__=${JSON.stringify(e.projectId)};`}export{h as a,v as b,b as c,P as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{i as S,p as g}from"./chunk-ZJPPZLXU.mjs";function h(e){return Array.from(e,t=>{if(t==='"'||t==="\\")return`\\${t}`;let r=t.codePointAt(0);return r<32||r===127?`\\${r.toString(16)} `:t}).join("")}function f(e){return`[data-popmelt-subject-adapter="${h(e.adapter)}"][data-popmelt-subject-key="${h(e.key)}"]`}function y(e){let t=e?.getAttribute("data-popmelt-subject-adapter"),r=e?.getAttribute("data-popmelt-subject-key");return t&&r?{adapter:t,key:r}:void 0}function p(e,t){let r=!1;e.dataset.popmeltSubjectLabel!==t.label&&(e.dataset.popmeltSubjectLabel=t.label,r=!0);let{left:a,top:i,width:n,height:s}=t.bounds,u=o=>`${Math.round(o*2)/2}px`,b={left:u(a),top:u(i),width:u(Math.max(0,n)),height:u(Math.max(0,s))};for(let[o,c]of Object.entries(b)){let m=o;e.style[m]!==c&&(e.style[m]=c,r=!0)}let l=t.surfaceBounds,j={popmeltSubjectSurfaceLeft:l?String(l.left):void 0,popmeltSubjectSurfaceTop:l?String(l.top):void 0,popmeltSubjectSurfaceWidth:l?String(l.width):void 0,popmeltSubjectSurfaceHeight:l?String(l.height):void 0};for(let[o,c]of Object.entries(j))c===void 0?o in e.dataset&&(delete e.dataset[o],r=!0):e.dataset[o]!==c&&(e.dataset[o]=c,r=!0);let d=t.outline?.map(o=>`${o.x},${o.y}`).join(" ");return d?e.dataset.popmeltSubjectOutline!==d&&(e.dataset.popmeltSubjectOutline=d,r=!0):e.dataset.popmeltSubjectOutline!==void 0&&(delete e.dataset.popmeltSubjectOutline,r=!0),r}var k=class{constructor(e){this.adapters=e,this.projections=new Map,this.frameListeners=new Set,this.frame=null,this.lastProjectionFrameTime=0,this.adapterUnsubscribes=e.flatMap(t=>{let r=t.subscribe?.(()=>{for(let a of this.frameListeners)a()});return r?[r]:[]})}async whenReady(){await Promise.all(this.adapters.map(e=>e.whenReady?.()))}hitTest(e){return this.hitTestAll(e)[0]??null}hitTestAll(e){for(let t=this.adapters.length-1;t>=0;t-=1){let r=this.adapters[t];if(!r)continue;let a=(r.hitTestAll?.(e)??[r.hitTest(e)]).filter(i=>!!i).map(i=>this.project(r,i));if(a.length>0)return a}return[]}resolve(e){let t=this.adapters.find(a=>a.id===e.adapter);if(!t)return null;let r=t.resolve(e.key);return r?this.project(t,r):null}restore(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.restoreSubject?.(e.key,t);return r&&a?this.project(r,a):null}async captureFeedback(e){let t=this.resolve(e);if(!t)return null;let{adapter:r,subject:a}=t,i={...t.elementInfo};if(a.sourceElement&&(i.sourceElement={...g(a.sourceElement),selector:S(a.sourceElement)}),!r.captureSubject)return{elementInfo:i};try{let n=await r.captureSubject(e.key);return n?{elementInfo:i,crop:n}:{elementInfo:i,warning:"Object crop unavailable; use the page screenshot and image coordinates."}}catch{return{elementInfo:i,warning:"Object crop unavailable (the image may block canvas access via CORS); use the page screenshot and image coordinates."}}}beginCreate(e){for(let t=this.adapters.length-1;t>=0;t-=1){let r=this.adapters[t],a=r?.beginCreate?.(e);if(r&&a)return{adapter:r,session:a}}return null}rename(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.renameSubject?.(e.key,t);return r&&a?this.project(r,a):null}updateBounds(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectBounds?.(e.key,t);return r&&a?this.project(r,a):null}updateTrackingAnchors(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectTrackingAnchors?.(e.key,t);return r&&a?this.project(r,a):null}promote(e){let t=this.adapters.find(a=>a.id===e.adapter),r=t?.promoteSubject?.(e.key);return t&&r?this.project(t,r):null}remove(e){this.adapters.find(t=>t.id===e.adapter)?.removeSubject?.(e.key)}async captureSurfaces(){return(await Promise.all(this.adapters.map(async e=>e.captureSurfaces?.()??[]))).flat()}subscribeFrame(e){return this.frameListeners.add(e),()=>this.frameListeners.delete(e)}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=null;for(let e of this.projections.values())e.element.remove();this.projections.clear();for(let e of this.adapterUnsubscribes)e();this.frameListeners.clear()}project(e,t){let r={adapter:e.id,key:t.key},a=`${e.id}\0${t.key}`,i=this.projections.get(a);if(i)return i.subject=t,i.elementInfo=this.elementInfo(e,t,i.selector),p(i.element,t),i;let n=f(r),s=document.createElement("div");s.dataset.popmeltSubjectAdapter=e.id,s.dataset.popmeltSubjectKey=t.key,s.dataset.popmeltSubjectLabel=t.label,s.dataset.popmeltSubjectProjection="true",s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",pointerEvents:"none",opacity:"0",zIndex:"-1"}),p(s,t),document.body.appendChild(s);let u={adapter:e,subject:t,target:r,element:s,selector:n,elementInfo:this.elementInfo(e,t,n)};return this.projections.set(a,u),this.ensureFrame(),u}elementInfo(e,t,r){return{selector:r,tagName:e.id,subjectLabel:t.label,textContent:t.label,context:t.context,...t.imageObject?{imageObject:t.imageObject}:{},...t.videoObject?{videoObject:t.videoObject}:{},dataAttributes:{adapter:e.id,key:t.key,...t.data??{}}}}ensureFrame(){if(this.frame!==null||this.projections.size===0)return;let e=t=>{if(this.frame=null,this.lastProjectionFrameTime>0&&t-this.lastProjectionFrameTime<32){this.ensureFrame();return}this.lastProjectionFrameTime=t;let r=!1;for(let[a,i]of this.projections){let n=i.adapter.resolve(i.target.key);if(!n){i.element.remove(),this.projections.delete(a),r=!0;continue}i.subject=n,r=p(i.element,n)||r}if(r)for(let a of this.frameListeners)a();this.projections.size>0&&this.ensureFrame()};this.frame=requestAnimationFrame(e)}},v={isAnnotating:!1,activeTool:"inspector",activeColor:"oklch(0.628 0.258 29)",strokeWidth:3,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,styleModifications:[],textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]};export{f as a,y as b,k as c,v as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var j=" >>> ";function _(e){return Array.from(e.querySelectorAll("*")).flatMap(t=>t.shadowRoot?[t.shadowRoot]:[])}function W(e=document){let t=[e];for(let r of t)t.push(..._(r));return t}function v(e,t=document){let r=e.split(j);if(r.length>1){let o=t,i=null;for(let l=0;l<r.length;l+=1){if(i=o.querySelector(r[l]),!i)return null;if(l<r.length-1){if(!i.shadowRoot)return null;o=i.shadowRoot}}return i}let n=[t];for(let o of n){let i=o.querySelector(e);if(i)return i;n.push(..._(o))}return null}function m(e){if(e.parentElement)return e.parentElement;let t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function A(e,t){let r=e;for(;r;){if(r.matches(t))return r;r=m(r)}return null}function Q(e,t){let r=t;for(;r;){if(r===e)return!0;r=m(r)}return!1}function U(e,t,r){let n=typeof e.elementsFromPoint=="function"?e.elementsFromPoint(t,r):[],o=e.elementFromPoint?.(t,r)??null;return o&&!n.includes(o)?[o,...n]:n}function L(e,t){let r=[],n=new Set;for(let o of W().reverse())for(let i of U(o,e,t))n.has(i)||(n.add(i),r.push(i));return r}function N(){return j}var tt=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],k=e=>e.replace(/\s+/g," ").trim();function w(e){return e==="id"||e==="data-popmelt-media-id"||/^data-(?:testid|test|cy)(?:-[a-z0-9_-]+)?$/.test(e)}function T(e,t){return!!(t&&t.length<=200&&!(e==="id"&&/^(radix-|:|_r_)/.test(t)))}function D(e){let t={},r=new Set([...tt,...e.getAttributeNames().filter(w)]);for(let i of r){let l=e.getAttribute(i);l&&T(i,l)&&(t[i]=l)}let n=k(e.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),o=k(Array.from(e.childNodes).filter(i=>i.nodeType===3).map(i=>i.textContent).join(" "));return{tag:e.tagName.toLowerCase(),...Object.keys(t).length?{attributes:t}:{},...n&&n.length<=200?{heading:n}:{},...o&&o.length<=200?{text:o}:{}}}function O(e,t,r=document){let n=W(r),o=s=>{try{return n.flatMap(c=>Array.from(c.querySelectorAll(s)))}catch{return[]}},i=!!(t&&(t.heading||t.text||Object.keys(t.attributes??{}).length)),l=s=>{if(!t||!i)return!0;let c=D(s);return c.tag===t.tag&&(!t.heading||c.heading===t.heading)&&(!t.text||c.text===t.text)&&Object.entries(t.attributes??{}).every(([d,E])=>s.getAttribute(d)===E)};for(let s of e){if(s.includes(" >>> ")){try{let d=v(s,r);if(d&&l(d))return{status:"matched",element:d}}catch{}continue}let c=o(s);if(c.length===1&&(/^\[data-pm=/.test(s)||!i))return{status:"matched",element:c[0]}}if(!i||e.some(s=>s.includes(" >>> "))||!/^[a-z][a-z0-9-]*$/.test(t.tag))return{status:"missing"};let a=o(t.tag);if(a.length>500)return{status:"ambiguous"};let u=Object.entries(t.attributes??{}).filter(([s])=>w(s));if(u.length){let s=a.filter(c=>u.every(([d,E])=>c.getAttribute(d)===E));return s.length===1?{status:"matched",element:s[0]}:{status:s.length?"ambiguous":"missing"}}let x=a.filter(l);return x.length===1?{status:"matched",element:x[0]}:{status:x.length?"ambiguous":"missing"}}function et(e,t,r=document){let n={};if(t)for(let[a,u]of Object.entries({...t.dataAttributes,...t.id?{id:t.id}:{}}))w(a)&&T(a,u)&&(n[a]=u);let o=t?.targetFingerprint?.tag??t?.tagName?.toLowerCase(),i=t&&o?{...t.targetFingerprint,tag:o,attributes:{...n,...t.targetFingerprint?.attributes}}:t?.targetFingerprint,l=O([e,t?.selector].filter(a=>!!a),i,r);return l.status==="matched"?l.element:null}var rt=["data-popmelt-media-id","data-testid","data-test","data-cy"];function I(e){let t=e.getRootNode();if(!(t instanceof Document||t instanceof ShadowRoot))return null;let r=new Set([...rt,...e.getAttributeNames().filter(n=>n!=="id"&&w(n))]);for(let n of r){let o=e.getAttribute(n);if(!o||o.length>200)continue;let i=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(o):Array.from(o,a=>{if(a==='"'||a==="\\")return`\\${a}`;let u=a.charCodeAt(0);return u<32||u===127?`\\${u.toString(16)} `:a}).join(""),l=`[${n}="${i}"]`;if(t.querySelectorAll(l).length===1)return l}return null}function nt(e){let t=I(e);if(t)return t;if(e.id)return`#${e.id}`;let r=e.tagName.toLowerCase(),n=Array.from(e.classList).slice(0,3).join(".");return n?`${r}.${n}`:r}function p(e){if(e.getRootNode()instanceof Document&&e.id&&!e.id.startsWith("radix-")&&!e.id.startsWith(":"))return`#${CSS.escape(e.id)}`;let t=[],r=e;for(;r&&r!==document.documentElement;){let n=r.tagName.toLowerCase(),o=I(r);if(o?n=o:r.id&&!r.id.startsWith("radix-")&&!r.id.startsWith(":")&&(n=`#${CSS.escape(r.id)}`),!o&&!n.startsWith("#")){let a=Array.from(r.classList).filter(u=>!u.startsWith("_")&&u.length<30).slice(0,2);a.length>0&&(n+="."+a.map(u=>CSS.escape(u)).join("."))}let i=r.parentElement;if(i&&!o&&!n.startsWith("#")){let a=Array.from(i.children).filter(u=>u.tagName===r.tagName);if(a.length>1){let u=a.indexOf(r)+1;n+=`:nth-of-type(${u})`}}if(t.unshift(n),o||n.startsWith("#")){let a=r.getRootNode();if(a instanceof Document)break;if(a instanceof ShadowRoot){t.unshift(N().trim()),r=a.host;continue}}if(i){r=i;continue}let l=r.getRootNode();if(!(l instanceof ShadowRoot))break;t.unshift(N().trim()),r=l.host}return t.join(" > ").replace(/ > >>> > /g,N())}function f(e){try{return v(e)}catch{return null}}function b(e){return e instanceof HTMLElement||e instanceof SVGElement}var $=new WeakMap,y=new WeakMap;function ot(e,t){if(b(t))for(let[r,n]of y.get(e)??[])n.value?t.style.setProperty(r,n.value,n.priority):t.style.removeProperty(r)}function it(e,t){$.set(e,new Set(t))}function lt(e){$.delete(e)}function M(e,t){return b(e)&&($.get(e)?.has(t)??!1)}function q(e){let t=e.sticker;return t?t.family==="padding"||t.family==="margin"?t.subproperty==="all"?10:t.subproperty==="x"||t.subproperty==="y"?20:30:t.family==="radius"||t.family==="border"?t.subproperty==="all"?10:20:10:0}function at(e){return e.changes.map((t,r)=>({change:t,index:r})).sort((t,r)=>q(t.change)-q(r.change)||t.index-r.index).map(({change:t})=>t)}function B(e,t,r){if(b(e)){let n=y.get(e);n||(n=new Map,y.set(e,n)),n.has(t)||n.set(t,{value:e.style.getPropertyValue(t),priority:e.style.getPropertyPriority(t)}),e.style.setProperty(t,r,"important")}}function ut(e,t,r,n=!1){if(b(e)){let o=n?y.get(e)?.get(t):void 0;o?.value?e.style.setProperty(t,o.value,o.priority):e.style.removeProperty(t),y.get(e)?.delete(t)}}function V(e){let t=f(e.selector);if(!t&&e.durableSelector&&(t=f(e.durableSelector),t)){let r=e.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&t.setAttribute("data-pm",r)}return t}function st(e){for(let t of e){let r=V(t);if(r)for(let n of at(t))M(r,n.property)||B(r,n.property,n.modified)}}function ct(e,t=!1){for(let r of e){let n=f(r.selector);if(n)for(let o of r.changes)M(n,o.property)||ut(n,o.property,o.original,t)}}function z(e){let t=f(e.selector);if(!t&&e.durableSelector&&(t=f(e.durableSelector),t)){let r=e.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&t.setAttribute("data-pm",r)}return t}function H(e,t){let r=e;for(let n of t)r=r?.childNodes[n]??null;return r?.nodeType===Node.TEXT_NODE?r:null}function ft(e){for(let t of e){let r=z(t);if(!r)continue;let n=H(r,t.textNodePath);n&&(n.nodeValue=t.modified)}}function dt(e){for(let t of e){let r=z(t);if(!r)continue;let n=H(r,t.textNodePath);n&&(n.nodeValue=t.original)}}function g(e,t){if(!e)return null;let r=f(e);if(!r&&t&&(r=f(t),r)){let n=e.match(/\[data-pm="([^"]+)"\]/)?.[1];n&&r.setAttribute("data-pm",n)}return r}function mt(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(t=>t.removeAttribute("data-pm"))}function gt(e,t){let r=t.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&e.setAttribute("data-pm",r)}function F(e,t,r){let n=Array.from(e.children).filter(i=>i!==t),o=Math.max(0,Math.min(r,n.length));e.insertBefore(t,n[o]??null)}function ht(e){for(let t of e){let r=g(t.targetParentSelector,t.targetParentDurableSelector);if(!r)continue;if(t.operation==="move"){let i=g(t.selector,t.durableSelector);if(!i||i===r||i.contains(r))continue;F(r,i,t.targetIndex);continue}if(g(t.selector,t.durableSelector))continue;let n=g(t.sourceSelector,t.sourceDurableSelector);if(!n)continue;let o=n.cloneNode(!0);o instanceof Element&&(mt(o),gt(o,t.selector),F(r,o,t.targetIndex))}}function pt(e){for(let t of[...e].reverse()){if(t.operation==="copy"){g(t.selector,t.durableSelector)?.remove();continue}let r=g(t.selector,t.durableSelector),n=g(t.originalParentSelector,t.originalParentDurableSelector);!r||!n||r===n||r.contains(n)||F(n,r,t.originalIndex??n.children.length)}}function X(e){let t=Object.keys(e).find(i=>i.startsWith("__reactFiber$")||i.startsWith("__reactInternalInstance$"));if(!t)return null;let r=e[t],n=[],o=r?._debugSource;for(;r;){let i=r.type,l=i?.displayName||i?.name;l&&typeof l=="string"&&/^[A-Z]/.test(l)&&!l.startsWith("_")&&l!=="Fragment"&&n.unshift(l),r=r.return}return n.length>0?{name:n[n.length-1],path:n,...o?.fileName&&Number.isFinite(o.lineNumber)?{source:o}:{}}:null}function bt(e){let t=Object.keys(e).find(o=>o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$"));if(!t)return[];let r=e[t],n=[];for(;r;){let o=r.type,i=typeof o=="function"||typeof o=="object"?o?.displayName||o?.name:null;i&&typeof i=="string"&&/^[A-Z]/.test(i)&&!i.startsWith("_")&&i!=="Fragment"&&n.push({name:i,fiber:r}),r=r.return}return n.reverse(),n}function yt(e){let t=e,r=new Set;for(;t&&!r.has(t);){if(r.add(t),t.stateNode instanceof Element)return t.stateNode;t.child?t=t.child:t=null}return null}var St=900,C=80;function h(e){if(!e)return null;try{return v(e)}catch{return null}}function S(e){return(e??"").replace(/\s+/g," ").trim()}function Z(e){let t=S(e.getAttribute("aria-label"));if(t)return t.slice(0,C);let r=S(e.getAttribute("aria-labelledby"));if(r){let o=r.split(/\s+/).map(i=>S(document.getElementById(i)?.textContent)).filter(Boolean).join(" ");if(o)return o.slice(0,C)}let n=S(e.getAttribute("title"));return n?n.slice(0,C):S(e.textContent).slice(0,C)}function vt(e){return e.id?Array.from(document.querySelectorAll("[aria-controls]")).find(t=>t.getAttribute("aria-controls")===e.id)??null:null}function At(e){if(e instanceof HTMLDetailsElement){let n=Array.from(e.children).find(i=>i.tagName.toLowerCase()==="summary");if(!n)return null;let o=Z(n);return o?{triggerSelector:p(n),targetSelector:p(e),label:o}:null}let t=vt(e);if(!t)return null;let r=Z(t);return r?{triggerSelector:p(t),targetSelector:p(e),label:r}:null}function P(e){let t=[],r=new Set,n=m(e);for(;n&&n!==document.body&&n!==document.documentElement;){let i=At(n);i&&!r.has(i.triggerSelector)&&(r.add(i.triggerSelector),t.push(i)),n=m(n)}if(t.length===0)return;let o=t.reverse();return{steps:o,location:o.map(i=>i.label)}}function G(e){let t=e?.[0]?.revealRecipe;if(t?.steps.length)return t;let r=h(e?.[0]?.selector);return r?P(r):void 0}function Nt(e){let t=G(e)?.location.filter(Boolean);return t?.length?`Inside: ${t.join(" \u203A ")}`:null}function R(e){if(!e?.isConnected)return!1;let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0||e.getClientRects().length===0)return!1;let r=e;for(;r;){let n=window.getComputedStyle(r);if(n.display==="none"||n.visibility==="hidden"||n.visibility==="collapse"||Number.parseFloat(n.opacity||"1")<=0)return!1;r=r.parentElement}return!0}function wt(e,t,r){return t.getAttribute("aria-expanded")==="true"||t.getAttribute("data-state")==="open"?!0:r instanceof HTMLDetailsElement?r.open:R(r)}function J(e,t=St){return e?new Promise(r=>{let n=performance.now(),o=()=>{let i=h(e);if(R(i)){r(i);return}if(performance.now()-n>=t){r(null);return}requestAnimationFrame(o)};o()}):Promise.resolve(null)}function Ct(e,t){return h(e)??h(t?.[0]?.selector)}async function xt(e,t){let r=Ct(e,t);if(R(r))return r;let n=G(t)??(r?P(r):void 0);if(!n)return null;for(let i of n.steps){let l=h(i.triggerSelector);if(!(l instanceof HTMLElement))return null;let a=h(i.targetSelector);if(!wt(i,l,a)&&(l.click(),!await J(i.targetSelector)))return null}let o=e&&h(e)?e:t?.[0]?.selector;return J(o)}function Et(e){let t={targetFingerprint:D(e),selector:nt(e),tagName:e.tagName.toLowerCase()};e.id&&(t.id=e.id),e.classList.length>0&&(t.className=Array.from(e.classList).join(" "));let r=Wt(e)||e.matches('button, a, [role="button"], [role="tab"]')&&(e.getAttribute("aria-label")||e.getAttribute("title")||e.textContent?.trim())||"";r&&r.length>0&&r.length<200&&(t.textContent=r);let n={};for(let a of e.attributes)a.name.startsWith("data-")&&(n[a.name]=a.value);Object.keys(n).length>0&&(t.dataAttributes=n);let o=X(e);o&&(t.reactComponent=o.name,t.reactComponentPath=o.path,o.source&&(t.reactSource=o.source));let i=Lt(e);i&&(t.context=i);let l=P(e);return l&&(t.revealRecipe=l),t}function Wt(e){let t="";for(let r of e.childNodes)r.nodeType===Node.TEXT_NODE&&(t+=r.textContent||"");return t.trim()}function $t(e,t,r){return Y(e,t,r)[0]??null}var Ft="[data-popmelt-canvas-block]";function K(e,t){let r=L(e,t).find(n=>n.id!=="devtools-canvas"&&n.id!=="devtools-scrim");return!!(r&&A(r,Ft))}function Pt(e){return e instanceof SVGElement?e.closest("svg")??e:e}function Y(e,t,r){if(K(e,t))return[];let n=new Set,o=L(e,t),i=o.map(Pt).filter(l=>n.has(l)||(n.add(l),l.id==="devtools-canvas"||l.id==="devtools-toolbar"||l.id==="devtools-scrim")||A(l,"#devtools-toolbar")||l.hasAttribute("data-devtools")||A(l,"[data-devtools]")?!1:l!==document.body&&l!==document.documentElement);return i.length>0?i:r?.allowBodyFallback&&o.includes(document.body)?[document.body]:[]}function Rt(e,t,r){for(let n of e.childNodes){if(n.nodeType!==Node.TEXT_NODE||!n.textContent?.trim())continue;let o=document.createRange();o.selectNodeContents(n);let i=o.getClientRects?.();if(i&&Array.from(i).some(l=>t>=l.left&&t<=l.right&&r>=l.top&&r<=l.bottom))return!0}return!1}function jt(e,t,r){if(Rt(e,t,r)||["button","canvas","embed","iframe","img","input","object","select","svg","textarea","video"].includes(e.tagName.toLowerCase()))return!0;let n=getComputedStyle(e);if(n.backgroundImage&&n.backgroundImage!=="none")return!0;let o=n.backgroundColor.trim();if(o&&o!=="transparent"&&!/rgba?\([^)]*,\s*0(?:\.0+)?\s*\)$/.test(o))return!0;let i=e.getBoundingClientRect(),l={top:Number.parseFloat(n.borderTopWidth)||0,right:Number.parseFloat(n.borderRightWidth)||0,bottom:Number.parseFloat(n.borderBottomWidth)||0,left:Number.parseFloat(n.borderLeftWidth)||0};return l.top>0&&r<=i.top+l.top||l.right>0&&t>=i.right-l.right||l.bottom>0&&r>=i.bottom-l.bottom||l.left>0&&t<=i.left+l.left}function _t(e,t,r){let n=Y(e,t,r);return n.find(o=>jt(o,e,t))??n.at(-1)??null}function Lt(e){let t=m(e),r=["section","article","nav","aside","header","footer","main"];for(;t&&t!==document.body;){let n=t.tagName.toLowerCase();if(r.includes(n)&&t.id)return`${n}#${t.id}`;if(t.id&&!t.id.startsWith("radix-")&&!t.id.startsWith(":"))return`${n}#${t.id}`;t=m(t)}return null}export{ct as A,ft as B,dt as C,ht as D,pt as E,W as a,v as b,m as c,A as d,Q as e,N as f,O as g,et as h,p as i,f as j,Nt as k,xt as l,X as m,bt as n,yt as o,Et as p,$t as q,K as r,_t as s,b as t,ot as u,it as v,lt as w,B as x,V as y,st as z};
|