feedbackkit-web 1.0.50 → 1.0.51

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