Changeset 2783097
- Timestamp:
- 09/12/2022 03:59:33 AM (4 years ago)
- Location:
- user-post-collections
- Files:
-
- 2 added
- 26 edited
- 1 copied
-
assets/banner-1544x500.png (modified) (1 prop) (previous)
-
assets/banner-772x250.png (modified) (1 prop) (previous)
-
assets/banner.svg (modified) (1 prop)
-
assets/icon-128x128.png (modified) (1 prop) (previous)
-
assets/icon-256x256.png (modified) (1 prop) (previous)
-
assets/icon.svg (modified) (1 prop)
-
assets/screenshot-1.png (modified) (1 prop) (previous)
-
assets/screenshot-2.png (modified) (1 prop) (previous)
-
assets/screenshot-3.png (modified) (1 prop) (previous)
-
assets/screenshot-4.png (modified) (1 prop) (previous)
-
assets/screenshot-5.png (modified) (1 prop) (previous)
-
assets/screenshot-6.png (modified) (1 prop) (previous)
-
assets/screenshot-7.png (modified) (1 prop) (previous)
-
assets/upc_.svg (modified) (1 prop)
-
tags/0.8.30 (copied) (copied from user-post-collections/trunk)
-
tags/0.8.30/classes/user-post-collections.php (modified) (1 diff)
-
tags/0.8.30/controllers/mg-upc-rest-list-items-controller.php (modified) (6 diffs)
-
tags/0.8.30/includes/themes-helper.php (added)
-
tags/0.8.30/javascript/mg-upc-client/dist/admin.js (modified) (1 diff)
-
tags/0.8.30/javascript/mg-upc-client/dist/main.js (modified) (1 diff)
-
tags/0.8.30/readme.txt (modified) (2 diffs)
-
tags/0.8.30/user-post-collections.php (modified) (2 diffs)
-
trunk/classes/user-post-collections.php (modified) (1 diff)
-
trunk/controllers/mg-upc-rest-list-items-controller.php (modified) (6 diffs)
-
trunk/includes/themes-helper.php (added)
-
trunk/javascript/mg-upc-client/dist/admin.js (modified) (1 diff)
-
trunk/javascript/mg-upc-client/dist/main.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/user-post-collections.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
user-post-collections/assets/banner-1544x500.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/banner-772x250.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/banner.svg
-
Property
svn:mime-type
set to
image/svg+xml
-
Property
svn:mime-type
set to
-
user-post-collections/assets/icon-128x128.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/icon-256x256.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/icon.svg
-
Property
svn:mime-type
set to
image/svg+xml
-
Property
svn:mime-type
set to
-
user-post-collections/assets/screenshot-1.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/screenshot-2.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/screenshot-3.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/screenshot-4.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/screenshot-5.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/screenshot-6.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/screenshot-7.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
user-post-collections/assets/upc_.svg
-
Property
svn:mime-type
set to
image/svg+xml
-
Property
svn:mime-type
set to
-
user-post-collections/tags/0.8.30/classes/user-post-collections.php
r2770186 r2783097 16 16 public $model; 17 17 18 const VERSION = '0.8. 29';18 const VERSION = '0.8.30'; 19 19 20 20 /** -
user-post-collections/tags/0.8.30/controllers/mg-upc-rest-list-items-controller.php
r2768965 r2783097 69 69 'permission_callback' => array( $this, 'write_item_permissions_check_always_exist' ), 70 70 'args' => $this->get_create_params(), 71 ), 72 'schema' => array( $this, 'get_item_schema' ), 73 ) 74 ); 75 76 register_rest_route( 77 $this->namespace, 78 '/' . $this->resource_name . '/(?P<upctype>' . $sticky_type . ')/items/(?P<postid>[\d]+)', 79 array( 80 array( 81 'methods' => WP_REST_Server::DELETABLE, 82 'callback' => array( $this, 'delete_item_always_exist' ), 83 'permission_callback' => array( $this, 'write_item_permissions_check_always_exist' ), 71 84 ), 72 85 'schema' => array( $this, 'get_item_schema' ), … … 336 349 } 337 350 351 return $this->delete_item_from_id( (int) $request['id'], (int) $request['postid']); 352 } 353 354 /** 355 * Remove item from a list ID 356 * 357 * @param int $list_id 358 * @param int $post_id 359 * 360 * @return WP_Error|WP_REST_Response 361 */ 362 private function delete_item_from_id( $list_id, $post_id ) { 338 363 try { 339 if ( ! $this->model->items->item_exists( (int) $ request['id'], (int) $request['postid']) ) {364 if ( ! $this->model->items->item_exists( (int) $list_id, (int) $post_id ) ) { 340 365 return new WP_Error( 341 366 'rest_item_not_found', 342 367 esc_html__( 'Item not found.', 'user-post-collections' ), 343 array( 'status' => 404 ) 368 array( 369 'status' => 404, 370 'list_id' => (int) $list_id, 371 'post_id' => (int) $post_id, 372 ) 344 373 ); 345 374 } 346 $this->model->items->remove_item( (int) $ request['id'], (int) $request['postid']);375 $this->model->items->remove_item( (int) $list_id, (int) $post_id ); 347 376 } catch ( Exception $e ) { 348 377 return new WP_Error( 349 378 'rest_item_error', 350 379 esc_html__( 'Unknown error.', 'user-post-collections' ), 351 array( 'status' => 500 ) 380 array( 381 'status' => 500, 382 'list_id' => (int) $list_id, 383 'post_id' => (int) $post_id, 384 ) 352 385 ); 353 386 } … … 357 390 array( 358 391 'deleted' => true, 392 'list_id' => (int) $list_id, 393 'post_id' => (int) $post_id, 359 394 ) 360 395 ); … … 408 443 409 444 /** 445 * Delete an item from an 'always exist' list 446 * 447 * @param WP_REST_Request $request Current request. 448 * 449 * @return WP_Error|WP_REST_Response 450 * 451 * @noinspection PhpUnused (Rest API callback) 452 */ 453 public function delete_item_always_exist( $request ) { 454 455 $response = array( 'data' => array() ); 456 457 try { 458 $list = $this->model->find_always_exist( $request['upctype'], get_current_user_id() ); 459 460 if ( null === $list ) { 461 return new WP_Error( 462 'rest_item_not_found', 463 esc_html__( 'Item not found.', 'user-post-collections' ), 464 array( 'status' => 404 ) 465 ); 466 } else { 467 return $this->delete_item_from_id( (int) $list->ID, (int) $request['postid'] ); 468 } 469 } catch ( MG_UPC_Invalid_Field_Exception $e ) { 470 $response['code'] = 'rest_invalid_field'; 471 $response['message'] = $e->getMessage(); 472 $response['data']['status'] = 409; 473 } 474 475 $response_api = new WP_REST_Response(); 476 $response_api->set_data( $response ); 477 $response_api->set_status( $response['status'] ); 478 479 return $response_api; 480 } 481 482 /** 410 483 * Create an item 411 484 * … … 427 500 $response['message'] = esc_html( $e->getMessage() ); 428 501 $response['data']['status'] = 409; 502 503 if ( 'check' === $request['context'] ) { 504 $response['check'] = 'OK'; 505 } 429 506 } catch ( Exception $e ) { 430 507 return new WP_Error( … … 554 631 } 555 632 633 if ( isset( $request['context'] ) && 'check' === $request['context'] ) { 634 if ( ! empty( $response['added'] ) ) { 635 $response['check'] = 'OK'; 636 } else { 637 $response['check'] = 'ERR'; 638 } 639 } 640 556 641 /** 557 642 * Filter for item to save. If return WP_Error, the operation is canceled. -
user-post-collections/tags/0.8.30/javascript/mg-upc-client/dist/admin.js
r2770186 r2783097 1 (()=>{"use strict";var t,e,n,i,s,o,a={},l=[],r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var s,o,a,l={};for(a in n)"key"==a?s=n[a]:"ref"==a?o=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return p(e,l,s,o,null)}function p(t,i,s,o,a){var l={type:t,props:i,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(l),l}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||s!==e.debounceRendering)&&((s=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,s,o,a;t.__d&&(o=(s=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},s)).__v=s.__v+1,I(a,s,i,e.__n,void 0!==a.ownerSVGElement,null!=s.__h?[o]:null,n,null==o?f(s):o,s.__h),S(n,s),s.__e!=o&&g(s)))}))}function y(t,e,n,i,s,o,r,c,u,d){var m,g,h,v,y,P, k,w=i&&i.__k||l,C=w.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=w[m])||h&&v.key==h.key&&v.type===h.type)w[m]=void 0;else for(g=0;g<C;g++){if((h=w[g])&&v.key==h.key&&v.type===h.type){w[g]=void 0;break}h=null}I(t,v,h=h||a,s,o,r,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(k||(k=[]),h.ref&&k.push(h.ref,null,v),k.push(g,v.__c||y,v)),null!=y?(null==P&&(P=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=N(t,v,h,w,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=P,m=C;m--;)null!=w[m]&&("function"==typeof n.type&&null!=w[m].__e&&w[m].__e==n.__d&&(n.__d=f(i,m+1)),E(w[m],w[m]));if(k)for(m=0;m<k.length;m++)A(k[m],k[++m],k[++m])}function b(t,e,n){for(var i,s=t.__k,o=0;s&&o<s.length;o++)(i=s[o])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):N(n,i,i,s,i.__e,e));return e}function P(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){P(t,e)})):e.push(t)),e}function N(t,e,n,i,s,o){var a,l,r;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||s!=o||null==s.parentNode)t:if(null==o||o.parentNode!==t)t.appendChild(s),a=null;else{for(l=o,r=0;(l=l.nextSibling)&&r<i.length;r+=2)if(l==s)break t;t.insertBefore(s,o),a=o}return void 0!==a?a:s.nextSibling}function k(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||r.test(e)?n:n+"px"}function w(t,e,n,i,s){var o;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||k(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||k(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])o=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i||t.addEventListener(e,o?x:C,o):t.removeEventListener(e,o?x:C,o);else if("dangerouslySetInnerHTML"!==e){if(s)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,s,o,a,l,r,u){var d,p,f,g,h,v,b,P,N,k,w,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,r=n.__e=i.__e,n.__h=null,a=[r]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(P=n.props,N=(d=I.contextType)&&s[d.__c],k=d?N?N.props.value:d.__:s,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(P,k):(n.__c=p=new m(P,k),p.constructor=I,p.render=L),N&&N.sub(p),p.props=P,p.state||(p.state={}),p.context=k,p.__n=s,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(P,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&P!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(P,k),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(P,p.__s,k)||n.__v===i.__v){p.props=P,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&l.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(P,p.__s,k),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=k,p.props=P,p.__v=n,p.__P=t,w=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,w&&w(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,w&&w(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(s=c(c({},s),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,s,o,a,l,r,u),p.base=n.__e,n.__h=null,p.__h.length&&l.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,s,o,a,l,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=r,n.__h=!!u,a[a.indexOf(r)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,s,o,l,r,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(o=!0),null!=l)for(;v<l.length;v++)if((d=l[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,l[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),l=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(l=l&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=l)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,s){var o;for(o in n)"children"===o||"key"===o||o in e||w(t,o,null,n[o],i);for(o in e)s&&"function"!=typeof e[o]||"children"===o||"key"===o||"value"===o||"checked"===o||n[o]===e[o]||w(t,o,e[o],n[o],i)}(e,g,m,o,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,s,o&&"foreignObject"!==h,l,r,l?l[0]:i.__k&&f(i,0),c),null!=l)for(v=l.length;v--;)null!=l[v]&&u(l[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&w(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&w(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var s,o;if(e.unmount&&e.unmount(t),(s=t.ref)&&(s.current&&s.current!==t.__e||A(s,null,n)),null!=(s=t.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(t){e.__e(t,n)}s.base=s.__P=null}if(s=t.__k)for(o=0;o<s.length;o++)s[o]&&E(s[o],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,s){var o,l,r;e.__&&e.__(n,i),l=(o="function"==typeof s)?null:s&&s.__k||i.__k,r=[],I(i,n=(!o&&s||i).__k=d(_,null,[n]),l||a,a,void 0!==i.ownerSVGElement,!o&&s?[s]:l?null:i.firstChild?t.call(i.childNodes):null,r,!o&&s?s:l?l.__e:i.firstChild,o),S(r,n)}t=l.slice,e={__e:function(t,e,n,i){for(var s,o,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&null!=o.getDerivedStateFromError&&(s.setState(o.getDerivedStateFromError(t)),a=s.__d),null!=s.componentDidCatch&&(s.componentDidCatch(t,i||{}),a=s.__d),a)return s.__E=s}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,o=0;var O,U,R,W,$=0,H=[],M=[],j=e.__b,B=e.__r,F=e.diffed,V=e.__c,q=e.unmount;function X(t,n){e.__h&&e.__h(U,t,$||n),$=0;var i=U.__H||(U.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:M}),i.__[t]}function K(t){return $=1,Q(ot,t)}function Q(t,e,n){var i=X(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):ot(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=U,!i.__c.u)){i.__c.__H.u=!0;var s=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var o=i.__c.__H.__.filter((function(t){return t.__c}));return(o.every((function(t){return!t.__N}))||!o.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!s||s(t,e,n))}}return i.__N||i.__}function G(t,n){var i=X(O++,3);!e.__s&&st(i.__H,n)&&(i.__=t,i.i=n,U.__H.__h.push(i))}function z(t){return $=5,J((function(){return{current:t}}),[])}function J(t,e){var n=X(O++,7);return st(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return $=8,J((function(){return t}),e)}function Z(t){var e=U.context[t.__c],n=X(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){U=null,j&&j(t)},e.__r=function(t){B&&B(t),O=0;var e=(U=t.__c).__H;e&&(R===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=M,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),R=U},e.diffed=function(t){F&&F(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&W===e.requestAnimationFrame||((W=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==M&&(t.__=t.__V),t.i=void 0,t.__V=M}))),R=U=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),V&&V(t,n)},e.unmount=function(t){q&&q(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=U,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),U=e}function it(t){var e=U;t.__c=t.__(),U=e}function st(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function ot(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},lt="ui/reset",rt="ui/error",ct="ui/editing",ut="ui/mode",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",Pt="list/setItems",Nt="list/removeItem",kt="list/addItem",wt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const s={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(s.body=JSON.stringify(n));const o=await fetch(Dt().root+i+e,s);o.headers.get("x-wp-nonce")&&(Dt().nonce=o.headers.get("x-wp-nonce"));const a=await o.json();return{data:a,headers:o.headers,status:o.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var s;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(s=t.data)||void 0===s?void 0:s.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){return It("DELETE","/"+t+"/items/"+e,{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Rt(){var t;return Object.values(null===(t=Dt())||void 0===t?void 0:t.statuses)}function Wt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function $t(t,e){return!!t.type&&Mt(t.type,e)}function Ht(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Mt(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Mt(t,e){const n=Ut(t);return!(!n||!n.supports)&&n.supports.includes(e)}const jt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Bt(t){return JSON.parse(JSON.stringify(t))}function Ft(t){return t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault(),!1}function Vt(t,e){const{type:n,payload:i}=e;let s=!1;const o=t=>(s=a({status:"failed"}),t.error&&(s.error=t.error.message?t.error.message:"",s.errorCode=t.error.code?t.error.code:""),s),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=Bt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(s[t]=e[t]);return s};let l=function(t,e){const{type:n,payload:i}=e;let s,o;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=!1===t?{}:Bt(t)),e)for(const t in e)o[t]=e[t];return o};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Bt(t.items),i;case _t:return i;case Pt:return a({items:i});case"list/addItem/failed":case kt:return null!=i&&i.list?a(i.list):t;case wt:const e=!!i.item&&i.item;return s=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:s});case Nt:if(1===t.items.length||!1===i)return t;if(o=a(),s=o.items.filter((t=>t.post_id!==i)),Mt(t.type,"sortable")){const e=parseInt(t.items[0].position,10);s.forEach(((t,n)=>{s[n].position=e+n}))}if(Mt(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(o.vote_counter=o.vote_counter-e.votes)}return{...o,items:s};case Ct:const n=parseInt(t.items[0].position,10);s=a().items.slice();const l=a().items[i.oldIndex];return s.splice(i.oldIndex,1),s.splice(i.newIndex,0,l),isNaN(n)?(alert("positions error!"),t):(s.forEach(((t,e)=>{s[e].position=n+e})),a({items:s}));default:return t}}(t.list,e),r=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case kt:case ht:return!1;case pt:return!1===i?t:Bt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===l&&r===t.listOfList||(s=a({listOfList:r,list:l}),t.addingPost||(s.title=s.list?s.list.title:Qt.title)),n){case ut:return a({mode:i});case lt:return{...Qt,mode:t.mode};case rt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case"ui/message":return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ct:return a({editing:i});case mt:return s=a(),s.addingPost=i,i&&(s.title="Add to..."),s;case _t:s=a(),s.title=i.title?i.title:Qt.title,s.listTotalPages=1,s.listPage=1,s.addingPost=!1;break;case kt:if(s=a(),null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(s.error=i.message,s.status="failed"),s.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return s=a(),s.status="loading",s.listOfList=!1,"object"==typeof i?(s.list=i,i.title&&(s.title=i.title)):s.list={ID:i},s;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/removeItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return s=a(),s.addingPost=!1,s.status="succeeded",s.error=!1,s.errorCode=!1,s.title=s.list?s.list.title:Qt.title,s;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return s=a({status:"failed"}),e.error&&e.error.message&&(s.error=e.error.message),s;case"list/addItem/failed":if(s=a(),s.addingPost=!1,s.title=s.list?s.list.title:Qt.title,null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(s.error=i.message,s.status="failed"),o(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return o(e)}return!1!==s?s:t}const qt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:s}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((s=n)&&"object"==typeof s&&!0===s.asyncThunk){let s={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,s)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var s;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Qt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},Gt=function(t,e){var n={__c:e="__cC"+o++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function zt(t){return new Date(t).toLocaleDateString()}const Jt=function(t){const{state:e,dispatch:n}=Z(Gt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){Ft(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",zt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",zt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Yt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var Zt,te,ee;ee={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(te="defaultProps")in(Zt=Yt)?Object.defineProperty(Zt,te,{value:ee,enumerable:!0,configurable:!0,writable:!0}):Zt[te]=ee;const ne=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},ie=()=>({type:lt,payload:null}),se=t=>({type:mt,payload:t}),oe=t=>({type:ct,payload:t}),ae=qt(xt,(async function(t,e){return await function(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}(t)})),le=qt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))})),re=qt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},s={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in s){const n=t.headers.get(e);n&&(i[s[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}const ue=qt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(le({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(le({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=qt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=qt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),he=qt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),ve=qt(Pt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=qt(Nt,(async function(t,e){const n=e.getState();return await Lt.quit(n.list.ID,t).then((i=>{if(1===n.list.items.length){const t=n.listPage,i=n.listTotalPages;return t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)})),!1}return t}))})),be=qt(kt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:"view"}).then((t=>{i=t.data}))}catch(t){var s;const n=null==t||null===(s=t.response)||void 0===s?void 0:s.data;i=e.rejectWithValue(n)}return i})),Pe=qt(wt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Ne=qt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],s=n.items[t],o=s.position-t+i;return await Lt.move(n.ID,s.post_id,o).then((e=>({oldIndex:t,newIndex:i})))})),ke=qt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),we=qt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(Gt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Yt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Yt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Yt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Jt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ne,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[s,o]=K(!1),[a,l]=K(""),r=z({});return G((()=>{l(t.item.description)}),[t.item]),G((()=>{s&&r.current.focus()}),[s]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!s&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!s&&d("button",{onClick:()=>{o(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:s?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){l(t.target.value)},maxLength:400}),s&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{o(!1),l(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),s&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{o(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var s,o=e;o=o.__;)if((s=o.__c)&&s.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),s.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function Ue(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Re(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var s=Ue(i.__v),o=!1,a=function(){o||(o=!0,n.__R=null,s?s(l):l())};n.__R=a;var l=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},r=!0===e.__h;i.__u++||r||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var s=e.__a&&d(_,null,t.fallback);return s&&(s.__h=null),[d(_,null,e.__a?null:t.children),s]};var We=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function $e(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d($e,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Re.prototype=new m).__a=function(t){var e=this,n=Ue(e.__v),i=e.o.get(t);return i[0]++,function(s){var o=function(){e.props.revealOrder?(i.push(s),We(e,t,i)):s()};n?n(o):o()}},Re.prototype.render=function(t){this.u=null,this.o=new Map;var e=P(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Re.prototype.componentDidUpdate=Re.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){We(t,n,e)}))};var Me="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,je=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Be="undefined"!=typeof document,Fe=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var Ve=e.event;function qe(){}function Xe(){return this.cancelBubble}function Ke(){return this.defaultPrevented}e.event=function(t){return Ve&&(t=Ve(t)),t.persist=qe,t.isPropagationStopped=Xe,t.isDefaultPrevented=Ke,t.nativeEvent=t};var Qe={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var s=-1===e.indexOf("-");for(var o in i={},n){var a=n[o];Be&&"children"===o&&"noscript"===e||"value"===o&&"defaultValue"in n&&null==a||("defaultValue"===o&&"value"in n&&null==n.value?o="value":"download"===o&&!0===a?a="":/ondoubleclick/i.test(o)?o="ondblclick":/^onchange(textarea|input)/i.test(o+e)&&!Fe(n.type)?o="oninput":/^onfocus$/i.test(o)?o="onfocusin":/^onblur$/i.test(o)?o="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(o)?o=o.toLowerCase():s&&je.test(o)?o=o.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(o)&&(o=o.toLowerCase(),i[o]&&(o="oninputCapture")),i[o]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=P(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=P(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Qe.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Qe))}t.$$typeof=Me,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));(t=>{const e=(()=>{const[t,e]=K(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=K(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),s=t.role||"dialog",o="alertdialog"===s,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:s,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:o?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:s}=t;if(G((()=>(n&&s(n),()=>s(void 0))),[s,n]),!e)return null;const o=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),l=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),r=["first"===t.closeButtonPosition&&l,a,t.children,"last"===t.closeButtonPosition&&l].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),r)),o)}).defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}};const nn=function(t){var e;const[n,i]=K(""),[s,o]=K(""),[a,l]=K(""),[r,c]=K(""),u=J((()=>Ht(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),l(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),o(t.list.content),l(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=Ut(a))&&void 0!==t&&t.available_statuses&&-1===Ut(a).available_statuses.indexOf(r)&&c(Ut(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Mt(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Mt(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:s,onChange:function(t){o(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==s?void 0:s.length),"/500")),""!==a&&!Ut(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=Ut(a))||void 0===e?void 0:e.available_statuses)&&Ut(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:r,onChange:function(t){c(t.target.value)}},Ut(a).available_statuses.map(((t,e)=>{if(function(t){const e=Wt(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Wt(t);return e?e.label:t}(t))})))),""!==a&&Ut(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:s,type:a,status:r})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=K(!1),[s,o]=K(""),[a,l]=K(null===(e=t.item)||void 0===e?void 0:e.quantity),r=z({});G((()=>{o(t.item.description)}),[t.item]),G((()=>{n&&r.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return $t(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&$t(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===s&&d("span",null,at("Add Comment")),""!==s&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:s,onChange:function(t){o(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),o(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(s)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&$t(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){l(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},on=function(t){return new Promise((function(e,n){const i=document.createElement("script");let s=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){s||this.readyState&&"complete"!=this.readyState||(s=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},an=function(t){var e,n,i;const s=z(null),o=z((e=>{t.onMove(e)}));return G((()=>{o.current=t.onMove})),G((()=>{let e=!1;if($t(t.list,"sortable")){const t=()=>{e=Sortable.create(s.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){o.current(t)}})};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Yt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Yt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Yt,{count:2})))))),d("ul",{ref:s,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),$t(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},ln=function(t){const e=z(null),n=z(null),i=at("Copy"),[s,o]=K(i);G((()=>{let t=null;s!==i&&(t=setTimeout((()=>{o(i),clearTimeout(t)}),2e3))}),[s]);const a=encodeURIComponent(t.link),l=encodeURIComponent(t.title);let r=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+l},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+l},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+l},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+l},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+l},{slug:"email",name:at("Email"),url:"mailto:?subject="+l+"&body="+a}];return void 0!==Dt().shareButtons&&(r=r.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?o(at("Copied!")):o("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,s)),r.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},rn=function(t){var e;const{state:n,dispatch:i}=Z(Gt),[s,o]=K(!1),a=z(!1),l=z(!1);function r(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,s=!1;if(t&&$t(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}})),a.current&&n.listPage>1&&(s=Sortable.create(l.current,{group:"shared",onAdd:t=>{i(we(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),s&&s.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{o(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(nn,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const s={};s.title=t.title,s.content=t.content,s.type=t.type,s.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(s.adding=n.addingPost.post_id),i(he(s))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(oe(!1)),-1===n.list.ID&&(i(fe(!1)),i(ie()),i(le()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Mt(i,"editable_title")||Mt(i,"editable_content")||(null===(e=Ut(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(oe(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>o(!s)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(ae(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),s&&n.list.link&&d(ln,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:(c=n.list.content,"string"!=typeof c?"":c.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2"))}}),d(Yt,{count:3}),d(an,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Ne(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(Pe(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(Pe(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ne,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){r(n.listPage-1)},onNext:function(){r(n.listPage+1)},prevRef:l,nextRef:a}));var c};D(d((t=>{const[e,n]=Q(Vt,Qt);return d(Gt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(Gt),[n,i]=K("any"),[s,o]=K("any"),[a,l]=K(""),[r,c]=K(null),u=z(!1),p=J((()=>Ht(t.addingPost)),[t.addingPost]),m=J((()=>{return Object.values(null===(t=Dt())||void 0===t?void 0:t.types);var t}),[]);let f="listOfList";if(t.addingPost)f=t.editing?"addingToNew":"adding";else if(t.editing){var g;f=-1!==(null===(g=t.list)||void 0===g?void 0:g.ID)?"edit":"new"}else f=t.list?"list":"listOfList";G((()=>{window.showMainLists=function(){e(ie()),h()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e(ie()),n||P(t)}}),[e]);const h=()=>{const i={};n&&(i.types=n),s&&(i.status=s),r&&(i.search=r),a&&(i.author=a),t.page>1&&(i.page=t.page),e(re(i))};function v(){t.page>1&&e(de(1))}function y(t){v(),i(t)}function b(t){v(),o(t)}G((()=>{Qt.title="",e({type:ut,payload:"admin"});const t=function(t){const n=parseInt(("author",new URLSearchParams(document.location.hash.substring(1)).get("author")),10);n>0&&n!==a&&(t&&Ft(t),e(de(1)),l(n),location.hash="")};return t(0),window.addEventListener("hashchange",t,!1),()=>{window.removeEventListener("hashchange",t)}}),[]),G((()=>{t.list||h()}),[n,s,a,t.page]),G((()=>{null!=r&&(clearTimeout(u.current),u.current=setTimeout((function(){h()}),300))}),[r]);const P=t=>{e(se({post_id:t})),e(le({addingPost:t}))};function N(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const k=d("h2",{key:"title"},("list"===f||"new"===f||"edit"===f||"addingToNew"===f)&&d("a",{"aria-label":"Back",className:"mg-upc-dg-back",href:"#",onClick:n=>{n.preventDefault(),function(){switch(f){case"list":e(fe(!1)),h();break;case"new":e(fe(!1)),e(oe(!1)),h();break;case"edit":e(oe(!1));break;case"addingToNew":e(fe(!1)),e(oe(!1)),e(le({addingPost:t.addingPost.post_id}));break;default:h()}}()}},"←")," ",t.title);return d(_,null,k,d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+f},d("div",{className:"mg-upc-dg-wait"}),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:rt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===f||"adding"===f)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},p.length>0&&d("button",{className:"mg-list-new",onClick:function(t){e(oe(!0)),e(fe(!0))}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Types"))),d("li",{className:"any"==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",onClick:()=>y("any"),onKeyPress:t=>{13===t.keyCode&&y("any")},tabIndex:"0"},d("i",{className:"mg-upc-icon upc-font-close mg-upc-dg-item-type mg-upc-dg-item-type-none"}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),m.map(((t,e)=>d("li",{className:t.name==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",key:t.name,onClick:()=>y(t.name),onKeyPress:e=>{13===e.keyCode&&y(t.name)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label)))))),Rt()&&d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Status"))),d("li",{className:"any"==s?"mg-upc-selected":"",onClick:()=>b("any"),onKeyPress:t=>{13===t.keyCode&&b("any")},tabIndex:"0"},d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),Rt().map(((t,e)=>d("li",{className:t.name==s?"mg-upc-selected":"",key:t.name,onClick:()=>b(t.name),onKeyPress:e=>{13===e.keyCode&&b(t.name)},tabIndex:"0"},t.label)))),d("div",{className:"mg-upc-dg-df"},d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Search"))),d("input",{onChange:function(t){v(),c(t.target.value)},value:r})),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Author (ID)"))),d("input",{type:"number",onChange:function(t){v(),l(t.target.value)},value:a}))),d(xe,{lists:t.listOfList,onSelect:function(n){e(oe(!1)),t.addingPost?e(be(n.ID,t.addingPost)):e(fe(n))},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){N(t.page-1)},loadNext:function(){N(t.page+1)}})),t.list&&d(rn,{editable:(t.list,!0)}))))}),null)," "),document.getElementById("mg-upc-admin-app")),setTimeout(window.showMainLists,1e3)})();1 (()=>{"use strict";var t,e,n,i,s,o,a={},l=[],r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var s,o,a,l={};for(a in n)"key"==a?s=n[a]:"ref"==a?o=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return p(e,l,s,o,null)}function p(t,i,s,o,a){var l={type:t,props:i,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(l),l}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||s!==e.debounceRendering)&&((s=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,s,o,a;t.__d&&(o=(s=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},s)).__v=s.__v+1,I(a,s,i,e.__n,void 0!==a.ownerSVGElement,null!=s.__h?[o]:null,n,null==o?f(s):o,s.__h),S(n,s),s.__e!=o&&g(s)))}))}function y(t,e,n,i,s,o,r,c,u,d){var m,g,h,v,y,P,w,k=i&&i.__k||l,C=k.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=k[m])||h&&v.key==h.key&&v.type===h.type)k[m]=void 0;else for(g=0;g<C;g++){if((h=k[g])&&v.key==h.key&&v.type===h.type){k[g]=void 0;break}h=null}I(t,v,h=h||a,s,o,r,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(w||(w=[]),h.ref&&w.push(h.ref,null,v),w.push(g,v.__c||y,v)),null!=y?(null==P&&(P=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=N(t,v,h,k,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=P,m=C;m--;)null!=k[m]&&("function"==typeof n.type&&null!=k[m].__e&&k[m].__e==n.__d&&(n.__d=f(i,m+1)),E(k[m],k[m]));if(w)for(m=0;m<w.length;m++)A(w[m],w[++m],w[++m])}function b(t,e,n){for(var i,s=t.__k,o=0;s&&o<s.length;o++)(i=s[o])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):N(n,i,i,s,i.__e,e));return e}function P(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){P(t,e)})):e.push(t)),e}function N(t,e,n,i,s,o){var a,l,r;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||s!=o||null==s.parentNode)t:if(null==o||o.parentNode!==t)t.appendChild(s),a=null;else{for(l=o,r=0;(l=l.nextSibling)&&r<i.length;r+=2)if(l==s)break t;t.insertBefore(s,o),a=o}return void 0!==a?a:s.nextSibling}function w(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||r.test(e)?n:n+"px"}function k(t,e,n,i,s){var o;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||w(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||w(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])o=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i||t.addEventListener(e,o?x:C,o):t.removeEventListener(e,o?x:C,o);else if("dangerouslySetInnerHTML"!==e){if(s)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,s,o,a,l,r,u){var d,p,f,g,h,v,b,P,N,w,k,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,r=n.__e=i.__e,n.__h=null,a=[r]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(P=n.props,N=(d=I.contextType)&&s[d.__c],w=d?N?N.props.value:d.__:s,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(P,w):(n.__c=p=new m(P,w),p.constructor=I,p.render=L),N&&N.sub(p),p.props=P,p.state||(p.state={}),p.context=w,p.__n=s,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(P,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&P!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(P,w),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(P,p.__s,w)||n.__v===i.__v){p.props=P,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&l.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(P,p.__s,w),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=w,p.props=P,p.__v=n,p.__P=t,k=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(s=c(c({},s),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,s,o,a,l,r,u),p.base=n.__e,n.__h=null,p.__h.length&&l.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,s,o,a,l,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=r,n.__h=!!u,a[a.indexOf(r)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,s,o,l,r,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(o=!0),null!=l)for(;v<l.length;v++)if((d=l[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,l[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),l=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(l=l&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=l)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,s){var o;for(o in n)"children"===o||"key"===o||o in e||k(t,o,null,n[o],i);for(o in e)s&&"function"!=typeof e[o]||"children"===o||"key"===o||"value"===o||"checked"===o||n[o]===e[o]||k(t,o,e[o],n[o],i)}(e,g,m,o,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,s,o&&"foreignObject"!==h,l,r,l?l[0]:i.__k&&f(i,0),c),null!=l)for(v=l.length;v--;)null!=l[v]&&u(l[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&k(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&k(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var s,o;if(e.unmount&&e.unmount(t),(s=t.ref)&&(s.current&&s.current!==t.__e||A(s,null,n)),null!=(s=t.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(t){e.__e(t,n)}s.base=s.__P=null}if(s=t.__k)for(o=0;o<s.length;o++)s[o]&&E(s[o],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,s){var o,l,r;e.__&&e.__(n,i),l=(o="function"==typeof s)?null:s&&s.__k||i.__k,r=[],I(i,n=(!o&&s||i).__k=d(_,null,[n]),l||a,a,void 0!==i.ownerSVGElement,!o&&s?[s]:l?null:i.firstChild?t.call(i.childNodes):null,r,!o&&s?s:l?l.__e:i.firstChild,o),S(r,n)}t=l.slice,e={__e:function(t,e,n,i){for(var s,o,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&null!=o.getDerivedStateFromError&&(s.setState(o.getDerivedStateFromError(t)),a=s.__d),null!=s.componentDidCatch&&(s.componentDidCatch(t,i||{}),a=s.__d),a)return s.__E=s}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,o=0;var O,U,R,W,$=0,H=[],M=[],j=e.__b,B=e.__r,F=e.diffed,V=e.__c,q=e.unmount;function X(t,n){e.__h&&e.__h(U,t,$||n),$=0;var i=U.__H||(U.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:M}),i.__[t]}function K(t){return $=1,Q(ot,t)}function Q(t,e,n){var i=X(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):ot(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=U,!i.__c.u)){i.__c.__H.u=!0;var s=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var o=i.__c.__H.__.filter((function(t){return t.__c}));return(o.every((function(t){return!t.__N}))||!o.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!s||s(t,e,n))}}return i.__N||i.__}function G(t,n){var i=X(O++,3);!e.__s&&st(i.__H,n)&&(i.__=t,i.i=n,U.__H.__h.push(i))}function z(t){return $=5,J((function(){return{current:t}}),[])}function J(t,e){var n=X(O++,7);return st(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return $=8,J((function(){return t}),e)}function Z(t){var e=U.context[t.__c],n=X(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){U=null,j&&j(t)},e.__r=function(t){B&&B(t),O=0;var e=(U=t.__c).__H;e&&(R===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=M,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),R=U},e.diffed=function(t){F&&F(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&W===e.requestAnimationFrame||((W=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==M&&(t.__=t.__V),t.i=void 0,t.__V=M}))),R=U=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),V&&V(t,n)},e.unmount=function(t){q&&q(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=U,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),U=e}function it(t){var e=U;t.__c=t.__(),U=e}function st(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function ot(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},lt="ui/reset",rt="ui/error",ct="ui/editing",ut="ui/mode",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",Pt="list/setItems",Nt="list/removeItem",wt="list/addItem",kt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const s={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(s.body=JSON.stringify(n));const o=await fetch(Dt().root+i+e,s);o.headers.get("x-wp-nonce")&&(Dt().nonce=o.headers.get("x-wp-nonce"));const a=await o.json();return{data:a,headers:o.headers,status:o.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var s;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(s=t.data)||void 0===s?void 0:s.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("DELETE","/"+t+"/items/"+e+St(n),{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Rt(){var t;return Object.values(null===(t=Dt())||void 0===t?void 0:t.statuses)}function Wt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function $t(t,e){return!!t.type&&Mt(t.type,e)}function Ht(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Mt(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Mt(t,e){const n=Ut(t);return!(!n||!n.supports)&&n.supports.includes(e)}const jt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Bt(t){return JSON.parse(JSON.stringify(t))}function Ft(t){return t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault(),!1}function Vt(t,e){const{type:n,payload:i}=e;let s=!1;const o=t=>(s=a({status:"failed"}),t.error&&(s.error=t.error.message?t.error.message:"",s.errorCode=t.error.code?t.error.code:""),s),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=Bt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(s[t]=e[t]);return s};let l=function(t,e){const{type:n,payload:i}=e;let s,o;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=!1===t?{}:Bt(t)),e)for(const t in e)o[t]=e[t];return o};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Bt(t.items),i;case _t:return i;case Pt:return a({items:i});case"list/addItem/failed":case wt:return null!=i&&i.list?a(i.list):t;case kt:const e=!!i.item&&i.item;return s=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:s});case Nt:if(!t.items||1===t.items.length||!1===i)return t;if(o=a(),s=o.items.filter((t=>t.post_id!==i)),Mt(t.type,"sortable")){const e=parseInt(t.items[0].position,10);s.forEach(((t,n)=>{s[n].position=e+n}))}if(Mt(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(o.vote_counter=o.vote_counter-e.votes)}return{...o,items:s};case Ct:const n=parseInt(t.items[0].position,10);s=a().items.slice();const l=a().items[i.oldIndex];return s.splice(i.oldIndex,1),s.splice(i.newIndex,0,l),isNaN(n)?(alert("positions error!"),t):(s.forEach(((t,e)=>{s[e].position=n+e})),a({items:s}));default:return t}}(t.list,e),r=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case wt:case ht:return!1;case pt:return!1===i?t:Bt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===l&&r===t.listOfList||(s=a({listOfList:r,list:l}),t.addingPost||(s.title=s.list?s.list.title:Qt.title)),n){case ut:return a({mode:i});case lt:return{...Qt,mode:t.mode};case rt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case"ui/message":return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ct:return a({editing:i});case mt:return s=a(),s.addingPost=i,i&&(s.title="Add to..."),s;case _t:s=a(),s.title=i.title?i.title:Qt.title,s.listTotalPages=1,s.listPage=1,s.addingPost=!1;break;case wt:if(s=a(),null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(s.error=i.message,s.status="failed"),s.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return s=a(),s.status="loading",s.listOfList=!1,"object"==typeof i?(s.list=i,i.title&&(s.title=i.title)):s.list={ID:i},s;case"list/removeItem/loading":return s=a({status:"loading"}),"object"==typeof i&&i.list_id&&(s.list={ID:i.list_id}),s;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return s=a(),s.addingPost=!1,s.status="succeeded",s.error=!1,s.errorCode=!1,s.title=s.list?s.list.title:Qt.title,s;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return s=a({status:"failed"}),e.error&&e.error.message&&(s.error=e.error.message),s;case"list/addItem/failed":if(s=a(),s.addingPost=!1,s.title=s.list?s.list.title:Qt.title,null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(s.error=i.message,s.status="failed"),o(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return o(e)}return!1!==s?s:t}const qt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:s}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((s=n)&&"object"==typeof s&&!0===s.asyncThunk){let s={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,s)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var s;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Qt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},Gt=function(t,e){var n={__c:e="__cC"+o++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function zt(t){return new Date(t).toLocaleDateString()}const Jt=function(t){const{state:e,dispatch:n}=Z(Gt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){Ft(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",zt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",zt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Yt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var Zt,te,ee;ee={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(te="defaultProps")in(Zt=Yt)?Object.defineProperty(Zt,te,{value:ee,enumerable:!0,configurable:!0,writable:!0}):Zt[te]=ee;const ne=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},ie=()=>({type:lt,payload:null}),se=t=>({type:mt,payload:t}),oe=t=>({type:ct,payload:t}),ae=qt(xt,(async function(t,e){return await function(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}(t)})),le=qt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))})),re=qt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},s={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in s){const n=t.headers.get(e);n&&(i[s[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}const ue=qt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(le({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(le({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=qt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=qt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),he=qt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),ve=qt(Pt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=qt(Nt,(async function(t,e){const n=e.getState();var i=e.extra.length>0?e.extra[0]:n.list.ID;const s=e.extra.length>1?e.extra[1]:"view";return await Lt.quit(i,t,{context:s}).then((o=>{if(o.data&&o.data.list_id,n.list&&n.list.ID){if(1===n.list.items.length){if(e.dispatch(ve({page})),n.list&&"view"===s){const t=n.listPage,i=n.listTotalPages;t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)}))}return!1}}else e.dispatch(fe({ID:i}));return t}))})),be=qt(wt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:e.extra.length>1?e.extra[1]:"view"}).then((t=>{i=t.data}))}catch(t){var s;const n=null==t||null===(s=t.response)||void 0===s?void 0:s.data;i=e.rejectWithValue(n)}return i})),Pe=qt(kt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Ne=qt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],s=n.items[t],o=s.position-t+i;return await Lt.move(n.ID,s.post_id,o).then((e=>({oldIndex:t,newIndex:i})))})),we=qt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),ke=qt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(Gt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Yt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Yt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Yt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Jt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ne,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[s,o]=K(!1),[a,l]=K(""),r=z({});return G((()=>{l(t.item.description)}),[t.item]),G((()=>{s&&r.current.focus()}),[s]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!s&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!s&&d("button",{onClick:()=>{o(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:s?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){l(t.target.value)},maxLength:400}),s&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{o(!1),l(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),s&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{o(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var s,o=e;o=o.__;)if((s=o.__c)&&s.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),s.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function Ue(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Re(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var s=Ue(i.__v),o=!1,a=function(){o||(o=!0,n.__R=null,s?s(l):l())};n.__R=a;var l=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},r=!0===e.__h;i.__u++||r||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var s=e.__a&&d(_,null,t.fallback);return s&&(s.__h=null),[d(_,null,e.__a?null:t.children),s]};var We=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function $e(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d($e,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Re.prototype=new m).__a=function(t){var e=this,n=Ue(e.__v),i=e.o.get(t);return i[0]++,function(s){var o=function(){e.props.revealOrder?(i.push(s),We(e,t,i)):s()};n?n(o):o()}},Re.prototype.render=function(t){this.u=null,this.o=new Map;var e=P(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Re.prototype.componentDidUpdate=Re.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){We(t,n,e)}))};var Me="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,je=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Be="undefined"!=typeof document,Fe=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var Ve=e.event;function qe(){}function Xe(){return this.cancelBubble}function Ke(){return this.defaultPrevented}e.event=function(t){return Ve&&(t=Ve(t)),t.persist=qe,t.isPropagationStopped=Xe,t.isDefaultPrevented=Ke,t.nativeEvent=t};var Qe={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var s=-1===e.indexOf("-");for(var o in i={},n){var a=n[o];Be&&"children"===o&&"noscript"===e||"value"===o&&"defaultValue"in n&&null==a||("defaultValue"===o&&"value"in n&&null==n.value?o="value":"download"===o&&!0===a?a="":/ondoubleclick/i.test(o)?o="ondblclick":/^onchange(textarea|input)/i.test(o+e)&&!Fe(n.type)?o="oninput":/^onfocus$/i.test(o)?o="onfocusin":/^onblur$/i.test(o)?o="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(o)?o=o.toLowerCase():s&&je.test(o)?o=o.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(o)&&(o=o.toLowerCase(),i[o]&&(o="oninputCapture")),i[o]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=P(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=P(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Qe.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Qe))}t.$$typeof=Me,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));(t=>{const e=(()=>{const[t,e]=K(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=K(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),s=t.role||"dialog",o="alertdialog"===s,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:s,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:o?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:s}=t;if(G((()=>(n&&s(n),()=>s(void 0))),[s,n]),!e)return null;const o=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),l=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),r=["first"===t.closeButtonPosition&&l,a,t.children,"last"===t.closeButtonPosition&&l].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),r)),o)}).defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}};const nn=function(t){var e;const[n,i]=K(""),[s,o]=K(""),[a,l]=K(""),[r,c]=K(""),u=J((()=>Ht(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),l(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),o(t.list.content),l(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=Ut(a))&&void 0!==t&&t.available_statuses&&-1===Ut(a).available_statuses.indexOf(r)&&c(Ut(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Mt(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Mt(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:s,onChange:function(t){o(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==s?void 0:s.length),"/500")),""!==a&&!Ut(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=Ut(a))||void 0===e?void 0:e.available_statuses)&&Ut(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:r,onChange:function(t){c(t.target.value)}},Ut(a).available_statuses.map(((t,e)=>{if(function(t){const e=Wt(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Wt(t);return e?e.label:t}(t))})))),""!==a&&Ut(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:s,type:a,status:r})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=K(!1),[s,o]=K(""),[a,l]=K(null===(e=t.item)||void 0===e?void 0:e.quantity),r=z({});G((()=>{o(t.item.description)}),[t.item]),G((()=>{n&&r.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return $t(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&$t(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===s&&d("span",null,at("Add Comment")),""!==s&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:s,onChange:function(t){o(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),o(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(s)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&$t(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){l(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},on=function(t){return new Promise((function(e,n){const i=document.createElement("script");let s=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){s||this.readyState&&"complete"!=this.readyState||(s=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},an=function(t){var e,n,i;const s=z(null),o=z((e=>{t.onMove(e)}));return G((()=>{o.current=t.onMove})),G((()=>{let e=!1;if($t(t.list,"sortable")){const t=()=>{e=Sortable.create(s.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){o.current(t)}})};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Yt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Yt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Yt,{count:2})))))),d("ul",{ref:s,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),$t(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},ln=function(t){const e=z(null),n=z(null),i=at("Copy"),[s,o]=K(i);G((()=>{let t=null;s!==i&&(t=setTimeout((()=>{o(i),clearTimeout(t)}),2e3))}),[s]);const a=encodeURIComponent(t.link),l=encodeURIComponent(t.title);let r=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+l},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+l},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+l},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+l},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+l},{slug:"email",name:at("Email"),url:"mailto:?subject="+l+"&body="+a}];return void 0!==Dt().shareButtons&&(r=r.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?o(at("Copied!")):o("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,s)),r.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},rn=function(t){var e;const{state:n,dispatch:i}=Z(Gt),[s,o]=K(!1),a=z(!1),l=z(!1);function r(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,s=!1;if(t&&$t(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(we(t.oldIndex))}})),a.current&&n.listPage>1&&(s=Sortable.create(l.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),s&&s.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{o(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(nn,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const s={};s.title=t.title,s.content=t.content,s.type=t.type,s.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(s.adding=n.addingPost.post_id),i(he(s))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(oe(!1)),-1===n.list.ID&&(i(fe(!1)),i(ie()),i(le()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Mt(i,"editable_title")||Mt(i,"editable_content")||(null===(e=Ut(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(oe(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>o(!s)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(ae(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),s&&n.list.link&&d(ln,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:(c=n.list.content,"string"!=typeof c?"":c.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2"))}}),d(Yt,{count:3}),d(an,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Ne(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(Pe(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(Pe(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ne,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){r(n.listPage-1)},onNext:function(){r(n.listPage+1)},prevRef:l,nextRef:a}));var c};D(d((t=>{const[e,n]=Q(Vt,Qt);return d(Gt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(Gt),[n,i]=K("any"),[s,o]=K("any"),[a,l]=K(""),[r,c]=K(null),u=z(!1),p=J((()=>Ht(t.addingPost)),[t.addingPost]),m=J((()=>{return Object.values(null===(t=Dt())||void 0===t?void 0:t.types);var t}),[]);let f="listOfList";if(t.addingPost)f=t.editing?"addingToNew":"adding";else if(t.editing){var g;f=-1!==(null===(g=t.list)||void 0===g?void 0:g.ID)?"edit":"new"}else f=t.list?"list":"listOfList";G((()=>{window.showMainLists=function(){e(ie()),h()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e(ie()),n||P(t)}}),[e]);const h=()=>{const i={};n&&(i.types=n),s&&(i.status=s),r&&(i.search=r),a&&(i.author=a),t.page>1&&(i.page=t.page),e(re(i))};function v(){t.page>1&&e(de(1))}function y(t){v(),i(t)}function b(t){v(),o(t)}G((()=>{Qt.title="",e({type:ut,payload:"admin"});const t=function(t){const n=parseInt(("author",new URLSearchParams(document.location.hash.substring(1)).get("author")),10);n>0&&n!==a&&(t&&Ft(t),e(de(1)),l(n),location.hash="")};return t(0),window.addEventListener("hashchange",t,!1),()=>{window.removeEventListener("hashchange",t)}}),[]),G((()=>{t.list||h()}),[n,s,a,t.page]),G((()=>{null!=r&&(clearTimeout(u.current),u.current=setTimeout((function(){h()}),300))}),[r]);const P=t=>{e(se({post_id:t})),e(le({addingPost:t}))};function N(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const w=d("h2",{key:"title"},("list"===f||"new"===f||"edit"===f||"addingToNew"===f)&&d("a",{"aria-label":"Back",className:"mg-upc-dg-back",href:"#",onClick:n=>{n.preventDefault(),function(){switch(f){case"list":e(fe(!1)),h();break;case"new":e(fe(!1)),e(oe(!1)),h();break;case"edit":e(oe(!1));break;case"addingToNew":e(fe(!1)),e(oe(!1)),e(le({addingPost:t.addingPost.post_id}));break;default:h()}}()}},"←")," ",t.title);return d(_,null,w,d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+f},d("div",{className:"mg-upc-dg-wait"}),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:rt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===f||"adding"===f)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},p.length>0&&d("button",{className:"mg-list-new",onClick:function(t){e(oe(!0)),e(fe(!0))}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Types"))),d("li",{className:"any"==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",onClick:()=>y("any"),onKeyPress:t=>{13===t.keyCode&&y("any")},tabIndex:"0"},d("i",{className:"mg-upc-icon upc-font-close mg-upc-dg-item-type mg-upc-dg-item-type-none"}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),m.map(((t,e)=>d("li",{className:t.name==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",key:t.name,onClick:()=>y(t.name),onKeyPress:e=>{13===e.keyCode&&y(t.name)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label)))))),Rt()&&d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Status"))),d("li",{className:"any"==s?"mg-upc-selected":"",onClick:()=>b("any"),onKeyPress:t=>{13===t.keyCode&&b("any")},tabIndex:"0"},d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),Rt().map(((t,e)=>d("li",{className:t.name==s?"mg-upc-selected":"",key:t.name,onClick:()=>b(t.name),onKeyPress:e=>{13===e.keyCode&&b(t.name)},tabIndex:"0"},t.label)))),d("div",{className:"mg-upc-dg-df"},d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Search"))),d("input",{onChange:function(t){v(),c(t.target.value)},value:r})),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Author (ID)"))),d("input",{type:"number",onChange:function(t){v(),l(t.target.value)},value:a}))),d(xe,{lists:t.listOfList,onSelect:function(n){e(oe(!1)),t.addingPost?e(be(n.ID,t.addingPost)):e(fe(n))},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){N(t.page-1)},loadNext:function(){N(t.page+1)}})),t.list&&d(rn,{editable:(t.list,!0)}))))}),null)," "),document.getElementById("mg-upc-admin-app")),setTimeout(window.showMainLists,1e3)})(); -
user-post-collections/tags/0.8.30/javascript/mg-upc-client/dist/main.js
r2770186 r2783097 1 (()=>{"use strict";var t,e,n,i,o,s,a={}, l=[],r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var o,s,a,l={};for(a in n)"key"==a?o=n[a]:"ref"==a?s=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return p(e,l,o,s,null)}function p(t,i,o,s,a){var l={type:t,props:i,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(l),l}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||o!==e.debounceRendering)&&((o=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,o,s,a;t.__d&&(s=(o=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},o)).__v=o.__v+1,I(a,o,i,e.__n,void 0!==a.ownerSVGElement,null!=o.__h?[s]:null,n,null==s?f(o):s,o.__h),S(n,o),o.__e!=s&&g(o)))}))}function y(t,e,n,i,o,s,r,c,u,d){var m,g,h,v,y,w,N,k=i&&i.__k||l,C=k.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=k[m])||h&&v.key==h.key&&v.type===h.type)k[m]=void 0;else for(g=0;g<C;g++){if((h=k[g])&&v.key==h.key&&v.type===h.type){k[g]=void 0;break}h=null}I(t,v,h=h||a,o,s,r,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(N||(N=[]),h.ref&&N.push(h.ref,null,v),N.push(g,v.__c||y,v)),null!=y?(null==w&&(w=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=P(t,v,h,k,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=w,m=C;m--;)null!=k[m]&&("function"==typeof n.type&&null!=k[m].__e&&k[m].__e==n.__d&&(n.__d=f(i,m+1)),E(k[m],k[m]));if(N)for(m=0;m<N.length;m++)A(N[m],N[++m],N[++m])}function b(t,e,n){for(var i,o=t.__k,s=0;o&&s<o.length;s++)(i=o[s])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):P(n,i,i,o,i.__e,e));return e}function w(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){w(t,e)})):e.push(t)),e}function P(t,e,n,i,o,s){var a,l,r;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||o!=s||null==o.parentNode)t:if(null==s||s.parentNode!==t)t.appendChild(o),a=null;else{for(l=s,r=0;(l=l.nextSibling)&&r<i.length;r+=2)if(l==o)break t;t.insertBefore(o,s),a=s}return void 0!==a?a:o.nextSibling}function N(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||r.test(e)?n:n+"px"}function k(t,e,n,i,o){var s;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||N(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||N(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])s=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?i||t.addEventListener(e,s?x:C,s):t.removeEventListener(e,s?x:C,s);else if("dangerouslySetInnerHTML"!==e){if(o)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,o,s,a,l,r,u){var d,p,f,g,h,v,b,w,P,N,k,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,r=n.__e=i.__e,n.__h=null,a=[r]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(w=n.props,P=(d=I.contextType)&&o[d.__c],N=d?P?P.props.value:d.__:o,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(w,N):(n.__c=p=new m(w,N),p.constructor=I,p.render=L),P&&P.sub(p),p.props=w,p.state||(p.state={}),p.context=N,p.__n=o,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(w,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&w!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,N),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,N)||n.__v===i.__v){p.props=w,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&l.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,N),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=N,p.props=w,p.__v=n,p.__P=t,k=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(o=c(c({},o),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,o,s,a,l,r,u),p.base=n.__e,n.__h=null,p.__h.length&&l.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,o,s,a,l,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=r,n.__h=!!u,a[a.indexOf(r)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,o,s,l,r,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(s=!0),null!=l)for(;v<l.length;v++)if((d=l[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,l[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=s?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),l=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(l=l&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=l)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,o){var s;for(s in n)"children"===s||"key"===s||s in e||k(t,s,null,n[s],i);for(s in e)o&&"function"!=typeof e[s]||"children"===s||"key"===s||"value"===s||"checked"===s||n[s]===e[s]||k(t,s,e[s],n[s],i)}(e,g,m,s,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,o,s&&"foreignObject"!==h,l,r,l?l[0]:i.__k&&f(i,0),c),null!=l)for(v=l.length;v--;)null!=l[v]&&u(l[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&k(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&k(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var o,s;if(e.unmount&&e.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||A(o,null,n)),null!=(o=t.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(t){e.__e(t,n)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&E(o[s],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,o){var s,l,r;e.__&&e.__(n,i),l=(s="function"==typeof o)?null:o&&o.__k||i.__k,r=[],I(i,n=(!s&&o||i).__k=d(_,null,[n]),l||a,a,void 0!==i.ownerSVGElement,!s&&o?[o]:l?null:i.firstChild?t.call(i.childNodes):null,r,!s&&o?o:l?l.__e:i.firstChild,s),S(r,n)}t=l.slice,e={__e:function(t,e,n,i){for(var o,s,a;e=e.__;)if((o=e.__c)&&!o.__)try{if((s=o.constructor)&&null!=s.getDerivedStateFromError&&(o.setState(s.getDerivedStateFromError(t)),a=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(t,i||{}),a=o.__d),a)return o.__E=o}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,s=0;var O,U,R,W,j=0,H=[],$=[],M=e.__b,B=e.__r,F=e.diffed,q=e.__c,V=e.unmount;function Q(t,n){e.__h&&e.__h(U,t,j||n),j=0;var i=U.__H||(U.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:$}),i.__[t]}function X(t){return j=1,K(st,t)}function K(t,e,n){var i=Q(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):st(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=U,!i.__c.u)){i.__c.__H.u=!0;var o=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var s=i.__c.__H.__.filter((function(t){return t.__c}));return(s.every((function(t){return!t.__N}))||!s.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!o||o(t,e,n))}}return i.__N||i.__}function G(t,n){var i=Q(O++,3);!e.__s&&ot(i.__H,n)&&(i.__=t,i.i=n,U.__H.__h.push(i))}function z(t){return j=5,J((function(){return{current:t}}),[])}function J(t,e){var n=Q(O++,7);return ot(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return j=8,J((function(){return t}),e)}function Z(t){var e=U.context[t.__c],n=Q(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){U=null,M&&M(t)},e.__r=function(t){B&&B(t),O=0;var e=(U=t.__c).__H;e&&(R===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=$,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),R=U},e.diffed=function(t){F&&F(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&W===e.requestAnimationFrame||((W=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==$&&(t.__=t.__V),t.i=void 0,t.__V=$}))),R=U=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),q&&q(t,n)},e.unmount=function(t){V&&V(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=U,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),U=e}function it(t){var e=U;t.__c=t.__(),U=e}function ot(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function st(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},lt="ui/reset",rt="ui/error",ct="ui/message",ut="ui/editing",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",wt="list/setItems",Pt="list/removeItem",Nt="list/addItem",kt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const o={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(o.body=JSON.stringify(n));const s=await fetch(Dt().root+i+e,o);s.headers.get("x-wp-nonce")&&(Dt().nonce=s.headers.get("x-wp-nonce"));const a=await s.json();return{data:a,headers:s.headers,status:s.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var o;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(o=t.data)||void 0===o?void 0:o.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){return It("DELETE","/"+t+"/items/"+e,{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Rt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function Wt(t,e){return!!t.type&&Ht(t.type,e)}function jt(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Ht(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Ht(t,e){const n=Ut(t);return!(!n||!n.supports)&&n.supports.includes(e)}const $t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Mt(t){return JSON.parse(JSON.stringify(t))}function Bt(t){return"string"!=typeof t?"":t.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2")}function Ft(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}function qt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error";if(!jQuery)return!1;const n=jQuery("<div>").addClass("mg-upc-alert mg-upc-alert-"+e);n.append(jQuery("<p>").html(t));const i=jQuery('<a class="mg-upc-alert-close" href="#"><span class="mg-upc-icon upc-font-close"></span></a>').on("click",(function(){return n.remove(),!1}));return n.append(i),n}function Vt(t,e){const{type:n,payload:i}=e;let o=!1;const s=t=>(o=a({status:"failed"}),t.error&&(o.error=t.error.message?t.error.message:"",o.errorCode=t.error.code?t.error.code:""),o),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=Mt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(o[t]=e[t]);return o};let l=function(t,e){const{type:n,payload:i}=e;let o,s;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=!1===t?{}:Mt(t)),e)for(const t in e)s[t]=e[t];return s};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Mt(t.items),i;case _t:return i;case wt:return a({items:i});case"list/addItem/failed":case Nt:return null!=i&&i.list?a(i.list):t;case kt:const e=!!i.item&&i.item;return o=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:o});case Pt:if(1===t.items.length||!1===i)return t;if(s=a(),o=s.items.filter((t=>t.post_id!==i)),Ht(t.type,"sortable")){const e=parseInt(t.items[0].position,10);o.forEach(((t,n)=>{o[n].position=e+n}))}if(Ht(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(s.vote_counter=s.vote_counter-e.votes)}return{...s,items:o};case Ct:const n=parseInt(t.items[0].position,10);o=a().items.slice();const l=a().items[i.oldIndex];return o.splice(i.oldIndex,1),o.splice(i.newIndex,0,l),isNaN(n)?(alert("positions error!"),t):(o.forEach(((t,e)=>{o[e].position=n+e})),a({items:o}));default:return t}}(t.list,e),r=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case Nt:case ht:return!1;case pt:return!1===i?t:Mt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===l&&r===t.listOfList||(o=a({listOfList:r,list:l}),t.addingPost||(o.title=o.list?o.list.title:Gt.title)),n){case"ui/mode":return a({mode:i});case lt:return{...Gt,mode:t.mode};case rt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case ct:return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ut:return a({editing:i});case mt:return o=a(),o.addingPost=i,i&&(o.title="Add to..."),o;case _t:o=a(),o.title=i.title?i.title:Gt.title,o.listTotalPages=1,o.listPage=1,o.addingPost=!1;break;case Nt:if(o=a(),null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(o.error=i.message,o.status="failed"),o.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return o=a(),o.status="loading",o.listOfList=!1,"object"==typeof i?(o.list=i,i.title&&(o.title=i.title)):o.list={ID:i},o;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/removeItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return o=a(),o.addingPost=!1,o.status="succeeded",o.error=!1,o.errorCode=!1,o.title=o.list?o.list.title:Gt.title,o;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return o=a({status:"failed"}),e.error&&e.error.message&&(o.error=e.error.message),o;case"list/addItem/failed":if(o=a(),o.addingPost=!1,o.title=o.list?o.list.title:Gt.title,null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(o.error=i.message,o.status="failed"),s(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return s(e)}return!1!==o?o:t}const Qt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:o}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((o=n)&&"object"==typeof o&&!0===o.asyncThunk){let o={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,o)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var o;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Gt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},zt=function(t,e){var n={__c:e="__cC"+s++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function Jt(t){return new Date(t).toLocaleDateString()}const Yt=function(t){const{state:e,dispatch:n}=Z(zt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){!function(t){t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()}(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",Jt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",Jt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Zt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var te,ee,ne;ne={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(ee="defaultProps")in(te=Zt)?Object.defineProperty(te,ee,{value:ne,enumerable:!0,configurable:!0,writable:!0}):te[ee]=ne;const ie=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},oe=()=>({type:lt,payload:null}),se=t=>({type:mt,payload:t}),ae=t=>({type:ut,payload:t}),le=Qt(xt,(async function(t,e){return await Ft(t)})),re=Qt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},o={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in o){const n=t.headers.get(e);n&&(i[o[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}Qt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));const ue=Qt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(re({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(re({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=Qt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=Qt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),he=Qt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),ve=Qt(wt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=Qt(Pt,(async function(t,e){const n=e.getState();return await Lt.quit(n.list.ID,t).then((i=>{if(1===n.list.items.length){const t=n.listPage,i=n.listTotalPages;return t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)})),!1}return t}))})),be=Qt(Nt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:"view"}).then((t=>{i=t.data}))}catch(t){var o;const n=null==t||null===(o=t.response)||void 0===o?void 0:o.data;i=e.rejectWithValue(n)}return i})),we=Qt(kt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Pe=Qt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],o=n.items[t],s=o.position-t+i;return await Lt.move(n.ID,o.post_id,s).then((e=>({oldIndex:t,newIndex:i})))})),Ne=Qt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),ke=Qt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(zt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Zt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Zt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Zt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Yt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ie,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[o,s]=X(!1),[a,l]=X(""),r=z({});return G((()=>{l(t.item.description)}),[t.item]),G((()=>{o&&r.current.focus()}),[o]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!o&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!o&&d("button",{onClick:()=>{s(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:o?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){l(t.target.value)},maxLength:400}),o&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{s(!1),l(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),o&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{s(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var o,s=e;s=s.__;)if((o=s.__c)&&o.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),o.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function Ue(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Re(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var o=Ue(i.__v),s=!1,a=function(){s||(s=!0,n.__R=null,o?o(l):l())};n.__R=a;var l=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},r=!0===e.__h;i.__u++||r||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var o=e.__a&&d(_,null,t.fallback);return o&&(o.__h=null),[d(_,null,e.__a?null:t.children),o]};var We=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function je(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d(je,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Re.prototype=new m).__a=function(t){var e=this,n=Ue(e.__v),i=e.o.get(t);return i[0]++,function(o){var s=function(){e.props.revealOrder?(i.push(o),We(e,t,i)):o()};n?n(s):s()}},Re.prototype.render=function(t){this.u=null,this.o=new Map;var e=w(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Re.prototype.componentDidUpdate=Re.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){We(t,n,e)}))};var $e="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Me=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Be="undefined"!=typeof document,Fe=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var qe=e.event;function Ve(){}function Qe(){return this.cancelBubble}function Xe(){return this.defaultPrevented}e.event=function(t){return qe&&(t=qe(t)),t.persist=Ve,t.isPropagationStopped=Qe,t.isDefaultPrevented=Xe,t.nativeEvent=t};var Ke={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var o=-1===e.indexOf("-");for(var s in i={},n){var a=n[s];Be&&"children"===s&&"noscript"===e||"value"===s&&"defaultValue"in n&&null==a||("defaultValue"===s&&"value"in n&&null==n.value?s="value":"download"===s&&!0===a?a="":/ondoubleclick/i.test(s)?s="ondblclick":/^onchange(textarea|input)/i.test(s+e)&&!Fe(n.type)?s="oninput":/^onfocus$/i.test(s)?s="onfocusin":/^onblur$/i.test(s)?s="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(s)?s=s.toLowerCase():o&&Me.test(s)?s=s.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(s)&&(s=s.toLowerCase(),i[s]&&(s="oninputCapture")),i[s]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=w(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=w(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Ke.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Ke))}t.$$typeof=$e,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));const nn=t=>{const e=(()=>{const[t,e]=X(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=X(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),o=t.role||"dialog",s="alertdialog"===o,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:o,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:s?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:o}=t;if(G((()=>(n&&o(n),()=>o(void 0))),[o,n]),!e)return null;const s=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),l=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),r=["first"===t.closeButtonPosition&&l,a,t.children,"last"===t.closeButtonPosition&&l].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),r)),s)};nn.defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}},function(t){function e(e,i,o,s){const a=o||s.parent(),l=a.find(".mg-upc-item-vote").attr("disabled",!0);mgUpcApiClient.vote(e,i,{context:"web",posts:n(a)}).then((function(e){t(document.body).trigger("mg_upc_vote_response",[e,a])})).catch((function(t){var e,n;l.attr("disabled",!1),null!==(e=t.response)&&void 0!==e&&null!==(n=e.data)&&void 0!==n&&n.message&&(s?s.append(qt(t.response.data.message)):a.before(qt(t.response.data.message)))}))}function n(e){return[...e.children().map((function(){return t(this).data("pid")}))].join(",")}t(".mg-upc-item-vote").on("click",(function(){const n=t(this).data("vote").split(",");return 2===n.length&&e(n[0],n[1],!1,t(this).closest(".mg-upc-item")),!1})),t((function(){t(".mg-upc-vote").each((function(){const n=t(this);e(n.data("id"),0,n.find(".mg-upc-items-container"),!1)}))})),t(document.body).on("mg_upc_vote_response",(function(e,n,i){if(!n.data)return;const o=parseInt(n.data.vote_counter,10),s=i.find(".mg-upc-item-vote");i.data("votes",o),n.data.can_vote?s.attr("disabled",!1).show():s.animate({width:0,padding:0,opacity:0},200,(function(){s.remove()})),n.data.posts.forEach((function(e){const n=i.find(".mg-upc-item[data-pid="+e.post_id+"]"),s=parseInt(e.votes,10);t(document.body).trigger("mg_upc_item_vote_set",[n,s,o])}))})),t(document.body).on("mg_upc_item_vote_set",(function(t,e,n,i){const o=i>0?Math.round(1e3*n/i)/10:0,s=e.find(".mg-upc-votes");s.find(".mg-upc-item-votes-number").html(n),s.find(".mg-upc-item-percent").html(o+"%"),s.find(".mg-upc-item-bar-progress").animate({width:o+"%"}),s.show()}))}(jQuery),function(t){t(".mg-upc-add-product-to-list").on("click",(function(){let e=t(this).data("id");const n=t(this).closest(".product,.summary").find("[name='variation_id']");return n.length>0&&parseInt(n.val(),10)>0&&(e=n.val()),window.addItemToList(e),!1}));const e="mg-upc-btn-loading",n="mg-upc-product-added",i="mg-upc-product-error",o="Sorry, an error occurred.";function s(a,l,r){if(l.hasClass(e))return!1;let c={product_id:l.data("product"),quantity:l.data("quantity")};if("0"==c.quantity){if(!r)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,l,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[l,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){l.removeClass(n+" "+i).addClass(e)},success:function(i){l.removeClass(e),i&&(i.error&&i.product_url?alert(o):(l.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,l])))},error:function(){l.addClass(i).removeClass(e),alert(o)}}),!1}function s(a,l,r){if(l.hasClass(e))return!1;let c={product_id:l.data("product"),quantity:l.data("quantity")};if("0"==c.quantity){if(!r)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,l,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[l,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){l.removeClass(n+" "+i).addClass(e)},success:function(i){l.removeClass(e),i&&(i.error&&i.product_url?alert(o):(l.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,l])))},error:function(){l.addClass(i).removeClass(e),alert(o)}}),!1}t((function(){if("undefined"==typeof wc_add_to_cart_params)return!1;t(".mg-upc-item-product").removeClass("mg-upc-hide").on("click",(function(e){return s(e,t(this),!1)})),t(".mg-upc-add-list-to-cart").removeClass("mg-upc-hide").on("click",(function(s){const a=t(this);return a.hasClass(e)||(a.removeClass(n+" "+i).addClass(e),window.mgUpcAddListToCart(t(this).data("id")).then((function(i){a.removeClass(e),i.err&&a.before(qt(Bt(i.err))),i.msg&&a.before(qt(Bt(i.msg),"success")),a.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,a])})).catch((t=>{var n,i;a.removeClass(e),null!==(n=t.response)&&void 0!==n&&null!==(i=n.data)&&void 0!==i&&i.message?a.before(qt(Bt(t.response.data.message))):alert(o)}))),!1}))}))}(jQuery);const on=function(t){var e;const[n,i]=X(""),[o,s]=X(""),[a,l]=X(""),[r,c]=X(""),u=J((()=>jt(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),l(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),s(t.list.content),l(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=Ut(a))&&void 0!==t&&t.available_statuses&&-1===Ut(a).available_statuses.indexOf(r)&&c(Ut(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Ht(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Ht(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:o,onChange:function(t){s(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==o?void 0:o.length),"/500")),""!==a&&!Ut(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=Ut(a))||void 0===e?void 0:e.available_statuses)&&Ut(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:r,onChange:function(t){c(t.target.value)}},Ut(a).available_statuses.map(((t,e)=>{if(function(t){const e=Rt(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Rt(t);return e?e.label:t}(t))})))),""!==a&&Ut(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:o,type:a,status:r})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=X(!1),[o,s]=X(""),[a,l]=X(null===(e=t.item)||void 0===e?void 0:e.quantity),r=z({});G((()=>{s(t.item.description)}),[t.item]),G((()=>{n&&r.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},Wt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),Wt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return Wt(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&Wt(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===o&&d("span",null,at("Add Comment")),""!==o&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:o,onChange:function(t){s(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),s(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(o)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&Wt(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){l(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},an=function(t){return new Promise((function(e,n){const i=document.createElement("script");let o=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){o||this.readyState&&"complete"!=this.readyState||(o=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},ln=function(t){var e,n,i;const o=z(null),s=z((e=>{t.onMove(e)}));return G((()=>{s.current=t.onMove})),G((()=>{let e=!1;if(Wt(t.list,"sortable")){const t=()=>{e=Sortable.create(o.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){s.current(t)}})};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},Wt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Zt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),Wt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Zt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Zt,{count:2})))))),d("ul",{ref:o,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),Wt(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},rn=function(t){const e=z(null),n=z(null),i=at("Copy"),[o,s]=X(i);G((()=>{let t=null;o!==i&&(t=setTimeout((()=>{s(i),clearTimeout(t)}),2e3))}),[o]);const a=encodeURIComponent(t.link),l=encodeURIComponent(t.title);let r=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+l},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+l},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+l},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+l},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+l},{slug:"email",name:at("Email"),url:"mailto:?subject="+l+"&body="+a}];return void 0!==Dt().shareButtons&&(r=r.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?s(at("Copied!")):s("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,o)),r.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},cn=function(t){var e;const{state:n,dispatch:i}=Z(zt),[o,s]=X(!1),a=z(!1),l=z(!1);function r(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,o=!1;if(t&&Wt(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(Ne(t.oldIndex))}})),a.current&&n.listPage>1&&(o=Sortable.create(l.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),o&&o.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{s(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(on,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const o={};o.title=t.title,o.content=t.content,o.type=t.type,o.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(o.adding=n.addingPost.post_id),i(he(o))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(ae(!1)),-1===n.list.ID&&(i(fe(!1)),i(oe()),i(re()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Ht(i,"editable_title")||Ht(i,"editable_content")||(null===(e=Ut(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(ae(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>s(!o)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(le(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),o&&n.list.link&&d(rn,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:Bt(n.list.content)}}),d(Zt,{count:3}),d(ln,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Pe(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(we(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(we(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ie,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){r(n.listPage-1)},onNext:function(){r(n.listPage+1)},prevRef:l,nextRef:a}))};function un(t){return parseInt(t.author,10)===parseInt(Dt().user_id,10)}function dn(){"replaceState"in history?(history.replaceState("",document.title,location.pathname),history.go(-1)):location.hash=""}D(d((t=>{const[e,n]=K(Vt,Gt);return d(zt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(zt),n=J((()=>jt(t.addingPost)),[t.addingPost]),i=z(!1);let o="listOfList";if(t.addingPost)o=t.editing?"addingToNew":"adding";else if(t.editing){var s;o=-1!==(null===(s=t.list)||void 0===s?void 0:s.ID)?"edit":"new"}else o=t.list?"list":"listOfList";const a={container:"mg-upc-dg-container",overlay:"mg-upc-dg-overlay",dialog:"mg-upc-dg-content"+(t.errorCode?" mg-upc-err-"+t.errorCode:""),title:"mg-upc-dg-title",closeButton:"mg-upc-dg-close"};G((()=>{window.showMyLists=function(){l()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e(oe()),n||r(t)},window.mgUpcAddListToCart=Ft}),[i.current,e]);const l=()=>{e(oe()),e(re()),i.current.show()},r=t=>{e(se({post_id:t})),e(re({addingPost:t})),i.current.show()};function c(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const u="list"===o||"new"===o||"edit"===o||"addingToNew"===o;return d(nn,{id:"mg-upc-dg-dialog",dialogRef:function(t){i.current=t},title:t.title,classNames:a,onBack:!!u&&function(){switch(o){case"list":default:l();break;case"new":e(fe(!1)),e(ae(!1)),l();break;case"edit":e(ae(!1));break;case"addingToNew":e(fe(!1)),e(ae(!1)),e(re({addingPost:t.addingPost.post_id}))}}},d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+o},d("div",{className:"mg-upc-dg-wait"}),t.message&&d("div",{className:"mg-upc-dg-msg"},t.message,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:ct,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:rt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===o||"adding"===o)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},n.length>0&&d("button",{className:"mg-list-new",onClick:function(t){e(ae(!0)),e(fe(!0)),i.current.show()}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d(xe,{lists:t.listOfList,onSelect:function(n){e(ae(!1)),t.addingPost?e(be(n.ID,t.addingPost)):(e(fe(n)),i.current.show())},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){c(t.page-1)},loadNext:function(){c(t.page+1)}})),t.list&&d(cn,{editable:un(t.list)}))))}),null)," "),document.querySelector("body")),"#my-lists"===location.hash&&dn(),window.addEventListener("hashchange",(function(){"#my-lists"===location.hash&&(window.showMyLists(),dn())}),!1),window.mgUpcApiClient=Lt})();1 (()=>{"use strict";var t,e,n,i,o,s,a={},r=[],l=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var o,s,a,r={};for(a in n)"key"==a?o=n[a]:"ref"==a?s=n[a]:r[a]=n[a];if(arguments.length>2&&(r.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===r[a]&&(r[a]=e.defaultProps[a]);return p(e,r,o,s,null)}function p(t,i,o,s,a){var r={type:t,props:i,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(r),r}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||o!==e.debounceRendering)&&((o=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,o,s,a;t.__d&&(s=(o=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},o)).__v=o.__v+1,I(a,o,i,e.__n,void 0!==a.ownerSVGElement,null!=o.__h?[s]:null,n,null==s?f(o):s,o.__h),S(n,o),o.__e!=s&&g(o)))}))}function y(t,e,n,i,o,s,l,c,u,d){var m,g,h,v,y,w,N,k=i&&i.__k||r,C=k.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=k[m])||h&&v.key==h.key&&v.type===h.type)k[m]=void 0;else for(g=0;g<C;g++){if((h=k[g])&&v.key==h.key&&v.type===h.type){k[g]=void 0;break}h=null}I(t,v,h=h||a,o,s,l,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(N||(N=[]),h.ref&&N.push(h.ref,null,v),N.push(g,v.__c||y,v)),null!=y?(null==w&&(w=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=P(t,v,h,k,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=w,m=C;m--;)null!=k[m]&&("function"==typeof n.type&&null!=k[m].__e&&k[m].__e==n.__d&&(n.__d=f(i,m+1)),E(k[m],k[m]));if(N)for(m=0;m<N.length;m++)A(N[m],N[++m],N[++m])}function b(t,e,n){for(var i,o=t.__k,s=0;o&&s<o.length;s++)(i=o[s])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):P(n,i,i,o,i.__e,e));return e}function w(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){w(t,e)})):e.push(t)),e}function P(t,e,n,i,o,s){var a,r,l;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||o!=s||null==o.parentNode)t:if(null==s||s.parentNode!==t)t.appendChild(o),a=null;else{for(r=s,l=0;(r=r.nextSibling)&&l<i.length;l+=2)if(r==o)break t;t.insertBefore(o,s),a=s}return void 0!==a?a:o.nextSibling}function N(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||l.test(e)?n:n+"px"}function k(t,e,n,i,o){var s;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||N(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||N(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])s=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?i||t.addEventListener(e,s?x:C,s):t.removeEventListener(e,s?x:C,s);else if("dangerouslySetInnerHTML"!==e){if(o)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,o,s,a,r,l,u){var d,p,f,g,h,v,b,w,P,N,k,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,l=n.__e=i.__e,n.__h=null,a=[l]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(w=n.props,P=(d=I.contextType)&&o[d.__c],N=d?P?P.props.value:d.__:o,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(w,N):(n.__c=p=new m(w,N),p.constructor=I,p.render=L),P&&P.sub(p),p.props=w,p.state||(p.state={}),p.context=N,p.__n=o,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(w,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&w!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,N),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,N)||n.__v===i.__v){p.props=w,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&r.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,N),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=N,p.props=w,p.__v=n,p.__P=t,k=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(o=c(c({},o),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,o,s,a,r,l,u),p.base=n.__e,n.__h=null,p.__h.length&&r.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,o,s,a,r,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=l,n.__h=!!u,a[a.indexOf(l)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,o,s,r,l,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(s=!0),null!=r)for(;v<r.length;v++)if((d=r[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,r[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=s?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),r=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(r=r&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=r)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,o){var s;for(s in n)"children"===s||"key"===s||s in e||k(t,s,null,n[s],i);for(s in e)o&&"function"!=typeof e[s]||"children"===s||"key"===s||"value"===s||"checked"===s||n[s]===e[s]||k(t,s,e[s],n[s],i)}(e,g,m,s,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,o,s&&"foreignObject"!==h,r,l,r?r[0]:i.__k&&f(i,0),c),null!=r)for(v=r.length;v--;)null!=r[v]&&u(r[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&k(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&k(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var o,s;if(e.unmount&&e.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||A(o,null,n)),null!=(o=t.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(t){e.__e(t,n)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&E(o[s],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,o){var s,r,l;e.__&&e.__(n,i),r=(s="function"==typeof o)?null:o&&o.__k||i.__k,l=[],I(i,n=(!s&&o||i).__k=d(_,null,[n]),r||a,a,void 0!==i.ownerSVGElement,!s&&o?[o]:r?null:i.firstChild?t.call(i.childNodes):null,l,!s&&o?o:r?r.__e:i.firstChild,s),S(l,n)}t=r.slice,e={__e:function(t,e,n,i){for(var o,s,a;e=e.__;)if((o=e.__c)&&!o.__)try{if((s=o.constructor)&&null!=s.getDerivedStateFromError&&(o.setState(s.getDerivedStateFromError(t)),a=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(t,i||{}),a=o.__d),a)return o.__E=o}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,s=0;var O,j,U,R,W=0,H=[],$=[],M=e.__b,F=e.__r,B=e.diffed,Q=e.__c,q=e.unmount;function V(t,n){e.__h&&e.__h(j,t,W||n),W=0;var i=j.__H||(j.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:$}),i.__[t]}function X(t){return W=1,K(st,t)}function K(t,e,n){var i=V(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):st(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=j,!i.__c.u)){i.__c.__H.u=!0;var o=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var s=i.__c.__H.__.filter((function(t){return t.__c}));return(s.every((function(t){return!t.__N}))||!s.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!o||o(t,e,n))}}return i.__N||i.__}function G(t,n){var i=V(O++,3);!e.__s&&ot(i.__H,n)&&(i.__=t,i.i=n,j.__H.__h.push(i))}function z(t){return W=5,J((function(){return{current:t}}),[])}function J(t,e){var n=V(O++,7);return ot(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return W=8,J((function(){return t}),e)}function Z(t){var e=j.context[t.__c],n=V(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(j)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){j=null,M&&M(t)},e.__r=function(t){F&&F(t),O=0;var e=(j=t.__c).__H;e&&(U===j?(e.__h=[],j.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=$,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),U=j},e.diffed=function(t){B&&B(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&R===e.requestAnimationFrame||((R=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==$&&(t.__=t.__V),t.i=void 0,t.__V=$}))),U=j=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),Q&&Q(t,n)},e.unmount=function(t){q&&q(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=j,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),j=e}function it(t){var e=j;t.__c=t.__(),j=e}function ot(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function st(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},rt="ui/reset",lt="ui/error",ct="ui/message",ut="ui/editing",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",wt="list/setItems",Pt="list/removeItem",Nt="list/addItem",kt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const o={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(o.body=JSON.stringify(n));const s=await fetch(Dt().root+i+e,o);s.headers.get("x-wp-nonce")&&(Dt().nonce=s.headers.get("x-wp-nonce"));const a=await s.json();return{data:a,headers:s.headers,status:s.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var o;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(o=t.data)||void 0===o?void 0:o.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("DELETE","/"+t+"/items/"+e+St(n),{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function jt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function Rt(t,e){return!!t.type&&Ht(t.type,e)}function Wt(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Ht(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Ht(t,e){const n=jt(t);return!(!n||!n.supports)&&n.supports.includes(e)}const $t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Mt(t){return JSON.parse(JSON.stringify(t))}function Ft(t){return"string"!=typeof t?"":t.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2")}function Bt(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}function Qt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error";if(!jQuery)return!1;const n=jQuery("<div>").addClass("mg-upc-alert mg-upc-alert-"+e);n.append(jQuery("<p>").html(t));const i=jQuery('<a class="mg-upc-alert-close" href="#"><span class="mg-upc-icon upc-font-close"></span></a>').on("click",(function(){return n.remove(),!1}));return n.append(i),n}function qt(t,e){const{type:n,payload:i}=e;let o=!1;const s=t=>(o=a({status:"failed"}),t.error&&(o.error=t.error.message?t.error.message:"",o.errorCode=t.error.code?t.error.code:""),o),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=Mt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(o[t]=e[t]);return o};let r=function(t,e){const{type:n,payload:i}=e;let o,s;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=!1===t?{}:Mt(t)),e)for(const t in e)s[t]=e[t];return s};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Mt(t.items),i;case _t:return i;case wt:return a({items:i});case"list/addItem/failed":case Nt:return null!=i&&i.list?a(i.list):t;case kt:const e=!!i.item&&i.item;return o=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:o});case Pt:if(!t.items||1===t.items.length||!1===i)return t;if(s=a(),o=s.items.filter((t=>t.post_id!==i)),Ht(t.type,"sortable")){const e=parseInt(t.items[0].position,10);o.forEach(((t,n)=>{o[n].position=e+n}))}if(Ht(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(s.vote_counter=s.vote_counter-e.votes)}return{...s,items:o};case Ct:const n=parseInt(t.items[0].position,10);o=a().items.slice();const r=a().items[i.oldIndex];return o.splice(i.oldIndex,1),o.splice(i.newIndex,0,r),isNaN(n)?(alert("positions error!"),t):(o.forEach(((t,e)=>{o[e].position=n+e})),a({items:o}));default:return t}}(t.list,e),l=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case Nt:case ht:return!1;case pt:return!1===i?t:Mt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===r&&l===t.listOfList||(o=a({listOfList:l,list:r}),t.addingPost||(o.title=o.list?o.list.title:Gt.title)),n){case"ui/mode":return a({mode:i});case rt:return{...Gt,mode:t.mode};case lt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case ct:return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ut:return a({editing:i});case mt:return o=a(),o.addingPost=i,i&&(o.title="Add to..."),o;case _t:o=a(),o.title=i.title?i.title:Gt.title,o.listTotalPages=1,o.listPage=1,o.addingPost=!1;break;case Nt:if(o=a(),null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(o.error=i.message,o.status="failed"),o.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return o=a(),o.status="loading",o.listOfList=!1,"object"==typeof i?(o.list=i,i.title&&(o.title=i.title)):o.list={ID:i},o;case"list/removeItem/loading":return o=a({status:"loading"}),"object"==typeof i&&i.list_id&&(o.list={ID:i.list_id}),o;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return o=a(),o.addingPost=!1,o.status="succeeded",o.error=!1,o.errorCode=!1,o.title=o.list?o.list.title:Gt.title,o;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return o=a({status:"failed"}),e.error&&e.error.message&&(o.error=e.error.message),o;case"list/addItem/failed":if(o=a(),o.addingPost=!1,o.title=o.list?o.list.title:Gt.title,null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(o.error=i.message,o.status="failed"),s(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return s(e)}return!1!==o?o:t}const Vt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:o}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((o=n)&&"object"==typeof o&&!0===o.asyncThunk){let o={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,o)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var o;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Gt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},zt=function(t,e){var n={__c:e="__cC"+s++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function Jt(t){return new Date(t).toLocaleDateString()}const Yt=function(t){const{state:e,dispatch:n}=Z(zt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){!function(t){t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()}(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",Jt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",Jt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Zt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var te,ee,ne;ne={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(ee="defaultProps")in(te=Zt)?Object.defineProperty(te,ee,{value:ne,enumerable:!0,configurable:!0,writable:!0}):te[ee]=ne;const ie=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},oe=()=>({type:rt,payload:null}),se=t=>({type:mt,payload:t}),ae=t=>({type:ut,payload:t}),re=Vt(xt,(async function(t,e){return await Bt(t)})),le=Vt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},o={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in o){const n=t.headers.get(e);n&&(i[o[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}Vt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));const ue=Vt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(le({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(le({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=Vt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=Vt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),he=Vt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),ve=Vt(wt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=Vt(Pt,(async function(t,e){const n=e.getState();var i=e.extra.length>0?e.extra[0]:n.list.ID;const o=e.extra.length>1?e.extra[1]:"view";return await Lt.quit(i,t,{context:o}).then((s=>{if(s.data&&s.data.list_id,n.list&&n.list.ID){if(1===n.list.items.length){if(e.dispatch(ve({page})),n.list&&"view"===o){const t=n.listPage,i=n.listTotalPages;t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)}))}return!1}}else e.dispatch(fe({ID:i}));return t}))})),be=Vt(Nt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:e.extra.length>1?e.extra[1]:"view"}).then((t=>{i=t.data}))}catch(t){var o;const n=null==t||null===(o=t.response)||void 0===o?void 0:o.data;i=e.rejectWithValue(n)}return i})),we=Vt(kt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Pe=Vt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],o=n.items[t],s=o.position-t+i;return await Lt.move(n.ID,o.post_id,s).then((e=>({oldIndex:t,newIndex:i})))})),Ne=Vt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),ke=Vt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(zt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Zt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Zt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Zt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Yt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ie,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[o,s]=X(!1),[a,r]=X(""),l=z({});return G((()=>{r(t.item.description)}),[t.item]),G((()=>{o&&l.current.focus()}),[o]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!o&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!o&&d("button",{onClick:()=>{s(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:l,className:o?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){r(t.target.value)},maxLength:400}),o&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{s(!1),r(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),o&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{s(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var o,s=e;s=s.__;)if((o=s.__c)&&o.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),o.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function je(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Ue(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var o=je(i.__v),s=!1,a=function(){s||(s=!0,n.__R=null,o?o(r):r())};n.__R=a;var r=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},l=!0===e.__h;i.__u++||l||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var o=e.__a&&d(_,null,t.fallback);return o&&(o.__h=null),[d(_,null,e.__a?null:t.children),o]};var Re=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function We(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d(We,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Ue.prototype=new m).__a=function(t){var e=this,n=je(e.__v),i=e.o.get(t);return i[0]++,function(o){var s=function(){e.props.revealOrder?(i.push(o),Re(e,t,i)):o()};n?n(s):s()}},Ue.prototype.render=function(t){this.u=null,this.o=new Map;var e=w(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Ue.prototype.componentDidUpdate=Ue.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){Re(t,n,e)}))};var $e="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Me=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Fe="undefined"!=typeof document,Be=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var Qe=e.event;function qe(){}function Ve(){return this.cancelBubble}function Xe(){return this.defaultPrevented}e.event=function(t){return Qe&&(t=Qe(t)),t.persist=qe,t.isPropagationStopped=Ve,t.isDefaultPrevented=Xe,t.nativeEvent=t};var Ke={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var o=-1===e.indexOf("-");for(var s in i={},n){var a=n[s];Fe&&"children"===s&&"noscript"===e||"value"===s&&"defaultValue"in n&&null==a||("defaultValue"===s&&"value"in n&&null==n.value?s="value":"download"===s&&!0===a?a="":/ondoubleclick/i.test(s)?s="ondblclick":/^onchange(textarea|input)/i.test(s+e)&&!Be(n.type)?s="oninput":/^onfocus$/i.test(s)?s="onfocusin":/^onblur$/i.test(s)?s="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(s)?s=s.toLowerCase():o&&Me.test(s)?s=s.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(s)&&(s=s.toLowerCase(),i[s]&&(s="oninputCapture")),i[s]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=w(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=w(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Ke.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Ke))}t.$$typeof=$e,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));const nn=t=>{const e=(()=>{const[t,e]=X(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=X(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),o=t.role||"dialog",s="alertdialog"===o,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:o,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:s?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:o}=t;if(G((()=>(n&&o(n),()=>o(void 0))),[o,n]),!e)return null;const s=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),r=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),l=["first"===t.closeButtonPosition&&r,a,t.children,"last"===t.closeButtonPosition&&r].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),l)),s)};nn.defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}},function(t){function e(e,i,o,s){const a=o||s.parent(),r=a.find(".mg-upc-item-vote").attr("disabled",!0);mgUpcApiClient.vote(e,i,{context:"web",posts:n(a)}).then((function(e){t(document.body).trigger("mg_upc_vote_response",[e,a])})).catch((function(t){var e,n;r.attr("disabled",!1),null!==(e=t.response)&&void 0!==e&&null!==(n=e.data)&&void 0!==n&&n.message&&(s?s.append(Qt(t.response.data.message)):a.before(Qt(t.response.data.message)))}))}function n(e){return[...e.children().map((function(){return t(this).data("pid")}))].join(",")}t(".mg-upc-item-vote").on("click",(function(){const n=t(this).data("vote").split(",");return 2===n.length&&e(n[0],n[1],!1,t(this).closest(".mg-upc-item")),!1})),t((function(){t(".mg-upc-vote").each((function(){const n=t(this);e(n.data("id"),0,n.find(".mg-upc-items-container"),!1)}))})),t(document.body).on("mg_upc_vote_response",(function(e,n,i){if(!n.data)return;const o=parseInt(n.data.vote_counter,10),s=i.find(".mg-upc-item-vote");i.data("votes",o),n.data.can_vote?s.attr("disabled",!1).show():s.animate({width:0,padding:0,opacity:0},200,(function(){s.remove()})),n.data.posts.forEach((function(e){const n=i.find(".mg-upc-item[data-pid="+e.post_id+"]"),s=parseInt(e.votes,10);t(document.body).trigger("mg_upc_item_vote_set",[n,s,o])}))})),t(document.body).on("mg_upc_item_vote_set",(function(t,e,n,i){const o=i>0?Math.round(1e3*n/i)/10:0,s=e.find(".mg-upc-votes");s.find(".mg-upc-item-votes-number").html(n),s.find(".mg-upc-item-percent").html(o+"%"),s.find(".mg-upc-item-bar-progress").animate({width:o+"%"}),s.show()}))}(jQuery),function(t){t(".mg-upc-add-product-to-list").on("click",(function(){let e=t(this).data("id");const n=t(this).closest(".product,.summary").find("[name='variation_id']");return n.length>0&&parseInt(n.val(),10)>0&&(e=n.val()),window.addItemToList(e),!1}));const e="mg-upc-btn-loading",n="mg-upc-product-added",i="mg-upc-product-error",o="Sorry, an error occurred.";function s(a,r,l){if(r.hasClass(e))return!1;let c={product_id:r.data("product"),quantity:r.data("quantity")};if("0"==c.quantity){if(!l)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,r,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[r,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){r.removeClass(n+" "+i).addClass(e)},success:function(i){r.removeClass(e),i&&(i.error&&i.product_url?alert(o):(r.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,r])))},error:function(){r.addClass(i).removeClass(e),alert(o)}}),!1}function s(a,r,l){if(r.hasClass(e))return!1;let c={product_id:r.data("product"),quantity:r.data("quantity")};if("0"==c.quantity){if(!l)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,r,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[r,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){r.removeClass(n+" "+i).addClass(e)},success:function(i){r.removeClass(e),i&&(i.error&&i.product_url?alert(o):(r.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,r])))},error:function(){r.addClass(i).removeClass(e),alert(o)}}),!1}t((function(){if("undefined"==typeof wc_add_to_cart_params)return!1;t(".mg-upc-item-product").removeClass("mg-upc-hide").on("click",(function(e){return s(e,t(this),!1)})),t(".mg-upc-add-list-to-cart").removeClass("mg-upc-hide").on("click",(function(s){const a=t(this);return a.hasClass(e)||(a.removeClass(n+" "+i).addClass(e),window.mgUpcAddListToCart(t(this).data("id")).then((function(i){a.removeClass(e),i.err&&a.before(Qt(Ft(i.err))),i.msg&&a.before(Qt(Ft(i.msg),"success")),a.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,a])})).catch((t=>{var n,i;a.removeClass(e),null!==(n=t.response)&&void 0!==n&&null!==(i=n.data)&&void 0!==i&&i.message?a.before(Qt(Ft(t.response.data.message))):alert(o)}))),!1}))}))}(jQuery);const on=function(t){var e;const[n,i]=X(""),[o,s]=X(""),[a,r]=X(""),[l,c]=X(""),u=J((()=>Wt(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),r(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),s(t.list.content),r(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=jt(a))&&void 0!==t&&t.available_statuses&&-1===jt(a).available_statuses.indexOf(l)&&c(jt(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Ht(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Ht(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:o,onChange:function(t){s(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==o?void 0:o.length),"/500")),""!==a&&!jt(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=jt(a))||void 0===e?void 0:e.available_statuses)&&jt(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:l,onChange:function(t){c(t.target.value)}},jt(a).available_statuses.map(((t,e)=>{if(function(t){const e=Ut(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Ut(t);return e?e.label:t}(t))})))),""!==a&&jt(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:o,type:a,status:l})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=X(!1),[o,s]=X(""),[a,r]=X(null===(e=t.item)||void 0===e?void 0:e.quantity),l=z({});G((()=>{s(t.item.description)}),[t.item]),G((()=>{n&&l.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},Rt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),Rt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return Rt(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&Rt(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===o&&d("span",null,at("Add Comment")),""!==o&&d("span",null,at("Edit Comment"))),d("input",{ref:l,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:o,onChange:function(t){s(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),s(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(o)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&Rt(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){r(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},an=function(t){return new Promise((function(e,n){const i=document.createElement("script");let o=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){o||this.readyState&&"complete"!=this.readyState||(o=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},rn=function(t){var e,n,i;const o=z(null),s=z((e=>{t.onMove(e)}));return G((()=>{s.current=t.onMove})),G((()=>{let e=!1;if(Rt(t.list,"sortable")){const t=()=>{e=Sortable.create(o.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){s.current(t)}})};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},Rt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Zt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),Rt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Zt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Zt,{count:2})))))),d("ul",{ref:o,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),Rt(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},ln=function(t){const e=z(null),n=z(null),i=at("Copy"),[o,s]=X(i);G((()=>{let t=null;o!==i&&(t=setTimeout((()=>{s(i),clearTimeout(t)}),2e3))}),[o]);const a=encodeURIComponent(t.link),r=encodeURIComponent(t.title);let l=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+r},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+r},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+r},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+r},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+r},{slug:"email",name:at("Email"),url:"mailto:?subject="+r+"&body="+a}];return void 0!==Dt().shareButtons&&(l=l.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?s(at("Copied!")):s("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,o)),l.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},cn=function(t){var e;const{state:n,dispatch:i}=Z(zt),[o,s]=X(!1),a=z(!1),r=z(!1);function l(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,o=!1;if(t&&Rt(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(Ne(t.oldIndex))}})),a.current&&n.listPage>1&&(o=Sortable.create(r.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),o&&o.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{s(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(on,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const o={};o.title=t.title,o.content=t.content,o.type=t.type,o.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(o.adding=n.addingPost.post_id),i(he(o))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(ae(!1)),-1===n.list.ID&&(i(fe(!1)),i(oe()),i(le()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Ht(i,"editable_title")||Ht(i,"editable_content")||(null===(e=jt(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(ae(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>s(!o)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(re(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),o&&n.list.link&&d(ln,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:Ft(n.list.content)}}),d(Zt,{count:3}),d(rn,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Pe(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(we(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(we(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ie,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){l(n.listPage-1)},onNext:function(){l(n.listPage+1)},prevRef:r,nextRef:a}))};function un(t){return parseInt(t.author,10)===parseInt(Dt().user_id,10)}function dn(){"replaceState"in history?(history.replaceState("",document.title,location.pathname),history.go(-1)):location.hash=""}D(d((t=>{const[e,n]=K(qt,Gt);return d(zt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(zt),n=J((()=>Wt(t.addingPost)),[t.addingPost]),i=z(!1);let o="listOfList";if(t.addingPost)o=t.editing?"addingToNew":"adding";else if(t.editing){var s;o=-1!==(null===(s=t.list)||void 0===s?void 0:s.ID)?"edit":"new"}else o=t.list?"list":"listOfList";const a={container:"mg-upc-dg-container",overlay:"mg-upc-dg-overlay",dialog:"mg-upc-dg-content"+(t.errorCode?" mg-upc-err-"+t.errorCode:""),title:"mg-upc-dg-title",closeButton:"mg-upc-dg-close"};G((()=>{window.showMyLists=function(){r()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"view";e(oe()),n?(e(be(n,t,o)),i.current.show()):l(t)},window.removeItemFromList=function(t,n){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"view";e(oe()),e(ye(t,n,o)),i.current.show()},window.mgUpcAddListToCart=Bt}),[i.current,e]);const r=()=>{e(oe()),e(le()),i.current.show()},l=t=>{e(se({post_id:t})),e(le({addingPost:t})),i.current.show()};function c(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const u="list"===o||"new"===o||"edit"===o||"addingToNew"===o;return d(nn,{id:"mg-upc-dg-dialog",dialogRef:function(t){i.current=t},title:t.title,classNames:a,onBack:!!u&&function(){switch(o){case"list":default:r();break;case"new":e(fe(!1)),e(ae(!1)),r();break;case"edit":e(ae(!1));break;case"addingToNew":e(fe(!1)),e(ae(!1)),e(le({addingPost:t.addingPost.post_id}))}}},d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+o},d("div",{className:"mg-upc-dg-wait"}),t.message&&d("div",{className:"mg-upc-dg-msg"},t.message,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:ct,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:lt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===o||"adding"===o)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},n.length>0&&!t.error&&d("button",{className:"mg-list-new",onClick:function(t){e(ae(!0)),e(fe(!0)),i.current.show()}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d(xe,{lists:t.listOfList,onSelect:function(n){e(ae(!1)),t.addingPost?e(be(n.ID,t.addingPost)):(e(fe(n)),i.current.show())},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){c(t.page-1)},loadNext:function(){c(t.page+1)}})),t.list&&d(cn,{editable:un(t.list)}))))}),null)," "),document.querySelector("body")),"#my-lists"===location.hash&&dn(),window.addEventListener("hashchange",(function(){"#my-lists"===location.hash&&(window.showMyLists(),dn())}),!1),window.mgUpcApiClient=Lt,window.mgUpcListeners=function(){jQuery(".mg-upc-post-add").on("click",(function(){return jQuery(this).data("post-id")>0&&window.addItemToList(jQuery(this).data("post-id"),(jQuery(this).data("upc-list")+"").length>0&&jQuery(this).data("upc-list")),!1})),jQuery(".mg-upc-post-remove").on("click",(function(){return jQuery(this).data("post-id")>0&&void 0!==jQuery(this).data("upc-list")&&window.removeItemFromList(jQuery(this).data("post-id"),(jQuery(this).data("upc-list")+"").length>0&&jQuery(this).data("upc-list")),!1}))},window.mgUpcListeners()})(); -
user-post-collections/tags/0.8.30/readme.txt
r2770186 r2783097 6 6 Tags: User lists, Post Collections, Woocommerce Wishlist 7 7 Tested up to: 6.0 8 Stable tag: 0.8. 298 Stable tag: 0.8.30 9 9 Requires PHP: 7.0 10 10 … … 68 68 == Changelog == 69 69 70 = 0.8.30 = 71 * Add some themes helper 72 70 73 = 0.8.29 = 71 74 * Update preact -
user-post-collections/tags/0.8.30/user-post-collections.php
r2770186 r2783097 4 4 Plugin URI: https://galetto.info/user-post-collections 5 5 Description: Allows users to create their post collections. 6 Version: 0.8. 296 Version: 0.8.30 7 7 Author: Mauricio Galetto 8 8 Author URI: https://galetto.info/ … … 67 67 require_once __DIR__ . '/includes/mg-upc-texts.php'; 68 68 require_once __DIR__ . '/includes/mg-upc-settings-api.php'; 69 require_once __DIR__ . '/includes/themes-helper.php'; 69 70 70 71 require_once __DIR__ . '/classes/Exceptions/mg-upc-item-exist-exception.php'; -
user-post-collections/trunk/classes/user-post-collections.php
r2770186 r2783097 16 16 public $model; 17 17 18 const VERSION = '0.8. 29';18 const VERSION = '0.8.30'; 19 19 20 20 /** -
user-post-collections/trunk/controllers/mg-upc-rest-list-items-controller.php
r2768965 r2783097 69 69 'permission_callback' => array( $this, 'write_item_permissions_check_always_exist' ), 70 70 'args' => $this->get_create_params(), 71 ), 72 'schema' => array( $this, 'get_item_schema' ), 73 ) 74 ); 75 76 register_rest_route( 77 $this->namespace, 78 '/' . $this->resource_name . '/(?P<upctype>' . $sticky_type . ')/items/(?P<postid>[\d]+)', 79 array( 80 array( 81 'methods' => WP_REST_Server::DELETABLE, 82 'callback' => array( $this, 'delete_item_always_exist' ), 83 'permission_callback' => array( $this, 'write_item_permissions_check_always_exist' ), 71 84 ), 72 85 'schema' => array( $this, 'get_item_schema' ), … … 336 349 } 337 350 351 return $this->delete_item_from_id( (int) $request['id'], (int) $request['postid']); 352 } 353 354 /** 355 * Remove item from a list ID 356 * 357 * @param int $list_id 358 * @param int $post_id 359 * 360 * @return WP_Error|WP_REST_Response 361 */ 362 private function delete_item_from_id( $list_id, $post_id ) { 338 363 try { 339 if ( ! $this->model->items->item_exists( (int) $ request['id'], (int) $request['postid']) ) {364 if ( ! $this->model->items->item_exists( (int) $list_id, (int) $post_id ) ) { 340 365 return new WP_Error( 341 366 'rest_item_not_found', 342 367 esc_html__( 'Item not found.', 'user-post-collections' ), 343 array( 'status' => 404 ) 368 array( 369 'status' => 404, 370 'list_id' => (int) $list_id, 371 'post_id' => (int) $post_id, 372 ) 344 373 ); 345 374 } 346 $this->model->items->remove_item( (int) $ request['id'], (int) $request['postid']);375 $this->model->items->remove_item( (int) $list_id, (int) $post_id ); 347 376 } catch ( Exception $e ) { 348 377 return new WP_Error( 349 378 'rest_item_error', 350 379 esc_html__( 'Unknown error.', 'user-post-collections' ), 351 array( 'status' => 500 ) 380 array( 381 'status' => 500, 382 'list_id' => (int) $list_id, 383 'post_id' => (int) $post_id, 384 ) 352 385 ); 353 386 } … … 357 390 array( 358 391 'deleted' => true, 392 'list_id' => (int) $list_id, 393 'post_id' => (int) $post_id, 359 394 ) 360 395 ); … … 408 443 409 444 /** 445 * Delete an item from an 'always exist' list 446 * 447 * @param WP_REST_Request $request Current request. 448 * 449 * @return WP_Error|WP_REST_Response 450 * 451 * @noinspection PhpUnused (Rest API callback) 452 */ 453 public function delete_item_always_exist( $request ) { 454 455 $response = array( 'data' => array() ); 456 457 try { 458 $list = $this->model->find_always_exist( $request['upctype'], get_current_user_id() ); 459 460 if ( null === $list ) { 461 return new WP_Error( 462 'rest_item_not_found', 463 esc_html__( 'Item not found.', 'user-post-collections' ), 464 array( 'status' => 404 ) 465 ); 466 } else { 467 return $this->delete_item_from_id( (int) $list->ID, (int) $request['postid'] ); 468 } 469 } catch ( MG_UPC_Invalid_Field_Exception $e ) { 470 $response['code'] = 'rest_invalid_field'; 471 $response['message'] = $e->getMessage(); 472 $response['data']['status'] = 409; 473 } 474 475 $response_api = new WP_REST_Response(); 476 $response_api->set_data( $response ); 477 $response_api->set_status( $response['status'] ); 478 479 return $response_api; 480 } 481 482 /** 410 483 * Create an item 411 484 * … … 427 500 $response['message'] = esc_html( $e->getMessage() ); 428 501 $response['data']['status'] = 409; 502 503 if ( 'check' === $request['context'] ) { 504 $response['check'] = 'OK'; 505 } 429 506 } catch ( Exception $e ) { 430 507 return new WP_Error( … … 554 631 } 555 632 633 if ( isset( $request['context'] ) && 'check' === $request['context'] ) { 634 if ( ! empty( $response['added'] ) ) { 635 $response['check'] = 'OK'; 636 } else { 637 $response['check'] = 'ERR'; 638 } 639 } 640 556 641 /** 557 642 * Filter for item to save. If return WP_Error, the operation is canceled. -
user-post-collections/trunk/javascript/mg-upc-client/dist/admin.js
r2770186 r2783097 1 (()=>{"use strict";var t,e,n,i,s,o,a={},l=[],r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var s,o,a,l={};for(a in n)"key"==a?s=n[a]:"ref"==a?o=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return p(e,l,s,o,null)}function p(t,i,s,o,a){var l={type:t,props:i,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(l),l}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||s!==e.debounceRendering)&&((s=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,s,o,a;t.__d&&(o=(s=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},s)).__v=s.__v+1,I(a,s,i,e.__n,void 0!==a.ownerSVGElement,null!=s.__h?[o]:null,n,null==o?f(s):o,s.__h),S(n,s),s.__e!=o&&g(s)))}))}function y(t,e,n,i,s,o,r,c,u,d){var m,g,h,v,y,P, k,w=i&&i.__k||l,C=w.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=w[m])||h&&v.key==h.key&&v.type===h.type)w[m]=void 0;else for(g=0;g<C;g++){if((h=w[g])&&v.key==h.key&&v.type===h.type){w[g]=void 0;break}h=null}I(t,v,h=h||a,s,o,r,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(k||(k=[]),h.ref&&k.push(h.ref,null,v),k.push(g,v.__c||y,v)),null!=y?(null==P&&(P=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=N(t,v,h,w,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=P,m=C;m--;)null!=w[m]&&("function"==typeof n.type&&null!=w[m].__e&&w[m].__e==n.__d&&(n.__d=f(i,m+1)),E(w[m],w[m]));if(k)for(m=0;m<k.length;m++)A(k[m],k[++m],k[++m])}function b(t,e,n){for(var i,s=t.__k,o=0;s&&o<s.length;o++)(i=s[o])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):N(n,i,i,s,i.__e,e));return e}function P(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){P(t,e)})):e.push(t)),e}function N(t,e,n,i,s,o){var a,l,r;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||s!=o||null==s.parentNode)t:if(null==o||o.parentNode!==t)t.appendChild(s),a=null;else{for(l=o,r=0;(l=l.nextSibling)&&r<i.length;r+=2)if(l==s)break t;t.insertBefore(s,o),a=o}return void 0!==a?a:s.nextSibling}function k(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||r.test(e)?n:n+"px"}function w(t,e,n,i,s){var o;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||k(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||k(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])o=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i||t.addEventListener(e,o?x:C,o):t.removeEventListener(e,o?x:C,o);else if("dangerouslySetInnerHTML"!==e){if(s)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,s,o,a,l,r,u){var d,p,f,g,h,v,b,P,N,k,w,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,r=n.__e=i.__e,n.__h=null,a=[r]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(P=n.props,N=(d=I.contextType)&&s[d.__c],k=d?N?N.props.value:d.__:s,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(P,k):(n.__c=p=new m(P,k),p.constructor=I,p.render=L),N&&N.sub(p),p.props=P,p.state||(p.state={}),p.context=k,p.__n=s,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(P,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&P!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(P,k),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(P,p.__s,k)||n.__v===i.__v){p.props=P,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&l.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(P,p.__s,k),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=k,p.props=P,p.__v=n,p.__P=t,w=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,w&&w(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,w&&w(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(s=c(c({},s),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,s,o,a,l,r,u),p.base=n.__e,n.__h=null,p.__h.length&&l.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,s,o,a,l,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=r,n.__h=!!u,a[a.indexOf(r)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,s,o,l,r,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(o=!0),null!=l)for(;v<l.length;v++)if((d=l[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,l[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),l=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(l=l&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=l)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,s){var o;for(o in n)"children"===o||"key"===o||o in e||w(t,o,null,n[o],i);for(o in e)s&&"function"!=typeof e[o]||"children"===o||"key"===o||"value"===o||"checked"===o||n[o]===e[o]||w(t,o,e[o],n[o],i)}(e,g,m,o,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,s,o&&"foreignObject"!==h,l,r,l?l[0]:i.__k&&f(i,0),c),null!=l)for(v=l.length;v--;)null!=l[v]&&u(l[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&w(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&w(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var s,o;if(e.unmount&&e.unmount(t),(s=t.ref)&&(s.current&&s.current!==t.__e||A(s,null,n)),null!=(s=t.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(t){e.__e(t,n)}s.base=s.__P=null}if(s=t.__k)for(o=0;o<s.length;o++)s[o]&&E(s[o],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,s){var o,l,r;e.__&&e.__(n,i),l=(o="function"==typeof s)?null:s&&s.__k||i.__k,r=[],I(i,n=(!o&&s||i).__k=d(_,null,[n]),l||a,a,void 0!==i.ownerSVGElement,!o&&s?[s]:l?null:i.firstChild?t.call(i.childNodes):null,r,!o&&s?s:l?l.__e:i.firstChild,o),S(r,n)}t=l.slice,e={__e:function(t,e,n,i){for(var s,o,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&null!=o.getDerivedStateFromError&&(s.setState(o.getDerivedStateFromError(t)),a=s.__d),null!=s.componentDidCatch&&(s.componentDidCatch(t,i||{}),a=s.__d),a)return s.__E=s}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,o=0;var O,U,R,W,$=0,H=[],M=[],j=e.__b,B=e.__r,F=e.diffed,V=e.__c,q=e.unmount;function X(t,n){e.__h&&e.__h(U,t,$||n),$=0;var i=U.__H||(U.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:M}),i.__[t]}function K(t){return $=1,Q(ot,t)}function Q(t,e,n){var i=X(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):ot(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=U,!i.__c.u)){i.__c.__H.u=!0;var s=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var o=i.__c.__H.__.filter((function(t){return t.__c}));return(o.every((function(t){return!t.__N}))||!o.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!s||s(t,e,n))}}return i.__N||i.__}function G(t,n){var i=X(O++,3);!e.__s&&st(i.__H,n)&&(i.__=t,i.i=n,U.__H.__h.push(i))}function z(t){return $=5,J((function(){return{current:t}}),[])}function J(t,e){var n=X(O++,7);return st(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return $=8,J((function(){return t}),e)}function Z(t){var e=U.context[t.__c],n=X(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){U=null,j&&j(t)},e.__r=function(t){B&&B(t),O=0;var e=(U=t.__c).__H;e&&(R===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=M,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),R=U},e.diffed=function(t){F&&F(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&W===e.requestAnimationFrame||((W=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==M&&(t.__=t.__V),t.i=void 0,t.__V=M}))),R=U=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),V&&V(t,n)},e.unmount=function(t){q&&q(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=U,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),U=e}function it(t){var e=U;t.__c=t.__(),U=e}function st(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function ot(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},lt="ui/reset",rt="ui/error",ct="ui/editing",ut="ui/mode",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",Pt="list/setItems",Nt="list/removeItem",kt="list/addItem",wt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const s={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(s.body=JSON.stringify(n));const o=await fetch(Dt().root+i+e,s);o.headers.get("x-wp-nonce")&&(Dt().nonce=o.headers.get("x-wp-nonce"));const a=await o.json();return{data:a,headers:o.headers,status:o.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var s;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(s=t.data)||void 0===s?void 0:s.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){return It("DELETE","/"+t+"/items/"+e,{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Rt(){var t;return Object.values(null===(t=Dt())||void 0===t?void 0:t.statuses)}function Wt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function $t(t,e){return!!t.type&&Mt(t.type,e)}function Ht(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Mt(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Mt(t,e){const n=Ut(t);return!(!n||!n.supports)&&n.supports.includes(e)}const jt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Bt(t){return JSON.parse(JSON.stringify(t))}function Ft(t){return t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault(),!1}function Vt(t,e){const{type:n,payload:i}=e;let s=!1;const o=t=>(s=a({status:"failed"}),t.error&&(s.error=t.error.message?t.error.message:"",s.errorCode=t.error.code?t.error.code:""),s),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=Bt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(s[t]=e[t]);return s};let l=function(t,e){const{type:n,payload:i}=e;let s,o;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=!1===t?{}:Bt(t)),e)for(const t in e)o[t]=e[t];return o};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Bt(t.items),i;case _t:return i;case Pt:return a({items:i});case"list/addItem/failed":case kt:return null!=i&&i.list?a(i.list):t;case wt:const e=!!i.item&&i.item;return s=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:s});case Nt:if(1===t.items.length||!1===i)return t;if(o=a(),s=o.items.filter((t=>t.post_id!==i)),Mt(t.type,"sortable")){const e=parseInt(t.items[0].position,10);s.forEach(((t,n)=>{s[n].position=e+n}))}if(Mt(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(o.vote_counter=o.vote_counter-e.votes)}return{...o,items:s};case Ct:const n=parseInt(t.items[0].position,10);s=a().items.slice();const l=a().items[i.oldIndex];return s.splice(i.oldIndex,1),s.splice(i.newIndex,0,l),isNaN(n)?(alert("positions error!"),t):(s.forEach(((t,e)=>{s[e].position=n+e})),a({items:s}));default:return t}}(t.list,e),r=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case kt:case ht:return!1;case pt:return!1===i?t:Bt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===l&&r===t.listOfList||(s=a({listOfList:r,list:l}),t.addingPost||(s.title=s.list?s.list.title:Qt.title)),n){case ut:return a({mode:i});case lt:return{...Qt,mode:t.mode};case rt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case"ui/message":return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ct:return a({editing:i});case mt:return s=a(),s.addingPost=i,i&&(s.title="Add to..."),s;case _t:s=a(),s.title=i.title?i.title:Qt.title,s.listTotalPages=1,s.listPage=1,s.addingPost=!1;break;case kt:if(s=a(),null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(s.error=i.message,s.status="failed"),s.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return s=a(),s.status="loading",s.listOfList=!1,"object"==typeof i?(s.list=i,i.title&&(s.title=i.title)):s.list={ID:i},s;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/removeItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return s=a(),s.addingPost=!1,s.status="succeeded",s.error=!1,s.errorCode=!1,s.title=s.list?s.list.title:Qt.title,s;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return s=a({status:"failed"}),e.error&&e.error.message&&(s.error=e.error.message),s;case"list/addItem/failed":if(s=a(),s.addingPost=!1,s.title=s.list?s.list.title:Qt.title,null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(s.error=i.message,s.status="failed"),o(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return o(e)}return!1!==s?s:t}const qt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:s}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((s=n)&&"object"==typeof s&&!0===s.asyncThunk){let s={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,s)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var s;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Qt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},Gt=function(t,e){var n={__c:e="__cC"+o++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function zt(t){return new Date(t).toLocaleDateString()}const Jt=function(t){const{state:e,dispatch:n}=Z(Gt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){Ft(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",zt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",zt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Yt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var Zt,te,ee;ee={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(te="defaultProps")in(Zt=Yt)?Object.defineProperty(Zt,te,{value:ee,enumerable:!0,configurable:!0,writable:!0}):Zt[te]=ee;const ne=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},ie=()=>({type:lt,payload:null}),se=t=>({type:mt,payload:t}),oe=t=>({type:ct,payload:t}),ae=qt(xt,(async function(t,e){return await function(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}(t)})),le=qt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))})),re=qt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},s={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in s){const n=t.headers.get(e);n&&(i[s[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}const ue=qt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(le({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(le({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=qt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=qt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),he=qt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),ve=qt(Pt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=qt(Nt,(async function(t,e){const n=e.getState();return await Lt.quit(n.list.ID,t).then((i=>{if(1===n.list.items.length){const t=n.listPage,i=n.listTotalPages;return t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)})),!1}return t}))})),be=qt(kt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:"view"}).then((t=>{i=t.data}))}catch(t){var s;const n=null==t||null===(s=t.response)||void 0===s?void 0:s.data;i=e.rejectWithValue(n)}return i})),Pe=qt(wt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Ne=qt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],s=n.items[t],o=s.position-t+i;return await Lt.move(n.ID,s.post_id,o).then((e=>({oldIndex:t,newIndex:i})))})),ke=qt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),we=qt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(Gt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Yt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Yt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Yt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Jt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ne,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[s,o]=K(!1),[a,l]=K(""),r=z({});return G((()=>{l(t.item.description)}),[t.item]),G((()=>{s&&r.current.focus()}),[s]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!s&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!s&&d("button",{onClick:()=>{o(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:s?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){l(t.target.value)},maxLength:400}),s&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{o(!1),l(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),s&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{o(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var s,o=e;o=o.__;)if((s=o.__c)&&s.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),s.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function Ue(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Re(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var s=Ue(i.__v),o=!1,a=function(){o||(o=!0,n.__R=null,s?s(l):l())};n.__R=a;var l=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},r=!0===e.__h;i.__u++||r||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var s=e.__a&&d(_,null,t.fallback);return s&&(s.__h=null),[d(_,null,e.__a?null:t.children),s]};var We=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function $e(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d($e,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Re.prototype=new m).__a=function(t){var e=this,n=Ue(e.__v),i=e.o.get(t);return i[0]++,function(s){var o=function(){e.props.revealOrder?(i.push(s),We(e,t,i)):s()};n?n(o):o()}},Re.prototype.render=function(t){this.u=null,this.o=new Map;var e=P(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Re.prototype.componentDidUpdate=Re.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){We(t,n,e)}))};var Me="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,je=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Be="undefined"!=typeof document,Fe=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var Ve=e.event;function qe(){}function Xe(){return this.cancelBubble}function Ke(){return this.defaultPrevented}e.event=function(t){return Ve&&(t=Ve(t)),t.persist=qe,t.isPropagationStopped=Xe,t.isDefaultPrevented=Ke,t.nativeEvent=t};var Qe={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var s=-1===e.indexOf("-");for(var o in i={},n){var a=n[o];Be&&"children"===o&&"noscript"===e||"value"===o&&"defaultValue"in n&&null==a||("defaultValue"===o&&"value"in n&&null==n.value?o="value":"download"===o&&!0===a?a="":/ondoubleclick/i.test(o)?o="ondblclick":/^onchange(textarea|input)/i.test(o+e)&&!Fe(n.type)?o="oninput":/^onfocus$/i.test(o)?o="onfocusin":/^onblur$/i.test(o)?o="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(o)?o=o.toLowerCase():s&&je.test(o)?o=o.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(o)&&(o=o.toLowerCase(),i[o]&&(o="oninputCapture")),i[o]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=P(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=P(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Qe.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Qe))}t.$$typeof=Me,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));(t=>{const e=(()=>{const[t,e]=K(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=K(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),s=t.role||"dialog",o="alertdialog"===s,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:s,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:o?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:s}=t;if(G((()=>(n&&s(n),()=>s(void 0))),[s,n]),!e)return null;const o=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),l=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),r=["first"===t.closeButtonPosition&&l,a,t.children,"last"===t.closeButtonPosition&&l].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),r)),o)}).defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}};const nn=function(t){var e;const[n,i]=K(""),[s,o]=K(""),[a,l]=K(""),[r,c]=K(""),u=J((()=>Ht(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),l(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),o(t.list.content),l(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=Ut(a))&&void 0!==t&&t.available_statuses&&-1===Ut(a).available_statuses.indexOf(r)&&c(Ut(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Mt(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Mt(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:s,onChange:function(t){o(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==s?void 0:s.length),"/500")),""!==a&&!Ut(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=Ut(a))||void 0===e?void 0:e.available_statuses)&&Ut(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:r,onChange:function(t){c(t.target.value)}},Ut(a).available_statuses.map(((t,e)=>{if(function(t){const e=Wt(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Wt(t);return e?e.label:t}(t))})))),""!==a&&Ut(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:s,type:a,status:r})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=K(!1),[s,o]=K(""),[a,l]=K(null===(e=t.item)||void 0===e?void 0:e.quantity),r=z({});G((()=>{o(t.item.description)}),[t.item]),G((()=>{n&&r.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return $t(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&$t(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===s&&d("span",null,at("Add Comment")),""!==s&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:s,onChange:function(t){o(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),o(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(s)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&$t(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){l(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},on=function(t){return new Promise((function(e,n){const i=document.createElement("script");let s=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){s||this.readyState&&"complete"!=this.readyState||(s=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},an=function(t){var e,n,i;const s=z(null),o=z((e=>{t.onMove(e)}));return G((()=>{o.current=t.onMove})),G((()=>{let e=!1;if($t(t.list,"sortable")){const t=()=>{e=Sortable.create(s.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){o.current(t)}})};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Yt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Yt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Yt,{count:2})))))),d("ul",{ref:s,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),$t(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},ln=function(t){const e=z(null),n=z(null),i=at("Copy"),[s,o]=K(i);G((()=>{let t=null;s!==i&&(t=setTimeout((()=>{o(i),clearTimeout(t)}),2e3))}),[s]);const a=encodeURIComponent(t.link),l=encodeURIComponent(t.title);let r=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+l},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+l},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+l},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+l},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+l},{slug:"email",name:at("Email"),url:"mailto:?subject="+l+"&body="+a}];return void 0!==Dt().shareButtons&&(r=r.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?o(at("Copied!")):o("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,s)),r.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},rn=function(t){var e;const{state:n,dispatch:i}=Z(Gt),[s,o]=K(!1),a=z(!1),l=z(!1);function r(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,s=!1;if(t&&$t(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}})),a.current&&n.listPage>1&&(s=Sortable.create(l.current,{group:"shared",onAdd:t=>{i(we(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),s&&s.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{o(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(nn,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const s={};s.title=t.title,s.content=t.content,s.type=t.type,s.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(s.adding=n.addingPost.post_id),i(he(s))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(oe(!1)),-1===n.list.ID&&(i(fe(!1)),i(ie()),i(le()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Mt(i,"editable_title")||Mt(i,"editable_content")||(null===(e=Ut(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(oe(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>o(!s)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(ae(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),s&&n.list.link&&d(ln,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:(c=n.list.content,"string"!=typeof c?"":c.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2"))}}),d(Yt,{count:3}),d(an,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Ne(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(Pe(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(Pe(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ne,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){r(n.listPage-1)},onNext:function(){r(n.listPage+1)},prevRef:l,nextRef:a}));var c};D(d((t=>{const[e,n]=Q(Vt,Qt);return d(Gt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(Gt),[n,i]=K("any"),[s,o]=K("any"),[a,l]=K(""),[r,c]=K(null),u=z(!1),p=J((()=>Ht(t.addingPost)),[t.addingPost]),m=J((()=>{return Object.values(null===(t=Dt())||void 0===t?void 0:t.types);var t}),[]);let f="listOfList";if(t.addingPost)f=t.editing?"addingToNew":"adding";else if(t.editing){var g;f=-1!==(null===(g=t.list)||void 0===g?void 0:g.ID)?"edit":"new"}else f=t.list?"list":"listOfList";G((()=>{window.showMainLists=function(){e(ie()),h()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e(ie()),n||P(t)}}),[e]);const h=()=>{const i={};n&&(i.types=n),s&&(i.status=s),r&&(i.search=r),a&&(i.author=a),t.page>1&&(i.page=t.page),e(re(i))};function v(){t.page>1&&e(de(1))}function y(t){v(),i(t)}function b(t){v(),o(t)}G((()=>{Qt.title="",e({type:ut,payload:"admin"});const t=function(t){const n=parseInt(("author",new URLSearchParams(document.location.hash.substring(1)).get("author")),10);n>0&&n!==a&&(t&&Ft(t),e(de(1)),l(n),location.hash="")};return t(0),window.addEventListener("hashchange",t,!1),()=>{window.removeEventListener("hashchange",t)}}),[]),G((()=>{t.list||h()}),[n,s,a,t.page]),G((()=>{null!=r&&(clearTimeout(u.current),u.current=setTimeout((function(){h()}),300))}),[r]);const P=t=>{e(se({post_id:t})),e(le({addingPost:t}))};function N(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const k=d("h2",{key:"title"},("list"===f||"new"===f||"edit"===f||"addingToNew"===f)&&d("a",{"aria-label":"Back",className:"mg-upc-dg-back",href:"#",onClick:n=>{n.preventDefault(),function(){switch(f){case"list":e(fe(!1)),h();break;case"new":e(fe(!1)),e(oe(!1)),h();break;case"edit":e(oe(!1));break;case"addingToNew":e(fe(!1)),e(oe(!1)),e(le({addingPost:t.addingPost.post_id}));break;default:h()}}()}},"←")," ",t.title);return d(_,null,k,d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+f},d("div",{className:"mg-upc-dg-wait"}),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:rt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===f||"adding"===f)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},p.length>0&&d("button",{className:"mg-list-new",onClick:function(t){e(oe(!0)),e(fe(!0))}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Types"))),d("li",{className:"any"==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",onClick:()=>y("any"),onKeyPress:t=>{13===t.keyCode&&y("any")},tabIndex:"0"},d("i",{className:"mg-upc-icon upc-font-close mg-upc-dg-item-type mg-upc-dg-item-type-none"}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),m.map(((t,e)=>d("li",{className:t.name==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",key:t.name,onClick:()=>y(t.name),onKeyPress:e=>{13===e.keyCode&&y(t.name)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label)))))),Rt()&&d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Status"))),d("li",{className:"any"==s?"mg-upc-selected":"",onClick:()=>b("any"),onKeyPress:t=>{13===t.keyCode&&b("any")},tabIndex:"0"},d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),Rt().map(((t,e)=>d("li",{className:t.name==s?"mg-upc-selected":"",key:t.name,onClick:()=>b(t.name),onKeyPress:e=>{13===e.keyCode&&b(t.name)},tabIndex:"0"},t.label)))),d("div",{className:"mg-upc-dg-df"},d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Search"))),d("input",{onChange:function(t){v(),c(t.target.value)},value:r})),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Author (ID)"))),d("input",{type:"number",onChange:function(t){v(),l(t.target.value)},value:a}))),d(xe,{lists:t.listOfList,onSelect:function(n){e(oe(!1)),t.addingPost?e(be(n.ID,t.addingPost)):e(fe(n))},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){N(t.page-1)},loadNext:function(){N(t.page+1)}})),t.list&&d(rn,{editable:(t.list,!0)}))))}),null)," "),document.getElementById("mg-upc-admin-app")),setTimeout(window.showMainLists,1e3)})();1 (()=>{"use strict";var t,e,n,i,s,o,a={},l=[],r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var s,o,a,l={};for(a in n)"key"==a?s=n[a]:"ref"==a?o=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return p(e,l,s,o,null)}function p(t,i,s,o,a){var l={type:t,props:i,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(l),l}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||s!==e.debounceRendering)&&((s=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,s,o,a;t.__d&&(o=(s=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},s)).__v=s.__v+1,I(a,s,i,e.__n,void 0!==a.ownerSVGElement,null!=s.__h?[o]:null,n,null==o?f(s):o,s.__h),S(n,s),s.__e!=o&&g(s)))}))}function y(t,e,n,i,s,o,r,c,u,d){var m,g,h,v,y,P,w,k=i&&i.__k||l,C=k.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=k[m])||h&&v.key==h.key&&v.type===h.type)k[m]=void 0;else for(g=0;g<C;g++){if((h=k[g])&&v.key==h.key&&v.type===h.type){k[g]=void 0;break}h=null}I(t,v,h=h||a,s,o,r,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(w||(w=[]),h.ref&&w.push(h.ref,null,v),w.push(g,v.__c||y,v)),null!=y?(null==P&&(P=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=N(t,v,h,k,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=P,m=C;m--;)null!=k[m]&&("function"==typeof n.type&&null!=k[m].__e&&k[m].__e==n.__d&&(n.__d=f(i,m+1)),E(k[m],k[m]));if(w)for(m=0;m<w.length;m++)A(w[m],w[++m],w[++m])}function b(t,e,n){for(var i,s=t.__k,o=0;s&&o<s.length;o++)(i=s[o])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):N(n,i,i,s,i.__e,e));return e}function P(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){P(t,e)})):e.push(t)),e}function N(t,e,n,i,s,o){var a,l,r;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||s!=o||null==s.parentNode)t:if(null==o||o.parentNode!==t)t.appendChild(s),a=null;else{for(l=o,r=0;(l=l.nextSibling)&&r<i.length;r+=2)if(l==s)break t;t.insertBefore(s,o),a=o}return void 0!==a?a:s.nextSibling}function w(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||r.test(e)?n:n+"px"}function k(t,e,n,i,s){var o;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||w(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||w(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])o=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i||t.addEventListener(e,o?x:C,o):t.removeEventListener(e,o?x:C,o);else if("dangerouslySetInnerHTML"!==e){if(s)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,s,o,a,l,r,u){var d,p,f,g,h,v,b,P,N,w,k,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,r=n.__e=i.__e,n.__h=null,a=[r]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(P=n.props,N=(d=I.contextType)&&s[d.__c],w=d?N?N.props.value:d.__:s,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(P,w):(n.__c=p=new m(P,w),p.constructor=I,p.render=L),N&&N.sub(p),p.props=P,p.state||(p.state={}),p.context=w,p.__n=s,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(P,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&P!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(P,w),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(P,p.__s,w)||n.__v===i.__v){p.props=P,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&l.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(P,p.__s,w),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=w,p.props=P,p.__v=n,p.__P=t,k=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(s=c(c({},s),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,s,o,a,l,r,u),p.base=n.__e,n.__h=null,p.__h.length&&l.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,s,o,a,l,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=r,n.__h=!!u,a[a.indexOf(r)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,s,o,l,r,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(o=!0),null!=l)for(;v<l.length;v++)if((d=l[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,l[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),l=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(l=l&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=l)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,s){var o;for(o in n)"children"===o||"key"===o||o in e||k(t,o,null,n[o],i);for(o in e)s&&"function"!=typeof e[o]||"children"===o||"key"===o||"value"===o||"checked"===o||n[o]===e[o]||k(t,o,e[o],n[o],i)}(e,g,m,o,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,s,o&&"foreignObject"!==h,l,r,l?l[0]:i.__k&&f(i,0),c),null!=l)for(v=l.length;v--;)null!=l[v]&&u(l[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&k(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&k(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var s,o;if(e.unmount&&e.unmount(t),(s=t.ref)&&(s.current&&s.current!==t.__e||A(s,null,n)),null!=(s=t.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(t){e.__e(t,n)}s.base=s.__P=null}if(s=t.__k)for(o=0;o<s.length;o++)s[o]&&E(s[o],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,s){var o,l,r;e.__&&e.__(n,i),l=(o="function"==typeof s)?null:s&&s.__k||i.__k,r=[],I(i,n=(!o&&s||i).__k=d(_,null,[n]),l||a,a,void 0!==i.ownerSVGElement,!o&&s?[s]:l?null:i.firstChild?t.call(i.childNodes):null,r,!o&&s?s:l?l.__e:i.firstChild,o),S(r,n)}t=l.slice,e={__e:function(t,e,n,i){for(var s,o,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&null!=o.getDerivedStateFromError&&(s.setState(o.getDerivedStateFromError(t)),a=s.__d),null!=s.componentDidCatch&&(s.componentDidCatch(t,i||{}),a=s.__d),a)return s.__E=s}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,o=0;var O,U,R,W,$=0,H=[],M=[],j=e.__b,B=e.__r,F=e.diffed,V=e.__c,q=e.unmount;function X(t,n){e.__h&&e.__h(U,t,$||n),$=0;var i=U.__H||(U.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:M}),i.__[t]}function K(t){return $=1,Q(ot,t)}function Q(t,e,n){var i=X(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):ot(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=U,!i.__c.u)){i.__c.__H.u=!0;var s=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var o=i.__c.__H.__.filter((function(t){return t.__c}));return(o.every((function(t){return!t.__N}))||!o.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!s||s(t,e,n))}}return i.__N||i.__}function G(t,n){var i=X(O++,3);!e.__s&&st(i.__H,n)&&(i.__=t,i.i=n,U.__H.__h.push(i))}function z(t){return $=5,J((function(){return{current:t}}),[])}function J(t,e){var n=X(O++,7);return st(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return $=8,J((function(){return t}),e)}function Z(t){var e=U.context[t.__c],n=X(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){U=null,j&&j(t)},e.__r=function(t){B&&B(t),O=0;var e=(U=t.__c).__H;e&&(R===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=M,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),R=U},e.diffed=function(t){F&&F(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&W===e.requestAnimationFrame||((W=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==M&&(t.__=t.__V),t.i=void 0,t.__V=M}))),R=U=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),V&&V(t,n)},e.unmount=function(t){q&&q(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=U,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),U=e}function it(t){var e=U;t.__c=t.__(),U=e}function st(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function ot(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},lt="ui/reset",rt="ui/error",ct="ui/editing",ut="ui/mode",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",Pt="list/setItems",Nt="list/removeItem",wt="list/addItem",kt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const s={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(s.body=JSON.stringify(n));const o=await fetch(Dt().root+i+e,s);o.headers.get("x-wp-nonce")&&(Dt().nonce=o.headers.get("x-wp-nonce"));const a=await o.json();return{data:a,headers:o.headers,status:o.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var s;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(s=t.data)||void 0===s?void 0:s.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("DELETE","/"+t+"/items/"+e+St(n),{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Rt(){var t;return Object.values(null===(t=Dt())||void 0===t?void 0:t.statuses)}function Wt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function $t(t,e){return!!t.type&&Mt(t.type,e)}function Ht(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Mt(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Mt(t,e){const n=Ut(t);return!(!n||!n.supports)&&n.supports.includes(e)}const jt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Bt(t){return JSON.parse(JSON.stringify(t))}function Ft(t){return t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault(),!1}function Vt(t,e){const{type:n,payload:i}=e;let s=!1;const o=t=>(s=a({status:"failed"}),t.error&&(s.error=t.error.message?t.error.message:"",s.errorCode=t.error.code?t.error.code:""),s),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=Bt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(s[t]=e[t]);return s};let l=function(t,e){const{type:n,payload:i}=e;let s,o;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=!1===t?{}:Bt(t)),e)for(const t in e)o[t]=e[t];return o};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Bt(t.items),i;case _t:return i;case Pt:return a({items:i});case"list/addItem/failed":case wt:return null!=i&&i.list?a(i.list):t;case kt:const e=!!i.item&&i.item;return s=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:s});case Nt:if(!t.items||1===t.items.length||!1===i)return t;if(o=a(),s=o.items.filter((t=>t.post_id!==i)),Mt(t.type,"sortable")){const e=parseInt(t.items[0].position,10);s.forEach(((t,n)=>{s[n].position=e+n}))}if(Mt(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(o.vote_counter=o.vote_counter-e.votes)}return{...o,items:s};case Ct:const n=parseInt(t.items[0].position,10);s=a().items.slice();const l=a().items[i.oldIndex];return s.splice(i.oldIndex,1),s.splice(i.newIndex,0,l),isNaN(n)?(alert("positions error!"),t):(s.forEach(((t,e)=>{s[e].position=n+e})),a({items:s}));default:return t}}(t.list,e),r=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case wt:case ht:return!1;case pt:return!1===i?t:Bt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===l&&r===t.listOfList||(s=a({listOfList:r,list:l}),t.addingPost||(s.title=s.list?s.list.title:Qt.title)),n){case ut:return a({mode:i});case lt:return{...Qt,mode:t.mode};case rt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case"ui/message":return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ct:return a({editing:i});case mt:return s=a(),s.addingPost=i,i&&(s.title="Add to..."),s;case _t:s=a(),s.title=i.title?i.title:Qt.title,s.listTotalPages=1,s.listPage=1,s.addingPost=!1;break;case wt:if(s=a(),null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(s.error=i.message,s.status="failed"),s.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return s=a(),s.status="loading",s.listOfList=!1,"object"==typeof i?(s.list=i,i.title&&(s.title=i.title)):s.list={ID:i},s;case"list/removeItem/loading":return s=a({status:"loading"}),"object"==typeof i&&i.list_id&&(s.list={ID:i.list_id}),s;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return s=a(),s.addingPost=!1,s.status="succeeded",s.error=!1,s.errorCode=!1,s.title=s.list?s.list.title:Qt.title,s;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return s=a({status:"failed"}),e.error&&e.error.message&&(s.error=e.error.message),s;case"list/addItem/failed":if(s=a(),s.addingPost=!1,s.title=s.list?s.list.title:Qt.title,null!=i&&i.list){const t=i.list;s.title=t.title?t.title:Qt.title;const e=null==t?void 0:t.items_page;e&&(s.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,s.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(s.error=i.message,s.status="failed"),o(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return o(e)}return!1!==s?s:t}const qt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:s}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((s=n)&&"object"==typeof s&&!0===s.asyncThunk){let s={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,s)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var s;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Qt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},Gt=function(t,e){var n={__c:e="__cC"+o++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function zt(t){return new Date(t).toLocaleDateString()}const Jt=function(t){const{state:e,dispatch:n}=Z(Gt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){Ft(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",zt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",zt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Yt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var Zt,te,ee;ee={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(te="defaultProps")in(Zt=Yt)?Object.defineProperty(Zt,te,{value:ee,enumerable:!0,configurable:!0,writable:!0}):Zt[te]=ee;const ne=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},ie=()=>({type:lt,payload:null}),se=t=>({type:mt,payload:t}),oe=t=>({type:ct,payload:t}),ae=qt(xt,(async function(t,e){return await function(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}(t)})),le=qt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))})),re=qt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},s={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in s){const n=t.headers.get(e);n&&(i[s[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}const ue=qt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(le({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(le({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=qt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=qt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),he=qt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(oe(!1)),Ce(t,e.dispatch),t.data)))})),ve=qt(Pt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=qt(Nt,(async function(t,e){const n=e.getState();var i=e.extra.length>0?e.extra[0]:n.list.ID;const s=e.extra.length>1?e.extra[1]:"view";return await Lt.quit(i,t,{context:s}).then((o=>{if(o.data&&o.data.list_id,n.list&&n.list.ID){if(1===n.list.items.length){if(e.dispatch(ve({page})),n.list&&"view"===s){const t=n.listPage,i=n.listTotalPages;t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)}))}return!1}}else e.dispatch(fe({ID:i}));return t}))})),be=qt(wt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:e.extra.length>1?e.extra[1]:"view"}).then((t=>{i=t.data}))}catch(t){var s;const n=null==t||null===(s=t.response)||void 0===s?void 0:s.data;i=e.rejectWithValue(n)}return i})),Pe=qt(kt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Ne=qt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],s=n.items[t],o=s.position-t+i;return await Lt.move(n.ID,s.post_id,o).then((e=>({oldIndex:t,newIndex:i})))})),we=qt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),ke=qt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const s=n.items[t];return await Lt.move(n.ID,s.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(Gt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Yt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Yt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Yt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Jt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ne,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[s,o]=K(!1),[a,l]=K(""),r=z({});return G((()=>{l(t.item.description)}),[t.item]),G((()=>{s&&r.current.focus()}),[s]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!s&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!s&&d("button",{onClick:()=>{o(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:s?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){l(t.target.value)},maxLength:400}),s&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{o(!1),l(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),s&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{o(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var s,o=e;o=o.__;)if((s=o.__c)&&s.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),s.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function Ue(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Re(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var s=Ue(i.__v),o=!1,a=function(){o||(o=!0,n.__R=null,s?s(l):l())};n.__R=a;var l=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},r=!0===e.__h;i.__u++||r||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var s=e.__a&&d(_,null,t.fallback);return s&&(s.__h=null),[d(_,null,e.__a?null:t.children),s]};var We=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function $e(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d($e,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Re.prototype=new m).__a=function(t){var e=this,n=Ue(e.__v),i=e.o.get(t);return i[0]++,function(s){var o=function(){e.props.revealOrder?(i.push(s),We(e,t,i)):s()};n?n(o):o()}},Re.prototype.render=function(t){this.u=null,this.o=new Map;var e=P(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Re.prototype.componentDidUpdate=Re.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){We(t,n,e)}))};var Me="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,je=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Be="undefined"!=typeof document,Fe=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var Ve=e.event;function qe(){}function Xe(){return this.cancelBubble}function Ke(){return this.defaultPrevented}e.event=function(t){return Ve&&(t=Ve(t)),t.persist=qe,t.isPropagationStopped=Xe,t.isDefaultPrevented=Ke,t.nativeEvent=t};var Qe={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var s=-1===e.indexOf("-");for(var o in i={},n){var a=n[o];Be&&"children"===o&&"noscript"===e||"value"===o&&"defaultValue"in n&&null==a||("defaultValue"===o&&"value"in n&&null==n.value?o="value":"download"===o&&!0===a?a="":/ondoubleclick/i.test(o)?o="ondblclick":/^onchange(textarea|input)/i.test(o+e)&&!Fe(n.type)?o="oninput":/^onfocus$/i.test(o)?o="onfocusin":/^onblur$/i.test(o)?o="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(o)?o=o.toLowerCase():s&&je.test(o)?o=o.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(o)&&(o=o.toLowerCase(),i[o]&&(o="oninputCapture")),i[o]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=P(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=P(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Qe.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Qe))}t.$$typeof=Me,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));(t=>{const e=(()=>{const[t,e]=K(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=K(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),s=t.role||"dialog",o="alertdialog"===s,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:s,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:o?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:s}=t;if(G((()=>(n&&s(n),()=>s(void 0))),[s,n]),!e)return null;const o=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),l=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),r=["first"===t.closeButtonPosition&&l,a,t.children,"last"===t.closeButtonPosition&&l].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),r)),o)}).defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}};const nn=function(t){var e;const[n,i]=K(""),[s,o]=K(""),[a,l]=K(""),[r,c]=K(""),u=J((()=>Ht(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),l(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),o(t.list.content),l(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=Ut(a))&&void 0!==t&&t.available_statuses&&-1===Ut(a).available_statuses.indexOf(r)&&c(Ut(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Mt(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Mt(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:s,onChange:function(t){o(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==s?void 0:s.length),"/500")),""!==a&&!Ut(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=Ut(a))||void 0===e?void 0:e.available_statuses)&&Ut(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:r,onChange:function(t){c(t.target.value)}},Ut(a).available_statuses.map(((t,e)=>{if(function(t){const e=Wt(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Wt(t);return e?e.label:t}(t))})))),""!==a&&Ut(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:s,type:a,status:r})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=K(!1),[s,o]=K(""),[a,l]=K(null===(e=t.item)||void 0===e?void 0:e.quantity),r=z({});G((()=>{o(t.item.description)}),[t.item]),G((()=>{n&&r.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return $t(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:jt})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&$t(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===s&&d("span",null,at("Add Comment")),""!==s&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:s,onChange:function(t){o(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),o(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(s)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&$t(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){l(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},on=function(t){return new Promise((function(e,n){const i=document.createElement("script");let s=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){s||this.readyState&&"complete"!=this.readyState||(s=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},an=function(t){var e,n,i;const s=z(null),o=z((e=>{t.onMove(e)}));return G((()=>{o.current=t.onMove})),G((()=>{let e=!1;if($t(t.list,"sortable")){const t=()=>{e=Sortable.create(s.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){o.current(t)}})};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},$t(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Yt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),$t(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Yt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Yt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Yt,{count:2})))))),d("ul",{ref:s,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),$t(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},ln=function(t){const e=z(null),n=z(null),i=at("Copy"),[s,o]=K(i);G((()=>{let t=null;s!==i&&(t=setTimeout((()=>{o(i),clearTimeout(t)}),2e3))}),[s]);const a=encodeURIComponent(t.link),l=encodeURIComponent(t.title);let r=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+l},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+l},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+l},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+l},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+l},{slug:"email",name:at("Email"),url:"mailto:?subject="+l+"&body="+a}];return void 0!==Dt().shareButtons&&(r=r.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?o(at("Copied!")):o("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,s)),r.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},rn=function(t){var e;const{state:n,dispatch:i}=Z(Gt),[s,o]=K(!1),a=z(!1),l=z(!1);function r(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,s=!1;if(t&&$t(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(we(t.oldIndex))}})),a.current&&n.listPage>1&&(s=Sortable.create(l.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():on(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),s&&s.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{o(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(nn,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const s={};s.title=t.title,s.content=t.content,s.type=t.type,s.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(s.adding=n.addingPost.post_id),i(he(s))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(oe(!1)),-1===n.list.ID&&(i(fe(!1)),i(ie()),i(le()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Mt(i,"editable_title")||Mt(i,"editable_content")||(null===(e=Ut(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(oe(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>o(!s)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(ae(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),s&&n.list.link&&d(ln,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:(c=n.list.content,"string"!=typeof c?"":c.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2"))}}),d(Yt,{count:3}),d(an,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Ne(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(Pe(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(Pe(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ne,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){r(n.listPage-1)},onNext:function(){r(n.listPage+1)},prevRef:l,nextRef:a}));var c};D(d((t=>{const[e,n]=Q(Vt,Qt);return d(Gt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(Gt),[n,i]=K("any"),[s,o]=K("any"),[a,l]=K(""),[r,c]=K(null),u=z(!1),p=J((()=>Ht(t.addingPost)),[t.addingPost]),m=J((()=>{return Object.values(null===(t=Dt())||void 0===t?void 0:t.types);var t}),[]);let f="listOfList";if(t.addingPost)f=t.editing?"addingToNew":"adding";else if(t.editing){var g;f=-1!==(null===(g=t.list)||void 0===g?void 0:g.ID)?"edit":"new"}else f=t.list?"list":"listOfList";G((()=>{window.showMainLists=function(){e(ie()),h()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e(ie()),n||P(t)}}),[e]);const h=()=>{const i={};n&&(i.types=n),s&&(i.status=s),r&&(i.search=r),a&&(i.author=a),t.page>1&&(i.page=t.page),e(re(i))};function v(){t.page>1&&e(de(1))}function y(t){v(),i(t)}function b(t){v(),o(t)}G((()=>{Qt.title="",e({type:ut,payload:"admin"});const t=function(t){const n=parseInt(("author",new URLSearchParams(document.location.hash.substring(1)).get("author")),10);n>0&&n!==a&&(t&&Ft(t),e(de(1)),l(n),location.hash="")};return t(0),window.addEventListener("hashchange",t,!1),()=>{window.removeEventListener("hashchange",t)}}),[]),G((()=>{t.list||h()}),[n,s,a,t.page]),G((()=>{null!=r&&(clearTimeout(u.current),u.current=setTimeout((function(){h()}),300))}),[r]);const P=t=>{e(se({post_id:t})),e(le({addingPost:t}))};function N(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const w=d("h2",{key:"title"},("list"===f||"new"===f||"edit"===f||"addingToNew"===f)&&d("a",{"aria-label":"Back",className:"mg-upc-dg-back",href:"#",onClick:n=>{n.preventDefault(),function(){switch(f){case"list":e(fe(!1)),h();break;case"new":e(fe(!1)),e(oe(!1)),h();break;case"edit":e(oe(!1));break;case"addingToNew":e(fe(!1)),e(oe(!1)),e(le({addingPost:t.addingPost.post_id}));break;default:h()}}()}},"←")," ",t.title);return d(_,null,w,d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+f},d("div",{className:"mg-upc-dg-wait"}),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:rt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===f||"adding"===f)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},p.length>0&&d("button",{className:"mg-list-new",onClick:function(t){e(oe(!0)),e(fe(!0))}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Types"))),d("li",{className:"any"==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",onClick:()=>y("any"),onKeyPress:t=>{13===t.keyCode&&y("any")},tabIndex:"0"},d("i",{className:"mg-upc-icon upc-font-close mg-upc-dg-item-type mg-upc-dg-item-type-none"}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),m.map(((t,e)=>d("li",{className:t.name==n?"mg-upc-dg-item-list-type mg-upc-selected":"mg-upc-dg-item-list-type",key:t.name,onClick:()=>y(t.name),onKeyPress:e=>{13===e.keyCode&&y(t.name)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label)))))),Rt()&&d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Status"))),d("li",{className:"any"==s?"mg-upc-selected":"",onClick:()=>b("any"),onKeyPress:t=>{13===t.keyCode&&b("any")},tabIndex:"0"},d("div",{className:"mg-upc-dg-item-title"},d("strong",null,"All"))),Rt().map(((t,e)=>d("li",{className:t.name==s?"mg-upc-selected":"",key:t.name,onClick:()=>b(t.name),onKeyPress:e=>{13===e.keyCode&&b(t.name)},tabIndex:"0"},t.label)))),d("div",{className:"mg-upc-dg-df"},d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Search"))),d("input",{onChange:function(t){v(),c(t.target.value)},value:r})),d("ul",{className:"mg-upc-dg-filter"},d("li",{className:"mg-upc-dg-filter-label"},d("strong",null,at("Author (ID)"))),d("input",{type:"number",onChange:function(t){v(),l(t.target.value)},value:a}))),d(xe,{lists:t.listOfList,onSelect:function(n){e(oe(!1)),t.addingPost?e(be(n.ID,t.addingPost)):e(fe(n))},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){N(t.page-1)},loadNext:function(){N(t.page+1)}})),t.list&&d(rn,{editable:(t.list,!0)}))))}),null)," "),document.getElementById("mg-upc-admin-app")),setTimeout(window.showMainLists,1e3)})(); -
user-post-collections/trunk/javascript/mg-upc-client/dist/main.js
r2770186 r2783097 1 (()=>{"use strict";var t,e,n,i,o,s,a={}, l=[],r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var o,s,a,l={};for(a in n)"key"==a?o=n[a]:"ref"==a?s=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return p(e,l,o,s,null)}function p(t,i,o,s,a){var l={type:t,props:i,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(l),l}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||o!==e.debounceRendering)&&((o=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,o,s,a;t.__d&&(s=(o=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},o)).__v=o.__v+1,I(a,o,i,e.__n,void 0!==a.ownerSVGElement,null!=o.__h?[s]:null,n,null==s?f(o):s,o.__h),S(n,o),o.__e!=s&&g(o)))}))}function y(t,e,n,i,o,s,r,c,u,d){var m,g,h,v,y,w,N,k=i&&i.__k||l,C=k.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=k[m])||h&&v.key==h.key&&v.type===h.type)k[m]=void 0;else for(g=0;g<C;g++){if((h=k[g])&&v.key==h.key&&v.type===h.type){k[g]=void 0;break}h=null}I(t,v,h=h||a,o,s,r,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(N||(N=[]),h.ref&&N.push(h.ref,null,v),N.push(g,v.__c||y,v)),null!=y?(null==w&&(w=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=P(t,v,h,k,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=w,m=C;m--;)null!=k[m]&&("function"==typeof n.type&&null!=k[m].__e&&k[m].__e==n.__d&&(n.__d=f(i,m+1)),E(k[m],k[m]));if(N)for(m=0;m<N.length;m++)A(N[m],N[++m],N[++m])}function b(t,e,n){for(var i,o=t.__k,s=0;o&&s<o.length;s++)(i=o[s])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):P(n,i,i,o,i.__e,e));return e}function w(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){w(t,e)})):e.push(t)),e}function P(t,e,n,i,o,s){var a,l,r;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||o!=s||null==o.parentNode)t:if(null==s||s.parentNode!==t)t.appendChild(o),a=null;else{for(l=s,r=0;(l=l.nextSibling)&&r<i.length;r+=2)if(l==o)break t;t.insertBefore(o,s),a=s}return void 0!==a?a:o.nextSibling}function N(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||r.test(e)?n:n+"px"}function k(t,e,n,i,o){var s;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||N(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||N(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])s=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?i||t.addEventListener(e,s?x:C,s):t.removeEventListener(e,s?x:C,s);else if("dangerouslySetInnerHTML"!==e){if(o)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,o,s,a,l,r,u){var d,p,f,g,h,v,b,w,P,N,k,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,r=n.__e=i.__e,n.__h=null,a=[r]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(w=n.props,P=(d=I.contextType)&&o[d.__c],N=d?P?P.props.value:d.__:o,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(w,N):(n.__c=p=new m(w,N),p.constructor=I,p.render=L),P&&P.sub(p),p.props=w,p.state||(p.state={}),p.context=N,p.__n=o,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(w,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&w!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,N),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,N)||n.__v===i.__v){p.props=w,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&l.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,N),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=N,p.props=w,p.__v=n,p.__P=t,k=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(o=c(c({},o),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,o,s,a,l,r,u),p.base=n.__e,n.__h=null,p.__h.length&&l.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,o,s,a,l,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=r,n.__h=!!u,a[a.indexOf(r)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,o,s,l,r,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(s=!0),null!=l)for(;v<l.length;v++)if((d=l[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,l[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=s?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),l=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(l=l&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=l)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,o){var s;for(s in n)"children"===s||"key"===s||s in e||k(t,s,null,n[s],i);for(s in e)o&&"function"!=typeof e[s]||"children"===s||"key"===s||"value"===s||"checked"===s||n[s]===e[s]||k(t,s,e[s],n[s],i)}(e,g,m,s,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,o,s&&"foreignObject"!==h,l,r,l?l[0]:i.__k&&f(i,0),c),null!=l)for(v=l.length;v--;)null!=l[v]&&u(l[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&k(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&k(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var o,s;if(e.unmount&&e.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||A(o,null,n)),null!=(o=t.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(t){e.__e(t,n)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&E(o[s],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,o){var s,l,r;e.__&&e.__(n,i),l=(s="function"==typeof o)?null:o&&o.__k||i.__k,r=[],I(i,n=(!s&&o||i).__k=d(_,null,[n]),l||a,a,void 0!==i.ownerSVGElement,!s&&o?[o]:l?null:i.firstChild?t.call(i.childNodes):null,r,!s&&o?o:l?l.__e:i.firstChild,s),S(r,n)}t=l.slice,e={__e:function(t,e,n,i){for(var o,s,a;e=e.__;)if((o=e.__c)&&!o.__)try{if((s=o.constructor)&&null!=s.getDerivedStateFromError&&(o.setState(s.getDerivedStateFromError(t)),a=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(t,i||{}),a=o.__d),a)return o.__E=o}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,s=0;var O,U,R,W,j=0,H=[],$=[],M=e.__b,B=e.__r,F=e.diffed,q=e.__c,V=e.unmount;function Q(t,n){e.__h&&e.__h(U,t,j||n),j=0;var i=U.__H||(U.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:$}),i.__[t]}function X(t){return j=1,K(st,t)}function K(t,e,n){var i=Q(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):st(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=U,!i.__c.u)){i.__c.__H.u=!0;var o=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var s=i.__c.__H.__.filter((function(t){return t.__c}));return(s.every((function(t){return!t.__N}))||!s.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!o||o(t,e,n))}}return i.__N||i.__}function G(t,n){var i=Q(O++,3);!e.__s&&ot(i.__H,n)&&(i.__=t,i.i=n,U.__H.__h.push(i))}function z(t){return j=5,J((function(){return{current:t}}),[])}function J(t,e){var n=Q(O++,7);return ot(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return j=8,J((function(){return t}),e)}function Z(t){var e=U.context[t.__c],n=Q(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){U=null,M&&M(t)},e.__r=function(t){B&&B(t),O=0;var e=(U=t.__c).__H;e&&(R===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=$,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),R=U},e.diffed=function(t){F&&F(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&W===e.requestAnimationFrame||((W=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==$&&(t.__=t.__V),t.i=void 0,t.__V=$}))),R=U=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),q&&q(t,n)},e.unmount=function(t){V&&V(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=U,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),U=e}function it(t){var e=U;t.__c=t.__(),U=e}function ot(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function st(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},lt="ui/reset",rt="ui/error",ct="ui/message",ut="ui/editing",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",wt="list/setItems",Pt="list/removeItem",Nt="list/addItem",kt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const o={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(o.body=JSON.stringify(n));const s=await fetch(Dt().root+i+e,o);s.headers.get("x-wp-nonce")&&(Dt().nonce=s.headers.get("x-wp-nonce"));const a=await s.json();return{data:a,headers:s.headers,status:s.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var o;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(o=t.data)||void 0===o?void 0:o.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){return It("DELETE","/"+t+"/items/"+e,{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Rt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function Wt(t,e){return!!t.type&&Ht(t.type,e)}function jt(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Ht(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Ht(t,e){const n=Ut(t);return!(!n||!n.supports)&&n.supports.includes(e)}const $t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Mt(t){return JSON.parse(JSON.stringify(t))}function Bt(t){return"string"!=typeof t?"":t.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2")}function Ft(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}function qt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error";if(!jQuery)return!1;const n=jQuery("<div>").addClass("mg-upc-alert mg-upc-alert-"+e);n.append(jQuery("<p>").html(t));const i=jQuery('<a class="mg-upc-alert-close" href="#"><span class="mg-upc-icon upc-font-close"></span></a>').on("click",(function(){return n.remove(),!1}));return n.append(i),n}function Vt(t,e){const{type:n,payload:i}=e;let o=!1;const s=t=>(o=a({status:"failed"}),t.error&&(o.error=t.error.message?t.error.message:"",o.errorCode=t.error.code?t.error.code:""),o),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=Mt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(o[t]=e[t]);return o};let l=function(t,e){const{type:n,payload:i}=e;let o,s;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=!1===t?{}:Mt(t)),e)for(const t in e)s[t]=e[t];return s};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Mt(t.items),i;case _t:return i;case wt:return a({items:i});case"list/addItem/failed":case Nt:return null!=i&&i.list?a(i.list):t;case kt:const e=!!i.item&&i.item;return o=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:o});case Pt:if(1===t.items.length||!1===i)return t;if(s=a(),o=s.items.filter((t=>t.post_id!==i)),Ht(t.type,"sortable")){const e=parseInt(t.items[0].position,10);o.forEach(((t,n)=>{o[n].position=e+n}))}if(Ht(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(s.vote_counter=s.vote_counter-e.votes)}return{...s,items:o};case Ct:const n=parseInt(t.items[0].position,10);o=a().items.slice();const l=a().items[i.oldIndex];return o.splice(i.oldIndex,1),o.splice(i.newIndex,0,l),isNaN(n)?(alert("positions error!"),t):(o.forEach(((t,e)=>{o[e].position=n+e})),a({items:o}));default:return t}}(t.list,e),r=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case Nt:case ht:return!1;case pt:return!1===i?t:Mt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===l&&r===t.listOfList||(o=a({listOfList:r,list:l}),t.addingPost||(o.title=o.list?o.list.title:Gt.title)),n){case"ui/mode":return a({mode:i});case lt:return{...Gt,mode:t.mode};case rt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case ct:return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ut:return a({editing:i});case mt:return o=a(),o.addingPost=i,i&&(o.title="Add to..."),o;case _t:o=a(),o.title=i.title?i.title:Gt.title,o.listTotalPages=1,o.listPage=1,o.addingPost=!1;break;case Nt:if(o=a(),null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(o.error=i.message,o.status="failed"),o.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return o=a(),o.status="loading",o.listOfList=!1,"object"==typeof i?(o.list=i,i.title&&(o.title=i.title)):o.list={ID:i},o;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/removeItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return o=a(),o.addingPost=!1,o.status="succeeded",o.error=!1,o.errorCode=!1,o.title=o.list?o.list.title:Gt.title,o;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return o=a({status:"failed"}),e.error&&e.error.message&&(o.error=e.error.message),o;case"list/addItem/failed":if(o=a(),o.addingPost=!1,o.title=o.list?o.list.title:Gt.title,null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(o.error=i.message,o.status="failed"),s(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return s(e)}return!1!==o?o:t}const Qt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:o}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((o=n)&&"object"==typeof o&&!0===o.asyncThunk){let o={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,o)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var o;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Gt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},zt=function(t,e){var n={__c:e="__cC"+s++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function Jt(t){return new Date(t).toLocaleDateString()}const Yt=function(t){const{state:e,dispatch:n}=Z(zt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){!function(t){t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()}(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",Jt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",Jt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Zt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var te,ee,ne;ne={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(ee="defaultProps")in(te=Zt)?Object.defineProperty(te,ee,{value:ne,enumerable:!0,configurable:!0,writable:!0}):te[ee]=ne;const ie=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},oe=()=>({type:lt,payload:null}),se=t=>({type:mt,payload:t}),ae=t=>({type:ut,payload:t}),le=Qt(xt,(async function(t,e){return await Ft(t)})),re=Qt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},o={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in o){const n=t.headers.get(e);n&&(i[o[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}Qt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));const ue=Qt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(re({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(re({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=Qt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=Qt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),he=Qt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),ve=Qt(wt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=Qt(Pt,(async function(t,e){const n=e.getState();return await Lt.quit(n.list.ID,t).then((i=>{if(1===n.list.items.length){const t=n.listPage,i=n.listTotalPages;return t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)})),!1}return t}))})),be=Qt(Nt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:"view"}).then((t=>{i=t.data}))}catch(t){var o;const n=null==t||null===(o=t.response)||void 0===o?void 0:o.data;i=e.rejectWithValue(n)}return i})),we=Qt(kt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Pe=Qt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],o=n.items[t],s=o.position-t+i;return await Lt.move(n.ID,o.post_id,s).then((e=>({oldIndex:t,newIndex:i})))})),Ne=Qt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),ke=Qt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(zt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Zt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Zt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Zt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Yt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ie,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[o,s]=X(!1),[a,l]=X(""),r=z({});return G((()=>{l(t.item.description)}),[t.item]),G((()=>{o&&r.current.focus()}),[o]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!o&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!o&&d("button",{onClick:()=>{s(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:o?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){l(t.target.value)},maxLength:400}),o&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{s(!1),l(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),o&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{s(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var o,s=e;s=s.__;)if((o=s.__c)&&o.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),o.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function Ue(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Re(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var o=Ue(i.__v),s=!1,a=function(){s||(s=!0,n.__R=null,o?o(l):l())};n.__R=a;var l=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},r=!0===e.__h;i.__u++||r||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var o=e.__a&&d(_,null,t.fallback);return o&&(o.__h=null),[d(_,null,e.__a?null:t.children),o]};var We=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function je(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d(je,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Re.prototype=new m).__a=function(t){var e=this,n=Ue(e.__v),i=e.o.get(t);return i[0]++,function(o){var s=function(){e.props.revealOrder?(i.push(o),We(e,t,i)):o()};n?n(s):s()}},Re.prototype.render=function(t){this.u=null,this.o=new Map;var e=w(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Re.prototype.componentDidUpdate=Re.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){We(t,n,e)}))};var $e="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Me=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Be="undefined"!=typeof document,Fe=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var qe=e.event;function Ve(){}function Qe(){return this.cancelBubble}function Xe(){return this.defaultPrevented}e.event=function(t){return qe&&(t=qe(t)),t.persist=Ve,t.isPropagationStopped=Qe,t.isDefaultPrevented=Xe,t.nativeEvent=t};var Ke={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var o=-1===e.indexOf("-");for(var s in i={},n){var a=n[s];Be&&"children"===s&&"noscript"===e||"value"===s&&"defaultValue"in n&&null==a||("defaultValue"===s&&"value"in n&&null==n.value?s="value":"download"===s&&!0===a?a="":/ondoubleclick/i.test(s)?s="ondblclick":/^onchange(textarea|input)/i.test(s+e)&&!Fe(n.type)?s="oninput":/^onfocus$/i.test(s)?s="onfocusin":/^onblur$/i.test(s)?s="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(s)?s=s.toLowerCase():o&&Me.test(s)?s=s.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(s)&&(s=s.toLowerCase(),i[s]&&(s="oninputCapture")),i[s]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=w(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=w(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Ke.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Ke))}t.$$typeof=$e,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));const nn=t=>{const e=(()=>{const[t,e]=X(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=X(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),o=t.role||"dialog",s="alertdialog"===o,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:o,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:s?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:o}=t;if(G((()=>(n&&o(n),()=>o(void 0))),[o,n]),!e)return null;const s=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),l=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),r=["first"===t.closeButtonPosition&&l,a,t.children,"last"===t.closeButtonPosition&&l].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),r)),s)};nn.defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}},function(t){function e(e,i,o,s){const a=o||s.parent(),l=a.find(".mg-upc-item-vote").attr("disabled",!0);mgUpcApiClient.vote(e,i,{context:"web",posts:n(a)}).then((function(e){t(document.body).trigger("mg_upc_vote_response",[e,a])})).catch((function(t){var e,n;l.attr("disabled",!1),null!==(e=t.response)&&void 0!==e&&null!==(n=e.data)&&void 0!==n&&n.message&&(s?s.append(qt(t.response.data.message)):a.before(qt(t.response.data.message)))}))}function n(e){return[...e.children().map((function(){return t(this).data("pid")}))].join(",")}t(".mg-upc-item-vote").on("click",(function(){const n=t(this).data("vote").split(",");return 2===n.length&&e(n[0],n[1],!1,t(this).closest(".mg-upc-item")),!1})),t((function(){t(".mg-upc-vote").each((function(){const n=t(this);e(n.data("id"),0,n.find(".mg-upc-items-container"),!1)}))})),t(document.body).on("mg_upc_vote_response",(function(e,n,i){if(!n.data)return;const o=parseInt(n.data.vote_counter,10),s=i.find(".mg-upc-item-vote");i.data("votes",o),n.data.can_vote?s.attr("disabled",!1).show():s.animate({width:0,padding:0,opacity:0},200,(function(){s.remove()})),n.data.posts.forEach((function(e){const n=i.find(".mg-upc-item[data-pid="+e.post_id+"]"),s=parseInt(e.votes,10);t(document.body).trigger("mg_upc_item_vote_set",[n,s,o])}))})),t(document.body).on("mg_upc_item_vote_set",(function(t,e,n,i){const o=i>0?Math.round(1e3*n/i)/10:0,s=e.find(".mg-upc-votes");s.find(".mg-upc-item-votes-number").html(n),s.find(".mg-upc-item-percent").html(o+"%"),s.find(".mg-upc-item-bar-progress").animate({width:o+"%"}),s.show()}))}(jQuery),function(t){t(".mg-upc-add-product-to-list").on("click",(function(){let e=t(this).data("id");const n=t(this).closest(".product,.summary").find("[name='variation_id']");return n.length>0&&parseInt(n.val(),10)>0&&(e=n.val()),window.addItemToList(e),!1}));const e="mg-upc-btn-loading",n="mg-upc-product-added",i="mg-upc-product-error",o="Sorry, an error occurred.";function s(a,l,r){if(l.hasClass(e))return!1;let c={product_id:l.data("product"),quantity:l.data("quantity")};if("0"==c.quantity){if(!r)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,l,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[l,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){l.removeClass(n+" "+i).addClass(e)},success:function(i){l.removeClass(e),i&&(i.error&&i.product_url?alert(o):(l.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,l])))},error:function(){l.addClass(i).removeClass(e),alert(o)}}),!1}function s(a,l,r){if(l.hasClass(e))return!1;let c={product_id:l.data("product"),quantity:l.data("quantity")};if("0"==c.quantity){if(!r)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,l,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[l,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){l.removeClass(n+" "+i).addClass(e)},success:function(i){l.removeClass(e),i&&(i.error&&i.product_url?alert(o):(l.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,l])))},error:function(){l.addClass(i).removeClass(e),alert(o)}}),!1}t((function(){if("undefined"==typeof wc_add_to_cart_params)return!1;t(".mg-upc-item-product").removeClass("mg-upc-hide").on("click",(function(e){return s(e,t(this),!1)})),t(".mg-upc-add-list-to-cart").removeClass("mg-upc-hide").on("click",(function(s){const a=t(this);return a.hasClass(e)||(a.removeClass(n+" "+i).addClass(e),window.mgUpcAddListToCart(t(this).data("id")).then((function(i){a.removeClass(e),i.err&&a.before(qt(Bt(i.err))),i.msg&&a.before(qt(Bt(i.msg),"success")),a.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,a])})).catch((t=>{var n,i;a.removeClass(e),null!==(n=t.response)&&void 0!==n&&null!==(i=n.data)&&void 0!==i&&i.message?a.before(qt(Bt(t.response.data.message))):alert(o)}))),!1}))}))}(jQuery);const on=function(t){var e;const[n,i]=X(""),[o,s]=X(""),[a,l]=X(""),[r,c]=X(""),u=J((()=>jt(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),l(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),s(t.list.content),l(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=Ut(a))&&void 0!==t&&t.available_statuses&&-1===Ut(a).available_statuses.indexOf(r)&&c(Ut(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Ht(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Ht(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:o,onChange:function(t){s(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==o?void 0:o.length),"/500")),""!==a&&!Ut(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=Ut(a))||void 0===e?void 0:e.available_statuses)&&Ut(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:r,onChange:function(t){c(t.target.value)}},Ut(a).available_statuses.map(((t,e)=>{if(function(t){const e=Rt(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Rt(t);return e?e.label:t}(t))})))),""!==a&&Ut(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:o,type:a,status:r})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=X(!1),[o,s]=X(""),[a,l]=X(null===(e=t.item)||void 0===e?void 0:e.quantity),r=z({});G((()=>{s(t.item.description)}),[t.item]),G((()=>{n&&r.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},Wt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),Wt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return Wt(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&Wt(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===o&&d("span",null,at("Add Comment")),""!==o&&d("span",null,at("Edit Comment"))),d("input",{ref:r,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:o,onChange:function(t){s(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),s(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(o)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&Wt(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){l(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},an=function(t){return new Promise((function(e,n){const i=document.createElement("script");let o=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){o||this.readyState&&"complete"!=this.readyState||(o=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},ln=function(t){var e,n,i;const o=z(null),s=z((e=>{t.onMove(e)}));return G((()=>{s.current=t.onMove})),G((()=>{let e=!1;if(Wt(t.list,"sortable")){const t=()=>{e=Sortable.create(o.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){s.current(t)}})};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},Wt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Zt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),Wt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Zt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Zt,{count:2})))))),d("ul",{ref:o,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),Wt(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},rn=function(t){const e=z(null),n=z(null),i=at("Copy"),[o,s]=X(i);G((()=>{let t=null;o!==i&&(t=setTimeout((()=>{s(i),clearTimeout(t)}),2e3))}),[o]);const a=encodeURIComponent(t.link),l=encodeURIComponent(t.title);let r=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+l},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+l},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+l},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+l},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+l},{slug:"email",name:at("Email"),url:"mailto:?subject="+l+"&body="+a}];return void 0!==Dt().shareButtons&&(r=r.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?s(at("Copied!")):s("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,o)),r.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},cn=function(t){var e;const{state:n,dispatch:i}=Z(zt),[o,s]=X(!1),a=z(!1),l=z(!1);function r(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,o=!1;if(t&&Wt(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(Ne(t.oldIndex))}})),a.current&&n.listPage>1&&(o=Sortable.create(l.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),o&&o.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{s(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(on,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const o={};o.title=t.title,o.content=t.content,o.type=t.type,o.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(o.adding=n.addingPost.post_id),i(he(o))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(ae(!1)),-1===n.list.ID&&(i(fe(!1)),i(oe()),i(re()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Ht(i,"editable_title")||Ht(i,"editable_content")||(null===(e=Ut(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(ae(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>s(!o)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(le(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),o&&n.list.link&&d(rn,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:Bt(n.list.content)}}),d(Zt,{count:3}),d(ln,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Pe(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(we(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(we(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ie,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){r(n.listPage-1)},onNext:function(){r(n.listPage+1)},prevRef:l,nextRef:a}))};function un(t){return parseInt(t.author,10)===parseInt(Dt().user_id,10)}function dn(){"replaceState"in history?(history.replaceState("",document.title,location.pathname),history.go(-1)):location.hash=""}D(d((t=>{const[e,n]=K(Vt,Gt);return d(zt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(zt),n=J((()=>jt(t.addingPost)),[t.addingPost]),i=z(!1);let o="listOfList";if(t.addingPost)o=t.editing?"addingToNew":"adding";else if(t.editing){var s;o=-1!==(null===(s=t.list)||void 0===s?void 0:s.ID)?"edit":"new"}else o=t.list?"list":"listOfList";const a={container:"mg-upc-dg-container",overlay:"mg-upc-dg-overlay",dialog:"mg-upc-dg-content"+(t.errorCode?" mg-upc-err-"+t.errorCode:""),title:"mg-upc-dg-title",closeButton:"mg-upc-dg-close"};G((()=>{window.showMyLists=function(){l()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e(oe()),n||r(t)},window.mgUpcAddListToCart=Ft}),[i.current,e]);const l=()=>{e(oe()),e(re()),i.current.show()},r=t=>{e(se({post_id:t})),e(re({addingPost:t})),i.current.show()};function c(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const u="list"===o||"new"===o||"edit"===o||"addingToNew"===o;return d(nn,{id:"mg-upc-dg-dialog",dialogRef:function(t){i.current=t},title:t.title,classNames:a,onBack:!!u&&function(){switch(o){case"list":default:l();break;case"new":e(fe(!1)),e(ae(!1)),l();break;case"edit":e(ae(!1));break;case"addingToNew":e(fe(!1)),e(ae(!1)),e(re({addingPost:t.addingPost.post_id}))}}},d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+o},d("div",{className:"mg-upc-dg-wait"}),t.message&&d("div",{className:"mg-upc-dg-msg"},t.message,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:ct,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:rt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===o||"adding"===o)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},n.length>0&&d("button",{className:"mg-list-new",onClick:function(t){e(ae(!0)),e(fe(!0)),i.current.show()}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d(xe,{lists:t.listOfList,onSelect:function(n){e(ae(!1)),t.addingPost?e(be(n.ID,t.addingPost)):(e(fe(n)),i.current.show())},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){c(t.page-1)},loadNext:function(){c(t.page+1)}})),t.list&&d(cn,{editable:un(t.list)}))))}),null)," "),document.querySelector("body")),"#my-lists"===location.hash&&dn(),window.addEventListener("hashchange",(function(){"#my-lists"===location.hash&&(window.showMyLists(),dn())}),!1),window.mgUpcApiClient=Lt})();1 (()=>{"use strict";var t,e,n,i,o,s,a={},r=[],l=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(e,n,i){var o,s,a,r={};for(a in n)"key"==a?o=n[a]:"ref"==a?s=n[a]:r[a]=n[a];if(arguments.length>2&&(r.children=arguments.length>3?t.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===r[a]&&(r[a]=e.defaultProps[a]);return p(e,r,o,s,null)}function p(t,i,o,s,a){var r={type:t,props:i,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==a?++n:a};return null==a&&null!=e.vnode&&e.vnode(r),r}function _(t){return t.children}function m(t,e){this.props=t,this.context=e}function f(t,e){if(null==e)return t.__?f(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?f(t):null}function g(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return g(t)}}function h(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||o!==e.debounceRendering)&&((o=e.debounceRendering)||setTimeout)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,i,o,s,a;t.__d&&(s=(o=(e=t).__v).__e,(a=e.__P)&&(n=[],(i=c({},o)).__v=o.__v+1,I(a,o,i,e.__n,void 0!==a.ownerSVGElement,null!=o.__h?[s]:null,n,null==s?f(o):s,o.__h),S(n,o),o.__e!=s&&g(o)))}))}function y(t,e,n,i,o,s,l,c,u,d){var m,g,h,v,y,w,N,k=i&&i.__k||r,C=k.length;for(n.__k=[],m=0;m<e.length;m++)if(null!=(v=n.__k[m]=null==(v=e[m])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?p(null,v,null,null,v):Array.isArray(v)?p(_,{children:v},null,null,null):v.__b>0?p(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(h=k[m])||h&&v.key==h.key&&v.type===h.type)k[m]=void 0;else for(g=0;g<C;g++){if((h=k[g])&&v.key==h.key&&v.type===h.type){k[g]=void 0;break}h=null}I(t,v,h=h||a,o,s,l,c,u,d),y=v.__e,(g=v.ref)&&h.ref!=g&&(N||(N=[]),h.ref&&N.push(h.ref,null,v),N.push(g,v.__c||y,v)),null!=y?(null==w&&(w=y),"function"==typeof v.type&&v.__k===h.__k?v.__d=u=b(v,u,t):u=P(t,v,h,k,y,u),"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=f(h))}for(n.__e=w,m=C;m--;)null!=k[m]&&("function"==typeof n.type&&null!=k[m].__e&&k[m].__e==n.__d&&(n.__d=f(i,m+1)),E(k[m],k[m]));if(N)for(m=0;m<N.length;m++)A(N[m],N[++m],N[++m])}function b(t,e,n){for(var i,o=t.__k,s=0;o&&s<o.length;s++)(i=o[s])&&(i.__=t,e="function"==typeof i.type?b(i,e,n):P(n,i,i,o,i.__e,e));return e}function w(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){w(t,e)})):e.push(t)),e}function P(t,e,n,i,o,s){var a,r,l;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(null==n||o!=s||null==o.parentNode)t:if(null==s||s.parentNode!==t)t.appendChild(o),a=null;else{for(r=s,l=0;(r=r.nextSibling)&&l<i.length;l+=2)if(r==o)break t;t.insertBefore(o,s),a=s}return void 0!==a?a:o.nextSibling}function N(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||l.test(e)?n:n+"px"}function k(t,e,n,i,o){var s;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof i&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||N(t.style,e,"");if(n)for(e in n)i&&n[e]===i[e]||N(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])s=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?i||t.addEventListener(e,s?x:C,s):t.removeEventListener(e,s?x:C,s);else if("dangerouslySetInnerHTML"!==e){if(o)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function C(t){this.l[t.type+!1](e.event?e.event(t):t)}function x(t){this.l[t.type+!0](e.event?e.event(t):t)}function I(t,n,i,o,s,a,r,l,u){var d,p,f,g,h,v,b,w,P,N,k,C,x,I=n.type;if(void 0!==n.constructor)return null;null!=i.__h&&(u=i.__h,l=n.__e=i.__e,n.__h=null,a=[l]),(d=e.__b)&&d(n);try{t:if("function"==typeof I){if(w=n.props,P=(d=I.contextType)&&o[d.__c],N=d?P?P.props.value:d.__:o,i.__c?b=(p=n.__c=i.__c).__=p.__E:("prototype"in I&&I.prototype.render?n.__c=p=new I(w,N):(n.__c=p=new m(w,N),p.constructor=I,p.render=L),P&&P.sub(p),p.props=w,p.state||(p.state={}),p.context=N,p.__n=o,f=p.__d=!0,p.__h=[]),null==p.__s&&(p.__s=p.state),null!=I.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=c({},p.__s)),c(p.__s,I.getDerivedStateFromProps(w,p.__s))),g=p.props,h=p.state,f)null==I.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==I.getDerivedStateFromProps&&w!==g&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,N),!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,N)||n.__v===i.__v){p.props=w,p.state=p.__s,n.__v!==i.__v&&(p.__d=!1),p.__v=n,n.__e=i.__e,n.__k=i.__k,n.__k.forEach((function(t){t&&(t.__=n)})),p.__h.length&&r.push(p);break t}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,N),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(g,h,v)}))}if(p.context=N,p.props=w,p.__v=n,p.__P=t,k=e.__r,C=0,"prototype"in I&&I.prototype.render)p.state=p.__s,p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context);else do{p.__d=!1,k&&k(n),d=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++C<25);p.state=p.__s,null!=p.getChildContext&&(o=c(c({},o),p.getChildContext())),f||null==p.getSnapshotBeforeUpdate||(v=p.getSnapshotBeforeUpdate(g,h)),x=null!=d&&d.type===_&&null==d.key?d.props.children:d,y(t,Array.isArray(x)?x:[x],n,i,o,s,a,r,l,u),p.base=n.__e,n.__h=null,p.__h.length&&r.push(p),b&&(p.__E=p.__=null),p.__e=!1}else null==a&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=T(i.__e,n,i,o,s,a,r,u);(d=e.diffed)&&d(n)}catch(t){n.__v=null,(u||null!=a)&&(n.__e=l,n.__h=!!u,a[a.indexOf(l)]=null),e.__e(t,n,i)}}function S(t,n){e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function T(e,n,i,o,s,r,l,c){var d,p,_,m=i.props,g=n.props,h=n.type,v=0;if("svg"===h&&(s=!0),null!=r)for(;v<r.length;v++)if((d=r[v])&&"setAttribute"in d==!!h&&(h?d.localName===h:3===d.nodeType)){e=d,r[v]=null;break}if(null==e){if(null===h)return document.createTextNode(g);e=s?document.createElementNS("http://www.w3.org/2000/svg",h):document.createElement(h,g.is&&g),r=null,c=!1}if(null===h)m===g||c&&e.data===g||(e.data=g);else{if(r=r&&t.call(e.childNodes),p=(m=i.props||a).dangerouslySetInnerHTML,_=g.dangerouslySetInnerHTML,!c){if(null!=r)for(m={},v=0;v<e.attributes.length;v++)m[e.attributes[v].name]=e.attributes[v].value;(_||p)&&(_&&(p&&_.__html==p.__html||_.__html===e.innerHTML)||(e.innerHTML=_&&_.__html||""))}if(function(t,e,n,i,o){var s;for(s in n)"children"===s||"key"===s||s in e||k(t,s,null,n[s],i);for(s in e)o&&"function"!=typeof e[s]||"children"===s||"key"===s||"value"===s||"checked"===s||n[s]===e[s]||k(t,s,e[s],n[s],i)}(e,g,m,s,c),_)n.__k=[];else if(v=n.props.children,y(e,Array.isArray(v)?v:[v],n,i,o,s&&"foreignObject"!==h,r,l,r?r[0]:i.__k&&f(i,0),c),null!=r)for(v=r.length;v--;)null!=r[v]&&u(r[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==e.value||"progress"===h&&!v||"option"===h&&v!==m.value)&&k(e,"value",v,m.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==e.checked&&k(e,"checked",v,m.checked,!1))}return e}function A(t,n,i){try{"function"==typeof t?t(n):t.current=n}catch(t){e.__e(t,i)}}function E(t,n,i){var o,s;if(e.unmount&&e.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||A(o,null,n)),null!=(o=t.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(t){e.__e(t,n)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&E(o[s],n,"function"!=typeof t.type);i||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function D(n,i,o){var s,r,l;e.__&&e.__(n,i),r=(s="function"==typeof o)?null:o&&o.__k||i.__k,l=[],I(i,n=(!s&&o||i).__k=d(_,null,[n]),r||a,a,void 0!==i.ownerSVGElement,!s&&o?[o]:r?null:i.firstChild?t.call(i.childNodes):null,l,!s&&o?o:r?r.__e:i.firstChild,s),S(l,n)}t=r.slice,e={__e:function(t,e,n,i){for(var o,s,a;e=e.__;)if((o=e.__c)&&!o.__)try{if((s=o.constructor)&&null!=s.getDerivedStateFromError&&(o.setState(s.getDerivedStateFromError(t)),a=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(t,i||{}),a=o.__d),a)return o.__E=o}catch(e){t=e}throw t}},n=0,m.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c({},this.state),"function"==typeof t&&(t=t(c({},n),this.props)),t&&c(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),h(this))},m.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),h(this))},m.prototype.render=_,i=[],v.__r=0,s=0;var O,j,U,R,W=0,H=[],$=[],M=e.__b,F=e.__r,B=e.diffed,Q=e.__c,q=e.unmount;function V(t,n){e.__h&&e.__h(j,t,W||n),W=0;var i=j.__H||(j.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:$}),i.__[t]}function X(t){return W=1,K(st,t)}function K(t,e,n){var i=V(O++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):st(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=j,!i.__c.u)){i.__c.__H.u=!0;var o=i.__c.shouldComponentUpdate;i.__c.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var s=i.__c.__H.__.filter((function(t){return t.__c}));return(s.every((function(t){return!t.__N}))||!s.every((function(t){if(!t.__N)return!0;var e=t.__[0];return t.__=t.__N,t.__N=void 0,e===t.__[0]})))&&(!o||o(t,e,n))}}return i.__N||i.__}function G(t,n){var i=V(O++,3);!e.__s&&ot(i.__H,n)&&(i.__=t,i.i=n,j.__H.__h.push(i))}function z(t){return W=5,J((function(){return{current:t}}),[])}function J(t,e){var n=V(O++,7);return ot(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function Y(t,e){return W=8,J((function(){return t}),e)}function Z(t){var e=j.context[t.__c],n=V(O++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(j)),e.props.value):t.__}function tt(){for(var t;t=H.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(it),t.__H.__h=[]}catch(n){t.__H.__h=[],e.__e(n,t.__v)}}e.__b=function(t){j=null,M&&M(t)},e.__r=function(t){F&&F(t),O=0;var e=(j=t.__c).__H;e&&(U===j?(e.__h=[],j.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=$,t.__N=t.i=void 0}))):(e.__h.forEach(nt),e.__h.forEach(it),e.__h=[])),U=j},e.diffed=function(t){B&&B(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(1!==H.push(n)&&R===e.requestAnimationFrame||((R=e.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(i),et&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);et&&(e=requestAnimationFrame(n))})(tt)),n.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.__V!==$&&(t.__=t.__V),t.i=void 0,t.__V=$}))),U=j=null},e.__c=function(t,n){n.some((function(t){try{t.__h.forEach(nt),t.__h=t.__h.filter((function(t){return!t.__||it(t)}))}catch(i){n.some((function(t){t.__h&&(t.__h=[])})),n=[],e.__e(i,t.__v)}})),Q&&Q(t,n)},e.unmount=function(t){q&&q(t);var n,i=t.__c;i&&i.__H&&(i.__H.__.forEach((function(t){try{nt(t)}catch(t){n=t}})),n&&e.__e(n,i.__v))};var et="function"==typeof requestAnimationFrame;function nt(t){var e=j,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),j=e}function it(t){var e=j;t.__c=t.__(),j=e}function ot(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function st(t,e){return"function"==typeof e?e(t):e}const at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return MgUpcTexts&&MgUpcTexts[t]?e?e.reduce((function(t,e){return t.replace(/%s/,e)}),MgUpcTexts[t]):MgUpcTexts[t]:t},rt="ui/reset",lt="ui/error",ct="ui/message",ut="ui/editing",dt="listOfLists/set",pt="listOfLists/remove",_t="listOfLists/create",mt="listOfList/addingPost",ft="listOfList/setPage",gt="listOfList/setTotalPages",ht="list/set",vt="list/update",yt="list/setPage",bt="list/setTotalPages",wt="list/setItems",Pt="list/removeItem",Nt="list/addItem",kt="list/updateItem",Ct="list/moveItem",xt="list/cart",It=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"mg-upc/v1/lists";if(void 0===Dt().nonce){const t=new FormData;t.append("action","mg_upc_user");const e={method:"POST",credentials:"same-origin",referrerPolicy:"no-referrer",body:t},n=await fetch(Dt().ajaxUrl,e),i=await n.json();i.nonce&&(Dt().nonce=i.nonce),i.user_id&&(Dt().user_id=i.user_id)}const o={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":Dt().nonce},referrerPolicy:"no-referrer"};"GET"!==t&&n&&(o.body=JSON.stringify(n));const s=await fetch(Dt().root+i+e,o);s.headers.get("x-wp-nonce")&&(Dt().nonce=s.headers.get("x-wp-nonce"));const a=await s.json();return{data:a,headers:s.headers,status:s.status}};function St(t){const e=Object.entries(t).filter((t=>{let[,e]=t;return null!=e})).map((t=>{let[e,n]=t;return`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`})),n=-1!==Dt().root.indexOf("?")?"&":"?";return e.length>0?`${n}${e.join("&")}`:""}class Tt extends Error{constructor(t,e){var n;super(t),this.name="MgApiError",this.code=null==e||null===(n=e.data)||void 0===n?void 0:n.code,this.response=e}}function At(t){var e,n;let i=null==t||null===(e=t.data)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.status;var o;if(!i&&t.status&&(i=t.status),400===i||401===i||403===i||404===i||409===i||500===i)throw new Tt(null==t||null===(o=t.data)||void 0===o?void 0:o.message,t)}let Et={my:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return It("GET","/My"+St(t),{}).then((function(t){return At(t),t}))},discover:function(t){return It("GET","/"+St(t),{}).then((function(t){return At(t),t}))},get:function(t){return It("GET","/"+t,{}).then((function(t){return At(t),t}))},cart:function(t){return It("POST","/cart",{list:t},"mg-upc/v1").then((function(t){return At(t),t}))},items:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It("GET","/"+t+"/items"+St(e),{}).then((function(t){return At(t),t}))},delete:function(t){return It("DELETE","/"+t,{}).then((function(t){return At(t),t}))},create:function(t){return It("POST","",t).then((function(t){return At(t),t}))},update:function(t){let e=t.id;return delete t.id,It("PATCH","/"+e,t).then((function(t){return At(t),t}))},add:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"object"!=typeof e&&(e={post_id:e}),It("POST","/"+t+"/items"+St(n),e).then((function(t){return At(t),t}))},quit:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("DELETE","/"+t+"/items/"+e+St(n),{}).then((function(t){return At(t),t}))},updateItem:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,n).then((function(t){return At(t),t}))},vote:function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return It("POST","/"+t+"/items/"+e+"/vote",n).then((function(t){return At(t),t}))},move:function(t,e,n){return It("PATCH","/"+t+"/items/"+e,{position:n}).then((function(t){return At(t),t}))}};const Lt=Et;function Dt(){return MgUserPostCollections}function Ot(){var t;return null===(t=Dt())||void 0===t?void 0:t.sortable}function jt(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.types;return!(!n||!n[t])&&n[t]}function Ut(t){var e;const n=null===(e=Dt())||void 0===e?void 0:e.statuses;return!(!n||!n[t])&&n[t]}function Rt(t,e){return!!t.type&&Ht(t.type,e)}function Wt(t){var e;const n=[],i=null===(e=Dt())||void 0===e?void 0:e.types;for(const e in i)i.hasOwnProperty(e)&&(Ht(e,"always_exists")||(null!=t&&t.type?i[e].available_post_types.includes(t.type)&&n.push(i[e]):n.push(i[e])));return n}function Ht(t,e){const n=jt(t);return!(!n||!n.supports)&&n.supports.includes(e)}const $t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=";function Mt(t){return JSON.parse(JSON.stringify(t))}function Ft(t){return"string"!=typeof t?"":t.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2")}function Bt(t){return Lt.cart(t).then((t=>(jQuery&&t.data.fragments&&t.data.cart_hash&&jQuery(document.body).trigger("added_to_cart",[t.data.fragments,t.data.cart_hash]),t.data)))}function Qt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error";if(!jQuery)return!1;const n=jQuery("<div>").addClass("mg-upc-alert mg-upc-alert-"+e);n.append(jQuery("<p>").html(t));const i=jQuery('<a class="mg-upc-alert-close" href="#"><span class="mg-upc-icon upc-font-close"></span></a>').on("click",(function(){return n.remove(),!1}));return n.append(i),n}function qt(t,e){const{type:n,payload:i}=e;let o=!1;const s=t=>(o=a({status:"failed"}),t.error&&(o.error=t.error.message?t.error.message:"",o.errorCode=t.error.code?t.error.code:""),o),a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(o||(o=Mt(t)),e)for(const t in e)e.hasOwnProperty(t)&&(o[t]=e[t]);return o};let r=function(t,e){const{type:n,payload:i}=e;let o,s;const a=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(s||(s=!1===t?{}:Mt(t)),e)for(const t in e)s[t]=e[t];return s};switch(n){case ht:return!0===i?{ID:-1,title:"",content:"",status:"",type:""}:i;case vt:return i.items=Mt(t.items),i;case _t:return i;case wt:return a({items:i});case"list/addItem/failed":case Nt:return null!=i&&i.list?a(i.list):t;case kt:const e=!!i.item&&i.item;return o=a().items.map((t=>t.post_id===i.post_id?e||Object.assign({},t,i):{...t})),a({items:o});case Pt:if(!t.items||1===t.items.length||!1===i)return t;if(s=a(),o=s.items.filter((t=>t.post_id!==i)),Ht(t.type,"sortable")){const e=parseInt(t.items[0].position,10);o.forEach(((t,n)=>{o[n].position=e+n}))}if(Ht(t.type,"vote")){const e=t.items.find((t=>t.post_id==i));e&&(s.vote_counter=s.vote_counter-e.votes)}return{...s,items:o};case Ct:const n=parseInt(t.items[0].position,10);o=a().items.slice();const r=a().items[i.oldIndex];return o.splice(i.oldIndex,1),o.splice(i.newIndex,0,r),isNaN(n)?(alert("positions error!"),t):(o.forEach(((t,e)=>{o[e].position=n+e})),a({items:o}));default:return t}}(t.list,e),l=function(t,e){const{type:n,payload:i}=e;switch(n){case dt:return i;case Nt:case ht:return!1;case pt:return!1===i?t:Mt(t.filter((t=>t.ID!=i)));default:return t}}(t.listOfList,e);switch(t.list===r&&l===t.listOfList||(o=a({listOfList:l,list:r}),t.addingPost||(o.title=o.list?o.list.title:Gt.title)),n){case"ui/mode":return a({mode:i});case rt:return{...Gt,mode:t.mode};case lt:return a(!1===i?{error:!1,errorCode:!1}:{error:i});case ct:return a(!1===i?{message:!1,errorCode:!1}:{message:i});case xt:const n=a();return i.msg&&(n.message=i.msg),i.err&&(n.error=i.err),n;case ut:return a({editing:i});case mt:return o=a(),o.addingPost=i,i&&(o.title="Add to..."),o;case _t:o=a(),o.title=i.title?i.title:Gt.title,o.listTotalPages=1,o.listPage=1,o.addingPost=!1;break;case Nt:if(o=a(),null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}i.message&&(o.error=i.message,o.status="failed"),o.addingPost=!1;break;case ft:return a({page:i});case gt:return a({totalPages:i});case yt:return a({listPage:i});case bt:return a({listTotalPages:i});case"list/set/loading":return o=a(),o.status="loading",o.listOfList=!1,"object"==typeof i?(o.list=i,i.title&&(o.title=i.title)):o.list={ID:i},o;case"list/removeItem/loading":return o=a({status:"loading"}),"object"==typeof i&&i.list_id&&(o.list={ID:i.list_id}),o;case"listOfLists/set/loading":case"list/setItems/loading":case"list/updateItem/loading":case"list/addItem/loading":case"list/moveItemNext/loading":case"list/moveItemPrev/loading":case"list/update/loading":case _t+"/loading":case"list/cart/loading":return a({status:"loading"});case"list/addItem/succeeded":return o=a(),o.addingPost=!1,o.status="succeeded",o.error=!1,o.errorCode=!1,o.title=o.list?o.list.title:Gt.title,o;case"list/cart/succeeded":return a({status:"succeeded",errorCode:!1});case"list/set/succeeded":if(!1===t.list)break;return a({status:"succeeded",error:!1,errorCode:!1});case"listOfLists/set/succeeded":case"list/setItems/succeeded":case"list/updateItem/succeeded":case"list/removeItem/succeeded":case"list/moveItem/succeeded":case"list/moveItemNext/succeeded":case"list/moveItemPrev/succeeded":case"list/update/succeeded":case _t+"/succeeded":return a({status:"succeeded",error:!1,errorCode:!1});case _t+"/failed":return o=a({status:"failed"}),e.error&&e.error.message&&(o.error=e.error.message),o;case"list/addItem/failed":if(o=a(),o.addingPost=!1,o.title=o.list?o.list.title:Gt.title,null!=i&&i.list){const t=i.list;o.title=t.title?t.title:Gt.title;const e=null==t?void 0:t.items_page;e&&(o.listTotalPages=e["X-WP-TotalPages"]?e["X-WP-TotalPages"]:1,o.listPage=e["X-WP-Page"]?e["X-WP-Page"]:1)}return i.message&&(o.error=i.message,o.status="failed"),s(e);case"listOfLists/set/failed":case"list/setItems/failed":case"list/updateItem/failed":case"list/removeItem/failed":case"list/moveItem/failed":case"list/moveItemNext/failed":case"list/moveItemPrev/failed":case"list/update/failed":case"list/set/failed":case"list/cart/failed":return s(e)}return!1!==o?o:t}const Vt=(t,e)=>function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;for(var i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];return{asyncThunk:!0,payload:e,type:t,arg:n,extra:o}};class Xt extends Error{constructor(t,e){super(t),this.name="MgUpcRejectWithValue",this.value=e}}const Kt=(t,e)=>n=>{let i;if((o=n)&&"object"==typeof o&&!0===o.asyncThunk){let o={dispatch:Kt(t,e),getState:e,extra:n.extra,rejectWithValue:t=>new Xt(n.type+": rejectWithValue",t)};t({type:n.type+"/loading",payload:n.arg}),i=n.payload(n.arg,o)}else{if(!(t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)(n.payload))return void t(n);t({type:n.type+"/loading"}),i=n.payload}var o;i.then((e=>{e instanceof Xt?t({type:n.type+"/failed",payload:e.value}):(t({type:n.type,payload:e}),t({type:n.type+"/succeeded"}))})).catch((e=>{t(e instanceof Xt?{type:n.type+"/failed",payload:e.value}:{type:n.type+"/failed",error:e})}))},Gt={list:!1,listOfList:!1,addingPost:null,status:"idle",error:null,message:null,errorCode:null,editing:!1,title:at("My Lists"),actualAction:"init",page:1,totalPages:1,listPage:1,listTotalPages:1,mode:"my"},zt=function(t,e){var n={__c:e="__cC"+s++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(h)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}({});function Jt(t){return new Date(t).toLocaleDateString()}const Yt=function(t){const{state:e,dispatch:n}=Z(zt);return d("li",{className:"mg-upc-dg-item-list",onClick:t.onClick,onKeyPress:e=>{13===e.keyCode&&t.onClick(e)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.list.type}),d("div",{className:"mg-upc-dg-item-title"},d("span",null,t.list.title),"my"!==e.mode&&d(_,null,d("span",null,d("a",{href:"#",onClick:function(e){!function(t){t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()}(e),function(t,e){const n=new URLSearchParams(document.location.hash.substring(1));n.set("author",e);let i=n.toString();""!==i&&(i="#"+i),window.location.hash=i}(0,t.list.author)}},t.list.user_login),d("span",{className:"mg-upc-list-dates"},d("i",null," ",d("b",null,"Created:")," ",Jt(t.list.created)),d("i",null," ",d("b",null,"Modified:")," ",Jt(t.list.modified)))))),d("span",{className:"mg-upc-dg-item-count"},t.list.count),d("span",{className:"mg-upc-dg-item-actions"},t.onRemove&&d("button",{"aria-label":at("Remove List"),onClick:e=>{e.stopPropagation(),t.onRemove(t.list)}},d("span",{className:"mg-upc-icon upc-font-trash"}))))};class Zt extends m{render(){const t=[];for(let e=0;e<this.props.count;e++){let n=this.props.styles?this.props.styles:{};null!=this.props.width&&(n.width=this.props.width),null!=this.props.height&&(n.height=this.props.height),null!==this.props.width&&null!==this.props.height&&this.props.circle&&(n.borderRadius="50%"),t.push(d("span",{key:e,className:"mg-upc-dg-loading-skeleton",style:n},""))}const e=this.props.wrapper;return d("span",null,e?t.map(((t,n)=>d(e,{key:n},t,""))):t)}}var te,ee,ne;ne={count:1,duration:1.2,width:null,wrapper:null,height:null,circle:!1},(ee="defaultProps")in(te=Zt)?Object.defineProperty(te,ee,{value:ne,enumerable:!0,configurable:!0,writable:!0}):te[ee]=ne;const ie=function(t){return d("div",{className:"mg-upc-dg-pagination-div"},d("button",{className:1===t.page?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.prevRef,disabled:1===t.page,"aria-label":at("Previous page"),title:at("Previous page"),onClick:t.onPreview},d("span",{className:"mg-upc-icon upc-font-arrow_left"})),d("span",{className:t.totalPages>1?"mg-upc-dg-pagination-current":"mg-upc-dg-hidden mg-upc-dg-pagination-current"},t.page),d("button",{className:t.page>=t.totalPages?"mg-upc-dg-hidden mg-upc-dg-pagination":"mg-upc-dg-pagination",ref:t.nextRef,disabled:t.page>=t.totalPages,"aria-label":at("Next page"),title:at("Next page"),onClick:t.onNext},d("span",{className:"mg-upc-icon upc-font-arrow_right"})))},oe=()=>({type:rt,payload:null}),se=t=>({type:mt,payload:t}),ae=t=>({type:ut,payload:t}),re=Vt(xt,(async function(t,e){return await Bt(t)})),le=Vt(dt,(async function(t,e){var n;const i=null===(n=t)||void 0===n?void 0:n.addingPost;return null===t&&(t={}),t.addingPost?t.adding=t.addingPost:(t.adding="",delete t.adding),await Lt.my(t).then((t=>ce(t,e,i)))}));function ce(t,e,n){if(t.headers.get("x-wp-page")&&(e.dispatch(de(parseInt(t.headers.get("x-wp-page"),10))),e.dispatch(pe(parseInt(t.headers.get("X-WP-TotalPages"),10)))),n&&t.headers.get("X-WP-Post-Type")){const i={post_id:n},o={"X-WP-Post-Type":"type","X-WP-Post-Title":"title","X-WP-Post-Image":"image"};for(const e in o){const n=t.headers.get(e);n&&(i[o[e]]=decodeURIComponent(n))}e.dispatch(se(i))}return t.data}Vt(dt,(async function(t,e){return null===t&&(t={}),await Lt.discover(t).then((t=>ce(t,e,!1)))}));const ue=Vt(pt,(async function(t,e){return await Lt.delete(t).then((n=>{if(1===e.getState().listOfList.length){const n=e.getState().page,i=e.getState().totalPages;if(n<i)e.dispatch(le({page:n}));else{if(!(n>1&&n===i))return t;e.dispatch(le({page:n-1}))}return!1}return t}))})),de=t=>({type:ft,payload:t}),pe=t=>({type:gt,payload:t}),_e=t=>({type:yt,payload:t}),me=t=>({type:bt,payload:t}),fe=Vt(ht,(async function(t,e){return!1===t||!0===t?t:await Lt.get("object"==typeof t?t.ID:t).then((t=>(Ce(t,e.dispatch),t.data)))})),ge=Vt(vt,(async function(t,e){return await Lt.update(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),he=Vt(_t,(async function(t,e){return null===t&&(t={}),t.adding&&t.adding!==e.getState().addingPost&&e.dispatch(se({id:t.addingPost})),await Lt.create(t).then((t=>(e.dispatch(ae(!1)),Ce(t,e.dispatch),t.data)))})),ve=Vt(wt,(async function(t,e){return await Lt.items(e.getState().list.ID,t).then((t=>(Ce(t,e.dispatch),t.data)))})),ye=Vt(Pt,(async function(t,e){const n=e.getState();var i=e.extra.length>0?e.extra[0]:n.list.ID;const o=e.extra.length>1?e.extra[1]:"view";return await Lt.quit(i,t,{context:o}).then((s=>{if(s.data&&s.data.list_id,n.list&&n.list.ID){if(1===n.list.items.length){if(e.dispatch(ve({page})),n.list&&"view"===o){const t=n.listPage,i=n.listTotalPages;t<i?e.dispatch(ve({page:t})):t===i&&e.dispatch(ve({page:Math.max(1,t-1)}))}return!1}}else e.dispatch(fe({ID:i}));return t}))})),be=Vt(Nt,(async function(t,e){let n=e.extra[0],i=!1;try{await Lt.add(t,n,{context:e.extra.length>1?e.extra[1]:"view"}).then((t=>{i=t.data}))}catch(t){var o;const n=null==t||null===(o=t.response)||void 0===o?void 0:o.data;i=e.rejectWithValue(n)}return i})),we=Vt(kt,(async function(t,e){const n=e.extra[0];return await Lt.updateItem(e.getState().list.ID,t,n).then((e=>{var i;return{...n,post_id:t,item:null==e||null===(i=e.data)||void 0===i?void 0:i.item}}))})),Pe=Vt(Ct,(async function(t,e){const n=e.extra[0],i=e.extra[1],o=n.items[t],s=o.position-t+i;return await Lt.move(n.ID,o.post_id,s).then((e=>({oldIndex:t,newIndex:i})))})),Ne=Vt("list/moveItemNext",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[n.items.length-1].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i+1),await e.dispatch(ve({page:e.getState().listPage})),t})),ke=Vt("list/moveItemPrev",(async function(t,e){const n=e.getState().list,i=parseInt(n.items[0].position,10);if(isNaN(i))throw alert("positions error!"),"positions error!";const o=n.items[t];return await Lt.move(n.ID,o.post_id,i-1),await e.dispatch(ve({page:e.getState().listPage})),t}));function Ce(t,e){!t.data.items_page&&t.headers.get("x-wp-page")?(e(_e(parseInt(t.headers.get("x-wp-page"),10))),e(me(parseInt(t.headers.get("X-WP-TotalPages"),10)))):t.data.items_page&&(e(_e(parseInt(t.data.items_page["X-WP-Page"],10))),e(me(parseInt(t.data.items_page["X-WP-TotalPages"],10))))}const xe=function(t){const{state:e,dispatch:n}=Z(zt);return d(_,null,d("ul",{className:"mg-upc-dg-list-of-lists-fake mg-upc-dg-on-loading"},[0,1,2].map((t=>d("li",{className:"mg-upc-dg-item-list"},d("div",null,d(Zt,{width:"1.5em",height:"1.5em"})),d("div",{className:"mg-upc-dg-item-title"},d(Zt,null)),d("div",{className:"mg-upc-dg-item-count"},d(Zt,null)))))),d("ul",{className:"mg-upc-dg-list-of-lists"},t.lists&&t.lists.map((e=>d(Yt,{list:e,onClick:()=>t.onSelect(e),onRemove:t.onRemove,key:e.ID})))),e.totalPages>1&&d(ie,{totalPages:e.totalPages,page:e.page,onPreview:t.loadPreview,onNext:t.loadNext}))},Ie=function(t){var e,n,i;const[o,s]=X(!1),[a,r]=X(""),l=z({});return G((()=>{r(t.item.description)}),[t.item]),G((()=>{o&&l.current.focus()}),[o]),d(_,null,d("span",null,d("br",null),"Adding item:"),d("div",{className:"mg-upc-dg-item mg-upc-dg-item-adding","data-post_id":t.item.post_id},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null," "),d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t}),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:null===(e=t.item)||void 0===e?void 0:e.link},null===(n=t.item)||void 0===n?void 0:n.title),!o&&d("p",null,null===(i=t.item)||void 0===i?void 0:i.description),!o&&d("button",{onClick:()=>{s(!0)}},""===a&&d("span",null,at("Add Comment")),""!==a&&d("span",null,at("Edit Comment"))),d("input",{ref:l,className:o?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:a,onChange:function(t){r(t.target.value)},maxLength:400}),o&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{s(!1),r(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),o&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{s(!1),t.onSaveItemDescription(a)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))))),d("span",null,at("Select where the item will be added:")))};function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Se.apply(this,arguments)}function Te(t,e){for(var n in t)if("__source"!==n&&!(n in e))return!0;for(var i in e)if("__source"!==i&&t[i]!==e[i])return!0;return!1}function Ae(t){this.props=t}(Ae.prototype=new m).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(t,e){return Te(this.props,t)||Te(this.state,e)};var Ee=e.__b;e.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Ee&&Ee(t)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Le=e.__e;e.__e=function(t,e,n,i){if(t.then)for(var o,s=e;s=s.__;)if((o=s.__c)&&o.__c)return null==e.__e&&(e.__e=n.__e,e.__k=n.__k),o.__c(t,e);Le(t,e,n,i)};var De=e.unmount;function Oe(){this.__u=0,this.t=null,this.__b=null}function je(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Ue(){this.u=null,this.o=null}e.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&!0===t.__h&&(t.type=null),De&&De(t)},(Oe.prototype=new m).__c=function(t,e){var n=e.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var o=je(i.__v),s=!1,a=function(){s||(s=!0,n.__R=null,o?o(r):r())};n.__R=a;var r=function(){if(!--i.__u){if(i.state.__a){var t=i.state.__a;i.__v.__k[0]=function t(e,n,i){return e&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)})),e.__c&&e.__c.__P===n&&(e.__e&&i.insertBefore(e.__e,e.__d),e.__c.__e=!0,e.__c.__P=i)),e}(t,t.__c.__P,t.__c.__O)}var e;for(i.setState({__a:i.__b=null});e=i.t.pop();)e.forceUpdate()}},l=!0===e.__h;i.__u++||l||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(a,a)},Oe.prototype.componentWillUnmount=function(){this.t=[]},Oe.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function t(e,n,i){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(t){"function"==typeof t.__c&&t.__c()})),e.__c.__H=null),null!=(e=function(t,e){for(var n in e)t[n]=e[n];return t}({},e)).__c&&(e.__c.__P===i&&(e.__c.__P=n),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return t(e,n,i)}))),e}(this.__b,n,i.__O=i.__P)}this.__b=null}var o=e.__a&&d(_,null,t.fallback);return o&&(o.__h=null),[d(_,null,e.__a?null:t.children),o]};var Re=function(t,e,n){if(++n[1]===n[0]&&t.o.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.o.size))for(n=t.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.u=n=n[2]}};function We(t){return this.getChildContext=function(){return t.context},t.children}function He(t){var e=this,n=t.i;e.componentWillUnmount=function(){D(null,e.l),e.l=null,e.i=null},e.i&&e.i!==n&&e.componentWillUnmount(),t.__v?(e.l||(e.i=n,e.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(t){this.childNodes.push(t),e.i.appendChild(t)},insertBefore:function(t,n){this.childNodes.push(t),e.i.appendChild(t)},removeChild:function(t){this.childNodes.splice(this.childNodes.indexOf(t)>>>1,1),e.i.removeChild(t)}}),D(d(We,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}(Ue.prototype=new m).__a=function(t){var e=this,n=je(e.__v),i=e.o.get(t);return i[0]++,function(o){var s=function(){e.props.revealOrder?(i.push(o),Re(e,t,i)):o()};n?n(s):s()}},Ue.prototype.render=function(t){this.u=null,this.o=new Map;var e=w(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var n=e.length;n--;)this.o.set(e[n],this.u=[1,0,this.u]);return t.children},Ue.prototype.componentDidUpdate=Ue.prototype.componentDidMount=function(){var t=this;this.o.forEach((function(e,n){Re(t,n,e)}))};var $e="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Me=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Fe="undefined"!=typeof document,Be=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(t)};m.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(t){Object.defineProperty(m.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}));var Qe=e.event;function qe(){}function Ve(){return this.cancelBubble}function Xe(){return this.defaultPrevented}e.event=function(t){return Qe&&(t=Qe(t)),t.persist=qe,t.isPropagationStopped=Ve,t.isDefaultPrevented=Xe,t.nativeEvent=t};var Ke={configurable:!0,get:function(){return this.class}},Ge=e.vnode;e.vnode=function(t){var e=t.type,n=t.props,i=n;if("string"==typeof e){var o=-1===e.indexOf("-");for(var s in i={},n){var a=n[s];Fe&&"children"===s&&"noscript"===e||"value"===s&&"defaultValue"in n&&null==a||("defaultValue"===s&&"value"in n&&null==n.value?s="value":"download"===s&&!0===a?a="":/ondoubleclick/i.test(s)?s="ondblclick":/^onchange(textarea|input)/i.test(s+e)&&!Be(n.type)?s="oninput":/^onfocus$/i.test(s)?s="onfocusin":/^onblur$/i.test(s)?s="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(s)?s=s.toLowerCase():o&&Me.test(s)?s=s.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===a&&(a=void 0),/^oninput$/i.test(s)&&(s=s.toLowerCase(),i[s]&&(s="oninputCapture")),i[s]=a)}"select"==e&&i.multiple&&Array.isArray(i.value)&&(i.value=w(n.children).forEach((function(t){t.props.selected=-1!=i.value.indexOf(t.props.value)}))),"select"==e&&null!=i.defaultValue&&(i.value=w(n.children).forEach((function(t){t.props.selected=i.multiple?-1!=i.defaultValue.indexOf(t.props.value):i.defaultValue==t.props.value}))),t.props=i,n.class!=n.className&&(Ke.enumerable="className"in n,null!=n.className&&(i.class=n.className),Object.defineProperty(i,"className",Ke))}t.$$typeof=$e,Ge&&Ge(t)};var ze=e.__r;e.__r=function(t){ze&&ze(t),t.__c};var Je=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function Ye(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function Ze(t,e){return n=(e||document).querySelectorAll(t),Array.prototype.slice.call(n);var n}function tn(t){(t.querySelector("[autofocus]")||t).focus()}function en(){Ze("[data-a11y-dialog]").forEach((function(t){new Ye(t)}))}Ye.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=Ze('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=Ze("[data-a11y-dialog-hide]",this.$el).concat(Ze('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},Ye.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,tn(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},Ye.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},Ye.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},Ye.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},Ye.prototype.off=function(t,e){var n=(this._listeners[t]||[]).indexOf(e);return n>-1&&this._listeners[t].splice(n,1),this},Ye.prototype._fire=function(t,e){var n=this._listeners[t]||[],i=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(i),n.forEach(function(t){t(this.$el,e)}.bind(this))},Ye.prototype._bindKeypress=function(t){this.$el.contains(document.activeElement)&&(this.shown&&"Escape"===t.key&&"alertdialog"!==this.$el.getAttribute("role")&&(t.preventDefault(),this.hide(t)),this.shown&&"Tab"===t.key&&function(t,e){var n=function(t){return Ze(Je.join(","),t).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(t),i=n.indexOf(document.activeElement);e.shiftKey&&0===i?(n[n.length-1].focus(),e.preventDefault()):e.shiftKey||i!==n.length-1||(n[0].focus(),e.preventDefault())}(this.$el,t))},Ye.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||tn(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",en):window.requestAnimationFrame?window.requestAnimationFrame(en):window.setTimeout(en,16));const nn=t=>{const e=(()=>{const[t,e]=X(!1);return G((()=>e(!0)),[]),t})(),[n,i]=(t=>{const[e,n]=(()=>{const[t,e]=X(null);return[t,Y((t=>{null!==t&&e(new Ye(t))}),[])]})(),i=Y((()=>e.hide()),[e]),o=t.role||"dialog",s="alertdialog"===o,a=t.titleId||t.id+"-title";return G((()=>()=>{e&&e.destroy()}),[e]),[e,{container:{id:t.id,ref:n,role:o,tabIndex:-1,"aria-modal":!0,"aria-hidden":!0,"aria-labelledby":a},overlay:{onClick:s?void 0:i},dialog:{role:"document"},closeButton:{type:"button",onClick:i},title:{role:"heading","aria-level":1,id:a}}]})(t),{dialogRef:o}=t;if(G((()=>(n&&o(n),()=>o(void 0))),[o,n]),!e)return null;const s=t.dialogRoot?document.querySelector(t.dialogRoot):document.body,a=d("h2",Se({},i.title,{className:t.classNames.title,key:"title"}),t.onBack&&d("a",{"aria-label":t.backButtonLabel,href:"#",onClick:e=>{e.preventDefault(),t.onBack(e)}},"←")," ",t.title),r=d("button",Se({},i.closeButton,{className:t.classNames.closeButton,"aria-label":t.closeButtonLabel,key:"button"}),t.closeButtonContent),l=["first"===t.closeButtonPosition&&r,a,t.children,"last"===t.closeButtonPosition&&r].filter(Boolean);return function(t,e){var n=d(He,{__v:t,i:e});return n.containerInfo=e,n}(d("div",Se({},i.container,{className:t.classNames.container}),d("div",Se({},i.overlay,{className:t.classNames.overlay})),d("div",Se({},i.dialog,{className:t.classNames.dialog}),l)),s)};nn.defaultProps={role:"dialog",closeButtonLabel:"Close this dialog window",closeButtonContent:"×",closeButtonPosition:"first",classNames:{},backButtonLabel:"Back",dialogRef:()=>{}},function(t){function e(e,i,o,s){const a=o||s.parent(),r=a.find(".mg-upc-item-vote").attr("disabled",!0);mgUpcApiClient.vote(e,i,{context:"web",posts:n(a)}).then((function(e){t(document.body).trigger("mg_upc_vote_response",[e,a])})).catch((function(t){var e,n;r.attr("disabled",!1),null!==(e=t.response)&&void 0!==e&&null!==(n=e.data)&&void 0!==n&&n.message&&(s?s.append(Qt(t.response.data.message)):a.before(Qt(t.response.data.message)))}))}function n(e){return[...e.children().map((function(){return t(this).data("pid")}))].join(",")}t(".mg-upc-item-vote").on("click",(function(){const n=t(this).data("vote").split(",");return 2===n.length&&e(n[0],n[1],!1,t(this).closest(".mg-upc-item")),!1})),t((function(){t(".mg-upc-vote").each((function(){const n=t(this);e(n.data("id"),0,n.find(".mg-upc-items-container"),!1)}))})),t(document.body).on("mg_upc_vote_response",(function(e,n,i){if(!n.data)return;const o=parseInt(n.data.vote_counter,10),s=i.find(".mg-upc-item-vote");i.data("votes",o),n.data.can_vote?s.attr("disabled",!1).show():s.animate({width:0,padding:0,opacity:0},200,(function(){s.remove()})),n.data.posts.forEach((function(e){const n=i.find(".mg-upc-item[data-pid="+e.post_id+"]"),s=parseInt(e.votes,10);t(document.body).trigger("mg_upc_item_vote_set",[n,s,o])}))})),t(document.body).on("mg_upc_item_vote_set",(function(t,e,n,i){const o=i>0?Math.round(1e3*n/i)/10:0,s=e.find(".mg-upc-votes");s.find(".mg-upc-item-votes-number").html(n),s.find(".mg-upc-item-percent").html(o+"%"),s.find(".mg-upc-item-bar-progress").animate({width:o+"%"}),s.show()}))}(jQuery),function(t){t(".mg-upc-add-product-to-list").on("click",(function(){let e=t(this).data("id");const n=t(this).closest(".product,.summary").find("[name='variation_id']");return n.length>0&&parseInt(n.val(),10)>0&&(e=n.val()),window.addItemToList(e),!1}));const e="mg-upc-btn-loading",n="mg-upc-product-added",i="mg-upc-product-error",o="Sorry, an error occurred.";function s(a,r,l){if(r.hasClass(e))return!1;let c={product_id:r.data("product"),quantity:r.data("quantity")};if("0"==c.quantity){if(!l)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,r,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[r,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){r.removeClass(n+" "+i).addClass(e)},success:function(i){r.removeClass(e),i&&(i.error&&i.product_url?alert(o):(r.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,r])))},error:function(){r.addClass(i).removeClass(e),alert(o)}}),!1}function s(a,r,l){if(r.hasClass(e))return!1;let c={product_id:r.data("product"),quantity:r.data("quantity")};if("0"==c.quantity){if(!l)return!!confirm(at("The quantity is zero! Do you want to add a unit?"))&&s(a,r,!0);c.quantity=1}t(document.body).trigger("adding_to_cart",[r,c]);const u=woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart");return t.ajax({type:"POST",url:u,data:c,beforeSend:function(t){r.removeClass(n+" "+i).addClass(e)},success:function(i){r.removeClass(e),i&&(i.error&&i.product_url?alert(o):(r.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,r])))},error:function(){r.addClass(i).removeClass(e),alert(o)}}),!1}t((function(){if("undefined"==typeof wc_add_to_cart_params)return!1;t(".mg-upc-item-product").removeClass("mg-upc-hide").on("click",(function(e){return s(e,t(this),!1)})),t(".mg-upc-add-list-to-cart").removeClass("mg-upc-hide").on("click",(function(s){const a=t(this);return a.hasClass(e)||(a.removeClass(n+" "+i).addClass(e),window.mgUpcAddListToCart(t(this).data("id")).then((function(i){a.removeClass(e),i.err&&a.before(Qt(Ft(i.err))),i.msg&&a.before(Qt(Ft(i.msg),"success")),a.addClass(n),t(document.body).trigger("added_to_cart",[i.fragments,i.cart_hash,a])})).catch((t=>{var n,i;a.removeClass(e),null!==(n=t.response)&&void 0!==n&&null!==(i=n.data)&&void 0!==i&&i.message?a.before(Qt(Ft(t.response.data.message))):alert(o)}))),!1}))}))}(jQuery);const on=function(t){var e;const[n,i]=X(""),[o,s]=X(""),[a,r]=X(""),[l,c]=X(""),u=J((()=>Wt(t.addingPost)),[t.addingPost]);function p(t){t.default_title&&i(t.default_title),t.default_status&&c(t.default_status),r(t.name)}return""===a&&1===u.length&&p(u[0]),G((()=>{i(t.list.title),s(t.list.content),r(t.list.type),c(t.list.status)}),[t.list]),G((()=>{var t;null!==(t=jt(a))&&void 0!==t&&t.available_statuses&&-1===jt(a).available_statuses.indexOf(l)&&c(jt(a).available_statuses[0])}),[a]),d("div",{className:"mg-list-edit"},-1===t.list.ID&&""===a&&d(_,null,d("label",null,at("Select a list type:")),d("ul",{id:`type-${t.list.ID}`},u.map(((t,e)=>d("li",{className:"mg-upc-dg-item-list-type",key:t.name,onClick:()=>p(t),onKeyPress:e=>{13===e.keyCode&&p(t)},tabIndex:"0"},d("i",{className:"mg-upc-icon mg-upc-dg-item-type mg-upc-dg-item-type-"+t.name}),d("div",{className:"mg-upc-dg-item-title"},d("strong",null,t.label),d("div",{className:"mg-upc-dg-item-desc"},t.description))))))),""!==a&&Ht(a,"editable_title")&&d(_,null,d("label",{htmlFor:`title-${t.list.ID}`},at("Title")),d("input",{id:`title-${t.list.ID}`,type:"text",value:n,onChange:function(t){i(t.target.value)},maxLength:100})),""!==a&&Ht(a,"editable_content")&&d(_,null,d("label",{htmlFor:`content-${t.list.ID}`},at("Description")),d("textarea",{id:`content-${t.list.ID}`,value:o,onChange:function(t){s(t.target.value)},maxLength:500}),d("span",{className:"mg-upc-dg-list-desc-edit-count"},d("i",null,null==o?void 0:o.length),"/500")),""!==a&&!jt(a)&&d("span",null,at("Unknown List Type...")),""!==a&&(null===(e=jt(a))||void 0===e?void 0:e.available_statuses)&&jt(a).available_statuses.length>1&&d(_,null,d("label",{htmlFor:`status-${t.list.ID}`},at("Status")),d("select",{id:`status-${t.list.ID}`,value:l,onChange:function(t){c(t.target.value)}},jt(a).available_statuses.map(((t,e)=>{if(function(t){const e=Ut(t);return e&&e.show_in_status_list}(t))return d("option",{value:t},function(t){const e=Ut(t);return e?e.label:t}(t))})))),""!==a&&jt(a)&&d("div",{className:"mg-upc-dg-edit-actions"},d("button",{onClick:()=>t.onSave({title:n,content:o,type:a,status:l})},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save"))),d("button",{onClick:()=>t.onCancel()},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel")))))},sn=function(t){var e;const[n,i]=X(!1),[o,s]=X(""),[a,r]=X(null===(e=t.item)||void 0===e?void 0:e.quantity),l=z({});G((()=>{s(t.item.description)}),[t.item]),G((()=>{n&&l.current.focus()}),[n]);const c=z(!1);return G((()=>{t.item.quantity!==a&&(clearTimeout(c.current),c.current=setTimeout((function(){t.onSaveItemQuantity(a)}),600))}),[a]),d("li",{className:"mg-upc-dg-item","data-post_id":t.item.post_id},Rt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle","aria-draggable":!0},"::"),d("span",{className:"mg-upc-dg-item-number"},t.item.position)),Rt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number"},(()=>{const e=parseInt(t.list.vote_counter,10);return Rt(t.list,"vote")&&e>0?Math.round(100*parseInt(t.item.votes,10)/e)+"%":"0%"})())),d("a",{href:t.item.link},d("img",{className:"mg-upc-dg-item-image",src:t.item.image?t.item.image:$t})),d("div",{className:"mg-upc-dg-item-data"},d("a",{href:t.item.link},t.item.title),t.item.price_html&&d("span",{className:"mg-upc-dg-price",dangerouslySetInnerHTML:{__html:t.item.price_html}}),t.item.stock_html&&d("span",{className:"mg-upc-dg-stock",dangerouslySetInnerHTML:{__html:t.item.stock_html}}),t.editable&&!n&&d("p",null,t.item.description),t.editable&&!n&&Rt(t.list,"editable_item_description")&&d("button",{onClick:()=>{i(!0)}},d("span",{className:"mg-upc-icon upc-font-edit"}),""===o&&d("span",null,at("Add Comment")),""!==o&&d("span",null,at("Edit Comment"))),d("input",{ref:l,className:n?"mg-upc-dg-btn-item-desc":"mg-upc-dg-dn",type:"text",value:o,onChange:function(t){s(t.target.value)},maxLength:400}),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-cancel",onClick:()=>{i(!1),s(t.item.description)}},d("span",{className:"mg-upc-icon upc-font-close"}),d("span",null,at("Cancel"))),t.editable&&n&&d("button",{className:"mg-upc-dg-btn-item-desc-save",onClick:()=>{i(!1),t.onSaveItemDescription(o)}},d("span",{className:"mg-upc-icon upc-font-save"}),d("span",null,at("Save")))),t.editable&&Rt(t.list,"quantity")&&d("div",{className:"mg-upc-dg-quantity"},d("small",null,at("Quantity")),d("input",{"aria-label":at("Quantity"),type:"number",value:a,onChange:function(){r(event.target.value)}})),t.editable&&!n&&d("div",null,d("button",{"aria-label":"Remove item",onClick:t.onRemove},d("span",{className:"mg-upc-icon upc-font-trash"}))))},an=function(t){return new Promise((function(e,n){const i=document.createElement("script");let o=!1;i.type="text/javascript",i.src=t,i.async=!0,i.onerror=function(t){n(t,i)},i.onload=i.onreadystatechange=function(){o||this.readyState&&"complete"!=this.readyState||(o=!0,setTimeout((function(){e()}),100))},(document.head||document.body||document.documentElement).appendChild(i)}))},rn=function(t){var e,n,i;const o=z(null),s=z((e=>{t.onMove(e)}));return G((()=>{s.current=t.onMove})),G((()=>{let e=!1;if(Rt(t.list,"sortable")){const t=()=>{e=Sortable.create(o.current,{handle:".mg-upc-dg-item-handle",group:"shared",animation:150,onUpdate:function(t){s.current(t)}})};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy()}})),d(_,null,d("ul",{className:"mg-upc-dg-list-fake mg-upc-dg-on-loading"},[0,1,2].map((e=>d("li",{className:"mg-upc-dg-item"},Rt(t.list,"sortable")&&d(_,null,d("span",{className:"mg-upc-dg-item-handle-skeleton"}," ",d(Zt,{width:"1.5em"})," "),d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),Rt(t.list,"vote")&&d(_,null,d("span",{className:"mg-upc-dg-item-number-skeleton"}," ",d(Zt,{width:"1em"})," ")),d("div",{className:"mg-upc-dg-item-skeleton-image"},d(Zt,{width:"5em",height:"5em"})),d("div",{className:"mg-upc-dg-item-data"},d(Zt,{count:2})))))),d("ul",{ref:o,className:"mg-upc-dg-list"},0===(null==t||null===(e=t.items)||void 0===e?void 0:e.length)&&d("span",null,"There are no items in this list"),(null==t||null===(n=t.items)||void 0===n?void 0:n.length)>0&&(null===(i=t.items)||void 0===i?void 0:i.map)&&t.items.map((e=>d(sn,{list:t.list,item:e,editable:t.editable,onRemove:()=>t.onRemove(t.list,e),onSaveItemDescription:n=>t.onSaveItemDescription(t.list,e,n),onSaveItemQuantity:n=>t.onSaveItemQuantity(t.list,e,n),key:e.ID+":"+e.post_id})))),Rt(t.list,"vote")&&d("span",{className:"mg-upc-dg-total-votes"}," ",at("Total votes:")," ",d("span",null," ",t.list.vote_counter)))},ln=function(t){const e=z(null),n=z(null),i=at("Copy"),[o,s]=X(i);G((()=>{let t=null;o!==i&&(t=setTimeout((()=>{s(i),clearTimeout(t)}),2e3))}),[o]);const a=encodeURIComponent(t.link),r=encodeURIComponent(t.title);let l=[{name:"Twitter",url:"https://twitter.com/share?url="+a+"&text="+r},{name:"Facebook",url:"https://www.facebook.com/sharer/sharer.php?u="+a+""e="+r},{name:"Pinterest",url:"https://pinterest.com/pin/create/button/?url="+a+"&description="+r},{name:"Whatsapp",url:"whatsapp://send?text="+a},{name:"Telegram",url:"https://t.me/share/url?url="+a+"&text="+r},{name:"LiNE",url:"https://social-plugins.line.me/lineit/share?url="+a+"&text="+r},{slug:"email",name:at("Email"),url:"mailto:?subject="+r+"&body="+a}];return void 0!==Dt().shareButtons&&(l=l.filter((t=>Dt().shareButtons.includes(t.slug||t.name.toLowerCase())))),d("div",{className:"mg-upc-dg-share-link"},d("input",{ref:e,value:t.link,onClick:function(){e.current.setSelectionRange(0,e.current.value.length)},readOnly:!0}),d("button",{ref:n,onClick:function(t){var n;(n=e.current).focus(),n.setSelectionRange(0,n.value.length),document.execCommand&&document.execCommand("copy")?s(at("Copied!")):s("Error!")}},d("span",{className:"mg-upc-icon upc-font-copy"}),d("span",null,o)),l.map((function(t){return(e=t).slug||(e.slug=e.name.toLowerCase()),d("a",{href:e.url,title:"Share with "+e.name,className:"mg-upc-dg-share",target:"_blank",rel:"noopener"},d("div",{className:"mg-upc-share-btn-img mg-upc-share-"+e.slug}," "));var e})))},cn=function(t){var e;const{state:n,dispatch:i}=Z(zt),[o,s]=X(!1),a=z(!1),r=z(!1);function l(t){t<1||t>n.listTotalPages||"loading"===n.status||i(ve({page:t}))}return G((()=>{const t=n.list;let e=!1,o=!1;if(t&&Rt(t,"sortable")){const t=()=>{a.current&&n.listPage<n.listTotalPages&&(e=Sortable.create(a.current,{group:"shared",onAdd:t=>{i(Ne(t.oldIndex))}})),a.current&&n.listPage>1&&(o=Sortable.create(r.current,{group:"shared",onAdd:t=>{i(ke(t.oldIndex))}}))};"undefined"!=typeof Sortable?t():an(Ot()).then((()=>{t()}))}return()=>{e&&e.destroy(),o&&o.destroy()}}),[n.list,n.listPage,n.listTotalPages]),G((()=>{s(!1)}),[n.editing,n.list,n.addingPost]),d(_,null,n.editing&&d(on,{list:n.list,addingPost:n.addingPost,onSave:function(t){if(-1===n.list.ID||t.title!==n.list.title||t.content!==n.list.content||t.status!==n.list.status)if(-1===n.list.ID){var e;const o={};o.title=t.title,o.content=t.content,o.type=t.type,o.status=t.status,null!==(e=n.addingPost)&&void 0!==e&&e.post_id&&(o.adding=n.addingPost.post_id),i(he(o))}else{const e={id:n.list.ID};t.status!==n.list.status&&(e.status=t.status),t.title!==n.list.title&&(e.title=t.title),t.content!==n.list.content&&(e.content=t.content),i(ge(e))}},onCancel:function(){i(ae(!1)),-1===n.list.ID&&(i(fe(!1)),i(oe()),i(le()))}}),!n.editing&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},function(t){var e,n;const i=t.type;return Ht(i,"editable_title")||Ht(i,"editable_content")||(null===(e=jt(i))||void 0===e||null===(n=e.available_statuses)||void 0===n?void 0:n.length)>1}(n.list)&&d("button",{className:"mg-upg-edit",onClick:()=>i(ae(!0))},d("span",{className:"mg-upc-icon upc-font-edit"}),d("span",null,at("Edit"))),n.list.link&&d("button",{className:"mg-upg-share",onClick:()=>s(!o)},d("span",{className:"mg-upc-icon upc-font-share"}),d("span",null,at("Share"))),"cart"===n.list.type&&d("button",{className:"mg-upg-share",onClick:function(){i(re(n.list.ID))}},d("span",{className:"mg-upc-icon upc-font-cart"}),d("span",null,at("Add all to cart")))),o&&n.list.link&&d(ln,{link:n.list.link,title:n.list.title}),n.list.content&&d("p",{className:"mg-upc-dg-list-desc",dangerouslySetInnerHTML:{__html:Ft(n.list.content)}}),d(Zt,{count:3}),d(rn,{list:n.list,items:(null===(e=n.list)||void 0===e?void 0:e.items)||[],onMove:function(t){i(Pe(t.oldIndex,n.list,t.newIndex))},onRemove:function(t,e){i(ye(e.post_id))},onSaveItemDescription:function(t,e,n){i(we(e.post_id,{description:n}))},onSaveItemQuantity:function(t,e,n){i(we(e.post_id,{quantity:n}))},editable:t.editable})),(!n.editing||!n.list)&&n.listTotalPages>1&&d(ie,{totalPages:n.listTotalPages,page:n.listPage,onPreview:function(){l(n.listPage-1)},onNext:function(){l(n.listPage+1)},prevRef:r,nextRef:a}))};function un(t){return parseInt(t.author,10)===parseInt(Dt().user_id,10)}function dn(){"replaceState"in history?(history.replaceState("",document.title,location.pathname),history.go(-1)):location.hash=""}D(d((t=>{const[e,n]=K(qt,Gt);return d(zt.Provider,{value:{state:e,dispatch:Kt(n,(()=>e))}},t.children)}),null,d((function(){const{state:t,dispatch:e}=Z(zt),n=J((()=>Wt(t.addingPost)),[t.addingPost]),i=z(!1);let o="listOfList";if(t.addingPost)o=t.editing?"addingToNew":"adding";else if(t.editing){var s;o=-1!==(null===(s=t.list)||void 0===s?void 0:s.ID)?"edit":"new"}else o=t.list?"list":"listOfList";const a={container:"mg-upc-dg-container",overlay:"mg-upc-dg-overlay",dialog:"mg-upc-dg-content"+(t.errorCode?" mg-upc-err-"+t.errorCode:""),title:"mg-upc-dg-title",closeButton:"mg-upc-dg-close"};G((()=>{window.showMyLists=function(){r()},window.addItemToList=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"view";e(oe()),n?(e(be(n,t,o)),i.current.show()):l(t)},window.removeItemFromList=function(t,n){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"view";e(oe()),e(ye(t,n,o)),i.current.show()},window.mgUpcAddListToCart=Bt}),[i.current,e]);const r=()=>{e(oe()),e(le()),i.current.show()},l=t=>{e(se({post_id:t})),e(le({addingPost:t})),i.current.show()};function c(n){n<1||n>t.totalPages||"loading"===t.status||e(de(n))}const u="list"===o||"new"===o||"edit"===o||"addingToNew"===o;return d(nn,{id:"mg-upc-dg-dialog",dialogRef:function(t){i.current=t},title:t.title,classNames:a,onBack:!!u&&function(){switch(o){case"list":default:r();break;case"new":e(fe(!1)),e(ae(!1)),r();break;case"edit":e(ae(!1));break;case"addingToNew":e(fe(!1)),e(ae(!1)),e(le({addingPost:t.addingPost.post_id}))}}},d("div",{className:"mg-upc-dg-content-wrapper mg-upc-dg-status-"+t.status+" mg-upc-dg-view-"+o},d("div",{className:"mg-upc-dg-wait"}),t.message&&d("div",{className:"mg-upc-dg-msg"},t.message,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:ct,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),t.error&&d("div",{className:"mg-upc-dg-error"},t.error,d("a",{href:"#",className:"mg-upc-dg-alert-close","aria-label":"Hide alert",onClick:t=>{t.preventDefault(),e({type:lt,payload:null})}},d("span",{className:"mg-upc-icon upc-font-close"}))),d("div",{className:"mg-upc-dg-body"},!t.error&&t.addingPost&&d(Ie,{item:t.addingPost,onSaveItemDescription:function(n){e(se({...t.addingPost,description:n}))}}),("listOfList"===o||"adding"===o)&&d(_,null,d("div",{className:"mg-upc-dg-top-action"},n.length>0&&!t.error&&d("button",{className:"mg-list-new",onClick:function(t){e(ae(!0)),e(fe(!0)),i.current.show()}},d("span",{className:"mg-upc-icon upc-font-add"}),d("span",null,at("Create List")))),d(xe,{lists:t.listOfList,onSelect:function(n){e(ae(!1)),t.addingPost?e(be(n.ID,t.addingPost)):(e(fe(n)),i.current.show())},onRemove:!t.addingPost&&function(t){e(ue(t.ID))},loadPreview:function(){c(t.page-1)},loadNext:function(){c(t.page+1)}})),t.list&&d(cn,{editable:un(t.list)}))))}),null)," "),document.querySelector("body")),"#my-lists"===location.hash&&dn(),window.addEventListener("hashchange",(function(){"#my-lists"===location.hash&&(window.showMyLists(),dn())}),!1),window.mgUpcApiClient=Lt,window.mgUpcListeners=function(){jQuery(".mg-upc-post-add").on("click",(function(){return jQuery(this).data("post-id")>0&&window.addItemToList(jQuery(this).data("post-id"),(jQuery(this).data("upc-list")+"").length>0&&jQuery(this).data("upc-list")),!1})),jQuery(".mg-upc-post-remove").on("click",(function(){return jQuery(this).data("post-id")>0&&void 0!==jQuery(this).data("upc-list")&&window.removeItemFromList(jQuery(this).data("post-id"),(jQuery(this).data("upc-list")+"").length>0&&jQuery(this).data("upc-list")),!1}))},window.mgUpcListeners()})(); -
user-post-collections/trunk/readme.txt
r2770186 r2783097 6 6 Tags: User lists, Post Collections, Woocommerce Wishlist 7 7 Tested up to: 6.0 8 Stable tag: 0.8. 298 Stable tag: 0.8.30 9 9 Requires PHP: 7.0 10 10 … … 68 68 == Changelog == 69 69 70 = 0.8.30 = 71 * Add some themes helper 72 70 73 = 0.8.29 = 71 74 * Update preact -
user-post-collections/trunk/user-post-collections.php
r2770186 r2783097 4 4 Plugin URI: https://galetto.info/user-post-collections 5 5 Description: Allows users to create their post collections. 6 Version: 0.8. 296 Version: 0.8.30 7 7 Author: Mauricio Galetto 8 8 Author URI: https://galetto.info/ … … 67 67 require_once __DIR__ . '/includes/mg-upc-texts.php'; 68 68 require_once __DIR__ . '/includes/mg-upc-settings-api.php'; 69 require_once __DIR__ . '/includes/themes-helper.php'; 69 70 70 71 require_once __DIR__ . '/classes/Exceptions/mg-upc-item-exist-exception.php';
Note: See TracChangeset
for help on using the changeset viewer.