@gradial/aci 0.1.46 → 0.1.48
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/README.md +4 -4
- package/dist/astro/error-page.d.ts +56 -0
- package/dist/astro/error-page.js +79 -0
- package/dist/astro/index.d.ts +4 -0
- package/dist/astro/index.js +9 -0
- package/dist/cli/emit-error-pages.d.mts +39 -0
- package/dist/cli/emit-error-pages.mjs +402 -0
- package/dist/collect/aci.js +1 -1
- package/dist/collect/aci.js.sha256 +1 -1
- package/dist/collect/webvitals.d.ts +3 -0
- package/dist/collect/webvitals.js +21 -11
- package/dist/content/default-error-page-html.d.ts +2 -0
- package/dist/content/default-error-page-html.js +6 -0
- package/dist/content/default-error-page.d.ts +23 -0
- package/dist/content/default-error-page.js +34 -0
- package/dist/content/error-page-kind.d.ts +57 -0
- package/dist/content/error-page-kind.js +106 -0
- package/dist/content/error-pages.d.ts +88 -0
- package/dist/content/error-pages.js +120 -0
- package/dist/content/index.d.ts +2 -0
- package/dist/content/index.js +2 -0
- package/dist/content/types.d.ts +12 -0
- package/dist/edge/personalization-core.js +6 -2
- package/dist/next/config.js +17 -0
- package/dist/next/error-page-instrumentation.d.ts +23 -0
- package/dist/next/error-page-instrumentation.js +36 -0
- package/dist/next/error-page-marker.d.ts +11 -0
- package/dist/next/error-page-marker.js +20 -0
- package/dist/next/error-pages.d.ts +52 -0
- package/dist/next/error-pages.js +94 -0
- package/dist/next/error-seat-payload.d.ts +33 -0
- package/dist/next/error-seat-payload.js +143 -0
- package/dist/next/error-seat.d.ts +57 -0
- package/dist/next/error-seat.js +83 -0
- package/dist/next/index.d.ts +4 -0
- package/dist/next/index.js +8 -0
- package/package.json +14 -8
- package/src/cli/emit-error-pages.mjs +424 -0
- package/templates/astro/template/package.json.tmpl +1 -1
- package/templates/astro/template/src/aci/error-page-instrumentation.mjs +33 -0
- package/templates/astro/template/src/pages/404.astro +54 -0
- package/templates/astro/template/src/pages/500.astro +53 -0
- package/templates/astro/template/src/pages/[...slug].astro +15 -2
- package/templates/common/.agents/skills/authoring/SKILL.md +71 -0
- package/templates/common/.content/config/robots.txt +4 -0
- package/templates/common/.content/config/site.json.tmpl +4 -0
- package/templates/common/.content/pages/404/_index.json +31 -0
- package/templates/common/.content/pages/error/_index.json +31 -0
- package/templates/common/.content/schemas/site.schema.json +9 -0
- package/templates/common/starter-content/.content/config/robots.txt +2 -0
- package/templates/common/starter-content/.content/config/site.json +4 -0
- package/templates/common/starter-content/.content/pages/404/_index.json +31 -0
- package/templates/common/starter-content/.content/pages/about/_index.json +3 -6
- package/templates/common/starter-content/.content/pages/error/_index.json +31 -0
- package/templates/common/starter-content/.content/pages/home/_index.json +10 -19
- package/templates/common/starter-content/.content/schemas/site.schema.json +9 -0
- package/templates/nextjs/template/package.json.tmpl +1 -1
- package/templates/nextjs/template/src/aci/error-page-instrumentation.d.mts +4 -0
- package/templates/nextjs/template/src/aci/error-page-instrumentation.mjs +38 -0
- package/templates/nextjs/template/src/app/error.tsx +18 -0
- package/templates/nextjs/template/src/app/not-found.tsx +13 -0
package/dist/collect/aci.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var Ne=Object.defineProperty;var Le=(t,e,n)=>e in t?Ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var y=(t,e,n)=>Le(t,typeof e!="symbol"?e+"":e,n);var x="data-aci-event",Oe="data-aci-on",H="data-aci-prop-",De="data-aci-refresh",q="custom.";function D(t){if(typeof t!="string")return;let e=t.trim().toLowerCase();if(!(e===""||/[\s/]/.test(e)))return e.startsWith(q)?e:q+e}function Re(t){let e;for(let n of Array.from(t.attributes)){if(!n.name.startsWith(H))continue;let r=n.name.slice(H.length);r!==""&&((e!=null?e:e={})[r]=n.value)}return e}function U(t,e){let n=D(t.getAttribute(x));if(n===void 0){e==null||e("capture",{reason:"malformed_declaration",attr:x});return}return{eventName:n,properties:Re(t)}}function X(t){var e,n;return(n=(e=t.getAttribute(Oe))==null?void 0:e.trim().toLowerCase())!=null?n:"click"}function $(t,e,n){let{document:r,debug:o}=e;r.addEventListener("click",f=>{var l,p;try{let u=f.target;if((l=u==null?void 0:u.closest)==null?void 0:l.call(u,`[${De}]`)){n==null||n();return}let m=(p=u==null?void 0:u.closest)==null?void 0:p.call(u,`[${x}]`);if(!m||X(m)!=="click")return;let g=U(m,o);g&&t(g)}catch(u){o==null||o("capture",{reason:"click_handler_failed",error:String(u)})}});let i=e.intersectionObserver;if(typeof i!="function")return;let s=Array.from(r.querySelectorAll(`[${x}]`)).filter(f=>X(f)==="visible");if(s.length===0)return;let a=new WeakSet,c=new i((f,l)=>{try{for(let p of f){if(!p.isIntersecting||p.intersectionRatio<.5||a.has(p.target))continue;a.add(p.target),l.unobserve(p.target);let u=U(p.target,o);u&&t(u)}}catch(p){o==null||o("capture",{reason:"visible_handler_failed",error:String(p)})}},{threshold:.5});for(let f of s)c.observe(f)}function K(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Y(t,e,n,r){let o=(...a)=>{try{let[c,...f]=a;if(c==="track"){let l=D(f[0]);if(l===void 0){r==null||r("capture",{reason:"malformed_track_name",name:f[0]});return}let p=f[1];if(p!==void 0&&!K(p)){r==null||r("capture",{reason:"malformed_track_properties",name:l});return}n.track(l,p);return}if(c==="consent"){if(e.preset!=="manual"){r==null||r("consent",{reason:"preset_authoritative",preset:e.preset});return}let l=f[0];if(!K(l)){r==null||r("consent",{reason:"malformed_consent_envelope"});return}n.consent({p:l.p,src:l.src});return}r==null||r("capture",{reason:"unknown_command",command:c})}catch(c){r==null||r("capture",{reason:"command_failed",error:String(c)})}},i=t.aci,s=i==null?void 0:i.q;if(t.aci=o,s!=null)for(let a of Array.from(s)){let c=Array.from(a);o(...c)}}var Be="experiment.exposure",Fe='script[type="application/json"][data-aci-assignments]';function Ve(t){if(typeof t!="object"||t===null)return null;let e=t,n=e.experimentId,r=e.armId,o=e.allocationVersion;return typeof n!="string"||n===""||typeof r!="string"||r===""||typeof o!="string"?null:{experimentId:n,armId:r,allocationVersion:o}}function Me(t,e){try{let n=t.querySelector(Fe);if(!n)return[];let r=n.textContent;if(r==null||r.trim()==="")return[];let o=JSON.parse(r);if(typeof o!="object"||o===null)return e==null||e("capture",{reason:"assignments_malformed"}),[];let i=o;if(i.v!==1||!Array.isArray(i.experiments))return e==null||e("capture",{reason:"assignments_malformed"}),[];let s=[];for(let a of i.experiments){let c=Ve(a);c&&s.push(c)}return s}catch(n){return e==null||e("capture",{reason:"assignments_parse_failed",error:String(n)}),[]}}function J(t,e){if(!e||t.experiment!==void 0)return t;let n=e.getActiveAssignments()[0];if(!n)return t;let r={experimentId:n.experimentId,armId:n.armId,allocationVersion:n.allocationVersion};return{...t,experiment:r}}function Q(t){let e=[],n=new Set,r,o=()=>{e=Me(t.document,t.debug);for(let i of e)n.has(i.experimentId)||(n.add(i.experimentId),r==null||r({eventName:Be,url:t.window.location.href,experiment:{experimentId:i.experimentId,armId:i.armId,allocationVersion:i.allocationVersion}}))};return{getActiveAssignments:()=>e.map(i=>({...i})),start(i){r=i,o()},rearm(){n.clear(),o()}}}var Z="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function We(t){globalThis.crypto.getRandomValues(t)}function S(t,e){let n=t!=null?t:Date.now(),r="";for(let c=0;c<10;c++)r=Z[n%32]+r,n=Math.floor(n/32);let o=new Uint8Array(10);(e!=null?e:We)(o);let i="",s=0,a=0;for(let c of o)for(s=s<<8|c,a+=8;a>=5;)i+=Z[s>>>a-5&31],a-=5;return r+i}var Ge=60*1024,je=100,ze=5e3,ee='{"envelopeId":"',te='","events":[',ne="]}",He=26,A=ee.length+He+te.length+ne.length,qe=new TextEncoder,Ue=t=>qe.encode(t).length,T=class{constructor(e){y(this,"options");y(this,"maxBytes");y(this,"queue",[]);y(this,"queuedBytes",0);y(this,"flushing",!1);y(this,"intervalId");var n;this.options=e,this.maxBytes=(n=e.maxBatchBytes)!=null?n:Ge}get pending(){return this.queue.length}push(e){let n=JSON.stringify(e),r=Ue(n);this.queue.push({json:n,bytes:r,eventId:e.eventId}),this.queuedBytes+=r,!this.flushing&&this.envelopeBytes()>=this.maxBytes&&this.flush()}flush(){var e,n;if(!this.flushing){this.flushing=!0;try{(n=(e=this.options).onTick)==null||n.call(e),this.drain()}finally{this.flushing=!1}}}start(){var o,i,s,a;let e=(o=this.options.timers)!=null?o:{setInterval:(c,f)=>setInterval(c,f),clearInterval:c=>clearInterval(c)};this.intervalId=e.setInterval(()=>this.flush(),(i=this.options.flushIntervalMs)!=null?i:ze);let n=(s=this.options.documentTarget)!=null?s:typeof document!="undefined"?document:void 0;n==null||n.addEventListener("visibilitychange",()=>{n.visibilityState==="hidden"&&this.flush()});let r=(a=this.options.windowTarget)!=null?a:typeof window!="undefined"?window:void 0;r==null||r.addEventListener("pagehide",()=>this.flush()),this.flush()}stop(){if(this.intervalId!==void 0){let e=this.options.timers;e?e.clearInterval(this.intervalId):clearInterval(this.intervalId),this.intervalId=void 0}}envelopeBytes(){let e=this.queue.length>1?this.queue.length-1:0;return A+this.queuedBytes+e}drain(){var e,n,r;for(;this.queue.length>0;){let o=this.queue[0];if(A+o.bytes>this.maxBytes){this.queue.shift(),this.queuedBytes-=o.bytes,(n=(e=this.options).debug)==null||n.call(e,"flush",{reason:"oversize_event",eventId:o.eventId,bytes:o.bytes});continue}let i=[],s=A;for(;this.queue.length>0;){let c=this.queue[0];if(A+c.bytes>this.maxBytes||i.length>=je)break;let f=s+c.bytes+(i.length>0?1:0);if(f>this.maxBytes)break;i.push(c.json),s=f,this.queue.shift(),this.queuedBytes-=c.bytes}if(i.length===0)continue;let a=((r=this.options.createEnvelopeId)!=null?r:S)();this.options.send(ee+a+te+i.join(",")+ne)}}};var Xe=new Set(["c15t","onetrust","cookiebot","trustarc","manual"]);function P(t,e){var o;let n=(o=t==null?void 0:t.getAttribute)==null?void 0:o.call(t,e);if(n==null)return;let r=n.trim();return r===""?void 0:r}function re(t){var r;let e=(r=P(t,"data-aci-consent"))==null?void 0:r.toLowerCase(),n=e!==void 0&&Xe.has(e)?e:"manual";return{site:P(t,"data-aci-site"),preset:n,categories:P(t,"data-aci-consent-categories"),debug:P(t,"data-aci-debug")==="1"}}function oe(t,e,n){if(!t)return()=>{};let r=e!=null?e:(i=>console.debug("[aci]",i)),o=n!=null?n:Date.now;return(i,s)=>{try{r({t:o(),kind:i,detail:s})}catch{}}}var R=new TextEncoder,$e=2048,Ke=32,Ye=128,Je=512,Qe=2147483647,Ze=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/,et=/^[\t\n\v\f\r ]+|[\t\n\v\f\r ]+$/g,tt=new Set(["true","all","granted","yes","personalization","personalized"]);function _(t,e=!0){let n=w(t);if(!n)return null;if(e)try{n=decodeURIComponent(n)}catch{}if(n=w(n),!n||R.encode(n).byteLength>$e)return null;if(tt.has(n.toLowerCase()))return{version:0,purposes:["personalization"],grantedAt:""};try{let r=JSON.parse(n),o=typeof r.t=="string"?r.t:"";return!Number.isInteger(r.v)||r.v<0||r.v>Qe||!Array.isArray(r.p)||r.p.length>Ke||!r.p.every(i=>typeof i=="string")||r.p.some(i=>R.encode(i).byteLength>Ye)||r.t!==void 0&&r.t!==null&&(typeof r.t!="string"||r.t===""||!nt(r.t))||r.src!==void 0&&r.src!==null&&typeof r.src!="string"||typeof r.src=="string"&&R.encode(r.src).byteLength>Je?null:{version:r.v,purposes:r.p,grantedAt:o,source:typeof r.src=="string"?r.src:void 0}}catch{return null}}function B(t){return(t==null?void 0:t.purposes.some(e=>w(e).toLowerCase()==="personalization"))||!1}function w(t){return t.replace(et,"")}function nt(t){let e=Ze.exec(t);if(!e||Number.isNaN(Date.parse(t)))return!1;let n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),i=Number(e[4]),s=Number(e[5]),a=Number(e[6]);if(r<1||r>12||o<1||o>rt(n,r)||i>23||s>59||a>59)return!1;let c=e[8];return c==="Z"||Number(c.slice(1,3))<=23&&Number(c.slice(4,6))<=59}function rt(t,e){return e===2?t%4===0&&(t%100!==0||t%400===0)?29:28:[4,6,9,11].includes(e)?30:31}var ie="personalization",F="aci_consent",V=1,ot=365*24*60*60;function it(t,e){var r;let n=`${F}=${t.encoded}; Path=/; Max-Age=${ot}; SameSite=Lax`;((r=e.document.location)==null?void 0:r.protocol)==="https:"&&(n+="; Secure"),e.document.cookie=n}function I(t,e,n){var o;let r=st(t,e,n.now);return r===null?!1:(B(r.snapshot)||(o=n.gapBuffer)==null||o.purge(),it(r,n),!0)}function se(t){for(let e of t.cookie.split(";")){let n=w(e);if(n.startsWith(F+"="))return n.slice(F.length+1)}}function ae(t){return t===void 0||t===""?!1:B(_(t,!0))}function ce(t){var r;if(!Array.isArray(t))return;let e=[];for(let o of t){if(typeof o!="string")return;e.push(w(o))}let n=JSON.stringify({v:V,p:e});return(r=_(n,!1))==null?void 0:r.purposes}function ue(t){var o;if(t!==void 0&&typeof t!="string")return;let e=typeof t=="string"?w(t):"",r=JSON.stringify({v:V,p:[],src:e===""?"manual":e});return(o=_(r,!1))==null?void 0:o.source}function st(t,e,n){try{let r=JSON.stringify({v:V,p:t,t:new Date((n!=null?n:Date.now)()).toISOString(),src:e}),o=_(r,!1);return o===null?null:{encoded:encodeURIComponent(r),snapshot:o}}catch{return null}}var at="cmp-",ct=/^[a-z0-9._-]+$/,ut={c15t:"measurement,marketing",onetrust:"c0002,c0004",cookiebot:"statistics,marketing",trustarc:"functional,advertising"};function M(t,e){let n=e!=null?e:ut[t];if(n===void 0)return null;let r=n.split(",").map(o=>o.trim().toLowerCase()).filter(o=>o!=="");if(r.length===0)return null;for(let o of r)if(!ct.test(o))return null;return r}function ft(t,e){return e.filter(r=>r in t.categories).some(r=>t.categories[r]===!0)?[ie]:[]}function k(t,e,n){var r,o,i,s;try{let a=M(e,n.categories);if(a===null){(r=n.debug)==null||r.call(n,"consent",{reason:"unparseable_mapping",preset:e});return}if(a.filter(l=>l in t.categories).length===0){(o=n.debug)==null||o.call(n,"consent",{reason:"unmappable_cmp_state",preset:e});return}let f=ft(t,a);I(f,at+e,{document:n.document,gapBuffer:n.gapBuffer,now:n.now}),(i=n.debug)==null||i.call(n,"consent",{reason:"written",preset:e,purposes:f})}catch(a){(s=n.debug)==null||s.call(n,"consent",{reason:"consent_bridge_failed",preset:e,error:String(a)})}}var fe=250,lt=1e4;function C(t,e,n){var s;let r=(s=n==null?void 0:n.scheduler)!=null?s:{setTimeout:(a,c)=>setTimeout(a,c),clearTimeout:a=>clearTimeout(a)},o=Math.floor(lt/fe),i=()=>{var c,f;let a;try{a=t()}catch(l){(c=n==null?void 0:n.debug)==null||c.call(n,"consent",{reason:"cmp_read_failed",error:String(l)});return}if(a!==void 0){e(a);return}if(o-=1,o<=0){(f=n==null?void 0:n.debug)==null||f.call(n,"consent",{reason:"cmp_not_found"});return}r.setTimeout(i,fe)};i()}function b(t,e){try{e()}catch(n){t==null||t("consent",{reason:"adapter_failed",error:String(n)})}}var dt="c15t";function pt(t){if(typeof t!="object"||t===null)return;let e={};for(let[n,r]of Object.entries(t))typeof r=="boolean"&&(e[n.toLowerCase()]=r);return{categories:e}}function mt(t,e){return typeof t=="object"&&t!==null?"consents"in t?t.consents:t:e.consents}function le(t){C(()=>{let e=t.window.c15t;return typeof e=="object"&&e!==null?e:void 0},e=>{b(t.debug,()=>{var r;let n=o=>{let i=pt(o);i&&k(i,dt,t)};n(e.consents),(r=e.onConsentChange)==null||r.call(e,o=>b(t.debug,()=>n(mt(o,e))))})},t)}var gt="cookiebot",vt=["CookiebotOnConsentReady","CookiebotOnAccept","CookiebotOnDecline"];function de(t){let e=t.Cookiebot;return typeof e=="object"&&e!==null?e:void 0}function ht(t){if(typeof t!="object"||t===null)return;let e={};for(let[n,r]of Object.entries(t))typeof r=="boolean"&&(e[n.toLowerCase()]=r);return{categories:e}}function pe(t){let e=()=>{let r=de(t.window);if(!r||r.hasResponse!==!0)return;let o=ht(r.consent);o&&k(o,gt,t)},n=t.window;if(typeof n.addEventListener=="function")for(let r of vt)n.addEventListener(r,()=>b(t.debug,e));C(()=>de(t.window),()=>b(t.debug,e),t)}var me="onetrust",bt=/^c\d{4}$/;function yt(t,e){let n={};for(let r of t.split(",")){let o=r.trim().toLowerCase();o!==""&&(n[o]=!0)}for(let r of e!=null?e:[])!(r in n)&&bt.test(r)&&(n[r]=!1);return{categories:n}}function ge(t){let e=t.window,n=()=>{let o=e.OnetrustActiveGroups;if(typeof o!="string")return;let i=M(me,t.categories);k(yt(o,i),me,t)},r=e.OptanonWrapper;e.OptanonWrapper=()=>{if(typeof r=="function")try{r()}catch{}b(t.debug,n)},C(()=>{let o=e.OnetrustActiveGroups;return typeof o=="string"?o:void 0},()=>b(t.debug,n),t)}var Et="trustarc",kt={required:1,functional:2,advertising:3},ve="PrivacyManagerAPI";function he(t){let e=t.truste,n=e==null?void 0:e.cma,r=n==null?void 0:n.callApi;return typeof r=="function"?r.bind(n):void 0}function Ct(t){if(typeof t!="object"||t===null)return;let e=t.consentDecision;if(typeof e!="number"||!Number.isFinite(e)||e<1)return;let n={};for(let[r,o]of Object.entries(kt))n[r]=e>=o;return{categories:n}}function wt(t){return typeof t=="string"?t.includes(ve):typeof t=="object"&&t!==null&&ve in t}function St(t){let e=t.location;return typeof(e==null?void 0:e.hostname)=="string"?e.hostname:void 0}function be(t){let e=()=>{let r=he(t.window);if(!r)return;let o=Ct(r("getConsentDecision",St(t.window)));o&&k(o,Et,t)},n=t.window;typeof n.addEventListener=="function"&&n.addEventListener("message",r=>b(t.debug,()=>{wt(r==null?void 0:r.data)&&e()})),C(()=>he(t.window),()=>b(t.debug,e),t)}var N="aci:buf";var ye="aci_m",L=class{constructor(e){y(this,"events");y(this,"storage");y(this,"debug");this.debug=e==null?void 0:e.debug,this.storage=e==null?void 0:e.storage,this.events=this.restore()}push(e){var n;this.events.push(e),this.events.length>50&&(this.events.splice(0,this.events.length-50),(n=this.debug)==null||n.call(this,"buffer",{reason:"cap_drop_oldest"})),this.persist()}drain(){let e=this.events;return this.events=[],this.persist(),e}purge(){var e;this.events.length>0&&((e=this.debug)==null||e.call(this,"buffer",{reason:"purged",count:this.events.length})),this.events=[],this.persist()}size(){return this.events.length}restore(){var r;let e=this.storage;if(!e)return[];let n;try{n=e.getItem(N)}catch(o){return this.storage=void 0,(r=this.debug)==null||r.call(this,"buffer",{reason:"storage_unavailable",error:String(o)}),[]}if(n==null)return[];try{let o=JSON.parse(n);if(Array.isArray(o))return o}catch{}try{e.removeItem(N)}catch{this.storage=void 0}return[]}persist(){var n;let e=this.storage;if(e)try{this.events.length===0?e.removeItem(N):e.setItem(N,JSON.stringify(this.events))}catch(r){this.storage=void 0,(n=this.debug)==null||n.call(this,"buffer",{reason:"storage_unavailable",error:String(r)})}}};function Ee(t){for(let e of t.cookie.split(";")){let n=e.trim();if(n.startsWith(ye+"="))return n.slice(ye.length+1)!==""}return!1}function ke(t,e){if(e.grants()&&!e.marker()){e.gapBuffer.push(t);return}e.batcher.push(t)}function W(t,e,n,r){if(t.size()===0||!n())return;let o=t.drain();for(let i of o)e.push(i);r==null||r("buffer",{reason:"flushed",count:o.length})}var _t="rum.link_click";function Ce(t,e){var i;let{document:n,debug:r}=e,o=(i=n.defaultView)==null?void 0:i.location;n.addEventListener("click",s=>{var a,c,f;try{let l=s.target,p=(a=l==null?void 0:l.closest)==null?void 0:a.call(l,"a[href]");if(!p)return;let u=p;t({eventName:_t,url:o==null?void 0:o.href,properties:{linkText:(f=(c=u.textContent)==null?void 0:c.trim())!=null?f:"",linkHref:u.href}})}catch(l){r==null||r("capture",{reason:"link_click_failed",error:String(l)})}},{capture:!0})}var xt="rum.page_view";function we(t){let e=t.indexOf("#");return e===-1?t:t.slice(0,e)}function Se(t,e){let n=we(t.location.href),r=()=>{let s=we(t.location.href);if(s!==n){n=s;for(let a of e)a()}},o=t.history,i=s=>{let a=o[s].bind(o);o[s]=(...c)=>{let f=a(...c);return r(),f}};i("pushState"),i("replaceState"),t.addEventListener("popstate",r)}function _e(t,e){let n=()=>t({eventName:xt,url:e.location.href,referrer:e.document.referrer});return n(),n}var G="/collect";function xe(t,e){let n=e==null?void 0:e.debug,r=e!==void 0&&"navigator"in e?e.navigator:globalThis.navigator,o=e!==void 0&&"fetch"in e?e.fetch:globalThis.fetch,i;try{i=new Blob([t],{type:"text/plain"})}catch{n==null||n("flush",{reason:"no_blob"});return}if(r!=null&&r.sendBeacon)try{if(r.sendBeacon(G,i))return}catch{}if(!o){n==null||n("flush",{reason:"no_transport"});return}try{o(G,{method:"POST",body:i,keepalive:!0}).catch(s=>{n==null||n("flush",{reason:"fetch_failed",error:String(s)})})}catch(s){n==null||n("flush",{reason:"fetch_failed",error:String(s)})}}function Ae(t){var n,r;let e=t!==void 0&&"fetch"in t?t.fetch:globalThis.fetch;if(!e)return Promise.resolve(!1);try{let o=((n=t==null?void 0:t.createEnvelopeId)!=null?n:S)(),i=new Blob([`{"envelopeId":"${o}","events":[]}`],{type:"text/plain"});return e(G,{method:"POST",body:i,keepalive:!0,credentials:"same-origin"}).then(s=>{var a;return typeof s=="object"&&s!==null&&"ok"in s&&s.ok===!1?((a=t==null?void 0:t.debug)==null||a.call(t,"flush",{reason:"refresh_failed",status:"not_ok"}),!1):!0}).catch(s=>{var a;return(a=t==null?void 0:t.debug)==null||a.call(t,"flush",{reason:"refresh_failed",error:String(s)}),!1})}catch(o){return(r=t==null?void 0:t.debug)==null||r.call(t,"flush",{reason:"refresh_failed",error:String(o)}),Promise.resolve(!1)}}var At="rum.variation_view",j="data-aci-variation";function Te(t,e){var f,l,p;let{document:n,debug:r}=e,o=e.MutationObserver;if(typeof o!="function")return;let i=(f=n.defaultView)==null?void 0:f.location,s=new WeakSet,a=u=>{let h=u.getAttribute(j);h!=null&&(s.has(u)||(s.add(u),t({eventName:At,url:i==null?void 0:i.href,properties:{variantKey:h}})))},c=u=>{try{u.hasAttribute(j)&&a(u);for(let h of Array.from(u.querySelectorAll(`[${j}]`)))a(h)}catch(h){r==null||r("capture",{reason:"variation_scan_failed",error:String(h)})}};try{let u=(l=n.body)!=null?l:n.documentElement;u&&c(u)}catch(u){r==null||r("capture",{reason:"variation_initial_scan_failed",error:String(u)})}try{let u=(p=n.body)!=null?p:n.documentElement;if(!u)return;new o(m=>{try{for(let g of m)for(let d=0;d<g.addedNodes.length;d++){let v=g.addedNodes[d];if((v==null?void 0:v.nodeType)!==1)continue;let E=v.element;E&&c(E)}}catch(g){r==null||r("capture",{reason:"variation_observer_failed",error:String(g)})}}).observe(u,{subtree:!0,childList:!0})}catch(u){r==null||r("capture",{reason:"variation_observe_failed",error:String(u)})}}var Tt="rum.web_vital";function Pe(t,e){var h,m,g;let n=e.PerformanceObserver;if(typeof n!="function")return;let{performance:r,debug:o}=e,i=(m=(h=e.window)==null?void 0:h.location)==null?void 0:m.href,s=e.document,a=new Set,c=(d,v)=>{a.has(d)||(a.add(d),t({eventName:Tt,url:i,properties:{vitalName:d,vitalValue:v}}))};try{let d=r==null?void 0:r.getEntriesByType("navigation")[0];d&&typeof d.responseStart=="number"&&typeof d.requestStart=="number"&&c("TTFB",d.responseStart-d.requestStart)}catch(d){o==null||o("capture",{reason:"ttfb_failed",error:String(d)})}let f=0,l=0,p=(d,v)=>{try{new n(Ie=>{try{for(let O of Ie.getEntries())v(O)}catch(O){o==null||o("capture",{reason:`${d}_handler_failed`,error:String(O)})}}).observe({type:d,buffered:!0})}catch(E){o==null||o("capture",{reason:`${d}_observe_failed`,error:String(E)})}};p("largest-contentful-paint",d=>{c("LCP",d.startTime)}),p("first-input",d=>{c("FID",d.startTime)}),p("layout-shift",d=>{var v;d.hadRecentInput||(f+=(v=d.value)!=null?v:0)}),p("event",d=>{var E;let v=(E=d.value)!=null?E:0;v>l&&(l=v)}),p("paint",d=>{d.name==="first-contentful-paint"&&c("FCP",d.startTime)});let u=()=>{try{a.has("CLS")||c("CLS",f),a.has("INP")||c("INP",l)}catch(d){o==null||o("capture",{reason:"visibility_handler_failed",error:String(d)})}};s&&s.addEventListener("visibilitychange",()=>{s.visibilityState==="hidden"&&u()}),(g=e.window)==null||g.addEventListener("pagehide",u)}var z={c15t:le,onetrust:ge,cookiebot:pe,trustarc:be};function Pt(t){var e,n;return typeof((e=t.navigator)==null?void 0:e.sendBeacon)=="function"&&typeof t.IntersectionObserver=="function"&&typeof((n=t.crypto)==null?void 0:n.getRandomValues)=="function"}function It(t){try{return t.sessionStorage}catch{return}}function Nt(t){var o;let e=t!=null?t:typeof window!="undefined"?window:void 0;if(!e||e.__aci_loaded||(e.__aci_loaded=!0,!Pt(e)))return;let n=re(e.document.currentScript),r=oe(n.debug);try{let i=e.document,s=new L({storage:It(e),debug:r}),a=()=>{try{return ae(se(i))}catch{return!1}},c=()=>{try{return Ee(i)}catch{return!1}},f={navigator:e.navigator,fetch:typeof e.fetch=="function"?e.fetch.bind(e):void 0,debug:r},l;l=new T({send:m=>xe(m,f),debug:r,onTick:()=>W(s,l,c,r),timers:{setInterval:(m,g)=>e.setInterval(m,g),clearInterval:m=>e.clearInterval(m)},documentTarget:i,windowTarget:e});let p=Q({document:i,window:e,debug:r}),u=m=>{ke({...J(m,p),eventId:S(void 0,g=>e.crypto.getRandomValues(g))},{grants:a,marker:c,gapBuffer:s,batcher:l})};p.start(u),Y(e,n,{track:(m,g)=>u({eventName:m,properties:g}),consent:({p:m,src:g})=>{let d=ce(m);if(d===void 0){r("consent",{reason:"malformed_purposes"});return}let v=ue(g);if(v===void 0){r("consent",{reason:"malformed_source"});return}I(d,v,{document:i,gapBuffer:s})||r("consent",{reason:"oversized_envelope"})}},r);let h=_e(u,e);Se(e,[()=>p.rearm(),h]),$(u,{document:i,intersectionObserver:e.IntersectionObserver,debug:r},()=>{Ae(f).then(m=>{m&&e.location.reload()})}),Ce(u,{document:i,debug:r}),Pe(u,{performance:e.performance,PerformanceObserver:e.PerformanceObserver,window:e,document:i,debug:r}),Te(u,{document:i,MutationObserver:e.MutationObserver,debug:r}),n.preset!=="manual"&&((o=z[n.preset])==null||o.call(z,{window:e,document:i,categories:n.categories,gapBuffer:s,debug:r,scheduler:{setTimeout:(m,g)=>e.setTimeout(m,g),clearTimeout:m=>e.clearTimeout(m)}})),l.start(),W(s,l,c,r),r("init",{config:n})}catch(i){r("init",{error:String(i)})}}Nt();})();
|
|
1
|
+
"use strict";(()=>{var Le=Object.defineProperty;var Oe=(t,e,n)=>e in t?Le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var y=(t,e,n)=>Oe(t,typeof e!="symbol"?e+"":e,n);var x="data-aci-event",De="data-aci-on",q="data-aci-prop-",Re="data-aci-refresh",U="custom.";function D(t){if(typeof t!="string")return;let e=t.trim().toLowerCase();if(!(e===""||/[\s/]/.test(e)))return e.startsWith(U)?e:U+e}function Be(t){let e;for(let n of Array.from(t.attributes)){if(!n.name.startsWith(q))continue;let r=n.name.slice(q.length);r!==""&&((e!=null?e:e={})[r]=n.value)}return e}function X(t,e){let n=D(t.getAttribute(x));if(n===void 0){e==null||e("capture",{reason:"malformed_declaration",attr:x});return}return{eventName:n,properties:Be(t)}}function $(t){var e,n;return(n=(e=t.getAttribute(De))==null?void 0:e.trim().toLowerCase())!=null?n:"click"}function K(t,e,n){let{document:r,debug:o}=e;r.addEventListener("click",l=>{var d,p;try{let u=l.target;if((d=u==null?void 0:u.closest)==null?void 0:d.call(u,`[${Re}]`)){n==null||n();return}let m=(p=u==null?void 0:u.closest)==null?void 0:p.call(u,`[${x}]`);if(!m||$(m)!=="click")return;let g=X(m,o);g&&t(g)}catch(u){o==null||o("capture",{reason:"click_handler_failed",error:String(u)})}});let i=e.intersectionObserver;if(typeof i!="function")return;let s=Array.from(r.querySelectorAll(`[${x}]`)).filter(l=>$(l)==="visible");if(s.length===0)return;let a=new WeakSet,c=new i((l,d)=>{try{for(let p of l){if(!p.isIntersecting||p.intersectionRatio<.5||a.has(p.target))continue;a.add(p.target),d.unobserve(p.target);let u=X(p.target,o);u&&t(u)}}catch(p){o==null||o("capture",{reason:"visible_handler_failed",error:String(p)})}},{threshold:.5});for(let l of s)c.observe(l)}function Y(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function J(t,e,n,r){let o=(...a)=>{try{let[c,...l]=a;if(c==="track"){let d=D(l[0]);if(d===void 0){r==null||r("capture",{reason:"malformed_track_name",name:l[0]});return}let p=l[1];if(p!==void 0&&!Y(p)){r==null||r("capture",{reason:"malformed_track_properties",name:d});return}n.track(d,p);return}if(c==="consent"){if(e.preset!=="manual"){r==null||r("consent",{reason:"preset_authoritative",preset:e.preset});return}let d=l[0];if(!Y(d)){r==null||r("consent",{reason:"malformed_consent_envelope"});return}n.consent({p:d.p,src:d.src});return}r==null||r("capture",{reason:"unknown_command",command:c})}catch(c){r==null||r("capture",{reason:"command_failed",error:String(c)})}},i=t.aci,s=i==null?void 0:i.q;if(t.aci=o,s!=null)for(let a of Array.from(s)){let c=Array.from(a);o(...c)}}var Fe="experiment.exposure",Ve='script[type="application/json"][data-aci-assignments]';function Me(t){if(typeof t!="object"||t===null)return null;let e=t,n=e.experimentId,r=e.armId,o=e.allocationVersion;return typeof n!="string"||n===""||typeof r!="string"||r===""||typeof o!="string"?null:{experimentId:n,armId:r,allocationVersion:o}}function We(t,e){try{let n=t.querySelector(Ve);if(!n)return[];let r=n.textContent;if(r==null||r.trim()==="")return[];let o=JSON.parse(r);if(typeof o!="object"||o===null)return e==null||e("capture",{reason:"assignments_malformed"}),[];let i=o;if(i.v!==1||!Array.isArray(i.experiments))return e==null||e("capture",{reason:"assignments_malformed"}),[];let s=[];for(let a of i.experiments){let c=Me(a);c&&s.push(c)}return s}catch(n){return e==null||e("capture",{reason:"assignments_parse_failed",error:String(n)}),[]}}function Q(t,e){if(!e||t.experiment!==void 0)return t;let n=e.getActiveAssignments()[0];if(!n)return t;let r={experimentId:n.experimentId,armId:n.armId,allocationVersion:n.allocationVersion};return{...t,experiment:r}}function Z(t){let e=[],n=new Set,r,o=()=>{e=We(t.document,t.debug);for(let i of e)n.has(i.experimentId)||(n.add(i.experimentId),r==null||r({eventName:Fe,url:t.window.location.href,experiment:{experimentId:i.experimentId,armId:i.armId,allocationVersion:i.allocationVersion}}))};return{getActiveAssignments:()=>e.map(i=>({...i})),start(i){r=i,o()},rearm(){n.clear(),o()}}}var ee="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function Ge(t){globalThis.crypto.getRandomValues(t)}function S(t,e){let n=t!=null?t:Date.now(),r="";for(let c=0;c<10;c++)r=ee[n%32]+r,n=Math.floor(n/32);let o=new Uint8Array(10);(e!=null?e:Ge)(o);let i="",s=0,a=0;for(let c of o)for(s=s<<8|c,a+=8;a>=5;)i+=ee[s>>>a-5&31],a-=5;return r+i}var je=60*1024,ze=100,He=5e3,te='{"envelopeId":"',ne='","events":[',re="]}",qe=26,A=te.length+qe+ne.length+re.length,Ue=new TextEncoder,Xe=t=>Ue.encode(t).length,T=class{constructor(e){y(this,"options");y(this,"maxBytes");y(this,"queue",[]);y(this,"queuedBytes",0);y(this,"flushing",!1);y(this,"intervalId");var n;this.options=e,this.maxBytes=(n=e.maxBatchBytes)!=null?n:je}get pending(){return this.queue.length}push(e){let n=JSON.stringify(e),r=Xe(n);this.queue.push({json:n,bytes:r,eventId:e.eventId}),this.queuedBytes+=r,!this.flushing&&this.envelopeBytes()>=this.maxBytes&&this.flush()}flush(){var e,n;if(!this.flushing){this.flushing=!0;try{(n=(e=this.options).onTick)==null||n.call(e),this.drain()}finally{this.flushing=!1}}}start(){var o,i,s,a;let e=(o=this.options.timers)!=null?o:{setInterval:(c,l)=>setInterval(c,l),clearInterval:c=>clearInterval(c)};this.intervalId=e.setInterval(()=>this.flush(),(i=this.options.flushIntervalMs)!=null?i:He);let n=(s=this.options.documentTarget)!=null?s:typeof document!="undefined"?document:void 0;n==null||n.addEventListener("visibilitychange",()=>{n.visibilityState==="hidden"&&this.flush()});let r=(a=this.options.windowTarget)!=null?a:typeof window!="undefined"?window:void 0;r==null||r.addEventListener("pagehide",()=>this.flush()),this.flush()}stop(){if(this.intervalId!==void 0){let e=this.options.timers;e?e.clearInterval(this.intervalId):clearInterval(this.intervalId),this.intervalId=void 0}}envelopeBytes(){let e=this.queue.length>1?this.queue.length-1:0;return A+this.queuedBytes+e}drain(){var e,n,r;for(;this.queue.length>0;){let o=this.queue[0];if(A+o.bytes>this.maxBytes){this.queue.shift(),this.queuedBytes-=o.bytes,(n=(e=this.options).debug)==null||n.call(e,"flush",{reason:"oversize_event",eventId:o.eventId,bytes:o.bytes});continue}let i=[],s=A;for(;this.queue.length>0;){let c=this.queue[0];if(A+c.bytes>this.maxBytes||i.length>=ze)break;let l=s+c.bytes+(i.length>0?1:0);if(l>this.maxBytes)break;i.push(c.json),s=l,this.queue.shift(),this.queuedBytes-=c.bytes}if(i.length===0)continue;let a=((r=this.options.createEnvelopeId)!=null?r:S)();this.options.send(te+a+ne+i.join(",")+re)}}};var $e=new Set(["c15t","onetrust","cookiebot","trustarc","manual"]);function P(t,e){var o;let n=(o=t==null?void 0:t.getAttribute)==null?void 0:o.call(t,e);if(n==null)return;let r=n.trim();return r===""?void 0:r}function oe(t){var r;let e=(r=P(t,"data-aci-consent"))==null?void 0:r.toLowerCase(),n=e!==void 0&&$e.has(e)?e:"manual";return{site:P(t,"data-aci-site"),preset:n,categories:P(t,"data-aci-consent-categories"),debug:P(t,"data-aci-debug")==="1"}}function ie(t,e,n){if(!t)return()=>{};let r=e!=null?e:(i=>console.debug("[aci]",i)),o=n!=null?n:Date.now;return(i,s)=>{try{r({t:o(),kind:i,detail:s})}catch{}}}var R=new TextEncoder,Ke=2048,Ye=32,Je=128,Qe=512,Ze=2147483647,et=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/,tt=/^[\t\n\v\f\r ]+|[\t\n\v\f\r ]+$/g,nt=new Set(["true","all","granted","yes","personalization","personalized"]);function _(t,e=!0){let n=w(t);if(!n)return null;if(e)try{n=decodeURIComponent(n)}catch{}if(n=w(n),!n||R.encode(n).byteLength>Ke)return null;if(nt.has(n.toLowerCase()))return{version:0,purposes:["personalization"],grantedAt:""};try{let r=JSON.parse(n),o=typeof r.t=="string"?r.t:"";return!Number.isInteger(r.v)||r.v<0||r.v>Ze||!Array.isArray(r.p)||r.p.length>Ye||!r.p.every(i=>typeof i=="string")||r.p.some(i=>R.encode(i).byteLength>Je)||r.t!==void 0&&r.t!==null&&(typeof r.t!="string"||r.t===""||!rt(r.t))||r.src!==void 0&&r.src!==null&&typeof r.src!="string"||typeof r.src=="string"&&R.encode(r.src).byteLength>Qe?null:{version:r.v,purposes:r.p,grantedAt:o,source:typeof r.src=="string"?r.src:void 0}}catch{return null}}function B(t){return(t==null?void 0:t.purposes.some(e=>w(e).toLowerCase()==="personalization"))||!1}function w(t){return t.replace(tt,"")}function rt(t){let e=et.exec(t);if(!e||Number.isNaN(Date.parse(t)))return!1;let n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),i=Number(e[4]),s=Number(e[5]),a=Number(e[6]);if(r<1||r>12||o<1||o>ot(n,r)||i>23||s>59||a>59)return!1;let c=e[8];return c==="Z"||Number(c.slice(1,3))<=23&&Number(c.slice(4,6))<=59}function ot(t,e){return e===2?t%4===0&&(t%100!==0||t%400===0)?29:28:[4,6,9,11].includes(e)?30:31}var se="personalization",F="aci_consent",V=1,it=365*24*60*60;function st(t,e){var r;let n=`${F}=${t.encoded}; Path=/; Max-Age=${it}; SameSite=Lax`;((r=e.document.location)==null?void 0:r.protocol)==="https:"&&(n+="; Secure"),e.document.cookie=n}function I(t,e,n){var o;let r=at(t,e,n.now);return r===null?!1:(B(r.snapshot)||(o=n.gapBuffer)==null||o.purge(),st(r,n),!0)}function ae(t){for(let e of t.cookie.split(";")){let n=w(e);if(n.startsWith(F+"="))return n.slice(F.length+1)}}function ce(t){return t===void 0||t===""?!1:B(_(t,!0))}function ue(t){var r;if(!Array.isArray(t))return;let e=[];for(let o of t){if(typeof o!="string")return;e.push(w(o))}let n=JSON.stringify({v:V,p:e});return(r=_(n,!1))==null?void 0:r.purposes}function fe(t){var o;if(t!==void 0&&typeof t!="string")return;let e=typeof t=="string"?w(t):"",r=JSON.stringify({v:V,p:[],src:e===""?"manual":e});return(o=_(r,!1))==null?void 0:o.source}function at(t,e,n){try{let r=JSON.stringify({v:V,p:t,t:new Date((n!=null?n:Date.now)()).toISOString(),src:e}),o=_(r,!1);return o===null?null:{encoded:encodeURIComponent(r),snapshot:o}}catch{return null}}var ct="cmp-",ut=/^[a-z0-9._-]+$/,ft={c15t:"measurement,marketing",onetrust:"c0002,c0004",cookiebot:"statistics,marketing",trustarc:"functional,advertising"};function M(t,e){let n=e!=null?e:ft[t];if(n===void 0)return null;let r=n.split(",").map(o=>o.trim().toLowerCase()).filter(o=>o!=="");if(r.length===0)return null;for(let o of r)if(!ut.test(o))return null;return r}function lt(t,e){return e.filter(r=>r in t.categories).some(r=>t.categories[r]===!0)?[se]:[]}function E(t,e,n){var r,o,i,s;try{let a=M(e,n.categories);if(a===null){(r=n.debug)==null||r.call(n,"consent",{reason:"unparseable_mapping",preset:e});return}if(a.filter(d=>d in t.categories).length===0){(o=n.debug)==null||o.call(n,"consent",{reason:"unmappable_cmp_state",preset:e});return}let l=lt(t,a);I(l,ct+e,{document:n.document,gapBuffer:n.gapBuffer,now:n.now}),(i=n.debug)==null||i.call(n,"consent",{reason:"written",preset:e,purposes:l})}catch(a){(s=n.debug)==null||s.call(n,"consent",{reason:"consent_bridge_failed",preset:e,error:String(a)})}}var le=250,dt=1e4;function k(t,e,n){var s;let r=(s=n==null?void 0:n.scheduler)!=null?s:{setTimeout:(a,c)=>setTimeout(a,c),clearTimeout:a=>clearTimeout(a)},o=Math.floor(dt/le),i=()=>{var c,l;let a;try{a=t()}catch(d){(c=n==null?void 0:n.debug)==null||c.call(n,"consent",{reason:"cmp_read_failed",error:String(d)});return}if(a!==void 0){e(a);return}if(o-=1,o<=0){(l=n==null?void 0:n.debug)==null||l.call(n,"consent",{reason:"cmp_not_found"});return}r.setTimeout(i,le)};i()}function b(t,e){try{e()}catch(n){t==null||t("consent",{reason:"adapter_failed",error:String(n)})}}var pt="c15t";function mt(t){if(typeof t!="object"||t===null)return;let e={};for(let[n,r]of Object.entries(t))typeof r=="boolean"&&(e[n.toLowerCase()]=r);return{categories:e}}function gt(t,e){return typeof t=="object"&&t!==null?"consents"in t?t.consents:t:e.consents}function de(t){k(()=>{let e=t.window.c15t;return typeof e=="object"&&e!==null?e:void 0},e=>{b(t.debug,()=>{var r;let n=o=>{let i=mt(o);i&&E(i,pt,t)};n(e.consents),(r=e.onConsentChange)==null||r.call(e,o=>b(t.debug,()=>n(gt(o,e))))})},t)}var vt="cookiebot",ht=["CookiebotOnConsentReady","CookiebotOnAccept","CookiebotOnDecline"];function pe(t){let e=t.Cookiebot;return typeof e=="object"&&e!==null?e:void 0}function bt(t){if(typeof t!="object"||t===null)return;let e={};for(let[n,r]of Object.entries(t))typeof r=="boolean"&&(e[n.toLowerCase()]=r);return{categories:e}}function me(t){let e=()=>{let r=pe(t.window);if(!r||r.hasResponse!==!0)return;let o=bt(r.consent);o&&E(o,vt,t)},n=t.window;if(typeof n.addEventListener=="function")for(let r of ht)n.addEventListener(r,()=>b(t.debug,e));k(()=>pe(t.window),()=>b(t.debug,e),t)}var ge="onetrust",yt=/^c\d{4}$/;function Et(t,e){let n={};for(let r of t.split(",")){let o=r.trim().toLowerCase();o!==""&&(n[o]=!0)}for(let r of e!=null?e:[])!(r in n)&&yt.test(r)&&(n[r]=!1);return{categories:n}}function ve(t){let e=t.window,n=()=>{let o=e.OnetrustActiveGroups;if(typeof o!="string")return;let i=M(ge,t.categories);E(Et(o,i),ge,t)},r=e.OptanonWrapper;e.OptanonWrapper=()=>{if(typeof r=="function")try{r()}catch{}b(t.debug,n)},k(()=>{let o=e.OnetrustActiveGroups;return typeof o=="string"?o:void 0},()=>b(t.debug,n),t)}var kt="trustarc",Ct={required:1,functional:2,advertising:3},he="PrivacyManagerAPI";function be(t){let e=t.truste,n=e==null?void 0:e.cma,r=n==null?void 0:n.callApi;return typeof r=="function"?r.bind(n):void 0}function wt(t){if(typeof t!="object"||t===null)return;let e=t.consentDecision;if(typeof e!="number"||!Number.isFinite(e)||e<1)return;let n={};for(let[r,o]of Object.entries(Ct))n[r]=e>=o;return{categories:n}}function St(t){return typeof t=="string"?t.includes(he):typeof t=="object"&&t!==null&&he in t}function _t(t){let e=t.location;return typeof(e==null?void 0:e.hostname)=="string"?e.hostname:void 0}function ye(t){let e=()=>{let r=be(t.window);if(!r)return;let o=wt(r("getConsentDecision",_t(t.window)));o&&E(o,kt,t)},n=t.window;typeof n.addEventListener=="function"&&n.addEventListener("message",r=>b(t.debug,()=>{St(r==null?void 0:r.data)&&e()})),k(()=>be(t.window),()=>b(t.debug,e),t)}var N="aci:buf";var Ee="aci_m",L=class{constructor(e){y(this,"events");y(this,"storage");y(this,"debug");this.debug=e==null?void 0:e.debug,this.storage=e==null?void 0:e.storage,this.events=this.restore()}push(e){var n;this.events.push(e),this.events.length>50&&(this.events.splice(0,this.events.length-50),(n=this.debug)==null||n.call(this,"buffer",{reason:"cap_drop_oldest"})),this.persist()}drain(){let e=this.events;return this.events=[],this.persist(),e}purge(){var e;this.events.length>0&&((e=this.debug)==null||e.call(this,"buffer",{reason:"purged",count:this.events.length})),this.events=[],this.persist()}size(){return this.events.length}restore(){var r;let e=this.storage;if(!e)return[];let n;try{n=e.getItem(N)}catch(o){return this.storage=void 0,(r=this.debug)==null||r.call(this,"buffer",{reason:"storage_unavailable",error:String(o)}),[]}if(n==null)return[];try{let o=JSON.parse(n);if(Array.isArray(o))return o}catch{}try{e.removeItem(N)}catch{this.storage=void 0}return[]}persist(){var n;let e=this.storage;if(e)try{this.events.length===0?e.removeItem(N):e.setItem(N,JSON.stringify(this.events))}catch(r){this.storage=void 0,(n=this.debug)==null||n.call(this,"buffer",{reason:"storage_unavailable",error:String(r)})}}};function ke(t){for(let e of t.cookie.split(";")){let n=e.trim();if(n.startsWith(Ee+"="))return n.slice(Ee.length+1)!==""}return!1}function Ce(t,e){if(e.grants()&&!e.marker()){e.gapBuffer.push(t);return}e.batcher.push(t)}function W(t,e,n,r){if(t.size()===0||!n())return;let o=t.drain();for(let i of o)e.push(i);r==null||r("buffer",{reason:"flushed",count:o.length})}var xt="rum.link_click";function we(t,e){var i;let{document:n,debug:r}=e,o=(i=n.defaultView)==null?void 0:i.location;n.addEventListener("click",s=>{var a,c,l;try{let d=s.target,p=(a=d==null?void 0:d.closest)==null?void 0:a.call(d,"a[href]");if(!p)return;let u=p;t({eventName:xt,url:o==null?void 0:o.href,properties:{linkText:(l=(c=u.textContent)==null?void 0:c.trim())!=null?l:"",linkHref:u.href}})}catch(d){r==null||r("capture",{reason:"link_click_failed",error:String(d)})}},{capture:!0})}var At="rum.page_view";function Se(t){let e=t.indexOf("#");return e===-1?t:t.slice(0,e)}function _e(t,e){let n=Se(t.location.href),r=()=>{let s=Se(t.location.href);if(s!==n){n=s;for(let a of e)a()}},o=t.history,i=s=>{let a=o[s].bind(o);o[s]=(...c)=>{let l=a(...c);return r(),l}};i("pushState"),i("replaceState"),t.addEventListener("popstate",r)}function xe(t,e){let n=()=>t({eventName:At,url:e.location.href,referrer:e.document.referrer});return n(),n}var G="/collect";function Ae(t,e){let n=e==null?void 0:e.debug,r=e!==void 0&&"navigator"in e?e.navigator:globalThis.navigator,o=e!==void 0&&"fetch"in e?e.fetch:globalThis.fetch,i;try{i=new Blob([t],{type:"text/plain"})}catch{n==null||n("flush",{reason:"no_blob"});return}if(r!=null&&r.sendBeacon)try{if(r.sendBeacon(G,i))return}catch{}if(!o){n==null||n("flush",{reason:"no_transport"});return}try{o(G,{method:"POST",body:i,keepalive:!0}).catch(s=>{n==null||n("flush",{reason:"fetch_failed",error:String(s)})})}catch(s){n==null||n("flush",{reason:"fetch_failed",error:String(s)})}}function Te(t){var n,r;let e=t!==void 0&&"fetch"in t?t.fetch:globalThis.fetch;if(!e)return Promise.resolve(!1);try{let o=((n=t==null?void 0:t.createEnvelopeId)!=null?n:S)(),i=new Blob([`{"envelopeId":"${o}","events":[]}`],{type:"text/plain"});return e(G,{method:"POST",body:i,keepalive:!0,credentials:"same-origin"}).then(s=>{var a;return typeof s=="object"&&s!==null&&"ok"in s&&s.ok===!1?((a=t==null?void 0:t.debug)==null||a.call(t,"flush",{reason:"refresh_failed",status:"not_ok"}),!1):!0}).catch(s=>{var a;return(a=t==null?void 0:t.debug)==null||a.call(t,"flush",{reason:"refresh_failed",error:String(s)}),!1})}catch(o){return(r=t==null?void 0:t.debug)==null||r.call(t,"flush",{reason:"refresh_failed",error:String(o)}),Promise.resolve(!1)}}var Tt="rum.variation_view",j="data-aci-variation";function Pe(t,e){var l,d,p;let{document:n,debug:r}=e,o=e.MutationObserver;if(typeof o!="function")return;let i=(l=n.defaultView)==null?void 0:l.location,s=new WeakSet,a=u=>{let h=u.getAttribute(j);h!=null&&(s.has(u)||(s.add(u),t({eventName:Tt,url:i==null?void 0:i.href,properties:{variantKey:h}})))},c=u=>{try{u.hasAttribute(j)&&a(u);for(let h of Array.from(u.querySelectorAll(`[${j}]`)))a(h)}catch(h){r==null||r("capture",{reason:"variation_scan_failed",error:String(h)})}};try{let u=(d=n.body)!=null?d:n.documentElement;u&&c(u)}catch(u){r==null||r("capture",{reason:"variation_initial_scan_failed",error:String(u)})}try{let u=(p=n.body)!=null?p:n.documentElement;if(!u)return;new o(m=>{try{for(let g of m)for(let f=0;f<g.addedNodes.length;f++){let v=g.addedNodes[f];if((v==null?void 0:v.nodeType)!==1)continue;let C=v.element;C&&c(C)}}catch(g){r==null||r("capture",{reason:"variation_observer_failed",error:String(g)})}}).observe(u,{subtree:!0,childList:!0})}catch(u){r==null||r("capture",{reason:"variation_observe_failed",error:String(u)})}}var Pt="rum.web_vital";function Ie(t,e){var h,m,g;let n=e.PerformanceObserver;if(typeof n!="function")return;let{performance:r,debug:o}=e,i=(m=(h=e.window)==null?void 0:h.location)==null?void 0:m.href,s=e.document,a=new Set,c=(f,v)=>{a.has(f)||(a.add(f),t({eventName:Pt,url:i,properties:{vitalName:f,vitalValue:v}}))};try{let f=r==null?void 0:r.getEntriesByType("navigation")[0];f&&typeof f.responseStart=="number"&&typeof f.requestStart=="number"&&c("TTFB",f.responseStart-f.requestStart)}catch(f){o==null||o("capture",{reason:"ttfb_failed",error:String(f)})}let l=0,d=0,p=(f,v,C)=>{try{new n(Ne=>{try{for(let O of Ne.getEntries())v(O)}catch(O){o==null||o("capture",{reason:`${f}_handler_failed`,error:String(O)})}}).observe({type:f,buffered:!0,...C})}catch(H){o==null||o("capture",{reason:`${f}_observe_failed`,error:String(H)})}};p("largest-contentful-paint",f=>{c("LCP",f.startTime)}),p("first-input",f=>{typeof f.processingStart=="number"&&c("FID",f.processingStart-f.startTime)}),p("layout-shift",f=>{var v;f.hadRecentInput||(l+=(v=f.value)!=null?v:0)}),p("event",f=>{var C;if(!f.interactionId)return;let v=(C=f.duration)!=null?C:0;v>d&&(d=v)},{durationThreshold:40}),p("paint",f=>{f.name==="first-contentful-paint"&&c("FCP",f.startTime)});let u=()=>{try{a.has("CLS")||c("CLS",l),a.has("INP")||c("INP",d)}catch(f){o==null||o("capture",{reason:"visibility_handler_failed",error:String(f)})}};s&&s.addEventListener("visibilitychange",()=>{s.visibilityState==="hidden"&&u()}),(g=e.window)==null||g.addEventListener("pagehide",u)}var z={c15t:de,onetrust:ve,cookiebot:me,trustarc:ye};function It(t){var e,n;return typeof((e=t.navigator)==null?void 0:e.sendBeacon)=="function"&&typeof t.IntersectionObserver=="function"&&typeof((n=t.crypto)==null?void 0:n.getRandomValues)=="function"}function Nt(t){try{return t.sessionStorage}catch{return}}function Lt(t){var o;let e=t!=null?t:typeof window!="undefined"?window:void 0;if(!e||e.__aci_loaded||(e.__aci_loaded=!0,!It(e)))return;let n=oe(e.document.currentScript),r=ie(n.debug);try{let i=e.document,s=new L({storage:Nt(e),debug:r}),a=()=>{try{return ce(ae(i))}catch{return!1}},c=()=>{try{return ke(i)}catch{return!1}},l={navigator:e.navigator,fetch:typeof e.fetch=="function"?e.fetch.bind(e):void 0,debug:r},d;d=new T({send:m=>Ae(m,l),debug:r,onTick:()=>W(s,d,c,r),timers:{setInterval:(m,g)=>e.setInterval(m,g),clearInterval:m=>e.clearInterval(m)},documentTarget:i,windowTarget:e});let p=Z({document:i,window:e,debug:r}),u=m=>{Ce({...Q(m,p),eventId:S(void 0,g=>e.crypto.getRandomValues(g))},{grants:a,marker:c,gapBuffer:s,batcher:d})};p.start(u),J(e,n,{track:(m,g)=>u({eventName:m,properties:g}),consent:({p:m,src:g})=>{let f=ue(m);if(f===void 0){r("consent",{reason:"malformed_purposes"});return}let v=fe(g);if(v===void 0){r("consent",{reason:"malformed_source"});return}I(f,v,{document:i,gapBuffer:s})||r("consent",{reason:"oversized_envelope"})}},r);let h=xe(u,e);_e(e,[()=>p.rearm(),h]),K(u,{document:i,intersectionObserver:e.IntersectionObserver,debug:r},()=>{Te(l).then(m=>{m&&e.location.reload()})}),we(u,{document:i,debug:r}),Ie(u,{performance:e.performance,PerformanceObserver:e.PerformanceObserver,window:e,document:i,debug:r}),Pe(u,{document:i,MutationObserver:e.MutationObserver,debug:r}),n.preset!=="manual"&&((o=z[n.preset])==null||o.call(z,{window:e,document:i,categories:n.categories,gapBuffer:s,debug:r,scheduler:{setTimeout:(m,g)=>e.setTimeout(m,g),clearTimeout:m=>e.clearTimeout(m)}})),d.start(),W(s,d,c,r),r("init",{config:n})}catch(i){r("init",{error:String(i)})}}Lt();})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
994ba27b5d9f4f39ec7c2b4fa6465cd458a0e435a594f275c133479e977eadcd
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
// vitalValue }. Captures LCP, FID, CLS, INP, TTFB and FCP via
|
|
3
3
|
// PerformanceObserver. LCP/FID/FCP fire as their entries arrive; TTFB is read
|
|
4
4
|
// once from the navigation entry on init; CLS and INP accumulate and are
|
|
5
|
-
// reported on visibilitychange to hidden (session-window semantics).
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
5
|
+
// reported on visibilitychange to hidden (session-window semantics). FID is
|
|
6
|
+
// the input delay (processingStart - startTime); INP is the worst interaction
|
|
7
|
+
// duration (entries with a nonzero interactionId), a max approximation of the
|
|
8
|
+
// spec's high-percentile definition. Each vital is emitted at most once per
|
|
9
|
+
// page load — there is no SPA reset in this first version. If
|
|
10
|
+
// PerformanceObserver is missing the collector is a no-op. Errors are
|
|
11
|
+
// swallowed silently.
|
|
9
12
|
export const WEB_VITAL_EVENT = "rum.web_vital";
|
|
10
13
|
/**
|
|
11
14
|
* startWebVitals observes Core Web Vitals and emits one rum.web_vital per
|
|
@@ -40,7 +43,7 @@ export function startWebVitals(emit, env) {
|
|
|
40
43
|
}
|
|
41
44
|
let clsValue = 0;
|
|
42
45
|
let inpWorst = 0;
|
|
43
|
-
const observe = (type, handler) => {
|
|
46
|
+
const observe = (type, handler, extraOptions) => {
|
|
44
47
|
try {
|
|
45
48
|
const obs = new Observer((list) => {
|
|
46
49
|
try {
|
|
@@ -51,7 +54,7 @@ export function startWebVitals(emit, env) {
|
|
|
51
54
|
debug?.("capture", { reason: `${type}_handler_failed`, error: String(err) });
|
|
52
55
|
}
|
|
53
56
|
});
|
|
54
|
-
obs.observe({ type, buffered: true });
|
|
57
|
+
obs.observe({ type, buffered: true, ...extraOptions });
|
|
55
58
|
}
|
|
56
59
|
catch (err) {
|
|
57
60
|
debug?.("capture", { reason: `${type}_observe_failed`, error: String(err) });
|
|
@@ -61,7 +64,9 @@ export function startWebVitals(emit, env) {
|
|
|
61
64
|
emitVital("LCP", entry.startTime);
|
|
62
65
|
});
|
|
63
66
|
observe("first-input", (entry) => {
|
|
64
|
-
|
|
67
|
+
if (typeof entry.processingStart !== "number")
|
|
68
|
+
return;
|
|
69
|
+
emitVital("FID", entry.processingStart - entry.startTime);
|
|
65
70
|
});
|
|
66
71
|
observe("layout-shift", (entry) => {
|
|
67
72
|
if (entry.hadRecentInput)
|
|
@@ -69,10 +74,15 @@ export function startWebVitals(emit, env) {
|
|
|
69
74
|
clsValue += entry.value ?? 0;
|
|
70
75
|
});
|
|
71
76
|
observe("event", (entry) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
if (!entry.interactionId)
|
|
78
|
+
return;
|
|
79
|
+
const duration = entry.duration ?? 0;
|
|
80
|
+
if (duration > inpWorst)
|
|
81
|
+
inpWorst = duration;
|
|
82
|
+
},
|
|
83
|
+
// The event-timing default durationThreshold is 104ms; lower it so
|
|
84
|
+
// ordinary sub-100ms interactions are represented in INP.
|
|
85
|
+
{ durationThreshold: 40 });
|
|
76
86
|
observe("paint", (entry) => {
|
|
77
87
|
if (entry.name === "first-contentful-paint") {
|
|
78
88
|
emitVital("FCP", entry.startTime);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Shipped branded-neutral default error page, embedded at build time. */
|
|
2
|
+
export declare const DEFAULT_ERROR_PAGE_HTML = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"robots\" content=\"noindex\">\n<title>Page unavailable</title>\n</head>\n<body style=\"margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#fafafa;color:#1a1a1a;font-family:system-ui,-apple-system,'Segoe UI',sans-serif;text-align:center\">\n<main style=\"max-width:26rem;padding:2rem\">\n<p style=\"margin:0 0 0.75rem;font-size:0.8rem;letter-spacing:0.12em;text-transform:uppercase;color:#6b6b6b\">Page unavailable</p>\n<h1 style=\"margin:0 0 1rem;font-size:1.5rem;font-weight:600;line-height:1.3\">This page can’t be shown right now.</h1>\n<p style=\"margin:0 0 1.5rem;font-size:1rem;line-height:1.6;color:#4a4a4a\">The page you requested doesn’t exist or couldn’t be served. Check the address, try again in a moment, or return to the homepage.</p>\n<a href=\"/\" style=\"display:inline-block;padding:0.6rem 1.4rem;border:1px solid #1a1a1a;border-radius:999px;color:#1a1a1a;text-decoration:none;font-size:0.9rem\">Back to homepage</a>\n</main>\n</body>\n</html>\n";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// GENERATED FILE — DO NOT EDIT.
|
|
2
|
+
// Source of truth: assets/error-pages/default.html
|
|
3
|
+
// Regenerate with: node scripts/generate-default-error-page.mjs
|
|
4
|
+
// (default-error-page.test.ts fails if this file drifts from the asset.)
|
|
5
|
+
/** Shipped branded-neutral default error page, embedded at build time. */
|
|
6
|
+
export const DEFAULT_ERROR_PAGE_HTML = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"robots\" content=\"noindex\">\n<title>Page unavailable</title>\n</head>\n<body style=\"margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#fafafa;color:#1a1a1a;font-family:system-ui,-apple-system,'Segoe UI',sans-serif;text-align:center\">\n<main style=\"max-width:26rem;padding:2rem\">\n<p style=\"margin:0 0 0.75rem;font-size:0.8rem;letter-spacing:0.12em;text-transform:uppercase;color:#6b6b6b\">Page unavailable</p>\n<h1 style=\"margin:0 0 1rem;font-size:1.5rem;font-weight:600;line-height:1.3\">This page can’t be shown right now.</h1>\n<p style=\"margin:0 0 1.5rem;font-size:1rem;line-height:1.6;color:#4a4a4a\">The page you requested doesn’t exist or couldn’t be served. Check the address, try again in a moment, or return to the homepage.</p>\n<a href=\"/\" style=\"display:inline-block;padding:0.6rem 1.4rem;border:1px solid #1a1a1a;border-radius:999px;color:#1a1a1a;text-decoration:none;font-size:0.9rem\">Back to homepage</a>\n</main>\n</body>\n</html>\n";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shipped branded-neutral default error page (authorable-error-pages
|
|
3
|
+
* REQ-4/D-5). Materialized with a loud warning when a site has no
|
|
4
|
+
* `errorPages` binding under the warn-then-enforce posture. Self-contained
|
|
5
|
+
* by construction: inline styles only, no external references (REQ-14).
|
|
6
|
+
*
|
|
7
|
+
* The human-editable source of truth is `assets/error-pages/default.html`;
|
|
8
|
+
* it is embedded here as a generated constant (default-error-page-html.ts)
|
|
9
|
+
* because bundled serverless functions cannot read package assets at
|
|
10
|
+
* runtime — webpack rewrites module-URL resolution and output file tracing
|
|
11
|
+
* does not carry the .html into the function bundle, so a runtime file read
|
|
12
|
+
* crashes the very error surface this page exists to protect.
|
|
13
|
+
*/
|
|
14
|
+
/** Returns the shipped branded-neutral default error page HTML. */
|
|
15
|
+
export declare function defaultErrorPageHtml(): string;
|
|
16
|
+
/**
|
|
17
|
+
* The shipped default page's `<body>` content as an embeddable fragment: the
|
|
18
|
+
* body element renamed to a `<div>` (its inline styles preserved) so
|
|
19
|
+
* framework error seats can inline the default INSIDE an existing document —
|
|
20
|
+
* the not-found seat and the client error seat render within the app's root
|
|
21
|
+
* layout, where a nested `<body>`/`<html>` would be invalid.
|
|
22
|
+
*/
|
|
23
|
+
export declare function defaultErrorPageFragmentHtml(): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DEFAULT_ERROR_PAGE_HTML } from './default-error-page-html.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shipped branded-neutral default error page (authorable-error-pages
|
|
4
|
+
* REQ-4/D-5). Materialized with a loud warning when a site has no
|
|
5
|
+
* `errorPages` binding under the warn-then-enforce posture. Self-contained
|
|
6
|
+
* by construction: inline styles only, no external references (REQ-14).
|
|
7
|
+
*
|
|
8
|
+
* The human-editable source of truth is `assets/error-pages/default.html`;
|
|
9
|
+
* it is embedded here as a generated constant (default-error-page-html.ts)
|
|
10
|
+
* because bundled serverless functions cannot read package assets at
|
|
11
|
+
* runtime — webpack rewrites module-URL resolution and output file tracing
|
|
12
|
+
* does not carry the .html into the function bundle, so a runtime file read
|
|
13
|
+
* crashes the very error surface this page exists to protect.
|
|
14
|
+
*/
|
|
15
|
+
/** Returns the shipped branded-neutral default error page HTML. */
|
|
16
|
+
export function defaultErrorPageHtml() {
|
|
17
|
+
return DEFAULT_ERROR_PAGE_HTML;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The shipped default page's `<body>` content as an embeddable fragment: the
|
|
21
|
+
* body element renamed to a `<div>` (its inline styles preserved) so
|
|
22
|
+
* framework error seats can inline the default INSIDE an existing document —
|
|
23
|
+
* the not-found seat and the client error seat render within the app's root
|
|
24
|
+
* layout, where a nested `<body>`/`<html>` would be invalid.
|
|
25
|
+
*/
|
|
26
|
+
export function defaultErrorPageFragmentHtml() {
|
|
27
|
+
const match = defaultErrorPageHtml().match(/<body([^>]*)>([\s\S]*?)<\/body>/i);
|
|
28
|
+
if (!match) {
|
|
29
|
+
// The shipped asset is package-controlled; this is a packaging bug, but
|
|
30
|
+
// error surfaces must never crash — fall back to the raw document body.
|
|
31
|
+
return defaultErrorPageHtml();
|
|
32
|
+
}
|
|
33
|
+
return `<div${match[1]}>${match[2]}</div>`;
|
|
34
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type ErrorPageKind = 'notFound' | 'catchAll';
|
|
2
|
+
/** D-14 page_type values for the error-surface `page_view` event. */
|
|
3
|
+
export type ErrorPageType = 'not_found' | 'error';
|
|
4
|
+
/** Maps a binding kind to its D-14 page_type. */
|
|
5
|
+
export declare function errorPageType(kind: ErrorPageKind): ErrorPageType;
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
dataLayer?: Array<Record<string, unknown>>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The D-15 policy shape: the dataLayer push for one error-surface view.
|
|
13
|
+
* Site policy lives in the tenant-owned scaffolded module
|
|
14
|
+
* `src/aci/error-page-instrumentation.mjs` (`pushErrorPageView`); the SDK
|
|
15
|
+
* ships `defaultPushErrorPageView` as the scaffolded default's twin. A push
|
|
16
|
+
* MUST be self-contained (browser globals only — no imports, no closed-over
|
|
17
|
+
* identifiers): the Astro seats and the 500.html emitter execute it
|
|
18
|
+
* STRINGIFIED via `serializeErrorPageInstrumentation`.
|
|
19
|
+
*/
|
|
20
|
+
export type ErrorPagePush = (pageType: ErrorPageType) => void;
|
|
21
|
+
/**
|
|
22
|
+
* The SDK's copy of the D-14 default payload push — the same body the
|
|
23
|
+
* scaffolded policy module ships with. Used when no tenant module is in
|
|
24
|
+
* play: the Next `ErrorPageInstrumentation` component's default, the Astro
|
|
25
|
+
* seats' fallback, and the emitter's fallback tag. Self-contained by the
|
|
26
|
+
* ErrorPagePush contract (it serializes via toString()).
|
|
27
|
+
*/
|
|
28
|
+
export declare function defaultPushErrorPageView(pageType: ErrorPageType): void;
|
|
29
|
+
/**
|
|
30
|
+
* SDK MECHANISM (D-15, code-organization R-14): serializes a self-contained
|
|
31
|
+
* push function into the inline analytics `<script>` tag the Astro seats
|
|
32
|
+
* inject via `<Fragment set:html>` and the Next emit-error-pages CLI stamps
|
|
33
|
+
* into `public/500.html`. The marker attribute and IIFE wrapper are
|
|
34
|
+
* SDK-owned platform contract (D-14: `data-aci-error-page` is the STABLE
|
|
35
|
+
* GTM suppression signal); the function body is site policy. `</script`,
|
|
36
|
+
* `<script` and `<!--` occurrences in the body are escaped (the script-data
|
|
37
|
+
* escaping table) so a push can neither break out of the tag nor walk the
|
|
38
|
+
* HTML parser into the escaped-script-data states (FIND-007).
|
|
39
|
+
*
|
|
40
|
+
* A non-function push degrades to the default tag with a warning
|
|
41
|
+
* (FIND-002): this is the runtime mechanism boundary and error surfaces
|
|
42
|
+
* must not crash over a broken policy value — the emitter keeps its own
|
|
43
|
+
* fail-loud stance at build time.
|
|
44
|
+
*/
|
|
45
|
+
export declare function serializeErrorPageInstrumentation(push: ErrorPagePush, kind: ErrorPageKind): string;
|
|
46
|
+
/**
|
|
47
|
+
* The SDK DEFAULT analytics tag (D-15 amended D-14): the serialized
|
|
48
|
+
* `defaultPushErrorPageView`. Consumers fall back to it when no tenant
|
|
49
|
+
* policy module is provided — the Astro seats without
|
|
50
|
+
* `options.pushErrorPageView` and the emitter when
|
|
51
|
+
* `src/aci/error-page-instrumentation.mjs` is absent. The Next 'use client'
|
|
52
|
+
* component (`next/error-page-instrumentation.tsx`) cannot consume a script
|
|
53
|
+
* tag (RSC skips inline scripts); it calls the same default function
|
|
54
|
+
* directly, and the parity test beside it holds both deliveries in
|
|
55
|
+
* lockstep.
|
|
56
|
+
*/
|
|
57
|
+
export declare function errorPageInstrumentationTag(kind: ErrorPageKind): string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Authorable error pages: the kind/page_type vocabulary (REQ-12 / D-14).
|
|
2
|
+
//
|
|
3
|
+
// This is a deliberately dependency-free CLIENT-SAFE leaf module: the Next
|
|
4
|
+
// error-surface components ('use client' — error-page-marker,
|
|
5
|
+
// error-page-instrumentation, error-seat) bundle it into the browser, so it
|
|
6
|
+
// must not import anything that reaches node builtins (content/error-pages.ts
|
|
7
|
+
// pulls content/routes.ts → node:path, which webpack rejects in client
|
|
8
|
+
// bundles). It is the SINGLE definition (quorum SIMPLE-005) — content/
|
|
9
|
+
// error-pages.ts re-exports it for server-side callers, and the next/astro
|
|
10
|
+
// barrels re-export from there.
|
|
11
|
+
/** Maps a binding kind to its D-14 page_type. */
|
|
12
|
+
export function errorPageType(kind) {
|
|
13
|
+
return kind === 'notFound' ? 'not_found' : 'error';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The SDK's copy of the D-14 default payload push — the same body the
|
|
17
|
+
* scaffolded policy module ships with. Used when no tenant module is in
|
|
18
|
+
* play: the Next `ErrorPageInstrumentation` component's default, the Astro
|
|
19
|
+
* seats' fallback, and the emitter's fallback tag. Self-contained by the
|
|
20
|
+
* ErrorPagePush contract (it serializes via toString()).
|
|
21
|
+
*/
|
|
22
|
+
export function defaultPushErrorPageView(pageType) {
|
|
23
|
+
window.dataLayer = window.dataLayer || [];
|
|
24
|
+
window.dataLayer.push({
|
|
25
|
+
event: 'page_view',
|
|
26
|
+
page_type: pageType,
|
|
27
|
+
page_path: window.location.pathname,
|
|
28
|
+
page_location: window.location.href,
|
|
29
|
+
page_referrer: document.referrer || '(direct)',
|
|
30
|
+
page_title: document.title,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SDK MECHANISM (D-15, code-organization R-14): serializes a self-contained
|
|
35
|
+
* push function into the inline analytics `<script>` tag the Astro seats
|
|
36
|
+
* inject via `<Fragment set:html>` and the Next emit-error-pages CLI stamps
|
|
37
|
+
* into `public/500.html`. The marker attribute and IIFE wrapper are
|
|
38
|
+
* SDK-owned platform contract (D-14: `data-aci-error-page` is the STABLE
|
|
39
|
+
* GTM suppression signal); the function body is site policy. `</script`,
|
|
40
|
+
* `<script` and `<!--` occurrences in the body are escaped (the script-data
|
|
41
|
+
* escaping table) so a push can neither break out of the tag nor walk the
|
|
42
|
+
* HTML parser into the escaped-script-data states (FIND-007).
|
|
43
|
+
*
|
|
44
|
+
* A non-function push degrades to the default tag with a warning
|
|
45
|
+
* (FIND-002): this is the runtime mechanism boundary and error surfaces
|
|
46
|
+
* must not crash over a broken policy value — the emitter keeps its own
|
|
47
|
+
* fail-loud stance at build time.
|
|
48
|
+
*/
|
|
49
|
+
export function serializeErrorPageInstrumentation(push, kind) {
|
|
50
|
+
const pageType = errorPageType(kind);
|
|
51
|
+
let effectivePush = push;
|
|
52
|
+
if (typeof effectivePush !== 'function') {
|
|
53
|
+
console.warn('[aci error-pages] pushErrorPageView is not a function; serializing the SDK default push instead (D-15)');
|
|
54
|
+
effectivePush = defaultPushErrorPageView;
|
|
55
|
+
}
|
|
56
|
+
const source = escapeInlineScriptSource(effectivePush.toString());
|
|
57
|
+
assertSerializablePushSource(source);
|
|
58
|
+
return `<script data-aci-error-page="${pageType}">(${source})(${JSON.stringify(pageType)});</script>`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Script-data escaping (FIND-007): `</script` would close the inline tag,
|
|
62
|
+
* and `<!--`/`<script` open the escaped-script-data parser states where the
|
|
63
|
+
* real closing tag is consumed as text. All three are defused with a
|
|
64
|
+
* case-PRESERVING backslash after `<` — inside JS string literals `\/`,
|
|
65
|
+
* `\s` and `\!` decode to the original characters, so payload values
|
|
66
|
+
* survive byte-for-byte on every surface.
|
|
67
|
+
*/
|
|
68
|
+
function escapeInlineScriptSource(source) {
|
|
69
|
+
return source.replace(/<(\/script|script|!--)/gi, (match) => `<\\${match.slice(1)}`);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Serialization smoke-eval (D-16, delta FIND-006): the tag ships the push
|
|
73
|
+
* STRINGIFIED, so its toString() must parse as a standalone function
|
|
74
|
+
* expression. Bound functions (`fn.bind(...)` stringifies to
|
|
75
|
+
* `function () { [native code] }`) and method-shorthand definitions
|
|
76
|
+
* (`{ pushErrorPageView(t) {…} }` stringifies without the `function`
|
|
77
|
+
* keyword) both produce source that is not an expression — the build must
|
|
78
|
+
* fail loudly here instead of shipping a tag that throws in every visitor's
|
|
79
|
+
* browser.
|
|
80
|
+
*/
|
|
81
|
+
function assertSerializablePushSource(source) {
|
|
82
|
+
try {
|
|
83
|
+
// Parse-only: the function body never executes.
|
|
84
|
+
new Function(`return (${source});`);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new Error('pushErrorPageView cannot be serialized: its toString() output does not parse as a '
|
|
88
|
+
+ `function expression (${String(error)}). Likely causes: exporting a bound function `
|
|
89
|
+
+ '(.bind() loses the source) or a method-shorthand definition. Export a plain '
|
|
90
|
+
+ 'self-contained `function pushErrorPageView(pageType) {…}` instead (D-15 contract).');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The SDK DEFAULT analytics tag (D-15 amended D-14): the serialized
|
|
95
|
+
* `defaultPushErrorPageView`. Consumers fall back to it when no tenant
|
|
96
|
+
* policy module is provided — the Astro seats without
|
|
97
|
+
* `options.pushErrorPageView` and the emitter when
|
|
98
|
+
* `src/aci/error-page-instrumentation.mjs` is absent. The Next 'use client'
|
|
99
|
+
* component (`next/error-page-instrumentation.tsx`) cannot consume a script
|
|
100
|
+
* tag (RSC skips inline scripts); it calls the same default function
|
|
101
|
+
* directly, and the parity test beside it holds both deliveries in
|
|
102
|
+
* lockstep.
|
|
103
|
+
*/
|
|
104
|
+
export function errorPageInstrumentationTag(kind) {
|
|
105
|
+
return serializeErrorPageInstrumentation(defaultPushErrorPageView, kind);
|
|
106
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { RouteEntry } from './provider.js';
|
|
2
|
+
import type { KernelSiteConfig, SiteErrorPages } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Error-page binding validation (authorable-error-pages REQ-4/REQ-5/D-5),
|
|
5
|
+
* semantically paired with the Go compiler's
|
|
6
|
+
* `internal/domain/contentbuild/error_pages.go`. Under the warn-then-enforce
|
|
7
|
+
* migration posture, absent bindings are legal: they produce a loud warning
|
|
8
|
+
* and a `defaulted: true` result so callers fall back to the shipped
|
|
9
|
+
* branded-neutral default page (`defaultErrorPageHtml()`). Present bindings
|
|
10
|
+
* are strict in every posture: malformed routes, bindings resolving to no
|
|
11
|
+
* page, unpublished bound pages, and audience/experiment overlays on bound
|
|
12
|
+
* pages all fail closed.
|
|
13
|
+
*
|
|
14
|
+
* NOTE: `src/next/error-seat-payload.ts` carries a SYNCHRONOUS twin of the
|
|
15
|
+
* binding validation below (it runs inside next.config evaluation where these
|
|
16
|
+
* async providers cannot be awaited). Keep the REQ-5 semantics of the two in
|
|
17
|
+
* lockstep when editing either; extraction into one shared core is deferred.
|
|
18
|
+
*/
|
|
19
|
+
/** D-5 migration posture for absent bindings; default is 'warn' today. */
|
|
20
|
+
export type ErrorPagePosture = 'warn' | 'enforce';
|
|
21
|
+
export { errorPageType, errorPageInstrumentationTag, defaultPushErrorPageView, serializeErrorPageInstrumentation, } from './error-page-kind.js';
|
|
22
|
+
export type { ErrorPageKind, ErrorPageType, ErrorPagePush } from './error-page-kind.js';
|
|
23
|
+
import type { ErrorPageKind } from './error-page-kind.js';
|
|
24
|
+
/**
|
|
25
|
+
* The one D-5 posture config surface, shared by every stack: the same
|
|
26
|
+
* variable the Go content build and publish materializer read.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ERROR_PAGES_POSTURE_ENV = "ACI_ERROR_PAGES_POSTURE";
|
|
29
|
+
/** Reads the D-5 posture from ACI_ERROR_PAGES_POSTURE; throws on unknown values (fail closed). */
|
|
30
|
+
export declare function errorPagePostureFromEnv(env?: Record<string, string | undefined>): ErrorPagePosture;
|
|
31
|
+
/** Mirrors the site.schema.json binding pattern: "/<segment>/". */
|
|
32
|
+
export declare const ERROR_PAGE_ROUTE_PATTERN: RegExp;
|
|
33
|
+
/**
|
|
34
|
+
* The slice of a content provider binding resolution needs. Both
|
|
35
|
+
* FileContentProvider and S3ContentProvider satisfy it.
|
|
36
|
+
*/
|
|
37
|
+
export interface ErrorPageContentSource {
|
|
38
|
+
listRoutes(): Promise<RouteEntry[]>;
|
|
39
|
+
getPage<T = unknown>(route: string): Promise<T>;
|
|
40
|
+
}
|
|
41
|
+
export interface ResolveErrorPageBindingsOptions {
|
|
42
|
+
/** Absent-binding posture; defaults to 'warn' (D-5). */
|
|
43
|
+
posture?: ErrorPagePosture;
|
|
44
|
+
/**
|
|
45
|
+
* Compiled content to resolve bindings against. When omitted, only shape
|
|
46
|
+
* validation runs (the serve-time seam: publish status was already
|
|
47
|
+
* enforced at build time).
|
|
48
|
+
*/
|
|
49
|
+
source?: ErrorPageContentSource;
|
|
50
|
+
}
|
|
51
|
+
export interface ErrorPageBindingsResolution {
|
|
52
|
+
/** Validated bindings; null when defaulted or invalid. */
|
|
53
|
+
bindings: SiteErrorPages | null;
|
|
54
|
+
/**
|
|
55
|
+
* True when no bindings are authored under the warn posture: callers must
|
|
56
|
+
* serve the shipped default page and surface `warnings` loudly.
|
|
57
|
+
*/
|
|
58
|
+
defaulted: boolean;
|
|
59
|
+
warnings: string[];
|
|
60
|
+
errors: string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Validates the site's error-page bindings under the given posture.
|
|
64
|
+
* Never throws for validation outcomes: callers fail their build closed on a
|
|
65
|
+
* non-empty `errors` array.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveErrorPageBindings(siteConfig: Pick<KernelSiteConfig, 'errorPages'> | null | undefined, options?: ResolveErrorPageBindingsOptions): Promise<ErrorPageBindingsResolution>;
|
|
68
|
+
/**
|
|
69
|
+
* One kind's resolution for the serve-time seams (02-design "SDK core"):
|
|
70
|
+
* `route: null` + `defaulted: true` means "serve the shipped branded-neutral
|
|
71
|
+
* default page" (`defaultErrorPageHtml()` / `defaultErrorPageFragmentHtml()`).
|
|
72
|
+
*/
|
|
73
|
+
export interface ResolvedErrorPage {
|
|
74
|
+
kind: ErrorPageKind;
|
|
75
|
+
/** Bound public route path, or null when the shipped default applies. */
|
|
76
|
+
route: string | null;
|
|
77
|
+
defaulted: boolean;
|
|
78
|
+
/** Loud-warning material (REQ-4) — callers surface these, e.g. console.warn. */
|
|
79
|
+
warnings: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolves one error-page kind under the warn posture (default). Unlike the
|
|
83
|
+
* build-time `resolveErrorPageBindings`, this NEVER fails: error surfaces
|
|
84
|
+
* must not crash and must not re-enter the failing system (ANTI-2), so a
|
|
85
|
+
* broken binding — which the build already failed closed on (REQ-5) —
|
|
86
|
+
* degrades to the shipped default with the problem surfaced in `warnings`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveErrorPage(kind: ErrorPageKind, siteConfig: Pick<KernelSiteConfig, 'errorPages'> | null | undefined, options?: ResolveErrorPageBindingsOptions): Promise<ResolvedErrorPage>;
|