/*! For license information please see 1042.js.LICENSE.txt */
"use strict";(self.webpackChunk_aidoop_aidoop_r=self.webpackChunk_aidoop_aidoop_r||[]).push([[1042],{81042:(t,e,r)=>{r.r(e),r.d(e,{BoardTemplateListPage:()=>m});var n=r(50493),o=r(68784),i=r(15633),a=r(77675),s=r(94430),u=r(56765),l=r(69292),c=r(27805),d=r(53421),p=r(37077),f=r(64312),h=r(28120),g=r(16682),y=r(44648);let m=class extends((0,h.$)(a.h)((0,d.NC)(d.z2)((0,l.f)(a.B4)))){get context(){var t;return{title:d.z2.t("title.board-template list"),search:{handler:t=>{this.grist.searchText=t},value:(null===(t=this.grist)||void 0===t?void 0:t.searchText)||""},filter:{handler:()=>{this.grist.toggleHeadroom()}},help:"board-service/board-template",actions:[Object.assign({title:d.z2.t("button.save"),action:this._updateBoardTemplate.bind(this)},i.jO.save),Object.assign({title:d.z2.t("button.delete"),action:this._deleteBoardTemplate.bind(this)},i.jO.delete)]}}render(){return s.dy`
      <ox-grist mode="CARD" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
        <div slot="headroom">
          <div id="filters">
            <ox-filters-form autofocus></ox-filters-form>
          </div>

          <div id="sorters">
            Sort
            <mwc-icon
              @click=${t=>{const e=t.currentTarget;this.sortersControl.open({right:0,top:e.offsetTop+e.offsetHeight})}}
              >expand_more</mwc-icon
            >
            <ox-popup id="sorter-control">
              <ox-sorters-control> </ox-sorters-control>
            </ox-popup>
          </div>
        </div>
      </ox-grist>
    `}async pageInitialized(t){this.gristConfig={list:{fields:["name","description"],details:["active","updatedAt"]},columns:[{type:"gutter",gutterName:"sequence"},{type:"gutter",gutterName:"row-selector",multiple:!0},{type:"string",name:"name",header:d.z2.t("field.name"),record:{editable:!0},filter:"search",sortable:!0,width:150},{type:"string",name:"description",header:d.z2.t("field.description"),record:{editable:!0},filter:"search",width:200},{type:"resource-object",name:"updater",header:d.z2.t("field.updater"),record:{editable:!1},sortable:!0,width:120},{type:"datetime",name:"updatedAt",header:d.z2.t("field.updated_at"),record:{editable:!1},sortable:!0,width:180}],rows:{selectable:{multiple:!0}},sorters:[{name:"name"}]}}async pageUpdated(t,e){this.active}async fetchHandler({page:t=1,limit:e=100,sortings:r=[],filters:n=[]}){const o=await c.Lp.query({query:g.ZP`
        query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
          responses: boardTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {
            items {
              id
              name
              description
              state
              model
              thumbnail
              updater {
                id
                name
              }
              updatedAt
            }
            total
          }
        }
      `,variables:{filters:n,pagination:{page:t,limit:e},sortings:r}});return{total:o.data.responses.total||0,records:o.data.responses.items||[]}}async _deleteBoardTemplate(){if(confirm(d.z2.t("text.sure_to_x",{x:d.z2.t("text.delete")}))){const t=this.grist.selected.map((t=>t.id));if(t&&t.length>0){const[e,{error:r}]=(0,y.D)("\nmutation ($ids: [String!]!) {\n  deleteBoardTemplates(ids: $ids)\n}");e({variables:{ids:t}}),r||(this.grist.fetch(),(0,p.h4)({message:d.z2.t("text.info_x_successfully",{x:d.z2.t("text.delete")})}))}}}async _updateBoardTemplate(){let t=this.grist.dirtyRecords;if(t&&t.length){t=t.map((t=>{let e=t.id?{id:t.id}:{};const r=t.__dirtyfields__;for(let t in r)e[t]=r[t].after;return e.cuFlag=t.__dirty__,e}));const[e,{error:r}]=(0,y.D)("\nmutation ($patches: [BoardTemplatePatch!]!) {\n  updateMultipleBoardTemplate(patches: $patches) {\n    name\n  }\n}");e({variables:{patches:t}}),r||this.grist.fetch()}}};m.styles=[i.Ix,i.Pn,s.iv`
      :host {
        display: flex;

        width: 100%;

        --grid-record-emphasized-background-color: red;
        --grid-record-emphasized-color: yellow;
      }
    `],(0,n.gn)([(0,u.Cb)({type:Object}),(0,n.w6)("design:type",Object)],m.prototype,"gristConfig",void 0),(0,n.gn)([(0,u.IO)("ox-grist"),(0,n.w6)("design:type",o.Nw)],m.prototype,"grist",void 0),(0,n.gn)([(0,u.IO)("#sorter-control"),(0,n.w6)("design:type",f.WP)],m.prototype,"sortersControl",void 0),m=(0,n.gn)([(0,u.Mo)("board-template-list-page")],m)},4619:(t,e)=>{var r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),u=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,y={};function m(t,e,r){this.props=t,this.context=e,this.refs=y,this.updater=r||h}function v(){}function b(t,e,r){this.props=t,this.context=e,this.refs=y,this.updater=r||h}m.prototype.isReactComponent={},m.prototype.setState=function(t,e){if("object"!=typeof t&&"function"!=typeof t&&null!=t)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},m.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},v.prototype=m.prototype;var _=b.prototype=new v;_.constructor=b,g(_,m.prototype),_.isPureReactComponent=!0;var k=Array.isArray,x=Object.prototype.hasOwnProperty,w={current:null},S={key:!0,ref:!0,__self:!0,__source:!0};function C(t,e,n){var o,i={},a=null,s=null;if(null!=e)for(o in void 0!==e.ref&&(s=e.ref),void 0!==e.key&&(a=""+e.key),e)x.call(e,o)&&!S.hasOwnProperty(o)&&(i[o]=e[o]);var u=arguments.length-2;if(1===u)i.children=n;else if(1<u){for(var l=Array(u),c=0;c<u;c++)l[c]=arguments[c+2];i.children=l}if(t&&t.defaultProps)for(o in u=t.defaultProps)void 0===i[o]&&(i[o]=u[o]);return{$$typeof:r,type:t,key:a,ref:s,props:i,_owner:w.current}}function $(t){return"object"==typeof t&&null!==t&&t.$$typeof===r}var j=/\/+/g;function O(t,e){return"object"==typeof t&&null!==t&&null!=t.key?function(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,(function(t){return e[t]}))}(""+t.key):e.toString(36)}function M(t,e,o,i,a){var s=typeof t;"undefined"!==s&&"boolean"!==s||(t=null);var u=!1;if(null===t)u=!0;else switch(s){case"string":case"number":u=!0;break;case"object":switch(t.$$typeof){case r:case n:u=!0}}if(u)return a=a(u=t),t=""===i?"."+O(u,0):i,k(a)?(o="",null!=t&&(o=t.replace(j,"$&/")+"/"),M(a,e,o,"",(function(t){return t}))):null!=a&&($(a)&&(a=function(t,e){return{$$typeof:r,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}(a,o+(!a.key||u&&u.key===a.key?"":(""+a.key).replace(j,"$&/")+"/")+t)),e.push(a)),1;if(u=0,i=""===i?".":i+":",k(t))for(var l=0;l<t.length;l++){var c=i+O(s=t[l],l);u+=M(s,e,o,c,a)}else if(c=function(t){return null===t||"object"!=typeof t?null:"function"==typeof(t=f&&t[f]||t["@@iterator"])?t:null}(t),"function"==typeof c)for(t=c.call(t),l=0;!(s=t.next()).done;)u+=M(s=s.value,e,o,c=i+O(s,l++),a);else if("object"===s)throw e=String(t),Error("Objects are not valid as a React child (found: "+("[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return u}function T(t,e,r){if(null==t)return t;var n=[],o=0;return M(t,n,"","",(function(t){return e.call(r,t,o++)})),n}function z(t){if(-1===t._status){var e=t._result;(e=e()).then((function(e){0!==t._status&&-1!==t._status||(t._status=1,t._result=e)}),(function(e){0!==t._status&&-1!==t._status||(t._status=2,t._result=e)})),-1===t._status&&(t._status=0,t._result=e)}if(1===t._status)return t._result.default;throw t._result}var P={current:null},E={transition:null};e.createContext=function(t){return(t={$$typeof:u,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:s,_context:t},t.Consumer=t},e.useCallback=function(t,e){return P.current.useCallback(t,e)},e.useContext=function(t){return P.current.useContext(t)},e.useEffect=function(t,e){return P.current.useEffect(t,e)},e.useRef=function(t){return P.current.useRef(t)},e.useState=function(t){return P.current.useState(t)}},44529:(t,e,r)=>{t.exports=r(4619)},44648:(t,e,r)=>{r.d(e,{D:()=>g});var n,o=r(50493),i=r(44529),a=r(19611),s=r(16361),u=r(33438);!function(t){t[t.Query=0]="Query",t[t.Mutation=1]="Mutation",t[t.Subscription=2]="Subscription"}(n||(n={}));var l=new Map;function c(t){var e;switch(t){case n.Query:e="Query";break;case n.Mutation:e="Mutation";break;case n.Subscription:e="Subscription"}return e}function d(t,e){var r=function(t){var e,r,o=l.get(t);if(o)return o;(0,u.kG)(!!t&&!!t.kind,59,t);for(var i=[],a=[],s=[],c=[],d=0,p=t.definitions;d<p.length;d++){var f=p[d];if("FragmentDefinition"!==f.kind){if("OperationDefinition"===f.kind)switch(f.operation){case"query":a.push(f);break;case"mutation":s.push(f);break;case"subscription":c.push(f)}}else i.push(f)}(0,u.kG)(!i.length||a.length||s.length||c.length,60),(0,u.kG)(a.length+s.length+c.length<=1,61,t,a.length,c.length,s.length),r=a.length?n.Query:n.Mutation,a.length||s.length||(r=n.Subscription);var h=a.length?a:s.length?s:c;(0,u.kG)(1===h.length,62,t,h.length);var g=h[0];e=g.variableDefinitions||[];var y={name:g.name&&"Name"===g.name.kind?g.name.value:"data",type:r,variables:e};return l.set(t,y),y}(t),o=c(e),i=c(r.type);(0,u.kG)(r.type===e,63,o,o,i)}var p=r(93869),f=r(42860).aS?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function h(){(0,u.kG)(!0,45);var t=i.createContext[f];return t||(Object.defineProperty(i.createContext,f,{value:t=i.createContext({}),enumerable:!1,writable:!1,configurable:!0}),t.displayName="ApolloContext"),t}function g(t,e){var r=function(t){var e=i.useContext(h()),r=t||e.client;return(0,u.kG)(!!r,49),r}(null==e?void 0:e.client);d(t,n.Mutation);var l=i.useState({called:!1,loading:!1,client:r}),c=l[0],f=l[1],g=i.useRef({result:c,mutationId:0,isMounted:!0,client:r,mutation:t,options:e});Object.assign(g.current,{client:r,options:e,mutation:t});var y=i.useCallback((function(t){void 0===t&&(t={});var e=g.current,r=e.options,n=e.mutation,i=(0,o.pi)((0,o.pi)({},r),{mutation:n}),u=t.client||g.current.client;g.current.result.loading||i.ignoreResults||!g.current.isMounted||f(g.current.result={loading:!0,error:void 0,data:void 0,called:!0,client:u});var l=++g.current.mutationId,c=(0,a.J)(i,t);return u.mutate(c).then((function(e){var r,n,o=e.data,i=e.errors,a=i&&i.length>0?new p.cA({graphQLErrors:i}):void 0,d=t.onError||(null===(r=g.current.options)||void 0===r?void 0:r.onError);if(a&&d&&d(a,c),l===g.current.mutationId&&!c.ignoreResults){var h={called:!0,loading:!1,data:o,error:a,client:u};g.current.isMounted&&!(0,s.D)(g.current.result,h)&&f(g.current.result=h)}var y=t.onCompleted||(null===(n=g.current.options)||void 0===n?void 0:n.onCompleted);return a||null==y||y(e.data,c),e})).catch((function(e){var r;if(l===g.current.mutationId&&g.current.isMounted){var n={loading:!1,error:e,data:void 0,called:!0,client:u};(0,s.D)(g.current.result,n)||f(g.current.result=n)}var o=t.onError||(null===(r=g.current.options)||void 0===r?void 0:r.onError);if(o)return o(e,c),{data:void 0,errors:e};throw e}))}),[]),m=i.useCallback((function(){g.current.isMounted&&f({called:!1,loading:!1,client:r})}),[]);return i.useEffect((function(){return g.current.isMounted=!0,function(){g.current.isMounted=!1}}),[]),[y,(0,o.pi)({reset:m},c)]}}}]);