Files
medicalalert-web-reloaded/wp/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/woo-directives-runtime.js
Rachit Bhargava 5d0f0734d8 first commit
2023-07-21 17:12:10 -04:00

1 line
6.3 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{6:function(e,t,o){"use strict";o.r(t),o.d(t,"store",(function(){return p}));var n=o(1),c=o(5),r=o(3),a=o(0);const s=e=>e&&"object"==typeof e&&!Array.isArray(e),i=(e,t)=>{if(s(e)&&s(t))for(const o in t)s(t[o])?(e[o]||Object.assign(e,{[o]:{}}),i(e[o],t[o])):Object.assign(e,{[o]:t[o]})},l=(()=>{const e=document.querySelector('script[type="application/json"]#store');if(!e)return{};try{const{state:t}=JSON.parse(e.textContent);if(s(t))return t;throw Error("Parsed state is not an object")}catch(e){console.log(e)}return{}})(),d={state:Object(r.a)(l)};"undefined"!=typeof window&&(window.store=d);const p=({state:e,...t})=>{i(d,t),i(l,e)},u=Object(a.b)({}),h={},f=(e,t)=>{h[e]=t},w={},b=(e,t)=>{w[e]=t},v=({ref:e}={})=>(t,o={})=>{const n=((e,t)=>{let o={...d,context:t};return e.split(".").forEach(e=>o=o[e]),o})(t,o.context);return"function"==typeof n?n({state:d.state,...void 0!==e?{ref:e}:{},...o}):n},y=({type:e,directives:t,props:o})=>{const c=Object(n.d)(null),r=Object(a.c)(e,{...o,ref:c,_wrapped:!0}),s={...o,children:r},i=v({ref:c.current}),l={directives:t,props:s,element:r,context:u,evaluate:i};for(const e in t){var d;const t=null===(d=h[e])||void 0===d?void 0:d.call(h,l);void 0!==t&&(s.children=t)}return s.children},m=a.e.vnode;a.e.vnode=e=>{const t=e.type,{directives:o}=e.props;if("string"==typeof t&&"woo-"===t.slice(0,"woo-".length))e.props.children=Object(a.c)(w[t.slice("woo-".length)],{...e.props,context:u,evaluate:v()},e.props.children);else if(o){const t=e.props;delete t.directives,t._wrapped?delete t._wrapped:(e.props={type:e.type,directives:o,props:t},e.type=y)}m&&m(e)};const O=new RegExp("data-woo-([^:]+):?(.*)$"),j=new WeakSet;function x(e){const t={},{attributes:o,childNodes:n}=e,c={};let r=!1,s=!1,i=!1;if(3===e.nodeType)return e.data;if(4===e.nodeType)return e.replaceWith(new Text(e.nodeValue)),e.nodeValue;for(let e=0;e<o.length;e++){const n=o[e].name;if(n["data-woo-".length]&&"data-woo-"===n.slice(0,"data-woo-".length))if("data-woo-ignore"===n)s=!0;else if("data-woo-island"===n)i=!0;else{r=!0;let t=o[e].value;try{t=JSON.parse(t)}catch(e){}const[,a,s]=O.exec(n);c[a]=c[a]||{},c[a][s||"default"]=t}else{if("ref"===n)continue;t[n]=o[e].value}}if(s&&!i)return Object(a.c)(e.localName,{dangerouslySetInnerHTML:{__html:e.innerHTML}});i&&j.add(e),r&&(t.directives=c);const l=[];for(let e=0;e<n.length;e++){const t=n[e];8===t.nodeType||7===t.nodeType?(t.remove(),e--):l.push(x(t))}return Object(a.c)(e.localName,t,l)}const g=(e,t)=>{const o=(t=[].concat(t))[t.length-1].nextSibling;function n(t,n){e.insertBefore(t,n||o)}return e.__k={nodeType:1,parentNode:e,firstChild:t[0],childNodes:t,insertBefore:n,appendChild:n,removeChild(t){e.removeChild(t)}}};let S;const E=new Map,k=new Map,A=e=>{const t=new URL(e,window.location);return t.pathname+t.search},N=e=>{var t;return"active"===(null===(t=e.querySelector("meta[itemprop='woo-client-side-navigation']"))||void 0===t?void 0:t.getAttribute("content"))},T=async e=>{const t=(await Promise.all([].map.call(e.querySelectorAll("link[rel='stylesheet']"),e=>{const t=e.getAttribute("href");return k.has(t)||k.set(t,fetch(t).then(e=>e.text())),k.get(t)}))).map(e=>{const t=document.createElement("style");return t.textContent=e,t});return[e.querySelector("title"),...e.querySelectorAll("style"),...t]},C=e=>{e=A(e),E.has(e)||E.set(e,(async e=>{const t=await window.fetch(e).then(e=>e.text()),o=(new window.DOMParser).parseFromString(t,"text/html");if(!N(o.head))return!1;return{head:await T(o.head),body:x(o.body)}})(e))};window.addEventListener("popstate",async()=>{const e=A(window.location),t=E.has(e)&&await E.get(e);t?(document.head.replaceChildren(...t.head),Object(a.f)(t.body,S)):window.location.reload()});var $=o(4);window.requestAnimationFrame;const L=N(document.head),q=e=>e&&"object"==typeof e&&!Array.isArray(e),_=(e,t)=>{for(const o in t)void 0===Object(r.b)(e,o)?e["$"+o]=t["$"+o]:q(Object(r.b)(e,o))&&q(Object(r.b)(t,o))&&_(e["$"+o].peek(),t["$"+o].peek())};var M=()=>{f("context",({directives:{context:{default:e}},props:{children:t},context:o})=>{const{Provider:c}=o,a=Object(n.a)(o),s=Object(n.c)(()=>{const t=Object(r.a)(e);return _(t,a),t},[e,a]);return Object($.a)(c,{value:s,children:t})}),f("effect",({directives:{effect:e},context:t,evaluate:o})=>{const r=Object(n.a)(t);Object.values(e).forEach(e=>{Object(c.a)(()=>{o(e,{context:r})})})}),f("on",({directives:{on:e},element:t,evaluate:o,context:c})=>{const r=Object(n.a)(c);Object.entries(e).forEach(([e,n])=>{t.props["on"+e]=e=>{o(n,{event:e,context:r})}})}),f("class",({directives:{class:e},element:t,evaluate:o,context:c})=>{const r=Object(n.a)(c);Object.keys(e).filter(e=>"default"!==e).forEach(c=>{const a=o(e[c],{className:c,context:r}),s=t.props.class||"",i=new RegExp(`(^|\\s)${c}(\\s|$)`,"g");a?i.test(s)||(t.props.class=s?`${s} ${c}`:c):t.props.class=s.replace(i," ").trim(),Object(n.b)(()=>{a?t.ref.current.classList.add(c):t.ref.current.classList.remove(c)},[])})}),f("bind",({directives:{bind:e},element:t,context:o,evaluate:c})=>{const r=Object(n.a)(o);Object.entries(e).filter(e=>"default"!==e).forEach(([e,o])=>{t.props[e]=c(o,{context:r})})}),f("link",({directives:{link:{default:e}},props:{href:t},element:o})=>{Object(n.b)(()=>{L&&null!=e&&e.prefetch&&C(t)}),L&&!1!==e&&(o.props.onclick=async o=>{o.preventDefault(),await(async e=>{const t=A(e);C(t);const o=await E.get(t);o?(document.head.replaceChildren(...o.head),Object(a.f)(o.body,S),window.history.pushState({},"",e)):window.location.assign(e)})(t),"smooth"===(null==e?void 0:e.scroll)?window.scrollTo({top:0,left:0,behavior:"smooth"}):!1!==(null==e?void 0:e.scroll)&&window.scrollTo(0,0)})})};document.addEventListener("DOMContentLoaded",async()=>{M(),(()=>{b("context",({children:e,data:t,context:{Provider:o}})=>{const c=Object(n.c)(()=>Object(r.a)(JSON.parse(t)),[t]);return Object($.a)(o,{value:c,children:e})});b("show",({children:e,when:t,evaluate:o,context:c})=>o(t,{context:Object(n.a)(c)})?e:Object($.a)("template",{children:e}))})(),await(async()=>{if(N(document.head)){S=g(document.documentElement,document.body);const e=x(document.body);Object(a.d)(e,S);const t=await T(document.head);E.set(A(window.location),Promise.resolve({body:e,head:t}))}else document.querySelectorAll("[data-woo-island]").forEach(e=>{if(!j.has(e)){const t=g(e.parentNode,e),o=x(e);Object(a.d)(o,t)}})})(),console.log("hydrated!")})}},[[6,1]]]);