import{m as z,h as m,o,bd as X,d as A,f as R,i as e,a8 as E,k as a,bj as Y,b as K,r as D,J as q,al as Q,bQ as B,an as G,C as T,D as I,L as j,t as C,j as S,V as P,Y as Z,B as W,bR as ee,ai as H,E as N,q as M,bS as te,by as ne,bT as oe,T as se,b1 as le,a5 as ae,W as ie}from"./DQtKGRlR.js";import{_ as re}from"./CgAL-aa6.js";const ce={},ue={xmlns:"http://www.w3.org/2000/svg",width:"848",height:"446",viewBox:"0 0 848 446",class:"inspector__logo"};function pe(w,s){return o(),m("svg",ue,s[0]||(s[0]=[X('',1)]))}const _e=Object.assign(z(ce,[["render",pe],["__scopeId","data-v-5dccb25d"]]),{__name:"InspectorLogo"}),de={class:"inspector__nav"},me=A({__name:"InspectorNavbar",props:{modelValue:{}},emits:["update:modelValue"],setup(w,{emit:s}){const n=w,r=s,u=R({get:()=>n.modelValue,set:v=>r("update:modelValue",v)});function l(){const v=Y("inspector-enabled",{default:()=>!1});v.value=!1}return(v,h)=>(o(),m("nav",de,[e("div",null,[e("button",{class:E([{"inspector__nav-item--active":a(u)==="optimizely"},"inspector__nav-item"]),onClick:h[0]||(h[0]=k=>u.value="optimizely")}," Optimizely ",2),e("button",{class:E([{"inspector__nav-item--active":a(u)==="form"},"inspector__nav-item"]),onClick:h[1]||(h[1]=k=>u.value="form")}," Form ",2),e("button",{class:E([{"inspector__nav-item--active":a(u)==="storyblok"},"inspector__nav-item"]),onClick:h[2]||(h[2]=k=>u.value="storyblok")}," Storyblok ",2),e("button",{class:E([{"inspector__nav-item--active":a(u)==="config"},"inspector__nav-item"]),onClick:h[3]||(h[3]=k=>u.value="config")}," Config ",2)]),e("button",{class:"inspector__nav-item",onClick:l},"Close")]))}}),fe=Object.assign(z(me,[["__scopeId","data-v-ac7ce665"]]),{__name:"InspectorNavbar"}),ye={},ve={class:"inspector-optimizely-disabled"};function he(w,s){return o(),m("div",ve,"Optimizely is disabled")}const be=Object.assign(z(ye,[["render",he],["__scopeId","data-v-05d16681"]]),{__name:"InspectorOptimizelyDisabled"});async function J(){var v;const{$optimizely:w}=K(),s=await((v=w==null?void 0:w.getOptimizelyConfig())==null?void 0:v.getDatafile()),n=s?JSON.parse(s):null,r=D([]);n||r.value.push("Error parsing datafile");const u=(n==null?void 0:n.experiments)??[],l=(n==null?void 0:n.featureFlags)??[];return{experiments:u,featureFlags:l,datafileErrors:r}}const ge={class:"inspector-optimizely-active"},ke={class:"inspector-optimizely-active__table"},Ce={colspan:"2"},we={class:"button-group"},xe=["value","onChange"],$e={class:"button-group__label-holder"},Ie={class:"button-group__label","aria-hidden":"true"},ze={class:"button-group__label"},Oe=["href","onMouseenter","onMouseleave"],Le={class:"button-group"},Ee=["name","value","checked","onChange"],Te={class:"button-group__label-holder"},Me={class:"button-group__label","aria-hidden":"true"},Se={class:"button-group__label"},Ae={class:"footer"},Ve={key:0,class:"messages"},je={class:"actions"},De=A({__name:"InspectorOptimizelyActive",async setup(w){let s,n;const r=D(new Map),{experiments:u,datafileErrors:l}=([s,n]=q(()=>J()),s=await s,n(),s),v=Q("optimizely"),h=D({}),k=R(()=>v.value?u.filter(t=>v.value[t.key]!==void 0).map(t=>{var _;return{key:t.key,variations:t.variations,currentVariation:((_=v.value[t.key])==null?void 0:_.variation)||"",isDisabled:v.value[t.key].variation===null}}):[]),b=R(()=>{var t;return[...new Set((t=k.value)==null?void 0:t.flatMap(({variations:_})=>_.map(({key:y})=>y)))]}),O=R(()=>{var t;return new Map(((t=k.value)==null?void 0:t.map(({key:_,variations:y})=>[_,new Set(y.map(({key:d})=>d))]))??[])}),V=R(()=>{const t=B();for(const[_,y]of Object.entries(h.value))t.searchParams.set(`optimizely_force_variation[${_}]`,y);return t});G(k,t=>{for(const{key:_,currentVariation:y}of t??[])Object.keys(h.value).includes(_)||p(_,y)},{immediate:!0});function i(t){var _;for(const y of Object.keys(h.value))(_=O.value.get(y))!=null&&_.has(t)?p(y,t):p(y,"control")}function p(t,_){h.value[t]=_}async function f(){const t={...Z().query};for(const[_,y]of Object.entries(h.value))t[`optimizely_force_variation[${_}]`]=y;await W().push({query:t}),window.location.reload()}async function c(){const t=crypto.randomUUID();try{await navigator.clipboard.writeText(V.value.href),r.value.set(t,{type:"success",message:"Successfully put link with this setup on clipboard"})}catch(_){r.value.set(t,{type:"error",message:`Something went wrong when putting link on clipboard: ${_}`})}finally{ee(()=>r.value.delete(t),3e3)}}function x(t){document.querySelectorAll(`[data-dpg-devtools-optimizely-feature-key="${t}"]`).forEach(y=>{const d=y.getBoundingClientRect(),g=document.createElement("div");g.style.position="absolute",g.style.top=`${window.scrollY+d.top}px`,g.style.left=`${window.scrollX+d.left}px`,g.style.width=`${d.width}px`,g.style.height=`${d.height}px`,g.style.outline="2px solid var(--link-text-color)",g.style.opacity="0.25",g.style.borderRadius="8px",g.style.backgroundColor="var(--link-text-color)",g.style.outlineOffset="2px",g.style.pointerEvents="none",g.style.zIndex="10000",g.setAttribute("data-highlight-overlay",t),document.body.appendChild(g)})}function L(t){document.querySelectorAll(`[data-highlight-overlay="${t}"]`).forEach(y=>y.remove())}return(t,_)=>{const y=P;return o(),m("div",ge,[e("div",ke,[e("table",null,[_[1]||(_[1]=e("thead",null,[e("tr",null,[e("th",{width:"99%"},"Test Key"),e("th",null,"Current Variation")])],-1)),e("tbody",null,[(o(!0),m(I,null,j(a(l),(d,g)=>(o(),m("tr",{key:g},[e("td",Ce,C(d),1)]))),128)),a(l).length===0?(o(),m(I,{key:0},[e("tr",null,[_[0]||(_[0]=e("td",null,"Bulk change all tests:",-1)),e("td",null,[e("div",we,[(o(!0),m(I,null,j(a(b),d=>(o(),m("label",{key:d,class:"button-group__element"},[e("input",{type:"radio",name:"modify-all",value:d,class:"button-group__input",onChange:g=>i(d)},null,40,xe),e("span",$e,[e("strong",Ie,C(d),1),e("span",ze,C(d),1)])]))),128))])])]),(o(!0),m(I,null,j(a(k),d=>{var g;return o(),m("tr",{key:d.key},[e("td",{class:E({"is-disabled":d.isDisabled}),width:"99%"},[e("a",{class:"test-link",target:"_blank",href:`https://app.optimizely.com/v2/projects/15080820342/flags/manage/${(g=d.key)==null?void 0:g.replace("_test","")}/`,onMouseenter:$=>x(d.key),onMouseleave:$=>L(d.key)},[e("span",null,C(d.key),1),S(y,{icon:"external-link"})],40,Oe)],2),e("td",null,[e("div",Le,[(o(!0),m(I,null,j(d.variations,$=>(o(),m("label",{key:d.key+$.key,class:"button-group__element"},[e("input",{type:"radio",name:d.key,value:$.key,class:"button-group__input",checked:a(h)[d.key]===$.key,onChange:F=>{var U;return p(d.key,(U=F.target)==null?void 0:U.value)}},null,40,Ee),e("span",Te,[e("strong",Me,C($.key),1),e("span",Se,C($.key),1)])]))),128))])])])}),128))],64)):T("",!0)])])]),e("div",Ae,[a(r).size>0?(o(),m("div",Ve,[(o(!0),m(I,null,j(a(r),([d,{message:g,type:$}])=>(o(),m("div",{key:d,class:E(["message",[`message--${$}`]])},C(g),3))),128))])):T("",!0),e("div",je,[e("button",{class:"action",onClick:f},[S(y,{icon:"refresh-cw"}),_[2]||(_[2]=e("span",null,"Reload page with this setup",-1))]),e("button",{class:"action",onClick:c},[S(y,{icon:"clipboard"})])])])])}}}),Re=Object.assign(z(De,[["__scopeId","data-v-80baca36"]]),{__name:"InspectorOptimizelyActive"}),Fe=["href"],Ne=A({__name:"InspectorOptimizelyAll",async setup(w){let s,n;const r=D(""),{experiments:u,featureFlags:l}=([s,n]=q(()=>J()),s=await s,n(),s),v=u.map(k=>{const b=l.find(O=>O.experimentIds.includes(k.id));return{experimentKey:k.key,featureKey:b==null?void 0:b.key,experimentDetails:k}}),h=R(()=>v.filter(k=>{var b;return k.experimentKey.toLowerCase().includes(r.value.toLowerCase())||((b=k.featureKey)==null?void 0:b.toLowerCase().includes(r.value.toLowerCase()))}));return(k,b)=>{const O=re,V=P;return o(),m("div",null,[S(O,{id:"search",modelValue:a(r),"onUpdate:modelValue":b[0]||(b[0]=i=>H(r)?r.value=i:null),type:"text",placeholder:"Search..."},null,8,["modelValue"]),e("table",null,[b[4]||(b[4]=e("thead",null,[e("tr",null,[e("th",null,"Key"),e("th",null,"Status")])],-1)),e("tbody",null,[(o(!0),m(I,null,j(a(h),i=>{var p;return o(),m("tr",{key:i.experimentKey},[e("td",null,[b[1]||(b[1]=e("b",null,"Experiment key: ",-1)),e("code",null,C(i.experimentKey),1),b[2]||(b[2]=e("br",null,null,-1)),b[3]||(b[3]=e("b",null,"Feature Key: ",-1)),e("code",null,C(i.featureKey),1)]),e("td",null,[e("a",{target:"_blank",href:`https://app.optimizely.com/v2/projects/15080820342/flags/manage/${(p=i.experimentKey)==null?void 0:p.replace("_test","")}/`},[N(C(i.experimentDetails.status)+" ",1),S(V,{icon:"external-link"})],8,Fe)])])}),128))])])])}}}),Pe=Object.assign(z(Ne,[["__scopeId","data-v-1c4f4f2f"]]),{__name:"InspectorOptimizelyAll"}),Be={class:"inspector-optimizely"},Ke={class:"inspector-optimizely__subnav"},Ue=A({__name:"InspectorOptimizely",setup(w){const s=D("active"),n=R(()=>B().searchParams.has("disable_optimizely","true"));async function r(){const u=B();if(n.value)u.searchParams.delete("disable_optimizely","true");else{for(const[l,v]of[...u.searchParams.entries()])l.startsWith("optimizely_force_variation")&&u.searchParams.delete(l,v);u.searchParams.set("disable_optimizely","true")}await W().push({query:{...Object.fromEntries([...u.searchParams.entries()])}}),window.location.reload()}return(u,l)=>{const v=P,h=be;return o(),m("div",Be,[e("nav",Ke,[e("button",{class:E([{"inspector-optimizely__subnav-item--active":a(s)==="active"},"inspector-optimizely__subnav-item"]),onClick:l[0]||(l[0]=k=>s.value="active")}," Active Experiments ",2),e("button",{class:E([{"inspector-optimizely__subnav-item--active":a(s)==="all"},"inspector-optimizely__subnav-item"]),onClick:l[1]||(l[1]=k=>s.value="all")}," All Experiments ",2),e("button",{class:E([{"inspector-optimizely__subnav-item--green":a(n),"inspector-optimizely__subnav-item--red":!a(n)},"inspector-optimizely__subnav-item"]),onClick:r},[S(v,{icon:"power"}),N(" "+C(a(n)?"Enable":"Disable")+" Optimizely ",1)],2)]),a(n)?(o(),M(h,{key:0})):a(s)==="active"?(o(),M(Re,{key:1})):a(s)==="all"?(o(),M(Pe,{key:2})):T("",!0)])}}}),qe=Object.assign(z(Ue,[["__scopeId","data-v-9e0a30e1"]]),{__name:"InspectorOptimizely"}),We={class:"tapp-inspector-form"},He=A({__name:"InspectorForm",setup(w){return(s,n)=>(o(),m("div",We,[e("button",{onClick:n[0]||(n[0]=r=>a(te)())},"Fill form data")]))}}),Je=Object.assign(z(He,[["__scopeId","data-v-4e131250"]]),{__name:"InspectorForm"}),Xe={class:"tapp-inspector__config"},Ye={class:"tapp-inspector__config-item"},Qe={class:"tapp-inspector__config-value"},Ge={class:"tapp-inspector__config-item"},Ze={class:"tapp-inspector__config-value"},et={class:"tapp-inspector__config"},tt={class:"tapp-inspector__config-item"},nt=A({__name:"InspectorConfig",setup(w){const s=ne(),r=K().$config.public.API_URL;return(u,l)=>(o(),m(I,null,[e("div",Xe,[e("div",Ye,[l[1]||(l[1]=N(" MID ")),e("div",Qe,C(a(s)),1)]),e("div",Ge,[l[2]||(l[2]=N(" API ")),e("div",Ze,C(a(r)),1)])]),l[4]||(l[4]=e("hr",{class:"tapp-inspector__config-divider"},null,-1)),e("div",et,[e("div",tt,[l[3]||(l[3]=N(" Refresh Nuxt Data ")),e("button",{class:"tapp-inspector__config-button",onClick:l[0]||(l[0]=()=>("refreshNuxtData"in u?u.refreshNuxtData:a(oe))())},"Refetch Data")])])],64))}}),ot=Object.assign(z(nt,[["__scopeId","data-v-be1684ad"]]),{__name:"InspectorConfig"}),st={class:"inspector-storyblok"},lt={class:"inspector-storyblok__table"},at=["onMouseenter"],it=["href"],rt="301263",ct=A({__name:"InspectorStoryblok",setup(w){const s=K().payload.data,n=D([]);function r(i){if(!i||typeof i!="object")return[];let p=[];return"full_slug"in i&&p.push(i),Array.isArray(i)?i.forEach(f=>{p=p.concat(r(f))}):Object.values(i).forEach(f=>{typeof f=="object"&&f!==null&&(p=p.concat(r(f)))}),p}function u(i,p=[]){if(!i||typeof i!="object")return[];let f=[];return Array.isArray(i)?i.forEach((c,x)=>{typeof c=="string"?f.push({path:[...p,x.toString()],value:c}):typeof c=="object"&&c!==null&&(f=f.concat(u(c,[...p,x.toString()])))}):Object.entries(i).forEach(([c,x])=>{if(c.startsWith("_"))return;const L=[...p,c];typeof x=="string"?f.push({path:L,value:x}):typeof x=="object"&&x!==null&&(f=f.concat(u(x,L)))}),f}function l(i){const p=new Map;return i.forEach(f=>{if(f.full_slug&&f.content){const c=u(f.content);c.length>0&&p.set(f.full_slug,c)}}),p}function v(i){return i?new Date(i).toLocaleString():"N/A"}const h=r(s),k=l(h);function b(i){const p=k.get(i);if(!p)return;const f=new Map,c=[],x=L=>{let t=L.parentElement;for(;t;){if(t.classList.contains("inspector"))return NodeFilter.FILTER_REJECT;t=t.parentElement}return NodeFilter.FILTER_ACCEPT};p.forEach(({value:L})=>{var d;if(!L)return;const t=[],_=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,x);let y;for(;y=_.nextNode();)if(((d=y.textContent)==null?void 0:d.trim())===L.trim()){const $=y.parentElement;t.push($);const F=$.getBoundingClientRect();c.push({top:F.top,left:F.left,width:F.width,height:F.height})}t.length>0&&f.set(L,t)}),n.value=c}function O(){n.value=[]}function V(){if(n.value.length===0)return;const i=n.value.map(p=>{const f=document.elementFromPoint(p.left,p.top);if(!f)return p;const c=f.getBoundingClientRect();return{top:c.top,left:c.left,width:c.width,height:c.height}});n.value=i}return se(function(){window.addEventListener("scroll",V),window.addEventListener("resize",V)}),le(function(){window.removeEventListener("scroll",V),window.removeEventListener("resize",V)}),(i,p)=>{const f=P;return o(),m("div",st,[e("div",lt,[e("table",null,[p[0]||(p[0]=e("thead",null,[e("tr",null,[e("th",null,"Full Slug"),e("th",null,"Last Updated")])],-1)),e("tbody",null,[(o(!0),m(I,null,j(a(h),c=>(o(),m("tr",{key:c.full_slug,onMouseenter:x=>b(c.full_slug),onMouseleave:O},[e("td",null,[e("a",{class:"storyblok-link",target:"_blank",href:`https://app.storyblok.com/#!/me/spaces/${rt}/stories/0/0/${c.id}`},[e("span",null,C(c.full_slug),1),S(f,{icon:"external-link"})],8,it)]),e("td",null,[e("span",null,C(v(c.updated_at)),1)])],40,at))),128))])])]),(o(!0),m(I,null,j(a(n),(c,x)=>(o(),m("div",{key:x,class:"inspector-storyblok__overlay",style:ae({top:`${c.top}px`,left:`${c.left}px`,width:`${c.width}px`,height:`${c.height}px`})},null,4))),128))])}}}),ut=Object.assign(z(ct,[["__scopeId","data-v-588165c4"]]),{__name:"InspectorStoryblok"}),pt={class:"inspector__body"},_t=A({__name:"InspectorBody",props:{currentTab:{}},setup(w){return(s,n)=>{const r=qe,u=Je,l=ot,v=ut;return o(),m("div",pt,[s.currentTab==="optimizely"?(o(),M(r,{key:0})):T("",!0),s.currentTab==="form"?(o(),M(u,{key:1})):T("",!0),s.currentTab==="config"?(o(),M(l,{key:2})):T("",!0),s.currentTab==="storyblok"?(o(),M(v,{key:3})):T("",!0)])}}}),dt=Object.assign(z(_t,[["__scopeId","data-v-f6dd6c94"]]),{__name:"InspectorBody"}),mt={key:2,class:"inspector__button-label"},ft={key:0,class:"inspector"},yt={class:"app-version"},vt=A({__name:"InspectorContainer",setup(w){const{public:s}=ie(),n=D(!1),r=D("optimizely");return(u,l)=>{const v=_e,h=P,k=fe,b=dt;return o(),m(I,null,[e("button",{class:E(["inspector__button bounce-in",{"inspector__button--active":a(n)}]),title:"Inspect TAPP Site",onClick:l[0]||(l[0]=O=>n.value=!a(n))},[a(n)?(o(),M(h,{key:1,class:"inspector__button-x-icon",icon:"x"})):(o(),M(v,{key:0})),a(n)?T("",!0):(o(),m("span",mt,"Devtools"))],2),a(n)?(o(),m("div",ft,[S(k,{modelValue:a(r),"onUpdate:modelValue":l[1]||(l[1]=O=>H(r)?r.value=O:null)},null,8,["modelValue"]),S(b,{"current-tab":a(r)},null,8,["current-tab"]),e("p",yt,"version: "+C(a(s).VERSION),1)])):T("",!0)],64)}}}),gt=Object.assign(z(vt,[["__scopeId","data-v-8c0924ea"]]),{__name:"InspectorContainer"});export{gt as default}; //# sourceMappingURL=ee9peNnP.js.map