instruckt 0.4.20 → 0.4.21
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/dist/instruckt.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* instruckt v0.4.
|
|
1
|
+
/* instruckt v0.4.21 | MIT */
|
|
2
2
|
"use strict";var Instruckt=(()=>{var V=Object.defineProperty,re=Object.defineProperties,ie=Object.getOwnPropertyDescriptor,se=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable;var bt=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))Q.call(t,n)&&bt(e,n,t[n]);if(q)for(var n of q(t))wt.call(t,n)&&bt(e,n,t[n]);return e},L=(e,t)=>re(e,se(t));var yt=(e,t)=>{var n={};for(var o in e)Q.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&q)for(var o of q(e))t.indexOf(o)<0&&wt.call(e,o)&&(n[o]=e[o]);return n};var le=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},ce=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ae(t))!Q.call(e,r)&&r!==n&&V(e,r,{get:()=>t[r],enumerable:!(o=ie(t,r))||o.enumerable});return e};var de=e=>ce(V({},"__esModule",{value:!0}),e);var Xn={};le(Xn,{Instruckt:()=>H,init:()=>Kn});function ue(){let e=document.cookie.match(/(?:^|;\s*)XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):""}function tt(){let e={"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest"},t=ue();return t&&(e["X-XSRF-TOKEN"]=t),e}function I(e){let t={};for(let[n,o]of Object.entries(e)){let r=n.replace(/_([a-z])/g,(i,s)=>s.toUpperCase());t[r]=Array.isArray(o)?o.map(i=>i&&typeof i=="object"&&!Array.isArray(i)?I(i):i):o&&typeof o=="object"&&!Array.isArray(o)?I(o):o}return t}function et(e){let t={};for(let[n,o]of Object.entries(e)){let r=n.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`);t[r]=o&&typeof o=="object"&&!Array.isArray(o)?et(o):o}return t}var W=class{constructor(t){this.endpoint=t}async getAnnotations(){let t=await fetch(`${this.endpoint}/annotations`,{headers:tt()});if(!t.ok)throw new Error(`instruckt: failed to load annotations (${t.status})`);return(await t.json()).map(o=>I(o))}async addAnnotation(t){let n=await fetch(`${this.endpoint}/annotations`,{method:"POST",headers:tt(),body:JSON.stringify(et(t))});if(!n.ok)throw new Error(`instruckt: failed to add annotation (${n.status})`);return I(await n.json())}async updateAnnotation(t,n){let o=await fetch(`${this.endpoint}/annotations/${t}`,{method:"PATCH",headers:tt(),body:JSON.stringify(et(n))});if(!o.ok)throw new Error(`instruckt: failed to update annotation (${o.status})`);return I(await o.json())}};var he=`
|
|
3
3
|
body.ik-annotating,
|
|
4
4
|
body.ik-annotating * { cursor: crosshair !important; }
|
|
@@ -393,20 +393,20 @@ textarea::placeholder { color:var(--ik-muted); }
|
|
|
393
393
|
.ik-marker.has-screenshot { background: var(--ik-marker-screenshot, #22c55e); box-shadow: 0 2px 8px color-mix(in srgb, var(--ik-marker-screenshot, #22c55e) 40%, transparent); }
|
|
394
394
|
.ik-marker.dismissed { background: var(--ik-marker-dismissed, #71717a); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
|
|
395
395
|
`;function ot(e){if(document.getElementById("instruckt-global"))return;let t=e?`:root {${e.default?` --ik-marker-default: ${e.default};`:""}${e.screenshot?` --ik-marker-screenshot: ${e.screenshot};`:""}${e.dismissed?` --ik-marker-dismissed: ${e.dismissed};`:""} }
|
|
396
|
-
`:"",n=document.createElement("style");n.id="instruckt-global",n.textContent=t+he+pe,document.head.appendChild(n)}var A={annotate:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>',freeze:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg>',copy:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',check:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',clear:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>',minimize:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="7 13 12 18 17 13"/><line x1="12" y1="6" x2="12" y2="18"/></svg>',screenshot:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',logo:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>'},$=class{constructor(t,n,o){this.position=t;this.callbacks=n;this.fabBadge=null;this.annotateActive=!1;this.freezeActive=!1;this.minimized=!1;this.totalCount=0;this.dragging=!1;this.dragOffset={x:0,y:0};this.keys=o!=null?o:{},this.build(),this.setupDrag()}build(){var l,h,d,m,g;this.host=document.createElement("div"),this.host.setAttribute("data-instruckt","toolbar"),this.shadow=this.host.attachShadow({mode:"open"});let t=document.createElement("style");t.textContent=kt,this.shadow.appendChild(t),this.toolbarEl=document.createElement("div"),this.toolbarEl.className="toolbar";let n=this.keys;this.annotateBtn=this.makeBtn(A.annotate,`Annotate elements (${((l=n.annotate)!=null?l:"A").toUpperCase()})`,()=>{let p=!this.annotateActive;this.setAnnotateActive(p),this.callbacks.onToggleAnnotate(p)}),this.freezeBtn=this.makeBtn(A.freeze,`Freeze page (${((h=n.freeze)!=null?h:"F").toUpperCase()})`,()=>{let p=!this.freezeActive;this.setFreezeActive(p),this.callbacks.onFreezeAnimations(p)});let o=this.makeBtn(A.screenshot,`Screenshot region (${((d=n.screenshot)!=null?d:"C").toUpperCase()})`,()=>{this.callbacks.onScreenshot()});this.copyBtn=this.makeBtn(A.copy,"Copy annotations as markdown",()=>{this.callbacks.onCopy(),this.copyBtn.innerHTML=A.check,setTimeout(()=>{this.copyBtn.innerHTML=A.copy},1200)});let r=document.createElement("div");r.className="clear-wrap";let i=this.makeBtn(A.clear,`Clear this page (${((m=n.clearPage)!=null?m:"X").toUpperCase()})`,()=>{var p,f;(f=(p=this.callbacks).onClearPage)==null||f.call(p)});i.classList.add("danger-btn");let s=this.makeBtn('<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2"/><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/></svg>',"Delete all instructions.",()=>{var p,f;return(f=(p=this.callbacks).onClearAll)==null?void 0:f.call(p)});s.classList.add("danger-btn","clear-all-btn"),r.appendChild(i),r.appendChild(s);let a=this.makeBtn(A.minimize,"Minimize toolbar",()=>{this.setMinimized(!0)});a.classList.add("minimize-btn");let c=()=>{let p=document.createElement("div");return p.className="divider",p};this.toolbarEl.append(this.annotateBtn,o,c(),this.freezeBtn,c(),this.copyBtn,r,c(),a),this.shadow.appendChild(this.toolbarEl),this.fab=document.createElement("button"),this.fab.className="fab",this.fab.title="Open instruckt toolbar",this.fab.setAttribute("aria-label","Open instruckt toolbar"),this.fab.innerHTML=A.logo,this.fab.style.display="none",this.fab.addEventListener("click",p=>{p.stopPropagation(),this.setMinimized(!1)}),this.shadow.appendChild(this.fab),this.host.addEventListener("click",p=>p.stopPropagation()),this.host.addEventListener("mousedown",p=>p.stopPropagation()),this.host.addEventListener("pointerdown",p=>p.stopPropagation()),this.applyPosition(),((g=document.getElementById("instruckt-root"))!=null?g:document.body).appendChild(this.host)}makeBtn(t,n,o){let r=document.createElement("button");return r.className="btn",r.setAttribute("data-tooltip",n),r.setAttribute("aria-label",n),r.innerHTML=t,r.addEventListener("click",i=>{i.stopPropagation(),o()}),r}applyPosition(){let t="16px";Object.assign(this.host.style,{position:"fixed",zIndex:"2147483646",bottom:this.position.includes("bottom")?t:"auto",top:this.position.includes("top")?t:"auto",right:this.position.includes("right")?t:"auto",left:this.position.includes("left")?t:"auto"})}setupDrag(){this.shadow.addEventListener("mousedown",t=>{let n=t;if(n.target.closest(".btn")||n.target.closest(".fab"))return;this.dragging=!0;let o=this.host.getBoundingClientRect();this.dragOffset={x:n.clientX-o.left,y:n.clientY-o.top},n.preventDefault()}),document.addEventListener("mousemove",t=>{this.dragging&&Object.assign(this.host.style,{left:`${t.clientX-this.dragOffset.x}px`,top:`${t.clientY-this.dragOffset.y}px`,right:"auto",bottom:"auto"})}),document.addEventListener("mouseup",()=>{this.dragging=!1})}setMinimized(t){var n,o;this.minimized=t,this.toolbarEl.style.display=t?"none":"",this.fab.style.display=t?"":"none",this.updateFabBadge(),(o=(n=this.callbacks).onMinimize)==null||o.call(n,t)}updateFabBadge(){var t;this.totalCount>0&&this.minimized?(this.fabBadge||(this.fabBadge=document.createElement("span"),this.fabBadge.className="fab-badge",this.fab.appendChild(this.fabBadge)),this.fabBadge.textContent=this.totalCount>99?"99+":String(this.totalCount)):((t=this.fabBadge)==null||t.remove(),this.fabBadge=null)}isMinimized(){return this.minimized}minimize(){this.minimized=!0,this.toolbarEl.style.display="none",this.fab.style.display="",this.updateFabBadge()}setAnnotateActive(t){this.annotateActive=t,this.annotateBtn.classList.toggle("active",t),document.body.classList.toggle("ik-annotating",t)}setFreezeActive(t){this.freezeActive=t,this.freezeBtn.classList.toggle("active",t)}setMode(t){this.setAnnotateActive(t==="annotating")}setAnnotationCount(t){let n=this.annotateBtn.querySelector(".badge");t>0?(n||(n=document.createElement("span"),n.className="badge",this.annotateBtn.appendChild(n)),n.textContent=t>99?"99+":String(t)):n==null||n.remove()}setTotalCount(t){this.totalCount=t,this.updateFabBadge()}destroy(){this.host.remove(),document.body.classList.remove("ik-annotating")}};var F=class{constructor(){var n;this.el=document.createElement("div"),Object.assign(this.el.style,{position:"fixed",pointerEvents:"none",zIndex:"2147483644",border:"2px solid rgba(99,102,241,0.7)",background:"rgba(99,102,241,0.1)",borderRadius:"3px",transition:"all 0.06s ease",display:"none"}),this.el.setAttribute("data-instruckt","highlight"),((n=document.getElementById("instruckt-root"))!=null?n:document.body).appendChild(this.el)}show(t){let n=t.getBoundingClientRect();if(n.width===0&&n.height===0){this.hide();return}Object.assign(this.el.style,{display:"block",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`})}hide(){this.el.style.display="none"}destroy(){this.el.remove()}};function me(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}var Mt=112,Lt=72,zt=89,Rt=115,rt;function fe(){let e=new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let o=0;o<8;o++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return e}function ge(e){let t=-1;rt||(rt=fe());for(let n=0;n<e.length;n++)t=rt[(t^e[n])&255]^t>>>8;return t^-1}function ve(e){let t=e.length-1;for(let n=t;n>=4;n--)if(e[n-4]===9&&e[n-3]===Mt&&e[n-2]===Lt&&e[n-1]===zt&&e[n]===Rt)return n-3;return 0}function be(e,t,n=!1){let o=new Uint8Array(13);t*=39.3701,o[0]=Mt,o[1]=Lt,o[2]=zt,o[3]=Rt,o[4]=t>>>24,o[5]=t>>>16,o[6]=t>>>8,o[7]=t&255,o[8]=o[4],o[9]=o[5],o[10]=o[6],o[11]=o[7],o[12]=1;let r=ge(o),i=new Uint8Array(4);if(i[0]=r>>>24,i[1]=r>>>16,i[2]=r>>>8,i[3]=r&255,n){let s=ve(e);return e.set(o,s),e.set(i,s+13),e}else{let s=new Uint8Array(4);s[0]=0,s[1]=0,s[2]=0,s[3]=9;let a=new Uint8Array(54);return a.set(e,0),a.set(s,33),a.set(o,37),a.set(i,50),a}}var we="AAlwSFlz",ye="AAAJcEhZ",ke="AAAACXBI";function xe(e){let t=e.indexOf(we);return t===-1&&(t=e.indexOf(ye)),t===-1&&(t=e.indexOf(ke)),t}var Bt="[modern-screenshot]",C=typeof window!="undefined",Ee=C&&"Worker"in window,Se=C&&"atob"in window,Ae=C&&"btoa"in window,Pt,at=C?(Pt=window.navigator)==null?void 0:Pt.userAgent:"",It=at.includes("Chrome"),K=at.includes("AppleWebKit")&&!It,lt=at.includes("Firefox"),Ce=e=>e&&"__CONTEXT__"in e,Te=e=>e.constructor.name==="CSSFontFaceRule",Pe=e=>e.constructor.name==="CSSImportRule",Me=e=>e.constructor.name==="CSSLayerBlockRule",S=e=>e.nodeType===1,U=e=>typeof e.className=="object",$t=e=>e.tagName==="image",Le=e=>e.tagName==="use",N=e=>S(e)&&typeof e.style!="undefined"&&!U(e),ze=e=>e.nodeType===8,Re=e=>e.nodeType===3,B=e=>e.tagName==="IMG",X=e=>e.tagName==="VIDEO",Be=e=>e.tagName==="CANVAS",Ie=e=>e.tagName==="TEXTAREA",$e=e=>e.tagName==="INPUT",Fe=e=>e.tagName==="STYLE",Ne=e=>e.tagName==="SCRIPT",_e=e=>e.tagName==="SELECT",Oe=e=>e.tagName==="SLOT",Ue=e=>e.tagName==="IFRAME",De=(...e)=>console.warn(Bt,...e);function je(e){var n;let t=(n=e==null?void 0:e.createElement)==null?void 0:n.call(e,"canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}var it=e=>e.startsWith("data:");function Ft(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(C&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!C)return e;let n=Y().implementation.createHTMLDocument(),o=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(o),n.body.appendChild(r),t&&(o.href=t),r.href=e,r.href}function Y(e){var t;return(t=e&&S(e)?e==null?void 0:e.ownerDocument:e)!=null?t:window.document}var G="http://www.w3.org/2000/svg";function He(e,t,n){let o=Y(n).createElementNS(G,"svg");return o.setAttributeNS(null,"width",e.toString()),o.setAttributeNS(null,"height",t.toString()),o.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),o}function qe(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function Ve(e,t){return new Promise((n,o)=>{let r=new FileReader;r.onload=()=>n(r.result),r.onerror=()=>o(r.error),r.onabort=()=>o(new Error(`Failed read blob to ${t}`)),t==="dataUrl"?r.readAsDataURL(e):t==="arrayBuffer"&&r.readAsArrayBuffer(e)})}var We=e=>Ve(e,"dataUrl");function R(e,t){let n=Y(t).createElement("img");return n.decoding="sync",n.loading="eager",n.src=e,n}function _(e,t){return new Promise(n=>{let{timeout:o,ownerDocument:r,onError:i,onWarn:s}=t!=null?t:{},a=typeof e=="string"?R(e,Y(r)):e,c=null,u=null;function l(){n(a),c&&clearTimeout(c),u==null||u()}if(o&&(c=setTimeout(l,o)),X(a)){let h=a.currentSrc||a.src;if(!h)return a.poster?_(a.poster,t).then(n):l();if(a.readyState>=2)return l();let d=l,m=g=>{s==null||s("Failed video load",h,g),i==null||i(g),l()};u=()=>{a.removeEventListener("loadeddata",d),a.removeEventListener("error",m)},a.addEventListener("loadeddata",d,{once:!0}),a.addEventListener("error",m,{once:!0})}else{let h=$t(a)?a.href.baseVal:a.currentSrc||a.src;if(!h)return l();let d=async()=>{if(B(a)&&"decode"in a)try{await a.decode()}catch(g){s==null||s("Failed to decode image, trying to render anyway",a.dataset.originalSrc||h,g)}l()},m=g=>{s==null||s("Failed image load",a.dataset.originalSrc||h,g),l()};if(B(a)&&a.complete)return d();u=()=>{a.removeEventListener("load",d),a.removeEventListener("error",m)},a.addEventListener("load",d,{once:!0}),a.addEventListener("error",m,{once:!0})}})}async function Ke(e,t){N(e)&&(B(e)||X(e)?await _(e,t):await Promise.all(["img","video"].flatMap(n=>Array.from(e.querySelectorAll(n)).map(o=>_(o,t)))))}var Nt=(function(){let t=0,n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${n()}${t}`)})();function _t(e){return e==null?void 0:e.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var xt=0;function Xe(e){let t=`${Bt}[#${xt}]`;return xt++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...n)=>e&&De(...n)}}function Ye(e){return{cache:e?"no-cache":"force-cache"}}async function J(e,t){return Ce(e)?e:Ge(e,L(E({},t),{autoDestruct:!0}))}async function Ge(e,t){var m,g,p,f,v;let{scale:n=1,workerUrl:o,workerNumber:r=1}=t||{},i=!!(t!=null&&t.debug),s=(m=t==null?void 0:t.features)!=null?m:!0,a=(g=e.ownerDocument)!=null?g:C?window.document:void 0,c=(f=(p=e.ownerDocument)==null?void 0:p.defaultView)!=null?f:C?window:void 0,u=new Map,l=L(E({width:0,height:0,quality:1,type:"image/png",scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:i,fetch:E({requestInit:Ye((v=t==null?void 0:t.fetch)==null?void 0:v.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1},t==null?void 0:t.fetch),fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:r,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1},t),{__CONTEXT__:!0,log:Xe(i),node:e,ownerDocument:a,ownerWindow:c,dpi:n===1?null:96*n,svgStyleElement:Ot(a),svgDefsElement:a==null?void 0:a.createElementNS(G,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:Ee&&o&&r?r:0})].map(()=>{try{let w=new Worker(o);return w.onmessage=async b=>{var x,P,M,vt;let{url:y,result:k}=b.data;k?(P=(x=u.get(y))==null?void 0:x.resolve)==null||P.call(x,k):(vt=(M=u.get(y))==null?void 0:M.reject)==null||vt.call(M,new Error(`Error receiving message from worker: ${y}`))},w.onmessageerror=b=>{var k,x;let{url:y}=b.data;(x=(k=u.get(y))==null?void 0:k.reject)==null||x.call(k,new Error(`Error receiving message from worker: ${y}`))},w}catch(w){return l.log.warn("Failed to new Worker",w),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[je(a)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:u,drawImageCount:0,tasks:[],features:s,isEnable:w=>{var b,y;return w==="restoreScrollPosition"?typeof s=="boolean"?!1:(b=s[w])!=null?b:!1:typeof s=="boolean"?s:(y=s[w])!=null?y:!0},shadowRoots:[]});l.log.time("wait until load"),await Ke(e,{timeout:l.timeout,onWarn:l.log.warn}),l.log.timeEnd("wait until load");let{width:h,height:d}=Je(e,l);return l.width=h,l.height=d,l}function Ot(e){if(!e)return;let t=e.createElement("style"),n=t.ownerDocument.createTextNode(`
|
|
396
|
+
`:"",n=document.createElement("style");n.id="instruckt-global",n.textContent=t+he+pe,document.head.appendChild(n)}var A={annotate:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>',freeze:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg>',copy:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',check:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',clear:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>',minimize:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="7 13 12 18 17 13"/><line x1="12" y1="6" x2="12" y2="18"/></svg>',screenshot:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',logo:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>'},$=class{constructor(t,n,o){this.position=t;this.callbacks=n;this.fabBadge=null;this.annotateActive=!1;this.freezeActive=!1;this.minimized=!1;this.totalCount=0;this.dragging=!1;this.dragOffset={x:0,y:0};this.keys=o!=null?o:{},this.build(),this.setupDrag()}build(){var l,h,u,m,g;this.host=document.createElement("div"),this.host.setAttribute("data-instruckt","toolbar"),this.shadow=this.host.attachShadow({mode:"open"});let t=document.createElement("style");t.textContent=kt,this.shadow.appendChild(t),this.toolbarEl=document.createElement("div"),this.toolbarEl.className="toolbar";let n=this.keys;this.annotateBtn=this.makeBtn(A.annotate,`Annotate elements (${((l=n.annotate)!=null?l:"A").toUpperCase()})`,()=>{let p=!this.annotateActive;this.setAnnotateActive(p),this.callbacks.onToggleAnnotate(p)}),this.freezeBtn=this.makeBtn(A.freeze,`Freeze page (${((h=n.freeze)!=null?h:"F").toUpperCase()})`,()=>{let p=!this.freezeActive;this.setFreezeActive(p),this.callbacks.onFreezeAnimations(p)});let o=this.makeBtn(A.screenshot,`Screenshot region (${((u=n.screenshot)!=null?u:"C").toUpperCase()})`,()=>{this.callbacks.onScreenshot()});this.copyBtn=this.makeBtn(A.copy,"Copy annotations as markdown",()=>{this.callbacks.onCopy(),this.copyBtn.innerHTML=A.check,setTimeout(()=>{this.copyBtn.innerHTML=A.copy},1200)});let r=document.createElement("div");r.className="clear-wrap";let i=this.makeBtn(A.clear,`Clear this page (${((m=n.clearPage)!=null?m:"X").toUpperCase()})`,()=>{var p,f;(f=(p=this.callbacks).onClearPage)==null||f.call(p)});i.classList.add("danger-btn");let s=this.makeBtn('<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2"/><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/></svg>',"Delete all instructions.",()=>{var p,f;return(f=(p=this.callbacks).onClearAll)==null?void 0:f.call(p)});s.classList.add("danger-btn","clear-all-btn"),r.appendChild(i),r.appendChild(s);let a=this.makeBtn(A.minimize,"Minimize toolbar",()=>{this.setMinimized(!0)});a.classList.add("minimize-btn");let c=()=>{let p=document.createElement("div");return p.className="divider",p};this.toolbarEl.append(this.annotateBtn,o,c(),this.freezeBtn,c(),this.copyBtn,r,c(),a),this.shadow.appendChild(this.toolbarEl),this.fab=document.createElement("button"),this.fab.className="fab",this.fab.title="Open instruckt toolbar",this.fab.setAttribute("aria-label","Open instruckt toolbar"),this.fab.innerHTML=A.logo,this.fab.style.display="none",this.fab.addEventListener("click",p=>{p.stopPropagation(),this.setMinimized(!1)}),this.shadow.appendChild(this.fab),this.host.addEventListener("click",p=>p.stopPropagation()),this.host.addEventListener("mousedown",p=>p.stopPropagation()),this.host.addEventListener("pointerdown",p=>p.stopPropagation()),this.applyPosition(),((g=document.getElementById("instruckt-root"))!=null?g:document.body).appendChild(this.host)}makeBtn(t,n,o){let r=document.createElement("button");return r.className="btn",r.setAttribute("data-tooltip",n),r.setAttribute("aria-label",n),r.innerHTML=t,r.addEventListener("click",i=>{i.stopPropagation(),o()}),r}applyPosition(){let t="16px";Object.assign(this.host.style,{position:"fixed",zIndex:"2147483646",bottom:this.position.includes("bottom")?t:"auto",top:this.position.includes("top")?t:"auto",right:this.position.includes("right")?t:"auto",left:this.position.includes("left")?t:"auto"})}setupDrag(){this.shadow.addEventListener("mousedown",t=>{let n=t;if(n.target.closest(".btn")||n.target.closest(".fab"))return;this.dragging=!0;let o=this.host.getBoundingClientRect();this.dragOffset={x:n.clientX-o.left,y:n.clientY-o.top},n.preventDefault()}),document.addEventListener("mousemove",t=>{this.dragging&&Object.assign(this.host.style,{left:`${t.clientX-this.dragOffset.x}px`,top:`${t.clientY-this.dragOffset.y}px`,right:"auto",bottom:"auto"})}),document.addEventListener("mouseup",()=>{this.dragging=!1})}setMinimized(t){var n,o;this.minimized=t,this.toolbarEl.style.display=t?"none":"",this.fab.style.display=t?"":"none",this.updateFabBadge(),(o=(n=this.callbacks).onMinimize)==null||o.call(n,t)}updateFabBadge(){var t;this.totalCount>0&&this.minimized?(this.fabBadge||(this.fabBadge=document.createElement("span"),this.fabBadge.className="fab-badge",this.fab.appendChild(this.fabBadge)),this.fabBadge.textContent=this.totalCount>99?"99+":String(this.totalCount)):((t=this.fabBadge)==null||t.remove(),this.fabBadge=null)}isMinimized(){return this.minimized}minimize(){this.minimized=!0,this.toolbarEl.style.display="none",this.fab.style.display="",this.updateFabBadge()}setAnnotateActive(t){this.annotateActive=t,this.annotateBtn.classList.toggle("active",t),document.body.classList.toggle("ik-annotating",t)}setFreezeActive(t){this.freezeActive=t,this.freezeBtn.classList.toggle("active",t)}setMode(t){this.setAnnotateActive(t==="annotating")}setAnnotationCount(t){let n=this.annotateBtn.querySelector(".badge");t>0?(n||(n=document.createElement("span"),n.className="badge",this.annotateBtn.appendChild(n)),n.textContent=t>99?"99+":String(t)):n==null||n.remove()}setTotalCount(t){this.totalCount=t,this.updateFabBadge()}destroy(){this.host.remove(),document.body.classList.remove("ik-annotating")}};var F=class{constructor(){var n;this.el=document.createElement("div"),Object.assign(this.el.style,{position:"fixed",pointerEvents:"none",zIndex:"2147483644",border:"2px solid rgba(99,102,241,0.7)",background:"rgba(99,102,241,0.1)",borderRadius:"3px",transition:"all 0.06s ease",display:"none"}),this.el.setAttribute("data-instruckt","highlight"),((n=document.getElementById("instruckt-root"))!=null?n:document.body).appendChild(this.el)}show(t){let n=t.getBoundingClientRect();if(n.width===0&&n.height===0){this.hide();return}Object.assign(this.el.style,{display:"block",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`})}hide(){this.el.style.display="none"}destroy(){this.el.remove()}};function me(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}var Mt=112,Lt=72,zt=89,Rt=115,rt;function fe(){let e=new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let o=0;o<8;o++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return e}function ge(e){let t=-1;rt||(rt=fe());for(let n=0;n<e.length;n++)t=rt[(t^e[n])&255]^t>>>8;return t^-1}function ve(e){let t=e.length-1;for(let n=t;n>=4;n--)if(e[n-4]===9&&e[n-3]===Mt&&e[n-2]===Lt&&e[n-1]===zt&&e[n]===Rt)return n-3;return 0}function be(e,t,n=!1){let o=new Uint8Array(13);t*=39.3701,o[0]=Mt,o[1]=Lt,o[2]=zt,o[3]=Rt,o[4]=t>>>24,o[5]=t>>>16,o[6]=t>>>8,o[7]=t&255,o[8]=o[4],o[9]=o[5],o[10]=o[6],o[11]=o[7],o[12]=1;let r=ge(o),i=new Uint8Array(4);if(i[0]=r>>>24,i[1]=r>>>16,i[2]=r>>>8,i[3]=r&255,n){let s=ve(e);return e.set(o,s),e.set(i,s+13),e}else{let s=new Uint8Array(4);s[0]=0,s[1]=0,s[2]=0,s[3]=9;let a=new Uint8Array(54);return a.set(e,0),a.set(s,33),a.set(o,37),a.set(i,50),a}}var we="AAlwSFlz",ye="AAAJcEhZ",ke="AAAACXBI";function xe(e){let t=e.indexOf(we);return t===-1&&(t=e.indexOf(ye)),t===-1&&(t=e.indexOf(ke)),t}var Bt="[modern-screenshot]",C=typeof window!="undefined",Ee=C&&"Worker"in window,Se=C&&"atob"in window,Ae=C&&"btoa"in window,Pt,at=C?(Pt=window.navigator)==null?void 0:Pt.userAgent:"",It=at.includes("Chrome"),K=at.includes("AppleWebKit")&&!It,lt=at.includes("Firefox"),Ce=e=>e&&"__CONTEXT__"in e,Te=e=>e.constructor.name==="CSSFontFaceRule",Pe=e=>e.constructor.name==="CSSImportRule",Me=e=>e.constructor.name==="CSSLayerBlockRule",S=e=>e.nodeType===1,U=e=>typeof e.className=="object",$t=e=>e.tagName==="image",Le=e=>e.tagName==="use",N=e=>S(e)&&typeof e.style!="undefined"&&!U(e),ze=e=>e.nodeType===8,Re=e=>e.nodeType===3,B=e=>e.tagName==="IMG",X=e=>e.tagName==="VIDEO",Be=e=>e.tagName==="CANVAS",Ie=e=>e.tagName==="TEXTAREA",$e=e=>e.tagName==="INPUT",Fe=e=>e.tagName==="STYLE",Ne=e=>e.tagName==="SCRIPT",_e=e=>e.tagName==="SELECT",Oe=e=>e.tagName==="SLOT",Ue=e=>e.tagName==="IFRAME",De=(...e)=>console.warn(Bt,...e);function je(e){var n;let t=(n=e==null?void 0:e.createElement)==null?void 0:n.call(e,"canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}var it=e=>e.startsWith("data:");function Ft(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(C&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!C)return e;let n=Y().implementation.createHTMLDocument(),o=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(o),n.body.appendChild(r),t&&(o.href=t),r.href=e,r.href}function Y(e){var t;return(t=e&&S(e)?e==null?void 0:e.ownerDocument:e)!=null?t:window.document}var G="http://www.w3.org/2000/svg";function He(e,t,n){let o=Y(n).createElementNS(G,"svg");return o.setAttributeNS(null,"width",e.toString()),o.setAttributeNS(null,"height",t.toString()),o.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),o}function qe(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function Ve(e,t){return new Promise((n,o)=>{let r=new FileReader;r.onload=()=>n(r.result),r.onerror=()=>o(r.error),r.onabort=()=>o(new Error(`Failed read blob to ${t}`)),t==="dataUrl"?r.readAsDataURL(e):t==="arrayBuffer"&&r.readAsArrayBuffer(e)})}var We=e=>Ve(e,"dataUrl");function R(e,t){let n=Y(t).createElement("img");return n.decoding="sync",n.loading="eager",n.src=e,n}function _(e,t){return new Promise(n=>{let{timeout:o,ownerDocument:r,onError:i,onWarn:s}=t!=null?t:{},a=typeof e=="string"?R(e,Y(r)):e,c=null,d=null;function l(){n(a),c&&clearTimeout(c),d==null||d()}if(o&&(c=setTimeout(l,o)),X(a)){let h=a.currentSrc||a.src;if(!h)return a.poster?_(a.poster,t).then(n):l();if(a.readyState>=2)return l();let u=l,m=g=>{s==null||s("Failed video load",h,g),i==null||i(g),l()};d=()=>{a.removeEventListener("loadeddata",u),a.removeEventListener("error",m)},a.addEventListener("loadeddata",u,{once:!0}),a.addEventListener("error",m,{once:!0})}else{let h=$t(a)?a.href.baseVal:a.currentSrc||a.src;if(!h)return l();let u=async()=>{if(B(a)&&"decode"in a)try{await a.decode()}catch(g){s==null||s("Failed to decode image, trying to render anyway",a.dataset.originalSrc||h,g)}l()},m=g=>{s==null||s("Failed image load",a.dataset.originalSrc||h,g),l()};if(B(a)&&a.complete)return u();d=()=>{a.removeEventListener("load",u),a.removeEventListener("error",m)},a.addEventListener("load",u,{once:!0}),a.addEventListener("error",m,{once:!0})}})}async function Ke(e,t){N(e)&&(B(e)||X(e)?await _(e,t):await Promise.all(["img","video"].flatMap(n=>Array.from(e.querySelectorAll(n)).map(o=>_(o,t)))))}var Nt=(function(){let t=0,n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${n()}${t}`)})();function _t(e){return e==null?void 0:e.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var xt=0;function Xe(e){let t=`${Bt}[#${xt}]`;return xt++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...n)=>e&&De(...n)}}function Ye(e){return{cache:e?"no-cache":"force-cache"}}async function J(e,t){return Ce(e)?e:Ge(e,L(E({},t),{autoDestruct:!0}))}async function Ge(e,t){var m,g,p,f,v;let{scale:n=1,workerUrl:o,workerNumber:r=1}=t||{},i=!!(t!=null&&t.debug),s=(m=t==null?void 0:t.features)!=null?m:!0,a=(g=e.ownerDocument)!=null?g:C?window.document:void 0,c=(f=(p=e.ownerDocument)==null?void 0:p.defaultView)!=null?f:C?window:void 0,d=new Map,l=L(E({width:0,height:0,quality:1,type:"image/png",scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:i,fetch:E({requestInit:Ye((v=t==null?void 0:t.fetch)==null?void 0:v.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1},t==null?void 0:t.fetch),fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:r,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1},t),{__CONTEXT__:!0,log:Xe(i),node:e,ownerDocument:a,ownerWindow:c,dpi:n===1?null:96*n,svgStyleElement:Ot(a),svgDefsElement:a==null?void 0:a.createElementNS(G,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:Ee&&o&&r?r:0})].map(()=>{try{let w=new Worker(o);return w.onmessage=async b=>{var x,P,M,vt;let{url:y,result:k}=b.data;k?(P=(x=d.get(y))==null?void 0:x.resolve)==null||P.call(x,k):(vt=(M=d.get(y))==null?void 0:M.reject)==null||vt.call(M,new Error(`Error receiving message from worker: ${y}`))},w.onmessageerror=b=>{var k,x;let{url:y}=b.data;(x=(k=d.get(y))==null?void 0:k.reject)==null||x.call(k,new Error(`Error receiving message from worker: ${y}`))},w}catch(w){return l.log.warn("Failed to new Worker",w),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[je(a)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:d,drawImageCount:0,tasks:[],features:s,isEnable:w=>{var b,y;return w==="restoreScrollPosition"?typeof s=="boolean"?!1:(b=s[w])!=null?b:!1:typeof s=="boolean"?s:(y=s[w])!=null?y:!0},shadowRoots:[]});l.log.time("wait until load"),await Ke(e,{timeout:l.timeout,onWarn:l.log.warn}),l.log.timeEnd("wait until load");let{width:h,height:u}=Je(e,l);return l.width=h,l.height=u,l}function Ot(e){if(!e)return;let t=e.createElement("style"),n=t.ownerDocument.createTextNode(`
|
|
397
397
|
.______background-clip--text {
|
|
398
398
|
background-clip: text;
|
|
399
399
|
-webkit-background-clip: text;
|
|
400
400
|
}
|
|
401
|
-
`);return t.appendChild(n),t}function Je(e,t){let{width:n,height:o}=t;if(S(e)&&(!n||!o)){let r=e.getBoundingClientRect();n=n||r.width||Number(e.getAttribute("width"))||0,o=o||r.height||Number(e.getAttribute("height"))||0}return{width:n,height:o}}async function Ze(e,t){let{log:n,timeout:o,drawImageCount:r,drawImageInterval:i}=t;n.time("image to canvas");let s=await _(e,{timeout:o,onWarn:t.log.warn}),{canvas:a,context2d:c}=Qe(e.ownerDocument,t),
|
|
402
|
-
`),w=a.get(v);w||(w=[],a.set(v,w)),w.push(`.${m[0]}${l}`)}dn.forEach(
|
|
403
|
-
`))}else{let c=Array.from(n.styleSheets).filter(l=>{try{return"cssRules"in l&&!!l.cssRules.length}catch(h){return t.log.warn(`Error while reading CSS rules from ${l.href}`,h),!1}});await Promise.all(c.flatMap(l=>Array.from(l.cssRules).map(async(h,
|
|
401
|
+
`);return t.appendChild(n),t}function Je(e,t){let{width:n,height:o}=t;if(S(e)&&(!n||!o)){let r=e.getBoundingClientRect();n=n||r.width||Number(e.getAttribute("width"))||0,o=o||r.height||Number(e.getAttribute("height"))||0}return{width:n,height:o}}async function Ze(e,t){let{log:n,timeout:o,drawImageCount:r,drawImageInterval:i}=t;n.time("image to canvas");let s=await _(e,{timeout:o,onWarn:t.log.warn}),{canvas:a,context2d:c}=Qe(e.ownerDocument,t),d=()=>{try{c==null||c.drawImage(s,0,0,a.width,a.height)}catch(l){t.log.warn("Failed to drawImage",l)}};if(d(),t.isEnable("fixSvgXmlDecode"))for(let l=0;l<r;l++)await new Promise(h=>{setTimeout(()=>{c==null||c.clearRect(0,0,a.width,a.height),d(),h()},l+i)});return t.drawImageCount=0,n.timeEnd("image to canvas"),a}function Qe(e,t){let{width:n,height:o,scale:r,backgroundColor:i,maximumCanvasSize:s}=t,a=e.createElement("canvas");a.width=Math.floor(n*r),a.height=Math.floor(o*r),a.style.width=`${n}px`,a.style.height=`${o}px`,s&&(a.width>s||a.height>s)&&(a.width>s&&a.height>s?a.width>a.height?(a.height*=s/a.width,a.width=s):(a.width*=s/a.height,a.height=s):a.width>s?(a.height*=s/a.width,a.width=s):(a.width*=s/a.height,a.height=s));let c=a.getContext("2d");return c&&i&&(c.fillStyle=i,c.fillRect(0,0,a.width,a.height)),{canvas:a,context2d:c}}function Ut(e,t){if(e.ownerDocument)try{let i=e.toDataURL();if(i!=="data:,")return R(i,e.ownerDocument)}catch(i){t.log.warn("Failed to clone canvas",i)}let n=e.cloneNode(!1),o=e.getContext("2d"),r=n.getContext("2d");try{return o&&r&&r.putImageData(o.getImageData(0,0,e.width,e.height),0,0),n}catch(i){t.log.warn("Failed to clone canvas",i)}return n}function tn(e,t){var n;try{if((n=e==null?void 0:e.contentDocument)!=null&&n.body)return ct(e.contentDocument.body,t)}catch(o){t.log.warn("Failed to clone iframe",o)}return e.cloneNode(!1)}function en(e){let t=e.cloneNode(!1);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function nn(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return R(e.poster,e.ownerDocument);let n=e.cloneNode(!1);n.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(n.src=e.currentSrc);let o=n.ownerDocument;if(o){let r=!0;if(await _(n,{onError:()=>r=!1,onWarn:t.log.warn}),!r)return e.poster?R(e.poster,e.ownerDocument):n;n.currentTime=e.currentTime,await new Promise(s=>{n.addEventListener("seeked",s,{once:!0})});let i=o.createElement("canvas");i.width=e.offsetWidth,i.height=e.offsetHeight;try{let s=i.getContext("2d");s&&s.drawImage(n,0,0,i.width,i.height)}catch(s){return t.log.warn("Failed to clone video",s),e.poster?R(e.poster,e.ownerDocument):n}return Ut(i,t)}return n}function on(e,t){return Be(e)?Ut(e,t):Ue(e)?tn(e,t):B(e)?en(e):X(e)?nn(e,t):e.cloneNode(!1)}function rn(e){let t=e.sandbox;if(!t){let{ownerDocument:n}=e;try{n&&(t=n.createElement("iframe"),t.id=`__SANDBOX__${Nt()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",n.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(o){e.log.warn("Failed to getSandBox",o)}}return t}var sn=["width","height","-webkit-text-fill-color"],an=["stroke","fill"];function Dt(e,t,n){let{defaultComputedStyles:o}=n,r=e.nodeName.toLowerCase(),i=U(e)&&r!=="svg",s=i?an.map(p=>[p,e.getAttribute(p)]).filter(([,p])=>p!==null):[],a=[i&&"svg",r,s.map((p,f)=>`${p}=${f}`).join(","),t].filter(Boolean).join(":");if(o.has(a))return o.get(a);let c=rn(n),d=c==null?void 0:c.contentWindow;if(!d)return new Map;let l=d==null?void 0:d.document,h,u;i?(h=l.createElementNS(G,"svg"),u=h.ownerDocument.createElementNS(h.namespaceURI,r),s.forEach(([p,f])=>{u.setAttributeNS(null,p,f)}),h.appendChild(u)):h=u=l.createElement(r),u.textContent=" ",l.body.appendChild(h);let m=d.getComputedStyle(u,t),g=new Map;for(let p=m.length,f=0;f<p;f++){let v=m.item(f);sn.includes(v)||g.set(v,m.getPropertyValue(v))}return l.body.removeChild(h),o.set(a,g),g}function jt(e,t,n){var a;let o=new Map,r=[],i=new Map;if(n)for(let c of n)s(c);else for(let c=e.length,d=0;d<c;d++){let l=e.item(d);s(l)}for(let c=r.length,d=0;d<c;d++)(a=i.get(r[d]))==null||a.forEach((l,h)=>o.set(h,l));function s(c){let d=e.getPropertyValue(c),l=e.getPropertyPriority(c),h=c.lastIndexOf("-"),u=h>-1?c.substring(0,h):void 0;if(u){let m=i.get(u);m||(m=new Map,i.set(u,m)),m.set(c,[d,l])}t.get(c)===d&&!l||(u?r.push(u):o.set(c,[d,l]))}return o}function ln(e,t,n,o){var h,u,m,g;let{ownerWindow:r,includeStyleProperties:i,currentParentNodeStyle:s}=o,a=t.style,c=r.getComputedStyle(e),d=Dt(e,null,o);s==null||s.forEach((p,f)=>{d.delete(f)});let l=jt(c,d,i);l.delete("transition-property"),l.delete("all"),l.delete("d"),l.delete("content"),n&&(l.delete("margin-top"),l.delete("margin-right"),l.delete("margin-bottom"),l.delete("margin-left"),l.delete("margin-block-start"),l.delete("margin-block-end"),l.delete("margin-inline-start"),l.delete("margin-inline-end"),l.set("box-sizing",["border-box",""])),((h=l.get("background-clip"))==null?void 0:h[0])==="text"&&t.classList.add("______background-clip--text"),It&&(l.has("font-kerning")||l.set("font-kerning",["normal",""]),(((u=l.get("overflow-x"))==null?void 0:u[0])==="hidden"||((m=l.get("overflow-y"))==null?void 0:m[0])==="hidden")&&((g=l.get("text-overflow"))==null?void 0:g[0])==="ellipsis"&&e.scrollWidth===e.clientWidth&&l.set("text-overflow",["clip",""]));for(let p=a.length,f=0;f<p;f++)a.removeProperty(a.item(f));return l.forEach(([p,f],v)=>{a.setProperty(v,p,f)}),l}function cn(e,t){(Ie(e)||$e(e)||_e(e))&&t.setAttribute("value",e.value)}var dn=["::before","::after"],un=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function hn(e,t,n,o,r){let{ownerWindow:i,svgStyleElement:s,svgStyles:a,currentNodeStyle:c}=o;if(!s||!i)return;function d(l){var b;let h=i.getComputedStyle(e,l),u=h.getPropertyValue("content");if(!u||u==="none")return;r==null||r(u),u=u.replace(/(')|(")|(counter\(.+\))/g,"");let m=[Nt()],g=Dt(e,l,o);c==null||c.forEach((y,k)=>{g.delete(k)});let p=jt(h,g,o.includeStyleProperties);p.delete("content"),p.delete("-webkit-locale"),((b=p.get("background-clip"))==null?void 0:b[0])==="text"&&t.classList.add("______background-clip--text");let f=[`content: '${u}';`];if(p.forEach(([y,k],x)=>{f.push(`${x}: ${y}${k?" !important":""};`)}),f.length===1)return;try{t.className=[t.className,...m].join(" ")}catch(y){o.log.warn("Failed to copyPseudoClass",y);return}let v=f.join(`
|
|
402
|
+
`),w=a.get(v);w||(w=[],a.set(v,w)),w.push(`.${m[0]}${l}`)}dn.forEach(d),n&&un.forEach(d)}var Et=new Set(["symbol"]);async function St(e,t,n,o,r){if(S(n)&&(Fe(n)||Ne(n))||o.filter&&!o.filter(n))return;Et.has(t.nodeName)||Et.has(n.nodeName)?o.currentParentNodeStyle=void 0:o.currentParentNodeStyle=o.currentNodeStyle;let i=await ct(n,o,!1,r);o.isEnable("restoreScrollPosition")&&pn(e,i),t.appendChild(i)}async function At(e,t,n,o){var i;let r=e.firstChild;S(e)&&e.shadowRoot&&(r=(i=e.shadowRoot)==null?void 0:i.firstChild,n.shadowRoots.push(e.shadowRoot));for(let s=r;s;s=s.nextSibling)if(!ze(s))if(S(s)&&Oe(s)&&typeof s.assignedNodes=="function"){let a=s.assignedNodes();for(let c=0;c<a.length;c++)await St(e,t,a[c],n,o)}else await St(e,t,s,n,o)}function pn(e,t){if(!N(e)||!N(t))return;let{scrollTop:n,scrollLeft:o}=e;if(!n&&!o)return;let{transform:r}=t.style,i=new DOMMatrix(r),{a:s,b:a,c,d}=i;i.a=1,i.b=0,i.c=0,i.d=1,i.translateSelf(-o,-n),i.a=s,i.b=a,i.c=c,i.d=d,t.style.transform=i.toString()}function mn(e,t){let{backgroundColor:n,width:o,height:r,style:i}=t,s=e.style;if(n&&s.setProperty("background-color",n,"important"),o&&s.setProperty("width",`${o}px`,"important"),r&&s.setProperty("height",`${r}px`,"important"),i)for(let a in i)s[a]=i[a]}var fn=/^[\w-:]+$/;async function ct(e,t,n=!1,o){var d,l,h,u;let{ownerDocument:r,ownerWindow:i,fontFamilies:s,onCloneEachNode:a}=t;if(r&&Re(e))return o&&/\S/.test(e.data)&&o(e.data),r.createTextNode(e.data);if(r&&i&&S(e)&&(N(e)||U(e))){let m=await on(e,t);if(t.isEnable("removeAbnormalAttributes")){let b=m.getAttributeNames();for(let y=b.length,k=0;k<y;k++){let x=b[k];fn.test(x)||m.removeAttribute(x)}}let g=t.currentNodeStyle=ln(e,m,n,t);n&&mn(m,t);let p=!1;if(t.isEnable("copyScrollbar")){let b=[(d=g.get("overflow-x"))==null?void 0:d[0],(l=g.get("overflow-y"))==null?void 0:l[0]];p=b.includes("scroll")||(b.includes("auto")||b.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}let f=(h=g.get("text-transform"))==null?void 0:h[0],v=_t((u=g.get("font-family"))==null?void 0:u[0]),w=v?b=>{f==="uppercase"?b=b.toUpperCase():f==="lowercase"?b=b.toLowerCase():f==="capitalize"&&(b=b[0].toUpperCase()+b.substring(1)),v.forEach(y=>{let k=s.get(y);k||s.set(y,k=new Set),b.split("").forEach(x=>k.add(x))})}:void 0;return hn(e,m,p,t,w),cn(e,m),X(e)||await At(e,m,t,w),await(a==null?void 0:a(m)),m}let c=e.cloneNode(!1);return await At(e,c,t),await(a==null?void 0:a(c)),c}function gn(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function vn(e){let a=e,{url:t,timeout:n,responseType:o}=a,r=yt(a,["url","timeout","responseType"]),i=new AbortController,s=n?setTimeout(()=>i.abort(),n):void 0;return fetch(t,E({signal:i.signal},r)).then(c=>{if(!c.ok)throw new Error("Failed fetch, not 2xx response",{cause:c});switch(o){case"arrayBuffer":return c.arrayBuffer();case"dataUrl":return c.blob().then(We);default:return c.text()}}).finally(()=>clearTimeout(s))}function O(e,t){let{url:n,requestType:o="text",responseType:r="text",imageDom:i}=t,s=n,{timeout:a,acceptOfImage:c,requests:d,fetchFn:l,fetch:{requestInit:h,bypassingCache:u,placeholderImage:m},font:g,workers:p,fontFamilies:f}=e;o==="image"&&(K||lt)&&e.drawImageCount++;let v=d.get(n);if(!v){u&&u instanceof RegExp&&u.test(s)&&(s+=(/\?/.test(s)?"&":"?")+new Date().getTime());let w=o.startsWith("font")&&g&&g.minify,b=new Set;w&&o.split(";")[1].split(",").forEach(P=>{f.has(P)&&f.get(P).forEach(M=>b.add(M))});let y=w&&b.size,k=E({url:s,timeout:a,responseType:y?"arrayBuffer":r,headers:o==="image"?{accept:c}:void 0},h);v={type:o,resolve:void 0,reject:void 0,response:null},v.response=(async()=>{if(l&&o==="image"){let x=await l(n);if(x)return x}return!K&&n.startsWith("http")&&p.length?new Promise((x,P)=>{p[d.size&p.length-1].postMessage(E({rawUrl:n},k)),v.resolve=x,v.reject=P}):vn(k)})().catch(x=>{if(d.delete(n),o==="image"&&m)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",s),typeof m=="string"?m:m(i);throw x}),d.set(n,v)}return v.response}async function Ht(e,t,n,o){if(!qt(e))return e;for(let[r,i]of bn(e,t))try{let s=await O(n,{url:i,requestType:o?"image":"text",responseType:"dataUrl"});e=e.replace(wn(r),`$1${s}$3`)}catch(s){n.log.warn("Failed to fetch css data url",r,s)}return e}function qt(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}var Vt=/url\((['"]?)([^'"]+?)\1\)/g;function bn(e,t){let n=[];return e.replace(Vt,(o,r,i)=>(n.push([i,Ft(i,t)]),o)),n.filter(([o])=>!it(o))}function wn(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}var yn=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function kn(e,t){return yn.map(n=>{let o=e.getPropertyValue(n);return!o||o==="none"?null:((K||lt)&&t.drawImageCount++,Ht(o,null,t,!0).then(r=>{!r||o===r||e.setProperty(n,r,e.getPropertyPriority(n))}))}).filter(Boolean)}function xn(e,t){if(B(e)){let n=e.currentSrc||e.src;if(!it(n))return[O(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(o=>{o&&(e.srcset="",e.dataset.originalSrc=n,e.src=o||"")})];(K||lt)&&t.drawImageCount++}else if(U(e)&&!it(e.href.baseVal)){let n=e.href.baseVal;return[O(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(o=>{o&&(e.dataset.originalSrc=n,e.href.baseVal=o||"")})]}return[]}function En(e,t){var a;let{ownerDocument:n,svgDefsElement:o}=t,r=(a=e.getAttribute("href"))!=null?a:e.getAttribute("xlink:href");if(!r)return[];let[i,s]=r.split("#");if(s){let c=`#${s}`,d=t.shadowRoots.reduce((l,h)=>l!=null?l:h.querySelector(`svg ${c}`),n==null?void 0:n.querySelector(`svg ${c}`));if(i&&e.setAttribute("href",c),o!=null&&o.querySelector(c))return[];if(d)return o==null||o.appendChild(d.cloneNode(!0)),[];if(i)return[O(t,{url:i,responseType:"text"}).then(l=>{o==null||o.insertAdjacentHTML("beforeend",l)})]}return[]}function Wt(e,t){let{tasks:n}=t;S(e)&&((B(e)||$t(e))&&n.push(...xn(e,t)),Le(e)&&n.push(...En(e,t))),N(e)&&n.push(...kn(e.style,t)),e.childNodes.forEach(o=>{Wt(o,t)})}async function Sn(e,t){let{ownerDocument:n,svgStyleElement:o,fontFamilies:r,fontCssTexts:i,tasks:s,font:a}=t;if(!(!n||!o||!r.size))if(a&&a.cssText){let c=Tt(a.cssText,t);o.appendChild(n.createTextNode(`${c}
|
|
403
|
+
`))}else{let c=Array.from(n.styleSheets).filter(l=>{try{return"cssRules"in l&&!!l.cssRules.length}catch(h){return t.log.warn(`Error while reading CSS rules from ${l.href}`,h),!1}});await Promise.all(c.flatMap(l=>Array.from(l.cssRules).map(async(h,u)=>{if(Pe(h)){let m=u+1,g=h.href,p="";try{p=await O(t,{url:g,requestType:"text",responseType:"text"})}catch(v){t.log.warn(`Error fetch remote css import from ${g}`,v)}let f=p.replace(Vt,(v,w,b)=>v.replace(b,Ft(b,g)));for(let v of Cn(f))try{l.insertRule(v,v.startsWith("@import")?m+=1:l.cssRules.length)}catch(w){t.log.warn("Error inserting rule from remote css import",{rule:v,error:w})}}})));let d=[];c.forEach(l=>{st(l.cssRules,d)}),d.filter(l=>{var h;return Te(l)&&qt(l.style.getPropertyValue("src"))&&((h=_t(l.style.getPropertyValue("font-family")))==null?void 0:h.some(u=>r.has(u)))}).forEach(l=>{let h=l,u=i.get(h.cssText);u?o.appendChild(n.createTextNode(`${u}
|
|
404
404
|
`)):s.push(Ht(h.cssText,h.parentStyleSheet?h.parentStyleSheet.href:null,t).then(m=>{m=Tt(m,t),i.set(h.cssText,m),o.appendChild(n.createTextNode(`${m}
|
|
405
|
-
`))}))})}}var An=/(\/\*[\s\S]*?\*\/)/g,Ct=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function Cn(e){if(e==null)return[];let t=[],n=e.replace(An,"");for(;;){let i=Ct.exec(n);if(!i)break;t.push(i[0])}n=n.replace(Ct,"");let o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,r=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let i=o.exec(n);if(i)r.lastIndex=o.lastIndex;else if(i=r.exec(n),i)o.lastIndex=r.lastIndex;else break;t.push(i[0])}return t}var Tn=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Pn=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Tt(e,t){let{font:n}=t,o=n?n==null?void 0:n.preferredFormat:void 0;return o?e.replace(Pn,r=>{for(;;){let[i,,s]=Tn.exec(r)||[];if(!s)return"";if(s===o)return`src: ${i};`}}):e}function st(e,t=[]){for(let n of Array.from(e))Me(n)?t.push(...st(n.cssRules)):"cssRules"in n?st(n.cssRules,t):t.push(n);return t}async function Mn(e,t){let n=await J(e,t);if(S(n.node)&&U(n.node))return n.node;let{ownerDocument:o,log:r,tasks:i,svgStyleElement:s,svgDefsElement:a,svgStyles:c,font:
|
|
405
|
+
`))}))})}}var An=/(\/\*[\s\S]*?\*\/)/g,Ct=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function Cn(e){if(e==null)return[];let t=[],n=e.replace(An,"");for(;;){let i=Ct.exec(n);if(!i)break;t.push(i[0])}n=n.replace(Ct,"");let o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,r=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let i=o.exec(n);if(i)r.lastIndex=o.lastIndex;else if(i=r.exec(n),i)o.lastIndex=r.lastIndex;else break;t.push(i[0])}return t}var Tn=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Pn=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Tt(e,t){let{font:n}=t,o=n?n==null?void 0:n.preferredFormat:void 0;return o?e.replace(Pn,r=>{for(;;){let[i,,s]=Tn.exec(r)||[];if(!s)return"";if(s===o)return`src: ${i};`}}):e}function st(e,t=[]){for(let n of Array.from(e))Me(n)?t.push(...st(n.cssRules)):"cssRules"in n?st(n.cssRules,t):t.push(n);return t}async function Mn(e,t){let n=await J(e,t);if(S(n.node)&&U(n.node))return n.node;let{ownerDocument:o,log:r,tasks:i,svgStyleElement:s,svgDefsElement:a,svgStyles:c,font:d,progress:l,autoDestruct:h,onCloneNode:u,onEmbedNode:m,onCreateForeignObjectSvg:g}=n;r.time("clone node");let p=await ct(n.node,n,!0);if(s&&o){let y="";c.forEach((k,x)=>{y+=`${k.join(`,
|
|
406
406
|
`)} {
|
|
407
407
|
${x}
|
|
408
408
|
}
|
|
409
|
-
`}),s.appendChild(o.createTextNode(y))}r.timeEnd("clone node"),await(
|
|
409
|
+
`}),s.appendChild(o.createTextNode(y))}r.timeEnd("clone node"),await(u==null?void 0:u(p)),d!==!1&&S(p)&&(r.time("embed web font"),await Sn(p,n),r.timeEnd("embed web font")),r.time("embed node"),Wt(p,n);let f=i.length,v=0,w=async()=>{for(;;){let y=i.pop();if(!y)break;try{await y}catch(k){n.log.warn("Failed to run task",k)}l==null||l(++v,f)}};l==null||l(v,f),await Promise.all([...Array.from({length:4})].map(w)),r.timeEnd("embed node"),await(m==null?void 0:m(p));let b=Ln(p,n);return a&&b.insertBefore(a,b.children[0]),s&&b.insertBefore(s,b.children[0]),h&&gn(n),await(g==null?void 0:g(b)),b}function Ln(e,t){let{width:n,height:o}=t,r=He(n,o,e.ownerDocument),i=r.ownerDocument.createElementNS(r.namespaceURI,"foreignObject");return i.setAttributeNS(null,"x","0%"),i.setAttributeNS(null,"y","0%"),i.setAttributeNS(null,"width","100%"),i.setAttributeNS(null,"height","100%"),i.append(e),r.appendChild(i),r}async function zn(e,t){var s;let n=await J(e,t),o=await Mn(n),r=qe(o,n.isEnable("removeControlCharacter"));n.autoDestruct||(n.svgStyleElement=Ot(n.ownerDocument),n.svgDefsElement=(s=n.ownerDocument)==null?void 0:s.createElementNS(G,"defs"),n.svgStyles.clear());let i=R(r,o.ownerDocument);return await Ze(i,n)}async function Rn(e,t){let n=await J(e,t),{log:o,quality:r,type:i,dpi:s}=n,a=await zn(n);o.time("canvas to data url");let c=a.toDataURL(i,r);if(["image/png","image/jpeg"].includes(i)&&s&&Se&&Ae){let[d,l]=c.split(","),h=0,u=!1;if(i==="image/png"){let b=xe(l);b>=0?(h=Math.ceil((b+28)/3)*4,u=!0):h=33/3*4}else i==="image/jpeg"&&(h=18/3*4);let m=l.substring(0,h),g=l.substring(h),p=window.atob(m),f=new Uint8Array(p.length);for(let b=0;b<f.length;b++)f[b]=p.charCodeAt(b);let v=i==="image/png"?be(f,s,u):me(f,s),w=window.btoa(String.fromCharCode(...v));c=[d,",",w,g].join("")}return o.timeEnd("canvas to data url"),c}async function dt(e,t){return Rn(await J(e,L(E({},t),{type:"image/png"})))}function Kt(e){var t;return!((t=e.getAttribute)!=null&&t.call(e,"data-instruckt"))}var z=null;async function Xt(){return z&&z.active||(z=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},preferCurrentTab:!0}),z.getVideoTracks()[0].addEventListener("ended",()=>{z=null})),z}async function Bn(e){let t=document.createElement("video");t.srcObject=e,t.muted=!0,await t.play(),await new Promise(o=>requestAnimationFrame(()=>requestAnimationFrame(o)));let n=await createImageBitmap(t);return t.pause(),t.srcObject=null,n}function Yt(e,t){return Bn(e).then(n=>{let o=window.devicePixelRatio||1,r=document.createElement("canvas");return r.width=t.width*o,r.height=t.height*o,r.getContext("2d").drawImage(n,t.x*o,t.y*o,t.width*o,t.height*o,0,0,r.width,r.height),n.close(),r.toDataURL("image/png")})}async function Gt(e){try{let t=await dt(e,{scale:2,filter:Kt});if(t)return t}catch(t){}try{let t=await Xt();return await Yt(t,e.getBoundingClientRect())}catch(t){return console.warn("[instruckt] captureElement failed:",t),null}}async function Jt(e){try{let t=await dt(document.body,{scale:2,filter:Kt});if(t)return await In(t,e)}catch(t){}try{let t=await Xt();return await Yt(t,e)}catch(t){return console.warn("[instruckt] captureRegion failed:",t),null}}function In(e,t){return new Promise((n,o)=>{let r=new Image;r.onload=()=>{let s=document.createElement("canvas");s.width=t.width*2,s.height=t.height*2,s.getContext("2d").drawImage(r,t.x*2,t.y*2,t.width*2,t.height*2,0,0,t.width*2,t.height*2),n(s.toDataURL("image/png"))},r.onerror=o,r.src=e})}function Zt(){return new Promise(e=>{let t=document.createElement("div");Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",cursor:"crosshair",background:"rgba(0,0,0,0.1)"}),t.setAttribute("data-instruckt","region-select");let n=document.createElement("div");Object.assign(n.style,{position:"fixed",border:"2px dashed #6366f1",background:"rgba(99,102,241,0.08)",borderRadius:"4px",display:"none",pointerEvents:"none"}),t.appendChild(n);let o=0,r=0,i=!1,s=u=>{o=u.clientX,r=u.clientY,i=!0,n.style.display="block",c(u)},a=u=>{i&&c(u)},c=u=>{let m=Math.min(o,u.clientX),g=Math.min(r,u.clientY),p=Math.abs(u.clientX-o),f=Math.abs(u.clientY-r);Object.assign(n.style,{left:`${m}px`,top:`${g}px`,width:`${p}px`,height:`${f}px`})},d=u=>{if(!i)return;i=!1;let m=Math.min(o,u.clientX),g=Math.min(r,u.clientY),p=Math.abs(u.clientX-o),f=Math.abs(u.clientY-r);h(),p<10||f<10?e(null):e(new DOMRect(m,g,p,f))},l=u=>{u.key==="Escape"&&(h(),e(null))},h=()=>{t.remove(),document.removeEventListener("keydown",l,!0)};t.addEventListener("mousedown",s),t.addEventListener("mousemove",a),t.addEventListener("mouseup",d),document.addEventListener("keydown",l,!0),document.body.appendChild(t)})}function $n(e,t){return e?e.startsWith("data:")?e:`${t!=null?t:"/instruckt"}/${e}`:null}function T(e){return String(e!=null?e:"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var Z=class{constructor(){this.host=null;this.shadow=null;this.boundOutside=t=>{this.host&&!this.host.contains(t.target)&&this.destroy()}}showNew(t,n){var g,p;this.destroy(),this.host=document.createElement("div"),this.host.setAttribute("data-instruckt","popup"),this.stopHostPropagation(this.host),this.shadow=this.host.attachShadow({mode:"open"});let o=document.createElement("style");o.textContent=nt,this.shadow.appendChild(o);let r=document.createElement("div");r.className="popup";let i=t.framework?`<div class="fw-badge">${T(t.framework.component)}</div>`:"",s=t.selectedText?`<div class="selected-text">"${T(t.selectedText.slice(0,80))}"</div>`:"",a=!!t.screenshot;r.innerHTML=`
|
|
410
410
|
<div class="header">
|
|
411
411
|
<span class="element-tag" title="${T(t.elementPath)}">${T(t.elementLabel)}</span>
|
|
412
412
|
<button class="close-btn" title="Cancel (Esc)">\u2715</button>
|
|
@@ -418,18 +418,18 @@ textarea::placeholder { color:var(--ik-muted); }
|
|
|
418
418
|
<button class="btn-secondary" data-action="cancel">Cancel</button>
|
|
419
419
|
<button class="btn-primary" data-action="submit" ${a?"":"disabled"}>Add note</button>
|
|
420
420
|
</div>
|
|
421
|
-
`;let c=(g=t.screenshot)!=null?g:null,
|
|
421
|
+
`;let c=(g=t.screenshot)!=null?g:null,d=r.querySelector("textarea"),l=r.querySelector('[data-action="submit"]'),h=r.querySelector(".screenshot-slot"),u=()=>{l.disabled=!c&&d.value.trim().length===0},m=()=>{let f=h.querySelector('[data-action="capture"]');f==null||f.addEventListener("click",async()=>{f.textContent="Capturing...";let w=await Gt(t.element);w?(c=w,h.innerHTML=`<div class="screenshot-preview"><img src="${w}" alt="Screenshot" /><button class="screenshot-remove" title="Remove screenshot">\u2715</button></div>`,d.placeholder="Add a note (optional)",m(),u()):(f.textContent="Capture failed",setTimeout(()=>{f.parentElement&&(f.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg> Capture screenshot')},1500))});let v=h.querySelector(".screenshot-remove");v==null||v.addEventListener("click",()=>{c=null,h.innerHTML='<button class="btn-capture" data-action="capture"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg> Capture screenshot</button>',d.placeholder="What needs to change here?",m(),u()})};m(),d.addEventListener("input",u),d.addEventListener("keydown",f=>{f.stopPropagation(),f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),l.disabled||l.click()),f.key==="Escape"&&(n.onCancel(),this.destroy())}),r.querySelector('[data-action="cancel"]').addEventListener("click",()=>{n.onCancel(),this.destroy()}),r.querySelector(".close-btn").addEventListener("click",()=>{n.onCancel(),this.destroy()}),l.addEventListener("click",()=>{let f=d.value.trim();!f&&!c||(n.onSubmit({comment:f||"(screenshot)",screenshot:c!=null?c:void 0}),this.destroy())}),this.shadow.appendChild(r),((p=document.getElementById("instruckt-root"))!=null?p:document.body).appendChild(this.host),this.positionHost(t.x,t.y),this.setupOutsideClick(),d.focus()}showEdit(t,n,o){var f;this.destroy(),this.host=document.createElement("div"),this.host.setAttribute("data-instruckt","popup"),this.stopHostPropagation(this.host),this.shadow=this.host.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=nt,this.shadow.appendChild(r);let i=document.createElement("div");i.className="popup";let s=t.framework?`<div class="fw-badge">${T(t.framework.component)}</div>`:"",a=$n(t.screenshot,o),c=a?`<div class="screenshot-preview screenshot-slot"><img src="${a}" alt="Screenshot" /><button class="screenshot-remove" title="Remove screenshot">\u2715</button></div>`:"",d=t.comment==="(screenshot)"?"":t.comment;i.innerHTML=`
|
|
422
422
|
<div class="header">
|
|
423
423
|
<span class="element-tag" title="${T(t.elementPath)}">${T(t.element)}</span>
|
|
424
424
|
<button class="close-btn">\u2715</button>
|
|
425
425
|
</div>
|
|
426
426
|
${s}${c}
|
|
427
|
-
<textarea rows="3">${T(
|
|
427
|
+
<textarea rows="3">${T(d)}</textarea>
|
|
428
428
|
<div class="actions">
|
|
429
429
|
<button class="btn-danger" data-action="delete">Remove</button>
|
|
430
430
|
<button class="btn-primary" data-action="save">Save</button>
|
|
431
431
|
</div>
|
|
432
|
-
`,i.querySelector(".close-btn").addEventListener("click",()=>this.destroy());let l=i.querySelector(".screenshot-remove");l==null||l.addEventListener("click",()=>{n.onSave(t,t.comment);let v=i.querySelector(".screenshot-slot");v&&v.remove()});let h=i.querySelector("textarea"),d=i.querySelector('[data-action="save"]'),m=i.querySelector('[data-action="delete"]');h.addEventListener("keydown",v=>{v.stopPropagation(),v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),d.click()),v.key==="Escape"&&this.destroy()}),d.addEventListener("click",()=>{let v=h.value.trim();v&&(n.onSave(t,v),this.destroy())}),m.addEventListener("click",()=>{n.onDelete(t),this.destroy()}),this.shadow.appendChild(i),((f=document.getElementById("instruckt-root"))!=null?f:document.body).appendChild(this.host);let g=t.x/100*window.innerWidth,p=t.y-window.scrollY;this.positionHost(g,p),this.setupOutsideClick(),h.focus(),h.setSelectionRange(h.value.length,h.value.length)}stopHostPropagation(t){for(let n of["click","mousedown","pointerdown","keydown","keyup","keypress","submit"])t.addEventListener(n,o=>o.stopPropagation())}positionHost(t,n){if(this.host){this.host.setAttribute("popover","manual");try{this.host.showPopover()}catch(o){}Object.assign(this.host.style,{position:"fixed",zIndex:"2147483647",left:"-9999px",top:"0"}),requestAnimationFrame(()=>{var u,l;if(!this.host)return;let o=360,r=(l=(u=this.host.querySelector(".popup"))==null?void 0:u.getBoundingClientRect().height)!=null?l:300,i=window.innerWidth,s=window.innerHeight,a=Math.max(10,Math.min(t+10,i-o)),c=Math.max(10,Math.min(n+10,s-r-10));Object.assign(this.host.style,{left:`${a}px`,top:`${c}px`})})}}setupOutsideClick(){setTimeout(()=>document.addEventListener("mousedown",this.boundOutside),0)}destroy(){var t;(t=this.host)==null||t.remove(),this.host=null,this.shadow=null,document.removeEventListener("mousedown",this.boundOutside)}};var D=class{constructor(t){this.onClick=t;this.markers=new Map;var o;this.container=document.createElement("div"),Object.assign(this.container.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"2147483645"}),this.container.setAttribute("data-instruckt","markers"),((o=document.getElementById("instruckt-root"))!=null?o:document.body).appendChild(this.container)}upsert(t,n){let o=this.markers.get(t.id);if(o){this.updateStyle(o.el,t);return}let r=document.createElement("div"),i=t.screenshot?" has-screenshot":"";r.className=`ik-marker ${this.statusClass(t.status)}${i}`,r.textContent=String(n),r.title=t.comment==="(screenshot)"?"Screenshot":t.comment.slice(0,60),r.style.pointerEvents="all",r.style.left=`${t.x/100*window.innerWidth}px`,r.style.top=`${t.y-window.scrollY}px`,r.addEventListener("click",s=>{s.stopPropagation(),this.onClick(t)}),this.container.appendChild(r),this.markers.set(t.id,{el:r,annotationId:t.id})}update(t){let n=this.markers.get(t.id);n&&this.updateStyle(n.el,t)}updateStyle(t,n){let o=n.screenshot?" has-screenshot":"";t.className=`ik-marker ${this.statusClass(n.status)}${o}`,t.title=n.comment==="(screenshot)"?"Screenshot":n.comment.slice(0,60)}statusClass(t){return t==="resolved"?"resolved":t==="dismissed"?"dismissed":""}reposition(t){t.forEach(n=>{let o=this.markers.get(n.id);o&&(o.el.style.left=`${n.x/100*window.innerWidth}px`,o.el.style.top=`${n.y-window.scrollY}px`)})}remove(t){let n=this.markers.get(t);n&&(n.el.remove(),this.markers.delete(t))}setVisible(t){this.container.style.display=t?"":"none"}clear(){for(let{el:t}of this.markers.values())t.remove();this.markers.clear()}destroy(){this.container.remove(),this.markers.clear()}};function ut(e){if(e.id)return`#${CSS.escape(e.id)}`;let t=[],n=e;for(;n&&n!==document.documentElement;){let o=n.tagName.toLowerCase(),r=n.parentElement;if(!r){t.unshift(o);break}let i=Array.from(n.classList).filter(a=>!a.match(/^(hover|focus|active|visited|is-|has-)/)).slice(0,3);if(i.length>0){let a=`${o}.${i.map(CSS.escape).join(".")}`;if(r.querySelectorAll(a).length===1){t.unshift(a);break}}let s=Array.from(r.children).filter(a=>a.tagName===n.tagName);if(s.length===1)t.unshift(o);else{let a=s.indexOf(n)+1;t.unshift(`${o}:nth-of-type(${a})`)}n=r}return t.join(" > ")}function ht(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("wire:model")||e.getAttribute("wire:click");if(n)return`${t}[wire:${n.split(".")[0]}]`;if(e.id)return`${t}#${e.id}`;let o=e.classList[0];return o?`${t}.${o}`:t}function pt(e){let t=e.tagName.toLowerCase(),n=(e.textContent||"").trim().replace(/\s+/g," ").slice(0,40),o=[];e.id&&o.push(`id="${e.id}"`);let r=e.getAttribute("role");r&&o.push(`role="${r}"`);let i=e.getAttribute("wire:model")||e.getAttribute("wire:click");i&&o.push(`wire:${e.hasAttribute("wire:model")?"model":"click"}="${i}"`);let s=o.length?" "+o.join(" "):"",a=`<${t}${s}>`;return n?`${a} ${n}`:a}function mt(e){return(e.textContent||"").trim().replace(/\s+/g," ").slice(0,120)}function ft(e){return Array.from(e.classList).filter(t=>!t.match(/^(instruckt-)/)).join(" ")}function gt(e){let t=e.getBoundingClientRect();return{x:t.left+window.scrollX,y:t.top+window.scrollY,width:t.width,height:t.height}}function Fn(){return typeof window.Livewire!="undefined"}function Nn(e){let t=e;for(;t&&t!==document.documentElement;){if(t.getAttribute("wire:id"))return t;t=t.parentElement}return null}function Qt(e){var i,s;if(!Fn())return null;let t=Nn(e);if(!t)return null;let n=t.getAttribute("wire:id"),o="Unknown",r=t.getAttribute("wire:snapshot");if(r)try{let a=JSON.parse(r);o=(s=(i=a==null?void 0:a.memo)==null?void 0:i.name)!=null?s:"Unknown"}catch(a){}return{framework:"livewire",component:o,wire_id:n}}function On(e){var n;let t=e;for(;t&&t!==document.documentElement;){let o=(n=t.__vueParentComponent)!=null?n:t.__vue__;if(o)return o;t=t.parentElement}return null}function te(e){var r,i,s,a,c,u,l,h;let t=On(e);if(!t)return null;let n=(h=(l=(c=(s=(r=t.$options)==null?void 0:r.name)!=null?s:(i=t.$options)==null?void 0:i.__name)!=null?c:(a=t.type)==null?void 0:a.name)!=null?l:(u=t.type)==null?void 0:u.__name)!=null?h:"Anonymous",o={};if(t.props&&Object.assign(o,t.props),t.setupState){for(let[d,m]of Object.entries(t.setupState))if(!d.startsWith("_")&&typeof m!="function")try{o[d]=JSON.parse(JSON.stringify(m))}catch(g){o[d]=String(m)}}return{framework:"vue",component:n,component_uid:t.uid!==void 0?String(t.uid):void 0,data:o}}function Dn(e){let t=e;for(;t&&t!==document.documentElement;){if(t.__svelte_meta)return t.__svelte_meta;t=t.parentElement}return null}function ee(e){var r,i,s,a;let t=Dn(e);if(!t)return null;let n=(i=(r=t.loc)==null?void 0:r.file)!=null?i:"";return{framework:"svelte",component:n&&(a=(s=n.split("/").pop())==null?void 0:s.replace(/\.svelte$/,""))!=null?a:"Unknown",data:n?{file:n}:void 0}}function Hn(e){for(let t of Object.keys(e))if(t.startsWith("__reactFiber$")||t.startsWith("__reactInternalInstance$"))return t;return null}function qn(e){let t=e;for(;t;){let{type:n}=t;if(typeof n=="function"&&n.name){let o=n.name;if(o[0]===o[0].toUpperCase()&&o.length>1)return o}if(typeof n=="object"&&n!==null&&n.displayName)return n.displayName;t=t.return}return"Component"}function Vn(e){var o,r;let t=(r=(o=e.memoizedProps)!=null?o:e.pendingProps)!=null?r:{},n={};for(let[i,s]of Object.entries(t))if(!(i==="children"||typeof s=="function"))try{n[i]=JSON.parse(JSON.stringify(s))}catch(a){n[i]=String(s)}return n}function ne(e){let t=e;for(;t&&t!==document.documentElement;){let n=Hn(t);if(n){let o=t[n];if(o){let r=qn(o),i=Vn(o);return{framework:"react",component:r,data:i}}}t=t.parentElement}return null}function oe(){return window.location.pathname}var j=class j{constructor(t){this.toolbar=null;this.highlight=null;this.popup=null;this.markers=null;this.annotations=[];this.isAnnotating=!1;this.isFrozen=!1;this.frozenStyleEl=null;this.frozenPopovers=[];this.rafId=null;this.pendingMouseTarget=null;this.highlightLocked=!1;this.pollTimer=null;this.boundReposition=()=>{var t;(t=this.markers)==null||t.reposition(this.annotations)};this.freezeBlockEvents=["click","mousedown","pointerdown","pointerup","mouseup","touchstart","touchend","auxclick"];this.freezePassiveEvents=["focusin","focusout","blur","pointerleave","mouseleave","mouseout"];this.boundFreezeClick=t=>{this.isInstruckt(t.target)||this.isAnnotating&&t.type==="click"||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};this.boundFreezeSubmit=t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()};this.boundFreezePassive=t=>{t.stopPropagation(),t.stopImmediatePropagation()};this.boundMouseMove=t=>{this.highlightLocked||(this.pendingMouseTarget=t.target,this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{var n,o;this.rafId=null,!this.highlightLocked&&(this.pendingMouseTarget&&!this.isInstruckt(this.pendingMouseTarget)?(n=this.highlight)==null||n.show(this.pendingMouseTarget):(o=this.highlight)==null||o.hide())})))};this.boundMouseLeave=()=>{var t;this.highlightLocked||(t=this.highlight)==null||t.hide()};this.boundAnnotateBlock=t=>{this.isInstruckt(t.target)||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};this.boundClick=t=>{var d,m,g;let n=t.target;if(this.isInstruckt(n))return;t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();let o=((d=window.getSelection())==null?void 0:d.toString().trim())||void 0,r=ut(n),i=ht(n),s=pt(n),a=ft(n),c=mt(n)||void 0,u=gt(n),l=(m=this.detectFramework(n))!=null?m:void 0;(g=this.highlight)==null||g.show(n),this.highlightLocked=!0;let h={element:n,elementPath:r,elementName:i,elementLabel:s,cssClasses:a,boundingBox:u,x:t.clientX,y:t.clientY,selectedText:o,nearbyText:c,framework:l};this.showAnnotationPopup(h)};this.config=E({adapters:["livewire","vue","svelte","react"],theme:"auto",position:"bottom-right"},t),this.api=new W(t.endpoint),this.boundKeydown=this.onKeydown.bind(this),this.init()}init(){ot(this.config.colors),this.config.theme!=="auto"&&document.documentElement.setAttribute("data-instruckt-theme",this.config.theme),this.toolbar=new $(this.config.position,{onToggleAnnotate:t=>{this.setAnnotating(t)},onFreezeAnimations:t=>{this.setFrozen(t)},onScreenshot:()=>this.startRegionCapture(),onCopy:()=>this.copyToClipboard(!0),onClearPage:()=>this.clearPage(),onClearAll:()=>this.clearEverything(),onMinimize:t=>this.onMinimize(t)},this.config.keys),this.highlight=new F,this.popup=new Z,this.markers=new D(t=>this.onMarkerClick(t)),document.addEventListener("keydown",this.boundKeydown),window.addEventListener("scroll",this.boundReposition,{passive:!0}),window.addEventListener("resize",this.boundReposition,{passive:!0}),document.addEventListener("livewire:navigated",()=>this.reattach()),document.addEventListener("inertia:navigate",()=>this.syncMarkers()),window.addEventListener("popstate",()=>{setTimeout(()=>this.reattach(),0)}),this.loadAnnotations(),this.syncMarkers()}makeToolbarCallbacks(){return{onToggleAnnotate:t=>{this.setAnnotating(t)},onFreezeAnimations:t=>{this.setFrozen(t)},onScreenshot:()=>this.startRegionCapture(),onCopy:()=>this.copyToClipboard(!0),onClearPage:()=>this.clearPage(),onClearAll:()=>this.clearEverything(),onMinimize:t=>this.onMinimize(t)}}reattach(){var i,s;let t=this.isAnnotating,n=this.isFrozen,o=(s=(i=this.toolbar)==null?void 0:i.isMinimized())!=null?s:!1;this.isAnnotating&&this.detachAnnotateListeners(),this.isFrozen&&this.setFrozen(!1),this.isAnnotating=!1,this.isFrozen=!1,document.querySelectorAll("[data-instruckt]").forEach(a=>a.remove()),this.toolbar=new $(this.config.position,this.makeToolbarCallbacks()),o&&this.toolbar.minimize(),this.markers=new D(a=>this.onMarkerClick(a)),this.highlight=new F,o&&this.markers.setVisible(!1);let r=document.getElementById("instruckt-global");r&&r.remove(),ot(this.config.colors),this.syncMarkers(),t&&!o&&this.setAnnotating(!0)}onMinimize(t){var n,o,r,i,s;t?(this.isAnnotating&&this.setAnnotating(!1),this.isFrozen&&this.setFrozen(!1),(n=this.toolbar)==null||n.setAnnotateActive(!1),(o=this.toolbar)==null||o.setFreezeActive(!1),(r=this.markers)==null||r.setVisible(!1),(i=this.popup)==null||i.destroy()):(s=this.markers)==null||s.setVisible(!0)}async loadAnnotations(){this.loadFromStorage();try{let t=await this.api.getAnnotations();if(t.length>0){let n=new Set(t.map(r=>r.id)),o=this.annotations.filter(r=>!n.has(r.id));this.annotations=[...t,...o],this.saveToStorage()}}catch(t){}this.syncMarkers()}saveToStorage(){try{localStorage.setItem(j.STORAGE_KEY,JSON.stringify(this.annotations))}catch(t){}}loadFromStorage(){try{let t=localStorage.getItem(j.STORAGE_KEY);t&&(this.annotations=JSON.parse(t))}catch(t){}}updatePolling(){let t=this.totalActiveCount()>0;t&&!this.pollTimer?this.pollTimer=setInterval(()=>this.pollForChanges(),3e3):!t&&this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}async pollForChanges(){try{let t=await this.api.getAnnotations(),n=!1;for(let o of t){let r=this.annotations.find(i=>i.id===o.id);r&&r.status!==o.status&&(r.status=o.status,r.resolvedAt=o.resolvedAt,r.resolvedBy=o.resolvedBy,n=!0)}n&&(this.saveToStorage(),this.syncMarkers())}catch(t){}}syncMarkers(){var o,r,i,s;(o=this.markers)==null||o.clear();let t=oe(),n=0;for(let a of this.annotations)a.status==="resolved"||a.status==="dismissed"||this.annotationPageKey(a)===t&&(n++,(r=this.markers)==null||r.upsert(a,n));(i=this.toolbar)==null||i.setAnnotationCount(this.pageAnnotations().length),(s=this.toolbar)==null||s.setTotalCount(this.totalActiveCount()),this.updatePolling()}annotationPageKey(t){try{return new URL(t.url).pathname}catch(n){return t.url}}pageAnnotations(){let t=oe();return this.annotations.filter(n=>this.annotationPageKey(n)===t&&n.status!=="resolved"&&n.status!=="dismissed")}totalActiveCount(){return this.annotations.filter(t=>t.status!=="resolved"&&t.status!=="dismissed").length}setAnnotating(t){var n,o;this.isAnnotating=t,(n=this.toolbar)==null||n.setAnnotateActive(t),t?this.attachAnnotateListeners():(this.detachAnnotateListeners(),(o=this.highlight)==null||o.hide(),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)),this.updateFreezeStyles()}setFrozen(t){var n,o;if(this.isFrozen=t,(n=this.toolbar)==null||n.setFreezeActive(t),t){this.updateFreezeStyles(),this.freezePopovers();for(let r of this.freezeBlockEvents)window.addEventListener(r,this.boundFreezeClick,!0);window.addEventListener("submit",this.boundFreezeSubmit,!0);for(let r of this.freezePassiveEvents)window.addEventListener(r,this.boundFreezePassive,!0)}else{(o=this.frozenStyleEl)==null||o.remove(),this.frozenStyleEl=null,this.unfreezePopovers();for(let r of this.freezeBlockEvents)window.removeEventListener(r,this.boundFreezeClick,!0);window.removeEventListener("submit",this.boundFreezeSubmit,!0);for(let r of this.freezePassiveEvents)window.removeEventListener(r,this.boundFreezePassive,!0)}}freezePopovers(){this.frozenPopovers=[];let t=":popover-open, .\\:popover-open";document.querySelectorAll("[popover]").forEach(n=>{var a;let o=n,r=(a=o.getAttribute("popover"))!=null?a:"",i=!1;try{i=o.matches(t)}catch(c){try{i=o.matches(".\\:popover-open")}catch(u){}}if(!i)return;let s=o.getBoundingClientRect();this.frozenPopovers.push({el:o,original:r}),o.removeAttribute("popover"),o.style.setProperty("display","block","important"),o.style.setProperty("position","fixed","important"),o.style.setProperty("z-index","2147483644","important"),o.style.setProperty("top",`${s.top}px`,"important"),o.style.setProperty("left",`${s.left}px`,"important"),o.style.setProperty("width",`${s.width}px`,"important"),o.classList.add(":popover-open")})}unfreezePopovers(){for(let{el:t,original:n}of this.frozenPopovers){for(let o of["display","position","z-index","top","left","width"])t.style.removeProperty(o);t.classList.remove(":popover-open"),t.setAttribute("popover",n||"auto")}this.frozenPopovers=[]}updateFreezeStyles(){var n;if(!this.isFrozen)return;(n=this.frozenStyleEl)==null||n.remove(),this.frozenStyleEl=document.createElement("style"),this.frozenStyleEl.id="instruckt-freeze";let t=this.isAnnotating?"":`
|
|
432
|
+
`,i.querySelector(".close-btn").addEventListener("click",()=>this.destroy());let l=i.querySelector(".screenshot-remove");l==null||l.addEventListener("click",()=>{n.onSave(t,t.comment);let v=i.querySelector(".screenshot-slot");v&&v.remove()});let h=i.querySelector("textarea"),u=i.querySelector('[data-action="save"]'),m=i.querySelector('[data-action="delete"]');h.addEventListener("keydown",v=>{v.stopPropagation(),v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),u.click()),v.key==="Escape"&&this.destroy()}),u.addEventListener("click",()=>{let v=h.value.trim();v&&(n.onSave(t,v),this.destroy())}),m.addEventListener("click",()=>{n.onDelete(t),this.destroy()}),this.shadow.appendChild(i),((f=document.getElementById("instruckt-root"))!=null?f:document.body).appendChild(this.host);let g=t.x/100*window.innerWidth,p=t.y-window.scrollY;this.positionHost(g,p),this.setupOutsideClick(),h.focus(),h.setSelectionRange(h.value.length,h.value.length)}stopHostPropagation(t){for(let n of["click","mousedown","pointerdown","keydown","keyup","keypress","submit"])t.addEventListener(n,o=>o.stopPropagation())}positionHost(t,n){if(this.host){this.host.setAttribute("popover","manual");try{this.host.showPopover()}catch(o){}Object.assign(this.host.style,{position:"fixed",zIndex:"2147483647",left:"-9999px",top:"0"}),requestAnimationFrame(()=>{var d,l;if(!this.host)return;let o=360,r=(l=(d=this.host.querySelector(".popup"))==null?void 0:d.getBoundingClientRect().height)!=null?l:300,i=window.innerWidth,s=window.innerHeight,a=Math.max(10,Math.min(t+10,i-o)),c=Math.max(10,Math.min(n+10,s-r-10));Object.assign(this.host.style,{left:`${a}px`,top:`${c}px`})})}}setupOutsideClick(){setTimeout(()=>document.addEventListener("mousedown",this.boundOutside),0)}destroy(){var t;(t=this.host)==null||t.remove(),this.host=null,this.shadow=null,document.removeEventListener("mousedown",this.boundOutside)}};var D=class{constructor(t){this.onClick=t;this.markers=new Map;var o;this.container=document.createElement("div"),Object.assign(this.container.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"2147483645"}),this.container.setAttribute("data-instruckt","markers"),((o=document.getElementById("instruckt-root"))!=null?o:document.body).appendChild(this.container)}upsert(t,n){let o=this.markers.get(t.id);if(o){this.updateStyle(o.el,t);return}let r=document.createElement("div"),i=t.screenshot?" has-screenshot":"";r.className=`ik-marker ${this.statusClass(t.status)}${i}`,r.textContent=String(n),r.title=t.comment==="(screenshot)"?"Screenshot":t.comment.slice(0,60),r.style.pointerEvents="all",r.style.left=`${t.x/100*window.innerWidth}px`,r.style.top=`${t.y-window.scrollY}px`,r.addEventListener("click",s=>{s.stopPropagation(),this.onClick(t)}),this.container.appendChild(r),this.markers.set(t.id,{el:r,annotationId:t.id})}update(t){let n=this.markers.get(t.id);n&&this.updateStyle(n.el,t)}updateStyle(t,n){let o=n.screenshot?" has-screenshot":"";t.className=`ik-marker ${this.statusClass(n.status)}${o}`,t.title=n.comment==="(screenshot)"?"Screenshot":n.comment.slice(0,60)}statusClass(t){return t==="resolved"?"resolved":t==="dismissed"?"dismissed":""}reposition(t){t.forEach(n=>{let o=this.markers.get(n.id);o&&(o.el.style.left=`${n.x/100*window.innerWidth}px`,o.el.style.top=`${n.y-window.scrollY}px`)})}remove(t){let n=this.markers.get(t);n&&(n.el.remove(),this.markers.delete(t))}setVisible(t){this.container.style.display=t?"":"none"}clear(){for(let{el:t}of this.markers.values())t.remove();this.markers.clear()}destroy(){this.container.remove(),this.markers.clear()}};function ut(e){if(e.id)return`#${CSS.escape(e.id)}`;let t=[],n=e;for(;n&&n!==document.documentElement;){let o=n.tagName.toLowerCase(),r=n.parentElement;if(!r){t.unshift(o);break}let i=Array.from(n.classList).filter(a=>!a.match(/^(hover|focus|active|visited|is-|has-)/)).slice(0,3);if(i.length>0){let a=`${o}.${i.map(CSS.escape).join(".")}`;if(r.querySelectorAll(a).length===1){t.unshift(a);break}}let s=Array.from(r.children).filter(a=>a.tagName===n.tagName);if(s.length===1)t.unshift(o);else{let a=s.indexOf(n)+1;t.unshift(`${o}:nth-of-type(${a})`)}n=r}return t.join(" > ")}function ht(e){let t=e.tagName.toLowerCase(),n=e.getAttribute("wire:model")||e.getAttribute("wire:click");if(n)return`${t}[wire:${n.split(".")[0]}]`;if(e.id)return`${t}#${e.id}`;let o=e.classList[0];return o?`${t}.${o}`:t}function pt(e){let t=e.tagName.toLowerCase(),n=(e.textContent||"").trim().replace(/\s+/g," ").slice(0,40),o=[];e.id&&o.push(`id="${e.id}"`);let r=e.getAttribute("role");r&&o.push(`role="${r}"`);let i=e.getAttribute("wire:model")||e.getAttribute("wire:click");i&&o.push(`wire:${e.hasAttribute("wire:model")?"model":"click"}="${i}"`);let s=o.length?" "+o.join(" "):"",a=`<${t}${s}>`;return n?`${a} ${n}`:a}function mt(e){return(e.textContent||"").trim().replace(/\s+/g," ").slice(0,120)}function ft(e){return Array.from(e.classList).filter(t=>!t.match(/^(instruckt-)/)).join(" ")}function gt(e){let t=e.getBoundingClientRect();return{x:t.left+window.scrollX,y:t.top+window.scrollY,width:t.width,height:t.height}}function Fn(){return typeof window.Livewire!="undefined"}function Nn(e){let t=e;for(;t&&t!==document.documentElement;){if(t.getAttribute("wire:id"))return t;t=t.parentElement}return null}function Qt(e){var i,s;if(!Fn())return null;let t=Nn(e);if(!t)return null;let n=t.getAttribute("wire:id"),o="Unknown",r=t.getAttribute("wire:snapshot");if(r)try{let a=JSON.parse(r);o=(s=(i=a==null?void 0:a.memo)==null?void 0:i.name)!=null?s:"Unknown"}catch(a){}return{framework:"livewire",component:o,wire_id:n}}function On(e){var n;let t=e;for(;t&&t!==document.documentElement;){let o=(n=t.__vueParentComponent)!=null?n:t.__vue__;if(o)return o;t=t.parentElement}return null}function te(e){var r,i,s,a,c,d,l,h;let t=On(e);if(!t)return null;let n=(h=(l=(c=(s=(r=t.$options)==null?void 0:r.name)!=null?s:(i=t.$options)==null?void 0:i.__name)!=null?c:(a=t.type)==null?void 0:a.name)!=null?l:(d=t.type)==null?void 0:d.__name)!=null?h:"Anonymous",o={};if(t.props&&Object.assign(o,t.props),t.setupState){for(let[u,m]of Object.entries(t.setupState))if(!u.startsWith("_")&&typeof m!="function")try{o[u]=JSON.parse(JSON.stringify(m))}catch(g){o[u]=String(m)}}return{framework:"vue",component:n,component_uid:t.uid!==void 0?String(t.uid):void 0,data:o}}function Dn(e){let t=e;for(;t&&t!==document.documentElement;){if(t.__svelte_meta)return t.__svelte_meta;t=t.parentElement}return null}function ee(e){var r,i,s,a;let t=Dn(e);if(!t)return null;let n=(i=(r=t.loc)==null?void 0:r.file)!=null?i:"";return{framework:"svelte",component:n&&(a=(s=n.split("/").pop())==null?void 0:s.replace(/\.svelte$/,""))!=null?a:"Unknown",data:n?{file:n}:void 0}}function Hn(e){for(let t of Object.keys(e))if(t.startsWith("__reactFiber$")||t.startsWith("__reactInternalInstance$"))return t;return null}function qn(e){let t=e;for(;t;){let{type:n}=t;if(typeof n=="function"&&n.name){let o=n.name;if(o[0]===o[0].toUpperCase()&&o.length>1)return o}if(typeof n=="object"&&n!==null&&n.displayName)return n.displayName;t=t.return}return"Component"}function Vn(e){var o,r;let t=(r=(o=e.memoizedProps)!=null?o:e.pendingProps)!=null?r:{},n={};for(let[i,s]of Object.entries(t))if(!(i==="children"||typeof s=="function"))try{n[i]=JSON.parse(JSON.stringify(s))}catch(a){n[i]=String(s)}return n}function ne(e){let t=e;for(;t&&t!==document.documentElement;){let n=Hn(t);if(n){let o=t[n];if(o){let r=qn(o),i=Vn(o);return{framework:"react",component:r,data:i}}}t=t.parentElement}return null}function oe(){return window.location.pathname}var j=class j{constructor(t){this.toolbar=null;this.highlight=null;this.popup=null;this.markers=null;this.annotations=[];this.isAnnotating=!1;this.isFrozen=!1;this.frozenStyleEl=null;this.frozenPopovers=[];this.rafId=null;this.pendingMouseTarget=null;this.highlightLocked=!1;this.pollTimer=null;this.boundReposition=()=>{var t;(t=this.markers)==null||t.reposition(this.annotations)};this.freezeBlockEvents=["click","mousedown","pointerdown","pointerup","mouseup","touchstart","touchend","auxclick"];this.freezePassiveEvents=["focusin","focusout","blur","pointerleave","mouseleave","mouseout"];this.boundFreezeClick=t=>{this.isInstruckt(t.target)||this.isAnnotating&&t.type==="click"||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};this.boundFreezeSubmit=t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()};this.boundFreezePassive=t=>{t.stopPropagation(),t.stopImmediatePropagation()};this.boundMouseMove=t=>{this.highlightLocked||(this.pendingMouseTarget=t.target,this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{var n,o;this.rafId=null,!this.highlightLocked&&(this.pendingMouseTarget&&!this.isInstruckt(this.pendingMouseTarget)?(n=this.highlight)==null||n.show(this.pendingMouseTarget):(o=this.highlight)==null||o.hide())})))};this.boundMouseLeave=()=>{var t;this.highlightLocked||(t=this.highlight)==null||t.hide()};this.boundAnnotateBlock=t=>{this.isInstruckt(t.target)||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};this.boundClick=t=>{var u,m,g;let n=t.target;if(this.isInstruckt(n))return;t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();let o=((u=window.getSelection())==null?void 0:u.toString().trim())||void 0,r=ut(n),i=ht(n),s=pt(n),a=ft(n),c=mt(n)||void 0,d=gt(n),l=(m=this.detectFramework(n))!=null?m:void 0;(g=this.highlight)==null||g.show(n),this.highlightLocked=!0;let h={element:n,elementPath:r,elementName:i,elementLabel:s,cssClasses:a,boundingBox:d,x:t.clientX,y:t.clientY,selectedText:o,nearbyText:c,framework:l};this.showAnnotationPopup(h)};this.config=E({adapters:["livewire","vue","svelte","react"],theme:"auto",position:"bottom-right"},t),this.api=new W(t.endpoint),this.boundKeydown=this.onKeydown.bind(this),this.init()}init(){ot(this.config.colors),this.config.theme!=="auto"&&document.documentElement.setAttribute("data-instruckt-theme",this.config.theme),this.toolbar=new $(this.config.position,{onToggleAnnotate:t=>{this.setAnnotating(t)},onFreezeAnimations:t=>{this.setFrozen(t)},onScreenshot:()=>this.startRegionCapture(),onCopy:()=>this.copyToClipboard(!0),onClearPage:()=>this.clearPage(),onClearAll:()=>this.clearEverything(),onMinimize:t=>this.onMinimize(t)},this.config.keys),this.highlight=new F,this.popup=new Z,this.markers=new D(t=>this.onMarkerClick(t)),document.addEventListener("keydown",this.boundKeydown),window.addEventListener("scroll",this.boundReposition,{passive:!0}),window.addEventListener("resize",this.boundReposition,{passive:!0}),document.addEventListener("livewire:navigated",()=>this.reattach()),document.addEventListener("inertia:navigate",()=>this.syncMarkers()),window.addEventListener("popstate",()=>{setTimeout(()=>this.reattach(),0)}),this.loadAnnotations(),this.syncMarkers()}makeToolbarCallbacks(){return{onToggleAnnotate:t=>{this.setAnnotating(t)},onFreezeAnimations:t=>{this.setFrozen(t)},onScreenshot:()=>this.startRegionCapture(),onCopy:()=>this.copyToClipboard(!0),onClearPage:()=>this.clearPage(),onClearAll:()=>this.clearEverything(),onMinimize:t=>this.onMinimize(t)}}reattach(){var i,s;let t=this.isAnnotating,n=this.isFrozen,o=(s=(i=this.toolbar)==null?void 0:i.isMinimized())!=null?s:!1;this.isAnnotating&&this.detachAnnotateListeners(),this.isFrozen&&this.setFrozen(!1),this.isAnnotating=!1,this.isFrozen=!1,document.querySelectorAll("[data-instruckt]").forEach(a=>a.remove()),this.toolbar=new $(this.config.position,this.makeToolbarCallbacks()),o&&this.toolbar.minimize(),this.markers=new D(a=>this.onMarkerClick(a)),this.highlight=new F,o&&this.markers.setVisible(!1);let r=document.getElementById("instruckt-global");r&&r.remove(),ot(this.config.colors),this.syncMarkers(),t&&!o&&this.setAnnotating(!0)}onMinimize(t){var n,o,r,i,s;t?(this.isAnnotating&&this.setAnnotating(!1),this.isFrozen&&this.setFrozen(!1),(n=this.toolbar)==null||n.setAnnotateActive(!1),(o=this.toolbar)==null||o.setFreezeActive(!1),(r=this.markers)==null||r.setVisible(!1),(i=this.popup)==null||i.destroy()):(s=this.markers)==null||s.setVisible(!0)}async loadAnnotations(){this.loadFromStorage();try{let t=await this.api.getAnnotations();if(t.length>0){let n=new Set(t.map(r=>r.id)),o=this.annotations.filter(r=>!n.has(r.id));this.annotations=[...t,...o],this.saveToStorage()}}catch(t){}this.syncMarkers()}saveToStorage(){try{localStorage.setItem(j.STORAGE_KEY,JSON.stringify(this.annotations))}catch(t){}}loadFromStorage(){try{let t=localStorage.getItem(j.STORAGE_KEY);t&&(this.annotations=JSON.parse(t))}catch(t){}}updatePolling(){let t=this.totalActiveCount()>0;t&&!this.pollTimer?this.pollTimer=setInterval(()=>this.pollForChanges(),3e3):!t&&this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}async pollForChanges(){try{let t=await this.api.getAnnotations(),n=!1;for(let o of t){let r=this.annotations.find(i=>i.id===o.id);r&&r.status!==o.status&&(r.status=o.status,r.resolvedAt=o.resolvedAt,r.resolvedBy=o.resolvedBy,n=!0)}n&&(this.saveToStorage(),this.syncMarkers())}catch(t){}}syncMarkers(){var o,r,i,s;(o=this.markers)==null||o.clear();let t=oe(),n=0;for(let a of this.annotations)a.status==="resolved"||a.status==="dismissed"||this.annotationPageKey(a)===t&&(n++,(r=this.markers)==null||r.upsert(a,n));(i=this.toolbar)==null||i.setAnnotationCount(this.pageAnnotations().length),(s=this.toolbar)==null||s.setTotalCount(this.totalActiveCount()),this.updatePolling()}annotationPageKey(t){try{return new URL(t.url).pathname}catch(n){return t.url}}pageAnnotations(){let t=oe();return this.annotations.filter(n=>this.annotationPageKey(n)===t&&n.status!=="resolved"&&n.status!=="dismissed")}totalActiveCount(){return this.annotations.filter(t=>t.status!=="resolved"&&t.status!=="dismissed").length}setAnnotating(t){var n,o;this.isAnnotating=t,(n=this.toolbar)==null||n.setAnnotateActive(t),t?this.attachAnnotateListeners():(this.detachAnnotateListeners(),(o=this.highlight)==null||o.hide(),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)),this.updateFreezeStyles()}setFrozen(t){var n,o;if(this.isFrozen=t,(n=this.toolbar)==null||n.setFreezeActive(t),t){this.updateFreezeStyles(),this.freezePopovers();for(let r of this.freezeBlockEvents)window.addEventListener(r,this.boundFreezeClick,!0);window.addEventListener("submit",this.boundFreezeSubmit,!0);for(let r of this.freezePassiveEvents)window.addEventListener(r,this.boundFreezePassive,!0)}else{(o=this.frozenStyleEl)==null||o.remove(),this.frozenStyleEl=null,this.unfreezePopovers();for(let r of this.freezeBlockEvents)window.removeEventListener(r,this.boundFreezeClick,!0);window.removeEventListener("submit",this.boundFreezeSubmit,!0);for(let r of this.freezePassiveEvents)window.removeEventListener(r,this.boundFreezePassive,!0)}}freezePopovers(){this.frozenPopovers=[];let t=":popover-open, .\\:popover-open";document.querySelectorAll("[popover]").forEach(n=>{var a;let o=n,r=(a=o.getAttribute("popover"))!=null?a:"",i=!1;try{i=o.matches(t)}catch(c){try{i=o.matches(".\\:popover-open")}catch(d){}}if(!i)return;let s=o.getBoundingClientRect();this.frozenPopovers.push({el:o,original:r}),o.removeAttribute("popover"),o.style.setProperty("display","block","important"),o.style.setProperty("position","fixed","important"),o.style.setProperty("z-index","2147483644","important"),o.style.setProperty("top",`${s.top}px`,"important"),o.style.setProperty("left",`${s.left}px`,"important"),o.style.setProperty("width",`${s.width}px`,"important"),o.classList.add(":popover-open")})}unfreezePopovers(){for(let{el:t,original:n}of this.frozenPopovers){for(let o of["display","position","z-index","top","left","width"])t.style.removeProperty(o);t.classList.remove(":popover-open"),t.setAttribute("popover",n||"auto")}this.frozenPopovers=[]}updateFreezeStyles(){var n;if(!this.isFrozen)return;(n=this.frozenStyleEl)==null||n.remove(),this.frozenStyleEl=document.createElement("style"),this.frozenStyleEl.id="instruckt-freeze";let t=this.isAnnotating?"":`
|
|
433
433
|
a[href], a[wire\\:navigate], [wire\\:click], [wire\\:navigate],
|
|
434
434
|
[x-on\\:click], [@click], [v-on\\:click], [onclick],
|
|
435
435
|
button, input[type="submit"], select, [role="button"], [role="link"],
|
|
@@ -444,8 +444,8 @@ textarea::placeholder { color:var(--ik-muted); }
|
|
|
444
444
|
}
|
|
445
445
|
video { filter: none !important; }
|
|
446
446
|
${t}
|
|
447
|
-
`,document.head.appendChild(this.frozenStyleEl)}showAnnotationPopup(t){var n;(n=this.popup)==null||n.showNew(t,{onSubmit:o=>{var r;this.highlightLocked=!1,(r=this.highlight)==null||r.hide(),this.submitAnnotation(t,o.comment,o.screenshot)},onCancel:()=>{var o;this.highlightLocked=!1,(o=this.highlight)==null||o.hide()}})}attachAnnotateListeners(){document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("mouseleave",this.boundMouseLeave);for(let t of["mousedown","pointerdown"])window.addEventListener(t,this.boundAnnotateBlock,!0);window.addEventListener("click",this.boundClick,!0)}detachAnnotateListeners(){document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("mouseleave",this.boundMouseLeave);for(let t of["mousedown","pointerdown"])window.removeEventListener(t,this.boundAnnotateBlock,!0);window.removeEventListener("click",this.boundClick,!0)}isInstruckt(t){return!t||!(t instanceof Element)?!1:t.closest("[data-instruckt]")!==null}async startRegionCapture(){var c,
|
|
447
|
+
`,document.head.appendChild(this.frozenStyleEl)}showAnnotationPopup(t){var n;(n=this.popup)==null||n.showNew(t,{onSubmit:o=>{var r;this.highlightLocked=!1,(r=this.highlight)==null||r.hide(),this.submitAnnotation(t,o.comment,o.screenshot)},onCancel:()=>{var o;this.highlightLocked=!1,(o=this.highlight)==null||o.hide()}})}attachAnnotateListeners(){document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("mouseleave",this.boundMouseLeave);for(let t of["mousedown","pointerdown"])window.addEventListener(t,this.boundAnnotateBlock,!0);window.addEventListener("click",this.boundClick,!0)}detachAnnotateListeners(){document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("mouseleave",this.boundMouseLeave);for(let t of["mousedown","pointerdown"])window.removeEventListener(t,this.boundAnnotateBlock,!0);window.removeEventListener("click",this.boundClick,!0)}isInstruckt(t){return!t||!(t instanceof Element)?!1:t.closest("[data-instruckt]")!==null}async startRegionCapture(){var c,d;let t=this.isAnnotating;t&&this.setAnnotating(!1);let n=await Zt();if(!n){t&&this.setAnnotating(!0);return}let o=await Jt(n);if(!o){t&&this.setAnnotating(!0);return}let r=n.x+n.width/2,i=n.y+n.height/2,s=(c=document.elementFromPoint(r,i))!=null?c:document.body,a={element:s,elementPath:ut(s),elementName:ht(s),elementLabel:pt(s),cssClasses:ft(s),boundingBox:gt(s),x:r,y:i,nearbyText:mt(s)||void 0,screenshot:o,framework:(d=this.detectFramework(s))!=null?d:void 0};this.showAnnotationPopup(a)}detectFramework(t){var o;let n=(o=this.config.adapters)!=null?o:[];if(n.includes("livewire")){let r=Qt(t);if(r)return r}if(n.includes("vue")){let r=te(t);if(r)return r}if(n.includes("svelte")){let r=ee(t);if(r)return r}if(n.includes("react")){let r=ne(t);if(r)return r}return null}async submitAnnotation(t,n,o){var s,a;let r={x:t.x/window.innerWidth*100,y:t.y+window.scrollY,comment:n,element:t.elementName,elementPath:t.elementPath,cssClasses:t.cssClasses,boundingBox:t.boundingBox,selectedText:t.selectedText,nearbyText:t.nearbyText,screenshot:o,intent:"fix",severity:"important",framework:t.framework,url:window.location.href},i;try{i=await this.api.addAnnotation(r)}catch(c){i=L(E({},r),{id:crypto.randomUUID(),status:"pending",createdAt:new Date().toISOString()})}this.annotations.push(i),this.saveToStorage(),this.syncMarkers(),(a=(s=this.config).onAnnotationAdd)==null||a.call(s,i),this.copyAnnotations()}onMarkerClick(t){var n;(n=this.popup)==null||n.showEdit(t,{onSave:async(o,r)=>{try{let i=await this.api.updateAnnotation(o.id,{comment:r});this.onAnnotationUpdated(i)}catch(i){this.onAnnotationUpdated(L(E({},o),{comment:r,updatedAt:new Date().toISOString()}))}},onDelete:async o=>{try{await this.api.updateAnnotation(o.id,{status:"dismissed"})}catch(r){}this.removeAnnotation(o.id)}},this.config.endpoint)}onAnnotationUpdated(t){let n=this.annotations.findIndex(o=>o.id===t.id);n>=0&&(this.annotations[n]=t),this.saveToStorage(),this.syncMarkers()}removeAnnotation(t){this.annotations=this.annotations.filter(n=>n.id!==t),this.saveToStorage(),this.syncMarkers()}async clearPage(){let t=this.pageAnnotations();for(let n of t)try{await this.api.updateAnnotation(n.id,{status:"dismissed"})}catch(o){}this.annotations=this.annotations.filter(n=>!t.includes(n)),this.saveToStorage(),this.syncMarkers()}async clearEverything(){let t=this.annotations.filter(n=>n.status!=="resolved"&&n.status!=="dismissed");for(let n of t)try{await this.api.updateAnnotation(n.id,{status:"dismissed"})}catch(o){}this.annotations=[],this.saveToStorage(),this.syncMarkers()}onKeydown(t){var i,s,a,c,d,l;if((i=this.toolbar)!=null&&i.isMinimized())return;let n=t.target;if(["INPUT","TEXTAREA","SELECT"].includes(n.tagName)||n.closest('[contenteditable="true"]')||this.isInstruckt(n))return;let o=(s=this.config.keys)!=null?s:{},r=!t.metaKey&&!t.ctrlKey&&!t.altKey;t.key===((a=o.annotate)!=null?a:"a")&&r&&this.setAnnotating(!this.isAnnotating),t.key===((c=o.freeze)!=null?c:"f")&&r&&this.setFrozen(!this.isFrozen),t.key===((d=o.screenshot)!=null?d:"c")&&r&&this.startRegionCapture(),t.key===((l=o.clearPage)!=null?l:"x")&&r&&this.clearPage(),t.key==="Escape"&&(this.isAnnotating&&this.setAnnotating(!1),this.isFrozen&&this.setFrozen(!1))}copyAnnotations(){this.copyToClipboard(!1)}copyToClipboard(t){let n=this.exportMarkdown();if(window.isSecureContext)navigator.clipboard.writeText(n).catch(()=>{});else if(t)try{let o=document.createElement("textarea");o.value=n,o.style.cssText="position:fixed;left:-9999px",document.body.appendChild(o),o.select(),document.execCommand("copy"),o.remove()}catch(o){}}exportMarkdown(){let t=this.annotations.filter(s=>s.status!=="resolved"&&s.status!=="dismissed");if(t.length===0)return`# UI Feedback
|
|
448
448
|
|
|
449
|
-
No open annotations.`;let n=new Map;for(let
|
|
449
|
+
No open annotations.`;let n=new Map;for(let s of t){let a=this.annotationPageKey(s);n.has(a)||n.set(a,[]),n.get(a).push(s)}let o=n.size>1,r=[];o&&(r.push("# UI Feedback"),r.push(""));for(let[s,a]of n){o?r.push(`## ${s}`):r.push(`# UI Feedback: ${s}`),r.push("");let c=o?"###":"##";a.forEach((d,l)=>{var u,m,g;let h=(u=d.framework)!=null&&u.component?` in \`${d.framework.component}\``:"";r.push(`${c} ${l+1}. ${d.comment}`),r.push(`- Element: \`${d.element}\`${h}`),(g=(m=d.framework)==null?void 0:m.data)!=null&&g.file&&r.push(`- File: \`${d.framework.data.file}\``),d.cssClasses&&r.push(`- Classes: \`${d.cssClasses}\``),d.selectedText?r.push(`- Text: "${d.selectedText}"`):d.nearbyText&&r.push(`- Text: "${d.nearbyText.slice(0,100)}"`),d.screenshot&&(d.screenshot.startsWith("data:")?r.push("- Screenshot: attached"):r.push(`- Screenshot: \`storage/app/_instruckt/${d.screenshot}\``)),r.push("")})}let i=t.some(s=>s.screenshot&&!s.screenshot.startsWith("data:"));return r.push("---"),r.push(""),i?r.push("Use the `instruckt.get_screenshot` MCP tool to view screenshots. After making changes, use `instruckt.resolve` to mark each annotation as resolved."):r.push("After making changes, use the `instruckt.resolve` MCP tool to mark each annotation as resolved."),r.join(`
|
|
450
450
|
`).trim()}getAnnotations(){return[...this.annotations]}destroy(){var t,n,o,r;this.setAnnotating(!1),this.setFrozen(!1),document.removeEventListener("keydown",this.boundKeydown),window.removeEventListener("scroll",this.boundReposition),window.removeEventListener("resize",this.boundReposition),(t=this.toolbar)==null||t.destroy(),(n=this.highlight)==null||n.destroy(),(o=this.popup)==null||o.destroy(),(r=this.markers)==null||r.destroy(),this.rafId!==null&&cancelAnimationFrame(this.rafId),this.pollTimer!==null&&clearInterval(this.pollTimer)}};j.STORAGE_KEY="instruckt:annotations";var H=j;function Kn(e){return new H(e)}return de(Xn);})();
|
|
451
451
|
//# sourceMappingURL=instruckt.iife.js.map
|