@lumen-stack/react 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var Rn=require('react'),sonner=require('sonner'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Rn__namespace=/*#__PURE__*/_interopNamespace(Rn);var N=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},zt=class extends N{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},Kt=class extends N{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},at=class extends N{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},br="https://shakebugs.vercel.app",vr="/api/v1/sdk/submit",wr=new Set([502,503,504]),en=class{apiKey;apiUrl;user;amplitude;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new N("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??br).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${vr}`,r=this.#e(e),o=null;for(let a=0;a<3;a++){a>0&&await Er(2**a*250);try{return await this.#t(n,r,t)}catch(i){if(o=i,i instanceof zt||i instanceof Kt||i instanceof N&&typeof i.status=="number"&&!wr.has(i.status))throw i}}throw o instanceof Error?o:new at("Submit failed after 3 attempts.")}#e(e){let t=new FormData;e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),e.submitterEmail&&t.append("submitterEmail",e.submitterEmail),e.submitterFingerprint&&t.append("submitterFingerprint",e.submitterFingerprint);let n=e.context.amplitude??this.amplitude,r=n?{...e.context,amplitude:n}:e.context;return t.append("context",JSON.stringify(r)),e.screenshot&&t.append("screenshot",e.screenshot,yr(e.screenshot)),e.audio&&t.append("audio",e.audio,"audio"),e.audioDurationMs!=null&&t.append("audioDurationMs",String(e.audioDurationMs)),e.video&&t.append("video",e.video,"video"),e.videoDurationMs!=null&&t.append("videoDurationMs",String(e.videoDurationMs)),t}#t(e,t,n){return new Promise((r,o)=>{let a=new XMLHttpRequest;a.open("POST",e,true),a.setRequestHeader("X-Lumen-Api-Key",this.apiKey),a.responseType="text";let{onUploadProgress:i,signal:s}=n;i&&a.upload.addEventListener("progress",u=>{u.lengthComputable&&u.total>0&&i(Math.min(1,u.loaded/u.total));});let l=()=>{a.abort(),o(new at("Submit aborted."));};if(s){if(s.aborted){o(new at("Submit aborted."));return}s.addEventListener("abort",l,{once:true});}a.addEventListener("load",()=>{if(s&&s.removeEventListener("abort",l),a.status===403){o(new zt);return}if(a.status===429){let u=Number(a.getResponseHeader("Retry-After"))||60;o(new Kt(u));return}if(a.status<200||a.status>=300){o(new N(Cr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let u=JSON.parse(a.responseText);r(u);}catch{o(new N("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{s&&s.removeEventListener("abort",l),o(new at("Network error during submit."));}),a.send(t);})}};function yr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Er(e){return new Promise(t=>setTimeout(t,e))}function Cr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var tn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function nn(e=tn){if(!e||typeof document>"u")return ()=>{};let t=[];for(let n of Array.from(document.querySelectorAll(e)))t.push({el:n,prev:n.style.visibility}),n.style.visibility="hidden";return ()=>{for(let{el:n,prev:r}of t)n.style.visibility=r;}}var Rr=2,Sr=1.5,xr=820,kr=12,$e=8*1024*1024;async function lt(e={}){kt();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return Ir(await e.provider(),e)}catch(n){if(t==="custom")throw n;e.onWarning?.(["Custom capture provider failed; falling back to browser DOM capture."]);}if(t==="manual")throw new N("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return jt(e);if(t==="dom")return $t(e);if(t==="custom")throw new N("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await $t(e)}catch(n){if(ln()){let r=await jt(e);return r.warnings=je(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function qe(e,t=[]){kt();let n=ut();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:je(t)}}var Wt=Promise.resolve();function $t(e){let t=Wt.then(()=>qt(e),()=>qt(e));return Wt=t.catch(()=>{}),t}async function qt(e){let t=await Nr(),n=e.target??document.documentElement,r=ut(),o=Or(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),s=window.scrollY+(a?.offsetTop??0),l=Br(e,r.width,r.height),u=Dr(n);!e.provider&&Ar()&&u.unshift(`Lumen is capturing inside a React Native WebView with no native capture provider, so this screenshot is a DOM re-render \u2014 it won't match the native screen and omits native overlays/inputs. Wire createNativeCaptureProvider() with capture mode "custom" (see docs/native-screenshot-expo.md).`);let d=Tr(n);await sn(e.awaitAnimationsMs??Vr),await Hr();let p=await t(n,{backgroundColor:null,logging:false,useCORS:true,allowTaint:false,width:r.width,height:r.height,windowWidth:o.width,windowHeight:o.height,scrollX:window.scrollX,scrollY:window.scrollY,x:i,y:s,scale:l,ignoreElements:w=>w instanceof HTMLElement&&(w.dataset.lumenCaptureIgnore==="true"||!!w.closest("[data-lumen-capture-ignore='true']")),onclone:(w,g)=>{Pr(g,d),Mr(w);}}),h={blob:await an(p,u),method:"web-dom",platform:"web",viewport:r,pixelRatio:l,warnings:je(u)};return h.warnings.length>0&&e.onWarning?.(h.warnings),h}var rn=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function Mr(e){for(let t of Array.from(e.querySelectorAll(rn))){if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){let n=t;n.value&&(n.value="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");continue}t.style.visibility="hidden";}}var Lr="[data-lumen-root], [data-lumen-capture-ignore='true']";function on(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(Lr))}function Tr(e){return on(e).map(t=>{if(t.matches(rn))return {skip:true};let n=t.type;return n==="checkbox"||n==="radio"?{skip:false,checked:t.checked}:n==="file"?{skip:true}:{skip:false,value:t.value}})}function Pr(e,t){let n=on(e);n.length===t.length&&n.forEach((r,o)=>{let a=t[o];!a||a.skip||(a.checked!==void 0?r.checked=a.checked:a.value!==void 0&&(r.value=a.value));});}function Ar(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function Nr(){let{default:e}=await import('html2canvas-pro');return e}async function xt(e={}){if(kt(),!ln())throw new N("Browser screen capture is unavailable in this environment.","DISPLAY_MEDIA_UNAVAILABLE");let t=await navigator.mediaDevices.getDisplayMedia({video:true,audio:false}),n=null;try{n=document.createElement("video"),n.muted=!0,n.playsInline=!0,n.srcObject=t,await Fr(n);}catch(i){for(let s of t.getTracks())s.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(s=>s());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let s=i?.conceal??true,l=s?nn():()=>{};try{s&&await Ur(r,3,400);let u=document.createElement("canvas");u.width=r.videoWidth,u.height=r.videoHeight;let d=u.getContext("2d");if(!d)throw new N("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");d.drawImage(r,0,0,u.width,u.height);let p=ut(),h=["Browser screen capture uses the window or tab selected by the user."],w={blob:await an(u,h),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?u.width/p.width:void 0,warnings:je(h)};return e.onWarning?.(w.warnings),w}finally{l();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function jt(e){let t=await xt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function Ir(e,t){let n=ut(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:je(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function Dr(e){let t=new Set;e.querySelector("iframe")&&t.add("Embedded iframes may be blank or incomplete in DOM capture."),e.querySelector("video")&&t.add("Video frames may be blank or stale in DOM capture."),e.querySelector("canvas")&&t.add("Canvas/WebGL content may be blank if it is cross-origin tainted."),document.fonts&&document.fonts.status!=="loaded"&&t.add("Web fonts were still loading when the screenshot was captured.");let n=0;for(let r of Array.from(e.querySelectorAll("img"))){let o=r.currentSrc||r.src;if(o)try{new URL(o,window.location.href).origin!==window.location.origin&&!r.crossOrigin&&(n+=1);}catch{}}return n>0&&t.add(`${n} cross-origin image${n===1?"":"s"} without CORS may be omitted from the screenshot.`),Array.from(t)}async function an(e,t){let n=await Yt(e,"image/png",.92);if(n.size<=$e)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>$e&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt($e/n.size)*.9)),i=document.createElement("canvas");i.width=Math.max(1,Math.round(r.width*a)),i.height=Math.max(1,Math.round(r.height*a));let s=i.getContext("2d");if(!s)return n;s.drawImage(r,0,0,i.width,i.height),r=i;for(let l of [.86,.74,.62,.5])if(n=await Yt(r,"image/jpeg",l),n.size<=$e)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>$e&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function Yt(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new N("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function ut(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function Or(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function Br(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??Rr;_r()&&(o=Math.min(o,Sr));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(kr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function _r(){let e=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0||typeof window<"u"&&"ontouchstart"in window,t=document.documentElement.clientWidth||window.innerWidth||0;return e&&t>0&&t<=xr}function Hr(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var Vr=400;async function sn(e){if(typeof document>"u"||typeof document.getAnimations!="function"||!(e>0))return;let t;try{t=document.getAnimations();}catch{return}let n=t.filter(a=>{if(a.playState!=="running")return false;let i=a.effect?.getComputedTiming?.();return !!i&&i.iterations!==1/0});if(n.length===0)return;let r=Promise.allSettled(n.map(a=>a.finished)).then(()=>{}),o=new Promise(a=>setTimeout(a,e));await Promise.race([r,o]);}function ln(){return !!navigator.mediaDevices?.getDisplayMedia}async function Fr(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new N("Could not read screen capture video.","VIDEO_FAILED"));e.addEventListener("loadedmetadata",a,{once:true}),e.addEventListener("error",i,{once:true}),e.play().catch(i);});let t=performance.now(),n=1500;for(;e.videoWidth===0||e.videoHeight===0;){if(performance.now()-t>n)throw new N("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function Ur(e,t,n){let r=e.requestVideoFrameCallback?.bind(e);if(typeof r!="function"){await new Promise(i=>setTimeout(i,Math.min(n,250)));return}let o=performance.now(),a=0;await new Promise(i=>{let s=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(s);};r(s),setTimeout(i,n);});}function kt(){if(typeof window>"u"||typeof document>"u")throw new N("Screenshot capture can only run in the browser.","INVALID_ENV")}function je(e){return Array.from(new Set(e.filter(Boolean)))}var un=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,zr=[/-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )?PRIVATE KEY-----/g,/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,/\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA|ANVA|AIPA)[A-Z0-9]{16}\b/g,/\bgh[posru]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{18,}\b/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,/\bAIza[A-Za-z0-9_-]{35}\b/g,/\b[srp]k_(?:live|test)_[A-Za-z0-9]{10,}\b/g,/\bsk-(?:proj-|ant-)?[A-Za-z0-9_-]{32,}\b/g];function Kr(e){let t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return false;let n=0,r=false;for(let o=t.length-1;o>=0;o--){let a=t.charCodeAt(o)-48;r&&(a*=2,a>9&&(a-=9)),n+=a,r=!r;}return n%10===0}function Et(e){let t=e;for(let n of zr)t=t.replace(n,"***");return t=t.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._\-+/=]+/gi,"$1 ***"),t=t.replace(/\b([A-Za-z_][\w-]*)"?\s*[=:]\s*("?)([^"\s&]{6,})\2/g,(n,r,o,a)=>/^(Bearer|Basic)$/i.test(a)?n:un.test(r)?`${r}=${o}***${o}`:a.length>=24&&/^[A-Za-z0-9._\-+/=]+$/.test(a)&&!a.includes(" ")?`${r}=${o}${a.slice(0,4)}\u2026${o}`:n),t=t.replace(/\b\d(?:[ -]?\d){12,18}\b/g,n=>Kr(n)?"***":n),t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***"),t=t.replace(/\b[\w.+-]+@[\w-]+\.[\w.-]+\b/g,"***@***"),t}function cn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])un.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Et(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Et(e)}}function dn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return cn(e)}}var Gt=200,Zt=4096,mn=[],it=[],Xt=false,Ct=null;function pn(e={}){Xt||typeof window>"u"||(Xt=true,Ct=e.ignoreUrlPrefix??null,jr(),Yr(),Gr());}function Wr(){return {consoleLog:mn.slice(),networkLog:it.slice()}}function st(e,t){e.push(t),e.length>Gt&&e.splice(0,e.length-Gt);}function $r(e){let t=[];for(let r of e){if(typeof r=="string"){t.push(r);continue}if(r instanceof Error){t.push(`${r.name}: ${r.message}${r.stack?`
|
|
3
|
-
${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,qr));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>Zt?n.slice(0,Zt)+"\u2026[truncated]":n}function qr(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function jr(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let r=e[n]?.bind(e);r&&(e[n]=(...o)=>{try{st(mn,{level:n,ts:Date.now(),message:Et($r(o))});}catch{}r(...o);});}}function fn(e){return Ct?e.startsWith(Ct):false}function Yr(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let r=typeof t=="string"?t:t instanceof URL?t.toString():t.url,o=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(fn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return st(it,{type:"fetch",method:o,url:Rt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw st(it,{type:"fetch",method:o,url:Rt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Gr(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...a){return this.__lumen={method:String(r).toUpperCase(),url:typeof o=="string"?o:o.toString(),t:0},t.call(this,r,o,...a)},e.prototype.send=function(r){let o=this.__lumen;if(o&&!fn(o.url)){o.t=performance.now();let a=()=>{try{st(it,{type:"xhr",method:o.method,url:Rt(o.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-o.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,r??null)};}function Zr(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Rt(e){return Zr(cn(e))}function gn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:Jt(e),consoleLog:[],networkLog:[]};let t=Wr();return {url:dn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:Jt(e),device:Xr(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function Xr(){let e={};try{e.screen={width:window.screen?.width??0,height:window.screen?.height??0},e.pixelRatio=window.devicePixelRatio??1,e.language=navigator.language,e.languages=Array.from(navigator.languages??[]),e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,e.colorScheme=window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light",e.referrer=document.referrer?dn(document.referrer):void 0,e.title=document.title||void 0,e.online=navigator.onLine,performance.getEntriesByType("navigation")[0]&&(e.uptimeMs=Math.round(performance.now()));}catch{}return e}function Jt(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var Jr="[data-lumen-root]",Qr="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function eo(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(St(n))return true;return St(e.target)}var Qt=["pointerdown","mousedown","touchstart","click"];function to(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of Qt)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of Qt)e.removeEventListener(n,t);}}function St(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(Qr)?true:!!e.closest(Jr):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?St(e.host):false:false}var ct="lumen:shake",no=8e3,ro=50,oo=400;function ao(e={}){return async function(){if(typeof window>"u")throw new N("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=so(),n=e.send??io,r=e.timeoutMs??no,o=e.captureSettleMs??ro,a=e.awaitAnimationsMs??oo,i=po(),s=nn(e.concealSelector===void 0?tn:e.concealSelector);try{await uo(o,a);let l=await new Promise((p,h)=>{let w=window.setTimeout(()=>{t.pending.delete(i),h(new N("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:g=>{window.clearTimeout(w),p(g);},reject:g=>{window.clearTimeout(w),h(g);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(w),h(new N("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(l.error||!l.dataUrl)throw new N(l.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let u=fo(l.dataUrl),d=e.platform??mo();return {blob:u,method:d==="android"?"android-native":"ios-native",platform:d,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:l.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{s();}}}function io(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new N("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function so(){if(window.__lumenNativeCapture)return window.__lumenNativeCapture;let e={pending:new Map,resolve(n,r,o){let a=e.pending.get(n);a&&(e.pending.delete(n),a.resolve({type:"lumen:capture-response",id:n,dataUrl:r,pixelRatio:o}));},reject(n,r){let o=e.pending.get(n);o&&(e.pending.delete(n),o.resolve({type:"lumen:capture-response",id:n,error:r}));}},t=n=>{let r=lo(n.data);if(!r||r.type!=="lumen:capture-response")return;let o=e.pending.get(r.id);o&&(e.pending.delete(r.id),o.resolve(r));};return window.addEventListener("message",t),document.addEventListener("message",t),window.__lumenNativeCapture=e,e}function lo(e){if(e&&typeof e=="object"&&"type"in e)return e;if(typeof e=="string")try{let t=JSON.parse(e);if(t&&typeof t=="object"&&t.type)return t}catch{}return null}async function uo(e,t){await sn(t),await co(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function co(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function mo(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function po(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function fo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new N("Native host returned an invalid image data URL.","NATIVE_CAPTURE_FAILED");let n=t[1]||"image/png",r=!!t[2],o=t[3]??"";if(!r)return new Blob([decodeURIComponent(o)],{type:n});let a=atob(o),i=new Uint8Array(a.length);for(let s=0;s<a.length;s++)i[s]=a.charCodeAt(s);return new Blob([i],{type:n})}var Ye="lumen:keyboardchange",Mt="--lumen-keyboard-inset";function go(e){if(typeof window>"u")return;let t=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):0;window.__lumenKeyboardInset=t,typeof document<"u"&&document.documentElement.style.setProperty(Mt,`${t}px`),window.dispatchEvent(new Event(Ye));}function Lt(){if(typeof window>"u")return null;let e=window.__lumenKeyboardInset;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof document<"u"&&typeof getComputedStyle=="function"){let t=getComputedStyle(document.documentElement).getPropertyValue(Mt).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function hn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new N("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new N("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(w=>MediaRecorder.isTypeSupported(w))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((w,g)=>{u=w,d=g;});p.catch(()=>{}),r.addEventListener("dataavailable",w=>{w.data&&w.data.size>0&&o.push(w.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let x of t.getTracks())x.stop();if(l)return;if(l=true,s){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let w=performance.now()-a,g=r.mimeType||n||"audio/webm",S=new Blob(o,{type:g});u({blob:S,durationMs:w,mimeType:g});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function h(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){s=true,h(),i!==null&&window.clearTimeout(i),i=null;for(let w of t.getTracks())w.stop();},stop(){return h(),p}}}async function bn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new N("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new N("Screen capture was denied or cancelled.","SCREEN_DENIED")}let n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(g=>MediaRecorder.isTypeSupported(g))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((g,S)=>{u=g,d=S;});p.catch(()=>{});function h(){i!==null&&(window.clearTimeout(i),i=null);for(let g of t.getTracks())g.stop();}r.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&o.push(g.data);}),r.addEventListener("stop",()=>{if(s)return;if(s=true,h(),l){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let g=r.mimeType||n||"video/webm";u({blob:new Blob(o,{type:g}),durationMs:performance.now()-a,mimeType:g});});function w(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(w,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",w),{stream:t,result:p,stop:w,cancel(){l=true,r.state!=="inactive"?r.stop():s||(s=true,h(),d(new N("Recording cancelled.","RECORDER_STOPPED")));}}}var Tt=Rn.createContext(null);function Ge(){let e=Rn.useContext(Tt);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var vn=100;function wn(){if(typeof document>"u")return false;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;if(!e)return false;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?true:e.isContentEditable===true}var Ze={open:false,inset:0};function yo(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:Ze}if(e.vvHeight==null||!e.coarse||!e.editable)return Ze;let n=e.vvBaseline-e.vvHeight;return n>vn?{open:true,inset:Math.round(n)}:Ze}function Xe(e,t){let[n,r]=Rn.useState(Ze),o=Rn.useRef(0),a=Rn.useRef(t);return a.current=t,Rn.useEffect(()=>{if(!e){r(Ze);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,s=()=>{let p=wn(),h=a.current,w=Lt(),g=window.visualViewport??null;g&&h==null&&w==null&&!p&&(o.current=g.height),r(yo({editable:p,override:h,injected:w,vvBaseline:o.current,vvHeight:g?g.height:null,coarse:i}));},l=0,u=()=>{l||(l=window.requestAnimationFrame(()=>{l=0,s();}));},d=window.visualViewport;return d&&(o.current=d.height),u(),d?.addEventListener("resize",u),d?.addEventListener("scroll",u),document.addEventListener("focusin",u),document.addEventListener("focusout",u),window.addEventListener(Ye,u),()=>{l&&window.cancelAnimationFrame(l),d?.removeEventListener("resize",u),d?.removeEventListener("scroll",u),document.removeEventListener("focusin",u),document.removeEventListener("focusout",u),window.removeEventListener(Ye,u);}},[e]),n}var At='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Cn(e,t=1){return Math.max(0,Math.min(t,e))}var Sn=Rn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a},i){let s=Rn.useRef(null),l=Rn.useRef(null),u=Rn.useRef(null),[d,p]=Rn.useState(null),[h,w]=Rn.useState([]),g=Rn.useRef(null),S=Rn.useRef(false),x=Rn.useRef(0),M=Rn.useRef(false),[L,b]=Rn.useState([]),C=Rn.useRef(0),I=Rn.useRef([]),A=Rn.useRef(null),q=Rn.useCallback((f,y)=>{b(k=>k.map(T=>T.id===f?{...T,text:y}:T));},[]),D=Rn.useCallback(f=>{b(k=>k.filter(T=>T.id!==f));let y=I.current.lastIndexOf("comment");y>=0&&I.current.splice(y,1);},[]);Rn.useEffect(()=>{let f=A.current;if(f==null)return;A.current=null,u.current?.querySelector(`[data-bubble-id="${f}"] .lumen-bubble-text`)?.focus();},[L]),Rn.useEffect(()=>{let f=false,y=null;return (async()=>{try{let k=await createImageBitmap(t);if(f){k.close?.();return}y=k,p(k);}catch{}})(),()=>{f=true,y?.close?.();}},[t]),Rn.useEffect(()=>{if(!d)return;let f=s.current,y=l.current;if(!f||!y)return;f.width=d.width,f.height=d.height,y.width=d.width,y.height=d.height;let k=f.getContext("2d");k&&(k.imageSmoothingEnabled=false,k.drawImage(d,0,0));},[d]),Rn.useEffect(()=>{let f=l.current;f&&dt(f,h,g.current);},[h]),Rn.useImperativeHandle(i,()=>({hasAnnotations:()=>h.length>0||L.some(f=>f.text.trim().length>0),reset:()=>{w([]),b([]),I.current=[];},undo:()=>{(I.current.pop()??"anno")==="comment"?b(y=>y.length===0?y:y.slice(0,-1)):w(y=>y.length===0?y:y.slice(0,-1));},async flatten(){let f=g.current,y=f?[...h,f]:h,k=L.filter(F=>F.text.trim().length>0);if(y.length===0&&k.length===0||!d)return t;let T=document.createElement("canvas");T.width=d.width,T.height=d.height;let V=T.getContext("2d");if(!V)return t;V.imageSmoothingEnabled=false,V.drawImage(d,0,0);for(let F of y)Nt(V,F);let K=s.current?.clientWidth||d.width,j=d.width/Math.max(K,1);for(let F of k)xo(V,F,d.width,d.height,j);return await new Promise(F=>{T.toBlob(oe=>{F(oe??t);},"image/jpeg",.85);})}}),[h,L,d,t]);function re(f){let y=l.current;if(!y)return {x:0,y:0};let k=y.getBoundingClientRect(),T=y.width/Math.max(k.width,1),V=y.height/Math.max(k.height,1);return {x:(f.clientX-k.left)*T,y:(f.clientY-k.top)*V}}function _(){M.current||(M.current=true,requestAnimationFrame(()=>{M.current=false;let f=l.current;f&&dt(f,h,g.current);}));}function Ce(f){if(f.button!==void 0&&f.button!==0)return;if(n==="comment"){let k=l.current;if(!k)return;let T=k.getBoundingClientRect(),V=Cn((f.clientX-T.left)/Math.max(T.width,1),.72),K=Cn((f.clientY-T.top)/Math.max(T.height,1),.8),j=++C.current;b(F=>[...F,{id:j,x:V,y:K,text:"",color:r}]),I.current.push("comment"),A.current=j;return}try{f.currentTarget.setPointerCapture(f.pointerId);}catch{}S.current=true,a?.(true);let y=re(f);n==="arrow"?g.current={kind:"arrow",from:y,to:y,color:r,width:o}:n==="rect"?g.current={kind:"rect",from:y,to:y,color:r,width:o}:g.current={kind:"freehand",points:[y],color:r,width:o},x.current=performance.now(),_();}function he(f){if(!S.current||!g.current)return;let y=re(f),k=g.current;if(k.kind==="arrow"||k.kind==="rect")k.to=y;else {let T=k.points[k.points.length-1],V=T?(T.x-y.x)**2+(T.y-y.y)**2:1/0,K=performance.now(),j=K-x.current;(V>16||j>16)&&(k.points.push(y),x.current=K);}_();}function H(){if(!S.current)return;S.current=false,a?.(false);let f=g.current;if(g.current=null,!!f){if(f.kind==="arrow"||f.kind==="rect"){let y=f.to.x-f.from.x,k=f.to.y-f.from.y;if(y*y+k*k<16){let T=l.current;T&&dt(T,h,null);return}}else if(f.points.length<2){let y=l.current;y&&dt(y,h,null);return}w(y=>[...y,f].slice(-50)),I.current.push("anno");}}return jsxRuntime.jsxs("div",{ref:u,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:s}),jsxRuntime.jsx("canvas",{ref:l,className:"lumen-annotate-overlay",onPointerDown:Ce,onPointerMove:he,onPointerUp:H,onPointerCancel:H}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:L.map(f=>jsxRuntime.jsx(Ro,{comment:f,onChange:q,onRemove:D},f.id))})]})});function Ro({comment:e,onChange:t,onRemove:n}){let r=Rn.useRef(null);return Rn.useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxRuntime.jsxs("div",{className:"lumen-bubble","data-bubble-id":e.id,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,"--lumen-bubble-accent":e.color},onPointerDown:o=>o.stopPropagation(),children:[jsxRuntime.jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsxRuntime.jsx("div",{ref:r,className:"lumen-bubble-text",contentEditable:true,suppressContentEditableWarning:true,role:"textbox","aria-label":"Comment text","data-placeholder":"Type a note\u2026",onInput:o=>t(e.id,o.currentTarget.textContent??"")}),jsxRuntime.jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function dt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)Nt(r,o);n&&Nt(r,n);}}function Nt(e,t){if(e.save(),e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",t.kind==="rect"){let n=Math.min(t.from.x,t.to.x),r=Math.min(t.from.y,t.to.y),o=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,r,o,a);}else if(t.kind==="freehand")So(e,t.points);else {let{from:n,to:r,width:o}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke();let a=Math.atan2(r.y-n.y,r.x-n.x),i=Math.max(12,o*4);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(r.x-i*Math.cos(a-Math.PI/7),r.y-i*Math.sin(a-Math.PI/7)),e.lineTo(r.x-i*Math.cos(a+Math.PI/7),r.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function So(e,t){if(t.length===0)return;e.beginPath();let n=t[0];if(!n)return;if(e.moveTo(n.x,n.y),t.length===1){e.arc(n.x,n.y,e.lineWidth/2,0,Math.PI*2),e.fill();return}if(t.length===2){let o=t[1];e.lineTo(o.x,o.y),e.stroke();return}for(let o=1;o<t.length-1;o++){let a=t[o],i=t[o+1],s=(a.x+i.x)/2,l=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,s,l);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function xo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,s=14*o,l=10*o,u=12*o,d=s*1.35,p=l*1.7,h=t.x*n,w=t.y*r,g=Math.min(n*.6,n-h-8*o);e.save(),e.font=`500 ${s}px ${At}`,e.textBaseline="top";let S=ko(e,a,g-i*2),x=S.reduce((A,q)=>Math.max(A,e.measureText(q).width),0),M=Math.min(g,Math.max(x,56*o)+i*2),L=i*2+p+S.length*d;Mo(e,h,w,M,L,u),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let b=h+18*o,C=w+L;e.beginPath(),e.moveTo(b,C-o),e.lineTo(b+13*o,C-o),e.lineTo(b+4*o,C+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${l}px ${At}`,e.fillText("COMMENT",h+i,w+i),e.fillStyle="#111318",e.font=`500 ${s}px ${At}`;let I=w+i+p;for(let A of S)e.fillText(A,h+i,I),I+=d;e.restore();}function ko(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let s=a?`${a} ${i}`:i;a&&e.measureText(s).width>n?(o.push(a),a=i):a=s;}return a&&o.push(a),o.length?o:[t]}function Mo(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function Qe({children:e,...t}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...t,children:e})}function Lo(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("path",{d:"M3 9a2 2 0 0 1 2-2h1.5l1-1.5h5l1 1.5H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),jsxRuntime.jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function To(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsxRuntime.jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Po(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsxRuntime.jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function mt(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function kn(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var It={shot:Lo,video:To,upload:Po};function Mn(e){let t=e.videoWidth||1280,n=e.videoHeight||720,r=document.createElement("canvas");r.width=t,r.height=n;let o=r.getContext("2d");return o?(o.drawImage(e,0,0,t,n),new Promise(a=>r.toBlob(i=>a(i),"image/jpeg",.82))):Promise.resolve(null)}function Ao(e,t){return !Number.isFinite(t)||t<=0?Promise.resolve():new Promise(n=>{e.addEventListener("seeked",()=>n(),{once:true});try{e.currentTime=t;}catch{n();}})}var No=4e3;async function Dt(e){if(typeof document>"u")return {poster:null,durationMs:0};let t=URL.createObjectURL(e),n=document.createElement("video");n.muted=true,n.playsInline=true,n.preload="auto",n.src=t;let r=async()=>{await new Promise((l,u)=>{if(n.readyState>=2)return l();n.addEventListener("loadeddata",()=>l(),{once:true}),n.addEventListener("error",()=>u(new Error("video decode failed")),{once:true});}),await Ao(n,Math.min(.1,(n.duration||0)/2));let i=await Mn(n),s=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:s}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),No);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Ot(e){if(typeof document>"u")return null;let t=document.createElement("video");t.muted=true,t.playsInline=true,t.srcObject=e;try{return await t.play().catch(()=>{}),await new Promise(n=>{if(t.readyState>=2)return n();t.addEventListener("loadeddata",()=>n(),{once:!0}),window.setTimeout(n,600);}),await Mn(t)}catch{return null}finally{t.srcObject=null;}}async function Bt(){if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=1280,e.height=720;let t=e.getContext("2d");return t?(t.fillStyle="#0e0e12",t.fillRect(0,0,e.width,e.height),t.fillStyle="#52525b",t.beginPath(),t.moveTo(590,312),t.lineTo(590,408),t.lineTo(694,360),t.closePath(),t.fill(),new Promise(n=>e.toBlob(r=>n(r),"image/jpeg",.8))):null}var _t=60,Io=25*1024*1024,Ln=[{label:"Red",value:"rgb(239, 68, 68)"},{label:"Amber",value:"rgb(245, 158, 11)"},{label:"Blue",value:"rgb(59, 130, 246)"},{label:"Green",value:"rgb(34, 197, 94)"},{label:"Neutral",value:"rgb(244, 244, 245)"}],Tn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],Pn=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],An=[{value:"shot",label:"Screenshot",hint:"This page, instantly",primary:true},{value:"video",label:"Video",hint:"Record up to 60s"},{value:"upload",label:"Upload",hint:"Image or video"}];function Ht(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:s,consumePendingVideo:l,canRecordScreen:u,consumeRecordStartError:d,startScreenCaptureSession:p,consumePendingScreenshot:h,isolateEvents:w,keyboardInset:g}=Ge(),[S,x]=Rn.useState(1),[M,L]=Rn.useState(null),[b,C]=Rn.useState({kind:"idle"}),[I,A]=Rn.useState(false),[q,D]=Rn.useState(0),[re,_]=Rn.useState(null),[Ce,he]=Rn.useState(false),[H,f]=Rn.useState("arrow"),[y,k]=Rn.useState(Ln[0].value),[T,V]=Rn.useState(Tn[1].value),[K,j]=Rn.useState(""),[F,oe]=Rn.useState("bug"),[Re,nt]=Rn.useState(r?.email??""),[W,Ie]=Rn.useState(null),[X,J]=Rn.useState(null),[de,Se]=Rn.useState(0),[ae,Q]=Rn.useState(null),[me,Y]=Rn.useState(null),[ee,Fe]=Rn.useState(false),pe=Rn.useRef(null),xe=Rn.useRef(null),Ue=Rn.useRef(null),ze=Rn.useRef(null),be=Xe(t,g),ie=Rn.useRef(false),De=Rn.useRef(false);Rn.useEffect(()=>{t||(De.current=false);},[t]),Rn.useEffect(()=>{if(!t)return;if(De.current){ie.current=false;return}De.current=true,ie.current=false,x(1),L(null),j(""),J(null),Se(0),Q(null),A(false),D(0),_(null),he(false),Y(null);let c=h();if(c){L("shot"),Oe(c),C({kind:"ready",capture:c});return}let v=l();if(v)L("video"),Q({blob:v.blob,durationMs:v.durationMs}),v.blob.size>Io&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),v.poster?C({kind:"ready",capture:qe(v.poster,["Screen recording; preview is the first frame."])}):(C({kind:"capturing"}),(async()=>{let P=null;if(v.deriveBlobPoster)try{P=(await Dt(v.blob)).poster;}catch{P=null;}P=P??await Bt(),!ie.current&&C(P?{kind:"ready",capture:qe(P,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let P=d();P?(L("video"),Y(P),C({kind:"idle"})):a?(L("shot"),C({kind:"ready",capture:a})):o?.mode==="manual"?C({kind:"manual"}):o?.provider&&!i?(L("shot"),ve(o.mode??"auto")):C({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ie.current=true;}},[t,o,a,i]),Rn.useEffect(()=>{if(!t)return;ze.current=document.activeElement??null;let c=document.documentElement,v=c.style.overflow,P=c.style.paddingRight,Z=window.innerWidth-c.clientWidth;c.style.overflow="hidden",Z>0&&(c.style.paddingRight=`${Z}px`);let te=false,Me=()=>{if(!te){te=true,c.style.overflow=v,c.style.paddingRight=P;try{ze.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Me),()=>{window.removeEventListener("pagehide",Me),Me();}},[t]),Rn.useEffect(()=>{if(!t)return;function c(v){if(v.key==="Escape"){v.preventDefault(),n();return}if(v.key!=="Tab")return;let P=xe.current;if(!P)return;let Z=Ko(P);if(Z.length===0)return;let te=Z[0],Me=Z[Z.length-1],yt=document.activeElement;v.shiftKey&&(yt===te||!P.contains(yt))?(v.preventDefault(),Me.focus()):!v.shiftKey&&yt===Me&&(v.preventDefault(),te.focus());}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,n]),Rn.useEffect(()=>{if(!t||!w)return;let c=Ue.current;if(!c)return;let v=P=>{P.target===c&&P.stopPropagation();};return c.addEventListener("pointerdown",v),c.addEventListener("click",v),c.addEventListener("touchstart",v,{passive:true}),()=>{c.removeEventListener("pointerdown",v),c.removeEventListener("click",v),c.removeEventListener("touchstart",v);}},[t,w]),Rn.useEffect(()=>{if(!t||!be.open)return;let c=xe.current,v=document.activeElement;if(c&&v&&c.contains(v))try{v.scrollIntoView({block:"center"});}catch{}},[t,be.open,be.inset]),Rn.useEffect(()=>{if(!t||b.kind!=="manual")return;function c(v){let te=Array.from(v.clipboardData?.items??[]).find(Me=>Me.type.startsWith("image/"))?.getAsFile();te&&(v.preventDefault(),G(te));}return window.addEventListener("paste",c),()=>window.removeEventListener("paste",c)},[t,b.kind]),Rn.useEffect(()=>{if(!W)return;let c=Date.now(),v=window.setInterval(()=>{let P=Math.floor((Date.now()-c)/1e3);Se(P),P>=_t&&ye();},250);return ()=>window.clearInterval(v)},[W]);let ke=Rn.useRef(null);if(ke.current=W,Rn.useEffect(()=>{t||ke.current&&(ke.current.cancel(),ke.current=null,Ie(null),Se(0));},[t]),Rn.useEffect(()=>()=>{ke.current?.cancel();},[]),!t)return null;async function ve(c){ie.current=false,C({kind:"capturing"});try{let v=await lt({...o,mode:c,target:o?.target??document.documentElement});return ie.current?!1:(Oe(v),C({kind:"ready",capture:v}),!0)}catch(v){return ie.current||C({kind:"manual",error:v instanceof Error?v.message:"Automatic screenshot capture was unavailable."}),false}}async function fe(c){L(c),Y(null),_(null),c!=="video"&&Be(),c==="shot"?await ve(o?.mode??"auto"):c==="video"?(Q(null),C({kind:"idle"})):C({kind:"manual"});}async function G(c){if(c.type.startsWith("image/")){Be();let v=qe(c,["Manual image upload used."]);C({kind:"ready",capture:v});return}if(c.type.startsWith("video/")){C({kind:"capturing"});try{let{poster:v,durationMs:P}=await Dt(c),Z=v??await Bt();if(!Z){C({kind:"manual",error:"Could not read that video."});return}let te=qe(Z,["Uploaded video; preview is the first frame."]);Q({blob:c,durationMs:P}),C({kind:"ready",capture:te});}catch{C({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function Oe(c){c.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function we(){try{let c=await hn(_t);Ie(c);}catch(c){sonner.toast.error(c instanceof Error?c.message:"Microphone unavailable");}}async function ye(){if(W)try{let c=await W.stop();J({blob:c.blob,durationMs:c.durationMs});}catch(c){sonner.toast.error(c instanceof Error?c.message:"Could not stop recording");}finally{Ie(null);}}function Ke(){W?.cancel(),Ie(null),J(null),Se(0);}function We(c){let v=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!W&&!X?jsxRuntime.jsxs("button",{type:"button",onClick:we,className:c==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(kn,{}),"Record voice note"]}):null,W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(Ho,{stream:W.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[de,"s / ",_t,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:ye,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:Ke,className:"lumen-btn-ghost",children:"Cancel"})]}):null,X&&!W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Fo,{blob:X.blob,durationMs:X.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>J(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return c==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[v,!W&&!X?jsxRuntime.jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),v]})}async function rt(){Y(null);try{await s();}catch(c){sonner.toast.error(c instanceof Error?c.message:"Screen capture unavailable");}}function Be(){Q(null);}let ot=b.kind==="ready";async function _e(){if(W&&await ye(),S===1){if(b.kind==="ready"){let c=await pe.current?.flatten();_(c??b.capture.blob),he(c!=null&&c!==b.capture.blob);}x(2);}else S===2?x(3):await vt();}function bt(){S>1&&x(c=>c-1);}async function vt(){if(b.kind!=="ready")return;let c=K.trim(),{capture:v}=b;A(true),D(0);try{let P=re??v.blob,Z=await e.submit({rawText:c.length>0?c:void 0,category:F,submitterEmail:Re.trim()||void 0,screenshot:P,audio:X?.blob,audioDurationMs:X?.durationMs,video:ae?.blob,videoDurationMs:ae?.durationMs,context:gn(v)},{onUploadProgress:te=>D(Math.min(.95,te))});D(1),sonner.toast.success("Feedback sent \u2014 thank you."),Z.id,n();}catch(P){sonner.toast.error(P instanceof Error?P.message:"Could not submit feedback"),A(false);}}function ge(c){c.target===c.currentTarget&&!I&&n();}let R=Math.round(q*100),O=M==="video",U=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,wt=M==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&U,gr=S===1&&!ot||I,hr=S<3?"Next":I?R<95?`Uploading ${R}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:Ue,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:be.inset?{"--lumen-keyboard-inset":`${be.inset}px`}:void 0,onMouseDown:ge,children:jsxRuntime.jsxs("div",{ref:xe,className:"lumen-modal","data-lumen-drawing":ee?"true":void 0,children:[jsxRuntime.jsx(_o,{onDismiss:n}),jsxRuntime.jsxs("header",{className:"lumen-modal-header",children:[jsxRuntime.jsxs("h2",{className:"lumen-modal-title",children:[jsxRuntime.jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsx(Do,{step:S}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[S===1?jsxRuntime.jsx("div",{className:"lumen-pane",children:M===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(c.primary?" lumen-method-primary":""),onClick:()=>fe(c.value),disabled:b.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(v,{})}),c.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]})]},c.value)})}),jsxRuntime.jsx("p",{className:"lumen-status lumen-method-help",children:"Choose how to capture your feedback."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method-switch",role:"group","aria-label":"Switch capture method",children:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button","aria-pressed":M===c.value,onClick:()=>fe(c.value),disabled:b.kind==="capturing",children:[jsxRuntime.jsx(v,{}),c.label]},c.value)})}),M==="video"&&b.kind==="idle"?jsxRuntime.jsx(Oo,{canRecord:u,onRecord:rt,onUpload:()=>fe("upload"),error:me}):null,b.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,b.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:M==="upload"?"Choose an image or video to attach \u2014 or paste an image.":b.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:M==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:M==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:c=>{let v=c.currentTarget.files?.[0];v&&G(v),c.currentTarget.value="";}})]})]}):null,b.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[O?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(pt,{label:"Arrow",active:H==="arrow",onClick:()=>f("arrow")}),jsxRuntime.jsx(pt,{label:"Box",active:H==="rect",onClick:()=>f("rect")}),jsxRuntime.jsx(pt,{label:"Draw",active:H==="freehand",onClick:()=>f("freehand")}),jsxRuntime.jsx(pt,{label:"Comment",active:H==="comment",onClick:()=>f("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:Ln.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:c.value},"aria-label":c.label,"aria-pressed":y===c.value,onClick:()=>k(c.value)},c.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Tn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":c.label,"aria-pressed":T===c.value,onClick:()=>V(c.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:c.dot,height:c.dot}})},c.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.undo(),children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.reset(),children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Sn,{ref:pe,screenshot:b.capture.blob,tool:H,color:y,strokeWidth:T,onDrawingChange:Fe})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>M&&fe(M),children:O?"\u21BB Re-record":"\u21BB Recapture"}),wt?jsxRuntime.jsxs("button",{type:"button",className:"lumen-btn-ghost lumen-exact-btn",onClick:()=>{p();},title:"Capture the real screen pixels \u2014 your browser will ask which tab or window to share, then you arrange the page and press Capture.",children:[jsxRuntime.jsx(mt,{})," Capture exact screen"]}):null,O?ae?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ae.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:b.capture.method==="web-display-media"?"Exact screen captured":`${Nn(M)} captured \xB7 switch method above anytime`})]}),We("capture")]}):null]})}):null,S===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:K,onChange:c=>j(c.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),We("describe"),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:Pn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":F===c.value,onClick:()=>oe(c.value),children:c.label},c.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:Re,onChange:c=>nt(c.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,S===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[Nn(M),Ce?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:Pn.find(c=>c.value===F)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[K.trim()?K.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[X?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(X.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>J(null),children:"\xD7"})]}):null,ae?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ae.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Be,children:"\xD7"})]}):null,Re.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",Re.trim()]}):null,!X&&!W?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{x(2),we();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[I?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":R,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${R}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:S===1?n:bt,className:"lumen-btn-ghost",disabled:I,children:S===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:_e,className:"lumen-btn-primary",disabled:gr,children:hr})]})]})]})})}function Nn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function Do({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsxRuntime.jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxRuntime.jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsxRuntime.jsx("span",{className:"lumen-step-num",children:n.n}),jsxRuntime.jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function Oo({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[r?jsxRuntime.jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsxRuntime.jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsxRuntime.jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxRuntime.jsxs("div",{className:"lumen-record-copy",children:[jsxRuntime.jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsxRuntime.jsx("div",{className:"lumen-record-sub",children:"Tap to start. The sheet closes so you can record freely \u2014 a Stop button stays on screen, then the sheet returns with your clip. Max 60s."})]})]}):jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[jsxRuntime.jsx("p",{className:"lumen-record-unavailable",children:Bo()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function Bo(){if(typeof navigator>"u")return false;let e=navigator.userAgent||"";return /iPad|iPhone|iPod/.test(e)?true:/Macintosh/.test(e)&&typeof document<"u"&&"ontouchend"in document}function pt({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function _o({onDismiss:e}){let t=Rn.useRef(null),n=Rn.useRef(0),r=Rn.useRef(null);function o(s){s.currentTarget.setPointerCapture(s.pointerId),t.current=s.clientY,n.current=performance.now(),r.current=s.currentTarget.parentElement;}function a(s){if(t.current==null||!r.current)return;let l=Math.max(0,s.clientY-t.current);r.current.style.transform=`translateY(${l}px)`;}function i(s){if(t.current==null||!r.current)return;let l=Math.max(0,s.clientY-t.current),u=Math.max(1,performance.now()-n.current),d=l/u;r.current.style.transform="",r.current.style.transition="",t.current=null,(l>80||d>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function Ho({stream:e}){let t=Rn.useRef(null);return Rn.useEffect(()=>{let n=t.current;if(!n)return;let r=Math.min(window.devicePixelRatio||1,2),o=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(o*r),n.height=Math.round(a*r);let i=n.getContext("2d");if(!i)return;i.scale(r,r);let s=window.AudioContext??window.webkitAudioContext;if(!s)return;let l=new s,u=l.createMediaStreamSource(e),d=l.createAnalyser();d.fftSize=1024,d.smoothingTimeConstant=.6,u.connect(d);let p=new Uint8Array(d.fftSize),h=18,w=3,g=3,S=Math.max(2,(o-w*(h-1))/h),x=Math.min(S/2,3),M=new Array(h).fill(0),L=0,b=false;function C(){if(b)return;d.getByteTimeDomainData(p);let I=Math.floor(p.length/h);i.clearRect(0,0,o,a),i.fillStyle=Uo("--lumen-danger")||"rgb(239,68,68)";for(let A=0;A<h;A++){let q=0;for(let H=0;H<I;H++){let f=Math.abs((p[A*I+H]??128)-128);f>q&&(q=f);}let D=Math.min(1,q/128*1.8),re=M[A]??0;M[A]=D>re?D:re+(D-re)*.35;let _=Math.max(g,M[A]*a),Ce=A*(S+w),he=(a-_)/2;Vo(i,Ce,he,S,_,x),i.fill();}L=requestAnimationFrame(C);}return L=requestAnimationFrame(C),()=>{b=true,cancelAnimationFrame(L);try{u.disconnect();}catch{}l.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function Vo(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function Fo({blob:e,durationMs:t}){let[n,r]=Rn.useState("");return Rn.useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxRuntime.jsxs("div",{className:"lumen-audio-preview",children:[jsxRuntime.jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxRuntime.jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function Uo(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var zo='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ko(e){return Array.from(e.querySelectorAll(zo)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var ft=class extends Rn__namespace.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t){if(typeof document<"u"){let n=document.documentElement;n.style.overflow="",n.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),sonner.toast.error("Feedback widget hit a snag and was reset. Please try again."),Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function _n({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx($o,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-rec-hud lumen-rec-hud-pending",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function $o({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(0);Rn.useEffect(()=>{let s=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));s();let l=window.setInterval(s,250);return ()=>window.clearInterval(l)},[e,t]);let i=s=>`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`;return jsxRuntime.jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxRuntime.jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxRuntime.jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function Hn({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,s=e.phase==="grabbing";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-cap-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[s?jsxRuntime.jsx("span",{className:"lumen-cap-hud-spinner","aria-hidden":"true"}):jsxRuntime.jsx("span",{className:"lumen-cap-hud-ico","aria-hidden":"true",children:jsxRuntime.jsx(mt,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:s?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:s,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:s,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Vt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function Vn(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function Fn(e){return e instanceof Error?e:new Error(String(e))}function Un(e,t,n){let r=false,o=false,a=false,i=null;function s(){o||(o=true,n.onCancelled());}function l(d){o||(o=true,n.onResult(d));}function u(d){o||(o=true,n.onError(d));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(d=>{if(i=d,r){try{d.cancel();}catch{}s();return}if(n.onActive(d),a){n.onProcessing();try{d.stop();}catch{}}Promise.resolve(d.result).then(p=>{r?s():l(p);}).catch(p=>{r||Vn(p)?s():u(Fn(p));});}).catch(d=>{r||Vn(d)?s():u(Fn(d));}),{stop(){if(!(o||r||a)&&(a=true,i)){n.onProcessing();try{i.stop();}catch{}}},cancel(){if(!(o&&r)){if(r=true,i)try{i.cancel();}catch{}s();}}}}function zn(){if(typeof document>"u"||typeof window>"u")return 0;let e=window.innerWidth,t=window.innerHeight;if(e===0||t===0)return 0;let n=t-4,r=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],o=new Set,a=0;for(let i of r){let s=document.elementsFromPoint(i,n);for(let l of s){if(o.has(l))continue;o.add(l);let u=window.getComputedStyle(l);if(u.position!=="fixed"&&u.position!=="sticky")continue;let d=l.getBoundingClientRect();d.bottom<t-8||d.bottom>t+8||d.width<e*.6||d.height>a&&(a=d.height);}}return a}function Ft(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,r=window.innerHeight,o=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let s of Array.from(i)){let l=s.getBoundingClientRect();if(l.height===0||l.width===0)continue;let u=0;switch(t){case "bottom":if(l.bottom<r-8)break;u=Math.max(0,r-l.top);break;case "top":if(l.top>8)break;u=Math.max(0,l.bottom);break;case "left":if(l.left>8)break;u=Math.max(0,l.right);break;case "right":if(l.right<n-8)break;u=Math.max(0,n-l.left);break}u>o&&(o=u);}}return o}function Kn(e){let[t,n]=Rn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Rn.useRef(t),o=Qo(e.avoid),a=e.placement,i=e.offset.x,s=e.offset.y;return Rn.useEffect(()=>{if(typeof window>"u")return;let l=0,u=false,d=()=>{if(l=0,u)return;let S=a[0]==="b"?"bottom":"top",x=a[1]==="r"?"right":"left",M=0,L=0;e.avoid==="auto"&&S==="bottom"?M=zn():Array.isArray(e.avoid)&&(M=Ft(e.avoid,S),L=Ft(e.avoid,x));let b={bottom:S==="bottom"?s+M:0,top:S==="top"?s+M:0,right:x==="right"?i+L:0,left:x==="left"?i+L:0},C=r.current;(b.bottom!==C.bottom||b.top!==C.top||b.right!==C.right||b.left!==C.left)&&(r.current=b,n(b));},p=()=>{l||(l=window.requestAnimationFrame(d));};p();let h=typeof ResizeObserver<"u"?new ResizeObserver(p):null;h?.observe(document.documentElement);let w=typeof MutationObserver<"u"?new MutationObserver(p):null;w?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let g=window.visualViewport;return g?.addEventListener("resize",p),g?.addEventListener("scroll",p),()=>{u=true,l&&window.cancelAnimationFrame(l),h?.disconnect(),w?.disconnect(),window.removeEventListener("resize",p),g?.removeEventListener("resize",p),g?.removeEventListener("scroll",p);}},[a,i,s,o]),t}function Qo(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var Wn=["mousedown","touchstart"];function Ve(e){let t=Rn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Rn.useRef(e.onClick);n.current=e.onClick;let r=Rn.useRef(e.isolate??true);r.current=e.isolate??true;let o=Rn.useRef(null);return Rn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=u=>{r.current&&u.stopPropagation(),t.current?.(u);},s=u=>{r.current&&u.stopPropagation(),n.current(u);},l=u=>{r.current&&u.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",s);for(let u of Wn)a.addEventListener(u,l,u==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",s);for(let u of Wn)a.removeEventListener(u,l);};},[])}function Yn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[s,l]=Rn.useState(null),u=Rn.useRef(null),d=Kn(e),p=Xe(e.keyboard!=="off",i),h=Ve({onPointerDown:r,onClick:o,isolate:a}),w=Rn.useCallback(D=>{u.current=D,h(D);},[h]);Rn.useEffect(()=>{typeof document>"u"||l(t??document.body);},[t]);let g=e.placement,S=g[0]==="b"?"bottom":"top",x=g[1]==="r"?"right":"left",M=S==="bottom",L=p.open&&M&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,b=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&M&&p.inset<=0);if(oa(u,!n&&!b),!s)return null;let C=S==="bottom"?d.bottom:d.top,I=x==="right"?d.right:d.left,A=n||b,q={position:"fixed",[S]:e.safeArea?`calc(${C}px + env(safe-area-inset-${S}, 0px))`:`${C}px`,[x]:e.safeArea?`calc(${I}px + env(safe-area-inset-${x}, 0px))`:`${I}px`,zIndex:e.zIndex,transform:L?`translateY(-${L}px)`:void 0,opacity:A?0:1,pointerEvents:A?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:w,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:q,"aria-label":e.label,"aria-hidden":A?true:void 0,tabIndex:A?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),s)}function oa(e,t){let n=Rn.useRef(false);Rn.useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let r=window.setTimeout(()=>{let o=e.current;if(!o)return;let a=o.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,s=a.top+a.height/2,l=document.elementsFromPoint(i,s),u=$n(window.getComputedStyle(o).zIndex);for(let d of l){if(d===o||o.contains(d))continue;if($n(window.getComputedStyle(d).zIndex)>u){n.current=true,console.warn("[lumen] trigger is occluded by",d);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function $n(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function Gn({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),l=Ve({onPointerDown:r,onClick:o,isolate:a});return Rn.useEffect(()=>{if(typeof document>"u")return;let u=e instanceof HTMLElement?e:e.current??null;s(u);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:l,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),i):null}function Jn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),[l,u]=Rn.useState(false),d=Rn.useRef(null),p=Ve({onPointerDown:x=>{r?.(x),d.current={x:x.clientX,y:x.clientY},u(true);let M=x.currentTarget;try{M?.setPointerCapture?.(x.pointerId);}catch{}},onClick:o,isolate:a});if(Rn.useEffect(()=>{typeof document>"u"||s(t??document.body);},[t]),!i)return null;let h=`lumen-notch lumen-notch-${e.edge}${l?" lumen-notch-expanded":""}`;function w(x){let M=d.current;if(!M)return;let L=x.clientX-M.x,b=x.clientY-M.y;(e.edge==="top"&&b>16||e.edge==="bottom"&&b<-16||e.edge==="right"&&L<-16||e.edge==="left"&&L>16)&&(d.current=null,o(x.nativeEvent));}function g(){d.current=null,u(false);}function S(){d.current=null,u(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:h,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:w,onPointerUp:g,onPointerCancel:S,onMouseEnter:()=>u(true),onMouseLeave:()=>u(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function Qn(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function ha(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function er(e){return {kind:"floating",placement:e.placement??"br",offset:{x:e.offset?.x??16,y:e.offset?.y??16},safeArea:e.safeArea??true,avoid:e.avoid===false?false:e.avoid==null?"auto":Array.isArray(e.avoid)?e.avoid:[e.avoid],keyboard:ha(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var wa={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function tr(e){let t=Rn.useId();Rn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${ya(t)}`,o={},a=(i,s)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,s);};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else {for(let[i,s]of Object.entries(wa)){let l=e[s];typeof l=="string"&&l.length>0&&a(i,l);}typeof e.accent=="string"&&e.accent.length>0&&(a("--lumen-accent",e.accent),a("--lumen-primary",e.accent),a("--lumen-accent-fg","#ffffff")),(e.scheme==="light"||e.scheme==="dark")&&(o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e.scheme));}return n.setAttribute(r,""),()=>{n.removeAttribute(r);for(let[i,s]of Object.entries(o))i.startsWith("--")?s?n.style.setProperty(i,s):n.style.removeProperty(i):s==null?n.removeAttribute(i):n.setAttribute(i,s);}},[e,t]);}function ya(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var nr=Symbol.for("lumen.history.patched"),Ut="lumen:locationchange";function Ra(){if(typeof window>"u")return;let e=window;if(e[nr])return;e[nr]=true;let t=()=>window.dispatchEvent(new Event(Ut)),n=history.pushState;history.pushState=function(...o){let a=n.apply(this,o);return t(),a};let r=history.replaceState;history.replaceState=function(...o){let a=r.apply(this,o);return t(),a},window.addEventListener("popstate",t);}function rr(e){let[t,n]=Rn.useState(false);return Rn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;Ra();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Ut,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Ut,r),window.removeEventListener("popstate",r);}},[e]),t}var ka=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function or(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let r=n.webkit;if(r&&r.messageHandlers){t(true);return}let o=navigator.userAgent||"";ka.some(a=>o.includes(a))&&t(true);},[]),e}var ir="lumen.config.v1.",Ta=3600*1e3;function sr(e,t){let[n,r]=Rn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Rn.useEffect(()=>{if(typeof window>"u")return;let o=Oa(e);o&&r({trigger:o.trigger,enabled:ar(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),s=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(s,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);let u=await l.json(),d=lr(u.trigger);if(!d)throw new Error("Malformed config response");let p=Na(u.trigger),h=ur(u.brand);Ba(e,d,p,h),r({trigger:d,enabled:ar(d),shakeToOpen:p,brand:h,loading:false});}).catch(()=>{r(l=>l.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:l);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function ar(e){return e.kind!=="headless"}var Pa=["br","bl","tr","tl"],Aa=["top","right","bottom","left"];function lr(e){if(!e||typeof e!="object")return null;let t=e;if(t.enabled===false)return {kind:"headless"};let n=typeof t.label=="string"?t.label:"Feedback";return t.kind==="floating"?{kind:"floating",placement:Pa.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:Aa.find(o=>o===t.edge)??"top",label:n}:null}function Na(e){return !e||typeof e!="object"?false:e.shake===true}var Ia=/^#[0-9a-fA-F]{6}$/,Da=["auto","light","dark"];function ur(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&Ia.test(t.accent)?t.accent:null;if(!n)return null;let r=Da.find(a=>a===t.mode)??"auto",o=typeof t.radius=="number"&&Number.isFinite(t.radius)?Math.min(20,Math.max(0,Math.round(t.radius))):10;return {accent:n,mode:r,radius:o}}function Oa(e){try{let t=window.localStorage.getItem(ir+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>Ta)return null;let r=lr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:ur(n.brand)}:null}catch{return null}}function Ba(e,t,n,r){try{window.localStorage.setItem(ir+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function Ha(e){if(e&&typeof e=="object")return e.type===ct;if(typeof e=="string")try{return JSON.parse(e).type===ct}catch{return false}return false}function Va(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(s,l,u,d){if(!a)return a={x:s,y:l,z:u,t:d},false;if(d-a.t<o)return false;let p=Math.abs(s-a.x)+Math.abs(l-a.y)+Math.abs(u-a.z);return a={x:s,y:l,z:u,t:d},p<t?false:(i=i.filter(h=>d-h<r),i.push(d),i.length>=n?(i=[],true):false)}}}function cr(e,t,n){Rn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let d=Date.now();n||d-r<o||(r=d,t());}let i=d=>{Ha(d.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let s=Va(),l=d=>{let p=d.accelerationIncludingGravity??d.acceleration;!p||p.x==null||p.y==null||p.z==null||s.push(p.x,p.y,p.z,Date.now())&&a();},u=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return u&&window.addEventListener("devicemotion",l),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),u&&window.removeEventListener("devicemotion",l);}},[e,t,n]);}var mr="https://shakebugs.vercel.app",ht=60;function pr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function za({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:s,portalTarget:l,capture:u,record:d,shakeToOpen:p,onOpenChange:h,beforeOpen:w,onTriggerActivate:g,isolateEvents:S=true,keyboardInset:x,suppressTrigger:M=false,children:L}){let[b,C]=Rn.useState(false),[I,A]=Rn.useState(false),[q,D]=Rn.useState(null),[re,_]=Rn.useState(null),[Ce]=Rn.useState(false),[he]=Rn.useState(null),H=Rn.useRef(false),f=Rn.useRef(false),y=Rn.useRef(null),k=Rn.useMemo(()=>new en({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Rn.useEffect(()=>{pn({ignoreUrlPrefix:(t??mr).replace(/\/$/,"")});},[t]);let T=Rn.useRef(h);T.current=h,Rn.useEffect(()=>{if(!(typeof document>"u"))return b?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[b]);let V=Rn.useRef(null);Rn.useEffect(()=>{if(V.current===b)return;let R=V.current;V.current=b,R!==null&&T.current?.(b);},[b]);let K=Rn.useRef(w);K.current=w;let j=Rn.useRef(g);j.current=g;let F=Rn.useCallback(R=>{f.current=true,y.current=Promise.resolve().then(()=>K.current?.(R)).then(()=>j.current?.(R)).then(()=>{});},[]),oe=Rn.useCallback(R=>{H.current||b||Y.current||we.current||(H.current=true,A(true),D(null),_(null),(async()=>{try{if(f.current?await y.current:(await K.current?.(R),await j.current?.(R)),u?.mode==="manual")D(null),_(null);else if(u?.provider)D(null),_(null);else {let O=await lt({...u,mode:u?.mode??"auto",target:u?.target??document.documentElement});D(O);}}catch(O){_(O instanceof Error?O:new Error(String(O)));}finally{f.current=false,y.current=null,H.current=false,A(false),C(true);}})());},[u,b]),Re=Rn.useCallback(()=>{C(false),D(null),_(null);},[]),nt=Rn.useCallback(k.submit.bind(k),[k]),[W,Ie]=Rn.useState(0),X=Rn.useCallback(()=>{H.current=false,A(false),C(false),D(null),_(null),Ie(R=>R+1);},[]),[J,de]=Rn.useState(null),[Se,ae]=Rn.useState(null),Q=Rn.useRef(null),me=Rn.useRef(null),Y=Rn.useRef(false),ee=Rn.useRef(null),Fe=Rn.useRef(null),pe=Rn.useRef(null),xe=Rn.useCallback((R,O=false)=>{if(Q.current=null,me.current=null,Y.current=false,de(null),!R){ee.current=null;return}Fe.current={blob:R.blob,durationMs:R.durationMs,poster:ee.current,deriveBlobPoster:O},ee.current=null,C(true);},[]);Rn.useEffect(()=>{if(!b)return;if(!d?.provider){ae(null);return}let R=d.isAvailable;if(!R){ae(true);return}let O=false;return Promise.resolve().then(()=>R()).then(U=>{O||ae(U);}).catch(()=>{O||ae(false);}),()=>{O=true;}},[b,d?.provider,d?.isAvailable]);let Ue=Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).canRecord,ze=Rn.useCallback(async()=>{if(Y.current)return;if(pe.current=null,Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).usingProvider&&d?.provider){Y.current=true,ee.current=null,C(false),me.current=Un(d.provider,{maxDurationSeconds:ht},{onStarting:()=>de({phase:"starting"}),onActive:U=>{de({phase:"recording",stream:U.stream??null,startedAt:Date.now(),maxSeconds:ht}),U.stream&&Ot(U.stream).then(wt=>{ee.current=wt;}).catch(()=>{});},onProcessing:()=>de({phase:"processing"}),onResult:U=>xe({blob:U.blob,durationMs:U.durationMs},true),onCancelled:()=>{me.current=null,Y.current=false,ee.current=null,de(null),D(null),_(null),C(true);},onError:U=>{me.current=null,Y.current=false,ee.current=null,de(null),pe.current=U.message||"Screen recording could not start.",C(true);}});return}if(Q.current)return;let O=await bn(ht);Q.current=O,Y.current=true,ee.current=null,de({phase:"recording",stream:O.stream,startedAt:Date.now(),maxSeconds:ht}),C(false),Ot(O.stream).then(U=>{ee.current=U;}).catch(()=>{}),O.result.then(U=>xe(U)).catch(()=>xe(null));},[xe,d?.provider,Se]),be=Rn.useCallback(()=>{me.current?me.current.stop():Q.current?.stop();},[]),ie=Rn.useCallback(()=>{if(me.current){me.current.cancel();return}let R=Q.current;Q.current=null,Y.current=false,ee.current=null,de(null),R?.cancel(),D(null),_(null),C(true);},[]),De=Rn.useCallback(()=>{let R=Fe.current;return Fe.current=null,R},[]),ke=Rn.useCallback(()=>{let R=pe.current;return pe.current=null,R},[]);Rn.useEffect(()=>{b||(pe.current=null);},[b]);let[ve,fe]=Rn.useState(null),G=Rn.useRef(null),Oe=Rn.useRef(null),we=Rn.useRef(false),ye=Rn.useCallback(()=>{let R=G.current;G.current=null,we.current=false,R?.stop(),fe(null),C(true);},[]),Ke=Rn.useCallback(()=>{let R=G.current;R&&(fe({phase:"grabbing"}),(async()=>{try{let O=await R.grab();if(G.current!==R)return;Oe.current=O,G.current=null,we.current=!1,R.stop(),fe(null),C(!0);}catch{if(G.current!==R)return;G.current=null,we.current=false,R.stop(),fe(null),sonner.toast.error("Could not capture the screen. Please try again."),C(true);}})());},[]),We=Rn.useCallback(async()=>{if(we.current)return;let R;try{R=await xt({...u});}catch{return}G.current=R,we.current=true,R.onEnded(()=>ye()),fe({phase:"live"}),C(false);},[u,ye]),rt=Rn.useCallback(()=>{let R=Oe.current;return Oe.current=null,R},[]);Rn.useEffect(()=>()=>{G.current?.stop(),G.current=null;},[]);let Be=or(),ot=rr(i),_e=sr(a?"":e,t??mr);tr(s??$a(_e.brand));let bt=p??_e.shakeToOpen;cr(bt,oe,b);let vt=Rn.useMemo(()=>({client:k,user:n,isOpen:b,isSubmitting:Ce,error:he,open:oe,close:Re,openCapture:oe,closeCapture:Re,submit:nt,isNativeShell:Be,capture:u,initialCapture:q,initialCaptureError:re,isOpening:I,startVideoSession:ze,stopVideoSession:be,cancelVideoSession:ie,recording:J,consumePendingVideo:De,canRecordScreen:Ue,consumeRecordStartError:ke,startScreenCaptureSession:We,grabScreenCaptureFrame:Ke,cancelScreenCaptureSession:ye,screenCapture:ve,consumePendingScreenshot:rt,isolateEvents:S,keyboardInset:x}),[k,n,b,Ce,he,oe,Re,nt,Be,u,q,re,ze,be,ie,J,De,Ue,ke,We,Ke,ye,ve,rt,I,S,x]),ge=Wa({explicit:a,remote:_e.trigger,remoteLoading:_e.loading,floatingButton:o});return jsxRuntime.jsxs(Tt.Provider,{value:vt,children:[L,jsxRuntime.jsxs(ft,{onReset:X,children:[ge?.kind==="floating"?jsxRuntime.jsx(Yn,{config:er(ge),portalTarget:l,hidden:ot||M||I||J!=null||ve!=null,onPointerDown:F,onClick:R=>oe(R),isolateEvents:S,keyboardInset:x}):null,ge?.kind==="notch"?jsxRuntime.jsx(Jn,{config:Qn(ge),portalTarget:l,hidden:ot||M||I||J!=null||ve!=null,onPointerDown:F,onClick:R=>oe(R),isolateEvents:S}):null,ge?.kind==="inline"?jsxRuntime.jsx(Gn,{mount:ge.mount,label:ge.label??"Feedback",icon:ge.icon,onPointerDown:F,onClick:R=>oe(R),isolateEvents:S}):null,ve?jsxRuntime.jsx(Hn,{state:ve,portalTarget:l,onCapture:Ke,onCancel:ye}):null,J?jsxRuntime.jsx(_n,{state:J,portalTarget:l,onStop:be,onCancel:ie}):null,jsxRuntime.jsx(Ht,{})]},W),jsxRuntime.jsx(Ka,{})]})}function Ka(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Wa(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function $a(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function qa({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=Ge(),s=["lumen-btn",e==="default"?"lumen-btn-primary":null,e==="ghost"?"lumen-btn-ghost":null,e==="outline"?"lumen-btn-outline":null,t?"lumen-btn-floating":null,n].filter(Boolean).join(" ");return jsxRuntime.jsx("button",{type:"button",className:s,"data-lumen-trigger":"",onClick:l=>{o?.(l),l.defaultPrevented||i(l.nativeEvent);},...a,children:r})}
|
|
4
|
-
exports.CaptureModal=Ht;exports.FeedbackButton=qa;exports.LUMEN_KEYBOARD_CSS_VAR=Mt;exports.LUMEN_KEYBOARD_EVENT=Ye;exports.LUMEN_SHAKE_MESSAGE=ct;exports.LumenProvider=za;exports.createNativeCaptureProvider=ao;exports.isLumenEventTarget=eo;exports.isolateLumenEvents=to;exports.readLumenKeyboardInset=Lt;exports.setLumenKeyboardInset=go;exports.useKeyboardInset=Xe;exports.useLumen=Ge;//# sourceMappingURL=index.cjs.map
|
|
2
|
+
'use strict';var Rn=require('react'),sonner=require('sonner'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Rn__namespace=/*#__PURE__*/_interopNamespace(Rn);var N=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},zt=class extends N{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},$t=class extends N{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},at=class extends N{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},br="https://shakebugs.vercel.app",vr="/api/v1/sdk/submit",wr="/api/v1/sdk/error",yr="0.13.2",Er=5,Cr=new Set([502,503,504]),en=class{apiKey;apiUrl;user;amplitude;#e=new Set;#t=0;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new N("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??br).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${vr}`,r=this.#n(e),o=null;for(let a=0;a<3;a++){a>0&&await Sr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof zt||i instanceof $t||i instanceof N&&typeof i.status=="number"&&!Cr.has(i.status))throw i}}throw o instanceof Error?o:new at("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Er)return;let t=(e.stack??"").split(`
|
|
3
|
+
`)[1]?.trim()??"",n=`${e.name}:${e.message}@${t}`;if(this.#e.has(n))return;this.#e.add(n),this.#t+=1;let r=typeof navigator<"u"?navigator:void 0,o=typeof performance<"u"?performance.memory:void 0,a;try{let s=new URL(window.location.href);a=s.origin+s.pathname;}catch{a=void 0;}let i={message:String(e.message??"").slice(0,1e3),name:String(e.name??"Error").slice(0,200),stack:e.stack?.slice(0,8e3),componentStack:e.componentStack?.slice(0,8e3),url:a,userAgent:r?.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},dpr:window.devicePixelRatio,deviceMemory:r?.deviceMemory,jsHeap:o?{used:o.usedJSHeapSize,limit:o.jsHeapSizeLimit}:void 0,sdkVersion:yr,context:e.context};fetch(`${this.apiUrl}${wr}`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumen-Api-Key":this.apiKey},body:JSON.stringify(i),keepalive:!0,credentials:"omit",mode:"cors"}).catch(()=>{});}catch{}}#n(e){let t=new FormData;e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),e.submitterEmail&&t.append("submitterEmail",e.submitterEmail),e.submitterFingerprint&&t.append("submitterFingerprint",e.submitterFingerprint);let n=e.context.amplitude??this.amplitude,r=n?{...e.context,amplitude:n}:e.context;return t.append("context",JSON.stringify(r)),e.screenshot&&t.append("screenshot",e.screenshot,Rr(e.screenshot)),e.audio&&t.append("audio",e.audio,"audio"),e.audioDurationMs!=null&&t.append("audioDurationMs",String(e.audioDurationMs)),e.video&&t.append("video",e.video,"video"),e.videoDurationMs!=null&&t.append("videoDurationMs",String(e.videoDurationMs)),t}#r(e,t,n){return new Promise((r,o)=>{let a=new XMLHttpRequest;a.open("POST",e,true),a.setRequestHeader("X-Lumen-Api-Key",this.apiKey),a.responseType="text";let{onUploadProgress:i,signal:s}=n;i&&a.upload.addEventListener("progress",u=>{u.lengthComputable&&u.total>0&&i(Math.min(1,u.loaded/u.total));});let l=()=>{a.abort(),o(new at("Submit aborted."));};if(s){if(s.aborted){o(new at("Submit aborted."));return}s.addEventListener("abort",l,{once:true});}a.addEventListener("load",()=>{if(s&&s.removeEventListener("abort",l),a.status===403){o(new zt);return}if(a.status===429){let u=Number(a.getResponseHeader("Retry-After"))||60;o(new $t(u));return}if(a.status<200||a.status>=300){o(new N(kr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let u=JSON.parse(a.responseText);r(u);}catch{o(new N("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{s&&s.removeEventListener("abort",l),o(new at("Network error during submit."));}),a.send(t);})}};function Rr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Sr(e){return new Promise(t=>setTimeout(t,e))}function kr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var tn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function nn(e=tn){if(!e||typeof document>"u")return ()=>{};let t=[];for(let n of Array.from(document.querySelectorAll(e)))t.push({el:n,prev:n.style.visibility}),n.style.visibility="hidden";return ()=>{for(let{el:n,prev:r}of t)n.style.visibility=r;}}var xr=2,Mr=1.5,Lr=820,Tr=12,We=8*1024*1024;async function lt(e={}){xt();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return Br(await e.provider(),e)}catch(n){if(t==="custom")throw n;e.onWarning?.(["Custom capture provider failed; falling back to browser DOM capture."]);}if(t==="manual")throw new N("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return jt(e);if(t==="dom")return Wt(e);if(t==="custom")throw new N("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await Wt(e)}catch(n){if(ln()){let r=await jt(e);return r.warnings=je(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function qe(e,t=[]){xt();let n=ut();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:je(t)}}var Kt=Promise.resolve();function Wt(e){let t=Kt.then(()=>qt(e),()=>qt(e));return Kt=t.catch(()=>{}),t}async function qt(e){let t=await Or(),n=e.target??document.documentElement,r=ut(),o=_r(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),s=window.scrollY+(a?.offsetTop??0),l=Vr(e,r.width,r.height),u=Hr(n);!e.provider&&Dr()&&u.unshift(`Lumen is capturing inside a React Native WebView with no native capture provider, so this screenshot is a DOM re-render \u2014 it won't match the native screen and omits native overlays/inputs. Wire createNativeCaptureProvider() with capture mode "custom" (see docs/native-screenshot-expo.md).`);let d=Nr(n);await sn(e.awaitAnimationsMs??zr),await Ur();let p=await t(n,{backgroundColor:null,logging:false,useCORS:true,allowTaint:false,width:r.width,height:r.height,windowWidth:o.width,windowHeight:o.height,scrollX:window.scrollX,scrollY:window.scrollY,x:i,y:s,scale:l,ignoreElements:w=>w instanceof HTMLElement&&(w.dataset.lumenCaptureIgnore==="true"||!!w.closest("[data-lumen-capture-ignore='true']")),onclone:(w,g)=>{Ir(g,d),Pr(w);}}),b={blob:await an(p,u),method:"web-dom",platform:"web",viewport:r,pixelRatio:l,warnings:je(u)};return b.warnings.length>0&&e.onWarning?.(b.warnings),b}var rn=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function Pr(e){for(let t of Array.from(e.querySelectorAll(rn))){if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){let n=t;n.value&&(n.value="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");continue}t.style.visibility="hidden";}}var Ar="[data-lumen-root], [data-lumen-capture-ignore='true']";function on(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(Ar))}function Nr(e){return on(e).map(t=>{if(t.matches(rn))return {skip:true};let n=t.type;return n==="checkbox"||n==="radio"?{skip:false,checked:t.checked}:n==="file"?{skip:true}:{skip:false,value:t.value}})}function Ir(e,t){let n=on(e);n.length===t.length&&n.forEach((r,o)=>{let a=t[o];!a||a.skip||(a.checked!==void 0?r.checked=a.checked:a.value!==void 0&&(r.value=a.value));});}function Dr(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function Or(){let{default:e}=await import('html2canvas-pro');return e}async function kt(e={}){if(xt(),!ln())throw new N("Browser screen capture is unavailable in this environment.","DISPLAY_MEDIA_UNAVAILABLE");let t=await navigator.mediaDevices.getDisplayMedia({video:true,audio:false}),n=null;try{n=document.createElement("video"),n.muted=!0,n.playsInline=!0,n.srcObject=t,await $r(n);}catch(i){for(let s of t.getTracks())s.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(s=>s());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let s=i?.conceal??true,l=s?nn():()=>{};try{s&&await Kr(r,3,400);let u=document.createElement("canvas");u.width=r.videoWidth,u.height=r.videoHeight;let d=u.getContext("2d");if(!d)throw new N("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");d.drawImage(r,0,0,u.width,u.height);let p=ut(),b=["Browser screen capture uses the window or tab selected by the user."],w={blob:await an(u,b),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?u.width/p.width:void 0,warnings:je(b)};return e.onWarning?.(w.warnings),w}finally{l();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function jt(e){let t=await kt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function Br(e,t){let n=ut(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:je(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function Hr(e){let t=new Set;e.querySelector("iframe")&&t.add("Embedded iframes may be blank or incomplete in DOM capture."),e.querySelector("video")&&t.add("Video frames may be blank or stale in DOM capture."),e.querySelector("canvas")&&t.add("Canvas/WebGL content may be blank if it is cross-origin tainted."),document.fonts&&document.fonts.status!=="loaded"&&t.add("Web fonts were still loading when the screenshot was captured.");let n=0;for(let r of Array.from(e.querySelectorAll("img"))){let o=r.currentSrc||r.src;if(o)try{new URL(o,window.location.href).origin!==window.location.origin&&!r.crossOrigin&&(n+=1);}catch{}}return n>0&&t.add(`${n} cross-origin image${n===1?"":"s"} without CORS may be omitted from the screenshot.`),Array.from(t)}async function an(e,t){let n=await Yt(e,"image/png",.92);if(n.size<=We)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>We&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(We/n.size)*.9)),i=document.createElement("canvas");i.width=Math.max(1,Math.round(r.width*a)),i.height=Math.max(1,Math.round(r.height*a));let s=i.getContext("2d");if(!s)return n;s.drawImage(r,0,0,i.width,i.height),r=i;for(let l of [.86,.74,.62,.5])if(n=await Yt(r,"image/jpeg",l),n.size<=We)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>We&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function Yt(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new N("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function ut(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function _r(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function Vr(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??xr;Fr()&&(o=Math.min(o,Mr));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(Tr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function Fr(){let e=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0||typeof window<"u"&&"ontouchstart"in window,t=document.documentElement.clientWidth||window.innerWidth||0;return e&&t>0&&t<=Lr}function Ur(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var zr=400;async function sn(e){if(typeof document>"u"||typeof document.getAnimations!="function"||!(e>0))return;let t;try{t=document.getAnimations();}catch{return}let n=t.filter(a=>{if(a.playState!=="running")return false;let i=a.effect?.getComputedTiming?.();return !!i&&i.iterations!==1/0});if(n.length===0)return;let r=Promise.allSettled(n.map(a=>a.finished)).then(()=>{}),o=new Promise(a=>setTimeout(a,e));await Promise.race([r,o]);}function ln(){return !!navigator.mediaDevices?.getDisplayMedia}async function $r(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new N("Could not read screen capture video.","VIDEO_FAILED"));e.addEventListener("loadedmetadata",a,{once:true}),e.addEventListener("error",i,{once:true}),e.play().catch(i);});let t=performance.now(),n=1500;for(;e.videoWidth===0||e.videoHeight===0;){if(performance.now()-t>n)throw new N("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function Kr(e,t,n){let r=e.requestVideoFrameCallback?.bind(e);if(typeof r!="function"){await new Promise(i=>setTimeout(i,Math.min(n,250)));return}let o=performance.now(),a=0;await new Promise(i=>{let s=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(s);};r(s),setTimeout(i,n);});}function xt(){if(typeof window>"u"||typeof document>"u")throw new N("Screenshot capture can only run in the browser.","INVALID_ENV")}function je(e){return Array.from(new Set(e.filter(Boolean)))}var un=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,Wr=[/-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )?PRIVATE KEY-----/g,/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,/\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA|ANVA|AIPA)[A-Z0-9]{16}\b/g,/\bgh[posru]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{18,}\b/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,/\bAIza[A-Za-z0-9_-]{35}\b/g,/\b[srp]k_(?:live|test)_[A-Za-z0-9]{10,}\b/g,/\bsk-(?:proj-|ant-)?[A-Za-z0-9_-]{32,}\b/g];function qr(e){let t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return false;let n=0,r=false;for(let o=t.length-1;o>=0;o--){let a=t.charCodeAt(o)-48;r&&(a*=2,a>9&&(a-=9)),n+=a,r=!r;}return n%10===0}function Et(e){let t=e;for(let n of Wr)t=t.replace(n,"***");return t=t.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._\-+/=]+/gi,"$1 ***"),t=t.replace(/\b([A-Za-z_][\w-]*)"?\s*[=:]\s*("?)([^"\s&]{6,})\2/g,(n,r,o,a)=>/^(Bearer|Basic)$/i.test(a)?n:un.test(r)?`${r}=${o}***${o}`:a.length>=24&&/^[A-Za-z0-9._\-+/=]+$/.test(a)&&!a.includes(" ")?`${r}=${o}${a.slice(0,4)}\u2026${o}`:n),t=t.replace(/\b\d(?:[ -]?\d){12,18}\b/g,n=>qr(n)?"***":n),t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***"),t=t.replace(/\b[\w.+-]+@[\w-]+\.[\w.-]+\b/g,"***@***"),t}function cn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])un.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Et(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Et(e)}}function dn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return cn(e)}}var Gt=200,Zt=4096,mn=[],it=[],Xt=false,Ct=null;function pn(e={}){Xt||typeof window>"u"||(Xt=true,Ct=e.ignoreUrlPrefix??null,Zr(),Xr(),Jr());}function jr(){return {consoleLog:mn.slice(),networkLog:it.slice()}}function st(e,t){e.push(t),e.length>Gt&&e.splice(0,e.length-Gt);}function Yr(e){let t=[];for(let r of e){if(typeof r=="string"){t.push(r);continue}if(r instanceof Error){t.push(`${r.name}: ${r.message}${r.stack?`
|
|
4
|
+
${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,Gr));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>Zt?n.slice(0,Zt)+"\u2026[truncated]":n}function Gr(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Zr(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let r=e[n]?.bind(e);r&&(e[n]=(...o)=>{try{st(mn,{level:n,ts:Date.now(),message:Et(Yr(o))});}catch{}r(...o);});}}function fn(e){return Ct?e.startsWith(Ct):false}function Xr(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let r=typeof t=="string"?t:t instanceof URL?t.toString():t.url,o=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(fn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return st(it,{type:"fetch",method:o,url:Rt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw st(it,{type:"fetch",method:o,url:Rt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Jr(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...a){return this.__lumen={method:String(r).toUpperCase(),url:typeof o=="string"?o:o.toString(),t:0},t.call(this,r,o,...a)},e.prototype.send=function(r){let o=this.__lumen;if(o&&!fn(o.url)){o.t=performance.now();let a=()=>{try{st(it,{type:"xhr",method:o.method,url:Rt(o.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-o.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,r??null)};}function Qr(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Rt(e){return Qr(cn(e))}function gn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:Jt(e),consoleLog:[],networkLog:[]};let t=jr();return {url:dn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:Jt(e),device:eo(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function eo(){let e={};try{e.screen={width:window.screen?.width??0,height:window.screen?.height??0},e.pixelRatio=window.devicePixelRatio??1,e.language=navigator.language,e.languages=Array.from(navigator.languages??[]),e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,e.colorScheme=window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light",e.referrer=document.referrer?dn(document.referrer):void 0,e.title=document.title||void 0,e.online=navigator.onLine,performance.getEntriesByType("navigation")[0]&&(e.uptimeMs=Math.round(performance.now()));}catch{}return e}function Jt(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var to="[data-lumen-root]",no="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function ro(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(St(n))return true;return St(e.target)}var Qt=["pointerdown","mousedown","touchstart","click"];function oo(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of Qt)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of Qt)e.removeEventListener(n,t);}}function St(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(no)?true:!!e.closest(to):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?St(e.host):false:false}var ct="lumen:shake",ao=8e3,io=50,so=400;function lo(e={}){return async function(){if(typeof window>"u")throw new N("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=co(),n=e.send??uo,r=e.timeoutMs??ao,o=e.captureSettleMs??io,a=e.awaitAnimationsMs??so,i=ho(),s=nn(e.concealSelector===void 0?tn:e.concealSelector);try{await po(o,a);let l=await new Promise((p,b)=>{let w=window.setTimeout(()=>{t.pending.delete(i),b(new N("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:g=>{window.clearTimeout(w),p(g);},reject:g=>{window.clearTimeout(w),b(g);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(w),b(new N("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(l.error||!l.dataUrl)throw new N(l.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let u=bo(l.dataUrl),d=e.platform??go();return {blob:u,method:d==="android"?"android-native":"ios-native",platform:d,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:l.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{s();}}}function uo(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new N("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function co(){if(window.__lumenNativeCapture)return window.__lumenNativeCapture;let e={pending:new Map,resolve(n,r,o){let a=e.pending.get(n);a&&(e.pending.delete(n),a.resolve({type:"lumen:capture-response",id:n,dataUrl:r,pixelRatio:o}));},reject(n,r){let o=e.pending.get(n);o&&(e.pending.delete(n),o.resolve({type:"lumen:capture-response",id:n,error:r}));}},t=n=>{let r=mo(n.data);if(!r||r.type!=="lumen:capture-response")return;let o=e.pending.get(r.id);o&&(e.pending.delete(r.id),o.resolve(r));};return window.addEventListener("message",t),document.addEventListener("message",t),window.__lumenNativeCapture=e,e}function mo(e){if(e&&typeof e=="object"&&"type"in e)return e;if(typeof e=="string")try{let t=JSON.parse(e);if(t&&typeof t=="object"&&t.type)return t}catch{}return null}async function po(e,t){await sn(t),await fo(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function fo(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function go(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function ho(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function bo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new N("Native host returned an invalid image data URL.","NATIVE_CAPTURE_FAILED");let n=t[1]||"image/png",r=!!t[2],o=t[3]??"";if(!r)return new Blob([decodeURIComponent(o)],{type:n});let a=atob(o),i=new Uint8Array(a.length);for(let s=0;s<a.length;s++)i[s]=a.charCodeAt(s);return new Blob([i],{type:n})}var Ye="lumen:keyboardchange",Mt="--lumen-keyboard-inset";function vo(e){if(typeof window>"u")return;let t=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):0;window.__lumenKeyboardInset=t,typeof document<"u"&&document.documentElement.style.setProperty(Mt,`${t}px`),window.dispatchEvent(new Event(Ye));}function Lt(){if(typeof window>"u")return null;let e=window.__lumenKeyboardInset;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof document<"u"&&typeof getComputedStyle=="function"){let t=getComputedStyle(document.documentElement).getPropertyValue(Mt).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function hn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new N("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new N("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(w=>MediaRecorder.isTypeSupported(w))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((w,g)=>{u=w,d=g;});p.catch(()=>{}),r.addEventListener("dataavailable",w=>{w.data&&w.data.size>0&&o.push(w.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let x of t.getTracks())x.stop();if(l)return;if(l=true,s){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let w=performance.now()-a,g=r.mimeType||n||"audio/webm",S=new Blob(o,{type:g});u({blob:S,durationMs:w,mimeType:g});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function b(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){s=true,b(),i!==null&&window.clearTimeout(i),i=null;for(let w of t.getTracks())w.stop();},stop(){return b(),p}}}async function bn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new N("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new N("Screen capture was denied or cancelled.","SCREEN_DENIED")}let n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(g=>MediaRecorder.isTypeSupported(g))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((g,S)=>{u=g,d=S;});p.catch(()=>{});function b(){i!==null&&(window.clearTimeout(i),i=null);for(let g of t.getTracks())g.stop();}r.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&o.push(g.data);}),r.addEventListener("stop",()=>{if(s)return;if(s=true,b(),l){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let g=r.mimeType||n||"video/webm";u({blob:new Blob(o,{type:g}),durationMs:performance.now()-a,mimeType:g});});function w(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(w,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",w),{stream:t,result:p,stop:w,cancel(){l=true,r.state!=="inactive"?r.stop():s||(s=true,b(),d(new N("Recording cancelled.","RECORDER_STOPPED")));}}}var Tt=Rn.createContext(null);function Ge(){let e=Rn.useContext(Tt);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var vn=100;function wn(){if(typeof document>"u")return false;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;if(!e)return false;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?true:e.isContentEditable===true}var Ze={open:false,inset:0};function Ro(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:Ze}if(e.vvHeight==null||!e.coarse||!e.editable)return Ze;let n=e.vvBaseline-e.vvHeight;return n>vn?{open:true,inset:Math.round(n)}:Ze}function Xe(e,t){let[n,r]=Rn.useState(Ze),o=Rn.useRef(0),a=Rn.useRef(t);return a.current=t,Rn.useEffect(()=>{if(!e){r(Ze);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,s=()=>{let p=wn(),b=a.current,w=Lt(),g=window.visualViewport??null;g&&b==null&&w==null&&!p&&(o.current=g.height),r(Ro({editable:p,override:b,injected:w,vvBaseline:o.current,vvHeight:g?g.height:null,coarse:i}));},l=0,u=()=>{l||(l=window.requestAnimationFrame(()=>{l=0,s();}));},d=window.visualViewport;return d&&(o.current=d.height),u(),d?.addEventListener("resize",u),d?.addEventListener("scroll",u),document.addEventListener("focusin",u),document.addEventListener("focusout",u),window.addEventListener(Ye,u),()=>{l&&window.cancelAnimationFrame(l),d?.removeEventListener("resize",u),d?.removeEventListener("scroll",u),document.removeEventListener("focusin",u),document.removeEventListener("focusout",u),window.removeEventListener(Ye,u);}},[e]),n}var At='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Cn(e,t=1){return Math.max(0,Math.min(t,e))}var Sn=Rn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a},i){let s=Rn.useRef(null),l=Rn.useRef(null),u=Rn.useRef(null),[d,p]=Rn.useState(null),[b,w]=Rn.useState([]),g=Rn.useRef(null),S=Rn.useRef(false),x=Rn.useRef(0),M=Rn.useRef(false),[L,h]=Rn.useState([]),R=Rn.useRef(0),I=Rn.useRef([]),A=Rn.useRef(null),_=Rn.useCallback((f,y)=>{h(k=>k.map(T=>T.id===f?{...T,text:y}:T));},[]),D=Rn.useCallback(f=>{h(k=>k.filter(T=>T.id!==f));let y=I.current.lastIndexOf("comment");y>=0&&I.current.splice(y,1);},[]);Rn.useEffect(()=>{let f=A.current;if(f==null)return;A.current=null,u.current?.querySelector(`[data-bubble-id="${f}"] .lumen-bubble-text`)?.focus();},[L]),Rn.useEffect(()=>{let f=false,y=null;return (async()=>{try{let k=await createImageBitmap(t);if(f){k.close?.();return}y=k,p(k);}catch{}})(),()=>{f=true,y?.close?.();}},[t]),Rn.useEffect(()=>{if(!d)return;let f=s.current,y=l.current;if(!f||!y)return;f.width=d.width,f.height=d.height,y.width=d.width,y.height=d.height;let k=f.getContext("2d");k&&(k.imageSmoothingEnabled=false,k.drawImage(d,0,0));},[d]),Rn.useEffect(()=>{let f=l.current;f&&dt(f,b,g.current);},[b]),Rn.useImperativeHandle(i,()=>({hasAnnotations:()=>b.length>0||L.some(f=>f.text.trim().length>0),reset:()=>{w([]),h([]),I.current=[];},undo:()=>{(I.current.pop()??"anno")==="comment"?h(y=>y.length===0?y:y.slice(0,-1)):w(y=>y.length===0?y:y.slice(0,-1));},async flatten(){let f=g.current,y=f?[...b,f]:b,k=L.filter(U=>U.text.trim().length>0);if(y.length===0&&k.length===0||!d)return t;let T=document.createElement("canvas");T.width=d.width,T.height=d.height;let F=T.getContext("2d");if(!F)return t;F.imageSmoothingEnabled=false,F.drawImage(d,0,0);for(let U of y)Nt(F,U);let K=s.current?.clientWidth||d.width,j=d.width/Math.max(K,1);for(let U of k)Lo(F,U,d.width,d.height,j);return await new Promise(U=>{T.toBlob(oe=>{U(oe??t);},"image/jpeg",.85);})}}),[b,L,d,t]);function J(f){let y=l.current;if(!y)return {x:0,y:0};let k=y.getBoundingClientRect(),T=y.width/Math.max(k.width,1),F=y.height/Math.max(k.height,1);return {x:(f.clientX-k.left)*T,y:(f.clientY-k.top)*F}}function H(){M.current||(M.current=true,requestAnimationFrame(()=>{M.current=false;let f=l.current;f&&dt(f,b,g.current);}));}function Ce(f){if(f.button!==void 0&&f.button!==0)return;if(n==="comment"){let k=l.current;if(!k)return;let T=k.getBoundingClientRect(),F=Cn((f.clientX-T.left)/Math.max(T.width,1),.72),K=Cn((f.clientY-T.top)/Math.max(T.height,1),.8),j=++R.current;h(U=>[...U,{id:j,x:F,y:K,text:"",color:r}]),I.current.push("comment"),A.current=j;return}try{f.currentTarget.setPointerCapture(f.pointerId);}catch{}S.current=true,a?.(true);let y=J(f);n==="arrow"?g.current={kind:"arrow",from:y,to:y,color:r,width:o}:n==="rect"?g.current={kind:"rect",from:y,to:y,color:r,width:o}:g.current={kind:"freehand",points:[y],color:r,width:o},x.current=performance.now(),H();}function be(f){if(!S.current||!g.current)return;let y=J(f),k=g.current;if(k.kind==="arrow"||k.kind==="rect")k.to=y;else {let T=k.points[k.points.length-1],F=T?(T.x-y.x)**2+(T.y-y.y)**2:1/0,K=performance.now(),j=K-x.current;(F>16||j>16)&&(k.points.push(y),x.current=K);}H();}function V(){if(!S.current)return;S.current=false,a?.(false);let f=g.current;if(g.current=null,!!f){if(f.kind==="arrow"||f.kind==="rect"){let y=f.to.x-f.from.x,k=f.to.y-f.from.y;if(y*y+k*k<16){let T=l.current;T&&dt(T,b,null);return}}else if(f.points.length<2){let y=l.current;y&&dt(y,b,null);return}w(y=>[...y,f].slice(-50)),I.current.push("anno");}}return jsxRuntime.jsxs("div",{ref:u,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:s}),jsxRuntime.jsx("canvas",{ref:l,className:"lumen-annotate-overlay",onPointerDown:Ce,onPointerMove:be,onPointerUp:V,onPointerCancel:V}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:L.map(f=>jsxRuntime.jsx(xo,{comment:f,onChange:_,onRemove:D},f.id))})]})});function xo({comment:e,onChange:t,onRemove:n}){let r=Rn.useRef(null);return Rn.useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxRuntime.jsxs("div",{className:"lumen-bubble","data-bubble-id":e.id,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,"--lumen-bubble-accent":e.color},onPointerDown:o=>o.stopPropagation(),children:[jsxRuntime.jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsxRuntime.jsx("div",{ref:r,className:"lumen-bubble-text",contentEditable:true,suppressContentEditableWarning:true,role:"textbox","aria-label":"Comment text","data-placeholder":"Type a note\u2026",onInput:o=>t(e.id,o.currentTarget.textContent??"")}),jsxRuntime.jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function dt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)Nt(r,o);n&&Nt(r,n);}}function Nt(e,t){if(e.save(),e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",t.kind==="rect"){let n=Math.min(t.from.x,t.to.x),r=Math.min(t.from.y,t.to.y),o=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,r,o,a);}else if(t.kind==="freehand")Mo(e,t.points);else {let{from:n,to:r,width:o}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke();let a=Math.atan2(r.y-n.y,r.x-n.x),i=Math.max(12,o*4);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(r.x-i*Math.cos(a-Math.PI/7),r.y-i*Math.sin(a-Math.PI/7)),e.lineTo(r.x-i*Math.cos(a+Math.PI/7),r.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function Mo(e,t){if(t.length===0)return;e.beginPath();let n=t[0];if(!n)return;if(e.moveTo(n.x,n.y),t.length===1){e.arc(n.x,n.y,e.lineWidth/2,0,Math.PI*2),e.fill();return}if(t.length===2){let o=t[1];e.lineTo(o.x,o.y),e.stroke();return}for(let o=1;o<t.length-1;o++){let a=t[o],i=t[o+1],s=(a.x+i.x)/2,l=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,s,l);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function Lo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,s=14*o,l=10*o,u=12*o,d=s*1.35,p=l*1.7,b=t.x*n,w=t.y*r,g=Math.min(n*.6,n-b-8*o);e.save(),e.font=`500 ${s}px ${At}`,e.textBaseline="top";let S=To(e,a,g-i*2),x=S.reduce((A,_)=>Math.max(A,e.measureText(_).width),0),M=Math.min(g,Math.max(x,56*o)+i*2),L=i*2+p+S.length*d;Po(e,b,w,M,L,u),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let h=b+18*o,R=w+L;e.beginPath(),e.moveTo(h,R-o),e.lineTo(h+13*o,R-o),e.lineTo(h+4*o,R+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${l}px ${At}`,e.fillText("COMMENT",b+i,w+i),e.fillStyle="#111318",e.font=`500 ${s}px ${At}`;let I=w+i+p;for(let A of S)e.fillText(A,b+i,I),I+=d;e.restore();}function To(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let s=a?`${a} ${i}`:i;a&&e.measureText(s).width>n?(o.push(a),a=i):a=s;}return a&&o.push(a),o.length?o:[t]}function Po(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function Qe({children:e,...t}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...t,children:e})}function Ao(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("path",{d:"M3 9a2 2 0 0 1 2-2h1.5l1-1.5h5l1 1.5H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),jsxRuntime.jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function No(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsxRuntime.jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Io(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsxRuntime.jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function mt(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function xn(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var It={shot:Ao,video:No,upload:Io};function Mn(e){let t=e.videoWidth||1280,n=e.videoHeight||720,r=document.createElement("canvas");r.width=t,r.height=n;let o=r.getContext("2d");return o?(o.drawImage(e,0,0,t,n),new Promise(a=>r.toBlob(i=>a(i),"image/jpeg",.82))):Promise.resolve(null)}function Do(e,t){return !Number.isFinite(t)||t<=0?Promise.resolve():new Promise(n=>{e.addEventListener("seeked",()=>n(),{once:true});try{e.currentTime=t;}catch{n();}})}var Oo=4e3;async function Dt(e){if(typeof document>"u")return {poster:null,durationMs:0};let t=URL.createObjectURL(e),n=document.createElement("video");n.muted=true,n.playsInline=true,n.preload="auto",n.src=t;let r=async()=>{await new Promise((l,u)=>{if(n.readyState>=2)return l();n.addEventListener("loadeddata",()=>l(),{once:true}),n.addEventListener("error",()=>u(new Error("video decode failed")),{once:true});}),await Do(n,Math.min(.1,(n.duration||0)/2));let i=await Mn(n),s=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:s}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),Oo);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Ot(e){if(typeof document>"u")return null;let t=document.createElement("video");t.muted=true,t.playsInline=true,t.srcObject=e;try{return await t.play().catch(()=>{}),await new Promise(n=>{if(t.readyState>=2)return n();t.addEventListener("loadeddata",()=>n(),{once:!0}),window.setTimeout(n,600);}),await Mn(t)}catch{return null}finally{t.srcObject=null;}}async function Bt(){if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=1280,e.height=720;let t=e.getContext("2d");return t?(t.fillStyle="#0e0e12",t.fillRect(0,0,e.width,e.height),t.fillStyle="#52525b",t.beginPath(),t.moveTo(590,312),t.lineTo(590,408),t.lineTo(694,360),t.closePath(),t.fill(),new Promise(n=>e.toBlob(r=>n(r),"image/jpeg",.8))):null}var Ht=60,Bo=25*1024*1024,Ln=[{label:"Red",value:"rgb(239, 68, 68)"},{label:"Amber",value:"rgb(245, 158, 11)"},{label:"Blue",value:"rgb(59, 130, 246)"},{label:"Green",value:"rgb(34, 197, 94)"},{label:"Neutral",value:"rgb(244, 244, 245)"}],Tn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],Pn=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],An=[{value:"shot",label:"Screenshot",hint:"This page, instantly",primary:true},{value:"video",label:"Video",hint:"Record up to 60s"},{value:"upload",label:"Upload",hint:"Image or video"}];function _t(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:s,consumePendingVideo:l,canRecordScreen:u,consumeRecordStartError:d,startScreenCaptureSession:p,consumePendingScreenshot:b,isolateEvents:w,keyboardInset:g}=Ge(),[S,x]=Rn.useState(1),[M,L]=Rn.useState(null),[h,R]=Rn.useState({kind:"idle"}),[I,A]=Rn.useState(false),[_,D]=Rn.useState(0),[J,H]=Rn.useState(null),[Ce,be]=Rn.useState(false),[V,f]=Rn.useState("arrow"),[y,k]=Rn.useState(Ln[0].value),[T,F]=Rn.useState(Tn[1].value),[K,j]=Rn.useState(""),[U,oe]=Rn.useState("bug"),[Re,nt]=Rn.useState(r?.email??""),[W,Ie]=Rn.useState(null),[Q,Y]=Rn.useState(null),[de,Se]=Rn.useState(0),[ae,ee]=Rn.useState(null),[me,G]=Rn.useState(null),[te,Fe]=Rn.useState(false),pe=Rn.useRef(null),ke=Rn.useRef(null),Ue=Rn.useRef(null),ze=Rn.useRef(null),ve=Xe(t,g),ie=Rn.useRef(false),De=Rn.useRef(false);Rn.useEffect(()=>{t||(De.current=false);},[t]),Rn.useEffect(()=>{if(!t)return;if(De.current){ie.current=false;return}De.current=true,ie.current=false,x(1),L(null),j(""),Y(null),Se(0),ee(null),A(false),D(0),H(null),be(false),G(null);let c=b();if(c){L("shot"),Oe(c),R({kind:"ready",capture:c});return}let v=l();if(v)L("video"),ee({blob:v.blob,durationMs:v.durationMs}),v.blob.size>Bo&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),v.poster?R({kind:"ready",capture:qe(v.poster,["Screen recording; preview is the first frame."])}):(R({kind:"capturing"}),(async()=>{let P=null;if(v.deriveBlobPoster)try{P=(await Dt(v.blob)).poster;}catch{P=null;}P=P??await Bt(),!ie.current&&R(P?{kind:"ready",capture:qe(P,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let P=d();P?(L("video"),G(P),R({kind:"idle"})):a?(L("shot"),R({kind:"ready",capture:a})):o?.mode==="manual"?R({kind:"manual"}):o?.provider&&!i?(L("shot"),fe(o.mode??"auto")):R({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ie.current=true;}},[t,o,a,i]),Rn.useEffect(()=>{if(!t)return;ze.current=document.activeElement??null;let c=document.documentElement,v=c.style.overflow,P=c.style.paddingRight,X=window.innerWidth-c.clientWidth;c.style.overflow="hidden",X>0&&(c.style.paddingRight=`${X}px`);let ne=false,Me=()=>{if(!ne){ne=true,c.style.overflow=v,c.style.paddingRight=P;try{ze.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Me),()=>{window.removeEventListener("pagehide",Me),Me();}},[t]),Rn.useEffect(()=>{if(!t)return;function c(v){if(v.key==="Escape"){v.preventDefault(),n();return}if(v.key!=="Tab")return;let P=ke.current;if(!P)return;let X=qo(P);if(X.length===0)return;let ne=X[0],Me=X[X.length-1],yt=document.activeElement;v.shiftKey&&(yt===ne||!P.contains(yt))?(v.preventDefault(),Me.focus()):!v.shiftKey&&yt===Me&&(v.preventDefault(),ne.focus());}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,n]),Rn.useEffect(()=>{if(!t||!w)return;let c=Ue.current;if(!c)return;let v=P=>{P.target===c&&P.stopPropagation();};return c.addEventListener("pointerdown",v),c.addEventListener("click",v),c.addEventListener("touchstart",v,{passive:true}),()=>{c.removeEventListener("pointerdown",v),c.removeEventListener("click",v),c.removeEventListener("touchstart",v);}},[t,w]),Rn.useEffect(()=>{if(!t||!ve.open)return;let c=ke.current,v=document.activeElement;if(c&&v&&c.contains(v))try{v.scrollIntoView({block:"center"});}catch{}},[t,ve.open,ve.inset]),Rn.useEffect(()=>{if(!t||h.kind!=="manual")return;function c(v){let ne=Array.from(v.clipboardData?.items??[]).find(Me=>Me.type.startsWith("image/"))?.getAsFile();ne&&(v.preventDefault(),Z(ne));}return window.addEventListener("paste",c),()=>window.removeEventListener("paste",c)},[t,h.kind]),Rn.useEffect(()=>{if(!W)return;let c=Date.now(),v=window.setInterval(()=>{let P=Math.floor((Date.now()-c)/1e3);Se(P),P>=Ht&&ye();},250);return ()=>window.clearInterval(v)},[W]);let xe=Rn.useRef(null);if(xe.current=W,Rn.useEffect(()=>{t||xe.current&&(xe.current.cancel(),xe.current=null,Ie(null),Se(0));},[t]),Rn.useEffect(()=>()=>{xe.current?.cancel();},[]),!t)return null;async function fe(c){ie.current=false,R({kind:"capturing"});try{let v=await lt({...o,mode:c,target:o?.target??document.documentElement});return ie.current?!1:(Oe(v),R({kind:"ready",capture:v}),!0)}catch(v){return ie.current||R({kind:"manual",error:v instanceof Error?v.message:"Automatic screenshot capture was unavailable."}),false}}async function ge(c){L(c),G(null),H(null),c!=="video"&&Be(),c==="shot"?await fe(o?.mode??"auto"):c==="video"?(ee(null),R({kind:"idle"})):R({kind:"manual"});}async function Z(c){if(c.type.startsWith("image/")){Be();let v=qe(c,["Manual image upload used."]);R({kind:"ready",capture:v});return}if(c.type.startsWith("video/")){R({kind:"capturing"});try{let{poster:v,durationMs:P}=await Dt(c),X=v??await Bt();if(!X){R({kind:"manual",error:"Could not read that video."});return}let ne=qe(X,["Uploaded video; preview is the first frame."]);ee({blob:c,durationMs:P}),R({kind:"ready",capture:ne});}catch{R({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function Oe(c){c.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function we(){try{let c=await hn(Ht);Ie(c);}catch(c){sonner.toast.error(c instanceof Error?c.message:"Microphone unavailable");}}async function ye(){if(W)try{let c=await W.stop();Y({blob:c.blob,durationMs:c.durationMs});}catch(c){sonner.toast.error(c instanceof Error?c.message:"Could not stop recording");}finally{Ie(null);}}function $e(){W?.cancel(),Ie(null),Y(null),Se(0);}function Ke(c){let v=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!W&&!Q?jsxRuntime.jsxs("button",{type:"button",onClick:we,className:c==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(xn,{}),"Record voice note"]}):null,W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(Uo,{stream:W.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[de,"s / ",Ht,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:ye,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:$e,className:"lumen-btn-ghost",children:"Cancel"})]}):null,Q&&!W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($o,{blob:Q.blob,durationMs:Q.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Y(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return c==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[v,!W&&!Q?jsxRuntime.jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),v]})}async function rt(){G(null);try{await s();}catch(c){sonner.toast.error(c instanceof Error?c.message:"Screen capture unavailable");}}function Be(){ee(null);}let ot=h.kind==="ready";async function He(){if(W&&await ye(),S===1){if(h.kind==="ready"){let c=await pe.current?.flatten();H(c??h.capture.blob),be(c!=null&&c!==h.capture.blob);}x(2);}else S===2?x(3):await vt();}function bt(){S>1&&x(c=>c-1);}async function vt(){if(h.kind!=="ready")return;let c=K.trim(),{capture:v}=h;A(true),D(0);try{let P=J??v.blob,X=await e.submit({rawText:c.length>0?c:void 0,category:U,submitterEmail:Re.trim()||void 0,screenshot:P,audio:Q?.blob,audioDurationMs:Q?.durationMs,video:ae?.blob,videoDurationMs:ae?.durationMs,context:gn(v)},{onUploadProgress:ne=>D(Math.min(.95,ne))});D(1),sonner.toast.success("Feedback sent \u2014 thank you."),X.id,n();}catch(P){sonner.toast.error(P instanceof Error?P.message:"Could not submit feedback"),A(false);}}function he(c){c.target===c.currentTarget&&!I&&n();}let C=Math.round(_*100),O=M==="video",z=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,wt=M==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&z,gr=S===1&&!ot||I,hr=S<3?"Next":I?C<95?`Uploading ${C}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:Ue,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:ve.inset?{"--lumen-keyboard-inset":`${ve.inset}px`}:void 0,onMouseDown:he,children:jsxRuntime.jsxs("div",{ref:ke,className:"lumen-modal","data-lumen-drawing":te?"true":void 0,children:[jsxRuntime.jsx(Fo,{onDismiss:n}),jsxRuntime.jsxs("header",{className:"lumen-modal-header",children:[jsxRuntime.jsxs("h2",{className:"lumen-modal-title",children:[jsxRuntime.jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsx(Ho,{step:S}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[S===1?jsxRuntime.jsx("div",{className:"lumen-pane",children:M===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(c.primary?" lumen-method-primary":""),onClick:()=>ge(c.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(v,{})}),c.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]})]},c.value)})}),jsxRuntime.jsx("p",{className:"lumen-status lumen-method-help",children:"Choose how to capture your feedback."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method-switch",role:"group","aria-label":"Switch capture method",children:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button","aria-pressed":M===c.value,onClick:()=>ge(c.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx(v,{}),c.label]},c.value)})}),M==="video"&&h.kind==="idle"?jsxRuntime.jsx(_o,{canRecord:u,onRecord:rt,onUpload:()=>ge("upload"),error:me}):null,h.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,h.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:M==="upload"?"Choose an image or video to attach \u2014 or paste an image.":h.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:M==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:M==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:c=>{let v=c.currentTarget.files?.[0];v&&Z(v),c.currentTarget.value="";}})]})]}):null,h.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[O?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(pt,{label:"Arrow",active:V==="arrow",onClick:()=>f("arrow")}),jsxRuntime.jsx(pt,{label:"Box",active:V==="rect",onClick:()=>f("rect")}),jsxRuntime.jsx(pt,{label:"Draw",active:V==="freehand",onClick:()=>f("freehand")}),jsxRuntime.jsx(pt,{label:"Comment",active:V==="comment",onClick:()=>f("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:Ln.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:c.value},"aria-label":c.label,"aria-pressed":y===c.value,onClick:()=>k(c.value)},c.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Tn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":c.label,"aria-pressed":T===c.value,onClick:()=>F(c.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:c.dot,height:c.dot}})},c.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.undo(),children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.reset(),children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Sn,{ref:pe,screenshot:h.capture.blob,tool:V,color:y,strokeWidth:T,onDrawingChange:Fe})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>M&&ge(M),children:O?"\u21BB Re-record":"\u21BB Recapture"}),wt?jsxRuntime.jsxs("button",{type:"button",className:"lumen-btn-ghost lumen-exact-btn",onClick:()=>{p();},title:"Capture the real screen pixels \u2014 your browser will ask which tab or window to share, then you arrange the page and press Capture.",children:[jsxRuntime.jsx(mt,{})," Capture exact screen"]}):null,O?ae?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ae.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:h.capture.method==="web-display-media"?"Exact screen captured":`${Nn(M)} captured \xB7 switch method above anytime`})]}),Ke("capture")]}):null]})}):null,S===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:K,onChange:c=>j(c.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),Ke("describe"),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:Pn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":U===c.value,onClick:()=>oe(c.value),children:c.label},c.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:Re,onChange:c=>nt(c.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,S===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[Nn(M),Ce?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:Pn.find(c=>c.value===U)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[K.trim()?K.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[Q?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(Q.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>Y(null),children:"\xD7"})]}):null,ae?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ae.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Be,children:"\xD7"})]}):null,Re.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",Re.trim()]}):null,!Q&&!W?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{x(2),we();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[I?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":C,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${C}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:S===1?n:bt,className:"lumen-btn-ghost",disabled:I,children:S===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:He,className:"lumen-btn-primary",disabled:gr,children:hr})]})]})]})})}function Nn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function Ho({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsxRuntime.jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxRuntime.jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsxRuntime.jsx("span",{className:"lumen-step-num",children:n.n}),jsxRuntime.jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function _o({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[r?jsxRuntime.jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsxRuntime.jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsxRuntime.jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxRuntime.jsxs("div",{className:"lumen-record-copy",children:[jsxRuntime.jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsxRuntime.jsx("div",{className:"lumen-record-sub",children:"Tap to start. The sheet closes so you can record freely \u2014 a Stop button stays on screen, then the sheet returns with your clip. Max 60s."})]})]}):jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[jsxRuntime.jsx("p",{className:"lumen-record-unavailable",children:Vo()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function Vo(){if(typeof navigator>"u")return false;let e=navigator.userAgent||"";return /iPad|iPhone|iPod/.test(e)?true:/Macintosh/.test(e)&&typeof document<"u"&&"ontouchend"in document}function pt({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function Fo({onDismiss:e}){let t=Rn.useRef(null),n=Rn.useRef(0),r=Rn.useRef(null);function o(s){s.currentTarget.setPointerCapture(s.pointerId),t.current=s.clientY,n.current=performance.now(),r.current=s.currentTarget.parentElement;}function a(s){if(t.current==null||!r.current)return;let l=Math.max(0,s.clientY-t.current);r.current.style.transform=`translateY(${l}px)`;}function i(s){if(t.current==null||!r.current)return;let l=Math.max(0,s.clientY-t.current),u=Math.max(1,performance.now()-n.current),d=l/u;r.current.style.transform="",r.current.style.transition="",t.current=null,(l>80||d>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function Uo({stream:e}){let t=Rn.useRef(null);return Rn.useEffect(()=>{let n=t.current;if(!n)return;let r=Math.min(window.devicePixelRatio||1,2),o=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(o*r),n.height=Math.round(a*r);let i=n.getContext("2d");if(!i)return;i.scale(r,r);let s=window.AudioContext??window.webkitAudioContext;if(!s)return;let l=new s,u=l.createMediaStreamSource(e),d=l.createAnalyser();d.fftSize=1024,d.smoothingTimeConstant=.6,u.connect(d);let p=new Uint8Array(d.fftSize),b=18,w=3,g=3,S=Math.max(2,(o-w*(b-1))/b),x=Math.min(S/2,3),M=new Array(b).fill(0),L=0,h=false;function R(){if(h)return;d.getByteTimeDomainData(p);let I=Math.floor(p.length/b);i.clearRect(0,0,o,a),i.fillStyle=Ko("--lumen-danger")||"rgb(239,68,68)";for(let A=0;A<b;A++){let _=0;for(let V=0;V<I;V++){let f=Math.abs((p[A*I+V]??128)-128);f>_&&(_=f);}let D=Math.min(1,_/128*1.8),J=M[A]??0;M[A]=D>J?D:J+(D-J)*.35;let H=Math.max(g,M[A]*a),Ce=A*(S+w),be=(a-H)/2;zo(i,Ce,be,S,H,x),i.fill();}L=requestAnimationFrame(R);}return L=requestAnimationFrame(R),()=>{h=true,cancelAnimationFrame(L);try{u.disconnect();}catch{}l.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function zo(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function $o({blob:e,durationMs:t}){let[n,r]=Rn.useState("");return Rn.useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxRuntime.jsxs("div",{className:"lumen-audio-preview",children:[jsxRuntime.jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxRuntime.jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function Ko(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var Wo='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function qo(e){return Array.from(e.querySelectorAll(Wo)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var ft=class extends Rn__namespace.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t,n){if(typeof document<"u"){let r=document.documentElement;r.style.overflow="",r.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),sonner.toast.error("Feedback widget hit a snag and was reset. Please try again.");try{let r=t instanceof Error?t:null;this.props.onError?.({message:r?.message??String(t),name:r?.name??"Error",stack:r?.stack,componentStack:n?.componentStack??void 0});}catch{}Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function Hn({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(Yo,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-rec-hud lumen-rec-hud-pending",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function Yo({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(0);Rn.useEffect(()=>{let s=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));s();let l=window.setInterval(s,250);return ()=>window.clearInterval(l)},[e,t]);let i=s=>`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`;return jsxRuntime.jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxRuntime.jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxRuntime.jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function _n({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,s=e.phase==="grabbing";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-cap-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[s?jsxRuntime.jsx("span",{className:"lumen-cap-hud-spinner","aria-hidden":"true"}):jsxRuntime.jsx("span",{className:"lumen-cap-hud-ico","aria-hidden":"true",children:jsxRuntime.jsx(mt,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:s?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:s,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:s,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Vt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function Vn(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function Fn(e){return e instanceof Error?e:new Error(String(e))}function Un(e,t,n){let r=false,o=false,a=false,i=null;function s(){o||(o=true,n.onCancelled());}function l(d){o||(o=true,n.onResult(d));}function u(d){o||(o=true,n.onError(d));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(d=>{if(i=d,r){try{d.cancel();}catch{}s();return}if(n.onActive(d),a){n.onProcessing();try{d.stop();}catch{}}Promise.resolve(d.result).then(p=>{r?s():l(p);}).catch(p=>{r||Vn(p)?s():u(Fn(p));});}).catch(d=>{r||Vn(d)?s():u(Fn(d));}),{stop(){if(!(o||r||a)&&(a=true,i)){n.onProcessing();try{i.stop();}catch{}}},cancel(){if(!(o&&r)){if(r=true,i)try{i.cancel();}catch{}s();}}}}function zn(){if(typeof document>"u"||typeof window>"u")return 0;let e=window.innerWidth,t=window.innerHeight;if(e===0||t===0)return 0;let n=t-4,r=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],o=new Set,a=0;for(let i of r){let s=document.elementsFromPoint(i,n);for(let l of s){if(o.has(l))continue;o.add(l);let u=window.getComputedStyle(l);if(u.position!=="fixed"&&u.position!=="sticky")continue;let d=l.getBoundingClientRect();d.bottom<t-8||d.bottom>t+8||d.width<e*.6||d.height>a&&(a=d.height);}}return a}function Ft(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,r=window.innerHeight,o=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let s of Array.from(i)){let l=s.getBoundingClientRect();if(l.height===0||l.width===0)continue;let u=0;switch(t){case "bottom":if(l.bottom<r-8)break;u=Math.max(0,r-l.top);break;case "top":if(l.top>8)break;u=Math.max(0,l.bottom);break;case "left":if(l.left>8)break;u=Math.max(0,l.right);break;case "right":if(l.right<n-8)break;u=Math.max(0,n-l.left);break}u>o&&(o=u);}}return o}function $n(e){let[t,n]=Rn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Rn.useRef(t),o=na(e.avoid),a=e.placement,i=e.offset.x,s=e.offset.y;return Rn.useEffect(()=>{if(typeof window>"u")return;let l=0,u=false,d=()=>{if(l=0,u)return;let S=a[0]==="b"?"bottom":"top",x=a[1]==="r"?"right":"left",M=0,L=0;e.avoid==="auto"&&S==="bottom"?M=zn():Array.isArray(e.avoid)&&(M=Ft(e.avoid,S),L=Ft(e.avoid,x));let h={bottom:S==="bottom"?s+M:0,top:S==="top"?s+M:0,right:x==="right"?i+L:0,left:x==="left"?i+L:0},R=r.current;(h.bottom!==R.bottom||h.top!==R.top||h.right!==R.right||h.left!==R.left)&&(r.current=h,n(h));},p=()=>{l||(l=window.requestAnimationFrame(d));};p();let b=typeof ResizeObserver<"u"?new ResizeObserver(p):null;b?.observe(document.documentElement);let w=typeof MutationObserver<"u"?new MutationObserver(p):null;w?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let g=window.visualViewport;return g?.addEventListener("resize",p),g?.addEventListener("scroll",p),()=>{u=true,l&&window.cancelAnimationFrame(l),b?.disconnect(),w?.disconnect(),window.removeEventListener("resize",p),g?.removeEventListener("resize",p),g?.removeEventListener("scroll",p);}},[a,i,s,o]),t}function na(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var Kn=["mousedown","touchstart"];function Ve(e){let t=Rn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Rn.useRef(e.onClick);n.current=e.onClick;let r=Rn.useRef(e.isolate??true);r.current=e.isolate??true;let o=Rn.useRef(null);return Rn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=u=>{r.current&&u.stopPropagation(),t.current?.(u);},s=u=>{r.current&&u.stopPropagation(),n.current(u);},l=u=>{r.current&&u.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",s);for(let u of Kn)a.addEventListener(u,l,u==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",s);for(let u of Kn)a.removeEventListener(u,l);};},[])}function Yn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[s,l]=Rn.useState(null),u=Rn.useRef(null),d=$n(e),p=Xe(e.keyboard!=="off",i),b=Ve({onPointerDown:r,onClick:o,isolate:a}),w=Rn.useCallback(D=>{u.current=D,b(D);},[b]);Rn.useEffect(()=>{typeof document>"u"||l(t??document.body);},[t]);let g=e.placement,S=g[0]==="b"?"bottom":"top",x=g[1]==="r"?"right":"left",M=S==="bottom",L=p.open&&M&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,h=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&M&&p.inset<=0);if(sa(u,!n&&!h),!s)return null;let R=S==="bottom"?d.bottom:d.top,I=x==="right"?d.right:d.left,A=n||h,_={position:"fixed",[S]:e.safeArea?`calc(${R}px + env(safe-area-inset-${S}, 0px))`:`${R}px`,[x]:e.safeArea?`calc(${I}px + env(safe-area-inset-${x}, 0px))`:`${I}px`,zIndex:e.zIndex,transform:L?`translateY(-${L}px)`:void 0,opacity:A?0:1,pointerEvents:A?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:w,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:_,"aria-label":e.label,"aria-hidden":A?true:void 0,tabIndex:A?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),s)}function sa(e,t){let n=Rn.useRef(false);Rn.useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let r=window.setTimeout(()=>{let o=e.current;if(!o)return;let a=o.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,s=a.top+a.height/2,l=document.elementsFromPoint(i,s),u=Wn(window.getComputedStyle(o).zIndex);for(let d of l){if(d===o||o.contains(d))continue;if(Wn(window.getComputedStyle(d).zIndex)>u){n.current=true,console.warn("[lumen] trigger is occluded by",d);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function Wn(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function Gn({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),l=Ve({onPointerDown:r,onClick:o,isolate:a});return Rn.useEffect(()=>{if(typeof document>"u")return;let u=e instanceof HTMLElement?e:e.current??null;s(u);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:l,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),i):null}function Jn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),[l,u]=Rn.useState(false),d=Rn.useRef(null),p=Ve({onPointerDown:x=>{r?.(x),d.current={x:x.clientX,y:x.clientY},u(true);let M=x.currentTarget;try{M?.setPointerCapture?.(x.pointerId);}catch{}},onClick:o,isolate:a});if(Rn.useEffect(()=>{typeof document>"u"||s(t??document.body);},[t]),!i)return null;let b=`lumen-notch lumen-notch-${e.edge}${l?" lumen-notch-expanded":""}`;function w(x){let M=d.current;if(!M)return;let L=x.clientX-M.x,h=x.clientY-M.y;(e.edge==="top"&&h>16||e.edge==="bottom"&&h<-16||e.edge==="right"&&L<-16||e.edge==="left"&&L>16)&&(d.current=null,o(x.nativeEvent));}function g(){d.current=null,u(false);}function S(){d.current=null,u(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:b,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:w,onPointerUp:g,onPointerCancel:S,onMouseEnter:()=>u(true),onMouseLeave:()=>u(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function Qn(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function wa(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function er(e){return {kind:"floating",placement:e.placement??"br",offset:{x:e.offset?.x??16,y:e.offset?.y??16},safeArea:e.safeArea??true,avoid:e.avoid===false?false:e.avoid==null?"auto":Array.isArray(e.avoid)?e.avoid:[e.avoid],keyboard:wa(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Ca={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function tr(e){let t=Rn.useId();Rn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${Ra(t)}`,o={},a=(i,s)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,s);};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else {for(let[i,s]of Object.entries(Ca)){let l=e[s];typeof l=="string"&&l.length>0&&a(i,l);}typeof e.accent=="string"&&e.accent.length>0&&(a("--lumen-accent",e.accent),a("--lumen-primary",e.accent),a("--lumen-accent-fg","#ffffff")),(e.scheme==="light"||e.scheme==="dark")&&(o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e.scheme));}return n.setAttribute(r,""),()=>{n.removeAttribute(r);for(let[i,s]of Object.entries(o))i.startsWith("--")?s?n.style.setProperty(i,s):n.style.removeProperty(i):s==null?n.removeAttribute(i):n.setAttribute(i,s);}},[e,t]);}function Ra(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var nr=Symbol.for("lumen.history.patched"),Ut="lumen:locationchange";function xa(){if(typeof window>"u")return;let e=window;if(e[nr])return;e[nr]=true;let t=()=>window.dispatchEvent(new Event(Ut)),n=history.pushState;history.pushState=function(...o){let a=n.apply(this,o);return t(),a};let r=history.replaceState;history.replaceState=function(...o){let a=r.apply(this,o);return t(),a},window.addEventListener("popstate",t);}function rr(e){let[t,n]=Rn.useState(false);return Rn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;xa();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Ut,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Ut,r),window.removeEventListener("popstate",r);}},[e]),t}var Ta=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function or(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let r=n.webkit;if(r&&r.messageHandlers){t(true);return}let o=navigator.userAgent||"";Ta.some(a=>o.includes(a))&&t(true);},[]),e}var ir="lumen.config.v1.",Na=3600*1e3;function sr(e,t){let[n,r]=Rn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Rn.useEffect(()=>{if(typeof window>"u")return;let o=_a(e);o&&r({trigger:o.trigger,enabled:ar(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),s=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(s,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);let u=await l.json(),d=lr(u.trigger);if(!d)throw new Error("Malformed config response");let p=Oa(u.trigger),b=ur(u.brand);Va(e,d,p,b),r({trigger:d,enabled:ar(d),shakeToOpen:p,brand:b,loading:false});}).catch(()=>{r(l=>l.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:l);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function ar(e){return e.kind!=="headless"}var Ia=["br","bl","tr","tl"],Da=["top","right","bottom","left"];function lr(e){if(!e||typeof e!="object")return null;let t=e;if(t.enabled===false)return {kind:"headless"};let n=typeof t.label=="string"?t.label:"Feedback";return t.kind==="floating"?{kind:"floating",placement:Ia.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:Da.find(o=>o===t.edge)??"top",label:n}:null}function Oa(e){return !e||typeof e!="object"?false:e.shake===true}var Ba=/^#[0-9a-fA-F]{6}$/,Ha=["auto","light","dark"];function ur(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&Ba.test(t.accent)?t.accent:null;if(!n)return null;let r=Ha.find(a=>a===t.mode)??"auto",o=typeof t.radius=="number"&&Number.isFinite(t.radius)?Math.min(20,Math.max(0,Math.round(t.radius))):10;return {accent:n,mode:r,radius:o}}function _a(e){try{let t=window.localStorage.getItem(ir+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>Na)return null;let r=lr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:ur(n.brand)}:null}catch{return null}}function Va(e,t,n,r){try{window.localStorage.setItem(ir+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function Ua(e){if(e&&typeof e=="object")return e.type===ct;if(typeof e=="string")try{return JSON.parse(e).type===ct}catch{return false}return false}function za(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(s,l,u,d){if(!a)return a={x:s,y:l,z:u,t:d},false;if(d-a.t<o)return false;let p=Math.abs(s-a.x)+Math.abs(l-a.y)+Math.abs(u-a.z);return a={x:s,y:l,z:u,t:d},p<t?false:(i=i.filter(b=>d-b<r),i.push(d),i.length>=n?(i=[],true):false)}}}function cr(e,t,n){Rn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let d=Date.now();n||d-r<o||(r=d,t());}let i=d=>{Ua(d.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let s=za(),l=d=>{let p=d.accelerationIncludingGravity??d.acceleration;!p||p.x==null||p.y==null||p.z==null||s.push(p.x,p.y,p.z,Date.now())&&a();},u=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return u&&window.addEventListener("devicemotion",l),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),u&&window.removeEventListener("devicemotion",l);}},[e,t,n]);}var mr="https://shakebugs.vercel.app",ht=60;function pr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function Wa({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:s,portalTarget:l,capture:u,record:d,shakeToOpen:p,onOpenChange:b,beforeOpen:w,onTriggerActivate:g,isolateEvents:S=true,keyboardInset:x,suppressTrigger:M=false,children:L}){let[h,R]=Rn.useState(false),[I,A]=Rn.useState(false),[_,D]=Rn.useState(null),[J,H]=Rn.useState(null),[Ce]=Rn.useState(false),[be]=Rn.useState(null),V=Rn.useRef(false),f=Rn.useRef(false),y=Rn.useRef(null),k=Rn.useMemo(()=>new en({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Rn.useEffect(()=>{pn({ignoreUrlPrefix:(t??mr).replace(/\/$/,"")});},[t]);let T=Rn.useRef(b);T.current=b,Rn.useEffect(()=>{if(!(typeof document>"u"))return h?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[h]);let F=Rn.useRef(null);Rn.useEffect(()=>{if(F.current===h)return;let C=F.current;F.current=h,C!==null&&T.current?.(h);},[h]);let K=Rn.useRef(w);K.current=w;let j=Rn.useRef(g);j.current=g;let U=Rn.useCallback(C=>{f.current=true,y.current=Promise.resolve().then(()=>K.current?.(C)).then(()=>j.current?.(C)).then(()=>{});},[]),oe=Rn.useCallback(C=>{V.current||h||G.current||we.current||(V.current=true,A(true),D(null),H(null),(async()=>{try{if(f.current?await y.current:(await K.current?.(C),await j.current?.(C)),u?.mode==="manual")D(null),H(null);else if(u?.provider)D(null),H(null);else {let O=await lt({...u,mode:u?.mode??"auto",target:u?.target??document.documentElement});D(O);}}catch(O){H(O instanceof Error?O:new Error(String(O)));}finally{f.current=false,y.current=null,V.current=false,A(false),R(true);}})());},[u,h]),Re=Rn.useCallback(()=>{R(false),D(null),H(null);},[]),nt=Rn.useCallback(k.submit.bind(k),[k]),[W,Ie]=Rn.useState(0),Q=Rn.useCallback(()=>{V.current=false,A(false),R(false),D(null),H(null),Ie(C=>C+1);},[]),[Y,de]=Rn.useState(null),[Se,ae]=Rn.useState(null),ee=Rn.useRef(null),me=Rn.useRef(null),G=Rn.useRef(false),te=Rn.useRef(null),Fe=Rn.useRef(null),pe=Rn.useRef(null),ke=Rn.useCallback((C,O=false)=>{if(ee.current=null,me.current=null,G.current=false,de(null),!C){te.current=null;return}Fe.current={blob:C.blob,durationMs:C.durationMs,poster:te.current,deriveBlobPoster:O},te.current=null,R(true);},[]);Rn.useEffect(()=>{if(!h)return;if(!d?.provider){ae(null);return}let C=d.isAvailable;if(!C){ae(true);return}let O=false;return Promise.resolve().then(()=>C()).then(z=>{O||ae(z);}).catch(()=>{O||ae(false);}),()=>{O=true;}},[h,d?.provider,d?.isAvailable]);let Ue=Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).canRecord,ze=Rn.useCallback(async()=>{if(G.current)return;if(pe.current=null,Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).usingProvider&&d?.provider){G.current=true,te.current=null,R(false),me.current=Un(d.provider,{maxDurationSeconds:ht},{onStarting:()=>de({phase:"starting"}),onActive:z=>{de({phase:"recording",stream:z.stream??null,startedAt:Date.now(),maxSeconds:ht}),z.stream&&Ot(z.stream).then(wt=>{te.current=wt;}).catch(()=>{});},onProcessing:()=>de({phase:"processing"}),onResult:z=>ke({blob:z.blob,durationMs:z.durationMs},true),onCancelled:()=>{me.current=null,G.current=false,te.current=null,de(null),D(null),H(null),R(true);},onError:z=>{me.current=null,G.current=false,te.current=null,de(null),pe.current=z.message||"Screen recording could not start.",R(true);}});return}if(ee.current)return;let O=await bn(ht);ee.current=O,G.current=true,te.current=null,de({phase:"recording",stream:O.stream,startedAt:Date.now(),maxSeconds:ht}),R(false),Ot(O.stream).then(z=>{te.current=z;}).catch(()=>{}),O.result.then(z=>ke(z)).catch(()=>ke(null));},[ke,d?.provider,Se]),ve=Rn.useCallback(()=>{me.current?me.current.stop():ee.current?.stop();},[]),ie=Rn.useCallback(()=>{if(me.current){me.current.cancel();return}let C=ee.current;ee.current=null,G.current=false,te.current=null,de(null),C?.cancel(),D(null),H(null),R(true);},[]),De=Rn.useCallback(()=>{let C=Fe.current;return Fe.current=null,C},[]),xe=Rn.useCallback(()=>{let C=pe.current;return pe.current=null,C},[]);Rn.useEffect(()=>{h||(pe.current=null);},[h]);let[fe,ge]=Rn.useState(null),Z=Rn.useRef(null),Oe=Rn.useRef(null),we=Rn.useRef(false),ye=Rn.useCallback(()=>{let C=Z.current;Z.current=null,we.current=false,C?.stop(),ge(null),R(true);},[]),$e=Rn.useCallback(()=>{let C=Z.current;C&&(ge({phase:"grabbing"}),(async()=>{try{let O=await C.grab();if(Z.current!==C)return;Oe.current=O,Z.current=null,we.current=!1,C.stop(),ge(null),R(!0);}catch{if(Z.current!==C)return;Z.current=null,we.current=false,C.stop(),ge(null),sonner.toast.error("Could not capture the screen. Please try again."),R(true);}})());},[]),Ke=Rn.useCallback(async()=>{if(we.current)return;let C;try{C=await kt({...u});}catch{return}Z.current=C,we.current=true,C.onEnded(()=>ye()),ge({phase:"live"}),R(false);},[u,ye]),rt=Rn.useCallback(()=>{let C=Oe.current;return Oe.current=null,C},[]);Rn.useEffect(()=>()=>{Z.current?.stop(),Z.current=null;},[]);let Be=or(),ot=rr(i),He=sr(a?"":e,t??mr);tr(s??Ya(He.brand));let bt=p??He.shakeToOpen;cr(bt,oe,h);let vt=Rn.useMemo(()=>({client:k,user:n,isOpen:h,isSubmitting:Ce,error:be,open:oe,close:Re,openCapture:oe,closeCapture:Re,submit:nt,isNativeShell:Be,capture:u,initialCapture:_,initialCaptureError:J,isOpening:I,startVideoSession:ze,stopVideoSession:ve,cancelVideoSession:ie,recording:Y,consumePendingVideo:De,canRecordScreen:Ue,consumeRecordStartError:xe,startScreenCaptureSession:Ke,grabScreenCaptureFrame:$e,cancelScreenCaptureSession:ye,screenCapture:fe,consumePendingScreenshot:rt,isolateEvents:S,keyboardInset:x}),[k,n,h,Ce,be,oe,Re,nt,Be,u,_,J,ze,ve,ie,Y,De,Ue,xe,Ke,$e,ye,fe,rt,I,S,x]),he=ja({explicit:a,remote:He.trigger,remoteLoading:He.loading,floatingButton:o});return jsxRuntime.jsxs(Tt.Provider,{value:vt,children:[L,jsxRuntime.jsxs(ft,{onReset:Q,onError:C=>k.reportClientError({...C,context:{open:h,opening:I,screenCapturePhase:fe?.phase,recordingPhase:Y?.phase,initialCaptureMethod:_?.method,initialCapturePixelRatio:_?.pixelRatio,initialCaptureViewport:_?.viewport,hadInitialCaptureError:J!=null}}),children:[he?.kind==="floating"?jsxRuntime.jsx(Yn,{config:er(he),portalTarget:l,hidden:ot||M||I||Y!=null||fe!=null,onPointerDown:U,onClick:C=>oe(C),isolateEvents:S,keyboardInset:x}):null,he?.kind==="notch"?jsxRuntime.jsx(Jn,{config:Qn(he),portalTarget:l,hidden:ot||M||I||Y!=null||fe!=null,onPointerDown:U,onClick:C=>oe(C),isolateEvents:S}):null,he?.kind==="inline"?jsxRuntime.jsx(Gn,{mount:he.mount,label:he.label??"Feedback",icon:he.icon,onPointerDown:U,onClick:C=>oe(C),isolateEvents:S}):null,fe?jsxRuntime.jsx(_n,{state:fe,portalTarget:l,onCapture:$e,onCancel:ye}):null,Y?jsxRuntime.jsx(Hn,{state:Y,portalTarget:l,onStop:ve,onCancel:ie}):null,jsxRuntime.jsx(_t,{})]},W),jsxRuntime.jsx(qa,{})]})}function qa(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function ja(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Ya(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Ga({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=Ge(),s=["lumen-btn",e==="default"?"lumen-btn-primary":null,e==="ghost"?"lumen-btn-ghost":null,e==="outline"?"lumen-btn-outline":null,t?"lumen-btn-floating":null,n].filter(Boolean).join(" ");return jsxRuntime.jsx("button",{type:"button",className:s,"data-lumen-trigger":"",onClick:l=>{o?.(l),l.defaultPrevented||i(l.nativeEvent);},...a,children:r})}
|
|
5
|
+
exports.CaptureModal=_t;exports.FeedbackButton=Ga;exports.LUMEN_KEYBOARD_CSS_VAR=Mt;exports.LUMEN_KEYBOARD_EVENT=Ye;exports.LUMEN_SHAKE_MESSAGE=ct;exports.LumenProvider=Wa;exports.createNativeCaptureProvider=lo;exports.isLumenEventTarget=ro;exports.isolateLumenEvents=oo;exports.readLumenKeyboardInset=Lt;exports.setLumenKeyboardInset=vo;exports.useKeyboardInset=Xe;exports.useLumen=Ge;//# sourceMappingURL=index.cjs.map
|
|
5
6
|
//# sourceMappingURL=index.cjs.map
|