palbase 0.5.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +2 -2
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +7 -7
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/{PALOWH6U.js → 2RG3I7LX.js} +2 -2
- package/dist/chunks/{R43DXJZE.js → 53FS342F.js} +2 -2
- package/dist/chunks/{TTZRGQWF.js → A3CDCPXX.js} +1 -1
- package/dist/chunks/{AWHTWL65.js → A76UZBAF.js} +2 -2
- package/dist/chunks/{DNHDO6AJ.js → AD5LBZAB.js} +1 -1
- package/dist/chunks/{3AUBDHV2.js → AYY4J3B2.js} +1 -1
- package/dist/chunks/{A7EL6JKQ.js → DRGYTL6T.js} +2 -2
- package/dist/chunks/{QIN2NQPN.js → DRTZ33XF.js} +2 -2
- package/dist/chunks/{32RCJNOH.js → GVFZM4BI.js} +3 -3
- package/dist/chunks/{7BA7LGEM.js → IVEAUFGE.js} +2 -2
- package/dist/chunks/{B45UFKBR.js → IYCW6PWG.js} +2 -2
- package/dist/chunks/KL7FIRII.js +2 -0
- package/dist/chunks/{PFSUOVTB.js → KLANM6M6.js} +1 -1
- package/dist/chunks/{ZXYDN6NA.js → SUX2BJG4.js} +1 -1
- package/dist/chunks/{FSXD7MN3.js → SXH5AIQX.js} +2 -2
- package/dist/chunks/{KSJ6AMCG.js → U4OZ4HOF.js} +2 -2
- package/dist/chunks/{EHJKMDP3.js → VP7V7YRH.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/ssr.js +2 -0
- package/dist/web/vite.js +2 -2
- package/package.json +6 -2
- package/types/backend/src/database.d.ts +3 -3
- package/types/web/src/client.d.ts +3 -1
- package/types/web/src/index.d.ts +1 -1
- package/types/web/src/session.d.ts +11 -0
- package/types/web/src/ssr.d.ts +86 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! palbase 0.
|
|
2
|
-
import{b as oe}from"./B45UFKBR.js";var Jt=s=>[...new Uint8Array(s)].map(t=>t.toString(16).padStart(2,"0")).join(""),Ut=s=>`pw-font-${s}`;function ie(s){return(typeof s=="string"?/^asset:([0-9a-f-]{36})$/.exec(s):null)?.[1]}async function Ge(s,t={}){let n={},i=t.fetch??((p,l)=>globalThis.fetch(p,l));return await Promise.all(s.map(async p=>{try{if(!/^https:\/\//.test(p.url))return;let l=await i(p.url,{signal:t.signal,credentials:"omit"});if(!l.ok)return;let f=await l.arrayBuffer();if(f.byteLength!==p.bytes&&p.bytes>0||Jt(await globalThis.crypto.subtle.digest("SHA-256",f))!==p.sha256.toLowerCase())return;let g=Vt(p.kind,new Uint8Array(f));if(g===void 0)return;let h=await Bt(p,f,g,t);h&&(n[p.id]=h)}catch{}})),n}var F=(s,t,n=0)=>s.length>=n+t.length&&t.every((i,p)=>s[n+p]===i),q=s=>[...s].map(t=>t.charCodeAt(0));function Vt(s,t){switch(s){case"image":return F(t,[137,80,78,71,13,10,26,10])?"image/png":F(t,[255,216,255])?"image/jpeg":F(t,q("RIFF"))&&F(t,q("WEBP"),8)?"image/webp":void 0;case"video":return F(t,q("ftyp"),4)?F(t,q("qt "),8)?"video/quicktime":"video/mp4":F(t,[26,69,223,163])?"video/webm":void 0;case"font":return F(t,q("wOF2"))?"font/woff2":F(t,q("wOFF"))?"font/woff":F(t,q("OTTO"))?"font/otf":F(t,[0,1,0,0])||F(t,q("true"))?"font/ttf":void 0;case"html":return F(t,[80,75,3,4])||F(t,[80,75,5,6])?"application/zip":void 0;default:return}}async function Bt(s,t,n,i){switch(s.kind){case"image":case"video":return{kind:s.kind,url:URL.createObjectURL(new Blob([t],{type:n}))};case"font":{let p=Ut(s.id),l=globalThis.FontFace,f=i.fonts??globalThis.document?.fonts;if(!l||!f)return;let y=new l(p,t,{display:"block"});return await y.load(),f.add(y),{kind:"font",url:"",family:p}}case"html":{let p=await qt(new Uint8Array(t)),l=Yt(p);return l===void 0?void 0:{kind:"html",url:"",html:l}}}}async function qt(s){let t=new DataView(s.buffer,s.byteOffset,s.byteLength),n=-1;for(let y=s.length-22;y>=Math.max(0,s.length-22-65535);y--)if(t.getUint32(y,!0)===101010256){n=y;break}if(n<0)throw new Error("not a zip");let i=t.getUint16(n+10,!0),p=t.getUint32(n+16,!0),l=new Map,f=0;for(let y=0;y<i;y++){if(t.getUint32(p,!0)!==33639248)throw new Error("a broken zip");let g=t.getUint16(p+10,!0),h=t.getUint32(p+20,!0),w=t.getUint32(p+24,!0),v=t.getUint16(p+28,!0),A=t.getUint16(p+30,!0),x=t.getUint16(p+32,!0),R=t.getUint32(p+42,!0),b=new TextDecoder().decode(s.subarray(p+46,p+46+v));if(p+=46+v+A+x,b.endsWith("/"))continue;if(b.startsWith("/")||b.split("/").includes(".."))throw new Error("a path leaving the zip");if(f+=w,l.size>=200||f>20971520)throw new Error("a zip too large");let T=R+30+t.getUint16(R+26,!0)+t.getUint16(R+28,!0),C=s.subarray(T,T+h);if(g===0)l.set(b,C);else if(g===8)l.set(b,await Wt(C));else throw new Error("a zip entry compressed another way")}return l}async function Wt(s){let t=new Response(new Uint8Array(s)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Kt={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 Ye(s,t){let n=Kt[s.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",i="";for(let p=0;p<t.length;p+=32768)i+=String.fromCharCode(...t.subarray(p,p+32768));return`data:${n};base64,${btoa(i)}`}var Xt="default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:";function Yt(s){let t=s.get("index.html");if(!t)return;let n=new TextDecoder().decode(t),i=h=>new TextDecoder().decode(s.get(h)),p=h=>{let w=h.replace(/^\.\//,"").split(/[?#]/)[0];return s.has(w)?w:void 0},l=h=>h.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(w,v,A)=>{let x=p(A);return x?`url("${Ye(x,s.get(x))}")`:w}),f=globalThis.DOMParser;if(!f)return;let y=new f().parseFromString(n,"text/html");for(let h of[...y.querySelectorAll('link[rel~="stylesheet"][href]')]){let w=p(h.getAttribute("href")),v=y.createElement("style");v.textContent=w?l(i(w)):"",h.replaceWith(v)}for(let h of[...y.querySelectorAll("style")])h.textContent=l(h.textContent??"");for(let h of[...y.querySelectorAll("[src], [href], [poster]")])for(let w of["src","href","poster"]){let v=h.getAttribute(w);if(v===null)continue;let A=p(v);A?h.setAttribute(w,Ye(A,s.get(A))):/^(https?:)?\/\//i.test(v)&&h.removeAttribute(w)}for(let h of[...y.querySelectorAll("[style]")])h.setAttribute("style",l(h.getAttribute("style")??""));let g=y.createElement("meta");return g.setAttribute("http-equiv","Content-Security-Policy"),g.setAttribute("content",Xt),y.head.prepend(g),`<!doctype html>${y.documentElement.outerHTML}`}var Ze=20,Qe=2048,et=256,Gt=/^[A-Za-z][A-Za-z0-9_.-]{0,39}$/,Q=s=>new oe({op:"GetPlacementPaywall",status:0,code:"invalid_attributes",message:s});function Zt(s){let t='"';for(let n=0;n<s.length;n++){let i=s.charCodeAt(n);i===34?t+='\\"':i===92?t+="\\\\":i>=32&&i<=126?t+=s[n]:t+=`\\u${i.toString(16).padStart(4,"0")}`}return`${t}"`}function tt(s){let t=Object.keys(s??{}).sort((p,l)=>p<l?-1:p>l?1:0);if(t.length===0)return;if(t.length>Ze)throw Q(`${t.length} attributes: at most ${Ze}`);let n=[];for(let p of t){if(!Gt.test(p))throw Q(`the attribute ${JSON.stringify(p)}: a key is a letter, then letters, digits and _ . -, at most 40`);let l=s[p],f;if(typeof l=="string"){if(new TextEncoder().encode(l).length>et)throw Q(`the attribute ${JSON.stringify(p)} is over ${et} bytes`);f=Zt(l)}else if(typeof l=="number"){if(!Number.isFinite(l))throw Q(`the attribute ${JSON.stringify(p)} is no number`);f=String(Object.is(l,-0)?0:l)}else if(typeof l=="boolean")f=l?"true":"false";else throw Q(`the attribute ${JSON.stringify(p)}: a value is a text, a number or a boolean`);n.push(`"${p}":${f}`)}let i=`{${n.join(",")}}`;if(i.length>Qe)throw Q(`the attributes are ${i.length} bytes: at most ${Qe}`);return i}function _e(s){let t=/^P(\d+)([DWMY])$/.exec(s??"");if(!t)return null;let n=Number(t[1]);if(!Number.isSafeInteger(n)||n<1)return null;switch(t[2]){case"D":return{count:n,unit:"day",months:n*12/365};case"W":return{count:n,unit:"week",months:n*12/52};case"M":return{count:n,unit:"month",months:n};default:return{count:n,unit:"year",months:n*12}}}function nt(s){try{return new Intl.NumberFormat("en",{style:"currency",currency:s}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function st(s,t,n){let i=s/10**nt(t);try{return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(i)}catch{return`${i.toFixed(nt(t))} ${t}`}}function Qt(s,t){try{let n=new Intl.NumberFormat(t,{style:"unit",unit:s.unit,unitDisplay:"long"});return s.count>1?n.format(s.count):n.formatToParts(1).filter(p=>p.type==="unit").map(p=>p.value).join("").trim()||n.format(1)}catch{return s.count>1?`${s.count} ${s.unit}s`:s.unit}}var en={en:s=>`${s} free`,tr:s=>`${s} \xFCcretsiz`,de:s=>`${s} kostenlos`,es:s=>`${s} gratis`,it:s=>`${s} gratis`,nl:s=>`${s} gratis`,pt:s=>`${s} gr\xE1tis`,sv:s=>`${s} gratis`,da:s=>`${s} gratis`,nb:s=>`${s} gratis`};function tn(s,t){let n;try{n=new Intl.NumberFormat(t,{style:"unit",unit:s.unit,unitDisplay:"long"}).format(s.count)}catch{n=`${s.count} ${s.unit}${s.count>1?"s":""}`}let i=en[t.split("-")[0].toLowerCase()];return i?i(n):n}function nn(s,t){try{return new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:0}).format(s)}catch{return`${Math.round(s*100)}%`}}function rt(s,t){let n=new Map,i=new Map;for(let l of s){let f=_e(l.period);if(!f)continue;let y=l.price.amount/f.months;n.set(l.key,y),i.set(l.price.currency,Math.max(i.get(l.price.currency)??0,y))}let p={};for(let l of s){let f={product_name:l.productName,price:st(l.price.amount,l.price.currency,t)},y=_e(l.period);if(y){f.period=Qt(y,t),f.price_per_month=st(Math.round(n.get(l.key)),l.price.currency,t);let h=i.get(l.price.currency)??0,w=h>0?Math.floor((1-n.get(l.key)/h)*100)/100:0;w>=.01&&(f.savings=nn(w,t))}let g=l.intro?.mode==="free_trial"?_e(l.intro.duration):null;g&&(f.trial=tn(g,t)),p[l.key]=f}return p}var W=(s,t,n)=>`M${s-n} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 ${-2*n} 0`,ue={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:[W(12,12,9),"M8 12l3 3 5-6"],clock:[W(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:[W(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",W(6,18,3),W(17,16,3)],people:[W(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:[W(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",W(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 ot="http://www.w3.org/2000/svg";function fe(s,t,n){let i=s.createElementNS(ot,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width",String(n)),i.setAttribute("height",String(n)),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");for(let p of t){let l=s.createElementNS(ot,"path");l.setAttribute("d",p),i.append(l)}return i}var he=2,m=(s,t=!1)=>({kind:"value",value:"plain",def:s,required:t}),N=s=>({kind:"value",value:"color",def:s}),it=s=>({kind:"value",value:"spacing",def:s}),sn=s=>({kind:"value",value:"radius",def:s}),Y=(s=!1)=>({kind:"text",required:s}),Ee=(s,t=!1)=>({kind:"list",item:s,required:t}),ae=(s,t=!1)=>({kind:"object",item:s,required:t}),at=(s=!1)=>({kind:"component",required:s}),Le={kind:"components"},lt={stack:{axis:m("vertical"),spacing:it(0),align:m("center"),distribution:m("start"),scroll:m(!1),children:Le},text:{text:Y(),spans:Ee("span"),font:m(),size:m(),weight:m(),line_height:m(),letter_spacing:m(),color:{kind:"value",value:"textColor",def:"text"},align:m("center"),max_lines:m(),uppercase:m(!1)},image:{src:m(void 0,!0),fit:m("fit"),aspect:m(),mask:ae("mask"),overlay:{kind:"value",value:"textColor"},alt:Y(),decorative:m(!1)},icon:{name:m(void 0,!0),color:N("accent"),size:m(24)},video:{src:m(void 0,!0),poster:m(),autoplay:m(!0),loop:m(!0),mute:m(!0),controls:m(!1),fit:m("fill"),aspect:m(),alt:Y()},button:{action:ae("action",!0),content:at(!0)},purchase_button:{content:at(!0),package:m()},package:{product:m(void 0,!0),plan:m(void 0,!0),selected:m(!1),children:Le},tabs:{},switch:{},carousel:{pages:Le,peek:m(0),spacing:m(8),loop:m(!1),auto_advance_ms:m(),indicator:ae("indicator"),height:m("")},countdown:{},timeline:{items:Ee("timeline_item",!0),line_color:N("accent"),line_width:m(2),icon_color:N("on_accent"),color:N("text"),spacing:m(16)},features:{items:Ee("feature",!0),icon_color:N("accent"),color:N("text"),spacing:m(12)},spacer:{size:it()},divider:{color:N("muted"),thickness:m(1)},custom_html:{src:m(void 0,!0),height:m("",!0)}},ee={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:m(""),height:m(""),max_width:m(),background:{kind:"fill"},border:ae("border"),corners:{kind:"corners"},shadow:ae("shadow"),opacity:m(1)},border:{width:m(),color:N("")},shadow:{color:N(""),radius:m(0),x:m(0),y:m(0)},linear:{type:m(""),angle:m(180),stops:m()},radial:{type:m(""),center_x:m(.5),center_y:m(.5),radius:m(.5),stops:m()},image_fill:{type:m(""),src:m(),fit:m("fill")},video_fill:{type:m(""),src:m(),poster:m(),loop:m(!0)},animation:{type:m(""),duration_ms:m(300),delay_ms:m(0),easing:m("ease_out")},action:{type:m(""),url:m(),sheet:m(),package:m()},mask:{shape:m(""),radius:sn(0),depth:m(16)},span:{text:Y(!0),bold:m(!1),italic:m(!1),underline:m(!1),strikethrough:m(!1),color:N(""),link:m()},timeline_item:{icon:m(void 0,!0),title:Y(!0),text:Y(),color:N("")},feature:{icon:m(void 0,!0),text:Y(!0)},indicator:{style:m("dots"),color:N("muted"),active_color:N("accent"),size:m(8),spacing:m(6)},typography:{font:m("system"),size:m(),weight:m(400),line_height:m(),letter_spacing:m(0),text_style:m("body")}},rn={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},on=["top","bottom","leading","trailing"],an=["top_leading","top_trailing","bottom_leading","bottom_trailing"],Fn=Object.keys(lt),ln=/\{\{\s*([^{}]*?)\s*\}\}/g,te=(s,t)=>typeof s=="object"&&s!==null&&Object.hasOwn(s,t),S=s=>typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{},J=s=>Array.isArray(s)?s:[],X=(s,t)=>s??t;function cn(s){let t=Math.floor(s/86400),n=Math.floor(s%86400/3600),i=Math.floor(s%3600/60),p=s%60,l=y=>String(y).padStart(2,"0");return{countdown:t>0?`${t}d ${l(n)}:${l(i)}:${l(p)}`:n>0?`${n}:${l(i)}:${l(p)}`:`${l(i)}:${l(p)}`,days:String(t),hours:l(n),minutes:l(i),seconds:l(p)}}function ct(s){let t=[],n=p=>{if(Array.isArray(p))return p.forEach(n);if(typeof p!="object"||p===null)return;let l=p;if(l.type==="package"&&typeof l.product=="string"&&typeof l.plan=="string"){let f=`${l.product}.${l.plan}`;t.includes(f)||t.push(f)}for(let f of Object.keys(l).sort())n(l[f])},i=s;for(let p of["header","root","footer"])n(i[p]);for(let p of Object.keys(S(i.sheets)).sort())n(S(S(i.sheets)[p]).root);return t}function Cn(s,t){return new ge(s,t).resolve().tree}function dt(s,t){return new ge(s,t).resolve()}var ge=class{d;opts;lang;texts={};palette;typography={};radii;spacing;packages;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,n){this.d=t,this.opts=n,this.packages=n.packages;let i=S(this.d.locales),p=String(this.d.default_locale??""),l=n.locale;te(i,l)||(l=l.split("-")[0]??"",te(i,l)||(l=p)),this.lang=l;for(let y of[p,l])for(let[g,h]of Object.entries(S(i[y])))typeof h=="string"&&(this.texts[g]=h);let f=S(this.d.theme);this.palette=S(S(f.colors)[n.appearance]);for(let[y,g]of Object.entries(S(f.typography))){let h={};for(let[w,v]of Object.entries(ee.typography)){let A=X(S(g)[w],v.def);A!=null&&(h[w]=A)}this.typography[y]=h}this.radii=S(f.radii),this.spacing=S(f.spacing)}resolve(){let[t,n]=this.initialState();this.tab=t,this.selected=n;let i={selected:n,theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};for(let l of["header","root","footer"]){let f=this.d[l];if(typeof f=="object"&&f!==null){let y=this.component(S(f),l,"",!1);y&&(i[l]=y)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let l={};for(let[f,y]of Object.entries(S(this.d.sheets))){let g=this.component(S(S(y).root),`sheets.${f}.root`,"",!1);g&&(l[f]=g);let h=this.text(S(y).title,this.packages[this.selected]);h!==null&&(p[f]=h)}i.sheets=l}return{tree:i,pathOf:l=>this.paths.get(l),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,n){return this.opts.switches&&Object.hasOwn(this.opts.switches,n)?this.opts.switches[n]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,n){let p=J(t.tabs).map(S).map(f=>String(f.id)),l=this.opts.tabs?.[n];return l!==void 0&&p.includes(l)?l:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:p[0]??""}initialState(){let t="",n="",i="",p="",l=(y,g)=>{if(Array.isArray(y)){y.forEach((w,v)=>l(w,`${g}[${v}]`));return}if(typeof y!="object"||y===null)return;let h=y;switch(h.type){case"package":{let w=`${h.product}.${h.plan}`;i===""&&(i=w),h.selected===!0&&n===""&&(n=w);break}case"switch":{let w=this.switchOn(h,g),v=w?h.on_package:h.off_package;typeof v=="string"&&p===""&&(p=v),l(w?h.on:h.off,`${g}.${w?"on":"off"}`);return}case"tabs":{let w=this.tabShown(h,g);t===""&&(t=w),J(h.tabs).forEach((v,A)=>{let x=S(v);x.id===w&&(typeof x.package=="string"&&p===""&&(p=x.package),l(x.content,`${g}.tabs[${A}].content`))});return}}for(let w of Object.keys(h).sort())w!=="sheets"&&l(h[w],g===""?w:`${g}.${w}`)};for(let y of["header","root","footer"])l(this.d[y],y);let f=this.opts.selected||p||n||i;return[t,f]}holds(t,n){let i=n||this.selected;for(let[p,l]of Object.entries(t))switch(p){case"selected_package":if(!J(l).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(i)!==l)return!1;break;case"platform":if(!J(l).includes(this.opts.platform))return!1;break;case"locale":if(!J(l).includes(this.opts.locale)&&!J(l).includes(this.lang))return!1;break;case"appearance":if(l!==this.opts.appearance)return!1;break;case"tab":if(l!==this.tab)return!1;break}return!0}component(t,n,i,p){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(S(t.visible),i))return null;let l=String(t.type),f=i,y=p;l==="package"&&(f=`${t.product}.${t.plan}`,y=f===this.selected);let g={type:l};this.paths.set(g,n),te(t,"id")&&(g.id=t.id);let h={...S(t.style)};y&&Object.assign(h,S(S(t.states).selected)),Object.keys(h).length>0&&(g.style=this.style(h)),typeof t.animation=="object"&&t.animation!==null&&(g.animation=this.defaults(S(t.animation),ee.animation));let w=this.packages[f||this.selected];switch(l){case"tabs":return this.tabs(t,g,n,f);case"switch":return this.switchOf(t,g,n,f,y);case"countdown":return this.countdown(t,g,n,f,y);case"purchase_button":{let v=typeof t.package=="string"?t.package:this.selected;g.package=v;let A=this.component(S(t.content),`${n}.content`,v,y);return A?(g.content=A,g):null}case"package":g.product=t.product,g.plan=t.plan,g.selected=y}for(let[v,A]of Object.entries(lt[l]??{})){if(l==="package"&&(v==="product"||v==="plan"||v==="selected"))continue;let x=t[v],R=te(t,v);switch(A.kind){case"component":{if(!R)continue;let b=this.component(S(x),`${n}.${v}`,f,y);if(!b&&A.required)return null;b&&(g[v]=b);break}case"components":{let b=[];J(x).forEach((T,C)=>{let K=this.component(S(T),`${n}.${v}[${C}]`,f,y);K&&b.push(K)}),g[v]=b;break}case"text":{let b=this.text(x,w);if(b!==null)g[v]=b;else if(A.required||l==="text"&&v==="text"&&R)return null;break}case"list":{let b=[];for(let T of J(x)){let C=this.item(A.item,S(T),w);C&&b.push(C)}if(l==="text"&&b.length===0&&R)return null;R&&(g[v]=b);break}case"object":{R?g[v]=this.object(S(x),A.item,w):v==="indicator"&&(g[v]=this.object({},A.item,w));break}case"value":{let b=this.value(X(x,A.def),A);b!=null&&b!==""&&(g[v]=b);break}}}return l==="text"&&this.typeStyle(g),g}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let n=this.typography[t.size];for(let i of["font","weight","line_height","letter_spacing","text_style"])!te(t,i)&&n?.[i]!==void 0&&n?.[i]!==null&&(t[i]=n[i]);t.size=n?.size??null}tabs(t,n,i,p){let l=this.tabShown(t,i);this.tabsShown[i]=l;let f=[];return J(t.tabs).forEach((y,g)=>{let h=S(y),w=h.id===l,v=this.component(S(h.label),`${i}.tabs[${g}].label`,p,w);if(f.push({id:h.id,selected:w,label:v}),w){let A=this.component(S(h.content),`${i}.tabs[${g}].content`,p,!1);A&&(n.content=A)}}),n.tabs=f,typeof t.bar=="object"&&t.bar!==null&&(n.bar=this.style(S(t.bar))),n}switchOf(t,n,i,p,l){let f=this.switchOn(t,i);this.switchesOn[i]=f,n.on=f;let y=this.text(t.label,this.packages[p||this.selected]);y!==null&&(n.label=y),n.tint=this.color(String(X(t.tint,"accent")));let g=f?"on":"off",h=this.component(S(t[g]),`${i}.${g}`,p,l);return h&&(n.content=h),n}countdown(t,n,i,p,l){let f=S(t.target),y=this.opts.now??Date.now(),g;if(typeof f.after_open_seconds=="number"?g=Math.trunc(f.after_open_seconds)-(this.opts.openedSecondsAgo??0):g=Math.trunc((Date.parse(String(f.at))-y)/1e3),g>0){n.state="counting",n.remaining_seconds=g,this.countdowns[i]=g;let h=this.packages,w={};for(let[A,x]of Object.entries(h))w[A]={...x,...cn(g)};this.packages=w;let v=this.component(S(t.counting),`${i}.counting`,p,l);return v&&(n.content=v),this.packages=h,n}if(n.state="ended",n.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let h=this.component(S(t.ended),`${i}.ended`,p,l);h&&(n.content=h)}return n}item(t,n,i){let p={};for(let[l,f]of Object.entries(ee[t]??{})){let y=n[l];if(f.kind==="text"){let g=this.text(y,i);if(g!==null)p[l]=g;else if(f.required)return null}else{let g=f.def,h=this.value(X(y,g),f);h!=null&&(te(n,l)||g!=null&&g!=="")&&(p[l]=h)}}return p}object(t,n,i){return n==="style"?this.style(t):this.item(n,t,i)??{}}defaults(t,n){let i={};for(let[p,l]of Object.entries(n)){let f=X(t[p],l.def);f!=null&&f!==""&&(i[p]=f)}return i}style(t){let n={};for(let[i,p]of Object.entries(t)){let l=ee.style[i];if(!l){n[i]=p;continue}switch(l.kind){case"edges":n[i]=this.sides(p,on,this.spacing);break;case"corners":n[i]=this.sides(p,an,this.radii);break;case"fill":n[i]=this.fill(p);break;case"object":{let f=S(p),y={};for(let[g,h]of Object.entries(ee[l.item]??{})){let w=X(f[g],h.def);w!=null&&w!==""&&(y[g]=this.value(w,h))}n[i]=y;break}default:n[i]=p}}return n}sides(t,n,i){let p={};for(let l of n){let f=typeof t=="object"&&t!==null?X(S(t)[l],0):t;p[l]=$e(f,i)}return p}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let n=S(t),i=this.defaults(n,ee[rn[String(n.type)]??""]??{});return Array.isArray(n.stops)&&(i.stops=n.stops.map(p=>({color:this.color(String(S(p).color)),at:S(p).at}))),i}value(t,n){if(n.kind!=="value")return t;switch(n.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 n=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof n=="string"?n:t}text(t,n){let i;if(typeof t=="string")i=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let l=t.t;i=typeof l=="string"&&Object.hasOwn(this.texts,l)?this.texts[l]:""}else return null;let p=!1;return i=i.replace(ln,(l,f)=>{let y=n&&Object.hasOwn(n,f)?n[f]:void 0;return typeof y!="string"||y===""?(p=!0,""):y}),p||i.trim()===""?null:i}};function $e(s,t){return typeof s=="string"?Object.hasOwn(t,s)?t[s]:null:s}var dn={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(s,t)=>`${s} of ${t}`},ne={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'},pn=1.35,pt=20,un=new Set(["button","purchase_button","package","text"]),fn=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),ut={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)"},gn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},hn={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},yn={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},mn={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},wn=`
|
|
1
|
+
/*! palbase 0.6.2 — Palbase SDK License (see LICENSE) */
|
|
2
|
+
import{b as oe}from"./IYCW6PWG.js";var Jt=s=>[...new Uint8Array(s)].map(t=>t.toString(16).padStart(2,"0")).join(""),Ut=s=>`pw-font-${s}`;function ie(s){return(typeof s=="string"?/^asset:([0-9a-f-]{36})$/.exec(s):null)?.[1]}async function Ge(s,t={}){let n={},i=t.fetch??((p,l)=>globalThis.fetch(p,l));return await Promise.all(s.map(async p=>{try{if(!/^https:\/\//.test(p.url))return;let l=await i(p.url,{signal:t.signal,credentials:"omit"});if(!l.ok)return;let f=await l.arrayBuffer();if(f.byteLength!==p.bytes&&p.bytes>0||Jt(await globalThis.crypto.subtle.digest("SHA-256",f))!==p.sha256.toLowerCase())return;let g=Vt(p.kind,new Uint8Array(f));if(g===void 0)return;let h=await Bt(p,f,g,t);h&&(n[p.id]=h)}catch{}})),n}var F=(s,t,n=0)=>s.length>=n+t.length&&t.every((i,p)=>s[n+p]===i),q=s=>[...s].map(t=>t.charCodeAt(0));function Vt(s,t){switch(s){case"image":return F(t,[137,80,78,71,13,10,26,10])?"image/png":F(t,[255,216,255])?"image/jpeg":F(t,q("RIFF"))&&F(t,q("WEBP"),8)?"image/webp":void 0;case"video":return F(t,q("ftyp"),4)?F(t,q("qt "),8)?"video/quicktime":"video/mp4":F(t,[26,69,223,163])?"video/webm":void 0;case"font":return F(t,q("wOF2"))?"font/woff2":F(t,q("wOFF"))?"font/woff":F(t,q("OTTO"))?"font/otf":F(t,[0,1,0,0])||F(t,q("true"))?"font/ttf":void 0;case"html":return F(t,[80,75,3,4])||F(t,[80,75,5,6])?"application/zip":void 0;default:return}}async function Bt(s,t,n,i){switch(s.kind){case"image":case"video":return{kind:s.kind,url:URL.createObjectURL(new Blob([t],{type:n}))};case"font":{let p=Ut(s.id),l=globalThis.FontFace,f=i.fonts??globalThis.document?.fonts;if(!l||!f)return;let y=new l(p,t,{display:"block"});return await y.load(),f.add(y),{kind:"font",url:"",family:p}}case"html":{let p=await qt(new Uint8Array(t)),l=Yt(p);return l===void 0?void 0:{kind:"html",url:"",html:l}}}}async function qt(s){let t=new DataView(s.buffer,s.byteOffset,s.byteLength),n=-1;for(let y=s.length-22;y>=Math.max(0,s.length-22-65535);y--)if(t.getUint32(y,!0)===101010256){n=y;break}if(n<0)throw new Error("not a zip");let i=t.getUint16(n+10,!0),p=t.getUint32(n+16,!0),l=new Map,f=0;for(let y=0;y<i;y++){if(t.getUint32(p,!0)!==33639248)throw new Error("a broken zip");let g=t.getUint16(p+10,!0),h=t.getUint32(p+20,!0),w=t.getUint32(p+24,!0),v=t.getUint16(p+28,!0),A=t.getUint16(p+30,!0),x=t.getUint16(p+32,!0),R=t.getUint32(p+42,!0),b=new TextDecoder().decode(s.subarray(p+46,p+46+v));if(p+=46+v+A+x,b.endsWith("/"))continue;if(b.startsWith("/")||b.split("/").includes(".."))throw new Error("a path leaving the zip");if(f+=w,l.size>=200||f>20971520)throw new Error("a zip too large");let T=R+30+t.getUint16(R+26,!0)+t.getUint16(R+28,!0),C=s.subarray(T,T+h);if(g===0)l.set(b,C);else if(g===8)l.set(b,await Wt(C));else throw new Error("a zip entry compressed another way")}return l}async function Wt(s){let t=new Response(new Uint8Array(s)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Kt={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 Ye(s,t){let n=Kt[s.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",i="";for(let p=0;p<t.length;p+=32768)i+=String.fromCharCode(...t.subarray(p,p+32768));return`data:${n};base64,${btoa(i)}`}var Xt="default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:";function Yt(s){let t=s.get("index.html");if(!t)return;let n=new TextDecoder().decode(t),i=h=>new TextDecoder().decode(s.get(h)),p=h=>{let w=h.replace(/^\.\//,"").split(/[?#]/)[0];return s.has(w)?w:void 0},l=h=>h.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(w,v,A)=>{let x=p(A);return x?`url("${Ye(x,s.get(x))}")`:w}),f=globalThis.DOMParser;if(!f)return;let y=new f().parseFromString(n,"text/html");for(let h of[...y.querySelectorAll('link[rel~="stylesheet"][href]')]){let w=p(h.getAttribute("href")),v=y.createElement("style");v.textContent=w?l(i(w)):"",h.replaceWith(v)}for(let h of[...y.querySelectorAll("style")])h.textContent=l(h.textContent??"");for(let h of[...y.querySelectorAll("[src], [href], [poster]")])for(let w of["src","href","poster"]){let v=h.getAttribute(w);if(v===null)continue;let A=p(v);A?h.setAttribute(w,Ye(A,s.get(A))):/^(https?:)?\/\//i.test(v)&&h.removeAttribute(w)}for(let h of[...y.querySelectorAll("[style]")])h.setAttribute("style",l(h.getAttribute("style")??""));let g=y.createElement("meta");return g.setAttribute("http-equiv","Content-Security-Policy"),g.setAttribute("content",Xt),y.head.prepend(g),`<!doctype html>${y.documentElement.outerHTML}`}var Ze=20,Qe=2048,et=256,Gt=/^[A-Za-z][A-Za-z0-9_.-]{0,39}$/,Q=s=>new oe({op:"GetPlacementPaywall",status:0,code:"invalid_attributes",message:s});function Zt(s){let t='"';for(let n=0;n<s.length;n++){let i=s.charCodeAt(n);i===34?t+='\\"':i===92?t+="\\\\":i>=32&&i<=126?t+=s[n]:t+=`\\u${i.toString(16).padStart(4,"0")}`}return`${t}"`}function tt(s){let t=Object.keys(s??{}).sort((p,l)=>p<l?-1:p>l?1:0);if(t.length===0)return;if(t.length>Ze)throw Q(`${t.length} attributes: at most ${Ze}`);let n=[];for(let p of t){if(!Gt.test(p))throw Q(`the attribute ${JSON.stringify(p)}: a key is a letter, then letters, digits and _ . -, at most 40`);let l=s[p],f;if(typeof l=="string"){if(new TextEncoder().encode(l).length>et)throw Q(`the attribute ${JSON.stringify(p)} is over ${et} bytes`);f=Zt(l)}else if(typeof l=="number"){if(!Number.isFinite(l))throw Q(`the attribute ${JSON.stringify(p)} is no number`);f=String(Object.is(l,-0)?0:l)}else if(typeof l=="boolean")f=l?"true":"false";else throw Q(`the attribute ${JSON.stringify(p)}: a value is a text, a number or a boolean`);n.push(`"${p}":${f}`)}let i=`{${n.join(",")}}`;if(i.length>Qe)throw Q(`the attributes are ${i.length} bytes: at most ${Qe}`);return i}function _e(s){let t=/^P(\d+)([DWMY])$/.exec(s??"");if(!t)return null;let n=Number(t[1]);if(!Number.isSafeInteger(n)||n<1)return null;switch(t[2]){case"D":return{count:n,unit:"day",months:n*12/365};case"W":return{count:n,unit:"week",months:n*12/52};case"M":return{count:n,unit:"month",months:n};default:return{count:n,unit:"year",months:n*12}}}function nt(s){try{return new Intl.NumberFormat("en",{style:"currency",currency:s}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function st(s,t,n){let i=s/10**nt(t);try{return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(i)}catch{return`${i.toFixed(nt(t))} ${t}`}}function Qt(s,t){try{let n=new Intl.NumberFormat(t,{style:"unit",unit:s.unit,unitDisplay:"long"});return s.count>1?n.format(s.count):n.formatToParts(1).filter(p=>p.type==="unit").map(p=>p.value).join("").trim()||n.format(1)}catch{return s.count>1?`${s.count} ${s.unit}s`:s.unit}}var en={en:s=>`${s} free`,tr:s=>`${s} \xFCcretsiz`,de:s=>`${s} kostenlos`,es:s=>`${s} gratis`,it:s=>`${s} gratis`,nl:s=>`${s} gratis`,pt:s=>`${s} gr\xE1tis`,sv:s=>`${s} gratis`,da:s=>`${s} gratis`,nb:s=>`${s} gratis`};function tn(s,t){let n;try{n=new Intl.NumberFormat(t,{style:"unit",unit:s.unit,unitDisplay:"long"}).format(s.count)}catch{n=`${s.count} ${s.unit}${s.count>1?"s":""}`}let i=en[t.split("-")[0].toLowerCase()];return i?i(n):n}function nn(s,t){try{return new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:0}).format(s)}catch{return`${Math.round(s*100)}%`}}function rt(s,t){let n=new Map,i=new Map;for(let l of s){let f=_e(l.period);if(!f)continue;let y=l.price.amount/f.months;n.set(l.key,y),i.set(l.price.currency,Math.max(i.get(l.price.currency)??0,y))}let p={};for(let l of s){let f={product_name:l.productName,price:st(l.price.amount,l.price.currency,t)},y=_e(l.period);if(y){f.period=Qt(y,t),f.price_per_month=st(Math.round(n.get(l.key)),l.price.currency,t);let h=i.get(l.price.currency)??0,w=h>0?Math.floor((1-n.get(l.key)/h)*100)/100:0;w>=.01&&(f.savings=nn(w,t))}let g=l.intro?.mode==="free_trial"?_e(l.intro.duration):null;g&&(f.trial=tn(g,t)),p[l.key]=f}return p}var W=(s,t,n)=>`M${s-n} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 ${-2*n} 0`,ue={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:[W(12,12,9),"M8 12l3 3 5-6"],clock:[W(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:[W(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",W(6,18,3),W(17,16,3)],people:[W(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:[W(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",W(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 ot="http://www.w3.org/2000/svg";function fe(s,t,n){let i=s.createElementNS(ot,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width",String(n)),i.setAttribute("height",String(n)),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");for(let p of t){let l=s.createElementNS(ot,"path");l.setAttribute("d",p),i.append(l)}return i}var he=2,m=(s,t=!1)=>({kind:"value",value:"plain",def:s,required:t}),N=s=>({kind:"value",value:"color",def:s}),it=s=>({kind:"value",value:"spacing",def:s}),sn=s=>({kind:"value",value:"radius",def:s}),Y=(s=!1)=>({kind:"text",required:s}),Ee=(s,t=!1)=>({kind:"list",item:s,required:t}),ae=(s,t=!1)=>({kind:"object",item:s,required:t}),at=(s=!1)=>({kind:"component",required:s}),Le={kind:"components"},lt={stack:{axis:m("vertical"),spacing:it(0),align:m("center"),distribution:m("start"),scroll:m(!1),children:Le},text:{text:Y(),spans:Ee("span"),font:m(),size:m(),weight:m(),line_height:m(),letter_spacing:m(),color:{kind:"value",value:"textColor",def:"text"},align:m("center"),max_lines:m(),uppercase:m(!1)},image:{src:m(void 0,!0),fit:m("fit"),aspect:m(),mask:ae("mask"),overlay:{kind:"value",value:"textColor"},alt:Y(),decorative:m(!1)},icon:{name:m(void 0,!0),color:N("accent"),size:m(24)},video:{src:m(void 0,!0),poster:m(),autoplay:m(!0),loop:m(!0),mute:m(!0),controls:m(!1),fit:m("fill"),aspect:m(),alt:Y()},button:{action:ae("action",!0),content:at(!0)},purchase_button:{content:at(!0),package:m()},package:{product:m(void 0,!0),plan:m(void 0,!0),selected:m(!1),children:Le},tabs:{},switch:{},carousel:{pages:Le,peek:m(0),spacing:m(8),loop:m(!1),auto_advance_ms:m(),indicator:ae("indicator"),height:m("")},countdown:{},timeline:{items:Ee("timeline_item",!0),line_color:N("accent"),line_width:m(2),icon_color:N("on_accent"),color:N("text"),spacing:m(16)},features:{items:Ee("feature",!0),icon_color:N("accent"),color:N("text"),spacing:m(12)},spacer:{size:it()},divider:{color:N("muted"),thickness:m(1)},custom_html:{src:m(void 0,!0),height:m("",!0)}},ee={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:m(""),height:m(""),max_width:m(),background:{kind:"fill"},border:ae("border"),corners:{kind:"corners"},shadow:ae("shadow"),opacity:m(1)},border:{width:m(),color:N("")},shadow:{color:N(""),radius:m(0),x:m(0),y:m(0)},linear:{type:m(""),angle:m(180),stops:m()},radial:{type:m(""),center_x:m(.5),center_y:m(.5),radius:m(.5),stops:m()},image_fill:{type:m(""),src:m(),fit:m("fill")},video_fill:{type:m(""),src:m(),poster:m(),loop:m(!0)},animation:{type:m(""),duration_ms:m(300),delay_ms:m(0),easing:m("ease_out")},action:{type:m(""),url:m(),sheet:m(),package:m()},mask:{shape:m(""),radius:sn(0),depth:m(16)},span:{text:Y(!0),bold:m(!1),italic:m(!1),underline:m(!1),strikethrough:m(!1),color:N(""),link:m()},timeline_item:{icon:m(void 0,!0),title:Y(!0),text:Y(),color:N("")},feature:{icon:m(void 0,!0),text:Y(!0)},indicator:{style:m("dots"),color:N("muted"),active_color:N("accent"),size:m(8),spacing:m(6)},typography:{font:m("system"),size:m(),weight:m(400),line_height:m(),letter_spacing:m(0),text_style:m("body")}},rn={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},on=["top","bottom","leading","trailing"],an=["top_leading","top_trailing","bottom_leading","bottom_trailing"],Fn=Object.keys(lt),ln=/\{\{\s*([^{}]*?)\s*\}\}/g,te=(s,t)=>typeof s=="object"&&s!==null&&Object.hasOwn(s,t),S=s=>typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{},J=s=>Array.isArray(s)?s:[],X=(s,t)=>s??t;function cn(s){let t=Math.floor(s/86400),n=Math.floor(s%86400/3600),i=Math.floor(s%3600/60),p=s%60,l=y=>String(y).padStart(2,"0");return{countdown:t>0?`${t}d ${l(n)}:${l(i)}:${l(p)}`:n>0?`${n}:${l(i)}:${l(p)}`:`${l(i)}:${l(p)}`,days:String(t),hours:l(n),minutes:l(i),seconds:l(p)}}function ct(s){let t=[],n=p=>{if(Array.isArray(p))return p.forEach(n);if(typeof p!="object"||p===null)return;let l=p;if(l.type==="package"&&typeof l.product=="string"&&typeof l.plan=="string"){let f=`${l.product}.${l.plan}`;t.includes(f)||t.push(f)}for(let f of Object.keys(l).sort())n(l[f])},i=s;for(let p of["header","root","footer"])n(i[p]);for(let p of Object.keys(S(i.sheets)).sort())n(S(S(i.sheets)[p]).root);return t}function Cn(s,t){return new ge(s,t).resolve().tree}function dt(s,t){return new ge(s,t).resolve()}var ge=class{d;opts;lang;texts={};palette;typography={};radii;spacing;packages;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,n){this.d=t,this.opts=n,this.packages=n.packages;let i=S(this.d.locales),p=String(this.d.default_locale??""),l=n.locale;te(i,l)||(l=l.split("-")[0]??"",te(i,l)||(l=p)),this.lang=l;for(let y of[p,l])for(let[g,h]of Object.entries(S(i[y])))typeof h=="string"&&(this.texts[g]=h);let f=S(this.d.theme);this.palette=S(S(f.colors)[n.appearance]);for(let[y,g]of Object.entries(S(f.typography))){let h={};for(let[w,v]of Object.entries(ee.typography)){let A=X(S(g)[w],v.def);A!=null&&(h[w]=A)}this.typography[y]=h}this.radii=S(f.radii),this.spacing=S(f.spacing)}resolve(){let[t,n]=this.initialState();this.tab=t,this.selected=n;let i={selected:n,theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};for(let l of["header","root","footer"]){let f=this.d[l];if(typeof f=="object"&&f!==null){let y=this.component(S(f),l,"",!1);y&&(i[l]=y)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let l={};for(let[f,y]of Object.entries(S(this.d.sheets))){let g=this.component(S(S(y).root),`sheets.${f}.root`,"",!1);g&&(l[f]=g);let h=this.text(S(y).title,this.packages[this.selected]);h!==null&&(p[f]=h)}i.sheets=l}return{tree:i,pathOf:l=>this.paths.get(l),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,n){return this.opts.switches&&Object.hasOwn(this.opts.switches,n)?this.opts.switches[n]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,n){let p=J(t.tabs).map(S).map(f=>String(f.id)),l=this.opts.tabs?.[n];return l!==void 0&&p.includes(l)?l:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:p[0]??""}initialState(){let t="",n="",i="",p="",l=(y,g)=>{if(Array.isArray(y)){y.forEach((w,v)=>l(w,`${g}[${v}]`));return}if(typeof y!="object"||y===null)return;let h=y;switch(h.type){case"package":{let w=`${h.product}.${h.plan}`;i===""&&(i=w),h.selected===!0&&n===""&&(n=w);break}case"switch":{let w=this.switchOn(h,g),v=w?h.on_package:h.off_package;typeof v=="string"&&p===""&&(p=v),l(w?h.on:h.off,`${g}.${w?"on":"off"}`);return}case"tabs":{let w=this.tabShown(h,g);t===""&&(t=w),J(h.tabs).forEach((v,A)=>{let x=S(v);x.id===w&&(typeof x.package=="string"&&p===""&&(p=x.package),l(x.content,`${g}.tabs[${A}].content`))});return}}for(let w of Object.keys(h).sort())w!=="sheets"&&l(h[w],g===""?w:`${g}.${w}`)};for(let y of["header","root","footer"])l(this.d[y],y);let f=this.opts.selected||p||n||i;return[t,f]}holds(t,n){let i=n||this.selected;for(let[p,l]of Object.entries(t))switch(p){case"selected_package":if(!J(l).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(i)!==l)return!1;break;case"platform":if(!J(l).includes(this.opts.platform))return!1;break;case"locale":if(!J(l).includes(this.opts.locale)&&!J(l).includes(this.lang))return!1;break;case"appearance":if(l!==this.opts.appearance)return!1;break;case"tab":if(l!==this.tab)return!1;break}return!0}component(t,n,i,p){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(S(t.visible),i))return null;let l=String(t.type),f=i,y=p;l==="package"&&(f=`${t.product}.${t.plan}`,y=f===this.selected);let g={type:l};this.paths.set(g,n),te(t,"id")&&(g.id=t.id);let h={...S(t.style)};y&&Object.assign(h,S(S(t.states).selected)),Object.keys(h).length>0&&(g.style=this.style(h)),typeof t.animation=="object"&&t.animation!==null&&(g.animation=this.defaults(S(t.animation),ee.animation));let w=this.packages[f||this.selected];switch(l){case"tabs":return this.tabs(t,g,n,f);case"switch":return this.switchOf(t,g,n,f,y);case"countdown":return this.countdown(t,g,n,f,y);case"purchase_button":{let v=typeof t.package=="string"?t.package:this.selected;g.package=v;let A=this.component(S(t.content),`${n}.content`,v,y);return A?(g.content=A,g):null}case"package":g.product=t.product,g.plan=t.plan,g.selected=y}for(let[v,A]of Object.entries(lt[l]??{})){if(l==="package"&&(v==="product"||v==="plan"||v==="selected"))continue;let x=t[v],R=te(t,v);switch(A.kind){case"component":{if(!R)continue;let b=this.component(S(x),`${n}.${v}`,f,y);if(!b&&A.required)return null;b&&(g[v]=b);break}case"components":{let b=[];J(x).forEach((T,C)=>{let K=this.component(S(T),`${n}.${v}[${C}]`,f,y);K&&b.push(K)}),g[v]=b;break}case"text":{let b=this.text(x,w);if(b!==null)g[v]=b;else if(A.required||l==="text"&&v==="text"&&R)return null;break}case"list":{let b=[];for(let T of J(x)){let C=this.item(A.item,S(T),w);C&&b.push(C)}if(l==="text"&&b.length===0&&R)return null;R&&(g[v]=b);break}case"object":{R?g[v]=this.object(S(x),A.item,w):v==="indicator"&&(g[v]=this.object({},A.item,w));break}case"value":{let b=this.value(X(x,A.def),A);b!=null&&b!==""&&(g[v]=b);break}}}return l==="text"&&this.typeStyle(g),g}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let n=this.typography[t.size];for(let i of["font","weight","line_height","letter_spacing","text_style"])!te(t,i)&&n?.[i]!==void 0&&n?.[i]!==null&&(t[i]=n[i]);t.size=n?.size??null}tabs(t,n,i,p){let l=this.tabShown(t,i);this.tabsShown[i]=l;let f=[];return J(t.tabs).forEach((y,g)=>{let h=S(y),w=h.id===l,v=this.component(S(h.label),`${i}.tabs[${g}].label`,p,w);if(f.push({id:h.id,selected:w,label:v}),w){let A=this.component(S(h.content),`${i}.tabs[${g}].content`,p,!1);A&&(n.content=A)}}),n.tabs=f,typeof t.bar=="object"&&t.bar!==null&&(n.bar=this.style(S(t.bar))),n}switchOf(t,n,i,p,l){let f=this.switchOn(t,i);this.switchesOn[i]=f,n.on=f;let y=this.text(t.label,this.packages[p||this.selected]);y!==null&&(n.label=y),n.tint=this.color(String(X(t.tint,"accent")));let g=f?"on":"off",h=this.component(S(t[g]),`${i}.${g}`,p,l);return h&&(n.content=h),n}countdown(t,n,i,p,l){let f=S(t.target),y=this.opts.now??Date.now(),g;if(typeof f.after_open_seconds=="number"?g=Math.trunc(f.after_open_seconds)-(this.opts.openedSecondsAgo??0):g=Math.trunc((Date.parse(String(f.at))-y)/1e3),g>0){n.state="counting",n.remaining_seconds=g,this.countdowns[i]=g;let h=this.packages,w={};for(let[A,x]of Object.entries(h))w[A]={...x,...cn(g)};this.packages=w;let v=this.component(S(t.counting),`${i}.counting`,p,l);return v&&(n.content=v),this.packages=h,n}if(n.state="ended",n.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let h=this.component(S(t.ended),`${i}.ended`,p,l);h&&(n.content=h)}return n}item(t,n,i){let p={};for(let[l,f]of Object.entries(ee[t]??{})){let y=n[l];if(f.kind==="text"){let g=this.text(y,i);if(g!==null)p[l]=g;else if(f.required)return null}else{let g=f.def,h=this.value(X(y,g),f);h!=null&&(te(n,l)||g!=null&&g!=="")&&(p[l]=h)}}return p}object(t,n,i){return n==="style"?this.style(t):this.item(n,t,i)??{}}defaults(t,n){let i={};for(let[p,l]of Object.entries(n)){let f=X(t[p],l.def);f!=null&&f!==""&&(i[p]=f)}return i}style(t){let n={};for(let[i,p]of Object.entries(t)){let l=ee.style[i];if(!l){n[i]=p;continue}switch(l.kind){case"edges":n[i]=this.sides(p,on,this.spacing);break;case"corners":n[i]=this.sides(p,an,this.radii);break;case"fill":n[i]=this.fill(p);break;case"object":{let f=S(p),y={};for(let[g,h]of Object.entries(ee[l.item]??{})){let w=X(f[g],h.def);w!=null&&w!==""&&(y[g]=this.value(w,h))}n[i]=y;break}default:n[i]=p}}return n}sides(t,n,i){let p={};for(let l of n){let f=typeof t=="object"&&t!==null?X(S(t)[l],0):t;p[l]=$e(f,i)}return p}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let n=S(t),i=this.defaults(n,ee[rn[String(n.type)]??""]??{});return Array.isArray(n.stops)&&(i.stops=n.stops.map(p=>({color:this.color(String(S(p).color)),at:S(p).at}))),i}value(t,n){if(n.kind!=="value")return t;switch(n.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 n=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof n=="string"?n:t}text(t,n){let i;if(typeof t=="string")i=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let l=t.t;i=typeof l=="string"&&Object.hasOwn(this.texts,l)?this.texts[l]:""}else return null;let p=!1;return i=i.replace(ln,(l,f)=>{let y=n&&Object.hasOwn(n,f)?n[f]:void 0;return typeof y!="string"||y===""?(p=!0,""):y}),p||i.trim()===""?null:i}};function $e(s,t){return typeof s=="string"?Object.hasOwn(t,s)?t[s]:null:s}var dn={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(s,t)=>`${s} of ${t}`},ne={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'},pn=1.35,pt=20,un=new Set(["button","purchase_button","package","text"]),fn=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),ut={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)"},gn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},hn={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},yn={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},mn={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},wn=`
|
|
3
3
|
:host{display:block;height:100%}
|
|
4
4
|
.pw2{position:relative;box-sizing:border-box;display:flex;flex-direction:column;height:100%;overflow:hidden;font-family:${ne.system};font-size:1rem;line-height:1.3;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;text-rendering:optimizeLegibility}
|
|
5
5
|
.pw2 *,.pw2 *::before,.pw2 *::after{box-sizing:border-box}
|
|
@@ -89,4 +89,4 @@ button.pw-c:disabled{cursor:default;opacity:.5}
|
|
|
89
89
|
[data-pw-hover]:not([data-pw-highlight]){outline:1px dashed #2E7CF6aa!important;outline-offset:-1px}
|
|
90
90
|
.pw-editing button,.pw-editing .pw-pkg,.pw-editing a{cursor:default}
|
|
91
91
|
@media (prefers-reduced-motion:reduce){.pw2 *{transition:none!important;scroll-behavior:auto!important}}
|
|
92
|
-
`,ye=s=>{if(typeof s!="string"||s.length>2048)return!1;try{let t=new URL(s);return t.protocol==="https:"&&t.hostname!==""&&t.username===""&&t.password===""}catch{return!1}},bn=s=>`${String(s.product)}.${String(s.plan)}`,Te=s=>{let[t,n]=s.split(".");return{product:t??"",plan:n??""}},_=s=>`${Number(s)||0}px`,ft=s=>`${s/16}rem`,vn=0;function gt(s,t,n){let i=s.ownerDocument,p=i.defaultView,l=`pw${++vn}`,f=i.createElement("div");f.setAttribute("data-palbase-paywall",""),f.style.display="block",f.style.height="100%";let y=f.attachShadow({mode:"open"});kn(i,y,wn);let g=i.createElement("div");g.className="pw2";let h=i.createElement("div");h.className="pw2-head";let w=i.createElement("div");w.className="pw2-body";let v=i.createElement("div");v.className="pw2-foot";let A=i.createElement("div");g.append(h,w,v),y.append(g),s.replaceChildren(f);let x={...t},R={openedAt:Date.now(),...t.state},b,T=new Map,C=new Map,K=!1,be=null,ve,Oe=!1,Fe=i.defaultView?.ResizeObserver,Ce=typeof Fe=="function"?new Fe(()=>{g.classList.toggle("pw2-large",Ne()>=pt),xe()}):null;Ce?.observe(g);let He=()=>xe();i.fonts?.addEventListener?.("loadingdone",He);let je=null,ke=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),re=()=>x.reduceMotion??ke?.matches??!1,H=()=>!!n.editor,le={...dn,...n.labels};function G(){let e=R.now??Date.now();b=dt(x.definition,{locale:x.locale,appearance:x.appearance,platform:x.platform??"web",packages:x.packages,eligible:x.eligible??[],...R.selected?{selected:R.selected}:{},tabs:R.tabs??{},switches:R.switches??{},openedSecondsAgo:Math.max(0,Math.floor((e-(R.openedAt??e))/1e3)),now:e});let c=b.tree.theme.colors;g.style.background=c.background??"",g.style.color=c.text??"",g.classList.toggle("pw-editing",H()),g.classList.toggle("pw2-large",Ne()>=pt),g.lang=b.language,g.dir=fn.has(b.language.split("-")[0]??"")?"rtl":"ltr",C=new Map,Pe(h,b.tree.header,"vertical"),Pe(w,b.tree.root,"vertical"),Pe(v,b.tree.footer,"vertical"),h.hidden=!b.tree.header,v.hidden=!b.tree.footer,w.classList.toggle("pw2-top",!b.tree.header),w.classList.toggle("pw2-bottom",!b.tree.footer),Nt();for(let[o,r]of T)C.has(o)||r.cleanup.forEach(a=>a());T=C,be&&We(be);for(let o of T.values())o.type==="custom_html"&&qe(o.el);xe(),clearTimeout(ve),Oe||=f.isConnected,R.now===void 0&&Object.keys(b.countdowns).length>0&&(ve=setTimeout(()=>{Oe&&!f.isConnected||G()},1e3-Date.now()%1e3+5))}function Ne(){let e=i.documentElement,c=e&&p?parseFloat(p.getComputedStyle(e).fontSize):NaN;return Number.isFinite(c)?c:16}function xe(){let e=[];for(let o of T.values()){if(o.type!=="text")continue;let r=o.el,a=r.dataset.pwFit??r.style.fontSize;if(!a||(r.style.fontSize=a,delete r.dataset.pwFit,!/^\S+$/.test(r.textContent??"")))continue;let d=r.parentElement,u=d&&p?p.getComputedStyle(d):null,k=d&&u?d.clientWidth-parseFloat(u.paddingLeft||"0")-parseFloat(u.paddingRight||"0"):1/0,M=Math.min(r.clientWidth,k);e.push({e:r,base:a,k:M<=0||r.scrollWidth<=M+.5?1:Math.max(.6,M/r.scrollWidth)})}let c=o=>o.closest(".pw-stack.h");for(let o of e){let r=Math.min(o.k,...e.filter(a=>a!==o&&a.base===o.base&&c(a.e)&&c(a.e)===c(o.e)).map(a=>a.k));r>=1||(o.e.dataset.pwFit=o.base,o.e.style.fontSize=`calc(${o.base} * ${r.toFixed(3)})`)}}function Pe(e,c,o){let r=c?U(c,o,{inControl:!1,inSheet:!1,inFooter:e===v}):null;V(e,r?[r]:[])}function U(e,c,o){let r=b.pathOf(e)??"",a=vt(e),d=T.get(r),u;if(d&&d.type===e.type&&d.key===a&&d.axis===c&&!C.has(r))u=d;else{let M=xt(e,r,c,o);if(!M)return null;u={el:M.el,type:e.type,key:a,styleKey:"",axis:c,slots:M.slots,cleanup:M.cleanup??[]},u.el.classList.add("pw-c"),u.el.dataset.pwPath=r,u.el.dataset.pwType=e.type,e.id&&(u.el.dataset.pwId=e.id),d&&d.cleanup.forEach(L=>L()),Ot(u.el,e)}let k=`${JSON.stringify(e.style??null)}|${c}`;return u.styleKey!==k&&(De(u.el,e,c),u.styleKey=k),C.set(r,u),$t(u,e),Tt(u,e,o),u.el}function vt(e){let c=new Set(["style",...yn[e.type]??[],...mn[e.type]??[]]),o={};for(let[r,a]of Object.entries(e))c.has(r)||(o[r]=a);return e.type==="tabs"&&(o.tabs=e.tabs.map(r=>r.id)),e.type==="carousel"&&(o.pages=e.pages.length),e.type==="stack"&&(o.greedy=e.children.some(r=>r.type==="spacer"&&typeof r.size!="number")),(e.type==="image"||e.type==="video"||e.type==="custom_html")&&(o.asset=kt(e)),JSON.stringify(o)}function kt(e){let c=ie(e.src);return c?(x.assets?.[c]?.url??x.assets?.[c]?.html?.length??"none").toString():""}function P(e,c){let o=i.createElement(e);return c&&(o.className=c),o}function xt(e,c,o,r){let a=e;switch(e.type){case"stack":{let d=P("div",`pw-stack${a.axis==="horizontal"?" h":a.axis==="z"?" z":""}${a.scroll?" scroll":""}`);return a.axis!=="z"&&a.children.some(u=>u.type==="spacer"&&typeof u.size!="number")&&d.classList.add(a.axis==="horizontal"?"greedy-h":"greedy-v"),d.style.gap=_(a.spacing),a.axis==="z"?d.style.placeItems=a.align==="stretch"?"stretch":String(a.align??"center"):(d.style.alignItems=gn[String(a.align)]??"center",d.style.justifyContent=hn[String(a.distribution)]??"flex-start"),{el:d,slots:{children:d}}}case"text":return{el:Pt(a,r),slots:{}};case"icon":{let d=ue[String(a.name)];if(!d)return null;let u=P("span","pw-icon");return u.style.color=String(a.color??""),u.append(fe(i,d,Number(a.size)||24)),u.setAttribute("aria-hidden","true"),{el:u,slots:{}}}case"image":return Mt(a);case"video":return St(a);case"features":{let d=P("ul","pw-features");d.style.gap=_(a.spacing);for(let u of a.items??[]){let k=P("li","pw-feature"),M=ue[u.icon];if(M){let z=fe(i,M,22);z.style.color=String(a.icon_color),z.style.flex="none",k.append(z)}let L=P("span");L.textContent=u.text,L.style.color=String(a.color),k.append(L),d.append(k)}return{el:d,slots:{}}}case"timeline":{let d=P("ol","pw-timeline");d.style.gap=_(a.spacing),d.style.setProperty("--pw-gap",_(a.spacing)),d.style.setProperty("--pw-line-w",_(a.line_width));for(let u of a.items??[]){let k=P("li","pw-step"),M=P("span","pw-dot");M.style.background=u.color??String(a.line_color),M.style.color=String(a.icon_color);let L=ue[u.icon];L&&M.append(fe(i,L,18)),M.setAttribute("aria-hidden","true");let z=P("span","pw-line");z.style.background=String(a.line_color),z.setAttribute("aria-hidden","true");let D=P("span");D.style.color=String(a.color);let B=P("span","pw-step-title");if(B.textContent=u.title,D.append(B),u.text){let $=P("span","pw-step-text");$.style.display="block",$.textContent=u.text,D.append($)}k.append(M,D,z),d.append(k)}return{el:d,slots:{}}}case"spacer":{let d=P("div","pw-spacer");return d.setAttribute("aria-hidden","true"),typeof a.size=="number"&&(d.style.flex="none",o==="horizontal"?d.style.width=_(a.size):d.style.height=_(a.size)),{el:d,slots:{}}}case"divider":{let d=P("div","pw-divider");return d.setAttribute("role","separator"),d.style.background=String(a.color),d.style.alignSelf="stretch",d.style.flex="none",o==="horizontal"?(d.setAttribute("aria-orientation","vertical"),d.style.width=_(a.thickness)):d.style.height=_(a.thickness),{el:d,slots:{}}}case"button":return Rt(a,r);case"purchase_button":{let d=P("button","pw-buy");return d.type="button",d.addEventListener("click",()=>{Ve(d,()=>jt(d.dataset.package??""))}),{el:d,slots:{content:d}}}case"package":{let d=P("div","pw-pkg");return d.setAttribute("role","radio"),d.addEventListener("click",()=>Re(d)),d.addEventListener("keydown",u=>Ft(u,d)),{el:d,slots:{children:d}}}case"tabs":return _t(a,c);case"switch":return Et(a,c);case"carousel":return Lt(a);case"countdown":{let d=P("div","pw-countdown");return d.setAttribute("role","timer"),d.setAttribute("aria-live","off"),{el:d,slots:{content:d}}}case"custom_html":{let d=x.assets?.[ie(a.src)??""];if(!d?.html)return null;let u=P("iframe","pw-html");return u.setAttribute("sandbox","allow-scripts"),u.setAttribute("aria-hidden","true"),u.setAttribute("title",""),u.tabIndex=-1,u.srcdoc=d.html,typeof a.height=="number"?u.style.height=_(a.height):typeof a.height=="string"&&a.height.endsWith("%")?u.style.height=a.height:a.height==="fill"&&(u.style.flex="1 1 0"),u.addEventListener("load",()=>qe(u)),{el:u,slots:{}}}default:return null}}function Pt(e,c){let o=String(e.text_style??"body"),r=c.inControl?"span":o==="large_title"?"h1":o==="title"||o==="title2"?"h2":o==="title3"?"h3":"p",a=P(r,"pw-text");c.inControl&&(a.style.display="block"),a.style.fontFamily=At(e.font);let d=typeof e.size=="number"?e.size:16;if(c.inFooter?(a.style.setProperty("--pw-fs",ft(d)),a.style.setProperty("--pw-fs-max",`${Number((d*pn).toFixed(2))}px`)):a.style.fontSize=ft(d),typeof e.weight=="number"&&(a.style.fontWeight=String(e.weight)),typeof e.line_height=="number"&&(a.style.lineHeight=String(e.line_height)),typeof e.letter_spacing=="number"&&e.letter_spacing!==0&&(a.style.letterSpacing=_(e.letter_spacing)),a.style.textAlign=String(e.align??"center"),e.uppercase===!0&&(a.style.textTransform="uppercase"),typeof e.max_lines=="number"&&(a.classList.add("pw-clamp"),a.style.setProperty("-webkit-line-clamp",String(e.max_lines))),typeof e.color=="string"?a.style.color=e.color:e.color&&typeof e.color=="object"&&(a.classList.add("pw-grad"),a.style.backgroundImage=Me(e.color)??""),Array.isArray(e.spans))for(let u of e.spans){let k=u.link==="terms"?x.links?.terms:u.link==="privacy"?x.links?.privacy:u.link,M=ye(k)&&!c.inControl,L=P(M?"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),M&&ye(k)&&(L.href=k,L.target="_blank",L.rel="noopener noreferrer",L.addEventListener("click",D=>{H()||!n.onLink||(D.preventDefault(),n.onLink(k))})),a.append(L)}else a.textContent=String(e.text??"");return a}function At(e){if(typeof e!="string")return ne.system;let c=ie(e);if(c){let o=x.assets?.[c]?.family;return o?`"${o}", ${ne.system}`:ne.system}return ne[e]??ne.system}function Z(e){let c=ie(e);return c?x.assets?.[c]?.url||void 0:ye(e)?e:void 0}function Mt(e){let c=P("div","pw-img");typeof e.aspect=="number"&&(c.style.aspectRatio=String(e.aspect));let o=Z(e.src),r=e.mask;if(r?.shape==="circle")c.style.borderRadius="50%";else if(r?.shape==="rect"&&r.radius)c.style.borderRadius=_(r.radius);else if(r?.shape==="convex")c.style.setProperty("border-end-start-radius",`50% ${_(r.depth)}`),c.style.setProperty("border-end-end-radius",`50% ${_(r.depth)}`);else if(r?.shape==="concave"){let a=`radial-gradient(ellipse 50% ${_(r.depth)} at 50% 100%, transparent 98%, #000 100%)`;c.style.setProperty("-webkit-mask-image",a),c.style.setProperty("mask-image",a)}if(o){let a=P("img");a.src=o,a.decoding="async",a.style.objectFit=e.fit==="fill"?"cover":"contain",e.decorative===!0?(a.alt="",c.setAttribute("aria-hidden","true")):a.alt=String(e.alt??""),a.addEventListener("error",()=>a.style.visibility="hidden"),c.append(a)}if(e.overlay&&typeof e.overlay=="object"){let a=P("div","pw-overlay");a.style.backgroundImage=Me(e.overlay)??"",c.append(a)}return{el:c,slots:{}}}function St(e){let c=P("div","pw-img");typeof e.aspect=="number"&&(c.style.aspectRatio=String(e.aspect));let o=Z(e.src);if(o){let r=P("video");r.src=o;let a=Z(e.poster);a&&(r.poster=a),r.muted=e.mute!==!1,r.loop=e.loop!==!1,r.playsInline=!0,r.controls=e.controls===!0,r.preload="auto",r.style.objectFit=e.fit==="fit"?"contain":"cover",r.autoplay=e.autoplay!==!1&&!re()&&!H(),typeof e.alt=="string"?r.setAttribute("aria-label",e.alt):r.setAttribute("aria-hidden","true"),c.append(r)}return{el:c,slots:{}}}function Rt(e,c){let o=e.action??{},r,a=o.type==="restore"||o.type==="offer_code";switch(o.type){case"close":c.inSheet?r=()=>pe(null):n.onClose&&(r=()=>n.onClose());break;case"restore":n.onRestore&&(r=()=>n.onRestore());break;case"offer_code":n.onOfferCode&&(x.platform??"web")!=="web"&&(r=()=>n.onOfferCode());break;case"open_url":case"terms":case"privacy":{let u=o.type==="open_url"?o.url:o.type==="terms"?x.links?.terms:x.links?.privacy;ye(u)&&(r=()=>n.onLink?n.onLink(u):void p?.open(u,"_blank","noopener,noreferrer"));break}case"sheet":o.sheet&&(r=()=>pe(o.sheet));break;case"select_package":o.package&&(r=()=>Se(o.package));break}if(!r&&!H())return null;let d=P("button");return d.type="button",o.type==="close"&&d.setAttribute("aria-label",le.close),d.addEventListener("click",()=>{!r||H()||(a?Ve(d,r):r())}),{el:d,slots:{content:d}}}function _t(e,c){let o=P("div","pw-tabs"),r=P("div","pw-tablist");r.setAttribute("role","tablist");let a=P("div","pw-tabpanel");a.setAttribute("role","tabpanel"),a.id=`${l}-${c}-panel`;let d={content:a},u=e.tabs.map(k=>k.id);return u.forEach((k,M)=>{let L=P("button","pw-tab");L.type="button",L.setAttribute("role","tab"),L.id=`${l}-${c}-tab-${M}`,L.setAttribute("aria-controls",a.id),L.dataset.tab=k,L.addEventListener("click",()=>Je(c,k)),L.addEventListener("keydown",z=>{let D=z.key==="ArrowRight"?M+1:z.key==="ArrowLeft"?M-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(c,B),r.querySelector(`[data-tab="${B}"]`)?.focus()}),r.append(L),d[`label:${k}`]=L}),o.append(r,a),d.bar=r,{el:o,slots:d}}function Et(e,c){let o=P("div","pw-switch"),r=P("div","pw-switchrow"),a=P("span","pw-switchlabel");a.id=`${l}-${c}-label`;let d=P("button","pw-toggle");d.type="button",d.setAttribute("role","switch"),d.setAttribute("aria-labelledby",a.id),d.append(P("i")),d.addEventListener("click",()=>Ht(c,d.getAttribute("aria-checked")!=="true")),r.append(a,d);let u=P("div","pw-switchcontent");return o.append(r,u),{el:o,slots:{content:u,label:a,toggle:d}}}function Lt(e){let c=P("div","pw-carousel");c.setAttribute("role","region"),c.setAttribute("aria-roledescription","carousel");let o=P("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 r=e.indicator??{},a=P("div",`pw-dots ${r.style??"dots"}`);a.style.setProperty("--pw-dot",_(r.size??8)),a.style.setProperty("--pw-dot-gap",_(r.spacing??6)),a.style.setProperty("--pw-dot-c",r.color??"#8888"),a.style.setProperty("--pw-dot-on",r.active_color??"currentColor"),r.style==="none"&&(a.hidden=!0),c.append(o,a);let d=()=>[...o.children].filter($=>$ instanceof(p?.HTMLElement??HTMLElement)),u=()=>{let $=d(),j=o.scrollLeft+o.clientWidth/2,O=0;return $.forEach((I,It)=>{Math.abs(I.offsetLeft+I.offsetWidth/2-j)<Math.abs(($[O]?.offsetLeft??0)+($[O]?.offsetWidth??0)/2-j)&&(O=It)}),O},k=$=>{let j=d();if(j.length===0)return;let O=e.loop?($+j.length)%j.length:Math.max(0,Math.min(j.length-1,$)),I=j[O];o.scrollTo?.({left:I.offsetLeft-(o.clientWidth-I.offsetWidth)/2,behavior:re()?"auto":"smooth"}),M(O)},M=$=>{[...a.children].forEach((j,O)=>j.setAttribute("aria-current",String(O===$)))};o.addEventListener("scroll",()=>M(u()),{passive:!0}),o.addEventListener("keydown",$=>{$.key!=="ArrowRight"&&$.key!=="ArrowLeft"||($.preventDefault(),k(u()+($.key==="ArrowRight"?1:-1)))});let L=!1,z=()=>L=!0,D=()=>L=!1;c.addEventListener("pointerenter",z),c.addEventListener("pointerleave",D),c.addEventListener("focusin",z),c.addEventListener("focusout",D);let B=[];if(typeof e.auto_advance_ms=="number"){let $=setInterval(()=>{if(L||re()||H())return;let j=d(),O=u();!e.loop&&O>=j.length-1||k(O+1)},e.auto_advance_ms);B.push(()=>clearInterval($))}return c.pwDots=$=>{a.children.length!==$&&(a.replaceChildren(...Array.from({length:$},(j,O)=>{let I=P("button");return I.type="button",I.setAttribute("aria-label",le.page(O+1,$)),I.addEventListener("click",()=>k(O)),I})),M(u()))},{el:c,slots:{pages:o},cleanup:B}}function $t(e,c){let o=c;switch(c.type){case"package":{let r=bn(o),d=!!x.packages[r]?.price;e.el.dataset.package=r,e.el.setAttribute("aria-checked",String(o.selected===!0)),e.el.setAttribute("aria-disabled",String(!d));break}case"purchase_button":{let r=String(o.package);e.el.dataset.package=r,e.el.disabled=K||!x.packages[r]?.price;break}case"switch":{let r=e.slots.toggle;r.setAttribute("aria-checked",String(o.on===!0)),r.style.setProperty("--pw-tint",String(o.tint??"")),r.style.setProperty("--pw-off",`color-mix(in srgb, ${b.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 r of o.tabs){let a=e.slots[`label:${r.id}`];a.setAttribute("aria-selected",String(r.selected)),a.tabIndex=r.selected?0:-1,r.selected&&e.slots.content.setAttribute("aria-labelledby",a.id)}o.bar&&De(e.slots.bar,{type:"stack",style:o.bar},"vertical");break}}}function Tt(e,c,o){let r=c,a={...o,inControl:o.inControl||c.type==="button"||c.type==="purchase_button"||c.type==="package"};switch(c.type){case"stack":case"package":{let d=c.type==="stack"?String(r.axis??"vertical"):"vertical",u=r.children.map(M=>[M,U(M,d,a)]).filter(M=>M[1]!==null),k=u.map(M=>M[1]);V(e.slots.children,k),zt(d,u),c.type==="stack"&&ce(e.el,k);break}case"button":case"purchase_button":{let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]);break}case"countdown":case"switch":{let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]),ce(e.slots.content,d?[d]:[]);break}case"tabs":{for(let u of r.tabs){let k=u.label?U(u.label,"vertical",{...a,inControl:!0}):null;V(e.slots[`label:${u.id}`],k?[k]:[])}let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]),ce(e.slots.content,d?[d]:[]);break}case"carousel":{let d=r.pages.map(u=>U(u,"page",a)).filter(Boolean);d.forEach((u,k)=>{u.setAttribute("role","group"),u.setAttribute("aria-roledescription","slide"),u.setAttribute("aria-label",le.page(k+1,d.length))}),V(e.slots.pages,d),ce(e.slots.pages,d),e.el.pwDots?.(d.length);break}}}function zt(e,c){let o=e==="horizontal"?"width":e==="vertical"?"height":null;if(!o)return;let r=u=>u?o==="width"?u.leading+u.trailing:u.top+u.bottom:0,a=c.filter(([u])=>u.style?.[o]==="fill"),d=Math.max(0,...a.map(([u])=>r(u.style?.padding)+r(u.style?.margin)));for(let[u,k]of a)k.style.flexBasis=_(d-r(u.style?.margin))}function ce(e,c){let o=c.filter(a=>a.dataset.pwType==="package");if(o.length===0){e.getAttribute("role")==="radiogroup"&&e.removeAttribute("role");return}e.setAttribute("role","radiogroup"),e.setAttribute("aria-label",le.packages);let r=o.find(a=>a.getAttribute("aria-checked")==="true")??o[0];for(let a of o)a.tabIndex=a===r?0:-1}function V(e,c){let o=()=>[...e.children].filter(a=>a.dataset?.pwPath!==void 0),r=o();for(let a of r)c.includes(a)||a.remove();r=o(),c.forEach((a,d)=>{r[d]!==a&&(e.insertBefore(a,r[d]??null),r=o())})}let Ae=new WeakMap;function E(e,c,o){e.style.setProperty(c,o),Ae.get(e).push(c)}function De(e,c,o){for(let u of Ae.get(e)??[])e.style.removeProperty(u);Ae.set(e,[]);for(let u of[...e.children])u.classList.contains("pw-bgvideo")&&u.remove();let r=c.style;if(c.type==="image"&&e.classList.toggle("natural",typeof c.aspect!="number"&&(r?.height===void 0||r.height==="fit")),!r)return;let a=(u,k)=>{k&&(E(e,`${u}-block-start`,_(k.top)),E(e,`${u}-block-end`,_(k.bottom)),E(e,`${u}-inline-start`,_(k.leading)),E(e,`${u}-inline-end`,_(k.trailing)))};a("padding",r.padding),a("margin",r.margin),Ie(e,"width",r.width,o),typeof r.height=="number"&&un.has(c.type)?(E(e,"min-height",_(r.height)),o==="vertical"&&E(e,"flex","none")):Ie(e,"height",r.height,o),typeof r.max_width=="number"&&E(e,"max-width",_(r.max_width));let d=r.background;if(d){if(d.type==="color")E(e,"background-color",d.color);else if(d.type==="linear"||d.type==="radial")E(e,"background-image",Me(d)??"");else if(d.type==="image"){let u=Z(d.src);u&&(E(e,"background-image",`url("${u.replace(/"/g,"%22")}")`),E(e,"background-size",d.fit==="fit"?"contain":"cover"),E(e,"background-position","center"),E(e,"background-repeat","no-repeat"))}else if(d.type==="video"){let u=Z(d.src);if(u){let k=P("video","pw-bgvideo");k.src=u;let M=Z(d.poster);M&&(k.poster=M),k.muted=!0,k.loop=d.loop!==!1,k.playsInline=!0,k.autoplay=!re()&&!H(),k.setAttribute("aria-hidden","true"),E(e,"isolation","isolate"),e.prepend(k)}}}if(r.border&&c.type==="custom_html"?E(e,"border",`${_(r.border.width)} solid ${r.border.color??"transparent"}`):r.border&&(E(e,"--pw-bw",_(r.border.width)),E(e,"--pw-bc",r.border.color??"transparent")),r.corners){let u=r.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)),(c.type==="image"||c.type==="video"||d?.type==="image"||d?.type==="video")&&E(e,"overflow","hidden")}r.shadow&&E(e,"box-shadow",`${_(r.shadow.x)} ${_(r.shadow.y)} ${_(r.shadow.radius)} ${r.shadow.color}`),typeof r.opacity=="number"&&r.opacity!==1&&E(e,"opacity",String(r.opacity))}function Ie(e,c,o,r){if(o==null||o==="")return;if(r==="page"){c==="height"&&E(e,"height",o==="fill"?"100%":typeof o=="number"?_(o):o==="fit"?"fit-content":String(o));return}let a=r==="horizontal"?"width":r==="vertical"?"height":null;o==="fill"?c===a?(E(e,"flex","1 1 0"),E(e,`min-${c}`,"0")):r==="z"?E(e,c,"100%"):(E(e,"align-self","stretch"),E(e,c,"auto")):o==="fit"?(c===a&&E(e,"flex","0 0 auto"),E(e,c,"fit-content")):(E(e,c,typeof o=="number"?_(o):String(o)),c===a&&E(e,"flex","none"))}function Me(e){let c=o=>o.map(r=>`${r.color} ${(r.at*100).toFixed(2)}%`).join(", ");if(e.type==="linear")return`linear-gradient(${e.angle}deg, ${c(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)}%, ${c(e.stops)})`}}function Ot(e,c){let o=c.animation;if(!o||x.animate===!1||re()||typeof e.animate!="function")return;let r=24,d={fade:{opacity:0},slide_up:{opacity:0,transform:`translateY(${r}px)`},slide_down:{opacity:0,transform:`translateY(-${r}px)`},slide_leading:{opacity:0,transform:`translateX(-${r}px)`},slide_trailing:{opacity:0,transform:`translateX(${r}px)`},scale:{opacity:0,transform:"scale(0.92)"}}[o.type];d&&e.animate([d,{opacity:1,transform:"none"}],{duration:o.duration_ms,delay:o.delay_ms,easing:ut[o.easing]??ut.ease_out,fill:"backwards"})}function de(){n.onState?.({...R}),G()}function Se(e){R.selected===e&&b.tree.selected===e||(R.selected=e,de(),n.onSelect?.(Te(e)))}function Re(e){H()||e.getAttribute("aria-disabled")==="true"||Se(e.dataset.package??"")}function Ft(e,c){if(e.key===" "||e.key==="Enter"){e.preventDefault(),Re(c);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 r=c.closest("[role=radiogroup]"),d=(r?[...r.children].filter(M=>M.dataset.pwType==="package"):[c]).filter(M=>M.getAttribute("aria-disabled")!=="true"),u=d.indexOf(c),k=d[(u+o+d.length)%d.length];k&&(Re(k),(T.get(k.dataset.pwPath??"")?.el??k).focus())}function Je(e,c){if(H())return;R.tabs={...R.tabs,[e]:c};let o=Ct(e,c);o&&(R.selected=o),de()}function Ct(e,c){return Ue(e)?.tabs?.find(r=>r.id===c)?.package}function Ht(e,c){if(H())return;R.switches={...R.switches,[e]:c};let o=Ue(e),r=c?o?.on_package:o?.off_package;r&&(R.selected=r),de()}function Ue(e){let c=x.definition;for(let o of e.match(/[^.[\]]+/g)??[])c=c?.[/^\d+$/.test(o)?Number(o):o];return c}async function Ve(e,c){if(!(H()||K)){K=!0,e.disabled=!0,e.setAttribute("aria-busy","true");try{await c()}finally{K=!1,e.removeAttribute("aria-busy"),e.disabled=!1;for(let o of T.values())o.type==="purchase_button"&&(o.el.disabled=!x.packages[o.el.dataset.package??""]?.price)}}}async function jt(e){x.packages[e]?.price&&await n.onPurchase(Te(e))}function pe(e){H()&&e!==null&&R.sheet===e||(e&&!R.sheet&&(je=y.activeElement??null),R.sheet=e,de(),e||je?.focus())}function Nt(){let e=R.sheet,c=e?b.tree.sheets?.[e]:void 0;if(!c){A.remove();return}A.className="pw-layer";let o=A.firstElementChild;if(!o){o=P("div","pw-sheet"),o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.tabIndex=-1;let a=P("div","pw-grab");a.setAttribute("aria-hidden","true"),o.append(a),A.append(o),A.addEventListener("click",d=>{d.target===A&&!H()&&pe(null)}),o.addEventListener("keydown",d=>Dt(d,o))}o.style.background=b.tree.theme.colors.background??"",o.setAttribute("aria-label",b.sheetTitles[e]??"");let r=U(c,"vertical",{inControl:!1,inSheet:!0});V(o,r?[r]:[]),A.isConnected||(g.append(A),queueMicrotask(()=>(Be(o)[0]??o).focus()))}function Be(e){return[...e.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')].filter(c=>!c.hidden)}function Dt(e,c){if(e.key==="Escape"){e.preventDefault(),pe(null);return}if(e.key!=="Tab")return;let o=Be(c);if(o.length===0){e.preventDefault();return}let r=o[0],a=o[o.length-1],d=y.activeElement;e.shiftKey&&d===r?(e.preventDefault(),a.focus()):!e.shiftKey&&d===a&&(e.preventDefault(),r.focus())}function qe(e){try{e.contentWindow?.postMessage({type:"palbase.paywall",package:b.tree.selected,locale:b.language,appearance:x.appearance},"*")}catch{}}function We(e){for(let c of y.querySelectorAll("[data-pw-highlight]"))c.removeAttribute("data-pw-highlight");be=e,e&&T.get(e)?.el.setAttribute("data-pw-highlight","")}let Ke=e=>e.composedPath().find(c=>c instanceof(p?.HTMLElement??HTMLElement)&&c.dataset.pwPath!==void 0);g.addEventListener("click",e=>{if(!n.editor)return;let c=Ke(e);c&&(e.preventDefault(),e.stopPropagation(),n.editor.onPick(c.dataset.pwPath))},!0),g.addEventListener("pointerover",e=>{if(n.editor){for(let c of y.querySelectorAll("[data-pw-hover]"))c.removeAttribute("data-pw-hover");Ke(e)?.setAttribute("data-pw-hover","")}}),g.addEventListener("pointerleave",()=>{for(let e of y.querySelectorAll("[data-pw-hover]"))e.removeAttribute("data-pw-hover")});let Xe=()=>G();return ke?.addEventListener?.("change",Xe),G(),{get selected(){return Te(b.tree.selected)},get state(){return{...R}},select(e){Se(e)},update(e){x={...x,...e},e.state&&Object.assign(R,e.state),G()},highlight(e){We(e)},replay(){for(let e of T.values())e.cleanup.forEach(c=>c());T=new Map;for(let e of[h,w,v])e.replaceChildren();G()},destroy(){clearTimeout(ve),Ce?.disconnect(),i.fonts?.removeEventListener?.("loadingdone",He),ke?.removeEventListener?.("change",Xe);for(let e of T.values())e.cleanup.forEach(c=>c());f.remove()}}}function kn(s,t,n){let i=s.defaultView;try{if(i&&"adoptedStyleSheets"in t&&typeof i.CSSStyleSheet=="function"){let l=new i.CSSStyleSheet;l.replaceSync(n),t.adoptedStyleSheets=[l];return}}catch{}let p=s.createElement("style");p.textContent=n,t.append(p)}var ht={version:"0.5.1"};var yt=`palbase-js/${ht.version}`;var we=class{placement;source;definition;assets;offerings;shown;deps;exposed=!1;constructor(t,n,i,p,l,f,y={}){this.placement=t,this.source=n,this.definition=i,this.assets=y,this.offerings=p,this.shown=l,this.deps=f}packages(t){return rt(Mn(this.offerings,ct(this.definition),t),t)}render(t,n){let i=n.locale??globalThis.navigator?.language??this.definition.default_locale,p=n.appearance===void 0?Pn():void 0,l=this.packages(i),f=gt(t,{definition:this.definition,locale:i,appearance:n.appearance??(p?.matches?"dark":"light"),platform:"web",packages:l,eligible:Object.entries(l).filter(([,h])=>h.trial).map(([h])=>h),links:n.links,assets:this.assets},{onPurchase:async h=>{try{let w=await this.deps.checkout({product:h.product,plan:h.plan,successUrl:n.successUrl,cancelUrl:n.cancelUrl});n.onCheckout?n.onCheckout(w,h):globalThis.location.assign(w)}catch(w){if(!n.onError)throw w;n.onError(w,h)}},onClose:n.onClose,onLink:n.onLink,labels:n.labels}),y=h=>f.update({appearance:h.matches?"dark":"light"});p?.addEventListener?.("change",y),!this.exposed&&this.shown&&(this.exposed=!0,this.deps.expose(this));let g=f.destroy.bind(f);return f.destroy=()=>{p?.removeEventListener?.("change",y),g()},f}};function Pn(){try{return globalThis.matchMedia?.("(prefers-color-scheme: dark)")}catch{return}}function An(s,t){if(!s)return;let n=t.split("-")[0];return s[t]?.name??s[n]?.name??Object.values(s).find(i=>i.name)?.name}function Mn(s,t,n){let i=[];for(let p of t){let[l,f]=p.split("."),y=s.products.find(w=>w.key===l),g=y?.channels.web,h=g?.plans.find(w=>w.key===f);!y||!g||!h||i.push({key:p,productName:An(g.locales,n)??y.key,price:{amount:h.price.amount,currency:h.price.currency},period:h.period,intro:h.intro})}return i}var Sn={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"}},mt=s=>({type:"button",action:{type:s},content:{type:"text",text:{t:s},size:"caption",color:"muted"}});function Rn(s){let t=s.products.flatMap(n=>(n.channels.web?.plans??[]).map(i=>({product:n.key,plan:i.key}))).slice(0,6);return t.length===0?null:{schema:2,name:"Default",default_locale:"en",locales:Sn,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:t.map(({product:n,plan:i})=>({type:"package",product:n,plan:i,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:[mt("terms"),mt("privacy")]}]}}}function se(){try{return globalThis.localStorage}catch{return}}function _n(s){try{let t=se()?.getItem(s);if(!t)return;let n=JSON.parse(t),i=n?.answer;return typeof i!="object"||i===null||typeof i.paywall_id!="string"||typeof i.version!="number"||typeof i.definition!="object"||i.definition===null||typeof i.offerings!="object"||i.definition.schema!==2?void 0:{etag:typeof n.etag=="string"?n.etag:void 0,answer:i}}catch{return}}function me(s,t){try{t?se()?.setItem(s,JSON.stringify(t)):se()?.removeItem(s)}catch{}}var wt=()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,bt;function En(s){let t=`palbase.installation.${s}`;try{let n=se()?.getItem(t);if(n&&/^[A-Za-z0-9._:-]{1,128}$/.test(n))return n;let i=wt();if(se()?.setItem(t,i),se()?.getItem(t)===i)return i}catch{}return bt??=wt(),bt}async function Zn(s,t,n,i,p={}){let{signal:l,fetch:f}=p,y=tt(p.attributes),g=`palbase.paywall.${t}.${n}`,h=En(t),v={checkout:i,expose:async b=>{if(b.shown)try{let T={paywall_id:b.shown.paywallId,version:b.shown.version,...b.shown.variant!==void 0?{variant:b.shown.variant}:{},...b.shown.ruleId!==void 0?{rule_id:b.shown.ruleId}:{}};await s.recordPaywallExposure({path:{placement:n},headers:{"X-Palbase-Installation":h},body:T})}catch{}}},A=async(b,T)=>new we(n,T,b.definition,b.offerings,{paywallId:b.paywall_id,version:b.version,...b.variant!==void 0?{variant:b.variant}:{},...b.rule_id!==void 0?{ruleId:b.rule_id}:{}},v,await Ge(b.assets??[],{signal:l,...f?{fetch:f}:{}})),x=_n(g),R;try{R=await s.getPlacementPaywall({path:{placement:n},query:{channel:"web"},headers:{"X-Palbase-Paywall-Schema":2,"X-Palbase-Installation":h,"X-Platform":"web","X-Palbase-SDK":yt,...p.appVersion?{"X-Palbase-Client-Version":p.appVersion}:{},...p.app?{"X-Palbase-App":p.app}:{},...p.locale?{"Accept-Language":p.locale}:{},...y!==void 0?{"X-Palbase-Attributes":y}:{},...x?.etag?{"If-None-Match":x.etag}:{}},signal:l})}catch(b){if(b instanceof oe&&b.status===404||b instanceof oe&&b.status===400&&b.code.startsWith("invalid_"))return me(g,void 0),ze(s,n,v,l);if(x&&!l?.aborted)return A(x.answer,"cache");throw b}return R.status===200?(me(g,{etag:R.headers.get("etag")??void 0,answer:R.data}),A(R.data,"server")):R.status===304&&x?A(x.answer,"server"):(me(g,void 0),ze(s,n,v,l))}async function ze(s,t,n,i){let p=(await s.getOfferings({query:{channel:"web"},signal:i})).data,l=Rn(p);return l?new we(t,"default",l,p,void 0,n):null}export{Ut as a,ie as b,Ge as c,qt as d,Yt as e,tt as f,_e as g,st as h,Qt as i,rt as j,ue as k,he as l,Fn as m,cn as n,ct as o,Cn as p,dt as q,gt as r,we as s,Rn as t,Zn as u};
|
|
92
|
+
`,ye=s=>{if(typeof s!="string"||s.length>2048)return!1;try{let t=new URL(s);return t.protocol==="https:"&&t.hostname!==""&&t.username===""&&t.password===""}catch{return!1}},bn=s=>`${String(s.product)}.${String(s.plan)}`,Te=s=>{let[t,n]=s.split(".");return{product:t??"",plan:n??""}},_=s=>`${Number(s)||0}px`,ft=s=>`${s/16}rem`,vn=0;function gt(s,t,n){let i=s.ownerDocument,p=i.defaultView,l=`pw${++vn}`,f=i.createElement("div");f.setAttribute("data-palbase-paywall",""),f.style.display="block",f.style.height="100%";let y=f.attachShadow({mode:"open"});kn(i,y,wn);let g=i.createElement("div");g.className="pw2";let h=i.createElement("div");h.className="pw2-head";let w=i.createElement("div");w.className="pw2-body";let v=i.createElement("div");v.className="pw2-foot";let A=i.createElement("div");g.append(h,w,v),y.append(g),s.replaceChildren(f);let x={...t},R={openedAt:Date.now(),...t.state},b,T=new Map,C=new Map,K=!1,be=null,ve,Oe=!1,Fe=i.defaultView?.ResizeObserver,Ce=typeof Fe=="function"?new Fe(()=>{g.classList.toggle("pw2-large",Ne()>=pt),xe()}):null;Ce?.observe(g);let He=()=>xe();i.fonts?.addEventListener?.("loadingdone",He);let je=null,ke=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),re=()=>x.reduceMotion??ke?.matches??!1,H=()=>!!n.editor,le={...dn,...n.labels};function G(){let e=R.now??Date.now();b=dt(x.definition,{locale:x.locale,appearance:x.appearance,platform:x.platform??"web",packages:x.packages,eligible:x.eligible??[],...R.selected?{selected:R.selected}:{},tabs:R.tabs??{},switches:R.switches??{},openedSecondsAgo:Math.max(0,Math.floor((e-(R.openedAt??e))/1e3)),now:e});let c=b.tree.theme.colors;g.style.background=c.background??"",g.style.color=c.text??"",g.classList.toggle("pw-editing",H()),g.classList.toggle("pw2-large",Ne()>=pt),g.lang=b.language,g.dir=fn.has(b.language.split("-")[0]??"")?"rtl":"ltr",C=new Map,Pe(h,b.tree.header,"vertical"),Pe(w,b.tree.root,"vertical"),Pe(v,b.tree.footer,"vertical"),h.hidden=!b.tree.header,v.hidden=!b.tree.footer,w.classList.toggle("pw2-top",!b.tree.header),w.classList.toggle("pw2-bottom",!b.tree.footer),Nt();for(let[o,r]of T)C.has(o)||r.cleanup.forEach(a=>a());T=C,be&&We(be);for(let o of T.values())o.type==="custom_html"&&qe(o.el);xe(),clearTimeout(ve),Oe||=f.isConnected,R.now===void 0&&Object.keys(b.countdowns).length>0&&(ve=setTimeout(()=>{Oe&&!f.isConnected||G()},1e3-Date.now()%1e3+5))}function Ne(){let e=i.documentElement,c=e&&p?parseFloat(p.getComputedStyle(e).fontSize):NaN;return Number.isFinite(c)?c:16}function xe(){let e=[];for(let o of T.values()){if(o.type!=="text")continue;let r=o.el,a=r.dataset.pwFit??r.style.fontSize;if(!a||(r.style.fontSize=a,delete r.dataset.pwFit,!/^\S+$/.test(r.textContent??"")))continue;let d=r.parentElement,u=d&&p?p.getComputedStyle(d):null,k=d&&u?d.clientWidth-parseFloat(u.paddingLeft||"0")-parseFloat(u.paddingRight||"0"):1/0,M=Math.min(r.clientWidth,k);e.push({e:r,base:a,k:M<=0||r.scrollWidth<=M+.5?1:Math.max(.6,M/r.scrollWidth)})}let c=o=>o.closest(".pw-stack.h");for(let o of e){let r=Math.min(o.k,...e.filter(a=>a!==o&&a.base===o.base&&c(a.e)&&c(a.e)===c(o.e)).map(a=>a.k));r>=1||(o.e.dataset.pwFit=o.base,o.e.style.fontSize=`calc(${o.base} * ${r.toFixed(3)})`)}}function Pe(e,c,o){let r=c?U(c,o,{inControl:!1,inSheet:!1,inFooter:e===v}):null;V(e,r?[r]:[])}function U(e,c,o){let r=b.pathOf(e)??"",a=vt(e),d=T.get(r),u;if(d&&d.type===e.type&&d.key===a&&d.axis===c&&!C.has(r))u=d;else{let M=xt(e,r,c,o);if(!M)return null;u={el:M.el,type:e.type,key:a,styleKey:"",axis:c,slots:M.slots,cleanup:M.cleanup??[]},u.el.classList.add("pw-c"),u.el.dataset.pwPath=r,u.el.dataset.pwType=e.type,e.id&&(u.el.dataset.pwId=e.id),d&&d.cleanup.forEach(L=>L()),Ot(u.el,e)}let k=`${JSON.stringify(e.style??null)}|${c}`;return u.styleKey!==k&&(De(u.el,e,c),u.styleKey=k),C.set(r,u),$t(u,e),Tt(u,e,o),u.el}function vt(e){let c=new Set(["style",...yn[e.type]??[],...mn[e.type]??[]]),o={};for(let[r,a]of Object.entries(e))c.has(r)||(o[r]=a);return e.type==="tabs"&&(o.tabs=e.tabs.map(r=>r.id)),e.type==="carousel"&&(o.pages=e.pages.length),e.type==="stack"&&(o.greedy=e.children.some(r=>r.type==="spacer"&&typeof r.size!="number")),(e.type==="image"||e.type==="video"||e.type==="custom_html")&&(o.asset=kt(e)),JSON.stringify(o)}function kt(e){let c=ie(e.src);return c?(x.assets?.[c]?.url??x.assets?.[c]?.html?.length??"none").toString():""}function P(e,c){let o=i.createElement(e);return c&&(o.className=c),o}function xt(e,c,o,r){let a=e;switch(e.type){case"stack":{let d=P("div",`pw-stack${a.axis==="horizontal"?" h":a.axis==="z"?" z":""}${a.scroll?" scroll":""}`);return a.axis!=="z"&&a.children.some(u=>u.type==="spacer"&&typeof u.size!="number")&&d.classList.add(a.axis==="horizontal"?"greedy-h":"greedy-v"),d.style.gap=_(a.spacing),a.axis==="z"?d.style.placeItems=a.align==="stretch"?"stretch":String(a.align??"center"):(d.style.alignItems=gn[String(a.align)]??"center",d.style.justifyContent=hn[String(a.distribution)]??"flex-start"),{el:d,slots:{children:d}}}case"text":return{el:Pt(a,r),slots:{}};case"icon":{let d=ue[String(a.name)];if(!d)return null;let u=P("span","pw-icon");return u.style.color=String(a.color??""),u.append(fe(i,d,Number(a.size)||24)),u.setAttribute("aria-hidden","true"),{el:u,slots:{}}}case"image":return Mt(a);case"video":return St(a);case"features":{let d=P("ul","pw-features");d.style.gap=_(a.spacing);for(let u of a.items??[]){let k=P("li","pw-feature"),M=ue[u.icon];if(M){let z=fe(i,M,22);z.style.color=String(a.icon_color),z.style.flex="none",k.append(z)}let L=P("span");L.textContent=u.text,L.style.color=String(a.color),k.append(L),d.append(k)}return{el:d,slots:{}}}case"timeline":{let d=P("ol","pw-timeline");d.style.gap=_(a.spacing),d.style.setProperty("--pw-gap",_(a.spacing)),d.style.setProperty("--pw-line-w",_(a.line_width));for(let u of a.items??[]){let k=P("li","pw-step"),M=P("span","pw-dot");M.style.background=u.color??String(a.line_color),M.style.color=String(a.icon_color);let L=ue[u.icon];L&&M.append(fe(i,L,18)),M.setAttribute("aria-hidden","true");let z=P("span","pw-line");z.style.background=String(a.line_color),z.setAttribute("aria-hidden","true");let D=P("span");D.style.color=String(a.color);let B=P("span","pw-step-title");if(B.textContent=u.title,D.append(B),u.text){let $=P("span","pw-step-text");$.style.display="block",$.textContent=u.text,D.append($)}k.append(M,D,z),d.append(k)}return{el:d,slots:{}}}case"spacer":{let d=P("div","pw-spacer");return d.setAttribute("aria-hidden","true"),typeof a.size=="number"&&(d.style.flex="none",o==="horizontal"?d.style.width=_(a.size):d.style.height=_(a.size)),{el:d,slots:{}}}case"divider":{let d=P("div","pw-divider");return d.setAttribute("role","separator"),d.style.background=String(a.color),d.style.alignSelf="stretch",d.style.flex="none",o==="horizontal"?(d.setAttribute("aria-orientation","vertical"),d.style.width=_(a.thickness)):d.style.height=_(a.thickness),{el:d,slots:{}}}case"button":return Rt(a,r);case"purchase_button":{let d=P("button","pw-buy");return d.type="button",d.addEventListener("click",()=>{Ve(d,()=>jt(d.dataset.package??""))}),{el:d,slots:{content:d}}}case"package":{let d=P("div","pw-pkg");return d.setAttribute("role","radio"),d.addEventListener("click",()=>Re(d)),d.addEventListener("keydown",u=>Ft(u,d)),{el:d,slots:{children:d}}}case"tabs":return _t(a,c);case"switch":return Et(a,c);case"carousel":return Lt(a);case"countdown":{let d=P("div","pw-countdown");return d.setAttribute("role","timer"),d.setAttribute("aria-live","off"),{el:d,slots:{content:d}}}case"custom_html":{let d=x.assets?.[ie(a.src)??""];if(!d?.html)return null;let u=P("iframe","pw-html");return u.setAttribute("sandbox","allow-scripts"),u.setAttribute("aria-hidden","true"),u.setAttribute("title",""),u.tabIndex=-1,u.srcdoc=d.html,typeof a.height=="number"?u.style.height=_(a.height):typeof a.height=="string"&&a.height.endsWith("%")?u.style.height=a.height:a.height==="fill"&&(u.style.flex="1 1 0"),u.addEventListener("load",()=>qe(u)),{el:u,slots:{}}}default:return null}}function Pt(e,c){let o=String(e.text_style??"body"),r=c.inControl?"span":o==="large_title"?"h1":o==="title"||o==="title2"?"h2":o==="title3"?"h3":"p",a=P(r,"pw-text");c.inControl&&(a.style.display="block"),a.style.fontFamily=At(e.font);let d=typeof e.size=="number"?e.size:16;if(c.inFooter?(a.style.setProperty("--pw-fs",ft(d)),a.style.setProperty("--pw-fs-max",`${Number((d*pn).toFixed(2))}px`)):a.style.fontSize=ft(d),typeof e.weight=="number"&&(a.style.fontWeight=String(e.weight)),typeof e.line_height=="number"&&(a.style.lineHeight=String(e.line_height)),typeof e.letter_spacing=="number"&&e.letter_spacing!==0&&(a.style.letterSpacing=_(e.letter_spacing)),a.style.textAlign=String(e.align??"center"),e.uppercase===!0&&(a.style.textTransform="uppercase"),typeof e.max_lines=="number"&&(a.classList.add("pw-clamp"),a.style.setProperty("-webkit-line-clamp",String(e.max_lines))),typeof e.color=="string"?a.style.color=e.color:e.color&&typeof e.color=="object"&&(a.classList.add("pw-grad"),a.style.backgroundImage=Me(e.color)??""),Array.isArray(e.spans))for(let u of e.spans){let k=u.link==="terms"?x.links?.terms:u.link==="privacy"?x.links?.privacy:u.link,M=ye(k)&&!c.inControl,L=P(M?"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),M&&ye(k)&&(L.href=k,L.target="_blank",L.rel="noopener noreferrer",L.addEventListener("click",D=>{H()||!n.onLink||(D.preventDefault(),n.onLink(k))})),a.append(L)}else a.textContent=String(e.text??"");return a}function At(e){if(typeof e!="string")return ne.system;let c=ie(e);if(c){let o=x.assets?.[c]?.family;return o?`"${o}", ${ne.system}`:ne.system}return ne[e]??ne.system}function Z(e){let c=ie(e);return c?x.assets?.[c]?.url||void 0:ye(e)?e:void 0}function Mt(e){let c=P("div","pw-img");typeof e.aspect=="number"&&(c.style.aspectRatio=String(e.aspect));let o=Z(e.src),r=e.mask;if(r?.shape==="circle")c.style.borderRadius="50%";else if(r?.shape==="rect"&&r.radius)c.style.borderRadius=_(r.radius);else if(r?.shape==="convex")c.style.setProperty("border-end-start-radius",`50% ${_(r.depth)}`),c.style.setProperty("border-end-end-radius",`50% ${_(r.depth)}`);else if(r?.shape==="concave"){let a=`radial-gradient(ellipse 50% ${_(r.depth)} at 50% 100%, transparent 98%, #000 100%)`;c.style.setProperty("-webkit-mask-image",a),c.style.setProperty("mask-image",a)}if(o){let a=P("img");a.src=o,a.decoding="async",a.style.objectFit=e.fit==="fill"?"cover":"contain",e.decorative===!0?(a.alt="",c.setAttribute("aria-hidden","true")):a.alt=String(e.alt??""),a.addEventListener("error",()=>a.style.visibility="hidden"),c.append(a)}if(e.overlay&&typeof e.overlay=="object"){let a=P("div","pw-overlay");a.style.backgroundImage=Me(e.overlay)??"",c.append(a)}return{el:c,slots:{}}}function St(e){let c=P("div","pw-img");typeof e.aspect=="number"&&(c.style.aspectRatio=String(e.aspect));let o=Z(e.src);if(o){let r=P("video");r.src=o;let a=Z(e.poster);a&&(r.poster=a),r.muted=e.mute!==!1,r.loop=e.loop!==!1,r.playsInline=!0,r.controls=e.controls===!0,r.preload="auto",r.style.objectFit=e.fit==="fit"?"contain":"cover",r.autoplay=e.autoplay!==!1&&!re()&&!H(),typeof e.alt=="string"?r.setAttribute("aria-label",e.alt):r.setAttribute("aria-hidden","true"),c.append(r)}return{el:c,slots:{}}}function Rt(e,c){let o=e.action??{},r,a=o.type==="restore"||o.type==="offer_code";switch(o.type){case"close":c.inSheet?r=()=>pe(null):n.onClose&&(r=()=>n.onClose());break;case"restore":n.onRestore&&(r=()=>n.onRestore());break;case"offer_code":n.onOfferCode&&(x.platform??"web")!=="web"&&(r=()=>n.onOfferCode());break;case"open_url":case"terms":case"privacy":{let u=o.type==="open_url"?o.url:o.type==="terms"?x.links?.terms:x.links?.privacy;ye(u)&&(r=()=>n.onLink?n.onLink(u):void p?.open(u,"_blank","noopener,noreferrer"));break}case"sheet":o.sheet&&(r=()=>pe(o.sheet));break;case"select_package":o.package&&(r=()=>Se(o.package));break}if(!r&&!H())return null;let d=P("button");return d.type="button",o.type==="close"&&d.setAttribute("aria-label",le.close),d.addEventListener("click",()=>{!r||H()||(a?Ve(d,r):r())}),{el:d,slots:{content:d}}}function _t(e,c){let o=P("div","pw-tabs"),r=P("div","pw-tablist");r.setAttribute("role","tablist");let a=P("div","pw-tabpanel");a.setAttribute("role","tabpanel"),a.id=`${l}-${c}-panel`;let d={content:a},u=e.tabs.map(k=>k.id);return u.forEach((k,M)=>{let L=P("button","pw-tab");L.type="button",L.setAttribute("role","tab"),L.id=`${l}-${c}-tab-${M}`,L.setAttribute("aria-controls",a.id),L.dataset.tab=k,L.addEventListener("click",()=>Je(c,k)),L.addEventListener("keydown",z=>{let D=z.key==="ArrowRight"?M+1:z.key==="ArrowLeft"?M-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(c,B),r.querySelector(`[data-tab="${B}"]`)?.focus()}),r.append(L),d[`label:${k}`]=L}),o.append(r,a),d.bar=r,{el:o,slots:d}}function Et(e,c){let o=P("div","pw-switch"),r=P("div","pw-switchrow"),a=P("span","pw-switchlabel");a.id=`${l}-${c}-label`;let d=P("button","pw-toggle");d.type="button",d.setAttribute("role","switch"),d.setAttribute("aria-labelledby",a.id),d.append(P("i")),d.addEventListener("click",()=>Ht(c,d.getAttribute("aria-checked")!=="true")),r.append(a,d);let u=P("div","pw-switchcontent");return o.append(r,u),{el:o,slots:{content:u,label:a,toggle:d}}}function Lt(e){let c=P("div","pw-carousel");c.setAttribute("role","region"),c.setAttribute("aria-roledescription","carousel");let o=P("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 r=e.indicator??{},a=P("div",`pw-dots ${r.style??"dots"}`);a.style.setProperty("--pw-dot",_(r.size??8)),a.style.setProperty("--pw-dot-gap",_(r.spacing??6)),a.style.setProperty("--pw-dot-c",r.color??"#8888"),a.style.setProperty("--pw-dot-on",r.active_color??"currentColor"),r.style==="none"&&(a.hidden=!0),c.append(o,a);let d=()=>[...o.children].filter($=>$ instanceof(p?.HTMLElement??HTMLElement)),u=()=>{let $=d(),j=o.scrollLeft+o.clientWidth/2,O=0;return $.forEach((I,It)=>{Math.abs(I.offsetLeft+I.offsetWidth/2-j)<Math.abs(($[O]?.offsetLeft??0)+($[O]?.offsetWidth??0)/2-j)&&(O=It)}),O},k=$=>{let j=d();if(j.length===0)return;let O=e.loop?($+j.length)%j.length:Math.max(0,Math.min(j.length-1,$)),I=j[O];o.scrollTo?.({left:I.offsetLeft-(o.clientWidth-I.offsetWidth)/2,behavior:re()?"auto":"smooth"}),M(O)},M=$=>{[...a.children].forEach((j,O)=>j.setAttribute("aria-current",String(O===$)))};o.addEventListener("scroll",()=>M(u()),{passive:!0}),o.addEventListener("keydown",$=>{$.key!=="ArrowRight"&&$.key!=="ArrowLeft"||($.preventDefault(),k(u()+($.key==="ArrowRight"?1:-1)))});let L=!1,z=()=>L=!0,D=()=>L=!1;c.addEventListener("pointerenter",z),c.addEventListener("pointerleave",D),c.addEventListener("focusin",z),c.addEventListener("focusout",D);let B=[];if(typeof e.auto_advance_ms=="number"){let $=setInterval(()=>{if(L||re()||H())return;let j=d(),O=u();!e.loop&&O>=j.length-1||k(O+1)},e.auto_advance_ms);B.push(()=>clearInterval($))}return c.pwDots=$=>{a.children.length!==$&&(a.replaceChildren(...Array.from({length:$},(j,O)=>{let I=P("button");return I.type="button",I.setAttribute("aria-label",le.page(O+1,$)),I.addEventListener("click",()=>k(O)),I})),M(u()))},{el:c,slots:{pages:o},cleanup:B}}function $t(e,c){let o=c;switch(c.type){case"package":{let r=bn(o),d=!!x.packages[r]?.price;e.el.dataset.package=r,e.el.setAttribute("aria-checked",String(o.selected===!0)),e.el.setAttribute("aria-disabled",String(!d));break}case"purchase_button":{let r=String(o.package);e.el.dataset.package=r,e.el.disabled=K||!x.packages[r]?.price;break}case"switch":{let r=e.slots.toggle;r.setAttribute("aria-checked",String(o.on===!0)),r.style.setProperty("--pw-tint",String(o.tint??"")),r.style.setProperty("--pw-off",`color-mix(in srgb, ${b.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 r of o.tabs){let a=e.slots[`label:${r.id}`];a.setAttribute("aria-selected",String(r.selected)),a.tabIndex=r.selected?0:-1,r.selected&&e.slots.content.setAttribute("aria-labelledby",a.id)}o.bar&&De(e.slots.bar,{type:"stack",style:o.bar},"vertical");break}}}function Tt(e,c,o){let r=c,a={...o,inControl:o.inControl||c.type==="button"||c.type==="purchase_button"||c.type==="package"};switch(c.type){case"stack":case"package":{let d=c.type==="stack"?String(r.axis??"vertical"):"vertical",u=r.children.map(M=>[M,U(M,d,a)]).filter(M=>M[1]!==null),k=u.map(M=>M[1]);V(e.slots.children,k),zt(d,u),c.type==="stack"&&ce(e.el,k);break}case"button":case"purchase_button":{let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]);break}case"countdown":case"switch":{let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]),ce(e.slots.content,d?[d]:[]);break}case"tabs":{for(let u of r.tabs){let k=u.label?U(u.label,"vertical",{...a,inControl:!0}):null;V(e.slots[`label:${u.id}`],k?[k]:[])}let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]),ce(e.slots.content,d?[d]:[]);break}case"carousel":{let d=r.pages.map(u=>U(u,"page",a)).filter(Boolean);d.forEach((u,k)=>{u.setAttribute("role","group"),u.setAttribute("aria-roledescription","slide"),u.setAttribute("aria-label",le.page(k+1,d.length))}),V(e.slots.pages,d),ce(e.slots.pages,d),e.el.pwDots?.(d.length);break}}}function zt(e,c){let o=e==="horizontal"?"width":e==="vertical"?"height":null;if(!o)return;let r=u=>u?o==="width"?u.leading+u.trailing:u.top+u.bottom:0,a=c.filter(([u])=>u.style?.[o]==="fill"),d=Math.max(0,...a.map(([u])=>r(u.style?.padding)+r(u.style?.margin)));for(let[u,k]of a)k.style.flexBasis=_(d-r(u.style?.margin))}function ce(e,c){let o=c.filter(a=>a.dataset.pwType==="package");if(o.length===0){e.getAttribute("role")==="radiogroup"&&e.removeAttribute("role");return}e.setAttribute("role","radiogroup"),e.setAttribute("aria-label",le.packages);let r=o.find(a=>a.getAttribute("aria-checked")==="true")??o[0];for(let a of o)a.tabIndex=a===r?0:-1}function V(e,c){let o=()=>[...e.children].filter(a=>a.dataset?.pwPath!==void 0),r=o();for(let a of r)c.includes(a)||a.remove();r=o(),c.forEach((a,d)=>{r[d]!==a&&(e.insertBefore(a,r[d]??null),r=o())})}let Ae=new WeakMap;function E(e,c,o){e.style.setProperty(c,o),Ae.get(e).push(c)}function De(e,c,o){for(let u of Ae.get(e)??[])e.style.removeProperty(u);Ae.set(e,[]);for(let u of[...e.children])u.classList.contains("pw-bgvideo")&&u.remove();let r=c.style;if(c.type==="image"&&e.classList.toggle("natural",typeof c.aspect!="number"&&(r?.height===void 0||r.height==="fit")),!r)return;let a=(u,k)=>{k&&(E(e,`${u}-block-start`,_(k.top)),E(e,`${u}-block-end`,_(k.bottom)),E(e,`${u}-inline-start`,_(k.leading)),E(e,`${u}-inline-end`,_(k.trailing)))};a("padding",r.padding),a("margin",r.margin),Ie(e,"width",r.width,o),typeof r.height=="number"&&un.has(c.type)?(E(e,"min-height",_(r.height)),o==="vertical"&&E(e,"flex","none")):Ie(e,"height",r.height,o),typeof r.max_width=="number"&&E(e,"max-width",_(r.max_width));let d=r.background;if(d){if(d.type==="color")E(e,"background-color",d.color);else if(d.type==="linear"||d.type==="radial")E(e,"background-image",Me(d)??"");else if(d.type==="image"){let u=Z(d.src);u&&(E(e,"background-image",`url("${u.replace(/"/g,"%22")}")`),E(e,"background-size",d.fit==="fit"?"contain":"cover"),E(e,"background-position","center"),E(e,"background-repeat","no-repeat"))}else if(d.type==="video"){let u=Z(d.src);if(u){let k=P("video","pw-bgvideo");k.src=u;let M=Z(d.poster);M&&(k.poster=M),k.muted=!0,k.loop=d.loop!==!1,k.playsInline=!0,k.autoplay=!re()&&!H(),k.setAttribute("aria-hidden","true"),E(e,"isolation","isolate"),e.prepend(k)}}}if(r.border&&c.type==="custom_html"?E(e,"border",`${_(r.border.width)} solid ${r.border.color??"transparent"}`):r.border&&(E(e,"--pw-bw",_(r.border.width)),E(e,"--pw-bc",r.border.color??"transparent")),r.corners){let u=r.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)),(c.type==="image"||c.type==="video"||d?.type==="image"||d?.type==="video")&&E(e,"overflow","hidden")}r.shadow&&E(e,"box-shadow",`${_(r.shadow.x)} ${_(r.shadow.y)} ${_(r.shadow.radius)} ${r.shadow.color}`),typeof r.opacity=="number"&&r.opacity!==1&&E(e,"opacity",String(r.opacity))}function Ie(e,c,o,r){if(o==null||o==="")return;if(r==="page"){c==="height"&&E(e,"height",o==="fill"?"100%":typeof o=="number"?_(o):o==="fit"?"fit-content":String(o));return}let a=r==="horizontal"?"width":r==="vertical"?"height":null;o==="fill"?c===a?(E(e,"flex","1 1 0"),E(e,`min-${c}`,"0")):r==="z"?E(e,c,"100%"):(E(e,"align-self","stretch"),E(e,c,"auto")):o==="fit"?(c===a&&E(e,"flex","0 0 auto"),E(e,c,"fit-content")):(E(e,c,typeof o=="number"?_(o):String(o)),c===a&&E(e,"flex","none"))}function Me(e){let c=o=>o.map(r=>`${r.color} ${(r.at*100).toFixed(2)}%`).join(", ");if(e.type==="linear")return`linear-gradient(${e.angle}deg, ${c(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)}%, ${c(e.stops)})`}}function Ot(e,c){let o=c.animation;if(!o||x.animate===!1||re()||typeof e.animate!="function")return;let r=24,d={fade:{opacity:0},slide_up:{opacity:0,transform:`translateY(${r}px)`},slide_down:{opacity:0,transform:`translateY(-${r}px)`},slide_leading:{opacity:0,transform:`translateX(-${r}px)`},slide_trailing:{opacity:0,transform:`translateX(${r}px)`},scale:{opacity:0,transform:"scale(0.92)"}}[o.type];d&&e.animate([d,{opacity:1,transform:"none"}],{duration:o.duration_ms,delay:o.delay_ms,easing:ut[o.easing]??ut.ease_out,fill:"backwards"})}function de(){n.onState?.({...R}),G()}function Se(e){R.selected===e&&b.tree.selected===e||(R.selected=e,de(),n.onSelect?.(Te(e)))}function Re(e){H()||e.getAttribute("aria-disabled")==="true"||Se(e.dataset.package??"")}function Ft(e,c){if(e.key===" "||e.key==="Enter"){e.preventDefault(),Re(c);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 r=c.closest("[role=radiogroup]"),d=(r?[...r.children].filter(M=>M.dataset.pwType==="package"):[c]).filter(M=>M.getAttribute("aria-disabled")!=="true"),u=d.indexOf(c),k=d[(u+o+d.length)%d.length];k&&(Re(k),(T.get(k.dataset.pwPath??"")?.el??k).focus())}function Je(e,c){if(H())return;R.tabs={...R.tabs,[e]:c};let o=Ct(e,c);o&&(R.selected=o),de()}function Ct(e,c){return Ue(e)?.tabs?.find(r=>r.id===c)?.package}function Ht(e,c){if(H())return;R.switches={...R.switches,[e]:c};let o=Ue(e),r=c?o?.on_package:o?.off_package;r&&(R.selected=r),de()}function Ue(e){let c=x.definition;for(let o of e.match(/[^.[\]]+/g)??[])c=c?.[/^\d+$/.test(o)?Number(o):o];return c}async function Ve(e,c){if(!(H()||K)){K=!0,e.disabled=!0,e.setAttribute("aria-busy","true");try{await c()}finally{K=!1,e.removeAttribute("aria-busy"),e.disabled=!1;for(let o of T.values())o.type==="purchase_button"&&(o.el.disabled=!x.packages[o.el.dataset.package??""]?.price)}}}async function jt(e){x.packages[e]?.price&&await n.onPurchase(Te(e))}function pe(e){H()&&e!==null&&R.sheet===e||(e&&!R.sheet&&(je=y.activeElement??null),R.sheet=e,de(),e||je?.focus())}function Nt(){let e=R.sheet,c=e?b.tree.sheets?.[e]:void 0;if(!c){A.remove();return}A.className="pw-layer";let o=A.firstElementChild;if(!o){o=P("div","pw-sheet"),o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.tabIndex=-1;let a=P("div","pw-grab");a.setAttribute("aria-hidden","true"),o.append(a),A.append(o),A.addEventListener("click",d=>{d.target===A&&!H()&&pe(null)}),o.addEventListener("keydown",d=>Dt(d,o))}o.style.background=b.tree.theme.colors.background??"",o.setAttribute("aria-label",b.sheetTitles[e]??"");let r=U(c,"vertical",{inControl:!1,inSheet:!0});V(o,r?[r]:[]),A.isConnected||(g.append(A),queueMicrotask(()=>(Be(o)[0]??o).focus()))}function Be(e){return[...e.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')].filter(c=>!c.hidden)}function Dt(e,c){if(e.key==="Escape"){e.preventDefault(),pe(null);return}if(e.key!=="Tab")return;let o=Be(c);if(o.length===0){e.preventDefault();return}let r=o[0],a=o[o.length-1],d=y.activeElement;e.shiftKey&&d===r?(e.preventDefault(),a.focus()):!e.shiftKey&&d===a&&(e.preventDefault(),r.focus())}function qe(e){try{e.contentWindow?.postMessage({type:"palbase.paywall",package:b.tree.selected,locale:b.language,appearance:x.appearance},"*")}catch{}}function We(e){for(let c of y.querySelectorAll("[data-pw-highlight]"))c.removeAttribute("data-pw-highlight");be=e,e&&T.get(e)?.el.setAttribute("data-pw-highlight","")}let Ke=e=>e.composedPath().find(c=>c instanceof(p?.HTMLElement??HTMLElement)&&c.dataset.pwPath!==void 0);g.addEventListener("click",e=>{if(!n.editor)return;let c=Ke(e);c&&(e.preventDefault(),e.stopPropagation(),n.editor.onPick(c.dataset.pwPath))},!0),g.addEventListener("pointerover",e=>{if(n.editor){for(let c of y.querySelectorAll("[data-pw-hover]"))c.removeAttribute("data-pw-hover");Ke(e)?.setAttribute("data-pw-hover","")}}),g.addEventListener("pointerleave",()=>{for(let e of y.querySelectorAll("[data-pw-hover]"))e.removeAttribute("data-pw-hover")});let Xe=()=>G();return ke?.addEventListener?.("change",Xe),G(),{get selected(){return Te(b.tree.selected)},get state(){return{...R}},select(e){Se(e)},update(e){x={...x,...e},e.state&&Object.assign(R,e.state),G()},highlight(e){We(e)},replay(){for(let e of T.values())e.cleanup.forEach(c=>c());T=new Map;for(let e of[h,w,v])e.replaceChildren();G()},destroy(){clearTimeout(ve),Ce?.disconnect(),i.fonts?.removeEventListener?.("loadingdone",He),ke?.removeEventListener?.("change",Xe);for(let e of T.values())e.cleanup.forEach(c=>c());f.remove()}}}function kn(s,t,n){let i=s.defaultView;try{if(i&&"adoptedStyleSheets"in t&&typeof i.CSSStyleSheet=="function"){let l=new i.CSSStyleSheet;l.replaceSync(n),t.adoptedStyleSheets=[l];return}}catch{}let p=s.createElement("style");p.textContent=n,t.append(p)}var ht={version:"0.6.2"};var yt=`palbase-js/${ht.version}`;var we=class{placement;source;definition;assets;offerings;shown;deps;exposed=!1;constructor(t,n,i,p,l,f,y={}){this.placement=t,this.source=n,this.definition=i,this.assets=y,this.offerings=p,this.shown=l,this.deps=f}packages(t){return rt(Mn(this.offerings,ct(this.definition),t),t)}render(t,n){let i=n.locale??globalThis.navigator?.language??this.definition.default_locale,p=n.appearance===void 0?Pn():void 0,l=this.packages(i),f=gt(t,{definition:this.definition,locale:i,appearance:n.appearance??(p?.matches?"dark":"light"),platform:"web",packages:l,eligible:Object.entries(l).filter(([,h])=>h.trial).map(([h])=>h),links:n.links,assets:this.assets},{onPurchase:async h=>{try{let w=await this.deps.checkout({product:h.product,plan:h.plan,successUrl:n.successUrl,cancelUrl:n.cancelUrl});n.onCheckout?n.onCheckout(w,h):globalThis.location.assign(w)}catch(w){if(!n.onError)throw w;n.onError(w,h)}},onClose:n.onClose,onLink:n.onLink,labels:n.labels}),y=h=>f.update({appearance:h.matches?"dark":"light"});p?.addEventListener?.("change",y),!this.exposed&&this.shown&&(this.exposed=!0,this.deps.expose(this));let g=f.destroy.bind(f);return f.destroy=()=>{p?.removeEventListener?.("change",y),g()},f}};function Pn(){try{return globalThis.matchMedia?.("(prefers-color-scheme: dark)")}catch{return}}function An(s,t){if(!s)return;let n=t.split("-")[0];return s[t]?.name??s[n]?.name??Object.values(s).find(i=>i.name)?.name}function Mn(s,t,n){let i=[];for(let p of t){let[l,f]=p.split("."),y=s.products.find(w=>w.key===l),g=y?.channels.web,h=g?.plans.find(w=>w.key===f);!y||!g||!h||i.push({key:p,productName:An(g.locales,n)??y.key,price:{amount:h.price.amount,currency:h.price.currency},period:h.period,intro:h.intro})}return i}var Sn={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"}},mt=s=>({type:"button",action:{type:s},content:{type:"text",text:{t:s},size:"caption",color:"muted"}});function Rn(s){let t=s.products.flatMap(n=>(n.channels.web?.plans??[]).map(i=>({product:n.key,plan:i.key}))).slice(0,6);return t.length===0?null:{schema:2,name:"Default",default_locale:"en",locales:Sn,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:t.map(({product:n,plan:i})=>({type:"package",product:n,plan:i,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:[mt("terms"),mt("privacy")]}]}}}function se(){try{return globalThis.localStorage}catch{return}}function _n(s){try{let t=se()?.getItem(s);if(!t)return;let n=JSON.parse(t),i=n?.answer;return typeof i!="object"||i===null||typeof i.paywall_id!="string"||typeof i.version!="number"||typeof i.definition!="object"||i.definition===null||typeof i.offerings!="object"||i.definition.schema!==2?void 0:{etag:typeof n.etag=="string"?n.etag:void 0,answer:i}}catch{return}}function me(s,t){try{t?se()?.setItem(s,JSON.stringify(t)):se()?.removeItem(s)}catch{}}var wt=()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,bt;function En(s){let t=`palbase.installation.${s}`;try{let n=se()?.getItem(t);if(n&&/^[A-Za-z0-9._:-]{1,128}$/.test(n))return n;let i=wt();if(se()?.setItem(t,i),se()?.getItem(t)===i)return i}catch{}return bt??=wt(),bt}async function Zn(s,t,n,i,p={}){let{signal:l,fetch:f}=p,y=tt(p.attributes),g=`palbase.paywall.${t}.${n}`,h=En(t),v={checkout:i,expose:async b=>{if(b.shown)try{let T={paywall_id:b.shown.paywallId,version:b.shown.version,...b.shown.variant!==void 0?{variant:b.shown.variant}:{},...b.shown.ruleId!==void 0?{rule_id:b.shown.ruleId}:{}};await s.recordPaywallExposure({path:{placement:n},headers:{"X-Palbase-Installation":h},body:T})}catch{}}},A=async(b,T)=>new we(n,T,b.definition,b.offerings,{paywallId:b.paywall_id,version:b.version,...b.variant!==void 0?{variant:b.variant}:{},...b.rule_id!==void 0?{ruleId:b.rule_id}:{}},v,await Ge(b.assets??[],{signal:l,...f?{fetch:f}:{}})),x=_n(g),R;try{R=await s.getPlacementPaywall({path:{placement:n},query:{channel:"web"},headers:{"X-Palbase-Paywall-Schema":2,"X-Palbase-Installation":h,"X-Platform":"web","X-Palbase-SDK":yt,...p.appVersion?{"X-Palbase-Client-Version":p.appVersion}:{},...p.app?{"X-Palbase-App":p.app}:{},...p.locale?{"Accept-Language":p.locale}:{},...y!==void 0?{"X-Palbase-Attributes":y}:{},...x?.etag?{"If-None-Match":x.etag}:{}},signal:l})}catch(b){if(b instanceof oe&&b.status===404||b instanceof oe&&b.status===400&&b.code.startsWith("invalid_"))return me(g,void 0),ze(s,n,v,l);if(x&&!l?.aborted)return A(x.answer,"cache");throw b}return R.status===200?(me(g,{etag:R.headers.get("etag")??void 0,answer:R.data}),A(R.data,"server")):R.status===304&&x?A(x.answer,"server"):(me(g,void 0),ze(s,n,v,l))}async function ze(s,t,n,i){let p=(await s.getOfferings({query:{channel:"web"},signal:i})).data,l=Rn(p);return l?new we(t,"default",l,p,void 0,n):null}export{Ut as a,ie as b,Ge as c,qt as d,Yt as e,tt as f,_e as g,st as h,Qt as i,rt as j,ue as k,he as l,Fn as m,cn as n,ct as o,Cn as p,dt as q,gt as r,we as s,Rn as t,Zn as u};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! palbase 0.
|
|
2
|
-
import{d as O}from"./
|
|
1
|
+
/*! palbase 0.6.2 — Palbase SDK License (see LICENSE) */
|
|
2
|
+
import{d as O}from"./SXH5AIQX.js";import{a as E,b as T,e as _}from"./IYCW6PWG.js";var a=class extends Error{kind;code;status;requestId;fields;retryAfter;data;constructor(n,t){super(t.message,t.cause===void 0?void 0:{cause:t.cause}),this.name="BackendError",this.kind=n,this.code=t.code,this.status=t.status??0,this.requestId=t.requestId,this.fields=t.fields,this.retryAfter=t.retryAfter,this.data=t.data}};function D(e){return e instanceof a||typeof e=="object"&&e!==null&&e.name==="BackendError"&&typeof e.kind=="string"}function $(e){let n=e.body,t={code:e.code,message:e.message,status:e.status,requestId:e.requestId??se(n,"request_id"),data:b(n,"data"),cause:e};if(e.code==="network_error")return new a("network",t);if(e.status===401)return new a("unauthorized",t);if(e.status===429)return new a("rateLimited",{...t,retryAfter:oe(n)??e.retryAfter});let r=re(n);return e.status===400&&r?new a("validation",{...t,fields:r}):new a("server",t)}function P(e){return e instanceof T||e instanceof Error&&e.name==="PalbaseError"}function j(e){return Array.isArray(e)&&e.length>0&&e.every(n=>typeof n=="object"&&n!==null&&typeof n.field=="string"&&typeof n.message=="string")}function re(e){let n=b(b(e,"data"),"fields");if(j(n))return n;let t=b(e,"fields");return j(t)?t:void 0}function oe(e){return N(e,"retry_after")??N(b(e,"data"),"retryAfter")}function b(e,n){if(typeof e=="object"&&e!==null)return e[n]}function N(e,n){let t=b(e,n);return typeof t=="number"?t:void 0}function se(e,n){let t=b(e,n);return typeof t=="string"?t:void 0}var ie=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ae=Object.freeze(["adoptSession","analytics","appContext","appVersion","auth","callOnSignOut","cancelCallOnSignOut","configuration","consent","currentSession","flags","installation","module","moduleDirectory","notify","onSessionChange","onSignOut","preferences","realtime","scope","send","socket","storage","storedUserId","telemetry","transport","version","palbe","data","stores","purchases","messaging","notifications","perf","debug","equals","hashCode","toString","self","Type","init","deinit","subscript","then","constructor","__proto__"]),ce=new Set(ae),de=new Set(["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","__proto__","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]);function S(e){return e==="then"||e==="toJSON"||de.has(e)}function A(e){return e==="call"||e==="join"||S(e)}function C(e){return typeof e=="string"&&ie.test(e)&&!ce.has(e)&&!S(e)}function B(e){return typeof e=="string"&&/^[a-z][a-z0-9-]{0,62}$/.test(e)}function I(e){_(e)}function J(e){return _(e).origin}var R=class extends Error{reason;constructor(n,t){super(n),this.name="RoomError",this.reason=t}},q=new WeakMap;async function U(e,n,t){let{pattern:r,events:o,messages:s}=pe(n),i=ue(r,t),c=q.get(e);c||q.set(e,c=new Map);let p=c;p.set(i,(p.get(i)??0)+1);let u=e.channel(i),l=()=>{let d=(p.get(i)??1)-1;d>0?p.set(i,d):(p.delete(i),u.leave())};try{await u.join()}catch{let d=u.state==="refused"?K(u.refusal,"unavailable"):"socket closed";throw l(),new R(`room ${JSON.stringify(i)} was not joined: ${d}`,d)}let m=!1,w=new Set,k=()=>{if(!m){m=!0,h();for(let d of[...w])d();l()}},h=u.onClosed(k),y=d=>{if(m)return()=>{};let v=u.on("broadcast",f=>{typeof f.event=="string"&&o.has(f.event)&&d(f.event,E(f.payload))}),g=()=>{w.delete(g),v()};return w.add(g),g};return{topic:i,on(d,v){if(typeof d=="function")return y((g,f)=>d({event:g,payload:f}));if(!o.has(d))throw new TypeError(`room ${JSON.stringify(r)} declares no event ${JSON.stringify(String(d))}`);if(typeof v!="function")throw new TypeError(`room ${JSON.stringify(r)}: on(${JSON.stringify(d)}, \u2026) takes the function the event is handed to`);return y((g,f)=>{g===d&&v(f)})},off(d){w.has(d)&&d()},async send(d,v){if(!s.has(d))throw new TypeError(`room ${JSON.stringify(r)} declares no message ${JSON.stringify(String(d))}`);let g=m?{status:"error",response:{reason:"not joined"}}:await u.push("broadcast",{type:"broadcast",event:d,payload:v});if(g.status==="ok")return;let f=K(g.response,"unavailable");throw new R(`room ${JSON.stringify(i)} did not take ${JSON.stringify(d)}: ${f}`,f)},leave:k}}function pe(e){let n=typeof e=="object"&&e!==null?e:{},t=r=>Array.isArray(r)&&r.every(o=>typeof o=="string");if(typeof n.pattern!="string"||n.pattern===""||!t(n.events)||!t(n.messages))throw new TypeError("join takes a room of the backend's generated module: its pattern, its events and its messages");return{pattern:n.pattern,events:new Set(n.events),messages:new Set(n.messages)}}function ue(e,n){let t=typeof n=="object"&&n!==null?n:{};return e.split(":").map(r=>{if(!(r.startsWith("{")&&r.endsWith("}")&&r.length>2))return r;let o=r.slice(1,-1),s=Object.hasOwn(t,o)?t[o]:void 0;if(typeof s!="string"||s==="")throw new TypeError(`room ${JSON.stringify(e)} needs a value for ${JSON.stringify(o)}`);if(s.includes(":"))throw new TypeError(`room ${JSON.stringify(e)}: the value of ${JSON.stringify(o)} is one segment of the channel's name and cannot hold ":"`);return s}).join(":")}function K(e,n){let t=e?.reason;return typeof t=="string"&&t!==""?t:n}var x=class{pending="";dataLines=[];eventName;consume(n){this.pending+=n.replace(/\r\n/g,`
|
|
3
3
|
`);let t=[],r=this.pending.indexOf(`
|
|
4
4
|
`);for(;r!==-1;){let o=this.pending.slice(0,r);this.pending=this.pending.slice(r+1);let s=o.endsWith("\r")?o.slice(0,-1):o;if(s==="")this.dataLines.length>0&&t.push({event:this.eventName,payload:this.dataLines.join(`
|
|
5
5
|
`)}),this.dataLines=[],this.eventName=void 0;else if(!s.startsWith(":")){if(s.startsWith("data:")){let i=s.slice(5);this.dataLines.push(i.startsWith(" ")?i.slice(1):i)}else if(s.startsWith("event:")){let i=s.slice(6);this.eventName=i.startsWith(" ")?i.slice(1):i}}r=this.pending.indexOf(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! palbase 0.
|
|
2
|
-
import{a as g,b}from"./
|
|
1
|
+
/*! palbase 0.6.2 — Palbase SDK License (see LICENSE) */
|
|
2
|
+
import{a as g,b}from"./KLANM6M6.js";var A=Symbol.for("palbase.data"),T=globalThis,m=T[A]??=new WeakSet;function S(t){return t instanceof Date||ArrayBuffer.isView(t)||t instanceof ArrayBuffer}function k(t){let e=[t];for(;e.length>0;){let n=e.pop();if(!(typeof n!="object"||n===null||m.has(n)||S(n))){m.add(n);for(let a of Array.isArray(n)?n:Object.values(n))e.push(a)}}return t}var l=class extends Error{status;code;requestId;retryAfter;body;op;constructor(e){super(e.message,e.cause===void 0?void 0:{cause:e.cause}),this.name="PalbaseError",this.op=e.op,this.status=e.status,this.code=e.code,this.requestId=e.requestId,this.retryAfter=e.retryAfter,this.body=e.body}};function C(t,e,n){let a=String(n);if(a===""||a==="."||a==="..")throw new l({op:t,status:0,code:"invalid_path_parameter",message:`${t}: ${e} cannot be ${a===""?"empty":JSON.stringify(a)}`});return encodeURIComponent(a)}var x=new Set(["apikey","authorization"]),q=64*1024;function W(t){let e=v(t.baseUrl),n=t.fetch??globalThis.fetch,a=t.solveProofOfWork??!0,u=async(r,o)=>{let d=E(e,r),s=new Headers;for(let[h,y]of Object.entries(r.headers??{}))y!=null&&!x.has(h.toLowerCase())&&s.set(h,String(y));for(let[h,y]of Object.entries(o))s.set(h,y);await j(r,t.credentials,s),s.has("accept")||s.set("accept","application/json");let f={method:r.method,headers:s,redirect:"manual",signal:r.signal,...r.keepalive?{keepalive:!0}:{}};r.body&&r.body.value!==void 0&&(s.set("content-type",r.body.contentType),f.body=L(r.body.kind,r.body.value),R(f.body)||(f.duplex="half"));let i;try{i=r.onUploadProgress&&t.xmlHttpRequest?await U(t.xmlHttpRequest,r.op,d,f,r.onUploadProgress):await n(d,f)}catch(h){throw r.signal?.aborted||h instanceof l?h:new l({op:r.op,status:0,code:"network_error",message:`${r.op}: the request did not reach ${e.origin}`,cause:h})}let c=r.answers[i.status];if(c===void 0)throw i.status>=200&&i.status<300?(await i.body?.cancel(),new l({op:r.op,status:i.status,code:"undeclared_answer",message:`${r.op}: the server answered ${i.status}, which its contract does not declare; the request may have taken effect`})):await P(r.op,i);let p;switch(c){case"json":try{p=k(await i.json())}catch(h){throw new l({op:r.op,status:i.status,code:"invalid_json",message:`${r.op}: the answer is not JSON`,cause:h})}break;case"raw":p=i;break;default:await i.body?.cancel(),p=void 0}return{status:i.status,data:p,headers:i.headers}};return{async send(r){try{return await u(r,{})}catch(o){let d=a&&o instanceof l&&o.status===403?g(o.body):null,s=r.body?.value;if(!d||r.body?.kind==="raw"&&!R(s))throw o;let f=o,i;try{i=await b(d,{signal:r.signal})}catch(c){throw r.signal?.aborted?c:new l({op:r.op,status:403,code:"pow_unsolved",message:`${r.op}: ${c instanceof Error?c.message:String(c)}`,requestId:f.requestId,body:f.body,cause:c})}return u(r,i)}}}}function U(t,e,n,a,u){return new Promise((r,o)=>{let d=a.signal;if(d?.aborted)return o(d.reason);let s=new t,f=()=>s.abort();d?.addEventListener("abort",f,{once:!0});let i=c=>{d?.removeEventListener("abort",f),c()};s.open(a.method??"GET",n.href),s.responseType="arraybuffer",new Headers(a.headers).forEach((c,p)=>s.setRequestHeader(p,c)),s.upload&&(s.upload.onprogress=c=>{c.lengthComputable&&u(c.loaded,c.total)}),s.onload=()=>i(()=>{if(s.responseURL!==""&&s.responseURL!==n.href){o(new l({op:e,status:0,code:"undeclared_redirect",message:`${e}: the server redirected; the answer is another address's, and was not read`}));return}if(s.status<200||s.status>599)return o(new TypeError(`${e}: answered ${s.status}`));let c=s.status===204||s.status===205||s.status===304;r(new Response(c?null:s.response,{status:s.status,statusText:s.statusText,headers:$(s.getAllResponseHeaders())}))}),s.onerror=()=>i(()=>o(new TypeError(`${e}: the request failed`))),s.onabort=()=>i(()=>o(d?.reason??new DOMException("The request was aborted","AbortError"))),s.send(a.body)})}function $(t){let e=new Headers;for(let n of t.split(/\r?\n/)){let a=n.indexOf(":");if(!(a<=0))try{e.append(n.slice(0,a).trim(),n.slice(a+1).trim())}catch{}}return e}function v(t){let e;try{e=new URL(t)}catch{throw new TypeError(`baseUrl ${JSON.stringify(t)} is not an absolute URL`)}let n=e.hostname==="localhost"||e.hostname.endsWith(".localhost")||e.hostname==="127.0.0.1"||e.hostname==="[::1]";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&n))throw new TypeError(`baseUrl must be https (http only for a loopback address): ${e.origin}`);if(e.username||e.password||e.search||e.hash)throw new TypeError("baseUrl carries no user, query or fragment");if(e.pathname!=="/"&&e.pathname!=="")throw new TypeError("baseUrl is the project origin alone, with no path");return e}function E(t,e){if(!e.path.startsWith("/")||e.path.startsWith("//"))throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path ${JSON.stringify(e.path)} is not absolute`});let n=new URL(e.path+O(e.query),t);if(n.origin!==t.origin)throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path leaves the project's origin`});return n}async function j(t,e,n){if(t.auth.length===0)return;let a=t.auth.some(o=>o.includes("userJWT"))?await e.accessToken?.():void 0,u=o=>{switch(o){case"ApiKeyAuth":return!!(e.publishableKey??e.secretKey);case"SecretKeyAuth":case"AdminAuth":return!!e.secretKey;case"userJWT":return!!a;default:return!1}},r=t.auth.filter(o=>o.every(u)).reduce((o,d)=>o===void 0||d.length>o.length?d:o,void 0);if(!r)throw new l({op:t.op,status:0,code:"missing_credential",message:`${t.op} needs one of: ${t.auth.map(o=>o.length===0?"nothing":o.join(" + ")).join(" | ")}`});for(let o of r)o==="ApiKeyAuth"?n.set("apikey",e.publishableKey??e.secretKey):o==="SecretKeyAuth"||o==="AdminAuth"?n.set("apikey",e.secretKey):o==="userJWT"&&n.set("authorization",`Bearer ${a}`)}function L(t,e){switch(t){case"json":return JSON.stringify(e);case"form":{let n=new URLSearchParams;for(let[a,u]of Object.entries(e))w(n,a,u);return n}case"raw":return e}}function R(t){return!!(t==null||typeof t=="string"||t instanceof URLSearchParams||t instanceof Blob||t instanceof FormData||t instanceof ArrayBuffer||ArrayBuffer.isView(t))}function O(t){if(!t)return"";let e=new URLSearchParams;for(let[a,u]of Object.entries(t))w(e,a,u);let n=e.toString();return n===""?"":`?${n}`}function w(t,e,n){if(n!=null){if(Array.isArray(n)){for(let a of n)w(t,e,a);return}if(n instanceof Date){t.append(e,n.toISOString());return}t.append(e,typeof n=="object"?JSON.stringify(n):String(n))}}async function P(t,e){let n=await _(e,q).catch(()=>""),a;try{a=n===""?void 0:JSON.parse(n)}catch{a=n}let u=B(a)?a:void 0,r=Number(e.headers.get("retry-after")),o=e.status>=300&&e.status<400;return new l({op:t,status:e.status,code:u?.error??(o?"undeclared_redirect":`http_${e.status}`),message:u?.error_description??(o?`${t}: the server redirected (${e.status}); the request was not followed, its credentials stay here`:`${t}: ${e.status} ${e.statusText}`.trim()),requestId:u?.request_id??e.headers.get("x-request-id")??void 0,retryAfter:u?.retry_after??(Number.isFinite(r)&&r>0?r:void 0),body:a})}async function _(t,e){if(!t.body)return"";let n=t.body.getReader(),a=[],u=0;for(;u<e;){let{done:d,value:s}=await n.read();if(d)break;a.push(s),u+=s.byteLength}await n.cancel().catch(()=>{});let r=new Uint8Array(Math.min(u,e)),o=0;for(let d of a){let s=Math.min(d.byteLength,r.byteLength-o);if(r.set(d.subarray(0,s),o),o+=s,o>=r.byteLength)break}return new TextDecoder().decode(r)}function B(t){return typeof t=="object"&&t!==null&&typeof t.error=="string"}export{k as a,l as b,C as c,W as d,v as e,R as f};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! palbase 0.6.2 — Palbase SDK License (see LICENSE) */
|
|
2
|
+
import{f as W,g as X}from"./IVEAUFGE.js";import{u as Y}from"./GVFZM4BI.js";import{c as k,e as j,f as p,g as z,h as D}from"./2RG3I7LX.js";import{a as B,b as U,c as m,h as H}from"./A76UZBAF.js";import{a as G,b as S,c as J}from"./SXH5AIQX.js";import{b as f,d as b}from"./IYCW6PWG.js";var y=class extends Error{code="session_changed";constructor(e){super(e),this.name="SessionChangedError"}};function Q(){let i=null;return{load:()=>i,save:e=>{i=e},clear:()=>{i=null},shared:!1}}function Z(i){let e=null,t=!0,s=()=>{try{return globalThis.localStorage}catch{return}};return{shared:!0,load(){try{let n=s()?.getItem(i);return n==null?t?null:e:JSON.parse(n)}catch{return e}},save(n){e=n;try{let r=s();if(!r)throw new Error("no storage");r.setItem(i,JSON.stringify(n)),t=!0}catch{t=!1}},clear(){e=null,t=!0;try{s()?.removeItem(i)}catch{}},watch(n){let r=globalThis;if(typeof r.addEventListener!="function")return()=>{};let o=a=>{(a.key===i||a.key===null)&&n()};return r.addEventListener("storage",o),()=>r.removeEventListener?.("storage",o)}}}function he(i){try{let e=i.split(".")[1]??"",t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"=")),s=JSON.parse(t).sub;return typeof s=="string"?s:""}catch{return""}}var de=6e4,ue=15e3;function pe(i,e,t){let s=i?globalThis.navigator?.locks:void 0;return s?s.request(e,t):t()}var T=class{current=null;loaded;inflight=null;listeners=new Set;store;refresher;isRejected;now;lockName;refreshTimeoutMs;mode;constructor(e,t,s,n={}){this.store=e,this.refresher=t,this.isRejected=s,this.now=n.now??Date.now,this.lockName=n.lockName??"palbase.session.refresh",this.refreshTimeoutMs=n.refreshTimeoutMs??ue,this.mode=n.refresh??"behind",this.loaded=Promise.resolve(e.load()).then(r=>{this.current=r}),e.watch?.(()=>{this.reconcile()})}async session(){return await this.loaded,this.current}snapshot(){return this.current}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}async set(e,t,s){await this.loaded;let n=t==="TOKEN_REFRESHED"?this.current:null,r={accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:this.now()+e.expires_in*1e3,userId:s?.id??n?.userId??he(e.access_token),user:s??n?.user};return this.current=r,await this.store.save(r),this.emit(t,r),r}async setUser(e,t){await this.loaded,!(!this.current||!t||this.current.userId!==t.userId)&&(this.current={...this.current,user:e},await this.store.save(this.current),this.emit("USER_UPDATED",this.current))}async clear(e){await this.loaded;let t=this.current;this.current=null,this.inflight=null;let s=await this.store.load();(!s||!t||s.userId===t.userId)&&await this.store.clear(),t&&this.emit(e,null)}async accessToken(){await this.loaded;let e=this.current;if(!e)return;let t=e.expiresAt-this.now();if(t>de)return e.accessToken;if(this.mode==="never")return t>0?e.accessToken:void 0;if(t>0&&this.mode==="behind")return this.refresh().catch(()=>{}),e.accessToken;if(t>0)try{return(await this.refresh()).accessToken}catch(s){if(this.current===e)return e.accessToken;throw s}return(await this.refresh()).accessToken}refresh(){if(this.mode==="never")return Promise.reject(new Error("this client does not renew its session (refresh: 'never'): where the session cannot be written back, the request's middleware renews it"));if(this.inflight)return this.inflight;let e=pe(this.store.shared===!0,this.lockName,async()=>{await this.loaded;let t=this.current;if(!t)throw new y("no session to refresh");let s=await this.adoptStored(t);if(s)return s;try{let n=await this.withTimeout(this.refresher(t.refreshToken));if(this.current?.refreshToken!==t.refreshToken)throw new y("the session changed while it was refreshed");return await this.set(n,"TOKEN_REFRESHED")}catch(n){throw this.isRejected(n)&&this.current?.refreshToken===t.refreshToken&&await this.clear("SESSION_EXPIRED"),n}});return this.inflight=e,e.finally(()=>{this.inflight===e&&(this.inflight=null)}).catch(()=>{}),e}async adoptStored(e){let t=await this.store.load();if(!t)throw this.current=null,this.emit("SIGNED_OUT",null),new y("signed out in another tab");if(t.userId!==e.userId)throw this.current=t,this.emit("SIGNED_OUT",null),this.emit("SIGNED_IN",t),new y("another user signed in in another tab");if(t.refreshToken!==e.refreshToken&&t.expiresAt>=e.expiresAt)return this.current=t,this.emit("TOKEN_REFRESHED",t),t}async reconcile(){await this.loaded;let e=this.current,t=await this.store.load();if(!e){t&&(this.current=t,this.emit("SIGNED_IN",t));return}await this.adoptStored(e).catch(()=>{})}withTimeout(e){let t,s=new Promise((n,r)=>{t=setTimeout(()=>r(new Error(`the refresh did not answer within ${this.refreshTimeoutMs/1e3} s`)),this.refreshTimeoutMs)});return Promise.race([e,s]).finally(()=>clearTimeout(t))}emit(e,t){for(let s of this.listeners)try{s(e,t)}catch{}}};var q=class{state="closed";refusal;joinRef=null;listeners=new Map;closers=new Set;joinWaiters=[];name;socket;constructor(e,t){this.name=e,this.socket=t}get topic(){return`realtime:${this.name}`}join(){if(this.state==="joined")return Promise.resolve();let e=new Promise((t,s)=>this.joinWaiters.push({resolve:t,reject:s}));return this.state!=="joining"&&this.socket.join(this),e}leave(){this.socket.leave(this)}push(e,t){return this.socket.request(this,e,t)}on(e,t){let s=this.listeners.get(e);return s||this.listeners.set(e,s=new Set),s.add(t),()=>s.delete(t)}onClosed(e){return this.closers.add(e),()=>this.closers.delete(e)}deliver(e,t){for(let s of this.listeners.get(e)??[])try{s(t)}catch{}}settled(e,t){this.state=e?"joined":"refused",this.refusal=e?void 0:t;let s=this.joinWaiters.splice(0);for(let n of s)e?n.resolve():n.reject(new Error(`join ${this.name} refused: ${JSON.stringify(t)}`))}closed(e){this.state="closed",this.joinRef=null;let t=this.joinWaiters.splice(0);for(let s of t)s.reject(new Error(`join ${this.name}: ${e}`));for(let s of[...this.closers])try{s()}catch{}}},P=class{ws=null;opening=null;ref=0;channels=new Map;replies=new Map;heartbeat=null;heartbeatRef=null;reconnectTimer=null;attempts=0;closedByUs=!1;reconnects=0;opts;constructor(e){this.opts=e}channel(e){let t=this.channels.get(e);return t||this.channels.set(e,t=new q(e,this)),t}disconnect(){this.closedByUs=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.stopHeartbeat();let e=this.ws;this.ws=null,this.opening=null,e?.close(1e3);for(let[,t]of this.replies)t("error",{reason:"socket closed"});this.replies.clear();for(let t of this.channels.values())t.closed("the socket was closed")}async tokenChanged(){if(!this.ws||this.ws.readyState!==1)return;let e=await this.opts.accessToken();if(e)for(let t of this.channels.values())t.state==="joined"&&this.push(t.joinRef,t.topic,"access_token",{access_token:e})}join(e){e.state="joining",this.open().then(()=>this.sendJoin(e)).catch(t=>e.settled(!1,{reason:t instanceof Error?t.message:String(t)}))}leave(e){e.state==="joined"&&this.ws?.readyState===1&&this.push(e.joinRef,e.topic,"phx_leave",{}),e.state="closed",this.channels.delete(e.name)}async request(e,t,s){let n=this.ws;if(this.channels.get(e.name)!==e||e.state!=="joined"||n?.readyState!==1)return{status:"error",response:{reason:"not joined"}};let r=this.nextRef(),o=JSON.stringify([e.joinRef,r,e.topic,t,s]),a=this.awaitReply(r);return n.send(o),a}open(){if(this.ws?.readyState===1)return Promise.resolve();if(this.opening)return this.opening;this.closedByUs=!1;let e=this.opts.webSocket??globalThis.WebSocket,t=`${this.opts.baseUrl.replace(/^http/,"ws")}/realtime/v1/websocket?vsn=2.0.0&apikey=${encodeURIComponent(this.opts.publishableKey)}`,s=new Promise((n,r)=>{let o=new e(t);this.ws=o,o.onopen=()=>{this.attempts=0,this.startHeartbeat(),n()},o.onmessage=a=>this.receive(String(a.data)),o.onerror=()=>r(new Error("the realtime socket could not be opened")),o.onclose=()=>this.dropped(o)});return this.opening=s,s.finally(()=>{this.opening===s&&(this.opening=null)}).catch(()=>{}),s}dropped(e){if(this.ws!==e)return;this.ws=null,this.stopHeartbeat();for(let[,n]of this.replies)n("error",{reason:"socket closed"});this.replies.clear();for(let n of this.channels.values())n.state==="joined"&&(n.state="joining");if(this.closedByUs||![...this.channels.values()].some(n=>n.state==="joining"))return;let t=this.opts.backoff??[500,1e3,2e3,5e3,1e4,3e4],s=t[Math.min(this.attempts,t.length-1)]*(.8+Math.random()*.4);this.attempts++,this.reconnectTimer=_(setTimeout(()=>{this.reconnectTimer=null,this.reconnects++;let n=[...this.channels.values()].filter(r=>r.state==="joining");this.open().then(()=>Promise.all(n.map(r=>this.sendJoin(r)))).catch(()=>{})},s))}async sendJoin(e){let t=await this.opts.accessToken(),s=this.nextRef();e.joinRef=s;let n=this.awaitReply(s);this.push(s,e.topic,"phx_join",{access_token:t,config:{broadcast:{self:!1}}},s);let{status:r,response:o}=await n;if(this.channels.get(e.name)!==e||e.state!=="joining"){r==="ok"&&this.ws?.readyState===1&&this.push(s,e.topic,"phx_leave",{});return}e.settled(r==="ok",o)}awaitReply(e){return new Promise(t=>{let s=_(setTimeout(()=>{this.replies.delete(e),t({status:"timeout",response:{reason:"no reply"}})},this.opts.replyTimeoutMs??1e4));this.replies.set(e,(n,r)=>{clearTimeout(s),this.replies.delete(e),t({status:n,response:r})})})}receive(e){let t;try{t=JSON.parse(e)}catch{return}if(!Array.isArray(t)||t.length!==5||typeof t[2]!="string"||typeof t[3]!="string")return;let[,s,n,r,o]=t,a=typeof o=="object"&&o!==null?o:{};if(r==="phx_reply"&&typeof s=="string"){if(s===this.heartbeatRef){this.heartbeatRef=null;return}this.replies.get(s)?.(String(a.status),a.response??{});return}let l=[...this.channels.values()].find(c=>c.topic===n);if(l){if(r==="phx_close"){l.state="closed";return}if(r==="phx_error"){l.state="joining",_(setTimeout(()=>this.channels.get(l.name)===l&&l.state==="joining"&&this.ws?.readyState===1&&void this.sendJoin(l),1e3));return}l.deliver(r,a)}}push(e,t,s,n,r=this.nextRef()){this.ws?.send(JSON.stringify([e,r,t,s,n]))}nextRef(){return String(++this.ref)}startHeartbeat(){this.stopHeartbeat(),this.heartbeat=_(setInterval(()=>{if(this.heartbeatRef!==null){this.heartbeatRef=null,this.ws?.close(4e3);return}this.heartbeatRef=this.nextRef(),this.push(null,"phoenix","heartbeat",{},this.heartbeatRef)},this.opts.heartbeatMs??25e3))}stopHeartbeat(){this.heartbeat&&clearInterval(this.heartbeat),this.heartbeat=null,this.heartbeatRef=null}};function _(i){return i.unref?.(),i}var ge=30*6e4,ee=1e3,ye=100,me=60*1024,I=()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;function R(){try{return globalThis.localStorage}catch{return}}var C=class{api;closingApi;flushMs;flushAt;now;anonKey;sessionKey;events=[];samples=[];timer;memoryAnon;memorySession;appVersion;stopAuto;session;identifyPending=!1;constructor(e,t,s,n={}){this.session=t,this.api=U.client(e),this.closingApi=U.client({send:r=>e.send({...r,keepalive:!0})}),this.flushMs=n.flushMs??5e3,this.flushAt=n.flushAt??20,this.now=n.now??Date.now,this.anonKey=`palbase.analytics.anonymous.${s}`,this.sessionKey=`palbase.analytics.session.${s}`,t.onChange(r=>{r==="SIGNED_IN"?(this.identifyPending=!0,this.soon()):r==="SIGNED_OUT"&&(this.identifyPending=!1,this.reset())})}capture(e,t){let s=this.now();this.hold({event:e,distinct_id:this.distinctId(),properties:t,timestamp:s,session_id:this.sessionId(s),...this.appVersion?{app_version:this.appVersion}:{}})}page(e={}){let t=globalThis.location,s=globalThis.document,n=e.url??(t?`${t.origin}${t.pathname}`:"");if(!n)return;let r=e.referrer??ke(s?.referrer);this.capture("$pageview",{...e.properties,url:n,...e.title??s?.title?{title:e.title??s?.title}:{},...r?{referrer:r}:{}})}async identify(e){this.identifyPending=!1;let t=this.session.snapshot()?.userId;t&&(await this.flush(),await this.sendIdentify(this.api,t,e))}async sendIdentify(e,t,s){try{await e.identify({body:{distinct_id:t,anonymous_id:this.anonymousId(),traits:s,timestamp:this.now(),sent_at:this.now()}})}catch{}}reset(){this.memoryAnon=void 0,this.memorySession=void 0;try{R()?.removeItem(this.anonKey),R()?.removeItem(this.sessionKey)}catch{}}async flush(e=!1){this.timer&&clearTimeout(this.timer),this.timer=void 0;let t=e?this.closingApi:this.api,s=this.now(),n=this.session.snapshot()?.userId;for(this.identifyPending&&n&&(this.identifyPending=!1,await this.sendIdentify(t,n));this.events.length>0;){let r=this.take(this.events,e);try{await t.batch({body:{events:r.map(o=>({...o,sent_at:s}))}})}catch{}}for(;this.samples.length>0;){let r=this.take(this.samples,e);try{await t.sendPerf({body:{items:r}})}catch{}}}start(e={}){this.stopAuto?.(),this.appVersion=e.appVersion;let t=globalThis;if(typeof t.addEventListener!="function"||typeof globalThis.document>"u")return()=>{};let s=[];e.pageViews!==!1&&s.push(this.watchPages(t)),e.webVitals!==!1&&s.push(be((o,a)=>this.sample("web_vital",o,a))),e.network!==!1&&s.push(this.watchFetch(t));let n=()=>{document.visibilityState==="hidden"&&this.flush(!0)},r=()=>{this.flush(!0)};return document.addEventListener("visibilitychange",n),t.addEventListener("pagehide",r),s.push(()=>{document.removeEventListener("visibilitychange",n),t.removeEventListener("pagehide",r)}),this.stopAuto=()=>{for(let o of s.splice(0))o();this.stopAuto=void 0},this.stopAuto}hold(e){this.events.length>=ee&&this.events.shift(),this.events.push(e),this.soon()}sample(e,t,s,n={}){this.samples.length>=ee&&this.samples.shift(),this.samples.push({row_id:I(),trace_type:e,name:t,value:Math.max(0,s),timestamp:this.now(),distinct_id:this.distinctId(),...n}),this.soon()}soon(){if(this.events.length+this.samples.length>=this.flushAt){this.flush();return}this.timer||(this.timer=setTimeout(()=>{this.flush()},this.flushMs),this.timer.unref?.())}take(e,t){let s=e.splice(0,ye);if(!t)return s;for(;s.length>1&&JSON.stringify(s).length>me;)e.unshift(s.pop());return s}distinctId(){return this.session.snapshot()?.userId??this.anonymousId()}anonymousId(){let e=R();try{let t=e?.getItem(this.anonKey);if(t)return t;let s=`anon_${I()}`;if(e?.setItem(this.anonKey,s),e?.getItem(this.anonKey)===s)return s}catch{}return this.memoryAnon??=`anon_${I()}`,this.memoryAnon}sessionId(e){let t=R(),s=this.memorySession;try{let r=t?.getItem(this.sessionKey);r&&(s=JSON.parse(r))}catch{}let n=s&&e-s.last<ge?{id:s.id,last:e}:{id:`ses_${I()}`,last:e};this.memorySession=n;try{t?.setItem(this.sessionKey,JSON.stringify(n))}catch{}return n.id}watchPages(e){let t="",s=()=>{let a=`${e.location.origin}${e.location.pathname}`;a!==t&&(t=a,setTimeout(()=>this.page({url:a}),0))},n=e.history,r=n.pushState.bind(n),o=n.replaceState.bind(n);return n.pushState=(...a)=>{r(...a),s()},n.replaceState=(...a)=>{o(...a),s()},e.addEventListener("popstate",s),s(),()=>{n.pushState=r,n.replaceState=o,e.removeEventListener("popstate",s)}}watchFetch(e){let t=e.fetch;if(typeof t!="function")return()=>{};let s=async(n,r)=>{let o=performance.now(),a=n instanceof Request?n:void 0,l=(r?.method??a?.method??"GET").toUpperCase(),c;try{c=new URL(a?.url??String(n),e.location.href)}catch{c=void 0}let h=!!c&&c.pathname.startsWith("/analytics/")||Se(r?.headers??a?.headers);try{let u=await t(n,r);return c&&!h&&this.sample("network",`${l} ${c.origin}${c.pathname}`,performance.now()-o,{attrs:{status:String(u.status)},...u.headers.get("x-request-id")?{request_id:u.headers.get("x-request-id")}:{}}),u}catch(u){throw c&&!h&&this.sample("network",`${l} ${c.origin}${c.pathname}`,performance.now()-o,{attrs:{status:"0"}}),u}};return e.fetch=s,()=>{e.fetch===s&&(e.fetch=t)}}},ve=i=>i.entryType==="layout-shift"&&"value"in i&&"hadRecentInput"in i,we=i=>i.entryType==="event"||i.entryType==="first-input";function E(i,e){if(!(typeof PerformanceObserver>"u"))try{let t=new PerformanceObserver(s=>e(s.getEntries()));return t.observe({type:i,buffered:!0}),t}catch{return}}function be(i){if(typeof document>"u"||typeof performance>"u"||typeof performance.getEntriesByType!="function")return()=>{};let e=0,t=0,s=0,n=[E("largest-contentful-paint",c=>{for(let h of c)e=Math.max(e,h.startTime)}),E("layout-shift",c=>{for(let h of c)ve(h)&&!h.hadRecentInput&&(t+=h.value)}),E("event",c=>{for(let h of c)we(h)&&(s=Math.max(s,h.duration))}),E("paint",c=>{for(let h of c)h.name==="first-contentful-paint"&&i("FCP",h.startTime)})],r=performance.getEntriesByType("navigation")[0];r&&r.responseStart>0&&i("TTFB",r.responseStart);let o=!1,a=()=>{o||(o=!0,e>0&&i("LCP",e),i("CLS",t),s>0&&i("INP",s))},l=()=>{document.visibilityState==="hidden"&&a()};return document.addEventListener("visibilitychange",l),()=>{a(),document.removeEventListener("visibilitychange",l);for(let c of n)c?.disconnect()}}function Se(i){if(!i)return!1;try{return new Headers(i).has("next-router-prefetch")}catch{return!1}}function ke(i){if(!i)return"";try{let e=new URL(i);return`${e.origin}${e.pathname}`}catch{return i.split(/[?#]/,1)[0]??""}}var x=class{api;session;socket;ref;fetch;appVersion;app;listeners=new Set;watch;following;last;constructor(e,t,s,n,r,o,a){this.api=H.client(e),this.session=t,this.socket=s,this.ref=n,this.fetch=r,this.appVersion=o,this.app=a}async me(){let e=this.session.snapshot()?.userId,t=(await this.api.getMyCustomerInfo()).data;return this.watch&&this.watch.userId===e&&this.offer(this.watch,t),t}async offerings(e="web"){return(await this.api.getOfferings({query:{channel:e}})).data}async paywall(e,t={}){return Y(this.api,this.ref,e,s=>this.checkout(s),{signal:t.signal,fetch:this.fetch,attributes:t.attributes,locale:t.locale,appVersion:this.appVersion,app:this.app})}async checkout(e){let t={product:e.product,plan:e.plan,success_url:e.successUrl,cancel_url:e.cancelUrl};return(await this.api.createCheckout({body:t})).data.url}async portal(e){return(await this.api.createPortalSession({body:{return_url:e}})).data.url}async mergeGrant(){return(await this.api.createMergeGrant()).data}async merge(e){let t=this.session.snapshot()?.userId,s=(await this.api.mergeGuest({body:{grant:typeof e=="string"?e:e.grant}})).data;return this.watch&&this.watch.userId===t&&this.offer(this.watch,s),s}onCustomerInfo(e){if(this.listeners.add(e),this.listeners.size===1)this.start();else if(this.last!==void 0){let t=this.last;queueMicrotask(()=>this.listeners.has(e)&&te(e,t))}return()=>{this.listeners.delete(e)&&this.listeners.size===0&&this.stop()}}start(){this.following=this.session.onChange((e,t)=>{(e==="SIGNED_IN"||e==="SIGNED_OUT"||e==="SESSION_EXPIRED")&&this.follow(t)}),this.session.session().then(e=>{this.following&&!this.watch&&this.last===void 0&&this.follow(e)})}stop(){this.following?.(),this.following=void 0,this.unfollow(),this.last=void 0}follow(e){if(this.unfollow(),!e){this.tell(null);return}let t=this.socket.channel(`purchases:${this.ref}:${e.userId}`),s={userId:e.userId,channel:t,off:()=>{},revision:-1,reading:!1,wanted:Number.NEGATIVE_INFINITY},n=[t.on("broadcast",r=>{r.event==="changed"&&this.changed(s,K(r.payload))}),t.on("state_snapshot",r=>this.held(s,K(se(r.entries)))),t.on("state_diff",r=>this.held(s,K(se(r.set))))];s.off=()=>n.forEach(r=>r()),this.watch=s,t.join().catch(()=>{}),this.read(s)}unfollow(){let e=this.watch;e&&(this.watch=void 0,e.off(),e.channel.leave())}changed(e,t){this.watch!==e||t!==void 0&&t<=e.revision||(e.reading?e.wanted=Math.max(e.wanted,t??Number.POSITIVE_INFINITY):this.read(e))}held(e,t){t!==void 0&&this.changed(e,t)}async read(e){e.reading=!0;try{for(;;){e.wanted=Number.NEGATIVE_INFINITY;try{let t=(await this.api.getMyCustomerInfo()).data;if(this.watch!==e)return;this.offer(e,t)}catch{}if(this.watch!==e||e.wanted<=e.revision)return}}finally{e.reading=!1}}offer(e,t){this.watch!==e||t.revision<=e.revision||(e.revision=t.revision,this.tell(t))}tell(e){if(!(this.last===null&&e===null)){this.last=e;for(let t of[...this.listeners])te(t,e)}}};function te(i,e){try{i(e)}catch{}}function se(i){let e=typeof i=="object"&&i!==null?i.revision:void 0;return typeof e=="object"&&e!==null?e.v:void 0}function K(i){let e=typeof i=="object"&&i!==null?i.revision:void 0;return typeof e=="number"&&Number.isFinite(e)?e:void 0}function ne(){return"cm_"+crypto.randomUUID()}async function M(i,e=4){for(let t=1;;t++)try{return await i()}catch(s){if(t>=e||!(s instanceof f)||s.status===429)throw j(s);let n=J(s,t,30);if(n===void 0)throw j(s);await new Promise(r=>setTimeout(r,n*1e3))}}var V=class{id;api;session;options;status="idle";error=null;messages=new Map;responses=new Map;order=[];turn=null;calls=new Map;voiceParts=[];handlers=new Map;answering=new Set;listeners=new Set;following;position;snapshot;told=!1;constructor(e,t,s={},n){this.api=e,this.id=t,this.options=s,this.session=n,this.position={after:s.after??0}}get state(){return this.snapshot??=this.build()}subscribe(e){return this.listeners.add(e),this.follow(),()=>{this.listeners.delete(e)}}async*[Symbol.asyncIterator](){let e,t,s=this.subscribe(()=>e?.());try{for(;;){let n=this.state;if(n!==t){t=n,yield n;continue}if(this.status==="closed"||this.status==="failed")return;await new Promise(r=>e=r)}}finally{s()}}async send(e,t={}){let s=t.clientId??ne(),n=this.messages.get(s),r=n?{...n,status:"pending",error:null}:{clientId:s,id:null,text:e,author:this.session?.snapshot()?.userId??null,authorName:"",delivery:t.delivery??"next",status:"pending",error:null,responseId:null,createdAt:new Date().toISOString(),mine:!0};this.messages.set(s,r),n||this.order.push({type:"message",key:s}),this.changed(),this.follow();let o={client_id:s,text:r.text};t.delivery!==void 0&&(o.delivery=t.delivery);try{let a=await M(async()=>(await this.api.sendChatMessage({path:{chat_id:this.id},body:o})).data);this.heard(a,!0)}catch(a){let l=this.messages.get(s);throw l.status==="pending"&&(this.messages.set(s,{...l,status:"failed",error:a instanceof f?a.code:"send_failed"}),this.changed()),a}return this.messages.get(s)}tools(e){for(let[t,s]of Object.entries(e))this.handlers.set(t,s);this.follow();for(let t of this.calls.values())this.autoAnswer(t);return()=>{for(let[t,s]of Object.entries(e))this.handlers.get(t)===s&&this.handlers.delete(t)}}async answer(e,t,s={}){let n={output:D(t),is_error:s.isError===!0};this.answering.add(e);try{return await M(()=>this.api.answerChatToolCall({path:{chat_id:this.id,call_id:e},body:n})),!0}catch(r){if(r instanceof f&&r.status===409)return!1;throw this.answering.delete(e),r}}async approve(e,t){await p(this.api.decideChatApproval({path:{chat_id:this.id,approval_id:e},body:t===void 0?{approve:!0}:{approve:!0,reason:t}}))}async deny(e,t){await p(this.api.decideChatApproval({path:{chat_id:this.id,approval_id:e},body:t===void 0?{approve:!1}:{approve:!1,reason:t}}))}async stop(){return(await p(this.api.stopChat({path:{chat_id:this.id}}))).data.stopped}async startVoice(e){let t=new RTCPeerConnection,s=e.audio??(typeof Audio=="function"?new Audio:void 0);s&&(s.autoplay=!0),t.ontrack=n=>{s&&(s.srcObject=n.streams[0]??new MediaStream([n.track]))};for(let n of e.stream.getAudioTracks())t.addTrack(n,e.stream);try{let n=await t.createOffer();await t.setLocalDescription(n);let r=e.voice===void 0?{sdp:n.sdp??""}:{sdp:n.sdp??"",voice:e.voice},o=(await p(this.api.startChatVoice({path:{chat_id:this.id},body:r}))).data;await t.setRemoteDescription({type:"answer",sdp:o.sdp??""}),this.follow();let a=o.id;return{id:a,peer:t,stop:async()=>(t.close(),(await p(this.api.closeChatVoice({path:{chat_id:this.id,voice_id:a}}))).data.seconds)}}catch(n){throw t.close(),n}}async sendToSubagent(e,t){let s={client_id:ne(),text:t};await M(()=>this.api.sendSubagentMessage({path:{chat_id:this.id,run_id:e},body:s}))}close(){this.following?.abort(),this.following=void 0,this.status="closed",this.changed()}follow(){if(this.following||this.status==="closed")return;let e=new AbortController;this.following=e,this.status="connecting",this.error=null,this.changed();let t=z(async(s,n)=>{this.status!=="connecting"&&(this.status="connecting",this.changed());let r=(await this.api.followChat({path:{chat_id:this.id},query:s,signal:n})).data;return this.status="live",this.changed(),r},{...this.position,resumeFor:this.options.resumeFor,signal:e.signal});(async()=>{try{for await(let s of t)this.take(s)}catch(s){if(this.position=t.position,e.signal.aborted)return;this.status="failed",this.error=s,this.following=void 0,this.changed()}})()}take(e){switch(e.type){case"message":this.heard(e.message,!1);return;case"turn":{let t=this.response(e.response_id);t.status=e.status,t.waiting=e.waiting,t.error=e.error,e.user_id!==void 0&&(t.startedBy=e.user_id),typeof e.solo=="boolean"&&(t.solo=e.solo),this.turn=e;for(let s of this.calls.values())s.response_id===e.response_id&&this.autoAnswer(s);break}case"text":{let t=this.response(e.response_id);t.text=t.text.slice(0,k(t.text,e.offset))+e.text;break}case"reset":{let t=this.response(e.response_id);t.text=t.text.slice(0,k(t.text,e.offset));break}case"tool":{this.response(typeof e.agent_response_id=="string"&&e.agent_response_id!==""?e.agent_response_id:e.response_id).marks.set(`tool:${e.call_id}`,e),this.calls.set(e.call_id,e),this.autoAnswer(e);break}case"voice":this.voiceParts.push(e);break;case"agent":{if(this.response(e.parent_response_id).marks.set(e.run_id?`agent:${e.run_id}`:`agent:seq:${e.seq}`,e),!e.response_id)break;let t=this.response(e.response_id);if(t.runId=e.run_id,t.agent=e.name,t.parentId===null){t.parentId=e.parent_response_id;let s=this.order.findIndex(n=>n.type==="response"&&n.key===e.response_id);s>=0&&this.order.splice(s,1)}break}}this.changed()}heard(e,t){let s=this.messages.get(e.client_id),n=e.status==="delivered"||e.status==="failed"?e.status:"pending",r={clientId:e.client_id,id:e.id,text:e.text,author:e.author,authorName:e.author_name,delivery:e.delivery,status:s&&s.status==="delivered"&&t?"delivered":n,error:e.error,responseId:e.response_id??s?.responseId??null,createdAt:e.created_at,mine:s?.mine??!1};this.messages.set(e.client_id,r),s||this.order.push({type:"message",key:e.client_id}),this.changed()}response(e){let t=this.responses.get(e);return t||(t={id:e,status:null,waiting:null,error:null,text:"",marks:new Map,runId:null,agent:null,parentId:null,startedBy:void 0,solo:void 0},this.responses.set(e,t),this.order.push({type:"response",key:e})),t}autoAnswer(e){if(e.status!=="awaiting_output"||this.answering.has(e.call_id)||!this.mine(e.response_id)||this.responses.get(e.response_id)?.solo!==!0)return;let t=this.handlers.get(e.name);t&&(this.answering.add(e.call_id),(async()=>{let s;try{s={output:D(await t(e.input,e)),is_error:!1}}catch(n){s={output:[{type:"text",text:n instanceof Error?n.message||n.name:String(n)}],is_error:!0}}try{await M(()=>this.api.answerChatToolCall({path:{chat_id:this.id,call_id:e.call_id},body:s}))}catch(n){n instanceof f&&(n.status===409||n.status===403)||this.answering.delete(e.call_id)}})())}mine(e){let t=this.session?.snapshot()?.userId;return t!==void 0&&this.responses.get(e)?.startedBy===t}changed(){this.snapshot=void 0,!this.told&&(this.told=!0,queueMicrotask(()=>{this.told=!1;let e=this.state;for(let t of[...this.listeners])try{t(e)}catch{}}))}build(){let e=new Map;for(let n of this.responses.values()){let r=n.parentId!==null?this.responses.get(n.parentId)??n:n;e.set(n.id,Te(n,r.startedBy??null,this.mine(r.id),r.solo??null))}let t=[];for(let n of this.order)n.type==="message"?t.push({type:"message",message:this.messages.get(n.key)}):this.responses.get(n.key).parentId===null&&t.push({type:"response",response:e.get(n.key)});let s=[...this.calls.values()].filter(n=>this.mine(n.response_id));return{status:this.status,error:this.error,items:t,messages:[...this.messages.values()],responses:[...e.values()],turn:this.turn,waiting:{approvals:s.filter(n=>n.status==="awaiting_approval"),outputs:s.filter(n=>n.status==="awaiting_output")},voice:[...this.voiceParts]}}};function Te(i,e,t,s){let n=[...i.marks.values()].map((a,l)=>({m:a,i:l,at:k(i.text,Math.max(0,Number(a.text_offset)||0))}));n.sort((a,l)=>a.at-l.at||a.i-l.i);let r=[],o=0;for(let{m:a,at:l}of n)l>o&&r.push({type:"text",text:i.text.slice(o,l)}),o=Math.max(o,l),r.push(a.type==="tool"?{type:"tool",tool:a}:{type:"agent",agent:a});return o<i.text.length&&r.push({type:"text",text:i.text.slice(o)}),{id:i.id,status:i.status,waiting:i.waiting,error:i.error,text:i.text,parts:r,runId:i.runId,agent:i.agent,parentId:i.parentId,startedBy:e,mine:t,solo:s}}var A=class{api;session;chats;constructor(e,t){let s=B.client(e);this.api=s,this.session=t,this.chats={async create(n){let r={agent:n.agent};return n.name!==void 0&&(r.name=n.name),n.title!==void 0&&(r.title=n.title),(await p(s.createChat({body:r}))).data},async list(){return(await p(s.listChats({}))).data.chats},async get(n){return(await p(s.getChat({path:{chat_id:n}}))).data},async delete(n){await p(s.deleteChat({path:{chat_id:n}}))}}}chat(e,t={}){if(typeof e!="string"||e==="")throw new TypeError("pb.ai.chat(id): id is the chat's");return new V(this.api,e,t,this.session)}};var O=class{api;open;session;credentials;mfa;passkey;magicLink;phone;password;email;sessions;constructor(e,t,s,n){this.api=m.client(e),this.open=m.client(t),this.session=s,this.credentials=n;let r=this.api,o=this.open;this.mfa={challenge:async(a,l,c)=>this.signedIn((await o.mfaChallenge({body:{mfa_token:a,type:l,code:c}})).data),recovery:async(a,l)=>this.signedIn((await o.mfaRecovery({body:{mfa_token:a,code:l}})).data),sendSmsCode:async a=>{await o.mfaSmsChallenge({body:{mfa_token:a}})},sendEmailCode:async a=>{await o.mfaEmailChallenge({body:{mfa_token:a}})},enrollTotp:async()=>{let a=(await r.mfaEnroll({body:{type:"totp"}})).data;return{enrollmentId:a.enrollment_id,secret:a.secret,otpUrl:a.otp_url,qrCode:a.qr_code,recoveryCodes:a.recovery_codes}},verifyTotp:async a=>{await r.mfaVerifyEnrollment({body:{code:a}})},enrollSms:async a=>(await r.mfaSmsEnroll({body:{phone:a}})).data,verifySms:async a=>{await r.mfaSmsVerifyEnrollment({body:{code:a}})},enrollEmail:async()=>{await r.mfaEmailEnroll()},factors:async()=>(await r.mfaListFactors()).data,removeFactor:async(a,l)=>{await r.mfaRemoveFactor({path:{id:a},body:{current_password:l}})},regenerateRecoveryCodes:async()=>(await r.mfaRegenerateRecoveryCodes()).data},this.passkey={register:async a=>{let l=(await r.webauthnRegisterBegin({body:{name:a}})).data,c=await this.authenticator().create({publicKey:ie(l.options.publicKey)});return(await r.webauthnRegisterFinish({body:ae(c)})).data},signIn:async(a={})=>{let l=(await o.webauthnLoginBegin({body:a.userId?{user_id:a.userId}:{}})).data,c=await this.authenticator().get({publicKey:re(l.options.publicKey)}),h=await o.webauthnLoginFinish({query:a.userId?{user_id:a.userId}:void 0,body:oe(c)});return this.signedIn(h.data)},signUp:async(a,l)=>{let c=(await o.webauthnSignupBegin({body:{identifier:a,user_name:l}})).data,h=await this.authenticator().create({publicKey:ie(c.options.publicKey)});await o.webauthnSignupFinish({query:{user_id:c.user_id},body:ae(h)});let u=(await o.webauthnLoginBegin({body:{user_id:c.user_id}})).data,v=await this.authenticator().get({publicKey:re(u.options.publicKey)});return this.signedIn((await o.webauthnLoginFinish({query:{user_id:c.user_id},body:oe(v)})).data)},list:async()=>(await r.webauthnListCredentials()).data,remove:async a=>{await r.webauthnDeleteCredential({path:{id:a}})}},this.magicLink={send:async a=>{await o.magicLinkRequest({body:{email:a}})},verify:async a=>this.signedIn((await o.magicLinkVerify({body:{token:a}})).data)},this.phone={sendCode:async a=>(await o.requestPhoneOtp({body:{phone:a,channel:"sms"}})).data,verifyCode:async(a,l)=>this.signInResult((await o.verifyPhoneOtp({body:{phone:a,token:l}})).data)},this.password={requestReset:async a=>{await o.passwordResetRequest({body:{email:a}})},confirmReset:async(a,l)=>{await o.passwordResetConfirm({body:{token:a,new_password:l}})},change:async a=>(await r.passwordChange({body:a})).data,set:async a=>(await r.setPassword({body:a})).data},this.email={verify:async a=>{await o.verifyEmail({body:a})},resendVerification:async a=>(await o.resendVerification({body:{email:a}})).data},this.sessions={list:async()=>(await r.listSessions()).data,revoke:async a=>{await r.revokeSession({path:{id:a}})},revokeAll:async()=>{await r.revokeAllSessions()}}}onAuthStateChange(e){return this.session.onChange(e)}currentSession(){return this.session.session()}async signUp(e){let t=(await this.open.signup({body:e})).data;return t.access_token&&t.refresh_token&&t.expires_in!==void 0&&await this.session.set({access_token:t.access_token,refresh_token:t.refresh_token,expires_in:t.expires_in},"SIGNED_IN",t.user),t}async signIn(e,t){return this.signInResult((await this.open.login({body:{email:e,password:t}})).data)}async signOut(){try{await this.session.session()&&await this.api.logout()}finally{await this.session.clear("SIGNED_OUT")}}async getUser(){let e=this.session.snapshot(),t=(await this.api.getMe()).data;return await this.session.setUser(t,e),t}async refreshSession(){return this.session.refresh()}async deleteAccount(e){await this.api.deleteAccount(e===void 0?void 0:{body:{password:e}}),await this.session.clear("SIGNED_OUT")}async signInResult(e){return"mfa_required"in e&&e.mfa_required?{mfaRequired:{mfaToken:e.mfa_token,factors:e.factors}}:{user:await this.signedIn(e)}}async setSession(e){return this.signedIn(e)}async signedIn(e){let t=await this.session.set({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in},"SIGNED_IN",e.user);if(e.user)return e.user;let s=(await this.api.verifyTokenUser()).data;return await this.session.setUser(s,t),s}authenticator(){if(!this.credentials)throw new Error("passkeys need navigator.credentials (or createClient({ webauthn }))");return this.credentials}},N=i=>{let e=atob(i.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(i.length/4)*4,"=")),t=new Uint8Array(e.length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);return t.buffer},g=i=>{if(!i)return;let e=i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength),t="";for(let s of e)t+=String.fromCharCode(s);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},le=i=>Array.isArray(i)?i.map(e=>({...e,id:N(String(e.id))})):void 0;function ie(i){let e=i.user;return{...i,challenge:N(String(i.challenge)),user:{...e,id:N(String(e.id))},excludeCredentials:le(i.excludeCredentials)}}function re(i){return{...i,challenge:N(String(i.challenge)),allowCredentials:le(i.allowCredentials)}}function ae(i){let e=i,t=e.response;return{id:e.id,rawId:g(e.rawId),type:"public-key",authenticatorAttachment:e.authenticatorAttachment??void 0,clientExtensionResults:e.getClientExtensionResults?.()??{},response:{clientDataJSON:g(t.clientDataJSON),attestationObject:g(t.attestationObject),transports:t.getTransports?.()}}}function oe(i){let e=i,t=e.response;return{id:e.id,rawId:g(e.rawId),type:"public-key",authenticatorAttachment:e.authenticatorAttachment??void 0,clientExtensionResults:e.getClientExtensionResults?.()??{},response:{clientDataJSON:g(t.clientDataJSON),authenticatorData:g(t.authenticatorData),signature:g(t.signature),userHandle:g(t.userHandle)}}}var _e=/^pb_[a-z0-9]+_s/,Pe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ie=new Set(["invalid_token","token_expired","session_expired","session_revoked","missing_token"]),Re=new Set(["invalid_token","token_reuse","token_expired","session_revoked","session_expired","session_device_changed"]);function Ee(i){return i.status===400&&i.code==="invalid_request"}function et(i){if(_e.test(i.publishableKey)||"secretKey"in i)throw new TypeError("a secret key never goes into a client app: palbase/web takes the publishable key (pb_<ref>_c\u2026); servers use palbase/server");let e=/^pb_([a-z0-9]+)_c/.exec(i.publishableKey)?.[1];if(e===void 0)throw new TypeError("publishableKey is the project publishable key (pb_<ref>_c\u2026)");if(i.appId!==void 0&&!Pe.test(i.appId))throw new TypeError("appId is the registered app's id, a UUID (settings.appId of palbase apps:sync), not its slug");let t=new URL(i.url).origin,s=i.storage??(Ce()?Z(`palbase.session.${t}`):Q()),n=i.retry??G,r=S(b({baseUrl:i.url,credentials:{publishableKey:i.publishableKey},fetch:i.fetch}),n),o=m.client(r),a=new T(s,async d=>(await o.refreshToken({body:{refresh_token:d}})).data,d=>d instanceof f&&(d.status===401&&Re.has(d.code)||Ee(d)),{lockName:`palbase.session.refresh.${t}`,refresh:i.refresh}),l=b({baseUrl:i.url,credentials:{publishableKey:i.publishableKey,accessToken:()=>a.accessToken()},fetch:i.fetch,xmlHttpRequest:i.xmlHttpRequest??(i.fetch===void 0?globalThis.XMLHttpRequest:void 0)}),c=S(F(l,a),n),h=new P({baseUrl:i.url,publishableKey:i.publishableKey,accessToken:()=>a.accessToken(),webSocket:i.webSocket});a.onChange(d=>{d==="SIGNED_OUT"||d==="SESSION_EXPIRED"||d==="SIGNED_IN"?h.disconnect():d==="TOKEN_REFRESHED"&&h.tokenChanged()});let u=new C(F(l,a),a,t);i.analytics&&u.start(i.analytics===!0?{}:i.analytics);let v=new Map,ce=d=>{let L=new URL(d).origin,w=v.get(L);return w||(w=S(F(b({baseUrl:L,credentials:{accessToken:()=>a.accessToken()},fetch:i.fetch}),a),n),v.set(L,w)),w},$=Object.assign(Object.create(W),{auth:new O(c,r,a,i.webauthn??globalThis.navigator?.credentials),socket:h,transport:c,analytics:u,purchases:new x(c,a,h,e,i.fetch,i.appVersion,i.appId),ai:new A(c,a)});return X($,t,ce,c,h),$}function Ce(){try{return typeof globalThis.localStorage<"u"}catch{return!1}}function F(i,e){return{async send(t){let s=await e.session();try{return await i.send(t)}catch(n){let r=t.auth.some(o=>o.includes("userJWT"));if(!(n instanceof f)||n.status!==401||!Ie.has(n.code)||!r||!s)throw n;try{e.snapshot()?.refreshToken===s.refreshToken&&await e.refresh()}catch{throw n}if(e.snapshot()?.userId!==s.userId)throw n;return i.send(t)}}}}export{y as a,Q as b,Z as c,q as d,P as e,C as f,x as g,V as h,A as i,et as j};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! palbase 0.
|
|
1
|
+
/*! palbase 0.6.2 — 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.
|
|
1
|
+
/*! palbase 0.6.2 — Palbase SDK License (see LICENSE) */
|
|
2
2
|
function o(){let n=globalThis;if(typeof n.document<"u"||n.navigator?.product==="ReactNative")return!0;let t=n.navigator?.userAgent;return typeof t=="string"&&t.startsWith("Mozilla/")}export{o as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! palbase 0.
|
|
2
|
-
import{b as c,f as u}from"./
|
|
1
|
+
/*! palbase 0.6.2 — Palbase SDK License (see LICENSE) */
|
|
2
|
+
import{b as c,f as u}from"./IYCW6PWG.js";var l={attempts:3,maxWaitSeconds:30},y=new Set([429,502,503,504]);function x(e,t=l){let r=t.sleep??h;return{async send(o){let n=p(o),a=n.body,m=!a||a.kind!=="raw"||u(a.value),f=(n.method==="GET"||n.method==="HEAD"||n.idempotent===!0)&&m;for(let i=1;;i++)try{return await e.send(n)}catch(s){if(!f||i>=t.attempts||!(s instanceof c)||n.signal?.aborted)throw s;let d=b(s,i,t.maxWaitSeconds);if(d===void 0)throw s;await r(d*1e3,n.signal)}}}}function p(e){return e.idempotent?Object.entries(e.headers??{}).some(([r,o])=>r.toLowerCase()==="idempotency-key"&&o!==void 0&&o!==null&&o!=="")?e:{...e,headers:{...e.headers,"Idempotency-Key":w()}}:e}function b(e,t,r){return y.has(e.status)||e.code==="network_error"?e.retryAfter!==void 0?e.retryAfter<=r?e.retryAfter:void 0:Math.min(.5*2**(t-1),r)*(.8+Math.random()*.4):void 0}function h(e,t){return new Promise((r,o)=>{if(t?.aborted)return o(t.reason);let n=()=>{clearTimeout(a),o(t?.reason)},a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e);t?.addEventListener("abort",n,{once:!0})})}function w(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}export{l as a,x as b,b as c,w as d};
|