@lumen-stack/react 0.14.0 → 0.15.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- 'use strict';var _n=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 _n__namespace=/*#__PURE__*/_interopNamespace(_n);var O=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},on=class extends O{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},an=class extends O{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},pt=class extends O{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},Vr="https://shakebugs.vercel.app",zr="/api/v1/sdk/submit",$r="/api/v1/sdk/error",Wr="0.13.2",Kr=5,qr=new Set([502,503,504]),gn=class{apiKey;apiUrl;user;amplitude;#e=new Set;#t=0;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new O("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??Vr).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${zr}`,r=this.#n(e),o=null;for(let a=0;a<3;a++){a>0&&await Yr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof on||i instanceof an||i instanceof O&&typeof i.status=="number"&&!qr.has(i.status))throw i}}throw o instanceof Error?o:new pt("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Kr)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 u=new URL(window.location.href);a=u.origin+u.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:Wr,context:e.context};fetch(`${this.apiUrl}${$r}`,{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.priority&&t.append("priority",e.priority),e.source&&t.append("source",e.source),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,jr(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:u}=n;i&&a.upload.addEventListener("progress",c=>{c.lengthComputable&&c.total>0&&i(Math.min(1,c.loaded/c.total));});let d=()=>{a.abort(),o(new pt("Submit aborted."));};if(u){if(u.aborted){o(new pt("Submit aborted."));return}u.addEventListener("abort",d,{once:true});}a.addEventListener("load",()=>{if(u&&u.removeEventListener("abort",d),a.status===403){o(new on);return}if(a.status===429){let c=Number(a.getResponseHeader("Retry-After"))||60;o(new an(c));return}if(a.status<200||a.status>=300){o(new O(Gr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let c=JSON.parse(a.responseText);r(c);}catch{o(new O("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{u&&u.removeEventListener("abort",d),o(new pt("Network error during submit."));}),a.send(t);})}};function jr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Yr(e){return new Promise(t=>setTimeout(t,e))}function Gr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var vn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function wn(e=vn){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 Zr=2,Xr=1.5,Jr=820,Qr=12,Je=8*1024*1024;async function bt(e={}){At();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return io(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 O("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return cn(e);if(t==="dom")return ln(e);if(t==="custom")throw new O("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await ln(e)}catch(n){if(kn()){let r=await cn(e);return r.warnings=et(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function Qe(e,t=[]){At();let n=gt();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:et(t)}}var sn=Promise.resolve();function ln(e){let t=sn.then(()=>un(e),()=>un(e));return sn=t.catch(()=>{}),t}async function un(e){let t=await ao(),n=e.target??document.documentElement,r=gt(),o=lo(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),u=window.scrollY+(a?.offsetTop??0),d=uo(e,r.width,r.height),c=so(n);!e.provider&&oo()&&c.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 m=no(n);await Rn(e.awaitAnimationsMs??po),await mo();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:u,scale:d,ignoreElements:v=>v instanceof HTMLElement&&(v.dataset.lumenCaptureIgnore==="true"||!!v.closest("[data-lumen-capture-ignore='true']")),onclone:(v,y)=>{ro(y,m),eo(v);}}),C={blob:await Cn(p,c),method:"web-dom",platform:"web",viewport:r,pixelRatio:d,warnings:et(c)};return C.warnings.length>0&&e.onWarning?.(C.warnings),C}var yn=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function eo(e){for(let t of Array.from(e.querySelectorAll(yn))){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 to="[data-lumen-root], [data-lumen-capture-ignore='true']";function En(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(to))}function no(e){return En(e).map(t=>{if(t.matches(yn))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 ro(e,t){let n=En(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 oo(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function ao(){let{default:e}=await import('html2canvas-pro');return e}async function Nt(e={}){if(At(),!kn())throw new O("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 fo(n);}catch(i){for(let u of t.getTracks())u.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(u=>u());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let u=i?.conceal??true,d=u?wn():()=>{};try{u&&await ho(r,3,400);let c=document.createElement("canvas");c.width=r.videoWidth,c.height=r.videoHeight;let m=c.getContext("2d");if(!m)throw new O("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");m.drawImage(r,0,0,c.width,c.height);let p=gt(),C=["Browser screen capture uses the window or tab selected by the user."],v={blob:await Cn(c,C),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?c.width/p.width:void 0,warnings:et(C)};return e.onWarning?.(v.warnings),v}finally{d();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function cn(e){let t=await Nt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function io(e,t){let n=gt(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:et(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function so(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 Cn(e,t){let n=await dn(e,"image/png",.92);if(n.size<=Je)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>Je&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(Je/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 u=i.getContext("2d");if(!u)return n;u.drawImage(r,0,0,i.width,i.height),r=i;for(let d of [.86,.74,.62,.5])if(n=await dn(r,"image/jpeg",d),n.size<=Je)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>Je&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function dn(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new O("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function gt(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function lo(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function uo(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??Zr;co()&&(o=Math.min(o,Xr));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(Qr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function co(){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<=Jr}function mo(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var po=400;async function Rn(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 kn(){return !!navigator.mediaDevices?.getDisplayMedia}async function fo(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new O("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 O("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function ho(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 u=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(u);};r(u),setTimeout(i,n);});}function At(){if(typeof window>"u"||typeof document>"u")throw new O("Screenshot capture can only run in the browser.","INVALID_ENV")}function et(e){return Array.from(new Set(e.filter(Boolean)))}var Sn=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,bo=[/-----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 go(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 Mt(e){let t=e;for(let n of bo)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:Sn.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=>go(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 xn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])Sn.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Mt(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Mt(e)}}function Mn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return xn(e)}}var mn=200,pn=4096,Pn=[],ft=[],fn=false,Pt=null;function Tn(e={}){fn||typeof window>"u"||(fn=true,Pt=e.ignoreUrlPrefix??null,Eo(),Co(),Ro());}function vo(){return {consoleLog:Pn.slice(),networkLog:ft.slice()}}function ht(e,t){e.push(t),e.length>mn&&e.splice(0,e.length-mn);}function wo(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,yo));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>pn?n.slice(0,pn)+"\u2026[truncated]":n}function yo(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Eo(){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{ht(Pn,{level:n,ts:Date.now(),message:Mt(wo(o))});}catch{}r(...o);});}}function Ln(e){return Pt?e.startsWith(Pt):false}function Co(){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(Ln(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ht(ft,{type:"fetch",method:o,url:Tt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ht(ft,{type:"fetch",method:o,url:Tt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Ro(){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&&!Ln(o.url)){o.t=performance.now();let a=()=>{try{ht(ft,{type:"xhr",method:o.method,url:Tt(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 ko(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Tt(e){return ko(xn(e))}function Nn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:hn(e),consoleLog:[],networkLog:[]};let t=vo();return {url:Mn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:hn(e),device:So(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function So(){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?Mn(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 hn(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var xo="[data-lumen-root]",Mo="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function Po(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(Lt(n))return true;return Lt(e.target)}var bn=["pointerdown","mousedown","touchstart","click"];function To(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of bn)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of bn)e.removeEventListener(n,t);}}function Lt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(Mo)?true:!!e.closest(xo):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?Lt(e.host):false:false}var vt="lumen:shake",Lo=8e3,No=50,Ao=400;function Io(e={}){return async function(){if(typeof window>"u")throw new O("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=Oo(),n=e.send??Do,r=e.timeoutMs??Lo,o=e.captureSettleMs??No,a=e.awaitAnimationsMs??Ao,i=Uo(),u=wn(e.concealSelector===void 0?vn:e.concealSelector);try{await Ho(o,a);let d=await new Promise((p,C)=>{let v=window.setTimeout(()=>{t.pending.delete(i),C(new O("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:y=>{window.clearTimeout(v),p(y);},reject:y=>{window.clearTimeout(v),C(y);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(v),C(new O("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(d.error||!d.dataUrl)throw new O(d.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let c=Vo(d.dataUrl),m=e.platform??Fo();return {blob:c,method:m==="android"?"android-native":"ios-native",platform:m,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:d.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{u();}}}function Do(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new O("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function Oo(){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=Bo(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 Bo(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 Ho(e,t){await Rn(t),await _o(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function _o(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function Fo(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function Uo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function Vo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new O("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 u=0;u<a.length;u++)i[u]=a.charCodeAt(u);return new Blob([i],{type:n})}var tt="lumen:keyboardchange",It="--lumen-keyboard-inset";function zo(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(It,`${t}px`),window.dispatchEvent(new Event(tt));}function Dt(){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(It).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function An(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new O("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new O("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(v=>MediaRecorder.isTypeSupported(v))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((v,y)=>{c=v,m=y;});p.catch(()=>{}),r.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&o.push(v.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let P of t.getTracks())P.stop();if(d)return;if(d=true,u){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let v=performance.now()-a,y=r.mimeType||n||"audio/webm",k=new Blob(o,{type:y});c({blob:k,durationMs:v,mimeType:y});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function C(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){u=true,C(),i!==null&&window.clearTimeout(i),i=null;for(let v of t.getTracks())v.stop();},stop(){return C(),p}}}async function In(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new O("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new O("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(y=>MediaRecorder.isTypeSupported(y))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((y,k)=>{c=y,m=k;});p.catch(()=>{});function C(){i!==null&&(window.clearTimeout(i),i=null);for(let y of t.getTracks())y.stop();}r.addEventListener("dataavailable",y=>{y.data&&y.data.size>0&&o.push(y.data);}),r.addEventListener("stop",()=>{if(u)return;if(u=true,C(),d){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let y=r.mimeType||n||"video/webm";c({blob:new Blob(o,{type:y}),durationMs:performance.now()-a,mimeType:y});});function v(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(v,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",v),{stream:t,result:p,stop:v,cancel(){d=true,r.state!=="inactive"?r.stop():u||(u=true,C(),m(new O("Recording cancelled.","RECORDER_STOPPED")));}}}var Ot=_n.createContext(null);function nt(){let e=_n.useContext(Ot);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var Dn=100;function On(){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 rt={open:false,inset:0};function jo(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:rt}if(e.vvHeight==null||!e.coarse||!e.editable)return rt;let n=e.vvBaseline-e.vvHeight;return n>Dn?{open:true,inset:Math.round(n)}:rt}function ot(e,t){let[n,r]=_n.useState(rt),o=_n.useRef(0),a=_n.useRef(t);return a.current=t,_n.useEffect(()=>{if(!e){r(rt);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,u=()=>{let p=On(),C=a.current,v=Dt(),y=window.visualViewport??null;y&&C==null&&v==null&&!p&&(o.current=y.height),r(jo({editable:p,override:C,injected:v,vvBaseline:o.current,vvHeight:y?y.height:null,coarse:i}));},d=0,c=()=>{d||(d=window.requestAnimationFrame(()=>{d=0,u();}));},m=window.visualViewport;return m&&(o.current=m.height),c(),m?.addEventListener("resize",c),m?.addEventListener("scroll",c),document.addEventListener("focusin",c),document.addEventListener("focusout",c),window.addEventListener(tt,c),()=>{d&&window.cancelAnimationFrame(d),m?.removeEventListener("resize",c),m?.removeEventListener("scroll",c),document.removeEventListener("focusin",c),document.removeEventListener("focusout",c),window.removeEventListener(tt,c);}},[e]),n}var Ht='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Hn(e,t=1){return Math.max(0,Math.min(t,e))}var Fn=_n__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},u){let d=_n.useRef(null),c=_n.useRef(null),m=_n.useRef(null),[p,C]=_n.useState(null),[v,y]=_n.useState(false),[k,P]=_n.useState(""),[S,T]=_n.useState([]),b=_n.useRef(null),E=_n.useRef(false),B=_n.useRef(0),N=_n.useRef(false),[F,A]=_n.useState([]),J=_n.useRef(0),I=_n.useRef([]),$=_n.useRef([]),j=_n.useRef(S);j.current=S;let W=_n.useRef(F);W.current=F;let se=_n.useRef(null),he=_n.useRef(i);he.current=i;let V=_n.useCallback(()=>{he.current?.({canUndo:I.current.length>0,canRedo:$.current.length>0});},[]),He=_n.useCallback((h,w)=>{A(x=>x.map(M=>M.id===h?{...M,text:w}:M));},[]),_e=_n.useCallback(h=>{A(x=>x.filter(M=>M.id!==h));let w=I.current.lastIndexOf("comment");w>=0&&I.current.splice(w,1),$.current=[],V();},[V]);_n.useEffect(()=>{let h=se.current;if(h==null)return;se.current=null,m.current?.querySelector(`[data-bubble-id="${h}"] .lumen-bubble-text`)?.focus();},[F]),_n.useEffect(()=>{T([]),A([]),y(false),I.current=[],$.current=[],V();},[t,V]),_n.useEffect(()=>{let h=false,w=null;return (async()=>{try{let x=await createImageBitmap(t);if(h){x.close?.();return}w=x,C(x);}catch{}})(),()=>{h=true,w?.close?.();}},[t]),_n.useEffect(()=>{if(!p)return;let h=d.current,w=c.current;if(!(!h||!w)){w.width=p.width,w.height=p.height;try{h.width=p.width,h.height=p.height;let x=h.getContext("2d");if(!x)return;x.imageSmoothingEnabled=!1,x.drawImage(p,0,0),y(!1);}catch{y(true);}}},[p]),_n.useEffect(()=>{if(!v){P("");return}let h=URL.createObjectURL(t);return P(h),()=>{URL.revokeObjectURL(h);}},[v,t]),_n.useEffect(()=>{let h=c.current;if(h)try{wt(h,S,b.current);}catch{}},[S]),_n.useImperativeHandle(u,()=>({hasAnnotations:()=>S.length>0||F.some(h=>h.text.trim().length>0),reset:()=>{T([]),A([]),j.current=[],W.current=[],I.current=[],$.current=[],V();},undo:()=>{let h=I.current[I.current.length-1];if(h){if(h==="comment"){let w=W.current,x=w[w.length-1];if(!x)return;let M=w.slice(0,-1);W.current=M,$.current.push({type:"comment",item:x}),A(M);}else {let w=j.current,x=w[w.length-1];if(!x)return;let M=w.slice(0,-1);j.current=M,$.current.push({type:"anno",item:x}),T(M);}I.current.pop(),V();}},redo:()=>{let h=$.current[$.current.length-1];if(h){if(h.type==="comment"){let w=[...W.current,h.item];W.current=w,A(w);}else {let w=[...j.current,h.item];j.current=w,T(w);}I.current.push(h.type),$.current.pop(),V();}},async flatten(){let h=b.current,w=h?[...S,h]:S,x=F.filter(M=>M.text.trim().length>0);if(w.length===0&&x.length===0||!p||v)return t;try{let M=document.createElement("canvas");M.width=p.width,M.height=p.height;let _=M.getContext("2d");if(!_)return t;_.imageSmoothingEnabled=!1,_.drawImage(p,0,0);for(let re of w)_t(_,re);let K=d.current?.clientWidth||p.width,ne=p.width/Math.max(K,1);for(let re of x)Jo(_,re,p.width,p.height,ne);return await new Promise(re=>{M.toBlob(Ce=>{re(Ce??t);},"image/jpeg",.85);})}catch{return t}}}),[S,F,p,t,v,V]);function be(h){let w=c.current;if(!w)return {x:0,y:0};let x=w.getBoundingClientRect(),M=w.width/Math.max(x.width,1),_=w.height/Math.max(x.height,1);return {x:(h.clientX-x.left)*M,y:(h.clientY-x.top)*_}}function xe(){N.current||(N.current=true,requestAnimationFrame(()=>{N.current=false;let h=c.current;h&&wt(h,j.current,b.current);}));}function ye(h){if(h.button!==void 0&&h.button!==0)return;if(n==="comment"){let x=c.current;if(!x)return;let M=x.getBoundingClientRect(),_=Hn((h.clientX-M.left)/Math.max(M.width,1),.72),K=Hn((h.clientY-M.top)/Math.max(M.height,1),.8),ne=++J.current;A(re=>[...re,{id:ne,x:_,y:K,text:"",color:r}]),I.current.push("comment"),$.current=[],se.current=ne,V();return}try{h.currentTarget.setPointerCapture(h.pointerId);}catch{}E.current=true,a?.(true);let w=be(h);n==="arrow"?b.current={kind:"arrow",from:w,to:w,color:r,width:o}:n==="rect"?b.current={kind:"rect",from:w,to:w,color:r,width:o}:b.current={kind:"freehand",points:[w],color:r,width:o},B.current=performance.now(),xe();}function oe(h){if(!E.current||!b.current)return;let w=be(h),x=b.current;if(x.kind==="arrow"||x.kind==="rect")x.to=w;else {let M=x.points[x.points.length-1],_=M?(M.x-w.x)**2+(M.y-w.y)**2:1/0,K=performance.now(),ne=K-B.current;(_>16||ne>16)&&(x.points.push(w),B.current=K);}xe();}function Ee(){if(!E.current)return;E.current=false,a?.(false);let h=b.current;if(b.current=null,!!h){if(h.kind==="arrow"||h.kind==="rect"){let w=h.to.x-h.from.x,x=h.to.y-h.from.y;if(w*w+x*x<16){let M=c.current;M&&wt(M,j.current,null);return}}else if(h.points.length<2){let w=c.current;w&&wt(w,j.current,null);return}T(w=>[...w,h].slice(-50)),I.current.push("anno"),$.current=[],V();}}return jsxRuntime.jsxs("div",{ref:m,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:d}),v&&k?jsxRuntime.jsx("img",{src:k,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsxRuntime.jsx("canvas",{ref:c,className:"lumen-annotate-overlay",onPointerDown:ye,onPointerMove:oe,onPointerUp:Ee,onPointerCancel:Ee}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:F.map(h=>jsxRuntime.jsx(Zo,{comment:h,onChange:He,onRemove:_e},h.id))})]})});function Zo({comment:e,onChange:t,onRemove:n}){let r=_n.useRef(null);return _n.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 wt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)_t(r,o);n&&_t(r,n);}}function _t(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")Xo(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 Xo(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],u=(a.x+i.x)/2,d=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,u,d);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function Jo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,u=14*o,d=10*o,c=12*o,m=u*1.35,p=d*1.7,C=t.x*n,v=t.y*r,y=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${u}px ${Ht}`,e.textBaseline="top";let k=Qo(e,a,y-i*2),P=k.reduce((N,F)=>Math.max(N,e.measureText(F).width),0),S=Math.min(y,Math.max(P,56*o)+i*2),T=i*2+p+k.length*m;ea(e,C,v,S,T,c),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let b=C+18*o,E=v+T;e.beginPath(),e.moveTo(b,E-o),e.lineTo(b+13*o,E-o),e.lineTo(b+4*o,E+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${d}px ${Ht}`,e.fillText("COMMENT",C+i,v+i),e.fillStyle="#111318",e.font=`500 ${u}px ${Ht}`;let B=v+i+p;for(let N of k)e.fillText(N,C+i,B),B+=m;e.restore();}function Qo(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let u=a?`${a} ${i}`:i;a&&e.measureText(u).width>n?(o.push(a),a=i):a=u;}return a&&o.push(a),o.length?o:[t]}function ea(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 ee({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 ta(e){return jsxRuntime.jsxs(ee,{...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 na(e){return jsxRuntime.jsxs(ee,{...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 Ft(e){return jsxRuntime.jsxs(ee,{...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 Vn(e){return jsxRuntime.jsx(ee,{...e,children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-8.5 8.5 9.5 9.5 0 0 1-3.5-.7L3 21l1.7-5.5A8.38 8.38 0 0 1 4 11.5 8.5 8.5 0 0 1 12.5 3 8.38 8.38 0 0 1 21 11.5Z"})})}function zn(e){return jsxRuntime.jsxs(ee,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19 19 5"}),jsxRuntime.jsx("path",{d:"M11 5h8v8"})]})}function $n(e){return jsxRuntime.jsx(ee,{...e,children:jsxRuntime.jsx("rect",{x:"4",y:"6",width:"16",height:"12",rx:"2"})})}function Ut(e){return jsxRuntime.jsxs(ee,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19l1.5-5L16 4.5 19.5 8 10 17.5 5 19z"}),jsxRuntime.jsx("path",{d:"M14 6.5l3.5 3.5"})]})}function Wn(e){return jsxRuntime.jsxs(ee,{...e,children:[jsxRuntime.jsx("path",{d:"M9 8 4 13l5 5"}),jsxRuntime.jsx("path",{d:"M4 13h11a5 5 0 0 1 0 10h-1"})]})}function Vt(e){return jsxRuntime.jsxs(ee,{...e,children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),jsxRuntime.jsx("path",{d:"M21 4v4h-4"})]})}function Kn(e){return jsxRuntime.jsxs(ee,{...e,children:[jsxRuntime.jsx("path",{d:"M15 8 20 13l-5 5"}),jsxRuntime.jsx("path",{d:"M20 13H9a5 5 0 0 0 0 10h1"})]})}function qn(e){return jsxRuntime.jsxs(ee,{...e,children:[jsxRuntime.jsx("path",{d:"M4 7h16"}),jsxRuntime.jsx("path",{d:"M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"}),jsxRuntime.jsx("path",{d:"M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"})]})}function jn(e){return jsxRuntime.jsx(ee,{...e,strokeWidth:2.2,children:jsxRuntime.jsx("path",{d:"M15 6l-6 6 6 6"})})}function Yn(e){return jsxRuntime.jsx(ee,{...e,strokeWidth:1.9,children:jsxRuntime.jsx("path",{d:"M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z"})})}function it(e){return jsxRuntime.jsxs(ee,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function zt(e){return jsxRuntime.jsxs(ee,{...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 yt={shot:ta,video:na,upload:Ft};function Gn(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 ra(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 oa=4e3;async function $t(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((d,c)=>{if(n.readyState>=2)return d();n.addEventListener("loadeddata",()=>d(),{once:true}),n.addEventListener("error",()=>c(new Error("video decode failed")),{once:true});}),await ra(n,Math.min(.1,(n.duration||0)/2));let i=await Gn(n),u=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:u}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),oa);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Wt(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 Gn(t)}catch{return null}finally{t.srcObject=null;}}async function Kt(){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 qt=60,aa=25*1024*1024,Zn=[{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)"}],Xn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],ia=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],sa=[{value:"",label:"No priority"},{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],la=[{value:"web",label:"Web"},{value:"ios-web",label:"iOS web"},{value:"android-web",label:"Android web"},{value:"ios-native",label:"iOS native"},{value:"android-native",label:"Android native"}];function ua(e){if(e.platform==="ios")return "ios-native";if(e.platform==="android")return "android-native";if(e.platform==="custom")return "custom";let t=typeof navigator<"u"&&navigator.userAgent||"";return /android/i.test(t)?"android-web":/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&typeof document<"u"&&"ontouchend"in document?"ios-web":"web"}function ca({value:e}){return e==="urgent"?jsxRuntime.jsx("span",{className:"lumen-pri-ic lumen-pri-urgent","aria-hidden":"true",children:"!"}):jsxRuntime.jsxs("span",{className:"lumen-pri-ic lumen-pri-bars","data-level":e==="high"?3:e==="medium"?2:1,"aria-hidden":"true",children:[jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{})]})}var jt=[{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 Yt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:u,consumePendingVideo:d,canRecordScreen:c,consumeRecordStartError:m,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:v,keyboardInset:y}=nt(),[k,P]=_n.useState(1),[S,T]=_n.useState(null),[b,E]=_n.useState({kind:"idle"}),[B,N]=_n.useState(false),[F,A]=_n.useState(0),[J,I]=_n.useState("arrow"),[$,j]=_n.useState(Zn[0].value),[W,se]=_n.useState(Xn[1].value),[he,V]=_n.useState(""),[He,_e]=_n.useState("bug"),[be,xe]=_n.useState(""),[ye,oe]=_n.useState(""),[Ee,h]=_n.useState(false),[w,x]=_n.useState(false),[M,_]=_n.useState(false),[K,ne]=_n.useState(false),[re,Ce]=_n.useState(r?.email??""),[z,ae]=_n.useState(null),[q,Me]=_n.useState(null),[Fe,Re]=_n.useState(0),[ke,Se]=_n.useState(null),[Ze,Pe]=_n.useState(null),[lt,ut]=_n.useState(false),[le,Te]=_n.useState({canUndo:false,canRedo:false}),Y=_n.useRef(null),We=_n.useRef(null),ge=_n.useRef(null),Le=_n.useRef(null),Ke=_n.useRef(null),Ne=ot(t,y),ve=_n.useRef(false),qe=_n.useRef(false);_n.useEffect(()=>{t||(qe.current=false);},[t]),_n.useEffect(()=>{if(!t)return;if(qe.current){ve.current=false;return}qe.current=true,ve.current=false,P(1),T(null),V(""),Me(null),Re(0),Se(null),N(false),A(0),oe(""),Pe(null),Te({canUndo:false,canRedo:false});let s=C();if(s){T("shot"),me(s),E({kind:"ready",capture:s});return}let g=d();if(g)T("video"),Se({blob:g.blob,durationMs:g.durationMs}),g.blob.size>aa&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),g.poster?E({kind:"ready",capture:Qe(g.poster,["Screen recording; preview is the first frame."])}):(E({kind:"capturing"}),(async()=>{let D=null;if(g.deriveBlobPoster)try{D=(await $t(g.blob)).poster;}catch{D=null;}D=D??await Kt(),!ve.current&&E(D?{kind:"ready",capture:Qe(D,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let D=m();D?(T("video"),Pe(D),E({kind:"idle"})):a?(T("shot"),E({kind:"ready",capture:a})):o?.mode==="manual"?E({kind:"manual"}):o?.provider&&!i?(T("shot"),Ue(o.mode??"auto")):E({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ve.current=true;}},[t,o,a,i]),_n.useEffect(()=>{if(!t)return;Ke.current=document.activeElement??null;let s=document.documentElement,g=s.style.overflow,D=s.style.paddingRight,ie=window.innerWidth-s.clientWidth;s.style.overflow="hidden",ie>0&&(s.style.paddingRight=`${ie}px`);let ue=false,we=()=>{if(!ue){ue=true,s.style.overflow=g,s.style.paddingRight=D;try{Ke.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",we),()=>{window.removeEventListener("pagehide",we),we();}},[t]),_n.useEffect(()=>{if(!t)return;function s(g){if(g.key==="Escape"){g.preventDefault(),n();return}if(g.key!=="Tab")return;let D=ge.current;if(!D)return;let ie=ya(D);if(ie.length===0)return;let ue=ie[0],we=ie[ie.length-1],xt=document.activeElement;g.shiftKey&&(xt===ue||!D.contains(xt))?(g.preventDefault(),we.focus()):!g.shiftKey&&xt===we&&(g.preventDefault(),ue.focus());}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),_n.useEffect(()=>{if(!t||!v)return;let s=Le.current;if(!s)return;let g=D=>{D.target===s&&D.stopPropagation();};return s.addEventListener("pointerdown",g),s.addEventListener("click",g),s.addEventListener("touchstart",g,{passive:true}),()=>{s.removeEventListener("pointerdown",g),s.removeEventListener("click",g),s.removeEventListener("touchstart",g);}},[t,v]),_n.useEffect(()=>{if(!t||!Ne.open)return;let s=ge.current,g=document.activeElement;if(s&&g&&s.contains(g))try{g.scrollIntoView({block:"center"});}catch{}},[t,Ne.open,Ne.inset]),_n.useEffect(()=>{if(!t||b.kind!=="manual")return;function s(g){let ue=Array.from(g.clipboardData?.items??[]).find(we=>we.type.startsWith("image/"))?.getAsFile();ue&&(g.preventDefault(),Xe(ue));}return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[t,b.kind]),_n.useEffect(()=>{if(!z)return;let s=Date.now(),g=window.setInterval(()=>{let D=Math.floor((Date.now()-s)/1e3);Re(D),D>=qt&&U();},250);return ()=>window.clearInterval(g)},[z]);let Ae=_n.useRef(null);if(Ae.current=z,_n.useEffect(()=>{t||Ae.current&&(Ae.current.cancel(),Ae.current=null,ae(null),Re(0));},[t]),_n.useEffect(()=>()=>{Ae.current?.cancel();},[]),!t)return null;async function Ue(s){ve.current=false,E({kind:"capturing"});try{let g=await bt({...o,mode:s,target:o?.target??document.documentElement});return ve.current?!1:(me(g),E({kind:"ready",capture:g}),!0)}catch(g){return ve.current||E({kind:"manual",error:g instanceof Error?g.message:"Automatic screenshot capture was unavailable."}),false}}async function Ie(s){T(s),Pe(null),s!=="video"&&St(),s==="shot"?await Ue(o?.mode??"auto"):s==="video"?(Se(null),E({kind:"idle"})):(E({kind:"manual"}),We.current?.click());}async function Xe(s){if(s.type.startsWith("image/")){St();let g=Qe(s,["Manual image upload used."]);E({kind:"ready",capture:g});return}if(s.type.startsWith("video/")){E({kind:"capturing"});try{let{poster:g,durationMs:D}=await $t(s),ie=g??await Kt();if(!ie){E({kind:"manual",error:"Could not read that video."});return}let ue=Qe(ie,["Uploaded video; preview is the first frame."]);Se({blob:s,durationMs:D}),E({kind:"ready",capture:ue});}catch{E({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function me(s){s.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function R(){try{let s=await An(qt);ae(s);}catch(s){sonner.toast.error(s instanceof Error?s.message:"Microphone unavailable");}}async function U(){if(z)try{let s=await z.stop();Me({blob:s.blob,durationMs:s.durationMs});}catch(s){sonner.toast.error(s instanceof Error?s.message:"Could not stop recording");}finally{ae(null);}}function G(){z?.cancel(),ae(null),Me(null),Re(0);}function ct(s){let g=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!z&&!q?jsxRuntime.jsxs("button",{type:"button",onClick:R,className:s==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(zt,{}),"Record voice note"]}):null,z?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(ha,{stream:z.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[Fe,"s / ",qt,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:U,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:G,className:"lumen-btn-ghost",children:"Cancel"})]}):null,q&&!z?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ga,{blob:q.blob,durationMs:q.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Me(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return s==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[g,!z&&!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)"}),g]})}async function Or(){Pe(null);try{await u();}catch(s){sonner.toast.error(s instanceof Error?s.message:"Screen capture unavailable");}}function St(){Se(null);}let Br=b.kind==="ready";async function Jt(){z&&await U(),k===1?(b.kind==="ready"&&!ye&&oe(ua(b.capture)),P(2)):await en();}function Qt(){k>1&&P(s=>s-1);}async function en(){if(b.kind!=="ready")return;let s=he.trim(),{capture:g}=b;N(true),A(0);try{let ie=await Y.current?.flatten()??g.blob,ue=await e.submit({rawText:s.length>0?s:void 0,category:He,priority:be||void 0,source:ye||void 0,submitterEmail:re.trim()||void 0,screenshot:ie,audio:q?.blob,audioDurationMs:q?.durationMs,video:ke?.blob,videoDurationMs:ke?.durationMs,context:Nn(g)},{onUploadProgress:we=>A(Math.min(.95,we))});A(1),sonner.toast.success("Feedback sent \u2014 thank you."),ue.id,n();}catch(D){sonner.toast.error(D instanceof Error?D.message:"Could not submit feedback"),N(false);}}function Hr(s){s.target===s.currentTarget&&!B&&n();}let je=Math.round(F*100),dt=S==="video",_r=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,tn=S==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&_r,nn=k===1&&!Br||B,Fr=k<3?"Next":B?je<95?`Uploading ${je}%\u2026`:"Almost done\u2026":"Send feedback",mt=k===1,rn=k===2&&b.kind==="ready",Ur=mt||rn;return jsxRuntime.jsx("div",{ref:Le,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Ne.inset?{"--lumen-keyboard-inset":`${Ne.inset}px`}:void 0,onMouseDown:Hr,children:jsxRuntime.jsxs("div",{ref:ge,className:"lumen-modal","data-lumen-drawing":lt?"true":void 0,"data-lumen-fs":Ur?"true":void 0,"data-lumen-review":rn?"true":void 0,"data-lumen-sheet":mt&&w?"down":void 0,children:[jsxRuntime.jsx(fa,{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(da,{step:k}),jsxRuntime.jsx("input",{ref:We,type:"file",accept:"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime",style:{display:"none"},onChange:s=>{let g=s.currentTarget.files?.[0];g&&Xe(g),s.currentTarget.value="";}}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[k===1||k===2?jsxRuntime.jsx("div",{className:"lumen-pane",children:S===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-top",children:jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})})}),jsxRuntime.jsxs("div",{className:"lumen-fs-center lumen-fs-picker",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-picker-head",children:[jsxRuntime.jsx("div",{className:"lumen-fs-picker-title",children:"How do you want to capture?"}),jsxRuntime.jsx("div",{className:"lumen-fs-picker-sub",children:"Pick a method to report this."})]}),jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(s.primary?" lumen-method-primary":""),onClick:()=>Ie(s.value),disabled:b.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(g,{})}),s.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]})]},s.value)})})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[b.kind!=="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsx("div",{className:"lumen-fs-pill",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>Ie(s.value),disabled:b.kind==="capturing",children:jsxRuntime.jsx(g,{})},s.value)})})})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-center",children:[S==="video"&&b.kind==="idle"?jsxRuntime.jsx(ma,{canRecord:c,onRecord:Or,onUpload:()=>Ie("upload"),error:Ze}):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:S==="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:S==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:S==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:s=>{let g=s.currentTarget.files?.[0];g&&Xe(g),s.currentTarget.value="";}})]})]}):null]})]}):null,b.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[k===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-fs-chip",onClick:()=>_(s=>!s),"aria-haspopup":"menu","aria-expanded":M,children:[jsxRuntime.jsx(Vt,{})," Recapture",jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},"aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),M?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-recap-overlay",onClick:()=>_(false)}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap-menu",role:"menu",children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),S&&Ie(S);},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(Vt,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Re-snap this view"}),jsxRuntime.jsx("small",{children:"Instant \xB7 masks sensitive fields"})]})]}),tn?jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),p();},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(it,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Capture exact pixels"}),jsxRuntime.jsx("small",{children:"Real screen \u2014 canvas, video & charts"})]})]}):null]})]}):null]})]}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsxs("div",{className:"lumen-fs-pill",role:"group","aria-label":"Tools and capture method",children:[dt?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn lumen-fs-pentog","data-on":!Ee,onClick:()=>h(s=>!s),"aria-label":"Toggle markup tools",title:"Toggle markup tools",children:jsxRuntime.jsx(Ut,{})}),jsxRuntime.jsx("span",{className:"lumen-fs-pill-sep"})]}),jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>Ie(s.value),children:jsxRuntime.jsx(g,{})},s.value)})]})})]}),!dt&&!Ee?jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(Et,{label:"Arrow",icon:jsxRuntime.jsx(zn,{}),active:J==="arrow",onClick:()=>I("arrow")}),jsxRuntime.jsx(Et,{label:"Box",icon:jsxRuntime.jsx($n,{}),active:J==="rect",onClick:()=>I("rect")}),jsxRuntime.jsx(Et,{label:"Draw",icon:jsxRuntime.jsx(Ut,{}),active:J==="freehand",onClick:()=>I("freehand")}),jsxRuntime.jsx(Et,{label:"Comment",icon:jsxRuntime.jsx(Vn,{}),active:J==="comment",onClick:()=>I("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsxs("div",{className:"lumen-fs-color",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-color-btn",style:{background:$},"aria-label":"Pick colour","aria-haspopup":"true","aria-expanded":K,onClick:()=>ne(s=>!s)}),K?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-color-overlay",onClick:()=>ne(false)}),jsxRuntime.jsx("div",{className:"lumen-fs-color-pop",role:"group","aria-label":"Colour",children:Zn.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:s.value},"aria-label":s.label,"aria-pressed":$===s.value,onClick:()=>{j(s.value),ne(false);}},s.value))})]}):null]}),mt?null:jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Xn.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":s.label,"aria-pressed":W===s.value,onClick:()=>se(s.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:s.dot,height:s.dot}})},s.value))}),mt?null:jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.undo(),disabled:!le.canUndo,"aria-label":"Undo",title:"Undo",children:jsxRuntime.jsx(Wn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.redo(),disabled:!le.canRedo,"aria-label":"Redo",title:"Redo",children:jsxRuntime.jsx(Kn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.reset(),disabled:!le.canUndo,"aria-label":"Clear",title:"Clear",children:jsxRuntime.jsx(qn,{})})]}):null]}):null,jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Fn,{ref:Y,screenshot:b.capture.blob,tool:J,color:$,strokeWidth:W,onDrawingChange:ut,onHistoryChange:Te})}),k===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>S&&Ie(S),children:dt?"\u21BB Re-record":"\u21BB Recapture"}),tn?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(it,{})," Capture exact screen"]}):null,dt?ke?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ke.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:b.capture.method==="web-display-media"?"Exact screen captured":`${Jn(S)} captured \xB7 switch method above anytime`})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-compose",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-grab",onClick:()=>x(s=>!s),"aria-label":w?"Expand sheet":"Minimize sheet"}),jsxRuntime.jsxs("div",{className:"lumen-fs-field",children:[jsxRuntime.jsx("input",{className:"lumen-input lumen-fs-desc",value:he,onChange:s=>V(s.target.value),placeholder:"Describe what's wrong \u2014 or use voice"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-mic",onClick:R,"aria-label":"Record voice note",children:jsxRuntime.jsx(zt,{})})]}),ct("capture"),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-fs-next",onClick:Jt,disabled:nn,children:"Next"})]})]}):null]}):null]})}):null,k===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-rv-pane",children:[jsxRuntime.jsx("div",{className:"lumen-rv-scrim","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"lumen-rv",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-head",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-back",onClick:Qt,children:[jsxRuntime.jsx(jn,{}),"Back"]}),jsxRuntime.jsx("span",{className:"lumen-rv-title",children:"Review & send"}),jsxRuntime.jsx("span",{className:"lumen-rv-spacer","aria-hidden":"true"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-rows",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Description"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 tap to edit"})]}),jsxRuntime.jsx("textarea",{className:"lumen-input lumen-rv-desc",value:he,onChange:s=>V(s.target.value),rows:2,placeholder:"Describe what's wrong\u2026"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Type"}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Type",children:ia.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":He===s.value,onClick:()=>_e(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Priority"}),jsxRuntime.jsx("div",{className:"lumen-rv-prio",role:"group","aria-label":"Priority",children:sa.filter(s=>s.value!=="").map(s=>jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-prio-opt","aria-pressed":be===s.value,onClick:()=>xe(be===s.value?"":s.value),children:[jsxRuntime.jsx(ca,{value:s.value}),s.label]},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Platform"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 auto-detected \u2014 change if wrong"})]}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Platform",children:la.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":ye===s.value,onClick:()=>oe(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-row",children:[jsxRuntime.jsx("span",{className:"lumen-rv-rk",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-rv-rv",children:[Jn(S),le.canUndo?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>P(1),children:"edit"})]})]}),ct("describe"),jsxRuntime.jsx("div",{className:"lumen-rv-attachrow",children:ke?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ke.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:St,children:"\xD7"})]}):jsxRuntime.jsxs("label",{className:"lumen-rv-attach",children:[jsxRuntime.jsx(Ft,{}),"Attach a video",jsxRuntime.jsx("input",{type:"file",accept:"video/mp4,video/webm,video/quicktime",onChange:s=>{let g=s.currentTarget.files?.[0];g&&Se({blob:g,durationMs:0}),s.currentTarget.value="";}})]})})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-rv-send",onClick:en,disabled:B,children:B?je<95?`Uploading ${je}%\u2026`:"Almost done\u2026":jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Yn,{}),"Send feedback"]})})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[B?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":je,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${je}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:k===1?n:Qt,className:"lumen-btn-ghost",disabled:B,children:k===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:Jt,className:"lumen-btn-primary",disabled:nn,children:Fr})]})]})]})})}function Jn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function da({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 ma({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:pa()?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 pa(){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 Et({label:e,active:t,onClick:n,icon:r}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,"aria-label":r?e:void 0,title:e,children:r??e})}function fa({onDismiss:e}){let t=_n.useRef(null),n=_n.useRef(0),r=_n.useRef(null);function o(u){u.currentTarget.setPointerCapture(u.pointerId),t.current=u.clientY,n.current=performance.now(),r.current=u.currentTarget.parentElement;}function a(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current);r.current.style.transform=`translateY(${d}px)`;}function i(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current),c=Math.max(1,performance.now()-n.current),m=d/c;r.current.style.transform="",r.current.style.transition="",t.current=null,(d>80||m>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function ha({stream:e}){let t=_n.useRef(null);return _n.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 u=window.AudioContext??window.webkitAudioContext;if(!u)return;let d=new u,c=d.createMediaStreamSource(e),m=d.createAnalyser();m.fftSize=1024,m.smoothingTimeConstant=.6,c.connect(m);let p=new Uint8Array(m.fftSize),C=18,v=3,y=3,k=Math.max(2,(o-v*(C-1))/C),P=Math.min(k/2,3),S=new Array(C).fill(0),T=0,b=false;function E(){if(b)return;m.getByteTimeDomainData(p);let B=Math.floor(p.length/C);i.clearRect(0,0,o,a),i.fillStyle=va("--lumen-danger")||"rgb(239,68,68)";for(let N=0;N<C;N++){let F=0;for(let W=0;W<B;W++){let se=Math.abs((p[N*B+W]??128)-128);se>F&&(F=se);}let A=Math.min(1,F/128*1.8),J=S[N]??0;S[N]=A>J?A:J+(A-J)*.35;let I=Math.max(y,S[N]*a),$=N*(k+v),j=(a-I)/2;ba(i,$,j,k,I,P),i.fill();}T=requestAnimationFrame(E);}return T=requestAnimationFrame(E),()=>{b=true,cancelAnimationFrame(T);try{c.disconnect();}catch{}d.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function ba(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 ga({blob:e,durationMs:t}){let[n,r]=_n.useState("");return _n.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 va(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var wa='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function ya(e){return Array.from(e.querySelectorAll(wa)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var Ct=class extends _n__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 rr({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=_n.useState(false);if(_n.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(Ca,{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 Ca({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=_n.useState(0);_n.useEffect(()=>{let u=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));u();let d=window.setInterval(u,250);return ()=>window.clearInterval(d)},[e,t]);let i=u=>`${Math.floor(u/60)}:${String(u%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 or({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=_n.useState(false);if(_n.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,u=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:[u?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(it,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:u?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:u,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:u,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Gt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function ar(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function ir(e){return e instanceof Error?e:new Error(String(e))}function sr(e,t,n){let r=false,o=false,a=false,i=null;function u(){o||(o=true,n.onCancelled());}function d(m){o||(o=true,n.onResult(m));}function c(m){o||(o=true,n.onError(m));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(m=>{if(i=m,r){try{m.cancel();}catch{}u();return}if(n.onActive(m),a){n.onProcessing();try{m.stop();}catch{}}Promise.resolve(m.result).then(p=>{r?u():d(p);}).catch(p=>{r||ar(p)?u():c(ir(p));});}).catch(m=>{r||ar(m)?u():c(ir(m));}),{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{}u();}}}}function lr(){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 u=document.elementsFromPoint(i,n);for(let d of u){if(o.has(d))continue;o.add(d);let c=window.getComputedStyle(d);if(c.position!=="fixed"&&c.position!=="sticky")continue;let m=d.getBoundingClientRect();m.bottom<t-8||m.bottom>t+8||m.width<e*.6||m.height>a&&(a=m.height);}}return a}function Zt(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 u of Array.from(i)){let d=u.getBoundingClientRect();if(d.height===0||d.width===0)continue;let c=0;switch(t){case "bottom":if(d.bottom<r-8)break;c=Math.max(0,r-d.top);break;case "top":if(d.top>8)break;c=Math.max(0,d.bottom);break;case "left":if(d.left>8)break;c=Math.max(0,d.right);break;case "right":if(d.right<n-8)break;c=Math.max(0,n-d.left);break}c>o&&(o=c);}}return o}function ur(e){let[t,n]=_n.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=_n.useRef(t),o=La(e.avoid),a=e.placement,i=e.offset.x,u=e.offset.y;return _n.useEffect(()=>{if(typeof window>"u")return;let d=0,c=false,m=()=>{if(d=0,c)return;let k=a[0]==="b"?"bottom":"top",P=a[1]==="r"?"right":"left",S=0,T=0;e.avoid==="auto"&&k==="bottom"?S=lr():Array.isArray(e.avoid)&&(S=Zt(e.avoid,k),T=Zt(e.avoid,P));let b={bottom:k==="bottom"?u+S:0,top:k==="top"?u+S:0,right:P==="right"?i+T:0,left:P==="left"?i+T:0},E=r.current;(b.bottom!==E.bottom||b.top!==E.top||b.right!==E.right||b.left!==E.left)&&(r.current=b,n(b));},p=()=>{d||(d=window.requestAnimationFrame(m));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let v=typeof MutationObserver<"u"?new MutationObserver(p):null;v?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let y=window.visualViewport;return y?.addEventListener("resize",p),y?.addEventListener("scroll",p),()=>{c=true,d&&window.cancelAnimationFrame(d),C?.disconnect(),v?.disconnect(),window.removeEventListener("resize",p),y?.removeEventListener("resize",p),y?.removeEventListener("scroll",p);}},[a,i,u,o]),t}function La(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var cr=["mousedown","touchstart"];function Ge(e){let t=_n.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=_n.useRef(e.onClick);n.current=e.onClick;let r=_n.useRef(e.isolate??true);r.current=e.isolate??true;let o=_n.useRef(null);return _n.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=c=>{r.current&&c.stopPropagation(),t.current?.(c);},u=c=>{r.current&&c.stopPropagation(),n.current(c);},d=c=>{r.current&&c.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",u);for(let c of cr)a.addEventListener(c,d,c==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",u);for(let c of cr)a.removeEventListener(c,d);};},[])}function fr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[u,d]=_n.useState(null),c=_n.useRef(null),m=ur(e),p=ot(e.keyboard!=="off",i),C=Ge({onPointerDown:r,onClick:o,isolate:a}),v=_n.useCallback(A=>{c.current=A,C(A);},[C]);_n.useEffect(()=>{typeof document>"u"||d(t??document.body);},[t]);let y=e.placement,k=y[0]==="b"?"bottom":"top",P=y[1]==="r"?"right":"left",S=k==="bottom",T=p.open&&S&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,b=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&S&&p.inset<=0);if(Oa(c,!n&&!b),!u)return null;let E=k==="bottom"?m.bottom:m.top,B=P==="right"?m.right:m.left,N=n||b,F={position:"fixed",[k]:e.safeArea?`calc(${E}px + env(safe-area-inset-${k}, 0px))`:`${E}px`,[P]:e.safeArea?`calc(${B}px + env(safe-area-inset-${P}, 0px))`:`${B}px`,zIndex:e.zIndex,transform:T?`translateY(-${T}px)`:void 0,opacity:N?0:1,pointerEvents:N?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:v,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:F,"aria-label":e.label,"aria-hidden":N?true:void 0,tabIndex:N?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),u)}function Oa(e,t){let n=_n.useRef(false);_n.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,u=a.top+a.height/2,d=document.elementsFromPoint(i,u),c=dr(window.getComputedStyle(o).zIndex);for(let m of d){if(m===o||o.contains(m))continue;if(dr(window.getComputedStyle(m).zIndex)>c){n.current=true,console.warn("[lumen] trigger is occluded by",m);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function dr(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function hr({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=_n.useState(null),d=Ge({onPointerDown:r,onClick:o,isolate:a});return _n.useEffect(()=>{if(typeof document>"u")return;let c=e instanceof HTMLElement?e:e.current??null;u(c);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:d,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 vr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=_n.useState(null),[d,c]=_n.useState(false),m=_n.useRef(null),p=Ge({onPointerDown:P=>{r?.(P),m.current={x:P.clientX,y:P.clientY},c(true);let S=P.currentTarget;try{S?.setPointerCapture?.(P.pointerId);}catch{}},onClick:o,isolate:a});if(_n.useEffect(()=>{typeof document>"u"||u(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${d?" lumen-notch-expanded":""}`;function v(P){let S=m.current;if(!S)return;let T=P.clientX-S.x,b=P.clientY-S.y;(e.edge==="top"&&b>16||e.edge==="bottom"&&b<-16||e.edge==="right"&&T<-16||e.edge==="left"&&T>16)&&(m.current=null,o(P.nativeEvent));}function y(){m.current=null,c(false);}function k(){m.current=null,c(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:C,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:v,onPointerUp:y,onPointerCancel:k,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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 wr(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function ja(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function yr(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:ja(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Za={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function Er(e){let t=_n.useId();_n.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${Xa(t)}`,o={},a=(i,u)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,u);};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,u]of Object.entries(Za)){let d=e[u];typeof d=="string"&&d.length>0&&a(i,d);}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,u]of Object.entries(o))i.startsWith("--")?u?n.style.setProperty(i,u):n.style.removeProperty(i):u==null?n.removeAttribute(i):n.setAttribute(i,u);}},[e,t]);}function Xa(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Cr=Symbol.for("lumen.history.patched"),Xt="lumen:locationchange";function ei(){if(typeof window>"u")return;let e=window;if(e[Cr])return;e[Cr]=true;let t=()=>window.dispatchEvent(new Event(Xt)),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]=_n.useState(false);return _n.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;ei();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Xt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Xt,r),window.removeEventListener("popstate",r);}},[e]),t}var ri=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function kr(){let[e,t]=_n.useState(false);return _n.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||"";ri.some(a=>o.includes(a))&&t(true);},[]),e}var xr="lumen.config.v1.",ii=3600*1e3;function Mr(e,t){let[n,r]=_n.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return _n.useEffect(()=>{if(typeof window>"u")return;let o=mi(e);o&&r({trigger:o.trigger,enabled:Sr(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),u=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(u,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.json(),m=Pr(c.trigger);if(!m)throw new Error("Malformed config response");let p=ui(c.trigger),C=Tr(c.brand);pi(e,m,p,C),r({trigger:m,enabled:Sr(m),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(d=>d.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:d);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Sr(e){return e.kind!=="headless"}var si=["br","bl","tr","tl"],li=["top","right","bottom","left"];function Pr(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:si.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:li.find(o=>o===t.edge)??"top",label:n}:null}function ui(e){return !e||typeof e!="object"?false:e.shake===true}var ci=/^#[0-9a-fA-F]{6}$/,di=["auto","light","dark"];function Tr(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&ci.test(t.accent)?t.accent:null;if(!n)return null;let r=di.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 mi(e){try{let t=window.localStorage.getItem(xr+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>ii)return null;let r=Pr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:Tr(n.brand)}:null}catch{return null}}function pi(e,t,n,r){try{window.localStorage.setItem(xr+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function hi(e){if(e&&typeof e=="object")return e.type===vt;if(typeof e=="string")try{return JSON.parse(e).type===vt}catch{return false}return false}function bi(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(u,d,c,m){if(!a)return a={x:u,y:d,z:c,t:m},false;if(m-a.t<o)return false;let p=Math.abs(u-a.x)+Math.abs(d-a.y)+Math.abs(c-a.z);return a={x:u,y:d,z:c,t:m},p<t?false:(i=i.filter(C=>m-C<r),i.push(m),i.length>=n?(i=[],true):false)}}}function Lr(e,t,n){_n.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let m=Date.now();n||m-r<o||(r=m,t());}let i=m=>{hi(m.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let u=bi(),d=m=>{let p=m.accelerationIncludingGravity??m.acceleration;!p||p.x==null||p.y==null||p.z==null||u.push(p.x,p.y,p.z,Date.now())&&a();},c=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return c&&window.addEventListener("devicemotion",d),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),c&&window.removeEventListener("devicemotion",d);}},[e,t,n]);}var Ar="https://shakebugs.vercel.app",kt=60;function Ir(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function wi({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:u,portalTarget:d,capture:c,record:m,shakeToOpen:p,onOpenChange:C,beforeOpen:v,onTriggerActivate:y,isolateEvents:k=true,keyboardInset:P,suppressTrigger:S=false,children:T}){let[b,E]=_n.useState(false),[B,N]=_n.useState(false),[F,A]=_n.useState(null),[J,I]=_n.useState(null),[$]=_n.useState(false),[j]=_n.useState(null),W=_n.useRef(false),se=_n.useRef(false),he=_n.useRef(null),V=_n.useMemo(()=>new gn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);_n.useEffect(()=>{Tn({ignoreUrlPrefix:(t??Ar).replace(/\/$/,"")});},[t]);let He=_n.useRef(C);He.current=C,_n.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 _e=_n.useRef(null);_n.useEffect(()=>{if(_e.current===b)return;let R=_e.current;_e.current=b,R!==null&&He.current?.(b);},[b]);let be=_n.useRef(v);be.current=v;let xe=_n.useRef(y);xe.current=y;let ye=_n.useCallback(R=>{se.current=true,he.current=Promise.resolve().then(()=>be.current?.(R)).then(()=>xe.current?.(R)).then(()=>{});},[]),oe=_n.useCallback(R=>{W.current||b||ae.current||ge.current||(W.current=true,N(true),A(null),I(null),(async()=>{try{if(se.current?await he.current:(await be.current?.(R),await xe.current?.(R)),c?.mode==="manual")A(null),I(null);else if(c?.provider)A(null),I(null);else {let U=await bt({...c,mode:c?.mode??"auto",target:c?.target??document.documentElement});A(U);}}catch(U){I(U instanceof Error?U:new Error(String(U)));}finally{se.current=false,he.current=null,W.current=false,N(false),E(true);}})());},[c,b]),Ee=_n.useCallback(()=>{E(false),A(null),I(null);},[]),h=_n.useCallback(V.submit.bind(V),[V]),[w,x]=_n.useState(0),M=_n.useCallback(()=>{W.current=false,N(false),E(false),A(null),I(null),x(R=>R+1);},[]),[_,K]=_n.useState(null),[ne,re]=_n.useState(null),Ce=_n.useRef(null),z=_n.useRef(null),ae=_n.useRef(false),q=_n.useRef(null),Me=_n.useRef(null),Fe=_n.useRef(null),Re=_n.useCallback((R,U=false)=>{if(Ce.current=null,z.current=null,ae.current=false,K(null),!R){q.current=null;return}Me.current={blob:R.blob,durationMs:R.durationMs,poster:q.current,deriveBlobPoster:U},q.current=null,E(true);},[]);_n.useEffect(()=>{if(!b)return;if(!m?.provider){re(null);return}let R=m.isAvailable;if(!R){re(true);return}let U=false;return Promise.resolve().then(()=>R()).then(G=>{U||re(G);}).catch(()=>{U||re(false);}),()=>{U=true;}},[b,m?.provider,m?.isAvailable]);let ke=Gt({hasProvider:!!m?.provider,providerAvailable:ne,hasGetDisplayMedia:Ir()}).canRecord,Se=_n.useCallback(async()=>{if(ae.current)return;if(Fe.current=null,Gt({hasProvider:!!m?.provider,providerAvailable:ne,hasGetDisplayMedia:Ir()}).usingProvider&&m?.provider){ae.current=true,q.current=null,E(false),z.current=sr(m.provider,{maxDurationSeconds:kt},{onStarting:()=>K({phase:"starting"}),onActive:G=>{K({phase:"recording",stream:G.stream??null,startedAt:Date.now(),maxSeconds:kt}),G.stream&&Wt(G.stream).then(ct=>{q.current=ct;}).catch(()=>{});},onProcessing:()=>K({phase:"processing"}),onResult:G=>Re({blob:G.blob,durationMs:G.durationMs},true),onCancelled:()=>{z.current=null,ae.current=false,q.current=null,K(null),A(null),I(null),E(true);},onError:G=>{z.current=null,ae.current=false,q.current=null,K(null),Fe.current=G.message||"Screen recording could not start.",E(true);}});return}if(Ce.current)return;let U=await In(kt);Ce.current=U,ae.current=true,q.current=null,K({phase:"recording",stream:U.stream,startedAt:Date.now(),maxSeconds:kt}),E(false),Wt(U.stream).then(G=>{q.current=G;}).catch(()=>{}),U.result.then(G=>Re(G)).catch(()=>Re(null));},[Re,m?.provider,ne]),Ze=_n.useCallback(()=>{z.current?z.current.stop():Ce.current?.stop();},[]),Pe=_n.useCallback(()=>{if(z.current){z.current.cancel();return}let R=Ce.current;Ce.current=null,ae.current=false,q.current=null,K(null),R?.cancel(),A(null),I(null),E(true);},[]),lt=_n.useCallback(()=>{let R=Me.current;return Me.current=null,R},[]),ut=_n.useCallback(()=>{let R=Fe.current;return Fe.current=null,R},[]);_n.useEffect(()=>{b||(Fe.current=null);},[b]);let[le,Te]=_n.useState(null),Y=_n.useRef(null),We=_n.useRef(null),ge=_n.useRef(false),Le=_n.useCallback(()=>{let R=Y.current;Y.current=null,ge.current=false,R?.stop(),Te(null),E(true);},[]),Ke=_n.useCallback(()=>{let R=Y.current;R&&(Te({phase:"grabbing"}),(async()=>{try{let U=await R.grab();if(Y.current!==R)return;We.current=U,Y.current=null,ge.current=!1,R.stop(),Te(null),E(!0);}catch{if(Y.current!==R)return;Y.current=null,ge.current=false,R.stop(),Te(null),sonner.toast.error("Could not capture the screen. Please try again."),E(true);}})());},[]),Ne=_n.useCallback(async()=>{if(ge.current)return;let R;try{R=await Nt({...c});}catch{return}Y.current=R,ge.current=true,R.onEnded(()=>Le()),Te({phase:"live"}),E(false);},[c,Le]),ve=_n.useCallback(()=>{let R=We.current;return We.current=null,R},[]);_n.useEffect(()=>()=>{Y.current?.stop(),Y.current=null;},[]);let qe=kr(),Ae=Rr(i),Ue=Mr(a?"":e,t??Ar);Er(u??Ci(Ue.brand));let Ie=p??Ue.shakeToOpen;Lr(Ie,oe,b);let Xe=_n.useMemo(()=>({client:V,user:n,isOpen:b,isSubmitting:$,error:j,open:oe,close:Ee,openCapture:oe,closeCapture:Ee,submit:h,isNativeShell:qe,capture:c,initialCapture:F,initialCaptureError:J,isOpening:B,startVideoSession:Se,stopVideoSession:Ze,cancelVideoSession:Pe,recording:_,consumePendingVideo:lt,canRecordScreen:ke,consumeRecordStartError:ut,startScreenCaptureSession:Ne,grabScreenCaptureFrame:Ke,cancelScreenCaptureSession:Le,screenCapture:le,consumePendingScreenshot:ve,isolateEvents:k,keyboardInset:P}),[V,n,b,$,j,oe,Ee,h,qe,c,F,J,Se,Ze,Pe,_,lt,ke,ut,Ne,Ke,Le,le,ve,B,k,P]),me=Ei({explicit:a,remote:Ue.trigger,remoteLoading:Ue.loading,floatingButton:o});return jsxRuntime.jsxs(Ot.Provider,{value:Xe,children:[T,jsxRuntime.jsxs(Ct,{onReset:M,onError:R=>V.reportClientError({...R,context:{open:b,opening:B,screenCapturePhase:le?.phase,recordingPhase:_?.phase,initialCaptureMethod:F?.method,initialCapturePixelRatio:F?.pixelRatio,initialCaptureViewport:F?.viewport,hadInitialCaptureError:J!=null}}),children:[me?.kind==="floating"?jsxRuntime.jsx(fr,{config:yr(me),portalTarget:d,hidden:Ae||S||B||_!=null||le!=null,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k,keyboardInset:P}):null,me?.kind==="notch"?jsxRuntime.jsx(vr,{config:wr(me),portalTarget:d,hidden:Ae||S||B||_!=null||le!=null,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k}):null,me?.kind==="inline"?jsxRuntime.jsx(hr,{mount:me.mount,label:me.label??"Feedback",icon:me.icon,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k}):null,le?jsxRuntime.jsx(or,{state:le,portalTarget:d,onCapture:Ke,onCancel:Le}):null,_?jsxRuntime.jsx(rr,{state:_,portalTarget:d,onStop:Ze,onCancel:Pe}):null,jsxRuntime.jsx(Yt,{})]},w),jsxRuntime.jsx(yi,{})]})}function yi(){let[e,t]=_n.useState(false);return _n.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Ei(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Ci(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Ri({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=nt(),u=["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:u,"data-lumen-trigger":"",onClick:d=>{o?.(d),d.defaultPrevented||i(d.nativeEvent);},...a,children:r})}
5
- exports.CaptureModal=Yt;exports.FeedbackButton=Ri;exports.LUMEN_KEYBOARD_CSS_VAR=It;exports.LUMEN_KEYBOARD_EVENT=tt;exports.LUMEN_SHAKE_MESSAGE=vt;exports.LumenProvider=wi;exports.createNativeCaptureProvider=Io;exports.isLumenEventTarget=Po;exports.isolateLumenEvents=To;exports.readLumenKeyboardInset=Dt;exports.setLumenKeyboardInset=zo;exports.useKeyboardInset=ot;exports.useLumen=nt;//# sourceMappingURL=index.cjs.map
2
+ 'use strict';var Fn=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 Fn__namespace=/*#__PURE__*/_interopNamespace(Fn);var O=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},an=class extends O{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},sn=class extends O{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},pt=class extends O{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},Kr="https://shakebugs.vercel.app",qr="/api/v1/sdk/submit",jr="/api/v1/sdk/error",Yr="0.15.0",Gr=5,Zr=new Set([502,503,504]),vn=class{apiKey;apiUrl;user;amplitude;#e=new Set;#t=0;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new O("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??Kr).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${qr}`,r=this.#n(e),o=null;for(let a=0;a<3;a++){a>0&&await Jr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof an||i instanceof sn||i instanceof O&&typeof i.status=="number"&&!Zr.has(i.status))throw i}}throw o instanceof Error?o:new pt("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Gr)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 u=new URL(window.location.href);a=u.origin+u.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}${jr}`,{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.priority&&t.append("priority",e.priority),e.source&&t.append("source",e.source),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,Xr(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:u}=n;i&&a.upload.addEventListener("progress",c=>{c.lengthComputable&&c.total>0&&i(Math.min(1,c.loaded/c.total));});let d=()=>{a.abort(),o(new pt("Submit aborted."));};if(u){if(u.aborted){o(new pt("Submit aborted."));return}u.addEventListener("abort",d,{once:true});}a.addEventListener("load",()=>{if(u&&u.removeEventListener("abort",d),a.status===403){o(new an);return}if(a.status===429){let c=Number(a.getResponseHeader("Retry-After"))||60;o(new sn(c));return}if(a.status<200||a.status>=300){o(new O(Qr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let c=JSON.parse(a.responseText);r(c);}catch{o(new O("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{u&&u.removeEventListener("abort",d),o(new pt("Network error during submit."));}),a.send(t);})}};function Xr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Jr(e){return new Promise(t=>setTimeout(t,e))}function Qr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var wn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function yn(e=wn){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 eo=2,to=1.5,no=820,ro=12,Je=8*1024*1024;async function bt(e={}){At();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return co(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 O("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return dn(e);if(t==="dom")return un(e);if(t==="custom")throw new O("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await un(e)}catch(n){if(Sn()){let r=await dn(e);return r.warnings=et(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function Qe(e,t=[]){At();let n=gt();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:et(t)}}var ln=Promise.resolve();function un(e){let t=ln.then(()=>cn(e),()=>cn(e));return ln=t.catch(()=>{}),t}async function cn(e){let t=await uo(),n=e.target??document.documentElement,r=gt(),o=po(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),u=window.scrollY+(a?.offsetTop??0),d=fo(e,r.width,r.height),c=mo(n);!e.provider&&lo()&&c.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 m=io(n);await Rn(e.awaitAnimationsMs??go),await bo();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:u,scale:d,ignoreElements:v=>v instanceof HTMLElement&&(v.dataset.lumenCaptureIgnore==="true"||!!v.closest("[data-lumen-capture-ignore='true']")),onclone:(v,y)=>{so(y,m),oo(v);}}),C={blob:await kn(p,c),method:"web-dom",platform:"web",viewport:r,pixelRatio:d,warnings:et(c)};return C.warnings.length>0&&e.onWarning?.(C.warnings),C}var En=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function oo(e){for(let t of Array.from(e.querySelectorAll(En))){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 ao="[data-lumen-root], [data-lumen-capture-ignore='true']";function Cn(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(ao))}function io(e){return Cn(e).map(t=>{if(t.matches(En))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 so(e,t){let n=Cn(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 lo(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function uo(){let{default:e}=await import('html2canvas-pro');return e}async function Nt(e={}){if(At(),!Sn())throw new O("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 vo(n);}catch(i){for(let u of t.getTracks())u.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(u=>u());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let u=i?.conceal??true,d=u?yn():()=>{};try{u&&await wo(r,3,400);let c=document.createElement("canvas");c.width=r.videoWidth,c.height=r.videoHeight;let m=c.getContext("2d");if(!m)throw new O("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");m.drawImage(r,0,0,c.width,c.height);let p=gt(),C=["Browser screen capture uses the window or tab selected by the user."],v={blob:await kn(c,C),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?c.width/p.width:void 0,warnings:et(C)};return e.onWarning?.(v.warnings),v}finally{d();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function dn(e){let t=await Nt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function co(e,t){let n=gt(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:et(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function mo(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 kn(e,t){let n=await mn(e,"image/png",.92);if(n.size<=Je)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>Je&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(Je/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 u=i.getContext("2d");if(!u)return n;u.drawImage(r,0,0,i.width,i.height),r=i;for(let d of [.86,.74,.62,.5])if(n=await mn(r,"image/jpeg",d),n.size<=Je)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>Je&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function mn(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new O("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function gt(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function po(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function fo(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??eo;ho()&&(o=Math.min(o,to));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(ro*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function ho(){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<=no}function bo(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var go=400;async function Rn(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 Sn(){return !!navigator.mediaDevices?.getDisplayMedia}async function vo(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new O("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 O("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function wo(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 u=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(u);};r(u),setTimeout(i,n);});}function At(){if(typeof window>"u"||typeof document>"u")throw new O("Screenshot capture can only run in the browser.","INVALID_ENV")}function et(e){return Array.from(new Set(e.filter(Boolean)))}var xn=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,yo=[/-----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 Eo(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 Mt(e){let t=e;for(let n of yo)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:xn.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=>Eo(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 Mn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])xn.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Mt(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Mt(e)}}function Pn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return Mn(e)}}var pn=200,fn=4096,Tn=[],ft=[],hn=false,Pt=null;function Ln(e={}){hn||typeof window>"u"||(hn=true,Pt=e.ignoreUrlPrefix??null,So(),xo(),Mo());}function Co(){return {consoleLog:Tn.slice(),networkLog:ft.slice()}}function ht(e,t){e.push(t),e.length>pn&&e.splice(0,e.length-pn);}function ko(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,Ro));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>fn?n.slice(0,fn)+"\u2026[truncated]":n}function Ro(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function So(){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{ht(Tn,{level:n,ts:Date.now(),message:Mt(ko(o))});}catch{}r(...o);});}}function Nn(e){return Pt?e.startsWith(Pt):false}function xo(){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(Nn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ht(ft,{type:"fetch",method:o,url:Tt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ht(ft,{type:"fetch",method:o,url:Tt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Mo(){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&&!Nn(o.url)){o.t=performance.now();let a=()=>{try{ht(ft,{type:"xhr",method:o.method,url:Tt(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 Po(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Tt(e){return Po(Mn(e))}function An(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:bn(e),consoleLog:[],networkLog:[]};let t=Co();return {url:Pn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:bn(e),device:To(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function To(){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?Pn(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 bn(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var Lo="[data-lumen-root]",No="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function Ao(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(Lt(n))return true;return Lt(e.target)}var gn=["pointerdown","mousedown","touchstart","click"];function Io(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of gn)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of gn)e.removeEventListener(n,t);}}function Lt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(No)?true:!!e.closest(Lo):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?Lt(e.host):false:false}var vt="lumen:shake",Do=8e3,Oo=50,Ho=400;function Bo(e={}){return async function(){if(typeof window>"u")throw new O("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=Fo(),n=e.send??_o,r=e.timeoutMs??Do,o=e.captureSettleMs??Oo,a=e.awaitAnimationsMs??Ho,i=Wo(),u=yn(e.concealSelector===void 0?wn:e.concealSelector);try{await Vo(o,a);let d=await new Promise((p,C)=>{let v=window.setTimeout(()=>{t.pending.delete(i),C(new O("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:y=>{window.clearTimeout(v),p(y);},reject:y=>{window.clearTimeout(v),C(y);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(v),C(new O("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(d.error||!d.dataUrl)throw new O(d.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let c=Ko(d.dataUrl),m=e.platform??$o();return {blob:c,method:m==="android"?"android-native":"ios-native",platform:m,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:d.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{u();}}}function _o(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new O("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function Fo(){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=Uo(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 Uo(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 Vo(e,t){await Rn(t),await zo(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function zo(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function $o(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function Wo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function Ko(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new O("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 u=0;u<a.length;u++)i[u]=a.charCodeAt(u);return new Blob([i],{type:n})}var tt="lumen:keyboardchange",It="--lumen-keyboard-inset";function qo(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(It,`${t}px`),window.dispatchEvent(new Event(tt));}function Dt(){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(It).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function In(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new O("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new O("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(v=>MediaRecorder.isTypeSupported(v))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((v,y)=>{c=v,m=y;});p.catch(()=>{}),r.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&o.push(v.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let T of t.getTracks())T.stop();if(d)return;if(d=true,u){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let v=performance.now()-a,y=r.mimeType||n||"audio/webm",R=new Blob(o,{type:y});c({blob:R,durationMs:v,mimeType:y});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function C(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){u=true,C(),i!==null&&window.clearTimeout(i),i=null;for(let v of t.getTracks())v.stop();},stop(){return C(),p}}}async function Dn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new O("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new O("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(y=>MediaRecorder.isTypeSupported(y))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((y,R)=>{c=y,m=R;});p.catch(()=>{});function C(){i!==null&&(window.clearTimeout(i),i=null);for(let y of t.getTracks())y.stop();}r.addEventListener("dataavailable",y=>{y.data&&y.data.size>0&&o.push(y.data);}),r.addEventListener("stop",()=>{if(u)return;if(u=true,C(),d){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let y=r.mimeType||n||"video/webm";c({blob:new Blob(o,{type:y}),durationMs:performance.now()-a,mimeType:y});});function v(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(v,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",v),{stream:t,result:p,stop:v,cancel(){d=true,r.state!=="inactive"?r.stop():u||(u=true,C(),m(new O("Recording cancelled.","RECORDER_STOPPED")));}}}var Ot=Fn.createContext(null);function nt(){let e=Fn.useContext(Ot);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var On=100;function Hn(){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 rt={open:false,inset:0};function Xo(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:rt}if(e.vvHeight==null||!e.coarse||!e.editable)return rt;let n=e.vvBaseline-e.vvHeight;return n>On?{open:true,inset:Math.round(n)}:rt}function ot(e,t){let[n,r]=Fn.useState(rt),o=Fn.useRef(0),a=Fn.useRef(t);return a.current=t,Fn.useEffect(()=>{if(!e){r(rt);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,u=()=>{let p=Hn(),C=a.current,v=Dt(),y=window.visualViewport??null;y&&C==null&&v==null&&!p&&(o.current=y.height),r(Xo({editable:p,override:C,injected:v,vvBaseline:o.current,vvHeight:y?y.height:null,coarse:i}));},d=0,c=()=>{d||(d=window.requestAnimationFrame(()=>{d=0,u();}));},m=window.visualViewport;return m&&(o.current=m.height),c(),m?.addEventListener("resize",c),m?.addEventListener("scroll",c),document.addEventListener("focusin",c),document.addEventListener("focusout",c),window.addEventListener(tt,c),()=>{d&&window.cancelAnimationFrame(d),m?.removeEventListener("resize",c),m?.removeEventListener("scroll",c),document.removeEventListener("focusin",c),document.removeEventListener("focusout",c),window.removeEventListener(tt,c);}},[e]),n}var Bt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function _n(e,t=1){return Math.max(0,Math.min(t,e))}var Un=Fn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},u){let d=Fn.useRef(null),c=Fn.useRef(null),m=Fn.useRef(null),[p,C]=Fn.useState(null),[v,y]=Fn.useState(false),[R,T]=Fn.useState(""),[S,L]=Fn.useState([]),b=Fn.useRef(null),E=Fn.useRef(false),H=Fn.useRef(0),N=Fn.useRef(false),[F,A]=Fn.useState([]),J=Fn.useRef(0),I=Fn.useRef([]),$=Fn.useRef([]),G=Fn.useRef(S);G.current=S;let W=Fn.useRef(F);W.current=F;let le=Fn.useRef(null),he=Fn.useRef(i);he.current=i;let V=Fn.useCallback(()=>{he.current?.({canUndo:I.current.length>0,canRedo:$.current.length>0});},[]),Oe=Fn.useCallback((h,w)=>{A(x=>x.map(P=>P.id===h?{...P,text:w}:P));},[]),He=Fn.useCallback(h=>{A(x=>x.filter(P=>P.id!==h));let w=I.current.lastIndexOf("comment");w>=0&&I.current.splice(w,1),$.current=[],V();},[V]);Fn.useEffect(()=>{let h=le.current;if(h==null)return;le.current=null,m.current?.querySelector(`[data-bubble-id="${h}"] .lumen-bubble-text`)?.focus();},[F]),Fn.useEffect(()=>{L([]),A([]),y(false),I.current=[],$.current=[],V();},[t,V]),Fn.useEffect(()=>{let h=false,w=null;return (async()=>{try{let x=await createImageBitmap(t);if(h){x.close?.();return}w=x,C(x);}catch{}})(),()=>{h=true,w?.close?.();}},[t]),Fn.useEffect(()=>{if(!p)return;let h=d.current,w=c.current;if(!(!h||!w)){w.width=p.width,w.height=p.height;try{h.width=p.width,h.height=p.height;let x=h.getContext("2d");if(!x)return;x.imageSmoothingEnabled=!1,x.drawImage(p,0,0),y(!1);}catch{y(true);}}},[p]),Fn.useEffect(()=>{if(!v){T("");return}let h=URL.createObjectURL(t);return T(h),()=>{URL.revokeObjectURL(h);}},[v,t]),Fn.useEffect(()=>{let h=c.current;if(h)try{wt(h,S,b.current);}catch{}},[S]),Fn.useImperativeHandle(u,()=>({hasAnnotations:()=>S.length>0||F.some(h=>h.text.trim().length>0),reset:()=>{L([]),A([]),G.current=[],W.current=[],I.current=[],$.current=[],V();},undo:()=>{let h=I.current[I.current.length-1];if(h){if(h==="comment"){let w=W.current,x=w[w.length-1];if(!x)return;let P=w.slice(0,-1);W.current=P,$.current.push({type:"comment",item:x}),A(P);}else {let w=G.current,x=w[w.length-1];if(!x)return;let P=w.slice(0,-1);G.current=P,$.current.push({type:"anno",item:x}),L(P);}I.current.pop(),V();}},redo:()=>{let h=$.current[$.current.length-1];if(h){if(h.type==="comment"){let w=[...W.current,h.item];W.current=w,A(w);}else {let w=[...G.current,h.item];G.current=w,L(w);}I.current.push(h.type),$.current.pop(),V();}},async flatten(){let h=b.current,w=h?[...S,h]:S,x=F.filter(P=>P.text.trim().length>0);if(w.length===0&&x.length===0||!p||v)return t;try{let P=document.createElement("canvas");P.width=p.width,P.height=p.height;let _=P.getContext("2d");if(!_)return t;_.imageSmoothingEnabled=!1,_.drawImage(p,0,0);for(let q of w)_t(_,q);let K=d.current?.clientWidth||p.width,re=p.width/Math.max(K,1);for(let q of x)na(_,q,p.width,p.height,re);return await new Promise(q=>{P.toBlob(pe=>{q(pe??t);},"image/jpeg",.85);})}catch{return t}}}),[S,F,p,t,v,V]);function be(h){let w=c.current;if(!w)return {x:0,y:0};let x=w.getBoundingClientRect(),P=w.width/Math.max(x.width,1),_=w.height/Math.max(x.height,1);return {x:(h.clientX-x.left)*P,y:(h.clientY-x.top)*_}}function Me(){N.current||(N.current=true,requestAnimationFrame(()=>{N.current=false;let h=c.current;h&&wt(h,G.current,b.current);}));}function Ce(h){if(h.button!==void 0&&h.button!==0)return;if(n==="comment"){let x=c.current;if(!x)return;let P=x.getBoundingClientRect(),_=_n((h.clientX-P.left)/Math.max(P.width,1),.72),K=_n((h.clientY-P.top)/Math.max(P.height,1),.8),re=++J.current;A(q=>[...q,{id:re,x:_,y:K,text:"",color:r}]),I.current.push("comment"),$.current=[],le.current=re,V();return}try{h.currentTarget.setPointerCapture(h.pointerId);}catch{}E.current=true,a?.(true);let w=be(h);n==="arrow"?b.current={kind:"arrow",from:w,to:w,color:r,width:o}:n==="rect"?b.current={kind:"rect",from:w,to:w,color:r,width:o}:b.current={kind:"freehand",points:[w],color:r,width:o},H.current=performance.now(),Me();}function oe(h){if(!E.current||!b.current)return;let w=be(h),x=b.current;if(x.kind==="arrow"||x.kind==="rect")x.to=w;else {let P=x.points[x.points.length-1],_=P?(P.x-w.x)**2+(P.y-w.y)**2:1/0,K=performance.now(),re=K-H.current;(_>16||re>16)&&(x.points.push(w),H.current=K);}Me();}function ke(){if(!E.current)return;E.current=false,a?.(false);let h=b.current;if(b.current=null,!!h){if(h.kind==="arrow"||h.kind==="rect"){let w=h.to.x-h.from.x,x=h.to.y-h.from.y;if(w*w+x*x<16){let P=c.current;P&&wt(P,G.current,null);return}}else if(h.points.length<2){let w=c.current;w&&wt(w,G.current,null);return}L(w=>[...w,h].slice(-50)),I.current.push("anno"),$.current=[],V();}}return jsxRuntime.jsxs("div",{ref:m,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:d}),v&&R?jsxRuntime.jsx("img",{src:R,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsxRuntime.jsx("canvas",{ref:c,className:"lumen-annotate-overlay",onPointerDown:Ce,onPointerMove:oe,onPointerUp:ke,onPointerCancel:ke}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:F.map(h=>jsxRuntime.jsx(ea,{comment:h,onChange:Oe,onRemove:He},h.id))})]})});function ea({comment:e,onChange:t,onRemove:n}){let r=Fn.useRef(null);return Fn.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 wt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)_t(r,o);n&&_t(r,n);}}function _t(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")ta(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 ta(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],u=(a.x+i.x)/2,d=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,u,d);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function na(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,u=14*o,d=10*o,c=12*o,m=u*1.35,p=d*1.7,C=t.x*n,v=t.y*r,y=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${u}px ${Bt}`,e.textBaseline="top";let R=ra(e,a,y-i*2),T=R.reduce((N,F)=>Math.max(N,e.measureText(F).width),0),S=Math.min(y,Math.max(T,56*o)+i*2),L=i*2+p+R.length*m;oa(e,C,v,S,L,c),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let b=C+18*o,E=v+L;e.beginPath(),e.moveTo(b,E-o),e.lineTo(b+13*o,E-o),e.lineTo(b+4*o,E+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${d}px ${Bt}`,e.fillText("COMMENT",C+i,v+i),e.fillStyle="#111318",e.font=`500 ${u}px ${Bt}`;let H=v+i+p;for(let N of R)e.fillText(N,C+i,H),H+=m;e.restore();}function ra(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let u=a?`${a} ${i}`:i;a&&e.measureText(u).width>n?(o.push(a),a=i):a=u;}return a&&o.push(a),o.length?o:[t]}function oa(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 Y({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 aa(e){return jsxRuntime.jsxs(Y,{...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 ia(e){return jsxRuntime.jsxs(Y,{...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 Ft(e){return jsxRuntime.jsxs(Y,{...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 zn(e){return jsxRuntime.jsx(Y,{...e,children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-8.5 8.5 9.5 9.5 0 0 1-3.5-.7L3 21l1.7-5.5A8.38 8.38 0 0 1 4 11.5 8.5 8.5 0 0 1 12.5 3 8.38 8.38 0 0 1 21 11.5Z"})})}function $n(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19 19 5"}),jsxRuntime.jsx("path",{d:"M11 5h8v8"})]})}function Wn(e){return jsxRuntime.jsx(Y,{...e,children:jsxRuntime.jsx("rect",{x:"4",y:"6",width:"16",height:"12",rx:"2"})})}function Ut(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19l1.5-5L16 4.5 19.5 8 10 17.5 5 19z"}),jsxRuntime.jsx("path",{d:"M14 6.5l3.5 3.5"})]})}function Kn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M9 8 4 13l5 5"}),jsxRuntime.jsx("path",{d:"M4 13h11a5 5 0 0 1 0 10h-1"})]})}function Vt(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),jsxRuntime.jsx("path",{d:"M21 4v4h-4"})]})}function qn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M15 8 20 13l-5 5"}),jsxRuntime.jsx("path",{d:"M20 13H9a5 5 0 0 0 0 10h1"})]})}function jn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M4 7h16"}),jsxRuntime.jsx("path",{d:"M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"}),jsxRuntime.jsx("path",{d:"M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"})]})}function Yn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),jsxRuntime.jsx("path",{d:"M16 3h3a2 2 0 0 1 2 2v3"}),jsxRuntime.jsx("path",{d:"M21 16v3a2 2 0 0 1-2 2h-3"}),jsxRuntime.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"})]})}function Gn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),jsxRuntime.jsx("path",{d:"M16 3v3a2 2 0 0 0 2 2h3"}),jsxRuntime.jsx("path",{d:"M21 16h-3a2 2 0 0 0-2 2v3"}),jsxRuntime.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"})]})}function Zn(e){return jsxRuntime.jsx(Y,{...e,strokeWidth:2.2,children:jsxRuntime.jsx("path",{d:"M15 6l-6 6 6 6"})})}function Xn(e){return jsxRuntime.jsx(Y,{...e,strokeWidth:1.9,children:jsxRuntime.jsx("path",{d:"M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z"})})}function it(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function zt(e){return jsxRuntime.jsxs(Y,{...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 yt={shot:aa,video:ia,upload:Ft};function Jn(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 sa(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 la=4e3;async function $t(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((d,c)=>{if(n.readyState>=2)return d();n.addEventListener("loadeddata",()=>d(),{once:true}),n.addEventListener("error",()=>c(new Error("video decode failed")),{once:true});}),await sa(n,Math.min(.1,(n.duration||0)/2));let i=await Jn(n),u=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:u}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),la);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Wt(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 Jn(t)}catch{return null}finally{t.srcObject=null;}}async function Kt(){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 qt=60,ua=25*1024*1024,Qn=[{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)"}],er=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],ca=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],da=[{value:"",label:"No priority"},{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],ma=[{value:"web",label:"Web"},{value:"ios-web",label:"iOS web"},{value:"android-web",label:"Android web"},{value:"ios-native",label:"iOS native"},{value:"android-native",label:"Android native"}];function pa(e){if(e.platform==="ios")return "ios-native";if(e.platform==="android")return "android-native";if(e.platform==="custom")return "custom";let t=typeof navigator<"u"&&navigator.userAgent||"";return /android/i.test(t)?"android-web":/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&typeof document<"u"&&"ontouchend"in document?"ios-web":"web"}function fa({value:e}){return e==="urgent"?jsxRuntime.jsx("span",{className:"lumen-pri-ic lumen-pri-urgent","aria-hidden":"true",children:"!"}):jsxRuntime.jsxs("span",{className:"lumen-pri-ic lumen-pri-bars","data-level":e==="high"?3:e==="medium"?2:1,"aria-hidden":"true",children:[jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{})]})}var jt=[{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 Yt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:u,consumePendingVideo:d,canRecordScreen:c,consumeRecordStartError:m,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:v,keyboardInset:y}=nt(),[R,T]=Fn.useState(1),[S,L]=Fn.useState(null),[b,E]=Fn.useState({kind:"idle"}),[H,N]=Fn.useState(false),[F,A]=Fn.useState(0),[J,I]=Fn.useState("arrow"),[$,G]=Fn.useState(Qn[0].value),[W,le]=Fn.useState(er[1].value),[he,V]=Fn.useState(""),[Oe,He]=Fn.useState("bug"),[be,Me]=Fn.useState(""),[Ce,oe]=Fn.useState(""),[ke,h]=Fn.useState(false),[w,x]=Fn.useState(false),[P,_]=Fn.useState(false),[K,re]=Fn.useState(false),[q,pe]=Fn.useState(false),[ge,Re]=Fn.useState(r?.email??""),[U,Pe]=Fn.useState(null),[ae,Se]=Fn.useState(null),[lt,Be]=Fn.useState(0),[ve,we]=Fn.useState(null),[ut,_e]=Fn.useState(null),[xe,Fe]=Fn.useState(false),[Q,Ke]=Fn.useState({canUndo:false,canRedo:false}),ue=Fn.useRef(null),Te=Fn.useRef(null),Ue=Fn.useRef(null),Ge=Fn.useRef(null),Ze=Fn.useRef(null),Le=ot(t,y),ye=Fn.useRef(false),Ne=Fn.useRef(false);Fn.useEffect(()=>{t||(Ne.current=false);},[t]),Fn.useEffect(()=>{if(!t)return;if(Ne.current){ye.current=false;return}Ne.current=true,ye.current=false,T(1),L(null),V(""),Se(null),Be(0),we(null),N(false),A(0),oe(""),pe(false),_e(null),Ke({canUndo:false,canRedo:false});let s=C();if(s){L("shot"),z(s),E({kind:"ready",capture:s});return}let g=d();if(g)L("video"),we({blob:g.blob,durationMs:g.durationMs}),g.blob.size>ua&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),g.poster?E({kind:"ready",capture:Qe(g.poster,["Screen recording; preview is the first frame."])}):(E({kind:"capturing"}),(async()=>{let D=null;if(g.deriveBlobPoster)try{D=(await $t(g.blob)).poster;}catch{D=null;}D=D??await Kt(),!ye.current&&E(D?{kind:"ready",capture:Qe(D,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let D=m();D?(L("video"),_e(D),E({kind:"idle"})):a?(L("shot"),E({kind:"ready",capture:a})):o?.mode==="manual"?E({kind:"manual"}):o?.provider&&!i?(L("shot"),ct(o.mode??"auto")):E({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ye.current=true;}},[t,o,a,i]),Fn.useEffect(()=>{if(!t)return;Ze.current=document.activeElement??null;let s=document.documentElement,g=s.style.overflow,D=s.style.paddingRight,ie=window.innerWidth-s.clientWidth;s.style.overflow="hidden",ie>0&&(s.style.paddingRight=`${ie}px`);let ce=false,Ee=()=>{if(!ce){ce=true,s.style.overflow=g,s.style.paddingRight=D;try{Ze.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Ee),()=>{window.removeEventListener("pagehide",Ee),Ee();}},[t]),Fn.useEffect(()=>{if(!t)return;function s(g){if(g.key==="Escape"){g.preventDefault(),n();return}if(g.key!=="Tab")return;let D=Ue.current;if(!D)return;let ie=Ra(D);if(ie.length===0)return;let ce=ie[0],Ee=ie[ie.length-1],xt=document.activeElement;g.shiftKey&&(xt===ce||!D.contains(xt))?(g.preventDefault(),Ee.focus()):!g.shiftKey&&xt===Ee&&(g.preventDefault(),ce.focus());}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),Fn.useEffect(()=>{if(!t||!v)return;let s=Ge.current;if(!s)return;let g=D=>{D.target===s&&D.stopPropagation();};return s.addEventListener("pointerdown",g),s.addEventListener("click",g),s.addEventListener("touchstart",g,{passive:true}),()=>{s.removeEventListener("pointerdown",g),s.removeEventListener("click",g),s.removeEventListener("touchstart",g);}},[t,v]),Fn.useEffect(()=>{if(!t||!Le.open)return;let s=Ue.current,g=document.activeElement;if(s&&g&&s.contains(g))try{g.scrollIntoView({block:"center"});}catch{}},[t,Le.open,Le.inset]),Fn.useEffect(()=>{if(!t||b.kind!=="manual")return;function s(g){let ce=Array.from(g.clipboardData?.items??[]).find(Ee=>Ee.type.startsWith("image/"))?.getAsFile();ce&&(g.preventDefault(),k(ce));}return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[t,b.kind]),Fn.useEffect(()=>{if(!U)return;let s=Date.now(),g=window.setInterval(()=>{let D=Math.floor((Date.now()-s)/1e3);Be(D),D>=qt&&Xe();},250);return ()=>window.clearInterval(g)},[U]);let Ve=Fn.useRef(null);if(Ve.current=U,Fn.useEffect(()=>{t||Ve.current&&(Ve.current.cancel(),Ve.current=null,Pe(null),Be(0));},[t]),Fn.useEffect(()=>()=>{Ve.current?.cancel();},[]),!t)return null;async function ct(s){ye.current=false,E({kind:"capturing"});try{let g=await bt({...o,mode:s,target:o?.target??document.documentElement});return ye.current?!1:(z(g),E({kind:"ready",capture:g}),!0)}catch(g){return ye.current||E({kind:"manual",error:g instanceof Error?g.message:"Automatic screenshot capture was unavailable."}),false}}async function ee(s){L(s),_e(null),s!=="video"&&St(),s==="shot"?await ct(o?.mode??"auto"):s==="video"?(we(null),E({kind:"idle"})):(E({kind:"manual"}),Te.current?.click());}async function k(s){if(s.type.startsWith("image/")){St();let g=Qe(s,["Manual image upload used."]);E({kind:"ready",capture:g});return}if(s.type.startsWith("video/")){E({kind:"capturing"});try{let{poster:g,durationMs:D}=await $t(s),ie=g??await Kt();if(!ie){E({kind:"manual",error:"Could not read that video."});return}let ce=Qe(ie,["Uploaded video; preview is the first frame."]);we({blob:s,durationMs:D}),E({kind:"ready",capture:ce});}catch{E({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function z(s){s.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function j(){try{let s=await In(qt);Pe(s);}catch(s){sonner.toast.error(s instanceof Error?s.message:"Microphone unavailable");}}async function Xe(){if(U)try{let s=await U.stop();Se({blob:s.blob,durationMs:s.durationMs});}catch(s){sonner.toast.error(s instanceof Error?s.message:"Could not stop recording");}finally{Pe(null);}}function _r(){U?.cancel(),Pe(null),Se(null),Be(0);}function Jt(s){let g=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!U&&!ae?jsxRuntime.jsxs("button",{type:"button",onClick:j,className:s==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(zt,{}),"Record voice note"]}):null,U?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(wa,{stream:U.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[lt,"s / ",qt,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:Xe,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:_r,className:"lumen-btn-ghost",children:"Cancel"})]}):null,ae&&!U?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ea,{blob:ae.blob,durationMs:ae.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Se(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return s==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[g,!U&&!ae?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)"}),g]})}async function Fr(){_e(null);try{await u();}catch(s){sonner.toast.error(s instanceof Error?s.message:"Screen capture unavailable");}}function St(){we(null);}let Ur=b.kind==="ready";async function Qt(){U&&await Xe(),R===1?(b.kind==="ready"&&!Ce&&oe(pa(b.capture)),T(2)):await tn();}function en(){R>1&&T(s=>s-1);}async function tn(){if(b.kind!=="ready")return;let s=he.trim(),{capture:g}=b;N(true),A(0);try{let ie=await ue.current?.flatten()??g.blob,ce=await e.submit({rawText:s.length>0?s:void 0,category:Oe,priority:be||void 0,source:Ce||void 0,submitterEmail:ge.trim()||void 0,screenshot:ie,audio:ae?.blob,audioDurationMs:ae?.durationMs,video:ve?.blob,videoDurationMs:ve?.durationMs,context:An(g)},{onUploadProgress:Ee=>A(Math.min(.95,Ee))});A(1),sonner.toast.success("Feedback sent \u2014 thank you."),ce.id,n();}catch(D){sonner.toast.error(D instanceof Error?D.message:"Could not submit feedback"),N(false);}}function Vr(s){s.target===s.currentTarget&&!H&&n();}let qe=Math.round(F*100),dt=S==="video",zr=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,nn=S==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&zr,rn=R===1&&!Ur||H,$r=R<3?"Next":H?qe<95?`Uploading ${qe}%\u2026`:"Almost done\u2026":"Send feedback",mt=R===1,on=R===2&&b.kind==="ready",Wr=mt||on;return jsxRuntime.jsx("div",{ref:Ge,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Le.inset?{"--lumen-keyboard-inset":`${Le.inset}px`}:void 0,onMouseDown:Vr,children:jsxRuntime.jsxs("div",{ref:Ue,className:"lumen-modal","data-lumen-drawing":xe?"true":void 0,"data-lumen-fs":Wr?"true":void 0,"data-lumen-expanded":q?"true":void 0,"data-lumen-review":on?"true":void 0,"data-lumen-sheet":mt&&w?"down":void 0,children:[jsxRuntime.jsx(va,{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(ha,{step:R}),jsxRuntime.jsx("input",{ref:Te,type:"file",accept:"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime",style:{display:"none"},onChange:s=>{let g=s.currentTarget.files?.[0];g&&k(g),s.currentTarget.value="";}}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[R===1||R===2?jsxRuntime.jsx("div",{className:"lumen-pane",children:S===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-top",children:jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})})}),jsxRuntime.jsxs("div",{className:"lumen-fs-center lumen-fs-picker",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-picker-head",children:[jsxRuntime.jsx("div",{className:"lumen-fs-picker-title",children:"How do you want to capture?"}),jsxRuntime.jsx("div",{className:"lumen-fs-picker-sub",children:"Pick a method to report this."})]}),jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(s.primary?" lumen-method-primary":""),onClick:()=>ee(s.value),disabled:b.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(g,{})}),s.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]})]},s.value)})})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[b.kind!=="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsx("div",{className:"lumen-fs-pill",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>ee(s.value),disabled:b.kind==="capturing",children:jsxRuntime.jsx(g,{})},s.value)})})})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-center",children:[S==="video"&&b.kind==="idle"?jsxRuntime.jsx(ba,{canRecord:c,onRecord:Fr,onUpload:()=>ee("upload"),error:ut}):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:S==="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:S==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:S==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:s=>{let g=s.currentTarget.files?.[0];g&&k(g),s.currentTarget.value="";}})]})]}):null]})]}):null,b.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[R===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-expand",onClick:()=>pe(s=>!s),"aria-pressed":q,"aria-label":q?"Shrink capture":"Expand capture",title:q?"Shrink":"Expand to full screen",children:q?jsxRuntime.jsx(Gn,{}):jsxRuntime.jsx(Yn,{})}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-fs-chip",onClick:()=>_(s=>!s),"aria-haspopup":"menu","aria-expanded":P,children:[jsxRuntime.jsx(Vt,{})," Recapture",jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},"aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),P?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-recap-overlay",onClick:()=>_(false)}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap-menu",role:"menu",children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),S&&ee(S);},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(Vt,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Re-snap this view"}),jsxRuntime.jsx("small",{children:"Instant \xB7 masks sensitive fields"})]})]}),nn?jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),p();},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(it,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Capture exact pixels"}),jsxRuntime.jsx("small",{children:"Real screen \u2014 canvas, video & charts"})]})]}):null]})]}):null]})]}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsxs("div",{className:"lumen-fs-pill",role:"group","aria-label":"Tools and capture method",children:[dt?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn lumen-fs-pentog","data-on":!ke,onClick:()=>h(s=>!s),"aria-label":"Toggle markup tools",title:"Toggle markup tools",children:jsxRuntime.jsx(Ut,{})}),jsxRuntime.jsx("span",{className:"lumen-fs-pill-sep"})]}),jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>ee(s.value),children:jsxRuntime.jsx(g,{})},s.value)})]})})]}),!dt&&!ke?jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(Et,{label:"Arrow",icon:jsxRuntime.jsx($n,{}),active:J==="arrow",onClick:()=>I("arrow")}),jsxRuntime.jsx(Et,{label:"Box",icon:jsxRuntime.jsx(Wn,{}),active:J==="rect",onClick:()=>I("rect")}),jsxRuntime.jsx(Et,{label:"Draw",icon:jsxRuntime.jsx(Ut,{}),active:J==="freehand",onClick:()=>I("freehand")}),jsxRuntime.jsx(Et,{label:"Comment",icon:jsxRuntime.jsx(zn,{}),active:J==="comment",onClick:()=>I("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsxs("div",{className:"lumen-fs-color",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-color-btn",style:{background:$},"aria-label":"Pick colour","aria-haspopup":"true","aria-expanded":K,onClick:()=>re(s=>!s)}),K?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-color-overlay",onClick:()=>re(false)}),jsxRuntime.jsx("div",{className:"lumen-fs-color-pop",role:"group","aria-label":"Colour",children:Qn.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:s.value},"aria-label":s.label,"aria-pressed":$===s.value,onClick:()=>{G(s.value),re(false);}},s.value))})]}):null]}),mt?null:jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:er.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":s.label,"aria-pressed":W===s.value,onClick:()=>le(s.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:s.dot,height:s.dot}})},s.value))}),mt?null:jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>ue.current?.undo(),disabled:!Q.canUndo,"aria-label":"Undo",title:"Undo",children:jsxRuntime.jsx(Kn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>ue.current?.redo(),disabled:!Q.canRedo,"aria-label":"Redo",title:"Redo",children:jsxRuntime.jsx(qn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>ue.current?.reset(),disabled:!Q.canUndo,"aria-label":"Clear",title:"Clear",children:jsxRuntime.jsx(jn,{})})]}):null]}):null,jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Un,{ref:ue,screenshot:b.capture.blob,tool:J,color:$,strokeWidth:W,onDrawingChange:Fe,onHistoryChange:Ke})}),R===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>S&&ee(S),children:dt?"\u21BB Re-record":"\u21BB Recapture"}),nn?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(it,{})," Capture exact screen"]}):null,dt?ve?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ve.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:b.capture.method==="web-display-media"?"Exact screen captured":`${tr(S)} captured \xB7 switch method above anytime`})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-compose",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-grab",onClick:()=>x(s=>!s),"aria-label":w?"Expand sheet":"Minimize sheet"}),jsxRuntime.jsxs("div",{className:"lumen-fs-field",children:[jsxRuntime.jsx("input",{className:"lumen-input lumen-fs-desc",value:he,onChange:s=>V(s.target.value),placeholder:"Describe what's wrong \u2014 or use voice"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-mic",onClick:j,"aria-label":"Record voice note",children:jsxRuntime.jsx(zt,{})})]}),Jt("capture"),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-fs-next",onClick:Qt,disabled:rn,children:"Next"})]})]}):null]}):null]})}):null,R===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-rv-pane",children:[jsxRuntime.jsx("div",{className:"lumen-rv-scrim","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"lumen-rv",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-head",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-back",onClick:en,children:[jsxRuntime.jsx(Zn,{}),"Back"]}),jsxRuntime.jsx("span",{className:"lumen-rv-title",children:"Review & send"}),jsxRuntime.jsx("span",{className:"lumen-rv-spacer","aria-hidden":"true"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-rows",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Description"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 tap to edit"})]}),jsxRuntime.jsx("textarea",{className:"lumen-input lumen-rv-desc",value:he,onChange:s=>V(s.target.value),rows:2,placeholder:"Describe what's wrong\u2026"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Type"}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Type",children:ca.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":Oe===s.value,onClick:()=>He(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Priority"}),jsxRuntime.jsx("div",{className:"lumen-rv-prio",role:"group","aria-label":"Priority",children:da.filter(s=>s.value!=="").map(s=>jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-prio-opt","aria-pressed":be===s.value,onClick:()=>Me(be===s.value?"":s.value),children:[jsxRuntime.jsx(fa,{value:s.value}),s.label]},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Platform"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 auto-detected \u2014 change if wrong"})]}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Platform",children:ma.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":Ce===s.value,onClick:()=>oe(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-row",children:[jsxRuntime.jsx("span",{className:"lumen-rv-rk",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-rv-rv",children:[tr(S),Q.canUndo?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>T(1),children:"edit"})]})]}),Jt("describe"),jsxRuntime.jsx("div",{className:"lumen-rv-attachrow",children:ve?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ve.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:St,children:"\xD7"})]}):jsxRuntime.jsxs("label",{className:"lumen-rv-attach",children:[jsxRuntime.jsx(Ft,{}),"Attach a video",jsxRuntime.jsx("input",{type:"file",accept:"video/mp4,video/webm,video/quicktime",onChange:s=>{let g=s.currentTarget.files?.[0];g&&we({blob:g,durationMs:0}),s.currentTarget.value="";}})]})})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-rv-send",onClick:tn,disabled:H,children:H?qe<95?`Uploading ${qe}%\u2026`:"Almost done\u2026":jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xn,{}),"Send feedback"]})})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[H?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":qe,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${qe}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:R===1?n:en,className:"lumen-btn-ghost",disabled:H,children:R===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:Qt,className:"lumen-btn-primary",disabled:rn,children:$r})]})]})]})})}function tr(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function ha({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 ba({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:ga()?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 ga(){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 Et({label:e,active:t,onClick:n,icon:r}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,"aria-label":r?e:void 0,title:e,children:r??e})}function va({onDismiss:e}){let t=Fn.useRef(null),n=Fn.useRef(0),r=Fn.useRef(null);function o(u){u.currentTarget.setPointerCapture(u.pointerId),t.current=u.clientY,n.current=performance.now(),r.current=u.currentTarget.parentElement;}function a(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current);r.current.style.transform=`translateY(${d}px)`;}function i(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current),c=Math.max(1,performance.now()-n.current),m=d/c;r.current.style.transform="",r.current.style.transition="",t.current=null,(d>80||m>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function wa({stream:e}){let t=Fn.useRef(null);return Fn.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 u=window.AudioContext??window.webkitAudioContext;if(!u)return;let d=new u,c=d.createMediaStreamSource(e),m=d.createAnalyser();m.fftSize=1024,m.smoothingTimeConstant=.6,c.connect(m);let p=new Uint8Array(m.fftSize),C=18,v=3,y=3,R=Math.max(2,(o-v*(C-1))/C),T=Math.min(R/2,3),S=new Array(C).fill(0),L=0,b=false;function E(){if(b)return;m.getByteTimeDomainData(p);let H=Math.floor(p.length/C);i.clearRect(0,0,o,a),i.fillStyle=Ca("--lumen-danger")||"rgb(239,68,68)";for(let N=0;N<C;N++){let F=0;for(let W=0;W<H;W++){let le=Math.abs((p[N*H+W]??128)-128);le>F&&(F=le);}let A=Math.min(1,F/128*1.8),J=S[N]??0;S[N]=A>J?A:J+(A-J)*.35;let I=Math.max(y,S[N]*a),$=N*(R+v),G=(a-I)/2;ya(i,$,G,R,I,T),i.fill();}L=requestAnimationFrame(E);}return L=requestAnimationFrame(E),()=>{b=true,cancelAnimationFrame(L);try{c.disconnect();}catch{}d.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function ya(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 Ea({blob:e,durationMs:t}){let[n,r]=Fn.useState("");return Fn.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 Ca(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var ka='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ra(e){return Array.from(e.querySelectorAll(ka)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var Ct=class extends Fn__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 ir({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Fn.useState(false);if(Fn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(xa,{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 xa({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Fn.useState(0);Fn.useEffect(()=>{let u=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));u();let d=window.setInterval(u,250);return ()=>window.clearInterval(d)},[e,t]);let i=u=>`${Math.floor(u/60)}:${String(u%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 sr({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Fn.useState(false);if(Fn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,u=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:[u?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(it,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:u?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:u,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:u,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Gt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function lr(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function ur(e){return e instanceof Error?e:new Error(String(e))}function cr(e,t,n){let r=false,o=false,a=false,i=null;function u(){o||(o=true,n.onCancelled());}function d(m){o||(o=true,n.onResult(m));}function c(m){o||(o=true,n.onError(m));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(m=>{if(i=m,r){try{m.cancel();}catch{}u();return}if(n.onActive(m),a){n.onProcessing();try{m.stop();}catch{}}Promise.resolve(m.result).then(p=>{r?u():d(p);}).catch(p=>{r||lr(p)?u():c(ur(p));});}).catch(m=>{r||lr(m)?u():c(ur(m));}),{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{}u();}}}}function dr(){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 u=document.elementsFromPoint(i,n);for(let d of u){if(o.has(d))continue;o.add(d);let c=window.getComputedStyle(d);if(c.position!=="fixed"&&c.position!=="sticky")continue;let m=d.getBoundingClientRect();m.bottom<t-8||m.bottom>t+8||m.width<e*.6||m.height>a&&(a=m.height);}}return a}function Zt(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 u of Array.from(i)){let d=u.getBoundingClientRect();if(d.height===0||d.width===0)continue;let c=0;switch(t){case "bottom":if(d.bottom<r-8)break;c=Math.max(0,r-d.top);break;case "top":if(d.top>8)break;c=Math.max(0,d.bottom);break;case "left":if(d.left>8)break;c=Math.max(0,d.right);break;case "right":if(d.right<n-8)break;c=Math.max(0,n-d.left);break}c>o&&(o=c);}}return o}function mr(e){let[t,n]=Fn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Fn.useRef(t),o=Da(e.avoid),a=e.placement,i=e.offset.x,u=e.offset.y;return Fn.useEffect(()=>{if(typeof window>"u")return;let d=0,c=false,m=()=>{if(d=0,c)return;let R=a[0]==="b"?"bottom":"top",T=a[1]==="r"?"right":"left",S=0,L=0;e.avoid==="auto"&&R==="bottom"?S=dr():Array.isArray(e.avoid)&&(S=Zt(e.avoid,R),L=Zt(e.avoid,T));let b={bottom:R==="bottom"?u+S:0,top:R==="top"?u+S:0,right:T==="right"?i+L:0,left:T==="left"?i+L:0},E=r.current;(b.bottom!==E.bottom||b.top!==E.top||b.right!==E.right||b.left!==E.left)&&(r.current=b,n(b));},p=()=>{d||(d=window.requestAnimationFrame(m));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let v=typeof MutationObserver<"u"?new MutationObserver(p):null;v?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let y=window.visualViewport;return y?.addEventListener("resize",p),y?.addEventListener("scroll",p),()=>{c=true,d&&window.cancelAnimationFrame(d),C?.disconnect(),v?.disconnect(),window.removeEventListener("resize",p),y?.removeEventListener("resize",p),y?.removeEventListener("scroll",p);}},[a,i,u,o]),t}function Da(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var pr=["mousedown","touchstart"];function Ye(e){let t=Fn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Fn.useRef(e.onClick);n.current=e.onClick;let r=Fn.useRef(e.isolate??true);r.current=e.isolate??true;let o=Fn.useRef(null);return Fn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=c=>{r.current&&c.stopPropagation(),t.current?.(c);},u=c=>{r.current&&c.stopPropagation(),n.current(c);},d=c=>{r.current&&c.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",u);for(let c of pr)a.addEventListener(c,d,c==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",u);for(let c of pr)a.removeEventListener(c,d);};},[])}function gr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[u,d]=Fn.useState(null),c=Fn.useRef(null),m=mr(e),p=ot(e.keyboard!=="off",i),C=Ye({onPointerDown:r,onClick:o,isolate:a}),v=Fn.useCallback(A=>{c.current=A,C(A);},[C]);Fn.useEffect(()=>{typeof document>"u"||d(t??document.body);},[t]);let y=e.placement,R=y[0]==="b"?"bottom":"top",T=y[1]==="r"?"right":"left",S=R==="bottom",L=p.open&&S&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,b=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&S&&p.inset<=0);if(Fa(c,!n&&!b),!u)return null;let E=R==="bottom"?m.bottom:m.top,H=T==="right"?m.right:m.left,N=n||b,F={position:"fixed",[R]:e.safeArea?`calc(${E}px + env(safe-area-inset-${R}, 0px))`:`${E}px`,[T]:e.safeArea?`calc(${H}px + env(safe-area-inset-${T}, 0px))`:`${H}px`,zIndex:e.zIndex,transform:L?`translateY(-${L}px)`:void 0,opacity:N?0:1,pointerEvents:N?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:v,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:F,"aria-label":e.label,"aria-hidden":N?true:void 0,tabIndex:N?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),u)}function Fa(e,t){let n=Fn.useRef(false);Fn.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,u=a.top+a.height/2,d=document.elementsFromPoint(i,u),c=fr(window.getComputedStyle(o).zIndex);for(let m of d){if(m===o||o.contains(m))continue;if(fr(window.getComputedStyle(m).zIndex)>c){n.current=true,console.warn("[lumen] trigger is occluded by",m);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function fr(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function vr({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=Fn.useState(null),d=Ye({onPointerDown:r,onClick:o,isolate:a});return Fn.useEffect(()=>{if(typeof document>"u")return;let c=e instanceof HTMLElement?e:e.current??null;u(c);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:d,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 Er({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=Fn.useState(null),[d,c]=Fn.useState(false),m=Fn.useRef(null),p=Ye({onPointerDown:T=>{r?.(T),m.current={x:T.clientX,y:T.clientY},c(true);let S=T.currentTarget;try{S?.setPointerCapture?.(T.pointerId);}catch{}},onClick:o,isolate:a});if(Fn.useEffect(()=>{typeof document>"u"||u(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${d?" lumen-notch-expanded":""}`;function v(T){let S=m.current;if(!S)return;let L=T.clientX-S.x,b=T.clientY-S.y;(e.edge==="top"&&b>16||e.edge==="bottom"&&b<-16||e.edge==="right"&&L<-16||e.edge==="left"&&L>16)&&(m.current=null,o(T.nativeEvent));}function y(){m.current=null,c(false);}function R(){m.current=null,c(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:C,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:v,onPointerUp:y,onPointerCancel:R,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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 Cr(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function Xa(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function kr(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:Xa(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var ei={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function Rr(e){let t=Fn.useId();Fn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${ti(t)}`,o={},a=(i,u)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,u);};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,u]of Object.entries(ei)){let d=e[u];typeof d=="string"&&d.length>0&&a(i,d);}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,u]of Object.entries(o))i.startsWith("--")?u?n.style.setProperty(i,u):n.style.removeProperty(i):u==null?n.removeAttribute(i):n.setAttribute(i,u);}},[e,t]);}function ti(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Sr=Symbol.for("lumen.history.patched"),Xt="lumen:locationchange";function oi(){if(typeof window>"u")return;let e=window;if(e[Sr])return;e[Sr]=true;let t=()=>window.dispatchEvent(new Event(Xt)),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 xr(e){let[t,n]=Fn.useState(false);return Fn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;oi();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Xt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Xt,r),window.removeEventListener("popstate",r);}},[e]),t}var si=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function Mr(){let[e,t]=Fn.useState(false);return Fn.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||"";si.some(a=>o.includes(a))&&t(true);},[]),e}var Tr="lumen.config.v1.",ci=3600*1e3;function Lr(e,t){let[n,r]=Fn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Fn.useEffect(()=>{if(typeof window>"u")return;let o=bi(e);o&&r({trigger:o.trigger,enabled:Pr(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),u=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(u,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.json(),m=Nr(c.trigger);if(!m)throw new Error("Malformed config response");let p=pi(c.trigger),C=Ar(c.brand);gi(e,m,p,C),r({trigger:m,enabled:Pr(m),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(d=>d.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:d);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Pr(e){return e.kind!=="headless"}var di=["br","bl","tr","tl"],mi=["top","right","bottom","left"];function Nr(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:di.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:mi.find(o=>o===t.edge)??"top",label:n}:null}function pi(e){return !e||typeof e!="object"?false:e.shake===true}var fi=/^#[0-9a-fA-F]{6}$/,hi=["auto","light","dark"];function Ar(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&fi.test(t.accent)?t.accent:null;if(!n)return null;let r=hi.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 bi(e){try{let t=window.localStorage.getItem(Tr+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>ci)return null;let r=Nr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:Ar(n.brand)}:null}catch{return null}}function gi(e,t,n,r){try{window.localStorage.setItem(Tr+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function wi(e){if(e&&typeof e=="object")return e.type===vt;if(typeof e=="string")try{return JSON.parse(e).type===vt}catch{return false}return false}function yi(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(u,d,c,m){if(!a)return a={x:u,y:d,z:c,t:m},false;if(m-a.t<o)return false;let p=Math.abs(u-a.x)+Math.abs(d-a.y)+Math.abs(c-a.z);return a={x:u,y:d,z:c,t:m},p<t?false:(i=i.filter(C=>m-C<r),i.push(m),i.length>=n?(i=[],true):false)}}}function Ir(e,t,n){Fn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let m=Date.now();n||m-r<o||(r=m,t());}let i=m=>{wi(m.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let u=yi(),d=m=>{let p=m.accelerationIncludingGravity??m.acceleration;!p||p.x==null||p.y==null||p.z==null||u.push(p.x,p.y,p.z,Date.now())&&a();},c=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return c&&window.addEventListener("devicemotion",d),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),c&&window.removeEventListener("devicemotion",d);}},[e,t,n]);}var Or="https://shakebugs.vercel.app",Rt=60;function Hr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function ki({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:u,portalTarget:d,capture:c,record:m,shakeToOpen:p,onOpenChange:C,beforeOpen:v,onTriggerActivate:y,isolateEvents:R=true,keyboardInset:T,suppressTrigger:S=false,children:L}){let[b,E]=Fn.useState(false),[H,N]=Fn.useState(false),[F,A]=Fn.useState(null),[J,I]=Fn.useState(null),[$]=Fn.useState(false),[G]=Fn.useState(null),W=Fn.useRef(false),le=Fn.useRef(false),he=Fn.useRef(null),V=Fn.useMemo(()=>new vn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Fn.useEffect(()=>{Ln({ignoreUrlPrefix:(t??Or).replace(/\/$/,"")});},[t]);let Oe=Fn.useRef(C);Oe.current=C,Fn.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 He=Fn.useRef(null);Fn.useEffect(()=>{if(He.current===b)return;let k=He.current;He.current=b,k!==null&&Oe.current?.(b);},[b]);let be=Fn.useRef(v);be.current=v;let Me=Fn.useRef(y);Me.current=y;let Ce=Fn.useCallback(k=>{le.current=true,he.current=Promise.resolve().then(()=>be.current?.(k)).then(()=>Me.current?.(k)).then(()=>{});},[]),oe=Fn.useCallback(k=>{W.current||b||Re.current||ue.current||(W.current=true,N(true),A(null),I(null),(async()=>{try{if(le.current?await he.current:(await be.current?.(k),await Me.current?.(k)),c?.mode==="manual")A(null),I(null);else if(c?.provider)A(null),I(null);else {let z=await bt({...c,mode:c?.mode??"auto",target:c?.target??document.documentElement});A(z);}}catch(z){I(z instanceof Error?z:new Error(String(z)));}finally{le.current=false,he.current=null,W.current=false,N(false),E(true);}})());},[c,b]),ke=Fn.useCallback(()=>{E(false),A(null),I(null);},[]),h=Fn.useCallback(V.submit.bind(V),[V]),[w,x]=Fn.useState(0),P=Fn.useCallback(()=>{W.current=false,N(false),E(false),A(null),I(null),x(k=>k+1);},[]),[_,K]=Fn.useState(null),[re,q]=Fn.useState(null),pe=Fn.useRef(null),ge=Fn.useRef(null),Re=Fn.useRef(false),U=Fn.useRef(null),Pe=Fn.useRef(null),ae=Fn.useRef(null),Se=Fn.useCallback((k,z=false)=>{if(pe.current=null,ge.current=null,Re.current=false,K(null),!k){U.current=null;return}Pe.current={blob:k.blob,durationMs:k.durationMs,poster:U.current,deriveBlobPoster:z},U.current=null,E(true);},[]);Fn.useEffect(()=>{if(!b)return;if(!m?.provider){q(null);return}let k=m.isAvailable;if(!k){q(true);return}let z=false;return Promise.resolve().then(()=>k()).then(j=>{z||q(j);}).catch(()=>{z||q(false);}),()=>{z=true;}},[b,m?.provider,m?.isAvailable]);let lt=Gt({hasProvider:!!m?.provider,providerAvailable:re,hasGetDisplayMedia:Hr()}).canRecord,Be=Fn.useCallback(async()=>{if(Re.current)return;if(ae.current=null,Gt({hasProvider:!!m?.provider,providerAvailable:re,hasGetDisplayMedia:Hr()}).usingProvider&&m?.provider){Re.current=true,U.current=null,E(false),ge.current=cr(m.provider,{maxDurationSeconds:Rt},{onStarting:()=>K({phase:"starting"}),onActive:j=>{K({phase:"recording",stream:j.stream??null,startedAt:Date.now(),maxSeconds:Rt}),j.stream&&Wt(j.stream).then(Xe=>{U.current=Xe;}).catch(()=>{});},onProcessing:()=>K({phase:"processing"}),onResult:j=>Se({blob:j.blob,durationMs:j.durationMs},true),onCancelled:()=>{ge.current=null,Re.current=false,U.current=null,K(null),A(null),I(null),E(true);},onError:j=>{ge.current=null,Re.current=false,U.current=null,K(null),ae.current=j.message||"Screen recording could not start.",E(true);}});return}if(pe.current)return;let z=await Dn(Rt);pe.current=z,Re.current=true,U.current=null,K({phase:"recording",stream:z.stream,startedAt:Date.now(),maxSeconds:Rt}),E(false),Wt(z.stream).then(j=>{U.current=j;}).catch(()=>{}),z.result.then(j=>Se(j)).catch(()=>Se(null));},[Se,m?.provider,re]),ve=Fn.useCallback(()=>{ge.current?ge.current.stop():pe.current?.stop();},[]),we=Fn.useCallback(()=>{if(ge.current){ge.current.cancel();return}let k=pe.current;pe.current=null,Re.current=false,U.current=null,K(null),k?.cancel(),A(null),I(null),E(true);},[]),ut=Fn.useCallback(()=>{let k=Pe.current;return Pe.current=null,k},[]),_e=Fn.useCallback(()=>{let k=ae.current;return ae.current=null,k},[]);Fn.useEffect(()=>{b||(ae.current=null);},[b]);let[xe,Fe]=Fn.useState(null),Q=Fn.useRef(null),Ke=Fn.useRef(null),ue=Fn.useRef(false),Te=Fn.useCallback(()=>{let k=Q.current;Q.current=null,ue.current=false,k?.stop(),Fe(null),E(true);},[]),Ue=Fn.useCallback(()=>{let k=Q.current;k&&(Fe({phase:"grabbing"}),(async()=>{try{let z=await k.grab();if(Q.current!==k)return;Ke.current=z,Q.current=null,ue.current=!1,k.stop(),Fe(null),E(!0);}catch{if(Q.current!==k)return;Q.current=null,ue.current=false,k.stop(),Fe(null),sonner.toast.error("Could not capture the screen. Please try again."),E(true);}})());},[]),Ge=Fn.useCallback(async()=>{if(ue.current)return;let k;try{k=await Nt({...c});}catch{return}Q.current=k,ue.current=true,k.onEnded(()=>Te()),Fe({phase:"live"}),E(false);},[c,Te]),Ze=Fn.useCallback(()=>{let k=Ke.current;return Ke.current=null,k},[]);Fn.useEffect(()=>()=>{Q.current?.stop(),Q.current=null;},[]);let Le=Mr(),ye=xr(i),Ne=Lr(a?"":e,t??Or);Rr(u??xi(Ne.brand));let Ve=p??Ne.shakeToOpen;Ir(Ve,oe,b);let ct=Fn.useMemo(()=>({client:V,user:n,isOpen:b,isSubmitting:$,error:G,open:oe,close:ke,openCapture:oe,closeCapture:ke,submit:h,isNativeShell:Le,capture:c,initialCapture:F,initialCaptureError:J,isOpening:H,startVideoSession:Be,stopVideoSession:ve,cancelVideoSession:we,recording:_,consumePendingVideo:ut,canRecordScreen:lt,consumeRecordStartError:_e,startScreenCaptureSession:Ge,grabScreenCaptureFrame:Ue,cancelScreenCaptureSession:Te,screenCapture:xe,consumePendingScreenshot:Ze,isolateEvents:R,keyboardInset:T}),[V,n,b,$,G,oe,ke,h,Le,c,F,J,Be,ve,we,_,ut,lt,_e,Ge,Ue,Te,xe,Ze,H,R,T]),ee=Si({explicit:a,remote:Ne.trigger,remoteLoading:Ne.loading,floatingButton:o});return jsxRuntime.jsxs(Ot.Provider,{value:ct,children:[L,jsxRuntime.jsxs(Ct,{onReset:P,onError:k=>V.reportClientError({...k,context:{open:b,opening:H,screenCapturePhase:xe?.phase,recordingPhase:_?.phase,initialCaptureMethod:F?.method,initialCapturePixelRatio:F?.pixelRatio,initialCaptureViewport:F?.viewport,hadInitialCaptureError:J!=null}}),children:[ee?.kind==="floating"?jsxRuntime.jsx(gr,{config:kr(ee),portalTarget:d,hidden:ye||S||H||_!=null||xe!=null,onPointerDown:Ce,onClick:k=>oe(k),isolateEvents:R,keyboardInset:T}):null,ee?.kind==="notch"?jsxRuntime.jsx(Er,{config:Cr(ee),portalTarget:d,hidden:ye||S||H||_!=null||xe!=null,onPointerDown:Ce,onClick:k=>oe(k),isolateEvents:R}):null,ee?.kind==="inline"?jsxRuntime.jsx(vr,{mount:ee.mount,label:ee.label??"Feedback",icon:ee.icon,onPointerDown:Ce,onClick:k=>oe(k),isolateEvents:R}):null,xe?jsxRuntime.jsx(sr,{state:xe,portalTarget:d,onCapture:Ue,onCancel:Te}):null,_?jsxRuntime.jsx(ir,{state:_,portalTarget:d,onStop:ve,onCancel:we}):null,jsxRuntime.jsx(Yt,{})]},w),jsxRuntime.jsx(Ri,{})]})}function Ri(){let[e,t]=Fn.useState(false);return Fn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Si(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function xi(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Mi({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=nt(),u=["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:u,"data-lumen-trigger":"",onClick:d=>{o?.(d),d.defaultPrevented||i(d.nativeEvent);},...a,children:r})}
5
+ exports.CaptureModal=Yt;exports.FeedbackButton=Mi;exports.LUMEN_KEYBOARD_CSS_VAR=It;exports.LUMEN_KEYBOARD_EVENT=tt;exports.LUMEN_SHAKE_MESSAGE=vt;exports.LumenProvider=ki;exports.createNativeCaptureProvider=Bo;exports.isLumenEventTarget=Ao;exports.isolateLumenEvents=Io;exports.readLumenKeyboardInset=Dt;exports.setLumenKeyboardInset=qo;exports.useKeyboardInset=ot;exports.useLumen=nt;//# sourceMappingURL=index.cjs.map
6
6
  //# sourceMappingURL=index.cjs.map