@fkn/lib 0.9.47 → 0.9.49

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 (60) hide show
  1. package/{storage-C6F9SnDM.js → account-storage-C31d68BN.js} +2 -2
  2. package/{storage-DmRIhg1P.cjs → account-storage-C6hcXjG0.cjs} +1 -1
  3. package/{storage-B_mXNAdB.d.ts → account-storage-DHl6bXdb.d.ts} +2 -2
  4. package/{api-DIBhBtcU.d.ts → api-wnOQJEK6.d.ts} +100 -2
  5. package/api.d.ts +2 -2
  6. package/cloud/dns.d.ts +1 -1
  7. package/cloud/fetch.d.ts +1 -1
  8. package/cloud/fs/promises.d.ts +1 -1
  9. package/cloud/fs.cjs +1 -1
  10. package/cloud/fs.d.ts +3 -3
  11. package/cloud/fs.js +12 -12
  12. package/cloud/net.d.ts +1 -1
  13. package/{cloud-BD7uzz5h.js → cloud-B4_qsdaE.js} +1 -1
  14. package/{cloud-DL4i8kvf.cjs → cloud-BmwojOb5.cjs} +1 -1
  15. package/{cloud-Bdw5nX-B.d.ts → cloud-CWHjH89l.d.ts} +4 -4
  16. package/cloud.cjs +1 -1
  17. package/cloud.d.ts +4 -4
  18. package/cloud.js +1 -1
  19. package/{contract-LOcbTDjP.d.ts → contract-DGuGXxKd.d.ts} +160 -2
  20. package/contract.cjs +1 -1
  21. package/contract.d.ts +3 -3
  22. package/contract.js +70 -1
  23. package/dgram.d.ts +2 -2
  24. package/dns.d.ts +1 -1
  25. package/{extension-Bsvr9OaV.d.ts → extension-C4Don9vi.d.ts} +1 -1
  26. package/{extension-BeIkBEi3.js → extension-hOZN6A1U.js} +1 -1
  27. package/{extension-eG1RMTDc.cjs → extension-uAlpUogG.cjs} +1 -1
  28. package/extension.cjs +1 -1
  29. package/extension.d.ts +2 -2
  30. package/extension.js +2 -2
  31. package/fs/promises.cjs +1 -1
  32. package/fs/promises.d.ts +1 -1
  33. package/fs/promises.js +1 -1
  34. package/{fs-lKZe5xIo.d.ts → fs-BZv2djbS.d.ts} +2 -2
  35. package/{fs-BY0Csn2V.js → fs-ClnOPmRF.js} +39 -39
  36. package/fs-zERmcLRS.cjs +1 -0
  37. package/fs.cjs +1 -1
  38. package/fs.d.ts +3 -3
  39. package/fs.js +2 -2
  40. package/http.d.ts +1 -1
  41. package/{index-D9x6A-Gx.d.ts → index-DawD_N1P.d.ts} +2 -2
  42. package/{index-iawzrUiB.d.ts → index-DlBWSKwV.d.ts} +6 -0
  43. package/index.cjs +1 -1
  44. package/index.d.ts +7 -6
  45. package/index.js +47 -46
  46. package/lib-5z-jA7ND.cjs +53 -0
  47. package/{lib-zMHWCUXz.js → lib-Dhq4W2V8.js} +27 -33
  48. package/{messages-d7pvCXPn.d.ts → messages-AdPfdoLV.d.ts} +1 -1
  49. package/messages.d.ts +1 -1
  50. package/{net-taIhsmvu.d.ts → net-C2sulnNU.d.ts} +2 -2
  51. package/net.d.ts +1 -1
  52. package/package.json +6 -1
  53. package/packages.d.ts +1 -1
  54. package/{proxy-CSKLtRTm.d.ts → proxy-MVuD49E2.d.ts} +2 -2
  55. package/rooms.d.ts +1 -1
  56. package/storage.cjs +1 -0
  57. package/storage.d.ts +69 -0
  58. package/storage.js +137 -0
  59. package/fs-DnF1cQuE.cjs +0 -1
  60. package/lib-CK2F5cc1.cjs +0 -53
@@ -0,0 +1,53 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./hosts-GNBhZO3-.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)return;let c=r.get(a);if(c===void 0){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),c={forward:i,listeners:new Set},r.set(a,c)}c.listeners.add(o),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!==void 0&&(o.listeners.delete(n),!(o.listeners.size>0)&&(e.removeEventListener(t,o.forward),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:()=>x,createVideoElementHandle:()=>b,isType:()=>ne,revive:()=>S,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}"`)}},ee=e=>({call:async t=>y(e,t),set:async(t,n)=>{try{e[t]=n}catch{}return h(e)},events:v(e)}),te=(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},b=e=>te(h(e),ee(e)),ne=e=>typeof e==`object`&&!!e&&e[d]===!0,x=(e,t)=>{let r=e;return{...n.BoxBase,type:s,initialState:r[f],controller:(0,n.recursiveBox)(r[p],t)}},S=(e,t)=>{let r=(0,n.recursiveRevive)(e.controller,t);return te({...e.initialState},r)},C=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},re=`headers`,w={type:re,isType:e=>e instanceof Headers,box:e=>({...n.BoxBase,type:re,entries:C(e)}),revive:e=>new Headers(e.entries)},ie=`response`,ae=new Set([101,204,205,304]),oe={type:ie,isType:e=>e instanceof Response,box:(e,t)=>({...n.BoxBase,type:ie,status:e.status,statusText:e.statusText,headers:w.box(e.headers),body:e.body?(0,n.recursiveBox)(e.body,t):null,url:e.url,redirected:e.redirected}),revive:(e,t)=>{if(e.status===0)return Response.error();let r=w.revive(e.headers),i=e.body?(0,n.recursiveRevive)(e.body,t):null,a=ae.has(e.status);i&&a&&i.cancel().catch(()=>{});let o=new Response(a?null:i,{status:e.status,statusText:e.statusText,headers:r});return e.url&&Object.defineProperty(o,"url",{value:e.url,configurable:!0}),e.redirected&&Object.defineProperty(o,"redirected",{value:!0,configurable:!0}),o}},se=e=>[o,w,oe,...e],ce=5,le=0,ue=`fknExtension`,de=`fknExtensionAbi`,fe=`fknExtensionOps`,pe=[`data-fkn-extension`,`data-fkn-extension-abi`,`data-fkn-extension-ops`],me=e=>{if(e===void 0)return 0;let t=Number(e);return Number.isInteger(t)&&t>=0?t:0},he=e=>e===void 0?null:e.split(`,`).map(e=>e.trim()).filter(Boolean),ge=(e,t=0)=>{if(e.fknExtension!==`true`)return{status:`absent`};let n=me(e[de]),r=he(e[fe]);return n<t?{status:`outdated`,abi:n,required:t,operations:r}:{status:`ok`,abi:n,operations:r}},_e=(e,t)=>e.status===`ok`?e.operations===null||e.operations.includes(t):!1,ve=(e,t)=>e.status===`ok`&&e.operations!==null&&e.operations.includes(t),T=class extends Error{abi;required;name=`ExtensionOutdatedError`;constructor(e,t){super(`The FKN WebExtension is installed but too old for this page: it speaks ABI ${e} and this page needs at least ${t}. Updating the extension fixes this.`),this.abi=e,this.required=t}},E=class extends Error{operation;abi;name=`ExtensionOperationUnsupportedError`;constructor(e,t,n){super(n??`The FKN WebExtension does not support "${e}" (ABI ${t}). Updating the extension may add it.`),this.operation=e,this.abi=t}},ye=`FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY`,be=(0,n.createTypedEventTarget)();typeof document<`u`&&document.addEventListener(ye,()=>{be.dispatchEvent(new CustomEvent(`statuschange`,{detail:{enabled:xe()}}))});var xe=()=>typeof document>`u`?!1:document.documentElement.dataset[ue]===`true`,D=()=>typeof document>`u`?{status:`absent`}:ge(document.documentElement.dataset),Se=null,Ce=e=>{Se=e},we=150,O=(e=1e3)=>new Promise((t,n)=>{let r=()=>D().status===`ok`;if(r())return t();let i,a=e=>{clearTimeout(i),c.disconnect(),document.removeEventListener(`readystatechange`,l),e()},o=()=>a(async()=>{let e=D();if(e.status===`outdated`)return n(new T(e.abi,e.required));if(Se){if(await Se().catch(()=>{}),r())return t();let e=D();if(e.status===`outdated`)return n(new T(e.abi,e.required))}n(Error(`The FKN WebExtension is not installed, enabled or not exposed on this page.`))}),s=()=>{clearTimeout(i),i=setTimeout(()=>r()?a(t):o(),we)},c=new MutationObserver(()=>{r()&&a(t)}),l=()=>{document.readyState===`complete`&&!r()&&s()};if(i=setTimeout(o,e),c.observe(document.documentElement,{attributes:!0,attributeFilter:[...pe]}),document.addEventListener(`readystatechange`,l),document.readyState===`complete`)return s();r()&&a(t)}),Te,k=new Proxy({},{get:(e,t)=>async(...e)=>{await O(),Te??=(0,n.expose)({},{transport:window,revivableModules:se});let r=(await Te)[t];return r(...e)}}),A=[`origin`,`referer`,`cookie`],Ee=(e,t)=>(e??[]).some(([e,n])=>e.trim().toLowerCase()===t&&n!==``),De=e=>Ee(e,`cookie`),Oe=(e,t)=>{if(t===`include`&&De(e))throw Error(`fetch: a forged Cookie header and credentials:'include' are different identities - send one or the other`)},ke=(e,t)=>{if(!Array.isArray(t))throw Error(`${e}: requestHeaders must be an array of header operations`);let n=[...new Set(t.map(e=>{let t=e?.header;return typeof t==`string`?t.trim().toLowerCase():String(t)}).filter(e=>!A.includes(e)))];if(n.length)throw Error(`${e}: refusing to rewrite request header(s): ${n.join(`, `)}`)},Ae=e=>{let t=[...new Set((e??[]).map(([e])=>e.trim().toLowerCase()).filter(e=>!A.includes(e)))];if(t.length)throw Error(`fetch: refusing to forge request header(s): ${t.join(`, `)}`)},je=[`fkn.app`,`fkn.dev`,`sdbx.app`,`fkn.cloudflareaccess.com`,`horionsoftware.com`,`62e9d4fbf21d90ebd4342e54b4babbd3.r2.cloudflarestorage.com`,`web-b3z.pages.dev`,`fkn-console.pages.dev`,`dev-dms.pages.dev`,`fkn-www.pages.dev`,`fkn-homepage.pages.dev`,`fkn-sandbox.pages.dev`,`internal-3ar.pages.dev`,`stub-ben.pages.dev`,`ripple-3t3.pages.dev`,`media-player-e3s.pages.dev`,`youtube-3c4.pages.dev`,`horionsoftware.pages.dev`,`container-ckf.pages.dev`,`stub-plugin.pages.dev`,`stub.plugins.banou.dev`],Me=e=>e.replace(/\.+$/,``),Ne=[`79.127.204.69`,`152.233.49.59`],Pe=e=>{let t;try{t=new URL(`http://${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}/`).hostname}catch{return}let n=/^\[(?:::ffff:|64:ff9b::)([0-9a-f]{1,4}):([0-9a-f]{1,4})\]$/.exec(t);if(n){let e=parseInt(n[1],16),t=parseInt(n[2],16);return[e>>8,e&255,t>>8,t&255].join(`.`)}return/^\d+\.\d+\.\d+\.\d+$/.test(t)?t:void 0},j=e=>{let t=Me(e);if(je.some(e=>t===e||t.endsWith(`.${e}`)))return!0;let n=Pe(t);return n!==void 0&&Ne.includes(n)},Fe={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.`},Ie={scope:`network.fetchCredentialed`,category:`network`,severity:3,chip:`load as you`,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.`},Le={scope:`network.fetchLocal`,category:`network`,severity:3,chip:`local network`,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.`},Re=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},ze=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:`):Re(n)},Be=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`||j(t.hostname)},Ve=e=>{if(Be(e))throw Error(`fetch: refusing to target the extension's own pages or FKN platform domains`)},He=e=>{if(!e?.headers)return;let t=new Headers(e.headers),n=A.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},Ue=async(e,t)=>{let n=new Request(e,t);Ve(n.url);let r=n.body?await n.arrayBuffer():null;return k.proxyFetch({url:n.url,method:n.method,headers:[...n.headers],body:r,credentials:t?.credentials===`include`?`include`:`omit`,redirect:n.redirect,unsafeHeaders:He(t),reason:t?.reason,signal:t?.signal??void 0})},We=e=>{for(let t of e)if(typeof t==`string`&&j(t.trim().toLowerCase()))return t},Ge=e=>{let t=e.trim().toLowerCase().replace(/^\.+|\.+$/g,``);return t!==``&&(j(t)||[...je,...Ne].some(e=>e.endsWith(`.${t}`)))},Ke=e=>{for(let t of e)if(typeof t==`string`&&Ge(t))return t},qe=e=>`${e}: refusing to target FKN platform domains`,Je=(e,t)=>{if(We(t)!==void 0)throw Error(qe(e))},Ye=e=>{try{return new URL(String(e)).hostname}catch{return``}},M=(e,t)=>{if(Ke(t)!==void 0)throw Error(qe(e))},Xe={scope:`network.readCookie`,category:`network`,severity:3,chip:`read cookie`,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.`},Ze={get:async e=>(Je(`cookies.get`,[Ye(e.url)]),k.getCookie(e))},Qe={scope:`network.modifyRequestHeaders`,category:`network`,severity:2,chip:`rewrite headers`,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.`},$e=async e=>(M(`setRequestHeaderRule`,e.domains),ke(`setRequestHeaderRule`,e.requestHeaders),k.setRequestHeaderRule(e)),et=e=>k.removeRequestHeaderRule({ruleId:e}),tt=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}},nt=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 rt=(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`)},P=(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=P(e,[`)`],o+1);if(t===-1)return-1;r=t+1}break;case`"`:{let t=rt(e,[`"`],o+1);if(t===-1)return-1;r=t+1}break;case`'`:{let t=rt(e,[`'`],o+1);if(t===-1)return-1;r=t+1}break;default:return o}i--}while(i>0);throw Error(`Too many escaping`)},F=/\/\*[^]*?(?:\*\/|$)/g;function I(e){return e?e.trim():``}function it(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=>{it(e,r)}):n&&typeof n==`object`&&it(n,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var at=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(`;`)}},ot=(e,t)=>{t||={};let n=1,r=1;function i(){let e={line:n,column:r};return i=>(i.position=new nt(e,{line:n,column:r},t?.source||``),u(),i)}let a=[];function o(i){let o=new tt(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=P(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=P(e,t,r);if(i===-1)return n.push(e.substring(r)),n;n.push(e.substring(r,i)),r=i+1}return n})(I(n).replace(F,``),[`,`]).map(e=>I(e))}function m(){let t=i(),n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);if(!n)return;l(n);let r=I(n[0]),a=/^:\s*/.exec(e);if(!a)return o(`property missing ':'`);l(a);let s=``,c=P(e,[`;`,`}`]);c!==-1&&(s=e.substring(0,c),l([s]),s=I(s).replace(F,``));let u=t({type:N.declaration,property:r.replace(F,``),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=P(e,[`{`]);if(t===-1)return!1;let n=P(e,[`;`]),r=P(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=S();if(e){n.push(e),d(n);continue}}if(g()){let e=C();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=S();if(e){n.push(e),d(n);continue}}if(g()){let e=C();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 ee=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*`),te=x(`import`),b=x(`charset`),ne=x(`namespace`);function x(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 S(){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=I(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:I(r[1]),media:I(r[2])})}()||function(){let t=i(),n=/^@supports *([^{]+)/.exec(e);if(!n)return;let r=I(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 '}'`)}()||te()||b()||ne()||function(){let t=i(),n=/^@([-\w]+)?document *([^{]+)/.exec(e);if(!n)return;let r=l(n),a=I(r[1]),u=I(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=S();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=I(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=I(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=I(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=I(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=ee.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=P(e,[`{`,`;`]);if(u!==-1&&u>0&&(a=I(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 C(){let e=i(),t=p();return t?(d(),e({type:N.rule,selectors:t,declarations:_()||[]})):o(`selector missing`)}return it(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=S()||C(),!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}}}())},st=(e,t)=>new at(t||{}).compile(e),ct=Object.defineProperty,lt=(e,t)=>{let n={};for(var r in e)ct(n,r,{get:e[r],enumerable:!0});return t||ct(n,Symbol.toStringTag,{value:`Module`}),n},ut=`LocatorError`,dt=`LocatorUnsupportedError`,ft=`LocatorDeniedError`,pt=`LocatorInvalidError`,mt=e=>typeof e==`object`&&e?e.name:void 0,L=e=>Object.assign(Error(e),{name:ut}),R=(e,t=``,n)=>Object.assign(Error(e),{name:dt,operation:t,backend:n}),ht=(e,t)=>R(`Locator operation not supported${t?` on the ${t} backend`:``}: ${e}`,e,t),z=(e,t)=>Object.assign(Error(e),{name:ft,operation:t}),gt=(e,t)=>Object.assign(Error(e),{name:pt,operation:t}),B=class extends Error{name=`TimeoutError`;constructor(e,t){super(e,t?.cause===void 0?void 0:{cause:t.cause})}},_t=e=>mt(e)===dt,vt=e=>mt(e)===ft,yt=e=>mt(e)===pt,bt=e=>vt(e)||_t(e)||yt(e),V=e=>{let t=(e.ownerDocument??e).defaultView;if(!t)throw L(`the resolved element belongs to a document with no window`);return t},xt=(e,t)=>{let n=e?.[t];return typeof n==`function`?n:null},St=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=(()=>{try{return xt(V(e),t)}catch{return null}})();if(n&&e instanceof n)return n;let r=xt(globalThis,t);return r&&e instanceof r?r:null},H=(e,t)=>St(e,t)!==null,U=e=>{if(e.length===0)throw L(`No elements found`);if(e.length>1)throw L(`Strict mode violation: locator resolved to ${e.length} elements`);return e[0]},Ct=(e,t)=>{if(!H(e,t))throw L(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);return e},wt=e=>e.tagName.toLowerCase(),Tt=new Set,Et=e=>{Tt.add(e)},Dt=/(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i,Ot=e=>e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16))).replace(/\\(.)/g,`$1`),kt=e=>!Dt.test(Ot(e.value)),At=new Set([N.import,N.fontFace,N.namespace,N.charset,N.document,N.comment]),jt=e=>{if(At.has(e.type))return null;if(e.type===N.declaration)return kt(e)?e:null;let t=e,n={...t};for(let e of[`declarations`,`rules`,`keyframes`]){let r=t[e];Array.isArray(r)&&(n[e]=Mt(r))}return n},Mt=e=>e.map(e=>jt(e)).filter(e=>e!==null),Nt=e=>{let t;try{t=ot(e,{silent:!0})}catch{return``}return t.stylesheet.rules=Mt(t.stylesheet.rules),st(t)},Pt=(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)},Ft={resolve:(e,t)=>{let n=e.document.createElement(`style`);n.textContent=t.noSanitize?t.content:Nt(t.content);try{Pt(e.document,n)}catch(e){console.error(e)}Et(n)}},It=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},W={kind:`frame`,ensureArgs:e=>[void 0,e],resolve:async(e,t,n={})=>{if(typeof t!=`string`)throw gt(`fetch: url must be a string`,`fetch`);let r=V(e.document),i;try{i=new r.URL(t,e.document.baseURI).href}catch{throw gt(`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:It(a.headers),body:await a.arrayBuffer()}}},G=lt({click:()=>Rt,count:()=>Kt,exists:()=>qt,fill:()=>Ht,getAttribute:()=>Wt,hover:()=>zt,isVisible:()=>Gt,textContent:()=>Ut}),Lt=(e,t)=>{let n=e.getBoundingClientRect();return{clientX:n.left+n.width*(t?.x??.5),clientY:n.top+n.height*(t?.y??.5)}},Rt={resolve:(e,t={})=>{let n=U(e.elements),r=V(n),i={bubbles:!0,cancelable:!0,composed:!0,...Lt(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}))}},zt={resolve:(e,t={})=>{let n=U(e.elements),r=V(n),i={bubbles:!0,cancelable:!0,composed:!0,...Lt(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))}},Bt=(e,t)=>{e._valueTracker?.setValue(``);let n=(St(e,`HTMLTextAreaElement`)??St(e,`HTMLInputElement`))?.prototype,r=n&&Object.getOwnPropertyDescriptor(n,`value`)?.set;r?r.call(e,t):e.value=t},Vt=(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}}},Ht={resolve:(e,t,n={})=>{let r=U(e.elements),i=V(r),a=H(r,`HTMLInputElement`);if(a||H(r,`HTMLTextAreaElement`)){let e=r,n=a?Vt(e,t):null;n&&(r.dispatchEvent(new i.PointerEvent(`pointerdown`,n.pointerDown)),r.dispatchEvent(new i.MouseEvent(`mousedown`,n.mouseDown))),Bt(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(H(r,`HTMLElement`)&&r.isContentEditable){r.textContent=t,r.dispatchEvent(new i.Event(`input`,{bubbles:!0}));return}throw Error(`fill: element <${wt(r)}> is not fillable`)}},Ut={resolve:(e,t={})=>U(e.elements).textContent},Wt={resolve:(e,t,n={})=>U(e.elements).getAttribute(t)},Gt={resolve:(e,t={})=>{let n=U(e.elements);if(!H(n,`HTMLElement`))return!0;let r=V(n).getComputedStyle(n);if(r?.display===`none`||r?.visibility===`hidden`)return!1;let i=n.getBoundingClientRect();return i.width>0&&i.height>0}},Kt={resolve:(e,t={})=>e.elements.length},qt={resolve:(e,t={})=>e.elements.length>0},K=(e,t)=>(e.topLevel?[e.document]:e.elements).flatMap(e=>[...e.querySelectorAll(t)]),Jt=e=>e.replaceAll(`"`,`\\"`),Yt={to:`element`,css:!0,resolve:(e,t)=>K(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`descend`})},Xt={to:`frame`,css:!0,barrier:`down`,resolve:(e,t)=>K(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`down`})},Zt={element:{selectors:{locator:Yt,frameLocator:Xt,getByRole:{to:`element`,resolve:(e,t)=>K(e,`[role="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[role="${Jt(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("${Jt(e)}")`:`:has-text(...)`})},getByTestId:{to:`element`,resolve:(e,t)=>K(e,`[data-testid="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[data-testid="${Jt(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:Rt,fill:Ht,hover:zt,textContent:Ut,getAttribute:Wt,isVisible:Gt,count:Kt,exists:qt}},frame:{selectors:{locator:Yt,frameLocator:Xt,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:Ft,fetch:W}}},Qt=(e,t=Zt)=>({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}}}),$t=3e4,en=50,tn=e=>{let t=e[e.length-1];return typeof t==`object`&&t?t:void 0},nn=e=>{let t=tn(e)?.timeout;return typeof t==`number`?t:$t},rn=({executor:e,parts:t})=>({highlight:n=>e.highlight(t,n).then(()=>{},()=>{})}),an=async e=>{let t={parts:e.parts,operation:e.operation,args:e.args,phase:`ensure`};await e.gate?.(t,rn(e))},on=(e,t)=>{if(t!==void 0&&typeof t==`number`&&!(Number.isFinite(t)&&t>0))throw TypeError(`${e}: timeout must be a positive number of milliseconds, not ${t}; every call ends at its deadline, so 0 does not turn it off`)},sn=e=>typeof e==`object`&&e&&typeof e.message==`string`?e.message:String(e),cn=async e=>{let{executor:t,gate:n,parts:r,operation:i,args:a}=e;on(i,tn(a)?.timeout),n&&await n({parts:r,operation:i,args:a,phase:`execute`},rn(e));let o=nn(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(bt(e))throw e;f=e;let t=s-Date.now();if(t<=0)break;await new Promise(e=>setTimeout(e,Math.min(en,t)))}}finally{clearTimeout(d)}throw f===c?new B(c.message):new B(sn(f),{cause:f})},ln=(e,t,n,r,i)=>{let a={};for(let[o,s]of Object.entries(t[r].selectors))a[o]=(...a)=>ln(e,t,n,s.to,[...i,{kind:r,name:o,args:a}]);for(let[n,o]of Object.entries(t[r].operations))a[n]=async(...t)=>cn({...e,parts:i,operation:n,args:o.send?o.send(...t):t});for(let[o,{to:s,rewrite:c}]of Object.entries(n[r]??{}))a[o]=(...r)=>ln(e,t,n,s,c(i,...r));return a.ensure=(n,a={})=>{let o=t[r].operations[n]?.ensureArgs;return an({...e,parts:i,operation:n,args:o?.(a)??[a]})},a},un=e=>ln(e,e.modules??Zt,e.rewrites??{},`frame`,[]),dn=()=>{let e=D();return e.status===`ok`&&e.abi>=2},fn=async()=>{await O();let e=D();if(e.status===`ok`&&e.abi<2)throw new T(e.abi,2)},pn=e=>`Read the text, links and details ${e} shows.`,mn=e=>`Inject unfiltered styles or code into ${e}. This can pass page details along to other sites.`,hn=[{id:`interaction`,heading:`Interaction`,summary:`Allow the app to interact with the website (clicks, type in text, etc.)`,title:e=>`Interact with ${e}`,description:(e,t)=>t?`Click, type and hover on ${e} for you. If you are signed in there, this happens as you.`:`Click, type and hover on ${e} for you, in a signed-out view.`,cloudTitle:e=>`Click and type on ${e}`,cloudDescription:e=>`Clicks, types and scrolls on ${e} for you.`},{id:`storage`,heading:`Site data`,summary:`Can read the website's data`,title:e=>`Read data from ${e}`,description:pn,cloudTitle:e=>`Read what's on ${e}`,cloudDescription:pn},{id:`network`,heading:`Network`,summary:`Make requests on behalf of the website (using your cookies, etc.)`,title:e=>`Make requests to ${e} as you`,description:e=>`Load pages and data from ${e} and send changes there with your signed-in session.`,cloudTitle:e=>`Load and send data on ${e}`,cloudDescription:e=>`Loads pages and data from ${e} and sends changes there.`},{id:`evaluation`,heading:`Evaluation`,summary:`Can execute arbitrary code on the website`,title:e=>`Run code on ${e}`,description:mn,cloudTitle:e=>`Run its own code on ${e}`,cloudDescription:mn}],gn=e=>t=>{if(typeof t!=`object`||!t)return t===void 0?[]:[t];if(t.position!==void 0)throw TypeError(`${e}: position is Playwright's offset in pixels, which no backend serves yet; pass relativePosition, a 0..1 fraction of the box`);let{relativePosition:n,...r}=t;return[n===void 0?r:{...r,position:n}]},_n=async(e,t,n)=>{try{return await W.resolve(e,t,n)}catch(e){throw bt(e)?e:z(`frame.fetch: ${e instanceof Error?`${e.name}: ${e.message}`:String(e)}; not retried, since the request may already have been sent`,`fetch`)}},vn=Qt({element:{operations:{click:{resolve:(e,t={})=>G.click.resolve(e,t),send:gn(`click`)},hover:{resolve:(e,t={})=>G.hover.resolve(e,t),send:gn(`hover`)},fill:{resolve:(e,t,n={})=>G.fill.resolve(e,t,n)},textContent:{resolve:(e,t={})=>G.textContent.resolve(e)},getAttribute:{resolve:(e,t,n={})=>G.getAttribute.resolve(e,t)},isVisible:{resolve:(e,t={})=>G.isVisible.resolve(e)},count:{resolve:(e,t={})=>G.count.resolve(e)},exists:{resolve:(e,t={})=>G.exists.resolve(e)},videoElement:{resolve:(e,t={})=>b(Ct(U(e.elements),`HTMLVideoElement`))}}},frame:{operations:{addStyleTag:{resolve:(e,t)=>Ft.resolve(e,t)},fetch:{resolve:(e,t,n={})=>_n(e,t,n),kind:W.kind,ensureArgs:W.ensureArgs},evaluate:{kind:`frame`,typed:!1,resolve:(e,t,n)=>{throw ht(`evaluate`,`this realm`)}}}}}),yn=e=>e[e.length-1],bn={element:{last:{to:`element`,rewrite:e=>[...e,{kind:`element`,name:`nth`,args:[-1]}]},contentFrame:{to:`frame`,rewrite:e=>{let t=yn(e);if(t?.name!==`locator`)throw TypeError(`locator.contentFrame: only a locator that ends in locator(selector) can enter its frame; use frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`frameLocator`}]}}},frame:{owner:{to:`element`,rewrite:e=>{let t=yn(e);if(t?.name!==`frameLocator`)throw TypeError(`frameLocator.owner: this frame was not entered through frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`locator`}]}},getByTestId:{to:`element`,rewrite:(e,t)=>[...e,{kind:`element`,name:`getByTestId`,args:[t]}]}}},xn=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:`||t.protocol!==`about:`&&j(t.hostname)},q=e=>{if(xn(e))throw Error(`attachFrame: refusing to target the extension's own pages or an FKN platform origin`)},Sn=({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`)},Cn={scope:`embed.iframe`,category:`interaction`,severity:0,title:`Load another website inside this app`,description:`Lets the app embed external pages directly inside its own view.`},wn={scope:`embed.open`,category:`interaction`,severity:0,title:`Open a website inside this app`,description:`Lets the app navigate to another site without leaving its window.`},Tn=[`load`,`commit`],En=e=>{if(`timeoutMs`in e)throw TypeError(`frame.goto: pass timeout, in milliseconds; timeoutMs is not an option`);let{waitUntil:t,timeout:n}=e;if(t!==void 0&&!Tn.includes(t))throw TypeError(`frame.goto: waitUntil must be 'load' or 'commit', not ${JSON.stringify(t)}`);if(n!==void 0&&typeof n!=`number`)throw TypeError(`frame.goto: timeout must be a number of milliseconds`);on(`frame.goto`,n)},Dn=class extends Error{name=`FrameWindowBlockedError`;constructor(){super(`attachFrame: the browser did not open the window. Call attachFrame directly in a click or key handler, and allow popups for this page`)}},On=new Set([`jar-unreachable`,`bad-url`,`opaque-opener`]),kn=class extends Error{name=`FrameWindowRefusedError`;reason;constructor(e){let t=On.has(e)?e:`unknown`;super(t===`opaque-opener`?`attachFrame: this page has an opaque origin, which a window can never answer, so no window was opened`:`attachFrame: the window refused to attach (${t}), and loaded nothing`),this.reason=t}},An=[`message`,`document`],jn=e=>{if(e===`*`)return`*`;let t=()=>TypeError(`frame.postMessage: targetOrigin must be '*' or an origin, not ${JSON.stringify(e)}`);if(typeof e!=`string`)throw t();let n;try{n=new URL(e).origin}catch{throw t()}if(n===`null`)throw t();return n},Mn=(e,t)=>{let n=typeof e==`object`&&!!e;if(n&&t!==void 0)throw TypeError(`frame.postMessage: pass transfer inside the options object, not after it`);let r=n?e.targetOrigin??`*`:e??`*`,i=n?e.transfer:t;if(i!==void 0&&!Array.isArray(i))throw TypeError(`frame.postMessage: transfer must be an array`);return{targetOrigin:jn(r),transfer:i===void 0?[]:[...i]}},Nn=[`url`,`path`,`type`],Pn=[`content`,`sourceUrl`],Fn=/[\n\r\u2028\u2029]/,In=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`frame.addScriptTag: options must be an object { content }`);let t=Object.keys(e),n=t.find(e=>Nn.includes(e));if(n!==void 0)throw TypeError(`frame.addScriptTag: "${n}" is not served; it runs content as a classic inline script`);let r=t.find(e=>!Pn.includes(e));if(r!==void 0)throw TypeError(`frame.addScriptTag: unknown option "${r}"`);let{content:i,sourceUrl:a}=e;if(typeof i!=`string`)throw TypeError(`frame.addScriptTag: content must be a string`);if(a!==void 0&&(typeof a!=`string`||a===``||Fn.test(a)))throw TypeError(`frame.addScriptTag: sourceUrl must be a non-empty string with no line break`);return a===void 0?{content:i}:{content:i,sourceUrl:a}},Ln=[`name`,`domain`,`path`],Rn=e=>e instanceof RegExp||Object.prototype.toString.call(e)===`[object RegExp]`,zn=e=>{if(e===void 0)return{};if(Object.prototype.toString.call(e)!==`[object Object]`)throw TypeError(`frame.clearCookies: options must be an object`);let t=e,n=Object.keys(t).find(e=>!Ln.includes(e));if(n!==void 0)throw TypeError(`frame.clearCookies: unknown option "${n}"`);let r=Ln.flatMap(e=>{let n=t[e];return n===void 0?[]:[{key:e,value:n}]}),i=r.find(({value:e})=>Rn(e));if(i!==void 0)throw TypeError(`frame.clearCookies: ${i.key} is a RegExp, and clearCookies takes strings for name, domain and path for now`);let a=r.find(({value:e})=>typeof e!=`string`);if(a!==void 0)throw TypeError(`frame.clearCookies: ${a.key} must be a string`);let o=r.find(({value:e})=>e===``);if(o!==void 0)throw TypeError(`frame.clearCookies: ${o.key} must not be empty; leave it out to match every ${o.key}`);let s={};for(let{key:e,value:t}of r)s[e]={equals:t};return s},Bn=e=>{typeof globalThis.reportError==`function`?globalThis.reportError(e):console.error(e)},Vn=e=>{let{owner:t,...n}=un({executor:e.executor,modules:vn,rewrites:bn,gate:e.gate}),r=async(t,n={})=>(q(t),En(n),e.goto(t,n)),i=()=>e.url(),a=async t=>{let n=e.requestPermissions;if(!n)throw Error(`frame.requestPermissions: this backend cannot ask for permission categories`);return n(t)},o=async(t,n)=>{let r=e.evaluate;if(!r)throw Error(`frame.evaluate: this backend cannot run code in the attached frame`);let i=typeof t==`function`?t.toString():t;if(typeof i!=`string`)throw TypeError(`frame.evaluate: pass a function or a source string`);return r(i,structuredClone(n))},s=async t=>{let{content:n,...r}=In(t),i=e.addScriptTag;if(!i)throw Error(`frame.addScriptTag: this backend cannot run scripts in the attached frame`);await i(n,r)},c=async t=>{let n=zn(t),r=e.clearCookies;if(!r)throw Error(`frame.clearCookies: this backend cannot clear cookies`);await r(n)},l=((t,n,r)=>{try{let i=e.postMessage;if(!i)throw Error(`frame.postMessage: this backend cannot message the attached frame`);let a=Mn(n,r);return i(t,a.targetOrigin,a.transfer)}catch(e){return Promise.reject(e)}}),u={message:new Set,document:new Set},d=null,f=(e,t)=>{if(!An.includes(e))throw TypeError(`frame.${t}: the event type must be ${An.map(e=>`'${e}'`).join(` or `)}, not ${JSON.stringify(e)}`);return u[e]},p=e=>{let t=e.type===`message`?Object.freeze({type:`message`,data:e.data,origin:e.origin,ports:Object.freeze([...e.ports]),source:_}):Object.freeze({type:`document`,origin:e.origin});for(let n of[...u[e.type]])try{n(t)}catch(e){Bn(e)}},m=(e,t)=>{if(f(e,`off`).delete(t),d!==null&&!u.message.size&&!u.document.size){let e=d;d=null,e()}},h=(t,n,r={})=>{let i=f(t,`on`);if(typeof n!=`function`)throw TypeError(`frame.on: the listener must be a function`);let{signal:a}=r;if(!(a?.aborted||i.has(n))){if(d===null){let t=e.listen;if(!t)throw Error(`frame.on: this backend cannot relay the page's messages`);d=t(p)}i.add(n),a?.addEventListener(`abort`,()=>m(t,n),{once:!0})}},g=()=>e.backend,_={...n,goto:r,url:i,backend:g,requestPermissions:a,evaluate:o,addScriptTag:s,clearCookies:c,postMessage:l,on:h,off:m};return _},Hn=[t.v,t._,t.y,t.h,t.g,t.n,t.i,t.r,t.f,t.a,t.o,t.s,t.p,Cn,wn,t.u,t.d,Fe,Ie,Le,Xe,Qe],Un=hn.map(e=>e.id),Wn={interaction:`act.click`,storage:`read.text`,network:`network.fetchCredentialed`,evaluation:`media.appearU`},Gn=e=>e===0?`auto`:e===4?`critical`:`bundled`,Kn=Hn,J=new Map,qn={};(()=>{J=new Map(Kn.map(e=>[e.scope,e])),qn=Object.fromEntries(J),Kn.filter(e=>e.severity===4).map(e=>e.scope);let e=e=>Kn.filter(t=>t.category===e&&Gn(t.severity)===`bundled`);Object.fromEntries(Un.map(t=>[t,Math.max(0,...e(t).map(e=>e.severity))])),Object.fromEntries(Un.map(t=>[t,e(t).some(e=>e.unsafe===!0)]))})();var Jn=e=>J.get(e)?.category,Yn=e=>{let t=J.get(e);return t&&Gn(t.severity)},Xn=e=>{let t=J.get(e);if(t)return Gn(t.severity)===`critical`?t.scope:t.category},Zn=e=>Wn[e],Qn=({category:e,key:t})=>{let n=t??(e&&Zn(e));return n!==void 0&&Jn(n)!==void 0?n:void 0},$n=(e,t)=>{for(let{category:n,key:r}of t)if(Qn({category:n,key:r})===void 0)throw TypeError(r===void 0?n===void 0?`${e}: name a category or a permission key`:`${e}: unknown permission category "${n}"`:`${e}: unknown permission key "${r}"`)},er=(e,t={})=>{let n=[],r=e.map(e=>{let r=Qn(e),i=[];if(r!==void 0)for(let a of e.hosts)i.push(n.length),n.push({...t,key:r,scope:``,site:a,hosts:e.hosts,reason:e.reason});return{key:r!==void 0&&Yn(r)===`critical`?r:void 0,category:r===void 0?e.category??`interaction`:qn[r].category,hosts:e.hosts,indexes:i}});return{items:n,answer:e=>r.map(({key:t,category:n,hosts:r,indexes:i})=>({category:n,...t===void 0?{}:{key:t},hosts:r,allow:i.length>0&&i.every(t=>e[t]?.allow===!0)}))}},tr=e=>typeof e==`object`&&!!e,nr=typeof chrome<`u`&&!!chrome.runtime?.id,rr=e=>tr(e)&&e.FKN_WEB_EXTENSION_FRAME_ANNOUNCE_KEY===!0&&typeof e.frameId==`string`&&typeof e.document==`string`,ir=new WeakMap,ar=new WeakMap,or=new WeakMap,sr=new Set;typeof window<`u`&&nr&&window.addEventListener(`message`,e=>{if(!rr(e.data))return;e.stopImmediatePropagation();let t=e.source;if(!t||typeof t!=`object`)return;let n=t,r=ir.get(n),i=e.data.frameId,a=e.data.document;if(ir.set(n,i),ar.set(n,a),r)for(let e of sr)e(r);let o=or.get(n);if(o){for(let e of[...o])(e.notDocument===void 0||e.notDocument!==a)&&(o.delete(e),e.resolve(i));o.size||or.delete(n)}},{capture:!0});var cr=3e4,lr=`frame.evaluate: the code did not settle within ${cr}ms`,ur=()=>new B(lr),dr=e=>yt(e)&&e.message===lr?ur():e,fr=[/^frame load timed out after \d+ms for /,/^frame goto: documentstart timed out$/,/^navigation to .+ did not commit a document within \d+ms$/s],pr=e=>{if(e instanceof B)return e;let t=typeof e?.message==`string`?e.message:``;return fr.some(e=>e.test(t))?new B(t):e},mr=e=>{let t=e;if(t.window===void 0)return`iframe`;if(t.iframe!==void 0)throw TypeError(`attachFrame: pass either iframe or window, not both`);if(t.lockdown)throw TypeError(`attachFrame: lockdown applies to an iframe, never to a window`);if(t.blank!==void 0)throw TypeError(`attachFrame: blank does not apply to a window`);if(typeof t.window!=`object`||t.window===null)throw TypeError(`attachFrame: window must be an object`);return`window`},hr=(e,t,n)=>{if(e===void 0)return t;if(typeof e!=`number`||!Number.isFinite(e)||e<=0)throw TypeError(`attachFrame: window.${n} must be a positive number of CSS pixels`);return Math.round(e)},gr=({url:e,width:t,height:n})=>{let r=(()=>{if(e===void 0||e===``||e===`about:blank`)return``;if(typeof e!=`string`)throw TypeError(`attachFrame: window.url must be a string`);let t=(()=>{try{return new URL(e,location.href)}catch{throw TypeError(`attachFrame: window.url is not a valid URL: ${e}`)}})();if(t.protocol!==`http:`&&t.protocol!==`https:`)throw TypeError(`attachFrame: window.url must be an http or https address`);return t.href})();return r&&q(r),{url:r,width:hr(t,500,`width`),height:hr(n,700,`height`)}},_r=`attachFrame: storageState seeds a fresh jar, so it needs cookies: 'ephemeral'`,vr=1e11,yr=[`name`,`value`,`domain`,`path`,`expires`,`httpOnly`,`secure`,`sameSite`],br=[`Strict`,`Lax`,`None`],Y=/[;\x00-\x1f\x7f]/,X=(e,t)=>TypeError(`attachFrame: storageState${e} ${t}`),Z=e=>Object.prototype.toString.call(e)===`[object Object]`,xr=e=>{let t=e.startsWith(`.`)?e.slice(1):e;if(t===``)return null;try{return new URL(`http://${t}/`).hostname===t.toLowerCase()?t.toLowerCase():null}catch{return null}},Sr=(e,t)=>{if(!Z(e))throw X(t,`must be an object`);let n=Object.keys(e).find(e=>!yr.includes(e));if(n!==void 0)throw X(`${t}.${n}`,`is not a cookie field`);let{name:r,value:i,domain:a,path:o,expires:s,httpOnly:c,secure:l,sameSite:u}=e;if(typeof r!=`string`||r===``||r.includes(`=`)||Y.test(r))throw X(`${t}.name`,`must be a non-empty string with no "=", ";" or control character`);if(typeof i!=`string`||Y.test(i))throw X(`${t}.value`,`must be a string with no ";" or control character`);if(typeof a!=`string`||xr(a)===null)throw X(`${t}.domain`,`must be a host: ".youtube.com" for a cookie its subdomains also receive, "www.youtube.com" for a host-only one`);if(o!==void 0&&(typeof o!=`string`||!o.startsWith(`/`)||Y.test(o)))throw X(`${t}.path`,`must be a string starting with "/"`);if(s!==void 0&&(typeof s!=`number`||!Number.isFinite(s)||s<=0&&s!==-1))throw X(`${t}.expires`,`must be -1 for a session cookie, or milliseconds since the epoch`);if(c!==void 0&&typeof c!=`boolean`)throw X(`${t}.httpOnly`,`must be a boolean`);if(l!==void 0&&typeof l!=`boolean`)throw X(`${t}.secure`,`must be a boolean`);if(u!==void 0&&!br.includes(u))throw X(`${t}.sameSite`,`must be 'Strict', 'Lax' or 'None', not ${JSON.stringify(u)}`);let d=r.toLowerCase();if(u===`None`&&l!==!0)throw X(t,`is SameSite=None, which needs secure: true`);if(d.startsWith(`__secure-`)&&l!==!0)throw X(t,`is a __Secure- cookie, which needs secure: true`);if(d.startsWith(`__host-`)&&(l!==!0||a.startsWith(`.`)||(o??`/`)!==`/`))throw X(t,`is a __Host- cookie, which needs secure: true, a host-only domain and path "/"`);let f={name:r,value:i,domain:a};return o!==void 0&&(f.path=o),s!==void 0&&(f.expires=s),c!==void 0&&(f.httpOnly=c),l!==void 0&&(f.secure=l),u!==void 0&&(f.sameSite=u),f},Cr=(e,t)=>{if(!Z(e))throw X(t,`must be an object { origin, localStorage }`);let n=Object.keys(e).find(e=>e!==`origin`&&e!==`localStorage`);if(n!==void 0)throw X(`${t}.${n}`,`is not an origin field`);let{origin:r,localStorage:i}=e,a=(()=>{try{return typeof r==`string`?new URL(r):null}catch{return null}})();if(a===null||a.protocol!==`http:`&&a.protocol!==`https:`||a.origin!==r)throw X(`${t}.origin`,`must be an absolute http or https origin, not ${JSON.stringify(r)}`);if(!Array.isArray(i))throw X(`${t}.localStorage`,`must be an array`);return{origin:r,localStorage:i.map((e,n)=>{let{name:r,value:i}=Z(e)&&Object.keys(e).every(e=>e===`name`||e===`value`)?e:{};if(typeof r!=`string`||typeof i!=`string`)throw X(`${t}.localStorage[${n}]`,`must be { name, value } strings`);return{name:r,value:i}})}},wr=e=>{if(!Z(e))throw X(``,`must be an object { cookies?, origins? }`);let t=Object.keys(e).find(e=>e!==`cookies`&&e!==`origins`);if(t!==void 0)throw X(`.${t}`,`is not a storageState key; it takes cookies and origins`);let{cookies:n=[],origins:r=[]}=e;if(!Array.isArray(n))throw X(`.cookies`,`must be an array`);if(!Array.isArray(r))throw X(`.origins`,`must be an array`);let i=n.map((e,t)=>Sr(e,`.cookies[${t}]`)),a=r.map((e,t)=>Cr(e,`.origins[${t}]`));return i.forEach(({expires:e},t)=>{if(e!==void 0&&e>0&&e<vr)throw X(`.cookies[${t}].expires`,`is milliseconds since the epoch, and ${e} reads as a date before 1974; a Playwright storageState gives seconds, so multiply it by 1000`)}),{cookies:i,origins:a}},Tr=[`persistent`,`ephemeral`,`native`],Er=`attachFrame: syncCookies was replaced by cookies. true is cookies: 'persistent', or 'native' for the person's own browser cookies on the extension; false is cookies: 'ephemeral'`,Dr=e=>{if(`syncCookies`in e)throw TypeError(Er);let{cookies:t=`persistent`}=e;if(!Tr.includes(t))throw TypeError(`attachFrame: cookies must be 'persistent', 'ephemeral' or 'native', not ${JSON.stringify(t)}`);if(e.storageState!==void 0&&t!==`ephemeral`)throw TypeError(_r);let n=e.storageState===void 0?void 0:wr(e.storageState),r=mr(e);if(r===`iframe`&&e.lockdown&&t!==`native`)throw TypeError(`attachFrame: lockdown runs on the extension, which serves only cookies: 'native'`);return n===void 0?{kind:r,cookies:t}:{kind:r,cookies:t,storageState:n}},Or=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,kr=!1,Ar=()=>{kr||(kr=!0,console.warn(`[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this.`))},jr=`frame: this frame no longer holds the document the app attached it to`,Mr=`frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin`,Nr=()=>{let e=D();if(e.status===`ok`&&e.abi>=1)return;let t=e.status===`absent`?0:e.abi;throw new E(`lockdown`,t,`attachFrame: the installed FKN WebExtension (ABI ${t}) may predate lockdown, and one that does attaches the frame with its CSP removed rather than locked down. Updating the extension fixes this.`)},Q=e=>{try{return new URL(e,location.href).hostname}catch{return``}},$=()=>{let e=D();return e.status===`absent`?0:e.abi},Pr=`attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame`,Fr=`frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame`,Ir=`frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar`,Lr=({executeLocator:e,highlightLocator:n,ensureLocatorPermission:r,requestCategories:i,evaluateFrame:a,goto:o},{hosts:s,url:c,page:l,unreachable:u,documents:d,navigated:f})=>{let p=new Set(t.t(s,{ipv6:!0})),m=e=>p.has(t.t([Ye(e)],{ipv6:!0})[0]??``);return Vn({backend:`extension`,executor:{execute:e,highlight:n},gate:e=>r(e.parts,e.operation,e.args),requestPermissions:async e=>($n(`frame.requestPermissions`,e),await fn(),i(e)),evaluate:async(e,t)=>{if(!ve(D(),`evaluate`)){let e=D();throw new E(`evaluate`,e.status===`ok`?e.abi:0)}return a({source:e,arg:t}).catch(e=>{throw dr(e)})},addScriptTag:async()=>{throw new E(`addScriptTag`,$(),Fr)},clearCookies:async()=>{throw new E(`clearCookies`,$(),Ir)},postMessage:(e,t,n)=>{if(t===`*`)throw R(Mr,`postMessage`,`extension`);if(!m(t))throw z(jr,`postMessage`);let r=u();if(r)throw r;return l().postMessage(e,t,n),Promise.resolve()},listen:e=>{let t=t=>{t.source!==null&&t.source===l()&&!rr(t.data)&&m(t.origin)&&e({type:`message`,data:t.data,origin:t.origin,ports:t.ports})};window.addEventListener(`message`,t);let n=d(()=>e({type:`document`,origin:``}));return()=>{window.removeEventListener(`message`,t),n()}},goto:(e,{waitUntil:n,timeout:r,...i}={})=>{M(`frame.goto`,[Q(e),...i.domains??[]]);for(let n of t.t([Q(e)],{ipv6:!0}))p.add(n);return f?.(e),o({url:e,...i,...n===void 0?{}:{waitUntil:n===`commit`?`documentstart`:n},...r===void 0?{}:{timeoutMs:r}}).catch(e=>{throw pr(e)})},url:c})},Rr=async({iframe:e,domains:t=[],lockdown:n=!1,permissions:r,blank:i})=>{if(i!==void 0)throw new E(`blank`,$(),Pr);let a=crypto.randomUUID();if(q(e.src),Sn({src:e.src,domains:t,lockdown:n}),M(`attachFrame`,t),await O(),n&&Nr(),!e.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);e.dispatchEvent(new CustomEvent(Or,{detail:a}));let o=Lr(await k.attachFrame({marker:a,domains:t,syncCookies:!0,lockdown:n}),{hosts:[...t,Q(e.src)],url:()=>e.src,page:()=>e.contentWindow,unreachable:()=>e.contentWindow===null?z(`frame: navigate the frame before postMessage`,`postMessage`):void 0,documents:t=>(e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t))});return r?.length&&(dn()?await o.requestPermissions(r):Ar()),o},zr=`attachFrame: a window on cookies: 'native' needs the FKN WebExtension, which is not on this page`,Br=`frame.postMessage: this window's page no longer keeps a link to the app's page, so a message cannot reach it`,Vr=`extension.attachFrame: the attached window closed; attach a fresh window`,Hr=e=>`attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`,Ur=async e=>{let{domains:t=[],permissions:n}=e,{url:r,width:i,height:a}=gr(e.window);M(`attachFrame`,t);let o=D();if(!ve(o,`attachWindow`))throw o.status===`absent`?new E(`attachWindow`,0,zr):new E(`attachWindow`,o.abi);let s=window.open(r||`about:blank`,`_blank`,`popup,width=${i},height=${a}`);if(!s)throw new Dn;let c;try{c=await k.attachWindow({url:r,domains:t})}catch(e){try{s.close()}catch{}throw e}let l=new Promise(e=>window.addEventListener(`pagehide`,()=>e(),{once:!0})),u=!1,d=Promise.race([c.closed,l]).then(()=>{u=!0},()=>{u=!0}),f=r,p=Lr(c,{hosts:r?[...t,Q(r)]:t,url:()=>f,page:()=>s,unreachable:()=>u?R(Vr,`postMessage`,`extension`):s.closed?z(Br,`postMessage`):void 0,documents:e=>{let t=!0;return(async()=>{let n=await c.documentsAfter(-1);for(;t;){let r=await c.documentsAfter(n);for(;t&&n<r;n++)e()}})().catch(()=>{}),()=>{t=!1}},navigated:e=>{try{f=new URL(e,location.href).href}catch{}}}),m,h=()=>m??=c.close().then(()=>d,()=>{}).then(()=>{u=!0;try{s.close()}catch{}}),g=Object.assign(p,{close:h,closed:d});try{n?.length&&await g.requestPermissions(n)}catch(e){throw await h(),e}return g},Wr=(async e=>{let{kind:t,cookies:n}=Dr(e);if(n!==`native`)throw new E(`cookies`,$(),Hr(n));return t===`window`?Ur(e):Rr(e)}),Gr=`permissions.request: pass hosts, the sites the grant applies to`,Kr={request:async e=>{let n=e.map(e=>{let{category:n,key:r,scope:i,reason:a,hosts:o}=e;if(!(`hosts`in e)&&!(`category`in e))return{legacy:{key:r,scope:i??``,reason:a}};let s=t.t(o??[],{ipv6:!0});if(!s.length)throw TypeError(Gr);return Je(`permissions.request`,s),{ask:{category:n,key:r,reason:a,hosts:s}}}),r=n.flatMap(e=>`ask`in e?[e.ask]:[]);$n(`permissions.request`,r),r.length&&await fn();let{items:i,answer:a}=er(r),o=n.flatMap(e=>`legacy`in e?[e.legacy]:[]),s=[...i,...o],c=s.length?await k.requestPermissions(s):[],l=a(c.slice(0,i.length)),u=c.slice(i.length),d=0,f=0;return n.map(e=>`ask`in e?l[d++]:u[f++])}},qr=`PermissionDeniedError`,Jr=e=>e instanceof Error?e.name===qr:tr(e)&&e.name===`PermissionDeniedError`;Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return xn}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return kn}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Wr}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return wn}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return pr}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return $n}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Dn}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Yn}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Or}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Jr}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Kr}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return qr}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return ur}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return $e}});
@@ -1527,7 +1527,7 @@ var Et = class {
1527
1527
  if (r?.display === "none" || r?.visibility === "hidden") return !1;
1528
1528
  let i = n.getBoundingClientRect();
1529
1529
  return i.width > 0 && i.height > 0;
1530
- } }, dn = { resolve: (e, t = {}) => e.elements.length }, fn = { resolve: (e, t = {}) => e.elements.length > 0 }, q = (e, t) => e.elements.flatMap((e) => [...e.querySelectorAll(t)]), pn = (e) => e.replaceAll("\"", "\\\""), mn = {
1530
+ } }, dn = { resolve: (e, t = {}) => e.elements.length }, fn = { resolve: (e, t = {}) => e.elements.length > 0 }, q = (e, t) => (e.topLevel ? [e.document] : e.elements).flatMap((e) => [...e.querySelectorAll(t)]), pn = (e) => e.replaceAll("\"", "\\\""), mn = {
1531
1531
  to: "element",
1532
1532
  css: !0,
1533
1533
  resolve: (e, t) => q(e, t),
@@ -2258,15 +2258,9 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2258
2258
  cookies: t,
2259
2259
  storageState: n
2260
2260
  };
2261
- }, qr = (e) => {
2262
- try {
2263
- return new URL(e).hostname;
2264
- } catch {
2265
- return "";
2266
- }
2267
- }, Jr = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", Yr = !1, Xr = () => {
2268
- Yr || (Yr = !0, console.warn("[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this."));
2269
- }, Zr = "frame: this frame no longer holds the document the app attached it to", Qr = "frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin", $r = () => {
2261
+ }, qr = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", Jr = !1, Yr = () => {
2262
+ Jr || (Jr = !0, console.warn("[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this."));
2263
+ }, Xr = "frame: this frame no longer holds the document the app attached it to", Zr = "frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin", Qr = () => {
2270
2264
  let e = E();
2271
2265
  if (e.status === "ok" && e.abi >= 1) return;
2272
2266
  let t = e.status === "absent" ? 0 : e.abi;
@@ -2280,8 +2274,8 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2280
2274
  }, $ = () => {
2281
2275
  let e = E();
2282
2276
  return e.status === "absent" ? 0 : e.abi;
2283
- }, ei = "attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame", ti = "frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame", ni = "frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar", ri = ({ executeLocator: e, highlightLocator: t, ensureLocatorPermission: n, requestCategories: r, evaluateFrame: i, goto: a }, { hosts: o, url: s, page: c, unreachable: l, documents: u, navigated: d }) => {
2284
- let f = new Set(p(o, { ipv6: !0 })), m = (e) => f.has(p([qr(e)], { ipv6: !0 })[0] ?? "");
2277
+ }, $r = "attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame", ei = "frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame", ti = "frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar", ni = ({ executeLocator: e, highlightLocator: t, ensureLocatorPermission: n, requestCategories: r, evaluateFrame: i, goto: a }, { hosts: o, url: s, page: c, unreachable: l, documents: u, navigated: d }) => {
2278
+ let f = new Set(p(o, { ipv6: !0 })), m = (e) => f.has(p([ht(e)], { ipv6: !0 })[0] ?? "");
2285
2279
  return ar({
2286
2280
  backend: "extension",
2287
2281
  executor: {
@@ -2303,14 +2297,14 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2303
2297
  });
2304
2298
  },
2305
2299
  addScriptTag: async () => {
2306
- throw new T("addScriptTag", $(), ti);
2300
+ throw new T("addScriptTag", $(), ei);
2307
2301
  },
2308
2302
  clearCookies: async () => {
2309
- throw new T("clearCookies", $(), ni);
2303
+ throw new T("clearCookies", $(), ti);
2310
2304
  },
2311
2305
  postMessage: (e, t, n) => {
2312
- if (t === "*") throw I(Qr, "postMessage", "extension");
2313
- if (!m(t)) throw L(Zr, "postMessage");
2306
+ if (t === "*") throw I(Zr, "postMessage", "extension");
2307
+ if (!m(t)) throw L(Xr, "postMessage");
2314
2308
  let r = l();
2315
2309
  if (r) throw r;
2316
2310
  return c().postMessage(e, t, n), Promise.resolve();
@@ -2347,16 +2341,16 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2347
2341
  },
2348
2342
  url: s
2349
2343
  });
2350
- }, ii = async ({ iframe: e, domains: t = [], lockdown: n = !1, permissions: r, blank: i }) => {
2351
- if (i !== void 0) throw new T("blank", $(), ei);
2344
+ }, ri = async ({ iframe: e, domains: t = [], lockdown: n = !1, permissions: r, blank: i }) => {
2345
+ if (i !== void 0) throw new T("blank", $(), $r);
2352
2346
  let a = crypto.randomUUID();
2353
2347
  if (J(e.src), Bn({
2354
2348
  src: e.src,
2355
2349
  domains: t,
2356
2350
  lockdown: n
2357
- }), j("attachFrame", t), await D(), n && $r(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
2358
- e.dispatchEvent(new CustomEvent(Jr, { detail: a }));
2359
- let o = ri(await O.attachFrame({
2351
+ }), j("attachFrame", t), await D(), n && Qr(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
2352
+ e.dispatchEvent(new CustomEvent(qr, { detail: a }));
2353
+ let o = ni(await O.attachFrame({
2360
2354
  marker: a,
2361
2355
  domains: t,
2362
2356
  syncCookies: !0,
@@ -2368,12 +2362,12 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2368
2362
  unreachable: () => e.contentWindow === null ? L("frame: navigate the frame before postMessage", "postMessage") : void 0,
2369
2363
  documents: (t) => (e.addEventListener("load", t), () => e.removeEventListener("load", t))
2370
2364
  });
2371
- return r?.length && (kn() ? await o.requestPermissions(r) : Xr()), o;
2372
- }, ai = "attachFrame: a window on cookies: 'native' needs the FKN WebExtension, which is not on this page", oi = "frame.postMessage: this window's page no longer keeps a link to the app's page, so a message cannot reach it", si = "extension.attachFrame: the attached window closed; attach a fresh window", ci = (e) => `attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`, li = async (e) => {
2365
+ return r?.length && (kn() ? await o.requestPermissions(r) : Yr()), o;
2366
+ }, ii = "attachFrame: a window on cookies: 'native' needs the FKN WebExtension, which is not on this page", ai = "frame.postMessage: this window's page no longer keeps a link to the app's page, so a message cannot reach it", oi = "extension.attachFrame: the attached window closed; attach a fresh window", si = (e) => `attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`, ci = async (e) => {
2373
2367
  let { domains: t = [], permissions: n } = e, { url: r, width: i, height: a } = Pr(e.window);
2374
2368
  j("attachFrame", t);
2375
2369
  let o = E();
2376
- if (!Re(o, "attachWindow")) throw o.status === "absent" ? new T("attachWindow", 0, ai) : new T("attachWindow", o.abi);
2370
+ if (!Re(o, "attachWindow")) throw o.status === "absent" ? new T("attachWindow", 0, ii) : new T("attachWindow", o.abi);
2377
2371
  let s = window.open(r || "about:blank", "_blank", `popup,width=${i},height=${a}`);
2378
2372
  if (!s) throw new Gn();
2379
2373
  let c;
@@ -2392,11 +2386,11 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2392
2386
  u = !0;
2393
2387
  }, () => {
2394
2388
  u = !0;
2395
- }), f = r, p = ri(c, {
2389
+ }), f = r, p = ni(c, {
2396
2390
  hosts: r ? [...t, Q(r)] : t,
2397
2391
  url: () => f,
2398
2392
  page: () => s,
2399
- unreachable: () => u ? I(si, "postMessage", "extension") : s.closed ? L(oi, "postMessage") : void 0,
2393
+ unreachable: () => u ? I(oi, "postMessage", "extension") : s.closed ? L(ai, "postMessage") : void 0,
2400
2394
  documents: (e) => {
2401
2395
  let t = !0;
2402
2396
  return (async () => {
@@ -2429,11 +2423,11 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2429
2423
  throw await h(), e;
2430
2424
  }
2431
2425
  return g;
2432
- }, ui = (async (e) => {
2426
+ }, li = (async (e) => {
2433
2427
  let { kind: t, cookies: n } = Kr(e);
2434
- if (n !== "native") throw new T("cookies", $(), ci(n));
2435
- return t === "window" ? li(e) : ii(e);
2436
- }), di = "permissions.request: pass hosts, the sites the grant applies to", fi = { request: async (e) => {
2428
+ if (n !== "native") throw new T("cookies", $(), si(n));
2429
+ return t === "window" ? ci(e) : ri(e);
2430
+ }), ui = "permissions.request: pass hosts, the sites the grant applies to", di = { request: async (e) => {
2437
2431
  let t = e.map((e) => {
2438
2432
  let { category: t, key: n, scope: r, reason: i, hosts: a } = e;
2439
2433
  if (!("hosts" in e) && !("category" in e)) return { legacy: {
@@ -2442,7 +2436,7 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2442
2436
  reason: i
2443
2437
  } };
2444
2438
  let o = p(a ?? [], { ipv6: !0 });
2445
- if (!o.length) throw TypeError(di);
2439
+ if (!o.length) throw TypeError(ui);
2446
2440
  return mt("permissions.request", o), { ask: {
2447
2441
  category: t,
2448
2442
  key: n,
@@ -2453,6 +2447,6 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2453
2447
  _r("permissions.request", n), n.length && await An();
2454
2448
  let { items: r, answer: i } = vr(n), a = t.flatMap((e) => "legacy" in e ? [e.legacy] : []), o = [...r, ...a], s = o.length ? await O.requestPermissions(o) : [], c = i(s.slice(0, r.length)), l = s.slice(r.length), u = 0, d = 0;
2455
2449
  return t.map((e) => "ask" in e ? c[u++] : l[d++]);
2456
- } }, pi = "PermissionDeniedError", mi = (e) => e instanceof Error ? e.name === pi : yr(e) && e.name === "PermissionDeniedError";
2450
+ } }, fi = "PermissionDeniedError", pi = (e) => e instanceof Error ? e.name === fi : yr(e) && e.name === "PermissionDeniedError";
2457
2451
  //#endregion
2458
- export { Be as $, It as A, _t as B, zn as C, Rt as D, Mt as E, zt as F, rt as G, st as H, Pt as I, at as J, tt as K, vt as L, I as M, B as N, L as O, jt as P, qe as Q, bt as R, Bn as S, R as T, lt as U, gt as V, nt as W, Xe as X, k as Y, Je as Z, qn as _, ui as a, T as at, Hn as b, jr as c, Le as ct, yr as d, _e as dt, Ve as et, _r as f, ve as ft, Gn as g, pr as h, Jr as i, Oe as it, z as j, Nt as k, Er as l, De as lt, mr as m, S as mt, mi as n, Ue as nt, Kr as o, w as ot, fr as p, be as pt, ot as q, fi as r, D as rt, Pr as s, ke as st, pi as t, E as tt, Or as u, ye as ut, Vn as v, Nn as w, J as x, ar as y, yt as z };
2452
+ export { Be as $, It as A, _t as B, zn as C, Rt as D, Mt as E, zt as F, rt as G, st as H, Pt as I, at as J, tt as K, vt as L, I as M, B as N, L as O, jt as P, qe as Q, bt as R, Bn as S, R as T, lt as U, gt as V, nt as W, Xe as X, k as Y, Je as Z, qn as _, li as a, T as at, Hn as b, jr as c, Le as ct, yr as d, _e as dt, Ve as et, _r as f, ve as ft, Gn as g, pr as h, qr as i, Oe as it, z as j, Nt as k, Er as l, De as lt, mr as m, S as mt, pi as n, Ue as nt, Kr as o, w as ot, fr as p, be as pt, ot as q, di as r, D as rt, Pr as s, ke as st, fi as t, E as tt, Or as u, ye as ut, Vn as v, Nn as w, J as x, ar as y, yt as z };
@@ -6,7 +6,7 @@ declare const E2E_INTEGRITY_MESSAGE = "fkn:e2e-integrity: stored data failed its
6
6
  declare const E2E_RETIRED_FORMAT_MESSAGE = "fkn:e2e-retired-format: stored data is in a format this version no longer opens";
7
7
  /**
8
8
  * The error code for "there is no object at this path", so a caller tests absence instead of parsing
9
- * a message. osra drops custom codes at the SharedWorker boundary, so storage.ts's rethrow re-mints
9
+ * a message. osra drops custom codes at the SharedWorker boundary, so account-storage.ts's rethrow re-mints
10
10
  * it from the message on the app side.
11
11
  */
12
12
  declare const STORAGE_NOT_FOUND = "FKN_STORAGE_NOT_FOUND";
package/messages.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as E2E_LOCKED_MESSAGE, c as STORAGE_ACCOUNT_CHANGED, d as STORAGE_UNREACHABLE, i as E2E_INTEGRITY_MESSAGE, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, n as ACCOUNT_PIN_INVALID_MESSAGE, o as E2E_RETIRED_FORMAT_MESSAGE, r as ACCOUNT_PIN_UNSUPPORTED_MESSAGE, s as E2E_STALE_EPOCH_MESSAGE, t as ACCOUNT_CHANGED_MESSAGE, u as STORAGE_NOT_FOUND } from "./messages-d7pvCXPn.js";
1
+ import { a as E2E_LOCKED_MESSAGE, c as STORAGE_ACCOUNT_CHANGED, d as STORAGE_UNREACHABLE, i as E2E_INTEGRITY_MESSAGE, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, n as ACCOUNT_PIN_INVALID_MESSAGE, o as E2E_RETIRED_FORMAT_MESSAGE, r as ACCOUNT_PIN_UNSUPPORTED_MESSAGE, s as E2E_STALE_EPOCH_MESSAGE, t as ACCOUNT_CHANGED_MESSAGE, u as STORAGE_NOT_FOUND } from "./messages-AdPfdoLV.js";
2
2
  export { ACCOUNT_CHANGED_MESSAGE, ACCOUNT_PIN_INVALID_MESSAGE, ACCOUNT_PIN_UNSUPPORTED_MESSAGE, E2E_INTEGRITY_MESSAGE, E2E_LOCKED_MESSAGE, E2E_RETIRED_FORMAT_MESSAGE, E2E_STALE_EPOCH_MESSAGE, STORAGE_ACCOUNT_CHANGED, STORAGE_ACCOUNT_PIN_UNSUPPORTED, STORAGE_NOT_FOUND, STORAGE_UNREACHABLE };
@@ -1,6 +1,6 @@
1
- import { Ct as TcpSocketListenerResult, K as Resolvers, Tt as TcpSocketResult } from "./contract-LOcbTDjP.js";
1
+ import { K as Resolvers, Mt as TcpSocketListenerResult, Pt as TcpSocketResult } from "./contract-DGuGXxKd.js";
2
2
  import { o as TcpSocketOption } from "./wire-Fk5pJaoy.js";
3
- import "./api-DIBhBtcU.js";
3
+ import "./api-wnOQJEK6.js";
4
4
  import { AddressInfo, ListenOptions, Server, ServerOpts, Socket, SocketConnectOpts, SocketConstructorOpts } from "net";
5
5
  import { DuplexOptions, Stream } from "stream";
6
6
  import { EventEmitter } from "events";
package/net.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-taIhsmvu.js";
1
+ import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-C2sulnNU.js";
2
2
  export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fkn/lib",
3
- "version": "0.9.47",
3
+ "version": "0.9.49",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
@@ -115,6 +115,11 @@
115
115
  "import": "./rooms.js",
116
116
  "require": "./rooms.cjs"
117
117
  },
118
+ "./storage": {
119
+ "types": "./storage.d.ts",
120
+ "import": "./storage.js",
121
+ "require": "./storage.cjs"
122
+ },
118
123
  "./react": {
119
124
  "types": "./react.d.ts",
120
125
  "import": "./react.js",
package/packages.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as InstalledPackage, F as PackageResult, G as Radii, I as PackagesErrorCode, P as PackageQuery, R as PickOptions, T as InstallOptions, m as ConnectOptions, xt as SurfaceRect, z as Placement } from "./contract-LOcbTDjP.js";
1
+ import { At as SurfaceRect, E as InstalledPackage, F as PackageResult, G as Radii, I as PackagesErrorCode, P as PackageQuery, R as PickOptions, T as InstallOptions, m as ConnectOptions, z as Placement } from "./contract-DGuGXxKd.js";
2
2
  import { Remote } from "osra";
3
3
  declare namespace packages_d_exports {
4
4
  export { AppConnectOptions, Connect, ConnectOptions, ConnectPayload, IncomingConnection, IncomingConnectionInfo, InstallOptions, InstalledPackage, MountOptions, MountedPackage, PackageConnection, PackageQuery, PackageResult, PackageView, PackagesError, PackagesErrorCode, PickOptions, Placement, Radii, RawPackageConnection, ShowOptions, SurfaceRect, attach, connect, hide, install, isVisible, list, mount, onConnect, onVisibilityChange, pick, search, show, uninstall };
@@ -1,5 +1,5 @@
1
- import { K as Resolvers } from "./contract-LOcbTDjP.js";
2
- import "./api-DIBhBtcU.js";
1
+ import { K as Resolvers } from "./contract-DGuGXxKd.js";
2
+ import "./api-wnOQJEK6.js";
3
3
  //#region src/proxy.d.ts
4
4
  type ProxyFetch = Resolvers['cloud']['fetch'];
5
5
  type FetchParameters = Parameters<ProxyFetch>;
package/rooms.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { J as RoomClaimOptions, Q as RoomEvent, X as RoomDefaults, Y as RoomCreateOptions, Z as RoomEnd, at as RoomPermission, et as RoomJoinOptions, it as RoomOpenOptions, nt as RoomMember, ot as RoomPermissions, q as RoomBacklog, rt as RoomMessage, st as RoomsErrorCode, tt as RoomMailbox } from "./contract-LOcbTDjP.js";
1
+ import { J as RoomClaimOptions, Q as RoomEvent, X as RoomDefaults, Y as RoomCreateOptions, Z as RoomEnd, at as RoomPermission, et as RoomJoinOptions, it as RoomOpenOptions, nt as RoomMember, ot as RoomPermissions, q as RoomBacklog, rt as RoomMessage, st as RoomsErrorCode, tt as RoomMailbox } from "./contract-DGuGXxKd.js";
2
2
  declare namespace rooms_d_exports {
3
3
  export { RoomClaimOptions as ClaimOptions, RoomCreateOptions as CreateOptions, RoomJoinOptions as JoinOptions, RoomOpenOptions as OpenOptions, Room, RoomBacklog, RoomDefaults, RoomEnd, RoomEvent, RoomMailbox, RoomMember, RoomMessage, RoomPermission, RoomPermissions, RoomsError, RoomsErrorCode, available, create, join, open };
4
4
  }
package/storage.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-DMnVye0K.cjs"),n=require("./contract.cjs"),r=require("./account-generation-9VhfEDoW.cjs"),i=require("./account-storage-C6hcXjG0.cjs");var a=e.t({available:()=>v,delete:()=>C,get:()=>x,list:()=>S,put:()=>y}),o=new Map(Object.values(n.STORAGE_REFUSALS).map(({code:e,message:t})=>[t,e])),s=new Set(o.values()),c=(e,t)=>Object.assign(Error(t),{code:e}),l=e=>c(n.STORAGE_REFUSALS[e].code,n.STORAGE_REFUSALS[e].message),u=e=>e instanceof Error&&s.has(e.code),d=e=>{if(u(e))return e;let t=e instanceof Error?e.message:``,n=o.get(t);return n?c(n,t):l(`unavailable`)},f=async()=>{if(!t.l)return;let e=(await t.s(`storage`).catch(()=>void 0))?.storage;return typeof e?.put==`function`?e:void 0},p=()=>{throw l(`unavailable`)},m=e=>typeof e==`object`&&!!e&&typeof e.error==`string`&&typeof e.message==`string`,h=(e,t,n)=>{throw e.error===`aborted`?t?.reason??new DOMException(`The operation was aborted.`,`AbortError`):(e.error===`account-changed`&&n&&r.r(n.generation),s.has(e.error)?c(e.error,e.message):l(`unavailable`))},g=async e=>{try{return await i.m(e)}catch(e){throw i.l(e)?l(`accountChanged`):e instanceof Error&&/not connected|not signed in/i.test(e.message)?l(`needsAccount`):l(`unavailable`)}},_=(e,t)=>(e.catch(()=>{}),t?Promise.race([e,new Promise((e,n)=>t.addEventListener(`abort`,()=>n(t.reason),{once:!0}))]):e),v=async()=>{let e=await f();return e?Promise.resolve(e.available()).catch(()=>!1):!1},y=async(e,t={})=>{let n=i.s(),{signal:r,onProgress:a,key:o}=t;r?.throwIfAborted();let s=typeof Blob<`u`&&e instanceof Blob,c=typeof ReadableStream<`u`&&e instanceof ReadableStream;if(!s&&!c)throw l(`notAFile`);let u=s?e.size:t.size;if(typeof u!=`number`||!Number.isSafeInteger(u)||u<0||s&&t.size!==void 0&&t.size!==u)throw l(`badSize`);let d=await f();if(!d)throw l(`unavailable`);let v=await g(n);r?.throwIfAborted();let y=await _(Promise.resolve(d.put(e,{size:u,...o===void 0?{}:{key:o},accountPin:v,...r?{signal:r}:{},...typeof a==`function`?{onProgress:e=>{try{a(e)}catch{}}}:{}})).catch(p),r);return m(y)?h(y,r,n):y},b=(e,t,n)=>{let r=(t,n)=>{if(t===void 0)return n;let r=Math.trunc(Number.isFinite(t)?t:t>0?e:-e);return r<0?Math.max(e+r,0):Math.min(r,e)},i=r(t,0);return{from:i,to:Math.max(i,r(n,e))}},x=async(e,n,r={})=>{if(typeof e!=`string`)throw l(`badUrl`);if(typeof n!=`string`)throw l(`badKey`);let{signal:i}=r;i?.throwIfAborted();let a=async()=>{let r=await f();if(!r)throw l(`unavailable`);let a=t.c()?.epoch,o=await _(Promise.resolve(r.get(e,n,i?{signal:i}:void 0)).catch(p),i);return m(o)?h(o,i):{handle:o,epoch:a}},o=await a(),s=async()=>{let e=t.c()?.epoch;return o.epoch!==void 0&&e!==void 0&&e!==o.epoch&&(o=await a()),o.handle},c=(e,t)=>{let n;return new ReadableStream({pull:async r=>{try{if(!n){let r=await s(),i=await Promise.resolve(r.read(e,t)).catch(p);if(m(i))return h(i);n=i.getReader()}let{value:i,done:a}=await n.read();a?r.close():r.enqueue(i)}catch(e){throw d(e)}},cancel:e=>n?.cancel(e)},{highWaterMark:0})},u=(e,t)=>({size:t-e,stream:()=>c(e,t),arrayBuffer:async()=>{let n=new Uint8Array(t-e),r=c(e,t).getReader(),i=0;for(;;){let{value:e,done:t}=await r.read();if(t)break;n.set(e,i),i+=e.length}return n.buffer},slice:(n,r)=>{let i=b(t-e,n,r);return u(e+i.from,e+i.to)}});return u(0,o.handle.size)},S=async(e={})=>{let t=i.s(),n=await f();if(!n)throw l(`unavailable`);let r=await g(t),{limit:a,cursor:o}=e,s=await Promise.resolve(n.list({accountPin:r,...a===void 0?{}:{limit:a},...o===void 0?{}:{cursor:o}})).catch(p);return m(s)?h(s,void 0,t):s},C=async e=>{let t=i.s();if(typeof e!=`string`)throw l(`badUrl`);let n=await f();if(!n)throw l(`unavailable`);let r=await g(t),a=await Promise.resolve(n.delete(e,{accountPin:r})).catch(p);m(a)&&h(a,void 0,t)};exports.available=v,exports.delete=C,exports.get=x,exports.list=S,exports.put=y,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
package/storage.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ import { Ct as StorageProgress, Ot as StoredObject, kt as StoredPage, wt as StoragePutOptions, xt as StorageErrorCode } from "./contract-DGuGXxKd.js";
2
+ declare namespace storage_d_exports {
3
+ export { StorageError, StorageErrorCode, StorageProgress, StoragePutOptions, StoredBlob, StoredObject, StoredPage, available, remove as delete, get, list, put };
4
+ }
5
+ /** Thrown by every member of this namespace except on an aborted signal. Match on `code`, never on the message. */
6
+ export type StorageError = Error & {
7
+ code: StorageErrorCode;
8
+ };
9
+ /**
10
+ * The bytes `get` opened, shaped like a `Blob`: `size`, `stream`, `arrayBuffer` and `slice`. Every read
11
+ * is by range and each 1 MiB record is checked before it is handed over, so a `slice` near the end of
12
+ * a large object fetches only that end.
13
+ */
14
+ export type StoredBlob = {
15
+ /** the plaintext bytes of this blob, a slice's own length */
16
+ size: number;
17
+ /** errors with `integrity` on the first record that does not open under the key */
18
+ stream: () => ReadableStream<Uint8Array>;
19
+ arrayBuffer: () => Promise<ArrayBuffer>;
20
+ /** `Blob.slice`'s arguments, negative ones counted from the end, and the same shape back */
21
+ slice: (start?: number, end?: number) => StoredBlob;
22
+ };
23
+ /** Whether put, list and delete can run here now. `get` needs no account and does not depend on this. Answers rather than rejecting. */
24
+ export declare const available: () => Promise<boolean>;
25
+ /**
26
+ * Seals the data in the broker and uploads it, then answers its url and the key that opens it: the
27
+ * app's own `key` unchanged, or the one the broker minted. Resolves once the object is `ready`. Needs
28
+ * a signed-in account, and counts the sealed size (28 bytes more per 1 MiB) against the account's
29
+ * storage from the moment it starts until the object is deleted or the upload is aborted. The account
30
+ * the call belongs to is the one this page is on when it is made, as for every storage call.
31
+ *
32
+ * `data` is a `Blob` (a `File` included) or a `ReadableStream<Uint8Array>` with its `size`. An upload
33
+ * survives the network dropping a part, not a reload: a reload starts the file again, and the upload
34
+ * left behind stops counting within the hour.
35
+ *
36
+ * Refused `invalid` for a stream without its size or one that delivers another, a file past the
37
+ * service's part ceiling, or a `key` that is not 32 bytes base64url; `denied` with no account; `quota`;
38
+ * `too-many` past the account's stored objects or this hour's uploads; `account-changed`.
39
+ */
40
+ export declare const put: (data: Blob | ReadableStream<Uint8Array>, options?: StoragePutOptions) => Promise<StoredObject & {
41
+ key: string;
42
+ }>;
43
+ /**
44
+ * Opens an object any app stored, with no account: the broker reads its size from the first ranged
45
+ * answer and fetches the sealed bytes by range. Refused `invalid` for a url that names no stored object
46
+ * or a key that is not 32 bytes base64url, `not-found` for an object that was never made, was deleted
47
+ * or is still uploading (one answer for all of them). A wrong key shows on the first read, as
48
+ * `integrity`. A broker replaced while the object is held is asked to open it again on the next read.
49
+ */
50
+ export declare const get: (url: string, key: string, options?: {
51
+ signal?: AbortSignal;
52
+ }) => Promise<StoredBlob>;
53
+ /**
54
+ * This app's objects, newest first, uploads in progress included: no key, which the service never
55
+ * holds. `limit` is 1 to 1,000 (1,000 by default), and `cursor` is the one a previous page answered;
56
+ * `invalid` otherwise.
57
+ */
58
+ export declare const list: (options?: {
59
+ limit?: number;
60
+ cursor?: string;
61
+ }) => Promise<StoredPage>;
62
+ /**
63
+ * Deletes an object by its url: every later `get` of it answers `not-found`, and an upload in progress
64
+ * is aborted and stops counting. Only the app that stored it (the same app once it is verified)
65
+ * deletes it, `denied` otherwise. An object already gone resolves.
66
+ */
67
+ declare const remove: (url: string) => Promise<void>;
68
+ //#endregion
69
+ export { type StorageErrorCode, type StorageProgress, type StoragePutOptions, type StoredObject, type StoredPage, remove as delete, storage_d_exports as t };