@popmelt.com/core 0.33.0 → 0.33.1

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.
Files changed (85) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/ExploreAttachment-VKCCEIM7.mjs +1 -0
  4. package/dist/ParticipantRuntime-YS5SIZUQ.mjs +1 -0
  5. package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +1 -215
  6. package/dist/PreviewRuntime-LFPK56NW.mjs +1 -2
  7. package/dist/QueuedReplies-ZYUDSTS2.mjs +1 -46
  8. package/dist/SuppliedContext-RWN6UR3K.mjs +1 -2
  9. package/dist/ThreadErrorCard-7J62GD5W.mjs +1 -2
  10. package/dist/ThreadPanel-KVNM67WO.mjs +1 -0
  11. package/dist/adapter-react-three-fiber.mjs +1 -2
  12. package/dist/bridge-entry.mjs +1 -1
  13. package/dist/bridge-recovery-3IQN3U6D.mjs +1 -2
  14. package/dist/bridgeSSEStream-NEYI73TC.mjs +1 -4
  15. package/dist/bridgeWebSocketStream-H3DCP4T3.mjs +1 -2
  16. package/dist/browser-runtime-AP35S5MK.mjs +1 -0
  17. package/dist/browser.mjs +1 -2
  18. package/dist/canvas-chat-note-NHYL3T6J.mjs +1 -2
  19. package/dist/checkFixture-MWBOYIM2.mjs +1 -0
  20. package/dist/chunk-27ADDVGC.mjs +1 -3
  21. package/dist/chunk-2IASPT6L.mjs +1 -2
  22. package/dist/chunk-2P2NUZW7.mjs +1 -2
  23. package/dist/chunk-2VCHBI7Y.mjs +1 -11
  24. package/dist/chunk-2ZJ4FBTG.mjs +1 -2
  25. package/dist/chunk-4LHTPRFY.mjs +1 -2
  26. package/dist/chunk-5K7SACPW.mjs +1 -2
  27. package/dist/chunk-6V2VCKPG.mjs +1 -53
  28. package/dist/chunk-6VXFTT5U.mjs +1 -2
  29. package/dist/chunk-75PQGTKX.mjs +1 -2
  30. package/dist/chunk-BVTLSUQT.mjs +1 -2
  31. package/dist/chunk-CPOYMGYY.mjs +1 -2
  32. package/dist/chunk-DNOKP3JS.mjs +1 -2
  33. package/dist/chunk-EAV2VV2V.mjs +1 -2
  34. package/dist/chunk-EX63NVDN.mjs +1 -2
  35. package/dist/chunk-F5XSNRGT.mjs +1 -2
  36. package/dist/chunk-GASEZICN.mjs +1 -2
  37. package/dist/chunk-H7XMDLGU.mjs +30 -0
  38. package/dist/{chunk-C5WXW6VL.mjs → chunk-HVD5ZG6W.mjs} +1 -1
  39. package/dist/chunk-J3UIBBU2.mjs +1 -2
  40. package/dist/chunk-J4WDYITA.mjs +1 -2
  41. package/dist/chunk-JMMP5JSP.mjs +1 -2
  42. package/dist/chunk-LVEMYZOA.mjs +1 -2
  43. package/dist/chunk-N2QUNHV6.mjs +1 -0
  44. package/dist/chunk-N2ZEZCHO.mjs +1 -2
  45. package/dist/{chunk-HNCV37XO.mjs → chunk-N6JTX4PD.mjs} +1 -1
  46. package/dist/chunk-O4HZP3RP.mjs +1 -2
  47. package/dist/chunk-ODIGT4YJ.mjs +1 -17
  48. package/dist/chunk-PQT5FYN5.mjs +1 -2
  49. package/dist/chunk-PSSHCTJ2.mjs +1 -8
  50. package/dist/chunk-RESPUCV7.mjs +1 -0
  51. package/dist/chunk-SHAIHRV2.mjs +1 -0
  52. package/dist/chunk-V2I7PSJW.mjs +1 -2
  53. package/dist/{chunk-H2UYAUX3.mjs → chunk-VPPVURBR.mjs} +1 -1
  54. package/dist/chunk-W5NIRROD.mjs +1 -7
  55. package/dist/chunk-WHJEKDNP.mjs +1 -2
  56. package/dist/chunk-XKD2ABCO.mjs +1 -7
  57. package/dist/chunk-XTOCFTVW.mjs +1 -2
  58. package/dist/chunk-YLKEDOII.mjs +31 -0
  59. package/dist/chunk-ZHJZPC7U.mjs +1 -2
  60. package/dist/cli.mjs +1 -1
  61. package/dist/codex-note-context-4JYQ437H.mjs +2 -0
  62. package/dist/{codex-project-7VYHYTWO.mjs → codex-project-FA4EK6VR.mjs} +1 -1
  63. package/dist/focus-inspection-VBS5656D.mjs +1 -2
  64. package/dist/index.mjs +1 -2
  65. package/dist/media.mjs +1 -2
  66. package/dist/{peer-client-MTWZG2FB.mjs → peer-client-KJCPXT76.mjs} +1 -1
  67. package/dist/plugin-astro.mjs +1 -1
  68. package/dist/plugin-nuxt.mjs +1 -1
  69. package/dist/plugin-vite.mjs +1 -1
  70. package/dist/server.mjs +1 -1
  71. package/dist/taste-proposal-session-XU4N7RUV.mjs +1 -2
  72. package/dist/workspace-snapshot-RTTXNNUX.mjs +1 -2
  73. package/package.json +1 -1
  74. package/dist/ExploreAttachment-CLFSAWKM.mjs +0 -260
  75. package/dist/ParticipantRuntime-HW3MOZI5.mjs +0 -139
  76. package/dist/ThreadPanel-RJIHV3P6.mjs +0 -197
  77. package/dist/browser-runtime-JJHSKIKD.mjs +0 -2
  78. package/dist/checkFixture-TJDFGPQI.mjs +0 -2
  79. package/dist/chunk-7IJGE5AK.mjs +0 -31
  80. package/dist/chunk-I63OQTCF.mjs +0 -347
  81. package/dist/chunk-J5SC3R5L.mjs +0 -2
  82. package/dist/chunk-PHKDIU3X.mjs +0 -30
  83. package/dist/chunk-XMKYGH62.mjs +0 -142
  84. package/dist/codex-note-context-YHKPQ4WP.mjs +0 -2
  85. /package/dist/{chunk-DMWB3IRD.mjs → chunk-QOJCTLQW.mjs} +0 -0
@@ -1,2 +1 @@
1
- "use client";
2
- function w(t){return!!(t&&(t.namespaceURI==="http://www.w3.org/1999/xhtml"||t.namespaceURI==="http://www.w3.org/2000/svg"))}export{w as a};
1
+ "use client";function t(t){return!(!t||"http://www.w3.org/1999/xhtml"!==t.namespaceURI&&"http://www.w3.org/2000/svg"!==t.namespaceURI)}export{t as a};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{C as t,E as e,j as a,p as r,q as i}from"./chunk-7IJGE5AK.mjs";import{readFile as o,realpath as n,mkdir as s,writeFile as c}from"fs/promises";import{createHash as p}from"crypto";import{join as d,resolve as l}from"path";function u(t,e){let a=p("sha256").update(e).digest("hex");return d(t,".popmelt","participant-agents",a+".json")}async function f(t,a){if(a.storeId!==t.storeId)return{ok:!1,body:{status:"writable_store_required"}};if("string"!=typeof a.threadId||!a.threadId||"string"!=typeof a.text||!a.text.trim()||a.text.length>8e3)return{ok:!1,body:{status:"invalid_note"}};let r;try{r=await h(t,t.sessionId,!0)}catch(t){if("ENOENT"!==t.code)throw t;return{ok:!1,body:{status:"participant_invitation_required"}}}if(!r)return{ok:!1,body:{status:"enrolled_bridge_required"}};let i=await e(r.endpoint,"/participants/thread-note",{...r.request,method:"POST",signal:AbortSignal.timeout(3e4),body:JSON.stringify({storeId:t.storeId,threadId:a.threadId,reply:a.text,sessionId:t.sessionId,requestId:a.requestId})});return{ok:i.response.ok,body:i.body}}async function h(t,r,s=!1){let c=await o(d(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(c.projectId!==t.projectId||!Number.isInteger(c.port)||c.port<1||c.port>65535)return null;let p={redirect:"error",signal:AbortSignal.timeout(3e3)},l=await e(c,"/status",p);if(!l.response.ok||l.body?.projectId!==t.projectId)return null;let f,h=u(t.projectRoot,r);try{f=JSON.parse(await o(h,"utf8"))}catch(l){if("ENOENT"!==l.code||!s)throw l;let u=await n(t.projectRoot),m=a(r);if(i(u)!==t.projectId||!m)return null;let g=JSON.parse(await o(d(u,".popmelt","participant-host.json"),"utf8"));if(!(await e(c,"/participants/agent-join",{...p,method:"POST",headers:{"X-Popmelt-Participant-Id":g.participantId,"X-Popmelt-Participant-Token":g.token},body:JSON.stringify({sessionId:r,name:m,headless:!0})})).response.ok)return null;f=JSON.parse(await o(h,"utf8"))}return{endpoint:c,request:{...p,headers:{"X-Popmelt-Participant-Id":f.participantId,"X-Popmelt-Participant-Token":f.token}}}}async function m(t,a,r){let i=[t,...t.mountedStores].find(t=>t.storeId===a.storeId);if(!i||r&&i!==t)return{ok:!1,body:{status:"store_unavailable"}};if(r&&("string"!=typeof a.threadId||!a.threadId))return{ok:!1,body:{status:"thread_required"}};let o=await h(i,t.sessionId,r).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,r?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,...r?{threadId:a.threadId}:{}})});return{ok:c.response.ok,body:c.body}}async function g(a,l,f={}){if(t())return{status:"already_managed_by_bridge"};if((await e(a,"/status",{redirect:"error",signal:AbortSignal.timeout(3e3)})).body?.participantSessions)return async function(t,a,l){if(!l.projectRoot)throw new Error("Participant connections require the active project root");let f=await n(l.projectRoot);if(i(f)!==t.projectId)throw new Error("Participant project does not match");let h,m,g=d(f,".popmelt"),w=p("sha256").update(a).digest("hex"),I=async(a,r,i)=>{let o=await e(t,"/participants/"+a,{method:"POST",redirect:"error",headers:{"X-Popmelt-Participant-Id":r.participantId,"X-Popmelt-Participant-Token":r.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{h=JSON.parse(await o(u(f,a),"utf8"))}catch(t){if("ENOENT"!==t.code)throw t;if(!l.name)return{status:"participant_invitation_required"};let e=JSON.parse(await o(d(g,"participant-host.json"),"utf8")),r=await I("agent-join",e,{sessionId:a,name:l.name});h=r.credential,m=r.participant}if(!l.action){let t=await I("agent-connect",h,{});return{status:"participant_connected",participantId:h.participantId,participant:t.participant??m}}let y=await I("agent-act",h,{action:r(l.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=d(g,"artifacts","participant-previews");await s(e,{recursive:!0,mode:448});let a=d(e,w+".jpg");return await c(a,Buffer.from(t.slice(t.indexOf(",")+1),"base64"),{mode:384}),{status:"participant_connected",participant:y.participant,evidence:{...b,frame:{imagePath:a,targets:b.frame.targets}}}}return{status:"participant_connected",participant:y.participant,evidence:y.evidence}}(a,l,f);let h=async(t,r)=>{let i=await e(a,`/peers/${t}`,{method:"POST",body:JSON.stringify(r),signal:AbortSignal.timeout(5e4)}),o=i.body;if(!i.response.ok||o?.error)throw new Error(o?.error??"Peer connection unavailable");return o},m=await h("join",{sessionId:l,name:f.name}),g=f.action?await h("act",{token:m.token,clientId:f.clientId,action:r(f.action)}):m,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:m.clients}}async function w(t){let a=e=>{let a=t.indexOf(e);return a>=0?t[a+1]:void 0},r=a("--session");if(!r)throw new Error("Usage: popmelt peer --session <stable-agent-session> [--project-root <active-project>] [--name <your-name>] [--client <canvas-id>] [--action <JSON>]");let s=await n(l(a("--project-root")??process.cwd())),c=JSON.parse(await o(d(s,".popmelt","bridge.lock"),"utf8")),p=i(s),u=await e({port:c.port,projectId:p},"/status",{signal:AbortSignal.timeout(3e3)});if(!u.response.ok||u.body.projectRoot!==s&&(!u.body.participantSessions||u.body.projectId!==p))throw new Error("No matching running project bridge");let f=a("--action");console.log(JSON.stringify(await g({port:c.port,projectId:p},r,{name:a("--name"),projectRoot:s,clientId:a("--client"),action:f?JSON.parse(f):void 0}),null,2))}export{u as a,f as b,h as c,m as d,g as e,w as f};
2
+ import{C as t,E as e,j as a,p as r,q as i}from"./chunk-YLKEDOII.mjs";import{readFile as o,realpath as n,mkdir as s,writeFile as c}from"fs/promises";import{createHash as p}from"crypto";import{join as d,resolve as l}from"path";function u(t,e){let a=p("sha256").update(e).digest("hex");return d(t,".popmelt","participant-agents",a+".json")}async function f(t,a){if(a.storeId!==t.storeId)return{ok:!1,body:{status:"writable_store_required"}};if("string"!=typeof a.threadId||!a.threadId||"string"!=typeof a.text||!a.text.trim()||a.text.length>8e3)return{ok:!1,body:{status:"invalid_note"}};let r;try{r=await h(t,t.sessionId,!0)}catch(t){if("ENOENT"!==t.code)throw t;return{ok:!1,body:{status:"participant_invitation_required"}}}if(!r)return{ok:!1,body:{status:"enrolled_bridge_required"}};let i=await e(r.endpoint,"/participants/thread-note",{...r.request,method:"POST",signal:AbortSignal.timeout(3e4),body:JSON.stringify({storeId:t.storeId,threadId:a.threadId,reply:a.text,sessionId:t.sessionId,requestId:a.requestId})});return{ok:i.response.ok,body:i.body}}async function h(t,r,s=!1){let c=await o(d(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(c.projectId!==t.projectId||!Number.isInteger(c.port)||c.port<1||c.port>65535)return null;let p={redirect:"error",signal:AbortSignal.timeout(3e3)},l=await e(c,"/status",p);if(!l.response.ok||l.body?.projectId!==t.projectId)return null;let f,h=u(t.projectRoot,r);try{f=JSON.parse(await o(h,"utf8"))}catch(l){if("ENOENT"!==l.code||!s)throw l;let u=await n(t.projectRoot),m=a(r);if(i(u)!==t.projectId||!m)return null;let g=JSON.parse(await o(d(u,".popmelt","participant-host.json"),"utf8"));if(!(await e(c,"/participants/agent-join",{...p,method:"POST",headers:{"X-Popmelt-Participant-Id":g.participantId,"X-Popmelt-Participant-Token":g.token},body:JSON.stringify({sessionId:r,name:m,headless:!0})})).response.ok)return null;f=JSON.parse(await o(h,"utf8"))}return{endpoint:c,request:{...p,headers:{"X-Popmelt-Participant-Id":f.participantId,"X-Popmelt-Participant-Token":f.token}}}}async function m(t,a,r){let i=[t,...t.mountedStores].find(t=>t.storeId===a.storeId);if(!i||r&&i!==t)return{ok:!1,body:{status:"store_unavailable"}};if(r&&("string"!=typeof a.threadId||!a.threadId))return{ok:!1,body:{status:"thread_required"}};let o=await h(i,t.sessionId,r).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,r?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,...r?{threadId:a.threadId}:{}})});return{ok:c.response.ok,body:c.body}}async function g(a,l,f={}){if(t())return{status:"already_managed_by_bridge"};if((await e(a,"/status",{redirect:"error",signal:AbortSignal.timeout(3e3)})).body?.participantSessions)return async function(t,a,l){if(!l.projectRoot)throw new Error("Participant connections require the active project root");let f=await n(l.projectRoot);if(i(f)!==t.projectId)throw new Error("Participant project does not match");let h,m,g=d(f,".popmelt"),w=p("sha256").update(a).digest("hex"),I=async(a,r,i)=>{let o=await e(t,"/participants/"+a,{method:"POST",redirect:"error",headers:{"X-Popmelt-Participant-Id":r.participantId,"X-Popmelt-Participant-Token":r.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{h=JSON.parse(await o(u(f,a),"utf8"))}catch(t){if("ENOENT"!==t.code)throw t;if(!l.name)return{status:"participant_invitation_required"};let e=JSON.parse(await o(d(g,"participant-host.json"),"utf8")),r=await I("agent-join",e,{sessionId:a,name:l.name});h=r.credential,m=r.participant}if(!l.action){let t=await I("agent-connect",h,{});return{status:"participant_connected",participantId:h.participantId,participant:t.participant??m}}let y=await I("agent-act",h,{action:r(l.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=d(g,"artifacts","participant-previews");await s(e,{recursive:!0,mode:448});let a=d(e,w+".jpg");return await c(a,Buffer.from(t.slice(t.indexOf(",")+1),"base64"),{mode:384}),{status:"participant_connected",participant:y.participant,evidence:{...b,frame:{imagePath:a,targets:b.frame.targets}}}}return{status:"participant_connected",participant:y.participant,evidence:y.evidence}}(a,l,f);let h=async(t,r)=>{let i=await e(a,`/peers/${t}`,{method:"POST",body:JSON.stringify(r),signal:AbortSignal.timeout(5e4)}),o=i.body;if(!i.response.ok||o?.error)throw new Error(o?.error??"Peer connection unavailable");return o},m=await h("join",{sessionId:l,name:f.name}),g=f.action?await h("act",{token:m.token,clientId:f.clientId,action:r(f.action)}):m,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:m.clients}}async function w(t){let a=e=>{let a=t.indexOf(e);return a>=0?t[a+1]:void 0},r=a("--session");if(!r)throw new Error("Usage: popmelt peer --session <stable-agent-session> [--project-root <active-project>] [--name <your-name>] [--client <canvas-id>] [--action <JSON>]");let s=await n(l(a("--project-root")??process.cwd())),c=JSON.parse(await o(d(s,".popmelt","bridge.lock"),"utf8")),p=i(s),u=await e({port:c.port,projectId:p},"/status",{signal:AbortSignal.timeout(3e3)});if(!u.response.ok||u.body.projectRoot!==s&&(!u.body.participantSessions||u.body.projectId!==p))throw new Error("No matching running project bridge");let f=a("--action");console.log(JSON.stringify(await g({port:c.port,projectId:p},r,{name:a("--name"),projectRoot:s,clientId:a("--client"),action:f?JSON.parse(f):void 0}),null,2))}export{u as a,f as b,h as c,m as d,g as e,w as f};
@@ -1,7 +1 @@
1
- "use client";
2
- function m(n,a,i){let t=n.flatMap(({requestedAt:r,resolvedAt:l})=>Number.isFinite(r)&&Number.isFinite(l)?[[Math.max(a,r),Math.min(i,l)]]:[]).sort((r,l)=>r[0]-l[0]),e=a,o=0;for(let[r,l]of t)o+=Math.max(0,l-Math.max(e,r)),e=Math.max(e,l);return o}function u(n){let a=new Map,i=new Set;for(let t of n)if(t.type==="approval"){let e=t.data.approval;a.set(e.id,e)}else(t.type==="done"||t.type==="error")&&i.add(String(t.data.jobId));return new Set([...a.values()].filter(t=>t.status==="pending"&&!i.has(t.jobId)).map(t=>t.jobId))}function p(n){let a=n?.requestItems?.flatMap(t=>t.kind==="annotation"&&t.text.trim()?[t.text.trim()]:[]);if(a?.length)return a.join("; ");let i=n?.requestItems?.flatMap(t=>t.kind==="changes"?[`${t.elementLabel} [${t.changes.join(", ")}]`]:[]);return i?.length?i.join("; "):n?.requestText?.trim()||void 0}function f(n,a){if(!n?.frames?.length)return[];let i=new Map;for(let t of n.steps){let e=t.visuals?.afterFrameId;e&&!i.has(e)&&i.set(e,t.action?.label?`After ${t.action.label}`:"Resulting state")}return n.frames.flatMap((t,e)=>{let o=a[t.imageIndex];return o?[{id:t.id,imageIndex:t.imageIndex,label:e===0?"Initial state":i.get(t.id)??"State",url:o}]:[]})}function s(n){let a=n.instruction?.trim();return a?n.attachments?.some(i=>i.name?.trim()===a)?null:a:null}function c(n,a){let i=n?.tagName?.toLowerCase(),t=n?.id?`#${n.id}`:"",e=n?.className?`.${n.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",o=i?`${i}${t}${e}`:a;return n?.reactComponent?`<${n.reactComponent}> ${o}`:o}function d(n){let a=n.elements?.[0]?.reactComponent||n.elements?.[0]?.tagName||n.linkedSelector,i=n.type&&n.type!=="annotation"?`${n.type} annotation`:"Annotation";return a?`${i} on ${a}`:i}function h(n){let a=n.annotations.map(e=>{let o=e.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:e.id,pathname:e.pathname,text:s(e)??d(e),...o>0?{interactionEpisodeStepCount:o}:{}}}),i=new Map,t=e=>{let o=`${e.pathname??""}:${e.durableSelector??e.selector}`,r=i.get(o);if(r){r.changes.push(e.text),e.annotationNumber!==void 0&&(r.annotationNumber===void 0||e.annotationNumber<r.annotationNumber)&&(r.annotationNumber=e.annotationNumber);return}let l={kind:"changes",elementKey:o,elementLabel:c(e.element,e.selector),...e.annotationNumber!==void 0?{annotationNumber:e.annotationNumber}:{},pathname:e.pathname,changes:[e.text]};i.set(o,l),a.push(l)};for(let e of n.styleModifications??[])for(let o of e.changes)t({...e,text:`${o.property}: ${o.original||"unset"} \u2192 ${o.modified||"unset"}${o.token?` (${o.token})`:""}`});for(let e of n.textModifications??[])t({...e,text:`Text: ${e.original||"empty"} \u2192 ${e.modified||"empty"}`});for(let e of n.domModifications??[])t({...e,text:e.operation==="copy"?"Copied element":"Moved element"});return n.spacingTokenChanges?.length&&a.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:n.spacingTokenChanges.map(e=>`${e.tokenName}: ${e.originalPx}px \u2192 ${e.newPx}px`)}),a}function g(n){let a=n.annotations.flatMap(t=>{let e=s(t);return e?[{instruction:e,pathname:t.pathname}]:[]});if(a.length===0)return;if(new Set(a.map(t=>t.pathname).filter(Boolean)).size<=1)return a.map(t=>t.instruction).join(`
3
-
4
- `);let i=new Map;for(let t of a){let e=t.pathname||"(unknown)",o=i.get(e)??[];o.push(t.instruction),i.set(e,o)}return[...i.entries()].map(([t,e])=>`\`${t}\`
5
- ${e.map(o=>`- ${o}`).join(`
6
- `)}`).join(`
7
- `)}function $(n,a=96){let i=n.replace(/\s+/g," ").trim();return i.length>a?`${i.slice(0,Math.max(0,a-3))}...`:i}function x(n,a,i){return i?.activePreview?i.annotationNumber:n??a}function b(n,a){return n?.trim()?n.trim():p(a.find(i=>i.role==="human"))}export{m as a,u as b,f as c,h as d,g as e,$ as f,x as g,b as h};
1
+ "use client";function e(e,t,n){let a=e.flatMap(({requestedAt:e,resolvedAt:a})=>Number.isFinite(e)&&Number.isFinite(a)?[[Math.max(t,e),Math.min(n,a)]]:[]).sort((e,t)=>e[0]-t[0]),o=t,i=0;for(let[e,t]of a)i+=Math.max(0,t-Math.max(o,e)),o=Math.max(o,t);return i}function t(e){let t=new Map,n=new Set;for(let a of e)if("approval"===a.type){let e=a.data.approval;t.set(e.id,e)}else("done"===a.type||"error"===a.type)&&n.add(String(a.data.jobId));return new Set([...t.values()].filter(e=>"pending"===e.status&&!n.has(e.jobId)).map(e=>e.jobId))}function n(e,t){if(!e?.frames?.length)return[];let n=new Map;for(let t of e.steps){let e=t.visuals?.afterFrameId;e&&!n.has(e)&&n.set(e,t.action?.label?`After ${t.action.label}`:"Resulting state")}return e.frames.flatMap((e,a)=>{let o=t[e.imageIndex];return o?[{id:e.id,imageIndex:e.imageIndex,label:0===a?"Initial state":n.get(e.id)??"State",url:o}]:[]})}function a(e){let t=e.instruction?.trim();return t?e.attachments?.some(e=>e.name?.trim()===t)?null:t:null}function o(e,t){let n=e?.tagName?.toLowerCase(),a=e?.id?`#${e.id}`:"",o=e?.className?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",i=n?`${n}${a}${o}`:t;return e?.reactComponent?`<${e.reactComponent}> ${i}`:i}function i(e){let t=e.elements?.[0]?.reactComponent||e.elements?.[0]?.tagName||e.linkedSelector,n=e.type&&"annotation"!==e.type?`${e.type} annotation`:"Annotation";return t?`${n} on ${t}`:n}function r(e){let t=e.annotations.map(e=>{let t=e.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:e.id,pathname:e.pathname,text:a(e)??i(e),...t>0?{interactionEpisodeStepCount:t}:{}}}),n=new Map,r=e=>{let a=`${e.pathname??""}:${e.durableSelector??e.selector}`,i=n.get(a);if(i)return i.changes.push(e.text),void(void 0!==e.annotationNumber&&(void 0===i.annotationNumber||e.annotationNumber<i.annotationNumber)&&(i.annotationNumber=e.annotationNumber));let r={kind:"changes",elementKey:a,elementLabel:o(e.element,e.selector),...void 0!==e.annotationNumber?{annotationNumber:e.annotationNumber}:{},pathname:e.pathname,changes:[e.text]};n.set(a,r),t.push(r)};for(let t of e.styleModifications??[])for(let e of t.changes)r({...t,text:`${e.property}: ${e.original||"unset"} → ${e.modified||"unset"}${e.token?` (${e.token})`:""}`});for(let t of e.textModifications??[])r({...t,text:`Text: ${t.original||"empty"} → ${t.modified||"empty"}`});for(let t of e.domModifications??[])r({...t,text:"copy"===t.operation?"Copied element":"Moved element"});return e.spacingTokenChanges?.length&&t.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:e.spacingTokenChanges.map(e=>`${e.tokenName}: ${e.originalPx}px → ${e.newPx}px`)}),t}function l(e){let t=e.annotations.flatMap(e=>{let t=a(e);return t?[{instruction:t,pathname:e.pathname}]:[]});if(0===t.length)return;if(new Set(t.map(e=>e.pathname).filter(Boolean)).size<=1)return t.map(e=>e.instruction).join("\n\n");let n=new Map;for(let e of t){let t=e.pathname||"(unknown)",a=n.get(t)??[];a.push(e.instruction),n.set(t,a)}return[...n.entries()].map(([e,t])=>`\`${e}\`\n${t.map(e=>`- ${e}`).join("\n")}`).join("\n")}function s(e,t=96){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(0,t-3))}...`:n}function m(e,t,n){return n?.activePreview?n.annotationNumber:e??t}function u(e,t){return e?.trim()?e.trim():function(e){let t=e?.requestItems?.flatMap(e=>"annotation"===e.kind&&e.text.trim()?[e.text.trim()]:[]);if(t?.length)return t.join("; ");let n=e?.requestItems?.flatMap(e=>"changes"===e.kind?[`${e.elementLabel} [${e.changes.join(", ")}]`]:[]);return n?.length?n.join("; "):e?.requestText?.trim()||void 0}(t.find(e=>"human"===e.role))}export{e as a,t as b,n as c,r as d,l as e,s as f,m as g,u as h};
@@ -1,2 +1 @@
1
- "use client";
2
- function m(t){if(typeof document<"u"&&t===document)return null;try{let e=t.defaultView?.frameElement;return e?.localName==="iframe"?e:null}catch{return null}}function w(t){if(t.localName!=="iframe"||t.closest("[data-devtools],[data-popmelt-peer-surface]"))return null;try{let e=t.contentDocument;return e?.documentElement?e:null}catch{return null}}function D(t){let e=t.getBoundingClientRect(),r=t.offsetWidth?e.width/t.offsetWidth:1,u=t.offsetHeight?e.height/t.offsetHeight:1;return{x:e.left+t.clientLeft*r,y:e.top+t.clientTop*u,sx:r,sy:u}}function v(t,e){let{left:r,top:u,width:o,height:n}=t,l=m(e);for(;l;){let i=D(l);r=i.x+r*i.sx,u=i.y+u*i.sy,o*=i.sx,n*=i.sy,l=m(l.ownerDocument)}return new DOMRect(r,u,o,n)}function V(t){return v(t.getBoundingClientRect(),t.ownerDocument)}function M(t,e,r){let u=[],o=m(r);for(;o;)u.unshift(o),o=m(o.ownerDocument);for(let n of u){let l=D(n);t=(t-l.x)/l.sx,e=(e-l.y)/l.sy}return{x:t,y:e}}function k(t){return t.ownerDocument.defaultView??window}function z(t){return!!(t&&t.namespaceURI==="http://www.w3.org/1999/xhtml")}function A(t,e=document){if(t===e)return!0;let r=m(t);return!!(r?.isConnected&&r.contentDocument===t&&A(r.ownerDocument,e))}function B(t,e){if(!A(e))return new DOMRect(0,0,0,0);let r=t.left,u=t.top,o=t.right,n=t.bottom;for(let l=m(e);l;l=m(l.ownerDocument)){let i=v({left:0,top:0,width:l.clientWidth,height:l.clientHeight},l.contentDocument);r=Math.max(r,i.left),u=Math.max(u,i.top),o=Math.min(o,i.right),n=Math.min(n,i.bottom)}return new DOMRect(r,u,Math.max(0,o-r),Math.max(0,n-u))}var g="@frame(";function I(t,e){return`${g}${encodeURIComponent(JSON.stringify({selector:t,url:e.URL}))}) `}function O(t){if(!t.startsWith(g))return null;let e=t.indexOf(") ");if(e<0)return null;try{let r=JSON.parse(decodeURIComponent(t.slice(g.length,e)));return typeof r.selector!="string"||typeof r.url!="string"?null:{...r,rest:t.slice(e+2)}}catch{return null}}var b=" >>> ";function N(t){return Array.from(t.querySelectorAll("*")).flatMap(e=>e.shadowRoot?[e.shadowRoot]:[])}function S(t=document){let e=[t];for(let r of e)e.push(...N(r));return e}function p(t,e=document){if(t.startsWith(g)){let o=O(t);if(!o)return null;let n=o.selector.startsWith(g)||o.selector.includes(b)?[p(o.selector,e)].filter(s=>!!s):S(e).flatMap(s=>Array.from(s.querySelectorAll(o.selector))),l=n.length===1?n[0]:null,i=l&&w(l);return!i||i.URL!==o.url?null:p(o.rest,i)}let r=t.split(b);if(r.length>1){let o=e,n=null;for(let l=0;l<r.length;l+=1){if(n=o.querySelector(r[l]),!n)return null;if(l<r.length-1){if(!n.shadowRoot)return null;o=n.shadowRoot}}return n}let u=[e];for(let o of u){let n=o.querySelector(t);if(n)return n;u.push(...N(o))}return null}function R(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return"host"in e?e.host:null}function _(t,e){return e.startsWith(g)||e.includes(b)?p(e)===t:t.matches(e)}function $(t,e){let r=t;for(;r;){if(r.matches(e))return r;r=R(r)}return null}function H(t,e){let r=e;for(;r;){if(r===t)return!0;r=R(r)}return!1}var W=new WeakMap;function E(t){let e=t.getAttribute("style");return t.style.setProperty("pointer-events","auto","important"),()=>{e===null?t.removeAttribute("style"):t.setAttribute("style",e)}}function J(t){let e=t.nodeType===9?t:t.ownerDocument,r="* { pointer-events: auto !important; }",u=[];try{let o=e.defaultView?.CSSStyleSheet;if(o?.prototype.replaceSync&&"adoptedStyleSheets"in t){let n=W.get(e);n||(n=new o,n.replaceSync(r),W.set(e,n));let l=[...t.adoptedStyleSheets];t.adoptedStyleSheets=[...l,n],u.push(()=>{t.adoptedStyleSheets=l})}else{let n=e.createElement("style");n.textContent=r,(t.nodeType===9?e.head??e.documentElement:t).appendChild(n),u.push(()=>n.remove())}for(let n of t.querySelectorAll('[style*="pointer-events"]'))n.style.getPropertyValue("pointer-events")!=="none"||n.style.getPropertyPriority("pointer-events")!=="important"||u.push(E(n))}catch(o){throw u.reverse().forEach(n=>n()),o}return()=>u.reverse().forEach(o=>o())}function G(t,e,r,u=n=>[n],o){let n=[];for(let l of t.querySelectorAll("iframe")){if(!w(l))continue;let i=l.getBoundingClientRect();e<i.left||e>i.right||r<i.top||r>i.bottom||l.ownerDocument.defaultView?.getComputedStyle(l).pointerEvents==="none"&&n.push(E(l))}try{let l=()=>{let c=typeof t.elementsFromPoint=="function"?t.elementsFromPoint(e,r):[],a=t.elementFromPoint?.(e,r)??null;return(a&&!c.includes(a)?[a,...c]:c).filter(f=>t.nodeType===9||f.getRootNode()===t)},i=l(),s=i;if(o){let c=J(t);try{s=l()}finally{c()}s=s.filter(a=>i.includes(a)||o(a))}return s.flatMap(u)}finally{n.forEach(l=>l())}}function q(t,e,r=document,u){let o=[],n=new Set,l=r.nodeType===9?r:r.ownerDocument,i=M(t,e,l);for(let s of S(r).reverse())for(let c of G(s,i.x,i.y,a=>{let f=w(a);return f?[...q(t,e,f,u),a]:[a]},u))n.has(c)||(n.add(c),o.push(c));return o}function K(){return b}var Q=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],j=t=>t.replace(/\s+/g," ").trim();function y(t){return t==="id"||t==="data-popmelt-media-id"||/^data-(?:testid|test|cy)(?:-[a-z0-9_-]+)?$/.test(t)}function F(t,e){return!!(e&&e.length<=200&&!(t==="id"&&/^(radix-|:|_r_)/.test(e)))}function P(t){let e={},r=new Set([...Q,...t.getAttributeNames().filter(y)]);for(let n of r){let l=t.getAttribute(n);l&&F(n,l)&&(e[n]=l)}let u=j(t.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),o=j(Array.from(t.childNodes).filter(n=>n.nodeType===3).map(n=>n.textContent).join(" "));return{tag:t.tagName.toLowerCase(),...Object.keys(e).length?{attributes:e}:{},...u&&u.length<=200?{heading:u}:{},...o&&o.length<=200?{text:o}:{}}}function L(t,e,r=document){let u=S(r),o=a=>{try{return u.flatMap(f=>Array.from(f.querySelectorAll(a)))}catch{return[]}},n=!!(e&&(e.heading||e.text||Object.keys(e.attributes??{}).length)),l=a=>{if(!e||!n)return!0;let f=P(a);return f.tag===e.tag&&(!e.heading||f.heading===e.heading)&&(!e.text||f.text===e.text)&&Object.entries(e.attributes??{}).every(([h,d])=>a.getAttribute(h)===d)};for(let a of t){if(a.includes(" >>> ")||a.startsWith("@frame(")){try{let h=p(a,r),d=O(a),C=Object.entries(e?.attributes??{}).filter(([x])=>y(x)),T=d&&h&&(d.rest.startsWith("[data-pm=")||C.length>0&&h.tagName.toLowerCase()===e?.tag&&C.every(([x,U])=>h.getAttribute(x)===U));if(h&&(T||l(h)))return{status:"matched",element:h}}catch{}continue}let f=o(a);if(f.length===1&&(/^\[data-pm=/.test(a)||!n))return{status:"matched",element:f[0]}}if(!n||t.some(a=>a.includes(" >>> ")||a.startsWith("@frame("))||!/^[a-z][a-z0-9-]*$/.test(e.tag))return{status:"missing"};let i=o(e.tag);if(i.length>500)return{status:"ambiguous"};let s=Object.entries(e.attributes??{}).filter(([a])=>y(a));if(s.length){let a=i.filter(f=>s.every(([h,d])=>f.getAttribute(h)===d));return a.length===1?{status:"matched",element:a[0]}:{status:a.length?"ambiguous":"missing"}}let c=i.filter(l);return c.length===1?{status:"matched",element:c[0]}:{status:c.length?"ambiguous":"missing"}}function X(t,e,r=document){let u={};if(e)for(let[i,s]of Object.entries({...e.dataAttributes,...e.id?{id:e.id}:{}}))y(i)&&F(i,s)&&(u[i]=s);let o=e?.targetFingerprint?.tag??e?.tagName?.toLowerCase(),n=e&&o?{...e.targetFingerprint,tag:o,attributes:{...u,...e.targetFingerprint?.attributes}}:e?.targetFingerprint,l=L([t,e?.selector].filter(i=>!!i),n,r);return l.status==="matched"?l.element:null}export{m as a,w as b,v as c,V as d,M as e,k as f,z as g,A as h,B as i,I as j,S as k,p as l,R as m,_ as n,$ as o,H as p,q,K as r,y as s,P as t,L as u,X as v};
1
+ "use client";function t(t){if(typeof document<"u"&&t===document)return null;try{let e=t.defaultView?.frameElement;return"iframe"===e?.localName?e:null}catch{return null}}function e(t){if("iframe"!==t.localName||t.closest("[data-devtools],[data-popmelt-peer-surface]"))return null;try{let e=t.contentDocument;return e?.documentElement?e:null}catch{return null}}function n(t){let e=t.getBoundingClientRect(),n=t.offsetWidth?e.width/t.offsetWidth:1,r=t.offsetHeight?e.height/t.offsetHeight:1;return{x:e.left+t.clientLeft*n,y:e.top+t.clientTop*r,sx:n,sy:r}}function r(e,r){let{left:l,top:o,width:i,height:u}=e,a=t(r);for(;a;){let e=n(a);l=e.x+l*e.sx,o=e.y+o*e.sy,i*=e.sx,u*=e.sy,a=t(a.ownerDocument)}return new DOMRect(l,o,i,u)}function l(t){return r(t.getBoundingClientRect(),t.ownerDocument)}function o(e,r,l){let o=[],i=t(l);for(;i;)o.unshift(i),i=t(i.ownerDocument);for(let t of o){let l=n(t);e=(e-l.x)/l.sx,r=(r-l.y)/l.sy}return{x:e,y:r}}function i(t){return t.ownerDocument.defaultView??window}function u(t){return!(!t||"http://www.w3.org/1999/xhtml"!==t.namespaceURI)}function a(e,n=document){if(e===n)return!0;let r=t(e);return!(!r?.isConnected||r.contentDocument!==e||!a(r.ownerDocument,n))}function s(e,n){if(!a(n))return new DOMRect(0,0,0,0);let l=e.left,o=e.top,i=e.right,u=e.bottom;for(let e=t(n);e;e=t(e.ownerDocument)){let t=r({left:0,top:0,width:e.clientWidth,height:e.clientHeight},e.contentDocument);l=Math.max(l,t.left),o=Math.max(o,t.top),i=Math.min(i,t.right),u=Math.min(u,t.bottom)}return new DOMRect(l,o,Math.max(0,i-l),Math.max(0,u-o))}var f="@frame(";function c(t,e){return`${f}${encodeURIComponent(JSON.stringify({selector:t,url:e.URL}))}) `}function h(t){if(!t.startsWith(f))return null;let e=t.indexOf(") ");if(e<0)return null;try{let n=JSON.parse(decodeURIComponent(t.slice(7,e)));return"string"!=typeof n.selector||"string"!=typeof n.url?null:{...n,rest:t.slice(e+2)}}catch{return null}}var m=" >>> ";function d(t){return Array.from(t.querySelectorAll("*")).flatMap(t=>t.shadowRoot?[t.shadowRoot]:[])}function g(t=document){let e=[t];for(let t of e)e.push(...d(t));return e}function p(t,n=document){if(t.startsWith(f)){let r=h(t);if(!r)return null;let l=r.selector.startsWith(f)||r.selector.includes(m)?[p(r.selector,n)].filter(t=>!!t):g(n).flatMap(t=>Array.from(t.querySelectorAll(r.selector))),o=1===l.length?l[0]:null,i=o&&e(o);return i&&i.URL===r.url?p(r.rest,i):null}let r=t.split(m);if(r.length>1){let t=n,e=null;for(let n=0;n<r.length;n+=1){if(e=t.querySelector(r[n]),!e)return null;if(n<r.length-1){if(!e.shadowRoot)return null;t=e.shadowRoot}}return e}let l=[n];for(let e of l){let n=e.querySelector(t);if(n)return n;l.push(...d(e))}return null}function y(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return"host"in e?e.host:null}function w(t,e){return e.startsWith(f)||e.includes(m)?p(e)===t:t.matches(e)}function b(t,e){let n=t;for(;n;){if(n.matches(e))return n;n=y(n)}return null}function S(t,e){let n=e;for(;n;){if(n===t)return!0;n=y(n)}return!1}var x=new WeakMap;function v(t){let e=t.getAttribute("style");return t.style.setProperty("pointer-events","auto","important"),()=>{null===e?t.removeAttribute("style"):t.setAttribute("style",e)}}function A(t,n,r,l=t=>[t],o){let i=[];for(let l of t.querySelectorAll("iframe")){if(!e(l))continue;let t=l.getBoundingClientRect();n<t.left||n>t.right||r<t.top||r>t.bottom||"none"===l.ownerDocument.defaultView?.getComputedStyle(l).pointerEvents&&i.push(v(l))}try{let e=()=>{let e="function"==typeof t.elementsFromPoint?t.elementsFromPoint(n,r):[],l=t.elementFromPoint?.(n,r)??null;return(l&&!e.includes(l)?[l,...e]:e).filter(e=>9===t.nodeType||e.getRootNode()===t)},i=e(),u=i;if(o){let n=function(t){let e=9===t.nodeType?t:t.ownerDocument,n="* { pointer-events: auto !important; }",r=[];try{let l=e.defaultView?.CSSStyleSheet;if(l?.prototype.replaceSync&&"adoptedStyleSheets"in t){let o=x.get(e);o||(o=new l,o.replaceSync(n),x.set(e,o));let i=[...t.adoptedStyleSheets];t.adoptedStyleSheets=[...i,o],r.push(()=>{t.adoptedStyleSheets=i})}else{let l=e.createElement("style");l.textContent=n,(9===t.nodeType?e.head??e.documentElement:t).appendChild(l),r.push(()=>l.remove())}for(let e of t.querySelectorAll('[style*="pointer-events"]'))"none"!==e.style.getPropertyValue("pointer-events")||"important"!==e.style.getPropertyPriority("pointer-events")||r.push(v(e))}catch(t){throw r.reverse().forEach(t=>t()),t}return()=>r.reverse().forEach(t=>t())}(t);try{u=e()}finally{n()}u=u.filter(t=>i.includes(t)||o(t))}return u.flatMap(l)}finally{i.forEach(t=>t())}}function R(t,n,r=document,l){let i=[],u=new Set,a=9===r.nodeType?r:r.ownerDocument,s=o(t,n,a);for(let o of g(r).reverse())for(let r of A(o,s.x,s.y,r=>{let o=e(r);return o?[...R(t,n,o,l),r]:[r]},l))u.has(r)||(u.add(r),i.push(r));return i}function C(){return m}var D=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],M=t=>t.replace(/\s+/g," ").trim();function O(t){return"id"===t||"data-popmelt-media-id"===t||/^data-(?:testid|test|cy)(?:-[a-z0-9_-]+)?$/.test(t)}function N(t,e){return!(!(e&&e.length<=200)||"id"===t&&/^(radix-|:|_r_)/.test(e))}function W(t){let e={},n=new Set([...D,...t.getAttributeNames().filter(O)]);for(let r of n){let n=t.getAttribute(r);n&&N(r,n)&&(e[r]=n)}let r=M(t.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),l=M(Array.from(t.childNodes).filter(t=>3===t.nodeType).map(t=>t.textContent).join(" "));return{tag:t.tagName.toLowerCase(),...Object.keys(e).length?{attributes:e}:{},...r&&r.length<=200?{heading:r}:{},...l&&l.length<=200?{text:l}:{}}}function E(t,e,n=document){let r=g(n),l=t=>{try{return r.flatMap(e=>Array.from(e.querySelectorAll(t)))}catch{return[]}},o=!(!e||!(e.heading||e.text||Object.keys(e.attributes??{}).length)),i=t=>{if(!e||!o)return!0;let n=W(t);return n.tag===e.tag&&(!e.heading||n.heading===e.heading)&&(!e.text||n.text===e.text)&&Object.entries(e.attributes??{}).every(([e,n])=>t.getAttribute(e)===n)};for(let r of t){if(r.includes(" >>> ")||r.startsWith("@frame(")){try{let t=p(r,n),l=h(r),o=Object.entries(e?.attributes??{}).filter(([t])=>O(t)),u=l&&t&&(l.rest.startsWith("[data-pm=")||o.length>0&&t.tagName.toLowerCase()===e?.tag&&o.every(([e,n])=>t.getAttribute(e)===n));if(t&&(u||i(t)))return{status:"matched",element:t}}catch{}continue}let t=l(r);if(1===t.length&&(/^\[data-pm=/.test(r)||!o))return{status:"matched",element:t[0]}}if(!o||t.some(t=>t.includes(" >>> ")||t.startsWith("@frame("))||!/^[a-z][a-z0-9-]*$/.test(e.tag))return{status:"missing"};let u=l(e.tag);if(u.length>500)return{status:"ambiguous"};let a=Object.entries(e.attributes??{}).filter(([t])=>O(t));if(a.length){let t=u.filter(t=>a.every(([e,n])=>t.getAttribute(e)===n));return 1===t.length?{status:"matched",element:t[0]}:{status:t.length?"ambiguous":"missing"}}let s=u.filter(i);return 1===s.length?{status:"matched",element:s[0]}:{status:s.length?"ambiguous":"missing"}}function q(t,e,n=document){let r={};if(e)for(let[t,n]of Object.entries({...e.dataAttributes,...e.id?{id:e.id}:{}}))O(t)&&N(t,n)&&(r[t]=n);let l=e?.targetFingerprint?.tag??e?.tagName?.toLowerCase(),o=e&&l?{...e.targetFingerprint,tag:l,attributes:{...r,...e.targetFingerprint?.attributes}}:e?.targetFingerprint,i=E([t,e?.selector].filter(t=>!!t),o,n);return"matched"===i.status?i.element:null}export{t as a,e as b,r as c,l as d,o as e,i as f,u as g,a as h,s as i,c as j,g as k,p as l,y as m,w as n,b as o,S as p,R as q,C as r,O as s,W as t,E as u,q as v};
@@ -1,7 +1 @@
1
- "use client";
2
- var P="Update the annotated component with this reviewed option and its Steer changes. Preserve existing behavior and unrelated styling.",j=`
3
- `+P+"\n```json\n",m="popmelt.explore-option.v1";function x(r,e,o){return[r?"Component: "+r:"Target: "+e,"Route: "+o].join(`
4
- `)}function A(r,e){if(!e||typeof e!="object"||Array.isArray(e))return r;let o=e.target;if(!o||typeof o!="object"||Array.isArray(o)||typeof o.pathname!="string")return r;let[t,...n]=r.split(`
5
- `),p=" \xB7 "+o.pathname;if(!t?.endsWith(p))return r;let l=t.slice(0,-p.length),i=typeof o.component=="string"?o.component:void 0;return!l||i&&l!==i?r:[x(i,l,o.pathname),...n].join(`
6
- `)}function y(r,e,o,t){let n=r.options[e],{pathname:p,selector:l,element:i}=r.target,u=i?.reactSource,s=i?.reactComponent,h=o.filter(a=>a.batchId===r.id&&a.option===e).map(({part:a,property:c,from:d,to:g})=>({part:a,property:c,from:d,to:g})),b={pathname:p,selector:l,...i?.selector&&{sourceSelector:i.selector},...s&&{component:s},...u&&{source:u}},f="root"in n&&t?.path.reduce((a,c)=>a.children[c],n.root);return{source:"Popmelt",title:f&&(t?.path.length||t?.field)?n.title+" \xB7 "+(f.name??f.label??f.kind)+(t.field?" label":""):t?.fixturePart?n.title+" \xB7 "+(t.fixturePartLabel||t.fixturePart.replace(/^@/,"")):n.title,content:[x(s,i?.subjectLabel||l,p),...h.map(({part:a,property:c,to:d})=>[a,c+" \u2192 "+d].filter(Boolean).join(" \xB7 "))].join(`
7
- `),...u&&{sourceURI:u.fileName},kind:m,selection:{batchId:r.id,index:e,target:b,option:n,steerEdits:h,...t&&(t.path.length||t.field||t.fixturePart)?{focus:{path:t.path,...t.fixturePart&&{part:t.fixturePart},...t.fixturePartLabel&&{label:t.fixturePartLabel},...t.field&&{field:t.field}}}:{}}}}function v(r,e,o){return{key:JSON.stringify([r.id,e.option,e.path,e.field,e.fixturePart]),tag:e,note:y(r,e.option,o,e)}}function B(r,e,o){let t=y(r,e,o);return{text:`Apply \u201C${t.title}\u201D in code.`,meta:{exploreOption:t}}}function S(r){if(!r?.startsWith("Apply \u201C"))return;let e=r.indexOf(j);if(e>0&&r.slice(0,e).endsWith("\u201D in code."))return r.slice(0,e)}export{m as a,A as b,v as c,B as d,S as e};
1
+ "use client";var t="popmelt.explore-option.v1";function e(t,e,r){return[t?"Component: "+t:"Target: "+e,"Route: "+r].join("\n")}function r(t,r){if(!r||"object"!=typeof r||Array.isArray(r))return t;let n=r.target;if(!n||"object"!=typeof n||Array.isArray(n)||"string"!=typeof n.pathname)return t;let[o,...i]=t.split("\n"),a=" · "+n.pathname;if(!o?.endsWith(a))return t;let l=o.slice(0,-a.length),p="string"==typeof n.component?n.component:void 0;return!l||p&&l!==p?t:[e(p,l,n.pathname),...i].join("\n")}function n(r,n,o,i){let a=r.options[n],{pathname:l,selector:p,element:c}=r.target,s=c?.reactSource,f=c?.reactComponent,u=o.filter(t=>t.batchId===r.id&&t.option===n).map(({part:t,property:e,from:r,to:n})=>({part:t,property:e,from:r,to:n})),d={pathname:l,selector:p,...c?.selector&&{sourceSelector:c.selector},...f&&{component:f},...s&&{source:s}},h="root"in a&&i?.path.reduce((t,e)=>t.children[e],a.root);return{source:"Popmelt",title:h&&(i?.path.length||i?.field)?a.title+" · "+(h.name??h.label??h.kind)+(i.field?" label":""):i?.fixturePart?a.title+" · "+(i.fixturePartLabel||i.fixturePart.replace(/^@/,"")):a.title,content:[e(f,c?.subjectLabel||p,l),...u.map(({part:t,property:e,to:r})=>[t,e+" → "+r].filter(Boolean).join(" · "))].join("\n"),...s&&{sourceURI:s.fileName},kind:t,selection:{batchId:r.id,index:n,target:d,option:a,steerEdits:u,...i&&(i.path.length||i.field||i.fixturePart)?{focus:{path:i.path,...i.fixturePart&&{part:i.fixturePart},...i.fixturePartLabel&&{label:i.fixturePartLabel},...i.field&&{field:i.field}}}:{}}}}function o(t,e,r){return{key:JSON.stringify([t.id,e.option,e.path,e.field,e.fixturePart]),tag:e,note:n(t,e.option,r,e)}}function i(t,e,r){let o=n(t,e,r);return{text:`Apply “${o.title}” in code.`,meta:{exploreOption:o}}}function a(t){if(!t?.startsWith("Apply “"))return;let e=t.indexOf("\nUpdate the annotated component with this reviewed option and its Steer changes. Preserve existing behavior and unrelated styling.\n```json\n");return e>0&&t.slice(0,e).endsWith("” in code.")?t.slice(0,e):void 0}export{t as a,r as b,o as c,i as d,a as e};
@@ -1,2 +1 @@
1
- "use client";
2
- function r(){let l=!1,t=null,n,a=new Set,s=()=>a.forEach(e=>e());return{connect(e){t!==e&&(n?.(),t=e,t.setAvailable(l),n=t.subscribe(s),s())},setAvailable(e){l=e,t?.setAvailable(e)},getSnapshot:()=>t?.getSnapshot()??null,subscribe(e){return a.add(e),()=>{a.delete(e)}}}}var b=r();export{b as a};
1
+ "use client";var e=function(){let e,t=!1,a=null,l=new Set,n=()=>l.forEach(e=>e());return{connect(l){a!==l&&(e?.(),a=l,a.setAvailable(t),e=a.subscribe(n),n())},setAvailable(e){t=e,a?.setAvailable(e)},getSnapshot:()=>a?.getSnapshot()??null,subscribe:e=>(l.add(e),()=>{l.delete(e)})}}();export{e as a};