@fkn/lib 0.9.19 → 0.9.21

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.
Files changed (86) hide show
  1. package/account.cjs +1 -1
  2. package/account.js +24 -17
  3. package/{api-DnO1DsJC.d.ts → api-B0qRPCcX.d.ts} +36 -37
  4. package/api-BqRjtWm_.js +311 -0
  5. package/api-CKO3Hw-O.cjs +3 -0
  6. package/busy-Bp1E3JPT.js +24 -0
  7. package/busy-Dv8wzE5M.cjs +1 -0
  8. package/cloud/dgram.cjs +1 -1
  9. package/cloud/dgram.js +1 -1
  10. package/cloud/fetch.cjs +1 -1
  11. package/cloud/fetch.d.ts +1 -1
  12. package/cloud/fetch.js +1 -1
  13. package/cloud/fs.cjs +1 -1
  14. package/cloud/fs.js +2 -2
  15. package/cloud/net.cjs +1 -1
  16. package/cloud/net.d.ts +1 -1
  17. package/cloud/net.js +1 -1
  18. package/cloud-BCQTex58.cjs +1 -0
  19. package/{cloud-uE4g-WqI.d.ts → cloud-BTpJn4jy.d.ts} +3 -3
  20. package/cloud-BlR1He17.js +212 -0
  21. package/cloud.cjs +1 -1
  22. package/cloud.d.ts +3 -3
  23. package/cloud.js +4 -4
  24. package/dgram-9hn582qO.cjs +1 -0
  25. package/{dgram-DlGl_ho1.js → dgram-TB03kqMr.js} +55 -49
  26. package/dgram.cjs +1 -1
  27. package/dgram.d.ts +2 -1
  28. package/dgram.js +1 -1
  29. package/dns.cjs +1 -1
  30. package/dns.js +1 -1
  31. package/extension-BI2NxGtC.js +78 -0
  32. package/{extension-CN9oFZ0Q.d.ts → extension-CMPZjuaV.d.ts} +1 -1
  33. package/extension-rFQQpEqJ.cjs +1 -0
  34. package/extension.cjs +1 -1
  35. package/extension.d.ts +2 -2
  36. package/extension.js +3 -3
  37. package/fs/promises.cjs +1 -1
  38. package/fs/promises.js +1 -1
  39. package/fs-BUcpl9k4.cjs +1 -0
  40. package/fs-bpb3Ysdd.js +347 -0
  41. package/fs.cjs +1 -1
  42. package/fs.js +1 -1
  43. package/http.cjs +1 -1
  44. package/http.d.ts +1 -1
  45. package/http.js +1 -1
  46. package/{index-DLaonjpx.d.ts → index-DY8WjklJ.d.ts} +82 -0
  47. package/index.cjs +1 -1
  48. package/index.d.ts +12 -18
  49. package/index.js +92 -39
  50. package/lib-DbiVHPXE.cjs +53 -0
  51. package/{lib-CegQxwDI.js → lib-k3lstfa4.js} +178 -131
  52. package/net-C2fIMWFr.cjs +1 -0
  53. package/{net-l7JVHsIR.d.ts → net-CnYxw_sB.d.ts} +3 -1
  54. package/{net-BbmQeMpt.js → net-Ct8ywVAk.js} +52 -41
  55. package/net.cjs +1 -1
  56. package/net.d.ts +1 -1
  57. package/net.js +1 -1
  58. package/node-fs-BZCQUmeE.js +404 -0
  59. package/node-fs-DZPGCYWg.cjs +1 -0
  60. package/opfs.cjs +1 -1
  61. package/opfs.js +1 -1
  62. package/package.json +1 -1
  63. package/{packages-vX-1yfRK.d.ts → packages-Cn8S-Hkn.d.ts} +20 -20
  64. package/packages.cjs +1 -1
  65. package/packages.d.ts +1 -1
  66. package/packages.js +165 -149
  67. package/proxy--aljNHvG.js +69 -0
  68. package/{proxy-7ib45Uo-.d.ts → proxy-CuXtzxSQ.d.ts} +1 -1
  69. package/proxy-oHfEx1cn.cjs +1 -0
  70. package/{storage-C8hBot2f.js → storage-C1nW5Tvh.js} +1 -1
  71. package/{storage-BW-jDLUL.cjs → storage-rXHvV2FU.cjs} +1 -1
  72. package/api-DQ-V4Lls.js +0 -220
  73. package/api-kHMHDGar.cjs +0 -3
  74. package/cloud-BQoppUw4.cjs +0 -1
  75. package/cloud-C8CeqUht.js +0 -130
  76. package/dgram-D2Or5f2e.cjs +0 -1
  77. package/extension-4BM5hKrn.cjs +0 -1
  78. package/extension-DVO10P3i.js +0 -78
  79. package/fs-BW5mVMmu.js +0 -340
  80. package/fs-DJm0bhjg.cjs +0 -1
  81. package/lib-ulyxIbTr.cjs +0 -53
  82. package/net-COzDDBnS.cjs +0 -1
  83. package/node-fs-BMR2yCEt.cjs +0 -1
  84. package/node-fs-DKfokOlh.js +0 -401
  85. package/proxy-B0gNjT8-.cjs +0 -1
  86. package/proxy-BpqvCJmA.js +0 -43
package/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-ulyxIbTr.cjs"),n=require("./api-kHMHDGar.cjs"),r=require("./cloud-BQoppUw4.cjs"),i=require("./dns.cjs"),a=require("./net-COzDDBnS.cjs"),o=require("./dgram-D2Or5f2e.cjs"),s=require("./http.cjs"),c=require("./extension-4BM5hKrn.cjs"),l=require("./desktop.cjs"),u=require("./fs-DJm0bhjg.cjs"),d=require("./opfs.cjs"),f=require("./packages.cjs"),p=require("./account.cjs"),m=require("./connect-button-BBEjXzB3.cjs");let h=require("osra");var g=1e4,_=150,v=()=>new Promise(e=>{if(t.P())return e(!0);let n,r=setTimeout(()=>i(t.P()),g),i=t=>{clearTimeout(n),clearTimeout(r),o.disconnect(),document.removeEventListener(`readystatechange`,s),e(t)},a=()=>{clearTimeout(n),n=setTimeout(()=>i(t.P()),_)},o=new MutationObserver(()=>{t.P()&&i(!0)}),s=()=>{document.readyState===`complete`&&!t.P()&&a()};o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,s),document.readyState===`complete`&&a()}),y=async e=>c.r()||e.lockdown||!r.a()||await v()?t.r(e):r.i(e),b=`https://fkn.app`,x=async(e,t)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);let r=await n.i;if(!r)throw Error(`FKN @fkn/lib: relayWorker found no FKN transport in this realm`);(0,h.relay)(r,e,{key:`fkn-api`,...r.emit instanceof MessagePort?{}:{originA:t?.originA??b,originB:t?.originB??`*`},unregisterSignal:t?.unregisterSignal})},S=async()=>typeof window>`u`?!1:(await n.t).connect.prompt(location.origin).catch(()=>!1),C=async()=>typeof window>`u`?null:(await n.t).relay.prompt().catch(()=>null),w=e.t({applyUpdate:()=>D,onUpdate:()=>E,updateReady:()=>T}),T=async()=>typeof window>`u`?!1:n.t.then(e=>e.shell?.updateReady()).then(e=>e===!0).catch(()=>!1),E=async e=>{if(typeof window>`u`)return()=>{};let t=await n.t.catch(()=>null);if(!t||typeof t.shell?.onUpdate!=`function`)return()=>{};let r=await t.shell.onUpdate(e).catch(()=>null);return typeof r==`function`?r:()=>{}},D=async()=>typeof window>`u`?!1:n.t.then(e=>e.shell?.applyUpdate()).then(e=>e===!0).catch(()=>!1);exports.ATTACH_FRAME_EVENT_KEY=t.n,exports.FORGEABLE_HEADERS=t.k,exports.LOCATOR_DENIED=t.g,exports.LOCATOR_ERROR=t.u,exports.LOCATOR_UNSUPPORTED=t.h,Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return p.t}}),exports.assertAttachableFrameUrl=t.s,exports.assertFetchableUrl=t.S,exports.assertForgeableHeaders=t.A,exports.assertLockdownApplicable=t.c,exports.assertOneCookieIdentity=t.j,exports.attachFrame=y,exports.attachFramePermission=t.i,exports.box=t.R,Object.defineProperty(exports,"cloud",{enumerable:!0,get:function(){return r.n}}),exports.connect=S,exports.connectButtonUrl=m.t,exports.cookies=t.b,exports.createFrame=t.a,exports.createVideoElementHandle=t.z,Object.defineProperty(exports,"desktop",{enumerable:!0,get:function(){return l.t}}),Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return o.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return i.t}}),Object.defineProperty(exports,"extension",{enumerable:!0,get:function(){return c.t}}),exports.fetch=c.n,exports.fetchCredentialedPermission=t.w,exports.fetchLocalPermission=t.T,exports.fetchPermission=t.E,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return u.u}}),exports.gotoPermission=t.o,exports.handleRevivableModules=t.L,exports.hasForgedCookie=t.M,Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return s.t}}),exports.isBlockedFetchUrl=t.D,exports.isBlockedFrameUrl=t.l,exports.isExtensionExposed=t.P,exports.isLocalNetworkUrl=t.O,exports.isLocatorDenied=t.d,exports.isLocatorUnsupported=t.m,exports.isTerminalError=t.p,exports.isType=t.B,exports.modifyRequestHeadersPermission=t._,Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return a.s}}),Object.defineProperty(exports,"opfs",{enumerable:!0,get:function(){return d.t}}),Object.defineProperty(exports,"packages",{enumerable:!0,get:function(){return f.t}}),exports.permissions=t.t,exports.promptInstall=c.i,exports.promptRelay=C,exports.readCookiePermission=t.x,exports.relayWorker=x,exports.removeRequestHeaderRule=t.v,exports.revive=t.V,exports.setMissingExtensionHandler=t.F,exports.setRequestHeaderRule=t.y,Object.defineProperty(exports,"shell",{enumerable:!0,get:function(){return w}}),exports.type=t.H,exports.waitForExtensionExposure=t.I;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-DbiVHPXE.cjs"),n=require("./api-CKO3Hw-O.cjs"),r=require("./busy-Dv8wzE5M.cjs"),i=require("./cloud-BCQTex58.cjs"),a=require("./dns.cjs"),o=require("./net-C2fIMWFr.cjs"),s=require("./dgram-9hn582qO.cjs"),c=require("./http.cjs"),l=require("./extension-rFQQpEqJ.cjs"),u=require("./desktop.cjs"),d=require("./fs-BUcpl9k4.cjs"),f=require("./opfs.cjs"),p=require("./packages.cjs"),m=require("./account.cjs"),h=require("./connect-button-BBEjXzB3.cjs");let g=require("osra");var _=1e4,v=150,y=()=>new Promise(e=>{if(t.F())return e(!0);let n,r=setTimeout(()=>i(t.F()),_),i=t=>{clearTimeout(n),clearTimeout(r),o.disconnect(),document.removeEventListener(`readystatechange`,s),e(t)},a=()=>{clearTimeout(n),n=setTimeout(()=>i(t.F()),v)},o=new MutationObserver(()=>{t.F()&&i(!0)}),s=()=>{document.readyState===`complete`&&!t.F()&&a()};o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,s),document.readyState===`complete`&&a()}),b=async e=>l.r()||e.lockdown||!i.a()||await y()?t.r(e):i.i(e),x=`https://fkn.app`,S=async(e,t)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);let i=await n.l;if(!i)throw Error(`FKN @fkn/lib: relayWorker found no FKN transport in this realm`);let a=r.t(`relayed worker`);t?.unregisterSignal?.aborted?a():t?.unregisterSignal?.addEventListener(`abort`,a,{once:!0}),(0,g.relay)(i,e,{key:`fkn-api`,...i.emit instanceof MessagePort?{}:{originA:t?.originA??x,originB:t?.originB??`*`},unregisterSignal:t?.unregisterSignal})},C=async()=>typeof window>`u`?!1:(await n.r).connect.prompt(location.origin).catch(()=>!1),w=async()=>typeof window>`u`?null:(await n.r).relay.prompt().catch(()=>null),T=e.t({applyUpdate:()=>N,onUpdate:()=>M,updateReady:()=>E}),E=async()=>typeof window>`u`?!1:n.r.then(e=>e.shell?.updateReady()).then(e=>e===!0).catch(()=>!1),D=new Set,O=!1,k=()=>{O=!0;for(let e of[...D])try{e()}catch{}},A=0,j=()=>{let e=n.a();!e||D.size===0||A===e.epoch||(A=e.epoch,O=!1,Promise.resolve(e.remote.shell?.onUpdate(k)).catch(()=>{A===e.epoch&&(A=0)}))};typeof window<`u`&&n.s(j);var M=async e=>{if(typeof window>`u`)return()=>{};if(D.add(e),O)try{e()}catch{}return j(),()=>{D.delete(e)}},N=async()=>typeof window>`u`?!1:n.r.then(e=>e.shell?.applyUpdate()).then(e=>e===!0).catch(()=>!1),P=3e4,F=e=>{let t=!1,n=!1;return{tick:async()=>{if(!t||n||!e.ownsFrame()||e.inFlight()>0||e.busy().length>0||e.now()-e.idleSince()<(e.hidden()?12e4:18e5))return!1;n=!0;try{return await e.flush().catch(()=>{}),await e.apply().catch(()=>!0)}finally{n=!1}},noteUpdateReady:()=>{t=!0},noteEpoch:()=>{t=!1,n=!1},isPending:()=>t}},I=!1,L=e=>({now:()=>Date.now(),hidden:()=>document.visibilityState===`hidden`,idleSince:()=>Math.max(n.n(),e),inFlight:n.t,busy:r.n,ownsFrame:()=>n.c()!==void 0,flush:()=>d.c(),apply:()=>n.r.then(e=>e.shell.applyUpdate()).then(e=>e===!0)});(()=>{if(I||typeof window>`u`||typeof document>`u`)return;I=!0;let e=F(L(Date.now()));n.s(()=>e.noteEpoch()),M(()=>e.noteUpdateReady()),setInterval(()=>{e.tick()},P)})(),exports.ATTACH_FRAME_EVENT_KEY=t.n,exports.FORGEABLE_HEADERS=t.A,exports.LOCATOR_DENIED=t.h,exports.LOCATOR_ERROR=t.g,exports.LOCATOR_UNSUPPORTED=t.m,Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return m.t}}),exports.assertAttachableFrameUrl=t.s,exports.assertFetchableUrl=t.C,exports.assertForgeableHeaders=t.j,exports.assertLockdownApplicable=t.c,exports.assertOneCookieIdentity=t.M,exports.attachFrame=b,exports.attachFramePermission=t.i,exports.box=t.z,Object.defineProperty(exports,"cloud",{enumerable:!0,get:function(){return i.n}}),exports.connect=C,exports.connectButtonUrl=h.t,exports.cookies=t.x,exports.createFrame=t.a,exports.createVideoElementHandle=t.B,Object.defineProperty(exports,"desktop",{enumerable:!0,get:function(){return u.t}}),Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return s.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return a.t}}),Object.defineProperty(exports,"extension",{enumerable:!0,get:function(){return l.t}}),exports.fetch=l.n,exports.fetchCredentialedPermission=t.T,exports.fetchLocalPermission=t.E,exports.fetchPermission=t.D,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return d.u}}),exports.gotoPermission=t.o,exports.handleRevivableModules=t.R,exports.hasForgedCookie=t.N,Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return c.t}}),exports.isBlockedFetchUrl=t.O,exports.isBlockedFrameUrl=t.l,exports.isExtensionExposed=t.F,exports.isLocalNetworkUrl=t.k,exports.isLocatorDenied=t.p,exports.isLocatorUnsupported=t.u,exports.isTerminalError=t.d,exports.isType=t.V,exports.modifyRequestHeadersPermission=t.v,Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return o.s}}),Object.defineProperty(exports,"opfs",{enumerable:!0,get:function(){return f.t}}),Object.defineProperty(exports,"packages",{enumerable:!0,get:function(){return p.t}}),exports.permissions=t.t,exports.promptInstall=l.i,exports.promptRelay=w,exports.readCookiePermission=t.S,exports.relayWorker=S,exports.removeRequestHeaderRule=t.y,exports.revive=t.H,exports.setMissingExtensionHandler=t.I,exports.setRequestHeaderRule=t.b,Object.defineProperty(exports,"shell",{enumerable:!0,get:function(){return T}}),exports.type=t.U,exports.waitForExtensionExposure=t.L;
package/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { t as account_d_exports } from "./account.js";
2
- import { S as packages_d_exports } from "./packages-vX-1yfRK.js";
3
- import { 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, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, 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, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-DLaonjpx.js";
4
- import { n as cloud_d_exports } from "./cloud-uE4g-WqI.js";
2
+ import { S as packages_d_exports } from "./packages-Cn8S-Hkn.js";
3
+ import { 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, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, 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, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-DY8WjklJ.js";
4
+ import { n as cloud_d_exports } from "./cloud-BTpJn4jy.js";
5
5
  import { t as dns_d_exports } from "./dns.js";
6
- import { s as net_d_exports } from "./net-l7JVHsIR.js";
6
+ import { s as net_d_exports } from "./net-CnYxw_sB.js";
7
7
  import { t as dgram_d_exports } from "./dgram.js";
8
8
  import { t as http_d_exports } from "./http.js";
9
9
  import { t as desktop_d_exports } from "./desktop.js";
10
- import { i as promptInstall, n as fetch, t as extension_d_exports } from "./extension-CN9oFZ0Q.js";
10
+ import { i as promptInstall, n as fetch, t as extension_d_exports } from "./extension-CMPZjuaV.js";
11
11
  import { u as index_d_exports } from "./index-BIZeEsNu.js";
12
12
  import { t as index_d_exports$1 } from "./opfs.js";
13
13
  import { t as connectButtonUrl } from "./connect-button-D8KXSL6s.js";
@@ -33,29 +33,23 @@ declare namespace shell_d_exports {
33
33
  /**
34
34
  * The FKN shell's update surface, for apps that want a say in when the platform frame reloads.
35
35
  *
36
- * The broker downloads updates behind the page and never applies one on its own authority,
37
- * because only the app knows what a reload costs right now (a torrent mid-download is the case
38
- * that matters). An app that subscribes here learns when a newer shell is ready and calls
39
- * applyUpdate() at a moment of its choosing; the reload covers ONLY the FKN frame, and whether
40
- * the app then reloads its own page is its own decision. Apps that ignore this module entirely
41
- * keep today's behavior: the shell offers the update in its own header instead.
36
+ * The broker downloads updates behind the page and the lib applies one on its own only when this
37
+ * page is demonstrably not using the broker (see auto-update.ts); an app that subscribes here can
38
+ * take it earlier, at a moment of its choosing. The reload covers ONLY the FKN frame, and the
39
+ * page's connection to it is re-established by the lib automatically; a call in flight at that
40
+ * moment rejects with a named error rather than hanging.
42
41
  */
43
42
  /** Whether a newer FKN shell is downloaded and ready to apply. */
44
43
  declare const updateReady: () => Promise<boolean>;
45
44
  /**
46
45
  * Subscribe to "a newer FKN shell is ready". Fires immediately when an update is already
47
- * waiting at subscribe time, so a late subscriber misses nothing. Returns an unsubscribe;
48
- * a shell without this surface yields a noop unsubscribe rather than an error.
46
+ * waiting at subscribe time, so a late subscriber misses nothing. Returns an unsubscribe that
47
+ * stays valid across broker replacements.
49
48
  */
50
49
  declare const onUpdate: (callback: () => void) => Promise<() => void>;
51
50
  /**
52
51
  * Apply a ready update by reloading the FKN frame this page mounted. Resolves true when the
53
52
  * reload was taken, false when there is nothing to apply or this caller does not own the frame.
54
- *
55
- * The page's FKN connection does NOT survive the frame reload: calling this means "now is a
56
- * safe moment", and reloading your own page right after (which remounts the frame fresh) is the
57
- * expected next step. An app that never calls this keeps today's behavior, where the shell
58
- * offers the update in its own header instead.
59
53
  */
60
54
  declare const applyUpdate: () => Promise<boolean>;
61
55
  //#endregion
package/index.js CHANGED
@@ -1,57 +1,110 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { A as t, B as n, D as r, E as i, F as a, H as o, I as s, L as c, M as ee, O as l, P as u, R as d, S as f, T as p, V as m, _ as h, a as g, b as _, c as v, d as y, g as b, h as x, i as S, j as C, k as w, l as T, m as E, n as D, o as O, p as k, r as A, s as j, t as M, u as N, v as P, w as F, x as I, y as te, z as L } from "./lib-CegQxwDI.js";
3
- import { i as R, t as z } from "./api-DQ-V4Lls.js";
4
- import { a as B, i as V, n as H } from "./cloud-C8CeqUht.js";
5
- import { t as U } from "./dns.js";
6
- import { s as W } from "./net-BbmQeMpt.js";
7
- import { i as G } from "./dgram-DlGl_ho1.js";
8
- import { t as K } from "./http.js";
9
- import { i as q, n as J, r as Y, t as X } from "./extension-DVO10P3i.js";
10
- import { t as Z } from "./desktop.js";
11
- import { u as Q } from "./fs-BW5mVMmu.js";
12
- import { t as ne } from "./opfs.js";
13
- import { t as re } from "./packages.js";
14
- import { t as ie } from "./account.js";
15
- import { t as ae } from "./connect-button-Ds9KpXHe.js";
16
- import { relay as oe } from "osra";
2
+ import { A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as ee, N as te, O as ne, R as re, S as ie, T as ae, U as oe, V as se, a as u, b as d, c as f, d as p, g as m, h, i as g, j as _, k as v, l as y, m as b, n as x, o as S, p as C, r as w, s as T, t as E, u as D, v as O, x as k, y as A, z as j } from "./lib-k3lstfa4.js";
3
+ import { a as M, c as N, l as P, n as F, r as I, s as L, t as R } from "./api-BqRjtWm_.js";
4
+ import { n as z, t as B } from "./busy-Bp1E3JPT.js";
5
+ import { a as V, i as H, n as U } from "./cloud-BlR1He17.js";
6
+ import { t as W } from "./dns.js";
7
+ import { s as G } from "./net-Ct8ywVAk.js";
8
+ import { i as K } from "./dgram-TB03kqMr.js";
9
+ import { t as ce } from "./http.js";
10
+ import { i as le, n as ue, r as de, t as fe } from "./extension-BI2NxGtC.js";
11
+ import { t as pe } from "./desktop.js";
12
+ import { c as me, u as he } from "./fs-bpb3Ysdd.js";
13
+ import { t as ge } from "./opfs.js";
14
+ import { t as _e } from "./packages.js";
15
+ import { t as ve } from "./account.js";
16
+ import { t as ye } from "./connect-button-Ds9KpXHe.js";
17
+ import { relay as be } from "osra";
17
18
  //#region src/lib/frame.ts
18
- var se = 1e4, ce = 150, le = () => new Promise((e) => {
19
- if (u()) return e(!0);
20
- let t, n = setTimeout(() => r(u()), se), r = (r) => {
21
- clearTimeout(t), clearTimeout(n), a.disconnect(), document.removeEventListener("readystatechange", o), e(r);
19
+ var xe = 1e4, Se = 150, Ce = () => new Promise((e) => {
20
+ if (o()) return e(!0);
21
+ let t, n = setTimeout(() => r(o()), xe), r = (r) => {
22
+ clearTimeout(t), clearTimeout(n), a.disconnect(), document.removeEventListener("readystatechange", s), e(r);
22
23
  }, i = () => {
23
- clearTimeout(t), t = setTimeout(() => r(u()), ce);
24
+ clearTimeout(t), t = setTimeout(() => r(o()), Se);
24
25
  }, a = new MutationObserver(() => {
25
- u() && r(!0);
26
- }), o = () => {
27
- document.readyState === "complete" && !u() && i();
26
+ o() && r(!0);
27
+ }), s = () => {
28
+ document.readyState === "complete" && !o() && i();
28
29
  };
29
30
  a.observe(document.documentElement, {
30
31
  attributes: !0,
31
32
  attributeFilter: ["data-fkn-extension"]
32
- }), document.addEventListener("readystatechange", o), document.readyState === "complete" && i();
33
- }), ue = async (e) => Y() || e.lockdown || !B() || await le() ? A(e) : V(e), de = "https://fkn.app", fe = async (e, t) => {
33
+ }), document.addEventListener("readystatechange", s), document.readyState === "complete" && i();
34
+ }), we = async (e) => de() || e.lockdown || !V() || await Ce() ? w(e) : H(e), Te = "https://fkn.app", Ee = async (e, t) => {
34
35
  if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
35
- let n = await R;
36
+ let n = await P;
36
37
  if (!n) throw Error("FKN @fkn/lib: relayWorker found no FKN transport in this realm");
37
- oe(n, e, {
38
+ let r = B("relayed worker");
39
+ t?.unregisterSignal?.aborted ? r() : t?.unregisterSignal?.addEventListener("abort", r, { once: !0 }), be(n, e, {
38
40
  key: "fkn-api",
39
41
  ...n.emit instanceof MessagePort ? {} : {
40
- originA: t?.originA ?? de,
42
+ originA: t?.originA ?? Te,
41
43
  originB: t?.originB ?? "*"
42
44
  },
43
45
  unregisterSignal: t?.unregisterSignal
44
46
  });
45
- }, pe = async () => typeof window > "u" ? !1 : (await z).connect.prompt(location.origin).catch(() => !1), $ = async () => typeof window > "u" ? null : (await z).relay.prompt().catch(() => null), me = /* @__PURE__ */ e({
46
- applyUpdate: () => _e,
47
- onUpdate: () => ge,
48
- updateReady: () => he
49
- }), he = async () => typeof window > "u" ? !1 : z.then((e) => e.shell?.updateReady()).then((e) => e === !0).catch(() => !1), ge = async (e) => {
47
+ }, De = async () => typeof window > "u" ? !1 : (await I).connect.prompt(location.origin).catch(() => !1), Oe = async () => typeof window > "u" ? null : (await I).relay.prompt().catch(() => null), ke = /* @__PURE__ */ e({
48
+ applyUpdate: () => Q,
49
+ onUpdate: () => Z,
50
+ updateReady: () => Ae
51
+ }), Ae = async () => typeof window > "u" ? !1 : I.then((e) => e.shell?.updateReady()).then((e) => e === !0).catch(() => !1), q = /* @__PURE__ */ new Set(), J = !1, je = () => {
52
+ J = !0;
53
+ for (let e of [...q]) try {
54
+ e();
55
+ } catch {}
56
+ }, Y = 0, X = () => {
57
+ let e = M();
58
+ !e || q.size === 0 || Y === e.epoch || (Y = e.epoch, J = !1, Promise.resolve(e.remote.shell?.onUpdate(je)).catch(() => {
59
+ Y === e.epoch && (Y = 0);
60
+ }));
61
+ };
62
+ typeof window < "u" && L(X);
63
+ var Z = async (e) => {
50
64
  if (typeof window > "u") return () => {};
51
- let t = await z.catch(() => null);
52
- if (!t || typeof t.shell?.onUpdate != "function") return () => {};
53
- let n = await t.shell.onUpdate(e).catch(() => null);
54
- return typeof n == "function" ? n : () => {};
55
- }, _e = async () => typeof window > "u" ? !1 : z.then((e) => e.shell?.applyUpdate()).then((e) => e === !0).catch(() => !1);
65
+ if (q.add(e), J) try {
66
+ e();
67
+ } catch {}
68
+ return X(), () => {
69
+ q.delete(e);
70
+ };
71
+ }, Q = async () => typeof window > "u" ? !1 : I.then((e) => e.shell?.applyUpdate()).then((e) => e === !0).catch(() => !1), Me = 3e4, Ne = (e) => {
72
+ let t = !1, n = !1;
73
+ return {
74
+ tick: async () => {
75
+ if (!t || n || !e.ownsFrame() || e.inFlight() > 0 || e.busy().length > 0 || e.now() - e.idleSince() < (e.hidden() ? 12e4 : 18e5)) return !1;
76
+ n = !0;
77
+ try {
78
+ return await e.flush().catch(() => {}), await e.apply().catch(() => !0);
79
+ } finally {
80
+ n = !1;
81
+ }
82
+ },
83
+ noteUpdateReady: () => {
84
+ t = !0;
85
+ },
86
+ noteEpoch: () => {
87
+ t = !1, n = !1;
88
+ },
89
+ isPending: () => t
90
+ };
91
+ }, $ = !1, Pe = (e) => ({
92
+ now: () => Date.now(),
93
+ hidden: () => document.visibilityState === "hidden",
94
+ idleSince: () => Math.max(F(), e),
95
+ inFlight: R,
96
+ busy: z,
97
+ ownsFrame: () => N() !== void 0,
98
+ flush: () => me(),
99
+ apply: () => I.then((e) => e.shell.applyUpdate()).then((e) => e === !0)
100
+ });
101
+ (() => {
102
+ if ($ || typeof window > "u" || typeof document > "u") return;
103
+ $ = !0;
104
+ let e = Ne(Pe(Date.now()));
105
+ L(() => e.noteEpoch()), Z(() => e.noteUpdateReady()), setInterval(() => {
106
+ e.tick();
107
+ }, Me);
108
+ })();
56
109
  //#endregion
57
- export { D as ATTACH_FRAME_EVENT_KEY, w as FORGEABLE_HEADERS, b as LOCATOR_DENIED, N as LOCATOR_ERROR, x as LOCATOR_UNSUPPORTED, ie as account, j as assertAttachableFrameUrl, f as assertFetchableUrl, t as assertForgeableHeaders, v as assertLockdownApplicable, C as assertOneCookieIdentity, ue as attachFrame, S as attachFramePermission, d as box, H as cloud, pe as connect, ae as connectButtonUrl, _ as cookies, g as createFrame, L as createVideoElementHandle, Z as desktop, G as dgram, U as dns, X as extension, J as fetch, F as fetchCredentialedPermission, p as fetchLocalPermission, i as fetchPermission, Q as fs, O as gotoPermission, c as handleRevivableModules, ee as hasForgedCookie, K as http, r as isBlockedFetchUrl, T as isBlockedFrameUrl, u as isExtensionExposed, l as isLocalNetworkUrl, y as isLocatorDenied, E as isLocatorUnsupported, k as isTerminalError, n as isType, h as modifyRequestHeadersPermission, W as net, ne as opfs, re as packages, M as permissions, q as promptInstall, $ as promptRelay, I as readCookiePermission, fe as relayWorker, P as removeRequestHeaderRule, m as revive, a as setMissingExtensionHandler, te as setRequestHeaderRule, me as shell, o as type, s as waitForExtensionExposure };
110
+ export { x as ATTACH_FRAME_EVENT_KEY, t as FORGEABLE_HEADERS, h as LOCATOR_DENIED, m as LOCATOR_ERROR, b as LOCATOR_UNSUPPORTED, ve as account, T as assertAttachableFrameUrl, r as assertFetchableUrl, _ as assertForgeableHeaders, f as assertLockdownApplicable, ee as assertOneCookieIdentity, we as attachFrame, g as attachFramePermission, j as box, U as cloud, De as connect, ye as connectButtonUrl, k as cookies, u as createFrame, n as createVideoElementHandle, pe as desktop, K as dgram, W as dns, fe as extension, ue as fetch, ae as fetchCredentialedPermission, a as fetchLocalPermission, i as fetchPermission, he as fs, S as gotoPermission, re as handleRevivableModules, te as hasForgedCookie, ce as http, ne as isBlockedFetchUrl, y as isBlockedFrameUrl, o as isExtensionExposed, v as isLocalNetworkUrl, C as isLocatorDenied, D as isLocatorUnsupported, p as isTerminalError, se as isType, O as modifyRequestHeadersPermission, G as net, ge as opfs, _e as packages, E as permissions, le as promptInstall, Oe as promptRelay, ie as readCookiePermission, Ee as relayWorker, A as removeRequestHeaderRule, s as revive, c as setMissingExtensionHandler, d as setRequestHeaderRule, ke as shell, oe as type, l as waitForExtensionExposure };
@@ -0,0 +1,53 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs");let t=require("osra");var n=(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},r=e=>typeof e==`boolean`?+!!e:+!!e?.capture,i=e=>{let t=new WeakMap;return{addEventListener:(n,i,a)=>{if(i===null)return;let o=`${n}|${r(a)}`,s=t.get(i);if(s||(s=new Map,t.set(i,s)),s.has(o))return;let c=typeof a==`object`&&!!a&&!!a.once,l=t=>{c&&s.delete(o);let r=e.unenrich(t,n);typeof i==`function`?i.call(e.target,r):i.handleEvent(r)};s.set(o,l),e.remoteEvents.addEventListener(n,l,a)},removeEventListener:(n,i,a)=>{if(i===null)return;let o=`${n}|${r(a)}`,s=t.get(i),c=s?.get(o);c&&(e.remoteEvents.removeEventListener(n,c,a),s.delete(o))},dispatchEvent:t=>e.remoteEvents.dispatchEvent(t)}},a=e.t({box:()=>S,createVideoElementHandle:()=>b,isType:()=>x,revive:()=>C,type:()=>o}),o=`videoElement`,s=[`currentTime`,`volume`,`muted`,`playbackRate`,`src`,`loop`,`autoplay`,`preload`,`poster`,`disableRemotePlayback`],c=[`duration`,`paused`,`ended`,`seeking`,`readyState`,`currentSrc`],l=[`buffered`,`seekable`],u=Symbol.for(`fkn.remoteVideoElement`),d=Symbol.for(`fkn.remoteVideoElement.state`),f=Symbol.for(`fkn.remoteVideoElement.controller`),p=e=>e?Array.from({length:e.length},(t,n)=>[e.start(n),e.end(n)]):[],m=e=>{let t={};for(let n of[...s,...c])t[n]=e[n];for(let n of l)t[n]=p(e[n]);return t.error=e.error?{code:e.error.code,message:e.error.message}:null,t},h=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]}}},g=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,ee=e=>n(e,(e,t)=>({originalDetail:e instanceof CustomEvent?e.detail:null,snapshot:m(t)})),_=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}"`)}},v=e=>({call:async t=>_(e,t),set:async(t,n)=>{try{e[t]=n}catch{}return m(e)},events:ee(e)}),y=(e,t)=>{let n=new EventTarget;Object.defineProperty(n,u,{value:!0}),Object.defineProperty(n,d,{value:e}),Object.defineProperty(n,f,{value:t});let r=i({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})}}),a={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 g(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 s)a[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 c)a[t]={configurable:!0,enumerable:!0,get(){return e[t]}};for(let t of l)a[t]={configurable:!0,enumerable:!0,get(){return h(e[t])}};return Object.defineProperties(n,a),n},b=e=>y(m(e),v(e)),x=e=>typeof e==`object`&&!!e&&e[u]===!0,S=(e,n)=>{let r=e;return{...t.BoxBase,type:o,initialState:r[d],controller:(0,t.recursiveBox)(r[f],n)}},C=(e,n)=>{let r=(0,t.recursiveRevive)(e.controller,n);return y({...e.initialState},r)},w=e=>[a,...e],T=`FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY`,te=`fknExtension`,E=(0,t.createTypedEventTarget)();typeof document<`u`&&document.addEventListener(T,()=>{E.dispatchEvent(new CustomEvent(`statuschange`,{detail:{enabled:D()}}))});var D=()=>typeof document>`u`?!1:document.documentElement.dataset[te]===`true`,O=null,ne=e=>{O=e},re=150,k=(e=1e3)=>new Promise((t,n)=>{if(D())return t();let r,i=e=>{clearTimeout(r),s.disconnect(),document.removeEventListener(`readystatechange`,c),e()},a=()=>i(async()=>{if(O&&(await O().catch(()=>{}),D()))return t();n(Error(`The FKN WebExtension is not installed, enabled or not exposed on this page.`))}),o=()=>{clearTimeout(r),r=setTimeout(()=>D()?i(t):a(),re)},s=new MutationObserver(()=>{D()&&i(t)}),c=()=>{document.readyState===`complete`&&!D()&&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();D()&&i(t)}),A,j=new Proxy({},{get:(e,n)=>async(...e)=>{await k(),A??=(0,t.expose)({},{transport:window,revivableModules:w});let r=(await A)[n];return r(...e)}}),M=[`origin`,`referer`,`cookie`],ie=(e,t)=>(e??[]).some(([e,n])=>e.trim().toLowerCase()===t&&n!==``),ae=e=>ie(e,`cookie`),oe=(e,t)=>{if(t===`include`&&ae(e))throw Error(`fetch: a forged Cookie header and credentials:'include' are different identities - send one or the other`)},se=e=>{let t=[...new Set((e??[]).map(([e])=>e.trim().toLowerCase()).filter(e=>!M.includes(e)))];if(t.length)throw Error(`fetch: refusing to forge request header(s): ${t.join(`, `)}`)},ce=[`fkn.app`,`fkn.dev`,`sdbx.app`],le=e=>ce.some(t=>e===t||e.endsWith(`.${t}`)),ue={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.`},de={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.`},fe={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.`},pe=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},me=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:`):pe(n)},he=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`?!0:le(t.hostname)},ge=e=>{if(he(e))throw Error(`fetch: refusing to target the extension's own pages or FKN platform domains`)},_e=e=>{if(!e?.headers)return;let t=new Headers(e.headers),n=M.map(e=>{let n=t.get(e);return n===null||n===``?void 0:[e,n]}).filter(e=>e!==void 0);return n.length?n:void 0},ve=async(e,t)=>{let n=new Request(e,t);ge(n.url);let r=n.body?await n.arrayBuffer():null;return j.proxyFetch({url:n.url,method:n.method,headers:[...n.headers],body:r,credentials:t?.credentials===`include`?`include`:`omit`,redirect:n.redirect,unsafeHeaders:_e(t),reason:t?.reason,signal:t?.signal??void 0})},ye={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.`},be={get:e=>j.getCookie(e)},xe={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.`},Se=e=>j.setRequestHeaderRule(e),Ce=e=>j.removeRequestHeaderRule({ruleId:e}),we=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}},Te=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 Ee=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(`;`)}},De=(e,t)=>{t||={};let n=1,r=1;function i(){let e={line:n,column:r};return i=>(i.position=new Te(e,{line:n,column:r},t?.source||``),u(),i)}let a=[];function o(i){let o=new we(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 ee(){let n=[];if(!s())return o(`missing '{'`);for(d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=w();if(e){n.push(e),d(n);continue}}if(g()){let e=T();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 _(){let n=[];for(u(),d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=w();if(e){n.push(e),d(n);continue}}if(g()){let e=T();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 v(){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 y=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*`),b=C(`import`),x=C(`charset`),S=C(`namespace`);function C(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 w(){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=v();for(;p;)f.push(p),f=f.concat(d()),p=v();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=_();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=_();return c()?t({type:N.supports,supports:r,rules:a}):o(`@supports missing '}'`)}()||b()||x()||S()||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=_();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=w();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=_();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=_();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=_();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=_();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=_();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=_();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=y.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=_();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 T(){let e=i(),t=p();return t?(d(),e({type:N.rule,selectors:t,declarations:ee()||[]})):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=w()||T(),!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}}}())},Oe=(e,t)=>new Ee(t||{}).compile(e),z=`LocatorError`,B=`LocatorUnsupportedError`,V=`LocatorDeniedError`,ke=`LocatorInvalidError`,H=e=>typeof e==`object`&&e?e.name:void 0,U=e=>Object.assign(Error(e),{name:z}),Ae=(e,t=``,n)=>Object.assign(Error(e),{name:B,operation:t,backend:n}),je=(e,t)=>Ae(`Locator operation not supported${t?` on the ${t} backend`:``}: ${e}`,e,t),Me=(e,t)=>Object.assign(Error(e),{name:V,operation:t}),Ne=(e,t)=>Object.assign(Error(e),{name:ke,operation:t}),Pe=e=>H(e)===B,Fe=e=>H(e)===V,Ie=e=>H(e)===ke,Le=e=>Fe(e)||Pe(e)||Ie(e),W=e=>{let t=(e.ownerDocument??e).defaultView;if(!t)throw U(`the resolved element belongs to a document with no window`);return t},Re=(e,t)=>{let n=e?.[t];return typeof n==`function`?n:null},G=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=(()=>{try{return Re(W(e),t)}catch{return null}})();if(n&&e instanceof n)return n;let r=Re(globalThis,t);return r&&e instanceof r?r:null},K=(e,t)=>G(e,t)!==null,q=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]},ze=(e,t)=>{if(!K(e,t))throw U(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);return e},Be=e=>e.tagName.toLowerCase(),Ve=new Set,He=e=>{Ve.add(e)},Ue=/(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i,We=e=>e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16))).replace(/\\(.)/g,`$1`),Ge=e=>!Ue.test(We(e.value)),Ke=new Set([N.import,N.fontFace,N.namespace,N.charset,N.document,N.comment]),qe=e=>{if(Ke.has(e.type))return null;if(e.type===N.declaration)return Ge(e)?e:null;let t=e,n={...t};for(let e of[`declarations`,`rules`,`keyframes`]){let r=t[e];Array.isArray(r)&&(n[e]=Je(r))}return n},Je=e=>e.map(e=>qe(e)).filter(e=>e!==null),Ye=e=>{let t;try{t=De(e,{silent:!0})}catch{return``}return t.stylesheet.rules=Je(t.stylesheet.rules),Oe(t)},Xe=(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)},Ze={resolve:(e,t)=>{let n=e.document.createElement(`style`);n.textContent=t.noSanitize?t.content:Ye(t.content);try{Xe(e.document,n)}catch(e){console.error(e)}He(n)}},Qe=new Set([`set-cookie`,`set-cookie2`]),$e=e=>{let t=[];return e.forEach((e,n)=>{Qe.has(n.toLowerCase())||t.push([n,e])}),t},J={kind:`frame`,resolve:async(e,t,n={})=>{if(typeof t!=`string`)throw Ne(`fetch: url must be a string`,`fetch`);let r=W(e.document),i;try{i=new r.URL(t,e.document.baseURI).href}catch{throw Ne(`fetch: not a valid url: ${t}`,`fetch`)}let a=await r.fetch(i,{method:n.method??`GET`,headers:n.headers,body:n.body??null,redirect:n.redirect??`follow`,credentials:n.credentials??`include`});return{status:a.status,statusText:a.statusText,ok:a.ok,url:a.url,redirected:a.redirected,type:a.type,headers:$e(a.headers),body:await a.arrayBuffer()}}},et=(e,t)=>{let n=e.getBoundingClientRect();return{clientX:n.left+n.width*(t?.x??.5),clientY:n.top+n.height*(t?.y??.5)}},tt={resolve:(e,t={})=>{let n=q(e.elements),r=W(n),i={bubbles:!0,cancelable:!0,composed:!0,...et(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}))}},nt={resolve:(e,t={})=>{let n=q(e.elements),r=W(n),i={bubbles:!0,cancelable:!0,composed:!0,...et(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))}},rt=(e,t)=>{e._valueTracker?.setValue(``);let n=(G(e,`HTMLTextAreaElement`)??G(e,`HTMLInputElement`))?.prototype,r=n&&Object.getOwnPropertyDescriptor(n,`value`)?.set;r?r.call(e,t):e.value=t},it=(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}}},at={resolve:(e,t,n={})=>{let r=q(e.elements),i=W(r),a=K(r,`HTMLInputElement`);if(a||K(r,`HTMLTextAreaElement`)){let e=r,n=a?it(e,t):null;n&&(r.dispatchEvent(new i.PointerEvent(`pointerdown`,n.pointerDown)),r.dispatchEvent(new i.MouseEvent(`mousedown`,n.mouseDown))),rt(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(K(r,`HTMLElement`)&&r.isContentEditable){r.textContent=t,r.dispatchEvent(new i.Event(`input`,{bubbles:!0}));return}throw Error(`fill: element <${Be(r)}> is not fillable`)}},ot={resolve:(e,t={})=>q(e.elements).textContent},st={resolve:(e,t,n={})=>q(e.elements).getAttribute(t)},ct={resolve:(e,t={})=>{let n=q(e.elements);if(!K(n,`HTMLElement`))return!0;let r=W(n).getComputedStyle(n);if(r?.display===`none`||r?.visibility===`hidden`)return!1;let i=n.getBoundingClientRect();return i.width>0&&i.height>0}},lt={resolve:(e,t={})=>e.elements.length},ut={resolve:(e,t={})=>e.elements.length>0},Y=Object.freeze(Object.defineProperty({__proto__:null,click:tt,count:lt,exists:ut,fill:at,getAttribute:st,hover:nt,isVisible:ct,textContent:ot},Symbol.toStringTag,{value:`Module`})),X=(e,t)=>e.elements.flatMap(e=>[...e.querySelectorAll(t)]),Z=e=>e.replaceAll(`"`,`\\"`),dt={to:`element`,css:!0,resolve:(e,t)=>X(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`descend`})},ft={to:`frame`,css:!0,barrier:`down`,resolve:(e,t)=>X(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`down`})},Q={element:{selectors:{locator:dt,frameLocator:ft,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:tt,fill:at,hover:nt,textContent:ot,getAttribute:st,isVisible:ct,count:lt,exists:ut}},frame:{selectors:{locator:dt,frameLocator:ft,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:Ze,fetch:J}}},pt=(e,t=Q)=>({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}}}),mt=3e4,ht=50,gt=e=>{let t=e[e.length-1];return typeof t==`object`&&t?t:void 0},_t=e=>{let t=gt(e)?.timeout;return typeof t==`number`?t:mt},vt=({executor:e,parts:t})=>({highlight:n=>e.highlight(t,n).then(()=>{},()=>{})}),yt=async e=>{let t={parts:e.parts,operation:e.operation,args:e.args,phase:`ensure`};await e.gate?.(t,vt(e))},bt=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`},vt(e));let o=_t(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(Le(e))throw e;f=e;let t=s-Date.now();if(t<=0)break;await new Promise(e=>setTimeout(e,Math.min(ht,t)))}}finally{clearTimeout(d)}throw f},xt=(e,t,n,r)=>{let i={};for(let[a,o]of Object.entries(t[n].selectors))i[a]=(...i)=>xt(e,t,o.to,[...r,{kind:n,name:a,args:i}]);for(let a of Object.keys(t[n].operations))i[a]=(...t)=>bt({...e,parts:r,operation:a,args:t});return i.ensure=(t,n={})=>yt({...e,parts:r,operation:t,args:[n]}),i},St=e=>xt(e,e.modules??Q,`frame`,[]),Ct=pt({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={})=>b(ze(q(e.elements),`HTMLVideoElement`))}}},frame:{operations:{addStyleTag:{resolve:(e,t)=>Ze.resolve(e,t)},fetch:{resolve:(e,t,n={})=>J.resolve(e,t,n),kind:J.kind}}}}),wt=e=>{if(!e||e===`about:blank`)return!1;let t;try{t=new URL(e,location.href)}catch{return!1}return t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`?!0:t.protocol===`about:`?!1:le(t.hostname)},$=e=>{if(wt(e))throw Error(`attachFrame: refusing to target the extension's own pages or an FKN platform origin`)},Tt=({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`)},Et={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.`},Dt={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.`},Ot=e=>{let t=St({executor:e.executor,modules:Ct,gate:e.gate}),n=(t,n={})=>($(t),e.goto(t,n)),r=()=>e.url();return{...t,goto:n,url:r}},kt=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,At=async({iframe:e,domains:t=[],syncCookies:n=!0,lockdown:r=!1})=>{let i=crypto.randomUUID();if($(e.src),Tt({src:e.src,domains:t,lockdown:r}),await k(),!e.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);e.dispatchEvent(new CustomEvent(kt,{detail:i}));let{executeLocator:a,highlightLocator:o,ensureLocatorPermission:s,goto:c}=await j.attachFrame({marker:i,domains:t,syncCookies:n,lockdown:r});return Ot({executor:{execute:a,highlight:o},gate:e=>s(e.parts,e.operation,e.args),goto:(e,t={})=>c({url:e,...t}),url:()=>e.src})},jt={request:e=>j.requestPermissions(e.map(e=>({key:e.key,scope:e.scope??``,reason:e.reason})))};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return S}});