kollapsminoriteten/wp-content/themes/astra/inc/lib/nps-survey/dist/main.js

4 lines
36 KiB
JavaScript
Raw Normal View History

2026-03-31 11:30:59 +02:00
(()=>{"use strict";var e,t={45(e,t,r){var n=r(609);const o=window.wp.element,a=e=>{let t;const r=new Set,n=(e,n)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=n?n:"object"!=typeof o||null===o)?o:Object.assign({},t,o),r.forEach((r=>r(t,e)))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>s,subscribe:e=>(r.add(e),()=>r.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},s=t=e(n,o,a);return a};var s=r(79);const{useDebugValue:l}=n,{useSyncExternalStoreWithSelector:i}=s;let c=!1;const d=e=>e,u=e=>{"function"!=typeof e&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t="function"==typeof e?(e=>e?a(e):a)(e):e,r=(e,r)=>function(e,t=d,r){r&&!c&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),c=!0);const n=i(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return l(n),n}(t,e,r);return Object.assign(r,t),r},p="SET_CURRENT_STEP",m="SET_NPS_RATING",b="SET_SHOW_NPS",f=document.querySelectorAll('[data-id^="nps-survey-"]'),g={};Array.from(f).forEach((e=>{const t=JSON.parse(e.getAttribute("data-vars"));t.npsId=e.dataset.id,g[t.npsId]={showNps:t?.show_if,currentStep:"plugin-rating"===t?.nps_status?.dismiss_step?"plugin-rating":"nps-rating",npsRating:null,npsId:t.npsId}}));const h=(G=(e,{type:t,payload:r,npsId:n})=>{switch(t){case b:return{...e,[n]:{...e[n],showNps:r}};case p:return{...e,[n]:{...e[n],currentStep:r}};case m:return{...e,[n]:{...e[n],npsRating:r}};default:return e}},M=g,(R=(e,t,r)=>(r.dispatch=t=>(e((e=>G(e,t)),!1,t),t),r.dispatchFromDevtools=!0,{dispatch:(...e)=>r.dispatch(...e),...M}))?u(R):u),y=({children:e})=>(0,n.createElement)("p",{className:"mt-1 mx-0 mb-0 text-base leading-6 font-normal text-zip-body-text"},e),v=({children:e})=>(0,n.createElement)("h3",{className:"my-0 text-lg font-bold leading-7 text-zip-app-heading"},e),x=window.wp.i18n,w=function(e){const{allow_review:t=!1,message:{logo:r,plugin_name:a,nps_rating_title:s,nps_rating_message:l,rating_min_label:i,rating_max_label:c},npsId:d}=e,{dispatch:u}=h(),p=Array.from({length:10},((e,t)=>t+1)),[m,b]=(0,o.useState)(null);return(0,n.createElement)("div",null,(0,n.createElement)("div",{className:"flex items-center justify-start gap-2"},(0,n.createElement)("img",{className:"size-6",src:r,alt:"Brand Logo"}),(0,n.createElement)(v,null,s||a)),(0,n.createElement)(y,null,l.replaceAll("#pluginname",a)),(0,n.createElement)("div",{className:"mt-5"},(0,n.createElement)("span",{className:"isolate inline-flex gap-2 w-full"},p.map((e=>(0,n.createElement)("button",{type:"button",key:e,onClick:()=>async function(e){null===m&&(b(e),u({npsId:d,type:"SET_NPS_RATING",payload:e}),u(t&&e>=8?{npsId:d,type:"SET_CURRENT_STEP",payload:"plugin-rating"}:{npsId:d,type:"SET_CURRENT_STEP",payload:"comment"}))}(e),className:"relative flex-1 inline-flex items-center justify-center bg-white py-1.5 text-sm font-medium text-nps-button-text hover:bg-gray-50 focus:z-10 border border-solid border-button-disabled rounded-md transition-colors ease-in-out duration-150 hover:cursor-pointer"},e))))),(0,n.createElement)("div",{className:"mt-3 flex items-center justify-between"},(0,n.createElement)("span",{className:"text-secondary-text text-xs font-medium leading-5"},i||(0,x.__)("Very unlikely","nps-survey")),(0,n.createElement)("span",{className:"text-secondary-text text-xs font-medium leading-5"},c||(0,x.__)("Very likely","nps-survey"))))},E=e=>{const t=N(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:e=>{const r=e.split("-");return""===r[0]&&1!==r.length&&r.shift(),_(r,t)||S(e)},getConflictingClassGroupIds:(e,t)=>{const o=r[e]||[];return
2025-12-12 13:14:39 +01:00
// translators: %s: `Privacy Policy` text with link
// translators: %s: `Privacy Policy` text with link
2026-03-31 11:30:59 +02:00
(0,x.__)("By submitting, you agree to our %s","nps-survey"),i?.url?`<a href="${i?.url}" target="_blank" rel="noopener noreferrer" class="text-inherit underline focus:shadow-none">${k}</a>`:k)}}))))},Ie=function(e){const{message:{feedback_title:t,feedback_content:r,plugin_rating_link:o,plugin_rating_button_string:a},dismiss_timespan:s,plugin_slug:l,npsId:i}=e,c=h((e=>e)),{currentStep:d,npsRating:u}=c[i],[p,m]=(0,n.useState)(!1),{dispatch:b}=h(),f=async function(e=!0){we(i,u,"","plugin-rating",b,m,l),xe(i,b,d,s,l),e&&window.open(o,"_blank")};return(0,n.createElement)("div",{className:ve(p&&"opacity-50 cursor-progress")},(0,n.createElement)("div",{className:"flex justify-between"},(0,n.createElement)(v,null,t)),(0,n.createElement)(y,null,r),(0,n.createElement)("div",{className:"flex justify-between mt-5"},(0,n.createElement)(_e,{className:"relative border-none py-2 px-4 pl-0 font-semibold bg-transparent text-nps-button-background",variant:"primary",onClick:e=>Ee(i,e,b),size:"small"},(0,n.createElement)(Ne,{className:"w-4"}),(0,x.__)("Back","nps-survey")),(0,n.createElement)("div",{className:"flex justify-start"},(0,n.createElement)(_e,{variant:"link",className:"py-2 px-4 no-underline font-normal",type:"button",onClick:()=>f(!1),size:"small"},(0,x.__)("I already did!","nps-survey")),(0,n.createElement)(_e,{variant:"primary",className:"py-2 px-4 font-semibold hover:text-white",type:"button",onClick:f,size:"small"},a||(0,x.__)("Rate the Plugin","nps-survey")))))};function Ce({title:e,titleId:t,...r},o){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:o,"aria-labelledby":t},r),e?n.createElement("title",{id:t},e):null,n.createElement("path",{d:"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"}))}const je=n.forwardRef(Ce),Pe=()=>{const e=window.innerWidth,t={xs:512,sm:640,md:768,lg:1024,xl:1280,"2xl":1536};for(const r in t)if(e<=t[r])return r},Te=e=>{const{plugin_slug:t,dismiss_timespan:r,npsId:o,popup:a={placement:"bottom-right"},show_overlay:s=!1}=e,l=h((e=>e)),{dispatch:i}=h(),{showNps:c,currentStep:d,npsRating:u}=l[o],[p,m]=(0,n.useState)(!1),[b,f]=(0,n.useState)(Pe());if((0,n.useEffect)((()=>{const e=()=>{f(Pe())};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),c)return(0,n.createElement)(n.Fragment,null,s&&(0,n.createElement)("div",{className:"nps-survey-overlay fixed inset-0 bg-[#111827BF]/75 z-[999999999]"}),(0,n.createElement)("div",{className:ve("comment"===d?"max-w-[36em]":"max-w-[30rem]","xs:w-full w-[calc(100%-8px)] flex bg-white rounded-lg fixed z-[9999999999] right-2 p-4 sm:p-5 border border-solid border-border-tertiary shadow-lg box-border"),style:(()=>{let e="8px";"xs"===b&&(e=4);const t={},[r,n="center"]=a?.placement?a?.placement.split("-"):["bottom","right"];"top"===r?t.top="8px":"center"===r?(t.top="50%",t.translate="0 -50%"):t.bottom="8px";const o="rtl"===document.documentElement.dir,s={left:o?"right":"left",right:o?"left":"right",center:"center"},l=s[n]||s.right;return"center"===l?(t.left="50%",t.transform="translateX(-50%)"):t[l]=e,t})()},(0,n.createElement)("div",{className:ve("w-full",p&&"opacity-50 cursor-progress")},"nps-rating"===d?(0,n.createElement)(w,{...e}):"comment"===d?(0,n.createElement)(ze,{...e}):"plugin-rating"===d?(0,n.createElement)(Ie,{...e}):void 0),(0,n.createElement)("span",{className:"absolute top-3 right-3 left-auto cursor-pointer",onClick:function(){p||(u&&"plugin-rating"===d&&we(o,u,"","plugin-rating",i,m,t),xe(o,i,d,r,t))}},(0,n.createElement)(je,{className:"h-5 w-5 text-zip-app-inactive-icon","aria-hidden":"true"}))))},Oe=e=>(0,n.createElement)("div",{id:"nps-survey-wrapper",className:"nps-survey-wrapper"},e&&(0,n.createElement)(Te,{...e}));document.querySelectorAll('[data-id^="nps-survey-"]').forEach(((e,t)=>{const r=(0,o.createRoot)(e),a=JSON.parse(e.getAttribute("data-vars"));a.npsId=e.datas