!function(){"use strict";var e={822:function(e,n,o){o.d(n,{default:function(){return a}});const i="PMC: Piano: ",t=()=>{var e,n;return null===(n=null===(e=window.location)||void 0===e?void 0:e.search)||void 0===n?void 0:n.includes("pianoDebug")};e=o.hmd(e);var r=function(e,n,o,i){return new(o||(o=Promise))((function(t,r){function l(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(e){e(n)}))).then(l,a)}c((i=i.apply(e,n||[])).next())}))};const l={cookieLabel:"pmc_piano_reporting",reporting:{entitlements:"",user_type:"ANONYMOUS",acct_id:null,acct_type:null,org_id:null,org_name:null,paywall_logged_in:!1},initialize:function(){const e=this;window.pmcPiano.callbacks.onInit({knownUser:()=>{e.setDataForAuthUser()},unknownUser:()=>r(this,void 0,void 0,(function*(){e.hasReportingCookie()||(yield e.set(JSON.stringify(e.reporting)))}))}).onKnownIP((function(){e.reporting.acct_type="ip",e.reporting.user_type="KNOWN",e.set(JSON.stringify(e.reporting))})).onLogin((()=>{e.setDataForAuthUser()})).onLogout(e.delete.bind(e))},set:function(e){return r(this,void 0,void 0,(function*(){t()&&console.log(i,"Setting pmc_piano_reporting cookie",e),yield function(e){return n=this,o=arguments,t=function*(e,n=100){for(;!e();)yield new Promise((e=>setTimeout(e,n)))},new((i=void 0)||(i=Promise))((function(e,r){function l(e){try{c(t.next(e))}catch(e){r(e)}}function a(e){try{c(t.throw(e))}catch(e){r(e)}}function c(n){var o;n.done?e(n.value):(o=n.value,o instanceof i?o:new i((function(e){e(o)}))).then(l,a)}c((t=t.apply(n,o||[])).next())}));var n,o,i,t}((()=>void 0!==window.OptanonActiveGroups)),window.pmc.cookie.set(this.cookieLabel,e,604800,"/","targeting",this.tld())}))},delete:function(){t()&&console.log(i,"Deleting pmc_piano_reporting cookie"),window.pmc.cookie.expire(this.cookieLabel,"/",this.tld())},getDataForAuthUser:function(){return r(this,void 0,void 0,(function*(){var e,n,o,r,l;let a=null!==(e=yield window.pmcPiano.api.getConversionList())&&void 0!==e?e:[];const c=null!==(n=a.sort(((e,n)=>n.create_date-e.create_date))[0])&&void 0!==n?n:void 0;a=a.filter((e=>{var n;return null===(n=null==e?void 0:e.user_access)||void 0===n?void 0:n.granted})),a=0>=a.length?[c]:(e=>{let n=[];return 1>=e.length?e:(["( |^)corporate","( |^)education","( |^)partner","( |^)agent","( |^)billboard member","( |^)employee","( |^)comp","( |^)(limited|registration)"].forEach((o=>{var i,t,r;let l=0;for(;l{var o,r;const l=e=>{var n,o;const i=null===(o=null===(n=null==e?void 0:e.term)||void 0===n?void 0:n.resource.name)||void 0===o?void 0:o.toLocaleLowerCase();return(null==i?void 0:i.match(/( |^)agent/))?"agent":(null==i?void 0:i.match(/( |^)(corporate|education|employee|partner)/))?"site_license":"individual"},a=l(e);if(1>=n.length)return a;const c=n.slice(1).map((e=>l(e))),d="individual"===a,u=c.includes("agent"),s=c.includes("site_license");return d&&u&&s?"individual|site_license|agent":d&&s&&!u?"individual|site_license":d&&u&&!s?"individual|agent":"site_license"===a&&u?"site_license|agent":(t()&&console.log(i,`User might have duplicate resources. userId: ${null===(r=null===(o=null==e?void 0:e.user_access)||void 0===o?void 0:o.user)||void 0===r?void 0:r.uid} accountType: ${a}`),a)})(a[0],a),u=Array.from(new Set(a.map((e=>{var n;return null===(n=null==e?void 0:e.term)||void 0===n?void 0:n.resource.name})))).join("|")||void 0,s=Array.from(new Set(a.map((e=>{var n;return null===(n=null==e?void 0:e.term)||void 0===n?void 0:n.name})))).join("|")||void 0,v=Array.from(new Set(a.map((e=>(null==e?void 0:e.user_access)||(null==e?void 0:e.term)?((e={})=>{const n=null==e?void 0:e.user_access,o=null==e?void 0:e.term,i=null==o?void 0:o.resource;return(null==i?void 0:i.name)&&""!==i.name?(null==n?void 0:n.granted)&&(/registration/i.exec(null==o?void 0:o.name)||"registration"===(null==o?void 0:o.type))?"REGISTERED":(null==n?void 0:n.granted)?"SUBSCRIBER":void 0:"KNOWN"})(e):void 0)))).sort(((e,n)=>e.localeCompare(n))).join("|")||void 0,p=[];for(const e of a)(null===(o=null==e?void 0:e.term)||void 0===o?void 0:o.term_id)&&(m=null==e?void 0:e.term)&&("email_domain_contract"===(null==m?void 0:m.type)||"specific_email_addresses_contract"===(null==m?void 0:m.type))&&p.push(yield window.pmcPiano.api.getLicenseeData(e.term.term_id));var m;const g=Array.from(new Set(p.map((e=>null==e?void 0:e.id)))).join("|")||void 0,f=Array.from(new Set(p.map((e=>null==e?void 0:e.name)))).join("|")||void 0;return{accessGrantedStatus:null!==(l=null===(r=a[0])||void 0===r?void 0:r.user_access.granted)&&void 0!==l&&l,accountTermType:d,resourceName:u,termName:s,orgId:g,orgName:f,userType:v}}))},setDataForAuthUser:function(){return r(this,void 0,void 0,(function*(){const e=this,n=window.tp.pianoId.getUser();let o=e.hasReportingCookie();if((null==o?void 0:o.acct_id)===n.uid)return Promise.resolve();const i=yield this.getDataForAuthUser(),t={acct_id:n.uid,acct_type:i.accountTermType,entitlements:i.resourceName,paywall_logged_in:i.accessGrantedStatus,user_type:i.userType,org_id:i.orgId||null,org_name:i.orgName||null};return this.reporting=Object.assign(Object.assign({},e.reporting),t),yield e.set(JSON.stringify(this.reporting)),Promise.resolve()}))},hasReportingCookie:function(){try{return JSON.parse(window.pmc.cookie.get("pmc_piano_reporting")||null)}catch(e){return t()&&console.log(i,"No reporting cookie",e.toString()),!1}},tld:function(){return new URL(window.location.href).hostname.split(/\./).slice(-2).join(".")}};l.initialize();var a=l;"undefined"!=typeof exports&&(e.exports=l)}},n={};function o(i){var t=n[i];if(void 0!==t)return t.exports;var r=n[i]={id:i,loaded:!1,exports:{}};return e[i](r,r.exports,o),r.loaded=!0,r.exports}o.d=function(e,n){for(var i in n)o.o(n,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:function(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)};var i=o(822);(window.pmcPiano=window.pmcPiano||{}).reportingCookie=i.default}();