@fkn/lib 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,73 +0,0 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { A as t, B as n, C as r, D as i, E as a, F as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, _ as g, a as _, b as v, c as y, d as b, f as x, g as S, h as C, i as w, j as T, k as E, l as D, n as O, o as k, p as A, r as j, s as M, t as N, u as P, v as F, w as I, x as L, y as R, z } from "./proxy-Bhk4X3xo.js";
3
- import { t as B } from "./api-Bhz3iB9m.js";
4
- import { available as V, fetch as H } from "./desktop.js";
5
- //#region src/lib/extension-prompt.ts
6
- var U = async (e) => {
7
- if (typeof window > "u") return !1;
8
- if (l()) return !0;
9
- let t = await B, n = null, r = new Promise((e) => {
10
- n = () => {
11
- l() && e(!0);
12
- }, T.addEventListener("statuschange", n);
13
- }), i = t.installPrompt.show(e).then(() => !1), a = await Promise.race([r, i]);
14
- return n && T.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
15
- }, W = null;
16
- u(() => (W ||= U().then(() => void 0).finally(() => {
17
- W = null;
18
- }), W));
19
- //#endregion
20
- //#region src/lib/auto.ts
21
- var G = () => typeof document < "u" && l(), K = async (e, t) => {
22
- if (O(e), t?.credentials === "include") {
23
- if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
24
- return h(e, t);
25
- }
26
- return G() ? h(e, {
27
- ...t,
28
- credentials: "omit"
29
- }) : V() ? H(e, t) : N(e, t);
30
- }, q = /* @__PURE__ */ e({
31
- ATTACH_FRAME_EVENT_KEY: () => w,
32
- LOCATOR_DENIED: () => F,
33
- LOCATOR_ERROR: () => x,
34
- LOCATOR_UNSUPPORTED: () => g,
35
- assertAttachableFrameUrl: () => D,
36
- assertFetchableUrl: () => I,
37
- assertLockdownApplicable: () => P,
38
- attachFrame: () => _,
39
- attachFramePermission: () => k,
40
- available: () => G,
41
- box: () => s,
42
- cookies: () => m,
43
- createFrame: () => M,
44
- createVideoElementHandle: () => c,
45
- events: () => T,
46
- extension: () => T,
47
- fetch: () => h,
48
- fetchCredentialedPermission: () => a,
49
- fetchLocalPermission: () => i,
50
- fetchPermission: () => d,
51
- gotoPermission: () => y,
52
- handleRevivableModules: () => o,
53
- isBlockedFetchUrl: () => E,
54
- isBlockedFrameUrl: () => b,
55
- isExtensionExposed: () => l,
56
- isLocalNetworkUrl: () => t,
57
- isLocatorDenied: () => A,
58
- isLocatorUnsupported: () => S,
59
- isTerminalError: () => C,
60
- isType: () => p,
61
- modifyRequestHeadersPermission: () => R,
62
- permissions: () => j,
63
- promptInstall: () => U,
64
- readCookiePermission: () => r,
65
- removeRequestHeaderRule: () => v,
66
- revive: () => z,
67
- setMissingExtensionHandler: () => u,
68
- setRequestHeaderRule: () => L,
69
- type: () => n,
70
- waitForExtensionExposure: () => f
71
- });
72
- //#endregion
73
- export { U as i, K as n, G as r, q as t };
@@ -1 +0,0 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./proxy-BEz2K6e4.cjs"),n=require("./api-C75xqLFy.cjs"),r=require("./desktop.cjs");var i=async e=>{if(typeof window>`u`)return!1;if(t.M())return!0;let r=await n.t,i=null,a=new Promise(e=>{i=()=>{t.M()&&e(!0)},t.j.addEventListener(`statuschange`,i)}),o=r.installPrompt.show(e).then(()=>!1),s=await Promise.race([a,o]);return i&&t.j.removeEventListener(`statuschange`,i),await r.installPrompt.hide().catch(()=>{}),s},a=null;t.N(()=>(a||=i().then(()=>void 0).finally(()=>{a=null}),a));var o=()=>typeof document<`u`&&t.M(),s=async(e,n)=>{if(t.n(e),n?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return t.T(e,n)}return o()?t.T(e,{...n,credentials:`omit`}):r.available()?r.fetch(e,n):t.t(e,n)},c=e.t({ATTACH_FRAME_EVENT_KEY:()=>t.i,LOCATOR_DENIED:()=>t.v,LOCATOR_ERROR:()=>t.f,LOCATOR_UNSUPPORTED:()=>t._,assertAttachableFrameUrl:()=>t.l,assertFetchableUrl:()=>t.w,assertLockdownApplicable:()=>t.u,attachFrame:()=>t.a,attachFramePermission:()=>t.o,available:()=>o,box:()=>t.I,cookies:()=>t.S,createFrame:()=>t.s,createVideoElementHandle:()=>t.L,events:()=>t.j,extension:()=>t.j,fetch:()=>t.T,fetchCredentialedPermission:()=>t.E,fetchLocalPermission:()=>t.D,fetchPermission:()=>t.O,gotoPermission:()=>t.c,handleRevivableModules:()=>t.F,isBlockedFetchUrl:()=>t.k,isBlockedFrameUrl:()=>t.d,isExtensionExposed:()=>t.M,isLocalNetworkUrl:()=>t.A,isLocatorDenied:()=>t.p,isLocatorUnsupported:()=>t.g,isTerminalError:()=>t.h,isType:()=>t.R,modifyRequestHeadersPermission:()=>t.y,permissions:()=>t.r,promptInstall:()=>i,readCookiePermission:()=>t.C,removeRequestHeaderRule:()=>t.b,revive:()=>t.z,setMissingExtensionHandler:()=>t.N,setRequestHeaderRule:()=>t.x,type:()=>t.B,waitForExtensionExposure:()=>t.P});Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
@@ -1,16 +0,0 @@
1
- import { $ as fetch$1, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-pr5vLVVT.js";
2
-
3
- //#region src/lib/extension-prompt.d.ts
4
- declare const promptInstall: (reason?: string) => Promise<boolean>;
5
- //#endregion
6
- //#region src/lib/auto.d.ts
7
- declare const isExtensionAvailable: () => boolean;
8
- declare const fetch: (input: RequestInfo | URL, init?: RequestInit & {
9
- reason?: string;
10
- render?: boolean;
11
- }) => Promise<Response>;
12
- declare namespace extension_d_exports {
13
- export { ATTACH_FRAME_EVENT_KEY, AttachFrameOptions, BoxedVideoElement, CookieDetails, Executor, FetchInit, Frame, FrameBackend, Gate, GateTools, GotoOptions, HeaderOperation, LOCATOR_DENIED, LOCATOR_ERROR, LOCATOR_UNSUPPORTED, Locator, OperationRequest, PermissionGrant, PermissionRequest, ProxyFetchRequest, RemoteVideoElement, RequestHeaderRule, SelectorPart, SiteCookie, VideoElementState, assertAttachableFrameUrl, assertFetchableUrl, assertLockdownApplicable, attachFrame, attachFramePermission, isExtensionAvailable as available, box, cookies, createFrame, createVideoElementHandle, extension as events, extension, fetch$1 as fetch, fetchCredentialedPermission, fetchLocalPermission, fetchPermission, gotoPermission, handleRevivableModules, isBlockedFetchUrl, isBlockedFrameUrl, isExtensionExposed, isLocalNetworkUrl, isLocatorDenied, isLocatorUnsupported, isTerminalError, isType, modifyRequestHeadersPermission, permissions, promptInstall, readCookiePermission, removeRequestHeaderRule, revive, setMissingExtensionHandler, setRequestHeaderRule, type, waitForExtensionExposure };
14
- }
15
- //#endregion
16
- export { promptInstall as i, fetch as n, isExtensionAvailable as r, extension_d_exports as t };
@@ -1,53 +0,0 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-C75xqLFy.cjs");let n=require("osra");var r=(e,t)=>{let n=new EventTarget,r=new Map,i=EventTarget.prototype.addEventListener.bind(n),a=EventTarget.prototype.removeEventListener.bind(n);return Object.defineProperty(n,"addEventListener",{configurable:!0,value:(a,o,s)=>{if(o!==null){if(!r.has(a)){let i=r=>{n.dispatchEvent(new CustomEvent(a,{detail:t(r,e),bubbles:r.bubbles,cancelable:r.cancelable,composed:r.composed}))};e.addEventListener(a,i),r.set(a,i)}i(a,o,s)}}}),Object.defineProperty(n,"removeEventListener",{configurable:!0,value:(t,n,i)=>{if(n===null)return;a(t,n,i);let o=r.get(t);o&&(e.removeEventListener(t,o),r.delete(t))}}),n},i=e=>typeof e==`boolean`?+!!e:+!!e?.capture,a=e=>{let t=new WeakMap;return{addEventListener:(n,r,a)=>{if(r===null)return;let o=`${n}|${i(a)}`,s=t.get(r);if(s||(s=new Map,t.set(r,s)),s.has(o))return;let c=typeof a==`object`&&!!a&&!!a.once,l=t=>{c&&s.delete(o);let i=e.unenrich(t,n);typeof r==`function`?r.call(e.target,i):r.handleEvent(i)};s.set(o,l),e.remoteEvents.addEventListener(n,l,a)},removeEventListener:(n,r,a)=>{if(r===null)return;let o=`${n}|${i(a)}`,s=t.get(r),c=s?.get(o);c&&(e.remoteEvents.removeEventListener(n,c,a),s.delete(o))},dispatchEvent:t=>e.remoteEvents.dispatchEvent(t)}},o=e.t({box:()=>w,createVideoElementHandle:()=>S,isType:()=>C,revive:()=>T,type:()=>s}),s=`videoElement`,c=[`currentTime`,`volume`,`muted`,`playbackRate`,`src`,`loop`,`autoplay`,`preload`,`poster`,`disableRemotePlayback`],l=[`duration`,`paused`,`ended`,`seeking`,`readyState`,`currentSrc`],u=[`buffered`,`seekable`],d=Symbol.for(`fkn.remoteVideoElement`),f=Symbol.for(`fkn.remoteVideoElement.state`),p=Symbol.for(`fkn.remoteVideoElement.controller`),m=e=>e?Array.from({length:e.length},(t,n)=>[e.start(n),e.end(n)]):[],h=e=>{let t={};for(let n of[...c,...l])t[n]=e[n];for(let n of u)t[n]=m(e[n]);return t.error=e.error?{code:e.error.code,message:e.error.message}:null,t},g=e=>{let t=t=>{if(!Number.isInteger(t)||t<0||t>=e.length)throw new DOMException(`Index or size is negative or greater than the allowed amount`,`IndexSizeError`)};return{get length(){return e.length},start(n){return t(n),e[n][0]},end(n){return t(n),e[n][1]}}},_=e=>e?{code:e.code,message:e.message,MEDIA_ERR_ABORTED:1,MEDIA_ERR_NETWORK:2,MEDIA_ERR_DECODE:3,MEDIA_ERR_SRC_NOT_SUPPORTED:4}:null,v=e=>r(e,(e,t)=>({originalDetail:e instanceof CustomEvent?e.detail:null,snapshot:h(t)})),y=async(e,t)=>{switch(t){case`play`:return await e.play(),null;case`pause`:return e.pause(),null;case`load`:return e.load(),null;case`requestPictureInPicture`:if(typeof e.requestPictureInPicture!=`function`)throw Error(`requestPictureInPicture is not supported in this environment`);return await e.requestPictureInPicture(),null;case`exitPictureInPicture`:{let t=e.ownerDocument;if(typeof t?.exitPictureInPicture!=`function`)throw Error(`exitPictureInPicture is not supported in this environment`);return await t.exitPictureInPicture(),null}default:throw Error(`videoElement: unknown method "${t}"`)}},b=e=>({call:async t=>y(e,t),set:async(t,n)=>{try{e[t]=n}catch{}return h(e)},events:v(e)}),x=(e,t)=>{let n=new EventTarget;Object.defineProperty(n,d,{value:!0}),Object.defineProperty(n,f,{value:e}),Object.defineProperty(n,p,{value:t});let r=a({target:n,remoteEvents:t.events,unenrich:(t,n)=>{if(!(t instanceof CustomEvent))return t;let r=t.detail;if(!r||!(`snapshot`in r))return t;Object.assign(e,r.snapshot);let i={bubbles:t.bubbles,cancelable:t.cancelable,composed:t.composed};return r.originalDetail===null?new Event(n,i):new CustomEvent(n,{...i,detail:r.originalDetail})}}),i={addEventListener:{configurable:!0,value:r.addEventListener},removeEventListener:{configurable:!0,value:r.removeEventListener},dispatchEvent:{configurable:!0,value:r.dispatchEvent},error:{configurable:!0,enumerable:!0,get(){return _(e.error)}},play:{configurable:!0,value:()=>t.call(`play`,[])},pause:{configurable:!0,value:()=>{t.call(`pause`,[]).catch(()=>{})}},load:{configurable:!0,value:()=>{t.call(`load`,[]).catch(()=>{})}},requestPictureInPicture:{configurable:!0,value:()=>t.call(`requestPictureInPicture`,[])},exitPictureInPicture:{configurable:!0,value:()=>t.call(`exitPictureInPicture`,[])},HAVE_FUTURE_DATA:{enumerable:!0,value:3},HAVE_ENOUGH_DATA:{enumerable:!0,value:4}};for(let n of c)i[n]={configurable:!0,enumerable:!0,get(){return e[n]},set(r){e[n]=r,t.set(n,r).then(t=>{Object.assign(e,t)},()=>{})}};for(let t of l)i[t]={configurable:!0,enumerable:!0,get(){return e[t]}};for(let t of u)i[t]={configurable:!0,enumerable:!0,get(){return g(e[t])}};return Object.defineProperties(n,i),n},S=e=>x(h(e),b(e)),C=e=>typeof e==`object`&&!!e&&e[d]===!0,w=(e,t)=>{let r=e;return{...n.BoxBase,type:s,initialState:r[f],controller:(0,n.recursiveBox)(r[p],t)}},T=(e,t)=>{let r=(0,n.recursiveRevive)(e.controller,t);return x({...e.initialState},r)},E=e=>[o,...e],ee=`FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY`,te=`fknExtension`,D=(0,n.createTypedEventTarget)();typeof document<`u`&&document.addEventListener(ee,()=>{D.dispatchEvent(new CustomEvent(`statuschange`,{detail:{enabled:O()}}))});var O=()=>typeof document>`u`?!1:document.documentElement.dataset[te]===`true`,k=null,ne=e=>{k=e},re=150,A=(e=1e3)=>new Promise((t,n)=>{if(O())return t();let r,i=e=>{clearTimeout(r),s.disconnect(),document.removeEventListener(`readystatechange`,c),e()},a=()=>i(async()=>{if(k&&(await k().catch(()=>{}),O()))return t();n(Error(`The FKN WebExtension is not installed, enabled or not exposed on this page.`))}),o=()=>{clearTimeout(r),r=setTimeout(()=>O()?i(t):a(),re)},s=new MutationObserver(()=>{O()&&i(t)}),c=()=>{document.readyState===`complete`&&!O()&&o()};if(r=setTimeout(a,e),s.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,c),document.readyState===`complete`)return o();O()&&i(t)}),j,M=new Proxy({},{get:(e,t)=>async(...e)=>{await A(),j??=(0,n.expose)({},{transport:window,revivableModules:E});let r=(await j)[t];return r(...e)}}),ie={scope:`network.fetch`,category:`network`,severity:0,title:`Fetch data from other sites`,description:`Lets the app download public data from other websites directly, past the usual cross-origin limits.`},ae={scope:`network.fetchCredentialed`,category:`network`,severity:3,unsafe:!0,title:`Fetch from other sites, signed in as you`,description:`Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see.`},oe={scope:`network.fetchLocal`,category:`network`,severity:3,unsafe:!0,title:`Access devices on your local network`,description:`Lets the app reach devices and services on your home or work network, which websites normally cannot touch.`},se=e=>{let t=e.match(/^(\d+)\.(\d+)\.\d+\.\d+$/);if(!t)return!1;let[n,r]=[Number(t[1]),Number(t[2])];return n===10||n===127||n===0||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168},ce=e=>{let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.replace(/^\[|\]$/g,``).toLowerCase().replace(/\.$/,``);return n===`localhost`||n.endsWith(`.localhost`)||n.endsWith(`.local`)||n.endsWith(`.internal`)||n.endsWith(`.home.arpa`)?!0:n.includes(`:`)?n===`::`||n===`::1`||n.startsWith(`fc`)||n.startsWith(`fd`)||/^fe[89ab]/.test(n)||n.startsWith(`::ffff:`):se(n)},le=[`fkn.app`,`fkn.dev`],ue=e=>{let t;try{t=new URL(e)}catch{return!1}if(t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`)return!0;let n=t.hostname;return le.some(e=>n===e||n.endsWith(`.${e}`))},de=e=>{if(ue(e))throw Error(`fetch: refusing to target the extension's own pages or FKN platform domains`)},fe=[`origin`,`referer`],pe=e=>{if(!e?.headers)return;let t=new Headers(e.headers),n=fe.map(e=>{let n=t.get(e);return n===null?void 0:[e,n]}).filter(e=>e!==void 0);return n.length?n:void 0},me=async(e,t)=>{let n=new Request(e,t);de(n.url);let r=n.body?await n.arrayBuffer():null;return M.proxyFetch({url:n.url,method:n.method,headers:[...n.headers],body:r,credentials:t?.credentials===`include`?`include`:`omit`,redirect:n.redirect,unsafeHeaders:pe(t),reason:t?.reason,signal:t?.signal??void 0})},he={scope:`network.readCookie`,category:`network`,severity:3,unsafe:!0,title:`Read a site’s cookie`,description:`Lets the app read a named cookie from another site, which can include the login token only that site should see.`},ge={get:e=>M.getCookie(e)},_e={scope:`network.modifyRequestHeaders`,category:`network`,severity:2,unsafe:!0,title:`Rewrite request headers to other sites`,description:`Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites.`},ve=e=>M.setRequestHeaderRule(e),ye=e=>M.removeRequestHeaderRule({ruleId:e}),be=class extends Error{reason;filename;line;column;source;constructor(e,t,n,r,i){super(`${e}:${n}:${r}: ${t}`),this.reason=t,this.filename=e,this.line=n,this.column=r,this.source=i}},xe=class{start;end;source;constructor(e,t,n){this.start=e,this.end=t,this.source=n}},N;(function(e){e.stylesheet=`stylesheet`,e.rule=`rule`,e.declaration=`declaration`,e.comment=`comment`,e.atRule=`at-rule`,e.container=`container`,e.charset=`charset`,e.counterStyle=`counter-style`,e.document=`document`,e.customMedia=`custom-media`,e.fontFace=`font-face`,e.fontFeatureValues=`font-feature-values`,e.host=`host`,e.import=`import`,e.keyframes=`keyframes`,e.keyframe=`keyframe`,e.layer=`layer`,e.media=`media`,e.namespace=`namespace`,e.page=`page`,e.pageMarginBox=`page-margin-box`,e.positionTry=`position-try`,e.property=`property`,e.scope=`scope`,e.startingStyle=`starting-style`,e.supports=`supports`,e.viewTransition=`view-transition`})(N||={});var P=(e,t,n)=>{let r=n,i=1e4;do{let n=t.map(t=>e.indexOf(t,r));n.push(e.indexOf(`\\`,r));let a=n.filter(e=>e!==-1);if(a.length===0)return-1;let o=Math.min(...a);if(e[o]!==`\\`)return o;r=o+2,i--}while(i>0);throw Error(`Too many escaping`)},F=(e,t,n)=>{let r=n,i=1e4;do{let n=t.map(t=>e.indexOf(t,r));n.push(e.indexOf(`(`,r)),n.push(e.indexOf(`"`,r)),n.push(e.indexOf(`'`,r)),n.push(e.indexOf(`\\`,r));let a=n.filter(e=>e!==-1);if(a.length===0)return-1;let o=Math.min(...a);switch(e[o]){case`\\`:r=o+2;break;case`(`:{let t=F(e,[`)`],o+1);if(t===-1)return-1;r=t+1}break;case`"`:{let t=P(e,[`"`],o+1);if(t===-1)return-1;r=t+1}break;case`'`:{let t=P(e,[`'`],o+1);if(t===-1)return-1;r=t+1}break;default:return o}i--}while(i>0);throw Error(`Too many escaping`)},I=/\/\*[^]*?(?:\*\/|$)/g;function L(e){return e?e.trim():``}function R(e,t){let n=e&&typeof e.type==`string`,r=n?e:t;for(let t in e){let n=e[t];Array.isArray(n)?n.forEach(e=>{R(e,r)}):n&&typeof n==`object`&&R(n,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var Se=class{level=0;indentation=` `;compress=!1;constructor(e){typeof e?.indent==`string`&&(this.indentation=e?.indent),e?.compress&&(this.compress=!0)}emit(e,t){return e}indent(e){return this.level=this.level||1,e?(this.level+=e,``):Array(this.level).join(this.indentation)}visit(e){switch(e.type){case N.stylesheet:return this.stylesheet(e);case N.rule:return this.rule(e);case N.declaration:return this.declaration(e);case N.comment:return this.comment(e);case N.container:return this.container(e);case N.charset:return this.charset(e);case N.counterStyle:return this.counterStyle(e);case N.document:return this.document(e);case N.customMedia:return this.customMedia(e);case N.fontFace:return this.fontFace(e);case N.fontFeatureValues:return this.fontFeatureValues(e);case N.host:return this.host(e);case N.import:return this.import(e);case N.keyframes:return this.keyframes(e);case N.keyframe:return this.keyframe(e);case N.layer:return this.layer(e);case N.media:return this.media(e);case N.namespace:return this.namespace(e);case N.page:return this.page(e);case N.pageMarginBox:return this.pageMarginBox(e);case N.positionTry:return this.positionTry(e);case N.property:return this.property(e);case N.scope:return this.scope(e);case N.startingStyle:return this.startingStyle(e);case N.supports:return this.supports(e);case N.viewTransition:return this.viewTransition(e);case N.atRule:return this.genericAtRule(e)}}mapVisit(e,t){let n=``;t||=``;for(let r=0,i=e.length;r<i;r++)n+=this.visit(e[r]),t&&r<i-1&&(n+=this.emit(t));return n}compile(e){return this.compress?e.stylesheet.rules.map(this.visit,this).join(``):this.stylesheet(e)}stylesheet(e){return this.mapVisit(e.stylesheet.rules,`
2
-
3
- `)}comment(e){return this.compress?this.emit(``,e.position):this.emit(`${this.indent()}/*${e.comment}*/`,e.position)}container(e){return this.compress?this.emit(`@container ${e.container}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@container ${e.container}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
4
-
5
- `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}layer(e){return this.compress?this.emit(`@layer ${e.layer}`,e.position)+(e.rules?this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):`;`):this.emit(`${this.indent()}@layer ${e.layer}`,e.position)+(e.rules?this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
6
-
7
- `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`):`;`)}import(e){return this.emit(`@import ${e.import};`,e.position)}media(e){return this.compress?this.emit(`@media ${e.media}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@media ${e.media}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
8
-
9
- `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}document(e){let t=`@${e.vendor||``}document ${e.document}`;return this.compress?this.emit(t,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(t,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
10
-
11
- `)+this.emit(`${this.indent(-1)}\n}`)}charset(e){return this.emit(`@charset ${e.charset};`,e.position)}namespace(e){return this.emit(`@namespace ${e.namespace};`,e.position)}startingStyle(e){return this.compress?this.emit(`@starting-style`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@starting-style`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
12
-
13
- `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}supports(e){return this.compress?this.emit(`@supports ${e.supports}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@supports ${e.supports}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
14
-
15
- `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}keyframes(e){return this.compress?this.emit(`@${e.vendor||``}keyframes ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.keyframes)+this.emit(`}`):this.emit(`@${e.vendor||``}keyframes ${e.name}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.keyframes,`
16
- `)+this.emit(`${this.indent(-1)}}`)}keyframe(e){let t=e.declarations;return this.compress?this.emit(e.values.join(`,`),e.position)+this.emit(`{`)+this.mapVisit(t)+this.emit(`}`):this.emit(this.indent())+this.emit(e.values.join(`, `),e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(t,`
17
- `)+this.emit(`${this.indent(-1)}\n${this.indent()}}\n`)}page(e){if(this.compress){let t=e.selectors.length?e.selectors.join(`, `):``;return this.emit(`@page ${t}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`)}let t=e.selectors.length?`${e.selectors.join(`, `)} `:``;return this.emit(`@page ${t}`,e.position)+this.emit(`{
18
- `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
19
- `)+this.emit(this.indent(-1))+this.emit(`
20
- }`)}pageMarginBox(e){return this.compress?this.emit(`@${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`${this.indent()}@${e.name} `,e.position)+this.emit(`{
21
- `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
22
- `)+this.emit(this.indent(-1))+this.emit(`\n${this.indent()}}`)}fontFace(e){return this.compress?this.emit(`@font-face`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@font-face `,e.position)+this.emit(`{
23
- `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
24
- `)+this.emit(this.indent(-1))+this.emit(`
25
- }`)}host(e){return this.compress?this.emit(`@host`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`@host`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
26
-
27
- `)+this.emit(`${this.indent(-1)}\n}`)}customMedia(e){return this.emit(`@custom-media ${e.name} ${e.media};`,e.position)}property(e){return this.compress?this.emit(`@property ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@property ${e.name} `,e.position)+this.emit(`{
28
- `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
29
- `)+this.emit(this.indent(-1))+this.emit(`
30
- }`)}counterStyle(e){return this.compress?this.emit(`@counter-style ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@counter-style ${e.name} `,e.position)+this.emit(`{
31
- `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
32
- `)+this.emit(this.indent(-1))+this.emit(`
33
- }`)}fontFeatureValues(e){return this.compress?this.emit(`@font-feature-values ${e.fontFamily}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@font-feature-values ${e.fontFamily}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
34
-
35
- `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}scope(e){let t=e.scope?` ${e.scope}`:``;return this.compress?this.emit(`@scope${t}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@scope${t}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
36
-
37
- `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}viewTransition(e){return this.compress?this.emit(`@view-transition`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@view-transition `,e.position)+this.emit(`{
38
- `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
39
- `)+this.emit(this.indent(-1))+this.emit(`
40
- }`)}positionTry(e){return this.compress?this.emit(`@position-try ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@position-try ${e.name} `,e.position)+this.emit(`{
41
- `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
42
- `)+this.emit(this.indent(-1))+this.emit(`
43
- }`)}genericAtRule(e){let t=e.prelude?` ${e.prelude}`:``;if(this.compress)return this.emit(`@${e.name}${t}`,e.position)+(e.rules?this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):`;`);if(!e.rules)return this.emit(`${this.indent()}@${e.name}${t};`,e.position);let n=e.rules.some(e=>e.type!==N.declaration&&e.type!==N.comment),r=n?`
44
-
45
- `:`
46
- `;return this.emit(`${this.indent()}@${e.name}${t}`,e.position)+this.emit(n?` {\n${this.indent(1)}`:` {
47
- `)+this.emit(n?``:this.indent(1))+this.mapVisit(e.rules,r)+this.emit(n?`\n${this.indent(-1)}${this.indent()}}`:`${this.indent(-1)}\n${this.indent()}}`)}rule(e){let t=e.declarations;if(!t.length)return``;if(this.compress)return this.emit(e.selectors.join(`,`),e.position)+this.emit(`{`)+this.mapVisit(t)+this.emit(`}`);let n=this.indent();return this.emit(e.selectors.map(e=>n+e).join(`,
48
- `),e.position)+this.emit(` {
49
- `)+this.emit(this.indent(1))+this.mapVisit(t,`
50
- `)+this.emit(this.indent(-1))+this.emit(`\n${this.indent()}}`)}declaration(e){return this.compress?this.emit(`${e.property}:${e.value}`,e.position)+this.emit(`;`):e.property===`grid-template-areas`?this.emit(this.indent())+this.emit(e.property+`: `+e.value.split(`
51
- `).join(`
52
- `.padEnd(22)+this.indent()),e.position)+this.emit(`;`):this.emit(this.indent())+this.emit(`${e.property}: ${e.value}`,e.position)+this.emit(`;`)}},Ce=(e,t)=>{t||={};let n=1,r=1;function i(){let e={line:n,column:r};return i=>(i.position=new xe(e,{line:n,column:r},t?.source||``),u(),i)}let a=[];function o(i){let o=new be(t?.source||``,i,n,r,e);if(!t?.silent)throw o;a.push(o)}function s(){let t=/^{\s*/.exec(e);return!!t&&(l(t),!0)}function c(){let t=/^}/.exec(e);return!!t&&(l(t),!0)}function l(t){let i=t[0];return function(e){let t=e.match(/\n/g);t&&(n+=t.length);let i=e.lastIndexOf(`
53
- `);r=~i?e.length-i:r+e.length}(i),e=e.slice(i.length),t}function u(){let t=/^\s*/.exec(e);t&&l(t)}function d(e){e||=[];let t=f();for(;t;)e.push(t),t=f();return e}function f(){let t=i();if(e.charAt(0)!==`/`||e.charAt(1)!==`*`)return;let n=/^\/\*[^]*?\*\//.exec(e);return n?(l(n),t({type:N.comment,comment:n[0].slice(2,-2)})):o(`End of comment missing`)}function p(){let t=F(e,[`{`]);if(t===-1||t===0)return;let n=e.substring(0,t);return l([n]),((e,t)=>{let n=[],r=0;for(;r<e.length;){let i=F(e,t,r);if(i===-1)return n.push(e.substring(r)),n;n.push(e.substring(r,i)),r=i+1}return n})(L(n).replace(I,``),[`,`]).map(e=>L(e))}function m(){let t=i(),n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);if(!n)return;l(n);let r=L(n[0]),a=/^:\s*/.exec(e);if(!a)return o(`property missing ':'`);l(a);let s=``,c=F(e,[`;`,`}`]);c!==-1&&(s=e.substring(0,c),l([s]),s=L(s).replace(I,``));let u=t({type:N.declaration,property:r.replace(I,``),value:s}),d=/^[;\s]*/.exec(e);return d&&l(d),u}function h(){let n=[];if(!s())return o(`missing '{'`);d(n);let r=m();for(;r;)n.push(r),d(n),r=m();for(;t?.silent&&e.length&&e.charAt(0)!==`}`;){let t=e.indexOf(`;`),i=e.indexOf(`}`);if(t===-1||!(i===-1||t<i))break;for(l([e.substring(0,t+1)]),u(),d(n),r=m();r;)n.push(r),d(n),r=m()}return c()?n:o(`missing '}'`)}function g(){let t=F(e,[`{`]);if(t===-1)return!1;let n=F(e,[`;`]),r=F(e,[`}`]);return!(n!==-1&&n<t)&&!(r!==-1&&r<t)}function _(){let n=[];if(!s())return o(`missing '{'`);for(d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){n.push(e),d(n);continue}}if(g()){let e=E();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return c()?n:o(`missing '}'`)}function v(){let n=[];for(u(),d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){n.push(e),d(n);continue}}if(g()){let e=E();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return n}function y(){let t=[],n=i(),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e);for(;r;){let n=l(r);t.push(n[1]);let i=/^,\s*/.exec(e);i&&l(i),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e)}if(t.length)return n({type:N.keyframe,values:t,declarations:h()||[]})}let b=RegExp(`^@(${[`top-left-corner`,`top-left`,`top-center`,`top-right`,`top-right-corner`,`bottom-left-corner`,`bottom-left`,`bottom-center`,`bottom-right`,`bottom-right-corner`,`left-top`,`left-middle`,`left-bottom`,`right-top`,`right-middle`,`right-bottom`].join(`|`)})(?![\\w-])\\s*`),x=w(`import`),S=w(`charset`),C=w(`namespace`);function w(t){let n=RegExp(`^@`+t+`\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);return()=>{let r=i(),a=n.exec(e);if(!a)return;let o=l(a),s={type:t};return s[t]=o[1].trim(),r(s)}}function T(){if(e[0]===`@`)return function(){let t=i(),n=/^@([-\w]+)?keyframes\s*/.exec(e);if(!n)return;let r=l(n)[1],a=/^([-\w]+)\s*/.exec(e);if(!a)return o(`@keyframes missing name`);let u=l(a)[1];if(!s())return o(`@keyframes missing '{'`);let f=d(),p=y();for(;p;)f.push(p),f=f.concat(d()),p=y();return c()?t({type:N.keyframes,name:u,vendor:r,keyframes:f}):o(`@keyframes missing '}'`)}()||function(){let t=i(),n=/^@media *([^{]+)/.exec(e);if(!n)return;let r=L(l(n)[1]);if(!s())return o(`@media missing '{'`);let a=v();return c()?t({type:N.media,media:r,rules:a}):o(`@media missing '}'`)}()||function(){let t=i(),n=/^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(e);if(!n)return;let r=l(n);return t({type:N.customMedia,name:L(r[1]),media:L(r[2])})}()||function(){let t=i(),n=/^@supports *([^{]+)/.exec(e);if(!n)return;let r=L(l(n)[1]);if(!s())return o(`@supports missing '{'`);let a=v();return c()?t({type:N.supports,supports:r,rules:a}):o(`@supports missing '}'`)}()||x()||S()||C()||function(){let t=i(),n=/^@([-\w]+)?document *([^{]+)/.exec(e);if(!n)return;let r=l(n),a=L(r[1]),u=L(r[2]);if(!s())return o(`@document missing '{'`);let d=v();return c()?t({type:N.document,document:u,vendor:a,rules:d}):o(`@document missing '}'`)}()||function(){let t=i(),n=/^@page */.exec(e);if(!n)return;l(n);let r=p()||[];if(!s())return o(`@page missing '{'`);let a=[];for(d(a);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){a.push(e),d(a);continue}}let t=m();if(!t)break;a.push(t),d(a)}return c()?t({type:N.page,selectors:r,declarations:a}):o(`@page missing '}'`)}()||function(){let t=i(),n=/^@host\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@host missing '{'`);let r=v();return c()?t({type:N.host,rules:r}):o(`@host missing '}'`)}()||function(){let t=i(),n=/^@font-face\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@font-face missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:N.fontFace,declarations:r}):o(`@font-face missing '}'`)}()||function(){let t=i(),n=/^@font-feature-values\s+([^{]+)/.exec(e);if(!n)return;let r=L(l(n)[1]);if(!s())return o(`@font-feature-values missing '{'`);let a=v();return c()?t({type:N.fontFeatureValues,fontFamily:r,rules:a}):o(`@font-feature-values missing '}'`)}()||function(){let t=i(),n=/^@container *([^{]+)/.exec(e);if(!n)return;let r=L(l(n)[1]);if(!s())return o(`@container missing '{'`);let a=v();return c()?t({type:N.container,container:r,rules:a}):o(`@container missing '}'`)}()||function(){let t=i(),n=/^@starting-style\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@starting-style missing '{'`);let r=v();return c()?t({type:N.startingStyle,rules:r}):o(`@starting-style missing '}'`)}()||function(){let t=i(),n=/^@layer *([^{;@]+)/.exec(e);if(!n)return;let r=L(l(n)[1]);if(!s()){let n=/^[;\s]*/.exec(e);return n&&l(n),t({type:N.layer,layer:r})}let a=v();return c()?t({type:N.layer,layer:r,rules:a}):o(`@layer missing '}'`)}()||function(){let t=i(),n=/^@property\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@property missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:N.property,name:r,declarations:a}):o(`@property missing '}'`)}()||function(){let t=i(),n=/^@counter-style\s+([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@counter-style missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:N.counterStyle,name:r,declarations:a}):o(`@counter-style missing '}'`)}()||function(){let t=i(),n=/^@scope\s*([^{]*)/.exec(e);if(!n)return;let r=L(l(n)[1]);if(!s())return o(`@scope missing '{'`);let a=v();return c()?t({type:N.scope,scope:r,rules:a}):o(`@scope missing '}'`)}()||function(){let t=i(),n=/^@view-transition\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@view-transition missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:N.viewTransition,declarations:r}):o(`@view-transition missing '}'`)}()||function(){let t=i(),n=/^@position-try\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@position-try missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:N.positionTry,name:r,declarations:a}):o(`@position-try missing '}'`)}()||function(){let t=i(),n=b.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@${r} missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:N.pageMarginBox,name:r,declarations:a}):o(`@${r} missing '}'`)}()||function(){let t=i(),n=/^@([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1],a=``,u=F(e,[`{`,`;`]);if(u!==-1&&u>0&&(a=L(e.substring(0,u)),l([e.substring(0,u)])),s()){let e=v();return c()?t({type:N.atRule,name:r,prelude:a,rules:e}):o(`@${r} missing '}'`)}let d=/^[;\s]*/.exec(e);return d&&l(d),t({type:N.atRule,name:r,prelude:a})}()}function E(){let e=i(),t=p();return t?(d(),e({type:N.rule,selectors:t,declarations:_()||[]})):o(`selector missing`)}return R(function(){let n=function(){let n,r=[];for(u(),d(r);e.length;){if(e.charAt(0)===`}`){if(t?.silent){o(`extra '}'`),l([`}`]),u(),d(r);continue}break}if(n=T()||E(),!n){if(t?.silent){l([e.charAt(0)]),u(),d(r);continue}break}r.push(n),d(r)}return r}();return{type:N.stylesheet,stylesheet:{source:t?.source,rules:n,parsingErrors:a}}}())},we=(e,t)=>new Se(t||{}).compile(e),z=`LocatorError`,B=`LocatorUnsupportedError`,V=`LocatorDeniedError`,H=e=>typeof e==`object`&&e?e.name:void 0,U=e=>Object.assign(Error(e),{name:z}),Te=(e,t=``,n)=>Object.assign(Error(e),{name:B,operation:t,backend:n}),Ee=(e,t)=>Te(`Locator operation not supported${t?` on the ${t} backend`:``}: ${e}`,e,t),W=e=>H(e)===B,De=e=>H(e)===V,Oe=e=>De(e)||W(e),G=e=>{let t=(e.ownerDocument??e).defaultView;if(!t)throw U(`the resolved element belongs to a document with no window`);return t},ke=(e,t)=>{let n=e?.[t];return typeof n==`function`?n:null},K=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=(()=>{try{return ke(G(e),t)}catch{return null}})();if(n&&e instanceof n)return n;let r=ke(globalThis,t);return r&&e instanceof r?r:null},q=(e,t)=>K(e,t)!==null,J=e=>{if(e.length===0)throw U(`No elements found`);if(e.length>1)throw U(`Strict mode violation: locator resolved to ${e.length} elements`);return e[0]},Ae=(e,t)=>{if(!q(e,t))throw U(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);return e},je=e=>e.tagName.toLowerCase(),Me=new Set,Ne=e=>{Me.add(e)},Pe=/(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i,Fe=e=>e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16))).replace(/\\(.)/g,`$1`),Ie=e=>!Pe.test(Fe(e.value)),Le=new Set([N.import,N.fontFace,N.namespace,N.charset,N.document,N.comment]),Re=e=>{if(Le.has(e.type))return null;if(e.type===N.declaration)return Ie(e)?e:null;let t=e,n={...t};for(let e of[`declarations`,`rules`,`keyframes`]){let r=t[e];Array.isArray(r)&&(n[e]=ze(r))}return n},ze=e=>e.map(e=>Re(e)).filter(e=>e!==null),Be=e=>{let t;try{t=Ce(e,{silent:!0})}catch{return``}return t.stylesheet.rules=ze(t.stylesheet.rules),we(t)},Ve=(e,t)=>{let n=()=>{t.parentNode||(e.head??e.documentElement).appendChild(t)};if(n(),e.readyState===`complete`)return;let r=new MutationObserver(e=>{for(let r of e)for(let e of r.removedNodes)if(e===t||e.contains?.(t)){n();return}});r.observe(e.documentElement,{childList:!0,subtree:!0});let i=()=>r.disconnect(),a=e.defaultView;a?a.addEventListener(`load`,i,{once:!0}):setTimeout(i,3e4)},He={resolve:(e,t)=>{let n=e.document.createElement(`style`);n.textContent=t.noSanitize?t.content:Be(t.content);try{Ve(e.document,n)}catch(e){console.error(e)}Ne(n)}},Ue=(e,t)=>{let n=e.getBoundingClientRect();return{clientX:n.left+n.width*(t?.x??.5),clientY:n.top+n.height*(t?.y??.5)}},We={resolve:(e,t={})=>{let n=J(e.elements),r=G(n),i={bubbles:!0,cancelable:!0,composed:!0,...Ue(n,t.position),button:0},a={...i,pointerType:`mouse`,pointerId:1,isPrimary:!0};n.dispatchEvent(new r.PointerEvent(`pointerdown`,{...a,buttons:1})),n.dispatchEvent(new r.MouseEvent(`mousedown`,{...i,buttons:1})),n.dispatchEvent(new r.PointerEvent(`pointerup`,{...a,buttons:0})),n.dispatchEvent(new r.MouseEvent(`mouseup`,{...i,buttons:0})),n.dispatchEvent(new r.MouseEvent(`click`,{...i,buttons:0}))}},Ge={resolve:(e,t={})=>{let n=J(e.elements),r=G(n),i={bubbles:!0,cancelable:!0,composed:!0,...Ue(n,t.position)},a={...i,pointerType:`mouse`,pointerId:1,isPrimary:!0};n.dispatchEvent(new r.PointerEvent(`pointerover`,a)),n.dispatchEvent(new r.PointerEvent(`pointerenter`,{...a,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseenter`,{...i,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseover`,i)),n.dispatchEvent(new r.PointerEvent(`pointermove`,a)),n.dispatchEvent(new r.MouseEvent(`mousemove`,i))}},Ke=(e,t)=>{e._valueTracker?.setValue(``);let n=(K(e,`HTMLTextAreaElement`)??K(e,`HTMLInputElement`))?.prototype,r=n&&Object.getOwnPropertyDescriptor(n,`value`)?.set;r?r.call(e,t):e.value=t},qe=(e,t)=>{if(e.type!==`range`)return null;let n=Number(e.min||0),r=Number(e.max||100);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=Number(t);if(!Number.isFinite(i))return null;let a=Math.max(0,Math.min(1,(i-n)/(r-n))),o=e.getBoundingClientRect(),s={bubbles:!0,cancelable:!0,composed:!0,clientX:o.left+o.width*a,clientY:o.top+o.height/2,button:0},c={...s,pointerType:`mouse`,pointerId:1,isPrimary:!0};return{pointerDown:{...c,buttons:1},pointerUp:{...c,buttons:0},mouseDown:{...s,buttons:1},mouseUp:{...s,buttons:0}}},Je={resolve:(e,t,n={})=>{let r=J(e.elements),i=G(r),a=q(r,`HTMLInputElement`);if(a||q(r,`HTMLTextAreaElement`)){let e=r,n=a?qe(e,t):null;n&&(r.dispatchEvent(new i.PointerEvent(`pointerdown`,n.pointerDown)),r.dispatchEvent(new i.MouseEvent(`mousedown`,n.mouseDown))),Ke(e,t),r.dispatchEvent(new i.Event(`input`,{bubbles:!0})),n&&(r.dispatchEvent(new i.PointerEvent(`pointerup`,n.pointerUp)),r.dispatchEvent(new i.MouseEvent(`mouseup`,n.mouseUp))),r.dispatchEvent(new i.Event(`change`,{bubbles:!0}));return}if(q(r,`HTMLElement`)&&r.isContentEditable){r.textContent=t,r.dispatchEvent(new i.Event(`input`,{bubbles:!0}));return}throw Error(`fill: element <${je(r)}> is not fillable`)}},Ye={resolve:(e,t={})=>J(e.elements).textContent},Xe={resolve:(e,t,n={})=>J(e.elements).getAttribute(t)},Ze={resolve:(e,t={})=>{let n=J(e.elements);if(!q(n,`HTMLElement`))return!0;let r=G(n).getComputedStyle(n);if(r?.display===`none`||r?.visibility===`hidden`)return!1;let i=n.getBoundingClientRect();return i.width>0&&i.height>0}},Qe={resolve:(e,t={})=>e.elements.length},$e={resolve:(e,t={})=>e.elements.length>0},Y=Object.freeze(Object.defineProperty({__proto__:null,click:We,count:Qe,exists:$e,fill:Je,getAttribute:Xe,hover:Ge,isVisible:Ze,textContent:Ye},Symbol.toStringTag,{value:`Module`})),X=(e,t)=>e.elements.flatMap(e=>[...e.querySelectorAll(t)]),Z=e=>e.replaceAll(`"`,`\\"`),et={to:`element`,css:!0,resolve:(e,t)=>X(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`descend`})},tt={to:`frame`,css:!0,barrier:`down`,resolve:(e,t)=>X(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`down`})},nt={element:{selectors:{locator:et,frameLocator:tt,getByRole:{to:`element`,resolve:(e,t)=>X(e,`[role="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[role="${Z(e)}"]`:`[role]`})},getByText:{to:`element`,resolve:(e,t)=>e.elements.flatMap(e=>[e,...e.querySelectorAll(`*`)]).filter(e=>e.textContent?.includes(t)),render:e=>({fragment:typeof e==`string`?`:has-text("${Z(e)}")`:`:has-text(...)`})},getByTestId:{to:`element`,resolve:(e,t)=>X(e,`[data-testid="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[data-testid="${Z(e)}"]`:`[data-testid]`})},first:{to:`element`,resolve:e=>e.elements.slice(0,1),render:()=>({fragment:`:first`})},nth:{to:`element`,resolve:(e,t)=>{let n=e.elements.at(t);return n?[n]:[]},render:e=>({fragment:typeof e==`number`?`:nth(${e})`:`:nth(?)`})}},operations:{click:We,fill:Je,hover:Ge,textContent:Ye,getAttribute:Xe,isVisible:Ze,count:Qe,exists:$e}},frame:{selectors:{locator:et,frameLocator:tt,owner:{to:`frame`,barrier:`up`,resolve:e=>{throw Error(`owner: must be processed by the executor as an upward pivot`)},render:()=>({fragment:``,separator:`up`})}},operations:{addStyleTag:He}}},rt=(e,t=nt)=>({element:{selectors:{...t.element.selectors,...e.element?.selectors},operations:{...t.element.operations,...e.element?.operations}},frame:{selectors:{...t.frame.selectors,...e.frame?.selectors},operations:{...t.frame.operations,...e.frame?.operations}}}),it=3e4,at=50,ot=e=>{let t=e[e.length-1];return typeof t==`object`&&t?t:void 0},st=e=>{let t=ot(e)?.timeout;return typeof t==`number`?t:it},ct=({executor:e,parts:t})=>({highlight:n=>e.highlight(t,n).then(()=>{},()=>{})}),lt=async e=>{let t={parts:e.parts,operation:e.operation,args:e.args,phase:`ensure`};await e.gate?.(t,ct(e))},ut=async e=>{let{executor:t,gate:n,parts:r,operation:i,args:a}=e;n&&await n({parts:r,operation:i,args:a,phase:`execute`},ct(e));let o=st(a),s=Date.now()+o,c=Error(`Locator timeout (${o}ms): ${i}`),{promise:l,reject:u}=Promise.withResolvers();l.catch(()=>{});let d=setTimeout(()=>u(c),o),f=c;try{for(;Date.now()<s;)try{return await Promise.race([t.execute(r,i,a),l])}catch(e){if(e===c)break;if(Oe(e))throw e;f=e;let t=s-Date.now();if(t<=0)break;await new Promise(e=>setTimeout(e,Math.min(at,t)))}}finally{clearTimeout(d)}throw f},dt=(e,t,n,r)=>{let i={};for(let[a,o]of Object.entries(t[n].selectors))i[a]=(...i)=>dt(e,t,o.to,[...r,{kind:n,name:a,args:i}]);for(let a of Object.keys(t[n].operations))i[a]=(...t)=>ut({...e,parts:r,operation:a,args:t});return i.ensure=(t,n={})=>lt({...e,parts:r,operation:t,args:[n]}),i},ft=e=>dt(e,e.modules??nt,`frame`,[]),pt=rt({element:{operations:{click:{resolve:(e,t={})=>Y.click.resolve(e,t)},hover:{resolve:(e,t={})=>Y.hover.resolve(e,t)},fill:{resolve:(e,t,n={})=>Y.fill.resolve(e,t,n)},textContent:{resolve:(e,t={})=>Y.textContent.resolve(e)},getAttribute:{resolve:(e,t,n={})=>Y.getAttribute.resolve(e,t)},isVisible:{resolve:(e,t={})=>Y.isVisible.resolve(e)},count:{resolve:(e,t={})=>Y.count.resolve(e)},exists:{resolve:(e,t={})=>Y.exists.resolve(e)},videoElement:{resolve:(e,t={})=>S(Ae(J(e.elements),`HTMLVideoElement`))}}},frame:{operations:{addStyleTag:{resolve:(e,t)=>He.resolve(e,t)}}}}),Q=e=>{if(!e||e===`about:blank`)return!1;let t;try{t=new URL(e,location.href)}catch{return!1}if(t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`)return!0;if(t.protocol===`about:`)return!1;let n=t.hostname,r=e=>n===e||n.endsWith(`.${e}`);return r(`fkn.app`)||r(`fkn.dev`)||r(`sdbx.app`)},$=e=>{if(Q(e))throw Error(`attachFrame: refusing to target the extension's own pages or an FKN platform origin`)},mt=({src:e,domains:t,lockdown:n})=>{if(!(!n||t.length)&&e&&e!==`about:blank`)throw Error(`attachFrame: lockdown needs domains when the frame already has a src; pass domains or load it via goto`)},ht={scope:`embed.iframe`,category:`embed`,severity:0,title:`Load another website inside this app`,description:`Lets the app embed external pages directly inside its own view.`},gt={scope:`embed.open`,category:`embed`,severity:0,title:`Open a website inside this app`,description:`Lets the app navigate to another site without leaving its window.`},_t=e=>{let t=ft({executor:e.executor,modules:pt,gate:e.gate}),n=(t,n={})=>($(t),e.goto(t,n)),r=()=>e.url();return{...t,goto:n,url:r}},vt=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,yt=async({iframe:e,domains:t=[],syncCookies:n=!0,lockdown:r=!1})=>{let i=crypto.randomUUID();if($(e.src),mt({src:e.src,domains:t,lockdown:r}),await A(),!e.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);e.dispatchEvent(new CustomEvent(vt,{detail:i}));let{executeLocator:a,highlightLocator:o,ensureLocatorPermission:s,goto:c}=await M.attachFrame({marker:i,domains:t,syncCookies:n,lockdown:r});return _t({executor:{execute:a,highlight:o},gate:e=>s(e.parts,e.operation,e.args),goto:(e,t={})=>c({url:e,...t}),url:()=>e.src})},bt={request:e=>M.requestPermissions(e.map(e=>({key:e.key,scope:e.scope??``,reason:e.reason})))},xt=[`fkn.app`,`fkn.dev`],St=e=>{let t=typeof e==`string`?e:e instanceof URL?e.href:e.url,n;try{n=new URL(t)}catch{return}let r=n.hostname;if(xt.some(e=>r===e||r.endsWith(`.${e}`)))throw Error(`fetch refuses FKN platform domains (${r})`)},Ct=async e=>{if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e:new Request(`https://body.invalid/`,{method:`POST`,body:e,duplex:`half`}).arrayBuffer()},wt=async e=>{if(e.method===`GET`||e.method===`HEAD`)return;let t=await e.clone().arrayBuffer();return t.byteLength?t:void 0},Tt=async(e,n)=>{if(St(e),typeof e==`object`&&e&&!(e instanceof URL)&&typeof e.url==`string`){let r=e,i={};r.headers.forEach((e,t)=>{i[t]=e});let a=await Ct(n?.body===void 0?await wt(r):n.body);return t.t.then(e=>e.cloud.fetch(r.url,{...n,method:n?.method??r.method,headers:n?.headers??i,body:a}))}let r=e instanceof URL?e.href:e,i=await Ct(n?.body);return t.t.then(e=>e.cloud.fetch(r,n?.body===void 0?n:{...n,body:i}))};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return T}});