palbase 0.72.0 → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai-sdk/index.js +2 -2
  3. package/dist/backend/engine.js +2 -2
  4. package/dist/backend/env.js +1 -1
  5. package/dist/backend/index.js +11 -11
  6. package/dist/backend/stack.js +1 -1
  7. package/dist/backend/test.js +2 -2
  8. package/dist/chunks/{JXIKBG4D.js → 25HECIZY.js} +1 -1
  9. package/dist/chunks/{S3N7N6UD.js → 3DUDNEMM.js} +2 -2
  10. package/dist/chunks/4XSSQAES.js +95 -0
  11. package/dist/chunks/{DE7BWXBF.js → 5OOA4R4H.js} +1 -1
  12. package/dist/chunks/{OY2MT7N5.js → 757A6AR6.js} +2 -2
  13. package/dist/chunks/76W5ZO2L.js +2 -0
  14. package/dist/chunks/{O6JNTYC5.js → CY6KUFZW.js} +2 -2
  15. package/dist/chunks/DIQMCEMJ.js +19 -0
  16. package/dist/chunks/{JMNQRIEG.js → EKOEK6LR.js} +2 -2
  17. package/dist/chunks/{Y7ZJ3M5F.js → IICQMY2Z.js} +2 -2
  18. package/dist/chunks/{QROXSSPQ.js → J7Z2PYL4.js} +1 -1
  19. package/dist/chunks/{WWXBXZUO.js → J7ZNBBRN.js} +1 -1
  20. package/dist/chunks/{MVVULWTH.js → JG4V6LNY.js} +2 -2
  21. package/dist/chunks/{I4SH2RTD.js → LCDNCPQW.js} +1 -1
  22. package/dist/chunks/{7TZJLWWX.js → MVKZWEHL.js} +2 -2
  23. package/dist/chunks/{E2MNCFOU.js → P36C47FS.js} +1 -1
  24. package/dist/chunks/{F4LE2YZX.js → P4NZ4NZD.js} +2 -2
  25. package/dist/chunks/{QDPRR5PE.js → PAQCJT7M.js} +2 -2
  26. package/dist/chunks/{LDFOUUBT.js → PEQZDT6P.js} +2 -2
  27. package/dist/chunks/SMECWMF7.js +2 -0
  28. package/dist/chunks/SRN7N2WX.js +13 -0
  29. package/dist/chunks/UFP6GLLW.js +23 -0
  30. package/dist/chunks/{D5I74USX.js → VEL7X2G3.js} +2 -2
  31. package/dist/chunks/{3MF6NROQ.js → YMIK6HLK.js} +2 -2
  32. package/dist/cli.js +259 -259
  33. package/dist/cloud/index.js +2 -2
  34. package/dist/refuse/ai-sdk.js +1 -1
  35. package/dist/refuse/ai.js +1 -1
  36. package/dist/refuse/backend.js +1 -1
  37. package/dist/refuse/cloud.js +1 -1
  38. package/dist/refuse/server.js +1 -1
  39. package/dist/server/index.js +2 -2
  40. package/dist/server/testing.js +2 -2
  41. package/dist/web/index.js +2 -2
  42. package/dist/web/message.js +2 -2
  43. package/dist/web/palbe.js +2 -2
  44. package/dist/web/payments-ui.js +2 -2
  45. package/dist/web/paywall.js +2 -2
  46. package/dist/web/push-sw.js +1 -1
  47. package/dist/web/ssr.js +2 -2
  48. package/dist/web/vite.js +2 -2
  49. package/package.json +2 -2
  50. package/types/backend/src/index.d.ts +1 -1
  51. package/types/backend/src/services.d.ts +31 -0
  52. package/types/cloud/src/generated/project.d.ts +2 -1
  53. package/types/internal/src/modules/analytics.d.ts +58 -4
  54. package/types/internal/src/modules/campaigns.d.ts +616 -0
  55. package/types/internal/src/modules/events.d.ts +4 -3
  56. package/types/internal/src/modules/index.d.ts +1 -0
  57. package/types/internal/src/modules/journeys.d.ts +145 -0
  58. package/types/internal/src/modules/notify.d.ts +7 -6
  59. package/types/server/src/campaigns.d.ts +31 -0
  60. package/types/server/src/index.d.ts +1 -0
  61. package/types/server/src/server.d.ts +4 -0
  62. package/types/web/src/campaigns.d.ts +59 -0
  63. package/types/web/src/client.d.ts +3 -0
  64. package/types/web/src/inapp.d.ts +4 -0
  65. package/types/web/src/index.d.ts +1 -0
  66. package/types/web/src/screen/render.d.ts +6 -1
  67. package/types/web/src/screen/resolve.d.ts +10 -0
  68. package/dist/chunks/CYS75YV4.js +0 -2
  69. package/dist/chunks/JP55FW66.js +0 -13
  70. package/dist/chunks/MB6ITBD2.js +0 -95
  71. package/dist/chunks/UXU6RXU3.js +0 -23
  72. package/dist/chunks/XUYC354U.js +0 -2
  73. package/dist/chunks/ZHSM4NCV.js +0 -13
@@ -0,0 +1,95 @@
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ var Rt=d=>[...new Uint8Array(d)].map(t=>t.toString(16).padStart(2,"0")).join(""),_t=d=>`pw-font-${d}`;function ne(d){return(typeof d=="string"?/^asset:([0-9a-f-]{36})$/.exec(d):null)?.[1]}async function an(d,t={}){let l={},a=t.fetch??((c,p)=>globalThis.fetch(c,p));return await Promise.all(d.map(async c=>{try{if(!/^https:\/\//.test(c.url))return;let p=await a(c.url,{signal:t.signal,credentials:"omit"});if(!p.ok)return;let g=await p.arrayBuffer();if(g.byteLength!==c.bytes&&c.bytes>0||Rt(await globalThis.crypto.subtle.digest("SHA-256",g))!==c.sha256.toLowerCase())return;let b=At(c.kind,new Uint8Array(g));if(b===void 0)return;let y=await Et(c,g,b,t);y&&(l[c.id]=y)}catch{}})),l}var C=(d,t,l=0)=>d.length>=l+t.length&&t.every((a,c)=>d[l+c]===a),W=d=>[...d].map(t=>t.charCodeAt(0));function At(d,t){switch(d){case"image":return C(t,[137,80,78,71,13,10,26,10])?"image/png":C(t,[255,216,255])?"image/jpeg":C(t,W("RIFF"))&&C(t,W("WEBP"),8)?"image/webp":void 0;case"video":return C(t,W("ftyp"),4)?C(t,W("qt "),8)?"video/quicktime":"video/mp4":C(t,[26,69,223,163])?"video/webm":void 0;case"font":return C(t,W("wOF2"))?"font/woff2":C(t,W("wOFF"))?"font/woff":C(t,W("OTTO"))?"font/otf":C(t,[0,1,0,0])||C(t,W("true"))?"font/ttf":void 0;case"html":return C(t,[80,75,3,4])||C(t,[80,75,5,6])?"application/zip":void 0;default:return}}async function Et(d,t,l,a){switch(d.kind){case"image":case"video":return{kind:d.kind,url:URL.createObjectURL(new Blob([t],{type:l}))};case"font":{let c=_t(d.id),p=globalThis.FontFace,g=a.fonts??globalThis.document?.fonts;if(!p||!g)return;let h=new p(c,t,{display:"block"});return await h.load(),g.add(h),{kind:"font",url:"",family:c}}case"html":{let c=await Lt(new Uint8Array(t)),p=Ot(c);return p===void 0?void 0:{kind:"html",url:"",html:p}}}}async function Lt(d){let t=new DataView(d.buffer,d.byteOffset,d.byteLength),l=-1;for(let h=d.length-22;h>=Math.max(0,d.length-22-65535);h--)if(t.getUint32(h,!0)===101010256){l=h;break}if(l<0)throw new Error("not a zip");let a=t.getUint16(l+10,!0),c=t.getUint32(l+16,!0),p=new Map,g=0;for(let h=0;h<a;h++){if(t.getUint32(c,!0)!==33639248)throw new Error("a broken zip");let b=t.getUint16(c+10,!0),y=t.getUint32(c+20,!0),m=t.getUint32(c+24,!0),v=t.getUint16(c+28,!0),A=t.getUint16(c+30,!0),P=t.getUint16(c+32,!0),R=t.getUint32(c+42,!0),x=new TextDecoder().decode(d.subarray(c+46,c+46+v));if(c+=46+v+A+P,x.endsWith("/"))continue;if(x.startsWith("/")||x.split("/").includes(".."))throw new Error("a path leaving the zip");if(g+=m,p.size>=200||g>20971520)throw new Error("a zip too large");let T=R+30+t.getUint16(R+26,!0)+t.getUint16(R+28,!0),O=d.subarray(T,T+y);if(b===0)p.set(x,O);else if(b===8)p.set(x,await Pt(O));else throw new Error("a zip entry compressed another way")}return p}async function Pt(d){let t=new Response(new Uint8Array(d)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Tt={html:"text/html",css:"text/css",js:"text/javascript",mjs:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",woff2:"font/woff2",woff:"font/woff",ttf:"font/ttf",otf:"font/otf"};function qe(d,t){let l=Tt[d.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",a="";for(let c=0;c<t.length;c+=32768)a+=String.fromCharCode(...t.subarray(c,c+32768));return`data:${l};base64,${btoa(a)}`}var $t="default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:";function Ot(d){let t=d.get("index.html");if(!t)return;let l=new TextDecoder().decode(t),a=y=>new TextDecoder().decode(d.get(y)),c=y=>{let m=y.replace(/^\.\//,"").split(/[?#]/)[0];return d.has(m)?m:void 0},p=y=>y.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(m,v,A)=>{let P=c(A);return P?`url("${qe(P,d.get(P))}")`:m}),g=globalThis.DOMParser;if(!g)return;let h=new g().parseFromString(l,"text/html");for(let y of[...h.querySelectorAll('link[rel~="stylesheet"][href]')]){let m=c(y.getAttribute("href")),v=h.createElement("style");v.textContent=m?p(a(m)):"",y.replaceWith(v)}for(let y of[...h.querySelectorAll("style")])y.textContent=p(y.textContent??"");for(let y of[...h.querySelectorAll("[src], [href], [poster]")])for(let m of["src","href","poster"]){let v=y.getAttribute(m);if(v===null)continue;let A=c(v);A?y.setAttribute(m,qe(A,d.get(A))):/^(https?:)?\/\//i.test(v)&&y.removeAttribute(m)}for(let y of[...h.querySelectorAll("[style]")])y.setAttribute("style",p(y.getAttribute("style")??""));let b=h.createElement("meta");return b.setAttribute("http-equiv","Content-Security-Policy"),b.setAttribute("content",$t),h.head.prepend(b),`<!doctype html>${h.documentElement.outerHTML}`}var K=(d,t,l)=>`M${d-l} ${t}a${l} ${l} 0 1 0 ${2*l} 0a${l} ${l} 0 1 0 ${-2*l} 0`,de={ad_free:["M3 7h18v10H3z","M4 4l16 16"],bell:["M6 16v-5a6 6 0 0 1 12 0v5l2 2H4z","M10 21a2 2 0 0 0 4 0"],bolt:["M13 2L4 14h7l-1 8 9-12h-7z"],book:["M5 4h11a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3z","M5 17a3 3 0 0 1 3-3h11"],chart:["M3 20h18","M6 20v-8","M11 20V5","M16 20v-6","M21 20V9"],chat:["M4 5h16v11H9l-5 4z"],check:["M5 12l5 5 9-10"],check_circle:[K(12,12,9),"M8 12l3 3 5-6"],clock:[K(12,12,9),"M12 7v5l3 2"],cloud:["M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9a4.5 4.5 0 0 1-.5 9z"],crown:["M3 8l4 4 5-7 5 7 4-4-2 11H5z"],download:["M12 4v11","M7 10l5 5 5-5","M4 20h16"],gift:["M3 9h18v4H3z","M5 13v8h14v-8","M12 9v12","M12 9C10 5 6 5 6 7.5S12 9 12 9zm0 0c2-4 6-4 6-1.5S12 9 12 9z"],globe:[K(12,12,9),"M3 12h18","M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18z"],heart:["M12 20s-7-4.5-9-9a4.5 4.5 0 0 1 9-3 4.5 4.5 0 0 1 9 3c-2 4.5-9 9-9 9z"],infinity:["M7 9a3 3 0 1 0 0 6c3 0 7-6 10-6a3 3 0 1 1 0 6c-3 0-7-6-10-6z"],lock_open:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 7.5-2"],music:["M9 18V5l11-2v13",K(6,18,3),K(17,16,3)],people:[K(9,8,3.5),"M2 20a7 7 0 0 1 14 0","M16 4.5a3.5 3.5 0 0 1 0 7","M18 14a6 6 0 0 1 4 6"],person:[K(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",K(8.5,9.5,1.5),"M3 17l5-5 4 4 3-3 6 6"],shield:["M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"],sparkles:["M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z","M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"],star:["M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3l-5.5 2.9 1-6.2L3 9.6l6.2-.9z"],video:["M3 6h12v12H3z","M15 10l6-3v10l-6-3z"],arrow_right:["M4 12h15","M13 6l6 6-6 6"],calendar:["M4 6h16v15H4z","M4 10h16","M8 3v5","M16 3v5"],close:["M6 6l12 12","M18 6L6 18"],lock:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 8 0v4"],play:["M7 4l13 8-13 8z"],quote:["M5 17c3 0 4-2 4-5V7H4v5h3","M15 17c3 0 4-2 4-5V7h-5v5h3"],trophy:["M7 4h10v5a5 5 0 0 1-10 0z","M7 6H4v2a3 3 0 0 0 3 3","M17 6h3v2a3 3 0 0 1-3 3","M12 14v4","M8 21h8","M9 18h6v3H9z"]};var Be="http://www.w3.org/2000/svg";function pe(d,t,l){let a=d.createElementNS(Be,"svg");a.setAttribute("viewBox","0 0 24 24"),a.setAttribute("width",String(l)),a.setAttribute("height",String(l)),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","2"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),a.setAttribute("focusable","false");for(let c of t){let p=d.createElementNS(Be,"path");p.setAttribute("d",c),a.append(p)}return a}var dn=2,pn=2,f=(d,t=!1)=>({kind:"value",value:"plain",def:d,required:t}),j=d=>({kind:"value",value:"color",def:d}),We=d=>({kind:"value",value:"spacing",def:d}),zt=d=>({kind:"value",value:"radius",def:d}),G=(d=!1)=>({kind:"text",required:d}),Me=(d,t=!1)=>({kind:"list",item:d,required:t}),se=(d,t=!1)=>({kind:"object",item:d,required:t}),Ke=(d=!1)=>({kind:"component",required:d}),Re={kind:"components"},Ge={stack:{axis:f("vertical"),spacing:We(0),align:f("center"),distribution:f("start"),scroll:f(!1),children:Re},text:{text:G(),spans:Me("span"),font:f(),size:f(),weight:f(),line_height:f(),letter_spacing:f(),color:{kind:"value",value:"textColor",def:"text"},align:f("center"),max_lines:f(),uppercase:f(!1)},image:{src:f(void 0,!0),fit:f("fit"),aspect:f(),mask:se("mask"),overlay:{kind:"value",value:"textColor"},alt:G(),decorative:f(!1)},icon:{name:f(void 0,!0),color:j("accent"),size:f(24)},video:{src:f(void 0,!0),poster:f(),autoplay:f(!0),loop:f(!0),mute:f(!0),controls:f(!1),fit:f("fill"),aspect:f(),alt:G()},button:{action:se("action",!0),content:Ke(!0)},purchase_button:{content:Ke(!0),package:f()},package:{product:f(void 0,!0),plan:f(void 0,!0),selected:f(!1),offer:f(),children:Re},tabs:{},switch:{},carousel:{pages:Re,peek:f(0),spacing:f(8),loop:f(!1),auto_advance_ms:f(),indicator:se("indicator"),height:f("")},countdown:{},timeline:{items:Me("timeline_item",!0),line_color:j("accent"),line_width:f(2),icon_color:j("on_accent"),color:j("text"),spacing:f(16)},features:{items:Me("feature",!0),icon_color:j("accent"),color:j("text"),spacing:f(12)},spacer:{size:We()},divider:{color:j("muted"),thickness:f(1)},custom_html:{src:f(void 0,!0),height:f("",!0)}},Ht={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:f(""),height:f(""),max_width:f(),background:{kind:"fill"},border:se("border"),corners:{kind:"corners"},shadow:se("shadow"),opacity:f(1)},border:{width:f(),color:j("")},shadow:{color:j(""),radius:f(0),x:f(0),y:f(0)},linear:{type:f(""),angle:f(180),stops:f()},radial:{type:f(""),center_x:f(.5),center_y:f(.5),radius:f(.5),stops:f()},image_fill:{type:f(""),src:f(),fit:f("fill")},video_fill:{type:f(""),src:f(),poster:f(),loop:f(!0)},animation:{type:f(""),duration_ms:f(300),delay_ms:f(0),easing:f("ease_out")},action:{type:f(""),url:f(),sheet:f(),package:f()},mask:{shape:f(""),radius:zt(0),depth:f(16)},span:{text:G(!0),bold:f(!1),italic:f(!1),underline:f(!1),strikethrough:f(!1),color:j(""),link:f()},timeline_item:{icon:f(void 0,!0),title:G(!0),text:G(),color:j("")},feature:{icon:f(void 0,!0),text:G(!0)},indicator:{style:f("dots"),color:j("muted"),active_color:j("accent"),size:f(8),spacing:f(6)},typography:{font:f("system"),size:f(),weight:f(400),line_height:f(),letter_spacing:f(0),text_style:f("body")}},Xe=new Set(["package","purchase_button"]),Ct={action:{type:f(""),url:f(),link:f(),sheet:f(),placement:f(),name:f(),value:f(),offer:f(),code:G(),dismiss:f(!0)},presentation:{type:f(""),position:f("bottom"),auto_dismiss_seconds:f(),dismissible:f(!0),backdrop:j("#00000080")}},jt={modal:["type","dismissible","backdrop"],fullscreen:["type"],banner:["type","position","auto_dismiss_seconds","dismissible"],slide_in:["type","position","auto_dismiss_seconds","dismissible"],toast:["type","position","auto_dismiss_seconds","dismissible"],card:["type"]},Ft={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},Nt=["top","bottom","leading","trailing"],Dt=["top_leading","top_trailing","bottom_leading","bottom_trailing"],Jt=Object.keys(Ge),un=Jt.filter(d=>!Xe.has(d)),Ye=/\{\{\s*([^{}]*?)\s*\}\}/g,Q=(d,t)=>typeof d=="object"&&d!==null&&Object.hasOwn(d,t),M=d=>typeof d=="object"&&d!==null&&!Array.isArray(d)?d:{},I=d=>Array.isArray(d)?d:[],X=(d,t)=>d??t;function It(d){let t="";for(let l of new TextEncoder().encode(d)){let a=String.fromCharCode(l);t+=/^[A-Za-z0-9._~-]$/.test(a)?a:`%${l.toString(16).toUpperCase().padStart(2,"0")}`}return t}function Vt(d){let t=Math.floor(d/86400),l=Math.floor(d%86400/3600),a=Math.floor(d%3600/60),c=d%60,p=h=>String(h).padStart(2,"0");return{countdown:t>0?`${t}d ${p(l)}:${p(a)}:${p(c)}`:l>0?`${l}:${p(a)}:${p(c)}`:`${p(a)}:${p(c)}`,days:String(t),hours:p(l),minutes:p(a),seconds:p(c)}}function fn(d){let t=[],l=c=>{if(Array.isArray(c))return c.forEach(l);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.product=="string"&&typeof p.plan=="string"){let g=`${p.product}.${p.plan}`;t.includes(g)||t.push(g)}for(let g of Object.keys(p).sort())l(p[g])},a=d;for(let c of["header","root","footer"])l(a[c]);for(let c of Object.keys(M(a.sheets)).sort())l(M(M(a.sheets)[c]).root);return t}function Ut(d){let t=new Map,l=c=>{if(Array.isArray(c))return c.forEach(l);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.offer=="string"){let g=`${p.product}.${p.plan}`;t.has(g)||t.set(g,p.offer)}for(let g of Object.keys(p).sort())l(p[g])},a=d;for(let c of["header","root","footer","sheets"])l(a[c]);return t}function gn(d,t){return Ae(d,t).tree}function Ae(d,t){return new ue("paywall",d,t).resolve()}function hn(d,t){return Ee(d,t).tree}function Ee(d,t){let{variables:l,...a}=t;return new ue("message",d,{...a,packages:{"":{...l}}}).resolve()}var ue=class{kind;d;opts;lang;texts={};palette;typography={};radii;spacing;packages;offers;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,l,a){this.kind=t,this.d=l,this.opts=a,this.offers=Ut(l);let c={};for(let[y,m]of Object.entries(a.packages??{})){let v={...m};this.open(y)||(m.price!==void 0?v.offer_price=m.price:delete v.offer_price),c[y]=v}this.packages=c;let p=M(this.d.locales),g=String(this.d.default_locale??""),h=a.locale;Q(p,h)||(h=h.split("-")[0]??"",Q(p,h)||(h=g)),this.lang=h;for(let y of[g,h])for(let[m,v]of Object.entries(M(p[y])))typeof v=="string"&&(this.texts[m]=v);let b=M(this.d.theme);this.palette=M(M(b.colors)[a.appearance]);for(let[y,m]of Object.entries(M(b.typography))){let v={};for(let[A,P]of Object.entries(this.objectFields("typography"))){let R=X(M(m)[A],P.def);R!=null&&(v[A]=R)}this.typography[y]=v}this.radii=M(b.radii),this.spacing=M(b.spacing)}open(t){let l=this.offers.get(t);return l!==void 0&&(this.opts.offers??[]).includes(l)}fields(t){if(!(this.kind==="message"&&Xe.has(t)))return Ge[t]}objectFields(t){return(this.kind==="message"?Ct[t]:void 0)??Ht[t]??{}}resolve(){let[t,l]=this.initialState();this.tab=t,this.selected=this.kind==="paywall"?l:"";let a={theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};this.kind==="paywall"&&(a.selected=l);let c=this.d.presentation;if(typeof c=="object"&&c!==null){let g=this.item("presentation",M(c),void 0)??{},h=jt[String(M(c).type)]??[];for(let b of Object.keys(g))h.includes(b)||delete g[b];a.presentation=g}for(let g of["header","root","footer"]){let h=this.d[g];if(typeof h=="object"&&h!==null){let b=this.component(M(h),g,"",!1);b&&(a[g]=b)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let g={};for(let[h,b]of Object.entries(M(this.d.sheets))){let y=this.component(M(M(b).root),`sheets.${h}.root`,"",!1);y&&(g[h]=y);let m=this.text(M(b).title,this.packages[this.selected]);m!==null&&(p[h]=m)}a.sheets=g}return{tree:a,pathOf:g=>this.paths.get(g),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,l){return this.opts.switches&&Object.hasOwn(this.opts.switches,l)?this.opts.switches[l]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,l){let c=I(t.tabs).map(M).map(g=>String(g.id)),p=this.opts.tabs?.[l];return p!==void 0&&c.includes(p)?p:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:c[0]??""}initialState(){let t="",l="",a="",c="",p=(h,b)=>{if(Array.isArray(h)){h.forEach((m,v)=>p(m,`${b}[${v}]`));return}if(typeof h!="object"||h===null)return;let y=h;switch(y.type){case"package":{let m=`${y.product}.${y.plan}`;a===""&&(a=m),y.selected===!0&&l===""&&(l=m);break}case"switch":{let m=this.switchOn(y,b),v=m?y.on_package:y.off_package;typeof v=="string"&&c===""&&(c=v),p(m?y.on:y.off,`${b}.${m?"on":"off"}`);return}case"tabs":{let m=this.tabShown(y,b);t===""&&(t=m),I(y.tabs).forEach((v,A)=>{let P=M(v);P.id===m&&(typeof P.package=="string"&&c===""&&(c=P.package),p(P.content,`${b}.tabs[${A}].content`))});return}}for(let m of Object.keys(y).sort())m!=="sheets"&&p(y[m],b===""?m:`${b}.${m}`)};for(let h of["header","root","footer"])p(this.d[h],h);let g=this.opts.selected||c||l||a;return[t,g]}holds(t,l){let a=l||this.selected;for(let[c,p]of Object.entries(t))switch(c){case"selected_package":if(!I(p).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(a)!==p)return!1;break;case"offer_open":if(this.open(a)!==p)return!1;break;case"platform":if(!I(p).includes(this.opts.platform))return!1;break;case"locale":if(!I(p).includes(this.opts.locale)&&!I(p).includes(this.lang))return!1;break;case"appearance":if(p!==this.opts.appearance)return!1;break;case"tab":if(p!==this.tab)return!1;break}return!0}component(t,l,a,c){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(M(t.visible),a))return null;let p=String(t.type),g=a,h=c;p==="package"&&(g=`${t.product}.${t.plan}`,h=g===this.selected);let b={type:p};this.paths.set(b,l),Q(t,"id")&&(b.id=t.id);let y={...M(t.style)};h&&Object.assign(y,M(M(t.states).selected)),Object.keys(y).length>0&&(b.style=this.style(y)),typeof t.animation=="object"&&t.animation!==null&&(b.animation=this.defaults(M(t.animation),this.objectFields("animation")));let m=this.packages[g||this.selected];switch(p){case"tabs":return this.tabs(t,b,l,g);case"switch":return this.switchOf(t,b,l,g,h);case"countdown":return this.countdown(t,b,l,g,h);case"purchase_button":{let v=typeof t.package=="string"?t.package:this.selected;b.package=v,this.open(v)&&(b.offer=this.offers.get(v));let A=this.component(M(t.content),`${l}.content`,v,h);return A?(b.content=A,b):null}case"package":b.product=t.product,b.plan=t.plan,b.selected=h,typeof t.offer=="string"&&(this.opts.offers??[]).includes(t.offer)&&(b.offer=t.offer)}for(let[v,A]of Object.entries(this.fields(p)??{})){if(p==="package"&&(v==="product"||v==="plan"||v==="selected"||v==="offer"))continue;let P=t[v],R=Q(t,v);switch(A.kind){case"component":{if(!R)continue;let x=this.component(M(P),`${l}.${v}`,g,h);if(!x&&A.required)return null;x&&(b[v]=x);break}case"components":{let x=[];I(P).forEach((T,O)=>{let V=this.component(M(T),`${l}.${v}[${O}]`,g,h);V&&x.push(V)}),b[v]=x;break}case"text":{let x=this.text(P,m);if(x!==null)b[v]=x;else if(A.required||p==="text"&&v==="text"&&R)return null;break}case"list":{let x=[];for(let T of I(P)){let O=this.item(A.item,M(T),m);O&&x.push(O)}if(p==="text"&&x.length===0&&R)return null;R&&(b[v]=x);break}case"object":{if(R){let x=this.object(M(P),A.item,m);if(x===null&&A.required)return null;b[v]=x}else v==="indicator"&&(b[v]=this.object({},A.item,m));break}case"value":{let x=this.value(X(P,A.def),A);x!=null&&x!==""&&(b[v]=x);break}}}return p==="text"&&this.typeStyle(b),b}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let l=this.typography[t.size];for(let a of["font","weight","line_height","letter_spacing","text_style"])!Q(t,a)&&l?.[a]!==void 0&&l?.[a]!==null&&(t[a]=l[a]);t.size=l?.size??null}tabs(t,l,a,c){let p=this.tabShown(t,a);this.tabsShown[a]=p;let g=[];return I(t.tabs).forEach((h,b)=>{let y=M(h),m=y.id===p,v=this.component(M(y.label),`${a}.tabs[${b}].label`,c,m);if(g.push({id:y.id,selected:m,label:v}),m){let A=this.component(M(y.content),`${a}.tabs[${b}].content`,c,!1);A&&(l.content=A)}}),l.tabs=g,typeof t.bar=="object"&&t.bar!==null&&(l.bar=this.style(M(t.bar))),l}switchOf(t,l,a,c,p){let g=this.switchOn(t,a);this.switchesOn[a]=g,l.on=g;let h=this.text(t.label,this.packages[c||this.selected]);h!==null&&(l.label=h),l.tint=this.color(String(X(t.tint,"accent")));let b=g?"on":"off",y=this.component(M(t[b]),`${a}.${b}`,c,p);return y&&(l.content=y),l}countdown(t,l,a,c,p){let g=M(t.target),h=this.opts.now??Date.now(),b;if(typeof g.after_open_seconds=="number"?b=Math.trunc(g.after_open_seconds)-(this.opts.openedSecondsAgo??0):b=Math.trunc((Date.parse(String(g.at))-h)/1e3),b>0){l.state="counting",l.remaining_seconds=b,this.countdowns[a]=b;let y=this.packages,m={};for(let[A,P]of Object.entries(y))m[A]={...P,...Vt(b)};this.packages=m;let v=this.component(M(t.counting),`${a}.counting`,c,p);return v&&(l.content=v),this.packages=y,l}if(l.state="ended",l.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let y=this.component(M(t.ended),`${a}.ended`,c,p);y&&(l.content=y)}return l}item(t,l,a){let c={};for(let[p,g]of Object.entries(this.objectFields(t))){let h=l[p];if(g.kind==="text"){let b=this.text(h,a);if(b!==null)c[p]=b;else if(g.required)return null}else{let b=g.def,y=this.value(X(h,b),g);y!=null&&(Q(l,p)||b!=null&&b!=="")&&(c[p]=y)}}return c}object(t,l,a){if(l==="style")return this.style(t);let c=this.item(l,t,a)??{};if(l==="action")for(let p of["url","link"]){if(typeof c[p]!="string")continue;let g=qt(c[p],a);if(g===null)return null;c[p]=g}return c}defaults(t,l){let a={};for(let[c,p]of Object.entries(l)){let g=X(t[c],p.def);g!=null&&g!==""&&(a[c]=g)}return a}style(t){let l={};for(let[a,c]of Object.entries(t)){let p=this.objectFields("style")[a];if(!p){l[a]=c;continue}switch(p.kind){case"edges":l[a]=this.sides(c,Nt,this.spacing);break;case"corners":l[a]=this.sides(c,Dt,this.radii);break;case"fill":l[a]=this.fill(c);break;case"object":{let g=M(c),h={};for(let[b,y]of Object.entries(this.objectFields(p.item))){let m=X(g[b],y.def);m!=null&&m!==""&&(h[b]=this.value(m,y))}l[a]=h;break}default:l[a]=c}}return l}sides(t,l,a){let c={};for(let p of l){let g=typeof t=="object"&&t!==null?X(M(t)[p],0):t;c[p]=_e(g,a)}return c}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let l=M(t),a=this.defaults(l,this.objectFields(Ft[String(l.type)]??""));return Array.isArray(l.stops)&&(a.stops=l.stops.map(c=>({color:this.color(String(M(c).color)),at:M(c).at}))),a}value(t,l){if(l.kind!=="value")return t;switch(l.value){case"color":return typeof t=="string"&&t!==""?this.color(t):t;case"textColor":return typeof t=="string"?this.color(t):t==null?t:this.fill(t);case"spacing":return _e(t,this.spacing);case"radius":return _e(t,this.radii);default:return t}}color(t){let l=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof l=="string"?l:t}text(t,l){let a;if(typeof t=="string")a=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let p=t.t;a=typeof p=="string"&&Object.hasOwn(this.texts,p)?this.texts[p]:""}else return null;let c=!1;return a=a.replace(Ye,(p,g)=>{let h=l&&Object.hasOwn(l,g)?l[g]:void 0;return typeof h!="string"||h===""?(c=!0,""):h}),c||a.trim()===""?null:a}};function qt(d,t){let l=!1,a=d.replace(Ye,(c,p)=>{let g=t&&Object.hasOwn(t,p)?t[p]:void 0;return typeof g!="string"||g===""?(l=!0,""):It(g)});return l?null:a}function _e(d,t){return typeof d=="string"?Object.hasOwn(t,d)?t[d]:null:d}var Bt={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(d,t)=>`${d} of ${t}`},ee={system:'-apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',rounded:'ui-rounded, "SF Pro Rounded", Nunito, "Varela Round", system-ui, -apple-system, sans-serif',serif:'ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif',mono:'ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace'},Wt=1.35,Ze=20,Kt=new Set(["button","purchase_button","package","text"]),Gt=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),Qe={ease_out:"cubic-bezier(0.16, 1, 0.3, 1)",ease_in_out:"cubic-bezier(0.65, 0, 0.35, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"},Xt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},Yt={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},Zt={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},Qt={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},en=`
3
+ :host{display:block;height:100%}
4
+ .pw2{position:relative;box-sizing:border-box;display:flex;flex-direction:column;height:100%;overflow:hidden;font-family:${ee.system};font-size:1rem;line-height:1.3;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;text-rendering:optimizeLegibility}
5
+ .pw2 *,.pw2 *::before,.pw2 *::after{box-sizing:border-box}
6
+ .pw2-head,.pw2-foot{flex:none;display:flex;flex-direction:column;position:relative;z-index:1}
7
+ .pw2-head[hidden],.pw2-foot[hidden]{display:none}
8
+ .pw2-foot{max-height:30%;overflow-y:auto;scrollbar-width:none}
9
+ .pw2-foot .pw-text{font-size:min(var(--pw-fs,1rem),var(--pw-fs-max,21.6px))}
10
+ .pw2.pw2-large{overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}
11
+ .pw2.pw2-large>.pw2-body{flex:1 0 auto;overflow:visible;min-height:auto}
12
+ .pw2.pw2-large>.pw2-foot{position:sticky;bottom:0}
13
+ .pw2:not(.pw2-fit){padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}
14
+ .pw2:not(.pw2-fit)>.pw2-head,.pw2:not(.pw2-fit)>.pw2-body.pw2-top{padding-top:env(safe-area-inset-top,0px)}
15
+ .pw2:not(.pw2-fit)>.pw2-foot,.pw2:not(.pw2-fit)>.pw2-body.pw2-bottom{padding-bottom:env(safe-area-inset-bottom,0px)}
16
+ .pw2.pw2-fit{height:auto;flex:0 1 auto;min-height:0}
17
+ .pw2-body{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;overscroll-behavior:contain;scrollbar-width:none}
18
+ .pw2-body::-webkit-scrollbar{display:none}
19
+ .pw2-body>.pw-c{flex:1 0 auto}
20
+ /* A part as wide as its place \u2014 narrower when it says how wide it is at most, then in the middle, as SwiftUI's stacks place it. */
21
+ .pw2-head>.pw-c,.pw2-body>.pw-c,.pw2-foot>.pw-c{align-self:center;width:100%}
22
+ .pw-c{position:relative;min-width:0}
23
+ .pw-c[style*="--pw-bw"]{isolation:isolate}
24
+ .pw-c[style*="--pw-bw"]::after{content:"";position:absolute;inset:0;border:var(--pw-bw) solid var(--pw-bc);border-radius:inherit;pointer-events:none;z-index:2}
25
+ .pw-stack{display:flex;flex-direction:column}
26
+ .pw-stack.h{flex-direction:row}
27
+ .pw-stack.z{display:grid}
28
+ .pw-stack.z>.pw-c{grid-area:1/1}
29
+ .pw-stack.scroll{overflow-y:auto;scrollbar-width:none}
30
+ .pw-stack.h.scroll{overflow-x:auto;overflow-y:hidden}
31
+ .pw-stack.scroll>.pw-c{flex-shrink:0}
32
+ .pw-text{margin:0;overflow-wrap:break-word;white-space:pre-line}
33
+ /* A text beside others wraps between its words, never inside one: a price stays whole, what is beside it wraps. */
34
+ .pw-stack.h>.pw-text{min-width:min-content}
35
+ .pw-text a{color:inherit}
36
+ .pw-clamp{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}
37
+ .pw-grad{-webkit-background-clip:text;background-clip:text;color:transparent!important;-webkit-text-fill-color:transparent}
38
+ .pw-icon{display:inline-flex;flex:none}
39
+ .pw-icon svg{display:block}
40
+ .pw-img{overflow:hidden;flex:none}
41
+ .pw-img img,.pw-img video{display:block;width:100%;height:100%}
42
+ .pw-img.natural img{height:auto}
43
+ .pw-overlay{position:absolute;inset:0;pointer-events:none}
44
+ .pw-bgvideo{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:-1;pointer-events:none}
45
+ button.pw-c{font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;text-align:inherit;display:flex;flex-direction:column;align-items:stretch;justify-content:center;-webkit-tap-highlight-color:transparent;transition:opacity .15s ease,transform .15s ease}
46
+ button.pw-c:active{transform:scale(.98)}
47
+ button.pw-c:disabled{cursor:default;opacity:.5}
48
+ .pw-pkg{cursor:pointer;display:flex;flex-direction:column;transition:background-color .2s ease,border-color .2s ease,box-shadow .2s ease}
49
+ .pw-pkg[aria-disabled=true]{cursor:default;opacity:.55}
50
+ :focus-visible{outline:2px solid currentColor;outline-offset:2px}
51
+ .pw-features{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
52
+ .pw-feature{display:flex;align-items:center;gap:12px;text-align:start}
53
+ .pw-timeline{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
54
+ .pw-step{display:grid;grid-template-columns:auto 1fr;column-gap:14px;position:relative;text-align:start}
55
+ .pw-dot{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;position:relative;z-index:1}
56
+ .pw-line{position:absolute;left:calc(16px - var(--pw-line-w)/2);top:32px;width:var(--pw-line-w);bottom:calc(-1 * var(--pw-gap))}
57
+ .pw-step:last-child .pw-line{display:none}
58
+ .pw-step-title{font-weight:600}
59
+ .pw-step-text{opacity:.72;font-size:.9375rem;margin-top:2px}
60
+ .pw-tabs{display:flex;flex-direction:column;gap:12px}
61
+ .pw-tablist{display:flex}
62
+ .pw-tab{flex:1 1 0;min-width:0;font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;display:flex}
63
+ .pw-tab>.pw-c{flex:1 1 auto}
64
+ .pw-switch{display:flex;flex-direction:column;gap:12px}
65
+ .pw-switchcontent{display:flex;flex-direction:column}
66
+ .pw-switchrow{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:start}
67
+ .pw-toggle{flex:none;width:51px;height:31px;border-radius:999px;border:0;padding:2px;cursor:pointer;background:var(--pw-off);transition:background-color .2s ease}
68
+ .pw-toggle[aria-checked=true]{background:var(--pw-tint)}
69
+ .pw-toggle i{display:block;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 2px 4px #0003;transition:transform .2s ease}
70
+ .pw-toggle[aria-checked=true] i{transform:translateX(20px)}
71
+ .pw-carousel{display:flex;flex-direction:column;gap:12px;min-width:0}
72
+ .pw-track{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;scroll-behavior:smooth;padding-inline:var(--pw-peek);scroll-padding-inline:var(--pw-peek);gap:var(--pw-gap)}
73
+ .pw-track::-webkit-scrollbar{display:none}
74
+ .pw-track>.pw-c{flex:none;width:100%;scroll-snap-align:center}
75
+ .pw-dots{display:flex;justify-content:center;gap:var(--pw-dot-gap)}
76
+ .pw-dots button{border:0;padding:0;cursor:pointer;width:var(--pw-dot);height:var(--pw-dot);border-radius:999px;background:var(--pw-dot-c);transition:width .25s ease,background-color .25s ease}
77
+ .pw-dots.bars button{width:calc(var(--pw-dot) * 3)}
78
+ .pw-dots button[aria-current=true]{background:var(--pw-dot-on)}
79
+ .pw-dots.dots button[aria-current=true]{width:calc(var(--pw-dot) * 2.5)}
80
+ .pw-html{display:block;width:100%;border:0;pointer-events:none;background:transparent}
81
+ .pw-spacer{flex:1 1 0}
82
+ .pw-stack:not(.h):not(.z)>.greedy-h,.pw-pkg>.greedy-h,button.pw-c>.greedy-h{align-self:stretch}
83
+ .pw-stack.h>.greedy-h{flex:1 1 0}
84
+ .pw-stack.z>.greedy-h{justify-self:stretch}
85
+ .pw-stack:not(.h):not(.z)>.greedy-v,.pw-pkg>.greedy-v{flex:1 1 auto}
86
+ .pw-stack.h>.greedy-v,.pw-stack.z>.greedy-v{align-self:stretch}
87
+ .pw-layer{position:absolute;inset:0;z-index:5;display:flex;flex-direction:column;justify-content:flex-end;background:#0007}
88
+ .pw-sheet{max-height:92%;overflow-y:auto;border-radius:16px 16px 0 0;display:flex;flex-direction:column;outline:none;padding-bottom:env(safe-area-inset-bottom,0px)}
89
+ .pw-sheet>.pw-c{flex:1 0 auto}
90
+ .pw-grab{width:36px;height:5px;border-radius:3px;background:currentColor;opacity:.25;margin:8px auto 0;flex:none}
91
+ [data-pw-highlight]{outline:2px solid #2E7CF6!important;outline-offset:-1px}
92
+ [data-pw-hover]:not([data-pw-highlight]){outline:1px dashed #2E7CF6aa!important;outline-offset:-1px}
93
+ .pw-editing button,.pw-editing .pw-pkg,.pw-editing a{cursor:default}
94
+ @media (prefers-reduced-motion:reduce){.pw2 *{transition:none!important;scroll-behavior:auto!important}}
95
+ `,oe=d=>{if(typeof d!="string"||d.length>2048)return!1;try{let t=new URL(d);return t.protocol==="https:"&&t.hostname!==""&&t.username===""&&t.password===""}catch{return!1}},tn=d=>{if(typeof d!="string"||d.length>2048||/[\s\u0000-\u001f\u007f]/.test(d))return!1;if(oe(d))return!0;let t=/^([a-z][a-z0-9+.-]{1,31}):(.+)$/.exec(d)?.[1];if(!t||nn.has(t))return!1;try{let l=new URL(d);return l.username===""&&l.password===""}catch{return!1}},nn=new Set(["https","http","javascript","data","file","vbscript","about","blob","content","intent"]),sn=d=>`${String(d.product)}.${String(d.plan)}`,fe=d=>{let[t,l]=d.split(".");return{product:t??"",plan:l??""}},_=d=>`${Number(d)||0}px`,et=d=>`${d/16}rem`,on=0;function vn(d,t,l){return tt("paywall",d,t,l)}function kn(d,t,l){return tt("message",d,t,l)}function tt(d,t,l,a){let c=t.ownerDocument,p=c.defaultView,g=`pw${++on}`,h=c.createElement("div");h.setAttribute(d==="paywall"?"data-palbase-paywall":"data-palbase-message",""),h.style.display="block",h.style.height="100%";let b=h.attachShadow({mode:"open"});rn(c,b,en);let y=c.createElement("div");y.className="pw2";let m=c.createElement("div");m.className="pw2-head";let v=c.createElement("div");v.className="pw2-body";let A=c.createElement("div");A.className="pw2-foot";let P=c.createElement("div");y.append(m,v,A),b.append(y),t.replaceChildren(h);let R={...l},x={openedAt:Date.now(),...l.state},T,O=new Map,V=new Map,ie=!1,ge=null,he,Le=!1,Pe=c.defaultView?.ResizeObserver,Te=typeof Pe=="function"?new Pe(()=>{y.classList.toggle("pw2-large",ze()>=Ze),we()}):null;Te?.observe(y);let $e=()=>we();c.fonts?.addEventListener?.("loadingdone",$e);let Oe=null,ye=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),te=()=>R.reduceMotion??ye?.matches??!1,F=()=>!!a.editor,re={...Bt,...a.labels},be=()=>T.tree.selected??"";function Y(){let e=x.now??Date.now(),i={locale:R.locale,appearance:R.appearance,platform:R.platform??"web",tabs:x.tabs??{},switches:x.switches??{},openedSecondsAgo:Math.max(0,Math.floor((e-(x.openedAt??e))/1e3)),now:e};T=d==="paywall"?Ae(R.definition,{...i,packages:R.packages??{},eligible:R.eligible??[],offers:R.offers??[],...x.selected?{selected:x.selected}:{}}):Ee(R.definition,{...i,variables:R.variables??{}});let o=T.tree.theme.colors,n=T.tree.presentation?.type,s=d==="message"&&n!==void 0&&n!=="fullscreen";y.classList.toggle("pw2-fit",s),h.style.display=s?"flex":"block",h.style.flexDirection=s?"column":"",h.style.minHeight=s?"0":"",h.style.flex=s?"0 1 auto":"",h.style.height=s?"auto":"100%",y.style.background=s?"":o.background??"",y.style.color=o.text??"",y.classList.toggle("pw-editing",F()),y.classList.toggle("pw2-large",ze()>=Ze),y.lang=T.language,y.dir=Gt.has(T.language.split("-")[0]??"")?"rtl":"ltr",V=new Map,me(m,T.tree.header,"vertical"),me(v,T.tree.root,"vertical"),me(A,T.tree.footer,"vertical"),m.hidden=!T.tree.header,A.hidden=!T.tree.footer,v.classList.toggle("pw2-top",!T.tree.header),v.classList.toggle("pw2-bottom",!T.tree.footer),xt();for(let[r,u]of O)V.has(r)||u.cleanup.forEach(w=>w());O=V,ge&&Ie(ge);for(let r of O.values())r.type==="custom_html"&&Je(r.el);we(),clearTimeout(he),Le||=h.isConnected,x.now===void 0&&Object.keys(T.countdowns).length>0&&(he=setTimeout(()=>{Le&&!h.isConnected||Y()},1e3-Date.now()%1e3+5))}function ze(){let e=c.documentElement,i=e&&p?parseFloat(p.getComputedStyle(e).fontSize):NaN;return Number.isFinite(i)?i:16}function we(){let e=[];for(let o of O.values()){if(o.type!=="text")continue;let n=o.el,s=n.dataset.pwFit??n.style.fontSize;if(!s||(n.style.fontSize=s,delete n.dataset.pwFit,!/^\S+$/.test(n.textContent??"")))continue;let r=n.parentElement,u=r&&p?p.getComputedStyle(r):null,w=r&&u?r.clientWidth-parseFloat(u.paddingLeft||"0")-parseFloat(u.paddingRight||"0"):1/0,k=Math.min(n.clientWidth,w);e.push({e:n,base:s,k:k<=0||n.scrollWidth<=k+.5?1:Math.max(.6,k/n.scrollWidth)})}let i=o=>o.closest(".pw-stack.h");for(let o of e){let n=Math.min(o.k,...e.filter(s=>s!==o&&s.base===o.base&&i(s.e)&&i(s.e)===i(o.e)).map(s=>s.k));n>=1||(o.e.dataset.pwFit=o.base,o.e.style.fontSize=`calc(${o.base} * ${n.toFixed(3)})`)}}function me(e,i,o){let n=i?U(i,o,{inControl:!1,inSheet:!1,inFooter:e===A}):null;q(e,n?[n]:[])}function U(e,i,o){let n=T.pathOf(e)??"",s=nt(e),r=O.get(n),u;if(r&&r.type===e.type&&r.key===s&&r.axis===i&&!V.has(n))u=r;else{let k=ot(e,n,i,o);if(!k)return null;u={el:k.el,type:e.type,key:s,styleKey:"",axis:i,slots:k.slots,cleanup:k.cleanup??[]},u.el.classList.add("pw-c"),u.el.dataset.pwPath=n,u.el.dataset.pwType=e.type,e.id&&(u.el.dataset.pwId=e.id),r&&r.cleanup.forEach(L=>L()),bt(u.el,e)}let w=`${JSON.stringify(e.style??null)}|${i}`;return u.styleKey!==w&&(He(u.el,e,i),u.styleKey=w),V.set(n,u),gt(u,e),ht(u,e,o),u.el}function nt(e){let i=new Set(["style",...Zt[e.type]??[],...Qt[e.type]??[]]),o={};for(let[n,s]of Object.entries(e))i.has(n)||(o[n]=s);return e.type==="tabs"&&(o.tabs=e.tabs.map(n=>n.id)),e.type==="carousel"&&(o.pages=e.pages.length),e.type==="stack"&&(o.greedy=e.children.some(n=>n.type==="spacer"&&typeof n.size!="number")),(e.type==="image"||e.type==="video"||e.type==="custom_html")&&(o.asset=st(e)),JSON.stringify(o)}function st(e){let i=ne(e.src);return i?(R.assets?.[i]?.url??R.assets?.[i]?.html?.length??"none").toString():""}function S(e,i){let o=c.createElement(e);return i&&(o.className=i),o}function ot(e,i,o,n){let s=e;switch(e.type){case"stack":{let r=S("div",`pw-stack${s.axis==="horizontal"?" h":s.axis==="z"?" z":""}${s.scroll?" scroll":""}`);return s.axis!=="z"&&s.children.some(u=>u.type==="spacer"&&typeof u.size!="number")&&r.classList.add(s.axis==="horizontal"?"greedy-h":"greedy-v"),r.style.gap=_(s.spacing),s.axis==="z"?r.style.placeItems=s.align==="stretch"?"stretch":String(s.align??"center"):(r.style.alignItems=Xt[String(s.align)]??"center",r.style.justifyContent=Yt[String(s.distribution)]??"flex-start"),{el:r,slots:{children:r}}}case"text":return{el:it(s,n),slots:{}};case"icon":{let r=de[String(s.name)];if(!r)return null;let u=S("span","pw-icon");return u.style.color=String(s.color??""),u.append(pe(c,r,Number(s.size)||24)),u.setAttribute("aria-hidden","true"),{el:u,slots:{}}}case"image":return at(s);case"video":return lt(s);case"features":{let r=S("ul","pw-features");r.style.gap=_(s.spacing);for(let u of s.items??[]){let w=S("li","pw-feature"),k=de[u.icon];if(k){let z=pe(c,k,22);z.style.color=String(s.icon_color),z.style.flex="none",w.append(z)}let L=S("span");L.textContent=u.text,L.style.color=String(s.color),w.append(L),r.append(w)}return{el:r,slots:{}}}case"timeline":{let r=S("ol","pw-timeline");r.style.gap=_(s.spacing),r.style.setProperty("--pw-gap",_(s.spacing)),r.style.setProperty("--pw-line-w",_(s.line_width));for(let u of s.items??[]){let w=S("li","pw-step"),k=S("span","pw-dot");k.style.background=u.color??String(s.line_color),k.style.color=String(s.icon_color);let L=de[u.icon];L&&k.append(pe(c,L,18)),k.setAttribute("aria-hidden","true");let z=S("span","pw-line");z.style.background=String(s.line_color),z.setAttribute("aria-hidden","true");let D=S("span");D.style.color=String(s.color);let B=S("span","pw-step-title");if(B.textContent=u.title,D.append(B),u.text){let $=S("span","pw-step-text");$.style.display="block",$.textContent=u.text,D.append($)}w.append(k,D,z),r.append(w)}return{el:r,slots:{}}}case"spacer":{let r=S("div","pw-spacer");return r.setAttribute("aria-hidden","true"),typeof s.size=="number"&&(r.style.flex="none",o==="horizontal"?r.style.width=_(s.size):r.style.height=_(s.size)),{el:r,slots:{}}}case"divider":{let r=S("div","pw-divider");return r.setAttribute("role","separator"),r.style.background=String(s.color),r.style.alignSelf="stretch",r.style.flex="none",o==="horizontal"?(r.setAttribute("aria-orientation","vertical"),r.style.width=_(s.thickness)):r.style.height=_(s.thickness),{el:r,slots:{}}}case"button":return ct(s,n,i);case"purchase_button":{let r=S("button","pw-buy");return r.type="button",r.addEventListener("click",()=>{Ne(r,()=>kt(r.dataset.package??"",r.dataset.offer))}),{el:r,slots:{content:r}}}case"package":{let r=S("div","pw-pkg");return r.setAttribute("role","radio"),r.addEventListener("click",()=>Se(r)),r.addEventListener("keydown",u=>wt(u,r)),{el:r,slots:{children:r}}}case"tabs":return pt(s,i);case"switch":return ut(s,i);case"carousel":return ft(s);case"countdown":{let r=S("div","pw-countdown");return r.setAttribute("role","timer"),r.setAttribute("aria-live","off"),{el:r,slots:{content:r}}}case"custom_html":{let r=R.assets?.[ne(s.src)??""];if(!r?.html)return null;let u=S("iframe","pw-html");return u.setAttribute("sandbox","allow-scripts"),u.setAttribute("aria-hidden","true"),u.setAttribute("title",""),u.tabIndex=-1,u.srcdoc=r.html,typeof s.height=="number"?u.style.height=_(s.height):typeof s.height=="string"&&s.height.endsWith("%")?u.style.height=s.height:s.height==="fill"&&(u.style.flex="1 1 0"),u.addEventListener("load",()=>Je(u)),{el:u,slots:{}}}default:return null}}function it(e,i){let o=String(e.text_style??"body"),n=i.inControl?"span":o==="large_title"?"h1":o==="title"||o==="title2"?"h2":o==="title3"?"h3":"p",s=S(n,"pw-text");i.inControl&&(s.style.display="block"),s.style.fontFamily=rt(e.font);let r=typeof e.size=="number"?e.size:16;if(i.inFooter?(s.style.setProperty("--pw-fs",et(r)),s.style.setProperty("--pw-fs-max",`${Number((r*Wt).toFixed(2))}px`)):s.style.fontSize=et(r),typeof e.weight=="number"&&(s.style.fontWeight=String(e.weight)),typeof e.line_height=="number"&&(s.style.lineHeight=String(e.line_height)),typeof e.letter_spacing=="number"&&e.letter_spacing!==0&&(s.style.letterSpacing=_(e.letter_spacing)),s.style.textAlign=String(e.align??"center"),e.uppercase===!0&&(s.style.textTransform="uppercase"),typeof e.max_lines=="number"&&(s.classList.add("pw-clamp"),s.style.setProperty("-webkit-line-clamp",String(e.max_lines))),typeof e.color=="string"?s.style.color=e.color:e.color&&typeof e.color=="object"&&(s.classList.add("pw-grad"),s.style.backgroundImage=ke(e.color)??""),Array.isArray(e.spans))for(let u of e.spans){let w=u.link==="terms"?R.links?.terms:u.link==="privacy"?R.links?.privacy:u.link,k=oe(w)&&!i.inControl,L=S(k?"a":"span");L.textContent=String(u.text),u.bold&&(L.style.fontWeight="700"),u.italic&&(L.style.fontStyle="italic");let z=[u.underline?"underline":"",u.strikethrough?"line-through":""].filter(Boolean).join(" ");z&&(L.style.textDecoration=z),typeof u.color=="string"&&u.color!==""&&(L.style.color=u.color),k&&oe(w)&&(L.href=w,L.target="_blank",L.rel="noopener noreferrer",L.addEventListener("click",D=>{F()||!a.onLink||(D.preventDefault(),a.onLink(w))})),s.append(L)}else s.textContent=String(e.text??"");return s}function rt(e){if(typeof e!="string")return ee.system;let i=ne(e);if(i){let o=R.assets?.[i]?.family;return o?`"${o}", ${ee.system}`:ee.system}return ee[e]??ee.system}function Z(e){let i=ne(e);return i?R.assets?.[i]?.url||void 0:oe(e)?e:void 0}function at(e){let i=S("div","pw-img");typeof e.aspect=="number"&&(i.style.aspectRatio=String(e.aspect));let o=Z(e.src),n=e.mask;if(n?.shape==="circle")i.style.borderRadius="50%";else if(n?.shape==="rect"&&n.radius)i.style.borderRadius=_(n.radius);else if(n?.shape==="convex")i.style.setProperty("border-end-start-radius",`50% ${_(n.depth)}`),i.style.setProperty("border-end-end-radius",`50% ${_(n.depth)}`);else if(n?.shape==="concave"){let s=`radial-gradient(ellipse 50% ${_(n.depth)} at 50% 100%, transparent 98%, #000 100%)`;i.style.setProperty("-webkit-mask-image",s),i.style.setProperty("mask-image",s)}if(o){let s=S("img");s.src=o,s.decoding="async",s.style.objectFit=e.fit==="fill"?"cover":"contain",e.decorative===!0?(s.alt="",i.setAttribute("aria-hidden","true")):s.alt=String(e.alt??""),s.addEventListener("error",()=>s.style.visibility="hidden"),i.append(s)}if(e.overlay&&typeof e.overlay=="object"){let s=S("div","pw-overlay");s.style.backgroundImage=ke(e.overlay)??"",i.append(s)}return{el:i,slots:{}}}function lt(e){let i=S("div","pw-img");typeof e.aspect=="number"&&(i.style.aspectRatio=String(e.aspect));let o=Z(e.src);if(o){let n=S("video");n.src=o;let s=Z(e.poster);s&&(n.poster=s),n.muted=e.mute!==!1,n.loop=e.loop!==!1,n.playsInline=!0,n.controls=e.controls===!0,n.preload="auto",n.style.objectFit=e.fit==="fit"?"contain":"cover",n.autoplay=e.autoplay!==!1&&!te()&&!F(),typeof e.alt=="string"?n.setAttribute("aria-label",e.alt):n.setAttribute("aria-hidden","true"),i.append(n)}return{el:i,slots:{}}}function ct(e,i,o){let n=e.action??{},s,r=n.type==="restore"||n.type==="offer_code"||n.type==="request_push"||n.type==="show_paywall"||n.type==="offer"||n.type==="apply_promo"||n.type==="copy_code",u=d==="message"&&n.type!=="close"&&n.type!=="sheet"&&n.dismiss!==!1;switch(n.type){case"close":i.inSheet?s=()=>ce(null):a.onClose&&(s=()=>a.onClose());break;case"restore":a.onRestore&&(s=()=>a.onRestore());break;case"offer_code":a.onOfferCode&&(R.platform??"web")!=="web"&&(s=()=>a.onOfferCode());break;case"open_url":case"terms":case"privacy":{let k=n.type==="open_url"?n.url:n.type==="terms"?R.links?.terms:R.links?.privacy;oe(k)&&(s=()=>a.onLink?a.onLink(k):void p?.open(k,"_blank","noopener,noreferrer"));break}case"sheet":n.sheet&&(s=()=>ce(n.sheet));break;case"select_package":n.package&&(s=()=>xe(n.package));break;case"deep_link":{let k=n.link;tn(k)&&(s=()=>a.onDeepLink?a.onDeepLink(k):p?.location.assign(k));break}case"request_push":a.onRequestPush&&(s=()=>a.onRequestPush());break;case"show_paywall":n.placement&&a.onShowPaywall&&(s=()=>a.onShowPaywall(n.placement));break;case"custom":n.name&&a.onCustom&&(s=()=>a.onCustom(n.name,n.value));break;case"offer":n.offer&&a.onOffer&&(s=()=>a.onOffer(n.offer));break;case"apply_promo":n.code&&a.onApplyPromo&&(s=()=>a.onApplyPromo(n.code));break;case"copy_code":if(n.code){let k=n.code;s=()=>a.onCopyCode?a.onCopyCode(k):p?.navigator?.clipboard?.writeText(k).catch(()=>{})}break}if(!s&&!F())return null;let w=S("button");return w.type="button",n.type==="close"&&w.setAttribute("aria-label",re.close),w.addEventListener("click",()=>{if(!s||F())return;d==="message"&&a.onAction?.(dt(n,o,e.id));let k=u?()=>a.onClose?.():void 0;r?Ne(w,async()=>{await s(),k?.()}):(s(),k?.())}),{el:w,slots:{content:w}}}function dt(e,i,o){let n={type:e.type,dismiss:e.type==="sheet"?!1:e.type==="close"||e.dismiss!==!1,path:i};for(let s of["url","link","placement","name","value","sheet","offer","code"])typeof e[s]=="string"&&(n[s]=e[s]);return typeof o=="string"&&(n.id=o),n}function pt(e,i){let o=S("div","pw-tabs"),n=S("div","pw-tablist");n.setAttribute("role","tablist");let s=S("div","pw-tabpanel");s.setAttribute("role","tabpanel"),s.id=`${g}-${i}-panel`;let r={content:s},u=e.tabs.map(w=>w.id);return u.forEach((w,k)=>{let L=S("button","pw-tab");L.type="button",L.setAttribute("role","tab"),L.id=`${g}-${i}-tab-${k}`,L.setAttribute("aria-controls",s.id),L.dataset.tab=w,L.addEventListener("click",()=>je(i,w)),L.addEventListener("keydown",z=>{let D=z.key==="ArrowRight"?k+1:z.key==="ArrowLeft"?k-1:z.key==="Home"?0:z.key==="End"?u.length-1:-2;if(D===-2)return;z.preventDefault();let B=u[(D+u.length)%u.length];je(i,B),n.querySelector(`[data-tab="${B}"]`)?.focus()}),n.append(L),r[`label:${w}`]=L}),o.append(n,s),r.bar=n,{el:o,slots:r}}function ut(e,i){let o=S("div","pw-switch"),n=S("div","pw-switchrow"),s=S("span","pw-switchlabel");s.id=`${g}-${i}-label`;let r=S("button","pw-toggle");r.type="button",r.setAttribute("role","switch"),r.setAttribute("aria-labelledby",s.id),r.append(S("i")),r.addEventListener("click",()=>vt(i,r.getAttribute("aria-checked")!=="true")),n.append(s,r);let u=S("div","pw-switchcontent");return o.append(n,u),{el:o,slots:{content:u,label:s,toggle:r}}}function ft(e){let i=S("div","pw-carousel");i.setAttribute("role","region"),i.setAttribute("aria-roledescription","carousel");let o=S("div","pw-track");o.tabIndex=0,o.style.setProperty("--pw-peek",_(e.peek)),o.style.setProperty("--pw-gap",_(e.spacing)),typeof e.height=="number"&&(o.style.minHeight=_(e.height));let n=e.indicator??{},s=S("div",`pw-dots ${n.style??"dots"}`);s.style.setProperty("--pw-dot",_(n.size??8)),s.style.setProperty("--pw-dot-gap",_(n.spacing??6)),s.style.setProperty("--pw-dot-c",n.color??"#8888"),s.style.setProperty("--pw-dot-on",n.active_color??"currentColor"),n.style==="none"&&(s.hidden=!0),i.append(o,s);let r=()=>[...o.children].filter($=>$ instanceof(p?.HTMLElement??HTMLElement)),u=()=>{let $=r(),N=o.scrollLeft+o.clientWidth/2,H=0;return $.forEach((J,Mt)=>{Math.abs(J.offsetLeft+J.offsetWidth/2-N)<Math.abs(($[H]?.offsetLeft??0)+($[H]?.offsetWidth??0)/2-N)&&(H=Mt)}),H},w=$=>{let N=r();if(N.length===0)return;let H=e.loop?($+N.length)%N.length:Math.max(0,Math.min(N.length-1,$)),J=N[H];o.scrollTo?.({left:J.offsetLeft-(o.clientWidth-J.offsetWidth)/2,behavior:te()?"auto":"smooth"}),k(H)},k=$=>{[...s.children].forEach((N,H)=>N.setAttribute("aria-current",String(H===$)))};o.addEventListener("scroll",()=>k(u()),{passive:!0}),o.addEventListener("keydown",$=>{$.key!=="ArrowRight"&&$.key!=="ArrowLeft"||($.preventDefault(),w(u()+($.key==="ArrowRight"?1:-1)))});let L=!1,z=()=>L=!0,D=()=>L=!1;i.addEventListener("pointerenter",z),i.addEventListener("pointerleave",D),i.addEventListener("focusin",z),i.addEventListener("focusout",D);let B=[];if(typeof e.auto_advance_ms=="number"){let $=setInterval(()=>{if(L||te()||F())return;let N=r(),H=u();!e.loop&&H>=N.length-1||w(H+1)},e.auto_advance_ms);B.push(()=>clearInterval($))}return i.pwDots=$=>{s.children.length!==$&&(s.replaceChildren(...Array.from({length:$},(N,H)=>{let J=S("button");return J.type="button",J.setAttribute("aria-label",re.page(H+1,$)),J.addEventListener("click",()=>w(H)),J})),k(u()))},{el:i,slots:{pages:o},cleanup:B}}function gt(e,i){let o=i;switch(i.type){case"package":{let n=sn(o),r=!!R.packages?.[n]?.price;e.el.dataset.package=n,e.el.setAttribute("aria-checked",String(o.selected===!0)),e.el.setAttribute("aria-disabled",String(!r));break}case"purchase_button":{let n=String(o.package);e.el.dataset.package=n,typeof o.offer=="string"?e.el.dataset.offer=o.offer:delete e.el.dataset.offer,e.el.disabled=ie||!R.packages?.[n]?.price;break}case"switch":{let n=e.slots.toggle;n.setAttribute("aria-checked",String(o.on===!0)),n.style.setProperty("--pw-tint",String(o.tint??"")),n.style.setProperty("--pw-off",`color-mix(in srgb, ${T.tree.theme.colors.muted??"#888888"} 45%, transparent)`),e.slots.label.textContent=String(o.label??""),e.slots.label.hidden=o.label===void 0;break}case"tabs":{for(let n of o.tabs){let s=e.slots[`label:${n.id}`];s.setAttribute("aria-selected",String(n.selected)),s.tabIndex=n.selected?0:-1,n.selected&&e.slots.content.setAttribute("aria-labelledby",s.id)}o.bar&&He(e.slots.bar,{type:"stack",style:o.bar},"vertical");break}}}function ht(e,i,o){let n=i,s={...o,inControl:o.inControl||i.type==="button"||i.type==="purchase_button"||i.type==="package"};switch(i.type){case"stack":case"package":{let r=i.type==="stack"?String(n.axis??"vertical"):"vertical",u=n.children.map(k=>[k,U(k,r,s)]).filter(k=>k[1]!==null),w=u.map(k=>k[1]);q(e.slots.children,w),yt(r,u),i.type==="stack"&&ae(e.el,w);break}case"button":case"purchase_button":{let r=n.content?U(n.content,"vertical",s):null;q(e.slots.content,r?[r]:[]);break}case"countdown":case"switch":{let r=n.content?U(n.content,"vertical",s):null;q(e.slots.content,r?[r]:[]),ae(e.slots.content,r?[r]:[]);break}case"tabs":{for(let u of n.tabs){let w=u.label?U(u.label,"vertical",{...s,inControl:!0}):null;q(e.slots[`label:${u.id}`],w?[w]:[])}let r=n.content?U(n.content,"vertical",s):null;q(e.slots.content,r?[r]:[]),ae(e.slots.content,r?[r]:[]);break}case"carousel":{let r=n.pages.map(u=>U(u,"page",s)).filter(Boolean);r.forEach((u,w)=>{u.setAttribute("role","group"),u.setAttribute("aria-roledescription","slide"),u.setAttribute("aria-label",re.page(w+1,r.length))}),q(e.slots.pages,r),ae(e.slots.pages,r),e.el.pwDots?.(r.length);break}}}function yt(e,i){let o=e==="horizontal"?"width":e==="vertical"?"height":null;if(!o)return;let n=u=>u?o==="width"?u.leading+u.trailing:u.top+u.bottom:0,s=i.filter(([u])=>u.style?.[o]==="fill"),r=Math.max(0,...s.map(([u])=>n(u.style?.padding)+n(u.style?.margin)));for(let[u,w]of s)w.style.flexBasis=_(r-n(u.style?.margin))}function ae(e,i){let o=i.filter(s=>s.dataset.pwType==="package");if(o.length===0){e.getAttribute("role")==="radiogroup"&&e.removeAttribute("role");return}e.setAttribute("role","radiogroup"),e.setAttribute("aria-label",re.packages);let n=o.find(s=>s.getAttribute("aria-checked")==="true")??o[0];for(let s of o)s.tabIndex=s===n?0:-1}function q(e,i){let o=()=>[...e.children].filter(s=>s.dataset?.pwPath!==void 0),n=o();for(let s of n)i.includes(s)||s.remove();n=o(),i.forEach((s,r)=>{n[r]!==s&&(e.insertBefore(s,n[r]??null),n=o())})}let ve=new WeakMap;function E(e,i,o){e.style.setProperty(i,o),ve.get(e).push(i)}function He(e,i,o){for(let u of ve.get(e)??[])e.style.removeProperty(u);ve.set(e,[]);for(let u of[...e.children])u.classList.contains("pw-bgvideo")&&u.remove();let n=i.style;if(i.type==="image"&&e.classList.toggle("natural",typeof i.aspect!="number"&&(n?.height===void 0||n.height==="fit")),!n)return;let s=(u,w)=>{w&&(E(e,`${u}-block-start`,_(w.top)),E(e,`${u}-block-end`,_(w.bottom)),E(e,`${u}-inline-start`,_(w.leading)),E(e,`${u}-inline-end`,_(w.trailing)))};s("padding",n.padding),s("margin",n.margin),Ce(e,"width",n.width,o),typeof n.height=="number"&&Kt.has(i.type)?(E(e,"min-height",_(n.height)),o==="vertical"&&E(e,"flex","none")):Ce(e,"height",n.height,o),typeof n.max_width=="number"&&E(e,"max-width",_(n.max_width));let r=n.background;if(r){if(r.type==="color")E(e,"background-color",r.color);else if(r.type==="linear"||r.type==="radial")E(e,"background-image",ke(r)??"");else if(r.type==="image"){let u=Z(r.src);u&&(E(e,"background-image",`url("${u.replace(/"/g,"%22")}")`),E(e,"background-size",r.fit==="fit"?"contain":"cover"),E(e,"background-position","center"),E(e,"background-repeat","no-repeat"))}else if(r.type==="video"){let u=Z(r.src);if(u){let w=S("video","pw-bgvideo");w.src=u;let k=Z(r.poster);k&&(w.poster=k),w.muted=!0,w.loop=r.loop!==!1,w.playsInline=!0,w.autoplay=!te()&&!F(),w.setAttribute("aria-hidden","true"),E(e,"isolation","isolate"),e.prepend(w)}}}if(n.border&&i.type==="custom_html"?E(e,"border",`${_(n.border.width)} solid ${n.border.color??"transparent"}`):n.border&&(E(e,"--pw-bw",_(n.border.width)),E(e,"--pw-bc",n.border.color??"transparent")),n.corners){let u=n.corners;E(e,"border-start-start-radius",_(u.top_leading)),E(e,"border-start-end-radius",_(u.top_trailing)),E(e,"border-end-start-radius",_(u.bottom_leading)),E(e,"border-end-end-radius",_(u.bottom_trailing)),(i.type==="image"||i.type==="video"||r?.type==="image"||r?.type==="video")&&E(e,"overflow","hidden")}n.shadow&&E(e,"box-shadow",`${_(n.shadow.x)} ${_(n.shadow.y)} ${_(n.shadow.radius)} ${n.shadow.color}`),typeof n.opacity=="number"&&n.opacity!==1&&E(e,"opacity",String(n.opacity))}function Ce(e,i,o,n){if(o==null||o==="")return;if(n==="page"){i==="height"&&E(e,"height",o==="fill"?"100%":typeof o=="number"?_(o):o==="fit"?"fit-content":String(o));return}let s=n==="horizontal"?"width":n==="vertical"?"height":null;o==="fill"?i===s?(E(e,"flex","1 1 0"),E(e,`min-${i}`,"0")):n==="z"?E(e,i,"100%"):(E(e,"align-self","stretch"),E(e,i,"auto")):o==="fit"?(i===s&&E(e,"flex","0 0 auto"),E(e,i,"fit-content")):(E(e,i,typeof o=="number"?_(o):String(o)),i===s&&E(e,"flex","none"))}function ke(e){let i=o=>o.map(n=>`${n.color} ${(n.at*100).toFixed(2)}%`).join(", ");if(e.type==="linear")return`linear-gradient(${e.angle}deg, ${i(e.stops)})`;if(e.type==="radial"){let o=`${(e.radius*100).toFixed(2)}%`;return`radial-gradient(ellipse ${o} ${o} at ${(e.center_x*100).toFixed(2)}% ${(e.center_y*100).toFixed(2)}%, ${i(e.stops)})`}}function bt(e,i){let o=i.animation;if(!o||R.animate===!1||te()||typeof e.animate!="function")return;let n=24,r={fade:{opacity:0},slide_up:{opacity:0,transform:`translateY(${n}px)`},slide_down:{opacity:0,transform:`translateY(-${n}px)`},slide_leading:{opacity:0,transform:`translateX(-${n}px)`},slide_trailing:{opacity:0,transform:`translateX(${n}px)`},scale:{opacity:0,transform:"scale(0.92)"}}[o.type];r&&e.animate([r,{opacity:1,transform:"none"}],{duration:o.duration_ms,delay:o.delay_ms,easing:Qe[o.easing]??Qe.ease_out,fill:"backwards"})}function le(){a.onState?.({...x}),Y()}function xe(e){x.selected===e&&be()===e||(x.selected=e,le(),a.onSelect?.(fe(e)))}function Se(e){F()||e.getAttribute("aria-disabled")==="true"||xe(e.dataset.package??"")}function wt(e,i){if(e.key===" "||e.key==="Enter"){e.preventDefault(),Se(i);return}let o=e.key==="ArrowDown"||e.key==="ArrowRight"?1:e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:0;if(o===0)return;e.preventDefault();let n=i.closest("[role=radiogroup]"),r=(n?[...n.children].filter(k=>k.dataset.pwType==="package"):[i]).filter(k=>k.getAttribute("aria-disabled")!=="true"),u=r.indexOf(i),w=r[(u+o+r.length)%r.length];w&&(Se(w),(O.get(w.dataset.pwPath??"")?.el??w).focus())}function je(e,i){if(F())return;x.tabs={...x.tabs,[e]:i};let o=mt(e,i);o&&(x.selected=o),le()}function mt(e,i){return Fe(e)?.tabs?.find(n=>n.id===i)?.package}function vt(e,i){if(F())return;x.switches={...x.switches,[e]:i};let o=Fe(e),n=i?o?.on_package:o?.off_package;n&&(x.selected=n),le()}function Fe(e){let i=R.definition;for(let o of e.match(/[^.[\]]+/g)??[])i=i?.[/^\d+$/.test(o)?Number(o):o];return i}async function Ne(e,i){if(!(F()||ie)){ie=!0,e.disabled=!0,e.setAttribute("aria-busy","true");try{await i()}finally{ie=!1,e.removeAttribute("aria-busy"),e.disabled=!1;for(let o of O.values())o.type==="purchase_button"&&(o.el.disabled=!R.packages?.[o.el.dataset.package??""]?.price)}}}async function kt(e,i){!R.packages?.[e]?.price||!a.onPurchase||await a.onPurchase(i!==void 0?{...fe(e),offer:i}:fe(e))}function ce(e){F()&&e!==null&&x.sheet===e||(e&&!x.sheet&&(Oe=b.activeElement??null),x.sheet=e,le(),e||Oe?.focus())}function xt(){let e=x.sheet,i=e?T.tree.sheets?.[e]:void 0;if(!i){P.remove();return}P.className="pw-layer";let o=P.firstElementChild;if(!o){o=S("div","pw-sheet"),o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.tabIndex=-1;let s=S("div","pw-grab");s.setAttribute("aria-hidden","true"),o.append(s),P.append(o),P.addEventListener("click",r=>{r.target===P&&!F()&&ce(null)}),o.addEventListener("keydown",r=>St(r,o))}o.style.background=T.tree.theme.colors.background??"",o.setAttribute("aria-label",T.sheetTitles[e]??"");let n=U(i,"vertical",{inControl:!1,inSheet:!0});q(o,n?[n]:[]),P.isConnected||(y.append(P),queueMicrotask(()=>(De(o)[0]??o).focus()))}function De(e){return[...e.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')].filter(i=>!i.hidden)}function St(e,i){if(e.key==="Escape"){e.preventDefault(),ce(null);return}if(e.key!=="Tab")return;let o=De(i);if(o.length===0){e.preventDefault();return}let n=o[0],s=o[o.length-1],r=b.activeElement;e.shiftKey&&r===n?(e.preventDefault(),s.focus()):!e.shiftKey&&r===s&&(e.preventDefault(),n.focus())}function Je(e){try{let i=d==="paywall"?{type:"palbase.paywall",package:be()}:{type:"palbase.message"};e.contentWindow?.postMessage({...i,locale:T.language,appearance:R.appearance},"*")}catch{}}function Ie(e){for(let i of b.querySelectorAll("[data-pw-highlight]"))i.removeAttribute("data-pw-highlight");ge=e,e&&O.get(e)?.el.setAttribute("data-pw-highlight","")}let Ve=e=>e.composedPath().find(i=>i instanceof(p?.HTMLElement??HTMLElement)&&i.dataset.pwPath!==void 0);y.addEventListener("click",e=>{if(!a.editor)return;let i=Ve(e);i&&(e.preventDefault(),e.stopPropagation(),a.editor.onPick(i.dataset.pwPath))},!0),y.addEventListener("pointerover",e=>{if(a.editor){for(let i of b.querySelectorAll("[data-pw-hover]"))i.removeAttribute("data-pw-hover");Ve(e)?.setAttribute("data-pw-hover","")}}),y.addEventListener("pointerleave",()=>{for(let e of b.querySelectorAll("[data-pw-hover]"))e.removeAttribute("data-pw-hover")});let Ue=()=>Y();return ye?.addEventListener?.("change",Ue),Y(),{get selected(){let e=be();return e?fe(e):null},get state(){return{...x}},select(e){xe(e)},update(e){R={...R,...e},e.state&&Object.assign(x,e.state),Y()},highlight(e){Ie(e)},replay(){for(let e of O.values())e.cleanup.forEach(i=>i());O=new Map;for(let e of[m,v,A])e.replaceChildren();Y()},destroy(){clearTimeout(he),Te?.disconnect(),c.fonts?.removeEventListener?.("loadingdone",$e),ye?.removeEventListener?.("change",Ue);for(let e of O.values())e.cleanup.forEach(i=>i());h.remove()}}}function rn(d,t,l){let a=d.defaultView;try{if(a&&"adoptedStyleSheets"in t&&typeof a.CSSStyleSheet=="function"){let p=new a.CSSStyleSheet;p.replaceSync(l),t.adoptedStyleSheets=[p];return}}catch{}let c=d.createElement("style");c.textContent=l,t.append(c)}export{_t as a,ne as b,an as c,Lt as d,Ot as e,de as f,dn as g,pn as h,Jt as i,un as j,Vt as k,fn as l,Ut as m,gn as n,Ae as o,hn as p,Ee as q,tn as r,vn as s,kn as t,rn as u};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
2
  var s=class extends Error{code;constructor(t,e){super(e),this.name="FieldError",this.code=t}},f="pbe1.",g="pbl1.",k=6e4,p="[A-Za-z_][A-Za-z0-9_$]{0,62}",w=new RegExp(`^${p}\\.${p}(\\.${p})?$`);function v(o){return w.test(o)}var h=class{crypto;keys=new Map;lookupKey;timer;opts;now;constructor(t){this.opts=t,this.now=t.now??Date.now}get loaded(){return this.lookupKey!==void 0}async load(t){this.crypto??=await import("node:crypto"),this.take(await this.opts.fetch(t)),this.timer===void 0&&(this.timer=setInterval(()=>{this.opts.fetch().then(e=>this.take(e),()=>{})},k),this.timer.unref?.())}close(){clearInterval(this.timer),this.timer=void 0}take(t){let e=new Map;for(let r of t.keys)e.set(r.id,{id:r.id,key:Buffer.from(r.key,"base64url"),activatesAt:Date.parse(r.activates_at)});this.keys=e,this.lookupKey=Buffer.from(t.lookup,"base64url")}ready(){if(this.crypto===void 0||this.lookupKey===void 0)throw new s("not_loaded","the project's field keys are not loaded: await palbase.fields.load() at startup");return this.crypto}currentKey(){this.ready();let t;for(let e of this.keys.values())e.activatesAt<=this.now()&&(t===void 0||e.activatesAt>=t.activatesAt)&&(t=e);if(t===void 0)throw new s("unknown_key","the project has no field key in force");return t.id}encrypt(t,e){let r=this.ready();l(t);let n=this.currentKey(),i=r.randomBytes(12);return b(r,this.keys.get(n).key,i,n,t,e)}decrypt(t,e){let r=this.ready();if(l(t),!e.startsWith(f))throw new s("not_encrypted",`${t} holds a value that is not encrypted`);let n=e.slice(f.length),i=n.indexOf("."),a=i<0?n:n.slice(0,i),u=this.keys.get(a);if(u===void 0)throw new s("unknown_key",`${t} was sealed with field key ${a}, which this project does not hold`);let c=Buffer.from(n.slice(i+1),"base64url");if(i<0||c.length<28||c.toString("base64url")!==n.slice(i+1))throw new s("unopenable",`${t} holds a value that does not open here`);try{let d=r.createDecipheriv("aes-256-gcm",u.key,c.subarray(0,12));return d.setAAD(y(t)),d.setAuthTag(c.subarray(c.length-16)),Buffer.concat([d.update(c.subarray(12,c.length-16)),d.final()]).toString("utf8")}catch{throw new s("unopenable",`${t} holds a value that does not open here: tampered, or another column's`)}}isEncrypted(t){return t.startsWith(f)}lookup(t,e){let r=this.ready();return l(t),m(r,this.lookupKey,t,e)}};function l(o){if(!v(o))throw new TypeError(`a field's address is table.column, or schema.table.column, not ${JSON.stringify(o)}`)}function y(o){return Buffer.from(`pbe1\0${o}`,"utf8")}function b(o,t,e,r,n,i){let a=o.createCipheriv("aes-256-gcm",t,e);a.setAAD(y(n));let u=Buffer.concat([e,a.update(i,"utf8"),a.final(),a.getAuthTag()]);return`${f}${r}.${u.toString("base64url")}`}function m(o,t,e,r){let n=o.createHmac("sha256",t);return n.update(`pbl1\0${e}\0`,"utf8"),n.update(r,"utf8"),`${g}${n.digest("base64url")}`}export{s as a,h as b};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- import{b as d,m as k}from"./QROXSSPQ.js";function S(n){let o=n.meta;if(typeof o!="function")throw new TypeError("encrypted() takes a zod schema: z.string(), z.number(), z.object(\u2026)");return o.call(n,{[d]:!0})}var p=class{value;constructor(o){this.value=o}toJSON(){throw new TypeError("an encrypt() value is sealed by the engine, in a route's answer: it is never JSON of its own")}},m=0;function $(n){if(n===void 0)throw new TypeError("encrypt() takes a JSON value: undefined is none");if(n instanceof p)throw new TypeError("encrypt() of an encrypt() value: one is enough");return m++,new p(n)}function j(){return m}function O(n){let o=[],s=new Set,f=(t,a)=>{if(t instanceof p){if(o.push(a),g(t.value,new Set))throw new TypeError(`${a}: an encrypt() value holds another \u2014 encrypt the whole, or its parts`);return t.value}if(typeof t!="object"||t===null||s.has(t))return t;if(Array.isArray(t)){s.add(t);let r=t.map((c,e)=>f(c,`${a}/${e}`));return s.delete(t),r}let y=Object.getPrototypeOf(t);if(y!==Object.prototype&&y!==null)return t;s.add(t);let i={};for(let[r,c]of Object.entries(t))i[r]=f(c,`${a}/${k(r)}`);return s.delete(t),i};return{value:f(n,"/response"),pointers:o}}function g(n,o){return n instanceof p?!0:typeof n!="object"||n===null||o.has(n)?!1:(o.add(n),Object.values(n).some(s=>g(s,o)))}function v(n,o,s){let f=new Set,l=n,t=l?.$defs??{},a=(i,r,c)=>{if(typeof i!="object"||i===null)return;let e=i;if(typeof e.$ref=="string"){if(c.has(e.$ref))return;let u=new Set(c).add(e.$ref);e.$ref==="#"?a(l,r,u):e.$ref.startsWith("#/$defs/")&&a(t[e.$ref.slice(8)],r,u)}if(e[d]===!0){f.add(r);return}for(let u of["anyOf","oneOf","allOf"])if(Array.isArray(e[u]))for(let w of e[u])a(w,r,c);if(typeof e.properties=="object"&&e.properties!==null)for(let[u,w]of Object.entries(e.properties))a(w,`${r}/${k(u)}`,c);typeof e.items=="object"&&e.items!==null&&a(e.items,`${r}/*`,c);for(let u of["additionalProperties","patternProperties","prefixItems"])if(e[u]!==void 0&&y(e[u]))throw new TypeError(`${s}: an encrypted field is a named property \u2014 not every key of a record, nor a tuple's place`)},y=i=>{if(h(i))return!0;let r=typeof i=="object"&&i!==null?i.$ref:void 0;return typeof r=="string"&&h(r==="#"?l:t[r.slice(8)])};return a(n,o,new Set),[...f]}function T(n){let s=n["~standard"].jsonSchema?.input;if(typeof s!="function")return{};try{return s({target:"draft-2020-12",libraryOptions:{unrepresentable:"any"}})}catch{return{}}}function h(n){return JSON.stringify(n??null).includes(`"${d}":true`)}export{S as a,$ as b,j as c,O as d,v as e,T as f,h as g};
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ import{b as d,m as k}from"./J7Z2PYL4.js";function S(n){let o=n.meta;if(typeof o!="function")throw new TypeError("encrypted() takes a zod schema: z.string(), z.number(), z.object(\u2026)");return o.call(n,{[d]:!0})}var p=class{value;constructor(o){this.value=o}toJSON(){throw new TypeError("an encrypt() value is sealed by the engine, in a route's answer: it is never JSON of its own")}},m=0;function $(n){if(n===void 0)throw new TypeError("encrypt() takes a JSON value: undefined is none");if(n instanceof p)throw new TypeError("encrypt() of an encrypt() value: one is enough");return m++,new p(n)}function j(){return m}function O(n){let o=[],s=new Set,f=(t,a)=>{if(t instanceof p){if(o.push(a),g(t.value,new Set))throw new TypeError(`${a}: an encrypt() value holds another \u2014 encrypt the whole, or its parts`);return t.value}if(typeof t!="object"||t===null||s.has(t))return t;if(Array.isArray(t)){s.add(t);let r=t.map((c,e)=>f(c,`${a}/${e}`));return s.delete(t),r}let y=Object.getPrototypeOf(t);if(y!==Object.prototype&&y!==null)return t;s.add(t);let i={};for(let[r,c]of Object.entries(t))i[r]=f(c,`${a}/${k(r)}`);return s.delete(t),i};return{value:f(n,"/response"),pointers:o}}function g(n,o){return n instanceof p?!0:typeof n!="object"||n===null||o.has(n)?!1:(o.add(n),Object.values(n).some(s=>g(s,o)))}function v(n,o,s){let f=new Set,l=n,t=l?.$defs??{},a=(i,r,c)=>{if(typeof i!="object"||i===null)return;let e=i;if(typeof e.$ref=="string"){if(c.has(e.$ref))return;let u=new Set(c).add(e.$ref);e.$ref==="#"?a(l,r,u):e.$ref.startsWith("#/$defs/")&&a(t[e.$ref.slice(8)],r,u)}if(e[d]===!0){f.add(r);return}for(let u of["anyOf","oneOf","allOf"])if(Array.isArray(e[u]))for(let w of e[u])a(w,r,c);if(typeof e.properties=="object"&&e.properties!==null)for(let[u,w]of Object.entries(e.properties))a(w,`${r}/${k(u)}`,c);typeof e.items=="object"&&e.items!==null&&a(e.items,`${r}/*`,c);for(let u of["additionalProperties","patternProperties","prefixItems"])if(e[u]!==void 0&&y(e[u]))throw new TypeError(`${s}: an encrypted field is a named property \u2014 not every key of a record, nor a tuple's place`)},y=i=>{if(h(i))return!0;let r=typeof i=="object"&&i!==null?i.$ref:void 0;return typeof r=="string"&&h(r==="#"?l:t[r.slice(8)])};return a(n,o,new Set),[...f]}function T(n){let s=n["~standard"].jsonSchema?.input;if(typeof s!="function")return{};try{return s({target:"draft-2020-12",libraryOptions:{unrepresentable:"any"}})}catch{return{}}}function h(n){return JSON.stringify(n??null).includes(`"${d}":true`)}export{S as a,$ as b,j as c,O as d,v as e,T as f,h as g};
@@ -0,0 +1,2 @@
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ import{b as C}from"./5OOA4R4H.js";import{a as pe}from"./25HECIZY.js";import{a as L,b as B,c as K,d as U,e as I,f as $,g as N,h as D,i as F,j as q,k as V,l as J,m as z,n as Y,o as G,p as X,q as Z,r as Q,s as ee}from"./SMECWMF7.js";import{a as w,c as re,d as oe,e as ie,f as se,h as ae,i as ce,j as R,k as le,l as de,o as A}from"./J7Z2PYL4.js";import{a as te,b as ne}from"./YMIK6HLK.js";import{b as P,d as v}from"./PEQZDT6P.js";var m=class extends Error{status=400;code;data;constructor(e,n,r={}){super(n),this.name="TransitRefusal",this.code=e,this.data=r}},We=6e4,He=1e3;function M(t){return/^t[1-9][0-9]{0,5}$/.test(t)?Number(t.slice(1)):0}var b=class{keys=new Map;retired=new Set;order=[];project;timer;fetchedAt=0;heldFrom=0;fetching;opts;now;sleep;constructor(e){this.opts=e,this.now=e.now??Date.now,this.sleep=e.sleep??(n=>new Promise(r=>setTimeout(r,n)))}get loaded(){return this.project!==void 0}get projectId(){if(this.project===void 0)throw new Error("the project's transit keys are not loaded: await palbase.transit.load() at startup");return this.project}current(){return this.order[0]}async load(e){await this.refresh(e),this.timer===void 0&&(this.timer=setInterval(()=>{this.refresh().catch(()=>{})},We),this.timer.unref?.())}close(){clearInterval(this.timer),this.timer=void 0}refresh(e){return this.fetching??=(async()=>{let n=this.now();try{let r=await this.opts.fetch(e),o=new Map;for(let i of r.keys){let s=oe(i.key);o.set(i.id,{privateKey:s,publicKey:this.keys.get(i.id)?.publicKey??await ie(s)})}this.keys=o,this.order=r.keys.map(i=>i.id),this.retired=new Set(r.retired),this.project=r.project,this.fetchedAt=this.now(),this.heldFrom=n}finally{this.fetching=void 0}})(),this.fetching}newest(){return Math.max(0,...this.order.map(M),...[...this.retired].map(M))}async key(e){let n=this.now();for(;M(e)>this.newest()&&this.heldFrom<n;){let i=this.fetchedAt+He-this.now();if(i>0){await this.sleep(i);continue}await this.refresh()}let r=this.keys.get(e),o=this.current();if(this.retired.has(e))throw new m("encryption_key_retired",`the request is sealed to ${e}, retired: fetch the project's keys again`,{current:o});if(r===void 0)throw new m("encryption_key_unknown",`the request is sealed to ${e}, which the project has not made`,{current:o});return r}async request(e){if(e.header===void 0||e.header===null||e.header==="")throw new m("encryption_required",`this route carries encrypted fields: the request names its key in ${w}`,{field:w,current:this.current()});let n;try{n=ae(e.header).kid}catch{throw new m("encryption_unopenable",`${w} is not one`,{field:w})}let r=await this.key(n),o;try{o=se(this.projectId,e.method,e.path,e.params??[])}catch{throw new m("encryption_unopenable","the request's path holds a value no key is sealed for",{field:w})}try{return new E(n,await ce(e.header,r.privateKey,r.publicKey,o))}catch(i){throw i instanceof re?new m("encryption_unopenable","the request's key does not open: sealed for another project, route or path, or changed",{field:w}):i}}},E=class{kid;key;constructor(e,n){this.kid=e,this.key=n}async open(e,n,r){return A(e,n,r,async(o,i)=>{if(!le(i))throw new m("encryption_required",`${o} is an encrypted field: it came plain`,{field:o});try{return await de(this.key,o,i)}catch{throw new m("encryption_unopenable",`${o} does not open: changed, moved from another field, or another request's`,{field:o})}})}async seal(e,n){return A(e,"/response",n,(r,o)=>R(this.key,r,o))}sealField(e,n){return R(this.key,e,n)}};var je=/^pb_[a-z0-9]+_s/;function O(t){if(pe())throw new TypeError("palbase/server runs on a server: its secret key never goes into a browser or a mobile app \u2014 apps use palbase/web (or the native SDKs) with the publishable key");if(typeof t.secretKey!="string"||!je.test(t.secretKey))throw new TypeError("secretKey is the project secret key (pb_<ref>_s\u2026); a publishable key belongs in palbase/web");let e=ne(v({baseUrl:t.url,credentials:{secretKey:t.secretKey},fetch:t.fetch,solveProofOfWork:t.solveProofOfWork??!1}),t.retry??te),n=X.client(e);return{ai:L.client(e),analytics:B.client(e),auth:K.client(e),cache:U.client(e),calls:I.client(e),fields:new C({fetch:async r=>(await n.getFieldKeys({signal:r})).data}),flags:D.client(e),iap:F.client(e),machines:V.client(e),messaging:J.client(e),notify:z.client(e),payments:Y.client(e),campaigns:$.client(e),commerce:N.client(e),journeys:q.client(e),realtime:G.client(e),secrets:n,storage:Z.client(e),stores:Q.client(e),workspaces:ee.client(e),transit:new b({fetch:async r=>(await n.getTransitKeys({signal:r})).data}),transport:e,url:new URL(t.url).origin}}var u=class extends Error{code;constructor(e,n){super(n),this.name="WebhookSignatureError",this.code=e}},Be=300,Ke=/^[0-9]{1,12}$/,Ue=/^[0-9a-f]{64}$/,ue=8,Ie=/^whsec_[0-9A-Za-z]{32,}$/,$e=1024*1024;async function ye(t){if(typeof t.secret!="string"||!Ie.test(t.secret))throw new TypeError("secret is the webhook endpoint secret (whsec_\u2026), not an API key");await he(t);let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(fe(t.body)))}catch{throw new u("invalid_body","the signed body is not JSON")}if(!Je(e))throw new u("invalid_body","the signed body is not a Palbase event (id, type, project_id, created_at, data)");return e}async function he(t){if(typeof t.secret!="string"||t.secret==="")throw new TypeError("secret is the key the request was signed with");let e=fe(t.body),{t:n,v1:r}=me(t),o=await crypto.subtle.importKey("raw",new TextEncoder().encode(t.secret),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign("HMAC",o,Ve(new TextEncoder().encode(`${n}.`),e))),s=!1;for(let l of r)qe(i,Fe(l))&&(s=!0);if(!s)throw new u("signature_mismatch","no v1 in Palbase-Signature is this body signed with this secret")}function me(t){let e=t.toleranceSeconds??Be;if(!Number.isFinite(e)||e<0)throw new TypeError(`toleranceSeconds is a number of seconds, 0 or more (got ${String(t.toleranceSeconds)})`);let n=(t.now??Date.now)();if(!Number.isFinite(n))throw new TypeError(`now() returns epoch milliseconds (got ${String(n)})`);let r=t.signature;if(typeof r!="string"||r.trim()==="")throw new u("missing_signature","the request carries no Palbase-Signature header");let o,i=[];for(let s of r.split(",")){let l=s.indexOf("=");if(l<=0)throw new u("malformed_signature","Palbase-Signature is t=<seconds>,v1=<hex>");let c=s.slice(0,l).trim(),a=s.slice(l+1).trim();if(c==="t"){if(o!==void 0||!Ke.test(a))throw new u("malformed_signature","Palbase-Signature carries one t, in unix seconds");o=a}else if(c==="v1"){if(!Ue.test(a))throw new u("malformed_signature","a v1 is 64 lowercase hex characters");if(i.length===ue)throw new u("malformed_signature",`Palbase-Signature carries at most ${ue} v1`);i.push(a)}}if(o===void 0||i.length===0)throw new u("malformed_signature","Palbase-Signature is t=<seconds>,v1=<hex>");if(Math.abs(n/1e3-Number(o))>e)throw new u("stale_timestamp",`the signature's time is more than ${e} s from now: an old delivery sent again is not taken`);return{t:o,v1:i}}async function Ne(t,e,n={}){let r=await De(t,n.maxBytes??$e);return ye({toleranceSeconds:n.toleranceSeconds,now:n.now,secret:e,signature:t.headers.get("palbase-signature"),body:r})}async function De(t,e){let n=()=>new u("body_too_large",`the body is larger than ${e} bytes`),r=Number(t.headers.get("content-length")??"NaN");if(Number.isFinite(r)&&r>e)throw n();if(!t.body)return new Uint8Array(0);let o=t.body.getReader(),i=[],s=0;for(;;){let{done:a,value:d}=await o.read();if(a)break;if(s+=d.byteLength,s>e)throw await o.cancel().catch(()=>{}),n();i.push(d)}let l=new Uint8Array(s),c=0;for(let a of i)l.set(a,c),c+=a.byteLength;return l}function fe(t){if(typeof t=="string")return new TextEncoder().encode(t);if(t instanceof Uint8Array)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);throw new TypeError("body is the raw request body (string or bytes): a parsed object is not what was signed \u2014 read the body before any JSON middleware")}function Fe(t){let e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function qe(t,e){if(t.byteLength!==e.byteLength)return!1;let n=0;for(let r=0;r<t.byteLength;r++)n|=t[r]^e[r];return n===0}function Ve(t,e){let n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t,0),n.set(e,t.byteLength),n}function Je(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.project_id=="string"&&typeof e.created_at=="string"&&"data"in e}var ge=60,ze=60,Ye=8*1024,Ge=1e5;function W(t){let e=t instanceof Uint8Array?t:new Uint8Array(t),n="";for(let r of e)n+=String.fromCharCode(r);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function be(t){let e=t.replace(/[\s=]+/g,"");if(!/^[A-Za-z0-9+/_-]*$/.test(e)||e.length%4===1)return;let n=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"=")),r=new Uint8Array(n.length);for(let o=0;o<n.length;o++)r[o]=n.charCodeAt(o);return r}function we(t){let e=be(t);if(e)try{let n=JSON.parse(new TextDecoder().decode(e));return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}catch{return}}var x=class{byKey=new Map;held=0;sweptAt=Number.NEGATIVE_INFINITY;max;constructor(e=Ge){this.max=e}spend(e,n){if(n>=e.until)throw new p("proof","the DPoP proof is not taken: it was checked too long ago");let r=this.byKey.get(e.jkt);if(r){this.forgetOld(e.jkt,r,n);let o=r.get(e.jti);if(o!==void 0&&o>n)throw new p("proof","the DPoP proof is not taken: it was used before");o!==void 0&&r.delete(e.jti)&&this.held--}this.held>=this.max&&this.makeRoom(n),r=this.byKey.get(e.jkt),r||(r=new Map,this.byKey.set(e.jkt,r)),r.set(e.jti,e.until),this.held++}forgetOld(e,n,r){for(let[o,i]of n){if(i>r)break;n.delete(o),this.held--}n.size===0&&this.byKey.delete(e)}makeRoom(e){if(e-this.sweptAt>=1e3){this.sweptAt=e;for(let[r,o]of this.byKey){for(let[i,s]of o)s>e||(o.delete(i),this.held--);o.size===0&&this.byKey.delete(r)}this.held=0;for(let r of this.byKey.values())this.held+=r.size}if(this.held<this.max)return;let n=[...this.byKey].sort((r,o)=>o[1].size-r[1].size);for(let[r,o]of n){if(this.held<=this.max*.9)break;this.byKey.delete(r),this.held-=o.size}}};async function Xe(t,e){let n=`{"crv":"P-256","kty":"EC","x":"${t}","y":"${e}"}`;return W(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)))}function ke(t){try{let e=new URL(t);return e.username!==""||e.password!==""?void 0:`${e.protocol}//${e.host}${e.pathname}`}catch{return}}async function Se(t,e,n,r){let o=Oe=>{throw new p("proof",`the DPoP proof is not taken: ${Oe}`)},i=n.proof;if(!i)return o("there is none (a DPoP-bound token comes with a DPoP header)");if(i.length>Ye)return o("it is too long");let s=i.split(".");if(s.length!==3)return o("it is not a JWS of three parts");let l=we(s[0]),c=we(s[1]);if(!l||!c)return o("its header or claims are not base64url JSON");if(l.typ!=="dpop+jwt")return o("its typ is not dpop+jwt");if(l.alg!=="ES256")return o(`it is signed with ${String(l.alg)}; only ES256 is taken`);let a=l.jwk;if(!a||typeof a!="object"||a.kty!=="EC"||a.crv!=="P-256"||typeof a.x!="string"||typeof a.y!="string")return o("its header carries no P-256 public key");if("d"in a)return o("its header carries a private key");if(await Xe(a.x,a.y)!==e)return o("it is signed by a key the token does not name");let d;try{d=await crypto.subtle.importKey("jwk",{kty:"EC",crv:"P-256",x:a.x,y:a.y,ext:!0},{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])}catch{return o("its key is not a P-256 point")}let y=be(s[2]);if(!y||!await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},d,y,new TextEncoder().encode(`${s[0]}.${s[1]}`)).catch(()=>!1))return o("its signature does not verify");if(typeof c.htm!="string"||c.htm.toUpperCase()!==n.method.toUpperCase())return o(`it is for ${String(c.htm)}, not ${n.method}`);let h=typeof c.htu=="string"?ke(c.htu):void 0,f=ke(n.url);if(!h||!f||h!==f)return o(`it is for ${String(c.htu)}, not ${f??n.url}`);let S=r/1e3;if(typeof c.iat!="number"||Math.abs(c.iat-S)>ge)return o("it was not made within a minute of now");let Ce=W(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t)));if(c.ath!==Ce)return o("it is not for this token (ath)");if(typeof c.jti!="string"||c.jti===""||c.jti.length>256)return o("it has no jti (or one longer than 256)");let Me=W(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(c.jti)));return{jkt:e,jti:Me,until:(c.iat+ge+ze)*1e3+1}}var p=class extends Error{reason;constructor(e,n){super(n),this.name="TokenError",this.reason=e}},k=class extends Error{constructor(e,n){super(e,n),this.name="AuthUnavailable"}},Ze=new Set(["invalid_api_key","missing_api_key","secret_key_in_browser"]);function Qe(t){return async e=>{let n=v({baseUrl:t.url,credentials:{secretKey:t.secretKey,accessToken:()=>e},fetch:t.fetch});try{return await n.send({op:"SessionStanding",method:"GET",path:"/auth/session/standing",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"}}),!0}catch(r){if(r instanceof P&&r.status===401&&!Ze.has(r.code))return!1;throw new k("a session's standing could not be told",{cause:r})}}}var H={ES256:{kty:"EC",import:{name:"ECDSA",namedCurve:"P-256"},verify:{name:"ECDSA",hash:"SHA-256"}},PS256:{kty:"RSA",import:{name:"RSA-PSS",hash:"SHA-256"},verify:{name:"RSA-PSS",saltLength:32}}},ve=60,et=16*1024,tt=10*6e4,nt=5e4,Ee=t=>typeof t=="string"&&Object.hasOwn(H,t),j=class{issuer;projectId;fetchImpl;now;maxKeyAgeMs;refetchIntervalMs;fetchTimeoutMs;standing;standingTtlMs;standingStaleMs;standings=new Map;asking=new Map;keys=new Map;keysUntil=0;lastFetch=Number.NEGATIVE_INFINITY;lastFailure=void 0;inflight=null;seenProofs=new x;constructor(e){let n=new URL(e.issuer);if(n.origin!==e.issuer.replace(/\/$/,""))throw new TypeError(`issuer is the project's origin (https://<ref>.<domain>), not ${e.issuer}`);if(typeof e.projectId!="string"||e.projectId==="")throw new TypeError("projectId is the project id the tokens carry");if(this.issuer=n.origin,this.projectId=e.projectId,this.fetchImpl=e.fetch??globalThis.fetch,this.now=e.now??Date.now,this.maxKeyAgeMs=e.maxKeyAgeMs??60*6e4,this.refetchIntervalMs=e.refetchIntervalMs??3e4,this.fetchTimeoutMs=e.fetchTimeoutMs??5e3,typeof e.standing!="function")throw new TypeError("standing is how the verifier asks whether a token's session stands");this.standing=e.standing,this.standingTtlMs=e.standingTtlMs??1e3,this.standingStaleMs=e.standingStaleMs??15e3}async verify(e,n){if(typeof e!="string"||e.length===0||e.length>et)throw new p("malformed","the token is not a JWT");let r=e.split(".");if(r.length!==3)throw new p("malformed","the token is not a JWS of three parts");let o=xe(r[0]),i=xe(r[1]);if(!o||!i)throw new p("malformed","the token header or claims are not base64url JSON");let s=o.alg;if(!Ee(s))throw new p("algorithm",`the token is signed with ${String(s)}; only ES256 and PS256 are taken`);let l=o.kid;if(typeof l!="string"||l==="")throw new p("malformed","the token header names no kid");let c=await this.key(l);if(!c)throw new p("unknown_key",`no key ${l} in the project's key set`);if(c.alg!==s)throw new p("algorithm",`key ${l} is ${c.alg}, the token says ${s}`);let a=_e(r[2]);if(!a)throw new p("malformed","the signature is not base64url");let d=new TextEncoder().encode(`${r[0]}.${r[1]}`);if(!await crypto.subtle.verify(H[c.alg].verify,c.key,a,d).catch(()=>!1))throw new p("signature","the signature does not verify");let g=this.check(i),h=i.cnf,f;if(h!==void 0){if(!n)throw new p("bound","the token is bound to a key (DPoP): it comes with the DPoP scheme and a proof, not as a Bearer");if(typeof h!="object"||h===null||typeof h.jkt!="string"||h.jkt==="")throw new p("bound","the token is bound to a key it does not name (cnf.jkt)");f=await Se(e,h.jkt,n,this.now())}else if(n)throw new p("not_bound","the DPoP scheme came with a token bound to no key");if(!await this.stands(e,g.sessionId))throw new p("session_ended","the token's session has ended (signed out, revoked, or its user banned)");return f&&this.seenProofs.spend(f,this.now()),g}async verifyRequest(e){let n=e.headers instanceof Headers?e.headers:ot(e.headers),r=n.get("authorization")??"";if(r==="")return null;let o=/^(bearer|dpop)\s+(\S+)$/i.exec(r);if(!o)throw new p("malformed","the Authorization header is not a Bearer or DPoP token");let i=o[1].toLowerCase()==="dpop",s=new URL(e.url,`http://${n.get("host")??"localhost"}`);return this.verify(o[2],i?{proof:n.get("dpop"),method:e.method,url:Te(n,s)}:void 0)}async stands(e,n){let r=this.now(),o=this.standings.get(n);if(o&&r<o.until)return o.live;let i=this.asking.get(n);i||(i=this.standing(e,n).finally(()=>this.asking.delete(n)),this.asking.set(n,i));let s;try{s=await i}catch(c){let a=this.standings.get(n),d=this.now();if(a&&d<a.at+this.standingStaleMs)return a.until=Math.min(d+this.standingTtlMs,a.at+this.standingStaleMs),a.live;throw new k("a session's standing cannot be read now",{cause:c})}let l=this.now();return this.standings.delete(n),this.standings.set(n,{live:s,at:l,until:l+this.standingTtlMs}),this.standings.size>nt&&this.standings.delete(this.standings.keys().next().value),s}check(e){if(e.iss!==this.issuer)throw new p("issuer",`the token was issued by ${String(e.iss)}, not this project`);if(!(Array.isArray(e.aud)?e.aud:[e.aud]).includes(this.issuer))throw new p("audience","the token is not meant for this project");if(e.project_id!==this.projectId)throw new p("project","the token names another project");let r=this.now()/1e3;if(typeof e.exp!="number"||e.exp+ve<=r)throw new p("expired","the token has expired");if(e.nbf!==void 0&&(typeof e.nbf!="number"||e.nbf-ve>r))throw new p("not_yet_valid","the token is not valid yet");if(typeof e.sub!="string"||e.sub===""||typeof e.auth_time!="number")throw new p("not_a_user","the token is not a user's");if(typeof e.session_id!="string"||e.session_id==="")throw new p("not_a_session","the token is no session's");let o=e.custom_claims;if(o!==void 0&&(typeof o!="object"||o===null||o.type!==void 0))throw new p("not_a_session","the token is a custom one (an exchange or an approval), not a session's");return{id:e.sub,email:typeof e.email=="string"?e.email:null,emailVerified:e.email_verified===!0,role:typeof e.role=="string"?e.role:null,sessionId:typeof e.session_id=="string"?e.session_id:null,claims:Object.freeze({...e})}}async key(e){let n=this.now();if(n>=this.keysUntil){let o=this.keys.size>0&&n<this.keysUntil+tt;if(this.lastFailure!==void 0&&n-this.lastFetch<this.refetchIntervalMs){if(!o)throw new k("the project's key set cannot be read now",{cause:this.lastFailure})}else try{await this.refresh()}catch(i){if(!o)throw i}}let r=this.keys.get(e);return!r&&n-this.lastFetch>=this.refetchIntervalMs&&(await this.refresh(),r=this.keys.get(e)),r}refresh(){if(this.inflight)return this.inflight;let e=this.load().finally(()=>{this.inflight=null});return this.inflight=e,e}async load(){this.lastFetch=this.now();let e,n;try{if(n=await this.fetchImpl(`${this.issuer}/.well-known/jwks.json`,{redirect:"error",headers:{accept:"application/json"},signal:AbortSignal.timeout(this.fetchTimeoutMs)}),!n.ok)throw new Error(`the project's key set answered ${n.status}`);e=await n.json()}catch(i){throw this.lastFailure=i,new k("the project's key set cannot be read now",{cause:i})}this.lastFailure=void 0;let r=new Map;for(let i of Array.isArray(e.keys)?e.keys:[]){let s=i.alg;if(typeof i.kid!="string"||!Ee(s))continue;let l=H[s];if(i.kty!==l.kty||i.use!==void 0&&i.use!=="sig")continue;let{d:c,...a}=i;try{r.set(i.kid,{alg:s,key:await crypto.subtle.importKey("jwk",a,l.import,!1,["verify"])})}catch{}}this.keys=r;let o=it(n.headers.get("cache-control"))??this.maxKeyAgeMs;this.keysUntil=this.now()+Math.min(Math.max(o,this.refetchIntervalMs),this.maxKeyAgeMs)}};function Te(t,e){let n=t.get("x-forwarded-proto")?.split(",")[0]?.trim().toLowerCase(),r=n==="https"||n==="http"?n:e.protocol.slice(0,-1),o=t.get("host")??e.host;return rt.test(o)?`${r}://${o}${e.pathname}`:""}var rt=/^(?:[a-z0-9-]+(?:\.[a-z0-9-]+)*|\[[0-9a-f:.]+\])(?::[0-9]{1,5})?$/i;function ot(t){let e=new Headers;for(let[n,r]of Object.entries(t))if(r!==void 0)for(let o of Array.isArray(r)?r:[r])e.append(n,o);return e}function it(t){let e=/(?:^|,)\s*max-age=(\d+)/i.exec(t??"");return e?Number(e[1])*1e3:void 0}function _e(t){if(!/^[A-Za-z0-9_-]*$/.test(t)||t.length%4===1)return null;let e=atob(t.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(t.length/4)*4,"=")),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}function xe(t){let e=_e(t);if(!e)return null;try{let n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}catch{return null}}function st(t,e,n=Date.now()){let r=Object.hasOwn(t.entitlements,e)?t.entitlements[e]:void 0;return r?.active?r.expires_at===null?!0:Date.parse(r.expires_at)>(typeof n=="number"?n:n.getTime()):!1}var T=class extends Error{receipt;constructor(e){super(`the reservation ${JSON.stringify(e.idempotency_key)} is ${e.status} already: its job is not run again (a new one is a new Idempotency-Key)`),this.name="ReservationSettled",this.receipt=e}};async function at(t,e,n,r){let{idempotencyKey:o,amount:i,ttlSeconds:s,metadata:l}=n;if(typeof o!="string"||o==="")throw new TypeError("idempotencyKey names the reservation for good: a retry with it is the same hold, never a second");let c={amount:i,...n.credits!==void 0?{credits:n.credits}:{limit:n.limit},...s!==void 0?{ttl_seconds:s}:{},...l!==void 0?{metadata:l}:{}},a=(await t.iap.holdSpend({path:{customer_id:e},headers:{"Idempotency-Key":o},body:c})).data;if(a.status!=="held")throw new T(a);let d={customer_id:a.customer,spend_id:a.id},y;try{y=await r(a)}catch(g){throw await t.iap.releaseSpend({path:d}).catch(()=>{}),g}return await t.iap.commitSpend({path:d}),y}var ct=new Set(["provider_unavailable","authentication_required","three_ds_failed"]);function lt(t){return t!==void 0&&ct.has(t)}function dt(t,e){return{[Pe]:!0,commitAmount:t,value:e}}var Pe=Symbol("palbase.payments.settleWalletHold");function pt(t){return typeof t=="object"&&t!==null&&Pe in t}var _=class extends Error{hold;constructor(e){super(`wallet hold ${JSON.stringify(e.id)} is already ${e.status}: the work is not run again (use a new Idempotency-Key for a new hold)`),this.name="WalletHoldSettled",this.hold=e}};async function ut(t,e,n){let{idempotencyKey:r,walletKey:o,amount:i,ttlSeconds:s,reference:l,metadata:c}=e;if(typeof r!="string"||r.trim()==="")throw new TypeError("idempotencyKey is required for withWalletHold so retries never reserve funds twice");if(!Number.isInteger(i)||i<=0)throw new TypeError("amount must be a positive integer in minor units");let a={wallet_key:o,amount:i,...e.customerId!==void 0?{customer_id:e.customerId}:{spend_token:e.spendToken},...s!==void 0?{ttl_seconds:s}:{},...l!==void 0?{reference:l}:{},...c!==void 0?{metadata:c}:{}},d=(await t.payments.createWalletHold({headers:{"Idempotency-Key":r},body:a})).data;if(d.status!=="held")throw new _(d);let y;try{y=await n(d)}catch(g){throw await t.payments.releaseWalletHold({path:{hold_id:d.id}}).catch(()=>{}),g}return pt(y)?(y.commitAmount<=0?await t.payments.releaseWalletHold({path:{hold_id:d.id}}):await t.payments.commitWalletHold({path:{hold_id:d.id},body:{amount:y.commitAmount}}),y.value):(await t.payments.commitWalletHold({path:{hold_id:d.id}}),y)}function yt(t){return t.type.startsWith("payments.")}function ht(t){return t.type.startsWith("commerce.")}function mt(t){return t.type.startsWith("promotions.")}var ft=300,gt=/^[0-9]{1,12}$/;function wt(t){return typeof t=="string"?new TextEncoder().encode(t):t instanceof ArrayBuffer?new Uint8Array(t):t}function kt(t){if(t.startsWith("whsec_")){let e=t.slice(6);try{let n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o++)r[o]=n.charCodeAt(o);return r}catch{}}return new TextEncoder().encode(t)}function bt(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function St(t){try{let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}catch{return null}}async function Re(t){if(typeof t.secret!="string"||t.secret==="")throw new TypeError("secret is the commerce hook signing secret (whsec_\u2026)");let e=t.webhookId?.trim()??"",n=t.webhookTimestamp?.trim()??"",r=t.webhookSignature?.trim()??"";if(!e||!n||!r)throw new u("missing_signature","webhook-id, webhook-timestamp, and webhook-signature headers are required");if(!gt.test(n))throw new u("malformed_signature","webhook-timestamp must be unix seconds");let o=t.toleranceSeconds??ft,i=Math.floor((t.now?.()??Date.now())/1e3);if(Math.abs(i-Number(n))>o)throw new u("stale_timestamp",`webhook-timestamp ${n} is outside tolerance (${o}s)`);let s=wt(t.body),l=new TextEncoder().encode(`${e}.${n}.`),c=new Uint8Array(l.length+s.length);c.set(l,0),c.set(s,l.length);let a=kt(t.secret),d=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),y=await crypto.subtle.importKey("raw",d,{name:"HMAC",hash:"SHA-256"},!1,["sign"]),g=new Uint8Array(await crypto.subtle.sign("HMAC",y,c)),h=!1;for(let f of r.split(/\s+/)){if(!f.startsWith("v1,"))continue;let S=St(f.slice(3));if(S&&bt(g,S)){h=!0;break}}if(!h)throw new u("signature_mismatch","no v1 signature in webhook-signature matches the payload")}function vt(t){return async e=>{let n=new Uint8Array(await e.arrayBuffer()),r=e.headers.get("webhook-id")??"";try{await Re({secret:t.secret,webhookId:r,webhookTimestamp:e.headers.get("webhook-timestamp"),webhookSignature:e.headers.get("webhook-signature"),body:n,toleranceSeconds:t.toleranceSeconds,now:t.now})}catch(s){let l=s instanceof u?s.code:"signature_mismatch",c=s instanceof Error?s.message:"invalid hook signature";return new Response(JSON.stringify({error:l,error_description:c}),{status:401,headers:{"content-type":"application/json"}})}let o;try{o=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n))}catch{return new Response(JSON.stringify({error:"invalid_body",error_description:"hook body is not valid JSON"}),{status:400,headers:{"content-type":"application/json"}})}let i=await t.handle({hookPoint:e.headers.get("x-palbase-hook-point")??"",webhookId:r,payload:o,request:e});return new Response(JSON.stringify(i),{status:200,headers:{"content-type":"application/json"}})}}function Et(t){return t.type.startsWith("campaigns.")}function xt(t){return t.type.startsWith("journey.")}async function*Tt(t){let e,n=new Set;do{let r=(await t(e)).data;yield r;let o=r.next_cursor??void 0;if(o!==void 0&&n.has(o))throw new Error(`the listing answered a cursor it had answered before (${o})`);o!==void 0&&n.add(o),e=o}while(e)}var _t=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,Pt=/^(PALBASE_|NODE_|BUN_|NPM_|LD_|DYLD_|GIT_|SSH_)|^(PATH|HOME|SHELL|USER|TMPDIR|TMP|TEMP|PWD|IFS|ENV|BASH_ENV|SSL_CERT_FILE|SSL_CERT_DIR|CURL_CA_BUNDLE|REQUESTS_CA_BUNDLE|NO_PROXY|ALL_PROXY|HTTP_PROXY|HTTPS_PROXY|PG\w*)$/i;function Ae(t){return!_t.test(t)||Pt.test(t)||/_PROXY$/i.test(t)}var Rt=/^(PORT|PALBASE_(URL|PROJECT_ID|MACHINE|REPLICAS|SECRET_KEY|WEBHOOK_SECRET|PLATFORM_SECRET|CONTRACT_OUT|CONTRACT_ENTRY|WEB_ORIGINS|SECRETS|DB_[A-Z0-9_]+))$/;function At(t){return Rt.test(t)}async function Ct(t={}){let e=t.env??process.env,n=e.PALBASE_SECRETS;if(n===void 0||n==="")return;if(n==="production")throw new TypeError("PALBASE_SECRETS=production: a production secret's value is never read back \u2014 only the machines that start with it are given it. Run here with PALBASE_SECRETS=development (palbase env:pull writes it), and set a value for this computer with palbase secrets:set NAME --dev");if(n!=="development")throw new TypeError(`PALBASE_SECRETS is development, not ${n}`);let r=t.url??e.PALBASE_URL??"",o=t.secretKey??e.PALBASE_SECRET_KEY??"";if(r===""||o==="")throw new TypeError("PALBASE_SECRETS reads the project's Secrets with PALBASE_URL and PALBASE_SECRET_KEY: give both (palbase env:pull writes them)");let i=O({url:new URL(r).origin,secretKey:o,fetch:t.fetch}),{data:s}=await i.secrets.getEnvironmentValues({path:{environment:n}}),l=[],c=[],a=[];for(let[d,y]of Object.entries(s.values)){if(Ae(d)){a.push(d);continue}if(e[d]!==void 0&&e[d]!==""){c.push(d);continue}e[d]=y,l.push(d)}return{set:n,loaded:l.sort(),kept:c.sort(),refused:a.sort()}}export{m as a,b,E as c,O as d,u as e,ye as f,he as g,me as h,Ne as i,p as j,k,Qe as l,j as m,Te as n,st as o,T as p,at as q,lt as r,dt as s,_ as t,ut as u,yt as v,ht as w,mt as x,Re as y,vt as z,Et as A,xt as B,Tt as C,Ae as D,At as E,Ct as F};
@@ -1,5 +1,5 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- import{a as w,d as He,e as Ke,f as Je}from"./D5I74USX.js";import{a as ze}from"./JXIKBG4D.js";import{a as Ve}from"./XUYC354U.js";import{a as Ge,b as Le,c as Fe}from"./3MF6NROQ.js";import{b as I,d as Be}from"./LDFOUUBT.js";async function*Qe(e,t={}){let i=e.getReader(),s=new TextDecoder,a="",d="",c=[],o,r=()=>{i.cancel().catch(()=>{})};t.signal?.addEventListener("abort",r,{once:!0});try{if(t.signal?.aborted)return;for(;;){let{done:n,value:l}=await i.read();if(n||t.signal?.aborted)return;t.onBytes?.(),a+=s.decode(l,{stream:!0});for(let u=a.indexOf(`
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ import{a as w,d as He,e as Ke,f as Je}from"./VEL7X2G3.js";import{a as ze}from"./25HECIZY.js";import{a as Ve}from"./SMECWMF7.js";import{a as Ge,b as Le,c as Fe}from"./YMIK6HLK.js";import{b as I,d as Be}from"./PEQZDT6P.js";async function*Qe(e,t={}){let i=e.getReader(),s=new TextDecoder,a="",d="",c=[],o,r=()=>{i.cancel().catch(()=>{})};t.signal?.addEventListener("abort",r,{once:!0});try{if(t.signal?.aborted)return;for(;;){let{done:n,value:l}=await i.read();if(n||t.signal?.aborted)return;t.onBytes?.(),a+=s.decode(l,{stream:!0});for(let u=a.indexOf(`
3
3
  `);u>=0;u=a.indexOf(`
4
4
  `)){let f=a.slice(0,a[u-1]==="\r"?u-1:u);a=a.slice(u+1),f===""?(d!==""&&(yield o===void 0?{event:d,data:c.join(`
5
5
  `)}:{event:d,data:c.join(`
@@ -0,0 +1,19 @@
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ import{p as R,t as Y,u as k}from"./4XSSQAES.js";var $=40,z=`
3
+ :host{display:contents}
4
+ .pm-modal,.pm-full{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;border:0;background:transparent;color:inherit;overflow:hidden;display:flex;flex-direction:column}
5
+ .pm-modal::backdrop,.pm-full::backdrop{background:transparent}
6
+ .pm-modal{align-items:center;justify-content:center;box-sizing:border-box;padding:max(16px,env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) max(16px,env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px))}
7
+ .pm-full{padding:0}
8
+ .pm-panel{display:flex;flex-direction:column;min-height:0;width:100%;max-height:100%;outline:none}
9
+ .pm-full>.pm-panel{flex:1 1 auto;height:100%}
10
+ .pm-banner{position:fixed;z-index:2147483000;left:50%;transform:translateX(-50%);width:min(640px,calc(100% - 16px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)));display:flex;flex-direction:column;touch-action:none;outline:none}
11
+ .pm-banner.top{top:calc(8px + env(safe-area-inset-top,0px))}
12
+ .pm-banner.bottom{bottom:calc(8px + env(safe-area-inset-bottom,0px))}
13
+ .pm-slide-in{position:fixed;z-index:2147483000;right:calc(16px + env(safe-area-inset-right,0px));width:min(380px,calc(100% - 32px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)));display:flex;flex-direction:column;touch-action:none;outline:none}
14
+ .pm-slide-in.top{top:calc(16px + env(safe-area-inset-top,0px))}
15
+ .pm-slide-in.bottom{bottom:calc(16px + env(safe-area-inset-bottom,0px))}
16
+ .pm-toast{position:fixed;z-index:2147483000;left:50%;transform:translateX(-50%);width:min(420px,calc(100% - 24px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)));display:flex;flex-direction:column;touch-action:none;outline:none}
17
+ .pm-toast.top{top:calc(12px + env(safe-area-inset-top,0px))}
18
+ .pm-toast.bottom{bottom:calc(12px + env(safe-area-inset-bottom,0px))}
19
+ `;function V(l,x={},H={}){let y=H.root??globalThis.document?.body;if(!y)throw new Error("presentMessage needs a page");let p=y.ownerDocument,A=p.defaultView,t=R(l.definition,{locale:l.locale,appearance:l.appearance,platform:l.platform??"web",variables:l.variables??{}}).presentation;if(t.type==="card")throw new Error("a card is drawn in its inbox (renderMessage), not shown over the page");let m=p.createElement("div");m.setAttribute("data-palbase-message-layer","");let h=m.attachShadow({mode:"open"});k(p,h,z);let r=t.type==="banner"||t.type==="slide_in"||t.type==="toast",D=t.type==="banner"||t.type==="toast",e=p.createElement(r?"div":"dialog"),f=r?e:p.createElement("div");if(r){let n=t.type==="slide_in"?"pm-slide-in":t.type==="toast"?"pm-toast":"pm-banner";e.className=`${n} ${t.position}`,e.setAttribute("role",t.type==="toast"?"status":"dialog"),e.setAttribute("aria-modal","false")}else e.className=t.type==="modal"?"pm-modal":"pm-full",t.type==="modal"&&(e.style.background=t.backdrop),f.className="pm-panel",e.append(f);let u=p.createElement("div");u.style.cssText="display:flex;flex-direction:column;min-height:0;flex:1 1 auto",f.append(u),h.append(e),y.append(m);let g=t.type!=="fullscreen"&&t.dismissible,v=()=>l.reduceMotion??A?.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,b=!1,w="button",M,S=new Promise(n=>M=n),E=[],L=Y(u,l,{...x,onAction(n){w=n.type==="close"?"button":"action",x.onAction?.(n)},onClose:()=>c(w)}),T=u.querySelector("[data-palbase-message]")?.shadowRoot?.querySelector("h1,h2,h3,.pw-text")?.textContent?.trim();if(T&&e.setAttribute("aria-label",T),r){let n=t.auto_dismiss_seconds;if(n!==void 0){let a=n*1e3,o=Date.now(),d,s=0,i=()=>{o=Date.now(),d=setTimeout(()=>c("timeout"),a)},C=()=>{s++===0&&(clearTimeout(d),a-=Date.now()-o)},P=()=>{--s===0&&i()};e.addEventListener("pointerenter",C),e.addEventListener("pointerleave",P),e.addEventListener("focusin",C),e.addEventListener("focusout",P),i(),E.push(()=>clearTimeout(d))}if(g){let a=t.position==="top",o=null;e.addEventListener("pointerdown",s=>{o=s.clientY}),e.addEventListener("pointermove",s=>{if(o===null)return;let i=Math.max(0,a?o-s.clientY:s.clientY-o);e.style.transform=D?`translateX(-50%) translateY(${a?-i:i}px)`:`translateY(${a?-i:i}px)`,e.style.opacity=String(Math.max(.3,1-i/120))});let d=s=>{if(o===null)return;let i=a?o-s.clientY:s.clientY-o;o=null,i>$?c("swipe"):(e.style.transform="",e.style.opacity="")};e.addEventListener("pointerup",d),e.addEventListener("pointercancel",d)}}else{let n=e;n.addEventListener("cancel",a=>{a.preventDefault(),g&&c("escape")}),t.type==="modal"&&n.addEventListener("click",a=>{a.target===n&&g&&c("outside")}),n.showModal()}X();function X(){if(v()||typeof e.animate!="function")return;let n=r?t.position==="top"?-24:24:0,a=t.type==="modal"?[{opacity:0,transform:"scale(0.96)"},{opacity:1,transform:"none"}]:t.type==="slide_in"?[{opacity:0,transform:`translateX(24px) translateY(${n}px)`},{opacity:1,transform:"none"}]:r?[{opacity:0,transform:`translateX(-50%) translateY(${n}px)`},{opacity:1,transform:"translateX(-50%)"}]:[{opacity:0,transform:"translateY(24px)"},{opacity:1,transform:"none"}];(r?e:f).animate(a,{duration:220,easing:"cubic-bezier(0.16, 1, 0.3, 1)"}),t.type==="modal"&&e.animate([{opacity:0},{opacity:1}],{duration:180,easing:"ease-out"})}function c(n){if(b)return;b=!0,E.forEach(o=>o());let a=()=>{r||e.close(),L.destroy(),m.remove()};v()||typeof e.animate!="function"?a():e.animate([{opacity:Number(e.style.opacity||1)},{opacity:0}],{duration:160,easing:"ease-in",fill:"forwards"}).finished.then(a,a),M(n),x.onClose?.(n)}return{view:L,closed:S,close:()=>c("app")}}export{V as a};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- import{b}from"./DE7BWXBF.js";import{a as k,b as A}from"./WWXBXZUO.js";import{randomBytes as _}from"node:crypto";async function N(){let n={keys:[{id:"k1",key:_(32).toString("base64url"),activates_at:new Date(0).toISOString()}],lookup:_(32).toString("base64url")},e=new b({fetch:async()=>n});return await e.load(),e.close(),e}var f=class extends Error{status;error;data;body;constructor(e,a,l,d){let u=d!==null&&typeof d=="object"?d:{},o=u.error??String(l);super(`${e} ${a} \u2192 ${l} ${o}${u.error_description?`: ${u.error_description}`:""}`),this.name="TestApiError",this.status=l,this.error=o,this.data=u.data,this.body=u}};function x(n,e){if(!n)throw new Error(`${e} is not set: the test client has nowhere to send its requests \u2014 \`palbase test\` sets it, as the platform's test run does`);return n}function B(n){let e=n.split(".")[1];if(!e)return null;try{let a=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof a.exp=="number"?a.exp-Math.floor(Date.now()/1e3):null}catch{return null}}function L(n){try{return JSON.parse(n)}catch{return n}}function $(n){let e=x(n.baseUrl,"PALBASE_TEST_BASE_URL").replace(/\/+$/,""),a=n.apiKey||void 0,l=(n.authUrl??e).replace(/\/+$/,""),d=n.fetch??fetch,u=[],o=null;async function c(r,t,s,i,T={},O=!0){let g={...T.headers},m=h=>Object.keys(g).some(R=>R.toLowerCase()===h);a!==void 0&&!m("apikey")&&(g.apikey=a),o&&O&&!m("authorization")&&(g.authorization=`Bearer ${o}`),i!==void 0&&!m("content-type")&&(g["content-type"]="application/json");let I=Date.now(),p=await d(`${r}${s}`,{method:t,headers:g,body:i===void 0?void 0:JSON.stringify(i)}),E=await p.text(),S=E?L(E):void 0;if(u.push({method:t,path:s,status:p.status,ms:Date.now()-I}),!p.ok){let h=p.status===401&&o?B(o):null;throw h!==null&&h<=0?new f(t,s,p.status,{error:"access_token_expired",error_description:`this run's access token expired ${-h}s ago: a test user's token is made for one run \u2014 run the tests again (\`palbase test\` makes new ones)`}):new f(t,s,p.status,S)}return S}let y={requests:u,get:(r,t)=>c(e,"GET",r,void 0,t),post:(r,t,s)=>c(e,"POST",r,t,s),patch:(r,t,s)=>c(e,"PATCH",r,t,s),put:(r,t,s)=>c(e,"PUT",r,t,s),delete:(r,t)=>c(e,"DELETE",r,void 0,t),query:(r,t,s)=>c(e,"QUERY",r,t,s),async signInAs(r){let t=n.identities?.[r];if(!t){let s=Object.keys(n.identities??{});throw s.length===0?new Error(`no test user named ${JSON.stringify(r)}: this run has no test users \u2014 none were named (the machine's test users, or \`palbase test --users <names>\`), or they could not be made: the run's log says which`):new Error(`no test user named ${JSON.stringify(r)} \u2014 this run has: ${s.join(", ")}. A run makes the test users its machine names (palbase machines:update <machine> --test-users <names>) or \`palbase test --users <names>\` names`)}return t.accessToken?(o=t.accessToken,{id:t.id??"",email:t.email}):y.signIn(t)},async signIn(r){if(a===void 0)throw new Error("PALBASE_TEST_API_KEY is not set: a sign-in at the project's auth is made with a publishable key of the project's (palbase apps:sdkconfig shows one) \u2014 a run's test users come with their tokens: api.signInAs(name)");let t=i=>c(l,"POST","/auth/login",r,i?{headers:i}:{},!1),s;try{s=await t()}catch(i){let T=i instanceof f&&i.status===403?k(i.body):null;if(!T)throw i;s=await t(await A(T))}return o=s.access_token,s.user??{id:""}},async signOut(){await c(l,"POST","/auth/logout",void 0),o=null},asAnonymous(){o=null}};return y}function P(n){if(!n)return{};let e;try{e=JSON.parse(n)}catch{throw new Error("PALBASE_TEST_IDENTITIES is set but is not JSON: the run that started these tests handed over a broken set of test users")}if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("PALBASE_TEST_IDENTITIES is not an object of test users by name");return e}var j={get stack(){return!!process.env.PALBASE_TEST_BASE_URL},minted(n){return Object.prototype.hasOwnProperty.call(P(process.env.PALBASE_TEST_IDENTITIES),n)}},w,q=new Proxy({},{get(n,e){return w??=$({baseUrl:process.env.PALBASE_TEST_BASE_URL??"",apiKey:process.env.PALBASE_TEST_API_KEY??"",authUrl:process.env.PALBASE_TEST_AUTH_URL,identities:P(process.env.PALBASE_TEST_IDENTITIES)}),Reflect.get(w,e,w)}});export{N as a,f as b,$ as c,j as d,q as e};
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ import{b}from"./5OOA4R4H.js";import{a as k,b as A}from"./J7ZNBBRN.js";import{randomBytes as _}from"node:crypto";async function N(){let n={keys:[{id:"k1",key:_(32).toString("base64url"),activates_at:new Date(0).toISOString()}],lookup:_(32).toString("base64url")},e=new b({fetch:async()=>n});return await e.load(),e.close(),e}var f=class extends Error{status;error;data;body;constructor(e,a,l,d){let u=d!==null&&typeof d=="object"?d:{},o=u.error??String(l);super(`${e} ${a} \u2192 ${l} ${o}${u.error_description?`: ${u.error_description}`:""}`),this.name="TestApiError",this.status=l,this.error=o,this.data=u.data,this.body=u}};function x(n,e){if(!n)throw new Error(`${e} is not set: the test client has nowhere to send its requests \u2014 \`palbase test\` sets it, as the platform's test run does`);return n}function B(n){let e=n.split(".")[1];if(!e)return null;try{let a=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof a.exp=="number"?a.exp-Math.floor(Date.now()/1e3):null}catch{return null}}function L(n){try{return JSON.parse(n)}catch{return n}}function $(n){let e=x(n.baseUrl,"PALBASE_TEST_BASE_URL").replace(/\/+$/,""),a=n.apiKey||void 0,l=(n.authUrl??e).replace(/\/+$/,""),d=n.fetch??fetch,u=[],o=null;async function c(r,t,s,i,T={},O=!0){let g={...T.headers},m=h=>Object.keys(g).some(R=>R.toLowerCase()===h);a!==void 0&&!m("apikey")&&(g.apikey=a),o&&O&&!m("authorization")&&(g.authorization=`Bearer ${o}`),i!==void 0&&!m("content-type")&&(g["content-type"]="application/json");let I=Date.now(),p=await d(`${r}${s}`,{method:t,headers:g,body:i===void 0?void 0:JSON.stringify(i)}),E=await p.text(),S=E?L(E):void 0;if(u.push({method:t,path:s,status:p.status,ms:Date.now()-I}),!p.ok){let h=p.status===401&&o?B(o):null;throw h!==null&&h<=0?new f(t,s,p.status,{error:"access_token_expired",error_description:`this run's access token expired ${-h}s ago: a test user's token is made for one run \u2014 run the tests again (\`palbase test\` makes new ones)`}):new f(t,s,p.status,S)}return S}let y={requests:u,get:(r,t)=>c(e,"GET",r,void 0,t),post:(r,t,s)=>c(e,"POST",r,t,s),patch:(r,t,s)=>c(e,"PATCH",r,t,s),put:(r,t,s)=>c(e,"PUT",r,t,s),delete:(r,t)=>c(e,"DELETE",r,void 0,t),query:(r,t,s)=>c(e,"QUERY",r,t,s),async signInAs(r){let t=n.identities?.[r];if(!t){let s=Object.keys(n.identities??{});throw s.length===0?new Error(`no test user named ${JSON.stringify(r)}: this run has no test users \u2014 none were named (the machine's test users, or \`palbase test --users <names>\`), or they could not be made: the run's log says which`):new Error(`no test user named ${JSON.stringify(r)} \u2014 this run has: ${s.join(", ")}. A run makes the test users its machine names (palbase machines:update <machine> --test-users <names>) or \`palbase test --users <names>\` names`)}return t.accessToken?(o=t.accessToken,{id:t.id??"",email:t.email}):y.signIn(t)},async signIn(r){if(a===void 0)throw new Error("PALBASE_TEST_API_KEY is not set: a sign-in at the project's auth is made with a publishable key of the project's (palbase apps:sdkconfig shows one) \u2014 a run's test users come with their tokens: api.signInAs(name)");let t=i=>c(l,"POST","/auth/login",r,i?{headers:i}:{},!1),s;try{s=await t()}catch(i){let T=i instanceof f&&i.status===403?k(i.body):null;if(!T)throw i;s=await t(await A(T))}return o=s.access_token,s.user??{id:""}},async signOut(){await c(l,"POST","/auth/logout",void 0),o=null},asAnonymous(){o=null}};return y}function P(n){if(!n)return{};let e;try{e=JSON.parse(n)}catch{throw new Error("PALBASE_TEST_IDENTITIES is set but is not JSON: the run that started these tests handed over a broken set of test users")}if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("PALBASE_TEST_IDENTITIES is not an object of test users by name");return e}var j={get stack(){return!!process.env.PALBASE_TEST_BASE_URL},minted(n){return Object.prototype.hasOwnProperty.call(P(process.env.PALBASE_TEST_IDENTITIES),n)}},w,q=new Proxy({},{get(n,e){return w??=$({baseUrl:process.env.PALBASE_TEST_BASE_URL??"",apiKey:process.env.PALBASE_TEST_API_KEY??"",authUrl:process.env.PALBASE_TEST_AUTH_URL,identities:P(process.env.PALBASE_TEST_IDENTITIES)}),Reflect.get(w,e,w)}});export{N as a,f as b,$ as c,j as d,q as e};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- import{c as O,g as w,l as F,m as _,s as D}from"./MB6ITBD2.js";import{b as h}from"./LDFOUUBT.js";var M=20,R=2048,S=256,z=/^[A-Za-z][A-Za-z0-9_.-]{0,39}$/,m=e=>new h({op:"GetPlacementPaywall",status:0,code:"invalid_attributes",message:e});function j(e){let n='"';for(let t=0;t<e.length;t++){let a=e.charCodeAt(t);a===34?n+='\\"':a===92?n+="\\\\":a>=32&&a<=126?n+=e[t]:n+=`\\u${a.toString(16).padStart(4,"0")}`}return`${n}"`}function T(e){let n=Object.keys(e??{}).sort((i,r)=>i<r?-1:i>r?1:0);if(n.length===0)return;if(n.length>M)throw m(`${n.length} attributes: at most ${M}`);let t=[];for(let i of n){if(!z.test(i))throw m(`the attribute ${JSON.stringify(i)}: a key is a letter, then letters, digits and _ . -, at most 40`);let r=e[i],s;if(typeof r=="string"){if(new TextEncoder().encode(r).length>S)throw m(`the attribute ${JSON.stringify(i)} is over ${S} bytes`);s=j(r)}else if(typeof r=="number"){if(!Number.isFinite(r))throw m(`the attribute ${JSON.stringify(i)} is no number`);s=String(Object.is(r,-0)?0:r)}else if(typeof r=="boolean")s=r?"true":"false";else throw m(`the attribute ${JSON.stringify(i)}: a value is a text, a number or a boolean`);t.push(`"${i}":${s}`)}let a=`{${t.join(",")}}`;if(a.length>R)throw m(`the attributes are ${a.length} bytes: at most ${R}`);return a}function v(e){let n=/^P(\d+)([DWMY])$/.exec(e??"");if(!n)return null;let t=Number(n[1]);if(!Number.isSafeInteger(t)||t<1)return null;switch(n[2]){case"D":return{count:t,unit:"day",months:t*12/365};case"W":return{count:t,unit:"week",months:t*12/52};case"M":return{count:t,unit:"month",months:t};default:return{count:t,unit:"year",months:t*12}}}function E(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function x(e,n,t){let a=e/10**E(n);try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(a)}catch{return`${a.toFixed(E(n))} ${n}`}}function L(e,n){try{let t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"});return e.count>1?t.format(e.count):t.formatToParts(1).filter(i=>i.type==="unit").map(i=>i.value).join("").trim()||t.format(1)}catch{return e.count>1?`${e.count} ${e.unit}s`:e.unit}}var X={en:e=>`${e} free`,tr:e=>`${e} \xFCcretsiz`,de:e=>`${e} kostenlos`,es:e=>`${e} gratis`,it:e=>`${e} gratis`,nl:e=>`${e} gratis`,pt:e=>`${e} gr\xE1tis`,sv:e=>`${e} gratis`,da:e=>`${e} gratis`,nb:e=>`${e} gratis`};function U(e,n){let t;try{t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"}).format(e.count)}catch{t=`${e.count} ${e.unit}${e.count>1?"s":""}`}let a=X[n.split("-")[0].toLowerCase()];return a?a(t):t}function K(e,n){try{return new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:0}).format(e)}catch{return`${Math.round(e*100)}%`}}function I(e,n){let t=new Map,a=new Map;for(let r of e){let s=v(r.period);if(!s)continue;let l=r.price.amount/s.months;t.set(r.key,l),a.set(r.price.currency,Math.max(a.get(r.price.currency)??0,l))}let i={};for(let r of e){let s={product_name:r.productName,price:x(r.price.amount,r.price.currency,n)},l=v(r.period);if(l){s.period=L(l,n),s.price_per_month=x(Math.round(t.get(r.key)),r.price.currency,n);let o=a.get(r.price.currency)??0,u=o>0?Math.floor((1-t.get(r.key)/o)*100)/100:0;u>=.01&&(s.savings=K(u,n))}let f=r.intro?.mode==="free_trial"?v(r.intro.duration):null;f&&(s.trial=U(f,n)),r.offer&&(s.offer_price=x(Math.floor((r.price.amount*(100-r.offer.percentOff)+50)/100),r.price.currency,n)),i[r.key]=s}return i}var V={version:"0.72.0"};var C=`palbase-js/${V.version}`;var b=class{placement;source;definition;assets;offerings;offers;shown;deps;exposed=!1;constructor(n,t,a,i,r,s,l={},f=[]){this.placement=n,this.source=t,this.definition=a,this.assets=l,this.offerings=i,this.offers=f,this.shown=r,this.deps=s}packages(n){return I(q(this.offerings,F(this.definition),n,W(this.definition,this.offers)),n)}render(n,t){let a=t.locale??globalThis.navigator?.language??this.definition.default_locale,i=t.appearance===void 0?H():void 0,r=this.packages(a),s=D(n,{definition:this.definition,locale:a,appearance:t.appearance??(i?.matches?"dark":"light"),platform:"web",packages:r,eligible:Object.entries(r).filter(([,o])=>o.trial).map(([o])=>o),offers:this.offers.filter(o=>o.web).map(o=>o.key),links:t.links,assets:this.assets},{onPurchase:async o=>{try{let u=await this.deps.checkout({product:o.product,plan:o.plan,successUrl:t.successUrl,cancelUrl:t.cancelUrl,...o.offer!==void 0?{offer:o.offer}:{}});t.onCheckout?t.onCheckout(u,o):globalThis.location.assign(u)}catch(u){if(!t.onError)throw u;t.onError(u,o)}},onClose:t.onClose,onLink:t.onLink,labels:t.labels}),l=o=>s.update({appearance:o.matches?"dark":"light"});i?.addEventListener?.("change",l),!this.exposed&&this.shown&&(this.exposed=!0,this.deps.expose(this));let f=s.destroy.bind(s);return s.destroy=()=>{i?.removeEventListener?.("change",l),f()},s}};function H(){try{return globalThis.matchMedia?.("(prefers-color-scheme: dark)")}catch{return}}function J(e,n){if(!e)return;let t=n.split("-")[0];return e[n]?.name??e[t]?.name??Object.values(e).find(a=>a.name)?.name}function q(e,n,t,a=new Map){let i=[];for(let r of n){let[s,l]=r.split("."),f=e.products.find(d=>d.key===s),o=f?.channels.web,u=o?.plans.find(d=>d.key===l);if(!f||!o||!u)continue;let p=a.get(r),g=p?.discount?p.discount.percent:p?.trial?100:void 0;i.push({key:r,productName:J(o.locales,t)??f.key,price:{amount:u.price.amount,currency:u.price.currency},period:u.period,intro:u.intro,...g!==void 0?{offer:{percentOff:g}}:{}})}return i}function W(e,n){let t=new Map;for(let[a,i]of _(e)){let r=n.find(s=>s.key===i);r?.web&&t.set(a,r)}return t}var Y={en:{cta:"Continue",terms:"Terms",privacy:"Privacy"},tr:{cta:"Devam et",terms:"Ko\u015Fullar",privacy:"Gizlilik"},de:{cta:"Weiter",terms:"Bedingungen",privacy:"Datenschutz"},es:{cta:"Continuar",terms:"T\xE9rminos",privacy:"Privacidad"},fr:{cta:"Continuer",terms:"Conditions",privacy:"Confidentialit\xE9"},it:{cta:"Continua",terms:"Termini",privacy:"Privacy"},pt:{cta:"Continuar",terms:"Termos",privacy:"Privacidade"},nl:{cta:"Doorgaan",terms:"Voorwaarden",privacy:"Privacy"},ja:{cta:"\u7D9A\u3051\u308B",terms:"\u5229\u7528\u898F\u7D04",privacy:"\u30D7\u30E9\u30A4\u30D0\u30B7\u30FC"}},N=e=>({type:"button",action:{type:e},content:{type:"text",text:{t:e},size:"caption",color:"muted"}});function G(e){let n=e.products.flatMap(t=>(t.channels.web?.plans??[]).map(a=>({product:t.key,plan:a.key}))).slice(0,6);return n.length===0?null:{schema:2,name:"Default",default_locale:"en",locales:Y,theme:{colors:{light:{background:"#FFFFFF",surface:"#F2F2F7",text:"#111114",muted:"#6B6B70",accent:"#111114",on_accent:"#FFFFFF",stroke:"#E5E5EA"},dark:{background:"#000000",surface:"#1C1C1E",text:"#F5F5F7",muted:"#9A9AA0",accent:"#F5F5F7",on_accent:"#000000",stroke:"#2C2C2E"}},typography:{headline:{size:17,weight:600,text_style:"headline"},caption:{size:13,weight:400,text_style:"footnote"}},radii:{card:14},spacing:{sm:8,md:16,lg:24}},root:{type:"stack",spacing:"md",align:"stretch",style:{padding:"lg"},children:[{type:"stack",axis:"horizontal",children:[{type:"spacer"},{type:"button",action:{type:"close"},content:{type:"icon",name:"close",color:"muted",size:22}}]},{type:"spacer"},{type:"stack",spacing:"sm",align:"stretch",children:n.map(({product:t,plan:a})=>({type:"package",product:t,plan:a,style:{padding:"md",corners:"card",background:"surface",border:{width:1,color:"stroke"}},states:{selected:{border:{width:2,color:"accent"}}},children:[{type:"stack",axis:"horizontal",spacing:"sm",children:[{type:"stack",align:"start",spacing:2,children:[{type:"text",text:"{{product_name}}",size:"headline",align:"start"},{type:"text",text:"{{period}}",size:"caption",color:"muted",align:"start"}]},{type:"spacer"},{type:"text",text:"{{price}}",size:"headline"}]}]}))},{type:"purchase_button",style:{padding:"md",corners:"card",background:"accent"},content:{type:"text",text:{t:"cta"},size:"headline",color:"on_accent"}},{type:"stack",axis:"horizontal",spacing:"md",distribution:"center",children:[N("terms"),N("privacy")]}]}}}function $(){try{return globalThis.localStorage}catch{return}}function Q(e){try{let n=$()?.getItem(e);if(!n)return;let t=JSON.parse(n),a=t?.answer;return typeof a!="object"||a===null||typeof a.paywall_id!="string"||typeof a.version!="number"||typeof a.definition!="object"||a.definition===null||typeof a.offerings!="object"||a.definition.schema!==2?void 0:{etag:typeof t.etag=="string"?t.etag:void 0,answer:a}}catch{return}}function P(e,n){try{n?$()?.setItem(e,JSON.stringify(n)):$()?.removeItem(e)}catch{}}async function de(e,n,t,a,i,r={}){let{signal:s,fetch:l}=r,f=T(r.attributes),o=`palbase.paywall.${n}.${t}`,p={checkout:i,expose:async c=>{if(c.shown)try{let k={paywall_id:c.shown.paywallId,version:c.shown.version,...c.shown.variant!==void 0?{variant:c.shown.variant}:{},...c.shown.ruleId!==void 0?{rule_id:c.shown.ruleId}:{}};await e.recordPaywallExposure({path:{placement:t},headers:{"X-Palbase-Installation":a},body:k})}catch{}}},g=async(c,k)=>new b(t,k,c.definition,c.offerings,{paywallId:c.paywall_id,version:c.version,...c.variant!==void 0?{variant:c.variant}:{},...c.rule_id!==void 0?{ruleId:c.rule_id}:{}},p,await O(c.assets??[],{signal:s,...l?{fetch:l}:{}}),c.offers??[]),d=Q(o),y;try{y=await e.getPlacementPaywall({path:{placement:t},query:{channel:"web"},headers:{"X-Palbase-Paywall-Schema":2,"X-Palbase-Installation":a,"X-Platform":"web","X-Palbase-SDK":C,...r.appVersion?{"X-Palbase-Client-Version":r.appVersion}:{},...r.app?{"X-Palbase-App":r.app}:{},...r.locale?{"Accept-Language":r.locale}:{},...f!==void 0?{"X-Palbase-Attributes":f}:{},...d?.etag?{"If-None-Match":d.etag}:{}},signal:s})}catch(c){if(c instanceof h&&c.status===404||c instanceof h&&c.status===400&&c.code.startsWith("invalid_"))return P(o,void 0),A(e,t,p,s);if(d&&!s?.aborted)return g(d.answer,"cache");throw c}return y.status===200?(P(o,{etag:y.headers.get("etag")??void 0,answer:y.data}),g(y.data,"server")):y.status===304&&d?g(d.answer,"server"):(P(o,void 0),A(e,t,p,s))}async function A(e,n,t,a){let i=(await e.getOfferings({query:{channel:"web"},signal:a})).data,r=G(i);return r?new b(n,"default",r,i,void 0,t):null}export{T as a,v as b,x as c,L as d,I as e,b as f,G as g,de as h};
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ import{c as O,g as w,l as F,m as _,s as D}from"./4XSSQAES.js";import{b as h}from"./PEQZDT6P.js";var M=20,R=2048,S=256,z=/^[A-Za-z][A-Za-z0-9_.-]{0,39}$/,m=e=>new h({op:"GetPlacementPaywall",status:0,code:"invalid_attributes",message:e});function j(e){let n='"';for(let t=0;t<e.length;t++){let a=e.charCodeAt(t);a===34?n+='\\"':a===92?n+="\\\\":a>=32&&a<=126?n+=e[t]:n+=`\\u${a.toString(16).padStart(4,"0")}`}return`${n}"`}function T(e){let n=Object.keys(e??{}).sort((i,r)=>i<r?-1:i>r?1:0);if(n.length===0)return;if(n.length>M)throw m(`${n.length} attributes: at most ${M}`);let t=[];for(let i of n){if(!z.test(i))throw m(`the attribute ${JSON.stringify(i)}: a key is a letter, then letters, digits and _ . -, at most 40`);let r=e[i],s;if(typeof r=="string"){if(new TextEncoder().encode(r).length>S)throw m(`the attribute ${JSON.stringify(i)} is over ${S} bytes`);s=j(r)}else if(typeof r=="number"){if(!Number.isFinite(r))throw m(`the attribute ${JSON.stringify(i)} is no number`);s=String(Object.is(r,-0)?0:r)}else if(typeof r=="boolean")s=r?"true":"false";else throw m(`the attribute ${JSON.stringify(i)}: a value is a text, a number or a boolean`);t.push(`"${i}":${s}`)}let a=`{${t.join(",")}}`;if(a.length>R)throw m(`the attributes are ${a.length} bytes: at most ${R}`);return a}function v(e){let n=/^P(\d+)([DWMY])$/.exec(e??"");if(!n)return null;let t=Number(n[1]);if(!Number.isSafeInteger(t)||t<1)return null;switch(n[2]){case"D":return{count:t,unit:"day",months:t*12/365};case"W":return{count:t,unit:"week",months:t*12/52};case"M":return{count:t,unit:"month",months:t};default:return{count:t,unit:"year",months:t*12}}}function E(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function x(e,n,t){let a=e/10**E(n);try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(a)}catch{return`${a.toFixed(E(n))} ${n}`}}function L(e,n){try{let t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"});return e.count>1?t.format(e.count):t.formatToParts(1).filter(i=>i.type==="unit").map(i=>i.value).join("").trim()||t.format(1)}catch{return e.count>1?`${e.count} ${e.unit}s`:e.unit}}var X={en:e=>`${e} free`,tr:e=>`${e} \xFCcretsiz`,de:e=>`${e} kostenlos`,es:e=>`${e} gratis`,it:e=>`${e} gratis`,nl:e=>`${e} gratis`,pt:e=>`${e} gr\xE1tis`,sv:e=>`${e} gratis`,da:e=>`${e} gratis`,nb:e=>`${e} gratis`};function U(e,n){let t;try{t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"}).format(e.count)}catch{t=`${e.count} ${e.unit}${e.count>1?"s":""}`}let a=X[n.split("-")[0].toLowerCase()];return a?a(t):t}function K(e,n){try{return new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:0}).format(e)}catch{return`${Math.round(e*100)}%`}}function I(e,n){let t=new Map,a=new Map;for(let r of e){let s=v(r.period);if(!s)continue;let l=r.price.amount/s.months;t.set(r.key,l),a.set(r.price.currency,Math.max(a.get(r.price.currency)??0,l))}let i={};for(let r of e){let s={product_name:r.productName,price:x(r.price.amount,r.price.currency,n)},l=v(r.period);if(l){s.period=L(l,n),s.price_per_month=x(Math.round(t.get(r.key)),r.price.currency,n);let o=a.get(r.price.currency)??0,u=o>0?Math.floor((1-t.get(r.key)/o)*100)/100:0;u>=.01&&(s.savings=K(u,n))}let f=r.intro?.mode==="free_trial"?v(r.intro.duration):null;f&&(s.trial=U(f,n)),r.offer&&(s.offer_price=x(Math.floor((r.price.amount*(100-r.offer.percentOff)+50)/100),r.price.currency,n)),i[r.key]=s}return i}var V={version:"0.73.0"};var C=`palbase-js/${V.version}`;var b=class{placement;source;definition;assets;offerings;offers;shown;deps;exposed=!1;constructor(n,t,a,i,r,s,l={},f=[]){this.placement=n,this.source=t,this.definition=a,this.assets=l,this.offerings=i,this.offers=f,this.shown=r,this.deps=s}packages(n){return I(q(this.offerings,F(this.definition),n,W(this.definition,this.offers)),n)}render(n,t){let a=t.locale??globalThis.navigator?.language??this.definition.default_locale,i=t.appearance===void 0?H():void 0,r=this.packages(a),s=D(n,{definition:this.definition,locale:a,appearance:t.appearance??(i?.matches?"dark":"light"),platform:"web",packages:r,eligible:Object.entries(r).filter(([,o])=>o.trial).map(([o])=>o),offers:this.offers.filter(o=>o.web).map(o=>o.key),links:t.links,assets:this.assets},{onPurchase:async o=>{try{let u=await this.deps.checkout({product:o.product,plan:o.plan,successUrl:t.successUrl,cancelUrl:t.cancelUrl,...o.offer!==void 0?{offer:o.offer}:{}});t.onCheckout?t.onCheckout(u,o):globalThis.location.assign(u)}catch(u){if(!t.onError)throw u;t.onError(u,o)}},onClose:t.onClose,onLink:t.onLink,labels:t.labels}),l=o=>s.update({appearance:o.matches?"dark":"light"});i?.addEventListener?.("change",l),!this.exposed&&this.shown&&(this.exposed=!0,this.deps.expose(this));let f=s.destroy.bind(s);return s.destroy=()=>{i?.removeEventListener?.("change",l),f()},s}};function H(){try{return globalThis.matchMedia?.("(prefers-color-scheme: dark)")}catch{return}}function J(e,n){if(!e)return;let t=n.split("-")[0];return e[n]?.name??e[t]?.name??Object.values(e).find(a=>a.name)?.name}function q(e,n,t,a=new Map){let i=[];for(let r of n){let[s,l]=r.split("."),f=e.products.find(d=>d.key===s),o=f?.channels.web,u=o?.plans.find(d=>d.key===l);if(!f||!o||!u)continue;let p=a.get(r),g=p?.discount?p.discount.percent:p?.trial?100:void 0;i.push({key:r,productName:J(o.locales,t)??f.key,price:{amount:u.price.amount,currency:u.price.currency},period:u.period,intro:u.intro,...g!==void 0?{offer:{percentOff:g}}:{}})}return i}function W(e,n){let t=new Map;for(let[a,i]of _(e)){let r=n.find(s=>s.key===i);r?.web&&t.set(a,r)}return t}var Y={en:{cta:"Continue",terms:"Terms",privacy:"Privacy"},tr:{cta:"Devam et",terms:"Ko\u015Fullar",privacy:"Gizlilik"},de:{cta:"Weiter",terms:"Bedingungen",privacy:"Datenschutz"},es:{cta:"Continuar",terms:"T\xE9rminos",privacy:"Privacidad"},fr:{cta:"Continuer",terms:"Conditions",privacy:"Confidentialit\xE9"},it:{cta:"Continua",terms:"Termini",privacy:"Privacy"},pt:{cta:"Continuar",terms:"Termos",privacy:"Privacidade"},nl:{cta:"Doorgaan",terms:"Voorwaarden",privacy:"Privacy"},ja:{cta:"\u7D9A\u3051\u308B",terms:"\u5229\u7528\u898F\u7D04",privacy:"\u30D7\u30E9\u30A4\u30D0\u30B7\u30FC"}},N=e=>({type:"button",action:{type:e},content:{type:"text",text:{t:e},size:"caption",color:"muted"}});function G(e){let n=e.products.flatMap(t=>(t.channels.web?.plans??[]).map(a=>({product:t.key,plan:a.key}))).slice(0,6);return n.length===0?null:{schema:2,name:"Default",default_locale:"en",locales:Y,theme:{colors:{light:{background:"#FFFFFF",surface:"#F2F2F7",text:"#111114",muted:"#6B6B70",accent:"#111114",on_accent:"#FFFFFF",stroke:"#E5E5EA"},dark:{background:"#000000",surface:"#1C1C1E",text:"#F5F5F7",muted:"#9A9AA0",accent:"#F5F5F7",on_accent:"#000000",stroke:"#2C2C2E"}},typography:{headline:{size:17,weight:600,text_style:"headline"},caption:{size:13,weight:400,text_style:"footnote"}},radii:{card:14},spacing:{sm:8,md:16,lg:24}},root:{type:"stack",spacing:"md",align:"stretch",style:{padding:"lg"},children:[{type:"stack",axis:"horizontal",children:[{type:"spacer"},{type:"button",action:{type:"close"},content:{type:"icon",name:"close",color:"muted",size:22}}]},{type:"spacer"},{type:"stack",spacing:"sm",align:"stretch",children:n.map(({product:t,plan:a})=>({type:"package",product:t,plan:a,style:{padding:"md",corners:"card",background:"surface",border:{width:1,color:"stroke"}},states:{selected:{border:{width:2,color:"accent"}}},children:[{type:"stack",axis:"horizontal",spacing:"sm",children:[{type:"stack",align:"start",spacing:2,children:[{type:"text",text:"{{product_name}}",size:"headline",align:"start"},{type:"text",text:"{{period}}",size:"caption",color:"muted",align:"start"}]},{type:"spacer"},{type:"text",text:"{{price}}",size:"headline"}]}]}))},{type:"purchase_button",style:{padding:"md",corners:"card",background:"accent"},content:{type:"text",text:{t:"cta"},size:"headline",color:"on_accent"}},{type:"stack",axis:"horizontal",spacing:"md",distribution:"center",children:[N("terms"),N("privacy")]}]}}}function $(){try{return globalThis.localStorage}catch{return}}function Q(e){try{let n=$()?.getItem(e);if(!n)return;let t=JSON.parse(n),a=t?.answer;return typeof a!="object"||a===null||typeof a.paywall_id!="string"||typeof a.version!="number"||typeof a.definition!="object"||a.definition===null||typeof a.offerings!="object"||a.definition.schema!==2?void 0:{etag:typeof t.etag=="string"?t.etag:void 0,answer:a}}catch{return}}function P(e,n){try{n?$()?.setItem(e,JSON.stringify(n)):$()?.removeItem(e)}catch{}}async function de(e,n,t,a,i,r={}){let{signal:s,fetch:l}=r,f=T(r.attributes),o=`palbase.paywall.${n}.${t}`,p={checkout:i,expose:async c=>{if(c.shown)try{let k={paywall_id:c.shown.paywallId,version:c.shown.version,...c.shown.variant!==void 0?{variant:c.shown.variant}:{},...c.shown.ruleId!==void 0?{rule_id:c.shown.ruleId}:{}};await e.recordPaywallExposure({path:{placement:t},headers:{"X-Palbase-Installation":a},body:k})}catch{}}},g=async(c,k)=>new b(t,k,c.definition,c.offerings,{paywallId:c.paywall_id,version:c.version,...c.variant!==void 0?{variant:c.variant}:{},...c.rule_id!==void 0?{ruleId:c.rule_id}:{}},p,await O(c.assets??[],{signal:s,...l?{fetch:l}:{}}),c.offers??[]),d=Q(o),y;try{y=await e.getPlacementPaywall({path:{placement:t},query:{channel:"web"},headers:{"X-Palbase-Paywall-Schema":2,"X-Palbase-Installation":a,"X-Platform":"web","X-Palbase-SDK":C,...r.appVersion?{"X-Palbase-Client-Version":r.appVersion}:{},...r.app?{"X-Palbase-App":r.app}:{},...r.locale?{"Accept-Language":r.locale}:{},...f!==void 0?{"X-Palbase-Attributes":f}:{},...d?.etag?{"If-None-Match":d.etag}:{}},signal:s})}catch(c){if(c instanceof h&&c.status===404||c instanceof h&&c.status===400&&c.code.startsWith("invalid_"))return P(o,void 0),A(e,t,p,s);if(d&&!s?.aborted)return g(d.answer,"cache");throw c}return y.status===200?(P(o,{etag:y.headers.get("etag")??void 0,answer:y.data}),g(y.data,"server")):y.status===304&&d?g(d.answer,"server"):(P(o,void 0),A(e,t,p,s))}async function A(e,n,t,a){let i=(await e.getOfferings({query:{channel:"web"},signal:a})).data,r=G(i);return r?new b(n,"default",r,i,void 0,t):null}export{T as a,v as b,x as c,L as d,I as e,b as f,G as g,de as h};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
2
  var K="pbt1.",E="Palbase-Encryption";var z="x-palbase-encrypted",o=class extends Error{code;constructor(t,n){super(n),this.name="TransitError",this.code=t}},h=new TextEncoder,P=new TextDecoder("utf-8",{fatal:!0}),l=()=>{let e=globalThis.crypto?.subtle;if(!e)throw new Error("encrypted fields need WebCrypto (crypto.subtle): a secure context \u2014 https, or localhost");return e};function y(e){return new Uint8Array(new ArrayBuffer(e))}function f(...e){let t=y(e.reduce((r,i)=>r+i.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function d(e){return f(e)}function m(e,t){let n=y(t);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return n}function x(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function w(e){let t=e.replace(/=+$/,"");if(!/^[A-Za-z0-9_-]*$/.test(t)||t.length%4===1)throw new o("malformed","not base64url");let n=atob(t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4)),r=y(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}var S=f(h.encode("KEM"),m(32,2)),g=f(h.encode("HPKE"),m(32,2),m(1,2),m(1,2)),v=h.encode("HPKE-v1"),X=16,H=12,T=32,$=Uint8Array.from([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function N(e,t){let n=await l().importKey("raw",e.length===0?y(32):d(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return new Uint8Array(await l().sign("HMAC",n,d(t)))}async function k(e,t,n,r){return N(t,f(v,e,h.encode(n),r))}async function U(e,t,n,r,i){let a=f(m(i,2),v,e,h.encode(n),r),s=y(i),c=y(0);for(let u=1,p=0;p<i;u++)c=await N(t,f(c,a,Uint8Array.of(u))),s.set(c.subarray(0,Math.min(c.length,i-p)),p),p+=c.length;return s}async function j(e){if(e.length!==32)throw new o("malformed","an X25519 private key is 32 bytes");return l().importKey("pkcs8",f($,e),{name:"X25519"},!1,["deriveBits"])}async function C(e){if(e.length!==32)throw new o("malformed","an X25519 public key is 32 bytes");return l().importKey("raw",d(e),{name:"X25519"},!1,[])}async function O(e,t){return new Uint8Array(await l().deriveBits({name:"X25519",public:t},e,256))}async function R(e,t,n){let r=await k(S,y(0),"eae_prk",e);return U(S,r,"shared_secret",f(t,n),T)}async function _(e,t){let n=await k(g,y(0),"psk_id_hash",y(0)),r=await k(g,y(0),"info_hash",t),i=f(Uint8Array.of(0),n,r),a=await k(g,e,"secret",y(0));return{key:await U(g,a,"key",i,X),nonce:await U(g,a,"base_nonce",i,H)}}async function b(e,t,n,r,i){let a=await l().importKey("raw",d(t),"AES-GCM",!1,[e]);return new Uint8Array(await l()[e]({name:"AES-GCM",iv:d(n),additionalData:d(r)},a,d(i)))}async function V(e,t,n,r=y(0),i){let a,s;if(i)a=await j(i.privateKey),s=d(i.publicKey);else{let B=await l().generateKey({name:"X25519"},!0,["deriveBits"]);a=B.privateKey,s=new Uint8Array(await l().exportKey("raw",B.publicKey))}let c=await R(await O(a,await C(e)),s,e),{key:u,nonce:p}=await _(c,t);return{enc:s,ct:await b("encrypt",u,p,r,n)}}async function q(e,t,n,r,i,a=y(0)){if(n.length!==32)throw new o("malformed","an encapsulated X25519 key is 32 bytes");try{let s=await R(await O(await j(e),await C(n)),n,t),{key:c,nonce:u}=await _(s,r);return await b("decrypt",c,u,a,i)}catch{throw new o("unopenable","the request's key does not open with the project's key it names")}}async function Z(e){let t=await l().importKey("pkcs8",f($,e),{name:"X25519"},!0,["deriveBits"]),n=await l().exportKey("jwk",t);return w(n.x)}function Q(e,t,n,r=[]){if(r.some(i=>i.includes("\0")))throw new o("malformed","a path's value holds no NUL");return h.encode(["palbase-encryption","1",e,t.toUpperCase(),L(n),...r].join("\0"))}function L(e){return e.replace(/\{[^/{}]*\}/g,"{}")}async function Y(e,t,n,r={}){let i=r.key?d(r.key):crypto.getRandomValues(y(32)),{enc:a,ct:s}=await V(t,n,i,y(0),r.ephemeral);return{kid:e,key:i,header:`1.${e}.${x(a)}.${x(s)}`}}function J(e){let t=e.trim().split(".");if(t.length!==4||t[0]!=="1"||!/^t[1-9][0-9]{0,5}$/.test(t[1]))throw new o("malformed",`${E} is 1.<key id>.<enc>.<ct>`);let n=w(t[2]),r=w(t[3]);if(n.length!==32||r.length!==48)throw new o("malformed",`${E} carries a 32-byte encapsulated key and a sealed 32-byte key`);return{kid:t[1],enc:n,ct:r}}async function ee(e,t,n,r){let{enc:i,ct:a}=J(e),s=await q(t,n,i,r,a);if(s.length!==32)throw new o("unopenable","the request's key is not 32 bytes");return s}function I(e){return h.encode(`pbt1\0${e}`)}async function te(e,t,n,r){let i=r?d(r):crypto.getRandomValues(y(12)),a=JSON.stringify(n);if(a===void 0)throw new o("malformed",`${t}: an encrypted field holds a JSON value`);let s=await b("encrypt",e,i,I(t),h.encode(a));return K+x(f(i,s))}function F(e){return typeof e=="string"&&e.startsWith(K)}async function ne(e,t,n){if(!F(n))throw new o("unopenable",`${t} is not an encrypted field`);let r;try{r=w(n.slice(K.length))}catch{throw new o("unopenable",`${t} is not an encrypted field`)}if(r.length<28)throw new o("unopenable",`${t} is too short to be an encrypted field`);let i;try{i=await b("decrypt",e,r.subarray(0,12),I(t),r.subarray(12))}catch{throw new o("unopenable",`${t} does not open: changed, moved from another field, or another request's`)}try{return JSON.parse(P.decode(i))}catch{throw new o("unopenable",`${t} opens to no JSON value`)}}function D(e){return e.replace(/~/g,"~0").replace(/\//g,"~1").replace(/\*/g,"~2")}function G(e){return e.replace(/~2/g,"*").replace(/~1/g,"/").replace(/~0/g,"~")}var M=Symbol("items");function W(e,t){if(!(e!==t&&!e.startsWith(t+"/")))return e===t?[]:e.slice(t.length+1).split("/").map(n=>n==="*"?M:G(n))}async function re(e,t,n,r){let i=e;for(let a of n){let s=W(a,t);s!==void 0&&(i=await A(i,s,t,r))}return i}async function A(e,t,n,r){if(t.length===0)return e===void 0?void 0:r(n,e);let[i,...a]=t;if(i===M){if(!Array.isArray(e))return e;let c=[];for(let[u,p]of e.entries())c.push(await A(p,a,`${n}/${u}`,r));return c}if(Array.isArray(e)){if(!/^(0|[1-9][0-9]*)$/.test(i)||Number(i)>=e.length)return e;let c=[...e];return c[Number(i)]=await A(c[Number(i)],a,`${n}/${i}`,r),c}if(typeof e!="object"||e===null||Array.isArray(e)||!Object.hasOwn(e,i))return e;let s={...e};return s[i]=await A(s[i],a,`${n}/${D(i)}`,r),s}function ie(){return x(crypto.getRandomValues(y(16)))}async function se(e,t,n,r){let i,a=!1;try{i=w(e.payload);let u=await l().importKey("raw",w(t),{name:"Ed25519"},!1,["verify"]);a=await l().verify({name:"Ed25519"},u,w(e.signature),i)}catch{throw new o("unverified","the project's key list does not verify")}if(!a)throw new o("unverified","the project's key list is not signed with the project's key");let s;try{s=JSON.parse(P.decode(i))}catch{throw new o("unverified","the project's key list is no JSON")}if(s.v!==1||s.project!==n||typeof s.issued_at!="string"||!Array.isArray(s.keys)||s.keys.length===0)throw new o("unverified","the key list is not this project's, or holds no key");if(s.nonce!==r)throw new o("unverified","the key list was not asked for just now: its nonce is not the one sent");let c=s.keys.map(u=>{if(typeof u.kid!="string"||!/^t[1-9][0-9]{0,5}$/.test(u.kid)||typeof u.key!="string")throw new o("unverified","a key of the list is malformed");let p=w(u.key);if(p.length!==32)throw new o("unverified","a key of the list is not an X25519 public key");return{kid:u.kid,key:p}});return{project:s.project,issuedAt:s.issued_at,keys:c}}export{E as a,z as b,o as c,w as d,Z as e,Q as f,Y as g,J as h,ee as i,te as j,F as k,ne as l,D as m,G as n,re as o,ie as p,se as q};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
2
  var u="X-PoW-Challenge-ID",c="X-PoW-Nonce";function m(e){if(typeof e!="object"||e===null)return null;let t=e;if(t.error!=="pow_required"||typeof t.challenge!="object"||t.challenge===null)return null;let{id:n,prefix:r,difficulty:o}=t.challenge;return typeof n!="string"||typeof r!="string"||typeof o!="number"||!Number.isInteger(o)||o<0?null:{id:n,prefix:r,difficulty:o}}function d(e){return 8*2**e}var s;async function l(){if(s)return s;let e=globalThis;if(e.process?.versions?.node!==void 0||e.process?.versions?.bun!==void 0)try{let r=(await import("node:crypto")).createHash;if(typeof r=="function")return s=o=>new Uint8Array(r("sha256").update(o).digest()),s}catch{}let t=new TextEncoder;return s=async n=>new Uint8Array(await crypto.subtle.digest("SHA-256",t.encode(n))),s}function p(e){let t=0;for(let n of e){if(n===0){t+=8;continue}return t+Math.clz32(n)-24}return t}var w=4096,g=typeof globalThis.setImmediate=="function"?()=>new Promise(e=>globalThis.setImmediate(e)):()=>new Promise(e=>setTimeout(e,0));async function y(e,t={}){if(e.difficulty>24)throw new Error(`proof-of-work: difficulty ${e.difficulty} is above auth's ceiling of 24`);let n=await l(),r=d(e.difficulty),o=Date.now()+(t.timeLimitMs??12e4);for(let i=0;i<r;i++){if(i%w===0&&i>0){if(await g(),t.signal?.aborted)throw t.signal.reason??new DOMException("proof-of-work aborted","AbortError");if(Date.now()>o)throw new Error(`proof-of-work: gave up on difficulty ${e.difficulty} after ${i} attempts`)}let f=n(e.prefix+i),a=f instanceof Uint8Array?f:await f;if(p(a)>=e.difficulty)return{[u]:e.id,[c]:String(i)}}throw new Error(`proof-of-work: no nonce for difficulty ${e.difficulty} within ${r} attempts`)}export{m as a,y as b};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- import{a as g,f as y,g as w}from"./OY2MT7N5.js";import"./QROXSSPQ.js";import"./E2MNCFOU.js";import{pathToFileURL as z}from"node:url";import{z as c}from"zod";async function S(r){let l=new Map,t=new Map;for(let s of r){let o=`${s.className}.${s.method}`,i=t.get(s.className);if(i!==void 0&&i!==s.file)throw new Error(`two controllers are named ${s.className} (${i}, ${s.file}): the contract tells routes apart by their class's name \u2014 rename one`);t.set(s.className,s.file),l.set(o,{returns:await x(s),throws:s.throws})}return s=>l.get(`${s.controller.name}.${s.fn}`)}async function x(r){let l=`${r.file} \u2014 ${r.className}.${r.method}`;switch(r.returns.kind){case"void":return{kind:"void"};case"raw":return{kind:"raw"};case"schema":{let s=(await import(z(r.returns.file).href))[r.returns.exportName];if(!k(s))throw new Error(`${l}: its return type names ${r.returns.exportName}, which ${r.returns.file} exports as no schema (a zod, valibot or arktype schema)`);if(w(y(s)))throw new Error(`${l}: ${r.returns.exportName} marks an encrypted field (encrypted()) \u2014 an answer's is encrypt(value) in what the handler returns, its type Encrypted<T>, which the contract reads`);return{kind:"json",schema:s,array:r.returns.array}}case"expression":{let t=$(r.returns.expression,l);if(!k(t))throw new Error(`${l}: the schema made of its return type is not one`);return{kind:"json",schema:t,array:!1}}}}function $(r,l){let t=0,s=()=>{for(;t<r.length&&/\s/.test(r[t]);)t++},o=e=>{throw new Error(`${l}: invalid inferred return schema (${e}) at offset ${t}`)},i=e=>(s(),r.startsWith(e,t)?(t+=e.length,!0):!1),n=e=>{i(e)||o(`expected ${JSON.stringify(e)}`)},f=()=>{s(),r[t]!=='"'&&o("expected string literal");let e=t+1;for(;e<r.length;){let d=r[e];if(d==="\\"){e+=2;continue}if(d==='"'){let h=r.slice(t,e+1);return t=e+1,JSON.parse(h)}e++}return o("unterminated string literal")},p=()=>{if(s(),r[t]==='"')return f();if(r.startsWith("true",t)&&!/[A-Za-z0-9_$]/.test(r[t+4]??""))return t+=4,!0;if(r.startsWith("false",t)&&!/[A-Za-z0-9_$]/.test(r[t+5]??""))return t+=5,!1;let e=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(r.slice(t));return e?(t+=e[0].length,Number(e[0])):o("expected literal value")},u=()=>{s();let e;if(i("encrypted(")){let d=u();n(")"),e=g(d)}else if(i("z.")){let d=t;for(;t<r.length&&/[A-Za-z0-9_]/.test(r[t]);)t++;let h=r.slice(d,t);switch(n("("),h){case"string":n(")"),e=c.string();break;case"number":n(")"),e=c.number();break;case"boolean":n(")"),e=c.boolean();break;case"null":n(")"),e=c.null();break;case"undefined":n(")"),e=c.undefined();break;case"literal":{let a=p();n(")"),e=c.literal(a);break}case"array":{let a=u();n(")"),e=c.array(a);break}case"union":{n("[");let a=[];if(!i("]")){do a.push(u());while(i(","));n("]")}n(")"),a.length<2&&o("z.union requires at least two alternatives"),e=c.union(a);break}case"record":{let a=u();n(",");let m=u();n(")"),e=c.record(a,m);break}case"object":{n("{");let a={};if(!i("}")){do{let m=f();n(":"),a[m]=u()}while(i(","));n("}")}n(")"),e=c.object(a);break}default:return o(`unsupported z.${h}`)}}else return o("expected z.* or encrypted(...)");for(;i(".");){let d=t;for(;t<r.length&&/[A-Za-z0-9_]/.test(r[t]);)t++;let h=r.slice(d,t);switch(n("("),h){case"strict":n(")"),e=e.strict();break;case"nullable":n(")"),e=e.nullable();break;case"optional":n(")"),e=e.optional();break;case"length":{let a=p();if(typeof a!="number"||!Number.isInteger(a)||a<0)return o("expected non-negative integer for .length()");n(")"),e=e.length(a);break}case"regex":{n("new RegExp(");let a=f();n(")"),n(")"),e=e.regex(new RegExp(a));break}default:return o(`unsupported modifier .${h}()`)}}return e},b=u();return s(),t!==r.length&&o("unexpected trailing tokens"),b}function k(r){return typeof r=="object"&&r!==null&&typeof r["~standard"]?.validate=="function"}export{S as routeContracts};
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
+ import{a as g,f as y,g as w}from"./757A6AR6.js";import"./J7Z2PYL4.js";import"./P36C47FS.js";import{pathToFileURL as z}from"node:url";import{z as c}from"zod";async function S(r){let l=new Map,t=new Map;for(let s of r){let o=`${s.className}.${s.method}`,i=t.get(s.className);if(i!==void 0&&i!==s.file)throw new Error(`two controllers are named ${s.className} (${i}, ${s.file}): the contract tells routes apart by their class's name \u2014 rename one`);t.set(s.className,s.file),l.set(o,{returns:await x(s),throws:s.throws})}return s=>l.get(`${s.controller.name}.${s.fn}`)}async function x(r){let l=`${r.file} \u2014 ${r.className}.${r.method}`;switch(r.returns.kind){case"void":return{kind:"void"};case"raw":return{kind:"raw"};case"schema":{let s=(await import(z(r.returns.file).href))[r.returns.exportName];if(!k(s))throw new Error(`${l}: its return type names ${r.returns.exportName}, which ${r.returns.file} exports as no schema (a zod, valibot or arktype schema)`);if(w(y(s)))throw new Error(`${l}: ${r.returns.exportName} marks an encrypted field (encrypted()) \u2014 an answer's is encrypt(value) in what the handler returns, its type Encrypted<T>, which the contract reads`);return{kind:"json",schema:s,array:r.returns.array}}case"expression":{let t=$(r.returns.expression,l);if(!k(t))throw new Error(`${l}: the schema made of its return type is not one`);return{kind:"json",schema:t,array:!1}}}}function $(r,l){let t=0,s=()=>{for(;t<r.length&&/\s/.test(r[t]);)t++},o=e=>{throw new Error(`${l}: invalid inferred return schema (${e}) at offset ${t}`)},i=e=>(s(),r.startsWith(e,t)?(t+=e.length,!0):!1),n=e=>{i(e)||o(`expected ${JSON.stringify(e)}`)},f=()=>{s(),r[t]!=='"'&&o("expected string literal");let e=t+1;for(;e<r.length;){let d=r[e];if(d==="\\"){e+=2;continue}if(d==='"'){let h=r.slice(t,e+1);return t=e+1,JSON.parse(h)}e++}return o("unterminated string literal")},p=()=>{if(s(),r[t]==='"')return f();if(r.startsWith("true",t)&&!/[A-Za-z0-9_$]/.test(r[t+4]??""))return t+=4,!0;if(r.startsWith("false",t)&&!/[A-Za-z0-9_$]/.test(r[t+5]??""))return t+=5,!1;let e=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(r.slice(t));return e?(t+=e[0].length,Number(e[0])):o("expected literal value")},u=()=>{s();let e;if(i("encrypted(")){let d=u();n(")"),e=g(d)}else if(i("z.")){let d=t;for(;t<r.length&&/[A-Za-z0-9_]/.test(r[t]);)t++;let h=r.slice(d,t);switch(n("("),h){case"string":n(")"),e=c.string();break;case"number":n(")"),e=c.number();break;case"boolean":n(")"),e=c.boolean();break;case"null":n(")"),e=c.null();break;case"undefined":n(")"),e=c.undefined();break;case"literal":{let a=p();n(")"),e=c.literal(a);break}case"array":{let a=u();n(")"),e=c.array(a);break}case"union":{n("[");let a=[];if(!i("]")){do a.push(u());while(i(","));n("]")}n(")"),a.length<2&&o("z.union requires at least two alternatives"),e=c.union(a);break}case"record":{let a=u();n(",");let m=u();n(")"),e=c.record(a,m);break}case"object":{n("{");let a={};if(!i("}")){do{let m=f();n(":"),a[m]=u()}while(i(","));n("}")}n(")"),e=c.object(a);break}default:return o(`unsupported z.${h}`)}}else return o("expected z.* or encrypted(...)");for(;i(".");){let d=t;for(;t<r.length&&/[A-Za-z0-9_]/.test(r[t]);)t++;let h=r.slice(d,t);switch(n("("),h){case"strict":n(")"),e=e.strict();break;case"nullable":n(")"),e=e.nullable();break;case"optional":n(")"),e=e.optional();break;case"length":{let a=p();if(typeof a!="number"||!Number.isInteger(a)||a<0)return o("expected non-negative integer for .length()");n(")"),e=e.length(a);break}case"regex":{n("new RegExp(");let a=f();n(")"),n(")"),e=e.regex(new RegExp(a));break}default:return o(`unsupported modifier .${h}()`)}}return e},b=u();return s(),t!==r.length&&o("unexpected trailing tokens"),b}function k(r){return typeof r=="object"&&r!==null&&typeof r["~standard"]?.validate=="function"}export{S as routeContracts};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.73.0 — Palbase SDK License (see LICENSE) */
2
2
  import{lstat as E,mkdir as k,readdir as b,readFile as j,rename as F,rm as J,writeFile as R}from"node:fs/promises";import{join as $}from"node:path";var o="palbase/strings",g="_meta.json",m=3,S=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function w(r){try{return Intl.getCanonicalLocales(r)[0]}catch{return}}function O(r,t){try{return JSON.parse(r)}catch(n){throw new Error(`${t} is not JSON: ${n.message}`)}}async function M(r){let t=$(r,o);try{if(!(await E(t)).isDirectory())throw new Error(`${o} is not a directory: the strings live in a directory of their own`)}catch(e){if(e.code==="ENOENT")return;throw e}let n=new Map;for(let e of await b(t,{withFileTypes:!0}))if(!(e.name.startsWith(".")||!e.name.endsWith(".json"))){if(!e.isFile())throw new Error(`${o}/${e.name} is not a regular file`);n.set(e.name,await j($(t,e.name),"utf8"))}return n.size===0?void 0:n}async function N(r){let t=await M(r);if(t===void 0)return;let n=t.get(g);if(n===void 0)throw new Error(`${o}/${g} is missing: it names the source language, and without it the language files are not a table`);let e=O(n,`${o}/${g}`);if(!S(e))throw new Error(`${o}/${g}: not a JSON object`);let c=e.version;if(c!==m)throw new Error(`${o}/${g}: version ${JSON.stringify(c)} is not one this reads (${m})`);let s=e.source;if(typeof s!="string"||w(s)!==s)throw new Error(`${o}/${g}: source ${JSON.stringify(s)} is not a language tag as it is written (${w(String(s))??"en, en-US, zh-Hans"})`);let f=new Map;for(let u of[...t.keys()].sort()){if(u===g)continue;let i=u.slice(0,-5),a=`${o}/${u}`,l=w(i);if(l===void 0)throw new Error(`${a}: ${JSON.stringify(i)} is not a language tag`);if(l!==i)throw new Error(`${a}: the language is written ${l} \u2014 name the file ${l}.json`);if(i===s)throw new Error(`${a}: ${i} is the source language \u2014 its text is the key itself, and it has no file`);if(i==="und"||i==="root"||i.startsWith("x-"))throw new Error(`${a}: ${i} is no language a request names \u2014 name the file for one (en, de, pt-BR)`);let d=O(t.get(u),a);if(!S(d))throw new Error(`${a}: not a JSON object of "sentence": "translation"`);let h=new Map;for(let[p,y]of Object.entries(d)){if(typeof y!="string")throw new Error(`${a}: the translation of ${JSON.stringify(p)} is not a string`);h.set(p,y)}f.set(i,h)}return{format:c,source:s,languages:f}}async function P(r){let t=await N(r);if(t===void 0)return;let n={};Object.setPrototypeOf(n,null);for(let[e,c]of t.languages)for(let[s,f]of c)Object.hasOwn(n,s)||(n[s]={},Object.setPrototypeOf(n[s],null)),n[s][e]=f;return{source:t.source,locales:[t.source,...t.languages.keys()],strings:n}}export{P as a};