(()=>{"use strict";var e={106780:(e,t,r)=>{r.d(t,{B:()=>n.B});var n=r(887271)},111903:(e,t,r)=>{r.d(t,{e:()=>s});var n=r(718214);function s(e,t,r,s,o){return e.handle(t,(async e=>{const i=function(e,t,r){if(void 0===r)throw new n.cC({code:"internal_error",message:`${e}: request cannot be undefined.`});return t.deserialize(r)}(t,r,e),a=await s(i);if(o)return o.serialize(a)}))}},133599:(e,t,r)=>{r.d(t,{X:()=>f,y:()=>O});var n=r(106780),s=r(376231),o=r(758754);const i={STRING:{typeOfValue:"string"},BOOLEAN:{typeOfValue:"boolean",defaultValue:!1,fixedSize:1},DOUBLE:{typeOfValue:"number",defaultValue:0,fixedSize:8},INT32:{typeOfValue:"number",defaultValue:0},INT64:{typeOfValue:"number",defaultValue:0},BYTES:{typeOfValue:"Uint8Array"}};function a(e,t,r,n,s,o,i,a,l,c,u){return{tag:e,fieldLabel:t,typeOfValue:r,jsonFullKey:n,jsonFullValue:s,value:o,defaults:i,default:a,defaultValue:l,obj:c,typeOfKey:u}}function l(e){const{tag:t,jsonFullKeyOrJsonMiniKey:r,jsonFullValue:n,value:s,defaults:i}=e,l=r===S?void 0:r;return a(t,o.d.CONSTANT,"string",l,n,s,i,void 0,void 0,void 0,void 0)}function c(e,t,r,n){return a(r,o.d.REQUIRED,e.typeOfValue,t,void 0,void 0,void 0,null!=n?n:e.defaultValue,e.defaultValue,void 0,void 0)}function u(e,t,r){return a(r,o.d.OPTIONAL,e.typeOfValue,t,void 0,void 0,void 0,void 0,e.defaultValue,void 0,void 0)}function d(e,t,r){return a(r,o.d.REPEATED,e.typeOfValue,t,void 0,void 0,void 0,void 0,void 0,void 0,void 0)}function h(e,t){return(r,n,s)=>{const{tag:i,jsonFullKey:l,other1:c}=R(r,n,s);let u;return u="object"===t?"object":"enum"===t?"string":t.typeOfValue,a(i,o.d.MAP,u,l,void 0,void 0,void 0,void 0,void 0,c,e.typeOfValue)}}class f{static constantString(e,t,r,n){const{tag:s,jsonFullKey:o,other1:i}=R(t,r,n);return l({tag:s,jsonFullKeyOrJsonMiniKey:e,jsonFullValue:o,value:i,defaults:!1})}static constantStringWithDefault(e,t,r,n){const{tag:s,jsonFullKey:o,other1:i}=R(t,r,n);return l({tag:s,jsonFullKeyOrJsonMiniKey:e,jsonFullValue:o,value:i,defaults:!0})}static requiredObject(e,t,r){const{tag:n,jsonFullKey:s,other1:i}=R(e,t,r);return a(n,o.d.REQUIRED,"object",s,void 0,void 0,void 0,void 0,void 0,i,void 0)}static optionalObject(e,t,r){const{tag:n,jsonFullKey:s,other1:i}=R(e,t,r);return a(n,o.d.OPTIONAL,"object",s,void 0,void 0,void 0,void 0,void 0,i,void 0)}static repeatedObject(e,t,r){const{tag:n,jsonFullKey:s,other1:i}=R(e,t,r);return a(n,o.d.REPEATED,"object",s,void 0,void 0,void 0,void 0,void 0,i,void 0)}static requiredStringEnum(e,t,r,n){const{tag:s,jsonFullKey:i,other1:l,other2:c}=R(e,t,r,n);return a(s,o.d.REQUIRED,"string",i,void 0,void 0,void 0,c,void 0,l,void 0)}static optionalStringEnum(e,t,r){const{tag:n,jsonFullKey:s,other1:i}=R(e,t,r);return a(n,o.d.OPTIONAL,"string",s,void 0,void 0,void 0,void 0,void 0,i,void 0)}static repeatedStringEnum(e,t,r){const{tag:n,jsonFullKey:s,other1:i}=R(e,t,r);return a(n,o.d.REPEATED,"string",s,void 0,void 0,void 0,void 0,void 0,i,void 0)}static createMessage(e,t={}){const r=(0,n.B)((()=>{const r=e(),n=Object.keys(r),i={},a={};for(let e=0;eString.fromCodePoint(e))).join("");return btoa(t)}(e):n.obj?n.obj.serializeWithPath(e,r):e}static deserialize(e){return i.deserializeWithPath(e,[])}static deserializeValue(e,t,r){const{config:n}=t;return"Uint8Array"===n.typeOfValue?(s=e,Uint8Array.from(atob(s),(e=>e.codePointAt(0)))):n.obj?n.obj.deserializeWithPath(e,r):e;var s}static deserializeWithPath(e,t){const{fieldMetadata:n}=r(),a=Object.create(i.prototype);for(let r=0;r{throw new TypeError(`Unproducible oneof case ${I(t)}`)}:(e,t)=>{if(null==e||"object"!=typeof e)throw new TypeError(`Expected type object, found: ${b(e)} ${I(t)}`);const{fieldMetadata:n}=r(),a={};for(let r=0;r{const n=e(),s=Object.keys(n)[0];let i,a;const l=new Map,c=new Map,u=new Map;for(let e=0;e{const{discriminatorKey:r,nameToObject:n}=s(),o=e[r],i=n.get(o);if(!i)throw new TypeError(`Unknown oneof deserialized case: ${JSON.stringify(o)} ${I(t)}`);return i.serializeWithPath(e,t)},a=(e,t)=>{const{serializedToObject:r,discriminatorJsonKeyEncodings:n,defaultObject:o}=s(),{primaryJsonKey:i,secondaryJsonKey:a}=n;let l=e[i];if(null==l&&a&&(l=e[a]),null==l&&o)return o.deserializeWithPath(e,t);const c=r.get(l);if(!c)throw new TypeError(`Unknown oneof serialized case: ${JSON.stringify(l)} ${I(t)}`);return c.deserializeWithPath(e,t)};return{init:s,serialize:e=>i(e,[]),serializeWithPath:i,deserialize:e=>a(e,[]),deserializeWithPath:a}}static createEnumUtil(e,t=0,r={}){const s=(0,n.B)((()=>{const n=e(),s=[],o=new Map,i=new Map,a=new Map,l=new Map,c=new Set;let u=0,d=1;for(;u{const{unproducible:n}=s();if(n&&n.has(e))throw new TypeError(`Unproducible enum value: ${JSON.stringify(e)} ${r?I(r):""}`);const o=t.get(e);if(null==o)throw new TypeError(`The proto enum serializer failed to serialize value ${JSON.stringify(e)} into JSON.\nIt does not recognize value ${JSON.stringify(e)} as a valid member of the TypeScript enum.\n${r?I(r):""}`);return o},i=(e,t)=>{const r=s().serializedToValue.get(e);if(null==r)throw new TypeError(`The proto enum deserializer failed to deserialize JSON ${JSON.stringify(e)} into an enum value.\nIt does not recognize JSON ${JSON.stringify(e)} as a valid JSON value encoding of the enum.\n${I(t)}`);return r};return{values:()=>s().values,producibleValues:()=>{const{values:e,unproducible:t}=s();return null==t?e:e.filter((e=>!t.has(e)))},serialize:e=>o(e,s().valueToSerialized,[]),serializeWithPath:(e,t)=>o(e,s().valueToSerialized,t),deserialize:e=>i(e,[]),deserializeWithPath:i}}}function p(e,t){return Object.entries(e).map((([e,r])=>{const n=function(e,t){let r,n=N(e.tag-1);if(e.fieldLabel===o.d.CONSTANT){const{primary:s,secondary:o}=y(n,e.jsonFullValue,t);n=S,r={primaryJsonValue:s,secondaryJsonValue:o}}const{primary:s,secondary:i}=y(n,e.jsonFullKey,t);return{keyEncodings:{primaryJsonKey:s,secondaryJsonKey:i},valueEncodings:r}}(r,t);return{config:r,name:e,primaryJsonKey:n.keyEncodings.primaryJsonKey,secondaryJsonKey:n.keyEncodings.secondaryJsonKey,primaryJsonValue:n.valueEncodings?.primaryJsonValue,secondaryJsonValue:n.valueEncodings?.secondaryJsonValue}}))}function y(e,t,r){if(!t){if(void 0!==r)throw new Error("Dual Deserialization config templated but JSON full key/value wasn't");return{primary:e,secondary:void 0}}if(void 0===r)return{primary:t,secondary:void 0};if(0===r)return{primary:e,secondary:t};if(1===r)return{primary:t,secondary:e};throw new Error("function should have been exhaustive, but wasn't")}function g(e,t,r,n){return new TypeError(`Expected repeated ${r} value for key ${w(e)}, found: ${b(t)} ${I(n)}`)}function m(e,t,r,n){return new TypeError(`Expected optional ${r} value for key ${w(e)}, found: ${b(t)} ${I(n)}`)}function v(e,t,r,n,s){return new TypeError(`Expected ${r} value${void 0!==s?` at index ${s}`:""} for key ${w(e)}, found: ${b(t)} ${I(n)}`)}function w(e){const{primaryJsonKey:t,secondaryJsonKey:r}=e;return r?`either "${t}" OR "${r}"`:`"${t}"`}function E(e){const{primaryJsonValue:t,secondaryJsonValue:r}=e;return r?`either "${t}" OR "${r}"`:`"${t}"`}function I(e){return`(path: .${e.join(".")})`}function b(e){return null===e?"null":Array.isArray(e)?"array":typeof e}f.requiredDouble=(e,t,r)=>{const{tag:n,jsonFullKey:s,other1:o}=R(e,t,r);return c(i.DOUBLE,s,n,o)},f.requiredInt32=(e,t,r)=>{const{tag:n,jsonFullKey:s,other1:o}=R(e,t,r);return c(i.INT32,s,n,o)},f.requiredInt64=(e,t,r)=>{const{tag:n,jsonFullKey:s,other1:o}=R(e,t,r);return c(i.INT64,s,n,o)},f.optionalDouble=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return u(i.DOUBLE,n,r)},f.optionalInt32=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return u(i.INT32,n,r)},f.optionalInt64=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return u(i.INT64,n,r)},f.repeatedDouble=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return d(i.DOUBLE,n,r)},f.repeatedInt32=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return d(i.INT32,n,r)},f.repeatedInt64=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return d(i.INT64,n,r)},f.requiredString=(e,t,r)=>{const{tag:n,jsonFullKey:s,other1:o}=R(e,t,r);return c(i.STRING,s,n,o)},f.optionalString=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return u(i.STRING,n,r)},f.repeatedString=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return d(i.STRING,n,r)},f.requiredBoolean=(e,t,r)=>{const{tag:n,jsonFullKey:s,other1:o}=R(e,t,r);return c(i.BOOLEAN,s,n,o)},f.optionalBoolean=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return u(i.BOOLEAN,n,r)},f.repeatedBoolean=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return d(i.BOOLEAN,n,r)},f.requiredBytes=(e,t,r)=>{const{tag:n,jsonFullKey:s,other1:o}=R(e,t,r);return c(i.BYTES,s,n,o)},f.optionalBytes=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return u(i.BYTES,n,r)},f.repeatedBytes=(e,t)=>{const{tag:r,jsonFullKey:n}=R(e,t);return d(i.BYTES,n,r)},f.booleanInt64Map=h(i.BOOLEAN,i.INT64),f.int32Int32Map=h(i.INT32,i.INT32),f.int32Int64Map=h(i.INT32,i.INT64),f.int32BoolMap=h(i.INT32,i.BOOLEAN),f.int32DoubleMap=h(i.INT32,i.DOUBLE),f.int32StringMap=h(i.INT32,i.STRING),f.int32StringEnumMap=h(i.INT32,"enum"),f.int32ObjectMap=h(i.INT32,"object"),f.int32BytesMap=h(i.INT32,i.BYTES),f.int64Int32Map=h(i.INT64,i.INT32),f.int64Int64Map=h(i.INT64,i.INT64),f.int64BooleanMap=h(i.INT64,i.BOOLEAN),f.int64DoubleMap=h(i.INT64,i.DOUBLE),f.int64StringMap=h(i.INT64,i.STRING),f.int64StringEnumMap=h(i.INT64,"enum"),f.int64ObjectMap=h(i.INT64,"object"),f.int64BytesMap=h(i.INT64,i.BYTES),f.doubleInt32Map=h(i.DOUBLE,i.INT32),f.doubleInt64Map=h(i.DOUBLE,i.INT64),f.doubleBoolMap=h(i.DOUBLE,i.BOOLEAN),f.doubleDoubleMap=h(i.DOUBLE,i.DOUBLE),f.doubleStringMap=h(i.DOUBLE,i.STRING),f.doubleStringEnumMap=h(i.DOUBLE,"enum"),f.doubleObjectMap=h(i.DOUBLE,"object"),f.doubleBytesMap=h(i.DOUBLE,i.BYTES),f.stringInt32Map=h(i.STRING,i.INT32),f.stringInt64Map=h(i.STRING,i.INT64),f.stringBooleanMap=h(i.STRING,i.BOOLEAN),f.stringDoubleMap=h(i.STRING,i.DOUBLE),f.stringStringMap=h(i.STRING,i.STRING),f.stringStringEnumMap=h(i.STRING,"enum"),f.stringObjectMap=h(i.STRING,"object"),f.stringBytesMap=h(i.STRING,i.BYTES);const O={MINI_PRIMARY_FULL_SECONDARY:0,FULL_PRIMARY_MINI_SECONDARY:1},S="A?",T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function N(e){if(e0;)t.push(T.charAt(e%T.length)),e=Math.floor(e/T.length);return t.reverse().join("")}}function R(e,t,r,n){return"string"==typeof e?{jsonFullKey:e,tag:t,other1:r,other2:n}:{tag:e,other1:t,other2:r}}function M(e,t){return typeof e===t||function(e,t){return"Uint8Array"===t&&"string"==typeof e}(e,t)}},141182:(e,t,r)=>{r.d(t,{c:()=>n});const n={INIT_TELEMETRY:"INIT_TELEMETRY",ERROR_OCCURRED:"ERROR_OCCURRED"}},175104:(e,t,r)=>{r.d(t,{J:()=>s,w:()=>n});class n{static checkArgument(e,t,...r){if(!e)throw new Error(null==t?"invalid argument":n.format(t,...r))}static checkState(e,t,...r){if(!e)throw new Error(null==t?"invalid state":n.format(t,...r))}static checkEquals(e,t,r,...s){if(e!==t)throw new Error(null==r?n.format("{} != {}",n.stringify(e),n.stringify(t)):n.format(r,...s))}static stringify(e){if(null==e||"symbol"==typeof e)return String(e);try{return JSON.stringify(e)}catch(t){return String(e)}}static checkExists(e,t,...r){if(null==e)throw new Error(null==t?"argument is null":n.format(t,...r));return e}static format(e,...t){let r=0;return e.replace(/\{}/g,(()=>r{r.d(t,{j:()=>n});const n=r(133599).X.createEnumUtil((()=>[0,1,2,3,4]))},248590:(e,t,r)=>{r.d(t,{J:()=>n,X:()=>s});class n extends Error{constructor(){super("[internal_error] Comms promise timed out.")}}class s{reset(e){e&&(this.timeoutMs=e),this.setTimeout()}resolve(e){clearTimeout(this.timeoutId),this.resolveFn(e)}reject(e){clearTimeout(this.timeoutId),this.rejectFn(e)}promise(){return this.p}rejectOnNextTick(){this.timeoutId=setTimeout((()=>{this.rejectFn(new n)}),500)}setTimeout(){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((()=>{this.rejectOnNextTick()}),Math.max(this.timeoutMs-500,500))}constructor(e){this.timeoutMs=e,this.p=new Promise(((e,t)=>{this.resolveFn=e,this.rejectFn=t})),this.setTimeout()}}},249333:(e,t,r)=>{r.d(t,{J:()=>l});var n=r(737329),s=r(626271),o=r(311939),i=r(687777);const a={maxBufferSize:25,maxAbsoluteBufferSize:1e3,flushIntervalMs:2e3,maxConsecutiveFailures:3,maxBeaconPayloadBytes:61440,maxEventsPerRequest:25};class l{setDocumentContext(e,t){this.documentId=e,this.elementId=t}setReleaseContext(e,t){this.deploymentGroup=e,this.releaseId=t}addLog(e){if(!this.permanentlyFailed){for(this.buffer.push(e);this.buffer.length>this.config.maxAbsoluteBufferSize;)this.buffer.shift();this.buffer.length>=this.config.maxBufferSize&&this.flush()}}async flush(){if(0===this.buffer.length||this.isSending||this.permanentlyFailed)return;if(this.consecutiveFailures>=this.config.maxConsecutiveFailures)return;this.isSending=!0;const e=[...this.buffer];this.buffer=[];try{const t=this.splitIntoBatches(e);for(const r of t){const t=this.createRequest(r),n=await fetch(this.telemetryEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o.g.serialize(t))});if(!n.ok){if(n.status>=400&&n.status<500)return void this.disablePermanently();{const t=e.indexOf(r[0]),n=e.slice(t);return this.buffer=[...n,...this.buffer],void this.consecutiveFailures++}}this.consecutiveFailures=0}}catch{this.buffer=[...e,...this.buffer],this.consecutiveFailures++}finally{this.isSending=!1}}flushSync(){if(this.permanentlyFailed)return!1;if(0===this.buffer.length)return!0;if(this.consecutiveFailures>=this.config.maxConsecutiveFailures)return!1;const e=this.trimLogsToFitPayloadLimit(this.buffer);if(0===e.length)return!1;const t=this.splitIntoBatches(e);let r=!0;for(const n of t){const e=this.createRequest(n),t=new Blob([JSON.stringify(o.g.serialize(e))],{type:"application/json"});if(!navigator.sendBeacon(this.telemetryEndpoint,t)){r=!1,this.consecutiveFailures++;break}}return r&&(this.buffer=[]),r}dispose(){null!=this.flushIntervalId&&(clearInterval(this.flushIntervalId),this.flushIntervalId=null)}startFlushInterval(){this.flushIntervalId=setInterval((()=>{this.flush()}),this.config.flushIntervalMs)}disablePermanently(){this.permanentlyFailed=!0,this.buffer=[],null!=this.flushIntervalId&&(clearInterval(this.flushIntervalId),this.flushIntervalId=null)}splitIntoBatches(e){const t=[];for(let r=0;r1?r.push({...n,message:`${n.message} (x${s})`}):r.push(n);return r.sort(((e,t)=>e.timestamp-t.timestamp))}trimToFitSize(e){const t=[...e];let r=this.basePayloadSize;for(let n=t.length-1;n>=0;n--){const e=this.calculateEntrySize(t[n]);if(!(r+e<=this.config.maxBeaconPayloadBytes))return n{r.d(t,{g:()=>i});var n=r(133599),s=r(687777),o=r(975926);const i=n.X.createMessage((()=>({documentId:n.X.optionalString(1),elementId:n.X.optionalString(2),logs:n.X.repeatedObject(3,s.I),sessionId:n.X.optionalString(4),deploymentGroup:n.X.optionalStringEnum(5,o.f),releaseId:n.X.optionalString(6)})))},376231:(e,t,r)=>{r.d(t,{J:()=>n.J});var n=r(175104)},401915:(e,t,r)=>{r.d(t,{N:()=>n});const n=r(133599).X.createMessage((()=>({})))},428647:(e,t,r)=>{r.d(t,{v:()=>s});var n=r(133599);const s=n.X.createMessage((()=>({documentId:n.X.optionalString("documentId",1),elementId:n.X.optionalString("elementId",2)})),{dualDeserializationConfig:n.y.MINI_PRIMARY_FULL_SECONDARY})},432265:(e,t,r)=>{function n(e){const t=new WeakSet,r=(e,r)=>{if(void 0===r)return"[undefined]";if("function"==typeof r)return`[Function: ${r.name||"anonymous"}]`;if("symbol"==typeof r)return r.toString();if("bigint"==typeof r)return`${r.toString()}n`;if(r instanceof Error)return{name:r.name,message:r.message,stack:r.stack};if(r instanceof RegExp)return r.toString();if(r instanceof Date)return r.toISOString();if(null!=r&&"object"==typeof r){if(t.has(r))return"[Circular]";t.add(r)}return r};try{return JSON.stringify(e,r)}catch{return String(e)}}function s(e){return void 0===e?"undefined":null==e?"null":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):"bigint"==typeof e?`${e.toString()}n`:"symbol"==typeof e?e.toString():"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e instanceof Error?e.message:n(e)}r.d(t,{J:()=>n,X:()=>s})},433113:(e,t,r)=>{r.d(t,{Mk:()=>l,q8:()=>c});r(111903);var n=r(141182),s=r(967545),o=r(428647),i=r(770021),a=r(401915);const l="canva-code-telemetry-sdk";class c{async sendInitTelemetry(e){const t=u(await this.comms.request(n.c.INIT_TELEMETRY,s.b.serialize(e)),n.c.INIT_TELEMETRY);return o.v.deserialize(t)}async sendErrorOccurred(e){const t=u(await this.comms.request(n.c.ERROR_OCCURRED,i.n.serialize(e)),n.c.ERROR_OCCURRED);return a.N.deserialize(t)}constructor(e){this.comms=e}}function u(e,t){if(!e.ok)throw new Error(`Encountered an error while sending ${t} request: ${e.error}`);if(null==e.value)throw new Error(`${t}: Result cannot be empty`);return e.value}},450674:(e,t,r)=>{r.d(t,{S:()=>g});var n=r(737329),s=r(928283),o=r(433113),i=r(967545),a=r(770021),l=r(432265),c=r(934939),u=r(992980),d=r(687777),h=r(786190);function f(e){return e.map((e=>"string"==typeof e?e:e instanceof Error?e.message:e===h.K?"":(0,l.X)(e))).filter((e=>e&&e.length>0)).join(" ")}function p(e){for(const t of e)if(t instanceof Error&&t.stack)return t.stack}function y(e){const t=e.filter((e=>e!==h.K));if(!(t.length<=1))return(0,l.J)(t.slice(1))}class g{setupReleaseContext(){try{const e=(0,s.v)();if(null==e)return;this.telemetryService.setReleaseContext(e.deploymentGroup,e.releaseId)}catch(e){this.errorService.errorException(e,{extra:new Map([[c.h,!0]])})}}async setupParentCommunication(){try{const e=await this.connectToParent(this.errorService,"*",window,o.Mk);if(!e.ok)return void this.errorService.error("Failed to connect to parent for telemetry");this.telemetryClientComms=this.createTelemetryClientComms(e.value);const t=await this.telemetryClientComms.sendInitTelemetry(new i.b);this.documentId=t.documentId,this.elementId=t.elementId,this.telemetryService.setDocumentContext(this.documentId,this.elementId),this.isInitialized=!0,this.flushPendingErrorNotifications(),this.errorService.info("Telemetry SDK initialized",{extra:new Map([[c.h,!0]])})}catch(e){this.errorService.errorException(e,{extra:new Map([[c.h,!0]])})}}setupConsoleHandlers(){console.debug=(...e)=>{const t=this.detectSystemLog(e);this.captureConsole(u.L.DEBUG,e,t),this.originalConsole.debug(...e)},console.log=(...e)=>{const t=this.detectSystemLog(e);this.captureConsole(u.L.INFO,e,t),this.originalConsole.log(...e)},console.info=(...e)=>{const t=this.detectSystemLog(e);this.captureConsole(u.L.INFO,e,t),this.originalConsole.info(...e)},console.warn=(...e)=>{const t=this.detectSystemLog(e);this.captureConsole(u.L.WARNING,e,t),this.originalConsole.warn(...e)},console.error=(...e)=>{const t=this.detectSystemLog(e),r=this.captureConsole(u.L.ERROR,e,t);!t&&r&&this.notifyErrorOccurred(f(e),r),this.originalConsole.error(...e)}}setupGlobalErrorHandlers(){this.originalOnError=window.onerror,this.originalOnUnhandledRejection=window.onunhandledrejection;const e=this.originalOnError,t=this.originalOnUnhandledRejection;window.onerror=(t,r,s,o,i)=>{const a=(0,n.g)(),l="string"==typeof t?t:"Unknown error",c=new d.I({eventId:a,message:l,severity:u.L.ERROR,timestamp:Date.now(),isSystem:!1,args:JSON.stringify({source:r,lineno:s,colno:o}),stackTrace:i?.stack});if(this.telemetryService.addLog(c),this.notifyErrorOccurred(l,a),"function"==typeof e)return e.call(window,t,r,s,o,i)},window.onunhandledrejection=e=>{const r=(0,n.g)(),s=e.reason,o=s instanceof Error?s.message:String(s??"Unhandled promise rejection"),i=new d.I({eventId:r,message:o,severity:u.L.ERROR,timestamp:Date.now(),isSystem:!1,stackTrace:s instanceof Error?s.stack:void 0});this.telemetryService.addLog(i),this.notifyErrorOccurred(o,r),"function"==typeof t&&t.call(window,e)}}setupBrowserApiHandlers(){this.originalSetTimeout=window.setTimeout,this.originalSetInterval=window.setInterval,this.originalRequestAnimationFrame=window.requestAnimationFrame;const e=this.originalSetTimeout,t=this.originalSetInterval,r=this.originalRequestAnimationFrame;window.setTimeout=(t,r,...n)=>{if("function"==typeof t){const s=(...e)=>{try{t(...e)}catch(r){throw this.handleBrowserApiError(r,"setTimeout"),r}};return e.call(window,s,r,...n)}return e.call(window,t,r,...n)},window.setInterval=(e,r,...n)=>{if("function"==typeof e){const s=(...t)=>{try{e(...t)}catch(r){throw this.handleBrowserApiError(r,"setInterval"),r}};return t.call(window,s,r,...n)}return t.call(window,e,r,...n)},window.requestAnimationFrame=e=>r.call(window,(t=>{try{e(t)}catch(r){throw this.handleBrowserApiError(r,"requestAnimationFrame"),r}}))}setupPageUnloadHandler(){this.visibilityChangeHandler=()=>{"hidden"===document.visibilityState&&this.telemetryService.flushSync()},this.pagehideHandler=()=>{this.telemetryService.flushSync()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),window.addEventListener("pagehide",this.pagehideHandler)}detectSystemLog(e){return e.some((e=>e===h.K))}captureConsole(e,t,r){const s=(0,n.g)(),o=new d.I({eventId:s,message:f(t),severity:e,timestamp:Date.now(),isSystem:r,args:y(t),stackTrace:p(t)});return this.telemetryService.addLog(o),s}handleBrowserApiError(e,t){const r=(0,n.g)(),s=e instanceof Error?e.message:String(e),o=new d.I({eventId:r,message:`[${t}] ${s}`,severity:u.L.ERROR,timestamp:Date.now(),isSystem:!1,stackTrace:e instanceof Error?e.stack:void 0});this.telemetryService.addLog(o),this.notifyErrorOccurred(s,r)}notifyErrorOccurred(e,t){this.isInitialized?this.telemetryClientComms&&this.telemetryClientComms.sendErrorOccurred(new a.n({errorTimestamp:Date.now(),errorId:t,message:e})):this.pendingErrorNotifications.push({summary:e,eventId:t})}flushPendingErrorNotifications(){if(this.telemetryClientComms){for(const e of this.pendingErrorNotifications)this.telemetryClientComms.sendErrorOccurred(new a.n({errorTimestamp:Date.now(),errorId:e.eventId,message:e.summary.substring(0,500)}));this.pendingErrorNotifications.length=0}}dispose(){this.telemetryService.dispose(),console.log=this.originalConsole.log,console.info=this.originalConsole.info,console.warn=this.originalConsole.warn,console.error=this.originalConsole.error,console.debug=this.originalConsole.debug,null!=this.originalOnError&&(window.onerror=this.originalOnError),null!=this.originalOnUnhandledRejection&&(window.onunhandledrejection=this.originalOnUnhandledRejection),null!=this.originalSetTimeout&&(window.setTimeout=this.originalSetTimeout),null!=this.originalSetInterval&&(window.setInterval=this.originalSetInterval),null!=this.originalRequestAnimationFrame&&(window.requestAnimationFrame=this.originalRequestAnimationFrame),null!=this.visibilityChangeHandler&&document.removeEventListener("visibilitychange",this.visibilityChangeHandler),null!=this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.pendingErrorNotifications.length=0}constructor(e,t,r){this.connectToParent=e,this.createTelemetryClientComms=t,this.telemetryService=r,this.isInitialized=!1,this.pendingErrorNotifications=[],this.originalOnUnhandledRejection=null;const n=console.log.bind(console),s=console.info.bind(console),o=console.warn.bind(console),i=console.error.bind(console),a=console.debug.bind(console);this.originalConsole={log:n,info:s,warn:o,error:i,debug:a},this.errorService=new c.F("Telemetry",this.telemetryService,this.originalConsole),this.setupReleaseContext(),this.setupConsoleHandlers(),this.setupGlobalErrorHandlers(),this.setupBrowserApiHandlers(),this.setupPageUnloadHandler()}}},488051:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(376231),s=r(658435),o=r(500383),i=r(697604);async function a(e,t,{parent:r,addEventListener:a,removeEventListener:l}=window,c){const u=Promise.withResolvers(),d=({ports:t,data:r})=>{const s=(0,i.lT)(r,"parent",c);if(!s.ok){switch(s.error){case i.Gz.INVALID_SOURCE:e.info(s.error,{errorMessagePrefix:"failed to verify message",extra:new Map([["data.sandboxCommsSource",r?.sandboxCommsSource]])});break;case i.Gz.MISSING_DATA:case i.Gz.MISSING_SOURCE:case i.Gz.UNKNOWN_CLIENT_ID:break;default:throw new n.J(s.error)}return}if(1!==t.length)return void e.error("invalid number of ports received from the parent");const[o]=t;u.resolve(o)};a("message",d);try{const n=(0,i.v7)("iframe",c);r.postMessage(n,t);const a=await u.promise;return s.Q.Ok(new o.I(a,e.createChild("comms"),!1))}catch(h){return s.Q.Err(h)}finally{l("message",d)}}},500383:(e,t,r)=>{r.d(t,{I:()=>a});var n=r(376231),s=r(841857),o=r(611411),i=r(749972);class a{constructor(e,t,r){this.request=(e,t)=>this.client.request(e,t),this.handle=(e,t)=>this.requestHandler.handle(e,t),this.addErrorObserver=e=>this.requestHandler.addErrorObserver(e);const s=new l((e=>{switch(e.type){case"ack":case"error":case"response":return void this.client.handleReply(e);case"request":return void this.requestHandler.handleRequest(e);default:throw new n.J(e)}}),e,t.createChild("bus"));this.client=new o.K(s.sendRequest,t.createChild("client")),this.requestHandler=new i.w(s,t.createChild("requestHandler"),r)}}class l{sendResponse(e,t){return this.bus.send({type:"response",requestId:e,payload:t})}sendError(e,t,r){return this.bus.send({type:"error",requestId:e,code:t,message:r})}sendAck(e){return this.bus.send({type:"ack",requestId:e})}constructor(e,t,r){this.handleMessage=e,this.sendRequest=(e,t,r)=>this.bus.send({type:"request",requestId:e,path:t,payload:r}),this.onReceive=e=>{switch(e.type){case"ack":return void this.handleMessage({type:"ack",requestId:e.requestId});case"error":return void this.handleMessage({type:"error",requestId:e.requestId,code:e.code,message:e.message});case"response":return void this.handleMessage({type:"response",requestId:e.requestId,payload:e.payload});case"request":return void this.handleMessage({type:"request",requestId:e.requestId,path:e.path,payload:e.payload});default:throw new n.J(e)}},this.bus=new s.Q({receive:this.onReceive},t,r)}}},543940:(e,t,r)=>{r.d(t,{L:()=>o});var n=r(133599),s=r(975926);const o=n.X.createMessage((()=>({deploymentGroup:n.X.requiredStringEnum(1,s.f),releaseId:n.X.requiredString(2),knownFonts:n.X.stringStringMap(3)})))},611411:(e,t,r)=>{r.d(t,{K:()=>c});var n=r(376231),s=r(658435),o=r(737329),i=r(718214),a=r(624859),l=r(248590);class c{request(e,t){const r=this.pendingRequests,n=this.recentTimedOutRequests,o=new l.X(a.FU),c=this.requestIdGenerator(),u=async function(){r.set(c,{path:e,requestPromise:o});try{const e=await o.promise();return s.Q.Ok(e)}catch(t){return t instanceof l.J?(n.set(c,[e,Date.now()]),n.size>32&&n.delete(n.keys().next().value),s.Q.Err(new i.cC({code:"internal_error",message:`Comms promise timed out (${e}).`}))):s.Q.Err(t)}finally{r.delete(c)}}(),d=this.send(c,e,t);return d.ok||(this.errorService.errorException(d.error,{errorMessagePrefix:"unable to send request",tags:new Map([["type","request"],["path",e]])}),o.reject(d.error)),u}handleReply(e){const{requestId:t,type:r}=e,{path:s,requestPromise:o}=this.pendingRequests.get(t)||{};if(o)switch(r){case"response":return void o.resolve(e.payload);case"ack":return void o.reset(a.I6);case"error":this.errorService.addBreadCrumb({level:"info",category:"sandbox_comms",message:"Error response received",data:{path:s??"unknown"}});const{code:t,message:r}=e;return void o.reject(new i.cC({code:t,message:r}));default:throw new n.J(e)}else if("ack"!==r){const[e,n]=this.recentTimedOutRequests.get(t)??["not_recently_timed_out",void 0],s=void 0!==n?new Map([["time_since_timeout",Date.now()-n]]):void 0;this.errorService.error("request has already been handled and resolved or was not sent from this client",{tags:new Map([["type",r],["path",e]]),extra:s})}}constructor(e,t,r=o.g){this.send=e,this.errorService=t,this.requestIdGenerator=r,this.pendingRequests=new Map,this.recentTimedOutRequests=new Map}}},624859:(e,t,r)=>{r.d(t,{FU:()=>s,I6:()=>o,MY:()=>n});const n=9e3,s=2e4,o=3e4},626271:(e,t,r)=>{function n(e,t){const r=t??window.location.href;let n;try{const e=new URL(r);e.hash="",e.search="";const t=e.pathname;if((t.split("/").pop()??"").toLowerCase().endsWith(".html")){const r=t.split("/");r.pop(),e.pathname=r.join("/")||"/"}n=e.toString()}catch{n=r.split("#")[0].split("?")[0]}n.endsWith("/")&&(n=n.slice(0,-1));return n+(e.startsWith("/")?e:"/"+e)}r.d(t,{n:()=>n})},658435:(e,t,r)=>{r.d(t,{Q:()=>o});class n{get ok(){return!0}map(e){return new n(e(this.value))}flatMap(e){return e(this.value)}mapError(){return this}get(){return this.value}constructor(e){this.value=e}}class s{get ok(){return!1}map(){return this}mapError(e){return new s(e(this.error))}flatMap(){return this}get(){}constructor(e){this.error=e}}const o={Ok:function(e){return void 0===e?i:new n(e)},Err:function(e){return void 0===e?a:new s(e)}},i=new n(void 0),a=new s(void 0)},687777:(e,t,r)=>{r.d(t,{I:()=>o});var n=r(133599),s=r(234104);const o=n.X.createMessage((()=>({eventId:n.X.requiredString(1),message:n.X.requiredString(2),severity:n.X.requiredStringEnum(3,s.j),timestamp:n.X.requiredInt64(4),isSystem:n.X.requiredBoolean(5),args:n.X.optionalString(6),stackTrace:n.X.optionalString(7)})))},697604:(e,t,r)=>{r.d(t,{Gz:()=>s,lT:()=>i,v7:()=>o});var n=r(658435);const s={MISSING_DATA:"missing 'data' field in MessageEvent",MISSING_SOURCE:"'sandboxCommsSource' is missing in MessageEvent data object",INVALID_SOURCE:"invalid source",UNKNOWN_CLIENT_ID:"unknown client id"};function o(e,t){return{sandboxCommsSource:e,clientId:t}}function i(e,t,r){if(!e)return n.Q.Err("missing 'data' field in MessageEvent");const s=e,o=s.sandboxCommsSource;return o?o!==t?n.Q.Err("invalid source"):s.clientId!==r?n.Q.Err("unknown client id"):n.Q.Ok():n.Q.Err("'sandboxCommsSource' is missing in MessageEvent data object")}},718214:(e,t,r)=>{r.d(t,{cC:()=>s});var n=r(903661);class s extends Error{constructor(e){e.code=o(e.code),super((0,n.C)(e)),this.code=e.code,this.name="CanvaError",this.rawMessage=e.message,Object.setPrototypeOf(this,s.prototype)}}let o=e=>e},737329:(e,t,r)=>{function n(e){const t=s(e,31);let r=0;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(e){const n=Number(e);return(n^t[r++]&15>>n/4).toString(16)}))}r.d(t,{g:()=>n});function s(e,t){if(!e&&"undefined"!=typeof window&&void 0!==window.crypto&&"function"==typeof window.crypto.getRandomValues)return window.crypto.getRandomValues(new Uint8Array(t));const r=e??Math.random;return Array.from({length:t},(()=>Math.floor(255*r())))}},749972:(e,t,r)=>{r.d(t,{w:()=>l});var n=r(718214),s=r(624859);const o=()=>"Something went wrong on our end, if this issue persists please contact us.",i=e=>`No request handler configured for path: "${e}".`,a=e=>`Handler for '${e}' is already defined.`;class l{addErrorObserver(e){return this.errorObservers.add(e),()=>this.errorObservers.delete(e)}handle(e,t){if(this.requestHandler.has(e))throw new n.cC({code:"internal_error",message:a(e)});return this.requestHandler.set(e,t),()=>this.requestHandler.delete(e)}async handleRequest(e){const{requestId:t,path:r,payload:a}=e,l=this.requestHandler.get(r);if(!l){const e=this.messenger.sendError(t,"internal_error",i(r));return void(e.ok||this.errorService.criticalException(e.error,{errorMessagePrefix:"unable to send error response",tags:new Map([["type","request"],["path",r]])}))}this.messenger.sendAck(t);const c=setInterval((()=>this.messenger.sendAck(t)),s.MY);let u;try{const e=await l(a);clearInterval(c),this.messenger.sendResponse(t,e)}catch(d){clearInterval(c);let e="internal_error",s=o();d instanceof n.cC?(u=d,"internal_error"===d.code?this.errorService.errorException(d,{errorMessagePrefix:"Internal error in comms handler",tags:new Map([["type","request"],["path",r]])}):(e=d.code,s=d.rawMessage)):this.reportNonCanvaErrors?this.errorService.errorException(d,{errorMessagePrefix:"Unexpected error type thrown from comms handler",tags:new Map([["type","request"],["path",r]])}):this.devConsole.error(d);const i=this.messenger.sendError(t,e,s);i.ok||this.errorService.criticalException(i.error,{errorMessagePrefix:"unable to send error response",tags:new Map([["type","request"],["path",r]])})}if(null!=u)for(const n of this.errorObservers)try{n(u)}catch(d){this.errorService.warningException(d,{errorMessagePrefix:"Error executing errorObserver"})}}constructor(e,t,r,n=console){this.messenger=e,this.errorService=t,this.reportNonCanvaErrors=r,this.devConsole=n,this.requestHandler=new Map,this.errorObservers=new Set}}},758754:(e,t,r)=>{r.d(t,{d:()=>n.dh,g:()=>n.gs});var n=r(923410)},770021:(e,t,r)=>{r.d(t,{n:()=>s});var n=r(133599);const s=n.X.createMessage((()=>({errorTimestamp:n.X.requiredInt64(1),errorId:n.X.requiredString(2),message:n.X.requiredString(3)})))},786190:(e,t,r)=>{r.d(t,{K:()=>n});const n=Symbol("canvaSystemLog")},841857:(e,t,r)=>{r.d(t,{Q:()=>o});var n=r(658435),s=r(718214);class o{constructor(e,t,r){this.handler=e,this.port=t,this.errorService=r,this.send=e=>{try{return this.port.postMessage(e),n.Q.Ok()}catch(t){return this.errorService.errorException(t),n.Q.Err(t)}},this.onMessageError=e=>{this.errorService.errorException(e)},this.onMessage=({data:e})=>{if(e)try{this.handler.receive(e)}catch(t){this.errorService.errorException(t)}else this.errorService.error(new s.cC({code:"internal_error",message:"missing data in 'MessageEvent'"}))},this.port.onmessage=this.onMessage,this.port.onmessageerror=this.onMessageError}}},887271:(e,t,r)=>{r.d(t,{B:()=>s});var n=r(175104);function s(e,{invalidateOnError:t}={invalidateOnError:!1}){let r,s=!1,o=!1;return(...i)=>{if(n.w.checkArgument(0===i.length),!o||t&&(!r.ok||s))try{s=!1,r={ok:!0,value:e()},o=!0,null!=(a=r.value)&&null!=a.then&&r.value.then(null,(e=>s=!0))}catch(l){r={ok:!1,error:l},o=!0}var a;if(r.ok)return r.value;throw r.error}}},903661:(e,t,r)=>{r.d(t,{C:()=>n});const n=e=>{const t=e.message.endsWith(".")?"":".";return`[${e.code}]: ${e.message}${t}`.trim()}},923410:(e,t,r)=>{r.d(t,{dh:()=>s,gs:()=>n});const n={CONCRETE:1,ONEOF:2},s={CONSTANT:1,REQUIRED:2,OPTIONAL:3,REPEATED:4,MAP:5}},928283:(e,t,r)=>{r.d(t,{v:()=>s});var n=r(543940);function s(){const e=window.__codeletBootstrap__;return e&&n.L.deserialize(e)}},934939:(e,t,r)=>{r.d(t,{F:()=>f,h:()=>c});var n=r(432265),s=r(992980),o=r(687777);function i(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function a(e){return"string"==typeof e?e:e instanceof Error?e.message:String(e)}function l(e){if(e instanceof Error)return e.stack}const c="isSystem";function u(e){if(void 0===e||"string"==typeof e)return!1;const t=e.extra;return void 0!==t&&(!0===t.get(c)||"true"===t.get(c))}function d(e){if(void 0===e)return;if("string"==typeof e)return(0,n.J)({errorMessagePrefix:e});const t={};return void 0!==e.fingerprint&&(t.fingerprint=e.fingerprint),void 0!==e.errorMessagePrefix&&(t.errorMessagePrefix=e.errorMessagePrefix),void 0!==e.tags&&(t.tags=Object.fromEntries(e.tags)),void 0!==e.userFlow&&(t.userFlow=e.userFlow),void 0!==e.extra&&(t.extra=Object.fromEntries(e.extra)),void 0!==e.sampleRate&&(t.sampleRate=e.sampleRate),(0,n.J)(t)}function h(e){switch(e){case"debug":return s.L.DEBUG;case"log":case"info":default:return s.L.INFO;case"warn":return s.L.WARNING;case"error":return s.L.ERROR}}class f{createChild(e){const t=new f(`${this.context}:${e}`,this.telemetryService,this.originalConsole,this);return t.documentId=this.documentId,t.elementId=this.elementId,t.beforeReportHandlers=this.beforeReportHandlers,this.children.push(t),t}withOfflineStatus(e,t){}setContext(e){this.logInternal("debug",!1,"context set",(0,n.J)(e))}setTag(e,t,r){this.logInternal("debug",!1,`tag set: ${e}=${t}`)}addBeforeSendHandler(e){}addBeforeReportHandler(e){this.beforeReportHandlers.push(e)}setFilters(e){}setSensitiveStrings(e){}addBreadCrumb(e){this.logInternal("debug",!1,"breadcrumb added",(0,n.J)(e))}debug(e,t){this.beforeReportHandlers.forEach((r=>r("debug",e,t)));const r=u(t);this.logInternal("debug",r,a(e),d(t))}info(e,t){this.beforeReportHandlers.forEach((r=>r("info",e,t)));const r=u(t);this.logInternal("info",r,a(e),d(t))}warning(e,t){this.beforeReportHandlers.forEach((r=>r("warning",e,t)));const r=u(t);this.logInternal("warn",r,a(e),d(t))}warningException(e,t){this.beforeReportHandlers.forEach((r=>r("warning",e,t)));const r=u(t);this.logInternal("warn",r,a(e),d(t),l(e))}error(e,t){this.beforeReportHandlers.forEach((r=>r("error",e,t)));const r=u(t);this.logInternal("error",r,a(e),d(t),l(e))}errorException(e,t){this.beforeReportHandlers.forEach((r=>r("error",e,t)));const r=u(t);this.logInternal("error",r,a(e),d(t),l(e))}critical(e,t){this.beforeReportHandlers.forEach((r=>r("fatal",e,t)));const r=u(t);this.logInternalCritical(r,a(e),d(t),l(e))}criticalException(e,t){this.beforeReportHandlers.forEach((r=>r("fatal",e,t)));const r=u(t);this.logInternalCritical(r,a(e),d(t),l(e))}logInternal(e,t,r,n,s){const a=`[CLIENT (${this.context})] ${r}`;void 0!==n?this.originalConsole[e](a,n):this.originalConsole[e](a);const l=new o.I({eventId:i(),message:a,severity:h(e),timestamp:Date.now(),isSystem:t,args:n,stackTrace:s});this.telemetryService.addLog(l)}logInternalCritical(e,t,r,n){const a=`[CLIENT (${this.context})] ${t}`;void 0!==r?this.originalConsole.error(a,r):this.originalConsole.error(a);const l=new o.I({eventId:i(),message:a,severity:s.L.FATAL,timestamp:Date.now(),isSystem:e,args:r,stackTrace:n});this.telemetryService.addLog(l)}constructor(e,t,r,n){this.context=e,this.telemetryService=t,this.originalConsole=r,this.parent=n,this.children=[],this.beforeReportHandlers=[]}}},967545:(e,t,r)=>{r.d(t,{b:()=>n});const n=r(133599).X.createMessage((()=>({})))},975926:(e,t,r)=>{r.d(t,{f:()=>n});const n=r(133599).X.createEnumUtil((()=>[0,1,2]))},992980:(e,t,r)=>{r.d(t,{L:()=>n});const n={DEBUG:1,INFO:2,WARNING:3,ERROR:4,FATAL:5}}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n=r(488051),s=r(433113),o=r(249333),i=r(450674);const a=new o.J;window.telemetrySdk=new i.S(n.A,(e=>new s.q8(e)),a),window.telemetrySdk.setupParentCommunication()})(); //# sourceMappingURL=sourcemaps/50d846425a1e5082.telemetry_sdk.js.map