feedbackkit-web 1.0.41 → 1.0.42
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/feedbackkit.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var FeedbackKit=(function(){"use strict";async function Dt(t={}){const e=Math.min(window.devicePixelRatio||1,t.maxPixelRatio??2);if(t.mode==="display")try{const n=await Ze(e);if(n)return n}catch{}return Xe(e,t.exclude)}const rt="data-feedbackkit-pin";async function Xe(t,e){const n=window.innerWidth,r=window.innerHeight,o=Ye(e),s=document.documentElement,i=getComputedStyle(document.body).backgroundColor,a=getComputedStyle(s).backgroundColor,c=$t(a)?$t(i)?"#ffffff":i:a;try{const{domToCanvas:l}=await Promise.resolve().then(()=>Jr);return{canvas:await l(s,{width:n,height:r,scale:t,backgroundColor:c,filter:e?h=>!e(h):null,features:{restoreScrollPosition:!0},timeout:8e3,onCloneEachNode:h=>{if(!(h instanceof HTMLElement))return;h.tagName==="BODY"&&!h.style.transform&&(h.style.transform="translate(0px, 0px)");const f=h.getAttribute(rt);if(f===null)return;h.removeAttribute(rt);const u=o.info.get(f);if(!u)return;const m=h.style;u.kind==="sticky"?(m.setProperty("position","relative","important"),m.setProperty("inset","auto","important"),m.setProperty("top",`${u.top}px`,"important"),m.setProperty("left",`${u.left}px`,"important")):(m.setProperty("position","fixed","important"),m.setProperty("inset","auto","important"),m.setProperty("top",`${u.top}px`,"important"),m.setProperty("left",`${u.left}px`,"important"),m.setProperty("width",`${u.width}px`,"important"),m.setProperty("height",`${u.height}px`,"important"),m.setProperty("margin","0","important"),m.setProperty("box-sizing","border-box","important"),m.setProperty("transform","none","important"),m.setProperty("translate","none","important"))}}),width:n,height:r,pixelRatio:t}}finally{o.cleanup()}}function Ye(t){const e=new Map,n=[],r=document.body;if(!r)return{info:e,cleanup:()=>{}};const o=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>t?.(i)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let s=0;for(let i=o.nextNode();i;i=o.nextNode()){const a=i,c=getComputedStyle(a);if(c.position!=="fixed"&&c.position!=="sticky"||c.display==="none")continue;const l=a.getBoundingClientRect(),d=String(s++);if(c.position==="sticky"){const h=a.style.getPropertyValue("position"),f=a.style.getPropertyPriority("position");a.style.setProperty("position","static","important");const u=a.getBoundingClientRect();a.style.setProperty("position",h,f),h||a.style.removeProperty("position");const m=l.top-u.top,p=l.left-u.left;if(Math.abs(p)<.5&&Math.abs(m)<.5)continue;e.set(d,{kind:"sticky",top:m,left:p,width:l.width,height:l.height})}else{const h=Je(a),f=h.getBoundingClientRect();e.set(d,{kind:"fixed",top:l.top-(f.top+h.clientTop),left:l.left-(f.left+h.clientLeft),width:l.width,height:l.height})}a.setAttribute(rt,d),n.push(a)}return{info:e,cleanup:()=>{for(const i of n)i.removeAttribute(rt)}}}function Je(t){for(let e=t.parentElement;e&&e!==document.body;e=e.parentElement){const n=getComputedStyle(e);if(n.transform!=="none"||n.filter!=="none"||n.perspective!=="none"||n.backdropFilter!==void 0&&n.backdropFilter!=="none"||/paint|layout|strict|content/.test(n.contain)||/transform|filter|perspective/.test(n.willChange))return e;const r=e.parentElement;if(r&&(r.scrollTop!==0||r.scrollLeft!==0))return e}return document.body}function $t(t){return!t||t==="transparent"||/rgba\(\s*0,\s*0,\s*0,\s*0\s*\)/.test(t)}async function Ze(t){if(!navigator.mediaDevices?.getDisplayMedia)return null;const e={video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include"},n=await navigator.mediaDevices.getDisplayMedia(e);try{const r=document.createElement("video");r.muted=!0,r.playsInline=!0,r.srcObject=n,await r.play(),await new Promise(c=>setTimeout(c,250));const o=window.innerWidth,s=window.innerHeight,i=document.createElement("canvas");i.width=Math.round(o*t),i.height=Math.round(s*t);const a=i.getContext("2d");return a?(a.drawImage(r,0,0,i.width,i.height),{canvas:i,width:o,height:s,pixelRatio:t}):null}finally{for(const r of n.getTracks())r.stop()}}function gt(t){return new Promise((e,n)=>{t.toBlob(r=>r?e(r):n(new Error("Failed to encode screenshot")),"image/png")})}function Qe(t){let e="Unknown",n="",r;(r=t.match(/(?:iPhone|iPad|iPod).*?OS (\d+[_.\d]*)/))?(e=/iPad/.test(t)?"iPadOS":"iOS",n=r[1].replace(/_/g,".")):(r=t.match(/Android (\d+(?:\.\d+)*)/))?(e="Android",n=r[1]):(r=t.match(/Windows NT (\d+\.\d+)/))?(e="Windows",n={"10.0":"10","6.3":"8.1","6.2":"8","6.1":"7"}[r[1]]??r[1]):(r=t.match(/Mac OS X (\d+[_.\d]*)/))?(e="macOS",n=r[1].replace(/_/g,".")):/CrOS/.test(t)?e="ChromeOS":/Linux/.test(t)&&(e="Linux");let o="Unknown",s="";const i=[["Edge",/Edg(?:e|A|iOS)?\/([\d.]+)/],["Opera",/(?:OPR|Opera)\/([\d.]+)/],["Samsung Internet",/SamsungBrowser\/([\d.]+)/],["Firefox",/(?:Firefox|FxiOS)\/([\d.]+)/],["Chrome",/(?:Chrome|CriOS)\/([\d.]+)/],["Safari",/Version\/([\d.]+).*Safari/]];for(const[a,c]of i){const l=t.match(c);if(l){o=a,s=l[1];break}}return{osName:e,osVersion:n,browserName:o,browserVersion:s}}const Bt=/token|secret|password|passwd|pwd|auth|session|key|code|signature|sig|jwt|otp|email/i;function Ot(t){try{const e=new URL(t);for(const n of[...e.searchParams.keys()])Bt.test(n)&&e.searchParams.set(n,"[redacted]");return e.hash&&Bt.test(e.hash)&&(e.hash="#[redacted]"),e.toString()}catch{return t}}async function tn(){const t=navigator.userAgentData;if(!t?.getHighEntropyValues)return null;try{return await Promise.race([t.getHighEntropyValues(["platform","platformVersion","fullVersionList"]),new Promise(e=>setTimeout(()=>e(null),300))])}catch{return null}}function en(t,e){const n=t.platform,r=t.platformVersion??"";if(!n)return e;if(n==="macOS")return{osName:"macOS",osVersion:ot(r)};if(n==="Windows"){const o=parseInt(r,10);return{osName:"Windows",osVersion:o>=13?"11":o>0?"10":e.osVersion}}return n==="Android"?{osName:"Android",osVersion:ot(r)||e.osVersion}:n==="Chrome OS"||n==="ChromeOS"?{osName:"ChromeOS",osVersion:ot(r)}:{osName:n,osVersion:ot(r)||e.osVersion}}function ot(t){return t.replace(/(\.0)+$/,"")}function nn(t){const e=t.fullVersionList??[],n=["Microsoft Edge","Opera","Google Chrome","Chromium"];for(const r of n){const o=e.find(s=>s.brand===r);if(o)return{name:r==="Microsoft Edge"?"Edge":r==="Google Chrome"?"Chrome":r,version:o.version}}return null}async function rn(t={}){const e=navigator.userAgent,n=Qe(e),r=await tn(),o=r?en(r,n):n,s=r&&nn(r)||{name:n.browserName,version:n.browserVersion},i=s.version.split(".")[0];return{osName:o.osName,osVersion:o.osVersion,deviceModel:i?`${s.name} ${i}`:s.name,appVersion:t.appVersion??"",appBuild:t.appBuild??"",bundleIdentifier:location.host,screenName:t.screenName||location.pathname||null,locale:navigator.language||"en",screenWidthPoints:window.innerWidth,screenHeightPoints:window.innerHeight,screenScale:window.devicePixelRatio||1,platform:"web",pageUrl:Ot(location.href),userAgent:e,browserName:s.name,browserVersion:s.version}}const Ut=1e3;function on(t){return t.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,"[redacted-jwt]").replace(/https?:\/\/[^\s"'<>)]+/g,e=>Ot(e)).replace(/("?(?:password|passwd|secret|token|api[_-]?key|access[_-]?token|refresh[_-]?token)"?\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s,}&]+)/gi,"$1[redacted]")}function st(t){if(typeof t=="string")return t;if(t instanceof Error)return t.stack||`${t.name}: ${t.message}`;if(t===void 0)return"undefined";if(typeof t=="function")return`[function ${t.name||"anonymous"}]`;if(typeof Element<"u"&&t instanceof Element)return`<${t.tagName.toLowerCase()}>`;try{const e=new WeakSet;return JSON.stringify(t,(n,r)=>{if(typeof r=="object"&&r!==null){if(e.has(r))return"[circular]";e.add(r)}return typeof r=="bigint"?r.toString():r})}catch{return String(t)}}class sn{constructor(e=50){this.maxEntries=e,this.entries=[]}push(e,n){let r=on(n);r.length>Ut&&(r=`${r.slice(0,Ut)}… [truncated]`),this.entries.push({level:e,message:r,timestamp:new Date().toISOString()}),this.entries.length>this.maxEntries&&this.entries.splice(0,this.entries.length-this.maxEntries)}snapshot(){return this.entries.slice()}clear(){this.entries=[]}}function an(t={}){const e=new sn(t.maxEntries??50),n=[],r=t.includeVerbose?["log","info","warn","error","debug"]:["warn","error"];for(const i of r){const a=console[i];console[i]=function(...c){try{e.push(i,c.map(st).join(" "))}catch{}return a.apply(this,c)},n.push(()=>{console[i]=a})}const o=i=>{const a=i.filename?` (${i.filename}:${i.lineno}:${i.colno})`:"";e.push("error",`Uncaught ${i.error?st(i.error):i.message}${a}`)},s=i=>{e.push("error",`Unhandled promise rejection: ${st(i.reason)}`)};return window.addEventListener("error",o),window.addEventListener("unhandledrejection",s),n.push(()=>{window.removeEventListener("error",o),window.removeEventListener("unhandledrejection",s)}),t.network!==!1&&n.push(ln(e),dn(e)),{buffer:e,uninstall:()=>{for(const i of n.reverse())i()}}}let yt=null;function cn(t){yt=t}function bt(t){return!!yt&&t.startsWith(yt)}function ln(t){if(typeof window.fetch!="function")return()=>{};const e=window.fetch;return window.fetch=async function(n,r){const o=(r?.method||(n instanceof Request?n.method:"GET")).toUpperCase(),s=n instanceof Request?n.url:String(n);try{const i=await e.call(window,n,r);return i.status>=400&&!bt(s)&&t.push("network",`${o} ${s} → ${i.status} ${i.statusText}`.trim()),i}catch(i){throw!bt(s)&&!(i instanceof DOMException&&i.name==="AbortError")&&t.push("network",`${o} ${s} → failed: ${st(i)}`),i}},()=>{window.fetch=e}}function dn(t){if(typeof XMLHttpRequest>"u")return()=>{};const e=XMLHttpRequest.prototype,n=e.open,r=e.send,o=new WeakMap;return e.open=function(s,i,...a){return o.set(this,{method:String(s).toUpperCase(),url:String(i)}),n.call(this,s,i,...a)},e.send=function(s){return this.addEventListener("loadend",()=>{const i=o.get(this);!i||bt(i.url)||(this.status===0?t.push("network",`${i.method} ${i.url} → failed (network error)`):this.status>=400&&t.push("network",`${i.method} ${i.url} → ${this.status} ${this.statusText}`.trim()))}),r.call(this,s)},()=>{e.open=n,e.send=r}}const j="https://gpucoladcyvijefdjudf.supabase.co/functions/v1/ingest-feedback";class I extends Error{constructor(e,n,r){super(e),this.kind=n,this.status=r,this.name="FeedbackSubmissionError"}}async function H(t){const e=new Uint8Array(await t.arrayBuffer());let n="";const r=32768;for(let o=0;o<e.length;o+=r)n+=String.fromCharCode(...e.subarray(o,o+r));return btoa(n)}async function hn(t,e,n={}){const r={project_key:e,id:t.id,created_at:t.createdAt.toISOString(),text:t.text,annotations:t.annotations,environment:t.environment};if(t.screenshotRaw&&t.screenshotAnnotated){const[o,s]=await Promise.all([H(t.screenshotRaw),H(t.screenshotAnnotated)]);r.screenshot_raw_png_base64=o,r.screenshot_annotated_png_base64=s}return t.attachment&&(r.attachment_filename=t.attachment.filename,r.attachment_mime_type=t.attachment.mimeType,r.attachment_data_base64=await H(t.attachment.data)),t.products.length>0&&(r.product_keys=t.products.map(o=>o.key),r.products=t.products.map(o=>({key:o.key,name:o.name,description:o.description??"",is_default:o.isDefault??!1}))),t.logs.length>0&&(r.logs=t.logs),n.reporterId&&(r.reporter_id=n.reporterId),n.user&&(r.reporter=n.user),r}async function jt(t,e,n={}){if(!e.projectKey)throw new I("FeedbackKit is not configured with a project key.","not_configured");const r=JSON.stringify(await hn(t,e.projectKey,n));let o;try{o=await fetch(e.endpoint??j,{method:"POST",headers:{"Content-Type":"application/json"},body:r})}catch(s){throw new I(`Network error: ${s instanceof Error?s.message:String(s)}`,"network")}if(!o.ok){let s="";try{s=(await o.json()).error??""}catch{}const i=s?` (${s})`:"",a=s==="origin_not_allowed"?`This site (${location.origin}) isn't in the project's allowed origins.`:o.status===401||o.status===403?`Server rejected the project key or origin (HTTP ${o.status})${i}.`:o.status===429?"Too many reports right now — please try again in a minute.":`Server returned HTTP ${o.status}${i}.`;throw new I(a,"server",o.status)}}async function un(t){const e=new URL(t.endpoint??j);e.searchParams.set("project_key",t.projectKey);const n=await fetch(e.toString());if(!n.ok)throw new I(`HTTP ${n.status}`,"server",n.status);return((await n.json()).products??[]).map(o=>({key:o.key,name:o.name,description:o.description??"",isDefault:o.is_default??!1}))}const Ht="feedbackkit.reporterId",fn=/^[A-Za-z0-9_-]{16,128}$/;let V=null,Vt=null;function zt(){const t=new Uint8Array(16);return crypto.getRandomValues(t),[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function z(){if(V)return V;try{const t=localStorage.getItem(Ht);if(t&&fn.test(t))return V=t;const e=zt();return localStorage.setItem(Ht,e),V=e}catch{return V=zt()}}function pn(t){Vt=t&&(t.id||t.email||t.name)?{...t}:null}function Wt(){return Vt}function Kt(t){if(t.reporterUpdatesEndpoint)return t.reporterUpdatesEndpoint;const e=new URL(t.endpoint??j);return e.pathname=e.pathname.replace(/\/[^/]*\/?$/,"/reporter-updates"),e.search="",e.toString()}function mn(t){return{feedbackId:t.feedback_id,text:t.text??"",createdAt:t.created_at??"",screenName:t.screen_name??null,fixStage:t.fix_stage??null,fixedInBuild:t.fixed_in_build??null,fixSummary:t.fix_summary??null,needsVerification:t.needs_verification??!1,openQuestion:t.open_question?{id:t.open_question.id,body:t.open_question.body,createdAt:t.open_question.created_at}:null,screenshotUrl:t.screenshot_url??null,messages:(t.messages??[]).map(e=>({id:e.id,kind:e.kind,body:e.body,author:e.author,createdAt:e.created_at}))}}async function qt(t){const e=new URL(Kt(t));e.searchParams.set("project_key",t.projectKey),e.searchParams.set("reporter_id",z()),t.appBuild&&e.searchParams.set("build",t.appBuild);let n;try{n=await fetch(e.toString())}catch(o){throw new I(`Network error: ${o instanceof Error?o.message:String(o)}`,"network")}if(!n.ok)throw new I(`HTTP ${n.status}`,"server",n.status);return((await n.json()).updates??[]).map(mn)}async function gn(t,e,n){const r={project_key:t.projectKey,reporter_id:z(),feedback_id:e,action:n.type};if(t.appBuild&&(r.build=t.appBuild),n.type==="reply"&&(r.text=n.text),n.type==="reopen"){const o=n.report,s=o?.text??n.text;s&&(r.text=s),o?.screenshotAnnotated&&(r.screenshot_annotated_png_base64=await H(o.screenshotAnnotated),o.screenshotRaw&&(r.screenshot_raw_png_base64=await H(o.screenshotRaw)),r.annotations=o.annotations)}return r}async function wt(t,e,n){const r=JSON.stringify(await gn(t,e,n));let o;try{o=await fetch(Kt(t),{method:"POST",headers:{"Content-Type":"application/json"},body:r})}catch(s){throw new I(`Network error: ${s instanceof Error?s.message:String(s)}`,"network")}if(!o.ok)throw new I(`HTTP ${o.status}`,"server",o.status)}const C=t=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`,v={feedback:C('<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12Z"/><path d="M8.5 10.5h7M8.5 14h4.5"/>'),pen:C('<path d="M4 20l4-1L19 8a2.1 2.1 0 0 0-3-3L5 16l-1 4Z"/><path d="M14.5 6.5l3 3"/>'),rectangle:C('<rect x="4" y="6" width="16" height="12" rx="1.5"/>'),arrow:C('<path d="M6 18L18 6"/><path d="M9 6h9v9"/>'),text:C('<path d="M5 6V5h14v1"/><path d="M12 5v14"/><path d="M9 19h6"/>'),move:C('<path d="M12 3v18M3 12h18"/><path d="M9 6l3-3 3 3M9 18l3 3 3-3M6 9l-3 3 3 3M18 9l3 3-3 3"/>'),undo:C('<path d="M9 14L4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>'),trash:C('<path d="M4 7h16"/><path d="M10 11v6M14 11v6"/><path d="M6 7l1 13h10l1-13"/><path d="M9 7V4h6v3"/>'),close:C('<path d="M6 6l12 12M18 6L6 18"/>'),paperclip:C('<path d="M21 11.5l-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l7.9-7.9"/>'),send:C('<path d="M4 12l16-8-6 16-3-7-7-1Z"/>'),check:C('<path d="M5 12.5l4.5 4.5L19 7.5"/>')};class yn{constructor(e,n,r){this.shadow=e,this.update=n,this.onOutcome=r,this.root=null,this.settled=!1}show(e){const n=this.update,r=_("section","fk-fixcard");r.dataset.position=e,r.setAttribute("role","dialog"),r.setAttribute("aria-labelledby","fk-fixcard-title");const o=_("div","fk-fixcard-header"),s=_("h2","fk-title");s.id="fk-fixcard-title",s.textContent=n.needsVerification?"We fixed something you reported":"A question about your report";const i=document.createElement("button");if(i.type="button",i.className="fk-close",i.innerHTML=v.close,i.setAttribute("aria-label","Remind me later"),i.title="Remind me later",i.addEventListener("click",()=>this.settle({type:"later"})),o.append(s,i),r.append(o),n.needsVerification&&n.fixedInBuild&&r.append(R("p","fk-meta",`Fixed in build ${n.fixedInBuild}.`)),n.screenshotUrl){const c=document.createElement("img");c.className="fk-fixcard-shot",c.alt="Your screenshot from the original report",c.src=n.screenshotUrl,c.addEventListener("error",()=>c.remove()),r.append(c)}r.append(R("p","fk-meta","You reported")),r.append(R("p","fk-fixcard-quote",n.text?`“${n.text}”`:"(no description)")),n.needsVerification&&n.fixSummary&&r.append(R("p","fk-fixcard-summary",`What changed: ${n.fixSummary}`));for(const c of n.messages.filter(l=>l.kind==="comment")){const l=_("div","fk-fixcard-message");l.append(R("span","fk-meta",c.author),R("p","",c.body)),r.append(l)}const a=_("div","fk-fixcard-actions");if(n.needsVerification){const c=kt("fk-btn fk-btn-primary","Yes, it's fixed");c.addEventListener("click",()=>this.settle({type:"verified"}));const l=kt("fk-btn fk-btn-secondary","No, still broken");l.addEventListener("click",()=>this.settle({type:"stillBroken"})),a.append(c,l)}else if(n.openQuestion){a.append(R("p","fk-fixcard-question",n.openQuestion.body));const c=document.createElement("textarea");c.className="fk-textarea",c.placeholder="Your answer",c.setAttribute("aria-label","Your answer");const l=kt("fk-btn fk-btn-primary","Send");l.disabled=!0,c.addEventListener("input",()=>l.disabled=c.value.trim()===""),l.addEventListener("click",()=>this.settle({type:"replied",text:c.value.trim()})),a.append(c,l)}r.append(a),this.root=r,this.shadow.append(r)}dismiss(){this.settle({type:"later"})}remove(){this.settled=!0,this.root?.remove(),this.root=null}settle(e){this.settled||(this.settled=!0,this.root?.remove(),this.root=null,this.onOutcome(e))}}function _(t,e){const n=document.createElement(t);return e&&(n.className=e),n}function R(t,e,n){const r=_(t,e);return r.textContent=n,r}function kt(t,e){const n=_("button",t);return n.type="button",n.textContent=e,n}const it=4,W=16,at=18,ct=Math.PI/7,xt=16,vt=8,Gt=1.19,Xt="#FF0000";function St(t=1){return`bold ${xt*t}px -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`}function Yt(t){if(Array.isArray(t))return{x:Number(t[0])||0,y:Number(t[1])||0};if(t&&typeof t=="object"){const e=t;return{x:Number(e.x)||0,y:Number(e.y)||0}}return{x:0,y:0}}function Et(t,e){return(t.points??[]).map(n=>{const{x:r,y:o}=Yt(n);return{x:r*e.width,y:o*e.height}})}function Jt(t){if(!t)return Xt;const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(e)||/^[0-9a-fA-F]{8}$/.test(e)?`#${e}`:Xt}function Ct(t,e,n){for(const r of e)Tt(t,r,n)}function Tt(t,e,n){const r=Jt(e.colorHex),o=Et(e,n),s=e.scale??1,i=e.rotation??0;switch(e.kind){case"freehand":bn(t,o,r);break;case"rectangle":o.length===2&&wn(t,o[0],o[1],r,s,i);break;case"arrow":o.length===2&&kn(t,o[0],o[1],r,s,i);break;case"text":o.length>=1&&e.label&&xn(t,e.label,o[0],r,s);break}}function bn(t,e,n){if(e.length!==0){t.save(),t.lineWidth=it,t.lineJoin="round",t.lineCap="round",t.strokeStyle=n,t.beginPath(),t.moveTo(e[0].x,e[0].y),e.length===1&&t.lineTo(e[0].x+.01,e[0].y);for(const r of e.slice(1))t.lineTo(r.x,r.y);t.stroke(),t.restore()}}function wn(t,e,n,r,o,s){const i=K(e,n),a=Qt(i,Math.abs(n.x-e.x)/2*o,Math.abs(n.y-e.y)/2*o,s);t.save(),t.lineWidth=it,t.lineJoin="miter",t.strokeStyle=r,t.beginPath(),t.moveTo(a[0].x,a[0].y);for(const c of a.slice(1))t.lineTo(c.x,c.y);t.closePath(),t.stroke(),t.restore()}function kn(t,e,n,r,o,s){const{start:i,end:a,left:c,right:l}=Zt(e,n,o,s);t.save(),t.lineWidth=it,t.lineJoin="round",t.lineCap="round",t.strokeStyle=r,t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(a.x,a.y),t.lineTo(c.x,c.y),t.moveTo(a.x,a.y),t.lineTo(l.x,l.y),t.stroke(),t.restore()}function Zt(t,e,n=1,r=0){const o=K(t,e),s=lt(q(t,n,o),r,o),i=lt(q(e,n,o),r,o),a=Math.atan2(i.y-s.y,i.x-s.x),c={x:i.x-at*Math.cos(a-ct),y:i.y-at*Math.sin(a-ct)},l={x:i.x-at*Math.cos(a+ct),y:i.y-at*Math.sin(a+ct)};return{start:s,end:i,left:c,right:l}}function xn(t,e,n,r,o){const s=At(t,e,n,o);t.save(),t.fillStyle=r,t.beginPath(),vn(t,s.x,s.y,s.width,s.height,8),t.fill(),t.font=St(o),t.fillStyle="#FFFFFF",t.textBaseline="top",t.fillText(e,s.x+vt,s.y+vt+xt*o*(Gt-1)/2),t.restore()}function vn(t,e,n,r,o,s){const i=Math.min(s,r/2,o/2);t.moveTo(e+i,n),t.arcTo(e+r,n,e+r,n+o,i),t.arcTo(e+r,n+o,e,n+o,i),t.arcTo(e,n+o,e,n,i),t.arcTo(e,n,e+r,n,i),t.closePath()}function At(t,e,n,r=1){const o=t.font;t.font=St(r);const s=t.measureText(e).width;t.font=o;const i=xt*r*Gt,a=vt*r;return{x:n.x,y:n.y,width:s+a*2,height:i+a*2}}function Qt(t,e,n,r){return[{x:t.x-e,y:t.y-n},{x:t.x+e,y:t.y-n},{x:t.x+e,y:t.y+n},{x:t.x-e,y:t.y+n}].map(o=>lt(o,r,t))}function te(t,e,n,r){const o=Et(t,n),s=t.scale??1;switch(t.kind){case"rectangle":{if(o.length!==2)return!1;const i=K(o[0],o[1]),a=Math.abs(o[1].x-o[0].x)/2*s+W,c=Math.abs(o[1].y-o[0].y)/2*s+W;return Math.abs(e.x-i.x)<=a&&Math.abs(e.y-i.y)<=c}case"arrow":{if(o.length!==2)return!1;const i=K(o[0],o[1]);return ee(e,q(o[0],s,i),q(o[1],s,i))<=W}case"text":{if(o.length<1||!t.label)return!1;const i=At(r,t.label,o[0],s),a=W/2;return e.x>=i.x-a&&e.x<=i.x+i.width+a&&e.y>=i.y-a&&e.y<=i.y+i.height+a}case"freehand":return!1}}function K(t,e){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function lt(t,e,n){const r=t.x-n.x,o=t.y-n.y;return{x:n.x+r*Math.cos(e)-o*Math.sin(e),y:n.y+r*Math.sin(e)+o*Math.cos(e)}}function q(t,e,n){return{x:n.x+(t.x-n.x)*e,y:n.y+(t.y-n.y)*e}}function ee(t,e,n){const r=n.x-e.x,o=n.y-e.y,s=r*r+o*o;if(s===0)return Math.hypot(t.x-e.x,t.y-e.y);const i=Math.max(0,Math.min(1,((t.x-e.x)*r+(t.y-e.y)*o)/s));return Math.hypot(t.x-(e.x+i*r),t.y-(e.y+i*o))}const Sn=Object.freeze(Object.defineProperty({__proto__:null,HIT_TEST_TOLERANCE:W,STROKE_WIDTH:it,arrowGeometry:Zt,denormalize:Et,distanceToSegment:ee,drawAnnotation:Tt,drawAnnotations:Ct,hitTest:te,midpoint:K,normalizeColor:Jt,readPoint:Yt,rectangleCorners:Qt,rotate:lt,scaled:q,textBubbleRect:At,textFont:St},Symbol.toStringTag,{value:"Module"})),ne=["#FF3B30","#FFCC00","#34C759","#007AFF","#000000"],re=.3,oe=5;class En{constructor(e){this.shot=e,this.annotations=[],this.tool="pen",this.color=ne[0],this.onChange=()=>{},this.history=[],this.draft=null,this.draftStart=null,this.pointers=new Map,this.drag=null,this.gesture=null,this.selected=null,this.textInput=null,this.displayScale=1,this.element=document.createElement("div"),this.element.className="fk-canvas-box",this.base=document.createElement("canvas"),this.ink=document.createElement("canvas"),this.ink.className="fk-ink",this.ink.setAttribute("role","img"),this.ink.setAttribute("aria-label","Screenshot — draw on it to highlight the problem"),this.element.append(this.base,this.ink);const n=this.ink.getContext("2d");if(!n)throw new Error("Canvas 2D is unavailable");this.inkCtx=n,this.ink.addEventListener("pointerdown",r=>this.onPointerDown(r)),this.ink.addEventListener("pointermove",r=>this.onPointerMove(r)),this.ink.addEventListener("pointerup",r=>this.onPointerUp(r)),this.ink.addEventListener("pointercancel",r=>this.onPointerUp(r)),this.ink.addEventListener("wheel",r=>this.onWheel(r),{passive:!1})}layout(e,n){const r=Math.max(.05,Math.min(e/this.shot.width,n/this.shot.height,1));this.displayScale=r;const o=Math.round(this.shot.width*r),s=Math.round(this.shot.height*r),i=window.devicePixelRatio||1;for(const c of[this.base,this.ink])c.style.width=`${o}px`,c.style.height=`${s}px`,c.width=Math.round(o*i),c.height=Math.round(s*i);const a=this.base.getContext("2d");a&&(a.imageSmoothingQuality="high",a.drawImage(this.shot.canvas,0,0,this.base.width,this.base.height)),this.cancelTextInput(),this.render()}setTool(e){this.commitTextInput(),this.tool=e,this.selected=null,this.ink.style.cursor=e==="move"?"grab":e==="text"?"text":"crosshair",this.render()}undo(){this.commitTextInput();const e=this.history.pop();e&&(this.annotations=e,this.selected=null,this.changed())}clear(){this.annotations.length!==0&&(this.snapshot(),this.annotations=[],this.selected=null,this.changed())}get canUndo(){return this.history.length>0}deleteSelected(){return this.selected===null||!this.annotations[this.selected]?!1:(this.snapshot(),this.annotations.splice(this.selected,1),this.selected=null,this.changed(),!0)}flatten(){this.commitTextInput();const e=document.createElement("canvas");e.width=this.shot.canvas.width,e.height=this.shot.canvas.height;const n=e.getContext("2d");if(!n)throw new Error("Canvas 2D is unavailable");return n.drawImage(this.shot.canvas,0,0),n.scale(e.width/this.shot.width,e.height/this.shot.height),Ct(n,this.annotations,{width:this.shot.width,height:this.shot.height}),e}commitTextInput(){const e=this.textInput;if(!e)return;this.textInput=null;const n=e.value.trim(),r=JSON.parse(e.dataset.origin??"[0,0]");e.remove(),n&&(this.snapshot(),this.annotations.push({kind:"text",points:[r],colorHex:this.color,label:n,scale:1,rotation:0}),this.changed())}cancelTextInput(){this.textInput?.remove(),this.textInput=null}render(){const e=this.inkCtx;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.ink.width,this.ink.height);const n=this.ink.width/this.shot.width;e.setTransform(n,0,0,n,0,0);const r={width:this.shot.width,height:this.shot.height};Ct(e,this.annotations,r),this.draft&&Tt(e,this.draft,r)}changed(){this.render(),this.onChange()}snapshot(){this.history.push(this.annotations.map(e=>({...e,points:e.points.map(n=>[n[0],n[1]])}))),this.history.length>100&&this.history.shift()}toCapture(e){const n=this.ink.getBoundingClientRect();return{x:Math.max(0,Math.min(this.shot.width,(e.clientX-n.left)/this.displayScale)),y:Math.max(0,Math.min(this.shot.height,(e.clientY-n.top)/this.displayScale))}}normalize(e){return[M(e.x/this.shot.width),M(e.y/this.shot.height)]}hitIndex(e){const n={width:this.shot.width,height:this.shot.height};for(let r=this.annotations.length-1;r>=0;r--)if(te(this.annotations[r],e,n,this.inkCtx))return r;return null}onPointerDown(e){if(e.button!==0&&e.pointerType==="mouse")return;e.preventDefault();const n=this.toCapture(e);if(this.ink.setPointerCapture(e.pointerId),this.pointers.set(e.pointerId,n),this.tool==="move"){if(this.pointers.size===2&&this.selected!==null){this.drag=null,this.startGesture();return}const o=this.hitIndex(n);this.selected=o,o!==null&&(this.snapshot(),this.drag={index:o,last:n,moved:!1},this.ink.style.cursor="grabbing");return}if(this.pointers.size>1)return;if(this.tool==="text"){this.commitTextInput(),this.openTextInput(n);return}this.draftStart=n;const r=this.normalize(n);this.draft={kind:this.tool==="pen"?"freehand":this.tool,points:this.tool==="pen"?[r]:[r,r],colorHex:this.color,scale:1,rotation:0},this.render()}onPointerMove(e){if(!this.pointers.has(e.pointerId)){this.tool==="move"&&e.pointerType==="mouse"&&(this.ink.style.cursor=this.hitIndex(this.toCapture(e))!==null?"grab":"default");return}const n=this.toCapture(e);if(this.pointers.set(e.pointerId,n),this.gesture){this.updateGesture();return}if(this.drag){const o=(n.x-this.drag.last.x)/this.shot.width,s=(n.y-this.drag.last.y)/this.shot.height;this.drag.last=n,this.drag.moved=!0;const i=this.annotations[this.drag.index];i.points=i.points.map(([a,c])=>[M(a+o),M(c+s)]),this.render();return}if(!this.draft||!this.draftStart)return;const r=this.normalize(n);if(this.draft.kind==="freehand"){const o=this.draft.points[this.draft.points.length-1];Math.hypot((r[0]-o[0])*this.shot.width,(r[1]-o[1])*this.shot.height)>=1.5&&this.draft.points.push(r)}else this.draft.points=[this.draft.points[0],r];this.render()}onPointerUp(e){if(!this.pointers.has(e.pointerId))return;if(this.pointers.delete(e.pointerId),this.ink.hasPointerCapture(e.pointerId)&&this.ink.releasePointerCapture(e.pointerId),this.gesture){this.pointers.size<2&&(this.gesture=null,this.onChange());return}if(this.drag){this.drag.moved||this.history.pop(),this.drag=null,this.ink.style.cursor="grab",this.onChange();return}const n=this.draft;this.draft=null;const r=this.draftStart;if(this.draftStart=null,!(!n||!r)){if(n.kind!=="freehand"){const[o,s]=n.points;if(Math.hypot((s[0]-o[0])*this.shot.width,(s[1]-o[1])*this.shot.height)<6){this.render();return}}this.snapshot(),this.annotations.push(n),this.changed()}}onWheel(e){if(this.tool!=="move")return;const n=this.toCapture(e),r=this.hitIndex(n)??this.selected;if(r===null||!this.annotations[r])return;e.preventDefault();const o=this.annotations[r];if(o.kind!=="freehand"){if(this.selected=r,e.shiftKey||e.altKey){if(o.kind==="text")return;const s=e.deltaY!==0?e.deltaY:e.deltaX;o.rotation=M(o.rotation+s*.004)}else o.scale=M(se(o.scale*Math.exp(-e.deltaY*(e.ctrlKey?.01:.0015)),re,oe));this.render(),this.onChange()}}startGesture(){if(this.selected===null)return;const[e,n]=[...this.pointers.values()],r=this.annotations[this.selected];this.snapshot(),this.gesture={index:this.selected,startDistance:Math.max(1,Math.hypot(n.x-e.x,n.y-e.y)),startAngle:Math.atan2(n.y-e.y,n.x-e.x),startScale:r.scale,startRotation:r.rotation}}updateGesture(){const e=this.gesture;if(!e||this.pointers.size<2)return;const[n,r]=[...this.pointers.values()],o=this.annotations[e.index];if(!o||o.kind==="freehand")return;const s=Math.hypot(r.x-n.x,r.y-n.y);o.scale=M(se(e.startScale*(s/e.startDistance),re,oe)),o.kind!=="text"&&(o.rotation=M(e.startRotation+(Math.atan2(r.y-n.y,r.x-n.x)-e.startAngle))),this.render()}openTextInput(e){const n=document.createElement("input");n.type="text",n.className="fk-text-input",n.placeholder="Add a note…",n.setAttribute("aria-label","Annotation text"),n.dataset.origin=JSON.stringify(this.normalize(e)),n.style.left=`${Math.min(e.x*this.displayScale,this.shot.width*this.displayScale-130)}px`,n.style.top=`${Math.min(e.y*this.displayScale,this.shot.height*this.displayScale-36)}px`,n.style.borderColor=this.color,n.addEventListener("keydown",r=>{r.stopPropagation(),r.key==="Enter"?this.commitTextInput():r.key==="Escape"&&this.cancelTextInput()}),n.addEventListener("blur",()=>this.commitTextInput()),this.element.append(n),this.textInput=n,requestAnimationFrame(()=>n.focus())}}function se(t,e,n){return Math.max(e,Math.min(n,t))}function M(t){return Math.round(t*1e4)/1e4}const Cn=`
|
|
1
|
+
var FeedbackKit=(function(){"use strict";async function $t(t={}){const e=Math.min(window.devicePixelRatio||1,t.maxPixelRatio??2);if(t.mode==="display")try{const n=await Ze(e);if(n)return n}catch{}return Xe(e,t.exclude)}const rt="data-feedbackkit-pin";async function Xe(t,e){const n=window.innerWidth,r=window.innerHeight,o=Ye(e),s=document.documentElement,i=getComputedStyle(document.body).backgroundColor,a=getComputedStyle(s).backgroundColor,c=Bt(a)?Bt(i)?"#ffffff":i:a;try{const{domToCanvas:l}=await Promise.resolve().then(()=>Jr);return{canvas:await l(s,{width:n,height:r,scale:t,backgroundColor:c,filter:e?h=>!e(h):null,features:{restoreScrollPosition:!0},timeout:8e3,onCloneEachNode:h=>{if(!(h instanceof HTMLElement))return;h.tagName==="BODY"&&!h.style.transform&&(h.style.transform="translate(0px, 0px)");const f=h.getAttribute(rt);if(f===null)return;h.removeAttribute(rt);const u=o.info.get(f);if(!u)return;const m=h.style;u.kind==="sticky"?(m.setProperty("position","relative","important"),m.setProperty("inset","auto","important"),m.setProperty("top",`${u.top}px`,"important"),m.setProperty("left",`${u.left}px`,"important")):(m.setProperty("position","fixed","important"),m.setProperty("inset","auto","important"),m.setProperty("top",`${u.top}px`,"important"),m.setProperty("left",`${u.left}px`,"important"),m.setProperty("width",`${u.width}px`,"important"),m.setProperty("height",`${u.height}px`,"important"),m.setProperty("margin","0","important"),m.setProperty("box-sizing","border-box","important"),m.setProperty("transform","none","important"),m.setProperty("translate","none","important"))}}),width:n,height:r,pixelRatio:t}}finally{o.cleanup()}}function Ye(t){const e=new Map,n=[],r=document.body;if(!r)return{info:e,cleanup:()=>{}};const o=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>t?.(i)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let s=0;for(let i=o.nextNode();i;i=o.nextNode()){const a=i,c=getComputedStyle(a);if(c.position!=="fixed"&&c.position!=="sticky"||c.display==="none")continue;const l=a.getBoundingClientRect(),d=String(s++);if(c.position==="sticky"){const h=a.style.getPropertyValue("position"),f=a.style.getPropertyPriority("position");a.style.setProperty("position","static","important");const u=a.getBoundingClientRect();a.style.setProperty("position",h,f),h||a.style.removeProperty("position");const m=l.top-u.top,p=l.left-u.left;if(Math.abs(p)<.5&&Math.abs(m)<.5)continue;e.set(d,{kind:"sticky",top:m,left:p,width:l.width,height:l.height})}else{const h=Je(a),f=h.getBoundingClientRect();e.set(d,{kind:"fixed",top:l.top-(f.top+h.clientTop),left:l.left-(f.left+h.clientLeft),width:l.width,height:l.height})}a.setAttribute(rt,d),n.push(a)}return{info:e,cleanup:()=>{for(const i of n)i.removeAttribute(rt)}}}function Je(t){for(let e=t.parentElement;e&&e!==document.body;e=e.parentElement){const n=getComputedStyle(e);if(n.transform!=="none"||n.filter!=="none"||n.perspective!=="none"||n.backdropFilter!==void 0&&n.backdropFilter!=="none"||/paint|layout|strict|content/.test(n.contain)||/transform|filter|perspective/.test(n.willChange))return e;const r=e.parentElement;if(r&&(r.scrollTop!==0||r.scrollLeft!==0))return e}return document.body}function Bt(t){return!t||t==="transparent"||/rgba\(\s*0,\s*0,\s*0,\s*0\s*\)/.test(t)}async function Ze(t){if(!navigator.mediaDevices?.getDisplayMedia)return null;const e={video:{displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include"},n=await navigator.mediaDevices.getDisplayMedia(e);try{const r=document.createElement("video");r.muted=!0,r.playsInline=!0,r.srcObject=n,await r.play(),await new Promise(c=>setTimeout(c,250));const o=window.innerWidth,s=window.innerHeight,i=document.createElement("canvas");i.width=Math.round(o*t),i.height=Math.round(s*t);const a=i.getContext("2d");return a?(a.drawImage(r,0,0,i.width,i.height),{canvas:i,width:o,height:s,pixelRatio:t}):null}finally{for(const r of n.getTracks())r.stop()}}function yt(t){return new Promise((e,n)=>{t.toBlob(r=>r?e(r):n(new Error("Failed to encode screenshot")),"image/png")})}function Qe(t){let e="Unknown",n="",r;(r=t.match(/(?:iPhone|iPad|iPod).*?OS (\d+[_.\d]*)/))?(e=/iPad/.test(t)?"iPadOS":"iOS",n=r[1].replace(/_/g,".")):(r=t.match(/Android (\d+(?:\.\d+)*)/))?(e="Android",n=r[1]):(r=t.match(/Windows NT (\d+\.\d+)/))?(e="Windows",n={"10.0":"10","6.3":"8.1","6.2":"8","6.1":"7"}[r[1]]??r[1]):(r=t.match(/Mac OS X (\d+[_.\d]*)/))?(e="macOS",n=r[1].replace(/_/g,".")):/CrOS/.test(t)?e="ChromeOS":/Linux/.test(t)&&(e="Linux");let o="Unknown",s="";const i=[["Edge",/Edg(?:e|A|iOS)?\/([\d.]+)/],["Opera",/(?:OPR|Opera)\/([\d.]+)/],["Samsung Internet",/SamsungBrowser\/([\d.]+)/],["Firefox",/(?:Firefox|FxiOS)\/([\d.]+)/],["Chrome",/(?:Chrome|CriOS)\/([\d.]+)/],["Safari",/Version\/([\d.]+).*Safari/]];for(const[a,c]of i){const l=t.match(c);if(l){o=a,s=l[1];break}}return{osName:e,osVersion:n,browserName:o,browserVersion:s}}const Ot=/token|secret|password|passwd|pwd|auth|session|key|code|signature|sig|jwt|otp|email/i;function Ut(t){try{const e=new URL(t);for(const n of[...e.searchParams.keys()])Ot.test(n)&&e.searchParams.set(n,"[redacted]");return e.hash&&Ot.test(e.hash)&&(e.hash="#[redacted]"),e.toString()}catch{return t}}async function tn(){const t=navigator.userAgentData;if(!t?.getHighEntropyValues)return null;try{return await Promise.race([t.getHighEntropyValues(["platform","platformVersion","fullVersionList"]),new Promise(e=>setTimeout(()=>e(null),300))])}catch{return null}}function en(t,e){const n=t.platform,r=t.platformVersion??"";if(!n)return e;if(n==="macOS")return{osName:"macOS",osVersion:ot(r)};if(n==="Windows"){const o=parseInt(r,10);return{osName:"Windows",osVersion:o>=13?"11":o>0?"10":e.osVersion}}return n==="Android"?{osName:"Android",osVersion:ot(r)||e.osVersion}:n==="Chrome OS"||n==="ChromeOS"?{osName:"ChromeOS",osVersion:ot(r)}:{osName:n,osVersion:ot(r)||e.osVersion}}function ot(t){return t.replace(/(\.0)+$/,"")}function nn(t){const e=t.fullVersionList??[],n=["Microsoft Edge","Opera","Google Chrome","Chromium"];for(const r of n){const o=e.find(s=>s.brand===r);if(o)return{name:r==="Microsoft Edge"?"Edge":r==="Google Chrome"?"Chrome":r,version:o.version}}return null}async function rn(t={}){const e=navigator.userAgent,n=Qe(e),r=await tn(),o=r?en(r,n):n,s=r&&nn(r)||{name:n.browserName,version:n.browserVersion},i=s.version.split(".")[0];return{osName:o.osName,osVersion:o.osVersion,deviceModel:i?`${s.name} ${i}`:s.name,appVersion:t.appVersion??"",appBuild:t.appBuild??"",bundleIdentifier:location.host,screenName:t.screenName||location.pathname||null,locale:navigator.language||"en",screenWidthPoints:window.innerWidth,screenHeightPoints:window.innerHeight,screenScale:window.devicePixelRatio||1,platform:"web",pageUrl:Ut(location.href),userAgent:e,browserName:s.name,browserVersion:s.version}}const jt=1e3;function on(t){return t.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,"[redacted-jwt]").replace(/https?:\/\/[^\s"'<>)]+/g,e=>Ut(e)).replace(/("?(?:password|passwd|secret|token|api[_-]?key|access[_-]?token|refresh[_-]?token)"?\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s,}&]+)/gi,"$1[redacted]")}function st(t){if(typeof t=="string")return t;if(t instanceof Error)return t.stack||`${t.name}: ${t.message}`;if(t===void 0)return"undefined";if(typeof t=="function")return`[function ${t.name||"anonymous"}]`;if(typeof Element<"u"&&t instanceof Element)return`<${t.tagName.toLowerCase()}>`;try{const e=new WeakSet;return JSON.stringify(t,(n,r)=>{if(typeof r=="object"&&r!==null){if(e.has(r))return"[circular]";e.add(r)}return typeof r=="bigint"?r.toString():r})}catch{return String(t)}}class sn{constructor(e=50){this.maxEntries=e,this.entries=[]}push(e,n){let r=on(n);r.length>jt&&(r=`${r.slice(0,jt)}… [truncated]`),this.entries.push({level:e,message:r,timestamp:new Date().toISOString()}),this.entries.length>this.maxEntries&&this.entries.splice(0,this.entries.length-this.maxEntries)}snapshot(){return this.entries.slice()}clear(){this.entries=[]}}function an(t={}){const e=new sn(t.maxEntries??50),n=[],r=t.includeVerbose?["log","info","warn","error","debug"]:["warn","error"];for(const i of r){const a=console[i];console[i]=function(...c){try{e.push(i,c.map(st).join(" "))}catch{}return a.apply(this,c)},n.push(()=>{console[i]=a})}const o=i=>{const a=i.filename?` (${i.filename}:${i.lineno}:${i.colno})`:"";e.push("error",`Uncaught ${i.error?st(i.error):i.message}${a}`)},s=i=>{e.push("error",`Unhandled promise rejection: ${st(i.reason)}`)};return window.addEventListener("error",o),window.addEventListener("unhandledrejection",s),n.push(()=>{window.removeEventListener("error",o),window.removeEventListener("unhandledrejection",s)}),t.network!==!1&&n.push(ln(e),dn(e)),{buffer:e,uninstall:()=>{for(const i of n.reverse())i()}}}let bt=null;function cn(t){bt=t}function wt(t){return!!bt&&t.startsWith(bt)}function ln(t){if(typeof window.fetch!="function")return()=>{};const e=window.fetch;return window.fetch=async function(n,r){const o=(r?.method||(n instanceof Request?n.method:"GET")).toUpperCase(),s=n instanceof Request?n.url:String(n);try{const i=await e.call(window,n,r);return i.status>=400&&!wt(s)&&t.push("network",`${o} ${s} → ${i.status} ${i.statusText}`.trim()),i}catch(i){throw!wt(s)&&!(i instanceof DOMException&&i.name==="AbortError")&&t.push("network",`${o} ${s} → failed: ${st(i)}`),i}},()=>{window.fetch=e}}function dn(t){if(typeof XMLHttpRequest>"u")return()=>{};const e=XMLHttpRequest.prototype,n=e.open,r=e.send,o=new WeakMap;return e.open=function(s,i,...a){return o.set(this,{method:String(s).toUpperCase(),url:String(i)}),n.call(this,s,i,...a)},e.send=function(s){return this.addEventListener("loadend",()=>{const i=o.get(this);!i||wt(i.url)||(this.status===0?t.push("network",`${i.method} ${i.url} → failed (network error)`):this.status>=400&&t.push("network",`${i.method} ${i.url} → ${this.status} ${this.statusText}`.trim()))}),r.call(this,s)},()=>{e.open=n,e.send=r}}const j="https://gpucoladcyvijefdjudf.supabase.co/functions/v1/ingest-feedback";class I extends Error{constructor(e,n,r){super(e),this.kind=n,this.status=r,this.name="FeedbackSubmissionError"}}async function H(t){const e=new Uint8Array(await t.arrayBuffer());let n="";const r=32768;for(let o=0;o<e.length;o+=r)n+=String.fromCharCode(...e.subarray(o,o+r));return btoa(n)}async function hn(t,e,n={}){const r={project_key:e,id:t.id,created_at:t.createdAt.toISOString(),text:t.text,annotations:t.annotations,environment:t.environment};if(t.screenshotRaw&&t.screenshotAnnotated){const[o,s]=await Promise.all([H(t.screenshotRaw),H(t.screenshotAnnotated)]);r.screenshot_raw_png_base64=o,r.screenshot_annotated_png_base64=s}return t.attachment&&(r.attachment_filename=t.attachment.filename,r.attachment_mime_type=t.attachment.mimeType,r.attachment_data_base64=await H(t.attachment.data)),t.products.length>0&&(r.product_keys=t.products.map(o=>o.key),r.products=t.products.map(o=>({key:o.key,name:o.name,description:o.description??"",is_default:o.isDefault??!1}))),t.logs.length>0&&(r.logs=t.logs),n.reporterId&&(r.reporter_id=n.reporterId),n.user&&(r.reporter=n.user),r}async function Ht(t,e,n={}){if(!e.projectKey)throw new I("FeedbackKit is not configured with a project key.","not_configured");const r=JSON.stringify(await hn(t,e.projectKey,n));let o;try{o=await fetch(e.endpoint??j,{method:"POST",headers:{"Content-Type":"application/json"},body:r})}catch(s){throw new I(`Network error: ${s instanceof Error?s.message:String(s)}`,"network")}if(!o.ok){let s="";try{s=(await o.json()).error??""}catch{}const i=s?` (${s})`:"",a=s==="origin_not_allowed"?`This site (${location.origin}) isn't in the project's allowed origins.`:o.status===401||o.status===403?`Server rejected the project key or origin (HTTP ${o.status})${i}.`:o.status===429?"Too many reports right now — please try again in a minute.":`Server returned HTTP ${o.status}${i}.`;throw new I(a,"server",o.status)}}async function un(t){const e=new URL(t.endpoint??j);e.searchParams.set("project_key",t.projectKey);const n=await fetch(e.toString());if(!n.ok)throw new I(`HTTP ${n.status}`,"server",n.status);return((await n.json()).products??[]).map(o=>({key:o.key,name:o.name,description:o.description??"",isDefault:o.is_default??!1}))}const Vt="feedbackkit.reporterId",fn=/^[A-Za-z0-9_-]{16,128}$/;let V=null,zt=null;function Wt(){const t=new Uint8Array(16);return crypto.getRandomValues(t),[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function z(){if(V)return V;try{const t=localStorage.getItem(Vt);if(t&&fn.test(t))return V=t;const e=Wt();return localStorage.setItem(Vt,e),V=e}catch{return V=Wt()}}function pn(t){zt=t&&(t.id||t.email||t.name)?{...t}:null}function Kt(){return zt}function qt(t){if(t.reporterUpdatesEndpoint)return t.reporterUpdatesEndpoint;const e=new URL(t.endpoint??j);return e.pathname=e.pathname.replace(/\/[^/]*\/?$/,"/reporter-updates"),e.search="",e.toString()}function mn(t){return{feedbackId:t.feedback_id,text:t.text??"",createdAt:t.created_at??"",screenName:t.screen_name??null,fixStage:t.fix_stage??null,fixedInBuild:t.fixed_in_build??null,fixSummary:t.fix_summary??null,needsVerification:t.needs_verification??!1,openQuestion:t.open_question?{id:t.open_question.id,body:t.open_question.body,createdAt:t.open_question.created_at}:null,screenshotUrl:t.screenshot_url??null,messages:(t.messages??[]).map(e=>({id:e.id,kind:e.kind,body:e.body,author:e.author,createdAt:e.created_at}))}}async function Gt(t){const e=new URL(qt(t));e.searchParams.set("project_key",t.projectKey),e.searchParams.set("reporter_id",z()),t.appBuild&&e.searchParams.set("build",t.appBuild);let n;try{n=await fetch(e.toString())}catch(o){throw new I(`Network error: ${o instanceof Error?o.message:String(o)}`,"network")}if(!n.ok)throw new I(`HTTP ${n.status}`,"server",n.status);return((await n.json()).updates??[]).map(mn)}async function gn(t,e,n){const r={project_key:t.projectKey,reporter_id:z(),feedback_id:e,action:n.type};if(t.appBuild&&(r.build=t.appBuild),n.type==="reply"&&(r.text=n.text),n.type==="reopen"){const o=n.report,s=o?.text??n.text;s&&(r.text=s),o?.screenshotAnnotated&&(r.screenshot_annotated_png_base64=await H(o.screenshotAnnotated),o.screenshotRaw&&(r.screenshot_raw_png_base64=await H(o.screenshotRaw)),r.annotations=o.annotations)}return r}async function kt(t,e,n){const r=JSON.stringify(await gn(t,e,n));let o;try{o=await fetch(qt(t),{method:"POST",headers:{"Content-Type":"application/json"},body:r})}catch(s){throw new I(`Network error: ${s instanceof Error?s.message:String(s)}`,"network")}if(!o.ok)throw new I(`HTTP ${o.status}`,"server",o.status)}const C=t=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`,v={feedback:C('<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12Z"/><path d="M8.5 10.5h7M8.5 14h4.5"/>'),pen:C('<path d="M4 20l4-1L19 8a2.1 2.1 0 0 0-3-3L5 16l-1 4Z"/><path d="M14.5 6.5l3 3"/>'),rectangle:C('<rect x="4" y="6" width="16" height="12" rx="1.5"/>'),arrow:C('<path d="M6 18L18 6"/><path d="M9 6h9v9"/>'),text:C('<path d="M5 6V5h14v1"/><path d="M12 5v14"/><path d="M9 19h6"/>'),move:C('<path d="M12 3v18M3 12h18"/><path d="M9 6l3-3 3 3M9 18l3 3 3-3M6 9l-3 3 3 3M18 9l3 3-3 3"/>'),undo:C('<path d="M9 14L4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>'),trash:C('<path d="M4 7h16"/><path d="M10 11v6M14 11v6"/><path d="M6 7l1 13h10l1-13"/><path d="M9 7V4h6v3"/>'),close:C('<path d="M6 6l12 12M18 6L6 18"/>'),paperclip:C('<path d="M21 11.5l-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l7.9-7.9"/>'),send:C('<path d="M4 12l16-8-6 16-3-7-7-1Z"/>'),check:C('<path d="M5 12.5l4.5 4.5L19 7.5"/>')};class yn{constructor(e,n,r){this.shadow=e,this.update=n,this.onOutcome=r,this.root=null,this.settled=!1}show(e){const n=this.update,r=_("section","fk-fixcard");r.dataset.position=e,r.setAttribute("role","dialog"),r.setAttribute("aria-labelledby","fk-fixcard-title");const o=_("div","fk-fixcard-header"),s=_("h2","fk-title");s.id="fk-fixcard-title",s.textContent=n.needsVerification?"We fixed something you reported":"A question about your report";const i=document.createElement("button");if(i.type="button",i.className="fk-close",i.innerHTML=v.close,i.setAttribute("aria-label","Remind me later"),i.title="Remind me later",i.addEventListener("click",()=>this.settle({type:"later"})),o.append(s,i),r.append(o),n.needsVerification&&n.fixedInBuild&&r.append(R("p","fk-meta",`Fixed in build ${n.fixedInBuild}.`)),n.screenshotUrl){const c=document.createElement("img");c.className="fk-fixcard-shot",c.alt="Your screenshot from the original report",c.src=n.screenshotUrl,c.addEventListener("error",()=>c.remove()),r.append(c)}r.append(R("p","fk-meta","You reported")),r.append(R("p","fk-fixcard-quote",n.text?`“${n.text}”`:"(no description)")),n.needsVerification&&n.fixSummary&&r.append(R("p","fk-fixcard-summary",`What changed: ${n.fixSummary}`));for(const c of n.messages.filter(l=>l.kind==="comment")){const l=_("div","fk-fixcard-message");l.append(R("span","fk-meta",c.author),R("p","",c.body)),r.append(l)}const a=_("div","fk-fixcard-actions");if(n.needsVerification){const c=xt("fk-btn fk-btn-primary","Yes, it's fixed");c.addEventListener("click",()=>this.settle({type:"verified"}));const l=xt("fk-btn fk-btn-secondary","No, still broken");l.addEventListener("click",()=>this.settle({type:"stillBroken"})),a.append(c,l)}else if(n.openQuestion){a.append(R("p","fk-fixcard-question",n.openQuestion.body));const c=document.createElement("textarea");c.className="fk-textarea",c.placeholder="Your answer",c.setAttribute("aria-label","Your answer");const l=xt("fk-btn fk-btn-primary","Send");l.disabled=!0,c.addEventListener("input",()=>l.disabled=c.value.trim()===""),l.addEventListener("click",()=>this.settle({type:"replied",text:c.value.trim()})),a.append(c,l)}r.append(a),this.root=r,this.shadow.append(r)}dismiss(){this.settle({type:"later"})}remove(){this.settled=!0,this.root?.remove(),this.root=null}settle(e){this.settled||(this.settled=!0,this.root?.remove(),this.root=null,this.onOutcome(e))}}function _(t,e){const n=document.createElement(t);return e&&(n.className=e),n}function R(t,e,n){const r=_(t,e);return r.textContent=n,r}function xt(t,e){const n=_("button",t);return n.type="button",n.textContent=e,n}const it=4,W=16,at=18,ct=Math.PI/7,vt=16,St=8,Xt=1.19,Yt="#FF0000";function Et(t=1){return`bold ${vt*t}px -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`}function Jt(t){if(Array.isArray(t))return{x:Number(t[0])||0,y:Number(t[1])||0};if(t&&typeof t=="object"){const e=t;return{x:Number(e.x)||0,y:Number(e.y)||0}}return{x:0,y:0}}function Ct(t,e){return(t.points??[]).map(n=>{const{x:r,y:o}=Jt(n);return{x:r*e.width,y:o*e.height}})}function Zt(t){if(!t)return Yt;const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(e)||/^[0-9a-fA-F]{8}$/.test(e)?`#${e}`:Yt}function Tt(t,e,n){for(const r of e)At(t,r,n)}function At(t,e,n){const r=Zt(e.colorHex),o=Ct(e,n),s=e.scale??1,i=e.rotation??0;switch(e.kind){case"freehand":bn(t,o,r);break;case"rectangle":o.length===2&&wn(t,o[0],o[1],r,s,i);break;case"arrow":o.length===2&&kn(t,o[0],o[1],r,s,i);break;case"text":o.length>=1&&e.label&&xn(t,e.label,o[0],r,s);break}}function bn(t,e,n){if(e.length!==0){t.save(),t.lineWidth=it,t.lineJoin="round",t.lineCap="round",t.strokeStyle=n,t.beginPath(),t.moveTo(e[0].x,e[0].y),e.length===1&&t.lineTo(e[0].x+.01,e[0].y);for(const r of e.slice(1))t.lineTo(r.x,r.y);t.stroke(),t.restore()}}function wn(t,e,n,r,o,s){const i=K(e,n),a=te(i,Math.abs(n.x-e.x)/2*o,Math.abs(n.y-e.y)/2*o,s);t.save(),t.lineWidth=it,t.lineJoin="miter",t.strokeStyle=r,t.beginPath(),t.moveTo(a[0].x,a[0].y);for(const c of a.slice(1))t.lineTo(c.x,c.y);t.closePath(),t.stroke(),t.restore()}function kn(t,e,n,r,o,s){const{start:i,end:a,left:c,right:l}=Qt(e,n,o,s);t.save(),t.lineWidth=it,t.lineJoin="round",t.lineCap="round",t.strokeStyle=r,t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(a.x,a.y),t.lineTo(c.x,c.y),t.moveTo(a.x,a.y),t.lineTo(l.x,l.y),t.stroke(),t.restore()}function Qt(t,e,n=1,r=0){const o=K(t,e),s=lt(q(t,n,o),r,o),i=lt(q(e,n,o),r,o),a=Math.atan2(i.y-s.y,i.x-s.x),c={x:i.x-at*Math.cos(a-ct),y:i.y-at*Math.sin(a-ct)},l={x:i.x-at*Math.cos(a+ct),y:i.y-at*Math.sin(a+ct)};return{start:s,end:i,left:c,right:l}}function xn(t,e,n,r,o){const s=Pt(t,e,n,o);t.save(),t.fillStyle=r,t.beginPath(),vn(t,s.x,s.y,s.width,s.height,8),t.fill(),t.font=Et(o),t.fillStyle="#FFFFFF",t.textBaseline="top",t.fillText(e,s.x+St,s.y+St+vt*o*(Xt-1)/2),t.restore()}function vn(t,e,n,r,o,s){const i=Math.min(s,r/2,o/2);t.moveTo(e+i,n),t.arcTo(e+r,n,e+r,n+o,i),t.arcTo(e+r,n+o,e,n+o,i),t.arcTo(e,n+o,e,n,i),t.arcTo(e,n,e+r,n,i),t.closePath()}function Pt(t,e,n,r=1){const o=t.font;t.font=Et(r);const s=t.measureText(e).width;t.font=o;const i=vt*r*Xt,a=St*r;return{x:n.x,y:n.y,width:s+a*2,height:i+a*2}}function te(t,e,n,r){return[{x:t.x-e,y:t.y-n},{x:t.x+e,y:t.y-n},{x:t.x+e,y:t.y+n},{x:t.x-e,y:t.y+n}].map(o=>lt(o,r,t))}function ee(t,e,n,r){const o=Ct(t,n),s=t.scale??1;switch(t.kind){case"rectangle":{if(o.length!==2)return!1;const i=K(o[0],o[1]),a=Math.abs(o[1].x-o[0].x)/2*s+W,c=Math.abs(o[1].y-o[0].y)/2*s+W;return Math.abs(e.x-i.x)<=a&&Math.abs(e.y-i.y)<=c}case"arrow":{if(o.length!==2)return!1;const i=K(o[0],o[1]);return ne(e,q(o[0],s,i),q(o[1],s,i))<=W}case"text":{if(o.length<1||!t.label)return!1;const i=Pt(r,t.label,o[0],s),a=W/2;return e.x>=i.x-a&&e.x<=i.x+i.width+a&&e.y>=i.y-a&&e.y<=i.y+i.height+a}case"freehand":return!1}}function K(t,e){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function lt(t,e,n){const r=t.x-n.x,o=t.y-n.y;return{x:n.x+r*Math.cos(e)-o*Math.sin(e),y:n.y+r*Math.sin(e)+o*Math.cos(e)}}function q(t,e,n){return{x:n.x+(t.x-n.x)*e,y:n.y+(t.y-n.y)*e}}function ne(t,e,n){const r=n.x-e.x,o=n.y-e.y,s=r*r+o*o;if(s===0)return Math.hypot(t.x-e.x,t.y-e.y);const i=Math.max(0,Math.min(1,((t.x-e.x)*r+(t.y-e.y)*o)/s));return Math.hypot(t.x-(e.x+i*r),t.y-(e.y+i*o))}const Sn=Object.freeze(Object.defineProperty({__proto__:null,HIT_TEST_TOLERANCE:W,STROKE_WIDTH:it,arrowGeometry:Qt,denormalize:Ct,distanceToSegment:ne,drawAnnotation:At,drawAnnotations:Tt,hitTest:ee,midpoint:K,normalizeColor:Zt,readPoint:Jt,rectangleCorners:te,rotate:lt,scaled:q,textBubbleRect:Pt,textFont:Et},Symbol.toStringTag,{value:"Module"})),re=["#FF3B30","#FFCC00","#34C759","#007AFF","#000000"],oe=.3,se=5;class En{constructor(e){this.shot=e,this.annotations=[],this.tool="pen",this.color=re[0],this.onChange=()=>{},this.history=[],this.draft=null,this.draftStart=null,this.pointers=new Map,this.drag=null,this.gesture=null,this.selected=null,this.textInput=null,this.displayScale=1,this.element=document.createElement("div"),this.element.className="fk-canvas-box",this.base=document.createElement("canvas"),this.ink=document.createElement("canvas"),this.ink.className="fk-ink",this.ink.setAttribute("role","img"),this.ink.setAttribute("aria-label","Screenshot — draw on it to highlight the problem"),this.element.append(this.base,this.ink);const n=this.ink.getContext("2d");if(!n)throw new Error("Canvas 2D is unavailable");this.inkCtx=n,this.ink.addEventListener("pointerdown",r=>this.onPointerDown(r)),this.ink.addEventListener("pointermove",r=>this.onPointerMove(r)),this.ink.addEventListener("pointerup",r=>this.onPointerUp(r)),this.ink.addEventListener("pointercancel",r=>this.onPointerUp(r)),this.ink.addEventListener("wheel",r=>this.onWheel(r),{passive:!1})}layout(e,n){const r=Math.max(.05,Math.min(e/this.shot.width,n/this.shot.height,1));this.displayScale=r;const o=Math.round(this.shot.width*r),s=Math.round(this.shot.height*r),i=window.devicePixelRatio||1;for(const c of[this.base,this.ink])c.style.width=`${o}px`,c.style.height=`${s}px`,c.width=Math.round(o*i),c.height=Math.round(s*i);const a=this.base.getContext("2d");a&&(a.imageSmoothingQuality="high",a.drawImage(this.shot.canvas,0,0,this.base.width,this.base.height)),this.cancelTextInput(),this.render()}setTool(e){this.commitTextInput(),this.tool=e,this.selected=null,this.ink.style.cursor=e==="move"?"grab":e==="text"?"text":"crosshair",this.render()}undo(){this.commitTextInput();const e=this.history.pop();e&&(this.annotations=e,this.selected=null,this.changed())}clear(){this.annotations.length!==0&&(this.snapshot(),this.annotations=[],this.selected=null,this.changed())}get canUndo(){return this.history.length>0}deleteSelected(){return this.selected===null||!this.annotations[this.selected]?!1:(this.snapshot(),this.annotations.splice(this.selected,1),this.selected=null,this.changed(),!0)}flatten(){this.commitTextInput();const e=document.createElement("canvas");e.width=this.shot.canvas.width,e.height=this.shot.canvas.height;const n=e.getContext("2d");if(!n)throw new Error("Canvas 2D is unavailable");return n.drawImage(this.shot.canvas,0,0),n.scale(e.width/this.shot.width,e.height/this.shot.height),Tt(n,this.annotations,{width:this.shot.width,height:this.shot.height}),e}commitTextInput(){const e=this.textInput;if(!e)return;this.textInput=null;const n=e.value.trim(),r=JSON.parse(e.dataset.origin??"[0,0]");e.remove(),n&&(this.snapshot(),this.annotations.push({kind:"text",points:[r],colorHex:this.color,label:n,scale:1,rotation:0}),this.changed())}cancelTextInput(){this.textInput?.remove(),this.textInput=null}render(){const e=this.inkCtx;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.ink.width,this.ink.height);const n=this.ink.width/this.shot.width;e.setTransform(n,0,0,n,0,0);const r={width:this.shot.width,height:this.shot.height};Tt(e,this.annotations,r),this.draft&&At(e,this.draft,r)}changed(){this.render(),this.onChange()}snapshot(){this.history.push(this.annotations.map(e=>({...e,points:e.points.map(n=>[n[0],n[1]])}))),this.history.length>100&&this.history.shift()}toCapture(e){const n=this.ink.getBoundingClientRect();return{x:Math.max(0,Math.min(this.shot.width,(e.clientX-n.left)/this.displayScale)),y:Math.max(0,Math.min(this.shot.height,(e.clientY-n.top)/this.displayScale))}}normalize(e){return[M(e.x/this.shot.width),M(e.y/this.shot.height)]}hitIndex(e){const n={width:this.shot.width,height:this.shot.height};for(let r=this.annotations.length-1;r>=0;r--)if(ee(this.annotations[r],e,n,this.inkCtx))return r;return null}onPointerDown(e){if(e.button!==0&&e.pointerType==="mouse")return;e.preventDefault();const n=this.toCapture(e);if(this.ink.setPointerCapture(e.pointerId),this.pointers.set(e.pointerId,n),this.tool==="move"){if(this.pointers.size===2&&this.selected!==null){this.drag=null,this.startGesture();return}const o=this.hitIndex(n);this.selected=o,o!==null&&(this.snapshot(),this.drag={index:o,last:n,moved:!1},this.ink.style.cursor="grabbing");return}if(this.pointers.size>1)return;if(this.tool==="text"){this.commitTextInput(),this.openTextInput(n);return}this.draftStart=n;const r=this.normalize(n);this.draft={kind:this.tool==="pen"?"freehand":this.tool,points:this.tool==="pen"?[r]:[r,r],colorHex:this.color,scale:1,rotation:0},this.render()}onPointerMove(e){if(!this.pointers.has(e.pointerId)){this.tool==="move"&&e.pointerType==="mouse"&&(this.ink.style.cursor=this.hitIndex(this.toCapture(e))!==null?"grab":"default");return}const n=this.toCapture(e);if(this.pointers.set(e.pointerId,n),this.gesture){this.updateGesture();return}if(this.drag){const o=(n.x-this.drag.last.x)/this.shot.width,s=(n.y-this.drag.last.y)/this.shot.height;this.drag.last=n,this.drag.moved=!0;const i=this.annotations[this.drag.index];i.points=i.points.map(([a,c])=>[M(a+o),M(c+s)]),this.render();return}if(!this.draft||!this.draftStart)return;const r=this.normalize(n);if(this.draft.kind==="freehand"){const o=this.draft.points[this.draft.points.length-1];Math.hypot((r[0]-o[0])*this.shot.width,(r[1]-o[1])*this.shot.height)>=1.5&&this.draft.points.push(r)}else this.draft.points=[this.draft.points[0],r];this.render()}onPointerUp(e){if(!this.pointers.has(e.pointerId))return;if(this.pointers.delete(e.pointerId),this.ink.hasPointerCapture(e.pointerId)&&this.ink.releasePointerCapture(e.pointerId),this.gesture){this.pointers.size<2&&(this.gesture=null,this.onChange());return}if(this.drag){this.drag.moved||this.history.pop(),this.drag=null,this.ink.style.cursor="grab",this.onChange();return}const n=this.draft;this.draft=null;const r=this.draftStart;if(this.draftStart=null,!(!n||!r)){if(n.kind!=="freehand"){const[o,s]=n.points;if(Math.hypot((s[0]-o[0])*this.shot.width,(s[1]-o[1])*this.shot.height)<6){this.render();return}}this.snapshot(),this.annotations.push(n),this.changed()}}onWheel(e){if(this.tool!=="move")return;const n=this.toCapture(e),r=this.hitIndex(n)??this.selected;if(r===null||!this.annotations[r])return;e.preventDefault();const o=this.annotations[r];if(o.kind!=="freehand"){if(this.selected=r,e.shiftKey||e.altKey){if(o.kind==="text")return;const s=e.deltaY!==0?e.deltaY:e.deltaX;o.rotation=M(o.rotation+s*.004)}else o.scale=M(ie(o.scale*Math.exp(-e.deltaY*(e.ctrlKey?.01:.0015)),oe,se));this.render(),this.onChange()}}startGesture(){if(this.selected===null)return;const[e,n]=[...this.pointers.values()],r=this.annotations[this.selected];this.snapshot(),this.gesture={index:this.selected,startDistance:Math.max(1,Math.hypot(n.x-e.x,n.y-e.y)),startAngle:Math.atan2(n.y-e.y,n.x-e.x),startScale:r.scale,startRotation:r.rotation}}updateGesture(){const e=this.gesture;if(!e||this.pointers.size<2)return;const[n,r]=[...this.pointers.values()],o=this.annotations[e.index];if(!o||o.kind==="freehand")return;const s=Math.hypot(r.x-n.x,r.y-n.y);o.scale=M(ie(e.startScale*(s/e.startDistance),oe,se)),o.kind!=="text"&&(o.rotation=M(e.startRotation+(Math.atan2(r.y-n.y,r.x-n.x)-e.startAngle))),this.render()}openTextInput(e){const n=document.createElement("input");n.type="text",n.className="fk-text-input",n.placeholder="Add a note…",n.setAttribute("aria-label","Annotation text"),n.dataset.origin=JSON.stringify(this.normalize(e)),n.style.left=`${Math.min(e.x*this.displayScale,this.shot.width*this.displayScale-130)}px`,n.style.top=`${Math.min(e.y*this.displayScale,this.shot.height*this.displayScale-36)}px`,n.style.borderColor=this.color,n.addEventListener("keydown",r=>{r.stopPropagation(),r.key==="Enter"?this.commitTextInput():r.key==="Escape"&&this.cancelTextInput()}),n.addEventListener("blur",()=>this.commitTextInput()),this.element.append(n),this.textInput=n,requestAnimationFrame(()=>n.focus())}}function ie(t,e,n){return Math.max(e,Math.min(n,t))}function M(t){return Math.round(t*1e4)/1e4}const Cn=`
|
|
2
2
|
:host {
|
|
3
3
|
all: initial;
|
|
4
4
|
--fk-primary: #007aff;
|
|
@@ -130,7 +130,10 @@ button:disabled { cursor: not-allowed; opacity: 0.45; }
|
|
|
130
130
|
box-shadow: 0 0 0 1px var(--fk-border);
|
|
131
131
|
}
|
|
132
132
|
.fk-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--fk-text); }
|
|
133
|
-
|
|
133
|
+
/* Shrinks (with an ellipsis) instead of wrapping onto its own line: hints
|
|
134
|
+
differ in length per tool, and a toolbar that changed height on every tool
|
|
135
|
+
switch would make the screenshot below jump mid-annotation. */
|
|
136
|
+
.fk-hint { flex: 1 1 0; min-width: 0; margin-left: auto; text-align: right; font-size: 12px; color: var(--fk-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
134
137
|
.fk-canvas-wrap {
|
|
135
138
|
position: relative;
|
|
136
139
|
flex: 1;
|
|
@@ -299,19 +302,19 @@ button:disabled { cursor: not-allowed; opacity: 0.45; }
|
|
|
299
302
|
@media (prefers-reduced-motion: reduce) {
|
|
300
303
|
.fk-overlay, .fk-dialog, .fk-fixcard { animation: none; }
|
|
301
304
|
}
|
|
302
|
-
`,Tn=10*1024*1024,An=[{tool:"pen",label:"Draw",icon:v.pen},{tool:"rectangle",label:"Rectangle",icon:v.rectangle},{tool:"arrow",label:"Arrow",icon:v.arrow},{tool:"text",label:"Text",icon:v.text},{tool:"move",label:"Move / resize",icon:v.move}],
|
|
303
|
-
`),o.append(s,i),e.append(o),this.logs.length){const c=ae("Include console & network logs",!0,l=>{this.includeLogs=l});c.style.marginTop="8px",e.append(c)}return e}async loadProducts(){let e=[];try{e=await this.deps.products()}catch{return}if(this.finished||e.length===0)return;this.products=e;const n=this.deps.defaultProductKey(),r=n&&e.find(a=>a.key===n)||e.find(a=>a.isDefault)||null;r&&this.selectedProducts.add(r.key);const o=this.overlay.querySelector('[data-role="products"]');if(!o)return;const s=b("span","fk-label");s.textContent="Affected product";const i=b("div","fk-chips");i.setAttribute("role","group"),i.setAttribute("aria-label","Affected products");for(const a of e){const c=document.createElement("button");c.type="button",c.className="fk-chip",c.textContent=a.name||a.key,a.description&&(c.title=a.description),c.setAttribute("aria-pressed",String(this.selectedProducts.has(a.key))),c.addEventListener("click",()=>{this.selectedProducts.has(a.key)?this.selectedProducts.delete(a.key):this.selectedProducts.add(a.key),c.setAttribute("aria-pressed",String(this.selectedProducts.has(a.key)))}),i.append(c)}o.replaceChildren(s,i),o.hidden=!1}refreshState(){const e=this.textarea?.value.trim().length>0,n=this.includeScreenshot&&(this.editor?.annotations.length??0)>0;this.sendButton&&(this.sendButton.disabled=this.sending||!e&&!n),this.undoButton&&(this.undoButton.disabled=!this.editor?.canUndo),this.clearButton&&(this.clearButton.disabled=!(this.editor&&this.editor.annotations.length>0))}handleKey(e){if(this.finished)return;const n=e.metaKey||e.ctrlKey,r=this.shadow.activeElement,o=r instanceof HTMLTextAreaElement||r instanceof HTMLInputElement;r instanceof HTMLInputElement&&r.classList.contains("fk-text-input")||(e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.cancel()):n&&e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.send()):n&&!e.shiftKey&&e.key.toLowerCase()==="z"&&!o?(e.preventDefault(),e.stopPropagation(),this.editor?.undo()):(e.key==="Backspace"||e.key==="Delete")&&!o?this.editor?.deleteSelected()&&(e.preventDefault(),e.stopPropagation()):e.key==="Tab"&&this.trapFocus(e))}trapFocus(e){const n=[...this.overlay.querySelectorAll("button:not(:disabled), textarea, input:not([type=file]):not(:disabled), summary")].filter(i=>i.offsetParent!==null||i.tagName==="INPUT");if(n.length===0)return;const r=n[0],o=n[n.length-1],s=this.shadow.activeElement;e.shiftKey&&(s===r||!s)?(e.preventDefault(),o.focus()):!e.shiftKey&&s===o&&(e.preventDefault(),r.focus())}showError(e){this.errorBox.hidden=!e,this.errorBox.textContent=e??""}async buildReport(){let e=null,n=null,r=[];if(this.includeScreenshot&&this.shot&&this.editor){const o=this.editor.flatten();[e,n]=await Promise.all([gt(this.shot.canvas),gt(o)]),r=this.editor.annotations.map(s=>({...s}))}return{id:In(),createdAt:new Date,text:this.textarea.value.trim(),screenshotRaw:e,screenshotAnnotated:n,annotations:r,environment:this.environment,attachment:this.attachment,products:this.products.filter(o=>this.selectedProducts.has(o.key)),logs:this.includeLogs?this.logs:[]}}async send(){if(!(this.sending||this.sendButton.disabled)){this.sending=!0,this.showError(null),this.refreshState(),this.sendButton.innerHTML='<span class="fk-spinner" aria-hidden="true"></span><span>Sending…</span>';try{const e=await this.buildReport();if(this.options.deliver)await this.options.deliver(e);else if(this.options.submit){const n=this.deps.configuration();if(!n)throw new Error("FeedbackKit.configure() hasn't been called.");await jt(e,n,this.deps.identity())}await this.options.onReport?.(e),this.showThanks(),setTimeout(()=>this.finish(e),this.delivers?1300:0)}catch(e){this.sending=!1,this.sendButton.innerHTML=`${v.send}<span>Retry</span>`,this.showError(e instanceof Error?e.message:"Something went wrong sending your feedback."),this.refreshState(),this.options.onError?.(e)}}}get delivers(){return this.options.submit||!!this.options.deliver}showThanks(){if(!this.delivers)return;const e=this.overlay.querySelector(".fk-composer");if(!e)return;const n=b("div","fk-done");n.setAttribute("role","status");const r=b("span","fk-done-icon");r.innerHTML=v.check;const o=b("h2","fk-title");o.textContent=this.options.copy?.thanksTitle??"Thanks for the feedback!";const s=b("p","fk-meta");s.textContent=this.options.copy?.thanksBody??"It's on its way to the team.",n.append(r,o,s),e.replaceChildren(n)}cancel(){this.sending||this.finish(null)}finish(e){this.finished||(this.finished=!0,this.resizeObserver?.disconnect(),document.removeEventListener("keydown",this.onKeyDown,!0),this.overlay.remove(),document.documentElement.style.overflow=this.previousOverflow,this.previousFocus instanceof HTMLElement&&this.previousFocus.focus({preventScroll:!0}),this.done(e))}}function b(t,e){const n=document.createElement(t);return e&&(n.className=e),n}function G(t,e,n){const r=document.createElement("button");return r.type="button",t&&(r.className=t),r.innerHTML=e,r.setAttribute("aria-label",n),r.title=n,r}function ae(t,e,n){const r=b("label","fk-switch"),o=document.createElement("input");o.type="checkbox",o.checked=e,o.setAttribute("role","switch"),o.addEventListener("change",()=>n(o.checked));const s=b("span","fk-switch-track"),i=b("span");return i.textContent=t,r.append(o,s,i),r}function ce(t){if(!t)return null;const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(e)?`#${e}`:null}function In(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);crypto.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=[...t].map(n=>n.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}let x=null,X=[],Y=null,$=null,J=null;const T=new Pn({configuration:()=>x,theme:()=>E.theme,products:()=>Nt(),defaultProductKey:()=>x?.defaultProductKey,logs:()=>$?.buffer.snapshot()??[],captureOptions:()=>E.captureOptions,currentScreen:()=>E.currentScreen,identity:()=>({reporterId:z(),user:Wt()})}),Mn=6e4;let Z=!1,le=0,Pt=!1;const de=new Set;function he(){document.visibilityState==="visible"&&Q(!1)}async function Q(t){const e=x;if(!Z||!e||Pt||T.isOpen||T.isShowingFixCard||!t&&Date.now()-le<Mn)return;Pt=!0,le=Date.now();let n;try{n=(await qt(e)).find(r=>!de.has(r.feedbackId))}catch{return}finally{Pt=!1}!n||!Z||Fn(e,n)}async function Fn(t,e){const n=await T.showFixCard(e);de.add(e.feedbackId);const r=o=>wt(t,e.feedbackId,o).catch(s=>console.warn("[FeedbackKit] Couldn't send fix verification.",s));switch(n.type){case"verified":await r({type:"verify"}),Q(!0);break;case"replied":await r({type:"reply",text:n.text}),Q(!0);break;case"stillBroken":{await T.open({submit:!1,deliver:s=>wt(t,e.feedbackId,{type:"reopen",report:s}),copy:{title:"Still broken",label:"What's still wrong?",placeholder:"Show us on the screenshot and describe what you still see…",thanksTitle:"Thanks — we're on it",thanksBody:"Your report was reopened and sent back to the team."}})||await r({type:"reopen"});break}}}function Nt(){if(X.length>0||!x)return Promise.resolve(X);if(!Y){const t=x;Y=un(t).then(e=>(x===t&&(X=e),e)).catch(()=>(Y=null,[]))}return Y}function ue(t){document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}const E={currentScreen:null,theme:null,captureOptions:{},DEFAULT_ENDPOINT:j,configure(t){x=t?{...t,endpoint:t.endpoint??j}:null,X=t?.products??[],Y=null,cn(x?.endpoint??null),x&&X.length===0&&Nt(),t&&t.captureLogs!==!1&&!$&&E.enableLogCapture(typeof t.captureLogs=="object"?t.captureLogs:{})},get isConfigured(){return x!==null},get configuration(){return x},fetchProducts(){return Nt()},present(t={}){return T.open({submit:!1,onReport:t.onReport})},presentAndSubmit(t={}){return x?T.open({submit:!0,onReport:t.onSubmitted,onError:t.onError}):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before presentAndSubmit()."))},submit(t){return x?jt(t,x,{reporterId:z(),user:Wt()}):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before submit()."))},get isPresenting(){return T.isOpen},showFloatingTriggerButton(t={}){ue(()=>T.showTrigger(t,()=>{x?E.presentAndSubmit():E.present({onReport:e=>console.info("[FeedbackKit] report",e)})}))},hideFloatingTriggerButton(){T.hideTrigger()},enableKeyboardShortcut(t={}){E.disableKeyboardShortcut();const e=(t.key??"F").toLowerCase();J=n=>{!(n.metaKey||n.ctrlKey)||!n.shiftKey||n.altKey||n.key.toLowerCase()!==e||(n.preventDefault(),x?E.presentAndSubmit():E.present({onReport:r=>console.info("[FeedbackKit] report",r)}))},window.addEventListener("keydown",J)},disableKeyboardShortcut(){J&&window.removeEventListener("keydown",J),J=null},enableLogCapture(t={}){$?.uninstall(),$=t===!1?null:an(t)},async captureScreenshot(t={}){const e=await Dt({...E.captureOptions,...t,exclude:T.isOwnNode});return gt(e.canvas)},setUser(t){pn(t)},get reporterId(){return z()},checkForFixUpdates(){return x?qt(x):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before checkForFixUpdates()."))},respondToFixUpdate(t,e){return x?wt(x,t,e):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before respondToFixUpdate()."))},enableFixVerification(){Z||(Z=!0,document.addEventListener("visibilitychange",he),ue(()=>{Q(!0)}))},disableFixVerification(){Z=!1,document.removeEventListener("visibilitychange",he),T.hideFixCard()},presentFixUpdatesIfNeeded(){return Q(!0)},destroy(){E.disableFixVerification(),E.disableKeyboardShortcut(),$?.uninstall(),$=null,T.destroy()}},Ln=Object.assign(E,{renderer:Sn});function fe(t,e){return t[13]=1,t[14]=e>>8,t[15]=e&255,t[16]=e>>8,t[17]=e&255,t}const pe=112,me=72,ge=89,ye=115;let It;function _n(){const t=new Int32Array(256);for(let e=0;e<256;e++){let n=e;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t}function Rn(t){let e=-1;It||(It=_n());for(let n=0;n<t.length;n++)e=It[(e^t[n])&255]^e>>>8;return e^-1}function Dn(t){const e=t.length-1;for(let n=e;n>=4;n--)if(t[n-4]===9&&t[n-3]===pe&&t[n-2]===me&&t[n-1]===ge&&t[n]===ye)return n-3;return 0}function be(t,e,n=!1){const r=new Uint8Array(13);e*=39.3701,r[0]=pe,r[1]=me,r[2]=ge,r[3]=ye,r[4]=e>>>24,r[5]=e>>>16,r[6]=e>>>8,r[7]=e&255,r[8]=r[4],r[9]=r[5],r[10]=r[6],r[11]=r[7],r[12]=1;const o=Rn(r),s=new Uint8Array(4);if(s[0]=o>>>24,s[1]=o>>>16,s[2]=o>>>8,s[3]=o&255,n){const i=Dn(t);return t.set(r,i),t.set(s,i+13),t}else{const i=new Uint8Array(4);i[0]=0,i[1]=0,i[2]=0,i[3]=9;const a=new Uint8Array(54);return a.set(t,0),a.set(i,33),a.set(r,37),a.set(s,50),a}}const $n="AAlwSFlz",Bn="AAAJcEhZ",On="AAAACXBI";function Un(t){let e=t.indexOf($n);return e===-1&&(e=t.indexOf(Bn)),e===-1&&(e=t.indexOf(On)),e}const we="[modern-screenshot]",F=typeof window<"u",jn=F&&"Worker"in window,ke=F&&"atob"in window,Hn=F&&"btoa"in window,Mt=F?window.navigator?.userAgent:"",xe=Mt.includes("Chrome"),dt=Mt.includes("AppleWebKit")&&!xe,Ft=Mt.includes("Firefox"),Vn=t=>t&&"__CONTEXT__"in t,zn=t=>t.constructor.name==="CSSFontFaceRule",Wn=t=>t.constructor.name==="CSSImportRule",Kn=t=>t.constructor.name==="CSSLayerBlockRule",A=t=>t.nodeType===1,tt=t=>typeof t.className=="object",ve=t=>t.tagName==="image",qn=t=>t.tagName==="use",et=t=>A(t)&&typeof t.style<"u"&&!tt(t),Gn=t=>t.nodeType===8,Xn=t=>t.nodeType===3,B=t=>t.tagName==="IMG",ht=t=>t.tagName==="VIDEO",Yn=t=>t.tagName==="CANVAS",Jn=t=>t.tagName==="TEXTAREA",Zn=t=>t.tagName==="INPUT",Qn=t=>t.tagName==="STYLE",tr=t=>t.tagName==="SCRIPT",er=t=>t.tagName==="SELECT",nr=t=>t.tagName==="SLOT",rr=t=>t.tagName==="IFRAME",or=(...t)=>console.warn(we,...t);function sr(t){const e=t?.createElement?.("canvas");return e&&(e.height=e.width=1),!!e&&"toDataURL"in e&&!!e.toDataURL("image/webp").includes("image/webp")}const Lt=t=>t.startsWith("data:");function Se(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(F&&t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i)||!F)return t;const n=ut().implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),e&&(r.href=e),o.href=t,o.href}function ut(t){return(t&&A(t)?t?.ownerDocument:t)??window.document}const ft="http://www.w3.org/2000/svg";function Ee(t,e,n){const r=ut(n).createElementNS(ft,"svg");return r.setAttributeNS(null,"width",t.toString()),r.setAttributeNS(null,"height",e.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${t} ${e}`),r}function Ce(t,e){let n=new XMLSerializer().serializeToString(t);return e&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}async function ir(t,e="image/png",n=1){try{return await new Promise((r,o)=>{t.toBlob(s=>{s?r(s):o(new Error("Blob is null"))},e,n)})}catch(r){if(ke)return ar(t.toDataURL(e,n));throw r}}function ar(t){const[e,n]=t.split(","),r=e.match(/data:(.+);/)?.[1]??void 0,o=window.atob(n),s=o.length,i=new Uint8Array(s);for(let a=0;a<s;a+=1)i[a]=o.charCodeAt(a);return new Blob([i],{type:r})}function Te(t,e){return new Promise((n,r)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=()=>r(o.error),o.onabort=()=>r(new Error(`Failed read blob to ${e}`)),e==="dataUrl"?o.readAsDataURL(t):e==="arrayBuffer"&&o.readAsArrayBuffer(t)})}const cr=t=>Te(t,"dataUrl"),lr=t=>Te(t,"arrayBuffer");function D(t,e){const n=ut(e).createElement("img");return n.decoding="sync",n.loading="eager",n.src=t,n}function O(t,e){return new Promise(n=>{const{timeout:r,ownerDocument:o,onError:s,onWarn:i}=e??{},a=typeof t=="string"?D(t,ut(o)):t;let c=null,l=null;function d(){n(a),c&&clearTimeout(c),l?.()}if(r&&(c=setTimeout(d,r)),ht(a)){const h=a.currentSrc||a.src;if(!h)return a.poster?O(a.poster,e).then(n):d();if(a.readyState>=2)return d();const f=d,u=m=>{i?.("Failed video load",h,m),s?.(m),d()};l=()=>{a.removeEventListener("loadeddata",f),a.removeEventListener("error",u)},a.addEventListener("loadeddata",f,{once:!0}),a.addEventListener("error",u,{once:!0})}else{const h=ve(a)?a.href.baseVal:a.currentSrc||a.src;if(!h)return d();const f=async()=>{if(B(a)&&"decode"in a)try{await a.decode()}catch(m){i?.("Failed to decode image, trying to render anyway",a.dataset.originalSrc||h,m)}d()},u=m=>{i?.("Failed image load",a.dataset.originalSrc||h,m),d()};if(B(a)&&a.complete)return f();l=()=>{a.removeEventListener("load",f),a.removeEventListener("error",u)},a.addEventListener("load",f,{once:!0}),a.addEventListener("error",u,{once:!0})}})}async function Ae(t,e){et(t)&&(B(t)||ht(t)?await O(t,e):await Promise.all(["img","video"].flatMap(n=>Array.from(t.querySelectorAll(n)).map(r=>O(r,e)))))}const Pe=(function(){let e=0;const n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${n()}${e}`)})();function Ne(t){return t?.split(",").map(e=>e.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let Ie=0;function dr(t){const e=`${we}[#${Ie}]`;return Ie++,{time:n=>t&&console.time(`${e} ${n}`),timeEnd:n=>t&&console.timeEnd(`${e} ${n}`),warn:(...n)=>t&&or(...n)}}function hr(t){return{cache:t?"no-cache":"force-cache"}}async function P(t,e){return Vn(t)?t:Me(t,{...e,autoDestruct:!0})}async function Me(t,e){const{scale:n=1,workerUrl:r,workerNumber:o=1}=e||{},s=!!e?.debug,i=e?.features??!0,a=t.ownerDocument??(F?window.document:void 0),c=t.ownerDocument?.defaultView??(F?window:void 0),l=new Map,d={width:0,height:0,quality:1,type:"image/png",scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:{requestInit:hr(e?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...e?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:o,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...e,__CONTEXT__:!0,log:dr(s),node:t,ownerDocument:a,ownerWindow:c,dpi:n===1?null:96*n,svgStyleElement:Fe(a),svgDefsElement:a?.createElementNS(ft,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:jn&&r&&o?o:0})].map(()=>{try{const u=new Worker(r);return u.onmessage=async m=>{const{url:p,result:g}=m.data;g?l.get(p)?.resolve?.(g):l.get(p)?.reject?.(new Error(`Error receiving message from worker: ${p}`))},u.onmessageerror=m=>{const{url:p}=m.data;l.get(p)?.reject?.(new Error(`Error receiving message from worker: ${p}`))},u}catch(u){return d.log.warn("Failed to new Worker",u),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[sr(a)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:l,drawImageCount:0,tasks:[],features:i,isEnable:u=>u==="restoreScrollPosition"?typeof i=="boolean"?!1:i[u]??!1:typeof i=="boolean"?i:i[u]??!0,shadowRoots:[]};d.log.time("wait until load"),await Ae(t,{timeout:d.timeout,onWarn:d.log.warn}),d.log.timeEnd("wait until load");const{width:h,height:f}=ur(t,d);return d.width=h,d.height=f,d}function Fe(t){if(!t)return;const e=t.createElement("style"),n=e.ownerDocument.createTextNode(`
|
|
305
|
+
`,Tn=10*1024*1024,An=[{tool:"pen",label:"Draw",icon:v.pen},{tool:"rectangle",label:"Rectangle",icon:v.rectangle},{tool:"arrow",label:"Arrow",icon:v.arrow},{tool:"text",label:"Text",icon:v.text},{tool:"move",label:"Move / resize",icon:v.move}],dt={pen:"Draw on the screenshot to highlight the problem",rectangle:"Drag to box an area",arrow:"Drag to point at something",text:"Click to add a note",move:"Drag to move · scroll to resize · Shift+scroll to rotate · Delete to remove"};class Pn{constructor(e){this.deps=e,this.host=null,this.shadow=null,this.trigger=null,this.pending=null,this.fixCard=null,this.isOwnNode=n=>n===this.host}get isShowingFixCard(){return this.fixCard!==null}showFixCard(e){this.fixCard?.remove();const n=this.mount();return new Promise(r=>{this.fixCard=new yn(n,e,o=>{this.fixCard=null,r(o)}),this.fixCard.show(this.trigger?.dataset.position==="bottom-left"?"bottom-left":"bottom-right")})}hideFixCard(){this.fixCard?.dismiss()}get isOpen(){return this.pending!==null}showTrigger(e,n){const r=this.mount();this.trigger?.remove();const o=document.createElement("button");o.type="button",o.className="fk-trigger",o.dataset.position=e.position??"bottom-right",o.dataset.compact=String(!!e.compact);const s=e.label??"Feedback";o.setAttribute("aria-label",s),o.innerHTML=`${v.feedback}<span class="fk-trigger-label"></span>`,o.querySelector(".fk-trigger-label").textContent=s,o.addEventListener("click",n),r.append(o),this.trigger=o,this.applyTheme()}hideTrigger(){this.trigger?.remove(),this.trigger=null}destroy(){this.hideTrigger(),this.fixCard?.remove(),this.fixCard=null,this.host?.remove(),this.host=null,this.shadow=null}open(e){return this.pending?this.pending:(this.pending=this.run(e).finally(()=>{this.pending=null}),this.pending)}mount(){if(this.shadow&&this.host?.isConnected)return this.shadow;const e=document.createElement("div");e.setAttribute("data-feedbackkit-root",""),e.style.cssText="position:static!important;display:contents!important;";const n=e.attachShadow({mode:"open"}),r=document.createElement("style");return r.textContent=Cn,n.append(r),document.body.append(e),this.host=e,this.shadow=n,this.applyTheme(),n}applyTheme(){const e=this.deps.theme(),n=this.host;if(!n)return;const r=ce(e?.primaryColorHex),o=ce(e?.secondaryColorHex);r?n.style.setProperty("--fk-primary",r):n.style.removeProperty("--fk-primary"),o?n.style.setProperty("--fk-secondary",o):n.style.removeProperty("--fk-secondary")}async run(e){const n=this.mount();this.applyTheme(),this.trigger?.setAttribute("aria-busy","true");const r=this.deps.captureOptions(),[o,s]=await Promise.all([$t({...r,exclude:this.isOwnNode}).catch(a=>(console.warn("[FeedbackKit] Screenshot capture failed; continuing without one.",a),null)),rn({screenName:this.deps.currentScreen(),appVersion:this.deps.configuration()?.appVersion,appBuild:this.deps.configuration()?.appBuild})]),i=this.deps.logs();return this.trigger?.removeAttribute("aria-busy"),new Promise(a=>{new Nn(n,o,s,i,this.deps,e,l=>{a(l)}).show()})}}class Nn{constructor(e,n,r,o,s,i,a){this.shadow=e,this.shot=n,this.environment=r,this.logs=o,this.deps=s,this.options=i,this.done=a,this.editor=null,this.includeLogs=!0,this.attachment=null,this.selectedProducts=new Set,this.products=[],this.sending=!1,this.finished=!1,this.resizeObserver=null,this.previousFocus=null,this.previousOverflow="",this.toolButtons=new Map,this.swatches=[],this.onKeyDown=c=>this.handleKey(c),this.includeScreenshot=n!==null}show(){this.previousFocus=document.activeElement,this.previousOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden";const e=b("div","fk-overlay"),n=b("div","fk-dialog");n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-labelledby","fk-title"),n.append(this.buildStage(),this.buildComposer()),e.append(n),e.addEventListener("mousedown",r=>{r.target===e&&this.cancel()}),this.overlay=e,this.shadow.append(e),document.addEventListener("keydown",this.onKeyDown,!0),this.layoutEditor(),requestAnimationFrame(()=>this.textarea.focus()),this.loadProducts()}buildStage(){const e=b("div","fk-stage");this.stage=e,e.dataset.screenshot=this.includeScreenshot?"on":"off";const n=b("div","fk-toolbar");n.setAttribute("role","toolbar"),n.setAttribute("aria-label","Annotation tools");for(const{tool:s,label:i,icon:a}of An){const c=G("fk-tool",a,i);c.setAttribute("aria-pressed",String(s==="pen")),c.addEventListener("click",()=>this.selectTool(s)),this.toolButtons.set(s,c),n.append(c)}n.append(b("span","fk-toolbar-sep")),re.forEach((s,i)=>{const a=document.createElement("button");a.type="button",a.className="fk-swatch",a.style.background=s,a.setAttribute("aria-label",`Color ${["red","yellow","green","blue","black"][i]}`),a.setAttribute("aria-pressed",String(i===0)),a.addEventListener("click",()=>{this.editor&&(this.editor.color=s),this.swatches.forEach(c=>c.setAttribute("aria-pressed",String(c===a)))}),this.swatches.push(a),n.append(a)}),n.append(b("span","fk-toolbar-sep")),this.undoButton=G("fk-tool",v.undo,"Undo"),this.undoButton.addEventListener("click",()=>this.editor?.undo()),this.clearButton=G("fk-tool",v.trash,"Clear all annotations"),this.clearButton.addEventListener("click",()=>this.editor?.clear()),n.append(this.undoButton,this.clearButton),this.hint=b("span","fk-hint"),this.hint.textContent=dt.pen,this.hint.title=dt.pen,n.append(this.hint);const r=b("div","fk-canvas-wrap");if(this.shot){const s=new En(this.shot);s.onChange=()=>this.refreshState(),s.setTool("pen"),this.editor=s,r.append(s.element),this.resizeObserver=new ResizeObserver(()=>this.layoutEditor()),this.resizeObserver.observe(r)}const o=b("div","fk-off-note");return o.textContent=this.shot?"Screenshot won't be included":"Screenshot unavailable on this page",r.append(o),e.append(n,r),e}layoutEditor(){if(!this.editor)return;const e=this.editor.element.parentElement;if(!e)return;const n=getComputedStyle(e),r=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight),o=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom);this.editor.layout(Math.max(40,e.clientWidth-r),Math.max(40,e.clientHeight-o))}selectTool(e){this.editor?.setTool(e),this.toolButtons.forEach((n,r)=>n.setAttribute("aria-pressed",String(r===e))),this.hint.textContent=dt[e],this.hint.title=dt[e]}buildComposer(){const e=b("div","fk-composer"),n=b("div","fk-header"),r=b("h2","fk-title");r.id="fk-title",r.textContent=this.options.copy?.title??"Send feedback";const o=G("fk-close",v.close,"Close");o.addEventListener("click",()=>this.cancel()),n.append(r,o);const s=b("label","fk-label");s.textContent=this.options.copy?.label??"What's the problem?",s.setAttribute("for","fk-text"),this.textarea=document.createElement("textarea"),this.textarea.id="fk-text",this.textarea.className="fk-textarea",this.textarea.placeholder=this.options.copy?.placeholder??"Describe what happened and what you expected instead…",this.textarea.addEventListener("input",()=>this.refreshState());const i=b("div");i.append(s,this.textarea);const a=b("div");a.dataset.role="products",a.hidden=!0;const c=b("div","fk-row"),l=ae("Screenshot",this.includeScreenshot,y=>{this.includeScreenshot=y,this.stage.dataset.screenshot=y?"on":"off",this.refreshState()});this.shot||(l.querySelector("input").disabled=!0);const d=b("div"),h=document.createElement("input");h.type="file",h.hidden=!0;const f=document.createElement("button");f.type="button",f.className="fk-attach",f.innerHTML=`${v.paperclip}<span>Attach file</span>`,f.addEventListener("click",()=>h.click()),h.addEventListener("change",()=>{const y=h.files?.[0];if(h.value="",!!y){if(y.size>Tn){this.showError(`"${y.name}" is larger than 10 MB.`);return}this.attachment={filename:y.name,mimeType:y.type||"application/octet-stream",data:y},u()}});const u=()=>{if(d.replaceChildren(h),this.attachment){const y=b("span","fk-file"),k=b("span");k.textContent=this.attachment.filename;const w=G("",v.close,`Remove ${this.attachment.filename}`);w.addEventListener("click",()=>{this.attachment=null,u()}),y.append(k,w),d.append(y)}else d.append(f)};u(),c.append(d,l);const m=this.buildDiagnostics();this.errorBox=b("p","fk-error"),this.errorBox.setAttribute("role","alert"),this.errorBox.hidden=!0;const p=b("div","fk-actions"),g=document.createElement("button");return g.type="button",g.className="fk-btn fk-btn-secondary",g.textContent="Cancel",g.addEventListener("click",()=>this.cancel()),this.sendButton=document.createElement("button"),this.sendButton.type="button",this.sendButton.className="fk-btn fk-btn-primary",this.sendButton.innerHTML=`${v.send}<span>Send</span>`,this.sendButton.title="Send (⌘/Ctrl + Enter)",this.sendButton.addEventListener("click",()=>{this.send()}),p.append(g,this.sendButton),e.append(n,i,a,c),m&&e.append(m),e.append(b("div","fk-spacer"),this.errorBox,p),this.refreshState(),e}buildDiagnostics(){const e=b("div","fk-meta"),n=this.environment,r=`${n.deviceModel} · ${n.osName} ${n.osVersion}`.trim(),o=document.createElement("details"),s=document.createElement("summary");s.textContent=`Included: page URL, ${r}${this.logs.length?`, ${this.logs.length} log entr${this.logs.length===1?"y":"ies"}`:""}`;const i=document.createElement("pre"),a=[`URL: ${n.pageUrl??""}`,`Viewport: ${n.screenWidthPoints}×${n.screenHeightPoints} @${n.screenScale}x`];if(this.logs.length&&a.push("",...this.logs.map(c=>`[${c.level}] ${c.message}`)),i.textContent=a.join(`
|
|
306
|
+
`),o.append(s,i),e.append(o),this.logs.length){const c=ae("Include console & network logs",!0,l=>{this.includeLogs=l});c.style.marginTop="8px",e.append(c)}return e}async loadProducts(){let e=[];try{e=await this.deps.products()}catch{return}if(this.finished||e.length===0)return;this.products=e;const n=this.deps.defaultProductKey(),r=n&&e.find(a=>a.key===n)||e.find(a=>a.isDefault)||null;r&&this.selectedProducts.add(r.key);const o=this.overlay.querySelector('[data-role="products"]');if(!o)return;const s=b("span","fk-label");s.textContent="Affected product";const i=b("div","fk-chips");i.setAttribute("role","group"),i.setAttribute("aria-label","Affected products");for(const a of e){const c=document.createElement("button");c.type="button",c.className="fk-chip",c.textContent=a.name||a.key,a.description&&(c.title=a.description),c.setAttribute("aria-pressed",String(this.selectedProducts.has(a.key))),c.addEventListener("click",()=>{this.selectedProducts.has(a.key)?this.selectedProducts.delete(a.key):this.selectedProducts.add(a.key),c.setAttribute("aria-pressed",String(this.selectedProducts.has(a.key)))}),i.append(c)}o.replaceChildren(s,i),o.hidden=!1}refreshState(){const e=this.textarea?.value.trim().length>0,n=this.includeScreenshot&&(this.editor?.annotations.length??0)>0;this.sendButton&&(this.sendButton.disabled=this.sending||!e&&!n),this.undoButton&&(this.undoButton.disabled=!this.editor?.canUndo),this.clearButton&&(this.clearButton.disabled=!(this.editor&&this.editor.annotations.length>0))}handleKey(e){if(this.finished)return;const n=e.metaKey||e.ctrlKey,r=this.shadow.activeElement,o=r instanceof HTMLTextAreaElement||r instanceof HTMLInputElement;r instanceof HTMLInputElement&&r.classList.contains("fk-text-input")||(e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.cancel()):n&&e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.send()):n&&!e.shiftKey&&e.key.toLowerCase()==="z"&&!o?(e.preventDefault(),e.stopPropagation(),this.editor?.undo()):(e.key==="Backspace"||e.key==="Delete")&&!o?this.editor?.deleteSelected()&&(e.preventDefault(),e.stopPropagation()):e.key==="Tab"&&this.trapFocus(e))}trapFocus(e){const n=[...this.overlay.querySelectorAll("button:not(:disabled), textarea, input:not([type=file]):not(:disabled), summary")].filter(i=>i.offsetParent!==null||i.tagName==="INPUT");if(n.length===0)return;const r=n[0],o=n[n.length-1],s=this.shadow.activeElement;e.shiftKey&&(s===r||!s)?(e.preventDefault(),o.focus()):!e.shiftKey&&s===o&&(e.preventDefault(),r.focus())}showError(e){this.errorBox.hidden=!e,this.errorBox.textContent=e??""}async buildReport(){let e=null,n=null,r=[];if(this.includeScreenshot&&this.shot&&this.editor){const o=this.editor.flatten();[e,n]=await Promise.all([yt(this.shot.canvas),yt(o)]),r=this.editor.annotations.map(s=>({...s}))}return{id:In(),createdAt:new Date,text:this.textarea.value.trim(),screenshotRaw:e,screenshotAnnotated:n,annotations:r,environment:this.environment,attachment:this.attachment,products:this.products.filter(o=>this.selectedProducts.has(o.key)),logs:this.includeLogs?this.logs:[]}}async send(){if(!(this.sending||this.sendButton.disabled)){this.sending=!0,this.showError(null),this.refreshState(),this.sendButton.innerHTML='<span class="fk-spinner" aria-hidden="true"></span><span>Sending…</span>';try{const e=await this.buildReport();if(this.options.deliver)await this.options.deliver(e);else if(this.options.submit){const n=this.deps.configuration();if(!n)throw new Error("FeedbackKit.configure() hasn't been called.");await Ht(e,n,this.deps.identity())}await this.options.onReport?.(e),this.showThanks(),setTimeout(()=>this.finish(e),this.delivers?1300:0)}catch(e){this.sending=!1,this.sendButton.innerHTML=`${v.send}<span>Retry</span>`,this.showError(e instanceof Error?e.message:"Something went wrong sending your feedback."),this.refreshState(),this.options.onError?.(e)}}}get delivers(){return this.options.submit||!!this.options.deliver}showThanks(){if(!this.delivers)return;const e=this.overlay.querySelector(".fk-composer");if(!e)return;const n=b("div","fk-done");n.setAttribute("role","status");const r=b("span","fk-done-icon");r.innerHTML=v.check;const o=b("h2","fk-title");o.textContent=this.options.copy?.thanksTitle??"Thanks for the feedback!";const s=b("p","fk-meta");s.textContent=this.options.copy?.thanksBody??"It's on its way to the team.",n.append(r,o,s),e.replaceChildren(n)}cancel(){this.sending||this.finish(null)}finish(e){this.finished||(this.finished=!0,this.resizeObserver?.disconnect(),document.removeEventListener("keydown",this.onKeyDown,!0),this.overlay.remove(),document.documentElement.style.overflow=this.previousOverflow,this.previousFocus instanceof HTMLElement&&this.previousFocus.focus({preventScroll:!0}),this.done(e))}}function b(t,e){const n=document.createElement(t);return e&&(n.className=e),n}function G(t,e,n){const r=document.createElement("button");return r.type="button",t&&(r.className=t),r.innerHTML=e,r.setAttribute("aria-label",n),r.title=n,r}function ae(t,e,n){const r=b("label","fk-switch"),o=document.createElement("input");o.type="checkbox",o.checked=e,o.setAttribute("role","switch"),o.addEventListener("change",()=>n(o.checked));const s=b("span","fk-switch-track"),i=b("span");return i.textContent=t,r.append(o,s,i),r}function ce(t){if(!t)return null;const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(e)?`#${e}`:null}function In(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);crypto.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=[...t].map(n=>n.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}let x=null,X=[],Y=null,$=null,J=null;const T=new Pn({configuration:()=>x,theme:()=>E.theme,products:()=>It(),defaultProductKey:()=>x?.defaultProductKey,logs:()=>$?.buffer.snapshot()??[],captureOptions:()=>E.captureOptions,currentScreen:()=>E.currentScreen,identity:()=>({reporterId:z(),user:Kt()})}),Mn=6e4;let Z=!1,le=0,Nt=!1;const de=new Set;function he(){document.visibilityState==="visible"&&Q(!1)}async function Q(t){const e=x;if(!Z||!e||Nt||T.isOpen||T.isShowingFixCard||!t&&Date.now()-le<Mn)return;Nt=!0,le=Date.now();let n;try{n=(await Gt(e)).find(r=>!de.has(r.feedbackId))}catch{return}finally{Nt=!1}!n||!Z||Fn(e,n)}async function Fn(t,e){const n=await T.showFixCard(e);de.add(e.feedbackId);const r=o=>kt(t,e.feedbackId,o).catch(s=>console.warn("[FeedbackKit] Couldn't send fix verification.",s));switch(n.type){case"verified":await r({type:"verify"}),Q(!0);break;case"replied":await r({type:"reply",text:n.text}),Q(!0);break;case"stillBroken":{await T.open({submit:!1,deliver:s=>kt(t,e.feedbackId,{type:"reopen",report:s}),copy:{title:"Still broken",label:"What's still wrong?",placeholder:"Show us on the screenshot and describe what you still see…",thanksTitle:"Thanks — we're on it",thanksBody:"Your report was reopened and sent back to the team."}})||await r({type:"reopen"});break}}}function It(){if(X.length>0||!x)return Promise.resolve(X);if(!Y){const t=x;Y=un(t).then(e=>(x===t&&(X=e),e)).catch(()=>(Y=null,[]))}return Y}function ue(t){document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}const E={currentScreen:null,theme:null,captureOptions:{},DEFAULT_ENDPOINT:j,configure(t){x=t?{...t,endpoint:t.endpoint??j}:null,X=t?.products??[],Y=null,cn(x?.endpoint??null),x&&X.length===0&&It(),t&&t.captureLogs!==!1&&!$&&E.enableLogCapture(typeof t.captureLogs=="object"?t.captureLogs:{})},get isConfigured(){return x!==null},get configuration(){return x},fetchProducts(){return It()},present(t={}){return T.open({submit:!1,onReport:t.onReport})},presentAndSubmit(t={}){return x?T.open({submit:!0,onReport:t.onSubmitted,onError:t.onError}):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before presentAndSubmit()."))},submit(t){return x?Ht(t,x,{reporterId:z(),user:Kt()}):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before submit()."))},get isPresenting(){return T.isOpen},showFloatingTriggerButton(t={}){ue(()=>T.showTrigger(t,()=>{x?E.presentAndSubmit():E.present({onReport:e=>console.info("[FeedbackKit] report",e)})}))},hideFloatingTriggerButton(){T.hideTrigger()},enableKeyboardShortcut(t={}){E.disableKeyboardShortcut();const e=(t.key??"F").toLowerCase();J=n=>{!(n.metaKey||n.ctrlKey)||!n.shiftKey||n.altKey||n.key.toLowerCase()!==e||(n.preventDefault(),x?E.presentAndSubmit():E.present({onReport:r=>console.info("[FeedbackKit] report",r)}))},window.addEventListener("keydown",J)},disableKeyboardShortcut(){J&&window.removeEventListener("keydown",J),J=null},enableLogCapture(t={}){$?.uninstall(),$=t===!1?null:an(t)},async captureScreenshot(t={}){const e=await $t({...E.captureOptions,...t,exclude:T.isOwnNode});return yt(e.canvas)},setUser(t){pn(t)},get reporterId(){return z()},checkForFixUpdates(){return x?Gt(x):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before checkForFixUpdates()."))},respondToFixUpdate(t,e){return x?kt(x,t,e):Promise.reject(new Error("FeedbackKit.configure({ projectKey }) must be called before respondToFixUpdate()."))},enableFixVerification(){Z||(Z=!0,document.addEventListener("visibilitychange",he),ue(()=>{Q(!0)}))},disableFixVerification(){Z=!1,document.removeEventListener("visibilitychange",he),T.hideFixCard()},presentFixUpdatesIfNeeded(){return Q(!0)},destroy(){E.disableFixVerification(),E.disableKeyboardShortcut(),$?.uninstall(),$=null,T.destroy()}},Ln=Object.assign(E,{renderer:Sn});function fe(t,e){return t[13]=1,t[14]=e>>8,t[15]=e&255,t[16]=e>>8,t[17]=e&255,t}const pe=112,me=72,ge=89,ye=115;let Mt;function _n(){const t=new Int32Array(256);for(let e=0;e<256;e++){let n=e;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t}function Rn(t){let e=-1;Mt||(Mt=_n());for(let n=0;n<t.length;n++)e=Mt[(e^t[n])&255]^e>>>8;return e^-1}function Dn(t){const e=t.length-1;for(let n=e;n>=4;n--)if(t[n-4]===9&&t[n-3]===pe&&t[n-2]===me&&t[n-1]===ge&&t[n]===ye)return n-3;return 0}function be(t,e,n=!1){const r=new Uint8Array(13);e*=39.3701,r[0]=pe,r[1]=me,r[2]=ge,r[3]=ye,r[4]=e>>>24,r[5]=e>>>16,r[6]=e>>>8,r[7]=e&255,r[8]=r[4],r[9]=r[5],r[10]=r[6],r[11]=r[7],r[12]=1;const o=Rn(r),s=new Uint8Array(4);if(s[0]=o>>>24,s[1]=o>>>16,s[2]=o>>>8,s[3]=o&255,n){const i=Dn(t);return t.set(r,i),t.set(s,i+13),t}else{const i=new Uint8Array(4);i[0]=0,i[1]=0,i[2]=0,i[3]=9;const a=new Uint8Array(54);return a.set(t,0),a.set(i,33),a.set(r,37),a.set(s,50),a}}const $n="AAlwSFlz",Bn="AAAJcEhZ",On="AAAACXBI";function Un(t){let e=t.indexOf($n);return e===-1&&(e=t.indexOf(Bn)),e===-1&&(e=t.indexOf(On)),e}const we="[modern-screenshot]",F=typeof window<"u",jn=F&&"Worker"in window,ke=F&&"atob"in window,Hn=F&&"btoa"in window,Ft=F?window.navigator?.userAgent:"",xe=Ft.includes("Chrome"),ht=Ft.includes("AppleWebKit")&&!xe,Lt=Ft.includes("Firefox"),Vn=t=>t&&"__CONTEXT__"in t,zn=t=>t.constructor.name==="CSSFontFaceRule",Wn=t=>t.constructor.name==="CSSImportRule",Kn=t=>t.constructor.name==="CSSLayerBlockRule",A=t=>t.nodeType===1,tt=t=>typeof t.className=="object",ve=t=>t.tagName==="image",qn=t=>t.tagName==="use",et=t=>A(t)&&typeof t.style<"u"&&!tt(t),Gn=t=>t.nodeType===8,Xn=t=>t.nodeType===3,B=t=>t.tagName==="IMG",ut=t=>t.tagName==="VIDEO",Yn=t=>t.tagName==="CANVAS",Jn=t=>t.tagName==="TEXTAREA",Zn=t=>t.tagName==="INPUT",Qn=t=>t.tagName==="STYLE",tr=t=>t.tagName==="SCRIPT",er=t=>t.tagName==="SELECT",nr=t=>t.tagName==="SLOT",rr=t=>t.tagName==="IFRAME",or=(...t)=>console.warn(we,...t);function sr(t){const e=t?.createElement?.("canvas");return e&&(e.height=e.width=1),!!e&&"toDataURL"in e&&!!e.toDataURL("image/webp").includes("image/webp")}const _t=t=>t.startsWith("data:");function Se(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(F&&t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i)||!F)return t;const n=ft().implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),e&&(r.href=e),o.href=t,o.href}function ft(t){return(t&&A(t)?t?.ownerDocument:t)??window.document}const pt="http://www.w3.org/2000/svg";function Ee(t,e,n){const r=ft(n).createElementNS(pt,"svg");return r.setAttributeNS(null,"width",t.toString()),r.setAttributeNS(null,"height",e.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${t} ${e}`),r}function Ce(t,e){let n=new XMLSerializer().serializeToString(t);return e&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}async function ir(t,e="image/png",n=1){try{return await new Promise((r,o)=>{t.toBlob(s=>{s?r(s):o(new Error("Blob is null"))},e,n)})}catch(r){if(ke)return ar(t.toDataURL(e,n));throw r}}function ar(t){const[e,n]=t.split(","),r=e.match(/data:(.+);/)?.[1]??void 0,o=window.atob(n),s=o.length,i=new Uint8Array(s);for(let a=0;a<s;a+=1)i[a]=o.charCodeAt(a);return new Blob([i],{type:r})}function Te(t,e){return new Promise((n,r)=>{const o=new FileReader;o.onload=()=>n(o.result),o.onerror=()=>r(o.error),o.onabort=()=>r(new Error(`Failed read blob to ${e}`)),e==="dataUrl"?o.readAsDataURL(t):e==="arrayBuffer"&&o.readAsArrayBuffer(t)})}const cr=t=>Te(t,"dataUrl"),lr=t=>Te(t,"arrayBuffer");function D(t,e){const n=ft(e).createElement("img");return n.decoding="sync",n.loading="eager",n.src=t,n}function O(t,e){return new Promise(n=>{const{timeout:r,ownerDocument:o,onError:s,onWarn:i}=e??{},a=typeof t=="string"?D(t,ft(o)):t;let c=null,l=null;function d(){n(a),c&&clearTimeout(c),l?.()}if(r&&(c=setTimeout(d,r)),ut(a)){const h=a.currentSrc||a.src;if(!h)return a.poster?O(a.poster,e).then(n):d();if(a.readyState>=2)return d();const f=d,u=m=>{i?.("Failed video load",h,m),s?.(m),d()};l=()=>{a.removeEventListener("loadeddata",f),a.removeEventListener("error",u)},a.addEventListener("loadeddata",f,{once:!0}),a.addEventListener("error",u,{once:!0})}else{const h=ve(a)?a.href.baseVal:a.currentSrc||a.src;if(!h)return d();const f=async()=>{if(B(a)&&"decode"in a)try{await a.decode()}catch(m){i?.("Failed to decode image, trying to render anyway",a.dataset.originalSrc||h,m)}d()},u=m=>{i?.("Failed image load",a.dataset.originalSrc||h,m),d()};if(B(a)&&a.complete)return f();l=()=>{a.removeEventListener("load",f),a.removeEventListener("error",u)},a.addEventListener("load",f,{once:!0}),a.addEventListener("error",u,{once:!0})}})}async function Ae(t,e){et(t)&&(B(t)||ut(t)?await O(t,e):await Promise.all(["img","video"].flatMap(n=>Array.from(t.querySelectorAll(n)).map(r=>O(r,e)))))}const Pe=(function(){let e=0;const n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${n()}${e}`)})();function Ne(t){return t?.split(",").map(e=>e.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let Ie=0;function dr(t){const e=`${we}[#${Ie}]`;return Ie++,{time:n=>t&&console.time(`${e} ${n}`),timeEnd:n=>t&&console.timeEnd(`${e} ${n}`),warn:(...n)=>t&&or(...n)}}function hr(t){return{cache:t?"no-cache":"force-cache"}}async function P(t,e){return Vn(t)?t:Me(t,{...e,autoDestruct:!0})}async function Me(t,e){const{scale:n=1,workerUrl:r,workerNumber:o=1}=e||{},s=!!e?.debug,i=e?.features??!0,a=t.ownerDocument??(F?window.document:void 0),c=t.ownerDocument?.defaultView??(F?window:void 0),l=new Map,d={width:0,height:0,quality:1,type:"image/png",scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:{requestInit:hr(e?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...e?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:o,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...e,__CONTEXT__:!0,log:dr(s),node:t,ownerDocument:a,ownerWindow:c,dpi:n===1?null:96*n,svgStyleElement:Fe(a),svgDefsElement:a?.createElementNS(pt,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:jn&&r&&o?o:0})].map(()=>{try{const u=new Worker(r);return u.onmessage=async m=>{const{url:p,result:g}=m.data;g?l.get(p)?.resolve?.(g):l.get(p)?.reject?.(new Error(`Error receiving message from worker: ${p}`))},u.onmessageerror=m=>{const{url:p}=m.data;l.get(p)?.reject?.(new Error(`Error receiving message from worker: ${p}`))},u}catch(u){return d.log.warn("Failed to new Worker",u),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[sr(a)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:l,drawImageCount:0,tasks:[],features:i,isEnable:u=>u==="restoreScrollPosition"?typeof i=="boolean"?!1:i[u]??!1:typeof i=="boolean"?i:i[u]??!0,shadowRoots:[]};d.log.time("wait until load"),await Ae(t,{timeout:d.timeout,onWarn:d.log.warn}),d.log.timeEnd("wait until load");const{width:h,height:f}=ur(t,d);return d.width=h,d.height=f,d}function Fe(t){if(!t)return;const e=t.createElement("style"),n=e.ownerDocument.createTextNode(`
|
|
304
307
|
.______background-clip--text {
|
|
305
308
|
background-clip: text;
|
|
306
309
|
-webkit-background-clip: text;
|
|
307
310
|
}
|
|
308
|
-
`);return e.appendChild(n),e}function ur(t,e){let{width:n,height:r}=e;if(A(t)&&(!n||!r)){const o=t.getBoundingClientRect();n=n||o.width||Number(t.getAttribute("width"))||0,r=r||o.height||Number(t.getAttribute("height"))||0}return{width:n,height:r}}async function fr(t,e){const{log:n,timeout:r,drawImageCount:o,drawImageInterval:s}=e;n.time("image to canvas");const i=await O(t,{timeout:r,onWarn:e.log.warn}),{canvas:a,context2d:c}=pr(t.ownerDocument,e),l=()=>{try{c?.drawImage(i,0,0,a.width,a.height)}catch(d){e.log.warn("Failed to drawImage",d)}};if(l(),e.isEnable("fixSvgXmlDecode"))for(let d=0;d<o;d++)await new Promise(h=>{setTimeout(()=>{c?.clearRect(0,0,a.width,a.height),l(),h()},d+s)});return e.drawImageCount=0,n.timeEnd("image to canvas"),a}function pr(t,e){const{width:n,height:r,scale:o,backgroundColor:s,maximumCanvasSize:i}=e,a=t.createElement("canvas");a.width=Math.floor(n*o),a.height=Math.floor(r*o),a.style.width=`${n}px`,a.style.height=`${r}px`,i&&(a.width>i||a.height>i)&&(a.width>i&&a.height>i?a.width>a.height?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i):a.width>i?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i));const c=a.getContext("2d");return c&&s&&(c.fillStyle=s,c.fillRect(0,0,a.width,a.height)),{canvas:a,context2d:c}}function Le(t,e){if(t.ownerDocument)try{const s=t.toDataURL();if(s!=="data:,")return D(s,t.ownerDocument)}catch(s){e.log.warn("Failed to clone canvas",s)}const n=t.cloneNode(!1),r=t.getContext("2d"),o=n.getContext("2d");try{return r&&o&&o.putImageData(r.getImageData(0,0,t.width,t.height),0,0),n}catch(s){e.log.warn("Failed to clone canvas",s)}return n}function mr(t,e){try{if(t?.contentDocument?.documentElement)return
|
|
309
|
-
`);let k=a.get(y);k||(k=[],a.set(y,k)),k.push(`.${u[0]}${d}`)}Er.forEach(l),n&&Cr.forEach(l)}const De=new Set(["symbol"]);async function $e(t,e,n,r,o){if(A(n)&&(Qn(n)||tr(n))||r.filter&&!r.filter(n))return;De.has(e.nodeName)||De.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;const s=await
|
|
310
|
-
`))}else{const c=Array.from(n.styleSheets).filter(u=>{try{return"cssRules"in u&&!!u.cssRules.length}catch(m){return e.log.warn(`Error while reading CSS rules from ${u.href}`,m),!1}}),l=n.implementation.createHTMLDocument(""),d=l.createElement("style");l.head.appendChild(d);const h=d.sheet;await Promise.all(c.flatMap(u=>Array.from(u.cssRules).map(async m=>{if(Wn(m)){const p=m.href;let g="";try{g=await nt(e,{url:p,requestType:"text",responseType:"text"})}catch(k){e.log.warn(`Error fetch remote css import from ${p}`,k)}const y=g.replace(He,(k,w,S)=>k.replace(S,Se(S,p)));for(const k of Or(y))try{h.insertRule(k,h.cssRules.length)}catch(w){e.log.warn("Error inserting rule from remote css import",{rule:k,error:w})}}}))),h.cssRules.length&&c.push(h);const f=[];c.forEach(u=>{
|
|
311
|
+
`);return e.appendChild(n),e}function ur(t,e){let{width:n,height:r}=e;if(A(t)&&(!n||!r)){const o=t.getBoundingClientRect();n=n||o.width||Number(t.getAttribute("width"))||0,r=r||o.height||Number(t.getAttribute("height"))||0}return{width:n,height:r}}async function fr(t,e){const{log:n,timeout:r,drawImageCount:o,drawImageInterval:s}=e;n.time("image to canvas");const i=await O(t,{timeout:r,onWarn:e.log.warn}),{canvas:a,context2d:c}=pr(t.ownerDocument,e),l=()=>{try{c?.drawImage(i,0,0,a.width,a.height)}catch(d){e.log.warn("Failed to drawImage",d)}};if(l(),e.isEnable("fixSvgXmlDecode"))for(let d=0;d<o;d++)await new Promise(h=>{setTimeout(()=>{c?.clearRect(0,0,a.width,a.height),l(),h()},d+s)});return e.drawImageCount=0,n.timeEnd("image to canvas"),a}function pr(t,e){const{width:n,height:r,scale:o,backgroundColor:s,maximumCanvasSize:i}=e,a=t.createElement("canvas");a.width=Math.floor(n*o),a.height=Math.floor(r*o),a.style.width=`${n}px`,a.style.height=`${r}px`,i&&(a.width>i||a.height>i)&&(a.width>i&&a.height>i?a.width>a.height?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i):a.width>i?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i));const c=a.getContext("2d");return c&&s&&(c.fillStyle=s,c.fillRect(0,0,a.width,a.height)),{canvas:a,context2d:c}}function Le(t,e){if(t.ownerDocument)try{const s=t.toDataURL();if(s!=="data:,")return D(s,t.ownerDocument)}catch(s){e.log.warn("Failed to clone canvas",s)}const n=t.cloneNode(!1),r=t.getContext("2d"),o=n.getContext("2d");try{return r&&o&&o.putImageData(r.getImageData(0,0,t.width,t.height),0,0),n}catch(s){e.log.warn("Failed to clone canvas",s)}return n}function mr(t,e){try{if(t?.contentDocument?.documentElement)return Rt(t.contentDocument.documentElement,e)}catch(n){e.log.warn("Failed to clone iframe",n)}return t.cloneNode(!1)}function gr(t){const e=t.cloneNode(!1);return t.currentSrc&&t.currentSrc!==t.src&&(e.src=t.currentSrc,e.srcset=""),e.loading==="lazy"&&(e.loading="eager"),e}async function yr(t,e){if(t.ownerDocument&&!t.currentSrc&&t.poster)return D(t.poster,t.ownerDocument);const n=t.cloneNode(!1);n.crossOrigin="anonymous",t.currentSrc&&t.currentSrc!==t.src&&(n.src=t.currentSrc);const r=n.ownerDocument;if(r){let o=!0;if(await O(n,{onError:()=>o=!1,onWarn:e.log.warn}),!o)return t.poster?D(t.poster,t.ownerDocument):n;n.currentTime=t.currentTime,await new Promise(i=>{n.addEventListener("seeked",i,{once:!0})});const s=r.createElement("canvas");s.width=t.offsetWidth,s.height=t.offsetHeight;try{const i=s.getContext("2d");i&&i.drawImage(n,0,0,s.width,s.height)}catch(i){return e.log.warn("Failed to clone video",i),t.poster?D(t.poster,t.ownerDocument):n}return Le(s,e)}return n}function br(t,e){return Yn(t)?Le(t,e):rr(t)?mr(t,e):B(t)?gr(t):ut(t)?yr(t,e):t.cloneNode(!1)}function wr(t){let e=t.sandbox;if(!e){const{ownerDocument:n}=t;try{n&&(e=n.createElement("iframe"),e.id=`__SANDBOX__${Pe()}`,e.width="0",e.height="0",e.style.visibility="hidden",e.style.position="fixed",n.body.appendChild(e),e.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',t.sandbox=e)}catch(r){t.log.warn("Failed to getSandBox",r)}}return e}const kr=["width","height","-webkit-text-fill-color"],xr=["stroke","fill"];function _e(t,e,n){const{defaultComputedStyles:r}=n,o=t.nodeName.toLowerCase(),s=tt(t)&&o!=="svg",i=s?xr.map(p=>[p,t.getAttribute(p)]).filter(([,p])=>p!==null):[],a=[s&&"svg",o,i.map((p,g)=>`${p}=${g}`).join(","),e].filter(Boolean).join(":");if(r.has(a))return r.get(a);const l=wr(n)?.contentWindow;if(!l)return new Map;const d=l?.document;let h,f;s?(h=d.createElementNS(pt,"svg"),f=h.ownerDocument.createElementNS(h.namespaceURI,o),i.forEach(([p,g])=>{f.setAttributeNS(null,p,g)}),h.appendChild(f)):h=f=d.createElement(o),f.textContent=" ",d.body.appendChild(h);const u=l.getComputedStyle(f,e),m=new Map;for(let p=u.length,g=0;g<p;g++){const y=u.item(g);kr.includes(y)||m.set(y,u.getPropertyValue(y))}return d.body.removeChild(h),r.set(a,m),m}function Re(t,e,n){const r=new Map,o=[],s=new Map;if(n)for(const a of n)i(a);else for(let a=t.length,c=0;c<a;c++){const l=t.item(c);i(l)}for(let a=o.length,c=0;c<a;c++)s.get(o[c])?.forEach((l,d)=>r.set(d,l));function i(a){const c=t.getPropertyValue(a),l=t.getPropertyPriority(a),d=a.lastIndexOf("-"),h=d>-1?a.substring(0,d):void 0;if(h){let f=s.get(h);f||(f=new Map,s.set(h,f)),f.set(a,[c,l])}e.get(a)===c&&!l||(h?o.push(h):r.set(a,[c,l]))}return r}function vr(t,e,n,r){const{ownerWindow:o,includeStyleProperties:s,currentParentNodeStyle:i}=r,a=e.style,c=o.getComputedStyle(t),l=_e(t,null,r);i?.forEach((h,f)=>{l.delete(f)});const d=Re(c,l,s);d.delete("transition-property"),d.delete("all"),d.delete("d"),d.delete("content"),n&&(d.delete("position"),d.delete("margin-top"),d.delete("margin-right"),d.delete("margin-bottom"),d.delete("margin-left"),d.delete("margin-block-start"),d.delete("margin-block-end"),d.delete("margin-inline-start"),d.delete("margin-inline-end"),d.set("box-sizing",["border-box",""])),d.get("background-clip")?.[0]==="text"&&e.classList.add("______background-clip--text"),xe&&(d.has("font-kerning")||d.set("font-kerning",["normal",""]),(d.get("overflow-x")?.[0]==="hidden"||d.get("overflow-y")?.[0]==="hidden")&&d.get("text-overflow")?.[0]==="ellipsis"&&t.scrollWidth===t.clientWidth&&d.set("text-overflow",["clip",""]));for(let h=a.length,f=0;f<h;f++)a.removeProperty(a.item(f));return d.forEach(([h,f],u)=>{a.setProperty(u,h,f)}),d}function Sr(t,e){(Jn(t)||Zn(t)||er(t))&&e.setAttribute("value",t.value)}const Er=["::before","::after"],Cr=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function Tr(t,e,n,r,o){const{ownerWindow:s,svgStyleElement:i,svgStyles:a,currentNodeStyle:c}=r;if(!i||!s)return;function l(d){const h=s.getComputedStyle(t,d);let f=h.getPropertyValue("content");if(!f||f==="none")return;o?.(f),f=f.replace(/(')|(")|(counter\(.+\))/g,"");const u=[Pe()],m=_e(t,d,r);c?.forEach((w,S)=>{m.delete(S)});const p=Re(h,m,r.includeStyleProperties);p.delete("content"),p.delete("-webkit-locale"),p.get("background-clip")?.[0]==="text"&&e.classList.add("______background-clip--text");const g=[`content: '${f}';`];if(p.forEach(([w,S],L)=>{g.push(`${L}: ${w}${S?" !important":""};`)}),g.length===1)return;try{e.className=[e.className,...u].join(" ")}catch(w){r.log.warn("Failed to copyPseudoClass",w);return}const y=g.join(`
|
|
312
|
+
`);let k=a.get(y);k||(k=[],a.set(y,k)),k.push(`.${u[0]}${d}`)}Er.forEach(l),n&&Cr.forEach(l)}const De=new Set(["symbol"]);async function $e(t,e,n,r,o){if(A(n)&&(Qn(n)||tr(n))||r.filter&&!r.filter(n))return;De.has(e.nodeName)||De.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;const s=await Rt(n,r,!1,o);r.isEnable("restoreScrollPosition")&&Ar(t,s),e.appendChild(s)}async function Be(t,e,n,r){let o=t.firstChild;A(t)&&t.shadowRoot&&(o=t.shadowRoot?.firstChild,n.shadowRoots.push(t.shadowRoot));for(let s=o;s;s=s.nextSibling)if(!Gn(s))if(A(s)&&nr(s)&&typeof s.assignedNodes=="function"){const i=s.assignedNodes();for(let a=0;a<i.length;a++)await $e(t,e,i[a],n,r)}else await $e(t,e,s,n,r)}function Ar(t,e){if(!et(t)||!et(e))return;const{scrollTop:n,scrollLeft:r}=t;if(!n&&!r)return;const{transform:o}=e.style,s=new DOMMatrix(o),{a:i,b:a,c,d:l}=s;s.a=1,s.b=0,s.c=0,s.d=1,s.translateSelf(-r,-n),s.a=i,s.b=a,s.c=c,s.d=l,e.style.transform=s.toString()}function Pr(t,e){const{backgroundColor:n,width:r,height:o,style:s}=e,i=t.style;if(n&&i.setProperty("background-color",n,"important"),r&&i.setProperty("width",`${r}px`,"important"),o&&i.setProperty("height",`${o}px`,"important"),s)for(const a in s)i[a]=s[a]}const Nr=/^[\w-:]+$/;async function Rt(t,e,n=!1,r){const{ownerDocument:o,ownerWindow:s,fontFamilies:i,onCloneEachNode:a}=e;if(o&&Xn(t))return r&&/\S/.test(t.data)&&r(t.data),o.createTextNode(t.data);if(o&&s&&A(t)&&(et(t)||tt(t))){const l=await br(t,e);if(e.isEnable("removeAbnormalAttributes")){const p=l.getAttributeNames();for(let g=p.length,y=0;y<g;y++){const k=p[y];Nr.test(k)||l.removeAttribute(k)}}const d=e.currentNodeStyle=vr(t,l,n,e);n&&Pr(l,e);let h=!1;if(e.isEnable("copyScrollbar")){const p=[d.get("overflow-x")?.[0],d.get("overflow-y")?.[0]];h=p.includes("scroll")||(p.includes("auto")||p.includes("overlay"))&&(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)}const f=d.get("text-transform")?.[0],u=Ne(d.get("font-family")?.[0]),m=u?p=>{f==="uppercase"?p=p.toUpperCase():f==="lowercase"?p=p.toLowerCase():f==="capitalize"&&(p=p[0].toUpperCase()+p.substring(1)),u.forEach(g=>{let y=i.get(g);y||i.set(g,y=new Set),p.split("").forEach(k=>y.add(k))})}:void 0;return Tr(t,l,h,e,m),Sr(t,l),ut(t)||await Be(t,l,e,m),await a?.(l),l}const c=t.cloneNode(!1);return await Be(t,c,e),await a?.(c),c}function Oe(t){if(t.ownerDocument=void 0,t.ownerWindow=void 0,t.svgStyleElement=void 0,t.svgDefsElement=void 0,t.svgStyles.clear(),t.defaultComputedStyles.clear(),t.sandbox){try{t.sandbox.remove()}catch(e){t.log.warn("Failed to destroyContext",e)}t.sandbox=void 0}t.workers=[],t.fontFamilies.clear(),t.fontCssTexts.clear(),t.requests.clear(),t.tasks=[],t.shadowRoots=[]}function Ir(t){const{url:e,timeout:n,responseType:r,...o}=t,s=new AbortController,i=n?setTimeout(()=>s.abort(),n):void 0;return fetch(e,{signal:s.signal,...o}).then(a=>{if(!a.ok)throw new Error("Failed fetch, not 2xx response",{cause:a});switch(r){case"arrayBuffer":return a.arrayBuffer();case"dataUrl":return a.blob().then(cr);default:return a.text()}}).finally(()=>clearTimeout(i))}function nt(t,e){const{url:n,requestType:r="text",responseType:o="text",imageDom:s}=e;let i=n;const{timeout:a,acceptOfImage:c,requests:l,fetchFn:d,fetch:{requestInit:h,bypassingCache:f,placeholderImage:u},font:m,workers:p,fontFamilies:g}=t;r==="image"&&(ht||Lt)&&t.drawImageCount++;let y=l.get(n);if(!y){f&&f instanceof RegExp&&f.test(i)&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());const k=r.startsWith("font")&&m&&m.minify,w=new Set;k&&r.split(";")[1].split(",").forEach(gt=>{g.has(gt)&&g.get(gt).forEach(Ge=>w.add(Ge))});const S=k&&w.size,L={url:i,timeout:a,responseType:S?"arrayBuffer":o,headers:r==="image"?{accept:c}:void 0,...h};y={type:r,resolve:void 0,reject:void 0,response:null},y.response=(async()=>{if(d&&r==="image"){const N=await d(n);if(N)return N}return!ht&&n.startsWith("http")&&p.length?new Promise((N,gt)=>{p[l.size&p.length-1].postMessage({rawUrl:n,...L}),y.resolve=N,y.reject=gt}):Ir(L)})().catch(N=>{if(l.delete(n),r==="image"&&u)return t.log.warn("Failed to fetch image base64, trying to use placeholder image",i),typeof u=="string"?u:u(s);throw N}),l.set(n,y)}return y.response}async function Ue(t,e,n,r){if(!je(t))return t;for(const[o,s]of Mr(t,e))try{const i=await nt(n,{url:s,requestType:r?"image":"text",responseType:"dataUrl"});t=t.replace(Fr(o),`$1${i}$3`)}catch(i){n.log.warn("Failed to fetch css data url",o,i)}return t}function je(t){return/url\((['"]?)([^'"]+?)\1\)/.test(t)}const He=/url\((['"]?)([^'"]+?)\1\)/g;function Mr(t,e){const n=[];return t.replace(He,(r,o,s)=>(n.push([s,Se(s,e)]),r)),n.filter(([r])=>!_t(r))}function Fr(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}const Lr=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function _r(t,e){return Lr.map(n=>{const r=t.getPropertyValue(n);return!r||r==="none"?null:((ht||Lt)&&e.drawImageCount++,Ue(r,null,e,!0).then(o=>{!o||r===o||t.setProperty(n,o,t.getPropertyPriority(n))}))}).filter(Boolean)}function Rr(t,e){if(B(t)){const n=t.currentSrc||t.src;if(!_t(n))return[nt(e,{url:n,imageDom:t,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(t.srcset="",t.dataset.originalSrc=n,t.src=r||"")})];(ht||Lt)&&e.drawImageCount++}else if(tt(t)&&!_t(t.href.baseVal)){const n=t.href.baseVal;return[nt(e,{url:n,imageDom:t,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(t.dataset.originalSrc=n,t.href.baseVal=r||"")})]}return[]}function Dr(t,e){const{ownerDocument:n,svgDefsElement:r}=e,o=t.getAttribute("href")??t.getAttribute("xlink:href");if(!o)return[];const[s,i]=o.split("#");if(i){const a=`#${i}`,c=e.shadowRoots.reduce((l,d)=>l??d.querySelector(`svg ${a}`),n?.querySelector(`svg ${a}`));if(s&&t.setAttribute("href",a),r?.querySelector(a))return[];if(c)return r?.appendChild(c.cloneNode(!0)),[];if(s)return[nt(e,{url:s,responseType:"text"}).then(l=>{r?.insertAdjacentHTML("beforeend",l)})]}return[]}function Ve(t,e){const{tasks:n}=e;A(t)&&((B(t)||ve(t))&&n.push(...Rr(t,e)),qn(t)&&n.push(...Dr(t,e))),et(t)&&n.push(..._r(t.style,e)),t.childNodes.forEach(r=>{Ve(r,e)})}async function $r(t,e){const{ownerDocument:n,svgStyleElement:r,fontFamilies:o,fontCssTexts:s,tasks:i,font:a}=e;if(!(!n||!r||!o.size))if(a&&a.cssText){const c=We(a.cssText,e);r.appendChild(n.createTextNode(`${c}
|
|
313
|
+
`))}else{const c=Array.from(n.styleSheets).filter(u=>{try{return"cssRules"in u&&!!u.cssRules.length}catch(m){return e.log.warn(`Error while reading CSS rules from ${u.href}`,m),!1}}),l=n.implementation.createHTMLDocument(""),d=l.createElement("style");l.head.appendChild(d);const h=d.sheet;await Promise.all(c.flatMap(u=>Array.from(u.cssRules).map(async m=>{if(Wn(m)){const p=m.href;let g="";try{g=await nt(e,{url:p,requestType:"text",responseType:"text"})}catch(k){e.log.warn(`Error fetch remote css import from ${p}`,k)}const y=g.replace(He,(k,w,S)=>k.replace(S,Se(S,p)));for(const k of Or(y))try{h.insertRule(k,h.cssRules.length)}catch(w){e.log.warn("Error inserting rule from remote css import",{rule:k,error:w})}}}))),h.cssRules.length&&c.push(h);const f=[];c.forEach(u=>{Dt(u.cssRules,f)}),f.filter(u=>zn(u)&&je(u.style.getPropertyValue("src"))&&Ne(u.style.getPropertyValue("font-family"))?.some(m=>o.has(m))).forEach(u=>{const m=u,p=s.get(m.cssText);p?r.appendChild(n.createTextNode(`${p}
|
|
311
314
|
`)):i.push(Ue(m.cssText,m.parentStyleSheet?m.parentStyleSheet.href:null,e).then(g=>{g=We(g,e),s.set(m.cssText,g),r.appendChild(n.createTextNode(`${g}
|
|
312
|
-
`))}))})}}const Br=/(\/\*[\s\S]*?\*\/)/g,ze=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function Or(t){if(t==null)return[];const e=[];let n=t.replace(Br,"");for(;;){const s=ze.exec(n);if(!s)break;e.push(s[0])}n=n.replace(ze,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let s=r.exec(n);if(s)o.lastIndex=r.lastIndex;else if(s=o.exec(n),s)r.lastIndex=o.lastIndex;else break;e.push(s[0])}return e}const Ur=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function We(t,e){const{font:n}=e,r=n?n?.preferredFormat:void 0;return r?t.replace(jr,o=>{for(;;){const[s,,i]=Ur.exec(o)||[];if(!i)return"";if(i===r)return`src: ${s};`}}):t}function
|
|
315
|
+
`))}))})}}const Br=/(\/\*[\s\S]*?\*\/)/g,ze=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function Or(t){if(t==null)return[];const e=[];let n=t.replace(Br,"");for(;;){const s=ze.exec(n);if(!s)break;e.push(s[0])}n=n.replace(ze,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let s=r.exec(n);if(s)o.lastIndex=r.lastIndex;else if(s=o.exec(n),s)r.lastIndex=o.lastIndex;else break;e.push(s[0])}return e}const Ur=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function We(t,e){const{font:n}=e,r=n?n?.preferredFormat:void 0;return r?t.replace(jr,o=>{for(;;){const[s,,i]=Ur.exec(o)||[];if(!i)return"";if(i===r)return`src: ${s};`}}):t}function Dt(t,e=[]){for(const n of Array.from(t))Kn(n)?e.push(...Dt(n.cssRules)):"cssRules"in n?Dt(n.cssRules,e):e.push(n);return e}const Hr=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function Vr(t){return Hr.test(t.innerHTML)}async function Ke(t,e){const n=await P(t,e);if(A(n.node)&&tt(n.node)&&!Vr(n.node))return n.node;const{ownerDocument:r,log:o,tasks:s,svgStyleElement:i,svgDefsElement:a,svgStyles:c,font:l,progress:d,autoDestruct:h,onCloneNode:f,onEmbedNode:u,onCreateForeignObjectSvg:m}=n;o.time("clone node");const p=await Rt(n.node,n,!0);if(i&&r){let S="";c.forEach((L,N)=>{S+=`${L.join(`,
|
|
313
316
|
`)} {
|
|
314
317
|
${N}
|
|
315
318
|
}
|
|
316
|
-
`}),i.appendChild(r.createTextNode(S))}o.timeEnd("clone node"),await f?.(p),l!==!1&&A(p)&&(o.time("embed web font"),await $r(p,n),o.timeEnd("embed web font")),o.time("embed node"),Ve(p,n);const g=s.length;let y=0;const k=async()=>{for(;;){const S=s.pop();if(!S)break;try{await S}catch(L){n.log.warn("Failed to run task",L)}d?.(++y,g)}};d?.(y,g),await Promise.all([...Array.from({length:4})].map(k)),o.timeEnd("embed node"),await u?.(p);const w=zr(p,n);return a&&w.insertBefore(a,w.children[0]),i&&w.insertBefore(i,w.children[0]),h&&Oe(n),await m?.(w),w}function zr(t,e){const{width:n,height:r}=e,o=Ee(n,r,t.ownerDocument),s=o.ownerDocument.createElementNS(o.namespaceURI,"foreignObject");return s.setAttributeNS(null,"x","0%"),s.setAttributeNS(null,"y","0%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.append(t),o.appendChild(s),o}async function
|
|
319
|
+
`}),i.appendChild(r.createTextNode(S))}o.timeEnd("clone node"),await f?.(p),l!==!1&&A(p)&&(o.time("embed web font"),await $r(p,n),o.timeEnd("embed web font")),o.time("embed node"),Ve(p,n);const g=s.length;let y=0;const k=async()=>{for(;;){const S=s.pop();if(!S)break;try{await S}catch(L){n.log.warn("Failed to run task",L)}d?.(++y,g)}};d?.(y,g),await Promise.all([...Array.from({length:4})].map(k)),o.timeEnd("embed node"),await u?.(p);const w=zr(p,n);return a&&w.insertBefore(a,w.children[0]),i&&w.insertBefore(i,w.children[0]),h&&Oe(n),await m?.(w),w}function zr(t,e){const{width:n,height:r}=e,o=Ee(n,r,t.ownerDocument),s=o.ownerDocument.createElementNS(o.namespaceURI,"foreignObject");return s.setAttributeNS(null,"x","0%"),s.setAttributeNS(null,"y","0%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.append(t),o.appendChild(s),o}async function mt(t,e){const n=await P(t,e),r=await Ke(n),o=Ce(r,n.isEnable("removeControlCharacter"));n.autoDestruct||(n.svgStyleElement=Fe(n.ownerDocument),n.svgDefsElement=n.ownerDocument?.createElementNS(pt,"defs"),n.svgStyles.clear());const s=D(o,r.ownerDocument);return await fr(s,n)}async function Wr(t,e){const n=await P(t,e),{log:r,type:o,quality:s,dpi:i}=n,a=await mt(n);r.time("canvas to blob");const c=await ir(a,o,s);if(["image/png","image/jpeg"].includes(o)&&i){const l=await lr(c.slice(0,33));let d=new Uint8Array(l);return o==="image/png"?d=be(d,i):o==="image/jpeg"&&(d=fe(d,i)),r.timeEnd("canvas to blob"),new Blob([d,c.slice(33)],{type:o})}return r.timeEnd("canvas to blob"),c}async function U(t,e){const n=await P(t,e),{log:r,quality:o,type:s,dpi:i}=n,a=await mt(n);r.time("canvas to data url");let c=a.toDataURL(s,o);if(["image/png","image/jpeg"].includes(s)&&i&&ke&&Hn){const[l,d]=c.split(",");let h=0,f=!1;if(s==="image/png"){const w=Un(d);w>=0?(h=Math.ceil((w+28)/3)*4,f=!0):h=44}else s==="image/jpeg"&&(h=24);const u=d.substring(0,h),m=d.substring(h),p=window.atob(u),g=new Uint8Array(p.length);for(let w=0;w<g.length;w++)g[w]=p.charCodeAt(w);const y=s==="image/png"?be(g,i,f):fe(g,i),k=window.btoa(String.fromCharCode(...y));c=[l,",",k,m].join("")}return r.timeEnd("canvas to data url"),c}async function qe(t,e){const n=await P(t,e),{width:r,height:o,ownerDocument:s}=n,i=await U(n),a=Ee(r,o,s),c=a.ownerDocument.createElementNS(a.namespaceURI,"image");return c.setAttributeNS(null,"href",i),c.setAttributeNS(null,"height","100%"),c.setAttributeNS(null,"width","100%"),a.appendChild(c),Ce(a,n.isEnable("removeControlCharacter"))}async function Kr(t,e){const n=await P(t,e),{ownerDocument:r,width:o,height:s,scale:i,type:a}=n,c=a==="image/svg+xml"?await qe(n):await U(n),l=D(c,r);return l.width=Math.floor(o*i),l.height=Math.floor(s*i),l.style.width=`${o}px`,l.style.height=`${s}px`,l}async function qr(t,e){return U(await P(t,{...e,type:"image/jpeg"}))}async function Gr(t,e){const n=await P(t,e),r=await mt(n);return r.getContext("2d").getImageData(0,0,r.width,r.height).data}async function Xr(t,e){return U(await P(t,{...e,type:"image/png"}))}async function Yr(t,e){return U(await P(t,{...e,type:"image/webp"}))}const Jr=Object.freeze(Object.defineProperty({__proto__:null,createContext:Me,destroyContext:Oe,domToBlob:Wr,domToCanvas:mt,domToDataUrl:U,domToForeignObjectSvg:Ke,domToImage:Kr,domToJpeg:qr,domToPixel:Gr,domToPng:Xr,domToSvg:qe,domToWebp:Yr,loadMedia:O,waitUntilLoad:Ae},Symbol.toStringTag,{value:"Module"}));return Ln})();
|
|
317
320
|
//# sourceMappingURL=feedbackkit.iife.js.map
|