@popmelt.com/core 0.37.1 → 0.38.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.
- package/THIRD_PARTY_NOTICES.md +236 -0
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ExploreAttachment-IIEORQP3.mjs +1 -0
- package/dist/{PagePreviewLayer-SIH7DDBF.mjs → PagePreviewLayer-AFSRCBAX.mjs} +1 -1
- package/dist/ParticipantRuntime-ZNEFG34O.mjs +1 -0
- package/dist/PhoneHostGate-OCIMKPLM.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-N2A5XPRO.mjs +1 -0
- package/dist/PreviewRuntime-3ANAJNFO.mjs +1 -0
- package/dist/QueuedReplies-5YG2DN3W.mjs +1 -0
- package/dist/SamplePlacementOverlay-EOJW6XGE.mjs +1 -0
- package/dist/ShareProjectPane-VYWTF3FW.mjs +1 -0
- package/dist/SuppliedContext-3S4HT6U6.mjs +1 -0
- package/dist/ThreadErrorCard-CTMVMETS.mjs +1 -0
- package/dist/ThreadPanel-G7OKSWD4.mjs +1 -0
- package/dist/adapter-react-three-fiber.d.mts +1 -1
- package/dist/adapter-react-three-fiber.mjs +1 -1
- package/dist/adapter-three.d.mts +2 -0
- package/dist/adapter-three.mjs +3 -3
- package/dist/bridge-entry.mjs +1 -1
- package/dist/bridge-recovery-NUYIGCFV.mjs +1 -0
- package/dist/bridgeSSEStream-HUFNXYPG.mjs +1 -0
- package/dist/bridgeWebSocketStream-AS22Y2FP.mjs +1 -0
- package/dist/browser-runtime-Q26JF5EA.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/canvas-chat-note-OLVVP55Y.mjs +1 -0
- package/dist/checkFixture-UNTXJKRN.mjs +1 -0
- package/dist/{chunk-YYODLRV3.mjs → chunk-25EXQOPI.mjs} +1 -1
- package/dist/{chunk-L6S66APQ.mjs → chunk-2F2BVGFH.mjs} +1 -1
- package/dist/chunk-2IWVTTYX.mjs +1 -0
- package/dist/{chunk-JSNK6NX7.mjs → chunk-2WQXHUEQ.mjs} +1 -1
- package/dist/{chunk-76WRZ2NH.mjs → chunk-3LZQLRZ2.mjs} +1 -1
- package/dist/chunk-3OGSLX4V.mjs +1 -0
- package/dist/{chunk-IAXSC2ZN.mjs → chunk-43BZCDGL.mjs} +1 -1
- package/dist/{chunk-7EISKUU7.mjs → chunk-5F34UIKL.mjs} +1 -1
- package/dist/{chunk-ECMLCGAM.mjs → chunk-6RMM7JB6.mjs} +1 -1
- package/dist/{chunk-CVVD2OMQ.mjs → chunk-AEC67LMY.mjs} +1 -1
- package/dist/{chunk-B22WBEQC.mjs → chunk-B3RA4XAR.mjs} +1 -1
- package/dist/{chunk-FON4QY7P.mjs → chunk-BEGAJYOY.mjs} +1 -1
- package/dist/{chunk-6XEEXK3U.mjs → chunk-BJUSVIDN.mjs} +1 -1
- package/dist/chunk-BOZVNUHJ.mjs +1 -0
- package/dist/chunk-CRZEJJI6.mjs +1 -0
- package/dist/{chunk-O2ZQFLNV.mjs → chunk-DBCBG5J6.mjs} +1 -1
- package/dist/{chunk-RUJC32MA.mjs → chunk-EFWBHWHP.mjs} +1 -1
- package/dist/{chunk-UX3DTCHL.mjs → chunk-FQLIJAUB.mjs} +1 -1
- package/dist/{chunk-EZVFCJEG.mjs → chunk-FYURSPM3.mjs} +1 -1
- package/dist/{chunk-HPU2UMVE.mjs → chunk-G6BN5TAZ.mjs} +1 -1
- package/dist/chunk-GTVTUWGH.mjs +1 -0
- package/dist/{chunk-SKKHZBOJ.mjs → chunk-JAMYVQFC.mjs} +1 -1
- package/dist/{chunk-SOT33EQ4.mjs → chunk-JJRKR4X3.mjs} +1 -1
- package/dist/{chunk-EFGQKWSZ.mjs → chunk-KHDXOXYF.mjs} +1 -1
- package/dist/chunk-KL5ODVJA.mjs +1 -0
- package/dist/{chunk-WF3YGZPI.mjs → chunk-L356S4EY.mjs} +1 -1
- package/dist/{chunk-3PSB5BST.mjs → chunk-N3MHDOMU.mjs} +1 -1
- package/dist/{chunk-QV5G3XRE.mjs → chunk-P2WAXWAZ.mjs} +1 -1
- package/dist/{chunk-HBFSPXIC.mjs → chunk-QQPUMPKU.mjs} +1 -1
- package/dist/{chunk-EUFR7R5Q.mjs → chunk-QXFBFKN6.mjs} +1 -1
- package/dist/{chunk-KXVXWEN4.mjs → chunk-RJWFSAKE.mjs} +1 -1
- package/dist/{chunk-FJWWBKCQ.mjs → chunk-RWZ7SVMO.mjs} +1 -1
- package/dist/{chunk-GAUQZAW6.mjs → chunk-SKM4ZXV5.mjs} +1 -1
- package/dist/{chunk-EBJ23A7F.mjs → chunk-TEXVTTWA.mjs} +1 -1
- package/dist/{chunk-QXVMGZFP.mjs → chunk-TSQEBZYO.mjs} +1 -1
- package/dist/{chunk-JEGBAHYK.mjs → chunk-TVIKC33M.mjs} +1 -1
- package/dist/{chunk-4LVGVKSS.mjs → chunk-TXL2CR66.mjs} +1 -1
- package/dist/{chunk-WJHYEACV.mjs → chunk-UOK5LOPJ.mjs} +1 -1
- package/dist/chunk-VG4ZV2OT.mjs +30 -0
- package/dist/{chunk-SBD7GQDN.mjs → chunk-W62YY5IT.mjs} +1 -1
- package/dist/chunk-WC7B5NU3.mjs +24 -0
- package/dist/{chunk-BYASSHKJ.mjs → chunk-WIJSWSNF.mjs} +1 -1
- package/dist/{chunk-NI77Y3WC.mjs → chunk-WJVRGXOS.mjs} +1 -1
- package/dist/{chunk-HAN6CUNB.mjs → chunk-WNOLXY3Y.mjs} +1 -1
- package/dist/chunk-YGP6PPOZ.mjs +1 -0
- package/dist/{chunk-LOUWY55X.mjs → chunk-ZHXTB5IN.mjs} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-4X7I5AIJ.mjs +1 -0
- package/dist/{codex-project-3GJPU63O.mjs → codex-project-Q6YT5P37.mjs} +1 -1
- package/dist/{codex-store-mount-F6RBC77X.mjs → codex-store-mount-WJAATWHT.mjs} +1 -1
- package/dist/dev-server-NROXLQKM.mjs +1 -0
- package/dist/focus-inspection-LGIRFL2T.mjs +1 -0
- package/dist/guest-admission.mjs +1 -1
- package/dist/guest-live-canvas.mjs +1 -1
- package/dist/index.d.mts +27 -6
- package/dist/index.mjs +1 -1
- package/dist/inviteQr-YK3JAR6U.mjs +1 -0
- package/dist/media.d.mts +3 -3
- package/dist/media.mjs +1 -1
- package/dist/memory-legacy.mjs +1 -1
- package/dist/memory-store.mjs +1 -1
- package/dist/{participantBootstrap-CSLsiQ-C.d.mts → participantBootstrap-BTcD7XgB.d.mts} +2 -2
- package/dist/{peer-client-7X52EKMX.mjs → peer-client-DWC5F6JN.mjs} +1 -1
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{subjects-BQFCkehy.d.mts → subjects-D_yanOQ2.d.mts} +2 -0
- package/dist/taste-proposal-session-AAXK4CFL.mjs +1 -0
- package/dist/toolbarFonts-JAGSN3DN.mjs +1 -0
- package/dist/{video-adapter-C0kSwUir.d.mts → video-adapter-CWpR4NSt.d.mts} +1 -1
- package/dist/webpEncoder-QJRHTWUU.mjs +1 -0
- package/dist/workspace-snapshot-RUGPDEYJ.mjs +1 -0
- package/package.json +26 -35
- package/dist/ExploreAttachment-6AIMXC2K.mjs +0 -1
- package/dist/ParticipantRuntime-RTMEFDKF.mjs +0 -1
- package/dist/PhoneHostGate-RZRGWS2E.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-FAJXJEQQ.mjs +0 -1
- package/dist/PreviewRuntime-MW33PLMV.mjs +0 -1
- package/dist/QueuedReplies-4APDDNQX.mjs +0 -1
- package/dist/SamplePlacementOverlay-2VLBRDPZ.mjs +0 -1
- package/dist/ShareProjectPane-OR2LS2A3.mjs +0 -1
- package/dist/SuppliedContext-SAQKEDWW.mjs +0 -1
- package/dist/ThreadErrorCard-OSHIWSHR.mjs +0 -1
- package/dist/ThreadPanel-CMC5Q6WM.mjs +0 -1
- package/dist/bridge-recovery-3IQN3U6D.mjs +0 -1
- package/dist/bridgeSSEStream-6OMAFDFW.mjs +0 -1
- package/dist/bridgeWebSocketStream-WIOGOPJW.mjs +0 -1
- package/dist/browser-runtime-5W2ZKUCZ.mjs +0 -1
- package/dist/canvas-chat-note-O3USBECW.mjs +0 -1
- package/dist/checkFixture-DQPLFEUL.mjs +0 -1
- package/dist/chunk-3QYA5LGF.mjs +0 -1
- package/dist/chunk-5GEBVPTA.mjs +0 -1
- package/dist/chunk-7JWADHTH.mjs +0 -1
- package/dist/chunk-CCFTIBCJ.mjs +0 -1
- package/dist/chunk-OIKFQ2FV.mjs +0 -1
- package/dist/chunk-QE5XGXIA.mjs +0 -30
- package/dist/chunk-ROKRMYFR.mjs +0 -1
- package/dist/chunk-VVNZ5IEG.mjs +0 -24
- package/dist/codex-note-context-6QGJT2V3.mjs +0 -1
- package/dist/dev-server-KWVIMLLL.mjs +0 -1
- package/dist/focus-inspection-F25RXWZV.mjs +0 -1
- package/dist/inviteQr-U77MLSEQ.mjs +0 -1
- package/dist/taste-proposal-session-DBOUA54V.mjs +0 -1
- package/dist/toolbarFonts-GVPRHJGB.mjs +0 -1
- package/dist/workspace-snapshot-6LN7U2NJ.mjs +0 -1
- /package/dist/{chunk-PWQB3FIW.mjs → chunk-AWWUJO3N.mjs} +0 -0
- /package/dist/{chunk-TIAPJGX2.mjs → chunk-L45FX4SU.mjs} +0 -0
- /package/dist/{chunk-W2QQVB2H.mjs → chunk-VXRRHXUP.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{p as t,r as e,f as n}from"./chunk-76WRZ2NH.mjs";import{X as o,A as i,a as r}from"./chunk-JEGBAHYK.mjs";import{a}from"./chunk-YYODLRV3.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 R(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 E(t,e){let n=null;return async o=>{if(!P(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 I(t,e,n){let o=Math.min(e,n);return{top:Math.max(0,Math.min(t,n-o)),height:o,annotations:[]}}function P(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 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 U(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 R(o)&&console.debug("[Screenshot] Reusing in-flight capture",i),r;let a=T(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 H(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 B(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})))}async function W(t,e){let n=[];for(let e of t){let t=Object.getOwnPropertyDescriptor(e.element,"toDataURL");try{Object.defineProperty(e.element,"toDataURL",{configurable:!0,value:()=>e.dataUrl}),n.push(()=>{t?Object.defineProperty(e.element,"toDataURL",t):Reflect.deleteProperty(e.element,"toDataURL")})}catch{}}try{return await e()}finally{for(let t of n.reverse())t()}}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,R(o)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",t)}}let a=await i(),l=C(),s=await 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",s}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 T(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=R(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?[{...I(window.scrollY,d,m),left:b,annotations:A}]:B(A,k,c,d,m),D=function(t){let e=0,n=0;for(let o of t.querySelectorAll("img[src]"))P(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,U=null,T=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),z=T?{...T,left:j[0]?.left}:null,q=z??j[0],F=async()=>{if(!Y){let e=C();Y=w(i,()=>async function(t,e,n,o,i,r,a,l){let s=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)>4*window.innerHeight||t.querySelectorAll("*").length>2500,c=l?await l():[],d=await W(c,()=>f(t,{autoDestruct:!1,filter:H,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:s?[...M]:null,fetchFn:E(i,()=>{a.remoteAssetFallbacks++}),fetch:{requestInit:{cache:"force-cache"},placeholderImage:x}}));return"null"===window.origin&&(d.sandbox=document.createElement("iframe")),d}(t,q,c,s,u,g,L,o?.captureSurfaces)).then(t=>(U=t,L.contextMs+=C()-e,t))}return Y};try{let t,e=C();if(z){let e=await w(i,()=>N(z,c,s,o,F,L));t=j.map(t=>$(e,z.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,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{U&&h(U)}}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,Y as h,U as i,W as j,z as k,q as l};
|
|
1
|
+
"use client";import{p as t,r as e,f as n}from"./chunk-3LZQLRZ2.mjs";import{X as o,A as i,a as r}from"./chunk-TVIKC33M.mjs";import{a}from"./chunk-25EXQOPI.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 I(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(!P(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 P(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 X(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 I(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 Y(){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 T=Promise.resolve();async function W(t,e){if(!t.length)return e();let n,o=T;T=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 $(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,I(o)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",t)}}let a=await i(),l=C(),s=await(o?.captureSurfaces?.())??[],c=await W(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 N(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 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=I(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]"))P(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,X=null,T=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=T?{...T,left:j[0]?.left}:null,z=W??j[0],q=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:Y(),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,z,c,s,u,g,L)).then(t=>(X=t,L.contextMs+=C()-e,t))}return U};try{let t,e=C();if(W){let e=await w(i,()=>$(W,c,s,o,q,L));t=j.map(t=>N(e,W.top,t,c,s,k,S,t.left??b))}else{t=[];for(let e of j){let n=await w(i,()=>$(e,c,s,o,q,L));t.push(N(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{X&&h(X)}}async function q(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 F(t,e,n,o,i){try{let r=Array.isArray(t)?t:[t];if(0===r.length)return!1;let a=await q(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,X as i,W as j,q as k,F as l};
|